@retion-miniapp/react-native 0.20.0 → 0.20.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/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -842,6 +842,13 @@ type ResolvedTheme = Required<Omit<MiniAppUpdatesTheme, 'kinds' | 'secondary'>>
|
|
|
842
842
|
bg: string;
|
|
843
843
|
}[];
|
|
844
844
|
};
|
|
845
|
+
/** Khai báo trước resolveMiniAppUpdatesTheme — DEFAULT_THEME tính ngay lúc nạp module. */
|
|
846
|
+
declare const MINIAPP_CHANGELOG_KINDS: {
|
|
847
|
+
key: keyof MiniAppChangelog;
|
|
848
|
+
label: string;
|
|
849
|
+
color: string;
|
|
850
|
+
bg: string;
|
|
851
|
+
}[];
|
|
845
852
|
declare const resolveMiniAppUpdatesTheme: (theme?: MiniAppUpdatesTheme, labels?: Partial<MiniAppUpdatesLabels>) => ResolvedTheme;
|
|
846
853
|
/** Bọc UI riêng để MiniAppChangelogGroups / MiniAppChangelogHistory ăn theme của app. */
|
|
847
854
|
declare const MiniAppUpdatesThemeProvider: ({ theme, labels, children }: {
|
|
@@ -850,12 +857,6 @@ declare const MiniAppUpdatesThemeProvider: ({ theme, labels, children }: {
|
|
|
850
857
|
children: ReactNode;
|
|
851
858
|
}) => React.JSX.Element;
|
|
852
859
|
declare const useMiniAppUpdatesTheme: () => ResolvedTheme;
|
|
853
|
-
declare const MINIAPP_CHANGELOG_KINDS: {
|
|
854
|
-
key: keyof MiniAppChangelog;
|
|
855
|
-
label: string;
|
|
856
|
-
color: string;
|
|
857
|
-
bg: string;
|
|
858
|
-
}[];
|
|
859
860
|
declare const mergeMiniAppChangelog: (versions: MiniAppChangelogVersion[]) => MiniAppChangelog;
|
|
860
861
|
/** 1 mục changelog: **đậm**, `code`, [chữ](https://link) — Text lồng nhau, link mở trình duyệt. */
|
|
861
862
|
declare const MiniAppChangelogText: ({ text, style }: {
|
package/dist/index.d.ts
CHANGED
|
@@ -842,6 +842,13 @@ type ResolvedTheme = Required<Omit<MiniAppUpdatesTheme, 'kinds' | 'secondary'>>
|
|
|
842
842
|
bg: string;
|
|
843
843
|
}[];
|
|
844
844
|
};
|
|
845
|
+
/** Khai báo trước resolveMiniAppUpdatesTheme — DEFAULT_THEME tính ngay lúc nạp module. */
|
|
846
|
+
declare const MINIAPP_CHANGELOG_KINDS: {
|
|
847
|
+
key: keyof MiniAppChangelog;
|
|
848
|
+
label: string;
|
|
849
|
+
color: string;
|
|
850
|
+
bg: string;
|
|
851
|
+
}[];
|
|
845
852
|
declare const resolveMiniAppUpdatesTheme: (theme?: MiniAppUpdatesTheme, labels?: Partial<MiniAppUpdatesLabels>) => ResolvedTheme;
|
|
846
853
|
/** Bọc UI riêng để MiniAppChangelogGroups / MiniAppChangelogHistory ăn theme của app. */
|
|
847
854
|
declare const MiniAppUpdatesThemeProvider: ({ theme, labels, children }: {
|
|
@@ -850,12 +857,6 @@ declare const MiniAppUpdatesThemeProvider: ({ theme, labels, children }: {
|
|
|
850
857
|
children: ReactNode;
|
|
851
858
|
}) => React.JSX.Element;
|
|
852
859
|
declare const useMiniAppUpdatesTheme: () => ResolvedTheme;
|
|
853
|
-
declare const MINIAPP_CHANGELOG_KINDS: {
|
|
854
|
-
key: keyof MiniAppChangelog;
|
|
855
|
-
label: string;
|
|
856
|
-
color: string;
|
|
857
|
-
bg: string;
|
|
858
|
-
}[];
|
|
859
860
|
declare const mergeMiniAppChangelog: (versions: MiniAppChangelogVersion[]) => MiniAppChangelog;
|
|
860
861
|
/** 1 mục changelog: **đậm**, `code`, [chữ](https://link) — Text lồng nhau, link mở trình duyệt. */
|
|
861
862
|
declare const MiniAppChangelogText: ({ text, style }: {
|
package/dist/index.js
CHANGED
|
@@ -86,4 +86,4 @@
|
|
|
86
86
|
if (ctx.state === 'running') { play(); } else { ctx.resume().then(play).catch(function () {}); }
|
|
87
87
|
} catch (e) {}
|
|
88
88
|
})(); true;`,Ri=new Set(["selection","impactLight","impactMedium","impactHeavy","rigid","soft","notificationSuccess","notificationWarning","notificationError"]),qt=(e,t)=>{if(typeof e!="string"||!e)throw new m("INVALID_PARAMS",`Thi\u1EBFu ${t}`);return e},lr=async({method:e,params:t},{getHostData:n,getPermissions:o,getContext:r,is_dark:i,close:a,app_id:s,instance_id:c,options:l,emit:u,isActive:d,playBeep:f})=>{var O,x,q,Y,ne,we,H,P;let p=l==null?void 0:l.handlers,y={app_id:s,instance_id:c,close:a},k=()=>{var w;(w=l==null?void 0:l.haptic)==null||w.call(l,"impactLight"),f==null||f()},R=()=>new m("NOT_SUPPORTED",`${e} ch\u01B0a h\u1ED7 tr\u1EE3 \u1EDF \u1EE9ng d\u1EE5ng n\xE0y`);switch(e){case"getCurrentLocation":{let w=ao(t);return bt(e,()=>lo(w,d))}case"speech.start":{if(!u)throw R();let w={};if((t==null?void 0:t.lang)!==void 0){if(typeof t.lang!="string"||!/^[a-zA-Z]{2,8}(-[a-zA-Z0-9]{1,8})*$/.test(t.lang))throw new m("INVALID_PARAMS","lang ph\u1EA3i l\xE0 m\xE3 ng\xF4n ng\u1EEF nh\u01B0 vi-VN");w.lang=t.lang}for(let $ of["continuous","interimResults","addsPunctuation","requiresOnDeviceRecognition"])if((t==null?void 0:t[$])!==void 0){if(typeof t[$]!="boolean")throw new m("INVALID_PARAMS",`${$} ph\u1EA3i l\xE0 boolean`);w[$]=t[$]}if((t==null?void 0:t.mode)!==void 0&&t.mode!=="s2t"&&t.mode!=="voice")throw new m("INVALID_PARAMS","mode ph\u1EA3i l\xE0 's2t' ho\u1EB7c 'voice'");let I=(t==null?void 0:t.mode)==="s2t"?"s2t":"voice",E=I==="voice"?(O=l==null?void 0:l.voice)!=null?O:l==null?void 0:l.speech:void 0;if(Oo(c,E),E){ko(c,E);try{return await E.start({owner:c,app_id:s,mode:I,options:w,emit:u,isActive:d!=null?d:(()=>!0)})}catch($){throw Ro(c,E),$}}return Lo(c,w,u,d)}case"speech.stop":{let w=Fo(c);return w?w.stop(c):Do(c)}case tt.scan:return zo(c,Mn(t),d,k);case tt.start:{if(!u)throw R();return $o(c,Mn(t),u,d,k)}case tt.stop:return Wo(c);case"uploadFiles":{let{task_id:w,...I}=t!=null?t:{};if(w!==void 0&&(typeof w!="string"||!w))throw new m("INVALID_PARAMS","task_id ph\u1EA3i l\xE0 chu\u1ED7i");return Co(yo(I),{instance_id:c,app_id:s,getContext:r,task_id:w,config:l==null?void 0:l.upload,emit:u,exclusivePick:E=>bt("uploadFiles.pick",E)})}case"uploadFiles.cancel":xo(c,t==null?void 0:t.task_id);return;case"getUploadCapabilities":return Mo(l==null?void 0:l.upload);case"getBiometricAvailability":return((x=l==null?void 0:l.biometrics)!=null?x:await fn()).getAvailability();case"authenticateBiometric":{let w=qt(t==null?void 0:t.reason,"reason").trim();if(!w||w.length>200)throw new m("INVALID_PARAMS","reason must contain 1\u2013200 characters");let I=t==null?void 0:t.cancelButtonText;if(I!==void 0&&(typeof I!="string"||!I.trim()||I.length>80))throw new m("INVALID_PARAMS","Invalid cancelButtonText");return bt(e,async()=>{var $;return(($=l==null?void 0:l.biometrics)!=null?$:await fn()).authenticate({reason:w,cancelButtonText:I})})}case"requestPayment":{let w=p==null?void 0:p.requestPayment;if(!w)throw R();let I=t==null?void 0:t.amount;if(typeof I!="number"||!Number.isFinite(I)||I<=0)throw new m("INVALID_PARAMS","amount ph\u1EA3i l\xE0 s\u1ED1 > 0");let E={...t,amount:I,currency:qt(t==null?void 0:t.currency,"currency")};return bt(e,()=>w(E,y))}case"printImage":{let w=p==null?void 0:p.printImage;if(!w)throw R();let I=qt(t==null?void 0:t.image,"image");await bt(e,()=>w({image:I},y));return}case"openScreen":if(!(p!=null&&p.openScreen))throw R();await p.openScreen({screen:qt(t==null?void 0:t.screen,"screen"),params:t==null?void 0:t.params},y);return;case"closeApp":a();return;case"openWebview":{let w=String((q=t==null?void 0:t.url)!=null?q:"");if(!/^https?:\/\//i.test(w))throw new m("INVALID_PARAMS","url ph\u1EA3i l\xE0 http(s)");await(l!=null&&l.openUrl?l.openUrl(w):wt.Linking.openURL(w));return}case"openLink":{let w=String((Y=t==null?void 0:t.url)!=null?Y:"").trim();if(!/^[a-z][a-z0-9+.-]*:/i.test(w)||/^(javascript|file|data|about|blob):/i.test(w))throw new m("INVALID_PARAMS","url kh\xF4ng h\u1EE3p l\u1EC7");try{await(l!=null&&l.openUrl?l.openUrl(w):wt.Linking.openURL(w))}catch(I){throw new m("NOT_SUPPORTED",String((we=(ne=I==null?void 0:I.message)!=null?ne:I)!=null?we:"Kh\xF4ng m\u1EDF \u0111\u01B0\u1EE3c link"))}return}case"showToast":{let w=Po(t);if(!w||(d==null?void 0:d())===!1)return;l!=null&&l.showToast?l.showToast(w.message,{type:w.type}):Eo(w.message,w.type);return}case"haptic":{let w=Ri.has(t==null?void 0:t.type)?t.type:"selection";(H=l==null?void 0:l.haptic)==null||H.call(l,w);return}case"getSystemInfo":return{platform:wt.Platform.OS==="ios"?"ios":"android",appVersion:(P=l==null?void 0:l.app_version)!=null?P:"",theme:i?"dark":"light"};case"getAccessToken":{let w=n().access_token;if(!w)throw new m("HOST_ERROR","Mini app ch\u01B0a c\xF3 token cho page n\xE0y");return w}case"getToken":{let w=t==null?void 0:t.type;if(w==="access"){let $=n().access_token;if(!$)throw new m("HOST_ERROR","Mini app ch\u01B0a c\xF3 token cho page n\xE0y");return $}if(w!=="partner"&&w!=="chatbox")throw new m("HOST_ERROR",`Lo\u1EA1i token kh\xF4ng h\u1EE3p l\u1EC7: ${String(w)}`);let I=ir[w];if(!o().includes(I))throw new m("PERMISSION_DENIED",`Mini app ch\u01B0a \u0111\u01B0\u1EE3c c\u1EA5p quy\u1EC1n ${I} (Console \u2192 Quy\u1EC1n l\u1EA5y token)`);let E=w==="partner"?n().partner_token:n().chatbox_token;if(!E)throw new m("HOST_ERROR",`Kh\xF4ng c\xF3 ${I}`);return E}case"getUserInfo":{let w=n().user;if(!w)throw new m("HOST_ERROR","Kh\xF4ng l\u1EA5y \u0111\u01B0\u1EE3c th\xF4ng tin nh\xE2n vi\xEAn");return w}case"getPageInfo":{let w=n().page;if(!w)throw new m("HOST_ERROR","Kh\xF4ng l\u1EA5y \u0111\u01B0\u1EE3c th\xF4ng tin page");return w}case"sendMessage":case"insertText":throw new m("NOT_SUPPORTED",`${e} ch\u01B0a h\u1ED7 tr\u1EE3 \u1EDF phi\xEAn b\u1EA3n app n\xE0y`);default:throw new m("NOT_SUPPORTED",`API kh\xF4ng t\u1ED3n t\u1EA1i: ${e}`)}};var Rn=e=>`bundle:${e}`,On=()=>`${L().file_system.document_dir}/miniapps`,Fn=On,In=(e,t,n="index.html",o=!1,r=[])=>{let i=`${Fn()}/${e}/${t}`;return{app_id:e,version:t,dir:i,entry_uri:`file://${i}/${n}`,context_update:o,permissions:r}},kn=e=>{var t;L().storage.setString(Rn(e.app_id),JSON.stringify({version:e.version,entry:e.entry,context_update:!!e.context_update,permissions:(t=e.permissions)!=null?t:[]}))},Oi=(e,t)=>/^https?:\/\//.test(t)?t:`${e.replace(/[^/]*$/,"")}${t}`,z=e=>{let t=L().storage.getString(Rn(e));if(!t)return null;try{let{version:n,entry:o,context_update:r,permissions:i}=JSON.parse(t);return In(e,n,o,!!r,Array.isArray(i)?i:[])}catch{return null}},De=e=>L().file_system.exists(e.entry_uri.replace("file://","")),Ln=async e=>{let t=z(e.app_id);return(t==null?void 0:t.version)===e.version&&await De(t)},pr=async(e,t)=>{let n=L().file_system,o=`${Fn()}/${e}`,r=await n.listDir(o).catch(()=>[]);await Promise.all(r.filter(i=>!t.includes(i)).map(i=>n.remove(`${o}/${i}`).catch(()=>{})))},ur=async e=>{var t;await((t=St[e])==null?void 0:t.catch(()=>{})),L().storage.setString(Rn(e),""),await L().file_system.remove(`${Fn()}/${e}`).catch(()=>{})},ot=class extends Error{constructor(){super("cancelled"),this.name="MiniAppInstallCancelled"}},St={},dr=(e,t)=>{var i;let o=((i=St[e])!=null?i:Promise.resolve()).catch(()=>{}).then(t),r=o.catch(()=>{});return St[e]=r,r.then(()=>{St[e]===r&&delete St[e]}),o},Dn=(e,t)=>{var r,i;let n=e.split(".").map(a=>parseInt(a,10)||0),o=t.split(".").map(a=>parseInt(a,10)||0);for(let a=0;a<Math.max(n.length,o.length);a++){let s=((r=n[a])!=null?r:0)-((i=o[a])!=null?i:0);if(s)return s}return 0},gr=({manifest:e,zip_path:t})=>dr(e.app_id,async()=>{var i;let n=L().file_system,o=z(e.app_id);if(o&&Dn(o.version,e.version)>=0&&await De(o))return o;if(e.sha256&&n.sha256&&await n.sha256(t)!==e.sha256)throw new Error("sha256 mismatch");let r=In(e.app_id,e.version,e.entry,!!e.context_update,(i=e.permissions)!=null?i:[]);return await n.remove(r.dir).catch(()=>{}),await n.mkdir(r.dir),await n.unzip(t,r.dir),kn(e),fe("\u0111\xE3 c\xE0i b\u1EA3n \u0111\xF3ng s\u1EB5n",e.app_id,e.version),pr(e.app_id,[e.version,o==null?void 0:o.version].filter(Boolean)),r}),Un=(e,{base_url:t,onProgress:n}={})=>{let o=L().file_system,r=null,i=!1,a=`${o.cache_dir}/${e.app_id}-${e.version}.zip`,s=()=>{if(i)throw new ot},c=async()=>{var d;s();let l=z(e.app_id);if((l==null?void 0:l.version)===e.version&&await o.exists(l.dir))return kn(e),z(e.app_id);s();let u=o.download({url:t?Oi(t,e.bundle_url):e.bundle_url,to_file:a,onProgress:(f,p)=>{var k;let y=p>0?p:(k=e.size)!=null?k:0;y>0&&(n==null||n(Math.min(1,f/y)))}});r=u;try{let{status:f}=await u.promise;if(s(),f!==200)throw new Error(`bundle ${f}`);if(e.sha256)if(o.sha256){if(await o.sha256(a)!==e.sha256)throw new Error("sha256 mismatch")}else fe("b\u1ECF qua ki\u1EC3m tra sha256 (file_system kh\xF4ng c\xF3 sha256)",e.app_id);s();let p=In(e.app_id,e.version,e.entry,!!e.context_update,(d=e.permissions)!=null?d:[]);return await o.remove(p.dir).catch(()=>{}),await o.mkdir(p.dir),await o.unzip(a,p.dir),kn(e),pr(e.app_id,[e.version,l==null?void 0:l.version].filter(Boolean)),p}catch(f){throw i?new ot:f}finally{r=null,o.remove(a).catch(()=>{})}};return{promise:dr(e.app_id,c),cancel:()=>{i=!0,r==null||r.cancel()}}},At={},Fi=__DEV__?0:60*1e3,cr={},hr=(e,t)=>{var o,r;let n=z(e);return n&&Date.now()-((o=cr[t])!=null?o:0)<Fi?Promise.resolve(n):((r=At[e])!=null||(At[e]=(async()=>{let i=await fetch(t,{headers:{"Cache-Control":"no-cache"}});if(!i.ok)throw new Error(`manifest ${i.status}`);let a=await i.json(),s=await Un(a,{base_url:t}).promise;return cr[t]=Date.now(),s})().catch(i=>(console.warn("[miniapp] sync failed",e,i==null?void 0:i.message),z(e))).finally(()=>{At[e]=void 0})),At[e])};var zt=new Map,mr=(e,t)=>(zt.set(e,t),()=>{zt.get(e)===t&&zt.delete(e)}),fr=(e,t)=>{let n=zt.get(e);return n?n(t):!1};var j=require("react"),A=require("react-native");var T=require("react/jsx-runtime"),Mt="#22C55E",Ii="\u0110\u01B0a m\xE3 v\xE0o khung \u0111\u1EC3 qu\xE9t",Li=2,Wt=18,Di=1600,vt=14,Ui=2e3,wr=.38,Ni=40,yr=2,Vi=8,Bi=2e3,qi=250,rt=2e3,Hi=[{top:0,left:0,borderTopWidth:4,borderLeftWidth:4,borderTopLeftRadius:vt},{top:0,right:0,borderTopWidth:4,borderRightWidth:4,borderTopRightRadius:vt},{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4,borderBottomLeftRadius:vt},{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4,borderBottomRightRadius:vt}],br=({color:e})=>(0,T.jsx)(T.Fragment,{children:Hi.map((t,n)=>(0,T.jsx)(A.View,{style:[C.corner,t,{borderColor:e}]},n))}),$t=({style:e,children:t,...n})=>{let o=(0,j.useRef)(new A.Animated.Value(1)).current,r=i=>A.Animated.spring(o,{toValue:i,speed:40,bounciness:8,useNativeDriver:!0}).start();return(0,T.jsx)(A.Pressable,{...n,onPressIn:()=>r(.88),onPressOut:()=>r(1),children:(0,T.jsx)(A.Animated.View,{style:[e,{transform:[{scale:o}]}],children:t})})},Vn=({scanner:e,closing:t=!1,onClosed:n,onHeight:o})=>{var b,S;let{vision:r,types:i,mode:a,layout:s,hint:c,glass_view:l,absolute:u}=e,d=s===ye.top,f=(0,j.useRef)(new A.Animated.Value(0)).current,p=r.useCameraDevice("back"),y=(0,j.useRef)(new A.Animated.Value(1)).current,[k,R]=(0,j.useState)(!1),[O,x]=(0,j.useState)(1),q=(0,j.useRef)(null),[Y,ne]=(0,j.useState)(()=>{let{width:M,height:G}=A.Dimensions.get("window");return{width:M,height:d?G*wr:G,window_y:0}}),we=J(ie,M=>M.last_value),H=J(ie,M=>M.hit_tick),P=J(ie,M=>M.scan_count),w=J(ie,M=>M.notice),I=J(ie,M=>M.is_picking),E=(0,j.useRef)(null),$=nt(),Ce=$.top,oe=(0,j.useRef)(new A.Animated.Value(0)).current,V=(0,j.useRef)(new A.Animated.Value(0)).current,ue=(0,j.useRef)(new A.Animated.Value(0)).current,ee=(0,j.useRef)(n);ee.current=n,(0,j.useEffect)(()=>{if(!t)return;f.setValue(Y.height);let M=A.Animated.timing(f,{toValue:0,duration:qi,easing:A.Easing.out(A.Easing.cubic),useNativeDriver:!1});return M.start(({finished:G})=>{var ge;G&&((ge=ee.current)==null||ge.call(ee))}),()=>M.stop()},[t,f]);let ae=Math.round(Y.width*(d?.8:.78)),de=Math.round(d?Y.height*.46:ae*.78),Ee=Math.round((Y.height-de)/2),ke=Math.round((Y.width-ae)/2),Qe=r.useCodeScanner({codeTypes:i,onCodeScanned:(0,j.useCallback)(M=>Cn(M),[])});(0,j.useEffect)(()=>{let M=A.BackHandler.addEventListener("hardwareBackPress",()=>(xn(),!0));return()=>M.remove()},[]);let Re=(0,j.useRef)(H);(0,j.useEffect)(()=>{if(H===Re.current)return;oe.setValue(1),ue.setValue(1);let M=A.Animated.parallel([A.Animated.timing(oe,{toValue:0,duration:450,useNativeDriver:!0}),A.Animated.sequence([A.Animated.delay(Ui),A.Animated.timing(ue,{toValue:0,duration:250,useNativeDriver:!0})])]);return M.start(),()=>M.stop()},[H,oe,ue]),(0,j.useEffect)(()=>{let M=ge=>A.Animated.timing(V,{toValue:ge,duration:Di,easing:A.Easing.inOut(A.Easing.quad),useNativeDriver:!0}),G=A.Animated.loop(A.Animated.sequence([M(1),M(0)]));return G.start(),()=>G.stop()},[V]);let Le=(0,j.useCallback)(()=>{A.Animated.timing(y,{toValue:0,duration:220,useNativeDriver:!0}).start()},[y]);(0,j.useEffect)(()=>{let M=setTimeout(Le,Bi);return()=>clearTimeout(M)},[Le]);let[ct,dn]=(0,j.useState)(!1);(0,j.useEffect)(()=>{let M=requestAnimationFrame(()=>{M=requestAnimationFrame(()=>dn(!0))});return()=>cancelAnimationFrame(M)},[]);let je=!!(p!=null&&p.hasTorch),pt=(b=p==null?void 0:p.neutralZoom)!=null?b:1,ut=p?Math.min(p.maxZoom/pt,Vi):1,gn=pt*Math.min(O,ut),Et=M=>{var he;let{touches:G}=M.nativeEvent;if(G.length!==2){q.current=null;return}let ge=Math.hypot(G[0].pageX-G[1].pageX,G[0].pageY-G[1].pageY);(he=q.current)!=null||(q.current={distance:ge,level:O}),x(Math.max(1,Math.min(ut,q.current.level*(ge/q.current.distance))))},kt=(0,T.jsx)(A.Text,{style:[C.hint,!!w&&C.hint_notice],numberOfLines:1,children:(S=w!=null?w:c)!=null?S:Ii});return(0,T.jsx)(A.Animated.View,{ref:E,onTouchMove:Et,onTouchEnd:()=>{q.current=null},pointerEvents:t?"none":"auto",style:d?[C.top,u&&C.top_absolute,t&&{height:f}]:C.full,onLayout:({nativeEvent:{layout:M}})=>{var G;t||(o==null||o(M.height),(G=E.current)==null||G.measureInWindow((ge,he)=>{ne({width:M.width,height:M.height,window_y:he||0})}))},children:(0,T.jsxs)(A.View,{style:t?[C.content_closing,{height:Y.height}]:C.content,children:[p&&ct&&(0,T.jsx)(r.Camera,{style:A.StyleSheet.absoluteFill,device:p,isActive:!I,codeScanner:Qe,torch:k&&je?"on":"off",zoom:gn,onPreviewStarted:Le,onError:M=>jo(M.message)}),(0,T.jsx)(A.Animated.View,{style:[C.preview_cover,{opacity:y}],pointerEvents:"none"}),Y.height>0&&(0,T.jsxs)(A.View,{style:C.overlay,pointerEvents:"none",children:[(0,T.jsx)(A.View,{style:[C.dim_ring,{top:Ee-rt,left:ke-rt,width:ae+rt*2,height:de+rt*2}]}),(0,T.jsxs)(A.View,{style:{position:"absolute",top:Ee,left:ke,width:ae,height:de},children:[(0,T.jsx)(br,{color:"#FFFFFF"}),(0,T.jsx)(A.Animated.View,{style:[A.StyleSheet.absoluteFill,{opacity:oe}],children:(0,T.jsx)(br,{color:Mt})}),(0,T.jsxs)(A.Animated.View,{style:[C.scan_line_wrap,{transform:[{translateY:V.interpolate({inputRange:[0,1],outputRange:[0,Math.max(0,de-Wt)]})}]}],children:[(0,T.jsx)(A.View,{style:C.scan_glow_outer}),(0,T.jsx)(A.View,{style:C.scan_glow_inner}),(0,T.jsx)(A.View,{style:C.scan_line})]})]}),(0,T.jsx)(A.View,{style:[C.hint_slot,d?{top:0,height:Ee-6,justifyContent:"flex-end"}:{top:Ee+de+20}],children:kt}),a===qe.continuous&&!!we&&(0,T.jsx)(A.Animated.View,{style:[C.result_slot,{top:d?Ee+de-Ni:Ee+de+52},{opacity:ue}],children:(0,T.jsxs)(A.View,{style:C.result,children:[(0,T.jsx)(A.View,{style:C.check_badge,children:(0,T.jsx)(A.View,{style:C.check_mark})}),(0,T.jsx)(A.Text,{style:C.result_text,numberOfLines:1,children:we}),(0,T.jsxs)(A.Text,{style:C.result_count,children:["\xB7 ",P," m\xE3"]})]})})]}),Y.height>0&&(0,T.jsx)(A.View,{style:[C.close_slot,d?C.close_slot_top:{top:Math.max(12,Ce-Y.window_y+12)}],children:(0,T.jsxs)($t,{style:[C.close_button,!!l&&C.glass_surface],onPress:xn,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"\u0110\xF3ng",children:[l&&(0,T.jsx)(l,{style:C.glass_fill,glassEffectStyle:"regular",colorScheme:"dark",tintColor:"rgba(24,24,27,0.35)",isInteractive:!0}),(0,T.jsx)(A.View,{style:[C.close_bar,C.close_bar_a]}),(0,T.jsx)(A.View,{style:[C.close_bar,C.close_bar_b]})]})}),(0,T.jsx)(A.View,{style:[C.toolbar_wrap,!d&&{bottom:$.bottom+20}],pointerEvents:"box-none",children:(0,T.jsxs)(A.View,{style:[C.toolbar,!!l&&C.glass_surface],children:[l&&(0,T.jsx)(l,{style:C.glass_fill,glassEffectStyle:"regular",colorScheme:"dark",tintColor:"rgba(24,24,27,0.35)",isInteractive:!0}),(0,T.jsx)($t,{style:C.tool,onPress:Go,disabled:I,accessibilityRole:"button",accessibilityLabel:"Qu\xE9t t\u1EEB \u1EA3nh",children:(0,T.jsxs)(A.View,{style:C.image_icon,children:[(0,T.jsx)(A.View,{style:C.image_icon_dot}),(0,T.jsx)(A.View,{style:C.image_icon_hill})]})}),!!p&&ut>=yr&&(0,T.jsx)($t,{style:[C.tool,O>1&&C.tool_on],onPress:()=>x(M=>M>1?1:yr),accessibilityRole:"button",accessibilityLabel:"Ph\xF3ng to",children:(0,T.jsxs)(A.Text,{style:[C.zoom_text,O>1&&C.zoom_text_on],children:[Math.round(O*10)/10,"x"]})}),je&&(0,T.jsx)($t,{style:[C.tool,k&&C.tool_on],onPress:()=>R(M=>!M),accessibilityRole:"button",accessibilityLabel:"\u0110\xE8n pin",accessibilityState:{selected:k},children:(0,T.jsx)(A.Text,{style:[C.torch_icon,k&&C.zoom_text_on],children:"\u26A1\uFE0E"})})]})})]})})},zi="rgba(0,0,0,0.5)",Nn=50,C=A.StyleSheet.create({top:{height:`${wr*100}%`,overflow:"hidden",backgroundColor:"#000000"},full:{position:"absolute",top:0,left:0,right:0,bottom:0},content:{flex:1,backgroundColor:"#000000"},top_absolute:{position:"absolute",top:0,left:0,right:0,zIndex:1},content_closing:{position:"absolute",left:0,right:0,bottom:0,backgroundColor:"#000000"},preview_cover:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"#000000"},overlay:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden"},dim_ring:{position:"absolute",borderWidth:rt,borderColor:zi,borderRadius:rt+vt},hint_slot:{position:"absolute",left:16,right:16,alignItems:"center"},hint:{color:"#FFFFFF",fontSize:14,fontWeight:"500"},hint_notice:{color:"#FCA5A5"},corner:{position:"absolute",width:28,height:28},scan_line_wrap:{position:"absolute",top:0,left:10,right:10,height:Wt,alignItems:"stretch",justifyContent:"center"},scan_glow_outer:{position:"absolute",left:0,right:0,height:Wt,borderRadius:Wt/2,backgroundColor:Mt,opacity:.1},scan_glow_inner:{position:"absolute",left:4,right:4,height:8,borderRadius:4,backgroundColor:Mt,opacity:.2},scan_line:{height:Li,borderRadius:1,backgroundColor:Mt},glass_surface:{backgroundColor:"transparent",overflow:"visible"},glass_fill:{position:"absolute",top:0,left:0,right:0,bottom:0,borderRadius:999},close_slot:{position:"absolute",right:12},close_slot_top:{bottom:15},close_button:{width:48,height:48,borderRadius:24,overflow:"hidden",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},close_bar:{position:"absolute",width:20,height:2,borderRadius:1,backgroundColor:"#FFFFFF"},close_bar_a:{transform:[{rotate:"45deg"}]},close_bar_b:{transform:[{rotate:"-45deg"}]},toolbar_wrap:{position:"absolute",left:0,right:0,bottom:10,alignItems:"center"},toolbar:{flexDirection:"row",alignItems:"center",gap:4,padding:4,borderRadius:999,backgroundColor:"rgba(24,24,27,0.72)"},tool:{width:Nn,height:Nn,borderRadius:Nn/2,alignItems:"center",justifyContent:"center"},tool_on:{backgroundColor:"#FFFFFF"},zoom_text:{color:"#FFFFFF",fontSize:16,fontWeight:"600"},zoom_text_on:{color:"#18181B"},torch_icon:{color:"#FFFFFF",fontSize:22,fontWeight:"600"},image_icon:{width:24,height:19,borderRadius:3,borderWidth:1.5,borderColor:"#FFFFFF",overflow:"hidden"},image_icon_dot:{position:"absolute",top:3,right:3,width:4,height:4,borderRadius:2,backgroundColor:"#FFFFFF"},image_icon_hill:{position:"absolute",left:2,bottom:-6,width:12,height:12,backgroundColor:"#FFFFFF",transform:[{rotate:"45deg"}]},result_slot:{position:"absolute",left:16,right:16,alignItems:"center"},result:{maxWidth:"100%",flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:"rgba(39,39,42,0.9)"},check_badge:{width:18,height:18,borderRadius:9,alignItems:"center",justifyContent:"center",backgroundColor:Mt},check_mark:{width:5,height:9,marginTop:-2,borderRightWidth:2,borderBottomWidth:2,borderColor:"#FFFFFF",transform:[{rotate:"45deg"}]},result_text:{flexShrink:1,color:"#FFFFFF",fontWeight:"600",fontSize:13},result_count:{color:"#A1A1AA",fontSize:13}});var ve=require("react"),F=require("react-native");var Z=require("react/jsx-runtime"),Bn={[Ae.info]:"#3B82F6",[Ae.success]:"#22C55E",[Ae.error]:"#EF4444"},_r=-120,jt=F.Platform.OS==="android",Ar=({type:e})=>e===Ae.success?(0,Z.jsx)(F.View,{style:ce.check_mark}):e===Ae.error?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F.View,{style:[ce.cross_bar,ce.cross_a]}),(0,Z.jsx)(F.View,{style:[ce.cross_bar,ce.cross_b]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F.View,{style:ce.info_dot}),(0,Z.jsx)(F.View,{style:ce.info_bar})]}),Sr=()=>{let e=J(ft,f=>f.message),t=J(ft,f=>f.type),n=J(ft,f=>f.tick),o=(0,ve.useRef)(new F.Animated.Value(_r)).current,r=(0,ve.useRef)(new F.Animated.Value(0)).current,i=(0,ve.useRef)(new F.Animated.Value(.92)).current,a=(0,ve.useRef)(new F.Animated.Value(0)).current,[s,c]=(0,ve.useState)(),[l,u]=(0,ve.useState)(!1);(0,ve.useEffect)(()=>{let f=!0;return yt().then(p=>{f&&p&&c(()=>p)}),()=>{f=!1}},[]);let d=(0,ve.useRef)(n);return(0,ve.useEffect)(()=>{if(n===d.current)return;F.AccessibilityInfo.announceForAccessibility(e),u(!0),a.setValue(0),i.setValue(.92);let f=F.Animated.sequence([F.Animated.parallel([F.Animated.spring(o,{toValue:0,speed:16,bounciness:7,useNativeDriver:!0}),F.Animated.spring(i,{toValue:1,speed:16,bounciness:9,useNativeDriver:!0}),F.Animated.timing(r,{toValue:1,duration:140,useNativeDriver:!0}),F.Animated.sequence([F.Animated.delay(90),F.Animated.spring(a,{toValue:1,speed:18,bounciness:14,useNativeDriver:!0})])]),F.Animated.delay(To[t]),F.Animated.parallel([F.Animated.timing(o,{toValue:_r,duration:240,useNativeDriver:!0}),F.Animated.timing(r,{toValue:0,duration:200,useNativeDriver:!0})])]);return f.start(({finished:p})=>{p&&u(!1)}),()=>f.stop()},[n]),l?(0,Z.jsx)(F.View,{style:[ce.layer,{top:nt().top+(jt?12:8)}],pointerEvents:"none",children:(0,Z.jsxs)(F.Animated.View,{style:[ce.toast,jt&&ce.toast_android,!!s&&ce.toast_glass,{opacity:s?1:r,transform:[{translateY:o},{scale:i}]}],accessibilityLiveRegion:"polite",children:[s&&(0,Z.jsx)(s,{style:ce.glass_fill,glassEffectStyle:"regular",colorScheme:"dark",tintColor:"rgba(24,24,27,0.55)"}),jt?(0,Z.jsx)(F.Animated.View,{style:[ce.badge_halo,{backgroundColor:`${Bn[t]}33`,transform:[{scale:a}]}],children:(0,Z.jsx)(F.View,{style:[ce.badge,{backgroundColor:Bn[t]}],children:(0,Z.jsx)(Ar,{type:t})})}):(0,Z.jsx)(F.Animated.View,{style:[ce.badge,{backgroundColor:Bn[t],transform:[{scale:a}]}],children:(0,Z.jsx)(Ar,{type:t})}),(0,Z.jsx)(F.Text,{style:[ce.message,jt&&ce.message_android],numberOfLines:2,children:e})]})}):null},ce=F.StyleSheet.create({layer:{position:"absolute",left:16,right:16,alignItems:"center",zIndex:9999,elevation:9999},toast:{maxWidth:"100%",minHeight:50,flexDirection:"row",alignItems:"center",gap:10,paddingLeft:11,paddingRight:18,paddingVertical:11,borderRadius:25,backgroundColor:"#18181B",shadowColor:"#000000",shadowOpacity:.32,shadowRadius:18,shadowOffset:{width:0,height:8},elevation:12},toast_android:{width:"100%",minHeight:60,gap:12,paddingLeft:10,paddingRight:16,paddingVertical:10,borderRadius:20,borderWidth:F.StyleSheet.hairlineWidth,borderColor:"rgba(255,255,255,0.16)",backgroundColor:"#232327",elevation:16},toast_glass:{backgroundColor:"transparent"},badge_halo:{width:40,height:40,borderRadius:20,alignItems:"center",justifyContent:"center"},glass_fill:{position:"absolute",top:0,left:0,right:0,bottom:0,borderRadius:25},badge:{width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},message:{flexShrink:1,color:"#FFFFFF",fontSize:15,lineHeight:20,fontWeight:"600"},message_android:{fontSize:14,fontWeight:"500",letterSpacing:.1,color:"#F4F4F5"},check_mark:{width:7,height:13,marginTop:-3,borderRightWidth:2.5,borderBottomWidth:2.5,borderColor:"#FFFFFF",transform:[{rotate:"45deg"}]},cross_bar:{position:"absolute",width:14,height:2.5,borderRadius:2,backgroundColor:"#FFFFFF"},cross_a:{transform:[{rotate:"45deg"}]},cross_b:{transform:[{rotate:"-45deg"}]},info_dot:{width:3,height:3,borderRadius:2,marginBottom:2,backgroundColor:"#FFFFFF"},info_bar:{width:2.5,height:10,borderRadius:2,backgroundColor:"#FFFFFF"}});var pe=Fe({active_key:null,instances:{}}),Mr=({app:e,instance_id:t,context:n={},url_params:o={},host_data:r={}},i)=>{var s;let a=(s=L().keep_alive)==null?void 0:s.max_webviews;pe.setState(c=>{let l=t!=null?t:e.app_id,u={...c.instances,[l]:{key:l,app:e,context:n,url_params:o,host_data:r,last_used_at:Date.now()}},d=Object.keys(u);return a&&a>0&&d.length>a&&d.filter(f=>f!==l).sort((f,p)=>u[f].last_used_at-u[p].last_used_at).slice(0,d.length-a).forEach(f=>{delete u[f]}),i?{active_key:l,instances:u}:{instances:u}})},vr=e=>Mr(e,!0),xr=e=>Mr(e,!1),it=()=>pe.setState({active_key:null}),Gt=e=>{pe.setState(t=>{if(t.active_key===e||!t.instances[e])return{};let n={...t.instances};return delete n[e],{instances:n}})};var Cr="catalog",$i="paused_apps",Wi="removed_apps",ji=10*1e3,Gi=2,Ji=3e3,Ki=()=>{var e;try{return JSON.parse((e=L().storage.getString(Cr))!=null?e:"{}")}catch{return{}}},U=Fe({catalog:{},downloads:{},pause_reasons:[],updates:{},apply_ticks:{}}),Tr=e=>{var t;return!!((t=L().manual_update)!=null&&t.includes(e))},Yt=new Set,Pr=e=>{let t=new Set,n=()=>L().storage.setString(e,JSON.stringify([...t]));return{has:o=>t.has(o),values:()=>[...t],add:o=>t.has(o)?!1:(t.add(o),n(),!0),delete:o=>t.delete(o)?(n(),!0):!1,load:()=>{var o;t.clear();try{let r=JSON.parse((o=L().storage.getString(e))!=null?o:"[]");Array.isArray(r)&&r.forEach(i=>{typeof i=="string"&&t.add(i)})}catch{}}}},Pe=Pr($i),$e=Pr(Wi);Ot(()=>{Pe.load(),$e.load();let e=Ki(),t={};Object.keys(e).filter(n=>!$e.has(n)).forEach(n=>{let o=z(n);o?t[n]={status:"installed",progress:1,version:o.version,has_local:!0}:Pe.has(n)&&(t[n]={status:"paused",progress:0,version:e[n].version,has_local:!1})}),U.setState({catalog:e,downloads:t})});var st=e=>J(U,t=>e?t.downloads[e]:void 0),Er=()=>J(U,e=>e.pause_reasons.length>0),Te=(...e)=>fe("queue",...e),se=[],Ue={},D=null,Jt=new Set,Xe={},qn=new Set,Ne=e=>{qn.forEach(t=>{try{t(e)}catch(n){console.warn("[miniapp-queue] event listener error",n==null?void 0:n.message)}})},Xt=e=>(qn.add(e),()=>{qn.delete(e)}),kr=()=>U.getState().downloads,be=(e,t)=>{let n=!!z(e),o=U.getState().downloads[e],r=t.status==="downloading"&&n?"updating":t.status,i={...o!=null?o:{status:"queued",progress:0},...t,...r?{status:r}:{},has_local:n};U.setState(a=>({downloads:{...a.downloads,[e]:i}})),(o==null?void 0:o.status)!==i.status||(o==null?void 0:o.version)!==i.version||(o==null?void 0:o.has_local)!==i.has_local?Ne({type:"status_change",app_id:e,state:i}):o.progress!==i.progress&&Ne({type:"progress",app_id:e,progress:i.progress,version:i.version})},Kt=(e,t)=>{var n;(n=Xe[e])==null||n.forEach(o=>o(t)),delete Xe[e]},Yi=()=>U.getState().pause_reasons.length>0,ze=e=>{var s;if(D)return;let t=e?se.indexOf(e):Yi()?-1:se.findIndex(c=>!Pe.has(c));if(t<0||t>=se.length)return;let[n]=se.splice(t,1),o=U.getState().catalog[n];if(!o){Kt(n,z(n)),ze();return}let r=Date.now();Ue[n]=((s=Ue[n])!=null?s:0)+1,be(n,{status:"downloading",progress:0,version:o.version,error:void 0});let i=0,a=Un(o,{onProgress:c=>{let l=Math.floor(c*100);l!==i&&(i=l,be(n,{progress:l/100,version:o.version}))}});D={app_id:n,handle:a,forced:!!e},Te("start",n,o.version,e?"(forced)":""),a.promise.then(c=>{Te("installed",n,o.version,`${Date.now()-r}ms`),be(n,{status:"installed",progress:1,version:o.version}),Kt(n,c)}).catch(c=>{var u;if(c instanceof ot){if(Jt.has(n))return;Te("paused",n),Ue[n]-=1,se.unshift(n),be(n,{status:Pe.has(n)?"paused":"queued",progress:0,version:o.version});return}let l=String((u=c==null?void 0:c.message)!=null?u:c);if(console.warn("[miniapp-queue] failed",n,l),Ue[n]<Gi){be(n,{status:"queued",progress:0,version:o.version,error:l}),setTimeout(()=>{var d;se.includes(n)||(D==null?void 0:D.app_id)===n||(se.push(n),ze((d=Xe[n])!=null&&d.length?n:void 0))},Ji);return}be(n,{status:"failed",progress:0,version:o.version,error:l}),Kt(n,z(n))}).finally(()=>{D=null;let c=se.find(l=>{var u;return(u=Xe[l])==null?void 0:u.length});ze(c)})},Qt=(e,{front:t=!1}={})=>{if((D==null?void 0:D.app_id)===e)return;let n=se.indexOf(e);if(n>=0){if(!t)return;se.splice(n,1)}t?se.unshift(e):se.push(e)},Xi=async e=>{let{host_id:t,client_token:n}=L(),o=new AbortController,r=setTimeout(()=>o.abort(),ji);try{let i=`${Ze}/api/hosts/${encodeURIComponent(t)}/miniapps?channel=${e}`,a=await fetch(i,{headers:{Authorization:`Bearer ${n}`,"Cache-Control":"no-cache"},signal:o.signal});if(!a.ok)throw new Error(`host list ${e} ${a.status}`);return(await a.json()).apps.map(c=>({...c,channel:e}))}finally{clearTimeout(r)}},xt=null,Zt=()=>(xt!=null||(xt=(async()=>{var t;let e=Date.now();try{let n=await Promise.all(L().channels.map(Xi)),o={};[...n].reverse().flat().forEach(c=>{o[c.app_id]=c});let r=Object.keys(U.getState().catalog).filter(c=>!o[c]);L().storage.setString(Cr,JSON.stringify(o)),U.setState({catalog:o}),await Promise.all(r.map(c=>Rr(c,{by_user:!1}))),r.forEach(c=>$e.delete(c));let i=Object.keys(o).filter(c=>!$e.has(c)),a=[],s={};for(let c of i.map(l=>o[l])){if(await Ln(c)){be(c.app_id,{status:"installed",progress:1,version:c.version});continue}let l=z(c.app_id);if(Tr(c.app_id)&&!Yt.has(c.app_id)&&l&&await De(l)){be(c.app_id,{status:"installed",progress:1,version:l.version}),s[c.app_id]={app_id:c.app_id,current_version:l.version,next_version:c.version};continue}a.push(c)}return U.setState({updates:s}),a.forEach(c=>{Ue[c.app_id]=0,be(c.app_id,{status:Pe.has(c.app_id)?"paused":"queued",progress:0,version:c.version,error:void 0}),Qt(c.app_id)}),Te("catalog",i.length,"apps, outdated",a.map(c=>c.app_id),"removed",r,`${Date.now()-e}ms`),Ne({type:"sync_complete",app_ids:i,removed:r}),Object.values(s).forEach(c=>Ne({type:"update_available",...c})),ze(),{ok:!0,app_ids:i,removed:r}}catch(n){let o=String((n==null?void 0:n.name)==="AbortError"?"timeout":(t=n==null?void 0:n.message)!=null?t:n);return console.warn("[miniapp-queue] sync catalog failed",o),Ne({type:"sync_failed",error:o}),{ok:!1,error:o}}finally{xt=null}})()),xt),Rr=async(e,{by_user:t})=>{var r,i,a,s;if(t&&$e.add(e),Jt.has(e))return;Jt.add(e),Pe.delete(e);let n=se.indexOf(e);n>=0&&se.splice(n,1),(D==null?void 0:D.app_id)===e&&D.handle.cancel();let o=(s=(a=(r=U.getState().downloads[e])==null?void 0:r.version)!=null?a:(i=z(e))==null?void 0:i.version)!=null?s:"";be(e,{status:"uninstalling",progress:0,version:o}),await ur(e),Gt(e),U.setState(c=>{let l={...c.downloads};return delete l[e],{downloads:l}}),delete Ue[e],Jt.delete(e),Kt(e,null),Te("uninstalled",e,t?"(user)":"(not in list)"),Ne({type:"uninstalled",app_id:e})},Or=e=>Rr(e,{by_user:!0}),Fr=e=>{let t=at(e);return t?($e.delete(e),(D==null?void 0:D.app_id)===e||se.includes(e)||(Ue[e]=0,be(e,{status:Pe.has(e)?"paused":"queued",progress:0,version:t.version,error:void 0}),Qt(e),ze(),Te("restore",e)),!0):!1},Ir=e=>{if(Pe.has(e))return;if(Pe.add(e),Te("pause app",e),(D==null?void 0:D.app_id)===e&&!D.forced){D.handle.cancel();return}let t=U.getState().downloads[e];se.includes(e)&&t&&be(e,{status:"paused",progress:0,version:t.version})},Lr=e=>{if(!Pe.delete(e))return;Te("resume app",e);let t=U.getState().downloads[e];(t==null?void 0:t.status)==="paused"&&!se.includes(e)&&at(e)&&(Ue[e]=0,Qt(e)),se.includes(e)&&t&&be(e,{status:"queued",progress:0,version:t.version}),ze()},Dr=e=>{let{pause_reasons:t}=U.getState();t.includes(e)||(U.setState({pause_reasons:[...t,e]}),Te("pause",e),t.length===0&&Ne({type:"pause_change",paused:!0,reasons:[e]}),D&&!D.forced&&D.handle.cancel())},Ur=e=>{let{pause_reasons:t}=U.getState();if(!t.includes(e))return;let n=t.filter(o=>o!==e);U.setState({pause_reasons:n}),Te("resume",e),n.length===0&&Ne({type:"pause_change",paused:!1,reasons:n}),ze()},Hn=e=>U.getState().updates[e],en=async e=>{var n,o;let t=Hn(e);Yt.add(e);try{let r=await Ct(e),i=(o=t==null?void 0:t.next_version)!=null?o:(n=at(e))==null?void 0:n.version;return!r||!i||r.version!==i?!1:(U.setState(a=>{var c;let s={...a.updates};return delete s[e],{updates:s,apply_ticks:{...a.apply_ticks,[e]:((c=a.apply_ticks[e])!=null?c:0)+1}}}),Te("updated",e,t==null?void 0:t.current_version,"\u2192",r.version),Ne({type:"update_applied",app_id:e,version:r.version}),!0)}finally{Yt.delete(e)}},Nr=()=>Object.values(U.getState().catalog).map(e=>({...e,installed:!!z(e.app_id),removed_by_user:$e.has(e.app_id)})),at=e=>U.getState().catalog[e],Ct=async e=>{let t=at(e);if(!t)return;if(Pe.delete(e),$e.delete(e),await Ln(t))return z(e);let n=z(e);if(Tr(e)&&!Yt.has(e)&&n&&await De(n))return n;let o=new Promise(r=>{var i;((i=Xe[e])!=null?i:Xe[e]=[]).push(r)});return(D==null?void 0:D.app_id)===e?D.forced=!0:(Ue[e]=0,Qt(e,{front:!0}),D&&!D.forced?D.handle.cancel():ze(e)),o};var B=require("react/jsx-runtime"),zn=e=>(e!=null?e:"").replace(/\?[^#]*/,""),Vr=0,Qi=()=>{let e=new Set;return{emit:t=>e.forEach(n=>n(t)),subscribe:t=>(e.add(t),()=>{e.delete(t)})}},Zi=v.default.memo(({instance_key:e,is_active:t,is_front:n,is_dark:o,reload_tick:r,web_at_top:i,splash:a,bridge:s,opaque_background:c,allow_embedded_miniapps:l,onWebLoadEnd:u})=>{var Et,kt;let d=(0,v.useRef)(null),f=(0,v.useRef)(!1),p=J(pe,b=>b.instances[e]),y=p==null?void 0:p.app.app_id,k=p==null?void 0:p.app.manifest_url,R=p==null?void 0:p.context,O=p==null?void 0:p.url_params,x=J(ie,b=>{var S;return((S=b.active)==null?void 0:S.owner)===e?b.active:null}),[q,Y]=(0,v.useState)(null),[ne,we]=(0,v.useState)(x);x!==ne&&(we(x),x?Y(null):(ne==null?void 0:ne.layout)===ye.top&&Y(ne));let H=(x==null?void 0:x.layout)===ye.top?x:q,[P,w]=(0,v.useState)(()=>y?z(y):null),[I,E]=(0,v.useState)(!1),[$,Ce]=(0,v.useState)(0),[oe,V]=(0,v.useState)(0),[ue,ee]=(0,v.useState)(!1),ae=(0,v.useRef)(null),de=b=>{ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{ae.current=null,ee(!0)},b)};(0,v.useEffect)(()=>()=>{ae.current&&clearTimeout(ae.current)},[]),(0,v.useEffect)(()=>{if(!y||!t&&P)return;let b=!0;return E(!1),(async()=>{let S=z(y),M=S?await De(S):!1;if(!b||(w(M?he=>!he||he.version!==S.version||he.permissions.join(",")!==S.permissions.join(",")?S:he:null),__DEV__&&Date.now()-Vr>1e4&&(Vr=Date.now(),await Zt()),!b))return;let G=await Ct(y),ge=G!==void 0?G:k?await hr(y,k):z(y);if(b){if(!ge){E(!0);return}w(he=>he!=null?he:ge)}})(),()=>{b=!1}},[t,y,k,$]),(0,v.useEffect)(()=>mr(e,b=>d.current?(d.current.postMessage(b),!0):!1),[e]);let Ee=J(U,b=>{let S=y?b.downloads[y]:void 0;return(S==null?void 0:S.status)==="installed"?S.version:void 0});(0,v.useEffect)(()=>{if(t||!y||!P)return;let b=z(y);if(!b||b.version===P.version)return;let S=!0;return De(b).then(M=>{!S||!M||(fe(`webview:${e}`,"\u0111\u1ED5i bundle (\u1EA9n)",P.version,"\u2192",b.version),w(b))}),()=>{S=!1}},[t,y,Ee,P==null?void 0:P.version]);let ke=J(U,b=>{var S;return y&&(S=b.apply_ticks[y])!=null?S:0});(0,v.useEffect)(()=>{if(!ke||!y)return;let b=z(y);if(!b||b.version===(P==null?void 0:P.version))return;let S=!0;return De(b).then(M=>{!S||!M||(fe(`webview:${e}`,"c\u1EADp nh\u1EADt",P==null?void 0:P.version,"\u2192",b.version),ee(!1),w(b))}),()=>{S=!1}},[ke]),(0,v.useEffect)(()=>{var M;let b=(M=L().keep_alive)==null?void 0:M.idle_close_ms;if(t||!b||b<=0)return;let S=setTimeout(()=>{Gt(e)},b);return()=>clearTimeout(S)},[t,e]),(0,v.useEffect)(()=>{r>0&&(E(!1),ee(!1),V(b=>b+1),Ce(b=>b+1))},[r]);let Qe=(0,v.useRef)(t);(0,v.useEffect)(()=>{var b;Qe.current!==t&&(Qe.current=t,f.current&&((b=d.current)==null||b.injectJavaScript(tr(t?"resumed":"paused"))))},[t]);let Re=`${(Et=P==null?void 0:P.version)!=null?Et:"none"}:${(kt=P==null?void 0:P.permissions.join(","))!=null?kt:""}:${oe}`,Le=(0,v.useMemo)(()=>JSON.stringify([R!=null?R:{},O!=null?O:{}]),[R,O]),ct=(0,v.useMemo)(()=>{var b;return sr(O!=null?O:{},(b=P==null?void 0:P.permissions)!=null?b:[])},[Le,P==null?void 0:P.permissions]),dn=(0,v.useMemo)(()=>rr(R!=null?R:{},ct)+Zo()+er()+(L().debug?Qo():""),[ct]),je=(0,v.useRef)(null),pt=(0,v.useRef)(null);(0,v.useEffect)(()=>{var S,M,G;if(!P)return;if(pt.current!==Re){pt.current=Re,je.current=Le;return}if(je.current===Le)return;let b=((M=JSON.parse((S=je.current)!=null?S:"[]")[0])!=null?M:{}).org_id;if(je.current=Le,b===(R==null?void 0:R.org_id)&&f.current){ee(!1),de(1500),(G=d.current)==null||G.injectJavaScript(nr(R!=null?R:{},ct));return}ee(!1),V(ge=>ge+1)},[Le,P,Re]),(0,v.useEffect)(()=>(t||(Ie(e),He(e),Je(e)),()=>{Ie(e),He(e),Je(e)}),[t,e,Re,r]),(0,v.useEffect)(()=>{let b=N.AppState.addEventListener("change",S=>{S==="background"&&!Io()&&Ie(e),S==="background"&&!Bo()&&He(e)});return()=>b.remove()},[e]);let ut=(0,v.useCallback)(async b=>{var M,G,ge,he,hn,eo;let S=Jo(b.nativeEvent.data);if(!S){if(y&&(s!=null&&s.onWebEvent))try{Promise.resolve(s.onWebEvent(b.nativeEvent.data,{app_id:y,instance_id:e})).catch(Q=>{console.warn("[miniapp] onWebEvent l\u1ED7i",y,Q)})}catch(Q){console.warn("[miniapp] onWebEvent l\u1ED7i",y,Q)}return}if(S.method==="log"){let{level:Q,text:te}=S;fe(`web:${e}`,Q!=null?Q:"log",te!=null?te:"");return}if(S.method==="pong"){ae.current||ee(!0);return}if(S.method==="touchAtTop"){i.emit(!!S.at_top);return}if(S.method==="contextApplied"){ae.current&&clearTimeout(ae.current),ae.current=null,ee(!0);return}if(S.method==="ready"){f.current=!0,ee(!0);let Q=(M=pe.getState().instances[e])==null?void 0:M.context;Q&&((G=d.current)==null||G.injectJavaScript(Pn(Q)));return}try{let Q=await lr(S,{getHostData:()=>{var te,_e;return(_e=(te=pe.getState().instances[e])==null?void 0:te.host_data)!=null?_e:{}},getPermissions:()=>{var te,_e;return y?(_e=(te=z(y))==null?void 0:te.permissions)!=null?_e:[]:[]},getContext:()=>{var te,_e;return(_e=(te=pe.getState().instances[e])==null?void 0:te.context)!=null?_e:{}},is_dark:o,close:it,app_id:y!=null?y:"",instance_id:e,options:s,emit:(te,_e)=>{var to;(to=d.current)==null||to.injectJavaScript(Xo(te,_e))},playBeep:(ge=s==null?void 0:s.playScannerBeep)!=null?ge:(()=>{var te;(te=d.current)==null||te.injectJavaScript(ar())}),isActive:()=>pe.getState().active_key===e&&N.AppState.currentState!=="background"});S.id&&((he=d.current)==null||he.injectJavaScript(Ko(S.id,Q)))}catch(Q){if(!S.id)return;let te=Q==null?void 0:Q.code,_e=Q instanceof m?Q:new m(typeof te=="string"?te:"HOST_ERROR",String((hn=Q==null?void 0:Q.message)!=null?hn:Q));(eo=d.current)==null||eo.injectJavaScript(Yo(S.id,_e))}},[e,o,y,i,s]),gn=(0,v.useCallback)(()=>{E(!1),V(b=>b+1),Ce(b=>b+1)},[]);return(0,B.jsxs)(N.View,{style:[N.StyleSheet.absoluteFill,c&&{backgroundColor:o?"#09090B":"#FFFFFF"},!n&&xe.behind],pointerEvents:t?"auto":"none",children:[H&&(0,B.jsx)(Vn,{scanner:H,closing:H===q,onClosed:()=>{var b;Y(null),H.absolute&&((b=d.current)==null||b.injectJavaScript(En(0)))},onHeight:H.absolute?b=>{var S;return(S=d.current)==null?void 0:S.injectJavaScript(En(b))}:void 0}),P?(0,B.jsx)(qr.default,{ref:d,source:{uri:P.entry_uri},originWhitelist:["*"],hideKeyboardAccessoryView:!0,mediaPlaybackRequiresUserAction:!1,allowingReadAccessToURL:`file://${l?On():P.dir}`,allowFileAccess:!0,allowFileAccessFromFileURLs:!0,allowUniversalAccessFromFileURLs:!0,injectedJavaScriptBeforeContentLoaded:dn,onMessage:ut,onShouldStartLoadWithRequest:b=>{let S=b.url;return b.isTopFrame===!1||!/^https?:\/\//i.test(S)?!0:(Promise.resolve(s!=null&&s.openUrl?s.openUrl(S):N.Linking.openURL(S)).catch(()=>{}),!1)},setSupportMultipleWindows:!1,bounces:!1,overScrollMode:"never",onLoadStart:b=>{Ie(e),He(e),Je(e),fe(`webview:${e}`,"load start",zn(b.nativeEvent.url)),f.current=!1,ee(!1)},onError:b=>{Ie(e),He(e),Je(e),fe(`webview:${e}`,"load error",zn(b.nativeEvent.url),b.nativeEvent.description),E(!0),ee(!1)},onLoadEnd:b=>{let S=b.nativeEvent.url;fe(`webview:${e}`,"load end",zn(S)),y&&(u==null||u({app_id:y,instance_id:e,url:S})),de(1500)},onContentProcessDidTerminate:()=>{Ie(e),He(e),Je(e),f.current=!1,ee(!1),V(b=>b+1)},onRenderProcessGone:()=>(Ie(e),He(e),Je(e),f.current=!1,ee(!1),V(b=>b+1),!0),style:xe.webview},Re):null,(x==null?void 0:x.layout)===ye.full&&(0,B.jsx)(Vn,{scanner:x}),p&&(0,B.jsx)(ts,{visible:!P||!ue,interactive:I,children:(0,B.jsx)(es,{splash:a,app:p.app,is_dark:o,error:I,has_bundle:!!P,retry:gn})})]})}),es=v.default.memo(({splash:e,app:t,is_dark:n,error:o,has_bundle:r,retry:i})=>{let a=e,s=st(t.app_id),c=o?"error":!r&&(s==null?void 0:s.status)==="downloading"?"downloading":"loading";return(0,B.jsx)(a,{app:t,is_dark:n,status:c,progress:c==="downloading"?s==null?void 0:s.progress:void 0,retry:i})}),ts=({visible:e,interactive:t,children:n})=>{let o=(0,v.useRef)(new N.Animated.Value(e?1:0)).current,[r,i]=(0,v.useState)(e);return(0,v.useEffect)(()=>{if(e){i(!0),o.setValue(1);return}let a=N.Animated.timing(o,{toValue:0,duration:180,useNativeDriver:!0});return a.start(({finished:s})=>{s&&i(!1)}),()=>a.stop()},[e,o]),r?(0,B.jsx)(N.Animated.View,{style:[N.StyleSheet.absoluteFill,{opacity:o}],pointerEvents:t?"auto":"none",children:n}):null},$n=({app:e,is_dark:t,status:n,progress:o,retry:r})=>{let i=t?"#FAFAFA":"#18181B";return(0,B.jsxs)(N.View,{style:[xe.splash,{backgroundColor:t?"#09090B":"#FFFFFF"}],children:[(0,B.jsx)(N.View,{style:[xe.splash_icon,{backgroundColor:t?"#18181B":"#F4F4F5"}],children:e.icon?(0,B.jsx)(N.Image,{source:{uri:e.icon},style:xe.splash_icon_image}):(0,B.jsx)(N.Text,{style:xe.splash_letter,children:(e.name||"?").slice(0,1).toUpperCase()})}),(0,B.jsx)(N.Text,{style:[xe.splash_name,{color:i}],children:e.name}),n==="error"?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(N.Text,{style:xe.splash_hint,children:"Kh\xF4ng t\u1EA3i \u0111\u01B0\u1EE3c mini app"}),(0,B.jsx)(N.TouchableOpacity,{activeOpacity:.7,style:[xe.retry_button,{backgroundColor:t?"#27272A":"#F4F4F5"}],onPress:r,children:(0,B.jsx)(N.Text,{style:[xe.retry_text,{color:i}],children:"Th\u1EED l\u1EA1i"})})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(N.ActivityIndicator,{style:xe.splash_spinner,color:t?"#A1A1AA":"#71717A"}),n==="downloading"&&(0,B.jsxs)(N.Text,{style:xe.splash_hint,children:["\u0110ang t\u1EA3i mini app",o?` ${Math.round(o*100)}%`:"\u2026"]})]})]})},Br=(e,t)=>{let n=(0,v.useRef)(t),o=(0,v.useRef)(!1);__DEV__&&!o.current&&n.current!==t&&(o.current=!0,console.warn(`[miniapp] MiniAppHost prop "${e}" \u0111\u1ED5i gi\u1EEFa c\xE1c l\u1EA7n render \u2192 m\u1ECDi WebView b\u1ECB mount l\u1EA1i. Khai b\xE1o component b\xEAn ngo\xE0i render.`))},ns=({container:e,splash:t=$n,is_dark:n=!1,bridge:o,close_on_back:r=!0,opaque_background:i=!0,allow_embedded_miniapps:a=!1,onWebLoadEnd:s})=>{Br("container",e),Br("splash",t);let c=e,l=J(pe,x=>x.active_key),u=(0,v.useRef)(l);l&&(u.current=l);let d=J(pe,x=>Object.keys(x.instances).join("|")),f=J(pe,x=>{var q;return x.active_key?(q=x.instances[x.active_key])==null?void 0:q.app.name:void 0}),p=(0,v.useMemo)(()=>d?d.split("|"):[],[d]),[y,k]=(0,v.useState)({}),R=(0,v.useRef)(Qi()).current;(0,v.useEffect)(()=>{if(!l||!r)return;let x=N.BackHandler.addEventListener("hardwareBackPress",()=>(it(),!0));return()=>x.remove()},[l,r]);let O=(0,v.useCallback)(()=>{let x=pe.getState().active_key;x&&k(q=>({...q,[x]:(q[x]||0)+1}))},[]);return p.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(c,{visible:!!l,title:f!=null?f:"",is_dark:n,close:it,reload:O,subscribeWebAtTop:R.subscribe,children:p.map(x=>(0,B.jsx)(Zi,{instance_key:x,is_active:l===x,is_front:(l!=null?l:u.current)===x,is_dark:n,reload_tick:y[x]||0,web_at_top:R,splash:t,bridge:o,opaque_background:i,allow_embedded_miniapps:a,onWebLoadEnd:s},x))}),(0,B.jsx)(Sr,{})]}):null},xe=N.StyleSheet.create({webview:{flex:1,backgroundColor:"transparent"},behind:{zIndex:-1},splash:{flex:1,alignItems:"center",justifyContent:"center",gap:12},splash_icon:{width:72,height:72,borderRadius:20,alignItems:"center",justifyContent:"center",overflow:"hidden"},splash_icon_image:{width:72,height:72},splash_letter:{fontSize:28,fontWeight:"700",color:"#1D4ED8"},splash_name:{fontSize:16,fontWeight:"600"},splash_hint:{color:"#71717A"},splash_spinner:{marginTop:8},retry_button:{marginTop:4,paddingHorizontal:20,paddingVertical:10,borderRadius:999},retry_text:{fontWeight:"600"}}),Hr=v.default.memo(ns);var Ve=require("react");var $r=e=>`changelog_seen:${e}`,os=10*1e3,nn=e=>L().storage.getString($r(e))||null,lt=(e,t=(n=>(n=z(e))==null?void 0:n.version)())=>{t&&L().storage.setString($r(e),t)},jn=e=>{var o;let t=(o=z(e))==null?void 0:o.version;if(!t)return null;let n=nn(e);return n?Dn(t,n)>0?{app_id:e,from:n,to:t}:null:(lt(e,t),null)},rs=e=>{var t,n,o;return(o=(n=(t=U.getState().catalog[e])==null?void 0:t.channel)!=null?n:L().channels[0])!=null?o:"production"},on=async(e,{from:t,to:n,channel:o=rs(e)}={})=>{let{client_token:r}=L(),i=new URLSearchParams({channel:o});t&&i.set("from",t),n&&i.set("to",n);let a=new AbortController,s=setTimeout(()=>a.abort(),os);try{let c=await fetch(`${Ze}/api/miniapps/${encodeURIComponent(e)}/changelog?${i}`,{headers:{Authorization:`Bearer ${r}`},signal:a.signal});if(!c.ok)throw new Error(`changelog ${e} ${c.status}`);return(await c.json()).versions}finally{clearTimeout(s)}},rn=(e,{from:t,to:n,enabled:o=!0}={})=>{let[r,i]=(0,Ve.useState)([]),[a,s]=(0,Ve.useState)(!1),[c,l]=(0,Ve.useState)(),[u,d]=(0,Ve.useState)(0),f=(0,Ve.useCallback)(()=>d(p=>p+1),[]);return(0,Ve.useEffect)(()=>{if(!e||!o)return;let p=!0;return s(!0),l(void 0),on(e,{from:t,to:n}).then(y=>{p&&i(y)}).catch(y=>{var k;p&&l(String((y==null?void 0:y.name)==="AbortError"?"timeout":(k=y==null?void 0:y.message)!=null?k:y))}).finally(()=>{p&&s(!1)}),()=>{p=!1}},[e,t,n,o,u]),{versions:r,loading:a,error:c,reload:f}},Tt=Fe({request:null}),Wn=!1,is=e=>{var t,n;return(n=(t=U.getState().catalog[e])==null?void 0:t.name)!=null?n:e},tn=async(e,{name:t}={})=>{if(Tt.getState().request||Wn)return!1;let n=jn(e);if(!n)return!1;Wn=!0;try{let o=await on(e,{from:n.from,to:n.to});return o.length?(Tt.setState({request:{...n,name:t!=null?t:is(e),versions:o}}),!0):(lt(e,n.to),!1)}catch(o){return fe("changelog failed",e,o),!1}finally{Wn=!1}},sn=()=>{let{request:e}=Tt.getState();e&<(e.app_id,e.to),Tt.setState({request:null})},an=()=>J(Tt,e=>e.request),zr=!1;Ot(()=>{if(zr)return;zr=!0;let e=()=>L().changelog!==!1;Xt(n=>{n.type==="status_change"&&n.state.status==="installed"&&!nn(n.app_id)&<(n.app_id,n.state.version),n.type==="update_applied"&&e()&&tn(n.app_id)});let t=pe.getState().active_key;pe.subscribe(()=>{let{active_key:n,instances:o}=pe.getState();if(n===t)return;t=n;let r=n?o[n]:void 0;r&&e()&&tn(r.app.app_id,{name:r.app.name})})});var X=me(require("react")),g=require("react-native");var ss=/\*\*(.+?)\*\*|`([^`]+)`|\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,Pt=e=>{var o;let t=[],n=0;for(let r of e.matchAll(ss)){let i=(o=r.index)!=null?o:0;i>n&&t.push({type:"text",text:e.slice(n,i)}),r[1]!==void 0?t.push({type:"bold",text:r[1]}):r[2]!==void 0?t.push({type:"code",text:r[2]}):t.push({type:"link",text:r[3],url:r[4]}),n=i+r[0].length}return n<e.length&&t.push({type:"text",text:e.slice(n)}),t},Wr=e=>Pt(e).map(t=>t.text).join("");var h=require("react/jsx-runtime"),Gn={changelog_title:"C\xF3 g\xEC m\u1EDBi",changelog_ok:"\u0110\xE3 hi\u1EC3u",changelog_view_all:"Xem t\u1EA5t c\u1EA3 c\u1EADp nh\u1EADt",changelog_more:"+{count} thay \u0111\u1ED5i kh\xE1c",history_title:"L\u1ECBch s\u1EED c\u1EADp nh\u1EADt",history_empty:"Ch\u01B0a c\xF3 ghi ch\xFA c\u1EADp nh\u1EADt.",history_error:"Kh\xF4ng t\u1EA3i \u0111\u01B0\u1EE3c l\u1ECBch s\u1EED c\u1EADp nh\u1EADt.",retry:"Th\u1EED l\u1EA1i",update_title:"\u0110\xE3 c\xF3 b\u1EA3n c\u1EADp nh\u1EADt",updating_title:"\u0110ang c\u1EADp nh\u1EADt\u2026",update_message:`Phi\xEAn b\u1EA3n {next} \u0111\xE3 s\u1EB5n s\xE0ng (hi\u1EC7n t\u1EA1i {current}).
|
|
89
|
-
Vui l\xF2ng c\u1EADp nh\u1EADt \u0111\u1EC3 ti\u1EBFp t\u1EE5c s\u1EED d\u1EE5ng.`,update_failed:"C\u1EADp nh\u1EADt kh\xF4ng th\xE0nh c\xF4ng. Ki\u1EC3m tra k\u1EBFt n\u1ED1i m\u1EA1ng r\u1ED3i th\u1EED l\u1EA1i.",update_now:"C\u1EADp nh\u1EADt ngay",updating_hint:"Vui l\xF2ng kh\xF4ng t\u1EAFt \u1EE9ng d\u1EE5ng"},Gr=(e,t)=>e.replace(/\{(\w+)\}/g,(n,o)=>o in t?String(t[o]):n),W={blue:"#007AFF",track:"#E5E5EA",overlay:"rgba(0, 0, 0, 0.6)",shadow:"#000000",title:"#1A1A1A",sub_title:"#666666",error:"#D92D20",hint:"#C0C0C0",surface:"#FFFFFF",background:"#F2F2F7"},as={primary:"#007AFF",on_primary:"#FFFFFF",background:"#F2F2F7",surface:"#FFFFFF",text:"#1C1C1E",text_secondary:"#666666",hint:"#AEAEB2",overlay:"rgba(0, 0, 0, 0.6)",divider:"rgba(60, 60, 67, 0.18)",radius:28,button_radius:12,button_height:50},ls={primary:"#0A84FF",on_primary:"#FFFFFF",background:"#000000",surface:"#1C1C1E",text:"#FFFFFF",text_secondary:"#A1A1AA",hint:"#636366",overlay:"rgba(0, 0, 0, 0.7)",divider:"rgba(84, 84, 88, 0.6)",radius:28,button_radius:12,button_height:50},cs={new:{color:"#64B5FF",bg:"rgba(10, 132, 255, 0.18)"},fix:{color:"#FF9F7A",bg:"rgba(255, 112, 67, 0.18)"},improve:{color:"#5FD39A",bg:"rgba(48, 209, 88, 0.18)"}},pn=(e={},t)=>{let n=!!e.dark,{kinds:o,...r}=e;return{...n?ls:as,...Object.fromEntries(Object.entries(r).filter(([,a])=>a!==void 0)),dark:n,labels:{...Gn,...t},kinds:Jn.map(a=>({...a,...n?cs[a.key]:null,...a.key==="new"&&e.primary?{color:e.primary}:null,...o==null?void 0:o[a.key]}))}},Jr=(0,X.createContext)(void 0),cn=({theme:e,labels:t,children:n})=>{let o=(0,X.useMemo)(()=>pn(e,t),[e,t]);return(0,h.jsx)(Jr.Provider,{value:o,children:n})},ps=pn(),We=()=>{var e;return(e=(0,X.useContext)(Jr))!=null?e:ps},Jn=[{key:"new",label:"M\u1EDBi",color:"#007AFF",bg:"#E5F1FF"},{key:"fix",label:"S\u1EEDa l\u1ED7i",color:"#C4320A",bg:"#FFF1EB"},{key:"improve",label:"C\u1EA3i thi\u1EC7n",color:"#067647",bg:"#E7F7EE"}],Kn=e=>({new:e.flatMap(t=>t.changelog.new),fix:e.flatMap(t=>t.changelog.fix),improve:e.flatMap(t=>t.changelog.improve)}),us=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("vi-VN")},Yn=({text:e,style:t})=>{let n=We();return(0,h.jsx)(g.Text,{style:t,children:Pt(e.replace(/^(?:[-*•]\s+)+/,"")).map((o,r)=>{switch(o.type){case"bold":return(0,h.jsx)(g.Text,{style:_.md_bold,children:o.text},r);case"code":return(0,h.jsx)(g.Text,{style:[_.md_code,{backgroundColor:n.background,color:n.text}],children:o.text},r);case"link":return(0,h.jsx)(g.Text,{style:[_.md_link,{color:n.primary}],accessibilityRole:"link",onPress:()=>{g.Linking.openURL(o.url).catch(()=>{})},children:o.text},r);default:return o.text}})})},un=({changelog:e,max_items:t,onMore:n})=>{let o=We();return(0,h.jsx)(g.View,{style:_.groups,children:o.kinds.filter(r=>e[r.key].length).map(r=>{let i=e[r.key],a=t?i.slice(0,t):i,s=i.length-a.length;return(0,h.jsxs)(g.View,{style:_.group,children:[(0,h.jsxs)(g.View,{style:_.group_head,children:[(0,h.jsx)(g.View,{style:[_.badge,{backgroundColor:r.bg}],children:(0,h.jsx)(g.Text,{style:[_.badge_text,{color:r.color}],children:r.label})}),(0,h.jsx)(g.Text,{style:[_.group_count,{color:o.hint}],children:i.length})]}),a.map((c,l)=>(0,h.jsxs)(g.View,{style:_.item,children:[(0,h.jsx)(g.View,{style:[_.dot,{backgroundColor:r.color}]}),(0,h.jsx)(Yn,{text:c,style:[_.item_text,{color:o.text}]})]},l)),s>0&&(0,h.jsx)(g.Text,{style:[_.more,{color:o.primary}],onPress:n,suppressHighlighting:!0,children:Gr(o.labels.changelog_more,{count:s})})]},r.key)})})},ln,ds=()=>(ln!=null||(ln=Promise.all([g.Platform.OS==="ios"?import("expo-image").then(e=>e.Image).catch(()=>{}):Promise.resolve(void 0),import("expo-linear-gradient").then(e=>e.LinearGradient).catch(()=>{})]).then(([e,t])=>({ExpoImage:e,LinearGradient:t}))),ln),gs=()=>{let[e,t]=(0,X.useState)({});return(0,X.useEffect)(()=>{let n=!0;return ds().then(o=>{n&&t(o)}),()=>{n=!1}},[]),e},Kr="#1C1C1E",hs=e=>/^#[0-9a-f]{6}$/i.test(e),ms=()=>{let[e,t]=(0,X.useState)();return(0,X.useEffect)(()=>{let n=!0;return yt().then(o=>{n&&o&&t(()=>o)}),()=>{n=!1}},[]),e},fs=({onPress:e,size:t,GlassView:n,ExpoImage:o})=>{let r=We(),i=r.dark?"#FFFFFF":Kr;return(0,h.jsxs)(g.Pressable,{onPress:e,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Quay l\u1EA1i",style:({pressed:a})=>[_.back_btn,{width:t,height:t,borderRadius:t/2},!n&&_.back_btn_fallback,!n&&r.dark&&{backgroundColor:"#3F3F46",shadowOpacity:0},!n&&a&&_.pressed],children:[n&&(0,h.jsx)(n,{style:[g.StyleSheet.absoluteFill,{borderRadius:t/2}],glassEffectStyle:"regular",colorScheme:r.dark?"dark":"light",isInteractive:!0}),(0,h.jsx)(g.View,{pointerEvents:"none",style:_.icon_layer,children:o?(0,h.jsx)(o,{source:"sf:chevron.left",transition:0,contentFit:"contain",style:{width:20,height:20,fontSize:20,color:i}}):(0,h.jsx)(g.View,{style:[_.chevron,{borderColor:i}]})})]})},Xn=({app_id:e,name:t,onBack:n,renderHeader:o})=>{let r=We(),i=nt(),a=ms(),{ExpoImage:s,LinearGradient:c}=gs(),l=a?46:42,u=o?0:i.top+l+10,{versions:d,loading:f,error:p,reload:y}=rn(e);return(0,h.jsxs)(g.View,{style:[_.history,{backgroundColor:r.background}],children:[o&&(0,h.jsx)(g.View,{style:{paddingTop:i.top},children:o({title:r.labels.history_title,subtitle:t,onBack:n})}),f&&!d.length?(0,h.jsx)(g.ActivityIndicator,{style:[_.loading,{marginTop:u+40}],color:r.primary}):p&&!d.length?(0,h.jsxs)(g.View,{style:[_.center,{marginTop:u+40}],children:[(0,h.jsx)(g.Text,{style:[_.sub_title,{color:r.text_secondary}],children:r.labels.history_error}),(0,h.jsx)(g.TouchableOpacity,{onPress:y,children:(0,h.jsx)(g.Text,{style:[_.link,{color:r.primary}],children:r.labels.retry})})]}):(0,h.jsxs)(g.ScrollView,{contentContainerStyle:[_.history_list,{paddingTop:u+8,paddingBottom:i.bottom+24}],scrollIndicatorInsets:{top:u},children:[d.map(k=>(0,h.jsxs)(g.View,{style:[_.card,{backgroundColor:r.surface,borderRadius:Math.max(r.radius-12,0)}],children:[(0,h.jsxs)(g.View,{style:_.card_head,children:[(0,h.jsxs)(g.Text,{style:[_.version,{color:r.text}],children:["v",k.version]}),(0,h.jsx)(g.Text,{style:[_.date,{color:r.text_secondary}],children:us(k.created_at)})]}),(0,h.jsx)(un,{changelog:k.changelog})]},k.version)),!d.length&&(0,h.jsx)(g.Text,{style:[_.sub_title,_.empty,{color:r.text_secondary}],children:r.labels.history_empty})]}),!o&&(0,h.jsxs)(g.View,{pointerEvents:"box-none",style:[_.float_header,{paddingTop:i.top}],children:[c&&hs(r.background)?(0,h.jsx)(c,{pointerEvents:"none",colors:[`${r.background}F5`,`${r.background}E6`,`${r.background}B3`,`${r.background}00`],locations:[0,.45,.75,1],style:[_.fade,{height:u+28}]}):(0,h.jsx)(g.View,{pointerEvents:"none",style:_.fade,children:ys.map((k,R)=>(0,h.jsx)(g.View,{style:{height:R===0?u:4,backgroundColor:r.background,opacity:k}},R))}),(0,h.jsxs)(g.View,{style:_.header_row,children:[(0,h.jsx)(fs,{onPress:n,size:l,GlassView:a,ExpoImage:s}),(0,h.jsxs)(g.View,{pointerEvents:"none",style:[_.header_title,{left:l+24,right:l+24}],children:[(0,h.jsx)(g.Text,{style:[_.history_title,{color:r.text}],numberOfLines:1,children:r.labels.history_title}),(0,h.jsx)(g.Text,{style:[_.history_sub,{color:r.text_secondary}],numberOfLines:1,children:t})]})]})]})]})},ys=[.96,.9,.8,.68,.55,.42,.3,.18,.08],Yr=e=>({backgroundColor:e.primary,borderRadius:e.button_radius,height:e.button_height,paddingVertical:0,justifyContent:"center"}),bs=4,Qn=({request:e,changelog:t,onClose:n,renderHistoryHeader:o,renderActions:r})=>{var f;let i=We(),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0),[u,d]=(0,X.useState)(0);return(0,h.jsx)(g.Modal,{visible:!0,transparent:!a,animationType:a?"slide":"fade",statusBarTranslucent:!0,onRequestClose:a?()=>s(!1):n,children:a?(0,h.jsx)(Xn,{app_id:e.app_id,name:e.name,onBack:()=>s(!1),renderHeader:o}):(0,h.jsxs)(g.View,{style:[_.overlay,{backgroundColor:i.overlay}],children:[(0,h.jsx)(g.Pressable,{style:g.StyleSheet.absoluteFill,onPress:n,accessibilityLabel:"\u0110\xF3ng"}),(0,h.jsxs)(g.View,{style:[_.sheet,{backgroundColor:i.surface,borderRadius:i.radius}],children:[(0,h.jsxs)(g.View,{style:_.sheet_head,children:[(0,h.jsx)(g.Text,{style:[_.title,{color:i.text}],children:i.labels.changelog_title}),(0,h.jsx)(g.Text,{style:[_.sheet_name,{color:i.text_secondary}],numberOfLines:1,children:e.name}),(0,h.jsxs)(g.View,{style:[_.version_pill,{backgroundColor:i.background}],children:[(0,h.jsx)(g.Text,{style:[_.version_old,{color:i.text_secondary}],children:`v${e.from}`}),(0,h.jsx)(g.Text,{style:[_.version_arrow,{color:i.hint}],children:"\u2192"}),(0,h.jsx)(g.Text,{style:[_.version_new,{color:i.primary}],children:`v${e.to}`})]})]}),(0,h.jsx)(g.ScrollView,{style:_.scroll,contentContainerStyle:_.scroll_content,onContentSizeChange:(p,y)=>l(y),onLayout:p=>d(p.nativeEvent.layout.height),children:(0,h.jsx)(un,{changelog:t,max_items:bs,onMore:()=>s(!0)})}),(0,h.jsx)(g.View,{style:[_.sheet_foot,c>u+1&&[_.sheet_foot_divider,{borderTopColor:i.divider}]],children:r?r({onClose:n,onViewAll:()=>s(!0),labels:i.labels}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(g.TouchableOpacity,{style:[_.btn_primary,Yr(i)],activeOpacity:.8,onPress:n,children:(0,h.jsx)(g.Text,{style:[_.btn_primary_text,{color:i.on_primary}],children:i.labels.changelog_ok})}),(0,h.jsx)(g.TouchableOpacity,{style:_.btn_secondary,onPress:()=>s(!0),children:(0,h.jsx)(g.Text,{style:[_.link,{color:(f=i.secondary)!=null?f:i.primary}],children:i.labels.changelog_view_all})})]})})]})]})})},Zn=({update:e,is_updating:t,progress:n,has_failed:o,onUpdate:r,logo:i,renderAction:a})=>{let s=We(),c=(0,X.useRef)(new g.Animated.Value(0)).current,l=(0,X.useRef)(new g.Animated.Value(30)).current;return(0,X.useEffect)(()=>{g.Animated.parallel([g.Animated.timing(c,{toValue:1,duration:400,useNativeDriver:!0}),g.Animated.spring(l,{toValue:0,friction:8,tension:40,useNativeDriver:!0})]).start()},[c,l]),(0,h.jsx)(g.Modal,{visible:!0,transparent:!0,animationType:"none",statusBarTranslucent:!0,onRequestClose:()=>{},children:(0,h.jsx)(g.View,{style:[_.overlay,{backgroundColor:s.overlay}],children:(0,h.jsxs)(g.Animated.View,{style:[_.container,{backgroundColor:s.surface,borderRadius:s.radius},{opacity:c,transform:[{translateY:l}]}],children:[i&&(0,h.jsx)(g.Image,{source:i,style:_.logo}),(0,h.jsx)(g.Text,{style:[_.title,{color:s.text}],children:t?s.labels.updating_title:s.labels.update_title}),!t&&(0,h.jsx)(g.Text,{style:[_.sub_title,_.gap,{color:s.text_secondary}],children:Gr(s.labels.update_message,{next:e.next_version,current:e.current_version})}),!t&&o&&(0,h.jsx)(g.Text,{style:_.error_text,children:s.labels.update_failed}),t?(0,h.jsxs)(g.View,{style:_.progress_section,children:[(0,h.jsxs)(g.Text,{style:[_.progress_text,{color:s.primary}],children:[n,"%"]}),(0,h.jsx)(g.View,{style:[_.progress_track,{backgroundColor:s.background}],children:(0,h.jsx)(g.View,{style:[_.progress_fill,{backgroundColor:s.primary,width:`${n}%`}]})}),(0,h.jsx)(g.Text,{style:[_.loading_hint,{color:s.hint}],children:s.labels.updating_hint})]}):a?(0,h.jsx)(g.View,{style:_.full,children:a({onUpdate:r,has_failed:o,label:o?s.labels.retry:s.labels.update_now})}):(0,h.jsx)(g.TouchableOpacity,{style:[_.btn_primary,_.full,Yr(s)],activeOpacity:.8,onPress:r,children:(0,h.jsx)(g.Text,{style:[_.btn_primary_text,{color:s.on_primary}],children:o?s.labels.retry:s.labels.update_now})})]})})})},ws=({app_ids:e,shouldShowUpdate:t,logo:n,renderUpdate:o,renderChangelog:r,theme:i,renderHistoryHeader:a,labels:s,renderChangelogActions:c,renderUpdateAction:l})=>{var ne,we;let u=J(U,H=>H.updates),f=((ne=e!=null?e:L().manual_update)!=null?ne:[]).map(H=>u[H]).find(H=>!!H&&(!t||t(H))),p=st(f==null?void 0:f.app_id),[y,k]=(0,X.useState)(!1),[R,O]=(0,X.useState)(!1),x=(0,X.useRef)(!1),q=an(),Y=async()=>{if(!f||x.current)return;x.current=!0,k(!0),O(!1);let H=await en(f.app_id);x.current=!1,k(!1),O(!H)};if(f){let H=(p==null?void 0:p.status)==="updating"?Math.round(((we=p.progress)!=null?we:0)*100):0,P={update:f,is_updating:y,progress:H,has_failed:R,onUpdate:Y};return(0,h.jsx)(cn,{theme:i,labels:s,children:o?o(P):(0,h.jsx)(Zn,{...P,logo:n,renderAction:l})})}if(q){let H={request:q,changelog:Kn(q.versions),onClose:sn};return(0,h.jsx)(cn,{theme:i,labels:s,children:r?r(H):(0,h.jsx)(Qn,{...H,renderHistoryHeader:a,renderActions:c})})}return null},jr=g.Platform.select({ios:{shadowColor:W.shadow,shadowOffset:{width:0,height:10},shadowOpacity:.1,shadowRadius:20},android:{elevation:10}}),_=g.StyleSheet.create({overlay:{flex:1,backgroundColor:W.overlay,justifyContent:"center",alignItems:"center"},container:{width:"85%",maxWidth:340,backgroundColor:W.surface,padding:24,borderRadius:28,alignItems:"center",...jr},sheet:{width:"88%",maxWidth:380,maxHeight:"78%",backgroundColor:W.surface,borderRadius:28,overflow:"hidden",...jr},sheet_head:{alignItems:"center",paddingTop:24,paddingHorizontal:22,paddingBottom:4},sheet_name:{fontSize:13,color:W.sub_title,marginTop:4,maxWidth:"100%"},version_pill:{flexDirection:"row",alignItems:"center",gap:6,marginTop:10,paddingHorizontal:12,paddingVertical:5,borderRadius:999,backgroundColor:W.background},version_old:{fontSize:13,color:W.sub_title,fontVariant:["tabular-nums"]},version_arrow:{fontSize:13,color:W.hint},version_new:{fontSize:13,fontWeight:"700",color:W.blue,fontVariant:["tabular-nums"]},sheet_foot:{paddingHorizontal:22,paddingTop:4,paddingBottom:18},sheet_foot_divider:{borderTopWidth:g.StyleSheet.hairlineWidth,borderTopColor:"rgba(60, 60, 67, 0.18)"},logo:{width:64,height:64,borderRadius:16,marginBottom:20},title:{fontSize:20,fontWeight:"700",color:W.title,textAlign:"center"},sub_title:{fontSize:13,color:W.sub_title,textAlign:"center",lineHeight:18,marginTop:6},gap:{marginBottom:15},error_text:{fontSize:12,textAlign:"center",color:W.error,lineHeight:17,marginBottom:15},progress_section:{width:"100%",alignItems:"center",paddingVertical:8,marginTop:8,gap:12},progress_text:{fontSize:18,fontWeight:"700",color:W.blue},progress_track:{width:"100%",height:6,borderRadius:3,backgroundColor:W.track,overflow:"hidden"},progress_fill:{height:"100%",borderRadius:3,backgroundColor:W.blue},loading_hint:{fontSize:12,color:W.hint,textAlign:"center"},scroll:{flexGrow:0,flexShrink:1},scroll_content:{paddingHorizontal:22,paddingTop:16,paddingBottom:16},groups:{gap:18},group:{gap:8},group_head:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},group_count:{fontSize:12,fontWeight:"600",color:W.hint},dot:{width:5,height:5,borderRadius:3,marginTop:8},more:{fontSize:14,fontWeight:"500",color:W.blue,paddingLeft:17,paddingTop:2},badge:{alignSelf:"flex-start",paddingHorizontal:10,paddingVertical:3,borderRadius:999},badge_text:{fontSize:12,fontWeight:"700"},item:{flexDirection:"row",gap:10,paddingLeft:2},item_text:{flex:1,fontSize:15,lineHeight:21,color:W.title},md_bold:{fontWeight:"700"},md_code:{fontFamily:g.Platform.select({ios:"Menlo",default:"monospace"}),fontSize:13,backgroundColor:"#F2F2F7",color:"#3A3A3C"},md_link:{color:W.blue,textDecorationLine:"underline"},full:{width:"100%"},btn_primary:{marginTop:14,backgroundColor:W.blue,paddingVertical:14,borderRadius:12,alignItems:"center"},btn_primary_text:{color:"white",fontWeight:"600",fontSize:16},btn_secondary:{paddingTop:12,alignItems:"center"},link:{color:W.blue,fontSize:15,fontWeight:"600"},history:{flex:1,backgroundColor:W.background},float_header:{position:"absolute",top:0,left:0,right:0},header_row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:2,paddingBottom:8},header_title:{position:"absolute",top:2,bottom:8,alignItems:"center",justifyContent:"center"},history_title:{fontSize:15,fontWeight:"500",color:"#1C1C1E"},history_sub:{fontSize:11,color:"#71717A",marginTop:1},back_btn:{alignItems:"center",justifyContent:"center"},back_btn_fallback:{backgroundColor:W.surface,...g.Platform.select({ios:{shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.1,shadowRadius:8},default:{borderWidth:g.StyleSheet.hairlineWidth*2,borderColor:"rgba(0, 0, 0, 0.08)"}})},icon_layer:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},fade:{position:"absolute",top:0,left:0,right:0},chevron:{width:11,height:11,borderLeftWidth:2.2,borderBottomWidth:2.2,borderColor:Kr,transform:[{rotate:"45deg"}],marginLeft:4},pressed:{opacity:.6,transform:[{scale:.94}]},history_list:{padding:16,gap:12},card:{backgroundColor:W.surface,borderRadius:16,padding:16,gap:12},card_head:{flexDirection:"row",justifyContent:"space-between",alignItems:"baseline"},version:{fontSize:16,fontWeight:"700",color:W.title},date:{fontSize:13,color:W.sub_title},loading:{marginTop:40},center:{alignItems:"center",marginTop:40,gap:12},empty:{marginTop:40}}),Xr=X.default.memo(ws);0&&(module.exports={CodeType,DEFAULT_MINIAPP_UPDATES_LABELS,DefaultMiniAppChangelogPrompt,DefaultMiniAppSplash,DefaultMiniAppUpdatePrompt,MINIAPP_CHANGELOG_KINDS,MINIAPP_PLATFORM_URL,MiniAppChangelogGroups,MiniAppChangelogHistory,MiniAppChangelogText,MiniAppHost,MiniAppHostError,MiniAppUpdates,MiniAppUpdatesThemeProvider,ScannerEndReason,ScannerEvent,ScannerLayout,ScannerMethod,ToastType,closeMiniApp,configureMiniApp,createMmkvStorage,createReactNativeBiometrics,createRnfsFileSystem,dismissMiniAppChangelog,ensureMiniApp,fetchMiniAppChangelog,getLocalMiniApp,getMiniAppCatalog,getMiniAppCatalogEntry,getMiniAppChangelogSeen,getMiniAppStatuses,getMiniAppUpdate,getPendingChangelog,installBundledMiniApp,markMiniAppChangelogSeen,mergeMiniAppChangelog,onMiniAppEvent,openMiniApp,parseInlineMarkdown,pauseMiniApp,pauseMiniAppDownloads,preloadMiniApp,releaseSpeechFor,resolveMiniAppUpdatesTheme,restoreMiniApp,resumeMiniApp,resumeMiniAppDownloads,sendEventToWeb,showMiniAppChangelog,stripInlineMarkdown,syncMiniAppCatalog,uninstallMiniApp,updateMiniApp,uploadToUrl,useMiniAppChangelog,useMiniAppChangelogRequest,useMiniAppDownload,useMiniAppDownloadsPaused,useMiniAppUpdatesTheme});
|
|
89
|
+
Vui l\xF2ng c\u1EADp nh\u1EADt \u0111\u1EC3 ti\u1EBFp t\u1EE5c s\u1EED d\u1EE5ng.`,update_failed:"C\u1EADp nh\u1EADt kh\xF4ng th\xE0nh c\xF4ng. Ki\u1EC3m tra k\u1EBFt n\u1ED1i m\u1EA1ng r\u1ED3i th\u1EED l\u1EA1i.",update_now:"C\u1EADp nh\u1EADt ngay",updating_hint:"Vui l\xF2ng kh\xF4ng t\u1EAFt \u1EE9ng d\u1EE5ng"},Gr=(e,t)=>e.replace(/\{(\w+)\}/g,(n,o)=>o in t?String(t[o]):n),W={blue:"#007AFF",track:"#E5E5EA",overlay:"rgba(0, 0, 0, 0.6)",shadow:"#000000",title:"#1A1A1A",sub_title:"#666666",error:"#D92D20",hint:"#C0C0C0",surface:"#FFFFFF",background:"#F2F2F7"},Jn=[{key:"new",label:"M\u1EDBi",color:"#007AFF",bg:"#E5F1FF"},{key:"fix",label:"S\u1EEDa l\u1ED7i",color:"#C4320A",bg:"#FFF1EB"},{key:"improve",label:"C\u1EA3i thi\u1EC7n",color:"#067647",bg:"#E7F7EE"}],as={primary:"#007AFF",on_primary:"#FFFFFF",background:"#F2F2F7",surface:"#FFFFFF",text:"#1C1C1E",text_secondary:"#666666",hint:"#AEAEB2",overlay:"rgba(0, 0, 0, 0.6)",divider:"rgba(60, 60, 67, 0.18)",radius:28,button_radius:12,button_height:50},ls={primary:"#0A84FF",on_primary:"#FFFFFF",background:"#000000",surface:"#1C1C1E",text:"#FFFFFF",text_secondary:"#A1A1AA",hint:"#636366",overlay:"rgba(0, 0, 0, 0.7)",divider:"rgba(84, 84, 88, 0.6)",radius:28,button_radius:12,button_height:50},cs={new:{color:"#64B5FF",bg:"rgba(10, 132, 255, 0.18)"},fix:{color:"#FF9F7A",bg:"rgba(255, 112, 67, 0.18)"},improve:{color:"#5FD39A",bg:"rgba(48, 209, 88, 0.18)"}},pn=(e={},t)=>{let n=!!e.dark,{kinds:o,...r}=e;return{...n?ls:as,...Object.fromEntries(Object.entries(r).filter(([,a])=>a!==void 0)),dark:n,labels:{...Gn,...t},kinds:Jn.map(a=>({...a,...n?cs[a.key]:null,...a.key==="new"&&e.primary?{color:e.primary}:null,...o==null?void 0:o[a.key]}))}},Jr=(0,X.createContext)(void 0),cn=({theme:e,labels:t,children:n})=>{let o=(0,X.useMemo)(()=>pn(e,t),[e,t]);return(0,h.jsx)(Jr.Provider,{value:o,children:n})},ps=pn(),We=()=>{var e;return(e=(0,X.useContext)(Jr))!=null?e:ps},Kn=e=>({new:e.flatMap(t=>t.changelog.new),fix:e.flatMap(t=>t.changelog.fix),improve:e.flatMap(t=>t.changelog.improve)}),us=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("vi-VN")},Yn=({text:e,style:t})=>{let n=We();return(0,h.jsx)(g.Text,{style:t,children:Pt(e.replace(/^(?:[-*•]\s+)+/,"")).map((o,r)=>{switch(o.type){case"bold":return(0,h.jsx)(g.Text,{style:_.md_bold,children:o.text},r);case"code":return(0,h.jsx)(g.Text,{style:[_.md_code,{backgroundColor:n.background,color:n.text}],children:o.text},r);case"link":return(0,h.jsx)(g.Text,{style:[_.md_link,{color:n.primary}],accessibilityRole:"link",onPress:()=>{g.Linking.openURL(o.url).catch(()=>{})},children:o.text},r);default:return o.text}})})},un=({changelog:e,max_items:t,onMore:n})=>{let o=We();return(0,h.jsx)(g.View,{style:_.groups,children:o.kinds.filter(r=>e[r.key].length).map(r=>{let i=e[r.key],a=t?i.slice(0,t):i,s=i.length-a.length;return(0,h.jsxs)(g.View,{style:_.group,children:[(0,h.jsxs)(g.View,{style:_.group_head,children:[(0,h.jsx)(g.View,{style:[_.badge,{backgroundColor:r.bg}],children:(0,h.jsx)(g.Text,{style:[_.badge_text,{color:r.color}],children:r.label})}),(0,h.jsx)(g.Text,{style:[_.group_count,{color:o.hint}],children:i.length})]}),a.map((c,l)=>(0,h.jsxs)(g.View,{style:_.item,children:[(0,h.jsx)(g.View,{style:[_.dot,{backgroundColor:r.color}]}),(0,h.jsx)(Yn,{text:c,style:[_.item_text,{color:o.text}]})]},l)),s>0&&(0,h.jsx)(g.Text,{style:[_.more,{color:o.primary}],onPress:n,suppressHighlighting:!0,children:Gr(o.labels.changelog_more,{count:s})})]},r.key)})})},ln,ds=()=>(ln!=null||(ln=Promise.all([g.Platform.OS==="ios"?import("expo-image").then(e=>e.Image).catch(()=>{}):Promise.resolve(void 0),import("expo-linear-gradient").then(e=>e.LinearGradient).catch(()=>{})]).then(([e,t])=>({ExpoImage:e,LinearGradient:t}))),ln),gs=()=>{let[e,t]=(0,X.useState)({});return(0,X.useEffect)(()=>{let n=!0;return ds().then(o=>{n&&t(o)}),()=>{n=!1}},[]),e},Kr="#1C1C1E",hs=e=>/^#[0-9a-f]{6}$/i.test(e),ms=()=>{let[e,t]=(0,X.useState)();return(0,X.useEffect)(()=>{let n=!0;return yt().then(o=>{n&&o&&t(()=>o)}),()=>{n=!1}},[]),e},fs=({onPress:e,size:t,GlassView:n,ExpoImage:o})=>{let r=We(),i=r.dark?"#FFFFFF":Kr;return(0,h.jsxs)(g.Pressable,{onPress:e,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Quay l\u1EA1i",style:({pressed:a})=>[_.back_btn,{width:t,height:t,borderRadius:t/2},!n&&_.back_btn_fallback,!n&&r.dark&&{backgroundColor:"#3F3F46",shadowOpacity:0},!n&&a&&_.pressed],children:[n&&(0,h.jsx)(n,{style:[g.StyleSheet.absoluteFill,{borderRadius:t/2}],glassEffectStyle:"regular",colorScheme:r.dark?"dark":"light",isInteractive:!0}),(0,h.jsx)(g.View,{pointerEvents:"none",style:_.icon_layer,children:o?(0,h.jsx)(o,{source:"sf:chevron.left",transition:0,contentFit:"contain",style:{width:20,height:20,fontSize:20,color:i}}):(0,h.jsx)(g.View,{style:[_.chevron,{borderColor:i}]})})]})},Xn=({app_id:e,name:t,onBack:n,renderHeader:o})=>{let r=We(),i=nt(),a=ms(),{ExpoImage:s,LinearGradient:c}=gs(),l=a?46:42,u=o?0:i.top+l+10,{versions:d,loading:f,error:p,reload:y}=rn(e);return(0,h.jsxs)(g.View,{style:[_.history,{backgroundColor:r.background}],children:[o&&(0,h.jsx)(g.View,{style:{paddingTop:i.top},children:o({title:r.labels.history_title,subtitle:t,onBack:n})}),f&&!d.length?(0,h.jsx)(g.ActivityIndicator,{style:[_.loading,{marginTop:u+40}],color:r.primary}):p&&!d.length?(0,h.jsxs)(g.View,{style:[_.center,{marginTop:u+40}],children:[(0,h.jsx)(g.Text,{style:[_.sub_title,{color:r.text_secondary}],children:r.labels.history_error}),(0,h.jsx)(g.TouchableOpacity,{onPress:y,children:(0,h.jsx)(g.Text,{style:[_.link,{color:r.primary}],children:r.labels.retry})})]}):(0,h.jsxs)(g.ScrollView,{contentContainerStyle:[_.history_list,{paddingTop:u+8,paddingBottom:i.bottom+24}],scrollIndicatorInsets:{top:u},children:[d.map(k=>(0,h.jsxs)(g.View,{style:[_.card,{backgroundColor:r.surface,borderRadius:Math.max(r.radius-12,0)}],children:[(0,h.jsxs)(g.View,{style:_.card_head,children:[(0,h.jsxs)(g.Text,{style:[_.version,{color:r.text}],children:["v",k.version]}),(0,h.jsx)(g.Text,{style:[_.date,{color:r.text_secondary}],children:us(k.created_at)})]}),(0,h.jsx)(un,{changelog:k.changelog})]},k.version)),!d.length&&(0,h.jsx)(g.Text,{style:[_.sub_title,_.empty,{color:r.text_secondary}],children:r.labels.history_empty})]}),!o&&(0,h.jsxs)(g.View,{pointerEvents:"box-none",style:[_.float_header,{paddingTop:i.top}],children:[c&&hs(r.background)?(0,h.jsx)(c,{pointerEvents:"none",colors:[`${r.background}F5`,`${r.background}E6`,`${r.background}B3`,`${r.background}00`],locations:[0,.45,.75,1],style:[_.fade,{height:u+28}]}):(0,h.jsx)(g.View,{pointerEvents:"none",style:_.fade,children:ys.map((k,R)=>(0,h.jsx)(g.View,{style:{height:R===0?u:4,backgroundColor:r.background,opacity:k}},R))}),(0,h.jsxs)(g.View,{style:_.header_row,children:[(0,h.jsx)(fs,{onPress:n,size:l,GlassView:a,ExpoImage:s}),(0,h.jsxs)(g.View,{pointerEvents:"none",style:[_.header_title,{left:l+24,right:l+24}],children:[(0,h.jsx)(g.Text,{style:[_.history_title,{color:r.text}],numberOfLines:1,children:r.labels.history_title}),(0,h.jsx)(g.Text,{style:[_.history_sub,{color:r.text_secondary}],numberOfLines:1,children:t})]})]})]})]})},ys=[.96,.9,.8,.68,.55,.42,.3,.18,.08],Yr=e=>({backgroundColor:e.primary,borderRadius:e.button_radius,height:e.button_height,paddingVertical:0,justifyContent:"center"}),bs=4,Qn=({request:e,changelog:t,onClose:n,renderHistoryHeader:o,renderActions:r})=>{var f;let i=We(),[a,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(0),[u,d]=(0,X.useState)(0);return(0,h.jsx)(g.Modal,{visible:!0,transparent:!a,animationType:a?"slide":"fade",statusBarTranslucent:!0,onRequestClose:a?()=>s(!1):n,children:a?(0,h.jsx)(Xn,{app_id:e.app_id,name:e.name,onBack:()=>s(!1),renderHeader:o}):(0,h.jsxs)(g.View,{style:[_.overlay,{backgroundColor:i.overlay}],children:[(0,h.jsx)(g.Pressable,{style:g.StyleSheet.absoluteFill,onPress:n,accessibilityLabel:"\u0110\xF3ng"}),(0,h.jsxs)(g.View,{style:[_.sheet,{backgroundColor:i.surface,borderRadius:i.radius}],children:[(0,h.jsxs)(g.View,{style:_.sheet_head,children:[(0,h.jsx)(g.Text,{style:[_.title,{color:i.text}],children:i.labels.changelog_title}),(0,h.jsx)(g.Text,{style:[_.sheet_name,{color:i.text_secondary}],numberOfLines:1,children:e.name}),(0,h.jsxs)(g.View,{style:[_.version_pill,{backgroundColor:i.background}],children:[(0,h.jsx)(g.Text,{style:[_.version_old,{color:i.text_secondary}],children:`v${e.from}`}),(0,h.jsx)(g.Text,{style:[_.version_arrow,{color:i.hint}],children:"\u2192"}),(0,h.jsx)(g.Text,{style:[_.version_new,{color:i.primary}],children:`v${e.to}`})]})]}),(0,h.jsx)(g.ScrollView,{style:_.scroll,contentContainerStyle:_.scroll_content,onContentSizeChange:(p,y)=>l(y),onLayout:p=>d(p.nativeEvent.layout.height),children:(0,h.jsx)(un,{changelog:t,max_items:bs,onMore:()=>s(!0)})}),(0,h.jsx)(g.View,{style:[_.sheet_foot,c>u+1&&[_.sheet_foot_divider,{borderTopColor:i.divider}]],children:r?r({onClose:n,onViewAll:()=>s(!0),labels:i.labels}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(g.TouchableOpacity,{style:[_.btn_primary,Yr(i)],activeOpacity:.8,onPress:n,children:(0,h.jsx)(g.Text,{style:[_.btn_primary_text,{color:i.on_primary}],children:i.labels.changelog_ok})}),(0,h.jsx)(g.TouchableOpacity,{style:_.btn_secondary,onPress:()=>s(!0),children:(0,h.jsx)(g.Text,{style:[_.link,{color:(f=i.secondary)!=null?f:i.primary}],children:i.labels.changelog_view_all})})]})})]})]})})},Zn=({update:e,is_updating:t,progress:n,has_failed:o,onUpdate:r,logo:i,renderAction:a})=>{let s=We(),c=(0,X.useRef)(new g.Animated.Value(0)).current,l=(0,X.useRef)(new g.Animated.Value(30)).current;return(0,X.useEffect)(()=>{g.Animated.parallel([g.Animated.timing(c,{toValue:1,duration:400,useNativeDriver:!0}),g.Animated.spring(l,{toValue:0,friction:8,tension:40,useNativeDriver:!0})]).start()},[c,l]),(0,h.jsx)(g.Modal,{visible:!0,transparent:!0,animationType:"none",statusBarTranslucent:!0,onRequestClose:()=>{},children:(0,h.jsx)(g.View,{style:[_.overlay,{backgroundColor:s.overlay}],children:(0,h.jsxs)(g.Animated.View,{style:[_.container,{backgroundColor:s.surface,borderRadius:s.radius},{opacity:c,transform:[{translateY:l}]}],children:[i&&(0,h.jsx)(g.Image,{source:i,style:_.logo}),(0,h.jsx)(g.Text,{style:[_.title,{color:s.text}],children:t?s.labels.updating_title:s.labels.update_title}),!t&&(0,h.jsx)(g.Text,{style:[_.sub_title,_.gap,{color:s.text_secondary}],children:Gr(s.labels.update_message,{next:e.next_version,current:e.current_version})}),!t&&o&&(0,h.jsx)(g.Text,{style:_.error_text,children:s.labels.update_failed}),t?(0,h.jsxs)(g.View,{style:_.progress_section,children:[(0,h.jsxs)(g.Text,{style:[_.progress_text,{color:s.primary}],children:[n,"%"]}),(0,h.jsx)(g.View,{style:[_.progress_track,{backgroundColor:s.background}],children:(0,h.jsx)(g.View,{style:[_.progress_fill,{backgroundColor:s.primary,width:`${n}%`}]})}),(0,h.jsx)(g.Text,{style:[_.loading_hint,{color:s.hint}],children:s.labels.updating_hint})]}):a?(0,h.jsx)(g.View,{style:_.full,children:a({onUpdate:r,has_failed:o,label:o?s.labels.retry:s.labels.update_now})}):(0,h.jsx)(g.TouchableOpacity,{style:[_.btn_primary,_.full,Yr(s)],activeOpacity:.8,onPress:r,children:(0,h.jsx)(g.Text,{style:[_.btn_primary_text,{color:s.on_primary}],children:o?s.labels.retry:s.labels.update_now})})]})})})},ws=({app_ids:e,shouldShowUpdate:t,logo:n,renderUpdate:o,renderChangelog:r,theme:i,renderHistoryHeader:a,labels:s,renderChangelogActions:c,renderUpdateAction:l})=>{var ne,we;let u=J(U,H=>H.updates),f=((ne=e!=null?e:L().manual_update)!=null?ne:[]).map(H=>u[H]).find(H=>!!H&&(!t||t(H))),p=st(f==null?void 0:f.app_id),[y,k]=(0,X.useState)(!1),[R,O]=(0,X.useState)(!1),x=(0,X.useRef)(!1),q=an(),Y=async()=>{if(!f||x.current)return;x.current=!0,k(!0),O(!1);let H=await en(f.app_id);x.current=!1,k(!1),O(!H)};if(f){let H=(p==null?void 0:p.status)==="updating"?Math.round(((we=p.progress)!=null?we:0)*100):0,P={update:f,is_updating:y,progress:H,has_failed:R,onUpdate:Y};return(0,h.jsx)(cn,{theme:i,labels:s,children:o?o(P):(0,h.jsx)(Zn,{...P,logo:n,renderAction:l})})}if(q){let H={request:q,changelog:Kn(q.versions),onClose:sn};return(0,h.jsx)(cn,{theme:i,labels:s,children:r?r(H):(0,h.jsx)(Qn,{...H,renderHistoryHeader:a,renderActions:c})})}return null},jr=g.Platform.select({ios:{shadowColor:W.shadow,shadowOffset:{width:0,height:10},shadowOpacity:.1,shadowRadius:20},android:{elevation:10}}),_=g.StyleSheet.create({overlay:{flex:1,backgroundColor:W.overlay,justifyContent:"center",alignItems:"center"},container:{width:"85%",maxWidth:340,backgroundColor:W.surface,padding:24,borderRadius:28,alignItems:"center",...jr},sheet:{width:"88%",maxWidth:380,maxHeight:"78%",backgroundColor:W.surface,borderRadius:28,overflow:"hidden",...jr},sheet_head:{alignItems:"center",paddingTop:24,paddingHorizontal:22,paddingBottom:4},sheet_name:{fontSize:13,color:W.sub_title,marginTop:4,maxWidth:"100%"},version_pill:{flexDirection:"row",alignItems:"center",gap:6,marginTop:10,paddingHorizontal:12,paddingVertical:5,borderRadius:999,backgroundColor:W.background},version_old:{fontSize:13,color:W.sub_title,fontVariant:["tabular-nums"]},version_arrow:{fontSize:13,color:W.hint},version_new:{fontSize:13,fontWeight:"700",color:W.blue,fontVariant:["tabular-nums"]},sheet_foot:{paddingHorizontal:22,paddingTop:4,paddingBottom:18},sheet_foot_divider:{borderTopWidth:g.StyleSheet.hairlineWidth,borderTopColor:"rgba(60, 60, 67, 0.18)"},logo:{width:64,height:64,borderRadius:16,marginBottom:20},title:{fontSize:20,fontWeight:"700",color:W.title,textAlign:"center"},sub_title:{fontSize:13,color:W.sub_title,textAlign:"center",lineHeight:18,marginTop:6},gap:{marginBottom:15},error_text:{fontSize:12,textAlign:"center",color:W.error,lineHeight:17,marginBottom:15},progress_section:{width:"100%",alignItems:"center",paddingVertical:8,marginTop:8,gap:12},progress_text:{fontSize:18,fontWeight:"700",color:W.blue},progress_track:{width:"100%",height:6,borderRadius:3,backgroundColor:W.track,overflow:"hidden"},progress_fill:{height:"100%",borderRadius:3,backgroundColor:W.blue},loading_hint:{fontSize:12,color:W.hint,textAlign:"center"},scroll:{flexGrow:0,flexShrink:1},scroll_content:{paddingHorizontal:22,paddingTop:16,paddingBottom:16},groups:{gap:18},group:{gap:8},group_head:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},group_count:{fontSize:12,fontWeight:"600",color:W.hint},dot:{width:5,height:5,borderRadius:3,marginTop:8},more:{fontSize:14,fontWeight:"500",color:W.blue,paddingLeft:17,paddingTop:2},badge:{alignSelf:"flex-start",paddingHorizontal:10,paddingVertical:3,borderRadius:999},badge_text:{fontSize:12,fontWeight:"700"},item:{flexDirection:"row",gap:10,paddingLeft:2},item_text:{flex:1,fontSize:15,lineHeight:21,color:W.title},md_bold:{fontWeight:"700"},md_code:{fontFamily:g.Platform.select({ios:"Menlo",default:"monospace"}),fontSize:13,backgroundColor:"#F2F2F7",color:"#3A3A3C"},md_link:{color:W.blue,textDecorationLine:"underline"},full:{width:"100%"},btn_primary:{marginTop:14,backgroundColor:W.blue,paddingVertical:14,borderRadius:12,alignItems:"center"},btn_primary_text:{color:"white",fontWeight:"600",fontSize:16},btn_secondary:{paddingTop:12,alignItems:"center"},link:{color:W.blue,fontSize:15,fontWeight:"600"},history:{flex:1,backgroundColor:W.background},float_header:{position:"absolute",top:0,left:0,right:0},header_row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:2,paddingBottom:8},header_title:{position:"absolute",top:2,bottom:8,alignItems:"center",justifyContent:"center"},history_title:{fontSize:15,fontWeight:"500",color:"#1C1C1E"},history_sub:{fontSize:11,color:"#71717A",marginTop:1},back_btn:{alignItems:"center",justifyContent:"center"},back_btn_fallback:{backgroundColor:W.surface,...g.Platform.select({ios:{shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.1,shadowRadius:8},default:{borderWidth:g.StyleSheet.hairlineWidth*2,borderColor:"rgba(0, 0, 0, 0.08)"}})},icon_layer:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},fade:{position:"absolute",top:0,left:0,right:0},chevron:{width:11,height:11,borderLeftWidth:2.2,borderBottomWidth:2.2,borderColor:Kr,transform:[{rotate:"45deg"}],marginLeft:4},pressed:{opacity:.6,transform:[{scale:.94}]},history_list:{padding:16,gap:12},card:{backgroundColor:W.surface,borderRadius:16,padding:16,gap:12},card_head:{flexDirection:"row",justifyContent:"space-between",alignItems:"baseline"},version:{fontSize:16,fontWeight:"700",color:W.title},date:{fontSize:13,color:W.sub_title},loading:{marginTop:40},center:{alignItems:"center",marginTop:40,gap:12},empty:{marginTop:40}}),Xr=X.default.memo(ws);0&&(module.exports={CodeType,DEFAULT_MINIAPP_UPDATES_LABELS,DefaultMiniAppChangelogPrompt,DefaultMiniAppSplash,DefaultMiniAppUpdatePrompt,MINIAPP_CHANGELOG_KINDS,MINIAPP_PLATFORM_URL,MiniAppChangelogGroups,MiniAppChangelogHistory,MiniAppChangelogText,MiniAppHost,MiniAppHostError,MiniAppUpdates,MiniAppUpdatesThemeProvider,ScannerEndReason,ScannerEvent,ScannerLayout,ScannerMethod,ToastType,closeMiniApp,configureMiniApp,createMmkvStorage,createReactNativeBiometrics,createRnfsFileSystem,dismissMiniAppChangelog,ensureMiniApp,fetchMiniAppChangelog,getLocalMiniApp,getMiniAppCatalog,getMiniAppCatalogEntry,getMiniAppChangelogSeen,getMiniAppStatuses,getMiniAppUpdate,getPendingChangelog,installBundledMiniApp,markMiniAppChangelogSeen,mergeMiniAppChangelog,onMiniAppEvent,openMiniApp,parseInlineMarkdown,pauseMiniApp,pauseMiniAppDownloads,preloadMiniApp,releaseSpeechFor,resolveMiniAppUpdatesTheme,restoreMiniApp,resumeMiniApp,resumeMiniAppDownloads,sendEventToWeb,showMiniAppChangelog,stripInlineMarkdown,syncMiniAppCatalog,uninstallMiniApp,updateMiniApp,uploadToUrl,useMiniAppChangelog,useMiniAppChangelogRequest,useMiniAppDownload,useMiniAppDownloadsPaused,useMiniAppUpdatesTheme});
|
package/dist/index.mjs
CHANGED
|
@@ -86,4 +86,4 @@ var pt="https://retion-miniapp-platform.vercel.app",We=null,go=new Set,ui=e=>{We
|
|
|
86
86
|
if (ctx.state === 'running') { play(); } else { ctx.resume().then(play).catch(function () {}); }
|
|
87
87
|
} catch (e) {}
|
|
88
88
|
})(); true;`,Gi=new Set(["selection","impactLight","impactMedium","impactHeavy","rigid","soft","notificationSuccess","notificationWarning","notificationError"]),$t=(e,t)=>{if(typeof e!="string"||!e)throw new g("INVALID_PARAMS",`Thi\u1EBFu ${t}`);return e},wr=async({method:e,params:t},{getHostData:n,getPermissions:o,getContext:r,is_dark:i,close:a,app_id:s,instance_id:c,options:l,emit:u,isActive:d,playBeep:h})=>{var P,S,L,W,Q,ye,D,v;let p=l==null?void 0:l.handlers,m={app_id:s,instance_id:c,close:a},C=()=>{var y;(y=l==null?void 0:l.haptic)==null||y.call(l,"impactLight"),h==null||h()},T=()=>new g("NOT_SUPPORTED",`${e} ch\u01B0a h\u1ED7 tr\u1EE3 \u1EDF \u1EE9ng d\u1EE5ng n\xE0y`);switch(e){case"getCurrentLocation":{let y=mo(t);return wt(e,()=>fo(y,d))}case"speech.start":{if(!u)throw T();let y={};if((t==null?void 0:t.lang)!==void 0){if(typeof t.lang!="string"||!/^[a-zA-Z]{2,8}(-[a-zA-Z0-9]{1,8})*$/.test(t.lang))throw new g("INVALID_PARAMS","lang ph\u1EA3i l\xE0 m\xE3 ng\xF4n ng\u1EEF nh\u01B0 vi-VN");y.lang=t.lang}for(let N of["continuous","interimResults","addsPunctuation","requiresOnDeviceRecognition"])if((t==null?void 0:t[N])!==void 0){if(typeof t[N]!="boolean")throw new g("INVALID_PARAMS",`${N} ph\u1EA3i l\xE0 boolean`);y[N]=t[N]}if((t==null?void 0:t.mode)!==void 0&&t.mode!=="s2t"&&t.mode!=="voice")throw new g("INVALID_PARAMS","mode ph\u1EA3i l\xE0 's2t' ho\u1EB7c 'voice'");let E=(t==null?void 0:t.mode)==="s2t"?"s2t":"voice",x=E==="voice"?(P=l==null?void 0:l.voice)!=null?P:l==null?void 0:l.speech:void 0;if(Ho(c,x),x){Bo(c,x);try{return await x.start({owner:c,app_id:s,mode:E,options:y,emit:u,isActive:d!=null?d:(()=>!0)})}catch(N){throw qo(c,x),N}}return Wo(c,y,u,d)}case"speech.stop":{let y=zo(c);return y?y.stop(c):jo(c)}case yt.scan:return Zo(c,An(t),d,C);case yt.start:{if(!u)throw T();return er(c,An(t),u,d,C)}case yt.stop:return tr(c);case"uploadFiles":{let{task_id:y,...E}=t!=null?t:{};if(y!==void 0&&(typeof y!="string"||!y))throw new g("INVALID_PARAMS","task_id ph\u1EA3i l\xE0 chu\u1ED7i");return Lo(xo(E),{instance_id:c,app_id:s,getContext:r,task_id:y,config:l==null?void 0:l.upload,emit:u,exclusivePick:x=>wt("uploadFiles.pick",x)})}case"uploadFiles.cancel":Io(c,t==null?void 0:t.task_id);return;case"getUploadCapabilities":return Oo(l==null?void 0:l.upload);case"getBiometricAvailability":return((S=l==null?void 0:l.biometrics)!=null?S:await hn()).getAvailability();case"authenticateBiometric":{let y=$t(t==null?void 0:t.reason,"reason").trim();if(!y||y.length>200)throw new g("INVALID_PARAMS","reason must contain 1\u2013200 characters");let E=t==null?void 0:t.cancelButtonText;if(E!==void 0&&(typeof E!="string"||!E.trim()||E.length>80))throw new g("INVALID_PARAMS","Invalid cancelButtonText");return wt(e,async()=>{var N;return((N=l==null?void 0:l.biometrics)!=null?N:await hn()).authenticate({reason:y,cancelButtonText:E})})}case"requestPayment":{let y=p==null?void 0:p.requestPayment;if(!y)throw T();let E=t==null?void 0:t.amount;if(typeof E!="number"||!Number.isFinite(E)||E<=0)throw new g("INVALID_PARAMS","amount ph\u1EA3i l\xE0 s\u1ED1 > 0");let x={...t,amount:E,currency:$t(t==null?void 0:t.currency,"currency")};return wt(e,()=>y(x,m))}case"printImage":{let y=p==null?void 0:p.printImage;if(!y)throw T();let E=$t(t==null?void 0:t.image,"image");await wt(e,()=>y({image:E},m));return}case"openScreen":if(!(p!=null&&p.openScreen))throw T();await p.openScreen({screen:$t(t==null?void 0:t.screen,"screen"),params:t==null?void 0:t.params},m);return;case"closeApp":a();return;case"openWebview":{let y=String((L=t==null?void 0:t.url)!=null?L:"");if(!/^https?:\/\//i.test(y))throw new g("INVALID_PARAMS","url ph\u1EA3i l\xE0 http(s)");await(l!=null&&l.openUrl?l.openUrl(y):rr.openURL(y));return}case"openLink":{let y=String((W=t==null?void 0:t.url)!=null?W:"").trim();if(!/^[a-z][a-z0-9+.-]*:/i.test(y)||/^(javascript|file|data|about|blob):/i.test(y))throw new g("INVALID_PARAMS","url kh\xF4ng h\u1EE3p l\u1EC7");try{await(l!=null&&l.openUrl?l.openUrl(y):rr.openURL(y))}catch(E){throw new g("NOT_SUPPORTED",String((ye=(Q=E==null?void 0:E.message)!=null?Q:E)!=null?ye:"Kh\xF4ng m\u1EDF \u0111\u01B0\u1EE3c link"))}return}case"showToast":{let y=Uo(t);if(!y||(d==null?void 0:d())===!1)return;l!=null&&l.showToast?l.showToast(y.message,{type:y.type}):No(y.message,y.type);return}case"haptic":{let y=Gi.has(t==null?void 0:t.type)?t.type:"selection";(D=l==null?void 0:l.haptic)==null||D.call(l,y);return}case"getSystemInfo":return{platform:ji.OS==="ios"?"ios":"android",appVersion:(v=l==null?void 0:l.app_version)!=null?v:"",theme:i?"dark":"light"};case"getAccessToken":{let y=n().access_token;if(!y)throw new g("HOST_ERROR","Mini app ch\u01B0a c\xF3 token cho page n\xE0y");return y}case"getToken":{let y=t==null?void 0:t.type;if(y==="access"){let N=n().access_token;if(!N)throw new g("HOST_ERROR","Mini app ch\u01B0a c\xF3 token cho page n\xE0y");return N}if(y!=="partner"&&y!=="chatbox")throw new g("HOST_ERROR",`Lo\u1EA1i token kh\xF4ng h\u1EE3p l\u1EC7: ${String(y)}`);let E=fr[y];if(!o().includes(E))throw new g("PERMISSION_DENIED",`Mini app ch\u01B0a \u0111\u01B0\u1EE3c c\u1EA5p quy\u1EC1n ${E} (Console \u2192 Quy\u1EC1n l\u1EA5y token)`);let x=y==="partner"?n().partner_token:n().chatbox_token;if(!x)throw new g("HOST_ERROR",`Kh\xF4ng c\xF3 ${E}`);return x}case"getUserInfo":{let y=n().user;if(!y)throw new g("HOST_ERROR","Kh\xF4ng l\u1EA5y \u0111\u01B0\u1EE3c th\xF4ng tin nh\xE2n vi\xEAn");return y}case"getPageInfo":{let y=n().page;if(!y)throw new g("HOST_ERROR","Kh\xF4ng l\u1EA5y \u0111\u01B0\u1EE3c th\xF4ng tin page");return y}case"sendMessage":case"insertText":throw new g("NOT_SUPPORTED",`${e} ch\u01B0a h\u1ED7 tr\u1EE3 \u1EDF phi\xEAn b\u1EA3n app n\xE0y`);default:throw new g("NOT_SUPPORTED",`API kh\xF4ng t\u1ED3n t\u1EA1i: ${e}`)}};var En=e=>`bundle:${e}`,kn=()=>`${R().file_system.document_dir}/miniapps`,Rn=kn,On=(e,t,n="index.html",o=!1,r=[])=>{let i=`${Rn()}/${e}/${t}`;return{app_id:e,version:t,dir:i,entry_uri:`file://${i}/${n}`,context_update:o,permissions:r}},Pn=e=>{var t;R().storage.setString(En(e.app_id),JSON.stringify({version:e.version,entry:e.entry,context_update:!!e.context_update,permissions:(t=e.permissions)!=null?t:[]}))},Ji=(e,t)=>/^https?:\/\//.test(t)?t:`${e.replace(/[^/]*$/,"")}${t}`,V=e=>{let t=R().storage.getString(En(e));if(!t)return null;try{let{version:n,entry:o,context_update:r,permissions:i}=JSON.parse(t);return On(e,n,o,!!r,Array.isArray(i)?i:[])}catch{return null}},Le=e=>R().file_system.exists(e.entry_uri.replace("file://","")),Fn=async e=>{let t=V(e.app_id);return(t==null?void 0:t.version)===e.version&&await Le(t)},Ar=async(e,t)=>{let n=R().file_system,o=`${Rn()}/${e}`,r=await n.listDir(o).catch(()=>[]);await Promise.all(r.filter(i=>!t.includes(i)).map(i=>n.remove(`${o}/${i}`).catch(()=>{})))},Sr=async e=>{var t;await((t=St[e])==null?void 0:t.catch(()=>{})),R().storage.setString(En(e),""),await R().file_system.remove(`${Rn()}/${e}`).catch(()=>{})},nt=class extends Error{constructor(){super("cancelled"),this.name="MiniAppInstallCancelled"}},St={},Mr=(e,t)=>{var i;let o=((i=St[e])!=null?i:Promise.resolve()).catch(()=>{}).then(t),r=o.catch(()=>{});return St[e]=r,r.then(()=>{St[e]===r&&delete St[e]}),o},In=(e,t)=>{var r,i;let n=e.split(".").map(a=>parseInt(a,10)||0),o=t.split(".").map(a=>parseInt(a,10)||0);for(let a=0;a<Math.max(n.length,o.length);a++){let s=((r=n[a])!=null?r:0)-((i=o[a])!=null?i:0);if(s)return s}return 0},Ki=({manifest:e,zip_path:t})=>Mr(e.app_id,async()=>{var i;let n=R().file_system,o=V(e.app_id);if(o&&In(o.version,e.version)>=0&&await Le(o))return o;if(e.sha256&&n.sha256&&await n.sha256(t)!==e.sha256)throw new Error("sha256 mismatch");let r=On(e.app_id,e.version,e.entry,!!e.context_update,(i=e.permissions)!=null?i:[]);return await n.remove(r.dir).catch(()=>{}),await n.mkdir(r.dir),await n.unzip(t,r.dir),Pn(e),ge("\u0111\xE3 c\xE0i b\u1EA3n \u0111\xF3ng s\u1EB5n",e.app_id,e.version),Ar(e.app_id,[e.version,o==null?void 0:o.version].filter(Boolean)),r}),Ln=(e,{base_url:t,onProgress:n}={})=>{let o=R().file_system,r=null,i=!1,a=`${o.cache_dir}/${e.app_id}-${e.version}.zip`,s=()=>{if(i)throw new nt},c=async()=>{var d;s();let l=V(e.app_id);if((l==null?void 0:l.version)===e.version&&await o.exists(l.dir))return Pn(e),V(e.app_id);s();let u=o.download({url:t?Ji(t,e.bundle_url):e.bundle_url,to_file:a,onProgress:(h,p)=>{var C;let m=p>0?p:(C=e.size)!=null?C:0;m>0&&(n==null||n(Math.min(1,h/m)))}});r=u;try{let{status:h}=await u.promise;if(s(),h!==200)throw new Error(`bundle ${h}`);if(e.sha256)if(o.sha256){if(await o.sha256(a)!==e.sha256)throw new Error("sha256 mismatch")}else ge("b\u1ECF qua ki\u1EC3m tra sha256 (file_system kh\xF4ng c\xF3 sha256)",e.app_id);s();let p=On(e.app_id,e.version,e.entry,!!e.context_update,(d=e.permissions)!=null?d:[]);return await o.remove(p.dir).catch(()=>{}),await o.mkdir(p.dir),await o.unzip(a,p.dir),Pn(e),Ar(e.app_id,[e.version,l==null?void 0:l.version].filter(Boolean)),p}catch(h){throw i?new nt:h}finally{r=null,o.remove(a).catch(()=>{})}};return{promise:Mr(e.app_id,c),cancel:()=>{i=!0,r==null||r.cancel()}}},At={},Yi=__DEV__?0:60*1e3,_r={},vr=(e,t)=>{var o,r;let n=V(e);return n&&Date.now()-((o=_r[t])!=null?o:0)<Yi?Promise.resolve(n):((r=At[e])!=null||(At[e]=(async()=>{let i=await fetch(t,{headers:{"Cache-Control":"no-cache"}});if(!i.ok)throw new Error(`manifest ${i.status}`);let a=await i.json(),s=await Ln(a,{base_url:t}).promise;return _r[t]=Date.now(),s})().catch(i=>(console.warn("[miniapp] sync failed",e,i==null?void 0:i.message),V(e))).finally(()=>{At[e]=void 0})),At[e])};var jt=new Map,xr=(e,t)=>(jt.set(e,t),()=>{jt.get(e)===t&&jt.delete(e)}),Xi=(e,t)=>{let n=jt.get(e);return n?n(t):!1};import{useCallback as Cr,useEffect as ot,useRef as Oe,useState as Gt}from"react";import{Animated as j,BackHandler as Qi,Dimensions as Zi,Easing as Jt,Pressable as es,StyleSheet as Un,Text as Mt,View as X}from"react-native";import{Fragment as us,jsx as k,jsxs as Re}from"react/jsx-runtime";var vt="#22C55E",ts="\u0110\u01B0a m\xE3 v\xE0o khung \u0111\u1EC3 qu\xE9t",ns=2,Yt=18,os=1600,xt=14,rs=2e3,Er=.38,is=40,Tr=2,ss=8,as=2e3,ls=250,rt=2e3,cs=[{top:0,left:0,borderTopWidth:4,borderLeftWidth:4,borderTopLeftRadius:xt},{top:0,right:0,borderTopWidth:4,borderRightWidth:4,borderTopRightRadius:xt},{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4,borderBottomLeftRadius:xt},{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4,borderBottomRightRadius:xt}],Pr=({color:e})=>k(us,{children:cs.map((t,n)=>k(X,{style:[M.corner,t,{borderColor:e}]},n))}),Kt=({style:e,children:t,...n})=>{let o=Oe(new j.Value(1)).current,r=i=>j.spring(o,{toValue:i,speed:40,bounciness:8,useNativeDriver:!0}).start();return k(es,{...n,onPressIn:()=>r(.88),onPressOut:()=>r(1),children:k(j.View,{style:[e,{transform:[{scale:o}]}],children:t})})},Nn=({scanner:e,closing:t=!1,onClosed:n,onHeight:o})=>{var f,_;let{vision:r,types:i,mode:a,layout:s,hint:c,glass_view:l,absolute:u}=e,d=s===_e.top,h=Oe(new j.Value(0)).current,p=r.useCameraDevice("back"),m=Oe(new j.Value(1)).current,[C,T]=Gt(!1),[P,S]=Gt(1),L=Oe(null),[W,Q]=Gt(()=>{let{width:A,height:H}=Zi.get("window");return{width:A,height:d?H*Er:H,window_y:0}}),ye=z(te,A=>A.last_value),D=z(te,A=>A.hit_tick),v=z(te,A=>A.scan_count),y=z(te,A=>A.notice),E=z(te,A=>A.is_picking),x=Oe(null),N=tt(),Se=N.top,Z=Oe(new j.Value(0)).current,I=Oe(new j.Value(0)).current,le=Oe(new j.Value(0)).current,K=Oe(n);K.current=n,ot(()=>{if(!t)return;h.setValue(W.height);let A=j.timing(h,{toValue:0,duration:ls,easing:Jt.out(Jt.cubic),useNativeDriver:!1});return A.start(({finished:H})=>{var pe;H&&((pe=K.current)==null||pe.call(K))}),()=>A.stop()},[t,h]);let ie=Math.round(W.width*(d?.8:.78)),ce=Math.round(d?W.height*.46:ie*.78),Te=Math.round((W.height-ce)/2),Pe=Math.round((W.width-ie)/2),Qe=r.useCodeScanner({codeTypes:i,onCodeScanned:Cr(A=>vn(A),[])});ot(()=>{let A=Qi.addEventListener("hardwareBackPress",()=>(Mn(),!0));return()=>A.remove()},[]);let Ee=Oe(D);ot(()=>{if(D===Ee.current)return;Z.setValue(1),le.setValue(1);let A=j.parallel([j.timing(Z,{toValue:0,duration:450,useNativeDriver:!0}),j.sequence([j.delay(rs),j.timing(le,{toValue:0,duration:250,useNativeDriver:!0})])]);return A.start(),()=>A.stop()},[D,Z,le]),ot(()=>{let A=pe=>j.timing(I,{toValue:pe,duration:os,easing:Jt.inOut(Jt.quad),useNativeDriver:!0}),H=j.loop(j.sequence([A(1),A(0)]));return H.start(),()=>H.stop()},[I]);let Fe=Cr(()=>{j.timing(m,{toValue:0,duration:220,useNativeDriver:!0}).start()},[m]);ot(()=>{let A=setTimeout(Fe,as);return()=>clearTimeout(A)},[Fe]);let[at,un]=Gt(!1);ot(()=>{let A=requestAnimationFrame(()=>{A=requestAnimationFrame(()=>un(!0))});return()=>cancelAnimationFrame(A)},[]);let $e=!!(p!=null&&p.hasTorch),lt=(f=p==null?void 0:p.neutralZoom)!=null?f:1,ct=p?Math.min(p.maxZoom/lt,ss):1,dn=lt*Math.min(P,ct),Lt=A=>{var ue;let{touches:H}=A.nativeEvent;if(H.length!==2){L.current=null;return}let pe=Math.hypot(H[0].pageX-H[1].pageX,H[0].pageY-H[1].pageY);(ue=L.current)!=null||(L.current={distance:pe,level:P}),S(Math.max(1,Math.min(ct,L.current.level*(pe/L.current.distance))))},Dt=k(Mt,{style:[M.hint,!!y&&M.hint_notice],numberOfLines:1,children:(_=y!=null?y:c)!=null?_:ts});return k(j.View,{ref:x,onTouchMove:Lt,onTouchEnd:()=>{L.current=null},pointerEvents:t?"none":"auto",style:d?[M.top,u&&M.top_absolute,t&&{height:h}]:M.full,onLayout:({nativeEvent:{layout:A}})=>{var H;t||(o==null||o(A.height),(H=x.current)==null||H.measureInWindow((pe,ue)=>{Q({width:A.width,height:A.height,window_y:ue||0})}))},children:Re(X,{style:t?[M.content_closing,{height:W.height}]:M.content,children:[p&&at&&k(r.Camera,{style:Un.absoluteFill,device:p,isActive:!E,codeScanner:Qe,torch:C&&$e?"on":"off",zoom:dn,onPreviewStarted:Fe,onError:A=>nr(A.message)}),k(j.View,{style:[M.preview_cover,{opacity:m}],pointerEvents:"none"}),W.height>0&&Re(X,{style:M.overlay,pointerEvents:"none",children:[k(X,{style:[M.dim_ring,{top:Te-rt,left:Pe-rt,width:ie+rt*2,height:ce+rt*2}]}),Re(X,{style:{position:"absolute",top:Te,left:Pe,width:ie,height:ce},children:[k(Pr,{color:"#FFFFFF"}),k(j.View,{style:[Un.absoluteFill,{opacity:Z}],children:k(Pr,{color:vt})}),Re(j.View,{style:[M.scan_line_wrap,{transform:[{translateY:I.interpolate({inputRange:[0,1],outputRange:[0,Math.max(0,ce-Yt)]})}]}],children:[k(X,{style:M.scan_glow_outer}),k(X,{style:M.scan_glow_inner}),k(X,{style:M.scan_line})]})]}),k(X,{style:[M.hint_slot,d?{top:0,height:Te-6,justifyContent:"flex-end"}:{top:Te+ce+20}],children:Dt}),a===Be.continuous&&!!ye&&k(j.View,{style:[M.result_slot,{top:d?Te+ce-is:Te+ce+52},{opacity:le}],children:Re(X,{style:M.result,children:[k(X,{style:M.check_badge,children:k(X,{style:M.check_mark})}),k(Mt,{style:M.result_text,numberOfLines:1,children:ye}),Re(Mt,{style:M.result_count,children:["\xB7 ",v," m\xE3"]})]})})]}),W.height>0&&k(X,{style:[M.close_slot,d?M.close_slot_top:{top:Math.max(12,Se-W.window_y+12)}],children:Re(Kt,{style:[M.close_button,!!l&&M.glass_surface],onPress:Mn,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"\u0110\xF3ng",children:[l&&k(l,{style:M.glass_fill,glassEffectStyle:"regular",colorScheme:"dark",tintColor:"rgba(24,24,27,0.35)",isInteractive:!0}),k(X,{style:[M.close_bar,M.close_bar_a]}),k(X,{style:[M.close_bar,M.close_bar_b]})]})}),k(X,{style:[M.toolbar_wrap,!d&&{bottom:N.bottom+20}],pointerEvents:"box-none",children:Re(X,{style:[M.toolbar,!!l&&M.glass_surface],children:[l&&k(l,{style:M.glass_fill,glassEffectStyle:"regular",colorScheme:"dark",tintColor:"rgba(24,24,27,0.35)",isInteractive:!0}),k(Kt,{style:M.tool,onPress:or,disabled:E,accessibilityRole:"button",accessibilityLabel:"Qu\xE9t t\u1EEB \u1EA3nh",children:Re(X,{style:M.image_icon,children:[k(X,{style:M.image_icon_dot}),k(X,{style:M.image_icon_hill})]})}),!!p&&ct>=Tr&&k(Kt,{style:[M.tool,P>1&&M.tool_on],onPress:()=>S(A=>A>1?1:Tr),accessibilityRole:"button",accessibilityLabel:"Ph\xF3ng to",children:Re(Mt,{style:[M.zoom_text,P>1&&M.zoom_text_on],children:[Math.round(P*10)/10,"x"]})}),$e&&k(Kt,{style:[M.tool,C&&M.tool_on],onPress:()=>T(A=>!A),accessibilityRole:"button",accessibilityLabel:"\u0110\xE8n pin",accessibilityState:{selected:C},children:k(Mt,{style:[M.torch_icon,C&&M.zoom_text_on],children:"\u26A1\uFE0E"})})]})})]})})},ps="rgba(0,0,0,0.5)",Dn=50,M=Un.create({top:{height:`${Er*100}%`,overflow:"hidden",backgroundColor:"#000000"},full:{position:"absolute",top:0,left:0,right:0,bottom:0},content:{flex:1,backgroundColor:"#000000"},top_absolute:{position:"absolute",top:0,left:0,right:0,zIndex:1},content_closing:{position:"absolute",left:0,right:0,bottom:0,backgroundColor:"#000000"},preview_cover:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"#000000"},overlay:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden"},dim_ring:{position:"absolute",borderWidth:rt,borderColor:ps,borderRadius:rt+xt},hint_slot:{position:"absolute",left:16,right:16,alignItems:"center"},hint:{color:"#FFFFFF",fontSize:14,fontWeight:"500"},hint_notice:{color:"#FCA5A5"},corner:{position:"absolute",width:28,height:28},scan_line_wrap:{position:"absolute",top:0,left:10,right:10,height:Yt,alignItems:"stretch",justifyContent:"center"},scan_glow_outer:{position:"absolute",left:0,right:0,height:Yt,borderRadius:Yt/2,backgroundColor:vt,opacity:.1},scan_glow_inner:{position:"absolute",left:4,right:4,height:8,borderRadius:4,backgroundColor:vt,opacity:.2},scan_line:{height:ns,borderRadius:1,backgroundColor:vt},glass_surface:{backgroundColor:"transparent",overflow:"visible"},glass_fill:{position:"absolute",top:0,left:0,right:0,bottom:0,borderRadius:999},close_slot:{position:"absolute",right:12},close_slot_top:{bottom:15},close_button:{width:48,height:48,borderRadius:24,overflow:"hidden",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},close_bar:{position:"absolute",width:20,height:2,borderRadius:1,backgroundColor:"#FFFFFF"},close_bar_a:{transform:[{rotate:"45deg"}]},close_bar_b:{transform:[{rotate:"-45deg"}]},toolbar_wrap:{position:"absolute",left:0,right:0,bottom:10,alignItems:"center"},toolbar:{flexDirection:"row",alignItems:"center",gap:4,padding:4,borderRadius:999,backgroundColor:"rgba(24,24,27,0.72)"},tool:{width:Dn,height:Dn,borderRadius:Dn/2,alignItems:"center",justifyContent:"center"},tool_on:{backgroundColor:"#FFFFFF"},zoom_text:{color:"#FFFFFF",fontSize:16,fontWeight:"600"},zoom_text_on:{color:"#18181B"},torch_icon:{color:"#FFFFFF",fontSize:22,fontWeight:"600"},image_icon:{width:24,height:19,borderRadius:3,borderWidth:1.5,borderColor:"#FFFFFF",overflow:"hidden"},image_icon_dot:{position:"absolute",top:3,right:3,width:4,height:4,borderRadius:2,backgroundColor:"#FFFFFF"},image_icon_hill:{position:"absolute",left:2,bottom:-6,width:12,height:12,backgroundColor:"#FFFFFF",transform:[{rotate:"45deg"}]},result_slot:{position:"absolute",left:16,right:16,alignItems:"center"},result:{maxWidth:"100%",flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:"rgba(39,39,42,0.9)"},check_badge:{width:18,height:18,borderRadius:9,alignItems:"center",justifyContent:"center",backgroundColor:vt},check_mark:{width:5,height:9,marginTop:-2,borderRightWidth:2,borderBottomWidth:2,borderColor:"#FFFFFF",transform:[{rotate:"45deg"}]},result_text:{flexShrink:1,color:"#FFFFFF",fontWeight:"600",fontSize:13},result_count:{color:"#A1A1AA",fontSize:13}});import{useEffect as kr,useRef as Ct,useState as Rr}from"react";import{AccessibilityInfo as ds,Animated as ne,Platform as gs,StyleSheet as Or,Text as hs,View as Je}from"react-native";import{Fragment as Lr,jsx as he,jsxs as Bn}from"react/jsx-runtime";var Vn={[Me.info]:"#3B82F6",[Me.success]:"#22C55E",[Me.error]:"#EF4444"},Fr=-120,Xt=gs.OS==="android",Ir=({type:e})=>e===Me.success?he(Je,{style:se.check_mark}):e===Me.error?Bn(Lr,{children:[he(Je,{style:[se.cross_bar,se.cross_a]}),he(Je,{style:[se.cross_bar,se.cross_b]})]}):Bn(Lr,{children:[he(Je,{style:se.info_dot}),he(Je,{style:se.info_bar})]}),Dr=()=>{let e=z(mt,h=>h.message),t=z(mt,h=>h.type),n=z(mt,h=>h.tick),o=Ct(new ne.Value(Fr)).current,r=Ct(new ne.Value(0)).current,i=Ct(new ne.Value(.92)).current,a=Ct(new ne.Value(0)).current,[s,c]=Rr(),[l,u]=Rr(!1);kr(()=>{let h=!0;return bt().then(p=>{h&&p&&c(()=>p)}),()=>{h=!1}},[]);let d=Ct(n);return kr(()=>{if(n===d.current)return;ds.announceForAccessibility(e),u(!0),a.setValue(0),i.setValue(.92);let h=ne.sequence([ne.parallel([ne.spring(o,{toValue:0,speed:16,bounciness:7,useNativeDriver:!0}),ne.spring(i,{toValue:1,speed:16,bounciness:9,useNativeDriver:!0}),ne.timing(r,{toValue:1,duration:140,useNativeDriver:!0}),ne.sequence([ne.delay(90),ne.spring(a,{toValue:1,speed:18,bounciness:14,useNativeDriver:!0})])]),ne.delay(Do[t]),ne.parallel([ne.timing(o,{toValue:Fr,duration:240,useNativeDriver:!0}),ne.timing(r,{toValue:0,duration:200,useNativeDriver:!0})])]);return h.start(({finished:p})=>{p&&u(!1)}),()=>h.stop()},[n]),l?he(Je,{style:[se.layer,{top:tt().top+(Xt?12:8)}],pointerEvents:"none",children:Bn(ne.View,{style:[se.toast,Xt&&se.toast_android,!!s&&se.toast_glass,{opacity:s?1:r,transform:[{translateY:o},{scale:i}]}],accessibilityLiveRegion:"polite",children:[s&&he(s,{style:se.glass_fill,glassEffectStyle:"regular",colorScheme:"dark",tintColor:"rgba(24,24,27,0.55)"}),Xt?he(ne.View,{style:[se.badge_halo,{backgroundColor:`${Vn[t]}33`,transform:[{scale:a}]}],children:he(Je,{style:[se.badge,{backgroundColor:Vn[t]}],children:he(Ir,{type:t})})}):he(ne.View,{style:[se.badge,{backgroundColor:Vn[t],transform:[{scale:a}]}],children:he(Ir,{type:t})}),he(hs,{style:[se.message,Xt&&se.message_android],numberOfLines:2,children:e})]})}):null},se=Or.create({layer:{position:"absolute",left:16,right:16,alignItems:"center",zIndex:9999,elevation:9999},toast:{maxWidth:"100%",minHeight:50,flexDirection:"row",alignItems:"center",gap:10,paddingLeft:11,paddingRight:18,paddingVertical:11,borderRadius:25,backgroundColor:"#18181B",shadowColor:"#000000",shadowOpacity:.32,shadowRadius:18,shadowOffset:{width:0,height:8},elevation:12},toast_android:{width:"100%",minHeight:60,gap:12,paddingLeft:10,paddingRight:16,paddingVertical:10,borderRadius:20,borderWidth:Or.hairlineWidth,borderColor:"rgba(255,255,255,0.16)",backgroundColor:"#232327",elevation:16},toast_glass:{backgroundColor:"transparent"},badge_halo:{width:40,height:40,borderRadius:20,alignItems:"center",justifyContent:"center"},glass_fill:{position:"absolute",top:0,left:0,right:0,bottom:0,borderRadius:25},badge:{width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},message:{flexShrink:1,color:"#FFFFFF",fontSize:15,lineHeight:20,fontWeight:"600"},message_android:{fontSize:14,fontWeight:"500",letterSpacing:.1,color:"#F4F4F5"},check_mark:{width:7,height:13,marginTop:-3,borderRightWidth:2.5,borderBottomWidth:2.5,borderColor:"#FFFFFF",transform:[{rotate:"45deg"}]},cross_bar:{position:"absolute",width:14,height:2.5,borderRadius:2,backgroundColor:"#FFFFFF"},cross_a:{transform:[{rotate:"45deg"}]},cross_b:{transform:[{rotate:"-45deg"}]},info_dot:{width:3,height:3,borderRadius:2,marginBottom:2,backgroundColor:"#FFFFFF"},info_bar:{width:2.5,height:10,borderRadius:2,backgroundColor:"#FFFFFF"}});var ae=ke({active_key:null,instances:{}}),Ur=({app:e,instance_id:t,context:n={},url_params:o={},host_data:r={}},i)=>{var s;let a=(s=R().keep_alive)==null?void 0:s.max_webviews;ae.setState(c=>{let l=t!=null?t:e.app_id,u={...c.instances,[l]:{key:l,app:e,context:n,url_params:o,host_data:r,last_used_at:Date.now()}},d=Object.keys(u);return a&&a>0&&d.length>a&&d.filter(h=>h!==l).sort((h,p)=>u[h].last_used_at-u[p].last_used_at).slice(0,d.length-a).forEach(h=>{delete u[h]}),i?{active_key:l,instances:u}:{instances:u}})},ms=e=>Ur(e,!0),fs=e=>Ur(e,!1),Tt=()=>ae.setState({active_key:null}),Qt=e=>{ae.setState(t=>{if(t.active_key===e||!t.instances[e])return{};let n={...t.instances};return delete n[e],{instances:n}})};var Nr="catalog",ys="paused_apps",bs="removed_apps",ws=10*1e3,_s=2,As=3e3,Ss=()=>{var e;try{return JSON.parse((e=R().storage.getString(Nr))!=null?e:"{}")}catch{return{}}},F=ke({catalog:{},downloads:{},pause_reasons:[],updates:{},apply_ticks:{}}),Vr=e=>{var t;return!!((t=R().manual_update)!=null&&t.includes(e))},tn=new Set,Br=e=>{let t=new Set,n=()=>R().storage.setString(e,JSON.stringify([...t]));return{has:o=>t.has(o),values:()=>[...t],add:o=>t.has(o)?!1:(t.add(o),n(),!0),delete:o=>t.delete(o)?(n(),!0):!1,load:()=>{var o;t.clear();try{let r=JSON.parse((o=R().storage.getString(e))!=null?o:"[]");Array.isArray(r)&&r.forEach(i=>{typeof i=="string"&&t.add(i)})}catch{}}}},xe=Br(ys),ze=Br(bs);Ut(()=>{xe.load(),ze.load();let e=Ss(),t={};Object.keys(e).filter(n=>!ze.has(n)).forEach(n=>{let o=V(n);o?t[n]={status:"installed",progress:1,version:o.version,has_local:!0}:xe.has(n)&&(t[n]={status:"paused",progress:0,version:e[n].version,has_local:!1})}),F.setState({catalog:e,downloads:t})});var Et=e=>z(F,t=>e?t.downloads[e]:void 0),Ms=()=>z(F,e=>e.pause_reasons.length>0),ve=(...e)=>ge("queue",...e),oe=[],De={},O=null,Zt=new Set,Ke={},qn=new Set,Ue=e=>{qn.forEach(t=>{try{t(e)}catch(n){console.warn("[miniapp-queue] event listener error",n==null?void 0:n.message)}})},Hn=e=>(qn.add(e),()=>{qn.delete(e)}),vs=()=>F.getState().downloads,me=(e,t)=>{let n=!!V(e),o=F.getState().downloads[e],r=t.status==="downloading"&&n?"updating":t.status,i={...o!=null?o:{status:"queued",progress:0},...t,...r?{status:r}:{},has_local:n};F.setState(a=>({downloads:{...a.downloads,[e]:i}})),(o==null?void 0:o.status)!==i.status||(o==null?void 0:o.version)!==i.version||(o==null?void 0:o.has_local)!==i.has_local?Ue({type:"status_change",app_id:e,state:i}):o.progress!==i.progress&&Ue({type:"progress",app_id:e,progress:i.progress,version:i.version})},en=(e,t)=>{var n;(n=Ke[e])==null||n.forEach(o=>o(t)),delete Ke[e]},xs=()=>F.getState().pause_reasons.length>0,He=e=>{var s;if(O)return;let t=e?oe.indexOf(e):xs()?-1:oe.findIndex(c=>!xe.has(c));if(t<0||t>=oe.length)return;let[n]=oe.splice(t,1),o=F.getState().catalog[n];if(!o){en(n,V(n)),He();return}let r=Date.now();De[n]=((s=De[n])!=null?s:0)+1,me(n,{status:"downloading",progress:0,version:o.version,error:void 0});let i=0,a=Ln(o,{onProgress:c=>{let l=Math.floor(c*100);l!==i&&(i=l,me(n,{progress:l/100,version:o.version}))}});O={app_id:n,handle:a,forced:!!e},ve("start",n,o.version,e?"(forced)":""),a.promise.then(c=>{ve("installed",n,o.version,`${Date.now()-r}ms`),me(n,{status:"installed",progress:1,version:o.version}),en(n,c)}).catch(c=>{var u;if(c instanceof nt){if(Zt.has(n))return;ve("paused",n),De[n]-=1,oe.unshift(n),me(n,{status:xe.has(n)?"paused":"queued",progress:0,version:o.version});return}let l=String((u=c==null?void 0:c.message)!=null?u:c);if(console.warn("[miniapp-queue] failed",n,l),De[n]<_s){me(n,{status:"queued",progress:0,version:o.version,error:l}),setTimeout(()=>{var d;oe.includes(n)||(O==null?void 0:O.app_id)===n||(oe.push(n),He((d=Ke[n])!=null&&d.length?n:void 0))},As);return}me(n,{status:"failed",progress:0,version:o.version,error:l}),en(n,V(n))}).finally(()=>{O=null;let c=oe.find(l=>{var u;return(u=Ke[l])==null?void 0:u.length});He(c)})},nn=(e,{front:t=!1}={})=>{if((O==null?void 0:O.app_id)===e)return;let n=oe.indexOf(e);if(n>=0){if(!t)return;oe.splice(n,1)}t?oe.unshift(e):oe.push(e)},Cs=async e=>{let{host_id:t,client_token:n}=R(),o=new AbortController,r=setTimeout(()=>o.abort(),ws);try{let i=`${pt}/api/hosts/${encodeURIComponent(t)}/miniapps?channel=${e}`,a=await fetch(i,{headers:{Authorization:`Bearer ${n}`,"Cache-Control":"no-cache"},signal:o.signal});if(!a.ok)throw new Error(`host list ${e} ${a.status}`);return(await a.json()).apps.map(c=>({...c,channel:e}))}finally{clearTimeout(r)}},Pt=null,zn=()=>(Pt!=null||(Pt=(async()=>{var t;let e=Date.now();try{let n=await Promise.all(R().channels.map(Cs)),o={};[...n].reverse().flat().forEach(c=>{o[c.app_id]=c});let r=Object.keys(F.getState().catalog).filter(c=>!o[c]);R().storage.setString(Nr,JSON.stringify(o)),F.setState({catalog:o}),await Promise.all(r.map(c=>qr(c,{by_user:!1}))),r.forEach(c=>ze.delete(c));let i=Object.keys(o).filter(c=>!ze.has(c)),a=[],s={};for(let c of i.map(l=>o[l])){if(await Fn(c)){me(c.app_id,{status:"installed",progress:1,version:c.version});continue}let l=V(c.app_id);if(Vr(c.app_id)&&!tn.has(c.app_id)&&l&&await Le(l)){me(c.app_id,{status:"installed",progress:1,version:l.version}),s[c.app_id]={app_id:c.app_id,current_version:l.version,next_version:c.version};continue}a.push(c)}return F.setState({updates:s}),a.forEach(c=>{De[c.app_id]=0,me(c.app_id,{status:xe.has(c.app_id)?"paused":"queued",progress:0,version:c.version,error:void 0}),nn(c.app_id)}),ve("catalog",i.length,"apps, outdated",a.map(c=>c.app_id),"removed",r,`${Date.now()-e}ms`),Ue({type:"sync_complete",app_ids:i,removed:r}),Object.values(s).forEach(c=>Ue({type:"update_available",...c})),He(),{ok:!0,app_ids:i,removed:r}}catch(n){let o=String((n==null?void 0:n.name)==="AbortError"?"timeout":(t=n==null?void 0:n.message)!=null?t:n);return console.warn("[miniapp-queue] sync catalog failed",o),Ue({type:"sync_failed",error:o}),{ok:!1,error:o}}finally{Pt=null}})()),Pt),qr=async(e,{by_user:t})=>{var r,i,a,s;if(t&&ze.add(e),Zt.has(e))return;Zt.add(e),xe.delete(e);let n=oe.indexOf(e);n>=0&&oe.splice(n,1),(O==null?void 0:O.app_id)===e&&O.handle.cancel();let o=(s=(a=(r=F.getState().downloads[e])==null?void 0:r.version)!=null?a:(i=V(e))==null?void 0:i.version)!=null?s:"";me(e,{status:"uninstalling",progress:0,version:o}),await Sr(e),Qt(e),F.setState(c=>{let l={...c.downloads};return delete l[e],{downloads:l}}),delete De[e],Zt.delete(e),en(e,null),ve("uninstalled",e,t?"(user)":"(not in list)"),Ue({type:"uninstalled",app_id:e})},Ts=e=>qr(e,{by_user:!0}),Ps=e=>{let t=kt(e);return t?(ze.delete(e),(O==null?void 0:O.app_id)===e||oe.includes(e)||(De[e]=0,me(e,{status:xe.has(e)?"paused":"queued",progress:0,version:t.version,error:void 0}),nn(e),He(),ve("restore",e)),!0):!1},Es=e=>{if(xe.has(e))return;if(xe.add(e),ve("pause app",e),(O==null?void 0:O.app_id)===e&&!O.forced){O.handle.cancel();return}let t=F.getState().downloads[e];oe.includes(e)&&t&&me(e,{status:"paused",progress:0,version:t.version})},ks=e=>{if(!xe.delete(e))return;ve("resume app",e);let t=F.getState().downloads[e];(t==null?void 0:t.status)==="paused"&&!oe.includes(e)&&kt(e)&&(De[e]=0,nn(e)),oe.includes(e)&&t&&me(e,{status:"queued",progress:0,version:t.version}),He()},Rs=e=>{let{pause_reasons:t}=F.getState();t.includes(e)||(F.setState({pause_reasons:[...t,e]}),ve("pause",e),t.length===0&&Ue({type:"pause_change",paused:!0,reasons:[e]}),O&&!O.forced&&O.handle.cancel())},Os=e=>{let{pause_reasons:t}=F.getState();if(!t.includes(e))return;let n=t.filter(o=>o!==e);F.setState({pause_reasons:n}),ve("resume",e),n.length===0&&Ue({type:"pause_change",paused:!1,reasons:n}),He()},Hr=e=>F.getState().updates[e],$n=async e=>{var n,o;let t=Hr(e);tn.add(e);try{let r=await on(e),i=(o=t==null?void 0:t.next_version)!=null?o:(n=kt(e))==null?void 0:n.version;return!r||!i||r.version!==i?!1:(F.setState(a=>{var c;let s={...a.updates};return delete s[e],{updates:s,apply_ticks:{...a.apply_ticks,[e]:((c=a.apply_ticks[e])!=null?c:0)+1}}}),ve("updated",e,t==null?void 0:t.current_version,"\u2192",r.version),Ue({type:"update_applied",app_id:e,version:r.version}),!0)}finally{tn.delete(e)}},Fs=()=>Object.values(F.getState().catalog).map(e=>({...e,installed:!!V(e.app_id),removed_by_user:ze.has(e.app_id)})),kt=e=>F.getState().catalog[e],on=async e=>{let t=kt(e);if(!t)return;if(xe.delete(e),ze.delete(e),await Fn(t))return V(e);let n=V(e);if(Vr(e)&&!tn.has(e)&&n&&await Le(n))return n;let o=new Promise(r=>{var i;((i=Ke[e])!=null?i:Ke[e]=[]).push(r)});return(O==null?void 0:O.app_id)===e?O.forced=!0:(De[e]=0,nn(e,{front:!0}),O&&!O.forced?O.handle.cancel():He(e)),o};import{Fragment as Kn,jsx as re,jsxs as it}from"react/jsx-runtime";var jn=e=>(e!=null?e:"").replace(/\?[^#]*/,""),$r=0,Bs=()=>{let e=new Set;return{emit:t=>e.forEach(n=>n(t)),subscribe:t=>(e.add(t),()=>{e.delete(t)})}},qs=Yn.memo(({instance_key:e,is_active:t,is_front:n,is_dark:o,reload_tick:r,web_at_top:i,splash:a,bridge:s,opaque_background:c,allow_embedded_miniapps:l,onWebLoadEnd:u})=>{var Lt,Dt;let d=Ce(null),h=Ce(!1),p=z(ae,f=>f.instances[e]),m=p==null?void 0:p.app.app_id,C=p==null?void 0:p.app.manifest_url,T=p==null?void 0:p.context,P=p==null?void 0:p.url_params,S=z(te,f=>{var _;return((_=f.active)==null?void 0:_.owner)===e?f.active:null}),[L,W]=Ne(null),[Q,ye]=Ne(S);S!==Q&&(ye(S),S?W(null):(Q==null?void 0:Q.layout)===_e.top&&W(Q));let D=(S==null?void 0:S.layout)===_e.top?S:L,[v,y]=Ne(()=>m?V(m):null),[E,x]=Ne(!1),[N,Se]=Ne(0),[Z,I]=Ne(0),[le,K]=Ne(!1),ie=Ce(null),ce=f=>{ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{ie.current=null,K(!0)},f)};fe(()=>()=>{ie.current&&clearTimeout(ie.current)},[]),fe(()=>{if(!m||!t&&v)return;let f=!0;return x(!1),(async()=>{let _=V(m),A=_?await Le(_):!1;if(!f||(y(A?ue=>!ue||ue.version!==_.version||ue.permissions.join(",")!==_.permissions.join(",")?_:ue:null),__DEV__&&Date.now()-$r>1e4&&($r=Date.now(),await zn()),!f))return;let H=await on(m),pe=H!==void 0?H:C?await vr(m,C):V(m);if(f){if(!pe){x(!0);return}y(ue=>ue!=null?ue:pe)}})(),()=>{f=!1}},[t,m,C,N]),fe(()=>xr(e,f=>d.current?(d.current.postMessage(f),!0):!1),[e]);let Te=z(F,f=>{let _=m?f.downloads[m]:void 0;return(_==null?void 0:_.status)==="installed"?_.version:void 0});fe(()=>{if(t||!m||!v)return;let f=V(m);if(!f||f.version===v.version)return;let _=!0;return Le(f).then(A=>{!_||!A||(ge(`webview:${e}`,"\u0111\u1ED5i bundle (\u1EA9n)",v.version,"\u2192",f.version),y(f))}),()=>{_=!1}},[t,m,Te,v==null?void 0:v.version]);let Pe=z(F,f=>{var _;return m&&(_=f.apply_ticks[m])!=null?_:0});fe(()=>{if(!Pe||!m)return;let f=V(m);if(!f||f.version===(v==null?void 0:v.version))return;let _=!0;return Le(f).then(A=>{!_||!A||(ge(`webview:${e}`,"c\u1EADp nh\u1EADt",v==null?void 0:v.version,"\u2192",f.version),K(!1),y(f))}),()=>{_=!1}},[Pe]),fe(()=>{var A;let f=(A=R().keep_alive)==null?void 0:A.idle_close_ms;if(t||!f||f<=0)return;let _=setTimeout(()=>{Qt(e)},f);return()=>clearTimeout(_)},[t,e]),fe(()=>{r>0&&(x(!1),K(!1),I(f=>f+1),Se(f=>f+1))},[r]);let Qe=Ce(t);fe(()=>{var f;Qe.current!==t&&(Qe.current=t,h.current&&((f=d.current)==null||f.injectJavaScript(dr(t?"resumed":"paused"))))},[t]);let Ee=`${(Lt=v==null?void 0:v.version)!=null?Lt:"none"}:${(Dt=v==null?void 0:v.permissions.join(","))!=null?Dt:""}:${Z}`,Fe=rn(()=>JSON.stringify([T!=null?T:{},P!=null?P:{}]),[T,P]),at=rn(()=>{var f;return yr(P!=null?P:{},(f=v==null?void 0:v.permissions)!=null?f:[])},[Fe,v==null?void 0:v.permissions]),un=rn(()=>mr(T!=null?T:{},at)+pr()+ur()+(R().debug?cr():""),[at]),$e=Ce(null),lt=Ce(null);fe(()=>{var _,A,H;if(!v)return;if(lt.current!==Ee){lt.current=Ee,$e.current=Fe;return}if($e.current===Fe)return;let f=((A=JSON.parse((_=$e.current)!=null?_:"[]")[0])!=null?A:{}).org_id;if($e.current=Fe,f===(T==null?void 0:T.org_id)&&h.current){K(!1),ce(1500),(H=d.current)==null||H.injectJavaScript(gr(T!=null?T:{},at));return}K(!1),I(pe=>pe+1)},[Fe,v,Ee]),fe(()=>(t||(Ie(e),qe(e),Ge(e)),()=>{Ie(e),qe(e),Ge(e)}),[t,e,Ee,r]),fe(()=>{let f=zr.addEventListener("change",_=>{_==="background"&&!$o()&&Ie(e),_==="background"&&!Yo()&&qe(e)});return()=>f.remove()},[e]);let ct=Gn(async f=>{var A,H,pe,ue,gn,po;let _=ir(f.nativeEvent.data);if(!_){if(m&&(s!=null&&s.onWebEvent))try{Promise.resolve(s.onWebEvent(f.nativeEvent.data,{app_id:m,instance_id:e})).catch(G=>{console.warn("[miniapp] onWebEvent l\u1ED7i",m,G)})}catch(G){console.warn("[miniapp] onWebEvent l\u1ED7i",m,G)}return}if(_.method==="log"){let{level:G,text:Y}=_;ge(`web:${e}`,G!=null?G:"log",Y!=null?Y:"");return}if(_.method==="pong"){ie.current||K(!0);return}if(_.method==="touchAtTop"){i.emit(!!_.at_top);return}if(_.method==="contextApplied"){ie.current&&clearTimeout(ie.current),ie.current=null,K(!0);return}if(_.method==="ready"){h.current=!0,K(!0);let G=(A=ae.getState().instances[e])==null?void 0:A.context;G&&((H=d.current)==null||H.injectJavaScript(Cn(G)));return}try{let G=await wr(_,{getHostData:()=>{var Y,be;return(be=(Y=ae.getState().instances[e])==null?void 0:Y.host_data)!=null?be:{}},getPermissions:()=>{var Y,be;return m?(be=(Y=V(m))==null?void 0:Y.permissions)!=null?be:[]:[]},getContext:()=>{var Y,be;return(be=(Y=ae.getState().instances[e])==null?void 0:Y.context)!=null?be:{}},is_dark:o,close:Tt,app_id:m!=null?m:"",instance_id:e,options:s,emit:(Y,be)=>{var uo;(uo=d.current)==null||uo.injectJavaScript(lr(Y,be))},playBeep:(pe=s==null?void 0:s.playScannerBeep)!=null?pe:(()=>{var Y;(Y=d.current)==null||Y.injectJavaScript(br())}),isActive:()=>ae.getState().active_key===e&&zr.currentState!=="background"});_.id&&((ue=d.current)==null||ue.injectJavaScript(sr(_.id,G)))}catch(G){if(!_.id)return;let Y=G==null?void 0:G.code,be=G instanceof g?G:new g(typeof Y=="string"?Y:"HOST_ERROR",String((gn=G==null?void 0:G.message)!=null?gn:G));(po=d.current)==null||po.injectJavaScript(ar(_.id,be))}},[e,o,m,i,s]),dn=Gn(()=>{x(!1),I(f=>f+1),Se(f=>f+1)},[]);return it(Jn,{style:[Xn.absoluteFill,c&&{backgroundColor:o?"#09090B":"#FFFFFF"},!n&&Ae.behind],pointerEvents:t?"auto":"none",children:[D&&re(Nn,{scanner:D,closing:D===L,onClosed:()=>{var f;W(null),D.absolute&&((f=d.current)==null||f.injectJavaScript(Tn(0)))},onHeight:D.absolute?f=>{var _;return(_=d.current)==null?void 0:_.injectJavaScript(Tn(f))}:void 0}),v?re(Vs,{ref:d,source:{uri:v.entry_uri},originWhitelist:["*"],hideKeyboardAccessoryView:!0,mediaPlaybackRequiresUserAction:!1,allowingReadAccessToURL:`file://${l?kn():v.dir}`,allowFileAccess:!0,allowFileAccessFromFileURLs:!0,allowUniversalAccessFromFileURLs:!0,injectedJavaScriptBeforeContentLoaded:un,onMessage:ct,onShouldStartLoadWithRequest:f=>{let _=f.url;return f.isTopFrame===!1||!/^https?:\/\//i.test(_)?!0:(Promise.resolve(s!=null&&s.openUrl?s.openUrl(_):Us.openURL(_)).catch(()=>{}),!1)},setSupportMultipleWindows:!1,bounces:!1,overScrollMode:"never",onLoadStart:f=>{Ie(e),qe(e),Ge(e),ge(`webview:${e}`,"load start",jn(f.nativeEvent.url)),h.current=!1,K(!1)},onError:f=>{Ie(e),qe(e),Ge(e),ge(`webview:${e}`,"load error",jn(f.nativeEvent.url),f.nativeEvent.description),x(!0),K(!1)},onLoadEnd:f=>{let _=f.nativeEvent.url;ge(`webview:${e}`,"load end",jn(_)),m&&(u==null||u({app_id:m,instance_id:e,url:_})),ce(1500)},onContentProcessDidTerminate:()=>{Ie(e),qe(e),Ge(e),h.current=!1,K(!1),I(f=>f+1)},onRenderProcessGone:()=>(Ie(e),qe(e),Ge(e),h.current=!1,K(!1),I(f=>f+1),!0),style:Ae.webview},Ee):null,(S==null?void 0:S.layout)===_e.full&&re(Nn,{scanner:S}),p&&re(zs,{visible:!v||!le,interactive:E,children:re(Hs,{splash:a,app:p.app,is_dark:o,error:E,has_bundle:!!v,retry:dn})})]})}),Hs=Yn.memo(({splash:e,app:t,is_dark:n,error:o,has_bundle:r,retry:i})=>{let a=e,s=Et(t.app_id),c=o?"error":!r&&(s==null?void 0:s.status)==="downloading"?"downloading":"loading";return re(a,{app:t,is_dark:n,status:c,progress:c==="downloading"?s==null?void 0:s.progress:void 0,retry:i})}),zs=({visible:e,interactive:t,children:n})=>{let o=Ce(new Wn.Value(e?1:0)).current,[r,i]=Ne(e);return fe(()=>{if(e){i(!0),o.setValue(1);return}let a=Wn.timing(o,{toValue:0,duration:180,useNativeDriver:!0});return a.start(({finished:s})=>{s&&i(!1)}),()=>a.stop()},[e,o]),r?re(Wn.View,{style:[Xn.absoluteFill,{opacity:o}],pointerEvents:t?"auto":"none",children:n}):null},jr=({app:e,is_dark:t,status:n,progress:o,retry:r})=>{let i=t?"#FAFAFA":"#18181B";return it(Jn,{style:[Ae.splash,{backgroundColor:t?"#09090B":"#FFFFFF"}],children:[re(Jn,{style:[Ae.splash_icon,{backgroundColor:t?"#18181B":"#F4F4F5"}],children:e.icon?re(Ds,{source:{uri:e.icon},style:Ae.splash_icon_image}):re(Rt,{style:Ae.splash_letter,children:(e.name||"?").slice(0,1).toUpperCase()})}),re(Rt,{style:[Ae.splash_name,{color:i}],children:e.name}),n==="error"?it(Kn,{children:[re(Rt,{style:Ae.splash_hint,children:"Kh\xF4ng t\u1EA3i \u0111\u01B0\u1EE3c mini app"}),re(Ns,{activeOpacity:.7,style:[Ae.retry_button,{backgroundColor:t?"#27272A":"#F4F4F5"}],onPress:r,children:re(Rt,{style:[Ae.retry_text,{color:i}],children:"Th\u1EED l\u1EA1i"})})]}):it(Kn,{children:[re(Is,{style:Ae.splash_spinner,color:t?"#A1A1AA":"#71717A"}),n==="downloading"&&it(Rt,{style:Ae.splash_hint,children:["\u0110ang t\u1EA3i mini app",o?` ${Math.round(o*100)}%`:"\u2026"]})]})]})},Wr=(e,t)=>{let n=Ce(t),o=Ce(!1);__DEV__&&!o.current&&n.current!==t&&(o.current=!0,console.warn(`[miniapp] MiniAppHost prop "${e}" \u0111\u1ED5i gi\u1EEFa c\xE1c l\u1EA7n render \u2192 m\u1ECDi WebView b\u1ECB mount l\u1EA1i. Khai b\xE1o component b\xEAn ngo\xE0i render.`))},$s=({container:e,splash:t=jr,is_dark:n=!1,bridge:o,close_on_back:r=!0,opaque_background:i=!0,allow_embedded_miniapps:a=!1,onWebLoadEnd:s})=>{Wr("container",e),Wr("splash",t);let c=e,l=z(ae,S=>S.active_key),u=Ce(l);l&&(u.current=l);let d=z(ae,S=>Object.keys(S.instances).join("|")),h=z(ae,S=>{var L;return S.active_key?(L=S.instances[S.active_key])==null?void 0:L.app.name:void 0}),p=rn(()=>d?d.split("|"):[],[d]),[m,C]=Ne({}),T=Ce(Bs()).current;fe(()=>{if(!l||!r)return;let S=Ls.addEventListener("hardwareBackPress",()=>(Tt(),!0));return()=>S.remove()},[l,r]);let P=Gn(()=>{let S=ae.getState().active_key;S&&C(L=>({...L,[S]:(L[S]||0)+1}))},[]);return p.length?it(Kn,{children:[re(c,{visible:!!l,title:h!=null?h:"",is_dark:n,close:Tt,reload:P,subscribeWebAtTop:T.subscribe,children:p.map(S=>re(qs,{instance_key:S,is_active:l===S,is_front:(l!=null?l:u.current)===S,is_dark:n,reload_tick:m[S]||0,web_at_top:T,splash:t,bridge:o,opaque_background:i,allow_embedded_miniapps:a,onWebLoadEnd:s},S))}),re(Dr,{})]}):null},Ae=Xn.create({webview:{flex:1,backgroundColor:"transparent"},behind:{zIndex:-1},splash:{flex:1,alignItems:"center",justifyContent:"center",gap:12},splash_icon:{width:72,height:72,borderRadius:20,alignItems:"center",justifyContent:"center",overflow:"hidden"},splash_icon_image:{width:72,height:72},splash_letter:{fontSize:28,fontWeight:"700",color:"#1D4ED8"},splash_name:{fontSize:16,fontWeight:"600"},splash_hint:{color:"#71717A"},splash_spinner:{marginTop:8},retry_button:{marginTop:4,paddingHorizontal:20,paddingVertical:10,borderRadius:999},retry_text:{fontWeight:"600"}}),Ws=Yn.memo($s);import{useCallback as js,useEffect as Gs,useState as sn}from"react";var Jr=e=>`changelog_seen:${e}`,Js=10*1e3,eo=e=>R().storage.getString(Jr(e))||null,Ft=(e,t=(n=>(n=V(e))==null?void 0:n.version)())=>{t&&R().storage.setString(Jr(e),t)},Kr=e=>{var o;let t=(o=V(e))==null?void 0:o.version;if(!t)return null;let n=eo(e);return n?In(t,n)>0?{app_id:e,from:n,to:t}:null:(Ft(e,t),null)},Ks=e=>{var t,n,o;return(o=(n=(t=F.getState().catalog[e])==null?void 0:t.channel)!=null?n:R().channels[0])!=null?o:"production"},to=async(e,{from:t,to:n,channel:o=Ks(e)}={})=>{let{client_token:r}=R(),i=new URLSearchParams({channel:o});t&&i.set("from",t),n&&i.set("to",n);let a=new AbortController,s=setTimeout(()=>a.abort(),Js);try{let c=await fetch(`${pt}/api/miniapps/${encodeURIComponent(e)}/changelog?${i}`,{headers:{Authorization:`Bearer ${r}`},signal:a.signal});if(!c.ok)throw new Error(`changelog ${e} ${c.status}`);return(await c.json()).versions}finally{clearTimeout(s)}},no=(e,{from:t,to:n,enabled:o=!0}={})=>{let[r,i]=sn([]),[a,s]=sn(!1),[c,l]=sn(),[u,d]=sn(0),h=js(()=>d(p=>p+1),[]);return Gs(()=>{if(!e||!o)return;let p=!0;return s(!0),l(void 0),to(e,{from:t,to:n}).then(m=>{p&&i(m)}).catch(m=>{var C;p&&l(String((m==null?void 0:m.name)==="AbortError"?"timeout":(C=m==null?void 0:m.message)!=null?C:m))}).finally(()=>{p&&s(!1)}),()=>{p=!1}},[e,t,n,o,u]),{versions:r,loading:a,error:c,reload:h}},Ot=ke({request:null}),Qn=!1,Ys=e=>{var t,n;return(n=(t=F.getState().catalog[e])==null?void 0:t.name)!=null?n:e},Zn=async(e,{name:t}={})=>{if(Ot.getState().request||Qn)return!1;let n=Kr(e);if(!n)return!1;Qn=!0;try{let o=await to(e,{from:n.from,to:n.to});return o.length?(Ot.setState({request:{...n,name:t!=null?t:Ys(e),versions:o}}),!0):(Ft(e,n.to),!1)}catch(o){return ge("changelog failed",e,o),!1}finally{Qn=!1}},oo=()=>{let{request:e}=Ot.getState();e&&Ft(e.app_id,e.to),Ot.setState({request:null})},ro=()=>z(Ot,e=>e.request),Gr=!1;Ut(()=>{if(Gr)return;Gr=!0;let e=()=>R().changelog!==!1;Hn(n=>{n.type==="status_change"&&n.state.status==="installed"&&!eo(n.app_id)&&Ft(n.app_id,n.state.version),n.type==="update_applied"&&e()&&Zn(n.app_id)});let t=ae.getState().active_key;ae.subscribe(()=>{let{active_key:n,instances:o}=ae.getState();if(n===t)return;t=n;let r=n?o[n]:void 0;r&&e()&&Zn(r.app.app_id,{name:r.app.name})})});import Zs,{createContext as ea,useContext as ta,useEffect as ao,useMemo as na,useRef as io,useState as Ye}from"react";import{ActivityIndicator as oa,Animated as st,Image as ra,Linking as ia,Modal as Xr,Platform as cn,Pressable as Qr,ScrollView as Zr,StyleSheet as It,Text as q,TouchableOpacity as pn,View as U}from"react-native";var Xs=/\*\*(.+?)\*\*|`([^`]+)`|\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,an=e=>{var o;let t=[],n=0;for(let r of e.matchAll(Xs)){let i=(o=r.index)!=null?o:0;i>n&&t.push({type:"text",text:e.slice(n,i)}),r[1]!==void 0?t.push({type:"bold",text:r[1]}):r[2]!==void 0?t.push({type:"code",text:r[2]}):t.push({type:"link",text:r[3],url:r[4]}),n=i+r[0].length}return n<e.length&&t.push({type:"text",text:e.slice(n)}),t},Qs=e=>an(e).map(t=>t.text).join("");import{Fragment as _a,jsx as w,jsxs as J}from"react/jsx-runtime";var ei={changelog_title:"C\xF3 g\xEC m\u1EDBi",changelog_ok:"\u0110\xE3 hi\u1EC3u",changelog_view_all:"Xem t\u1EA5t c\u1EA3 c\u1EADp nh\u1EADt",changelog_more:"+{count} thay \u0111\u1ED5i kh\xE1c",history_title:"L\u1ECBch s\u1EED c\u1EADp nh\u1EADt",history_empty:"Ch\u01B0a c\xF3 ghi ch\xFA c\u1EADp nh\u1EADt.",history_error:"Kh\xF4ng t\u1EA3i \u0111\u01B0\u1EE3c l\u1ECBch s\u1EED c\u1EADp nh\u1EADt.",retry:"Th\u1EED l\u1EA1i",update_title:"\u0110\xE3 c\xF3 b\u1EA3n c\u1EADp nh\u1EADt",updating_title:"\u0110ang c\u1EADp nh\u1EADt\u2026",update_message:`Phi\xEAn b\u1EA3n {next} \u0111\xE3 s\u1EB5n s\xE0ng (hi\u1EC7n t\u1EA1i {current}).
|
|
89
|
-
Vui l\xF2ng c\u1EADp nh\u1EADt \u0111\u1EC3 ti\u1EBFp t\u1EE5c s\u1EED d\u1EE5ng.`,update_failed:"C\u1EADp nh\u1EADt kh\xF4ng th\xE0nh c\xF4ng. Ki\u1EC3m tra k\u1EBFt n\u1ED1i m\u1EA1ng r\u1ED3i th\u1EED l\u1EA1i.",update_now:"C\u1EADp nh\u1EADt ngay",updating_hint:"Vui l\xF2ng kh\xF4ng t\u1EAFt \u1EE9ng d\u1EE5ng"},ti=(e,t)=>e.replace(/\{(\w+)\}/g,(n,o)=>o in t?String(t[o]):n),B={blue:"#007AFF",track:"#E5E5EA",overlay:"rgba(0, 0, 0, 0.6)",shadow:"#000000",title:"#1A1A1A",sub_title:"#666666",error:"#D92D20",hint:"#C0C0C0",surface:"#FFFFFF",background:"#F2F2F7"},sa={primary:"#007AFF",on_primary:"#FFFFFF",background:"#F2F2F7",surface:"#FFFFFF",text:"#1C1C1E",text_secondary:"#666666",hint:"#AEAEB2",overlay:"rgba(0, 0, 0, 0.6)",divider:"rgba(60, 60, 67, 0.18)",radius:28,button_radius:12,button_height:50},aa={primary:"#0A84FF",on_primary:"#FFFFFF",background:"#000000",surface:"#1C1C1E",text:"#FFFFFF",text_secondary:"#A1A1AA",hint:"#636366",overlay:"rgba(0, 0, 0, 0.7)",divider:"rgba(84, 84, 88, 0.6)",radius:28,button_radius:12,button_height:50},la={new:{color:"#64B5FF",bg:"rgba(10, 132, 255, 0.18)"},fix:{color:"#FF9F7A",bg:"rgba(255, 112, 67, 0.18)"},improve:{color:"#5FD39A",bg:"rgba(48, 209, 88, 0.18)"}},lo=(e={},t)=>{let n=!!e.dark,{kinds:o,...r}=e;return{...n?aa:sa,...Object.fromEntries(Object.entries(r).filter(([,a])=>a!==void 0)),dark:n,labels:{...ei,...t},kinds:oi.map(a=>({...a,...n?la[a.key]:null,...a.key==="new"&&e.primary?{color:e.primary}:null,...o==null?void 0:o[a.key]}))}},ni=ea(void 0),so=({theme:e,labels:t,children:n})=>{let o=na(()=>lo(e,t),[e,t]);return w(ni.Provider,{value:o,children:n})},ca=lo(),Xe=()=>{var e;return(e=ta(ni))!=null?e:ca},oi=[{key:"new",label:"M\u1EDBi",color:"#007AFF",bg:"#E5F1FF"},{key:"fix",label:"S\u1EEDa l\u1ED7i",color:"#C4320A",bg:"#FFF1EB"},{key:"improve",label:"C\u1EA3i thi\u1EC7n",color:"#067647",bg:"#E7F7EE"}],ri=e=>({new:e.flatMap(t=>t.changelog.new),fix:e.flatMap(t=>t.changelog.fix),improve:e.flatMap(t=>t.changelog.improve)}),pa=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("vi-VN")},ii=({text:e,style:t})=>{let n=Xe();return w(q,{style:t,children:an(e.replace(/^(?:[-*•]\s+)+/,"")).map((o,r)=>{switch(o.type){case"bold":return w(q,{style:b.md_bold,children:o.text},r);case"code":return w(q,{style:[b.md_code,{backgroundColor:n.background,color:n.text}],children:o.text},r);case"link":return w(q,{style:[b.md_link,{color:n.primary}],accessibilityRole:"link",onPress:()=>{ia.openURL(o.url).catch(()=>{})},children:o.text},r);default:return o.text}})})},co=({changelog:e,max_items:t,onMore:n})=>{let o=Xe();return w(U,{style:b.groups,children:o.kinds.filter(r=>e[r.key].length).map(r=>{let i=e[r.key],a=t?i.slice(0,t):i,s=i.length-a.length;return J(U,{style:b.group,children:[J(U,{style:b.group_head,children:[w(U,{style:[b.badge,{backgroundColor:r.bg}],children:w(q,{style:[b.badge_text,{color:r.color}],children:r.label})}),w(q,{style:[b.group_count,{color:o.hint}],children:i.length})]}),a.map((c,l)=>J(U,{style:b.item,children:[w(U,{style:[b.dot,{backgroundColor:r.color}]}),w(ii,{text:c,style:[b.item_text,{color:o.text}]})]},l)),s>0&&w(q,{style:[b.more,{color:o.primary}],onPress:n,suppressHighlighting:!0,children:ti(o.labels.changelog_more,{count:s})})]},r.key)})})},ln,ua=()=>(ln!=null||(ln=Promise.all([cn.OS==="ios"?import("expo-image").then(e=>e.Image).catch(()=>{}):Promise.resolve(void 0),import("expo-linear-gradient").then(e=>e.LinearGradient).catch(()=>{})]).then(([e,t])=>({ExpoImage:e,LinearGradient:t}))),ln),da=()=>{let[e,t]=Ye({});return ao(()=>{let n=!0;return ua().then(o=>{n&&t(o)}),()=>{n=!1}},[]),e},si="#1C1C1E",ga=e=>/^#[0-9a-f]{6}$/i.test(e),ha=()=>{let[e,t]=Ye();return ao(()=>{let n=!0;return bt().then(o=>{n&&o&&t(()=>o)}),()=>{n=!1}},[]),e},ma=({onPress:e,size:t,GlassView:n,ExpoImage:o})=>{let r=Xe(),i=r.dark?"#FFFFFF":si;return J(Qr,{onPress:e,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Quay l\u1EA1i",style:({pressed:a})=>[b.back_btn,{width:t,height:t,borderRadius:t/2},!n&&b.back_btn_fallback,!n&&r.dark&&{backgroundColor:"#3F3F46",shadowOpacity:0},!n&&a&&b.pressed],children:[n&&w(n,{style:[It.absoluteFill,{borderRadius:t/2}],glassEffectStyle:"regular",colorScheme:r.dark?"dark":"light",isInteractive:!0}),w(U,{pointerEvents:"none",style:b.icon_layer,children:o?w(o,{source:"sf:chevron.left",transition:0,contentFit:"contain",style:{width:20,height:20,fontSize:20,color:i}}):w(U,{style:[b.chevron,{borderColor:i}]})})]})},ai=({app_id:e,name:t,onBack:n,renderHeader:o})=>{let r=Xe(),i=tt(),a=ha(),{ExpoImage:s,LinearGradient:c}=da(),l=a?46:42,u=o?0:i.top+l+10,{versions:d,loading:h,error:p,reload:m}=no(e);return J(U,{style:[b.history,{backgroundColor:r.background}],children:[o&&w(U,{style:{paddingTop:i.top},children:o({title:r.labels.history_title,subtitle:t,onBack:n})}),h&&!d.length?w(oa,{style:[b.loading,{marginTop:u+40}],color:r.primary}):p&&!d.length?J(U,{style:[b.center,{marginTop:u+40}],children:[w(q,{style:[b.sub_title,{color:r.text_secondary}],children:r.labels.history_error}),w(pn,{onPress:m,children:w(q,{style:[b.link,{color:r.primary}],children:r.labels.retry})})]}):J(Zr,{contentContainerStyle:[b.history_list,{paddingTop:u+8,paddingBottom:i.bottom+24}],scrollIndicatorInsets:{top:u},children:[d.map(C=>J(U,{style:[b.card,{backgroundColor:r.surface,borderRadius:Math.max(r.radius-12,0)}],children:[J(U,{style:b.card_head,children:[J(q,{style:[b.version,{color:r.text}],children:["v",C.version]}),w(q,{style:[b.date,{color:r.text_secondary}],children:pa(C.created_at)})]}),w(co,{changelog:C.changelog})]},C.version)),!d.length&&w(q,{style:[b.sub_title,b.empty,{color:r.text_secondary}],children:r.labels.history_empty})]}),!o&&J(U,{pointerEvents:"box-none",style:[b.float_header,{paddingTop:i.top}],children:[c&&ga(r.background)?w(c,{pointerEvents:"none",colors:[`${r.background}F5`,`${r.background}E6`,`${r.background}B3`,`${r.background}00`],locations:[0,.45,.75,1],style:[b.fade,{height:u+28}]}):w(U,{pointerEvents:"none",style:b.fade,children:fa.map((C,T)=>w(U,{style:{height:T===0?u:4,backgroundColor:r.background,opacity:C}},T))}),J(U,{style:b.header_row,children:[w(ma,{onPress:n,size:l,GlassView:a,ExpoImage:s}),J(U,{pointerEvents:"none",style:[b.header_title,{left:l+24,right:l+24}],children:[w(q,{style:[b.history_title,{color:r.text}],numberOfLines:1,children:r.labels.history_title}),w(q,{style:[b.history_sub,{color:r.text_secondary}],numberOfLines:1,children:t})]})]})]})]})},fa=[.96,.9,.8,.68,.55,.42,.3,.18,.08],li=e=>({backgroundColor:e.primary,borderRadius:e.button_radius,height:e.button_height,paddingVertical:0,justifyContent:"center"}),ya=4,ci=({request:e,changelog:t,onClose:n,renderHistoryHeader:o,renderActions:r})=>{var h;let i=Xe(),[a,s]=Ye(!1),[c,l]=Ye(0),[u,d]=Ye(0);return w(Xr,{visible:!0,transparent:!a,animationType:a?"slide":"fade",statusBarTranslucent:!0,onRequestClose:a?()=>s(!1):n,children:a?w(ai,{app_id:e.app_id,name:e.name,onBack:()=>s(!1),renderHeader:o}):J(U,{style:[b.overlay,{backgroundColor:i.overlay}],children:[w(Qr,{style:It.absoluteFill,onPress:n,accessibilityLabel:"\u0110\xF3ng"}),J(U,{style:[b.sheet,{backgroundColor:i.surface,borderRadius:i.radius}],children:[J(U,{style:b.sheet_head,children:[w(q,{style:[b.title,{color:i.text}],children:i.labels.changelog_title}),w(q,{style:[b.sheet_name,{color:i.text_secondary}],numberOfLines:1,children:e.name}),J(U,{style:[b.version_pill,{backgroundColor:i.background}],children:[w(q,{style:[b.version_old,{color:i.text_secondary}],children:`v${e.from}`}),w(q,{style:[b.version_arrow,{color:i.hint}],children:"\u2192"}),w(q,{style:[b.version_new,{color:i.primary}],children:`v${e.to}`})]})]}),w(Zr,{style:b.scroll,contentContainerStyle:b.scroll_content,onContentSizeChange:(p,m)=>l(m),onLayout:p=>d(p.nativeEvent.layout.height),children:w(co,{changelog:t,max_items:ya,onMore:()=>s(!0)})}),w(U,{style:[b.sheet_foot,c>u+1&&[b.sheet_foot_divider,{borderTopColor:i.divider}]],children:r?r({onClose:n,onViewAll:()=>s(!0),labels:i.labels}):J(_a,{children:[w(pn,{style:[b.btn_primary,li(i)],activeOpacity:.8,onPress:n,children:w(q,{style:[b.btn_primary_text,{color:i.on_primary}],children:i.labels.changelog_ok})}),w(pn,{style:b.btn_secondary,onPress:()=>s(!0),children:w(q,{style:[b.link,{color:(h=i.secondary)!=null?h:i.primary}],children:i.labels.changelog_view_all})})]})})]})]})})},pi=({update:e,is_updating:t,progress:n,has_failed:o,onUpdate:r,logo:i,renderAction:a})=>{let s=Xe(),c=io(new st.Value(0)).current,l=io(new st.Value(30)).current;return ao(()=>{st.parallel([st.timing(c,{toValue:1,duration:400,useNativeDriver:!0}),st.spring(l,{toValue:0,friction:8,tension:40,useNativeDriver:!0})]).start()},[c,l]),w(Xr,{visible:!0,transparent:!0,animationType:"none",statusBarTranslucent:!0,onRequestClose:()=>{},children:w(U,{style:[b.overlay,{backgroundColor:s.overlay}],children:J(st.View,{style:[b.container,{backgroundColor:s.surface,borderRadius:s.radius},{opacity:c,transform:[{translateY:l}]}],children:[i&&w(ra,{source:i,style:b.logo}),w(q,{style:[b.title,{color:s.text}],children:t?s.labels.updating_title:s.labels.update_title}),!t&&w(q,{style:[b.sub_title,b.gap,{color:s.text_secondary}],children:ti(s.labels.update_message,{next:e.next_version,current:e.current_version})}),!t&&o&&w(q,{style:b.error_text,children:s.labels.update_failed}),t?J(U,{style:b.progress_section,children:[J(q,{style:[b.progress_text,{color:s.primary}],children:[n,"%"]}),w(U,{style:[b.progress_track,{backgroundColor:s.background}],children:w(U,{style:[b.progress_fill,{backgroundColor:s.primary,width:`${n}%`}]})}),w(q,{style:[b.loading_hint,{color:s.hint}],children:s.labels.updating_hint})]}):a?w(U,{style:b.full,children:a({onUpdate:r,has_failed:o,label:o?s.labels.retry:s.labels.update_now})}):w(pn,{style:[b.btn_primary,b.full,li(s)],activeOpacity:.8,onPress:r,children:w(q,{style:[b.btn_primary_text,{color:s.on_primary}],children:o?s.labels.retry:s.labels.update_now})})]})})})},ba=({app_ids:e,shouldShowUpdate:t,logo:n,renderUpdate:o,renderChangelog:r,theme:i,renderHistoryHeader:a,labels:s,renderChangelogActions:c,renderUpdateAction:l})=>{var Q,ye;let u=z(F,D=>D.updates),h=((Q=e!=null?e:R().manual_update)!=null?Q:[]).map(D=>u[D]).find(D=>!!D&&(!t||t(D))),p=Et(h==null?void 0:h.app_id),[m,C]=Ye(!1),[T,P]=Ye(!1),S=io(!1),L=ro(),W=async()=>{if(!h||S.current)return;S.current=!0,C(!0),P(!1);let D=await $n(h.app_id);S.current=!1,C(!1),P(!D)};if(h){let D=(p==null?void 0:p.status)==="updating"?Math.round(((ye=p.progress)!=null?ye:0)*100):0,v={update:h,is_updating:m,progress:D,has_failed:T,onUpdate:W};return w(so,{theme:i,labels:s,children:o?o(v):w(pi,{...v,logo:n,renderAction:l})})}if(L){let D={request:L,changelog:ri(L.versions),onClose:oo};return w(so,{theme:i,labels:s,children:r?r(D):w(ci,{...D,renderHistoryHeader:a,renderActions:c})})}return null},Yr=cn.select({ios:{shadowColor:B.shadow,shadowOffset:{width:0,height:10},shadowOpacity:.1,shadowRadius:20},android:{elevation:10}}),b=It.create({overlay:{flex:1,backgroundColor:B.overlay,justifyContent:"center",alignItems:"center"},container:{width:"85%",maxWidth:340,backgroundColor:B.surface,padding:24,borderRadius:28,alignItems:"center",...Yr},sheet:{width:"88%",maxWidth:380,maxHeight:"78%",backgroundColor:B.surface,borderRadius:28,overflow:"hidden",...Yr},sheet_head:{alignItems:"center",paddingTop:24,paddingHorizontal:22,paddingBottom:4},sheet_name:{fontSize:13,color:B.sub_title,marginTop:4,maxWidth:"100%"},version_pill:{flexDirection:"row",alignItems:"center",gap:6,marginTop:10,paddingHorizontal:12,paddingVertical:5,borderRadius:999,backgroundColor:B.background},version_old:{fontSize:13,color:B.sub_title,fontVariant:["tabular-nums"]},version_arrow:{fontSize:13,color:B.hint},version_new:{fontSize:13,fontWeight:"700",color:B.blue,fontVariant:["tabular-nums"]},sheet_foot:{paddingHorizontal:22,paddingTop:4,paddingBottom:18},sheet_foot_divider:{borderTopWidth:It.hairlineWidth,borderTopColor:"rgba(60, 60, 67, 0.18)"},logo:{width:64,height:64,borderRadius:16,marginBottom:20},title:{fontSize:20,fontWeight:"700",color:B.title,textAlign:"center"},sub_title:{fontSize:13,color:B.sub_title,textAlign:"center",lineHeight:18,marginTop:6},gap:{marginBottom:15},error_text:{fontSize:12,textAlign:"center",color:B.error,lineHeight:17,marginBottom:15},progress_section:{width:"100%",alignItems:"center",paddingVertical:8,marginTop:8,gap:12},progress_text:{fontSize:18,fontWeight:"700",color:B.blue},progress_track:{width:"100%",height:6,borderRadius:3,backgroundColor:B.track,overflow:"hidden"},progress_fill:{height:"100%",borderRadius:3,backgroundColor:B.blue},loading_hint:{fontSize:12,color:B.hint,textAlign:"center"},scroll:{flexGrow:0,flexShrink:1},scroll_content:{paddingHorizontal:22,paddingTop:16,paddingBottom:16},groups:{gap:18},group:{gap:8},group_head:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},group_count:{fontSize:12,fontWeight:"600",color:B.hint},dot:{width:5,height:5,borderRadius:3,marginTop:8},more:{fontSize:14,fontWeight:"500",color:B.blue,paddingLeft:17,paddingTop:2},badge:{alignSelf:"flex-start",paddingHorizontal:10,paddingVertical:3,borderRadius:999},badge_text:{fontSize:12,fontWeight:"700"},item:{flexDirection:"row",gap:10,paddingLeft:2},item_text:{flex:1,fontSize:15,lineHeight:21,color:B.title},md_bold:{fontWeight:"700"},md_code:{fontFamily:cn.select({ios:"Menlo",default:"monospace"}),fontSize:13,backgroundColor:"#F2F2F7",color:"#3A3A3C"},md_link:{color:B.blue,textDecorationLine:"underline"},full:{width:"100%"},btn_primary:{marginTop:14,backgroundColor:B.blue,paddingVertical:14,borderRadius:12,alignItems:"center"},btn_primary_text:{color:"white",fontWeight:"600",fontSize:16},btn_secondary:{paddingTop:12,alignItems:"center"},link:{color:B.blue,fontSize:15,fontWeight:"600"},history:{flex:1,backgroundColor:B.background},float_header:{position:"absolute",top:0,left:0,right:0},header_row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:2,paddingBottom:8},header_title:{position:"absolute",top:2,bottom:8,alignItems:"center",justifyContent:"center"},history_title:{fontSize:15,fontWeight:"500",color:"#1C1C1E"},history_sub:{fontSize:11,color:"#71717A",marginTop:1},back_btn:{alignItems:"center",justifyContent:"center"},back_btn_fallback:{backgroundColor:B.surface,...cn.select({ios:{shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.1,shadowRadius:8},default:{borderWidth:It.hairlineWidth*2,borderColor:"rgba(0, 0, 0, 0.08)"}})},icon_layer:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},fade:{position:"absolute",top:0,left:0,right:0},chevron:{width:11,height:11,borderLeftWidth:2.2,borderBottomWidth:2.2,borderColor:si,transform:[{rotate:"45deg"}],marginLeft:4},pressed:{opacity:.6,transform:[{scale:.94}]},history_list:{padding:16,gap:12},card:{backgroundColor:B.surface,borderRadius:16,padding:16,gap:12},card_head:{flexDirection:"row",justifyContent:"space-between",alignItems:"baseline"},version:{fontSize:16,fontWeight:"700",color:B.title},date:{fontSize:13,color:B.sub_title},loading:{marginTop:40},center:{alignItems:"center",marginTop:40,gap:12},empty:{marginTop:40}}),wa=Zs.memo(ba);export{de as CodeType,ei as DEFAULT_MINIAPP_UPDATES_LABELS,ci as DefaultMiniAppChangelogPrompt,jr as DefaultMiniAppSplash,pi as DefaultMiniAppUpdatePrompt,oi as MINIAPP_CHANGELOG_KINDS,pt as MINIAPP_PLATFORM_URL,co as MiniAppChangelogGroups,ai as MiniAppChangelogHistory,ii as MiniAppChangelogText,Ws as MiniAppHost,g as MiniAppHostError,wa as MiniAppUpdates,so as MiniAppUpdatesThemeProvider,et as ScannerEndReason,_n as ScannerEvent,_e as ScannerLayout,yt as ScannerMethod,Me as ToastType,Tt as closeMiniApp,ui as configureMiniApp,gi as createMmkvStorage,ho as createReactNativeBiometrics,di as createRnfsFileSystem,oo as dismissMiniAppChangelog,on as ensureMiniApp,to as fetchMiniAppChangelog,V as getLocalMiniApp,Fs as getMiniAppCatalog,kt as getMiniAppCatalogEntry,eo as getMiniAppChangelogSeen,vs as getMiniAppStatuses,Hr as getMiniAppUpdate,Kr as getPendingChangelog,Ki as installBundledMiniApp,Ft as markMiniAppChangelogSeen,ri as mergeMiniAppChangelog,Hn as onMiniAppEvent,ms as openMiniApp,an as parseInlineMarkdown,Es as pauseMiniApp,Rs as pauseMiniAppDownloads,fs as preloadMiniApp,Ie as releaseSpeechFor,lo as resolveMiniAppUpdatesTheme,Ps as restoreMiniApp,ks as resumeMiniApp,Os as resumeMiniAppDownloads,Xi as sendEventToWeb,Zn as showMiniAppChangelog,Qs as stripInlineMarkdown,zn as syncMiniAppCatalog,Ts as uninstallMiniApp,$n as updateMiniApp,ko as uploadToUrl,no as useMiniAppChangelog,ro as useMiniAppChangelogRequest,Et as useMiniAppDownload,Ms as useMiniAppDownloadsPaused,Xe as useMiniAppUpdatesTheme};
|
|
89
|
+
Vui l\xF2ng c\u1EADp nh\u1EADt \u0111\u1EC3 ti\u1EBFp t\u1EE5c s\u1EED d\u1EE5ng.`,update_failed:"C\u1EADp nh\u1EADt kh\xF4ng th\xE0nh c\xF4ng. Ki\u1EC3m tra k\u1EBFt n\u1ED1i m\u1EA1ng r\u1ED3i th\u1EED l\u1EA1i.",update_now:"C\u1EADp nh\u1EADt ngay",updating_hint:"Vui l\xF2ng kh\xF4ng t\u1EAFt \u1EE9ng d\u1EE5ng"},ti=(e,t)=>e.replace(/\{(\w+)\}/g,(n,o)=>o in t?String(t[o]):n),B={blue:"#007AFF",track:"#E5E5EA",overlay:"rgba(0, 0, 0, 0.6)",shadow:"#000000",title:"#1A1A1A",sub_title:"#666666",error:"#D92D20",hint:"#C0C0C0",surface:"#FFFFFF",background:"#F2F2F7"},ni=[{key:"new",label:"M\u1EDBi",color:"#007AFF",bg:"#E5F1FF"},{key:"fix",label:"S\u1EEDa l\u1ED7i",color:"#C4320A",bg:"#FFF1EB"},{key:"improve",label:"C\u1EA3i thi\u1EC7n",color:"#067647",bg:"#E7F7EE"}],sa={primary:"#007AFF",on_primary:"#FFFFFF",background:"#F2F2F7",surface:"#FFFFFF",text:"#1C1C1E",text_secondary:"#666666",hint:"#AEAEB2",overlay:"rgba(0, 0, 0, 0.6)",divider:"rgba(60, 60, 67, 0.18)",radius:28,button_radius:12,button_height:50},aa={primary:"#0A84FF",on_primary:"#FFFFFF",background:"#000000",surface:"#1C1C1E",text:"#FFFFFF",text_secondary:"#A1A1AA",hint:"#636366",overlay:"rgba(0, 0, 0, 0.7)",divider:"rgba(84, 84, 88, 0.6)",radius:28,button_radius:12,button_height:50},la={new:{color:"#64B5FF",bg:"rgba(10, 132, 255, 0.18)"},fix:{color:"#FF9F7A",bg:"rgba(255, 112, 67, 0.18)"},improve:{color:"#5FD39A",bg:"rgba(48, 209, 88, 0.18)"}},lo=(e={},t)=>{let n=!!e.dark,{kinds:o,...r}=e;return{...n?aa:sa,...Object.fromEntries(Object.entries(r).filter(([,a])=>a!==void 0)),dark:n,labels:{...ei,...t},kinds:ni.map(a=>({...a,...n?la[a.key]:null,...a.key==="new"&&e.primary?{color:e.primary}:null,...o==null?void 0:o[a.key]}))}},oi=ea(void 0),so=({theme:e,labels:t,children:n})=>{let o=na(()=>lo(e,t),[e,t]);return w(oi.Provider,{value:o,children:n})},ca=lo(),Xe=()=>{var e;return(e=ta(oi))!=null?e:ca},ri=e=>({new:e.flatMap(t=>t.changelog.new),fix:e.flatMap(t=>t.changelog.fix),improve:e.flatMap(t=>t.changelog.improve)}),pa=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("vi-VN")},ii=({text:e,style:t})=>{let n=Xe();return w(q,{style:t,children:an(e.replace(/^(?:[-*•]\s+)+/,"")).map((o,r)=>{switch(o.type){case"bold":return w(q,{style:b.md_bold,children:o.text},r);case"code":return w(q,{style:[b.md_code,{backgroundColor:n.background,color:n.text}],children:o.text},r);case"link":return w(q,{style:[b.md_link,{color:n.primary}],accessibilityRole:"link",onPress:()=>{ia.openURL(o.url).catch(()=>{})},children:o.text},r);default:return o.text}})})},co=({changelog:e,max_items:t,onMore:n})=>{let o=Xe();return w(U,{style:b.groups,children:o.kinds.filter(r=>e[r.key].length).map(r=>{let i=e[r.key],a=t?i.slice(0,t):i,s=i.length-a.length;return J(U,{style:b.group,children:[J(U,{style:b.group_head,children:[w(U,{style:[b.badge,{backgroundColor:r.bg}],children:w(q,{style:[b.badge_text,{color:r.color}],children:r.label})}),w(q,{style:[b.group_count,{color:o.hint}],children:i.length})]}),a.map((c,l)=>J(U,{style:b.item,children:[w(U,{style:[b.dot,{backgroundColor:r.color}]}),w(ii,{text:c,style:[b.item_text,{color:o.text}]})]},l)),s>0&&w(q,{style:[b.more,{color:o.primary}],onPress:n,suppressHighlighting:!0,children:ti(o.labels.changelog_more,{count:s})})]},r.key)})})},ln,ua=()=>(ln!=null||(ln=Promise.all([cn.OS==="ios"?import("expo-image").then(e=>e.Image).catch(()=>{}):Promise.resolve(void 0),import("expo-linear-gradient").then(e=>e.LinearGradient).catch(()=>{})]).then(([e,t])=>({ExpoImage:e,LinearGradient:t}))),ln),da=()=>{let[e,t]=Ye({});return ao(()=>{let n=!0;return ua().then(o=>{n&&t(o)}),()=>{n=!1}},[]),e},si="#1C1C1E",ga=e=>/^#[0-9a-f]{6}$/i.test(e),ha=()=>{let[e,t]=Ye();return ao(()=>{let n=!0;return bt().then(o=>{n&&o&&t(()=>o)}),()=>{n=!1}},[]),e},ma=({onPress:e,size:t,GlassView:n,ExpoImage:o})=>{let r=Xe(),i=r.dark?"#FFFFFF":si;return J(Qr,{onPress:e,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Quay l\u1EA1i",style:({pressed:a})=>[b.back_btn,{width:t,height:t,borderRadius:t/2},!n&&b.back_btn_fallback,!n&&r.dark&&{backgroundColor:"#3F3F46",shadowOpacity:0},!n&&a&&b.pressed],children:[n&&w(n,{style:[It.absoluteFill,{borderRadius:t/2}],glassEffectStyle:"regular",colorScheme:r.dark?"dark":"light",isInteractive:!0}),w(U,{pointerEvents:"none",style:b.icon_layer,children:o?w(o,{source:"sf:chevron.left",transition:0,contentFit:"contain",style:{width:20,height:20,fontSize:20,color:i}}):w(U,{style:[b.chevron,{borderColor:i}]})})]})},ai=({app_id:e,name:t,onBack:n,renderHeader:o})=>{let r=Xe(),i=tt(),a=ha(),{ExpoImage:s,LinearGradient:c}=da(),l=a?46:42,u=o?0:i.top+l+10,{versions:d,loading:h,error:p,reload:m}=no(e);return J(U,{style:[b.history,{backgroundColor:r.background}],children:[o&&w(U,{style:{paddingTop:i.top},children:o({title:r.labels.history_title,subtitle:t,onBack:n})}),h&&!d.length?w(oa,{style:[b.loading,{marginTop:u+40}],color:r.primary}):p&&!d.length?J(U,{style:[b.center,{marginTop:u+40}],children:[w(q,{style:[b.sub_title,{color:r.text_secondary}],children:r.labels.history_error}),w(pn,{onPress:m,children:w(q,{style:[b.link,{color:r.primary}],children:r.labels.retry})})]}):J(Zr,{contentContainerStyle:[b.history_list,{paddingTop:u+8,paddingBottom:i.bottom+24}],scrollIndicatorInsets:{top:u},children:[d.map(C=>J(U,{style:[b.card,{backgroundColor:r.surface,borderRadius:Math.max(r.radius-12,0)}],children:[J(U,{style:b.card_head,children:[J(q,{style:[b.version,{color:r.text}],children:["v",C.version]}),w(q,{style:[b.date,{color:r.text_secondary}],children:pa(C.created_at)})]}),w(co,{changelog:C.changelog})]},C.version)),!d.length&&w(q,{style:[b.sub_title,b.empty,{color:r.text_secondary}],children:r.labels.history_empty})]}),!o&&J(U,{pointerEvents:"box-none",style:[b.float_header,{paddingTop:i.top}],children:[c&&ga(r.background)?w(c,{pointerEvents:"none",colors:[`${r.background}F5`,`${r.background}E6`,`${r.background}B3`,`${r.background}00`],locations:[0,.45,.75,1],style:[b.fade,{height:u+28}]}):w(U,{pointerEvents:"none",style:b.fade,children:fa.map((C,T)=>w(U,{style:{height:T===0?u:4,backgroundColor:r.background,opacity:C}},T))}),J(U,{style:b.header_row,children:[w(ma,{onPress:n,size:l,GlassView:a,ExpoImage:s}),J(U,{pointerEvents:"none",style:[b.header_title,{left:l+24,right:l+24}],children:[w(q,{style:[b.history_title,{color:r.text}],numberOfLines:1,children:r.labels.history_title}),w(q,{style:[b.history_sub,{color:r.text_secondary}],numberOfLines:1,children:t})]})]})]})]})},fa=[.96,.9,.8,.68,.55,.42,.3,.18,.08],li=e=>({backgroundColor:e.primary,borderRadius:e.button_radius,height:e.button_height,paddingVertical:0,justifyContent:"center"}),ya=4,ci=({request:e,changelog:t,onClose:n,renderHistoryHeader:o,renderActions:r})=>{var h;let i=Xe(),[a,s]=Ye(!1),[c,l]=Ye(0),[u,d]=Ye(0);return w(Xr,{visible:!0,transparent:!a,animationType:a?"slide":"fade",statusBarTranslucent:!0,onRequestClose:a?()=>s(!1):n,children:a?w(ai,{app_id:e.app_id,name:e.name,onBack:()=>s(!1),renderHeader:o}):J(U,{style:[b.overlay,{backgroundColor:i.overlay}],children:[w(Qr,{style:It.absoluteFill,onPress:n,accessibilityLabel:"\u0110\xF3ng"}),J(U,{style:[b.sheet,{backgroundColor:i.surface,borderRadius:i.radius}],children:[J(U,{style:b.sheet_head,children:[w(q,{style:[b.title,{color:i.text}],children:i.labels.changelog_title}),w(q,{style:[b.sheet_name,{color:i.text_secondary}],numberOfLines:1,children:e.name}),J(U,{style:[b.version_pill,{backgroundColor:i.background}],children:[w(q,{style:[b.version_old,{color:i.text_secondary}],children:`v${e.from}`}),w(q,{style:[b.version_arrow,{color:i.hint}],children:"\u2192"}),w(q,{style:[b.version_new,{color:i.primary}],children:`v${e.to}`})]})]}),w(Zr,{style:b.scroll,contentContainerStyle:b.scroll_content,onContentSizeChange:(p,m)=>l(m),onLayout:p=>d(p.nativeEvent.layout.height),children:w(co,{changelog:t,max_items:ya,onMore:()=>s(!0)})}),w(U,{style:[b.sheet_foot,c>u+1&&[b.sheet_foot_divider,{borderTopColor:i.divider}]],children:r?r({onClose:n,onViewAll:()=>s(!0),labels:i.labels}):J(_a,{children:[w(pn,{style:[b.btn_primary,li(i)],activeOpacity:.8,onPress:n,children:w(q,{style:[b.btn_primary_text,{color:i.on_primary}],children:i.labels.changelog_ok})}),w(pn,{style:b.btn_secondary,onPress:()=>s(!0),children:w(q,{style:[b.link,{color:(h=i.secondary)!=null?h:i.primary}],children:i.labels.changelog_view_all})})]})})]})]})})},pi=({update:e,is_updating:t,progress:n,has_failed:o,onUpdate:r,logo:i,renderAction:a})=>{let s=Xe(),c=io(new st.Value(0)).current,l=io(new st.Value(30)).current;return ao(()=>{st.parallel([st.timing(c,{toValue:1,duration:400,useNativeDriver:!0}),st.spring(l,{toValue:0,friction:8,tension:40,useNativeDriver:!0})]).start()},[c,l]),w(Xr,{visible:!0,transparent:!0,animationType:"none",statusBarTranslucent:!0,onRequestClose:()=>{},children:w(U,{style:[b.overlay,{backgroundColor:s.overlay}],children:J(st.View,{style:[b.container,{backgroundColor:s.surface,borderRadius:s.radius},{opacity:c,transform:[{translateY:l}]}],children:[i&&w(ra,{source:i,style:b.logo}),w(q,{style:[b.title,{color:s.text}],children:t?s.labels.updating_title:s.labels.update_title}),!t&&w(q,{style:[b.sub_title,b.gap,{color:s.text_secondary}],children:ti(s.labels.update_message,{next:e.next_version,current:e.current_version})}),!t&&o&&w(q,{style:b.error_text,children:s.labels.update_failed}),t?J(U,{style:b.progress_section,children:[J(q,{style:[b.progress_text,{color:s.primary}],children:[n,"%"]}),w(U,{style:[b.progress_track,{backgroundColor:s.background}],children:w(U,{style:[b.progress_fill,{backgroundColor:s.primary,width:`${n}%`}]})}),w(q,{style:[b.loading_hint,{color:s.hint}],children:s.labels.updating_hint})]}):a?w(U,{style:b.full,children:a({onUpdate:r,has_failed:o,label:o?s.labels.retry:s.labels.update_now})}):w(pn,{style:[b.btn_primary,b.full,li(s)],activeOpacity:.8,onPress:r,children:w(q,{style:[b.btn_primary_text,{color:s.on_primary}],children:o?s.labels.retry:s.labels.update_now})})]})})})},ba=({app_ids:e,shouldShowUpdate:t,logo:n,renderUpdate:o,renderChangelog:r,theme:i,renderHistoryHeader:a,labels:s,renderChangelogActions:c,renderUpdateAction:l})=>{var Q,ye;let u=z(F,D=>D.updates),h=((Q=e!=null?e:R().manual_update)!=null?Q:[]).map(D=>u[D]).find(D=>!!D&&(!t||t(D))),p=Et(h==null?void 0:h.app_id),[m,C]=Ye(!1),[T,P]=Ye(!1),S=io(!1),L=ro(),W=async()=>{if(!h||S.current)return;S.current=!0,C(!0),P(!1);let D=await $n(h.app_id);S.current=!1,C(!1),P(!D)};if(h){let D=(p==null?void 0:p.status)==="updating"?Math.round(((ye=p.progress)!=null?ye:0)*100):0,v={update:h,is_updating:m,progress:D,has_failed:T,onUpdate:W};return w(so,{theme:i,labels:s,children:o?o(v):w(pi,{...v,logo:n,renderAction:l})})}if(L){let D={request:L,changelog:ri(L.versions),onClose:oo};return w(so,{theme:i,labels:s,children:r?r(D):w(ci,{...D,renderHistoryHeader:a,renderActions:c})})}return null},Yr=cn.select({ios:{shadowColor:B.shadow,shadowOffset:{width:0,height:10},shadowOpacity:.1,shadowRadius:20},android:{elevation:10}}),b=It.create({overlay:{flex:1,backgroundColor:B.overlay,justifyContent:"center",alignItems:"center"},container:{width:"85%",maxWidth:340,backgroundColor:B.surface,padding:24,borderRadius:28,alignItems:"center",...Yr},sheet:{width:"88%",maxWidth:380,maxHeight:"78%",backgroundColor:B.surface,borderRadius:28,overflow:"hidden",...Yr},sheet_head:{alignItems:"center",paddingTop:24,paddingHorizontal:22,paddingBottom:4},sheet_name:{fontSize:13,color:B.sub_title,marginTop:4,maxWidth:"100%"},version_pill:{flexDirection:"row",alignItems:"center",gap:6,marginTop:10,paddingHorizontal:12,paddingVertical:5,borderRadius:999,backgroundColor:B.background},version_old:{fontSize:13,color:B.sub_title,fontVariant:["tabular-nums"]},version_arrow:{fontSize:13,color:B.hint},version_new:{fontSize:13,fontWeight:"700",color:B.blue,fontVariant:["tabular-nums"]},sheet_foot:{paddingHorizontal:22,paddingTop:4,paddingBottom:18},sheet_foot_divider:{borderTopWidth:It.hairlineWidth,borderTopColor:"rgba(60, 60, 67, 0.18)"},logo:{width:64,height:64,borderRadius:16,marginBottom:20},title:{fontSize:20,fontWeight:"700",color:B.title,textAlign:"center"},sub_title:{fontSize:13,color:B.sub_title,textAlign:"center",lineHeight:18,marginTop:6},gap:{marginBottom:15},error_text:{fontSize:12,textAlign:"center",color:B.error,lineHeight:17,marginBottom:15},progress_section:{width:"100%",alignItems:"center",paddingVertical:8,marginTop:8,gap:12},progress_text:{fontSize:18,fontWeight:"700",color:B.blue},progress_track:{width:"100%",height:6,borderRadius:3,backgroundColor:B.track,overflow:"hidden"},progress_fill:{height:"100%",borderRadius:3,backgroundColor:B.blue},loading_hint:{fontSize:12,color:B.hint,textAlign:"center"},scroll:{flexGrow:0,flexShrink:1},scroll_content:{paddingHorizontal:22,paddingTop:16,paddingBottom:16},groups:{gap:18},group:{gap:8},group_head:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},group_count:{fontSize:12,fontWeight:"600",color:B.hint},dot:{width:5,height:5,borderRadius:3,marginTop:8},more:{fontSize:14,fontWeight:"500",color:B.blue,paddingLeft:17,paddingTop:2},badge:{alignSelf:"flex-start",paddingHorizontal:10,paddingVertical:3,borderRadius:999},badge_text:{fontSize:12,fontWeight:"700"},item:{flexDirection:"row",gap:10,paddingLeft:2},item_text:{flex:1,fontSize:15,lineHeight:21,color:B.title},md_bold:{fontWeight:"700"},md_code:{fontFamily:cn.select({ios:"Menlo",default:"monospace"}),fontSize:13,backgroundColor:"#F2F2F7",color:"#3A3A3C"},md_link:{color:B.blue,textDecorationLine:"underline"},full:{width:"100%"},btn_primary:{marginTop:14,backgroundColor:B.blue,paddingVertical:14,borderRadius:12,alignItems:"center"},btn_primary_text:{color:"white",fontWeight:"600",fontSize:16},btn_secondary:{paddingTop:12,alignItems:"center"},link:{color:B.blue,fontSize:15,fontWeight:"600"},history:{flex:1,backgroundColor:B.background},float_header:{position:"absolute",top:0,left:0,right:0},header_row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:2,paddingBottom:8},header_title:{position:"absolute",top:2,bottom:8,alignItems:"center",justifyContent:"center"},history_title:{fontSize:15,fontWeight:"500",color:"#1C1C1E"},history_sub:{fontSize:11,color:"#71717A",marginTop:1},back_btn:{alignItems:"center",justifyContent:"center"},back_btn_fallback:{backgroundColor:B.surface,...cn.select({ios:{shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.1,shadowRadius:8},default:{borderWidth:It.hairlineWidth*2,borderColor:"rgba(0, 0, 0, 0.08)"}})},icon_layer:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},fade:{position:"absolute",top:0,left:0,right:0},chevron:{width:11,height:11,borderLeftWidth:2.2,borderBottomWidth:2.2,borderColor:si,transform:[{rotate:"45deg"}],marginLeft:4},pressed:{opacity:.6,transform:[{scale:.94}]},history_list:{padding:16,gap:12},card:{backgroundColor:B.surface,borderRadius:16,padding:16,gap:12},card_head:{flexDirection:"row",justifyContent:"space-between",alignItems:"baseline"},version:{fontSize:16,fontWeight:"700",color:B.title},date:{fontSize:13,color:B.sub_title},loading:{marginTop:40},center:{alignItems:"center",marginTop:40,gap:12},empty:{marginTop:40}}),wa=Zs.memo(ba);export{de as CodeType,ei as DEFAULT_MINIAPP_UPDATES_LABELS,ci as DefaultMiniAppChangelogPrompt,jr as DefaultMiniAppSplash,pi as DefaultMiniAppUpdatePrompt,ni as MINIAPP_CHANGELOG_KINDS,pt as MINIAPP_PLATFORM_URL,co as MiniAppChangelogGroups,ai as MiniAppChangelogHistory,ii as MiniAppChangelogText,Ws as MiniAppHost,g as MiniAppHostError,wa as MiniAppUpdates,so as MiniAppUpdatesThemeProvider,et as ScannerEndReason,_n as ScannerEvent,_e as ScannerLayout,yt as ScannerMethod,Me as ToastType,Tt as closeMiniApp,ui as configureMiniApp,gi as createMmkvStorage,ho as createReactNativeBiometrics,di as createRnfsFileSystem,oo as dismissMiniAppChangelog,on as ensureMiniApp,to as fetchMiniAppChangelog,V as getLocalMiniApp,Fs as getMiniAppCatalog,kt as getMiniAppCatalogEntry,eo as getMiniAppChangelogSeen,vs as getMiniAppStatuses,Hr as getMiniAppUpdate,Kr as getPendingChangelog,Ki as installBundledMiniApp,Ft as markMiniAppChangelogSeen,ri as mergeMiniAppChangelog,Hn as onMiniAppEvent,ms as openMiniApp,an as parseInlineMarkdown,Es as pauseMiniApp,Rs as pauseMiniAppDownloads,fs as preloadMiniApp,Ie as releaseSpeechFor,lo as resolveMiniAppUpdatesTheme,Ps as restoreMiniApp,ks as resumeMiniApp,Os as resumeMiniAppDownloads,Xi as sendEventToWeb,Zn as showMiniAppChangelog,Qs as stripInlineMarkdown,zn as syncMiniAppCatalog,Ts as uninstallMiniApp,$n as updateMiniApp,ko as uploadToUrl,no as useMiniAppChangelog,ro as useMiniAppChangelogRequest,Et as useMiniAppDownload,Ms as useMiniAppDownloadsPaused,Xe as useMiniAppUpdatesTheme};
|