@v-tilt/browser 1.3.0 → 1.4.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.
Files changed (45) hide show
  1. package/dist/all-external-dependencies.js.map +1 -1
  2. package/dist/array.full.js +1 -1
  3. package/dist/array.full.js.map +1 -1
  4. package/dist/array.js +1 -1
  5. package/dist/array.js.map +1 -1
  6. package/dist/array.no-external.js +1 -1
  7. package/dist/array.no-external.js.map +1 -1
  8. package/dist/chat.js +2 -0
  9. package/dist/chat.js.map +1 -0
  10. package/dist/entrypoints/chat.d.ts +22 -0
  11. package/dist/extensions/chat/chat-wrapper.d.ts +172 -0
  12. package/dist/extensions/chat/chat.d.ts +87 -0
  13. package/dist/extensions/chat/index.d.ts +10 -0
  14. package/dist/extensions/chat/types.d.ts +156 -0
  15. package/dist/external-scripts-loader.js +1 -1
  16. package/dist/external-scripts-loader.js.map +1 -1
  17. package/dist/main.js +1 -1
  18. package/dist/main.js.map +1 -1
  19. package/dist/module.d.ts +279 -2
  20. package/dist/module.js +1 -1
  21. package/dist/module.js.map +1 -1
  22. package/dist/module.no-external.d.ts +279 -2
  23. package/dist/module.no-external.js +1 -1
  24. package/dist/module.no-external.js.map +1 -1
  25. package/dist/recorder.js.map +1 -1
  26. package/dist/types.d.ts +27 -0
  27. package/dist/utils/globals.d.ts +111 -1
  28. package/dist/vtilt.d.ts +11 -1
  29. package/dist/web-vitals.js.map +1 -1
  30. package/lib/entrypoints/chat.d.ts +22 -0
  31. package/lib/entrypoints/chat.js +32 -0
  32. package/lib/entrypoints/external-scripts-loader.js +1 -1
  33. package/lib/extensions/chat/chat-wrapper.d.ts +172 -0
  34. package/lib/extensions/chat/chat-wrapper.js +497 -0
  35. package/lib/extensions/chat/chat.d.ts +87 -0
  36. package/lib/extensions/chat/chat.js +1004 -0
  37. package/lib/extensions/chat/index.d.ts +10 -0
  38. package/lib/extensions/chat/index.js +27 -0
  39. package/lib/extensions/chat/types.d.ts +156 -0
  40. package/lib/extensions/chat/types.js +22 -0
  41. package/lib/types.d.ts +27 -0
  42. package/lib/utils/globals.d.ts +111 -1
  43. package/lib/vtilt.d.ts +11 -1
  44. package/lib/vtilt.js +42 -1
  45. package/package.json +2 -1
