{"version":3,"file":"EstimatedReadTime.DMU6Z1vK.mjs","names":[],"sources":["https:/framerusercontent.com/modules/VCKUQ8ec8Jg0oNLsR9yY/u6Wi7oiGUevUSuepkj5x/EstimatedReadTime.js"],"sourcesContent":["// This component renders an Estimated Read Time element based on set content.\n// Last updated by @joshua on 20241126.\n// Imports necessary for functionality and Framer integration.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";/** Word-count based estimate (avoids npm `reading-time` in Framer bundle). */function estimateReadingMinutes(text,wordsPerMinute){const words=text.trim().split(/\\s+/).filter(w=>w.length>0).length;if(words===0)return 0;return Math.max(1,Math.round(words/wordsPerMinute));}// Extracts text content recursively from a React element to compute reading time.\nfunction getTextContentArrayFromReactElement(element){// Handle null or undefined elements.\nif(!element)return[];// If the element is a string, return it as an array.\nif(typeof element===\"string\")return[element];// Recursively process arrays of elements.\nif(Array.isArray(element))return element.flatMap(getTextContentArrayFromReactElement);// Recursively process children if the element has props and children.\nif(element.props?.children){const children=Array.isArray(element.props.children)?element.props.children:[element.props.children];return children.flatMap(getTextContentArrayFromReactElement);}// Return an empty array for unsupported element types.\nreturn[];}// Main component to render estimated reading time.\nexport default function EstimatedReadTime(props){// Variables to track text content availability and extracted strings.\nlet hasText=false;let strings=[];// Determine the source of text and extract content.\nif(props.formatted){// Extract text from a formatted React element.\nstrings=getTextContentArrayFromReactElement(props.formattedText);hasText=props.formattedText&&strings.length>0;}else{// Use plain text input.\nstrings.push(props.plainText);hasText=!!props.plainText;}const minutes=estimateReadingMinutes(strings.join(\" \"),props.wpm);// Render reading time or a placeholder if no text content is provided.\nreturn /*#__PURE__*/_jsx(\"p\",{style:{color:props.fontColor,userSelect:props.textSelect?\"auto\":\"none\",margin:0,...props.font},children:hasText?`${props.prefix}${minutes}${props.suffix}`:\"“No text content connected.”\"});}// Define the display name for the component in Framer.\nEstimatedReadTime.displayName=\"Estimated Read Time (Atom)\";// Define property controls for the component in Framer.\naddPropertyControls(EstimatedReadTime,{formatted:{type:ControlType.Boolean,title:\"Formatted Text\",defaultValue:true},formattedText:{type:ControlType.RichText,title:\"Text\",hidden:props=>!props.formatted},plainText:{type:ControlType.String,title:\"Text\",displayTextArea:true,hidden:props=>props.formatted},wpm:{type:ControlType.Number,title:\"WPM\",description:\"Words per minute\",defaultValue:200,step:1,min:1},fontColor:{type:ControlType.Color,title:\"Font Color\",defaultValue:\"#000\"},font:{type:\"font\",title:\"Font Style\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1.4}},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\" min read\"},textSelect:{type:ControlType.Boolean,title:\"Allow Text Selection\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EstimatedReadTime\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./EstimatedReadTime.map"],"mappings":"6JAG6K,SAAS,EAAuB,EAAK,EAAe,CAAC,IAAM,EAAM,EAAK,MAAM,CAAC,MAAM,MAAM,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,CAAC,OAA6B,OAAnB,IAAQ,EAAS,EAAS,KAAK,IAAI,EAAE,KAAK,MAAM,EAAM,EAAe,CAAC,CAC7W,SAAS,EAAoC,EAAQ,CAKrD,OAJI,EACD,OAAO,GAAU,SAAe,CAAC,EAAQ,CACzC,MAAM,QAAQ,EAAQ,CAAQ,EAAQ,QAAQ,EAAoC,CAClF,EAAQ,OAAO,UAAyB,MAAM,QAAQ,EAAQ,MAAM,SAAS,CAAC,EAAQ,MAAM,SAAS,CAAC,EAAQ,MAAM,SAAS,EAAiB,QAAQ,EAAoC,CACvL,EAAE,CAJU,EAAE,CAKpB,SAAwB,EAAkB,EAAM,CAChD,IAAI,EAAQ,GAAU,EAAQ,EAAE,C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