mantur-components 0.1.14-beta.6 → 0.1.14-beta.7
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.
|
@@ -3264,7 +3264,7 @@ function Lr(e, t) {
|
|
|
3264
3264
|
return /* @__PURE__ */ V("div", {
|
|
3265
3265
|
className: "flex flex-col gap-3 text-sm text-arco-text-2",
|
|
3266
3266
|
children: [/* @__PURE__ */ B("div", {
|
|
3267
|
-
className: "
|
|
3267
|
+
className: "border-arco-border-1 bg-arco-fill-1 flex flex-col overflow-hidden rounded-lg border",
|
|
3268
3268
|
children: [{
|
|
3269
3269
|
label: t.currentBalance,
|
|
3270
3270
|
value: Fr(e.balance),
|
|
@@ -3274,12 +3274,12 @@ function Lr(e, t) {
|
|
|
3274
3274
|
value: Fr(e.deductPoints),
|
|
3275
3275
|
valueClassName: "text-arco-danger-6!"
|
|
3276
3276
|
}].map((e) => /* @__PURE__ */ V("div", {
|
|
3277
|
-
className: "border-arco-border-1
|
|
3277
|
+
className: "border-arco-border-1 flex items-center justify-between gap-4 border-b px-3 py-3 last:border-b-0",
|
|
3278
3278
|
children: [/* @__PURE__ */ B("div", {
|
|
3279
|
-
className: "text-arco-text-
|
|
3279
|
+
className: "text-arco-text-2 text-sm leading-5",
|
|
3280
3280
|
children: e.label
|
|
3281
3281
|
}), /* @__PURE__ */ V("div", {
|
|
3282
|
-
className: `${e.valueClassName}
|
|
3282
|
+
className: `${e.valueClassName} text-right text-2xl leading-7 font-bold`,
|
|
3283
3283
|
children: [e.value, /* @__PURE__ */ B("span", {
|
|
3284
3284
|
className: "text-arco-text-3 ml-1 text-xs font-normal",
|
|
3285
3285
|
children: t.pointsUnit
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`@posthog/react`),require(`@arco-design/web-react`),require(`@arco-design/web-react/icon`),require(`react-i18next`),require(`react/jsx-runtime`),require(`next-themes`),require(`posthog-js`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`@posthog/react`,`@arco-design/web-react`,`@arco-design/web-react/icon`,`react-i18next`,`react/jsx-runtime`,`next-themes`,`posthog-js`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ManturComponents={},e.React,e.PostHogReact,e.ArcoDesign,e.ArcoDesignIcon,e.ReactI18next,e.jsxRuntime,e.nextThemes,e.posthog))})(this,function(e,t,n,r,i,a,o,s,c){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var l=Object.create,u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,p=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,h=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),g=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=f(t),a=0,o=i.length,s;a<o;a++)s=i[a],!m.call(e,s)&&s!==n&&u(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=d(t,s))||r.enumerable});return e},_=(e,t,n)=>(n=e==null?{}:l(p(e)),g(t||!e||!e.__esModule?u(n,`default`,{value:e,enumerable:!0}):n,e));t=_(t,1),c=_(c,1);var v=()=>{if(typeof window>`u`||!window.location?.href)throw Error(`redirectToManturMain requires currentUrl when window.location is unavailable.`);return window.location.href},y=(e,t)=>{let n=e.split(`.`);return n.length<=1?t:[t,...n.slice(1)].join(`.`)},b=e=>`${e.pathname}${e.search}${e.hash}`,x=new Set([`localhost`,`127.0.0.1`,`::1`,`[::1]`]),S=e=>x.has(e),C=e=>e.startsWith(`[`)&&e.endsWith(`]`)?e:e.includes(`:`)?`[${e}]`:e,w={82:`creative-agent`,83:`production-agent`,81:`traffic-engine`,84:`distribution-matrix`};function T(e){let t={BASE_URL:`/`,DEV:!1,MODE:`test`,PROD:!0,SSR:!1,VITE_MANTUR_STRIPE_PUBLISHABLE_KEY:`pk_test_51TJ8JiERSsQknDG7bJSIX81RFq3LcCfUXCV7mh0cQsZ2dwmYcJ5Ki6bPXynNvdyZEEBE83I6I719NIFyO9Qreey700yPAul8sv`}?.[e];return typeof t==`string`?t.trim():``}function E(e){return(typeof window>`u`?T(`VITE_APP_NAME`):window.__MANTUR_APP_NAME__||T(`VITE_APP_NAME`))?.trim()||w[e.port]||`mantur`}function D(e={}){let t=new URL(e.currentUrl||(typeof window>`u`?`http://localhost/`:v()));return{app:E(t),redirect:b(t)}}function O(e,t={}){let n=new URL(t.currentUrl||v()),r=e?.trim();if(S(n.hostname))return`${n.protocol}//${C(n.hostname)}:80/`;let i=new URL(n.toString());return r&&(i.hostname=y(n.hostname,r)),i.port=``,i.pathname=`/`,i.search=``,i.hash=``,i.toString()}function k(e,t={}){let n=O(e,t);return t.navigate!==!1&&typeof window<`u`&&(window.location.href=n),n}function A(e,t,n={}){let r=new URL(n.currentUrl||v()),i=new URL(r.toString()),a=e?.trim();a&&(i.hostname=y(r.hostname,a)),i.port=``;let o=b(r);i.pathname=`/login`,i.searchParams.set(`app`,t?.trim()),i.searchParams.set(`redirect`,o);let s=i.toString();return n.navigate!==!1&&typeof window<`u`&&(window.location.href=s),s}var j=`/api`,M=`/billing/accounts/me`,N=`mantur-points-refresh`,P=`mantur-recharge-order-created`,F=`mantur-recharge-config-change`,I=`mantur-recharge-request`,ee=`mantur-tenant-context-change`;function te(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_API_BASE__?window.__MANTUR_COMPONENTS_API_BASE__:j}function ne(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__?window.__MANTUR_COMPONENTS_POINTS_ENDPOINT__:M}function re(e){let t=new URLSearchParams;Object.entries(e).forEach(([e,n])=>{if(n!==void 0){if(Array.isArray(n)){n.length>0&&t.set(e,n.join(`,`));return}t.set(e,String(n))}});let n=t.toString();return n?`?${n}`:``}function ie(e){if(typeof document>`u`)return;let t=`${encodeURIComponent(e)}=`;return document.cookie.split(`; `).find(e=>e.startsWith(t))?.slice(t.length)}function ae(e){if(typeof document>`u`)return;let t=encodeURIComponent(e),n=window.location.hostname,r=[void 0,n],i=n.split(`.`);i.length>=2&&r.push(`.${i.slice(-2).join(`.`)}`),r.forEach(e=>{document.cookie=`${t}=; path=/; max-age=0${e?`; domain=${e}`:``}`})}function L(e){let t=JSON.parse(e||`null`);if(!t)throw Error(`Request failed`);if(t.code!==0)throw Error(t.message||`Request failed`);return t}async function R(e,t={}){let n=ie(`front-token`),r=ie(`Accept-Language`),i=t.headers||{};return n&&(i.Authorization=decodeURIComponent(n)),r&&(i[`Accept-Language`]=decodeURIComponent(r)),new Promise((n,r)=>{let a=new XMLHttpRequest;a.open(t.method||`GET`,`${te()}${e}`,!0),a.timeout=t.timeout||1e4,Object.entries(i).forEach(([e,t])=>{a.setRequestHeader(e,t)}),a.onload=()=>{try{let e=L(a.responseText);if(a.status<200||a.status>=300){r(Error(e.message||a.statusText));return}n(e)}catch(e){r(e)}},a.onerror=()=>r(Error(`Network request failed`)),a.ontimeout=()=>r(Error(`Network request timed out`)),a.send(t.body??null)})}async function oe(){try{await R(`/auth/front-logout`,{method:`DELETE`})}catch(e){console.warn(`Logout request failed, continuing local logout.`,e)}finally{ae(`front-token`),ae(`refreshToken`),typeof window<`u`&&window.location.reload()}}async function se(e){let t;if(e.avatarFile){let n=new FormData;n.append(`file`,e.avatarFile),t=(await R(`/users/me/avatar`,{method:`POST`,body:n})).data}return(await R(`/users/me`,{method:`PUT`,headers:{"Content-Type":`application/json;charset=utf-8`},body:JSON.stringify({nickname:e.nickname})})).data||t}function ce(e){let t=(...t)=>{let n=t.map(t=>e?.[t]).find(e=>e!==void 0);return typeof n==`number`?n:Number(n||0)};return{total:t(`total`,`totalPoints`,`totalBalance`,`balance`,`points`),recharge:t(`recharge`,`rechargePoints`,`rechargeBalance`,`paidPoints`),gifted:t(`gifted`,`giftedPoints`,`giftBalance`,`bonusPoints`)}}async function le(){return ce((await R(ne())).data)}async function ue(){let e=await le();return typeof window<`u`&&window.dispatchEvent(new CustomEvent(N,{detail:e})),e}function de(e){let t=Number(e);if(!Number.isFinite(t)||t<0)throw Error(`deductPoints must be a non-negative number`);return t}function fe(e){return{total:e.total??0,recharge:e.recharge??0,gifted:e.gifted??0}}async function pe(e){let t=de(e),n=fe(await ue()),r=Number(n.total||0);return{deductPoints:t,balance:r,enough:r>=t,points:n}}async function me(){return(await R(`/billing/packages`)).data||[]}async function he(){return{enabled:(await R(`/billing/recharge/config`)).data?.enabled===!0}}async function ge(e){let t=D();return(await R(`/billing/recharge/orders`,{method:`POST`,headers:{"Content-Type":`application/json;charset=utf-8`},body:JSON.stringify({uiMode:`elements`,...t,...e})})).data}async function z(e){return(await R(`/billing/recharge/orders/${encodeURIComponent(e)}`)).data}async function B(e){return(await R(`/billing/recharge/orders/${encodeURIComponent(e)}/cancel`,{method:`POST`})).data}async function _e(){return(await R(`/billing/pricing/charge-points`)).data||[]}async function ve(e){return(await R(`/billing/pricing/charge-points/${encodeURIComponent(e)}`)).data}async function V(){return(await R(`/billing/accounts/me`)).data}async function H(e){return(await R(`/billing/accounts/me/ledger${re({pageNum:e.pageNum,pageSize:e.pageSize,directions:e.directions,bizTypes:e.bizTypes,fromTime:e.fromTime,toTime:e.toTime})}`)).data||{records:[]}}function ye(e,t){return t?.tenantId?e.find(e=>e.tenantId===t.tenantId)||{tenantId:t.tenantId,tenantName:t.tenantName||t.tenantId,roles:t.roles?.map(e=>({roleCode:e,roleName:e}))}:e.find(e=>e.isOwner)||e[0]}function be(e){typeof window<`u`&&(window.__MANTUR_COMPONENTS_TENANT_CONTEXT__=e,window.dispatchEvent(new CustomEvent(ee,{detail:e})))}async function xe(){return(await R(`/users/me/tenants`)).data||[]}async function Se(){return(await R(`/auth/current-tenant`)).data}async function Ce(e){return(await R(`/auth/current-tenant/${e}`,{method:`PUT`})).data}async function we(e=`refresh`){let[t,n]=await Promise.all([xe(),Se()]),r={tenants:t,currentTenant:ye(t,n),auth:n,reason:e};return be(r),r}async function Te(e){let t=await Ce(e),n=await xe(),r={tenants:n,currentTenant:ye(n,t),auth:t,reason:`switch`};return be(r),r}var Ee={title:`Mantur`,home:`Home`,switchTeam:`Switch Team`,personalSettings:`Personal Settings`,logout:`Logout`,loading:`Loading...`,owner:`Owner`,member:`Member`,createTeam:`Create Team`,createTeamComingSoon:`Create team is coming soon`,switchedToTeam:`Switched team`,error:`Request failed`,profileTitle:`Profile`,profileNickname:`Nickname`,profileNicknamePlaceholder:`Please enter nickname`,profileAvatar:`Avatar`,profileUploadAvatar:`Upload Avatar`,profileAvatarHint:`JPG/PNG/WebP, max 2MB, max 2048px.`,profileAvatarTooLarge:`Avatar must be less than 2MB`,profileAvatarDimensionExceeded:`Avatar dimensions must be within 2048px`,profileAvatarInvalidImage:`Invalid image`,profileUpdateSuccess:`Profile updated`,profileSave:`Save`,profileCancel:`Cancel`,myPoints:`My Points`,totalBalance:`Total Balance`,rechargePoints:`Recharge Points`,giftedPoints:`Gifted Points`,recharge:`Recharge`,rechargeTitle:`Recharge Points`,pointsDetail:`Points Detail`,close:`Close`,currentBalance:`Current Balance`,pointsUnit:`points`,rechargeHint:`Recharge points are valid for 2 years after arrival.`,payNow:`Pay Now`,rechargeSuccess:`Recharge successful`,rechargeOrderCreated:`Recharge order created. Continue to complete payment.`,insufficientBalanceTitle:`Insufficient points balance`,insufficientBalanceDescription:`Current balance is {balance} {pointsUnit}; estimated deduction is {deductPoints} {pointsUnit}.`,insufficientBalanceDeductPoints:`Points to consume`,insufficientBalanceRechargeGuide:`Recharge points before continuing.`,insufficientBalanceContactAdminGuide:`Recharge is currently unavailable. Contact an administrator.`,contactAdmin:`Contact Admin`,stripePaymentTitle:`Stripe Payment`,stripePaymentDescription:`Complete card payment. Points will be credited automatically after payment succeeds.`,stripePaymentTotalAmount:`Total Amount`,stripePaymentOrderNo:`Order No.`,stripeContactDetails:`Contact Details`,stripePaymentSection:`Payment`,stripePay:`Confirm Payment`,stripePaymentLoading:`Loading Stripe payment...`,stripePaymentConfigMissing:`Stripe publishable key is not configured`,stripePaymentClientSecretMissing:`Stripe payment credential is missing from the order`,stripePaymentWindowOpenFailed:`Unable to open the payment window. Allow browser pop-ups and try again.`,stripeCheckoutClientSecretInvalid:`Invalid Stripe payment credential. The backend must return a Checkout Session client_secret that starts with cs_ and uses ui_mode elements or custom.`,stripePaymentProcessing:`Payment is processing. Please refresh points later.`,stripePaymentFailed:`Payment failed. Please try again.`,stripePaymentLoadFailed:`Failed to load Stripe payment. Please refresh and try again.`,customRechargeAmount:`Custom Amount`,customRechargeDescription:`Enter the recharge amount you need. Minimum $10 USD.`,customRechargeMinError:`Minimum recharge is $10 USD`,customRechargeEstimate:`Estimated points`,customRechargeRate:`$1 = 100 points. Package bonuses do not apply.`,selectRechargePackage:`Select a package or enter a custom amount`,all:`All`,income:`Income`,expense:`Expense`,source:`Source`,sourceAll:`All Sources`,sourceRecharge:`Recharge`,sourceGifted:`Gifted`,dateRange:`Date Range`,startDate:`Start Date`,endDate:`End Date`,dateTo:`to`,query:`Query`,refreshed:`Refreshed`,pointsDeductionTip:`Points expiring soon are deducted first.`,pointsNoteTitle:`Note`,pointsAccountNote:`Points are attached to your personal account. You recharge, consume, and manage them yourself. Others cannot recharge or use them for you. Recharge points are valid for 2 years; gifted points follow the validity set by operations.`},De={languageZh:`中文`,languageEn:`English`},Oe={title:`漫途`,home:`主页`,switchTeam:`切换团队`,personalSettings:`个人设置`,logout:`退出登录`,loading:`加载中...`,owner:`管理员`,member:`成员`,createTeam:`创建团队`,createTeamComingSoon:`创建团队功能即将上线`,switchedToTeam:`已切换团队`,error:`请求失败`,profileTitle:`个人资料`,profileNickname:`昵称`,profileNicknamePlaceholder:`请输入昵称`,profileAvatar:`头像`,profileUploadAvatar:`上传头像`,profileAvatarHint:`支持 JPG/PNG/WebP,最大 2MB,尺寸不超过 2048px。`,profileAvatarTooLarge:`头像不能超过 2MB`,profileAvatarDimensionExceeded:`头像尺寸不能超过 2048px`,profileAvatarInvalidImage:`图片无效`,profileUpdateSuccess:`个人资料已更新`,profileSave:`保存`,profileCancel:`取消`,myPoints:`我的积分`,totalBalance:`总余额`,rechargePoints:`充值积分`,giftedPoints:`赠送积分`,recharge:`去充值`,rechargeTitle:`充值积分`,pointsDetail:`积分明细`,close:`关闭`,currentBalance:`当前余额`,pointsUnit:`积分`,rechargeHint:`充值积分有效期 2 年(自到账日起算),支付后不可退换。`,payNow:`立即支付`,rechargeSuccess:`充值成功`,rechargeOrderCreated:`充值订单已创建,请继续完成支付`,insufficientBalanceTitle:`积分余额不足`,insufficientBalanceDescription:`当前余额 {balance} {pointsUnit},预计扣款 {deductPoints} {pointsUnit}。`,insufficientBalanceDeductPoints:`消耗积分`,insufficientBalanceRechargeGuide:`请充值后继续。`,insufficientBalanceContactAdminGuide:`充值入口暂未开放,请联系管理员处理。`,contactAdmin:`联系管理员`,stripePaymentTitle:`Stripe 支付`,stripePaymentDescription:`请完成银行卡支付,支付成功后积分将自动到账。`,stripePaymentTotalAmount:`总金额`,stripePaymentOrderNo:`订单号`,stripeContactDetails:`联系方式`,stripePaymentSection:`支付方式`,stripePay:`确认支付`,stripePaymentLoading:`正在加载 Stripe 支付组件...`,stripePaymentConfigMissing:`Stripe publishable key 未配置`,stripePaymentClientSecretMissing:`订单缺少 Stripe 支付凭证`,stripePaymentWindowOpenFailed:`无法打开支付窗口,请允许浏览器弹出窗口后重试`,stripeCheckoutClientSecretInvalid:`Stripe 支付凭证类型不正确,请后端返回 ui_mode 为 elements 或 custom 的 Checkout Session client_secret(cs_ 开头)`,stripePaymentProcessing:`支付处理中,请稍后刷新积分`,stripePaymentFailed:`支付失败,请重试`,stripePaymentLoadFailed:`Stripe 支付组件加载失败,请刷新后重试`,customRechargeAmount:`自定义金额`,customRechargeDescription:`按需输入充值金额,最低 $10 USD 起充`,customRechargeMinError:`最低充值 $10 USD`,customRechargeEstimate:`预计到账积分`,customRechargeRate:`兑换比 $1 = 100 积分(不享套餐赠送)`,selectRechargePackage:`请先选择套餐或输入自定义金额`,all:`全部`,income:`获得`,expense:`消耗`,source:`来源`,sourceAll:`全部来源`,sourceRecharge:`充值`,sourceGifted:`赠送`,dateRange:`日期查询`,startDate:`开始日期`,endDate:`结束日期`,dateTo:`至`,query:`查询`,refreshed:`已刷新`,pointsDeductionTip:`优先扣减即将到期的积分`,pointsNoteTitle:`说明`,pointsAccountNote:`积分账户挂在你的个人账号上,自己充值、自己消耗、自己负责;他人不能代充、不能代用。充值积分有效期固定 2 年;赠送积分有效期由后台运营发放时设置。`},ke={languageZh:`中文`,languageEn:`English`},Ae=`i18nextLng`,je=`manturLanguageSource`,Me=`mantur-language-change`,Ne={"zh-CN":{...Oe,...ke},"en-US":{...Ee,...De}};function U(e){return e?.toLowerCase().startsWith(`en`)?`en-US`:`zh-CN`}function W(){return typeof window>`u`?`zh-CN`:U(window.localStorage.getItem(`i18nextLng`)||document.documentElement.lang||navigator.language)}function Pe(e){return Ne[U(e)]}var Fe=Ae,Ie=je;function Le(e,t){document.cookie=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/`}function Re(){let{i18n:e}=(0,a.useTranslation)(),[n,s]=(0,t.useState)(()=>W()),c=Pe(n);return(0,t.useEffect)(()=>{s(U(e.language))},[e.language]),(0,o.jsx)(r.Dropdown,{droplist:(0,o.jsxs)(r.Menu,{selectedKeys:[n],onClickMenuItem:t=>{let n=U(t);localStorage.setItem(Fe,t),localStorage.setItem(Ie,`manual`),s(n),e.changeLanguage(t),Le(`Accept-Language`,t),window.dispatchEvent(new CustomEvent(Me,{detail:n})),window.location.reload()},children:[(0,o.jsx)(r.Menu.Item,{children:c.languageZh},`zh-CN`),(0,o.jsx)(r.Menu.Item,{children:c.languageEn},`en-US`)]}),trigger:`click`,position:`br`,children:(0,o.jsx)(r.Button,{shape:`circle`,icon:(0,o.jsx)(i.IconLanguage,{})})})}var ze={enabled:!1},Be=new Set,Ve,He;function Ue(e){return{enabled:e?.enabled===!0}}function We(){return typeof window<`u`&&window.__MANTUR_COMPONENTS_RECHARGE_CONFIG__?Ue(window.__MANTUR_COMPONENTS_RECHARGE_CONFIG__):Ve||ze}function Ge(e){let t=Ue(e);return Ve=t,typeof window<`u`&&(window.__MANTUR_COMPONENTS_RECHARGE_CONFIG__=t,window.dispatchEvent(new CustomEvent(F,{detail:t}))),Be.forEach(e=>e(t)),t}function G(){return We()}function Ke(e){return Be.add(e),e(We()),()=>{Be.delete(e)}}async function qe(){return He||=he().then(Ge).finally(()=>{He=void 0}),He}function Je(){let{resolvedTheme:e,setTheme:t}=(0,s.useTheme)();return(0,o.jsx)(r.Button,{shape:`circle`,icon:e===`light`?(0,o.jsx)(i.IconMoonFill,{}):(0,o.jsx)(i.IconSunFill,{}),onClick:()=>{t(e===`light`?`dark`:`light`)}})}var Ye=`mantur-components`,Xe=(e,t={},n=c.default)=>{typeof window>`u`||n.__loaded&&n.capture(e,{component_library:Ye,...t})},Ze=_(h(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){"use strict";var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))(),1);function Qe(e,t=`datetime`,n){if(!e)return`-`;let r=(n?U(n):W()).startsWith(`en`),i=t===`date`?r?`MM/DD/YYYY`:`YYYY-MM-DD`:r?`MM/DD/YYYY HH:mm:ss`:`YYYY-MM-DD HH:mm:ss`;return(0,Ze.default)(e).format(i)}var{RangePicker:$e}=r.DatePicker,et=7,tt=[1],nt=[3,5,6,7],rt=[1],it=[2];function at(e){return e===`recharge`?`arcoblue`:e===`gift`?`cyan`:e===`expired`?`gray`:`orange`}function ot(e){if(e===`income`)return tt;if(e===`expense`)return nt}function st(e){if(e===`recharge`)return rt;if(e===`gift`)return it}function ct(e,t){if(e)return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T${t}`:e}function lt(e){let t=Number(e.amount||0);return t<0?t:e.direction===3||e.direction===6||e.direction===7?-t:t}function ut(e){return e.pointType===1?`recharge`:e.pointType===2?`gift`:e.direction===6||e.bizType===5?`expired`:lt(e)<0?`deducted`:`recharge`}function dt(e,t){return e.pointType===1?t.sourceRecharge:e.pointType===2?t.sourceGifted:e.actionName||(lt(e)<0?t.expense:t.income)}function ft({visible:e,points:n,rechargeEnabled:a,text:s,onCancel:c,onRecharge:l}){let[u,d]=(0,t.useState)(`all`),[f,p]=(0,t.useState)(`all`),[m,h]=(0,t.useState)([]),[g,_]=(0,t.useState)(1),[v,y]=(0,t.useState)([]),[b,x]=(0,t.useState)(0),[S,C]=(0,t.useState)(!1),w=(0,t.useRef)(0),T=e=>new Intl.NumberFormat().format(e),E=(0,t.useCallback)(e=>{let[t,n]=m;return{pageNum:e,pageSize:et,directions:ot(u),bizTypes:st(f),fromTime:ct(t,`00:00:00`),toTime:ct(n,`23:59:59`)}},[m,f,u]),D=(0,t.useCallback)((e,t,n)=>{let r=lt(e),i=[e.createTime?Qe(e.createTime):void 0,e.contextDisplay,e.bizRefId?`ID ${e.bizRefId}`:void 0,e.balanceAfter===void 0?void 0:`${s.currentBalance}: ${T(Number(e.balanceAfter||0))}`].filter(Boolean);return{id:e.id||`${n}-${t}`,name:e.actionName||(r<0?s.expense:s.income),meta:i.join(` · `),amount:r,badgeKind:ut(e),badgeText:dt(e,s)}},[s]),O=(0,t.useCallback)(async(e=g,t=!1)=>{let n=w.current+1;w.current=n,C(!0);try{let i=await H(E(e));if(n!==w.current)return;y((i.records||[]).map((t,n)=>D(t,n,e))),x(Number(i.total||0)),_(Number(i.pageNum||e)),t&&r.Message.success(s.refreshed)}catch(e){if(n!==w.current)return;console.warn(`Failed to load Mantur points ledger.`,e),r.Message.error(s.error)}finally{n===w.current&&C(!1)}},[E,g,D,s.error,s.refreshed]);(0,t.useEffect)(()=>{e&&O()},[O,e]);let k=[{title:s.pointsDetail,dataIndex:`name`,render:(e,t)=>(0,o.jsxs)(`div`,{className:`min-w-0`,children:[(0,o.jsx)(r.Typography.Text,{className:`font-medium!`,children:t.name}),(0,o.jsx)(r.Typography.Text,{type:`secondary`,className:`mt-1 block! text-xs!`,children:t.meta})]})},{title:s.pointsUnit,dataIndex:`amount`,width:120,align:`right`,render:(e,t)=>(0,o.jsxs)(r.Typography.Text,{className:`font-semibold! ${t.amount>0?`text-arco-success-6!`:`text-arco-danger-6!`}`,children:[t.amount>0?`+`:``,T(t.amount)]})},{title:s.source,dataIndex:`badgeText`,width:110,align:`right`,render:(e,t)=>(0,o.jsx)(r.Tag,{color:at(t.badgeKind),children:t.badgeText})}];return(0,o.jsx)(r.Modal,{title:s.pointsDetail,visible:e,footer:(0,o.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,o.jsx)(r.Button,{onClick:c,children:s.close}),a?(0,o.jsx)(r.Button,{type:`primary`,icon:(0,o.jsx)(i.IconPlus,{}),onClick:()=>{c(),l()},children:s.recharge}):null]}),onCancel:c,style:{width:780,maxWidth:`calc(100vw - 48px)`},children:(0,o.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto`,children:[(0,o.jsxs)(r.Card,{bordered:!1,className:`from-arco-primary-light-1/40 to-cyan-400/5 rounded-none! bg-linear-to-br!`,children:[(0,o.jsx)(r.Typography.Text,{type:`secondary`,className:`text-xs!`,children:s.totalBalance}),(0,o.jsxs)(`div`,{className:`mt-1.5 mb-3.5 `,children:[(0,o.jsx)(r.Typography.Text,{className:`text-3xl! font-bold!`,children:T(n.total)}),(0,o.jsxs)(r.Typography.Text,{type:`secondary`,className:`ml-2 text-sm! `,children:[`🪙 `,s.pointsUnit]})]}),(0,o.jsxs)(r.Grid.Row,{gutter:12,children:[(0,o.jsx)(r.Grid.Col,{span:12,children:(0,o.jsxs)(r.Card,{size:`small`,children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,o.jsx)(r.Typography.Text,{type:`secondary`,className:`text-xs!`,children:s.rechargePoints}),(0,o.jsx)(r.Tag,{color:`arcoblue`,children:s.sourceRecharge})]}),(0,o.jsx)(r.Typography.Text,{className:`text-lg! font-semibold!`,children:T(n.recharge)})]})}),(0,o.jsx)(r.Grid.Col,{span:12,children:(0,o.jsxs)(r.Card,{size:`small`,children:[(0,o.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,o.jsx)(r.Typography.Text,{type:`secondary`,className:`text-xs!`,children:s.giftedPoints}),(0,o.jsx)(r.Tag,{color:`cyan`,children:s.sourceGifted})]}),(0,o.jsx)(r.Typography.Text,{className:`text-lg! font-semibold!`,children:T(n.gifted)})]})})]}),(0,o.jsx)(r.Typography.Text,{type:`secondary`,className:`mt-2.5 block! text-xs!`,children:s.pointsDeductionTip})]}),(0,o.jsxs)(`div`,{className:`px-6 py-4`,children:[(0,o.jsxs)(r.Tabs,{activeTab:u,onChange:e=>{d(e),_(1)},children:[(0,o.jsx)(r.Tabs.TabPane,{title:s.all},`all`),(0,o.jsx)(r.Tabs.TabPane,{title:s.income},`income`),(0,o.jsx)(r.Tabs.TabPane,{title:s.expense},`expense`)]}),(0,o.jsxs)(`div`,{className:`mt-2 mb-3.5 flex flex-wrap items-center gap-2.5`,children:[(0,o.jsxs)(r.Select,{value:f,style:{width:140},onChange:e=>{p(e),_(1)},children:[(0,o.jsx)(r.Select.Option,{value:`all`,children:s.sourceAll}),(0,o.jsx)(r.Select.Option,{value:`recharge`,children:s.sourceRecharge}),(0,o.jsx)(r.Select.Option,{value:`gift`,children:s.sourceGifted})]}),(0,o.jsx)($e,{value:m,onChange:e=>{h(e||[]),_(1)},style:{width:260}}),(0,o.jsx)(r.Button,{loading:S,onClick:()=>void O(g,!0),children:s.query})]}),(0,o.jsx)(r.Table,{rowKey:`id`,columns:k,data:v,loading:S,pagination:!1,border:!1}),(0,o.jsx)(r.Pagination,{className:`mt-3 flex justify-center!`,current:g,pageSize:et,total:b,onChange:_})]}),(0,o.jsx)(r.Card,{bordered:!1,className:`bg-arco-primary-light-1/30 rounded-none!`,children:(0,o.jsxs)(r.Typography.Text,{type:`secondary`,className:`text-xs! leading-6!`,children:[(0,o.jsxs)(`strong`,{children:[s.pointsNoteTitle,`:`]}),s.pointsAccountNote]})})]})})}var pt=Ee;function mt(e){return{...pt,...e}}var ht=2048,gt=2*1024*1024;function _t(e){return new Promise((t,n)=>{let r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t({width:i.naturalWidth,height:i.naturalHeight})},i.onerror=()=>{URL.revokeObjectURL(r),n(Error(`invalid image`))},i.src=r})}function vt({visible:e,user:n,labels:a,onCancel:s,onSubmit:c}){let l=mt(a),[u]=r.Form.useForm(),[d,f]=(0,t.useState)(!1),[p,m]=(0,t.useState)(null),[h,g]=(0,t.useState)(null),_=(0,t.useRef)(null);(0,t.useEffect)(()=>()=>{_.current&&=(URL.revokeObjectURL(_.current),null)},[]),(0,t.useEffect)(()=>{e&&(u.setFieldsValue({nickname:n?.nickname||n?.username||``}),m(null),g(e=>(e&&URL.revokeObjectURL(e),_.current=null,null)))},[e,n,u]);let v=(e,t)=>{console.error(t),r.Message.error(e)},y=e=>{r.Message.success(e)};return(0,o.jsx)(r.Modal,{title:l.profileTitle,visible:e,onOk:async()=>{try{let e=await u.validate();f(!0),await c({nickname:e.nickname,avatarFile:p}),y(l.profileUpdateSuccess),s()}catch(e){e instanceof Error&&v(e.message||l.error,e)}finally{f(!1)}},onCancel:s,confirmLoading:d,okText:l.profileSave,cancelText:l.profileCancel,children:(0,o.jsxs)(r.Form,{form:u,layout:`vertical`,children:[(0,o.jsx)(r.Form.Item,{label:l.profileNickname,field:`nickname`,rules:[{required:!0,message:l.profileNicknamePlaceholder}],children:(0,o.jsx)(r.Input,{placeholder:l.profileNicknamePlaceholder,allowClear:!0})}),(0,o.jsx)(r.Form.Item,{label:l.profileAvatar,children:(0,o.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,o.jsx)(r.Avatar,{size:64,className:`shrink-0 bg-arco-primary-light-1!`,children:h||n?.avatar?(0,o.jsx)(`img`,{src:h||n?.avatar,alt:``,className:`block h-full w-full object-cover`}):n?.nickname?.[0]||n?.username?.[0]||`U`}),(0,o.jsx)(r.Upload,{accept:`image/*`,showUploadList:!1,beforeUpload:async e=>{if(e.size>gt)return v(l.profileAvatarTooLarge),!1;try{let{width:t,height:n}=await _t(e);if(t>ht||n>ht)return v(l.profileAvatarDimensionExceeded),!1}catch(e){return v(l.profileAvatarInvalidImage,e),!1}return g(t=>{t&&URL.revokeObjectURL(t);let n=URL.createObjectURL(e);return _.current=n,n}),m(e),!1},children:(0,o.jsx)(r.Button,{type:`outline`,size:`small`,icon:(0,o.jsx)(i.IconUpload,{}),children:l.profileUploadAvatar})})]}),(0,o.jsx)(`span`,{className:`text-xs text-arco-text-3`,children:l.profileAvatarHint})]})})]})})}var yt=[{id:`points-500`,points:500,price:5},{id:`points-1000`,points:1e3,price:10},{id:`points-5500`,points:5500,price:50,recommended:!0}];function bt(e){return e?.nickname?.[0]||e?.username?.[0]||`U`}function xt({user:e,size:t,className:n=``}){return(0,o.jsx)(r.Avatar,{size:t,className:`bg-arco-primary/20! text-arco-primary-6 border-2 font-bold ${n}`,children:e?.avatar?(0,o.jsx)(`img`,{src:e.avatar,alt:`avatar`,className:`h-full w-full object-cover`}):bt(e)})}var St={minHeight:292,height:`100%`,display:`flex`,flexDirection:`column`,justifyContent:`space-between`},Ct=`relative h-full! min-h-[292px]! w-full! overflow-hidden rounded-lg! border shadow-sm! transition-all duration-200 before:absolute before:inset-x-0 before:top-0 before:h-1 before:bg-linear-to-r before:from-arco-primary before:to-transparent hover:shadow-md! [&_.arco-card-body]:flex! [&_.arco-card-body]:h-full! [&_.arco-card-body]:flex-col! [&_.arco-card-body]:justify-between!`;function wt({visible:e,user:n,points:a,text:s,packages:c,packageLoading:l=!1,submitting:u=!1,onCancel:d,onPay:f}){let[p,m]=(0,t.useState)(yt[2].id),[h,g]=(0,t.useState)(``),_=(0,t.useRef)(null),v=c?.length?c:yt,y=e=>new Intl.NumberFormat().format(e),b=h.trim(),x=Number(b),S=b.length>0,C=p===`custom`,w=S&&Number.isFinite(x)&&Number.isInteger(x)&&x>=10,T=v.find(e=>e.id===p),E=C&&w?{id:`custom`,price:x,points:x*100,custom:!0}:T,D=E?`${s.payNow} · $${E.price}`:S?s.customRechargeMinError:s.selectRechargePackage;(0,t.useEffect)(()=>{!e||C||v.some(e=>e.id===p)||m((v.find(e=>e.recommended)||v[0])?.id||`custom`)},[v,C,p,e]);let O=e=>{m(e),g(``)},k=()=>{m(`custom`),g(e=>e||`10`),_.current?.focus()};return(0,o.jsx)(r.Modal,{title:s.rechargeTitle,visible:e,footer:(0,o.jsxs)(`div`,{className:`mx-auto flex max-w-7xl items-center justify-between gap-5`,children:[(0,o.jsx)(`span`,{className:`text-arco-text-2 text-sm leading-6`,children:s.rechargeHint}),(0,o.jsx)(r.Button,{type:`primary`,size:`large`,className:`min-w-48! font-bold!`,disabled:!E||l||u,loading:u,onClick:()=>{E&&f(E)},children:D})]}),onCancel:()=>{u||d()},closable:!u,maskClosable:!u,escToExit:!u,alignCenter:!1,wrapClassName:`overflow-hidden!`,style:{width:`100vw`,maxWidth:`100vw`,top:0,paddingBottom:0},className:`top-0! m-0! flex! h-screen! w-screen! max-w-none! flex-col! [&_.arco-modal-body]:min-h-0! [&_.arco-modal-body]:flex-1! [&_.arco-modal-body]:overflow-hidden! [&_.arco-modal-body]:p-0! [&_.arco-modal-close-icon]:top-1.5! [&_.arco-modal-close-icon]:right-4! [&_.arco-modal-close-icon]:inline-flex! [&_.arco-modal-close-icon]:h-9! [&_.arco-modal-close-icon]:w-9! [&_.arco-modal-close-icon]:items-center! [&_.arco-modal-close-icon]:justify-center! [&_.arco-modal-close-icon]:rounded-lg! [&_.arco-modal-close-icon]:text-lg! [&_.arco-modal-close-icon]:leading-9! [&_.arco-modal-close-icon]:transition-colors [&_.arco-modal-close-icon:hover]:bg-arco-fill-2 [&_.arco-modal-close-icon:hover]:text-arco-primary-6 [&_.arco-modal-close-icon_svg]:h-[18px]! [&_.arco-modal-close-icon_svg]:w-[18px]! [&_.arco-modal-content]:flex! [&_.arco-modal-content]:h-auto! [&_.arco-modal-content]:min-h-0! [&_.arco-modal-content]:flex-1! [&_.arco-modal-content]:flex-col! [&_.arco-modal-content]:overflow-hidden! [&_.arco-modal-content]:rounded-none! [&_.arco-modal-footer]:shrink-0! [&_.arco-modal-header]:shrink-0!`,children:(0,o.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-7xl flex-col items-center `,children:[(0,o.jsxs)(`div`,{className:`w-full border-arco-border-1 bg-arco-fill-1 text-arco-text-2 flex items-center gap-2.5 rounded-lg border px-3.5 py-3 text-sm`,children:[(0,o.jsx)(xt,{user:n,size:32,className:`shrink-0`}),(0,o.jsxs)(`span`,{children:[n?.nickname||n?.username,` · `,s.currentBalance,` `,(0,o.jsx)(`strong`,{className:`text-arco-text-1`,children:y(a.total)}),` `,s.pointsUnit]})]}),(0,o.jsx)(`div`,{className:`mt-6 w-full`,children:(0,o.jsxs)(r.Grid.Row,{gutter:[16,16],style:{alignItems:`stretch`},children:[v.map(e=>(0,o.jsx)(r.Grid.Col,{xs:24,sm:12,lg:6,style:{display:`flex`},children:(0,o.jsxs)(r.Card,{hoverable:!0,loading:l,role:`button`,tabIndex:0,onClick:()=>O(e.id),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&O(e.id)},bodyStyle:St,className:`${Ct} border-arco-border-2! bg-arco-bg-2! cursor-pointer ${p===e.id?`border-arco-primary-6! bg-arco-primary-light-1/40! ring-arco-primary-6/20 ring-2! shadow-[0_18px_38px_rgb(var(--primary-6)/22%)]!`:`hover:border-arco-primary-6!`}`,children:[p===e.id?(0,o.jsx)(i.IconCheckCircleFill,{className:`text-arco-primary-6! absolute bottom-4 left-4 text-xl`}):null,`recommended`in e&&e.recommended?(0,o.jsx)(r.Tag,{color:`arcoblue`,className:`absolute top-4 right-4 text-xs! font-bold!`,children:`HOT`}):null,(0,o.jsxs)(`div`,{className:`min-w-0 pr-16`,children:[(0,o.jsxs)(r.Typography.Text,{className:`flex items-center text-3xl! leading-tight! font-bold!`,children:[y(e.points),(0,o.jsx)(`span`,{className:`ml-1 text-2xl`,children:`🪙`})]}),(0,o.jsx)(r.Typography.Text,{type:`secondary`,className:`mt-1 block! text-sm!`,children:s.pointsUnit})]}),(0,o.jsx)(`div`,{className:`mt-7 flex w-full justify-end`,children:(0,o.jsxs)(r.Typography.Text,{className:`text-arco-primary-6! text-right text-2xl! leading-tight! font-bold!`,children:[`$`,e.price]})})]})},e.id)),(0,o.jsx)(r.Grid.Col,{xs:24,sm:12,lg:6,style:{display:`flex`},children:(0,o.jsxs)(r.Card,{role:`button`,tabIndex:0,onClick:k,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&k()},bodyStyle:St,className:`${Ct} cursor-text ${w?`border-arco-primary-6! bg-arco-primary-light-1/40! ring-arco-primary-6/20 ring-2! shadow-[0_18px_38px_rgb(var(--primary-6)/22%)]!`:S&&C?`border-arco-danger-6! bg-arco-bg-1! hover:border-arco-danger-6!`:`border-arco-primary-6/30! bg-arco-primary-light-1/20! hover:border-arco-primary-6!`}`,children:[w?(0,o.jsx)(i.IconCheckCircleFill,{className:`text-arco-primary-6! absolute top-4 right-4 text-xl`}):null,(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5`,children:[(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5 pr-8`,children:[(0,o.jsx)(r.Tag,{color:`arcoblue`,className:`w-fit text-xs! font-bold!`,children:s.customRechargeAmount}),(0,o.jsx)(r.Typography.Text,{type:`secondary`,className:`block! text-sm! leading-5! `,children:s.customRechargeDescription})]}),(0,o.jsx)(`div`,{className:`mt-1`,onClick:e=>e.stopPropagation(),children:(0,o.jsx)(r.Input,{ref:_,type:`text`,inputMode:`numeric`,pattern:`[0-9]*`,value:h,placeholder:`10`,onFocus:k,onChange:e=>{m(`custom`),g(e.replace(/\D/g,``))},prefix:(0,o.jsx)(`span`,{className:`text-arco-primary-6 text-base font-semibold`,children:`$`}),suffix:(0,o.jsx)(`span`,{className:`text-arco-primary-6 text-xs font-semibold`,children:`USD`}),height:48,status:S&&C&&!w?`error`:void 0,className:`w-full! rounded-md! shadow-[0_0_0_3px_rgb(var(--primary-6)/8%)] transition-all [&_.arco-input]:text-xl! [&_.arco-input]:font-bold! [&_.arco-input]:text-arco-text-1! [&_.arco-input]:[font-family:var(--font-display)] [&_.arco-input-inner-wrapper]:border-2! [&_.arco-input-inner-wrapper]:bg-arco-bg-1! [&_.arco-input-inner-wrapper]:px-3! [&_.arco-input-inner-wrapper]:shadow-none! [&_.arco-input-inner-wrapper-focus]:border-arco-primary-6! [&_.arco-input-inner-wrapper-focus]:shadow-[0_0_0_4px_rgb(var(--primary-6)/14%)]! ${S&&C&&!w?`[&_.arco-input-inner-wrapper]:border-arco-danger-6! shadow-[0_0_0_3px_rgb(var(--danger-6)/12%)]`:`[&_.arco-input-inner-wrapper]:border-arco-primary-6/50!`}`})}),(0,o.jsx)(`div`,{className:`h-4`,children:(0,o.jsx)(r.Typography.Text,{type:`error`,className:`block! text-xs! leading-4! transition-opacity ${S&&C&&!w?`opacity-100`:`opacity-0`}`,children:s.customRechargeMinError})})]}),(0,o.jsxs)(`div`,{className:`border-arco-primary-6/20! bg-arco-bg-1!/80 mt-3 rounded-md border px-3.5 py-3 shadow-sm`,children:[(0,o.jsx)(r.Typography.Text,{type:`secondary`,className:`block! text-xs!`,children:s.customRechargeEstimate}),(0,o.jsxs)(r.Typography.Text,{className:`text-arco-primary-6! mt-1 block! text-xl! leading-tight! font-bold!`,children:[w?y(x*100):`-`,(0,o.jsx)(`span`,{className:`text-arco-text-3 ml-1 text-xs font-normal`,children:s.pointsUnit})]}),(0,o.jsx)(r.Typography.Text,{type:`secondary`,className:`mt-0.5 block! text-[10px]!`,children:s.customRechargeRate})]})]})})]})})]})})}var Tt=h((e=>{var t=typeof Symbol==`function`&&Symbol.for,n=t?Symbol.for(`react.element`):60103,r=t?Symbol.for(`react.portal`):60106,i=t?Symbol.for(`react.fragment`):60107,a=t?Symbol.for(`react.strict_mode`):60108,o=t?Symbol.for(`react.profiler`):60114,s=t?Symbol.for(`react.provider`):60109,c=t?Symbol.for(`react.context`):60110,l=t?Symbol.for(`react.async_mode`):60111,u=t?Symbol.for(`react.concurrent_mode`):60111,d=t?Symbol.for(`react.forward_ref`):60112,f=t?Symbol.for(`react.suspense`):60113,p=t?Symbol.for(`react.suspense_list`):60120,m=t?Symbol.for(`react.memo`):60115,h=t?Symbol.for(`react.lazy`):60116,g=t?Symbol.for(`react.block`):60121,_=t?Symbol.for(`react.fundamental`):60117,v=t?Symbol.for(`react.responder`):60118,y=t?Symbol.for(`react.scope`):60119;function b(e){if(typeof e==`object`&&e){var t=e.$$typeof;switch(t){case n:switch(e=e.type,e){case l:case u:case i:case o:case a:case f:return e;default:switch(e&&=e.$$typeof,e){case c:case d:case h:case m:case s:return e;default:return t}}case r:return t}}}function x(e){return b(e)===u}e.AsyncMode=l,e.ConcurrentMode=u,e.ContextConsumer=c,e.ContextProvider=s,e.Element=n,e.ForwardRef=d,e.Fragment=i,e.Lazy=h,e.Memo=m,e.Portal=r,e.Profiler=o,e.StrictMode=a,e.Suspense=f,e.isAsyncMode=function(e){return x(e)||b(e)===l},e.isConcurrentMode=x,e.isContextConsumer=function(e){return b(e)===c},e.isContextProvider=function(e){return b(e)===s},e.isElement=function(e){return typeof e==`object`&&!!e&&e.$$typeof===n},e.isForwardRef=function(e){return b(e)===d},e.isFragment=function(e){return b(e)===i},e.isLazy=function(e){return b(e)===h},e.isMemo=function(e){return b(e)===m},e.isPortal=function(e){return b(e)===r},e.isProfiler=function(e){return b(e)===o},e.isStrictMode=function(e){return b(e)===a},e.isSuspense=function(e){return b(e)===f},e.isValidElementType=function(e){return typeof e==`string`||typeof e==`function`||e===i||e===u||e===o||e===a||e===f||e===p||typeof e==`object`&&!!e&&(e.$$typeof===h||e.$$typeof===m||e.$$typeof===s||e.$$typeof===c||e.$$typeof===d||e.$$typeof===_||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)},e.typeOf=b})),Et=h((e=>{process.env.NODE_ENV!==`production`&&(function(){"use strict";var t=typeof Symbol==`function`&&Symbol.for,n=t?Symbol.for(`react.element`):60103,r=t?Symbol.for(`react.portal`):60106,i=t?Symbol.for(`react.fragment`):60107,a=t?Symbol.for(`react.strict_mode`):60108,o=t?Symbol.for(`react.profiler`):60114,s=t?Symbol.for(`react.provider`):60109,c=t?Symbol.for(`react.context`):60110,l=t?Symbol.for(`react.async_mode`):60111,u=t?Symbol.for(`react.concurrent_mode`):60111,d=t?Symbol.for(`react.forward_ref`):60112,f=t?Symbol.for(`react.suspense`):60113,p=t?Symbol.for(`react.suspense_list`):60120,m=t?Symbol.for(`react.memo`):60115,h=t?Symbol.for(`react.lazy`):60116,g=t?Symbol.for(`react.block`):60121,_=t?Symbol.for(`react.fundamental`):60117,v=t?Symbol.for(`react.responder`):60118,y=t?Symbol.for(`react.scope`):60119;function b(e){return typeof e==`string`||typeof e==`function`||e===i||e===u||e===o||e===a||e===f||e===p||typeof e==`object`&&!!e&&(e.$$typeof===h||e.$$typeof===m||e.$$typeof===s||e.$$typeof===c||e.$$typeof===d||e.$$typeof===_||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)}function x(e){if(typeof e==`object`&&e){var t=e.$$typeof;switch(t){case n:var p=e.type;switch(p){case l:case u:case i:case o:case a:case f:return p;default:var g=p&&p.$$typeof;switch(g){case c:case d:case h:case m:case s:return g;default:return t}}case r:return t}}}var S=l,C=u,w=c,T=s,E=n,D=d,O=i,k=h,A=m,j=r,M=o,N=a,P=f,F=!1;function I(e){return F||(F=!0,console.warn(`The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.`)),ee(e)||x(e)===l}function ee(e){return x(e)===u}function te(e){return x(e)===c}function ne(e){return x(e)===s}function re(e){return typeof e==`object`&&!!e&&e.$$typeof===n}function ie(e){return x(e)===d}function ae(e){return x(e)===i}function L(e){return x(e)===h}function R(e){return x(e)===m}function oe(e){return x(e)===r}function se(e){return x(e)===o}function ce(e){return x(e)===a}function le(e){return x(e)===f}e.AsyncMode=S,e.ConcurrentMode=C,e.ContextConsumer=w,e.ContextProvider=T,e.Element=E,e.ForwardRef=D,e.Fragment=O,e.Lazy=k,e.Memo=A,e.Portal=j,e.Profiler=M,e.StrictMode=N,e.Suspense=P,e.isAsyncMode=I,e.isConcurrentMode=ee,e.isContextConsumer=te,e.isContextProvider=ne,e.isElement=re,e.isForwardRef=ie,e.isFragment=ae,e.isLazy=L,e.isMemo=R,e.isPortal=oe,e.isProfiler=se,e.isStrictMode=ce,e.isSuspense=le,e.isValidElementType=b,e.typeOf=x})()})),Dt=h(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=Tt():t.exports=Et()})),Ot=h(((e,t)=>{var n=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function a(e){if(e==null)throw TypeError(`Object.assign cannot be called with null or undefined`);return Object(e)}function o(){try{if(!Object.assign)return!1;var e=new String(`abc`);if(e[5]=`de`,Object.getOwnPropertyNames(e)[0]===`5`)return!1;for(var t={},n=0;n<10;n++)t[`_`+String.fromCharCode(n)]=n;if(Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(``)!==`0123456789`)return!1;var r={};return`abcdefghijklmnopqrst`.split(``).forEach(function(e){r[e]=e}),Object.keys(Object.assign({},r)).join(``)===`abcdefghijklmnopqrst`}catch{return!1}}t.exports=o()?Object.assign:function(e,t){for(var o,s=a(e),c,l=1;l<arguments.length;l++){for(var u in o=Object(arguments[l]),o)r.call(o,u)&&(s[u]=o[u]);if(n){c=n(o);for(var d=0;d<c.length;d++)i.call(o,c[d])&&(s[c[d]]=o[c[d]])}}return s}})),kt=h(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),At=h(((e,t)=>{t.exports=Function.call.bind(Object.prototype.hasOwnProperty)})),jt=h(((e,t)=>{var n=function(){};if(process.env.NODE_ENV!==`production`){var r=kt(),i={},a=At();n=function(e){var t=`Warning: `+e;typeof console<`u`&&console.error(t);try{throw Error(t)}catch{}}}function o(e,t,o,s,c){if(process.env.NODE_ENV!==`production`){for(var l in e)if(a(e,l)){var u;try{if(typeof e[l]!=`function`){var d=Error((s||`React class`)+`: `+o+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw d.name=`Invariant Violation`,d}u=e[l](t,l,s,o,null,r)}catch(e){u=e}if(u&&!(u instanceof Error)&&n((s||`React class`)+`: type specification of `+o+" `"+l+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof u+`. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).`),u instanceof Error&&!(u.message in i)){i[u.message]=!0;var f=c?c():``;n(`Failed `+o+` type: `+u.message+(f??``))}}}}o.resetWarningCache=function(){process.env.NODE_ENV!==`production`&&(i={})},t.exports=o})),Mt=h(((e,t)=>{var n=Dt(),r=Ot(),i=kt(),a=At(),o=jt(),s=function(){};process.env.NODE_ENV!==`production`&&(s=function(e){var t=`Warning: `+e;typeof console<`u`&&console.error(t);try{throw Error(t)}catch{}});function c(){return null}t.exports=function(e,t){var l=typeof Symbol==`function`&&Symbol.iterator,u=`@@iterator`;function d(e){var t=e&&(l&&e[l]||e[u]);if(typeof t==`function`)return t}var f=`<<anonymous>>`,p={array:_(`array`),bigint:_(`bigint`),bool:_(`boolean`),func:_(`function`),number:_(`number`),object:_(`object`),string:_(`string`),symbol:_(`symbol`),any:v(),arrayOf:y,element:b(),elementType:x(),instanceOf:S,node:E(),objectOf:w,oneOf:C,oneOfType:T,shape:O,exact:k};function m(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}function h(e,t){this.message=e,this.data=t&&typeof t==`object`?t:{},this.stack=``}h.prototype=Error.prototype;function g(e){if(process.env.NODE_ENV!==`production`)var n={},r=0;function a(a,o,c,l,u,d,p){if(l||=f,d||=c,p!==i){if(t){var m=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw m.name=`Invariant Violation`,m}else if(process.env.NODE_ENV!==`production`&&typeof console<`u`){var g=l+`:`+c;!n[g]&&r<3&&(s("You are manually calling a React.PropTypes validation function for the `"+d+"` prop on `"+l+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),n[g]=!0,r++)}}return o[c]==null?a?o[c]===null?new h(`The `+u+" `"+d+"` is marked as required "+("in `"+l+"`, but its value is `null`.")):new h(`The `+u+" `"+d+"` is marked as required in "+("`"+l+"`, but its value is `undefined`.")):null:e(o,c,l,u,d)}var o=a.bind(null,!1);return o.isRequired=a.bind(null,!0),o}function _(e){function t(t,n,r,i,a,o){var s=t[n];if(M(s)!==e){var c=N(s);return new h(`Invalid `+i+" `"+a+"` of type "+("`"+c+"` supplied to `"+r+"`, expected ")+("`"+e+"`."),{expectedType:e})}return null}return g(t)}function v(){return g(c)}function y(e){function t(t,n,r,a,o){if(typeof e!=`function`)return new h("Property `"+o+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var s=t[n];if(!Array.isArray(s)){var c=M(s);return new h(`Invalid `+a+" `"+o+"` of type "+("`"+c+"` supplied to `"+r+"`, expected an array."))}for(var l=0;l<s.length;l++){var u=e(s,l,r,a,o+`[`+l+`]`,i);if(u instanceof Error)return u}return null}return g(t)}function b(){function t(t,n,r,i,a){var o=t[n];if(!e(o)){var s=M(o);return new h(`Invalid `+i+" `"+a+"` of type "+("`"+s+"` supplied to `"+r+"`, expected a single ReactElement."))}return null}return g(t)}function x(){function e(e,t,r,i,a){var o=e[t];if(!n.isValidElementType(o)){var s=M(o);return new h(`Invalid `+i+" `"+a+"` of type "+("`"+s+"` supplied to `"+r+"`, expected a single ReactElement type."))}return null}return g(e)}function S(e){function t(t,n,r,i,a){if(!(t[n]instanceof e)){var o=e.name||f,s=F(t[n]);return new h(`Invalid `+i+" `"+a+"` of type "+("`"+s+"` supplied to `"+r+"`, expected ")+("instance of `"+o+"`."))}return null}return g(t)}function C(e){if(!Array.isArray(e))return process.env.NODE_ENV!==`production`&&(arguments.length>1?s(`Invalid arguments supplied to oneOf, expected an array, got `+arguments.length+` arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).`):s(`Invalid argument supplied to oneOf, expected an array.`)),c;function t(t,n,r,i,a){for(var o=t[n],s=0;s<e.length;s++)if(m(o,e[s]))return null;var c=JSON.stringify(e,function(e,t){return N(t)===`symbol`?String(t):t});return new h(`Invalid `+i+" `"+a+"` of value `"+String(o)+"` "+("supplied to `"+r+"`, expected one of "+c+`.`))}return g(t)}function w(e){function t(t,n,r,o,s){if(typeof e!=`function`)return new h("Property `"+s+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var c=t[n],l=M(c);if(l!==`object`)return new h(`Invalid `+o+" `"+s+"` of type "+("`"+l+"` supplied to `"+r+"`, expected an object."));for(var u in c)if(a(c,u)){var d=e(c,u,r,o,s+`.`+u,i);if(d instanceof Error)return d}return null}return g(t)}function T(e){if(!Array.isArray(e))return process.env.NODE_ENV!==`production`&&s(`Invalid argument supplied to oneOfType, expected an instance of array.`),c;for(var t=0;t<e.length;t++){var n=e[t];if(typeof n!=`function`)return s(`Invalid argument supplied to oneOfType. Expected an array of check functions, but received `+P(n)+` at index `+t+`.`),c}function r(t,n,r,o,s){for(var c=[],l=0;l<e.length;l++){var u=e[l],d=u(t,n,r,o,s,i);if(d==null)return null;d.data&&a(d.data,`expectedType`)&&c.push(d.data.expectedType)}var f=c.length>0?`, expected one of type [`+c.join(`, `)+`]`:``;return new h(`Invalid `+o+" `"+s+"` supplied to "+("`"+r+"`"+f+`.`))}return g(r)}function E(){function e(e,t,n,r,i){return A(e[t])?null:new h(`Invalid `+r+" `"+i+"` supplied to "+("`"+n+"`, expected a ReactNode."))}return g(e)}function D(e,t,n,r,i){return new h((e||`React class`)+`: `+t+" type `"+n+`.`+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+i+"`.")}function O(e){function t(t,n,r,a,o){var s=t[n],c=M(s);if(c!==`object`)return new h(`Invalid `+a+" `"+o+"` of type `"+c+"` "+("supplied to `"+r+"`, expected `object`."));for(var l in e){var u=e[l];if(typeof u!=`function`)return D(r,a,o,l,N(u));var d=u(s,l,r,a,o+`.`+l,i);if(d)return d}return null}return g(t)}function k(e){function t(t,n,o,s,c){var l=t[n],u=M(l);if(u!==`object`)return new h(`Invalid `+s+" `"+c+"` of type `"+u+"` "+("supplied to `"+o+"`, expected `object`."));for(var d in r({},t[n],e)){var f=e[d];if(a(e,d)&&typeof f!=`function`)return D(o,s,c,d,N(f));if(!f)return new h(`Invalid `+s+" `"+c+"` key `"+d+"` supplied to `"+o+`\`.
|
|
2
2
|
Bad object: `+JSON.stringify(t[n],null,` `)+`
|
|
3
3
|
Valid keys: `+JSON.stringify(Object.keys(e),null,` `));var p=f(l,d,o,s,c+`.`+d,i);if(p)return p}return null}return g(t)}function A(t){switch(typeof t){case`number`:case`string`:case`undefined`:return!0;case`boolean`:return!t;case`object`:if(Array.isArray(t))return t.every(A);if(t===null||e(t))return!0;var n=d(t);if(n){var r=n.call(t),i;if(n!==t.entries){for(;!(i=r.next()).done;)if(!A(i.value))return!1}else for(;!(i=r.next()).done;){var a=i.value;if(a&&!A(a[1]))return!1}}else return!1;return!0;default:return!1}}function j(e,t){return e===`symbol`?!0:t?t[`@@toStringTag`]===`Symbol`||typeof Symbol==`function`&&t instanceof Symbol:!1}function M(e){var t=typeof e;return Array.isArray(e)?`array`:e instanceof RegExp?`object`:j(t,e)?`symbol`:t}function N(e){if(e==null)return``+e;var t=M(e);if(t===`object`){if(e instanceof Date)return`date`;if(e instanceof RegExp)return`regexp`}return t}function P(e){var t=N(e);switch(t){case`array`:case`object`:return`an `+t;case`boolean`:case`date`:case`regexp`:return`a `+t;default:return t}}function F(e){return!e.constructor||!e.constructor.name?f:e.constructor.name}return p.checkPropTypes=o,p.resetWarningCache=o.resetWarningCache,p.PropTypes=p,p}})),Nt=h(((e,t)=>{var n=kt();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),K=_(h(((e,t)=>{if(process.env.NODE_ENV!==`production`){var n=Dt();t.exports=Mt()(n.isElement,!0)}else t.exports=Nt()()}))(),1);function Pt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Pt(Object(n),!0).forEach(function(t){It(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ft(e){"@babel/helpers - typeof";return Ft=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ft(e)}function It(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lt(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Rt(e,t){if(e==null)return{};var n=Lt(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function J(e,t){return zt(e)||Bt(e,t)||Vt(e,t)||Ut()}function zt(e){if(Array.isArray(e))return e}function Bt(e,t){var n=e&&(typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`]);if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Vt(e,t){if(e){if(typeof e==`string`)return Ht(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ht(e,t)}}function Ht(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ut(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Y=function(e){return e!==null&&Ft(e)===`object`},Wt=function(e){return Y(e)&&typeof e.then==`function`},Gt=function(e){return Y(e)&&typeof e.elements==`function`&&typeof e.createToken==`function`&&typeof e.createPaymentMethod==`function`&&typeof e.confirmCardPayment==`function`},Kt="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",qt=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Kt;if(e===null||Gt(e))return e;throw Error(t)},Jt=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Kt;if(Wt(e))return{tag:`async`,stripePromise:Promise.resolve(e).then(function(e){return qt(e,t)})};var n=qt(e,t);return n===null?{tag:`empty`}:{tag:`sync`,stripe:n}},Yt=function(e){var n=t.default.useRef(e);return t.default.useEffect(function(){n.current=e},[e]),n.current},Xt=`[object Object]`,X=function e(t,n){if(!Y(t)||!Y(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Xt;if(i!==(Object.prototype.toString.call(n)===Xt))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},Zt=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:`react-stripe-js`,version:`6.4.0`}),e.registerAppInfo({name:`react-stripe-js`,version:`6.4.0`,url:`https://stripe.com/docs/stripe-js/react`}))},Qt=function(e,t,n){return Y(e)?Object.keys(e).reduce(function(r,i){var a=!Y(t)||!X(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?q(q({},r||{}),{},It({},i,e[i])):r},null):null},$t=t.default.createContext(null);$t.displayName=`ElementsContext`;var en=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e};K.default.any,K.default.object,K.default.func.isRequired;var tn=[`on`,`loadActions`],nn=[`getSession`],rn=t.default.createContext(null);rn.displayName=`CheckoutContext`;var an=function(e,t){if(!e)throw Error(`Could not find checkout context; You need to wrap the part of your app that ${t} in a <CheckoutElementsProvider> or <CheckoutFormProvider> provider.`);return e},on=function(e){var n=t.default.useContext(rn),r=t.default.useContext($t);if(n){if(r)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return n}else return en(r,e)},sn=function(e){if(e.type===`success`){var t=e.sdk,n=e.session,r=e.checkoutActions;t.on,t.loadActions;var i=Rt(t,tn);r.getSession;var a=Rt(r,nn);return{type:`success`,checkout:q(q(q({},n),i),a)}}else if(e.type===`loading`)return{type:`loading`};else return{type:`error`,error:e.error}},cn=function(){var e=an(t.default.useContext(rn),`calls useCheckoutElements()`).checkoutState;if(e.type===`success`&&e.sdkKind!==`elements`)throw Error(`useCheckoutElements() must be used inside <CheckoutElementsProvider>. Inside <CheckoutFormProvider>, use useCheckoutForm() instead.`);return sn(e)},ln="Invalid prop `stripe` supplied to `CheckoutElementsProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",un=function(e){return e.type===`success`||e.type===`loading`?e.sdk:null},dn=function(e){var n=e.stripe,r=e.options,i=e.children,a=t.default.useMemo(function(){return Jt(n,ln)},[n]),o=J(t.default.useState({type:`loading`,sdk:null}),2),s=o[0],c=o[1],l=J(t.default.useState(null),2),u=l[0],d=l[1],f=t.default.useRef(!1);t.default.useEffect(function(){var e=!0,t=function(t){var n=t.stripe;if(n&&e&&!f.current){f.current=!0;var i=n.initCheckoutElementsSdk(r);c({type:`loading`,sdk:i}),i.loadActions().then(function(e){if(e.type===`success`){var t=e.actions;c({type:`success`,sdkKind:`elements`,sdk:i,checkoutActions:t,session:t.getSession()}),i.on(`change`,function(e){c(function(t){return t.type===`success`&&t.sdkKind===`elements`?{type:`success`,sdkKind:`elements`,sdk:t.sdk,checkoutActions:t.checkoutActions,session:e}:t})})}else c({type:`error`,error:e.error})}).catch(function(e){c({type:`error`,error:e})})}};return a.tag===`async`?a.stripePromise.then(function(e){d(e),e&&t({stripe:e})}):a.tag===`sync`&&(d(a.stripe),t({stripe:a.stripe})),function(){e=!1}},[a,r,c]);var p=Yt(n);t.default.useEffect(function(){p!==null&&p!==n&&console.warn("Unsupported prop change on CheckoutElementsProvider: You cannot change the `stripe` prop after setting it.")},[p,n]);var m=un(s),h=Yt(r);t.default.useEffect(function(){if(m){var e=h?.elementsOptions?.appearance,t=r?.elementsOptions?.appearance,n=!X(t,e);t&&n&&m.changeAppearance(t);var i=h?.elementsOptions?.fonts,a=r?.elementsOptions?.fonts,o=!X(i,a);a&&o&&m.loadFonts(a)}},[r,h,m]),t.default.useEffect(function(){Zt(u)},[u]);var g=t.default.useMemo(function(){return{stripe:u,checkoutState:s}},[u,s]);return t.default.createElement(rn.Provider,{value:g},i)};dn.propTypes={stripe:K.default.any,options:K.default.shape({clientSecret:K.default.oneOfType([K.default.string,K.default.instanceOf(Promise)]).isRequired,elementsOptions:K.default.object}).isRequired};var fn="Invalid prop `stripe` supplied to `CheckoutFormProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",pn=function(e){var n=e.stripe,r=e.options,i=e.children,a=t.default.useMemo(function(){return Jt(n,fn)},[n]),o=J(t.default.useState({type:`loading`,sdk:null}),2),s=o[0],c=o[1],l=J(t.default.useState(null),2),u=l[0],d=l[1],f=t.default.useRef(!1);t.default.useEffect(function(){var e=!0,t=function(t){var n=t.stripe;if(n&&e&&!f.current){f.current=!0;var i=n.initCheckoutFormSdk(r);c({type:`loading`,sdk:i}),i.loadActions().then(function(e){if(e.type===`success`){var t=e.actions;c({type:`success`,sdkKind:`form`,sdk:i,checkoutActions:t,session:t.getSession()}),i.on(`change`,function(e){c(function(t){return t.type===`success`&&t.sdkKind===`form`?{type:`success`,sdkKind:`form`,sdk:t.sdk,checkoutActions:t.checkoutActions,session:e}:t})})}else c({type:`error`,error:e.error})}).catch(function(e){c({type:`error`,error:e})})}};return a.tag===`async`?a.stripePromise.then(function(e){d(e),e&&t({stripe:e})}):a.tag===`sync`&&(d(a.stripe),t({stripe:a.stripe})),function(){e=!1}},[a,r,c]);var p=Yt(n);t.default.useEffect(function(){p!==null&&p!==n&&console.warn("Unsupported prop change on CheckoutFormProvider: You cannot change the `stripe` prop after setting it.")},[p,n]);var m=s.type===`success`||s.type===`loading`?s.sdk:null,h=Yt(r);t.default.useEffect(function(){if(m){var e=h?.appearance,t=r?.appearance,n=!X(t,e);t&&n&&m.changeAppearance(t);var i=h?.fonts,a=r?.fonts,o=!X(i,a);a&&o&&m.loadFonts(a)}},[r,h,m]),t.default.useEffect(function(){Zt(u)},[u]);var g=t.default.useMemo(function(){return{stripe:u,checkoutState:s}},[u,s]);return t.default.createElement(rn.Provider,{value:g},i)};pn.propTypes={stripe:K.default.any,options:K.default.shape({clientSecret:K.default.oneOfType([K.default.string,K.default.instanceOf(Promise)]).isRequired,appearance:K.default.object,loader:K.default.string,fonts:K.default.array,savedPaymentMethod:K.default.object,defaultValues:K.default.object}).isRequired};var Z=function(e,n,r){var i=!!r,a=t.default.useRef(r);t.default.useEffect(function(){a.current=r},[r]),t.default.useEffect(function(){if(!i||!e)return function(){};var t=function(){a.current&&a.current.apply(a,arguments)};return e.on(n,t),function(){e.off(n,t)}},[i,n,e,a])},mn=[`mode`],hn=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},Q=function(e,n,r){var i=r||`${hn(e)}Element`,a=n?function(e){on(`mounts <${i}>`);var n=e.id,r=e.className;return t.default.createElement(`div`,{id:n,className:r})}:function(n){var r=n.id,a=n.className,o=n.options,s=o===void 0?{}:o,c=n.onBlur,l=n.onFocus,u=n.onReady,d=n.onChange,f=n.onEscape,p=n.onClick,m=n.onLoadError,h=n.onLoaderStart,g=n.onNetworksChange,_=n.onConfirm,v=n.onCancel,y=n.onShippingAddressChange,b=n.onShippingRateChange,x=n.onSavedPaymentMethodRemove,S=n.onSavedPaymentMethodUpdate,C=n.onAvailablePaymentMethodsChange,w=on(`mounts <${i}>`),T=`elements`in w?w.elements:null,E=`checkoutState`in w?w.checkoutState:null,D=E?.type===`success`||E?.type===`loading`?E.sdk:null,O=J(t.default.useState(null),2),k=O[0],A=O[1],j=t.default.useRef(null),M=t.default.useRef(null);Z(k,`blur`,c),Z(k,`focus`,l),Z(k,`escape`,f),Z(k,`click`,p),Z(k,`loaderror`,m),Z(k,`loaderstart`,h),Z(k,`networkschange`,g),Z(k,`confirm`,_),Z(k,`cancel`,v),Z(k,`shippingaddresschange`,y),Z(k,`shippingratechange`,b),Z(k,`savedpaymentmethodremove`,x),Z(k,`savedpaymentmethodupdate`,S),Z(k,`availablepaymentmethodschange`,C),Z(k,`change`,d);var N;u&&(N=e===`expressCheckout`?u:function(){u(k)}),Z(k,`ready`,N),t.default.useLayoutEffect(function(){if(j.current===null&&M.current!==null&&(T||D)){var t=null;if(D){var n=D,r=D;switch(e){case`paymentForm`:t=r.createForm(s);break;case`payment`:t=n.createPaymentElement(s);break;case`address`:if(`mode`in s){var a=s.mode,o=Rt(s,mn);if(a===`shipping`)t=n.createShippingAddressElement(o);else if(a===`billing`)t=n.createBillingAddressElement(o);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(s);break;case`currencySelector`:t=D.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(s);break;case`contactDetails`:t=n.createContactDetailsElement();break;default:throw Error(`<${i}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else T&&(t=T.create(e,s));j.current=t,A(t),t&&t.mount(M.current)}},[T,D,s]);var P=Yt(s);return t.default.useEffect(function(){if(j.current){var e=Qt(s,P,[`paymentRequest`]);e&&`update`in j.current&&j.current.update(e)}},[s,P]),t.default.useLayoutEffect(function(){return function(){if(j.current&&typeof j.current.destroy==`function`)try{j.current.destroy(),j.current=null}catch{}}},[]),t.default.createElement(`div`,{id:r,className:a,ref:M})};return a.propTypes={id:K.default.string,className:K.default.string,onChange:K.default.func,onBlur:K.default.func,onFocus:K.default.func,onReady:K.default.func,onEscape:K.default.func,onClick:K.default.func,onLoadError:K.default.func,onLoaderStart:K.default.func,onNetworksChange:K.default.func,onConfirm:K.default.func,onCancel:K.default.func,onShippingAddressChange:K.default.func,onShippingRateChange:K.default.func,onSavedPaymentMethodRemove:K.default.func,onSavedPaymentMethodUpdate:K.default.func,onAvailablePaymentMethodsChange:K.default.func,options:K.default.object},a.displayName=i,a.__elementType=e,a},$=typeof window>`u`;Q(`currencySelector`,$);var gn=Q(`payment`,$);Q(`paymentForm`,$,`CheckoutForm`),Q(`expressCheckout`,$),Q(`taxId`,$);var _n=Q(`contactDetails`,$);Q(`address`,$);function vn(e){"@babel/helpers - typeof";return vn=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},vn(e)}var yn=`dahlia`,bn=function(e){return e===3?`v3`:e},xn=`https://js.stripe.com`,Sn=`${xn}/${yn}/stripe.js`,Cn=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,wn=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,Tn=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,En=function(e){return Cn.test(e)||wn.test(e)},Dn=function(){for(var e=document.querySelectorAll(`script[src^="${xn}"]`),t=0;t<e.length;t++){var n=e[t];if(En(n.src))return n}return null},On=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${Sn}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},kn=function(e,t){!e||!e._registerWrapper||e._registerWrapper({name:`stripe-js`,version:`9.6.0`,startTime:t})},An=null,jn=null,Mn=null,Nn=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},Pn=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},Fn=function(e){return An===null?(An=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(Tn),window.Stripe){t(window.Stripe);return}try{var r=Dn();if(r&&e)console.warn(Tn);else if(!r)r=On(e);else if(r&&Mn!==null&&jn!==null){var i;r.removeEventListener(`load`,Mn),r.removeEventListener(`error`,jn),(i=r.parentNode)==null||i.removeChild(r),r=On(e)}Mn=Pn(t,n),jn=Nn(n),r.addEventListener(`load`,Mn),r.addEventListener(`error`,jn)}catch(e){n(e);return}}),An.catch(function(e){return An=null,Promise.reject(e)})):An},In=function(e,t,n){if(e===null)return null;var r=t[0];if(typeof r!=`string`)throw Error(`Expected publishable key to be of type string, got type ${vn(r)} instead.`);var i=r.match(/^pk_test/),a=bn(e.version),o=yn;i&&a!==o&&console.warn(`Stripe.js@${a} was loaded on the page, but @stripe/stripe-js@9.6.0 expected Stripe.js@${o}. This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning`);var s=e.apply(void 0,t);return kn(s,n),s},Ln,Rn=!1,zn=function(){return Ln||(Ln=Fn(null).catch(function(e){return Ln=null,Promise.reject(e)}),Ln)};Promise.resolve().then(function(){return zn()}).catch(function(e){Rn||console.warn(e)});var Bn=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];Rn=!0;var r=Date.now();return zn().then(function(e){return In(e,t,r)})},Vn=`-`;function Hn(e){return e===void 0?Vn:`$${new Intl.NumberFormat(`en-US`).format(Number(e||0))}`}function Un(e){return(0,o.jsx)(r.Typography.Text,{className:`text-arco-text-1! text-3xl! leading-tight! font-bold!`,children:Hn(e)})}function Wn({text:e,onSuccess:n}){let i=cn(),[a,s]=(0,t.useState)(``),[c,l]=(0,t.useState)(!1);if(i.type===`loading`)return(0,o.jsx)(`div`,{className:`flex min-h-80 items-center justify-center`,children:(0,o.jsx)(r.Spin,{tip:e.stripePaymentLoading})});if(i.type===`error`)return(0,o.jsx)(r.Alert,{type:`error`,content:i.error.message});let{checkout:u}=i,d=u.total.total.amount;return(0,o.jsxs)(`form`,{className:`flex flex-col gap-6`,onSubmit:async t=>{if(t.preventDefault(),!(!u.canConfirm||c)){l(!0),s(``);try{let e=await u.confirm({redirect:`if_required`});if(e.type===`error`){s(e.error.message);return}n()}catch(t){s(t instanceof Error?t.message:e.stripePaymentFailed)}finally{l(!1)}}},children:[(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,o.jsx)(r.Typography.Title,{heading:6,className:`text-arco-text-1! mb-0!`,children:e.stripeContactDetails}),(0,o.jsx)(_n,{})]}),(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,o.jsx)(r.Typography.Title,{heading:6,className:`text-arco-text-1! mb-0!`,children:e.stripePaymentSection}),(0,o.jsx)(gn,{id:`mantur-stripe-payment-element`})]}),(0,o.jsxs)(r.Button,{htmlType:`submit`,type:`primary`,size:`large`,className:`w-full!`,disabled:!u.canConfirm||c,loading:c,children:[e.stripePay,` · `,d]}),a?(0,o.jsx)(r.Alert,{type:`error`,content:a}):null]})}function Gn({visible:e,publishableKey:n,order:i,text:a,onCancel:c,onSuccess:l}){let{resolvedTheme:u}=(0,s.useTheme)(),[d,f]=(0,t.useState)(!1),p=(0,t.useRef)(!1),m=i?.clientSecret||i?.stripeClientSecret,h=(0,t.useMemo)(()=>n?Bn(n):null,[n]),g=u===`dark`?`night`:`flat`,_=(0,t.useMemo)(()=>m?{clientSecret:m,elementsOptions:{appearance:{theme:g,labels:`above`}}}:void 0,[m,g]),v=(0,t.useMemo)(()=>[{label:a.stripePaymentTotalAmount,value:Un(i?.amount)},{label:a.stripePaymentOrderNo,value:i?.orderNo||Vn}],[i?.amount,i?.orderNo,a.stripePaymentOrderNo,a.stripePaymentTotalAmount]),y=(0,t.useCallback)(async()=>{if(p.current)return;let e=i?.orderNo;if(!e){c();return}p.current=!0,f(!0);try{await B(e)}catch(e){console.warn(`Failed to cancel Mantur recharge order.`,e)}finally{p.current=!1,f(!1),c()}},[c,i?.orderNo]),b=!n||!h?(0,o.jsx)(r.Alert,{type:`error`,content:a.stripePaymentConfigMissing}):m?m.startsWith(`cs_`)?_?(0,o.jsx)(dn,{stripe:h,options:_,children:(0,o.jsx)(Wn,{text:a,onSuccess:l})},`${m}-${g}`):(0,o.jsx)(r.Alert,{type:`error`,content:a.stripePaymentClientSecretMissing}):(0,o.jsx)(r.Alert,{type:`error`,content:a.stripeCheckoutClientSecretInvalid}):(0,o.jsx)(r.Alert,{type:`error`,content:a.stripePaymentClientSecretMissing});return(0,o.jsx)(r.Modal,{title:a.stripePaymentTitle,visible:e,closeIcon:null,footer:(0,o.jsx)(`div`,{className:`flex justify-end gap-2 mx-auto max-w-7xl `,children:(0,o.jsx)(r.Button,{size:`large`,type:`primary`,status:`danger`,disabled:d,loading:d,onClick:()=>void y(),children:a.close})}),onCancel:()=>void y(),alignCenter:!1,wrapStyle:{padding:0},style:{width:`100vw`,maxWidth:`100vw`,height:`100vh`,top:0,margin:0,padding:0},className:`top-0! m-0! flex! h-screen! w-screen! max-w-none! flex-col! rounded-none! [&_.arco-modal-body]:min-h-0! [&_.arco-modal-body]:flex-1! [&_.arco-modal-body]:overflow-auto! [&_.arco-modal-content]:flex! [&_.arco-modal-content]:h-full! [&_.arco-modal-content]:flex-col! [&_.arco-modal-content]:rounded-none! [&_.arco-modal-header]:shrink-0!`,focusLock:!1,children:(0,o.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-7xl gap-8 px-6 py-6 lg:px-8`,children:[(0,o.jsx)(`div`,{className:`w-80`,children:(0,o.jsx)(`div`,{className:`bg-arco-bg-1 mx-auto w-full rounded-xl p-6`,children:(0,o.jsx)(r.Descriptions,{border:!1,column:1,data:v,labelStyle:{width:96}})})}),(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsx)(`div`,{className:`bg-arco-bg-1 mx-auto w-full max-w-2xl rounded-xl p-6`,children:b})})]})})}function Kn({user:e,points:t,rechargeEnabled:n,text:a,onEditProfile:s,onRecharge:c,onPointsDetail:l,onLogout:u}){let d=e=>new Intl.NumberFormat().format(e);return(0,o.jsxs)(`div`,{className:`w-80 overflow-hidden rounded-xl border border-arco-border-2 bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)]`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-3 px-6 pt-5 pb-4`,children:[(0,o.jsx)(xt,{user:e,size:48,className:`shrink-0`}),(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,o.jsx)(`span`,{className:`text-arco-text-1 truncate text-base leading-6 font-bold`,children:e?.nickname||e?.username}),(0,o.jsx)(r.Button,{type:`text`,size:`mini`,icon:(0,o.jsx)(i.IconEdit,{}),className:`text-arco-text-3 h-6! min-w-6! px-0!`,onClick:s})]}),e?.email?(0,o.jsx)(`span`,{className:`text-arco-text-3 truncate text-xs leading-5`,children:e.email}):null]})]}),(0,o.jsx)(r.Divider,{className:`m-0!`}),(0,o.jsxs)(`ul`,{className:`flex flex-col gap-3.5 px-6 py-4`,children:[(0,o.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,o.jsx)(`span`,{children:a.myPoints}),(0,o.jsx)(`strong`,{className:`text-arco-primary-6 text-base font-bold`,children:d(t.total)})]}),(0,o.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,o.jsx)(`span`,{children:a.rechargePoints}),(0,o.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:d(t.recharge)})]}),(0,o.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,o.jsx)(`span`,{children:a.giftedPoints}),(0,o.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:d(t.gifted)})]})]}),(0,o.jsx)(r.Divider,{className:`m-0!`}),(0,o.jsxs)(`div`,{className:`flex flex-col gap-2 px-6 py-4`,children:[n?(0,o.jsx)(r.Button,{type:`primary`,long:!0,icon:(0,o.jsx)(i.IconPlus,{}),shape:`round`,className:`h-10! font-medium!`,onClick:c,children:a.recharge}):null,(0,o.jsx)(r.Button,{long:!0,shape:`round`,icon:(0,o.jsx)(i.IconFile,{}),className:`border-arco-border-2! bg-arco-fill-1! text-arco-text-1! h-10! font-medium!`,onClick:l,children:a.pointsDetail})]}),(0,o.jsx)(r.Divider,{className:`m-0!`}),(0,o.jsx)(`div`,{className:`px-6 py-4`,children:(0,o.jsx)(r.Button,{icon:(0,o.jsx)(i.IconPoweroff,{}),type:`text`,status:`danger`,long:!0,className:`flex! items-center justify-start gap-2 text-sm text-arco-text-2`,onClick:()=>void u?.(),children:a.logout})})]})}var qn=`https://mantur.ai/images/logo.png`,Jn=[`from-arco-primary-light-1 to-arco-primary-light-2 text-arco-primary-6`,`from-arco-success-light-1 to-arco-success-light-2 text-arco-success-6`,`from-arco-warning-light-1 to-arco-warning-light-2 text-arco-warning-6`,`from-arco-danger-light-1 to-arco-danger-light-2 text-arco-danger-6`];function Yn(e,t=!1){return`flex h-8 min-h-8 w-8 min-w-8 flex-none items-center justify-center rounded-lg bg-linear-to-br font-bold leading-none ${Jn[e%Jn.length]} ${t?`shadow-[inset_0_1px_3px_rgb(0_0_0/8%)]`:``}`}function Xn(e){return e?.tenantName?.[0]?.toUpperCase()||`T`}function Zn(e,t,n){let r=e?.roles?.map(e=>e.roleName).filter(Boolean);return r?.length?r.join(`, `):e?.isOwner?t:n}function Qn({user:e,disabled:a=!1,brandSlot:s,children:c,onTenantContextChange:l,appName:u,mainPrefix:d,stripePublishableKey:f}){let p=(0,n.usePostHog)(),[m,h]=(0,t.useState)(()=>W()),g=Pe(m),[_,v]=(0,t.useState)(!1),[y,b]=(0,t.useState)(!1),[x,S]=(0,t.useState)(()=>G().enabled),[C,w]=(0,t.useState)(!1),[T,E]=(0,t.useState)(e),[D,O]=(0,t.useState)([]),[A,j]=(0,t.useState)(),[M,F]=(0,t.useState)(!1),[ee,te]=(0,t.useState)(!1),[ne,re]=(0,t.useState)(!1),[ie,ae]=(0,t.useState)([]),[L,R]=(0,t.useState)(),ce=(0,t.useRef)(l),le=f||(typeof window<`u`?window.__MANTUR_COMPONENTS_STRIPE_PUBLISHABLE_KEY__:void 0)||`pk_test_51TJ8JiERSsQknDG7bJSIX81RFq3LcCfUXCV7mh0cQsZ2dwmYcJ5Ki6bPXynNvdyZEEBE83I6I719NIFyO9Qreey700yPAul8sv`,de=d??(typeof window<`u`?window.__MANTUR_MAIN_PREFIX__:void 0)??void 0,fe=u??(typeof window<`u`?window.__MANTUR_APP_NAME__:void 0)??void 0,[pe,he]=(0,t.useState)({total:0,recharge:0,gifted:0}),z=A?.tenantId||``,B=a,_e={total:pe.total??0,recharge:pe.recharge??0,gifted:pe.gifted??0},ve=async e=>{let t=await se(e);return t&&E(t),t},V=(0,t.useCallback)((e,t={})=>{Xe(e,{app_name:fe,tenant_id:z,user_id:T?.userId,...t},p)},[T?.userId,p,fe,z]);(0,t.useEffect)(()=>{E(e)},[e]),(0,t.useEffect)(()=>{ce.current=l},[l]);let H=(0,t.useCallback)(e=>{O(e.tenants),j(e.currentTenant),ce.current?.(e)},[]);(0,t.useEffect)(()=>{F(!0),we().then(H).catch(e=>{console.warn(`Failed to refresh Mantur tenant context.`,e),r.Message.error(g.error)}).finally(()=>F(!1))},[H,g.error]),(0,t.useEffect)(()=>{let e=e=>{e instanceof CustomEvent&&he(e.detail)};return window.addEventListener(N,e),ue().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)}),()=>{window.removeEventListener(N,e)}},[]),(0,t.useEffect)(()=>{let e=Ke(e=>{S(e.enabled)});return qe().catch(e=>{console.warn(`Failed to refresh Mantur recharge config.`,e)}),e},[]),(0,t.useEffect)(()=>{let e=()=>{G().enabled&&b(!0)};return window.addEventListener(I,e),()=>{window.removeEventListener(I,e)}},[]),(0,t.useEffect)(()=>{x||b(!1)},[x]),(0,t.useEffect)(()=>{let e=e=>{h(e instanceof CustomEvent?U(e.detail):W())};return window.addEventListener(Me,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(Me,e),window.removeEventListener(`storage`,e)}},[]),(0,t.useEffect)(()=>{!y||!x||(te(!0),me().then(e=>{let t=e.filter(e=>e.id&&e.amount!==void 0&&e.points!==void 0).sort((e,t)=>(e.sortOrder??0)-(t.sortOrder??0)).map(e=>({id:e.id,packageCode:e.packageCode,packageName:e.packageName,packageNameEn:e.packageNameEn,price:Number(e.amount||0),points:Number(e.points||0),recommended:e.isRecommended,sortOrder:e.sortOrder}));t.length>0&&ae(t)}).catch(e=>{console.warn(`Failed to load Mantur recharge packages.`,e)}).finally(()=>te(!1)))},[x,y]);let ye=e=>{r.Message.success(e)},be=(e,t)=>{console.error(t),r.Message.error(e)},xe=(0,t.useCallback)(async e=>{if(!B&&e!==z)try{F(!0),H(await Te(e)),V(`mantur_header_tenant_switch`,{next_tenant_id:e}),ye(g.switchedToTeam)}catch(e){be(g.error,e)}finally{F(!1)}},[H,V,z,B,g.error,g.switchedToTeam]),Se=async e=>{let t=u?.trim();try{re(!0);let n=await ge({...`custom`in e&&e.custom?{customAmount:e.price}:{packageId:e.id},...t?{app:t}:{},uiMode:`elements`});if(!n){r.Message.error(g.stripePaymentClientSecretMissing);return}typeof window<`u`&&window.dispatchEvent(new CustomEvent(P,{detail:n})),r.Message.success(g.rechargeOrderCreated),V(`mantur_header_recharge_order_created`,{order_no:n.orderNo,amount:n.amount,points:n.points}),b(!1),R(n)}catch(e){be(g.error,e)}finally{re(!1)}},Ce=(0,t.useCallback)(()=>{V(`mantur_header_logo_click`),k(de)},[V,de]),Ee=(0,t.useMemo)(()=>(0,o.jsxs)(r.Menu,{className:`w-56 rounded-xl bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)] [&_.arco-menu-inner]:px-2 [&_.arco-menu-inner]:py-1`,selectedKeys:z?[z]:[],onClickMenuItem:xe,children:[(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold tracking-[0.04em] text-arco-text-4 uppercase`,children:g.switchTeam}),D.map((e,t)=>(0,o.jsx)(r.Menu.Item,{className:`mb-1 h-auto! min-h-10! overflow-visible! rounded-lg! px-2! py-1! leading-normal!`,children:(0,o.jsxs)(`div`,{className:`flex w-full items-center gap-3 leading-normal`,children:[(0,o.jsx)(`div`,{className:Yn(t),children:Xn(e)}),(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-0.75`,children:[(0,o.jsx)(`span`,{className:`text-sm leading-5 font-medium text-arco-text-1`,children:e.tenantName}),(0,o.jsx)(`span`,{className:`text-xs leading-4 text-arco-text-3`,children:Zn(e,g.owner,g.member)})]})]})},e.tenantId))]}),[xe,z,D,g]),De=(0,o.jsx)(Kn,{user:T,points:_e,rechargeEnabled:x,text:g,onEditProfile:()=>{V(`mantur_header_profile_open`),v(!0)},onRecharge:()=>{V(`mantur_header_recharge_open`,{entry:`user_menu`}),b(!0)},onPointsDetail:()=>{V(`mantur_header_points_detail_open`),w(!0)},onLogout:()=>(V(`mantur_header_logout_click`),oe())}),Oe=Math.max(0,D.findIndex(e=>e.tenantId===A?.tenantId));return(0,o.jsxs)(`div`,{className:`flex h-20 items-center justify-between bg-transparent pr-8 shadow-[0_2px_10px_rgb(0_0_0/2%)] backdrop-blur-md max-md:pr-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,o.jsxs)(`div`,{className:`flex w-65 items-center gap-3 px-8 max-md:w-auto max-md:px-4`,children:[(0,o.jsx)(r.Tooltip,{content:g.home,position:`bottom`,children:(0,o.jsx)(`button`,{type:`button`,"aria-label":g.home,className:`relative flex w-12 cursor-pointer items-center justify-center overflow-hidden rounded-md border-0 bg-transparent p-0 transition-opacity hover:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-arco-primary-6`,onClick:Ce,children:(0,o.jsx)(`img`,{src:qn,alt:`logo`,className:`w-full object-contain`,onError:e=>{e.currentTarget.style.display=`none`}})})}),s??(0,o.jsx)(`span`,{className:`text-lg font-bold tracking-normal text-arco-text-1`,children:g.title})]}),(0,o.jsx)(r.Dropdown,{droplist:Ee,trigger:`click`,position:`bl`,disabled:B,children:(0,o.jsxs)(`div`,{"aria-disabled":B,className:`flex items-center gap-3 rounded-full border border-arco-border-1 bg-arco-bg-1 px-2 py-1.5 transition-all ${B?`cursor-not-allowed opacity-60`:`cursor-pointer hover:bg-arco-fill-2 hover:shadow-[0_4px_12px_rgb(0_0_0/8%)]`}`,children:[(0,o.jsx)(`div`,{className:Yn(Oe,!0),children:Xn(A)}),(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,o.jsx)(`span`,{className:`text-xs leading-none font-bold text-arco-text-1`,children:M?g.loading:A?.tenantName||g.loading}),(0,o.jsx)(`span`,{className:`mt-1 text-[10px] leading-none text-arco-text-3`,children:Zn(A,g.owner,g.member)})]}),(0,o.jsx)(i.IconDown,{className:`ml-1 text-arco-text-3`})]})})]}),(0,o.jsx)(`div`,{className:`flex-1`,children:c}),(0,o.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,o.jsx)(Je,{}),(0,o.jsx)(Re,{})]}),(0,o.jsx)(r.Dropdown,{droplist:De,trigger:`click`,position:`br`,onVisibleChange:e=>{e&&(V(`mantur_header_user_menu_open`),ue().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)}),qe().catch(e=>{console.warn(`Failed to refresh Mantur recharge config.`,e)}))},children:(0,o.jsxs)(`div`,{className:`hover:bg-arco-fill-2 flex cursor-pointer items-center gap-2.5 rounded-full border border-transparent p-1 pr-2 transition-all`,children:[(0,o.jsxs)(`div`,{className:`from-arco-primary to-transparent relative rounded-full bg-linear-to-br p-0.5 shadow-sm`,children:[(0,o.jsx)(xt,{user:T,size:36}),(0,o.jsx)(`div`,{className:`bg-arco-success border-arco-bg-white absolute right-0 bottom-0 h-3 w-3 rounded-full border-2 shadow-sm`})]}),(0,o.jsx)(`div`,{className:`hidden flex-col md:flex`,children:(0,o.jsx)(`span`,{className:`text-arco-text-1 text-sm font-medium`,children:T?.nickname||T?.username})}),(0,o.jsx)(i.IconDown,{className:`text-arco-text-3 ml-1`})]})})]}),(0,o.jsx)(vt,{visible:_,user:T,labels:g,onCancel:()=>v(!1),onSubmit:ve}),(0,o.jsx)(wt,{visible:y,user:T,points:_e,text:g,packages:ie,packageLoading:ee,submitting:ne,onCancel:()=>b(!1),onPay:Se}),(0,o.jsx)(ft,{visible:C,points:_e,rechargeEnabled:x,text:g,onCancel:()=>w(!1),onRecharge:()=>{V(`mantur_header_recharge_open`,{entry:`points_detail`}),b(!0)}}),(0,o.jsx)(Gn,{visible:!!L,publishableKey:le,order:L,text:g,onCancel:()=>R(void 0),onSuccess:()=>{r.Message.success(g.rechargeSuccess),V(`mantur_header_stripe_payment_success`,{order_no:L?.orderNo,amount:L?.amount,points:L?.points}),R(void 0),ue().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)})}})]})}function $n(e){return new Intl.NumberFormat().format(e)}function er(){typeof window>`u`||window.dispatchEvent(new CustomEvent(I))}function tr(e,t){return(0,o.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm text-arco-text-2`,children:[(0,o.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[{label:t.currentBalance,value:$n(e.balance),valueClassName:`text-arco-primary-6!`},{label:t.insufficientBalanceDeductPoints||`Points to consume`,value:$n(e.deductPoints),valueClassName:`text-arco-danger-6!`}].map(e=>(0,o.jsxs)(`div`,{className:`border-arco-border-1 bg-arco-fill-1 rounded-lg border px-3 py-3`,children:[(0,o.jsx)(`div`,{className:`text-arco-text-3 text-xs leading-5`,children:e.label}),(0,o.jsxs)(`div`,{className:`${e.valueClassName} mt-1 text-2xl leading-7 font-bold`,children:[e.value,(0,o.jsx)(`span`,{className:`text-arco-text-3 ml-1 text-xs font-normal`,children:t.pointsUnit})]})]},e.label))}),e.rechargeEnabled?null:(0,o.jsx)(`span`,{className:`leading-6 text-arco-text-2`,children:t.insufficientBalanceContactAdminGuide})]})}function nr(e,t){if(typeof window>`u`)return;let n=Pe(W()),i=e.rechargeEnabled?()=>{if(t.onRecharge){t.onRecharge();return}er()}:t.onContactAdmin;r.Modal.confirm({title:t.title||n.insufficientBalanceTitle,content:t.content||tr(e,n),className:`[&_.arco-modal-footer]:text-right!`,okText:e.rechargeEnabled?n.recharge:n.contactAdmin,cancelText:n.close,onOk:i})}async function rr(e,t={}){let n=await pe(e);if(n.enough)return{...n,rechargeEnabled:G().enabled};let r=await qe().catch(e=>(console.warn(`Failed to refresh Mantur recharge config.`,e),G())),i={...n,rechargeEnabled:r.enabled};return t.showModal!==!1&&nr(i,t),i}var ir=`mantur-stripe-payment-window`,ar=`/stripe-payment`;function or(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.source===`mantur-components`&&t.type===`mantur-stripe-payment-window`&&(t.action===`close`||t.action===`success`||t.action===`failed`)}function sr(e=`close`,t,n=typeof window>`u`?void 0:window.location.origin){if(typeof window>`u`||!n)return;let r={source:`mantur-components`,type:ir,action:e,orderNo:t};window.opener?.postMessage(r,n),window.parent&&window.parent!==window&&window.parent.postMessage(r,n)}function cr(){return typeof window>`u`?void 0:window.__MANTUR_MAIN_PREFIX__||void 0}function lr(){return typeof window>`u`?`mantur`:window.__MANTUR_APP_NAME__||`mantur`}function ur(e,t){let n=e.split(`.`);return n.length<=1?t:[t,...n.slice(1)].join(`.`)}function dr(e){let t=new URL(e.toString()),n=cr()?.trim();return n&&lr()!==`mantur`&&(t.hostname=ur(e.hostname,n)),t.port=``,t.toString()}function fr(e,t={}){let n=e.clientSecret||e.stripeClientSecret;if(typeof window>`u`||!e.orderNo||!n)return;let r=new URL(ar,window.location.href),i=D(),a=t.app||i.app,o=t.redirect||i.redirect;return r.searchParams.set(`orderNo`,e.orderNo),r.searchParams.set(`clientSecret`,n),r.searchParams.set(`openerOrigin`,window.location.origin),r.searchParams.set(`app`,a),r.searchParams.set(`redirect`,o),e.amount!==void 0&&r.searchParams.set(`amount`,String(e.amount)),e.points!==void 0&&r.searchParams.set(`points`,String(e.points)),t.stripePublishableKey&&r.searchParams.set(`publishableKey`,t.stripePublishableKey),dr(r)}function pr(e,t={}){return fr(e,t)||e.paymentUrl||e.checkoutUrl||e.url||e.returnUrl}e.MANTUR_POINTS_REFRESH_EVENT=N,e.MANTUR_RECHARGE_CONFIG_CHANGE_EVENT=F,e.MANTUR_RECHARGE_ORDER_CREATED_EVENT=P,e.MANTUR_RECHARGE_REQUEST_EVENT=I,e.MANTUR_STRIPE_PAYMENT_ROUTE=ar,e.MANTUR_STRIPE_PAYMENT_WINDOW_MESSAGE_TYPE=ir,e.MANTUR_TENANT_CONTEXT_CHANGE_EVENT=ee,e.ManturHeader=Qn,e.cancelManturRechargeOrder=B,e.captureManturComponentEvent=Xe,e.checkManturBalanceEnough=pe,e.createManturRechargeOrder=ge,e.ensureManturBalanceEnough=rr,e.formatDateByLang=Qe,e.getManturBillingAccount=V,e.getManturBillingLedger=H,e.getManturBillingPackages=me,e.getManturPricingChargePoint=ve,e.getManturPricingChargePoints=_e,e.getManturRechargeConfig=he,e.getManturRechargeConfigSnapshot=G,e.getManturRechargeOrder=z,e.getManturRechargeRedirectContext=D,e.isManturStripePaymentWindowMessage=or,e.openManturRechargeModal=er,e.postManturStripePaymentWindowMessage=sr,e.redirectToManturMain=A,e.redirectToManturMainHome=k,e.refreshManturRechargeConfig=qe,e.refreshManturTenantContext=we,e.refreshManturUserPoints=ue,e.resolveManturMainHomeUrl=O,e.resolveManturRechargePaymentPageUrl=pr,e.resolveManturStripePaymentPageUrl=fr,e.subscribeManturRechargeConfig=Ke});
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Y=function(e){return e!==null&&Ft(e)===`object`},Wt=function(e){return Y(e)&&typeof e.then==`function`},Gt=function(e){return Y(e)&&typeof e.elements==`function`&&typeof e.createToken==`function`&&typeof e.createPaymentMethod==`function`&&typeof e.confirmCardPayment==`function`},Kt="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",qt=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Kt;if(e===null||Gt(e))return e;throw Error(t)},Jt=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Kt;if(Wt(e))return{tag:`async`,stripePromise:Promise.resolve(e).then(function(e){return qt(e,t)})};var n=qt(e,t);return n===null?{tag:`empty`}:{tag:`sync`,stripe:n}},Yt=function(e){var n=t.default.useRef(e);return t.default.useEffect(function(){n.current=e},[e]),n.current},Xt=`[object Object]`,X=function e(t,n){if(!Y(t)||!Y(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var i=Object.prototype.toString.call(t)===Xt;if(i!==(Object.prototype.toString.call(n)===Xt))return!1;if(!i&&!r)return t===n;var a=Object.keys(t),o=Object.keys(n);if(a.length!==o.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<o.length;l+=1)s[o[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,f=n;return u.every(function(t){return e(d[t],f[t])})},Zt=function(e){!e||!e._registerWrapper||!e.registerAppInfo||(e._registerWrapper({name:`react-stripe-js`,version:`6.4.0`}),e.registerAppInfo({name:`react-stripe-js`,version:`6.4.0`,url:`https://stripe.com/docs/stripe-js/react`}))},Qt=function(e,t,n){return Y(e)?Object.keys(e).reduce(function(r,i){var a=!Y(t)||!X(e[i],t[i]);return n.includes(i)?(a&&console.warn(`Unsupported prop change: options.${i} is not a mutable property.`),r):a?q(q({},r||{}),{},It({},i,e[i])):r},null):null},$t=t.default.createContext(null);$t.displayName=`ElementsContext`;var en=function(e,t){if(!e)throw Error(`Could not find Elements context; You need to wrap the part of your app that ${t} in an <Elements> provider.`);return e};K.default.any,K.default.object,K.default.func.isRequired;var tn=[`on`,`loadActions`],nn=[`getSession`],rn=t.default.createContext(null);rn.displayName=`CheckoutContext`;var an=function(e,t){if(!e)throw Error(`Could not find checkout context; You need to wrap the part of your app that ${t} in a <CheckoutElementsProvider> or <CheckoutFormProvider> provider.`);return e},on=function(e){var n=t.default.useContext(rn),r=t.default.useContext($t);if(n){if(r)throw Error(`You cannot wrap the part of your app that ${e} in both a checkout provider and <Elements> provider.`);return n}else return en(r,e)},sn=function(e){if(e.type===`success`){var t=e.sdk,n=e.session,r=e.checkoutActions;t.on,t.loadActions;var i=Rt(t,tn);r.getSession;var a=Rt(r,nn);return{type:`success`,checkout:q(q(q({},n),i),a)}}else if(e.type===`loading`)return{type:`loading`};else return{type:`error`,error:e.error}},cn=function(){var e=an(t.default.useContext(rn),`calls useCheckoutElements()`).checkoutState;if(e.type===`success`&&e.sdkKind!==`elements`)throw Error(`useCheckoutElements() must be used inside <CheckoutElementsProvider>. Inside <CheckoutFormProvider>, use useCheckoutForm() instead.`);return sn(e)},ln="Invalid prop `stripe` supplied to `CheckoutElementsProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",un=function(e){return e.type===`success`||e.type===`loading`?e.sdk:null},dn=function(e){var n=e.stripe,r=e.options,i=e.children,a=t.default.useMemo(function(){return Jt(n,ln)},[n]),o=J(t.default.useState({type:`loading`,sdk:null}),2),s=o[0],c=o[1],l=J(t.default.useState(null),2),u=l[0],d=l[1],f=t.default.useRef(!1);t.default.useEffect(function(){var e=!0,t=function(t){var n=t.stripe;if(n&&e&&!f.current){f.current=!0;var i=n.initCheckoutElementsSdk(r);c({type:`loading`,sdk:i}),i.loadActions().then(function(e){if(e.type===`success`){var t=e.actions;c({type:`success`,sdkKind:`elements`,sdk:i,checkoutActions:t,session:t.getSession()}),i.on(`change`,function(e){c(function(t){return t.type===`success`&&t.sdkKind===`elements`?{type:`success`,sdkKind:`elements`,sdk:t.sdk,checkoutActions:t.checkoutActions,session:e}:t})})}else c({type:`error`,error:e.error})}).catch(function(e){c({type:`error`,error:e})})}};return a.tag===`async`?a.stripePromise.then(function(e){d(e),e&&t({stripe:e})}):a.tag===`sync`&&(d(a.stripe),t({stripe:a.stripe})),function(){e=!1}},[a,r,c]);var p=Yt(n);t.default.useEffect(function(){p!==null&&p!==n&&console.warn("Unsupported prop change on CheckoutElementsProvider: You cannot change the `stripe` prop after setting it.")},[p,n]);var m=un(s),h=Yt(r);t.default.useEffect(function(){if(m){var e=h?.elementsOptions?.appearance,t=r?.elementsOptions?.appearance,n=!X(t,e);t&&n&&m.changeAppearance(t);var i=h?.elementsOptions?.fonts,a=r?.elementsOptions?.fonts,o=!X(i,a);a&&o&&m.loadFonts(a)}},[r,h,m]),t.default.useEffect(function(){Zt(u)},[u]);var g=t.default.useMemo(function(){return{stripe:u,checkoutState:s}},[u,s]);return t.default.createElement(rn.Provider,{value:g},i)};dn.propTypes={stripe:K.default.any,options:K.default.shape({clientSecret:K.default.oneOfType([K.default.string,K.default.instanceOf(Promise)]).isRequired,elementsOptions:K.default.object}).isRequired};var fn="Invalid prop `stripe` supplied to `CheckoutFormProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",pn=function(e){var n=e.stripe,r=e.options,i=e.children,a=t.default.useMemo(function(){return Jt(n,fn)},[n]),o=J(t.default.useState({type:`loading`,sdk:null}),2),s=o[0],c=o[1],l=J(t.default.useState(null),2),u=l[0],d=l[1],f=t.default.useRef(!1);t.default.useEffect(function(){var e=!0,t=function(t){var n=t.stripe;if(n&&e&&!f.current){f.current=!0;var i=n.initCheckoutFormSdk(r);c({type:`loading`,sdk:i}),i.loadActions().then(function(e){if(e.type===`success`){var t=e.actions;c({type:`success`,sdkKind:`form`,sdk:i,checkoutActions:t,session:t.getSession()}),i.on(`change`,function(e){c(function(t){return t.type===`success`&&t.sdkKind===`form`?{type:`success`,sdkKind:`form`,sdk:t.sdk,checkoutActions:t.checkoutActions,session:e}:t})})}else c({type:`error`,error:e.error})}).catch(function(e){c({type:`error`,error:e})})}};return a.tag===`async`?a.stripePromise.then(function(e){d(e),e&&t({stripe:e})}):a.tag===`sync`&&(d(a.stripe),t({stripe:a.stripe})),function(){e=!1}},[a,r,c]);var p=Yt(n);t.default.useEffect(function(){p!==null&&p!==n&&console.warn("Unsupported prop change on CheckoutFormProvider: You cannot change the `stripe` prop after setting it.")},[p,n]);var m=s.type===`success`||s.type===`loading`?s.sdk:null,h=Yt(r);t.default.useEffect(function(){if(m){var e=h?.appearance,t=r?.appearance,n=!X(t,e);t&&n&&m.changeAppearance(t);var i=h?.fonts,a=r?.fonts,o=!X(i,a);a&&o&&m.loadFonts(a)}},[r,h,m]),t.default.useEffect(function(){Zt(u)},[u]);var g=t.default.useMemo(function(){return{stripe:u,checkoutState:s}},[u,s]);return t.default.createElement(rn.Provider,{value:g},i)};pn.propTypes={stripe:K.default.any,options:K.default.shape({clientSecret:K.default.oneOfType([K.default.string,K.default.instanceOf(Promise)]).isRequired,appearance:K.default.object,loader:K.default.string,fonts:K.default.array,savedPaymentMethod:K.default.object,defaultValues:K.default.object}).isRequired};var Z=function(e,n,r){var i=!!r,a=t.default.useRef(r);t.default.useEffect(function(){a.current=r},[r]),t.default.useEffect(function(){if(!i||!e)return function(){};var t=function(){a.current&&a.current.apply(a,arguments)};return e.on(n,t),function(){e.off(n,t)}},[i,n,e,a])},mn=[`mode`],hn=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},Q=function(e,n,r){var i=r||`${hn(e)}Element`,a=n?function(e){on(`mounts <${i}>`);var n=e.id,r=e.className;return t.default.createElement(`div`,{id:n,className:r})}:function(n){var r=n.id,a=n.className,o=n.options,s=o===void 0?{}:o,c=n.onBlur,l=n.onFocus,u=n.onReady,d=n.onChange,f=n.onEscape,p=n.onClick,m=n.onLoadError,h=n.onLoaderStart,g=n.onNetworksChange,_=n.onConfirm,v=n.onCancel,y=n.onShippingAddressChange,b=n.onShippingRateChange,x=n.onSavedPaymentMethodRemove,S=n.onSavedPaymentMethodUpdate,C=n.onAvailablePaymentMethodsChange,w=on(`mounts <${i}>`),T=`elements`in w?w.elements:null,E=`checkoutState`in w?w.checkoutState:null,D=E?.type===`success`||E?.type===`loading`?E.sdk:null,O=J(t.default.useState(null),2),k=O[0],A=O[1],j=t.default.useRef(null),M=t.default.useRef(null);Z(k,`blur`,c),Z(k,`focus`,l),Z(k,`escape`,f),Z(k,`click`,p),Z(k,`loaderror`,m),Z(k,`loaderstart`,h),Z(k,`networkschange`,g),Z(k,`confirm`,_),Z(k,`cancel`,v),Z(k,`shippingaddresschange`,y),Z(k,`shippingratechange`,b),Z(k,`savedpaymentmethodremove`,x),Z(k,`savedpaymentmethodupdate`,S),Z(k,`availablepaymentmethodschange`,C),Z(k,`change`,d);var N;u&&(N=e===`expressCheckout`?u:function(){u(k)}),Z(k,`ready`,N),t.default.useLayoutEffect(function(){if(j.current===null&&M.current!==null&&(T||D)){var t=null;if(D){var n=D,r=D;switch(e){case`paymentForm`:t=r.createForm(s);break;case`payment`:t=n.createPaymentElement(s);break;case`address`:if(`mode`in s){var a=s.mode,o=Rt(s,mn);if(a===`shipping`)t=n.createShippingAddressElement(o);else if(a===`billing`)t=n.createBillingAddressElement(o);else throw Error(`Invalid options.mode. mode must be 'billing' or 'shipping'.`)}else throw Error(`You must supply options.mode. mode must be 'billing' or 'shipping'.`);break;case`expressCheckout`:t=n.createExpressCheckoutElement(s);break;case`currencySelector`:t=D.createCurrencySelectorElement();break;case`taxId`:t=n.createTaxIdElement(s);break;case`contactDetails`:t=n.createContactDetailsElement();break;default:throw Error(`<${i}> is not supported inside a checkout provider. Use an <Elements> provider instead.`)}}else T&&(t=T.create(e,s));j.current=t,A(t),t&&t.mount(M.current)}},[T,D,s]);var P=Yt(s);return t.default.useEffect(function(){if(j.current){var e=Qt(s,P,[`paymentRequest`]);e&&`update`in j.current&&j.current.update(e)}},[s,P]),t.default.useLayoutEffect(function(){return function(){if(j.current&&typeof j.current.destroy==`function`)try{j.current.destroy(),j.current=null}catch{}}},[]),t.default.createElement(`div`,{id:r,className:a,ref:M})};return a.propTypes={id:K.default.string,className:K.default.string,onChange:K.default.func,onBlur:K.default.func,onFocus:K.default.func,onReady:K.default.func,onEscape:K.default.func,onClick:K.default.func,onLoadError:K.default.func,onLoaderStart:K.default.func,onNetworksChange:K.default.func,onConfirm:K.default.func,onCancel:K.default.func,onShippingAddressChange:K.default.func,onShippingRateChange:K.default.func,onSavedPaymentMethodRemove:K.default.func,onSavedPaymentMethodUpdate:K.default.func,onAvailablePaymentMethodsChange:K.default.func,options:K.default.object},a.displayName=i,a.__elementType=e,a},$=typeof window>`u`;Q(`currencySelector`,$);var gn=Q(`payment`,$);Q(`paymentForm`,$,`CheckoutForm`),Q(`expressCheckout`,$),Q(`taxId`,$);var _n=Q(`contactDetails`,$);Q(`address`,$);function vn(e){"@babel/helpers - typeof";return vn=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},vn(e)}var yn=`dahlia`,bn=function(e){return e===3?`v3`:e},xn=`https://js.stripe.com`,Sn=`${xn}/${yn}/stripe.js`,Cn=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,wn=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,Tn=`loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used`,En=function(e){return Cn.test(e)||wn.test(e)},Dn=function(){for(var e=document.querySelectorAll(`script[src^="${xn}"]`),t=0;t<e.length;t++){var n=e[t];if(En(n.src))return n}return null},On=function(e){var t=e&&!e.advancedFraudSignals?`?advancedFraudSignals=false`:``,n=document.createElement(`script`);n.src=`${Sn}${t}`;var r=document.head||document.body;if(!r)throw Error(`Expected document.body not to be null. Stripe.js requires a <body> element.`);return r.appendChild(n),n},kn=function(e,t){!e||!e._registerWrapper||e._registerWrapper({name:`stripe-js`,version:`9.6.0`,startTime:t})},An=null,jn=null,Mn=null,Nn=function(e){return function(t){e(Error(`Failed to load Stripe.js`,{cause:t}))}},Pn=function(e,t){return function(){window.Stripe?e(window.Stripe):t(Error(`Stripe.js not available`))}},Fn=function(e){return An===null?(An=new Promise(function(t,n){if(typeof window>`u`||typeof document>`u`){t(null);return}if(window.Stripe&&e&&console.warn(Tn),window.Stripe){t(window.Stripe);return}try{var r=Dn();if(r&&e)console.warn(Tn);else if(!r)r=On(e);else if(r&&Mn!==null&&jn!==null){var i;r.removeEventListener(`load`,Mn),r.removeEventListener(`error`,jn),(i=r.parentNode)==null||i.removeChild(r),r=On(e)}Mn=Pn(t,n),jn=Nn(n),r.addEventListener(`load`,Mn),r.addEventListener(`error`,jn)}catch(e){n(e);return}}),An.catch(function(e){return An=null,Promise.reject(e)})):An},In=function(e,t,n){if(e===null)return null;var r=t[0];if(typeof r!=`string`)throw Error(`Expected publishable key to be of type string, got type ${vn(r)} instead.`);var i=r.match(/^pk_test/),a=bn(e.version),o=yn;i&&a!==o&&console.warn(`Stripe.js@${a} was loaded on the page, but @stripe/stripe-js@9.6.0 expected Stripe.js@${o}. This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning`);var s=e.apply(void 0,t);return kn(s,n),s},Ln,Rn=!1,zn=function(){return Ln||(Ln=Fn(null).catch(function(e){return Ln=null,Promise.reject(e)}),Ln)};Promise.resolve().then(function(){return zn()}).catch(function(e){Rn||console.warn(e)});var Bn=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];Rn=!0;var r=Date.now();return zn().then(function(e){return In(e,t,r)})},Vn=`-`;function Hn(e){return e===void 0?Vn:`$${new Intl.NumberFormat(`en-US`).format(Number(e||0))}`}function Un(e){return(0,o.jsx)(r.Typography.Text,{className:`text-arco-text-1! text-3xl! leading-tight! font-bold!`,children:Hn(e)})}function Wn({text:e,onSuccess:n}){let i=cn(),[a,s]=(0,t.useState)(``),[c,l]=(0,t.useState)(!1);if(i.type===`loading`)return(0,o.jsx)(`div`,{className:`flex min-h-80 items-center justify-center`,children:(0,o.jsx)(r.Spin,{tip:e.stripePaymentLoading})});if(i.type===`error`)return(0,o.jsx)(r.Alert,{type:`error`,content:i.error.message});let{checkout:u}=i,d=u.total.total.amount;return(0,o.jsxs)(`form`,{className:`flex flex-col gap-6`,onSubmit:async t=>{if(t.preventDefault(),!(!u.canConfirm||c)){l(!0),s(``);try{let e=await u.confirm({redirect:`if_required`});if(e.type===`error`){s(e.error.message);return}n()}catch(t){s(t instanceof Error?t.message:e.stripePaymentFailed)}finally{l(!1)}}},children:[(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,o.jsx)(r.Typography.Title,{heading:6,className:`text-arco-text-1! mb-0!`,children:e.stripeContactDetails}),(0,o.jsx)(_n,{})]}),(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,o.jsx)(r.Typography.Title,{heading:6,className:`text-arco-text-1! mb-0!`,children:e.stripePaymentSection}),(0,o.jsx)(gn,{id:`mantur-stripe-payment-element`})]}),(0,o.jsxs)(r.Button,{htmlType:`submit`,type:`primary`,size:`large`,className:`w-full!`,disabled:!u.canConfirm||c,loading:c,children:[e.stripePay,` · `,d]}),a?(0,o.jsx)(r.Alert,{type:`error`,content:a}):null]})}function Gn({visible:e,publishableKey:n,order:i,text:a,onCancel:c,onSuccess:l}){let{resolvedTheme:u}=(0,s.useTheme)(),[d,f]=(0,t.useState)(!1),p=(0,t.useRef)(!1),m=i?.clientSecret||i?.stripeClientSecret,h=(0,t.useMemo)(()=>n?Bn(n):null,[n]),g=u===`dark`?`night`:`flat`,_=(0,t.useMemo)(()=>m?{clientSecret:m,elementsOptions:{appearance:{theme:g,labels:`above`}}}:void 0,[m,g]),v=(0,t.useMemo)(()=>[{label:a.stripePaymentTotalAmount,value:Un(i?.amount)},{label:a.stripePaymentOrderNo,value:i?.orderNo||Vn}],[i?.amount,i?.orderNo,a.stripePaymentOrderNo,a.stripePaymentTotalAmount]),y=(0,t.useCallback)(async()=>{if(p.current)return;let e=i?.orderNo;if(!e){c();return}p.current=!0,f(!0);try{await B(e)}catch(e){console.warn(`Failed to cancel Mantur recharge order.`,e)}finally{p.current=!1,f(!1),c()}},[c,i?.orderNo]),b=!n||!h?(0,o.jsx)(r.Alert,{type:`error`,content:a.stripePaymentConfigMissing}):m?m.startsWith(`cs_`)?_?(0,o.jsx)(dn,{stripe:h,options:_,children:(0,o.jsx)(Wn,{text:a,onSuccess:l})},`${m}-${g}`):(0,o.jsx)(r.Alert,{type:`error`,content:a.stripePaymentClientSecretMissing}):(0,o.jsx)(r.Alert,{type:`error`,content:a.stripeCheckoutClientSecretInvalid}):(0,o.jsx)(r.Alert,{type:`error`,content:a.stripePaymentClientSecretMissing});return(0,o.jsx)(r.Modal,{title:a.stripePaymentTitle,visible:e,closeIcon:null,footer:(0,o.jsx)(`div`,{className:`flex justify-end gap-2 mx-auto max-w-7xl `,children:(0,o.jsx)(r.Button,{size:`large`,type:`primary`,status:`danger`,disabled:d,loading:d,onClick:()=>void y(),children:a.close})}),onCancel:()=>void y(),alignCenter:!1,wrapStyle:{padding:0},style:{width:`100vw`,maxWidth:`100vw`,height:`100vh`,top:0,margin:0,padding:0},className:`top-0! m-0! flex! h-screen! w-screen! max-w-none! flex-col! rounded-none! [&_.arco-modal-body]:min-h-0! [&_.arco-modal-body]:flex-1! [&_.arco-modal-body]:overflow-auto! [&_.arco-modal-content]:flex! [&_.arco-modal-content]:h-full! [&_.arco-modal-content]:flex-col! [&_.arco-modal-content]:rounded-none! [&_.arco-modal-header]:shrink-0!`,focusLock:!1,children:(0,o.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-7xl gap-8 px-6 py-6 lg:px-8`,children:[(0,o.jsx)(`div`,{className:`w-80`,children:(0,o.jsx)(`div`,{className:`bg-arco-bg-1 mx-auto w-full rounded-xl p-6`,children:(0,o.jsx)(r.Descriptions,{border:!1,column:1,data:v,labelStyle:{width:96}})})}),(0,o.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,o.jsx)(`div`,{className:`bg-arco-bg-1 mx-auto w-full max-w-2xl rounded-xl p-6`,children:b})})]})})}function Kn({user:e,points:t,rechargeEnabled:n,text:a,onEditProfile:s,onRecharge:c,onPointsDetail:l,onLogout:u}){let d=e=>new Intl.NumberFormat().format(e);return(0,o.jsxs)(`div`,{className:`w-80 overflow-hidden rounded-xl border border-arco-border-2 bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)]`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-3 px-6 pt-5 pb-4`,children:[(0,o.jsx)(xt,{user:e,size:48,className:`shrink-0`}),(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,o.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,o.jsx)(`span`,{className:`text-arco-text-1 truncate text-base leading-6 font-bold`,children:e?.nickname||e?.username}),(0,o.jsx)(r.Button,{type:`text`,size:`mini`,icon:(0,o.jsx)(i.IconEdit,{}),className:`text-arco-text-3 h-6! min-w-6! px-0!`,onClick:s})]}),e?.email?(0,o.jsx)(`span`,{className:`text-arco-text-3 truncate text-xs leading-5`,children:e.email}):null]})]}),(0,o.jsx)(r.Divider,{className:`m-0!`}),(0,o.jsxs)(`ul`,{className:`flex flex-col gap-3.5 px-6 py-4`,children:[(0,o.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,o.jsx)(`span`,{children:a.myPoints}),(0,o.jsx)(`strong`,{className:`text-arco-primary-6 text-base font-bold`,children:d(t.total)})]}),(0,o.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,o.jsx)(`span`,{children:a.rechargePoints}),(0,o.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:d(t.recharge)})]}),(0,o.jsxs)(`li`,{className:`text-arco-text-2 flex items-center justify-between gap-4 text-sm`,children:[(0,o.jsx)(`span`,{children:a.giftedPoints}),(0,o.jsx)(`strong`,{className:`text-arco-text-1 text-base font-bold`,children:d(t.gifted)})]})]}),(0,o.jsx)(r.Divider,{className:`m-0!`}),(0,o.jsxs)(`div`,{className:`flex flex-col gap-2 px-6 py-4`,children:[n?(0,o.jsx)(r.Button,{type:`primary`,long:!0,icon:(0,o.jsx)(i.IconPlus,{}),shape:`round`,className:`h-10! font-medium!`,onClick:c,children:a.recharge}):null,(0,o.jsx)(r.Button,{long:!0,shape:`round`,icon:(0,o.jsx)(i.IconFile,{}),className:`border-arco-border-2! bg-arco-fill-1! text-arco-text-1! h-10! font-medium!`,onClick:l,children:a.pointsDetail})]}),(0,o.jsx)(r.Divider,{className:`m-0!`}),(0,o.jsx)(`div`,{className:`px-6 py-4`,children:(0,o.jsx)(r.Button,{icon:(0,o.jsx)(i.IconPoweroff,{}),type:`text`,status:`danger`,long:!0,className:`flex! items-center justify-start gap-2 text-sm text-arco-text-2`,onClick:()=>void u?.(),children:a.logout})})]})}var qn=`https://mantur.ai/images/logo.png`,Jn=[`from-arco-primary-light-1 to-arco-primary-light-2 text-arco-primary-6`,`from-arco-success-light-1 to-arco-success-light-2 text-arco-success-6`,`from-arco-warning-light-1 to-arco-warning-light-2 text-arco-warning-6`,`from-arco-danger-light-1 to-arco-danger-light-2 text-arco-danger-6`];function Yn(e,t=!1){return`flex h-8 min-h-8 w-8 min-w-8 flex-none items-center justify-center rounded-lg bg-linear-to-br font-bold leading-none ${Jn[e%Jn.length]} ${t?`shadow-[inset_0_1px_3px_rgb(0_0_0/8%)]`:``}`}function Xn(e){return e?.tenantName?.[0]?.toUpperCase()||`T`}function Zn(e,t,n){let r=e?.roles?.map(e=>e.roleName).filter(Boolean);return r?.length?r.join(`, `):e?.isOwner?t:n}function Qn({user:e,disabled:a=!1,brandSlot:s,children:c,onTenantContextChange:l,appName:u,mainPrefix:d,stripePublishableKey:f}){let p=(0,n.usePostHog)(),[m,h]=(0,t.useState)(()=>W()),g=Pe(m),[_,v]=(0,t.useState)(!1),[y,b]=(0,t.useState)(!1),[x,S]=(0,t.useState)(()=>G().enabled),[C,w]=(0,t.useState)(!1),[T,E]=(0,t.useState)(e),[D,O]=(0,t.useState)([]),[A,j]=(0,t.useState)(),[M,F]=(0,t.useState)(!1),[ee,te]=(0,t.useState)(!1),[ne,re]=(0,t.useState)(!1),[ie,ae]=(0,t.useState)([]),[L,R]=(0,t.useState)(),ce=(0,t.useRef)(l),le=f||(typeof window<`u`?window.__MANTUR_COMPONENTS_STRIPE_PUBLISHABLE_KEY__:void 0)||`pk_test_51TJ8JiERSsQknDG7bJSIX81RFq3LcCfUXCV7mh0cQsZ2dwmYcJ5Ki6bPXynNvdyZEEBE83I6I719NIFyO9Qreey700yPAul8sv`,de=d??(typeof window<`u`?window.__MANTUR_MAIN_PREFIX__:void 0)??void 0,fe=u??(typeof window<`u`?window.__MANTUR_APP_NAME__:void 0)??void 0,[pe,he]=(0,t.useState)({total:0,recharge:0,gifted:0}),z=A?.tenantId||``,B=a,_e={total:pe.total??0,recharge:pe.recharge??0,gifted:pe.gifted??0},ve=async e=>{let t=await se(e);return t&&E(t),t},V=(0,t.useCallback)((e,t={})=>{Xe(e,{app_name:fe,tenant_id:z,user_id:T?.userId,...t},p)},[T?.userId,p,fe,z]);(0,t.useEffect)(()=>{E(e)},[e]),(0,t.useEffect)(()=>{ce.current=l},[l]);let H=(0,t.useCallback)(e=>{O(e.tenants),j(e.currentTenant),ce.current?.(e)},[]);(0,t.useEffect)(()=>{F(!0),we().then(H).catch(e=>{console.warn(`Failed to refresh Mantur tenant context.`,e),r.Message.error(g.error)}).finally(()=>F(!1))},[H,g.error]),(0,t.useEffect)(()=>{let e=e=>{e instanceof CustomEvent&&he(e.detail)};return window.addEventListener(N,e),ue().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)}),()=>{window.removeEventListener(N,e)}},[]),(0,t.useEffect)(()=>{let e=Ke(e=>{S(e.enabled)});return qe().catch(e=>{console.warn(`Failed to refresh Mantur recharge config.`,e)}),e},[]),(0,t.useEffect)(()=>{let e=()=>{G().enabled&&b(!0)};return window.addEventListener(I,e),()=>{window.removeEventListener(I,e)}},[]),(0,t.useEffect)(()=>{x||b(!1)},[x]),(0,t.useEffect)(()=>{let e=e=>{h(e instanceof CustomEvent?U(e.detail):W())};return window.addEventListener(Me,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(Me,e),window.removeEventListener(`storage`,e)}},[]),(0,t.useEffect)(()=>{!y||!x||(te(!0),me().then(e=>{let t=e.filter(e=>e.id&&e.amount!==void 0&&e.points!==void 0).sort((e,t)=>(e.sortOrder??0)-(t.sortOrder??0)).map(e=>({id:e.id,packageCode:e.packageCode,packageName:e.packageName,packageNameEn:e.packageNameEn,price:Number(e.amount||0),points:Number(e.points||0),recommended:e.isRecommended,sortOrder:e.sortOrder}));t.length>0&&ae(t)}).catch(e=>{console.warn(`Failed to load Mantur recharge packages.`,e)}).finally(()=>te(!1)))},[x,y]);let ye=e=>{r.Message.success(e)},be=(e,t)=>{console.error(t),r.Message.error(e)},xe=(0,t.useCallback)(async e=>{if(!B&&e!==z)try{F(!0),H(await Te(e)),V(`mantur_header_tenant_switch`,{next_tenant_id:e}),ye(g.switchedToTeam)}catch(e){be(g.error,e)}finally{F(!1)}},[H,V,z,B,g.error,g.switchedToTeam]),Se=async e=>{let t=u?.trim();try{re(!0);let n=await ge({...`custom`in e&&e.custom?{customAmount:e.price}:{packageId:e.id},...t?{app:t}:{},uiMode:`elements`});if(!n){r.Message.error(g.stripePaymentClientSecretMissing);return}typeof window<`u`&&window.dispatchEvent(new CustomEvent(P,{detail:n})),r.Message.success(g.rechargeOrderCreated),V(`mantur_header_recharge_order_created`,{order_no:n.orderNo,amount:n.amount,points:n.points}),b(!1),R(n)}catch(e){be(g.error,e)}finally{re(!1)}},Ce=(0,t.useCallback)(()=>{V(`mantur_header_logo_click`),k(de)},[V,de]),Ee=(0,t.useMemo)(()=>(0,o.jsxs)(r.Menu,{className:`w-56 rounded-xl bg-arco-bg-popup shadow-[0_10px_28px_rgb(0_0_0/12%)] [&_.arco-menu-inner]:px-2 [&_.arco-menu-inner]:py-1`,selectedKeys:z?[z]:[],onClickMenuItem:xe,children:[(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold tracking-[0.04em] text-arco-text-4 uppercase`,children:g.switchTeam}),D.map((e,t)=>(0,o.jsx)(r.Menu.Item,{className:`mb-1 h-auto! min-h-10! overflow-visible! rounded-lg! px-2! py-1! leading-normal!`,children:(0,o.jsxs)(`div`,{className:`flex w-full items-center gap-3 leading-normal`,children:[(0,o.jsx)(`div`,{className:Yn(t),children:Xn(e)}),(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-0.75`,children:[(0,o.jsx)(`span`,{className:`text-sm leading-5 font-medium text-arco-text-1`,children:e.tenantName}),(0,o.jsx)(`span`,{className:`text-xs leading-4 text-arco-text-3`,children:Zn(e,g.owner,g.member)})]})]})},e.tenantId))]}),[xe,z,D,g]),De=(0,o.jsx)(Kn,{user:T,points:_e,rechargeEnabled:x,text:g,onEditProfile:()=>{V(`mantur_header_profile_open`),v(!0)},onRecharge:()=>{V(`mantur_header_recharge_open`,{entry:`user_menu`}),b(!0)},onPointsDetail:()=>{V(`mantur_header_points_detail_open`),w(!0)},onLogout:()=>(V(`mantur_header_logout_click`),oe())}),Oe=Math.max(0,D.findIndex(e=>e.tenantId===A?.tenantId));return(0,o.jsxs)(`div`,{className:`flex h-20 items-center justify-between bg-transparent pr-8 shadow-[0_2px_10px_rgb(0_0_0/2%)] backdrop-blur-md max-md:pr-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,o.jsxs)(`div`,{className:`flex w-65 items-center gap-3 px-8 max-md:w-auto max-md:px-4`,children:[(0,o.jsx)(r.Tooltip,{content:g.home,position:`bottom`,children:(0,o.jsx)(`button`,{type:`button`,"aria-label":g.home,className:`relative flex w-12 cursor-pointer items-center justify-center overflow-hidden rounded-md border-0 bg-transparent p-0 transition-opacity hover:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-arco-primary-6`,onClick:Ce,children:(0,o.jsx)(`img`,{src:qn,alt:`logo`,className:`w-full object-contain`,onError:e=>{e.currentTarget.style.display=`none`}})})}),s??(0,o.jsx)(`span`,{className:`text-lg font-bold tracking-normal text-arco-text-1`,children:g.title})]}),(0,o.jsx)(r.Dropdown,{droplist:Ee,trigger:`click`,position:`bl`,disabled:B,children:(0,o.jsxs)(`div`,{"aria-disabled":B,className:`flex items-center gap-3 rounded-full border border-arco-border-1 bg-arco-bg-1 px-2 py-1.5 transition-all ${B?`cursor-not-allowed opacity-60`:`cursor-pointer hover:bg-arco-fill-2 hover:shadow-[0_4px_12px_rgb(0_0_0/8%)]`}`,children:[(0,o.jsx)(`div`,{className:Yn(Oe,!0),children:Xn(A)}),(0,o.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,o.jsx)(`span`,{className:`text-xs leading-none font-bold text-arco-text-1`,children:M?g.loading:A?.tenantName||g.loading}),(0,o.jsx)(`span`,{className:`mt-1 text-[10px] leading-none text-arco-text-3`,children:Zn(A,g.owner,g.member)})]}),(0,o.jsx)(i.IconDown,{className:`ml-1 text-arco-text-3`})]})})]}),(0,o.jsx)(`div`,{className:`flex-1`,children:c}),(0,o.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,o.jsx)(Je,{}),(0,o.jsx)(Re,{})]}),(0,o.jsx)(r.Dropdown,{droplist:De,trigger:`click`,position:`br`,onVisibleChange:e=>{e&&(V(`mantur_header_user_menu_open`),ue().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)}),qe().catch(e=>{console.warn(`Failed to refresh Mantur recharge config.`,e)}))},children:(0,o.jsxs)(`div`,{className:`hover:bg-arco-fill-2 flex cursor-pointer items-center gap-2.5 rounded-full border border-transparent p-1 pr-2 transition-all`,children:[(0,o.jsxs)(`div`,{className:`from-arco-primary to-transparent relative rounded-full bg-linear-to-br p-0.5 shadow-sm`,children:[(0,o.jsx)(xt,{user:T,size:36}),(0,o.jsx)(`div`,{className:`bg-arco-success border-arco-bg-white absolute right-0 bottom-0 h-3 w-3 rounded-full border-2 shadow-sm`})]}),(0,o.jsx)(`div`,{className:`hidden flex-col md:flex`,children:(0,o.jsx)(`span`,{className:`text-arco-text-1 text-sm font-medium`,children:T?.nickname||T?.username})}),(0,o.jsx)(i.IconDown,{className:`text-arco-text-3 ml-1`})]})})]}),(0,o.jsx)(vt,{visible:_,user:T,labels:g,onCancel:()=>v(!1),onSubmit:ve}),(0,o.jsx)(wt,{visible:y,user:T,points:_e,text:g,packages:ie,packageLoading:ee,submitting:ne,onCancel:()=>b(!1),onPay:Se}),(0,o.jsx)(ft,{visible:C,points:_e,rechargeEnabled:x,text:g,onCancel:()=>w(!1),onRecharge:()=>{V(`mantur_header_recharge_open`,{entry:`points_detail`}),b(!0)}}),(0,o.jsx)(Gn,{visible:!!L,publishableKey:le,order:L,text:g,onCancel:()=>R(void 0),onSuccess:()=>{r.Message.success(g.rechargeSuccess),V(`mantur_header_stripe_payment_success`,{order_no:L?.orderNo,amount:L?.amount,points:L?.points}),R(void 0),ue().catch(e=>{console.warn(`Failed to refresh Mantur user points.`,e)})}})]})}function $n(e){return new Intl.NumberFormat().format(e)}function er(){typeof window>`u`||window.dispatchEvent(new CustomEvent(I))}function tr(e,t){return(0,o.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm text-arco-text-2`,children:[(0,o.jsx)(`div`,{className:`border-arco-border-1 bg-arco-fill-1 flex flex-col overflow-hidden rounded-lg border`,children:[{label:t.currentBalance,value:$n(e.balance),valueClassName:`text-arco-primary-6!`},{label:t.insufficientBalanceDeductPoints||`Points to consume`,value:$n(e.deductPoints),valueClassName:`text-arco-danger-6!`}].map(e=>(0,o.jsxs)(`div`,{className:`border-arco-border-1 flex items-center justify-between gap-4 border-b px-3 py-3 last:border-b-0`,children:[(0,o.jsx)(`div`,{className:`text-arco-text-2 text-sm leading-5`,children:e.label}),(0,o.jsxs)(`div`,{className:`${e.valueClassName} text-right text-2xl leading-7 font-bold`,children:[e.value,(0,o.jsx)(`span`,{className:`text-arco-text-3 ml-1 text-xs font-normal`,children:t.pointsUnit})]})]},e.label))}),e.rechargeEnabled?null:(0,o.jsx)(`span`,{className:`leading-6 text-arco-text-2`,children:t.insufficientBalanceContactAdminGuide})]})}function nr(e,t){if(typeof window>`u`)return;let n=Pe(W()),i=e.rechargeEnabled?()=>{if(t.onRecharge){t.onRecharge();return}er()}:t.onContactAdmin;r.Modal.confirm({title:t.title||n.insufficientBalanceTitle,content:t.content||tr(e,n),className:`[&_.arco-modal-footer]:text-right!`,okText:e.rechargeEnabled?n.recharge:n.contactAdmin,cancelText:n.close,onOk:i})}async function rr(e,t={}){let n=await pe(e);if(n.enough)return{...n,rechargeEnabled:G().enabled};let r=await qe().catch(e=>(console.warn(`Failed to refresh Mantur recharge config.`,e),G())),i={...n,rechargeEnabled:r.enabled};return t.showModal!==!1&&nr(i,t),i}var ir=`mantur-stripe-payment-window`,ar=`/stripe-payment`;function or(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.source===`mantur-components`&&t.type===`mantur-stripe-payment-window`&&(t.action===`close`||t.action===`success`||t.action===`failed`)}function sr(e=`close`,t,n=typeof window>`u`?void 0:window.location.origin){if(typeof window>`u`||!n)return;let r={source:`mantur-components`,type:ir,action:e,orderNo:t};window.opener?.postMessage(r,n),window.parent&&window.parent!==window&&window.parent.postMessage(r,n)}function cr(){return typeof window>`u`?void 0:window.__MANTUR_MAIN_PREFIX__||void 0}function lr(){return typeof window>`u`?`mantur`:window.__MANTUR_APP_NAME__||`mantur`}function ur(e,t){let n=e.split(`.`);return n.length<=1?t:[t,...n.slice(1)].join(`.`)}function dr(e){let t=new URL(e.toString()),n=cr()?.trim();return n&&lr()!==`mantur`&&(t.hostname=ur(e.hostname,n)),t.port=``,t.toString()}function fr(e,t={}){let n=e.clientSecret||e.stripeClientSecret;if(typeof window>`u`||!e.orderNo||!n)return;let r=new URL(ar,window.location.href),i=D(),a=t.app||i.app,o=t.redirect||i.redirect;return r.searchParams.set(`orderNo`,e.orderNo),r.searchParams.set(`clientSecret`,n),r.searchParams.set(`openerOrigin`,window.location.origin),r.searchParams.set(`app`,a),r.searchParams.set(`redirect`,o),e.amount!==void 0&&r.searchParams.set(`amount`,String(e.amount)),e.points!==void 0&&r.searchParams.set(`points`,String(e.points)),t.stripePublishableKey&&r.searchParams.set(`publishableKey`,t.stripePublishableKey),dr(r)}function pr(e,t={}){return fr(e,t)||e.paymentUrl||e.checkoutUrl||e.url||e.returnUrl}e.MANTUR_POINTS_REFRESH_EVENT=N,e.MANTUR_RECHARGE_CONFIG_CHANGE_EVENT=F,e.MANTUR_RECHARGE_ORDER_CREATED_EVENT=P,e.MANTUR_RECHARGE_REQUEST_EVENT=I,e.MANTUR_STRIPE_PAYMENT_ROUTE=ar,e.MANTUR_STRIPE_PAYMENT_WINDOW_MESSAGE_TYPE=ir,e.MANTUR_TENANT_CONTEXT_CHANGE_EVENT=ee,e.ManturHeader=Qn,e.cancelManturRechargeOrder=B,e.captureManturComponentEvent=Xe,e.checkManturBalanceEnough=pe,e.createManturRechargeOrder=ge,e.ensureManturBalanceEnough=rr,e.formatDateByLang=Qe,e.getManturBillingAccount=V,e.getManturBillingLedger=H,e.getManturBillingPackages=me,e.getManturPricingChargePoint=ve,e.getManturPricingChargePoints=_e,e.getManturRechargeConfig=he,e.getManturRechargeConfigSnapshot=G,e.getManturRechargeOrder=z,e.getManturRechargeRedirectContext=D,e.isManturStripePaymentWindowMessage=or,e.openManturRechargeModal=er,e.postManturStripePaymentWindowMessage=sr,e.redirectToManturMain=A,e.redirectToManturMainHome=k,e.refreshManturRechargeConfig=qe,e.refreshManturTenantContext=we,e.refreshManturUserPoints=ue,e.resolveManturMainHomeUrl=O,e.resolveManturRechargePaymentPageUrl=pr,e.resolveManturStripePaymentPageUrl=fr,e.subscribeManturRechargeConfig=Ke});
|