@abtnode/blocklet-services 1.16.38-beta-20250110-093740-edc58f78 → 1.16.38-beta-20250115-235439-bb5a1c1b

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.
Files changed (147) hide show
  1. package/api/libs/connect/session.js +47 -9
  2. package/api/routes/oauth.js +5 -7
  3. package/api/routes/user.js +6 -8
  4. package/api/services/dashboard/index.js +6 -2
  5. package/dist/assets/{Add-2VCvBnGd.js → Add-C6s-Vnmg.js} +1 -1
  6. package/dist/assets/{ArrowDropDown-BdHlAt9a.js → ArrowDropDown-vKf3f5eE.js} +1 -1
  7. package/dist/assets/{CheckCircle-BElcljFC.js → CheckCircle-D3sLlO8U.js} +1 -1
  8. package/dist/assets/{ChevronLeft-BfF37o7u.js → ChevronLeft-COXTEKCd.js} +1 -1
  9. package/dist/assets/{ChevronRight-B8pf890W.js → ChevronRight-DnoIUF6_.js} +1 -1
  10. package/dist/assets/{DeleteOutline-VzoIEqow.js → DeleteOutline-BkfiCnRt.js} +1 -1
  11. package/dist/assets/{Done-BCESxXX2.js → Done-zh2eXk8O.js} +1 -1
  12. package/dist/assets/{Download-BJmwtO6i.js → Download-9HhUOVnv.js} +1 -1
  13. package/dist/assets/{Error-CpAOVH8t.js → Error-CpLyAhkv.js} +1 -1
  14. package/dist/assets/{Google-rxW6OGq8.js → Google-thaEal7z.js} +1 -1
  15. package/dist/assets/{InfoOutlined-BFP30UJa.js → InfoOutlined-phoVf4hW.js} +1 -1
  16. package/dist/assets/{Launch-BOCFiYoz.js → Launch-B3dFrLjr.js} +1 -1
  17. package/dist/assets/{LaunchOutlined-B-PaS5ms.js → LaunchOutlined-DtUHpbN5.js} +1 -1
  18. package/dist/assets/{Loop-n5c7A0qE.js → Loop-AE9uCvcp.js} +1 -1
  19. package/dist/assets/{MoreHoriz-DnFq43xg.js → MoreHoriz-CUgH0jV-.js} +1 -1
  20. package/dist/assets/{PlayArrow-oA7gV2MA.js → PlayArrow-Du9tHm7-.js} +1 -1
  21. package/dist/assets/{ViewList-IMqkd2Sv.js → ViewList-BUKDlFq_.js} +1 -1
  22. package/dist/assets/_createAggregator-DqBCPv73.js +1 -0
  23. package/dist/assets/{access-control-DcliPEX2.js → access-control-CQEVUKlf.js} +1 -1
  24. package/dist/assets/{actions-BEpPU26q.js → actions-B2A8ao0K.js} +1 -1
  25. package/dist/assets/{add-component-core-DSlHbXth.js → add-component-core-CWVYZ8WA.js} +3 -3
  26. package/dist/assets/{add-resource-B9SUcn9b.js → add-resource-0OEygRwE.js} +1 -1
  27. package/dist/assets/{addon-C8Ytd8YY.js → addon-BQKNb4Py.js} +1 -1
  28. package/dist/assets/{analytics-BVmtToBr.js → analytics-BIzuxCPf.js} +1 -1
  29. package/dist/assets/{ar-DuHAbPhE.js → ar-7ttREm7R.js} +2 -2
  30. package/dist/assets/{ar-hiIrGdss.js → ar-Da8oOZhL.js} +1 -1
  31. package/dist/assets/{audit-logs-DOpEhbRi.js → audit-logs-CeDS3WGD.js} +1 -1
  32. package/dist/assets/{base32-COJTblwx.js → base32-C41aFfgE.js} +1 -1
  33. package/dist/assets/{branding-BIbnR-Yt.js → branding-Dmu7SZwa.js} +2 -2
  34. package/dist/assets/{bundle-avatar-DqROxHMq.js → bundle-avatar-Dx7DsJvg.js} +1 -1
  35. package/dist/assets/{button-Bo5ZAcJk.js → button-pEMdQ6vg.js} +1 -1
  36. package/dist/assets/{click-to-copy-DNu8CktB.js → click-to-copy-w1sXXA5-.js} +1 -1
  37. package/dist/assets/{complete-B_C_fwut.js → complete-BkbfIahT.js} +1 -1
  38. package/dist/assets/{component-eAmweIYL.js → component-SByzcdSk.js} +1 -1
  39. package/dist/assets/{config-d41PVAVu.js → config-CJbAebUi.js} +1 -1
  40. package/dist/assets/{config-CWoxBu0J.js → config-DkAoqJrm.js} +2 -2
  41. package/dist/assets/{config-navigation-jKhcoDId.js → config-navigation-D3CEseYs.js} +3 -3
  42. package/dist/assets/{config-space-Dofzrh5m.js → config-space-CVzrNiJs.js} +1 -1
  43. package/dist/assets/{confirm-C0rryr4e.js → confirm-BHRsp-P-.js} +1 -1
  44. package/dist/assets/{connect-CfWNBUY4.js → connect-D7u7zAHW.js} +1 -1
  45. package/dist/assets/{connect-Wiz0Gw9I.js → connect-FahpyiOI.js} +1 -1
  46. package/dist/assets/connect-to-DgFj0KxA.js +1 -0
  47. package/dist/assets/{dashboard-Ca8O6iHB.js → dashboard-z7zVrYGA.js} +3 -3
  48. package/dist/assets/{de-D_LJn5nm.js → de-BYtQQOr-.js} +1 -1
  49. package/dist/assets/{de-CJi7wiel.js → de-rZ-qvWqU.js} +2 -2
  50. package/dist/assets/{did-address-49U3oRW2.js → did-address-vWQGhW6L.js} +1 -1
  51. package/dist/assets/{domain-list-BEjAE8hh.js → domain-list-D8GpnsIy.js} +2 -2
  52. package/dist/assets/{domain-DJyjDPmO.js → domain-mBK5lWF5.js} +1 -1
  53. package/dist/assets/{email-C3ggDSGp.js → email-C14Xa0wL.js} +2 -2
  54. package/dist/assets/{es-ClwhOFrW.js → es-BU9x-PJk.js} +2 -2
  55. package/dist/assets/{es-B0ocJhTd.js → es-BYjXKvnd.js} +1 -1
  56. package/dist/assets/{exchange-passport-4QuzoW2F.js → exchange-passport-B1Fx0Rd9.js} +1 -1
  57. package/dist/assets/{form-text-input-CT57jMfW.js → form-text-input-IJ-ksbZ2.js} +1 -1
  58. package/dist/assets/{fr-CAkkNKvy.js → fr-DW8hDuav.js} +2 -2
  59. package/dist/assets/{fr-eolYJCOV.js → fr-Di7fDhg9.js} +1 -1
  60. package/dist/assets/{fuel-CJ-CsgDu.js → fuel-Czk5ukUs.js} +1 -1
  61. package/dist/assets/{fullpage-CFp4hSHz.js → fullpage-DTja3SmB.js} +1 -1
  62. package/dist/assets/{get-safe-url-CVhAz4Qr.js → get-safe-url-BuiowS2J.js} +1 -1
  63. package/dist/assets/{get-safe-url-RTzyOi09.js → get-safe-url-Ddj-Tmsl.js} +1 -1
  64. package/dist/assets/{hi-CGrG89HI.js → hi-BBATPy58.js} +1 -1
  65. package/dist/assets/{hi-DSwvTH0x.js → hi-JrL4jTWL.js} +1 -1
  66. package/dist/assets/{home-D1QP6Ilh.js → home-CB9sf1Sa.js} +1 -1
  67. package/dist/assets/{id-D6PyIa8m.js → id-B3tqmZ1i.js} +2 -2
  68. package/dist/assets/{id-5G9oPRk4.js → id-CgtYzmhQ.js} +1 -1
  69. package/dist/assets/{iframe-BUonayoL.js → iframe-ITMZuuxP.js} +1 -1
  70. package/dist/assets/{index-wG4Kh8A_.js → index-BjauMU9c.js} +27 -27
  71. package/dist/assets/{index-BQxL3qXG.js → index-C76B4rKX.js} +1 -1
  72. package/dist/assets/{index-BZnWmdZ0.js → index-CCUCWBor.js} +7 -7
  73. package/dist/assets/{index-ROkOEO9F.js → index-CJxgi_0G.js} +1 -1
  74. package/dist/assets/{index-IdPbsC-k.js → index-CYcmGLzu.js} +1 -1
  75. package/dist/assets/{index-DMelUylN.js → index-CaHJ0Ch7.js} +15 -15
  76. package/dist/assets/{index-CQT4qLcx.js → index-CoELNYm2.js} +1 -1
  77. package/dist/assets/{index-BQCwe2Vs.js → index-DB6VR6GM.js} +1 -1
  78. package/dist/assets/{index-mnKcDZP2.js → index-DFJvHEx_.js} +1 -1
  79. package/dist/assets/index-DH5NMoAp.js +228 -0
  80. package/dist/assets/{index-l4yaELph.js → index-DSZK2W1l.js} +2 -2
  81. package/dist/assets/index-DaEfQ655.js +5 -0
  82. package/dist/assets/{index-Bxg1LKG8.js → index-DmCoJI6s.js} +1 -1
  83. package/dist/assets/{index-CrvlY8Z5.js → index-DxdlbVnC.js} +1 -1
  84. package/dist/assets/{invitation-Dn2JFqk3.js → invitation-DPt0gdGE.js} +1 -1
  85. package/dist/assets/{invite-k-THgUaE.js → invite-DE-KlgyB.js} +1 -1
  86. package/dist/assets/{issue-passport-Cp0z7zOC.js → issue-passport-D-nMcnvC.js} +1 -1
  87. package/dist/assets/{item-DqTNLhw3.js → item-Bb-pZLx0.js} +1 -1
  88. package/dist/assets/{ja-C82Szos_.js → ja-B7dx7PB1.js} +2 -2
  89. package/dist/assets/{ja-B2h7onKc.js → ja-kNnm5FIs.js} +1 -1
  90. package/dist/assets/{ko-B8lz4XE7.js → ko-Bp4AGMi0.js} +1 -1
  91. package/dist/assets/{ko-zaXquvPm.js → ko-BuKH8Xym.js} +2 -2
  92. package/dist/assets/{layout-BRN0uPvp.js → layout-CIMojpa6.js} +1 -1
  93. package/dist/assets/{list-header-Bn1GhGok.js → list-header-BHxsELKC.js} +1 -1
  94. package/dist/assets/{localization-L03Lvx4v.js → localization-XiAFT9tg.js} +1 -1
  95. package/dist/assets/{log-D1ShKaDY.js → log-CoxkHKGx.js} +1 -1
  96. package/dist/assets/{login-D9awP98G.js → login-A4fvlgxL.js} +1 -1
  97. package/dist/assets/{login-oauth-callback-DHA7e6Ar.js → login-oauth-callback-C177kNaH.js} +1 -1
  98. package/dist/assets/{logo-uploader-BA8U554_.js → logo-uploader-kxXncDgy.js} +3 -3
  99. package/dist/assets/{lost-passport-kJqVsdV1.js → lost-passport-kAphaEDd.js} +1 -1
  100. package/dist/assets/{open-window-B-5Hms7z.js → open-window-BeXz5cPG.js} +1 -1
  101. package/dist/assets/{overview-4bff7RWe.js → overview-BTCtLzrM.js} +1 -1
  102. package/dist/assets/{page-header-6EUz18Qu.js → page-header-7_k_ugJy.js} +1 -1
  103. package/dist/assets/{permission-SgzW7fBj.js → permission-BGRlqVt3.js} +1 -1
  104. package/dist/assets/{preferences-RkqN3i2t.js → preferences-DamRKQ0e.js} +1 -1
  105. package/dist/assets/{pt-JWdcQImo.js → pt-DWGzgF0H.js} +1 -1
  106. package/dist/assets/{pt-CMq2TmiV.js → pt-SFtgVKOC.js} +1 -1
  107. package/dist/assets/publish-resource-Cflic0Q5.js +1 -0
  108. package/dist/assets/{react-beautiful-dnd.esm-C8vTtkBe.js → react-beautiful-dnd.esm-BWxUJ9Xq.js} +1 -1
  109. package/dist/assets/{relative-time-BXb5Mt72.js → relative-time-D4irHZ27.js} +1 -1
  110. package/dist/assets/{ru-BwmmHWZS.js → ru-DW4CEx4a.js} +1 -1
  111. package/dist/assets/{ru-CWgdu04g.js → ru-KetZJtiW.js} +1 -1
  112. package/dist/assets/sdk-CdMKuCxo.js +1 -0
  113. package/dist/assets/session-DZl-cVQ_.js +1 -0
  114. package/dist/assets/{setup-DTQXAoXZ.js → setup-COWzvXcE.js} +3 -3
  115. package/dist/assets/{start-DNpygdxp.js → start-ZxWVl-6C.js} +1 -1
  116. package/dist/assets/{step-actions-ClTz1KhK.js → step-actions-BJ6wYLRD.js} +1 -1
  117. package/dist/assets/{studio-DPoV-6q9.js → studio-ClCPyH_R.js} +1 -1
  118. package/dist/assets/{switch-control-D-IROOaC.js → switch-control-_nA0DJVI.js} +1 -1
  119. package/dist/assets/{th-C-hKn9xa.js → th-C-m_sG2U.js} +1 -1
  120. package/dist/assets/{th-BnfuNX_7.js → th-DbGao18H.js} +1 -1
  121. package/dist/assets/{toUpper-BQrWudMF.js → toUpper-DFtRDHUH.js} +1 -1
  122. package/dist/assets/{transfer-A_yTwCWw.js → transfer-0U_178Ru.js} +1 -1
  123. package/dist/assets/{unsubscribe-uaBnibKD.js → unsubscribe-DF3iFxk4.js} +1 -1
  124. package/dist/assets/{useLocalStorage-CSyjxtUy.js → useLocalStorage-Bby1iRzv.js} +1 -1
  125. package/dist/assets/user-center-BWqF0ggv.js +202 -0
  126. package/dist/assets/{util-ao8gSgii.js → util-BZGCzHyk.js} +1 -1
  127. package/dist/assets/{vendor-arcblock-CiLB_TiI.js → vendor-arcblock-CZGLzU01.js} +2 -2
  128. package/dist/assets/{vi-C_iM9J2X.js → vi-DFWs_XTe.js} +1 -1
  129. package/dist/assets/{vi-D7HQHu1T.js → vi-hrya0JxD.js} +1 -1
  130. package/dist/assets/wrap-locale-B1cP4AVb.js +1 -0
  131. package/dist/assets/{zh-DNY792IC.js → zh-C84g18sR.js} +3 -3
  132. package/dist/assets/{zh-6fa1T5uL.js → zh-CHioW4ik.js} +1 -1
  133. package/dist/assets/{zh-tw-9sY6BN2s.js → zh-tw-DBzp3T8D.js} +2 -2
  134. package/dist/assets/{zh-tw-jFbTVB_K.js → zh-tw-LiaeDjuy.js} +1 -1
  135. package/dist/index.html +2 -2
  136. package/dist/service-worker.js +1 -1
  137. package/dist/share/shared-service-worker.js +60 -2
  138. package/package.json +21 -21
  139. package/dist/assets/_createAggregator-B4i0o6gy.js +0 -1
  140. package/dist/assets/connect-to-Dsq1ST9l.js +0 -1
  141. package/dist/assets/index-BPF3oif7.js +0 -228
  142. package/dist/assets/index-CqPx8QUY.js +0 -5
  143. package/dist/assets/publish-resource-BhQQlAPL.js +0 -1
  144. package/dist/assets/sdk-Dqc91xl4.js +0 -1
  145. package/dist/assets/session-ocxAyn6f.js +0 -1
  146. package/dist/assets/user-center-B3stHKHJ.js +0 -202
  147. package/dist/assets/wrap-locale-DNve09jN.js +0 -1
