import{o as m,aL as V,aM as E,U as I,Y as k,a2 as T,A as C,y as g,aN as b,aO as B,aP as J,aQ as O,k as w,a as t,aR as z,aS as A,B as H,Q as M,aT as N}from"./app.B46ok1sD.js";import{H as U}from"./ShopPayCaptcha.CTSuxniV.js";let L=!1;function x(){const p=m(),a=V(),c=a.value,o=E(),{captcha:s}=I(),e=s.value,[h,l]=k(e?.sitekey),{negotiate:d}=T(),r=C(null),[i,f]=k(L),[v]=k(!!e?.token),y=p("captcha.errors.not_solved");g(()=>{e?e?.sitekey&&l(e.sitekey):l(void 0)},[e]),g(()=>{const n=o.type==="error"?o.violations.map(P=>P.code):[];e&&e.violationCode&&n.includes(e.violationCode)?(r?.current?.resetCaptcha(),a.value=y):e?.token&&(a.value=void 0)},[e,a,y,o,r]);const R=n=>{e&&(s.value={...e,token:n,violationCode:void 0},d({progression:!1,include:["captcha"],skipStateUpdates:!0}))};b(s,a,n=>{if(n&&!n.token)return y},B.InvalidCaptcha);const u=C(null),S=J({active:!!c});return g(()=>{e&&i&&u.current&&(S.current=u.current.querySelector("iframe"))},[e,u,i,S]),{captcha:e,sitekey:h,error:c,handleVerify:R,handleLoad:()=>{L=!0,f(!0)},isLoaded:i,captchaRef:r,captchaContainerRef:u,solvedOnLoad:v}}const D={Error:"MTtRU"};function Y(){const{locale:p}=O().i18n,a=m(),c=w("worker-version")!=="fast",{captcha:o,sitekey:s,error:e,handleVerify:h,handleLoad:l,isLoaded:d,captchaRef:r,captchaContainerRef:i,solvedOnLoad:f}=x(),v=f&&!o?.sitekey;return!o||o.provider!=="hcaptcha"||v||!s?null:t("div",{children:[d?null:t(z,{delay:c,contentDisplay:"block",inlineSize:302,blockSize:83}),t(A,{accessibilityLabel:a("captcha.title"),display:d?void 0:"none",children:t(H,{spacing:"small400",children:[t("div",{className:e&&M(D.Error),ref:i,children:t(U,{sitekey:s,onVerify:h,languageOverride:p,ref:r,onLoad:l})}),e&&t(N,{children:e?.message??e})]})})]})}export{Y as default};