// @bun
var{defineProperty:C,getOwnPropertyNames:J,getOwnPropertyDescriptor:K}=Object,N=Object.prototype.hasOwnProperty;function O(j){return this[j]}var W=(j)=>{var b=(E??=new WeakMap).get(j),w;if(b)return b;if(b=C({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var z of J(j))if(!N.call(b,z))C(b,z,{get:O.bind(j,z),enumerable:!(w=K(j,z))||w.enumerable})}return E.set(j,b),b},E;var P=(j)=>j;function Q(j,b){this[j]=P.bind(null,b)}var X=(j,b)=>{for(var w in b)C(j,w,{get:b[w],enumerable:!0,configurable:!0,set:Q.bind(b,w)})};var Y=(j,b)=>()=>(j&&(b=j(j=0)),b);var Z=import.meta.require;async function $(j,b,w,z={}){let x=b.story?.variants.find((B)=>B.id===w);if(!x)return"<!-- Variant not found -->";let q=x.source||"";if(q=R(q),q=S(q,x.state||{}),z.format)q=U(q);if(z.minify)q=V(q);return q}function R(j){let b=j;return b=b.replace(/@if\s*\([^)]+\)/g,"<!-- @if -->"),b=b.replace(/@endif/g,"<!-- @endif -->"),b=b.replace(/@foreach\s*\([^)]+\)/g,"<!-- @foreach -->"),b=b.replace(/@endforeach/g,"<!-- @endforeach -->"),b=b.replace(/@unless\s*\([^)]+\)/g,"<!-- @unless -->"),b=b.replace(/@endunless/g,"<!-- @endunless -->"),b=b.replace(/@component\s*\([^)]+\)/g,"<!-- @component -->"),b=b.replace(/@endcomponent/g,"<!-- @endcomponent -->"),b}function S(j,b){return j.replace(/\{\{\s*(\w+)\s*\}\}/g,(w,z)=>{if(z in b){let x=b[z];if(typeof x==="string")return F(x);if(typeof x==="number"||typeof x==="boolean")return String(x);return JSON.stringify(x)}return`{{ ${z} }}`})}function U(j){let b="",w=0,z=j.split(/>\s*</).map((x,q,B)=>{let A=x;if(q>0)A=`<${A}`;if(q<B.length-1)A=`${A}>`;return A});for(let x of z){let q=x.trim();if(!q)continue;if(q.startsWith("</")||q.startsWith("-->"))w=Math.max(0,w-1);if(b+=`${"  ".repeat(w)}${q}
`,q.startsWith("<")&&!q.startsWith("</")&&!q.startsWith("<!")&&!q.endsWith("/>")&&!q.includes("</"))w++}return b.trim()}function V(j){return j.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function F(j){return j.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function D(j){return`
    <div class="stx-compiled-output">
      <div class="stx-compiled-header">
        <span>Compiled HTML</span>
        <div class="stx-compiled-actions">
          <button onclick="window.__stxStory.copyCompiledOutput()" title="Copy">\uD83D\uDCCB</button>
          <button onclick="window.__stxStory.toggleMinify()" title="Toggle minify">\uD83D\uDDDC\uFE0F</button>
        </div>
      </div>
      <pre class="stx-compiled-code"><code>${F(j)}</code></pre>
    </div>
  `}function G(){return`
    .stx-compiled-output {
      display: flex;
      flex-direction: column;
      height: 100%;
    }
    .stx-compiled-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 12px;
      background: var(--bg-secondary);
      border-bottom: 1px solid var(--border);
      font-size: 12px;
      font-weight: 500;
    }
    .stx-compiled-actions {
      display: flex;
      gap: 4px;
    }
    .stx-compiled-actions button {
      padding: 4px 8px;
      border: 1px solid var(--border);
      border-radius: 4px;
      background: var(--bg);
      cursor: pointer;
    }
    .stx-compiled-actions button:hover {
      background: var(--bg-secondary);
    }
    .stx-compiled-code {
      flex: 1;
      margin: 0;
      padding: 12px;
      overflow: auto;
      font-family: var(--code-font-family);
      font-size: 12px;
      line-height: 1.5;
      background: var(--bg);
      white-space: pre-wrap;
      word-break: break-word;
    }
    .stx-compiled-code code {
      font-family: inherit;
    }
  `}function f(){return`
    window.__stxStory = window.__stxStory || {};

    window.__stxStory.showCompiledOutput = false;

    window.__stxStory.toggleCompiledOutput = function() {
      this.showCompiledOutput = !this.showCompiledOutput;
      const panel = document.querySelector('.stx-compiled-output');
      if (panel) {
        panel.style.display = this.showCompiledOutput ? 'flex' : 'none';
      }
    };

    window.__stxStory.copyCompiledOutput = function() {
      const code = document.querySelector('.stx-compiled-code code');
      if (code) {
        navigator.clipboard.writeText(code.textContent || '');
      }
    };
  `}export{G as getCompiledOutputStyles,f as getCompiledOutputScript,$ as getCompiledOutput,D as generateCompiledOutputPanel};
