
@php

if(!session('auth_redirect_url') || (session('auth_redirect_url') && session('disable_auth_redirect_overwrite' , 0) == 0 )){
        if(request()->headers->get('referer')){
            $url = request()->headers->get('referer');
            $domain = explode('/',str_replace(['https://','http://'],'',url()->current()))[0];
            if(!\Illuminate\Support\Str::contains($url,$domain)){
                $url = url()->full();
            }
            session(['auth_redirect_url' => $url, 'disable_auth_redirect_overwrite' => 0 ]);
        }else{
            $url = url()->full();
            session(['auth_redirect_url' => $url, 'disable_auth_redirect_overwrite' => 0]);
        }
}

session(['auth_redirect_current' => url()->current() ]);

$iframe_url = ecom('url')->prefix().'/account/auth';

if(session('login') && request()->input('complete_profile') == 1){
    $iframe_url = route('complete-profile');
}

@endphp

<iframe id="twa_auth_iframe" style="width: 100%;"
        onload="TWA_resizeIframe(this)"
        scrolling="no"
        src="{{$iframe_url}}"  name="iframe_a" title="Login"></iframe>

<script>
    function TWA_resizeIframe(elem) {

            var Height = elem.contentWindow.document.body.offsetHeight;
            var scrollHeight = elem.contentWindow.document.body.scrollHeight;

            if(Height < scrollHeight){ Height = scrollHeight; }

            // Add some space for recaptsha box
            Height += 200;

            elem.style.height = Height + 'px';
            $(elem).contents().find('input[autofocus]').focus();
    }

</script>

