"use strict";const f=require("./FetchConfigsUtils-c73b687c.js"),k=require("./useUserInfo-dc3105ae.js"),e=require("react"),y=require("@accelbyte/sdk-iam"),u=require("./Alert-ccfa7db1.js"),E=require("./CommonError-c282a0a2.js"),m=require("./Alert-dec85153.js"),g=require("./ProfileImage-5c51b03f.js"),A=require("@accelbyte/sdk"),s=require("react-i18next"),l=require("./Button-44f4db23.js"),p=require("./Dialog-5110afb8.js"),N=require("./i18n-478e3048.js"),h=require("./useDiscoveryConfigs-367fb38f.js"),D=({children:o})=>{const{state:{user:n,userFetchStatus:t}}=k.useUserInfo(),{state:r}=k.useHistory(),[a]=f.useSdk();return e.useEffect(()=>{if(!n&&t!==f.FetchStatus.FETCHING){const c=new y.IamUserAuthorizationClient(a).createLoginURL(r.location.pathname);window.location.replace(c)}},[]),e.createElement(e.Fragment,null,o)},P=o=>{const{error:n,accountConflictInformation:t,onDismiss:r}=o;if((t==null?void 0:t.errorCode)===A.ERROR_LINK_ANOTHER_3RD_PARTY_ACCOUNT&&(t!=null&&t.previousLinkedPlatformAccount)){const{platformID:a,platformUserID:c,platformDisplayName:i}=t.previousLinkedPlatformAccount,d=g.UserHelper.getPlatformName(a);return e.createElement(u.Alert,{className:"mb-6",type:m.AlertType.danger,onDismiss:r},e.createElement(s.Trans,{i18nKey:"LinkedAccountpage.cannotLinkWithAnotherAccount"},"Unable to link this ",{platformName:d}," account. Please link the ",{platformName:d}," account previously linked to this account :"," ",{platformDisplayName:i}," ( ",{platformUserID:c}," )."))}if(t){const a=g.UserHelper.getPlatformName(t.platformId);return e.createElement(u.Alert,{className:"mb-6",type:m.AlertType.danger,onDismiss:r},e.createElement(s.Trans,{i18nKey:"LinkedAccountPage.linkConflictError"},"That ",{platformName:a}," account has already been linked with another account.",e.createElement("br",null)," Please contact support for assistance linking it with a different account."))}return n?e.createElement(u.Alert,{type:m.AlertType.danger,className:"alert",onDismiss:r},e.createElement(E.CommonError,{error:n})):null};const T=({onCancel:o,onConfirm:n,platformId:t})=>{var i;const{state:r}=h.useDiscoveryConfigs(),a=g.UserHelper.getPlatformName(t),c=((i=r.discoveryConfigData)==null?void 0:i.brandName.data.value)||"";return e.createElement(p.Dialog,{className:"purchaseDialog",title:N.t("LinkedAccountPage.confirmUnlinkDialog.title"),isOpen:!0},e.createElement(p.DialogBody,null,e.createElement("p",{className:"dialogPlatformBodyText"},e.createElement(s.Trans,{i18nKey:"LinkedAccountPage.confirmUnlinkDialog.unlinkConfirm"},"Do you want to unlink your ",e.createElement("span",{className:"capitalize"},{platformName:a})," account from",{publisherName:c},"?"))),e.createElement(p.DialogFooter,null,e.createElement("div",{className:"flex justify-end"},e.createElement(l.Button,{className:"btn btn-ghost mr-2 uppercase",buttonType:l.ButtonType.TEXT,buttonStyle:l.ButtonStyle.NONE,onClick:()=>{o&&o()}},e.createElement(s.Trans,{i18nKey:"LinkAccountPage.cancel"},"Cancel")),e.createElement(l.Button,{className:"btn btn-primary uppercase",onClick:()=>{n&&n()}},e.createElement(s.Trans,{i18nKey:"LinkAccountPage.unlink"},"Unlink")))))};exports.LinkedAccountsErrorAlert=P;exports.PrivateWidget=D;exports.UnlinkAccountConfirmDialog=T;
