// @bun
var{defineProperty:N,getOwnPropertyNames:T,getOwnPropertyDescriptor:U}=Object,R=Object.prototype.hasOwnProperty;function S(z){return this[z]}var p=(z)=>{var j=(Z??=new WeakMap).get(z),A;if(j)return j;if(j=N({},"__esModule",{value:!0}),z&&typeof z==="object"||typeof z==="function"){for(var E of T(z))if(!R.call(j,E))N(j,E,{get:S.bind(z,E),enumerable:!(A=U(z,E))||A.enumerable})}return Z.set(z,j),j},Z;var F=(z)=>z;function w(z,j){this[z]=F.bind(null,j)}var v=(z,j)=>{for(var A in j)N(z,A,{get:j[A],enumerable:!0,configurable:!0,set:w.bind(j,A)})};var $=(z,j)=>()=>(z&&(j=z(z=0)),j);var y=import.meta.require;function q(z){let j={...k,...z};return{enabled:j.enabled??!0,outDir:j.outDir??".stx/dist/story",storyMatch:j.storyMatch??["**/*.story.stx"],storyIgnored:j.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{..._,...j.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...j.theme},responsivePresets:j.responsivePresets??b,backgroundPresets:j.backgroundPresets??G,autoApplyContrastColor:j.autoApplyContrastColor??!1,setupFile:j.setupFile,port:j.port??6006}}function l(){return{...k}}var b,G,_,k;var B=$(()=>{b=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],G=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],_={file:"title",order:"asc",groups:[]},k={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:_,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:b,backgroundPresets:G,autoApplyContrastColor:!1,port:6006}});var h={};v(h,{updateContextTree:()=>x,updateContextStoryFiles:()=>C,createContext:()=>O});import P from"path";async function O(z){let j=z.root??process.cwd(),A;try{let I=await import(P.join(j,"stx.config.ts"));A=(I.default||I).story}catch{}let E={...A,...z.config},H=q(E);return{root:j,config:H,storyFiles:[],tree:void 0,mode:z.mode}}function C(z,j){z.storyFiles=j}function x(z,j){z.tree=j}var D=$(()=>{B()});D();import c from"fs";import Q from"path";async function u(z={}){console.log(`
\uD83D\uDCD6 Previewing STX Story build...
`);let j=await O({mode:"build"}),A=Q.resolve(j.root,j.config.outDir),E=Q.join(A,"index.html");try{await c.promises.access(E)}catch{console.log(`  \u274C No build found at ${j.config.outDir}`),console.log(`  Run "stx story build" first.
`);return}let H=z.port??4173,V=Bun.serve({port:H,async fetch(J){let K=new URL(J.url).pathname;if(K==="/")K="/index.html";let W=Q.join(A,K);try{let X=Bun.file(W);if(!await X.exists()){let M=`${W}.html`,Y=Bun.file(M);if(await Y.exists())return new Response(Y);return new Response("Not found",{status:404})}return new Response(X)}catch{return new Response("Error",{status:500})}}});if(console.log("  \uD83D\uDCDA Preview server running at:"),console.log(`     http://localhost:${H}
`),z.open)try{let{exec:J}=await import("child_process"),L=process.platform;J(`${L==="darwin"?"open":L==="win32"?"start":"xdg-open"} http://localhost:${H}`)}catch{}let I=()=>{console.log(`
  Shutting down...`),V.stop(),process.exit(0)};process.on("SIGINT",I),process.on("SIGTERM",I),await new Promise(()=>{})}var r=u;export{u as previewCommand,r as preview};
