{"version":3,"file":"Submit_Button.DC_5W2mE.mjs","names":[],"sources":["https:/framerusercontent.com/modules/6vF6kUzOJd1ogFVYvZGq/tger83vshE4qcvhzxnHE/Submit_Button.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef}from\"react\";const ERROR_MESSAGES={\"Invalid email address\":\"Please enter a valid email address.\",\"Could not determine a valid ASIN. Provide an ASIN or Amazon product URL.\":\"Please provide a valid ASIN (10 characters) or a full Amazon product URL.\",\"Failed to fetch listing data from Amazon\":\"We couldn't find that ASIN on Amazon. Please double-check it and try again.\"};function showToast(message,type){const existing=document.getElementById(\"audit-toast\");if(existing)existing.remove();const toast=document.createElement(\"div\");toast.id=\"audit-toast\";toast.textContent=message;toast.style.cssText=`\n        position: fixed;\n        bottom: 32px;\n        left: 50%;\n        transform: translateX(-50%) translateY(20px);\n        background: ${type===\"success\"?\"#1a1a1a\":\"#c0392b\"};\n        color: #fff;\n        padding: 14px 24px;\n        border-radius: 100px;\n        font-size: 14px;\n        font-family: sans-serif;\n        box-shadow: 0 4px 24px rgba(0,0,0,0.18);\n        opacity: 0;\n        transition: opacity 0.25s ease, transform 0.25s ease;\n        z-index: 99999;\n        white-space: nowrap;\n    `;document.body.appendChild(toast);requestAnimationFrame(()=>{requestAnimationFrame(()=>{toast.style.opacity=\"1\";toast.style.transform=\"translateX(-50%) translateY(0)\";});});setTimeout(()=>{toast.style.opacity=\"0\";toast.style.transform=\"translateX(-50%) translateY(20px)\";setTimeout(()=>toast.remove(),300);},4e3);}export function withAuditSubmitButton(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const handleClick=async()=>{const emailInput=document.querySelector('input[name=\"email\"]');const asinInput=document.querySelector('input[name=\"asin\"]');const urlInput=document.querySelector('input[name=\"url\"]');const email=emailInput?.value?.trim();const asin=asinInput?.value?.trim();const url=urlInput?.value?.trim();if(!email||!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)){showToast(\"Please enter a valid email address.\",\"error\");return;}if(!asin&&!url){showToast(\"Please provide a valid ASIN (10 characters) or Amazon product URL.\",\"error\");return;}if(asin&&asin.length!==10){showToast(\"ASINs must be exactly 10 characters. Please check and try again.\",\"error\");return;}const payload={email};if(asin)payload.asin=asin;if(url)payload.url=url;try{const response=await fetch(\"https://content-processor-dgs7lzqofq-uc.a.run.app/api/v1/public/audit\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(payload)});if(response.ok){showToast(\"Your free listing audit is underway. We'll send your report to your email within 24 hours.\",\"success\");const closeButton=document.querySelector('[data-framer-name=\"Close\"]');closeButton?.click();}else{const err=await response.json();const apiMessage=err?.detail||err?.message||err?.error||\"\";const friendly=ERROR_MESSAGES[apiMessage]||\"Something went wrong. Please check your inputs and try again.\";showToast(friendly,\"error\");}}catch(error){showToast(\"Network error — please check your connection and try again.\",\"error\");}};return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onClick:handleClick});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withAuditSubmitButton\":{\"type\":\"reactHoc\",\"name\":\"withAuditSubmitButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Submit_Button.map"],"mappings":"kHAA8a,SAAS,EAAU,EAAQ,EAAK,CAAC,IAAM,EAAS,SAAS,eAAe,cAAc,CAAI,GAAS,EAAS,QAAQ,CAAC,IAAM,EAAM,SAAS,cAAc,MAAM,CAAC,EAAM,GAAG,cAAc,EAAM,YAAY,EAAQ,EAAM,MAAM,QAAQ;;;;;sBAK5nB,IAAO,UAAU,UAAU,UAAU;;;;;;;;;;;MAWrD,SAAS,KAAK,YAAY,EAAM,CAAC,0BAA0B,CAAC,0BAA0B,CAAC,EAAM,MAAM,QAAQ,IAAI,EAAM,MAAM,UAAU,kCAAmC,EAAG,CAAC,eAAe,CAAC,EAAM,MAAM,QAAQ,IAAI,EAAM,MAAM,UAAU,oCAAoC,eAAe,EAAM,QAAQ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