{"version":3,"file":"QRCode.DkPFZkTE.mjs","names":[],"sources":["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":"qOAIkB,SAAS,EAAa,EAAM,CAI9C,GAJoD,CAAC,cAAY,OAAK,WAAS,WAAS,CAAC,EAAW,CAAC,EAAS,EAAY,CAAC,GAAS,EAAM,CAAM,CAAC,EAAa,EAAgB,CAAC,EAAS,GAAG,CACrL,EAAU,EAAQ,IAAQ,IAAW,QAA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