{"version":3,"file":"Fit_Text.BOAWbeUl.mjs","names":["useRef","useState","__esmMin","_e","de","c","init_jsx_runtime","init_npm_react_18_3_1","ce","init_framer_D6uXRwWs","ControlType","addPropertyControls","FitText","containerRef","fontSize","setFontSize","calculate","container","testSpan","fontFamily","fontWeight","text","textWidth","containerWidth","ls","letterSpacing","totalWidthPerUnit","observer","tag","color","init_Fit_Text"],"sources":["https:/framerusercontent.com/modules/tJsBKbEweu0ACvACR0Zv/n3osUpBpGrwts2QWVx92/Fit_Text.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef,useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function FitText({text,fontFamily,fontWeight,color,letterSpacing,tag}){const containerRef=useRef(null);const[fontSize,setFontSize]=useState(100);useEffect(()=>{if(!containerRef.current)return;const calculate=()=>{const container=containerRef.current;if(!container)return;const testSpan=document.createElement(\"span\");testSpan.style.cssText=`\n                position: absolute;\n                visibility: hidden;\n                white-space: nowrap;\n                font-size: 100px;\n                font-family: ${fontFamily||\"inherit\"};\n                font-weight: ${fontWeight||\"400\"};\n            `;testSpan.textContent=text;document.body.appendChild(testSpan);const textWidth=testSpan.offsetWidth;document.body.removeChild(testSpan);const containerWidth=container.offsetWidth;const ls=letterSpacing||0;const totalWidthPerUnit=textWidth/100+ls*(text.length-1);if(totalWidthPerUnit>0){setFontSize(containerWidth/totalWidthPerUnit);}};calculate();const observer=new ResizeObserver(calculate);observer.observe(containerRef.current);return()=>observer.disconnect();},[text,fontFamily,fontWeight,letterSpacing]);// Renders as whichever tag is chosen in the property panel — the\n// fitted-text behavior is identical either way, only the semantic\n// element changes. Defaults to \"h1\" since that's this component's\n// primary use case (a large fitted name/wordmark), but any text\n// instance can be switched to h2/p/span/div as needed.\nconst Tag=tag||\"h1\";return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{width:\"100%\",overflow:\"visible\"},children:/*#__PURE__*/_jsx(Tag,{style:{display:\"block\",margin:0,fontSize:`${fontSize}px`,whiteSpace:\"nowrap\",fontFamily:fontFamily||\"inherit\",fontWeight:fontWeight||\"400\",lineHeight:1.2,color:color||\"#000000\",letterSpacing:`${letterSpacing||0}em`},children:text})});}addPropertyControls(FitText,{text:{type:ControlType.String,defaultValue:\"Halcyon\"},tag:{type:ControlType.Enum,title:\"Tag\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"p\",\"span\",\"div\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"H4\",\"Paragraph\",\"Span\",\"Div\"],defaultValue:\"h1\"},fontFamily:{type:ControlType.String,defaultValue:\"\"},fontWeight:{type:ControlType.String,defaultValue:\"400\"},color:{type:ControlType.Color,defaultValue:\"#000000\"},letterSpacing:{type:ControlType.Number,defaultValue:0,step:.01,displayStepper:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FitText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Fit_Text.map"],"mappings":"A,wLAA4I,SAAwBY,EAAQ,CAAC,OAAK,aAAW,aAAW,QAAM,gBAAc,OAAK,CAAC,IAAMC,EAAab,EAAO,IAAI,EAAO,CAACc,EAASC,GAAad,EAAS,GAAG,EAYtR,OAZwRO,MAAc,CAAC,GAAG,CAACK,EAAa,QAAQ,OAAO,IAAMG,MAAc,CAAC,IAAMC,EAAUJ,EAAa,QAAQ,GAAG,CAACI,EAAU,OAAO,IAAMC,EAAS,SAAS,cAAc,MAAM,EAAE,EAAS,MAAM,QAAQ;;;;;+BAKhdC,GAAY,UAAU;+BACtBC,GAAY,MAAM;cACnC,EAAS,YAAYC,EAAK,SAAS,KAAK,YAAYH,CAAQ,EAAE,IAAMI,EAAUJ,EAAS,YAAY,SAAS,KAAK,YAAYA,CAAQ,EAAE,IAAMK,EAAeN,EAAU,YAAkBO,EAAGC,GAAe,EAAQC,EAAkBJ,EAAU,IAAIE,G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