@@ -1,4 +1,4 @@
1
- import{ad as ae,ba as $e,N as ut,f as Be,L as mt,g as k,ag as W,al as pt,v as ft,z as O,aS as le,bF as ht,bG as Me,bH as xt,C as Pe,ab as gt,bl as Ee,ao as ze,b0 as Dt,bB as yt,aM as jt}from"./vendor-arcblock-CiLB_TiI.js";import{a1 as ce,j as e,a3 as p,a2 as z,T as q,ad as de,e as K,t as ue,aj as Ue,E as s,a4 as M,M as vt,bW as bt,al as Ne,bp as Ct,bq as wt,am as St,ao as Rt,aa as At,I as It}from"./vendor-mui-core-BlX2BJoA.js";import{r as A,g as Pt}from"./vendor-react-D-afvo_7.js";import{d as Et}from"./Add-2VCvBnGd.js";import{b as kt}from"./base32-COJTblwx.js";import{ag as Tt,ah as Oe,y as F,B as We,h as ke,ai as He,M as Lt,aj as _t,af as Ve,b as qt,G as Te,ak as Ft,al as $t,I as Bt,am as Mt,an as zt,f as Le}from"./index-wG4Kh8A_.js";import{d as Ut}from"./LockIcon-DQtUl5vk.js";import{I as Nt,u as V,D as Ot,B as Wt,L as Ht}from"./vendor-hooks-CLzfFpO7.js";import{d as Vt}from"./CheckCircle-BElcljFC.js";import{d as Gt,p as _e}from"./util-ao8gSgii.js";import{j as G,w as Kt,a as Qt}from"./vendor-utils-DCpRgzMR.js";import{_ as Q}from"./useSetState-Crt4S51m.js";import{w as Ge}from"./permission-SgzW7fBj.js";import{_ as Yt,D as qe}from"./useAsyncRetry-KXMle3o0.js";import{C as Y}from"./confirm-C0rryr4e.js";import{d as Zt}from"./InfoOutlined-BFP30UJa.js";import{_ as Xt}from"./useAsync-cdOzMWPw.js";import"./api-C0C4sDJA.js";import{I as Jt}from"./index-mnKcDZP2.js";import{A as en}from"./actions-BEpPU26q.js";var me={},tn=ce;Object.defineProperty(me,"__esModule",{value:!0});var Ke=me.default=void 0,nn=tn(ae()),sn=e;Ke=me.default=(0,nn.default)((0,sn.jsx)("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess");const on=$e({});on.interceptors.request.use(n=>{const t=window.blocklet?window.blocklet.prefix:"/";return n.baseURL=t||"",n.url=G("/api",String(n.url)),n.timeout=2e5,n.params=n.params||{},new URLSearchParams(n.url.split("?")[1]).has("locale")||(n.params.locale=ut()),n},n=>Promise.reject(n));const Qe=(...n)=>$e(...n),rn=(n,t)=>t?n?[n,...Array.isArray(t)?t:[t]]:t:n,an=(n,{width:t=600,height:o=700,name:i="did-domain:popup"}={})=>{const a=window.screenX+(window.innerWidth-t)/2,r=window.screenY+(window.innerHeight-o)/2,l=[`left=${a}`,`top=${r}`,`width=${t}`,`height=${o}`,"resizable=no","scrollbars=yes","status=yes","popup=yes"],c=window.open("",i,l.join(","));if(c===null)throw new Error("Failed to open popup");return c.location.href=Kt(n,{opener:window.location.origin}),c},ln="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p",Ye=async n=>{var d;if(!n||!(n!=null&&n.trim()))return null;const t=Qe(),o=new URL(n);o.pathname="__blocklet__.js",o.searchParams.set("type","json");const{data:i}=await t.get(o.toString()),a=(d=i==null?void 0:i.componentMountPoints)==null?void 0:d.find(h=>h.did===ln),r=new URL(n);r.pathname=a==null?void 0:a.mountPoint;const l=r.toString(),c=G(l,"/api");return{base:l,api:c}},cn=Be({buy:{button:{title:"Buy DID Domain"},status:{inProgress:"Please wait while we are processing your request, the domain will be automatically resolved to the current app after the purchase...",success:"Purchase completed!"},error:{failedToCreateSession:"Failed to create session"}}}),dn=Be({buy:{button:{title:"购买 DID 域名"},status:{inProgress:"请稍等,我们正在处理您的请求,购买域名后会自动解析到当前的应用...",success:"购买完成!"},error:{failedToCreateSession:"创建会话失败"}}}),un={zh:dn,en:cn};function Ze({delegatee:n,delegateePk:t,didDomainURL:o,locale:i,title:a,onSuccess:r,...l}){const{t:c}=k(),[d,h]=Nt({currentState:1}),f=A.useRef(null),C=V(x=>{var m,v,I,j;x.data.type==="didDomain.success"&&(r==null||r({nftDid:(m=x.data)==null?void 0:m.nftDid,domain:(v=x.data)==null?void 0:v.domain,chainHost:(I=x.data)==null?void 0:I.chainHost}),(j=f.current)==null||j.close(),f.current=null,h({currentState:4}),setTimeout(()=>{h({currentState:8})},2e3))});Ot(()=>{var x;try{window.removeEventListener("message",C),(x=f.current)==null||x.close(),f.current=null}catch(m){console.warn("Failed to close popup",m)}});const S=V(()=>{h({currentState:1})}),g=V(()=>{h({currentState:2}),P.run()}),y=V(({sessionId:x,baseURL:m})=>{window.addEventListener("message",C);const v=new URL(m);v.searchParams.set("sessionId",x),v.searchParams.set("locale",i),f.current=an(v.toString());const I=setInterval(()=>{var j;(j=f.current)!=null&&j.closed&&(clearInterval(I),S())},1e3);return()=>clearInterval(I)}),P=Wt(async()=>{const x=await Ye(o);if(!x)return null;const m=Qe({baseURL:x.api}),{data:v}=await m.post("/payment/session",{delegatee:n,delegateePk:t});return y({sessionId:v.sessionId,baseURL:x.base})},{manual:!0,debounceWait:500,debounceLeading:!0,debounceTrailing:!1,debounceMaxWait:3e3,refreshDeps:[],onError(x){console.error(x)}});return e.jsxs(e.Fragment,{children:[e.jsx(W,{onClick:g,variant:"contained",startIcon:e.jsx(Gt,{}),...l,children:a||c("buy.button.title")}),e.jsxs(pt,{fullWidth:!0,maxWidth:"xs",open:d.currentState>1&&d.currentState<8,onClose:S,children:[!P.error&&e.jsxs(p,{sx:{display:"flex",alignItems:"center",flexDirection:"column",gap:2},children:[d.currentState===2&&e.jsx(z,{size:50}),d.currentState===4&&e.jsx(Vt,{sx:{color:"primary.main",fontSize:"5rem"}}),d.currentState===2&&e.jsx(q,{children:c("buy.status.inProgress")}),d.currentState===4&&e.jsx(q,{children:c("buy.status.success")})]}),P.error&&e.jsx(de,{severity:"error",children:c("buy.error.failedToCreateSession")})]})]})}const Xe={onSuccess:()=>{},title:""};Ze.defaultProps=Xe;function Je(n){return e.jsx(mt,{locale:n.locale,translations:un,children:e.jsx(Ze,{...n})})}Je.defaultProps=Xe;function et({nftDid:n,didDomainURL:t,locale:o,sx:i}){const{t:a}=k(),[r,l]=Q({safeIframeRef:null,popoverAnchorEl:null}),c=A.useRef(null),d=K(),h=ue(d.breakpoints.down("md")),f=y=>{l({popoverAnchorEl:y.currentTarget})},C=()=>{l({popoverAnchorEl:null})},S=Ht(async()=>{const y=await Ye(t);return y?y.base:null});if(!S.value)return null;if(S.loading)return e.jsx(z,{});const g=G(S.value,`/embed/domain?nft-did=${n}&locale=${o}`);return e.jsxs(e.Fragment,{children:[e.jsx(p,{component:"img",src:G(t,"/.well-known/service/blocklet/logo"),alt:"logo",width:16,height:16,onClick:f,sx:rn({cursor:"pointer"},i)}),e.jsx(Ue,{id:"popover-info",open:!!r.popoverAnchorEl,anchorEl:r.popoverAnchorEl,onClose:C,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx("iframe",{ref:c,title:a("common.subscription"),width:h?"320px":"400px",height:h?"600px":"680px",style:{border:0},src:g})})]})}et.defaultProps={sx:{}};const mn=n=>["waiting","creating","renewaling"].includes(n);function pe(n){var w,R;const{t}=k(),[o,i]=A.useState(!1),{inService:a}=F(),[r,l]=A.useState(null),{siteId:c,domain:d,onAdd:h,children:f,did:C}=n,[S,g]=A.useState(!1),{api:y,ws:{useSubscription:P}}=F(),{mode:x,actions:{refreshDomainStatus:m}}=We(),v=Yt(async()=>{const{cert:b}=await y.findCertificateByDomain({input:{domain:d,did:C}});return b}),I=(b,U)=>{b.domain===d&&(g(!1),i(!1),a&&x!=="setup"&&(U==="success"?O.success(t("setup.domain.genCertSuccess",{domain:b.domain})):U==="error"&&O.error(t("setup.domain.genCertFailed",{domain:b.domain,message:b.message}))))};if(A.useEffect(()=>{var b;v.loading||g(mn((b=v.value)==null?void 0:b.status))},[v.loading,(w=v.value)==null?void 0:w.status]),P(ke.BlockletEvents.certError,b=>I(b,"error")),P(ke.BlockletEvents.certIssued,b=>{v.retry(),m(b.domain),I(b,"success")}),v.loading||((R=v.value)==null?void 0:R.status)==="normal")return"";const j=()=>{i(!1),l(null)},T=async()=>{i(!0);try{await y.issueLetsEncryptCert({input:{siteId:c,domain:d,did:C,inBlockletSetup:x==="setup"}}),h(),g(!0)}catch(b){console.error(b),g(!1)}finally{i(!1),l(null)}},u={title:t("router.cert.genLetsEncryptCert.title"),description:e.jsxs("div",{children:[e.jsx(de,{severity:"success",children:t("router.cert.genLetsEncryptCert.dnsTip")}),t("router.cert.genLetsEncryptCert.description")]}),confirm:t("common.confirm"),onConfirm:T,onCancel:j},L=b=>{b.stopPropagation(),l(u)};return e.jsxs(e.Fragment,{children:[S?e.jsx(M,{title:t("router.cert.issuing"),children:e.jsx(z,{size:12})}):f({loading:o,open:L}),r&&e.jsx(Y,{color:"primary",title:r.title,description:r.description,confirm:r.confirm,params:r.params,onConfirm:r.onConfirm,onCancel:r.onCancel})]})}pe.propTypes={domain:s.string.isRequired,did:s.string.isRequired,siteId:s.string.isRequired,onAdd:s.func,children:s.any};pe.defaultProps={onAdd:()=>{},children:null};function fe(n){const{domain:t,domainStatus:o,...i}=n;return Tt(t)||!Oe(t)||ft(o)||o!=null&&o.isHttps?"":e.jsx(pe,{domain:t,...i})}fe.propTypes={domain:s.string.isRequired,domainStatus:s.shape({isHttps:s.bool}).isRequired,did:s.string.isRequired,onAdd:s.func,children:s.any};fe.defaultProps={onAdd:()=>{},children:null};var he={},pn=ce;Object.defineProperty(he,"__esModule",{value:!0});var tt=he.default=void 0,fn=pn(ae()),hn=e;tt=he.default=(0,fn.default)((0,hn.jsx)("path",{d:"M17 20.41 18.41 19 15 15.59 13.59 17zM7.5 8H11v5.59L5.59 19 7 20.41l6-6V8h3.5L12 3.5z"}),"CallMerge");const nt=A.createContext({}),{Provider:xn,Consumer:es}=nt;function gn({children:n}){const[t,o]=Q({domain:"",error:null}),{locale:i}=k(),a={error:t.error,domain:t.domain,setError:r=>{o({error:r})},setDomain:r=>{const l=le(r),c=He(l,i);o({domain:l,error:c})}};return e.jsx(xn,{value:{value:a},children:n})}function Dn(){const{value:n}=A.useContext(nt);return n}const{joinURL:Fe}=Lt,yn=_t,st="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p",jn=async n=>{var c;if(!n||!(n!=null&&n.trim()))return null;const t=new URL(n);t.pathname="__blocklet__.js",t.searchParams.set("type","json");const{data:o}=await yn.get(t.toString()),i=(c=o==null?void 0:o.componentMountPoints)==null?void 0:c.find(d=>d.did===st),a=new URL(n);a.pathname=i==null?void 0:i.mountPoint;const r=a.toString(),l=Fe(r,"/api");return{base:r,api:l,domain:Fe(l,"/domains")}};var vn={DID_DOMAIN_SERVICE_DID:st,getDidDomainServiceURL:jn},Z={exports:{}};const bn=ht,Cn=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class ot extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}}const wn=(n,t,o)=>{const i=o.retries-(t-1);return n.attemptNumber=t,n.retriesLeft=i,n},Sn=n=>Cn.includes(n),it=(n,t)=>new Promise((o,i)=>{t={onFailedAttempt:()=>{},retries:10,...t};const a=bn.operation(t);a.attempt(async r=>{try{o(await n(r))}catch(l){if(!(l instanceof Error)){i(new TypeError(`Non-error was thrown: "${l}". You should only throw errors.`));return}if(l instanceof ot)a.stop(),i(l.originalError);else if(l instanceof TypeError&&!Sn(l.message))a.stop(),i(l);else{wn(l,r,t);try{await t.onFailedAttempt(l)}catch(c){i(c);return}a.retry(l)||i(a.mainError())}}})});Z.exports=it;Z.exports.default=it;Z.exports.AbortError=ot;var Rn=Z.exports;const An=Pt(Rn);function xe({domain:n,resolvedTarget:t,...o}){const{t:i,locale:a}=k();return e.jsxs(p,{sx:{backgroundColor:"rgb(236, 251, 253)",borderColor:"rgb(236, 251, 253)",borderRadius:"8px",padding:"12px"},...o,children:[e.jsxs(p,{display:"flex",children:[i("router.domain.setup.tipStart"),n&&e.jsx(p,{mx:.5,color:"primary.main",fontWeight:"fontWeightBold",children:n}),i("router.domain.setup.tipEnd"),":"]}),e.jsxs(p,{sx:{"&>div":{mb:0},marginTop:"8px"},children:[e.jsx(se,{label:i("router.domain.setup.recordType"),value:"CNAME",locale:a}),e.jsx(se,{label:i("router.domain.setup.recordValue"),value:t,locale:a})]})]})}xe.propTypes={domain:s.string,resolvedTarget:s.string.isRequired};xe.defaultProps={domain:""};function se({locale:n,label:t,value:o}){const i=ue(r=>r.breakpoints.down("md")),a=K();return e.jsx(Jt,{name:t,nameWidth:120,children:e.jsxs(p,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[e.jsx(q,{component:"span",color:"primary.main",overflow:"auto",sx:i?{maxWidth:"95%",wordWrap:"break-word"}:{wordWrap:"break-word"},children:o}),e.jsx(Me,{content:o,locale:n,style:{marginLeft:"4px",color:a.palette.text.secondary}})]})})}se.propTypes={locale:s.string.isRequired,label:s.string.isRequired,value:s.string.isRequired};function ge({siteId:n,teamDid:t,cnameDomain:o,defaultCustomDomain:i,onInputDomain:a,appId:r,appPk:l,onSuccess:c,onError:d,disabled:h,autoFocus:f,inBlockletSetup:C,shouldCheckDomain:S,onStateChange:g,currentIp:y,resolveDomain:P,...x}){const{t:m,locale:v}=k(),{api:I,info:j}=F(),T=Dn(),u=K(),L=xt({key:"sm"}),[w,R]=Q({submittingDomain:!1,domain:i,error:null,type:j!=null&&j.nftDomainUrl?"nftDomain":"inputDomain",showNFTDomainAuth:!1,showDnsTip:!1}),b=Xt(()=>vn.getDidDomainServiceURL(j==null?void 0:j.nftDomainUrl));if(j!=null&&j.nftDomainUrl&&b.loading)return e.jsx(p,{...x,children:e.jsx(Pe,{relative:"parent",children:e.jsx(z,{})})});if(b.error)return e.jsx(p,{...x,children:e.jsx(Pe,{relative:"parent",children:b.error.message})});const U=b.value,at=()=>{R({invalidDNSDomain:null})},ee=async D=>{g(m("setup.domain.addingDomain")),await I.addDomainAlias({input:{id:n,domainAlias:D,teamDid:t,inBlockletSetup:!0}}),R({submittingDomain:!1}),c({domain:D,type:"inputDomain"})},Se=async({domain:D,type:E,nftDid:N,chainHost:_})=>{try{if(!S){if(E==="inputDomain"){await ee(D);return}c({domain:D,type:E,nftDid:N,chainHost:_});return}g({text:m("setup.domain.checkingResolvable")});let $=30;const te=3e3,dt=$*1e3/te,Ae=setInterval(()=>{if($<=0){clearInterval(Ae);return}g({text:`${m("setup.domain.checkingResolvable")} (${$--}s)`})},1e3),Ie=await An(async()=>{const{data:B}=await P(D);if(!B.address)throw new Error("Cannot resolve domain");return B.address},{retries:dt,minTimeout:te,maxTimeout:te,onFailedAttempt:console.error}).catch(console.error);if(clearInterval(Ae),!Ie){const B=m("setup.domain.cannotResolve",{domain:D});if(E==="nftDomain"){O.error(B),c({domain:D,type:"nftDomain"});return}g({text:""}),R({invalidDNSDomain:{domain:D,error:B},domain:D,type:E,submittingDomain:!1});return}if(Ie!==y){const B=m("setup.domain.resolvedAddressError",{domain:D,curDomain:window.location.hostname});if(E==="nftDomain"){O.error(B),c({domain:D,type:"nftDomain"});return}g({text:""}),R({invalidDNSDomain:{domain:D,error:B},domain:D,type:E,submittingDomain:!1});return}if(E==="nftDomain"){c({domain:D,type:"nftDomain"});return}await ee(D)}catch($){O.error($.message),g({text:""}),R({submittingDomain:!1})}},lt=async({domain:D,nftDid:E,chainHost:N})=>{try{const _=_e(D);R({submittingDomain:!0}),await I.addDomainAlias({input:{id:n,type:"nft-domain",domainAlias:_,nftDid:E,chainHost:N,teamDid:t,inBlockletSetup:C}});const $="nftDomain";R({showNFTDomainAuth:!1,type:$}),await Se({domain:_,type:$,nftDid:E,chainHost:N})}catch(_){O.error(_.message)}finally{R({showNFTDomainAuth:!1,submittingDomain:!1})}},ct=async()=>{try{R({submittingDomain:!0});const D=_e(w.domain);if(j.nftDomainUrl&&U&&(await I.isDidDomain({input:{domain:D}})).value===!0){R({showNFTDomainAuth:!0});return}await Se({domain:D,type:w.type})}catch(D){R({submittingDomain:!1}),T.setError(D.message)}},Re=T.error||w.error;return e.jsx(p,{...x,children:e.jsxs(p,{sx:{display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:"1em"},children:[e.jsxs(p,{sx:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(q,{sx:{color:u.palette.text.primary},children:m("router.domainAlias.add.tips")}),e.jsx(vt,{sx:{display:"block",marginTop:"8px"},label:m("router.domainAlias.add.domainDescription"),helperText:w.type==="inputDomain"&&Re||m("router.domainAlias.add.helperText"),inputProps:{"data-cy":"domain-name-input"},fullWidth:!0,disabled:h,value:w.domain,size:"small",variant:"outlined",error:!!Re&&w.type==="inputDomain",onChange:D=>{var _;const E=le((_=D.target)==null?void 0:_.value);T.setDomain(E);const N=He(E,v);R({domain:E,error:N,type:"inputDomain"}),a({domain:E,error:N,type:"inputDomain"})},autoFocus:f,onBlur:()=>{T.domain||(R({error:null}),T.setError(null))}}),e.jsx(p,{sx:{width:"100%",display:"flex",justifyContent:"flex-end"},children:e.jsx(bt,{"data-cy":"confirm-add-domain",fullWidth:L,variant:"contained",loading:w.submittingDomain,onClick:ct,children:m("common.add")})}),e.jsxs(p,{sx:{cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"4px",lineHeight:1,color:u.palette.primary.main},onClick:()=>R({showDnsTip:!w.showDnsTip}),children:[e.jsx(Zt,{fontSize:"1em"}),m("router.domainAlias.showTipHint")]}),w.showDnsTip&&e.jsx(xe,{domain:w.domain,resolvedTarget:o,style:{marginTop:"4px"}})]}),w.invalidDNSDomain&&e.jsx(Y,{title:m("common.reminder"),description:m("setup.domain.invalidDNSReminder",{error:w.invalidDNSDomain.error}),color:"primary",confirm:m("setup.domain.continueAdd"),onConfirm:()=>ee(w.invalidDNSDomain.domain,w.type),onCancel:at}),U&&e.jsx(gt,{open:w.showNFTDomainAuth,popup:!0,useSocket:!1,forceConnected:!1,action:"authorize",baseUrl:U.api,checkFn:Qt.create({baseURL:U.api}).get,extraParams:{delegatee:r,delegateePk:l,domain:w.domain},onSuccess:lt,onClose:()=>R({showNFTDomainAuth:!1,submittingDomain:!1}),checkTimeout:60*5e3,showDownload:!1,messages:{title:m("router.domainAlias.addDomainNFT.connect.title"),scan:m("router.domainAlias.addDomainNFT.connect.scan"),confirm:m("router.domainAlias.addDomainNFT.connect.confirm"),success:m("router.domainAlias.addDomainNFT.connect.success")}})]})})}ge.propTypes={siteId:s.string.isRequired,currentIp:s.string,teamDid:s.string.isRequired,cnameDomain:s.string.isRequired,defaultCustomDomain:s.string,onInputDomain:s.func,onSuccess:s.func,appId:s.string,appPk:s.string,disabled:s.bool,autoFocus:s.bool,inBlockletSetup:s.bool,shouldCheckDomain:s.bool,onStateChange:s.func,resolveDomain:s.func,onError:s.func};ge.defaultProps={defaultCustomDomain:"",currentIp:"",onInputDomain:Ee,onSuccess:Ee,appId:"",appPk:"",disabled:!1,autoFocus:!0,inBlockletSetup:!1,shouldCheckDomain:!1,onStateChange:()=>{},resolveDomain:()=>{},onError:()=>{}};function De({id:n,children:t,title:o,teamDid:i,systemDomains:a,appId:r,appPk:l}){const{t:c}=k(),[d,h]=Q({loading:!1,confirmSetting:null}),f=a.find(y=>Ve.isDidDomain(y)),C=()=>{h({loading:!1,confirmSetting:null})},S={title:o||c("router.domainAlias.add.title"),description:function(P,x,m){return e.jsx(ge,{siteId:n,teamDid:i,cnameDomain:f,onSuccess:()=>h({confirmSetting:null}),onInputDomain:({domain:v,type:I,error:j})=>{x({...P,domain:v,type:I,__disableConfirm:!!j}),m(j)},appId:r,appPk:l})},confirm:c("common.confirm"),cancel:c("common.cancel"),params:{domain:"",__disableConfirm:!0},onCancel:C},g=y=>{y.stopPropagation(),h({confirmSetting:S})};return e.jsxs(e.Fragment,{children:[typeof t=="function"?t({loading:d.loading,open:g}):e.jsxs(Ne,{onClick:g,className:"rule-action","data-cy":"action-add-domain-alias",children:[d.loading?e.jsx(z,{size:16}):e.jsx(tt,{style:{fontSize:18,marginRight:5}}),c("router.domainAlias.add.title")]}),d.confirmSetting&&e.jsx(Y,{title:d.confirmSetting.title,description:d.confirmSetting.description,confirm:d.confirmSetting.confirm,cancel:d.confirmSetting.cancel,params:d.confirmSetting.params,onCancel:d.confirmSetting.onCancel,showConfirm:!1,showCancel:!0,displayError:!1,color:"primary",loading:d.loading,maxWidth:"sm"})]})}De.propTypes={id:s.string.isRequired,children:s.any,title:s.string,teamDid:s.string,systemDomains:s.arrayOf(s.string).isRequired,appId:s.string,appPk:s.string.isRequired};De.defaultProps={children:null,title:"",teamDid:"",appId:null};function In(n){return e.jsx(gn,{children:e.jsx(De,{...n})})}function ye({appId:n,appPk:t,siteId:o,inBlockletSetup:i,teamDid:a,sx:r,...l}){const{api:c,info:d}=F(),{locale:h,t:f}=k(),C=async({domain:S,nftDid:g,chainHost:y})=>{await c.addDomainAlias({input:{id:o,type:"nft-domain",domainAlias:S,nftDid:g,chainHost:y,teamDid:a,inBlockletSetup:i}})};return e.jsx(Je,{delegatee:n,delegateePk:t,didDomainURL:d.nftDomainUrl,onSuccess:C,locale:h,variant:"outlined",sx:r,title:f("router.domainAlias.addDomainNFT.buy"),...l})}ye.propTypes={appId:s.string.isRequired,appPk:s.string.isRequired,siteId:s.string.isRequired,inBlockletSetup:s.bool.isRequired,teamDid:s.string.isRequired,sx:s.object};ye.defaultProps={sx:{}};function je(n){const{t}=k(),[o,i]=A.useState(!1),[a,r]=A.useState(null),{id:l,domain:c,children:d,teamDid:h}=n,{api:f}=F(),C=()=>{i(!1),r(null)},S=async()=>{i(!0);try{await f.deleteDomainAlias({input:{id:l,domainAlias:c,teamDid:h}}),await qt(2e3)}catch(P){O.error(P.message)}finally{r(null),i(!1)}},g={title:t("router.domainAlias.delete.title"),description:t("router.domainAlias.delete.description"),confirm:t("common.confirm"),onConfirm:S,onCancel:C},y=P=>{P.stopPropagation(),r(g)};return e.jsxs(e.Fragment,{children:[typeof d=="function"?d({loading:o,open:y}):e.jsxs(W,{edge:"end",onClick:y,size:"small",className:"rule-action",color:"error","data-cy":"action-delete-domain-alias",children:[o?e.jsx(z,{size:16}):e.jsx(ze,{style:{fontSize:16}}),t("router.domainAlias.delete.title")]}),a&&e.jsx(Y,{title:a.title,description:a.description,confirm:a.confirm,params:a.params,onConfirm:a.onConfirm,onCancel:a.onCancel})]})}je.propTypes={id:s.string.isRequired,domain:s.string.isRequired,children:s.any,teamDid:s.string};je.defaultProps={children:null,teamDid:""};function ve({site:n,domain:t,blocklet:o}){const{t:i}=k(),a=t.value===window.location.hostname;return e.jsx(en,{"data-cy":"domain-actions",size:"large",actions:[({close:r})=>{var l;return e.jsx(je,{id:n.id,domain:t.value,teamDid:(l=o==null?void 0:o.meta)==null?void 0:l.did,children:({open:c})=>e.jsx(M,{title:a?i("blocklet.router.currentDomainTip"):"",children:e.jsx("span",{children:e.jsxs(Ne,{disabled:t.isProtected||a,dense:!0,onClick:d=>{r(),c(d)},"data-cy":"action-toggle-block",children:[e.jsx(Ct,{style:{minWidth:24,marginRight:8},children:e.jsx(ze,{})}),e.jsx(wt,{primary:i("common.delete")})]},"remove")})})})}]})}ve.propTypes={site:s.object.isRequired,domain:s.object.isRequired,blocklet:s.object.isRequired};ve.defaultProps={};var be={},Pn=ce;Object.defineProperty(be,"__esModule",{value:!0});var Ce=be.default=void 0,En=Pn(ae()),kn=e;Ce=be.default=(0,En.default)((0,kn.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1z"}),"Https");const X=s.shape({href:s.string,accessibility:s.shape({loading:s.bool,accessible:s.bool}),domainStatus:s.shape({isHttps:s.bool,matchedCert:s.object}),dns:s.shape({resolved:s.bool,ip:s.string})});function we({certificate:n}){const[t,o]=A.useState(null),i=F(),{t:a,locale:r}=k(),l=h=>{o(h.currentTarget)},c=()=>{o(null)},d=!!t;return e.jsxs(e.Fragment,{children:[e.jsx(Ce,{"aria-owns":d?"mouse-over-popover":void 0,onMouseEnter:l,onMouseLeave:c,style:{color:"#44cdc6",fontSize:20,cursor:"pointer"}}),e.jsx(Ue,{id:"mouse-over-popover",style:{pointerEvents:"none"},open:d,anchorEl:t,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},onClose:c,disableRestoreFocus:!0,children:e.jsx(St,{children:e.jsxs(Rt,{style:{display:"flex"},children:[e.jsx("div",{children:e.jsx("img",{src:`${i.imgPrefix}/https-certificate-icon.png`,alt:"certificate icon",style:{maxHeight:"100%",maxWidth:"100%"}})}),e.jsxs(q,{component:"div",style:{marginLeft:"16px"},children:[e.jsx(q,{component:"div",style:{fontWeight:"bold"},children:n.domain}),e.jsx(q,{component:"div",children:`${a("common.issuer")}: ${Dt(n,"issuer.commonName","")}`}),e.jsx(q,{component:"div",children:`${a("router.cert.issuedOn")}: ${Te(n.validFrom,r)}`}),e.jsx(q,{component:"div",children:`${a("router.cert.expiryOn")}: ${Te(n.validTo,r)}`})]})]})})})]})}we.propTypes={certificate:s.object};we.defaultProps={certificate:{}};function H({domain:n,filters:t}){const{t:o}=k(),{value:i,domainStatus:a}=n;if(!Oe(i))return null;let r=null,l=null;const{isHttps:c,matchedCert:d}=a;if(!Ft(i)){const{dns:{resolved:f,ip:C}={}}=a;f||C==="127.0.0.1"?r=e.jsx(M,{title:o("router.domain.verify.ok"),children:e.jsx(qe,{color:"success"})}):r=e.jsx(M,{title:o("router.domain.verify.notResolved"),children:e.jsx(qe,{color:"error"})})}c?l=e.jsx(we,{certificate:d}):l=e.jsx(M,{title:o("router.domain.https.bad"),children:e.jsx(Ce,{style:{color:"#D0021B",fontSize:20,cursor:"pointer"}})});const h=t.map(f=>f==="domain"?r:f==="http"?l:null);return A.createElement(A.Fragment,null,...h)}H.propTypes={domain:X.isRequired,filters:s.array};H.defaultProps={filters:["domain","http"]};const Tn=Ge(J,"mutate_blocklets"),Ln=Ge(J,"",$t);function rt(n){const{inService:t}=F(),{blocklet:o,loadingRuntimeInfo:i}=We();let a=Tn;return t&&(a=Ln),e.jsx(a,{...n,blocklet:o,inService:t,loadingRuntimeInfo:i})}rt.propTypes={listOnly:s.bool};rt.defaultProps={listOnly:!1};function J({hasPermission:n,blocklet:t,loadingRuntimeInfo:o,inService:i,listOnly:a}){var v,I,j,T;const{t:r}=k(),{info:l}=F(),[c,d]=A.useState(!1),h=ue(u=>u.breakpoints.down("md")),f=A.useMemo(()=>{let u=n;return Bt(t)&&(u=u&&i),u},[n,i,t]),{site:C}=t,S=A.useMemo(()=>{var u;return Mt((u=t.site)==null?void 0:u.domainAliases)},[(v=t.site)==null?void 0:v.domainAliases]),g=[],y=[],P=kt.encode(t.appPid),x=(j=(I=t.environments)==null?void 0:I.find(u=>u.key==="BLOCKLET_APP_PK"))==null?void 0:j.value,m=zt(S);return S.forEach(u=>{const L=u.value||"";Ve.isDidDomain(L)&&!L.startsWith(P)?y.push(u):g.push(u)}),e.jsxs(e.Fragment,{children:[!a&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{className:"title first",display:"flex",justifyContent:"space-between",alignItems:"center",children:[e.jsx(p,{children:r("common.domain")}),f&&e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(In,{id:C.id,title:r("router.domain.add.title"),teamDid:(T=t.meta)==null?void 0:T.did,appId:t.appPid,appPk:x,systemDomains:m==null?void 0:m.map(u=>u.value),children:({open:u})=>e.jsxs(W,{style:{marginLeft:16},variant:"contained",color:"primary","data-cy":"add-domain-alias",onClick:u,disabled:Le.isInProgress(t.status),children:[e.jsx(Et,{style:{fontSize:"1.3em",marginRight:4}}),r("common.add")]})}),l.nftDomainUrl&&e.jsx(ye,{variant:"outlined",appId:t.appPid,appPk:x,siteId:C.id,inBlockletSetup:!1,teamDid:t.meta.did})]})]}),Le.isAccessible(t.status)===!1&&e.jsx(p,{mt:1.5,mb:1.5,children:e.jsx(de,{severity:"warning",children:r("blocklet.router.noRunning")})})]}),e.jsx(p,{sx:{display:"flex",flexDirection:"column",gap:1},children:(c?S:g).map(u=>{var w,R;const L=u.value;return e.jsxs(A.Fragment,{children:[h&&e.jsxs(p,{display:"flex",flexDirection:"column",children:[e.jsx(p,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:e.jsx(oe,{domain:u,target:"_blank",children:u.value})}),e.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:1},children:[e.jsx(H,{domain:u,filters:["domain"]},`${u.value}-domain`),e.jsx(re,{siteId:(w=t.site)==null?void 0:w.id,domain:u,blocklet:t,hasMutatePermission:f})]}),e.jsx(p,{sx:{button:{padding:0}},children:e.jsx(ie,{hasMutatePermission:f,site:C,domain:u,blocklet:t})})]})]},L),!h&&e.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[e.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[e.jsx(H,{domain:u,filters:["domain"]},`${u.value}-domain`),e.jsx(p,{sx:{ml:2,mr:.5},children:e.jsx(oe,{domain:u,target:"_blank",children:u.value})}),e.jsx(re,{siteId:(R=t.site)==null?void 0:R.id,domain:u,blocklet:t,hasMutatePermission:f})]}),e.jsx(p,{sx:{button:{padding:0}},children:e.jsx(ie,{hasMutatePermission:f,site:C,domain:u,blocklet:t})})]},L)]},L)})}),y.length>0&&e.jsx("div",{style:{marginLeft:"20px",marginTop:"12px"},children:e.jsx(W,{endIcon:c?e.jsx(Ke,{}):e.jsx(yt,{}),onClick:()=>d(!c),children:r(c?"common.collapseAll":"blocklet.router.showAllDomains")})}),!S.length&&(o?e.jsx(z,{size:16}):e.jsx(jt,{children:r("common.empty")}))]})}J.propTypes={hasPermission:s.bool,blocklet:s.object.isRequired,loadingRuntimeInfo:s.bool,inService:s.bool.isRequired,listOnly:s.bool};J.defaultProps={hasPermission:!1,loadingRuntimeInfo:!1,listOnly:!1};function oe({domain:n,children:t,...o}){const{t:i,locale:a}=k(),{href:r,accessibility:l,value:c}=n,d=A.useCallback(()=>e.jsx(Me,{content:le(c),locale:a,style:{marginLeft:"4px",color:"#999",fontSize:"0.8em",verticalAlign:"bottom"}}),[c,a]);return!l||l.loading?e.jsxs(ne,{...o,children:[t,d(),e.jsx(M,{title:i("blocklet.router.checkUrlAccessible"),placement:"top-end",children:e.jsx("span",{className:"status",children:e.jsx(z,{size:12})})})]}):l.accessible?e.jsxs(ne,{...o,children:[e.jsx(p,{component:"a",href:r,target:"_blank",rel:"noopener noreferrer",children:t}),d()]}):e.jsxs(ne,{...o,children:[e.jsx(M,{title:i("blocklet.router.urlInaccessible"),placement:"top-end",children:e.jsx("span",{children:t})}),d()]})}oe.propTypes={domain:X.isRequired,children:s.any.isRequired};const ne=At.span`
1
+ import{ad as ae,ba as $e,N as ut,f as Be,L as mt,g as T,ag as W,al as pt,v as ft,z as O,aT as le,bE as ht,bF as Me,bG as xt,C as Pe,ab as gt,bl as Ee,ao as ze,b0 as Dt,bA as yt,aN as jt}from"./vendor-arcblock-CZGLzU01.js";import{a1 as ce,j as e,a3 as p,a2 as z,T as q,ad as de,e as K,t as ue,aj as Ne,E as s,a4 as M,M as vt,bW as bt,al as Ue,bp as Ct,bq as wt,am as St,ao as Rt,aa as At,I as It}from"./vendor-mui-core-BlX2BJoA.js";import{r as A,g as Pt}from"./vendor-react-D-afvo_7.js";import{d as Et}from"./Add-C6s-Vnmg.js";import{b as Tt}from"./base32-C41aFfgE.js";import{ag as kt,ah as Oe,y as F,B as We,h as Te,ai as He,M as Lt,aj as _t,af as Ve,b as qt,G as ke,ak as Ft,al as $t,I as Bt,am as Mt,an as zt,f as Le}from"./index-BjauMU9c.js";import{d as Nt}from"./LockIcon-DQtUl5vk.js";import{I as Ut,u as V,D as Ot,B as Wt,L as Ht}from"./vendor-hooks-CLzfFpO7.js";import{d as Vt}from"./CheckCircle-D3sLlO8U.js";import{d as Gt,p as _e}from"./util-BZGCzHyk.js";import{j as G,w as Kt,a as Qt}from"./vendor-utils-DCpRgzMR.js";import{_ as Q}from"./useSetState-Crt4S51m.js";import{w as Ge}from"./permission-BGRlqVt3.js";import{_ as Yt,D as qe}from"./useAsyncRetry-KXMle3o0.js";import{C as Y}from"./confirm-BHRsp-P-.js";import{d as Zt}from"./InfoOutlined-phoVf4hW.js";import{_ as Xt}from"./useAsync-cdOzMWPw.js";import"./api-C0C4sDJA.js";import{I as Jt}from"./index-DFJvHEx_.js";import{A as en}from"./actions-B2A8ao0K.js";var me={},tn=ce;Object.defineProperty(me,"__esModule",{value:!0});var Ke=me.default=void 0,nn=tn(ae()),sn=e;Ke=me.default=(0,nn.default)((0,sn.jsx)("path",{d:"m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess");const on=$e({});on.interceptors.request.use(n=>{const t=window.blocklet?window.blocklet.prefix:"/";return n.baseURL=t||"",n.url=G("/api",String(n.url)),n.timeout=2e5,n.params=n.params||{},new URLSearchParams(n.url.split("?")[1]).has("locale")||(n.params.locale=ut()),n},n=>Promise.reject(n));const Qe=(...n)=>$e(...n),rn=(n,t)=>t?n?[n,...Array.isArray(t)?t:[t]]:t:n,an=(n,{width:t=600,height:o=700,name:i="did-domain:popup"}={})=>{const a=window.screenX+(window.innerWidth-t)/2,r=window.screenY+(window.innerHeight-o)/2,l=[`left=${a}`,`top=${r}`,`width=${t}`,`height=${o}`,"resizable=no","scrollbars=yes","status=yes","popup=yes"],c=window.open("",i,l.join(","));if(c===null)throw new Error("Failed to open popup");return c.location.href=Kt(n,{opener:window.location.origin}),c},ln="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p",Ye=async n=>{var d;if(!n||!(n!=null&&n.trim()))return null;const t=Qe(),o=new URL(n);o.pathname="__blocklet__.js",o.searchParams.set("type","json");const{data:i}=await t.get(o.toString()),a=(d=i==null?void 0:i.componentMountPoints)==null?void 0:d.find(h=>h.did===ln),r=new URL(n);r.pathname=a==null?void 0:a.mountPoint;const l=r.toString(),c=G(l,"/api");return{base:l,api:c}},cn=Be({buy:{button:{title:"Buy DID Domain"},status:{inProgress:"Please wait while we are processing your request, the domain will be automatically resolved to the current app after the purchase...",success:"Purchase completed!"},error:{failedToCreateSession:"Failed to create session"}}}),dn=Be({buy:{button:{title:"购买 DID 域名"},status:{inProgress:"请稍等,我们正在处理您的请求,购买域名后会自动解析到当前的应用...",success:"购买完成!"},error:{failedToCreateSession:"创建会话失败"}}}),un={zh:dn,en:cn};function Ze({delegatee:n,delegateePk:t,didDomainURL:o,locale:i,title:a,onSuccess:r,...l}){const{t:c}=T(),[d,h]=Ut({currentState:1}),f=A.useRef(null),C=V(x=>{var m,v,I,j;x.data.type==="didDomain.success"&&(r==null||r({nftDid:(m=x.data)==null?void 0:m.nftDid,domain:(v=x.data)==null?void 0:v.domain,chainHost:(I=x.data)==null?void 0:I.chainHost}),(j=f.current)==null||j.close(),f.current=null,h({currentState:4}),setTimeout(()=>{h({currentState:8})},2e3))});Ot(()=>{var x;try{window.removeEventListener("message",C),(x=f.current)==null||x.close(),f.current=null}catch(m){console.warn("Failed to close popup",m)}});const S=V(()=>{h({currentState:1})}),g=V(()=>{h({currentState:2}),P.run()}),y=V(({sessionId:x,baseURL:m})=>{window.addEventListener("message",C);const v=new URL(m);v.searchParams.set("sessionId",x),v.searchParams.set("locale",i),f.current=an(v.toString());const I=setInterval(()=>{var j;(j=f.current)!=null&&j.closed&&(clearInterval(I),S())},1e3);return()=>clearInterval(I)}),P=Wt(async()=>{const x=await Ye(o);if(!x)return null;const m=Qe({baseURL:x.api}),{data:v}=await m.post("/payment/session",{delegatee:n,delegateePk:t});return y({sessionId:v.sessionId,baseURL:x.base})},{manual:!0,debounceWait:500,debounceLeading:!0,debounceTrailing:!1,debounceMaxWait:3e3,refreshDeps:[],onError(x){console.error(x)}});return e.jsxs(e.Fragment,{children:[e.jsx(W,{onClick:g,variant:"contained",startIcon:e.jsx(Gt,{}),...l,children:a||c("buy.button.title")}),e.jsxs(pt,{fullWidth:!0,maxWidth:"xs",open:d.currentState>1&&d.currentState<8,onClose:S,children:[!P.error&&e.jsxs(p,{sx:{display:"flex",alignItems:"center",flexDirection:"column",gap:2},children:[d.currentState===2&&e.jsx(z,{size:50}),d.currentState===4&&e.jsx(Vt,{sx:{color:"primary.main",fontSize:"5rem"}}),d.currentState===2&&e.jsx(q,{children:c("buy.status.inProgress")}),d.currentState===4&&e.jsx(q,{children:c("buy.status.success")})]}),P.error&&e.jsx(de,{severity:"error",children:c("buy.error.failedToCreateSession")})]})]})}const Xe={onSuccess:()=>{},title:""};Ze.defaultProps=Xe;function Je(n){return e.jsx(mt,{locale:n.locale,translations:un,children:e.jsx(Ze,{...n})})}Je.defaultProps=Xe;function et({nftDid:n,didDomainURL:t,locale:o,sx:i}){const{t:a}=T(),[r,l]=Q({safeIframeRef:null,popoverAnchorEl:null}),c=A.useRef(null),d=K(),h=ue(d.breakpoints.down("md")),f=y=>{l({popoverAnchorEl:y.currentTarget})},C=()=>{l({popoverAnchorEl:null})},S=Ht(async()=>{const y=await Ye(t);return y?y.base:null});if(!S.value)return null;if(S.loading)return e.jsx(z,{});const g=G(S.value,`/embed/domain?nft-did=${n}&locale=${o}`);return e.jsxs(e.Fragment,{children:[e.jsx(p,{component:"img",src:G(t,"/.well-known/service/blocklet/logo"),alt:"logo",width:16,height:16,onClick:f,sx:rn({cursor:"pointer"},i)}),e.jsx(Ne,{id:"popover-info",open:!!r.popoverAnchorEl,anchorEl:r.popoverAnchorEl,onClose:C,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx("iframe",{ref:c,title:a("common.subscription"),width:h?"320px":"400px",height:h?"600px":"680px",style:{border:0},src:g})})]})}et.defaultProps={sx:{}};const mn=n=>["waiting","creating","renewaling"].includes(n);function pe(n){var w,R;const{t}=T(),[o,i]=A.useState(!1),{inService:a}=F(),[r,l]=A.useState(null),{siteId:c,domain:d,onAdd:h,children:f,did:C}=n,[S,g]=A.useState(!1),{api:y,ws:{useSubscription:P}}=F(),{mode:x,actions:{refreshDomainStatus:m}}=We(),v=Yt(async()=>{const{cert:b}=await y.findCertificateByDomain({input:{domain:d,did:C}});return b}),I=(b,N)=>{b.domain===d&&(g(!1),i(!1),a&&x!=="setup"&&(N==="success"?O.success(t("setup.domain.genCertSuccess",{domain:b.domain})):N==="error"&&O.error(t("setup.domain.genCertFailed",{domain:b.domain,message:b.message}))))};if(A.useEffect(()=>{var b;v.loading||g(mn((b=v.value)==null?void 0:b.status))},[v.loading,(w=v.value)==null?void 0:w.status]),P(Te.BlockletEvents.certError,b=>I(b,"error")),P(Te.BlockletEvents.certIssued,b=>{v.retry(),m(b.domain),I(b,"success")}),v.loading||((R=v.value)==null?void 0:R.status)==="normal")return"";const j=()=>{i(!1),l(null)},k=async()=>{i(!0);try{await y.issueLetsEncryptCert({input:{siteId:c,domain:d,did:C,inBlockletSetup:x==="setup"}}),h(),g(!0)}catch(b){console.error(b),g(!1)}finally{i(!1),l(null)}},u={title:t("router.cert.genLetsEncryptCert.title"),description:e.jsxs("div",{children:[e.jsx(de,{severity:"success",children:t("router.cert.genLetsEncryptCert.dnsTip")}),t("router.cert.genLetsEncryptCert.description")]}),confirm:t("common.confirm"),onConfirm:k,onCancel:j},L=b=>{b.stopPropagation(),l(u)};return e.jsxs(e.Fragment,{children:[S?e.jsx(M,{title:t("router.cert.issuing"),children:e.jsx(z,{size:12})}):f({loading:o,open:L}),r&&e.jsx(Y,{color:"primary",title:r.title,description:r.description,confirm:r.confirm,params:r.params,onConfirm:r.onConfirm,onCancel:r.onCancel})]})}pe.propTypes={domain:s.string.isRequired,did:s.string.isRequired,siteId:s.string.isRequired,onAdd:s.func,children:s.any};pe.defaultProps={onAdd:()=>{},children:null};function fe(n){const{domain:t,domainStatus:o,...i}=n;return kt(t)||!Oe(t)||ft(o)||o!=null&&o.isHttps?"":e.jsx(pe,{domain:t,...i})}fe.propTypes={domain:s.string.isRequired,domainStatus:s.shape({isHttps:s.bool}).isRequired,did:s.string.isRequired,onAdd:s.func,children:s.any};fe.defaultProps={onAdd:()=>{},children:null};var he={},pn=ce;Object.defineProperty(he,"__esModule",{value:!0});var tt=he.default=void 0,fn=pn(ae()),hn=e;tt=he.default=(0,fn.default)((0,hn.jsx)("path",{d:"M17 20.41 18.41 19 15 15.59 13.59 17zM7.5 8H11v5.59L5.59 19 7 20.41l6-6V8h3.5L12 3.5z"}),"CallMerge");const nt=A.createContext({}),{Provider:xn,Consumer:es}=nt;function gn({children:n}){const[t,o]=Q({domain:"",error:null}),{locale:i}=T(),a={error:t.error,domain:t.domain,setError:r=>{o({error:r})},setDomain:r=>{const l=le(r),c=He(l,i);o({domain:l,error:c})}};return e.jsx(xn,{value:{value:a},children:n})}function Dn(){const{value:n}=A.useContext(nt);return n}const{joinURL:Fe}=Lt,yn=_t,st="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p",jn=async n=>{var c;if(!n||!(n!=null&&n.trim()))return null;const t=new URL(n);t.pathname="__blocklet__.js",t.searchParams.set("type","json");const{data:o}=await yn.get(t.toString()),i=(c=o==null?void 0:o.componentMountPoints)==null?void 0:c.find(d=>d.did===st),a=new URL(n);a.pathname=i==null?void 0:i.mountPoint;const r=a.toString(),l=Fe(r,"/api");return{base:r,api:l,domain:Fe(l,"/domains")}};var vn={DID_DOMAIN_SERVICE_DID:st,getDidDomainServiceURL:jn},Z={exports:{}};const bn=ht,Cn=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class ot extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}}const wn=(n,t,o)=>{const i=o.retries-(t-1);return n.attemptNumber=t,n.retriesLeft=i,n},Sn=n=>Cn.includes(n),it=(n,t)=>new Promise((o,i)=>{t={onFailedAttempt:()=>{},retries:10,...t};const a=bn.operation(t);a.attempt(async r=>{try{o(await n(r))}catch(l){if(!(l instanceof Error)){i(new TypeError(`Non-error was thrown: "${l}". You should only throw errors.`));return}if(l instanceof ot)a.stop(),i(l.originalError);else if(l instanceof TypeError&&!Sn(l.message))a.stop(),i(l);else{wn(l,r,t);try{await t.onFailedAttempt(l)}catch(c){i(c);return}a.retry(l)||i(a.mainError())}}})});Z.exports=it;Z.exports.default=it;Z.exports.AbortError=ot;var Rn=Z.exports;const An=Pt(Rn);function xe({domain:n,resolvedTarget:t,...o}){const{t:i,locale:a}=T();return e.jsxs(p,{sx:{backgroundColor:"rgb(236, 251, 253)",borderColor:"rgb(236, 251, 253)",borderRadius:"8px",padding:"12px"},...o,children:[e.jsxs(p,{display:"flex",children:[i("router.domain.setup.tipStart"),n&&e.jsx(p,{mx:.5,color:"primary.main",fontWeight:"fontWeightBold",children:n}),i("router.domain.setup.tipEnd"),":"]}),e.jsxs(p,{sx:{"&>div":{mb:0},marginTop:"8px"},children:[e.jsx(se,{label:i("router.domain.setup.recordType"),value:"CNAME",locale:a}),e.jsx(se,{label:i("router.domain.setup.recordValue"),value:t,locale:a})]})]})}xe.propTypes={domain:s.string,resolvedTarget:s.string.isRequired};xe.defaultProps={domain:""};function se({locale:n,label:t,value:o}){const i=ue(r=>r.breakpoints.down("md")),a=K();return e.jsx(Jt,{name:t,nameWidth:120,children:e.jsxs(p,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[e.jsx(q,{component:"span",color:"primary.main",overflow:"auto",sx:i?{maxWidth:"95%",wordWrap:"break-word"}:{wordWrap:"break-word"},children:o}),e.jsx(Me,{content:o,locale:n,style:{marginLeft:"4px",color:a.palette.text.secondary}})]})})}se.propTypes={locale:s.string.isRequired,label:s.string.isRequired,value:s.string.isRequired};function ge({siteId:n,teamDid:t,cnameDomain:o,defaultCustomDomain:i,onInputDomain:a,appId:r,appPk:l,onSuccess:c,onError:d,disabled:h,autoFocus:f,inBlockletSetup:C,shouldCheckDomain:S,onStateChange:g,currentIp:y,resolveDomain:P,...x}){const{t:m,locale:v}=T(),{api:I,info:j}=F(),k=Dn(),u=K(),L=xt({key:"sm"}),[w,R]=Q({submittingDomain:!1,domain:i,error:null,type:j!=null&&j.nftDomainUrl?"nftDomain":"inputDomain",showNFTDomainAuth:!1,showDnsTip:!1}),b=Xt(()=>vn.getDidDomainServiceURL(j==null?void 0:j.nftDomainUrl));if(j!=null&&j.nftDomainUrl&&b.loading)return e.jsx(p,{...x,children:e.jsx(Pe,{relative:"parent",children:e.jsx(z,{})})});if(b.error)return e.jsx(p,{...x,children:e.jsx(Pe,{relative:"parent",children:b.error.message})});const N=b.value,at=()=>{R({invalidDNSDomain:null})},ee=async D=>{g(m("setup.domain.addingDomain")),await I.addDomainAlias({input:{id:n,domainAlias:D,teamDid:t,inBlockletSetup:!0}}),R({submittingDomain:!1}),c({domain:D,type:"inputDomain"})},Se=async({domain:D,type:E,nftDid:U,chainHost:_})=>{try{if(!S){if(E==="inputDomain"){await ee(D);return}c({domain:D,type:E,nftDid:U,chainHost:_});return}g({text:m("setup.domain.checkingResolvable")});let $=30;const te=3e3,dt=$*1e3/te,Ae=setInterval(()=>{if($<=0){clearInterval(Ae);return}g({text:`${m("setup.domain.checkingResolvable")} (${$--}s)`})},1e3),Ie=await An(async()=>{const{data:B}=await P(D);if(!B.address)throw new Error("Cannot resolve domain");return B.address},{retries:dt,minTimeout:te,maxTimeout:te,onFailedAttempt:console.error}).catch(console.error);if(clearInterval(Ae),!Ie){const B=m("setup.domain.cannotResolve",{domain:D});if(E==="nftDomain"){O.error(B),c({domain:D,type:"nftDomain"});return}g({text:""}),R({invalidDNSDomain:{domain:D,error:B},domain:D,type:E,submittingDomain:!1});return}if(Ie!==y){const B=m("setup.domain.resolvedAddressError",{domain:D,curDomain:window.location.hostname});if(E==="nftDomain"){O.error(B),c({domain:D,type:"nftDomain"});return}g({text:""}),R({invalidDNSDomain:{domain:D,error:B},domain:D,type:E,submittingDomain:!1});return}if(E==="nftDomain"){c({domain:D,type:"nftDomain"});return}await ee(D)}catch($){O.error($.message),g({text:""}),R({submittingDomain:!1})}},lt=async({domain:D,nftDid:E,chainHost:U})=>{try{const _=_e(D);R({submittingDomain:!0}),await I.addDomainAlias({input:{id:n,type:"nft-domain",domainAlias:_,nftDid:E,chainHost:U,teamDid:t,inBlockletSetup:C}});const $="nftDomain";R({showNFTDomainAuth:!1,type:$}),await Se({domain:_,type:$,nftDid:E,chainHost:U})}catch(_){O.error(_.message)}finally{R({showNFTDomainAuth:!1,submittingDomain:!1})}},ct=async()=>{try{R({submittingDomain:!0});const D=_e(w.domain);if(j.nftDomainUrl&&N&&(await I.isDidDomain({input:{domain:D}})).value===!0){R({showNFTDomainAuth:!0});return}await Se({domain:D,type:w.type})}catch(D){R({submittingDomain:!1}),k.setError(D.message)}},Re=k.error||w.error;return e.jsx(p,{...x,children:e.jsxs(p,{sx:{display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:"1em"},children:[e.jsxs(p,{sx:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(q,{sx:{color:u.palette.text.primary},children:m("router.domainAlias.add.tips")}),e.jsx(vt,{sx:{display:"block",marginTop:"8px"},label:m("router.domainAlias.add.domainDescription"),helperText:w.type==="inputDomain"&&Re||m("router.domainAlias.add.helperText"),inputProps:{"data-cy":"domain-name-input"},fullWidth:!0,disabled:h,value:w.domain,size:"small",variant:"outlined",error:!!Re&&w.type==="inputDomain",onChange:D=>{var _;const E=le((_=D.target)==null?void 0:_.value);k.setDomain(E);const U=He(E,v);R({domain:E,error:U,type:"inputDomain"}),a({domain:E,error:U,type:"inputDomain"})},autoFocus:f,onBlur:()=>{k.domain||(R({error:null}),k.setError(null))}}),e.jsx(p,{sx:{width:"100%",display:"flex",justifyContent:"flex-end"},children:e.jsx(bt,{"data-cy":"confirm-add-domain",fullWidth:L,variant:"contained",loading:w.submittingDomain,onClick:ct,children:m("common.add")})}),e.jsxs(p,{sx:{cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"4px",lineHeight:1,color:u.palette.primary.main},onClick:()=>R({showDnsTip:!w.showDnsTip}),children:[e.jsx(Zt,{fontSize:"1em"}),m("router.domainAlias.showTipHint")]}),w.showDnsTip&&e.jsx(xe,{domain:w.domain,resolvedTarget:o,style:{marginTop:"4px"}})]}),w.invalidDNSDomain&&e.jsx(Y,{title:m("common.reminder"),description:m("setup.domain.invalidDNSReminder",{error:w.invalidDNSDomain.error}),color:"primary",confirm:m("setup.domain.continueAdd"),onConfirm:()=>ee(w.invalidDNSDomain.domain,w.type),onCancel:at}),N&&e.jsx(gt,{open:w.showNFTDomainAuth,popup:!0,useSocket:!1,forceConnected:!1,action:"authorize",baseUrl:N.api,checkFn:Qt.create({baseURL:N.api}).get,extraParams:{delegatee:r,delegateePk:l,domain:w.domain},onSuccess:lt,onClose:()=>R({showNFTDomainAuth:!1,submittingDomain:!1}),checkTimeout:60*5e3,showDownload:!1,messages:{title:m("router.domainAlias.addDomainNFT.connect.title"),scan:m("router.domainAlias.addDomainNFT.connect.scan"),confirm:m("router.domainAlias.addDomainNFT.connect.confirm"),success:m("router.domainAlias.addDomainNFT.connect.success")}})]})})}ge.propTypes={siteId:s.string.isRequired,currentIp:s.string,teamDid:s.string.isRequired,cnameDomain:s.string.isRequired,defaultCustomDomain:s.string,onInputDomain:s.func,onSuccess:s.func,appId:s.string,appPk:s.string,disabled:s.bool,autoFocus:s.bool,inBlockletSetup:s.bool,shouldCheckDomain:s.bool,onStateChange:s.func,resolveDomain:s.func,onError:s.func};ge.defaultProps={defaultCustomDomain:"",currentIp:"",onInputDomain:Ee,onSuccess:Ee,appId:"",appPk:"",disabled:!1,autoFocus:!0,inBlockletSetup:!1,shouldCheckDomain:!1,onStateChange:()=>{},resolveDomain:()=>{},onError:()=>{}};function De({id:n,children:t,title:o,teamDid:i,systemDomains:a,appId:r,appPk:l}){const{t:c}=T(),[d,h]=Q({loading:!1,confirmSetting:null}),f=a.find(y=>Ve.isDidDomain(y)),C=()=>{h({loading:!1,confirmSetting:null})},S={title:o||c("router.domainAlias.add.title"),description:function(P,x,m){return e.jsx(ge,{siteId:n,teamDid:i,cnameDomain:f,onSuccess:()=>h({confirmSetting:null}),onInputDomain:({domain:v,type:I,error:j})=>{x({...P,domain:v,type:I,__disableConfirm:!!j}),m(j)},appId:r,appPk:l})},confirm:c("common.confirm"),cancel:c("common.cancel"),params:{domain:"",__disableConfirm:!0},onCancel:C},g=y=>{y.stopPropagation(),h({confirmSetting:S})};return e.jsxs(e.Fragment,{children:[typeof t=="function"?t({loading:d.loading,open:g}):e.jsxs(Ue,{onClick:g,className:"rule-action","data-cy":"action-add-domain-alias",children:[d.loading?e.jsx(z,{size:16}):e.jsx(tt,{style:{fontSize:18,marginRight:5}}),c("router.domainAlias.add.title")]}),d.confirmSetting&&e.jsx(Y,{title:d.confirmSetting.title,description:d.confirmSetting.description,confirm:d.confirmSetting.confirm,cancel:d.confirmSetting.cancel,params:d.confirmSetting.params,onCancel:d.confirmSetting.onCancel,showConfirm:!1,showCancel:!0,displayError:!1,color:"primary",loading:d.loading,maxWidth:"sm"})]})}De.propTypes={id:s.string.isRequired,children:s.any,title:s.string,teamDid:s.string,systemDomains:s.arrayOf(s.string).isRequired,appId:s.string,appPk:s.string.isRequired};De.defaultProps={children:null,title:"",teamDid:"",appId:null};function In(n){return e.jsx(gn,{children:e.jsx(De,{...n})})}function ye({appId:n,appPk:t,siteId:o,inBlockletSetup:i,teamDid:a,sx:r,...l}){const{api:c,info:d}=F(),{locale:h,t:f}=T(),C=async({domain:S,nftDid:g,chainHost:y})=>{await c.addDomainAlias({input:{id:o,type:"nft-domain",domainAlias:S,nftDid:g,chainHost:y,teamDid:a,inBlockletSetup:i}})};return e.jsx(Je,{delegatee:n,delegateePk:t,didDomainURL:d.nftDomainUrl,onSuccess:C,locale:h,variant:"outlined",sx:r,title:f("router.domainAlias.addDomainNFT.buy"),...l})}ye.propTypes={appId:s.string.isRequired,appPk:s.string.isRequired,siteId:s.string.isRequired,inBlockletSetup:s.bool.isRequired,teamDid:s.string.isRequired,sx:s.object};ye.defaultProps={sx:{}};function je(n){const{t}=T(),[o,i]=A.useState(!1),[a,r]=A.useState(null),{id:l,domain:c,children:d,teamDid:h}=n,{api:f}=F(),C=()=>{i(!1),r(null)},S=async()=>{i(!0);try{await f.deleteDomainAlias({input:{id:l,domainAlias:c,teamDid:h}}),await qt(2e3)}catch(P){O.error(P.message)}finally{r(null),i(!1)}},g={title:t("router.domainAlias.delete.title"),description:t("router.domainAlias.delete.description"),confirm:t("common.confirm"),onConfirm:S,onCancel:C},y=P=>{P.stopPropagation(),r(g)};return e.jsxs(e.Fragment,{children:[typeof d=="function"?d({loading:o,open:y}):e.jsxs(W,{edge:"end",onClick:y,size:"small",className:"rule-action",color:"error","data-cy":"action-delete-domain-alias",children:[o?e.jsx(z,{size:16}):e.jsx(ze,{style:{fontSize:16}}),t("router.domainAlias.delete.title")]}),a&&e.jsx(Y,{title:a.title,description:a.description,confirm:a.confirm,params:a.params,onConfirm:a.onConfirm,onCancel:a.onCancel})]})}je.propTypes={id:s.string.isRequired,domain:s.string.isRequired,children:s.any,teamDid:s.string};je.defaultProps={children:null,teamDid:""};function ve({site:n,domain:t,blocklet:o}){const{t:i}=T(),a=t.value===window.location.hostname;return e.jsx(en,{"data-cy":"domain-actions",size:"large",actions:[({close:r})=>{var l;return e.jsx(je,{id:n.id,domain:t.value,teamDid:(l=o==null?void 0:o.meta)==null?void 0:l.did,children:({open:c})=>e.jsx(M,{title:a?i("blocklet.router.currentDomainTip"):"",children:e.jsx("span",{children:e.jsxs(Ue,{disabled:t.isProtected||a,dense:!0,onClick:d=>{r(),c(d)},"data-cy":"action-toggle-block",children:[e.jsx(Ct,{style:{minWidth:24,marginRight:8},children:e.jsx(ze,{})}),e.jsx(wt,{primary:i("common.delete")})]},"remove")})})})}]})}ve.propTypes={site:s.object.isRequired,domain:s.object.isRequired,blocklet:s.object.isRequired};ve.defaultProps={};var be={},Pn=ce;Object.defineProperty(be,"__esModule",{value:!0});var Ce=be.default=void 0,En=Pn(ae()),Tn=e;Ce=be.default=(0,En.default)((0,Tn.jsx)("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1z"}),"Https");const X=s.shape({href:s.string,accessibility:s.shape({loading:s.bool,accessible:s.bool}),domainStatus:s.shape({isHttps:s.bool,matchedCert:s.object}),dns:s.shape({resolved:s.bool,ip:s.string})});function we({certificate:n}){const[t,o]=A.useState(null),i=F(),{t:a,locale:r}=T(),l=h=>{o(h.currentTarget)},c=()=>{o(null)},d=!!t;return e.jsxs(e.Fragment,{children:[e.jsx(Ce,{"aria-owns":d?"mouse-over-popover":void 0,onMouseEnter:l,onMouseLeave:c,style:{color:"#44cdc6",fontSize:20,cursor:"pointer"}}),e.jsx(Ne,{id:"mouse-over-popover",style:{pointerEvents:"none"},open:d,anchorEl:t,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},onClose:c,disableRestoreFocus:!0,children:e.jsx(St,{children:e.jsxs(Rt,{style:{display:"flex"},children:[e.jsx("div",{children:e.jsx("img",{src:`${i.imgPrefix}/https-certificate-icon.png`,alt:"certificate icon",style:{maxHeight:"100%",maxWidth:"100%"}})}),e.jsxs(q,{component:"div",style:{marginLeft:"16px"},children:[e.jsx(q,{component:"div",style:{fontWeight:"bold"},children:n.domain}),e.jsx(q,{component:"div",children:`${a("common.issuer")}: ${Dt(n,"issuer.commonName","")}`}),e.jsx(q,{component:"div",children:`${a("router.cert.issuedOn")}: ${ke(n.validFrom,r)}`}),e.jsx(q,{component:"div",children:`${a("router.cert.expiryOn")}: ${ke(n.validTo,r)}`})]})]})})})]})}we.propTypes={certificate:s.object};we.defaultProps={certificate:{}};function H({domain:n,filters:t}){const{t:o}=T(),{value:i,domainStatus:a}=n;if(!Oe(i))return null;let r=null,l=null;const{isHttps:c,matchedCert:d}=a;if(!Ft(i)){const{dns:{resolved:f,ip:C}={}}=a;f||C==="127.0.0.1"?r=e.jsx(M,{title:o("router.domain.verify.ok"),children:e.jsx(qe,{color:"success"})}):r=e.jsx(M,{title:o("router.domain.verify.notResolved"),children:e.jsx(qe,{color:"error"})})}c?l=e.jsx(we,{certificate:d}):l=e.jsx(M,{title:o("router.domain.https.bad"),children:e.jsx(Ce,{style:{color:"#D0021B",fontSize:20,cursor:"pointer"}})});const h=t.map(f=>f==="domain"?r:f==="http"?l:null);return A.createElement(A.Fragment,null,...h)}H.propTypes={domain:X.isRequired,filters:s.array};H.defaultProps={filters:["domain","http"]};const kn=Ge(J,"mutate_blocklets"),Ln=Ge(J,"",$t);function rt(n){const{inService:t}=F(),{blocklet:o,loadingRuntimeInfo:i}=We();let a=kn;return t&&(a=Ln),e.jsx(a,{...n,blocklet:o,inService:t,loadingRuntimeInfo:i})}rt.propTypes={listOnly:s.bool};rt.defaultProps={listOnly:!1};function J({hasPermission:n,blocklet:t,loadingRuntimeInfo:o,inService:i,listOnly:a}){var v,I,j,k;const{t:r}=T(),{info:l}=F(),[c,d]=A.useState(!1),h=ue(u=>u.breakpoints.down("md")),f=A.useMemo(()=>{let u=n;return Bt(t)&&(u=u&&i),u},[n,i,t]),{site:C}=t,S=A.useMemo(()=>{var u;return Mt((u=t.site)==null?void 0:u.domainAliases)},[(v=t.site)==null?void 0:v.domainAliases]),g=[],y=[],P=Tt.encode(t.appPid),x=(j=(I=t.environments)==null?void 0:I.find(u=>u.key==="BLOCKLET_APP_PK"))==null?void 0:j.value,m=zt(S);return S.forEach(u=>{const L=u.value||"";Ve.isDidDomain(L)&&!L.startsWith(P)?y.push(u):g.push(u)}),e.jsxs(e.Fragment,{children:[!a&&e.jsxs(e.Fragment,{children:[e.jsxs(p,{className:"title first",display:"flex",justifyContent:"space-between",alignItems:"center",children:[e.jsx(p,{children:r("common.domain")}),f&&e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(In,{id:C.id,title:r("router.domain.add.title"),teamDid:(k=t.meta)==null?void 0:k.did,appId:t.appPid,appPk:x,systemDomains:m==null?void 0:m.map(u=>u.value),children:({open:u})=>e.jsxs(W,{style:{marginLeft:16},variant:"contained",color:"primary","data-cy":"add-domain-alias",onClick:u,disabled:Le.isInProgress(t.status),children:[e.jsx(Et,{style:{fontSize:"1.3em",marginRight:4}}),r("common.add")]})}),l.nftDomainUrl&&e.jsx(ye,{variant:"outlined",appId:t.appPid,appPk:x,siteId:C.id,inBlockletSetup:!1,teamDid:t.meta.did})]})]}),Le.isAccessible(t.status)===!1&&e.jsx(p,{mt:1.5,mb:1.5,children:e.jsx(de,{severity:"warning",children:r("blocklet.router.noRunning")})})]}),e.jsx(p,{sx:{display:"flex",flexDirection:"column",gap:1},children:(c?S:g).map(u=>{var w,R;const L=u.value;return e.jsxs(A.Fragment,{children:[h&&e.jsxs(p,{display:"flex",flexDirection:"column",children:[e.jsx(p,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:e.jsx(oe,{domain:u,target:"_blank",children:u.value})}),e.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:1},children:[e.jsx(H,{domain:u,filters:["domain"]},`${u.value}-domain`),e.jsx(re,{siteId:(w=t.site)==null?void 0:w.id,domain:u,blocklet:t,hasMutatePermission:f})]}),e.jsx(p,{sx:{button:{padding:0}},children:e.jsx(ie,{hasMutatePermission:f,site:C,domain:u,blocklet:t})})]})]},L),!h&&e.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"space-between",children:[e.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[e.jsx(H,{domain:u,filters:["domain"]},`${u.value}-domain`),e.jsx(p,{sx:{ml:2,mr:.5},children:e.jsx(oe,{domain:u,target:"_blank",children:u.value})}),e.jsx(re,{siteId:(R=t.site)==null?void 0:R.id,domain:u,blocklet:t,hasMutatePermission:f})]}),e.jsx(p,{sx:{button:{padding:0}},children:e.jsx(ie,{hasMutatePermission:f,site:C,domain:u,blocklet:t})})]},L)]},L)})}),y.length>0&&e.jsx("div",{style:{marginLeft:"20px",marginTop:"12px"},children:e.jsx(W,{endIcon:c?e.jsx(Ke,{}):e.jsx(yt,{}),onClick:()=>d(!c),children:r(c?"common.collapseAll":"blocklet.router.showAllDomains")})}),!S.length&&(o?e.jsx(z,{size:16}):e.jsx(jt,{children:r("common.empty")}))]})}J.propTypes={hasPermission:s.bool,blocklet:s.object.isRequired,loadingRuntimeInfo:s.bool,inService:s.bool.isRequired,listOnly:s.bool};J.defaultProps={hasPermission:!1,loadingRuntimeInfo:!1,listOnly:!1};function oe({domain:n,children:t,...o}){const{t:i,locale:a}=T(),{href:r,accessibility:l,value:c}=n,d=A.useCallback(()=>e.jsx(Me,{content:le(c),locale:a,style:{marginLeft:"4px",color:"#999",fontSize:"0.8em",verticalAlign:"bottom"}}),[c,a]);return!l||l.loading?e.jsxs(ne,{...o,children:[t,d(),e.jsx(M,{title:i("blocklet.router.checkUrlAccessible"),placement:"top-end",children:e.jsx("span",{className:"status",children:e.jsx(z,{size:12})})})]}):l.accessible?e.jsxs(ne,{...o,children:[e.jsx(p,{component:"a",href:r,target:"_blank",rel:"noopener noreferrer",children:t}),d()]}):e.jsxs(ne,{...o,children:[e.jsx(M,{title:i("blocklet.router.urlInaccessible"),placement:"top-end",children:e.jsx("span",{children:t})}),d()]})}oe.propTypes={domain:X.isRequired,children:s.any.isRequired};const ne=At.span`
2
2
  &,
3
3
  & > * {
4
4
  color: #222;
@@ -12,4 +12,4 @@ import{ad as ae,ba as $e,N as ut,f as Be,L as mt,g as k,ag as W,al as pt,v as ft
12
12
  .status {
13
13
  margin-left: 8px;
14
14
  }
15
- `;function ie({hasMutatePermission:n,site:t,domain:o,blocklet:i}){const a=K(),{t:r}=k();return n&&!o.isProtected?e.jsx(ve,{site:t,domain:o,blocklet:i}):e.jsx(M,{title:r("blocklet.router.domainLockTooltip"),placement:"top",children:e.jsx(It,{disabled:!0,size:"large",style:{pointerEvents:"auto",paddingTop:0,paddingBottom:0},children:e.jsx(Ut,{style:{fill:a.palette.text.disabled}})})})}ie.propTypes={hasMutatePermission:s.bool.isRequired,site:s.object.isRequired,domain:X.isRequired,blocklet:s.object.isRequired};function re({siteId:n,domain:t,blocklet:o,hasMutatePermission:i}){const{info:a}=F(),{t:r,locale:l}=k();return e.jsxs(p,{sx:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:1},children:[t.type==="nft-domain"&&e.jsx(et,{locale:l,nftDid:t.nftDid,didDomainURL:a.nftDomainUrl}),e.jsx(H,{domain:t,filters:["http"]},`${t.value}-http`),i&&e.jsx(fe,{siteId:n,domain:t.value,domainStatus:t.domainStatus,did:o.meta.did,children:({open:c})=>e.jsx(W,{sx:{padding:0},size:"small",onClick:d=>c(d),children:r("router.cert.genLetsEncryptCert.title")})})]})}re.propTypes={siteId:s.string.isRequired,domain:X.isRequired,blocklet:s.object.isRequired,hasMutatePermission:s.bool.isRequired};export{ge as A,ye as B,gn as D,rt as a};
15
+ `;function ie({hasMutatePermission:n,site:t,domain:o,blocklet:i}){const a=K(),{t:r}=T();return n&&!o.isProtected?e.jsx(ve,{site:t,domain:o,blocklet:i}):e.jsx(M,{title:r("blocklet.router.domainLockTooltip"),placement:"top",children:e.jsx(It,{disabled:!0,size:"large",style:{pointerEvents:"auto",paddingTop:0,paddingBottom:0},children:e.jsx(Nt,{style:{fill:a.palette.text.disabled}})})})}ie.propTypes={hasMutatePermission:s.bool.isRequired,site:s.object.isRequired,domain:X.isRequired,blocklet:s.object.isRequired};function re({siteId:n,domain:t,blocklet:o,hasMutatePermission:i}){const{info:a}=F(),{t:r,locale:l}=T();return e.jsxs(p,{sx:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:1},children:[t.type==="nft-domain"&&e.jsx(et,{locale:l,nftDid:t.nftDid,didDomainURL:a.nftDomainUrl}),e.jsx(H,{domain:t,filters:["http"]},`${t.value}-http`),i&&e.jsx(fe,{siteId:n,domain:t.value,domainStatus:t.domainStatus,did:o.meta.did,children:({open:c})=>e.jsx(W,{sx:{padding:0},size:"small",onClick:d=>c(d),children:r("router.cert.genLetsEncryptCert.title")})})]})}re.propTypes={siteId:s.string.isRequired,domain:X.isRequired,blocklet:s.object.isRequired,hasMutatePermission:s.bool.isRequired};export{ge as A,ye as B,gn as D,rt as a};
@@ -1,4 +1,4 @@
1
- import{a1 as E,j as t,a3 as i,T as j,I as _,C as w,E as y,aa as A}from"./vendor-mui-core-BlX2BJoA.js";import{H as L,o as W,f as H,af as R,d as S}from"./index-wG4Kh8A_.js";import{D as z,a as O,B as q,A as N}from"./domain-list-BEjAE8hh.js";import{ad as $,af as F,bB as K}from"./vendor-arcblock-CiLB_TiI.js";import{P as M}from"./page-header-6EUz18Qu.js";import{r}from"./vendor-react-D-afvo_7.js";import{_ as U}from"./useSetState-Crt4S51m.js";import{S as l}from"./button-Bo5ZAcJk.js";import{S as Y}from"./layout-BRN0uPvp.js";import{S as G}from"./step-actions-ClTz1KhK.js";import"./vendor-utils-DCpRgzMR.js";import"./vendor-hooks-CLzfFpO7.js";import"./Add-2VCvBnGd.js";import"./base32-COJTblwx.js";import"./LockIcon-DQtUl5vk.js";import"./CheckCircle-BElcljFC.js";import"./util-ao8gSgii.js";import"./permission-SgzW7fBj.js";import"./session-ocxAyn6f.js";import"./useAsyncRetry-KXMle3o0.js";import"./useAsync-cdOzMWPw.js";import"./confirm-C0rryr4e.js";import"./format-error-C0Ke3VXF.js";import"./InfoOutlined-BFP30UJa.js";import"./api-C0C4sDJA.js";import"./index-mnKcDZP2.js";import"./actions-BEpPU26q.js";import"./MoreHoriz-DnFq43xg.js";import"./content-layout-CK_AzZZ-.js";var p={},J=E;Object.defineProperty(p,"__esModule",{value:!0});var v=p.default=void 0,Q=J($()),V=t;v=p.default=(0,Q.default)((0,V.jsx)("path",{d:"M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m6 9.8a.9.9 0 0 1-.1.5l-2.1 4.9a1.34 1.34 0 0 1-1.3.8H9a2 2 0 0 1-2-2v-5a1.28 1.28 0 0 1 .4-1L12 5l.69.69a1.08 1.08 0 0 1 .3.7v.2L12.41 10H17a1 1 0 0 1 1 1z"}),"Recommend");function c({onNext:s,onPrevious:g}){var h,D;const{t:o}=r.useContext(F),{info:C}=L(),[k,u]=r.useState(!1),{blocklet:a}=W(),[x,I]=r.useState(""),[d,P]=r.useState(!1),B=(((a==null?void 0:a.site)||{}).domainAliases||[]).map(e=>H.replaceSlotToIp(e.value,x)),[n,m]=U({domain:"",invalidDNSDomain:null,type:"",addDomainState:{text:""}}),f=(D=(h=a.environments)==null?void 0:h.find(e=>e.key==="BLOCKLET_APP_PK"))==null?void 0:D.value,T=B.find(e=>R.isDidDomain(e));return r.useEffect(()=>{S.get(`/dns-resolve?hostname=${window.location.hostname}`).then(({data:e})=>{I(e.address||"")}).catch(e=>{console.error(e.message)})},[]),t.jsxs(X,{children:[t.jsx("div",{className:"header",children:t.jsx(M,{title:o("setup.domain.title"),subTitle:o("setup.domain.subTitle"),onClickBack:g})}),t.jsxs(i,{className:"form",sx:{display:"flex",flexDirection:"column",gap:3,overflowY:"auto"},children:[t.jsxs(i,{children:[t.jsxs(i,{color:"text.primary",fontWeight:"fontWeightBold",fontSize:"1.125rem",children:[t.jsx(i,{display:"inline",children:o("setup.domain.skipStart")}),t.jsx(l,{variant:"text",size:"small",disabled:!!n.addDomainState.text,onClick:()=>s(),style:{paddingTop:0},children:t.jsx("span",{style:{textDecoration:"underline"},children:o("setup.domain.skip")})}),t.jsx(i,{display:"inline",children:o("setup.domain.skipEnd")})]}),t.jsx(i,{sx:{marginTop:"12px"},children:t.jsx(O,{listOnly:!0,inSetup:!0})})]}),t.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:2},children:[C.nftDomainUrl&&t.jsxs(t.Fragment,{children:[t.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(v,{color:"primary"}),t.jsx(j,{fontWeight:"fontWeightBold",children:o("setup.domain.buyDIDDomainTitle")})]}),t.jsxs(i,{children:[t.jsx(q,{appPk:f,appId:a.appPid,siteId:a.site.id,teamDid:a.meta.did,title:o("common.buy"),inBlockletSetup:!0}),t.jsx(j,{sx:{marginTop:1},children:o("setup.domain.buyDIDDomainTips")})]})]}),t.jsxs(i,{children:[t.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",overflow:"hidden",cursor:"pointer"},onClick:()=>P(!d),children:[t.jsx(i,{fontWeight:"fontWeightBold",fontSize:"1.125rem",children:o("setup.domain.addTitle")}),t.jsx(_,{sx:{transform:d?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s"},children:t.jsx(K,{})})]}),t.jsx(w,{in:d,timeout:"auto",unmountOnExit:!0,children:t.jsx(N,{autoFocus:!1,appPk:f,appId:a.appPid,siteId:a.site.id,teamDid:a.meta.did,cnameDomain:T,currentIp:x,inBlockletSetup:!0,shouldCheckDomain:!0,resolveDomain:e=>S.get(`/dns-resolve?hostname=${e}`),onInputDomain:e=>{m({domain:e.domain,type:e.type}),u(e.error)},onStateChange:e=>m({addDomainState:e}),onSuccess:e=>{const b={domain:e.domain,type:e.type,nftDid:e.nftDid,chainHost:e.chainHost};m(b),s()},onError:u})})]})]})]}),t.jsx(G,{mt:8,disabled:!!n.addDomainState.text,blocklet:a,onStartNow:()=>s("complete"),children:n.domain?t.jsx(l,{variant:"contained",loading:!!n.addDomainState.text,disabled:k||!!n.addDomainState.text||!n.domain,onClick:()=>s(),children:n.addDomainState.text||o("setup.next")}):t.jsx(l,{variant:"contained",disabled:!!n.addDomainState.text,onClick:()=>s(),children:o("setup.skip")})})]})}function Et(s){return t.jsx(z,{children:t.jsx(c,{...s})})}c.propTypes={onNext:y.func,onPrevious:y.func};c.defaultProps={onNext:()=>{},onPrevious:()=>{}};const X=A(Y)`
1
+ import{a1 as E,j as t,a3 as i,T as j,I as _,C as A,E as y,aa as w}from"./vendor-mui-core-BlX2BJoA.js";import{H as L,o as W,f as H,af as R,d as S}from"./index-BjauMU9c.js";import{D as z,a as O,B as q,A as N}from"./domain-list-D8GpnsIy.js";import{ad as $,af as F,bA as K}from"./vendor-arcblock-CZGLzU01.js";import{P as M}from"./page-header-7_k_ugJy.js";import{r}from"./vendor-react-D-afvo_7.js";import{_ as U}from"./useSetState-Crt4S51m.js";import{S as l}from"./button-pEMdQ6vg.js";import{S as Y}from"./layout-CIMojpa6.js";import{S as G}from"./step-actions-BJ6wYLRD.js";import"./vendor-utils-DCpRgzMR.js";import"./vendor-hooks-CLzfFpO7.js";import"./Add-C6s-Vnmg.js";import"./base32-C41aFfgE.js";import"./LockIcon-DQtUl5vk.js";import"./CheckCircle-D3sLlO8U.js";import"./util-BZGCzHyk.js";import"./permission-BGRlqVt3.js";import"./session-DZl-cVQ_.js";import"./useAsyncRetry-KXMle3o0.js";import"./useAsync-cdOzMWPw.js";import"./confirm-BHRsp-P-.js";import"./format-error-C0Ke3VXF.js";import"./InfoOutlined-phoVf4hW.js";import"./api-C0C4sDJA.js";import"./index-DFJvHEx_.js";import"./actions-B2A8ao0K.js";import"./MoreHoriz-CUgH0jV-.js";import"./content-layout-CK_AzZZ-.js";var p={},J=E;Object.defineProperty(p,"__esModule",{value:!0});var v=p.default=void 0,Q=J($()),V=t;v=p.default=(0,Q.default)((0,V.jsx)("path",{d:"M12 2a10 10 0 1 0 10 10A10 10 0 0 0 12 2m6 9.8a.9.9 0 0 1-.1.5l-2.1 4.9a1.34 1.34 0 0 1-1.3.8H9a2 2 0 0 1-2-2v-5a1.28 1.28 0 0 1 .4-1L12 5l.69.69a1.08 1.08 0 0 1 .3.7v.2L12.41 10H17a1 1 0 0 1 1 1z"}),"Recommend");function c({onNext:s,onPrevious:g}){var h,D;const{t:o}=r.useContext(F),{info:C}=L(),[k,u]=r.useState(!1),{blocklet:a}=W(),[x,I]=r.useState(""),[d,P]=r.useState(!1),T=(((a==null?void 0:a.site)||{}).domainAliases||[]).map(e=>H.replaceSlotToIp(e.value,x)),[n,m]=U({domain:"",invalidDNSDomain:null,type:"",addDomainState:{text:""}}),f=(D=(h=a.environments)==null?void 0:h.find(e=>e.key==="BLOCKLET_APP_PK"))==null?void 0:D.value,B=T.find(e=>R.isDidDomain(e));return r.useEffect(()=>{S.get(`/dns-resolve?hostname=${window.location.hostname}`).then(({data:e})=>{I(e.address||"")}).catch(e=>{console.error(e.message)})},[]),t.jsxs(X,{children:[t.jsx("div",{className:"header",children:t.jsx(M,{title:o("setup.domain.title"),subTitle:o("setup.domain.subTitle"),onClickBack:g})}),t.jsxs(i,{className:"form",sx:{display:"flex",flexDirection:"column",gap:3,overflowY:"auto"},children:[t.jsxs(i,{children:[t.jsxs(i,{color:"text.primary",fontWeight:"fontWeightBold",fontSize:"1.125rem",children:[t.jsx(i,{display:"inline",children:o("setup.domain.skipStart")}),t.jsx(l,{variant:"text",size:"small",disabled:!!n.addDomainState.text,onClick:()=>s(),style:{paddingTop:0},children:t.jsx("span",{style:{textDecoration:"underline"},children:o("setup.domain.skip")})}),t.jsx(i,{display:"inline",children:o("setup.domain.skipEnd")})]}),t.jsx(i,{sx:{marginTop:"12px"},children:t.jsx(O,{listOnly:!0,inSetup:!0})})]}),t.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:2},children:[C.nftDomainUrl&&t.jsxs(t.Fragment,{children:[t.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(v,{color:"primary"}),t.jsx(j,{fontWeight:"fontWeightBold",children:o("setup.domain.buyDIDDomainTitle")})]}),t.jsxs(i,{children:[t.jsx(q,{appPk:f,appId:a.appPid,siteId:a.site.id,teamDid:a.meta.did,title:o("common.buy"),inBlockletSetup:!0}),t.jsx(j,{sx:{marginTop:1},children:o("setup.domain.buyDIDDomainTips")})]})]}),t.jsxs(i,{children:[t.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",overflow:"hidden",cursor:"pointer"},onClick:()=>P(!d),children:[t.jsx(i,{fontWeight:"fontWeightBold",fontSize:"1.125rem",children:o("setup.domain.addTitle")}),t.jsx(_,{sx:{transform:d?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s"},children:t.jsx(K,{})})]}),t.jsx(A,{in:d,timeout:"auto",unmountOnExit:!0,children:t.jsx(N,{autoFocus:!1,appPk:f,appId:a.appPid,siteId:a.site.id,teamDid:a.meta.did,cnameDomain:B,currentIp:x,inBlockletSetup:!0,shouldCheckDomain:!0,resolveDomain:e=>S.get(`/dns-resolve?hostname=${e}`),onInputDomain:e=>{m({domain:e.domain,type:e.type}),u(e.error)},onStateChange:e=>m({addDomainState:e}),onSuccess:e=>{const b={domain:e.domain,type:e.type,nftDid:e.nftDid,chainHost:e.chainHost};m(b),s()},onError:u})})]})]})]}),t.jsx(G,{mt:8,disabled:!!n.addDomainState.text,blocklet:a,onStartNow:()=>s("complete"),children:n.domain?t.jsx(l,{variant:"contained",loading:!!n.addDomainState.text,disabled:k||!!n.addDomainState.text||!n.domain,onClick:()=>s(),children:n.addDomainState.text||o("setup.next")}):t.jsx(l,{variant:"contained",disabled:!!n.addDomainState.text,onClick:()=>s(),children:o("setup.skip")})})]})}function Et(s){return t.jsx(z,{children:t.jsx(c,{...s})})}c.propTypes={onNext:y.func,onPrevious:y.func};c.defaultProps={onNext:()=>{},onPrevious:()=>{}};const X=w(Y)`
2
2
  height: 100%;
3
3
  overflow-y: hidden;
4
4
  .form {
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DVYdq7IA.js","assets/vendor-react-D-afvo_7.js"])))=>i.map(i=>d[i]);
2
- import{u as ee,_ as b,d as $}from"./index-wG4Kh8A_.js";import{a1 as te,j as e,ac as g,T as w,x as P,aQ as se,a3 as F,M,a2 as ne,aa as ie}from"./vendor-mui-core-BlX2BJoA.js";import{r,u as re}from"./vendor-react-D-afvo_7.js";import{d as p,ad as ae,g as oe,W as ce,z as C,aS as h,P as le,U as ue,S as de,D as fe}from"./vendor-arcblock-CiLB_TiI.js";import{i as me}from"./isEmail-BWNRBSAy.js";import{F as pe}from"./fullpage-CFp4hSHz.js";import"./vendor-hooks-CLzfFpO7.js";import{f as S}from"./format-error-C0Ke3VXF.js";import{d as ge}from"./CheckCircle-BElcljFC.js";import{g as R}from"./get-safe-url-CVhAz4Qr.js";import"./vendor-utils-DCpRgzMR.js";var N;(N=window.env)!=null&&N.groupPathPrefix;p.ROLES.ADMIN,p.ROLES.OWNER;const y=()=>{const{searchParams:o}=new URL(window.location.href);return o.get("fromWallet")==="1"};var T={},he=te;Object.defineProperty(T,"__esModule",{value:!0});var H=T.default=void 0,ye=he(ae()),xe=e;H=T.default=(0,ye.default)((0,xe.jsx)("path",{d:"M12 19c0-3.87 3.13-7 7-7 1.08 0 2.09.25 3 .68V6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h8.08c-.05-.33-.08-.66-.08-1M4 6l8 5 8-5v2l-8 5-8-5zm13.34 16-3.54-3.54 1.41-1.41 2.12 2.12 4.24-4.24L23 16.34z"}),"MarkEmailRead");const Ee=ie.form`
2
+ import{u as ee,_ as b,d as $}from"./index-BjauMU9c.js";import{a1 as te,j as e,ac as g,T as w,x as D,aQ as se,a3 as F,M,a2 as ne,aa as ie}from"./vendor-mui-core-BlX2BJoA.js";import{r,u as re}from"./vendor-react-D-afvo_7.js";import{d as p,ad as ae,g as oe,W as ce,z as C,aT as h,P as le,U as ue,S as de,D as fe}from"./vendor-arcblock-CZGLzU01.js";import{i as me}from"./isEmail-BWNRBSAy.js";import{F as pe}from"./fullpage-DTja3SmB.js";import"./vendor-hooks-CLzfFpO7.js";import{f as S}from"./format-error-C0Ke3VXF.js";import{d as ge}from"./CheckCircle-D3sLlO8U.js";import{g as P}from"./get-safe-url-Ddj-Tmsl.js";import"./vendor-utils-DCpRgzMR.js";var N;(N=window.env)!=null&&N.groupPathPrefix;p.ROLES.ADMIN,p.ROLES.OWNER;const y=()=>{const{searchParams:o}=new URL(window.location.href);return o.get("fromWallet")==="1"};var R={},he=te;Object.defineProperty(R,"__esModule",{value:!0});var H=R.default=void 0,ye=he(ae()),xe=e;H=R.default=(0,ye.default)((0,xe.jsx)("path",{d:"M12 19c0-3.87 3.13-7 7-7 1.08 0 2.09.25 3 .68V6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h8.08c-.05-.33-.08-.66-.08-1M4 6l8 5 8-5v2l-8 5-8-5zm13.34 16-3.54-3.54 1.41-1.41 2.12 2.12 4.24-4.24L23 16.34z"}),"MarkEmailRead");const Ee=ie.form`
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  align-items: center;
@@ -15,4 +15,4 @@ import{u as ee,_ as b,d as $}from"./index-wG4Kh8A_.js";import{a1 as te,j as e,ac
15
15
  div.Mui-focused input {
16
16
  caret-color: ${o=>o.theme.palette.primary.main};
17
17
  }
18
- `,ve=o=>{try{if(!o)return null;const a=fe.fromBase64(o).toString();return me(a)?a:null}catch{return null}};function Re(){var B,W;const o=r.useRef(null),{session:a,connectApi:I}=ee(),{t:s,locale:d}=oe(),[x,L]=r.useState(((B=a.user)==null?void 0:B.email)||""),[c,A]=r.useState(""),[E,_]=r.useState(!1),[U,q]=r.useState(!1),[u,G]=r.useState(!1),[Y,K]=r.useState(!1),[v,Q]=r.useState(!1),{wallet:f}=ce(),[l]=re(),O=l.get("inviter")||localStorage.getItem("inviter"),m=l.get("updateKyc")==="1";r.useEffect(()=>{const n=l.get("subject"),t=ve(n);t&&L(t)},[]),r.useEffect(()=>{var n;(n=a.user)!=null&&n.emailVerified&&m&&(K(!0),setTimeout(()=>{if(f&&y()){b(()=>import("./index-DVYdq7IA.js").then(t=>t.i),__vite__mapDeps([0,1])).then(t=>{t.call("arcClosePage")});return}window.location.href=R(l.get("redirect")||"/")},1e3))},[a.user,m,f,l]);const J=r.useCallback(async n=>{var t;n.preventDefault(),_(!0);try{await $.post(`/kyc/email/send?locale=${d}`,{email:x}),G(!0),C.success(s("login.issueKyc.codeSentSuccess"))}catch(i){C.error(S(i)),(t=document.getElementById("email-input"))==null||t.focus()}finally{_(!1)}},[x,d,s]),k=r.useCallback(async n=>{var t;n&&n.preventDefault(),_(!0);try{await $.post(`/kyc/email/verify?locale=${d}`,{code:c}),K(!0),I.open({locale:d,action:"issue-kyc",extraParams:{code:c,updateKyc:l.get("updateKyc")||"0",inviter:O||""},containerEl:o.current,className:"connect",popup:!1,saveConnect:!1,forceConnected:!0,messages:{title:s("login.issueKyc.claim"),scan:s("login.issueKyc.scan"),confirm:s("login.issueKyc.confirm"),success:s("login.issueKyc.success")},useSocket:!0,onSuccess:()=>{Q(!0),I.close(),m?(a.refresh({showProgress:!1,forceRefreshToken:!0}),setTimeout(()=>{if(f&&y()){b(()=>import("./index-DVYdq7IA.js").then(i=>i.i),__vite__mapDeps([0,1])).then(i=>{i.call("arcClosePage")});return}window.location.href=R(l.get("redirect")||"/")},1e3)):f&&y()&&b(()=>import("./index-DVYdq7IA.js").then(i=>i.i),__vite__mapDeps([0,1])).then(i=>{i.call("arcClosePage")})},onError:i=>{C.error(S(i))}})}catch(i){K(!1),C.error(S(i)),(t=document.getElementById(`code-input-${h(c).length-1}`))==null||t.focus()}finally{_(!1)}},[c,d,l,m,f,O]);r.useEffect(()=>{u&&h(c).length===p.VERIFY_CODE_LENGTH&&k()},[c,k,u]);const X=r.useCallback(()=>{q(!0),I.open({locale:d,action:"update-kyc",containerEl:o.current,className:"connect",popup:!1,saveConnect:!1,forceConnected:!0,messages:{title:s("login.updateKyc.title"),scan:s("login.updateKyc.scan"),confirm:s("login.updateKyc.confirm"),success:s("login.updateKyc.success")},useSocket:!0,onSuccess:()=>{a.refresh({showProgress:!1,forceRefreshToken:!0}),setTimeout(()=>{if(f&&y()){b(()=>import("./index-DVYdq7IA.js").then(n=>n.i),__vite__mapDeps([0,1])).then(n=>{n.call("arcClosePage")});return}window.location.href=R(l.get("redirect")||"/")},2e3)},onError:n=>{C.error(S(n))}})},[d,l,f]),D=r.useCallback(n=>{if(!u)return;n.preventDefault();const t=h(n.clipboardData.getData("text/plain").slice(0,p.VERIFY_CODE_LENGTH));if(!/^\d+$/.test(t))return;A(t.padEnd(p.VERIFY_CODE_LENGTH," "));const i=document.getElementById(`code-input-${t.length}`);i&&i.focus()},[u]);r.useEffect(()=>(document.addEventListener("paste",D),()=>{document.removeEventListener("paste",D)}),[D]);const V=y()?s("login.issueKyc.issueTitle"):s("login.issueKyc.verifyTitle"),Z=y()?s("login.issueKyc.issueAction"):s("login.issueKyc.verifyAction");return e.jsxs(pe,{did:(W=window.blocklet)==null?void 0:W.appPid,children:[e.jsx(le,{children:e.jsx("title",{children:V})}),e.jsxs(g,{direction:"column",justifyContent:"center",alignItems:"center",sx:{width:"560px",px:2,boxSizing:"border-box",maxWidth:"100%",height:"100%"},children:[e.jsxs(g,{spacing:1,justifyContent:"center",alignItems:"center",sx:{mb:3},children:[v?e.jsx(ge,{sx:{fontSize:72},color:"success"}):e.jsx(H,{sx:{fontSize:72},color:"primary"}),e.jsx(w,{variant:"h5",sx:{textAlign:"center"},children:V}),!v&&e.jsx(w,{variant:"body2",color:"text.secondary",sx:{textAlign:"center"},children:s("login.issueKyc.pageDescription")}),v&&e.jsx(w,{variant:"body1",sx:{textAlign:"center"},children:s("login.issueKyc.success")}),v&&e.jsx(P,{variant:"contained",color:"primary",component:se,href:"/",size:"large",children:s("login.issueKyc.backToHome")}),!v&&a.user&&e.jsxs(g,{direction:"column",justifyContent:"center",alignItems:"center",children:[e.jsx(w,{variant:"body2",color:"info.main",sx:{textAlign:"center",mt:1},children:s("login.issueKyc.issueTarget",{action:Z})}),e.jsxs(g,{direction:"row",justifyContent:"center",alignItems:"center",spacing:1,sx:{width:"100%",maxWidth:360},children:[e.jsx(ue,{did:a.user.did,responsive:!0,copyable:!0,showQrcode:!1}),e.jsx(de,{locale:d,session:a,showRole:!0,showManageBlocklet:!1})]})]})]}),e.jsx(F,{ref:o,sx:{width:"100%"},children:!Y&&!U&&e.jsxs(Ee,{onSubmit:u?k:J,children:[!u&&e.jsx(M,{type:"email",id:"email-input",placeholder:s("login.issueKyc.emailPlaceholder"),sx:{width:"100%",maxWidth:360},value:x,onChange:n=>L(n.target.value),disabled:E,required:!0}),u&&e.jsxs(g,{direction:"column",justifyContent:"center",alignItems:"center",spacing:2,children:[e.jsx(w,{variant:"body2",textAlign:"center",children:s("login.issueKyc.codeSentMessage",{email:x})}),e.jsx(F,{sx:{width:"100%",maxWidth:360,display:"flex",justifyContent:"space-between"},children:[...Array(p.VERIFY_CODE_LENGTH)].map((n,t)=>e.jsx(M,{value:h(c[t])||"",type:"number",inputProps:{maxLength:1,style:{textAlign:"center",fontSize:"1.5rem"},autoComplete:"off"},sx:{width:"14%"},onChange:i=>{var z;const j=c.split("");j[t]=i.target.value,A(j.join("")),i.target.value&&t<5&&((z=document.getElementById(`code-input-${t+1}`))==null||z.focus())},onKeyDown:i=>{var j;i.key==="Backspace"&&!h(c[t])&&t>0&&((j=document.getElementById(`code-input-${t-1}`))==null||j.focus())},disabled:E,required:!0,id:`code-input-${t}`,autoComplete:"off"},`code-input-${t}`))})]}),e.jsxs(g,{direction:"row",justifyContent:m?"space-between":"center",alignItems:"center",spacing:2,sx:{width:"100%",maxWidth:360},children:[m&&e.jsx(P,{variant:"text",disabled:E,onClick:X,size:"large",children:s("login.updateKyc.button")}),e.jsx(P,{type:"submit",size:"large",variant:"contained",disabled:E||!x||u&&h(c).length!==p.VERIFY_CODE_LENGTH,sx:{width:m?"auto":"100%"},children:E?e.jsx(ne,{size:24}):s(u?"login.issueKyc.verifyButton":"login.issueKyc.sendCodeButton")})]})]})})]})]})}export{Re as default};
18
+ `,ve=o=>{try{if(!o)return null;const a=fe.fromBase64(o).toString();return me(a)?a:null}catch{return null}};function Pe(){var B,W;const o=r.useRef(null),{session:a,connectApi:I}=ee(),{t:s,locale:d}=oe(),[x,L]=r.useState(((B=a.user)==null?void 0:B.email)||""),[c,A]=r.useState(""),[E,_]=r.useState(!1),[U,q]=r.useState(!1),[u,G]=r.useState(!1),[Y,K]=r.useState(!1),[v,Q]=r.useState(!1),{wallet:f}=ce(),[l]=re(),O=l.get("inviter")||localStorage.getItem("inviter"),m=l.get("updateKyc")==="1";r.useEffect(()=>{const n=l.get("subject"),t=ve(n);t&&L(t)},[]),r.useEffect(()=>{var n;(n=a.user)!=null&&n.emailVerified&&m&&(K(!0),setTimeout(()=>{if(f&&y()){b(()=>import("./index-DVYdq7IA.js").then(t=>t.i),__vite__mapDeps([0,1])).then(t=>{t.call("arcClosePage")});return}window.location.href=P(l.get("redirect")||"/")},1e3))},[a.user,m,f,l]);const J=r.useCallback(async n=>{var t;n.preventDefault(),_(!0);try{await $.post(`/kyc/email/send?locale=${d}`,{email:x}),G(!0),C.success(s("login.issueKyc.codeSentSuccess"))}catch(i){C.error(S(i)),(t=document.getElementById("email-input"))==null||t.focus()}finally{_(!1)}},[x,d,s]),k=r.useCallback(async n=>{var t;n&&n.preventDefault(),_(!0);try{await $.post(`/kyc/email/verify?locale=${d}`,{code:c}),K(!0),I.open({locale:d,action:"issue-kyc",extraParams:{code:c,updateKyc:l.get("updateKyc")||"0",inviter:O||""},containerEl:o.current,className:"connect",popup:!1,saveConnect:!1,forceConnected:!0,messages:{title:s("login.issueKyc.claim"),scan:s("login.issueKyc.scan"),confirm:s("login.issueKyc.confirm"),success:s("login.issueKyc.success")},useSocket:!0,onSuccess:()=>{Q(!0),I.close(),m?(a.refresh({showProgress:!1,forceRefreshToken:!0}),setTimeout(()=>{if(f&&y()){b(()=>import("./index-DVYdq7IA.js").then(i=>i.i),__vite__mapDeps([0,1])).then(i=>{i.call("arcClosePage")});return}window.location.href=P(l.get("redirect")||"/")},1e3)):f&&y()&&b(()=>import("./index-DVYdq7IA.js").then(i=>i.i),__vite__mapDeps([0,1])).then(i=>{i.call("arcClosePage")})},onError:i=>{C.error(S(i))}})}catch(i){K(!1),C.error(S(i)),(t=document.getElementById(`code-input-${h(c).length-1}`))==null||t.focus()}finally{_(!1)}},[c,d,l,m,f,O]);r.useEffect(()=>{u&&h(c).length===p.VERIFY_CODE_LENGTH&&k()},[c,k,u]);const X=r.useCallback(()=>{q(!0),I.open({locale:d,action:"update-kyc",containerEl:o.current,className:"connect",popup:!1,saveConnect:!1,forceConnected:!0,messages:{title:s("login.updateKyc.title"),scan:s("login.updateKyc.scan"),confirm:s("login.updateKyc.confirm"),success:s("login.updateKyc.success")},useSocket:!0,onSuccess:()=>{a.refresh({showProgress:!1,forceRefreshToken:!0}),setTimeout(()=>{if(f&&y()){b(()=>import("./index-DVYdq7IA.js").then(n=>n.i),__vite__mapDeps([0,1])).then(n=>{n.call("arcClosePage")});return}window.location.href=P(l.get("redirect")||"/")},2e3)},onError:n=>{C.error(S(n))}})},[d,l,f]),T=r.useCallback(n=>{if(!u)return;n.preventDefault();const t=h(n.clipboardData.getData("text/plain").slice(0,p.VERIFY_CODE_LENGTH));if(!/^\d+$/.test(t))return;A(t.padEnd(p.VERIFY_CODE_LENGTH," "));const i=document.getElementById(`code-input-${t.length}`);i&&i.focus()},[u]);r.useEffect(()=>(document.addEventListener("paste",T),()=>{document.removeEventListener("paste",T)}),[T]);const V=y()?s("login.issueKyc.issueTitle"):s("login.issueKyc.verifyTitle"),Z=y()?s("login.issueKyc.issueAction"):s("login.issueKyc.verifyAction");return e.jsxs(pe,{did:(W=window.blocklet)==null?void 0:W.appPid,children:[e.jsx(le,{children:e.jsx("title",{children:V})}),e.jsxs(g,{direction:"column",justifyContent:"center",alignItems:"center",sx:{width:"560px",px:2,boxSizing:"border-box",maxWidth:"100%",height:"100%"},children:[e.jsxs(g,{spacing:1,justifyContent:"center",alignItems:"center",sx:{mb:3},children:[v?e.jsx(ge,{sx:{fontSize:72},color:"success"}):e.jsx(H,{sx:{fontSize:72},color:"primary"}),e.jsx(w,{variant:"h5",sx:{textAlign:"center"},children:V}),!v&&e.jsx(w,{variant:"body2",color:"text.secondary",sx:{textAlign:"center"},children:s("login.issueKyc.pageDescription")}),v&&e.jsx(w,{variant:"body1",sx:{textAlign:"center"},children:s("login.issueKyc.success")}),v&&e.jsx(D,{variant:"contained",color:"primary",component:se,href:"/",size:"large",children:s("login.issueKyc.backToHome")}),!v&&a.user&&e.jsxs(g,{direction:"column",justifyContent:"center",alignItems:"center",children:[e.jsx(w,{variant:"body2",color:"info.main",sx:{textAlign:"center",mt:1},children:s("login.issueKyc.issueTarget",{action:Z})}),e.jsxs(g,{direction:"row",justifyContent:"center",alignItems:"center",spacing:1,sx:{width:"100%",maxWidth:360},children:[e.jsx(ue,{did:a.user.did,responsive:!0,copyable:!0,showQrcode:!1}),e.jsx(de,{locale:d,session:a,showRole:!0,showManageBlocklet:!1})]})]})]}),e.jsx(F,{ref:o,sx:{width:"100%"},children:!Y&&!U&&e.jsxs(Ee,{onSubmit:u?k:J,children:[!u&&e.jsx(M,{type:"email",id:"email-input",placeholder:s("login.issueKyc.emailPlaceholder"),sx:{width:"100%",maxWidth:360},value:x,onChange:n=>L(n.target.value),disabled:E,required:!0}),u&&e.jsxs(g,{direction:"column",justifyContent:"center",alignItems:"center",spacing:2,children:[e.jsx(w,{variant:"body2",textAlign:"center",children:s("login.issueKyc.codeSentMessage",{email:x})}),e.jsx(F,{sx:{width:"100%",maxWidth:360,display:"flex",justifyContent:"space-between"},children:[...Array(p.VERIFY_CODE_LENGTH)].map((n,t)=>e.jsx(M,{value:h(c[t])||"",type:"number",inputProps:{maxLength:1,style:{textAlign:"center",fontSize:"1.5rem"},autoComplete:"off"},sx:{width:"14%"},onChange:i=>{var z;const j=c.split("");j[t]=i.target.value,A(j.join("")),i.target.value&&t<5&&((z=document.getElementById(`code-input-${t+1}`))==null||z.focus())},onKeyDown:i=>{var j;i.key==="Backspace"&&!h(c[t])&&t>0&&((j=document.getElementById(`code-input-${t-1}`))==null||j.focus())},disabled:E,required:!0,id:`code-input-${t}`,autoComplete:"off"},`code-input-${t}`))})]}),e.jsxs(g,{direction:"row",justifyContent:m?"space-between":"center",alignItems:"center",spacing:2,sx:{width:"100%",maxWidth:360},children:[m&&e.jsx(D,{variant:"text",disabled:E,onClick:X,size:"large",children:s("login.updateKyc.button")}),e.jsx(D,{type:"submit",size:"large",variant:"contained",disabled:E||!x||u&&h(c).length!==p.VERIFY_CODE_LENGTH,sx:{width:m?"auto":"100%"},children:E?e.jsx(ne,{size:24}):s(u?"login.issueKyc.verifyButton":"login.issueKyc.sendCodeButton")})]})]})})]})]})}export{Pe as default};