{"version":3,"file":"ImageProtection.CDSnTgFL.mjs","names":["WrappedComponent","__esmMin","init_npm_react_18_3_1","init_ssg_sandbox_shims","window","c","J","init_jsx_runtime","ce","getElementFromTarget","target","hasBackgroundImage","backgroundImage","element","isProtectedVisualTarget","isEditableField","withImageProtection","styleElement","onContextMenu","event","onDragStart","onSelectStart","onKeyDown","key","activeElement","Component","props","init_ImageProtection"],"sources":["https:/framerusercontent.com/modules/XtNcRXOKB9sykpzU05nu/WUREFkpwxytiKE2DLEOs/ImageProtection.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";function getElementFromTarget(target){if(target instanceof Element)return target;if(target instanceof Node)return target.parentElement;return null;}function hasBackgroundImage(element){if(typeof window===\"undefined\")return false;const backgroundImage=window.getComputedStyle(element).backgroundImage;return Boolean(backgroundImage&&backgroundImage!==\"none\");}function isProtectedVisualTarget(target){const element=getElementFromTarget(target);if(!element)return false;if(element instanceof HTMLImageElement)return true;return hasBackgroundImage(element);}function isEditableField(element){if(!element)return false;if(element.isContentEditable)return true;const editableAncestor=element.closest('input, textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]');return Boolean(editableAncestor);}export function withImageProtection(Component){return /*#__PURE__*/forwardRef(function WithImageProtection(props,ref){useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\"){return;}const styleElement=document.createElement(\"style\");styleElement.setAttribute(\"data-image-protection-style\",\"true\");styleElement.textContent=`\n[data-image-protection-root=\"true\"] img,\n[data-image-protection-root=\"true\"] picture {\n  -webkit-user-drag: none;\n  user-drag: none;\n  -webkit-user-select: none;\n  user-select: none;\n  -webkit-touch-callout: none;\n}\n`;document.head.appendChild(styleElement);const onContextMenu=event=>{if(isProtectedVisualTarget(event.target)){event.preventDefault();}};const onDragStart=event=>{if(isProtectedVisualTarget(event.target)){event.preventDefault();}};const onSelectStart=event=>{if(isProtectedVisualTarget(event.target)){event.preventDefault();}};const onKeyDown=event=>{const key=event.key.toLowerCase();if(!(event.ctrlKey||event.metaKey)||key!==\"s\")return;const activeElement=document.activeElement;if(isEditableField(activeElement))return;event.preventDefault();};document.addEventListener(\"contextmenu\",onContextMenu);document.addEventListener(\"dragstart\",onDragStart);document.addEventListener(\"selectstart\",onSelectStart);window.addEventListener(\"keydown\",onKeyDown);return()=>{document.removeEventListener(\"contextmenu\",onContextMenu);document.removeEventListener(\"dragstart\",onDragStart);document.removeEventListener(\"selectstart\",onSelectStart);window.removeEventListener(\"keydown\",onKeyDown);styleElement.remove();};},[]);const WrappedComponent=Component;return /*#__PURE__*/_jsx(WrappedComponent,{ref:ref,...props,\"data-image-protection-root\":\"true\"});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withImageProtection\":{\"type\":\"reactHoc\",\"name\":\"withImageProtection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageProtection.map"],"mappings":"A,uIAAmF,SAASS,EAAqB,EAAO,CAAkG,OAA9FC,aAAkB,QAAeA,EAAUA,aAAkB,KAAYA,EAAO,cAAqB,IAAK,CAAC,SAASC,EAAmB,EAAQ,CAAC,GAAUP,IAAS,OAAY,MAAO,GAAM,IAAMQ,EAAgBR,EAAO,iBAAiBS,CAAO,CAAC,CAAC,gBAAgB,MAAO,GAAQD,GAAiBA,IAAkB,OAAQ,CAAC,SAASE,EAAwB,EAAO,CAAC,IAAMD,EAAQJ,EAAqBC,CAAM,EAA8E,OAAxEG,EAAwBA,aAAmB,kBAAoCF,EAAmBE,CAAO,EAA1F,EAA4F,CAAC,SAASE,EAAgB,EAAQ,CAAqL,OAAhLF,EAAwBA,EAAQ,kBAAyB,GAA8H,EAAlGA,EAAQ,QAAQ,yEAA0F,EAAhL,EAAkM,CAAC,SAAgBG,EAAoB,EAAU,CAAC,MAAoB,gBAAW,SAA6B,EAAM,EAAI,CAS2C,OAT1CR,MAAc,CAAC,GAAUJ,IAAS,QAAa,OAAO,SAAW,I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