@retion-miniapp/react-native 0.20.1 → 0.20.2
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 +32 -35
- package/dist/index.d.ts +32 -35
- package/dist/index.js +11 -11
- package/dist/index.mjs +11 -11
- package/docs/MINIAPP_README.md +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Qr=Object.create;var Rt=Object.defineProperty;var Zr=Object.getOwnPropertyDescriptor;var ei=Object.getOwnPropertyNames;var ti=Object.getPrototypeOf,ni=Object.prototype.hasOwnProperty;var oi=(e,t)=>{for(var n in t)Rt(e,n,{get:t[n],enumerable:!0})},no=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ei(t))!ni.call(e,r)&&r!==n&&Rt(e,r,{get:()=>t[r],enumerable:!(o=Zr(t,r))||o.enumerable});return e};var me=(e,t,n)=>(n=e!=null?Qr(ti(e)):{},no(t||!e||!e.__esModule?Rt(n,"default",{value:e,enumerable:!0}):n,e)),ri=e=>no(Rt({},"__esModule",{value:!0}),e);var _s={};oi(_s,{CodeType:()=>le,DEFAULT_MINIAPP_UPDATES_LABELS:()=>Gn,DefaultMiniAppChangelogPrompt:()=>Qn,DefaultMiniAppSplash:()=>$n,DefaultMiniAppUpdatePrompt:()=>Zn,MINIAPP_CHANGELOG_KINDS:()=>Jn,MINIAPP_PLATFORM_URL:()=>Ze,MiniAppChangelogGroups:()=>un,MiniAppChangelogHistory:()=>Xn,MiniAppChangelogText:()=>Yn,MiniAppHost:()=>Hr,MiniAppHostError:()=>m,MiniAppUpdates:()=>Xr,MiniAppUpdatesThemeProvider:()=>cn,ScannerEndReason:()=>Ye,ScannerEvent:()=>Vt,ScannerLayout:()=>ye,ScannerMethod:()=>tt,ToastType:()=>Ae,closeMiniApp:()=>it,configureMiniApp:()=>ro,createMmkvStorage:()=>so,createReactNativeBiometrics:()=>mn,createRnfsFileSystem:()=>io,dismissMiniAppChangelog:()=>sn,ensureMiniApp:()=>Ct,fetchMiniAppChangelog:()=>on,getLocalMiniApp:()=>z,getMiniAppCatalog:()=>Nr,getMiniAppCatalogEntry:()=>at,getMiniAppChangelogSeen:()=>nn,getMiniAppStatuses:()=>kr,getMiniAppUpdate:()=>Hn,getPendingChangelog:()=>jn,installBundledMiniApp:()=>gr,markMiniAppChangelogSeen:()=>lt,mergeMiniAppChangelog:()=>Kn,onMiniAppEvent:()=>Xt,openMiniApp:()=>vr,parseInlineMarkdown:()=>Pt,pauseMiniApp:()=>Ir,pauseMiniAppDownloads:()=>Dr,preloadMiniApp:()=>xr,releaseSpeechFor:()=>Ie,resolveMiniAppUpdatesTheme:()=>pn,restoreMiniApp:()=>Fr,resumeMiniApp:()=>Lr,resumeMiniAppDownloads:()=>Ur,sendEventToWeb:()=>fr,showMiniAppChangelog:()=>tn,stripInlineMarkdown:()=>Wr,syncMiniAppCatalog:()=>Zt,uninstallMiniApp:()=>Or,updateMiniApp:()=>en,uploadToUrl:()=>wn,useMiniAppChangelog:()=>rn,useMiniAppChangelogRequest:()=>an,useMiniAppDownload:()=>st,useMiniAppDownloadsPaused:()=>Er,useMiniAppUpdatesTheme:()=>We});module.exports=ri(_s);var Ze="https://retion-miniapp-platform.vercel.app",Ge=null,oo=new Set,ro=e=>{Ge=e,oo.forEach(t=>t())},L=()=>{if(!Ge)throw new Error("[miniapp] Ch\u01B0a g\u1ECDi configureMiniApp()");return Ge},Ot=e=>{oo.add(e),Ge&&e()},fe=(...e)=>{Ge!=null&&Ge.debug&&console.log("[miniapp]",...e)};var io=(e,t)=>({document_dir:e.DocumentDirectoryPath,cache_dir:e.CachesDirectoryPath,exists:n=>e.exists(n),mkdir:n=>e.mkdir(n),remove:n=>e.unlink(n).catch(()=>{}),listDir:n=>e.readDir(n).then(o=>o.map(r=>r.name)).catch(()=>[]),sha256:n=>e.hash(n,"sha256"),unzip:async(n,o)=>{await t(n,o)},download:({url:n,to_file:o,onProgress:r})=>{let{jobId:i,promise:a}=e.downloadFile({fromUrl:n,toFile:o,progressInterval:250,begin:()=>{},progress:({bytesWritten:s,contentLength:c})=>r==null?void 0:r(s,c)});return{promise:a.then(({statusCode:s})=>({status:s})),cancel:()=>e.stopDownload(i)}}}),so=e=>({getString:t=>e.getString(t),setString:(t,n)=>e.set(t,n)});var v=me(require("react")),N=require("react-native"),qr=me(require("react-native-webview"));var wt=require("react-native");var mn=e=>({getAvailability:()=>e.isSensorAvailable(),authenticate:({reason:t,cancelButtonText:n})=>e.simplePrompt({promptMessage:t,cancelButtonText:n,fallbackPromptMessage:""})}),Ft,fn=()=>(Ft||(Ft=import("react-native-biometrics").then(({default:e})=>mn(new e({allowDeviceCredentials:!1}))).catch(e=>{throw Ft=void 0,new m("NOT_SUPPORTED",`Biometric native module unavailable: ${e instanceof Error?e.message:String(e)}`)})),Ft);var Oe=require("react-native");var ao=e=>{var n,o,r;if(e!==void 0&&(e===null||typeof e!="object"||Array.isArray(e)))throw new m("INVALID_PARAMS","Tu\u1EF3 ch\u1ECDn v\u1ECB tr\xED ph\u1EA3i l\xE0 object");let t=e!=null?e:{};if(t.enableHighAccuracy!==void 0&&typeof t.enableHighAccuracy!="boolean")throw new m("INVALID_PARAMS","enableHighAccuracy ph\u1EA3i l\xE0 boolean");for(let[i,a,s]of[["timeout",1,6e4],["maximumAge",0,864e5]]){let c=t[i];if(c!==void 0&&(typeof c!="number"||!Number.isFinite(c)||c<a||c>s))throw new m("INVALID_PARAMS",`${i} ph\u1EA3i n\u1EB1m trong kho\u1EA3ng ${a}\u2013${s} ms`)}return{enableHighAccuracy:(n=t.enableHighAccuracy)!=null?n:!1,timeout:(o=t.timeout)!=null?o:15e3,maximumAge:(r=t.maximumAge)!=null?r:0}},lo=(e,t=()=>!0)=>new Promise((n,o)=>{let r=!1,i=(c,l)=>{r||(r=!0,clearTimeout(a),c?o(c):n(l))},a=setTimeout(()=>i(new m("TIMEOUT","H\u1EBFt th\u1EDDi gian ch\u1EDD c\u1EA5p quy\u1EC1n/l\u1EA5y v\u1ECB tr\xED")),12e4+e.timeout),s=()=>r?!1:t()?!0:(i(new m("CANCELLED","Mini app kh\xF4ng c\xF2n ho\u1EA1t \u0111\u1ED9ng")),!1);(async()=>{if(!s())return;let c;try{c=(await import("@react-native-community/geolocation")).default}catch{throw new m("NOT_SUPPORTED","Ch\u01B0a c\xF3 module v\u1ECB tr\xED trong b\u1EA3n native")}if(s()){if(Oe.Platform.OS==="android"){let l=Oe.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,u=Oe.PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,d=await Oe.PermissionsAndroid.check(l);if(!s())return;let f=d||await Oe.PermissionsAndroid.check(u);if(!s())return;if(!d&&!f){let p=await Oe.PermissionsAndroid.requestMultiple([l,u]);if(!s())return;if(p[l]!==Oe.PermissionsAndroid.RESULTS.GRANTED&&p[u]!==Oe.PermissionsAndroid.RESULTS.GRANTED)throw new m("PERMISSION_DENIED","Ch\u01B0a c\u1EA5p quy\u1EC1n truy c\u1EADp v\u1ECB tr\xED")}}s()&&c.getCurrentPosition(l=>{s()&&i(void 0,l)},l=>{var d;if(!s())return;let u=(d={1:"PERMISSION_DENIED",2:"POSITION_UNAVAILABLE",3:"TIMEOUT"}[l.code])!=null?d:"LOCATION_ERROR";i(new m(u,l.message))},e)}})().catch(c=>i(c))});var bn=require("react-native");var yn=20,co=20,fo=/^[a-z][a-z0-9_-]{0,31}$/,ii=/^(\.[\w-]{1,16}|[\w.+-]+\/(\*|[\w.+-]+))$/,si=["low","medium","high"],Be=e=>!!e&&typeof e=="object"&&!Array.isArray(e),re=e=>new m("INVALID_PARAMS",e),mt=(e,t,n)=>typeof e=="number"&&Number.isInteger(e)&&e>=t&&e<=n,po=(e,t)=>{if(e===void 0)return{};if(!Be(e)||Object.keys(e).length>co||Object.values(e).some(n=>typeof n!="string"))throw re(`${t} ph\u1EA3i l\xE0 object chu\u1ED7i (t\u1ED1i \u0111a ${co} key)`);return e},yo=e=>{var n,o,r,i;if(e!==void 0&&!Be(e))throw re("Tu\u1EF3 ch\u1ECDn upload ph\u1EA3i l\xE0 object");let t=e!=null?e:{};if(t.source!==void 0&&(typeof t.source!="string"||!fo.test(t.source)))throw re("source ph\u1EA3i l\xE0 t\xEAn ngu\u1ED3n, vd library | camera | document");if(t.accept!==void 0&&(!Array.isArray(t.accept)||t.accept.length>50||t.accept.some(a=>typeof a!="string"||!ii.test(a))))throw re("accept ph\u1EA3i l\xE0 m\u1EA3ng mime (image/*, application/pdf) ho\u1EB7c \u0111u\xF4i (.docx)");if(t.max_count!==void 0&&!mt(t.max_count,1,yn))throw re(`max_count ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn 1\u2013${yn}`);if(t.max_size!==void 0&&!mt(t.max_size,1,Number.MAX_SAFE_INTEGER))throw re("max_size ph\u1EA3i l\xE0 s\u1ED1 byte > 0");if(t.concurrency!==void 0&&!mt(t.concurrency,1,5))throw re("concurrency ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn 1\u20135");return{source:(n=t.source)!=null?n:"library",accept:((o=t.accept)!=null?o:[]).map(a=>a.toLowerCase()),max_count:(r=t.max_count)!=null?r:1,max_size:t.max_size,process:ai(t.process),target:li(t.upload),concurrency:(i=t.concurrency)!=null?i:3}},ai=e=>{if(e===void 0)return{};if(!Be(e))throw re("process ph\u1EA3i l\xE0 object");let t={};if(e.image!==void 0){let n=e.image;if(!Be(n))throw re("process.image ph\u1EA3i l\xE0 object");for(let o of["max_width","max_height"])if(n[o]!==void 0&&!mt(n[o],1,1e4))throw re(`process.image.${o} ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn 1\u201310000`);if(n.quality!==void 0&&(typeof n.quality!="number"||n.quality<=0||n.quality>1))throw re("process.image.quality ph\u1EA3i trong kho\u1EA3ng (0, 1]");t.image={max_width:n.max_width,max_height:n.max_height,quality:n.quality}}if(e.video!==void 0){let n=e.video;if(!Be(n))throw re("process.video ph\u1EA3i l\xE0 object");if(n.max_duration!==void 0&&!mt(n.max_duration,1,3600))throw re("process.video.max_duration ph\u1EA3i l\xE0 s\u1ED1 gi\xE2y 1\u20133600");if(n.quality!==void 0&&!si.includes(n.quality))throw re("process.video.quality ph\u1EA3i l\xE0 low | medium | high");t.video={max_duration:n.max_duration,quality:n.quality}}return t},li=e=>{var n,o,r,i;if(e===void 0)return{target:"host",params:{}};if(!Be(e))throw re("upload ph\u1EA3i l\xE0 object");let t=(n=e.target)!=null?n:"host";if(typeof t!="string"||!fo.test(t))throw re("upload.target ph\u1EA3i l\xE0 t\xEAn \u0111\xEDch, vd host | url");if(t!=="url"){if(e.params!==void 0&&!Be(e.params))throw re("upload.params ph\u1EA3i l\xE0 object");return{target:t,params:(o=e.params)!=null?o:{}}}if(typeof e.url!="string"||!/^https:\/\//i.test(e.url))throw re("upload.url ph\u1EA3i l\xE0 https");for(let a of["field_name","url_field"])if(e[a]!==void 0&&(typeof e[a]!="string"||!e[a]))throw re(`upload.${a} ph\u1EA3i l\xE0 chu\u1ED7i`);return{target:"url",url:e.url,headers:po(e.headers,"upload.headers"),form_data:po(e.form_data,"upload.form_data"),field_name:(r=e.field_name)!=null?r:"file",url_field:(i=e.url_field)!=null?i:"url"}},bo=e=>{let t=e.lastIndexOf(".");return t>0?e.slice(t).toLowerCase():""},ci=(e,t)=>{if(!t.length)return!0;let n=e.mime_type.toLowerCase(),o=bo(e.name);return t.some(r=>r==="*/*"?!0:r.startsWith(".")?r===o:r.endsWith("/*")?n.startsWith(r.slice(0,-1)):n===r)},pi=e=>{let t=e.length>0&&e.every(o=>o.startsWith("image/")),n=e.length>0&&e.every(o=>o.startsWith("video/"));return t?"image":n?"video":"mixed"},dt,ui=()=>(dt!=null||(dt=import("react-native-image-picker").catch(e=>{throw dt=void 0,new m("NOT_SUPPORTED",`Ch\u01B0a c\xF3 module ch\u1ECDn \u1EA3nh trong b\u1EA3n native: ${e instanceof Error?e.message:String(e)}`)})),dt),uo=e=>async({accept:t,max_count:n,process:o})=>{var c,l,u,d,f,p,y,k,R;let r=await ui(),i=pi(t),a={mediaType:i==="image"?"photo":i,maxWidth:(c=o.image)==null?void 0:c.max_width,maxHeight:(l=o.image)==null?void 0:l.max_height,quality:(d=(u=o.image)==null?void 0:u.quality)!=null?d:.8,videoQuality:(p=(f=o.video)==null?void 0:f.quality)!=null?p:"medium",durationLimit:(y=o.video)==null?void 0:y.max_duration,assetRepresentationMode:"compatible"},s=e==="camera"?await r.launchCamera({...a,saveToPhotos:!1}):await r.launchImageLibrary({...a,selectionLimit:n});if(s.didCancel)return[];if(s.errorCode){let O=s.errorCode==="permission"?"PERMISSION_DENIED":s.errorCode==="camera_unavailable"?"NOT_SUPPORTED":"HOST_ERROR";throw new m(O,(k=s.errorMessage)!=null?k:s.errorCode)}return((R=s.assets)!=null?R:[]).filter(O=>O.uri).map((O,x)=>{var q,Y,ne;return{uri:O.uri,name:(q=O.fileName)!=null?q:`file_${x+1}`,mime_type:(Y=O.type)!=null?Y:"application/octet-stream",size:O.fileSize,width:O.width,height:O.height,duration:O.duration,processed:!((ne=O.type)!=null&&ne.startsWith("video/"))||bn.Platform.OS==="ios"}})},di={"image/*":"images","video/*":"video","audio/*":"audio","text/plain":"plainText","text/csv":"csv","application/pdf":"pdf","application/json":"json","application/zip":"zip","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx"},gi={".pdf":"pdf",".txt":"plainText",".csv":"csv",".json":"json",".zip":"zip",".doc":"doc",".docx":"docx",".xls":"xls",".xlsx":"xlsx",".ppt":"ppt",".pptx":"pptx"},hi=e=>async({accept:t,max_count:n})=>{var i,a,s,c;let o=t.map(l=>{var u;return(u=di[l])!=null?u:gi[l]}),r=!t.length||o.some(l=>!l||!e.types[l])?e.types.allFiles:[...new Set(o)].flatMap(l=>e.types[l]);try{let u=(await e.pick({type:r,allowMultiSelection:n>1,mode:"import"})).filter(p=>p.uri&&!p.error).map((p,y)=>{var k,R,O;return{uri:p.uri,name:(k=p.name)!=null?k:`file_${y+1}`,mime_type:(R=p.type)!=null?R:"application/octet-stream",size:(O=p.size)!=null?O:void 0}});if(bn.Platform.OS!=="android"||!e.keepLocalCopy||!u.some(p=>p.uri.startsWith("content://")))return u;let d=await e.keepLocalCopy({files:u.map(p=>({uri:p.uri,fileName:p.name})),destination:"cachesDirectory"}),f=new Map(d.map(p=>[p.sourceUri,p.status==="success"?p.localUri:void 0]));return u.map(p=>{var y;return{...p,uri:(y=f.get(p.uri))!=null?y:p.uri}})}catch(l){let u=l==null?void 0:l.code;if(u===((a=(i=e.errorCodes)==null?void 0:i.OPERATION_CANCELED)!=null?a:"OPERATION_CANCELED"))return[];throw u===((c=(s=e.errorCodes)==null?void 0:s.IN_PROGRESS)!=null?c:"ASYNC_OP_IN_PROGRESS")?new m("BUSY","\u0110ang m\u1EDF tr\xECnh ch\u1ECDn file kh\xE1c"):l}},gt,mi=async e=>(gt!=null||(gt=import("@react-native-documents/picker").then(t=>hi(t)).catch(t=>{throw gt=void 0,new m("NOT_SUPPORTED",`Ch\u01B0a c\xF3 module ch\u1ECDn file trong b\u1EA3n native: ${t instanceof Error?t.message:String(t)}`)})),(await gt)(e)),wo={library:uo("library"),camera:uo("camera"),document:mi},go={type:"image",label:"\u1EA2nh",accept:["image/*"]},ho={type:"video",label:"Video",accept:["video/*"]},mo={library:[go,ho],camera:[go,ho],document:[{type:"any",label:"M\u1ECDi file",accept:[]},{type:"pdf",label:"PDF",accept:["application/pdf"]},{type:"word",label:"Word",accept:[".doc",".docx"]},{type:"excel",label:"Excel",accept:[".xls",".xlsx"]},{type:"powerpoint",label:"PowerPoint",accept:[".ppt",".pptx"]}]},ht,_o=()=>(ht!=null||(ht=import("react-native-compressor").catch(()=>(ht=void 0,null))),ht),Ao=async(e,t,n)=>{try{return Number(await e.getFileSize(t))||n}catch{return n}},fi=new Set(["image/jpeg","image/jpg","image/heic","image/heif","image/webp"]),yi={low:640,medium:1280,high:1920},bi=async(e,{image:t})=>{var o;if(!t||!fi.has(e.mime_type.toLowerCase()))return e;let n=await _o();if(!n)return e;try{let r=await n.Image.compress(e.uri,{compressionMethod:"manual",maxWidth:t.max_width,maxHeight:t.max_height,quality:(o=t.quality)!=null?o:.8,output:"jpg"});return{...e,uri:r,mime_type:"image/jpeg",name:e.name.replace(/\.[^.]+$/,"")+".jpg",size:await Ao(n,r,e.size),processed:!0}}catch{return e}},wi=async(e,{video:t})=>{var o;let n=await _o();if(!n)return e;try{let r=await n.Video.compress(e.uri,{compressionMethod:"auto",maxSize:yi[(o=t==null?void 0:t.quality)!=null?o:"medium"],minimumFileSizeForCompress:2});return{...e,uri:r,mime_type:"video/mp4",size:await Ao(n,r,e.size),processed:!0}}catch{return e}},_i={image:bi,video:wi},Ai=(e,t)=>t.split(".").reduce((n,o)=>Be(n)?n[o]:void 0,e),wn=({file:e,target:t,onProgress:n,signal:o})=>new Promise((r,i)=>{if(t.target!=="url"||!("url"in t)){i(new m("INVALID_PARAMS","Thi\u1EBFu upload.url"));return}let a=t;if(o.aborted){i(new m("CANCELLED","\u0110\xE3 hu\u1EF7 upload"));return}let s=new XMLHttpRequest,c=new FormData;Object.entries(a.form_data).forEach(([d,f])=>c.append(d,f)),c.append(a.field_name,{uri:e.uri,name:e.name,type:e.mime_type});let l=()=>s.abort();o.addEventListener("abort",l);let u=d=>{o.removeEventListener("abort",l),d()};s.open("POST",a.url),Object.entries(a.headers).forEach(([d,f])=>s.setRequestHeader(d,f)),s.upload.onprogress=d=>n(d.loaded,d.total||e.size||0),s.onload=()=>u(()=>{let d=s.responseText;try{d=JSON.parse(s.responseText)}catch{}if(s.status<200||s.status>=300){i(new m("UPLOAD_FAILED",`HTTP ${s.status}`));return}let f=Ai(d,a.url_field);if(typeof f!="string"||!f){i(new m("UPLOAD_FAILED",`Response kh\xF4ng c\xF3 "${a.url_field}"`));return}r({url:f,response:d})}),s.onerror=()=>u(()=>i(new m("UPLOAD_FAILED","L\u1ED7i m\u1EA1ng khi upload"))),s.onabort=()=>u(()=>i(new m("CANCELLED","\u0110\xE3 hu\u1EF7 upload"))),s.send(c)}),So=e=>{var o,r;let t={...wo};for(let[i,a]of Object.entries((o=e==null?void 0:e.sources)!=null?o:{}))a?t[i]=a:delete t[i];let n={url:wn};for(let[i,a]of Object.entries((r=e==null?void 0:e.targets)!=null?r:{}))i!=="url"&&a&&(n[i]=a);return{sources:t,targets:n}},Mo=e=>{let{sources:t,targets:n}=So(e),o=Object.keys(t),r=Object.fromEntries(o.filter(i=>t[i]===wo[i]&&mo[i]).map(i=>[i,mo[i]]));return{sources:o,file_types:r,targets:Object.keys(n),max_count:yn}},Lt=new Map,vo=(e,t)=>`${e}:${t}`,Si=0,xo=(e,t)=>{var n;typeof t=="string"&&((n=Lt.get(vo(e,t)))==null||n.abort())},Je=e=>{for(let[t,n]of Lt)t.startsWith(`${e}:`)&&n.abort()},It=()=>new m("CANCELLED","\u0110\xE3 hu\u1EF7 upload"),Mi=(e,t)=>{var n;return{name:e,code:typeof(t==null?void 0:t.code)=="string"?t.code:"UPLOAD_FAILED",message:String((n=t==null?void 0:t.message)!=null?n:t)}},Co=async(e,t)=>{var c;let{sources:n,targets:o}=So(t.config),r=n[e.source];if(!r)throw new m("NOT_SUPPORTED",`\u1EE8ng d\u1EE5ng ch\u01B0a h\u1ED7 tr\u1EE3 ngu\u1ED3n "${e.source}"`);let i=o[e.target.target];if(!i)throw new m("NOT_SUPPORTED",`\u1EE8ng d\u1EE5ng ch\u01B0a h\u1ED7 tr\u1EE3 \u0111\xEDch upload "${e.target.target}"`);let a=new AbortController,s=vo(t.instance_id,(c=t.task_id)!=null?c:`auto-${++Si}`);Lt.set(s,a);try{return await vi(e,t,r,i,a.signal)}finally{Lt.delete(s)}},vi=async(e,{instance_id:t,app_id:n,getContext:o,task_id:r,config:i,emit:a,exclusivePick:s=d=>d()},c,l,u)=>{var P,w,I;let d={app_id:n!=null?n:"",instance_id:t,context:{...(P=o==null?void 0:o())!=null?P:{}}},f=(await s(()=>c({accept:e.accept,max_count:e.max_count,process:e.process,caller:d}))).slice(0,e.max_count);if(u.aborted)throw It();if(!f.length)throw new m("CANCELLED","Ng\u01B0\u1EDDi d\xF9ng kh\xF4ng ch\u1ECDn file");let p=[],y=f.filter(E=>ci(E,e.accept)?!0:(p.push({name:E.name,code:"INVALID_FILE",message:`Kh\xF4ng cho ph\xE9p \u0111\u1ECBnh d\u1EA1ng ${E.mime_type||bo(E.name)}`}),!1)),k=y.map(()=>0),R=y.map(E=>{var $;return($=E.size)!=null?$:0}),O=0,x=0,q=(E=!1)=>{if(!a||!r)return;let $=Date.now();if(!E&&$-x<200)return;x=$;let Ce=R.reduce((V,ue)=>V+ue,0),oe=k.reduce((V,ue)=>V+ue,0);a("upload.progress",{task_id:r,loaded:oe,total:Ce,percent:Ce?Math.min(100,Math.round(oe/Ce*100)):0,done_count:O,count:y.length})},Y=[],ne=0,we=async()=>{var E,$,Ce;for(;ne<y.length;){let oe=ne++,V=y[oe];try{if(u.aborted)throw It();let ue=V.mime_type.startsWith("image/")?"image":V.mime_type.startsWith("video/")?"video":void 0,ee=ue&&!V.processed?($=(E=i==null?void 0:i.processors)==null?void 0:E[ue])!=null?$:_i[ue]:void 0;if(ee&&(V=await ee(V,e.process),R[oe]=(Ce=V.size)!=null?Ce:R[oe],u.aborted))throw It();if(e.max_size&&V.size&&V.size>e.max_size)throw new m("FILE_TOO_LARGE",`File ${V.size} byte v\u01B0\u1EE3t gi\u1EDBi h\u1EA1n ${e.max_size}`);let ae=(Qe,Re)=>{k[oe]=Qe,Re&&(R[oe]=Re),q()},de=await l({file:V,target:e.target,onProgress:ae,signal:u,caller:d});if(typeof(de==null?void 0:de.url)!="string"||!de.url)throw new m("UPLOAD_FAILED","Upload kh\xF4ng tr\u1EA3 url");let{url:Ee,...ke}=de;Y[oe]={url:Ee,name:V.name,mime_type:V.mime_type,size:V.size,width:V.width,height:V.height,duration:V.duration,...Object.keys(ke).length?{response:"response"in ke?ke.response:ke}:{}},k[oe]=R[oe]}catch(ue){p.push(Mi(y[oe].name,ue))}finally{O++,q(!0)}}};if(await Promise.all(Array.from({length:Math.min(e.concurrency,y.length)},we)),u.aborted)throw It();let H=Y.filter(E=>!!E);if(!H.length){let E=p[0];throw new m((w=E==null?void 0:E.code)!=null?w:"UPLOAD_FAILED",(I=E==null?void 0:E.message)!=null?I:"Kh\xF4ng upload \u0111\u01B0\u1EE3c file n\xE0o")}return{files:H,failed:p}};var Dt=require("react"),Fe=e=>{let t=e,n=new Set;return{getState:()=>t,setState:o=>{let r=typeof o=="function"?o(t):o;t={...t,...r},n.forEach(i=>i())},subscribe:o=>(n.add(o),()=>{n.delete(o)})}},J=(e,t,n=Object.is)=>{let o=(0,Dt.useRef)(null),r=()=>{let i=e.getState(),a=o.current;if(a&&a.state===i&&a.selector===t)return a.value;let s=t(i),c=a&&n(a.value,s)?a.value:s;return o.current={state:i,selector:t,value:c},c};return(0,Dt.useSyncExternalStore)(e.subscribe,r)};var Ae={info:"info",success:"success",error:"error"},xi=200,To={info:2e3,success:2e3,error:3e3},ft=Fe({message:"",type:Ae.info,tick:0}),Po=e=>{let{message:t,type:n}=e!=null?e:{},o=String(t!=null?t:"").trim().slice(0,xi);return o?{message:o,type:Object.values(Ae).includes(n)?n:Ae.info}:null},Eo=(e,t=Ae.info)=>{ft.setState(n=>({message:e,type:t,tick:n.tick+1}))};var Me=require("react-native");var Ke=require("react-native");var Se,et=new Map,ko=(e,t)=>{var o;let n=(o=et.get(e))!=null?o:new Set;n.add(t),et.set(e,n)},Ro=(e,t)=>{let n=et.get(e);n&&(t?n.delete(t):n.clear(),n.size===0&&et.delete(e))},An=new Map,Oo=(e,t)=>{An.set(e,t)},Fo=e=>An.get(e),Io=()=>Ke.Platform.OS==="android"&&!!(Se!=null&&Se.requesting_permission),Ci=1500,Ut=()=>new Promise(e=>{if(Ke.Platform.OS!=="android"||Ke.AppState.currentState==="active"){e();return}let t=()=>{clearTimeout(n),o.remove(),e()},n=setTimeout(t,Ci),o=Ke.AppState.addEventListener("change",r=>{r==="active"&&t()})}),_n=e=>{var t;if(Se===e&&(Se=void 0,e.subscriptions.forEach(n=>n.remove()),e.started&&Ke.Platform.OS==="ios"))try{(t=e.native)==null||t.setAudioSessionActiveIOS(!1,{notifyOthersOnDeactivation:!0})}catch{}},Lo=async(e,t,n,o=()=>!0)=>{var i,a,s,c,l;if(Se)throw new m("BUSY","Micro \u0111ang \u0111\u01B0\u1EE3c mini app kh\xE1c s\u1EED d\u1EE5ng");if(!o())throw new m("CANCELLED","Mini app kh\xF4ng c\xF2n ho\u1EA1t \u0111\u1ED9ng");let r={owner:e,emit:n,cancelled:!1,started:!1,subscriptions:[]};Se=r;try{let u;try{u=await import("expo-speech-recognition")}catch{throw new m("NOT_SUPPORTED","Ch\u01B0a c\xF3 module nh\u1EADn d\u1EA1ng gi\u1ECDng n\xF3i trong b\u1EA3n native")}let d=u.ExpoSpeechRecognitionModule;if(r.native=d,r.cancelled||!o())throw new m("CANCELLED","Mini app \u0111\xE3 \u0111\xF3ng");r.requesting_permission=!0;let f;try{f=await d.requestPermissionsAsync()}finally{r.requesting_permission=!1}if(await Ut(),r.cancelled||!o())throw new m("CANCELLED","Mini app \u0111\xE3 \u0111\xF3ng");if(!f.granted)throw new m("PERMISSION_DENIED","Ch\u01B0a c\u1EA5p quy\u1EC1n micro / nh\u1EADn d\u1EA1ng gi\u1ECDng n\xF3i");if(await d.getStateAsync()!=="inactive")throw new m("BUSY","Nh\u1EADn d\u1EA1ng gi\u1ECDng n\xF3i \u0111ang \u0111\u01B0\u1EE3c t\xEDnh n\u0103ng kh\xE1c s\u1EED d\u1EE5ng");if(r.cancelled||!o())throw new m("CANCELLED","Mini app \u0111\xE3 \u0111\xF3ng");r.subscriptions.push(d.addListener("result",p=>{var y,k;Se!==r||r.cancelled||n(p.isFinal?"speech.final":"speech.partial",{...p,text:(k=(y=p.results[0])==null?void 0:y.transcript)!=null?k:""})}),d.addListener("error",p=>{Se===r&&!r.cancelled&&n("speech.error",{...p,code:p.error})}),d.addListener("end",()=>{Se===r&&(_n(r),n("speech.end"))})),r.started=!0,d.start({lang:(i=t.lang)!=null?i:"vi-VN",continuous:(a=t.continuous)!=null?a:!0,interimResults:(s=t.interimResults)!=null?s:!0,addsPunctuation:(c=t.addsPunctuation)!=null?c:!0,requiresOnDeviceRecognition:(l=t.requiresOnDeviceRecognition)!=null?l:!1,iosCategory:{category:u.AVAudioSessionCategory.playAndRecord,categoryOptions:[u.AVAudioSessionCategoryOptions.defaultToSpeaker,u.AVAudioSessionCategoryOptions.allowBluetooth],mode:u.AVAudioSessionMode.measurement}})}catch(u){throw _n(r),u}},Do=e=>{let t=Se;if(!(!t||t.owner!==e)){if(!t.started){t.cancelled=!0;return}t.native.stop()}},Ie=e=>{An.delete(e);let t=et.get(e);et.delete(e),t==null||t.forEach(o=>{var r;try{(r=o.release)==null||r.call(o,e)}catch{}});let n=Se;if(!(!n||n.owner!==e||n.cancelled)&&(n.cancelled=!0,n.started))try{n.native.abort()}catch{_n(n)}};var Uo={qr:"qr",ean13:"ean-13",ean8:"ean-8",upcA:"upc-a",upcE:"upc-e",code128:"code-128",code39:"code-39",code93:"code-93",codabar:"codabar",itf:"itf",pdf417:"pdf-417",aztec:"aztec",dataMatrix:"data-matrix"},le={...Uo,all:Object.values(Uo)},tt={scan:"scanner.scan",start:"scanner.start",stop:"scanner.stop"},Vt={result:"scanner.result",end:"scanner.end"},Ye={user:"user",web:"web",closed:"closed",error:"error"},ye={top:"top",full:"full"},qe={once:"once",continuous:"continuous"},Ti=1500,No=6e4,K,ie=Fe({active:null,last_value:null,hit_tick:0,scan_count:0,notice:null,is_picking:!1}),Bo=()=>Me.Platform.OS==="android"&&!!(K!=null&&K.requesting_permission),Mn=e=>{let{types:t,cooldown_ms:n,hint:o,layout:r,absolute:i}=e!=null?e:{},a={};if(t!==void 0){if(!Array.isArray(t)||!t.length||!t.every(s=>le.all.includes(s)))throw new m("INVALID_PARAMS","types ph\u1EA3i l\xE0 m\u1EA3ng CodeType");a.types=t}if(n!==void 0){if(typeof n!="number"||!Number.isFinite(n)||n<0||n>No)throw new m("INVALID_PARAMS",`cooldown_ms ph\u1EA3i t\u1EEB 0 \u0111\u1EBFn ${No}`);a.cooldown_ms=n}if(o!==void 0){if(typeof o!="string"||!o.trim()||o.length>80)throw new m("INVALID_PARAMS","hint ph\u1EA3i c\xF3 1\u201380 k\xFD t\u1EF1");a.hint=o}if(r!==void 0){if(!Object.values(ye).includes(r))throw new m("INVALID_PARAMS","layout ph\u1EA3i l\xE0 ScannerLayout");a.layout=r}if(i!==void 0){if(typeof i!="boolean")throw new m("INVALID_PARAMS","absolute ph\u1EA3i l\xE0 boolean");a.absolute=i}return a},vn=e=>K!==e?!1:(K=void 0,ie.setState({active:null,last_value:null,scan_count:0,notice:null,is_picking:!1}),!0),Pi=()=>Me.Alert.alert("Ch\u01B0a c\u1EA5p quy\u1EC1n camera","H\xE3y b\u1EADt quy\u1EC1n camera trong C\xE0i \u0111\u1EB7t \u0111\u1EC3 qu\xE9t m\xE3.",[{text:"Hu\u1EF7",style:"cancel"},{text:"M\u1EDF C\xE0i \u0111\u1EB7t",onPress:()=>{Me.Linking.openSettings().catch(()=>{})}}]),qo=async(e,t)=>{if(K)throw new m("BUSY","Camera qu\xE9t m\xE3 \u0111ang \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng");if(!t())throw new m("CANCELLED","Mini app kh\xF4ng c\xF2n ho\u1EA1t \u0111\u1ED9ng");K=e;let n=()=>{if(e.cancelled||!t())throw new m("CANCELLED","Mini app \u0111\xE3 \u0111\xF3ng")};try{let o;try{o=await import("react-native-vision-camera")}catch{throw new m("NOT_SUPPORTED","Ch\u01B0a c\xF3 module camera trong b\u1EA3n native")}n();let r=o.Camera.getCameraPermissionStatus();if(r!=="granted"){let a=Me.Platform.OS==="ios"&&r==="denied";e.requesting_permission=!0;let s;try{s=await o.Camera.requestCameraPermission()}finally{e.requesting_permission=!1}if(await Ut(),n(),s!=="granted")throw a&&Pi(),new m("PERMISSION_DENIED","Ch\u01B0a c\u1EA5p quy\u1EC1n camera")}if(!o.Camera.getAvailableCameraDevices().some(a=>a.position==="back"))throw new m("NOT_SUPPORTED","Thi\u1EBFt b\u1ECB kh\xF4ng c\xF3 camera sau");let i=await yt();n(),ie.setState({active:{owner:e.owner,mode:e.mode,types:e.types,layout:e.layout,absolute:e.absolute,hint:e.hint,vision:o,glass_view:i},last_value:null,scan_count:0,notice:null})}catch(o){throw vn(e),o}},Nt;import("react-native-safe-area-context").then(({initialWindowMetrics:e})=>{Nt=e==null?void 0:e.insets}).catch(()=>{});var nt=()=>{var e;return Nt!=null?Nt:{top:Me.Platform.OS==="ios"?54:(e=Me.StatusBar.currentHeight)!=null?e:0,bottom:Me.Platform.OS==="ios"?34:48}},yt=async()=>{if(Me.Platform.OS==="ios")try{let e=await import("expo-glass-effect");return e.isLiquidGlassAvailable()?e.GlassView:void 0}catch{return}},Ho=(e,t,n)=>{var o,r,i,a;return{owner:e,mode:t,types:(o=n.types)!=null?o:le.all,cooldown_ms:(r=n.cooldown_ms)!=null?r:Ti,hint:n.hint,layout:t===qe.once?ye.full:(i=n.layout)!=null?i:ye.top,absolute:t!==qe.once&&((a=n.layout)!=null?a:ye.top)===ye.top&&n.absolute===!0,cancelled:!1,requesting_permission:!1,last_seen:new Map}},zo=(e,t,n=()=>!0,o)=>new Promise((r,i)=>{let a=Ho(e,qe.once,t);a.onHit=o,a.resolve=r,a.reject=i,qo(a,n).catch(i)}),$o=(e,t,n,o=()=>!0,r)=>{let i=Ho(e,qe.continuous,t);return i.emit=n,i.onHit=r,qo(i,o)},Bt=(e,t,n)=>{var o,r;if(!ie.getState().active){e.cancelled=!0;return}if(vn(e)){if(e.mode===qe.once){(o=e.reject)==null||o.call(e,t===Ye.error?new m("HOST_ERROR",n!=null?n:"L\u1ED7i camera"):new m("CANCELLED","\u0110\xE3 \u0111\xF3ng camera qu\xE9t m\xE3"));return}(r=e.emit)==null||r.call(e,Vt.end,n?{reason:t,message:n}:{reason:t})}},Wo=e=>{(K==null?void 0:K.owner)===e&&Bt(K,Ye.web)},He=e=>{(K==null?void 0:K.owner)===e&&Bt(K,Ye.closed)},xn=()=>{K&&Bt(K,Ye.user)},jo=e=>{K&&Bt(K,Ye.error,e)},Cn=(e,t=Date.now(),n=!1)=>{var r,i,a;let o=K;if(!(!o||!ie.getState().active))for(let{value:s,type:c}of e){if(!s)continue;let l=o.last_seen.get(s);if(o.last_seen.set(s,t),!(!n&&l!==void 0&&t-l<o.cooldown_ms)){if((r=o.onHit)==null||r.call(o),o.mode===qe.once){vn(o),(i=o.resolve)==null||i.call(o,{value:s,type:c});return}ie.setState(u=>({last_value:s,hit_tick:u.hit_tick+1,scan_count:u.scan_count+1,notice:null})),(a=o.emit)==null||a.call(o,Vt.result,{value:s,type:c})}}},Ei={1:le.code128,2:le.code39,4:le.code93,8:le.codabar,16:le.dataMatrix,32:le.ean13,64:le.ean8,128:le.itf,256:le.qr,512:le.upcA,1024:le.upcE,2048:le.pdf417,4096:le.aztec},ki=2500,Vo=2e3,Sn=e=>{ie.setState({notice:e}),setTimeout(()=>{ie.getState().notice===e&&ie.setState({notice:null})},ki)},Go=async()=>{var t,n;let e=K;if(!(!e||ie.getState().is_picking)){e.requesting_permission=!0,ie.setState({is_picking:!0,notice:null});try{let{launchImageLibrary:o}=await import("react-native-image-picker"),r=await o({mediaType:"photo",selectionLimit:1,maxWidth:Vo,maxHeight:Vo}),i=(n=(t=r.assets)==null?void 0:t[0])==null?void 0:n.uri;if(r.didCancel||K!==e)return;if(r.errorCode||!i){Sn("Kh\xF4ng m\u1EDF \u0111\u01B0\u1EE3c \u1EA3nh");return}let{default:a}=await import("@react-native-ml-kit/barcode-scanning"),s=await a.scan(i);if(K!==e)return;let c=s.map(({value:l,format:u})=>({value:l,code_type:Ei[u]})).filter(({code_type:l})=>!l||e.types.includes(l)).map(({value:l,code_type:u})=>({value:l,type:u!=null?u:"unknown"}));if(!c.length){Sn("Kh\xF4ng t\xECm th\u1EA5y m\xE3 trong \u1EA3nh");return}Cn(c,Date.now(),!0)}catch{K===e&&Sn("Kh\xF4ng \u0111\u1ECDc \u0111\u01B0\u1EE3c m\xE3 t\u1EEB \u1EA3nh")}finally{await Ut(),e.requesting_permission=!1,K===e&&ie.setState({is_picking:!1})}}};var Ht=1,m=class extends Error{constructor(n,o){super(o);this.code=n}},Jo=e=>{try{let t=JSON.parse(e);return(t==null?void 0:t.__retion)===Ht&&typeof t.method=="string"?t:null}catch{return null}},_t=e=>`window.__RETION_MINIAPP__ && window.__RETION_MINIAPP__.receive(${JSON.stringify(e)}); true;`,Ko=(e,t)=>_t({id:e,result:t}),Yo=(e,t)=>_t({id:e,error:{code:t.code,message:t.message}}),Xo=(e,t)=>_t({event:e,data:t}),Pn=e=>_t({event:"context",data:e});var Qo=()=>`(function () {
|
|
1
|
+
"use strict";var pi=Object.create;var Jt=Object.defineProperty;var ui=Object.getOwnPropertyDescriptor;var di=Object.getOwnPropertyNames;var gi=Object.getPrototypeOf,hi=Object.prototype.hasOwnProperty;var mi=(e,t)=>{for(var n in t)Jt(e,n,{get:t[n],enumerable:!0})},mo=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of di(t))!hi.call(e,r)&&r!==n&&Jt(e,r,{get:()=>t[r],enumerable:!(o=ui(t,r))||o.enumerable});return e};var ye=(e,t,n)=>(n=e!=null?pi(gi(e)):{},mo(t||!e||!e.__esModule?Jt(n,"default",{value:e,enumerable:!0}):n,e)),fi=e=>mo(Jt({},"__esModule",{value:!0}),e);var Rs={};mi(Rs,{CodeType:()=>ce,DEFAULT_MINIAPP_UPDATES_LABELS:()=>xn,DefaultMiniAppChangelogPrompt:()=>zt,DefaultMiniAppSplash:()=>lo,DefaultMiniAppUpdatePrompt:()=>$t,MINIAPP_CHANGELOG_KINDS:()=>Tn,MINIAPP_PLATFORM_URL:()=>at,MiniAppChangelogGroups:()=>rt,MiniAppChangelogHistory:()=>qt,MiniAppChangelogText:()=>Pn,MiniAppHost:()=>ei,MiniAppHostError:()=>g,MiniAppUpdates:()=>ci,MiniAppUpdatesThemeProvider:()=>bt,ScannerEndReason:()=>nt,ScannerEvent:()=>nn,ScannerLayout:()=>_e,ScannerMethod:()=>ct,ToastType:()=>ve,closeMiniApp:()=>gt,configureMiniApp:()=>yo,createMmkvStorage:()=>wo,createReactNativeBiometrics:()=>In,createRnfsFileSystem:()=>bo,dismissMiniAppChangelog:()=>Mn,ensureMiniApp:()=>Ut,fetchMiniAppChangelog:()=>An,getLocalMiniApp:()=>W,getMiniAppCatalog:()=>Yr,getMiniAppCatalogEntry:()=>mt,getMiniAppChangelogSeen:()=>_n,getMiniAppStatuses:()=>qr,getMiniAppUpdate:()=>so,getPendingChangelog:()=>po,installBundledMiniApp:()=>xr,markMiniAppChangelogSeen:()=>ft,mergeMiniAppChangelog:()=>Ht,onMiniAppEvent:()=>mn,openMiniApp:()=>Dr,parseInlineMarkdown:()=>Vt,pauseMiniApp:()=>jr,pauseMiniAppDownloads:()=>Jr,preloadMiniApp:()=>Ur,releaseSpeechFor:()=>Ne,resolveMiniAppUpdatesTheme:()=>Bt,restoreMiniApp:()=>Wr,resumeMiniApp:()=>Gr,resumeMiniAppDownloads:()=>Kr,sendEventToWeb:()=>Pr,showMiniAppChangelog:()=>wn,stripInlineMarkdown:()=>oi,syncMiniAppCatalog:()=>yn,uninstallMiniApp:()=>$r,updateMiniApp:()=>bn,uploadToUrl:()=>Un,useMiniAppChangelog:()=>Sn,useMiniAppChangelogRequest:()=>vn,useMiniAppDownload:()=>ht,useMiniAppDownloadsPaused:()=>Hr,useMiniAppUpdatesTheme:()=>Ee});module.exports=fi(Rs);var at="https://retion-miniapp-platform.vercel.app",Ze=null,fo=new Set,yo=e=>{Ze=e,fo.forEach(t=>t())},D=()=>{if(!Ze)throw new Error("[miniapp] Ch\u01B0a g\u1ECDi configureMiniApp()");return Ze},Kt=e=>{fo.add(e),Ze&&e()},we=(...e)=>{Ze!=null&&Ze.debug&&console.log("[miniapp]",...e)};var bo=(e,t)=>({document_dir:e.DocumentDirectoryPath,cache_dir:e.CachesDirectoryPath,exists:n=>e.exists(n),mkdir:n=>e.mkdir(n),remove:n=>e.unlink(n).catch(()=>{}),listDir:n=>e.readDir(n).then(o=>o.map(r=>r.name)).catch(()=>[]),sha256:n=>e.hash(n,"sha256"),unzip:async(n,o)=>{await t(n,o)},download:({url:n,to_file:o,onProgress:r})=>{let{jobId:i,promise:l}=e.downloadFile({fromUrl:n,toFile:o,progressInterval:250,begin:()=>{},progress:({bytesWritten:s,contentLength:c})=>r==null?void 0:r(s,c)});return{promise:l.then(({statusCode:s})=>({status:s})),cancel:()=>e.stopDownload(i)}}}),wo=e=>({getString:t=>e.getString(t),setString:(t,n)=>e.set(t,n)});var S=ye(require("react")),V=require("react-native"),Zr=ye(require("react-native-webview"));var kt=require("react-native");var In=e=>({getAvailability:()=>e.isSensorAvailable(),authenticate:({reason:t,cancelButtonText:n})=>e.simplePrompt({promptMessage:t,cancelButtonText:n,fallbackPromptMessage:""})}),Yt,Fn=()=>(Yt||(Yt=import("react-native-biometrics").then(({default:e})=>In(new e({allowDeviceCredentials:!1}))).catch(e=>{throw Yt=void 0,new g("NOT_SUPPORTED",`Biometric native module unavailable: ${e instanceof Error?e.message:String(e)}`)})),Yt);var De=require("react-native");var _o=e=>{var n,o,r;if(e!==void 0&&(e===null||typeof e!="object"||Array.isArray(e)))throw new g("INVALID_PARAMS","Tu\u1EF3 ch\u1ECDn v\u1ECB tr\xED ph\u1EA3i l\xE0 object");let t=e!=null?e:{};if(t.enableHighAccuracy!==void 0&&typeof t.enableHighAccuracy!="boolean")throw new g("INVALID_PARAMS","enableHighAccuracy ph\u1EA3i l\xE0 boolean");for(let[i,l,s]of[["timeout",1,6e4],["maximumAge",0,864e5]]){let c=t[i];if(c!==void 0&&(typeof c!="number"||!Number.isFinite(c)||c<l||c>s))throw new g("INVALID_PARAMS",`${i} ph\u1EA3i n\u1EB1m trong kho\u1EA3ng ${l}\u2013${s} ms`)}return{enableHighAccuracy:(n=t.enableHighAccuracy)!=null?n:!1,timeout:(o=t.timeout)!=null?o:15e3,maximumAge:(r=t.maximumAge)!=null?r:0}},Ao=(e,t=()=>!0)=>new Promise((n,o)=>{let r=!1,i=(c,a)=>{r||(r=!0,clearTimeout(l),c?o(c):n(a))},l=setTimeout(()=>i(new g("TIMEOUT","H\u1EBFt th\u1EDDi gian ch\u1EDD c\u1EA5p quy\u1EC1n/l\u1EA5y v\u1ECB tr\xED")),12e4+e.timeout),s=()=>r?!1:t()?!0:(i(new g("CANCELLED","Mini app kh\xF4ng c\xF2n ho\u1EA1t \u0111\u1ED9ng")),!1);(async()=>{if(!s())return;let c;try{c=(await import("@react-native-community/geolocation")).default}catch{throw new g("NOT_SUPPORTED","Ch\u01B0a c\xF3 module v\u1ECB tr\xED trong b\u1EA3n native")}if(s()){if(De.Platform.OS==="android"){let a=De.PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,u=De.PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,d=await De.PermissionsAndroid.check(a);if(!s())return;let h=d||await De.PermissionsAndroid.check(u);if(!s())return;if(!d&&!h){let p=await De.PermissionsAndroid.requestMultiple([a,u]);if(!s())return;if(p[a]!==De.PermissionsAndroid.RESULTS.GRANTED&&p[u]!==De.PermissionsAndroid.RESULTS.GRANTED)throw new g("PERMISSION_DENIED","Ch\u01B0a c\u1EA5p quy\u1EC1n truy c\u1EADp v\u1ECB tr\xED")}}s()&&c.getCurrentPosition(a=>{s()&&i(void 0,a)},a=>{var d;if(!s())return;let u=(d={1:"PERMISSION_DENIED",2:"POSITION_UNAVAILABLE",3:"TIMEOUT"}[a.code])!=null?d:"LOCATION_ERROR";i(new g(u,a.message))},e)}})().catch(c=>i(c))});var Dn=require("react-native");var Ln=20,So=20,Po=/^[a-z][a-z0-9_-]{0,31}$/,yi=/^(\.[\w-]{1,16}|[\w.+-]+\/(\*|[\w.+-]+))$/,bi=["low","medium","high"],je=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ie=e=>new g("INVALID_PARAMS",e),Ct=(e,t,n)=>typeof e=="number"&&Number.isInteger(e)&&e>=t&&e<=n,Mo=(e,t)=>{if(e===void 0)return{};if(!je(e)||Object.keys(e).length>So||Object.values(e).some(n=>typeof n!="string"))throw ie(`${t} ph\u1EA3i l\xE0 object chu\u1ED7i (t\u1ED1i \u0111a ${So} key)`);return e},Eo=e=>{var n,o,r,i;if(e!==void 0&&!je(e))throw ie("Tu\u1EF3 ch\u1ECDn upload ph\u1EA3i l\xE0 object");let t=e!=null?e:{};if(t.source!==void 0&&(typeof t.source!="string"||!Po.test(t.source)))throw ie("source ph\u1EA3i l\xE0 t\xEAn ngu\u1ED3n, vd library | camera | document");if(t.accept!==void 0&&(!Array.isArray(t.accept)||t.accept.length>50||t.accept.some(l=>typeof l!="string"||!yi.test(l))))throw ie("accept ph\u1EA3i l\xE0 m\u1EA3ng mime (image/*, application/pdf) ho\u1EB7c \u0111u\xF4i (.docx)");if(t.max_count!==void 0&&!Ct(t.max_count,1,Ln))throw ie(`max_count ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn 1\u2013${Ln}`);if(t.max_size!==void 0&&!Ct(t.max_size,1,Number.MAX_SAFE_INTEGER))throw ie("max_size ph\u1EA3i l\xE0 s\u1ED1 byte > 0");if(t.concurrency!==void 0&&!Ct(t.concurrency,1,5))throw ie("concurrency ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn 1\u20135");return{source:(n=t.source)!=null?n:"library",accept:((o=t.accept)!=null?o:[]).map(l=>l.toLowerCase()),max_count:(r=t.max_count)!=null?r:1,max_size:t.max_size,process:wi(t.process),target:_i(t.upload),concurrency:(i=t.concurrency)!=null?i:3}},wi=e=>{if(e===void 0)return{};if(!je(e))throw ie("process ph\u1EA3i l\xE0 object");let t={};if(e.image!==void 0){let n=e.image;if(!je(n))throw ie("process.image ph\u1EA3i l\xE0 object");for(let o of["max_width","max_height"])if(n[o]!==void 0&&!Ct(n[o],1,1e4))throw ie(`process.image.${o} ph\u1EA3i l\xE0 s\u1ED1 nguy\xEAn 1\u201310000`);if(n.quality!==void 0&&(typeof n.quality!="number"||n.quality<=0||n.quality>1))throw ie("process.image.quality ph\u1EA3i trong kho\u1EA3ng (0, 1]");t.image={max_width:n.max_width,max_height:n.max_height,quality:n.quality}}if(e.video!==void 0){let n=e.video;if(!je(n))throw ie("process.video ph\u1EA3i l\xE0 object");if(n.max_duration!==void 0&&!Ct(n.max_duration,1,3600))throw ie("process.video.max_duration ph\u1EA3i l\xE0 s\u1ED1 gi\xE2y 1\u20133600");if(n.quality!==void 0&&!bi.includes(n.quality))throw ie("process.video.quality ph\u1EA3i l\xE0 low | medium | high");t.video={max_duration:n.max_duration,quality:n.quality}}return t},_i=e=>{var n,o,r,i;if(e===void 0)return{target:"host",params:{}};if(!je(e))throw ie("upload ph\u1EA3i l\xE0 object");let t=(n=e.target)!=null?n:"host";if(typeof t!="string"||!Po.test(t))throw ie("upload.target ph\u1EA3i l\xE0 t\xEAn \u0111\xEDch, vd host | url");if(t!=="url"){if(e.params!==void 0&&!je(e.params))throw ie("upload.params ph\u1EA3i l\xE0 object");return{target:t,params:(o=e.params)!=null?o:{}}}if(typeof e.url!="string"||!/^https:\/\//i.test(e.url))throw ie("upload.url ph\u1EA3i l\xE0 https");for(let l of["field_name","url_field"])if(e[l]!==void 0&&(typeof e[l]!="string"||!e[l]))throw ie(`upload.${l} ph\u1EA3i l\xE0 chu\u1ED7i`);return{target:"url",url:e.url,headers:Mo(e.headers,"upload.headers"),form_data:Mo(e.form_data,"upload.form_data"),field_name:(r=e.field_name)!=null?r:"file",url_field:(i=e.url_field)!=null?i:"url"}},ko=e=>{let t=e.lastIndexOf(".");return t>0?e.slice(t).toLowerCase():""},Ai=(e,t)=>{if(!t.length)return!0;let n=e.mime_type.toLowerCase(),o=ko(e.name);return t.some(r=>r==="*/*"?!0:r.startsWith(".")?r===o:r.endsWith("/*")?n.startsWith(r.slice(0,-1)):n===r)},Si=e=>{let t=e.length>0&&e.every(o=>o.startsWith("image/")),n=e.length>0&&e.every(o=>o.startsWith("video/"));return t?"image":n?"video":"mixed"},Mt,Mi=()=>(Mt!=null||(Mt=import("react-native-image-picker").catch(e=>{throw Mt=void 0,new g("NOT_SUPPORTED",`Ch\u01B0a c\xF3 module ch\u1ECDn \u1EA3nh trong b\u1EA3n native: ${e instanceof Error?e.message:String(e)}`)})),Mt),vo=e=>async({accept:t,max_count:n,process:o})=>{var c,a,u,d,h,p,m,E,k;let r=await Mi(),i=Si(t),l={mediaType:i==="image"?"photo":i,maxWidth:(c=o.image)==null?void 0:c.max_width,maxHeight:(a=o.image)==null?void 0:a.max_height,quality:(d=(u=o.image)==null?void 0:u.quality)!=null?d:.8,videoQuality:(p=(h=o.video)==null?void 0:h.quality)!=null?p:"medium",durationLimit:(m=o.video)==null?void 0:m.max_duration,assetRepresentationMode:"compatible"},s=e==="camera"?await r.launchCamera({...l,saveToPhotos:!1}):await r.launchImageLibrary({...l,selectionLimit:n});if(s.didCancel)return[];if(s.errorCode){let R=s.errorCode==="permission"?"PERMISSION_DENIED":s.errorCode==="camera_unavailable"?"NOT_SUPPORTED":"HOST_ERROR";throw new g(R,(E=s.errorMessage)!=null?E:s.errorCode)}return((k=s.assets)!=null?k:[]).filter(R=>R.uri).map((R,M)=>{var z,Q,oe;return{uri:R.uri,name:(z=R.fileName)!=null?z:`file_${M+1}`,mime_type:(Q=R.type)!=null?Q:"application/octet-stream",size:R.fileSize,width:R.width,height:R.height,duration:R.duration,processed:!((oe=R.type)!=null&&oe.startsWith("video/"))||Dn.Platform.OS==="ios"}})},vi={"image/*":"images","video/*":"video","audio/*":"audio","text/plain":"plainText","text/csv":"csv","application/pdf":"pdf","application/json":"json","application/zip":"zip","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx"},xi={".pdf":"pdf",".txt":"plainText",".csv":"csv",".json":"json",".zip":"zip",".doc":"doc",".docx":"docx",".xls":"xls",".xlsx":"xlsx",".ppt":"ppt",".pptx":"pptx"},Ci=e=>async({accept:t,max_count:n})=>{var i,l,s,c;let o=t.map(a=>{var u;return(u=vi[a])!=null?u:xi[a]}),r=!t.length||o.some(a=>!a||!e.types[a])?e.types.allFiles:[...new Set(o)].flatMap(a=>e.types[a]);try{let u=(await e.pick({type:r,allowMultiSelection:n>1,mode:"import"})).filter(p=>p.uri&&!p.error).map((p,m)=>{var E,k,R;return{uri:p.uri,name:(E=p.name)!=null?E:`file_${m+1}`,mime_type:(k=p.type)!=null?k:"application/octet-stream",size:(R=p.size)!=null?R:void 0}});if(Dn.Platform.OS!=="android"||!e.keepLocalCopy||!u.some(p=>p.uri.startsWith("content://")))return u;let d=await e.keepLocalCopy({files:u.map(p=>({uri:p.uri,fileName:p.name})),destination:"cachesDirectory"}),h=new Map(d.map(p=>[p.sourceUri,p.status==="success"?p.localUri:void 0]));return u.map(p=>{var m;return{...p,uri:(m=h.get(p.uri))!=null?m:p.uri}})}catch(a){let u=a==null?void 0:a.code;if(u===((l=(i=e.errorCodes)==null?void 0:i.OPERATION_CANCELED)!=null?l:"OPERATION_CANCELED"))return[];throw u===((c=(s=e.errorCodes)==null?void 0:s.IN_PROGRESS)!=null?c:"ASYNC_OP_IN_PROGRESS")?new g("BUSY","\u0110ang m\u1EDF tr\xECnh ch\u1ECDn file kh\xE1c"):a}},vt,Ti=async e=>(vt!=null||(vt=import("@react-native-documents/picker").then(t=>Ci(t)).catch(t=>{throw vt=void 0,new g("NOT_SUPPORTED",`Ch\u01B0a c\xF3 module ch\u1ECDn file trong b\u1EA3n native: ${t instanceof Error?t.message:String(t)}`)})),(await vt)(e)),Ro={library:vo("library"),camera:vo("camera"),document:Ti},xo={type:"image",label:"\u1EA2nh",accept:["image/*"]},Co={type:"video",label:"Video",accept:["video/*"]},To={library:[xo,Co],camera:[xo,Co],document:[{type:"any",label:"M\u1ECDi file",accept:[]},{type:"pdf",label:"PDF",accept:["application/pdf"]},{type:"word",label:"Word",accept:[".doc",".docx"]},{type:"excel",label:"Excel",accept:[".xls",".xlsx"]},{type:"powerpoint",label:"PowerPoint",accept:[".ppt",".pptx"]}]},xt,Oo=()=>(xt!=null||(xt=import("react-native-compressor").catch(()=>(xt=void 0,null))),xt),Io=async(e,t,n)=>{try{return Number(await e.getFileSize(t))||n}catch{return n}},Pi=new Set(["image/jpeg","image/jpg","image/heic","image/heif","image/webp"]),Ei={low:640,medium:1280,high:1920},ki=async(e,{image:t})=>{var o;if(!t||!Pi.has(e.mime_type.toLowerCase()))return e;let n=await Oo();if(!n)return e;try{let r=await n.Image.compress(e.uri,{compressionMethod:"manual",maxWidth:t.max_width,maxHeight:t.max_height,quality:(o=t.quality)!=null?o:.8,output:"jpg"});return{...e,uri:r,mime_type:"image/jpeg",name:e.name.replace(/\.[^.]+$/,"")+".jpg",size:await Io(n,r,e.size),processed:!0}}catch{return e}},Ri=async(e,{video:t})=>{var o;let n=await Oo();if(!n)return e;try{let r=await n.Video.compress(e.uri,{compressionMethod:"auto",maxSize:Ei[(o=t==null?void 0:t.quality)!=null?o:"medium"],minimumFileSizeForCompress:2});return{...e,uri:r,mime_type:"video/mp4",size:await Io(n,r,e.size),processed:!0}}catch{return e}},Oi={image:ki,video:Ri},Ii=(e,t)=>t.split(".").reduce((n,o)=>je(n)?n[o]:void 0,e),Un=({file:e,target:t,onProgress:n,signal:o})=>new Promise((r,i)=>{if(t.target!=="url"||!("url"in t)){i(new g("INVALID_PARAMS","Thi\u1EBFu upload.url"));return}let l=t;if(o.aborted){i(new g("CANCELLED","\u0110\xE3 hu\u1EF7 upload"));return}let s=new XMLHttpRequest,c=new FormData;Object.entries(l.form_data).forEach(([d,h])=>c.append(d,h)),c.append(l.field_name,{uri:e.uri,name:e.name,type:e.mime_type});let a=()=>s.abort();o.addEventListener("abort",a);let u=d=>{o.removeEventListener("abort",a),d()};s.open("POST",l.url),Object.entries(l.headers).forEach(([d,h])=>s.setRequestHeader(d,h)),s.upload.onprogress=d=>n(d.loaded,d.total||e.size||0),s.onload=()=>u(()=>{let d=s.responseText;try{d=JSON.parse(s.responseText)}catch{}if(s.status<200||s.status>=300){i(new g("UPLOAD_FAILED",`HTTP ${s.status}`));return}let h=Ii(d,l.url_field);if(typeof h!="string"||!h){i(new g("UPLOAD_FAILED",`Response kh\xF4ng c\xF3 "${l.url_field}"`));return}r({url:h,response:d})}),s.onerror=()=>u(()=>i(new g("UPLOAD_FAILED","L\u1ED7i m\u1EA1ng khi upload"))),s.onabort=()=>u(()=>i(new g("CANCELLED","\u0110\xE3 hu\u1EF7 upload"))),s.send(c)}),Fo=e=>{var o,r;let t={...Ro};for(let[i,l]of Object.entries((o=e==null?void 0:e.sources)!=null?o:{}))l?t[i]=l:delete t[i];let n={url:Un};for(let[i,l]of Object.entries((r=e==null?void 0:e.targets)!=null?r:{}))i!=="url"&&l&&(n[i]=l);return{sources:t,targets:n}},Lo=e=>{let{sources:t,targets:n}=Fo(e),o=Object.keys(t),r=Object.fromEntries(o.filter(i=>t[i]===Ro[i]&&To[i]).map(i=>[i,To[i]]));return{sources:o,file_types:r,targets:Object.keys(n),max_count:Ln}},Qt=new Map,Do=(e,t)=>`${e}:${t}`,Fi=0,Uo=(e,t)=>{var n;typeof t=="string"&&((n=Qt.get(Do(e,t)))==null||n.abort())},et=e=>{for(let[t,n]of Qt)t.startsWith(`${e}:`)&&n.abort()},Xt=()=>new g("CANCELLED","\u0110\xE3 hu\u1EF7 upload"),Li=(e,t)=>{var n;return{name:e,code:typeof(t==null?void 0:t.code)=="string"?t.code:"UPLOAD_FAILED",message:String((n=t==null?void 0:t.message)!=null?n:t)}},No=async(e,t)=>{var c;let{sources:n,targets:o}=Fo(t.config),r=n[e.source];if(!r)throw new g("NOT_SUPPORTED",`\u1EE8ng d\u1EE5ng ch\u01B0a h\u1ED7 tr\u1EE3 ngu\u1ED3n "${e.source}"`);let i=o[e.target.target];if(!i)throw new g("NOT_SUPPORTED",`\u1EE8ng d\u1EE5ng ch\u01B0a h\u1ED7 tr\u1EE3 \u0111\xEDch upload "${e.target.target}"`);let l=new AbortController,s=Do(t.instance_id,(c=t.task_id)!=null?c:`auto-${++Fi}`);Qt.set(s,l);try{return await Di(e,t,r,i,l.signal)}finally{Qt.delete(s)}},Di=async(e,{instance_id:t,app_id:n,getContext:o,task_id:r,config:i,emit:l,exclusivePick:s=d=>d()},c,a,u)=>{var T,y,F;let d={app_id:n!=null?n:"",instance_id:t,context:{...(T=o==null?void 0:o())!=null?T:{}}},h=(await s(()=>c({accept:e.accept,max_count:e.max_count,process:e.process,caller:d}))).slice(0,e.max_count);if(u.aborted)throw Xt();if(!h.length)throw new g("CANCELLED","Ng\u01B0\u1EDDi d\xF9ng kh\xF4ng ch\u1ECDn file");let p=[],m=h.filter(P=>Ai(P,e.accept)?!0:(p.push({name:P.name,code:"INVALID_FILE",message:`Kh\xF4ng cho ph\xE9p \u0111\u1ECBnh d\u1EA1ng ${P.mime_type||ko(P.name)}`}),!1)),E=m.map(()=>0),k=m.map(P=>{var j;return(j=P.size)!=null?j:0}),R=0,M=0,z=(P=!1)=>{if(!l||!r)return;let j=Date.now();if(!P&&j-M<200)return;M=j;let ke=k.reduce((B,ge)=>B+ge,0),re=E.reduce((B,ge)=>B+ge,0);l("upload.progress",{task_id:r,loaded:re,total:ke,percent:ke?Math.min(100,Math.round(re/ke*100)):0,done_count:R,count:m.length})},Q=[],oe=0,Se=async()=>{var P,j,ke;for(;oe<m.length;){let re=oe++,B=m[re];try{if(u.aborted)throw Xt();let ge=B.mime_type.startsWith("image/")?"image":B.mime_type.startsWith("video/")?"video":void 0,te=ge&&!B.processed?(j=(P=i==null?void 0:i.processors)==null?void 0:P[ge])!=null?j:Oi[ge]:void 0;if(te&&(B=await te(B,e.process),k[re]=(ke=B.size)!=null?ke:k[re],u.aborted))throw Xt();if(e.max_size&&B.size&&B.size>e.max_size)throw new g("FILE_TOO_LARGE",`File ${B.size} byte v\u01B0\u1EE3t gi\u1EDBi h\u1EA1n ${e.max_size}`);let le=(st,Le)=>{E[re]=st,Le&&(k[re]=Le),z()},he=await a({file:B,target:e.target,onProgress:le,signal:u,caller:d});if(typeof(he==null?void 0:he.url)!="string"||!he.url)throw new g("UPLOAD_FAILED","Upload kh\xF4ng tr\u1EA3 url");let{url:Ie,...Fe}=he;Q[re]={url:Ie,name:B.name,mime_type:B.mime_type,size:B.size,width:B.width,height:B.height,duration:B.duration,...Object.keys(Fe).length?{response:"response"in Fe?Fe.response:Fe}:{}},E[re]=k[re]}catch(ge){p.push(Li(m[re].name,ge))}finally{R++,z(!0)}}};if(await Promise.all(Array.from({length:Math.min(e.concurrency,m.length)},Se)),u.aborted)throw Xt();let $=Q.filter(P=>!!P);if(!$.length){let P=p[0];throw new g((y=P==null?void 0:P.code)!=null?y:"UPLOAD_FAILED",(F=P==null?void 0:P.message)!=null?F:"Kh\xF4ng upload \u0111\u01B0\u1EE3c file n\xE0o")}return{files:$,failed:p}};var Zt=require("react"),Ue=e=>{let t=e,n=new Set;return{getState:()=>t,setState:o=>{let r=typeof o=="function"?o(t):o;t={...t,...r},n.forEach(i=>i())},subscribe:o=>(n.add(o),()=>{n.delete(o)})}},Y=(e,t,n=Object.is)=>{let o=(0,Zt.useRef)(null),r=()=>{let i=e.getState(),l=o.current;if(l&&l.state===i&&l.selector===t)return l.value;let s=t(i),c=l&&n(l.value,s)?l.value:s;return o.current={state:i,selector:t,value:c},c};return(0,Zt.useSyncExternalStore)(e.subscribe,r)};var ve={info:"info",success:"success",error:"error"},Ui=200,Vo={info:2e3,success:2e3,error:3e3},Tt=Ue({message:"",type:ve.info,tick:0}),Bo=e=>{let{message:t,type:n}=e!=null?e:{},o=String(t!=null?t:"").trim().slice(0,Ui);return o?{message:o,type:Object.values(ve).includes(n)?n:ve.info}:null},Ho=(e,t=ve.info)=>{Tt.setState(n=>({message:e,type:t,tick:n.tick+1}))};var Ce=require("react-native");var tt=require("react-native");var xe,lt=new Map,qo=(e,t)=>{var o;let n=(o=lt.get(e))!=null?o:new Set;n.add(t),lt.set(e,n)},zo=(e,t)=>{let n=lt.get(e);n&&(t?n.delete(t):n.clear(),n.size===0&<.delete(e))},Vn=new Map,$o=(e,t)=>{Vn.set(e,t)},Wo=e=>Vn.get(e),jo=()=>tt.Platform.OS==="android"&&!!(xe!=null&&xe.requesting_permission),Ni=1500,en=()=>new Promise(e=>{if(tt.Platform.OS!=="android"||tt.AppState.currentState==="active"){e();return}let t=()=>{clearTimeout(n),o.remove(),e()},n=setTimeout(t,Ni),o=tt.AppState.addEventListener("change",r=>{r==="active"&&t()})}),Nn=e=>{var t;if(xe===e&&(xe=void 0,e.subscriptions.forEach(n=>n.remove()),e.started&&tt.Platform.OS==="ios"))try{(t=e.native)==null||t.setAudioSessionActiveIOS(!1,{notifyOthersOnDeactivation:!0})}catch{}},Go=async(e,t,n,o=()=>!0)=>{var i,l,s,c,a;if(xe)throw new g("BUSY","Micro \u0111ang \u0111\u01B0\u1EE3c mini app kh\xE1c s\u1EED d\u1EE5ng");if(!o())throw new g("CANCELLED","Mini app kh\xF4ng c\xF2n ho\u1EA1t \u0111\u1ED9ng");let r={owner:e,emit:n,cancelled:!1,started:!1,subscriptions:[]};xe=r;try{let u;try{u=await import("expo-speech-recognition")}catch{throw new g("NOT_SUPPORTED","Ch\u01B0a c\xF3 module nh\u1EADn d\u1EA1ng gi\u1ECDng n\xF3i trong b\u1EA3n native")}let d=u.ExpoSpeechRecognitionModule;if(r.native=d,r.cancelled||!o())throw new g("CANCELLED","Mini app \u0111\xE3 \u0111\xF3ng");r.requesting_permission=!0;let h;try{h=await d.requestPermissionsAsync()}finally{r.requesting_permission=!1}if(await en(),r.cancelled||!o())throw new g("CANCELLED","Mini app \u0111\xE3 \u0111\xF3ng");if(!h.granted)throw new g("PERMISSION_DENIED","Ch\u01B0a c\u1EA5p quy\u1EC1n micro / nh\u1EADn d\u1EA1ng gi\u1ECDng n\xF3i");if(await d.getStateAsync()!=="inactive")throw new g("BUSY","Nh\u1EADn d\u1EA1ng gi\u1ECDng n\xF3i \u0111ang \u0111\u01B0\u1EE3c t\xEDnh n\u0103ng kh\xE1c s\u1EED d\u1EE5ng");if(r.cancelled||!o())throw new g("CANCELLED","Mini app \u0111\xE3 \u0111\xF3ng");r.subscriptions.push(d.addListener("result",p=>{var m,E;xe!==r||r.cancelled||n(p.isFinal?"speech.final":"speech.partial",{...p,text:(E=(m=p.results[0])==null?void 0:m.transcript)!=null?E:""})}),d.addListener("error",p=>{xe===r&&!r.cancelled&&n("speech.error",{...p,code:p.error})}),d.addListener("end",()=>{xe===r&&(Nn(r),n("speech.end"))})),r.started=!0,d.start({lang:(i=t.lang)!=null?i:"vi-VN",continuous:(l=t.continuous)!=null?l:!0,interimResults:(s=t.interimResults)!=null?s:!0,addsPunctuation:(c=t.addsPunctuation)!=null?c:!0,requiresOnDeviceRecognition:(a=t.requiresOnDeviceRecognition)!=null?a:!1,iosCategory:{category:u.AVAudioSessionCategory.playAndRecord,categoryOptions:[u.AVAudioSessionCategoryOptions.defaultToSpeaker,u.AVAudioSessionCategoryOptions.allowBluetooth],mode:u.AVAudioSessionMode.measurement}})}catch(u){throw Nn(r),u}},Jo=e=>{let t=xe;if(!(!t||t.owner!==e)){if(!t.started){t.cancelled=!0;return}t.native.stop()}},Ne=e=>{Vn.delete(e);let t=lt.get(e);lt.delete(e),t==null||t.forEach(o=>{var r;try{(r=o.release)==null||r.call(o,e)}catch{}});let n=xe;if(!(!n||n.owner!==e||n.cancelled)&&(n.cancelled=!0,n.started))try{n.native.abort()}catch{Nn(n)}};var Ko={qr:"qr",ean13:"ean-13",ean8:"ean-8",upcA:"upc-a",upcE:"upc-e",code128:"code-128",code39:"code-39",code93:"code-93",codabar:"codabar",itf:"itf",pdf417:"pdf-417",aztec:"aztec",dataMatrix:"data-matrix"},ce={...Ko,all:Object.values(Ko)},ct={scan:"scanner.scan",start:"scanner.start",stop:"scanner.stop"},nn={result:"scanner.result",end:"scanner.end"},nt={user:"user",web:"web",closed:"closed",error:"error"},_e={top:"top",full:"full"},Ge={once:"once",continuous:"continuous"},Vi=1500,Yo=6e4,X,se=Ue({active:null,last_value:null,hit_tick:0,scan_count:0,notice:null,is_picking:!1}),Qo=()=>Ce.Platform.OS==="android"&&!!(X!=null&&X.requesting_permission),Hn=e=>{let{types:t,cooldown_ms:n,hint:o,layout:r,absolute:i}=e!=null?e:{},l={};if(t!==void 0){if(!Array.isArray(t)||!t.length||!t.every(s=>ce.all.includes(s)))throw new g("INVALID_PARAMS","types ph\u1EA3i l\xE0 m\u1EA3ng CodeType");l.types=t}if(n!==void 0){if(typeof n!="number"||!Number.isFinite(n)||n<0||n>Yo)throw new g("INVALID_PARAMS",`cooldown_ms ph\u1EA3i t\u1EEB 0 \u0111\u1EBFn ${Yo}`);l.cooldown_ms=n}if(o!==void 0){if(typeof o!="string"||!o.trim()||o.length>80)throw new g("INVALID_PARAMS","hint ph\u1EA3i c\xF3 1\u201380 k\xFD t\u1EF1");l.hint=o}if(r!==void 0){if(!Object.values(_e).includes(r))throw new g("INVALID_PARAMS","layout ph\u1EA3i l\xE0 ScannerLayout");l.layout=r}if(i!==void 0){if(typeof i!="boolean")throw new g("INVALID_PARAMS","absolute ph\u1EA3i l\xE0 boolean");l.absolute=i}return l},qn=e=>X!==e?!1:(X=void 0,se.setState({active:null,last_value:null,scan_count:0,notice:null,is_picking:!1}),!0),Bi=()=>Ce.Alert.alert("Ch\u01B0a c\u1EA5p quy\u1EC1n camera","H\xE3y b\u1EADt quy\u1EC1n camera trong C\xE0i \u0111\u1EB7t \u0111\u1EC3 qu\xE9t m\xE3.",[{text:"Hu\u1EF7",style:"cancel"},{text:"M\u1EDF C\xE0i \u0111\u1EB7t",onPress:()=>{Ce.Linking.openSettings().catch(()=>{})}}]),Zo=async(e,t)=>{if(X)throw new g("BUSY","Camera qu\xE9t m\xE3 \u0111ang \u0111\u01B0\u1EE3c s\u1EED d\u1EE5ng");if(!t())throw new g("CANCELLED","Mini app kh\xF4ng c\xF2n ho\u1EA1t \u0111\u1ED9ng");X=e;let n=()=>{if(e.cancelled||!t())throw new g("CANCELLED","Mini app \u0111\xE3 \u0111\xF3ng")};try{let o;try{o=await import("react-native-vision-camera")}catch{throw new g("NOT_SUPPORTED","Ch\u01B0a c\xF3 module camera trong b\u1EA3n native")}n();let r=o.Camera.getCameraPermissionStatus();if(r!=="granted"){let l=Ce.Platform.OS==="ios"&&r==="denied";e.requesting_permission=!0;let s;try{s=await o.Camera.requestCameraPermission()}finally{e.requesting_permission=!1}if(await en(),n(),s!=="granted")throw l&&Bi(),new g("PERMISSION_DENIED","Ch\u01B0a c\u1EA5p quy\u1EC1n camera")}if(!o.Camera.getAvailableCameraDevices().some(l=>l.position==="back"))throw new g("NOT_SUPPORTED","Thi\u1EBFt b\u1ECB kh\xF4ng c\xF3 camera sau");let i=await Pt();n(),se.setState({active:{owner:e.owner,mode:e.mode,types:e.types,layout:e.layout,absolute:e.absolute,hint:e.hint,vision:o,glass_view:i},last_value:null,scan_count:0,notice:null})}catch(o){throw qn(e),o}},tn;import("react-native-safe-area-context").then(({initialWindowMetrics:e})=>{tn=e==null?void 0:e.insets}).catch(()=>{});var pt=()=>{var e;return tn!=null?tn:{top:Ce.Platform.OS==="ios"?54:(e=Ce.StatusBar.currentHeight)!=null?e:0,bottom:Ce.Platform.OS==="ios"?34:48}},Pt=async()=>{if(Ce.Platform.OS==="ios")try{let e=await import("expo-glass-effect");return e.isLiquidGlassAvailable()?e.GlassView:void 0}catch{return}},er=(e,t,n)=>{var o,r,i,l;return{owner:e,mode:t,types:(o=n.types)!=null?o:ce.all,cooldown_ms:(r=n.cooldown_ms)!=null?r:Vi,hint:n.hint,layout:t===Ge.once?_e.full:(i=n.layout)!=null?i:_e.top,absolute:t!==Ge.once&&((l=n.layout)!=null?l:_e.top)===_e.top&&n.absolute===!0,cancelled:!1,requesting_permission:!1,last_seen:new Map}},tr=(e,t,n=()=>!0,o)=>new Promise((r,i)=>{let l=er(e,Ge.once,t);l.onHit=o,l.resolve=r,l.reject=i,Zo(l,n).catch(i)}),nr=(e,t,n,o=()=>!0,r)=>{let i=er(e,Ge.continuous,t);return i.emit=n,i.onHit=r,Zo(i,o)},on=(e,t,n)=>{var o,r;if(!se.getState().active){e.cancelled=!0;return}if(qn(e)){if(e.mode===Ge.once){(o=e.reject)==null||o.call(e,t===nt.error?new g("HOST_ERROR",n!=null?n:"L\u1ED7i camera"):new g("CANCELLED","\u0110\xE3 \u0111\xF3ng camera qu\xE9t m\xE3"));return}(r=e.emit)==null||r.call(e,nn.end,n?{reason:t,message:n}:{reason:t})}},or=e=>{(X==null?void 0:X.owner)===e&&on(X,nt.web)},Je=e=>{(X==null?void 0:X.owner)===e&&on(X,nt.closed)},zn=()=>{X&&on(X,nt.user)},rr=e=>{X&&on(X,nt.error,e)},$n=(e,t=Date.now(),n=!1)=>{var r,i,l;let o=X;if(!(!o||!se.getState().active))for(let{value:s,type:c}of e){if(!s)continue;let a=o.last_seen.get(s);if(o.last_seen.set(s,t),!(!n&&a!==void 0&&t-a<o.cooldown_ms)){if((r=o.onHit)==null||r.call(o),o.mode===Ge.once){qn(o),(i=o.resolve)==null||i.call(o,{value:s,type:c});return}se.setState(u=>({last_value:s,hit_tick:u.hit_tick+1,scan_count:u.scan_count+1,notice:null})),(l=o.emit)==null||l.call(o,nn.result,{value:s,type:c})}}},Hi={1:ce.code128,2:ce.code39,4:ce.code93,8:ce.codabar,16:ce.dataMatrix,32:ce.ean13,64:ce.ean8,128:ce.itf,256:ce.qr,512:ce.upcA,1024:ce.upcE,2048:ce.pdf417,4096:ce.aztec},qi=2500,Xo=2e3,Bn=e=>{se.setState({notice:e}),setTimeout(()=>{se.getState().notice===e&&se.setState({notice:null})},qi)},ir=async()=>{var t,n;let e=X;if(!(!e||se.getState().is_picking)){e.requesting_permission=!0,se.setState({is_picking:!0,notice:null});try{let{launchImageLibrary:o}=await import("react-native-image-picker"),r=await o({mediaType:"photo",selectionLimit:1,maxWidth:Xo,maxHeight:Xo}),i=(n=(t=r.assets)==null?void 0:t[0])==null?void 0:n.uri;if(r.didCancel||X!==e)return;if(r.errorCode||!i){Bn("Kh\xF4ng m\u1EDF \u0111\u01B0\u1EE3c \u1EA3nh");return}let{default:l}=await import("@react-native-ml-kit/barcode-scanning"),s=await l.scan(i);if(X!==e)return;let c=s.map(({value:a,format:u})=>({value:a,code_type:Hi[u]})).filter(({code_type:a})=>!a||e.types.includes(a)).map(({value:a,code_type:u})=>({value:a,type:u!=null?u:"unknown"}));if(!c.length){Bn("Kh\xF4ng t\xECm th\u1EA5y m\xE3 trong \u1EA3nh");return}$n(c,Date.now(),!0)}catch{X===e&&Bn("Kh\xF4ng \u0111\u1ECDc \u0111\u01B0\u1EE3c m\xE3 t\u1EEB \u1EA3nh")}finally{await en(),e.requesting_permission=!1,X===e&&se.setState({is_picking:!1})}}};var sn=1,g=class extends Error{constructor(n,o){super(o);this.code=n}},sr=e=>{try{let t=JSON.parse(e);return(t==null?void 0:t.__retion)===sn&&typeof t.method=="string"?t:null}catch{return null}},Rt=e=>`window.__RETION_MINIAPP__ && window.__RETION_MINIAPP__.receive(${JSON.stringify(e)}); true;`,ar=(e,t)=>Rt({id:e,result:t}),lr=(e,t)=>Rt({id:e,error:{code:t.code,message:t.message}}),cr=(e,t)=>Rt({event:e,data:t}),jn=e=>Rt({event:"context",data:e});var pr=()=>`(function () {
|
|
2
2
|
var post = function (level, args) {
|
|
3
3
|
try {
|
|
4
4
|
var parts = [];
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
else if (typeof a === 'object') { try { parts.push(JSON.stringify(a).slice(0, 800)); } catch (e) { parts.push(String(a)); } }
|
|
9
9
|
else { parts.push(String(a)); }
|
|
10
10
|
}
|
|
11
|
-
window.ReactNativeWebView && window.ReactNativeWebView.postMessage(JSON.stringify({ __retion: ${
|
|
11
|
+
window.ReactNativeWebView && window.ReactNativeWebView.postMessage(JSON.stringify({ __retion: ${sn}, method: 'log', level: level, text: parts.join(' ') }));
|
|
12
12
|
} catch (e) {}
|
|
13
13
|
};
|
|
14
14
|
['log', 'info', 'warn', 'error'].forEach(function (level) {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
window.addEventListener('unhandledrejection', function (e) { post('error', ['[unhandledrejection]', e.reason]); });
|
|
20
20
|
// Kh\xF4ng log query (c\xF3 th\u1EC3 ch\u1EE9a token) \u2014 ch\u1EC9 \u0111\u01B0\u1EDDng d\u1EABn + route.
|
|
21
21
|
post('info', ['[page] ' + location.pathname + location.hash]);
|
|
22
|
-
})(); true;`,
|
|
22
|
+
})(); true;`,ur=()=>`(function () {
|
|
23
23
|
function atTop(el) {
|
|
24
24
|
for (var n = el; n && n !== document.documentElement; n = n.parentElement) {
|
|
25
25
|
if (n.scrollTop > 0) { return false; }
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
function report(at_top) {
|
|
31
31
|
if (at_top === last) { return; }
|
|
32
32
|
last = at_top;
|
|
33
|
-
window.ReactNativeWebView && window.ReactNativeWebView.postMessage(JSON.stringify({ __retion: ${
|
|
33
|
+
window.ReactNativeWebView && window.ReactNativeWebView.postMessage(JSON.stringify({ __retion: ${sn}, method: 'touchAtTop', at_top: at_top }));
|
|
34
34
|
}
|
|
35
35
|
document.addEventListener('touchstart', function (e) { report(atTop(e.target)); }, { capture: true, passive: true });
|
|
36
36
|
// Cu\u1ED9n r\u1EDDi \u0111\u1EA7u trang \u2192 b\xE1o ngay, kh\xF4ng \u0111\u1EE3i l\u1EA7n ch\u1EA1m sau (tr\xE1nh host d\xF9ng gi\xE1 tr\u1ECB c\u0169 "\u0111ang \u1EDF \u0111\u1EA7u").
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
var el = e.target === document ? document.documentElement : e.target;
|
|
39
39
|
if (el && el.scrollTop > 0) { report(false); }
|
|
40
40
|
}, { capture: true, passive: true });
|
|
41
|
-
})(); true;`,
|
|
41
|
+
})(); true;`,dr=()=>`(function () {
|
|
42
42
|
if (window.__retionSafeAreaFrozen) { return; }
|
|
43
43
|
window.__retionSafeAreaFrozen = true;
|
|
44
44
|
var max = {};
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
|
-
})(); true;`,
|
|
63
|
-
${
|
|
62
|
+
})(); true;`,gr=e=>Rt({event:e}),hr=(e,t)=>{let n=mr(t);return`try { history.replaceState(history.state, '', location.pathname + ${JSON.stringify(n?`?${n}`:"")} + location.hash); } catch (e) {}
|
|
63
|
+
${jn(e)}`},mr=e=>Object.entries(e).filter(([,t])=>t!=null&&t!=="").map(([t,n])=>`${encodeURIComponent(t)}=${encodeURIComponent(String(n))}`).join("&"),fr=(e,t={})=>{let n=mr(t);return`window.__RETION_MINIAPP_HOST__ = { protocol: ${sn} };
|
|
64
64
|
window.__RETION_MINIAPP_CONTEXT__ = ${JSON.stringify(e)};
|
|
65
65
|
${n?`try { history.replaceState(history.state, '', location.pathname + '?' + ${JSON.stringify(n)} + location.hash); } catch (e) {}`:""}
|
|
66
|
-
true;`},
|
|
66
|
+
true;`},yr={partner:"partner_token",chatbox:"chatbox_token"},br=(e,t)=>{let n={...e};for(let o of Object.values(yr))t.includes(o)||delete n[o];return n},Wn=new Set,Et=async(e,t)=>{if(Wn.has(e))throw new g("BUSY",`${e} \u0111ang ch\u1EA1y \u2014 ch\u1EDD l\u01B0\u1EE3t tr\u01B0\u1EDBc xong`);Wn.add(e);try{return await t()}finally{Wn.delete(e)}},Gn=e=>`(function () {
|
|
67
67
|
window.__retionScannerHeight = ${Math.max(0,Math.round(e))};
|
|
68
68
|
window.dispatchEvent(new Event('retionscannerheight'));
|
|
69
|
-
})(); true;`,
|
|
69
|
+
})(); true;`,wr=()=>`(function () {
|
|
70
70
|
try {
|
|
71
71
|
var AudioCtx = window.AudioContext || window.webkitAudioContext;
|
|
72
72
|
if (!AudioCtx) { return; }
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
// iOS c\xF3 th\u1EC3 \u0111\u1EC3 context \u1EDF suspended / interrupted (vd. khi camera m\u1EDF phi\xEAn quay): ch\u1EA1y l\u1EA1i xong m\u1EDBi ph\xE1t.
|
|
86
86
|
if (ctx.state === 'running') { play(); } else { ctx.resume().then(play).catch(function () {}); }
|
|
87
87
|
} catch (e) {}
|
|
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"},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});
|
|
88
|
+
})(); true;`,zi=new Set(["selection","impactLight","impactMedium","impactHeavy","rigid","soft","notificationSuccess","notificationWarning","notificationError"]),rn=(e,t)=>{if(typeof e!="string"||!e)throw new g("INVALID_PARAMS",`Thi\u1EBFu ${t}`);return e},_r=async({method:e,params:t},{getHostData:n,getPermissions:o,getContext:r,is_dark:i,close:l,app_id:s,instance_id:c,options:a,emit:u,isActive:d,playBeep:h})=>{var R,M,z,Q,oe,Se,$,T;let p=a==null?void 0:a.handlers,m={app_id:s,instance_id:c,close:l},E=()=>{var y;(y=a==null?void 0:a.haptic)==null||y.call(a,"impactLight"),h==null||h()},k=()=>new g("NOT_SUPPORTED",`${e} ch\u01B0a h\u1ED7 tr\u1EE3 \u1EDF \u1EE9ng d\u1EE5ng n\xE0y`);switch(e){case"getCurrentLocation":{let y=_o(t);return Et(e,()=>Ao(y,d))}case"speech.start":{if(!u)throw k();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 j of["continuous","interimResults","addsPunctuation","requiresOnDeviceRecognition"])if((t==null?void 0:t[j])!==void 0){if(typeof t[j]!="boolean")throw new g("INVALID_PARAMS",`${j} ph\u1EA3i l\xE0 boolean`);y[j]=t[j]}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 F=(t==null?void 0:t.mode)==="s2t"?"s2t":"voice",P=F==="voice"?(R=a==null?void 0:a.voice)!=null?R:a==null?void 0:a.speech:void 0;if($o(c,P),P){qo(c,P);try{return await P.start({owner:c,app_id:s,mode:F,options:y,emit:u,isActive:d!=null?d:(()=>!0)})}catch(j){throw zo(c,P),j}}return Go(c,y,u,d)}case"speech.stop":{let y=Wo(c);return y?y.stop(c):Jo(c)}case ct.scan:return tr(c,Hn(t),d,E);case ct.start:{if(!u)throw k();return nr(c,Hn(t),u,d,E)}case ct.stop:return or(c);case"uploadFiles":{let{task_id:y,...F}=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 No(Eo(F),{instance_id:c,app_id:s,getContext:r,task_id:y,config:a==null?void 0:a.upload,emit:u,exclusivePick:P=>Et("uploadFiles.pick",P)})}case"uploadFiles.cancel":Uo(c,t==null?void 0:t.task_id);return;case"getUploadCapabilities":return Lo(a==null?void 0:a.upload);case"getBiometricAvailability":return((M=a==null?void 0:a.biometrics)!=null?M:await Fn()).getAvailability();case"authenticateBiometric":{let y=rn(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 F=t==null?void 0:t.cancelButtonText;if(F!==void 0&&(typeof F!="string"||!F.trim()||F.length>80))throw new g("INVALID_PARAMS","Invalid cancelButtonText");return Et(e,async()=>{var j;return((j=a==null?void 0:a.biometrics)!=null?j:await Fn()).authenticate({reason:y,cancelButtonText:F})})}case"requestPayment":{let y=p==null?void 0:p.requestPayment;if(!y)throw k();let F=t==null?void 0:t.amount;if(typeof F!="number"||!Number.isFinite(F)||F<=0)throw new g("INVALID_PARAMS","amount ph\u1EA3i l\xE0 s\u1ED1 > 0");let P={...t,amount:F,currency:rn(t==null?void 0:t.currency,"currency")};return Et(e,()=>y(P,m))}case"printImage":{let y=p==null?void 0:p.printImage;if(!y)throw k();let F=rn(t==null?void 0:t.image,"image");await Et(e,()=>y({image:F},m));return}case"openScreen":if(!(p!=null&&p.openScreen))throw k();await p.openScreen({screen:rn(t==null?void 0:t.screen,"screen"),params:t==null?void 0:t.params},m);return;case"closeApp":l();return;case"openWebview":{let y=String((z=t==null?void 0:t.url)!=null?z:"");if(!/^https?:\/\//i.test(y))throw new g("INVALID_PARAMS","url ph\u1EA3i l\xE0 http(s)");await(a!=null&&a.openUrl?a.openUrl(y):kt.Linking.openURL(y));return}case"openLink":{let y=String((Q=t==null?void 0:t.url)!=null?Q:"").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(a!=null&&a.openUrl?a.openUrl(y):kt.Linking.openURL(y))}catch(F){throw new g("NOT_SUPPORTED",String((Se=(oe=F==null?void 0:F.message)!=null?oe:F)!=null?Se:"Kh\xF4ng m\u1EDF \u0111\u01B0\u1EE3c link"))}return}case"showToast":{let y=Bo(t);if(!y||(d==null?void 0:d())===!1)return;a!=null&&a.showToast?a.showToast(y.message,{type:y.type}):Ho(y.message,y.type);return}case"haptic":{let y=zi.has(t==null?void 0:t.type)?t.type:"selection";($=a==null?void 0:a.haptic)==null||$.call(a,y);return}case"getSystemInfo":return{platform:kt.Platform.OS==="ios"?"ios":"android",appVersion:(T=a==null?void 0:a.app_version)!=null?T:"",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 j=n().access_token;if(!j)throw new g("HOST_ERROR","Mini app ch\u01B0a c\xF3 token cho page n\xE0y");return j}if(y!=="partner"&&y!=="chatbox")throw new g("HOST_ERROR",`Lo\u1EA1i token kh\xF4ng h\u1EE3p l\u1EC7: ${String(y)}`);let F=yr[y];if(!o().includes(F))throw new g("PERMISSION_DENIED",`Mini app ch\u01B0a \u0111\u01B0\u1EE3c c\u1EA5p quy\u1EC1n ${F} (Console \u2192 Quy\u1EC1n l\u1EA5y token)`);let P=y==="partner"?n().partner_token:n().chatbox_token;if(!P)throw new g("HOST_ERROR",`Kh\xF4ng c\xF3 ${F}`);return P}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 Kn=e=>`bundle:${e}`,Yn=()=>`${D().file_system.document_dir}/miniapps`,Xn=Yn,Qn=(e,t,n="index.html",o=!1,r=[])=>{let i=`${Xn()}/${e}/${t}`;return{app_id:e,version:t,dir:i,entry_uri:`file://${i}/${n}`,context_update:o,permissions:r}},Jn=e=>{var t;D().storage.setString(Kn(e.app_id),JSON.stringify({version:e.version,entry:e.entry,context_update:!!e.context_update,permissions:(t=e.permissions)!=null?t:[]}))},$i=(e,t)=>/^https?:\/\//.test(t)?t:`${e.replace(/[^/]*$/,"")}${t}`,W=e=>{let t=D().storage.getString(Kn(e));if(!t)return null;try{let{version:n,entry:o,context_update:r,permissions:i}=JSON.parse(t);return Qn(e,n,o,!!r,Array.isArray(i)?i:[])}catch{return null}},He=e=>D().file_system.exists(e.entry_uri.replace("file://","")),Zn=async e=>{let t=W(e.app_id);return(t==null?void 0:t.version)===e.version&&await He(t)},Sr=async(e,t)=>{let n=D().file_system,o=`${Xn()}/${e}`,r=await n.listDir(o).catch(()=>[]);await Promise.all(r.filter(i=>!t.includes(i)).map(i=>n.remove(`${o}/${i}`).catch(()=>{})))},Mr=async e=>{var t;await((t=It[e])==null?void 0:t.catch(()=>{})),D().storage.setString(Kn(e),""),await D().file_system.remove(`${Xn()}/${e}`).catch(()=>{})},ut=class extends Error{constructor(){super("cancelled"),this.name="MiniAppInstallCancelled"}},It={},vr=(e,t)=>{var i;let o=((i=It[e])!=null?i:Promise.resolve()).catch(()=>{}).then(t),r=o.catch(()=>{});return It[e]=r,r.then(()=>{It[e]===r&&delete It[e]}),o},eo=(e,t)=>{var r,i;let n=e.split(".").map(l=>parseInt(l,10)||0),o=t.split(".").map(l=>parseInt(l,10)||0);for(let l=0;l<Math.max(n.length,o.length);l++){let s=((r=n[l])!=null?r:0)-((i=o[l])!=null?i:0);if(s)return s}return 0},xr=({manifest:e,zip_path:t})=>vr(e.app_id,async()=>{var i;let n=D().file_system,o=W(e.app_id);if(o&&eo(o.version,e.version)>=0&&await He(o))return o;if(e.sha256&&n.sha256&&await n.sha256(t)!==e.sha256)throw new Error("sha256 mismatch");let r=Qn(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),Jn(e),we("\u0111\xE3 c\xE0i b\u1EA3n \u0111\xF3ng s\u1EB5n",e.app_id,e.version),Sr(e.app_id,[e.version,o==null?void 0:o.version].filter(Boolean)),r}),to=(e,{base_url:t,onProgress:n}={})=>{let o=D().file_system,r=null,i=!1,l=`${o.cache_dir}/${e.app_id}-${e.version}.zip`,s=()=>{if(i)throw new ut},c=async()=>{var d;s();let a=W(e.app_id);if((a==null?void 0:a.version)===e.version&&await o.exists(a.dir))return Jn(e),W(e.app_id);s();let u=o.download({url:t?$i(t,e.bundle_url):e.bundle_url,to_file:l,onProgress:(h,p)=>{var E;let m=p>0?p:(E=e.size)!=null?E: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(l)!==e.sha256)throw new Error("sha256 mismatch")}else we("b\u1ECF qua ki\u1EC3m tra sha256 (file_system kh\xF4ng c\xF3 sha256)",e.app_id);s();let p=Qn(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(l,p.dir),Jn(e),Sr(e.app_id,[e.version,a==null?void 0:a.version].filter(Boolean)),p}catch(h){throw i?new ut:h}finally{r=null,o.remove(l).catch(()=>{})}};return{promise:vr(e.app_id,c),cancel:()=>{i=!0,r==null||r.cancel()}}},Ot={},Wi=__DEV__?0:60*1e3,Ar={},Cr=(e,t)=>{var o,r;let n=W(e);return n&&Date.now()-((o=Ar[t])!=null?o:0)<Wi?Promise.resolve(n):((r=Ot[e])!=null||(Ot[e]=(async()=>{let i=await fetch(t,{headers:{"Cache-Control":"no-cache"}});if(!i.ok)throw new Error(`manifest ${i.status}`);let l=await i.json(),s=await to(l,{base_url:t}).promise;return Ar[t]=Date.now(),s})().catch(i=>(console.warn("[miniapp] sync failed",e,i==null?void 0:i.message),W(e))).finally(()=>{Ot[e]=void 0})),Ot[e])};var an=new Map,Tr=(e,t)=>(an.set(e,t),()=>{an.get(e)===t&&an.delete(e)}),Pr=(e,t)=>{let n=an.get(e);return n?n(t):!1};var J=require("react"),w=require("react-native");var C=require("react/jsx-runtime"),Ft="#22C55E",ji="\u0110\u01B0a m\xE3 v\xE0o khung \u0111\u1EC3 qu\xE9t",Gi=2,cn=18,Ji=1600,Lt=14,Ki=2e3,Rr=.38,Yi=40,Er=2,Xi=8,Qi=2e3,Zi=250,dt=2e3,es=[{top:0,left:0,borderTopWidth:4,borderLeftWidth:4,borderTopLeftRadius:Lt},{top:0,right:0,borderTopWidth:4,borderRightWidth:4,borderTopRightRadius:Lt},{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4,borderBottomLeftRadius:Lt},{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4,borderBottomRightRadius:Lt}],kr=({color:e})=>(0,C.jsx)(C.Fragment,{children:es.map((t,n)=>(0,C.jsx)(w.View,{style:[v.corner,t,{borderColor:e}]},n))}),ln=({style:e,children:t,...n})=>{let o=(0,J.useRef)(new w.Animated.Value(1)).current,r=i=>w.Animated.spring(o,{toValue:i,speed:40,bounciness:8,useNativeDriver:!0}).start();return(0,C.jsx)(w.Pressable,{...n,onPressIn:()=>r(.88),onPressOut:()=>r(1),children:(0,C.jsx)(w.Animated.View,{style:[e,{transform:[{scale:o}]}],children:t})})},oo=({scanner:e,closing:t=!1,onClosed:n,onHeight:o})=>{var f,_;let{vision:r,types:i,mode:l,layout:s,hint:c,glass_view:a,absolute:u}=e,d=s===_e.top,h=(0,J.useRef)(new w.Animated.Value(0)).current,p=r.useCameraDevice("back"),m=(0,J.useRef)(new w.Animated.Value(1)).current,[E,k]=(0,J.useState)(!1),[R,M]=(0,J.useState)(1),z=(0,J.useRef)(null),[Q,oe]=(0,J.useState)(()=>{let{width:A,height:K}=w.Dimensions.get("window");return{width:A,height:d?K*Rr:K,window_y:0}}),Se=Y(se,A=>A.last_value),$=Y(se,A=>A.hit_tick),T=Y(se,A=>A.scan_count),y=Y(se,A=>A.notice),F=Y(se,A=>A.is_picking),P=(0,J.useRef)(null),j=pt(),ke=j.top,re=(0,J.useRef)(new w.Animated.Value(0)).current,B=(0,J.useRef)(new w.Animated.Value(0)).current,ge=(0,J.useRef)(new w.Animated.Value(0)).current,te=(0,J.useRef)(n);te.current=n,(0,J.useEffect)(()=>{if(!t)return;h.setValue(Q.height);let A=w.Animated.timing(h,{toValue:0,duration:Zi,easing:w.Easing.out(w.Easing.cubic),useNativeDriver:!1});return A.start(({finished:K})=>{var me;K&&((me=te.current)==null||me.call(te))}),()=>A.stop()},[t,h]);let le=Math.round(Q.width*(d?.8:.78)),he=Math.round(d?Q.height*.46:le*.78),Ie=Math.round((Q.height-he)/2),Fe=Math.round((Q.width-le)/2),st=r.useCodeScanner({codeTypes:i,onCodeScanned:(0,J.useCallback)(A=>$n(A),[])});(0,J.useEffect)(()=>{let A=w.BackHandler.addEventListener("hardwareBackPress",()=>(zn(),!0));return()=>A.remove()},[]);let Le=(0,J.useRef)($);(0,J.useEffect)(()=>{if($===Le.current)return;re.setValue(1),ge.setValue(1);let A=w.Animated.parallel([w.Animated.timing(re,{toValue:0,duration:450,useNativeDriver:!0}),w.Animated.sequence([w.Animated.delay(Ki),w.Animated.timing(ge,{toValue:0,duration:250,useNativeDriver:!0})])]);return A.start(),()=>A.stop()},[$,re,ge]),(0,J.useEffect)(()=>{let A=me=>w.Animated.timing(B,{toValue:me,duration:Ji,easing:w.Easing.inOut(w.Easing.quad),useNativeDriver:!0}),K=w.Animated.loop(w.Animated.sequence([A(1),A(0)]));return K.start(),()=>K.stop()},[B]);let Be=(0,J.useCallback)(()=>{w.Animated.timing(m,{toValue:0,duration:220,useNativeDriver:!0}).start()},[m]);(0,J.useEffect)(()=>{let A=setTimeout(Be,Qi);return()=>clearTimeout(A)},[Be]);let[_t,kn]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let A=requestAnimationFrame(()=>{A=requestAnimationFrame(()=>kn(!0))});return()=>cancelAnimationFrame(A)},[]);let Qe=!!(p!=null&&p.hasTorch),At=(f=p==null?void 0:p.neutralZoom)!=null?f:1,St=p?Math.min(p.maxZoom/At,Xi):1,Rn=At*Math.min(R,St),jt=A=>{var fe;let{touches:K}=A.nativeEvent;if(K.length!==2){z.current=null;return}let me=Math.hypot(K[0].pageX-K[1].pageX,K[0].pageY-K[1].pageY);(fe=z.current)!=null||(z.current={distance:me,level:R}),M(Math.max(1,Math.min(St,z.current.level*(me/z.current.distance))))},Gt=(0,C.jsx)(w.Text,{style:[v.hint,!!y&&v.hint_notice],numberOfLines:1,children:(_=y!=null?y:c)!=null?_:ji});return(0,C.jsx)(w.Animated.View,{ref:P,onTouchMove:jt,onTouchEnd:()=>{z.current=null},pointerEvents:t?"none":"auto",style:d?[v.top,u&&v.top_absolute,t&&{height:h}]:v.full,onLayout:({nativeEvent:{layout:A}})=>{var K;t||(o==null||o(A.height),(K=P.current)==null||K.measureInWindow((me,fe)=>{oe({width:A.width,height:A.height,window_y:fe||0})}))},children:(0,C.jsxs)(w.View,{style:t?[v.content_closing,{height:Q.height}]:v.content,children:[p&&_t&&(0,C.jsx)(r.Camera,{style:w.StyleSheet.absoluteFill,device:p,isActive:!F,codeScanner:st,torch:E&&Qe?"on":"off",zoom:Rn,onPreviewStarted:Be,onError:A=>rr(A.message)}),(0,C.jsx)(w.Animated.View,{style:[v.preview_cover,{opacity:m}],pointerEvents:"none"}),Q.height>0&&(0,C.jsxs)(w.View,{style:v.overlay,pointerEvents:"none",children:[(0,C.jsx)(w.View,{style:[v.dim_ring,{top:Ie-dt,left:Fe-dt,width:le+dt*2,height:he+dt*2}]}),(0,C.jsxs)(w.View,{style:{position:"absolute",top:Ie,left:Fe,width:le,height:he},children:[(0,C.jsx)(kr,{color:"#FFFFFF"}),(0,C.jsx)(w.Animated.View,{style:[w.StyleSheet.absoluteFill,{opacity:re}],children:(0,C.jsx)(kr,{color:Ft})}),(0,C.jsxs)(w.Animated.View,{style:[v.scan_line_wrap,{transform:[{translateY:B.interpolate({inputRange:[0,1],outputRange:[0,Math.max(0,he-cn)]})}]}],children:[(0,C.jsx)(w.View,{style:v.scan_glow_outer}),(0,C.jsx)(w.View,{style:v.scan_glow_inner}),(0,C.jsx)(w.View,{style:v.scan_line})]})]}),(0,C.jsx)(w.View,{style:[v.hint_slot,d?{top:0,height:Ie-6,justifyContent:"flex-end"}:{top:Ie+he+20}],children:Gt}),l===Ge.continuous&&!!Se&&(0,C.jsx)(w.Animated.View,{style:[v.result_slot,{top:d?Ie+he-Yi:Ie+he+52},{opacity:ge}],children:(0,C.jsxs)(w.View,{style:v.result,children:[(0,C.jsx)(w.View,{style:v.check_badge,children:(0,C.jsx)(w.View,{style:v.check_mark})}),(0,C.jsx)(w.Text,{style:v.result_text,numberOfLines:1,children:Se}),(0,C.jsxs)(w.Text,{style:v.result_count,children:["\xB7 ",T," m\xE3"]})]})})]}),Q.height>0&&(0,C.jsx)(w.View,{style:[v.close_slot,d?v.close_slot_top:{top:Math.max(12,ke-Q.window_y+12)}],children:(0,C.jsxs)(ln,{style:[v.close_button,!!a&&v.glass_surface],onPress:zn,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"\u0110\xF3ng",children:[a&&(0,C.jsx)(a,{style:v.glass_fill,glassEffectStyle:"regular",colorScheme:"dark",tintColor:"rgba(24,24,27,0.35)",isInteractive:!0}),(0,C.jsx)(w.View,{style:[v.close_bar,v.close_bar_a]}),(0,C.jsx)(w.View,{style:[v.close_bar,v.close_bar_b]})]})}),(0,C.jsx)(w.View,{style:[v.toolbar_wrap,!d&&{bottom:j.bottom+20}],pointerEvents:"box-none",children:(0,C.jsxs)(w.View,{style:[v.toolbar,!!a&&v.glass_surface],children:[a&&(0,C.jsx)(a,{style:v.glass_fill,glassEffectStyle:"regular",colorScheme:"dark",tintColor:"rgba(24,24,27,0.35)",isInteractive:!0}),(0,C.jsx)(ln,{style:v.tool,onPress:ir,disabled:F,accessibilityRole:"button",accessibilityLabel:"Qu\xE9t t\u1EEB \u1EA3nh",children:(0,C.jsxs)(w.View,{style:v.image_icon,children:[(0,C.jsx)(w.View,{style:v.image_icon_dot}),(0,C.jsx)(w.View,{style:v.image_icon_hill})]})}),!!p&&St>=Er&&(0,C.jsx)(ln,{style:[v.tool,R>1&&v.tool_on],onPress:()=>M(A=>A>1?1:Er),accessibilityRole:"button",accessibilityLabel:"Ph\xF3ng to",children:(0,C.jsxs)(w.Text,{style:[v.zoom_text,R>1&&v.zoom_text_on],children:[Math.round(R*10)/10,"x"]})}),Qe&&(0,C.jsx)(ln,{style:[v.tool,E&&v.tool_on],onPress:()=>k(A=>!A),accessibilityRole:"button",accessibilityLabel:"\u0110\xE8n pin",accessibilityState:{selected:E},children:(0,C.jsx)(w.Text,{style:[v.torch_icon,E&&v.zoom_text_on],children:"\u26A1\uFE0E"})})]})})]})})},ts="rgba(0,0,0,0.5)",no=50,v=w.StyleSheet.create({top:{height:`${Rr*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:dt,borderColor:ts,borderRadius:dt+Lt},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:cn,alignItems:"stretch",justifyContent:"center"},scan_glow_outer:{position:"absolute",left:0,right:0,height:cn,borderRadius:cn/2,backgroundColor:Ft,opacity:.1},scan_glow_inner:{position:"absolute",left:4,right:4,height:8,borderRadius:4,backgroundColor:Ft,opacity:.2},scan_line:{height:Gi,borderRadius:1,backgroundColor:Ft},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:no,height:no,borderRadius:no/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:Ft},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 Te=require("react"),I=require("react-native");var ee=require("react/jsx-runtime"),ro={[ve.info]:"#3B82F6",[ve.success]:"#22C55E",[ve.error]:"#EF4444"},Or=-120,pn=I.Platform.OS==="android",Ir=({type:e})=>e===ve.success?(0,ee.jsx)(I.View,{style:pe.check_mark}):e===ve.error?(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)(I.View,{style:[pe.cross_bar,pe.cross_a]}),(0,ee.jsx)(I.View,{style:[pe.cross_bar,pe.cross_b]})]}):(0,ee.jsxs)(ee.Fragment,{children:[(0,ee.jsx)(I.View,{style:pe.info_dot}),(0,ee.jsx)(I.View,{style:pe.info_bar})]}),Fr=()=>{let e=Y(Tt,h=>h.message),t=Y(Tt,h=>h.type),n=Y(Tt,h=>h.tick),o=(0,Te.useRef)(new I.Animated.Value(Or)).current,r=(0,Te.useRef)(new I.Animated.Value(0)).current,i=(0,Te.useRef)(new I.Animated.Value(.92)).current,l=(0,Te.useRef)(new I.Animated.Value(0)).current,[s,c]=(0,Te.useState)(),[a,u]=(0,Te.useState)(!1);(0,Te.useEffect)(()=>{let h=!0;return Pt().then(p=>{h&&p&&c(()=>p)}),()=>{h=!1}},[]);let d=(0,Te.useRef)(n);return(0,Te.useEffect)(()=>{if(n===d.current)return;I.AccessibilityInfo.announceForAccessibility(e),u(!0),l.setValue(0),i.setValue(.92);let h=I.Animated.sequence([I.Animated.parallel([I.Animated.spring(o,{toValue:0,speed:16,bounciness:7,useNativeDriver:!0}),I.Animated.spring(i,{toValue:1,speed:16,bounciness:9,useNativeDriver:!0}),I.Animated.timing(r,{toValue:1,duration:140,useNativeDriver:!0}),I.Animated.sequence([I.Animated.delay(90),I.Animated.spring(l,{toValue:1,speed:18,bounciness:14,useNativeDriver:!0})])]),I.Animated.delay(Vo[t]),I.Animated.parallel([I.Animated.timing(o,{toValue:Or,duration:240,useNativeDriver:!0}),I.Animated.timing(r,{toValue:0,duration:200,useNativeDriver:!0})])]);return h.start(({finished:p})=>{p&&u(!1)}),()=>h.stop()},[n]),a?(0,ee.jsx)(I.View,{style:[pe.layer,{top:pt().top+(pn?12:8)}],pointerEvents:"none",children:(0,ee.jsxs)(I.Animated.View,{style:[pe.toast,pn&&pe.toast_android,!!s&&pe.toast_glass,{opacity:s?1:r,transform:[{translateY:o},{scale:i}]}],accessibilityLiveRegion:"polite",children:[s&&(0,ee.jsx)(s,{style:pe.glass_fill,glassEffectStyle:"regular",colorScheme:"dark",tintColor:"rgba(24,24,27,0.55)"}),pn?(0,ee.jsx)(I.Animated.View,{style:[pe.badge_halo,{backgroundColor:`${ro[t]}33`,transform:[{scale:l}]}],children:(0,ee.jsx)(I.View,{style:[pe.badge,{backgroundColor:ro[t]}],children:(0,ee.jsx)(Ir,{type:t})})}):(0,ee.jsx)(I.Animated.View,{style:[pe.badge,{backgroundColor:ro[t],transform:[{scale:l}]}],children:(0,ee.jsx)(Ir,{type:t})}),(0,ee.jsx)(I.Text,{style:[pe.message,pn&&pe.message_android],numberOfLines:2,children:e})]})}):null},pe=I.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:I.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 ue=Ue({active_key:null,instances:{}}),Lr=({app:e,instance_id:t,context:n={},url_params:o={},host_data:r={}},i)=>{var s;let l=(s=D().keep_alive)==null?void 0:s.max_webviews;ue.setState(c=>{let a=t!=null?t:e.app_id,u={...c.instances,[a]:{key:a,app:e,context:n,url_params:o,host_data:r,last_used_at:Date.now()}},d=Object.keys(u);return l&&l>0&&d.length>l&&d.filter(h=>h!==a).sort((h,p)=>u[h].last_used_at-u[p].last_used_at).slice(0,d.length-l).forEach(h=>{delete u[h]}),i?{active_key:a,instances:u}:{instances:u}})},Dr=e=>Lr(e,!0),Ur=e=>Lr(e,!1),gt=()=>ue.setState({active_key:null}),un=e=>{ue.setState(t=>{if(t.active_key===e||!t.instances[e])return{};let n={...t.instances};return delete n[e],{instances:n}})};var Nr="catalog",ns="paused_apps",os="removed_apps",rs=10*1e3,is=2,ss=3e3,as=()=>{var e;try{return JSON.parse((e=D().storage.getString(Nr))!=null?e:"{}")}catch{return{}}},N=Ue({catalog:{},downloads:{},pause_reasons:[],updates:{},apply_ticks:{}}),Vr=e=>{var t;return!!((t=D().manual_update)!=null&&t.includes(e))},hn=new Set,Br=e=>{let t=new Set,n=()=>D().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=D().storage.getString(e))!=null?o:"[]");Array.isArray(r)&&r.forEach(i=>{typeof i=="string"&&t.add(i)})}catch{}}}},Oe=Br(ns),Ye=Br(os);Kt(()=>{Oe.load(),Ye.load();let e=as(),t={};Object.keys(e).filter(n=>!Ye.has(n)).forEach(n=>{let o=W(n);o?t[n]={status:"installed",progress:1,version:o.version,has_local:!0}:Oe.has(n)&&(t[n]={status:"paused",progress:0,version:e[n].version,has_local:!1})}),N.setState({catalog:e,downloads:t})});var ht=e=>Y(N,t=>e?t.downloads[e]:void 0),Hr=()=>Y(N,e=>e.pause_reasons.length>0),Re=(...e)=>we("queue",...e),ae=[],qe={},U=null,dn=new Set,ot={},io=new Set,ze=e=>{io.forEach(t=>{try{t(e)}catch(n){console.warn("[miniapp-queue] event listener error",n==null?void 0:n.message)}})},mn=e=>(io.add(e),()=>{io.delete(e)}),qr=()=>N.getState().downloads,Ae=(e,t)=>{let n=!!W(e),o=N.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};N.setState(l=>({downloads:{...l.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?ze({type:"status_change",app_id:e,state:i}):o.progress!==i.progress&&ze({type:"progress",app_id:e,progress:i.progress,version:i.version})},gn=(e,t)=>{var n;(n=ot[e])==null||n.forEach(o=>o(t)),delete ot[e]},ls=()=>N.getState().pause_reasons.length>0,Ke=e=>{var s;if(U)return;let t=e?ae.indexOf(e):ls()?-1:ae.findIndex(c=>!Oe.has(c));if(t<0||t>=ae.length)return;let[n]=ae.splice(t,1),o=N.getState().catalog[n];if(!o){gn(n,W(n)),Ke();return}let r=Date.now();qe[n]=((s=qe[n])!=null?s:0)+1,Ae(n,{status:"downloading",progress:0,version:o.version,error:void 0});let i=0,l=to(o,{onProgress:c=>{let a=Math.floor(c*100);a!==i&&(i=a,Ae(n,{progress:a/100,version:o.version}))}});U={app_id:n,handle:l,forced:!!e},Re("start",n,o.version,e?"(forced)":""),l.promise.then(c=>{Re("installed",n,o.version,`${Date.now()-r}ms`),Ae(n,{status:"installed",progress:1,version:o.version}),gn(n,c)}).catch(c=>{var u;if(c instanceof ut){if(dn.has(n))return;Re("paused",n),qe[n]-=1,ae.unshift(n),Ae(n,{status:Oe.has(n)?"paused":"queued",progress:0,version:o.version});return}let a=String((u=c==null?void 0:c.message)!=null?u:c);if(console.warn("[miniapp-queue] failed",n,a),qe[n]<is){Ae(n,{status:"queued",progress:0,version:o.version,error:a}),setTimeout(()=>{var d;ae.includes(n)||(U==null?void 0:U.app_id)===n||(ae.push(n),Ke((d=ot[n])!=null&&d.length?n:void 0))},ss);return}Ae(n,{status:"failed",progress:0,version:o.version,error:a}),gn(n,W(n))}).finally(()=>{U=null;let c=ae.find(a=>{var u;return(u=ot[a])==null?void 0:u.length});Ke(c)})},fn=(e,{front:t=!1}={})=>{if((U==null?void 0:U.app_id)===e)return;let n=ae.indexOf(e);if(n>=0){if(!t)return;ae.splice(n,1)}t?ae.unshift(e):ae.push(e)},cs=async e=>{let{host_id:t,client_token:n}=D(),o=new AbortController,r=setTimeout(()=>o.abort(),rs);try{let i=`${at}/api/hosts/${encodeURIComponent(t)}/miniapps?channel=${e}`,l=await fetch(i,{headers:{Authorization:`Bearer ${n}`,"Cache-Control":"no-cache"},signal:o.signal});if(!l.ok)throw new Error(`host list ${e} ${l.status}`);return(await l.json()).apps.map(c=>({...c,channel:e}))}finally{clearTimeout(r)}},Dt=null,yn=()=>(Dt!=null||(Dt=(async()=>{var t;let e=Date.now();try{let n=await Promise.all(D().channels.map(cs)),o={};[...n].reverse().flat().forEach(c=>{o[c.app_id]=c});let r=Object.keys(N.getState().catalog).filter(c=>!o[c]);D().storage.setString(Nr,JSON.stringify(o)),N.setState({catalog:o}),await Promise.all(r.map(c=>zr(c,{by_user:!1}))),r.forEach(c=>Ye.delete(c));let i=Object.keys(o).filter(c=>!Ye.has(c)),l=[],s={};for(let c of i.map(a=>o[a])){if(await Zn(c)){Ae(c.app_id,{status:"installed",progress:1,version:c.version});continue}let a=W(c.app_id);if(Vr(c.app_id)&&!hn.has(c.app_id)&&a&&await He(a)){Ae(c.app_id,{status:"installed",progress:1,version:a.version}),s[c.app_id]={app_id:c.app_id,current_version:a.version,next_version:c.version};continue}l.push(c)}return N.setState({updates:s}),l.forEach(c=>{qe[c.app_id]=0,Ae(c.app_id,{status:Oe.has(c.app_id)?"paused":"queued",progress:0,version:c.version,error:void 0}),fn(c.app_id)}),Re("catalog",i.length,"apps, outdated",l.map(c=>c.app_id),"removed",r,`${Date.now()-e}ms`),ze({type:"sync_complete",app_ids:i,removed:r}),Object.values(s).forEach(c=>ze({type:"update_available",...c})),Ke(),{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),ze({type:"sync_failed",error:o}),{ok:!1,error:o}}finally{Dt=null}})()),Dt),zr=async(e,{by_user:t})=>{var r,i,l,s;if(t&&Ye.add(e),dn.has(e))return;dn.add(e),Oe.delete(e);let n=ae.indexOf(e);n>=0&&ae.splice(n,1),(U==null?void 0:U.app_id)===e&&U.handle.cancel();let o=(s=(l=(r=N.getState().downloads[e])==null?void 0:r.version)!=null?l:(i=W(e))==null?void 0:i.version)!=null?s:"";Ae(e,{status:"uninstalling",progress:0,version:o}),await Mr(e),un(e),N.setState(c=>{let a={...c.downloads};return delete a[e],{downloads:a}}),delete qe[e],dn.delete(e),gn(e,null),Re("uninstalled",e,t?"(user)":"(not in list)"),ze({type:"uninstalled",app_id:e})},$r=e=>zr(e,{by_user:!0}),Wr=e=>{let t=mt(e);return t?(Ye.delete(e),(U==null?void 0:U.app_id)===e||ae.includes(e)||(qe[e]=0,Ae(e,{status:Oe.has(e)?"paused":"queued",progress:0,version:t.version,error:void 0}),fn(e),Ke(),Re("restore",e)),!0):!1},jr=e=>{if(Oe.has(e))return;if(Oe.add(e),Re("pause app",e),(U==null?void 0:U.app_id)===e&&!U.forced){U.handle.cancel();return}let t=N.getState().downloads[e];ae.includes(e)&&t&&Ae(e,{status:"paused",progress:0,version:t.version})},Gr=e=>{if(!Oe.delete(e))return;Re("resume app",e);let t=N.getState().downloads[e];(t==null?void 0:t.status)==="paused"&&!ae.includes(e)&&mt(e)&&(qe[e]=0,fn(e)),ae.includes(e)&&t&&Ae(e,{status:"queued",progress:0,version:t.version}),Ke()},Jr=e=>{let{pause_reasons:t}=N.getState();t.includes(e)||(N.setState({pause_reasons:[...t,e]}),Re("pause",e),t.length===0&&ze({type:"pause_change",paused:!0,reasons:[e]}),U&&!U.forced&&U.handle.cancel())},Kr=e=>{let{pause_reasons:t}=N.getState();if(!t.includes(e))return;let n=t.filter(o=>o!==e);N.setState({pause_reasons:n}),Re("resume",e),n.length===0&&ze({type:"pause_change",paused:!1,reasons:n}),Ke()},so=e=>N.getState().updates[e],bn=async e=>{var n,o;let t=so(e);hn.add(e);try{let r=await Ut(e),i=(o=t==null?void 0:t.next_version)!=null?o:(n=mt(e))==null?void 0:n.version;return!r||!i||r.version!==i?!1:(N.setState(l=>{var c;let s={...l.updates};return delete s[e],{updates:s,apply_ticks:{...l.apply_ticks,[e]:((c=l.apply_ticks[e])!=null?c:0)+1}}}),Re("updated",e,t==null?void 0:t.current_version,"\u2192",r.version),ze({type:"update_applied",app_id:e,version:r.version}),!0)}finally{hn.delete(e)}},Yr=()=>Object.values(N.getState().catalog).map(e=>({...e,installed:!!W(e.app_id),removed_by_user:Ye.has(e.app_id)})),mt=e=>N.getState().catalog[e],Ut=async e=>{let t=mt(e);if(!t)return;if(Oe.delete(e),Ye.delete(e),await Zn(t))return W(e);let n=W(e);if(Vr(e)&&!hn.has(e)&&n&&await He(n))return n;let o=new Promise(r=>{var i;((i=ot[e])!=null?i:ot[e]=[]).push(r)});return(U==null?void 0:U.app_id)===e?U.forced=!0:(qe[e]=0,fn(e,{front:!0}),U&&!U.forced?U.handle.cancel():Ke(e)),o};var H=require("react/jsx-runtime"),ao=e=>(e!=null?e:"").replace(/\?[^#]*/,""),Xr=0,ps=()=>{let e=new Set;return{emit:t=>e.forEach(n=>n(t)),subscribe:t=>(e.add(t),()=>{e.delete(t)})}},us=S.default.memo(({instance_key:e,is_active:t,is_front:n,is_dark:o,reload_tick:r,web_at_top:i,splash:l,bridge:s,opaque_background:c,allow_embedded_miniapps:a,onWebLoadEnd:u})=>{var jt,Gt;let d=(0,S.useRef)(null),h=(0,S.useRef)(!1),p=Y(ue,f=>f.instances[e]),m=p==null?void 0:p.app.app_id,E=p==null?void 0:p.app.manifest_url,k=p==null?void 0:p.context,R=p==null?void 0:p.url_params,M=Y(se,f=>{var _;return((_=f.active)==null?void 0:_.owner)===e?f.active:null}),[z,Q]=(0,S.useState)(null),[oe,Se]=(0,S.useState)(M);M!==oe&&(Se(M),M?Q(null):(oe==null?void 0:oe.layout)===_e.top&&Q(oe));let $=(M==null?void 0:M.layout)===_e.top?M:z,[T,y]=(0,S.useState)(()=>m?W(m):null),[F,P]=(0,S.useState)(!1),[j,ke]=(0,S.useState)(0),[re,B]=(0,S.useState)(0),[ge,te]=(0,S.useState)(!1),le=(0,S.useRef)(null),he=f=>{le.current&&clearTimeout(le.current),le.current=setTimeout(()=>{le.current=null,te(!0)},f)};(0,S.useEffect)(()=>()=>{le.current&&clearTimeout(le.current)},[]),(0,S.useEffect)(()=>{if(!m||!t&&T)return;let f=!0;return P(!1),(async()=>{let _=W(m),A=_?await He(_):!1;if(!f||(y(A?fe=>!fe||fe.version!==_.version||fe.permissions.join(",")!==_.permissions.join(",")?_:fe:null),__DEV__&&Date.now()-Xr>1e4&&(Xr=Date.now(),await yn()),!f))return;let K=await Ut(m),me=K!==void 0?K:E?await Cr(m,E):W(m);if(f){if(!me){P(!0);return}y(fe=>fe!=null?fe:me)}})(),()=>{f=!1}},[t,m,E,j]),(0,S.useEffect)(()=>Tr(e,f=>d.current?(d.current.postMessage(f),!0):!1),[e]);let Ie=Y(N,f=>{let _=m?f.downloads[m]:void 0;return(_==null?void 0:_.status)==="installed"?_.version:void 0});(0,S.useEffect)(()=>{if(t||!m||!T)return;let f=W(m);if(!f||f.version===T.version)return;let _=!0;return He(f).then(A=>{!_||!A||(we(`webview:${e}`,"\u0111\u1ED5i bundle (\u1EA9n)",T.version,"\u2192",f.version),y(f))}),()=>{_=!1}},[t,m,Ie,T==null?void 0:T.version]);let Fe=Y(N,f=>{var _;return m&&(_=f.apply_ticks[m])!=null?_:0});(0,S.useEffect)(()=>{if(!Fe||!m)return;let f=W(m);if(!f||f.version===(T==null?void 0:T.version))return;let _=!0;return He(f).then(A=>{!_||!A||(we(`webview:${e}`,"c\u1EADp nh\u1EADt",T==null?void 0:T.version,"\u2192",f.version),te(!1),y(f))}),()=>{_=!1}},[Fe]),(0,S.useEffect)(()=>{var A;let f=(A=D().keep_alive)==null?void 0:A.idle_close_ms;if(t||!f||f<=0)return;let _=setTimeout(()=>{un(e)},f);return()=>clearTimeout(_)},[t,e]),(0,S.useEffect)(()=>{r>0&&(P(!1),te(!1),B(f=>f+1),ke(f=>f+1))},[r]);let st=(0,S.useRef)(t);(0,S.useEffect)(()=>{var f;st.current!==t&&(st.current=t,h.current&&((f=d.current)==null||f.injectJavaScript(gr(t?"resumed":"paused"))))},[t]);let Le=`${(jt=T==null?void 0:T.version)!=null?jt:"none"}:${(Gt=T==null?void 0:T.permissions.join(","))!=null?Gt:""}:${re}`,Be=(0,S.useMemo)(()=>JSON.stringify([k!=null?k:{},R!=null?R:{}]),[k,R]),_t=(0,S.useMemo)(()=>{var f;return br(R!=null?R:{},(f=T==null?void 0:T.permissions)!=null?f:[])},[Be,T==null?void 0:T.permissions]),kn=(0,S.useMemo)(()=>fr(k!=null?k:{},_t)+ur()+dr()+(D().debug?pr():""),[_t]),Qe=(0,S.useRef)(null),At=(0,S.useRef)(null);(0,S.useEffect)(()=>{var _,A,K;if(!T)return;if(At.current!==Le){At.current=Le,Qe.current=Be;return}if(Qe.current===Be)return;let f=((A=JSON.parse((_=Qe.current)!=null?_:"[]")[0])!=null?A:{}).org_id;if(Qe.current=Be,f===(k==null?void 0:k.org_id)&&h.current){te(!1),he(1500),(K=d.current)==null||K.injectJavaScript(hr(k!=null?k:{},_t));return}te(!1),B(me=>me+1)},[Be,T,Le]),(0,S.useEffect)(()=>(t||(Ne(e),Je(e),et(e)),()=>{Ne(e),Je(e),et(e)}),[t,e,Le,r]),(0,S.useEffect)(()=>{let f=V.AppState.addEventListener("change",_=>{_==="background"&&!jo()&&Ne(e),_==="background"&&!Qo()&&Je(e)});return()=>f.remove()},[e]);let St=(0,S.useCallback)(async f=>{var A,K,me,fe,On,go;let _=sr(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(Z=>{console.warn("[miniapp] onWebEvent l\u1ED7i",m,Z)})}catch(Z){console.warn("[miniapp] onWebEvent l\u1ED7i",m,Z)}return}if(_.method==="log"){let{level:Z,text:ne}=_;we(`web:${e}`,Z!=null?Z:"log",ne!=null?ne:"");return}if(_.method==="pong"){le.current||te(!0);return}if(_.method==="touchAtTop"){i.emit(!!_.at_top);return}if(_.method==="contextApplied"){le.current&&clearTimeout(le.current),le.current=null,te(!0);return}if(_.method==="ready"){h.current=!0,te(!0);let Z=(A=ue.getState().instances[e])==null?void 0:A.context;Z&&((K=d.current)==null||K.injectJavaScript(jn(Z)));return}try{let Z=await _r(_,{getHostData:()=>{var ne,Me;return(Me=(ne=ue.getState().instances[e])==null?void 0:ne.host_data)!=null?Me:{}},getPermissions:()=>{var ne,Me;return m?(Me=(ne=W(m))==null?void 0:ne.permissions)!=null?Me:[]:[]},getContext:()=>{var ne,Me;return(Me=(ne=ue.getState().instances[e])==null?void 0:ne.context)!=null?Me:{}},is_dark:o,close:gt,app_id:m!=null?m:"",instance_id:e,options:s,emit:(ne,Me)=>{var ho;(ho=d.current)==null||ho.injectJavaScript(cr(ne,Me))},playBeep:(me=s==null?void 0:s.playScannerBeep)!=null?me:(()=>{var ne;(ne=d.current)==null||ne.injectJavaScript(wr())}),isActive:()=>ue.getState().active_key===e&&V.AppState.currentState!=="background"});_.id&&((fe=d.current)==null||fe.injectJavaScript(ar(_.id,Z)))}catch(Z){if(!_.id)return;let ne=Z==null?void 0:Z.code,Me=Z instanceof g?Z:new g(typeof ne=="string"?ne:"HOST_ERROR",String((On=Z==null?void 0:Z.message)!=null?On:Z));(go=d.current)==null||go.injectJavaScript(lr(_.id,Me))}},[e,o,m,i,s]),Rn=(0,S.useCallback)(()=>{P(!1),B(f=>f+1),ke(f=>f+1)},[]);return(0,H.jsxs)(V.View,{style:[V.StyleSheet.absoluteFill,c&&{backgroundColor:o?"#09090B":"#FFFFFF"},!n&&Pe.behind],pointerEvents:t?"auto":"none",children:[$&&(0,H.jsx)(oo,{scanner:$,closing:$===z,onClosed:()=>{var f;Q(null),$.absolute&&((f=d.current)==null||f.injectJavaScript(Gn(0)))},onHeight:$.absolute?f=>{var _;return(_=d.current)==null?void 0:_.injectJavaScript(Gn(f))}:void 0}),T?(0,H.jsx)(Zr.default,{ref:d,source:{uri:T.entry_uri},originWhitelist:["*"],hideKeyboardAccessoryView:!0,mediaPlaybackRequiresUserAction:!1,allowingReadAccessToURL:`file://${a?Yn():T.dir}`,allowFileAccess:!0,allowFileAccessFromFileURLs:!0,allowUniversalAccessFromFileURLs:!0,injectedJavaScriptBeforeContentLoaded:kn,onMessage:St,onShouldStartLoadWithRequest:f=>{let _=f.url;return f.isTopFrame===!1||!/^https?:\/\//i.test(_)?!0:(Promise.resolve(s!=null&&s.openUrl?s.openUrl(_):V.Linking.openURL(_)).catch(()=>{}),!1)},setSupportMultipleWindows:!1,bounces:!1,overScrollMode:"never",onLoadStart:f=>{Ne(e),Je(e),et(e),we(`webview:${e}`,"load start",ao(f.nativeEvent.url)),h.current=!1,te(!1)},onError:f=>{Ne(e),Je(e),et(e),we(`webview:${e}`,"load error",ao(f.nativeEvent.url),f.nativeEvent.description),P(!0),te(!1)},onLoadEnd:f=>{let _=f.nativeEvent.url;we(`webview:${e}`,"load end",ao(_)),m&&(u==null||u({app_id:m,instance_id:e,url:_})),he(1500)},onContentProcessDidTerminate:()=>{Ne(e),Je(e),et(e),h.current=!1,te(!1),B(f=>f+1)},onRenderProcessGone:()=>(Ne(e),Je(e),et(e),h.current=!1,te(!1),B(f=>f+1),!0),style:Pe.webview},Le):null,(M==null?void 0:M.layout)===_e.full&&(0,H.jsx)(oo,{scanner:M}),p&&(0,H.jsx)(gs,{visible:!T||!ge,interactive:F,children:(0,H.jsx)(ds,{splash:l,app:p.app,is_dark:o,error:F,has_bundle:!!T,retry:Rn})})]})}),ds=S.default.memo(({splash:e,app:t,is_dark:n,error:o,has_bundle:r,retry:i})=>{let l=e,s=ht(t.app_id),c=o?"error":!r&&(s==null?void 0:s.status)==="downloading"?"downloading":"loading";return(0,H.jsx)(l,{app:t,is_dark:n,status:c,progress:c==="downloading"?s==null?void 0:s.progress:void 0,retry:i})}),gs=({visible:e,interactive:t,children:n})=>{let o=(0,S.useRef)(new V.Animated.Value(e?1:0)).current,[r,i]=(0,S.useState)(e);return(0,S.useEffect)(()=>{if(e){i(!0),o.setValue(1);return}let l=V.Animated.timing(o,{toValue:0,duration:180,useNativeDriver:!0});return l.start(({finished:s})=>{s&&i(!1)}),()=>l.stop()},[e,o]),r?(0,H.jsx)(V.Animated.View,{style:[V.StyleSheet.absoluteFill,{opacity:o}],pointerEvents:t?"auto":"none",children:n}):null},lo=({app:e,is_dark:t,status:n,progress:o,retry:r})=>{let i=t?"#FAFAFA":"#18181B";return(0,H.jsxs)(V.View,{style:[Pe.splash,{backgroundColor:t?"#09090B":"#FFFFFF"}],children:[(0,H.jsx)(V.View,{style:[Pe.splash_icon,{backgroundColor:t?"#18181B":"#F4F4F5"}],children:e.icon?(0,H.jsx)(V.Image,{source:{uri:e.icon},style:Pe.splash_icon_image}):(0,H.jsx)(V.Text,{style:Pe.splash_letter,children:(e.name||"?").slice(0,1).toUpperCase()})}),(0,H.jsx)(V.Text,{style:[Pe.splash_name,{color:i}],children:e.name}),n==="error"?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(V.Text,{style:Pe.splash_hint,children:"Kh\xF4ng t\u1EA3i \u0111\u01B0\u1EE3c mini app"}),(0,H.jsx)(V.TouchableOpacity,{activeOpacity:.7,style:[Pe.retry_button,{backgroundColor:t?"#27272A":"#F4F4F5"}],onPress:r,children:(0,H.jsx)(V.Text,{style:[Pe.retry_text,{color:i}],children:"Th\u1EED l\u1EA1i"})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(V.ActivityIndicator,{style:Pe.splash_spinner,color:t?"#A1A1AA":"#71717A"}),n==="downloading"&&(0,H.jsxs)(V.Text,{style:Pe.splash_hint,children:["\u0110ang t\u1EA3i mini app",o?` ${Math.round(o*100)}%`:"\u2026"]})]})]})},Qr=(e,t)=>{let n=(0,S.useRef)(t),o=(0,S.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.`))},hs=({container:e,splash:t=lo,is_dark:n=!1,bridge:o,close_on_back:r=!0,opaque_background:i=!0,allow_embedded_miniapps:l=!1,onWebLoadEnd:s})=>{Qr("container",e),Qr("splash",t);let c=e,a=Y(ue,M=>M.active_key),u=(0,S.useRef)(a);a&&(u.current=a);let d=Y(ue,M=>Object.keys(M.instances).join("|")),h=Y(ue,M=>{var z;return M.active_key?(z=M.instances[M.active_key])==null?void 0:z.app.name:void 0}),p=(0,S.useMemo)(()=>d?d.split("|"):[],[d]),[m,E]=(0,S.useState)({}),k=(0,S.useRef)(ps()).current;(0,S.useEffect)(()=>{if(!a||!r)return;let M=V.BackHandler.addEventListener("hardwareBackPress",()=>(gt(),!0));return()=>M.remove()},[a,r]);let R=(0,S.useCallback)(()=>{let M=ue.getState().active_key;M&&E(z=>({...z,[M]:(z[M]||0)+1}))},[]);return p.length?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(c,{visible:!!a,title:h!=null?h:"",is_dark:n,close:gt,reload:R,subscribeWebAtTop:k.subscribe,children:p.map(M=>(0,H.jsx)(us,{instance_key:M,is_active:a===M,is_front:(a!=null?a:u.current)===M,is_dark:n,reload_tick:m[M]||0,web_at_top:k,splash:t,bridge:o,opaque_background:i,allow_embedded_miniapps:l,onWebLoadEnd:s},M))}),(0,H.jsx)(Fr,{})]}):null},Pe=V.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"}}),ei=S.default.memo(hs);var $e=require("react");var ni=e=>`changelog_seen:${e}`,ms=10*1e3,_n=e=>D().storage.getString(ni(e))||null,ft=(e,t=(n=>(n=W(e))==null?void 0:n.version)())=>{t&&D().storage.setString(ni(e),t)},po=e=>{var o;let t=(o=W(e))==null?void 0:o.version;if(!t)return null;let n=_n(e);return n?eo(t,n)>0?{app_id:e,from:n,to:t}:null:(ft(e,t),null)},fs=e=>{var t,n,o;return(o=(n=(t=N.getState().catalog[e])==null?void 0:t.channel)!=null?n:D().channels[0])!=null?o:"production"},An=async(e,{from:t,to:n,channel:o=fs(e)}={})=>{let{client_token:r}=D(),i=new URLSearchParams({channel:o});t&&i.set("from",t),n&&i.set("to",n);let l=new AbortController,s=setTimeout(()=>l.abort(),ms);try{let c=await fetch(`${at}/api/miniapps/${encodeURIComponent(e)}/changelog?${i}`,{headers:{Authorization:`Bearer ${r}`},signal:l.signal});if(!c.ok)throw new Error(`changelog ${e} ${c.status}`);return(await c.json()).versions}finally{clearTimeout(s)}},Sn=(e,{from:t,to:n,enabled:o=!0}={})=>{let[r,i]=(0,$e.useState)([]),[l,s]=(0,$e.useState)(!1),[c,a]=(0,$e.useState)(),[u,d]=(0,$e.useState)(0),h=(0,$e.useCallback)(()=>d(p=>p+1),[]);return(0,$e.useEffect)(()=>{if(!e||!o)return;let p=!0;return s(!0),a(void 0),An(e,{from:t,to:n}).then(m=>{p&&i(m)}).catch(m=>{var E;p&&a(String((m==null?void 0:m.name)==="AbortError"?"timeout":(E=m==null?void 0:m.message)!=null?E:m))}).finally(()=>{p&&s(!1)}),()=>{p=!1}},[e,t,n,o,u]),{versions:r,loading:l,error:c,reload:h}},Nt=Ue({request:null}),co=!1,ys=e=>{var t,n;return(n=(t=N.getState().catalog[e])==null?void 0:t.name)!=null?n:e},wn=async(e,{name:t}={})=>{if(Nt.getState().request||co)return!1;let n=po(e);if(!n)return!1;co=!0;try{let o=await An(e,{from:n.from,to:n.to});return o.length?(Nt.setState({request:{...n,name:t!=null?t:ys(e),versions:o}}),!0):(ft(e,n.to),!1)}catch(o){return we("changelog failed",e,o),!1}finally{co=!1}},Mn=()=>{let{request:e}=Nt.getState();e&&ft(e.app_id,e.to),Nt.setState({request:null})},vn=()=>Y(Nt,e=>e.request),ti=!1;Kt(()=>{if(ti)return;ti=!0;let e=()=>D().changelog!==!1;mn(n=>{n.type==="status_change"&&n.state.status==="installed"&&!_n(n.app_id)&&ft(n.app_id,n.state.version),n.type==="update_applied"&&e()&&wn(n.app_id)});let t=ue.getState().active_key;ue.subscribe(()=>{let{active_key:n,instances:o}=ue.getState();if(n===t)return;t=n;let r=n?o[n]:void 0;r&&e()&&wn(r.app.app_id,{name:r.app.name})})});var it=ye(require("react"));var We=require("react"),x=require("react-native");var de=require("react-native");var bs=/\*\*(.+?)\*\*|`([^`]+)`|\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,Vt=e=>{var o;let t=[],n=0;for(let r of e.matchAll(bs)){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},oi=e=>Vt(e).map(t=>t.text).join("");var Xe=require("react-native");var yt=require("react"),si=require("react/jsx-runtime"),xn={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",date_locale:"vi-VN"},Cn=(e,t)=>e.replace(/\{(\w+)\}/g,(n,o)=>o in t?String(t[o]):n),Tn=[{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"}],Ve={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},ws={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},_s={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)"}},uo=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),Bt=(e={},t)=>{let{kinds:n,dark:o=!1,...r}=e;return{...o?ws:Ve,...uo(r),dark:o,labels:{...xn,...uo(t!=null?t:{})},kinds:Tn.map(i=>{var l;return{...i,...o?_s[i.key]:null,...i.key==="new"&&e.primary?{color:e.primary}:null,...uo((l=n==null?void 0:n[i.key])!=null?l:{})}})}},ri=(0,yt.createContext)(void 0),As=Bt(),bt=({theme:e,labels:t,children:n})=>{let o=(0,yt.useMemo)(()=>Bt(e,t),[e,t]);return(0,si.jsx)(ri.Provider,{value:o,children:n})},Ee=()=>{var e;return(e=(0,yt.useContext)(ri))!=null?e:As},Ht=e=>({new:e.flatMap(t=>t.changelog.new),fix:e.flatMap(t=>t.changelog.fix),improve:e.flatMap(t=>t.changelog.improve)}),ii=(e,t)=>{let n=new Date(e);return Number.isNaN(n.getTime())?"":n.toLocaleDateString(t)};var G={blue:Ve.primary,track:"#E5E5EA",overlay:Ve.overlay,shadow:"#000000",title:Ve.text,sub_title:Ve.text_secondary,error:"#D92D20",hint:Ve.hint,surface:Ve.surface,background:Ve.background},ai=Xe.Platform.select({ios:{shadowColor:G.shadow,shadowOffset:{width:0,height:10},shadowOpacity:.1,shadowRadius:20},android:{elevation:10}}),b=Xe.StyleSheet.create({overlay:{flex:1,backgroundColor:G.overlay,justifyContent:"center",alignItems:"center"},container:{width:"85%",maxWidth:340,backgroundColor:G.surface,padding:24,borderRadius:28,alignItems:"center",...ai},sheet:{width:"88%",maxWidth:380,maxHeight:"78%",backgroundColor:G.surface,borderRadius:28,overflow:"hidden",...ai},sheet_head:{alignItems:"center",paddingTop:24,paddingHorizontal:22,paddingBottom:4},sheet_name:{fontSize:13,color:G.sub_title,marginTop:4,maxWidth:"100%"},version_pill:{flexDirection:"row",alignItems:"center",gap:6,marginTop:10,paddingHorizontal:12,paddingVertical:5,borderRadius:999,backgroundColor:G.background},version_old:{fontSize:13,color:G.sub_title,fontVariant:["tabular-nums"]},version_arrow:{fontSize:13,color:G.hint},version_new:{fontSize:13,fontWeight:"700",color:G.blue,fontVariant:["tabular-nums"]},sheet_foot:{paddingHorizontal:22,paddingTop:4,paddingBottom:18},sheet_foot_divider:{borderTopWidth:Xe.StyleSheet.hairlineWidth,borderTopColor:"rgba(60, 60, 67, 0.18)"},logo:{width:64,height:64,borderRadius:16,marginBottom:20},title:{fontSize:20,fontWeight:"700",color:G.title,textAlign:"center"},sub_title:{fontSize:13,color:G.sub_title,textAlign:"center",lineHeight:18,marginTop:6},gap:{marginBottom:15},error_text:{fontSize:12,textAlign:"center",color:G.error,lineHeight:17,marginBottom:15},progress_section:{width:"100%",alignItems:"center",paddingVertical:8,marginTop:8,gap:12},progress_text:{fontSize:18,fontWeight:"700",color:G.blue},progress_track:{width:"100%",height:6,borderRadius:3,backgroundColor:G.track,overflow:"hidden"},progress_fill:{height:"100%",borderRadius:3,backgroundColor:G.blue},loading_hint:{fontSize:12,color:G.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:G.hint},dot:{width:5,height:5,borderRadius:3,marginTop:8},more:{fontSize:14,fontWeight:"500",color:G.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:G.title},md_bold:{fontWeight:"700"},md_code:{fontFamily:Xe.Platform.select({ios:"Menlo",default:"monospace"}),fontSize:13,backgroundColor:"#F2F2F7",color:"#3A3A3C"},md_link:{color:G.blue,textDecorationLine:"underline"},full:{width:"100%"},btn_primary:{marginTop:14,backgroundColor:G.blue,paddingVertical:14,borderRadius:12,alignItems:"center"},btn_primary_text:{color:"white",fontWeight:"600",fontSize:16},btn_secondary:{paddingTop:12,alignItems:"center"},link:{color:G.blue,fontSize:15,fontWeight:"600"},history:{flex:1,backgroundColor:G.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:G.surface,...Xe.Platform.select({ios:{shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.1,shadowRadius:8},default:{borderWidth:Xe.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:Ve.text,transform:[{rotate:"45deg"}],marginLeft:4},pressed:{opacity:.6,transform:[{scale:.94}]},history_list:{padding:16,gap:12},card:{backgroundColor:G.surface,borderRadius:16,padding:16,gap:12},card_head:{flexDirection:"row",justifyContent:"space-between",alignItems:"baseline"},version:{fontSize:16,fontWeight:"700",color:G.title},date:{fontSize:13,color:G.sub_title},loading:{marginTop:40},center:{alignItems:"center",marginTop:40,gap:12},empty:{marginTop:40}});var be=require("react/jsx-runtime"),Pn=({text:e,style:t})=>{let n=Ee();return(0,be.jsx)(de.Text,{style:t,children:Vt(e.replace(/^(?:[-*•]\s+)+/,"")).map((o,r)=>{switch(o.type){case"bold":return(0,be.jsx)(de.Text,{style:b.md_bold,children:o.text},r);case"code":return(0,be.jsx)(de.Text,{style:[b.md_code,{backgroundColor:n.background,color:n.text}],children:o.text},r);case"link":return(0,be.jsx)(de.Text,{style:[b.md_link,{color:n.primary}],accessibilityRole:"link",onPress:()=>{de.Linking.openURL(o.url).catch(()=>{})},children:o.text},r);default:return o.text}})})},rt=({changelog:e,max_items:t,onMore:n})=>{let o=Ee();return(0,be.jsx)(de.View,{style:b.groups,children:o.kinds.filter(r=>e[r.key].length).map(r=>{let i=e[r.key],l=t?i.slice(0,t):i,s=i.length-l.length;return(0,be.jsxs)(de.View,{style:b.group,children:[(0,be.jsxs)(de.View,{style:b.group_head,children:[(0,be.jsx)(de.View,{style:[b.badge,{backgroundColor:r.bg}],children:(0,be.jsx)(de.Text,{style:[b.badge_text,{color:r.color}],children:r.label})}),(0,be.jsx)(de.Text,{style:[b.group_count,{color:o.hint}],children:i.length})]}),l.map((c,a)=>(0,be.jsxs)(de.View,{style:b.item,children:[(0,be.jsx)(de.View,{style:[b.dot,{backgroundColor:r.color}]}),(0,be.jsx)(Pn,{text:c,style:[b.item_text,{color:o.text}]})]},a)),s>0&&(0,be.jsx)(de.Text,{style:[b.more,{color:o.primary}],onPress:n,suppressHighlighting:!0,children:Cn(o.labels.changelog_more,{count:s})})]},r.key)})})};var wt=require("react"),L=require("react-native");var q=require("react/jsx-runtime"),En,Ss=()=>(En!=null||(En=Promise.all([L.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}))),En),Ms=()=>{let[e,t]=(0,wt.useState)({});return(0,wt.useEffect)(()=>{let n=!0;return Ss().then(o=>{n&&t(o)}),()=>{n=!1}},[]),e},vs="#1C1C1E",xs=e=>/^#[0-9a-f]{6}$/i.test(e),Cs=()=>{let[e,t]=(0,wt.useState)();return(0,wt.useEffect)(()=>{let n=!0;return Pt().then(o=>{n&&o&&t(()=>o)}),()=>{n=!1}},[]),e},Ts=({onPress:e,size:t,GlassView:n,ExpoImage:o})=>{let r=Ee(),i=r.dark?"#FFFFFF":vs;return(0,q.jsxs)(L.Pressable,{onPress:e,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Quay l\u1EA1i",style:({pressed:l})=>[b.back_btn,{width:t,height:t,borderRadius:t/2},!n&&b.back_btn_fallback,!n&&r.dark&&{backgroundColor:"#3F3F46",shadowOpacity:0},!n&&l&&b.pressed],children:[n&&(0,q.jsx)(n,{style:[L.StyleSheet.absoluteFill,{borderRadius:t/2}],glassEffectStyle:"regular",colorScheme:r.dark?"dark":"light",isInteractive:!0}),(0,q.jsx)(L.View,{pointerEvents:"none",style:b.icon_layer,children:o?(0,q.jsx)(o,{source:"sf:chevron.left",transition:0,contentFit:"contain",style:{width:20,height:20,fontSize:20,color:i}}):(0,q.jsx)(L.View,{style:[b.chevron,{borderColor:i}]})})]})},qt=({app_id:e,name:t,onBack:n,renderHeader:o})=>{let r=Ee(),i=pt(),l=Cs(),{ExpoImage:s,LinearGradient:c}=Ms(),a=l?46:42,u=o?0:i.top+a+10,{versions:d,loading:h,error:p,reload:m}=Sn(e);return(0,q.jsxs)(L.View,{style:[b.history,{backgroundColor:r.background}],children:[o&&(0,q.jsx)(L.View,{style:{paddingTop:i.top},children:o({title:r.labels.history_title,subtitle:t,onBack:n})}),h&&!d.length?(0,q.jsx)(L.ActivityIndicator,{style:[b.loading,{marginTop:u+40}],color:r.primary}):p&&!d.length?(0,q.jsxs)(L.View,{style:[b.center,{marginTop:u+40}],children:[(0,q.jsx)(L.Text,{style:[b.sub_title,{color:r.text_secondary}],children:r.labels.history_error}),(0,q.jsx)(L.TouchableOpacity,{onPress:m,children:(0,q.jsx)(L.Text,{style:[b.link,{color:r.primary}],children:r.labels.retry})})]}):(0,q.jsxs)(L.ScrollView,{contentContainerStyle:[b.history_list,{paddingTop:u+8,paddingBottom:i.bottom+24}],scrollIndicatorInsets:{top:u},children:[d.map(E=>(0,q.jsxs)(L.View,{style:[b.card,{backgroundColor:r.surface,borderRadius:Math.max(r.radius-12,0)}],children:[(0,q.jsxs)(L.View,{style:b.card_head,children:[(0,q.jsxs)(L.Text,{style:[b.version,{color:r.text}],children:["v",E.version]}),(0,q.jsx)(L.Text,{style:[b.date,{color:r.text_secondary}],children:ii(E.created_at,r.labels.date_locale)})]}),(0,q.jsx)(rt,{changelog:E.changelog})]},E.version)),!d.length&&(0,q.jsx)(L.Text,{style:[b.sub_title,b.empty,{color:r.text_secondary}],children:r.labels.history_empty})]}),!o&&(0,q.jsxs)(L.View,{pointerEvents:"box-none",style:[b.float_header,{paddingTop:i.top}],children:[c&&xs(r.background)?(0,q.jsx)(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}]}):(0,q.jsx)(L.View,{pointerEvents:"none",style:b.fade,children:Ps.map((E,k)=>(0,q.jsx)(L.View,{style:{height:k===0?u:4,backgroundColor:r.background,opacity:E}},k))}),(0,q.jsxs)(L.View,{style:b.header_row,children:[(0,q.jsx)(Ts,{onPress:n,size:a,GlassView:l,ExpoImage:s}),(0,q.jsxs)(L.View,{pointerEvents:"none",style:[b.header_title,{left:a+24,right:a+24}],children:[(0,q.jsx)(L.Text,{style:[b.history_title,{color:r.text}],numberOfLines:1,children:r.labels.history_title}),(0,q.jsx)(L.Text,{style:[b.history_sub,{color:r.text_secondary}],numberOfLines:1,children:t})]})]})]})]})},Ps=[.96,.9,.8,.68,.55,.42,.3,.18,.08];var O=require("react/jsx-runtime"),li=e=>({backgroundColor:e.primary,borderRadius:e.button_radius,height:e.button_height,paddingVertical:0,justifyContent:"center"}),Es=4,zt=({request:e,changelog:t,onClose:n,renderHistoryHeader:o,renderActions:r})=>{var h;let i=Ee(),[l,s]=(0,We.useState)(!1),[c,a]=(0,We.useState)(0),[u,d]=(0,We.useState)(0);return(0,O.jsx)(x.Modal,{visible:!0,transparent:!l,animationType:l?"slide":"fade",statusBarTranslucent:!0,onRequestClose:l?()=>s(!1):n,children:l?(0,O.jsx)(qt,{app_id:e.app_id,name:e.name,onBack:()=>s(!1),renderHeader:o}):(0,O.jsxs)(x.View,{style:[b.overlay,{backgroundColor:i.overlay}],children:[(0,O.jsx)(x.Pressable,{style:x.StyleSheet.absoluteFill,onPress:n,accessibilityLabel:"\u0110\xF3ng"}),(0,O.jsxs)(x.View,{style:[b.sheet,{backgroundColor:i.surface,borderRadius:i.radius}],children:[(0,O.jsxs)(x.View,{style:b.sheet_head,children:[(0,O.jsx)(x.Text,{style:[b.title,{color:i.text}],children:i.labels.changelog_title}),(0,O.jsx)(x.Text,{style:[b.sheet_name,{color:i.text_secondary}],numberOfLines:1,children:e.name}),(0,O.jsxs)(x.View,{style:[b.version_pill,{backgroundColor:i.background}],children:[(0,O.jsx)(x.Text,{style:[b.version_old,{color:i.text_secondary}],children:`v${e.from}`}),(0,O.jsx)(x.Text,{style:[b.version_arrow,{color:i.hint}],children:"\u2192"}),(0,O.jsx)(x.Text,{style:[b.version_new,{color:i.primary}],children:`v${e.to}`})]})]}),(0,O.jsx)(x.ScrollView,{style:b.scroll,contentContainerStyle:b.scroll_content,onContentSizeChange:(p,m)=>a(m),onLayout:p=>d(p.nativeEvent.layout.height),children:(0,O.jsx)(rt,{changelog:t,max_items:Es,onMore:()=>s(!0)})}),(0,O.jsx)(x.View,{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}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(x.TouchableOpacity,{style:[b.btn_primary,li(i)],activeOpacity:.8,onPress:n,children:(0,O.jsx)(x.Text,{style:[b.btn_primary_text,{color:i.on_primary}],children:i.labels.changelog_ok})}),(0,O.jsx)(x.TouchableOpacity,{style:b.btn_secondary,onPress:()=>s(!0),children:(0,O.jsx)(x.Text,{style:[b.link,{color:(h=i.secondary)!=null?h:i.primary}],children:i.labels.changelog_view_all})})]})})]})]})})},$t=({update:e,is_updating:t,progress:n,has_failed:o,onUpdate:r,logo:i,renderAction:l})=>{let s=Ee(),c=(0,We.useRef)(new x.Animated.Value(0)).current,a=(0,We.useRef)(new x.Animated.Value(30)).current;return(0,We.useEffect)(()=>{x.Animated.parallel([x.Animated.timing(c,{toValue:1,duration:400,useNativeDriver:!0}),x.Animated.spring(a,{toValue:0,friction:8,tension:40,useNativeDriver:!0})]).start()},[c,a]),(0,O.jsx)(x.Modal,{visible:!0,transparent:!0,animationType:"none",statusBarTranslucent:!0,onRequestClose:()=>{},children:(0,O.jsx)(x.View,{style:[b.overlay,{backgroundColor:s.overlay}],children:(0,O.jsxs)(x.Animated.View,{style:[b.container,{backgroundColor:s.surface,borderRadius:s.radius},{opacity:c,transform:[{translateY:a}]}],children:[i&&(0,O.jsx)(x.Image,{source:i,style:b.logo}),(0,O.jsx)(x.Text,{style:[b.title,{color:s.text}],children:t?s.labels.updating_title:s.labels.update_title}),!t&&(0,O.jsx)(x.Text,{style:[b.sub_title,b.gap,{color:s.text_secondary}],children:Cn(s.labels.update_message,{next:e.next_version,current:e.current_version})}),!t&&o&&(0,O.jsx)(x.Text,{style:b.error_text,children:s.labels.update_failed}),t?(0,O.jsxs)(x.View,{style:b.progress_section,children:[(0,O.jsxs)(x.Text,{style:[b.progress_text,{color:s.primary}],children:[n,"%"]}),(0,O.jsx)(x.View,{style:[b.progress_track,{backgroundColor:s.background}],children:(0,O.jsx)(x.View,{style:[b.progress_fill,{backgroundColor:s.primary,width:`${n}%`}]})}),(0,O.jsx)(x.Text,{style:[b.loading_hint,{color:s.hint}],children:s.labels.updating_hint})]}):l?(0,O.jsx)(x.View,{style:b.full,children:l({onUpdate:r,has_failed:o,label:o?s.labels.retry:s.labels.update_now})}):(0,O.jsx)(x.TouchableOpacity,{style:[b.btn_primary,b.full,li(s)],activeOpacity:.8,onPress:r,children:(0,O.jsx)(x.Text,{style:[b.btn_primary_text,{color:s.on_primary}],children:o?s.labels.retry:s.labels.update_now})})]})})})};var Wt=require("react/jsx-runtime"),ks=({app_ids:e,shouldShowUpdate:t,logo:n,renderUpdate:o,renderChangelog:r,theme:i,renderHistoryHeader:l,labels:s,renderChangelogActions:c,renderUpdateAction:a})=>{var oe,Se;let u=Y(N,$=>$.updates),h=((oe=e!=null?e:D().manual_update)!=null?oe:[]).map($=>u[$]).find($=>!!$&&(!t||t($))),p=ht(h==null?void 0:h.app_id),[m,E]=(0,it.useState)(!1),[k,R]=(0,it.useState)(!1),M=(0,it.useRef)(!1),z=vn(),Q=async()=>{if(!h||M.current)return;M.current=!0,E(!0),R(!1);let $=await bn(h.app_id);M.current=!1,E(!1),R(!$)};if(h){let $=(p==null?void 0:p.status)==="updating"?Math.round(((Se=p.progress)!=null?Se:0)*100):0,T={update:h,is_updating:m,progress:$,has_failed:k,onUpdate:Q};return(0,Wt.jsx)(bt,{theme:i,labels:s,children:o?o(T):(0,Wt.jsx)($t,{...T,logo:n,renderAction:a})})}if(z){let $={request:z,changelog:Ht(z.versions),onClose:Mn};return(0,Wt.jsx)(bt,{theme:i,labels:s,children:r?r($):(0,Wt.jsx)(zt,{...$,renderHistoryHeader:l,renderActions:c})})}return null},ci=it.default.memo(ks);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});
|