{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/OBsvQyrYBHWS19sLCilW/NOxva8cZ2o2vlZF7oPGw/QRCode.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useMemo,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// Function to validate if a string is a valid URL\nconst isValidUrl=string=>{try{new URL(string);return true;}catch(_){return false;}};/**\n * @framerIntrinsicHeight 160\n * @framerIntrinsicWidth 160\n */export default function CustomQRCode(props){const{customImage,data,dataType,linkData}=props;const[hasError,setHasError]=useState(false);const[errorMessage,setErrorMessage]=useState(\"\");// Determine the actual data source based on dataType.\nconst finalData=useMemo(()=>{if(dataType===\"image\")return\"\";if(dataType===\"link\"){return linkData||\"\";}return data||\"\";},[dataType,linkData,data]);// Generate QR Code URL\nconst qrUrl=useMemo(()=>{if(!finalData||dataType===\"image\")return null;const qrParams=new URLSearchParams({data:finalData,ecc:\"M\",format:\"png\"});return`https://api.qrserver.com/v1/create-qr-code/?${qrParams.toString()}`;},[finalData,dataType]);const errorStyle={display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"#000000\",fontSize:14,textAlign:\"center\",padding:10,boxSizing:\"border-box\",width:\"100%\",height:\"100%\"};// Determine the image source: custom image or generated QR code.\nconst imageSrc=dataType===\"image\"&&customImage?customImage:qrUrl;// Handles the image loading error\nconst handleImageError=()=>{setHasError(true);setErrorMessage(dataType===\"image\"?\"Failed to load image.\":\"Failed to load QR Code.\");};useEffect(()=>{setHasError(false);setErrorMessage(\"\");if(dataType===\"link\"&&linkData&&!isValidUrl(linkData)){setHasError(true);setErrorMessage(\"Invalid URL provided.\");}if(finalData===\"\"&&dataType!==\"image\"){setErrorMessage(\"No data provided.\");}},[finalData,linkData,dataType]);const altText=dataType===\"image\"?\"Custom Image\":`QR Code for: ${finalData}`;return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",background:\"none\"},children:/*#__PURE__*/_jsx(\"div\",{style:{backgroundColor:\"#FFFFFF\",overflow:\"hidden\",width:\"100%\",height:\"100%\"},children:hasError||!finalData&&dataType!==\"image\"?/*#__PURE__*/_jsx(\"div\",{style:errorStyle,children:errorMessage}):/*#__PURE__*/_jsx(\"img\",{src:imageSrc,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\"},alt:altText,onError:handleImageError})})});}CustomQRCode.displayName=\"Custom QR Code CC\";CustomQRCode.description=\"A customizable QR code component with advanced options, supporting text, links, and custom images.\";CustomQRCode.defaultProps={data:\"\",dataType:\"text\",linkData:\"\"};addPropertyControls(CustomQRCode,{dataType:{type:ControlType.Enum,options:[\"text\",\"link\",\"image\"],optionTitles:[\"Text\",\"Link\",\"Image\"],title:\"Data Type\",defaultValue:\"text\",description:\"Select the type of data to encode: text, a link (URL), or an image.\"},customImage:{description:\"Upload a custom image to use as the QR code.\",hidden(props){return props.dataType!==\"image\";},title:\"QR Image\",type:ControlType.Image},data:{defaultValue:\"\",description:\"The data or URL to encode into the QR code.\",hidden(props){return props.dataType!==\"text\";},placeholder:\"Enter data or URL...\",title:\"Data\",type:ControlType.String},linkData:{defaultValue:\"\",description:\"The URL to encode into the QR code.\",hidden(props){return props.dataType!==\"link\";},title:\"Data\",type:ControlType.Link}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CustomQRCode\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"160\",\"framerIntrinsicWidth\":\"160\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./QRCode.map"],
  "mappings": "uJAAAA,IACA,IAAMC,EAAWC,GAAQ,CAAC,GAAG,CAAC,WAAI,IAAIA,CAAM,EAAS,EAAK,MAAS,CAAC,MAAO,EAAM,CAAC,EAGhE,SAARC,EAA8BC,EAAM,CAAC,GAAK,CAAC,YAAAC,EAAY,KAAAC,EAAK,SAAAC,EAAS,SAAAC,CAAQ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CAAC,EAAeU,EAAK,MAAM,CAAC,IAAIJ,EAAS,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,UAAU,QAAQ,QAAQ,OAAO,EAAE,IAAIG,EAAQ,QAAQF,CAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAChB,EAAa,YAAY,oBAAoBA,EAAa,YAAY,qGAAqGA,EAAa,aAAa,CAAC,KAAK,GAAG,SAAS,OAAO,SAAS,EAAE,EAAEoB,EAAoBpB,EAAa,CAAC,SAAS,CAAC,KAAKqB,EAAY,KAAK,QAAQ,CAAC,OAAO,OAAO,OAAO,EAAE,aAAa,CAAC,OAAO,OAAO,OAAO,EAAE,MAAM,YAAY,aAAa,OAAO,YAAY,qEAAqE,EAAE,YAAY,CAAC,YAAY,+CAA+C,OAAOpB,EAAM,CAAC,OAAOA,EAAM,WAAW,OAAQ,EAAE,MAAM,WAAW,KAAKoB,EAAY,KAAK,EAAE,KAAK,CAAC,aAAa,GAAG,YAAY,8CAA8C,OAAOpB,EAAM,CAAC,OAAOA,EAAM,WAAW,MAAO,EAAE,YAAY,uBAAuB,MAAM,OAAO,KAAKoB,EAAY,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,YAAY,sCAAsC,OAAOpB,EAAM,CAAC,OAAOA,EAAM,WAAW,MAAO,EAAE,MAAM,OAAO,KAAKoB,EAAY,IAAI,CAAC,CAAC",
  "names": ["init_ssg_sandbox_shims", "isValidUrl", "string", "CustomQRCode", "props", "customImage", "data", "dataType", "linkData", "hasError", "setHasError", "ye", "errorMessage", "setErrorMessage", "finalData", "se", "qrUrl", "errorStyle", "imageSrc", "handleImageError", "ue", "altText", "p", "addPropertyControls", "ControlType"]
}
