@safe-stars/components
Version:
React component library for buying Telegram Stars in Telegram Mini Apps via Safe Stars.
66 lines (59 loc) • 4.77 kB
JavaScript
;const e=require("./index-CtZaCMo8.cjs"),c=require("./if-defined-MmHKu2JE.cjs");function f(){try{return e.CoreHelperUtil.returnOpenHref(`${e.ConstantsUtil$1.SECURE_SITE_SDK_ORIGIN}/loading`,"popupWindow","width=600,height=800,scrollbars=yes")}catch{throw new Error("Could not open social popup")}}async function h(){e.RouterController.push("ConnectingFarcaster");const o=e.ConnectorController.getAuthConnector();if(o&&!e.AccountController.state.farcasterUrl)try{const{url:r}=await o.provider.getFarcasterUri();e.AccountController.setFarcasterUrl(r,e.ChainController.state.activeChain)}catch(r){e.RouterController.goBack(),e.SnackController.showError(r)}}async function w(o){e.RouterController.push("ConnectingSocial");const r=e.ConnectorController.getAuthConnector();let t=null;try{const n=setTimeout(()=>{throw new Error("Social login timed out. Please try again.")},45e3);if(r&&o){if(e.CoreHelperUtil.isTelegram()||(t=f()),t)e.AccountController.setSocialWindow(t,e.ChainController.state.activeChain);else if(!e.CoreHelperUtil.isTelegram())throw new Error("Could not create social popup");const{uri:l}=await r.provider.getSocialRedirectUri({provider:o});if(!l)throw t==null||t.close(),new Error("Could not fetch the social redirect uri");if(t&&(t.location.href=l),e.CoreHelperUtil.isTelegram()){e.StorageUtil.setTelegramSocialProvider(o);const i=e.CoreHelperUtil.formatTelegramSocialLoginUrl(l);e.CoreHelperUtil.openHref(i,"_top")}clearTimeout(n)}}catch(n){t==null||t.close(),e.SnackController.showError(n==null?void 0:n.message)}}async function C(o){e.AccountController.setSocialProvider(o,e.ChainController.state.activeChain),e.EventsController.sendEvent({type:"track",event:"SOCIAL_LOGIN_STARTED",properties:{provider:o}}),o==="farcaster"?await h():await w(o)}const v=e.i`
:host {
display: flex;
justify-content: center;
align-items: center;
width: 40px;
height: 40px;
border-radius: var(--wui-border-radius-3xl);
border: 1px solid var(--wui-color-gray-glass-005);
overflow: hidden;
}
wui-icon {
width: 100%;
height: 100%;
}
`;var p=function(o,r,t,n){var l=arguments.length,i=l<3?r:n===null?n=Object.getOwnPropertyDescriptor(r,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(o,r,t,n);else for(var u=o.length-1;u>=0;u--)(a=o[u])&&(i=(l<3?a(i):l>3?a(r,t,i):a(r,t))||i);return l>3&&i&&Object.defineProperty(r,t,i),i};let d=class extends e.i$1{constructor(){super(...arguments),this.logo="google"}render(){return e.x`<wui-icon color="inherit" size="inherit" name=${this.logo}></wui-icon> `}};d.styles=[e.resetStyles,v];p([c.n()],d.prototype,"logo",void 0);d=p([c.customElement("wui-logo")],d);const y=e.i`
button {
column-gap: var(--wui-spacing-s);
padding: 7px var(--wui-spacing-l) 7px var(--wui-spacing-xs);
width: 100%;
justify-content: flex-start;
background-color: var(--wui-color-gray-glass-002);
border-radius: var(--wui-border-radius-xs);
color: var(--wui-color-fg-100);
}
wui-text {
text-transform: capitalize;
}
wui-text[data-align='left'] {
display: flex;
flex: 1;
}
wui-text[data-align='center'] {
display: flex;
flex: 1;
justify-content: center;
}
.invisible {
opacity: 0;
pointer-events: none;
}
button:disabled {
background-color: var(--wui-color-gray-glass-015);
color: var(--wui-color-gray-glass-015);
}
`;var g=function(o,r,t,n){var l=arguments.length,i=l<3?r:n===null?n=Object.getOwnPropertyDescriptor(r,t):n,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(o,r,t,n);else for(var u=o.length-1;u>=0;u--)(a=o[u])&&(i=(l<3?a(i):l>3?a(r,t,i):a(r,t))||i);return l>3&&i&&Object.defineProperty(r,t,i),i};let s=class extends e.i$1{constructor(){super(...arguments),this.logo="google",this.name="Continue with google",this.align="left",this.disabled=!1}render(){return e.x`
<button ?disabled=${this.disabled} tabindex=${c.o(this.tabIdx)}>
<wui-logo logo=${this.logo}></wui-logo>
<wui-text
data-align=${this.align}
variant="paragraph-500"
color="inherit"
align=${this.align}
>${this.name}</wui-text
>
${this.templatePlacement()}
</button>
`}templatePlacement(){return this.align==="center"?e.x` <wui-logo class="invisible" logo=${this.logo}></wui-logo>`:null}};s.styles=[e.resetStyles,e.elementStyles,y];g([c.n()],s.prototype,"logo",void 0);g([c.n()],s.prototype,"name",void 0);g([c.n()],s.prototype,"align",void 0);g([c.n()],s.prototype,"tabIdx",void 0);g([c.n({type:Boolean})],s.prototype,"disabled",void 0);s=g([c.customElement("wui-list-social")],s);exports.executeSocialLogin=C;
//# sourceMappingURL=index-DDoNK4iu.cjs.map