posthog-js 1.316.0 → 1.317.0

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 (86) hide show
  1. package/dist/all-external-dependencies.js +1 -1
  2. package/dist/all-external-dependencies.js.map +1 -1
  3. package/dist/array.full.es5.js +1 -1
  4. package/dist/array.full.es5.js.map +1 -1
  5. package/dist/array.full.js +1 -1
  6. package/dist/array.full.js.map +1 -1
  7. package/dist/array.full.no-external.js +1 -1
  8. package/dist/array.full.no-external.js.map +1 -1
  9. package/dist/array.js +1 -1
  10. package/dist/array.no-external.js +1 -1
  11. package/dist/customizations.full.js +1 -1
  12. package/dist/element-inference.d.ts +21 -0
  13. package/dist/element-inference.js +2 -0
  14. package/dist/element-inference.js.map +1 -0
  15. package/dist/lazy-recorder.js +1 -1
  16. package/dist/main.js +1 -1
  17. package/dist/main.js.map +1 -1
  18. package/dist/module.d.ts +12 -0
  19. package/dist/module.full.d.ts +12 -0
  20. package/dist/module.full.js +1 -1
  21. package/dist/module.full.js.map +1 -1
  22. package/dist/module.full.no-external.d.ts +12 -0
  23. package/dist/module.full.no-external.js +1 -1
  24. package/dist/module.full.no-external.js.map +1 -1
  25. package/dist/module.js +1 -1
  26. package/dist/module.js.map +1 -1
  27. package/dist/module.no-external.d.ts +12 -0
  28. package/dist/module.no-external.js +1 -1
  29. package/dist/module.no-external.js.map +1 -1
  30. package/dist/posthog-recorder.js +1 -1
  31. package/dist/product-tours-preview.d.ts +12 -0
  32. package/dist/product-tours-preview.js +1 -1
  33. package/dist/product-tours-preview.js.map +1 -1
  34. package/dist/product-tours.js +1 -1
  35. package/dist/product-tours.js.map +1 -1
  36. package/dist/src/entrypoints/element-inference.es.d.ts +1 -0
  37. package/dist/src/entrypoints/product-tours.d.ts +2 -0
  38. package/dist/src/extensions/product-tours/element-inference.d.ts +30 -0
  39. package/dist/src/extensions/product-tours/index.d.ts +2 -0
  40. package/dist/src/extensions/product-tours/product-tours-utils.d.ts +2 -1
  41. package/dist/src/extensions/surveys.d.ts +2 -2
  42. package/dist/src/posthog-product-tours-types.d.ts +7 -0
  43. package/dist/src/utils/survey-branching.d.ts +11 -0
  44. package/dist/src/utils/survey-url-prefill.d.ts +7 -5
  45. package/dist/surveys-preview.d.ts +18 -1
  46. package/dist/surveys-preview.js +1 -1
  47. package/dist/surveys-preview.js.map +1 -1
  48. package/dist/surveys.js +1 -1
  49. package/dist/surveys.js.map +1 -1
  50. package/lib/package.json +5 -1
  51. package/lib/src/entrypoints/element-inference.es.d.ts +1 -0
  52. package/lib/src/entrypoints/element-inference.es.js +8 -0
  53. package/lib/src/entrypoints/element-inference.es.js.map +1 -0
  54. package/lib/src/entrypoints/product-tours.d.ts +2 -0
  55. package/lib/src/entrypoints/product-tours.js +5 -0
  56. package/lib/src/entrypoints/product-tours.js.map +1 -1
  57. package/lib/src/extensions/product-tours/components/ProductTourTooltip.js +5 -2
  58. package/lib/src/extensions/product-tours/components/ProductTourTooltip.js.map +1 -1
  59. package/lib/src/extensions/product-tours/components/ProductTourTooltipInner.js +1 -1
  60. package/lib/src/extensions/product-tours/components/ProductTourTooltipInner.js.map +1 -1
  61. package/lib/src/extensions/product-tours/element-inference.d.ts +30 -0
  62. package/lib/src/extensions/product-tours/element-inference.js +296 -0
  63. package/lib/src/extensions/product-tours/element-inference.js.map +1 -0
  64. package/lib/src/extensions/product-tours/index.d.ts +2 -0
  65. package/lib/src/extensions/product-tours/index.js +4 -1
  66. package/lib/src/extensions/product-tours/index.js.map +1 -1
  67. package/lib/src/extensions/product-tours/preview.js +1 -1
  68. package/lib/src/extensions/product-tours/preview.js.map +1 -1
  69. package/lib/src/extensions/product-tours/product-tours-utils.d.ts +2 -1
  70. package/lib/src/extensions/product-tours/product-tours-utils.js +12 -0
  71. package/lib/src/extensions/product-tours/product-tours-utils.js.map +1 -1
  72. package/lib/src/extensions/product-tours/product-tours.js +15 -31
  73. package/lib/src/extensions/product-tours/product-tours.js.map +1 -1
  74. package/lib/src/extensions/surveys.d.ts +2 -2
  75. package/lib/src/extensions/surveys.js +5 -94
  76. package/lib/src/extensions/surveys.js.map +1 -1
  77. package/lib/src/posthog-product-tours-types.d.ts +7 -0
  78. package/lib/src/posthog-product-tours-types.js.map +1 -1
  79. package/lib/src/utils/survey-branching.d.ts +11 -0
  80. package/lib/src/utils/survey-branching.js +106 -0
  81. package/lib/src/utils/survey-branching.js.map +1 -0
  82. package/lib/src/utils/survey-url-prefill.d.ts +7 -5
  83. package/lib/src/utils/survey-url-prefill.js +30 -18
  84. package/lib/src/utils/survey-url-prefill.js.map +1 -1
  85. package/lib/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +7 -3
@@ -1 +1 @@
1
- {"version":3,"file":"product-tours.js","sources":["../src/utils/globals.ts","../../../node_modules/.pnpm/preact@10.19.3/node_modules/preact/dist/preact.module.js","../src/posthog-surveys-types.ts","../src/posthog-product-tours-types.ts","../../core/dist/types.mjs","../../core/dist/utils/type-utils.mjs","../src/utils/logger.ts","../src/extensions/utils/stylesheet-loader.ts","../src/utils/index.ts","../src/utils/survey-utils.ts","../src/request.ts","../src/utils/regex-utils.ts","../src/utils/property-utils.ts","../../../node_modules/.pnpm/preact@10.19.3/node_modules/preact/hooks/dist/hooks.module.js","../src/extensions/surveys/surveys-extension-utils.tsx","../src/extensions/product-tours/product-tours-utils.ts","../src/extensions/surveys/icons.tsx","../src/extensions/product-tours/components/ProductTourTooltipInner.tsx","../src/extensions/product-tours/components/ProductTourSurveyStepInner.tsx","../src/extensions/product-tours/components/ProductTourTooltip.tsx","../src/uuidv7.ts","../src/storage.ts","../src/extensions/product-tours/constants.ts","../src/utils/product-tour-utils.ts","../src/utils/simple-event-emitter.ts","../src/utils/elements-chain-utils.ts","../src/extensions/surveys/action-matcher.ts","../src/utils/event-receiver.ts","../src/utils/product-tour-event-receiver.ts","../src/constants.ts","../src/extensions/product-tours/product-tours.tsx","../src/extensions/product-tours/index.ts","../src/entrypoints/product-tours.ts"],"sourcesContent":["import type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ExternalIntegrationKind,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n SessionStartReason,\n} from '../types'\nimport type {\n ConversationsRemoteConfig,\n GetMessagesResponse,\n GetTicketsOptions,\n GetTicketsResponse,\n MarkAsReadResponse,\n SendMessageResponse,\n UserProvidedTraits,\n} from '../posthog-conversations-types'\n// only importing types here, so won't affect the bundle\n// eslint-disable-next-line posthog-js/no-external-replay-imports\nimport type { SessionRecordingStatus, TriggerType } from '../extensions/replay/external/triggerMatching'\nimport { eventWithTime } from '../extensions/replay/types/rrweb-types'\nimport { ErrorTracking } from '@posthog/core'\n\n/*\n * Global helpers to protect access to browser globals in a way that is safer for different targets\n * like DOM, SSR, Web workers etc.\n *\n * NOTE: Typically we want the \"window\" but globalThis works for both the typical browser context as\n * well as other contexts such as the web worker context. Window is still exported for any bits that explicitly require it.\n * If in doubt - export the global you need from this file and use that as an optional value. This way the code path is forced\n * to handle the case where the global is not available.\n */\n\n// eslint-disable-next-line no-restricted-globals\nconst win: (Window & typeof globalThis) | undefined = typeof window !== 'undefined' ? window : undefined\n\nexport type AssignableWindow = Window &\n typeof globalThis & {\n /*\n * Main PostHog instance\n */\n posthog: any\n\n /*\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n */\n __PosthogExtensions__?: PostHogExtensions\n\n /**\n * When loading remote config, we assign it to this global configuration\n * for ease of sharing it with the rest of the SDK\n */\n _POSTHOG_REMOTE_CONFIG?: Record<\n string,\n {\n config: RemoteConfig\n siteApps: SiteAppLoader[]\n }\n >\n\n /**\n * If this is set on the window, our logger will log to the console\n * for ease of debugging. Used for testing purposes only.\n *\n * @see {Config.DEBUG} from config.ts\n */\n POSTHOG_DEBUG: any\n\n // Exposed by the browser\n doNotTrack: any\n\n // See entrypoints/customizations.full.ts\n posthogCustomizations: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/exception-autocapture.ts\n *\n * @deprecated use `__PosthogExtensions__.errorWrappingFunctions` instead\n */\n posthogErrorWrappingFunctions: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrweb` instead\n */\n rrweb: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrwebConsoleRecord` instead\n */\n rrwebConsoleRecord: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.getRecordNetworkPlugin` instead\n */\n getRecordNetworkPlugin: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/web-vitals.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogWebVitalsCallbacks` instead\n */\n postHogWebVitalsCallbacks: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/tracing-headers.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogTracingHeadersPatchFns` instead\n */\n postHogTracingHeadersPatchFns: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/surveys.ts\n *\n * @deprecated use `__PosthogExtensions__.generateSurveys` instead\n */\n extendPostHogWithSurveys: any\n\n /*\n * These are used to handle our toolbar state.\n * @see {Toolbar} from extensions/toolbar.ts\n */\n ph_load_toolbar: any\n ph_load_editor: any\n ph_toolbar_state: any\n } & Record<`__$$ph_site_app_${string}`, any>\n\n/**\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n * changes to this interface can be breaking changes for users of the SDK\n */\n\nexport type ExternalExtensionKind = 'intercom-integration' | 'crisp-chat-integration'\n\nexport type PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'lazy-recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'conversations'\n | 'product-tours'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n | ExternalExtensionKind\n\nexport interface LazyLoadedSessionRecordingInterface {\n start: (startReason?: SessionStartReason) => void\n stop: () => void\n sessionId: string\n status: SessionRecordingStatus\n onRRwebEmit: (rawEvent: eventWithTime) => void\n log: (message: string, level: 'log' | 'warn' | 'error') => void\n sdkDebugProperties: Properties\n overrideLinkedFlag: () => void\n overrideSampling: () => void\n overrideTrigger: (triggerType: TriggerType) => void\n isStarted: boolean\n tryAddCustomEvent(tag: string, payload: any): boolean\n}\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\n}\n\nexport interface LazyLoadedConversationsInterface {\n // Widget control\n show: () => void\n hide: () => void\n isVisible: () => boolean\n\n // Lifecycle\n reset: () => void\n\n // API methods\n sendMessage: (message: string, userTraits?: UserProvidedTraits, newTicket?: boolean) => Promise<SendMessageResponse>\n getMessages: (ticketId?: string, after?: string) => Promise<GetMessagesResponse>\n markAsRead: (ticketId?: string) => Promise<MarkAsReadResponse>\n getTickets: (options?: GetTicketsOptions) => Promise<GetTicketsResponse>\n getCurrentTicketId: () => string | null\n getWidgetSessionId: () => string\n}\n\ninterface PostHogExtensions {\n loadExternalDependency?: (\n posthog: PostHog,\n kind: PostHogExtensionKind,\n callback: (error?: string | Event, event?: Event) => void\n ) => void\n\n loadSiteApp?: (posthog: PostHog, appUrl: string, callback: (error?: string | Event, event?: Event) => void) => void\n\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapConsoleError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n generateSurveys?: (posthog: PostHog, isSurveysEnabled: boolean) => any | undefined\n generateProductTours?: (posthog: PostHog, isEnabled: boolean) => any | undefined\n postHogWebVitalsCallbacks?: {\n onLCP: (metric: any) => void\n onCLS: (metric: any) => void\n onFCP: (metric: any) => void\n onINP: (metric: any) => void\n }\n tracingHeadersPatchFns?: {\n _patchFetch: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n _patchXHR: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n integrations?: {\n [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void; stop: () => void }\n }\n initSessionRecording?: (ph: PostHog) => LazyLoadedSessionRecordingInterface\n initConversations?: (config: ConversationsRemoteConfig, posthog: PostHog) => LazyLoadedConversationsInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\n\n// React Native polyfills for posthog-js compatibility\nif (typeof self === 'undefined') {\n ;(global as any).self = global\n}\nif (typeof File === 'undefined') {\n ;(global as any).File = function () {}\n}\n\nexport const ArrayProto = Array.prototype\nexport const nativeForEach = ArrayProto.forEach\nexport const nativeIndexOf = ArrayProto.indexOf\n\nexport const navigator = global?.navigator\nexport const document = global?.document\nexport const location = global?.location\nexport const fetch = global?.fetch\nexport const XMLHttpRequest =\n global?.XMLHttpRequest && 'withCredentials' in new global.XMLHttpRequest() ? global.XMLHttpRequest : undefined\nexport const AbortController = global?.AbortController\nexport const userAgent = navigator?.userAgent\nexport const assignableWindow: AssignableWindow = win ?? ({} as any)\n\nexport { win as window }\n","var n,l,u,t,i,o,r,f,e,c={},s=[],a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,h=Array.isArray;function v(n,l){for(var u in l)n[u]=l[u];return n}function p(n){var l=n.parentNode;l&&l.removeChild(n)}function y(l,u,t){var i,o,r,f={};for(r in u)\"key\"==r?i=u[r]:\"ref\"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),\"function\"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return d(l,f,i,o,null)}function d(n,t,i,o,r){var f={type:n,props:t,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++u:r,__i:-1,__u:0};return null==r&&null!=l.vnode&&l.vnode(f),f}function _(){return{current:null}}function g(n){return n.children}function b(n,l){this.props=n,this.context=l}function m(n,l){if(null==l)return n.__?m(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return\"function\"==typeof n.type?m(n):null}function k(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k(n)}}function w(n){(!n.__d&&(n.__d=!0)&&i.push(n)&&!x.__r++||o!==l.debounceRendering)&&((o=l.debounceRendering)||r)(x)}function x(){var n,u,t,o,r,e,c,s,a;for(i.sort(f);n=i.shift();)n.__d&&(u=i.length,o=void 0,e=(r=(t=n).__v).__e,s=[],a=[],(c=t.__P)&&((o=v({},r)).__v=r.__v+1,l.vnode&&l.vnode(o),L(c,o,r,t.__n,void 0!==c.ownerSVGElement,32&r.__u?[e]:null,s,null==e?m(r):e,!!(32&r.__u),a),o.__.__k[o.__i]=o,M(s,o,a),o.__e!=e&&k(o)),i.length>u&&i.sort(f));x.__r=0}function C(n,l,u,t,i,o,r,f,e,a,h){var v,p,y,d,_,g=t&&t.__k||s,b=l.length;for(u.__d=e,P(u,l,g),e=u.__d,v=0;v<b;v++)null!=(y=u.__k[v])&&\"boolean\"!=typeof y&&\"function\"!=typeof y&&(p=-1===y.__i?c:g[y.__i]||c,y.__i=v,L(n,y,p,i,o,r,f,e,a,h),d=y.__e,y.ref&&p.ref!=y.ref&&(p.ref&&z(p.ref,null,y),h.push(y.ref,y.__c||d,y)),null==_&&null!=d&&(_=d),65536&y.__u||p.__k===y.__k?e=S(y,e,n):\"function\"==typeof y.type&&void 0!==y.__d?e=y.__d:d&&(e=d.nextSibling),y.__d=void 0,y.__u&=-196609);u.__d=e,u.__e=_}function P(n,l,u){var t,i,o,r,f,e=l.length,c=u.length,s=c,a=0;for(n.__k=[],t=0;t<e;t++)null!=(i=n.__k[t]=null==(i=l[t])||\"boolean\"==typeof i||\"function\"==typeof i?null:\"string\"==typeof i||\"number\"==typeof i||\"bigint\"==typeof i||i.constructor==String?d(null,i,null,null,i):h(i)?d(g,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?d(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=n,i.__b=n.__b+1,f=H(i,u,r=t+a,s),i.__i=f,o=null,-1!==f&&(s--,(o=u[f])&&(o.__u|=131072)),null==o||null===o.__v?(-1==f&&a--,\"function\"!=typeof i.type&&(i.__u|=65536)):f!==r&&(f===r+1?a++:f>r?s>e-r?a+=f-r:a--:a=f<r&&f==r-1?f-r:0,f!==t+a&&(i.__u|=65536))):(o=u[t])&&null==o.key&&o.__e&&(o.__e==n.__d&&(n.__d=m(o)),N(o,o,!1),u[t]=null,s--);if(s)for(t=0;t<c;t++)null!=(o=u[t])&&0==(131072&o.__u)&&(o.__e==n.__d&&(n.__d=m(o)),N(o,o))}function S(n,l,u){var t,i;if(\"function\"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=S(t[i],l,u));return l}return n.__e!=l&&(u.insertBefore(n.__e,l||null),l=n.__e),l&&l.nextSibling}function $(n,l){return l=l||[],null==n||\"boolean\"==typeof n||(h(n)?n.some(function(n){$(n,l)}):l.push(n)),l}function H(n,l,u,t){var i=n.key,o=n.type,r=u-1,f=u+1,e=l[u];if(null===e||e&&i==e.key&&o===e.type)return u;if(t>(null!=e&&0==(131072&e.__u)?1:0))for(;r>=0||f<l.length;){if(r>=0){if((e=l[r])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return r;r--}if(f<l.length){if((e=l[f])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return f;f++}}return-1}function I(n,l,u){\"-\"===l[0]?n.setProperty(l,null==u?\"\":u):n[l]=null==u?\"\":\"number\"!=typeof u||a.test(l)?u:u+\"px\"}function T(n,l,u,t,i){var o;n:if(\"style\"===l)if(\"string\"==typeof u)n.style.cssText=u;else{if(\"string\"==typeof t&&(n.style.cssText=t=\"\"),t)for(l in t)u&&l in u||I(n.style,l,\"\");if(u)for(l in u)t&&u[l]===t[l]||I(n.style,l,u[l])}else if(\"o\"===l[0]&&\"n\"===l[1])o=l!==(l=l.replace(/(PointerCapture)$|Capture$/,\"$1\")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?t?u.u=t.u:(u.u=Date.now(),n.addEventListener(l,o?D:A,o)):n.removeEventListener(l,o?D:A,o);else{if(i)l=l.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(\"width\"!==l&&\"height\"!==l&&\"href\"!==l&&\"list\"!==l&&\"form\"!==l&&\"tabIndex\"!==l&&\"download\"!==l&&\"rowSpan\"!==l&&\"colSpan\"!==l&&\"role\"!==l&&l in n)try{n[l]=null==u?\"\":u;break n}catch(n){}\"function\"==typeof u||(null==u||!1===u&&\"-\"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u))}}function A(n){var u=this.l[n.type+!1];if(n.t){if(n.t<=u.u)return}else n.t=Date.now();return u(l.event?l.event(n):n)}function D(n){return this.l[n.type+!0](l.event?l.event(n):n)}function L(n,u,t,i,o,r,f,e,c,s){var a,p,y,d,_,m,k,w,x,P,S,$,H,I,T,A=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),r=[e=u.__e=t.__e]),(a=l.__b)&&a(u);n:if(\"function\"==typeof A)try{if(w=u.props,x=(a=A.contextType)&&i[a.__c],P=a?x?x.props.value:a.__:i,t.__c?k=(p=u.__c=t.__c).__=p.__E:(\"prototype\"in A&&A.prototype.render?u.__c=p=new A(w,P):(u.__c=p=new b(w,P),p.constructor=A,p.render=O),x&&x.sub(p),p.props=w,p.state||(p.state={}),p.context=P,p.__n=i,y=p.__d=!0,p.__h=[],p._sb=[]),null==p.__s&&(p.__s=p.state),null!=A.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=v({},p.__s)),v(p.__s,A.getDerivedStateFromProps(w,p.__s))),d=p.props,_=p.state,p.__v=u,y)null==A.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==A.getDerivedStateFromProps&&w!==d&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(w,P),!p.__e&&(null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(w,p.__s,P)||u.__v===t.__v)){for(u.__v!==t.__v&&(p.props=w,p.state=p.__s,p.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.forEach(function(n){n&&(n.__=u)}),S=0;S<p._sb.length;S++)p.__h.push(p._sb[S]);p._sb=[],p.__h.length&&f.push(p);break n}null!=p.componentWillUpdate&&p.componentWillUpdate(w,p.__s,P),null!=p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(d,_,m)})}if(p.context=P,p.props=w,p.__P=n,p.__e=!1,$=l.__r,H=0,\"prototype\"in A&&A.prototype.render){for(p.state=p.__s,p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),I=0;I<p._sb.length;I++)p.__h.push(p._sb[I]);p._sb=[]}else do{p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++H<25);p.state=p.__s,null!=p.getChildContext&&(i=v(v({},i),p.getChildContext())),y||null==p.getSnapshotBeforeUpdate||(m=p.getSnapshotBeforeUpdate(d,_)),C(n,h(T=null!=a&&a.type===g&&null==a.key?a.props.children:a)?T:[T],u,t,i,o,r,f,e,c,s),p.base=u.__e,u.__u&=-161,p.__h.length&&f.push(p),k&&(p.__E=p.__=null)}catch(n){u.__v=null,c||null!=r?(u.__e=e,u.__u|=c?160:32,r[r.indexOf(e)]=null):(u.__e=t.__e,u.__k=t.__k),l.__e(n,u,t)}else null==r&&u.__v===t.__v?(u.__k=t.__k,u.__e=t.__e):u.__e=j(t.__e,u,t,i,o,r,f,c,s);(a=l.diffed)&&a(u)}function M(n,u,t){u.__d=void 0;for(var i=0;i<t.length;i++)z(t[i],t[++i],t[++i]);l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){l.__e(n,u.__v)}})}function j(l,u,t,i,o,r,f,e,s){var a,v,y,d,_,g,b,k=t.props,w=u.props,x=u.type;if(\"svg\"===x&&(o=!0),null!=r)for(a=0;a<r.length;a++)if((_=r[a])&&\"setAttribute\"in _==!!x&&(x?_.localName===x:3===_.nodeType)){l=_,r[a]=null;break}if(null==l){if(null===x)return document.createTextNode(w);l=o?document.createElementNS(\"http://www.w3.org/2000/svg\",x):document.createElement(x,w.is&&w),r=null,e=!1}if(null===x)k===w||e&&l.data===w||(l.data=w);else{if(r=r&&n.call(l.childNodes),k=t.props||c,!e&&null!=r)for(k={},a=0;a<l.attributes.length;a++)k[(_=l.attributes[a]).name]=_.value;for(a in k)_=k[a],\"children\"==a||(\"dangerouslySetInnerHTML\"==a?y=_:\"key\"===a||a in w||T(l,a,null,_,o));for(a in w)_=w[a],\"children\"==a?d=_:\"dangerouslySetInnerHTML\"==a?v=_:\"value\"==a?g=_:\"checked\"==a?b=_:\"key\"===a||e&&\"function\"!=typeof _||k[a]===_||T(l,a,_,k[a],o);if(v)e||y&&(v.__html===y.__html||v.__html===l.innerHTML)||(l.innerHTML=v.__html),u.__k=[];else if(y&&(l.innerHTML=\"\"),C(l,h(d)?d:[d],u,t,i,o&&\"foreignObject\"!==x,r,f,r?r[0]:t.__k&&m(t,0),e,s),null!=r)for(a=r.length;a--;)null!=r[a]&&p(r[a]);e||(a=\"value\",void 0!==g&&(g!==l[a]||\"progress\"===x&&!g||\"option\"===x&&g!==k[a])&&T(l,a,g,k[a],!1),a=\"checked\",void 0!==b&&b!==l[a]&&T(l,a,b,k[a],!1))}return l}function z(n,u,t){try{\"function\"==typeof n?n(u):n.current=u}catch(n){l.__e(n,t)}}function N(n,u,t){var i,o;if(l.unmount&&l.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||z(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){l.__e(n,u)}i.base=i.__P=null,n.__c=void 0}if(i=n.__k)for(o=0;o<i.length;o++)i[o]&&N(i[o],u,t||\"function\"!=typeof n.type);t||null==n.__e||p(n.__e),n.__=n.__e=n.__d=void 0}function O(n,l,u){return this.constructor(n,u)}function q(u,t,i){var o,r,f,e;l.__&&l.__(u,t),r=(o=\"function\"==typeof i)?null:i&&i.__k||t.__k,f=[],e=[],L(t,u=(!o&&i||t).__k=y(g,null,[u]),r||c,c,void 0!==t.ownerSVGElement,!o&&i?[i]:r?null:t.firstChild?n.call(t.childNodes):null,f,!o&&i?i:r?r.__e:t.firstChild,o,e),M(f,u,e)}function B(n,l){q(n,l,B)}function E(l,u,t){var i,o,r,f,e=v({},l.props);for(r in l.type&&l.type.defaultProps&&(f=l.type.defaultProps),u)\"key\"==r?i=u[r]:\"ref\"==r?o=u[r]:e[r]=void 0===u[r]&&void 0!==f?f[r]:u[r];return arguments.length>2&&(e.children=arguments.length>3?n.call(arguments,2):t),d(l.type,e,i||l.key,o||l.ref,null)}function F(n,l){var u={__c:l=\"__cC\"+e++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=[],(t={})[l]=this,this.getChildContext=function(){return t},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(function(n){n.__e=!0,w(n)})},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=s.slice,l={__e:function(n,l,u,t){for(var i,o,r;l=l.__;)if((i=l.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(n)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),r=i.__d),r)return i.__E=i}catch(l){n=l}throw n}},u=0,t=function(n){return null!=n&&null==n.constructor},b.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=v({},this.state),\"function\"==typeof n&&(n=n(v({},u),this.props)),n&&v(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),w(this))},b.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),w(this))},b.prototype.render=g,i=[],r=\"function\"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f=function(n,l){return n.__v.__b-l.__v.__b},x.__r=0,e=0;export{b as Component,g as Fragment,E as cloneElement,F as createContext,y as createElement,_ as createRef,y as h,B as hydrate,t as isValidElement,l as options,q as render,$ as toChildArray};\n//# sourceMappingURL=preact.module.js.map\n","/**\n * Having Survey types in types.ts was confusing tsc\n * and generating an invalid module.d.ts\n * See https://github.com/PostHog/posthog-js/issues/698\n */\n\nimport type { PropertyMatchType } from './types'\nimport type { SurveyAppearance as CoreSurveyAppearance } from '@posthog/core'\n\nexport enum SurveyEventType {\n Activation = 'events',\n Cancellation = 'cancelEvents',\n}\n\n// Extended operator type to include numeric operators not in PropertyMatchType\nexport type PropertyOperator = PropertyMatchType | 'gt' | 'lt'\n\nexport type PropertyFilters = {\n [propertyName: string]: {\n values: string[]\n operator: PropertyOperator\n }\n}\n\nexport interface SurveyEventWithFilters {\n name: string\n propertyFilters?: PropertyFilters\n}\n\nexport enum SurveyWidgetType {\n Button = 'button',\n Tab = 'tab',\n Selector = 'selector',\n}\n\nexport enum SurveyPosition {\n TopLeft = 'top_left',\n TopRight = 'top_right',\n TopCenter = 'top_center',\n MiddleLeft = 'middle_left',\n MiddleRight = 'middle_right',\n MiddleCenter = 'middle_center',\n Left = 'left',\n Center = 'center',\n Right = 'right',\n NextToTrigger = 'next_to_trigger',\n}\n\nexport enum SurveyTabPosition {\n Top = 'top',\n Left = 'left',\n Right = 'right',\n Bottom = 'bottom',\n}\n\n// Extends core SurveyAppearance with browser-specific fields\n// Omit 'position' from core because browser's SurveyPosition has additional values (e.g., NextToTrigger)\nexport interface SurveyAppearance extends Omit<CoreSurveyAppearance, 'position'> {\n // Browser-specific fields not in core\n /** @deprecated - not currently used */\n descriptionTextColor?: string\n ratingButtonHoverColor?: string\n whiteLabel?: boolean\n tabPosition?: SurveyTabPosition\n fontFamily?: string\n maxWidth?: string\n zIndex?: string\n disabledButtonOpacity?: string\n boxPadding?: string\n /** @deprecated Use inputBackground instead (inherited from core) */\n inputBackgroundColor?: string\n // Hide the X (cancel) button - defaults to false (show the button)\n hideCancelButton?: boolean\n // Browser's SurveyPosition has more options than core (e.g., NextToTrigger)\n position?: SurveyPosition\n}\n\nexport enum SurveyType {\n Popover = 'popover',\n API = 'api',\n Widget = 'widget',\n ExternalSurvey = 'external_survey',\n}\n\nexport type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion\n\nexport type SurveyQuestionDescriptionContentType = 'html' | 'text'\n\ninterface SurveyQuestionBase {\n question: string\n id?: string\n description?: string | null\n descriptionContentType?: SurveyQuestionDescriptionContentType\n optional?: boolean\n buttonText?: string\n branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching\n}\n\nexport interface BasicSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Open\n}\n\nexport interface LinkSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Link\n link?: string | null\n}\n\nexport interface RatingSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Rating\n display: 'number' | 'emoji'\n scale: 3 | 5 | 7 | 10\n lowerBoundLabel: string\n upperBoundLabel: string\n skipSubmitButton?: boolean\n}\n\nexport interface MultipleSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice\n choices: string[]\n hasOpenChoice?: boolean\n shuffleOptions?: boolean\n skipSubmitButton?: boolean\n}\n\nexport enum SurveyQuestionType {\n Open = 'open',\n MultipleChoice = 'multiple_choice',\n SingleChoice = 'single_choice',\n Rating = 'rating',\n Link = 'link',\n}\n\nexport enum SurveyQuestionBranchingType {\n NextQuestion = 'next_question',\n End = 'end',\n ResponseBased = 'response_based',\n SpecificQuestion = 'specific_question',\n}\n\ninterface NextQuestionBranching {\n type: SurveyQuestionBranchingType.NextQuestion\n}\n\ninterface EndBranching {\n type: SurveyQuestionBranchingType.End\n}\n\ninterface ResponseBasedBranching {\n type: SurveyQuestionBranchingType.ResponseBased\n responseValues: Record<string, any>\n}\n\ninterface SpecificQuestionBranching {\n type: SurveyQuestionBranchingType.SpecificQuestion\n index: number\n}\n\nexport type SurveyCallback = (surveys: Survey[], context?: { isLoaded: boolean; error?: string }) => void\n\nexport interface SurveyElement {\n text?: string\n $el_text?: string\n tag_name?: string\n href?: string\n attr_id?: string\n attr_class?: string[]\n nth_child?: number\n nth_of_type?: number\n attributes?: Record<string, any>\n event_id?: number\n order?: number\n group_id?: number\n}\nexport interface SurveyRenderReason {\n visible: boolean\n disabledReason?: string\n}\n\nexport enum SurveySchedule {\n Once = 'once',\n Recurring = 'recurring',\n Always = 'always',\n}\n\nexport interface Survey {\n // Sync this with the backend's SurveyAPISerializer!\n id: string\n name: string\n description: string\n type: SurveyType\n feature_flag_keys:\n | {\n key: string\n value?: string\n }[]\n | null\n // the linked flag key is the flag key that is used to link the survey to a flag\n linked_flag_key: string | null\n targeting_flag_key: string | null\n // the internal targeting flag key is the flag key that is used to target users who have seen the survey\n // eg survey-targeting-<survey-id>\n internal_targeting_flag_key: string | null\n questions: SurveyQuestion[]\n appearance: SurveyAppearance | null\n conditions: {\n url?: string\n selector?: string\n seenSurveyWaitPeriodInDays?: number\n urlMatchType?: PropertyMatchType\n /** events that trigger surveys */\n events: {\n repeatedActivation?: boolean\n values: SurveyEventWithFilters[]\n } | null\n /** events that cancel \"pending\" (time-delayed) surveys */\n cancelEvents: {\n values: SurveyEventWithFilters[]\n } | null\n actions: {\n values: SurveyActionType[]\n } | null\n deviceTypes?: string[]\n deviceTypesMatchType?: PropertyMatchType\n linkedFlagVariant?: string\n } | null\n start_date: string | null\n end_date: string | null\n current_iteration: number | null\n current_iteration_start_date: string | null\n schedule?: SurveySchedule | null\n enable_partial_responses?: boolean | null\n}\n\nexport type SurveyWithTypeAndAppearance = Pick<Survey, 'id' | 'type' | 'appearance'>\n\nexport interface SurveyActionType {\n id: number\n name: string | null\n steps?: ActionStepType[]\n}\n\n/** Sync with plugin-server/src/types.ts */\nexport type ActionStepStringMatching = 'contains' | 'exact' | 'regex'\n\nexport interface ActionStepType {\n event?: string | null\n selector?: string | null\n /** pre-compiled regex pattern for matching selector against $elements_chain */\n selector_regex?: string | null\n /** @deprecated Only `selector` should be used now. */\n tag_name?: string\n text?: string | null\n /** @default StringMatching.Exact */\n text_matching?: ActionStepStringMatching | null\n href?: string | null\n /** @default ActionStepStringMatching.Exact */\n href_matching?: ActionStepStringMatching | null\n url?: string | null\n /** @default StringMatching.Contains */\n url_matching?: ActionStepStringMatching | null\n /** Property filters for action step matching */\n properties?: {\n key: string\n value?: string | number | boolean | (string | number | boolean)[] | null\n operator?: PropertyMatchType\n type?: string\n }[]\n}\n\nexport enum SurveyEventName {\n SHOWN = 'survey shown',\n DISMISSED = 'survey dismissed',\n SENT = 'survey sent',\n ABANDONED = 'survey abandoned',\n}\n\nexport enum SurveyEventProperties {\n SURVEY_ID = '$survey_id',\n SURVEY_NAME = '$survey_name',\n SURVEY_RESPONSE = '$survey_response',\n SURVEY_ITERATION = '$survey_iteration',\n SURVEY_ITERATION_START_DATE = '$survey_iteration_start_date',\n SURVEY_PARTIALLY_COMPLETED = '$survey_partially_completed',\n SURVEY_SUBMISSION_ID = '$survey_submission_id',\n SURVEY_QUESTIONS = '$survey_questions',\n SURVEY_COMPLETED = '$survey_completed',\n PRODUCT_TOUR_ID = '$product_tour_id',\n SURVEY_LAST_SEEN_DATE = '$survey_last_seen_date',\n}\n\nexport enum DisplaySurveyType {\n Popover = 'popover',\n Inline = 'inline',\n}\n\ninterface DisplaySurveyOptionsBase {\n ignoreConditions: boolean\n ignoreDelay: boolean\n displayType: DisplaySurveyType\n}\n\ninterface DisplaySurveyPopoverOptions extends DisplaySurveyOptionsBase {\n displayType: DisplaySurveyType.Popover\n}\n\ninterface DisplaySurveyInlineOptions extends DisplaySurveyOptionsBase {\n displayType: DisplaySurveyType.Inline\n selector: string\n}\n\nexport type DisplaySurveyOptions = DisplaySurveyPopoverOptions | DisplaySurveyInlineOptions\n\nexport interface SurveyConfig {\n prefillFromUrl?: boolean\n /**\n * @deprecated No longer used. Surveys will automatically advance past\n * prefilled questions with skipSubmitButton enabled. If partial response\n * collection is enabled, partial responses for pre-filled questions will\n * be submitted automatically on page load.\n */\n autoSubmitIfComplete?: boolean\n /**\n * @deprecated No longer used. Pre-filled responses are now sent\n * immediately when partial responses are enabled, or all required\n * quesions have been pre-filled.\n */\n autoSubmitDelay?: number\n}\n","import { PropertyMatchType } from './types'\nimport { SurveyActionType, SurveyEventWithFilters } from './posthog-surveys-types'\n\nexport interface JSONContent {\n type?: string\n attrs?: Record<string, any>\n content?: JSONContent[]\n marks?: { type: string; attrs?: Record<string, any> }[]\n text?: string\n}\n\nexport type ProductTourStepType = 'element' | 'modal' | 'survey'\n\nexport type ProductTourSurveyQuestionType = 'open' | 'rating'\n\nexport interface ProductTourSurveyQuestion {\n type: ProductTourSurveyQuestionType\n questionText: string\n /** Rating display type - emoji or number */\n display?: 'emoji' | 'number'\n /** Rating scale - 3 or 5 for emoji, 5 or 10 for number */\n scale?: 3 | 5 | 10\n /** Label for low end of rating scale (e.g., \"Not likely\") */\n lowerBoundLabel?: string\n /** Label for high end of rating scale (e.g., \"Very likely\") */\n upperBoundLabel?: string\n}\n\nexport interface ProductTourStep {\n id: string\n type: ProductTourStepType\n selector?: string\n progressionTrigger: 'button' | 'click'\n content: JSONContent | null\n /** Inline survey question config - if present, this is a survey step */\n survey?: ProductTourSurveyQuestion\n /** ID of the auto-created survey for this step (set by backend) */\n linkedSurveyId?: string\n /** ID of the survey question (set by backend, used for event tracking) */\n linkedSurveyQuestionId?: string\n}\n\nexport interface ProductTourConditions {\n url?: string\n urlMatchType?: PropertyMatchType\n selector?: string\n autoShowDelaySeconds?: number\n events?: {\n values: SurveyEventWithFilters[]\n } | null\n cancelEvents?: {\n values: SurveyEventWithFilters[]\n } | null\n actions?: {\n values: SurveyActionType[]\n } | null\n}\n\nexport interface ProductTourAppearance {\n backgroundColor?: string\n textColor?: string\n buttonColor?: string\n borderRadius?: number\n buttonBorderRadius?: number\n borderColor?: string\n fontFamily?: string\n boxShadow?: string\n showOverlay?: boolean\n whiteLabel?: boolean\n}\n\nexport interface ProductTour {\n id: string\n name: string\n description?: string\n type: 'product_tour'\n auto_launch?: boolean\n start_date: string | null\n end_date: string | null\n current_iteration?: number\n conditions?: ProductTourConditions\n appearance?: ProductTourAppearance\n steps: ProductTourStep[]\n internal_targeting_flag_key?: string\n linked_flag_key?: string\n}\n\nexport type ProductTourCallback = (tours: ProductTour[], context?: { isLoaded: boolean; error?: string }) => void\n\nexport type ProductTourSelectorError = 'not_found' | 'multiple_matches' | 'not_visible'\n\nexport type ProductTourDismissReason =\n | 'user_clicked_skip'\n | 'user_clicked_outside'\n | 'escape_key'\n | 'element_unavailable'\n\nexport type ProductTourRenderReason = 'auto' | 'api' | 'trigger' | 'event'\n\nexport const DEFAULT_PRODUCT_TOUR_APPEARANCE: Required<ProductTourAppearance> = {\n backgroundColor: '#ffffff',\n textColor: '#1d1f27',\n buttonColor: '#1d1f27',\n borderRadius: 8,\n buttonBorderRadius: 6,\n borderColor: '#e5e7eb',\n fontFamily: 'system-ui',\n boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',\n showOverlay: true,\n whiteLabel: false,\n}\n\nexport interface ShowTourOptions {\n reason?: ProductTourRenderReason\n enableStrictValidation?: boolean\n}\n","var types_PostHogPersistedProperty = /*#__PURE__*/ function(PostHogPersistedProperty) {\n PostHogPersistedProperty[\"AnonymousId\"] = \"anonymous_id\";\n PostHogPersistedProperty[\"DistinctId\"] = \"distinct_id\";\n PostHogPersistedProperty[\"Props\"] = \"props\";\n PostHogPersistedProperty[\"FeatureFlagDetails\"] = \"feature_flag_details\";\n PostHogPersistedProperty[\"FeatureFlags\"] = \"feature_flags\";\n PostHogPersistedProperty[\"FeatureFlagPayloads\"] = \"feature_flag_payloads\";\n PostHogPersistedProperty[\"BootstrapFeatureFlagDetails\"] = \"bootstrap_feature_flag_details\";\n PostHogPersistedProperty[\"BootstrapFeatureFlags\"] = \"bootstrap_feature_flags\";\n PostHogPersistedProperty[\"BootstrapFeatureFlagPayloads\"] = \"bootstrap_feature_flag_payloads\";\n PostHogPersistedProperty[\"OverrideFeatureFlags\"] = \"override_feature_flags\";\n PostHogPersistedProperty[\"Queue\"] = \"queue\";\n PostHogPersistedProperty[\"OptedOut\"] = \"opted_out\";\n PostHogPersistedProperty[\"SessionId\"] = \"session_id\";\n PostHogPersistedProperty[\"SessionStartTimestamp\"] = \"session_start_timestamp\";\n PostHogPersistedProperty[\"SessionLastTimestamp\"] = \"session_timestamp\";\n PostHogPersistedProperty[\"PersonProperties\"] = \"person_properties\";\n PostHogPersistedProperty[\"GroupProperties\"] = \"group_properties\";\n PostHogPersistedProperty[\"InstalledAppBuild\"] = \"installed_app_build\";\n PostHogPersistedProperty[\"InstalledAppVersion\"] = \"installed_app_version\";\n PostHogPersistedProperty[\"SessionReplay\"] = \"session_replay\";\n PostHogPersistedProperty[\"SurveyLastSeenDate\"] = \"survey_last_seen_date\";\n PostHogPersistedProperty[\"SurveysSeen\"] = \"surveys_seen\";\n PostHogPersistedProperty[\"Surveys\"] = \"surveys\";\n PostHogPersistedProperty[\"RemoteConfig\"] = \"remote_config\";\n PostHogPersistedProperty[\"FlagsEndpointWasHit\"] = \"flags_endpoint_was_hit\";\n return PostHogPersistedProperty;\n}({});\nvar types_Compression = /*#__PURE__*/ function(Compression) {\n Compression[\"GZipJS\"] = \"gzip-js\";\n Compression[\"Base64\"] = \"base64\";\n return Compression;\n}({});\nvar types_SurveyPosition = /*#__PURE__*/ function(SurveyPosition) {\n SurveyPosition[\"TopLeft\"] = \"top_left\";\n SurveyPosition[\"TopCenter\"] = \"top_center\";\n SurveyPosition[\"TopRight\"] = \"top_right\";\n SurveyPosition[\"MiddleLeft\"] = \"middle_left\";\n SurveyPosition[\"MiddleCenter\"] = \"middle_center\";\n SurveyPosition[\"MiddleRight\"] = \"middle_right\";\n SurveyPosition[\"Left\"] = \"left\";\n SurveyPosition[\"Right\"] = \"right\";\n SurveyPosition[\"Center\"] = \"center\";\n return SurveyPosition;\n}({});\nvar types_SurveyWidgetType = /*#__PURE__*/ function(SurveyWidgetType) {\n SurveyWidgetType[\"Button\"] = \"button\";\n SurveyWidgetType[\"Tab\"] = \"tab\";\n SurveyWidgetType[\"Selector\"] = \"selector\";\n return SurveyWidgetType;\n}({});\nvar types_SurveyType = /*#__PURE__*/ function(SurveyType) {\n SurveyType[\"Popover\"] = \"popover\";\n SurveyType[\"API\"] = \"api\";\n SurveyType[\"Widget\"] = \"widget\";\n SurveyType[\"ExternalSurvey\"] = \"external_survey\";\n return SurveyType;\n}({});\nvar types_SurveyQuestionDescriptionContentType = /*#__PURE__*/ function(SurveyQuestionDescriptionContentType) {\n SurveyQuestionDescriptionContentType[\"Html\"] = \"html\";\n SurveyQuestionDescriptionContentType[\"Text\"] = \"text\";\n return SurveyQuestionDescriptionContentType;\n}({});\nvar types_SurveyRatingDisplay = /*#__PURE__*/ function(SurveyRatingDisplay) {\n SurveyRatingDisplay[\"Number\"] = \"number\";\n SurveyRatingDisplay[\"Emoji\"] = \"emoji\";\n return SurveyRatingDisplay;\n}({});\nvar types_SurveyQuestionType = /*#__PURE__*/ function(SurveyQuestionType) {\n SurveyQuestionType[\"Open\"] = \"open\";\n SurveyQuestionType[\"MultipleChoice\"] = \"multiple_choice\";\n SurveyQuestionType[\"SingleChoice\"] = \"single_choice\";\n SurveyQuestionType[\"Rating\"] = \"rating\";\n SurveyQuestionType[\"Link\"] = \"link\";\n return SurveyQuestionType;\n}({});\nvar types_SurveyQuestionBranchingType = /*#__PURE__*/ function(SurveyQuestionBranchingType) {\n SurveyQuestionBranchingType[\"NextQuestion\"] = \"next_question\";\n SurveyQuestionBranchingType[\"End\"] = \"end\";\n SurveyQuestionBranchingType[\"ResponseBased\"] = \"response_based\";\n SurveyQuestionBranchingType[\"SpecificQuestion\"] = \"specific_question\";\n return SurveyQuestionBranchingType;\n}({});\nvar types_SurveyMatchType = /*#__PURE__*/ function(SurveyMatchType) {\n SurveyMatchType[\"Regex\"] = \"regex\";\n SurveyMatchType[\"NotRegex\"] = \"not_regex\";\n SurveyMatchType[\"Exact\"] = \"exact\";\n SurveyMatchType[\"IsNot\"] = \"is_not\";\n SurveyMatchType[\"Icontains\"] = \"icontains\";\n SurveyMatchType[\"NotIcontains\"] = \"not_icontains\";\n return SurveyMatchType;\n}({});\nvar types_ActionStepStringMatching = /*#__PURE__*/ function(ActionStepStringMatching) {\n ActionStepStringMatching[\"Contains\"] = \"contains\";\n ActionStepStringMatching[\"Exact\"] = \"exact\";\n ActionStepStringMatching[\"Regex\"] = \"regex\";\n return ActionStepStringMatching;\n}({});\nconst knownUnsafeEditableEvent = [\n '$snapshot',\n '$pageview',\n '$pageleave',\n '$set',\n 'survey dismissed',\n 'survey sent',\n 'survey shown',\n '$identify',\n '$groupidentify',\n '$create_alias',\n '$$client_ingestion_warning',\n '$web_experiment_applied',\n '$feature_enrollment_update',\n '$feature_flag_called'\n];\nexport { types_ActionStepStringMatching as ActionStepStringMatching, types_Compression as Compression, types_PostHogPersistedProperty as PostHogPersistedProperty, types_SurveyMatchType as SurveyMatchType, types_SurveyPosition as SurveyPosition, types_SurveyQuestionBranchingType as SurveyQuestionBranchingType, types_SurveyQuestionDescriptionContentType as SurveyQuestionDescriptionContentType, types_SurveyQuestionType as SurveyQuestionType, types_SurveyRatingDisplay as SurveyRatingDisplay, types_SurveyType as SurveyType, types_SurveyWidgetType as SurveyWidgetType, knownUnsafeEditableEvent };\n","import { knownUnsafeEditableEvent } from \"../types.mjs\";\nimport { includes } from \"./string-utils.mjs\";\nconst nativeIsArray = Array.isArray;\nconst ObjProto = Object.prototype;\nconst type_utils_hasOwnProperty = ObjProto.hasOwnProperty;\nconst type_utils_toString = ObjProto.toString;\nconst isArray = nativeIsArray || function(obj) {\n return '[object Array]' === type_utils_toString.call(obj);\n};\nconst isFunction = (x)=>'function' == typeof x;\nconst isNativeFunction = (x)=>isFunction(x) && -1 !== x.toString().indexOf('[native code]');\nconst isObject = (x)=>x === Object(x) && !isArray(x);\nconst isEmptyObject = (x)=>{\n if (isObject(x)) {\n for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;\n return true;\n }\n return false;\n};\nconst isUndefined = (x)=>void 0 === x;\nconst isString = (x)=>'[object String]' == type_utils_toString.call(x);\nconst isEmptyString = (x)=>isString(x) && 0 === x.trim().length;\nconst isNull = (x)=>null === x;\nconst isNullish = (x)=>isUndefined(x) || isNull(x);\nconst isNumber = (x)=>'[object Number]' == type_utils_toString.call(x);\nconst isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);\nconst isFormData = (x)=>x instanceof FormData;\nconst isFile = (x)=>x instanceof File;\nconst isPlainError = (x)=>x instanceof Error;\nconst isKnownUnsafeEditableEvent = (x)=>includes(knownUnsafeEditableEvent, x);\nfunction isPrimitive(value) {\n return null === value || 'object' != typeof value;\n}\nfunction isBuiltin(candidate, className) {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`;\n}\nfunction isError(candidate) {\n switch(Object.prototype.toString.call(candidate)){\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n case '[object DOMError]':\n case '[object WebAssembly.Exception]':\n return true;\n default:\n return isInstanceOf(candidate, Error);\n }\n}\nfunction isErrorEvent(event) {\n return isBuiltin(event, 'ErrorEvent');\n}\nfunction isEvent(candidate) {\n return !isUndefined(Event) && isInstanceOf(candidate, Event);\n}\nfunction isPlainObject(candidate) {\n return isBuiltin(candidate, 'Object');\n}\nfunction isInstanceOf(candidate, base) {\n try {\n return candidate instanceof base;\n } catch {\n return false;\n }\n}\nconst yesLikeValues = [\n true,\n 'true',\n 1,\n '1',\n 'yes'\n];\nconst isYesLike = (val)=>includes(yesLikeValues, val);\nconst noLikeValues = [\n false,\n 'false',\n 0,\n '0',\n 'no'\n];\nconst isNoLike = (val)=>includes(noLikeValues, val);\nexport { type_utils_hasOwnProperty as hasOwnProperty, isArray, isBoolean, isBuiltin, isEmptyObject, isEmptyString, isError, isErrorEvent, isEvent, isFile, isFormData, isFunction, isKnownUnsafeEditableEvent, isNativeFunction, isNoLike, isNull, isNullish, isNumber, isObject, isPlainError, isPlainObject, isPrimitive, isString, isUndefined, isYesLike, noLikeValues, yesLikeValues };\n","import Config from '../config'\nimport { isUndefined } from '@posthog/core'\nimport { assignableWindow, window } from './globals'\nimport type { Logger } from '@posthog/core'\n\ntype CreateLoggerOptions = {\n debugEnabled?: boolean\n}\n\ntype PosthogJsLogger = Omit<Logger, 'createLogger'> & {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => void\n uninitializedWarning: (methodName: string) => void\n createLogger: (prefix: string, options?: CreateLoggerOptions) => PosthogJsLogger\n}\n\nconst _createLogger = (prefix: string, { debugEnabled }: CreateLoggerOptions = {}): PosthogJsLogger => {\n const logger: PosthogJsLogger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG || debugEnabled) &&\n !isUndefined(window.console) &&\n window.console\n ) {\n const consoleLog =\n '__rrweb_original__' in window.console[level]\n ? (window.console[level] as any)['__rrweb_original__']\n : window.console[level]\n\n // eslint-disable-next-line no-console\n consoleLog(prefix, ...args)\n }\n },\n\n info: (...args: any[]) => {\n logger._log('log', ...args)\n },\n\n warn: (...args: any[]) => {\n logger._log('warn', ...args)\n },\n\n error: (...args: any[]) => {\n logger._log('error', ...args)\n },\n\n critical: (...args: any[]) => {\n // Critical errors are always logged to the console\n // eslint-disable-next-line no-console\n console.error(prefix, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n\n createLogger: (additionalPrefix: string, options?: CreateLoggerOptions) =>\n _createLogger(`${prefix} ${additionalPrefix}`, options),\n }\n return logger\n}\n\nexport const logger = _createLogger('[PostHog.js]')\n\nexport const createLogger = logger.createLogger\n","import { PostHog } from '../../posthog-core'\nimport { createLogger } from '../../utils/logger'\n\nconst logger = createLogger('[Stylesheet Loader]')\n\nexport const prepareStylesheet = (document: Document, innerText: string, posthog?: PostHog) => {\n // Forcing the existence of `document` requires this function to be called in a browser environment\n let stylesheet: HTMLStyleElement | null = document.createElement('style')\n stylesheet.innerText = innerText\n\n if (posthog?.config?.prepare_external_dependency_stylesheet) {\n stylesheet = posthog.config.prepare_external_dependency_stylesheet(stylesheet)\n }\n\n if (!stylesheet) {\n logger.error('prepare_external_dependency_stylesheet returned null')\n return null\n }\n\n return stylesheet\n}\n","import { Breaker, Properties } from '../types'\nimport { nativeForEach, nativeIndexOf } from './globals'\nimport { logger } from './logger'\nimport { isFormData, isNull, isNullish, isNumber, isString, isUndefined, hasOwnProperty, isArray } from '@posthog/core'\n\nconst breaker: Breaker = {}\n\nexport function eachArray<E = any>(\n obj: E[] | null | undefined,\n iterator: (value: E, key: number) => void | Breaker,\n thisArg?: any\n): void {\n if (isArray(obj)) {\n if (nativeForEach && obj.forEach === nativeForEach) {\n obj.forEach(iterator, thisArg)\n } else if ('length' in obj && obj.length === +obj.length) {\n for (let i = 0, l = obj.length; i < l; i++) {\n if (i in obj && iterator.call(thisArg, obj[i], i) === breaker) {\n return\n }\n }\n }\n }\n}\n\n/**\n * @param {*=} obj\n * @param {function(...*)=} iterator\n * @param {Object=} thisArg\n */\nexport function each(obj: any, iterator: (value: any, key: any) => void | Breaker, thisArg?: any): void {\n if (isNullish(obj)) {\n return\n }\n if (isArray(obj)) {\n return eachArray(obj, iterator, thisArg)\n }\n if (isFormData(obj)) {\n for (const pair of obj.entries()) {\n if (iterator.call(thisArg, pair[1], pair[0]) === breaker) {\n return\n }\n }\n return\n }\n for (const key in obj) {\n if (hasOwnProperty.call(obj, key)) {\n if (iterator.call(thisArg, obj[key], key) === breaker) {\n return\n }\n }\n }\n}\n\nexport const extend = function (obj: Record<string, any>, ...args: Record<string, any>[]): Record<string, any> {\n eachArray(args, function (source) {\n for (const prop in source) {\n if (source[prop] !== void 0) {\n obj[prop] = source[prop]\n }\n }\n })\n return obj\n}\n\nexport const extendArray = function <T>(obj: T[], ...args: T[][]): T[] {\n eachArray(args, function (source) {\n eachArray(source, function (item) {\n obj.push(item)\n })\n })\n return obj\n}\n\nexport const include = function (\n obj: null | string | Array<any> | Record<string, any>,\n target: any\n): boolean | Breaker {\n let found = false\n if (isNull(obj)) {\n return found\n }\n if (nativeIndexOf && obj.indexOf === nativeIndexOf) {\n return obj.indexOf(target) != -1\n }\n each(obj, function (value) {\n if (found || (found = value === target)) {\n return breaker\n }\n return\n })\n return found\n}\n\n/**\n * Object.entries() polyfill\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries\n */\nexport function entries<T = any>(obj: Record<string, T>): [string, T][] {\n const ownProps = Object.keys(obj)\n let i = ownProps.length\n const resArray = new Array(i) // preallocate the Array\n\n while (i--) {\n resArray[i] = [ownProps[i], obj[ownProps[i]]]\n }\n return resArray\n}\n\nexport const trySafe = function <T>(fn: () => T): T | undefined {\n try {\n return fn()\n } catch {\n return undefined\n }\n}\n\nexport const safewrap = function <F extends (...args: any[]) => any = (...args: any[]) => any>(f: F): F {\n return function (...args) {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return f.apply(this, args)\n } catch (e) {\n logger.critical(\n 'Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.'\n )\n logger.critical(e)\n }\n } as F\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const safewrapClass = function (klass: Function, functions: string[]): void {\n for (let i = 0; i < functions.length; i++) {\n klass.prototype[functions[i]] = safewrap(klass.prototype[functions[i]])\n }\n}\n\nexport const stripEmptyProperties = function (p: Properties): Properties {\n const ret: Properties = {}\n each(p, function (v, k) {\n if ((isString(v) && v.length > 0) || isNumber(v)) {\n ret[k] = v\n }\n })\n return ret\n}\n\n/**\n * Deep copies an object.\n * It handles cycles by replacing all references to them with `undefined`\n * Also supports customizing native values\n *\n * @param value\n * @param customizer\n * @returns {{}|undefined|*}\n */\nfunction deepCircularCopy<T extends Record<string, any> = Record<string, any>>(\n value: T,\n customizer?: <K extends keyof T = keyof T>(value: T[K], key?: K) => T[K]\n): T | undefined {\n const COPY_IN_PROGRESS_SET = new Set()\n\n function internalDeepCircularCopy(value: T, key?: string): T | undefined {\n if (value !== Object(value)) return customizer ? customizer(value as any, key) : value // primitive value\n\n if (COPY_IN_PROGRESS_SET.has(value)) return undefined\n COPY_IN_PROGRESS_SET.add(value)\n let result: T\n\n if (isArray(value)) {\n result = [] as any as T\n eachArray(value, (it) => {\n result.push(internalDeepCircularCopy(it))\n })\n } else {\n result = {} as T\n each(value, (val, key) => {\n if (!COPY_IN_PROGRESS_SET.has(val)) {\n ;(result as any)[key] = internalDeepCircularCopy(val, key)\n }\n })\n }\n return result\n }\n return internalDeepCircularCopy(value)\n}\n\nexport function _copyAndTruncateStrings<T extends Record<string, any> = Record<string, any>>(\n object: T,\n maxStringLength: number | null\n): T {\n return deepCircularCopy(object, (value: any) => {\n if (isString(value) && !isNull(maxStringLength)) {\n return (value as string).slice(0, maxStringLength)\n }\n return value\n }) as T\n}\n\n// NOTE: Update PostHogConfig docs if you change this list\n// We will not try to catch all bullets here, but we should make an effort to catch the most common ones\n// You should be highly against adding more to this list, because ultimately customers can configure\n// their `cross_subdomain_cookie` setting to anything they want.\nconst EXCLUDED_FROM_CROSS_SUBDOMAIN_COOKIE = ['herokuapp.com', 'vercel.app', 'netlify.app']\nexport function isCrossDomainCookie(documentLocation: Location | undefined) {\n const hostname = documentLocation?.hostname\n\n if (!isString(hostname)) {\n return false\n }\n // split and slice isn't a great way to match arbitrary domains,\n // but it's good enough for ensuring we only match herokuapp.com when it is the TLD\n // for the hostname\n const lastTwoParts = hostname.split('.').slice(-2).join('.')\n\n for (const excluded of EXCLUDED_FROM_CROSS_SUBDOMAIN_COOKIE) {\n if (lastTwoParts === excluded) {\n return false\n }\n }\n\n return true\n}\n\nexport function find<T>(value: T[], predicate: (value: T) => boolean): T | undefined {\n for (let i = 0; i < value.length; i++) {\n if (predicate(value[i])) {\n return value[i]\n }\n }\n return undefined\n}\n\n// Use this instead of element.addEventListener to avoid eslint errors\n// this properly implements the default options for passive event listeners\nexport function addEventListener(\n element: Window | Document | Element | undefined,\n event: string,\n callback: EventListener,\n options?: AddEventListenerOptions\n): void {\n const { capture = false, passive = true } = options ?? {}\n\n // This is the only place where we are allowed to call this function\n // because the whole idea is that we should be calling this instead of the built-in one\n // eslint-disable-next-line posthog-js/no-add-event-listener\n element?.addEventListener(event, callback, { capture, passive })\n}\n\n/**\n * Helper to migrate deprecated config fields to new field names with appropriate warnings\n * @param config - The config object to check\n * @param newField - The new field name to use\n * @param oldField - The deprecated field name to check for\n * @param defaultValue - The default value if neither field is set\n * @param loggerInstance - Optional logger instance for deprecation warnings\n * @returns The value to use (new field takes precedence over old field)\n */\nexport function migrateConfigField<T>(\n config: Record<string, any>,\n newField: string,\n oldField: string,\n defaultValue: T,\n loggerInstance?: { warn: (message: string) => void }\n): T {\n const hasNewField = newField in config && !isUndefined(config[newField])\n const hasOldField = oldField in config && !isUndefined(config[oldField])\n\n if (hasNewField) {\n return config[newField]\n }\n\n if (hasOldField) {\n if (loggerInstance) {\n loggerInstance.warn(\n `Config field '${oldField}' is deprecated. Please use '${newField}' instead. ` +\n `The old field will be removed in a future major version.`\n )\n }\n return config[oldField]\n }\n\n return defaultValue\n}\n","import { DisplaySurveyOptions, DisplaySurveyType, Survey, SurveyType } from '../posthog-surveys-types'\nimport { createLogger } from '../utils/logger'\n\nexport const SURVEY_LOGGER = createLogger('[Surveys]')\n\nexport function isSurveyRunning(survey: Survey): boolean {\n return !!(survey.start_date && !survey.end_date)\n}\n\nexport function doesSurveyActivateByEvent(survey: Pick<Survey, 'conditions'>): boolean {\n return !!survey.conditions?.events?.values?.length\n}\n\nexport function doesSurveyActivateByAction(survey: Pick<Survey, 'conditions'>): boolean {\n return !!survey.conditions?.actions?.values?.length\n}\n\nexport const SURVEY_SEEN_PREFIX = 'seenSurvey_'\nexport const SURVEY_IN_PROGRESS_PREFIX = 'inProgressSurvey_'\nexport const SURVEY_ABANDONED_PREFIX = 'abandonedSurvey_'\n\nexport const getSurveyInteractionProperty = (\n survey: Pick<Survey, 'id' | 'current_iteration'>,\n action: 'responded' | 'dismissed'\n): string => {\n let surveyProperty = `$survey_${action}/${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n surveyProperty = `$survey_${action}/${survey.id}/${survey.current_iteration}`\n }\n\n return surveyProperty\n}\n\nconst getSurveyStorageKey = (prefix: string, survey: Pick<Survey, 'id' | 'current_iteration'>): string => {\n let key = `${prefix}${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n key = `${prefix}${survey.id}_${survey.current_iteration}`\n }\n return key\n}\n\nexport const getSurveySeenKey = (survey: Pick<Survey, 'id' | 'current_iteration'>): string => {\n return getSurveyStorageKey(SURVEY_SEEN_PREFIX, survey)\n}\n\nexport const getSurveyAbandonedKey = (survey: Pick<Survey, 'id' | 'current_iteration'>): string => {\n return getSurveyStorageKey(SURVEY_ABANDONED_PREFIX, survey)\n}\n\nexport const setSurveySeenOnLocalStorage = (survey: Pick<Survey, 'id' | 'current_iteration'>) => {\n const isSurveySeen = localStorage.getItem(getSurveySeenKey(survey))\n // if survey is already seen, no need to set it again\n if (isSurveySeen) {\n return\n }\n\n localStorage.setItem(getSurveySeenKey(survey), 'true')\n}\n\n// These surveys are relevant for the getActiveMatchingSurveys method. They are used to\n// display surveys in our customer's application. Any new in-app survey type should be added here.\nexport const IN_APP_SURVEY_TYPES = [SurveyType.Popover, SurveyType.Widget, SurveyType.API]\n\nexport const DEFAULT_DISPLAY_SURVEY_OPTIONS: DisplaySurveyOptions = {\n ignoreConditions: false,\n ignoreDelay: false,\n displayType: DisplaySurveyType.Popover,\n}\n","import { each, find } from './utils'\nimport Config from './config'\nimport { Compression, RequestWithOptions, RequestResponse } from './types'\nimport { formDataToQuery } from './utils/request-utils'\n\nimport { logger } from './utils/logger'\nimport { AbortController, fetch, navigator, XMLHttpRequest } from './utils/globals'\nimport { gzipSync, strToU8 } from 'fflate'\n\nimport { _base64Encode } from './utils/encode-utils'\n\n// eslint-disable-next-line compat/compat\nexport const SUPPORTS_REQUEST = !!XMLHttpRequest || !!fetch\n\nconst CONTENT_TYPE_PLAIN = 'text/plain'\nconst CONTENT_TYPE_JSON = 'application/json'\nconst CONTENT_TYPE_FORM = 'application/x-www-form-urlencoded'\nconst SIXTY_FOUR_KILOBYTES = 64 * 1024\n/*\n fetch will fail if we request keepalive with a body greater than 64kb\n sets the threshold lower than that so that\n any overhead doesn't push over the threshold after checking here\n*/\nconst KEEP_ALIVE_THRESHOLD = SIXTY_FOUR_KILOBYTES * 0.8\ntype EncodedBody = {\n contentType: string\n body: string | BlobPart\n estimatedSize: number\n}\n\n/**\n * Extends a URL with additional query parameters\n * @param url - The URL to extend\n * @param params - The parameters to add\n * @param replace - When true (default), new params overwrite existing ones with same key. When false, existing params are preserved.\n * @returns The URL with extended parameters\n */\nexport const extendURLParams = (url: string, params: Record<string, any>, replace: boolean = true): string => {\n const [baseUrl, search] = url.split('?')\n const newParams = { ...params }\n\n const updatedSearch =\n search?.split('&').map((pair) => {\n const [key, origValue] = pair.split('=')\n const value = replace ? (newParams[key] ?? origValue) : origValue\n delete newParams[key]\n return `${key}=${value}`\n }) ?? []\n\n const remaining = formDataToQuery(newParams)\n if (remaining) {\n updatedSearch.push(remaining)\n }\n\n return `${baseUrl}?${updatedSearch.join('&')}`\n}\n\nexport const jsonStringify = (data: any, space?: string | number): string => {\n // With plain JSON.stringify, we get an exception when a property is a BigInt. This has caused problems for some users,\n // see https://github.com/PostHog/posthog-js/issues/1440\n // To work around this, we convert BigInts to strings before stringifying the data. This is not ideal, as we lose\n // information that this was originally a number, but given ClickHouse doesn't support BigInts, the customer\n // would not be able to operate on these numerically anyway.\n return JSON.stringify(data, (_, value) => (typeof value === 'bigint' ? value.toString() : value), space)\n}\n\nconst encodeToDataString = (data: string | Record<string, any>): string => {\n return 'data=' + encodeURIComponent(typeof data === 'string' ? data : jsonStringify(data))\n}\n\nconst encodePostData = ({ data, compression }: RequestWithOptions): EncodedBody | undefined => {\n if (!data) {\n return\n }\n\n if (compression === Compression.GZipJS) {\n const gzipData = gzipSync(strToU8(jsonStringify(data)), { mtime: 0 })\n const blob = new Blob([gzipData], { type: CONTENT_TYPE_PLAIN })\n return {\n contentType: CONTENT_TYPE_PLAIN,\n body: blob,\n estimatedSize: blob.size,\n }\n }\n\n if (compression === Compression.Base64) {\n const b64data = _base64Encode(jsonStringify(data))\n const encodedBody = encodeToDataString(b64data)\n\n return {\n contentType: CONTENT_TYPE_FORM,\n body: encodedBody,\n estimatedSize: new Blob([encodedBody]).size,\n }\n }\n\n const jsonBody = jsonStringify(data)\n return {\n contentType: CONTENT_TYPE_JSON,\n body: jsonBody,\n estimatedSize: new Blob([jsonBody]).size,\n }\n}\n\nconst xhr = (options: RequestWithOptions) => {\n const req = new XMLHttpRequest!()\n req.open(options.method || 'GET', options.url, true)\n const { contentType, body } = encodePostData(options) ?? {}\n\n each(options.headers, function (headerValue, headerName) {\n req.setRequestHeader(headerName, headerValue)\n })\n\n if (contentType) {\n req.setRequestHeader('Content-Type', contentType)\n }\n\n if (options.timeout) {\n req.timeout = options.timeout\n }\n if (!options.disableXHRCredentials) {\n // send the ph_optout cookie\n // withCredentials cannot be modified until after calling .open on Android and Mobile Safari\n req.withCredentials = true\n }\n req.onreadystatechange = () => {\n // XMLHttpRequest.DONE == 4, except in safari 4\n if (req.readyState === 4) {\n const response: RequestResponse = {\n statusCode: req.status,\n text: req.responseText,\n }\n if (req.status === 200) {\n try {\n response.json = JSON.parse(req.responseText)\n } catch {\n // logger.error(e)\n }\n }\n\n options.callback?.(response)\n }\n }\n req.send(body)\n}\n\nconst _fetch = (options: RequestWithOptions) => {\n const { contentType, body, estimatedSize } = encodePostData(options) ?? {}\n\n // eslint-disable-next-line compat/compat\n const headers = new Headers()\n each(options.headers, function (headerValue, headerName) {\n headers.append(headerName, headerValue)\n })\n\n if (contentType) {\n headers.append('Content-Type', contentType)\n }\n\n const url = options.url\n let aborter: { signal: any; timeout: ReturnType<typeof setTimeout> } | null = null\n\n if (AbortController) {\n const controller = new AbortController()\n aborter = {\n signal: controller.signal,\n timeout: setTimeout(() => controller.abort(), options.timeout),\n }\n }\n\n fetch!(url, {\n method: options?.method || 'GET',\n headers,\n // if body is greater than 64kb, then fetch with keepalive will error\n // see 8:10:5 at https://fetch.spec.whatwg.org/#http-network-or-cache-fetch,\n // but we do want to set keepalive sometimes as it can help with success\n // when e.g. a page is being closed\n // so let's get the best of both worlds and only set keepalive for POST requests\n // where the body is less than 64kb\n // NB this is fetch keepalive and not http keepalive\n keepalive: options.method === 'POST' && (estimatedSize || 0) < KEEP_ALIVE_THRESHOLD,\n body,\n signal: aborter?.signal,\n ...options.fetchOptions,\n })\n .then((response) => {\n return response.text().then((responseText) => {\n const res: RequestResponse = {\n statusCode: response.status,\n text: responseText,\n }\n\n if (response.status === 200) {\n try {\n res.json = JSON.parse(responseText)\n } catch (e) {\n logger.error(e)\n }\n }\n\n options.callback?.(res)\n })\n })\n .catch((error) => {\n logger.error(error)\n options.callback?.({ statusCode: 0, text: error })\n })\n .finally(() => (aborter ? clearTimeout(aborter.timeout) : null))\n\n return\n}\n\nconst _sendBeacon = (options: RequestWithOptions) => {\n // beacon documentation https://w3c.github.io/beacon/\n // beacons format the message and use the type property\n\n const url = extendURLParams(options.url, {\n beacon: '1',\n })\n\n try {\n const { contentType, body } = encodePostData(options) ?? {}\n // sendBeacon requires a blob so we convert it\n const sendBeaconBody = typeof body === 'string' ? new Blob([body], { type: contentType }) : body\n navigator!.sendBeacon!(url, sendBeaconBody)\n } catch {\n // send beacon is a best-effort, fire-and-forget mechanism on page unload,\n // we don't want to throw errors here\n }\n}\n\nconst AVAILABLE_TRANSPORTS: {\n transport: RequestWithOptions['transport']\n method: (options: RequestWithOptions) => void\n}[] = []\n\n// We add the transports in order of preference\nif (fetch) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'fetch',\n method: _fetch,\n })\n}\n\nif (XMLHttpRequest) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'XHR',\n method: xhr,\n })\n}\n\nif (navigator?.sendBeacon) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'sendBeacon',\n method: _sendBeacon,\n })\n}\n\n// This is the entrypoint. It takes care of sanitizing the options and then calls the appropriate request method.\nexport const request = (_options: RequestWithOptions) => {\n // Clone the options so we don't modify the original object\n const options = { ..._options }\n options.timeout = options.timeout || 60000\n\n options.url = extendURLParams(options.url, {\n _: new Date().getTime().toString(),\n ver: Config.LIB_VERSION,\n compression: options.compression,\n })\n\n const transport = options.transport ?? 'fetch'\n\n const availableTransports = AVAILABLE_TRANSPORTS.filter(\n (t) => !options.disableTransport || !t.transport || !options.disableTransport.includes(t.transport)\n )\n\n const transportMethod =\n find(availableTransports, (t) => t.transport === transport)?.method ?? availableTransports[0].method\n\n if (!transportMethod) {\n throw new Error('No available transport method')\n }\n\n transportMethod(options)\n}\n","export const isValidRegex = function (str: string): boolean {\n try {\n new RegExp(str)\n } catch {\n return false\n }\n return true\n}\n\nexport const isMatchingRegex = function (value: string, pattern: string): boolean {\n if (!isValidRegex(pattern)) return false\n\n try {\n return new RegExp(pattern).test(value)\n } catch {\n return false\n }\n}\n","import { isNull, isUndefined } from '@posthog/core'\nimport { jsonStringify } from '../request'\nimport { PropertyFilters, PropertyOperator } from '../posthog-surveys-types'\nimport type { Properties } from '../types'\nimport { isMatchingRegex } from './regex-utils'\n\nexport function getPersonPropertiesHash(\n distinct_id: string,\n userPropertiesToSet?: Properties,\n userPropertiesToSetOnce?: Properties\n): string {\n return jsonStringify({ distinct_id, userPropertiesToSet, userPropertiesToSetOnce })\n}\n\nexport const propertyComparisons: Record<PropertyOperator, (targets: string[], values: string[]) => boolean> = {\n exact: (targets, values) => values.some((value) => targets.some((target) => value === target)),\n is_not: (targets, values) => values.every((value) => targets.every((target) => value !== target)),\n regex: (targets, values) => values.some((value) => targets.some((target) => isMatchingRegex(value, target))),\n not_regex: (targets, values) => values.every((value) => targets.every((target) => !isMatchingRegex(value, target))),\n icontains: (targets, values) =>\n values.map(toLowerCase).some((value) => targets.map(toLowerCase).some((target) => value.includes(target))),\n not_icontains: (targets, values) =>\n values.map(toLowerCase).every((value) => targets.map(toLowerCase).every((target) => !value.includes(target))),\n gt: (targets, values) =>\n values.some((value) => {\n const numValue = parseFloat(value)\n return !isNaN(numValue) && targets.some((t) => numValue > parseFloat(t))\n }),\n lt: (targets, values) =>\n values.some((value) => {\n const numValue = parseFloat(value)\n return !isNaN(numValue) && targets.some((t) => numValue < parseFloat(t))\n }),\n}\n\nconst toLowerCase = (v: string): string => v.toLowerCase()\n\nexport function matchPropertyFilters(\n propertyFilters: PropertyFilters | undefined,\n eventProperties: Properties | undefined\n): boolean {\n // if there are no property filters, it means we're only matching on event name\n if (!propertyFilters) {\n return true\n }\n\n return Object.entries(propertyFilters).every(([propertyName, filter]) => {\n const eventPropertyValue = eventProperties?.[propertyName]\n\n if (isUndefined(eventPropertyValue) || isNull(eventPropertyValue)) {\n return false\n }\n\n // convert event property to string array for comparison\n const eventValues = [String(eventPropertyValue)]\n\n const comparisonFunction = propertyComparisons[filter.operator]\n if (!comparisonFunction) {\n return false\n }\n\n return comparisonFunction(filter.values, eventValues)\n })\n}\n","import{options as n}from\"preact\";var t,r,u,i,o=0,f=[],c=[],e=n.__b,a=n.__r,v=n.diffed,l=n.__c,m=n.unmount;function d(t,u){n.__h&&n.__h(r,t,o||u),o=0;var i=r.__H||(r.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:c}),i.__[t]}function h(n){return o=1,s(B,n)}function s(n,u,i){var o=d(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):B(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.u)){var f=function(n,t,r){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return!n.__N}))return!c||c.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),!(!i&&o.__c.props===n)&&(!c||c.call(this,n,t,r))};r.u=!0;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u}e&&e.call(this,n,t,r)},r.shouldComponentUpdate=f}return o.__N||o.__}function p(u,i){var o=d(t++,3);!n.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__H.__h.push(o))}function y(u,i){var o=d(t++,4);!n.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__h.push(o))}function _(n){return o=5,F(function(){return{current:n}},[])}function A(n,t,r){o=6,y(function(){return\"function\"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==r?r:r.concat(n))}function F(n,r){var u=d(t++,7);return z(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function T(n,t){return o=8,F(function(){return n},t)}function q(n){var u=r.context[n.__c],i=d(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function x(t,r){n.useDebugValue&&n.useDebugValue(r?r(t):t)}function P(n){var u=d(t++,10),i=h();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n,t){u.__&&u.__(n,t),i[1](n)}),[i[0],function(){i[1](void 0)}]}function V(){var n=d(t++,11);if(!n.__){for(var u=r.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;var i=u.__m||(u.__m=[0,0]);n.__=\"P\"+i[0]+\"-\"+i[1]++}return n.__}function b(){for(var t;t=f.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(k),t.__H.__h.forEach(w),t.__H.__h=[]}catch(r){t.__H.__h=[],n.__e(r,t.__v)}}n.__b=function(n){r=null,e&&e(n)},n.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=c,n.__N=n.i=void 0})):(i.__h.forEach(k),i.__h.forEach(w),i.__h=[],t=0)),u=r},n.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==f.push(o)&&i===n.requestAnimationFrame||((i=n.requestAnimationFrame)||j)(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==c&&(n.__=n.__V),n.i=void 0,n.__V=c})),u=r=null},n.__c=function(t,r){r.some(function(t){try{t.__h.forEach(k),t.__h=t.__h.filter(function(n){return!n.__||w(n)})}catch(u){r.some(function(n){n.__h&&(n.__h=[])}),r=[],n.__e(u,t.__v)}}),l&&l(t,r)},n.unmount=function(t){m&&m(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{k(n)}catch(n){r=n}}),u.__H=void 0,r&&n.__e(r,u.__v))};var g=\"function\"==typeof requestAnimationFrame;function j(n){var t,r=function(){clearTimeout(u),g&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,100);g&&(t=requestAnimationFrame(r))}function k(n){var t=r,u=n.__c;\"function\"==typeof u&&(n.__c=void 0,u()),r=t}function w(n){var t=r;n.__c=n.__(),r=t}function z(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function B(n,t){return\"function\"==typeof t?t(n):t}export{T as useCallback,q as useContext,x as useDebugValue,p as useEffect,P as useErrorBoundary,V as useId,A as useImperativeHandle,y as useLayoutEffect,F as useMemo,s as useReducer,_ as useRef,h as useState};\n//# sourceMappingURL=hooks.module.js.map\n","import { VNode, cloneElement, createContext, type JSX } from 'preact'\nimport { PostHog } from '../../posthog-core'\nimport {\n MultipleSurveyQuestion,\n Survey,\n SurveyAppearance,\n SurveyEventName,\n SurveyEventProperties,\n SurveyPosition,\n SurveyQuestion,\n SurveySchedule,\n SurveyType,\n SurveyWidgetType,\n} from '../../posthog-surveys-types'\nimport { document as _document, window as _window, userAgent } from '../../utils/globals'\nimport {\n getSurveyInteractionProperty,\n getSurveySeenKey,\n getSurveyAbandonedKey,\n SURVEY_LOGGER as logger,\n setSurveySeenOnLocalStorage,\n SURVEY_IN_PROGRESS_PREFIX,\n} from '../../utils/survey-utils'\nimport { isArray, isNullish } from '@posthog/core'\n\nimport { detectDeviceType } from '@posthog/core'\nimport { propertyComparisons } from '../../utils/property-utils'\nimport { PropertyMatchType } from '../../types'\nimport { prepareStylesheet } from '../utils/stylesheet-loader'\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst window = _window as Window & typeof globalThis\nconst document = _document as Document\nimport surveyStyles from './survey.css'\nimport { useContext } from 'preact/hooks'\n\nexport function getFontFamily(fontFamily?: string): string {\n if (fontFamily === 'inherit') {\n return 'inherit'\n }\n\n const defaultFontStack =\n 'BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"'\n return fontFamily ? `${fontFamily}, ${defaultFontStack}` : `-apple-system, ${defaultFontStack}`\n}\n\nexport function getSurveyResponseKey(questionId: string) {\n return `$survey_response_${questionId}`\n}\n\nconst BLACK_TEXT_COLOR = '#020617' // Maps out to text-slate-950 from tailwind colors. Intended for text use outside interactive elements like buttons\n\n// Keep in sync with defaultSurveyAppearance on the main app\nexport const defaultSurveyAppearance = {\n fontFamily: 'inherit',\n backgroundColor: '#eeeded',\n submitButtonColor: 'black',\n submitButtonTextColor: 'white',\n ratingButtonColor: 'white',\n ratingButtonActiveColor: 'black',\n borderColor: '#c9c6c6',\n placeholder: 'Start typing...',\n whiteLabel: false,\n displayThankYouMessage: true,\n thankYouMessageHeader: 'Thank you for your feedback!',\n position: SurveyPosition.Right,\n widgetType: SurveyWidgetType.Tab,\n widgetLabel: 'Feedback',\n widgetColor: 'black',\n zIndex: '2147483647',\n disabledButtonOpacity: '0.6',\n maxWidth: '300px',\n textSubtleColor: '#939393',\n boxPadding: '20px 24px',\n boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',\n borderRadius: '10px',\n shuffleQuestions: false,\n surveyPopupDelaySeconds: undefined,\n // Not customizable atm\n outlineColor: 'rgba(59, 130, 246, 0.8)',\n inputBackground: 'white',\n inputTextColor: BLACK_TEXT_COLOR,\n scrollbarThumbColor: 'var(--ph-survey-border-color)',\n scrollbarTrackColor: 'var(--ph-survey-background-color)',\n} as const\n\nexport const addSurveyCSSVariablesToElement = (\n element: HTMLElement,\n type: SurveyType,\n appearance?: SurveyAppearance | null\n) => {\n const effectiveAppearance = { ...defaultSurveyAppearance, ...appearance }\n const hostStyle = element.style\n\n const surveyHasBottomBorder =\n ![SurveyPosition.Center, SurveyPosition.Left, SurveyPosition.Right].includes(effectiveAppearance.position) ||\n (type === SurveyType.Widget && appearance?.widgetType === SurveyWidgetType.Tab)\n\n hostStyle.setProperty('--ph-survey-font-family', getFontFamily(effectiveAppearance.fontFamily))\n hostStyle.setProperty('--ph-survey-box-padding', effectiveAppearance.boxPadding)\n hostStyle.setProperty('--ph-survey-max-width', effectiveAppearance.maxWidth)\n hostStyle.setProperty('--ph-survey-z-index', effectiveAppearance.zIndex)\n hostStyle.setProperty('--ph-survey-border-color', effectiveAppearance.borderColor)\n // Non-bottom surveys or tab surveys have the border bottom\n if (surveyHasBottomBorder) {\n hostStyle.setProperty('--ph-survey-border-radius', effectiveAppearance.borderRadius)\n hostStyle.setProperty('--ph-survey-border-bottom', '1.5px solid var(--ph-survey-border-color)')\n } else {\n hostStyle.setProperty('--ph-survey-border-bottom', 'none')\n hostStyle.setProperty(\n '--ph-survey-border-radius',\n `${effectiveAppearance.borderRadius} ${effectiveAppearance.borderRadius} 0 0`\n )\n }\n hostStyle.setProperty('--ph-survey-background-color', effectiveAppearance.backgroundColor)\n hostStyle.setProperty('--ph-survey-box-shadow', effectiveAppearance.boxShadow)\n hostStyle.setProperty('--ph-survey-disabled-button-opacity', effectiveAppearance.disabledButtonOpacity)\n hostStyle.setProperty('--ph-survey-submit-button-color', effectiveAppearance.submitButtonColor)\n hostStyle.setProperty(\n '--ph-survey-submit-button-text-color',\n appearance?.submitButtonTextColor || getContrastingTextColor(effectiveAppearance.submitButtonColor)\n )\n hostStyle.setProperty('--ph-survey-rating-bg-color', effectiveAppearance.ratingButtonColor)\n hostStyle.setProperty('--ph-survey-rating-active-bg-color', effectiveAppearance.ratingButtonActiveColor)\n // Active rating text is always auto-calculated for contrast with active background\n hostStyle.setProperty(\n '--ph-survey-rating-active-text-color',\n getContrastingTextColor(effectiveAppearance.ratingButtonActiveColor)\n )\n // Primary text color: use override if provided, otherwise auto-calculate from background\n hostStyle.setProperty(\n '--ph-survey-text-primary-color',\n appearance?.textColor || getContrastingTextColor(effectiveAppearance.backgroundColor)\n )\n hostStyle.setProperty('--ph-survey-text-subtle-color', effectiveAppearance.textSubtleColor)\n hostStyle.setProperty('--ph-widget-color', effectiveAppearance.widgetColor)\n hostStyle.setProperty('--ph-widget-text-color', getContrastingTextColor(effectiveAppearance.widgetColor))\n hostStyle.setProperty('--ph-widget-z-index', effectiveAppearance.zIndex)\n\n // Use user-provided inputBackground (or deprecated inputBackgroundColor for backwards compat)\n // Fallback to internal default, with slight adjustment for white backgrounds\n const userInputBg = appearance?.inputBackground || appearance?.inputBackgroundColor\n let inputBgColor = userInputBg || effectiveAppearance.inputBackground\n if (!userInputBg && effectiveAppearance.backgroundColor === 'white') {\n inputBgColor = '#f8f8f8'\n }\n hostStyle.setProperty('--ph-survey-input-background', inputBgColor)\n // Input text color applies to both text inputs and inactive rating buttons\n const inputTextColor = appearance?.inputTextColor || getContrastingTextColor(inputBgColor)\n hostStyle.setProperty('--ph-survey-input-text-color', inputTextColor)\n hostStyle.setProperty('--ph-survey-rating-text-color', inputTextColor)\n hostStyle.setProperty('--ph-survey-scrollbar-thumb-color', effectiveAppearance.scrollbarThumbColor)\n hostStyle.setProperty('--ph-survey-scrollbar-track-color', effectiveAppearance.scrollbarTrackColor)\n hostStyle.setProperty('--ph-survey-outline-color', effectiveAppearance.outlineColor)\n}\n\nfunction nameToHex(name: string) {\n return {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n 'indianred ': '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrodyellow: '#fafad2',\n lightgrey: '#d3d3d3',\n lightgreen: '#90ee90',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370d8',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#d87093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32',\n }[name.toLowerCase()]\n}\n\nexport function hex2rgb(c: string): string {\n if (c.startsWith('#')) {\n let hexColor = c.replace(/^#/, '')\n // Handle 3-character shorthand (e.g., #111 -> #111111, #abc -> #aabbcc)\n if (/^[0-9A-Fa-f]{3}$/.test(hexColor)) {\n hexColor = hexColor[0] + hexColor[0] + hexColor[1] + hexColor[1] + hexColor[2] + hexColor[2]\n }\n if (!/^[0-9A-Fa-f]{6}$/.test(hexColor)) {\n return 'rgb(255, 255, 255)'\n }\n const r = parseInt(hexColor.slice(0, 2), 16)\n const g = parseInt(hexColor.slice(2, 4), 16)\n const b = parseInt(hexColor.slice(4, 6), 16)\n return `rgb(${r},${g},${b})`\n }\n return 'rgb(255, 255, 255)'\n}\n\nexport function hexToRgba(hex: string, opacity: number): string {\n const rgb = hex2rgb(hex)\n const match = rgb.match(/^rgb\\((\\d+),(\\d+),(\\d+)\\)$/)\n if (!match) {\n return hex\n }\n return `rgba(${match[1]}, ${match[2]}, ${match[3]}, ${opacity})`\n}\n\nexport function getContrastingTextColor(color: string = defaultSurveyAppearance.backgroundColor) {\n let rgb\n if (color[0] === '#') {\n rgb = hex2rgb(color)\n }\n if (color.startsWith('rgb')) {\n rgb = color\n }\n // otherwise it's a color name\n const nameColorToHex = nameToHex(color)\n if (nameColorToHex) {\n rgb = hex2rgb(nameColorToHex)\n }\n if (!rgb) {\n return BLACK_TEXT_COLOR\n }\n const colorMatch = rgb.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (colorMatch) {\n const r = parseInt(colorMatch[1])\n const g = parseInt(colorMatch[2])\n const b = parseInt(colorMatch[3])\n const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n return hsp > 127.5 ? BLACK_TEXT_COLOR : 'white'\n }\n return BLACK_TEXT_COLOR\n}\n\nexport function getSurveyStylesheet(posthog?: PostHog) {\n const stylesheet = prepareStylesheet(document, typeof surveyStyles === 'string' ? surveyStyles : '', posthog)\n stylesheet?.setAttribute('data-ph-survey-style', 'true')\n return stylesheet\n}\n\nexport const retrieveSurveyShadow = (\n survey: Pick<Survey, 'id' | 'appearance' | 'type'>,\n posthog?: PostHog,\n element?: Element\n) => {\n const widgetClassName = getSurveyContainerClass(survey)\n const existingDiv = document.querySelector(`.${widgetClassName}`)\n\n if (existingDiv && existingDiv.shadowRoot) {\n return {\n shadow: existingDiv.shadowRoot,\n isNewlyCreated: false,\n }\n }\n\n // If it doesn't exist, create it\n const div = document.createElement('div')\n addSurveyCSSVariablesToElement(div, survey.type, survey.appearance)\n div.className = widgetClassName\n const shadow = div.attachShadow({ mode: 'open' })\n const stylesheet = getSurveyStylesheet(posthog)\n if (stylesheet) {\n const existingStylesheet = shadow.querySelector('style')\n if (existingStylesheet) {\n shadow.removeChild(existingStylesheet)\n }\n shadow.appendChild(stylesheet)\n }\n ;(element ? element : document.body).appendChild(div)\n return {\n shadow,\n isNewlyCreated: true,\n }\n}\n\ninterface SendSurveyEventArgs {\n responses: Record<string, string | number | string[] | null>\n survey: Survey\n surveySubmissionId: string\n isSurveyCompleted: boolean\n posthog?: PostHog\n}\n\nconst getSurveyResponseValue = (responses: Record<string, string | number | string[] | null>, questionId?: string) => {\n if (!questionId) {\n return null\n }\n const response = responses[getSurveyResponseKey(questionId)]\n if (isArray(response)) {\n return [...response]\n }\n return response\n}\n\nexport const sendSurveyEvent = ({\n responses,\n survey,\n surveySubmissionId,\n posthog,\n isSurveyCompleted,\n}: SendSurveyEventArgs) => {\n if (!posthog) {\n logger.error('[survey sent] event not captured, PostHog instance not found.')\n return\n }\n setSurveySeenOnLocalStorage(survey)\n posthog.capture(SurveyEventName.SENT, {\n [SurveyEventProperties.SURVEY_NAME]: survey.name,\n [SurveyEventProperties.SURVEY_ID]: survey.id,\n [SurveyEventProperties.SURVEY_ITERATION]: survey.current_iteration,\n [SurveyEventProperties.SURVEY_ITERATION_START_DATE]: survey.current_iteration_start_date,\n [SurveyEventProperties.SURVEY_QUESTIONS]: survey.questions.map((question) => ({\n id: question.id,\n question: question.question,\n response: getSurveyResponseValue(responses, question.id),\n })),\n [SurveyEventProperties.SURVEY_SUBMISSION_ID]: surveySubmissionId,\n [SurveyEventProperties.SURVEY_COMPLETED]: isSurveyCompleted,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...responses,\n $set: {\n [getSurveyInteractionProperty(survey, 'responded')]: true,\n },\n })\n if (isSurveyCompleted) {\n // Only dispatch PHSurveySent if the survey is completed, as that removes the survey from focus\n window.dispatchEvent(new CustomEvent('PHSurveySent', { detail: { surveyId: survey.id } }))\n clearInProgressSurveyState(survey)\n }\n}\n\nconst _surveyHasResponses = (inProgressSurvey: InProgressSurveyState | null) => {\n return Object.values(inProgressSurvey?.responses || {}).filter((resp) => !isNullish(resp)).length > 0\n}\n\nconst _buildSurveyEventProperties = (\n survey: Survey,\n inProgressSurvey: InProgressSurveyState | null,\n posthog: PostHog\n) => ({\n [SurveyEventProperties.SURVEY_NAME]: survey.name,\n [SurveyEventProperties.SURVEY_ID]: survey.id,\n [SurveyEventProperties.SURVEY_ITERATION]: survey.current_iteration,\n [SurveyEventProperties.SURVEY_ITERATION_START_DATE]: survey.current_iteration_start_date,\n [SurveyEventProperties.SURVEY_PARTIALLY_COMPLETED]: _surveyHasResponses(inProgressSurvey),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...inProgressSurvey?.responses,\n [SurveyEventProperties.SURVEY_SUBMISSION_ID]: inProgressSurvey?.surveySubmissionId,\n [SurveyEventProperties.SURVEY_QUESTIONS]: survey.questions.map((question) => ({\n id: question.id,\n question: question.question,\n response: getSurveyResponseValue(inProgressSurvey?.responses || {}, question.id),\n })),\n})\n\nexport const dismissedSurveyEvent = (survey: Survey, posthog?: PostHog, readOnly?: boolean) => {\n if (!posthog) {\n logger.error('[survey dismissed] event not captured, PostHog instance not found.')\n return\n }\n if (readOnly) {\n return\n }\n\n const inProgressSurvey = getInProgressSurveyState(survey)\n posthog.capture(SurveyEventName.DISMISSED, {\n ..._buildSurveyEventProperties(survey, inProgressSurvey, posthog),\n $set: {\n [getSurveyInteractionProperty(survey, 'dismissed')]: true,\n },\n })\n clearInProgressSurveyState(survey)\n setSurveySeenOnLocalStorage(survey)\n window.dispatchEvent(new CustomEvent('PHSurveyClosed', { detail: { surveyId: survey.id } }))\n}\n\nexport const sendSurveyAbandonedEvent = (survey: Survey, posthog?: PostHog) => {\n if (!posthog) {\n logger.error('[survey abandoned] event not captured, PostHog instance not found.')\n return\n }\n\n const abandonedKey = getSurveyAbandonedKey(survey)\n try {\n if (localStorage.getItem(abandonedKey) === 'true') {\n return\n }\n } catch {\n // localStorage not available\n return\n }\n\n const inProgressSurvey = getInProgressSurveyState(survey)\n if (!inProgressSurvey) {\n return\n }\n\n try {\n localStorage.setItem(abandonedKey, 'true')\n } catch {\n // localStorage not available\n }\n\n posthog.capture(SurveyEventName.ABANDONED, _buildSurveyEventProperties(survey, inProgressSurvey, posthog), {\n transport: 'sendBeacon',\n })\n}\n\n// Use the Fisher-yates algorithm to shuffle this array\n// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle\nexport const shuffle = (array: any[]) => {\n return array\n .map((a) => ({ sort: Math.floor(Math.random() * 10), value: a }))\n .sort((a, b) => a.sort - b.sort)\n .map((a) => a.value)\n}\n\nconst reverseIfUnshuffled = (unshuffled: any[], shuffled: any[]): any[] => {\n if (unshuffled.length === shuffled.length && unshuffled.every((val, index) => val === shuffled[index])) {\n return shuffled.reverse()\n }\n\n return shuffled\n}\n\nexport const getDisplayOrderChoices = (question: MultipleSurveyQuestion): string[] => {\n if (!question.shuffleOptions) {\n return question.choices\n }\n\n const displayOrderChoices = question.choices\n let openEndedChoice = ''\n if (question.hasOpenChoice) {\n // if the question has an open-ended choice, its always the last element in the choices array.\n openEndedChoice = displayOrderChoices.pop()!\n }\n\n const shuffledOptions = reverseIfUnshuffled(displayOrderChoices, shuffle(displayOrderChoices))\n\n if (question.hasOpenChoice) {\n question.choices.push(openEndedChoice)\n shuffledOptions.push(openEndedChoice)\n }\n\n return shuffledOptions\n}\n\nexport const getDisplayOrderQuestions = (survey: Survey): SurveyQuestion[] => {\n if (!survey.appearance || !survey.appearance.shuffleQuestions || survey.enable_partial_responses) {\n return survey.questions\n }\n\n return reverseIfUnshuffled(survey.questions, shuffle(survey.questions))\n}\n\nexport const hasEvents = (survey: Pick<Survey, 'conditions'>): boolean => {\n return survey.conditions?.events?.values?.length != undefined && survey.conditions?.events?.values?.length > 0\n}\n\nexport const canActivateRepeatedly = (\n survey: Pick<Survey, 'schedule' | 'conditions' | 'id' | 'current_iteration'>\n): boolean => {\n return (\n !!(survey.conditions?.events?.repeatedActivation && hasEvents(survey)) ||\n survey.schedule === SurveySchedule.Always ||\n isSurveyInProgress(survey)\n )\n}\n\n/**\n * getSurveySeen checks local storage for the surveySeen Key a\n * and overrides this value if the survey can be repeatedly activated by its events.\n * @param survey\n */\nexport const getSurveySeen = (survey: Survey): boolean => {\n const surveySeen = localStorage.getItem(getSurveySeenKey(survey))\n if (surveySeen) {\n // if a survey has already been seen,\n // we will override it with the event repeated activation value.\n return !canActivateRepeatedly(survey)\n }\n\n return false\n}\n\nconst LAST_SEEN_SURVEY_DATE_KEY = 'lastSeenSurveyDate'\n\nexport const hasWaitPeriodPassed = (waitPeriodInDays: number | undefined): boolean => {\n const lastSeenSurveyDate = localStorage.getItem(LAST_SEEN_SURVEY_DATE_KEY)\n if (!waitPeriodInDays || !lastSeenSurveyDate) {\n return true\n }\n\n const today = new Date()\n const diff = Math.abs(today.getTime() - new Date(lastSeenSurveyDate).getTime())\n const diffDaysFromToday = Math.ceil(diff / (1000 * 3600 * 24))\n return diffDaysFromToday > waitPeriodInDays\n}\n\ninterface SurveyContextProps {\n isPreviewMode: boolean\n previewPageIndex: number | undefined\n onPopupSurveyDismissed: () => void\n isPopup: boolean\n onPreviewSubmit: (res: string | string[] | number | null) => void\n surveySubmissionId: string\n}\n\nexport const SurveyContext = createContext<SurveyContextProps>({\n isPreviewMode: false,\n previewPageIndex: 0,\n onPopupSurveyDismissed: () => {},\n isPopup: true,\n onPreviewSubmit: () => {},\n surveySubmissionId: '',\n})\n\nexport const useSurveyContext = () => {\n return useContext(SurveyContext)\n}\n\ninterface RenderProps {\n component: VNode<{ className: string }>\n children: string\n renderAsHtml?: boolean\n style?: JSX.CSSProperties\n}\n\nexport const renderChildrenAsTextOrHtml = ({ component, children, renderAsHtml, style }: RenderProps) => {\n return renderAsHtml\n ? cloneElement(component, {\n dangerouslySetInnerHTML: { __html: children },\n style,\n })\n : cloneElement(component, {\n children,\n style,\n })\n}\n\nfunction defaultMatchType(matchType?: PropertyMatchType): PropertyMatchType {\n return matchType ?? 'icontains'\n}\n\n// use urlMatchType to validate url condition, fallback to contains for backwards compatibility\nexport function doesSurveyUrlMatch(survey: Pick<Survey, 'conditions'>): boolean {\n if (!survey.conditions?.url) {\n return true\n }\n // if we dont know the url, assume it is not a match\n const href = window?.location?.href\n if (!href) {\n return false\n }\n const targets = [survey.conditions.url]\n const matchType = defaultMatchType(survey.conditions?.urlMatchType)\n return propertyComparisons[matchType](targets, [href])\n}\n\nexport function doesSurveyDeviceTypesMatch(survey: Survey): boolean {\n if (!survey.conditions?.deviceTypes || survey.conditions?.deviceTypes.length === 0) {\n return true\n }\n // if we dont know the device type, assume it is not a match\n if (!userAgent) {\n return false\n }\n\n const deviceType = detectDeviceType(userAgent)\n return propertyComparisons[defaultMatchType(survey.conditions?.deviceTypesMatchType)](\n survey.conditions.deviceTypes,\n [deviceType]\n )\n}\n\nexport function doesSurveyMatchSelector(survey: Survey): boolean {\n if (!survey.conditions?.selector) {\n return true\n }\n return !!document?.querySelector(survey.conditions.selector)\n}\n\ninterface InProgressSurveyState {\n surveySubmissionId: string\n lastQuestionIndex: number\n responses: Record<string, string | number | string[] | null>\n}\n\nconst getInProgressSurveyStateKey = (survey: Pick<Survey, 'id' | 'current_iteration'>): string => {\n let key = `${SURVEY_IN_PROGRESS_PREFIX}${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n key = `${SURVEY_IN_PROGRESS_PREFIX}${survey.id}_${survey.current_iteration}`\n }\n return key\n}\n\nexport const setInProgressSurveyState = (\n survey: Pick<Survey, 'id' | 'current_iteration'>,\n state: InProgressSurveyState\n): void => {\n try {\n localStorage.setItem(getInProgressSurveyStateKey(survey), JSON.stringify(state))\n } catch (e) {\n logger.error('Error setting in-progress survey state in localStorage', e)\n }\n}\n\nexport const getInProgressSurveyState = (\n survey: Pick<Survey, 'id' | 'current_iteration'>\n): InProgressSurveyState | null => {\n try {\n const stateString = localStorage.getItem(getInProgressSurveyStateKey(survey))\n if (stateString) {\n return JSON.parse(stateString) as InProgressSurveyState\n }\n } catch (e) {\n logger.error('Error getting in-progress survey state from localStorage', e)\n }\n return null\n}\n\nexport const isSurveyInProgress = (survey: Pick<Survey, 'id' | 'current_iteration'>): boolean => {\n const state = getInProgressSurveyState(survey)\n return !isNullish(state?.surveySubmissionId)\n}\n\nexport const clearInProgressSurveyState = (survey: Pick<Survey, 'id' | 'current_iteration'>): void => {\n try {\n localStorage.removeItem(getInProgressSurveyStateKey(survey))\n } catch (e) {\n logger.error('Error clearing in-progress survey state from localStorage', e)\n }\n}\n\nexport function getSurveyContainerClass(survey: Pick<Survey, 'id'>, asSelector = false): string {\n const className = `PostHogSurvey-${survey.id}`\n return asSelector ? `.${className}` : className\n}\n","import {\n ProductTourAppearance,\n ProductTourSelectorError,\n DEFAULT_PRODUCT_TOUR_APPEARANCE,\n} from '../../posthog-product-tours-types'\nimport { prepareStylesheet } from '../utils/stylesheet-loader'\nimport { document as _document, window as _window } from '../../utils/globals'\nimport { getFontFamily, getContrastingTextColor, hexToRgba } from '../surveys/surveys-extension-utils'\n\nimport productTourStyles from './product-tour.css'\n\nconst document = _document as Document\nconst window = _window as Window & typeof globalThis\n\nexport function getProductTourStylesheet(): HTMLStyleElement | null {\n const stylesheet = prepareStylesheet(document, typeof productTourStyles === 'string' ? productTourStyles : '')\n stylesheet?.setAttribute('data-ph-product-tour-style', 'true')\n return stylesheet\n}\n\nexport interface ElementFindResult {\n element: HTMLElement | null\n error: ProductTourSelectorError | null\n matchCount: number\n}\n\nexport function findElementBySelector(selector: string): ElementFindResult {\n try {\n const elements = document.querySelectorAll(selector)\n\n if (elements.length === 0) {\n return { element: null, error: 'not_found', matchCount: 0 }\n }\n\n const element = elements[0] as HTMLElement\n\n if (!isElementVisible(element)) {\n return { element: null, error: 'not_visible', matchCount: elements.length }\n }\n\n if (elements.length > 1) {\n return { element, error: 'multiple_matches', matchCount: elements.length }\n }\n\n return { element, error: null, matchCount: 1 }\n } catch {\n return { element: null, error: 'not_found', matchCount: 0 }\n }\n}\n\nexport function isElementVisible(element: HTMLElement): boolean {\n const style = window.getComputedStyle(element)\n\n if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') {\n return false\n }\n\n const rect = element.getBoundingClientRect()\n if (rect.width === 0 || rect.height === 0) {\n return false\n }\n\n return true\n}\n\nexport function getElementMetadata(element: HTMLElement): {\n tag: string\n id: string | undefined\n classes: string | undefined\n text: string | undefined\n} {\n return {\n tag: element.tagName,\n id: element.id || undefined,\n classes: element.className || undefined,\n text: element.innerText?.slice(0, 100) || undefined,\n }\n}\n\nexport type TooltipPosition = 'top' | 'bottom' | 'left' | 'right'\n\nexport interface PositionResult {\n top: number\n left: number\n position: TooltipPosition\n}\n\nconst TOOLTIP_MARGIN = 12\nconst TOOLTIP_WIDTH = 320\nconst TOOLTIP_HEIGHT_ESTIMATE = 180\n\nexport function calculateTooltipPosition(targetRect: DOMRect): PositionResult {\n const viewportWidth = window.innerWidth\n const viewportHeight = window.innerHeight\n\n const spaceBelow = viewportHeight - targetRect.bottom\n const spaceLeft = targetRect.left\n const spaceRight = viewportWidth - targetRect.right\n\n let position: TooltipPosition\n let top: number\n let left: number\n\n if (spaceRight >= TOOLTIP_WIDTH + TOOLTIP_MARGIN) {\n position = 'right'\n top = targetRect.top + targetRect.height / 2 - TOOLTIP_HEIGHT_ESTIMATE / 2\n left = targetRect.right + TOOLTIP_MARGIN\n } else if (spaceLeft >= TOOLTIP_WIDTH + TOOLTIP_MARGIN) {\n position = 'left'\n top = targetRect.top + targetRect.height / 2 - TOOLTIP_HEIGHT_ESTIMATE / 2\n left = targetRect.left - TOOLTIP_WIDTH - TOOLTIP_MARGIN\n } else if (spaceBelow >= TOOLTIP_HEIGHT_ESTIMATE + TOOLTIP_MARGIN) {\n position = 'bottom'\n top = targetRect.bottom + TOOLTIP_MARGIN\n left = targetRect.left + targetRect.width / 2 - TOOLTIP_WIDTH / 2\n } else {\n position = 'top'\n top = targetRect.top - TOOLTIP_HEIGHT_ESTIMATE - TOOLTIP_MARGIN\n left = targetRect.left + targetRect.width / 2 - TOOLTIP_WIDTH / 2\n }\n\n return { top, left, position }\n}\n\nexport function getSpotlightStyle(targetRect: DOMRect, padding: number = 8): Record<string, string> {\n return {\n top: `${targetRect.top - padding}px`,\n left: `${targetRect.left - padding}px`,\n width: `${targetRect.width + padding * 2}px`,\n height: `${targetRect.height + padding * 2}px`,\n }\n}\n\nexport function addProductTourCSSVariablesToElement(element: HTMLElement, appearance?: ProductTourAppearance): void {\n const merged = { ...DEFAULT_PRODUCT_TOUR_APPEARANCE, ...appearance }\n const style = element.style\n\n // User-customizable variables\n style.setProperty('--ph-tour-background-color', merged.backgroundColor)\n style.setProperty('--ph-tour-text-color', merged.textColor)\n style.setProperty('--ph-tour-button-color', merged.buttonColor)\n style.setProperty('--ph-tour-border-radius', `${merged.borderRadius}px`)\n style.setProperty('--ph-tour-button-border-radius', `${merged.buttonBorderRadius}px`)\n style.setProperty('--ph-tour-border-color', merged.borderColor)\n style.setProperty('--ph-tour-font-family', getFontFamily(merged.fontFamily))\n\n // Derived colors\n style.setProperty('--ph-tour-text-secondary-color', hexToRgba(merged.textColor, 0.6))\n style.setProperty('--ph-tour-branding-text-color', getContrastingTextColor(merged.backgroundColor))\n style.setProperty('--ph-tour-button-text-color', getContrastingTextColor(merged.buttonColor))\n style.setProperty('--ph-tour-box-shadow', merged.boxShadow)\n style.setProperty('--ph-tour-overlay-color', merged.showOverlay ? 'rgba(0, 0, 0, 0.5)' : 'transparent')\n\n // Internal styling variables (not customizable)\n style.setProperty('--ph-tour-button-secondary-color', 'transparent')\n style.setProperty('--ph-tour-button-secondary-text-color', merged.textColor)\n style.setProperty('--ph-tour-max-width', '320px')\n style.setProperty('--ph-tour-padding', '16px')\n}\n\nexport function renderTipTapContent(content: any): string {\n if (!content) {\n return ''\n }\n\n if (typeof content === 'string') {\n return escapeHtml(content)\n }\n\n if (content.type === 'text') {\n let text = escapeHtml(content.text || '')\n\n if (content.marks) {\n for (const mark of content.marks) {\n switch (mark.type) {\n case 'bold':\n text = `<strong>${text}</strong>`\n break\n case 'italic':\n text = `<em>${text}</em>`\n break\n case 'underline':\n text = `<u>${text}</u>`\n break\n case 'strike':\n text = `<s>${text}</s>`\n break\n }\n }\n }\n\n return text\n }\n\n const children = content.content?.map(renderTipTapContent).join('') || ''\n\n switch (content.type) {\n case 'doc':\n return children\n case 'paragraph':\n return `<p>${children}</p>`\n case 'heading': {\n const level = content.attrs?.level || 1\n return `<h${level}>${children}</h${level}>`\n }\n case 'bulletList':\n return `<ul>${children}</ul>`\n case 'orderedList':\n return `<ol>${children}</ol>`\n case 'listItem':\n return `<li>${children}</li>`\n case 'hardBreak':\n return '<br>'\n default:\n return children\n }\n}\n\nexport function normalizeUrl(url: string): string {\n return url.endsWith('/') ? url.slice(0, -1) : url\n}\n\nfunction escapeHtml(text: string): string {\n const div = document.createElement('div')\n div.textContent = text\n return div.innerHTML\n}\n","export const satisfiedEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\" />\n </svg>\n)\nexport const neutralEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\" />\n </svg>\n)\nexport const dissatisfiedEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\" />\n </svg>\n)\nexport const veryDissatisfiedEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z\" />\n </svg>\n)\nexport const verySatisfiedEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\" />\n </svg>\n)\nexport const cancelSVG = (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-labelledby=\"close-survey-title\"\n >\n <title id=\"close-survey-title\">Close survey</title>\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z\"\n fill=\"black\"\n />\n </svg>\n)\nexport const IconPosthogLogo = (\n <svg width=\"77\" height=\"14\" viewBox=\"0 0 77 14\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g clip-path=\"url(#clip0_2415_6911)\">\n <mask\n id=\"mask0_2415_6911\"\n style={{ maskType: 'luminance' }}\n maskUnits=\"userSpaceOnUse\"\n x=\"0\"\n y=\"0\"\n width=\"77\"\n height=\"14\"\n >\n <path d=\"M0.5 0H76.5V14H0.5V0Z\" fill=\"white\" />\n </mask>\n <g mask=\"url(#mask0_2415_6911)\">\n <path\n d=\"M5.77226 8.02931C5.59388 8.37329 5.08474 8.37329 4.90634 8.02931L4.4797 7.20672C4.41155 7.07535 4.41155 6.9207 4.4797 6.78933L4.90634 5.96669C5.08474 5.62276 5.59388 5.62276 5.77226 5.96669L6.19893 6.78933C6.26709 6.9207 6.26709 7.07535 6.19893 7.20672L5.77226 8.02931ZM5.77226 12.6946C5.59388 13.0386 5.08474 13.0386 4.90634 12.6946L4.4797 11.872C4.41155 11.7406 4.41155 11.586 4.4797 11.4546L4.90634 10.632C5.08474 10.288 5.59388 10.288 5.77226 10.632L6.19893 11.4546C6.26709 11.586 6.26709 11.7406 6.19893 11.872L5.77226 12.6946Z\"\n fill=\"#1D4AFF\"\n />\n <path\n d=\"M0.5 10.9238C0.5 10.508 1.02142 10.2998 1.32637 10.5938L3.54508 12.7327C3.85003 13.0267 3.63405 13.5294 3.20279 13.5294H0.984076C0.716728 13.5294 0.5 13.3205 0.5 13.0627V10.9238ZM0.5 8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.19753 13.3927C5.28831 13.4802 5.41144 13.5294 5.53982 13.5294H8.0421C8.47337 13.5294 8.68936 13.0267 8.3844 12.7327L1.32637 5.92856C1.02142 5.63456 0.5 5.84278 0.5 6.25854V8.67083ZM0.5 4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L10.0368 13.3927C10.1276 13.4802 10.2508 13.5294 10.3791 13.5294H12.8814C13.3127 13.5294 13.5287 13.0267 13.2237 12.7327L1.32637 1.26329C1.02142 0.969312 0.5 1.17752 0.5 1.59327V4.00556ZM5.33931 4.00556C5.33931 4.12932 5.39033 4.24802 5.4811 4.33554L14.1916 12.7327C14.4965 13.0267 15.0179 12.8185 15.0179 12.4028V9.99047C15.0179 9.86671 14.9669 9.74799 14.8762 9.66049L6.16568 1.26329C5.86071 0.969307 5.33931 1.17752 5.33931 1.59327V4.00556ZM11.005 1.26329C10.7 0.969307 10.1786 1.17752 10.1786 1.59327V4.00556C10.1786 4.12932 10.2296 4.24802 10.3204 4.33554L14.1916 8.06748C14.4965 8.36148 15.0179 8.15325 15.0179 7.7375V5.3252C15.0179 5.20144 14.9669 5.08272 14.8762 4.99522L11.005 1.26329Z\"\n fill=\"#F9BD2B\"\n />\n <path\n d=\"M21.0852 10.981L16.5288 6.58843C16.2238 6.29443 15.7024 6.50266 15.7024 6.91841V13.0627C15.7024 13.3205 15.9191 13.5294 16.1865 13.5294H23.2446C23.5119 13.5294 23.7287 13.3205 23.7287 13.0627V12.5032C23.7287 12.2455 23.511 12.0396 23.2459 12.0063C22.4323 11.9042 21.6713 11.546 21.0852 10.981ZM18.0252 12.0365C17.5978 12.0365 17.251 11.7021 17.251 11.2901C17.251 10.878 17.5978 10.5436 18.0252 10.5436C18.4527 10.5436 18.7996 10.878 18.7996 11.2901C18.7996 11.7021 18.4527 12.0365 18.0252 12.0365Z\"\n fill=\"currentColor\"\n />\n <path\n d=\"M0.5 13.0627C0.5 13.3205 0.716728 13.5294 0.984076 13.5294H3.20279C3.63405 13.5294 3.85003 13.0267 3.54508 12.7327L1.32637 10.5938C1.02142 10.2998 0.5 10.508 0.5 10.9238V13.0627ZM5.33931 5.13191L1.32637 1.26329C1.02142 0.969306 0.5 1.17752 0.5 1.59327V4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L5.33931 8.86412V5.13191ZM1.32637 5.92855C1.02142 5.63455 0.5 5.84278 0.5 6.25853V8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.33931 13.5294V9.79717L1.32637 5.92855Z\"\n fill=\"#1D4AFF\"\n />\n <path\n d=\"M10.1787 5.3252C10.1787 5.20144 10.1277 5.08272 10.0369 4.99522L6.16572 1.26329C5.8608 0.969306 5.33936 1.17752 5.33936 1.59327V4.00556C5.33936 4.12932 5.39037 4.24802 5.48114 4.33554L10.1787 8.86412V5.3252ZM5.33936 13.5294H8.04214C8.47341 13.5294 8.6894 13.0267 8.38443 12.7327L5.33936 9.79717V13.5294ZM5.33936 5.13191V8.67083C5.33936 8.79459 5.39037 8.91331 5.48114 9.00081L10.1787 13.5294V9.99047C10.1787 9.86671 10.1277 9.74803 10.0369 9.66049L5.33936 5.13191Z\"\n fill=\"#F54E00\"\n />\n <path\n d=\"M29.375 11.6667H31.3636V8.48772H33.0249C34.8499 8.48772 36.0204 7.4443 36.0204 5.83052C36.0204 4.21681 34.8499 3.17334 33.0249 3.17334H29.375V11.6667ZM31.3636 6.84972V4.81136H32.8236C33.5787 4.81136 34.0318 5.19958 34.0318 5.83052C34.0318 6.4615 33.5787 6.84972 32.8236 6.84972H31.3636ZM39.618 11.7637C41.5563 11.7637 42.9659 10.429 42.9659 8.60905C42.9659 6.78905 41.5563 5.45438 39.618 5.45438C37.6546 5.45438 36.2701 6.78905 36.2701 8.60905C36.2701 10.429 37.6546 11.7637 39.618 11.7637ZM38.1077 8.60905C38.1077 7.63838 38.7118 6.97105 39.618 6.97105C40.5116 6.97105 41.1157 7.63838 41.1157 8.60905C41.1157 9.57972 40.5116 10.2471 39.618 10.2471C38.7118 10.2471 38.1077 9.57972 38.1077 8.60905ZM46.1482 11.7637C47.6333 11.7637 48.6402 10.8658 48.6402 9.81025C48.6402 7.33505 45.2294 8.13585 45.2294 7.16518C45.2294 6.8983 45.5189 6.72843 45.9342 6.72843C46.3622 6.72843 46.8782 6.98318 47.0418 7.54132L48.527 6.94678C48.2375 6.06105 47.1677 5.45438 45.8713 5.45438C44.4743 5.45438 43.6058 6.25518 43.6058 7.21372C43.6058 9.53118 46.9663 8.88812 46.9663 9.84665C46.9663 10.1864 46.6391 10.417 46.1482 10.417C45.4434 10.417 44.9525 9.94376 44.8015 9.3735L43.3164 9.93158C43.6436 10.8537 44.6001 11.7637 46.1482 11.7637ZM53.4241 11.606L53.2982 10.0651C53.0843 10.1743 52.8074 10.2106 52.5808 10.2106C52.1278 10.2106 51.8257 9.89523 51.8257 9.34918V7.03172H53.3612V5.55145H51.8257V3.78001H49.9755V5.55145H48.9687V7.03172H49.9755V9.57972C49.9755 11.06 51.0202 11.7637 52.3921 11.7637C52.7696 11.7637 53.122 11.7031 53.4241 11.606ZM59.8749 3.17334V6.47358H56.376V3.17334H54.3874V11.6667H56.376V8.11158H59.8749V11.6667H61.8761V3.17334H59.8749ZM66.2899 11.7637C68.2281 11.7637 69.6378 10.429 69.6378 8.60905C69.6378 6.78905 68.2281 5.45438 66.2899 5.45438C64.3265 5.45438 62.942 6.78905 62.942 8.60905C62.942 10.429 64.3265 11.7637 66.2899 11.7637ZM64.7796 8.60905C64.7796 7.63838 65.3837 6.97105 66.2899 6.97105C67.1835 6.97105 67.7876 7.63838 67.7876 8.60905C67.7876 9.57972 67.1835 10.2471 66.2899 10.2471C65.3837 10.2471 64.7796 9.57972 64.7796 8.60905ZM73.2088 11.4725C73.901 11.4725 74.5177 11.242 74.845 10.8416V11.424C74.845 12.1034 74.2786 12.5767 73.4102 12.5767C72.7935 12.5767 72.2523 12.2854 72.1642 11.788L70.4776 12.0428C70.7042 13.1955 71.925 13.972 73.4102 13.972C75.361 13.972 76.6574 12.8679 76.6574 11.2298V5.55145H74.8324V6.07318C74.4926 5.69705 73.9136 5.45438 73.171 5.45438C71.409 5.45438 70.3014 6.61918 70.3014 8.46345C70.3014 10.3077 71.409 11.4725 73.2088 11.4725ZM72.1012 8.46345C72.1012 7.55345 72.655 6.97105 73.5109 6.97105C74.3793 6.97105 74.9331 7.55345 74.9331 8.46345C74.9331 9.37345 74.3793 9.95585 73.5109 9.95585C72.655 9.95585 72.1012 9.37345 72.1012 8.46345Z\"\n fill=\"currentColor\"\n />\n </g>\n </g>\n <defs>\n <clipPath id=\"clip0_2415_6911\">\n <rect width=\"76\" height=\"14\" fill=\"white\" transform=\"translate(0.5)\" />\n </clipPath>\n </defs>\n </svg>\n)\nexport const checkSVG = (\n <svg width=\"16\" height=\"12\" viewBox=\"0 0 16 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M5.30769 10.6923L4.77736 11.2226C4.91801 11.3633 5.10878 11.4423 5.30769 11.4423C5.5066 11.4423 5.69737 11.3633 5.83802 11.2226L5.30769 10.6923ZM15.5303 1.53033C15.8232 1.23744 15.8232 0.762563 15.5303 0.46967C15.2374 0.176777 14.7626 0.176777 14.4697 0.46967L15.5303 1.53033ZM1.53033 5.85429C1.23744 5.56139 0.762563 5.56139 0.46967 5.85429C0.176777 6.14718 0.176777 6.62205 0.46967 6.91495L1.53033 5.85429ZM5.83802 11.2226L15.5303 1.53033L14.4697 0.46967L4.77736 10.162L5.83802 11.2226ZM0.46967 6.91495L4.77736 11.2226L5.83802 10.162L1.53033 5.85429L0.46967 6.91495Z\"\n fill=\"currentColor\"\n />\n </svg>\n)\n","import { h } from 'preact'\nimport { ProductTourStep, ProductTourAppearance } from '../../../posthog-product-tours-types'\nimport { renderTipTapContent } from '../product-tours-utils'\nimport { IconPosthogLogo, cancelSVG } from '../../surveys/icons'\n\nexport interface ProductTourTooltipInnerProps {\n step: ProductTourStep\n appearance?: ProductTourAppearance\n stepIndex: number\n totalSteps: number\n onNext?: () => void\n onPrevious?: () => void\n onDismiss?: () => void\n}\n\nexport function ProductTourTooltipInner({\n step,\n appearance,\n stepIndex,\n totalSteps,\n onNext,\n onPrevious,\n onDismiss,\n}: ProductTourTooltipInnerProps): h.JSX.Element {\n const whiteLabel = appearance?.whiteLabel ?? false\n const isLastStep = stepIndex >= totalSteps - 1\n const isFirstStep = stepIndex === 0\n const showNextButton = step.progressionTrigger === 'button' || step.type === 'modal'\n\n const isInteractive = !!(onNext || onPrevious || onDismiss)\n const cursorStyle = isInteractive ? undefined : { cursor: 'default' }\n\n return (\n <>\n <button class=\"ph-tour-dismiss\" onClick={onDismiss} aria-label=\"Close tour\" style={cursorStyle}>\n {cancelSVG}\n </button>\n\n <div class=\"ph-tour-content\" dangerouslySetInnerHTML={{ __html: renderTipTapContent(step.content) }} />\n\n <div class=\"ph-tour-footer\">\n <span class=\"ph-tour-progress\">\n {stepIndex + 1} of {totalSteps}\n </span>\n\n <div class=\"ph-tour-buttons\">\n {!isFirstStep && (\n <button\n class=\"ph-tour-button ph-tour-button--secondary\"\n onClick={onPrevious}\n style={cursorStyle}\n >\n Back\n </button>\n )}\n {showNextButton && (\n <button class=\"ph-tour-button ph-tour-button--primary\" onClick={onNext} style={cursorStyle}>\n {isLastStep ? 'Done' : 'Next'}\n </button>\n )}\n </div>\n </div>\n\n {!whiteLabel && (\n <a\n href={isInteractive ? 'https://posthog.com/product-tours' : undefined}\n target={isInteractive ? '_blank' : undefined}\n rel={isInteractive ? 'noopener noreferrer' : undefined}\n class=\"ph-tour-branding\"\n style={isInteractive ? undefined : { cursor: 'default', pointerEvents: 'none' }}\n >\n Tour by {IconPosthogLogo}\n </a>\n )}\n </>\n )\n}\n","import { h } from 'preact'\nimport { useState, useRef, useEffect } from 'preact/hooks'\nimport { ProductTourStep, ProductTourAppearance, ProductTourSurveyQuestion } from '../../../posthog-product-tours-types'\nimport { cancelSVG, IconPosthogLogo } from '../../surveys/icons'\nimport {\n dissatisfiedEmoji,\n neutralEmoji,\n satisfiedEmoji,\n veryDissatisfiedEmoji,\n verySatisfiedEmoji,\n} from '../../surveys/icons'\n\nexport interface ProductTourSurveyStepInnerProps {\n step: ProductTourStep\n appearance?: ProductTourAppearance\n stepIndex: number\n totalSteps: number\n onPrevious?: () => void\n onSubmit?: (response: string | number | null) => void\n onDismiss?: () => void\n}\n\nconst threeScaleEmojis = [dissatisfiedEmoji, neutralEmoji, satisfiedEmoji]\nconst fiveScaleEmojis = [veryDissatisfiedEmoji, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, verySatisfiedEmoji]\n\nfunction getScaleNumbers(scale: number): number[] {\n switch (scale) {\n case 5:\n return [1, 2, 3, 4, 5]\n case 10:\n return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n default:\n return [1, 2, 3, 4, 5]\n }\n}\n\nfunction OpenTextInput({\n value,\n onChange,\n onSubmit,\n isInteractive,\n}: {\n value: string\n onChange: (text: string) => void\n onSubmit?: () => void\n isInteractive: boolean\n}): h.JSX.Element {\n const inputRef = useRef<HTMLTextAreaElement>(null)\n\n useEffect(() => {\n if (isInteractive) {\n setTimeout(() => inputRef.current?.focus(), 100)\n }\n }, [isInteractive])\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter' && e.metaKey && isInteractive) {\n e.preventDefault()\n onSubmit?.()\n }\n }\n\n return (\n <textarea\n ref={inputRef}\n class=\"ph-tour-survey-textarea\"\n rows={3}\n placeholder=\"Your feedback (optional)...\"\n value={value}\n onInput={(e) => onChange((e.target as HTMLTextAreaElement).value)}\n onKeyDown={handleKeyDown}\n disabled={!isInteractive}\n style={isInteractive ? undefined : { cursor: 'default' }}\n />\n )\n}\n\nfunction RatingInput({\n survey,\n onSubmit,\n isInteractive,\n}: {\n survey: ProductTourSurveyQuestion\n onSubmit?: (rating: number) => void\n isInteractive: boolean\n}): h.JSX.Element {\n const [selectedRating, setSelectedRating] = useState<number | null>(null)\n const display = survey.display || 'emoji'\n const scale = survey.scale || 5\n\n const handleSelect = (rating: number) => {\n if (!isInteractive) {\n return\n }\n setSelectedRating(rating)\n // Auto-submit on selection for ratings\n onSubmit?.(rating)\n }\n\n if (display === 'emoji') {\n const emojis = scale === 3 ? threeScaleEmojis : fiveScaleEmojis\n return (\n <div class=\"ph-tour-survey-rating-container\">\n <div class=\"ph-tour-survey-rating-emoji\">\n {emojis.map((emoji, idx) => {\n const rating = idx + 1\n const isActive = selectedRating === rating\n return (\n <button\n key={idx}\n type=\"button\"\n class={`ph-tour-survey-emoji-button ${isActive ? 'ph-tour-survey-emoji-button--active' : ''}`}\n onClick={() => handleSelect(rating)}\n style={isInteractive ? undefined : { cursor: 'default' }}\n aria-label={`Rate ${rating}`}\n >\n {emoji}\n </button>\n )\n })}\n </div>\n {(survey.lowerBoundLabel || survey.upperBoundLabel) && (\n <div class=\"ph-tour-survey-rating-labels\">\n <span>{survey.lowerBoundLabel}</span>\n <span>{survey.upperBoundLabel}</span>\n </div>\n )}\n </div>\n )\n }\n\n // Number display\n const numbers = getScaleNumbers(scale)\n return (\n <div class=\"ph-tour-survey-rating-container\">\n <div\n class=\"ph-tour-survey-rating-numbers\"\n style={{ gridTemplateColumns: `repeat(${numbers.length}, minmax(0, 1fr))` }}\n >\n {numbers.map((num) => {\n const isActive = selectedRating === num\n return (\n <button\n key={num}\n type=\"button\"\n class={`ph-tour-survey-number-button ${isActive ? 'ph-tour-survey-number-button--active' : ''}`}\n onClick={() => handleSelect(num)}\n style={isInteractive ? undefined : { cursor: 'default' }}\n aria-label={`Rate ${num}`}\n >\n {num}\n </button>\n )\n })}\n </div>\n {(survey.lowerBoundLabel || survey.upperBoundLabel) && (\n <div class=\"ph-tour-survey-rating-labels\">\n <span>{survey.lowerBoundLabel}</span>\n <span>{survey.upperBoundLabel}</span>\n </div>\n )}\n </div>\n )\n}\n\nexport function ProductTourSurveyStepInner({\n step,\n appearance,\n stepIndex,\n totalSteps,\n onPrevious,\n onSubmit,\n onDismiss,\n}: ProductTourSurveyStepInnerProps): h.JSX.Element {\n const [textValue, setTextValue] = useState('')\n const survey = step.survey\n const whiteLabel = appearance?.whiteLabel ?? false\n const isFirstStep = stepIndex === 0\n const isOpenText = survey?.type === 'open'\n\n const isInteractive = !!(onPrevious || onSubmit || onDismiss)\n const cursorStyle = isInteractive ? undefined : { cursor: 'default' }\n\n const handleTextSubmit = () => {\n onSubmit?.(textValue.trim() || null)\n }\n\n if (!survey) {\n return <div />\n }\n\n return (\n <>\n <button class=\"ph-tour-dismiss\" onClick={onDismiss} aria-label=\"Close survey\" style={cursorStyle}>\n {cancelSVG}\n </button>\n\n <div class=\"ph-tour-survey-question\">{survey.questionText}</div>\n\n {isOpenText ? (\n <OpenTextInput\n value={textValue}\n onChange={setTextValue}\n onSubmit={handleTextSubmit}\n isInteractive={isInteractive}\n />\n ) : (\n <RatingInput survey={survey} onSubmit={onSubmit} isInteractive={isInteractive} />\n )}\n\n <div class=\"ph-tour-footer\">\n <span class=\"ph-tour-progress\">\n {stepIndex + 1} of {totalSteps}\n </span>\n\n <div class=\"ph-tour-buttons\">\n {!isFirstStep && (\n <button\n class=\"ph-tour-button ph-tour-button--secondary\"\n onClick={onPrevious}\n style={cursorStyle}\n >\n Back\n </button>\n )}\n {isOpenText && (\n <button\n class=\"ph-tour-button ph-tour-button--primary\"\n onClick={handleTextSubmit}\n style={cursorStyle}\n >\n Submit\n </button>\n )}\n </div>\n </div>\n\n {!whiteLabel && (\n <a\n href={isInteractive ? 'https://posthog.com/product-tours' : undefined}\n target={isInteractive ? '_blank' : undefined}\n rel={isInteractive ? 'noopener noreferrer' : undefined}\n class=\"ph-tour-branding\"\n style={isInteractive ? undefined : { cursor: 'default', pointerEvents: 'none' }}\n >\n Survey by {IconPosthogLogo}\n </a>\n )}\n </>\n )\n}\n","import { h } from 'preact'\nimport { useEffect, useState, useCallback, useRef } from 'preact/hooks'\nimport { ProductTour, ProductTourStep, ProductTourDismissReason } from '../../../posthog-product-tours-types'\nimport { calculateTooltipPosition, getSpotlightStyle, TooltipPosition } from '../product-tours-utils'\nimport { addEventListener } from '../../../utils'\nimport { window as _window } from '../../../utils/globals'\nimport { ProductTourTooltipInner } from './ProductTourTooltipInner'\nimport { ProductTourSurveyStepInner } from './ProductTourSurveyStepInner'\nimport { isNull } from '@posthog/core'\n\nconst window = _window as Window & typeof globalThis\n\ntype TransitionState = 'entering' | 'visible' | 'exiting'\n\nexport interface ProductTourTooltipProps {\n tour: ProductTour\n step: ProductTourStep\n stepIndex: number\n totalSteps: number\n targetElement: HTMLElement | null\n onNext: () => void\n onPrevious: () => void\n onDismiss: (reason: ProductTourDismissReason) => void\n onSurveySubmit?: (response: string | number | null) => void\n}\n\nfunction getOppositePosition(position: TooltipPosition): TooltipPosition {\n const opposites: Record<TooltipPosition, TooltipPosition> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n }\n return opposites[position]\n}\n\nfunction scrollToElement(element: HTMLElement, resolve: () => void): void {\n const initialRect = element.getBoundingClientRect()\n const viewportHeight = window.innerHeight\n const viewportWidth = window.innerWidth\n\n const safeMarginY = viewportHeight / 6\n const safeMarginX = viewportWidth / 6\n\n const isInSafeZone =\n initialRect.top >= safeMarginY &&\n initialRect.bottom <= viewportHeight - safeMarginY &&\n initialRect.left >= safeMarginX &&\n initialRect.right <= viewportWidth - safeMarginX\n\n if (isInSafeZone) {\n resolve()\n return\n }\n\n element.scrollIntoView({ behavior: 'smooth', block: 'center' })\n\n let lastTop = initialRect.top\n let stableCount = 0\n let resolved = false\n\n const checkStability = () => {\n if (resolved) return\n\n const currentRect = element.getBoundingClientRect()\n if (Math.abs(currentRect.top - lastTop) < 1) {\n stableCount++\n if (stableCount >= 3) {\n resolved = true\n resolve()\n return\n }\n } else {\n stableCount = 0\n }\n lastTop = currentRect.top\n setTimeout(checkStability, 50)\n }\n\n setTimeout(checkStability, 30)\n\n setTimeout(() => {\n if (!resolved) {\n resolved = true\n resolve()\n }\n }, 500)\n}\n\nconst TRANSITION_DURATION = 150\n\nexport function ProductTourTooltip({\n tour,\n step,\n stepIndex,\n totalSteps,\n targetElement,\n onNext,\n onPrevious,\n onDismiss,\n onSurveySubmit,\n}: ProductTourTooltipProps): h.JSX.Element {\n const [transitionState, setTransitionState] = useState<TransitionState>('entering')\n const [position, setPosition] = useState<ReturnType<typeof calculateTooltipPosition> | null>(null)\n const [spotlightStyle, setSpotlightStyle] = useState<ReturnType<typeof getSpotlightStyle> | null>(null)\n\n const [displayedStep, setDisplayedStep] = useState(step)\n const [displayedStepIndex, setDisplayedStepIndex] = useState(stepIndex)\n\n const previousStepRef = useRef(stepIndex)\n const isTransitioningRef = useRef(false)\n\n // Modal and survey steps are both centered on screen\n const isCentered = displayedStep.type === 'modal' || displayedStep.type === 'survey'\n\n const updatePosition = useCallback(() => {\n if (!targetElement) return\n const rect = targetElement.getBoundingClientRect()\n setPosition(calculateTooltipPosition(rect))\n setSpotlightStyle(getSpotlightStyle(rect))\n }, [targetElement])\n\n useEffect(() => {\n const currentStepIndex = stepIndex\n const isStepChange = previousStepRef.current !== stepIndex\n\n const finishEntering = () => {\n if (previousStepRef.current !== currentStepIndex) return\n setTransitionState('visible')\n isTransitioningRef.current = false\n }\n\n const enterStep = () => {\n // Only scroll/position for element steps\n if (targetElement && step.type === 'element') {\n scrollToElement(targetElement, () => {\n if (previousStepRef.current !== currentStepIndex) return\n updatePosition()\n setTimeout(finishEntering, 50)\n })\n } else {\n setTimeout(finishEntering, 50)\n }\n }\n\n if (!isStepChange) {\n previousStepRef.current = stepIndex\n isTransitioningRef.current = true\n enterStep()\n return\n }\n\n previousStepRef.current = stepIndex\n isTransitioningRef.current = true\n setTransitionState('exiting')\n\n setTimeout(() => {\n if (previousStepRef.current !== currentStepIndex) return\n\n // Reset position for element steps to prevent flash at old position\n if (step.type === 'element') {\n setPosition(null)\n setSpotlightStyle(null)\n }\n\n setDisplayedStep(step)\n setDisplayedStepIndex(stepIndex)\n setTransitionState('entering')\n\n enterStep()\n }, TRANSITION_DURATION)\n }, [targetElement, stepIndex, step, updatePosition])\n\n useEffect(() => {\n if (transitionState !== 'visible' || isCentered) return\n\n const handleUpdate = () => {\n if (!isTransitioningRef.current) {\n updatePosition()\n }\n }\n\n addEventListener(window, 'scroll', handleUpdate as EventListener, { capture: true })\n addEventListener(window, 'resize', handleUpdate as EventListener)\n\n return () => {\n window?.removeEventListener('scroll', handleUpdate, true)\n window?.removeEventListener('resize', handleUpdate)\n }\n }, [updatePosition, transitionState, isCentered])\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n onDismiss('escape_key')\n }\n }\n addEventListener(window, 'keydown', handleKeyDown as EventListener)\n return () => {\n window?.removeEventListener('keydown', handleKeyDown)\n }\n }, [onDismiss])\n\n const handleOverlayClick = (e: MouseEvent) => {\n e.stopPropagation()\n onDismiss('user_clicked_outside')\n }\n\n const handleTooltipClick = (e: MouseEvent) => {\n e.stopPropagation()\n }\n\n const handleSpotlightClick = (e: MouseEvent) => {\n e.stopPropagation()\n if (targetElement) {\n targetElement.click()\n }\n onNext()\n }\n\n const isVisible = transitionState === 'visible'\n const isSurvey = displayedStep.type === 'survey'\n\n // For element steps, don't render until position is calculated\n const isPositionReady = isCentered || !isNull(position)\n\n const tooltipStyle = isCentered\n ? {\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n }\n : {\n top: position ? `${position.top}px` : '0',\n left: position ? `${position.left}px` : '0',\n }\n\n return (\n <div class=\"ph-tour-container\">\n <div class=\"ph-tour-click-overlay\" onClick={handleOverlayClick} />\n\n {/* Modal overlay - visible for centered steps */}\n <div\n class=\"ph-tour-modal-overlay\"\n style={{\n opacity: isCentered && isVisible ? 1 : 0,\n transition: `opacity ${TRANSITION_DURATION}ms ease-out`,\n pointerEvents: isCentered ? 'auto' : 'none',\n }}\n />\n\n {/* Spotlight - visible for element steps */}\n <div\n class=\"ph-tour-spotlight\"\n style={{\n ...(isVisible && isPositionReady && spotlightStyle\n ? spotlightStyle\n : { top: '50%', left: '50%', width: '0px', height: '0px' }),\n opacity: !isCentered && isVisible && isPositionReady ? 1 : 0,\n transition: `opacity ${TRANSITION_DURATION}ms ease-out`,\n ...(displayedStep.progressionTrigger === 'click' &&\n !isCentered && {\n pointerEvents: 'auto',\n cursor: 'pointer',\n }),\n }}\n onClick={displayedStep.progressionTrigger === 'click' && !isCentered ? handleSpotlightClick : undefined}\n />\n\n <div\n class={`ph-tour-tooltip ${isCentered ? 'ph-tour-tooltip--modal' : ''} ${isSurvey ? 'ph-tour-survey-step' : ''}`}\n style={{\n ...tooltipStyle,\n opacity: isVisible && isPositionReady ? 1 : 0,\n transition: `opacity ${TRANSITION_DURATION}ms ease-out`,\n }}\n onClick={handleTooltipClick}\n >\n {!isCentered && position && (\n <div class={`ph-tour-arrow ph-tour-arrow--${getOppositePosition(position.position)}`} />\n )}\n\n {isSurvey ? (\n <ProductTourSurveyStepInner\n step={displayedStep}\n appearance={tour.appearance}\n stepIndex={displayedStepIndex}\n totalSteps={totalSteps}\n onSubmit={onSurveySubmit}\n onPrevious={onPrevious}\n onDismiss={() => onDismiss('user_clicked_skip')}\n />\n ) : (\n <ProductTourTooltipInner\n step={displayedStep}\n appearance={tour.appearance}\n stepIndex={displayedStepIndex}\n totalSteps={totalSteps}\n onNext={onNext}\n onPrevious={onPrevious}\n onDismiss={() => onDismiss('user_clicked_skip')}\n />\n )}\n </div>\n </div>\n )\n}\n","/**\n * uuidv7: An experimental implementation of the proposed UUID Version 7\n *\n * @license Apache-2.0\n * @copyright 2021-2023 LiosK\n * @packageDocumentation\n *\n * from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts\n */\n\n// polyfill for IE11\nimport { window } from './utils/globals'\n\nimport { isNumber, isUndefined } from '@posthog/core'\n\nif (!Math.trunc) {\n Math.trunc = function (v) {\n return v < 0 ? Math.ceil(v) : Math.floor(v)\n }\n}\n\n// polyfill for IE11\nif (!Number.isInteger) {\n Number.isInteger = function (value) {\n return isNumber(value) && isFinite(value) && Math.floor(value) === value\n }\n}\n\nconst DIGITS = '0123456789abcdef'\n\n/** Represents a UUID as a 16-byte byte array. */\nexport class UUID {\n /** @param bytes - The 16-byte byte array representation. */\n constructor(readonly bytes: Readonly<Uint8Array>) {\n if (bytes.length !== 16) {\n throw new TypeError('not 128-bit length')\n }\n }\n\n /**\n * Builds a byte array from UUIDv7 field values.\n *\n * @param unixTsMs - A 48-bit `unix_ts_ms` field value.\n * @param randA - A 12-bit `rand_a` field value.\n * @param randBHi - The higher 30 bits of 62-bit `rand_b` field value.\n * @param randBLo - The lower 32 bits of 62-bit `rand_b` field value.\n */\n static fromFieldsV7(unixTsMs: number, randA: number, randBHi: number, randBLo: number): UUID {\n if (\n !Number.isInteger(unixTsMs) ||\n !Number.isInteger(randA) ||\n !Number.isInteger(randBHi) ||\n !Number.isInteger(randBLo) ||\n unixTsMs < 0 ||\n randA < 0 ||\n randBHi < 0 ||\n randBLo < 0 ||\n unixTsMs > 0xffff_ffff_ffff ||\n randA > 0xfff ||\n randBHi > 0x3fff_ffff ||\n randBLo > 0xffff_ffff\n ) {\n throw new RangeError('invalid field value')\n }\n\n const bytes = new Uint8Array(16)\n bytes[0] = unixTsMs / 2 ** 40\n bytes[1] = unixTsMs / 2 ** 32\n bytes[2] = unixTsMs / 2 ** 24\n bytes[3] = unixTsMs / 2 ** 16\n bytes[4] = unixTsMs / 2 ** 8\n bytes[5] = unixTsMs\n bytes[6] = 0x70 | (randA >>> 8)\n bytes[7] = randA\n bytes[8] = 0x80 | (randBHi >>> 24)\n bytes[9] = randBHi >>> 16\n bytes[10] = randBHi >>> 8\n bytes[11] = randBHi\n bytes[12] = randBLo >>> 24\n bytes[13] = randBLo >>> 16\n bytes[14] = randBLo >>> 8\n bytes[15] = randBLo\n return new UUID(bytes)\n }\n\n /** @returns The 8-4-4-4-12 canonical hexadecimal string representation. */\n toString(): string {\n let text = ''\n for (let i = 0; i < this.bytes.length; i++) {\n text = text + DIGITS.charAt(this.bytes[i] >>> 4) + DIGITS.charAt(this.bytes[i] & 0xf)\n if (i === 3 || i === 5 || i === 7 || i === 9) {\n text += '-'\n }\n }\n\n if (text.length !== 36) {\n // We saw one customer whose bundling code was mangling the UUID generation\n // rather than accept a bad UUID, we throw an error here.\n throw new Error('Invalid UUIDv7 was generated')\n }\n return text\n }\n\n /** Creates an object from `this`. */\n clone(): UUID {\n return new UUID(this.bytes.slice(0))\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n equals(other: UUID): boolean {\n return this.compareTo(other) === 0\n }\n\n /**\n * Returns a negative integer, zero, or positive integer if `this` is less\n * than, equal to, or greater than `other`, respectively.\n */\n compareTo(other: UUID): number {\n for (let i = 0; i < 16; i++) {\n const diff = this.bytes[i] - other.bytes[i]\n if (diff !== 0) {\n return Math.sign(diff)\n }\n }\n return 0\n }\n}\n\n/** Encapsulates the monotonic counter state. */\nclass V7Generator {\n private _timestamp = 0\n private _counter = 0\n private readonly _random = new DefaultRandom()\n\n /**\n * Generates a new UUIDv7 object from the current timestamp, or resets the\n * generator upon significant timestamp rollback.\n *\n * This method returns monotonically increasing UUIDs unless the up-to-date\n * timestamp is significantly (by ten seconds or more) smaller than the one\n * embedded in the immediately preceding UUID. If such a significant clock\n * rollback is detected, this method resets the generator and returns a new\n * UUID based on the current timestamp.\n */\n generate(): UUID {\n const value = this.generateOrAbort()\n if (!isUndefined(value)) {\n return value\n } else {\n // reset state and resume\n this._timestamp = 0\n const valueAfterReset = this.generateOrAbort()\n if (isUndefined(valueAfterReset)) {\n throw new Error('Could not generate UUID after timestamp reset')\n }\n return valueAfterReset\n }\n }\n\n /**\n * Generates a new UUIDv7 object from the current timestamp, or returns\n * `undefined` upon significant timestamp rollback.\n *\n * This method returns monotonically increasing UUIDs unless the up-to-date\n * timestamp is significantly (by ten seconds or more) smaller than the one\n * embedded in the immediately preceding UUID. If such a significant clock\n * rollback is detected, this method aborts and returns `undefined`.\n */\n generateOrAbort(): UUID | undefined {\n const MAX_COUNTER = 0x3ff_ffff_ffff\n const ROLLBACK_ALLOWANCE = 10_000 // 10 seconds\n\n const ts = Date.now()\n if (ts > this._timestamp) {\n this._timestamp = ts\n this._resetCounter()\n } else if (ts + ROLLBACK_ALLOWANCE > this._timestamp) {\n // go on with previous timestamp if new one is not much smaller\n this._counter++\n if (this._counter > MAX_COUNTER) {\n // increment timestamp at counter overflow\n this._timestamp++\n this._resetCounter()\n }\n } else {\n // abort if clock went backwards to unbearable extent\n return undefined\n }\n\n return UUID.fromFieldsV7(\n this._timestamp,\n Math.trunc(this._counter / 2 ** 30),\n this._counter & (2 ** 30 - 1),\n this._random.nextUint32()\n )\n }\n\n /** Initializes the counter at a 42-bit random integer. */\n private _resetCounter(): void {\n this._counter = this._random.nextUint32() * 0x400 + (this._random.nextUint32() & 0x3ff)\n }\n}\n\n/** A global flag to force use of cryptographically strong RNG. */\ndeclare const UUIDV7_DENY_WEAK_RNG: boolean\n\n/** Stores `crypto.getRandomValues()` available in the environment. */\nlet getRandomValues: <T extends Uint8Array | Uint32Array>(buffer: T) => T = (buffer) => {\n // fall back on Math.random() unless the flag is set to true\n // TRICKY: don't use the isUndefined method here as can't pass the reference\n if (typeof UUIDV7_DENY_WEAK_RNG !== 'undefined' && UUIDV7_DENY_WEAK_RNG) {\n throw new Error('no cryptographically strong RNG available')\n }\n\n for (let i = 0; i < buffer.length; i++) {\n buffer[i] = Math.trunc(Math.random() * 0x1_0000) * 0x1_0000 + Math.trunc(Math.random() * 0x1_0000)\n }\n return buffer\n}\n\n// detect Web Crypto API\nif (window && !isUndefined(window.crypto) && crypto.getRandomValues) {\n getRandomValues = (buffer) => crypto.getRandomValues(buffer)\n}\n\n/**\n * Wraps `crypto.getRandomValues()` and compatibles to enable buffering; this\n * uses a small buffer by default to avoid unbearable throughput decline in some\n * environments as well as the waste of time and space for unused values.\n */\nclass DefaultRandom {\n private readonly _buffer = new Uint32Array(8)\n private _cursor = Infinity\n nextUint32(): number {\n if (this._cursor >= this._buffer.length) {\n getRandomValues(this._buffer)\n this._cursor = 0\n }\n return this._buffer[this._cursor++]\n }\n}\n\nlet defaultGenerator: V7Generator | undefined\n\n/**\n * Generates a UUIDv7 string.\n *\n * @returns The 8-4-4-4-12 canonical hexadecimal string representation\n * (\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\").\n */\nexport const uuidv7 = (): string => uuidv7obj().toString()\n\n/** Generates a UUIDv7 object. */\nconst uuidv7obj = (): UUID => (defaultGenerator || (defaultGenerator = new V7Generator())).generate()\n\nexport const uuid7ToTimestampMs = (uuid: string): number => {\n // remove hyphens\n const hex = uuid.replace(/-/g, '')\n // ensure that it's a version 7 UUID\n if (hex.length !== 32) {\n throw new Error('Not a valid UUID')\n }\n if (hex[12] !== '7') {\n throw new Error('Not a UUIDv7')\n }\n // the first 6 bytes are the timestamp, which means that we can read only the first 12 hex characters\n return parseInt(hex.substring(0, 12), 16)\n}\n","import { extend } from './utils'\nimport { PersistentStore, Properties } from './types'\nimport {\n DEVICE_ID,\n DISTINCT_ID,\n ENABLE_PERSON_PROCESSING,\n INITIAL_PERSON_INFO,\n SESSION_ID,\n SESSION_RECORDING_IS_SAMPLED,\n} from './constants'\n\nimport { isNull, isUndefined } from '@posthog/core'\nimport { logger } from './utils/logger'\nimport { window, document } from './utils/globals'\nimport { uuidv7 } from './uuidv7'\n\n// we store the discovered subdomain in memory because it might be read multiple times\nlet firstNonPublicSubDomain = ''\n\n// helper to allow tests to clear this \"cache\"\nexport const resetSubDomainCache = () => {\n firstNonPublicSubDomain = ''\n}\n\n/**\n * Browsers don't offer a way to check if something is a public suffix\n * e.g. `.com.au`, `.io`, `.org.uk`\n *\n * But they do reject cookies set on public suffixes\n * Setting a cookie on `.co.uk` would mean it was sent for every `.co.uk` site visited\n *\n * So, we can use this to check if a domain is a public suffix\n * by trying to set a cookie on a subdomain of the provided hostname\n * until the browser accepts it\n *\n * inspired by https://github.com/AngusFu/browser-root-domain\n */\nexport function seekFirstNonPublicSubDomain(hostname: string, cookieJar = document): string {\n if (firstNonPublicSubDomain) {\n return firstNonPublicSubDomain\n }\n\n if (!cookieJar) {\n return ''\n }\n if (['localhost', '127.0.0.1'].includes(hostname)) return ''\n\n const list = hostname.split('.')\n let len = Math.min(list.length, 8) // paranoia - we know this number should be small\n const key = 'dmn_chk_' + uuidv7()\n\n while (!firstNonPublicSubDomain && len--) {\n const candidate = list.slice(len).join('.')\n const candidateCookieValue = key + '=1;domain=.' + candidate + ';path=/'\n\n // try to set cookie, include a short expiry in seconds since we'll check immediately\n cookieJar.cookie = candidateCookieValue + ';max-age=3'\n\n if (cookieJar.cookie.includes(key)) {\n // the cookie was accepted by the browser, remove the test cookie\n cookieJar.cookie = candidateCookieValue + ';max-age=0'\n firstNonPublicSubDomain = candidate\n }\n }\n\n return firstNonPublicSubDomain\n}\n\nconst DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\\.[a-z]{2,}$/i\nconst originalCookieDomainFn = (hostname: string): string => {\n const matches = hostname.match(DOMAIN_MATCH_REGEX)\n return matches ? matches[0] : ''\n}\n\nexport function chooseCookieDomain(hostname: string, cross_subdomain: boolean | undefined): string {\n if (cross_subdomain) {\n // NOTE: Could we use this for cross domain tracking?\n let matchedSubDomain = seekFirstNonPublicSubDomain(hostname)\n\n if (!matchedSubDomain) {\n const originalMatch = originalCookieDomainFn(hostname)\n if (originalMatch !== matchedSubDomain) {\n logger.info('Warning: cookie subdomain discovery mismatch', originalMatch, matchedSubDomain)\n }\n matchedSubDomain = originalMatch\n }\n\n return matchedSubDomain ? '; domain=.' + matchedSubDomain : ''\n }\n return ''\n}\n\n// Methods partially borrowed from quirksmode.org/js/cookies.html\nexport const cookieStore: PersistentStore = {\n _is_supported: () => !!document,\n\n _error: function (msg) {\n logger.error('cookieStore error: ' + msg)\n },\n\n _get: function (name) {\n if (!document) {\n return\n }\n\n try {\n const nameEQ = name + '='\n const ca = document.cookie.split(';').filter((x) => x.length)\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i]\n while (c.charAt(0) == ' ') {\n c = c.substring(1, c.length)\n }\n if (c.indexOf(nameEQ) === 0) {\n return decodeURIComponent(c.substring(nameEQ.length, c.length))\n }\n }\n } catch {}\n return null\n },\n\n _parse: function (name) {\n let cookie\n try {\n cookie = JSON.parse(cookieStore._get(name)) || {}\n } catch {\n // noop\n }\n return cookie\n },\n\n _set: function (name, value, days, cross_subdomain, is_secure) {\n if (!document) {\n return\n }\n try {\n let expires = '',\n secure = ''\n\n const cdomain = chooseCookieDomain(document.location.hostname, cross_subdomain)\n\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)\n expires = '; expires=' + date.toUTCString()\n }\n\n if (is_secure) {\n secure = '; secure'\n }\n\n const new_cookie_val =\n name +\n '=' +\n encodeURIComponent(JSON.stringify(value)) +\n expires +\n '; SameSite=Lax; path=/' +\n cdomain +\n secure\n\n // 4096 bytes is the size at which some browsers (e.g. firefox) will not store a cookie, warn slightly before that\n if (new_cookie_val.length > 4096 * 0.9) {\n logger.warn('cookieStore warning: large cookie, len=' + new_cookie_val.length)\n }\n\n document.cookie = new_cookie_val\n return new_cookie_val\n } catch {\n return\n }\n },\n\n _remove: function (name, cross_subdomain) {\n if (!document?.cookie) {\n return\n }\n try {\n cookieStore._set(name, '', -1, cross_subdomain)\n } catch {\n return\n }\n },\n}\n\nlet _localStorage_supported: boolean | null = null\nexport const resetLocalStorageSupported = () => {\n _localStorage_supported = null\n}\n\nexport const localStore: PersistentStore = {\n _is_supported: function () {\n if (!isNull(_localStorage_supported)) {\n return _localStorage_supported\n }\n\n let supported = true\n if (!isUndefined(window)) {\n try {\n const key = '__mplssupport__',\n val = 'xyz'\n localStore._set(key, val)\n if (localStore._get(key) !== '\"xyz\"') {\n supported = false\n }\n localStore._remove(key)\n } catch {\n supported = false\n }\n } else {\n supported = false\n }\n if (!supported) {\n logger.error('localStorage unsupported; falling back to cookie store')\n }\n\n _localStorage_supported = supported\n return supported\n },\n\n _error: function (msg) {\n logger.error('localStorage error: ' + msg)\n },\n\n _get: function (name) {\n try {\n return window?.localStorage.getItem(name)\n } catch (err) {\n localStore._error(err)\n }\n return null\n },\n\n _parse: function (name) {\n try {\n return JSON.parse(localStore._get(name)) || {}\n } catch {\n // noop\n }\n return null\n },\n\n _set: function (name, value) {\n try {\n window?.localStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n localStore._error(err)\n }\n },\n\n _remove: function (name) {\n try {\n window?.localStorage.removeItem(name)\n } catch (err) {\n localStore._error(err)\n }\n },\n}\n\n// Use localstorage for most data but still use cookie for COOKIE_PERSISTED_PROPERTIES\n// This solves issues with cookies having too much data in them causing headers too large\n// Also makes sure we don't have to send a ton of data to the server\nconst COOKIE_PERSISTED_PROPERTIES = [\n DEVICE_ID,\n DISTINCT_ID,\n SESSION_ID,\n SESSION_RECORDING_IS_SAMPLED,\n ENABLE_PERSON_PROCESSING,\n INITIAL_PERSON_INFO,\n]\n\n/**\n * Creates a localPlusCookieStore instance with custom cookie-persisted properties\n */\nexport const createLocalPlusCookieStore = (customCookieProperties: readonly string[] = []): PersistentStore => {\n const cookiePropertiesToPersist = [...COOKIE_PERSISTED_PROPERTIES, ...customCookieProperties]\n\n return {\n ...localStore,\n _parse: function (name) {\n try {\n let cookieProperties: Properties = {}\n try {\n // See if there's a cookie stored with data.\n cookieProperties = cookieStore._parse(name) || {}\n } catch {}\n const value = extend(cookieProperties, JSON.parse(localStore._get(name) || '{}'))\n localStore._set(name, value)\n return value\n } catch {\n // noop\n }\n return null\n },\n\n _set: function (name, value, days, cross_subdomain, is_secure, debug) {\n try {\n localStore._set(name, value, undefined, undefined, debug)\n const cookiePersistedProperties: Record<string, any> = {}\n cookiePropertiesToPersist.forEach((key) => {\n if (value[key]) {\n cookiePersistedProperties[key] = value[key]\n }\n })\n\n if (Object.keys(cookiePersistedProperties).length) {\n cookieStore._set(name, cookiePersistedProperties, days, cross_subdomain, is_secure, debug)\n }\n } catch (err) {\n localStore._error(err)\n }\n },\n\n _remove: function (name, cross_subdomain) {\n try {\n window?.localStorage.removeItem(name)\n cookieStore._remove(name, cross_subdomain)\n } catch (err) {\n localStore._error(err)\n }\n },\n }\n}\n\nconst memoryStorage: Properties = {}\n\n// Storage that only lasts the length of the pageview if we don't want to use cookies\nexport const memoryStore: PersistentStore = {\n _is_supported: function () {\n return true\n },\n\n _error: function (msg) {\n logger.error('memoryStorage error: ' + msg)\n },\n\n _get: function (name) {\n return memoryStorage[name] || null\n },\n\n _parse: function (name) {\n return memoryStorage[name] || null\n },\n\n _set: function (name, value) {\n memoryStorage[name] = value\n },\n\n _remove: function (name) {\n delete memoryStorage[name]\n },\n}\n\nlet sessionStorageSupported: boolean | null = null\nexport const resetSessionStorageSupported = () => {\n sessionStorageSupported = null\n}\n// Storage that only lasts the length of a tab/window. Survives page refreshes\nexport const sessionStore: PersistentStore = {\n _is_supported: function () {\n if (!isNull(sessionStorageSupported)) {\n return sessionStorageSupported\n }\n sessionStorageSupported = true\n if (!isUndefined(window)) {\n try {\n const key = '__support__',\n val = 'xyz'\n sessionStore._set(key, val)\n if (sessionStore._get(key) !== '\"xyz\"') {\n sessionStorageSupported = false\n }\n sessionStore._remove(key)\n } catch {\n sessionStorageSupported = false\n }\n } else {\n sessionStorageSupported = false\n }\n return sessionStorageSupported\n },\n\n _error: function (msg) {\n logger.error('sessionStorage error: ', msg)\n },\n\n _get: function (name) {\n try {\n return window?.sessionStorage.getItem(name)\n } catch (err) {\n sessionStore._error(err)\n }\n return null\n },\n\n _parse: function (name) {\n try {\n return JSON.parse(sessionStore._get(name)) || null\n } catch {\n // noop\n }\n return null\n },\n\n _set: function (name, value) {\n try {\n window?.sessionStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n sessionStore._error(err)\n }\n },\n\n _remove: function (name) {\n try {\n window?.sessionStorage.removeItem(name)\n } catch (err) {\n sessionStore._error(err)\n }\n },\n}\n","export const TOUR_COMPLETED_KEY_PREFIX = 'ph_product_tour_completed_'\nexport const TOUR_DISMISSED_KEY_PREFIX = 'ph_product_tour_dismissed_'\nexport const ACTIVE_TOUR_SESSION_KEY = 'ph_active_product_tour'\n","import { ProductTour } from '../posthog-product-tours-types'\n\nexport function doesTourActivateByEvent(tour: Pick<ProductTour, 'conditions'>): boolean {\n return !!(tour.conditions?.events && tour.conditions.events.values?.length > 0)\n}\n\nexport function doesTourActivateByAction(tour: Pick<ProductTour, 'conditions'>): boolean {\n return !!(tour.conditions?.actions && tour.conditions.actions.values?.length > 0)\n}\n","export class SimpleEventEmitter {\n private _events: { [key: string]: ((...args: any[]) => void)[] } = {}\n\n constructor() {\n this._events = {}\n }\n\n on(event: string, listener: (...args: any[]) => void): () => void {\n if (!this._events[event]) {\n this._events[event] = []\n }\n this._events[event].push(listener)\n\n return () => {\n this._events[event] = this._events[event].filter((x) => x !== listener)\n }\n }\n\n emit(event: string, payload: any): void {\n for (const listener of this._events[event] || []) {\n listener(payload)\n }\n for (const listener of this._events['*'] || []) {\n listener(event, payload)\n }\n }\n}\n","import { isNullish } from '@posthog/core'\n\nexport function extractHref(elementsChain: string): string {\n const match = elementsChain.match(/(?::|\")href=\"(.*?)\"/)\n return match ? match[1] : ''\n}\n\nexport function extractTexts(elementsChain: string): string[] {\n const texts: string[] = []\n const regex = /(?::|\")text=\"(.*?)\"/g\n let match\n while (!isNullish((match = regex.exec(elementsChain)))) {\n if (!texts.includes(match[1])) {\n texts.push(match[1])\n }\n }\n return texts\n}\n\nexport function matchString(\n value: string | undefined | null,\n pattern: string,\n matching: 'exact' | 'contains' | 'regex'\n): boolean {\n if (isNullish(value)) return false\n switch (matching) {\n case 'exact':\n return value === pattern\n case 'contains': {\n // Simulating SQL LIKE behavior (_ = any single character, % = any zero or more characters)\n const likePattern = pattern\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/_/g, '.')\n .replace(/%/g, '.*')\n return new RegExp(likePattern, 'i').test(value)\n }\n case 'regex':\n try {\n return new RegExp(pattern).test(value)\n } catch {\n return false\n }\n default:\n return false\n }\n}\n\nexport function matchTexts(texts: string[], pattern: string, matching: 'exact' | 'contains' | 'regex'): boolean {\n return texts.some((text) => matchString(text, pattern, matching))\n}\n","import { PostHog } from '../../posthog-core'\nimport { ActionStepType, PropertyFilters, SurveyActionType, SurveyElement } from '../../posthog-surveys-types'\nimport { SimpleEventEmitter } from '../../utils/simple-event-emitter'\nimport { CaptureResult, PropertyMatchType } from '../../types'\nimport { isArray, isUndefined } from '@posthog/core'\nimport { matchPropertyFilters } from '../../utils/property-utils'\nimport { extractTexts, extractHref, matchString, matchTexts } from '../../utils/elements-chain-utils'\n\nexport class ActionMatcher {\n private readonly _actionRegistry?: Set<SurveyActionType>\n private readonly _instance?: PostHog\n private readonly _actionEvents: Set<string>\n private _debugEventEmitter = new SimpleEventEmitter()\n\n constructor(instance?: PostHog) {\n this._instance = instance\n this._actionEvents = new Set<string>()\n this._actionRegistry = new Set<SurveyActionType>()\n }\n\n init() {\n if (!isUndefined(this._instance?._addCaptureHook)) {\n const matchEventToAction = (eventName: string, eventPayload: any) => {\n this.on(eventName, eventPayload)\n }\n this._instance?._addCaptureHook(matchEventToAction)\n }\n }\n\n register(actions: SurveyActionType[]): void {\n if (isUndefined(this._instance?._addCaptureHook)) {\n return\n }\n\n actions.forEach((action) => {\n this._actionRegistry?.add(action)\n action.steps?.forEach((step) => {\n this._actionEvents?.add(step?.event || '')\n })\n })\n\n if (this._instance?.autocapture) {\n const selectorsToWatch: Set<string> = new Set<string>()\n actions.forEach((action) => {\n action.steps?.forEach((step) => {\n if (step?.selector) {\n selectorsToWatch.add(step?.selector)\n }\n })\n })\n this._instance?.autocapture.setElementSelectors(selectorsToWatch)\n }\n }\n\n on(eventName: string, eventPayload?: CaptureResult) {\n if (eventPayload == null || eventName.length == 0) {\n return\n }\n\n if (!this._actionEvents.has(eventName) && !this._actionEvents.has(<string>eventPayload?.event)) {\n return\n }\n\n if (this._actionRegistry && this._actionRegistry?.size > 0) {\n this._actionRegistry.forEach((action) => {\n if (this._checkAction(eventPayload, action)) {\n this._debugEventEmitter.emit('actionCaptured', action.name)\n }\n })\n }\n }\n\n _addActionHook(callback: (actionName: string, eventPayload?: any) => void): void {\n this.onAction('actionCaptured', (data) => callback(data))\n }\n\n private _checkAction(event?: CaptureResult, action?: SurveyActionType): boolean {\n if (action?.steps == null) {\n return false\n }\n\n for (const step of action.steps) {\n if (this._checkStep(event, step)) {\n return true\n }\n }\n\n return false\n }\n\n onAction(event: 'actionCaptured', cb: (...args: any[]) => void): () => void {\n return this._debugEventEmitter.on(event, cb)\n }\n\n private _checkStep = (event?: CaptureResult, step?: ActionStepType): boolean => {\n return (\n this._checkStepEvent(event, step) &&\n this._checkStepUrl(event, step) &&\n this._checkStepElement(event, step) &&\n this._checkStepProperties(event, step)\n )\n }\n\n private _checkStepEvent = (event?: CaptureResult, step?: ActionStepType): boolean => {\n // CHECK CONDITIONS, OTHERWISE SKIPPED\n if (step?.event && event?.event !== step?.event) {\n return false // EVENT NAME IS A MISMATCH\n }\n return true\n }\n\n private _checkStepUrl(event?: CaptureResult, step?: ActionStepType): boolean {\n // CHECK CONDITIONS, OTHERWISE SKIPPED\n if (step?.url) {\n const eventUrl = event?.properties?.$current_url\n if (!eventUrl || typeof eventUrl !== 'string') {\n return false\n }\n if (!matchString(eventUrl, step.url, step.url_matching || 'contains')) {\n return false\n }\n }\n return true\n }\n\n private _checkStepElement(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!this._checkStepHref(event, step)) return false\n if (!this._checkStepText(event, step)) return false\n if (!this._checkStepSelector(event, step)) return false\n return true\n }\n\n private _checkStepHref(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!step?.href) return true\n\n const elements = this._getElementsList(event)\n if (elements.length > 0) {\n return elements.some((el) => matchString(el.href, step.href!, step.href_matching || 'exact'))\n }\n\n const chain = (event?.properties?.$elements_chain as string) || ''\n if (chain) {\n return matchString(extractHref(chain), step.href, step.href_matching || 'exact')\n }\n\n return false\n }\n\n private _checkStepText(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!step?.text) return true\n\n const elements = this._getElementsList(event)\n if (elements.length > 0) {\n return elements.some(\n (el) =>\n matchString(el.text, step.text!, step.text_matching || 'exact') ||\n matchString(el.$el_text, step.text!, step.text_matching || 'exact')\n )\n }\n\n const chain = (event?.properties?.$elements_chain as string) || ''\n if (chain) {\n return matchTexts(extractTexts(chain), step.text, step.text_matching || 'exact')\n }\n\n return false\n }\n\n private _checkStepSelector(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!step?.selector) return true\n\n // check exact match on $element_selectors from autocapture\n const elementSelectors = event?.properties?.$element_selectors as string[] | undefined\n if (elementSelectors?.includes(step.selector)) {\n return true\n }\n\n // check against compiled regex\n const chain = (event?.properties?.$elements_chain as string) || ''\n if (step.selector_regex && chain) {\n try {\n return new RegExp(step.selector_regex).test(chain)\n } catch {\n return false\n }\n }\n\n return false\n }\n\n private _getElementsList(event?: CaptureResult): SurveyElement[] {\n if (event?.properties?.$elements == null) {\n return []\n }\n\n return event?.properties.$elements as unknown as SurveyElement[]\n }\n\n private _checkStepProperties(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!step?.properties || step.properties.length === 0) {\n return true\n }\n\n // transform to match same property format as normal events\n const propertyFilters: PropertyFilters = step.properties.reduce<PropertyFilters>((acc, filter) => {\n const values = isArray(filter.value)\n ? filter.value.map(String)\n : filter.value != null\n ? [String(filter.value)]\n : []\n\n acc[filter.key] = {\n values,\n operator: (filter.operator || 'exact') as PropertyMatchType,\n }\n return acc\n }, {})\n\n return matchPropertyFilters(propertyFilters, event?.properties)\n }\n}\n","import { SurveyActionType, SurveyEventType, SurveyEventWithFilters } from '../posthog-surveys-types'\nimport { ActionMatcher } from '../extensions/surveys/action-matcher'\nimport { PostHog } from '../posthog-core'\nimport { CaptureResult } from '../types'\nimport { matchPropertyFilters } from './property-utils'\nimport { isUndefined } from '@posthog/core'\nimport { createLogger } from './logger'\n\n/**\n * Interface for items that can be triggered by events/actions.\n * Both Survey and ProductTour implement this interface.\n */\nexport interface EventTriggerable {\n id: string\n conditions?: {\n events?: { repeatedActivation?: boolean; values: SurveyEventWithFilters[] } | null\n cancelEvents?: { values: SurveyEventWithFilters[] } | null\n actions?: { values: SurveyActionType[] } | null\n } | null\n}\n\n/**\n * Abstract base class for receiving events and matching them to triggerable items.\n * Subclasses implement type-specific behavior for surveys and product tours.\n */\nexport abstract class EventReceiver<T extends EventTriggerable> {\n // eventToItems is a mapping of event name to all the items that are activated by it\n protected _eventToItems: Map<string, string[]>\n // cancelEventToItems is a mapping of event name to all the items that should be cancelled by it\n protected _cancelEventToItems: Map<string, string[]>\n // actionToItems is a mapping of action name to all the items that are activated by it\n protected readonly _actionToItems: Map<string, string[]>\n // actionMatcher can look at CaptureResult payloads and match an event to its corresponding action.\n protected _actionMatcher?: ActionMatcher | null\n protected readonly _instance?: PostHog\n\n constructor(instance: PostHog) {\n this._instance = instance\n this._eventToItems = new Map<string, string[]>()\n this._cancelEventToItems = new Map<string, string[]>()\n this._actionToItems = new Map<string, string[]>()\n }\n\n // Abstract methods for subclasses to implement\n protected abstract _getActivatedKey(): string\n protected abstract _getShownEventName(): string\n protected abstract _getItems(callback: (items: T[]) => void): void\n protected abstract _cancelPendingItem(itemId: string): void\n protected abstract _getLogger(): ReturnType<typeof createLogger>\n /** Check if item is permanently ineligible (e.g. completed/dismissed). Skip adding to activated list. */\n protected abstract _isItemPermanentlyIneligible(itemId?: string): boolean\n\n private _doesEventMatchFilter(\n eventConfig: SurveyEventWithFilters | undefined,\n eventPayload?: CaptureResult\n ): boolean {\n if (!eventConfig) {\n return false\n }\n\n return matchPropertyFilters(eventConfig.propertyFilters, eventPayload?.properties)\n }\n\n private _buildEventToItemMap(items: T[], conditionField: SurveyEventType): Map<string, string[]> {\n const map = new Map<string, string[]>()\n items.forEach((item) => {\n item.conditions?.[conditionField]?.values?.forEach((event) => {\n if (event?.name) {\n const existing = map.get(event.name) || []\n existing.push(item.id)\n map.set(event.name, existing)\n }\n })\n })\n return map\n }\n\n /**\n * build a map of (Event1) => [Item1, Item2, Item3]\n * used for items that should be [activated|cancelled] by Event1\n */\n private _getMatchingItems(\n eventName: string,\n eventPayload: CaptureResult | undefined,\n conditionField: SurveyEventType\n ): T[] {\n const itemIdMap = conditionField === SurveyEventType.Activation ? this._eventToItems : this._cancelEventToItems\n const itemIds = itemIdMap.get(eventName)\n\n let items: T[] = []\n this._getItems((allItems) => {\n items = allItems.filter((item) => itemIds?.includes(item.id))\n })\n\n return items.filter((item) => {\n const eventConfig = item.conditions?.[conditionField]?.values?.find((e) => e.name === eventName)\n return this._doesEventMatchFilter(eventConfig, eventPayload)\n })\n }\n\n register(items: T[]): void {\n if (isUndefined(this._instance?._addCaptureHook)) {\n return\n }\n\n this._setupEventBasedItems(items)\n this._setupActionBasedItems(items)\n }\n\n private _setupActionBasedItems(items: T[]) {\n const actionBasedItems = items.filter(\n (item: T) => item.conditions?.actions && item.conditions?.actions?.values?.length > 0\n )\n\n if (actionBasedItems.length === 0) {\n return\n }\n\n if (this._actionMatcher == null) {\n this._actionMatcher = new ActionMatcher(this._instance)\n this._actionMatcher.init()\n // match any actions to its corresponding item.\n const matchActionToItem = (actionName: string) => {\n this.onAction(actionName)\n }\n\n this._actionMatcher._addActionHook(matchActionToItem)\n }\n\n actionBasedItems.forEach((item) => {\n if (\n item.conditions &&\n item.conditions?.actions &&\n item.conditions?.actions?.values &&\n item.conditions?.actions?.values?.length > 0\n ) {\n // register the known set of actions with\n // the action-matcher so it can match\n // events to actions\n this._actionMatcher?.register(item.conditions.actions.values)\n\n // maintain a mapping of (Action1) => [Item1, Item2, Item3]\n // where Items 1-3 are all activated by Action1\n item.conditions?.actions?.values?.forEach((action) => {\n if (action && action.name) {\n const knownItems: string[] | undefined = this._actionToItems.get(action.name)\n if (knownItems) {\n knownItems.push(item.id)\n }\n this._actionToItems.set(action.name, knownItems || [item.id])\n }\n })\n }\n })\n }\n\n private _setupEventBasedItems(items: T[]) {\n const eventBasedItems = items.filter(\n (item: T) => item.conditions?.events && item.conditions?.events?.values?.length > 0\n )\n\n const itemsWithCancelEvents = items.filter(\n (item: T) => item.conditions?.cancelEvents && item.conditions?.cancelEvents?.values?.length > 0\n )\n\n if (eventBasedItems.length === 0 && itemsWithCancelEvents.length === 0) {\n return\n }\n\n // match any events to its corresponding item.\n const matchEventToItem = (eventName: string, eventPayload?: CaptureResult) => {\n this.onEvent(eventName, eventPayload)\n }\n this._instance?._addCaptureHook(matchEventToItem)\n\n this._eventToItems = this._buildEventToItemMap(items, SurveyEventType.Activation)\n this._cancelEventToItems = this._buildEventToItemMap(items, SurveyEventType.Cancellation)\n }\n\n onEvent(event: string, eventPayload?: CaptureResult): void {\n const logger = this._getLogger()\n const activatedKey = this._getActivatedKey()\n const shownEventName = this._getShownEventName()\n\n const existingActivatedItems: string[] = this._instance?.persistence?.props[activatedKey] || []\n if (shownEventName === event && eventPayload && existingActivatedItems.length > 0) {\n // remove item from activatedItems here.\n logger.info('event matched, removing item from activated items', {\n event,\n eventPayload,\n existingActivatedItems,\n })\n const itemId = eventPayload?.properties?.$survey_id || eventPayload?.properties?.$product_tour_id\n if (itemId) {\n const index = existingActivatedItems.indexOf(itemId)\n if (index >= 0) {\n existingActivatedItems.splice(index, 1)\n this._updateActivatedItems(existingActivatedItems)\n }\n }\n\n return\n }\n\n // check if this event should cancel any pending items\n if (this._cancelEventToItems.has(event)) {\n const itemsToCancel = this._getMatchingItems(event, eventPayload, SurveyEventType.Cancellation)\n\n if (itemsToCancel.length > 0) {\n logger.info('cancel event matched, cancelling items', {\n event,\n itemsToCancel: itemsToCancel.map((s) => s.id),\n })\n\n itemsToCancel.forEach((item) => {\n // remove from activated items\n const index = existingActivatedItems.indexOf(item.id)\n if (index >= 0) {\n existingActivatedItems.splice(index, 1)\n }\n // cancel any pending timeout for this item\n this._cancelPendingItem(item.id)\n })\n\n this._updateActivatedItems(existingActivatedItems)\n }\n }\n\n // if the event is not in the eventToItems map, nothing else to do\n if (!this._eventToItems.has(event)) {\n return\n }\n\n logger.info('event name matched', {\n event,\n eventPayload,\n items: this._eventToItems.get(event),\n })\n\n const matchedItems = this._getMatchingItems(event, eventPayload, SurveyEventType.Activation)\n\n this._updateActivatedItems(existingActivatedItems.concat(matchedItems.map((item) => item.id) || []))\n }\n\n onAction(actionName: string): void {\n const activatedKey = this._getActivatedKey()\n const existingActivatedItems: string[] = this._instance?.persistence?.props[activatedKey] || []\n if (this._actionToItems.has(actionName)) {\n this._updateActivatedItems(existingActivatedItems.concat(this._actionToItems.get(actionName) || []))\n }\n }\n\n private _updateActivatedItems(activatedItems: string[]) {\n const logger = this._getLogger()\n const activatedKey = this._getActivatedKey()\n // Filter out permanently ineligible items and remove duplicates\n const eligibleItems = [...new Set(activatedItems)].filter(\n (itemId) => !this._isItemPermanentlyIneligible(itemId)\n )\n logger.info('updating activated items', {\n activatedItems: eligibleItems,\n })\n\n this._instance?.persistence?.register({\n [activatedKey]: eligibleItems,\n })\n }\n\n getActivatedIds(): string[] {\n const activatedKey = this._getActivatedKey()\n const existingActivatedItems = this._instance?.persistence?.props[activatedKey]\n return existingActivatedItems ? existingActivatedItems : []\n }\n\n getEventToItemsMap(): Map<string, string[]> {\n return this._eventToItems\n }\n\n _getActionMatcher(): ActionMatcher | null | undefined {\n return this._actionMatcher\n }\n}\n","import { PRODUCT_TOURS_ACTIVATED } from '../constants'\nimport { ProductTour } from '../posthog-product-tours-types'\nimport { PostHog } from '../posthog-core'\nimport { EventReceiver } from './event-receiver'\nimport { createLogger } from './logger'\nimport { localStore } from '../storage'\nimport { TOUR_COMPLETED_KEY_PREFIX, TOUR_DISMISSED_KEY_PREFIX } from '../extensions/product-tours/constants'\n\nconst logger = createLogger('[Product Tour Event Receiver]')\n\nexport class ProductTourEventReceiver extends EventReceiver<ProductTour> {\n constructor(instance: PostHog) {\n super(instance)\n }\n\n protected _getActivatedKey(): string {\n return PRODUCT_TOURS_ACTIVATED\n }\n\n protected _getShownEventName(): string {\n return 'product tour shown'\n }\n\n protected _getItems(callback: (items: ProductTour[]) => void): void {\n this._instance?.productTours?.getProductTours(callback)\n }\n\n protected _cancelPendingItem(itemId: string): void {\n this._instance?.productTours?.cancelPendingTour(itemId)\n }\n\n protected _getLogger(): ReturnType<typeof createLogger> {\n return logger\n }\n\n protected _isItemPermanentlyIneligible(itemId?: string): boolean {\n if (!itemId) return true\n const completedKey = `${TOUR_COMPLETED_KEY_PREFIX}${itemId}`\n const dismissedKey = `${TOUR_DISMISSED_KEY_PREFIX}${itemId}`\n return !!(localStore._get(completedKey) || localStore._get(dismissedKey))\n }\n\n getTours(): string[] {\n return this.getActivatedIds()\n }\n}\n","/*\n * Constants\n */\n\n/* PROPERTY KEYS */\n\n// This key is deprecated, but we want to check for it to see whether aliasing is allowed.\nexport const PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id'\nexport const DISTINCT_ID = 'distinct_id'\nexport const DEVICE_ID = '$device_id'\nexport const ALIAS_ID_KEY = '__alias'\nexport const CAMPAIGN_IDS_KEY = '__cmpns'\nexport const EVENT_TIMERS_KEY = '__timers'\nexport const AUTOCAPTURE_DISABLED_SERVER_SIDE = '$autocapture_disabled_server_side'\nexport const HEATMAPS_ENABLED_SERVER_SIDE = '$heatmaps_enabled_server_side'\nexport const EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE = '$exception_capture_enabled_server_side'\nexport const ERROR_TRACKING_SUPPRESSION_RULES = '$error_tracking_suppression_rules'\nexport const ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS = '$error_tracking_capture_extension_exceptions'\nexport const WEB_VITALS_ENABLED_SERVER_SIDE = '$web_vitals_enabled_server_side'\nexport const DEAD_CLICKS_ENABLED_SERVER_SIDE = '$dead_clicks_enabled_server_side'\nexport const PRODUCT_TOURS_ENABLED_SERVER_SIDE = '$product_tours_enabled_server_side'\nexport const WEB_VITALS_ALLOWED_METRICS = '$web_vitals_allowed_metrics'\nexport const SESSION_RECORDING_REMOTE_CONFIG = '$session_recording_remote_config'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side'\n// @deprecated can be removed along with eager loaded replay\nexport const CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = '$console_log_recording_enabled_server_side'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE = '$session_recording_network_payload_capture'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_MASKING = '$session_recording_masking'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_CANVAS_RECORDING = '$session_recording_canvas_recording'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_SAMPLE_RATE = '$replay_sample_rate'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_MINIMUM_DURATION = '$replay_minimum_duration'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_SCRIPT_CONFIG = '$replay_script_config'\nexport const SESSION_RECORDING_OVERRIDE_SAMPLING = '$replay_override_sampling'\nexport const SESSION_RECORDING_OVERRIDE_LINKED_FLAG = '$replay_override_linked_flag'\nexport const SESSION_RECORDING_OVERRIDE_URL_TRIGGER = '$replay_override_url_trigger'\nexport const SESSION_RECORDING_OVERRIDE_EVENT_TRIGGER = '$replay_override_event_trigger'\nexport const SESSION_ID = '$sesid'\nexport const SESSION_RECORDING_IS_SAMPLED = '$session_is_sampled'\nexport const SESSION_RECORDING_PAST_MINIMUM_DURATION = '$session_past_minimum_duration'\nexport const SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION = '$session_recording_url_trigger_activated_session'\nexport const SESSION_RECORDING_EVENT_TRIGGER_ACTIVATED_SESSION = '$session_recording_event_trigger_activated_session'\nexport const ENABLED_FEATURE_FLAGS = '$enabled_feature_flags'\nexport const PERSISTENCE_EARLY_ACCESS_FEATURES = '$early_access_features'\nexport const PERSISTENCE_FEATURE_FLAG_DETAILS = '$feature_flag_details'\nexport const STORED_PERSON_PROPERTIES_KEY = '$stored_person_properties'\nexport const STORED_GROUP_PROPERTIES_KEY = '$stored_group_properties'\nexport const SURVEYS = '$surveys'\nexport const SURVEYS_ACTIVATED = '$surveys_activated'\nexport const PRODUCT_TOURS_ACTIVATED = '$product_tours_activated'\nexport const CONVERSATIONS = '$conversations'\nexport const FLAG_CALL_REPORTED = '$flag_call_reported'\nexport const USER_STATE = '$user_state'\nexport const CLIENT_SESSION_PROPS = '$client_session_props'\nexport const CAPTURE_RATE_LIMIT = '$capture_rate_limit'\n\n/** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */\nexport const INITIAL_CAMPAIGN_PARAMS = '$initial_campaign_params'\n/** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */\nexport const INITIAL_REFERRER_INFO = '$initial_referrer_info'\nexport const INITIAL_PERSON_INFO = '$initial_person_info'\nexport const ENABLE_PERSON_PROCESSING = '$epp'\nexport const TOOLBAR_ID = '__POSTHOG_TOOLBAR__'\nexport const TOOLBAR_CONTAINER_CLASS = 'toolbar-global-fade-container'\n\n/**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Sentinel value for distinct id, device id, session id. Signals that the server should generate the value\n * */\nexport const COOKIELESS_SENTINEL_VALUE = '$posthog_cookieless'\nexport const COOKIELESS_MODE_FLAG_PROPERTY = '$cookieless_mode'\n\nexport const WEB_EXPERIMENTS = '$web_experiments'\n\n// These are properties that are reserved and will not be automatically included in events\nexport const PERSISTENCE_RESERVED_PROPERTIES = [\n PEOPLE_DISTINCT_ID_KEY,\n ALIAS_ID_KEY,\n CAMPAIGN_IDS_KEY,\n EVENT_TIMERS_KEY,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n HEATMAPS_ENABLED_SERVER_SIDE,\n SESSION_ID,\n ENABLED_FEATURE_FLAGS,\n ERROR_TRACKING_SUPPRESSION_RULES,\n USER_STATE,\n PERSISTENCE_EARLY_ACCESS_FEATURES,\n PERSISTENCE_FEATURE_FLAG_DETAILS,\n STORED_GROUP_PROPERTIES_KEY,\n STORED_PERSON_PROPERTIES_KEY,\n SURVEYS,\n FLAG_CALL_REPORTED,\n CLIENT_SESSION_PROPS,\n CAPTURE_RATE_LIMIT,\n INITIAL_CAMPAIGN_PARAMS,\n INITIAL_REFERRER_INFO,\n ENABLE_PERSON_PROCESSING,\n INITIAL_PERSON_INFO,\n // Conversations keys (defined in lazy-loaded extension)\n '$conversations_widget_session_id',\n '$conversations_ticket_id',\n '$conversations_widget_state',\n '$conversations_user_traits',\n]\n\nexport const SURVEYS_REQUEST_TIMEOUT_MS = 10000\n","import { render } from 'preact'\nimport { PostHog } from '../../posthog-core'\nimport {\n ProductTour,\n ProductTourCallback,\n ProductTourDismissReason,\n ProductTourRenderReason,\n ShowTourOptions,\n} from '../../posthog-product-tours-types'\nimport { SurveyEventName, SurveyEventProperties } from '../../posthog-surveys-types'\nimport {\n addProductTourCSSVariablesToElement,\n findElementBySelector,\n getElementMetadata,\n getProductTourStylesheet,\n normalizeUrl,\n} from './product-tours-utils'\nimport { ProductTourTooltip } from './components/ProductTourTooltip'\nimport { createLogger } from '../../utils/logger'\nimport { document as _document, window as _window } from '../../utils/globals'\nimport { localStore, sessionStore } from '../../storage'\nimport { addEventListener } from '../../utils'\nimport { isNull, SurveyMatchType } from '@posthog/core'\nimport { propertyComparisons } from '../../utils/property-utils'\nimport { TOUR_COMPLETED_KEY_PREFIX, TOUR_DISMISSED_KEY_PREFIX, ACTIVE_TOUR_SESSION_KEY } from './constants'\nimport { doesTourActivateByAction, doesTourActivateByEvent } from '../../utils/product-tour-utils'\nimport { TOOLBAR_ID } from '../../constants'\nimport { ProductTourEventReceiver } from '../../utils/product-tour-event-receiver'\n\nconst logger = createLogger('[Product Tours]')\n\nconst document = _document as Document\nconst window = _window as Window & typeof globalThis\n\n// Tour condition checking - reuses the same URL matching logic as surveys\nfunction doesTourUrlMatch(tour: ProductTour): boolean {\n const conditions = tour.conditions\n if (!conditions?.url) {\n return true\n }\n\n const href = window?.location?.href\n if (!href) {\n return false\n }\n\n const matchType = conditions.urlMatchType || SurveyMatchType.Icontains\n\n if (matchType === SurveyMatchType.Exact) {\n return normalizeUrl(href) === normalizeUrl(conditions.url)\n }\n\n const targets = [conditions.url]\n return propertyComparisons[matchType](targets, [href])\n}\n\nfunction isTourInDateRange(tour: ProductTour): boolean {\n const now = new Date()\n\n if (tour.start_date) {\n const startDate = new Date(tour.start_date)\n if (now < startDate) {\n return false\n }\n }\n\n if (tour.end_date) {\n const endDate = new Date(tour.end_date)\n if (now > endDate) {\n return false\n }\n }\n\n return true\n}\n\nfunction checkTourConditions(tour: ProductTour): boolean {\n return isTourInDateRange(tour) && doesTourUrlMatch(tour)\n}\n\nconst CONTAINER_CLASS = 'ph-product-tour-container'\nconst TRIGGER_LISTENER_ATTRIBUTE = 'data-ph-tour-trigger'\nconst CHECK_INTERVAL_MS = 1000\n\ninterface TriggerListenerData {\n element: Element\n listener: (event: Event) => void\n tour: ProductTour\n}\n\nfunction retrieveTourShadow(tour: ProductTour): { shadow: ShadowRoot; isNewlyCreated: boolean } {\n const containerClass = `${CONTAINER_CLASS}-${tour.id}`\n const existingDiv = document.querySelector(`.${containerClass}`)\n\n if (existingDiv && existingDiv.shadowRoot) {\n return {\n shadow: existingDiv.shadowRoot,\n isNewlyCreated: false,\n }\n }\n\n const div = document.createElement('div')\n div.className = containerClass\n\n addProductTourCSSVariablesToElement(div, tour.appearance)\n\n const shadow = div.attachShadow({ mode: 'open' })\n\n const stylesheet = getProductTourStylesheet()\n if (stylesheet) {\n shadow.appendChild(stylesheet)\n }\n\n document.body.appendChild(div)\n\n return {\n shadow,\n isNewlyCreated: true,\n }\n}\n\nfunction removeTourFromDom(tourId: string): void {\n const containerClass = `${CONTAINER_CLASS}-${tourId}`\n const container = document.querySelector(`.${containerClass}`)\n if (container?.shadowRoot) {\n render(null, container.shadowRoot)\n }\n container?.remove()\n}\n\nexport class ProductTourManager {\n private _instance: PostHog\n private _activeTour: ProductTour | null = null\n private _currentStepIndex: number = 0\n private _isPreviewMode: boolean = false\n private _isResuming: boolean = false\n private _checkInterval: ReturnType<typeof setInterval> | null = null\n private _triggerSelectorListeners: Map<string, TriggerListenerData> = new Map()\n private _pendingTourTimeouts: Map<string, ReturnType<typeof setTimeout>> = new Map()\n private _eventReceiver: ProductTourEventReceiver\n private _registeredEventTourIds: Set<string> = new Set()\n\n constructor(instance: PostHog) {\n this._instance = instance\n this._eventReceiver = new ProductTourEventReceiver(instance)\n }\n\n private _setStepIndex(index: number): void {\n this._currentStepIndex = index\n this._saveSessionState()\n }\n\n private _saveSessionState(): void {\n if (!this._activeTour || this._isPreviewMode) {\n return\n }\n sessionStore._set(ACTIVE_TOUR_SESSION_KEY, {\n tourId: this._activeTour.id,\n stepIndex: this._currentStepIndex,\n })\n }\n\n private _clearSessionState(): void {\n sessionStore._remove(ACTIVE_TOUR_SESSION_KEY)\n }\n\n private _getSessionState(): { tourId: string; stepIndex: number } | null {\n const stored = sessionStore._get(ACTIVE_TOUR_SESSION_KEY)\n if (!stored) {\n return null\n }\n try {\n return JSON.parse(stored)\n } catch {\n return null\n }\n }\n\n start(): void {\n if (this._checkInterval) {\n return\n }\n\n // Check for saved session state before starting the evaluation loop\n const savedState = this._getSessionState()\n if (savedState) {\n this._resumeSavedTour(savedState.tourId, savedState.stepIndex, () => {\n this._startEvaluationLoop()\n })\n } else {\n this._startEvaluationLoop()\n }\n }\n\n private _startEvaluationLoop(): void {\n this._checkInterval = setInterval(() => {\n this._evaluateAndDisplayTours()\n }, CHECK_INTERVAL_MS)\n\n this._evaluateAndDisplayTours()\n addEventListener(document, 'visibilitychange', this._handleVisibilityChange)\n }\n\n private _resumeSavedTour(tourId: string, stepIndex: number, onComplete: () => void): void {\n this._instance.productTours?.getProductTours((tours) => {\n const tour = tours.find((t) => t.id === tourId)\n\n if (!tour) {\n if (tours.length > 0) {\n this._clearSessionState()\n }\n } else {\n this._activeTour = tour\n this._currentStepIndex = stepIndex\n this._isResuming = true\n this._renderCurrentStep()\n }\n\n onComplete()\n })\n }\n\n stop(): void {\n if (this._checkInterval) {\n clearInterval(this._checkInterval)\n this._checkInterval = null\n }\n document.removeEventListener('visibilitychange', this._handleVisibilityChange)\n this._removeAllTriggerListeners()\n this._cancelAllPendingTours()\n this._cleanup()\n }\n\n private _handleVisibilityChange = (): void => {\n if (document.hidden && this._checkInterval) {\n clearInterval(this._checkInterval)\n this._checkInterval = null\n } else if (!document.hidden && !this._checkInterval) {\n this._checkInterval = setInterval(() => {\n this._evaluateAndDisplayTours()\n }, CHECK_INTERVAL_MS)\n this._evaluateAndDisplayTours()\n }\n }\n\n private _evaluateAndDisplayTours(): void {\n if (document?.getElementById(TOOLBAR_ID)) {\n return\n }\n\n // Use getProductTours (not getActiveProductTours) because selector-triggered tours\n // should work even if completed/dismissed\n this._instance.productTours?.getProductTours((tours) => {\n if (tours.length === 0) {\n this._removeAllTriggerListeners()\n return\n }\n\n const activeTriggerTourIds = new Set<string>()\n\n const unregisteredEventTours = tours.filter(\n (tour: ProductTour) =>\n !this._registeredEventTourIds.has(tour.id) &&\n (doesTourActivateByEvent(tour) || doesTourActivateByAction(tour))\n )\n if (unregisteredEventTours.length > 0) {\n this._eventReceiver.register(unregisteredEventTours)\n unregisteredEventTours.forEach((tour) => this._registeredEventTourIds.add(tour.id))\n }\n\n const eventActivatedTourIds = this._activeTour ? [] : this._eventReceiver.getTours()\n\n /**\n * tours can be shown three ways, really:\n *\n * 1) selector clicks\n * 2a) auto-show immediately\n * 2b) auto-show after event/action\n *\n * (1) and (2[a|b]) are fully independent of each other\n */\n for (const tour of tours) {\n // 1) SELECTOR CLICK TRIGGER - just attach an event listener and keep going\n const triggerSelector = tour.conditions?.selector\n if (triggerSelector) {\n activeTriggerTourIds.add(tour.id)\n this._manageTriggerSelectorListener(tour, triggerSelector)\n }\n\n // skip auto-launch checks if a tour is already active\n if (this._activeTour) {\n continue\n }\n\n // 2) AUTO-LAUNCH\n const hasEventOrActionTriggers = doesTourActivateByAction(tour) || doesTourActivateByEvent(tour)\n\n if (tour.auto_launch && this._isTourEligible(tour)) {\n // tour should auto-launch, and the current session is eligible\n\n if (!hasEventOrActionTriggers) {\n // 2a) AUTO-SHOW WITH NO EVENT/ACTION\n this._showOrQueueTour(tour, 'auto')\n continue\n }\n\n // 2b) AUTO-SHOW, BUT WAIT FOR EVENT/ACTION\n if (eventActivatedTourIds.includes(tour.id)) {\n this._showOrQueueTour(tour, 'event')\n }\n }\n }\n\n this._triggerSelectorListeners.forEach(({ tour }) => {\n if (!activeTriggerTourIds.has(tour.id)) {\n this._removeTriggerSelectorListener(tour.id)\n }\n })\n })\n }\n\n private _showOrQueueTour(tour: ProductTour, reason: ProductTourRenderReason): void {\n const delaySeconds = tour.conditions?.autoShowDelaySeconds || 0\n if (delaySeconds > 0) {\n if (!this.isTourPending(tour.id)) {\n this.queueTourWithDelay(tour.id, delaySeconds, reason)\n }\n } else {\n this.showTour(tour, { reason })\n }\n }\n\n private _isTourEligible(tour: ProductTour): boolean {\n if (!checkTourConditions(tour)) {\n logger.info(`Tour ${tour.id} failed conditions check`)\n return false\n }\n\n const completedKey = `${TOUR_COMPLETED_KEY_PREFIX}${tour.id}`\n const dismissedKey = `${TOUR_DISMISSED_KEY_PREFIX}${tour.id}`\n\n if (localStore._get(completedKey) || localStore._get(dismissedKey)) {\n logger.info(`Tour ${tour.id} already completed or dismissed`)\n return false\n }\n\n if (tour.internal_targeting_flag_key) {\n const flagValue = this._instance.featureFlags?.getFeatureFlag(tour.internal_targeting_flag_key)\n if (!flagValue) {\n logger.info(`Tour ${tour.id} failed feature flag check: ${tour.internal_targeting_flag_key}`)\n return false\n }\n }\n\n return true\n }\n\n showTour(tour: ProductTour, options?: ShowTourOptions): void {\n const renderReason: ProductTourRenderReason = options?.reason ?? 'auto'\n\n this.cancelPendingTour(tour.id)\n\n // Validate all step selectors before showing the tour\n // Steps without selectors are modal steps and don't need validation\n const selectorFailures: Array<{\n stepIndex: number\n stepId: string\n selector: string\n error: string\n matchCount: number\n }> = []\n\n for (let i = 0; i < tour.steps.length; i++) {\n const step = tour.steps[i]\n\n // Skip validation for modal steps (no selector)\n if (!step.selector) {\n continue\n }\n\n const result = findElementBySelector(step.selector)\n\n if (result.error === 'not_found' || result.error === 'not_visible') {\n selectorFailures.push({\n stepIndex: i,\n stepId: step.id,\n selector: step.selector,\n error: result.error,\n matchCount: result.matchCount,\n })\n }\n }\n\n if (selectorFailures.length > 0) {\n // Emit events for each failed selector for debugging/data purposes\n for (const failure of selectorFailures) {\n this._captureEvent('product tour step selector failed', {\n $product_tour_id: tour.id,\n $product_tour_step_id: failure.stepId,\n $product_tour_step_order: failure.stepIndex,\n $product_tour_step_selector: failure.selector,\n $product_tour_error: failure.error,\n $product_tour_matches_count: failure.matchCount,\n $product_tour_failure_phase: 'validation',\n })\n }\n\n const failedSelectors = selectorFailures.map((f) => `Step ${f.stepIndex}: \"${f.selector}\" (${f.error})`)\n logger.warn(\n `Tour \"${tour.name}\" (${tour.id}): ${selectorFailures.length} selector(s) failed to match:\\n - ${failedSelectors.join('\\n - ')}${options?.enableStrictValidation === true ? '\\n\\nenableStrictValidation is true, not displaying tour.' : ''}`\n )\n if (options?.enableStrictValidation === true) return\n }\n\n this._activeTour = tour\n this._setStepIndex(0)\n\n this._captureEvent('product tour shown', {\n $product_tour_id: tour.id,\n $product_tour_name: tour.name,\n $product_tour_iteration: tour.current_iteration || 1,\n $product_tour_render_reason: renderReason,\n })\n\n this._renderCurrentStep()\n }\n\n showTourById(tourId: string, reason?: ProductTourRenderReason): void {\n logger.info(`showTourById(${tourId})`)\n this._instance.productTours?.getProductTours((tours) => {\n const tour = tours.find((t) => t.id === tourId)\n if (tour) {\n this.showTour(tour, { reason: reason ?? 'api' })\n } else {\n logger.warn('could not find tour', tourId)\n }\n })\n }\n\n previewTour(tour: ProductTour): void {\n logger.info(`Previewing tour ${tour.id}`)\n\n this._cleanup()\n\n this._isPreviewMode = true\n this._activeTour = tour\n this._currentStepIndex = 0\n\n this._renderCurrentStep()\n }\n\n nextStep = (): void => {\n if (!this._activeTour) {\n return\n }\n\n const currentStep = this._activeTour.steps[this._currentStepIndex]\n\n this._captureEvent('product tour step completed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: currentStep.id,\n $product_tour_step_order: this._currentStepIndex,\n })\n\n if (this._currentStepIndex < this._activeTour.steps.length - 1) {\n this._setStepIndex(this._currentStepIndex + 1)\n this._renderCurrentStep()\n } else {\n this._completeTour()\n }\n }\n\n previousStep = (): void => {\n if (!this._activeTour || this._currentStepIndex === 0) {\n return\n }\n\n this._setStepIndex(this._currentStepIndex - 1)\n this._renderCurrentStep()\n }\n\n dismissTour = (reason: ProductTourDismissReason = 'user_clicked_skip'): void => {\n if (!this._activeTour) {\n return\n }\n\n const currentStep = this._activeTour.steps[this._currentStepIndex]\n\n this._captureEvent('product tour dismissed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: currentStep.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_dismiss_reason: reason,\n })\n\n if (!this._isPreviewMode) {\n localStore._set(`${TOUR_DISMISSED_KEY_PREFIX}${this._activeTour.id}`, true)\n }\n\n window.dispatchEvent(\n new CustomEvent('PHProductTourDismissed', { detail: { tourId: this._activeTour.id, reason } })\n )\n\n this._cleanup()\n }\n\n private _completeTour(): void {\n if (!this._activeTour) {\n return\n }\n\n this._captureEvent('product tour completed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_steps_count: this._activeTour.steps.length,\n })\n\n if (!this._isPreviewMode) {\n localStore._set(`${TOUR_COMPLETED_KEY_PREFIX}${this._activeTour.id}`, true)\n\n this._instance.capture('$set', {\n $set: {\n [`$product_tour_completed/${this._activeTour.id}`]: true,\n },\n })\n }\n\n window.dispatchEvent(new CustomEvent('PHProductTourCompleted', { detail: { tourId: this._activeTour.id } }))\n\n this._cleanup()\n }\n\n private _renderCurrentStep(retryCount: number = 0): void {\n if (!this._activeTour) {\n return\n }\n\n const step = this._activeTour.steps[this._currentStepIndex]\n if (!step) {\n logger.warn(`Step ${this._currentStepIndex} not found in tour ${this._activeTour.id}`)\n this._cleanup()\n return\n }\n\n // Survey step - render native survey step component\n if (step.type === 'survey') {\n if (step.survey) {\n this._renderSurveyStep()\n } else {\n logger.warn('Unable to render survey step - survey data not found')\n }\n\n return\n }\n\n // Modal step (no selector) - render without a target element\n if (step.type === 'modal') {\n this._captureEvent('product tour step shown', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_type: 'modal',\n })\n\n this._isResuming = false\n this._renderTooltipWithPreact(null)\n return\n }\n\n if (!step.selector) {\n logger.warn('Unable to render element step - no selector defined.')\n return\n }\n\n const result = findElementBySelector(step.selector)\n\n const previousStep = this._currentStepIndex > 0 ? this._activeTour.steps[this._currentStepIndex - 1] : null\n const shouldWaitForElement = previousStep?.progressionTrigger === 'click' || this._isResuming\n\n // 2s total timeout\n const maxRetries = 20\n const retryTimeout = 100\n\n if (result.error === 'not_found' || result.error === 'not_visible') {\n // if previous step was click-to-progress, or we are resuming a tour,\n // give some time for the next element\n if (shouldWaitForElement && retryCount < maxRetries) {\n setTimeout(() => {\n this._renderCurrentStep(retryCount + 1)\n }, retryTimeout)\n return\n }\n\n const waitDurationMs = retryCount * retryTimeout\n\n this._captureEvent('product tour step selector failed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_selector: step.selector,\n $product_tour_error: result.error,\n $product_tour_matches_count: result.matchCount,\n $product_tour_failure_phase: 'runtime',\n $product_tour_waited_for_element: shouldWaitForElement,\n $product_tour_wait_duration_ms: waitDurationMs,\n })\n\n logger.warn(\n `Tour \"${this._activeTour.name}\" dismissed: element for step ${this._currentStepIndex} became unavailable (${result.error})` +\n (shouldWaitForElement ? ` after waiting ${waitDurationMs}ms` : '')\n )\n this.dismissTour('element_unavailable')\n return\n }\n\n if (result.error === 'multiple_matches') {\n this._captureEvent('product tour step selector failed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_selector: step.selector,\n $product_tour_error: result.error,\n $product_tour_matches_count: result.matchCount,\n $product_tour_failure_phase: 'runtime',\n })\n // Continue with first match for multiple_matches case\n }\n\n if (!result.element) {\n return\n }\n\n const element = result.element\n const metadata = getElementMetadata(element)\n\n this._captureEvent('product tour step shown', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_selector: step.selector,\n $product_tour_step_selector_found: true,\n $product_tour_step_element_tag: metadata.tag,\n $product_tour_step_element_id: metadata.id,\n $product_tour_step_element_classes: metadata.classes,\n $product_tour_step_element_text: metadata.text,\n })\n\n this._isResuming = false\n this._renderTooltipWithPreact(element)\n }\n\n private _renderTooltipWithPreact(\n element: HTMLElement | null,\n onSurveySubmit?: (response: string | number | null) => void,\n onDismissOverride?: (reason: ProductTourDismissReason) => void\n ): void {\n if (!this._activeTour) {\n return\n }\n\n const step = this._activeTour.steps[this._currentStepIndex]\n const { shadow } = retrieveTourShadow(this._activeTour)\n\n render(\n <ProductTourTooltip\n tour={this._activeTour}\n step={step}\n stepIndex={this._currentStepIndex}\n totalSteps={this._activeTour.steps.length}\n targetElement={element}\n onNext={this.nextStep}\n onPrevious={this.previousStep}\n onDismiss={onDismissOverride || this.dismissTour}\n onSurveySubmit={onSurveySubmit}\n />,\n shadow\n )\n }\n\n private _renderSurveyStep(): void {\n if (!this._activeTour) {\n return\n }\n\n const tourId = this._activeTour.id\n const step = this._activeTour.steps[this._currentStepIndex]\n const surveyId = step.linkedSurveyId\n const questionId = step.linkedSurveyQuestionId\n const questionText = step.survey?.questionText || ''\n\n this._captureEvent('product tour step shown', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_type: 'survey',\n $product_tour_linked_survey_id: surveyId,\n })\n\n this._captureEvent(SurveyEventName.SHOWN, {\n [SurveyEventProperties.SURVEY_ID]: surveyId,\n [SurveyEventProperties.PRODUCT_TOUR_ID]: tourId,\n sessionRecordingUrl: this._instance.get_session_replay_url?.(),\n })\n\n const handleSubmit = (response: string | number | null) => {\n const responseKey = questionId ? `$survey_response_${questionId}` : '$survey_response'\n this._captureEvent(SurveyEventName.SENT, {\n [SurveyEventProperties.SURVEY_ID]: surveyId,\n [SurveyEventProperties.PRODUCT_TOUR_ID]: tourId,\n [SurveyEventProperties.SURVEY_QUESTIONS]: [\n {\n id: questionId,\n question: questionText,\n response: response,\n },\n ],\n [SurveyEventProperties.SURVEY_COMPLETED]: true,\n sessionRecordingUrl: this._instance.get_session_replay_url?.(),\n ...(!isNull(response) && { [responseKey]: response }),\n })\n\n logger.info(`Survey ${surveyId} completed`, !isNull(response) ? `with response: ${response}` : '(skipped)')\n this.nextStep()\n }\n\n const handleDismiss = (reason: ProductTourDismissReason) => {\n this._captureEvent(SurveyEventName.DISMISSED, {\n [SurveyEventProperties.SURVEY_ID]: surveyId,\n [SurveyEventProperties.PRODUCT_TOUR_ID]: tourId,\n [SurveyEventProperties.SURVEY_QUESTIONS]: [\n {\n id: questionId,\n question: questionText,\n response: null,\n },\n ],\n [SurveyEventProperties.SURVEY_PARTIALLY_COMPLETED]: false,\n sessionRecordingUrl: this._instance.get_session_replay_url?.(),\n })\n\n logger.info(`Survey ${surveyId} dismissed`)\n this.dismissTour(reason)\n }\n\n this._renderTooltipWithPreact(null, handleSubmit, handleDismiss)\n\n logger.info(`Rendered survey step for tour step ${this._currentStepIndex}`)\n }\n\n private _cleanup(): void {\n if (this._activeTour) {\n removeTourFromDom(this._activeTour.id)\n }\n\n this._activeTour = null\n this._currentStepIndex = 0\n this._isPreviewMode = false\n this._isResuming = false\n this._clearSessionState()\n }\n\n private _manageTriggerSelectorListener(tour: ProductTour, selector: string): void {\n const currentElement = document.querySelector(selector)\n const existingListenerData = this._triggerSelectorListeners.get(tour.id)\n\n if (!currentElement) {\n if (existingListenerData) {\n this._removeTriggerSelectorListener(tour.id)\n }\n return\n }\n\n if (existingListenerData) {\n if (currentElement !== existingListenerData.element) {\n logger.info(`Trigger element changed for tour ${tour.id}. Re-attaching listener.`)\n this._removeTriggerSelectorListener(tour.id)\n } else {\n return\n }\n }\n\n if (!currentElement.hasAttribute(TRIGGER_LISTENER_ATTRIBUTE)) {\n const listener = (event: Event) => {\n event.stopPropagation()\n\n if (this._activeTour) {\n logger.info(`Tour ${tour.id} trigger clicked but another tour is active`)\n return\n }\n\n // manual triggers only check launch status, no other conditions\n if (!isTourInDateRange(tour)) {\n logger.warn(`Tour ${tour.id} trigger clicked, but tour is not launched - not showing tour.`)\n return\n }\n\n logger.info(`Tour ${tour.id} triggered by click on ${selector}`)\n this.showTour(tour, { reason: 'trigger' })\n }\n\n addEventListener(currentElement, 'click', listener)\n currentElement.setAttribute(TRIGGER_LISTENER_ATTRIBUTE, tour.id)\n this._triggerSelectorListeners.set(tour.id, { element: currentElement, listener, tour })\n logger.info(`Attached trigger listener for tour ${tour.id} on ${selector}`)\n }\n }\n\n private _removeTriggerSelectorListener(tourId: string): void {\n const existing = this._triggerSelectorListeners.get(tourId)\n if (existing) {\n existing.element.removeEventListener('click', existing.listener)\n existing.element.removeAttribute(TRIGGER_LISTENER_ATTRIBUTE)\n this._triggerSelectorListeners.delete(tourId)\n logger.info(`Removed trigger listener for tour ${tourId}`)\n }\n }\n\n private _removeAllTriggerListeners(): void {\n this._triggerSelectorListeners.forEach((_, tourId) => {\n this._removeTriggerSelectorListener(tourId)\n })\n }\n\n private _captureEvent(eventName: string, properties: Record<string, any>): void {\n if (this._isPreviewMode) {\n return\n }\n this._instance.capture(eventName, properties)\n }\n\n // Public API methods delegated from PostHogProductTours\n getActiveProductTours(callback: ProductTourCallback): void {\n this._instance.productTours?.getProductTours((tours, context) => {\n if (!context?.isLoaded) {\n callback([], context)\n return\n }\n\n const activeTours = tours.filter((tour) => this._isTourEligible(tour))\n callback(activeTours, context)\n })\n }\n\n resetTour(tourId: string): void {\n localStore._remove(`${TOUR_COMPLETED_KEY_PREFIX}${tourId}`)\n localStore._remove(`${TOUR_DISMISSED_KEY_PREFIX}${tourId}`)\n }\n\n resetAllTours(): void {\n const storage = window?.localStorage\n if (!storage) {\n return\n }\n const keysToRemove: string[] = []\n for (let i = 0; i < storage.length; i++) {\n const key = storage.key(i)\n if (key?.startsWith(TOUR_COMPLETED_KEY_PREFIX) || key?.startsWith(TOUR_DISMISSED_KEY_PREFIX)) {\n keysToRemove.push(key)\n }\n }\n keysToRemove.forEach((key) => localStore._remove(key))\n }\n\n cancelPendingTour(tourId: string): void {\n const timeout = this._pendingTourTimeouts.get(tourId)\n if (timeout) {\n clearTimeout(timeout)\n this._pendingTourTimeouts.delete(tourId)\n logger.info(`Cancelled pending tour: ${tourId}`)\n }\n }\n\n private _cancelAllPendingTours(): void {\n this._pendingTourTimeouts.forEach((timeout) => clearTimeout(timeout))\n this._pendingTourTimeouts.clear()\n }\n\n isTourPending(tourId: string): boolean {\n return this._pendingTourTimeouts.has(tourId)\n }\n\n queueTourWithDelay(tourId: string, delaySeconds: number, reason?: ProductTourRenderReason): void {\n logger.info(`Queueing tour ${tourId} with ${delaySeconds}s delay`)\n\n const timeoutId = setTimeout(() => {\n this._pendingTourTimeouts.delete(tourId)\n logger.info(`Delay elapsed for tour ${tourId}, showing now`)\n this.showTourById(tourId, reason)\n }, delaySeconds * 1000)\n\n this._pendingTourTimeouts.set(tourId, timeoutId)\n }\n}\n","import { PostHog } from '../../posthog-core'\nimport { document as _document } from '../../utils/globals'\nimport { ProductTourManager } from './product-tours'\n\nexport { ProductTourManager } from './product-tours'\nexport { findElementBySelector, getElementMetadata, getProductTourStylesheet } from './product-tours-utils'\n\nexport function generateProductTours(posthog: PostHog, isEnabled: boolean): ProductTourManager | undefined {\n if (!_document) {\n return\n }\n\n const manager = new ProductTourManager(posthog)\n\n if (isEnabled) {\n manager.start()\n }\n\n return manager\n}\n","import { generateProductTours } from '../extensions/product-tours'\nimport { assignableWindow } from '../utils/globals'\n\nassignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {}\nassignableWindow.__PosthogExtensions__.generateProductTours = generateProductTours\n\nexport default generateProductTours\n"],"names":["win","window","undefined","global","globalThis","self","File","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","assignableWindow","c","s","a","SurveyEventType","SurveyEventName","SurveyEventProperties","DEFAULT_PRODUCT_TOUR_APPEARANCE","backgroundColor","textColor","buttonColor","borderRadius","buttonBorderRadius","borderColor","fontFamily","boxShadow","showOverlay","whiteLabel","types_SurveyMatchType","SurveyMatchType","nativeIsArray","Array","isArray","type_utils_toString","Object","prototype","toString","obj","call","isUndefined","x","isNull","isNullish","_createLogger","prefix","_temp","debugEnabled","logger","_log","level","POSTHOG_DEBUG","console","consoleLog","_len","arguments","length","args","_key","info","_len2","_key2","warn","_len3","_key3","error","_len4","_key4","critical","_len5","_key5","uninitializedWarning","methodName","createLogger","additionalPrefix","options","prepareStylesheet","innerText","posthog","stylesheet","createElement","addEventListener","element","event","callback","capture","passive","sendBeacon","isMatchingRegex","value","pattern","str","RegExp","_unused","isValidRegex","test","_unused2","propertyComparisons","exact","targets","values","some","target","is_not","every","regex","not_regex","icontains","map","toLowerCase","includes","not_icontains","gt","numValue","parseFloat","isNaN","t","lt","v","matchPropertyFilters","propertyFilters","eventProperties","entries","_ref","propertyName","filter","eventPropertyValue","eventValues","String","comparisonFunction","operator","r","u","i","o","f","e","n","__b","__r","diffed","l","__c","m","unmount","d","__h","__H","__","push","__V","h","B","__N","setState","this","forEach","props","shouldComponentUpdate","componentWillUpdate","__e","p","__s","z","_","F","current","b","shift","__P","k","w","__v","requestAnimationFrame","j","g","clearTimeout","cancelAnimationFrame","setTimeout","BLACK_TEXT_COLOR","defaultSurveyAppearance","hex2rgb","startsWith","hexColor","replace","parseInt","slice","getContrastingTextColor","color","rgb","nameColorToHex","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","honeydew","hotpink","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","colorMatch","match","Math","sqrt","createContext","isPreviewMode","previewPageIndex","onPopupSurveyDismissed","isPopup","onPreviewSubmit","surveySubmissionId","_document","_window","findElementBySelector","selector","elements","querySelectorAll","matchCount","style","getComputedStyle","display","visibility","opacity","rect","getBoundingClientRect","width","height","isElementVisible","TOOLTIP_MARGIN","TOOLTIP_WIDTH","TOOLTIP_HEIGHT_ESTIMATE","addProductTourCSSVariablesToElement","appearance","hex","merged","_extends","setProperty","defaultFontStack","getFontFamily","renderTipTapContent","content","_content$content","escapeHtml","type","text","marks","mark","children","join","_content$attrs","attrs","normalizeUrl","url","endsWith","div","textContent","innerHTML","satisfiedEmoji","_jsx","className","xmlns","viewBox","neutralEmoji","dissatisfiedEmoji","veryDissatisfiedEmoji","verySatisfiedEmoji","cancelSVG","_jsxs","fill","id","IconPosthogLogo","maskType","maskUnits","y","mask","transform","ProductTourTooltipInner","_appearance$whiteLabe","step","stepIndex","totalSteps","onNext","onPrevious","onDismiss","isLastStep","isFirstStep","showNextButton","progressionTrigger","isInteractive","cursorStyle","cursor","_Fragment","class","onClick","dangerouslySetInnerHTML","__html","href","rel","pointerEvents","threeScaleEmojis","fiveScaleEmojis","OpenTextInput","onChange","onSubmit","inputRef","useRef","useEffect","_inputRef$current","focus","ref","rows","placeholder","onInput","onKeyDown","key","metaKey","preventDefault","disabled","RatingInput","_ref2","survey","selectedRating","setSelectedRating","useState","scale","handleSelect","rating","emoji","idx","lowerBoundLabel","upperBoundLabel","numbers","getScaleNumbers","gridTemplateColumns","num","ProductTourSurveyStepInner","_ref3","textValue","setTextValue","isOpenText","handleTextSubmit","trim","questionText","getOppositePosition","position","top","bottom","left","right","TRANSITION_DURATION","ProductTourTooltip","tour","targetElement","onSurveySubmit","transitionState","setTransitionState","setPosition","spotlightStyle","setSpotlightStyle","displayedStep","setDisplayedStep","displayedStepIndex","setDisplayedStepIndex","previousStepRef","isTransitioningRef","isCentered","updatePosition","useCallback","targetRect","padding","viewportWidth","innerWidth","spaceBelow","innerHeight","spaceLeft","calculateTooltipPosition","currentStepIndex","isStepChange","finishEntering","enterStep","resolve","initialRect","viewportHeight","safeMarginY","safeMarginX","scrollIntoView","behavior","block","lastTop","stableCount","resolved","checkStability","currentRect","abs","scrollToElement","handleUpdate","removeEventListener","handleKeyDown","isVisible","isSurvey","isPositionReady","tooltipStyle","stopPropagation","transition","click","trunc","ceil","floor","Number","isInteger","isNumber","isFinite","crypto","getRandomValues","_localStorage_supported","localStore","_is_supported","supported","_set","_get","_remove","_unused5","_error","msg","name","localStorage","getItem","err","_parse","JSON","parse","_unused6","setItem","stringify","removeItem","sessionStorageSupported","sessionStore","_unused9","sessionStorage","_unused0","TOUR_COMPLETED_KEY_PREFIX","TOUR_DISMISSED_KEY_PREFIX","ACTIVE_TOUR_SESSION_KEY","doesTourActivateByEvent","_tour$conditions","_tour$conditions$even","conditions","events","doesTourActivateByAction","_tour$conditions2","_tour$conditions$acti","actions","SimpleEventEmitter","constructor","_events","on","listener","emit","payload","matchString","matching","likePattern","ActionMatcher","instance","_debugEventEmitter","_checkStep","_checkStepEvent","_checkStepUrl","_checkStepElement","_checkStepProperties","_instance","_actionEvents","Set","_actionRegistry","init","_this$_instance","_addCaptureHook","_this$_instance2","matchEventToAction","eventName","eventPayload","register","_this$_instance3","_this$_instance4","action","_this$_actionRegistry","_action$steps","add","steps","_this$_actionEvents","autocapture","_this$_instance5","selectorsToWatch","_action$steps2","setElementSelectors","_this$_actionRegistry2","has","size","_checkAction","_addActionHook","onAction","data","cb","_event$properties","eventUrl","properties","$current_url","url_matching","_checkStepHref","_checkStepText","_checkStepSelector","_event$properties2","_getElementsList","el","href_matching","chain","$elements_chain","_event$properties3","text_matching","$el_text","texts","elementsChain","exec","extractTexts","_event$properties4","_event$properties5","elementSelectors","$element_selectors","selector_regex","_event$properties6","$elements","reduce","acc","EventReceiver","_eventToItems","Map","_cancelEventToItems","_actionToItems","_doesEventMatchFilter","eventConfig","_buildEventToItemMap","items","conditionField","item","_item$conditions","existing","get","set","_getMatchingItems","itemIds","Activation","_getItems","allItems","_item$conditions2","find","_setupEventBasedItems","_setupActionBasedItems","actionBasedItems","_item$conditions3","_item$conditions4","_actionMatcher","actionName","_item$conditions5","_item$conditions6","_item$conditions7","_this$_actionMatcher","_item$conditions8","knownItems","eventBasedItems","_item$conditions9","_item$conditions0","itemsWithCancelEvents","_item$conditions1","_item$conditions10","cancelEvents","matchEventToItem","onEvent","Cancellation","_getLogger","activatedKey","_getActivatedKey","shownEventName","_getShownEventName","existingActivatedItems","persistence","_eventPayload$propert","_eventPayload$propert2","itemId","$survey_id","$product_tour_id","index","indexOf","splice","_updateActivatedItems","itemsToCancel","_cancelPendingItem","matchedItems","concat","activatedItems","eligibleItems","_isItemPermanentlyIneligible","getActivatedIds","_this$_instance6","getEventToItemsMap","_getActionMatcher","ProductTourEventReceiver","super","productTours","getProductTours","cancelPendingTour","completedKey","dismissedKey","getTours","isTourInDateRange","now","Date","start_date","end_date","checkTourConditions","_window$location","matchType","urlMatchType","Icontains","Exact","doesTourUrlMatch","CONTAINER_CLASS","TRIGGER_LISTENER_ATTRIBUTE","retrieveTourShadow","containerClass","existingDiv","querySelector","shadowRoot","shadow","isNewlyCreated","attachShadow","mode","productTourStyles","setAttribute","getProductTourStylesheet","appendChild","body","ProductTourManager","_this","_activeTour","_currentStepIndex","_isPreviewMode","_isResuming","_checkInterval","_triggerSelectorListeners","_pendingTourTimeouts","_registeredEventTourIds","_handleVisibilityChange","hidden","clearInterval","setInterval","_evaluateAndDisplayTours","nextStep","currentStep","_captureEvent","$product_tour_step_id","$product_tour_step_order","_setStepIndex","_renderCurrentStep","_completeTour","previousStep","dismissTour","reason","$product_tour_dismiss_reason","dispatchEvent","CustomEvent","detail","tourId","_cleanup","_eventReceiver","_saveSessionState","_clearSessionState","_getSessionState","stored","start","savedState","_resumeSavedTour","_startEvaluationLoop","onComplete","_this$_instance$produ","tours","stop","_removeAllTriggerListeners","_cancelAllPendingTours","_this$_instance$produ2","getElementById","activeTriggerTourIds","unregisteredEventTours","eventActivatedTourIds","triggerSelector","_manageTriggerSelectorListener","hasEventOrActionTriggers","auto_launch","_isTourEligible","_showOrQueueTour","_removeTriggerSelectorListener","delaySeconds","autoShowDelaySeconds","isTourPending","queueTourWithDelay","showTour","_this$_instance$featu","internal_targeting_flag_key","featureFlags","getFeatureFlag","_options$reason","renderReason","selectorFailures","result","stepId","failure","$product_tour_step_selector","$product_tour_error","$product_tour_matches_count","$product_tour_failure_phase","failedSelectors","enableStrictValidation","$product_tour_name","$product_tour_iteration","current_iteration","$product_tour_render_reason","showTourById","_this$_instance$produ3","previewTour","$product_tour_steps_count","$set","retryCount","$product_tour_step_type","_renderTooltipWithPreact","shouldWaitForElement","waitDurationMs","$product_tour_waited_for_element","$product_tour_wait_duration_ms","metadata","_element$innerText","tag","tagName","classes","getElementMetadata","$product_tour_step_selector_found","$product_tour_step_element_tag","$product_tour_step_element_id","$product_tour_step_element_classes","$product_tour_step_element_text","_renderSurveyStep","onDismissOverride","render","_step$survey","_this$_instance$get_s","surveyId","linkedSurveyId","questionId","linkedSurveyQuestionId","$product_tour_linked_survey_id","SHOWN","SURVEY_ID","PRODUCT_TOUR_ID","sessionRecordingUrl","get_session_replay_url","response","_this$_instance$get_s2","responseKey","SENT","SURVEY_QUESTIONS","question","SURVEY_COMPLETED","_this$_instance$get_s3","DISMISSED","SURVEY_PARTIALLY_COMPLETED","container","remove","currentElement","existingListenerData","hasAttribute","removeAttribute","delete","getActiveProductTours","_this$_instance$produ4","context","isLoaded","activeTours","resetTour","resetAllTours","storage","keysToRemove","timeout","clear","timeoutId","generateProductTours","isEnabled","manager","__PosthogExtensions__"],"mappings":"yBAoCA,IAAMA,EAAkE,oBAAXC,OAAyBA,YAASC,EAyNzFC,EAA8D,oBAAfC,WAA6BA,WAAaJ,EAG3E,oBAATK,OACLF,EAAeE,KAAOF,GAER,oBAATG,OACLH,EAAeG,KAAO,WAAa,GAOlC,IAAMC,EAAkB,MAANJ,OAAM,EAANA,EAAQI,UACpBC,EAAiB,MAANL,OAAM,EAANA,EAAQK,SACF,MAANL,GAAAA,EAAQM,SACL,MAANN,GAAAA,EAAQO,YAEzBP,GAAAA,EAAQQ,gBAAkB,oBAAqB,IAAIR,EAAOQ,gBAAmBR,EAAOQ,eACnD,MAANR,GAAAA,EAAQS,gBACL,MAATL,GAAAA,EAAWM,UAC7B,IAAMC,EAAqCd,QAAAA,EAAQ,CAAA,0NClR7C,oBAWAe,EAAgC,CAAA,EAChCC,EAAY,GACZC,EACZ,qoCAd2B,sCAAA,uoBAML,8EAFK,sFAAA,qIAEL,gTAFK,oeAEL,qEAAA,iFAAA,mxCAJO,iBAFF,kyDASF,sGATE,gzGCQ5B,IAAYC,WAAAA,GAAe,OAAfA,EAAe,WAAA,SAAfA,EAAe,aAAA,eAAfA,CAAe,EAAA,IAoQfC,WAAAA,GAAe,OAAfA,EAAe,MAAA,eAAfA,EAAe,UAAA,mBAAfA,EAAe,KAAA,cAAfA,EAAe,UAAA,mBAAfA,CAAe,EA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BsuB,mBACtCtoB,KAAK4rB,aAAatD,EAAQL,EAAO,GACnB,IAAfkC,GAEHnqB,KAAKgnB,GAAqBtG,IAAI4H,EAAQwH,EAC1C,ECn3BG,SAASC,GAAqB50B,EAAkB60B,GACnD,GAAKtkB,EAAL,CAIA,IAAMukB,EAAU,IAAIzJ,GAAmBrrB,GAMvC,OAJI60B,GACAC,EAAQpH,QAGLoH,CARP,CASJ,CChBAj5B,EAAiBk5B,sBAAwBl5B,EAAiBk5B,uBAAyB,CAAA,EACnFl5B,EAAiBk5B,sBAAsBH,qBAAuBA","x_google_ignoreList":[1,13]}
1
+ {"version":3,"file":"product-tours.js","sources":["../src/utils/globals.ts","../../../node_modules/.pnpm/preact@10.19.3/node_modules/preact/dist/preact.module.js","../src/posthog-surveys-types.ts","../../../node_modules/.pnpm/dompurify@3.3.1/node_modules/dompurify/dist/purify.es.mjs","../src/posthog-product-tours-types.ts","../../core/dist/types.mjs","../../core/dist/utils/type-utils.mjs","../../core/dist/utils/logger.mjs","../src/utils/logger.ts","../src/extensions/utils/stylesheet-loader.ts","../src/utils/index.ts","../src/utils/survey-utils.ts","../src/request.ts","../src/utils/regex-utils.ts","../src/utils/property-utils.ts","../../../node_modules/.pnpm/preact@10.19.3/node_modules/preact/hooks/dist/hooks.module.js","../src/extensions/surveys/surveys-extension-utils.tsx","../src/extensions/product-tours/product-tours-utils.ts","../../../node_modules/.pnpm/query-selector-shadow-dom@1.0.1/node_modules/query-selector-shadow-dom/src/querySelectorDeep.js","../../../node_modules/.pnpm/query-selector-shadow-dom@1.0.1/node_modules/query-selector-shadow-dom/src/normalize.js","../src/extensions/product-tours/element-inference.ts","../src/extensions/surveys/icons.tsx","../src/extensions/product-tours/components/ProductTourTooltipInner.tsx","../src/extensions/product-tours/components/ProductTourSurveyStepInner.tsx","../src/extensions/product-tours/components/ProductTourTooltip.tsx","../src/uuidv7.ts","../src/storage.ts","../src/extensions/product-tours/constants.ts","../src/utils/product-tour-utils.ts","../src/utils/simple-event-emitter.ts","../src/utils/elements-chain-utils.ts","../src/extensions/surveys/action-matcher.ts","../src/utils/event-receiver.ts","../src/utils/product-tour-event-receiver.ts","../src/constants.ts","../src/extensions/product-tours/product-tours.tsx","../src/extensions/product-tours/index.ts","../src/entrypoints/product-tours.ts"],"sourcesContent":["import type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ExternalIntegrationKind,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n SessionStartReason,\n} from '../types'\nimport type {\n ConversationsRemoteConfig,\n GetMessagesResponse,\n GetTicketsOptions,\n GetTicketsResponse,\n MarkAsReadResponse,\n SendMessageResponse,\n UserProvidedTraits,\n} from '../posthog-conversations-types'\n// only importing types here, so won't affect the bundle\n// eslint-disable-next-line posthog-js/no-external-replay-imports\nimport type { SessionRecordingStatus, TriggerType } from '../extensions/replay/external/triggerMatching'\nimport { eventWithTime } from '../extensions/replay/types/rrweb-types'\nimport { ErrorTracking } from '@posthog/core'\n\n/*\n * Global helpers to protect access to browser globals in a way that is safer for different targets\n * like DOM, SSR, Web workers etc.\n *\n * NOTE: Typically we want the \"window\" but globalThis works for both the typical browser context as\n * well as other contexts such as the web worker context. Window is still exported for any bits that explicitly require it.\n * If in doubt - export the global you need from this file and use that as an optional value. This way the code path is forced\n * to handle the case where the global is not available.\n */\n\n// eslint-disable-next-line no-restricted-globals\nconst win: (Window & typeof globalThis) | undefined = typeof window !== 'undefined' ? window : undefined\n\nexport type AssignableWindow = Window &\n typeof globalThis & {\n /*\n * Main PostHog instance\n */\n posthog: any\n\n /*\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n */\n __PosthogExtensions__?: PostHogExtensions\n\n /**\n * When loading remote config, we assign it to this global configuration\n * for ease of sharing it with the rest of the SDK\n */\n _POSTHOG_REMOTE_CONFIG?: Record<\n string,\n {\n config: RemoteConfig\n siteApps: SiteAppLoader[]\n }\n >\n\n /**\n * If this is set on the window, our logger will log to the console\n * for ease of debugging. Used for testing purposes only.\n *\n * @see {Config.DEBUG} from config.ts\n */\n POSTHOG_DEBUG: any\n\n // Exposed by the browser\n doNotTrack: any\n\n // See entrypoints/customizations.full.ts\n posthogCustomizations: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/exception-autocapture.ts\n *\n * @deprecated use `__PosthogExtensions__.errorWrappingFunctions` instead\n */\n posthogErrorWrappingFunctions: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrweb` instead\n */\n rrweb: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrwebConsoleRecord` instead\n */\n rrwebConsoleRecord: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.getRecordNetworkPlugin` instead\n */\n getRecordNetworkPlugin: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/web-vitals.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogWebVitalsCallbacks` instead\n */\n postHogWebVitalsCallbacks: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/tracing-headers.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogTracingHeadersPatchFns` instead\n */\n postHogTracingHeadersPatchFns: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/surveys.ts\n *\n * @deprecated use `__PosthogExtensions__.generateSurveys` instead\n */\n extendPostHogWithSurveys: any\n\n /*\n * These are used to handle our toolbar state.\n * @see {Toolbar} from extensions/toolbar.ts\n */\n ph_load_toolbar: any\n ph_load_editor: any\n ph_toolbar_state: any\n } & Record<`__$$ph_site_app_${string}`, any>\n\n/**\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n * changes to this interface can be breaking changes for users of the SDK\n */\n\nexport type ExternalExtensionKind = 'intercom-integration' | 'crisp-chat-integration'\n\nexport type PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'lazy-recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'conversations'\n | 'product-tours'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n | ExternalExtensionKind\n\nexport interface LazyLoadedSessionRecordingInterface {\n start: (startReason?: SessionStartReason) => void\n stop: () => void\n sessionId: string\n status: SessionRecordingStatus\n onRRwebEmit: (rawEvent: eventWithTime) => void\n log: (message: string, level: 'log' | 'warn' | 'error') => void\n sdkDebugProperties: Properties\n overrideLinkedFlag: () => void\n overrideSampling: () => void\n overrideTrigger: (triggerType: TriggerType) => void\n isStarted: boolean\n tryAddCustomEvent(tag: string, payload: any): boolean\n}\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\n}\n\nexport interface LazyLoadedConversationsInterface {\n // Widget control\n show: () => void\n hide: () => void\n isVisible: () => boolean\n\n // Lifecycle\n reset: () => void\n\n // API methods\n sendMessage: (message: string, userTraits?: UserProvidedTraits, newTicket?: boolean) => Promise<SendMessageResponse>\n getMessages: (ticketId?: string, after?: string) => Promise<GetMessagesResponse>\n markAsRead: (ticketId?: string) => Promise<MarkAsReadResponse>\n getTickets: (options?: GetTicketsOptions) => Promise<GetTicketsResponse>\n getCurrentTicketId: () => string | null\n getWidgetSessionId: () => string\n}\n\ninterface PostHogExtensions {\n loadExternalDependency?: (\n posthog: PostHog,\n kind: PostHogExtensionKind,\n callback: (error?: string | Event, event?: Event) => void\n ) => void\n\n loadSiteApp?: (posthog: PostHog, appUrl: string, callback: (error?: string | Event, event?: Event) => void) => void\n\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapConsoleError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n generateSurveys?: (posthog: PostHog, isSurveysEnabled: boolean) => any | undefined\n generateProductTours?: (posthog: PostHog, isEnabled: boolean) => any | undefined\n postHogWebVitalsCallbacks?: {\n onLCP: (metric: any) => void\n onCLS: (metric: any) => void\n onFCP: (metric: any) => void\n onINP: (metric: any) => void\n }\n tracingHeadersPatchFns?: {\n _patchFetch: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n _patchXHR: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n integrations?: {\n [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void; stop: () => void }\n }\n initSessionRecording?: (ph: PostHog) => LazyLoadedSessionRecordingInterface\n initConversations?: (config: ConversationsRemoteConfig, posthog: PostHog) => LazyLoadedConversationsInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\n\n// React Native polyfills for posthog-js compatibility\nif (typeof self === 'undefined') {\n ;(global as any).self = global\n}\nif (typeof File === 'undefined') {\n ;(global as any).File = function () {}\n}\n\nexport const ArrayProto = Array.prototype\nexport const nativeForEach = ArrayProto.forEach\nexport const nativeIndexOf = ArrayProto.indexOf\n\nexport const navigator = global?.navigator\nexport const document = global?.document\nexport const location = global?.location\nexport const fetch = global?.fetch\nexport const XMLHttpRequest =\n global?.XMLHttpRequest && 'withCredentials' in new global.XMLHttpRequest() ? global.XMLHttpRequest : undefined\nexport const AbortController = global?.AbortController\nexport const userAgent = navigator?.userAgent\nexport const assignableWindow: AssignableWindow = win ?? ({} as any)\n\nexport { win as window }\n","var n,l,u,t,i,o,r,f,e,c={},s=[],a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,h=Array.isArray;function v(n,l){for(var u in l)n[u]=l[u];return n}function p(n){var l=n.parentNode;l&&l.removeChild(n)}function y(l,u,t){var i,o,r,f={};for(r in u)\"key\"==r?i=u[r]:\"ref\"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),\"function\"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return d(l,f,i,o,null)}function d(n,t,i,o,r){var f={type:n,props:t,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++u:r,__i:-1,__u:0};return null==r&&null!=l.vnode&&l.vnode(f),f}function _(){return{current:null}}function g(n){return n.children}function b(n,l){this.props=n,this.context=l}function m(n,l){if(null==l)return n.__?m(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return\"function\"==typeof n.type?m(n):null}function k(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return k(n)}}function w(n){(!n.__d&&(n.__d=!0)&&i.push(n)&&!x.__r++||o!==l.debounceRendering)&&((o=l.debounceRendering)||r)(x)}function x(){var n,u,t,o,r,e,c,s,a;for(i.sort(f);n=i.shift();)n.__d&&(u=i.length,o=void 0,e=(r=(t=n).__v).__e,s=[],a=[],(c=t.__P)&&((o=v({},r)).__v=r.__v+1,l.vnode&&l.vnode(o),L(c,o,r,t.__n,void 0!==c.ownerSVGElement,32&r.__u?[e]:null,s,null==e?m(r):e,!!(32&r.__u),a),o.__.__k[o.__i]=o,M(s,o,a),o.__e!=e&&k(o)),i.length>u&&i.sort(f));x.__r=0}function C(n,l,u,t,i,o,r,f,e,a,h){var v,p,y,d,_,g=t&&t.__k||s,b=l.length;for(u.__d=e,P(u,l,g),e=u.__d,v=0;v<b;v++)null!=(y=u.__k[v])&&\"boolean\"!=typeof y&&\"function\"!=typeof y&&(p=-1===y.__i?c:g[y.__i]||c,y.__i=v,L(n,y,p,i,o,r,f,e,a,h),d=y.__e,y.ref&&p.ref!=y.ref&&(p.ref&&z(p.ref,null,y),h.push(y.ref,y.__c||d,y)),null==_&&null!=d&&(_=d),65536&y.__u||p.__k===y.__k?e=S(y,e,n):\"function\"==typeof y.type&&void 0!==y.__d?e=y.__d:d&&(e=d.nextSibling),y.__d=void 0,y.__u&=-196609);u.__d=e,u.__e=_}function P(n,l,u){var t,i,o,r,f,e=l.length,c=u.length,s=c,a=0;for(n.__k=[],t=0;t<e;t++)null!=(i=n.__k[t]=null==(i=l[t])||\"boolean\"==typeof i||\"function\"==typeof i?null:\"string\"==typeof i||\"number\"==typeof i||\"bigint\"==typeof i||i.constructor==String?d(null,i,null,null,i):h(i)?d(g,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?d(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=n,i.__b=n.__b+1,f=H(i,u,r=t+a,s),i.__i=f,o=null,-1!==f&&(s--,(o=u[f])&&(o.__u|=131072)),null==o||null===o.__v?(-1==f&&a--,\"function\"!=typeof i.type&&(i.__u|=65536)):f!==r&&(f===r+1?a++:f>r?s>e-r?a+=f-r:a--:a=f<r&&f==r-1?f-r:0,f!==t+a&&(i.__u|=65536))):(o=u[t])&&null==o.key&&o.__e&&(o.__e==n.__d&&(n.__d=m(o)),N(o,o,!1),u[t]=null,s--);if(s)for(t=0;t<c;t++)null!=(o=u[t])&&0==(131072&o.__u)&&(o.__e==n.__d&&(n.__d=m(o)),N(o,o))}function S(n,l,u){var t,i;if(\"function\"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=S(t[i],l,u));return l}return n.__e!=l&&(u.insertBefore(n.__e,l||null),l=n.__e),l&&l.nextSibling}function $(n,l){return l=l||[],null==n||\"boolean\"==typeof n||(h(n)?n.some(function(n){$(n,l)}):l.push(n)),l}function H(n,l,u,t){var i=n.key,o=n.type,r=u-1,f=u+1,e=l[u];if(null===e||e&&i==e.key&&o===e.type)return u;if(t>(null!=e&&0==(131072&e.__u)?1:0))for(;r>=0||f<l.length;){if(r>=0){if((e=l[r])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return r;r--}if(f<l.length){if((e=l[f])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return f;f++}}return-1}function I(n,l,u){\"-\"===l[0]?n.setProperty(l,null==u?\"\":u):n[l]=null==u?\"\":\"number\"!=typeof u||a.test(l)?u:u+\"px\"}function T(n,l,u,t,i){var o;n:if(\"style\"===l)if(\"string\"==typeof u)n.style.cssText=u;else{if(\"string\"==typeof t&&(n.style.cssText=t=\"\"),t)for(l in t)u&&l in u||I(n.style,l,\"\");if(u)for(l in u)t&&u[l]===t[l]||I(n.style,l,u[l])}else if(\"o\"===l[0]&&\"n\"===l[1])o=l!==(l=l.replace(/(PointerCapture)$|Capture$/,\"$1\")),l=l.toLowerCase()in n?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?t?u.u=t.u:(u.u=Date.now(),n.addEventListener(l,o?D:A,o)):n.removeEventListener(l,o?D:A,o);else{if(i)l=l.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(\"width\"!==l&&\"height\"!==l&&\"href\"!==l&&\"list\"!==l&&\"form\"!==l&&\"tabIndex\"!==l&&\"download\"!==l&&\"rowSpan\"!==l&&\"colSpan\"!==l&&\"role\"!==l&&l in n)try{n[l]=null==u?\"\":u;break n}catch(n){}\"function\"==typeof u||(null==u||!1===u&&\"-\"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u))}}function A(n){var u=this.l[n.type+!1];if(n.t){if(n.t<=u.u)return}else n.t=Date.now();return u(l.event?l.event(n):n)}function D(n){return this.l[n.type+!0](l.event?l.event(n):n)}function L(n,u,t,i,o,r,f,e,c,s){var a,p,y,d,_,m,k,w,x,P,S,$,H,I,T,A=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),r=[e=u.__e=t.__e]),(a=l.__b)&&a(u);n:if(\"function\"==typeof A)try{if(w=u.props,x=(a=A.contextType)&&i[a.__c],P=a?x?x.props.value:a.__:i,t.__c?k=(p=u.__c=t.__c).__=p.__E:(\"prototype\"in A&&A.prototype.render?u.__c=p=new A(w,P):(u.__c=p=new b(w,P),p.constructor=A,p.render=O),x&&x.sub(p),p.props=w,p.state||(p.state={}),p.context=P,p.__n=i,y=p.__d=!0,p.__h=[],p._sb=[]),null==p.__s&&(p.__s=p.state),null!=A.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=v({},p.__s)),v(p.__s,A.getDerivedStateFromProps(w,p.__s))),d=p.props,_=p.state,p.__v=u,y)null==A.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==A.getDerivedStateFromProps&&w!==d&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(w,P),!p.__e&&(null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(w,p.__s,P)||u.__v===t.__v)){for(u.__v!==t.__v&&(p.props=w,p.state=p.__s,p.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.forEach(function(n){n&&(n.__=u)}),S=0;S<p._sb.length;S++)p.__h.push(p._sb[S]);p._sb=[],p.__h.length&&f.push(p);break n}null!=p.componentWillUpdate&&p.componentWillUpdate(w,p.__s,P),null!=p.componentDidUpdate&&p.__h.push(function(){p.componentDidUpdate(d,_,m)})}if(p.context=P,p.props=w,p.__P=n,p.__e=!1,$=l.__r,H=0,\"prototype\"in A&&A.prototype.render){for(p.state=p.__s,p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),I=0;I<p._sb.length;I++)p.__h.push(p._sb[I]);p._sb=[]}else do{p.__d=!1,$&&$(u),a=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++H<25);p.state=p.__s,null!=p.getChildContext&&(i=v(v({},i),p.getChildContext())),y||null==p.getSnapshotBeforeUpdate||(m=p.getSnapshotBeforeUpdate(d,_)),C(n,h(T=null!=a&&a.type===g&&null==a.key?a.props.children:a)?T:[T],u,t,i,o,r,f,e,c,s),p.base=u.__e,u.__u&=-161,p.__h.length&&f.push(p),k&&(p.__E=p.__=null)}catch(n){u.__v=null,c||null!=r?(u.__e=e,u.__u|=c?160:32,r[r.indexOf(e)]=null):(u.__e=t.__e,u.__k=t.__k),l.__e(n,u,t)}else null==r&&u.__v===t.__v?(u.__k=t.__k,u.__e=t.__e):u.__e=j(t.__e,u,t,i,o,r,f,c,s);(a=l.diffed)&&a(u)}function M(n,u,t){u.__d=void 0;for(var i=0;i<t.length;i++)z(t[i],t[++i],t[++i]);l.__c&&l.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u)})}catch(n){l.__e(n,u.__v)}})}function j(l,u,t,i,o,r,f,e,s){var a,v,y,d,_,g,b,k=t.props,w=u.props,x=u.type;if(\"svg\"===x&&(o=!0),null!=r)for(a=0;a<r.length;a++)if((_=r[a])&&\"setAttribute\"in _==!!x&&(x?_.localName===x:3===_.nodeType)){l=_,r[a]=null;break}if(null==l){if(null===x)return document.createTextNode(w);l=o?document.createElementNS(\"http://www.w3.org/2000/svg\",x):document.createElement(x,w.is&&w),r=null,e=!1}if(null===x)k===w||e&&l.data===w||(l.data=w);else{if(r=r&&n.call(l.childNodes),k=t.props||c,!e&&null!=r)for(k={},a=0;a<l.attributes.length;a++)k[(_=l.attributes[a]).name]=_.value;for(a in k)_=k[a],\"children\"==a||(\"dangerouslySetInnerHTML\"==a?y=_:\"key\"===a||a in w||T(l,a,null,_,o));for(a in w)_=w[a],\"children\"==a?d=_:\"dangerouslySetInnerHTML\"==a?v=_:\"value\"==a?g=_:\"checked\"==a?b=_:\"key\"===a||e&&\"function\"!=typeof _||k[a]===_||T(l,a,_,k[a],o);if(v)e||y&&(v.__html===y.__html||v.__html===l.innerHTML)||(l.innerHTML=v.__html),u.__k=[];else if(y&&(l.innerHTML=\"\"),C(l,h(d)?d:[d],u,t,i,o&&\"foreignObject\"!==x,r,f,r?r[0]:t.__k&&m(t,0),e,s),null!=r)for(a=r.length;a--;)null!=r[a]&&p(r[a]);e||(a=\"value\",void 0!==g&&(g!==l[a]||\"progress\"===x&&!g||\"option\"===x&&g!==k[a])&&T(l,a,g,k[a],!1),a=\"checked\",void 0!==b&&b!==l[a]&&T(l,a,b,k[a],!1))}return l}function z(n,u,t){try{\"function\"==typeof n?n(u):n.current=u}catch(n){l.__e(n,t)}}function N(n,u,t){var i,o;if(l.unmount&&l.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||z(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(n){l.__e(n,u)}i.base=i.__P=null,n.__c=void 0}if(i=n.__k)for(o=0;o<i.length;o++)i[o]&&N(i[o],u,t||\"function\"!=typeof n.type);t||null==n.__e||p(n.__e),n.__=n.__e=n.__d=void 0}function O(n,l,u){return this.constructor(n,u)}function q(u,t,i){var o,r,f,e;l.__&&l.__(u,t),r=(o=\"function\"==typeof i)?null:i&&i.__k||t.__k,f=[],e=[],L(t,u=(!o&&i||t).__k=y(g,null,[u]),r||c,c,void 0!==t.ownerSVGElement,!o&&i?[i]:r?null:t.firstChild?n.call(t.childNodes):null,f,!o&&i?i:r?r.__e:t.firstChild,o,e),M(f,u,e)}function B(n,l){q(n,l,B)}function E(l,u,t){var i,o,r,f,e=v({},l.props);for(r in l.type&&l.type.defaultProps&&(f=l.type.defaultProps),u)\"key\"==r?i=u[r]:\"ref\"==r?o=u[r]:e[r]=void 0===u[r]&&void 0!==f?f[r]:u[r];return arguments.length>2&&(e.children=arguments.length>3?n.call(arguments,2):t),d(l.type,e,i||l.key,o||l.ref,null)}function F(n,l){var u={__c:l=\"__cC\"+e++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=[],(t={})[l]=this,this.getChildContext=function(){return t},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(function(n){n.__e=!0,w(n)})},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=s.slice,l={__e:function(n,l,u,t){for(var i,o,r;l=l.__;)if((i=l.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(n)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),r=i.__d),r)return i.__E=i}catch(l){n=l}throw n}},u=0,t=function(n){return null!=n&&null==n.constructor},b.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=v({},this.state),\"function\"==typeof n&&(n=n(v({},u),this.props)),n&&v(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),w(this))},b.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),w(this))},b.prototype.render=g,i=[],r=\"function\"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f=function(n,l){return n.__v.__b-l.__v.__b},x.__r=0,e=0;export{b as Component,g as Fragment,E as cloneElement,F as createContext,y as createElement,_ as createRef,y as h,B as hydrate,t as isValidElement,l as options,q as render,$ as toChildArray};\n//# sourceMappingURL=preact.module.js.map\n","/**\n * Having Survey types in types.ts was confusing tsc\n * and generating an invalid module.d.ts\n * See https://github.com/PostHog/posthog-js/issues/698\n */\n\nimport type { PropertyMatchType } from './types'\nimport type { SurveyAppearance as CoreSurveyAppearance } from '@posthog/core'\n\nexport enum SurveyEventType {\n Activation = 'events',\n Cancellation = 'cancelEvents',\n}\n\n// Extended operator type to include numeric operators not in PropertyMatchType\nexport type PropertyOperator = PropertyMatchType | 'gt' | 'lt'\n\nexport type PropertyFilters = {\n [propertyName: string]: {\n values: string[]\n operator: PropertyOperator\n }\n}\n\nexport interface SurveyEventWithFilters {\n name: string\n propertyFilters?: PropertyFilters\n}\n\nexport enum SurveyWidgetType {\n Button = 'button',\n Tab = 'tab',\n Selector = 'selector',\n}\n\nexport enum SurveyPosition {\n TopLeft = 'top_left',\n TopRight = 'top_right',\n TopCenter = 'top_center',\n MiddleLeft = 'middle_left',\n MiddleRight = 'middle_right',\n MiddleCenter = 'middle_center',\n Left = 'left',\n Center = 'center',\n Right = 'right',\n NextToTrigger = 'next_to_trigger',\n}\n\nexport enum SurveyTabPosition {\n Top = 'top',\n Left = 'left',\n Right = 'right',\n Bottom = 'bottom',\n}\n\n// Extends core SurveyAppearance with browser-specific fields\n// Omit 'position' from core because browser's SurveyPosition has additional values (e.g., NextToTrigger)\nexport interface SurveyAppearance extends Omit<CoreSurveyAppearance, 'position'> {\n // Browser-specific fields not in core\n /** @deprecated - not currently used */\n descriptionTextColor?: string\n ratingButtonHoverColor?: string\n whiteLabel?: boolean\n tabPosition?: SurveyTabPosition\n fontFamily?: string\n maxWidth?: string\n zIndex?: string\n disabledButtonOpacity?: string\n boxPadding?: string\n /** @deprecated Use inputBackground instead (inherited from core) */\n inputBackgroundColor?: string\n // Hide the X (cancel) button - defaults to false (show the button)\n hideCancelButton?: boolean\n // Browser's SurveyPosition has more options than core (e.g., NextToTrigger)\n position?: SurveyPosition\n}\n\nexport enum SurveyType {\n Popover = 'popover',\n API = 'api',\n Widget = 'widget',\n ExternalSurvey = 'external_survey',\n}\n\nexport type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion\n\nexport type SurveyQuestionDescriptionContentType = 'html' | 'text'\n\ninterface SurveyQuestionBase {\n question: string\n id?: string\n description?: string | null\n descriptionContentType?: SurveyQuestionDescriptionContentType\n optional?: boolean\n buttonText?: string\n branching?: NextQuestionBranching | EndBranching | ResponseBasedBranching | SpecificQuestionBranching\n}\n\nexport interface BasicSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Open\n}\n\nexport interface LinkSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Link\n link?: string | null\n}\n\nexport interface RatingSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.Rating\n display: 'number' | 'emoji'\n scale: 3 | 5 | 7 | 10\n lowerBoundLabel: string\n upperBoundLabel: string\n skipSubmitButton?: boolean\n}\n\nexport interface MultipleSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice\n choices: string[]\n hasOpenChoice?: boolean\n shuffleOptions?: boolean\n skipSubmitButton?: boolean\n}\n\nexport enum SurveyQuestionType {\n Open = 'open',\n MultipleChoice = 'multiple_choice',\n SingleChoice = 'single_choice',\n Rating = 'rating',\n Link = 'link',\n}\n\nexport enum SurveyQuestionBranchingType {\n NextQuestion = 'next_question',\n End = 'end',\n ResponseBased = 'response_based',\n SpecificQuestion = 'specific_question',\n}\n\ninterface NextQuestionBranching {\n type: SurveyQuestionBranchingType.NextQuestion\n}\n\ninterface EndBranching {\n type: SurveyQuestionBranchingType.End\n}\n\ninterface ResponseBasedBranching {\n type: SurveyQuestionBranchingType.ResponseBased\n responseValues: Record<string, any>\n}\n\ninterface SpecificQuestionBranching {\n type: SurveyQuestionBranchingType.SpecificQuestion\n index: number\n}\n\nexport type SurveyCallback = (surveys: Survey[], context?: { isLoaded: boolean; error?: string }) => void\n\nexport interface SurveyElement {\n text?: string\n $el_text?: string\n tag_name?: string\n href?: string\n attr_id?: string\n attr_class?: string[]\n nth_child?: number\n nth_of_type?: number\n attributes?: Record<string, any>\n event_id?: number\n order?: number\n group_id?: number\n}\nexport interface SurveyRenderReason {\n visible: boolean\n disabledReason?: string\n}\n\nexport enum SurveySchedule {\n Once = 'once',\n Recurring = 'recurring',\n Always = 'always',\n}\n\nexport interface Survey {\n // Sync this with the backend's SurveyAPISerializer!\n id: string\n name: string\n description: string\n type: SurveyType\n feature_flag_keys:\n | {\n key: string\n value?: string\n }[]\n | null\n // the linked flag key is the flag key that is used to link the survey to a flag\n linked_flag_key: string | null\n targeting_flag_key: string | null\n // the internal targeting flag key is the flag key that is used to target users who have seen the survey\n // eg survey-targeting-<survey-id>\n internal_targeting_flag_key: string | null\n questions: SurveyQuestion[]\n appearance: SurveyAppearance | null\n conditions: {\n url?: string\n selector?: string\n seenSurveyWaitPeriodInDays?: number\n urlMatchType?: PropertyMatchType\n /** events that trigger surveys */\n events: {\n repeatedActivation?: boolean\n values: SurveyEventWithFilters[]\n } | null\n /** events that cancel \"pending\" (time-delayed) surveys */\n cancelEvents: {\n values: SurveyEventWithFilters[]\n } | null\n actions: {\n values: SurveyActionType[]\n } | null\n deviceTypes?: string[]\n deviceTypesMatchType?: PropertyMatchType\n linkedFlagVariant?: string\n } | null\n start_date: string | null\n end_date: string | null\n current_iteration: number | null\n current_iteration_start_date: string | null\n schedule?: SurveySchedule | null\n enable_partial_responses?: boolean | null\n}\n\nexport type SurveyWithTypeAndAppearance = Pick<Survey, 'id' | 'type' | 'appearance'>\n\nexport interface SurveyActionType {\n id: number\n name: string | null\n steps?: ActionStepType[]\n}\n\n/** Sync with plugin-server/src/types.ts */\nexport type ActionStepStringMatching = 'contains' | 'exact' | 'regex'\n\nexport interface ActionStepType {\n event?: string | null\n selector?: string | null\n /** pre-compiled regex pattern for matching selector against $elements_chain */\n selector_regex?: string | null\n /** @deprecated Only `selector` should be used now. */\n tag_name?: string\n text?: string | null\n /** @default StringMatching.Exact */\n text_matching?: ActionStepStringMatching | null\n href?: string | null\n /** @default ActionStepStringMatching.Exact */\n href_matching?: ActionStepStringMatching | null\n url?: string | null\n /** @default StringMatching.Contains */\n url_matching?: ActionStepStringMatching | null\n /** Property filters for action step matching */\n properties?: {\n key: string\n value?: string | number | boolean | (string | number | boolean)[] | null\n operator?: PropertyMatchType\n type?: string\n }[]\n}\n\nexport enum SurveyEventName {\n SHOWN = 'survey shown',\n DISMISSED = 'survey dismissed',\n SENT = 'survey sent',\n ABANDONED = 'survey abandoned',\n}\n\nexport enum SurveyEventProperties {\n SURVEY_ID = '$survey_id',\n SURVEY_NAME = '$survey_name',\n SURVEY_RESPONSE = '$survey_response',\n SURVEY_ITERATION = '$survey_iteration',\n SURVEY_ITERATION_START_DATE = '$survey_iteration_start_date',\n SURVEY_PARTIALLY_COMPLETED = '$survey_partially_completed',\n SURVEY_SUBMISSION_ID = '$survey_submission_id',\n SURVEY_QUESTIONS = '$survey_questions',\n SURVEY_COMPLETED = '$survey_completed',\n PRODUCT_TOUR_ID = '$product_tour_id',\n SURVEY_LAST_SEEN_DATE = '$survey_last_seen_date',\n}\n\nexport enum DisplaySurveyType {\n Popover = 'popover',\n Inline = 'inline',\n}\n\ninterface DisplaySurveyOptionsBase {\n ignoreConditions: boolean\n ignoreDelay: boolean\n displayType: DisplaySurveyType\n}\n\ninterface DisplaySurveyPopoverOptions extends DisplaySurveyOptionsBase {\n displayType: DisplaySurveyType.Popover\n}\n\ninterface DisplaySurveyInlineOptions extends DisplaySurveyOptionsBase {\n displayType: DisplaySurveyType.Inline\n selector: string\n}\n\nexport type DisplaySurveyOptions = DisplaySurveyPopoverOptions | DisplaySurveyInlineOptions\n\nexport interface SurveyConfig {\n prefillFromUrl?: boolean\n /**\n * @deprecated No longer used. Surveys will automatically advance past\n * prefilled questions with skipSubmitButton enabled. If partial response\n * collection is enabled, partial responses for pre-filled questions will\n * be submitted automatically on page load.\n */\n autoSubmitIfComplete?: boolean\n /**\n * @deprecated No longer used. Pre-filled responses are now sent\n * immediately when partial responses are enabled, or all required\n * quesions have been pre-filled.\n */\n autoSubmitDelay?: number\n}\n","/*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */\n\nconst {\n entries,\n setPrototypeOf,\n isFrozen,\n getPrototypeOf,\n getOwnPropertyDescriptor\n} = Object;\nlet {\n freeze,\n seal,\n create\n} = Object; // eslint-disable-line import/no-mutable-exports\nlet {\n apply,\n construct\n} = typeof Reflect !== 'undefined' && Reflect;\nif (!freeze) {\n freeze = function freeze(x) {\n return x;\n };\n}\nif (!seal) {\n seal = function seal(x) {\n return x;\n };\n}\nif (!apply) {\n apply = function apply(func, thisArg) {\n for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n args[_key - 2] = arguments[_key];\n }\n return func.apply(thisArg, args);\n };\n}\nif (!construct) {\n construct = function construct(Func) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n return new Func(...args);\n };\n}\nconst arrayForEach = unapply(Array.prototype.forEach);\nconst arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);\nconst arrayPop = unapply(Array.prototype.pop);\nconst arrayPush = unapply(Array.prototype.push);\nconst arraySplice = unapply(Array.prototype.splice);\nconst stringToLowerCase = unapply(String.prototype.toLowerCase);\nconst stringToString = unapply(String.prototype.toString);\nconst stringMatch = unapply(String.prototype.match);\nconst stringReplace = unapply(String.prototype.replace);\nconst stringIndexOf = unapply(String.prototype.indexOf);\nconst stringTrim = unapply(String.prototype.trim);\nconst objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);\nconst regExpTest = unapply(RegExp.prototype.test);\nconst typeErrorCreate = unconstruct(TypeError);\n/**\n * Creates a new function that calls the given function with a specified thisArg and arguments.\n *\n * @param func - The function to be wrapped and called.\n * @returns A new function that calls the given function with a specified thisArg and arguments.\n */\nfunction unapply(func) {\n return function (thisArg) {\n if (thisArg instanceof RegExp) {\n thisArg.lastIndex = 0;\n }\n for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {\n args[_key3 - 1] = arguments[_key3];\n }\n return apply(func, thisArg, args);\n };\n}\n/**\n * Creates a new function that constructs an instance of the given constructor function with the provided arguments.\n *\n * @param func - The constructor function to be wrapped and called.\n * @returns A new function that constructs an instance of the given constructor function with the provided arguments.\n */\nfunction unconstruct(Func) {\n return function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n return construct(Func, args);\n };\n}\n/**\n * Add properties to a lookup table\n *\n * @param set - The set to which elements will be added.\n * @param array - The array containing elements to be added to the set.\n * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.\n * @returns The modified set with added elements.\n */\nfunction addToSet(set, array) {\n let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;\n if (setPrototypeOf) {\n // Make 'in' and truthy checks like Boolean(set.constructor)\n // independent of any properties defined on Object.prototype.\n // Prevent prototype setters from intercepting set as a this value.\n setPrototypeOf(set, null);\n }\n let l = array.length;\n while (l--) {\n let element = array[l];\n if (typeof element === 'string') {\n const lcElement = transformCaseFunc(element);\n if (lcElement !== element) {\n // Config presets (e.g. tags.js, attrs.js) are immutable.\n if (!isFrozen(array)) {\n array[l] = lcElement;\n }\n element = lcElement;\n }\n }\n set[element] = true;\n }\n return set;\n}\n/**\n * Clean up an array to harden against CSPP\n *\n * @param array - The array to be cleaned.\n * @returns The cleaned version of the array\n */\nfunction cleanArray(array) {\n for (let index = 0; index < array.length; index++) {\n const isPropertyExist = objectHasOwnProperty(array, index);\n if (!isPropertyExist) {\n array[index] = null;\n }\n }\n return array;\n}\n/**\n * Shallow clone an object\n *\n * @param object - The object to be cloned.\n * @returns A new object that copies the original.\n */\nfunction clone(object) {\n const newObject = create(null);\n for (const [property, value] of entries(object)) {\n const isPropertyExist = objectHasOwnProperty(object, property);\n if (isPropertyExist) {\n if (Array.isArray(value)) {\n newObject[property] = cleanArray(value);\n } else if (value && typeof value === 'object' && value.constructor === Object) {\n newObject[property] = clone(value);\n } else {\n newObject[property] = value;\n }\n }\n }\n return newObject;\n}\n/**\n * This method automatically checks if the prop is function or getter and behaves accordingly.\n *\n * @param object - The object to look up the getter function in its prototype chain.\n * @param prop - The property name for which to find the getter function.\n * @returns The getter function found in the prototype chain or a fallback function.\n */\nfunction lookupGetter(object, prop) {\n while (object !== null) {\n const desc = getOwnPropertyDescriptor(object, prop);\n if (desc) {\n if (desc.get) {\n return unapply(desc.get);\n }\n if (typeof desc.value === 'function') {\n return unapply(desc.value);\n }\n }\n object = getPrototypeOf(object);\n }\n function fallbackValue() {\n return null;\n }\n return fallbackValue;\n}\n\nconst html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);\nconst svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);\nconst svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);\n// List of SVG elements that are disallowed by default.\n// We still need to know them so that we can do namespace\n// checks properly in case one wants to add them to\n// allow-list.\nconst svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);\nconst mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);\n// Similarly to SVG, we want to know all MathML elements,\n// even those that we disallow by default.\nconst mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);\nconst text = freeze(['#text']);\n\nconst html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);\nconst svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);\nconst mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);\nconst xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);\n\n// eslint-disable-next-line unicorn/better-regex\nconst MUSTACHE_EXPR = seal(/\\{\\{[\\w\\W]*|[\\w\\W]*\\}\\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode\nconst ERB_EXPR = seal(/<%[\\w\\W]*|[\\w\\W]*%>/gm);\nconst TMPLIT_EXPR = seal(/\\$\\{[\\w\\W]*/gm); // eslint-disable-line unicorn/better-regex\nconst DATA_ATTR = seal(/^data-[\\-\\w.\\u00B7-\\uFFFF]+$/); // eslint-disable-line no-useless-escape\nconst ARIA_ATTR = seal(/^aria-[\\-\\w]+$/); // eslint-disable-line no-useless-escape\nconst IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i // eslint-disable-line no-useless-escape\n);\nconst IS_SCRIPT_OR_DATA = seal(/^(?:\\w+script|data):/i);\nconst ATTR_WHITESPACE = seal(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g // eslint-disable-line no-control-regex\n);\nconst DOCTYPE_NAME = seal(/^html$/i);\nconst CUSTOM_ELEMENT = seal(/^[a-z][.\\w]*(-[.\\w]+)+$/i);\n\nvar EXPRESSIONS = /*#__PURE__*/Object.freeze({\n __proto__: null,\n ARIA_ATTR: ARIA_ATTR,\n ATTR_WHITESPACE: ATTR_WHITESPACE,\n CUSTOM_ELEMENT: CUSTOM_ELEMENT,\n DATA_ATTR: DATA_ATTR,\n DOCTYPE_NAME: DOCTYPE_NAME,\n ERB_EXPR: ERB_EXPR,\n IS_ALLOWED_URI: IS_ALLOWED_URI,\n IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,\n MUSTACHE_EXPR: MUSTACHE_EXPR,\n TMPLIT_EXPR: TMPLIT_EXPR\n});\n\n/* eslint-disable @typescript-eslint/indent */\n// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType\nconst NODE_TYPE = {\n element: 1,\n attribute: 2,\n text: 3,\n cdataSection: 4,\n entityReference: 5,\n // Deprecated\n entityNode: 6,\n // Deprecated\n progressingInstruction: 7,\n comment: 8,\n document: 9,\n documentType: 10,\n documentFragment: 11,\n notation: 12 // Deprecated\n};\nconst getGlobal = function getGlobal() {\n return typeof window === 'undefined' ? null : window;\n};\n/**\n * Creates a no-op policy for internal use only.\n * Don't export this function outside this module!\n * @param trustedTypes The policy factory.\n * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).\n * @return The policy created (or null, if Trusted Types\n * are not supported or creating the policy failed).\n */\nconst _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {\n if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {\n return null;\n }\n // Allow the callers to control the unique policy name\n // by adding a data-tt-policy-suffix to the script element with the DOMPurify.\n // Policy creation with duplicate names throws in Trusted Types.\n let suffix = null;\n const ATTR_NAME = 'data-tt-policy-suffix';\n if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {\n suffix = purifyHostElement.getAttribute(ATTR_NAME);\n }\n const policyName = 'dompurify' + (suffix ? '#' + suffix : '');\n try {\n return trustedTypes.createPolicy(policyName, {\n createHTML(html) {\n return html;\n },\n createScriptURL(scriptUrl) {\n return scriptUrl;\n }\n });\n } catch (_) {\n // Policy creation failed (most likely another DOMPurify script has\n // already run). Skip creating the policy, as this will only cause errors\n // if TT are enforced.\n console.warn('TrustedTypes policy ' + policyName + ' could not be created.');\n return null;\n }\n};\nconst _createHooksMap = function _createHooksMap() {\n return {\n afterSanitizeAttributes: [],\n afterSanitizeElements: [],\n afterSanitizeShadowDOM: [],\n beforeSanitizeAttributes: [],\n beforeSanitizeElements: [],\n beforeSanitizeShadowDOM: [],\n uponSanitizeAttribute: [],\n uponSanitizeElement: [],\n uponSanitizeShadowNode: []\n };\n};\nfunction createDOMPurify() {\n let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();\n const DOMPurify = root => createDOMPurify(root);\n DOMPurify.version = '3.3.1';\n DOMPurify.removed = [];\n if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {\n // Not running in a browser, provide a factory function\n // so that you can pass your own Window\n DOMPurify.isSupported = false;\n return DOMPurify;\n }\n let {\n document\n } = window;\n const originalDocument = document;\n const currentScript = originalDocument.currentScript;\n const {\n DocumentFragment,\n HTMLTemplateElement,\n Node,\n Element,\n NodeFilter,\n NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,\n HTMLFormElement,\n DOMParser,\n trustedTypes\n } = window;\n const ElementPrototype = Element.prototype;\n const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');\n const remove = lookupGetter(ElementPrototype, 'remove');\n const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');\n const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');\n const getParentNode = lookupGetter(ElementPrototype, 'parentNode');\n // As per issue #47, the web-components registry is inherited by a\n // new document created via createHTMLDocument. As per the spec\n // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)\n // a new empty registry is used when creating a template contents owner\n // document, so we use that as our parent document to ensure nothing\n // is inherited.\n if (typeof HTMLTemplateElement === 'function') {\n const template = document.createElement('template');\n if (template.content && template.content.ownerDocument) {\n document = template.content.ownerDocument;\n }\n }\n let trustedTypesPolicy;\n let emptyHTML = '';\n const {\n implementation,\n createNodeIterator,\n createDocumentFragment,\n getElementsByTagName\n } = document;\n const {\n importNode\n } = originalDocument;\n let hooks = _createHooksMap();\n /**\n * Expose whether this browser supports running the full DOMPurify.\n */\n DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;\n const {\n MUSTACHE_EXPR,\n ERB_EXPR,\n TMPLIT_EXPR,\n DATA_ATTR,\n ARIA_ATTR,\n IS_SCRIPT_OR_DATA,\n ATTR_WHITESPACE,\n CUSTOM_ELEMENT\n } = EXPRESSIONS;\n let {\n IS_ALLOWED_URI: IS_ALLOWED_URI$1\n } = EXPRESSIONS;\n /**\n * We consider the elements and attributes below to be safe. Ideally\n * don't add any new ones but feel free to remove unwanted ones.\n */\n /* allowed element names */\n let ALLOWED_TAGS = null;\n const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);\n /* Allowed attribute names */\n let ALLOWED_ATTR = null;\n const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);\n /*\n * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.\n * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)\n * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)\n * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.\n */\n let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {\n tagNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n attributeNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n allowCustomizedBuiltInElements: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: false\n }\n }));\n /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */\n let FORBID_TAGS = null;\n /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */\n let FORBID_ATTR = null;\n /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */\n const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {\n tagCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n attributeCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n }\n }));\n /* Decide if ARIA attributes are okay */\n let ALLOW_ARIA_ATTR = true;\n /* Decide if custom data attributes are okay */\n let ALLOW_DATA_ATTR = true;\n /* Decide if unknown protocols are okay */\n let ALLOW_UNKNOWN_PROTOCOLS = false;\n /* Decide if self-closing tags in attributes are allowed.\n * Usually removed due to a mXSS issue in jQuery 3.0 */\n let ALLOW_SELF_CLOSE_IN_ATTR = true;\n /* Output should be safe for common template engines.\n * This means, DOMPurify removes data attributes, mustaches and ERB\n */\n let SAFE_FOR_TEMPLATES = false;\n /* Output should be safe even for XML used within HTML and alike.\n * This means, DOMPurify removes comments when containing risky content.\n */\n let SAFE_FOR_XML = true;\n /* Decide if document with <html>... should be returned */\n let WHOLE_DOCUMENT = false;\n /* Track whether config is already set on this instance of DOMPurify. */\n let SET_CONFIG = false;\n /* Decide if all elements (e.g. style, script) must be children of\n * document.body. By default, browsers might move them to document.head */\n let FORCE_BODY = false;\n /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported).\n * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead\n */\n let RETURN_DOM = false;\n /* Decide if a DOM `DocumentFragment` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported) */\n let RETURN_DOM_FRAGMENT = false;\n /* Try to return a Trusted Type object instead of a string, return a string in\n * case Trusted Types are not supported */\n let RETURN_TRUSTED_TYPE = false;\n /* Output should be free from DOM clobbering attacks?\n * This sanitizes markups named with colliding, clobberable built-in DOM APIs.\n */\n let SANITIZE_DOM = true;\n /* Achieve full DOM Clobbering protection by isolating the namespace of named\n * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.\n *\n * HTML/DOM spec rules that enable DOM Clobbering:\n * - Named Access on Window (§7.3.3)\n * - DOM Tree Accessors (§3.1.5)\n * - Form Element Parent-Child Relations (§4.10.3)\n * - Iframe srcdoc / Nested WindowProxies (§4.8.5)\n * - HTMLCollection (§4.2.10.2)\n *\n * Namespace isolation is implemented by prefixing `id` and `name` attributes\n * with a constant string, i.e., `user-content-`\n */\n let SANITIZE_NAMED_PROPS = false;\n const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';\n /* Keep element content when removing element? */\n let KEEP_CONTENT = true;\n /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead\n * of importing it into a new Document and returning a sanitized copy */\n let IN_PLACE = false;\n /* Allow usage of profiles like html, svg and mathMl */\n let USE_PROFILES = {};\n /* Tags to ignore content of when KEEP_CONTENT is true */\n let FORBID_CONTENTS = null;\n const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);\n /* Tags that are safe for data: URIs */\n let DATA_URI_TAGS = null;\n const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);\n /* Attributes safe for values like \"javascript:\" */\n let URI_SAFE_ATTRIBUTES = null;\n const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);\n const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n /* Document namespace */\n let NAMESPACE = HTML_NAMESPACE;\n let IS_EMPTY_INPUT = false;\n /* Allowed XHTML+XML namespaces */\n let ALLOWED_NAMESPACES = null;\n const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);\n let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);\n let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);\n // Certain elements are allowed in both SVG and HTML\n // namespace. We need to specify them explicitly\n // so that they don't get erroneously deleted from\n // HTML namespace.\n const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);\n /* Parsing of strict XHTML documents */\n let PARSER_MEDIA_TYPE = null;\n const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];\n const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';\n let transformCaseFunc = null;\n /* Keep a reference to config to pass to hooks */\n let CONFIG = null;\n /* Ideally, do not touch anything below this line */\n /* ______________________________________________ */\n const formElement = document.createElement('form');\n const isRegexOrFunction = function isRegexOrFunction(testValue) {\n return testValue instanceof RegExp || testValue instanceof Function;\n };\n /**\n * _parseConfig\n *\n * @param cfg optional config literal\n */\n // eslint-disable-next-line complexity\n const _parseConfig = function _parseConfig() {\n let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (CONFIG && CONFIG === cfg) {\n return;\n }\n /* Shield configuration object from tampering */\n if (!cfg || typeof cfg !== 'object') {\n cfg = {};\n }\n /* Shield configuration object from prototype pollution */\n cfg = clone(cfg);\n PARSER_MEDIA_TYPE =\n // eslint-disable-next-line unicorn/prefer-includes\n SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;\n // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.\n transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;\n /* Set configuration parameters */\n ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;\n ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;\n ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;\n URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;\n DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;\n FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;\n FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});\n FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});\n USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;\n ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true\n ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true\n ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false\n ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true\n SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false\n SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true\n WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false\n RETURN_DOM = cfg.RETURN_DOM || false; // Default false\n RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false\n RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false\n FORCE_BODY = cfg.FORCE_BODY || false; // Default false\n SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true\n SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false\n KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true\n IN_PLACE = cfg.IN_PLACE || false; // Default false\n IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;\n NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;\n MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;\n HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;\n CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};\n if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;\n }\n if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;\n }\n if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;\n }\n if (SAFE_FOR_TEMPLATES) {\n ALLOW_DATA_ATTR = false;\n }\n if (RETURN_DOM_FRAGMENT) {\n RETURN_DOM = true;\n }\n /* Parse profile info */\n if (USE_PROFILES) {\n ALLOWED_TAGS = addToSet({}, text);\n ALLOWED_ATTR = [];\n if (USE_PROFILES.html === true) {\n addToSet(ALLOWED_TAGS, html$1);\n addToSet(ALLOWED_ATTR, html);\n }\n if (USE_PROFILES.svg === true) {\n addToSet(ALLOWED_TAGS, svg$1);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.svgFilters === true) {\n addToSet(ALLOWED_TAGS, svgFilters);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.mathMl === true) {\n addToSet(ALLOWED_TAGS, mathMl$1);\n addToSet(ALLOWED_ATTR, mathMl);\n addToSet(ALLOWED_ATTR, xml);\n }\n }\n /* Merge configuration parameters */\n if (cfg.ADD_TAGS) {\n if (typeof cfg.ADD_TAGS === 'function') {\n EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;\n } else {\n if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);\n }\n }\n if (cfg.ADD_ATTR) {\n if (typeof cfg.ADD_ATTR === 'function') {\n EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;\n } else {\n if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);\n }\n }\n if (cfg.ADD_URI_SAFE_ATTR) {\n addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);\n }\n if (cfg.FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);\n }\n if (cfg.ADD_FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);\n }\n /* Add #text in case KEEP_CONTENT is set to true */\n if (KEEP_CONTENT) {\n ALLOWED_TAGS['#text'] = true;\n }\n /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */\n if (WHOLE_DOCUMENT) {\n addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);\n }\n /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */\n if (ALLOWED_TAGS.table) {\n addToSet(ALLOWED_TAGS, ['tbody']);\n delete FORBID_TAGS.tbody;\n }\n if (cfg.TRUSTED_TYPES_POLICY) {\n if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.');\n }\n if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.');\n }\n // Overwrite existing TrustedTypes policy.\n trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;\n // Sign local variables required by `sanitize`.\n emptyHTML = trustedTypesPolicy.createHTML('');\n } else {\n // Uninitialized policy, attempt to initialize the internal dompurify policy.\n if (trustedTypesPolicy === undefined) {\n trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);\n }\n // If creating the internal policy succeeded sign internal variables.\n if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {\n emptyHTML = trustedTypesPolicy.createHTML('');\n }\n }\n // Prevent further manipulation of configuration.\n // Not available in IE8, Safari 5, etc.\n if (freeze) {\n freeze(cfg);\n }\n CONFIG = cfg;\n };\n /* Keep track of all possible SVG and MathML tags\n * so that we can perform the namespace checks\n * correctly. */\n const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);\n const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);\n /**\n * @param element a DOM element whose namespace is being checked\n * @returns Return false if the element has a\n * namespace that a spec-compliant parser would never\n * return. Return true otherwise.\n */\n const _checkValidNamespace = function _checkValidNamespace(element) {\n let parent = getParentNode(element);\n // In JSDOM, if we're inside shadow DOM, then parentNode\n // can be null. We just simulate parent in this case.\n if (!parent || !parent.tagName) {\n parent = {\n namespaceURI: NAMESPACE,\n tagName: 'template'\n };\n }\n const tagName = stringToLowerCase(element.tagName);\n const parentTagName = stringToLowerCase(parent.tagName);\n if (!ALLOWED_NAMESPACES[element.namespaceURI]) {\n return false;\n }\n if (element.namespaceURI === SVG_NAMESPACE) {\n // The only way to switch from HTML namespace to SVG\n // is via <svg>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'svg';\n }\n // The only way to switch from MathML to SVG is via`\n // svg if parent is either <annotation-xml> or MathML\n // text integration points.\n if (parent.namespaceURI === MATHML_NAMESPACE) {\n return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);\n }\n // We only allow elements that are defined in SVG\n // spec. All others are disallowed in SVG namespace.\n return Boolean(ALL_SVG_TAGS[tagName]);\n }\n if (element.namespaceURI === MATHML_NAMESPACE) {\n // The only way to switch from HTML namespace to MathML\n // is via <math>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'math';\n }\n // The only way to switch from SVG to MathML is via\n // <math> and HTML integration points\n if (parent.namespaceURI === SVG_NAMESPACE) {\n return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];\n }\n // We only allow elements that are defined in MathML\n // spec. All others are disallowed in MathML namespace.\n return Boolean(ALL_MATHML_TAGS[tagName]);\n }\n if (element.namespaceURI === HTML_NAMESPACE) {\n // The only way to switch from SVG to HTML is via\n // HTML integration points, and from MathML to HTML\n // is via MathML text integration points\n if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n // We disallow tags that are specific for MathML\n // or SVG and should never appear in HTML namespace\n return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);\n }\n // For XHTML and XML documents that support custom namespaces\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {\n return true;\n }\n // The code should never reach this place (this means\n // that the element somehow got namespace that is not\n // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).\n // Return false just in case.\n return false;\n };\n /**\n * _forceRemove\n *\n * @param node a DOM node\n */\n const _forceRemove = function _forceRemove(node) {\n arrayPush(DOMPurify.removed, {\n element: node\n });\n try {\n // eslint-disable-next-line unicorn/prefer-dom-node-remove\n getParentNode(node).removeChild(node);\n } catch (_) {\n remove(node);\n }\n };\n /**\n * _removeAttribute\n *\n * @param name an Attribute name\n * @param element a DOM node\n */\n const _removeAttribute = function _removeAttribute(name, element) {\n try {\n arrayPush(DOMPurify.removed, {\n attribute: element.getAttributeNode(name),\n from: element\n });\n } catch (_) {\n arrayPush(DOMPurify.removed, {\n attribute: null,\n from: element\n });\n }\n element.removeAttribute(name);\n // We void attribute values for unremovable \"is\" attributes\n if (name === 'is') {\n if (RETURN_DOM || RETURN_DOM_FRAGMENT) {\n try {\n _forceRemove(element);\n } catch (_) {}\n } else {\n try {\n element.setAttribute(name, '');\n } catch (_) {}\n }\n }\n };\n /**\n * _initDocument\n *\n * @param dirty - a string of dirty markup\n * @return a DOM, filled with the dirty markup\n */\n const _initDocument = function _initDocument(dirty) {\n /* Create a HTML document */\n let doc = null;\n let leadingWhitespace = null;\n if (FORCE_BODY) {\n dirty = '<remove></remove>' + dirty;\n } else {\n /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */\n const matches = stringMatch(dirty, /^[\\r\\n\\t ]+/);\n leadingWhitespace = matches && matches[0];\n }\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {\n // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)\n dirty = '<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>' + dirty + '</body></html>';\n }\n const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;\n /*\n * Use the DOMParser API by default, fallback later if needs be\n * DOMParser not work for svg when has multiple root element.\n */\n if (NAMESPACE === HTML_NAMESPACE) {\n try {\n doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);\n } catch (_) {}\n }\n /* Use createHTMLDocument in case DOMParser is not available */\n if (!doc || !doc.documentElement) {\n doc = implementation.createDocument(NAMESPACE, 'template', null);\n try {\n doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;\n } catch (_) {\n // Syntax error if dirtyPayload is invalid xml\n }\n }\n const body = doc.body || doc.documentElement;\n if (dirty && leadingWhitespace) {\n body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);\n }\n /* Work on whole document or just its body */\n if (NAMESPACE === HTML_NAMESPACE) {\n return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];\n }\n return WHOLE_DOCUMENT ? doc.documentElement : body;\n };\n /**\n * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.\n *\n * @param root The root element or node to start traversing on.\n * @return The created NodeIterator\n */\n const _createNodeIterator = function _createNodeIterator(root) {\n return createNodeIterator.call(root.ownerDocument || root, root,\n // eslint-disable-next-line no-bitwise\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);\n };\n /**\n * _isClobbered\n *\n * @param element element to check for clobbering attacks\n * @return true if clobbered, false if safe\n */\n const _isClobbered = function _isClobbered(element) {\n return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');\n };\n /**\n * Checks whether the given object is a DOM node.\n *\n * @param value object to check whether it's a DOM node\n * @return true is object is a DOM node\n */\n const _isNode = function _isNode(value) {\n return typeof Node === 'function' && value instanceof Node;\n };\n function _executeHooks(hooks, currentNode, data) {\n arrayForEach(hooks, hook => {\n hook.call(DOMPurify, currentNode, data, CONFIG);\n });\n }\n /**\n * _sanitizeElements\n *\n * @protect nodeName\n * @protect textContent\n * @protect removeChild\n * @param currentNode to check for permission to exist\n * @return true if node was killed, false if left alive\n */\n const _sanitizeElements = function _sanitizeElements(currentNode) {\n let content = null;\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeElements, currentNode, null);\n /* Check if element is clobbered or can clobber */\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Now let's check the element's type and name */\n const tagName = transformCaseFunc(currentNode.nodeName);\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeElement, currentNode, {\n tagName,\n allowedTags: ALLOWED_TAGS\n });\n /* Detect mXSS attempts abusing namespace confusion */\n if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\\w!]/g, currentNode.textContent)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Remove any occurrence of processing instructions */\n if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {\n _forceRemove(currentNode);\n return true;\n }\n /* Remove any kind of possibly harmful comments */\n if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\\w]/g, currentNode.data)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Remove element if anything forbids its presence */\n if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) {\n /* Check if we have a custom element to handle */\n if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {\n if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {\n return false;\n }\n if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {\n return false;\n }\n }\n /* Keep content except for bad-listed elements */\n if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {\n const parentNode = getParentNode(currentNode) || currentNode.parentNode;\n const childNodes = getChildNodes(currentNode) || currentNode.childNodes;\n if (childNodes && parentNode) {\n const childCount = childNodes.length;\n for (let i = childCount - 1; i >= 0; --i) {\n const childClone = cloneNode(childNodes[i], true);\n childClone.__removalCount = (currentNode.__removalCount || 0) + 1;\n parentNode.insertBefore(childClone, getNextSibling(currentNode));\n }\n }\n }\n _forceRemove(currentNode);\n return true;\n }\n /* Check whether element has a valid namespace */\n if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Make sure that older browsers don't get fallback-tag mXSS */\n if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\\/no(script|embed|frames)/i, currentNode.innerHTML)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Sanitize element content to be template-safe */\n if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {\n /* Get the element's text content */\n content = currentNode.textContent;\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {\n content = stringReplace(content, expr, ' ');\n });\n if (currentNode.textContent !== content) {\n arrayPush(DOMPurify.removed, {\n element: currentNode.cloneNode()\n });\n currentNode.textContent = content;\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeElements, currentNode, null);\n return false;\n };\n /**\n * _isValidAttribute\n *\n * @param lcTag Lowercase tag name of containing element.\n * @param lcName Lowercase attribute name.\n * @param value Attribute value.\n * @return Returns true if `value` is valid, otherwise false.\n */\n // eslint-disable-next-line complexity\n const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {\n /* Make sure attribute cannot clobber */\n if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {\n return false;\n }\n /* Allow valid data-* attributes: At least one character after \"-\"\n (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)\n XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)\n We don't need to check the value; it's always URI safe. */\n if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {\n if (\n // First condition does a very basic check if a) it's basically a valid custom element tagname AND\n // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck\n _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) ||\n // Alternative, second condition checks if it's an `is`-attribute, AND\n // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {\n return false;\n }\n /* Check value is safe. First, is attr inert? If so, is safe */\n } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {\n return false;\n } else ;\n return true;\n };\n /**\n * _isBasicCustomElement\n * checks if at least one dash is included in tagName, and it's not the first char\n * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name\n *\n * @param tagName name of the tag of the node to sanitize\n * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.\n */\n const _isBasicCustomElement = function _isBasicCustomElement(tagName) {\n return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);\n };\n /**\n * _sanitizeAttributes\n *\n * @protect attributes\n * @protect nodeName\n * @protect removeAttribute\n * @protect setAttribute\n *\n * @param currentNode to sanitize\n */\n const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);\n const {\n attributes\n } = currentNode;\n /* Check if we have attributes; if not we might have a text node */\n if (!attributes || _isClobbered(currentNode)) {\n return;\n }\n const hookEvent = {\n attrName: '',\n attrValue: '',\n keepAttr: true,\n allowedAttributes: ALLOWED_ATTR,\n forceKeepAttr: undefined\n };\n let l = attributes.length;\n /* Go backwards over all attributes; safely remove bad ones */\n while (l--) {\n const attr = attributes[l];\n const {\n name,\n namespaceURI,\n value: attrValue\n } = attr;\n const lcName = transformCaseFunc(name);\n const initValue = attrValue;\n let value = name === 'value' ? initValue : stringTrim(initValue);\n /* Execute a hook if present */\n hookEvent.attrName = lcName;\n hookEvent.attrValue = value;\n hookEvent.keepAttr = true;\n hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set\n _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);\n value = hookEvent.attrValue;\n /* Full DOM Clobbering protection via namespace isolation,\n * Prefix id and name attributes with `user-content-`\n */\n if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {\n // Remove the attribute with this value\n _removeAttribute(name, currentNode);\n // Prefix the value and later re-create the attribute with the sanitized value\n value = SANITIZE_NAMED_PROPS_PREFIX + value;\n }\n /* Work around a security issue with comments inside attributes */\n if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\\/(style|title|textarea)/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Make sure we cannot easily use animated hrefs, even if animations are allowed */\n if (lcName === 'attributename' && stringMatch(value, 'href')) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Did the hooks approve of the attribute? */\n if (hookEvent.forceKeepAttr) {\n continue;\n }\n /* Did the hooks approve of the attribute? */\n if (!hookEvent.keepAttr) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Work around a security issue in jQuery 3.0 */\n if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\\/>/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Sanitize attribute content to be template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {\n value = stringReplace(value, expr, ' ');\n });\n }\n /* Is `value` valid for this attribute? */\n const lcTag = transformCaseFunc(currentNode.nodeName);\n if (!_isValidAttribute(lcTag, lcName, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Handle attributes that require Trusted Types */\n if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {\n if (namespaceURI) ; else {\n switch (trustedTypes.getAttributeType(lcTag, lcName)) {\n case 'TrustedHTML':\n {\n value = trustedTypesPolicy.createHTML(value);\n break;\n }\n case 'TrustedScriptURL':\n {\n value = trustedTypesPolicy.createScriptURL(value);\n break;\n }\n }\n }\n }\n /* Handle invalid data-* attribute set by try-catching it */\n if (value !== initValue) {\n try {\n if (namespaceURI) {\n currentNode.setAttributeNS(namespaceURI, name, value);\n } else {\n /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. \"x-schema\". */\n currentNode.setAttribute(name, value);\n }\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n } else {\n arrayPop(DOMPurify.removed);\n }\n } catch (_) {\n _removeAttribute(name, currentNode);\n }\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);\n };\n /**\n * _sanitizeShadowDOM\n *\n * @param fragment to iterate over recursively\n */\n const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {\n let shadowNode = null;\n const shadowIterator = _createNodeIterator(fragment);\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);\n while (shadowNode = shadowIterator.nextNode()) {\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);\n /* Sanitize tags and elements */\n _sanitizeElements(shadowNode);\n /* Check attributes next */\n _sanitizeAttributes(shadowNode);\n /* Deep shadow DOM detected */\n if (shadowNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(shadowNode.content);\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);\n };\n // eslint-disable-next-line complexity\n DOMPurify.sanitize = function (dirty) {\n let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let body = null;\n let importedNode = null;\n let currentNode = null;\n let returnNode = null;\n /* Make sure we have a string to sanitize.\n DO NOT return early, as this will return the wrong type if\n the user has requested a DOM object rather than a string */\n IS_EMPTY_INPUT = !dirty;\n if (IS_EMPTY_INPUT) {\n dirty = '<!-->';\n }\n /* Stringify, in case dirty is an object */\n if (typeof dirty !== 'string' && !_isNode(dirty)) {\n if (typeof dirty.toString === 'function') {\n dirty = dirty.toString();\n if (typeof dirty !== 'string') {\n throw typeErrorCreate('dirty is not a string, aborting');\n }\n } else {\n throw typeErrorCreate('toString is not a function');\n }\n }\n /* Return dirty HTML if DOMPurify cannot run */\n if (!DOMPurify.isSupported) {\n return dirty;\n }\n /* Assign config vars */\n if (!SET_CONFIG) {\n _parseConfig(cfg);\n }\n /* Clean up removed elements */\n DOMPurify.removed = [];\n /* Check if dirty is correctly typed for IN_PLACE */\n if (typeof dirty === 'string') {\n IN_PLACE = false;\n }\n if (IN_PLACE) {\n /* Do some early pre-sanitization to avoid unsafe root nodes */\n if (dirty.nodeName) {\n const tagName = transformCaseFunc(dirty.nodeName);\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');\n }\n }\n } else if (dirty instanceof Node) {\n /* If dirty is a DOM element, append to an empty document to avoid\n elements being stripped by the parser */\n body = _initDocument('<!---->');\n importedNode = body.ownerDocument.importNode(dirty, true);\n if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {\n /* Node is already a body, use as is */\n body = importedNode;\n } else if (importedNode.nodeName === 'HTML') {\n body = importedNode;\n } else {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n body.appendChild(importedNode);\n }\n } else {\n /* Exit directly if we have nothing to do */\n if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&\n // eslint-disable-next-line unicorn/prefer-includes\n dirty.indexOf('<') === -1) {\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;\n }\n /* Initialize the document to work on */\n body = _initDocument(dirty);\n /* Check we have a DOM node from the data */\n if (!body) {\n return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';\n }\n }\n /* Remove first element node (ours) if FORCE_BODY is set */\n if (body && FORCE_BODY) {\n _forceRemove(body.firstChild);\n }\n /* Get node iterator */\n const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);\n /* Now start iterating over the created document */\n while (currentNode = nodeIterator.nextNode()) {\n /* Sanitize tags and elements */\n _sanitizeElements(currentNode);\n /* Check attributes next */\n _sanitizeAttributes(currentNode);\n /* Shadow DOM detected, sanitize it */\n if (currentNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(currentNode.content);\n }\n }\n /* If we sanitized `dirty` in-place, return it. */\n if (IN_PLACE) {\n return dirty;\n }\n /* Return sanitized string or DOM */\n if (RETURN_DOM) {\n if (RETURN_DOM_FRAGMENT) {\n returnNode = createDocumentFragment.call(body.ownerDocument);\n while (body.firstChild) {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n returnNode.appendChild(body.firstChild);\n }\n } else {\n returnNode = body;\n }\n if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {\n /*\n AdoptNode() is not used because internal state is not reset\n (e.g. the past names map of a HTMLFormElement), this is safe\n in theory but we would rather not risk another attack vector.\n The state that is cloned by importNode() is explicitly defined\n by the specs.\n */\n returnNode = importNode.call(originalDocument, returnNode, true);\n }\n return returnNode;\n }\n let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;\n /* Serialize doctype if allowed */\n if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {\n serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\\n' + serializedHTML;\n }\n /* Sanitize final string template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {\n serializedHTML = stringReplace(serializedHTML, expr, ' ');\n });\n }\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;\n };\n DOMPurify.setConfig = function () {\n let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _parseConfig(cfg);\n SET_CONFIG = true;\n };\n DOMPurify.clearConfig = function () {\n CONFIG = null;\n SET_CONFIG = false;\n };\n DOMPurify.isValidAttribute = function (tag, attr, value) {\n /* Initialize shared config vars if necessary. */\n if (!CONFIG) {\n _parseConfig({});\n }\n const lcTag = transformCaseFunc(tag);\n const lcName = transformCaseFunc(attr);\n return _isValidAttribute(lcTag, lcName, value);\n };\n DOMPurify.addHook = function (entryPoint, hookFunction) {\n if (typeof hookFunction !== 'function') {\n return;\n }\n arrayPush(hooks[entryPoint], hookFunction);\n };\n DOMPurify.removeHook = function (entryPoint, hookFunction) {\n if (hookFunction !== undefined) {\n const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);\n return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];\n }\n return arrayPop(hooks[entryPoint]);\n };\n DOMPurify.removeHooks = function (entryPoint) {\n hooks[entryPoint] = [];\n };\n DOMPurify.removeAllHooks = function () {\n hooks = _createHooksMap();\n };\n return DOMPurify;\n}\nvar purify = createDOMPurify();\n\nexport { purify as default };\n//# sourceMappingURL=purify.es.mjs.map\n","import { PropertyMatchType } from './types'\nimport { SurveyActionType, SurveyEventWithFilters } from './posthog-surveys-types'\nimport type { InferredSelector } from './extensions/product-tours/element-inference'\n\nexport interface JSONContent {\n type?: string\n attrs?: Record<string, any>\n content?: JSONContent[]\n marks?: { type: string; attrs?: Record<string, any> }[]\n text?: string\n}\n\nexport type ProductTourStepType = 'element' | 'modal' | 'survey'\n\nexport type ProductTourSurveyQuestionType = 'open' | 'rating'\n\nexport interface ProductTourSurveyQuestion {\n type: ProductTourSurveyQuestionType\n questionText: string\n /** Rating display type - emoji or number */\n display?: 'emoji' | 'number'\n /** Rating scale - 3 or 5 for emoji, 5 or 10 for number */\n scale?: 3 | 5 | 10\n /** Label for low end of rating scale (e.g., \"Not likely\") */\n lowerBoundLabel?: string\n /** Label for high end of rating scale (e.g., \"Very likely\") */\n upperBoundLabel?: string\n}\n\nexport interface ProductTourStep {\n id: string\n type: ProductTourStepType\n selector?: string\n progressionTrigger: 'button' | 'click'\n content: JSONContent | null\n /** Pre-rendered HTML content from the editor. If present, SDK should use this instead of rendering from JSONContent. */\n contentHtml?: string\n /** Inline survey question config - if present, this is a survey step */\n survey?: ProductTourSurveyQuestion\n /** ID of the auto-created survey for this step (set by backend) */\n linkedSurveyId?: string\n /** ID of the survey question (set by backend, used for event tracking) */\n linkedSurveyQuestionId?: string\n /** Enhanced element data for more reliable lookup at runtime */\n inferenceData?: InferredSelector\n /** Maximum tooltip width in pixels (defaults to 320px) */\n maxWidth?: number\n}\n\nexport interface ProductTourConditions {\n url?: string\n urlMatchType?: PropertyMatchType\n selector?: string\n autoShowDelaySeconds?: number\n events?: {\n values: SurveyEventWithFilters[]\n } | null\n cancelEvents?: {\n values: SurveyEventWithFilters[]\n } | null\n actions?: {\n values: SurveyActionType[]\n } | null\n}\n\nexport interface ProductTourAppearance {\n backgroundColor?: string\n textColor?: string\n buttonColor?: string\n borderRadius?: number\n buttonBorderRadius?: number\n borderColor?: string\n fontFamily?: string\n boxShadow?: string\n showOverlay?: boolean\n whiteLabel?: boolean\n}\n\nexport interface ProductTour {\n id: string\n name: string\n description?: string\n type: 'product_tour'\n auto_launch?: boolean\n start_date: string | null\n end_date: string | null\n current_iteration?: number\n conditions?: ProductTourConditions\n appearance?: ProductTourAppearance\n steps: ProductTourStep[]\n internal_targeting_flag_key?: string\n linked_flag_key?: string\n}\n\nexport type ProductTourCallback = (tours: ProductTour[], context?: { isLoaded: boolean; error?: string }) => void\n\nexport type ProductTourSelectorError = 'not_found' | 'multiple_matches' | 'not_visible'\n\nexport type ProductTourDismissReason =\n | 'user_clicked_skip'\n | 'user_clicked_outside'\n | 'escape_key'\n | 'element_unavailable'\n\nexport type ProductTourRenderReason = 'auto' | 'api' | 'trigger' | 'event'\n\nexport const DEFAULT_PRODUCT_TOUR_APPEARANCE: Required<ProductTourAppearance> = {\n backgroundColor: '#ffffff',\n textColor: '#1d1f27',\n buttonColor: '#1d1f27',\n borderRadius: 8,\n buttonBorderRadius: 6,\n borderColor: '#e5e7eb',\n fontFamily: 'system-ui',\n boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',\n showOverlay: true,\n whiteLabel: false,\n}\n\nexport interface ShowTourOptions {\n reason?: ProductTourRenderReason\n enableStrictValidation?: boolean\n}\n","var types_PostHogPersistedProperty = /*#__PURE__*/ function(PostHogPersistedProperty) {\n PostHogPersistedProperty[\"AnonymousId\"] = \"anonymous_id\";\n PostHogPersistedProperty[\"DistinctId\"] = \"distinct_id\";\n PostHogPersistedProperty[\"Props\"] = \"props\";\n PostHogPersistedProperty[\"FeatureFlagDetails\"] = \"feature_flag_details\";\n PostHogPersistedProperty[\"FeatureFlags\"] = \"feature_flags\";\n PostHogPersistedProperty[\"FeatureFlagPayloads\"] = \"feature_flag_payloads\";\n PostHogPersistedProperty[\"BootstrapFeatureFlagDetails\"] = \"bootstrap_feature_flag_details\";\n PostHogPersistedProperty[\"BootstrapFeatureFlags\"] = \"bootstrap_feature_flags\";\n PostHogPersistedProperty[\"BootstrapFeatureFlagPayloads\"] = \"bootstrap_feature_flag_payloads\";\n PostHogPersistedProperty[\"OverrideFeatureFlags\"] = \"override_feature_flags\";\n PostHogPersistedProperty[\"Queue\"] = \"queue\";\n PostHogPersistedProperty[\"OptedOut\"] = \"opted_out\";\n PostHogPersistedProperty[\"SessionId\"] = \"session_id\";\n PostHogPersistedProperty[\"SessionStartTimestamp\"] = \"session_start_timestamp\";\n PostHogPersistedProperty[\"SessionLastTimestamp\"] = \"session_timestamp\";\n PostHogPersistedProperty[\"PersonProperties\"] = \"person_properties\";\n PostHogPersistedProperty[\"GroupProperties\"] = \"group_properties\";\n PostHogPersistedProperty[\"InstalledAppBuild\"] = \"installed_app_build\";\n PostHogPersistedProperty[\"InstalledAppVersion\"] = \"installed_app_version\";\n PostHogPersistedProperty[\"SessionReplay\"] = \"session_replay\";\n PostHogPersistedProperty[\"SurveyLastSeenDate\"] = \"survey_last_seen_date\";\n PostHogPersistedProperty[\"SurveysSeen\"] = \"surveys_seen\";\n PostHogPersistedProperty[\"Surveys\"] = \"surveys\";\n PostHogPersistedProperty[\"RemoteConfig\"] = \"remote_config\";\n PostHogPersistedProperty[\"FlagsEndpointWasHit\"] = \"flags_endpoint_was_hit\";\n return PostHogPersistedProperty;\n}({});\nvar types_Compression = /*#__PURE__*/ function(Compression) {\n Compression[\"GZipJS\"] = \"gzip-js\";\n Compression[\"Base64\"] = \"base64\";\n return Compression;\n}({});\nvar types_SurveyPosition = /*#__PURE__*/ function(SurveyPosition) {\n SurveyPosition[\"TopLeft\"] = \"top_left\";\n SurveyPosition[\"TopCenter\"] = \"top_center\";\n SurveyPosition[\"TopRight\"] = \"top_right\";\n SurveyPosition[\"MiddleLeft\"] = \"middle_left\";\n SurveyPosition[\"MiddleCenter\"] = \"middle_center\";\n SurveyPosition[\"MiddleRight\"] = \"middle_right\";\n SurveyPosition[\"Left\"] = \"left\";\n SurveyPosition[\"Right\"] = \"right\";\n SurveyPosition[\"Center\"] = \"center\";\n return SurveyPosition;\n}({});\nvar types_SurveyWidgetType = /*#__PURE__*/ function(SurveyWidgetType) {\n SurveyWidgetType[\"Button\"] = \"button\";\n SurveyWidgetType[\"Tab\"] = \"tab\";\n SurveyWidgetType[\"Selector\"] = \"selector\";\n return SurveyWidgetType;\n}({});\nvar types_SurveyType = /*#__PURE__*/ function(SurveyType) {\n SurveyType[\"Popover\"] = \"popover\";\n SurveyType[\"API\"] = \"api\";\n SurveyType[\"Widget\"] = \"widget\";\n SurveyType[\"ExternalSurvey\"] = \"external_survey\";\n return SurveyType;\n}({});\nvar types_SurveyQuestionDescriptionContentType = /*#__PURE__*/ function(SurveyQuestionDescriptionContentType) {\n SurveyQuestionDescriptionContentType[\"Html\"] = \"html\";\n SurveyQuestionDescriptionContentType[\"Text\"] = \"text\";\n return SurveyQuestionDescriptionContentType;\n}({});\nvar types_SurveyRatingDisplay = /*#__PURE__*/ function(SurveyRatingDisplay) {\n SurveyRatingDisplay[\"Number\"] = \"number\";\n SurveyRatingDisplay[\"Emoji\"] = \"emoji\";\n return SurveyRatingDisplay;\n}({});\nvar types_SurveyQuestionType = /*#__PURE__*/ function(SurveyQuestionType) {\n SurveyQuestionType[\"Open\"] = \"open\";\n SurveyQuestionType[\"MultipleChoice\"] = \"multiple_choice\";\n SurveyQuestionType[\"SingleChoice\"] = \"single_choice\";\n SurveyQuestionType[\"Rating\"] = \"rating\";\n SurveyQuestionType[\"Link\"] = \"link\";\n return SurveyQuestionType;\n}({});\nvar types_SurveyQuestionBranchingType = /*#__PURE__*/ function(SurveyQuestionBranchingType) {\n SurveyQuestionBranchingType[\"NextQuestion\"] = \"next_question\";\n SurveyQuestionBranchingType[\"End\"] = \"end\";\n SurveyQuestionBranchingType[\"ResponseBased\"] = \"response_based\";\n SurveyQuestionBranchingType[\"SpecificQuestion\"] = \"specific_question\";\n return SurveyQuestionBranchingType;\n}({});\nvar types_SurveyMatchType = /*#__PURE__*/ function(SurveyMatchType) {\n SurveyMatchType[\"Regex\"] = \"regex\";\n SurveyMatchType[\"NotRegex\"] = \"not_regex\";\n SurveyMatchType[\"Exact\"] = \"exact\";\n SurveyMatchType[\"IsNot\"] = \"is_not\";\n SurveyMatchType[\"Icontains\"] = \"icontains\";\n SurveyMatchType[\"NotIcontains\"] = \"not_icontains\";\n return SurveyMatchType;\n}({});\nvar types_ActionStepStringMatching = /*#__PURE__*/ function(ActionStepStringMatching) {\n ActionStepStringMatching[\"Contains\"] = \"contains\";\n ActionStepStringMatching[\"Exact\"] = \"exact\";\n ActionStepStringMatching[\"Regex\"] = \"regex\";\n return ActionStepStringMatching;\n}({});\nconst knownUnsafeEditableEvent = [\n '$snapshot',\n '$pageview',\n '$pageleave',\n '$set',\n 'survey dismissed',\n 'survey sent',\n 'survey shown',\n '$identify',\n '$groupidentify',\n '$create_alias',\n '$$client_ingestion_warning',\n '$web_experiment_applied',\n '$feature_enrollment_update',\n '$feature_flag_called'\n];\nexport { types_ActionStepStringMatching as ActionStepStringMatching, types_Compression as Compression, types_PostHogPersistedProperty as PostHogPersistedProperty, types_SurveyMatchType as SurveyMatchType, types_SurveyPosition as SurveyPosition, types_SurveyQuestionBranchingType as SurveyQuestionBranchingType, types_SurveyQuestionDescriptionContentType as SurveyQuestionDescriptionContentType, types_SurveyQuestionType as SurveyQuestionType, types_SurveyRatingDisplay as SurveyRatingDisplay, types_SurveyType as SurveyType, types_SurveyWidgetType as SurveyWidgetType, knownUnsafeEditableEvent };\n","import { knownUnsafeEditableEvent } from \"../types.mjs\";\nimport { includes } from \"./string-utils.mjs\";\nconst nativeIsArray = Array.isArray;\nconst ObjProto = Object.prototype;\nconst type_utils_hasOwnProperty = ObjProto.hasOwnProperty;\nconst type_utils_toString = ObjProto.toString;\nconst isArray = nativeIsArray || function(obj) {\n return '[object Array]' === type_utils_toString.call(obj);\n};\nconst isFunction = (x)=>'function' == typeof x;\nconst isNativeFunction = (x)=>isFunction(x) && -1 !== x.toString().indexOf('[native code]');\nconst isObject = (x)=>x === Object(x) && !isArray(x);\nconst isEmptyObject = (x)=>{\n if (isObject(x)) {\n for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;\n return true;\n }\n return false;\n};\nconst isUndefined = (x)=>void 0 === x;\nconst isString = (x)=>'[object String]' == type_utils_toString.call(x);\nconst isEmptyString = (x)=>isString(x) && 0 === x.trim().length;\nconst isNull = (x)=>null === x;\nconst isNullish = (x)=>isUndefined(x) || isNull(x);\nconst isNumber = (x)=>'[object Number]' == type_utils_toString.call(x);\nconst isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);\nconst isFormData = (x)=>x instanceof FormData;\nconst isFile = (x)=>x instanceof File;\nconst isPlainError = (x)=>x instanceof Error;\nconst isKnownUnsafeEditableEvent = (x)=>includes(knownUnsafeEditableEvent, x);\nfunction isPrimitive(value) {\n return null === value || 'object' != typeof value;\n}\nfunction isBuiltin(candidate, className) {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`;\n}\nfunction isError(candidate) {\n switch(Object.prototype.toString.call(candidate)){\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n case '[object DOMError]':\n case '[object WebAssembly.Exception]':\n return true;\n default:\n return isInstanceOf(candidate, Error);\n }\n}\nfunction isErrorEvent(event) {\n return isBuiltin(event, 'ErrorEvent');\n}\nfunction isEvent(candidate) {\n return !isUndefined(Event) && isInstanceOf(candidate, Event);\n}\nfunction isPlainObject(candidate) {\n return isBuiltin(candidate, 'Object');\n}\nfunction isInstanceOf(candidate, base) {\n try {\n return candidate instanceof base;\n } catch {\n return false;\n }\n}\nconst yesLikeValues = [\n true,\n 'true',\n 1,\n '1',\n 'yes'\n];\nconst isYesLike = (val)=>includes(yesLikeValues, val);\nconst noLikeValues = [\n false,\n 'false',\n 0,\n '0',\n 'no'\n];\nconst isNoLike = (val)=>includes(noLikeValues, val);\nexport { type_utils_hasOwnProperty as hasOwnProperty, isArray, isBoolean, isBuiltin, isEmptyObject, isEmptyString, isError, isErrorEvent, isEvent, isFile, isFormData, isFunction, isKnownUnsafeEditableEvent, isNativeFunction, isNoLike, isNull, isNullish, isNumber, isObject, isPlainError, isPlainObject, isPrimitive, isString, isUndefined, isYesLike, noLikeValues, yesLikeValues };\n","function createConsole(consoleLike = console) {\n const lockedMethods = {\n log: consoleLike.log.bind(consoleLike),\n warn: consoleLike.warn.bind(consoleLike),\n error: consoleLike.error.bind(consoleLike),\n debug: consoleLike.debug.bind(consoleLike)\n };\n return lockedMethods;\n}\nconst _createLogger = (prefix, maybeCall, consoleLike)=>{\n function _log(level, ...args) {\n maybeCall(()=>{\n const consoleMethod = consoleLike[level];\n consoleMethod(prefix, ...args);\n });\n }\n const logger = {\n info: (...args)=>{\n _log('log', ...args);\n },\n warn: (...args)=>{\n _log('warn', ...args);\n },\n error: (...args)=>{\n _log('error', ...args);\n },\n critical: (...args)=>{\n consoleLike['error'](prefix, ...args);\n },\n createLogger: (additionalPrefix)=>_createLogger(`${prefix} ${additionalPrefix}`, maybeCall, consoleLike)\n };\n return logger;\n};\nconst passThrough = (fn)=>fn();\nfunction createLogger(prefix, maybeCall = passThrough) {\n return _createLogger(prefix, maybeCall, createConsole());\n}\nexport { _createLogger, createLogger };\n","import Config from '../config'\nimport { isUndefined } from '@posthog/core'\nimport { assignableWindow, window } from './globals'\nimport type { Logger } from '@posthog/core'\n\ntype CreateLoggerOptions = {\n debugEnabled?: boolean\n}\n\ntype PosthogJsLogger = Omit<Logger, 'createLogger'> & {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => void\n uninitializedWarning: (methodName: string) => void\n createLogger: (prefix: string, options?: CreateLoggerOptions) => PosthogJsLogger\n}\n\nconst _createLogger = (prefix: string, { debugEnabled }: CreateLoggerOptions = {}): PosthogJsLogger => {\n const logger: PosthogJsLogger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG || debugEnabled) &&\n !isUndefined(window.console) &&\n window.console\n ) {\n const consoleLog =\n '__rrweb_original__' in window.console[level]\n ? (window.console[level] as any)['__rrweb_original__']\n : window.console[level]\n\n // eslint-disable-next-line no-console\n consoleLog(prefix, ...args)\n }\n },\n\n info: (...args: any[]) => {\n logger._log('log', ...args)\n },\n\n warn: (...args: any[]) => {\n logger._log('warn', ...args)\n },\n\n error: (...args: any[]) => {\n logger._log('error', ...args)\n },\n\n critical: (...args: any[]) => {\n // Critical errors are always logged to the console\n // eslint-disable-next-line no-console\n console.error(prefix, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n\n createLogger: (additionalPrefix: string, options?: CreateLoggerOptions) =>\n _createLogger(`${prefix} ${additionalPrefix}`, options),\n }\n return logger\n}\n\nexport const logger = _createLogger('[PostHog.js]')\n\nexport const createLogger = logger.createLogger\n","import { PostHog } from '../../posthog-core'\nimport { createLogger } from '../../utils/logger'\n\nconst logger = createLogger('[Stylesheet Loader]')\n\nexport const prepareStylesheet = (document: Document, innerText: string, posthog?: PostHog) => {\n // Forcing the existence of `document` requires this function to be called in a browser environment\n let stylesheet: HTMLStyleElement | null = document.createElement('style')\n stylesheet.innerText = innerText\n\n if (posthog?.config?.prepare_external_dependency_stylesheet) {\n stylesheet = posthog.config.prepare_external_dependency_stylesheet(stylesheet)\n }\n\n if (!stylesheet) {\n logger.error('prepare_external_dependency_stylesheet returned null')\n return null\n }\n\n return stylesheet\n}\n","import { Breaker, Properties } from '../types'\nimport { nativeForEach, nativeIndexOf } from './globals'\nimport { logger } from './logger'\nimport { isFormData, isNull, isNullish, isNumber, isString, isUndefined, hasOwnProperty, isArray } from '@posthog/core'\n\nconst breaker: Breaker = {}\n\nexport function eachArray<E = any>(\n obj: E[] | null | undefined,\n iterator: (value: E, key: number) => void | Breaker,\n thisArg?: any\n): void {\n if (isArray(obj)) {\n if (nativeForEach && obj.forEach === nativeForEach) {\n obj.forEach(iterator, thisArg)\n } else if ('length' in obj && obj.length === +obj.length) {\n for (let i = 0, l = obj.length; i < l; i++) {\n if (i in obj && iterator.call(thisArg, obj[i], i) === breaker) {\n return\n }\n }\n }\n }\n}\n\n/**\n * @param {*=} obj\n * @param {function(...*)=} iterator\n * @param {Object=} thisArg\n */\nexport function each(obj: any, iterator: (value: any, key: any) => void | Breaker, thisArg?: any): void {\n if (isNullish(obj)) {\n return\n }\n if (isArray(obj)) {\n return eachArray(obj, iterator, thisArg)\n }\n if (isFormData(obj)) {\n for (const pair of obj.entries()) {\n if (iterator.call(thisArg, pair[1], pair[0]) === breaker) {\n return\n }\n }\n return\n }\n for (const key in obj) {\n if (hasOwnProperty.call(obj, key)) {\n if (iterator.call(thisArg, obj[key], key) === breaker) {\n return\n }\n }\n }\n}\n\nexport const extend = function (obj: Record<string, any>, ...args: Record<string, any>[]): Record<string, any> {\n eachArray(args, function (source) {\n for (const prop in source) {\n if (source[prop] !== void 0) {\n obj[prop] = source[prop]\n }\n }\n })\n return obj\n}\n\nexport const extendArray = function <T>(obj: T[], ...args: T[][]): T[] {\n eachArray(args, function (source) {\n eachArray(source, function (item) {\n obj.push(item)\n })\n })\n return obj\n}\n\nexport const include = function (\n obj: null | string | Array<any> | Record<string, any>,\n target: any\n): boolean | Breaker {\n let found = false\n if (isNull(obj)) {\n return found\n }\n if (nativeIndexOf && obj.indexOf === nativeIndexOf) {\n return obj.indexOf(target) != -1\n }\n each(obj, function (value) {\n if (found || (found = value === target)) {\n return breaker\n }\n return\n })\n return found\n}\n\n/**\n * Object.entries() polyfill\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries\n */\nexport function entries<T = any>(obj: Record<string, T>): [string, T][] {\n const ownProps = Object.keys(obj)\n let i = ownProps.length\n const resArray = new Array(i) // preallocate the Array\n\n while (i--) {\n resArray[i] = [ownProps[i], obj[ownProps[i]]]\n }\n return resArray\n}\n\nexport const trySafe = function <T>(fn: () => T): T | undefined {\n try {\n return fn()\n } catch {\n return undefined\n }\n}\n\nexport const safewrap = function <F extends (...args: any[]) => any = (...args: any[]) => any>(f: F): F {\n return function (...args) {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return f.apply(this, args)\n } catch (e) {\n logger.critical(\n 'Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.'\n )\n logger.critical(e)\n }\n } as F\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const safewrapClass = function (klass: Function, functions: string[]): void {\n for (let i = 0; i < functions.length; i++) {\n klass.prototype[functions[i]] = safewrap(klass.prototype[functions[i]])\n }\n}\n\nexport const stripEmptyProperties = function (p: Properties): Properties {\n const ret: Properties = {}\n each(p, function (v, k) {\n if ((isString(v) && v.length > 0) || isNumber(v)) {\n ret[k] = v\n }\n })\n return ret\n}\n\n/**\n * Deep copies an object.\n * It handles cycles by replacing all references to them with `undefined`\n * Also supports customizing native values\n *\n * @param value\n * @param customizer\n * @returns {{}|undefined|*}\n */\nfunction deepCircularCopy<T extends Record<string, any> = Record<string, any>>(\n value: T,\n customizer?: <K extends keyof T = keyof T>(value: T[K], key?: K) => T[K]\n): T | undefined {\n const COPY_IN_PROGRESS_SET = new Set()\n\n function internalDeepCircularCopy(value: T, key?: string): T | undefined {\n if (value !== Object(value)) return customizer ? customizer(value as any, key) : value // primitive value\n\n if (COPY_IN_PROGRESS_SET.has(value)) return undefined\n COPY_IN_PROGRESS_SET.add(value)\n let result: T\n\n if (isArray(value)) {\n result = [] as any as T\n eachArray(value, (it) => {\n result.push(internalDeepCircularCopy(it))\n })\n } else {\n result = {} as T\n each(value, (val, key) => {\n if (!COPY_IN_PROGRESS_SET.has(val)) {\n ;(result as any)[key] = internalDeepCircularCopy(val, key)\n }\n })\n }\n return result\n }\n return internalDeepCircularCopy(value)\n}\n\nexport function _copyAndTruncateStrings<T extends Record<string, any> = Record<string, any>>(\n object: T,\n maxStringLength: number | null\n): T {\n return deepCircularCopy(object, (value: any) => {\n if (isString(value) && !isNull(maxStringLength)) {\n return (value as string).slice(0, maxStringLength)\n }\n return value\n }) as T\n}\n\n// NOTE: Update PostHogConfig docs if you change this list\n// We will not try to catch all bullets here, but we should make an effort to catch the most common ones\n// You should be highly against adding more to this list, because ultimately customers can configure\n// their `cross_subdomain_cookie` setting to anything they want.\nconst EXCLUDED_FROM_CROSS_SUBDOMAIN_COOKIE = ['herokuapp.com', 'vercel.app', 'netlify.app']\nexport function isCrossDomainCookie(documentLocation: Location | undefined) {\n const hostname = documentLocation?.hostname\n\n if (!isString(hostname)) {\n return false\n }\n // split and slice isn't a great way to match arbitrary domains,\n // but it's good enough for ensuring we only match herokuapp.com when it is the TLD\n // for the hostname\n const lastTwoParts = hostname.split('.').slice(-2).join('.')\n\n for (const excluded of EXCLUDED_FROM_CROSS_SUBDOMAIN_COOKIE) {\n if (lastTwoParts === excluded) {\n return false\n }\n }\n\n return true\n}\n\nexport function find<T>(value: T[], predicate: (value: T) => boolean): T | undefined {\n for (let i = 0; i < value.length; i++) {\n if (predicate(value[i])) {\n return value[i]\n }\n }\n return undefined\n}\n\n// Use this instead of element.addEventListener to avoid eslint errors\n// this properly implements the default options for passive event listeners\nexport function addEventListener(\n element: Window | Document | Element | undefined,\n event: string,\n callback: EventListener,\n options?: AddEventListenerOptions\n): void {\n const { capture = false, passive = true } = options ?? {}\n\n // This is the only place where we are allowed to call this function\n // because the whole idea is that we should be calling this instead of the built-in one\n // eslint-disable-next-line posthog-js/no-add-event-listener\n element?.addEventListener(event, callback, { capture, passive })\n}\n\n/**\n * Helper to migrate deprecated config fields to new field names with appropriate warnings\n * @param config - The config object to check\n * @param newField - The new field name to use\n * @param oldField - The deprecated field name to check for\n * @param defaultValue - The default value if neither field is set\n * @param loggerInstance - Optional logger instance for deprecation warnings\n * @returns The value to use (new field takes precedence over old field)\n */\nexport function migrateConfigField<T>(\n config: Record<string, any>,\n newField: string,\n oldField: string,\n defaultValue: T,\n loggerInstance?: { warn: (message: string) => void }\n): T {\n const hasNewField = newField in config && !isUndefined(config[newField])\n const hasOldField = oldField in config && !isUndefined(config[oldField])\n\n if (hasNewField) {\n return config[newField]\n }\n\n if (hasOldField) {\n if (loggerInstance) {\n loggerInstance.warn(\n `Config field '${oldField}' is deprecated. Please use '${newField}' instead. ` +\n `The old field will be removed in a future major version.`\n )\n }\n return config[oldField]\n }\n\n return defaultValue\n}\n","import { DisplaySurveyOptions, DisplaySurveyType, Survey, SurveyType } from '../posthog-surveys-types'\nimport { createLogger } from '../utils/logger'\n\nexport const SURVEY_LOGGER = createLogger('[Surveys]')\n\nexport function isSurveyRunning(survey: Survey): boolean {\n return !!(survey.start_date && !survey.end_date)\n}\n\nexport function doesSurveyActivateByEvent(survey: Pick<Survey, 'conditions'>): boolean {\n return !!survey.conditions?.events?.values?.length\n}\n\nexport function doesSurveyActivateByAction(survey: Pick<Survey, 'conditions'>): boolean {\n return !!survey.conditions?.actions?.values?.length\n}\n\nexport const SURVEY_SEEN_PREFIX = 'seenSurvey_'\nexport const SURVEY_IN_PROGRESS_PREFIX = 'inProgressSurvey_'\nexport const SURVEY_ABANDONED_PREFIX = 'abandonedSurvey_'\n\nexport const getSurveyInteractionProperty = (\n survey: Pick<Survey, 'id' | 'current_iteration'>,\n action: 'responded' | 'dismissed'\n): string => {\n let surveyProperty = `$survey_${action}/${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n surveyProperty = `$survey_${action}/${survey.id}/${survey.current_iteration}`\n }\n\n return surveyProperty\n}\n\nconst getSurveyStorageKey = (prefix: string, survey: Pick<Survey, 'id' | 'current_iteration'>): string => {\n let key = `${prefix}${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n key = `${prefix}${survey.id}_${survey.current_iteration}`\n }\n return key\n}\n\nexport const getSurveySeenKey = (survey: Pick<Survey, 'id' | 'current_iteration'>): string => {\n return getSurveyStorageKey(SURVEY_SEEN_PREFIX, survey)\n}\n\nexport const getSurveyAbandonedKey = (survey: Pick<Survey, 'id' | 'current_iteration'>): string => {\n return getSurveyStorageKey(SURVEY_ABANDONED_PREFIX, survey)\n}\n\nexport const setSurveySeenOnLocalStorage = (survey: Pick<Survey, 'id' | 'current_iteration'>) => {\n const isSurveySeen = localStorage.getItem(getSurveySeenKey(survey))\n // if survey is already seen, no need to set it again\n if (isSurveySeen) {\n return\n }\n\n localStorage.setItem(getSurveySeenKey(survey), 'true')\n}\n\n// These surveys are relevant for the getActiveMatchingSurveys method. They are used to\n// display surveys in our customer's application. Any new in-app survey type should be added here.\nexport const IN_APP_SURVEY_TYPES = [SurveyType.Popover, SurveyType.Widget, SurveyType.API]\n\nexport const DEFAULT_DISPLAY_SURVEY_OPTIONS: DisplaySurveyOptions = {\n ignoreConditions: false,\n ignoreDelay: false,\n displayType: DisplaySurveyType.Popover,\n}\n","import { each, find } from './utils'\nimport Config from './config'\nimport { Compression, RequestWithOptions, RequestResponse } from './types'\nimport { formDataToQuery } from './utils/request-utils'\n\nimport { logger } from './utils/logger'\nimport { AbortController, fetch, navigator, XMLHttpRequest } from './utils/globals'\nimport { gzipSync, strToU8 } from 'fflate'\n\nimport { _base64Encode } from './utils/encode-utils'\n\n// eslint-disable-next-line compat/compat\nexport const SUPPORTS_REQUEST = !!XMLHttpRequest || !!fetch\n\nconst CONTENT_TYPE_PLAIN = 'text/plain'\nconst CONTENT_TYPE_JSON = 'application/json'\nconst CONTENT_TYPE_FORM = 'application/x-www-form-urlencoded'\nconst SIXTY_FOUR_KILOBYTES = 64 * 1024\n/*\n fetch will fail if we request keepalive with a body greater than 64kb\n sets the threshold lower than that so that\n any overhead doesn't push over the threshold after checking here\n*/\nconst KEEP_ALIVE_THRESHOLD = SIXTY_FOUR_KILOBYTES * 0.8\ntype EncodedBody = {\n contentType: string\n body: string | BlobPart\n estimatedSize: number\n}\n\n/**\n * Extends a URL with additional query parameters\n * @param url - The URL to extend\n * @param params - The parameters to add\n * @param replace - When true (default), new params overwrite existing ones with same key. When false, existing params are preserved.\n * @returns The URL with extended parameters\n */\nexport const extendURLParams = (url: string, params: Record<string, any>, replace: boolean = true): string => {\n const [baseUrl, search] = url.split('?')\n const newParams = { ...params }\n\n const updatedSearch =\n search?.split('&').map((pair) => {\n const [key, origValue] = pair.split('=')\n const value = replace ? (newParams[key] ?? origValue) : origValue\n delete newParams[key]\n return `${key}=${value}`\n }) ?? []\n\n const remaining = formDataToQuery(newParams)\n if (remaining) {\n updatedSearch.push(remaining)\n }\n\n return `${baseUrl}?${updatedSearch.join('&')}`\n}\n\nexport const jsonStringify = (data: any, space?: string | number): string => {\n // With plain JSON.stringify, we get an exception when a property is a BigInt. This has caused problems for some users,\n // see https://github.com/PostHog/posthog-js/issues/1440\n // To work around this, we convert BigInts to strings before stringifying the data. This is not ideal, as we lose\n // information that this was originally a number, but given ClickHouse doesn't support BigInts, the customer\n // would not be able to operate on these numerically anyway.\n return JSON.stringify(data, (_, value) => (typeof value === 'bigint' ? value.toString() : value), space)\n}\n\nconst encodeToDataString = (data: string | Record<string, any>): string => {\n return 'data=' + encodeURIComponent(typeof data === 'string' ? data : jsonStringify(data))\n}\n\nconst encodePostData = ({ data, compression }: RequestWithOptions): EncodedBody | undefined => {\n if (!data) {\n return\n }\n\n if (compression === Compression.GZipJS) {\n const gzipData = gzipSync(strToU8(jsonStringify(data)), { mtime: 0 })\n const blob = new Blob([gzipData], { type: CONTENT_TYPE_PLAIN })\n return {\n contentType: CONTENT_TYPE_PLAIN,\n body: blob,\n estimatedSize: blob.size,\n }\n }\n\n if (compression === Compression.Base64) {\n const b64data = _base64Encode(jsonStringify(data))\n const encodedBody = encodeToDataString(b64data)\n\n return {\n contentType: CONTENT_TYPE_FORM,\n body: encodedBody,\n estimatedSize: new Blob([encodedBody]).size,\n }\n }\n\n const jsonBody = jsonStringify(data)\n return {\n contentType: CONTENT_TYPE_JSON,\n body: jsonBody,\n estimatedSize: new Blob([jsonBody]).size,\n }\n}\n\nconst xhr = (options: RequestWithOptions) => {\n const req = new XMLHttpRequest!()\n req.open(options.method || 'GET', options.url, true)\n const { contentType, body } = encodePostData(options) ?? {}\n\n each(options.headers, function (headerValue, headerName) {\n req.setRequestHeader(headerName, headerValue)\n })\n\n if (contentType) {\n req.setRequestHeader('Content-Type', contentType)\n }\n\n if (options.timeout) {\n req.timeout = options.timeout\n }\n if (!options.disableXHRCredentials) {\n // send the ph_optout cookie\n // withCredentials cannot be modified until after calling .open on Android and Mobile Safari\n req.withCredentials = true\n }\n req.onreadystatechange = () => {\n // XMLHttpRequest.DONE == 4, except in safari 4\n if (req.readyState === 4) {\n const response: RequestResponse = {\n statusCode: req.status,\n text: req.responseText,\n }\n if (req.status === 200) {\n try {\n response.json = JSON.parse(req.responseText)\n } catch {\n // logger.error(e)\n }\n }\n\n options.callback?.(response)\n }\n }\n req.send(body)\n}\n\nconst _fetch = (options: RequestWithOptions) => {\n const { contentType, body, estimatedSize } = encodePostData(options) ?? {}\n\n // eslint-disable-next-line compat/compat\n const headers = new Headers()\n each(options.headers, function (headerValue, headerName) {\n headers.append(headerName, headerValue)\n })\n\n if (contentType) {\n headers.append('Content-Type', contentType)\n }\n\n const url = options.url\n let aborter: { signal: any; timeout: ReturnType<typeof setTimeout> } | null = null\n\n if (AbortController) {\n const controller = new AbortController()\n aborter = {\n signal: controller.signal,\n timeout: setTimeout(() => controller.abort(), options.timeout),\n }\n }\n\n fetch!(url, {\n method: options?.method || 'GET',\n headers,\n // if body is greater than 64kb, then fetch with keepalive will error\n // see 8:10:5 at https://fetch.spec.whatwg.org/#http-network-or-cache-fetch,\n // but we do want to set keepalive sometimes as it can help with success\n // when e.g. a page is being closed\n // so let's get the best of both worlds and only set keepalive for POST requests\n // where the body is less than 64kb\n // NB this is fetch keepalive and not http keepalive\n keepalive: options.method === 'POST' && (estimatedSize || 0) < KEEP_ALIVE_THRESHOLD,\n body,\n signal: aborter?.signal,\n ...options.fetchOptions,\n })\n .then((response) => {\n return response.text().then((responseText) => {\n const res: RequestResponse = {\n statusCode: response.status,\n text: responseText,\n }\n\n if (response.status === 200) {\n try {\n res.json = JSON.parse(responseText)\n } catch (e) {\n logger.error(e)\n }\n }\n\n options.callback?.(res)\n })\n })\n .catch((error) => {\n logger.error(error)\n options.callback?.({ statusCode: 0, text: error })\n })\n .finally(() => (aborter ? clearTimeout(aborter.timeout) : null))\n\n return\n}\n\nconst _sendBeacon = (options: RequestWithOptions) => {\n // beacon documentation https://w3c.github.io/beacon/\n // beacons format the message and use the type property\n\n const url = extendURLParams(options.url, {\n beacon: '1',\n })\n\n try {\n const { contentType, body } = encodePostData(options) ?? {}\n // sendBeacon requires a blob so we convert it\n const sendBeaconBody = typeof body === 'string' ? new Blob([body], { type: contentType }) : body\n navigator!.sendBeacon!(url, sendBeaconBody)\n } catch {\n // send beacon is a best-effort, fire-and-forget mechanism on page unload,\n // we don't want to throw errors here\n }\n}\n\nconst AVAILABLE_TRANSPORTS: {\n transport: RequestWithOptions['transport']\n method: (options: RequestWithOptions) => void\n}[] = []\n\n// We add the transports in order of preference\nif (fetch) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'fetch',\n method: _fetch,\n })\n}\n\nif (XMLHttpRequest) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'XHR',\n method: xhr,\n })\n}\n\nif (navigator?.sendBeacon) {\n AVAILABLE_TRANSPORTS.push({\n transport: 'sendBeacon',\n method: _sendBeacon,\n })\n}\n\n// This is the entrypoint. It takes care of sanitizing the options and then calls the appropriate request method.\nexport const request = (_options: RequestWithOptions) => {\n // Clone the options so we don't modify the original object\n const options = { ..._options }\n options.timeout = options.timeout || 60000\n\n options.url = extendURLParams(options.url, {\n _: new Date().getTime().toString(),\n ver: Config.LIB_VERSION,\n compression: options.compression,\n })\n\n const transport = options.transport ?? 'fetch'\n\n const availableTransports = AVAILABLE_TRANSPORTS.filter(\n (t) => !options.disableTransport || !t.transport || !options.disableTransport.includes(t.transport)\n )\n\n const transportMethod =\n find(availableTransports, (t) => t.transport === transport)?.method ?? availableTransports[0].method\n\n if (!transportMethod) {\n throw new Error('No available transport method')\n }\n\n transportMethod(options)\n}\n","export const isValidRegex = function (str: string): boolean {\n try {\n new RegExp(str)\n } catch {\n return false\n }\n return true\n}\n\nexport const isMatchingRegex = function (value: string, pattern: string): boolean {\n if (!isValidRegex(pattern)) return false\n\n try {\n return new RegExp(pattern).test(value)\n } catch {\n return false\n }\n}\n","import { isNull, isUndefined } from '@posthog/core'\nimport { jsonStringify } from '../request'\nimport { PropertyFilters, PropertyOperator } from '../posthog-surveys-types'\nimport type { Properties } from '../types'\nimport { isMatchingRegex } from './regex-utils'\n\nexport function getPersonPropertiesHash(\n distinct_id: string,\n userPropertiesToSet?: Properties,\n userPropertiesToSetOnce?: Properties\n): string {\n return jsonStringify({ distinct_id, userPropertiesToSet, userPropertiesToSetOnce })\n}\n\nexport const propertyComparisons: Record<PropertyOperator, (targets: string[], values: string[]) => boolean> = {\n exact: (targets, values) => values.some((value) => targets.some((target) => value === target)),\n is_not: (targets, values) => values.every((value) => targets.every((target) => value !== target)),\n regex: (targets, values) => values.some((value) => targets.some((target) => isMatchingRegex(value, target))),\n not_regex: (targets, values) => values.every((value) => targets.every((target) => !isMatchingRegex(value, target))),\n icontains: (targets, values) =>\n values.map(toLowerCase).some((value) => targets.map(toLowerCase).some((target) => value.includes(target))),\n not_icontains: (targets, values) =>\n values.map(toLowerCase).every((value) => targets.map(toLowerCase).every((target) => !value.includes(target))),\n gt: (targets, values) =>\n values.some((value) => {\n const numValue = parseFloat(value)\n return !isNaN(numValue) && targets.some((t) => numValue > parseFloat(t))\n }),\n lt: (targets, values) =>\n values.some((value) => {\n const numValue = parseFloat(value)\n return !isNaN(numValue) && targets.some((t) => numValue < parseFloat(t))\n }),\n}\n\nconst toLowerCase = (v: string): string => v.toLowerCase()\n\nexport function matchPropertyFilters(\n propertyFilters: PropertyFilters | undefined,\n eventProperties: Properties | undefined\n): boolean {\n // if there are no property filters, it means we're only matching on event name\n if (!propertyFilters) {\n return true\n }\n\n return Object.entries(propertyFilters).every(([propertyName, filter]) => {\n const eventPropertyValue = eventProperties?.[propertyName]\n\n if (isUndefined(eventPropertyValue) || isNull(eventPropertyValue)) {\n return false\n }\n\n // convert event property to string array for comparison\n const eventValues = [String(eventPropertyValue)]\n\n const comparisonFunction = propertyComparisons[filter.operator]\n if (!comparisonFunction) {\n return false\n }\n\n return comparisonFunction(filter.values, eventValues)\n })\n}\n","import{options as n}from\"preact\";var t,r,u,i,o=0,f=[],c=[],e=n.__b,a=n.__r,v=n.diffed,l=n.__c,m=n.unmount;function d(t,u){n.__h&&n.__h(r,t,o||u),o=0;var i=r.__H||(r.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:c}),i.__[t]}function h(n){return o=1,s(B,n)}function s(n,u,i){var o=d(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):B(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.u)){var f=function(n,t,r){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return!n.__N}))return!c||c.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),!(!i&&o.__c.props===n)&&(!c||c.call(this,n,t,r))};r.u=!0;var c=r.shouldComponentUpdate,e=r.componentWillUpdate;r.componentWillUpdate=function(n,t,r){if(this.__e){var u=c;c=void 0,f(n,t,r),c=u}e&&e.call(this,n,t,r)},r.shouldComponentUpdate=f}return o.__N||o.__}function p(u,i){var o=d(t++,3);!n.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__H.__h.push(o))}function y(u,i){var o=d(t++,4);!n.__s&&z(o.__H,i)&&(o.__=u,o.i=i,r.__h.push(o))}function _(n){return o=5,F(function(){return{current:n}},[])}function A(n,t,r){o=6,y(function(){return\"function\"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==r?r:r.concat(n))}function F(n,r){var u=d(t++,7);return z(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function T(n,t){return o=8,F(function(){return n},t)}function q(n){var u=r.context[n.__c],i=d(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function x(t,r){n.useDebugValue&&n.useDebugValue(r?r(t):t)}function P(n){var u=d(t++,10),i=h();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n,t){u.__&&u.__(n,t),i[1](n)}),[i[0],function(){i[1](void 0)}]}function V(){var n=d(t++,11);if(!n.__){for(var u=r.__v;null!==u&&!u.__m&&null!==u.__;)u=u.__;var i=u.__m||(u.__m=[0,0]);n.__=\"P\"+i[0]+\"-\"+i[1]++}return n.__}function b(){for(var t;t=f.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(k),t.__H.__h.forEach(w),t.__H.__h=[]}catch(r){t.__H.__h=[],n.__e(r,t.__v)}}n.__b=function(n){r=null,e&&e(n)},n.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=c,n.__N=n.i=void 0})):(i.__h.forEach(k),i.__h.forEach(w),i.__h=[],t=0)),u=r},n.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==f.push(o)&&i===n.requestAnimationFrame||((i=n.requestAnimationFrame)||j)(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==c&&(n.__=n.__V),n.i=void 0,n.__V=c})),u=r=null},n.__c=function(t,r){r.some(function(t){try{t.__h.forEach(k),t.__h=t.__h.filter(function(n){return!n.__||w(n)})}catch(u){r.some(function(n){n.__h&&(n.__h=[])}),r=[],n.__e(u,t.__v)}}),l&&l(t,r)},n.unmount=function(t){m&&m(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{k(n)}catch(n){r=n}}),u.__H=void 0,r&&n.__e(r,u.__v))};var g=\"function\"==typeof requestAnimationFrame;function j(n){var t,r=function(){clearTimeout(u),g&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,100);g&&(t=requestAnimationFrame(r))}function k(n){var t=r,u=n.__c;\"function\"==typeof u&&(n.__c=void 0,u()),r=t}function w(n){var t=r;n.__c=n.__(),r=t}function z(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function B(n,t){return\"function\"==typeof t?t(n):t}export{T as useCallback,q as useContext,x as useDebugValue,p as useEffect,P as useErrorBoundary,V as useId,A as useImperativeHandle,y as useLayoutEffect,F as useMemo,s as useReducer,_ as useRef,h as useState};\n//# sourceMappingURL=hooks.module.js.map\n","import { VNode, cloneElement, createContext, type JSX } from 'preact'\nimport { PostHog } from '../../posthog-core'\nimport {\n MultipleSurveyQuestion,\n Survey,\n SurveyAppearance,\n SurveyEventName,\n SurveyEventProperties,\n SurveyPosition,\n SurveyQuestion,\n SurveySchedule,\n SurveyType,\n SurveyWidgetType,\n} from '../../posthog-surveys-types'\nimport { document as _document, window as _window, userAgent } from '../../utils/globals'\nimport {\n getSurveyInteractionProperty,\n getSurveySeenKey,\n getSurveyAbandonedKey,\n SURVEY_LOGGER as logger,\n setSurveySeenOnLocalStorage,\n SURVEY_IN_PROGRESS_PREFIX,\n} from '../../utils/survey-utils'\nimport { isArray, isNullish } from '@posthog/core'\n\nimport { detectDeviceType } from '@posthog/core'\nimport { propertyComparisons } from '../../utils/property-utils'\nimport { PropertyMatchType } from '../../types'\nimport { prepareStylesheet } from '../utils/stylesheet-loader'\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst window = _window as Window & typeof globalThis\nconst document = _document as Document\nimport surveyStyles from './survey.css'\nimport { useContext } from 'preact/hooks'\n\nexport function getFontFamily(fontFamily?: string): string {\n if (fontFamily === 'inherit') {\n return 'inherit'\n }\n\n const defaultFontStack =\n 'BlinkMacSystemFont, \"Inter\", \"Segoe UI\", \"Roboto\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"'\n return fontFamily ? `${fontFamily}, ${defaultFontStack}` : `-apple-system, ${defaultFontStack}`\n}\n\nexport function getSurveyResponseKey(questionId: string) {\n return `$survey_response_${questionId}`\n}\n\nconst BLACK_TEXT_COLOR = '#020617' // Maps out to text-slate-950 from tailwind colors. Intended for text use outside interactive elements like buttons\n\n// Keep in sync with defaultSurveyAppearance on the main app\nexport const defaultSurveyAppearance = {\n fontFamily: 'inherit',\n backgroundColor: '#eeeded',\n submitButtonColor: 'black',\n submitButtonTextColor: 'white',\n ratingButtonColor: 'white',\n ratingButtonActiveColor: 'black',\n borderColor: '#c9c6c6',\n placeholder: 'Start typing...',\n whiteLabel: false,\n displayThankYouMessage: true,\n thankYouMessageHeader: 'Thank you for your feedback!',\n position: SurveyPosition.Right,\n widgetType: SurveyWidgetType.Tab,\n widgetLabel: 'Feedback',\n widgetColor: 'black',\n zIndex: '2147483647',\n disabledButtonOpacity: '0.6',\n maxWidth: '300px',\n textSubtleColor: '#939393',\n boxPadding: '20px 24px',\n boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',\n borderRadius: '10px',\n shuffleQuestions: false,\n surveyPopupDelaySeconds: undefined,\n // Not customizable atm\n outlineColor: 'rgba(59, 130, 246, 0.8)',\n inputBackground: 'white',\n inputTextColor: BLACK_TEXT_COLOR,\n scrollbarThumbColor: 'var(--ph-survey-border-color)',\n scrollbarTrackColor: 'var(--ph-survey-background-color)',\n} as const\n\nexport const addSurveyCSSVariablesToElement = (\n element: HTMLElement,\n type: SurveyType,\n appearance?: SurveyAppearance | null\n) => {\n const effectiveAppearance = { ...defaultSurveyAppearance, ...appearance }\n const hostStyle = element.style\n\n const surveyHasBottomBorder =\n ![SurveyPosition.Center, SurveyPosition.Left, SurveyPosition.Right].includes(effectiveAppearance.position) ||\n (type === SurveyType.Widget && appearance?.widgetType === SurveyWidgetType.Tab)\n\n hostStyle.setProperty('--ph-survey-font-family', getFontFamily(effectiveAppearance.fontFamily))\n hostStyle.setProperty('--ph-survey-box-padding', effectiveAppearance.boxPadding)\n hostStyle.setProperty('--ph-survey-max-width', effectiveAppearance.maxWidth)\n hostStyle.setProperty('--ph-survey-z-index', effectiveAppearance.zIndex)\n hostStyle.setProperty('--ph-survey-border-color', effectiveAppearance.borderColor)\n // Non-bottom surveys or tab surveys have the border bottom\n if (surveyHasBottomBorder) {\n hostStyle.setProperty('--ph-survey-border-radius', effectiveAppearance.borderRadius)\n hostStyle.setProperty('--ph-survey-border-bottom', '1.5px solid var(--ph-survey-border-color)')\n } else {\n hostStyle.setProperty('--ph-survey-border-bottom', 'none')\n hostStyle.setProperty(\n '--ph-survey-border-radius',\n `${effectiveAppearance.borderRadius} ${effectiveAppearance.borderRadius} 0 0`\n )\n }\n hostStyle.setProperty('--ph-survey-background-color', effectiveAppearance.backgroundColor)\n hostStyle.setProperty('--ph-survey-box-shadow', effectiveAppearance.boxShadow)\n hostStyle.setProperty('--ph-survey-disabled-button-opacity', effectiveAppearance.disabledButtonOpacity)\n hostStyle.setProperty('--ph-survey-submit-button-color', effectiveAppearance.submitButtonColor)\n hostStyle.setProperty(\n '--ph-survey-submit-button-text-color',\n appearance?.submitButtonTextColor || getContrastingTextColor(effectiveAppearance.submitButtonColor)\n )\n hostStyle.setProperty('--ph-survey-rating-bg-color', effectiveAppearance.ratingButtonColor)\n hostStyle.setProperty('--ph-survey-rating-active-bg-color', effectiveAppearance.ratingButtonActiveColor)\n // Active rating text is always auto-calculated for contrast with active background\n hostStyle.setProperty(\n '--ph-survey-rating-active-text-color',\n getContrastingTextColor(effectiveAppearance.ratingButtonActiveColor)\n )\n // Primary text color: use override if provided, otherwise auto-calculate from background\n hostStyle.setProperty(\n '--ph-survey-text-primary-color',\n appearance?.textColor || getContrastingTextColor(effectiveAppearance.backgroundColor)\n )\n hostStyle.setProperty('--ph-survey-text-subtle-color', effectiveAppearance.textSubtleColor)\n hostStyle.setProperty('--ph-widget-color', effectiveAppearance.widgetColor)\n hostStyle.setProperty('--ph-widget-text-color', getContrastingTextColor(effectiveAppearance.widgetColor))\n hostStyle.setProperty('--ph-widget-z-index', effectiveAppearance.zIndex)\n\n // Use user-provided inputBackground (or deprecated inputBackgroundColor for backwards compat)\n // Fallback to internal default, with slight adjustment for white backgrounds\n const userInputBg = appearance?.inputBackground || appearance?.inputBackgroundColor\n let inputBgColor = userInputBg || effectiveAppearance.inputBackground\n if (!userInputBg && effectiveAppearance.backgroundColor === 'white') {\n inputBgColor = '#f8f8f8'\n }\n hostStyle.setProperty('--ph-survey-input-background', inputBgColor)\n // Input text color applies to both text inputs and inactive rating buttons\n const inputTextColor = appearance?.inputTextColor || getContrastingTextColor(inputBgColor)\n hostStyle.setProperty('--ph-survey-input-text-color', inputTextColor)\n hostStyle.setProperty('--ph-survey-rating-text-color', inputTextColor)\n hostStyle.setProperty('--ph-survey-scrollbar-thumb-color', effectiveAppearance.scrollbarThumbColor)\n hostStyle.setProperty('--ph-survey-scrollbar-track-color', effectiveAppearance.scrollbarTrackColor)\n hostStyle.setProperty('--ph-survey-outline-color', effectiveAppearance.outlineColor)\n}\n\nfunction nameToHex(name: string) {\n return {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n 'indianred ': '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrodyellow: '#fafad2',\n lightgrey: '#d3d3d3',\n lightgreen: '#90ee90',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370d8',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#d87093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32',\n }[name.toLowerCase()]\n}\n\nexport function hex2rgb(c: string): string {\n if (c.startsWith('#')) {\n let hexColor = c.replace(/^#/, '')\n // Handle 3-character shorthand (e.g., #111 -> #111111, #abc -> #aabbcc)\n if (/^[0-9A-Fa-f]{3}$/.test(hexColor)) {\n hexColor = hexColor[0] + hexColor[0] + hexColor[1] + hexColor[1] + hexColor[2] + hexColor[2]\n }\n if (!/^[0-9A-Fa-f]{6}$/.test(hexColor)) {\n return 'rgb(255, 255, 255)'\n }\n const r = parseInt(hexColor.slice(0, 2), 16)\n const g = parseInt(hexColor.slice(2, 4), 16)\n const b = parseInt(hexColor.slice(4, 6), 16)\n return `rgb(${r},${g},${b})`\n }\n return 'rgb(255, 255, 255)'\n}\n\nexport function hexToRgba(hex: string, opacity: number): string {\n const rgb = hex2rgb(hex)\n const match = rgb.match(/^rgb\\((\\d+),(\\d+),(\\d+)\\)$/)\n if (!match) {\n return hex\n }\n return `rgba(${match[1]}, ${match[2]}, ${match[3]}, ${opacity})`\n}\n\nexport function getContrastingTextColor(color: string = defaultSurveyAppearance.backgroundColor) {\n let rgb\n if (color[0] === '#') {\n rgb = hex2rgb(color)\n }\n if (color.startsWith('rgb')) {\n rgb = color\n }\n // otherwise it's a color name\n const nameColorToHex = nameToHex(color)\n if (nameColorToHex) {\n rgb = hex2rgb(nameColorToHex)\n }\n if (!rgb) {\n return BLACK_TEXT_COLOR\n }\n const colorMatch = rgb.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (colorMatch) {\n const r = parseInt(colorMatch[1])\n const g = parseInt(colorMatch[2])\n const b = parseInt(colorMatch[3])\n const hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b))\n return hsp > 127.5 ? BLACK_TEXT_COLOR : 'white'\n }\n return BLACK_TEXT_COLOR\n}\n\nexport function getSurveyStylesheet(posthog?: PostHog) {\n const stylesheet = prepareStylesheet(document, typeof surveyStyles === 'string' ? surveyStyles : '', posthog)\n stylesheet?.setAttribute('data-ph-survey-style', 'true')\n return stylesheet\n}\n\nexport const retrieveSurveyShadow = (\n survey: Pick<Survey, 'id' | 'appearance' | 'type'>,\n posthog?: PostHog,\n element?: Element\n) => {\n const widgetClassName = getSurveyContainerClass(survey)\n const existingDiv = document.querySelector(`.${widgetClassName}`)\n\n if (existingDiv && existingDiv.shadowRoot) {\n return {\n shadow: existingDiv.shadowRoot,\n isNewlyCreated: false,\n }\n }\n\n // If it doesn't exist, create it\n const div = document.createElement('div')\n addSurveyCSSVariablesToElement(div, survey.type, survey.appearance)\n div.className = widgetClassName\n const shadow = div.attachShadow({ mode: 'open' })\n const stylesheet = getSurveyStylesheet(posthog)\n if (stylesheet) {\n const existingStylesheet = shadow.querySelector('style')\n if (existingStylesheet) {\n shadow.removeChild(existingStylesheet)\n }\n shadow.appendChild(stylesheet)\n }\n ;(element ? element : document.body).appendChild(div)\n return {\n shadow,\n isNewlyCreated: true,\n }\n}\n\ninterface SendSurveyEventArgs {\n responses: Record<string, string | number | string[] | null>\n survey: Survey\n surveySubmissionId: string\n isSurveyCompleted: boolean\n posthog?: PostHog\n}\n\nconst getSurveyResponseValue = (responses: Record<string, string | number | string[] | null>, questionId?: string) => {\n if (!questionId) {\n return null\n }\n const response = responses[getSurveyResponseKey(questionId)]\n if (isArray(response)) {\n return [...response]\n }\n return response\n}\n\nexport const sendSurveyEvent = ({\n responses,\n survey,\n surveySubmissionId,\n posthog,\n isSurveyCompleted,\n}: SendSurveyEventArgs) => {\n if (!posthog) {\n logger.error('[survey sent] event not captured, PostHog instance not found.')\n return\n }\n setSurveySeenOnLocalStorage(survey)\n posthog.capture(SurveyEventName.SENT, {\n [SurveyEventProperties.SURVEY_NAME]: survey.name,\n [SurveyEventProperties.SURVEY_ID]: survey.id,\n [SurveyEventProperties.SURVEY_ITERATION]: survey.current_iteration,\n [SurveyEventProperties.SURVEY_ITERATION_START_DATE]: survey.current_iteration_start_date,\n [SurveyEventProperties.SURVEY_QUESTIONS]: survey.questions.map((question) => ({\n id: question.id,\n question: question.question,\n response: getSurveyResponseValue(responses, question.id),\n })),\n [SurveyEventProperties.SURVEY_SUBMISSION_ID]: surveySubmissionId,\n [SurveyEventProperties.SURVEY_COMPLETED]: isSurveyCompleted,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...responses,\n $set: {\n [getSurveyInteractionProperty(survey, 'responded')]: true,\n },\n })\n if (isSurveyCompleted) {\n // Only dispatch PHSurveySent if the survey is completed, as that removes the survey from focus\n window.dispatchEvent(new CustomEvent('PHSurveySent', { detail: { surveyId: survey.id } }))\n clearInProgressSurveyState(survey)\n }\n}\n\nconst _surveyHasResponses = (inProgressSurvey: InProgressSurveyState | null) => {\n return Object.values(inProgressSurvey?.responses || {}).filter((resp) => !isNullish(resp)).length > 0\n}\n\nconst _buildSurveyEventProperties = (\n survey: Survey,\n inProgressSurvey: InProgressSurveyState | null,\n posthog: PostHog\n) => ({\n [SurveyEventProperties.SURVEY_NAME]: survey.name,\n [SurveyEventProperties.SURVEY_ID]: survey.id,\n [SurveyEventProperties.SURVEY_ITERATION]: survey.current_iteration,\n [SurveyEventProperties.SURVEY_ITERATION_START_DATE]: survey.current_iteration_start_date,\n [SurveyEventProperties.SURVEY_PARTIALLY_COMPLETED]: _surveyHasResponses(inProgressSurvey),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...inProgressSurvey?.responses,\n [SurveyEventProperties.SURVEY_SUBMISSION_ID]: inProgressSurvey?.surveySubmissionId,\n [SurveyEventProperties.SURVEY_QUESTIONS]: survey.questions.map((question) => ({\n id: question.id,\n question: question.question,\n response: getSurveyResponseValue(inProgressSurvey?.responses || {}, question.id),\n })),\n})\n\nexport const dismissedSurveyEvent = (survey: Survey, posthog?: PostHog, readOnly?: boolean) => {\n if (!posthog) {\n logger.error('[survey dismissed] event not captured, PostHog instance not found.')\n return\n }\n if (readOnly) {\n return\n }\n\n const inProgressSurvey = getInProgressSurveyState(survey)\n posthog.capture(SurveyEventName.DISMISSED, {\n ..._buildSurveyEventProperties(survey, inProgressSurvey, posthog),\n $set: {\n [getSurveyInteractionProperty(survey, 'dismissed')]: true,\n },\n })\n clearInProgressSurveyState(survey)\n setSurveySeenOnLocalStorage(survey)\n window.dispatchEvent(new CustomEvent('PHSurveyClosed', { detail: { surveyId: survey.id } }))\n}\n\nexport const sendSurveyAbandonedEvent = (survey: Survey, posthog?: PostHog) => {\n if (!posthog) {\n logger.error('[survey abandoned] event not captured, PostHog instance not found.')\n return\n }\n\n const abandonedKey = getSurveyAbandonedKey(survey)\n try {\n if (localStorage.getItem(abandonedKey) === 'true') {\n return\n }\n } catch {\n // localStorage not available\n return\n }\n\n const inProgressSurvey = getInProgressSurveyState(survey)\n if (!inProgressSurvey) {\n return\n }\n\n try {\n localStorage.setItem(abandonedKey, 'true')\n } catch {\n // localStorage not available\n }\n\n posthog.capture(SurveyEventName.ABANDONED, _buildSurveyEventProperties(survey, inProgressSurvey, posthog), {\n transport: 'sendBeacon',\n })\n}\n\n// Use the Fisher-yates algorithm to shuffle this array\n// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle\nexport const shuffle = (array: any[]) => {\n return array\n .map((a) => ({ sort: Math.floor(Math.random() * 10), value: a }))\n .sort((a, b) => a.sort - b.sort)\n .map((a) => a.value)\n}\n\nconst reverseIfUnshuffled = (unshuffled: any[], shuffled: any[]): any[] => {\n if (unshuffled.length === shuffled.length && unshuffled.every((val, index) => val === shuffled[index])) {\n return shuffled.reverse()\n }\n\n return shuffled\n}\n\nexport const getDisplayOrderChoices = (question: MultipleSurveyQuestion): string[] => {\n if (!question.shuffleOptions) {\n return question.choices\n }\n\n const displayOrderChoices = question.choices\n let openEndedChoice = ''\n if (question.hasOpenChoice) {\n // if the question has an open-ended choice, its always the last element in the choices array.\n openEndedChoice = displayOrderChoices.pop()!\n }\n\n const shuffledOptions = reverseIfUnshuffled(displayOrderChoices, shuffle(displayOrderChoices))\n\n if (question.hasOpenChoice) {\n question.choices.push(openEndedChoice)\n shuffledOptions.push(openEndedChoice)\n }\n\n return shuffledOptions\n}\n\nexport const getDisplayOrderQuestions = (survey: Survey): SurveyQuestion[] => {\n if (!survey.appearance || !survey.appearance.shuffleQuestions || survey.enable_partial_responses) {\n return survey.questions\n }\n\n return reverseIfUnshuffled(survey.questions, shuffle(survey.questions))\n}\n\nexport const hasEvents = (survey: Pick<Survey, 'conditions'>): boolean => {\n return survey.conditions?.events?.values?.length != undefined && survey.conditions?.events?.values?.length > 0\n}\n\nexport const canActivateRepeatedly = (\n survey: Pick<Survey, 'schedule' | 'conditions' | 'id' | 'current_iteration'>\n): boolean => {\n return (\n !!(survey.conditions?.events?.repeatedActivation && hasEvents(survey)) ||\n survey.schedule === SurveySchedule.Always ||\n isSurveyInProgress(survey)\n )\n}\n\n/**\n * getSurveySeen checks local storage for the surveySeen Key a\n * and overrides this value if the survey can be repeatedly activated by its events.\n * @param survey\n */\nexport const getSurveySeen = (survey: Survey): boolean => {\n const surveySeen = localStorage.getItem(getSurveySeenKey(survey))\n if (surveySeen) {\n // if a survey has already been seen,\n // we will override it with the event repeated activation value.\n return !canActivateRepeatedly(survey)\n }\n\n return false\n}\n\nconst LAST_SEEN_SURVEY_DATE_KEY = 'lastSeenSurveyDate'\n\nexport const hasWaitPeriodPassed = (waitPeriodInDays: number | undefined): boolean => {\n const lastSeenSurveyDate = localStorage.getItem(LAST_SEEN_SURVEY_DATE_KEY)\n if (!waitPeriodInDays || !lastSeenSurveyDate) {\n return true\n }\n\n const today = new Date()\n const diff = Math.abs(today.getTime() - new Date(lastSeenSurveyDate).getTime())\n const diffDaysFromToday = Math.ceil(diff / (1000 * 3600 * 24))\n return diffDaysFromToday > waitPeriodInDays\n}\n\ninterface SurveyContextProps {\n isPreviewMode: boolean\n previewPageIndex: number | undefined\n onPopupSurveyDismissed: () => void\n isPopup: boolean\n onPreviewSubmit: (res: string | string[] | number | null) => void\n surveySubmissionId: string\n}\n\nexport const SurveyContext = createContext<SurveyContextProps>({\n isPreviewMode: false,\n previewPageIndex: 0,\n onPopupSurveyDismissed: () => {},\n isPopup: true,\n onPreviewSubmit: () => {},\n surveySubmissionId: '',\n})\n\nexport const useSurveyContext = () => {\n return useContext(SurveyContext)\n}\n\ninterface RenderProps {\n component: VNode<{ className: string }>\n children: string\n renderAsHtml?: boolean\n style?: JSX.CSSProperties\n}\n\nexport const renderChildrenAsTextOrHtml = ({ component, children, renderAsHtml, style }: RenderProps) => {\n return renderAsHtml\n ? cloneElement(component, {\n dangerouslySetInnerHTML: { __html: children },\n style,\n })\n : cloneElement(component, {\n children,\n style,\n })\n}\n\nfunction defaultMatchType(matchType?: PropertyMatchType): PropertyMatchType {\n return matchType ?? 'icontains'\n}\n\n// use urlMatchType to validate url condition, fallback to contains for backwards compatibility\nexport function doesSurveyUrlMatch(survey: Pick<Survey, 'conditions'>): boolean {\n if (!survey.conditions?.url) {\n return true\n }\n // if we dont know the url, assume it is not a match\n const href = window?.location?.href\n if (!href) {\n return false\n }\n const targets = [survey.conditions.url]\n const matchType = defaultMatchType(survey.conditions?.urlMatchType)\n return propertyComparisons[matchType](targets, [href])\n}\n\nexport function doesSurveyDeviceTypesMatch(survey: Survey): boolean {\n if (!survey.conditions?.deviceTypes || survey.conditions?.deviceTypes.length === 0) {\n return true\n }\n // if we dont know the device type, assume it is not a match\n if (!userAgent) {\n return false\n }\n\n const deviceType = detectDeviceType(userAgent)\n return propertyComparisons[defaultMatchType(survey.conditions?.deviceTypesMatchType)](\n survey.conditions.deviceTypes,\n [deviceType]\n )\n}\n\nexport function doesSurveyMatchSelector(survey: Survey): boolean {\n if (!survey.conditions?.selector) {\n return true\n }\n return !!document?.querySelector(survey.conditions.selector)\n}\n\ninterface InProgressSurveyState {\n surveySubmissionId: string\n lastQuestionIndex: number\n responses: Record<string, string | number | string[] | null>\n}\n\nconst getInProgressSurveyStateKey = (survey: Pick<Survey, 'id' | 'current_iteration'>): string => {\n let key = `${SURVEY_IN_PROGRESS_PREFIX}${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n key = `${SURVEY_IN_PROGRESS_PREFIX}${survey.id}_${survey.current_iteration}`\n }\n return key\n}\n\nexport const setInProgressSurveyState = (\n survey: Pick<Survey, 'id' | 'current_iteration'>,\n state: InProgressSurveyState\n): void => {\n try {\n localStorage.setItem(getInProgressSurveyStateKey(survey), JSON.stringify(state))\n } catch (e) {\n logger.error('Error setting in-progress survey state in localStorage', e)\n }\n}\n\nexport const getInProgressSurveyState = (\n survey: Pick<Survey, 'id' | 'current_iteration'>\n): InProgressSurveyState | null => {\n try {\n const stateString = localStorage.getItem(getInProgressSurveyStateKey(survey))\n if (stateString) {\n return JSON.parse(stateString) as InProgressSurveyState\n }\n } catch (e) {\n logger.error('Error getting in-progress survey state from localStorage', e)\n }\n return null\n}\n\nexport const isSurveyInProgress = (survey: Pick<Survey, 'id' | 'current_iteration'>): boolean => {\n const state = getInProgressSurveyState(survey)\n return !isNullish(state?.surveySubmissionId)\n}\n\nexport const clearInProgressSurveyState = (survey: Pick<Survey, 'id' | 'current_iteration'>): void => {\n try {\n localStorage.removeItem(getInProgressSurveyStateKey(survey))\n } catch (e) {\n logger.error('Error clearing in-progress survey state from localStorage', e)\n }\n}\n\nexport function getSurveyContainerClass(survey: Pick<Survey, 'id'>, asSelector = false): string {\n const className = `PostHogSurvey-${survey.id}`\n return asSelector ? `.${className}` : className\n}\n","import DOMPurify from 'dompurify'\n\nimport {\n ProductTourAppearance,\n ProductTourSelectorError,\n ProductTourStep,\n DEFAULT_PRODUCT_TOUR_APPEARANCE,\n} from '../../posthog-product-tours-types'\nimport { prepareStylesheet } from '../utils/stylesheet-loader'\nimport { document as _document, window as _window } from '../../utils/globals'\nimport { getFontFamily, getContrastingTextColor, hexToRgba } from '../surveys/surveys-extension-utils'\n\nimport productTourStyles from './product-tour.css'\n\nconst document = _document as Document\nconst window = _window as Window & typeof globalThis\n\nexport function getProductTourStylesheet(): HTMLStyleElement | null {\n const stylesheet = prepareStylesheet(document, typeof productTourStyles === 'string' ? productTourStyles : '')\n stylesheet?.setAttribute('data-ph-product-tour-style', 'true')\n return stylesheet\n}\n\nexport interface ElementFindResult {\n element: HTMLElement | null\n error: ProductTourSelectorError | null\n matchCount: number\n}\n\nexport function findElementBySelector(selector: string): ElementFindResult {\n try {\n const elements = document.querySelectorAll(selector)\n\n if (elements.length === 0) {\n return { element: null, error: 'not_found', matchCount: 0 }\n }\n\n const element = elements[0] as HTMLElement\n\n if (!isElementVisible(element)) {\n return { element: null, error: 'not_visible', matchCount: elements.length }\n }\n\n if (elements.length > 1) {\n return { element, error: 'multiple_matches', matchCount: elements.length }\n }\n\n return { element, error: null, matchCount: 1 }\n } catch {\n return { element: null, error: 'not_found', matchCount: 0 }\n }\n}\n\nexport function isElementVisible(element: HTMLElement): boolean {\n const style = window.getComputedStyle(element)\n\n if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') {\n return false\n }\n\n const rect = element.getBoundingClientRect()\n if (rect.width === 0 || rect.height === 0) {\n return false\n }\n\n return true\n}\n\nexport function getElementMetadata(element: HTMLElement): {\n tag: string\n id: string | undefined\n classes: string | undefined\n text: string | undefined\n} {\n return {\n tag: element.tagName,\n id: element.id || undefined,\n classes: element.className || undefined,\n text: element.innerText?.slice(0, 100) || undefined,\n }\n}\n\nexport type TooltipPosition = 'top' | 'bottom' | 'left' | 'right'\n\nexport interface PositionResult {\n top: number\n left: number\n position: TooltipPosition\n}\n\nconst TOOLTIP_MARGIN = 12\nconst TOOLTIP_WIDTH = 320\nconst TOOLTIP_HEIGHT_ESTIMATE = 180\n\nexport function calculateTooltipPosition(targetRect: DOMRect): PositionResult {\n const viewportWidth = window.innerWidth\n const viewportHeight = window.innerHeight\n\n const spaceBelow = viewportHeight - targetRect.bottom\n const spaceLeft = targetRect.left\n const spaceRight = viewportWidth - targetRect.right\n\n let position: TooltipPosition\n let top: number\n let left: number\n\n if (spaceRight >= TOOLTIP_WIDTH + TOOLTIP_MARGIN) {\n position = 'right'\n top = targetRect.top + targetRect.height / 2 - TOOLTIP_HEIGHT_ESTIMATE / 2\n left = targetRect.right + TOOLTIP_MARGIN\n } else if (spaceLeft >= TOOLTIP_WIDTH + TOOLTIP_MARGIN) {\n position = 'left'\n top = targetRect.top + targetRect.height / 2 - TOOLTIP_HEIGHT_ESTIMATE / 2\n left = targetRect.left - TOOLTIP_WIDTH - TOOLTIP_MARGIN\n } else if (spaceBelow >= TOOLTIP_HEIGHT_ESTIMATE + TOOLTIP_MARGIN) {\n position = 'bottom'\n top = targetRect.bottom + TOOLTIP_MARGIN\n left = targetRect.left + targetRect.width / 2 - TOOLTIP_WIDTH / 2\n } else {\n position = 'top'\n top = targetRect.top - TOOLTIP_HEIGHT_ESTIMATE - TOOLTIP_MARGIN\n left = targetRect.left + targetRect.width / 2 - TOOLTIP_WIDTH / 2\n }\n\n return { top, left, position }\n}\n\nexport function getSpotlightStyle(targetRect: DOMRect, padding: number = 8): Record<string, string> {\n return {\n top: `${targetRect.top - padding}px`,\n left: `${targetRect.left - padding}px`,\n width: `${targetRect.width + padding * 2}px`,\n height: `${targetRect.height + padding * 2}px`,\n }\n}\n\nexport function addProductTourCSSVariablesToElement(element: HTMLElement, appearance?: ProductTourAppearance): void {\n const merged = { ...DEFAULT_PRODUCT_TOUR_APPEARANCE, ...appearance }\n const style = element.style\n\n // User-customizable variables\n style.setProperty('--ph-tour-background-color', merged.backgroundColor)\n style.setProperty('--ph-tour-text-color', merged.textColor)\n style.setProperty('--ph-tour-button-color', merged.buttonColor)\n style.setProperty('--ph-tour-border-radius', `${merged.borderRadius}px`)\n style.setProperty('--ph-tour-button-border-radius', `${merged.buttonBorderRadius}px`)\n style.setProperty('--ph-tour-border-color', merged.borderColor)\n style.setProperty('--ph-tour-font-family', getFontFamily(merged.fontFamily))\n\n // Derived colors\n style.setProperty('--ph-tour-text-secondary-color', hexToRgba(merged.textColor, 0.6))\n style.setProperty('--ph-tour-branding-text-color', getContrastingTextColor(merged.backgroundColor))\n style.setProperty('--ph-tour-button-text-color', getContrastingTextColor(merged.buttonColor))\n style.setProperty('--ph-tour-box-shadow', merged.boxShadow)\n style.setProperty('--ph-tour-overlay-color', merged.showOverlay ? 'rgba(0, 0, 0, 0.5)' : 'transparent')\n\n // Internal styling variables (not customizable)\n style.setProperty('--ph-tour-button-secondary-color', 'transparent')\n style.setProperty('--ph-tour-button-secondary-text-color', merged.textColor)\n style.setProperty('--ph-tour-max-width', '320px')\n style.setProperty('--ph-tour-padding', '16px')\n}\n\nexport function renderTipTapContent(content: any): string {\n if (!content) {\n return ''\n }\n\n if (typeof content === 'string') {\n return escapeHtml(content)\n }\n\n if (content.type === 'text') {\n let text = escapeHtml(content.text || '')\n\n if (content.marks) {\n for (const mark of content.marks) {\n switch (mark.type) {\n case 'bold':\n text = `<strong>${text}</strong>`\n break\n case 'italic':\n text = `<em>${text}</em>`\n break\n case 'underline':\n text = `<u>${text}</u>`\n break\n case 'strike':\n text = `<s>${text}</s>`\n break\n }\n }\n }\n\n return text\n }\n\n const children = content.content?.map(renderTipTapContent).join('') || ''\n\n switch (content.type) {\n case 'doc':\n return children\n case 'paragraph':\n return `<p>${children}</p>`\n case 'heading': {\n const level = content.attrs?.level || 1\n return `<h${level}>${children}</h${level}>`\n }\n case 'bulletList':\n return `<ul>${children}</ul>`\n case 'orderedList':\n return `<ol>${children}</ol>`\n case 'listItem':\n return `<li>${children}</li>`\n case 'hardBreak':\n return '<br>'\n default:\n return children\n }\n}\n\nexport function normalizeUrl(url: string): string {\n return url.endsWith('/') ? url.slice(0, -1) : url\n}\n\nfunction escapeHtml(text: string): string {\n const div = document.createElement('div')\n div.textContent = text\n return div.innerHTML\n}\n\nexport function getStepHtml(step: ProductTourStep): string {\n if (step.contentHtml) {\n return DOMPurify.sanitize(step.contentHtml, {\n ADD_TAGS: ['iframe'],\n ADD_ATTR: ['allowfullscreen', 'frameborder', 'referrerpolicy'],\n })\n }\n\n // backwards compat, will be deprecated\n return renderTipTapContent(step.content)\n}\n","import { normalizeSelector } from './normalize';\n\n/**\n* Finds first matching elements on the page that may be in a shadow root using a complex selector of n-depth\n*\n* Don't have to specify all shadow roots to button, tree is travered to find the correct element\n*\n* Example querySelectorAllDeep('downloads-item:nth-child(4) #remove');\n*\n* Example should work on chrome://downloads outputting the remove button inside of a download card component\n*\n* Example find first active download link element querySelectorDeep('#downloads-list .is-active a[href^=\"https://\"]');\n*\n* Another example querySelectorAllDeep('#downloads-list div#title-area + a');\ne.g.\n*/\nexport function querySelectorAllDeep(selector, root = document, allElements = null) {\n return _querySelectorDeep(selector, true, root, allElements);\n}\n\nexport function querySelectorDeep(selector, root = document, allElements = null) {\n return _querySelectorDeep(selector, false, root, allElements);\n}\n\nfunction _querySelectorDeep(selector, findMany, root, allElements = null) {\n selector = normalizeSelector(selector);\n let lightElement = root.querySelector(selector);\n\n if (document.head.createShadowRoot || document.head.attachShadow) {\n // no need to do any special if selector matches something specific in light-dom\n if (!findMany && lightElement) {\n return lightElement;\n }\n\n // split on commas because those are a logical divide in the operation\n const selectionsToMake = splitByCharacterUnlessQuoted(selector, ',');\n\n return selectionsToMake.reduce((acc, minimalSelector) => {\n // if not finding many just reduce the first match\n if (!findMany && acc) {\n return acc;\n }\n // do best to support complex selectors and split the query\n const splitSelector = splitByCharacterUnlessQuoted(minimalSelector\n //remove white space at start of selector\n .replace(/^\\s+/g, '')\n .replace(/\\s*([>+~]+)\\s*/g, '$1'), ' ')\n // filter out entry white selectors\n .filter((entry) => !!entry)\n // convert \"a > b\" to [\"a\", \"b\"]\n .map((entry) => splitByCharacterUnlessQuoted(entry, '>'));\n\n const possibleElementsIndex = splitSelector.length - 1;\n const lastSplitPart = splitSelector[possibleElementsIndex][splitSelector[possibleElementsIndex].length - 1];\n const possibleElements = collectAllElementsDeep(lastSplitPart, root, allElements);\n const findElements = findMatchingElement(splitSelector, possibleElementsIndex, root);\n if (findMany) {\n acc = acc.concat(possibleElements.filter(findElements));\n return acc;\n } else {\n acc = possibleElements.find(findElements);\n return acc || null;\n }\n }, findMany ? [] : null);\n\n\n } else {\n if (!findMany) {\n return lightElement;\n } else {\n return root.querySelectorAll(selector);\n }\n }\n\n}\n\nfunction findMatchingElement(splitSelector, possibleElementsIndex, root) {\n return (element) => {\n let position = possibleElementsIndex;\n let parent = element;\n let foundElement = false;\n while (parent && !isDocumentNode(parent)) {\n let foundMatch = true;\n if (splitSelector[position].length === 1) {\n foundMatch = parent.matches(splitSelector[position]);\n } else {\n // selector is in the format \"a > b\"\n // make sure a few parents match in order\n const reversedParts = ([]).concat(splitSelector[position]).reverse();\n let newParent = parent;\n for (const part of reversedParts) {\n if (!newParent || !newParent.matches(part)) {\n foundMatch = false;\n break;\n }\n newParent = findParentOrHost(newParent, root);\n }\n }\n\n if (foundMatch && position === 0) {\n foundElement = true;\n break;\n }\n if (foundMatch) {\n position--;\n }\n parent = findParentOrHost(parent, root);\n }\n return foundElement;\n };\n\n}\n\nfunction splitByCharacterUnlessQuoted(selector, character) {\n return selector.match(/\\\\?.|^$/g).reduce((p, c) => {\n if (c === '\"' && !p.sQuote) {\n p.quote ^= 1;\n p.a[p.a.length - 1] += c;\n } else if (c === '\\'' && !p.quote) {\n p.sQuote ^= 1;\n p.a[p.a.length - 1] += c;\n\n } else if (!p.quote && !p.sQuote && c === character) {\n p.a.push('');\n } else {\n p.a[p.a.length - 1] += c;\n }\n return p;\n }, { a: [''] }).a;\n}\n\n/**\n * Checks if the node is a document node or not.\n * @param {Node} node\n * @returns {node is Document | DocumentFragment}\n */\nfunction isDocumentNode(node) {\n return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.DOCUMENT_NODE;\n}\n\nfunction findParentOrHost(element, root) {\n const parentNode = element.parentNode;\n return (parentNode && parentNode.host && parentNode.nodeType === 11) ? parentNode.host : parentNode === root ? null : parentNode;\n}\n\n/**\n * Finds all elements on the page, inclusive of those within shadow roots.\n * @param {string=} selector Simple selector to filter the elements by. e.g. 'a', 'div.main'\n * @return {!Array<string>} List of anchor hrefs.\n * @author ebidel@ (Eric Bidelman)\n * License Apache-2.0\n */\nexport function collectAllElementsDeep(selector = null, root, cachedElements = null) {\n let allElements = [];\n\n if (cachedElements) {\n allElements = cachedElements;\n } else {\n const findAllElements = function(nodes) {\n for (let i = 0; i < nodes.length; i++) {\n const el = nodes[i];\n allElements.push(el);\n // If the element has a shadow root, dig deeper.\n if (el.shadowRoot) {\n findAllElements(el.shadowRoot.querySelectorAll('*'));\n }\n }\n };\n if(root.shadowRoot) {\n findAllElements(root.shadowRoot.querySelectorAll('*'));\n }\n findAllElements(root.querySelectorAll('*'));\n }\n\n return selector ? allElements.filter(el => el.matches(selector)) : allElements;\t}\n\n","/* istanbul ignore file */\n\n\n// normalize-selector-rev-02.js\n/*\n author: kyle simpson (@getify)\n original source: https://gist.github.com/getify/9679380\n\n modified for tests by david kaye (@dfkaye)\n 21 march 2014\n\n rev-02 incorporate kyle's changes 3/2/42014\n*/\n\nexport function normalizeSelector(sel) {\n // save unmatched text, if any\n function saveUnmatched() {\n if (unmatched) {\n // whitespace needed after combinator?\n if (tokens.length > 0 && /^[~+>]$/.test(tokens[tokens.length - 1])) {\n tokens.push(\" \");\n }\n\n // save unmatched text\n tokens.push(unmatched);\n }\n }\n\n var tokens = [],\n match,\n unmatched,\n regex,\n state = [0],\n next_match_idx = 0,\n prev_match_idx,\n not_escaped_pattern = /(?:[^\\\\]|(?:^|[^\\\\])(?:\\\\\\\\)+)$/,\n whitespace_pattern = /^\\s+$/,\n state_patterns = [\n /\\s+|\\/\\*|[\"'>~+[(]/g, // general\n /\\s+|\\/\\*|[\"'[\\]()]/g, // [..] set\n /\\s+|\\/\\*|[\"'[\\]()]/g, // (..) set\n null, // string literal (placeholder)\n /\\*\\//g, // comment\n ];\n sel = sel.trim();\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n unmatched = \"\";\n\n regex = state_patterns[state[state.length - 1]];\n\n regex.lastIndex = next_match_idx;\n match = regex.exec(sel);\n\n // matched text to process?\n if (match) {\n prev_match_idx = next_match_idx;\n next_match_idx = regex.lastIndex;\n\n // collect the previous string chunk not matched before this token\n if (prev_match_idx < next_match_idx - match[0].length) {\n unmatched = sel.substring(\n prev_match_idx,\n next_match_idx - match[0].length\n );\n }\n\n // general, [ ] pair, ( ) pair?\n if (state[state.length - 1] < 3) {\n saveUnmatched();\n\n // starting a [ ] pair?\n if (match[0] === \"[\") {\n state.push(1);\n }\n // starting a ( ) pair?\n else if (match[0] === \"(\") {\n state.push(2);\n }\n // starting a string literal?\n else if (/^[\"']$/.test(match[0])) {\n state.push(3);\n state_patterns[3] = new RegExp(match[0], \"g\");\n }\n // starting a comment?\n else if (match[0] === \"/*\") {\n state.push(4);\n }\n // ending a [ ] or ( ) pair?\n else if (/^[\\])]$/.test(match[0]) && state.length > 0) {\n state.pop();\n }\n // handling whitespace or a combinator?\n else if (/^(?:\\s+|[~+>])$/.test(match[0])) {\n // need to insert whitespace before?\n if (\n tokens.length > 0 &&\n !whitespace_pattern.test(tokens[tokens.length - 1]) &&\n state[state.length - 1] === 0\n ) {\n // add normalized whitespace\n tokens.push(\" \");\n }\n\n // case-insensitive attribute selector CSS L4\n if (\n state[state.length - 1] === 1 &&\n tokens.length === 5 &&\n tokens[2].charAt(tokens[2].length - 1) === \"=\"\n ) {\n tokens[4] = \" \" + tokens[4];\n }\n\n // whitespace token we can skip?\n if (whitespace_pattern.test(match[0])) {\n continue;\n }\n }\n\n // save matched text\n tokens.push(match[0]);\n }\n // otherwise, string literal or comment\n else {\n // save unmatched text\n tokens[tokens.length - 1] += unmatched;\n\n // unescaped terminator to string literal or comment?\n if (not_escaped_pattern.test(tokens[tokens.length - 1])) {\n // comment terminator?\n if (state[state.length - 1] === 4) {\n // ok to drop comment?\n if (\n tokens.length < 2 ||\n whitespace_pattern.test(tokens[tokens.length - 2])\n ) {\n tokens.pop();\n }\n // otherwise, turn comment into whitespace\n else {\n tokens[tokens.length - 1] = \" \";\n }\n\n // handled already\n match[0] = \"\";\n }\n\n state.pop();\n }\n\n // append matched text to existing token\n tokens[tokens.length - 1] += match[0];\n }\n }\n // otherwise, end of processing (no more matches)\n else {\n unmatched = sel.substr(next_match_idx);\n saveUnmatched();\n\n break;\n }\n }\n\n return tokens.join(\"\").trim();\n}\n","import { querySelectorAllDeep } from 'query-selector-shadow-dom'\nimport { window as _window } from '../../utils/globals'\nimport { createLogger, isArray, isUndefined } from '@posthog/core'\n\nconst window = _window as Window & typeof globalThis\nconst logger = createLogger('[Element Inference]')\n\n// this is copied directly from the main repo: /frontend/src/toolbar/utils.ts\n// TODO: once this is deployed, we can have the main repo reference this instead\nexport function elementIsVisible(element: HTMLElement, cache: WeakMap<HTMLElement, boolean>): boolean {\n try {\n const alreadyCached = cache.get(element)\n if (!isUndefined(alreadyCached)) {\n return alreadyCached\n }\n\n if (element.checkVisibility) {\n const nativeIsVisible = element.checkVisibility({\n checkOpacity: true,\n checkVisibilityCSS: true,\n })\n cache.set(element, nativeIsVisible)\n return nativeIsVisible\n }\n\n const style = window.getComputedStyle(element)\n const isInvisible = style.display === 'none' || style.visibility === 'hidden' || parseFloat(style.opacity) === 0\n if (isInvisible) {\n cache.set(element, false)\n return false\n }\n\n // Check parent chain for display/visibility\n let parent = element.parentElement\n while (parent) {\n // Check cache first\n const cached = cache.get(parent)\n if (!isUndefined(cached)) {\n if (!cached) {\n return false\n }\n // If cached as visible, skip to next parent\n parent = parent.parentElement\n continue\n }\n\n const parentStyle = window.getComputedStyle(parent)\n const parentVisible = parentStyle.display !== 'none' && parentStyle.visibility !== 'hidden'\n\n cache.set(parent, parentVisible)\n\n if (!parentVisible) {\n return false\n }\n parent = parent.parentElement\n }\n\n // Check if element has actual rendered dimensions\n const rect = element.getBoundingClientRect()\n const elementHasActualRenderedDimensions =\n rect.width > 0 ||\n rect.height > 0 ||\n // Some elements might be 0x0 but still visible (e.g., inline elements with content)\n element.getClientRects().length > 0\n cache.set(element, elementHasActualRenderedDimensions)\n return elementHasActualRenderedDimensions\n } catch {\n // if we can't get the computed style, we'll assume the element is visible\n return true\n }\n}\n\nexport interface SelectorGroup {\n cardinality: number\n cssSelectors: Array<{\n css: string\n offset: number\n }>\n}\n\nexport interface AutoData {\n notextGroups: SelectorGroup[]\n textGroups: SelectorGroup[]\n}\n\nexport interface InferredSelector {\n autoData: string\n text: string | null\n excludeText?: boolean\n}\n\nfunction getElementText(element: HTMLElement): string | null {\n const text = element.innerText?.trim()\n // anything higher than 250 chars -> prob not a good selector / button / target\n if (!text || text.length > 250) {\n return null\n }\n return text\n}\n\nfunction elementMatchesText(element: HTMLElement, text: string): boolean {\n const elementText = getElementText(element)\n return elementText?.toLowerCase() === text.toLowerCase()\n}\n\n// generator to query elements, filtering by text and visibility\nfunction* queryElements(\n selector: string,\n text: string | null,\n visibilityCache: WeakMap<HTMLElement, boolean>\n): Generator<HTMLElement, void, undefined> {\n let elements: HTMLElement[]\n\n try {\n elements = querySelectorAllDeep(selector) as unknown as HTMLElement[]\n } catch {\n return\n }\n\n for (const el of elements) {\n const element = el as HTMLElement\n if (text && !elementMatchesText(element, text)) {\n continue\n }\n if (!elementIsVisible(element, visibilityCache)) {\n continue\n }\n yield element\n }\n}\n\n// could be inlined, but wanna keep lazy eval from queryElements\nfunction nth<T>(iterable: Iterable<T>, n: number): T | null {\n let idx = 0\n for (const item of iterable) {\n if (idx === n) {\n return item\n }\n idx++\n }\n return null\n}\n\n/**\n * if inferSelector is the sauce, this is the nugget\n *\n * find an element in the dom using the element inference data\n *\n * 1. try each group of selectors, starting with most specific (lowest cardinality)\n * 2. try each selector in the group - run the css query, go to offset\n * 3. \"vote\" for the element if it was found\n * 4. return early if any element gets majority votes\n * 5. return element w/ most votes\n */\nexport function findElement(selector: InferredSelector): HTMLElement | null {\n try {\n const autoData = JSON.parse(selector.autoData) as AutoData\n if (!isArray(autoData?.textGroups) || !isArray(autoData?.notextGroups)) {\n logger.error('Invalid autoData structure:', autoData)\n return null\n }\n const { text, excludeText } = selector\n\n // excludeText -> user setting, usually if the target element\n // has dynamic/localized text\n const useText = text != null && !excludeText\n\n // choose appropriate group + sort\n const groups = (useText ? autoData.textGroups : autoData.notextGroups).sort(\n (a, b) => a.cardinality - b.cardinality\n )\n\n if (groups.length === 0) {\n return null\n }\n\n const visibilityCache = new WeakMap<HTMLElement, boolean>()\n\n // try each selector group, starting w/ most specific (lowest cardinality)\n for (const group of groups) {\n const votes = new Map<HTMLElement, number>()\n let winner: HTMLElement | null = null\n let maxVotes = 0\n\n // test each selector in the group\n for (const { css, offset } of group.cssSelectors) {\n // get matches, jump to offset to find our target\n const element = nth(queryElements(css, useText ? text : null, visibilityCache), offset)\n\n if (!element) {\n continue\n }\n\n // if we found something, this element gets a vote\n const voteCount = (votes.get(element) ?? 0) + 1\n votes.set(element, voteCount)\n\n if (voteCount > maxVotes) {\n maxVotes = voteCount\n winner = element\n\n // break early if we have a majority\n if (voteCount >= Math.ceil(group.cssSelectors.length / 2)) {\n return winner\n }\n }\n }\n\n if (winner) {\n return winner\n }\n }\n\n return null\n } catch (error) {\n logger.error('Error finding element:', error)\n return null\n }\n}\n\nexport function getElementPath(el: HTMLElement | null, depth = 4): string | null {\n if (!el) {\n return null\n }\n const parts: string[] = []\n let current: HTMLElement | null = el\n\n while (current && parts.length < depth && current.tagName !== 'BODY') {\n let part = current.tagName.toLowerCase()\n if (current.id) {\n part += `#${current.id}`\n } else if (current.classList.length) {\n part += `.${current.classList[0]}`\n }\n parts.unshift(part)\n current = current.parentElement\n }\n\n return parts.join(' > ')\n}\n","export const satisfiedEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146 272q66 0 121.5-35.5T682-393h-52q-23 40-63 61.5T480.5-310q-46.5 0-87-21T331-393h-53q26 61 81 96.5T480-261Zm0 181q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\" />\n </svg>\n)\nexport const neutralEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm20 194h253v-49H354v49ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\" />\n </svg>\n)\nexport const dissatisfiedEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M626-533q22.5 0 38.25-15.75T680-587q0-22.5-15.75-38.25T626-641q-22.5 0-38.25 15.75T572-587q0 22.5 15.75 38.25T626-533Zm-292 0q22.5 0 38.25-15.75T388-587q0-22.5-15.75-38.25T334-641q-22.5 0-38.25 15.75T280-587q0 22.5 15.75 38.25T334-533Zm146.174 116Q413-417 358.5-379.5T278-280h53q22-42 62.173-65t87.5-23Q528-368 567.5-344.5T630-280h52q-25-63-79.826-100-54.826-37-122-37ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\" />\n </svg>\n)\nexport const veryDissatisfiedEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M480-417q-67 0-121.5 37.5T278-280h404q-25-63-80-100t-122-37Zm-183-72 50-45 45 45 31-36-45-45 45-45-31-36-45 45-50-45-31 36 45 45-45 45 31 36Zm272 0 44-45 51 45 31-36-45-45 45-45-31-36-51 45-44-45-31 36 44 45-44 45 31 36ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142 0 241-99t99-241q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 142 99 241t241 99Z\" />\n </svg>\n)\nexport const verySatisfiedEmoji = (\n <svg className=\"emoji-svg\" xmlns=\"http://www.w3.org/2000/svg\" height=\"48\" viewBox=\"0 -960 960 960\" width=\"48\">\n <path d=\"M479.504-261Q537-261 585.5-287q48.5-26 78.5-72.4 6-11.6-.75-22.6-6.75-11-20.25-11H316.918Q303-393 296.5-382t-.5 22.6q30 46.4 78.5 72.4 48.5 26 105.004 26ZM347-578l27 27q7.636 8 17.818 8Q402-543 410-551q8-8 8-18t-8-18l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.636-8 17.818Q276-559 284-551q8 8 18 8t18-8l27-27Zm267 0 27 27q7.714 8 18 8t18-8q8-7.636 8-17.818Q685-579 677-587l-42-42q-8.8-9-20.9-9-12.1 0-21.1 9l-42 42q-8 7.714-8 18t8 18q7.636 8 17.818 8Q579-543 587-551l27-27ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 340q142.375 0 241.188-98.812Q820-337.625 820-480t-98.812-241.188Q622.375-820 480-820t-241.188 98.812Q140-622.375 140-480t98.812 241.188Q337.625-140 480-140Z\" />\n </svg>\n)\nexport const cancelSVG = (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-labelledby=\"close-survey-title\"\n >\n <title id=\"close-survey-title\">Close survey</title>\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M0.164752 0.164752C0.384422 -0.0549175 0.740578 -0.0549175 0.960248 0.164752L6 5.20451L11.0398 0.164752C11.2594 -0.0549175 11.6156 -0.0549175 11.8352 0.164752C12.0549 0.384422 12.0549 0.740578 11.8352 0.960248L6.79549 6L11.8352 11.0398C12.0549 11.2594 12.0549 11.6156 11.8352 11.8352C11.6156 12.0549 11.2594 12.0549 11.0398 11.8352L6 6.79549L0.960248 11.8352C0.740578 12.0549 0.384422 12.0549 0.164752 11.8352C-0.0549175 11.6156 -0.0549175 11.2594 0.164752 11.0398L5.20451 6L0.164752 0.960248C-0.0549175 0.740578 -0.0549175 0.384422 0.164752 0.164752Z\"\n fill=\"black\"\n />\n </svg>\n)\nexport const IconPosthogLogo = (\n <svg width=\"77\" height=\"14\" viewBox=\"0 0 77 14\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <g clip-path=\"url(#clip0_2415_6911)\">\n <mask\n id=\"mask0_2415_6911\"\n style={{ maskType: 'luminance' }}\n maskUnits=\"userSpaceOnUse\"\n x=\"0\"\n y=\"0\"\n width=\"77\"\n height=\"14\"\n >\n <path d=\"M0.5 0H76.5V14H0.5V0Z\" fill=\"white\" />\n </mask>\n <g mask=\"url(#mask0_2415_6911)\">\n <path\n d=\"M5.77226 8.02931C5.59388 8.37329 5.08474 8.37329 4.90634 8.02931L4.4797 7.20672C4.41155 7.07535 4.41155 6.9207 4.4797 6.78933L4.90634 5.96669C5.08474 5.62276 5.59388 5.62276 5.77226 5.96669L6.19893 6.78933C6.26709 6.9207 6.26709 7.07535 6.19893 7.20672L5.77226 8.02931ZM5.77226 12.6946C5.59388 13.0386 5.08474 13.0386 4.90634 12.6946L4.4797 11.872C4.41155 11.7406 4.41155 11.586 4.4797 11.4546L4.90634 10.632C5.08474 10.288 5.59388 10.288 5.77226 10.632L6.19893 11.4546C6.26709 11.586 6.26709 11.7406 6.19893 11.872L5.77226 12.6946Z\"\n fill=\"#1D4AFF\"\n />\n <path\n d=\"M0.5 10.9238C0.5 10.508 1.02142 10.2998 1.32637 10.5938L3.54508 12.7327C3.85003 13.0267 3.63405 13.5294 3.20279 13.5294H0.984076C0.716728 13.5294 0.5 13.3205 0.5 13.0627V10.9238ZM0.5 8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.19753 13.3927C5.28831 13.4802 5.41144 13.5294 5.53982 13.5294H8.0421C8.47337 13.5294 8.68936 13.0267 8.3844 12.7327L1.32637 5.92856C1.02142 5.63456 0.5 5.84278 0.5 6.25854V8.67083ZM0.5 4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L10.0368 13.3927C10.1276 13.4802 10.2508 13.5294 10.3791 13.5294H12.8814C13.3127 13.5294 13.5287 13.0267 13.2237 12.7327L1.32637 1.26329C1.02142 0.969312 0.5 1.17752 0.5 1.59327V4.00556ZM5.33931 4.00556C5.33931 4.12932 5.39033 4.24802 5.4811 4.33554L14.1916 12.7327C14.4965 13.0267 15.0179 12.8185 15.0179 12.4028V9.99047C15.0179 9.86671 14.9669 9.74799 14.8762 9.66049L6.16568 1.26329C5.86071 0.969307 5.33931 1.17752 5.33931 1.59327V4.00556ZM11.005 1.26329C10.7 0.969307 10.1786 1.17752 10.1786 1.59327V4.00556C10.1786 4.12932 10.2296 4.24802 10.3204 4.33554L14.1916 8.06748C14.4965 8.36148 15.0179 8.15325 15.0179 7.7375V5.3252C15.0179 5.20144 14.9669 5.08272 14.8762 4.99522L11.005 1.26329Z\"\n fill=\"#F9BD2B\"\n />\n <path\n d=\"M21.0852 10.981L16.5288 6.58843C16.2238 6.29443 15.7024 6.50266 15.7024 6.91841V13.0627C15.7024 13.3205 15.9191 13.5294 16.1865 13.5294H23.2446C23.5119 13.5294 23.7287 13.3205 23.7287 13.0627V12.5032C23.7287 12.2455 23.511 12.0396 23.2459 12.0063C22.4323 11.9042 21.6713 11.546 21.0852 10.981ZM18.0252 12.0365C17.5978 12.0365 17.251 11.7021 17.251 11.2901C17.251 10.878 17.5978 10.5436 18.0252 10.5436C18.4527 10.5436 18.7996 10.878 18.7996 11.2901C18.7996 11.7021 18.4527 12.0365 18.0252 12.0365Z\"\n fill=\"currentColor\"\n />\n <path\n d=\"M0.5 13.0627C0.5 13.3205 0.716728 13.5294 0.984076 13.5294H3.20279C3.63405 13.5294 3.85003 13.0267 3.54508 12.7327L1.32637 10.5938C1.02142 10.2998 0.5 10.508 0.5 10.9238V13.0627ZM5.33931 5.13191L1.32637 1.26329C1.02142 0.969306 0.5 1.17752 0.5 1.59327V4.00556C0.5 4.12932 0.551001 4.24802 0.641783 4.33554L5.33931 8.86412V5.13191ZM1.32637 5.92855C1.02142 5.63455 0.5 5.84278 0.5 6.25853V8.67083C0.5 8.79459 0.551001 8.91331 0.641783 9.00081L5.33931 13.5294V9.79717L1.32637 5.92855Z\"\n fill=\"#1D4AFF\"\n />\n <path\n d=\"M10.1787 5.3252C10.1787 5.20144 10.1277 5.08272 10.0369 4.99522L6.16572 1.26329C5.8608 0.969306 5.33936 1.17752 5.33936 1.59327V4.00556C5.33936 4.12932 5.39037 4.24802 5.48114 4.33554L10.1787 8.86412V5.3252ZM5.33936 13.5294H8.04214C8.47341 13.5294 8.6894 13.0267 8.38443 12.7327L5.33936 9.79717V13.5294ZM5.33936 5.13191V8.67083C5.33936 8.79459 5.39037 8.91331 5.48114 9.00081L10.1787 13.5294V9.99047C10.1787 9.86671 10.1277 9.74803 10.0369 9.66049L5.33936 5.13191Z\"\n fill=\"#F54E00\"\n />\n <path\n d=\"M29.375 11.6667H31.3636V8.48772H33.0249C34.8499 8.48772 36.0204 7.4443 36.0204 5.83052C36.0204 4.21681 34.8499 3.17334 33.0249 3.17334H29.375V11.6667ZM31.3636 6.84972V4.81136H32.8236C33.5787 4.81136 34.0318 5.19958 34.0318 5.83052C34.0318 6.4615 33.5787 6.84972 32.8236 6.84972H31.3636ZM39.618 11.7637C41.5563 11.7637 42.9659 10.429 42.9659 8.60905C42.9659 6.78905 41.5563 5.45438 39.618 5.45438C37.6546 5.45438 36.2701 6.78905 36.2701 8.60905C36.2701 10.429 37.6546 11.7637 39.618 11.7637ZM38.1077 8.60905C38.1077 7.63838 38.7118 6.97105 39.618 6.97105C40.5116 6.97105 41.1157 7.63838 41.1157 8.60905C41.1157 9.57972 40.5116 10.2471 39.618 10.2471C38.7118 10.2471 38.1077 9.57972 38.1077 8.60905ZM46.1482 11.7637C47.6333 11.7637 48.6402 10.8658 48.6402 9.81025C48.6402 7.33505 45.2294 8.13585 45.2294 7.16518C45.2294 6.8983 45.5189 6.72843 45.9342 6.72843C46.3622 6.72843 46.8782 6.98318 47.0418 7.54132L48.527 6.94678C48.2375 6.06105 47.1677 5.45438 45.8713 5.45438C44.4743 5.45438 43.6058 6.25518 43.6058 7.21372C43.6058 9.53118 46.9663 8.88812 46.9663 9.84665C46.9663 10.1864 46.6391 10.417 46.1482 10.417C45.4434 10.417 44.9525 9.94376 44.8015 9.3735L43.3164 9.93158C43.6436 10.8537 44.6001 11.7637 46.1482 11.7637ZM53.4241 11.606L53.2982 10.0651C53.0843 10.1743 52.8074 10.2106 52.5808 10.2106C52.1278 10.2106 51.8257 9.89523 51.8257 9.34918V7.03172H53.3612V5.55145H51.8257V3.78001H49.9755V5.55145H48.9687V7.03172H49.9755V9.57972C49.9755 11.06 51.0202 11.7637 52.3921 11.7637C52.7696 11.7637 53.122 11.7031 53.4241 11.606ZM59.8749 3.17334V6.47358H56.376V3.17334H54.3874V11.6667H56.376V8.11158H59.8749V11.6667H61.8761V3.17334H59.8749ZM66.2899 11.7637C68.2281 11.7637 69.6378 10.429 69.6378 8.60905C69.6378 6.78905 68.2281 5.45438 66.2899 5.45438C64.3265 5.45438 62.942 6.78905 62.942 8.60905C62.942 10.429 64.3265 11.7637 66.2899 11.7637ZM64.7796 8.60905C64.7796 7.63838 65.3837 6.97105 66.2899 6.97105C67.1835 6.97105 67.7876 7.63838 67.7876 8.60905C67.7876 9.57972 67.1835 10.2471 66.2899 10.2471C65.3837 10.2471 64.7796 9.57972 64.7796 8.60905ZM73.2088 11.4725C73.901 11.4725 74.5177 11.242 74.845 10.8416V11.424C74.845 12.1034 74.2786 12.5767 73.4102 12.5767C72.7935 12.5767 72.2523 12.2854 72.1642 11.788L70.4776 12.0428C70.7042 13.1955 71.925 13.972 73.4102 13.972C75.361 13.972 76.6574 12.8679 76.6574 11.2298V5.55145H74.8324V6.07318C74.4926 5.69705 73.9136 5.45438 73.171 5.45438C71.409 5.45438 70.3014 6.61918 70.3014 8.46345C70.3014 10.3077 71.409 11.4725 73.2088 11.4725ZM72.1012 8.46345C72.1012 7.55345 72.655 6.97105 73.5109 6.97105C74.3793 6.97105 74.9331 7.55345 74.9331 8.46345C74.9331 9.37345 74.3793 9.95585 73.5109 9.95585C72.655 9.95585 72.1012 9.37345 72.1012 8.46345Z\"\n fill=\"currentColor\"\n />\n </g>\n </g>\n <defs>\n <clipPath id=\"clip0_2415_6911\">\n <rect width=\"76\" height=\"14\" fill=\"white\" transform=\"translate(0.5)\" />\n </clipPath>\n </defs>\n </svg>\n)\nexport const checkSVG = (\n <svg width=\"16\" height=\"12\" viewBox=\"0 0 16 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M5.30769 10.6923L4.77736 11.2226C4.91801 11.3633 5.10878 11.4423 5.30769 11.4423C5.5066 11.4423 5.69737 11.3633 5.83802 11.2226L5.30769 10.6923ZM15.5303 1.53033C15.8232 1.23744 15.8232 0.762563 15.5303 0.46967C15.2374 0.176777 14.7626 0.176777 14.4697 0.46967L15.5303 1.53033ZM1.53033 5.85429C1.23744 5.56139 0.762563 5.56139 0.46967 5.85429C0.176777 6.14718 0.176777 6.62205 0.46967 6.91495L1.53033 5.85429ZM5.83802 11.2226L15.5303 1.53033L14.4697 0.46967L4.77736 10.162L5.83802 11.2226ZM0.46967 6.91495L4.77736 11.2226L5.83802 10.162L1.53033 5.85429L0.46967 6.91495Z\"\n fill=\"currentColor\"\n />\n </svg>\n)\n","import { h } from 'preact'\nimport { ProductTourStep, ProductTourAppearance } from '../../../posthog-product-tours-types'\nimport { getStepHtml } from '../product-tours-utils'\nimport { IconPosthogLogo, cancelSVG } from '../../surveys/icons'\n\nexport interface ProductTourTooltipInnerProps {\n step: ProductTourStep\n appearance?: ProductTourAppearance\n stepIndex: number\n totalSteps: number\n onNext?: () => void\n onPrevious?: () => void\n onDismiss?: () => void\n}\n\nexport function ProductTourTooltipInner({\n step,\n appearance,\n stepIndex,\n totalSteps,\n onNext,\n onPrevious,\n onDismiss,\n}: ProductTourTooltipInnerProps): h.JSX.Element {\n const whiteLabel = appearance?.whiteLabel ?? false\n const isLastStep = stepIndex >= totalSteps - 1\n const isFirstStep = stepIndex === 0\n const showNextButton = step.progressionTrigger === 'button' || step.type === 'modal'\n\n const isInteractive = !!(onNext || onPrevious || onDismiss)\n const cursorStyle = isInteractive ? undefined : { cursor: 'default' }\n\n return (\n <>\n <button class=\"ph-tour-dismiss\" onClick={onDismiss} aria-label=\"Close tour\" style={cursorStyle}>\n {cancelSVG}\n </button>\n\n <div class=\"ph-tour-content\" dangerouslySetInnerHTML={{ __html: getStepHtml(step) }} />\n\n <div class=\"ph-tour-footer\">\n <span class=\"ph-tour-progress\">\n {stepIndex + 1} of {totalSteps}\n </span>\n\n <div class=\"ph-tour-buttons\">\n {!isFirstStep && (\n <button\n class=\"ph-tour-button ph-tour-button--secondary\"\n onClick={onPrevious}\n style={cursorStyle}\n >\n Back\n </button>\n )}\n {showNextButton && (\n <button class=\"ph-tour-button ph-tour-button--primary\" onClick={onNext} style={cursorStyle}>\n {isLastStep ? 'Done' : 'Next'}\n </button>\n )}\n </div>\n </div>\n\n {!whiteLabel && (\n <a\n href={isInteractive ? 'https://posthog.com/product-tours' : undefined}\n target={isInteractive ? '_blank' : undefined}\n rel={isInteractive ? 'noopener noreferrer' : undefined}\n class=\"ph-tour-branding\"\n style={isInteractive ? undefined : { cursor: 'default', pointerEvents: 'none' }}\n >\n Tour by {IconPosthogLogo}\n </a>\n )}\n </>\n )\n}\n","import { h } from 'preact'\nimport { useState, useRef, useEffect } from 'preact/hooks'\nimport { ProductTourStep, ProductTourAppearance, ProductTourSurveyQuestion } from '../../../posthog-product-tours-types'\nimport { cancelSVG, IconPosthogLogo } from '../../surveys/icons'\nimport {\n dissatisfiedEmoji,\n neutralEmoji,\n satisfiedEmoji,\n veryDissatisfiedEmoji,\n verySatisfiedEmoji,\n} from '../../surveys/icons'\n\nexport interface ProductTourSurveyStepInnerProps {\n step: ProductTourStep\n appearance?: ProductTourAppearance\n stepIndex: number\n totalSteps: number\n onPrevious?: () => void\n onSubmit?: (response: string | number | null) => void\n onDismiss?: () => void\n}\n\nconst threeScaleEmojis = [dissatisfiedEmoji, neutralEmoji, satisfiedEmoji]\nconst fiveScaleEmojis = [veryDissatisfiedEmoji, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, verySatisfiedEmoji]\n\nfunction getScaleNumbers(scale: number): number[] {\n switch (scale) {\n case 5:\n return [1, 2, 3, 4, 5]\n case 10:\n return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n default:\n return [1, 2, 3, 4, 5]\n }\n}\n\nfunction OpenTextInput({\n value,\n onChange,\n onSubmit,\n isInteractive,\n}: {\n value: string\n onChange: (text: string) => void\n onSubmit?: () => void\n isInteractive: boolean\n}): h.JSX.Element {\n const inputRef = useRef<HTMLTextAreaElement>(null)\n\n useEffect(() => {\n if (isInteractive) {\n setTimeout(() => inputRef.current?.focus(), 100)\n }\n }, [isInteractive])\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Enter' && e.metaKey && isInteractive) {\n e.preventDefault()\n onSubmit?.()\n }\n }\n\n return (\n <textarea\n ref={inputRef}\n class=\"ph-tour-survey-textarea\"\n rows={3}\n placeholder=\"Your feedback (optional)...\"\n value={value}\n onInput={(e) => onChange((e.target as HTMLTextAreaElement).value)}\n onKeyDown={handleKeyDown}\n disabled={!isInteractive}\n style={isInteractive ? undefined : { cursor: 'default' }}\n />\n )\n}\n\nfunction RatingInput({\n survey,\n onSubmit,\n isInteractive,\n}: {\n survey: ProductTourSurveyQuestion\n onSubmit?: (rating: number) => void\n isInteractive: boolean\n}): h.JSX.Element {\n const [selectedRating, setSelectedRating] = useState<number | null>(null)\n const display = survey.display || 'emoji'\n const scale = survey.scale || 5\n\n const handleSelect = (rating: number) => {\n if (!isInteractive) {\n return\n }\n setSelectedRating(rating)\n // Auto-submit on selection for ratings\n onSubmit?.(rating)\n }\n\n if (display === 'emoji') {\n const emojis = scale === 3 ? threeScaleEmojis : fiveScaleEmojis\n return (\n <div class=\"ph-tour-survey-rating-container\">\n <div class=\"ph-tour-survey-rating-emoji\">\n {emojis.map((emoji, idx) => {\n const rating = idx + 1\n const isActive = selectedRating === rating\n return (\n <button\n key={idx}\n type=\"button\"\n class={`ph-tour-survey-emoji-button ${isActive ? 'ph-tour-survey-emoji-button--active' : ''}`}\n onClick={() => handleSelect(rating)}\n style={isInteractive ? undefined : { cursor: 'default' }}\n aria-label={`Rate ${rating}`}\n >\n {emoji}\n </button>\n )\n })}\n </div>\n {(survey.lowerBoundLabel || survey.upperBoundLabel) && (\n <div class=\"ph-tour-survey-rating-labels\">\n <span>{survey.lowerBoundLabel}</span>\n <span>{survey.upperBoundLabel}</span>\n </div>\n )}\n </div>\n )\n }\n\n // Number display\n const numbers = getScaleNumbers(scale)\n return (\n <div class=\"ph-tour-survey-rating-container\">\n <div\n class=\"ph-tour-survey-rating-numbers\"\n style={{ gridTemplateColumns: `repeat(${numbers.length}, minmax(0, 1fr))` }}\n >\n {numbers.map((num) => {\n const isActive = selectedRating === num\n return (\n <button\n key={num}\n type=\"button\"\n class={`ph-tour-survey-number-button ${isActive ? 'ph-tour-survey-number-button--active' : ''}`}\n onClick={() => handleSelect(num)}\n style={isInteractive ? undefined : { cursor: 'default' }}\n aria-label={`Rate ${num}`}\n >\n {num}\n </button>\n )\n })}\n </div>\n {(survey.lowerBoundLabel || survey.upperBoundLabel) && (\n <div class=\"ph-tour-survey-rating-labels\">\n <span>{survey.lowerBoundLabel}</span>\n <span>{survey.upperBoundLabel}</span>\n </div>\n )}\n </div>\n )\n}\n\nexport function ProductTourSurveyStepInner({\n step,\n appearance,\n stepIndex,\n totalSteps,\n onPrevious,\n onSubmit,\n onDismiss,\n}: ProductTourSurveyStepInnerProps): h.JSX.Element {\n const [textValue, setTextValue] = useState('')\n const survey = step.survey\n const whiteLabel = appearance?.whiteLabel ?? false\n const isFirstStep = stepIndex === 0\n const isOpenText = survey?.type === 'open'\n\n const isInteractive = !!(onPrevious || onSubmit || onDismiss)\n const cursorStyle = isInteractive ? undefined : { cursor: 'default' }\n\n const handleTextSubmit = () => {\n onSubmit?.(textValue.trim() || null)\n }\n\n if (!survey) {\n return <div />\n }\n\n return (\n <>\n <button class=\"ph-tour-dismiss\" onClick={onDismiss} aria-label=\"Close survey\" style={cursorStyle}>\n {cancelSVG}\n </button>\n\n <div class=\"ph-tour-survey-question\">{survey.questionText}</div>\n\n {isOpenText ? (\n <OpenTextInput\n value={textValue}\n onChange={setTextValue}\n onSubmit={handleTextSubmit}\n isInteractive={isInteractive}\n />\n ) : (\n <RatingInput survey={survey} onSubmit={onSubmit} isInteractive={isInteractive} />\n )}\n\n <div class=\"ph-tour-footer\">\n <span class=\"ph-tour-progress\">\n {stepIndex + 1} of {totalSteps}\n </span>\n\n <div class=\"ph-tour-buttons\">\n {!isFirstStep && (\n <button\n class=\"ph-tour-button ph-tour-button--secondary\"\n onClick={onPrevious}\n style={cursorStyle}\n >\n Back\n </button>\n )}\n {isOpenText && (\n <button\n class=\"ph-tour-button ph-tour-button--primary\"\n onClick={handleTextSubmit}\n style={cursorStyle}\n >\n Submit\n </button>\n )}\n </div>\n </div>\n\n {!whiteLabel && (\n <a\n href={isInteractive ? 'https://posthog.com/product-tours' : undefined}\n target={isInteractive ? '_blank' : undefined}\n rel={isInteractive ? 'noopener noreferrer' : undefined}\n class=\"ph-tour-branding\"\n style={isInteractive ? undefined : { cursor: 'default', pointerEvents: 'none' }}\n >\n Survey by {IconPosthogLogo}\n </a>\n )}\n </>\n )\n}\n","import { h } from 'preact'\nimport { useEffect, useState, useCallback, useRef } from 'preact/hooks'\nimport { ProductTour, ProductTourStep, ProductTourDismissReason } from '../../../posthog-product-tours-types'\nimport { calculateTooltipPosition, getSpotlightStyle, TooltipPosition } from '../product-tours-utils'\nimport { addEventListener } from '../../../utils'\nimport { window as _window } from '../../../utils/globals'\nimport { ProductTourTooltipInner } from './ProductTourTooltipInner'\nimport { ProductTourSurveyStepInner } from './ProductTourSurveyStepInner'\nimport { isNull } from '@posthog/core'\n\nconst window = _window as Window & typeof globalThis\n\ntype TransitionState = 'entering' | 'visible' | 'exiting'\n\nexport interface ProductTourTooltipProps {\n tour: ProductTour\n step: ProductTourStep\n stepIndex: number\n totalSteps: number\n targetElement: HTMLElement | null\n onNext: () => void\n onPrevious: () => void\n onDismiss: (reason: ProductTourDismissReason) => void\n onSurveySubmit?: (response: string | number | null) => void\n}\n\nfunction getOppositePosition(position: TooltipPosition): TooltipPosition {\n const opposites: Record<TooltipPosition, TooltipPosition> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n }\n return opposites[position]\n}\n\nfunction scrollToElement(element: HTMLElement, resolve: () => void): void {\n const initialRect = element.getBoundingClientRect()\n const viewportHeight = window.innerHeight\n const viewportWidth = window.innerWidth\n\n const safeMarginY = viewportHeight / 6\n const safeMarginX = viewportWidth / 6\n\n const isInSafeZone =\n initialRect.top >= safeMarginY &&\n initialRect.bottom <= viewportHeight - safeMarginY &&\n initialRect.left >= safeMarginX &&\n initialRect.right <= viewportWidth - safeMarginX\n\n if (isInSafeZone) {\n resolve()\n return\n }\n\n element.scrollIntoView({ behavior: 'smooth', block: 'center' })\n\n let lastTop = initialRect.top\n let stableCount = 0\n let resolved = false\n\n const checkStability = () => {\n if (resolved) return\n\n const currentRect = element.getBoundingClientRect()\n if (Math.abs(currentRect.top - lastTop) < 1) {\n stableCount++\n if (stableCount >= 3) {\n resolved = true\n resolve()\n return\n }\n } else {\n stableCount = 0\n }\n lastTop = currentRect.top\n setTimeout(checkStability, 50)\n }\n\n setTimeout(checkStability, 30)\n\n setTimeout(() => {\n if (!resolved) {\n resolved = true\n resolve()\n }\n }, 500)\n}\n\nconst TRANSITION_DURATION = 150\n\nexport function ProductTourTooltip({\n tour,\n step,\n stepIndex,\n totalSteps,\n targetElement,\n onNext,\n onPrevious,\n onDismiss,\n onSurveySubmit,\n}: ProductTourTooltipProps): h.JSX.Element {\n const [transitionState, setTransitionState] = useState<TransitionState>('entering')\n const [position, setPosition] = useState<ReturnType<typeof calculateTooltipPosition> | null>(null)\n const [spotlightStyle, setSpotlightStyle] = useState<ReturnType<typeof getSpotlightStyle> | null>(null)\n\n const [displayedStep, setDisplayedStep] = useState(step)\n const [displayedStepIndex, setDisplayedStepIndex] = useState(stepIndex)\n\n const previousStepRef = useRef(stepIndex)\n const isTransitioningRef = useRef(false)\n\n // Modal and survey steps are both centered on screen\n const isCentered = displayedStep.type === 'modal' || displayedStep.type === 'survey'\n\n const updatePosition = useCallback(() => {\n if (!targetElement) return\n const rect = targetElement.getBoundingClientRect()\n setPosition(calculateTooltipPosition(rect))\n setSpotlightStyle(getSpotlightStyle(rect))\n }, [targetElement])\n\n useEffect(() => {\n const currentStepIndex = stepIndex\n const isStepChange = previousStepRef.current !== stepIndex\n\n const finishEntering = () => {\n if (previousStepRef.current !== currentStepIndex) return\n setTransitionState('visible')\n isTransitioningRef.current = false\n }\n\n const enterStep = () => {\n // Only scroll/position for element steps\n if (targetElement && step.type === 'element') {\n scrollToElement(targetElement, () => {\n if (previousStepRef.current !== currentStepIndex) return\n updatePosition()\n setTimeout(finishEntering, 50)\n })\n } else {\n setTimeout(finishEntering, 50)\n }\n }\n\n if (!isStepChange) {\n previousStepRef.current = stepIndex\n isTransitioningRef.current = true\n enterStep()\n return\n }\n\n previousStepRef.current = stepIndex\n isTransitioningRef.current = true\n setTransitionState('exiting')\n\n setTimeout(() => {\n if (previousStepRef.current !== currentStepIndex) return\n\n // Reset position for element steps to prevent flash at old position\n if (step.type === 'element') {\n setPosition(null)\n setSpotlightStyle(null)\n }\n\n setDisplayedStep(step)\n setDisplayedStepIndex(stepIndex)\n setTransitionState('entering')\n\n enterStep()\n }, TRANSITION_DURATION)\n }, [targetElement, stepIndex, step, updatePosition])\n\n useEffect(() => {\n if (transitionState !== 'visible' || isCentered) return\n\n const handleUpdate = () => {\n if (!isTransitioningRef.current) {\n updatePosition()\n }\n }\n\n addEventListener(window, 'scroll', handleUpdate as EventListener, { capture: true })\n addEventListener(window, 'resize', handleUpdate as EventListener)\n\n return () => {\n window?.removeEventListener('scroll', handleUpdate, true)\n window?.removeEventListener('resize', handleUpdate)\n }\n }, [updatePosition, transitionState, isCentered])\n\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n onDismiss('escape_key')\n }\n }\n addEventListener(window, 'keydown', handleKeyDown as EventListener)\n return () => {\n window?.removeEventListener('keydown', handleKeyDown)\n }\n }, [onDismiss])\n\n const handleOverlayClick = (e: MouseEvent) => {\n e.stopPropagation()\n onDismiss('user_clicked_outside')\n }\n\n const handleTooltipClick = (e: MouseEvent) => {\n e.stopPropagation()\n }\n\n const handleSpotlightClick = (e: MouseEvent) => {\n e.stopPropagation()\n if (targetElement) {\n targetElement.click()\n }\n onNext()\n }\n\n const isVisible = transitionState === 'visible'\n const isSurvey = displayedStep.type === 'survey'\n\n // For element steps, don't render until position is calculated\n const isPositionReady = isCentered || !isNull(position)\n\n const tooltipStyle = {\n ...(displayedStep.maxWidth && {\n width: `${displayedStep.maxWidth}px`,\n maxWidth: `${displayedStep.maxWidth}px`,\n }),\n ...(isCentered\n ? {\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n }\n : {\n top: position ? `${position.top}px` : '0',\n left: position ? `${position.left}px` : '0',\n }),\n }\n\n return (\n <div class=\"ph-tour-container\">\n <div class=\"ph-tour-click-overlay\" onClick={handleOverlayClick} />\n\n {/* Modal overlay - visible for centered steps */}\n <div\n class=\"ph-tour-modal-overlay\"\n style={{\n opacity: isCentered && isVisible ? 1 : 0,\n transition: `opacity ${TRANSITION_DURATION}ms ease-out`,\n pointerEvents: isCentered ? 'auto' : 'none',\n }}\n />\n\n {/* Spotlight - visible for element steps */}\n <div\n class=\"ph-tour-spotlight\"\n style={{\n ...(isVisible && isPositionReady && spotlightStyle\n ? spotlightStyle\n : { top: '50%', left: '50%', width: '0px', height: '0px' }),\n opacity: !isCentered && isVisible && isPositionReady ? 1 : 0,\n transition: `opacity ${TRANSITION_DURATION}ms ease-out`,\n ...(displayedStep.progressionTrigger === 'click' &&\n !isCentered && {\n pointerEvents: 'auto',\n cursor: 'pointer',\n }),\n }}\n onClick={displayedStep.progressionTrigger === 'click' && !isCentered ? handleSpotlightClick : undefined}\n />\n\n <div\n class={`ph-tour-tooltip ${isCentered ? 'ph-tour-tooltip--modal' : ''} ${isSurvey ? 'ph-tour-survey-step' : ''}`}\n style={{\n ...tooltipStyle,\n opacity: isVisible && isPositionReady ? 1 : 0,\n transition: `opacity ${TRANSITION_DURATION}ms ease-out`,\n }}\n onClick={handleTooltipClick}\n >\n {!isCentered && position && (\n <div class={`ph-tour-arrow ph-tour-arrow--${getOppositePosition(position.position)}`} />\n )}\n\n {isSurvey ? (\n <ProductTourSurveyStepInner\n step={displayedStep}\n appearance={tour.appearance}\n stepIndex={displayedStepIndex}\n totalSteps={totalSteps}\n onSubmit={onSurveySubmit}\n onPrevious={onPrevious}\n onDismiss={() => onDismiss('user_clicked_skip')}\n />\n ) : (\n <ProductTourTooltipInner\n step={displayedStep}\n appearance={tour.appearance}\n stepIndex={displayedStepIndex}\n totalSteps={totalSteps}\n onNext={onNext}\n onPrevious={onPrevious}\n onDismiss={() => onDismiss('user_clicked_skip')}\n />\n )}\n </div>\n </div>\n )\n}\n","/**\n * uuidv7: An experimental implementation of the proposed UUID Version 7\n *\n * @license Apache-2.0\n * @copyright 2021-2023 LiosK\n * @packageDocumentation\n *\n * from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts\n */\n\n// polyfill for IE11\nimport { window } from './utils/globals'\n\nimport { isNumber, isUndefined } from '@posthog/core'\n\nif (!Math.trunc) {\n Math.trunc = function (v) {\n return v < 0 ? Math.ceil(v) : Math.floor(v)\n }\n}\n\n// polyfill for IE11\nif (!Number.isInteger) {\n Number.isInteger = function (value) {\n return isNumber(value) && isFinite(value) && Math.floor(value) === value\n }\n}\n\nconst DIGITS = '0123456789abcdef'\n\n/** Represents a UUID as a 16-byte byte array. */\nexport class UUID {\n /** @param bytes - The 16-byte byte array representation. */\n constructor(readonly bytes: Readonly<Uint8Array>) {\n if (bytes.length !== 16) {\n throw new TypeError('not 128-bit length')\n }\n }\n\n /**\n * Builds a byte array from UUIDv7 field values.\n *\n * @param unixTsMs - A 48-bit `unix_ts_ms` field value.\n * @param randA - A 12-bit `rand_a` field value.\n * @param randBHi - The higher 30 bits of 62-bit `rand_b` field value.\n * @param randBLo - The lower 32 bits of 62-bit `rand_b` field value.\n */\n static fromFieldsV7(unixTsMs: number, randA: number, randBHi: number, randBLo: number): UUID {\n if (\n !Number.isInteger(unixTsMs) ||\n !Number.isInteger(randA) ||\n !Number.isInteger(randBHi) ||\n !Number.isInteger(randBLo) ||\n unixTsMs < 0 ||\n randA < 0 ||\n randBHi < 0 ||\n randBLo < 0 ||\n unixTsMs > 0xffff_ffff_ffff ||\n randA > 0xfff ||\n randBHi > 0x3fff_ffff ||\n randBLo > 0xffff_ffff\n ) {\n throw new RangeError('invalid field value')\n }\n\n const bytes = new Uint8Array(16)\n bytes[0] = unixTsMs / 2 ** 40\n bytes[1] = unixTsMs / 2 ** 32\n bytes[2] = unixTsMs / 2 ** 24\n bytes[3] = unixTsMs / 2 ** 16\n bytes[4] = unixTsMs / 2 ** 8\n bytes[5] = unixTsMs\n bytes[6] = 0x70 | (randA >>> 8)\n bytes[7] = randA\n bytes[8] = 0x80 | (randBHi >>> 24)\n bytes[9] = randBHi >>> 16\n bytes[10] = randBHi >>> 8\n bytes[11] = randBHi\n bytes[12] = randBLo >>> 24\n bytes[13] = randBLo >>> 16\n bytes[14] = randBLo >>> 8\n bytes[15] = randBLo\n return new UUID(bytes)\n }\n\n /** @returns The 8-4-4-4-12 canonical hexadecimal string representation. */\n toString(): string {\n let text = ''\n for (let i = 0; i < this.bytes.length; i++) {\n text = text + DIGITS.charAt(this.bytes[i] >>> 4) + DIGITS.charAt(this.bytes[i] & 0xf)\n if (i === 3 || i === 5 || i === 7 || i === 9) {\n text += '-'\n }\n }\n\n if (text.length !== 36) {\n // We saw one customer whose bundling code was mangling the UUID generation\n // rather than accept a bad UUID, we throw an error here.\n throw new Error('Invalid UUIDv7 was generated')\n }\n return text\n }\n\n /** Creates an object from `this`. */\n clone(): UUID {\n return new UUID(this.bytes.slice(0))\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n equals(other: UUID): boolean {\n return this.compareTo(other) === 0\n }\n\n /**\n * Returns a negative integer, zero, or positive integer if `this` is less\n * than, equal to, or greater than `other`, respectively.\n */\n compareTo(other: UUID): number {\n for (let i = 0; i < 16; i++) {\n const diff = this.bytes[i] - other.bytes[i]\n if (diff !== 0) {\n return Math.sign(diff)\n }\n }\n return 0\n }\n}\n\n/** Encapsulates the monotonic counter state. */\nclass V7Generator {\n private _timestamp = 0\n private _counter = 0\n private readonly _random = new DefaultRandom()\n\n /**\n * Generates a new UUIDv7 object from the current timestamp, or resets the\n * generator upon significant timestamp rollback.\n *\n * This method returns monotonically increasing UUIDs unless the up-to-date\n * timestamp is significantly (by ten seconds or more) smaller than the one\n * embedded in the immediately preceding UUID. If such a significant clock\n * rollback is detected, this method resets the generator and returns a new\n * UUID based on the current timestamp.\n */\n generate(): UUID {\n const value = this.generateOrAbort()\n if (!isUndefined(value)) {\n return value\n } else {\n // reset state and resume\n this._timestamp = 0\n const valueAfterReset = this.generateOrAbort()\n if (isUndefined(valueAfterReset)) {\n throw new Error('Could not generate UUID after timestamp reset')\n }\n return valueAfterReset\n }\n }\n\n /**\n * Generates a new UUIDv7 object from the current timestamp, or returns\n * `undefined` upon significant timestamp rollback.\n *\n * This method returns monotonically increasing UUIDs unless the up-to-date\n * timestamp is significantly (by ten seconds or more) smaller than the one\n * embedded in the immediately preceding UUID. If such a significant clock\n * rollback is detected, this method aborts and returns `undefined`.\n */\n generateOrAbort(): UUID | undefined {\n const MAX_COUNTER = 0x3ff_ffff_ffff\n const ROLLBACK_ALLOWANCE = 10_000 // 10 seconds\n\n const ts = Date.now()\n if (ts > this._timestamp) {\n this._timestamp = ts\n this._resetCounter()\n } else if (ts + ROLLBACK_ALLOWANCE > this._timestamp) {\n // go on with previous timestamp if new one is not much smaller\n this._counter++\n if (this._counter > MAX_COUNTER) {\n // increment timestamp at counter overflow\n this._timestamp++\n this._resetCounter()\n }\n } else {\n // abort if clock went backwards to unbearable extent\n return undefined\n }\n\n return UUID.fromFieldsV7(\n this._timestamp,\n Math.trunc(this._counter / 2 ** 30),\n this._counter & (2 ** 30 - 1),\n this._random.nextUint32()\n )\n }\n\n /** Initializes the counter at a 42-bit random integer. */\n private _resetCounter(): void {\n this._counter = this._random.nextUint32() * 0x400 + (this._random.nextUint32() & 0x3ff)\n }\n}\n\n/** A global flag to force use of cryptographically strong RNG. */\ndeclare const UUIDV7_DENY_WEAK_RNG: boolean\n\n/** Stores `crypto.getRandomValues()` available in the environment. */\nlet getRandomValues: <T extends Uint8Array | Uint32Array>(buffer: T) => T = (buffer) => {\n // fall back on Math.random() unless the flag is set to true\n // TRICKY: don't use the isUndefined method here as can't pass the reference\n if (typeof UUIDV7_DENY_WEAK_RNG !== 'undefined' && UUIDV7_DENY_WEAK_RNG) {\n throw new Error('no cryptographically strong RNG available')\n }\n\n for (let i = 0; i < buffer.length; i++) {\n buffer[i] = Math.trunc(Math.random() * 0x1_0000) * 0x1_0000 + Math.trunc(Math.random() * 0x1_0000)\n }\n return buffer\n}\n\n// detect Web Crypto API\nif (window && !isUndefined(window.crypto) && crypto.getRandomValues) {\n getRandomValues = (buffer) => crypto.getRandomValues(buffer)\n}\n\n/**\n * Wraps `crypto.getRandomValues()` and compatibles to enable buffering; this\n * uses a small buffer by default to avoid unbearable throughput decline in some\n * environments as well as the waste of time and space for unused values.\n */\nclass DefaultRandom {\n private readonly _buffer = new Uint32Array(8)\n private _cursor = Infinity\n nextUint32(): number {\n if (this._cursor >= this._buffer.length) {\n getRandomValues(this._buffer)\n this._cursor = 0\n }\n return this._buffer[this._cursor++]\n }\n}\n\nlet defaultGenerator: V7Generator | undefined\n\n/**\n * Generates a UUIDv7 string.\n *\n * @returns The 8-4-4-4-12 canonical hexadecimal string representation\n * (\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\").\n */\nexport const uuidv7 = (): string => uuidv7obj().toString()\n\n/** Generates a UUIDv7 object. */\nconst uuidv7obj = (): UUID => (defaultGenerator || (defaultGenerator = new V7Generator())).generate()\n\nexport const uuid7ToTimestampMs = (uuid: string): number => {\n // remove hyphens\n const hex = uuid.replace(/-/g, '')\n // ensure that it's a version 7 UUID\n if (hex.length !== 32) {\n throw new Error('Not a valid UUID')\n }\n if (hex[12] !== '7') {\n throw new Error('Not a UUIDv7')\n }\n // the first 6 bytes are the timestamp, which means that we can read only the first 12 hex characters\n return parseInt(hex.substring(0, 12), 16)\n}\n","import { extend } from './utils'\nimport { PersistentStore, Properties } from './types'\nimport {\n DEVICE_ID,\n DISTINCT_ID,\n ENABLE_PERSON_PROCESSING,\n INITIAL_PERSON_INFO,\n SESSION_ID,\n SESSION_RECORDING_IS_SAMPLED,\n} from './constants'\n\nimport { isNull, isUndefined } from '@posthog/core'\nimport { logger } from './utils/logger'\nimport { window, document } from './utils/globals'\nimport { uuidv7 } from './uuidv7'\n\n// we store the discovered subdomain in memory because it might be read multiple times\nlet firstNonPublicSubDomain = ''\n\n// helper to allow tests to clear this \"cache\"\nexport const resetSubDomainCache = () => {\n firstNonPublicSubDomain = ''\n}\n\n/**\n * Browsers don't offer a way to check if something is a public suffix\n * e.g. `.com.au`, `.io`, `.org.uk`\n *\n * But they do reject cookies set on public suffixes\n * Setting a cookie on `.co.uk` would mean it was sent for every `.co.uk` site visited\n *\n * So, we can use this to check if a domain is a public suffix\n * by trying to set a cookie on a subdomain of the provided hostname\n * until the browser accepts it\n *\n * inspired by https://github.com/AngusFu/browser-root-domain\n */\nexport function seekFirstNonPublicSubDomain(hostname: string, cookieJar = document): string {\n if (firstNonPublicSubDomain) {\n return firstNonPublicSubDomain\n }\n\n if (!cookieJar) {\n return ''\n }\n if (['localhost', '127.0.0.1'].includes(hostname)) return ''\n\n const list = hostname.split('.')\n let len = Math.min(list.length, 8) // paranoia - we know this number should be small\n const key = 'dmn_chk_' + uuidv7()\n\n while (!firstNonPublicSubDomain && len--) {\n const candidate = list.slice(len).join('.')\n const candidateCookieValue = key + '=1;domain=.' + candidate + ';path=/'\n\n // try to set cookie, include a short expiry in seconds since we'll check immediately\n cookieJar.cookie = candidateCookieValue + ';max-age=3'\n\n if (cookieJar.cookie.includes(key)) {\n // the cookie was accepted by the browser, remove the test cookie\n cookieJar.cookie = candidateCookieValue + ';max-age=0'\n firstNonPublicSubDomain = candidate\n }\n }\n\n return firstNonPublicSubDomain\n}\n\nconst DOMAIN_MATCH_REGEX = /[a-z0-9][a-z0-9-]+\\.[a-z]{2,}$/i\nconst originalCookieDomainFn = (hostname: string): string => {\n const matches = hostname.match(DOMAIN_MATCH_REGEX)\n return matches ? matches[0] : ''\n}\n\nexport function chooseCookieDomain(hostname: string, cross_subdomain: boolean | undefined): string {\n if (cross_subdomain) {\n // NOTE: Could we use this for cross domain tracking?\n let matchedSubDomain = seekFirstNonPublicSubDomain(hostname)\n\n if (!matchedSubDomain) {\n const originalMatch = originalCookieDomainFn(hostname)\n if (originalMatch !== matchedSubDomain) {\n logger.info('Warning: cookie subdomain discovery mismatch', originalMatch, matchedSubDomain)\n }\n matchedSubDomain = originalMatch\n }\n\n return matchedSubDomain ? '; domain=.' + matchedSubDomain : ''\n }\n return ''\n}\n\n// Methods partially borrowed from quirksmode.org/js/cookies.html\nexport const cookieStore: PersistentStore = {\n _is_supported: () => !!document,\n\n _error: function (msg) {\n logger.error('cookieStore error: ' + msg)\n },\n\n _get: function (name) {\n if (!document) {\n return\n }\n\n try {\n const nameEQ = name + '='\n const ca = document.cookie.split(';').filter((x) => x.length)\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i]\n while (c.charAt(0) == ' ') {\n c = c.substring(1, c.length)\n }\n if (c.indexOf(nameEQ) === 0) {\n return decodeURIComponent(c.substring(nameEQ.length, c.length))\n }\n }\n } catch {}\n return null\n },\n\n _parse: function (name) {\n let cookie\n try {\n cookie = JSON.parse(cookieStore._get(name)) || {}\n } catch {\n // noop\n }\n return cookie\n },\n\n _set: function (name, value, days, cross_subdomain, is_secure) {\n if (!document) {\n return\n }\n try {\n let expires = '',\n secure = ''\n\n const cdomain = chooseCookieDomain(document.location.hostname, cross_subdomain)\n\n if (days) {\n const date = new Date()\n date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000)\n expires = '; expires=' + date.toUTCString()\n }\n\n if (is_secure) {\n secure = '; secure'\n }\n\n const new_cookie_val =\n name +\n '=' +\n encodeURIComponent(JSON.stringify(value)) +\n expires +\n '; SameSite=Lax; path=/' +\n cdomain +\n secure\n\n // 4096 bytes is the size at which some browsers (e.g. firefox) will not store a cookie, warn slightly before that\n if (new_cookie_val.length > 4096 * 0.9) {\n logger.warn('cookieStore warning: large cookie, len=' + new_cookie_val.length)\n }\n\n document.cookie = new_cookie_val\n return new_cookie_val\n } catch {\n return\n }\n },\n\n _remove: function (name, cross_subdomain) {\n if (!document?.cookie) {\n return\n }\n try {\n cookieStore._set(name, '', -1, cross_subdomain)\n } catch {\n return\n }\n },\n}\n\nlet _localStorage_supported: boolean | null = null\nexport const resetLocalStorageSupported = () => {\n _localStorage_supported = null\n}\n\nexport const localStore: PersistentStore = {\n _is_supported: function () {\n if (!isNull(_localStorage_supported)) {\n return _localStorage_supported\n }\n\n let supported = true\n if (!isUndefined(window)) {\n try {\n const key = '__mplssupport__',\n val = 'xyz'\n localStore._set(key, val)\n if (localStore._get(key) !== '\"xyz\"') {\n supported = false\n }\n localStore._remove(key)\n } catch {\n supported = false\n }\n } else {\n supported = false\n }\n if (!supported) {\n logger.error('localStorage unsupported; falling back to cookie store')\n }\n\n _localStorage_supported = supported\n return supported\n },\n\n _error: function (msg) {\n logger.error('localStorage error: ' + msg)\n },\n\n _get: function (name) {\n try {\n return window?.localStorage.getItem(name)\n } catch (err) {\n localStore._error(err)\n }\n return null\n },\n\n _parse: function (name) {\n try {\n return JSON.parse(localStore._get(name)) || {}\n } catch {\n // noop\n }\n return null\n },\n\n _set: function (name, value) {\n try {\n window?.localStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n localStore._error(err)\n }\n },\n\n _remove: function (name) {\n try {\n window?.localStorage.removeItem(name)\n } catch (err) {\n localStore._error(err)\n }\n },\n}\n\n// Use localstorage for most data but still use cookie for COOKIE_PERSISTED_PROPERTIES\n// This solves issues with cookies having too much data in them causing headers too large\n// Also makes sure we don't have to send a ton of data to the server\nconst COOKIE_PERSISTED_PROPERTIES = [\n DEVICE_ID,\n DISTINCT_ID,\n SESSION_ID,\n SESSION_RECORDING_IS_SAMPLED,\n ENABLE_PERSON_PROCESSING,\n INITIAL_PERSON_INFO,\n]\n\n/**\n * Creates a localPlusCookieStore instance with custom cookie-persisted properties\n */\nexport const createLocalPlusCookieStore = (customCookieProperties: readonly string[] = []): PersistentStore => {\n const cookiePropertiesToPersist = [...COOKIE_PERSISTED_PROPERTIES, ...customCookieProperties]\n\n return {\n ...localStore,\n _parse: function (name) {\n try {\n let cookieProperties: Properties = {}\n try {\n // See if there's a cookie stored with data.\n cookieProperties = cookieStore._parse(name) || {}\n } catch {}\n const value = extend(cookieProperties, JSON.parse(localStore._get(name) || '{}'))\n localStore._set(name, value)\n return value\n } catch {\n // noop\n }\n return null\n },\n\n _set: function (name, value, days, cross_subdomain, is_secure, debug) {\n try {\n localStore._set(name, value, undefined, undefined, debug)\n const cookiePersistedProperties: Record<string, any> = {}\n cookiePropertiesToPersist.forEach((key) => {\n if (value[key]) {\n cookiePersistedProperties[key] = value[key]\n }\n })\n\n if (Object.keys(cookiePersistedProperties).length) {\n cookieStore._set(name, cookiePersistedProperties, days, cross_subdomain, is_secure, debug)\n }\n } catch (err) {\n localStore._error(err)\n }\n },\n\n _remove: function (name, cross_subdomain) {\n try {\n window?.localStorage.removeItem(name)\n cookieStore._remove(name, cross_subdomain)\n } catch (err) {\n localStore._error(err)\n }\n },\n }\n}\n\nconst memoryStorage: Properties = {}\n\n// Storage that only lasts the length of the pageview if we don't want to use cookies\nexport const memoryStore: PersistentStore = {\n _is_supported: function () {\n return true\n },\n\n _error: function (msg) {\n logger.error('memoryStorage error: ' + msg)\n },\n\n _get: function (name) {\n return memoryStorage[name] || null\n },\n\n _parse: function (name) {\n return memoryStorage[name] || null\n },\n\n _set: function (name, value) {\n memoryStorage[name] = value\n },\n\n _remove: function (name) {\n delete memoryStorage[name]\n },\n}\n\nlet sessionStorageSupported: boolean | null = null\nexport const resetSessionStorageSupported = () => {\n sessionStorageSupported = null\n}\n// Storage that only lasts the length of a tab/window. Survives page refreshes\nexport const sessionStore: PersistentStore = {\n _is_supported: function () {\n if (!isNull(sessionStorageSupported)) {\n return sessionStorageSupported\n }\n sessionStorageSupported = true\n if (!isUndefined(window)) {\n try {\n const key = '__support__',\n val = 'xyz'\n sessionStore._set(key, val)\n if (sessionStore._get(key) !== '\"xyz\"') {\n sessionStorageSupported = false\n }\n sessionStore._remove(key)\n } catch {\n sessionStorageSupported = false\n }\n } else {\n sessionStorageSupported = false\n }\n return sessionStorageSupported\n },\n\n _error: function (msg) {\n logger.error('sessionStorage error: ', msg)\n },\n\n _get: function (name) {\n try {\n return window?.sessionStorage.getItem(name)\n } catch (err) {\n sessionStore._error(err)\n }\n return null\n },\n\n _parse: function (name) {\n try {\n return JSON.parse(sessionStore._get(name)) || null\n } catch {\n // noop\n }\n return null\n },\n\n _set: function (name, value) {\n try {\n window?.sessionStorage.setItem(name, JSON.stringify(value))\n } catch (err) {\n sessionStore._error(err)\n }\n },\n\n _remove: function (name) {\n try {\n window?.sessionStorage.removeItem(name)\n } catch (err) {\n sessionStore._error(err)\n }\n },\n}\n","export const TOUR_COMPLETED_KEY_PREFIX = 'ph_product_tour_completed_'\nexport const TOUR_DISMISSED_KEY_PREFIX = 'ph_product_tour_dismissed_'\nexport const ACTIVE_TOUR_SESSION_KEY = 'ph_active_product_tour'\n","import { ProductTour } from '../posthog-product-tours-types'\n\nexport function doesTourActivateByEvent(tour: Pick<ProductTour, 'conditions'>): boolean {\n return !!(tour.conditions?.events && tour.conditions.events.values?.length > 0)\n}\n\nexport function doesTourActivateByAction(tour: Pick<ProductTour, 'conditions'>): boolean {\n return !!(tour.conditions?.actions && tour.conditions.actions.values?.length > 0)\n}\n","export class SimpleEventEmitter {\n private _events: { [key: string]: ((...args: any[]) => void)[] } = {}\n\n constructor() {\n this._events = {}\n }\n\n on(event: string, listener: (...args: any[]) => void): () => void {\n if (!this._events[event]) {\n this._events[event] = []\n }\n this._events[event].push(listener)\n\n return () => {\n this._events[event] = this._events[event].filter((x) => x !== listener)\n }\n }\n\n emit(event: string, payload: any): void {\n for (const listener of this._events[event] || []) {\n listener(payload)\n }\n for (const listener of this._events['*'] || []) {\n listener(event, payload)\n }\n }\n}\n","import { isNullish } from '@posthog/core'\n\nexport function extractHref(elementsChain: string): string {\n const match = elementsChain.match(/(?::|\")href=\"(.*?)\"/)\n return match ? match[1] : ''\n}\n\nexport function extractTexts(elementsChain: string): string[] {\n const texts: string[] = []\n const regex = /(?::|\")text=\"(.*?)\"/g\n let match\n while (!isNullish((match = regex.exec(elementsChain)))) {\n if (!texts.includes(match[1])) {\n texts.push(match[1])\n }\n }\n return texts\n}\n\nexport function matchString(\n value: string | undefined | null,\n pattern: string,\n matching: 'exact' | 'contains' | 'regex'\n): boolean {\n if (isNullish(value)) return false\n switch (matching) {\n case 'exact':\n return value === pattern\n case 'contains': {\n // Simulating SQL LIKE behavior (_ = any single character, % = any zero or more characters)\n const likePattern = pattern\n .replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n .replace(/_/g, '.')\n .replace(/%/g, '.*')\n return new RegExp(likePattern, 'i').test(value)\n }\n case 'regex':\n try {\n return new RegExp(pattern).test(value)\n } catch {\n return false\n }\n default:\n return false\n }\n}\n\nexport function matchTexts(texts: string[], pattern: string, matching: 'exact' | 'contains' | 'regex'): boolean {\n return texts.some((text) => matchString(text, pattern, matching))\n}\n","import { PostHog } from '../../posthog-core'\nimport { ActionStepType, PropertyFilters, SurveyActionType, SurveyElement } from '../../posthog-surveys-types'\nimport { SimpleEventEmitter } from '../../utils/simple-event-emitter'\nimport { CaptureResult, PropertyMatchType } from '../../types'\nimport { isArray, isUndefined } from '@posthog/core'\nimport { matchPropertyFilters } from '../../utils/property-utils'\nimport { extractTexts, extractHref, matchString, matchTexts } from '../../utils/elements-chain-utils'\n\nexport class ActionMatcher {\n private readonly _actionRegistry?: Set<SurveyActionType>\n private readonly _instance?: PostHog\n private readonly _actionEvents: Set<string>\n private _debugEventEmitter = new SimpleEventEmitter()\n\n constructor(instance?: PostHog) {\n this._instance = instance\n this._actionEvents = new Set<string>()\n this._actionRegistry = new Set<SurveyActionType>()\n }\n\n init() {\n if (!isUndefined(this._instance?._addCaptureHook)) {\n const matchEventToAction = (eventName: string, eventPayload: any) => {\n this.on(eventName, eventPayload)\n }\n this._instance?._addCaptureHook(matchEventToAction)\n }\n }\n\n register(actions: SurveyActionType[]): void {\n if (isUndefined(this._instance?._addCaptureHook)) {\n return\n }\n\n actions.forEach((action) => {\n this._actionRegistry?.add(action)\n action.steps?.forEach((step) => {\n this._actionEvents?.add(step?.event || '')\n })\n })\n\n if (this._instance?.autocapture) {\n const selectorsToWatch: Set<string> = new Set<string>()\n actions.forEach((action) => {\n action.steps?.forEach((step) => {\n if (step?.selector) {\n selectorsToWatch.add(step?.selector)\n }\n })\n })\n this._instance?.autocapture.setElementSelectors(selectorsToWatch)\n }\n }\n\n on(eventName: string, eventPayload?: CaptureResult) {\n if (eventPayload == null || eventName.length == 0) {\n return\n }\n\n if (!this._actionEvents.has(eventName) && !this._actionEvents.has(<string>eventPayload?.event)) {\n return\n }\n\n if (this._actionRegistry && this._actionRegistry?.size > 0) {\n this._actionRegistry.forEach((action) => {\n if (this._checkAction(eventPayload, action)) {\n this._debugEventEmitter.emit('actionCaptured', action.name)\n }\n })\n }\n }\n\n _addActionHook(callback: (actionName: string, eventPayload?: any) => void): void {\n this.onAction('actionCaptured', (data) => callback(data))\n }\n\n private _checkAction(event?: CaptureResult, action?: SurveyActionType): boolean {\n if (action?.steps == null) {\n return false\n }\n\n for (const step of action.steps) {\n if (this._checkStep(event, step)) {\n return true\n }\n }\n\n return false\n }\n\n onAction(event: 'actionCaptured', cb: (...args: any[]) => void): () => void {\n return this._debugEventEmitter.on(event, cb)\n }\n\n private _checkStep = (event?: CaptureResult, step?: ActionStepType): boolean => {\n return (\n this._checkStepEvent(event, step) &&\n this._checkStepUrl(event, step) &&\n this._checkStepElement(event, step) &&\n this._checkStepProperties(event, step)\n )\n }\n\n private _checkStepEvent = (event?: CaptureResult, step?: ActionStepType): boolean => {\n // CHECK CONDITIONS, OTHERWISE SKIPPED\n if (step?.event && event?.event !== step?.event) {\n return false // EVENT NAME IS A MISMATCH\n }\n return true\n }\n\n private _checkStepUrl(event?: CaptureResult, step?: ActionStepType): boolean {\n // CHECK CONDITIONS, OTHERWISE SKIPPED\n if (step?.url) {\n const eventUrl = event?.properties?.$current_url\n if (!eventUrl || typeof eventUrl !== 'string') {\n return false\n }\n if (!matchString(eventUrl, step.url, step.url_matching || 'contains')) {\n return false\n }\n }\n return true\n }\n\n private _checkStepElement(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!this._checkStepHref(event, step)) return false\n if (!this._checkStepText(event, step)) return false\n if (!this._checkStepSelector(event, step)) return false\n return true\n }\n\n private _checkStepHref(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!step?.href) return true\n\n const elements = this._getElementsList(event)\n if (elements.length > 0) {\n return elements.some((el) => matchString(el.href, step.href!, step.href_matching || 'exact'))\n }\n\n const chain = (event?.properties?.$elements_chain as string) || ''\n if (chain) {\n return matchString(extractHref(chain), step.href, step.href_matching || 'exact')\n }\n\n return false\n }\n\n private _checkStepText(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!step?.text) return true\n\n const elements = this._getElementsList(event)\n if (elements.length > 0) {\n return elements.some(\n (el) =>\n matchString(el.text, step.text!, step.text_matching || 'exact') ||\n matchString(el.$el_text, step.text!, step.text_matching || 'exact')\n )\n }\n\n const chain = (event?.properties?.$elements_chain as string) || ''\n if (chain) {\n return matchTexts(extractTexts(chain), step.text, step.text_matching || 'exact')\n }\n\n return false\n }\n\n private _checkStepSelector(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!step?.selector) return true\n\n // check exact match on $element_selectors from autocapture\n const elementSelectors = event?.properties?.$element_selectors as string[] | undefined\n if (elementSelectors?.includes(step.selector)) {\n return true\n }\n\n // check against compiled regex\n const chain = (event?.properties?.$elements_chain as string) || ''\n if (step.selector_regex && chain) {\n try {\n return new RegExp(step.selector_regex).test(chain)\n } catch {\n return false\n }\n }\n\n return false\n }\n\n private _getElementsList(event?: CaptureResult): SurveyElement[] {\n if (event?.properties?.$elements == null) {\n return []\n }\n\n return event?.properties.$elements as unknown as SurveyElement[]\n }\n\n private _checkStepProperties(event?: CaptureResult, step?: ActionStepType): boolean {\n if (!step?.properties || step.properties.length === 0) {\n return true\n }\n\n // transform to match same property format as normal events\n const propertyFilters: PropertyFilters = step.properties.reduce<PropertyFilters>((acc, filter) => {\n const values = isArray(filter.value)\n ? filter.value.map(String)\n : filter.value != null\n ? [String(filter.value)]\n : []\n\n acc[filter.key] = {\n values,\n operator: (filter.operator || 'exact') as PropertyMatchType,\n }\n return acc\n }, {})\n\n return matchPropertyFilters(propertyFilters, event?.properties)\n }\n}\n","import { SurveyActionType, SurveyEventType, SurveyEventWithFilters } from '../posthog-surveys-types'\nimport { ActionMatcher } from '../extensions/surveys/action-matcher'\nimport { PostHog } from '../posthog-core'\nimport { CaptureResult } from '../types'\nimport { matchPropertyFilters } from './property-utils'\nimport { isUndefined } from '@posthog/core'\nimport { createLogger } from './logger'\n\n/**\n * Interface for items that can be triggered by events/actions.\n * Both Survey and ProductTour implement this interface.\n */\nexport interface EventTriggerable {\n id: string\n conditions?: {\n events?: { repeatedActivation?: boolean; values: SurveyEventWithFilters[] } | null\n cancelEvents?: { values: SurveyEventWithFilters[] } | null\n actions?: { values: SurveyActionType[] } | null\n } | null\n}\n\n/**\n * Abstract base class for receiving events and matching them to triggerable items.\n * Subclasses implement type-specific behavior for surveys and product tours.\n */\nexport abstract class EventReceiver<T extends EventTriggerable> {\n // eventToItems is a mapping of event name to all the items that are activated by it\n protected _eventToItems: Map<string, string[]>\n // cancelEventToItems is a mapping of event name to all the items that should be cancelled by it\n protected _cancelEventToItems: Map<string, string[]>\n // actionToItems is a mapping of action name to all the items that are activated by it\n protected readonly _actionToItems: Map<string, string[]>\n // actionMatcher can look at CaptureResult payloads and match an event to its corresponding action.\n protected _actionMatcher?: ActionMatcher | null\n protected readonly _instance?: PostHog\n\n constructor(instance: PostHog) {\n this._instance = instance\n this._eventToItems = new Map<string, string[]>()\n this._cancelEventToItems = new Map<string, string[]>()\n this._actionToItems = new Map<string, string[]>()\n }\n\n // Abstract methods for subclasses to implement\n protected abstract _getActivatedKey(): string\n protected abstract _getShownEventName(): string\n protected abstract _getItems(callback: (items: T[]) => void): void\n protected abstract _cancelPendingItem(itemId: string): void\n protected abstract _getLogger(): ReturnType<typeof createLogger>\n /** Check if item is permanently ineligible (e.g. completed/dismissed). Skip adding to activated list. */\n protected abstract _isItemPermanentlyIneligible(itemId?: string): boolean\n\n private _doesEventMatchFilter(\n eventConfig: SurveyEventWithFilters | undefined,\n eventPayload?: CaptureResult\n ): boolean {\n if (!eventConfig) {\n return false\n }\n\n return matchPropertyFilters(eventConfig.propertyFilters, eventPayload?.properties)\n }\n\n private _buildEventToItemMap(items: T[], conditionField: SurveyEventType): Map<string, string[]> {\n const map = new Map<string, string[]>()\n items.forEach((item) => {\n item.conditions?.[conditionField]?.values?.forEach((event) => {\n if (event?.name) {\n const existing = map.get(event.name) || []\n existing.push(item.id)\n map.set(event.name, existing)\n }\n })\n })\n return map\n }\n\n /**\n * build a map of (Event1) => [Item1, Item2, Item3]\n * used for items that should be [activated|cancelled] by Event1\n */\n private _getMatchingItems(\n eventName: string,\n eventPayload: CaptureResult | undefined,\n conditionField: SurveyEventType\n ): T[] {\n const itemIdMap = conditionField === SurveyEventType.Activation ? this._eventToItems : this._cancelEventToItems\n const itemIds = itemIdMap.get(eventName)\n\n let items: T[] = []\n this._getItems((allItems) => {\n items = allItems.filter((item) => itemIds?.includes(item.id))\n })\n\n return items.filter((item) => {\n const eventConfig = item.conditions?.[conditionField]?.values?.find((e) => e.name === eventName)\n return this._doesEventMatchFilter(eventConfig, eventPayload)\n })\n }\n\n register(items: T[]): void {\n if (isUndefined(this._instance?._addCaptureHook)) {\n return\n }\n\n this._setupEventBasedItems(items)\n this._setupActionBasedItems(items)\n }\n\n private _setupActionBasedItems(items: T[]) {\n const actionBasedItems = items.filter(\n (item: T) => item.conditions?.actions && item.conditions?.actions?.values?.length > 0\n )\n\n if (actionBasedItems.length === 0) {\n return\n }\n\n if (this._actionMatcher == null) {\n this._actionMatcher = new ActionMatcher(this._instance)\n this._actionMatcher.init()\n // match any actions to its corresponding item.\n const matchActionToItem = (actionName: string) => {\n this.onAction(actionName)\n }\n\n this._actionMatcher._addActionHook(matchActionToItem)\n }\n\n actionBasedItems.forEach((item) => {\n if (\n item.conditions &&\n item.conditions?.actions &&\n item.conditions?.actions?.values &&\n item.conditions?.actions?.values?.length > 0\n ) {\n // register the known set of actions with\n // the action-matcher so it can match\n // events to actions\n this._actionMatcher?.register(item.conditions.actions.values)\n\n // maintain a mapping of (Action1) => [Item1, Item2, Item3]\n // where Items 1-3 are all activated by Action1\n item.conditions?.actions?.values?.forEach((action) => {\n if (action && action.name) {\n const knownItems: string[] | undefined = this._actionToItems.get(action.name)\n if (knownItems) {\n knownItems.push(item.id)\n }\n this._actionToItems.set(action.name, knownItems || [item.id])\n }\n })\n }\n })\n }\n\n private _setupEventBasedItems(items: T[]) {\n const eventBasedItems = items.filter(\n (item: T) => item.conditions?.events && item.conditions?.events?.values?.length > 0\n )\n\n const itemsWithCancelEvents = items.filter(\n (item: T) => item.conditions?.cancelEvents && item.conditions?.cancelEvents?.values?.length > 0\n )\n\n if (eventBasedItems.length === 0 && itemsWithCancelEvents.length === 0) {\n return\n }\n\n // match any events to its corresponding item.\n const matchEventToItem = (eventName: string, eventPayload?: CaptureResult) => {\n this.onEvent(eventName, eventPayload)\n }\n this._instance?._addCaptureHook(matchEventToItem)\n\n this._eventToItems = this._buildEventToItemMap(items, SurveyEventType.Activation)\n this._cancelEventToItems = this._buildEventToItemMap(items, SurveyEventType.Cancellation)\n }\n\n onEvent(event: string, eventPayload?: CaptureResult): void {\n const logger = this._getLogger()\n const activatedKey = this._getActivatedKey()\n const shownEventName = this._getShownEventName()\n\n const existingActivatedItems: string[] = this._instance?.persistence?.props[activatedKey] || []\n if (shownEventName === event && eventPayload && existingActivatedItems.length > 0) {\n // remove item from activatedItems here.\n logger.info('event matched, removing item from activated items', {\n event,\n eventPayload,\n existingActivatedItems,\n })\n const itemId = eventPayload?.properties?.$survey_id || eventPayload?.properties?.$product_tour_id\n if (itemId) {\n const index = existingActivatedItems.indexOf(itemId)\n if (index >= 0) {\n existingActivatedItems.splice(index, 1)\n this._updateActivatedItems(existingActivatedItems)\n }\n }\n\n return\n }\n\n // check if this event should cancel any pending items\n if (this._cancelEventToItems.has(event)) {\n const itemsToCancel = this._getMatchingItems(event, eventPayload, SurveyEventType.Cancellation)\n\n if (itemsToCancel.length > 0) {\n logger.info('cancel event matched, cancelling items', {\n event,\n itemsToCancel: itemsToCancel.map((s) => s.id),\n })\n\n itemsToCancel.forEach((item) => {\n // remove from activated items\n const index = existingActivatedItems.indexOf(item.id)\n if (index >= 0) {\n existingActivatedItems.splice(index, 1)\n }\n // cancel any pending timeout for this item\n this._cancelPendingItem(item.id)\n })\n\n this._updateActivatedItems(existingActivatedItems)\n }\n }\n\n // if the event is not in the eventToItems map, nothing else to do\n if (!this._eventToItems.has(event)) {\n return\n }\n\n logger.info('event name matched', {\n event,\n eventPayload,\n items: this._eventToItems.get(event),\n })\n\n const matchedItems = this._getMatchingItems(event, eventPayload, SurveyEventType.Activation)\n\n this._updateActivatedItems(existingActivatedItems.concat(matchedItems.map((item) => item.id) || []))\n }\n\n onAction(actionName: string): void {\n const activatedKey = this._getActivatedKey()\n const existingActivatedItems: string[] = this._instance?.persistence?.props[activatedKey] || []\n if (this._actionToItems.has(actionName)) {\n this._updateActivatedItems(existingActivatedItems.concat(this._actionToItems.get(actionName) || []))\n }\n }\n\n private _updateActivatedItems(activatedItems: string[]) {\n const logger = this._getLogger()\n const activatedKey = this._getActivatedKey()\n // Filter out permanently ineligible items and remove duplicates\n const eligibleItems = [...new Set(activatedItems)].filter(\n (itemId) => !this._isItemPermanentlyIneligible(itemId)\n )\n logger.info('updating activated items', {\n activatedItems: eligibleItems,\n })\n\n this._instance?.persistence?.register({\n [activatedKey]: eligibleItems,\n })\n }\n\n getActivatedIds(): string[] {\n const activatedKey = this._getActivatedKey()\n const existingActivatedItems = this._instance?.persistence?.props[activatedKey]\n return existingActivatedItems ? existingActivatedItems : []\n }\n\n getEventToItemsMap(): Map<string, string[]> {\n return this._eventToItems\n }\n\n _getActionMatcher(): ActionMatcher | null | undefined {\n return this._actionMatcher\n }\n}\n","import { PRODUCT_TOURS_ACTIVATED } from '../constants'\nimport { ProductTour } from '../posthog-product-tours-types'\nimport { PostHog } from '../posthog-core'\nimport { EventReceiver } from './event-receiver'\nimport { createLogger } from './logger'\nimport { localStore } from '../storage'\nimport { TOUR_COMPLETED_KEY_PREFIX, TOUR_DISMISSED_KEY_PREFIX } from '../extensions/product-tours/constants'\n\nconst logger = createLogger('[Product Tour Event Receiver]')\n\nexport class ProductTourEventReceiver extends EventReceiver<ProductTour> {\n constructor(instance: PostHog) {\n super(instance)\n }\n\n protected _getActivatedKey(): string {\n return PRODUCT_TOURS_ACTIVATED\n }\n\n protected _getShownEventName(): string {\n return 'product tour shown'\n }\n\n protected _getItems(callback: (items: ProductTour[]) => void): void {\n this._instance?.productTours?.getProductTours(callback)\n }\n\n protected _cancelPendingItem(itemId: string): void {\n this._instance?.productTours?.cancelPendingTour(itemId)\n }\n\n protected _getLogger(): ReturnType<typeof createLogger> {\n return logger\n }\n\n protected _isItemPermanentlyIneligible(itemId?: string): boolean {\n if (!itemId) return true\n const completedKey = `${TOUR_COMPLETED_KEY_PREFIX}${itemId}`\n const dismissedKey = `${TOUR_DISMISSED_KEY_PREFIX}${itemId}`\n return !!(localStore._get(completedKey) || localStore._get(dismissedKey))\n }\n\n getTours(): string[] {\n return this.getActivatedIds()\n }\n}\n","/*\n * Constants\n */\n\n/* PROPERTY KEYS */\n\n// This key is deprecated, but we want to check for it to see whether aliasing is allowed.\nexport const PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id'\nexport const DISTINCT_ID = 'distinct_id'\nexport const DEVICE_ID = '$device_id'\nexport const ALIAS_ID_KEY = '__alias'\nexport const CAMPAIGN_IDS_KEY = '__cmpns'\nexport const EVENT_TIMERS_KEY = '__timers'\nexport const AUTOCAPTURE_DISABLED_SERVER_SIDE = '$autocapture_disabled_server_side'\nexport const HEATMAPS_ENABLED_SERVER_SIDE = '$heatmaps_enabled_server_side'\nexport const EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE = '$exception_capture_enabled_server_side'\nexport const ERROR_TRACKING_SUPPRESSION_RULES = '$error_tracking_suppression_rules'\nexport const ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS = '$error_tracking_capture_extension_exceptions'\nexport const WEB_VITALS_ENABLED_SERVER_SIDE = '$web_vitals_enabled_server_side'\nexport const DEAD_CLICKS_ENABLED_SERVER_SIDE = '$dead_clicks_enabled_server_side'\nexport const PRODUCT_TOURS_ENABLED_SERVER_SIDE = '$product_tours_enabled_server_side'\nexport const WEB_VITALS_ALLOWED_METRICS = '$web_vitals_allowed_metrics'\nexport const SESSION_RECORDING_REMOTE_CONFIG = '$session_recording_remote_config'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side'\n// @deprecated can be removed along with eager loaded replay\nexport const CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = '$console_log_recording_enabled_server_side'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE = '$session_recording_network_payload_capture'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_MASKING = '$session_recording_masking'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_CANVAS_RECORDING = '$session_recording_canvas_recording'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_SAMPLE_RATE = '$replay_sample_rate'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_MINIMUM_DURATION = '$replay_minimum_duration'\n// @deprecated can be removed along with eager loaded replay\nexport const SESSION_RECORDING_SCRIPT_CONFIG = '$replay_script_config'\nexport const SESSION_RECORDING_OVERRIDE_SAMPLING = '$replay_override_sampling'\nexport const SESSION_RECORDING_OVERRIDE_LINKED_FLAG = '$replay_override_linked_flag'\nexport const SESSION_RECORDING_OVERRIDE_URL_TRIGGER = '$replay_override_url_trigger'\nexport const SESSION_RECORDING_OVERRIDE_EVENT_TRIGGER = '$replay_override_event_trigger'\nexport const SESSION_ID = '$sesid'\nexport const SESSION_RECORDING_IS_SAMPLED = '$session_is_sampled'\nexport const SESSION_RECORDING_PAST_MINIMUM_DURATION = '$session_past_minimum_duration'\nexport const SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION = '$session_recording_url_trigger_activated_session'\nexport const SESSION_RECORDING_EVENT_TRIGGER_ACTIVATED_SESSION = '$session_recording_event_trigger_activated_session'\nexport const ENABLED_FEATURE_FLAGS = '$enabled_feature_flags'\nexport const PERSISTENCE_EARLY_ACCESS_FEATURES = '$early_access_features'\nexport const PERSISTENCE_FEATURE_FLAG_DETAILS = '$feature_flag_details'\nexport const STORED_PERSON_PROPERTIES_KEY = '$stored_person_properties'\nexport const STORED_GROUP_PROPERTIES_KEY = '$stored_group_properties'\nexport const SURVEYS = '$surveys'\nexport const SURVEYS_ACTIVATED = '$surveys_activated'\nexport const PRODUCT_TOURS_ACTIVATED = '$product_tours_activated'\nexport const CONVERSATIONS = '$conversations'\nexport const FLAG_CALL_REPORTED = '$flag_call_reported'\nexport const USER_STATE = '$user_state'\nexport const CLIENT_SESSION_PROPS = '$client_session_props'\nexport const CAPTURE_RATE_LIMIT = '$capture_rate_limit'\n\n/** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */\nexport const INITIAL_CAMPAIGN_PARAMS = '$initial_campaign_params'\n/** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */\nexport const INITIAL_REFERRER_INFO = '$initial_referrer_info'\nexport const INITIAL_PERSON_INFO = '$initial_person_info'\nexport const ENABLE_PERSON_PROCESSING = '$epp'\nexport const TOOLBAR_ID = '__POSTHOG_TOOLBAR__'\nexport const TOOLBAR_CONTAINER_CLASS = 'toolbar-global-fade-container'\n\n/**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Sentinel value for distinct id, device id, session id. Signals that the server should generate the value\n * */\nexport const COOKIELESS_SENTINEL_VALUE = '$posthog_cookieless'\nexport const COOKIELESS_MODE_FLAG_PROPERTY = '$cookieless_mode'\n\nexport const WEB_EXPERIMENTS = '$web_experiments'\n\n// These are properties that are reserved and will not be automatically included in events\nexport const PERSISTENCE_RESERVED_PROPERTIES = [\n PEOPLE_DISTINCT_ID_KEY,\n ALIAS_ID_KEY,\n CAMPAIGN_IDS_KEY,\n EVENT_TIMERS_KEY,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n HEATMAPS_ENABLED_SERVER_SIDE,\n SESSION_ID,\n ENABLED_FEATURE_FLAGS,\n ERROR_TRACKING_SUPPRESSION_RULES,\n USER_STATE,\n PERSISTENCE_EARLY_ACCESS_FEATURES,\n PERSISTENCE_FEATURE_FLAG_DETAILS,\n STORED_GROUP_PROPERTIES_KEY,\n STORED_PERSON_PROPERTIES_KEY,\n SURVEYS,\n FLAG_CALL_REPORTED,\n CLIENT_SESSION_PROPS,\n CAPTURE_RATE_LIMIT,\n INITIAL_CAMPAIGN_PARAMS,\n INITIAL_REFERRER_INFO,\n ENABLE_PERSON_PROCESSING,\n INITIAL_PERSON_INFO,\n // Conversations keys (defined in lazy-loaded extension)\n '$conversations_widget_session_id',\n '$conversations_ticket_id',\n '$conversations_widget_state',\n '$conversations_user_traits',\n]\n\nexport const SURVEYS_REQUEST_TIMEOUT_MS = 10000\n","import { render } from 'preact'\nimport { PostHog } from '../../posthog-core'\nimport {\n ProductTour,\n ProductTourCallback,\n ProductTourDismissReason,\n ProductTourRenderReason,\n ShowTourOptions,\n} from '../../posthog-product-tours-types'\nimport { SurveyEventName, SurveyEventProperties } from '../../posthog-surveys-types'\nimport {\n addProductTourCSSVariablesToElement,\n findElementBySelector,\n getElementMetadata,\n getProductTourStylesheet,\n normalizeUrl,\n} from './product-tours-utils'\nimport { findElement } from './element-inference'\nimport { ProductTourTooltip } from './components/ProductTourTooltip'\nimport { createLogger } from '../../utils/logger'\nimport { document as _document, window as _window } from '../../utils/globals'\nimport { localStore, sessionStore } from '../../storage'\nimport { addEventListener } from '../../utils'\nimport { isNull, SurveyMatchType } from '@posthog/core'\nimport { propertyComparisons } from '../../utils/property-utils'\nimport { TOUR_COMPLETED_KEY_PREFIX, TOUR_DISMISSED_KEY_PREFIX, ACTIVE_TOUR_SESSION_KEY } from './constants'\nimport { doesTourActivateByAction, doesTourActivateByEvent } from '../../utils/product-tour-utils'\nimport { TOOLBAR_ID } from '../../constants'\nimport { ProductTourEventReceiver } from '../../utils/product-tour-event-receiver'\n\nconst logger = createLogger('[Product Tours]')\n\nconst document = _document as Document\nconst window = _window as Window & typeof globalThis\n\n// Tour condition checking - reuses the same URL matching logic as surveys\nfunction doesTourUrlMatch(tour: ProductTour): boolean {\n const conditions = tour.conditions\n if (!conditions?.url) {\n return true\n }\n\n const href = window?.location?.href\n if (!href) {\n return false\n }\n\n const matchType = conditions.urlMatchType || SurveyMatchType.Icontains\n\n if (matchType === SurveyMatchType.Exact) {\n return normalizeUrl(href) === normalizeUrl(conditions.url)\n }\n\n const targets = [conditions.url]\n return propertyComparisons[matchType](targets, [href])\n}\n\nfunction isTourInDateRange(tour: ProductTour): boolean {\n const now = new Date()\n\n if (tour.start_date) {\n const startDate = new Date(tour.start_date)\n if (now < startDate) {\n return false\n }\n }\n\n if (tour.end_date) {\n const endDate = new Date(tour.end_date)\n if (now > endDate) {\n return false\n }\n }\n\n return true\n}\n\nfunction checkTourConditions(tour: ProductTour): boolean {\n return isTourInDateRange(tour) && doesTourUrlMatch(tour)\n}\n\nconst CONTAINER_CLASS = 'ph-product-tour-container'\nconst TRIGGER_LISTENER_ATTRIBUTE = 'data-ph-tour-trigger'\nconst CHECK_INTERVAL_MS = 1000\n\ninterface TriggerListenerData {\n element: Element\n listener: (event: Event) => void\n tour: ProductTour\n}\n\nfunction retrieveTourShadow(tour: ProductTour): { shadow: ShadowRoot; isNewlyCreated: boolean } {\n const containerClass = `${CONTAINER_CLASS}-${tour.id}`\n const existingDiv = document.querySelector(`.${containerClass}`)\n\n if (existingDiv && existingDiv.shadowRoot) {\n return {\n shadow: existingDiv.shadowRoot,\n isNewlyCreated: false,\n }\n }\n\n const div = document.createElement('div')\n div.className = containerClass\n\n addProductTourCSSVariablesToElement(div, tour.appearance)\n\n const shadow = div.attachShadow({ mode: 'open' })\n\n const stylesheet = getProductTourStylesheet()\n if (stylesheet) {\n shadow.appendChild(stylesheet)\n }\n\n document.body.appendChild(div)\n\n return {\n shadow,\n isNewlyCreated: true,\n }\n}\n\nfunction removeTourFromDom(tourId: string): void {\n const containerClass = `${CONTAINER_CLASS}-${tourId}`\n const container = document.querySelector(`.${containerClass}`)\n if (container?.shadowRoot) {\n render(null, container.shadowRoot)\n }\n container?.remove()\n}\n\nexport class ProductTourManager {\n private _instance: PostHog\n private _activeTour: ProductTour | null = null\n private _currentStepIndex: number = 0\n private _isPreviewMode: boolean = false\n private _isResuming: boolean = false\n private _checkInterval: ReturnType<typeof setInterval> | null = null\n private _triggerSelectorListeners: Map<string, TriggerListenerData> = new Map()\n private _pendingTourTimeouts: Map<string, ReturnType<typeof setTimeout>> = new Map()\n private _eventReceiver: ProductTourEventReceiver\n private _registeredEventTourIds: Set<string> = new Set()\n\n constructor(instance: PostHog) {\n this._instance = instance\n this._eventReceiver = new ProductTourEventReceiver(instance)\n }\n\n private _setStepIndex(index: number): void {\n this._currentStepIndex = index\n this._saveSessionState()\n }\n\n private _saveSessionState(): void {\n if (!this._activeTour || this._isPreviewMode) {\n return\n }\n sessionStore._set(ACTIVE_TOUR_SESSION_KEY, {\n tourId: this._activeTour.id,\n stepIndex: this._currentStepIndex,\n })\n }\n\n private _clearSessionState(): void {\n sessionStore._remove(ACTIVE_TOUR_SESSION_KEY)\n }\n\n private _getSessionState(): { tourId: string; stepIndex: number } | null {\n const stored = sessionStore._get(ACTIVE_TOUR_SESSION_KEY)\n if (!stored) {\n return null\n }\n try {\n return JSON.parse(stored)\n } catch {\n return null\n }\n }\n\n start(): void {\n if (this._checkInterval) {\n return\n }\n\n // Check for saved session state before starting the evaluation loop\n const savedState = this._getSessionState()\n if (savedState) {\n this._resumeSavedTour(savedState.tourId, savedState.stepIndex, () => {\n this._startEvaluationLoop()\n })\n } else {\n this._startEvaluationLoop()\n }\n }\n\n private _startEvaluationLoop(): void {\n this._checkInterval = setInterval(() => {\n this._evaluateAndDisplayTours()\n }, CHECK_INTERVAL_MS)\n\n this._evaluateAndDisplayTours()\n addEventListener(document, 'visibilitychange', this._handleVisibilityChange)\n }\n\n private _resumeSavedTour(tourId: string, stepIndex: number, onComplete: () => void): void {\n this._instance.productTours?.getProductTours((tours) => {\n const tour = tours.find((t) => t.id === tourId)\n\n if (!tour) {\n if (tours.length > 0) {\n this._clearSessionState()\n }\n } else {\n this._activeTour = tour\n this._currentStepIndex = stepIndex\n this._isResuming = true\n this._renderCurrentStep()\n }\n\n onComplete()\n })\n }\n\n stop(): void {\n if (this._checkInterval) {\n clearInterval(this._checkInterval)\n this._checkInterval = null\n }\n document.removeEventListener('visibilitychange', this._handleVisibilityChange)\n this._removeAllTriggerListeners()\n this._cancelAllPendingTours()\n this._cleanup()\n }\n\n private _handleVisibilityChange = (): void => {\n if (document.hidden && this._checkInterval) {\n clearInterval(this._checkInterval)\n this._checkInterval = null\n } else if (!document.hidden && !this._checkInterval) {\n this._checkInterval = setInterval(() => {\n this._evaluateAndDisplayTours()\n }, CHECK_INTERVAL_MS)\n this._evaluateAndDisplayTours()\n }\n }\n\n private _evaluateAndDisplayTours(): void {\n if (document?.getElementById(TOOLBAR_ID)) {\n return\n }\n\n // Use getProductTours (not getActiveProductTours) because selector-triggered tours\n // should work even if completed/dismissed\n this._instance.productTours?.getProductTours((tours) => {\n if (tours.length === 0) {\n this._removeAllTriggerListeners()\n return\n }\n\n const activeTriggerTourIds = new Set<string>()\n\n const unregisteredEventTours = tours.filter(\n (tour: ProductTour) =>\n !this._registeredEventTourIds.has(tour.id) &&\n (doesTourActivateByEvent(tour) || doesTourActivateByAction(tour))\n )\n if (unregisteredEventTours.length > 0) {\n this._eventReceiver.register(unregisteredEventTours)\n unregisteredEventTours.forEach((tour) => this._registeredEventTourIds.add(tour.id))\n }\n\n const eventActivatedTourIds = this._activeTour ? [] : this._eventReceiver.getTours()\n\n /**\n * tours can be shown three ways, really:\n *\n * 1) selector clicks\n * 2a) auto-show immediately\n * 2b) auto-show after event/action\n *\n * (1) and (2[a|b]) are fully independent of each other\n */\n for (const tour of tours) {\n // 1) SELECTOR CLICK TRIGGER - just attach an event listener and keep going\n const triggerSelector = tour.conditions?.selector\n if (triggerSelector) {\n activeTriggerTourIds.add(tour.id)\n this._manageTriggerSelectorListener(tour, triggerSelector)\n }\n\n // skip auto-launch checks if a tour is already active\n if (this._activeTour) {\n continue\n }\n\n // 2) AUTO-LAUNCH\n const hasEventOrActionTriggers = doesTourActivateByAction(tour) || doesTourActivateByEvent(tour)\n\n if (tour.auto_launch && this._isTourEligible(tour)) {\n // tour should auto-launch, and the current session is eligible\n\n if (!hasEventOrActionTriggers) {\n // 2a) AUTO-SHOW WITH NO EVENT/ACTION\n this._showOrQueueTour(tour, 'auto')\n continue\n }\n\n // 2b) AUTO-SHOW, BUT WAIT FOR EVENT/ACTION\n if (eventActivatedTourIds.includes(tour.id)) {\n this._showOrQueueTour(tour, 'event')\n }\n }\n }\n\n this._triggerSelectorListeners.forEach(({ tour }) => {\n if (!activeTriggerTourIds.has(tour.id)) {\n this._removeTriggerSelectorListener(tour.id)\n }\n })\n })\n }\n\n private _showOrQueueTour(tour: ProductTour, reason: ProductTourRenderReason): void {\n const delaySeconds = tour.conditions?.autoShowDelaySeconds || 0\n if (delaySeconds > 0) {\n if (!this.isTourPending(tour.id)) {\n this.queueTourWithDelay(tour.id, delaySeconds, reason)\n }\n } else {\n this.showTour(tour, { reason })\n }\n }\n\n private _isTourEligible(tour: ProductTour): boolean {\n if (!checkTourConditions(tour)) {\n logger.info(`Tour ${tour.id} failed conditions check`)\n return false\n }\n\n const completedKey = `${TOUR_COMPLETED_KEY_PREFIX}${tour.id}`\n const dismissedKey = `${TOUR_DISMISSED_KEY_PREFIX}${tour.id}`\n\n if (localStore._get(completedKey) || localStore._get(dismissedKey)) {\n logger.info(`Tour ${tour.id} already completed or dismissed`)\n return false\n }\n\n if (tour.internal_targeting_flag_key) {\n const flagValue = this._instance.featureFlags?.getFeatureFlag(tour.internal_targeting_flag_key)\n if (!flagValue) {\n logger.info(`Tour ${tour.id} failed feature flag check: ${tour.internal_targeting_flag_key}`)\n return false\n }\n }\n\n return true\n }\n\n showTour(tour: ProductTour, options?: ShowTourOptions): void {\n const renderReason: ProductTourRenderReason = options?.reason ?? 'auto'\n\n this.cancelPendingTour(tour.id)\n\n // Validate all step selectors before showing the tour\n // Steps without selectors are modal steps and don't need validation\n const selectorFailures: Array<{\n stepIndex: number\n stepId: string\n selector: string\n error: string\n matchCount: number\n }> = []\n\n for (let i = 0; i < tour.steps.length; i++) {\n const step = tour.steps[i]\n\n // Skip validation for modal steps (no selector)\n if (!step.selector) {\n continue\n }\n\n const result = findElementBySelector(step.selector)\n\n if (result.error === 'not_found' || result.error === 'not_visible') {\n selectorFailures.push({\n stepIndex: i,\n stepId: step.id,\n selector: step.selector,\n error: result.error,\n matchCount: result.matchCount,\n })\n }\n }\n\n if (selectorFailures.length > 0) {\n // Emit events for each failed selector for debugging/data purposes\n for (const failure of selectorFailures) {\n this._captureEvent('product tour step selector failed', {\n $product_tour_id: tour.id,\n $product_tour_step_id: failure.stepId,\n $product_tour_step_order: failure.stepIndex,\n $product_tour_step_selector: failure.selector,\n $product_tour_error: failure.error,\n $product_tour_matches_count: failure.matchCount,\n $product_tour_failure_phase: 'validation',\n })\n }\n\n const failedSelectors = selectorFailures.map((f) => `Step ${f.stepIndex}: \"${f.selector}\" (${f.error})`)\n logger.warn(\n `Tour \"${tour.name}\" (${tour.id}): ${selectorFailures.length} selector(s) failed to match:\\n - ${failedSelectors.join('\\n - ')}${options?.enableStrictValidation === true ? '\\n\\nenableStrictValidation is true, not displaying tour.' : ''}`\n )\n if (options?.enableStrictValidation === true) return\n }\n\n this._activeTour = tour\n this._setStepIndex(0)\n\n this._captureEvent('product tour shown', {\n $product_tour_id: tour.id,\n $product_tour_name: tour.name,\n $product_tour_iteration: tour.current_iteration || 1,\n $product_tour_render_reason: renderReason,\n })\n\n this._renderCurrentStep()\n }\n\n showTourById(tourId: string, reason?: ProductTourRenderReason): void {\n logger.info(`showTourById(${tourId})`)\n this._instance.productTours?.getProductTours((tours) => {\n const tour = tours.find((t) => t.id === tourId)\n if (tour) {\n this.showTour(tour, { reason: reason ?? 'api' })\n } else {\n logger.warn('could not find tour', tourId)\n }\n })\n }\n\n previewTour(tour: ProductTour): void {\n logger.info(`Previewing tour ${tour.id}`)\n\n this._cleanup()\n\n this._isPreviewMode = true\n this._activeTour = tour\n this._currentStepIndex = 0\n\n this._renderCurrentStep()\n }\n\n nextStep = (): void => {\n if (!this._activeTour) {\n return\n }\n\n const currentStep = this._activeTour.steps[this._currentStepIndex]\n\n this._captureEvent('product tour step completed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: currentStep.id,\n $product_tour_step_order: this._currentStepIndex,\n })\n\n if (this._currentStepIndex < this._activeTour.steps.length - 1) {\n this._setStepIndex(this._currentStepIndex + 1)\n this._renderCurrentStep()\n } else {\n this._completeTour()\n }\n }\n\n previousStep = (): void => {\n if (!this._activeTour || this._currentStepIndex === 0) {\n return\n }\n\n this._setStepIndex(this._currentStepIndex - 1)\n this._renderCurrentStep()\n }\n\n dismissTour = (reason: ProductTourDismissReason = 'user_clicked_skip'): void => {\n if (!this._activeTour) {\n return\n }\n\n const currentStep = this._activeTour.steps[this._currentStepIndex]\n\n this._captureEvent('product tour dismissed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: currentStep.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_dismiss_reason: reason,\n })\n\n if (!this._isPreviewMode) {\n localStore._set(`${TOUR_DISMISSED_KEY_PREFIX}${this._activeTour.id}`, true)\n }\n\n window.dispatchEvent(\n new CustomEvent('PHProductTourDismissed', { detail: { tourId: this._activeTour.id, reason } })\n )\n\n this._cleanup()\n }\n\n private _completeTour(): void {\n if (!this._activeTour) {\n return\n }\n\n this._captureEvent('product tour completed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_steps_count: this._activeTour.steps.length,\n })\n\n if (!this._isPreviewMode) {\n localStore._set(`${TOUR_COMPLETED_KEY_PREFIX}${this._activeTour.id}`, true)\n\n this._instance.capture('$set', {\n $set: {\n [`$product_tour_completed/${this._activeTour.id}`]: true,\n },\n })\n }\n\n window.dispatchEvent(new CustomEvent('PHProductTourCompleted', { detail: { tourId: this._activeTour.id } }))\n\n this._cleanup()\n }\n\n private _renderCurrentStep(retryCount: number = 0): void {\n if (!this._activeTour) {\n return\n }\n\n const step = this._activeTour.steps[this._currentStepIndex]\n if (!step) {\n logger.warn(`Step ${this._currentStepIndex} not found in tour ${this._activeTour.id}`)\n this._cleanup()\n return\n }\n\n // Survey step - render native survey step component\n if (step.type === 'survey') {\n if (step.survey) {\n this._renderSurveyStep()\n } else {\n logger.warn('Unable to render survey step - survey data not found')\n }\n\n return\n }\n\n // Modal step (no selector) - render without a target element\n if (step.type === 'modal') {\n this._captureEvent('product tour step shown', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_type: 'modal',\n })\n\n this._isResuming = false\n this._renderTooltipWithPreact(null)\n return\n }\n\n if (!step.selector) {\n logger.warn('Unable to render element step - no selector defined.')\n return\n }\n\n const result = findElementBySelector(step.selector)\n\n // shadow mode: try inference to compare with selector results\n const inferenceProps = step.inferenceData\n ? (() => {\n const inferenceElement = findElement(step.inferenceData)\n return {\n $inference_data_present: true,\n $inference_found: !!inferenceElement,\n $inference_matches_selector: result.element === inferenceElement,\n }\n })()\n : { $inference_data_present: false }\n\n const previousStep = this._currentStepIndex > 0 ? this._activeTour.steps[this._currentStepIndex - 1] : null\n const shouldWaitForElement = previousStep?.progressionTrigger === 'click' || this._isResuming\n\n // 2s total timeout\n const maxRetries = 20\n const retryTimeout = 100\n\n if (result.error === 'not_found' || result.error === 'not_visible') {\n // if previous step was click-to-progress, or we are resuming a tour,\n // give some time for the next element\n if (shouldWaitForElement && retryCount < maxRetries) {\n setTimeout(() => {\n this._renderCurrentStep(retryCount + 1)\n }, retryTimeout)\n return\n }\n\n const waitDurationMs = retryCount * retryTimeout\n\n this._captureEvent('product tour step selector failed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_selector: step.selector,\n $product_tour_error: result.error,\n $product_tour_matches_count: result.matchCount,\n $product_tour_failure_phase: 'runtime',\n $product_tour_waited_for_element: shouldWaitForElement,\n $product_tour_wait_duration_ms: waitDurationMs,\n ...inferenceProps,\n })\n\n logger.warn(\n `Tour \"${this._activeTour.name}\" dismissed: element for step ${this._currentStepIndex} became unavailable (${result.error})` +\n (shouldWaitForElement ? ` after waiting ${waitDurationMs}ms` : '')\n )\n this.dismissTour('element_unavailable')\n return\n }\n\n if (result.error === 'multiple_matches') {\n this._captureEvent('product tour step selector failed', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_selector: step.selector,\n $product_tour_error: result.error,\n $product_tour_matches_count: result.matchCount,\n $product_tour_failure_phase: 'runtime',\n ...inferenceProps,\n })\n // Continue with first match for multiple_matches case\n }\n\n if (!result.element) {\n return\n }\n\n const element = result.element\n const metadata = getElementMetadata(element)\n\n this._captureEvent('product tour step shown', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_selector: step.selector,\n $product_tour_step_selector_found: true,\n $product_tour_step_element_tag: metadata.tag,\n $product_tour_step_element_id: metadata.id,\n $product_tour_step_element_classes: metadata.classes,\n $product_tour_step_element_text: metadata.text,\n ...inferenceProps,\n })\n\n this._isResuming = false\n this._renderTooltipWithPreact(element)\n }\n\n private _renderTooltipWithPreact(\n element: HTMLElement | null,\n onSurveySubmit?: (response: string | number | null) => void,\n onDismissOverride?: (reason: ProductTourDismissReason) => void\n ): void {\n if (!this._activeTour) {\n return\n }\n\n const step = this._activeTour.steps[this._currentStepIndex]\n const { shadow } = retrieveTourShadow(this._activeTour)\n\n render(\n <ProductTourTooltip\n tour={this._activeTour}\n step={step}\n stepIndex={this._currentStepIndex}\n totalSteps={this._activeTour.steps.length}\n targetElement={element}\n onNext={this.nextStep}\n onPrevious={this.previousStep}\n onDismiss={onDismissOverride || this.dismissTour}\n onSurveySubmit={onSurveySubmit}\n />,\n shadow\n )\n }\n\n private _renderSurveyStep(): void {\n if (!this._activeTour) {\n return\n }\n\n const tourId = this._activeTour.id\n const step = this._activeTour.steps[this._currentStepIndex]\n const surveyId = step.linkedSurveyId\n const questionId = step.linkedSurveyQuestionId\n const questionText = step.survey?.questionText || ''\n\n this._captureEvent('product tour step shown', {\n $product_tour_id: this._activeTour.id,\n $product_tour_step_id: step.id,\n $product_tour_step_order: this._currentStepIndex,\n $product_tour_step_type: 'survey',\n $product_tour_linked_survey_id: surveyId,\n })\n\n this._captureEvent(SurveyEventName.SHOWN, {\n [SurveyEventProperties.SURVEY_ID]: surveyId,\n [SurveyEventProperties.PRODUCT_TOUR_ID]: tourId,\n sessionRecordingUrl: this._instance.get_session_replay_url?.(),\n })\n\n const handleSubmit = (response: string | number | null) => {\n const responseKey = questionId ? `$survey_response_${questionId}` : '$survey_response'\n this._captureEvent(SurveyEventName.SENT, {\n [SurveyEventProperties.SURVEY_ID]: surveyId,\n [SurveyEventProperties.PRODUCT_TOUR_ID]: tourId,\n [SurveyEventProperties.SURVEY_QUESTIONS]: [\n {\n id: questionId,\n question: questionText,\n response: response,\n },\n ],\n [SurveyEventProperties.SURVEY_COMPLETED]: true,\n sessionRecordingUrl: this._instance.get_session_replay_url?.(),\n ...(!isNull(response) && { [responseKey]: response }),\n })\n\n logger.info(`Survey ${surveyId} completed`, !isNull(response) ? `with response: ${response}` : '(skipped)')\n this.nextStep()\n }\n\n const handleDismiss = (reason: ProductTourDismissReason) => {\n this._captureEvent(SurveyEventName.DISMISSED, {\n [SurveyEventProperties.SURVEY_ID]: surveyId,\n [SurveyEventProperties.PRODUCT_TOUR_ID]: tourId,\n [SurveyEventProperties.SURVEY_QUESTIONS]: [\n {\n id: questionId,\n question: questionText,\n response: null,\n },\n ],\n [SurveyEventProperties.SURVEY_PARTIALLY_COMPLETED]: false,\n sessionRecordingUrl: this._instance.get_session_replay_url?.(),\n })\n\n logger.info(`Survey ${surveyId} dismissed`)\n this.dismissTour(reason)\n }\n\n this._renderTooltipWithPreact(null, handleSubmit, handleDismiss)\n\n logger.info(`Rendered survey step for tour step ${this._currentStepIndex}`)\n }\n\n private _cleanup(): void {\n if (this._activeTour) {\n removeTourFromDom(this._activeTour.id)\n }\n\n this._activeTour = null\n this._currentStepIndex = 0\n this._isPreviewMode = false\n this._isResuming = false\n this._clearSessionState()\n }\n\n private _manageTriggerSelectorListener(tour: ProductTour, selector: string): void {\n const currentElement = document.querySelector(selector)\n const existingListenerData = this._triggerSelectorListeners.get(tour.id)\n\n if (!currentElement) {\n if (existingListenerData) {\n this._removeTriggerSelectorListener(tour.id)\n }\n return\n }\n\n if (existingListenerData) {\n if (currentElement !== existingListenerData.element) {\n logger.info(`Trigger element changed for tour ${tour.id}. Re-attaching listener.`)\n this._removeTriggerSelectorListener(tour.id)\n } else {\n return\n }\n }\n\n if (!currentElement.hasAttribute(TRIGGER_LISTENER_ATTRIBUTE)) {\n const listener = (event: Event) => {\n event.stopPropagation()\n\n if (this._activeTour) {\n logger.info(`Tour ${tour.id} trigger clicked but another tour is active`)\n return\n }\n\n // manual triggers only check launch status, no other conditions\n if (!isTourInDateRange(tour)) {\n logger.warn(`Tour ${tour.id} trigger clicked, but tour is not launched - not showing tour.`)\n return\n }\n\n logger.info(`Tour ${tour.id} triggered by click on ${selector}`)\n this.showTour(tour, { reason: 'trigger' })\n }\n\n addEventListener(currentElement, 'click', listener)\n currentElement.setAttribute(TRIGGER_LISTENER_ATTRIBUTE, tour.id)\n this._triggerSelectorListeners.set(tour.id, { element: currentElement, listener, tour })\n logger.info(`Attached trigger listener for tour ${tour.id} on ${selector}`)\n }\n }\n\n private _removeTriggerSelectorListener(tourId: string): void {\n const existing = this._triggerSelectorListeners.get(tourId)\n if (existing) {\n existing.element.removeEventListener('click', existing.listener)\n existing.element.removeAttribute(TRIGGER_LISTENER_ATTRIBUTE)\n this._triggerSelectorListeners.delete(tourId)\n logger.info(`Removed trigger listener for tour ${tourId}`)\n }\n }\n\n private _removeAllTriggerListeners(): void {\n this._triggerSelectorListeners.forEach((_, tourId) => {\n this._removeTriggerSelectorListener(tourId)\n })\n }\n\n private _captureEvent(eventName: string, properties: Record<string, any>): void {\n if (this._isPreviewMode) {\n return\n }\n this._instance.capture(eventName, properties)\n }\n\n // Public API methods delegated from PostHogProductTours\n getActiveProductTours(callback: ProductTourCallback): void {\n this._instance.productTours?.getProductTours((tours, context) => {\n if (!context?.isLoaded) {\n callback([], context)\n return\n }\n\n const activeTours = tours.filter((tour) => this._isTourEligible(tour))\n callback(activeTours, context)\n })\n }\n\n resetTour(tourId: string): void {\n localStore._remove(`${TOUR_COMPLETED_KEY_PREFIX}${tourId}`)\n localStore._remove(`${TOUR_DISMISSED_KEY_PREFIX}${tourId}`)\n }\n\n resetAllTours(): void {\n const storage = window?.localStorage\n if (!storage) {\n return\n }\n const keysToRemove: string[] = []\n for (let i = 0; i < storage.length; i++) {\n const key = storage.key(i)\n if (key?.startsWith(TOUR_COMPLETED_KEY_PREFIX) || key?.startsWith(TOUR_DISMISSED_KEY_PREFIX)) {\n keysToRemove.push(key)\n }\n }\n keysToRemove.forEach((key) => localStore._remove(key))\n }\n\n cancelPendingTour(tourId: string): void {\n const timeout = this._pendingTourTimeouts.get(tourId)\n if (timeout) {\n clearTimeout(timeout)\n this._pendingTourTimeouts.delete(tourId)\n logger.info(`Cancelled pending tour: ${tourId}`)\n }\n }\n\n private _cancelAllPendingTours(): void {\n this._pendingTourTimeouts.forEach((timeout) => clearTimeout(timeout))\n this._pendingTourTimeouts.clear()\n }\n\n isTourPending(tourId: string): boolean {\n return this._pendingTourTimeouts.has(tourId)\n }\n\n queueTourWithDelay(tourId: string, delaySeconds: number, reason?: ProductTourRenderReason): void {\n logger.info(`Queueing tour ${tourId} with ${delaySeconds}s delay`)\n\n const timeoutId = setTimeout(() => {\n this._pendingTourTimeouts.delete(tourId)\n logger.info(`Delay elapsed for tour ${tourId}, showing now`)\n this.showTourById(tourId, reason)\n }, delaySeconds * 1000)\n\n this._pendingTourTimeouts.set(tourId, timeoutId)\n }\n}\n","import { PostHog } from '../../posthog-core'\nimport { document as _document } from '../../utils/globals'\nimport { ProductTourManager } from './product-tours'\n\nexport { ProductTourManager } from './product-tours'\nexport { findElementBySelector, getElementMetadata, getProductTourStylesheet } from './product-tours-utils'\nexport { findElement, getElementPath } from './element-inference'\nexport type { InferredSelector, AutoData, SelectorGroup } from './element-inference'\n\nexport function generateProductTours(posthog: PostHog, isEnabled: boolean): ProductTourManager | undefined {\n if (!_document) {\n return\n }\n\n const manager = new ProductTourManager(posthog)\n\n if (isEnabled) {\n manager.start()\n }\n\n return manager\n}\n","import { generateProductTours } from '../extensions/product-tours'\nimport { assignableWindow } from '../utils/globals'\n\nassignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {}\nassignableWindow.__PosthogExtensions__.generateProductTours = generateProductTours\n\nexport { findElement, getElementPath, elementIsVisible } from '../extensions/product-tours/element-inference'\nexport type { InferredSelector, AutoData, SelectorGroup } from '../extensions/product-tours/element-inference'\n\nexport default generateProductTours\n"],"names":["win","window","undefined","global","globalThis","self","File","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","assignableWindow","c","s","a","SurveyEventType","SurveyEventName","SurveyEventProperties","entries","setPrototypeOf","isFrozen","getPrototypeOf","getOwnPropertyDescriptor","Object","freeze","seal","create","apply","construct","Reflect","x","func","thisArg","_len","arguments","length","args","Array","_key","Func","_len2","_key2","arrayForEach","unapply","prototype","forEach","arrayLastIndexOf","lastIndexOf","arrayPop","pop","arrayPush","push","arraySplice","splice","stringToLowerCase","String","toLowerCase","stringToString","toString","stringMatch","match","stringReplace","replace","stringIndexOf","indexOf","stringTrim","trim","objectHasOwnProperty","hasOwnProperty","regExpTest","RegExp","test","typeErrorCreate","TypeError","_len4","_key4","lastIndex","_len3","_key3","addToSet","set","array","transformCaseFunc","l","element","lcElement","cleanArray","index","clone","object","newObject","property","value","isArray","constructor","lookupGetter","prop","desc","get","DEFAULT_PRODUCT_TOUR_APPEARANCE","backgroundColor","textColor","buttonColor","borderRadius","buttonBorderRadius","borderColor","fontFamily","boxShadow","showOverlay","whiteLabel","types_SurveyMatchType","SurveyMatchType","nativeIsArray","type_utils_toString","obj","call","isUndefined","isNull","isNullish","_createLogger","prefix","maybeCall","consoleLike","_log","level","consoleMethod","logger","info","warn","error","critical","_len5","_key5","createLogger","additionalPrefix","passThrough","fn","_temp","debugEnabled","POSTHOG_DEBUG","console","consoleLog","uninitializedWarning","methodName","options","prepareStylesheet","innerText","posthog","stylesheet","createElement","addEventListener","event","callback","capture","passive","sendBeacon","isMatchingRegex","pattern","str","_unused","isValidRegex","_unused2","propertyComparisons","exact","targets","values","some","target","is_not","every","regex","not_regex","icontains","map","includes","not_icontains","gt","numValue","parseFloat","isNaN","t","lt","v","matchPropertyFilters","propertyFilters","eventProperties","_ref","propertyName","filter","eventPropertyValue","eventValues","comparisonFunction","operator","r","u","i","o","f","e","n","__b","__r","diffed","__c","m","unmount","d","__h","__H","__","__V","h","B","__N","setState","this","props","shouldComponentUpdate","componentWillUpdate","__e","p","__s","z","_","F","current","b","shift","__P","k","w","__v","requestAnimationFrame","j","g","clearTimeout","cancelAnimationFrame","setTimeout","BLACK_TEXT_COLOR","defaultSurveyAppearance","hex2rgb","startsWith","hexColor","parseInt","slice","getContrastingTextColor","color","rgb","nameColorToHex","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","honeydew","hotpink","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","colorMatch","Math","sqrt","createContext","isPreviewMode","previewPageIndex","onPopupSurveyDismissed","isPopup","onPreviewSubmit","surveySubmissionId","_document","_window","findElementBySelector","selector","elements","querySelectorAll","matchCount","style","getComputedStyle","display","visibility","opacity","rect","getBoundingClientRect","width","height","isElementVisible","TOOLTIP_MARGIN","TOOLTIP_WIDTH","TOOLTIP_HEIGHT_ESTIMATE","addProductTourCSSVariablesToElement","appearance","hex","merged","_extends","setProperty","defaultFontStack","getFontFamily","renderTipTapContent","content","_content$content","escapeHtml","type","text","marks","mark","children","join","_content$attrs","attrs","normalizeUrl","url","endsWith","div","textContent","innerHTML","getStepHtml","step","contentHtml","DOMPurify","sanitize","ADD_TAGS","ADD_ATTR","querySelectorAllDeep","root","allElements","findMany","sel","saveUnmatched","unmatched","tokens","prev_match_idx","state","next_match_idx","not_escaped_pattern","whitespace_pattern","state_patterns","exec","substr","substring","charAt","normalizeSelector","querySelector","head","createShadowRoot","attachShadow","splitByCharacterUnlessQuoted","reduce","acc","minimalSelector","splitSelector","entry","possibleElementsIndex","possibleElements","cachedElements","findAllElements","nodes","el","shadowRoot","matches","collectAllElementsDeep","findElements","position","parent","foundElement","isDocumentNode","foundMatch","reversedParts","concat","reverse","newParent","part","findParentOrHost","findMatchingElement","_querySelectorDeep","character","sQuote","quote","node","nodeType","Node","DOCUMENT_FRAGMENT_NODE","DOCUMENT_NODE","parentNode","host","log","bind","debug","elementIsVisible","cache","alreadyCached","checkVisibility","nativeIsVisible","checkOpacity","checkVisibilityCSS","parentElement","cached","parentStyle","parentVisible","elementHasActualRenderedDimensions","getClientRects","elementMatchesText","elementText","_element$innerText","getElementText","queryElements","visibilityCache","nth","iterable","idx","item","findElement","autoData","JSON","parse","textGroups","notextGroups","excludeText","useText","groups","sort","cardinality","WeakMap","group","votes","Map","winner","maxVotes","css","offset","cssSelectors","_votes$get","voteCount","ceil","satisfiedEmoji","_jsx","className","xmlns","viewBox","neutralEmoji","dissatisfiedEmoji","veryDissatisfiedEmoji","verySatisfiedEmoji","cancelSVG","_jsxs","fill","id","IconPosthogLogo","maskType","maskUnits","y","mask","transform","ProductTourTooltipInner","_appearance$whiteLabe","stepIndex","totalSteps","onNext","onPrevious","onDismiss","isLastStep","isFirstStep","showNextButton","progressionTrigger","isInteractive","cursorStyle","cursor","_Fragment","class","onClick","dangerouslySetInnerHTML","__html","href","rel","pointerEvents","threeScaleEmojis","fiveScaleEmojis","OpenTextInput","onChange","onSubmit","inputRef","useRef","useEffect","_inputRef$current","focus","ref","rows","placeholder","onInput","onKeyDown","key","metaKey","preventDefault","disabled","RatingInput","_ref2","survey","selectedRating","setSelectedRating","useState","scale","handleSelect","rating","emoji","lowerBoundLabel","upperBoundLabel","numbers","getScaleNumbers","gridTemplateColumns","num","ProductTourSurveyStepInner","_ref3","textValue","setTextValue","isOpenText","handleTextSubmit","questionText","getOppositePosition","top","bottom","left","right","TRANSITION_DURATION","ProductTourTooltip","tour","targetElement","onSurveySubmit","transitionState","setTransitionState","setPosition","spotlightStyle","setSpotlightStyle","displayedStep","setDisplayedStep","displayedStepIndex","setDisplayedStepIndex","previousStepRef","isTransitioningRef","isCentered","updatePosition","useCallback","targetRect","padding","viewportWidth","innerWidth","spaceBelow","innerHeight","spaceLeft","calculateTooltipPosition","currentStepIndex","isStepChange","finishEntering","enterStep","resolve","initialRect","viewportHeight","safeMarginY","safeMarginX","scrollIntoView","behavior","block","lastTop","stableCount","resolved","checkStability","currentRect","abs","scrollToElement","handleUpdate","removeEventListener","handleKeyDown","isVisible","isSurvey","isPositionReady","tooltipStyle","maxWidth","stopPropagation","transition","click","trunc","floor","Number","isInteger","isNumber","isFinite","crypto","getRandomValues","_localStorage_supported","localStore","_is_supported","supported","_set","_get","_remove","_unused5","_error","msg","name","localStorage","getItem","err","_parse","_unused6","setItem","stringify","removeItem","sessionStorageSupported","sessionStore","_unused9","sessionStorage","_unused0","TOUR_COMPLETED_KEY_PREFIX","TOUR_DISMISSED_KEY_PREFIX","ACTIVE_TOUR_SESSION_KEY","doesTourActivateByEvent","_tour$conditions","_tour$conditions$even","conditions","events","doesTourActivateByAction","_tour$conditions2","_tour$conditions$acti","actions","SimpleEventEmitter","_events","on","listener","emit","payload","matchString","matching","likePattern","ActionMatcher","instance","_debugEventEmitter","_checkStep","_checkStepEvent","_checkStepUrl","_checkStepElement","_checkStepProperties","_instance","_actionEvents","Set","_actionRegistry","init","_this$_instance","_addCaptureHook","_this$_instance2","matchEventToAction","eventName","eventPayload","register","_this$_instance3","_this$_instance4","action","_this$_actionRegistry","_action$steps","add","steps","_this$_actionEvents","autocapture","_this$_instance5","selectorsToWatch","_action$steps2","setElementSelectors","_this$_actionRegistry2","has","size","_checkAction","_addActionHook","onAction","data","cb","_event$properties","eventUrl","properties","$current_url","url_matching","_checkStepHref","_checkStepText","_checkStepSelector","_event$properties2","_getElementsList","href_matching","chain","$elements_chain","_event$properties3","text_matching","$el_text","texts","elementsChain","extractTexts","_event$properties4","_event$properties5","elementSelectors","$element_selectors","selector_regex","_event$properties6","$elements","EventReceiver","_eventToItems","_cancelEventToItems","_actionToItems","_doesEventMatchFilter","eventConfig","_buildEventToItemMap","items","conditionField","_item$conditions","existing","_getMatchingItems","itemIds","Activation","_getItems","allItems","_item$conditions2","find","_setupEventBasedItems","_setupActionBasedItems","actionBasedItems","_item$conditions3","_item$conditions4","_actionMatcher","actionName","_item$conditions5","_item$conditions6","_item$conditions7","_this$_actionMatcher","_item$conditions8","knownItems","eventBasedItems","_item$conditions9","_item$conditions0","itemsWithCancelEvents","_item$conditions1","_item$conditions10","cancelEvents","matchEventToItem","onEvent","Cancellation","_getLogger","activatedKey","_getActivatedKey","shownEventName","_getShownEventName","existingActivatedItems","persistence","_eventPayload$propert","_eventPayload$propert2","itemId","$survey_id","$product_tour_id","_updateActivatedItems","itemsToCancel","_cancelPendingItem","matchedItems","activatedItems","eligibleItems","_isItemPermanentlyIneligible","getActivatedIds","_this$_instance6","getEventToItemsMap","_getActionMatcher","ProductTourEventReceiver","super","productTours","getProductTours","cancelPendingTour","completedKey","dismissedKey","getTours","isTourInDateRange","now","Date","start_date","end_date","checkTourConditions","_window$location","matchType","urlMatchType","Icontains","Exact","doesTourUrlMatch","CONTAINER_CLASS","TRIGGER_LISTENER_ATTRIBUTE","retrieveTourShadow","containerClass","existingDiv","shadow","isNewlyCreated","mode","productTourStyles","setAttribute","getProductTourStylesheet","appendChild","body","ProductTourManager","_this","_activeTour","_currentStepIndex","_isPreviewMode","_isResuming","_checkInterval","_triggerSelectorListeners","_pendingTourTimeouts","_registeredEventTourIds","_handleVisibilityChange","hidden","clearInterval","setInterval","_evaluateAndDisplayTours","nextStep","currentStep","_captureEvent","$product_tour_step_id","$product_tour_step_order","_setStepIndex","_renderCurrentStep","_completeTour","previousStep","dismissTour","reason","$product_tour_dismiss_reason","dispatchEvent","CustomEvent","detail","tourId","_cleanup","_eventReceiver","_saveSessionState","_clearSessionState","_getSessionState","stored","start","savedState","_resumeSavedTour","_startEvaluationLoop","onComplete","_this$_instance$produ","tours","stop","_removeAllTriggerListeners","_cancelAllPendingTours","_this$_instance$produ2","getElementById","activeTriggerTourIds","unregisteredEventTours","eventActivatedTourIds","triggerSelector","_manageTriggerSelectorListener","hasEventOrActionTriggers","auto_launch","_isTourEligible","_showOrQueueTour","_removeTriggerSelectorListener","delaySeconds","autoShowDelaySeconds","isTourPending","queueTourWithDelay","showTour","_this$_instance$featu","internal_targeting_flag_key","featureFlags","getFeatureFlag","_options$reason","renderReason","selectorFailures","result","stepId","failure","$product_tour_step_selector","$product_tour_error","$product_tour_matches_count","$product_tour_failure_phase","failedSelectors","enableStrictValidation","$product_tour_name","$product_tour_iteration","current_iteration","$product_tour_render_reason","showTourById","_this$_instance$produ3","previewTour","$product_tour_steps_count","$set","retryCount","$product_tour_step_type","_renderTooltipWithPreact","inferenceElement","inferenceProps","inferenceData","$inference_data_present","$inference_found","$inference_matches_selector","shouldWaitForElement","waitDurationMs","$product_tour_waited_for_element","$product_tour_wait_duration_ms","metadata","tag","tagName","classes","getElementMetadata","$product_tour_step_selector_found","$product_tour_step_element_tag","$product_tour_step_element_id","$product_tour_step_element_classes","$product_tour_step_element_text","_renderSurveyStep","onDismissOverride","render","_step$survey","_this$_instance$get_s","surveyId","linkedSurveyId","questionId","linkedSurveyQuestionId","$product_tour_linked_survey_id","SHOWN","SURVEY_ID","PRODUCT_TOUR_ID","sessionRecordingUrl","get_session_replay_url","response","_this$_instance$get_s2","responseKey","SENT","SURVEY_QUESTIONS","question","SURVEY_COMPLETED","_this$_instance$get_s3","DISMISSED","SURVEY_PARTIALLY_COMPLETED","container","remove","currentElement","existingListenerData","hasAttribute","removeAttribute","delete","getActiveProductTours","_this$_instance$produ4","context","isLoaded","activeTours","resetTour","resetAllTours","storage","keysToRemove","timeout","clear","timeoutId","generateProductTours","isEnabled","manager","__PosthogExtensions__","depth","parts","classList","unshift"],"mappings":"0BAoCA,IAAMA,EAAkE,oBAAXC,OAAyBA,YAASC,EAyNzFC,EAA8D,oBAAfC,WAA6BA,WAAaJ,EAG3E,oBAATK,OACLF,EAAeE,KAAOF,GAER,oBAATG,OACLH,EAAeG,KAAO,WAAa,GAOlC,IAAMC,EAAkB,MAANJ,OAAM,EAANA,EAAQI,UACpBC,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