@@ -86,6 +86,10 @@ interface VTiltConfig {
86
86
  session_recording?: SessionRecordingOptions;
87
87
  /** Disable session recording (convenience flag) */
88
88
  disable_session_recording?: boolean;
89
+ /** Chat widget configuration */
90
+ chat?: ChatWidgetConfig;
91
+ /** Disable chat (convenience flag) */
92
+ disable_chat?: boolean;
89
93
  /** Global attributes added to all events */
90
94
  globalAttributes?: Record<string, string>;
91
95
  /** Bootstrap data for initialization */
@@ -297,6 +301,29 @@ interface SessionRecordingOptions {
297
301
  /** Internal: Mutation throttler bucket size */
298
302
  __mutationThrottlerBucketSize?: number;
299
303
  }
304
+ /** Chat widget configuration */
305
+ interface ChatWidgetConfig {
306
+ /** Enable/disable chat widget (default: auto from dashboard) */
307
+ enabled?: boolean;
308
+ /** Auto-fetch settings from dashboard (default: true) */
309
+ autoConfig?: boolean;
310
+ /** Widget position (default: 'bottom-right') */
311
+ position?: "bottom-right" | "bottom-left";
312
+ /** Widget header/greeting message */
313
+ greeting?: string;
314
+ /** Widget primary color */
315
+ color?: string;
316
+ /** Start in AI mode (default: true) */
317
+ aiMode?: boolean;
318
+ /** AI greeting message (first message from AI) */
319
+ aiGreeting?: string;
320
+ /** Preload widget script on idle vs on-demand */
321
+ preload?: boolean;
322
+ /** Offline message shown when business is unavailable */
323
+ offlineMessage?: string;
324
+ /** Collect email when offline */
325
+ collectEmailOffline?: boolean;
326
+ }
300
327
  interface RemoteConfig {
301
328
  /** Default to identified_only mode */
302
329
  defaultIdentifiedOnly?: boolean;
@@ -407,6 +434,94 @@ interface SessionRecordingConfig {
407
434
  /** Recording start reason */
408
435
  type SessionStartReason = "recording_initialized" | "session_id_changed" | "linked_flag_matched" | "linked_flag_overridden" | "sampling_overridden" | "url_trigger_matched" | "event_trigger_matched" | "sampled";
409
436
 
437
+ /**
438
+ * Chat message structure (matches PostgreSQL chat_messages table)
439
+ * Note: Read status is determined by cursor comparison, not per-message
440
+ */
441
+ interface ChatMessage {
442
+ id: string;
443
+ channel_id: string;
444
+ sender_type: "user" | "agent" | "ai" | "system";
445
+ sender_id: string | null;
446
+ sender_name: string | null;
447
+ sender_avatar_url: string | null;
448
+ content: string;
449
+ content_type: "text" | "html" | "attachment";
450
+ metadata: Record<string, unknown>;
451
+ created_at: string;
452
+ }
453
+ /**
454
+ * Chat channel structure (maps 1:1 to Ably channel)
455
+ */
456
+ interface ChatChannel {
457
+ id: string;
458
+ project_id: string;
459
+ person_id: string;
460
+ distinct_id: string;
461
+ status: "open" | "closed" | "snoozed";
462
+ ai_mode: boolean;
463
+ unread_count: number;
464
+ last_message_at: string | null;
465
+ last_message_preview: string | null;
466
+ last_message_sender: "user" | "agent" | "ai" | "system" | null;
467
+ user_last_read_at: string | null;
468
+ agent_last_read_at: string | null;
469
+ created_at: string;
470
+ }
471
+ /**
472
+ * Chat widget configuration
473
+ *
474
+ * Settings can come from two sources:
475
+ * 1. Dashboard (fetched from /api/chat/settings) - "snippet-only" mode
476
+ * 2. Code config (passed to vt.init) - overrides dashboard settings
477
+ *
478
+ * This enables Intercom-like flexibility: just add snippet OR customize with code.
479
+ */
480
+ interface ChatConfig {
481
+ /**
482
+ * Enable/disable chat widget.
483
+ * - undefined: Use dashboard setting (auto-fetch)
484
+ * - true: Enable (override dashboard)
485
+ * - false: Disable entirely
486
+ */
487
+ enabled?: boolean;
488
+ /**
489
+ * Auto-fetch settings from dashboard (default: true)
490
+ * When true, SDK fetches /api/chat/settings and uses those as base config.
491
+ * Code config always overrides fetched settings.
492
+ */
493
+ autoConfig?: boolean;
494
+ /** Widget position (default: 'bottom-right') */
495
+ position?: "bottom-right" | "bottom-left";
496
+ /** Widget header/greeting message */
497
+ greeting?: string;
498
+ /** Widget primary color */
499
+ color?: string;
500
+ /** Start in AI mode (default: true) */
501
+ aiMode?: boolean;
502
+ /** AI greeting message (first message from AI) */
503
+ aiGreeting?: string;
504
+ /** Preload widget script on idle vs on-demand */
505
+ preload?: boolean;
506
+ /** Custom theme */
507
+ theme?: ChatTheme;
508
+ /** Offline message shown when business is unavailable */
509
+ offlineMessage?: string;
510
+ /** Collect email when offline */
511
+ collectEmailOffline?: boolean;
512
+ }
513
+ /**
514
+ * Chat theme customization
515
+ */
516
+ interface ChatTheme {
517
+ primaryColor?: string;
518
+ fontFamily?: string;
519
+ borderRadius?: string;
520
+ headerBgColor?: string;
521
+ userBubbleColor?: string;
522
+ agentBubbleColor?: string;
523
+ }
524
+
410
525
  /**
411
526
  * Session Recording Wrapper
412
527
  *
@@ -467,6 +582,159 @@ declare class SessionRecordingWrapper {
467
582
  private _onScriptLoaded;
468
583
  }
469
584
 
585
+ /**
586
+ * Message callback type
587
+ */
588
+ type MessageCallback = (message: ChatMessage) => void;
589
+ /**
590
+ * Typing callback type
591
+ */
592
+ type TypingCallback = (isTyping: boolean, senderType: string) => void;
593
+ /**
594
+ * Connection callback type
595
+ */
596
+ type ConnectionCallback = (connected: boolean) => void;
597
+ /**
598
+ * Unsubscribe function type
599
+ */
600
+ type Unsubscribe = () => void;
601
+
602
+ /**
603
+ * Chat Wrapper
604
+ *
605
+ * This is the lightweight class that lives in the main bundle.
606
+ * It handles:
607
+ * - Auto-fetching settings from dashboard (Intercom-like)
608
+ * - Merging server settings with code config
609
+ * - Deciding if chat should be enabled
610
+ * - Lazy loading the actual chat widget code
611
+ * - Delegating to LazyLoadedChat
612
+ * - Queuing messages/callbacks before widget loads
613
+ */
614
+ declare class ChatWrapper {
615
+ private readonly _instance;
616
+ private _lazyLoadedChat;
617
+ private _config;
618
+ private _serverConfig;
619
+ private _configFetched;
620
+ private _isLoading;
621
+ private _loadError;
622
+ private _pendingMessages;
623
+ private _pendingCallbacks;
624
+ private _messageCallbacks;
625
+ private _typingCallbacks;
626
+ private _connectionCallbacks;
627
+ constructor(_instance: VTilt, config?: ChatConfig);
628
+ /**
629
+ * Whether the chat widget is open
630
+ */
631
+ get isOpen(): boolean;
632
+ /**
633
+ * Whether connected to realtime service
634
+ */
635
+ get isConnected(): boolean;
636
+ /**
637
+ * Whether the widget is loading
638
+ */
639
+ get isLoading(): boolean;
640
+ /**
641
+ * Number of unread messages
642
+ */
643
+ get unreadCount(): number;
644
+ /**
645
+ * Current channel (if any)
646
+ */
647
+ get channel(): ChatChannel | null;
648
+ /**
649
+ * Open the chat widget
650
+ */
651
+ open(): void;
652
+ /**
653
+ * Close the chat widget
654
+ */
655
+ close(): void;
656
+ /**
657
+ * Toggle the chat widget open/closed
658
+ */
659
+ toggle(): void;
660
+ /**
661
+ * Show the chat widget (make visible but not necessarily open)
662
+ */
663
+ show(): void;
664
+ /**
665
+ * Hide the chat widget
666
+ */
667
+ hide(): void;
668
+ /**
669
+ * Send a message
670
+ */
671
+ sendMessage(content: string): void;
672
+ /**
673
+ * Mark messages as read
674
+ */
675
+ markAsRead(): void;
676
+ /**
677
+ * Subscribe to new messages
678
+ */
679
+ onMessage(callback: MessageCallback): Unsubscribe;
680
+ /**
681
+ * Subscribe to typing indicators
682
+ */
683
+ onTyping(callback: TypingCallback): Unsubscribe;
684
+ /**
685
+ * Subscribe to connection changes
686
+ */
687
+ onConnectionChange(callback: ConnectionCallback): Unsubscribe;
688
+ /**
689
+ * Start chat if enabled, called by VTilt after init
690
+ *
691
+ * This method supports two modes (Intercom-like):
692
+ * 1. Auto-config: Fetch settings from /api/chat/settings (default)
693
+ * 2. Code-only: Use only code config (autoConfig: false)
694
+ */
695
+ startIfEnabled(): Promise<void>;
696
+ /**
697
+ * Update configuration
698
+ */
699
+ updateConfig(config: Partial<ChatConfig>): void;
700
+ /**
701
+ * Get the merged configuration (server + code, code takes precedence)
702
+ */
703
+ getMergedConfig(): ChatConfig;
704
+ /**
705
+ * Destroy the chat widget
706
+ */
707
+ destroy(): void;
708
+ private get _isChatEnabled();
709
+ /**
710
+ * Fetch chat settings from the server
711
+ * This enables "snippet-only" installation where widget configures from dashboard
712
+ */
713
+ private _fetchServerSettings;
714
+ /**
715
+ * Show the chat bubble (launcher button) without fully loading the widget
716
+ * This creates a lightweight bubble that loads the full widget on click
717
+ */
718
+ private _showBubble;
719
+ private get _scriptName();
720
+ /**
721
+ * Schedule preload on idle
722
+ */
723
+ private _schedulePreload;
724
+ /**
725
+ * Lazy load and then execute callback
726
+ */
727
+ private _lazyLoadAndThen;
728
+ /**
729
+ * Lazy load the chat script
730
+ */
731
+ private _lazyLoad;
732
+ /**
733
+ * Called after the chat script is loaded
734
+ */
735
+ private _onScriptLoaded;
736
+ }
737
+
470
738
  /**
471
739
  * Request Queue - Event Batching (PostHog-style)
472
740
  *
@@ -498,6 +766,7 @@ declare class VTilt {
498
766
  private rateLimiter;
499
767
  historyAutocapture?: HistoryAutocapture;
500
768
  sessionRecording?: SessionRecordingWrapper;
769
+ chat?: ChatWrapper;
501
770
  __loaded: boolean;
502
771
  private _initial_pageview_captured;
503
772
  private _visibility_state_listener;
@@ -756,11 +1025,19 @@ declare class VTilt {
756
1025
  /**
757
1026
  * Check if session recording is active
758
1027
  */
759
- isSessionRecordingActive(): boolean;
1028
+ isRecordingActive(): boolean;
760
1029
  /**
761
1030
  * Get session recording ID
762
1031
  */
763
1032
  getSessionRecordingId(): string | null;
1033
+ /**
1034
+ * Initialize chat widget
1035
+ */
1036
+ private _initChat;
1037
+ /**
1038
+ * Build chat config from VTiltConfig
1039
+ */
1040
+ private _buildChatConfig;
764
1041
  /**
765
1042
  * _execute_array() deals with processing any vTilt function
766
1043
  * calls that were called before the vTilt library was loaded
@@ -783,4 +1060,4 @@ declare class VTilt {
783
1060
  declare const vt: VTilt;
784
1061
 
785
1062
  export { ALL_WEB_VITALS_METRICS, DEFAULT_WEB_VITALS_METRICS, VTilt, vt as default, vt };
786
- export type { AliasEvent, CaptureOptions, CapturePerformanceConfig, CaptureResult, EventPayload, FeatureFlagsConfig, GeolocationData, GroupsConfig, PersistenceMethod, Properties, Property, PropertyOperations, RemoteConfig, RequestOptions, SessionData, SessionIdChangedCallback, SessionRecordingMaskInputOptions, SessionRecordingOptions, SupportedWebVitalsMetric, TrackingEvent, UserIdentity, UserProperties, VTiltConfig, WebVitalMetric };
1063
+ export type { AliasEvent, CaptureOptions, CapturePerformanceConfig, CaptureResult, ChatWidgetConfig, EventPayload, FeatureFlagsConfig, GeolocationData, GroupsConfig, PersistenceMethod, Properties, Property, PropertyOperations, RemoteConfig, RequestOptions, SessionData, SessionIdChangedCallback, SessionRecordingMaskInputOptions, SessionRecordingOptions, SupportedWebVitalsMetric, TrackingEvent, UserIdentity, UserProperties, VTiltConfig, WebVitalMetric };
@@ -1,2 +1,2 @@
1
- function e(e,t,i,r,s,n,o){try{var a=e[n](o),u=a.value}catch(e){return void i(e)}a.done?t(u):Promise.resolve(u).then(r,s)}function t(t){return function(){var i=this,r=arguments;return new Promise(function(s,n){var o=t.apply(i,r);function a(t){e(o,s,n,a,u,"next",t)}function u(t){e(o,s,n,a,u,"throw",t)}a(void 0)})}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}class r{constructor(e){void 0===e&&(e={}),this.config=this.parseConfigFromScript(e)}parseConfigFromScript(e){if(!document.currentScript)return i({token:e.token||""},e);var t=document.currentScript,r=i({token:""},e);r.api_host=t.getAttribute("data-api-host")||t.getAttribute("data-host")||e.api_host,r.script_host=t.getAttribute("data-script-host")||e.script_host,r.proxy=t.getAttribute("data-proxy")||e.proxy,r.proxyUrl=t.getAttribute("data-proxy-url")||e.proxyUrl,r.token=t.getAttribute("data-token")||e.token||"",r.projectId=t.getAttribute("data-project-id")||e.projectId||"",r.domain=t.getAttribute("data-domain")||e.domain,r.storage=t.getAttribute("data-storage")||e.storage,r.stringifyPayload="false"!==t.getAttribute("data-stringify-payload");var s="true"===t.getAttribute("data-capture-performance");if(r.capture_performance=!!s||e.capture_performance,r.proxy&&r.proxyUrl)throw console.error("Error: Both data-proxy and data-proxy-url are specified. Please use only one of them."),new Error("Both data-proxy and data-proxy-url are specified. Please use only one of them.");for(var n of(r.globalAttributes=i({},e.globalAttributes),Array.from(t.attributes)))n.name.startsWith("data-vt-")&&(r.globalAttributes[n.name.slice(8).replace(/-/g,"_")]=n.value);return r}getConfig(){return i({},this.config)}updateConfig(e){this.config=i({},this.config,e)}}var s="__vt_session",n="__vt_window_id",o="__vt_primary_window",a="__vt_user_state",u="__vt_device_id",l="__vt_anonymous_id",d="__vt_distinct_id",h="__vt_user_properties",c="localStorage",g="localStorage+cookie",v="sessionStorage",f="memory",_="$initial_person_info";function p(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}function m(e){return!(!e||"string"!=typeof e)&&!(e.length<2||e.length>10240)}function y(e,t,i){if(e)if(Array.isArray(e))e.forEach((e,r)=>{t.call(i,e,r)});else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(i,e[r],r)}function w(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}function b(e,t){if(!t)return e;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function S(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];for(var s of i)for(var n of s)e.push(n);return e}var I="undefined"!=typeof window?window:void 0,T="undefined"!=typeof globalThis?globalThis:I,M=null==T?void 0:T.navigator,E=null==T?void 0:T.document,R=null==T?void 0:T.location,C=null==T?void 0:T.fetch,k=(null==T?void 0:T.XMLHttpRequest)&&"withCredentials"in new T.XMLHttpRequest?T.XMLHttpRequest:void 0;null==T||T.AbortController;var x=null==M?void 0:M.userAgent,P=null!=I?I:{},L=31536e3,A=["herokuapp.com","vercel.app","netlify.app"];function O(e){var t;if(!e)return"";if("undefined"==typeof document)return"";var i=null===(t=document.location)||void 0===t?void 0:t.hostname;if(!i)return"";var r=i.match(/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i);return r?"."+r[0]:""}class ${constructor(e){var t,i;this.memoryStorage=new Map,this.method=e.method,this.cross_subdomain=null!==(t=e.cross_subdomain)&&void 0!==t?t:function(){var e;if("undefined"==typeof document)return!1;var t=null===(e=document.location)||void 0===e?void 0:e.hostname;if(!t)return!1;var i=t.split(".").slice(-2).join(".");for(var r of A)if(i===r)return!1;return!0}(),this.sameSite=e.sameSite||"Lax",this.secure=null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol}get(e){var t;try{if(this.method===f)return null!==(t=this.memoryStorage.get(e))&&void 0!==t?t:null;if(this.usesLocalStorage()){var i=localStorage.getItem(e);return null!==i?i:this.method===g?this.getCookie(e):null}return this.usesSessionStorage()?sessionStorage.getItem(e):this.getCookie(e)}catch(t){return console.warn('[StorageManager] Failed to get "'+e+'":',t),null}}set(e,t,i){try{if(this.method===f)return void this.memoryStorage.set(e,t);if(this.usesLocalStorage())return localStorage.setItem(e,t),void(this.method===g&&this.setCookie(e,t,i||L));if(this.usesSessionStorage())return void sessionStorage.setItem(e,t);this.setCookie(e,t,i||L)}catch(t){console.warn('[StorageManager] Failed to set "'+e+'":',t)}}remove(e){try{if(this.method===f)return void this.memoryStorage.delete(e);if(this.usesLocalStorage())return localStorage.removeItem(e),void(this.method===g&&this.removeCookie(e));if(this.usesSessionStorage())return void sessionStorage.removeItem(e);this.removeCookie(e)}catch(t){console.warn('[StorageManager] Failed to remove "'+e+'":',t)}}getWithExpiry(e){var t=this.get(e);if(!t)return null;try{var i=JSON.parse(t);return i.expiry&&Date.now()>i.expiry?(this.remove(e),null):i.value}catch(e){return null}}setWithExpiry(e,t,r){var s=i({value:t},r?{expiry:Date.now()+r}:{});this.set(e,JSON.stringify(s))}getJSON(e){var t=this.get(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return null}}setJSON(e,t,i){this.set(e,JSON.stringify(t),i)}getCookie(e){if("undefined"==typeof document)return null;var t=document.cookie.split(";");for(var i of t){var[r,...s]=i.trim().split("=");if(r===e){var n=s.join("=");try{return decodeURIComponent(n)}catch(e){return n}}}return null}setCookie(e,t,i){if("undefined"!=typeof document){var r=e+"="+encodeURIComponent(t);r+="; Max-Age="+i,r+="; path=/",r+="; SameSite="+this.sameSite,this.secure&&(r+="; Secure");var s=O(this.cross_subdomain);s&&(r+="; domain="+s),document.cookie=r}}removeCookie(e){if("undefined"!=typeof document){var t=O(this.cross_subdomain),i=e+"=; Max-Age=0; path=/";t&&(i+="; domain="+t),document.cookie=i,document.cookie=e+"=; Max-Age=0; path=/"}}usesLocalStorage(){return this.method===c||this.method===g}usesSessionStorage(){return this.method===v}canUseSessionStorage(){if(void 0===I||!(null==I?void 0:I.sessionStorage))return!1;try{var e="__vt_storage_test__";return I.sessionStorage.setItem(e,"test"),I.sessionStorage.removeItem(e),!0}catch(e){return!1}}getSessionStorage(){var e;return this.canUseSessionStorage()&&null!==(e=null==I?void 0:I.sessionStorage)&&void 0!==e?e:null}setMethod(e){this.method=e}getMethod(){return this.method}}class q{constructor(e,t){void 0===e&&(e="cookie"),this.storage=new $({method:e,cross_subdomain:t,sameSite:"Lax"}),this._windowId=void 0,this._initializeWindowId()}getSessionId(){var e=this._getSessionIdRaw();return e||(e=p(),this._storeSessionId(e)),e}setSessionId(){var e=this._getSessionIdRaw()||p();return this._storeSessionId(e),e}resetSessionId(){this._clearSessionId(),this.setSessionId(),this._setWindowId(p())}_getSessionIdRaw(){return this.storage.get(s)}_storeSessionId(e){this.storage.set(s,e,1800)}_clearSessionId(){this.storage.remove(s)}getWindowId(){if(this._windowId)return this._windowId;var e=this.storage.getSessionStorage();if(e){var t=e.getItem(n);if(t)return this._windowId=t,t}var i=p();return this._setWindowId(i),i}_setWindowId(e){if(e!==this._windowId){this._windowId=e;var t=this.storage.getSessionStorage();t&&t.setItem(n,e)}}_initializeWindowId(){var e=this.storage.getSessionStorage();if(e){var t=e.getItem(o),i=e.getItem(n);i&&!t?this._windowId=i:(i&&e.removeItem(n),this._setWindowId(p())),e.setItem(o,"true"),this._listenToUnload()}else this._windowId=p()}_listenToUnload(){var e=this.storage.getSessionStorage();I&&e&&w(I,"beforeunload",()=>{var e=this.storage.getSessionStorage();e&&e.removeItem(o)},{capture:!1})}updateStorageMethod(e,t){this.storage=new $({method:e,cross_subdomain:t,sameSite:"Lax"})}}function U(e){if(!E)return null;var t=E.createElement("a");return t.href=e,t}function D(e,t){for(var i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<i.length;r++){var s=i[r].split("=");if(s[0]===t){if(s.length<2)return"";var n=s[1];try{n=decodeURIComponent(n)}catch(e){}return n.replace(/\+/g," ")}}return""}function B(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[0]||"",n=r[1],o=s.split("?"),a=o[1],u=o[0],l=(a||"").split("&"),d=[],h=0;h<l.length;h++){var c=l[h].split("="),g=c[0],v=c.slice(1).join("=");-1!==t.indexOf(g)?d.push(g+"="+i):g&&d.push(g+(v?"="+v:""))}var f=d.join("&");return u+(f?"?"+f:"")+(n?"#"+n:"")}function z(e){return"function"==typeof e}var N="Mobile",j="iOS",W="Android",F="Tablet",V=W+" "+F,J="iPad",H="Apple",Q=H+" Watch",X="Safari",K="BlackBerry",G="Samsung",Z=G+"Browser",Y=G+" Internet",ee="Chrome",te=ee+" OS",ie=ee+" "+j,re="Internet Explorer",se=re+" "+N,ne="Opera",oe=ne+" Mini",ae="Edge",ue="Microsoft "+ae,le="Firefox",de=le+" "+j,he="Nintendo",ce="PlayStation",ge="Xbox",ve=W+" "+N,fe=N+" "+X,_e="Windows",pe=_e+" Phone",me="Nokia",ye="Ouya",we="Generic",be=we+" "+N.toLowerCase(),Se=we+" "+F.toLowerCase(),Ie="Konqueror",Te="(\\d+(\\.\\d+)?)",Me=new RegExp("Version/"+Te),Ee=new RegExp(ge,"i"),Re=new RegExp(ce+" \\w+","i"),Ce=new RegExp(he+" \\w+","i"),ke=new RegExp(K+"|PlayBook|BB10","i"),xe={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function Pe(e,t){return e.toLowerCase().includes(t.toLowerCase())}var Le=(e,t)=>t&&Pe(t,H)||function(e){return Pe(e,X)&&!Pe(e,ee)&&!Pe(e,W)}(e),Ae=function(e,t){return t=t||"",Pe(e," OPR/")&&Pe(e,"Mini")?oe:Pe(e," OPR/")?ne:ke.test(e)?K:Pe(e,"IE"+N)||Pe(e,"WPDesktop")?se:Pe(e,Z)?Y:Pe(e,ae)||Pe(e,"Edg/")?ue:Pe(e,"FBIOS")?"Facebook "+N:Pe(e,"UCWEB")||Pe(e,"UCBrowser")?"UC Browser":Pe(e,"CriOS")?ie:Pe(e,"CrMo")||Pe(e,ee)?ee:Pe(e,W)&&Pe(e,X)?ve:Pe(e,"FxiOS")?de:Pe(e.toLowerCase(),Ie.toLowerCase())?Ie:Le(e,t)?Pe(e,N)?fe:X:Pe(e,le)?le:Pe(e,"MSIE")||Pe(e,"Trident/")?re:Pe(e,"Gecko")?le:""},Oe={[se]:[new RegExp("rv:"+Te)],[ue]:[new RegExp(ae+"?\\/"+Te)],[ee]:[new RegExp("("+ee+"|CrMo)\\/"+Te)],[ie]:[new RegExp("CriOS\\/"+Te)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Te)],[X]:[Me],[fe]:[Me],[ne]:[new RegExp("(Opera|OPR)\\/"+Te)],[le]:[new RegExp(le+"\\/"+Te)],[de]:[new RegExp("FxiOS\\/"+Te)],[Ie]:[new RegExp("Konqueror[:/]?"+Te,"i")],[K]:[new RegExp(K+" "+Te),Me],[ve]:[new RegExp("android\\s"+Te,"i")],[Y]:[new RegExp(Z+"\\/"+Te)],[re]:[new RegExp("(rv:|MSIE )"+Te)],Mozilla:[new RegExp("rv:"+Te)]},$e=function(e,t){var i=Ae(e,t),r=Oe[i];if(void 0===r)return null;for(var s=0;s<r.length;s++){var n=r[s],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},qe=[[new RegExp(ge+"; "+ge+" (.*?)[);]","i"),e=>[ge,e&&e[1]||""]],[new RegExp(he,"i"),[he,""]],[new RegExp(ce,"i"),[ce,""]],[ke,[K,""]],[new RegExp(_e,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[pe,""];if(new RegExp(N).test(t)&&!/IEMobile\b/.test(t))return[_e+" "+N,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],s=xe[r]||"";return/arm/i.test(t)&&(s="RT"),[_e,s]}return[_e,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[j,t.join(".")]}return[j,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=void 0===e[2]?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+W+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+W+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[W,t.join(".")]}return[W,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[te,""]],[/Linux|debian/i,["Linux",""]]],Ue=function(e){return Ce.test(e)?he:Re.test(e)?ce:Ee.test(e)?ge:new RegExp(ye,"i").test(e)?ye:new RegExp("("+pe+"|WPDesktop)","i").test(e)?pe:/iPad/.test(e)?J:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Q:ke.test(e)?K:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(me,"i").test(e)?me:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(N).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?W:V:W:new RegExp("(pda|"+N+")","i").test(e)?be:new RegExp(F,"i").test(e)&&!new RegExp(F+" pc","i").test(e)?Se:""},De="https?://(.*)",Be=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ze=S(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Be),Ne="<masked>";function je(e){var t=function(e){return e?0===e.search(De+"google.([^/?]*)")?"google":0===e.search(De+"bing.com")?"bing":0===e.search(De+"yahoo.com")?"yahoo":0===e.search(De+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!==t?"q":"p",r={};if(null!==t){r.$search_engine=t;var s=E?D(E.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function We(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function Fe(){return(null==E?void 0:E.referrer)||"$direct"}function Ve(){var e;return(null==E?void 0:E.referrer)&&(null===(e=U(E.referrer))||void 0===e?void 0:e.host)||"$direct"}function Je(e){var t,{r:i,u:r}=e,s={$referrer:i,$referring_domain:null==i?void 0:"$direct"===i?"$direct":null===(t=U(i))||void 0===t?void 0:t.host};if(r){s.$current_url=r;var n=U(r);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var o=function(e){var t=ze.concat([]),i={};return y(t,function(t){var r=D(e,t);i[t]=r||null}),i}(r);b(s,o)}i&&b(s,je(i));return s}function He(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Qe(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function Xe(e,t){if(!x)return{};var i,r,s,[n,o]=function(e){for(var t=0;t<qe.length;t++){var[i,r]=qe[t],s=i.exec(e),n=s&&(z(r)?r(s,e):r);if(n)return n}return["",""]}(x);return b(function(e){var t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=e[i];null!=r&&""!==r&&(t[i]=r)}return t}({$os:n,$os_version:o,$browser:Ae(x,navigator.vendor),$device:Ue(x),$device_type:(r=x,s=Ue(r),s===J||s===V||"Kobo"===s||"Kindle Fire"===s||s===Se?F:s===he||s===ge||s===ce||s===ye?"Console":s===Q?"Wearable":s?N:"Desktop"),$timezone:He(),$timezone_offset:Qe()}),{$current_url:B(null==R?void 0:R.href,[],Ne),$host:null==R?void 0:R.host,$pathname:null==R?void 0:R.pathname,$raw_user_agent:x.length>1e3?x.substring(0,997)+"...":x,$browser_version:$e(x,navigator.vendor),$browser_language:We(),$browser_language_prefix:(i=We(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==I?void 0:I.screen.height,$screen_width:null==I?void 0:I.screen.width,$viewport_height:null==I?void 0:I.innerHeight,$viewport_width:null==I?void 0:I.innerWidth,$lib:"web",$lib_version:"1.0.7",$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}class Ke{constructor(e,t){void 0===e&&(e="localStorage"),this._cachedPersonProperties=null,this.storage=new $({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}getUserIdentity(){return i({},this.userIdentity)}getDistinctId(){return this.userIdentity.distinct_id}getAnonymousId(){return this.userIdentity.anonymous_id||(this.userIdentity.anonymous_id=this.generateAnonymousId(),this.storage.set(l,this.userIdentity.anonymous_id,L)),this.userIdentity.anonymous_id}getUserProperties(){return i({},this.userIdentity.properties)}getEffectiveId(){return this.userIdentity.distinct_id||this.getAnonymousId()}getDeviceId(){return this.userIdentity.device_id}getUserState(){return this.userIdentity.user_state}identify(e,t,r){if("number"==typeof e&&(e=e.toString(),console.warn("The first argument to vTilt.identify was a number, but it should be a string. It has been converted to a string.")),e)if(this.isDistinctIdStringLike(e))console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if("COOKIELESS_SENTINEL_VALUE"!==e){var s=this.userIdentity.distinct_id;if(this.userIdentity.distinct_id=e,!this.userIdentity.device_id){var n=s||this.userIdentity.anonymous_id;this.userIdentity.device_id=n,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:n})}e!==s&&(this.userIdentity.distinct_id=e);var o="anonymous"===this.userIdentity.user_state;e!==s&&o?(this.userIdentity.user_state="identified",t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):t||r?("anonymous"===this.userIdentity.user_state&&(this.userIdentity.user_state="identified"),t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),r&&Object.keys(r).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=r[e])}),this.saveUserIdentity()):e!==s&&(this.userIdentity.user_state="identified",this.saveUserIdentity())}else console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID is only used as a sentinel value.');else console.error("Unique user id has not been set in vTilt.identify")}setUserProperties(e,t){if(!e&&!t)return!1;var r=this.userIdentity.distinct_id||this.userIdentity.anonymous_id,s=this.getPersonPropertiesHash(r,e,t);return this._cachedPersonProperties===s?(console.info("VTilt: A duplicate setUserProperties call was made with the same properties. It has been ignored."),!1):(e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity(),this._cachedPersonProperties=s,!0)}reset(e){var t=this.generateAnonymousId(),r=this.userIdentity.device_id,s=e?this.generateDeviceId():r;this.userIdentity={distinct_id:null,anonymous_id:t,device_id:s,properties:{},user_state:"anonymous"},this._cachedPersonProperties=null,this.saveUserIdentity(),this.userIdentity.properties=i({},this.userIdentity.properties,{$last_vtilt_reset:(new Date).toISOString()}),this.saveUserIdentity()}setDistinctId(e){this.userIdentity.distinct_id=e,this.saveUserIdentity()}setUserState(e){this.userIdentity.user_state=e,this.saveUserIdentity()}updateUserProperties(e,t){e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity()}ensureDeviceId(e){this.userIdentity.device_id||(this.userIdentity.device_id=e,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:e}),this.saveUserIdentity())}createAlias(e,t){return this.isValidDistinctId(e)?(void 0===t&&(t=this.getDistinctId()||this.getAnonymousId()),this.isValidDistinctId(t)?e===t?(console.warn("alias matches current distinct_id - should use identify instead"),null):{distinct_id:e,original:t}:(console.warn("Invalid original distinct ID"),null)):(console.warn("Invalid alias provided"),null)}isDistinctIdStringLikePublic(e){return this.isDistinctIdStringLike(e)}set_initial_person_info(e,t){if(!this.getStoredUserProperties()[_]){var i=function(e,t){var i=e?S([],Be,t||[]):[],r=null==R?void 0:R.href.substring(0,1e3);return{r:Fe().substring(0,1e3),u:r?B(r,i,Ne):void 0}}(e,t);this.register_once({[_]:i},void 0)}}get_initial_props(){var e,t,i=this.getStoredUserProperties()[_];return i?(e=Je(i),t={},y(e,function(e,i){var r;t["$initial_"+(r=String(i),r.startsWith("$")?r.substring(1):r)]=e}),t):{}}update_referrer_info(){var e={$referrer:Fe(),$referring_domain:Ve()};this.register_once(e,void 0)}loadUserIdentity(){var e=this.storage.get(l)||this.generateAnonymousId(),t=this.storage.get(d)||null,i=this.storage.get(u)||this.generateDeviceId(),r=this.getStoredUserProperties(),s=this.storage.get(a)||"anonymous";return{distinct_id:t,anonymous_id:e||this.generateAnonymousId(),device_id:i,properties:r,user_state:s}}saveUserIdentity(){this.storage.set(l,this.userIdentity.anonymous_id,L),this.storage.set(u,this.userIdentity.device_id,L),this.storage.set(a,this.userIdentity.user_state,L),this.userIdentity.distinct_id?this.storage.set(d,this.userIdentity.distinct_id,L):this.storage.remove(d),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(h)||{}}setStoredUserProperties(e){this.storage.setJSON(h,e,L)}register_once(e,t){var i=this.getStoredUserProperties(),r=!1;for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(s in i||(i[s]=e[s],r=!0));if(t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(n in i||(i[n]=t[n],r=!0));r&&this.setStoredUserProperties(i)}generateAnonymousId(){return"anon_"+p()}generateDeviceId(){return"device_"+p()}getPersonPropertiesHash(e,t,i){return JSON.stringify({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}isValidDistinctId(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return!["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none"].includes(t)&&0!==e.trim().length}isDistinctIdStringLike(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none","demo","example","sample","placeholder"].includes(t)}updateStorageMethod(e,t){this.storage=new $({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}}var Ge=["LCP","CLS","FCP","INP","TTFB"],Ze=["LCP","CLS","FCP","INP"],Ye=9e5,et="[WebVitals]";class tt{constructor(e,t){this.initialized=!1,this.instance=t,this.buffer=this.createEmptyBuffer(),this.config=this.parseConfig(e.capture_performance),this.isEnabled&&I&&this.startIfEnabled()}parseConfig(e){return"boolean"==typeof e?{web_vitals:e}:"object"==typeof e&&null!==e?e:{web_vitals:!1}}get isEnabled(){var e=null==R?void 0:R.protocol;return("http:"===e||"https:"===e)&&!1!==this.config.web_vitals}get allowedMetrics(){return this.config.web_vitals_allowed_metrics||Ze}get flushTimeoutMs(){return this.config.web_vitals_delayed_flush_ms||5e3}get maxAllowedValue(){var e=this.config.__web_vitals_max_value;return void 0===e?Ye:0===e?0:e<6e4?Ye:e}createEmptyBuffer(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}getWebVitalsCallbacks(){var e;return null===(e=P.__VTiltExtensions__)||void 0===e?void 0:e.webVitalsCallbacks}startIfEnabled(){if(this.isEnabled&&!this.initialized){var e=this.getWebVitalsCallbacks();e?this.startCapturing(e):this.loadWebVitals()}}loadWebVitals(){var e,t=null===(e=P.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;t?t(this.instance,"web-vitals",e=>{if(e)console.error(et+" Failed to load web-vitals:",e);else{var t=this.getWebVitalsCallbacks();t?this.startCapturing(t):console.error(et+" web-vitals loaded but callbacks not registered")}}):console.warn(et+" External dependency loader not available. Include web-vitals.ts entrypoint or use array.full.js bundle.")}startCapturing(e){if(!this.initialized){var t=this.allowedMetrics,i=this.addToBuffer.bind(this);t.includes("LCP")&&e.onLCP&&e.onLCP(i),t.includes("CLS")&&e.onCLS&&e.onCLS(i,{reportAllChanges:!0}),t.includes("FCP")&&e.onFCP&&e.onFCP(i),t.includes("INP")&&e.onINP&&e.onINP(i),t.includes("TTFB")&&e.onTTFB&&e.onTTFB(i),this.initialized=!0}}getCurrentUrl(){var e;return null===(e=null==I?void 0:I.location)||void 0===e?void 0:e.href}getCurrentPathname(){return null==R?void 0:R.pathname}addToBuffer(e){try{if(!I||!E||!R)return;if(!(null==e?void 0:e.name)||void 0===(null==e?void 0:e.value))return void console.warn(et+" Invalid metric received",e);if(this.maxAllowedValue>0&&e.value>=this.maxAllowedValue&&"CLS"!==e.name)return void console.warn(et+" Ignoring "+e.name+" with value >= "+this.maxAllowedValue+"ms");var t=this.getCurrentUrl(),r=this.getCurrentPathname();if(!t)return void console.warn(et+" Could not determine current URL");this.buffer.url&&this.buffer.url!==t&&this.flush(),this.buffer.url||(this.buffer.url=t,this.buffer.pathname=r),this.buffer.firstMetricTimestamp||(this.buffer.firstMetricTimestamp=Date.now());var s=this.cleanAttribution(e.attribution),n=this.instance.getSessionId(),o=this.getWindowId(),a=i({},e,{attribution:s,timestamp:Date.now(),$current_url:t,$session_id:n,$window_id:o}),u=this.buffer.metrics.findIndex(t=>t.name===e.name);u>=0?this.buffer.metrics[u]=a:this.buffer.metrics.push(a),this.scheduleFlush(),this.buffer.metrics.length>=this.allowedMetrics.length&&this.flush()}catch(e){console.error(et+" Error adding metric to buffer:",e)}}cleanAttribution(e){if(e){var t=i({},e);return"interactionTargetElement"in t&&delete t.interactionTargetElement,t}}getWindowId(){var e;try{return(null===(e=this.instance.sessionManager)||void 0===e?void 0:e.getWindowId())||null}catch(e){return null}}scheduleFlush(){this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>{this.flush()},this.flushTimeoutMs)}flush(){if(this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0),0!==this.buffer.metrics.length){try{var e={$pathname:this.buffer.pathname,$current_url:this.buffer.url};for(var t of this.buffer.metrics)e["$web_vitals_"+t.name+"_value"]=t.value,e["$web_vitals_"+t.name+"_event"]={name:t.name,value:t.value,delta:t.delta,rating:t.rating,id:t.id,navigationType:t.navigationType,attribution:t.attribution,$session_id:t.$session_id,$window_id:t.$window_id};this.instance.capture("$web_vitals",e)}catch(e){console.error(et+" Error flushing metrics:",e)}this.buffer=this.createEmptyBuffer()}}}function it(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return z(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]=r}}catch(e){return()=>{}}}class rt{constructor(e){var t;this._instance=e,this._lastPathname=(null===(t=null==I?void 0:I.location)||void 0===t?void 0:t.pathname)||""}get isEnabled(){return!0}startIfEnabled(){this.isEnabled&&this.monitorHistoryChanges()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0}monitorHistoryChanges(){var e,t;if(I&&R&&(this._lastPathname=R.pathname||"",I.history)){var i=this;(null===(e=I.history.pushState)||void 0===e?void 0:e.__vtilt_wrapped__)||it(I.history,"pushState",e=>function(t,r,s){e.call(this,t,r,s),i._capturePageview("pushState")}),(null===(t=I.history.replaceState)||void 0===t?void 0:t.__vtilt_wrapped__)||it(I.history,"replaceState",e=>function(t,r,s){e.call(this,t,r,s),i._capturePageview("replaceState")}),this._setupPopstateListener()}}_capturePageview(e){var t;try{var i=null===(t=null==I?void 0:I.location)||void 0===t?void 0:t.pathname;if(!i||!R||!E)return;if(i!==this._lastPathname&&this.isEnabled){var r={navigation_type:e};this._instance.capture("$pageview",r)}this._lastPathname=i}catch(t){console.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener&&I){var e=()=>{this._capturePageview("popstate")};w(I,"popstate",e),this._popstateListener=()=>{I&&I.removeEventListener("popstate",e)}}}}var st="[SessionRecording]";class nt{constructor(e,t){void 0===t&&(t={}),this._instance=e,this._config=t}get started(){var e;return!!(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.isStarted)}get status(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.status)||"lazy_loading"}get sessionId(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.sessionId)||""}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||!(null===(t=this._lazyLoadedRecording)||void 0===t?void 0:t.isStarted)){var i=void 0!==Object.assign&&void 0!==Array.from;this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),console.info(st+" starting")):this.stopRecording()}}stopRecording(){var e;null===(e=this._lazyLoadedRecording)||void 0===e||e.stop()}log(e,t){var i;void 0===t&&(t="log"),(null===(i=this._lazyLoadedRecording)||void 0===i?void 0:i.log)?this._lazyLoadedRecording.log(e,t):console.warn(st+" log called before recorder was ready")}updateConfig(e){var t;this._config=i({},this._config,e),null===(t=this._lazyLoadedRecording)||void 0===t||t.updateConfig(this._config)}get _isRecordingEnabled(){var e,t=this._instance.getConfig(),i=null!==(e=this._config.enabled)&&void 0!==e&&e,r=!t.disable_session_recording;return!!I&&i&&r}get _scriptName(){return"recorder"}_lazyLoadAndStart(e){var t,i,r,s;if(this._isRecordingEnabled)if((null===(i=null===(t=null==P?void 0:P.__VTiltExtensions__)||void 0===t?void 0:t.rrweb)||void 0===i?void 0:i.record)&&(null===(r=P.__VTiltExtensions__)||void 0===r?void 0:r.initSessionRecording))this._onScriptLoaded(e);else{var n=null===(s=P.__VTiltExtensions__)||void 0===s?void 0:s.loadExternalDependency;n?n(this._instance,this._scriptName,t=>{t?console.error(st+" could not load recorder:",t):this._onScriptLoaded(e)}):console.error(st+" loadExternalDependency not available. Session recording cannot start.")}}_onScriptLoaded(e){var t,i=null===(t=P.__VTiltExtensions__)||void 0===t?void 0:t.initSessionRecording;i?(this._lazyLoadedRecording||(this._lazyLoadedRecording=i(this._instance,this._config)),this._lazyLoadedRecording.start(e)):console.error(st+" initSessionRecording not available after script load")}}var ot=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(ot||{}),at=Uint8Array,ut=Uint16Array,lt=Int32Array,dt=new at([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ht=new at([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ct=new at([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gt=function(e,t){for(var i=new ut(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var s=new lt(i[30]);for(r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)s[n]=n-i[r]<<5|r;return{b:i,r:s}},vt=gt(dt,2),ft=vt.b,_t=vt.r;ft[28]=258,_t[258]=28;for(var pt=gt(ht,0).r,mt=new ut(32768),yt=0;yt<32768;++yt){var wt=(43690&yt)>>1|(21845&yt)<<1;wt=(61680&(wt=(52428&wt)>>2|(13107&wt)<<2))>>4|(3855&wt)<<4,mt[yt]=((65280&wt)>>8|(255&wt)<<8)>>1}var bt=function(e,t,i){for(var r=e.length,s=0,n=new ut(t);s<r;++s)e[s]&&++n[e[s]-1];var o,a=new ut(t);for(s=1;s<t;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new ut(1<<t);var u=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],d=t-e[s],h=a[e[s]-1]++<<d,c=h|(1<<d)-1;h<=c;++h)o[mt[h]>>u]=l}else for(o=new ut(r),s=0;s<r;++s)e[s]&&(o[s]=mt[a[e[s]-1]++]>>15-e[s]);return o},St=new at(288);for(yt=0;yt<144;++yt)St[yt]=8;for(yt=144;yt<256;++yt)St[yt]=9;for(yt=256;yt<280;++yt)St[yt]=7;for(yt=280;yt<288;++yt)St[yt]=8;var It=new at(32);for(yt=0;yt<32;++yt)It[yt]=5;var Tt=bt(St,9,0),Mt=bt(It,5,0),Et=function(e){return(e+7)/8|0},Rt=function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new at(e.subarray(t,i))},Ct=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8},kt=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>8,e[r+2]|=i>>16},xt=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return{t:Ut,l:0};if(1==s){var o=new at(i[0].s+1);return o[i[0].s]=1,{t:o,l:1}}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],u=i[1],l=0,d=1,h=2;for(i[0]={s:-1,f:a.f+u.f,l:a,r:u};d!=s-1;)a=i[i[l].f<i[h].f?l++:h++],u=i[l!=d&&i[l].f<i[h].f?l++:h++],i[d++]={s:-1,f:a.f+u.f,l:a,r:u};var c=n[0].s;for(r=1;r<s;++r)n[r].s>c&&(c=n[r].s);var g=new ut(c+1),v=Pt(i[d-1],g,0);if(v>t){r=0;var f=0,_=v-t,p=1<<_;for(n.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});r<s;++r){var m=n[r].s;if(!(g[m]>t))break;f+=p-(1<<v-g[m]),g[m]=t}for(f>>=_;f>0;){var y=n[r].s;g[y]<t?f-=1<<t-g[y]++-1:++r}for(;r>=0&&f;--r){var w=n[r].s;g[w]==t&&(--g[w],++f)}v=t}return{t:new at(g),l:v}},Pt=function(e,t,i){return-1==e.s?Math.max(Pt(e.l,t,i+1),Pt(e.r,t,i+1)):t[e.s]=i},Lt=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new ut(++t),r=0,s=e[0],n=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=e[a]}return{c:i.subarray(0,r),n:t}},At=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},Ot=function(e,t,i){var r=i.length,s=Et(t+2);e[s]=255&r,e[s+1]=r>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;n<r;++n)e[s+n+4]=i[n];return 8*(s+4+r)},$t=function(e,t,i,r,s,n,o,a,u,l,d){Ct(t,d++,i),++s[256];for(var h=xt(s,15),c=h.t,g=h.l,v=xt(n,15),f=v.t,_=v.l,p=Lt(c),m=p.c,y=p.n,w=Lt(f),b=w.c,S=w.n,I=new ut(19),T=0;T<m.length;++T)++I[31&m[T]];for(T=0;T<b.length;++T)++I[31&b[T]];for(var M=xt(I,7),E=M.t,R=M.l,C=19;C>4&&!E[ct[C-1]];--C);var k,x,P,L,A=l+5<<3,O=At(s,St)+At(n,It)+o,$=At(s,c)+At(n,f)+o+14+3*C+At(I,E)+2*I[16]+3*I[17]+7*I[18];if(u>=0&&A<=O&&A<=$)return Ot(t,d,e.subarray(u,u+l));if(Ct(t,d,1+($<O)),d+=2,$<O){k=bt(c,g,0),x=c,P=bt(f,_,0),L=f;var q=bt(E,R,0);Ct(t,d,y-257),Ct(t,d+5,S-1),Ct(t,d+10,C-4),d+=14;for(T=0;T<C;++T)Ct(t,d+3*T,E[ct[T]]);d+=3*C;for(var U=[m,b],D=0;D<2;++D){var B=U[D];for(T=0;T<B.length;++T){var z=31&B[T];Ct(t,d,q[z]),d+=E[z],z>15&&(Ct(t,d,B[T]>>5&127),d+=B[T]>>12)}}}else k=Tt,x=St,P=Mt,L=It;for(T=0;T<a;++T){var N=r[T];if(N>255){kt(t,d,k[(z=N>>18&31)+257]),d+=x[z+257],z>7&&(Ct(t,d,N>>23&31),d+=dt[z]);var j=31&N;kt(t,d,P[j]),d+=L[j],j>3&&(kt(t,d,N>>5&8191),d+=ht[j])}else kt(t,d,k[N]),d+=x[N]}return kt(t,d,k[256]),d+x[256]},qt=new lt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ut=new at(0),Dt=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&-306674912)^i>>>1;e[t]=i}return e}(),Bt=function(e,t,i,r,s){if(!s&&(s={l:1},t.dictionary)){var n=t.dictionary.subarray(-32768),o=new at(n.length+e.length);o.set(n),o.set(e,n.length),e=o,s.w=n.length}return function(e,t,i,r,s,n){var o=n.z||e.length,a=new at(r+o+5*(1+Math.ceil(o/7e3))+s),u=a.subarray(r,a.length-s),l=n.l,d=7&(n.r||0);if(t){d&&(u[0]=n.r>>3);for(var h=qt[t-1],c=h>>13,g=8191&h,v=(1<<i)-1,f=n.p||new ut(32768),_=n.h||new ut(v+1),p=Math.ceil(i/3),m=2*p,y=function(t){return(e[t]^e[t+1]<<p^e[t+2]<<m)&v},w=new lt(25e3),b=new ut(288),S=new ut(32),I=0,T=0,M=n.i||0,E=0,R=n.w||0,C=0;M+2<o;++M){var k=y(M),x=32767&M,P=_[k];if(f[x]=P,_[k]=x,R<=M){var L=o-M;if((I>7e3||E>24576)&&(L>423||!l)){d=$t(e,u,0,w,b,S,T,E,C,M-C,d),E=I=T=0,C=M;for(var A=0;A<286;++A)b[A]=0;for(A=0;A<30;++A)S[A]=0}var O=2,$=0,q=g,U=x-P&32767;if(L>2&&k==y(M-U))for(var D=Math.min(c,L)-1,B=Math.min(32767,M),z=Math.min(258,L);U<=B&&--q&&x!=P;){if(e[M+O]==e[M+O-U]){for(var N=0;N<z&&e[M+N]==e[M+N-U];++N);if(N>O){if(O=N,$=U,N>D)break;var j=Math.min(U,N-2),W=0;for(A=0;A<j;++A){var F=M-U+A&32767,V=F-f[F]&32767;V>W&&(W=V,P=F)}}}U+=(x=P)-(P=f[x])&32767}if($){w[E++]=268435456|_t[O]<<18|pt[$];var J=31&_t[O],H=31&pt[$];T+=dt[J]+ht[H],++b[257+J],++S[H],R=M+O,++I}else w[E++]=e[M],++b[e[M]]}}for(M=Math.max(M,R);M<o;++M)w[E++]=e[M],++b[e[M]];d=$t(e,u,l,w,b,S,T,E,C,M-C,d),l||(n.r=7&d|u[d/8|0]<<3,d-=7,n.h=_,n.p=f,n.i=M,n.w=R)}else{for(M=n.w||0;M<o+l;M+=65535){var Q=M+65535;Q>=o&&(u[d/8|0]=l,Q=o),d=Ot(u,d+1,e.subarray(M,Q))}n.i=o}return Rt(a,0,r+Et(d)+s)}(e,null==t.level?6:t.level,null==t.mem?s.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,i,r,s)},zt=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Nt(e,t){t||(t={});var i=function(){var e=-1;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=Dt[255&i^t[r]]^i>>>8;e=i},d:function(){return~e}}}(),r=e.length;i.p(e);var s,n=Bt(e,t,10+((s=t).filename?s.filename.length+1:0),8),o=n.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&zt(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(n,t),zt(n,o-8,i.d()),zt(n,o-4,r),n}var jt="undefined"!=typeof TextEncoder&&new TextEncoder,Wt="undefined"!=typeof TextDecoder&&new TextDecoder;try{Wt.decode(Ut,{stream:!0})}catch(e){}ot.MouseMove,ot.MouseInteraction,ot.Scroll,ot.ViewportResize,ot.Input,ot.TouchMove,ot.MediaInteraction,ot.Drag;var Ft,Vt="text/plain";!function(e){e.GZipJS="gzip-js",e.None="none"}(Ft||(Ft={}));var Jt=e=>{var{data:t,compression:i}=e;if(t){var r=(e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t))(t),s=new Blob([r]).size;if(i===Ft.GZipJS&&s>=1024)try{var n=Nt(function(e,t){if(jt)return jt.encode(e);for(var i=e.length,r=new at(e.length+(e.length>>1)),s=0,n=function(e){r[s++]=e},o=0;o<i;++o){if(s+5>r.length){var a=new at(s+8+(i-o<<1));a.set(r),r=a}var u=e.charCodeAt(o);u<128||t?n(u):u<2048?(n(192|u>>6),n(128|63&u)):u>55295&&u<57344?(n(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++o))>>18),n(128|u>>12&63),n(128|u>>6&63),n(128|63&u)):(n(224|u>>12),n(128|u>>6&63),n(128|63&u))}return Rt(r,0,s)}(r),{mtime:0}),o=new Blob([n],{type:Vt});if(o.size<.95*s)return{contentType:Vt,body:o,estimatedSize:o.size}}catch(e){}return{contentType:"application/json",body:r,estimatedSize:s}}},Ht=[{name:"fetch",available:"undefined"!=typeof fetch,method:e=>{var r=Jt(e);if(r){var{contentType:s,body:n,estimatedSize:o}=r,a=e.compression===Ft.GZipJS&&s===Vt?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,u=i({"Content-Type":s},e.headers||{}),l=new AbortController,d=e.timeout?setTimeout(()=>l.abort(),e.timeout):null;fetch(a,{method:e.method||"POST",headers:u,body:n,keepalive:o<52428.8,signal:l.signal}).then(function(){var i=t(function*(t){var i,r=yield t.text(),s={statusCode:t.status,text:r};if(200===t.status)try{s.json=JSON.parse(r)}catch(e){}null===(i=e.callback)||void 0===i||i.call(e,s)});return function(e){return i.apply(this,arguments)}}()).catch(()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})}).finally(()=>{d&&clearTimeout(d)})}}},{name:"XHR",available:"undefined"!=typeof XMLHttpRequest,method:e=>{var t=Jt(e);if(t){var{contentType:i,body:r}=t,s=e.compression===Ft.GZipJS&&i===Vt?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,n=new XMLHttpRequest;n.open(e.method||"POST",s,!0),e.headers&&Object.entries(e.headers).forEach(e=>{var[t,i]=e;n.setRequestHeader(t,i)}),n.setRequestHeader("Content-Type",i),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{var t;if(4===n.readyState){var i={statusCode:n.status,text:n.responseText};if(200===n.status)try{i.json=JSON.parse(n.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,i)}},n.onerror=()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})},n.send(r)}}},{name:"sendBeacon",available:"undefined"!=typeof navigator&&!!navigator.sendBeacon,method:e=>{var t=Jt(e);if(t){var{contentType:i,body:r}=t;try{var s="string"==typeof r?new Blob([r],{type:i}):r,n=e.compression===Ft.GZipJS&&i===Vt?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url;navigator.sendBeacon(n,s)}catch(e){}}}}],Qt=e=>{var t,i=e.transport||"fetch",r=Ht.find(e=>e.name===i&&e.available)||Ht.find(e=>e.available);if(!r)return console.error("vTilt: No available transport method"),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0}));r.method(e)};class Xt{constructor(e,t){var i,r,s,n;this._isPaused=!0,this._queue=[],this._flushTimeoutMs=(i=(null==t?void 0:t.flush_interval_ms)||3e3,r=250,s=5e3,n=3e3,"number"!=typeof i||isNaN(i)?n:Math.min(Math.max(i,r),s)),this._sendRequest=e}get length(){return this._queue.length}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){if(this._clearFlushTimeout(),0!==this._queue.length){var e=this._formatQueue();for(var t in e){var r=e[t];this._sendRequest(i({},r,{transport:"sendBeacon"}))}}}enable(){this._isPaused=!1,this._setFlushTimeout()}pause(){this._isPaused=!0,this._clearFlushTimeout()}flush(){this._clearFlushTimeout(),this._flushNow(),this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flushNow(),this._queue.length>0&&this._setFlushTimeout()},this._flushTimeoutMs))}_clearFlushTimeout(){this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0)}_flushNow(){if(0!==this._queue.length){var e=this._formatQueue(),t=Date.now();for(var i in e){var r=e[i];r.events.forEach(e=>{var i=new Date(e.timestamp).getTime();e.$offset=Math.abs(i-t)}),this._sendRequest(r)}}}_formatQueue(){var e={};return this._queue.forEach(t=>{var i=t.batchKey||t.url;e[i]||(e[i]={url:t.url,events:[],batchKey:t.batchKey}),e[i].events.push(t.event)}),this._queue=[],e}}class Kt{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._areWeOnline=!0,this._sendRequest=e.sendRequest,this._sendBeacon=e.sendBeacon,I&&void 0!==M&&"onLine"in M&&(this._areWeOnline=M.onLine,w(I,"online",()=>{this._areWeOnline=!0,this._flush()}),w(I,"offline",()=>{this._areWeOnline=!1}))}get length(){return this._queue.length}enqueue(e,t){if(void 0===t&&(t=0),t>=10)console.warn("VTilt: Request failed after 10 retries, giving up");else{var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,r=Math.min(18e5,t),s=(Math.random()-.5)*(r-i);return Math.ceil(r+s)}(t),r=Date.now()+i;this._queue.push({retryAt:r,request:e,retriesPerformedSoFar:t+1});var s="VTilt: Enqueued failed request for retry in "+Math.round(i/1e3)+"s";this._areWeOnline||(s+=" (Browser is offline)"),console.warn(s),this._isPolling||(this._isPolling=!0,this._poll())}}retriableRequest(e){var i=this;return t(function*(){try{var t=yield i._sendRequest(e);200!==t.statusCode&&(t.statusCode<400||t.statusCode>=500)&&i.enqueue(e,0)}catch(t){i.enqueue(e,0)}})()}_poll(){this._poller&&clearTimeout(this._poller),this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._queue.length>0?this._poll():this._isPolling=!1},this._pollIntervalMs)}_flush(){var e=this,i=Date.now(),r=[],s=[];this._queue.forEach(e=>{e.retryAt<i?s.push(e):r.push(e)}),this._queue=r,s.forEach(function(){var i=t(function*(t){var{request:i,retriesPerformedSoFar:r}=t;try{var s=yield e._sendRequest(i);200!==s.statusCode&&(s.statusCode<400||s.statusCode>=500)&&e.enqueue(i,r)}catch(t){e.enqueue(i,r)}});return function(e){return i.apply(this,arguments)}}())}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue.forEach(e=>{var{request:t}=e;try{this._sendBeacon(t)}catch(e){console.error("VTilt: Failed to send beacon on unload",e)}}),this._queue=[]}}var Gt="vt_rate_limit";class Zt{constructor(e){var t,i;void 0===e&&(e={}),this.lastEventRateLimited=!1,this.eventsPerSecond=null!==(t=e.eventsPerSecond)&&void 0!==t?t:10,this.eventsBurstLimit=Math.max(null!==(i=e.eventsBurstLimit)&&void 0!==i?i:10*this.eventsPerSecond,this.eventsPerSecond),this.persistence=e.persistence,this.captureWarning=e.captureWarning,this.lastEventRateLimited=this.checkRateLimit(!0).isRateLimited}checkRateLimit(e){var t,i,r,s;void 0===e&&(e=!1);var n=Date.now(),o=null!==(i=null===(t=this.persistence)||void 0===t?void 0:t.get(Gt))&&void 0!==i?i:{tokens:this.eventsBurstLimit,last:n},a=(n-o.last)/1e3;o.tokens+=a*this.eventsPerSecond,o.last=n,o.tokens>this.eventsBurstLimit&&(o.tokens=this.eventsBurstLimit);var u=o.tokens<1;return u||e||(o.tokens=Math.max(0,o.tokens-1)),!u||this.lastEventRateLimited||e||null===(r=this.captureWarning)||void 0===r||r.call(this,"vTilt client rate limited. Config: "+this.eventsPerSecond+" events/second, "+this.eventsBurstLimit+" burst limit."),this.lastEventRateLimited=u,null===(s=this.persistence)||void 0===s||s.set(Gt,o),{isRateLimited:u,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class Yt{constructor(e){void 0===e&&(e={}),this.version="1.1.5",this.__loaded=!1,this._initial_pageview_captured=!1,this._visibility_state_listener=null,this.__request_queue=[],this._has_warned_about_config=!1,this._set_once_properties_sent=!1,this.configManager=new r(e);var t=this.configManager.getConfig();this.sessionManager=new q(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Ke(t.persistence||"localStorage",t.cross_subdomain_cookie),this.webVitalsManager=new tt(t,this),this.rateLimiter=new Zt({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:e=>{this._capture_internal("$$client_ingestion_warning",{$$client_ingestion_warning_message:e})}}),this.retryQueue=new Kt({sendRequest:e=>this._send_http_request(e),sendBeacon:e=>this._send_beacon_request(e)}),this.requestQueue=new Xt(e=>this._send_batched_request(e),{flush_interval_ms:3e3})}init(e,t,i){var r;if(i&&i!==ti){var s=null!==(r=ei[i])&&void 0!==r?r:new Yt;return s._init(e,t,i),ei[i]=s,ei[ti][i]=s,s}return this._init(e,t,i)}_init(e,t,r){if(void 0===t&&(t={}),this.__loaded)return console.warn("vTilt: You have already initialized vTilt! Re-initializing is a no-op"),this;this.updateConfig(i({},t,{projectId:e||t.projectId,name:r})),this.__loaded=!0;var s=this.configManager.getConfig();return this.userManager.set_initial_person_info(s.mask_personal_data_properties,s.custom_personal_data_properties),this.historyAutocapture=new rt(this),this.historyAutocapture.startIfEnabled(),this._initSessionRecording(),this._setup_unload_handler(),this._start_queue_if_opted_in(),!1!==s.capture_pageview&&this._capture_initial_pageview(),this}_start_queue_if_opted_in(){this.requestQueue.enable()}_setup_unload_handler(){if(I){var e=()=>{this.requestQueue.unload(),this.retryQueue.unload()};w(I,"beforeunload",e),w(I,"pagehide",e)}}toString(){var e,t=null!==(e=this.configManager.getConfig().name)&&void 0!==e?e:ti;return t!==ti&&(t=ti+"."+t),t}getCurrentDomain(){if(!R)return"";var e=R.protocol,t=R.hostname,i=R.port;return e+"//"+t+(i?":"+i:"")}_is_configured(){var e=this.configManager.getConfig();return!(!e.projectId||!e.token)||(this._has_warned_about_config||(console.warn("VTilt: projectId and token are required for tracking. Events will be skipped until init() or updateConfig() is called with these fields."),this._has_warned_about_config=!0),!1)}buildUrl(){var e=this.configManager.getConfig(),{proxyUrl:t,proxy:i,api_host:r,token:s}=e;return t||(i?i+"/api/tracking?token="+s:r?r.replace(/\/+$/gm,"")+"/api/tracking?token="+s:"/api/tracking?token="+s)}sendRequest(e,t,i){if(this._is_configured()){if(i&&void 0!==I)if(I.__VTILT_ENQUEUE_REQUESTS)return void this.__request_queue.push({url:e,event:t});this.requestQueue.enqueue({url:e,event:t})}}_send_batched_request(e){var{transport:t}=e;"sendBeacon"!==t?this.retryQueue.retriableRequest(e):this._send_beacon_request(e)}_send_http_request(e){return new Promise(t=>{var{url:i,events:r}=e,s=1===r.length?r[0]:{events:r},n=this.configManager.getConfig().disable_compression?Ft.None:Ft.GZipJS;Qt({url:i,data:s,method:"POST",transport:"XHR",compression:n,callback:e=>{t({statusCode:e.statusCode})}})})}_send_beacon_request(e){var{url:t,events:i}=e,r=1===i.length?i[0]:{events:i},s=this.configManager.getConfig().disable_compression?Ft.None:Ft.GZipJS;Qt({url:t,data:r,method:"POST",transport:"sendBeacon",compression:s})}_send_retriable_request(e){this.sendRequest(e.url,e.event,!1)}capture(e,t,r){if(this.sessionManager.setSessionId(),M&&M.userAgent&&function(e){return!(e&&"string"==typeof e&&e.length>500)}(M.userAgent)&&((null==r?void 0:r.skip_client_rate_limiting)||this.rateLimiter.shouldAllowEvent())){var s=this.buildUrl(),n=Xe(),o=this.userManager.getUserProperties(),a=this.userManager.get_initial_props(),u=this.sessionManager.getSessionId(),l=this.sessionManager.getWindowId(),d=this.userManager.getAnonymousId(),h={};!this._set_once_properties_sent&&Object.keys(a).length>0&&Object.assign(h,a),t.$set_once&&Object.assign(h,t.$set_once);var c=i({},n,o,{$session_id:u,$window_id:l},d?{$anon_distinct_id:d}:{},Object.keys(h).length>0?{$set_once:h}:{},t.$set?{$set:t.$set}:{},t);!this._set_once_properties_sent&&Object.keys(a).length>0&&(this._set_once_properties_sent=!0),"$pageview"===e&&E&&(c.title=E.title);var g,v,f=this.configManager.getConfig();if(!1!==f.stringifyPayload){if(g=Object.assign({},c,f.globalAttributes),!m(g=JSON.stringify(g)))return}else if(g=Object.assign({},c,f.globalAttributes),!m(JSON.stringify(g)))return;v="$identify"===e?this.userManager.getAnonymousId():this.userManager.getDistinctId()||this.userManager.getAnonymousId();var _={timestamp:(new Date).toISOString(),event:e,project_id:f.projectId||"",payload:g,distinct_id:v,anonymous_id:d};this.sendRequest(s,_,!0)}}_capture_internal(e,t){this.capture(e,t,{skip_client_rate_limiting:!0})}trackEvent(e,t){void 0===t&&(t={}),this.capture(e,t)}identify(e,t,i){if("number"==typeof e&&(e=String(e),console.warn("The first argument to vTilt.identify was a number, but it should be a string. It has been converted to a string.")),e)if(this.userManager.isDistinctIdStringLikePublic(e))console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if("COOKIELESS_SENTINEL_VALUE"!==e){var r=this.userManager.getDistinctId(),s=this.userManager.getAnonymousId(),n=this.userManager.getDeviceId(),o="anonymous"===this.userManager.getUserState();if(!n){var a=r||s;this.userManager.ensureDeviceId(a)}e!==r&&o?(this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s,$set:t||{},$set_once:i||{}}),this.userManager.setDistinctId(e)):t||i?(o&&this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$set",{$set:t||{},$set_once:i||{}})):e!==r&&(this.userManager.setUserState("identified"),this.userManager.setDistinctId(e))}else console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID is only used as a sentinel value.');else console.error("Unique user id has not been set in vTilt.identify")}setUserProperties(e,t){this.userManager.setUserProperties(e,t)&&this.capture("$set",{$set:e||{},$set_once:t||{}})}resetUser(e){this.sessionManager.resetSessionId(),this.userManager.reset(e)}getUserIdentity(){return this.userManager.getUserIdentity()}getDeviceId(){return this.userManager.getDeviceId()}getUserState(){return this.userManager.getUserState()}createAlias(e,t){var i=this.userManager.createAlias(e,t);i?this.capture("$alias",{$original_id:i.original,$alias_id:i.distinct_id}):e===(t||this.userManager.getDistinctId()||this.userManager.getAnonymousId())&&this.identify(e)}_capture_initial_pageview(){E&&("visible"===E.visibilityState?this._initial_pageview_captured||(this._initial_pageview_captured=!0,setTimeout(()=>{if(E&&R){this.capture("$pageview",{navigation_type:"initial_load"})}},300),this._visibility_state_listener&&(E.removeEventListener("visibilitychange",this._visibility_state_listener),this._visibility_state_listener=null)):this._visibility_state_listener||(this._visibility_state_listener=()=>{this._capture_initial_pageview()},w(E,"visibilitychange",this._visibility_state_listener)))}getConfig(){return this.configManager.getConfig()}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this.userManager.getDistinctId()||this.userManager.getAnonymousId()}getAnonymousId(){return this.userManager.getAnonymousId()}updateConfig(e){this.configManager.updateConfig(e);var t=this.configManager.getConfig();this.sessionManager=new q(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Ke(t.persistence||"localStorage",t.cross_subdomain_cookie),this.webVitalsManager=new tt(t,this),this.sessionRecording&&t.session_recording&&this.sessionRecording.updateConfig(this._buildSessionRecordingConfig(t))}_initSessionRecording(){var e=this.configManager.getConfig();if(!e.disable_session_recording){var t=this._buildSessionRecordingConfig(e);this.sessionRecording=new nt(this,t),t.enabled&&this.sessionRecording.startIfEnabledOrStop("recording_initialized")}}_buildSessionRecordingConfig(e){var t,i,r,s=e.session_recording||{};return{enabled:null!==(t=s.enabled)&&void 0!==t&&t,sampleRate:s.sampleRate,minimumDurationMs:s.minimumDurationMs,sessionIdleThresholdMs:s.sessionIdleThresholdMs,fullSnapshotIntervalMs:s.fullSnapshotIntervalMs,captureConsole:null!==(i=s.captureConsole)&&void 0!==i&&i,captureNetwork:null!==(r=s.captureNetwork)&&void 0!==r&&r,captureCanvas:s.captureCanvas,blockClass:s.blockClass,blockSelector:s.blockSelector,ignoreClass:s.ignoreClass,maskTextClass:s.maskTextClass,maskTextSelector:s.maskTextSelector,maskAllInputs:s.maskAllInputs,maskInputOptions:s.maskInputOptions,masking:s.masking,recordHeaders:s.recordHeaders,recordBody:s.recordBody,compressEvents:s.compressEvents,__mutationThrottlerRefillRate:s.__mutationThrottlerRefillRate,__mutationThrottlerBucketSize:s.__mutationThrottlerBucketSize}}startSessionRecording(){if(!this.sessionRecording){var e=this.configManager.getConfig(),t=this._buildSessionRecordingConfig(e);t.enabled=!0,this.sessionRecording=new nt(this,t)}this.sessionRecording.startIfEnabledOrStop("recording_initialized")}stopSessionRecording(){var e;null===(e=this.sessionRecording)||void 0===e||e.stopRecording()}isSessionRecordingActive(){var e;return"active"===(null===(e=this.sessionRecording)||void 0===e?void 0:e.status)}getSessionRecordingId(){var e;return(null===(e=this.sessionRecording)||void 0===e?void 0:e.sessionId)||null}_execute_array(e){Array.isArray(e)&&e.forEach(e=>{if(e&&Array.isArray(e)&&e.length>0){var t=e[0],i=e.slice(1);if("function"==typeof this[t])try{this[t](...i)}catch(e){console.error("vTilt: Error executing queued call "+t+":",e)}}})}_dom_loaded(){this.__request_queue.forEach(e=>{this._send_retriable_request(e)}),this.__request_queue=[],this._start_queue_if_opted_in()}}var ei={},ti="vt",ii=!(void 0!==k||void 0!==C)&&-1===(null==x?void 0:x.indexOf("MSIE"))&&-1===(null==x?void 0:x.indexOf("Mozilla"));null!=I&&(I.__VTILT_ENQUEUE_REQUESTS=ii);var ri,si=(ri=ei[ti]=new Yt,function(){function e(){e.done||(e.done=!0,ii=!1,null!=I&&(I.__VTILT_ENQUEUE_REQUESTS=!1),y(ei,function(e){e._dom_loaded()}))}E&&"function"==typeof E.addEventListener?"complete"===E.readyState?e():w(E,"DOMContentLoaded",e,{capture:!1}):I&&console.error("Browser doesn't support `document.addEventListener` so vTilt couldn't be initialized")}(),ri);export{Ge as ALL_WEB_VITALS_METRICS,Ze as DEFAULT_WEB_VITALS_METRICS,Yt as VTilt,si as default,si as vt};
1
+ function e(e,t,i,n,r,s,o){try{var a=e[s](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(n,r)}function t(t){return function(){var i=this,n=arguments;return new Promise(function(r,s){var o=t.apply(i,n);function a(t){e(o,r,s,a,l,"next",t)}function l(t){e(o,r,s,a,l,"throw",t)}a(void 0)})}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)({}).hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},i.apply(null,arguments)}class n{constructor(e){void 0===e&&(e={}),this.config=this.parseConfigFromScript(e)}parseConfigFromScript(e){if(!document.currentScript)return i({token:e.token||""},e);var t=document.currentScript,n=i({token:""},e);n.api_host=t.getAttribute("data-api-host")||t.getAttribute("data-host")||e.api_host,n.script_host=t.getAttribute("data-script-host")||e.script_host,n.proxy=t.getAttribute("data-proxy")||e.proxy,n.proxyUrl=t.getAttribute("data-proxy-url")||e.proxyUrl,n.token=t.getAttribute("data-token")||e.token||"",n.projectId=t.getAttribute("data-project-id")||e.projectId||"",n.domain=t.getAttribute("data-domain")||e.domain,n.storage=t.getAttribute("data-storage")||e.storage,n.stringifyPayload="false"!==t.getAttribute("data-stringify-payload");var r="true"===t.getAttribute("data-capture-performance");if(n.capture_performance=!!r||e.capture_performance,n.proxy&&n.proxyUrl)throw console.error("Error: Both data-proxy and data-proxy-url are specified. Please use only one of them."),new Error("Both data-proxy and data-proxy-url are specified. Please use only one of them.");for(var s of(n.globalAttributes=i({},e.globalAttributes),Array.from(t.attributes)))s.name.startsWith("data-vt-")&&(n.globalAttributes[s.name.slice(8).replace(/-/g,"_")]=s.value);return n}getConfig(){return i({},this.config)}updateConfig(e){this.config=i({},this.config,e)}}var r="__vt_session",s="__vt_window_id",o="__vt_primary_window",a="__vt_user_state",l="__vt_device_id",d="__vt_anonymous_id",u="__vt_distinct_id",h="__vt_user_properties",c="localStorage",g="localStorage+cookie",v="sessionStorage",_="memory",f="$initial_person_info";function p(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16))}function m(e){return!(!e||"string"!=typeof e)&&!(e.length<2||e.length>10240)}function y(e,t,i){if(e)if(Array.isArray(e))e.forEach((e,n)=>{t.call(i,e,n)});else for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.call(i,e[n],n)}function b(e,t,i,n){var{capture:r=!1,passive:s=!0}=null!=n?n:{};null==e||e.addEventListener(t,i,{capture:r,passive:s})}function w(e,t){if(!t)return e;for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}function S(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];for(var r of i)for(var s of r)e.push(s);return e}var I="undefined"!=typeof window?window:void 0,C="undefined"!=typeof globalThis?globalThis:I,M=null==C?void 0:C.navigator,E=null==C?void 0:C.document,T=null==C?void 0:C.location,k=null==C?void 0:C.fetch,L=(null==C?void 0:C.XMLHttpRequest)&&"withCredentials"in new C.XMLHttpRequest?C.XMLHttpRequest:void 0;null==C||C.AbortController;var x=null==M?void 0:M.userAgent,R=null!=I?I:{},P=31536e3,A=["herokuapp.com","vercel.app","netlify.app"];function O(e){var t;if(!e)return"";if("undefined"==typeof document)return"";var i=null===(t=document.location)||void 0===t?void 0:t.hostname;if(!i)return"";var n=i.match(/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i);return n?"."+n[0]:""}class z{constructor(e){var t,i;this.memoryStorage=new Map,this.method=e.method,this.cross_subdomain=null!==(t=e.cross_subdomain)&&void 0!==t?t:function(){var e;if("undefined"==typeof document)return!1;var t=null===(e=document.location)||void 0===e?void 0:e.hostname;if(!t)return!1;var i=t.split(".").slice(-2).join(".");for(var n of A)if(i===n)return!1;return!0}(),this.sameSite=e.sameSite||"Lax",this.secure=null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol}get(e){var t;try{if(this.method===_)return null!==(t=this.memoryStorage.get(e))&&void 0!==t?t:null;if(this.usesLocalStorage()){var i=localStorage.getItem(e);return null!==i?i:this.method===g?this.getCookie(e):null}return this.usesSessionStorage()?sessionStorage.getItem(e):this.getCookie(e)}catch(t){return console.warn('[StorageManager] Failed to get "'+e+'":',t),null}}set(e,t,i){try{if(this.method===_)return void this.memoryStorage.set(e,t);if(this.usesLocalStorage())return localStorage.setItem(e,t),void(this.method===g&&this.setCookie(e,t,i||P));if(this.usesSessionStorage())return void sessionStorage.setItem(e,t);this.setCookie(e,t,i||P)}catch(t){console.warn('[StorageManager] Failed to set "'+e+'":',t)}}remove(e){try{if(this.method===_)return void this.memoryStorage.delete(e);if(this.usesLocalStorage())return localStorage.removeItem(e),void(this.method===g&&this.removeCookie(e));if(this.usesSessionStorage())return void sessionStorage.removeItem(e);this.removeCookie(e)}catch(t){console.warn('[StorageManager] Failed to remove "'+e+'":',t)}}getWithExpiry(e){var t=this.get(e);if(!t)return null;try{var i=JSON.parse(t);return i.expiry&&Date.now()>i.expiry?(this.remove(e),null):i.value}catch(e){return null}}setWithExpiry(e,t,n){var r=i({value:t},n?{expiry:Date.now()+n}:{});this.set(e,JSON.stringify(r))}getJSON(e){var t=this.get(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return null}}setJSON(e,t,i){this.set(e,JSON.stringify(t),i)}getCookie(e){if("undefined"==typeof document)return null;var t=document.cookie.split(";");for(var i of t){var[n,...r]=i.trim().split("=");if(n===e){var s=r.join("=");try{return decodeURIComponent(s)}catch(e){return s}}}return null}setCookie(e,t,i){if("undefined"!=typeof document){var n=e+"="+encodeURIComponent(t);n+="; Max-Age="+i,n+="; path=/",n+="; SameSite="+this.sameSite,this.secure&&(n+="; Secure");var r=O(this.cross_subdomain);r&&(n+="; domain="+r),document.cookie=n}}removeCookie(e){if("undefined"!=typeof document){var t=O(this.cross_subdomain),i=e+"=; Max-Age=0; path=/";t&&(i+="; domain="+t),document.cookie=i,document.cookie=e+"=; Max-Age=0; path=/"}}usesLocalStorage(){return this.method===c||this.method===g}usesSessionStorage(){return this.method===v}canUseSessionStorage(){if(void 0===I||!(null==I?void 0:I.sessionStorage))return!1;try{var e="__vt_storage_test__";return I.sessionStorage.setItem(e,"test"),I.sessionStorage.removeItem(e),!0}catch(e){return!1}}getSessionStorage(){var e;return this.canUseSessionStorage()&&null!==(e=null==I?void 0:I.sessionStorage)&&void 0!==e?e:null}setMethod(e){this.method=e}getMethod(){return this.method}}class ${constructor(e,t){void 0===e&&(e="cookie"),this.storage=new z({method:e,cross_subdomain:t,sameSite:"Lax"}),this._windowId=void 0,this._initializeWindowId()}getSessionId(){var e=this._getSessionIdRaw();return e||(e=p(),this._storeSessionId(e)),e}setSessionId(){var e=this._getSessionIdRaw()||p();return this._storeSessionId(e),e}resetSessionId(){this._clearSessionId(),this.setSessionId(),this._setWindowId(p())}_getSessionIdRaw(){return this.storage.get(r)}_storeSessionId(e){this.storage.set(r,e,1800)}_clearSessionId(){this.storage.remove(r)}getWindowId(){if(this._windowId)return this._windowId;var e=this.storage.getSessionStorage();if(e){var t=e.getItem(s);if(t)return this._windowId=t,t}var i=p();return this._setWindowId(i),i}_setWindowId(e){if(e!==this._windowId){this._windowId=e;var t=this.storage.getSessionStorage();t&&t.setItem(s,e)}}_initializeWindowId(){var e=this.storage.getSessionStorage();if(e){var t=e.getItem(o),i=e.getItem(s);i&&!t?this._windowId=i:(i&&e.removeItem(s),this._setWindowId(p())),e.setItem(o,"true"),this._listenToUnload()}else this._windowId=p()}_listenToUnload(){var e=this.storage.getSessionStorage();I&&e&&b(I,"beforeunload",()=>{var e=this.storage.getSessionStorage();e&&e.removeItem(o)},{capture:!1})}updateStorageMethod(e,t){this.storage=new z({method:e,cross_subdomain:t,sameSite:"Lax"})}}function q(e){if(!E)return null;var t=E.createElement("a");return t.href=e,t}function U(e,t){for(var i=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;n<i.length;n++){var r=i[n].split("=");if(r[0]===t){if(r.length<2)return"";var s=r[1];try{s=decodeURIComponent(s)}catch(e){}return s.replace(/\+/g," ")}}return""}function D(e,t,i){if(!e||!t||!t.length)return e;for(var n=e.split("#"),r=n[0]||"",s=n[1],o=r.split("?"),a=o[1],l=o[0],d=(a||"").split("&"),u=[],h=0;h<d.length;h++){var c=d[h].split("="),g=c[0],v=c.slice(1).join("=");-1!==t.indexOf(g)?u.push(g+"="+i):g&&u.push(g+(v?"="+v:""))}var _=u.join("&");return l+(_?"?"+_:"")+(s?"#"+s:"")}function B(e){return"function"==typeof e}var F="Mobile",N="iOS",j="Android",V="Tablet",W=j+" "+V,J="iPad",H="Apple",Q=H+" Watch",G="Safari",X="BlackBerry",K="Samsung",Z=K+"Browser",Y=K+" Internet",ee="Chrome",te=ee+" OS",ie=ee+" "+N,ne="Internet Explorer",re=ne+" "+F,se="Opera",oe=se+" Mini",ae="Edge",le="Microsoft "+ae,de="Firefox",ue=de+" "+N,he="Nintendo",ce="PlayStation",ge="Xbox",ve=j+" "+F,_e=F+" "+G,fe="Windows",pe=fe+" Phone",me="Nokia",ye="Ouya",be="Generic",we=be+" "+F.toLowerCase(),Se=be+" "+V.toLowerCase(),Ie="Konqueror",Ce="(\\d+(\\.\\d+)?)",Me=new RegExp("Version/"+Ce),Ee=new RegExp(ge,"i"),Te=new RegExp(ce+" \\w+","i"),ke=new RegExp(he+" \\w+","i"),Le=new RegExp(X+"|PlayBook|BB10","i"),xe={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};function Re(e,t){return e.toLowerCase().includes(t.toLowerCase())}var Pe=(e,t)=>t&&Re(t,H)||function(e){return Re(e,G)&&!Re(e,ee)&&!Re(e,j)}(e),Ae=function(e,t){return t=t||"",Re(e," OPR/")&&Re(e,"Mini")?oe:Re(e," OPR/")?se:Le.test(e)?X:Re(e,"IE"+F)||Re(e,"WPDesktop")?re:Re(e,Z)?Y:Re(e,ae)||Re(e,"Edg/")?le:Re(e,"FBIOS")?"Facebook "+F:Re(e,"UCWEB")||Re(e,"UCBrowser")?"UC Browser":Re(e,"CriOS")?ie:Re(e,"CrMo")||Re(e,ee)?ee:Re(e,j)&&Re(e,G)?ve:Re(e,"FxiOS")?ue:Re(e.toLowerCase(),Ie.toLowerCase())?Ie:Pe(e,t)?Re(e,F)?_e:G:Re(e,de)?de:Re(e,"MSIE")||Re(e,"Trident/")?ne:Re(e,"Gecko")?de:""},Oe={[re]:[new RegExp("rv:"+Ce)],[le]:[new RegExp(ae+"?\\/"+Ce)],[ee]:[new RegExp("("+ee+"|CrMo)\\/"+Ce)],[ie]:[new RegExp("CriOS\\/"+Ce)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ce)],[G]:[Me],[_e]:[Me],[se]:[new RegExp("(Opera|OPR)\\/"+Ce)],[de]:[new RegExp(de+"\\/"+Ce)],[ue]:[new RegExp("FxiOS\\/"+Ce)],[Ie]:[new RegExp("Konqueror[:/]?"+Ce,"i")],[X]:[new RegExp(X+" "+Ce),Me],[ve]:[new RegExp("android\\s"+Ce,"i")],[Y]:[new RegExp(Z+"\\/"+Ce)],[ne]:[new RegExp("(rv:|MSIE )"+Ce)],Mozilla:[new RegExp("rv:"+Ce)]},ze=function(e,t){var i=Ae(e,t),n=Oe[i];if(void 0===n)return null;for(var r=0;r<n.length;r++){var s=n[r],o=e.match(s);if(o)return parseFloat(o[o.length-2])}return null},$e=[[new RegExp(ge+"; "+ge+" (.*?)[);]","i"),e=>[ge,e&&e[1]||""]],[new RegExp(he,"i"),[he,""]],[new RegExp(ce,"i"),[ce,""]],[Le,[X,""]],[new RegExp(fe,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[pe,""];if(new RegExp(F).test(t)&&!/IEMobile\b/.test(t))return[fe+" "+F,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var n=i[1],r=xe[n]||"";return/arm/i.test(t)&&(r="RT"),[fe,r]}return[fe,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[N,t.join(".")]}return[N,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=void 0===e[2]?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+j+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+j+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[j,t.join(".")]}return[j,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[te,""]],[/Linux|debian/i,["Linux",""]]],qe=function(e){return ke.test(e)?he:Te.test(e)?ce:Ee.test(e)?ge:new RegExp(ye,"i").test(e)?ye:new RegExp("("+pe+"|WPDesktop)","i").test(e)?pe:/iPad/.test(e)?J:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Q:Le.test(e)?X:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(me,"i").test(e)?me:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(F).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?j:W:j:new RegExp("(pda|"+F+")","i").test(e)?we:new RegExp(V,"i").test(e)&&!new RegExp(V+" pc","i").test(e)?Se:""},Ue="https?://(.*)",De=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Be=S(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],De),Fe="<masked>";function Ne(e){var t=function(e){return e?0===e.search(Ue+"google.([^/?]*)")?"google":0===e.search(Ue+"bing.com")?"bing":0===e.search(Ue+"yahoo.com")?"yahoo":0===e.search(Ue+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!==t?"q":"p",n={};if(null!==t){n.$search_engine=t;var r=E?U(E.referrer,i):"";r.length&&(n.ph_keyword=r)}return n}function je(){if("undefined"!=typeof navigator)return navigator.language||navigator.userLanguage}function Ve(){return(null==E?void 0:E.referrer)||"$direct"}function We(){var e;return(null==E?void 0:E.referrer)&&(null===(e=q(E.referrer))||void 0===e?void 0:e.host)||"$direct"}function Je(e){var t,{r:i,u:n}=e,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"===i?"$direct":null===(t=q(i))||void 0===t?void 0:t.host};if(n){r.$current_url=n;var s=q(n);r.$host=null==s?void 0:s.host,r.$pathname=null==s?void 0:s.pathname;var o=function(e){var t=Be.concat([]),i={};return y(t,function(t){var n=U(e,t);i[t]=n||null}),i}(n);w(r,o)}i&&w(r,Ne(i));return r}function He(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Qe(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function Ge(e,t){if(!x)return{};var i,n,r,[s,o]=function(e){for(var t=0;t<$e.length;t++){var[i,n]=$e[t],r=i.exec(e),s=r&&(B(n)?n(r,e):n);if(s)return s}return["",""]}(x);return w(function(e){var t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var n=e[i];null!=n&&""!==n&&(t[i]=n)}return t}({$os:s,$os_version:o,$browser:Ae(x,navigator.vendor),$device:qe(x),$device_type:(n=x,r=qe(n),r===J||r===W||"Kobo"===r||"Kindle Fire"===r||r===Se?V:r===he||r===ge||r===ce||r===ye?"Console":r===Q?"Wearable":r?F:"Desktop"),$timezone:He(),$timezone_offset:Qe()}),{$current_url:D(null==T?void 0:T.href,[],Fe),$host:null==T?void 0:T.host,$pathname:null==T?void 0:T.pathname,$raw_user_agent:x.length>1e3?x.substring(0,997)+"...":x,$browser_version:ze(x,navigator.vendor),$browser_language:je(),$browser_language_prefix:(i=je(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==I?void 0:I.screen.height,$screen_width:null==I?void 0:I.screen.width,$viewport_height:null==I?void 0:I.innerHeight,$viewport_width:null==I?void 0:I.innerWidth,$lib:"web",$lib_version:"1.0.7",$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}class Xe{constructor(e,t){void 0===e&&(e="localStorage"),this._cachedPersonProperties=null,this.storage=new z({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}getUserIdentity(){return i({},this.userIdentity)}getDistinctId(){return this.userIdentity.distinct_id}getAnonymousId(){return this.userIdentity.anonymous_id||(this.userIdentity.anonymous_id=this.generateAnonymousId(),this.storage.set(d,this.userIdentity.anonymous_id,P)),this.userIdentity.anonymous_id}getUserProperties(){return i({},this.userIdentity.properties)}getEffectiveId(){return this.userIdentity.distinct_id||this.getAnonymousId()}getDeviceId(){return this.userIdentity.device_id}getUserState(){return this.userIdentity.user_state}identify(e,t,n){if("number"==typeof e&&(e=e.toString(),console.warn("The first argument to vTilt.identify was a number, but it should be a string. It has been converted to a string.")),e)if(this.isDistinctIdStringLike(e))console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if("COOKIELESS_SENTINEL_VALUE"!==e){var r=this.userIdentity.distinct_id;if(this.userIdentity.distinct_id=e,!this.userIdentity.device_id){var s=r||this.userIdentity.anonymous_id;this.userIdentity.device_id=s,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:s})}e!==r&&(this.userIdentity.distinct_id=e);var o="anonymous"===this.userIdentity.user_state;e!==r&&o?(this.userIdentity.user_state="identified",t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),n&&Object.keys(n).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=n[e])}),this.saveUserIdentity()):t||n?("anonymous"===this.userIdentity.user_state&&(this.userIdentity.user_state="identified"),t&&(this.userIdentity.properties=i({},this.userIdentity.properties,t)),n&&Object.keys(n).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=n[e])}),this.saveUserIdentity()):e!==r&&(this.userIdentity.user_state="identified",this.saveUserIdentity())}else console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID is only used as a sentinel value.');else console.error("Unique user id has not been set in vTilt.identify")}setUserProperties(e,t){if(!e&&!t)return!1;var n=this.userIdentity.distinct_id||this.userIdentity.anonymous_id,r=this.getPersonPropertiesHash(n,e,t);return this._cachedPersonProperties===r?(console.info("VTilt: A duplicate setUserProperties call was made with the same properties. It has been ignored."),!1):(e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity(),this._cachedPersonProperties=r,!0)}reset(e){var t=this.generateAnonymousId(),n=this.userIdentity.device_id,r=e?this.generateDeviceId():n;this.userIdentity={distinct_id:null,anonymous_id:t,device_id:r,properties:{},user_state:"anonymous"},this._cachedPersonProperties=null,this.saveUserIdentity(),this.userIdentity.properties=i({},this.userIdentity.properties,{$last_vtilt_reset:(new Date).toISOString()}),this.saveUserIdentity()}setDistinctId(e){this.userIdentity.distinct_id=e,this.saveUserIdentity()}setUserState(e){this.userIdentity.user_state=e,this.saveUserIdentity()}updateUserProperties(e,t){e&&(this.userIdentity.properties=i({},this.userIdentity.properties,e)),t&&Object.keys(t).forEach(e=>{e in this.userIdentity.properties||(this.userIdentity.properties[e]=t[e])}),this.saveUserIdentity()}ensureDeviceId(e){this.userIdentity.device_id||(this.userIdentity.device_id=e,this.userIdentity.properties=i({},this.userIdentity.properties,{$had_persisted_distinct_id:!0,$device_id:e}),this.saveUserIdentity())}createAlias(e,t){return this.isValidDistinctId(e)?(void 0===t&&(t=this.getDistinctId()||this.getAnonymousId()),this.isValidDistinctId(t)?e===t?(console.warn("alias matches current distinct_id - should use identify instead"),null):{distinct_id:e,original:t}:(console.warn("Invalid original distinct ID"),null)):(console.warn("Invalid alias provided"),null)}isDistinctIdStringLikePublic(e){return this.isDistinctIdStringLike(e)}set_initial_person_info(e,t){if(!this.getStoredUserProperties()[f]){var i=function(e,t){var i=e?S([],De,t||[]):[],n=null==T?void 0:T.href.substring(0,1e3);return{r:Ve().substring(0,1e3),u:n?D(n,i,Fe):void 0}}(e,t);this.register_once({[f]:i},void 0)}}get_initial_props(){var e,t,i=this.getStoredUserProperties()[f];return i?(e=Je(i),t={},y(e,function(e,i){var n;t["$initial_"+(n=String(i),n.startsWith("$")?n.substring(1):n)]=e}),t):{}}update_referrer_info(){var e={$referrer:Ve(),$referring_domain:We()};this.register_once(e,void 0)}loadUserIdentity(){var e=this.storage.get(d)||this.generateAnonymousId(),t=this.storage.get(u)||null,i=this.storage.get(l)||this.generateDeviceId(),n=this.getStoredUserProperties(),r=this.storage.get(a)||"anonymous";return{distinct_id:t,anonymous_id:e||this.generateAnonymousId(),device_id:i,properties:n,user_state:r}}saveUserIdentity(){this.storage.set(d,this.userIdentity.anonymous_id,P),this.storage.set(l,this.userIdentity.device_id,P),this.storage.set(a,this.userIdentity.user_state,P),this.userIdentity.distinct_id?this.storage.set(u,this.userIdentity.distinct_id,P):this.storage.remove(u),this.setStoredUserProperties(this.userIdentity.properties)}getStoredUserProperties(){return this.storage.getJSON(h)||{}}setStoredUserProperties(e){this.storage.setJSON(h,e,P)}register_once(e,t){var i=this.getStoredUserProperties(),n=!1;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(r in i||(i[r]=e[r],n=!0));if(t)for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(s in i||(i[s]=t[s],n=!0));n&&this.setStoredUserProperties(i)}generateAnonymousId(){return"anon_"+p()}generateDeviceId(){return"device_"+p()}getPersonPropertiesHash(e,t,i){return JSON.stringify({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}isValidDistinctId(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return!["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none"].includes(t)&&0!==e.trim().length}isDistinctIdStringLike(e){if(!e||"string"!=typeof e)return!1;var t=e.toLowerCase().trim();return["null","undefined","false","true","anonymous","anon","user","test","guest","visitor","unknown","none","demo","example","sample","placeholder"].includes(t)}updateStorageMethod(e,t){this.storage=new z({method:e,cross_subdomain:t,sameSite:"Lax"}),this.userIdentity=this.loadUserIdentity()}}var Ke=["LCP","CLS","FCP","INP","TTFB"],Ze=["LCP","CLS","FCP","INP"],Ye=9e5,et="[WebVitals]";class tt{constructor(e,t){this.initialized=!1,this.instance=t,this.buffer=this.createEmptyBuffer(),this.config=this.parseConfig(e.capture_performance),this.isEnabled&&I&&this.startIfEnabled()}parseConfig(e){return"boolean"==typeof e?{web_vitals:e}:"object"==typeof e&&null!==e?e:{web_vitals:!1}}get isEnabled(){var e=null==T?void 0:T.protocol;return("http:"===e||"https:"===e)&&!1!==this.config.web_vitals}get allowedMetrics(){return this.config.web_vitals_allowed_metrics||Ze}get flushTimeoutMs(){return this.config.web_vitals_delayed_flush_ms||5e3}get maxAllowedValue(){var e=this.config.__web_vitals_max_value;return void 0===e?Ye:0===e?0:e<6e4?Ye:e}createEmptyBuffer(){return{url:void 0,pathname:void 0,metrics:[],firstMetricTimestamp:void 0}}getWebVitalsCallbacks(){var e;return null===(e=R.__VTiltExtensions__)||void 0===e?void 0:e.webVitalsCallbacks}startIfEnabled(){if(this.isEnabled&&!this.initialized){var e=this.getWebVitalsCallbacks();e?this.startCapturing(e):this.loadWebVitals()}}loadWebVitals(){var e,t=null===(e=R.__VTiltExtensions__)||void 0===e?void 0:e.loadExternalDependency;t?t(this.instance,"web-vitals",e=>{if(e)console.error(et+" Failed to load web-vitals:",e);else{var t=this.getWebVitalsCallbacks();t?this.startCapturing(t):console.error(et+" web-vitals loaded but callbacks not registered")}}):console.warn(et+" External dependency loader not available. Include web-vitals.ts entrypoint or use array.full.js bundle.")}startCapturing(e){if(!this.initialized){var t=this.allowedMetrics,i=this.addToBuffer.bind(this);t.includes("LCP")&&e.onLCP&&e.onLCP(i),t.includes("CLS")&&e.onCLS&&e.onCLS(i,{reportAllChanges:!0}),t.includes("FCP")&&e.onFCP&&e.onFCP(i),t.includes("INP")&&e.onINP&&e.onINP(i),t.includes("TTFB")&&e.onTTFB&&e.onTTFB(i),this.initialized=!0}}getCurrentUrl(){var e;return null===(e=null==I?void 0:I.location)||void 0===e?void 0:e.href}getCurrentPathname(){return null==T?void 0:T.pathname}addToBuffer(e){try{if(!I||!E||!T)return;if(!(null==e?void 0:e.name)||void 0===(null==e?void 0:e.value))return void console.warn(et+" Invalid metric received",e);if(this.maxAllowedValue>0&&e.value>=this.maxAllowedValue&&"CLS"!==e.name)return void console.warn(et+" Ignoring "+e.name+" with value >= "+this.maxAllowedValue+"ms");var t=this.getCurrentUrl(),n=this.getCurrentPathname();if(!t)return void console.warn(et+" Could not determine current URL");this.buffer.url&&this.buffer.url!==t&&this.flush(),this.buffer.url||(this.buffer.url=t,this.buffer.pathname=n),this.buffer.firstMetricTimestamp||(this.buffer.firstMetricTimestamp=Date.now());var r=this.cleanAttribution(e.attribution),s=this.instance.getSessionId(),o=this.getWindowId(),a=i({},e,{attribution:r,timestamp:Date.now(),$current_url:t,$session_id:s,$window_id:o}),l=this.buffer.metrics.findIndex(t=>t.name===e.name);l>=0?this.buffer.metrics[l]=a:this.buffer.metrics.push(a),this.scheduleFlush(),this.buffer.metrics.length>=this.allowedMetrics.length&&this.flush()}catch(e){console.error(et+" Error adding metric to buffer:",e)}}cleanAttribution(e){if(e){var t=i({},e);return"interactionTargetElement"in t&&delete t.interactionTargetElement,t}}getWindowId(){var e;try{return(null===(e=this.instance.sessionManager)||void 0===e?void 0:e.getWindowId())||null}catch(e){return null}}scheduleFlush(){this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=setTimeout(()=>{this.flush()},this.flushTimeoutMs)}flush(){if(this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0),0!==this.buffer.metrics.length){try{var e={$pathname:this.buffer.pathname,$current_url:this.buffer.url};for(var t of this.buffer.metrics)e["$web_vitals_"+t.name+"_value"]=t.value,e["$web_vitals_"+t.name+"_event"]={name:t.name,value:t.value,delta:t.delta,rating:t.rating,id:t.id,navigationType:t.navigationType,attribution:t.attribution,$session_id:t.$session_id,$window_id:t.$window_id};this.instance.capture("$web_vitals",e)}catch(e){console.error(et+" Error flushing metrics:",e)}this.buffer=this.createEmptyBuffer()}}}function it(e,t,i){try{if(!(t in e))return()=>{};var n=e[t],r=i(n);return B(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__vtilt_wrapped__:{enumerable:!1,value:!0}})),e[t]=r,()=>{e[t]=n}}catch(e){return()=>{}}}class nt{constructor(e){var t;this._instance=e,this._lastPathname=(null===(t=null==I?void 0:I.location)||void 0===t?void 0:t.pathname)||""}get isEnabled(){return!0}startIfEnabled(){this.isEnabled&&this.monitorHistoryChanges()}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0}monitorHistoryChanges(){var e,t;if(I&&T&&(this._lastPathname=T.pathname||"",I.history)){var i=this;(null===(e=I.history.pushState)||void 0===e?void 0:e.__vtilt_wrapped__)||it(I.history,"pushState",e=>function(t,n,r){e.call(this,t,n,r),i._capturePageview("pushState")}),(null===(t=I.history.replaceState)||void 0===t?void 0:t.__vtilt_wrapped__)||it(I.history,"replaceState",e=>function(t,n,r){e.call(this,t,n,r),i._capturePageview("replaceState")}),this._setupPopstateListener()}}_capturePageview(e){var t;try{var i=null===(t=null==I?void 0:I.location)||void 0===t?void 0:t.pathname;if(!i||!T||!E)return;if(i!==this._lastPathname&&this.isEnabled){var n={navigation_type:e};this._instance.capture("$pageview",n)}this._lastPathname=i}catch(t){console.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener&&I){var e=()=>{this._capturePageview("popstate")};b(I,"popstate",e),this._popstateListener=()=>{I&&I.removeEventListener("popstate",e)}}}}var rt="[SessionRecording]";class st{constructor(e,t){void 0===t&&(t={}),this._instance=e,this._config=t}get started(){var e;return!!(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.isStarted)}get status(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.status)||"lazy_loading"}get sessionId(){var e;return(null===(e=this._lazyLoadedRecording)||void 0===e?void 0:e.sessionId)||""}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||!(null===(t=this._lazyLoadedRecording)||void 0===t?void 0:t.isStarted)){var i=void 0!==Object.assign&&void 0!==Array.from;this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),console.info(rt+" starting")):this.stopRecording()}}stopRecording(){var e;null===(e=this._lazyLoadedRecording)||void 0===e||e.stop()}log(e,t){var i;void 0===t&&(t="log"),(null===(i=this._lazyLoadedRecording)||void 0===i?void 0:i.log)?this._lazyLoadedRecording.log(e,t):console.warn(rt+" log called before recorder was ready")}updateConfig(e){var t;this._config=i({},this._config,e),null===(t=this._lazyLoadedRecording)||void 0===t||t.updateConfig(this._config)}get _isRecordingEnabled(){var e,t=this._instance.getConfig(),i=null!==(e=this._config.enabled)&&void 0!==e&&e,n=!t.disable_session_recording;return!!I&&i&&n}get _scriptName(){return"recorder"}_lazyLoadAndStart(e){var t,i,n,r;if(this._isRecordingEnabled)if((null===(i=null===(t=null==R?void 0:R.__VTiltExtensions__)||void 0===t?void 0:t.rrweb)||void 0===i?void 0:i.record)&&(null===(n=R.__VTiltExtensions__)||void 0===n?void 0:n.initSessionRecording))this._onScriptLoaded(e);else{var s=null===(r=R.__VTiltExtensions__)||void 0===r?void 0:r.loadExternalDependency;s?s(this._instance,this._scriptName,t=>{t?console.error(rt+" could not load recorder:",t):this._onScriptLoaded(e)}):console.error(rt+" loadExternalDependency not available. Session recording cannot start.")}}_onScriptLoaded(e){var t,i=null===(t=R.__VTiltExtensions__)||void 0===t?void 0:t.initSessionRecording;i?(this._lazyLoadedRecording||(this._lazyLoadedRecording=i(this._instance,this._config)),this._lazyLoadedRecording.start(e)):console.error(rt+" initSessionRecording not available after script load")}}var ot=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(ot||{}),at=Uint8Array,lt=Uint16Array,dt=Int32Array,ut=new at([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ht=new at([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ct=new at([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gt=function(e,t){for(var i=new lt(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var r=new dt(i[30]);for(n=1;n<30;++n)for(var s=i[n];s<i[n+1];++s)r[s]=s-i[n]<<5|n;return{b:i,r:r}},vt=gt(ut,2),_t=vt.b,ft=vt.r;_t[28]=258,ft[258]=28;for(var pt=gt(ht,0).r,mt=new lt(32768),yt=0;yt<32768;++yt){var bt=(43690&yt)>>1|(21845&yt)<<1;bt=(61680&(bt=(52428&bt)>>2|(13107&bt)<<2))>>4|(3855&bt)<<4,mt[yt]=((65280&bt)>>8|(255&bt)<<8)>>1}var wt=function(e,t,i){for(var n=e.length,r=0,s=new lt(t);r<n;++r)e[r]&&++s[e[r]-1];var o,a=new lt(t);for(r=1;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;if(i){o=new lt(1<<t);var l=15-t;for(r=0;r<n;++r)if(e[r])for(var d=r<<4|e[r],u=t-e[r],h=a[e[r]-1]++<<u,c=h|(1<<u)-1;h<=c;++h)o[mt[h]>>l]=d}else for(o=new lt(n),r=0;r<n;++r)e[r]&&(o[r]=mt[a[e[r]-1]++]>>15-e[r]);return o},St=new at(288);for(yt=0;yt<144;++yt)St[yt]=8;for(yt=144;yt<256;++yt)St[yt]=9;for(yt=256;yt<280;++yt)St[yt]=7;for(yt=280;yt<288;++yt)St[yt]=8;var It=new at(32);for(yt=0;yt<32;++yt)It[yt]=5;var Ct=wt(St,9,0),Mt=wt(It,5,0),Et=function(e){return(e+7)/8|0},Tt=function(e,t,i){return(null==i||i>e.length)&&(i=e.length),new at(e.subarray(t,i))},kt=function(e,t,i){i<<=7&t;var n=t/8|0;e[n]|=i,e[n+1]|=i>>8},Lt=function(e,t,i){i<<=7&t;var n=t/8|0;e[n]|=i,e[n+1]|=i>>8,e[n+2]|=i>>16},xt=function(e,t){for(var i=[],n=0;n<e.length;++n)e[n]&&i.push({s:n,f:e[n]});var r=i.length,s=i.slice();if(!r)return{t:qt,l:0};if(1==r){var o=new at(i[0].s+1);return o[i[0].s]=1,{t:o,l:1}}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],d=0,u=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[d].f<i[h].f?d++:h++],l=i[d!=u&&i[d].f<i[h].f?d++:h++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var c=s[0].s;for(n=1;n<r;++n)s[n].s>c&&(c=s[n].s);var g=new lt(c+1),v=Rt(i[u-1],g,0);if(v>t){n=0;var _=0,f=v-t,p=1<<f;for(s.sort(function(e,t){return g[t.s]-g[e.s]||e.f-t.f});n<r;++n){var m=s[n].s;if(!(g[m]>t))break;_+=p-(1<<v-g[m]),g[m]=t}for(_>>=f;_>0;){var y=s[n].s;g[y]<t?_-=1<<t-g[y]++-1:++n}for(;n>=0&&_;--n){var b=s[n].s;g[b]==t&&(--g[b],++_)}v=t}return{t:new at(g),l:v}},Rt=function(e,t,i){return-1==e.s?Math.max(Rt(e.l,t,i+1),Rt(e.r,t,i+1)):t[e.s]=i},Pt=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new lt(++t),n=0,r=e[0],s=1,o=function(e){i[n++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++s;else{if(!r&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(r),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(r);s=1,r=e[a]}return{c:i.subarray(0,n),n:t}},At=function(e,t){for(var i=0,n=0;n<t.length;++n)i+=e[n]*t[n];return i},Ot=function(e,t,i){var n=i.length,r=Et(t+2);e[r]=255&n,e[r+1]=n>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var s=0;s<n;++s)e[r+s+4]=i[s];return 8*(r+4+n)},zt=function(e,t,i,n,r,s,o,a,l,d,u){kt(t,u++,i),++r[256];for(var h=xt(r,15),c=h.t,g=h.l,v=xt(s,15),_=v.t,f=v.l,p=Pt(c),m=p.c,y=p.n,b=Pt(_),w=b.c,S=b.n,I=new lt(19),C=0;C<m.length;++C)++I[31&m[C]];for(C=0;C<w.length;++C)++I[31&w[C]];for(var M=xt(I,7),E=M.t,T=M.l,k=19;k>4&&!E[ct[k-1]];--k);var L,x,R,P,A=d+5<<3,O=At(r,St)+At(s,It)+o,z=At(r,c)+At(s,_)+o+14+3*k+At(I,E)+2*I[16]+3*I[17]+7*I[18];if(l>=0&&A<=O&&A<=z)return Ot(t,u,e.subarray(l,l+d));if(kt(t,u,1+(z<O)),u+=2,z<O){L=wt(c,g,0),x=c,R=wt(_,f,0),P=_;var $=wt(E,T,0);kt(t,u,y-257),kt(t,u+5,S-1),kt(t,u+10,k-4),u+=14;for(C=0;C<k;++C)kt(t,u+3*C,E[ct[C]]);u+=3*k;for(var q=[m,w],U=0;U<2;++U){var D=q[U];for(C=0;C<D.length;++C){var B=31&D[C];kt(t,u,$[B]),u+=E[B],B>15&&(kt(t,u,D[C]>>5&127),u+=D[C]>>12)}}}else L=Ct,x=St,R=Mt,P=It;for(C=0;C<a;++C){var F=n[C];if(F>255){Lt(t,u,L[(B=F>>18&31)+257]),u+=x[B+257],B>7&&(kt(t,u,F>>23&31),u+=ut[B]);var N=31&F;Lt(t,u,R[N]),u+=P[N],N>3&&(Lt(t,u,F>>5&8191),u+=ht[N])}else Lt(t,u,L[F]),u+=x[F]}return Lt(t,u,L[256]),u+x[256]},$t=new dt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),qt=new at(0),Ut=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var i=t,n=9;--n;)i=(1&i&&-306674912)^i>>>1;e[t]=i}return e}(),Dt=function(e,t,i,n,r){if(!r&&(r={l:1},t.dictionary)){var s=t.dictionary.subarray(-32768),o=new at(s.length+e.length);o.set(s),o.set(e,s.length),e=o,r.w=s.length}return function(e,t,i,n,r,s){var o=s.z||e.length,a=new at(n+o+5*(1+Math.ceil(o/7e3))+r),l=a.subarray(n,a.length-r),d=s.l,u=7&(s.r||0);if(t){u&&(l[0]=s.r>>3);for(var h=$t[t-1],c=h>>13,g=8191&h,v=(1<<i)-1,_=s.p||new lt(32768),f=s.h||new lt(v+1),p=Math.ceil(i/3),m=2*p,y=function(t){return(e[t]^e[t+1]<<p^e[t+2]<<m)&v},b=new dt(25e3),w=new lt(288),S=new lt(32),I=0,C=0,M=s.i||0,E=0,T=s.w||0,k=0;M+2<o;++M){var L=y(M),x=32767&M,R=f[L];if(_[x]=R,f[L]=x,T<=M){var P=o-M;if((I>7e3||E>24576)&&(P>423||!d)){u=zt(e,l,0,b,w,S,C,E,k,M-k,u),E=I=C=0,k=M;for(var A=0;A<286;++A)w[A]=0;for(A=0;A<30;++A)S[A]=0}var O=2,z=0,$=g,q=x-R&32767;if(P>2&&L==y(M-q))for(var U=Math.min(c,P)-1,D=Math.min(32767,M),B=Math.min(258,P);q<=D&&--$&&x!=R;){if(e[M+O]==e[M+O-q]){for(var F=0;F<B&&e[M+F]==e[M+F-q];++F);if(F>O){if(O=F,z=q,F>U)break;var N=Math.min(q,F-2),j=0;for(A=0;A<N;++A){var V=M-q+A&32767,W=V-_[V]&32767;W>j&&(j=W,R=V)}}}q+=(x=R)-(R=_[x])&32767}if(z){b[E++]=268435456|ft[O]<<18|pt[z];var J=31&ft[O],H=31&pt[z];C+=ut[J]+ht[H],++w[257+J],++S[H],T=M+O,++I}else b[E++]=e[M],++w[e[M]]}}for(M=Math.max(M,T);M<o;++M)b[E++]=e[M],++w[e[M]];u=zt(e,l,d,b,w,S,C,E,k,M-k,u),d||(s.r=7&u|l[u/8|0]<<3,u-=7,s.h=f,s.p=_,s.i=M,s.w=T)}else{for(M=s.w||0;M<o+d;M+=65535){var Q=M+65535;Q>=o&&(l[u/8|0]=d,Q=o),u=Ot(l,u+1,e.subarray(M,Q))}s.i=o}return Tt(a,0,n+Et(u)+r)}(e,null==t.level?6:t.level,null==t.mem?r.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,i,n,r)},Bt=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Ft(e,t){t||(t={});var i=function(){var e=-1;return{p:function(t){for(var i=e,n=0;n<t.length;++n)i=Ut[255&i^t[n]]^i>>>8;e=i},d:function(){return~e}}}(),n=e.length;i.p(e);var r,s=Dt(e,t,10+((r=t).filename?r.filename.length+1:0),8),o=s.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Bt(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var n=0;n<=i.length;++n)e[n+10]=i.charCodeAt(n)}}(s,t),Bt(s,o-8,i.d()),Bt(s,o-4,n),s}var Nt="undefined"!=typeof TextEncoder&&new TextEncoder,jt="undefined"!=typeof TextDecoder&&new TextDecoder;try{jt.decode(qt,{stream:!0})}catch(e){}ot.MouseMove,ot.MouseInteraction,ot.Scroll,ot.ViewportResize,ot.Input,ot.TouchMove,ot.MediaInteraction,ot.Drag;var Vt="[Chat]";class Wt{constructor(e,t){void 0===t&&(t={}),this._instance=e,this._serverConfig=null,this._configFetched=!1,this._isLoading=!1,this._loadError=null,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[],this._config=t}get isOpen(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isOpen)&&void 0!==t&&t}get isConnected(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isConnected)&&void 0!==t&&t}get isLoading(){var e,t;return this._isLoading||null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.isLoading)&&void 0!==t&&t}get unreadCount(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.unreadCount)&&void 0!==t?t:0}get channel(){var e,t;return null!==(t=null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.channel)&&void 0!==t?t:null}open(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.open()})}close(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.close()}toggle(){this._lazyLoadedChat?this._lazyLoadedChat.toggle():this.open()}show(){this._lazyLoadAndThen(()=>{var e;return null===(e=this._lazyLoadedChat)||void 0===e?void 0:e.show()})}hide(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.hide()}sendMessage(e){this._lazyLoadedChat?this._lazyLoadedChat.sendMessage(e):(this._pendingMessages.push(e),this._lazyLoadAndThen(()=>{this._pendingMessages.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.sendMessage(e)}),this._pendingMessages=[]}))}markAsRead(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.markAsRead()}onMessage(e){return this._messageCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onMessage(e):()=>{var t=this._messageCallbacks.indexOf(e);t>-1&&this._messageCallbacks.splice(t,1)}}onTyping(e){return this._typingCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onTyping(e):()=>{var t=this._typingCallbacks.indexOf(e);t>-1&&this._typingCallbacks.splice(t,1)}}onConnectionChange(e){return this._connectionCallbacks.push(e),this._lazyLoadedChat?this._lazyLoadedChat.onConnectionChange(e):()=>{var t=this._connectionCallbacks.indexOf(e);t>-1&&this._connectionCallbacks.splice(t,1)}}startIfEnabled(){var e=this;return t(function*(){var t,i,n,r;!1!==e._config.enabled?e._instance.getConfig().disable_chat?console.info(Vt+" disabled by disable_chat config"):(!1!==e._config.autoConfig&&(yield e._fetchServerSettings()),e._isChatEnabled?(null!==(n=null!==(t=e._config.preload)&&void 0!==t?t:null===(i=e._serverConfig)||void 0===i?void 0:i.enabled)&&void 0!==n&&n&&e._schedulePreload(),(null===(r=e._serverConfig)||void 0===r?void 0:r.enabled)&&e._showBubble(),console.info(Vt+" ready (lazy-load on demand)")):console.info(Vt+" not enabled (check dashboard settings)")):console.info(Vt+" disabled by code config")})()}updateConfig(e){this._config=i({},this._config,e)}getMergedConfig(){var e,t,i,n,r,s,o,a,l,d,u,h,c,g,v,_,f,p,m=this._serverConfig,y=this._config;return{enabled:null!==(t=null!==(e=y.enabled)&&void 0!==e?e:null==m?void 0:m.enabled)&&void 0!==t&&t,autoConfig:null===(i=y.autoConfig)||void 0===i||i,position:null!==(r=null!==(n=y.position)&&void 0!==n?n:null==m?void 0:m.position)&&void 0!==r?r:"bottom-right",greeting:null!==(s=y.greeting)&&void 0!==s?s:null==m?void 0:m.greeting,color:null!==(a=null!==(o=y.color)&&void 0!==o?o:null==m?void 0:m.color)&&void 0!==a?a:"#6366f1",aiMode:null===(d=null!==(l=y.aiMode)&&void 0!==l?l:null==m?void 0:m.ai_enabled)||void 0===d||d,aiGreeting:null!==(u=y.aiGreeting)&&void 0!==u?u:null==m?void 0:m.ai_greeting,preload:null!==(h=y.preload)&&void 0!==h&&h,theme:null!==(c=y.theme)&&void 0!==c?c:{primaryColor:null!==(v=null!==(g=y.color)&&void 0!==g?g:null==m?void 0:m.color)&&void 0!==v?v:"#6366f1"},offlineMessage:null!==(_=y.offlineMessage)&&void 0!==_?_:null==m?void 0:m.offline_message,collectEmailOffline:null===(p=null!==(f=y.collectEmailOffline)&&void 0!==f?f:null==m?void 0:m.collect_email_offline)||void 0===p||p}}destroy(){var e;null===(e=this._lazyLoadedChat)||void 0===e||e.destroy(),this._lazyLoadedChat=void 0,this._pendingMessages=[],this._pendingCallbacks=[],this._messageCallbacks=[],this._typingCallbacks=[],this._connectionCallbacks=[]}get _isChatEnabled(){var e;return!1!==this._config.enabled&&(!0===this._config.enabled||!0===(null===(e=this._serverConfig)||void 0===e?void 0:e.enabled))}_fetchServerSettings(){var e=this;return t(function*(){if(!e._configFetched){var t=e._instance.getConfig(),i=t.token,n=t.api_host;if(!i||!n)return console.warn(Vt+" Cannot fetch settings: missing token or api_host"),void(e._configFetched=!0);try{var r=n+"/api/chat/settings?token="+encodeURIComponent(i),s=yield fetch(r);if(!s.ok)return console.warn(Vt+" Failed to fetch settings: "+s.status),void(e._configFetched=!0);e._serverConfig=yield s.json(),e._configFetched=!0,console.info(Vt+" Loaded settings from dashboard")}catch(t){console.warn(Vt+" Error fetching settings:",t),e._configFetched=!0}}})()}_showBubble(){if((null==I?void 0:I.document)&&!document.getElementById("vtilt-chat-bubble")){var e=this.getMergedConfig(),t=e.position||"bottom-right",i=e.color||"#6366f1",n=document.createElement("div");n.id="vtilt-chat-bubble",n.setAttribute("style",("\n position: fixed;\n bottom: 20px;\n "+("bottom-right"===t?"right: 20px;":"left: 20px;")+"\n width: 60px;\n height: 60px;\n border-radius: 50%;\n background: "+i+";\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n transition: transform 0.2s, box-shadow 0.2s;\n z-index: 999999;\n ").trim()),n.innerHTML='\n <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">\n <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>\n </svg>\n ',n.addEventListener("mouseenter",()=>{n.style.transform="scale(1.05)",n.style.boxShadow="0 6px 16px rgba(0, 0, 0, 0.2)"}),n.addEventListener("mouseleave",()=>{n.style.transform="scale(1)",n.style.boxShadow="0 4px 12px rgba(0, 0, 0, 0.15)"}),n.addEventListener("click",()=>{this.open()}),document.body.appendChild(n)}}get _scriptName(){return"chat"}_schedulePreload(){"undefined"!=typeof requestIdleCallback?requestIdleCallback(()=>this._lazyLoad(),{timeout:5e3}):setTimeout(()=>this._lazyLoad(),3e3)}_lazyLoadAndThen(e){this._lazyLoadedChat?e():(this._pendingCallbacks.push(e),this._lazyLoad())}_lazyLoad(){var e,t;if(!(this._isLoading||this._lazyLoadedChat||this._loadError))if(null===(e=R.__VTiltExtensions__)||void 0===e?void 0:e.initChat)this._onScriptLoaded();else{this._isLoading=!0;var i=null===(t=R.__VTiltExtensions__)||void 0===t?void 0:t.loadExternalDependency;if(!i)return console.error(Vt+" loadExternalDependency not available. Chat cannot start."),this._isLoading=!1,void(this._loadError="loadExternalDependency not available");i(this._instance,this._scriptName,e=>{if(this._isLoading=!1,e)return console.error(Vt+" Failed to load:",e),void(this._loadError=String(e));this._onScriptLoaded()})}}_onScriptLoaded(){var e,t=null===(e=R.__VTiltExtensions__)||void 0===e?void 0:e.initChat;if(!t)return console.error(Vt+" initChat not available after script load"),void(this._loadError="initChat not available");if(!this._lazyLoadedChat){var i=this.getMergedConfig();this._lazyLoadedChat=t(this._instance,i),this._messageCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onMessage(e)}),this._typingCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onTyping(e)}),this._connectionCallbacks.forEach(e=>{var t;return null===(t=this._lazyLoadedChat)||void 0===t?void 0:t.onConnectionChange(e)});var n=null===document||void 0===document?void 0:document.getElementById("vtilt-chat-bubble");n&&n.remove()}this._pendingCallbacks.forEach(e=>e()),this._pendingCallbacks=[],console.info(Vt+" loaded and ready")}}var Jt,Ht="text/plain";!function(e){e.GZipJS="gzip-js",e.None="none"}(Jt||(Jt={}));var Qt=e=>{var{data:t,compression:i}=e;if(t){var n=(e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t))(t),r=new Blob([n]).size;if(i===Jt.GZipJS&&r>=1024)try{var s=Ft(function(e,t){if(Nt)return Nt.encode(e);for(var i=e.length,n=new at(e.length+(e.length>>1)),r=0,s=function(e){n[r++]=e},o=0;o<i;++o){if(r+5>n.length){var a=new at(r+8+(i-o<<1));a.set(n),n=a}var l=e.charCodeAt(o);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|63&l)):(s(224|l>>12),s(128|l>>6&63),s(128|63&l))}return Tt(n,0,r)}(n),{mtime:0}),o=new Blob([s],{type:Ht});if(o.size<.95*r)return{contentType:Ht,body:o,estimatedSize:o.size}}catch(e){}return{contentType:"application/json",body:n,estimatedSize:r}}},Gt=[{name:"fetch",available:"undefined"!=typeof fetch,method:e=>{var n=Qt(e);if(n){var{contentType:r,body:s,estimatedSize:o}=n,a=e.compression===Jt.GZipJS&&r===Ht?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,l=i({"Content-Type":r},e.headers||{}),d=new AbortController,u=e.timeout?setTimeout(()=>d.abort(),e.timeout):null;fetch(a,{method:e.method||"POST",headers:l,body:s,keepalive:o<52428.8,signal:d.signal}).then(function(){var i=t(function*(t){var i,n=yield t.text(),r={statusCode:t.status,text:n};if(200===t.status)try{r.json=JSON.parse(n)}catch(e){}null===(i=e.callback)||void 0===i||i.call(e,r)});return function(e){return i.apply(this,arguments)}}()).catch(()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})}).finally(()=>{u&&clearTimeout(u)})}}},{name:"XHR",available:"undefined"!=typeof XMLHttpRequest,method:e=>{var t=Qt(e);if(t){var{contentType:i,body:n}=t,r=e.compression===Jt.GZipJS&&i===Ht?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url,s=new XMLHttpRequest;s.open(e.method||"POST",r,!0),e.headers&&Object.entries(e.headers).forEach(e=>{var[t,i]=e;s.setRequestHeader(t,i)}),s.setRequestHeader("Content-Type",i),e.timeout&&(s.timeout=e.timeout),s.onreadystatechange=()=>{var t;if(4===s.readyState){var i={statusCode:s.status,text:s.responseText};if(200===s.status)try{i.json=JSON.parse(s.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,i)}},s.onerror=()=>{var t;null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0})},s.send(n)}}},{name:"sendBeacon",available:"undefined"!=typeof navigator&&!!navigator.sendBeacon,method:e=>{var t=Qt(e);if(t){var{contentType:i,body:n}=t;try{var r="string"==typeof n?new Blob([n],{type:i}):n,s=e.compression===Jt.GZipJS&&i===Ht?e.url+(e.url.includes("?")?"&":"?")+"compression=gzip-js":e.url;navigator.sendBeacon(s,r)}catch(e){}}}}],Xt=e=>{var t,i=e.transport||"fetch",n=Gt.find(e=>e.name===i&&e.available)||Gt.find(e=>e.available);if(!n)return console.error("vTilt: No available transport method"),void(null===(t=e.callback)||void 0===t||t.call(e,{statusCode:0}));n.method(e)};class Kt{constructor(e,t){var i,n,r,s;this._isPaused=!0,this._queue=[],this._flushTimeoutMs=(i=(null==t?void 0:t.flush_interval_ms)||3e3,n=250,r=5e3,s=3e3,"number"!=typeof i||isNaN(i)?s:Math.min(Math.max(i,n),r)),this._sendRequest=e}get length(){return this._queue.length}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){if(this._clearFlushTimeout(),0!==this._queue.length){var e=this._formatQueue();for(var t in e){var n=e[t];this._sendRequest(i({},n,{transport:"sendBeacon"}))}}}enable(){this._isPaused=!1,this._setFlushTimeout()}pause(){this._isPaused=!0,this._clearFlushTimeout()}flush(){this._clearFlushTimeout(),this._flushNow(),this._setFlushTimeout()}_setFlushTimeout(){this._isPaused||(this._flushTimeout=setTimeout(()=>{this._clearFlushTimeout(),this._flushNow(),this._queue.length>0&&this._setFlushTimeout()},this._flushTimeoutMs))}_clearFlushTimeout(){this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0)}_flushNow(){if(0!==this._queue.length){var e=this._formatQueue(),t=Date.now();for(var i in e){var n=e[i];n.events.forEach(e=>{var i=new Date(e.timestamp).getTime();e.$offset=Math.abs(i-t)}),this._sendRequest(n)}}}_formatQueue(){var e={};return this._queue.forEach(t=>{var i=t.batchKey||t.url;e[i]||(e[i]={url:t.url,events:[],batchKey:t.batchKey}),e[i].events.push(t.event)}),this._queue=[],e}}class Zt{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._areWeOnline=!0,this._sendRequest=e.sendRequest,this._sendBeacon=e.sendBeacon,I&&void 0!==M&&"onLine"in M&&(this._areWeOnline=M.onLine,b(I,"online",()=>{this._areWeOnline=!0,this._flush()}),b(I,"offline",()=>{this._areWeOnline=!1}))}get length(){return this._queue.length}enqueue(e,t){if(void 0===t&&(t=0),t>=10)console.warn("VTilt: Request failed after 10 retries, giving up");else{var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,n=Math.min(18e5,t),r=(Math.random()-.5)*(n-i);return Math.ceil(n+r)}(t),n=Date.now()+i;this._queue.push({retryAt:n,request:e,retriesPerformedSoFar:t+1});var r="VTilt: Enqueued failed request for retry in "+Math.round(i/1e3)+"s";this._areWeOnline||(r+=" (Browser is offline)"),console.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}}retriableRequest(e){var i=this;return t(function*(){try{var t=yield i._sendRequest(e);200!==t.statusCode&&(t.statusCode<400||t.statusCode>=500)&&i.enqueue(e,0)}catch(t){i.enqueue(e,0)}})()}_poll(){this._poller&&clearTimeout(this._poller),this._poller=setTimeout(()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._queue.length>0?this._poll():this._isPolling=!1},this._pollIntervalMs)}_flush(){var e=this,i=Date.now(),n=[],r=[];this._queue.forEach(e=>{e.retryAt<i?r.push(e):n.push(e)}),this._queue=n,r.forEach(function(){var i=t(function*(t){var{request:i,retriesPerformedSoFar:n}=t;try{var r=yield e._sendRequest(i);200!==r.statusCode&&(r.statusCode<400||r.statusCode>=500)&&e.enqueue(i,n)}catch(t){e.enqueue(i,n)}});return function(e){return i.apply(this,arguments)}}())}unload(){this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue.forEach(e=>{var{request:t}=e;try{this._sendBeacon(t)}catch(e){console.error("VTilt: Failed to send beacon on unload",e)}}),this._queue=[]}}var Yt="vt_rate_limit";class ei{constructor(e){var t,i;void 0===e&&(e={}),this.lastEventRateLimited=!1,this.eventsPerSecond=null!==(t=e.eventsPerSecond)&&void 0!==t?t:10,this.eventsBurstLimit=Math.max(null!==(i=e.eventsBurstLimit)&&void 0!==i?i:10*this.eventsPerSecond,this.eventsPerSecond),this.persistence=e.persistence,this.captureWarning=e.captureWarning,this.lastEventRateLimited=this.checkRateLimit(!0).isRateLimited}checkRateLimit(e){var t,i,n,r;void 0===e&&(e=!1);var s=Date.now(),o=null!==(i=null===(t=this.persistence)||void 0===t?void 0:t.get(Yt))&&void 0!==i?i:{tokens:this.eventsBurstLimit,last:s},a=(s-o.last)/1e3;o.tokens+=a*this.eventsPerSecond,o.last=s,o.tokens>this.eventsBurstLimit&&(o.tokens=this.eventsBurstLimit);var l=o.tokens<1;return l||e||(o.tokens=Math.max(0,o.tokens-1)),!l||this.lastEventRateLimited||e||null===(n=this.captureWarning)||void 0===n||n.call(this,"vTilt client rate limited. Config: "+this.eventsPerSecond+" events/second, "+this.eventsBurstLimit+" burst limit."),this.lastEventRateLimited=l,null===(r=this.persistence)||void 0===r||r.set(Yt,o),{isRateLimited:l,remainingTokens:o.tokens}}shouldAllowEvent(){return!this.checkRateLimit(!1).isRateLimited}getRemainingTokens(){return this.checkRateLimit(!0).remainingTokens}}class ti{constructor(e){void 0===e&&(e={}),this.version="1.1.5",this.__loaded=!1,this._initial_pageview_captured=!1,this._visibility_state_listener=null,this.__request_queue=[],this._has_warned_about_config=!1,this._set_once_properties_sent=!1,this.configManager=new n(e);var t=this.configManager.getConfig();this.sessionManager=new $(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Xe(t.persistence||"localStorage",t.cross_subdomain_cookie),this.webVitalsManager=new tt(t,this),this.rateLimiter=new ei({eventsPerSecond:10,eventsBurstLimit:100,captureWarning:e=>{this._capture_internal("$$client_ingestion_warning",{$$client_ingestion_warning_message:e})}}),this.retryQueue=new Zt({sendRequest:e=>this._send_http_request(e),sendBeacon:e=>this._send_beacon_request(e)}),this.requestQueue=new Kt(e=>this._send_batched_request(e),{flush_interval_ms:3e3})}init(e,t,i){var n;if(i&&i!==ni){var r=null!==(n=ii[i])&&void 0!==n?n:new ti;return r._init(e,t,i),ii[i]=r,ii[ni][i]=r,r}return this._init(e,t,i)}_init(e,t,n){if(void 0===t&&(t={}),this.__loaded)return console.warn("vTilt: You have already initialized vTilt! Re-initializing is a no-op"),this;this.updateConfig(i({},t,{projectId:e||t.projectId,name:n})),this.__loaded=!0;var r=this.configManager.getConfig();return this.userManager.set_initial_person_info(r.mask_personal_data_properties,r.custom_personal_data_properties),this.historyAutocapture=new nt(this),this.historyAutocapture.startIfEnabled(),this._initSessionRecording(),this._initChat(),this._setup_unload_handler(),this._start_queue_if_opted_in(),!1!==r.capture_pageview&&this._capture_initial_pageview(),this}_start_queue_if_opted_in(){this.requestQueue.enable()}_setup_unload_handler(){if(I){var e=()=>{this.requestQueue.unload(),this.retryQueue.unload()};b(I,"beforeunload",e),b(I,"pagehide",e)}}toString(){var e,t=null!==(e=this.configManager.getConfig().name)&&void 0!==e?e:ni;return t!==ni&&(t=ni+"."+t),t}getCurrentDomain(){if(!T)return"";var e=T.protocol,t=T.hostname,i=T.port;return e+"//"+t+(i?":"+i:"")}_is_configured(){var e=this.configManager.getConfig();return!(!e.projectId||!e.token)||(this._has_warned_about_config||(console.warn("VTilt: projectId and token are required for tracking. Events will be skipped until init() or updateConfig() is called with these fields."),this._has_warned_about_config=!0),!1)}buildUrl(){var e=this.configManager.getConfig(),{proxyUrl:t,proxy:i,api_host:n,token:r}=e;return t||(i?i+"/api/tracking?token="+r:n?n.replace(/\/+$/gm,"")+"/api/tracking?token="+r:"/api/tracking?token="+r)}sendRequest(e,t,i){if(this._is_configured()){if(i&&void 0!==I)if(I.__VTILT_ENQUEUE_REQUESTS)return void this.__request_queue.push({url:e,event:t});this.requestQueue.enqueue({url:e,event:t})}}_send_batched_request(e){var{transport:t}=e;"sendBeacon"!==t?this.retryQueue.retriableRequest(e):this._send_beacon_request(e)}_send_http_request(e){return new Promise(t=>{var{url:i,events:n}=e,r=1===n.length?n[0]:{events:n},s=this.configManager.getConfig().disable_compression?Jt.None:Jt.GZipJS;Xt({url:i,data:r,method:"POST",transport:"XHR",compression:s,callback:e=>{t({statusCode:e.statusCode})}})})}_send_beacon_request(e){var{url:t,events:i}=e,n=1===i.length?i[0]:{events:i},r=this.configManager.getConfig().disable_compression?Jt.None:Jt.GZipJS;Xt({url:t,data:n,method:"POST",transport:"sendBeacon",compression:r})}_send_retriable_request(e){this.sendRequest(e.url,e.event,!1)}capture(e,t,n){if(this.sessionManager.setSessionId(),M&&M.userAgent&&function(e){return!(e&&"string"==typeof e&&e.length>500)}(M.userAgent)&&((null==n?void 0:n.skip_client_rate_limiting)||this.rateLimiter.shouldAllowEvent())){var r=this.buildUrl(),s=Ge(),o=this.userManager.getUserProperties(),a=this.userManager.get_initial_props(),l=this.sessionManager.getSessionId(),d=this.sessionManager.getWindowId(),u=this.userManager.getAnonymousId(),h={};!this._set_once_properties_sent&&Object.keys(a).length>0&&Object.assign(h,a),t.$set_once&&Object.assign(h,t.$set_once);var c=i({},s,o,{$session_id:l,$window_id:d},u?{$anon_distinct_id:u}:{},Object.keys(h).length>0?{$set_once:h}:{},t.$set?{$set:t.$set}:{},t);!this._set_once_properties_sent&&Object.keys(a).length>0&&(this._set_once_properties_sent=!0),"$pageview"===e&&E&&(c.title=E.title);var g,v,_=this.configManager.getConfig();if(!1!==_.stringifyPayload){if(g=Object.assign({},c,_.globalAttributes),!m(g=JSON.stringify(g)))return}else if(g=Object.assign({},c,_.globalAttributes),!m(JSON.stringify(g)))return;v="$identify"===e?this.userManager.getAnonymousId():this.userManager.getDistinctId()||this.userManager.getAnonymousId();var f={timestamp:(new Date).toISOString(),event:e,project_id:_.projectId||"",payload:g,distinct_id:v,anonymous_id:u};this.sendRequest(r,f,!0)}}_capture_internal(e,t){this.capture(e,t,{skip_client_rate_limiting:!0})}trackEvent(e,t){void 0===t&&(t={}),this.capture(e,t)}identify(e,t,i){if("number"==typeof e&&(e=String(e),console.warn("The first argument to vTilt.identify was a number, but it should be a string. It has been converted to a string.")),e)if(this.userManager.isDistinctIdStringLikePublic(e))console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if("COOKIELESS_SENTINEL_VALUE"!==e){var n=this.userManager.getDistinctId(),r=this.userManager.getAnonymousId(),s=this.userManager.getDeviceId(),o="anonymous"===this.userManager.getUserState();if(!s){var a=n||r;this.userManager.ensureDeviceId(a)}e!==n&&o?(this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r,$set:t||{},$set_once:i||{}}),this.userManager.setDistinctId(e)):t||i?(o&&this.userManager.setUserState("identified"),this.userManager.updateUserProperties(t,i),this.capture("$set",{$set:t||{},$set_once:i||{}})):e!==n&&(this.userManager.setUserState("identified"),this.userManager.setDistinctId(e))}else console.error('The string "'+e+'" was set in vTilt.identify which indicates an error. This ID is only used as a sentinel value.');else console.error("Unique user id has not been set in vTilt.identify")}setUserProperties(e,t){this.userManager.setUserProperties(e,t)&&this.capture("$set",{$set:e||{},$set_once:t||{}})}resetUser(e){this.sessionManager.resetSessionId(),this.userManager.reset(e)}getUserIdentity(){return this.userManager.getUserIdentity()}getDeviceId(){return this.userManager.getDeviceId()}getUserState(){return this.userManager.getUserState()}createAlias(e,t){var i=this.userManager.createAlias(e,t);i?this.capture("$alias",{$original_id:i.original,$alias_id:i.distinct_id}):e===(t||this.userManager.getDistinctId()||this.userManager.getAnonymousId())&&this.identify(e)}_capture_initial_pageview(){E&&("visible"===E.visibilityState?this._initial_pageview_captured||(this._initial_pageview_captured=!0,setTimeout(()=>{if(E&&T){this.capture("$pageview",{navigation_type:"initial_load"})}},300),this._visibility_state_listener&&(E.removeEventListener("visibilitychange",this._visibility_state_listener),this._visibility_state_listener=null)):this._visibility_state_listener||(this._visibility_state_listener=()=>{this._capture_initial_pageview()},b(E,"visibilitychange",this._visibility_state_listener)))}getConfig(){return this.configManager.getConfig()}getSessionId(){return this.sessionManager.getSessionId()}getDistinctId(){return this.userManager.getDistinctId()||this.userManager.getAnonymousId()}getAnonymousId(){return this.userManager.getAnonymousId()}updateConfig(e){this.configManager.updateConfig(e);var t=this.configManager.getConfig();this.sessionManager=new $(t.storage||"cookie",t.cross_subdomain_cookie),this.userManager=new Xe(t.persistence||"localStorage",t.cross_subdomain_cookie),this.webVitalsManager=new tt(t,this),this.sessionRecording&&t.session_recording&&this.sessionRecording.updateConfig(this._buildSessionRecordingConfig(t))}_initSessionRecording(){var e=this.configManager.getConfig();if(!e.disable_session_recording){var t=this._buildSessionRecordingConfig(e);this.sessionRecording=new st(this,t),t.enabled&&this.sessionRecording.startIfEnabledOrStop("recording_initialized")}}_buildSessionRecordingConfig(e){var t,i,n,r=e.session_recording||{};return{enabled:null!==(t=r.enabled)&&void 0!==t&&t,sampleRate:r.sampleRate,minimumDurationMs:r.minimumDurationMs,sessionIdleThresholdMs:r.sessionIdleThresholdMs,fullSnapshotIntervalMs:r.fullSnapshotIntervalMs,captureConsole:null!==(i=r.captureConsole)&&void 0!==i&&i,captureNetwork:null!==(n=r.captureNetwork)&&void 0!==n&&n,captureCanvas:r.captureCanvas,blockClass:r.blockClass,blockSelector:r.blockSelector,ignoreClass:r.ignoreClass,maskTextClass:r.maskTextClass,maskTextSelector:r.maskTextSelector,maskAllInputs:r.maskAllInputs,maskInputOptions:r.maskInputOptions,masking:r.masking,recordHeaders:r.recordHeaders,recordBody:r.recordBody,compressEvents:r.compressEvents,__mutationThrottlerRefillRate:r.__mutationThrottlerRefillRate,__mutationThrottlerBucketSize:r.__mutationThrottlerBucketSize}}startSessionRecording(){if(!this.sessionRecording){var e=this.configManager.getConfig(),t=this._buildSessionRecordingConfig(e);t.enabled=!0,this.sessionRecording=new st(this,t)}this.sessionRecording.startIfEnabledOrStop("recording_initialized")}stopSessionRecording(){var e;null===(e=this.sessionRecording)||void 0===e||e.stopRecording()}isRecordingActive(){var e;return"active"===(null===(e=this.sessionRecording)||void 0===e?void 0:e.status)}getSessionRecordingId(){var e;return(null===(e=this.sessionRecording)||void 0===e?void 0:e.sessionId)||null}_initChat(){var e=this.configManager.getConfig();if(!e.disable_chat){var t=this._buildChatConfig(e);this.chat=new Wt(this,t),this.chat.startIfEnabled()}}_buildChatConfig(e){var t,i=e.chat||{};return{enabled:i.enabled,autoConfig:null===(t=i.autoConfig)||void 0===t||t,position:i.position,greeting:i.greeting,color:i.color,aiMode:i.aiMode,aiGreeting:i.aiGreeting,preload:i.preload,offlineMessage:i.offlineMessage,collectEmailOffline:i.collectEmailOffline}}_execute_array(e){Array.isArray(e)&&e.forEach(e=>{if(e&&Array.isArray(e)&&e.length>0){var t=e[0],i=e.slice(1);if("function"==typeof this[t])try{this[t](...i)}catch(e){console.error("vTilt: Error executing queued call "+t+":",e)}}})}_dom_loaded(){this.__request_queue.forEach(e=>{this._send_retriable_request(e)}),this.__request_queue=[],this._start_queue_if_opted_in()}}var ii={},ni="vt",ri=!(void 0!==L||void 0!==k)&&-1===(null==x?void 0:x.indexOf("MSIE"))&&-1===(null==x?void 0:x.indexOf("Mozilla"));null!=I&&(I.__VTILT_ENQUEUE_REQUESTS=ri);var si,oi=(si=ii[ni]=new ti,function(){function e(){e.done||(e.done=!0,ri=!1,null!=I&&(I.__VTILT_ENQUEUE_REQUESTS=!1),y(ii,function(e){e._dom_loaded()}))}E&&"function"==typeof E.addEventListener?"complete"===E.readyState?e():b(E,"DOMContentLoaded",e,{capture:!1}):I&&console.error("Browser doesn't support `document.addEventListener` so vTilt couldn't be initialized")}(),si);export{Ke as ALL_WEB_VITALS_METRICS,Ze as DEFAULT_WEB_VITALS_METRICS,ti as VTilt,oi as default,oi as vt};
2
2
  //# sourceMappingURL=module.no-external.js.map