1import{u as R,_ as D,a as j}from"./BKiaIFs4.js";import{G as B,z as J,aT as L,N as G,as as u,ak as l,I as e,al as a,ax as i,aG as Y,aK as z,i as T,ao as v,aw as H,am as K,aF as Q,aC as W,e as c,r as X,y as Z}from"./BjTTogN2.js";import{a as ee}from"./BuHMDiBE.js";import{m as te}from"./DtsFtUoh.js";import{a as oe,i as ne}from"./6uq7J8du.js";import"./tn3b78NZ.js";import"./DyfadX0W.js";import"./Cjc_RYEd.js";const ae={class:"complete-signup-page"},se={key:0,class:"complete-signup-panel"},ie={key:0,class:"form-group"},re={for:"complete-signup-name"},ue={key:1,class:"alert alert-danger"},le=["disabled"],ce={key:0,class:"fa fa-spinner fa-spin"},pe={key:1,class:"complete-signup-panel"},de=B({__name:"complete-signup",setup(me){const{$translate:o,$store:w}=J(),s=L(),b=Z(),p=ee.useSession(),{termsAccepted:y,termsError:q,completeSignupError:S,isCompletingSignup:x,collectNameValue:d,oauthNamePrefill:_,resetCompleteSignupForm:$,submitCompleteSignup:E}=R(),{handleSignupExpired:P}=j();oe({title:o("Almost There!")});const r=c(()=>String(s.query.shopId||"")),h=c(()=>String(s.query.returnUrl||"")),C=c(()=>s.query.widgetMode==="1"),I=c(()=>String(s.query.parentOrigin||"")),N=c(()=>String(s.query.userName||"").trim()),m=X(!1),k=c(()=>!_.value&&!N.value),A=c(()=>k.value?o("Please enter your name and accept the Johku terms and conditions to finish creating your account."):o("Please accept the Johku terms and conditions to finish creating your account."));G(async()=>{if(await p.value?.refetch(),!p.value?.data?.session?.token){m.value=!0;return}const t=N.value;t?d.value=t:_.value&&(d.value=_.value)});const V=async()=>{await $fetch("/api/auth/backend-sync",{method:"POST",headers:{"x-johku-shop-id":r.value},body:{shopId:r.value}});const t=window.location.hostname===b.public.authDomain,n=w.locale||String(s.query.locale||"fi_FI"),g=te(n);if(t&&h.value){if(!p.value?.data?.session?.token)throw new Error("Missing session");const U=await $fetch("/api/auth/create-bridge-token",{method:"POST",body:{shopId:r.value}});window.location.href=`${h.value}/api/auth/bridge?token=${encodeURIComponent(U.bridgeToken)}&redirect=${encodeURIComponent(g)}`;return}window.location.href=g},F=async()=>{await $fetch("/api/auth/backend-sync",{method:"POST",headers:{"x-johku-shop-id":r.value},body:{shopId:r.value}});const t=p.value?.data?.session?.token,n=p.value?.data?.user;if(!t||!window.opener)throw new Error("Missing widget session");window.opener.postMessage({type:"johku-widget-auth",shopId:r.value,sessionToken:t,userName:n?.name?.trim()||"",userEmail:n?.email?.trim()||""},I.value),window.close()},M=async()=>{await E({requireName:k.value,onExpired:async()=>{m.value=!0},onSuccess:async()=>{if(C.value){await F();return}await V()}})},O=async()=>{await P(()=>{if($(),m.value=!1,C.value){const t=new URLSearchParams({shopId:r.value,parentOrigin:I.value,storefrontUrl:window.location.origin,locale:w.locale||String(s.query.locale||"fi_FI")});window.location.href=`https://${b.public.authDomain}/widget-auth?${t.toString()}`;return}if(h.value){const t=w.locale||String(s.query.locale||"fi_FI");window.location.href=`${h.value}/${t}/`}})};return(t,n)=>{const g=D;return u(),l("div",ae,[e(m)?v("",!0):(u(),l("div",se,[a("h1",null,i(e(o)("Almost There!")),1),a("p",null,i(e(A)),1),a("form",{onSubmit:W(M,["prevent"])},[e(k)?(u(),l("div",ie,[a("label",re,i(e(o)("Your name")),1),Y(a("input",{id:"complete-signup-name","onUpdate:modelValue":n[0]||(n[0]=f=>T(d)?d.value=f:null),type:"text",class:"form-control",required:"",autocomplete:"name"},null,512),[[z,e(d)]])])):v("",!0),H(g,{modelValue:e(y),"onUpdate:modelValue":n[1]||(n[1]=f=>T(y)?y.value=f:null),"input-id":"complete-signup-terms-checkbox",error:e(q)},null,8,["modelValue","error"]),e(S)?(u(),l("div",ue,i(e(S)),1)):v("",!0),a("button",{type:"submit",class:"btn btn-success btn-block",disabled:e(x)},[e(x)?(u(),l("i",ce)):(u(),l(K,{key:1},[Q(i(e(o)("Create Account")),1)],64))],8,le)],32)])),e(m)?(u(),l("div",pe,[a("h1",null,i(e(o)("Complete your account")),1),a("p",null,i(e(o)("Your signup session has expired. Please sign in again to create your account.")),1),a("button",{type:"button",class:"btn btn-success btn-block",onClick:O}
1,i(e(o)("Sign in again")),1)])):v("",!0)])}}}),be=ne(de,[["__scopeId","data-v-58dcc4f1"]]);export{be as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.