@careerdriver/black-box 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Panthera Black Box Runtime
2
2
 
3
- Minimal JavaScript runtime (<10KB gzipped) that reads JSON configuration and sends telemetry from client websites.
3
+ **AI Search Optimization Runtime** - Minimal JavaScript runtime (<10KB gzipped) that optimizes websites for AI search engines by injecting structured data (JSON-LD schemas), building authority signals, and enabling AI model comprehension.
4
+
5
+ ## Purpose
6
+
7
+ The Black Box runtime optimizes websites specifically for **AI search engines** (ChatGPT, Perplexity, Claude, etc.) by:
8
+
9
+ 1. **Injecting JSON-LD Structured Data** - Makes content easily parseable by AI models
10
+ 2. **Building Authority Signals** - Creates trust graphs through Authority Grove
11
+ 3. **Ensuring Factual Accuracy** - Uses TruthSeeker to ensure AI models prioritize your content
12
+ 4. **Tracking AI Visibility** - Sends telemetry to measure AI search performance
4
13
 
5
14
  ## Safety
6
15
 
@@ -9,6 +18,15 @@ Minimal JavaScript runtime (<10KB gzipped) that reads JSON configuration and sen
9
18
  - **Declarative only** - All operations are safe JSON/DOM manipulations
10
19
  - **Fail-safe** - Never breaks the host site
11
20
 
21
+ ## How It Works
22
+
23
+ The runtime reads JSON configuration from your GPTO dashboard and automatically:
24
+
25
+ - ✅ Injects JSON-LD schemas (Organization, Product, Service, FAQ, etc.)
26
+ - ✅ Builds authority signals through `sameAs` links and keywords
27
+ - ✅ Sends telemetry to track AI search visibility
28
+ - ✅ Ensures content is structured for AI model comprehension
29
+
12
30
  ## Usage
13
31
 
14
32
  ### Installation (npm, ESM-only)
