1"use strict";(self.webpackChunkgcom_rhythm=self.webpackChunkgcom_rhythm||[]).push([[1813],{1813(e,t,a){a.d(t,{C:()=>o,checkFrameInCart:()=>s,handlePauseReservation:()=>n});var r=a(5805);async function n(e,t,a){let n,s=[];localStorage.getItem("pauseCartItems")&&(s=JSON.parse(localStorage.getItem("pauseCartItems")));const i=new URLSearchParams(window.location.search).get("frame"),u=await async function(e,t){const a="/a/app/graphql/query",r=document.querySelector('[name="product_id"]').value,n=document.querySelector('[name="id"]').value;let s=await o();s.includes("?key=")&&(s=s.split("?key=")[0]);localStorage.getItem("pauseCartId")!==s&&localStorage.setItem("pauseCartId",s);let i=1;t.length>0&&(i=t[t.length-1].lineId+1);let u="";for(let e=0;e<t.length;e++)u+=`frame${t[e].lineId}:pauseFrameReserve(input: { frameNum: ${t[e].frameNum}, cartId: "${s}", productId: "${t[e].productId}", shopifyVariantId: "${t[e].variantId}" }) {\n duration\n }`;const c={query:`mutation PauseFrameReserve {\n frame${i}:pauseFrameReserve(input: { frameNum: ${e}, cartId: "${s}", productId: "${r}" , shopifyVariantId: "${n}" }) {\n duration\n }\n ${u}\n }`};try{const e=await fetch(a,{headers:{"Content-Type":"application/json"},body:JSON.stringify(c),method:"POST"});if(e.ok&&e.status<400){const t=await e.json();return null!==t.data&&void 0!==t.data&&{duration:t.data["frame"+i].duration}}}catch(e){return!1}}(i,s);if(!1!==u){const e=new Date;e.setSeconds(e.getSeconds()+u.duration),localStorage.setItem("pauseCountdown",e);const a=e.toISOString(),o=JSON.stringify({attributes:{"_pause-expiry-date-time":a}});await fetch(`${routes.cart_update_url}`,{...(0,r.Dz)(),body:o}).then(e=>e.json()).then(e=>{let a=1;s.length>0&&(a=s[s.length-1].lineId+1);const r={lineKey:e.items[0].key,lineId:a,productId:document.querySelector('[name="product_id"]').value,frameNum:i,variantId:t};s.push(r),localStorage.setItem("pauseCartItems",JSON.stringify(s)),n=!0})}else{const t=JSON.stringify({id:e.key,quantity:0});await fetch(`${routes.cart_change_url}`,{...(0,r.Dz)(),body:t}).then(e=>{n=!1}).catch(e=>{n=!1})}if(!1===n){a.has_cart_error=!0,a.handleErrorMessage(window.cartStrings.pauseFrameSoldOutMessage);const e=a.querySelector('[type="submit"]');e.setAttribute("disabled",!0),e.setAttribute("aria-disabled",!0),document.querySelector("main .product__info .product-form__submit .buybutton_label").innerHTML=window.variantStrings.soldOut}else if(!0===n){a.has_cart_error=!1;const e=a.querySelector('[type="submit"]');e.removeAttribute("disabled"),e.removeAttribute("aria-disabled"),e.setAttribute("data-pause-current-state","extend_timer")}return n}async function o(){try{const e=await fetch("/cart.js");if(e.ok){return(await e.json()).token}throw new Error("Something wrongs")}catch(e){}}async function s(e,t){const a=new URLSearchParams(window.location.search).get("frame"),n=document.querySelector('main .product__info [name="product_id"]').value;let o=[];localStorage.getItem("pauseCartItems")&&(o=JSON.parse(localStorage.getItem("pauseCartItems")));let s=!1;for(let t=0;t<o.length;t++)if(o[t].frameNum===a&&o[t].variantId===e&&o[t].productId===n||o[t].frameNum===a&&o[t].variantId!==e&&o[t].productId===n){s=!0;const e=JSON.stringify({id:o[t].lineKey,quantity:0});await fetch(`${routes.cart_change_url}`,{...(0,r.Dz)(),body:e}).then(e=>{!0===e.ok&&(o.splice(t,1),localStorage.setItem("pauseCartItems",JSON.stringify(o)))}).catch(e=>{});break}const i=await async function(e){const t={query:`query getFrameAvailability { \n pauseFrame(productId: "${document.querySelector('[name="product_id"]').value}", shopifyVariantId: "${document.querySelector('[name="id"]').value}", num: ${e} ) {\n available\n soldOut\n } \n }`};try{const e=await fetch("/a/app/graphql/query",{headers:{"Content-Type":"application/json"},body:JSON.stringify(t),method:"POST"});return!!(e.ok&&e.status<400)&&(await e.json()).data.pauseFrame}catch(e){return!1}}(a);let u;return!0===i.soldOut&&(u="sold_out"),!0===i.available&&(u="available"),!1===i.soldOut&&!1===i.available&&(u="reserved"),"sold_out"===u&&!1===s?(t.handleErrorMessage(window.cartStrings.pauseFrameSoldOutMessage),!1):!("reserved"===u&&!1===s||"reserved"===u&&!0===s)||(t.handleErrorMessage(window.cartStrings.pauseFrameUnavailableMessage),!1)}}}]);
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.