import{al as p,a7 as g,qb as k,qc as A,dS as m,jF as q,fe as I,bZ as l,j5 as E,ia as u,qd as y,d2 as R,aq as _}from"./app.ZXowmuNl.js";const M=()=>window.self!==window.top,N=6e4;function z({enabled:e,onTimeout:n,timeout:s=N}){const o=p(null),t=p(n);t.current=n,g(()=>{if(e)return o.current=setTimeout(()=>t.current(s),s),()=>{o.current&&clearTimeout(o.current)}},[e,s])}function F(){const[e]=k(),[n]=A(),{shippingRequired:s}=m(),[o]=q(),[t]=I(),i=!!o?.requiresVerification,r=l(()=>o?!t.some(d=>E(d.address,o.address)):!1,[o,t]);return(!s||i||r)&&(n==="email"||!e)}const O=()=>{const n=new URL(window.location.href).pathname.match(/checkout\/([^/]+)\/spe/)?.[1];if(!n)return;const s=parseInt(n,10);if(!isNaN(s))return s},P="stored-session-token",V="pay-session-token",w=({persistence:e,html:n,shopPay:s})=>{const o=O(),t=n.getSerialization(V),i={scope:()=>({shopPaySessionTokenKey:o})},r=t===P?void 0:t,S=u.ShopPaySessionToken,c=()=>e?.get(u.ShopPaySessionToken,i),d=()=>s.sessionToken||c(),h=e?.createUpdate(u.ShopPaySessionToken,i)||(()=>{}),f=a=>{s.updateSessionToken(a),a?h(a):e?.remove(S,i)},T=()=>{r&&f(r)};return{get:d,set:f,load:()=>{T(),s.updateSessionToken(c())}}},L=()=>{const e=p(!1),n=y(),s=l(()=>w(n),[n]),{sessionToken:o}=R();return e.current||(s.load(),e.current=!0),[o,s.set]},K=[3890849,3850711,5198245];function x(){const e=_("api-client-id");return e?K.includes(e):!1}export{z as a,F as b,x as c,O as g,M as i,L as u};