import{i as e,A as t,y as n,d as o,a as r,q as i,T as l,D as a,_ as s,b as c,u,k as d,f,c as m,e as p,g as h,h as g,j as y,l as v,m as w,n as b,S as x,o as E,C as R,$ as T,P as O,p as L,r as _,s as C,t as P,v as D,w as A,x as M,F as z,z as k,B as S,E as I,G as F,H as N}from"./chunk.common_BmX2zUFb.esm.js";const j=Math.min,H=Math.max,V=Math.round,B=Math.floor,W=e=>({x:e,y:e}),q={left:"right",right:"left",bottom:"top",top:"bottom"},$={start:"end",end:"start"};function U(e,t,n){return H(e,j(t,n))}function X(e,t){return"function"==typeof e?e(t):e}function Y(e){return e.split("-")[0]}function Z(e){return e.split("-")[1]}function G(e){return"x"===e?"y":"x"}function J(e){return"y"===e?"height":"width"}function K(e){return["top","bottom"].includes(Y(e))?"y":"x"}function Q(e){return G(K(e))}function ee(e){return e.replace(/start|end/g,(e=>$[e]))}function te(e){return e.replace(/left|right|bottom|top/g,(e=>q[e]))}function ne(e){return"number"!=typeof e?function(e){return{top:0,right:0,bottom:0,left:0,...e}}(e):{top:e,right:e,bottom:e,left:e}}function oe(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function re(e,t,n){let{reference:o,floating:r}=e;const i=K(t),l=Q(t),a=J(l),s=Y(t),c="y"===i,u=o.x+o.width/2-r.width/2,d=o.y+o.height/2-r.height/2,f=o[a]/2-r[a]/2;let m;switch(s){case"top":m={x:u,y:o.y-r.height};break;case"bottom":m={x:u,y:o.y+o.height};break;case"right":m={x:o.x+o.width,y:d};break;case"left":m={x:o.x-r.width,y:d};break;default:m={x:o.x,y:o.y}}switch(Z(t)){case"start":m[l]-=f*(n&&c?-1:1);break;case"end":m[l]+=f*(n&&c?-1:1)}return m}async function ie(e,t){var n;void 0===t&&(t={});const{x:o,y:r,platform:i,rects:l,elements:a,strategy:s}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:m=0}=X(t,e),p=ne(m),h=a[f?"floating"===d?"reference":"floating":d],g=oe(await i.getClippingRect({element:null==(n=await(null==i.isElement?void 0:i.isElement(h)))||n?h:h.contextElement||await(null==i.getDocumentElement?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:s})),y="floating"===d?{x:o,y:r,width:l.floating.width,height:l.floating.height}:l.reference,v=await(null==i.getOffsetParent?void 0:i.getOffsetParent(a.floating)),w=await(null==i.isElement?void 0:i.isElement(v))&&await(null==i.getScale?void 0:i.getScale(v))||{x:1,y:1},b=oe(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:v,strategy:s}):y);return{top:(g.top-b.top+p.top)/w.y,bottom:(b.bottom-g.bottom+p.bottom)/w.y,left:(g.left-b.left+p.left)/w.x,right:(b.right-g.right+p.right)/w.x}}function le(){return"undefined"!=typeof window}function ae(e){return ue(e)?(e.nodeName||"").toLowerCase():"#document"}function se(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function ce(e){var t;return null==(t=(ue(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function ue(e){return!!le()&&(e instanceof Node||e instanceof se(e).Node)}function de(e){return!!le()&&(e instanceof Element||e instanceof se(e).Element)}function fe(e){return!!le()&&(e instanceof HTMLElement||e instanceof se(e).HTMLElement)}function me(e){return!(!le()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof se(e).ShadowRoot)}function pe(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=be(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!["inline","contents"].includes(r)}function he(e){return["table","td","th"].includes(ae(e))}function ge(e){return[":popover-open",":modal"].some((t=>{try{return e.matches(t)}catch(e){return!1}}))}function ye(e){const t=ve(),n=de(e)?be(e):e;return["transform","translate","scale","rotate","perspective"].some((e=>!!n[e]&&"none"!==n[e]))||!!n.containerType&&"normal"!==n.containerType||!t&&!!n.backdropFilter&&"none"!==n.backdropFilter||!t&&!!n.filter&&"none"!==n.filter||["transform","translate","scale","rotate","perspective","filter"].some((e=>(n.willChange||"").includes(e)))||["paint","layout","strict","content"].some((e=>(n.contain||"").includes(e)))}function ve(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function we(e){return["html","body","#document"].includes(ae(e))}function be(e){return se(e).getComputedStyle(e)}function xe(e){return de(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ee(e){if("html"===ae(e))return e;const t=e.assignedSlot||e.parentNode||me(e)&&e.host||ce(e);return me(t)?t.host:t}function Re(e){const t=Ee(e);return we(t)?e.ownerDocument?e.ownerDocument.body:e.body:fe(t)&&pe(t)?t:Re(t)}function Te(e,t,n){var o;void 0===t&&(t=[]),void 0===n&&(n=!0);const r=Re(e),i=r===(null==(o=e.ownerDocument)?void 0:o.body),l=se(r);if(i){const e=Oe(l);return t.concat(l,l.visualViewport||[],pe(r)?r:[],e&&n?Te(e):[])}return t.concat(r,Te(r,[],n))}function Oe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Le(e){const t=be(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=fe(e),i=r?e.offsetWidth:n,l=r?e.offsetHeight:o,a=V(n)!==i||V(o)!==l;return a&&(n=i,o=l),{width:n,height:o,$:a}}function _e(e){return de(e)?e:e.contextElement}function Ce(e){const t=_e(e);if(!fe(t))return W(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:i}=Le(t);let l=(i?V(n.width):n.width)/o,a=(i?V(n.height):n.height)/r;return l&&Number.isFinite(l)||(l=1),a&&Number.isFinite(a)||(a=1),{x:l,y:a}}const Pe=W(0);function De(e){const t=se(e);return ve()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:Pe}function Ae(e,t,n,o){void 0===t&&(t=!1),void 0===n&&(n=!1);const r=e.getBoundingClientRect(),i=_e(e);let l=W(1);t&&(o?de(o)&&(l=Ce(o)):l=Ce(e));const a=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==se(e))&&t}(i,n,o)?De(i):W(0);let s=(r.left+a.x)/l.x,c=(r.top+a.y)/l.y,u=r.width/l.x,d=r.height/l.y;if(i){const e=se(i),t=o&&de(o)?se(o):o;let n=e,r=Oe(n);for(;r&&o&&t!==n;){const e=Ce(r),t=r.getBoundingClientRect(),o=be(r),i=t.left+(r.clientLeft+parseFloat(o.paddingLeft))*e.x,l=t.top+(r.clientTop+parseFloat(o.paddingTop))*e.y;s*=e.x,c*=e.y,u*=e.x,d*=e.y,s+=i,c+=l,n=se(r),r=Oe(n)}}return oe({width:u,height:d,x:s,y:c})}function Me(e,t){const n=xe(e).scrollLeft;return t?t.left+n:Ae(ce(e)).left+n}function ze(e,t,n){void 0===n&&(n=!1);const o=e.getBoundingClientRect();return{x:o.left+t.scrollLeft-(n?0:Me(e,o)),y:o.top+t.scrollTop}}function ke(e,t,n){let o;if("viewport"===t)o=function(e,t){const n=se(e),o=ce(e),r=n.visualViewport;let i=o.clientWidth,l=o.clientHeight,a=0,s=0;if(r){i=r.width,l=r.height;const e=ve();(!e||e&&"fixed"===t)&&(a=r.offsetLeft,s=r.offsetTop)}return{width:i,height:l,x:a,y:s}}(e,n);else if("document"===t)o=function(e){const t=ce(e),n=xe(e),o=e.ownerDocument.body,r=H(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=H(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let l=-n.scrollLeft+Me(e);const a=-n.scrollTop;return"rtl"===be(o).direction&&(l+=H(t.clientWidth,o.clientWidth)-r),{width:r,height:i,x:l,y:a}}(ce(e));else if(de(t))o=function(e,t){const n=Ae(e,!0,"fixed"===t),o=n.top+e.clientTop,r=n.left+e.clientLeft,i=fe(e)?Ce(e):W(1);return{width:e.clientWidth*i.x,height:e.clientHeight*i.y,x:r*i.x,y:o*i.y}}(t,n);else{const n=De(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return oe(o)}function Se(e,t){const n=Ee(e);return!(n===t||!de(n)||we(n))&&("fixed"===be(n).position||Se(n,t))}function Ie(e,t,n){const o=fe(t),r=ce(t),i="fixed"===n,l=Ae(e,!0,i,t);let a={scrollLeft:0,scrollTop:0};const s=W(0);if(o||!o&&!i)if(("body"!==ae(t)||pe(r))&&(a=xe(t)),o){const e=Ae(t,!0,i,t);s.x=e.x+t.clientLeft,s.y=e.y+t.clientTop}else r&&(s.x=Me(r));const c=!r||o||i?W(0):ze(r,a);return{x:l.left+a.scrollLeft-s.x-c.x,y:l.top+a.scrollTop-s.y-c.y,width:l.width,height:l.height}}function Fe(e){return"static"===be(e).position}function Ne(e,t){if(!fe(e)||"fixed"===be(e).position)return null;if(t)return t(e);let n=e.offsetParent;return ce(e)===n&&(n=n.ownerDocument.body),n}function je(e,t){const n=se(e);if(ge(e))return n;if(!fe(e)){let t=Ee(e);for(;t&&!we(t);){if(de(t)&&!Fe(t))return t;t=Ee(t)}return n}let o=Ne(e,t);for(;o&&he(o)&&Fe(o);)o=Ne(o,t);return o&&we(o)&&Fe(o)&&!ye(o)?n:o||function(e){let t=Ee(e);for(;fe(t)&&!we(t);){if(ye(t))return t;if(ge(t))return null;t=Ee(t)}return null}(e)||n}const He={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const i="fixed"===r,l=ce(o),a=!!t&&ge(t.floating);if(o===l||a&&i)return n;let s={scrollLeft:0,scrollTop:0},c=W(1);const u=W(0),d=fe(o);if((d||!d&&!i)&&(("body"!==ae(o)||pe(l))&&(s=xe(o)),fe(o))){const e=Ae(o);c=Ce(o),u.x=e.x+o.clientLeft,u.y=e.y+o.clientTop}const f=!l||d||i?W(0):ze(l,s,!0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-s.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-s.scrollTop*c.y+u.y+f.y}},getDocumentElement:ce,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[..."clippingAncestors"===n?ge(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let o=Te(e,[],!1).filter((e=>de(e)&&"body"!==ae(e))),r=null;const i="fixed"===be(e).position;let l=i?Ee(e):e;for(;de(l)&&!we(l);){const t=be(l),n=ye(l);n||"fixed"!==t.position||(r=null),(i?!n&&!r:!n&&"static"===t.position&&r&&["absolute","fixed"].includes(r.position)||pe(l)&&!n&&Se(e,l))?o=o.filter((e=>e!==l)):r=t,l=Ee(l)}return t.set(e,o),o}(t,this._c):[].concat(n),o],l=i[0],a=i.reduce(((e,n)=>{const o=ke(t,n,r);return e.top=H(o.top,e.top),e.right=j(o.right,e.right),e.bottom=j(o.bottom,e.bottom),e.left=H(o.left,e.left),e}),ke(t,l,r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:je,getElementRects:async function(e){const t=this.getOffsetParent||je,n=this.getDimensions,o=await n(e.floating);return{reference:Ie(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){const{width:t,height:n}=Le(e);return{width:t,height:n}},getScale:Ce,isElement:de,isRTL:function(e){return"rtl"===be(e).direction}};function Ve(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Be(e,t,n,o){void 0===o&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:s=!1}=o,c=_e(e),u=r||i?[...c?Te(c):[],...Te(t)]:[];u.forEach((e=>{r&&e.addEventListener("scroll",n,{passive:!0}),i&&e.addEventListener("resize",n)}));const d=c&&a?function(e,t){let n,o=null;const r=ce(e);function i(){var e;clearTimeout(n),null==(e=o)||e.disconnect(),o=null}return function l(a,s){void 0===a&&(a=!1),void 0===s&&(s=1),i();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:m}=c;if(a||t(),!f||!m)return;const p={rootMargin:-B(d)+"px "+-B(r.clientWidth-(u+f))+"px "+-B(r.clientHeight-(d+m))+"px "+-B(u)+"px",threshold:H(0,j(1,s))||1};let h=!0;function g(t){const o=t[0].intersectionRatio;if(o!==s){if(!h)return l();o?l(!1,o):n=setTimeout((()=>{l(!1,1e-7)}),1e3)}1!==o||Ve(c,e.getBoundingClientRect())||l(),h=!1}try{o=new IntersectionObserver(g,{...p,root:r.ownerDocument})}catch(e){o=new IntersectionObserver(g,p)}o.observe(e)}(!0),i}(c,n):null;let f,m=-1,p=null;l&&(p=new ResizeObserver((e=>{let[o]=e;o&&o.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame((()=>{var e;null==(e=p)||e.observe(t)}))),n()})),c&&!s&&p.observe(c),p.observe(t));let h=s?Ae(e):null;return s&&function t(){const o=Ae(e);h&&!Ve(h,o)&&n();h=o,f=requestAnimationFrame(t)}(),n(),()=>{var e;u.forEach((e=>{r&&e.removeEventListener("scroll",n),i&&e.removeEventListener("resize",n)})),null==d||d(),null==(e=p)||e.disconnect(),p=null,s&&cancelAnimationFrame(f)}}const We=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:i,placement:l,middlewareData:a}=t,s=await async function(e,t){const{placement:n,platform:o,elements:r}=e,i=await(null==o.isRTL?void 0:o.isRTL(r.floating)),l=Y(n),a=Z(n),s="y"===K(n),c=["left","top"].includes(l)?-1:1,u=i&&s?-1:1,d=X(t,e);let{mainAxis:f,crossAxis:m,alignmentAxis:p}="number"==typeof d?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return a&&"number"==typeof p&&(m="end"===a?-1*p:p),s?{x:m*u,y:f*c}:{x:f*c,y:m*u}}(t,e);return l===(null==(n=a.offset)?void 0:n.placement)&&null!=(o=a.arrow)&&o.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:l}}}}},qe=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r}=t,{mainAxis:i=!0,crossAxis:l=!1,limiter:a={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...s}=X(e,t),c={x:n,y:o},u=await ie(t,s),d=K(Y(r)),f=G(d);let m=c[f],p=c[d];if(i){const e="y"===f?"bottom":"right";m=U(m+u["y"===f?"top":"left"],m,m-u[e])}if(l){const e="y"===d?"bottom":"right";p=U(p+u["y"===d?"top":"left"],p,p-u[e])}const h=a.fn({...t,[f]:m,[d]:p});return{...h,data:{x:h.x-n,y:h.y-o}}}}},$e=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:i,rects:l,initialPlacement:a,platform:s,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:h=!0,...g}=X(e,t);if(null!=(n=i.arrow)&&n.alignmentOffset)return{};const y=Y(r),v=K(a),w=Y(a)===a,b=await(null==s.isRTL?void 0:s.isRTL(c.floating)),x=f||(w||!h?[te(a)]:function(e){const t=te(e);return[ee(e),t,ee(t)]}(a)),E="none"!==p;!f&&E&&x.push(...function(e,t,n,o){const r=Z(e);let i=function(e,t,n){const o=["left","right"],r=["right","left"],i=["top","bottom"],l=["bottom","top"];switch(e){case"top":case"bottom":return n?t?r:o:t?o:r;case"left":case"right":return t?i:l;default:return[]}}(Y(e),"start"===n,o);return r&&(i=i.map((e=>e+"-"+r)),t&&(i=i.concat(i.map(ee)))),i}(a,h,p,b));const R=[a,...x],T=await ie(t,g),O=[];let L=(null==(o=i.flip)?void 0:o.overflows)||[];if(u&&O.push(T[y]),d){const e=function(e,t,n){void 0===n&&(n=!1);const o=Z(e),r=Q(e),i=J(r);let l="x"===r?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return t.reference[i]>t.floating[i]&&(l=te(l)),[l,te(l)]}(r,l,b);O.push(T[e[0]],T[e[1]])}if(L=[...L,{placement:r,overflows:O}],!O.every((e=>e<=0))){var _,C;const e=((null==(_=i.flip)?void 0:_.index)||0)+1,t=R[e];if(t)return{data:{index:e,overflows:L},reset:{placement:t}};let n=null==(C=L.filter((e=>e.overflows[0]<=0)).sort(((e,t)=>e.overflows[1]-t.overflows[1]))[0])?void 0:C.placement;if(!n)switch(m){case"bestFit":{var P;const e=null==(P=L.filter((e=>{if(E){const t=K(e.placement);return t===v||"y"===t}return!0})).map((e=>[e.placement,e.overflows.filter((e=>e>0)).reduce(((e,t)=>e+t),0)])).sort(((e,t)=>e[1]-t[1]))[0])?void 0:P[0];e&&(n=e);break}case"initialPlacement":n=a}if(r!==n)return{reset:{placement:n}}}return{}}}},Ue=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:i,platform:l,elements:a,middlewareData:s}=t,{element:c,padding:u=0}=X(e,t)||{};if(null==c)return{};const d=ne(u),f={x:n,y:o},m=Q(r),p=J(m),h=await l.getDimensions(c),g="y"===m,y=g?"top":"left",v=g?"bottom":"right",w=g?"clientHeight":"clientWidth",b=i.reference[p]+i.reference[m]-f[m]-i.floating[p],x=f[m]-i.reference[m],E=await(null==l.getOffsetParent?void 0:l.getOffsetParent(c));let R=E?E[w]:0;R&&await(null==l.isElement?void 0:l.isElement(E))||(R=a.floating[w]||i.floating[p]);const T=b/2-x/2,O=R/2-h[p]/2-1,L=j(d[y],O),_=j(d[v],O),C=L,P=R-h[p]-_,D=R/2-h[p]/2+T,A=U(C,D,P),M=!s.arrow&&null!=Z(r)&&D!==A&&i.reference[p]/2-(D{const o=new Map,r={platform:He,...n},i={...r.platform,_c:o};return(async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:l}=n,a=i.filter(Boolean),s=await(null==l.isRTL?void 0:l.isRTL(t));let c=await l.getElementRects({reference:e,floating:t,strategy:r}),{x:u,y:d}=re(c,o,s),f=o,m={},p=0;for(let n=0;n{o.current=e})),o}const Je=a(((e,n)=>{var{as:o="div",children:r,disabled:i=!1}=e,l=s(e,["as","children","disabled"]);const a=t(null),p=t(null),h=t(null);c((()=>{var e;i||null===(e=a.current)||void 0===e||e.focus()}),[i]);const g=e=>{const t=a.current;if(!t||i)return;((e?f(t):m(t))||t).focus()},y=i?-1:0,v="absolute -m-px h-px w-px overflow-hidden whitespace-nowrap p-0";return u(d,{children:[u("div",{className:v,ref:p,onFocus:()=>g(!1),tabIndex:y}),u(o,Object.assign({},l,{ref:e=>{a.current=e,"function"==typeof n?n(e):n&&(n.current=e)},tabIndex:-1,children:r})),u("div",{className:v,ref:h,onFocus:()=>g(!0),tabIndex:y})]})})),Ke=["right","left","bottom","top"],Qe=({anchorTo:a,children:s,headerTitle:c,hideHeader:d=!1,disableMinWidth:f=!1,key:m,modalTitle:L="Sign in with Shop",onDismiss:_,onModalInViewport:C,popupDisabled:P,type:D,variant:A,visible:M})=>{var z,k,S;const{dispatch:I,modalDismissible:F}=p(),{translate:N}=h(),j=t(null),[H,V]=o(null),B=t(null),W=t(null),q=t(null),[$,U]=o(!1),{instanceId:X}=g(),Y=t(null),{floatingStyles:Z,middlewareData:G,refs:J,update:K}=function(e={}){const{placement:a="bottom",strategy:s="absolute",middleware:c=[],platform:u,elements:{reference:d,floating:f}={},transform:m=!0,whileElementsMounted:p,open:h}=e,[g,y]=o({x:0,y:0,strategy:s,placement:a,middlewareData:{},isPositioned:!1}),[v,w]=o(c);r(v,c)||w(c);const[b,x]=o(null),[E,R]=o(null),T=i((e=>{e!==C.current&&(C.current=e,x(e))}),[]),O=i((e=>{e!==P.current&&(P.current=e,R(e))}),[]),L=d||b,_=f||E,C=t(null),P=t(null),D=t(g),A=null!=p,M=Ge(p),z=Ge(u),k=i((()=>{if(!C.current||!P.current)return;const e={placement:a,strategy:s,middleware:v};z.current&&(e.platform=z.current),Xe(C.current,P.current,e).then((e=>{const t=Object.assign(Object.assign({},e),{isPositioned:!0});S.current&&!r(D.current,t)&&(D.current=t,y(t))})).catch((e=>{console.error("error caught during computePosition",e)}))}),[v,a,s,z]);n((()=>{!1===h&&D.current.isPositioned&&(D.current.isPositioned=!1,y((e=>Object.assign(Object.assign({},e),{isPositioned:!1}))))}),[h]);const S=t(!1);n((()=>(S.current=!0,()=>{S.current=!1})),[]),n((()=>{if(L&&(C.current=L),_&&(P.current=_),L&&_){if(M.current)return M.current(L,_,k);k()}}),[L,_,k,M,A]);const I=l((()=>({reference:C,floating:P,setReference:T,setFloating:O})),[T,O]),F=l((()=>({reference:L,floating:_})),[L,_]),N=l((()=>{const e={position:s,left:0,top:0};if(!F.floating)return e;const t=Ze(F.floating,g.x),n=Ze(F.floating,g.y);return m?Object.assign(Object.assign(Object.assign({},e),{transform:`translate(${t}px, ${n}px)`}),Ye(F.floating)>=1.5&&{willChange:"transform"}):{position:s,left:t,top:n}}),[s,m,F.floating,g.x,g.y]);return l((()=>Object.assign(Object.assign({},g),{update:k,refs:I,elements:F,floatingStyles:N})),[g,k,I,F,N])}({middleware:[$e({crossAxis:!1,fallbackPlacements:Ke.slice(1)}),qe({padding:30}),We(30),(Q={element:B,padding:28},{name:"arrow",options:Q,fn(e){const{element:t,padding:n}=Q;return t&&(o=t,{}.hasOwnProperty.call(o,"current"))?null!=t.current?Ue({element:t.current,padding:n}).fn(e):{}:t?Ue({element:t,padding:n}).fn(e):{};var o}})],placement:Ke[0],whileElementsMounted:Be});var Q;n((()=>{if(a){let e;e="string"==typeof a?y.querySelector(a):a.current,V(e),J.setReference(e),K()}}),[a,J,K]),null===Y.current&&(Y.current=y.documentElement.style.overflow),!W.current&&v()&&(W.current=new IntersectionObserver((t=>{for(const n of t){n.boundingClientRect.top<0&&e.scrollTo({top:0,left:0}),n.isIntersecting&&(null==C||C())}}))),!j.current&&v()&&(j.current=new IntersectionObserver((t=>{var n;for(const o of t){if(o.boundingClientRect.top<0&&e.scrollTo({top:0,left:0}),!o.isIntersecting&&o.target.offsetTop){const t=((null==H?void 0:H.offsetHeight)||0)+((null===(n=q.current)||void 0===n?void 0:n.offsetHeight)||0)/2+30;e.scrollTo({top:o.target.offsetTop-t})}}}))),n((()=>()=>{W.current&&W.current.disconnect(),j.current&&j.current.disconnect()}),[]);const{isDesktop:ee}=w(),te=l((()=>H&&!P&&ee?"dynamic":"center"),[H,ee,P]);n((()=>{const e=y.documentElement,t=null==e?void 0:e.style.overflow;return()=>{t&&e?e.style.overflow=t:e.style.removeProperty("overflow")}}),[]);const ne=i((e=>{F&&(_(e),y.documentElement.style.overflow=Y.current||"")}),[F,_]);n((()=>{function t({key:e}){"Escape"!==e&&"Esc"!==e||ne("keyboard")}return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}}),[ne]),n((()=>{M?(y.documentElement.style.overflow="hidden",W.current&&q.current&&W.current.observe(q.current),j.current&&H&&j.current.observe(H)):(W.current&&q.current&&W.current.unobserve(q.current),j.current&&H&&j.current.unobserve(H),y.documentElement.style.overflow=Y.current||"")}),[H,ne,M]),n((()=>{var e;if(!M)return void U(!1);const t=()=>{U(!0)};return null===(e=q.current)||void 0===e||e.addEventListener("transitionend",t,{once:!0}),()=>{var e;null===(e=q.current)||void 0===e||e.removeEventListener("transitionend",t)}}),[M]),n((()=>{if(M){const e=setTimeout((()=>{I({type:"modalDismissible"})}),400);return()=>{clearTimeout(e)}}}),[I,M]);const oe=b("fixed inset-0 z-10 bg-overlay transition-opacity duration-400 ease-cubic-modal motion-reduce_duration-0",M?"opacity-100":"opacity-0"),re=b("fixed inset-0 z-max overflow-hidden","center"===te&&"flex items-center justify-center",M?"visible":"pointer-events-none invisible"),ie=b("relative z-50 bg-white transition duration-400 ease-cubic-modal will-change-transform focus_outline-0 motion-reduce_duration-0 sm_absolute sm_inset-x-0 sm_bottom-0 sm_top-auto sm_rounded-b-none",M?"opacity-100 sm_translate-y-0":"opacity-0 sm_translate-y-full","dynamic"===te&&M?"scale-100":"","dynamic"!==te||M?"":"scale-0 sm_scale-100",!f&&("wide"===D?"min-w-100":"min-w-85"),!d&&"rounded-lg"),le=b("relative overflow-hidden sm_rounded-b-none",!d&&"rounded-lg"),ae=l((()=>{var e,t,n,o,r,i,l,a;if("center"===te)return null;const s={right:{top:null===(e=G.arrow)||void 0===e?void 0:e.y,left:(null===(t=G.arrow)||void 0===t?void 0:t.x)||"-10px"},left:{top:null===(n=G.arrow)||void 0===n?void 0:n.y,right:(null===(o=G.arrow)||void 0===o?void 0:o.x)||"-10px"},bottom:{top:"-10px",left:(null===(r=G.arrow)||void 0===r?void 0:r.x)||"-10px"},top:{bottom:"-10px",left:(null===(i=G.arrow)||void 0===i?void 0:i.x)||"-10px"}},c=Ke[(null===(a=null===(l=G.flip)||void 0===l?void 0:l.overflows)||void 0===a?void 0:a.length)||0],d=s[c],f=b("absolute z-30 block size-6 rotate-45 rounded-xs duration-400 ease-cubic-modal sm_hidden","top"===c?"bg-grayscale-l4":"bg-white");return u("div",{className:f,"data-testid":"authorize-modal-arrow",ref:B,style:d})}),[null===(z=G.arrow)||void 0===z?void 0:z.x,null===(k=G.arrow)||void 0===k?void 0:k.y,null===(S=G.flip)||void 0===S?void 0:S.overflows,te]),se=Boolean(c),ce=se?u(x,{className:"size-8 text-purple-primary"}):u(E,{className:"h-4-5 text-purple-primary"}),ue=b("flex w-full items-center justify-between p-4 pb-2",se&&"mb-5 gap-x-4 border-b border-solid border-grayscale-l2l px-5 pb-4"),de="dynamic"===te?Z:void 0,fe=d?null:u("div",{className:ue,"data-testid":"authorize-modal-header","data-variant":se?"with-title":"default",children:[ce,se&&u("div",{className:"flex-1 font-sans text-body-large",children:c}),u("button",{"aria-label":N("button.close",{defaultValue:"Close"}),className:"group relative z-50 flex size-6 cursor-pointer rounded-max","data-testid":"authorize-modal-close-button",onClick:()=>ne("close_button"),type:"button",children:[u(R,{className:"size-6 text-grayscale-l4 transition-colors group-hover_text-grayscale-l2l"}),u("div",{className:"absolute inset-05 -z-10 rounded-max bg-grayscale-primary-light"})]})]}),me=M?{}:{"aria-hidden":!0};return T(u(O,{instanceId:X,type:"modal",variant:A,children:u("div",{className:re,"data-testid":"authorize-modal-container","data-variant":D,children:[u("div",Object.assign({},me,{className:oe,"data-testid":"authorize-modal-overlay",onClick:()=>ne("overlay")})),u(Je,Object.assign({as:"section",disabled:!$,"aria-modal":"true"},me,{"aria-label":L,className:ie,"data-testid":"authorize-modal","data-visible":M,part:"modal",ref:e=>{q.current=e,H&&(J.setFloating(e),K())},role:"dialog",style:de,children:[u("div",{className:le,children:[fe,s]}),ae]}))]})},m),y.body)},et=()=>u(d,{children:[u("div",{class:"animate-pulse px-4 py-1 pb-6","data-testid":"loading-skeleton",children:[u("div",{class:"flex items-center pb-3",children:[u("div",{class:"mr-3 size-6 rounded-max bg-grayscale-l2"}),u("div",{class:"mr-20 h-3 flex-1 rounded-md bg-grayscale-l2"})]}),u("div",{class:"h-10 rounded-md bg-grayscale-l2"})]}),u("div",{class:"h-10 animate-pulse bg-grayscale-l3"})]}),tt=({children:e})=>{const{uiRendered:t}=p();return u(d,{children:[!t&&u(et,{}),u("div",{children:e})]})},nt=["api_unavailable","captcha_challenge","retriable_server_error"],ot=[/existing customer \d+ on shop \d+ has a conflicting provider subject associated: existing '([^']+)' != incoming '([^']+)'/,/no_prequalification_amount_available/];const rt=a((({activator:e,allowAttribute:o,anchorTo:r,autoOpen:l,disableDefaultIframeResizing:a=!1,insideModal:s=!0,keepModalOpen:c=!1,modalHeaderTitle:d,modalHeaderVisible:f=!0,onComplete:m,onCustomFlowSideEffect:h,onError:g,onLoaded:v,onModalVisibleChange:w,onResizeIframe:b,onPromptChange:x,onPromptContinue:E,proxy:R,scrolling:T,src:O,storefrontOrigin:j,modalType:H,variant:V},B)=>{const{dispatch:W,loaded:q,modalVisible:$}=p(),{leaveBreadcrumb:U,notify:X}=L(),Y=_(),{clearLoadTimeout:Z,initLoadTimeout:G}=C(),{trackPageImpression:J}=P(),{recordCounter:K}=D(),Q=t(null),ee=A($),te=i((e=>{W({type:"showModal",reason:e})}),[W]),ne=i((({dismissMethod:t,reason:n})=>{$&&(W({type:"hideModal",reason:n,dismissMethod:t}),(null==e?void 0:e.current)&&it(e)&&e.current.focus())}),[e,W,$]);n((()=>{const t=N((function(){te("user_button_clicked")}),150,!0),n=e;if((null==n?void 0:n.current)&&it(n))return n.current.addEventListener("click",t),()=>{var e;null===(e=n.current)||void 0===e||e.removeEventListener("click",t)}}),[e,te]);const oe=i((()=>{k({iframe:Q.current,src:O})}),[O]),{destroy:re,waitForMessage:ie}=M({includeCore:R,onClose:()=>ne({dismissMethod:"auto",reason:"event_close_requested"}),onComplete:e=>S(void 0,void 0,void 0,(function*(){!c&&s&&ne({dismissMethod:"auto",reason:"event_completed"}),yield null==m?void 0:m(e)})),onCustomFlowSideEffect:h,onError:e=>{const{message:t,code:n}=e;!function(e,t){return!(nt.includes(e)||ot.some((e=>e.test(t))))}(n,t)?(K("shop_js_handle_silent_error",{attributes:{errorCode:n}}),U("silent error",{code:n},"state")):(U("authorize error",{code:n,message:t},"state"),X(new I(t,"AuthorizeError"))),Z(),null==g||g(e)},onLoaded:e=>{W({type:"loaded",payload:{autoOpen:Boolean(l),sessionDetected:e.userFound}}),null==v||v(e),Z()},onUnloaded:()=>{W({type:"reset"})},onResizeIframe:e=>{a||Q.current&&(Q.current.style.height=`${e.height}px`),e.height>0&&W({type:"uiRendered"}),null==b||b(e)},onShopUserMatched:()=>{Y("shopusermatched"),U("shop user matched",{},"state")},onShopUserNotMatched:({apiError:e})=>{Y("shopusernotmatched",e&&{apiError:e}),U("shop user not matched",{},"state")},onPromptChange:()=>{null==x||x()},onPromptContinue:()=>{null==E||E()},source:Q,storefrontOrigin:j});n((()=>()=>{Q.current&&re()}),[re]);const le=i(((e,...t)=>S(void 0,[e,...t],void 0,(function*(e,{afterLoaded:t=!1}={}){var n;t&&!q&&(yield ie("loaded")),F({contentWindow:null===(n=Q.current)||void 0===n?void 0:n.contentWindow,event:e})}))),[q,ie]);n((()=>{var e;if($!==ee)if($){try{le({type:"sheetmodalopened"},{afterLoaded:!0}),Y("modalopened")}catch(e){X(new Error(`Error before calling onModalVisibleChange(true): ${e}`))}null==w||w(!0)}else le({type:"sheetmodalclosed"},{afterLoaded:!0}),Y("modalclosed"),null==w||w(!1),null===(e=y.querySelector("com-1password-notification"))||void 0===e||e.remove()}),[Y,$,X,w,le,ee]),z(B,(()=>({close:ne,iframeRef:Q,open:te,postMessage:le,reload:oe,waitForMessage:ie})),[ne,te,le,oe,ie]),n((()=>{G(),U("Iframe url updated",{src:O},"state")}),[G,U,O]),n((()=>{$&&J({page:"AUTHORIZE_MODAL"})}),[$,J]),n((()=>{k({iframe:Q.current,src:O})}),[O]);const ae=u("iframe",{allow:o||"publickey-credentials-get *",className:"relative z-40 m-auto w-full border-none",ref:e=>{e&&(Q.current=e,e.getAttribute("src")||e.setAttribute("src",O))},tabIndex:0,scrolling:T,"data-testid":"authorize-iframe"});return s?u(Qe,{anchorTo:r,headerTitle:d,hideHeader:!f,onDismiss:e=>ne({dismissMethod:e,reason:"user_dismissed"}),onModalInViewport:()=>{J({page:"AUTHORIZE_MODAL_IN_VIEWPORT",allowDuplicates:!0}),U("modal in viewport",{},"state")},type:H,variant:V,visible:$,children:u(tt,{children:ae})}):ae}));function it(e){return Object.prototype.hasOwnProperty.call(e,"current")}rt.displayName="AuthorizeIframe";export{rt as A,Qe as M}; //# sourceMappingURL=chunk.modal_Djw5vGxd.esm.js.map