// @bun
var{defineProperty:Q,getOwnPropertyNames:V,getOwnPropertyDescriptor:W}=Object,X=Object.prototype.hasOwnProperty;function Y(A){return this[A]}var z=(A)=>{var B=(T??=new WeakMap).get(A),C;if(B)return B;if(B=Q({},"__esModule",{value:!0}),A&&typeof A==="object"||typeof A==="function"){for(var F of V(A))if(!X.call(B,F))Q(B,F,{get:Y.bind(A,F),enumerable:!(C=W(A,F))||C.enumerable})}return T.set(A,B),B},T;var Z=(A)=>A;function _(A,B){this[A]=Z.bind(null,B)}var q=(A,B)=>{for(var C in B)Q(A,C,{get:B[C],enumerable:!0,configurable:!0,set:_.bind(B,C)})};var $=(A,B)=>()=>(A&&(B=A(A=0)),B);var k=import.meta.require;function j(A){if(N.set(A.name,A),A.client)S.set(A.name,A.client)}function h(A){return N.get(A)}function P(){return Array.from(N.values())}function I(A){return S.delete(A),N.delete(A)}function G(A){return j(A),{name:A.name,hasEndTag:A.hasEndTag??!0,description:A.description,handler:async(C,F,H,L)=>{let J=w(F,A.defaults);if(A.validate){let E=A.validate(J);if(E!==!0){let M=typeof E==="string"?E:`Invalid parameters for @${A.name}`;throw Error(M)}}let K=C;if(A.transform)K=await A.transform(C,J,H,L);if(A.clientScript){let E=A.clientScript(J);K+=`<script>${E}</script>`}if(A.css){let E=A.css(J);K+=`<style>${E}</style>`}return K}}}function y(A,B){let C=typeof B==="function"?{mounted:B}:B;return S.set(A,C),C}function w(A,B){let C={...B};for(let F of A){let H=F.indexOf(":"),L=F.indexOf("="),J=H>=0&&(L<0||H<L)?H:L;if(J>=0){let K=F.slice(0,J).trim(),E=F.slice(J+1).trim();if(E==="true")E=!0;else if(E==="false")E=!1;else if(E==="null")E=null;else if(!Number.isNaN(Number(E)))E=Number(E);else if(typeof E==="string"&&E.startsWith("{"))try{E=JSON.parse(E)}catch{}C[K]=E}else{let K=Object.keys(C).filter((E)=>!B||!(E in B)).length;C[K===0?"value":`arg${K}`]=F}}return C}function R(){return[G({name:"uppercase",description:"Convert content to uppercase",transform:(A)=>A.toUpperCase()}),G({name:"lowercase",description:"Convert content to lowercase",transform:(A)=>A.toLowerCase()}),G({name:"capitalize",description:"Capitalize first letter of content",transform:(A)=>A.charAt(0).toUpperCase()+A.slice(1)}),G({name:"trim",description:"Remove leading and trailing whitespace",transform:(A)=>A.trim()}),G({name:"truncate",description:"Truncate content to specified length",defaults:{length:100,suffix:"..."},transform:(A,{length:B,suffix:C})=>A.length>B?A.slice(0,B)+C:A}),G({name:"highlight",description:"Highlight content with background color",defaults:{color:"yellow"},transform:(A,{color:B})=>`<mark style="background-color: ${B}; padding: 0.1em 0.2em; border-radius: 0.2em;">${A}</mark>`}),G({name:"badge",description:"Create a badge/tag",defaults:{variant:"default",color:""},transform:(A,{variant:B,color:C})=>{let F={default:"background: #e5e7eb; color: #374151;",primary:"background: #3b82f6; color: white;",success:"background: #10b981; color: white;",warning:"background: #f59e0b; color: white;",danger:"background: #ef4444; color: white;",info:"background: #06b6d4; color: white;"};return`<span style="${C?`background: ${C}; color: white;`:F[B]||F.default} padding: 0.25em 0.5em; border-radius: 9999px; font-size: 0.875em; font-weight: 500;">${A}</span>`}}),G({name:"code",description:"Style content as inline code",transform:(A)=>`<code style="background: #f3f4f6; padding: 0.2em 0.4em; border-radius: 0.25em; font-family: ui-monospace, monospace; font-size: 0.875em;">${A}</code>`}),G({name:"tooltip",description:"Add a tooltip to content",defaults:{text:"",position:"top"},hasEndTag:!0,transform:(A,{text:B,position:C})=>`<span class="stx-tooltip" data-tooltip="${B}" data-tooltip-position="${C}" style="position: relative; cursor: help;">${A}</span>`,css:()=>`
        .stx-tooltip::after {
          content: attr(data-tooltip);
          position: absolute;
          bottom: 100%;
          left: 50%;
          transform: translateX(-50%);
          padding: 0.5em 0.75em;
          background: #1f2937;
          color: white;
          font-size: 0.75rem;
          border-radius: 0.25rem;
          white-space: nowrap;
          opacity: 0;
          visibility: hidden;
          transition: opacity 0.2s, visibility 0.2s;
          z-index: 1000;
          margin-bottom: 0.25rem;
        }
        .stx-tooltip:hover::after {
          opacity: 1;
          visibility: visible;
        }
      `}),G({name:"clipboard",description:"Add copy to clipboard functionality",defaults:{label:"Copy"},transform:(A,{label:B})=>{let C=`clipboard-${Date.now()}-${Math.random().toString(36).slice(2)}`;return`
          <span class="stx-clipboard" data-clipboard-id="${C}">
            <span class="stx-clipboard-content">${A}</span>
            <button type="button" class="stx-clipboard-btn" onclick="navigator.clipboard.writeText(document.querySelector('[data-clipboard-id=\\'${C}\\'] .stx-clipboard-content').textContent).then(() => { this.textContent = 'Copied!'; setTimeout(() => this.textContent = '${B}', 2000); })">${B}</button>
          </span>
        `},css:()=>`
        .stx-clipboard {
          display: inline-flex;
          align-items: center;
          gap: 0.5em;
        }
        .stx-clipboard-btn {
          padding: 0.25em 0.5em;
          font-size: 0.75em;
          background: #e5e7eb;
          border: none;
          border-radius: 0.25em;
          cursor: pointer;
        }
        .stx-clipboard-btn:hover {
          background: #d1d5db;
        }
      `}),G({name:"time",description:"Display relative time",defaults:{date:""},hasEndTag:!1,transform:(A,{date:B})=>{let C=B?new Date(B).getTime():Date.now();return`<time datetime="${new Date(C).toISOString()}" data-stx-relative-time="${C}"></time>`},clientScript:()=>`
        document.querySelectorAll('[data-stx-relative-time]').forEach(el => {
          const timestamp = parseInt(el.dataset.stxRelativeTime);
          const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
          const diff = timestamp - Date.now();
          const seconds = Math.floor(diff / 1000);
          const minutes = Math.floor(seconds / 60);
          const hours = Math.floor(minutes / 60);
          const days = Math.floor(hours / 24);

          if (Math.abs(days) > 0) el.textContent = rtf.format(days, 'day');
          else if (Math.abs(hours) > 0) el.textContent = rtf.format(hours, 'hour');
          else if (Math.abs(minutes) > 0) el.textContent = rtf.format(minutes, 'minute');
          else el.textContent = rtf.format(seconds, 'second');
        });
      `}),G({name:"currency",description:"Format number as currency",defaults:{amount:0,currency:"USD",locale:"en-US"},hasEndTag:!1,transform:(A,{amount:B,currency:C,locale:F})=>{return new Intl.NumberFormat(F,{style:"currency",currency:C}).format(B)}}),G({name:"number",description:"Format number with locale",defaults:{value:0,decimals:2,locale:"en-US"},hasEndTag:!1,transform:(A,{value:B,decimals:C,locale:F})=>{return new Intl.NumberFormat(F,{minimumFractionDigits:C,maximumFractionDigits:C}).format(B)}}),G({name:"pluralize",description:"Pluralize text based on count",defaults:{count:0,singular:"",plural:""},hasEndTag:!1,transform:(A,{count:B,singular:C,plural:F})=>{let H=B===1?C:F||C+"s";return`${B} ${H}`}})]}function D(){return`
// STX Directive Runtime
(function() {
  if (typeof window === 'undefined') return;

  window.STX = window.STX || {};
  window.STX.directives = window.STX.directives || {};

  // Register a client-side directive
  window.STX.directive = function(name, definition) {
    if (typeof definition === 'function') {
      definition = { mounted: definition };
    }
    window.STX.directives[name] = definition;
  };

  // Apply directive to element
  window.STX.applyDirective = function(el, name, value, arg, modifiers) {
    const directive = window.STX.directives[name];
    if (!directive) {
      console.warn('[stx] Unknown directive:', name);
      return;
    }

    const binding = {
      value: value,
      arg: arg,
      modifiers: modifiers || {},
      dir: directive
    };

    // Store binding on element for updates
    el.__stx_directives__ = el.__stx_directives__ || {};
    el.__stx_directives__[name] = binding;

    // Call lifecycle hooks
    if (directive.created) directive.created(el, binding);
    if (directive.beforeMount) directive.beforeMount(el, binding);

    // Defer mounted until DOM is ready
    requestAnimationFrame(function() {
      if (directive.mounted) directive.mounted(el, binding);
    });
  };

  // Update directive on element
  window.STX.updateDirective = function(el, name, newValue) {
    const binding = el.__stx_directives__ && el.__stx_directives__[name];
    if (!binding) return;

    const directive = binding.dir;
    const oldValue = binding.value;
    binding.oldValue = oldValue;
    binding.value = newValue;

    if (directive.beforeUpdate) directive.beforeUpdate(el, binding);
    if (directive.updated) directive.updated(el, binding);
  };

  // Remove directive from element
  window.STX.removeDirective = function(el, name) {
    const binding = el.__stx_directives__ && el.__stx_directives__[name];
    if (!binding) return;

    const directive = binding.dir;
    if (directive.beforeUnmount) directive.beforeUnmount(el, binding);
    if (directive.unmounted) directive.unmounted(el, binding);

    delete el.__stx_directives__[name];
  };

  // Auto-apply directives on page load
  document.addEventListener('DOMContentLoaded', function() {
    document.querySelectorAll('[data-stx-directive]').forEach(function(el) {
      const directives = el.dataset.stxDirective.split(';');
      directives.forEach(function(d) {
        const [name, value] = d.split(':').map(s => s.trim());
        window.STX.applyDirective(el, name, value);
      });
    });
  });

  console.log('[stx] Directive runtime initialized');
})();
`}function x(A){let B=/v-(\w+)(?::(\w+))?(?:\.([\w.]+))?="([^"]*)"/g;return A.replace(B,(C,F,H,L,J)=>{let E=(L?L.split("."):[]).reduce((M,U)=>{return M[U]=!0,M},{});return`data-stx-directive="${F}:${J}" data-stx-directive-arg="${H||""}" data-stx-directive-modifiers='${JSON.stringify(E)}'`})}var N,S;var O=$(()=>{N=new Map,S=new Map});O();export{I as unregisterDirective,j as registerDirective,x as processDirectiveAttributes,P as getDirectives,h as getDirective,D as generateDirectiveRuntime,G as defineDirective,y as defineClientDirective,R as createBuiltinDirectives};
