{"version":3,"file":"Embed_Custom_Feature.C23K4Orf.mjs","names":["React.useRef"],"sources":["https:/framerusercontent.com/modules/MBgfjWz6mvYC9iAZodYR/PXsxiMfv5ap82IQkOzaS/Embed_Custom_Feature.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";export function BackgroundRemoverFrame(props){const iframeRef=React.useRef(null);const{url=\"https://www.example.com\",title=\"Embedded Content\"}=props;// 下载图片的函数\nconst downloadImage=async imageSrc=>{try{const image=await fetch(imageSrc);const imageBlob=await image.blob();const imageURL=URL.createObjectURL(imageBlob);const link=document.createElement(\"a\");link.href=imageURL;link.download=\"Download\";document.body.appendChild(link);link.click();document.body.removeChild(link);URL.revokeObjectURL(imageURL)// 防止内存泄漏\n;}catch(error){console.error(\"下载图片失败\",error);}};React.useEffect(()=>{// 消息事件处理函数\nconst handleMessage=event=>{if(event.data.type===\"customeow:mount\"){console.log(\"🚀 ~  : customeow:mount\");}if(event.data.type===\"customeow:confirm\"){console.log(\"🚀 ~  : customeow:confirm\",event.data);const afterImageUrl=event.data.data[\"preview\"].images[0];downloadImage(afterImageUrl);}if(event.data.type===\"customeow:close\"){console.log(\"🚀 ~  : customeow:close\");if(iframeRef.current&&iframeRef.current.contentWindow){iframeRef.current.contentWindow.postMessage({type:\"customeow:reload\"},\"*\");}}if(event.data.type===\"customeow:error\"){console.log(\"🚀 ~  : customeow:error\");}};window.addEventListener(\"message\",handleMessage);return()=>window.removeEventListener(\"message\",handleMessage);},[]);return /*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,src:url,style:{padding:0,margin:0,width:\"100%\",height:\"100%\",border:\"none\"},title:title,allow:\"clipboard-write\"});}addPropertyControls(BackgroundRemoverFrame,{url:{type:ControlType.String,title:\"URL\",description:\"Your website url\",defaultValue:\"https://www.example.com\"},title:{type:ControlType.String,title:\"Title\",description:\"iframe title\",defaultValue:\"Embedded Content\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"BackgroundRemoverFrame\":{\"type\":\"reactComponent\",\"name\":\"BackgroundRemoverFrame\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Embed_Custom_Feature.map"],"mappings":"0LAA2H,SAAgB,EAAuB,EAAM,CAAC,IAAM,EAAUA,EAAa,KAAK,CAAM,CAAC,MAAI,0BAA0B,QAAM,oBAAoB,EACpQ,EAAc,KAAM,IAAU,CAAC,GAAG,CAAmC,IAAM,EAAU,MAAtC,MAAM,MAAM,EAAS,EAA6B,MAAM,CAAO,EAAS,IAAI,gBAAgB,EAAU,CAAO,EAAK,SAAS,cAAc,IAAI,CAAC,EAAK,KAAK,EAAS,EAAK,SAAS,WAAW,SAAS,KAAK,YAAY,EAAK,CAAC,EAAK,OAAO,CAAC,SAAS,KAAK,YAAY,EAAK,CAAC,IAAI,gBAAgB,EAAS,OACjV,EAAM,CAAC,QAAQ,MAAM,SAAS,EAAM,GAC+oB,OAD3oB,MAAoB,CACpE,IAAM,EAAc,GAAO,CAAiF,GAA7E,EAAM,KAAK,OAAO,mBAAmB,QAAQ,IAAI,0BAA0B,CAAK,EAAM,KAAK,OAAO,oBAAoB,CAAC,QAAQ,IAAI,4BAA4B,EAAM,KAAK,CAAC,IAAM,EAAc,EAAM,KAAK,KAAK,QAAW,OAAO,GAAG,EAAc,EAAc,CAAK,EAAM,KAAK,OAAO,oBAAmB,QAAQ,IAAI,0BAA0B,CAAI,EAAU,SAAS,EAAU,QAAQ,eAAe,EAAU,QAAQ,cAAc,YAAY,CAAC,KAAK,mBAAmB,CAAC,IAAI,EAAM,EAAM,KAAK,OAAO,mBAAmB,QAAQ,IAAI,0BAA0B,EAAqD,OAAjD,EAAO,iBAAiB,UAAU,EAAc,KAAW,EAAO,oBAAoB,UAAU,EAAc,EAAG,EAAE,CAAC,CAAqB,EAAK,SAAS,CAAC,IAAI,EAAU,IAAI,EAAI,MAAM,CA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