// @bun
var{defineProperty:J,getOwnPropertyNames:W,getOwnPropertyDescriptor:X}=Object,Y=Object.prototype.hasOwnProperty;function Z(b){return this[b]}var R=(b)=>{var j=(N??=new WeakMap).get(b),z;if(j)return j;if(j=J({},"__esModule",{value:!0}),b&&typeof b==="object"||typeof b==="function"){for(var q of W(b))if(!Y.call(j,q))J(j,q,{get:Z.bind(b,q),enumerable:!(z=X(b,q))||z.enumerable})}return N.set(b,j),j},N;var _=(b)=>b;function $(b,j){this[b]=_.bind(null,j)}var M=(b,j)=>{for(var z in j)J(b,z,{get:j[z],enumerable:!0,configurable:!0,set:$.bind(j,z)})};var g=(b,j)=>()=>(b&&(j=b(b=0)),j);var E=import.meta.require;var x={};M(x,{processTransitionDirectives:()=>I,processTransitionAttributes:()=>S,performLeave:()=>C,performEnter:()=>k,generateTransitionRuntime:()=>y,generateTransitionCSS:()=>w});function P(b,j={}){return{enterFrom:j.enterClass||`${b}-enter-from`,enterActive:j.enterActiveClass||`${b}-enter-active`,enterTo:j.enterToClass||`${b}-enter-to`,leaveFrom:j.leaveClass||`${b}-leave-from`,leaveActive:j.leaveActiveClass||`${b}-leave-active`,leaveTo:j.leaveToClass||`${b}-leave-to`}}function V(b){let j=getComputedStyle(b),z=j.transitionDuration||"0s",q=j.animationDuration||"0s",B=(A)=>{let F=A.match(/^([\d.]+)(s|ms)?$/);if(!F)return 0;let G=parseFloat(F[1]);return(F[2]||"s")==="ms"?G:G*1000};return Math.max(B(z),B(q))}function Q(b,j){return new Promise((z)=>{let q=j??V(b);if(q===0){z();return}let B=!1,A=()=>{if(B)return;B=!0,b.removeEventListener("transitionend",F),b.removeEventListener("animationend",F),z()},F=(G)=>{if(G.target===b)A()};b.addEventListener("transitionend",F),b.addEventListener("animationend",F),setTimeout(A,q+50)})}function U(b){b.offsetHeight}async function k(b,j={}){let z=j.name||"stx",q=P(z,j),B=typeof j.duration==="object"?j.duration.enter:j.duration;if(j.onBeforeEnter?.(b),b.classList.add(q.enterFrom),b.classList.add(q.enterActive),U(b),b.classList.remove(q.enterFrom),b.classList.add(q.enterTo),j.onEnter)await new Promise((A)=>{j.onEnter(b,A)});else await Q(b,B);b.classList.remove(q.enterActive),b.classList.remove(q.enterTo),j.onAfterEnter?.(b)}async function C(b,j={}){let z=j.name||"stx",q=P(z,j),B=typeof j.duration==="object"?j.duration.leave:j.duration;if(j.onBeforeLeave?.(b),b.classList.add(q.leaveFrom),b.classList.add(q.leaveActive),U(b),b.classList.remove(q.leaveFrom),b.classList.add(q.leaveTo),j.onLeave)await new Promise((A)=>{j.onLeave(b,A)});else await Q(b,B);b.classList.remove(q.leaveActive),b.classList.remove(q.leaveTo),j.onAfterLeave?.(b)}function I(b,j={},z){let q=/@transition\s*\(([^)]*)\)([\s\S]*?)@endtransition/gi;return b.replace(q,(B,A,F)=>{let G=f(A),H=G.name||"stx",K=G.duration||300,L=`stx-transition-${Math.random().toString(36).slice(2,9)}`;return`
<div
  class="stx-transition-wrapper"
  data-transition="${H}"
  data-transition-id="${L}"
  data-transition-duration="${K}"
  ${G.mode?`data-transition-mode="${G.mode}"`:""}
>
  ${F.trim()}
</div>
<script>
(function() {
  const wrapper = document.querySelector('[data-transition-id="${L}"]');
  if (!wrapper) return;

  const name = '${H}';
  const duration = ${K};

  // Observe for child changes to trigger transitions
  const observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
      mutation.addedNodes.forEach(function(node) {
        if (node.nodeType === 1) {
          window.STX?.transition?.enter(node, { name: name, duration: duration });
        }
      });
      mutation.removedNodes.forEach(function(node) {
        if (node.nodeType === 1) {
          // Leave transition handled before removal
        }
      });
    });
  });

  observer.observe(wrapper, { childList: true });

  // Initial enter transition for existing children
  Array.from(wrapper.children).forEach(function(child) {
    window.STX?.transition?.enter(child, { name: name, duration: duration });
  });
})();
</script>
`})}function f(b){let j={},z=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,q;while((q=z.exec(b))!==null){let B=q[1],A=q[2]||q[3]||q[4]||q[5];switch(B){case"name":j.name=A;break;case"duration":j.duration=parseInt(A,10);break;case"mode":j.mode=A;break;case"easing":j.easing=A;break}}return j}function w(){return`
/* STX Transition Presets */

/* Fade */
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}
.fade-enter-to,
.fade-leave-from {
  opacity: 1;
}

/* Slide Up */
.slide-up-enter-from,
.slide-up-leave-to {
  opacity: 0;
  transform: translateY(20px);
}
.slide-up-enter-active,
.slide-up-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.slide-up-enter-to,
.slide-up-leave-from {
  opacity: 1;
  transform: translateY(0);
}

/* Slide Down */
.slide-down-enter-from,
.slide-down-leave-to {
  opacity: 0;
  transform: translateY(-20px);
}
.slide-down-enter-active,
.slide-down-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.slide-down-enter-to,
.slide-down-leave-from {
  opacity: 1;
  transform: translateY(0);
}

/* Slide Left */
.slide-left-enter-from {
  opacity: 0;
  transform: translateX(20px);
}
.slide-left-leave-to {
  opacity: 0;
  transform: translateX(-20px);
}
.slide-left-enter-active,
.slide-left-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.slide-left-enter-to,
.slide-left-leave-from {
  opacity: 1;
  transform: translateX(0);
}

/* Slide Right */
.slide-right-enter-from {
  opacity: 0;
  transform: translateX(-20px);
}
.slide-right-leave-to {
  opacity: 0;
  transform: translateX(20px);
}
.slide-right-enter-active,
.slide-right-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.slide-right-enter-to,
.slide-right-leave-from {
  opacity: 1;
  transform: translateX(0);
}

/* Scale */
.scale-enter-from,
.scale-leave-to {
  opacity: 0;
  transform: scale(0.9);
}
.scale-enter-active,
.scale-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.scale-enter-to,
.scale-leave-from {
  opacity: 1;
  transform: scale(1);
}

/* Scale Up (grow) */
.scale-up-enter-from,
.scale-up-leave-to {
  opacity: 0;
  transform: scale(0.5);
}
.scale-up-enter-active,
.scale-up-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.scale-up-enter-to,
.scale-up-leave-from {
  opacity: 1;
  transform: scale(1);
}

/* Bounce */
.bounce-enter-active {
  animation: bounce-in 0.5s;
}
.bounce-leave-active {
  animation: bounce-in 0.5s reverse;
}
@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* Flip */
.flip-enter-from,
.flip-leave-to {
  opacity: 0;
  transform: perspective(400px) rotateY(90deg);
}
.flip-enter-active,
.flip-leave-active {
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.flip-enter-to,
.flip-leave-from {
  opacity: 1;
  transform: perspective(400px) rotateY(0);
}

/* Zoom */
.zoom-enter-from,
.zoom-leave-to {
  opacity: 0;
  transform: scale(0);
}
.zoom-enter-active,
.zoom-leave-active {
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.zoom-enter-to,
.zoom-leave-from {
  opacity: 1;
  transform: scale(1);
}

/* Collapse (height) */
.collapse-enter-from,
.collapse-leave-to {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
}
.collapse-enter-active,
.collapse-leave-active {
  transition: opacity 0.3s ease, max-height 0.3s ease;
  overflow: hidden;
}
.collapse-enter-to,
.collapse-leave-from {
  opacity: 1;
  max-height: 1000px;
}
`}function y(){return`
// STX Transition Runtime
(function() {
  if (typeof window === 'undefined') return;

  window.STX = window.STX || {};
  window.STX.transition = {
    // Perform enter transition
    enter: function(el, options) {
      options = options || {};
      const name = options.name || 'stx';
      const duration = options.duration || 300;

      const classes = {
        enterFrom: name + '-enter-from',
        enterActive: name + '-enter-active',
        enterTo: name + '-enter-to'
      };

      // Add initial classes
      el.classList.add(classes.enterFrom);
      el.classList.add(classes.enterActive);

      // Force reflow
      void el.offsetHeight;

      // Start transition
      el.classList.remove(classes.enterFrom);
      el.classList.add(classes.enterTo);

      // Cleanup after transition
      setTimeout(function() {
        el.classList.remove(classes.enterActive);
        el.classList.remove(classes.enterTo);
      }, duration + 50);

      return el;
    },

    // Perform leave transition
    leave: function(el, options) {
      return new Promise(function(resolve) {
        options = options || {};
        const name = options.name || 'stx';
        const duration = options.duration || 300;

        const classes = {
          leaveFrom: name + '-leave-from',
          leaveActive: name + '-leave-active',
          leaveTo: name + '-leave-to'
        };

        // Add initial classes
        el.classList.add(classes.leaveFrom);
        el.classList.add(classes.leaveActive);

        // Force reflow
        void el.offsetHeight;

        // Start transition
        el.classList.remove(classes.leaveFrom);
        el.classList.add(classes.leaveTo);

        // Cleanup and resolve after transition
        setTimeout(function() {
          el.classList.remove(classes.leaveActive);
          el.classList.remove(classes.leaveTo);
          resolve(el);
        }, duration + 50);
      });
    },

    // Toggle with transition
    toggle: function(el, show, options) {
      if (show) {
        el.style.display = '';
        return this.enter(el, options);
      }
else {
        return this.leave(el, options).then(function() {
          el.style.display = 'none';
          return el;
        });
      }
    }
  };

  console.log('[stx] Transition runtime initialized');
})();
`}function S(b){let j=/@transition\.([a-z-]+)(?:\.(\d+))?="([^"]+)"/gi;return b.replace(j,(z,q,B,A)=>{let F=B||"300",G=`stx-t-${Math.random().toString(36).slice(2,7)}`;return`data-stx-transition="${q}" data-stx-transition-duration="${F}" data-stx-transition-condition="${A}" data-stx-transition-id="${G}"`})}export{I as processTransitionDirectives,S as processTransitionAttributes,C as performLeave,k as performEnter,y as generateTransitionRuntime,w as generateTransitionCSS};
