{"version":3,"file":"AuthCallBack.Ckt056ws.mjs","names":["React"],"sources":["https:/framerusercontent.com/modules/yLysaOZ6KQ9PHuDkWXJd/b6S8qgyQfunHEfylz7m0/AuthCallBack.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import React from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useShopifyStore}from\"https://framerusercontent.com/modules/znmeN2mKRItnf7zyDZ26/TXqjakjsaeQzSOClG1Cf/ShopifyStore.js\";export function ShopifyAuthCallback(props){const{successRedirect=\"/\",errorRedirect,showStatus=true,processingLabel=\"Completing sign in...\",successLabel=\"Success! Redirecting...\",errorLabel=\"Authentication failed\",textColor=\"#333333\",successColor=\"#22c55e\",errorColor=\"#ef4444\",fontFamily=\"system-ui, -apple-system, sans-serif\"}=props;const[status,setStatus]=React.useState(\"idle\");const[errorMessage,setErrorMessage]=React.useState(\"\");const handleOAuthCallback=useShopifyStore(state=>state.handleOAuthCallback);const shopId=useShopifyStore(state=>state.shopId);React.useEffect(()=>{const processCallback=async()=>{const urlParams=new URLSearchParams(window.location.search);const code=urlParams.get(\"code\");const state=urlParams.get(\"state\");const error=urlParams.get(\"error\");const errorDescription=urlParams.get(\"error_description\");// No OAuth params - not a callback, just normal page visit\nif(!code&&!state&&!error){setStatus(\"idle\");return;}setStatus(\"processing\");// Handle OAuth errors from Shopify\nif(error){const message=errorDescription||error;setStatus(\"error\");setErrorMessage(message);if(errorRedirect){setTimeout(()=>{window.location.href=`${errorRedirect}?error=${encodeURIComponent(message)}`;},2e3);}return;}// Missing params\nif(!code||!state){setStatus(\"error\");setErrorMessage(\"Missing authorization code\");return;}// Check config\nif(!shopId){setStatus(\"error\");setErrorMessage(\"Shop not configured. Add ShopifyStoreComponent with credentials.\");return;}try{const success=await handleOAuthCallback(code,state);if(success){setStatus(\"success\");// Clean URL\nwindow.history.replaceState({},document.title,window.location.pathname);setTimeout(()=>{window.location.href=successRedirect;},1e3);}else{setStatus(\"error\");setErrorMessage(\"Authentication failed\");}}catch(err){setStatus(\"error\");setErrorMessage(err instanceof Error?err.message:\"Authentication failed\");if(errorRedirect){setTimeout(()=>{window.location.href=errorRedirect;},2e3);}}};processCallback();},[shopId]);// Don't show anything if not processing a callback\nif(status===\"idle\"||!showStatus){return null;}const containerStyle={display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",padding:\"40px 20px\",fontFamily,textAlign:\"center\"};const spinnerStyle={width:40,height:40,border:`3px solid ${textColor}20`,borderTopColor:textColor,borderRadius:\"50%\",animation:\"callback-spin 0.8s linear infinite\",marginBottom:20};const textStyle={fontSize:16,color:status===\"success\"?successColor:status===\"error\"?errorColor:textColor,margin:0};return /*#__PURE__*/_jsxs(\"div\",{style:containerStyle,children:[/*#__PURE__*/_jsx(\"style\",{children:`@keyframes callback-spin { to { transform: rotate(360deg); } }`}),status===\"processing\"&&/*#__PURE__*/_jsx(\"div\",{style:spinnerStyle}),status===\"success\"&&/*#__PURE__*/_jsxs(\"svg\",{width:\"48\",height:\"48\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:successColor,strokeWidth:\"2\",style:{marginBottom:20},children:[/*#__PURE__*/_jsx(\"path\",{d:\"M22 11.08V12a10 10 0 1 1-5.93-9.14\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"22 4 12 14.01 9 11.01\"})]}),status===\"error\"&&/*#__PURE__*/_jsxs(\"svg\",{width:\"48\",height:\"48\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:errorColor,strokeWidth:\"2\",style:{marginBottom:20},children:[/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"10\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"15\",y1:\"9\",x2:\"9\",y2:\"15\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"9\",y1:\"9\",x2:\"15\",y2:\"15\"})]}),/*#__PURE__*/_jsxs(\"p\",{style:textStyle,children:[status===\"processing\"&&processingLabel,status===\"success\"&&successLabel,status===\"error\"&&errorLabel]}),status===\"error\"&&errorMessage&&/*#__PURE__*/_jsx(\"p\",{style:{...textStyle,fontSize:14,opacity:.7,marginTop:8},children:errorMessage})]});}addPropertyControls(ShopifyAuthCallback,{successRedirect:{type:ControlType.String,title:\"Success URL\",defaultValue:\"/\"},errorRedirect:{type:ControlType.String,title:\"Error URL\",defaultValue:\"\"},showStatus:{type:ControlType.Boolean,title:\"Show Status\",defaultValue:true},processingLabel:{type:ControlType.String,title:\"Processing\",defaultValue:\"Completing sign in...\"},successLabel:{type:ControlType.String,title:\"Success\",defaultValue:\"Success! Redirecting...\"},errorLabel:{type:ControlType.String,title:\"Error\",defaultValue:\"Authentication failed\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#333333\"},successColor:{type:ControlType.Color,title:\"Success Color\",defaultValue:\"#22c55e\"},errorColor:{type:ControlType.Color,title:\"Error Color\",defaultValue:\"#ef4444\"},fontFamily:{type:ControlType.String,title:\"Font\",defaultValue:\"system-ui, -apple-system, sans-serif\"}});export default ShopifyAuthCallback;\nexport const __FramerMetadata__ = {\"exports\":{\"ShopifyAuthCallback\":{\"type\":\"reactComponent\",\"name\":\"ShopifyAuthCallback\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"ShopifyAuthCallback\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"oPAAmQ,SAAgB,EAAoB,EAAM,CAAC,GAAK,CAAC,kBAAgB,IAAI,gBAAc,aAAW,GAAK,kBAAgB,wBAAwB,eAAa,0BAA0B,aAAW,wBAAwB,YAAU,UAAU,eAAa,UAAU,aAAW,UAAU,aAAW,wCAAwC,EAAW,CAAC,EAAO,GAAWA,EAAM,SAAS,OAAO,CAAM,CAAC,EAAa,GAAiBA,EAAM,SAAS,GAAG,CAAO,EAAoB,EAAgB,GAAO,EAAM,oBAAoB,CAAO,EA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