{"version":3,"file":"SteelCodeBlock.C93LNASZ.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/Mg6tHRCqToSKMQ4e0HtD/hMZ0cmy6l086nTg9bETv/SteelCodeBlock.js"],"sourcesContent":["/**\n * User request: Create a new Framer code component named \"SteelCodeBlock\" with lightweight regex/tokenizer-based\n * syntax highlighting, Steel dark theme controls, line numbers, monospace typography, SSR-safe rendering, and\n * content-height + full-width layout behavior suitable for docs/code snippets.\n */import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";const jsTsKeywords=new Set([\"import\",\"export\",\"from\",\"default\",\"const\",\"let\",\"var\",\"function\",\"return\",\"if\",\"else\",\"switch\",\"case\",\"break\",\"continue\",\"for\",\"while\",\"do\",\"new\",\"class\",\"extends\",\"implements\",\"interface\",\"type\",\"enum\",\"public\",\"private\",\"protected\",\"static\",\"async\",\"await\",\"try\",\"catch\",\"finally\",\"throw\",\"typeof\",\"instanceof\",\"in\",\"of\",\"as\",\"void\",\"yield\",\"this\",\"super\",\"true\",\"false\",\"null\",\"undefined\"]);const pythonKeywords=new Set([\"def\",\"return\",\"if\",\"elif\",\"else\",\"for\",\"while\",\"break\",\"continue\",\"class\",\"import\",\"from\",\"as\",\"try\",\"except\",\"finally\",\"raise\",\"pass\",\"lambda\",\"with\",\"async\",\"await\",\"True\",\"False\",\"None\",\"and\",\"or\",\"not\",\"in\",\"is\"]);const shellKeywords=new Set([\"if\",\"then\",\"else\",\"fi\",\"for\",\"do\",\"done\",\"while\",\"case\",\"esac\",\"function\",\"in\",\"return\",\"export\",\"local\"]);const jsonKeywords=new Set([\"true\",\"false\",\"null\"]);function getKeywordSet(language){if(language===\"Python\")return pythonKeywords;if(language===\"Shell\")return shellKeywords;if(language===\"JSON\")return jsonKeywords;return jsTsKeywords;}function tokenizeCode(code,language){try{const lines=code.split(\"\\n\");const tokenLines=[];const keywordSet=getKeywordSet(language);const isJSLike=language===\"JavaScript\"||language===\"TypeScript\"||language===\"JSON\";const isHashComment=language===\"Python\"||language===\"Shell\";let inBlockComment=false;for(let lineIndex=0;lineIndex<lines.length;lineIndex++){const line=lines[lineIndex];const lineTokens=[];let i=0;while(i<line.length){const rest=line.slice(i);if(inBlockComment){const endIndex=rest.indexOf(\"*/\");if(endIndex===-1){lineTokens.push({type:\"comment\",value:rest});i=line.length;continue;}const commentPart=rest.slice(0,endIndex+2);lineTokens.push({type:\"comment\",value:commentPart});i+=endIndex+2;inBlockComment=false;continue;}if(isJSLike&&rest.startsWith(\"//\")){lineTokens.push({type:\"comment\",value:rest});i=line.length;continue;}if(isHashComment&&rest.startsWith(\"#\")){lineTokens.push({type:\"comment\",value:rest});i=line.length;continue;}if(isJSLike&&rest.startsWith(\"/*\")){const endIndex=rest.indexOf(\"*/\",2);if(endIndex===-1){lineTokens.push({type:\"comment\",value:rest});inBlockComment=true;i=line.length;continue;}const commentPart=rest.slice(0,endIndex+2);lineTokens.push({type:\"comment\",value:commentPart});i+=endIndex+2;continue;}const quote=rest[0];if(quote==='\"'||quote===\"'\"||isJSLike&&quote===\"`\"){let j=1;while(j<rest.length){if(rest[j]===\"\\\\\"&&j+1<rest.length){j+=2;continue;}if(rest[j]===quote){j+=1;break;}j+=1;}lineTokens.push({type:\"string\",value:rest.slice(0,j)});i+=j;continue;}const numberMatch=rest.match(/^(?:0x[0-9a-fA-F]+|\\d+(?:\\.\\d+)?)/);if(numberMatch){lineTokens.push({type:\"number\",value:numberMatch[0]});i+=numberMatch[0].length;continue;}const identMatch=rest.match(/^[A-Za-z_$][A-Za-z0-9_$]*/);if(identMatch){const ident=identMatch[0];if(keywordSet.has(ident)){lineTokens.push({type:\"keyword\",value:ident});}else if(/^\\s*\\(/.test(rest.slice(ident.length))){lineTokens.push({type:\"function\",value:ident});}else{lineTokens.push({type:\"plain\",value:ident});}i+=ident.length;continue;}const punctuationMatch=rest.match(/^[\\[\\]{}().,;:+\\-*/%=&|!<>?:~^]+/);if(punctuationMatch){lineTokens.push({type:\"punctuation\",value:punctuationMatch[0]});i+=punctuationMatch[0].length;continue;}lineTokens.push({type:\"plain\",value:rest[0]});i+=1;}tokenLines.push(lineTokens);}return tokenLines;}catch(_error){return code.split(\"\\n\").map(line=>[{type:\"plain\",value:line}]);}}function getTokenColor(type,props){if(type===\"keyword\")return props.keywordColor;if(type===\"string\")return props.stringColor;if(type===\"comment\")return props.commentColor;if(type===\"function\")return props.functionColor;if(type===\"number\")return props.numberColor;if(type===\"punctuation\")return props.punctuationColor;return props.plainText;}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function SteelCodeBlock(props){const tokenLines=useMemo(()=>tokenizeCode(props.code,props.language),[props.code,props.language]);const lineCount=tokenLines.length;const lineDigits=String(Math.max(1,lineCount)).length;return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:\"100%\",boxSizing:\"border-box\",background:props.background,border:`1px solid ${props.borderColor}`,borderRadius:props.radius,padding:props.padding,overflowX:\"auto\",overflowY:\"hidden\"},children:/*#__PURE__*/_jsxs(\"div\",{style:{display:\"grid\",gridTemplateColumns:props.showLineNumbers?`${lineDigits+1}ch minmax(0, 1fr)`:\"minmax(0, 1fr)\",columnGap:props.showLineNumbers?16:0,alignItems:\"start\",minWidth:\"max-content\",width:\"100%\"},children:[props.showLineNumbers&&/*#__PURE__*/_jsx(\"div\",{style:{color:props.lineNumberColor,userSelect:\"none\",textAlign:\"right\",fontFamily:'\"Geist Mono\", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace',fontSize:props.fontSize,lineHeight:1.6,whiteSpace:\"pre\"},children:tokenLines.map((_,index)=>/*#__PURE__*/_jsx(\"div\",{children:index+1},`line-number-${index}`))}),/*#__PURE__*/_jsx(\"div\",{style:{fontFamily:'\"Geist Mono\", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace',fontSize:props.fontSize,lineHeight:1.6,color:props.plainText,whiteSpace:\"pre\"},children:tokenLines.map((lineTokens,lineIndex)=>/*#__PURE__*/_jsx(\"div\",{children:lineTokens.length===0?\" \":lineTokens.map((token,tokenIndex)=>/*#__PURE__*/_jsx(\"span\",{style:{color:getTokenColor(token.type,props)},children:token.value},`token-${lineIndex}-${tokenIndex}`))},`code-line-${lineIndex}`))})]})});}addPropertyControls(SteelCodeBlock,{code:{type:ControlType.String,title:\"Code\",displayTextArea:true,defaultValue:'import { useMemo } from \"react\"\\\\n\\\\nexport function sum(a: number, b: number) {\\\\n    // Steel docs example\\\\n    return a + b\\\\n}'},language:{type:ControlType.Enum,title:\"Language\",options:[\"Python\",\"JavaScript\",\"TypeScript\",\"Shell\",\"JSON\"],defaultValue:\"TypeScript\"},showLineNumbers:{type:ControlType.Boolean,title:\"Line #\",defaultValue:true},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:14,min:10,max:24,step:1,unit:\"px\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgb(25, 25, 24)\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"rgb(34, 34, 33)\"},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:40,step:1,unit:\"px\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:24,min:0,max:64,step:1,unit:\"px\"},plainText:{type:ControlType.Color,title:\"Plain\",defaultValue:\"rgb(238, 238, 236)\"},keywordColor:{type:ControlType.Color,title:\"Keyword\",defaultValue:\"rgb(255, 139, 62)\"},stringColor:{type:ControlType.Color,title:\"String\",defaultValue:\"rgb(76, 196, 138)\"},commentColor:{type:ControlType.Color,title:\"Comment\",defaultValue:\"rgb(124, 123, 116)\"},functionColor:{type:ControlType.Color,title:\"Function\",defaultValue:\"rgb(46, 200, 238)\"},numberColor:{type:ControlType.Color,title:\"Number\",defaultValue:\"rgb(219, 161, 110)\"},punctuationColor:{type:ControlType.Color,title:\"Punctuation\",defaultValue:\"rgb(181, 179, 173)\"},lineNumberColor:{type:ControlType.Color,title:\"Line # Color\",defaultValue:\"rgb(81, 80, 75)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SteelCodeBlock\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SteelCodeBlock.map"],"mappings":"4KAIw+B,SAAS,EAAc,EAAS,CAAkI,OAA9H,IAAW,SAAgB,EAAkB,IAAW,QAAe,EAAiB,IAAW,OAAc,EAAoB,EAAc,SAAS,EAAa,EAAK,EAAS,CAAC,GAAG,CAAC,IAAM,EAAM,EAAK,MAAM;EAAK,CAAO,EAAW,EAAE,CAAO,EAAW,EAAc,EAAS,CAAO,EAAS,IAAW,cAAc,IAAW,cAAc,IAAW,OAAa,EAAc,IAAW,UAAU,IAAW,QAAY,EAAe,GAAM,IAAI,IAAI,EAAU,EAAE,EAAU,EAAM,OAAO,IAAY,CAAC,IAAM,EAAK,EAAM,GAAiB,EAAW,EAAE,CAAK,EAAE,EAAE,KAAM,EAAE,EAAK,QAAO,CAAC,IAAM,EAAK,EAAK,MAAM,EAAE,CAAC,GAAG,EAAe,CAAC,IAAM,EAAS,EAAK,QAAQ,KAAK,CAAC,GAAG,IAAW,GAAG,CAAC,EAAW,KAAK,CAAC,KAAK,UAAU,MAAM,EAAK,CAAC,CAAC,EAAE,EAAK,OAAO,SAAU,IAAM,EAAY,EAAK,MAAM,EAAE,EAAS,EAAE,CAAC,EAAW,KAAK,CAAC,KAAK,UAAU,MAAM,EAAY,CAAC,CAAC,GAAG,EAAS,EAAE,EAAe,GAAM,SAAU,GAAG,GAAU,EAAK,WAAW,KAAK,CAAC,CAAC,EAAW,KAAK,CAAC,KAAK,UAAU,MAAM,EAAK,CAAC,CAAC,EAAE,EAAK,OA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