{"version":3,"sources":["../../src/utils/errors.ts","../../src/utils/dom.ts","../../src/utils/debug.ts","../../src/utils/performance.ts","../../src/utils/index.ts"],"names":["StegaError","createErrorInfo","type","context","error","additionalData","handleStegaError","errorInfo","handleDOMError","handleContextError","contextName","DOMService","tag","className","element","styles","property","value","rect","x1","y1","x2","y2","pointX","pointY","elements","closestElement","minDistance","distance","event","handler","options","DebugLogger","_DebugLogger","__spreadValues","_a","_b","globalDebugLogger","message","args","prefix","scopeName","__spreadProps","initDebugLogger","enabled","getDebugLogger","debugLog","debugWarn","debugError","createScopedLogger","throttle","func","delay","timeoutId","lastExecTime","throttledFunc","currentTime","timeSinceLastExec","debounce","debouncedFunc","createElementCache","query","ttl","cache","lastCacheTime","now","cn","inputs","twMerge","clsx","sendPreprEvent","data"],"mappings":"igBAAO,IAAMA,CAAAA,CAAa,CACxB,aAAA,CAAe,sBACf,cAAA,CAAgB,sBAAA,CAChB,uBAAA,CAAyB,yBAAA,CACzB,iBAAA,CAAmB,mBACrB,EAqBO,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACW,CACX,OAAO,CACL,KAAAH,CAAAA,CACA,OAAA,CAAAC,EACA,OAAA,CAASC,CAAAA,CAAM,OAAA,CACf,SAAA,CAAW,IAAI,IAAA,GAAO,WAAA,EAAY,CAClC,KAAA,CAAOA,CAAAA,CAAM,KAAA,CACb,cAAA,CAAAC,CACF,CACF,CAEO,SAASC,CAAAA,CACdF,CAAAA,CACAD,CAAAA,CACAE,EACA,CACA,IAAME,EAAYN,CAAAA,CAChBD,CAAAA,CAAW,cACXG,CAAAA,CACAC,CAAAA,CACAC,CACF,CAAA,CAEA,OAAA,OAAA,CAAQ,KAAA,CAAM,eAAgBE,CAAS,CAAA,CAGnC,OAAA,CAAQ,GAAA,CAAI,QAAA,CAITA,CACT,CAEO,SAASC,CAAAA,CAAeJ,CAAAA,CAAcD,CAAAA,CAAiB,CAC5D,IAAMI,EAAYN,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,IAAMjC,CAAAA,CAAUJ,CAAAA,CAAA,CACd,IAAA,CAAM,oBACN,KAAA,CAAAL,CAAAA,CAAAA,CACG0C,CAAAA,CAAAA,CAIL,MAAA,CAAO,aAAA,CACL,IAAI,YAAY,mBAAA,CAAqB,CAAE,MAAA,CAAQjC,CAAQ,CAAC,CAC1D,EAGI,MAAA,CAAO,MAAA,EAAU,MAAA,CAAO,MAAA,GAAW,MAAA,EACrC,MAAA,CAAO,OAAO,WAAA,CAAYA,CAAAA,CAAS,GAAG,EAE1C,CACF","file":"index.cjs","sourcesContent":["export const StegaError = {\n  DECODE_FAILED: 'STEGA_DECODE_FAILED',\n  INVALID_FORMAT: 'STEGA_INVALID_FORMAT',\n  DOM_MANIPULATION_FAILED: 'DOM_MANIPULATION_FAILED',\n  CONTEXT_NOT_FOUND: 'CONTEXT_NOT_FOUND',\n} as const;\n\nexport type StegaErrorType = (typeof StegaError)[keyof typeof StegaError];\n\n// Define specific types for error additional data\nexport interface ErrorAdditionalData {\n  input?: string;\n  element?: HTMLElement;\n  context?: string;\n  [key: string]: string | HTMLElement | undefined;\n}\n\nexport interface ErrorInfo {\n  type: StegaErrorType;\n  context: string;\n  message: string;\n  timestamp: string;\n  stack?: string;\n  additionalData?: ErrorAdditionalData;\n}\n\nexport function createErrorInfo(\n  type: StegaErrorType,\n  context: string,\n  error: Error,\n  additionalData?: ErrorAdditionalData\n): ErrorInfo {\n  return {\n    type,\n    context,\n    message: error.message,\n    timestamp: new Date().toISOString(),\n    stack: error.stack,\n    additionalData,\n  };\n}\n\nexport function handleStegaError(\n  error: Error,\n  context: string,\n  additionalData?: ErrorAdditionalData\n) {\n  const errorInfo = createErrorInfo(\n    StegaError.DECODE_FAILED,\n    context,\n    error,\n    additionalData\n  );\n\n  console.error('Stega Error:', errorInfo);\n\n  // In production, you might want to send this to an error tracking service\n  if (process.env.NODE_ENV === 'production') {\n    // sendToErrorTrackingService(errorInfo);\n  }\n\n  return errorInfo;\n}\n\nexport function handleDOMError(error: Error, context: string) {\n  const errorInfo = createErrorInfo(\n    StegaError.DOM_MANIPULATION_FAILED,\n    context,\n    error\n  );\n\n  console.error('DOM Error:', errorInfo);\n  return errorInfo;\n}\n\nexport function handleContextError(contextName: string) {\n  const error = new Error(`${contextName} must be used within its provider`);\n  const errorInfo = createErrorInfo(\n    StegaError.CONTEXT_NOT_FOUND,\n    contextName,\n    error\n  );\n\n  console.error('Context Error:', errorInfo);\n  throw error;\n}\n","import { handleDOMError } from './errors';\n\nexport class DOMService {\n  /**\n   * Creates an HTML element with specified tag and class name\n   */\n  static createElement(tag: string, className: string): HTMLElement {\n    try {\n      const element = document.createElement(tag);\n      element.className = className;\n      return element;\n    } catch (error) {\n      handleDOMError(error as Error, 'createElement');\n      throw error;\n    }\n  }\n\n  /**\n   * Appends an element to the document body\n   */\n  static appendToBody(element: HTMLElement): void {\n    try {\n      document.body.appendChild(element);\n    } catch (error) {\n      handleDOMError(error as Error, 'appendToBody');\n      throw error;\n    }\n  }\n\n  /**\n   * Removes an element from the document body\n   */\n  static removeFromBody(element: HTMLElement): void {\n    try {\n      if (element.parentNode) {\n        element.parentNode.removeChild(element);\n      }\n    } catch (error) {\n      handleDOMError(error as Error, 'removeFromBody');\n      throw error;\n    }\n  }\n\n  /**\n   * Sets multiple CSS properties on an element\n   */\n  static setElementStyles(\n    element: HTMLElement,\n    styles: Record<string, string>\n  ): void {\n    try {\n      Object.entries(styles).forEach(([property, value]) => {\n        element.style.setProperty(property, value);\n      });\n    } catch (error) {\n      handleDOMError(error as Error, 'setElementStyles');\n      throw error;\n    }\n  }\n\n  /**\n   * Gets the bounding rectangle of an element\n   */\n  static getElementRect(element: HTMLElement): DOMRect {\n    try {\n      return element.getBoundingClientRect();\n    } catch (error) {\n      handleDOMError(error as Error, 'getElementRect');\n      throw error;\n    }\n  }\n\n  /**\n   * Checks if an element is in the viewport\n   */\n  static isElementInViewport(element: HTMLElement): boolean {\n    try {\n      const rect = this.getElementRect(element);\n      return (\n        rect.top >= 0 &&\n        rect.left >= 0 &&\n        rect.bottom <=\n          (window.innerHeight || document.documentElement.clientHeight) &&\n        rect.right <=\n          (window.innerWidth || document.documentElement.clientWidth)\n      );\n    } catch (error) {\n      handleDOMError(error as Error, 'isElementInViewport');\n      return false;\n    }\n  }\n\n  /**\n   * Calculates distance between two points\n   */\n  static calculateDistance(\n    x1: number,\n    y1: number,\n    x2: number,\n    y2: number\n  ): number {\n    return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));\n  }\n\n  /**\n   * Finds the closest element to a point from a list of elements\n   */\n  static findClosestElement(\n    pointX: number,\n    pointY: number,\n    elements: NodeListOf<Element>\n  ): HTMLElement | null {\n    try {\n      let closestElement: HTMLElement | null = null;\n      let minDistance = Infinity;\n\n      elements.forEach(element => {\n        const rect = this.getElementRect(element as HTMLElement);\n        const distance = this.calculateDistance(\n          pointX,\n          pointY,\n          rect.left + rect.width / 2,\n          rect.top + rect.height / 2\n        );\n\n        if (distance < minDistance) {\n          minDistance = distance;\n          closestElement = element as HTMLElement;\n        }\n      });\n\n      return closestElement;\n    } catch (error) {\n      handleDOMError(error as Error, 'findClosestElement');\n      return null;\n    }\n  }\n\n  /**\n   * Safely adds event listeners\n   */\n  static addEventListener(\n    element: EventTarget,\n    event: string,\n    handler: EventListener,\n    options?: AddEventListenerOptions\n  ): void {\n    try {\n      element.addEventListener(event, handler, options);\n    } catch (error) {\n      handleDOMError(error as Error, 'addEventListener');\n      throw error;\n    }\n  }\n\n  /**\n   * Safely removes event listeners\n   */\n  static removeEventListener(\n    element: EventTarget,\n    event: string,\n    handler: EventListener,\n    options?: EventListenerOptions\n  ): void {\n    try {\n      element.removeEventListener(event, handler, options);\n    } catch (error) {\n      handleDOMError(error as Error, 'removeEventListener');\n      throw error;\n    }\n  }\n}\n","/**\n * Debug utility for Prepr Next.js package\n * Provides centralized debug logging with performance optimizations\n */\n\n// Define specific types for debug arguments\nexport type DebugArg = string | number | boolean | null | undefined | object;\n\ninterface DebugOptions {\n  enabled?: boolean;\n  prefix?: string;\n}\n\nclass DebugLogger {\n  private options: DebugOptions;\n\n  constructor(options: DebugOptions) {\n    this.options = {\n      prefix: '[Prepr]',\n      ...options,\n    };\n  }\n\n  /**\n   * Check if debug is enabled - checks both local and global state\n   */\n  private isEnabled(): boolean {\n    // If this logger has a local enabled state, use it\n    if (this.options.enabled !== undefined) {\n      return this.options.enabled;\n    }\n\n    // Otherwise, check the global logger state\n    return globalDebugLogger?.options?.enabled ?? false;\n  }\n\n  /**\n   * Log a debug message if debug is enabled\n   */\n  log(message: string, ...args: DebugArg[]): void {\n    if (!this.isEnabled()) return;\n\n    const prefix = this.options.prefix;\n    console.log(`${prefix} ${message}`, ...args);\n  }\n\n  /**\n   * Log a debug warning if debug is enabled\n   */\n  warn(message: string, ...args: DebugArg[]): void {\n    if (!this.isEnabled()) return;\n\n    const prefix = this.options.prefix;\n    console.warn(`${prefix} ${message}`, ...args);\n  }\n\n  /**\n   * Log a debug error if debug is enabled\n   */\n  error(message: string, ...args: DebugArg[]): void {\n    if (!this.isEnabled()) return;\n\n    const prefix = this.options.prefix;\n    console.error(`${prefix} ${message}`, ...args);\n  }\n\n  /**\n   * Create a scoped logger with additional context\n   */\n  scope(scopeName: string): DebugLogger {\n    return new DebugLogger({\n      ...this.options,\n      prefix: `${this.options.prefix}[${scopeName}]`,\n    });\n  }\n}\n\n// Global debug instance\nlet globalDebugLogger: DebugLogger | null = null;\n\n/**\n * Initialize the debug logger\n */\nexport function initDebugLogger(enabled: boolean = false): void {\n  globalDebugLogger = new DebugLogger({ enabled });\n}\n\n/**\n * Get the debug logger instance\n */\nexport function getDebugLogger(): DebugLogger {\n  if (!globalDebugLogger) {\n    // Fallback to disabled logger if not initialized\n    globalDebugLogger = new DebugLogger({ enabled: false });\n  }\n  return globalDebugLogger;\n}\n\n/**\n * Convenience function for logging\n */\nexport function debugLog(message: string, ...args: DebugArg[]): void {\n  getDebugLogger().log(message, ...args);\n}\n\n/**\n * Convenience function for warning\n */\nexport function debugWarn(message: string, ...args: DebugArg[]): void {\n  getDebugLogger().warn(message, ...args);\n}\n\n/**\n * Convenience function for errors\n */\nexport function debugError(message: string, ...args: DebugArg[]): void {\n  getDebugLogger().error(message, ...args);\n}\n\n/**\n * Create a scoped debug logger that dynamically checks global debug state\n */\nexport function createScopedLogger(scopeName: string): DebugLogger {\n  // Create a scoped logger without its own enabled state\n  // This allows it to dynamically check the global logger state\n  return new DebugLogger({\n    prefix: `[Prepr][${scopeName}]`,\n  });\n}\n","// Performance utilities\n\n/**\n * Throttled function with cancellation support\n */\nexport interface ThrottledFunction<T extends (...args: any[]) => any> {\n  (...args: Parameters<T>): void;\n  cancel(): void;\n}\n\n/**\n * Improved throttle function with better memory management and cancellation\n * @param func - The function to throttle\n * @param delay - The delay in milliseconds\n * @returns Throttled function with cancel method\n */\nexport function throttle<T extends (...args: any[]) => any>(\n  func: T,\n  delay: number\n): ThrottledFunction<T> {\n  let timeoutId: NodeJS.Timeout | null = null;\n  let lastExecTime = 0;\n\n  const throttledFunc = ((...args: Parameters<T>) => {\n    const currentTime = Date.now();\n    const timeSinceLastExec = currentTime - lastExecTime;\n\n    if (timeSinceLastExec >= delay) {\n      func(...args);\n      lastExecTime = currentTime;\n    } else {\n      if (timeoutId) {\n        clearTimeout(timeoutId);\n      }\n      timeoutId = setTimeout(() => {\n        func(...args);\n        lastExecTime = Date.now();\n        timeoutId = null;\n      }, delay - timeSinceLastExec);\n    }\n  }) as ThrottledFunction<T>;\n\n  throttledFunc.cancel = () => {\n    if (timeoutId) {\n      clearTimeout(timeoutId);\n      timeoutId = null;\n    }\n  };\n\n  return throttledFunc;\n}\n\n/**\n * Debounce function with cancellation support\n * @param func - The function to debounce\n * @param delay - The delay in milliseconds\n * @returns Debounced function with cancel method\n */\nexport function debounce<T extends (...args: any[]) => any>(\n  func: T,\n  delay: number\n): ThrottledFunction<T> {\n  let timeoutId: NodeJS.Timeout | null = null;\n\n  const debouncedFunc = ((...args: Parameters<T>) => {\n    if (timeoutId) {\n      clearTimeout(timeoutId);\n    }\n    timeoutId = setTimeout(() => {\n      func(...args);\n      timeoutId = null;\n    }, delay);\n  }) as ThrottledFunction<T>;\n\n  debouncedFunc.cancel = () => {\n    if (timeoutId) {\n      clearTimeout(timeoutId);\n      timeoutId = null;\n    }\n  };\n\n  return debouncedFunc;\n}\n\n// Simple DOM element cache for querySelectorAll\nexport function createElementCache<T extends Element = Element>(\n  query: string,\n  ttl: number = 1000\n) {\n  let cache: NodeListOf<T> | null = null;\n  let lastCacheTime = 0;\n  return () => {\n    const now = Date.now();\n    if (!cache || now - lastCacheTime > ttl) {\n      cache = document.querySelectorAll<T>(query);\n      lastCacheTime = now;\n    }\n    return cache;\n  };\n}\n","import { ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\nimport { PreprEventType } from '../types';\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\n// Define specific types for Prepr events\nexport interface PreprEventData {\n  readonly segment?: string;\n  readonly variant?: string;\n  readonly editMode?: boolean;\n  readonly [key: string]: string | boolean | number | undefined;\n}\n\n/**\n * Sends a Prepr event to both the current window and parent window\n * @param event - The event type to send\n * @param data - Optional event data\n */\nexport function sendPreprEvent(\n  event: PreprEventType,\n  data?: PreprEventData\n): void {\n  if (typeof window !== 'undefined') {\n    const message = {\n      name: 'prepr_preview_bar',\n      event,\n      ...data,\n    };\n\n    // Send to current window for local event handling\n    window.dispatchEvent(\n      new CustomEvent('prepr_preview_bar', { detail: message })\n    );\n\n    // Send to parent window if available\n    if (window.parent && window.parent !== window) {\n      window.parent.postMessage(message, '*');\n    }\n  }\n}\n\n// Export error handling utilities\nexport * from './errors';\n\n// Export DOM service\nexport * from './dom';\n\n// Export debug utilities\nexport * from './debug';\n\n// Export performance utilities\nexport * from './performance';\n"]}