// @bun
var{defineProperty:E,getOwnPropertyNames:O,getOwnPropertyDescriptor:Q}=Object,R=Object.prototype.hasOwnProperty;function U(j){return this[j]}var $=(j)=>{var q=(N??=new WeakMap).get(j),z;if(q)return q;if(q=E({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var A of O(j))if(!R.call(q,A))E(q,A,{get:U.bind(j,A),enumerable:!(z=Q(j,A))||z.enumerable})}return N.set(j,q),q},N;var V=(j)=>j;function W(j,q){this[j]=V.bind(null,q)}var H=(j,q)=>{for(var z in q)E(j,z,{get:q[z],enumerable:!0,configurable:!0,set:W.bind(q,z)})};var L=(j,q)=>()=>(j&&(q=j(j=0)),q);var T=import.meta.require;import X from"fs";import Y from"path";var I=new Map,J=[],K=[],B=new Map;async function f(j){let q=j.config.setupFile;if(!q)return;let z=Y.resolve(j.root,q);try{await X.promises.access(z)}catch{return}let A={storyContext:j,registerComponent:(w,D)=>{I.set(w,D)},addCSS:(w)=>{J.push(w)},addScript:(w)=>{K.push(w)},setState:(w,D)=>{B.set(w,D)}};try{let w=await import(z);if(typeof w.default==="function")await w.default(A);else if(typeof w.setupStory==="function")await w.setupStory(A)}catch(w){console.warn(`Warning: Failed to load setup file: ${w}`)}}function G(){return I}function Z(){return J.join(`
`)}function _(){return K.join(`
`)}function k(){return B}function y(j){return B.get(j)}function M(){I.clear(),J=[],K=[],B.clear()}function d(){let j=Z(),q=_(),z="";if(j)z+=`<style>
${j}
</style>
`;if(q)z+=`<script>
${q}
</script>
`;return z}export{M as resetSetup,f as loadSetupFile,y as getState,d as getSetupHTML,k as getGlobalState,_ as getGlobalScripts,G as getGlobalComponents,Z as getGlobalCSS};