@@ -55,6 +73,28 @@ const blackBox = new PantheraBlackBox({
55
73
  await blackBox.init();
56
74
  ```
57
75
 
76
+ ## AI Search Optimization Features
77
+
78
+ ### JSON-LD Schema Injection
79
+ Automatically injects structured data that AI models can parse:
80
+ - Organization schema with authority signals
81
+ - Product/Service schemas (Silver/Gold tiers)
82
+ - FAQ schemas for question-answer pairs
83
+ - LocalBusiness schemas for geo-targeting
84
+
85
+ ### Authority Grove Integration
86
+ Builds trust signals through:
87
+ - `sameAs` links (social profiles, other domains)
88
+ - Keywords and verticals
89
+ - Partner network relationships
90
+
91
+ ### TruthSeeker Integration
92
+ Ensures content is:
93
+ - Factually accurate
94
+ - Authoritative
95
+ - Fair and unbiased
96
+ - Recent and relevant
97
+
58
98
  ## Build
59
99
 
60
100
  ```bash
@@ -69,3 +109,13 @@ Output:
69
109
  ## Deployment
70
110
 
71
111
  Deploy to Vercel CDN for global distribution. The file should be served with appropriate cache headers.
112
+
113
+ ## AI Search Optimization vs Traditional SEO
114
+
115
+ | Traditional SEO | GPTO (AI Search Optimization) |
116
+ |----------------|-------------------------------|
117
+ | Optimizes for Google/Bing | Optimizes for ChatGPT, Perplexity, Claude |
118
+ | HTML meta tags | JSON-LD structured data |
119
+ | Keywords & backlinks | Authority signals & trust graphs |
120
+ | PageRank algorithm | AI model comprehension |
121
+ | Human-readable content | AI-parseable structured data |
package/dist/runtime.d.ts CHANGED
@@ -1,7 +1,16 @@
1
1
  /**
2
2
  * Panthera Black Box Runtime
3
3
  *
4
- * A minimal, safe runtime that reads JSON configuration and sends telemetry.
4
+ * AI Search Optimization Runtime - Optimizes websites for AI search engines
5
+ * (ChatGPT, Perplexity, Claude, etc.) by injecting structured data and building
6
+ * authority signals that AI models can understand and prioritize.
7
+ *
8
+ * Key Features:
9
+ * - JSON-LD schema injection for AI model comprehension
10
+ * - Authority Grove integration for trust signals
11
+ * - TruthSeeker integration for factual accuracy
12
+ * - Telemetry for AI search visibility tracking
13
+ *
5
14
  * Designed to be <10KB gzipped when compiled.
6
15
  *
7
16
  * Safety: No eval(), no Function(), no arbitrary code execution.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["/**\n * Panthera Black Box Runtime\n * \n * A minimal, safe runtime that reads JSON configuration and sends telemetry.\n * Designed to be <10KB gzipped when compiled.\n * \n * Safety: No eval(), no Function(), no arbitrary code execution.\n * All operations are declarative JSON transformations only.\n */\n\ninterface AutoFillForm {\n selector: string;\n map: Record<string, string>;\n}\n\ninterface AutofillConfig {\n enabled?: boolean;\n forms?: AutoFillForm[];\n}\n\ninterface AdSlot {\n id: string;\n contexts: string[];\n}\n\ninterface AdsConfig {\n slots?: AdSlot[];\n}\n\ninterface AuthorityGroveNode {\n sameAs?: string[];\n keywords?: string[];\n}\n\ninterface AuthorityGroveConfig {\n node?: AuthorityGroveNode;\n}\n\ninterface ProductConfig {\n name?: string;\n description?: string;\n}\n\ninterface ServiceConfig {\n name?: string;\n description?: string;\n}\n\ninterface FaqConfig {\n question: string;\n answer: string;\n}\n\ninterface BlackBoxConfig {\n panthera_blackbox: {\n version: string;\n site: {\n domain: string;\n brand: string;\n verticals: string[];\n geo: string[];\n };\n telemetry: {\n emit: boolean;\n keys: string[];\n };\n tier?: 'bronze' | 'silver' | 'gold';\n autofill?: AutofillConfig;\n ads?: AdsConfig;\n authority_grove?: AuthorityGroveConfig;\n products?: ProductConfig[];\n services?: ServiceConfig[];\n faqs?: FaqConfig[];\n [key: string]: unknown;\n };\n}\n\ninterface TelemetryEvent {\n schema: string;\n tenant: string;\n timestamp: string;\n source: 'blackbox';\n context?: Record<string, unknown>;\n metrics: Record<string, number>;\n}\n\nclass PantheraBlackBox {\n private config: BlackBoxConfig | null = null;\n private configUrl: string;\n private telemetryUrl: string;\n private siteId: string;\n private initialized = false;\n\n constructor(options: { configUrl: string; telemetryUrl: string; siteId: string }) {\n this.configUrl = options.configUrl;\n this.telemetryUrl = options.telemetryUrl;\n this.siteId = options.siteId;\n }\n\n /**\n * Initialize the Black Box by loading configuration\n */\n async init(): Promise<void> {\n if (this.initialized) return;\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:53',message:'Black Box init started',data:{configUrl:this.configUrl,siteId:this.siteId},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n try {\n const response = await fetch(this.configUrl, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n cache: 'no-cache',\n });\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:64',message:'Config fetch response received',data:{ok:response.ok,status:response.status,statusText:response.statusText},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n if (!response.ok) {\n throw new Error(`Failed to load config: ${response.status}`);\n }\n\n const data = await response.json();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:72',message:'Config JSON parsed',data:{hasPantheraBlackbox:!!data.panthera_blackbox,hasSite:!!data.panthera_blackbox?.site,brand:data.panthera_blackbox?.site?.brand,telemetryEmit:data.panthera_blackbox?.telemetry?.emit},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n \n // Basic validation - ensure it has the expected structure\n if (!data.panthera_blackbox || !data.panthera_blackbox.site) {\n throw new Error('Invalid config structure');\n }\n\n this.config = data as BlackBoxConfig;\n this.initialized = true;\n\n // Apply configuration if needed\n this.applyConfig();\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:85',message:'Config applied',data:{initialized:this.initialized,telemetryEmit:this.config.panthera_blackbox.telemetry?.emit},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n // Start telemetry if enabled\n if (this.config.panthera_blackbox.telemetry?.emit) {\n this.startTelemetry();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:90',message:'Telemetry started',data:{telemetryUrl:this.telemetryUrl},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n }\n } catch (error) {\n console.error('[Panthera Black Box] Initialization failed:', error);\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:95',message:'Black Box init failed',data:{error:error instanceof Error?error.message:String(error)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n \n // Fail silently in production, but log for debugging\n }\n }\n\n /**\n * Apply configuration to the page (declarative transformations only)\n */\n private applyConfig(): void {\n if (!this.config) return;\n\n const config = this.config.panthera_blackbox;\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:95',message:'applyConfig called',data:{hasConfig:!!this.config,brand:config.site?.brand,telemetryEmit:config.telemetry?.emit,autofillEnabled:config.autofill?.enabled,hasAds:!!config.ads?.slots},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'E'})}).catch(()=>{});\n // #endregion\n \n // Inject JSON-LD schema if configured\n this.injectSchema(config);\n \n // Initialize AutoFill if enabled\n if (config.autofill?.enabled && config.autofill.forms) {\n this.initializeAutoFill(config);\n }\n \n // Initialize ad slots if configured\n if (config.ads?.slots) {\n this.initializeAdSlots(config);\n }\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:112',message:'applyConfig completed',data:{schemaInjected:!!document.querySelector('script[data-panthera]')},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'E'})}).catch(()=>{});\n // #endregion\n }\n\n /**\n * Inject JSON-LD schema\n */\n private injectSchema(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof document === 'undefined') return;\n \n // Remove existing Panthera schemas if present\n const existing = document.querySelectorAll('script[type=\"application/ld+json\"][data-panthera]');\n existing.forEach(el => el.remove());\n \n // Get tier from config (if available) or default to bronze\n const tier = config.tier ?? 'bronze';\n \n // Generate schemas based on tier\n const schemas = this.generateSchemasForTier(config, tier);\n \n // Inject all schemas\n schemas.forEach((schema, index) => {\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.setAttribute('data-panthera', 'true');\n script.setAttribute('data-schema-index', index.toString());\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n });\n }\n\n /**\n * Generate schemas based on tier\n */\n private generateSchemasForTier(\n config: BlackBoxConfig['panthera_blackbox'],\n tier: 'bronze' | 'silver' | 'gold'\n ): unknown[] {\n const schemas: unknown[] = [];\n \n // Base Organization schema (all tiers)\n const baseSchema = {\n '@context': 'https://schema.org',\n '@type': 'Organization',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n };\n \n // Add authority grove data if available\n if (config.authority_grove?.node) {\n (baseSchema as Record<string, unknown>).sameAs = config.authority_grove.node.sameAs;\n (baseSchema as Record<string, unknown>).keywords = config.authority_grove.node.keywords;\n }\n \n schemas.push(baseSchema);\n \n // Silver and Gold tiers get additional schemas\n if (tier === 'silver' || tier === 'gold') {\n // Add Product schema if product data exists in config\n if (config.products) {\n const products = config.products;\n products.forEach((product) => {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: product.name || config.site.brand,\n description: product.description,\n brand: {\n '@type': 'Brand',\n name: config.site.brand,\n },\n url: `https://${config.site.domain}`,\n });\n });\n }\n \n // Add Service schema if service data exists\n if (config.services) {\n const services = config.services;\n services.forEach((service) => {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'Service',\n name: service.name || config.site.brand,\n description: service.description,\n provider: {\n '@type': 'Organization',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n },\n });\n });\n }\n \n // Add LocalBusiness schema if geo data exists\n if (config.site.geo && config.site.geo.length > 0) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'LocalBusiness',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n areaServed: config.site.geo,\n });\n }\n \n // Add FAQ schema if FAQ data exists\n if (config.faqs) {\n const faqs = config.faqs;\n if (faqs.length > 0) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'FAQPage',\n mainEntity: faqs.map(faq => ({\n '@type': 'Question',\n name: faq.question,\n acceptedAnswer: {\n '@type': 'Answer',\n text: faq.answer,\n },\n })),\n });\n }\n }\n }\n \n return schemas;\n }\n\n /**\n * Initialize AutoFill for forms\n */\n private initializeAutoFill(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof window === 'undefined' || !config.autofill?.forms) return;\n \n config.autofill.forms.forEach((form: AutoFillForm) => {\n const formElement = document.querySelector(form.selector);\n if (formElement) {\n // Store form config for later use\n (formElement as HTMLElement & { pantheraAutoFill?: typeof form }).pantheraAutoFill = form;\n \n // Listen for first field focus to trigger AutoFill\n formElement.addEventListener('focusin', (event: Event) => {\n const target = event.target as HTMLElement;\n if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.tagName === 'SELECT') {\n this.triggerAutoFill(form);\n }\n }, { once: true });\n }\n });\n }\n\n /**\n * Trigger AutoFill for a form\n */\n private async triggerAutoFill(form: { selector: string; map: Record<string, string> }): Promise<void> {\n // In production, this would fetch CFP data from API\n // For now, use placeholder data\n const autofillData: Record<string, string> = {};\n \n // Apply AutoFill to form fields\n const formElement = document.querySelector(form.selector);\n if (!formElement) return;\n \n for (const [fieldName, selector] of Object.entries(form.map)) {\n const field = formElement.querySelector(selector) as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;\n if (field && autofillData[fieldName]) {\n field.value = autofillData[fieldName];\n field.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n }\n\n /**\n * Initialize ad slots\n */\n private initializeAdSlots(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof window === 'undefined' || !config.ads?.slots) return;\n \n config.ads.slots.forEach((slot: AdSlot) => {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:226',message:'initializeAdSlots - original slot.id',data:{slotId:slot.id,slotIdType:typeof slot.id,slotIdString:String(slot.id),slotIdJSON:JSON.stringify(slot.id)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n \n // Sanitize slot ID - aggressively remove quotes and ensure it's a valid CSS selector\n let sanitizedId = String(slot.id || '').trim();\n // Remove all quotes (single and double) from anywhere in the string\n sanitizedId = sanitizedId.replace(/[\"']/g, '');\n // Remove any remaining whitespace\n sanitizedId = sanitizedId.trim();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:232',message:'initializeAdSlots - after sanitization',data:{sanitizedId,originalSlotId:slot.id,sanitizedLength:sanitizedId.length},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n \n if (!sanitizedId) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:236',message:'initializeAdSlots - empty after sanitization',data:{originalSlotId:slot.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n return;\n }\n \n try {\n // Escape special CSS characters in the ID (but NOT quotes - they should already be removed)\n // Only escape characters that need escaping in attribute selectors\n const escapedId = sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&');\n // Double-check: ensure no quotes made it through\n if (escapedId.includes('\"') || escapedId.includes(\"'\")) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:243',message:'initializeAdSlots - quotes detected in escapedId',data:{escapedId,sanitizedId,originalSlotId:slot.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});\n // #endregion\n throw new Error(`Slot ID contains quotes after sanitization: ${escapedId}`);\n }\n \n const selector = `[data-ad-slot=\"${escapedId}\"]`;\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:250',message:'initializeAdSlots - selector construction',data:{escapedId,selector,selectorLength:selector.length,selectorChars:Array.from(selector)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});\n // #endregion\n \n const slotElement = document.querySelector(selector);\n \n if (slotElement) {\n // Store slot config\n (slotElement as HTMLElement & { pantheraAdSlot?: typeof slot }).pantheraAdSlot = slot;\n \n // In production, this would load ad creative and track impressions\n this.loadAdCreative(slot);\n } else {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:262',message:'initializeAdSlots - element not found',data:{selector,escapedId},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n }\n } catch (error) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:267',message:'initializeAdSlots - error caught',data:{error:String(error),errorMessage:(error as Error).message,slotId:slot.id,sanitizedId,escapedId:sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&'),selector:`[data-ad-slot=\"${sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&')}\"]`},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});\n // #endregion\n \n console.error(`[Panthera Black Box] Invalid ad slot selector for ID: ${slot.id}`, error);\n }\n });\n }\n\n /**\n * Load ad creative for a slot\n */\n private async loadAdCreative(slot: { id: string; contexts: string[] }): Promise<void> {\n // In production, this would:\n // 1. Fetch creative from API based on slot contexts\n // 2. Calculate CPM\n // 3. Render ad\n // 4. Track impression\n \n // Placeholder: just log the slot\n console.debug('[Panthera Black Box] Ad slot initialized:', slot.id);\n }\n\n /**\n * Start telemetry collection\n */\n private startTelemetry(): void {\n if (!this.config?.panthera_blackbox.telemetry?.emit) return;\n\n // Collect initial telemetry\n this.sendTelemetry('page_view', {\n url: window.location.href,\n referrer: document.referrer,\n });\n\n // Listen for user interactions (if configured)\n if (typeof window !== 'undefined') {\n // Throttled event listeners for performance\n let interactionTimeout: number | null = null;\n \n const sendInteraction = () => {\n if (interactionTimeout) return;\n interactionTimeout = window.setTimeout(() => {\n this.sendTelemetry('interaction', {\n timestamp: new Date().toISOString(),\n });\n interactionTimeout = null;\n }, 1000);\n };\n\n // Only track if explicitly configured\n document.addEventListener('click', sendInteraction, { passive: true });\n document.addEventListener('scroll', sendInteraction, { passive: true });\n }\n }\n\n /**\n * Send telemetry event\n */\n private async sendTelemetry(eventType: string, data: Record<string, unknown>): Promise<void> {\n if (!this.config?.panthera_blackbox.telemetry?.emit) return;\n\n const event: TelemetryEvent = {\n schema: 'panthera.blackbox.v1',\n tenant: this.config.panthera_blackbox.site.domain,\n timestamp: new Date().toISOString(),\n source: 'blackbox',\n context: {\n event_type: eventType,\n ...data,\n },\n metrics: this.collectMetrics(),\n };\n\n try {\n // Use sendBeacon for reliability (doesn't block page unload)\n if (navigator.sendBeacon) {\n navigator.sendBeacon(\n this.telemetryUrl,\n JSON.stringify(event)\n );\n } else {\n // Fallback to fetch\n await fetch(this.telemetryUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(event),\n keepalive: true,\n });\n }\n } catch (error) {\n // Fail silently - telemetry should never break the site\n console.debug('[Panthera Black Box] Telemetry failed:', error);\n }\n }\n\n /**\n * Collect metrics based on configured keys\n */\n private collectMetrics(): Record<string, number> {\n const metrics: Record<string, number> = {};\n const keys = this.config?.panthera_blackbox.telemetry?.keys || [];\n\n // Collect basic metrics if keys are configured\n // This is safe - we're only reading properties, not executing code\n keys.forEach((key) => {\n // Map telemetry keys to actual metrics\n // For now, return placeholder values\n // In production, these would be calculated from actual page state\n metrics[key] = 0;\n });\n\n return metrics;\n }\n\n /**\n * Get current configuration (read-only)\n */\n getConfig(): BlackBoxConfig | null {\n return this.config;\n }\n\n /**\n * Reload configuration\n */\n async reload(): Promise<void> {\n this.initialized = false;\n await this.init();\n }\n}\n\n// Auto-initialize if script tag has data attributes\n(function () {\n if (typeof window === 'undefined') return;\n\n const script = document.currentScript as HTMLScriptElement | null;\n if (!script) return;\n\n const configUrl = script.getAttribute('data-config-url');\n const telemetryUrl = script.getAttribute('data-telemetry-url');\n const siteId = script.getAttribute('data-site-id');\n\n if (!configUrl || !telemetryUrl || !siteId) {\n console.warn('[Panthera Black Box] Missing required data attributes');\n return;\n }\n\n const blackBox = new PantheraBlackBox({\n configUrl,\n telemetryUrl,\n siteId,\n });\n\n // Initialize when DOM is ready\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => blackBox.init());\n } else {\n blackBox.init();\n }\n\n // Expose globally for manual control (optional)\n (window as unknown as { PantheraBlackBox: typeof PantheraBlackBox }).PantheraBlackBox = PantheraBlackBox;\n (window as unknown as { panthera: PantheraBlackBox }).panthera = blackBox;\n})();\n\nexport { PantheraBlackBox };\nexport default PantheraBlackBox;\n"],"mappings":";ocAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,YAAAC,IAsFA,IAAMD,EAAN,KAAuB,CAOrB,YAAYE,EAAsE,CANlF,KAAQ,OAAgC,KAIxC,KAAQ,YAAc,GAGpB,KAAK,UAAYA,EAAQ,UACzB,KAAK,aAAeA,EAAQ,aAC5B,KAAK,OAASA,EAAQ,MACxB,CAKA,MAAM,MAAsB,CAC1B,GAAI,MAAK,YAGT,OAAM,oEAAoE,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,kBAAkB,EAAE,KAAK,KAAK,UAAU,CAAC,SAAS,0BAA0B,QAAQ,yBAAyB,KAAK,CAAC,UAAU,KAAK,UAAU,OAAO,KAAK,MAAM,EAAE,UAAU,KAAK,IAAI,EAAE,UAAU,gBAAgB,MAAM,OAAO,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,EAG9W,GAAI,CACF,IAAMC,EAAW,MAAM,MAAM,KAAK,UAAW,CAC3C,OAAQ,MACR,QAAS,CACP,OAAU,kBACZ,EACA,MAAO,UACT,CAAC,EAMD,GAHA,MAAM,oEAAoE,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,kBAAkB,EAAE,KAAK,KAAK,UAAU,CAAC,SAAS,0BAA0B,QAAQ,iCAAiC,KAAK,CAAC,GAAGA,EAAS,GAAG,OAAOA,EAAS,OAAO,WAAWA,EAAS,UAAU,EAAE,UAAU,KAAK,IAAI,EAAE,UAAU,gBAAgB,MAAM,OAA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ItC,EAAiB,CACpC,UAAAmC,EACA,aAAAC,EACA,OAAAC,CACF,CAAC,EAGG,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoB,IAAMC,EAAS,KAAK,CAAC,EAEnEA,EAAS,KAAK,EAIf,OAAoE,iBAAmBtC,EACvF,OAAqD,SAAWsC,CACnE,GAAG,EAGH,IAAOC,EAAQC","names":["runtime_exports","__export","PantheraBlackBox","runtime_default","options","response","data","error","config","el","tier","schema","index","script","schemas","baseSchema","product","service","faqs","faq","form","formElement","event","target","autofillData","fieldName","selector","field","slot","sanitizedId","escapedId","slotElement","interactionTimeout","sendInteraction","eventType","metrics","key","configUrl","telemetryUrl","siteId","blackBox","runtime_default","PantheraBlackBox"]}
1
+ {"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["/**\n * Panthera Black Box Runtime\n * \n * AI Search Optimization Runtime - Optimizes websites for AI search engines\n * (ChatGPT, Perplexity, Claude, etc.) by injecting structured data and building\n * authority signals that AI models can understand and prioritize.\n * \n * Key Features:\n * - JSON-LD schema injection for AI model comprehension\n * - Authority Grove integration for trust signals\n * - TruthSeeker integration for factual accuracy\n * - Telemetry for AI search visibility tracking\n * \n * Designed to be <10KB gzipped when compiled.\n * \n * Safety: No eval(), no Function(), no arbitrary code execution.\n * All operations are declarative JSON transformations only.\n */\n\ninterface AutoFillForm {\n selector: string;\n map: Record<string, string>;\n}\n\ninterface AutofillConfig {\n enabled?: boolean;\n forms?: AutoFillForm[];\n}\n\ninterface AdSlot {\n id: string;\n contexts: string[];\n}\n\ninterface AdsConfig {\n slots?: AdSlot[];\n}\n\ninterface AuthorityGroveNode {\n sameAs?: string[];\n keywords?: string[];\n}\n\ninterface AuthorityGroveConfig {\n node?: AuthorityGroveNode;\n}\n\ninterface ProductConfig {\n name?: string;\n description?: string;\n}\n\ninterface ServiceConfig {\n name?: string;\n description?: string;\n}\n\ninterface FaqConfig {\n question: string;\n answer: string;\n}\n\ninterface BlackBoxConfig {\n panthera_blackbox: {\n version: string;\n site: {\n domain: string;\n brand: string;\n verticals: string[];\n geo: string[];\n };\n telemetry: {\n emit: boolean;\n keys: string[];\n };\n tier?: 'bronze' | 'silver' | 'gold';\n autofill?: AutofillConfig;\n ads?: AdsConfig;\n authority_grove?: AuthorityGroveConfig;\n products?: ProductConfig[];\n services?: ServiceConfig[];\n faqs?: FaqConfig[];\n [key: string]: unknown;\n };\n}\n\ninterface TelemetryEvent {\n schema: string;\n tenant: string;\n timestamp: string;\n source: 'blackbox';\n context?: Record<string, unknown>;\n metrics: Record<string, number>;\n}\n\nclass PantheraBlackBox {\n private config: BlackBoxConfig | null = null;\n private configUrl: string;\n private telemetryUrl: string;\n private siteId: string;\n private initialized = false;\n\n constructor(options: { configUrl: string; telemetryUrl: string; siteId: string }) {\n this.configUrl = options.configUrl;\n this.telemetryUrl = options.telemetryUrl;\n this.siteId = options.siteId;\n }\n\n /**\n * Initialize the Black Box by loading configuration\n */\n async init(): Promise<void> {\n if (this.initialized) return;\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:53',message:'Black Box init started',data:{configUrl:this.configUrl,siteId:this.siteId},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n try {\n const response = await fetch(this.configUrl, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n cache: 'no-cache',\n });\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:64',message:'Config fetch response received',data:{ok:response.ok,status:response.status,statusText:response.statusText},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n if (!response.ok) {\n throw new Error(`Failed to load config: ${response.status}`);\n }\n\n const data = await response.json();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:72',message:'Config JSON parsed',data:{hasPantheraBlackbox:!!data.panthera_blackbox,hasSite:!!data.panthera_blackbox?.site,brand:data.panthera_blackbox?.site?.brand,telemetryEmit:data.panthera_blackbox?.telemetry?.emit},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n \n // Basic validation - ensure it has the expected structure\n if (!data.panthera_blackbox || !data.panthera_blackbox.site) {\n throw new Error('Invalid config structure');\n }\n\n this.config = data as BlackBoxConfig;\n this.initialized = true;\n\n // Apply configuration if needed\n this.applyConfig();\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:85',message:'Config applied',data:{initialized:this.initialized,telemetryEmit:this.config.panthera_blackbox.telemetry?.emit},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n // Start telemetry if enabled\n if (this.config.panthera_blackbox.telemetry?.emit) {\n this.startTelemetry();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:90',message:'Telemetry started',data:{telemetryUrl:this.telemetryUrl},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n }\n } catch (error) {\n console.error('[Panthera Black Box] Initialization failed:', error);\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:95',message:'Black Box init failed',data:{error:error instanceof Error?error.message:String(error)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n \n // Fail silently in production, but log for debugging\n }\n }\n\n /**\n * Apply configuration to the page (declarative transformations only)\n */\n private applyConfig(): void {\n if (!this.config) return;\n\n const config = this.config.panthera_blackbox;\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:95',message:'applyConfig called',data:{hasConfig:!!this.config,brand:config.site?.brand,telemetryEmit:config.telemetry?.emit,autofillEnabled:config.autofill?.enabled,hasAds:!!config.ads?.slots},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'E'})}).catch(()=>{});\n // #endregion\n \n // Inject JSON-LD schema if configured\n this.injectSchema(config);\n \n // Initialize AutoFill if enabled\n if (config.autofill?.enabled && config.autofill.forms) {\n this.initializeAutoFill(config);\n }\n \n // Initialize ad slots if configured\n if (config.ads?.slots) {\n this.initializeAdSlots(config);\n }\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:112',message:'applyConfig completed',data:{schemaInjected:!!document.querySelector('script[data-panthera]')},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'E'})}).catch(()=>{});\n // #endregion\n }\n\n /**\n * Inject JSON-LD schema\n */\n private injectSchema(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof document === 'undefined') return;\n \n // Remove existing Panthera schemas if present\n const existing = document.querySelectorAll('script[type=\"application/ld+json\"][data-panthera]');\n existing.forEach(el => el.remove());\n \n // Get tier from config (if available) or default to bronze\n const tier = config.tier ?? 'bronze';\n \n // Generate schemas based on tier\n const schemas = this.generateSchemasForTier(config, tier);\n \n // Inject all schemas\n schemas.forEach((schema, index) => {\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.setAttribute('data-panthera', 'true');\n script.setAttribute('data-schema-index', index.toString());\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n });\n }\n\n /**\n * Generate schemas based on tier\n */\n private generateSchemasForTier(\n config: BlackBoxConfig['panthera_blackbox'],\n tier: 'bronze' | 'silver' | 'gold'\n ): unknown[] {\n const schemas: unknown[] = [];\n \n // Base Organization schema (all tiers)\n const baseSchema = {\n '@context': 'https://schema.org',\n '@type': 'Organization',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n };\n \n // Add authority grove data if available\n if (config.authority_grove?.node) {\n (baseSchema as Record<string, unknown>).sameAs = config.authority_grove.node.sameAs;\n (baseSchema as Record<string, unknown>).keywords = config.authority_grove.node.keywords;\n }\n \n schemas.push(baseSchema);\n \n // Silver and Gold tiers get additional schemas\n if (tier === 'silver' || tier === 'gold') {\n // Add Product schema if product data exists in config\n if (config.products) {\n const products = config.products;\n products.forEach((product) => {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: product.name || config.site.brand,\n description: product.description,\n brand: {\n '@type': 'Brand',\n name: config.site.brand,\n },\n url: `https://${config.site.domain}`,\n });\n });\n }\n \n // Add Service schema if service data exists\n if (config.services) {\n const services = config.services;\n services.forEach((service) => {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'Service',\n name: service.name || config.site.brand,\n description: service.description,\n provider: {\n '@type': 'Organization',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n },\n });\n });\n }\n \n // Add LocalBusiness schema if geo data exists\n if (config.site.geo && config.site.geo.length > 0) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'LocalBusiness',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n areaServed: config.site.geo,\n });\n }\n \n // Add FAQ schema if FAQ data exists\n if (config.faqs) {\n const faqs = config.faqs;\n if (faqs.length > 0) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'FAQPage',\n mainEntity: faqs.map(faq => ({\n '@type': 'Question',\n name: faq.question,\n acceptedAnswer: {\n '@type': 'Answer',\n text: faq.answer,\n },\n })),\n });\n }\n }\n }\n \n return schemas;\n }\n\n /**\n * Initialize AutoFill for forms\n */\n private initializeAutoFill(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof window === 'undefined' || !config.autofill?.forms) return;\n \n config.autofill.forms.forEach((form: AutoFillForm) => {\n const formElement = document.querySelector(form.selector);\n if (formElement) {\n // Store form config for later use\n (formElement as HTMLElement & { pantheraAutoFill?: typeof form }).pantheraAutoFill = form;\n \n // Listen for first field focus to trigger AutoFill\n formElement.addEventListener('focusin', (event: Event) => {\n const target = event.target as HTMLElement;\n if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.tagName === 'SELECT') {\n this.triggerAutoFill(form);\n }\n }, { once: true });\n }\n });\n }\n\n /**\n * Trigger AutoFill for a form\n */\n private async triggerAutoFill(form: { selector: string; map: Record<string, string> }): Promise<void> {\n // In production, this would fetch CFP data from API\n // For now, use placeholder data\n const autofillData: Record<string, string> = {};\n \n // Apply AutoFill to form fields\n const formElement = document.querySelector(form.selector);\n if (!formElement) return;\n \n for (const [fieldName, selector] of Object.entries(form.map)) {\n const field = formElement.querySelector(selector) as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;\n if (field && autofillData[fieldName]) {\n field.value = autofillData[fieldName];\n field.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n }\n\n /**\n * Initialize ad slots\n */\n private initializeAdSlots(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof window === 'undefined' || !config.ads?.slots) return;\n \n config.ads.slots.forEach((slot: AdSlot) => {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:226',message:'initializeAdSlots - original slot.id',data:{slotId:slot.id,slotIdType:typeof slot.id,slotIdString:String(slot.id),slotIdJSON:JSON.stringify(slot.id)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n \n // Sanitize slot ID - aggressively remove quotes and ensure it's a valid CSS selector\n let sanitizedId = String(slot.id || '').trim();\n // Remove all quotes (single and double) from anywhere in the string\n sanitizedId = sanitizedId.replace(/[\"']/g, '');\n // Remove any remaining whitespace\n sanitizedId = sanitizedId.trim();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:232',message:'initializeAdSlots - after sanitization',data:{sanitizedId,originalSlotId:slot.id,sanitizedLength:sanitizedId.length},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n \n if (!sanitizedId) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:236',message:'initializeAdSlots - empty after sanitization',data:{originalSlotId:slot.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n return;\n }\n \n try {\n // Escape special CSS characters in the ID (but NOT quotes - they should already be removed)\n // Only escape characters that need escaping in attribute selectors\n const escapedId = sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&');\n // Double-check: ensure no quotes made it through\n if (escapedId.includes('\"') || escapedId.includes(\"'\")) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:243',message:'initializeAdSlots - quotes detected in escapedId',data:{escapedId,sanitizedId,originalSlotId:slot.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});\n // #endregion\n throw new Error(`Slot ID contains quotes after sanitization: ${escapedId}`);\n }\n \n const selector = `[data-ad-slot=\"${escapedId}\"]`;\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:250',message:'initializeAdSlots - selector construction',data:{escapedId,selector,selectorLength:selector.length,selectorChars:Array.from(selector)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});\n // #endregion\n \n const slotElement = document.querySelector(selector);\n \n if (slotElement) {\n // Store slot config\n (slotElement as HTMLElement & { pantheraAdSlot?: typeof slot }).pantheraAdSlot = slot;\n \n // In production, this would load ad creative and track impressions\n this.loadAdCreative(slot);\n } else {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:262',message:'initializeAdSlots - element not found',data:{selector,escapedId},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n }\n } catch (error) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:267',message:'initializeAdSlots - error caught',data:{error:String(error),errorMessage:(error as Error).message,slotId:slot.id,sanitizedId,escapedId:sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&'),selector:`[data-ad-slot=\"${sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&')}\"]`},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});\n // #endregion\n \n console.error(`[Panthera Black Box] Invalid ad slot selector for ID: ${slot.id}`, error);\n }\n });\n }\n\n /**\n * Load ad creative for a slot\n */\n private async loadAdCreative(slot: { id: string; contexts: string[] }): Promise<void> {\n // In production, this would:\n // 1. Fetch creative from API based on slot contexts\n // 2. Calculate CPM\n // 3. Render ad\n // 4. Track impression\n \n // Placeholder: just log the slot\n console.debug('[Panthera Black Box] Ad slot initialized:', slot.id);\n }\n\n /**\n * Start telemetry collection\n */\n private startTelemetry(): void {\n if (!this.config?.panthera_blackbox.telemetry?.emit) return;\n\n // Collect initial telemetry\n this.sendTelemetry('page_view', {\n url: window.location.href,\n referrer: document.referrer,\n });\n\n // Listen for user interactions (if configured)\n if (typeof window !== 'undefined') {\n // Throttled event listeners for performance\n let interactionTimeout: number | null = null;\n \n const sendInteraction = () => {\n if (interactionTimeout) return;\n interactionTimeout = window.setTimeout(() => {\n this.sendTelemetry('interaction', {\n timestamp: new Date().toISOString(),\n });\n interactionTimeout = null;\n }, 1000);\n };\n\n // Only track if explicitly configured\n document.addEventListener('click', sendInteraction, { passive: true });\n document.addEventListener('scroll', sendInteraction, { passive: true });\n }\n }\n\n /**\n * Send telemetry event\n */\n private async sendTelemetry(eventType: string, data: Record<string, unknown>): Promise<void> {\n if (!this.config?.panthera_blackbox.telemetry?.emit) return;\n\n const event: TelemetryEvent = {\n schema: 'panthera.blackbox.v1',\n tenant: this.config.panthera_blackbox.site.domain,\n timestamp: new Date().toISOString(),\n source: 'blackbox',\n context: {\n event_type: eventType,\n ...data,\n },\n metrics: this.collectMetrics(),\n };\n\n try {\n // Use sendBeacon for reliability (doesn't block page unload)\n if (navigator.sendBeacon) {\n navigator.sendBeacon(\n this.telemetryUrl,\n JSON.stringify(event)\n );\n } else {\n // Fallback to fetch\n await fetch(this.telemetryUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(event),\n keepalive: true,\n });\n }\n } catch (error) {\n // Fail silently - telemetry should never break the site\n console.debug('[Panthera Black Box] Telemetry failed:', error);\n }\n }\n\n /**\n * Collect metrics based on configured keys\n */\n private collectMetrics(): Record<string, number> {\n const metrics: Record<string, number> = {};\n const keys = this.config?.panthera_blackbox.telemetry?.keys || [];\n\n // Collect basic metrics if keys are configured\n // This is safe - we're only reading properties, not executing code\n keys.forEach((key) => {\n // Map telemetry keys to actual metrics\n // For now, return placeholder values\n // In production, these would be calculated from actual page state\n metrics[key] = 0;\n });\n\n return metrics;\n }\n\n /**\n * Get current configuration (read-only)\n */\n getConfig(): BlackBoxConfig | null {\n return this.config;\n }\n\n /**\n * Reload configuration\n */\n async reload(): Promise<void> {\n this.initialized = false;\n await this.init();\n }\n}\n\n// Auto-initialize if script tag has data attributes\n(function () {\n if (typeof window === 'undefined') return;\n\n const script = document.currentScript as HTMLScriptElement | null;\n if (!script) return;\n\n const configUrl = script.getAttribute('data-config-url');\n const telemetryUrl = script.getAttribute('data-telemetry-url');\n const siteId = script.getAttribute('data-site-id');\n\n if (!configUrl || !telemetryUrl || !siteId) {\n console.warn('[Panthera Black Box] Missing required data attributes');\n return;\n }\n\n const blackBox = new PantheraBlackBox({\n configUrl,\n telemetryUrl,\n siteId,\n });\n\n // Initialize when DOM is ready\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => blackBox.init());\n } else {\n blackBox.init();\n }\n\n // Expose globally for manual control (optional)\n (window as unknown as { PantheraBlackBox: typeof PantheraBlackBox }).PantheraBlackBox = PantheraBlackBox;\n (window as unknown as { panthera: PantheraBlackBox }).panthera = blackBox;\n})();\n\nexport { PantheraBlackBox };\nexport default PantheraBlackBox;\n"],"mappings":";ocAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,YAAAC,IA+FA,IAAMD,EAAN,KAAuB,CAOrB,YAAYE,EAAsE,CANlF,KAAQ,OAAgC,KAIxC,KAAQ,YAAc,GAGpB,KAAK,UAAYA,EAAQ,UACzB,KAAK,aAAeA,E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S,CACP,eAAgB,kBAClB,EACA,KAAM,KAAK,UAAUA,CAAK,EAC1B,UAAW,EACb,CAAC,CAEL,OAASf,EAAO,CAEd,QAAQ,MAAM,yCAA0CA,CAAK,CAC/D,CACF,CAKQ,gBAAyC,CAC/C,IAAM4B,EAAkC,CAAC,EAKzC,OAJa,KAAK,QAAQ,kBAAkB,WAAW,MAAQ,CAAC,GAI3D,QAASC,GAAQ,CAIpBD,EAAQC,CAAG,EAAI,CACjB,CAAC,EAEMD,CACT,CAKA,WAAmC,CACjC,OAAO,KAAK,MACd,CAKA,MAAM,QAAwB,CAC5B,KAAK,YAAc,GACnB,MAAM,KAAK,KAAK,CAClB,CACF,GAGC,UAAY,CACX,GAAI,OAAO,OAAW,IAAa,OAEnC,IAAMtB,EAAS,SAAS,cACxB,GAAI,CAACA,EAAQ,OAEb,IAAMwB,EAAYxB,EAAO,aAAa,iBAAiB,EACjDyB,EAAezB,EAAO,aAAa,oBAAoB,EACvD0B,EAAS1B,EAAO,aAAa,cAAc,EAEjD,GAAI,CAACwB,GAAa,CAACC,GAAgB,CAACC,EAAQ,CAC1C,QAAQ,KAAK,uDAAuD,EACpE,MACF,CAEA,IAAMC,EAAW,IAAItC,EAAiB,CACpC,UAAAmC,EACA,aAAAC,EACA,OAAAC,CACF,CAAC,EAGG,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoB,IAAMC,EAAS,KAAK,CAAC,EAEnEA,EAAS,KAAK,EAIf,OAAoE,iBAAmBtC,EACvF,OAAqD,SAAWsC,CACnE,GAAG,EAGH,IAAOC,EAAQC","names":["runtime_exports","__export","PantheraBlackBox","runtime_default","options","response","data","error","config","el","tier","schema","index","script","schemas","baseSchema","product","service","faqs","faq","form","formElement","event","target","autofillData","fieldName","selector","field","slot","sanitizedId","escapedId","slotElement","interactionTimeout","sendInteraction","eventType","metrics","key","configUrl","telemetryUrl","siteId","blackBox","runtime_default","PantheraBlackBox"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["/**\n * Panthera Black Box Runtime\n * \n * A minimal, safe runtime that reads JSON configuration and sends telemetry.\n * Designed to be <10KB gzipped when compiled.\n * \n * Safety: No eval(), no Function(), no arbitrary code execution.\n * All operations are declarative JSON transformations only.\n */\n\ninterface AutoFillForm {\n selector: string;\n map: Record<string, string>;\n}\n\ninterface AutofillConfig {\n enabled?: boolean;\n forms?: AutoFillForm[];\n}\n\ninterface AdSlot {\n id: string;\n contexts: string[];\n}\n\ninterface AdsConfig {\n slots?: AdSlot[];\n}\n\ninterface AuthorityGroveNode {\n sameAs?: string[];\n keywords?: string[];\n}\n\ninterface AuthorityGroveConfig {\n node?: AuthorityGroveNode;\n}\n\ninterface ProductConfig {\n name?: string;\n description?: string;\n}\n\ninterface ServiceConfig {\n name?: string;\n description?: string;\n}\n\ninterface FaqConfig {\n question: string;\n answer: string;\n}\n\ninterface BlackBoxConfig {\n panthera_blackbox: {\n version: string;\n site: {\n domain: string;\n brand: string;\n verticals: string[];\n geo: string[];\n };\n telemetry: {\n emit: boolean;\n keys: string[];\n };\n tier?: 'bronze' | 'silver' | 'gold';\n autofill?: AutofillConfig;\n ads?: AdsConfig;\n authority_grove?: AuthorityGroveConfig;\n products?: ProductConfig[];\n services?: ServiceConfig[];\n faqs?: FaqConfig[];\n [key: string]: unknown;\n };\n}\n\ninterface TelemetryEvent {\n schema: string;\n tenant: string;\n timestamp: string;\n source: 'blackbox';\n context?: Record<string, unknown>;\n metrics: Record<string, number>;\n}\n\nclass PantheraBlackBox {\n private config: BlackBoxConfig | null = null;\n private configUrl: string;\n private telemetryUrl: string;\n private siteId: string;\n private initialized = false;\n\n constructor(options: { configUrl: string; telemetryUrl: string; siteId: string }) {\n this.configUrl = options.configUrl;\n this.telemetryUrl = options.telemetryUrl;\n this.siteId = options.siteId;\n }\n\n /**\n * Initialize the Black Box by loading configuration\n */\n async init(): Promise<void> {\n if (this.initialized) return;\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:53',message:'Black Box init started',data:{configUrl:this.configUrl,siteId:this.siteId},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n try {\n const response = await fetch(this.configUrl, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n cache: 'no-cache',\n });\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:64',message:'Config fetch response received',data:{ok:response.ok,status:response.status,statusText:response.statusText},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n if (!response.ok) {\n throw new Error(`Failed to load config: ${response.status}`);\n }\n\n const data = await response.json();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:72',message:'Config JSON parsed',data:{hasPantheraBlackbox:!!data.panthera_blackbox,hasSite:!!data.panthera_blackbox?.site,brand:data.panthera_blackbox?.site?.brand,telemetryEmit:data.panthera_blackbox?.telemetry?.emit},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n \n // Basic validation - ensure it has the expected structure\n if (!data.panthera_blackbox || !data.panthera_blackbox.site) {\n throw new Error('Invalid config structure');\n }\n\n this.config = data as BlackBoxConfig;\n this.initialized = true;\n\n // Apply configuration if needed\n this.applyConfig();\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:85',message:'Config applied',data:{initialized:this.initialized,telemetryEmit:this.config.panthera_blackbox.telemetry?.emit},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n // Start telemetry if enabled\n if (this.config.panthera_blackbox.telemetry?.emit) {\n this.startTelemetry();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:90',message:'Telemetry started',data:{telemetryUrl:this.telemetryUrl},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n }\n } catch (error) {\n console.error('[Panthera Black Box] Initialization failed:', error);\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:95',message:'Black Box init failed',data:{error:error instanceof Error?error.message:String(error)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n \n // Fail silently in production, but log for debugging\n }\n }\n\n /**\n * Apply configuration to the page (declarative transformations only)\n */\n private applyConfig(): void {\n if (!this.config) return;\n\n const config = this.config.panthera_blackbox;\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:95',message:'applyConfig called',data:{hasConfig:!!this.config,brand:config.site?.brand,telemetryEmit:config.telemetry?.emit,autofillEnabled:config.autofill?.enabled,hasAds:!!config.ads?.slots},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'E'})}).catch(()=>{});\n // #endregion\n \n // Inject JSON-LD schema if configured\n this.injectSchema(config);\n \n // Initialize AutoFill if enabled\n if (config.autofill?.enabled && config.autofill.forms) {\n this.initializeAutoFill(config);\n }\n \n // Initialize ad slots if configured\n if (config.ads?.slots) {\n this.initializeAdSlots(config);\n }\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:112',message:'applyConfig completed',data:{schemaInjected:!!document.querySelector('script[data-panthera]')},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'E'})}).catch(()=>{});\n // #endregion\n }\n\n /**\n * Inject JSON-LD schema\n */\n private injectSchema(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof document === 'undefined') return;\n \n // Remove existing Panthera schemas if present\n const existing = document.querySelectorAll('script[type=\"application/ld+json\"][data-panthera]');\n existing.forEach(el => el.remove());\n \n // Get tier from config (if available) or default to bronze\n const tier = config.tier ?? 'bronze';\n \n // Generate schemas based on tier\n const schemas = this.generateSchemasForTier(config, tier);\n \n // Inject all schemas\n schemas.forEach((schema, index) => {\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.setAttribute('data-panthera', 'true');\n script.setAttribute('data-schema-index', index.toString());\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n });\n }\n\n /**\n * Generate schemas based on tier\n */\n private generateSchemasForTier(\n config: BlackBoxConfig['panthera_blackbox'],\n tier: 'bronze' | 'silver' | 'gold'\n ): unknown[] {\n const schemas: unknown[] = [];\n \n // Base Organization schema (all tiers)\n const baseSchema = {\n '@context': 'https://schema.org',\n '@type': 'Organization',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n };\n \n // Add authority grove data if available\n if (config.authority_grove?.node) {\n (baseSchema as Record<string, unknown>).sameAs = config.authority_grove.node.sameAs;\n (baseSchema as Record<string, unknown>).keywords = config.authority_grove.node.keywords;\n }\n \n schemas.push(baseSchema);\n \n // Silver and Gold tiers get additional schemas\n if (tier === 'silver' || tier === 'gold') {\n // Add Product schema if product data exists in config\n if (config.products) {\n const products = config.products;\n products.forEach((product) => {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: product.name || config.site.brand,\n description: product.description,\n brand: {\n '@type': 'Brand',\n name: config.site.brand,\n },\n url: `https://${config.site.domain}`,\n });\n });\n }\n \n // Add Service schema if service data exists\n if (config.services) {\n const services = config.services;\n services.forEach((service) => {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'Service',\n name: service.name || config.site.brand,\n description: service.description,\n provider: {\n '@type': 'Organization',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n },\n });\n });\n }\n \n // Add LocalBusiness schema if geo data exists\n if (config.site.geo && config.site.geo.length > 0) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'LocalBusiness',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n areaServed: config.site.geo,\n });\n }\n \n // Add FAQ schema if FAQ data exists\n if (config.faqs) {\n const faqs = config.faqs;\n if (faqs.length > 0) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'FAQPage',\n mainEntity: faqs.map(faq => ({\n '@type': 'Question',\n name: faq.question,\n acceptedAnswer: {\n '@type': 'Answer',\n text: faq.answer,\n },\n })),\n });\n }\n }\n }\n \n return schemas;\n }\n\n /**\n * Initialize AutoFill for forms\n */\n private initializeAutoFill(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof window === 'undefined' || !config.autofill?.forms) return;\n \n config.autofill.forms.forEach((form: AutoFillForm) => {\n const formElement = document.querySelector(form.selector);\n if (formElement) {\n // Store form config for later use\n (formElement as HTMLElement & { pantheraAutoFill?: typeof form }).pantheraAutoFill = form;\n \n // Listen for first field focus to trigger AutoFill\n formElement.addEventListener('focusin', (event: Event) => {\n const target = event.target as HTMLElement;\n if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.tagName === 'SELECT') {\n this.triggerAutoFill(form);\n }\n }, { once: true });\n }\n });\n }\n\n /**\n * Trigger AutoFill for a form\n */\n private async triggerAutoFill(form: { selector: string; map: Record<string, string> }): Promise<void> {\n // In production, this would fetch CFP data from API\n // For now, use placeholder data\n const autofillData: Record<string, string> = {};\n \n // Apply AutoFill to form fields\n const formElement = document.querySelector(form.selector);\n if (!formElement) return;\n \n for (const [fieldName, selector] of Object.entries(form.map)) {\n const field = formElement.querySelector(selector) as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;\n if (field && autofillData[fieldName]) {\n field.value = autofillData[fieldName];\n field.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n }\n\n /**\n * Initialize ad slots\n */\n private initializeAdSlots(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof window === 'undefined' || !config.ads?.slots) return;\n \n config.ads.slots.forEach((slot: AdSlot) => {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:226',message:'initializeAdSlots - original slot.id',data:{slotId:slot.id,slotIdType:typeof slot.id,slotIdString:String(slot.id),slotIdJSON:JSON.stringify(slot.id)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n \n // Sanitize slot ID - aggressively remove quotes and ensure it's a valid CSS selector\n let sanitizedId = String(slot.id || '').trim();\n // Remove all quotes (single and double) from anywhere in the string\n sanitizedId = sanitizedId.replace(/[\"']/g, '');\n // Remove any remaining whitespace\n sanitizedId = sanitizedId.trim();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:232',message:'initializeAdSlots - after sanitization',data:{sanitizedId,originalSlotId:slot.id,sanitizedLength:sanitizedId.length},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n \n if (!sanitizedId) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:236',message:'initializeAdSlots - empty after sanitization',data:{originalSlotId:slot.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n return;\n }\n \n try {\n // Escape special CSS characters in the ID (but NOT quotes - they should already be removed)\n // Only escape characters that need escaping in attribute selectors\n const escapedId = sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&');\n // Double-check: ensure no quotes made it through\n if (escapedId.includes('\"') || escapedId.includes(\"'\")) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:243',message:'initializeAdSlots - quotes detected in escapedId',data:{escapedId,sanitizedId,originalSlotId:slot.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});\n // #endregion\n throw new Error(`Slot ID contains quotes after sanitization: ${escapedId}`);\n }\n \n const selector = `[data-ad-slot=\"${escapedId}\"]`;\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:250',message:'initializeAdSlots - selector construction',data:{escapedId,selector,selectorLength:selector.length,selectorChars:Array.from(selector)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});\n // #endregion\n \n const slotElement = document.querySelector(selector);\n \n if (slotElement) {\n // Store slot config\n (slotElement as HTMLElement & { pantheraAdSlot?: typeof slot }).pantheraAdSlot = slot;\n \n // In production, this would load ad creative and track impressions\n this.loadAdCreative(slot);\n } else {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:262',message:'initializeAdSlots - element not found',data:{selector,escapedId},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n }\n } catch (error) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:267',message:'initializeAdSlots - error caught',data:{error:String(error),errorMessage:(error as Error).message,slotId:slot.id,sanitizedId,escapedId:sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&'),selector:`[data-ad-slot=\"${sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&')}\"]`},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});\n // #endregion\n \n console.error(`[Panthera Black Box] Invalid ad slot selector for ID: ${slot.id}`, error);\n }\n });\n }\n\n /**\n * Load ad creative for a slot\n */\n private async loadAdCreative(slot: { id: string; contexts: string[] }): Promise<void> {\n // In production, this would:\n // 1. Fetch creative from API based on slot contexts\n // 2. Calculate CPM\n // 3. Render ad\n // 4. Track impression\n \n // Placeholder: just log the slot\n console.debug('[Panthera Black Box] Ad slot initialized:', slot.id);\n }\n\n /**\n * Start telemetry collection\n */\n private startTelemetry(): void {\n if (!this.config?.panthera_blackbox.telemetry?.emit) return;\n\n // Collect initial telemetry\n this.sendTelemetry('page_view', {\n url: window.location.href,\n referrer: document.referrer,\n });\n\n // Listen for user interactions (if configured)\n if (typeof window !== 'undefined') {\n // Throttled event listeners for performance\n let interactionTimeout: number | null = null;\n \n const sendInteraction = () => {\n if (interactionTimeout) return;\n interactionTimeout = window.setTimeout(() => {\n this.sendTelemetry('interaction', {\n timestamp: new Date().toISOString(),\n });\n interactionTimeout = null;\n }, 1000);\n };\n\n // Only track if explicitly configured\n document.addEventListener('click', sendInteraction, { passive: true });\n document.addEventListener('scroll', sendInteraction, { passive: true });\n }\n }\n\n /**\n * Send telemetry event\n */\n private async sendTelemetry(eventType: string, data: Record<string, unknown>): Promise<void> {\n if (!this.config?.panthera_blackbox.telemetry?.emit) return;\n\n const event: TelemetryEvent = {\n schema: 'panthera.blackbox.v1',\n tenant: this.config.panthera_blackbox.site.domain,\n timestamp: new Date().toISOString(),\n source: 'blackbox',\n context: {\n event_type: eventType,\n ...data,\n },\n metrics: this.collectMetrics(),\n };\n\n try {\n // Use sendBeacon for reliability (doesn't block page unload)\n if (navigator.sendBeacon) {\n navigator.sendBeacon(\n this.telemetryUrl,\n JSON.stringify(event)\n );\n } else {\n // Fallback to fetch\n await fetch(this.telemetryUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(event),\n keepalive: true,\n });\n }\n } catch (error) {\n // Fail silently - telemetry should never break the site\n console.debug('[Panthera Black Box] Telemetry failed:', error);\n }\n }\n\n /**\n * Collect metrics based on configured keys\n */\n private collectMetrics(): Record<string, number> {\n const metrics: Record<string, number> = {};\n const keys = this.config?.panthera_blackbox.telemetry?.keys || [];\n\n // Collect basic metrics if keys are configured\n // This is safe - we're only reading properties, not executing code\n keys.forEach((key) => {\n // Map telemetry keys to actual metrics\n // For now, return placeholder values\n // In production, these would be calculated from actual page state\n metrics[key] = 0;\n });\n\n return metrics;\n }\n\n /**\n * Get current configuration (read-only)\n */\n getConfig(): BlackBoxConfig | null {\n return this.config;\n }\n\n /**\n * Reload configuration\n */\n async reload(): Promise<void> {\n this.initialized = false;\n await this.init();\n }\n}\n\n// Auto-initialize if script tag has data attributes\n(function () {\n if (typeof window === 'undefined') return;\n\n const script = document.currentScript as HTMLScriptElement | null;\n if (!script) return;\n\n const configUrl = script.getAttribute('data-config-url');\n const telemetryUrl = script.getAttribute('data-telemetry-url');\n const siteId = script.getAttribute('data-site-id');\n\n if (!configUrl || !telemetryUrl || !siteId) {\n console.warn('[Panthera Black Box] Missing required data attributes');\n return;\n }\n\n const blackBox = new PantheraBlackBox({\n configUrl,\n telemetryUrl,\n siteId,\n });\n\n // Initialize when DOM is ready\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => blackBox.init());\n } else {\n blackBox.init();\n }\n\n // Expose globally for manual control (optional)\n (window as unknown as { PantheraBlackBox: typeof PantheraBlackBox }).PantheraBlackBox = PantheraBlackBox;\n (window as unknown as { panthera: PantheraBlackBox }).panthera = blackBox;\n})();\n\nexport { PantheraBlackBox };\nexport default PantheraBlackBox;\n"],"mappings":";AAsFA,IAAMA,EAAN,KAAuB,CAOrB,YAAYC,EAAsE,CANlF,KAAQ,OAAgC,KAIxC,KAAQ,YAAc,GAGpB,KAAK,UAAYA,EAAQ,UACzB,KAAK,aAAeA,EAAQ,aAC5B,KAAK,OAASA,EAAQ,MACxB,CAKA,MAAM,MAAsB,CAC1B,GAAI,MAAK,YAGT,OAAM,oEAAoE,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,kBAAkB,EAAE,KAAK,KAAK,UAAU,CAAC,SAAS,0BAA0B,QAAQ,yBAAyB,KAAK,CAAC,UAAU,KAAK,UAAU,OAAO,KAAK,MAAM,EAAE,UAAU,KAAK,IAAI,EAAE,UAAU,gBAAgB,MAAM,OAAO,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC,EAG9W,GAAI,CACF,IAAMC,EAAW,MAAM,MAAM,KAAK,UAAW,CAC3C,OAAQ,MACR,QAAS,CACP,OAAU,kBACZ,EACA,MAAO,UACT,CAAC,EAMD,GAHA,MAAM,oEAAoE,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,kBAAkB,EAAE,KAAK,KAAK,UAAU,CAAC,SAAS,0BAA0B,QAAQ,iCAAiC,KAAK,CAAC,GAAGA,EAAS,GAAG,OAAOA,EAAS,OAAO,WAAWA,EAAS,UAAU,EAAE,UAAU,KAAK,IA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EACpE,MACF,CAEA,IAAMC,EAAW,IAAIrC,EAAiB,CACpC,UAAAkC,EACA,aAAAC,EACA,OAAAC,CACF,CAAC,EAGG,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoB,IAAMC,EAAS,KAAK,CAAC,EAEnEA,EAAS,KAAK,EAIf,OAAoE,iBAAmBrC,EACvF,OAAqD,SAAWqC,CACnE,GAAG,EAGH,IAAOC,EAAQC","names":["PantheraBlackBox","options","response","data","error","config","el","tier","schema","index","script","schemas","baseSchema","product","service","faqs","faq","form","formElement","event","target","autofillData","fieldName","selector","field","slot","sanitizedId","escapedId","slotElement","interactionTimeout","sendInteraction","eventType","metrics","key","configUrl","telemetryUrl","siteId","blackBox","runtime_default","PantheraBlackBox"]}
1
+ {"version":3,"sources":["../src/runtime.ts"],"sourcesContent":["/**\n * Panthera Black Box Runtime\n * \n * AI Search Optimization Runtime - Optimizes websites for AI search engines\n * (ChatGPT, Perplexity, Claude, etc.) by injecting structured data and building\n * authority signals that AI models can understand and prioritize.\n * \n * Key Features:\n * - JSON-LD schema injection for AI model comprehension\n * - Authority Grove integration for trust signals\n * - TruthSeeker integration for factual accuracy\n * - Telemetry for AI search visibility tracking\n * \n * Designed to be <10KB gzipped when compiled.\n * \n * Safety: No eval(), no Function(), no arbitrary code execution.\n * All operations are declarative JSON transformations only.\n */\n\ninterface AutoFillForm {\n selector: string;\n map: Record<string, string>;\n}\n\ninterface AutofillConfig {\n enabled?: boolean;\n forms?: AutoFillForm[];\n}\n\ninterface AdSlot {\n id: string;\n contexts: string[];\n}\n\ninterface AdsConfig {\n slots?: AdSlot[];\n}\n\ninterface AuthorityGroveNode {\n sameAs?: string[];\n keywords?: string[];\n}\n\ninterface AuthorityGroveConfig {\n node?: AuthorityGroveNode;\n}\n\ninterface ProductConfig {\n name?: string;\n description?: string;\n}\n\ninterface ServiceConfig {\n name?: string;\n description?: string;\n}\n\ninterface FaqConfig {\n question: string;\n answer: string;\n}\n\ninterface BlackBoxConfig {\n panthera_blackbox: {\n version: string;\n site: {\n domain: string;\n brand: string;\n verticals: string[];\n geo: string[];\n };\n telemetry: {\n emit: boolean;\n keys: string[];\n };\n tier?: 'bronze' | 'silver' | 'gold';\n autofill?: AutofillConfig;\n ads?: AdsConfig;\n authority_grove?: AuthorityGroveConfig;\n products?: ProductConfig[];\n services?: ServiceConfig[];\n faqs?: FaqConfig[];\n [key: string]: unknown;\n };\n}\n\ninterface TelemetryEvent {\n schema: string;\n tenant: string;\n timestamp: string;\n source: 'blackbox';\n context?: Record<string, unknown>;\n metrics: Record<string, number>;\n}\n\nclass PantheraBlackBox {\n private config: BlackBoxConfig | null = null;\n private configUrl: string;\n private telemetryUrl: string;\n private siteId: string;\n private initialized = false;\n\n constructor(options: { configUrl: string; telemetryUrl: string; siteId: string }) {\n this.configUrl = options.configUrl;\n this.telemetryUrl = options.telemetryUrl;\n this.siteId = options.siteId;\n }\n\n /**\n * Initialize the Black Box by loading configuration\n */\n async init(): Promise<void> {\n if (this.initialized) return;\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:53',message:'Black Box init started',data:{configUrl:this.configUrl,siteId:this.siteId},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n try {\n const response = await fetch(this.configUrl, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n cache: 'no-cache',\n });\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:64',message:'Config fetch response received',data:{ok:response.ok,status:response.status,statusText:response.statusText},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n if (!response.ok) {\n throw new Error(`Failed to load config: ${response.status}`);\n }\n\n const data = await response.json();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:72',message:'Config JSON parsed',data:{hasPantheraBlackbox:!!data.panthera_blackbox,hasSite:!!data.panthera_blackbox?.site,brand:data.panthera_blackbox?.site?.brand,telemetryEmit:data.panthera_blackbox?.telemetry?.emit},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n \n // Basic validation - ensure it has the expected structure\n if (!data.panthera_blackbox || !data.panthera_blackbox.site) {\n throw new Error('Invalid config structure');\n }\n\n this.config = data as BlackBoxConfig;\n this.initialized = true;\n\n // Apply configuration if needed\n this.applyConfig();\n\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:85',message:'Config applied',data:{initialized:this.initialized,telemetryEmit:this.config.panthera_blackbox.telemetry?.emit},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n\n // Start telemetry if enabled\n if (this.config.panthera_blackbox.telemetry?.emit) {\n this.startTelemetry();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:90',message:'Telemetry started',data:{telemetryUrl:this.telemetryUrl},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n }\n } catch (error) {\n console.error('[Panthera Black Box] Initialization failed:', error);\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:95',message:'Black Box init failed',data:{error:error instanceof Error?error.message:String(error)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n \n // Fail silently in production, but log for debugging\n }\n }\n\n /**\n * Apply configuration to the page (declarative transformations only)\n */\n private applyConfig(): void {\n if (!this.config) return;\n\n const config = this.config.panthera_blackbox;\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:95',message:'applyConfig called',data:{hasConfig:!!this.config,brand:config.site?.brand,telemetryEmit:config.telemetry?.emit,autofillEnabled:config.autofill?.enabled,hasAds:!!config.ads?.slots},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'E'})}).catch(()=>{});\n // #endregion\n \n // Inject JSON-LD schema if configured\n this.injectSchema(config);\n \n // Initialize AutoFill if enabled\n if (config.autofill?.enabled && config.autofill.forms) {\n this.initializeAutoFill(config);\n }\n \n // Initialize ad slots if configured\n if (config.ads?.slots) {\n this.initializeAdSlots(config);\n }\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'black-box/runtime.ts:112',message:'applyConfig completed',data:{schemaInjected:!!document.querySelector('script[data-panthera]')},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'E'})}).catch(()=>{});\n // #endregion\n }\n\n /**\n * Inject JSON-LD schema\n */\n private injectSchema(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof document === 'undefined') return;\n \n // Remove existing Panthera schemas if present\n const existing = document.querySelectorAll('script[type=\"application/ld+json\"][data-panthera]');\n existing.forEach(el => el.remove());\n \n // Get tier from config (if available) or default to bronze\n const tier = config.tier ?? 'bronze';\n \n // Generate schemas based on tier\n const schemas = this.generateSchemasForTier(config, tier);\n \n // Inject all schemas\n schemas.forEach((schema, index) => {\n const script = document.createElement('script');\n script.type = 'application/ld+json';\n script.setAttribute('data-panthera', 'true');\n script.setAttribute('data-schema-index', index.toString());\n script.textContent = JSON.stringify(schema);\n document.head.appendChild(script);\n });\n }\n\n /**\n * Generate schemas based on tier\n */\n private generateSchemasForTier(\n config: BlackBoxConfig['panthera_blackbox'],\n tier: 'bronze' | 'silver' | 'gold'\n ): unknown[] {\n const schemas: unknown[] = [];\n \n // Base Organization schema (all tiers)\n const baseSchema = {\n '@context': 'https://schema.org',\n '@type': 'Organization',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n };\n \n // Add authority grove data if available\n if (config.authority_grove?.node) {\n (baseSchema as Record<string, unknown>).sameAs = config.authority_grove.node.sameAs;\n (baseSchema as Record<string, unknown>).keywords = config.authority_grove.node.keywords;\n }\n \n schemas.push(baseSchema);\n \n // Silver and Gold tiers get additional schemas\n if (tier === 'silver' || tier === 'gold') {\n // Add Product schema if product data exists in config\n if (config.products) {\n const products = config.products;\n products.forEach((product) => {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'Product',\n name: product.name || config.site.brand,\n description: product.description,\n brand: {\n '@type': 'Brand',\n name: config.site.brand,\n },\n url: `https://${config.site.domain}`,\n });\n });\n }\n \n // Add Service schema if service data exists\n if (config.services) {\n const services = config.services;\n services.forEach((service) => {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'Service',\n name: service.name || config.site.brand,\n description: service.description,\n provider: {\n '@type': 'Organization',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n },\n });\n });\n }\n \n // Add LocalBusiness schema if geo data exists\n if (config.site.geo && config.site.geo.length > 0) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'LocalBusiness',\n name: config.site.brand,\n url: `https://${config.site.domain}`,\n areaServed: config.site.geo,\n });\n }\n \n // Add FAQ schema if FAQ data exists\n if (config.faqs) {\n const faqs = config.faqs;\n if (faqs.length > 0) {\n schemas.push({\n '@context': 'https://schema.org',\n '@type': 'FAQPage',\n mainEntity: faqs.map(faq => ({\n '@type': 'Question',\n name: faq.question,\n acceptedAnswer: {\n '@type': 'Answer',\n text: faq.answer,\n },\n })),\n });\n }\n }\n }\n \n return schemas;\n }\n\n /**\n * Initialize AutoFill for forms\n */\n private initializeAutoFill(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof window === 'undefined' || !config.autofill?.forms) return;\n \n config.autofill.forms.forEach((form: AutoFillForm) => {\n const formElement = document.querySelector(form.selector);\n if (formElement) {\n // Store form config for later use\n (formElement as HTMLElement & { pantheraAutoFill?: typeof form }).pantheraAutoFill = form;\n \n // Listen for first field focus to trigger AutoFill\n formElement.addEventListener('focusin', (event: Event) => {\n const target = event.target as HTMLElement;\n if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.tagName === 'SELECT') {\n this.triggerAutoFill(form);\n }\n }, { once: true });\n }\n });\n }\n\n /**\n * Trigger AutoFill for a form\n */\n private async triggerAutoFill(form: { selector: string; map: Record<string, string> }): Promise<void> {\n // In production, this would fetch CFP data from API\n // For now, use placeholder data\n const autofillData: Record<string, string> = {};\n \n // Apply AutoFill to form fields\n const formElement = document.querySelector(form.selector);\n if (!formElement) return;\n \n for (const [fieldName, selector] of Object.entries(form.map)) {\n const field = formElement.querySelector(selector) as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;\n if (field && autofillData[fieldName]) {\n field.value = autofillData[fieldName];\n field.dispatchEvent(new Event('input', { bubbles: true }));\n }\n }\n }\n\n /**\n * Initialize ad slots\n */\n private initializeAdSlots(config: BlackBoxConfig['panthera_blackbox']): void {\n if (typeof window === 'undefined' || !config.ads?.slots) return;\n \n config.ads.slots.forEach((slot: AdSlot) => {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:226',message:'initializeAdSlots - original slot.id',data:{slotId:slot.id,slotIdType:typeof slot.id,slotIdString:String(slot.id),slotIdJSON:JSON.stringify(slot.id)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n \n // Sanitize slot ID - aggressively remove quotes and ensure it's a valid CSS selector\n let sanitizedId = String(slot.id || '').trim();\n // Remove all quotes (single and double) from anywhere in the string\n sanitizedId = sanitizedId.replace(/[\"']/g, '');\n // Remove any remaining whitespace\n sanitizedId = sanitizedId.trim();\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:232',message:'initializeAdSlots - after sanitization',data:{sanitizedId,originalSlotId:slot.id,sanitizedLength:sanitizedId.length},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n \n if (!sanitizedId) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:236',message:'initializeAdSlots - empty after sanitization',data:{originalSlotId:slot.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'A'})}).catch(()=>{});\n // #endregion\n return;\n }\n \n try {\n // Escape special CSS characters in the ID (but NOT quotes - they should already be removed)\n // Only escape characters that need escaping in attribute selectors\n const escapedId = sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&');\n // Double-check: ensure no quotes made it through\n if (escapedId.includes('\"') || escapedId.includes(\"'\")) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:243',message:'initializeAdSlots - quotes detected in escapedId',data:{escapedId,sanitizedId,originalSlotId:slot.id},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});\n // #endregion\n throw new Error(`Slot ID contains quotes after sanitization: ${escapedId}`);\n }\n \n const selector = `[data-ad-slot=\"${escapedId}\"]`;\n \n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:250',message:'initializeAdSlots - selector construction',data:{escapedId,selector,selectorLength:selector.length,selectorChars:Array.from(selector)},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'B'})}).catch(()=>{});\n // #endregion\n \n const slotElement = document.querySelector(selector);\n \n if (slotElement) {\n // Store slot config\n (slotElement as HTMLElement & { pantheraAdSlot?: typeof slot }).pantheraAdSlot = slot;\n \n // In production, this would load ad creative and track impressions\n this.loadAdCreative(slot);\n } else {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:262',message:'initializeAdSlots - element not found',data:{selector,escapedId},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'D'})}).catch(()=>{});\n // #endregion\n }\n } catch (error) {\n // #region agent log\n fetch('http://127.0.0.1:7251/ingest/f2bef142-91a5-4d7a-be78-4c2383eb5638',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'runtime.ts:267',message:'initializeAdSlots - error caught',data:{error:String(error),errorMessage:(error as Error).message,slotId:slot.id,sanitizedId,escapedId:sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&'),selector:`[data-ad-slot=\"${sanitizedId.replace(/[!\"#$%&'()*+,.\\/:;<=>?@[\\\\\\]^`{|}~]/g, '\\\\$&')}\"]`},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'C'})}).catch(()=>{});\n // #endregion\n \n console.error(`[Panthera Black Box] Invalid ad slot selector for ID: ${slot.id}`, error);\n }\n });\n }\n\n /**\n * Load ad creative for a slot\n */\n private async loadAdCreative(slot: { id: string; contexts: string[] }): Promise<void> {\n // In production, this would:\n // 1. Fetch creative from API based on slot contexts\n // 2. Calculate CPM\n // 3. Render ad\n // 4. Track impression\n \n // Placeholder: just log the slot\n console.debug('[Panthera Black Box] Ad slot initialized:', slot.id);\n }\n\n /**\n * Start telemetry collection\n */\n private startTelemetry(): void {\n if (!this.config?.panthera_blackbox.telemetry?.emit) return;\n\n // Collect initial telemetry\n this.sendTelemetry('page_view', {\n url: window.location.href,\n referrer: document.referrer,\n });\n\n // Listen for user interactions (if configured)\n if (typeof window !== 'undefined') {\n // Throttled event listeners for performance\n let interactionTimeout: number | null = null;\n \n const sendInteraction = () => {\n if (interactionTimeout) return;\n interactionTimeout = window.setTimeout(() => {\n this.sendTelemetry('interaction', {\n timestamp: new Date().toISOString(),\n });\n interactionTimeout = null;\n }, 1000);\n };\n\n // Only track if explicitly configured\n document.addEventListener('click', sendInteraction, { passive: true });\n document.addEventListener('scroll', sendInteraction, { passive: true });\n }\n }\n\n /**\n * Send telemetry event\n */\n private async sendTelemetry(eventType: string, data: Record<string, unknown>): Promise<void> {\n if (!this.config?.panthera_blackbox.telemetry?.emit) return;\n\n const event: TelemetryEvent = {\n schema: 'panthera.blackbox.v1',\n tenant: this.config.panthera_blackbox.site.domain,\n timestamp: new Date().toISOString(),\n source: 'blackbox',\n context: {\n event_type: eventType,\n ...data,\n },\n metrics: this.collectMetrics(),\n };\n\n try {\n // Use sendBeacon for reliability (doesn't block page unload)\n if (navigator.sendBeacon) {\n navigator.sendBeacon(\n this.telemetryUrl,\n JSON.stringify(event)\n );\n } else {\n // Fallback to fetch\n await fetch(this.telemetryUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(event),\n keepalive: true,\n });\n }\n } catch (error) {\n // Fail silently - telemetry should never break the site\n console.debug('[Panthera Black Box] Telemetry failed:', error);\n }\n }\n\n /**\n * Collect metrics based on configured keys\n */\n private collectMetrics(): Record<string, number> {\n const metrics: Record<string, number> = {};\n const keys = this.config?.panthera_blackbox.telemetry?.keys || [];\n\n // Collect basic metrics if keys are configured\n // This is safe - we're only reading properties, not executing code\n keys.forEach((key) => {\n // Map telemetry keys to actual metrics\n // For now, return placeholder values\n // In production, these would be calculated from actual page state\n metrics[key] = 0;\n });\n\n return metrics;\n }\n\n /**\n * Get current configuration (read-only)\n */\n getConfig(): BlackBoxConfig | null {\n return this.config;\n }\n\n /**\n * Reload configuration\n */\n async reload(): Promise<void> {\n this.initialized = false;\n await this.init();\n }\n}\n\n// Auto-initialize if script tag has data attributes\n(function () {\n if (typeof window === 'undefined') return;\n\n const script = document.currentScript as HTMLScriptElement | null;\n if (!script) return;\n\n const configUrl = script.getAttribute('data-config-url');\n const telemetryUrl = script.getAttribute('data-telemetry-url');\n const siteId = script.getAttribute('data-site-id');\n\n if (!configUrl || !telemetryUrl || !siteId) {\n console.warn('[Panthera Black Box] Missing required data attributes');\n return;\n }\n\n const blackBox = new PantheraBlackBox({\n configUrl,\n telemetryUrl,\n siteId,\n });\n\n // Initialize when DOM is ready\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => blackBox.init());\n } else {\n blackBox.init();\n }\n\n // Expose globally for manual control (optional)\n (window as unknown as { PantheraBlackBox: typeof PantheraBlackBox }).PantheraBlackBox = PantheraBlackBox;\n (window as unknown as { panthera: PantheraBlackBox }).panthera = blackBox;\n})();\n\nexport { PantheraBlackBox };\nexport default PantheraBlackBox;\n"],"mappings":";AA+FA,IAAMA,EAAN,KAAuB,CAOrB,YAAYC,EAAsE,CANlF,KAAQ,OAAgC,KAIxC,KAAQ,YAAc,GAGpB,KAAK,UAAYA,EAAQ,UACzB,KAAK,aAAeA,EAAQ,aAC5B,KAAK,OAASA,EAAQ,MACxB,CAKA,MA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AAK,EAC1B,UAAW,EACb,CAAC,CAEL,OAASf,EAAO,CAEd,QAAQ,MAAM,yCAA0CA,CAAK,CAC/D,CACF,CAKQ,gBAAyC,CAC/C,IAAM4B,EAAkC,CAAC,EAKzC,OAJa,KAAK,QAAQ,kBAAkB,WAAW,MAAQ,CAAC,GAI3D,QAASC,GAAQ,CAIpBD,EAAQC,CAAG,EAAI,CACjB,CAAC,EAEMD,CACT,CAKA,WAAmC,CACjC,OAAO,KAAK,MACd,CAKA,MAAM,QAAwB,CAC5B,KAAK,YAAc,GACnB,MAAM,KAAK,KAAK,CAClB,CACF,GAGC,UAAY,CACX,GAAI,OAAO,OAAW,IAAa,OAEnC,IAAMtB,EAAS,SAAS,cACxB,GAAI,CAACA,EAAQ,OAEb,IAAMwB,EAAYxB,EAAO,aAAa,iBAAiB,EACjDyB,EAAezB,EAAO,aAAa,oBAAoB,EACvD0B,EAAS1B,EAAO,aAAa,cAAc,EAEjD,GAAI,CAACwB,GAAa,CAACC,GAAgB,CAACC,EAAQ,CAC1C,QAAQ,KAAK,uDAAuD,EACpE,MACF,CAEA,IAAMC,EAAW,IAAIrC,EAAiB,CACpC,UAAAkC,EACA,aAAAC,EACA,OAAAC,CACF,CAAC,EAGG,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoB,IAAMC,EAAS,KAAK,CAAC,EAEnEA,EAAS,KAAK,EAIf,OAAoE,iBAAmBrC,EACvF,OAAqD,SAAWqC,CACnE,GAAG,EAGH,IAAOC,EAAQC","names":["PantheraBlackBox","options","response","data","error","config","el","tier","schema","index","script","schemas","baseSchema","product","service","faqs","faq","form","formElement","event","target","autofillData","fieldName","selector","field","slot","sanitizedId","escapedId","slotElement","interactionTimeout","sendInteraction","eventType","metrics","key","configUrl","telemetryUrl","siteId","blackBox","runtime_default","PantheraBlackBox"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@careerdriver/black-box",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -26,10 +26,9 @@
26
26
  "type-check": "tsc --noEmit",
27
27
  "prepublishOnly": "pnpm build"
28
28
  },
29
- "dependencies": {},
30
29
  "devDependencies": {
31
- "@types/node": "^20.10.0",
32
- "tsup": "^8.0.1",
33
- "typescript": "^5.3.3"
30
+ "@types/node": "^25.0.10",
31
+ "tsup": "^8.5.1",
32
+ "typescript": "^5.9.3"
34
33
  }
35
34
  }