{"version":3,"file":"ShopifyText.DNETeddB.mjs","names":["React.useState","__esmMin","init_npm_react_18_3_1","window","ce","init_jsx_runtime","c","p","_e","init_ssg_sandbox_shims","motion","init_framer_motion_DhsWWWsN","RenderTarget","init_framer_DcxuU94H","addPropertyControls","ControlType","getFirstParagraph","html","pMatch","brParts","nlParts","ShopifyDataText","framerProps","props","isCanvas","initialData","metafieldKey","value","setValue","isExpanded","setIsExpanded","handleDataReady","shouldHide","isGradient","colorType","shadowStyle","shadowEnabled","shadowX","shadowY","shadowBlur","shadowColor","textStyles","typography","gradientColor","textColor","displayText","workingText","firstParaText","hasMoreContent","firstParagraphOnly","activeText","useFormatting","enableFormatting","cleanText","hideLastWord","words","htmlToRender","inner","MotionTag","htmlTag","toggleButton","init_ShopifyText"],"sources":["https:/framerusercontent.com/modules/p1TmCy93nU8X0ZaLcBsd/gQARMdELzXtgtP53YiXf/ShopifyText.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion}from\"framer-motion\";// Grabs just the first paragraph out of a raw HTML/description string.\nfunction getFirstParagraph(html){if(!html)return html;const pMatch=html.match(/<p[^>]*>([\\s\\S]*?)<\\/p>/i);if(pMatch)return pMatch[0];const brParts=html.split(/(?:<br\\s*\\/?>\\s*){2,}/i);if(brParts.length>1)return brParts[0];const nlParts=html.split(/\\n\\s*\\n/);if(nlParts.length>1)return nlParts[0];return html;}export default function ShopifyDataText(props){const{metafieldKey,htmlTag,typography,colorType,textColor,gradientColor,textAlign,textTransform,shadowEnabled,shadowColor,shadowX,shadowY,shadowBlur,hideLastWord,enableFormatting,firstParagraphOnly,...framerProps}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;// @ts-ignore\nconst initialData=typeof window!==\"undefined\"?window.__SHOPIFY_METAFIELDS?.[metafieldKey]:null;const[value,setValue]=React.useState(initialData);const[isExpanded,setIsExpanded]=React.useState(false);React.useEffect(()=>{if(isCanvas)return;const handleDataReady=()=>{// @ts-ignore\nif(window.__SHOPIFY_METAFIELDS){// @ts-ignore\nsetValue(window.__SHOPIFY_METAFIELDS[metafieldKey]||null);}};window.addEventListener(\"shopify_data_ready\",handleDataReady);return()=>window.removeEventListener(\"shopify_data_ready\",handleDataReady);},[metafieldKey,isCanvas]);// --- SMART HIDE LOGIC ---\nlet shouldHide=false;if(!isCanvas){if(value===null||value===undefined||value.trim()===\"\"||metafieldKey.startsWith(\"custom.\")&&value===metafieldKey){shouldHide=true;}}if(shouldHide)return null;const isGradient=colorType===\"gradient\";// --- SMART SHADOW LOGIC ---\nconst shadowStyle=shadowEnabled?isGradient?{filter:`drop-shadow(${shadowX}px ${shadowY}px ${shadowBlur}px ${shadowColor})`}:{textShadow:`${shadowX}px ${shadowY}px ${shadowBlur}px ${shadowColor}`}:{};const textStyles={...typography,textAlign,textTransform,margin:0,...shadowStyle,...isGradient?{display:\"inline-block\",width:\"fit-content\",maxWidth:\"100%\",backgroundImage:gradientColor,WebkitBackgroundClip:\"text\",WebkitTextFillColor:\"transparent\",backgroundClip:\"text\",color:\"transparent\"}:{display:\"block\",width:\"100%\",color:textColor}};let displayText=value;if(isCanvas){displayText=`[${metafieldKey}]`;}else if(value===null){displayText=\"...\";}// --- EXPANDABLE / FIRST PARAGRAPH LOGIC ---\nlet workingText=displayText||\"\";let firstParaText=workingText;let hasMoreContent=false;if(firstParagraphOnly&&!isCanvas){firstParaText=getFirstParagraph(workingText);hasMoreContent=workingText.trim().length>firstParaText.trim().length;}// Decide which text to show based on expanded state\nlet activeText=firstParagraphOnly&&!isExpanded&&!isCanvas?firstParaText:workingText;// --- FORMATTING LOGIC ---\nconst useFormatting=enableFormatting&&!isCanvas;let cleanText=useFormatting?activeText:activeText.replace(/<[^>]*>/g,\"\");// --- HIDE LAST WORD LOGIC ---\nif(hideLastWord&&!isCanvas&&!useFormatting&&cleanText){const words=cleanText.trim().split(\" \");if(words.length>1){cleanText=words.slice(0,-1).join(\" \");}else{cleanText=\"\";}}let htmlToRender=cleanText.trim();// Strip wrapping <p> tag to prevent unwanted line breaks before our custom toggle\nif(useFormatting&&htmlToRender.toLowerCase().startsWith(\"<p>\")&&htmlToRender.toLowerCase().endsWith(\"</p>\")){const inner=htmlToRender.slice(3,-4).trim();if(!inner.toLowerCase().includes(\"<p>\")){htmlToRender=inner;}}const MotionTag=motion[htmlTag];// --- TOGGLE BUTTON UI ---\nconst toggleButton=firstParagraphOnly&&hasMoreContent&&!isCanvas?/*#__PURE__*/_jsx(motion.span,{onClick:()=>setIsExpanded(!isExpanded),initial:{color:\"#999999\"},whileHover:{color:\"#FF3B2E\"},style:{cursor:\"pointer\",display:\"block\",textAlign:\"right\",textDecoration:\"underline\",marginTop:\"4px\",width:\"100%\",fontSize:\"14px\"},children:isExpanded?\"Less\":\"More\"}):null;if(useFormatting){return /*#__PURE__*/_jsxs(MotionTag,{...framerProps,style:{...framerProps.style,...textStyles},children:[/*#__PURE__*/_jsx(\"span\",{dangerouslySetInnerHTML:{__html:htmlToRender}}),toggleButton]});}return /*#__PURE__*/_jsxs(MotionTag,{...framerProps,style:{...framerProps.style,...textStyles},children:[htmlToRender,toggleButton]});}addPropertyControls(ShopifyDataText,{metafieldKey:{type:ControlType.String,title:\"Data Key\"},htmlTag:{type:ControlType.Enum,options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],title:\"HTML Tag\",defaultValue:\"p\"},typography:{type:ControlType.Font,title:\"Typography\",controls:\"extended\",defaultValue:{fontFamily:\"Inter\",fontSize:16,fontWeight:500,lineHeight:1.2}},colorType:{type:ControlType.Enum,options:[\"solid\",\"gradient\"],title:\"Color Type\",defaultValue:\"solid\"},textColor:{type:ControlType.Color,title:\"Solid Color\",defaultValue:\"#FFFFFF\",hidden(props){return props.colorType===\"gradient\";}},gradientColor:{type:ControlType.String,title:\"Gradient CSS\",defaultValue:\"linear-gradient(135deg, #FF6B9D 0%, #C084FC 50%, #60A5FA 100%)\",hidden(props){return props.colorType===\"solid\";}},textAlign:{type:ControlType.Enum,options:[\"left\",\"center\",\"right\"],title:\"Align\",defaultValue:\"left\"},textTransform:{type:ControlType.Enum,options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],title:\"Transform\",defaultValue:\"none\"},enableFormatting:{type:ControlType.Boolean,title:\"Format HTML\",defaultValue:false},firstParagraphOnly:{type:ControlType.Boolean,title:\"Expandable (1st Para)\",defaultValue:false},hideLastWord:{type:ControlType.Boolean,title:\"Hide Last Word\",defaultValue:false},shadowEnabled:{type:ControlType.Boolean,title:\"Enable Shadow\",defaultValue:false},shadowColor:{type:ControlType.Color,title:\"Shadow Color\",defaultValue:\"rgba(189, 28, 17, 0.76)\",hidden(props){return!props.shadowEnabled;}},shadowX:{type:ControlType.Number,title:\"Shadow X\",defaultValue:0,displayStepper:true,hidden(props){return!props.shadowEnabled;}},shadowY:{type:ControlType.Number,title:\"Shadow Y\",defaultValue:0,displayStepper:true,hidden(props){return!props.shadowEnabled;}},shadowBlur:{type:ControlType.Number,title:\"Shadow Blur\",defaultValue:38,displayStepper:true,min:0,hidden(props){return!props.shadowEnabled;}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ShopifyDataText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ShopifyText.map"],"mappings":"A,+PACA,SAASgB,EAAkB,EAAK,CAAC,GAAG,CAACC,EAAK,OAAOA,EAAK,IAAMC,EAAOD,EAAK,MAAM,0BAA0B,EAAE,GAAGC,EAAO,OAAOA,EAAO,GAAG,IAAMC,EAAQF,EAAK,MAAM,wBAAwB,EAAE,GAAGE,EAAQ,OAAO,EAAE,OAAOA,EAAQ,GAAG,IAAMC,EAAQH,EAAK,MAAM,SAAS,EAAwC,OAAnCG,EAAQ,OAAO,EAASA,EAAQ,GAAUH,CAAK,CAAC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