{"version":3,"file":"PDFViewer_1.BHCIcZ-R.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/rmpf0SwQPvl248tTMr1m/nEfgKf55Z9jCN04cJxKP/PDFViewer_1.js"],"sourcesContent":["// PDF Viewer component with CMS file support\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";// Framer CMS file fields can arrive as a plain string URL, an object\n// { url, name, ... } or { src, ... }, or an array of such objects.\nfunction resolveUrl(value){if(!value)return\"\";if(typeof value===\"string\")return value.trim();if(Array.isArray(value))return resolveUrl(value[0]);if(typeof value===\"object\"){const url=value.url??value.src??value.href??value.file??value.path??value.uri??\"\";return String(url).trim();}return\"\";}/**\n * PDF Viewer\n *\n * @framerIntrinsicWidth 800\n * @framerIntrinsicHeight 600\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function PDFViewer(props){const{pdfFile,showControls=true,useGoogleViewer=false,backgroundColor=\"#F5F5F5\",borderRadius=8,style}=props;const resolvedPdf=resolveUrl(pdfFile);const[error,setError]=useState(null);const[isLoading,setIsLoading]=useState(false);useEffect(()=>{if(!resolvedPdf)return;startTransition(()=>{setIsLoading(true);setError(null);});},[resolvedPdf,useGoogleViewer]);const handleLoad=()=>{startTransition(()=>{setIsLoading(false);setError(null);});};const handleError=()=>{startTransition(()=>{setIsLoading(false);setError(\"Failed to load PDF. Please check the file URL.\");});};const isFixedWidth=style?.width===\"100%\";const isFixedHeight=style?.height===\"100%\";// Build the src used in the embed. Google Docs viewer bypasses X-Frame-Options\n// restrictions on external PDFs; use it when the toggle is on.\nconst embedSrc=resolvedPdf?useGoogleViewer?`https://docs.google.com/viewer?url=${encodeURIComponent(resolvedPdf)}&embedded=true`:`${resolvedPdf}#toolbar=${showControls?\"1\":\"0\"}&navpanes=0&scrollbar=1`:null;return /*#__PURE__*/_jsxs(\"div\",{style:{...style,position:\"relative\",width:isFixedWidth?\"100%\":style?.width||800,height:isFixedHeight?\"100%\":style?.height||600,backgroundColor,borderRadius,overflow:\"hidden\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:[isLoading&&!error&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"50%\",left:\"50%\",transform:\"translate(-50%, -50%)\",color:\"#666\",fontSize:14,fontFamily:\"Inter, sans-serif\"},children:\"Loading PDF...\"}),error&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"50%\",left:\"50%\",transform:\"translate(-50%, -50%)\",color:\"#FF5588\",fontSize:14,fontFamily:\"Inter, sans-serif\",textAlign:\"center\",padding:20},children:error}),embedSrc&&/*#__PURE__*/_jsx(\"iframe\",{src:embedSrc,style:{width:\"100%\",height:\"100%\",border:\"none\",display:error?\"none\":\"block\"},title:\"PDF Viewer\",onLoad:handleLoad,onError:handleError},embedSrc),!resolvedPdf&&!error&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"#999\",fontSize:14,fontFamily:\"Inter, sans-serif\",textAlign:\"center\",padding:16},children:RenderTarget.current()===RenderTarget.canvas&&pdfFile!==undefined?// Debug: shown only in the Framer canvas to reveal the raw CMS value shape\n/*#__PURE__*/_jsxs(\"span\",{style:{color:\"#f90\",fontSize:11,wordBreak:\"break-all\"},children:[\"⚠ CMS value received but not resolved:\",\" \",/*#__PURE__*/_jsx(\"strong\",{children:JSON.stringify(pdfFile)})]}):\"No PDF file selected\"})]});}addPropertyControls(PDFViewer,{pdfFile:{// ControlType.File shows as connectable to CMS File fields (purple dot).\n// You can also upload a PDF directly here for static use.\ntype:ControlType.File,title:\"PDF File\",allowedFileTypes:[\"pdf\"]},showControls:{type:ControlType.Boolean,title:\"Show Controls\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\",hidden(props){return props.useGoogleViewer;}},useGoogleViewer:{type:ControlType.Boolean,title:\"Google Viewer\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#F5F5F5\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:32,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PDFViewer\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"800\",\"framerIntrinsicHeight\":\"600\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PDFViewer_1.map"],"mappings":"kMAGA,SAAS,EAAW,EAAM,CAAC,GAAG,CAAC,EAAM,MAAM,GAAG,GAAG,OAAO,GAAQ,SAAS,OAAO,EAAM,MAAM,CAAC,GAAG,MAAM,QAAQ,EAAM,CAAC,OAAO,EAAW,EAAM,GAAG,CAAC,GAAG,OAAO,GAAQ,SAAS,CAAC,IAAM,EAAI,EAAM,KAAK,EAAM,KAAK,EAAM,MAAM,EAAM,MAAM,EAAM,MAAM,EAAM,KAAK,GAAG,OAAO,OAAO,EAAI,CAAC,MAAM,CAAE,MAAM,GAQ7R,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,UAAQ,eAAa,GAAK,kBAAgB,GAAM,kBAAgB,UAAU,eAAa,EAAE,SAAO,EAAY,EAAY,EAAW,EAAQ,CAAM,CAAC,EAAM,GAAUA,EAAS,KAAK,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAC,MAAc,CAAK,GAAmB,MAAoB,CAAC,EAAa,GAAK,CAAC,EAAS,KAAK,EAAG,EAAG,CAAC,EAAY,EAAgB,CAAC,CAAC,IAAM,MAAe,CAAC,MAAoB,CAAC,EAAa,GAAM,CAAC,EAAS,KAAK,EAAG,EAAS,MAAgB,CAAC,MAAoB,CAAC,EAAa,GAAM,CAAC,EAAS,iDAAi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