{"version":3,"file":"WriterNameOverride.B6tYFiry.mjs","names":[],"sources":["https:/framerusercontent.com/modules/si2GTUXkOetze1SVZmuZ/ERDQiJZTF9IKBlnRwCOj/WriterNameOverride.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,cloneElement,isValidElement}from\"react\";function replaceNameInTree(node,name){if(typeof node===\"string\"){return node.replaceAll(\"{name}\",name);}if(Array.isArray(node)){return node.map(child=>replaceNameInTree(child,name));}if(/*#__PURE__*/isValidElement(node)){return /*#__PURE__*/cloneElement(node,{...node.props,children:replaceNameInTree(node.props.children,name)});}return node;}export function getWriterName(Component){return props=>{const writerName=typeof window!==\"undefined\"?localStorage.getItem(\"writerName\")||\"Your\":\"Your\";const updatedChildren=replaceNameInTree(props.children,writerName);return /*#__PURE__*/_jsx(Component,{...props,children:updatedChildren});};}export function withWriterNameAndTextColor(Component){return props=>{const[color,setColor]=useState(null);useEffect(()=>{const storedColor=localStorage.getItem(\"book_color\")||\"green\";const colorToHex={green:\"#FFFFFF\",gray:\"#000000\",white:\"#000000\",blue:\"#FFFFFF\",red:\"#000000\",black:\"#FFFFFF\"};setColor(colorToHex[storedColor]||colorToHex.green);},[]);if(!color)return null;// Get and format writer name\nconst rawName=localStorage.getItem(\"writerName\")||\"You\";const formattedName=rawName.split(\" \").join(\"\\n\");// Recursively apply color to children\nconst applyColorToChildren=children=>{if(Array.isArray(children)){return children.map(applyColorToChildren);}if(/*#__PURE__*/isValidElement(children)){return /*#__PURE__*/cloneElement(children,{style:{...children.props.style||{},color},children:applyColorToChildren(children.props.children)});}return children;};const styledChildren=applyColorToChildren(props.children);return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style||{},color},children:styledChildren,text:formattedName});};}\nexport const __FramerMetadata__ = {\"exports\":{\"getWriterName\":{\"type\":\"reactHoc\",\"name\":\"getWriterName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withWriterNameAndTextColor\":{\"type\":\"reactHoc\",\"name\":\"withWriterNameAndTextColor\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WriterNameOverride.map"],"mappings":"uIAA6G,SAAS,EAAkB,EAAK,EAAK,CAAqS,OAAjS,OAAO,GAAO,SAAiB,EAAK,WAAW,SAAS,EAAK,CAAK,MAAM,QAAQ,EAAK,CAAS,EAAK,IAAI,GAAO,EAAkB,EAAM,EAAK,CAAC,CAAkB,EAAe,EAAK,CAAsB,EAAa,EAAK,CAAC,GAAG,EAAK,MAAM,SAAS,EAAkB,EAAK,MAAM,SAAS,EAAK,CAAC,CAAC,CAAS,EAAM,SAAgB,EAAc,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,EAAkB,IAAS,OAAuD,OAA3C,aAAa,QAAQ,aAAa,EAAE,OAAoB,EAAgB,EAAkB,EAAM,SAAS,EAAW,CAAC,OAAoB,EAAK,EAAU,CAAC,GAAG,EAAM,SAAS,EAAgB,CAAC,uBAA1rB,IAAkE"}