// @bun
var{defineProperty:U,getOwnPropertyNames:$,getOwnPropertyDescriptor:j}=Object,D=Object.prototype.hasOwnProperty;function G(k){return this[k]}var W=(k)=>{var q=(Y??=new WeakMap).get(k),z;if(q)return q;if(q=U({},"__esModule",{value:!0}),k&&typeof k==="object"||typeof k==="function"){for(var A of $(k))if(!D.call(q,A))U(q,A,{get:G.bind(k,A),enumerable:!(z=j(k,A))||z.enumerable})}return Y.set(k,q),q},Y;var H=(k)=>k;function N(k,q){this[k]=H.bind(null,q)}var y=(k,q)=>{for(var z in q)U(k,z,{get:q[z],enumerable:!0,configurable:!0,set:N.bind(q,z)})};var w=(k,q)=>()=>(k&&(q=k(k=0)),q);var Z=import.meta.require;function T(k,q={}){let{includeVariants:z=!0,includeProps:A=!0,frameWidth:B=400,frameHeight:E=300,componentSpacing:K=40}=q,J={},L={},V=[],X=0;for(let Q of k){let R=S(),_=v(Q,R,X,0,B,E,A);V.push(_),J[R]={key:R,name:Q.name,description:Q.description||""},X+=B+K}return{name:"STX Components",lastModified:new Date().toISOString(),version:"1.0.0",document:{id:"0:0",name:"Document",type:"DOCUMENT",children:[{id:"0:1",name:"Components",type:"CANVAS",children:V}]},components:J,styles:L}}function v(k,q,z,A,B,E,K){let J=[];if(J.push({id:`${q}:title`,name:"Title",type:"TEXT",characters:k.name,style:{fontFamily:"Inter",fontWeight:600,fontSize:16},fills:[{type:"SOLID",color:{r:0,g:0,b:0,a:1}}]}),k.description)J.push({id:`${q}:desc`,name:"Description",type:"TEXT",characters:k.description,style:{fontFamily:"Inter",fontWeight:400,fontSize:12},fills:[{type:"SOLID",color:{r:0.4,g:0.4,b:0.4,a:1}}]});if(K&&k.props.length>0){let L=O(k.props,`${q}:props`);J.push(L)}return J.push({id:`${q}:preview`,name:"Preview",type:"RECTANGLE",absoluteBoundingBox:{x:0,y:0,width:B-32,height:150},fills:[{type:"SOLID",color:{r:0.95,g:0.95,b:0.95,a:1}}],strokes:[{type:"SOLID",color:{r:0.9,g:0.9,b:0.9,a:1}}],strokeWeight:1,cornerRadius:8}),{id:q,name:k.name,type:"COMPONENT",children:J,absoluteBoundingBox:{x:z,y:A,width:B,height:E},fills:[{type:"SOLID",color:{r:1,g:1,b:1,a:1}}],strokes:[{type:"SOLID",color:{r:0.9,g:0.9,b:0.9,a:1}}],strokeWeight:1,cornerRadius:12,paddingLeft:16,paddingRight:16,paddingTop:16,paddingBottom:16,itemSpacing:12,layoutMode:"VERTICAL",primaryAxisAlignItems:"MIN",counterAxisAlignItems:"MIN"}}function O(k,q){let z=[];z.push({id:`${q}:header`,name:"Props Header",type:"TEXT",characters:"Props",style:{fontFamily:"Inter",fontWeight:600,fontSize:12},fills:[{type:"SOLID",color:{r:0.4,g:0.4,b:0.4,a:1}}]});for(let A=0;A<k.length;A++){let B=k[A];z.push({id:`${q}:prop:${A}`,name:B.name,type:"TEXT",characters:`${B.name}: ${B.type}${B.required?" (required)":""}`,style:{fontFamily:"SF Mono",fontWeight:400,fontSize:11},fills:[{type:"SOLID",color:{r:0.2,g:0.2,b:0.2,a:1}}]})}return{id:q,name:"Props",type:"FRAME",children:z,fills:[{type:"SOLID",color:{r:0.98,g:0.98,b:0.98,a:1}}],cornerRadius:6,paddingLeft:12,paddingRight:12,paddingTop:8,paddingBottom:8,itemSpacing:4,layoutMode:"VERTICAL",primaryAxisAlignItems:"MIN",counterAxisAlignItems:"MIN"}}function S(){return`${Date.now()}:${Math.random().toString(36).slice(2,8)}`}async function F(k,q,z={}){let A=T(k,z),B=JSON.stringify(A,null,2),E=await import("fs"),K=await import("path");await E.promises.mkdir(K.dirname(q),{recursive:!0}),await E.promises.writeFile(q,B)}function M(k){if(k.startsWith("#")){let z=k.slice(1),A=Number.parseInt(z.slice(0,2),16)/255,B=Number.parseInt(z.slice(2,4),16)/255,E=Number.parseInt(z.slice(4,6),16)/255,K=z.length===8?Number.parseInt(z.slice(6,8),16)/255:1;return{r:A,g:B,b:E,a:K}}let q=k.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);if(q)return{r:Number.parseInt(q[1])/255,g:Number.parseInt(q[2])/255,b:Number.parseInt(q[3])/255,a:q[4]?Number.parseFloat(q[4]):1};return{r:0,g:0,b:0,a:1}}function P(k){let q=Math.round(k.r*255),z=Math.round(k.g*255),A=Math.round(k.b*255);if(k.a===1)return`#${q.toString(16).padStart(2,"0")}${z.toString(16).padStart(2,"0")}${A.toString(16).padStart(2,"0")}`;return`rgba(${q}, ${z}, ${A}, ${k.a})`}function b(k){return{name:k,id:`stx-story-${k.toLowerCase().replace(/\s+/g,"-")}`,api:"1.0.0",main:"code.js",ui:"ui.html",editorType:["figma"],capabilities:["inspect"],permissions:["currentuser"]}}function x(k){let q=k.map((z)=>z.name).join(", ");return`
// Figma Plugin Code to import STX components
// Run this in Figma's plugin console

const components = ${JSON.stringify(k.map((z)=>({name:z.name,props:z.props.map((A)=>({name:A.name,type:A.type}))})),null,2)};

async function importComponents() {
  for (const comp of components) {
    const frame = figma.createFrame();
    frame.name = comp.name;
    frame.resize(400, 300);

    // Add title
    const title = figma.createText();
    await figma.loadFontAsync({ family: "Inter", style: "Semi Bold" });
    title.fontName = { family: "Inter", style: "Semi Bold" };
    title.characters = comp.name;
    title.fontSize = 16;
    frame.appendChild(title);

    // Position on canvas
    frame.x = figma.viewport.center.x;
    frame.y = figma.viewport.center.y;
  }

  figma.notify('Imported ${q}');
}

importComponents();
`}export{b as generateFigmaPluginManifest,x as generateFigmaImportCode,P as figmaColorToCss,F as exportToFigmaFile,T as exportToFigma,M as cssColorToFigma};
