{"version":3,"file":"ShopifyCapBuyButton.CHII6pHZ.mjs","names":["useState","useMemo","__esmMin","pe","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","_e","p","c","init_jsx_runtime","ce","init_framer_CN96F41L","addPropertyControls","ControlType","useIsStaticRenderer","storefront","response","endpoint","token","json","money","value","displayText","text","shortTitle","title","ShopifyCatalog","isStatic","products","setProducts","selected","setSelected","cartId","setCartId","checkoutUrl","setCheckoutUrl","cartCount","setCartCount","loading","setLoading","adding","setAdding","error","setError","catalogQuery","next","data","product","v","addToCart","merchandiseId","addLineMutation","createCartMutation","result","displayedProducts","productView","style","variants","activeVariant","productImage","current","event","variant","init_ShopifyCapBuyButton"],"sources":["https:/framerusercontent.com/modules/OPUZ6RF8di0M1no14fkp/Lf8sQN84WfUAbhVxTMck/ShopifyCapBuyButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useMemo,useState}from\"react\";import{useIsStaticRenderer,addPropertyControls,ControlType}from\"framer\";const endpoint=\"https://spmvq9-01.myshopify.com/api/2025-10/graphql.json\";const token=\"167ea655af02c5f205e9214cf45a9875\";async function storefront(query,variables={}){const response=await fetch(endpoint,{method:\"POST\",headers:{\"Content-Type\":\"application/json\",\"X-Shopify-Storefront-Access-Token\":token},body:JSON.stringify({query,variables})});const json=await response.json();if(!response.ok||json.errors)throw new Error(json.errors?.[0]?.message||\"Shopify request failed\");return json.data;}const catalogQuery=`query Catalog {\n  products(first: 50, sortKey: CREATED_AT) {\n    nodes {\n      id title handle availableForSale\n      featuredImage { url altText }\n      priceRange { minVariantPrice { amount currencyCode } }\n      variants(first: 50) { nodes { id title availableForSale price { amount currencyCode } image { url altText } } }\n    }\n  }\n}`;const createCartMutation=`mutation CreateCart($lines: [CartLineInput!]!) {\n  cartCreate(input: { lines: $lines }) { cart { id checkoutUrl totalQuantity } userErrors { message } }\n}`;const addLineMutation=`mutation AddLine($cartId: ID!, $lines: [CartLineInput!]!) {\n  cartLinesAdd(cartId: $cartId, lines: $lines) { cart { id checkoutUrl totalQuantity } userErrors { message } }\n}`;function money(value){return new Intl.NumberFormat(\"en-US\",{style:\"currency\",currency:value.currencyCode}).format(Number(value.amount));}function displayText(text){return text.replace(/[\\u00ad]/g,\"\").replace(/[-\\u2010-\\u2015\\u2212]/g,\" \").replace(/ {2,}/g,\" \");}function shortTitle(title){if(/sticker/i.test(title))return\"MONKE Sticker\";return displayText(title.replace(/^MONKE\\s+/i,\"MONKE \"));}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function ShopifyCatalog({style,productView=\"all\"}){const isStatic=useIsStaticRenderer();const[products,setProducts]=useState([]);const[selected,setSelected]=useState({});const[cartId,setCartId]=useState(\"\");const[checkoutUrl,setCheckoutUrl]=useState(\"\");const[cartCount,setCartCount]=useState(0);const[loading,setLoading]=useState(true);const[adding,setAdding]=useState(\"\");const[error,setError]=useState(\"\");useEffect(()=>{if(isStatic)return;storefront(catalogQuery).then(data=>{const next=data.products.nodes.filter(product=>product.availableForSale);setProducts(next);setSelected(Object.fromEntries(next.map(product=>[product.id,product.variants.nodes.find(v=>v.availableForSale)?.id||\"\"])));}).catch(()=>setError(\"The shop could not load. Please refresh and try again.\")).finally(()=>setLoading(false));},[isStatic]);const addToCart=async product=>{const merchandiseId=selected[product.id];if(!merchandiseId)return;setAdding(product.id);setError(\"\");try{const variables=cartId?{cartId,lines:[{merchandiseId,quantity:1}]}:{lines:[{merchandiseId,quantity:1}]};const data=await storefront(cartId?addLineMutation:createCartMutation,variables);const result=cartId?data.cartLinesAdd:data.cartCreate;if(result.userErrors?.length)throw new Error(result.userErrors[0].message);setCartId(result.cart.id);setCheckoutUrl(result.cart.checkoutUrl);setCartCount(result.cart.totalQuantity);}catch{setError(\"That item could not be added. Please try again.\");}finally{setAdding(\"\");}};const previewProducts=useMemo(()=>isStatic?[{id:\"preview-cap\",title:\"MONKE Local Tourist Garment-Washed Cap\",handle:\"cap\",availableForSale:true,featuredImage:{url:\"https://cdn.shopify.com/s/files/1/0827/6085/9885/files/17940655998526959048_2048.jpg?v=1785978969\"},priceRange:{minVariantPrice:{amount:\"32\",currencyCode:\"USD\"}},variants:{nodes:[]}},{id:\"preview-sticker\",title:\"MONKE Sticker\",handle:\"sticker\",availableForSale:true,featuredImage:{url:\"https://cdn.shopify.com/s/files/1/0827/6085/9885/files/2347757597566801327_1200.jpg?v=1786304867\"},priceRange:{minVariantPrice:{amount:\"4.99\",currencyCode:\"USD\"}},variants:{nodes:[]}}]:products,[isStatic,products]);const displayedProducts=previewProducts.filter(product=>productView!==\"cap\"||/cap/i.test(product.title));return /*#__PURE__*/_jsxs(\"div\",{className:\"monke-storefront\",style:{...style,position:\"relative\",width:\"100%\",height:\"auto\",minHeight:0,fontFamily:\"Inter, Arial, sans-serif\",color:\"#11110E\"},children:[/*#__PURE__*/_jsx(\"style\",{children:`\n            .monke-storefront{container-type:inline-size}\n            .monke-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:24px}\n            .monke-card{display:flex;flex-direction:column;background:#f4f1e8;border:1px solid #b7b1a5;border-radius:12px;overflow:hidden;transition:transform .35s cubic-bezier(.2,.8,.2,1),box-shadow .35s ease}\n            .monke-card:hover{transform:translateY(-5px);box-shadow:0 18px 44px rgba(17,17,14,.13)}\n            .monke-image{flex:none;aspect-ratio:1.18/1;background:#fff;overflow:hidden}\n            .monke-image img{width:100%;height:100%;object-fit:contain;display:block;transition:transform .5s cubic-bezier(.2,.8,.2,1)}\n            .monke-card:hover img{transform:scale(1.025)}\n            .monke-body{flex:1;padding:24px;display:flex;flex-direction:column;gap:17px}\n            .monke-meta{display:flex;justify-content:space-between;gap:18px;align-items:flex-start}\n            .monke-title{margin:0;font-size:24px;line-height:1.08;font-weight:650;letter-spacing:-.025em;flex:1;min-width:0}\n            .monke-price{font-size:17px;white-space:nowrap}\n            .monke-select{width:100%;background:#fff;color:#11110e;border:1px solid #b7b1a5;border-radius:10px;padding:13px 14px;font:500 14px Inter,Arial,sans-serif}\n            .monke-button{margin-top:auto;width:100%;border:0;border-radius:999px;background:#11110e;color:#f4f1e8;padding:15px 18px;font:650 14px Inter,Arial,sans-serif;cursor:pointer;transition:background .22s ease,transform .22s ease}\n            .monke-button:hover{background:#b85c3d}.monke-button:active{transform:scale(.985)}.monke-button:disabled{opacity:.55;cursor:wait}\n            .monke-cart{position:sticky;bottom:18px;margin:22px auto 0;max-width:520px;background:#11110e;color:#f4f1e8;border-radius:999px;padding:12px 13px 12px 20px;display:flex;align-items:center;justify-content:space-between;gap:20px;box-shadow:0 16px 40px rgba(0,0,0,.25);animation:cartin .35s ease both}\n            .monke-checkout{border:0;border-radius:999px;background:#d9a930;color:#11110e;padding:12px 18px;font:700 13px Inter,Arial,sans-serif;cursor:pointer}\n            .monke-single{grid-template-columns:1fr}.monke-single .monke-card{display:grid;grid-template-columns:1.1fr 1fr;align-items:center}\n            .monke-button:focus-visible,.monke-select:focus-visible,.monke-checkout:focus-visible{outline:3px solid #b85c3d;outline-offset:3px}\n            .monke-status{padding:28px 0;text-align:center;font-size:14px}.monke-error{color:#9f3f2a;margin:15px 0;text-align:center;font-size:14px}\n            @keyframes cartin{from{opacity:0;transform:translateY(16px)}to{opacity:1;transform:translateY(0)}}\n            @container(max-width:640px){.monke-grid{grid-template-columns:1fr;gap:18px}.monke-single .monke-card{display:block}.monke-body{padding:19px}.monke-title{font-size:22px}.monke-cart{bottom:10px}}\n            @container(max-width:360px){.monke-meta{flex-direction:column;gap:8px}.monke-title{width:100%}}\n            @media(prefers-reduced-motion:reduce){.monke-card,.monke-image img,.monke-button{transition:none}.monke-card:hover{transform:none}.monke-cart{animation:none}}\n        `}),loading&&!isStatic&&/*#__PURE__*/_jsx(\"div\",{className:\"monke-status\",children:\"Loading the shop…\"}),/*#__PURE__*/_jsx(\"div\",{className:`monke-grid ${productView===\"cap\"?\"monke-single\":\"\"}`,children:displayedProducts.map(product=>{const variants=product.variants.nodes.filter(v=>v.availableForSale);const activeVariant=variants.find(v=>v.id===selected[product.id]);const productImage=activeVariant?.image||product.featuredImage;return /*#__PURE__*/_jsxs(\"article\",{className:\"monke-card\",children:[/*#__PURE__*/_jsx(\"div\",{className:\"monke-image\",children:/*#__PURE__*/_jsx(\"img\",{src:productImage?.url,alt:displayText(productImage?.altText||shortTitle(product.title)),loading:\"lazy\"})}),/*#__PURE__*/_jsxs(\"div\",{className:\"monke-body\",children:[/*#__PURE__*/_jsxs(\"div\",{className:\"monke-meta\",children:[/*#__PURE__*/_jsx(\"h2\",{className:\"monke-title\",children:shortTitle(product.title)}),/*#__PURE__*/_jsx(\"div\",{className:\"monke-price\",children:money(activeVariant?.price||product.priceRange.minVariantPrice)})]}),!isStatic&&variants.length>1&&/*#__PURE__*/_jsx(\"select\",{className:\"monke-select\",\"aria-label\":`Choose options for ${shortTitle(product.title)}`,value:selected[product.id]||\"\",onChange:event=>setSelected(current=>({...current,[product.id]:event.target.value})),children:variants.map(variant=>/*#__PURE__*/_jsxs(\"option\",{value:variant.id,children:[displayText(variant.title),\" / \",money(variant.price)]},variant.id))}),/*#__PURE__*/_jsx(\"button\",{className:\"monke-button\",disabled:isStatic||!!adding||!product.availableForSale,onClick:()=>addToCart(product),children:adding===product.id?\"Adding…\":\"Add to cart\"})]})]},product.id);})}),!loading&&!isStatic&&!error&&displayedProducts.length===0&&/*#__PURE__*/_jsx(\"div\",{className:\"monke-status\",children:\"This item is currently unavailable. Please check back soon.\"}),error&&/*#__PURE__*/_jsx(\"div\",{className:\"monke-error\",role:\"alert\",children:displayText(error)}),cartCount>0&&/*#__PURE__*/_jsxs(\"div\",{className:\"monke-cart\",children:[/*#__PURE__*/_jsxs(\"span\",{children:[cartCount,\" \",cartCount===1?\"item\":\"items\",\" in cart\"]}),/*#__PURE__*/_jsx(\"button\",{className:\"monke-checkout\",onClick:()=>window.location.assign(checkoutUrl),children:\"Checkout\"})]})]});}addPropertyControls(ShopifyCatalog,{productView:{type:ControlType.Enum,title:\"Products\",options:[\"all\",\"cap\"],optionTitles:[\"All products\",\"Local Tourist cap\"],defaultValue:\"all\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ShopifyCatalog\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ShopifyCapBuyButton.map"],"mappings":"A,qNAAwS,eAAegB,EAAW,EAAM,EAAU,CAAC,EAAE,CAAC,IAAMC,EAAS,MAAM,MAAMC,EAAS,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,mBAAmB,oCAAoCC,CAAK,EAAE,KAAK,KAAK,UAAU,CAAC,QAAM,WAAS,CAAC,CAAC,CAAC,EAAQC,EAAK,MAAMH,EAAS,KAAK,EAAE,GAAG,CAACA,EAAS,IAAIG,EAAK,OAAO,MAAU,MAAMA,EAAK,SAAS,EAAE,EAAE,SAAS,wBAAwB,EAAE,OAAOA,EAAK,IAAK,CAazpB,SAASC,EAAM,EAAM,CAAC,OAAO,IAAI,KAAK,aAAa,QAAQ,CAAC,MAAM,WAAW,SAASC,EAAM,YAAY,CAAC,CAAC,CAAC,OAAO,OAAOA,EAAM,MAAM,CAAC,CAAE,CAAC,SAASC,EAAY,EAAK,CAAC,OAAOC,EAAK,QAAQ,YAAY,EAAE,CAAC,CAAC,QAAQ,0BAA0B,GAAG,CAAC,CAAC,QAAQ,SAAS,GAAG,CAAE,CAAC,SAASC,EAAW,EAAM,CAAiD,MAA7C,WAAW,KAAKC,CAAK,EAAQ,gBAAuBH,EAAYG,EAAM,QAAQ,aAAa,QAAQ,CAAC,CAAE,CAG1Y,SAAwBC,EAAe,CAAC,QAAM,cAAY,OAAO,CAAC,IAAMC,EAASb,EAAoB,EAAO,CAACc,EAASC,GAAa9B,EAAS,CAAC,CAAC,EAAO,CAAC+B,EAAS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