posthog-js 1.231.1 → 1.231.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/main.js +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/src/extensions/surveys.d.ts +3 -0
- package/dist/surveys-preview.js +1 -1
- package/dist/surveys-preview.js.map +1 -1
- package/dist/surveys.js +1 -1
- package/dist/surveys.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/surveys.d.ts +3 -0
- package/lib/src/extensions/surveys.jsx +35 -19
- package/lib/src/extensions/surveys.jsx.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surveys-preview.js","sources":["../src/constants.ts","../src/posthog-surveys-types.ts","../node_modules/.pnpm/preact@10.19.3/node_modules/preact/dist/preact.module.js","../src/utils/globals.ts","../src/types.ts","../src/utils/type-utils.ts","../src/utils/logger.ts","../src/extensions/utils/stylesheet-loader.ts","../src/extensions/surveys/surveys-utils.tsx","../src/utils/index.ts","../src/utils/event-utils.ts","../src/utils/regex-utils.ts","../src/utils/simple-event-emitter.ts","../src/extensions/surveys/action-matcher.ts","../src/utils/survey-event-receiver.ts","../src/posthog-surveys.ts","../node_modules/.pnpm/preact@10.19.3/node_modules/preact/hooks/dist/hooks.module.js","../src/extensions/surveys/icons.tsx","../src/extensions/surveys/components/PostHogLogo.tsx","../src/extensions/surveys/components/BottomSection.tsx","../src/extensions/surveys/components/QuestionHeader.tsx","../src/extensions/surveys/components/ConfirmationMessage.tsx","../src/extensions/surveys/hooks/useContrastingTextColor.ts","../src/extensions/surveys/components/QuestionTypes.tsx","../src/extensions/surveys.tsx","../src/extensions/surveys-widget.ts"],"sourcesContent":["/*\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 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 WEB_VITALS_ENABLED_SERVER_SIDE = '$web_vitals_enabled_server_side'\nexport const DEAD_CLICKS_ENABLED_SERVER_SIDE = '$dead_clicks_enabled_server_side'\nexport const WEB_VITALS_ALLOWED_METRICS = '$web_vitals_allowed_metrics'\nexport const SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side'\nexport const CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = '$console_log_recording_enabled_server_side'\nexport const SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE = '$session_recording_network_payload_capture'\nexport const SESSION_RECORDING_MASKING = '$session_recording_masking'\nexport const SESSION_RECORDING_CANVAS_RECORDING = '$session_recording_canvas_recording'\nexport const SESSION_RECORDING_SAMPLE_RATE = '$replay_sample_rate'\nexport const SESSION_RECORDING_MINIMUM_DURATION = '$replay_minimum_duration'\nexport const SESSION_RECORDING_SCRIPT_CONFIG = '$replay_script_config'\nexport const SESSION_ID = '$sesid'\nexport const SESSION_RECORDING_IS_SAMPLED = '$session_is_sampled'\nexport const SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION = '$session_recording_url_trigger_activated_session'\nexport const SESSION_RECORDING_URL_TRIGGER_STATUS = '$session_recording_url_trigger_status'\nexport const SESSION_RECORDING_EVENT_TRIGGER_ACTIVATED_SESSION = '$session_recording_event_trigger_activated_session'\nexport const SESSION_RECORDING_EVENT_TRIGGER_STATUS = '$session_recording_event_trigger_status'\nexport const ENABLED_FEATURE_FLAGS = '$enabled_feature_flags'\nexport const PERSISTENCE_EARLY_ACCESS_FEATURES = '$early_access_features'\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 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 USER_STATE,\n PERSISTENCE_EARLY_ACCESS_FEATURES,\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]\n\nexport const SURVEYS_REQUEST_TIMEOUT_MS = 10000\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\nexport interface SurveyAppearance {\n // keep in sync with frontend/src/types.ts -> SurveyAppearance\n backgroundColor?: string\n submitButtonColor?: string\n // text color is deprecated, use auto contrast text color instead\n textColor?: string\n // deprecate submit button text eventually\n submitButtonText?: string\n submitButtonTextColor?: string\n descriptionTextColor?: string\n ratingButtonColor?: string\n ratingButtonActiveColor?: string\n ratingButtonHoverColor?: string\n whiteLabel?: boolean\n autoDisappear?: boolean\n displayThankYouMessage?: boolean\n thankYouMessageHeader?: string\n thankYouMessageDescription?: string\n thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType\n thankYouMessageCloseButtonText?: string\n borderColor?: string\n position?: 'left' | 'right' | 'center'\n placeholder?: string\n shuffleQuestions?: boolean\n surveyPopupDelaySeconds?: number\n // widget options\n widgetType?: 'button' | 'tab' | 'selector'\n widgetSelector?: string\n widgetLabel?: string\n widgetColor?: string\n fontFamily?: string\n // questionable: Not in frontend/src/types.ts -> SurveyAppearance, but used in site app\n maxWidth?: string\n zIndex?: string\n disabledButtonOpacity?: string\n}\n\nexport enum SurveyType {\n Popover = 'popover',\n API = 'api',\n Widget = 'widget',\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}\n\nexport interface MultipleSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice\n choices: string[]\n hasOpenChoice?: boolean\n shuffleOptions?: 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 interface SurveyResponse {\n surveys: Survey[]\n}\n\nexport type SurveyCallback = (surveys: Survey[]) => void\n\nexport type SurveyMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains'\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 linked_flag_key: string | null\n targeting_flag_key: string | null\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?: SurveyMatchType\n events: {\n repeatedActivation?: boolean\n values: {\n name: string\n }[]\n } | null\n actions: {\n values: SurveyActionType[]\n } | null\n deviceTypes?: string[]\n deviceTypesMatchType?: SurveyMatchType\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}\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 /** @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}\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","import { ErrorProperties } from '../extensions/exception-autocapture/error-conversion'\nimport type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ErrorConversionArgs,\n ErrorMetadata,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n} from '../types'\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 Record<string, any> & {\n __PosthogExtensions__?: PostHogExtensions\n\n _POSTHOG_REMOTE_CONFIG?: Record<\n string,\n {\n config: RemoteConfig\n siteApps: SiteAppLoader[]\n }\n >\n }\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 PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\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 parseErrorAsProperties?: ({ error, event }: ErrorConversionArgs, metadata?: ErrorMetadata) => ErrorProperties\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: Properties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: Properties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n canActivateRepeatedly?: (survey: any) => boolean\n generateSurveys?: (posthog: PostHog) => 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: (sessionManager?: SessionIdManager) => () => void\n _patchXHR: (sessionManager?: SessionIdManager) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\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","import type { recordOptions } from './extensions/replay/types/rrweb'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\nimport { PostHog } from './posthog-core'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'\n\nexport const 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] as const\n\n/**\n * These events can be processed by the `beforeCapture` function\n * but can cause unexpected confusion in data.\n *\n * Some features of PostHog rely on receiving 100% of these events\n */\nexport type KnownUnsafeEditableEvent = (typeof knownUnsafeEditableEvent)[number]\n\n/**\n * These are known events PostHog events that can be processed by the `beforeCapture` function\n * That means PostHog functionality does not rely on receiving 100% of these for calculations\n * So, it is safe to sample them to reduce the volume of events sent to PostHog\n */\nexport type KnownEventName =\n | '$heatmaps_data'\n | '$opt_in'\n | '$exception'\n | '$$heatmap'\n | '$web_vitals'\n | '$dead_click'\n | '$autocapture'\n | typeof COPY_AUTOCAPTURE_EVENT\n | '$rageclick'\n\nexport type EventName =\n | KnownUnsafeEditableEvent\n | KnownEventName\n // magic value so that the type of EventName is a set of known strings or any other string\n // which means you get autocomplete for known strings\n // but no type complaints when you add an arbitrary string\n | (string & {})\n\nexport interface CaptureResult {\n uuid: string\n event: EventName\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on specific pages only\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_allowlist?: (string | RegExp)[]\n\n /**\n * List of URLs to not allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on most pages but not some specific ones\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_ignorelist?: (string | RegExp)[]\n\n /**\n * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']\n */\n dom_event_allowlist?: DomAutocaptureEvents[]\n\n /**\n * List of DOM elements to allow autocapture on\n * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']\n *\n * We consider the tree of elements from the root to the target element of the click event\n * so for the tree `div > div > button > svg`\n * if the allowlist has `button` then we allow the capture when the `button` or the `svg` is the click target\n * but not if either of the `div`s are detected as the click target\n */\n element_allowlist?: AutocaptureCompatibleElement[]\n\n /**\n * List of CSS selectors to allow autocapture on\n * e.g. ['[ph-capture]']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * and allow list config `['[id]']`\n * we will capture the click if the click-target or its parents has any id\n *\n * Everything is allowed when there's no allowlist\n */\n css_selector_allowlist?: string[]\n\n /**\n * Exclude certain element attributes from autocapture\n * E.g. ['aria-label'] or [data-attr-pii]\n */\n element_attribute_ignorelist?: string[]\n\n /**\n * When set to true, autocapture will capture the text of any element that is cut or copied.\n */\n capture_copied_text?: boolean\n}\n\nexport interface BootstrapConfig {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n\n /**\n * Optionally provide a sessionID, this is so that you can provide an existing sessionID here to continue a user's session across a domain or device. It MUST be:\n * - unique to this user\n * - a valid UUID v7\n * - the timestamp part must be <= the timestamp of the first event in the session\n * - the timestamp of the last event in the session must be < the timestamp part + 24 hours\n * **/\n sessionID?: string\n}\n\nexport type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP'\n\nexport interface PerformanceCaptureConfig {\n /**\n * Works with session replay to use the browser's native performance observer to capture performance metrics\n */\n network_timing?: boolean\n\n /**\n * Use chrome's web vitals library to wrap fetch and capture web vitals\n */\n web_vitals?: boolean\n\n /**\n * We observe very large values reported by the Chrome web vitals library\n * These outliers are likely not real, useful values, and we exclude them\n * You can set this to 0 in order to include all values, NB this is not recommended\n *\n * @default 15 * 60 * 1000 (15 minutes)\n */\n __web_vitals_max_value?: number\n\n /**\n * By default all 4 metrics are captured\n * You can set this config to restrict which metrics are captured\n * e.g. ['CLS', 'FCP'] to only capture those two metrics\n * NB setting this does not override whether the capture is enabled\n *\n * @default ['LCP', 'CLS', 'FCP', 'INP']\n */\n web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[]\n\n /**\n * We delay flushing web vitals metrics to reduce the number of events we send\n * This is the maximum time we will wait before sending the metrics\n *\n * @default 5000\n */\n web_vitals_delayed_flush_ms?: number\n}\n\nexport interface DeadClickCandidate {\n node: Element\n originalEvent: MouseEvent\n timestamp: number\n // time between click and the most recent scroll\n scrollDelayMs?: number\n // time between click and the most recent mutation\n mutationDelayMs?: number\n // time between click and the most recent selection changed event\n selectionChangedDelayMs?: number\n // if neither scroll nor mutation seen before threshold passed\n absoluteDelayMs?: number\n}\n\nexport type DeadClicksAutoCaptureConfig = {\n /**\n * We'll not consider a click to be a dead click, if it's followed by a scroll within `scroll_threshold_ms` milliseconds\n *\n * @default 100\n */\n scroll_threshold_ms?: number\n\n /**\n * We'll not consider a click to be a dead click, if it's followed by a selection change within `selection_change_threshold_ms` milliseconds\n *\n * @default 100\n */\n selection_change_threshold_ms?: number\n\n /**\n * We'll not consider a click to be a dead click, if it's followed by a mutation within `mutation_threshold_ms` milliseconds\n *\n * @default 2500\n */\n mutation_threshold_ms?: number\n\n /**\n * Allows setting behavior for when a dead click is captured.\n * For e.g. to support capture to heatmaps\n *\n * If not provided the default behavior is to auto-capture dead click events\n *\n * Only intended to be provided by our own SDK\n */\n __onCapture?: ((click: DeadClickCandidate, properties: Properties) => void) | undefined\n} & Pick<AutocaptureConfig, 'element_attribute_ignorelist'>\n\nexport interface HeatmapConfig {\n /**\n * How often to send batched data in `$heatmap_data` events\n * If set to 0 or not set, sends using the default interval of 1 second\n *\n * @default 1000\n */\n flush_interval_milliseconds: number\n}\n\nexport type BeforeSendFn = (cr: CaptureResult | null) => CaptureResult | null\n\n/**\n * Configuration options for the PostHog JavaScript SDK.\n * @see https://posthog.com/docs/libraries/js#config\n */\nexport interface PostHogConfig {\n /** URL of your PostHog instance.\n *\n * @default 'https://us.i.posthog.com'\n */\n api_host: string\n\n /**\n * If using a reverse proxy for `api_host` then this should be the actual PostHog app URL (e.g. https://us.posthog.com).\n * This ensures that links to PostHog point to the correct host.\n *\n * @default null\n */\n ui_host: string | null\n\n /**\n * The transport method to use for API requests.\n *\n * @default 'fetch'\n */\n api_transport?: 'XHR' | 'fetch'\n\n /**\n * The token for your PostHog project.\n * It should NOT be provided manually in the config, but rather passed as the first parameter to `posthog.init()`.\n */\n token: string\n\n /**\n * The name this instance will be identified by.\n * You don't need to set this most of the time,\n * but can be useful if you have several Posthog instances running at the same time.\n *\n * @default 'posthog'\n */\n name: string\n\n /**\n * Determines whether PostHog should autocapture events.\n * This setting does not affect capturing pageview events (see `capture_pageview`).\n *\n * @default true\n */\n autocapture: boolean | AutocaptureConfig\n\n /**\n * Determines whether PostHog should capture rage clicks.\n *\n * @default true\n */\n rageclick: boolean\n\n /**\n * Determines if cookie should be set on the top level domain (example.com).\n * If PostHog-js is loaded on a subdomain (test.example.com), and `cross_subdomain_cookie` is set to false,\n * it'll set the cookie on the subdomain only (test.example.com).\n *\n * NOTE: It will be set to `false` if we detect that the domain is a subdomain of a platform that is excluded from cross-subdomain cookie setting.\n * The current list of excluded platforms is `herokuapp.com`, `vercel.app`, and `netlify.app`.\n *\n * @see `isCrossDomainCookie`\n * @default true\n */\n cross_subdomain_cookie: boolean\n\n /**\n * Determines how PostHog stores information about the user. See [persistence](https://posthog.com/docs/libraries/js#persistence) for details.\n *\n * @default 'localStorage+cookie'\n */\n persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage'\n\n /**\n * The name for the super properties persistent store\n *\n * @default ''\n */\n persistence_name: string\n\n /** @deprecated - Use 'persistence_name' instead */\n cookie_name?: string\n\n /**\n * A function to be called once the PostHog scripts have loaded successfully.\n *\n * @param posthog_instance - The PostHog instance that has been loaded.\n */\n loaded: (posthog_instance: PostHog) => void\n\n /**\n * Determines whether PostHog should save referrer information.\n *\n * @default true\n */\n save_referrer: boolean\n\n /**\n * Determines whether PostHog should save marketing parameters.\n * These are `utm_*` paramaters and friends.\n *\n * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.\n * @default true\n */\n save_campaign_params: boolean\n\n /** @deprecated - Use `save_campaign_params` instead */\n store_google?: boolean\n\n /**\n * Used to extend the list of campaign parameters that are saved by default.\n *\n * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.\n * @default []\n */\n custom_campaign_params: string[]\n\n /**\n * Used to extend the list of user agents that are blocked by default.\n *\n * @see {DEFAULT_BLOCKED_UA_STRS} from './utils/blocked-uas' - Default list of blocked user agents.\n * @default []\n */\n custom_blocked_useragents: string[]\n\n /**\n * Determines whether PostHog should be in debug mode.\n * You can enable this to get more detailed logging.\n *\n * You can also enable this on your website by appending `?__posthog_debug=true` at the end of your URL\n * You can also call `posthog.debug()` in your code to enable debug mode\n *\n * @default false\n */\n debug: boolean\n\n /** @deprecated Use `debug` instead */\n verbose?: boolean\n\n /**\n * Determines whether PostHog should capture pageview events automatically.\n *\n * @default true\n */\n capture_pageview: boolean\n\n /**\n * Determines whether PostHog should capture pageleave events.\n * If set to `true`, it will capture pageleave events for all pages.\n * If set to `'if_capture_pageview'`, it will only capture pageleave events if `capture_pageview` is also set to `true`.\n *\n * @default 'if_capture_pageview'\n */\n capture_pageleave: boolean | 'if_capture_pageview'\n\n /**\n * Determines the number of days to store cookies for.\n *\n * @default 365\n */\n cookie_expiration: number\n\n /**\n * Determines whether PostHog should upgrade old cookies.\n * If set to `true`, the library will check for a cookie from our old js library and import super properties from it, then the old cookie is deleted.\n * This option only works in the initialization, so make sure you set it when you create the library.\n *\n * @default false\n */\n upgrade: boolean\n\n /**\n * Determines whether PostHog should disable session recording.\n *\n * @default false\n */\n disable_session_recording: boolean\n\n /**\n * Determines whether PostHog should disable persistence.\n * If set to `true`, the library will not save any data to the browser. It will also delete any data previously saved to the browser.\n *\n * @default false\n */\n disable_persistence: boolean\n\n /** @deprecated - use `disable_persistence` instead */\n disable_cookie?: boolean\n\n /**\n * Determines whether PostHog should disable surveys.\n *\n * @default false\n */\n disable_surveys: boolean\n\n /**\n * Determines whether PostHog should disable web experiments.\n *\n * Currently disabled while we're in BETA. It will be toggled to `true` in a future release.\n *\n * @default true\n */\n disable_web_experiments: boolean\n\n /**\n * Determines whether PostHog should disable any external dependency loading.\n * This will prevent PostHog from requesting any external scripts such as those needed for Session Replay, Surveys or Site Apps.\n *\n * @default false\n */\n disable_external_dependency_loading: boolean\n\n /**\n * A function to be called when a script is being loaded.\n * This can be used to modify the script before it is loaded.\n * This is useful for adding a nonce to the script, for example.\n *\n * @param script - The script element that is being loaded.\n * @returns The modified script element, or null if the script should not be loaded.\n */\n prepare_external_dependency_script?: (script: HTMLScriptElement) => HTMLScriptElement | null\n\n /**\n * A function to be called when a stylesheet is being loaded.\n * This can be used to modify the stylesheet before it is loaded.\n * This is useful for adding a nonce to the stylesheet, for example.\n *\n * @param stylesheet - The stylesheet element that is being loaded.\n * @returns The modified stylesheet element, or null if the stylesheet should not be loaded.\n */\n prepare_external_dependency_stylesheet?: (stylesheet: HTMLStyleElement) => HTMLStyleElement | null\n\n /**\n * Determines whether PostHog should enable recording console logs.\n * When undefined, it falls back to the remote config setting.\n *\n * @default undefined\n */\n enable_recording_console_log?: boolean\n\n /**\n * Determines whether PostHog should use secure cookies.\n * If this is `true`, PostHog cookies will be marked as secure,\n * meaning they will only be transmitted over HTTPS.\n *\n * @default window.location.protocol === 'https:'\n */\n secure_cookie: boolean\n\n /**\n * Determines whether PostHog should capture IP addresses.\n *\n * @default true\n */\n ip: boolean\n\n /**\n * Determines if users should be opted out of PostHog tracking by default,\n * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.\n *\n * @default false\n */\n opt_out_capturing_by_default: boolean\n\n /**\n * Determines where we'll save the information about whether users are opted out of capturing.\n *\n * @default 'localStorage'\n */\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n\n /**\n * Determines if users should be opted out of browser data storage by this PostHog instance by default,\n * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.\n *\n * @default false\n */\n opt_out_persistence_by_default?: boolean\n\n /**\n * Determines if users should be opted out of user agent filtering such as googlebot or other bots.\n * If this is set to `true`, PostHog will set `$browser_type` to either `bot` or `browser` for all events,\n * but will process all events as if they were from a browser.\n *\n * @default false\n */\n opt_out_useragent_filter: boolean\n\n /**\n * Determines the prefix for the cookie used to store the information about whether users are opted out of capturing.\n * When `null`, it falls back to the default prefix found in `consent.ts`.\n *\n * @default null\n */\n opt_out_capturing_cookie_prefix: string | null\n\n /**\n * Determines if users should be opted in to site apps.\n *\n * @default false\n */\n opt_in_site_apps: boolean\n\n /**\n * Determines whether PostHog should respect the Do Not Track header when computing\n * consent in `ConsentManager`.\n *\n * @see `ConsentManager`\n * @default false\n */\n respect_dnt: boolean\n\n /**\n * A list of properties that should never be sent with capture calls.\n *\n * @default []\n */\n property_denylist: string[]\n\n /** @deprecated - use `property_denylist` instead */\n property_blacklist?: string[]\n\n /**\n * A list of headers that should be sent with requests to the PostHog API.\n *\n * @default {}\n */\n request_headers: { [header_name: string]: string }\n\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n\n /**\n * A function that is called when a request to the PostHog API fails.\n *\n * @param error - The `RequestResponse` object that occurred.\n */\n on_request_error?: (error: RequestResponse) => void\n\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n\n /**\n * Determines whether PostHog should batch requests to the PostHog API.\n *\n * @default true\n */\n request_batching: boolean\n\n /**\n * Determines the maximum length of the properties string that can be sent with capture calls.\n *\n * @default 65535\n */\n properties_string_max_length: number\n\n /**\n * Determines the session recording options.\n *\n * @see `SessionRecordingOptions`\n * @default {}\n */\n session_recording: SessionRecordingOptions\n\n /**\n * Determines the session idle timeout in seconds.\n * Any new event that's happened after this timeout will create a new session.\n *\n * @default 30 * 60 -- 30 minutes\n */\n session_idle_timeout_seconds: number\n\n /**\n * Prevent autocapture from capturing any attribute names on elements.\n *\n * @default false\n */\n mask_all_element_attributes: boolean\n\n /**\n * Prevent autocapture from capturing `textContent` on elements.\n *\n * @default false\n */\n mask_all_text: boolean\n\n /**\n * Prevent autocapture from capturing personal data properties.\n * These include campaign parameters, UTM parameters, and other parameters that could be considered personal data under e.g. GDPR.\n *\n * @default false\n */\n mask_personal_data_properties: boolean\n\n /**\n * Custom list of personal data properties to mask.\n *\n * @default []\n */\n custom_personal_data_properties: string[]\n\n /**\n * One of the very first things the PostHog library does when init() is called\n * is make a request to the /decide endpoint on PostHog's backend.\n * This endpoint contains information on how to run the PostHog library\n * so events are properly received in the backend.\n *\n * This endpoint is required to run most features of the library.\n * However, if you're not using any of the described features,\n * you may wish to turn off the call completely to avoid an extra request\n * and reduce resource usage on both the client and the server.\n *\n * @default false\n */\n advanced_disable_decide: boolean\n\n /**\n * Will keep /decide running, but without any feature flag requests\n *\n * @default false\n */\n advanced_disable_feature_flags: boolean\n\n /**\n * Stops from firing feature flag requests on first page load.\n * Only requests feature flags when user identity or properties are updated,\n * or you manually request for flags to be loaded.\n *\n * @default false\n */\n advanced_disable_feature_flags_on_first_load: boolean\n\n /**\n * Determines whether PostHog should disable toolbar metrics.\n * This is our internal instrumentation for our toolbar in your website.\n *\n * @default false\n */\n advanced_disable_toolbar_metrics: boolean\n\n /**\n * Sets timeout for fetching feature flags\n *\n * @default 3000\n */\n feature_flag_request_timeout_ms: number\n\n /**\n * Sets timeout for fetching surveys\n *\n * @default 10000\n */\n surveys_request_timeout_ms: number\n\n /**\n * Function to get the device ID.\n * This doesn't usually need to be set, but can be useful if you want to use a custom device ID.\n *\n * @param uuid - The UUID we would use for the device ID.\n * @returns The device ID.\n *\n * @default (uuid) => uuid\n */\n get_device_id: (uuid: string) => string\n\n /**\n * This function or array of functions - if provided - are called immediately before sending data to the server.\n * It allows you to edit data before it is sent, or choose not to send it all.\n * if provided as an array the functions are called in the order they are provided\n * any one function returning null means the event will not be sent\n */\n before_send?: BeforeSendFn | BeforeSendFn[]\n\n /** @deprecated - use `before_send` instead */\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n\n /** @deprecated - use `before_send` instead */\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n\n /**\n * Determines whether to capture performance metrics.\n * These include Network Timing and Web Vitals.\n *\n * When `undefined`, fallback to the remote configuration.\n * If `false`, neither network timing nor web vitals will work.\n * If an object, that will override the remote configuration.\n *\n * @see {PerformanceCaptureConfig}\n * @default undefined\n */\n capture_performance?: boolean | PerformanceCaptureConfig\n\n /**\n * Determines whether to disable compression when sending events to the server.\n * WARNING: Should only be used for testing. Could negatively impact performance.\n *\n * @default false\n */\n disable_compression: boolean\n\n /**\n * An object containing the `distinctID`, `isIdentifiedID`, and `featureFlags` keys,\n * where `distinctID` is a string, and `featureFlags` is an object of key-value pairs.\n *\n * Since there is a delay between initializing PostHog and fetching feature flags,\n * feature flags are not always available immediately.\n * This makes them unusable if you want to do something like redirecting a user\n * to a different page based on a feature flag.\n *\n * You can, therefore, fetch the feature flags in your server and pre-fill them here,\n * allowing PostHog to know the feature flag values immediately.\n *\n * After the SDK fetches feature flags from PostHog, it will use those flag values instead of bootstrapped ones.\n *\n * @default {}\n */\n bootstrap: BootstrapConfig\n\n /**\n * The segment analytics object.\n *\n * @see https://posthog.com/docs/libraries/segment\n */\n segment?: SegmentAnalytics\n\n /**\n * Determines whether to capture heatmaps.\n *\n * @see {HeatmapConfig}\n * @default undefined\n */\n capture_heatmaps?: boolean | HeatmapConfig\n\n /* @deprecated - use `capture_heatmaps` instead */\n enable_heatmaps?: boolean\n\n /**\n * Determines whether to capture dead clicks.\n *\n * @see {DeadClicksAutoCaptureConfig}\n * @default undefined\n */\n capture_dead_clicks?: boolean | DeadClicksAutoCaptureConfig\n\n /**\n * Determines whether to capture exceptions.\n *\n * @default undefined\n */\n capture_exceptions?: boolean\n\n /**\n * Determines whether to disable scroll properties.\n * These allow you to keep track of how far down someone scrolled in your website.\n *\n * @default false\n */\n disable_scroll_properties?: boolean\n\n /**\n * Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`\n * It will use `window.document.documentElement` if not specified.\n */\n scroll_root_selector?: string | string[]\n\n /**\n * You can control whether events from PostHog-js have person processing enabled with the `person_profiles` config setting.\n * There are three options:\n * - `person_profiles: 'always'` - we will process persons data for all events\n * - `person_profiles: 'never'` - we won't process persons for any event. This means that anonymous users will not be merged once they sign up or login, so you lose the ability to create funnels that track users from anonymous to identified. All events (including `$identify`) will be sent with `$process_person_profile: False`.\n * - `person_profiles: 'identified_only'` _(default)_ - we will only process persons when you call `posthog.identify`, `posthog.alias`, `posthog.setPersonProperties`, `posthog.group`, `posthog.setPersonPropertiesForFlags` or `posthog.setGroupPropertiesForFlags` Anonymous users won't get person profiles.\n *\n * @default 'identified_only'\n */\n person_profiles?: 'always' | 'never' | 'identified_only'\n\n /** @deprecated - use `person_profiles` instead */\n process_person?: 'always' | 'never' | 'identified_only'\n\n /**\n * Client side rate limiting\n */\n rate_limiting?: {\n /**\n * The average number of events per second that should be permitted\n *\n * @default 10\n */\n events_per_second?: number\n\n /**\n * How many events can be captured in a burst. This defaults to 10 times the events_per_second count\n *\n * @default 10 * `events_per_second`\n */\n events_burst_limit?: number\n }\n\n /**\n * Used when sending data via `fetch`, use with care.\n * This is intentionally meant to be used with NextJS `fetch`\n *\n * Incorrect `cache` usage may cause out-of-date data for feature flags, actions tracking, etc.\n * See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\n */\n fetch_options?: {\n cache?: RequestInit['cache']\n next_options?: NextOptions\n }\n\n /**\n * Used to change the behavior of the request queue.\n * This is an advanced feature and should be used with caution.\n */\n request_queue_config?: RequestQueueConfig\n\n // ------- PREVIEW CONFIGS -------\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Whether to wrap fetch and add tracing headers to the request\n * */\n __add_tracing_headers?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Enables the new RemoteConfig approach to loading config instead of decide\n * */\n __preview_remote_config?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Whether to send a sentinel value for distinct id, device id, and session id, which will be replaced server-side by a cookieless hash\n * */\n __preview_experimental_cookieless_mode?: boolean\n\n // ------- RETIRED CONFIGS - NO REPLACEMENT OR USAGE -------\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n api_method?: string\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n inapp_protocol?: string\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n inapp_link_new_window?: boolean\n}\n\nexport interface SessionRecordingOptions {\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-no-capture'\n */\n blockClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default null\n */\n blockSelector?: string | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-ignore-input'\n */\n ignoreClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-mask'\n */\n maskTextClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskTextSelector?: string | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskTextFn?: ((text: string, element?: HTMLElement) => string) | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskAllInputs?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskInputOptions?: recordOptions['maskInputOptions']\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default {}\n */\n slimDOMOptions?: recordOptions['slimDOMOptions']\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n collectFonts?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default true\n */\n inlineStylesheet?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordCrossOriginIframes?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordHeaders?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordBody?: boolean\n\n /**\n * Allows local config to override remote canvas recording settings from the decide response\n */\n captureCanvas?: SessionRecordingCanvasOptions\n\n /**\n * Modify the network request before it is captured. Returning null or undefined stops it being captured\n */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n\n /**\n * ADVANCED: while a user is active we take a full snapshot of the browser every interval.\n * For very few sites playback performance might be better with different interval.\n * Set to 0 to disable\n *\n * @default 1000 * 60 * 5 (5 minutes)\n */\n full_snapshot_interval_millis?: number\n\n /**\n * ADVANCED: whether to partially compress rrweb events before sending them to the server,\n * defaults to true, can be set to false to disable partial compression\n * NB requests are still compressed when sent to the server regardless of this setting\n *\n * @default true\n */\n compress_events?: boolean\n\n /**\n * ADVANCED: alters the threshold before a recording considers a user has become idle.\n * Normally only altered alongside changes to session_idle_timeout_ms.\n *\n * @default 1000 * 60 * 5 (5 minutes)\n */\n session_idle_threshold_ms?: number\n\n /**\n * ADVANCED: alters the refill rate for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 10\n */\n __mutationRateLimiterRefillRate?: number\n\n /**\n * ADVANCED: alters the bucket size for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 100\n */\n __mutationRateLimiterBucketSize?: number\n}\n\nexport type SessionIdChangedCallback = (\n sessionId: string,\n windowId: string | null | undefined,\n changeReason?: { noSessionId: boolean; activityTimeout: boolean; sessionPastMaximumLength: boolean }\n) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\n// See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\ntype NextOptions = { revalidate: false | 0 | number; tags: string[] }\n\nexport interface RequestWithOptions {\n url: string\n // Data can be a single object or an array of objects when batched\n data?: Record<string, any> | Record<string, any>[]\n headers?: Record<string, any>\n transport?: 'XHR' | 'fetch' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n callback?: RequestCallback\n timeout?: number\n noRetries?: boolean\n compression?: Compression | 'best-available'\n fetchOptions?: {\n cache?: RequestInit['cache']\n next?: NextOptions\n }\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestWithOptions extends RequestWithOptions {\n /** key of queue, e.g. 'sessionRecording' vs 'event' */\n batchKey?: string\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestWithOptions extends QueuedRequestWithOptions {\n retriesPerformedSoFar?: number\n}\n\n// we used to call a request that was sent to the queue with options attached `RequestQueueOptions`\n// so we can't call the options used to configure the behavior of the RequestQueue that as well,\n// so instead we call them config\nexport interface RequestQueueConfig {\n /**\n * ADVANCED - alters the frequency which PostHog sends events to the server.\n * generally speaking this is only set when apps have automatic page refreshes, or very short visits.\n * Defaults to 3 seconds when not set\n * Allowed values between 250 and 5000\n * */\n flush_interval_ms?: number\n}\n\nexport interface CaptureOptions {\n /**\n * Used when `$identify` is called\n * Will set person properties overriding previous values\n */\n $set?: Properties\n\n /**\n * Used when `$identify` is called\n * Will set person properties but only once, it will NOT override previous values\n */\n $set_once?: Properties\n\n /**\n * Used to override the desired endpoint for the captured event\n */\n _url?: string\n\n /**\n * key of queue, e.g. 'sessionRecording' vs 'event'\n */\n _batchKey?: string\n\n /**\n * If set, overrides and disables config.properties_string_max_length\n */\n _noTruncate?: boolean\n\n /**\n * If set, skips the batched queue\n */\n send_instantly?: boolean\n\n /**\n * If set, skips the client side rate limiting\n */\n skip_client_rate_limiting?: boolean\n\n /**\n * If set, overrides the desired transport method\n */\n transport?: RequestWithOptions['transport']\n\n /**\n * If set, overrides the current timestamp\n */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport type SessionRecordingCanvasOptions = {\n /**\n * If set, records the canvas\n *\n * @default false\n */\n recordCanvas?: boolean | null\n\n /**\n * If set, records the canvas at the given FPS\n * Can be set in the remote configuration\n * Limited between 0 and 12\n * When canvas recording is enabled, if this is not set locally, then remote config sets this as 4\n *\n * @default null-ish\n */\n canvasFps?: number | null\n\n /**\n * If set, records the canvas at the given quality\n * Can be set in the remote configuration\n * Must be a string that is a valid decimal between 0 and 1\n * When canvas recording is enabled, if this is not set locally, then remote config sets this as \"0.4\"\n *\n * @default null-ish\n */\n canvasQuality?: string | null\n}\n\n/**\n * Remote configuration for the PostHog instance\n *\n * All of these settings can be configured directly in your PostHog instance\n * Any configuration set in the client overrides the information from the server\n */\nexport interface RemoteConfig {\n /**\n * Supported compression algorithms\n */\n supportedCompression: Compression[]\n\n /**\n * If set, disables autocapture\n */\n autocapture_opt_out?: boolean\n\n /**\n * originally capturePerformance was replay only and so boolean true\n * is equivalent to { network_timing: true }\n * now capture performance can be separately enabled within replay\n * and as a standalone web vitals tracker\n * people can have them enabled separately\n * they work standalone but enhance each other\n * TODO: deprecate this so we make a new config that doesn't need this explanation\n */\n capturePerformance?: boolean | PerformanceCaptureConfig\n\n /**\n * Whether we should use a custom endpoint for analytics\n *\n * @default { endpoint: \"/e\" }\n */\n analytics?: {\n endpoint?: string\n }\n\n /**\n * Whether the `$elements_chain` property should be sent as a string or as an array\n *\n * @default false\n */\n elementsChainAsString?: boolean\n\n /**\n * This is currently in development and may have breaking changes without a major version bump\n */\n autocaptureExceptions?: boolean | { endpoint?: string }\n\n /**\n * Session recording configuration options\n */\n sessionRecording?: SessionRecordingCanvasOptions & {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n masking?: Pick<SessionRecordingOptions, 'maskAllInputs' | 'maskTextSelector'>\n urlTriggers?: SessionRecordingUrlTrigger[]\n scriptConfig?: { script?: string | undefined }\n urlBlocklist?: SessionRecordingUrlTrigger[]\n eventTriggers?: string[]\n }\n\n /**\n * Whether surveys are enabled\n */\n surveys?: boolean\n\n /**\n * Parameters for the toolbar\n */\n toolbarParams: ToolbarParams\n\n /**\n * @deprecated renamed to toolbarParams, still present on older API responses\n */\n editorParams?: ToolbarParams\n\n /**\n * @deprecated, moved to toolbarParams\n */\n toolbarVersion: 'toolbar'\n\n /**\n * Whether the user is authenticated\n */\n isAuthenticated: boolean\n\n /**\n * List of site apps with their IDs and URLs\n */\n siteApps: { id: string; url: string }[]\n\n /**\n * Whether heatmaps are enabled\n */\n heatmaps?: boolean\n\n /**\n * Whether to only capture identified users by default\n */\n defaultIdentifiedOnly?: boolean\n\n /**\n * Whether to capture dead clicks\n */\n captureDeadClicks?: boolean\n\n /**\n * Indicates if the team has any flags enabled (if not we don't need to load them)\n */\n hasFeatureFlags?: boolean\n}\n\n/**\n * Decide returns everything we have on the remote config plus feature flags and their payloads\n */\nexport interface DecideResponse extends RemoteConfig {\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n requestId?: string\n}\n\nexport type SiteAppGlobals = {\n event: {\n uuid: string\n event: EventName\n properties: Properties\n timestamp?: Date\n elements_chain?: string\n distinct_id?: string\n }\n person: {\n properties: Properties\n }\n groups: Record<string, { id: string; type: string; properties: Properties }>\n}\n\nexport type SiteAppLoader = {\n id: string\n init: (config: { posthog: PostHog; callback: (success: boolean) => void }) => {\n processEvent?: (globals: SiteAppGlobals) => void\n }\n}\n\nexport type SiteApp = {\n id: string\n loaded: boolean\n errored: boolean\n processedBuffer: boolean\n processEvent?: (globals: SiteAppGlobals) => void\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => void\n\nexport type RemoteConfigFeatureFlagCallback = (payload: JsonType) => void\n\nexport interface PersistentStore {\n is_supported: () => boolean\n error: (error: any) => void\n parse: (name: string) => any\n get: (name: string) => any\n set: (\n name: string,\n value: any,\n expire_days?: number | null,\n cross_subdomain?: boolean,\n secure?: boolean,\n debug?: boolean\n ) => void\n remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonRecord = { [key: string]: JsonType }\nexport type JsonType = string | number | boolean | null | undefined | JsonRecord | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureStage = 'concept' | 'alpha' | 'beta' | 'general-availability'\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n /**\n * some domains we should never record the payload\n * for example other companies session replay ingestion payloads aren't super useful but are gigantic\n * if this isn't provided we use a default list\n * if this is provided - we add the provided list to the default list\n * i.e. we never record the payloads on the default deny list\n */\n payloadHostDenyList?: string[]\n}\n\n/** @deprecated - use CapturedNetworkRequest instead */\nexport type NetworkRequest = {\n url: string\n}\n\n// In rrweb this is called NetworkRequest, but we already exposed that as having only URL\n// we also want to vary from the rrweb NetworkRequest because we want to include\n// all PerformanceEntry properties too.\n// that has 4 required properties\n// readonly duration: DOMHighResTimeStamp;\n// readonly entryType: string;\n// readonly name: string;\n// readonly startTime: DOMHighResTimeStamp;\n// NB: properties below here are ALPHA, don't rely on them, they may change without notice\n\n// we mirror PerformanceEntry since we read into this type from a PerformanceObserver,\n// but we don't want to inherit its readonly-iness\ntype Writable<T> = { -readonly [P in keyof T]: T[P] }\n\nexport type CapturedNetworkRequest = Writable<Omit<PerformanceEntry, 'toJSON'>> & {\n // properties below here are ALPHA, don't rely on them, they may change without notice\n method?: string\n initiatorType?: InitiatorType\n status?: number\n timeOrigin?: number\n timestamp?: number\n startTime?: number\n endTime?: number\n requestHeaders?: Headers\n requestBody?: string | null\n responseHeaders?: Headers\n responseBody?: string | null\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\n\nexport type ErrorConversionArgs = {\n event: string | Event\n error?: Error\n}\n\nexport type ErrorEventArgs = [\n event: string | Event,\n source?: string | undefined,\n lineno?: number | undefined,\n colno?: number | undefined,\n error?: Error | undefined,\n]\n\nexport type ErrorMetadata = {\n handled?: boolean\n synthetic?: boolean\n syntheticException?: Error\n overrideExceptionType?: string\n overrideExceptionMessage?: string\n defaultExceptionType?: string\n defaultExceptionMessage?: string\n}\n\n// levels originally copied from Sentry to work with the sentry integration\n// and to avoid relying on a frequently changing @sentry/types dependency\n// but provided as an array of literal types, so we can constrain the level below\nexport const severityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug'] as const\nexport declare type SeverityLevel = (typeof severityLevels)[number]\n\nexport interface ErrorProperties {\n $exception_type: string\n $exception_message: string\n $exception_level: SeverityLevel\n $exception_source?: string\n $exception_lineno?: number\n $exception_colno?: number\n $exception_DOMException_code?: string\n $exception_is_synthetic?: boolean\n $exception_stack_trace_raw?: string\n $exception_handled?: boolean\n $exception_personURL?: string\n}\n\nexport interface ErrorConversions {\n errorToProperties: (args: ErrorEventArgs) => ErrorProperties\n unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties\n}\n\nexport interface SessionRecordingUrlTrigger {\n url: string\n matching: 'regex'\n}\n","import { window } from './globals'\nimport { knownUnsafeEditableEvent, KnownUnsafeEditableEvent } from '../types'\nimport { includes } from './string-utils'\n\n// eslint-disable-next-line posthog-js/no-direct-array-check\nconst nativeIsArray = Array.isArray\nconst ObjProto = Object.prototype\nexport const hasOwnProperty = ObjProto.hasOwnProperty\nconst toString = ObjProto.toString\n\nexport const isArray =\n nativeIsArray ||\n function (obj: any): obj is any[] {\n return toString.call(obj) === '[object Array]'\n }\n\n// from a comment on http://dbj.org/dbj/?p=286\n// fails on only one very rare and deliberate custom object:\n// let bomb = { toString : undefined, valueOf: function(o) { return \"function BOMBA!\"; }};\nexport const isFunction = (x: unknown): x is (...args: any[]) => any => {\n // eslint-disable-next-line posthog-js/no-direct-function-check\n return typeof x === 'function'\n}\n\nexport const isNativeFunction = (x: unknown): x is (...args: any[]) => any =>\n isFunction(x) && x.toString().indexOf('[native code]') !== -1\n\n// When angular patches functions they pass the above `isNativeFunction` check (at least the MutationObserver)\nexport const isAngularZonePresent = (): boolean => {\n return !!(window as any).Zone\n}\n\n// Underscore Addons\nexport const isObject = (x: unknown): x is Record<string, any> => {\n // eslint-disable-next-line posthog-js/no-direct-object-check\n return x === Object(x) && !isArray(x)\n}\nexport const isEmptyObject = (x: unknown) => {\n if (isObject(x)) {\n for (const key in x) {\n if (hasOwnProperty.call(x, key)) {\n return false\n }\n }\n return true\n }\n return false\n}\nexport const isUndefined = (x: unknown): x is undefined => x === void 0\n\nexport const isString = (x: unknown): x is string => {\n // eslint-disable-next-line posthog-js/no-direct-string-check\n return toString.call(x) == '[object String]'\n}\n\nexport const isEmptyString = (x: unknown): boolean => isString(x) && x.trim().length === 0\n\nexport const isNull = (x: unknown): x is null => {\n // eslint-disable-next-line posthog-js/no-direct-null-check\n return x === null\n}\n\n/*\n sometimes you want to check if something is null or undefined\n that's what this is for\n */\nexport const isNullish = (x: unknown): x is null | undefined => isUndefined(x) || isNull(x)\n\nexport const isNumber = (x: unknown): x is number => {\n // eslint-disable-next-line posthog-js/no-direct-number-check\n return toString.call(x) == '[object Number]'\n}\nexport const isBoolean = (x: unknown): x is boolean => {\n // eslint-disable-next-line posthog-js/no-direct-boolean-check\n return toString.call(x) === '[object Boolean]'\n}\n\nexport const isDocument = (x: unknown): x is Document => {\n // eslint-disable-next-line posthog-js/no-direct-document-check\n return x instanceof Document\n}\n\nexport const isFormData = (x: unknown): x is FormData => {\n // eslint-disable-next-line posthog-js/no-direct-form-data-check\n return x instanceof FormData\n}\n\nexport const isFile = (x: unknown): x is File => {\n // eslint-disable-next-line posthog-js/no-direct-file-check\n return x instanceof File\n}\n\nexport const isError = (x: unknown): x is Error => {\n return x instanceof Error\n}\n\nexport const isKnownUnsafeEditableEvent = (x: unknown): x is KnownUnsafeEditableEvent => {\n return includes(knownUnsafeEditableEvent as unknown as string[], x)\n}\n","import Config from '../config'\nimport { isUndefined } from './type-utils'\nimport { assignableWindow, window } from './globals'\n\nexport type Logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => void\n info: (...args: any[]) => void\n warn: (...args: any[]) => void\n error: (...args: any[]) => void\n critical: (...args: any[]) => void\n uninitializedWarning: (methodName: string) => void\n createLogger: (prefix: string) => Logger\n}\n\nconst _createLogger = (prefix: string): Logger => {\n const logger: Logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG) &&\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) => _createLogger(`${prefix} ${additionalPrefix}`),\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 { VNode, cloneElement, createContext } from 'preact'\nimport { PostHog } from '../../posthog-core'\nimport {\n MultipleSurveyQuestion,\n Survey,\n SurveyAppearance,\n SurveyQuestion,\n SurveySchedule,\n SurveyType,\n} from '../../posthog-surveys-types'\nimport { document as _document, window as _window } from '../../utils/globals'\nimport { createLogger } from '../../utils/logger'\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\nconst SurveySeenPrefix = 'seenSurvey_'\n\nconst logger = createLogger('[Surveys]')\n\nexport const SURVEY_DEFAULT_Z_INDEX = 2147483647\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\nexport const style = (appearance: SurveyAppearance | null) => {\n const positions = {\n left: 'left: 30px;',\n right: 'right: 30px;',\n center: `\n left: 50%;\n transform: translateX(-50%);\n `,\n }\n return `\n .survey-form, .thank-you-message {\n position: fixed;\n margin: 0px;\n bottom: 0px;\n color: black;\n font-weight: normal;\n font-family: ${getFontFamily(appearance?.fontFamily)};\n text-align: left;\n max-width: ${parseInt(appearance?.maxWidth || '300')}px;\n width: 100%;\n z-index: ${parseInt(appearance?.zIndex || SURVEY_DEFAULT_Z_INDEX.toString())};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n border-bottom: 0px;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n flex-direction: column;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n }\n\n .survey-box, .thank-you-message-container {\n padding: 20px 25px 10px;\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n }\n\n .thank-you-message {\n text-align: center;\n }\n\n .form-submit[disabled] {\n opacity: ${appearance?.disabledButtonOpacity || '0.6'};\n filter: grayscale(50%);\n cursor: not-allowed;\n }\n .survey-form textarea {\n color: #2d2d2d;\n font-size: 14px;\n font-family: ${getFontFamily(appearance?.fontFamily)};\n background: white;\n color: black;\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n padding-top: 10px;\n border-radius: 6px;\n border-color: ${appearance?.borderColor || '#c9c6c6'};\n margin-top: 14px;\n width: 100%;\n box-sizing: border-box;\n }\n .survey-box:has(.survey-question:empty):not(:has(.survey-question-description)) textarea {\n margin-top: 0;\n }\n .form-submit {\n box-sizing: border-box;\n margin: 0;\n font-family: inherit;\n overflow: visible;\n text-transform: none;\n position: relative;\n display: inline-block;\n font-weight: 700;\n white-space: nowrap;\n text-align: center;\n border: 1.5px solid transparent;\n cursor: pointer;\n user-select: none;\n touch-action: manipulation;\n padding: 12px;\n font-size: 14px;\n border-radius: 6px;\n outline: 0;\n background: ${appearance?.submitButtonColor || 'black'} !important;\n text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);\n box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);\n width: 100%;\n }\n .form-cancel {\n display: flex;\n float: right;\n border: none;\n background: none;\n cursor: pointer;\n }\n .cancel-btn-wrapper {\n position: absolute;\n width: 35px;\n height: 35px;\n border-radius: 100%;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n background: white;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .bolded { font-weight: 600; }\n .buttons {\n display: flex;\n justify-content: center;\n }\n .footer-branding {\n font-size: 11px;\n margin-top: 10px;\n text-align: center;\n display: flex;\n justify-content: center;\n gap: 4px;\n align-items: center;\n font-weight: 500;\n background: ${appearance?.backgroundColor || '#eeeded'};\n text-decoration: none;\n backgroundColor: ${appearance?.backgroundColor || '#eeeded'};\n color: ${getContrastingTextColor(appearance?.backgroundColor || '#eeeded')};\n }\n .survey-question {\n font-weight: 500;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .question-textarea-wrapper {\n display: flex;\n flex-direction: column;\n }\n .survey-question-description {\n font-size: 13px;\n padding-top: 5px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .ratings-number {\n font-size: 16px;\n font-weight: 600;\n padding: 8px 0px;\n border: none;\n }\n .ratings-number:hover {\n cursor: pointer;\n }\n .rating-options {\n margin-top: 14px;\n }\n .rating-options-number {\n display: grid;\n border-radius: 6px;\n overflow: hidden;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-number > .ratings-number {\n border-right: 1px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-number > .ratings-number:last-of-type {\n border-right: 0px;\n }\n .rating-options-number .rating-active {\n background: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .rating-options-emoji {\n display: flex;\n justify-content: space-between;\n }\n .ratings-emoji {\n font-size: 16px;\n background-color: transparent;\n border: none;\n padding: 0px;\n }\n .ratings-emoji:hover {\n cursor: pointer;\n }\n .ratings-emoji.rating-active svg {\n fill: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .emoji-svg {\n fill: '#939393';\n }\n .rating-text {\n display: flex;\n flex-direction: row;\n font-size: 11px;\n justify-content: space-between;\n margin-top: 6px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n opacity: .60;\n }\n .limit-height {\n max-height: 300px;\n overflow: auto;\n scrollbar-width: thin;\n scrollbar-color: ${appearance?.borderColor || '#c9c6c6'} ${appearance?.backgroundColor || '#eeeded'};\n }\n .multiple-choice-options {\n margin-top: 13px;\n font-size: 14px;\n }\n .survey-box:has(.survey-question:empty):not(:has(.survey-question-description)) .multiple-choice-options {\n margin-top: 0;\n }\n .multiple-choice-options .choice-option {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 13px;\n cursor: pointer;\n margin-bottom: 5px;\n position: relative;\n }\n .multiple-choice-options > .choice-option:last-of-type {\n margin-bottom: 0px;\n }\n .multiple-choice-options input {\n cursor: pointer;\n position: absolute;\n opacity: 0;\n }\n .choice-check {\n position: absolute;\n right: 10px;\n background: white;\n }\n .choice-check svg {\n display: none;\n }\n .multiple-choice-options .choice-option:hover .choice-check svg {\n display: inline-block;\n opacity: .25;\n }\n .multiple-choice-options input:checked + label + .choice-check svg {\n display: inline-block;\n opacity: 100% !important;\n }\n .multiple-choice-options input:checked + label {\n font-weight: bold;\n border: 1.5px solid rgba(0,0,0);\n }\n .multiple-choice-options input:checked + label input {\n font-weight: bold;\n }\n .multiple-choice-options label {\n width: 100%;\n cursor: pointer;\n padding: 10px;\n border: 1.5px solid rgba(0,0,0,.25);\n border-radius: 4px;\n background: white;\n }\n .multiple-choice-options .choice-option-open label {\n padding-right: 30px;\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n max-width: 100%;\n }\n .multiple-choice-options .choice-option-open label span {\n width: 100%;\n }\n .multiple-choice-options .choice-option-open input:disabled + label {\n opacity: 0.6;\n }\n .multiple-choice-options .choice-option-open label input {\n position: relative;\n opacity: 1;\n flex-grow: 1;\n border: 0;\n outline: 0;\n }\n .thank-you-message-body {\n margin-top: 6px;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-header {\n margin: 10px 0px 0px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-container .form-submit {\n margin-top: 20px;\n margin-bottom: 10px;\n }\n .thank-you-message-countdown {\n margin-left: 6px;\n }\n .bottom-section {\n margin-top: 14px;\n }\n `\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\nfunction hex2rgb(c: string) {\n if (c[0] === '#') {\n const hexColor = c.replace(/^#/, '')\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 getContrastingTextColor(color: string = defaultBackgroundColor) {\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'\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' : 'white'\n }\n return 'black'\n}\nexport function getTextColor(el: HTMLElement) {\n const backgroundColor = window.getComputedStyle(el).backgroundColor\n if (backgroundColor === 'rgba(0, 0, 0, 0)') {\n return 'black'\n }\n const colorMatch = backgroundColor.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (!colorMatch) return 'black'\n\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' : 'white'\n}\n\nexport const defaultSurveyAppearance: SurveyAppearance = {\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: 'right',\n}\n\nexport const defaultBackgroundColor = '#eeeded'\n\nexport const createShadow = (styleSheet: string, surveyId: string, element?: Element, posthog?: PostHog) => {\n const div = document.createElement('div')\n div.className = `PostHogSurvey${surveyId}`\n const shadow = div.attachShadow({ mode: 'open' })\n if (styleSheet) {\n const styleElement = prepareStylesheet(document, styleSheet, posthog)\n if (styleElement) {\n shadow.appendChild(styleElement)\n }\n }\n ;(element ? element : document.body).appendChild(div)\n return shadow\n}\n\nexport const sendSurveyEvent = (\n responses: Record<string, string | number | string[] | null> = {},\n survey: Survey,\n posthog?: PostHog\n) => {\n if (!posthog) {\n logger.error('[survey sent] event not captured, PostHog instance not found.')\n return\n }\n localStorage.setItem(getSurveySeenKey(survey), 'true')\n\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n $survey_questions: survey.questions.map((question, index) => ({\n id: question.id,\n question: question.question,\n index,\n })),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...responses,\n $set: {\n [getSurveyInteractionProperty(survey, 'responded')]: true,\n },\n })\n window.dispatchEvent(new Event('PHSurveySent'))\n}\n\nexport const dismissedSurveyEvent = (survey: Survey, posthog?: PostHog, readOnly?: boolean) => {\n // TODO: state management and unit tests for this would be nice\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 posthog.capture('survey dismissed', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [getSurveyInteractionProperty(survey, 'dismissed')]: true,\n },\n })\n localStorage.setItem(getSurveySeenKey(survey), 'true')\n window.dispatchEvent(new Event('PHSurveyClosed'))\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) {\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 = (survey: Pick<Survey, 'schedule' | 'type' | 'conditions'>): boolean => {\n if (survey.schedule === SurveySchedule.Always && survey.type === SurveyType.Widget) {\n return true\n }\n\n return !!(survey.conditions?.events?.repeatedActivation && hasEvents(survey))\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\nexport const getSurveySeenKey = (survey: Survey): string => {\n let surveySeenKey = `${SurveySeenPrefix}${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n surveySeenKey = `${SurveySeenPrefix}${survey.id}_${survey.current_iteration}`\n }\n\n return surveySeenKey\n}\n\nexport const getSurveySeenStorageKeys = (): string[] => {\n const surveyKeys = []\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i)\n if (key?.startsWith(SurveySeenPrefix)) {\n surveyKeys.push(key)\n }\n }\n\n return surveyKeys\n}\n\nconst getSurveyInteractionProperty = (survey: Survey, action: string): 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\nexport const hasWaitPeriodPassed = (\n lastSeenSurveyDate: string | null,\n waitPeriodInDays: number | undefined\n): boolean => {\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 onPopupSurveySent: () => void\n}\n\nexport const SurveyContext = createContext<SurveyContextProps>({\n isPreviewMode: false,\n previewPageIndex: 0,\n onPopupSurveyDismissed: () => {},\n isPopup: true,\n onPreviewSubmit: () => {},\n onPopupSurveySent: () => {},\n})\n\ninterface RenderProps {\n component: VNode<{ className: string }>\n children: string\n renderAsHtml?: boolean\n style?: React.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","import { Breaker, Properties } from '../types'\nimport { hasOwnProperty, isArray, isFormData, isNull, isNullish, isString } from './type-utils'\nimport { logger } from './logger'\nimport { nativeForEach, nativeIndexOf } from './globals'\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) {\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","import { getQueryParam, convertToURL, maskQueryParams } from './request-utils'\nimport { isNull } from './type-utils'\nimport { Properties } from '../types'\nimport Config from '../config'\nimport { each, extend, extendArray, stripEmptyProperties } from './index'\nimport { document, location, userAgent, window } from './globals'\nimport { detectBrowser, detectBrowserVersion, detectDevice, detectDeviceType, detectOS } from './user-agent-utils'\nimport { stripLeadingDollar } from './string-utils'\n\nconst URL_REGEX_PREFIX = 'https?://(.*)'\n\n// CAMPAIGN_PARAMS and EVENT_TO_PERSON_PROPERTIES should be kept in sync with\n// https://github.com/PostHog/posthog/blob/master/plugin-server/src/utils/db/utils.ts#L60\n\n// The list of campaign parameters that could be considered personal data under e.g. GDPR.\n// These can be masked in URLs and properties before being sent to posthog.\nexport const PERSONAL_DATA_CAMPAIGN_PARAMS = [\n 'gclid', // google ads\n 'gclsrc', // google ads 360\n 'dclid', // google display ads\n 'gbraid', // google ads, web to app\n 'wbraid', // google ads, app to web\n 'fbclid', // facebook\n 'msclkid', // microsoft\n 'twclid', // twitter\n 'li_fat_id', // linkedin\n 'igshid', // instagram\n 'ttclid', // tiktok\n 'rdt_cid', // reddit\n 'irclid', // impact\n '_kx', // klaviyo\n]\n\nexport const CAMPAIGN_PARAMS = extendArray(\n [\n 'utm_source',\n 'utm_medium',\n 'utm_campaign',\n 'utm_content',\n 'utm_term',\n 'gad_source', // google ads source\n 'mc_cid', // mailchimp campaign id\n ],\n PERSONAL_DATA_CAMPAIGN_PARAMS\n)\n\nexport const EVENT_TO_PERSON_PROPERTIES = [\n // mobile params\n '$app_build',\n '$app_name',\n '$app_namespace',\n '$app_version',\n // web params\n '$browser',\n '$browser_version',\n '$device_type',\n '$current_url',\n '$pathname',\n '$os',\n '$os_name', // $os_name is a special case, it's treated as an alias of $os!\n '$os_version',\n '$referring_domain',\n '$referrer',\n]\n\nexport const MASKED = '<masked>'\n\nexport const Info = {\n campaignParams: function ({\n customTrackedParams,\n maskPersonalDataProperties,\n customPersonalDataProperties,\n }: {\n customTrackedParams?: string[]\n maskPersonalDataProperties?: boolean\n customPersonalDataProperties?: string[] | undefined\n } = {}): Record<string, string> {\n if (!document) {\n return {}\n }\n\n const paramsToMask = maskPersonalDataProperties\n ? extendArray([], PERSONAL_DATA_CAMPAIGN_PARAMS, customPersonalDataProperties || [])\n : []\n\n return this._campaignParamsFromUrl(maskQueryParams(document.URL, paramsToMask, MASKED), customTrackedParams)\n },\n\n _campaignParamsFromUrl: function (url: string, customParams?: string[]): Record<string, string> {\n const campaign_keywords = CAMPAIGN_PARAMS.concat(customParams || [])\n\n const params: Record<string, any> = {}\n each(campaign_keywords, function (kwkey) {\n const kw = getQueryParam(url, kwkey)\n params[kwkey] = kw ? kw : null\n })\n\n return params\n },\n\n _searchEngine: function (referrer: string): string | null {\n if (!referrer) {\n return null\n } else {\n if (referrer.search(URL_REGEX_PREFIX + 'google.([^/?]*)') === 0) {\n return 'google'\n } else if (referrer.search(URL_REGEX_PREFIX + 'bing.com') === 0) {\n return 'bing'\n } else if (referrer.search(URL_REGEX_PREFIX + 'yahoo.com') === 0) {\n return 'yahoo'\n } else if (referrer.search(URL_REGEX_PREFIX + 'duckduckgo.com') === 0) {\n return 'duckduckgo'\n } else {\n return null\n }\n }\n },\n\n _searchInfoFromReferrer: function (referrer: string): Record<string, any> {\n const search = Info._searchEngine(referrer)\n const param = search != 'yahoo' ? 'q' : 'p'\n const ret: Record<string, any> = {}\n\n if (!isNull(search)) {\n ret['$search_engine'] = search\n\n const keyword = document ? getQueryParam(document.referrer, param) : ''\n if (keyword.length) {\n ret['ph_keyword'] = keyword\n }\n }\n\n return ret\n },\n\n searchInfo: function (): Record<string, any> {\n const referrer = document?.referrer\n if (!referrer) {\n return {}\n }\n return this._searchInfoFromReferrer(referrer)\n },\n\n /**\n * This function detects which browser is running this script.\n * The order of the checks are important since many user agents\n * include keywords used in later checks.\n */\n browser: detectBrowser,\n\n /**\n * This function detects which browser version is running this script,\n * parsing major and minor version (e.g., 42.1). User agent strings from:\n * http://www.useragentstring.com/pages/useragentstring.php\n *\n * `navigator.vendor` is passed in and used to help with detecting certain browsers\n * NB `navigator.vendor` is deprecated and not present in every browser\n */\n browserVersion: detectBrowserVersion,\n\n browserLanguage: function (): string | undefined {\n return (\n navigator.language || // Any modern browser\n (navigator as Record<string, any>).userLanguage // IE11\n )\n },\n\n browserLanguagePrefix: function (): string | undefined {\n const browserLanguage = this.browserLanguage()\n return typeof browserLanguage === 'string' ? browserLanguage.split('-')[0] : undefined\n },\n\n os: detectOS,\n\n device: detectDevice,\n\n deviceType: detectDeviceType,\n\n referrer: function (): string {\n return document?.referrer || '$direct'\n },\n\n referringDomain: function (): string {\n if (!document?.referrer) {\n return '$direct'\n }\n return convertToURL(document.referrer)?.host || '$direct'\n },\n\n referrerInfo: function (): Record<string, any> {\n return {\n $referrer: this.referrer(),\n $referring_domain: this.referringDomain(),\n }\n },\n\n personInfo: function ({\n maskPersonalDataProperties,\n customPersonalDataProperties,\n }: {\n maskPersonalDataProperties?: boolean\n customPersonalDataProperties?: string[]\n } = {}) {\n const paramsToMask = maskPersonalDataProperties\n ? extendArray([], PERSONAL_DATA_CAMPAIGN_PARAMS, customPersonalDataProperties || [])\n : []\n const url = location?.href.substring(0, 1000)\n // we're being a bit more economical with bytes here because this is stored in the cookie\n return {\n r: this.referrer().substring(0, 1000),\n u: url ? maskQueryParams(url, paramsToMask, MASKED) : undefined,\n }\n },\n\n personPropsFromInfo: function (info: Record<string, any>): Record<string, any> {\n const { r: referrer, u: url } = info\n const referring_domain =\n referrer == null ? undefined : referrer == '$direct' ? '$direct' : convertToURL(referrer)?.host\n\n const props: Record<string, string | undefined> = {\n $referrer: referrer,\n $referring_domain: referring_domain,\n }\n if (url) {\n props['$current_url'] = url\n const location = convertToURL(url)\n props['$host'] = location?.host\n props['$pathname'] = location?.pathname\n const campaignParams = this._campaignParamsFromUrl(url)\n extend(props, campaignParams)\n }\n if (referrer) {\n const searchInfo = this._searchInfoFromReferrer(referrer)\n extend(props, searchInfo)\n }\n return props\n },\n\n initialPersonPropsFromInfo: function (info: Record<string, any>): Record<string, any> {\n const personProps = this.personPropsFromInfo(info)\n const props: Record<string, any> = {}\n each(personProps, function (val: any, key: string) {\n props[`$initial_${stripLeadingDollar(key)}`] = val\n })\n return props\n },\n\n timezone: function (): string | undefined {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone\n } catch {\n return undefined\n }\n },\n\n timezoneOffset: function (): number | undefined {\n try {\n return new Date().getTimezoneOffset()\n } catch {\n return undefined\n }\n },\n\n properties: function ({\n maskPersonalDataProperties,\n customPersonalDataProperties,\n }: {\n maskPersonalDataProperties?: boolean\n customPersonalDataProperties?: string[]\n } = {}): Properties {\n if (!userAgent) {\n return {}\n }\n const paramsToMask = maskPersonalDataProperties\n ? extendArray([], PERSONAL_DATA_CAMPAIGN_PARAMS, customPersonalDataProperties || [])\n : []\n const [os_name, os_version] = Info.os(userAgent)\n return extend(\n stripEmptyProperties({\n $os: os_name,\n $os_version: os_version,\n $browser: Info.browser(userAgent, navigator.vendor),\n $device: Info.device(userAgent),\n $device_type: Info.deviceType(userAgent),\n $timezone: Info.timezone(),\n $timezone_offset: Info.timezoneOffset(),\n }),\n {\n $current_url: maskQueryParams(location?.href, paramsToMask, MASKED),\n $host: location?.host,\n $pathname: location?.pathname,\n $raw_user_agent: userAgent.length > 1000 ? userAgent.substring(0, 997) + '...' : userAgent,\n $browser_version: Info.browserVersion(userAgent, navigator.vendor),\n $browser_language: Info.browserLanguage(),\n $browser_language_prefix: Info.browserLanguagePrefix(),\n $screen_height: window?.screen.height,\n $screen_width: window?.screen.width,\n $viewport_height: window?.innerHeight,\n $viewport_width: window?.innerWidth,\n $lib: 'web',\n $lib_version: Config.LIB_VERSION,\n $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),\n $time: Date.now() / 1000, // epoch time in seconds\n }\n )\n },\n\n people_properties: function (): Properties {\n if (!userAgent) {\n return {}\n }\n\n const [os_name, os_version] = Info.os(userAgent)\n return extend(\n stripEmptyProperties({\n $os: os_name,\n $os_version: os_version,\n $browser: Info.browser(userAgent, navigator.vendor),\n }),\n {\n $browser_version: Info.browserVersion(userAgent, navigator.vendor),\n }\n )\n },\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","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 { PostHog } from '../../posthog-core'\nimport { ActionStepStringMatching, ActionStepType, SurveyActionType, SurveyElement } from '../../posthog-surveys-types'\nimport { SimpleEventEmitter } from '../../utils/simple-event-emitter'\nimport { CaptureResult } from '../../types'\nimport { isUndefined } from '../../utils/type-utils'\nimport { window } from '../../utils/globals'\nimport { isMatchingRegex } from '../../utils/regex-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 this.checkStepEvent(event, step) && this.checkStepUrl(event, step) && this.checkStepElement(event, step)\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 // URL IS UNKNOWN\n }\n if (!ActionMatcher.matchString(eventUrl, step?.url, step?.url_matching || 'contains')) {\n return false // URL IS A MISMATCH\n }\n }\n return true\n }\n\n private static matchString(url: string, pattern: string, matching: ActionStepStringMatching): boolean {\n switch (matching) {\n case 'regex':\n return !!window && isMatchingRegex(url, pattern)\n case 'exact':\n return pattern === url\n case 'contains':\n // Simulating SQL LIKE behavior (_ = any single character, % = any zero or more characters)\n // eslint-disable-next-line no-case-declarations\n const adjustedRegExpStringPattern = ActionMatcher.escapeStringRegexp(pattern)\n .replace(/_/g, '.')\n .replace(/%/g, '.*')\n return isMatchingRegex(url, adjustedRegExpStringPattern)\n\n default:\n return false\n }\n }\n\n private static escapeStringRegexp(pattern: string): string {\n // Escape characters with special meaning either inside or outside character sets.\n // Use a simple backslash escape when it’s always valid, and a `\\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.\n return pattern.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d')\n }\n\n private checkStepElement(event?: CaptureResult, step?: ActionStepType): boolean {\n // CHECK CONDITIONS, OTHERWISE SKIPPED\n if (step?.href || step?.tag_name || step?.text) {\n const elements = this.getElementsList(event)\n if (\n !elements.some((element) => {\n if (\n step?.href &&\n !ActionMatcher.matchString(element.href || '', step?.href, step?.href_matching || 'exact')\n ) {\n return false // ELEMENT HREF IS A MISMATCH\n }\n if (step?.tag_name && element.tag_name !== step?.tag_name) {\n return false // ELEMENT TAG NAME IS A MISMATCH\n }\n if (\n step?.text &&\n !(\n ActionMatcher.matchString(element.text || '', step?.text, step?.text_matching || 'exact') ||\n ActionMatcher.matchString(\n element.$el_text || '',\n step?.text,\n step?.text_matching || 'exact'\n )\n )\n ) {\n return false // ELEMENT TEXT IS A MISMATCH\n }\n return true\n })\n ) {\n // AT LEAST ONE ELEMENT MUST BE A SUBMATCH\n return false\n }\n }\n\n if (step?.selector) {\n const elementSelectors = event?.properties?.$element_selectors as unknown as string[]\n if (!elementSelectors) {\n return false // SELECTOR IS A MISMATCH\n }\n if (!elementSelectors.includes(step?.selector)) {\n return false // SELECTOR IS A MISMATCH\n }\n }\n\n return true\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","import { Survey } from '../posthog-surveys-types'\nimport { SURVEYS_ACTIVATED } from '../constants'\n\nimport { CaptureResult } from '../types'\nimport { ActionMatcher } from '../extensions/surveys/action-matcher'\nimport { PostHog } from '../posthog-core'\nimport { isUndefined } from './type-utils'\n\nexport class SurveyEventReceiver {\n // eventToSurveys is a mapping of event name to all the surveys that are activated by it\n private readonly eventToSurveys: Map<string, string[]>\n // actionToSurveys is a mapping of action name to all the surveys that are activated by it\n private readonly actionToSurveys: Map<string, string[]>\n // actionMatcher can look at CaptureResult payloads and match an event to its corresponding action.\n private actionMatcher?: ActionMatcher | null\n private readonly instance?: PostHog\n private static SURVEY_SHOWN_EVENT_NAME = 'survey shown'\n\n constructor(instance: PostHog) {\n this.instance = instance\n this.eventToSurveys = new Map<string, string[]>()\n this.actionToSurveys = new Map<string, string[]>()\n }\n\n register(surveys: Survey[]): void {\n if (isUndefined(this.instance?._addCaptureHook)) {\n return\n }\n\n this.setupEventBasedSurveys(surveys)\n this.setupActionBasedSurveys(surveys)\n }\n\n private setupActionBasedSurveys(surveys: Survey[]) {\n const actionBasedSurveys = surveys.filter(\n (survey: Survey) => survey.conditions?.actions && survey.conditions?.actions?.values?.length > 0\n )\n\n if (actionBasedSurveys.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 survey.\n const matchActionToSurvey = (actionName: string) => {\n this.onAction(actionName)\n }\n\n this.actionMatcher._addActionHook(matchActionToSurvey)\n }\n\n actionBasedSurveys.forEach((survey) => {\n if (\n survey.conditions &&\n survey.conditions?.actions &&\n survey.conditions?.actions?.values &&\n survey.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(survey.conditions.actions.values)\n\n // maintain a mapping of (Action1) => [Survey1, Survey2, Survey3]\n // where Surveys 1-3 are all activated by Action1\n survey.conditions?.actions?.values?.forEach((action) => {\n if (action && action.name) {\n const knownSurveys: string[] | undefined = this.actionToSurveys.get(action.name)\n if (knownSurveys) {\n knownSurveys.push(survey.id)\n }\n this.actionToSurveys.set(action.name, knownSurveys || [survey.id])\n }\n })\n }\n })\n }\n\n private setupEventBasedSurveys(surveys: Survey[]) {\n const eventBasedSurveys = surveys.filter(\n (survey: Survey) => survey.conditions?.events && survey.conditions?.events?.values?.length > 0\n )\n\n if (eventBasedSurveys.length === 0) {\n return\n }\n\n // match any events to its corresponding survey.\n const matchEventToSurvey = (eventName: string, eventPayload?: CaptureResult) => {\n this.onEvent(eventName, eventPayload)\n }\n this.instance?._addCaptureHook(matchEventToSurvey)\n\n surveys.forEach((survey) => {\n // maintain a mapping of (Event1) => [Survey1, Survey2, Survey3]\n // where Surveys 1-3 are all activated by Event1\n survey.conditions?.events?.values?.forEach((event) => {\n if (event && event.name) {\n const knownSurveys: string[] | undefined = this.eventToSurveys.get(event.name)\n if (knownSurveys) {\n knownSurveys.push(survey.id)\n }\n this.eventToSurveys.set(event.name, knownSurveys || [survey.id])\n }\n })\n })\n }\n\n onEvent(event: string, eventPayload?: CaptureResult): void {\n const existingActivatedSurveys: string[] = this.instance?.persistence?.props[SURVEYS_ACTIVATED] || []\n if (\n SurveyEventReceiver.SURVEY_SHOWN_EVENT_NAME == event &&\n eventPayload &&\n existingActivatedSurveys.length > 0\n ) {\n // remove survey that from activatedSurveys here.\n const surveyId = eventPayload?.properties?.$survey_id\n if (surveyId) {\n const index = existingActivatedSurveys.indexOf(surveyId)\n if (index >= 0) {\n existingActivatedSurveys.splice(index, 1)\n this._updateActivatedSurveys(existingActivatedSurveys)\n }\n }\n } else {\n if (this.eventToSurveys.has(event)) {\n this._updateActivatedSurveys(existingActivatedSurveys.concat(this.eventToSurveys.get(event) || []))\n }\n }\n }\n\n onAction(actionName: string): void {\n const existingActivatedSurveys: string[] = this.instance?.persistence?.props[SURVEYS_ACTIVATED] || []\n if (this.actionToSurveys.has(actionName)) {\n this._updateActivatedSurveys(existingActivatedSurveys.concat(this.actionToSurveys.get(actionName) || []))\n }\n }\n\n private _updateActivatedSurveys(activatedSurveys: string[]) {\n // we use a new Set here to remove duplicates.\n this.instance?.persistence?.register({\n [SURVEYS_ACTIVATED]: [...new Set(activatedSurveys)],\n })\n }\n\n getSurveys(): string[] {\n const existingActivatedSurveys = this.instance?.persistence?.props[SURVEYS_ACTIVATED]\n return existingActivatedSurveys ? existingActivatedSurveys : []\n }\n\n getEventToSurveys(): Map<string, string[]> {\n return this.eventToSurveys\n }\n\n _getActionMatcher(): ActionMatcher | null | undefined {\n return this.actionMatcher\n }\n}\n","import { SURVEYS } from './constants'\nimport { getSurveySeenStorageKeys } from './extensions/surveys/surveys-utils'\nimport { PostHog } from './posthog-core'\nimport { Survey, SurveyCallback, SurveyMatchType } from './posthog-surveys-types'\nimport { RemoteConfig } from './types'\nimport { Info } from './utils/event-utils'\nimport { assignableWindow, document, userAgent, window } from './utils/globals'\nimport { createLogger } from './utils/logger'\nimport { isMatchingRegex } from './utils/regex-utils'\nimport { SurveyEventReceiver } from './utils/survey-event-receiver'\nimport { isNullish } from './utils/type-utils'\n\nconst logger = createLogger('[Surveys]')\n\nexport const surveyValidationMap: Record<SurveyMatchType, (targets: string[], value: string) => boolean> = {\n icontains: (targets, value) => targets.some((target) => value.toLowerCase().includes(target.toLowerCase())),\n\n not_icontains: (targets, value) => targets.every((target) => !value.toLowerCase().includes(target.toLowerCase())),\n\n regex: (targets, value) => targets.some((target) => isMatchingRegex(value, target)),\n\n not_regex: (targets, value) => targets.every((target) => !isMatchingRegex(value, target)),\n\n exact: (targets, value) => targets.some((target) => value === target),\n\n is_not: (targets, value) => targets.every((target) => value !== target),\n}\n\nfunction defaultMatchType(matchType?: SurveyMatchType): SurveyMatchType {\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\n const targets = [survey.conditions.url]\n return surveyValidationMap[defaultMatchType(survey.conditions?.urlMatchType)](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 = Info.deviceType(userAgent)\n return surveyValidationMap[defaultMatchType(survey.conditions?.deviceTypesMatchType)](\n survey.conditions.deviceTypes,\n deviceType\n )\n}\n\nexport class PostHogSurveys {\n private _decideServerResponse?: boolean\n public _surveyEventReceiver: SurveyEventReceiver | null\n private _surveyManager: any\n private _isFetchingSurveys: boolean = false\n private _isInitializingSurveys: boolean = false\n\n constructor(private readonly instance: PostHog) {\n // we set this to undefined here because we need the persistence storage for this type\n // but that's not initialized until loadIfEnabled is called.\n this._surveyEventReceiver = null\n }\n\n onRemoteConfig(response: RemoteConfig) {\n this._decideServerResponse = !!response['surveys']\n logger.info(`decideServerResponse set to ${this._decideServerResponse}`)\n\n this.loadIfEnabled()\n }\n\n reset(): void {\n localStorage.removeItem('lastSeenSurveyDate')\n const surveyKeys = getSurveySeenStorageKeys()\n surveyKeys.forEach((key) => localStorage.removeItem(key))\n }\n\n loadIfEnabled() {\n if (this._surveyManager) {\n // Surveys already loaded.\n return\n }\n\n if (this._isInitializingSurveys) {\n logger.info('Already initializing surveys, skipping...')\n return\n }\n\n const disableSurveys = this.instance.config.disable_surveys\n\n if (disableSurveys) {\n logger.info('Disabled. Not loading surveys.')\n return\n }\n\n const phExtensions = assignableWindow?.__PosthogExtensions__\n\n if (!phExtensions) {\n logger.error('PostHog Extensions not found.')\n return\n }\n\n if (!this._decideServerResponse) {\n logger.warn('Decide not loaded yet. Not loading surveys.')\n return\n }\n\n this._isInitializingSurveys = true\n\n try {\n const generateSurveys = phExtensions.generateSurveys\n\n if (!generateSurveys) {\n const loadExternalDependency = phExtensions.loadExternalDependency\n\n if (loadExternalDependency) {\n loadExternalDependency(this.instance, 'surveys', (err) => {\n if (err || !phExtensions.generateSurveys) {\n logger.error('Could not load surveys script', err)\n this._isInitializingSurveys = false\n return\n }\n\n this._surveyManager = phExtensions.generateSurveys(this.instance)\n this._isInitializingSurveys = false\n this._surveyEventReceiver = new SurveyEventReceiver(this.instance)\n logger.info('Surveys loaded successfully')\n })\n } else {\n logger.error('PostHog loadExternalDependency extension not found. Cannot load remote config.')\n this._isInitializingSurveys = false\n }\n } else {\n this._surveyManager = generateSurveys(this.instance)\n this._isInitializingSurveys = false\n this._surveyEventReceiver = new SurveyEventReceiver(this.instance)\n logger.info('Surveys loaded successfully')\n }\n } catch (e) {\n logger.error('Error initializing surveys', e)\n this._isInitializingSurveys = false\n throw e\n }\n }\n\n getSurveys(callback: SurveyCallback, forceReload = false) {\n // In case we manage to load the surveys script, but config says not to load surveys\n // then we shouldn't return survey data\n if (this.instance.config.disable_surveys) {\n logger.info('Disabled. Not loading surveys.')\n return callback([])\n }\n\n const existingSurveys = this.instance.get_property(SURVEYS)\n\n if (!existingSurveys || forceReload) {\n // Prevent concurrent API calls\n if (this._isFetchingSurveys) {\n return callback([])\n }\n\n try {\n this._isFetchingSurveys = true\n this.instance._send_request({\n url: this.instance.requestRouter.endpointFor(\n 'api',\n `/api/surveys/?token=${this.instance.config.token}`\n ),\n method: 'GET',\n timeout: this.instance.config.surveys_request_timeout_ms,\n callback: (response) => {\n this._isFetchingSurveys = false\n const statusCode = response.statusCode\n if (statusCode !== 200 || !response.json) {\n logger.error(`Surveys API could not be loaded, status: ${statusCode}`)\n return callback([])\n }\n const surveys = response.json.surveys || []\n\n const eventOrActionBasedSurveys = surveys.filter(\n (survey: Survey) =>\n (survey.conditions?.events &&\n survey.conditions?.events?.values &&\n survey.conditions?.events?.values?.length > 0) ||\n (survey.conditions?.actions &&\n survey.conditions?.actions?.values &&\n survey.conditions?.actions?.values?.length > 0)\n )\n\n if (eventOrActionBasedSurveys.length > 0) {\n this._surveyEventReceiver?.register(eventOrActionBasedSurveys)\n }\n\n this.instance.persistence?.register({ [SURVEYS]: surveys })\n return callback(surveys)\n },\n })\n } catch (e) {\n this._isFetchingSurveys = false\n throw e\n }\n } else {\n return callback(existingSurveys)\n }\n }\n\n private isSurveyFeatureFlagEnabled(flagKey: string | null) {\n if (!flagKey) {\n return true\n }\n return this.instance.featureFlags.isFeatureEnabled(flagKey)\n }\n\n getActiveMatchingSurveys(callback: SurveyCallback, forceReload = false) {\n this.getSurveys((surveys) => {\n const activeSurveys = surveys.filter((survey) => {\n return !!(survey.start_date && !survey.end_date)\n })\n\n const conditionMatchedSurveys = activeSurveys.filter((survey) => {\n if (!survey.conditions) {\n return true\n }\n\n const urlCheck = doesSurveyUrlMatch(survey)\n const selectorCheck = survey.conditions?.selector\n ? document?.querySelector(survey.conditions.selector)\n : true\n const deviceTypeCheck = doesSurveyDeviceTypesMatch(survey)\n return urlCheck && selectorCheck && deviceTypeCheck\n })\n\n // get all the surveys that have been activated so far with user actions.\n const activatedSurveys: string[] | undefined = this._surveyEventReceiver?.getSurveys()\n const targetingMatchedSurveys = conditionMatchedSurveys.filter((survey) => {\n if (\n !survey.linked_flag_key &&\n !survey.targeting_flag_key &&\n !survey.internal_targeting_flag_key &&\n !survey.feature_flag_keys?.length\n ) {\n return true\n }\n const linkedFlagCheck = this.isSurveyFeatureFlagEnabled(survey.linked_flag_key)\n const targetingFlagCheck = this.isSurveyFeatureFlagEnabled(survey.targeting_flag_key)\n\n const hasEvents = (survey.conditions?.events?.values?.length ?? 0) > 0\n const hasActions = (survey.conditions?.actions?.values?.length ?? 0) > 0\n\n const eventBasedTargetingFlagCheck =\n hasEvents || hasActions ? activatedSurveys?.includes(survey.id) : true\n\n const overrideInternalTargetingFlagCheck = this._canActivateRepeatedly(survey)\n const internalTargetingFlagCheck =\n overrideInternalTargetingFlagCheck ||\n this.isSurveyFeatureFlagEnabled(survey.internal_targeting_flag_key)\n\n const flagsCheck = this.checkFlags(survey)\n return (\n linkedFlagCheck &&\n targetingFlagCheck &&\n internalTargetingFlagCheck &&\n eventBasedTargetingFlagCheck &&\n flagsCheck\n )\n })\n\n return callback(targetingMatchedSurveys)\n }, forceReload)\n }\n\n checkFlags(survey: Survey): boolean {\n if (!survey.feature_flag_keys?.length) {\n return true\n }\n\n return survey.feature_flag_keys.every(({ key, value }) => {\n if (!key || !value) {\n return true\n }\n return this.instance.featureFlags.isFeatureEnabled(value)\n })\n }\n\n // this method is lazily loaded onto the window to avoid loading preact and other dependencies if surveys is not enabled\n private _canActivateRepeatedly(survey: Survey) {\n if (isNullish(assignableWindow.__PosthogExtensions__?.canActivateRepeatedly)) {\n logger.warn('init was not called')\n return false // TODO does it make sense to have a default here?\n }\n return assignableWindow.__PosthogExtensions__.canActivateRepeatedly(survey)\n }\n\n canRenderSurvey(surveyId: string) {\n if (isNullish(this._surveyManager)) {\n logger.warn('init was not called')\n return\n }\n this.getSurveys((surveys) => {\n const survey = surveys.filter((x) => x.id === surveyId)[0]\n this._surveyManager.canRenderSurvey(survey)\n })\n }\n\n renderSurvey(surveyId: string, selector: string) {\n if (isNullish(this._surveyManager)) {\n logger.warn('init was not called')\n return\n }\n this.getSurveys((surveys) => {\n const survey = surveys.filter((x) => x.id === surveyId)[0]\n this._surveyManager.renderSurvey(survey, document?.querySelector(selector))\n })\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","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 width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\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 { IconPosthogLogo } from '../icons'\n// import { getContrastingTextColor } from '../surveys-utils'\n\nexport function PostHogLogo() {\n // const textColor = getContrastingTextColor(backgroundColor)\n\n return (\n <a\n href=\"https://posthog.com\"\n target=\"_blank\"\n rel=\"noopener\"\n // style={{ backgroundColor: backgroundColor, color: textColor }}\n className=\"footer-branding\"\n >\n Survey by {IconPosthogLogo}\n </a>\n )\n}\n","import { window } from '../../../utils/globals'\n\nimport { SurveyAppearance } from '../../../posthog-surveys-types'\n\nimport { useContext } from 'preact/hooks'\nimport { SurveyContext, defaultSurveyAppearance, getContrastingTextColor } from '../surveys-utils'\nimport { PostHogLogo } from './PostHogLogo'\n\nexport function BottomSection({\n text,\n submitDisabled,\n appearance,\n onSubmit,\n link,\n onPreviewSubmit,\n}: {\n text: string\n submitDisabled: boolean\n appearance: SurveyAppearance\n onSubmit: () => void\n link?: string | null\n onPreviewSubmit?: () => void\n}) {\n const { isPreviewMode, isPopup } = useContext(SurveyContext)\n const textColor =\n appearance.submitButtonTextColor ||\n getContrastingTextColor(appearance.submitButtonColor || defaultSurveyAppearance.submitButtonColor)\n return (\n <div className=\"bottom-section\">\n <div className=\"buttons\">\n <button\n className=\"form-submit\"\n disabled={submitDisabled}\n type=\"button\"\n style={isPopup ? { color: textColor } : {}}\n onClick={() => {\n if (link) {\n window?.open(link)\n }\n if (isPreviewMode) {\n onPreviewSubmit?.()\n } else {\n onSubmit()\n }\n }}\n >\n {text}\n </button>\n </div>\n {!appearance.whiteLabel && <PostHogLogo />}\n </div>\n )\n}\n","import { SurveyContext, defaultSurveyAppearance, renderChildrenAsTextOrHtml } from '../surveys-utils'\nimport { cancelSVG } from '../icons'\nimport { useContext } from 'preact/hooks'\nimport { SurveyQuestionDescriptionContentType } from '../../../posthog-surveys-types'\nimport { h } from 'preact'\n\nexport function QuestionHeader({\n question,\n description,\n descriptionContentType,\n backgroundColor,\n forceDisableHtml,\n}: {\n question: string\n description?: string | null\n descriptionContentType?: SurveyQuestionDescriptionContentType\n forceDisableHtml: boolean\n backgroundColor?: string\n}) {\n const { isPopup } = useContext(SurveyContext)\n return (\n <div style={isPopup ? { backgroundColor: backgroundColor || defaultSurveyAppearance.backgroundColor } : {}}>\n <div className=\"survey-question\">{question}</div>\n {description &&\n renderChildrenAsTextOrHtml({\n component: h('div', { className: 'survey-question-description' }),\n children: description,\n renderAsHtml: !forceDisableHtml && descriptionContentType !== 'text',\n })}\n </div>\n )\n}\n\nexport function Cancel({ onClick }: { onClick: () => void }) {\n const { isPreviewMode } = useContext(SurveyContext)\n\n return (\n <div className=\"cancel-btn-wrapper\" onClick={onClick} disabled={isPreviewMode}>\n <button className=\"form-cancel\" onClick={onClick} disabled={isPreviewMode}>\n {cancelSVG}\n </button>\n </div>\n )\n}\n","import { BottomSection } from './BottomSection'\nimport { Cancel } from './QuestionHeader'\nimport { SurveyAppearance, SurveyQuestionDescriptionContentType } from '../../../posthog-surveys-types'\nimport { defaultSurveyAppearance, getContrastingTextColor, renderChildrenAsTextOrHtml } from '../surveys-utils'\nimport { h } from 'preact'\n\nimport { useContext } from 'preact/hooks'\nimport { SurveyContext } from '../../surveys/surveys-utils'\n\nexport function ConfirmationMessage({\n header,\n description,\n contentType,\n forceDisableHtml,\n appearance,\n onClose,\n styleOverrides,\n}: {\n header: string\n description: string\n forceDisableHtml: boolean\n contentType?: SurveyQuestionDescriptionContentType\n appearance: SurveyAppearance\n onClose: () => void\n styleOverrides?: React.CSSProperties\n}) {\n const textColor = getContrastingTextColor(appearance.backgroundColor || defaultSurveyAppearance.backgroundColor)\n\n const { isPopup } = useContext(SurveyContext)\n\n return (\n <>\n <div className=\"thank-you-message\" style={{ ...styleOverrides }}>\n <div className=\"thank-you-message-container\">\n {isPopup && <Cancel onClick={() => onClose()} />}\n <h3 className=\"thank-you-message-header\" style={{ color: textColor }}>\n {header}\n </h3>\n {description &&\n renderChildrenAsTextOrHtml({\n component: h('div', { className: 'thank-you-message-body' }),\n children: description,\n renderAsHtml: !forceDisableHtml && contentType !== 'text',\n style: { color: textColor },\n })}\n {isPopup && (\n <BottomSection\n text={appearance.thankYouMessageCloseButtonText || 'Close'}\n submitDisabled={false}\n appearance={appearance}\n onSubmit={() => onClose()}\n />\n )}\n </div>\n </div>\n </>\n )\n}\n","import { useEffect, useRef, useState } from 'preact/hooks'\nimport { SurveyAppearance } from '../../../posthog-surveys-types'\nimport * as Preact from 'preact'\nimport { getTextColor } from '../surveys-utils'\n\nexport function useContrastingTextColor(options: {\n appearance: SurveyAppearance\n defaultTextColor?: string\n forceUpdate?: boolean\n}): {\n ref: Preact.RefObject<HTMLElement>\n textColor: string\n} {\n const ref = useRef<HTMLElement>(null)\n const [textColor, setTextColor] = useState(options.defaultTextColor ?? 'black')\n\n // TODO: useContext to get the background colors instead of querying the DOM\n useEffect(() => {\n if (ref.current) {\n const color = getTextColor(ref.current)\n setTextColor(color)\n }\n }, [options.appearance, options.forceUpdate])\n\n return {\n ref,\n textColor,\n }\n}\n","import { RefObject } from 'preact'\nimport { useMemo, useRef, useState } from 'preact/hooks'\nimport {\n BasicSurveyQuestion,\n LinkSurveyQuestion,\n MultipleSurveyQuestion,\n RatingSurveyQuestion,\n SurveyAppearance,\n SurveyQuestionType,\n} from '../../../posthog-surveys-types'\nimport { isArray, isNull } from '../../../utils/type-utils'\nimport { useContrastingTextColor } from '../hooks/useContrastingTextColor'\nimport {\n checkSVG,\n dissatisfiedEmoji,\n neutralEmoji,\n satisfiedEmoji,\n veryDissatisfiedEmoji,\n verySatisfiedEmoji,\n} from '../icons'\nimport { getDisplayOrderChoices } from '../surveys-utils'\nimport { BottomSection } from './BottomSection'\nimport { QuestionHeader } from './QuestionHeader'\n\ninterface CommonProps {\n forceDisableHtml: boolean\n appearance: SurveyAppearance\n onSubmit: (res: string | string[] | number | null) => void\n onPreviewSubmit: (res: string | string[] | number | null) => void\n}\n\nexport function OpenTextQuestion({\n question,\n forceDisableHtml,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: CommonProps & {\n question: BasicSurveyQuestion\n}) {\n const textRef = useRef(null)\n const [text, setText] = useState('')\n\n return (\n <div ref={textRef}>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n backgroundColor={appearance.backgroundColor}\n forceDisableHtml={forceDisableHtml}\n />\n <textarea rows={4} placeholder={appearance?.placeholder} onInput={(e) => setText(e.currentTarget.value)} />\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={!text && !question.optional}\n appearance={appearance}\n onSubmit={() => onSubmit(text)}\n onPreviewSubmit={() => onPreviewSubmit(text)}\n />\n </div>\n )\n}\n\nexport function LinkQuestion({\n question,\n forceDisableHtml,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: CommonProps & {\n question: LinkSurveyQuestion\n}) {\n return (\n <>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\n />\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={false}\n link={question.link}\n appearance={appearance}\n onSubmit={() => onSubmit('link clicked')}\n onPreviewSubmit={() => onPreviewSubmit('link clicked')}\n />\n </>\n )\n}\n\nexport function RatingQuestion({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: CommonProps & {\n question: RatingSurveyQuestion\n displayQuestionIndex: number\n}) {\n const scale = question.scale\n const starting = question.scale === 10 ? 0 : 1\n const [rating, setRating] = useState<number | null>(null)\n\n return (\n <>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\n backgroundColor={appearance.backgroundColor}\n />\n <div className=\"rating-section\">\n <div className=\"rating-options\">\n {question.display === 'emoji' && (\n <div className=\"rating-options-emoji\">\n {(question.scale === 3 ? threeScaleEmojis : fiveScaleEmojis).map((emoji, idx) => {\n const active = idx + 1 === rating\n return (\n <button\n className={`ratings-emoji question-${displayQuestionIndex}-rating-${idx} ${\n active ? 'rating-active' : null\n }`}\n value={idx + 1}\n key={idx}\n type=\"button\"\n onClick={() => {\n setRating(idx + 1)\n }}\n style={{\n fill: active\n ? appearance.ratingButtonActiveColor\n : appearance.ratingButtonColor,\n borderColor: appearance.borderColor,\n }}\n >\n {emoji}\n </button>\n )\n })}\n </div>\n )}\n {question.display === 'number' && (\n <div\n className=\"rating-options-number\"\n style={{ gridTemplateColumns: `repeat(${scale - starting + 1}, minmax(0, 1fr))` }}\n >\n {getScaleNumbers(question.scale).map((number, idx) => {\n const active = rating === number\n return (\n <RatingButton\n key={idx}\n displayQuestionIndex={displayQuestionIndex}\n active={active}\n appearance={appearance}\n num={number}\n setActiveNumber={(num) => {\n setRating(num)\n }}\n />\n )\n })}\n </div>\n )}\n </div>\n <div className=\"rating-text\">\n <div>{question.lowerBoundLabel}</div>\n <div>{question.upperBoundLabel}</div>\n </div>\n </div>\n <BottomSection\n text={question.buttonText || appearance?.submitButtonText || 'Submit'}\n submitDisabled={isNull(rating) && !question.optional}\n appearance={appearance}\n onSubmit={() => onSubmit(rating)}\n onPreviewSubmit={() => onPreviewSubmit(rating)}\n />\n </>\n )\n}\n\nexport function RatingButton({\n num,\n active,\n displayQuestionIndex,\n appearance,\n setActiveNumber,\n}: {\n num: number\n active: boolean\n displayQuestionIndex: number\n appearance: SurveyAppearance\n setActiveNumber: (num: number) => void\n}) {\n const { textColor, ref } = useContrastingTextColor({ appearance, defaultTextColor: 'black', forceUpdate: active })\n return (\n <button\n ref={ref as RefObject<HTMLButtonElement>}\n className={`ratings-number question-${displayQuestionIndex}-rating-${num} ${\n active ? 'rating-active' : null\n }`}\n type=\"button\"\n onClick={() => {\n setActiveNumber(num)\n }}\n style={{\n color: textColor,\n backgroundColor: active ? appearance.ratingButtonActiveColor : appearance.ratingButtonColor,\n borderColor: appearance.borderColor,\n }}\n >\n {num}\n </button>\n )\n}\n\nexport function MultipleChoiceQuestion({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: CommonProps & {\n question: MultipleSurveyQuestion\n displayQuestionIndex: number\n}) {\n const textRef = useRef(null)\n const choices = useMemo(() => getDisplayOrderChoices(question), [question])\n const [selectedChoices, setSelectedChoices] = useState<string | string[] | null>(\n question.type === SurveyQuestionType.MultipleChoice ? [] : null\n )\n const [openChoiceSelected, setOpenChoiceSelected] = useState(false)\n const [openEndedInput, setOpenEndedInput] = useState('')\n\n const inputType = question.type === SurveyQuestionType.SingleChoice ? 'radio' : 'checkbox'\n return (\n <div ref={textRef}>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\n backgroundColor={appearance.backgroundColor}\n />\n <div className=\"multiple-choice-options limit-height\">\n {/* Remove the last element from the choices, if hasOpenChoice is set */}\n {/* shuffle all other options here if question.shuffleOptions is set */}\n {/* Always ensure that the open ended choice is the last option */}\n {choices.map((choice: string, idx: number) => {\n let choiceClass = 'choice-option'\n const val = choice\n const option = choice\n if (!!question.hasOpenChoice && idx === question.choices.length - 1) {\n choiceClass += ' choice-option-open'\n }\n return (\n <div className={choiceClass}>\n <input\n type={inputType}\n id={`surveyQuestion${displayQuestionIndex}Choice${idx}`}\n name={`question${displayQuestionIndex}`}\n value={val}\n disabled={!val}\n onInput={() => {\n if (question.hasOpenChoice && idx === question.choices.length - 1) {\n return setOpenChoiceSelected(!openChoiceSelected)\n }\n if (question.type === SurveyQuestionType.SingleChoice) {\n return setSelectedChoices(val)\n }\n if (\n question.type === SurveyQuestionType.MultipleChoice &&\n isArray(selectedChoices)\n ) {\n if (selectedChoices.includes(val)) {\n // filter out values because clicking on a selected choice should deselect it\n return setSelectedChoices(\n selectedChoices.filter((choice) => choice !== val)\n )\n }\n return setSelectedChoices([...selectedChoices, val])\n }\n }}\n />\n <label\n htmlFor={`surveyQuestion${displayQuestionIndex}Choice${idx}`}\n style={{ color: 'black' }}\n >\n {question.hasOpenChoice && idx === question.choices.length - 1 ? (\n <>\n <span>{option}:</span>\n <input\n type=\"text\"\n id={`surveyQuestion${displayQuestionIndex}Choice${idx}Open`}\n name={`question${displayQuestionIndex}`}\n onInput={(e) => {\n const userValue = e.currentTarget.value\n if (question.type === SurveyQuestionType.SingleChoice) {\n return setSelectedChoices(userValue)\n }\n if (\n question.type === SurveyQuestionType.MultipleChoice &&\n isArray(selectedChoices)\n ) {\n return setOpenEndedInput(userValue)\n }\n }}\n />\n </>\n ) : (\n option\n )}\n </label>\n <span className=\"choice-check\" style={{ color: 'black' }}>\n {checkSVG}\n </span>\n </div>\n )\n })}\n </div>\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={\n (isNull(selectedChoices) ||\n (isArray(selectedChoices) && !openChoiceSelected && selectedChoices.length === 0) ||\n (isArray(selectedChoices) &&\n openChoiceSelected &&\n !openEndedInput &&\n selectedChoices.length === 0 &&\n !question.optional)) &&\n !question.optional\n }\n appearance={appearance}\n onSubmit={() => {\n if (openChoiceSelected && question.type === SurveyQuestionType.MultipleChoice) {\n if (isArray(selectedChoices)) {\n onSubmit([...selectedChoices, openEndedInput])\n }\n } else {\n onSubmit(selectedChoices)\n }\n }}\n onPreviewSubmit={() => {\n if (openChoiceSelected && question.type === SurveyQuestionType.MultipleChoice) {\n if (isArray(selectedChoices)) {\n onPreviewSubmit([...selectedChoices, openEndedInput])\n }\n } else {\n onPreviewSubmit(selectedChoices)\n }\n }}\n />\n </div>\n )\n}\n\nconst threeScaleEmojis = [dissatisfiedEmoji, neutralEmoji, satisfiedEmoji]\nconst fiveScaleEmojis = [veryDissatisfiedEmoji, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, verySatisfiedEmoji]\nconst fiveScaleNumbers = [1, 2, 3, 4, 5]\nconst sevenScaleNumbers = [1, 2, 3, 4, 5, 6, 7]\nconst tenScaleNumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\nfunction getScaleNumbers(scale: number): number[] {\n switch (scale) {\n case 5:\n return fiveScaleNumbers\n case 7:\n return sevenScaleNumbers\n case 10:\n return tenScaleNumbers\n default:\n return fiveScaleNumbers\n }\n}\n","import { PostHog } from '../posthog-core'\nimport { doesSurveyUrlMatch } from '../posthog-surveys'\nimport {\n Survey,\n SurveyAppearance,\n SurveyQuestion,\n SurveyQuestionBranchingType,\n SurveyQuestionType,\n SurveyRenderReason,\n SurveyType,\n} from '../posthog-surveys-types'\n\nimport * as Preact from 'preact'\nimport { useContext, useEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { addEventListener } from '../utils'\nimport { document as _document, window as _window } from '../utils/globals'\nimport { createLogger } from '../utils/logger'\nimport { isNull, isNumber } from '../utils/type-utils'\nimport { createWidgetShadow, createWidgetStyle } from './surveys-widget'\nimport { ConfirmationMessage } from './surveys/components/ConfirmationMessage'\nimport { Cancel } from './surveys/components/QuestionHeader'\nimport {\n LinkQuestion,\n MultipleChoiceQuestion,\n OpenTextQuestion,\n RatingQuestion,\n} from './surveys/components/QuestionTypes'\nimport {\n createShadow,\n defaultSurveyAppearance,\n dismissedSurveyEvent,\n getContrastingTextColor,\n getDisplayOrderQuestions,\n getSurveyResponseKey,\n getSurveySeen,\n hasWaitPeriodPassed,\n sendSurveyEvent,\n style,\n SURVEY_DEFAULT_Z_INDEX,\n SurveyContext,\n} from './surveys/surveys-utils'\nimport { prepareStylesheet } from './utils/stylesheet-loader'\nconst logger = createLogger('[Surveys]')\n\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\n\nfunction getPosthogWidgetClass(surveyId: string) {\n return `.PostHogWidget${surveyId}`\n}\n\nfunction getRatingBucketForResponseValue(responseValue: number, scale: number) {\n if (scale === 3) {\n if (responseValue < 1 || responseValue > 3) {\n throw new Error('The response must be in range 1-3')\n }\n\n return responseValue === 1 ? 'negative' : responseValue === 2 ? 'neutral' : 'positive'\n } else if (scale === 5) {\n if (responseValue < 1 || responseValue > 5) {\n throw new Error('The response must be in range 1-5')\n }\n\n return responseValue <= 2 ? 'negative' : responseValue === 3 ? 'neutral' : 'positive'\n } else if (scale === 7) {\n if (responseValue < 1 || responseValue > 7) {\n throw new Error('The response must be in range 1-7')\n }\n\n return responseValue <= 3 ? 'negative' : responseValue === 4 ? 'neutral' : 'positive'\n } else if (scale === 10) {\n if (responseValue < 0 || responseValue > 10) {\n throw new Error('The response must be in range 0-10')\n }\n\n return responseValue <= 6 ? 'detractors' : responseValue <= 8 ? 'passives' : 'promoters'\n }\n\n throw new Error('The scale must be one of: 3, 5, 7, 10')\n}\n\nexport function getNextSurveyStep(\n survey: Survey,\n currentQuestionIndex: number,\n response: string | string[] | number | null\n) {\n const question = survey.questions[currentQuestionIndex]\n const nextQuestionIndex = currentQuestionIndex + 1\n\n if (!question.branching?.type) {\n if (currentQuestionIndex === survey.questions.length - 1) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n\n if (question.branching.type === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n } else if (question.branching.type === SurveyQuestionBranchingType.SpecificQuestion) {\n if (Number.isInteger(question.branching.index)) {\n return question.branching.index\n }\n } else if (question.branching.type === SurveyQuestionBranchingType.ResponseBased) {\n // Single choice\n if (question.type === SurveyQuestionType.SingleChoice) {\n // :KLUDGE: for now, look up the choiceIndex based on the response\n // TODO: once QuestionTypes.MultipleChoiceQuestion is refactored, pass the selected choiceIndex into this method\n const selectedChoiceIndex = question.choices.indexOf(`${response}`)\n\n if (question.branching?.responseValues?.hasOwnProperty(selectedChoiceIndex)) {\n const nextStep = question.branching.responseValues[selectedChoiceIndex]\n\n // Specific question\n if (Number.isInteger(nextStep)) {\n return nextStep\n }\n\n if (nextStep === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n } else if (question.type === SurveyQuestionType.Rating) {\n if (typeof response !== 'number' || !Number.isInteger(response)) {\n throw new Error('The response type must be an integer')\n }\n\n const ratingBucket = getRatingBucketForResponseValue(response, question.scale)\n\n if (question.branching?.responseValues?.hasOwnProperty(ratingBucket)) {\n const nextStep = question.branching.responseValues[ratingBucket]\n\n // Specific question\n if (Number.isInteger(nextStep)) {\n return nextStep\n }\n\n if (nextStep === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n }\n\n return nextQuestionIndex\n }\n\n logger.warn('Falling back to next question index due to unexpected branching type')\n return nextQuestionIndex\n}\n\nexport class SurveyManager {\n private posthog: PostHog\n private surveyInFocus: string | null\n\n constructor(posthog: PostHog) {\n this.posthog = posthog\n // This is used to track the survey that is currently in focus. We only show one survey at a time.\n this.surveyInFocus = null\n }\n\n private canShowNextEventBasedSurvey = (): boolean => {\n // with event based surveys, we need to show the next survey without reloading the page.\n // A simple check for div elements with the class name pattern of PostHogSurvey_xyz doesn't work here\n // because preact leaves behind the div element for any surveys responded/dismissed with a <style> node.\n // To alleviate this, we check the last div in the dom and see if it has any elements other than a Style node.\n // if the last PostHogSurvey_xyz div has only one style node, we can show the next survey in the queue\n // without reloading the page.\n const surveyPopups = document.querySelectorAll(`div[class^=PostHogSurvey]`)\n if (surveyPopups.length > 0) {\n return surveyPopups[surveyPopups.length - 1].shadowRoot?.childElementCount === 1\n }\n return true\n }\n\n private handlePopoverSurvey = (survey: Survey): void => {\n const surveyWaitPeriodInDays = survey.conditions?.seenSurveyWaitPeriodInDays\n const lastSeenSurveyDate = localStorage.getItem(`lastSeenSurveyDate`)\n\n if (!hasWaitPeriodPassed(lastSeenSurveyDate, surveyWaitPeriodInDays)) {\n return\n }\n\n const surveySeen = getSurveySeen(survey)\n if (!surveySeen) {\n this.addSurveyToFocus(survey.id)\n const shadow = createShadow(style(survey?.appearance), survey.id, undefined, this.posthog)\n Preact.render(\n <SurveyPopup\n key={'popover-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n isPopup={true}\n />,\n shadow\n )\n }\n }\n\n private handleWidget = (survey: Survey): void => {\n const shadow = createWidgetShadow(survey, this.posthog)\n\n const stylesheetContent = style(survey.appearance)\n const stylesheet = prepareStylesheet(document, stylesheetContent, this.posthog)\n\n if (stylesheet) {\n shadow.appendChild(stylesheet)\n }\n\n Preact.render(\n <FeedbackWidget\n key={'feedback-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n />,\n shadow\n )\n }\n\n private handleWidgetSelector = (survey: Survey): void => {\n const selectorOnPage =\n survey.appearance?.widgetSelector && document.querySelector(survey.appearance.widgetSelector)\n if (selectorOnPage) {\n if (document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 0) {\n this.handleWidget(survey)\n } else if (document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 1) {\n // we have to check if user selector already has a survey listener attached to it because we always have to check if it's on the page or not\n if (!selectorOnPage.getAttribute('PHWidgetSurveyClickListener')) {\n const surveyPopup = document\n .querySelector(getPosthogWidgetClass(survey.id))\n ?.shadowRoot?.querySelector(`.survey-form`) as HTMLFormElement\n\n addEventListener(selectorOnPage, 'click', () => {\n if (surveyPopup) {\n surveyPopup.style.display = surveyPopup.style.display === 'none' ? 'block' : 'none'\n addEventListener(surveyPopup, 'PHSurveyClosed', () => {\n this.removeSurveyFromFocus(survey.id)\n surveyPopup.style.display = 'none'\n })\n }\n })\n\n selectorOnPage.setAttribute('PHWidgetSurveyClickListener', 'true')\n }\n }\n }\n }\n\n /**\n * Sorts surveys by their appearance delay in ascending order. If a survey does not have an appearance delay,\n * it is considered to have a delay of 0.\n * @param surveys\n * @returns The surveys sorted by their appearance delay\n */\n private sortSurveysByAppearanceDelay(surveys: Survey[]): Survey[] {\n return surveys.sort(\n (a, b) => (a.appearance?.surveyPopupDelaySeconds || 0) - (b.appearance?.surveyPopupDelaySeconds || 0)\n )\n }\n\n /**\n * Checks the feature flags associated with this Survey to see if the survey can be rendered.\n * @param survey\n * @param instance\n */\n public canRenderSurvey = (survey: Survey): SurveyRenderReason => {\n const renderReason: SurveyRenderReason = {\n visible: false,\n }\n\n if (survey.end_date) {\n renderReason.disabledReason = `survey was completed on ${survey.end_date}`\n return renderReason\n }\n\n if (survey.type != SurveyType.Popover) {\n renderReason.disabledReason = `Only Popover survey types can be rendered`\n return renderReason\n }\n\n const linkedFlagCheck = survey.linked_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.linked_flag_key)\n : true\n\n if (!linkedFlagCheck) {\n renderReason.disabledReason = `linked feature flag ${survey.linked_flag_key} is false`\n return renderReason\n }\n\n const targetingFlagCheck = survey.targeting_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.targeting_flag_key)\n : true\n\n if (!targetingFlagCheck) {\n renderReason.disabledReason = `targeting feature flag ${survey.targeting_flag_key} is false`\n return renderReason\n }\n\n const internalTargetingFlagCheck = survey.internal_targeting_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.internal_targeting_flag_key)\n : true\n\n if (!internalTargetingFlagCheck) {\n renderReason.disabledReason = `internal targeting feature flag ${survey.internal_targeting_flag_key} is false`\n return renderReason\n }\n\n renderReason.visible = true\n return renderReason\n }\n\n public renderSurvey = (survey: Survey, selector: Element): void => {\n Preact.render(\n <SurveyPopup\n key={'popover-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n isPopup={false}\n />,\n selector\n )\n }\n\n public callSurveysAndEvaluateDisplayLogic = (forceReload: boolean = false): void => {\n this.posthog?.getActiveMatchingSurveys((surveys) => {\n const nonAPISurveys = surveys.filter((survey) => survey.type !== 'api')\n\n // Create a queue of surveys sorted by their appearance delay. We will evaluate the display logic\n // for each survey in the queue in order, and only display one survey at a time.\n const nonAPISurveyQueue = this.sortSurveysByAppearanceDelay(nonAPISurveys)\n\n nonAPISurveyQueue.forEach((survey) => {\n // We only evaluate the display logic for one survey at a time\n if (!isNull(this.surveyInFocus)) {\n return\n }\n if (survey.type === SurveyType.Widget) {\n if (\n survey.appearance?.widgetType === 'tab' &&\n document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 0\n ) {\n this.handleWidget(survey)\n }\n if (survey.appearance?.widgetType === 'selector' && survey.appearance?.widgetSelector) {\n this.handleWidgetSelector(survey)\n }\n }\n\n if (survey.type === SurveyType.Popover && this.canShowNextEventBasedSurvey()) {\n this.handlePopoverSurvey(survey)\n }\n })\n }, forceReload)\n }\n\n private addSurveyToFocus = (id: string): void => {\n if (!isNull(this.surveyInFocus)) {\n logger.error(`Survey ${[...this.surveyInFocus]} already in focus. Cannot add survey ${id}.`)\n }\n this.surveyInFocus = id\n }\n\n private removeSurveyFromFocus = (id: string): void => {\n if (this.surveyInFocus !== id) {\n logger.error(`Survey ${id} is not in focus. Cannot remove survey ${id}.`)\n }\n this.surveyInFocus = null\n }\n\n // Expose internal state and methods for testing\n public getTestAPI() {\n return {\n addSurveyToFocus: this.addSurveyToFocus,\n removeSurveyFromFocus: this.removeSurveyFromFocus,\n surveyInFocus: this.surveyInFocus,\n canShowNextEventBasedSurvey: this.canShowNextEventBasedSurvey,\n handleWidget: this.handleWidget,\n handlePopoverSurvey: this.handlePopoverSurvey,\n handleWidgetSelector: this.handleWidgetSelector,\n sortSurveysByAppearanceDelay: this.sortSurveysByAppearanceDelay,\n }\n }\n}\n\nexport const renderSurveysPreview = ({\n survey,\n parentElement,\n previewPageIndex,\n forceDisableHtml,\n onPreviewSubmit,\n posthog,\n}: {\n survey: Survey\n parentElement: HTMLElement\n previewPageIndex: number\n forceDisableHtml?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n posthog?: PostHog\n}) => {\n const stylesheetContent = style(survey.appearance)\n const stylesheet = prepareStylesheet(document, stylesheetContent, posthog)\n\n // Remove previously attached <style>\n Array.from(parentElement.children).forEach((child) => {\n if (child instanceof HTMLStyleElement) {\n parentElement.removeChild(child)\n }\n })\n\n if (stylesheet) {\n parentElement.appendChild(stylesheet)\n }\n\n const textColor = getContrastingTextColor(\n survey.appearance?.backgroundColor || defaultSurveyAppearance.backgroundColor || 'white'\n )\n\n Preact.render(\n <SurveyPopup\n key=\"surveys-render-preview\"\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={{\n position: 'relative',\n right: 0,\n borderBottom: `1px solid ${survey.appearance?.borderColor}`,\n borderRadius: 10,\n color: textColor,\n }}\n onPreviewSubmit={onPreviewSubmit}\n previewPageIndex={previewPageIndex}\n removeSurveyFromFocus={() => {}}\n isPopup={true}\n />,\n parentElement\n )\n}\n\nexport const renderFeedbackWidgetPreview = ({\n survey,\n root,\n forceDisableHtml,\n posthog,\n}: {\n survey: Survey\n root: HTMLElement\n forceDisableHtml?: boolean\n posthog?: PostHog\n}) => {\n const stylesheetContent = createWidgetStyle(survey.appearance?.widgetColor)\n const stylesheet = prepareStylesheet(document, stylesheetContent, posthog)\n if (stylesheet) {\n root.appendChild(stylesheet)\n }\n\n Preact.render(\n <FeedbackWidget\n key={'feedback-render-preview'}\n forceDisableHtml={forceDisableHtml}\n survey={survey}\n readOnly={true}\n removeSurveyFromFocus={() => {}}\n />,\n root\n )\n}\n\n// This is the main exported function\nexport function generateSurveys(posthog: PostHog) {\n // NOTE: Important to ensure we never try and run surveys without a window environment\n if (!document || !window) {\n return\n }\n\n const surveyManager = new SurveyManager(posthog)\n surveyManager.callSurveysAndEvaluateDisplayLogic(true)\n\n // recalculate surveys every second to check if URL or selectors have changed\n setInterval(() => {\n surveyManager.callSurveysAndEvaluateDisplayLogic(false)\n }, 1000)\n return surveyManager\n}\n\ntype UseHideSurveyOnURLChangeProps = {\n survey: Pick<Survey, 'id' | 'conditions'>\n removeSurveyFromFocus: (id: string) => void\n setSurveyVisible: (visible: boolean) => void\n isPreviewMode?: boolean\n}\n\n/**\n * This hook handles URL-based survey visibility after the initial mount.\n * The initial URL check is handled by the `getActiveMatchingSurveys` method in the `PostHogSurveys` class,\n * which ensures the URL matches before displaying a survey for the first time.\n * That is the method that is called every second to see if there's a matching survey.\n *\n * This separation of concerns means:\n * 1. Initial URL matching is done by `getActiveMatchingSurveys` before displaying the survey\n * 2. Subsequent URL changes are handled here to hide the survey as the user navigates\n */\nexport function useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus,\n setSurveyVisible,\n isPreviewMode = false,\n}: UseHideSurveyOnURLChangeProps) {\n useEffect(() => {\n if (isPreviewMode || !survey.conditions?.url) {\n return\n }\n\n const checkUrlMatch = () => {\n const urlCheck = doesSurveyUrlMatch(survey)\n if (!urlCheck) {\n setSurveyVisible(false)\n return removeSurveyFromFocus(survey.id)\n }\n }\n\n // Listen for browser back/forward browser history changes\n addEventListener(window, 'popstate', checkUrlMatch)\n // Listen for hash changes, for SPA frameworks that use hash-based routing\n // The hashchange event is fired when the fragment identifier of the URL has changed (the part of the URL beginning with and following the # symbol).\n addEventListener(window, 'hashchange', checkUrlMatch)\n\n // Listen for SPA navigation\n const originalPushState = window.history.pushState\n const originalReplaceState = window.history.replaceState\n\n window.history.pushState = function (...args) {\n originalPushState.apply(this, args)\n checkUrlMatch()\n }\n\n window.history.replaceState = function (...args) {\n originalReplaceState.apply(this, args)\n checkUrlMatch()\n }\n\n return () => {\n window.removeEventListener('popstate', checkUrlMatch)\n window.removeEventListener('hashchange', checkUrlMatch)\n window.history.pushState = originalPushState\n window.history.replaceState = originalReplaceState\n }\n }, [isPreviewMode, survey, removeSurveyFromFocus, setSurveyVisible])\n}\n\nexport function usePopupVisibility(\n survey: Survey,\n posthog: PostHog | undefined,\n millisecondDelay: number,\n isPreviewMode: boolean,\n removeSurveyFromFocus: (id: string) => void\n) {\n const [isPopupVisible, setIsPopupVisible] = useState(isPreviewMode || millisecondDelay === 0)\n const [isSurveySent, setIsSurveySent] = useState(false)\n\n useEffect(() => {\n if (!posthog) {\n logger.error('usePopupVisibility hook called without a PostHog instance.')\n return\n }\n if (isPreviewMode) {\n return\n }\n\n const handleSurveyClosed = () => {\n removeSurveyFromFocus(survey.id)\n setIsPopupVisible(false)\n }\n\n const handleSurveySent = () => {\n if (!survey.appearance?.displayThankYouMessage) {\n removeSurveyFromFocus(survey.id)\n setIsPopupVisible(false)\n } else {\n setIsSurveySent(true)\n removeSurveyFromFocus(survey.id)\n if (survey.appearance?.autoDisappear) {\n setTimeout(() => {\n setIsPopupVisible(false)\n }, 5000)\n }\n }\n }\n\n const showSurvey = () => {\n // check if the url is still matching, necessary for delayed surveys, as the URL may have changed\n // since the survey was scheduled to appear\n if (!doesSurveyUrlMatch(survey)) {\n return\n }\n\n setIsPopupVisible(true)\n window.dispatchEvent(new Event('PHSurveyShown'))\n posthog.capture('survey shown', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n })\n localStorage.setItem('lastSeenSurveyDate', new Date().toISOString())\n setTimeout(() => {\n const inputField = document\n .querySelector(getPosthogWidgetClass(survey.id))\n ?.shadowRoot?.querySelector('textarea, input[type=\"text\"]') as HTMLElement\n if (inputField) {\n inputField.focus()\n }\n }, 100)\n }\n\n const handleShowSurveyWithDelay = () => {\n const timeoutId = setTimeout(() => {\n showSurvey()\n }, millisecondDelay)\n\n return () => {\n clearTimeout(timeoutId)\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed)\n window.removeEventListener('PHSurveySent', handleSurveySent)\n }\n }\n\n const handleShowSurveyImmediately = () => {\n showSurvey()\n return () => {\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed)\n window.removeEventListener('PHSurveySent', handleSurveySent)\n }\n }\n\n addEventListener(window, 'PHSurveyClosed', handleSurveyClosed)\n addEventListener(window, 'PHSurveySent', handleSurveySent)\n\n if (millisecondDelay > 0) {\n return handleShowSurveyWithDelay()\n } else {\n return handleShowSurveyImmediately()\n }\n }, [])\n\n useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus,\n setSurveyVisible: setIsPopupVisible,\n isPreviewMode,\n })\n\n return { isPopupVisible, isSurveySent, setIsPopupVisible }\n}\n\ninterface SurveyPopupProps {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n style?: React.CSSProperties\n previewPageIndex?: number | undefined\n removeSurveyFromFocus: (id: string) => void\n isPopup?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n onPopupSurveyDismissed?: () => void\n onPopupSurveySent?: () => void\n}\n\nexport function SurveyPopup({\n survey,\n forceDisableHtml,\n posthog,\n style,\n previewPageIndex,\n removeSurveyFromFocus,\n isPopup,\n onPreviewSubmit = () => {},\n onPopupSurveyDismissed = () => {},\n onPopupSurveySent = () => {},\n}: SurveyPopupProps) {\n const isPreviewMode = Number.isInteger(previewPageIndex)\n // NB: The client-side code passes the millisecondDelay in seconds, but setTimeout expects milliseconds, so we multiply by 1000\n const surveyPopupDelayMilliseconds = survey.appearance?.surveyPopupDelaySeconds\n ? survey.appearance.surveyPopupDelaySeconds * 1000\n : 0\n const { isPopupVisible, isSurveySent, setIsPopupVisible } = usePopupVisibility(\n survey,\n posthog,\n surveyPopupDelayMilliseconds,\n isPreviewMode,\n removeSurveyFromFocus\n )\n const shouldShowConfirmation = isSurveySent || previewPageIndex === survey.questions.length\n const confirmationBoxLeftStyle = style?.left && isNumber(style?.left) ? { left: style.left - 40 } : {}\n\n if (isPreviewMode) {\n style = style || {}\n style.left = 'unset'\n style.right = 'unset'\n style.transform = 'unset'\n }\n\n return isPopupVisible ? (\n <SurveyContext.Provider\n value={{\n isPreviewMode,\n previewPageIndex: previewPageIndex,\n onPopupSurveyDismissed: () => {\n dismissedSurveyEvent(survey, posthog, isPreviewMode)\n onPopupSurveyDismissed()\n },\n isPopup: isPopup || false,\n onPreviewSubmit,\n onPopupSurveySent: () => {\n onPopupSurveySent()\n },\n }}\n >\n {!shouldShowConfirmation ? (\n <Questions\n survey={survey}\n forceDisableHtml={!!forceDisableHtml}\n posthog={posthog}\n styleOverrides={style}\n />\n ) : (\n <ConfirmationMessage\n header={survey.appearance?.thankYouMessageHeader || 'Thank you!'}\n description={survey.appearance?.thankYouMessageDescription || ''}\n forceDisableHtml={!!forceDisableHtml}\n contentType={survey.appearance?.thankYouMessageDescriptionContentType}\n appearance={survey.appearance || defaultSurveyAppearance}\n styleOverrides={{ ...style, ...confirmationBoxLeftStyle }}\n onClose={() => setIsPopupVisible(false)}\n />\n )}\n </SurveyContext.Provider>\n ) : null\n}\n\nexport function Questions({\n survey,\n forceDisableHtml,\n posthog,\n styleOverrides,\n}: {\n survey: Survey\n forceDisableHtml: boolean\n posthog?: PostHog\n styleOverrides?: React.CSSProperties\n}) {\n const textColor = getContrastingTextColor(\n survey.appearance?.backgroundColor || defaultSurveyAppearance.backgroundColor\n )\n const [questionsResponses, setQuestionsResponses] = useState({})\n const { previewPageIndex, onPopupSurveyDismissed, isPopup, onPreviewSubmit, onPopupSurveySent } =\n useContext(SurveyContext)\n const [currentQuestionIndex, setCurrentQuestionIndex] = useState(previewPageIndex || 0)\n const surveyQuestions = useMemo(() => getDisplayOrderQuestions(survey), [survey])\n\n // Sync preview state\n useEffect(() => {\n setCurrentQuestionIndex(previewPageIndex ?? 0)\n }, [previewPageIndex])\n\n const onNextButtonClick = ({\n res,\n displayQuestionIndex,\n questionId,\n }: {\n res: string | string[] | number | null\n displayQuestionIndex: number\n questionId?: string\n }) => {\n if (!posthog) {\n logger.error('onNextButtonClick called without a PostHog instance.')\n return\n }\n\n if (!questionId) {\n logger.error('onNextButtonClick called without a questionId.')\n return\n }\n\n const responseKey = getSurveyResponseKey(questionId)\n\n setQuestionsResponses({ ...questionsResponses, [responseKey]: res })\n\n const nextStep = getNextSurveyStep(survey, displayQuestionIndex, res)\n if (nextStep === SurveyQuestionBranchingType.End) {\n sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog)\n onPopupSurveySent()\n } else {\n setCurrentQuestionIndex(nextStep)\n }\n }\n\n return (\n <form\n className=\"survey-form\"\n style={\n isPopup\n ? {\n color: textColor,\n borderColor: survey.appearance?.borderColor,\n ...styleOverrides,\n }\n : {}\n }\n >\n {surveyQuestions.map((question, displayQuestionIndex) => {\n const isVisible = currentQuestionIndex === displayQuestionIndex\n return (\n isVisible && (\n <div\n className=\"survey-box\"\n style={\n isPopup\n ? {\n backgroundColor:\n survey.appearance?.backgroundColor ||\n defaultSurveyAppearance.backgroundColor,\n }\n : {}\n }\n >\n {isPopup && (\n <Cancel\n onClick={() => {\n onPopupSurveyDismissed()\n }}\n />\n )}\n {getQuestionComponent({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance: survey.appearance || defaultSurveyAppearance,\n onSubmit: (res) =>\n onNextButtonClick({\n res,\n displayQuestionIndex,\n questionId: question.id,\n }),\n onPreviewSubmit,\n })}\n </div>\n )\n )\n })}\n </form>\n )\n}\n\nexport function FeedbackWidget({\n survey,\n forceDisableHtml,\n posthog,\n readOnly,\n removeSurveyFromFocus,\n}: {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n readOnly?: boolean\n removeSurveyFromFocus: (id: string) => void\n}): JSX.Element | null {\n const [isFeedbackButtonVisible, setIsFeedbackButtonVisible] = useState(true)\n const [showSurvey, setShowSurvey] = useState(false)\n const [styleOverrides, setStyle] = useState({})\n const widgetRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!posthog) {\n logger.error('FeedbackWidget called without a PostHog instance.')\n return\n }\n if (readOnly) {\n return\n }\n\n if (survey.appearance?.widgetType === 'tab') {\n if (widgetRef.current) {\n const widgetPos = widgetRef.current.getBoundingClientRect()\n const style = {\n top: '50%',\n left: parseInt(`${widgetPos.right - 360}`),\n bottom: 'auto',\n borderRadius: 10,\n borderBottom: `1.5px solid ${survey.appearance?.borderColor || '#c9c6c6'}`,\n }\n setStyle(style)\n }\n }\n if (survey.appearance?.widgetType === 'selector') {\n const widget = document.querySelector(survey.appearance.widgetSelector || '') ?? undefined\n\n addEventListener(widget, 'click', (event) => {\n // Calculate position based on the selector button\n const buttonRect = (event.currentTarget as HTMLElement).getBoundingClientRect()\n const viewportHeight = window.innerHeight\n\n // Get survey width from maxWidth or default to 300px\n const surveyWidth = parseInt(survey.appearance?.maxWidth || '300')\n\n // Calculate horizontal center position of the button\n const buttonCenterX = buttonRect.left + buttonRect.width / 2\n\n // Calculate horizontal center position\n let left = buttonCenterX - surveyWidth / 2\n\n // Ensure the survey doesn't go off-screen horizontally\n const rightEdge = left + surveyWidth\n if (rightEdge > window.innerWidth) {\n left = window.innerWidth - surveyWidth - 20 // 20px padding from right edge\n }\n if (left < 20) {\n left = 20 // 20px padding from left edge\n }\n\n // Determine if we should show above or below\n let showAbove = false\n\n // Check if there's enough space below (need at least 300px)\n // If not enough space below, show above\n if (buttonRect.bottom + 300 > viewportHeight) {\n showAbove = true\n }\n\n // Simple spacing between button and survey\n const spacing = 12\n\n // Calculate positions\n let topPosition\n\n if (showAbove) {\n // Problem: When showing above, we're trying to position based on an estimated height,\n // but we don't know the actual height of the survey yet.\n // Solution: Instead of using top positioning for above, use bottom positioning\n // This will anchor the survey to the bottom edge at the button's top position\n topPosition = null // We'll use bottom positioning instead\n } else {\n // When showing below, position the top of the survey below the button plus spacing\n topPosition = buttonRect.bottom + window.scrollY + spacing\n }\n\n // Set style overrides for positioning\n setStyle({\n position: 'fixed',\n top: showAbove ? 'auto' : topPosition + 'px',\n left: left + 'px',\n right: 'auto',\n bottom: showAbove ? window.innerHeight - buttonRect.top + spacing + 'px' : 'auto',\n transform: 'none',\n border: `1.5px solid ${survey.appearance?.borderColor || '#c9c6c6'}`,\n borderRadius: '10px',\n width: `${surveyWidth}px`,\n zIndex: SURVEY_DEFAULT_Z_INDEX,\n boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',\n maxHeight: showAbove\n ? `calc(100vh - 40px - ${spacing * 2}px)`\n : `calc(100vh - ${topPosition}px - 20px)`,\n })\n\n setShowSurvey(!showSurvey)\n })\n\n widget?.setAttribute('PHWidgetSurveyClickListener', 'true')\n }\n }, [])\n\n useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus,\n setSurveyVisible: setIsFeedbackButtonVisible,\n })\n\n if (!isFeedbackButtonVisible) {\n return null\n }\n\n const resetShowSurvey = () => {\n setShowSurvey(false)\n }\n\n return (\n <Preact.Fragment>\n {survey.appearance?.widgetType === 'tab' && (\n <div\n className=\"ph-survey-widget-tab\"\n ref={widgetRef}\n onClick={() => !readOnly && setShowSurvey(!showSurvey)}\n style={{ color: getContrastingTextColor(survey.appearance.widgetColor) }}\n >\n <div className=\"ph-survey-widget-tab-icon\"></div>\n {survey.appearance?.widgetLabel || ''}\n </div>\n )}\n {showSurvey && (\n <SurveyPopup\n key={'feedback-widget-survey'}\n posthog={posthog}\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={styleOverrides}\n removeSurveyFromFocus={removeSurveyFromFocus}\n isPopup={true}\n onPopupSurveyDismissed={resetShowSurvey}\n onPopupSurveySent={resetShowSurvey}\n />\n )}\n </Preact.Fragment>\n )\n}\n\ninterface GetQuestionComponentProps {\n question: SurveyQuestion\n forceDisableHtml: boolean\n displayQuestionIndex: number\n appearance: SurveyAppearance\n onSubmit: (res: string | string[] | number | null) => void\n onPreviewSubmit: (res: string | string[] | number | null) => void\n}\n\nconst getQuestionComponent = ({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: GetQuestionComponentProps): JSX.Element => {\n const questionComponents = {\n [SurveyQuestionType.Open]: OpenTextQuestion,\n [SurveyQuestionType.Link]: LinkQuestion,\n [SurveyQuestionType.Rating]: RatingQuestion,\n [SurveyQuestionType.SingleChoice]: MultipleChoiceQuestion,\n [SurveyQuestionType.MultipleChoice]: MultipleChoiceQuestion,\n }\n\n const commonProps = {\n question,\n forceDisableHtml,\n appearance,\n onPreviewSubmit: (res: string | string[] | number | null) => {\n onPreviewSubmit(res)\n },\n onSubmit: (res: string | string[] | number | null) => {\n onSubmit(res)\n },\n }\n\n const additionalProps: Record<SurveyQuestionType, any> = {\n [SurveyQuestionType.Open]: {},\n [SurveyQuestionType.Link]: {},\n [SurveyQuestionType.Rating]: { displayQuestionIndex },\n [SurveyQuestionType.SingleChoice]: { displayQuestionIndex },\n [SurveyQuestionType.MultipleChoice]: { displayQuestionIndex },\n }\n\n const Component = questionComponents[question.type]\n const componentProps = { ...commonProps, ...additionalProps[question.type] }\n\n return <Component {...componentProps} />\n}\n","import { PostHog } from '../posthog-core'\nimport { Survey } from '../posthog-surveys-types'\nimport { document as _document } from '../utils/globals'\nimport { SURVEY_DEFAULT_Z_INDEX } from './surveys/surveys-utils'\nimport { prepareStylesheet } from './utils/stylesheet-loader'\n\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst document = _document as Document\n\nexport function createWidgetShadow(survey: Survey, posthog?: PostHog) {\n const div = document.createElement('div')\n div.className = `PostHogWidget${survey.id}`\n const shadow = div.attachShadow({ mode: 'open' })\n const widgetStyleSheet = createWidgetStyle(survey.appearance?.widgetColor)\n\n const stylesheet = prepareStylesheet(document, widgetStyleSheet, posthog)\n if (stylesheet) {\n shadow.append(stylesheet)\n }\n\n document.body.appendChild(div)\n return shadow\n}\n\nexport function createWidgetStyle(widgetColor?: string) {\n return `\n .ph-survey-widget-tab {\n position: fixed;\n top: 50%;\n right: 0;\n background: ${widgetColor || '#e0a045'};\n color: white;\n transform: rotate(-90deg) translate(0, -100%);\n transform-origin: right top;\n min-width: 40px;\n padding: 8px 12px;\n font-weight: 500;\n border-radius: 3px 3px 0 0;\n text-align: center;\n cursor: pointer;\n z-index: ${SURVEY_DEFAULT_Z_INDEX};\n }\n .ph-survey-widget-tab:hover {\n padding-bottom: 13px;\n }\n .ph-survey-widget-button {\n position: fixed;\n }\n `\n}\n"],"names":["SurveyType","SurveyQuestionType","SurveyQuestionBranchingType","SurveySchedule","SURVEYS_ACTIVATED","EMPTY_OBJ","EMPTY_ARR","IS_NON_DIMENSIONAL","__u","win","window","undefined","global","globalThis","nativeForEach","Array","prototype","forEach","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","Compression","assignableWindow","nativeIsArray","isArray","toString","Object","obj","call","isUndefined","x","isNull","isNumber","_createLogger","prefix","logger","_log","level","console","consoleLog","_len","arguments","length","args","_key","info","_len2","_key2","warn","_len3","_key3","error","_len4","_key4","critical","_len5","_key5","uninitializedWarning","methodName","concat","createLogger","additionalPrefix","prepareStylesheet","innerText","posthog","_posthog$config","stylesheet","createElement","config","prepare_external_dependency_stylesheet","_window","SurveySeenPrefix","SURVEY_DEFAULT_Z_INDEX","getFontFamily","fontFamily","defaultFontStack","hex2rgb","c","hexColor","replace","parseInt","slice","getContrastingTextColor","rgb","color","defaultBackgroundColor","startsWith","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","toLowerCase","colorMatch","match","r","g","b","Math","sqrt","defaultSurveyAppearance","backgroundColor","submitButtonColor","submitButtonTextColor","ratingButtonColor","ratingButtonActiveColor","borderColor","placeholder","whiteLabel","displayThankYouMessage","thankYouMessageHeader","position","sendSurveyEvent","_posthog$get_session_","responses","survey","localStorage","setItem","getSurveySeenKey","capture","_objectSpread","$survey_name","name","$survey_id","id","$survey_iteration","current_iteration","$survey_iteration_start_date","current_iteration_start_date","$survey_questions","questions","map","question","index","sessionRecordingUrl","get_session_replay_url","$set","getSurveyInteractionProperty","dispatchEvent","Event","dismissedSurveyEvent","readOnly","_posthog$get_session_2","shuffle","array","a","sort","floor","random","value","reverseIfUnshuffled","unshuffled","shuffled","every","val","reverse","getDisplayOrderQuestions","appearance","shuffleQuestions","surveySeenKey","action","surveyProperty","SurveyContext","createContext","isPreviewMode","previewPageIndex","onPopupSurveyDismissed","isPopup","onPreviewSubmit","onPopupSurveySent","renderChildrenAsTextOrHtml","_ref","component","children","renderAsHtml","style","cloneElement","dangerouslySetInnerHTML","__html","breaker","eachArray","iterator","thisArg","i","l","addEventListener","element","event","callback","options","passive","source","item","push","extendArray","isMatchingRegex","pattern","str","RegExp","_unused","isValidRegex","test","_unused2","SimpleEventEmitter","constructor","_defineProperty","this","events","on","listener","filter","emit","payload","ActionMatcher","instance","step","checkStepEvent","checkStepUrl","checkStepElement","actionEvents","Set","actionRegistry","init","_this$instance","_addCaptureHook","_this$instance2","matchEventToAction","eventName","eventPayload","register","actions","_this$instance3","_this$instance4","_this$actionRegistry","_action$steps","add","steps","_this$actionEvents","autocapture","_this$instance5","selectorsToWatch","_action$steps2","selector","setElementSelectors","_this$actionRegistry2","has","size","checkAction","_debugEventEmitter","_addActionHook","onAction","data","checkStep","cb","url","_event$properties","eventUrl","properties","$current_url","matchString","url_matching","matching","adjustedRegExpStringPattern","escapeStringRegexp","href","tag_name","text","getElementsList","some","href_matching","text_matching","$el_text","_event$properties2","elementSelectors","$element_selectors","includes","$elements","SurveyEventReceiver","eventToSurveys","Map","actionToSurveys","surveys","setupEventBasedSurveys","setupActionBasedSurveys","actionBasedSurveys","_survey$conditions","_survey$conditions2","_survey$conditions2$a","_survey$conditions2$a2","conditions","values","actionMatcher","actionName","_survey$conditions3","_survey$conditions4","_survey$conditions4$a","_survey$conditions5","_survey$conditions5$a","_survey$conditions5$a2","_this$actionMatcher","_survey$conditions6","_survey$conditions6$a","_survey$conditions6$a2","knownSurveys","get","set","_survey$conditions7","_survey$conditions8","_survey$conditions8$e","_survey$conditions8$e2","matchEventToSurvey","onEvent","_survey$conditions9","_survey$conditions9$e","_survey$conditions9$e2","_this$instance3$persi","existingActivatedSurveys","persistence","props","SURVEY_SHOWN_EVENT_NAME","_eventPayload$propert","surveyId","indexOf","splice","_updateActivatedSurveys","_this$instance4$persi","activatedSurveys","_this$instance5$persi","getSurveys","_this$instance6","_this$instance6$persi","getEventToSurveys","_getActionMatcher","surveyValidationMap","icontains","targets","target","not_icontains","regex","not_regex","exact","is_not","doesSurveyUrlMatch","_window$location","matchType","urlMatchType","currentIndex","currentComponent","previousComponent","prevRaf","currentHook","afterPaintEffects","EMPTY","oldBeforeDiff","__b","oldBeforeRender","__r","oldAfterDiff","diffed","oldCommit","__c","oldBeforeUnmount","unmount","getHookState","type","__h","hooks","__H","__","__V","useState","initialState","useReducer","reducer","hookState","_reducer","invokeOrReturn","n","currentValue","__N","nextValue","setState","_hasScuFromHooks","updateHookState","f","p","s","stateHooks","prevScu","shouldUpdate","hookItem","shouldComponentUpdate","prevCWU","componentWillUpdate","__e","tmp","useEffect","state","__s","argsChanged","_pendingArgs","useRef","initialValue","useMemo","current","factory","useContext","context","provider","sub","flushAfterPaintEffects","shift","__P","invokeCleanup","invokeEffect","e","__v","vnode","t","requestAnimationFrame","afterNextFrame","commitQueue","hasErrored","HAS_RAF","raf","done","clearTimeout","timeout","cancelAnimationFrame","setTimeout","hook","comp","cleanup","oldArgs","newArgs","arg","satisfiedEmoji","_jsx","className","xmlns","height","viewBox","width","d","neutralEmoji","dissatisfiedEmoji","veryDissatisfiedEmoji","verySatisfiedEmoji","cancelSVG","fill","IconPosthogLogo","_jsxs","maskType","maskUnits","y","mask","transform","checkSVG","PostHogLogo","rel","BottomSection","submitDisabled","onSubmit","link","textColor","disabled","onClick","open","QuestionHeader","description","descriptionContentType","forceDisableHtml","h","Cancel","_ref2","ConfirmationMessage","header","contentType","onClose","styleOverrides","_Fragment","thankYouMessageCloseButtonText","useContrastingTextColor","_options$defaultTextC","ref","setTextColor","defaultTextColor","el","getComputedStyle","getTextColor","forceUpdate","OpenTextQuestion","textRef","setText","rows","onInput","currentTarget","buttonText","optional","LinkQuestion","RatingQuestion","_ref3","displayQuestionIndex","scale","starting","rating","setRating","display","threeScaleEmojis","fiveScaleEmojis","emoji","idx","active","gridTemplateColumns","getScaleNumbers","number","RatingButton","num","setActiveNumber","lowerBoundLabel","upperBoundLabel","submitButtonText","_ref4","MultipleChoiceQuestion","_ref5","choices","shuffleOptions","displayOrderChoices","openEndedChoice","hasOpenChoice","pop","shuffledOptions","getDisplayOrderChoices","selectedChoices","setSelectedChoices","MultipleChoice","openChoiceSelected","setOpenChoiceSelected","openEndedInput","setOpenEndedInput","inputType","SingleChoice","choice","choiceClass","option","htmlFor","userValue","fiveScaleNumbers","sevenScaleNumbers","tenScaleNumbers","_document","getNextSurveyStep","currentQuestionIndex","response","_question$branching","nextQuestionIndex","branching","End","SpecificQuestion","Number","isInteger","ResponseBased","_question$branching2","_question$branching2$","selectedChoiceIndex","responseValues","hasOwnProperty","nextStep","Rating","_question$branching3","_question$branching3$","Error","ratingBucket","responseValue","getRatingBucketForResponseValue","renderSurveysPreview","_survey$appearance5","_survey$appearance6","parentElement","stylesheetContent","maxWidth","zIndex","left","right","center","disabledButtonOpacity","from","child","HTMLStyleElement","removeChild","appendChild","Preact","SurveyPopup","borderBottom","borderRadius","removeSurveyFromFocus","renderFeedbackWidgetPreview","_survey$appearance7","widgetColor","root","FeedbackWidget","useHideSurveyOnURLChange","setSurveyVisible","checkUrlMatch","originalPushState","history","pushState","originalReplaceState","replaceState","apply","removeEventListener","_survey$appearance10","_style","_style2","_survey$appearance11","_survey$appearance12","_survey$appearance13","surveyPopupDelayMilliseconds","surveyPopupDelaySeconds","isPopupVisible","isSurveySent","setIsPopupVisible","millisecondDelay","setIsSurveySent","timeoutId","handleSurveyClosed","handleSurveySent","_survey$appearance8","_survey$appearance9","autoDisappear","showSurvey","Date","toISOString","_document$querySelect3","_document$querySelect4","inputField","querySelector","shadowRoot","focus","usePopupVisibility","shouldShowConfirmation","confirmationBoxLeftStyle","Provider","thankYouMessageDescription","thankYouMessageDescriptionContentType","Questions","_survey$appearance14","_survey$appearance15","questionsResponses","setQuestionsResponses","setCurrentQuestionIndex","surveyQuestions","_survey$appearance16","getQuestionComponent","res","_ref6","questionId","responseKey","getSurveyResponseKey","onNextButtonClick","_ref7","_survey$appearance22","_survey$appearance23","isFeedbackButtonVisible","setIsFeedbackButtonVisible","setShowSurvey","setStyle","widgetRef","_survey$appearance17","_survey$appearance19","widgetType","_survey$appearance18","widgetPos","getBoundingClientRect","top","bottom","_document$querySelect5","widget","widgetSelector","_survey$appearance20","_survey$appearance21","buttonRect","viewportHeight","innerHeight","surveyWidth","innerWidth","showAbove","topPosition","scrollY","border","boxShadow","maxHeight","spacing","setAttribute","resetShowSurvey","widgetLabel","_ref8","questionComponents","Open","Link","commonProps","additionalProps","Component","componentProps"],"mappings":"urBAqCO,oBCMKA,EA4CAC,EAQAC,EAoDAC,ED9GCC,EAAoB,qBEzBpBC,EAAgC,CAAA,EAChCC,EAAY,GACZC,EACZ,06CAd2B,sCAAA,uoBAML,8EAFK,iFAAAC,KAAA,qIAEL,gTAFK,oeAEL,qEAAA,iFAAA,mxCAJO,iBAFF,kyDASF,sGATE,w2GD8C3B,SAJWR,GAAAA,EAAU,QAAA,UAAVA,EAAU,IAAA,MAAVA,EAAU,OAAA,QAAVA,CAIX,CAJWA,IAAAA,EAAU,CAAA,IAkDrB,SANWC,GAAAA,EAAkB,KAAA,OAAlBA,EAAkB,eAAA,kBAAlBA,EAAkB,aAAA,gBAAlBA,EAAkB,OAAA,SAAlBA,EAAkB,KAAA,MAAlBA,CAMX,CANWA,IAAAA,EAAkB,CAAA,IAa7B,SALWC,GAAAA,EAA2B,aAAA,gBAA3BA,EAA2B,IAAA,MAA3BA,EAA2B,cAAA,iBAA3BA,EAA2B,iBAAA,mBAA3BA,CAKX,CALWA,IAAAA,EAA2B,CAAA,IAwDtC,SAJWC,GAAAA,EAAc,KAAA,OAAdA,EAAc,UAAA,YAAdA,EAAc,OAAA,QAAdA,CAIX,CAJWA,IAAAA,EAAc,CAAA,IE5H1B,IAAMM,EAAkE,oBAAXC,OAAyBA,YAASC,EA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L,EAAc,CAChBxjB,WACAmV,mBACA1T,aACAW,gBAAkBse,IACdte,EAAgBse,EAAI,EAExBhM,SAAWgM,IACPhM,EAASgM,EAAI,GAIf+C,EAAmD,CACrD,CAACv0B,EAAmBo0B,MAAO,CAAE,EAC7B,CAACp0B,EAAmBq0B,MAAO,CAAE,EAC7B,CAACr0B,EAAmBksB,QAAS,CAAElE,wBAC/B,CAAChoB,EAAmBuqB,cAAe,CAAEvC,wBACrC,CAAChoB,EAAmBiqB,gBAAiB,CAAEjC,yBAGrCwM,EAAYL,EAAmBrjB,EAASwO,MACxCmV,EAAcvkB,EAAAA,EAAQokB,CAAAA,EAAAA,GAAgBC,EAAgBzjB,EAASwO,OAErE,OAAOyE,GAACyQ,EAAStkB,EAAKukB,CAAAA,EAAAA,GAAkB","x_google_ignoreList":[2,16]}
|
|
1
|
+
{"version":3,"file":"surveys-preview.js","sources":["../src/constants.ts","../src/posthog-surveys-types.ts","../node_modules/.pnpm/preact@10.19.3/node_modules/preact/dist/preact.module.js","../src/utils/globals.ts","../src/types.ts","../src/utils/type-utils.ts","../src/utils/logger.ts","../src/extensions/utils/stylesheet-loader.ts","../src/extensions/surveys/surveys-utils.tsx","../src/utils/index.ts","../src/utils/event-utils.ts","../src/utils/regex-utils.ts","../src/utils/simple-event-emitter.ts","../src/extensions/surveys/action-matcher.ts","../src/utils/survey-event-receiver.ts","../src/posthog-surveys.ts","../node_modules/.pnpm/preact@10.19.3/node_modules/preact/hooks/dist/hooks.module.js","../src/extensions/surveys/icons.tsx","../src/extensions/surveys/components/PostHogLogo.tsx","../src/extensions/surveys/components/BottomSection.tsx","../src/extensions/surveys/components/QuestionHeader.tsx","../src/extensions/surveys/components/ConfirmationMessage.tsx","../src/extensions/surveys/hooks/useContrastingTextColor.ts","../src/extensions/surveys/components/QuestionTypes.tsx","../src/extensions/surveys.tsx","../src/extensions/surveys-widget.ts"],"sourcesContent":["/*\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 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 WEB_VITALS_ENABLED_SERVER_SIDE = '$web_vitals_enabled_server_side'\nexport const DEAD_CLICKS_ENABLED_SERVER_SIDE = '$dead_clicks_enabled_server_side'\nexport const WEB_VITALS_ALLOWED_METRICS = '$web_vitals_allowed_metrics'\nexport const SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side'\nexport const CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = '$console_log_recording_enabled_server_side'\nexport const SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE = '$session_recording_network_payload_capture'\nexport const SESSION_RECORDING_MASKING = '$session_recording_masking'\nexport const SESSION_RECORDING_CANVAS_RECORDING = '$session_recording_canvas_recording'\nexport const SESSION_RECORDING_SAMPLE_RATE = '$replay_sample_rate'\nexport const SESSION_RECORDING_MINIMUM_DURATION = '$replay_minimum_duration'\nexport const SESSION_RECORDING_SCRIPT_CONFIG = '$replay_script_config'\nexport const SESSION_ID = '$sesid'\nexport const SESSION_RECORDING_IS_SAMPLED = '$session_is_sampled'\nexport const SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION = '$session_recording_url_trigger_activated_session'\nexport const SESSION_RECORDING_URL_TRIGGER_STATUS = '$session_recording_url_trigger_status'\nexport const SESSION_RECORDING_EVENT_TRIGGER_ACTIVATED_SESSION = '$session_recording_event_trigger_activated_session'\nexport const SESSION_RECORDING_EVENT_TRIGGER_STATUS = '$session_recording_event_trigger_status'\nexport const ENABLED_FEATURE_FLAGS = '$enabled_feature_flags'\nexport const PERSISTENCE_EARLY_ACCESS_FEATURES = '$early_access_features'\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 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 USER_STATE,\n PERSISTENCE_EARLY_ACCESS_FEATURES,\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]\n\nexport const SURVEYS_REQUEST_TIMEOUT_MS = 10000\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\nexport interface SurveyAppearance {\n // keep in sync with frontend/src/types.ts -> SurveyAppearance\n backgroundColor?: string\n submitButtonColor?: string\n // text color is deprecated, use auto contrast text color instead\n textColor?: string\n // deprecate submit button text eventually\n submitButtonText?: string\n submitButtonTextColor?: string\n descriptionTextColor?: string\n ratingButtonColor?: string\n ratingButtonActiveColor?: string\n ratingButtonHoverColor?: string\n whiteLabel?: boolean\n autoDisappear?: boolean\n displayThankYouMessage?: boolean\n thankYouMessageHeader?: string\n thankYouMessageDescription?: string\n thankYouMessageDescriptionContentType?: SurveyQuestionDescriptionContentType\n thankYouMessageCloseButtonText?: string\n borderColor?: string\n position?: 'left' | 'right' | 'center'\n placeholder?: string\n shuffleQuestions?: boolean\n surveyPopupDelaySeconds?: number\n // widget options\n widgetType?: 'button' | 'tab' | 'selector'\n widgetSelector?: string\n widgetLabel?: string\n widgetColor?: string\n fontFamily?: string\n // questionable: Not in frontend/src/types.ts -> SurveyAppearance, but used in site app\n maxWidth?: string\n zIndex?: string\n disabledButtonOpacity?: string\n}\n\nexport enum SurveyType {\n Popover = 'popover',\n API = 'api',\n Widget = 'widget',\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}\n\nexport interface MultipleSurveyQuestion extends SurveyQuestionBase {\n type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice\n choices: string[]\n hasOpenChoice?: boolean\n shuffleOptions?: 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 interface SurveyResponse {\n surveys: Survey[]\n}\n\nexport type SurveyCallback = (surveys: Survey[]) => void\n\nexport type SurveyMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains'\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 linked_flag_key: string | null\n targeting_flag_key: string | null\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?: SurveyMatchType\n events: {\n repeatedActivation?: boolean\n values: {\n name: string\n }[]\n } | null\n actions: {\n values: SurveyActionType[]\n } | null\n deviceTypes?: string[]\n deviceTypesMatchType?: SurveyMatchType\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}\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 /** @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}\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","import { ErrorProperties } from '../extensions/exception-autocapture/error-conversion'\nimport type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ErrorConversionArgs,\n ErrorMetadata,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n} from '../types'\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 Record<string, any> & {\n __PosthogExtensions__?: PostHogExtensions\n\n _POSTHOG_REMOTE_CONFIG?: Record<\n string,\n {\n config: RemoteConfig\n siteApps: SiteAppLoader[]\n }\n >\n }\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 PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\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 parseErrorAsProperties?: ({ error, event }: ErrorConversionArgs, metadata?: ErrorMetadata) => ErrorProperties\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: Properties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: Properties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n canActivateRepeatedly?: (survey: any) => boolean\n generateSurveys?: (posthog: PostHog) => 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: (sessionManager?: SessionIdManager) => () => void\n _patchXHR: (sessionManager?: SessionIdManager) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\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","import type { recordOptions } from './extensions/replay/types/rrweb'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\nimport { PostHog } from './posthog-core'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'\n\nexport const 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] as const\n\n/**\n * These events can be processed by the `beforeCapture` function\n * but can cause unexpected confusion in data.\n *\n * Some features of PostHog rely on receiving 100% of these events\n */\nexport type KnownUnsafeEditableEvent = (typeof knownUnsafeEditableEvent)[number]\n\n/**\n * These are known events PostHog events that can be processed by the `beforeCapture` function\n * That means PostHog functionality does not rely on receiving 100% of these for calculations\n * So, it is safe to sample them to reduce the volume of events sent to PostHog\n */\nexport type KnownEventName =\n | '$heatmaps_data'\n | '$opt_in'\n | '$exception'\n | '$$heatmap'\n | '$web_vitals'\n | '$dead_click'\n | '$autocapture'\n | typeof COPY_AUTOCAPTURE_EVENT\n | '$rageclick'\n\nexport type EventName =\n | KnownUnsafeEditableEvent\n | KnownEventName\n // magic value so that the type of EventName is a set of known strings or any other string\n // which means you get autocomplete for known strings\n // but no type complaints when you add an arbitrary string\n | (string & {})\n\nexport interface CaptureResult {\n uuid: string\n event: EventName\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on specific pages only\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_allowlist?: (string | RegExp)[]\n\n /**\n * List of URLs to not allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on most pages but not some specific ones\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_ignorelist?: (string | RegExp)[]\n\n /**\n * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']\n */\n dom_event_allowlist?: DomAutocaptureEvents[]\n\n /**\n * List of DOM elements to allow autocapture on\n * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']\n *\n * We consider the tree of elements from the root to the target element of the click event\n * so for the tree `div > div > button > svg`\n * if the allowlist has `button` then we allow the capture when the `button` or the `svg` is the click target\n * but not if either of the `div`s are detected as the click target\n */\n element_allowlist?: AutocaptureCompatibleElement[]\n\n /**\n * List of CSS selectors to allow autocapture on\n * e.g. ['[ph-capture]']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * and allow list config `['[id]']`\n * we will capture the click if the click-target or its parents has any id\n *\n * Everything is allowed when there's no allowlist\n */\n css_selector_allowlist?: string[]\n\n /**\n * Exclude certain element attributes from autocapture\n * E.g. ['aria-label'] or [data-attr-pii]\n */\n element_attribute_ignorelist?: string[]\n\n /**\n * When set to true, autocapture will capture the text of any element that is cut or copied.\n */\n capture_copied_text?: boolean\n}\n\nexport interface BootstrapConfig {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n\n /**\n * Optionally provide a sessionID, this is so that you can provide an existing sessionID here to continue a user's session across a domain or device. It MUST be:\n * - unique to this user\n * - a valid UUID v7\n * - the timestamp part must be <= the timestamp of the first event in the session\n * - the timestamp of the last event in the session must be < the timestamp part + 24 hours\n * **/\n sessionID?: string\n}\n\nexport type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP'\n\nexport interface PerformanceCaptureConfig {\n /**\n * Works with session replay to use the browser's native performance observer to capture performance metrics\n */\n network_timing?: boolean\n\n /**\n * Use chrome's web vitals library to wrap fetch and capture web vitals\n */\n web_vitals?: boolean\n\n /**\n * We observe very large values reported by the Chrome web vitals library\n * These outliers are likely not real, useful values, and we exclude them\n * You can set this to 0 in order to include all values, NB this is not recommended\n *\n * @default 15 * 60 * 1000 (15 minutes)\n */\n __web_vitals_max_value?: number\n\n /**\n * By default all 4 metrics are captured\n * You can set this config to restrict which metrics are captured\n * e.g. ['CLS', 'FCP'] to only capture those two metrics\n * NB setting this does not override whether the capture is enabled\n *\n * @default ['LCP', 'CLS', 'FCP', 'INP']\n */\n web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[]\n\n /**\n * We delay flushing web vitals metrics to reduce the number of events we send\n * This is the maximum time we will wait before sending the metrics\n *\n * @default 5000\n */\n web_vitals_delayed_flush_ms?: number\n}\n\nexport interface DeadClickCandidate {\n node: Element\n originalEvent: MouseEvent\n timestamp: number\n // time between click and the most recent scroll\n scrollDelayMs?: number\n // time between click and the most recent mutation\n mutationDelayMs?: number\n // time between click and the most recent selection changed event\n selectionChangedDelayMs?: number\n // if neither scroll nor mutation seen before threshold passed\n absoluteDelayMs?: number\n}\n\nexport type DeadClicksAutoCaptureConfig = {\n /**\n * We'll not consider a click to be a dead click, if it's followed by a scroll within `scroll_threshold_ms` milliseconds\n *\n * @default 100\n */\n scroll_threshold_ms?: number\n\n /**\n * We'll not consider a click to be a dead click, if it's followed by a selection change within `selection_change_threshold_ms` milliseconds\n *\n * @default 100\n */\n selection_change_threshold_ms?: number\n\n /**\n * We'll not consider a click to be a dead click, if it's followed by a mutation within `mutation_threshold_ms` milliseconds\n *\n * @default 2500\n */\n mutation_threshold_ms?: number\n\n /**\n * Allows setting behavior for when a dead click is captured.\n * For e.g. to support capture to heatmaps\n *\n * If not provided the default behavior is to auto-capture dead click events\n *\n * Only intended to be provided by our own SDK\n */\n __onCapture?: ((click: DeadClickCandidate, properties: Properties) => void) | undefined\n} & Pick<AutocaptureConfig, 'element_attribute_ignorelist'>\n\nexport interface HeatmapConfig {\n /**\n * How often to send batched data in `$heatmap_data` events\n * If set to 0 or not set, sends using the default interval of 1 second\n *\n * @default 1000\n */\n flush_interval_milliseconds: number\n}\n\nexport type BeforeSendFn = (cr: CaptureResult | null) => CaptureResult | null\n\n/**\n * Configuration options for the PostHog JavaScript SDK.\n * @see https://posthog.com/docs/libraries/js#config\n */\nexport interface PostHogConfig {\n /** URL of your PostHog instance.\n *\n * @default 'https://us.i.posthog.com'\n */\n api_host: string\n\n /**\n * If using a reverse proxy for `api_host` then this should be the actual PostHog app URL (e.g. https://us.posthog.com).\n * This ensures that links to PostHog point to the correct host.\n *\n * @default null\n */\n ui_host: string | null\n\n /**\n * The transport method to use for API requests.\n *\n * @default 'fetch'\n */\n api_transport?: 'XHR' | 'fetch'\n\n /**\n * The token for your PostHog project.\n * It should NOT be provided manually in the config, but rather passed as the first parameter to `posthog.init()`.\n */\n token: string\n\n /**\n * The name this instance will be identified by.\n * You don't need to set this most of the time,\n * but can be useful if you have several Posthog instances running at the same time.\n *\n * @default 'posthog'\n */\n name: string\n\n /**\n * Determines whether PostHog should autocapture events.\n * This setting does not affect capturing pageview events (see `capture_pageview`).\n *\n * @default true\n */\n autocapture: boolean | AutocaptureConfig\n\n /**\n * Determines whether PostHog should capture rage clicks.\n *\n * @default true\n */\n rageclick: boolean\n\n /**\n * Determines if cookie should be set on the top level domain (example.com).\n * If PostHog-js is loaded on a subdomain (test.example.com), and `cross_subdomain_cookie` is set to false,\n * it'll set the cookie on the subdomain only (test.example.com).\n *\n * NOTE: It will be set to `false` if we detect that the domain is a subdomain of a platform that is excluded from cross-subdomain cookie setting.\n * The current list of excluded platforms is `herokuapp.com`, `vercel.app`, and `netlify.app`.\n *\n * @see `isCrossDomainCookie`\n * @default true\n */\n cross_subdomain_cookie: boolean\n\n /**\n * Determines how PostHog stores information about the user. See [persistence](https://posthog.com/docs/libraries/js#persistence) for details.\n *\n * @default 'localStorage+cookie'\n */\n persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage'\n\n /**\n * The name for the super properties persistent store\n *\n * @default ''\n */\n persistence_name: string\n\n /** @deprecated - Use 'persistence_name' instead */\n cookie_name?: string\n\n /**\n * A function to be called once the PostHog scripts have loaded successfully.\n *\n * @param posthog_instance - The PostHog instance that has been loaded.\n */\n loaded: (posthog_instance: PostHog) => void\n\n /**\n * Determines whether PostHog should save referrer information.\n *\n * @default true\n */\n save_referrer: boolean\n\n /**\n * Determines whether PostHog should save marketing parameters.\n * These are `utm_*` paramaters and friends.\n *\n * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.\n * @default true\n */\n save_campaign_params: boolean\n\n /** @deprecated - Use `save_campaign_params` instead */\n store_google?: boolean\n\n /**\n * Used to extend the list of campaign parameters that are saved by default.\n *\n * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.\n * @default []\n */\n custom_campaign_params: string[]\n\n /**\n * Used to extend the list of user agents that are blocked by default.\n *\n * @see {DEFAULT_BLOCKED_UA_STRS} from './utils/blocked-uas' - Default list of blocked user agents.\n * @default []\n */\n custom_blocked_useragents: string[]\n\n /**\n * Determines whether PostHog should be in debug mode.\n * You can enable this to get more detailed logging.\n *\n * You can also enable this on your website by appending `?__posthog_debug=true` at the end of your URL\n * You can also call `posthog.debug()` in your code to enable debug mode\n *\n * @default false\n */\n debug: boolean\n\n /** @deprecated Use `debug` instead */\n verbose?: boolean\n\n /**\n * Determines whether PostHog should capture pageview events automatically.\n *\n * @default true\n */\n capture_pageview: boolean\n\n /**\n * Determines whether PostHog should capture pageleave events.\n * If set to `true`, it will capture pageleave events for all pages.\n * If set to `'if_capture_pageview'`, it will only capture pageleave events if `capture_pageview` is also set to `true`.\n *\n * @default 'if_capture_pageview'\n */\n capture_pageleave: boolean | 'if_capture_pageview'\n\n /**\n * Determines the number of days to store cookies for.\n *\n * @default 365\n */\n cookie_expiration: number\n\n /**\n * Determines whether PostHog should upgrade old cookies.\n * If set to `true`, the library will check for a cookie from our old js library and import super properties from it, then the old cookie is deleted.\n * This option only works in the initialization, so make sure you set it when you create the library.\n *\n * @default false\n */\n upgrade: boolean\n\n /**\n * Determines whether PostHog should disable session recording.\n *\n * @default false\n */\n disable_session_recording: boolean\n\n /**\n * Determines whether PostHog should disable persistence.\n * If set to `true`, the library will not save any data to the browser. It will also delete any data previously saved to the browser.\n *\n * @default false\n */\n disable_persistence: boolean\n\n /** @deprecated - use `disable_persistence` instead */\n disable_cookie?: boolean\n\n /**\n * Determines whether PostHog should disable surveys.\n *\n * @default false\n */\n disable_surveys: boolean\n\n /**\n * Determines whether PostHog should disable web experiments.\n *\n * Currently disabled while we're in BETA. It will be toggled to `true` in a future release.\n *\n * @default true\n */\n disable_web_experiments: boolean\n\n /**\n * Determines whether PostHog should disable any external dependency loading.\n * This will prevent PostHog from requesting any external scripts such as those needed for Session Replay, Surveys or Site Apps.\n *\n * @default false\n */\n disable_external_dependency_loading: boolean\n\n /**\n * A function to be called when a script is being loaded.\n * This can be used to modify the script before it is loaded.\n * This is useful for adding a nonce to the script, for example.\n *\n * @param script - The script element that is being loaded.\n * @returns The modified script element, or null if the script should not be loaded.\n */\n prepare_external_dependency_script?: (script: HTMLScriptElement) => HTMLScriptElement | null\n\n /**\n * A function to be called when a stylesheet is being loaded.\n * This can be used to modify the stylesheet before it is loaded.\n * This is useful for adding a nonce to the stylesheet, for example.\n *\n * @param stylesheet - The stylesheet element that is being loaded.\n * @returns The modified stylesheet element, or null if the stylesheet should not be loaded.\n */\n prepare_external_dependency_stylesheet?: (stylesheet: HTMLStyleElement) => HTMLStyleElement | null\n\n /**\n * Determines whether PostHog should enable recording console logs.\n * When undefined, it falls back to the remote config setting.\n *\n * @default undefined\n */\n enable_recording_console_log?: boolean\n\n /**\n * Determines whether PostHog should use secure cookies.\n * If this is `true`, PostHog cookies will be marked as secure,\n * meaning they will only be transmitted over HTTPS.\n *\n * @default window.location.protocol === 'https:'\n */\n secure_cookie: boolean\n\n /**\n * Determines whether PostHog should capture IP addresses.\n *\n * @default true\n */\n ip: boolean\n\n /**\n * Determines if users should be opted out of PostHog tracking by default,\n * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.\n *\n * @default false\n */\n opt_out_capturing_by_default: boolean\n\n /**\n * Determines where we'll save the information about whether users are opted out of capturing.\n *\n * @default 'localStorage'\n */\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n\n /**\n * Determines if users should be opted out of browser data storage by this PostHog instance by default,\n * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.\n *\n * @default false\n */\n opt_out_persistence_by_default?: boolean\n\n /**\n * Determines if users should be opted out of user agent filtering such as googlebot or other bots.\n * If this is set to `true`, PostHog will set `$browser_type` to either `bot` or `browser` for all events,\n * but will process all events as if they were from a browser.\n *\n * @default false\n */\n opt_out_useragent_filter: boolean\n\n /**\n * Determines the prefix for the cookie used to store the information about whether users are opted out of capturing.\n * When `null`, it falls back to the default prefix found in `consent.ts`.\n *\n * @default null\n */\n opt_out_capturing_cookie_prefix: string | null\n\n /**\n * Determines if users should be opted in to site apps.\n *\n * @default false\n */\n opt_in_site_apps: boolean\n\n /**\n * Determines whether PostHog should respect the Do Not Track header when computing\n * consent in `ConsentManager`.\n *\n * @see `ConsentManager`\n * @default false\n */\n respect_dnt: boolean\n\n /**\n * A list of properties that should never be sent with capture calls.\n *\n * @default []\n */\n property_denylist: string[]\n\n /** @deprecated - use `property_denylist` instead */\n property_blacklist?: string[]\n\n /**\n * A list of headers that should be sent with requests to the PostHog API.\n *\n * @default {}\n */\n request_headers: { [header_name: string]: string }\n\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n\n /**\n * A function that is called when a request to the PostHog API fails.\n *\n * @param error - The `RequestResponse` object that occurred.\n */\n on_request_error?: (error: RequestResponse) => void\n\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n\n /**\n * Determines whether PostHog should batch requests to the PostHog API.\n *\n * @default true\n */\n request_batching: boolean\n\n /**\n * Determines the maximum length of the properties string that can be sent with capture calls.\n *\n * @default 65535\n */\n properties_string_max_length: number\n\n /**\n * Determines the session recording options.\n *\n * @see `SessionRecordingOptions`\n * @default {}\n */\n session_recording: SessionRecordingOptions\n\n /**\n * Determines the session idle timeout in seconds.\n * Any new event that's happened after this timeout will create a new session.\n *\n * @default 30 * 60 -- 30 minutes\n */\n session_idle_timeout_seconds: number\n\n /**\n * Prevent autocapture from capturing any attribute names on elements.\n *\n * @default false\n */\n mask_all_element_attributes: boolean\n\n /**\n * Prevent autocapture from capturing `textContent` on elements.\n *\n * @default false\n */\n mask_all_text: boolean\n\n /**\n * Prevent autocapture from capturing personal data properties.\n * These include campaign parameters, UTM parameters, and other parameters that could be considered personal data under e.g. GDPR.\n *\n * @default false\n */\n mask_personal_data_properties: boolean\n\n /**\n * Custom list of personal data properties to mask.\n *\n * @default []\n */\n custom_personal_data_properties: string[]\n\n /**\n * One of the very first things the PostHog library does when init() is called\n * is make a request to the /decide endpoint on PostHog's backend.\n * This endpoint contains information on how to run the PostHog library\n * so events are properly received in the backend.\n *\n * This endpoint is required to run most features of the library.\n * However, if you're not using any of the described features,\n * you may wish to turn off the call completely to avoid an extra request\n * and reduce resource usage on both the client and the server.\n *\n * @default false\n */\n advanced_disable_decide: boolean\n\n /**\n * Will keep /decide running, but without any feature flag requests\n *\n * @default false\n */\n advanced_disable_feature_flags: boolean\n\n /**\n * Stops from firing feature flag requests on first page load.\n * Only requests feature flags when user identity or properties are updated,\n * or you manually request for flags to be loaded.\n *\n * @default false\n */\n advanced_disable_feature_flags_on_first_load: boolean\n\n /**\n * Determines whether PostHog should disable toolbar metrics.\n * This is our internal instrumentation for our toolbar in your website.\n *\n * @default false\n */\n advanced_disable_toolbar_metrics: boolean\n\n /**\n * Sets timeout for fetching feature flags\n *\n * @default 3000\n */\n feature_flag_request_timeout_ms: number\n\n /**\n * Sets timeout for fetching surveys\n *\n * @default 10000\n */\n surveys_request_timeout_ms: number\n\n /**\n * Function to get the device ID.\n * This doesn't usually need to be set, but can be useful if you want to use a custom device ID.\n *\n * @param uuid - The UUID we would use for the device ID.\n * @returns The device ID.\n *\n * @default (uuid) => uuid\n */\n get_device_id: (uuid: string) => string\n\n /**\n * This function or array of functions - if provided - are called immediately before sending data to the server.\n * It allows you to edit data before it is sent, or choose not to send it all.\n * if provided as an array the functions are called in the order they are provided\n * any one function returning null means the event will not be sent\n */\n before_send?: BeforeSendFn | BeforeSendFn[]\n\n /** @deprecated - use `before_send` instead */\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n\n /** @deprecated - use `before_send` instead */\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n\n /**\n * Determines whether to capture performance metrics.\n * These include Network Timing and Web Vitals.\n *\n * When `undefined`, fallback to the remote configuration.\n * If `false`, neither network timing nor web vitals will work.\n * If an object, that will override the remote configuration.\n *\n * @see {PerformanceCaptureConfig}\n * @default undefined\n */\n capture_performance?: boolean | PerformanceCaptureConfig\n\n /**\n * Determines whether to disable compression when sending events to the server.\n * WARNING: Should only be used for testing. Could negatively impact performance.\n *\n * @default false\n */\n disable_compression: boolean\n\n /**\n * An object containing the `distinctID`, `isIdentifiedID`, and `featureFlags` keys,\n * where `distinctID` is a string, and `featureFlags` is an object of key-value pairs.\n *\n * Since there is a delay between initializing PostHog and fetching feature flags,\n * feature flags are not always available immediately.\n * This makes them unusable if you want to do something like redirecting a user\n * to a different page based on a feature flag.\n *\n * You can, therefore, fetch the feature flags in your server and pre-fill them here,\n * allowing PostHog to know the feature flag values immediately.\n *\n * After the SDK fetches feature flags from PostHog, it will use those flag values instead of bootstrapped ones.\n *\n * @default {}\n */\n bootstrap: BootstrapConfig\n\n /**\n * The segment analytics object.\n *\n * @see https://posthog.com/docs/libraries/segment\n */\n segment?: SegmentAnalytics\n\n /**\n * Determines whether to capture heatmaps.\n *\n * @see {HeatmapConfig}\n * @default undefined\n */\n capture_heatmaps?: boolean | HeatmapConfig\n\n /* @deprecated - use `capture_heatmaps` instead */\n enable_heatmaps?: boolean\n\n /**\n * Determines whether to capture dead clicks.\n *\n * @see {DeadClicksAutoCaptureConfig}\n * @default undefined\n */\n capture_dead_clicks?: boolean | DeadClicksAutoCaptureConfig\n\n /**\n * Determines whether to capture exceptions.\n *\n * @default undefined\n */\n capture_exceptions?: boolean\n\n /**\n * Determines whether to disable scroll properties.\n * These allow you to keep track of how far down someone scrolled in your website.\n *\n * @default false\n */\n disable_scroll_properties?: boolean\n\n /**\n * Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`\n * It will use `window.document.documentElement` if not specified.\n */\n scroll_root_selector?: string | string[]\n\n /**\n * You can control whether events from PostHog-js have person processing enabled with the `person_profiles` config setting.\n * There are three options:\n * - `person_profiles: 'always'` - we will process persons data for all events\n * - `person_profiles: 'never'` - we won't process persons for any event. This means that anonymous users will not be merged once they sign up or login, so you lose the ability to create funnels that track users from anonymous to identified. All events (including `$identify`) will be sent with `$process_person_profile: False`.\n * - `person_profiles: 'identified_only'` _(default)_ - we will only process persons when you call `posthog.identify`, `posthog.alias`, `posthog.setPersonProperties`, `posthog.group`, `posthog.setPersonPropertiesForFlags` or `posthog.setGroupPropertiesForFlags` Anonymous users won't get person profiles.\n *\n * @default 'identified_only'\n */\n person_profiles?: 'always' | 'never' | 'identified_only'\n\n /** @deprecated - use `person_profiles` instead */\n process_person?: 'always' | 'never' | 'identified_only'\n\n /**\n * Client side rate limiting\n */\n rate_limiting?: {\n /**\n * The average number of events per second that should be permitted\n *\n * @default 10\n */\n events_per_second?: number\n\n /**\n * How many events can be captured in a burst. This defaults to 10 times the events_per_second count\n *\n * @default 10 * `events_per_second`\n */\n events_burst_limit?: number\n }\n\n /**\n * Used when sending data via `fetch`, use with care.\n * This is intentionally meant to be used with NextJS `fetch`\n *\n * Incorrect `cache` usage may cause out-of-date data for feature flags, actions tracking, etc.\n * See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\n */\n fetch_options?: {\n cache?: RequestInit['cache']\n next_options?: NextOptions\n }\n\n /**\n * Used to change the behavior of the request queue.\n * This is an advanced feature and should be used with caution.\n */\n request_queue_config?: RequestQueueConfig\n\n // ------- PREVIEW CONFIGS -------\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Whether to wrap fetch and add tracing headers to the request\n * */\n __add_tracing_headers?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Enables the new RemoteConfig approach to loading config instead of decide\n * */\n __preview_remote_config?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Whether to send a sentinel value for distinct id, device id, and session id, which will be replaced server-side by a cookieless hash\n * */\n __preview_experimental_cookieless_mode?: boolean\n\n // ------- RETIRED CONFIGS - NO REPLACEMENT OR USAGE -------\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n api_method?: string\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n inapp_protocol?: string\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n inapp_link_new_window?: boolean\n}\n\nexport interface SessionRecordingOptions {\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-no-capture'\n */\n blockClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default null\n */\n blockSelector?: string | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-ignore-input'\n */\n ignoreClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-mask'\n */\n maskTextClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskTextSelector?: string | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskTextFn?: ((text: string, element?: HTMLElement) => string) | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskAllInputs?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskInputOptions?: recordOptions['maskInputOptions']\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default {}\n */\n slimDOMOptions?: recordOptions['slimDOMOptions']\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n collectFonts?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default true\n */\n inlineStylesheet?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordCrossOriginIframes?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordHeaders?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordBody?: boolean\n\n /**\n * Allows local config to override remote canvas recording settings from the decide response\n */\n captureCanvas?: SessionRecordingCanvasOptions\n\n /**\n * Modify the network request before it is captured. Returning null or undefined stops it being captured\n */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n\n /**\n * ADVANCED: while a user is active we take a full snapshot of the browser every interval.\n * For very few sites playback performance might be better with different interval.\n * Set to 0 to disable\n *\n * @default 1000 * 60 * 5 (5 minutes)\n */\n full_snapshot_interval_millis?: number\n\n /**\n * ADVANCED: whether to partially compress rrweb events before sending them to the server,\n * defaults to true, can be set to false to disable partial compression\n * NB requests are still compressed when sent to the server regardless of this setting\n *\n * @default true\n */\n compress_events?: boolean\n\n /**\n * ADVANCED: alters the threshold before a recording considers a user has become idle.\n * Normally only altered alongside changes to session_idle_timeout_ms.\n *\n * @default 1000 * 60 * 5 (5 minutes)\n */\n session_idle_threshold_ms?: number\n\n /**\n * ADVANCED: alters the refill rate for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 10\n */\n __mutationRateLimiterRefillRate?: number\n\n /**\n * ADVANCED: alters the bucket size for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 100\n */\n __mutationRateLimiterBucketSize?: number\n}\n\nexport type SessionIdChangedCallback = (\n sessionId: string,\n windowId: string | null | undefined,\n changeReason?: { noSessionId: boolean; activityTimeout: boolean; sessionPastMaximumLength: boolean }\n) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\n// See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\ntype NextOptions = { revalidate: false | 0 | number; tags: string[] }\n\nexport interface RequestWithOptions {\n url: string\n // Data can be a single object or an array of objects when batched\n data?: Record<string, any> | Record<string, any>[]\n headers?: Record<string, any>\n transport?: 'XHR' | 'fetch' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n callback?: RequestCallback\n timeout?: number\n noRetries?: boolean\n compression?: Compression | 'best-available'\n fetchOptions?: {\n cache?: RequestInit['cache']\n next?: NextOptions\n }\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestWithOptions extends RequestWithOptions {\n /** key of queue, e.g. 'sessionRecording' vs 'event' */\n batchKey?: string\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestWithOptions extends QueuedRequestWithOptions {\n retriesPerformedSoFar?: number\n}\n\n// we used to call a request that was sent to the queue with options attached `RequestQueueOptions`\n// so we can't call the options used to configure the behavior of the RequestQueue that as well,\n// so instead we call them config\nexport interface RequestQueueConfig {\n /**\n * ADVANCED - alters the frequency which PostHog sends events to the server.\n * generally speaking this is only set when apps have automatic page refreshes, or very short visits.\n * Defaults to 3 seconds when not set\n * Allowed values between 250 and 5000\n * */\n flush_interval_ms?: number\n}\n\nexport interface CaptureOptions {\n /**\n * Used when `$identify` is called\n * Will set person properties overriding previous values\n */\n $set?: Properties\n\n /**\n * Used when `$identify` is called\n * Will set person properties but only once, it will NOT override previous values\n */\n $set_once?: Properties\n\n /**\n * Used to override the desired endpoint for the captured event\n */\n _url?: string\n\n /**\n * key of queue, e.g. 'sessionRecording' vs 'event'\n */\n _batchKey?: string\n\n /**\n * If set, overrides and disables config.properties_string_max_length\n */\n _noTruncate?: boolean\n\n /**\n * If set, skips the batched queue\n */\n send_instantly?: boolean\n\n /**\n * If set, skips the client side rate limiting\n */\n skip_client_rate_limiting?: boolean\n\n /**\n * If set, overrides the desired transport method\n */\n transport?: RequestWithOptions['transport']\n\n /**\n * If set, overrides the current timestamp\n */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport type SessionRecordingCanvasOptions = {\n /**\n * If set, records the canvas\n *\n * @default false\n */\n recordCanvas?: boolean | null\n\n /**\n * If set, records the canvas at the given FPS\n * Can be set in the remote configuration\n * Limited between 0 and 12\n * When canvas recording is enabled, if this is not set locally, then remote config sets this as 4\n *\n * @default null-ish\n */\n canvasFps?: number | null\n\n /**\n * If set, records the canvas at the given quality\n * Can be set in the remote configuration\n * Must be a string that is a valid decimal between 0 and 1\n * When canvas recording is enabled, if this is not set locally, then remote config sets this as \"0.4\"\n *\n * @default null-ish\n */\n canvasQuality?: string | null\n}\n\n/**\n * Remote configuration for the PostHog instance\n *\n * All of these settings can be configured directly in your PostHog instance\n * Any configuration set in the client overrides the information from the server\n */\nexport interface RemoteConfig {\n /**\n * Supported compression algorithms\n */\n supportedCompression: Compression[]\n\n /**\n * If set, disables autocapture\n */\n autocapture_opt_out?: boolean\n\n /**\n * originally capturePerformance was replay only and so boolean true\n * is equivalent to { network_timing: true }\n * now capture performance can be separately enabled within replay\n * and as a standalone web vitals tracker\n * people can have them enabled separately\n * they work standalone but enhance each other\n * TODO: deprecate this so we make a new config that doesn't need this explanation\n */\n capturePerformance?: boolean | PerformanceCaptureConfig\n\n /**\n * Whether we should use a custom endpoint for analytics\n *\n * @default { endpoint: \"/e\" }\n */\n analytics?: {\n endpoint?: string\n }\n\n /**\n * Whether the `$elements_chain` property should be sent as a string or as an array\n *\n * @default false\n */\n elementsChainAsString?: boolean\n\n /**\n * This is currently in development and may have breaking changes without a major version bump\n */\n autocaptureExceptions?: boolean | { endpoint?: string }\n\n /**\n * Session recording configuration options\n */\n sessionRecording?: SessionRecordingCanvasOptions & {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n masking?: Pick<SessionRecordingOptions, 'maskAllInputs' | 'maskTextSelector'>\n urlTriggers?: SessionRecordingUrlTrigger[]\n scriptConfig?: { script?: string | undefined }\n urlBlocklist?: SessionRecordingUrlTrigger[]\n eventTriggers?: string[]\n }\n\n /**\n * Whether surveys are enabled\n */\n surveys?: boolean\n\n /**\n * Parameters for the toolbar\n */\n toolbarParams: ToolbarParams\n\n /**\n * @deprecated renamed to toolbarParams, still present on older API responses\n */\n editorParams?: ToolbarParams\n\n /**\n * @deprecated, moved to toolbarParams\n */\n toolbarVersion: 'toolbar'\n\n /**\n * Whether the user is authenticated\n */\n isAuthenticated: boolean\n\n /**\n * List of site apps with their IDs and URLs\n */\n siteApps: { id: string; url: string }[]\n\n /**\n * Whether heatmaps are enabled\n */\n heatmaps?: boolean\n\n /**\n * Whether to only capture identified users by default\n */\n defaultIdentifiedOnly?: boolean\n\n /**\n * Whether to capture dead clicks\n */\n captureDeadClicks?: boolean\n\n /**\n * Indicates if the team has any flags enabled (if not we don't need to load them)\n */\n hasFeatureFlags?: boolean\n}\n\n/**\n * Decide returns everything we have on the remote config plus feature flags and their payloads\n */\nexport interface DecideResponse extends RemoteConfig {\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n requestId?: string\n}\n\nexport type SiteAppGlobals = {\n event: {\n uuid: string\n event: EventName\n properties: Properties\n timestamp?: Date\n elements_chain?: string\n distinct_id?: string\n }\n person: {\n properties: Properties\n }\n groups: Record<string, { id: string; type: string; properties: Properties }>\n}\n\nexport type SiteAppLoader = {\n id: string\n init: (config: { posthog: PostHog; callback: (success: boolean) => void }) => {\n processEvent?: (globals: SiteAppGlobals) => void\n }\n}\n\nexport type SiteApp = {\n id: string\n loaded: boolean\n errored: boolean\n processedBuffer: boolean\n processEvent?: (globals: SiteAppGlobals) => void\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => void\n\nexport type RemoteConfigFeatureFlagCallback = (payload: JsonType) => void\n\nexport interface PersistentStore {\n is_supported: () => boolean\n error: (error: any) => void\n parse: (name: string) => any\n get: (name: string) => any\n set: (\n name: string,\n value: any,\n expire_days?: number | null,\n cross_subdomain?: boolean,\n secure?: boolean,\n debug?: boolean\n ) => void\n remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonRecord = { [key: string]: JsonType }\nexport type JsonType = string | number | boolean | null | undefined | JsonRecord | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureStage = 'concept' | 'alpha' | 'beta' | 'general-availability'\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n /**\n * some domains we should never record the payload\n * for example other companies session replay ingestion payloads aren't super useful but are gigantic\n * if this isn't provided we use a default list\n * if this is provided - we add the provided list to the default list\n * i.e. we never record the payloads on the default deny list\n */\n payloadHostDenyList?: string[]\n}\n\n/** @deprecated - use CapturedNetworkRequest instead */\nexport type NetworkRequest = {\n url: string\n}\n\n// In rrweb this is called NetworkRequest, but we already exposed that as having only URL\n// we also want to vary from the rrweb NetworkRequest because we want to include\n// all PerformanceEntry properties too.\n// that has 4 required properties\n// readonly duration: DOMHighResTimeStamp;\n// readonly entryType: string;\n// readonly name: string;\n// readonly startTime: DOMHighResTimeStamp;\n// NB: properties below here are ALPHA, don't rely on them, they may change without notice\n\n// we mirror PerformanceEntry since we read into this type from a PerformanceObserver,\n// but we don't want to inherit its readonly-iness\ntype Writable<T> = { -readonly [P in keyof T]: T[P] }\n\nexport type CapturedNetworkRequest = Writable<Omit<PerformanceEntry, 'toJSON'>> & {\n // properties below here are ALPHA, don't rely on them, they may change without notice\n method?: string\n initiatorType?: InitiatorType\n status?: number\n timeOrigin?: number\n timestamp?: number\n startTime?: number\n endTime?: number\n requestHeaders?: Headers\n requestBody?: string | null\n responseHeaders?: Headers\n responseBody?: string | null\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\n\nexport type ErrorConversionArgs = {\n event: string | Event\n error?: Error\n}\n\nexport type ErrorEventArgs = [\n event: string | Event,\n source?: string | undefined,\n lineno?: number | undefined,\n colno?: number | undefined,\n error?: Error | undefined,\n]\n\nexport type ErrorMetadata = {\n handled?: boolean\n synthetic?: boolean\n syntheticException?: Error\n overrideExceptionType?: string\n overrideExceptionMessage?: string\n defaultExceptionType?: string\n defaultExceptionMessage?: string\n}\n\n// levels originally copied from Sentry to work with the sentry integration\n// and to avoid relying on a frequently changing @sentry/types dependency\n// but provided as an array of literal types, so we can constrain the level below\nexport const severityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug'] as const\nexport declare type SeverityLevel = (typeof severityLevels)[number]\n\nexport interface ErrorProperties {\n $exception_type: string\n $exception_message: string\n $exception_level: SeverityLevel\n $exception_source?: string\n $exception_lineno?: number\n $exception_colno?: number\n $exception_DOMException_code?: string\n $exception_is_synthetic?: boolean\n $exception_stack_trace_raw?: string\n $exception_handled?: boolean\n $exception_personURL?: string\n}\n\nexport interface ErrorConversions {\n errorToProperties: (args: ErrorEventArgs) => ErrorProperties\n unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties\n}\n\nexport interface SessionRecordingUrlTrigger {\n url: string\n matching: 'regex'\n}\n","import { window } from './globals'\nimport { knownUnsafeEditableEvent, KnownUnsafeEditableEvent } from '../types'\nimport { includes } from './string-utils'\n\n// eslint-disable-next-line posthog-js/no-direct-array-check\nconst nativeIsArray = Array.isArray\nconst ObjProto = Object.prototype\nexport const hasOwnProperty = ObjProto.hasOwnProperty\nconst toString = ObjProto.toString\n\nexport const isArray =\n nativeIsArray ||\n function (obj: any): obj is any[] {\n return toString.call(obj) === '[object Array]'\n }\n\n// from a comment on http://dbj.org/dbj/?p=286\n// fails on only one very rare and deliberate custom object:\n// let bomb = { toString : undefined, valueOf: function(o) { return \"function BOMBA!\"; }};\nexport const isFunction = (x: unknown): x is (...args: any[]) => any => {\n // eslint-disable-next-line posthog-js/no-direct-function-check\n return typeof x === 'function'\n}\n\nexport const isNativeFunction = (x: unknown): x is (...args: any[]) => any =>\n isFunction(x) && x.toString().indexOf('[native code]') !== -1\n\n// When angular patches functions they pass the above `isNativeFunction` check (at least the MutationObserver)\nexport const isAngularZonePresent = (): boolean => {\n return !!(window as any).Zone\n}\n\n// Underscore Addons\nexport const isObject = (x: unknown): x is Record<string, any> => {\n // eslint-disable-next-line posthog-js/no-direct-object-check\n return x === Object(x) && !isArray(x)\n}\nexport const isEmptyObject = (x: unknown) => {\n if (isObject(x)) {\n for (const key in x) {\n if (hasOwnProperty.call(x, key)) {\n return false\n }\n }\n return true\n }\n return false\n}\nexport const isUndefined = (x: unknown): x is undefined => x === void 0\n\nexport const isString = (x: unknown): x is string => {\n // eslint-disable-next-line posthog-js/no-direct-string-check\n return toString.call(x) == '[object String]'\n}\n\nexport const isEmptyString = (x: unknown): boolean => isString(x) && x.trim().length === 0\n\nexport const isNull = (x: unknown): x is null => {\n // eslint-disable-next-line posthog-js/no-direct-null-check\n return x === null\n}\n\n/*\n sometimes you want to check if something is null or undefined\n that's what this is for\n */\nexport const isNullish = (x: unknown): x is null | undefined => isUndefined(x) || isNull(x)\n\nexport const isNumber = (x: unknown): x is number => {\n // eslint-disable-next-line posthog-js/no-direct-number-check\n return toString.call(x) == '[object Number]'\n}\nexport const isBoolean = (x: unknown): x is boolean => {\n // eslint-disable-next-line posthog-js/no-direct-boolean-check\n return toString.call(x) === '[object Boolean]'\n}\n\nexport const isDocument = (x: unknown): x is Document => {\n // eslint-disable-next-line posthog-js/no-direct-document-check\n return x instanceof Document\n}\n\nexport const isFormData = (x: unknown): x is FormData => {\n // eslint-disable-next-line posthog-js/no-direct-form-data-check\n return x instanceof FormData\n}\n\nexport const isFile = (x: unknown): x is File => {\n // eslint-disable-next-line posthog-js/no-direct-file-check\n return x instanceof File\n}\n\nexport const isError = (x: unknown): x is Error => {\n return x instanceof Error\n}\n\nexport const isKnownUnsafeEditableEvent = (x: unknown): x is KnownUnsafeEditableEvent => {\n return includes(knownUnsafeEditableEvent as unknown as string[], x)\n}\n","import Config from '../config'\nimport { isUndefined } from './type-utils'\nimport { assignableWindow, window } from './globals'\n\nexport type Logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => void\n info: (...args: any[]) => void\n warn: (...args: any[]) => void\n error: (...args: any[]) => void\n critical: (...args: any[]) => void\n uninitializedWarning: (methodName: string) => void\n createLogger: (prefix: string) => Logger\n}\n\nconst _createLogger = (prefix: string): Logger => {\n const logger: Logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG) &&\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) => _createLogger(`${prefix} ${additionalPrefix}`),\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 { VNode, cloneElement, createContext } from 'preact'\nimport { PostHog } from '../../posthog-core'\nimport {\n MultipleSurveyQuestion,\n Survey,\n SurveyAppearance,\n SurveyQuestion,\n SurveySchedule,\n SurveyType,\n} from '../../posthog-surveys-types'\nimport { document as _document, window as _window } from '../../utils/globals'\nimport { createLogger } from '../../utils/logger'\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\nconst SurveySeenPrefix = 'seenSurvey_'\n\nconst logger = createLogger('[Surveys]')\n\nexport const SURVEY_DEFAULT_Z_INDEX = 2147483647\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\nexport const style = (appearance: SurveyAppearance | null) => {\n const positions = {\n left: 'left: 30px;',\n right: 'right: 30px;',\n center: `\n left: 50%;\n transform: translateX(-50%);\n `,\n }\n return `\n .survey-form, .thank-you-message {\n position: fixed;\n margin: 0px;\n bottom: 0px;\n color: black;\n font-weight: normal;\n font-family: ${getFontFamily(appearance?.fontFamily)};\n text-align: left;\n max-width: ${parseInt(appearance?.maxWidth || '300')}px;\n width: 100%;\n z-index: ${parseInt(appearance?.zIndex || SURVEY_DEFAULT_Z_INDEX.toString())};\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n border-bottom: 0px;\n ${positions[appearance?.position || 'right'] || 'right: 30px;'}\n flex-direction: column;\n background: ${appearance?.backgroundColor || '#eeeded'};\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n box-shadow: -6px 0 16px -8px rgb(0 0 0 / 8%), -9px 0 28px 0 rgb(0 0 0 / 5%), -12px 0 48px 16px rgb(0 0 0 / 3%);\n }\n\n .survey-box, .thank-you-message-container {\n padding: 20px 25px 10px;\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n }\n\n .thank-you-message {\n text-align: center;\n }\n\n .form-submit[disabled] {\n opacity: ${appearance?.disabledButtonOpacity || '0.6'};\n filter: grayscale(50%);\n cursor: not-allowed;\n }\n .survey-form textarea {\n color: #2d2d2d;\n font-size: 14px;\n font-family: ${getFontFamily(appearance?.fontFamily)};\n background: white;\n color: black;\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n padding-top: 10px;\n border-radius: 6px;\n border-color: ${appearance?.borderColor || '#c9c6c6'};\n margin-top: 14px;\n width: 100%;\n box-sizing: border-box;\n }\n .survey-box:has(.survey-question:empty):not(:has(.survey-question-description)) textarea {\n margin-top: 0;\n }\n .form-submit {\n box-sizing: border-box;\n margin: 0;\n font-family: inherit;\n overflow: visible;\n text-transform: none;\n position: relative;\n display: inline-block;\n font-weight: 700;\n white-space: nowrap;\n text-align: center;\n border: 1.5px solid transparent;\n cursor: pointer;\n user-select: none;\n touch-action: manipulation;\n padding: 12px;\n font-size: 14px;\n border-radius: 6px;\n outline: 0;\n background: ${appearance?.submitButtonColor || 'black'} !important;\n text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.12);\n box-shadow: 0 2px 0 rgba(0, 0, 0, 0.045);\n width: 100%;\n }\n .form-cancel {\n display: flex;\n float: right;\n border: none;\n background: none;\n cursor: pointer;\n }\n .cancel-btn-wrapper {\n position: absolute;\n width: 35px;\n height: 35px;\n border-radius: 100%;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n background: white;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .bolded { font-weight: 600; }\n .buttons {\n display: flex;\n justify-content: center;\n }\n .footer-branding {\n font-size: 11px;\n margin-top: 10px;\n text-align: center;\n display: flex;\n justify-content: center;\n gap: 4px;\n align-items: center;\n font-weight: 500;\n background: ${appearance?.backgroundColor || '#eeeded'};\n text-decoration: none;\n backgroundColor: ${appearance?.backgroundColor || '#eeeded'};\n color: ${getContrastingTextColor(appearance?.backgroundColor || '#eeeded')};\n }\n .survey-question {\n font-weight: 500;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .question-textarea-wrapper {\n display: flex;\n flex-direction: column;\n }\n .survey-question-description {\n font-size: 13px;\n padding-top: 5px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .ratings-number {\n font-size: 16px;\n font-weight: 600;\n padding: 8px 0px;\n border: none;\n }\n .ratings-number:hover {\n cursor: pointer;\n }\n .rating-options {\n margin-top: 14px;\n }\n .rating-options-number {\n display: grid;\n border-radius: 6px;\n overflow: hidden;\n border: 1.5px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-number > .ratings-number {\n border-right: 1px solid ${appearance?.borderColor || '#c9c6c6'};\n }\n .rating-options-number > .ratings-number:last-of-type {\n border-right: 0px;\n }\n .rating-options-number .rating-active {\n background: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .rating-options-emoji {\n display: flex;\n justify-content: space-between;\n }\n .ratings-emoji {\n font-size: 16px;\n background-color: transparent;\n border: none;\n padding: 0px;\n }\n .ratings-emoji:hover {\n cursor: pointer;\n }\n .ratings-emoji.rating-active svg {\n fill: ${appearance?.ratingButtonActiveColor || 'black'};\n }\n .emoji-svg {\n fill: '#939393';\n }\n .rating-text {\n display: flex;\n flex-direction: row;\n font-size: 11px;\n justify-content: space-between;\n margin-top: 6px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n opacity: .60;\n }\n .limit-height {\n max-height: 300px;\n overflow: auto;\n scrollbar-width: thin;\n scrollbar-color: ${appearance?.borderColor || '#c9c6c6'} ${appearance?.backgroundColor || '#eeeded'};\n }\n .multiple-choice-options {\n margin-top: 13px;\n font-size: 14px;\n }\n .survey-box:has(.survey-question:empty):not(:has(.survey-question-description)) .multiple-choice-options {\n margin-top: 0;\n }\n .multiple-choice-options .choice-option {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 13px;\n cursor: pointer;\n margin-bottom: 5px;\n position: relative;\n }\n .multiple-choice-options > .choice-option:last-of-type {\n margin-bottom: 0px;\n }\n .multiple-choice-options input {\n cursor: pointer;\n position: absolute;\n opacity: 0;\n }\n .choice-check {\n position: absolute;\n right: 10px;\n background: white;\n }\n .choice-check svg {\n display: none;\n }\n .multiple-choice-options .choice-option:hover .choice-check svg {\n display: inline-block;\n opacity: .25;\n }\n .multiple-choice-options input:checked + label + .choice-check svg {\n display: inline-block;\n opacity: 100% !important;\n }\n .multiple-choice-options input:checked + label {\n font-weight: bold;\n border: 1.5px solid rgba(0,0,0);\n }\n .multiple-choice-options input:checked + label input {\n font-weight: bold;\n }\n .multiple-choice-options label {\n width: 100%;\n cursor: pointer;\n padding: 10px;\n border: 1.5px solid rgba(0,0,0,.25);\n border-radius: 4px;\n background: white;\n }\n .multiple-choice-options .choice-option-open label {\n padding-right: 30px;\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n max-width: 100%;\n }\n .multiple-choice-options .choice-option-open label span {\n width: 100%;\n }\n .multiple-choice-options .choice-option-open input:disabled + label {\n opacity: 0.6;\n }\n .multiple-choice-options .choice-option-open label input {\n position: relative;\n opacity: 1;\n flex-grow: 1;\n border: 0;\n outline: 0;\n }\n .thank-you-message-body {\n margin-top: 6px;\n font-size: 14px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-header {\n margin: 10px 0px 0px;\n background: ${appearance?.backgroundColor || '#eeeded'};\n }\n .thank-you-message-container .form-submit {\n margin-top: 20px;\n margin-bottom: 10px;\n }\n .thank-you-message-countdown {\n margin-left: 6px;\n }\n .bottom-section {\n margin-top: 14px;\n }\n `\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\nfunction hex2rgb(c: string) {\n if (c[0] === '#') {\n const hexColor = c.replace(/^#/, '')\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 getContrastingTextColor(color: string = defaultBackgroundColor) {\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'\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' : 'white'\n }\n return 'black'\n}\nexport function getTextColor(el: HTMLElement) {\n const backgroundColor = window.getComputedStyle(el).backgroundColor\n if (backgroundColor === 'rgba(0, 0, 0, 0)') {\n return 'black'\n }\n const colorMatch = backgroundColor.match(/^rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)(?:,\\s*(\\d+(?:\\.\\d+)?))?\\)$/)\n if (!colorMatch) return 'black'\n\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' : 'white'\n}\n\nexport const defaultSurveyAppearance: SurveyAppearance = {\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: 'right',\n}\n\nexport const defaultBackgroundColor = '#eeeded'\n\nexport const createShadow = (styleSheet: string, surveyId: string, element?: Element, posthog?: PostHog) => {\n const div = document.createElement('div')\n div.className = `PostHogSurvey${surveyId}`\n const shadow = div.attachShadow({ mode: 'open' })\n if (styleSheet) {\n const styleElement = prepareStylesheet(document, styleSheet, posthog)\n if (styleElement) {\n shadow.appendChild(styleElement)\n }\n }\n ;(element ? element : document.body).appendChild(div)\n return shadow\n}\n\nexport const sendSurveyEvent = (\n responses: Record<string, string | number | string[] | null> = {},\n survey: Survey,\n posthog?: PostHog\n) => {\n if (!posthog) {\n logger.error('[survey sent] event not captured, PostHog instance not found.')\n return\n }\n localStorage.setItem(getSurveySeenKey(survey), 'true')\n\n posthog.capture('survey sent', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n $survey_questions: survey.questions.map((question, index) => ({\n id: question.id,\n question: question.question,\n index,\n })),\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n ...responses,\n $set: {\n [getSurveyInteractionProperty(survey, 'responded')]: true,\n },\n })\n window.dispatchEvent(new Event('PHSurveySent'))\n}\n\nexport const dismissedSurveyEvent = (survey: Survey, posthog?: PostHog, readOnly?: boolean) => {\n // TODO: state management and unit tests for this would be nice\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 posthog.capture('survey dismissed', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n $set: {\n [getSurveyInteractionProperty(survey, 'dismissed')]: true,\n },\n })\n localStorage.setItem(getSurveySeenKey(survey), 'true')\n window.dispatchEvent(new Event('PHSurveyClosed'))\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) {\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 = (survey: Pick<Survey, 'schedule' | 'type' | 'conditions'>): boolean => {\n if (survey.schedule === SurveySchedule.Always && survey.type === SurveyType.Widget) {\n return true\n }\n\n return !!(survey.conditions?.events?.repeatedActivation && hasEvents(survey))\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\nexport const getSurveySeenKey = (survey: Survey): string => {\n let surveySeenKey = `${SurveySeenPrefix}${survey.id}`\n if (survey.current_iteration && survey.current_iteration > 0) {\n surveySeenKey = `${SurveySeenPrefix}${survey.id}_${survey.current_iteration}`\n }\n\n return surveySeenKey\n}\n\nexport const getSurveySeenStorageKeys = (): string[] => {\n const surveyKeys = []\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i)\n if (key?.startsWith(SurveySeenPrefix)) {\n surveyKeys.push(key)\n }\n }\n\n return surveyKeys\n}\n\nconst getSurveyInteractionProperty = (survey: Survey, action: string): 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\nexport const hasWaitPeriodPassed = (\n lastSeenSurveyDate: string | null,\n waitPeriodInDays: number | undefined\n): boolean => {\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 onPopupSurveySent: () => void\n}\n\nexport const SurveyContext = createContext<SurveyContextProps>({\n isPreviewMode: false,\n previewPageIndex: 0,\n onPopupSurveyDismissed: () => {},\n isPopup: true,\n onPreviewSubmit: () => {},\n onPopupSurveySent: () => {},\n})\n\ninterface RenderProps {\n component: VNode<{ className: string }>\n children: string\n renderAsHtml?: boolean\n style?: React.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","import { Breaker, Properties } from '../types'\nimport { hasOwnProperty, isArray, isFormData, isNull, isNullish, isString } from './type-utils'\nimport { logger } from './logger'\nimport { nativeForEach, nativeIndexOf } from './globals'\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) {\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","import { getQueryParam, convertToURL, maskQueryParams } from './request-utils'\nimport { isNull } from './type-utils'\nimport { Properties } from '../types'\nimport Config from '../config'\nimport { each, extend, extendArray, stripEmptyProperties } from './index'\nimport { document, location, userAgent, window } from './globals'\nimport { detectBrowser, detectBrowserVersion, detectDevice, detectDeviceType, detectOS } from './user-agent-utils'\nimport { stripLeadingDollar } from './string-utils'\n\nconst URL_REGEX_PREFIX = 'https?://(.*)'\n\n// CAMPAIGN_PARAMS and EVENT_TO_PERSON_PROPERTIES should be kept in sync with\n// https://github.com/PostHog/posthog/blob/master/plugin-server/src/utils/db/utils.ts#L60\n\n// The list of campaign parameters that could be considered personal data under e.g. GDPR.\n// These can be masked in URLs and properties before being sent to posthog.\nexport const PERSONAL_DATA_CAMPAIGN_PARAMS = [\n 'gclid', // google ads\n 'gclsrc', // google ads 360\n 'dclid', // google display ads\n 'gbraid', // google ads, web to app\n 'wbraid', // google ads, app to web\n 'fbclid', // facebook\n 'msclkid', // microsoft\n 'twclid', // twitter\n 'li_fat_id', // linkedin\n 'igshid', // instagram\n 'ttclid', // tiktok\n 'rdt_cid', // reddit\n 'irclid', // impact\n '_kx', // klaviyo\n]\n\nexport const CAMPAIGN_PARAMS = extendArray(\n [\n 'utm_source',\n 'utm_medium',\n 'utm_campaign',\n 'utm_content',\n 'utm_term',\n 'gad_source', // google ads source\n 'mc_cid', // mailchimp campaign id\n ],\n PERSONAL_DATA_CAMPAIGN_PARAMS\n)\n\nexport const EVENT_TO_PERSON_PROPERTIES = [\n // mobile params\n '$app_build',\n '$app_name',\n '$app_namespace',\n '$app_version',\n // web params\n '$browser',\n '$browser_version',\n '$device_type',\n '$current_url',\n '$pathname',\n '$os',\n '$os_name', // $os_name is a special case, it's treated as an alias of $os!\n '$os_version',\n '$referring_domain',\n '$referrer',\n]\n\nexport const MASKED = '<masked>'\n\nexport const Info = {\n campaignParams: function ({\n customTrackedParams,\n maskPersonalDataProperties,\n customPersonalDataProperties,\n }: {\n customTrackedParams?: string[]\n maskPersonalDataProperties?: boolean\n customPersonalDataProperties?: string[] | undefined\n } = {}): Record<string, string> {\n if (!document) {\n return {}\n }\n\n const paramsToMask = maskPersonalDataProperties\n ? extendArray([], PERSONAL_DATA_CAMPAIGN_PARAMS, customPersonalDataProperties || [])\n : []\n\n return this._campaignParamsFromUrl(maskQueryParams(document.URL, paramsToMask, MASKED), customTrackedParams)\n },\n\n _campaignParamsFromUrl: function (url: string, customParams?: string[]): Record<string, string> {\n const campaign_keywords = CAMPAIGN_PARAMS.concat(customParams || [])\n\n const params: Record<string, any> = {}\n each(campaign_keywords, function (kwkey) {\n const kw = getQueryParam(url, kwkey)\n params[kwkey] = kw ? kw : null\n })\n\n return params\n },\n\n _searchEngine: function (referrer: string): string | null {\n if (!referrer) {\n return null\n } else {\n if (referrer.search(URL_REGEX_PREFIX + 'google.([^/?]*)') === 0) {\n return 'google'\n } else if (referrer.search(URL_REGEX_PREFIX + 'bing.com') === 0) {\n return 'bing'\n } else if (referrer.search(URL_REGEX_PREFIX + 'yahoo.com') === 0) {\n return 'yahoo'\n } else if (referrer.search(URL_REGEX_PREFIX + 'duckduckgo.com') === 0) {\n return 'duckduckgo'\n } else {\n return null\n }\n }\n },\n\n _searchInfoFromReferrer: function (referrer: string): Record<string, any> {\n const search = Info._searchEngine(referrer)\n const param = search != 'yahoo' ? 'q' : 'p'\n const ret: Record<string, any> = {}\n\n if (!isNull(search)) {\n ret['$search_engine'] = search\n\n const keyword = document ? getQueryParam(document.referrer, param) : ''\n if (keyword.length) {\n ret['ph_keyword'] = keyword\n }\n }\n\n return ret\n },\n\n searchInfo: function (): Record<string, any> {\n const referrer = document?.referrer\n if (!referrer) {\n return {}\n }\n return this._searchInfoFromReferrer(referrer)\n },\n\n /**\n * This function detects which browser is running this script.\n * The order of the checks are important since many user agents\n * include keywords used in later checks.\n */\n browser: detectBrowser,\n\n /**\n * This function detects which browser version is running this script,\n * parsing major and minor version (e.g., 42.1). User agent strings from:\n * http://www.useragentstring.com/pages/useragentstring.php\n *\n * `navigator.vendor` is passed in and used to help with detecting certain browsers\n * NB `navigator.vendor` is deprecated and not present in every browser\n */\n browserVersion: detectBrowserVersion,\n\n browserLanguage: function (): string | undefined {\n return (\n navigator.language || // Any modern browser\n (navigator as Record<string, any>).userLanguage // IE11\n )\n },\n\n browserLanguagePrefix: function (): string | undefined {\n const browserLanguage = this.browserLanguage()\n return typeof browserLanguage === 'string' ? browserLanguage.split('-')[0] : undefined\n },\n\n os: detectOS,\n\n device: detectDevice,\n\n deviceType: detectDeviceType,\n\n referrer: function (): string {\n return document?.referrer || '$direct'\n },\n\n referringDomain: function (): string {\n if (!document?.referrer) {\n return '$direct'\n }\n return convertToURL(document.referrer)?.host || '$direct'\n },\n\n referrerInfo: function (): Record<string, any> {\n return {\n $referrer: this.referrer(),\n $referring_domain: this.referringDomain(),\n }\n },\n\n personInfo: function ({\n maskPersonalDataProperties,\n customPersonalDataProperties,\n }: {\n maskPersonalDataProperties?: boolean\n customPersonalDataProperties?: string[]\n } = {}) {\n const paramsToMask = maskPersonalDataProperties\n ? extendArray([], PERSONAL_DATA_CAMPAIGN_PARAMS, customPersonalDataProperties || [])\n : []\n const url = location?.href.substring(0, 1000)\n // we're being a bit more economical with bytes here because this is stored in the cookie\n return {\n r: this.referrer().substring(0, 1000),\n u: url ? maskQueryParams(url, paramsToMask, MASKED) : undefined,\n }\n },\n\n personPropsFromInfo: function (info: Record<string, any>): Record<string, any> {\n const { r: referrer, u: url } = info\n const referring_domain =\n referrer == null ? undefined : referrer == '$direct' ? '$direct' : convertToURL(referrer)?.host\n\n const props: Record<string, string | undefined> = {\n $referrer: referrer,\n $referring_domain: referring_domain,\n }\n if (url) {\n props['$current_url'] = url\n const location = convertToURL(url)\n props['$host'] = location?.host\n props['$pathname'] = location?.pathname\n const campaignParams = this._campaignParamsFromUrl(url)\n extend(props, campaignParams)\n }\n if (referrer) {\n const searchInfo = this._searchInfoFromReferrer(referrer)\n extend(props, searchInfo)\n }\n return props\n },\n\n initialPersonPropsFromInfo: function (info: Record<string, any>): Record<string, any> {\n const personProps = this.personPropsFromInfo(info)\n const props: Record<string, any> = {}\n each(personProps, function (val: any, key: string) {\n props[`$initial_${stripLeadingDollar(key)}`] = val\n })\n return props\n },\n\n timezone: function (): string | undefined {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone\n } catch {\n return undefined\n }\n },\n\n timezoneOffset: function (): number | undefined {\n try {\n return new Date().getTimezoneOffset()\n } catch {\n return undefined\n }\n },\n\n properties: function ({\n maskPersonalDataProperties,\n customPersonalDataProperties,\n }: {\n maskPersonalDataProperties?: boolean\n customPersonalDataProperties?: string[]\n } = {}): Properties {\n if (!userAgent) {\n return {}\n }\n const paramsToMask = maskPersonalDataProperties\n ? extendArray([], PERSONAL_DATA_CAMPAIGN_PARAMS, customPersonalDataProperties || [])\n : []\n const [os_name, os_version] = Info.os(userAgent)\n return extend(\n stripEmptyProperties({\n $os: os_name,\n $os_version: os_version,\n $browser: Info.browser(userAgent, navigator.vendor),\n $device: Info.device(userAgent),\n $device_type: Info.deviceType(userAgent),\n $timezone: Info.timezone(),\n $timezone_offset: Info.timezoneOffset(),\n }),\n {\n $current_url: maskQueryParams(location?.href, paramsToMask, MASKED),\n $host: location?.host,\n $pathname: location?.pathname,\n $raw_user_agent: userAgent.length > 1000 ? userAgent.substring(0, 997) + '...' : userAgent,\n $browser_version: Info.browserVersion(userAgent, navigator.vendor),\n $browser_language: Info.browserLanguage(),\n $browser_language_prefix: Info.browserLanguagePrefix(),\n $screen_height: window?.screen.height,\n $screen_width: window?.screen.width,\n $viewport_height: window?.innerHeight,\n $viewport_width: window?.innerWidth,\n $lib: 'web',\n $lib_version: Config.LIB_VERSION,\n $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),\n $time: Date.now() / 1000, // epoch time in seconds\n }\n )\n },\n\n people_properties: function (): Properties {\n if (!userAgent) {\n return {}\n }\n\n const [os_name, os_version] = Info.os(userAgent)\n return extend(\n stripEmptyProperties({\n $os: os_name,\n $os_version: os_version,\n $browser: Info.browser(userAgent, navigator.vendor),\n }),\n {\n $browser_version: Info.browserVersion(userAgent, navigator.vendor),\n }\n )\n },\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","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 { PostHog } from '../../posthog-core'\nimport { ActionStepStringMatching, ActionStepType, SurveyActionType, SurveyElement } from '../../posthog-surveys-types'\nimport { SimpleEventEmitter } from '../../utils/simple-event-emitter'\nimport { CaptureResult } from '../../types'\nimport { isUndefined } from '../../utils/type-utils'\nimport { window } from '../../utils/globals'\nimport { isMatchingRegex } from '../../utils/regex-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 this.checkStepEvent(event, step) && this.checkStepUrl(event, step) && this.checkStepElement(event, step)\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 // URL IS UNKNOWN\n }\n if (!ActionMatcher.matchString(eventUrl, step?.url, step?.url_matching || 'contains')) {\n return false // URL IS A MISMATCH\n }\n }\n return true\n }\n\n private static matchString(url: string, pattern: string, matching: ActionStepStringMatching): boolean {\n switch (matching) {\n case 'regex':\n return !!window && isMatchingRegex(url, pattern)\n case 'exact':\n return pattern === url\n case 'contains':\n // Simulating SQL LIKE behavior (_ = any single character, % = any zero or more characters)\n // eslint-disable-next-line no-case-declarations\n const adjustedRegExpStringPattern = ActionMatcher.escapeStringRegexp(pattern)\n .replace(/_/g, '.')\n .replace(/%/g, '.*')\n return isMatchingRegex(url, adjustedRegExpStringPattern)\n\n default:\n return false\n }\n }\n\n private static escapeStringRegexp(pattern: string): string {\n // Escape characters with special meaning either inside or outside character sets.\n // Use a simple backslash escape when it’s always valid, and a `\\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.\n return pattern.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d')\n }\n\n private checkStepElement(event?: CaptureResult, step?: ActionStepType): boolean {\n // CHECK CONDITIONS, OTHERWISE SKIPPED\n if (step?.href || step?.tag_name || step?.text) {\n const elements = this.getElementsList(event)\n if (\n !elements.some((element) => {\n if (\n step?.href &&\n !ActionMatcher.matchString(element.href || '', step?.href, step?.href_matching || 'exact')\n ) {\n return false // ELEMENT HREF IS A MISMATCH\n }\n if (step?.tag_name && element.tag_name !== step?.tag_name) {\n return false // ELEMENT TAG NAME IS A MISMATCH\n }\n if (\n step?.text &&\n !(\n ActionMatcher.matchString(element.text || '', step?.text, step?.text_matching || 'exact') ||\n ActionMatcher.matchString(\n element.$el_text || '',\n step?.text,\n step?.text_matching || 'exact'\n )\n )\n ) {\n return false // ELEMENT TEXT IS A MISMATCH\n }\n return true\n })\n ) {\n // AT LEAST ONE ELEMENT MUST BE A SUBMATCH\n return false\n }\n }\n\n if (step?.selector) {\n const elementSelectors = event?.properties?.$element_selectors as unknown as string[]\n if (!elementSelectors) {\n return false // SELECTOR IS A MISMATCH\n }\n if (!elementSelectors.includes(step?.selector)) {\n return false // SELECTOR IS A MISMATCH\n }\n }\n\n return true\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","import { Survey } from '../posthog-surveys-types'\nimport { SURVEYS_ACTIVATED } from '../constants'\n\nimport { CaptureResult } from '../types'\nimport { ActionMatcher } from '../extensions/surveys/action-matcher'\nimport { PostHog } from '../posthog-core'\nimport { isUndefined } from './type-utils'\n\nexport class SurveyEventReceiver {\n // eventToSurveys is a mapping of event name to all the surveys that are activated by it\n private readonly eventToSurveys: Map<string, string[]>\n // actionToSurveys is a mapping of action name to all the surveys that are activated by it\n private readonly actionToSurveys: Map<string, string[]>\n // actionMatcher can look at CaptureResult payloads and match an event to its corresponding action.\n private actionMatcher?: ActionMatcher | null\n private readonly instance?: PostHog\n private static SURVEY_SHOWN_EVENT_NAME = 'survey shown'\n\n constructor(instance: PostHog) {\n this.instance = instance\n this.eventToSurveys = new Map<string, string[]>()\n this.actionToSurveys = new Map<string, string[]>()\n }\n\n register(surveys: Survey[]): void {\n if (isUndefined(this.instance?._addCaptureHook)) {\n return\n }\n\n this.setupEventBasedSurveys(surveys)\n this.setupActionBasedSurveys(surveys)\n }\n\n private setupActionBasedSurveys(surveys: Survey[]) {\n const actionBasedSurveys = surveys.filter(\n (survey: Survey) => survey.conditions?.actions && survey.conditions?.actions?.values?.length > 0\n )\n\n if (actionBasedSurveys.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 survey.\n const matchActionToSurvey = (actionName: string) => {\n this.onAction(actionName)\n }\n\n this.actionMatcher._addActionHook(matchActionToSurvey)\n }\n\n actionBasedSurveys.forEach((survey) => {\n if (\n survey.conditions &&\n survey.conditions?.actions &&\n survey.conditions?.actions?.values &&\n survey.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(survey.conditions.actions.values)\n\n // maintain a mapping of (Action1) => [Survey1, Survey2, Survey3]\n // where Surveys 1-3 are all activated by Action1\n survey.conditions?.actions?.values?.forEach((action) => {\n if (action && action.name) {\n const knownSurveys: string[] | undefined = this.actionToSurveys.get(action.name)\n if (knownSurveys) {\n knownSurveys.push(survey.id)\n }\n this.actionToSurveys.set(action.name, knownSurveys || [survey.id])\n }\n })\n }\n })\n }\n\n private setupEventBasedSurveys(surveys: Survey[]) {\n const eventBasedSurveys = surveys.filter(\n (survey: Survey) => survey.conditions?.events && survey.conditions?.events?.values?.length > 0\n )\n\n if (eventBasedSurveys.length === 0) {\n return\n }\n\n // match any events to its corresponding survey.\n const matchEventToSurvey = (eventName: string, eventPayload?: CaptureResult) => {\n this.onEvent(eventName, eventPayload)\n }\n this.instance?._addCaptureHook(matchEventToSurvey)\n\n surveys.forEach((survey) => {\n // maintain a mapping of (Event1) => [Survey1, Survey2, Survey3]\n // where Surveys 1-3 are all activated by Event1\n survey.conditions?.events?.values?.forEach((event) => {\n if (event && event.name) {\n const knownSurveys: string[] | undefined = this.eventToSurveys.get(event.name)\n if (knownSurveys) {\n knownSurveys.push(survey.id)\n }\n this.eventToSurveys.set(event.name, knownSurveys || [survey.id])\n }\n })\n })\n }\n\n onEvent(event: string, eventPayload?: CaptureResult): void {\n const existingActivatedSurveys: string[] = this.instance?.persistence?.props[SURVEYS_ACTIVATED] || []\n if (\n SurveyEventReceiver.SURVEY_SHOWN_EVENT_NAME == event &&\n eventPayload &&\n existingActivatedSurveys.length > 0\n ) {\n // remove survey that from activatedSurveys here.\n const surveyId = eventPayload?.properties?.$survey_id\n if (surveyId) {\n const index = existingActivatedSurveys.indexOf(surveyId)\n if (index >= 0) {\n existingActivatedSurveys.splice(index, 1)\n this._updateActivatedSurveys(existingActivatedSurveys)\n }\n }\n } else {\n if (this.eventToSurveys.has(event)) {\n this._updateActivatedSurveys(existingActivatedSurveys.concat(this.eventToSurveys.get(event) || []))\n }\n }\n }\n\n onAction(actionName: string): void {\n const existingActivatedSurveys: string[] = this.instance?.persistence?.props[SURVEYS_ACTIVATED] || []\n if (this.actionToSurveys.has(actionName)) {\n this._updateActivatedSurveys(existingActivatedSurveys.concat(this.actionToSurveys.get(actionName) || []))\n }\n }\n\n private _updateActivatedSurveys(activatedSurveys: string[]) {\n // we use a new Set here to remove duplicates.\n this.instance?.persistence?.register({\n [SURVEYS_ACTIVATED]: [...new Set(activatedSurveys)],\n })\n }\n\n getSurveys(): string[] {\n const existingActivatedSurveys = this.instance?.persistence?.props[SURVEYS_ACTIVATED]\n return existingActivatedSurveys ? existingActivatedSurveys : []\n }\n\n getEventToSurveys(): Map<string, string[]> {\n return this.eventToSurveys\n }\n\n _getActionMatcher(): ActionMatcher | null | undefined {\n return this.actionMatcher\n }\n}\n","import { SURVEYS } from './constants'\nimport { getSurveySeenStorageKeys } from './extensions/surveys/surveys-utils'\nimport { PostHog } from './posthog-core'\nimport { Survey, SurveyCallback, SurveyMatchType } from './posthog-surveys-types'\nimport { RemoteConfig } from './types'\nimport { Info } from './utils/event-utils'\nimport { assignableWindow, document, userAgent, window } from './utils/globals'\nimport { createLogger } from './utils/logger'\nimport { isMatchingRegex } from './utils/regex-utils'\nimport { SurveyEventReceiver } from './utils/survey-event-receiver'\nimport { isNullish } from './utils/type-utils'\n\nconst logger = createLogger('[Surveys]')\n\nexport const surveyValidationMap: Record<SurveyMatchType, (targets: string[], value: string) => boolean> = {\n icontains: (targets, value) => targets.some((target) => value.toLowerCase().includes(target.toLowerCase())),\n\n not_icontains: (targets, value) => targets.every((target) => !value.toLowerCase().includes(target.toLowerCase())),\n\n regex: (targets, value) => targets.some((target) => isMatchingRegex(value, target)),\n\n not_regex: (targets, value) => targets.every((target) => !isMatchingRegex(value, target)),\n\n exact: (targets, value) => targets.some((target) => value === target),\n\n is_not: (targets, value) => targets.every((target) => value !== target),\n}\n\nfunction defaultMatchType(matchType?: SurveyMatchType): SurveyMatchType {\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\n const targets = [survey.conditions.url]\n return surveyValidationMap[defaultMatchType(survey.conditions?.urlMatchType)](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 = Info.deviceType(userAgent)\n return surveyValidationMap[defaultMatchType(survey.conditions?.deviceTypesMatchType)](\n survey.conditions.deviceTypes,\n deviceType\n )\n}\n\nexport class PostHogSurveys {\n private _decideServerResponse?: boolean\n public _surveyEventReceiver: SurveyEventReceiver | null\n private _surveyManager: any\n private _isFetchingSurveys: boolean = false\n private _isInitializingSurveys: boolean = false\n\n constructor(private readonly instance: PostHog) {\n // we set this to undefined here because we need the persistence storage for this type\n // but that's not initialized until loadIfEnabled is called.\n this._surveyEventReceiver = null\n }\n\n onRemoteConfig(response: RemoteConfig) {\n this._decideServerResponse = !!response['surveys']\n logger.info(`decideServerResponse set to ${this._decideServerResponse}`)\n\n this.loadIfEnabled()\n }\n\n reset(): void {\n localStorage.removeItem('lastSeenSurveyDate')\n const surveyKeys = getSurveySeenStorageKeys()\n surveyKeys.forEach((key) => localStorage.removeItem(key))\n }\n\n loadIfEnabled() {\n if (this._surveyManager) {\n // Surveys already loaded.\n return\n }\n\n if (this._isInitializingSurveys) {\n logger.info('Already initializing surveys, skipping...')\n return\n }\n\n const disableSurveys = this.instance.config.disable_surveys\n\n if (disableSurveys) {\n logger.info('Disabled. Not loading surveys.')\n return\n }\n\n const phExtensions = assignableWindow?.__PosthogExtensions__\n\n if (!phExtensions) {\n logger.error('PostHog Extensions not found.')\n return\n }\n\n if (!this._decideServerResponse) {\n logger.warn('Decide not loaded yet. Not loading surveys.')\n return\n }\n\n this._isInitializingSurveys = true\n\n try {\n const generateSurveys = phExtensions.generateSurveys\n\n if (!generateSurveys) {\n const loadExternalDependency = phExtensions.loadExternalDependency\n\n if (loadExternalDependency) {\n loadExternalDependency(this.instance, 'surveys', (err) => {\n if (err || !phExtensions.generateSurveys) {\n logger.error('Could not load surveys script', err)\n this._isInitializingSurveys = false\n return\n }\n\n this._surveyManager = phExtensions.generateSurveys(this.instance)\n this._isInitializingSurveys = false\n this._surveyEventReceiver = new SurveyEventReceiver(this.instance)\n logger.info('Surveys loaded successfully')\n })\n } else {\n logger.error('PostHog loadExternalDependency extension not found. Cannot load remote config.')\n this._isInitializingSurveys = false\n }\n } else {\n this._surveyManager = generateSurveys(this.instance)\n this._isInitializingSurveys = false\n this._surveyEventReceiver = new SurveyEventReceiver(this.instance)\n logger.info('Surveys loaded successfully')\n }\n } catch (e) {\n logger.error('Error initializing surveys', e)\n this._isInitializingSurveys = false\n throw e\n }\n }\n\n getSurveys(callback: SurveyCallback, forceReload = false) {\n // In case we manage to load the surveys script, but config says not to load surveys\n // then we shouldn't return survey data\n if (this.instance.config.disable_surveys) {\n logger.info('Disabled. Not loading surveys.')\n return callback([])\n }\n\n const existingSurveys = this.instance.get_property(SURVEYS)\n\n if (!existingSurveys || forceReload) {\n // Prevent concurrent API calls\n if (this._isFetchingSurveys) {\n return callback([])\n }\n\n try {\n this._isFetchingSurveys = true\n this.instance._send_request({\n url: this.instance.requestRouter.endpointFor(\n 'api',\n `/api/surveys/?token=${this.instance.config.token}`\n ),\n method: 'GET',\n timeout: this.instance.config.surveys_request_timeout_ms,\n callback: (response) => {\n this._isFetchingSurveys = false\n const statusCode = response.statusCode\n if (statusCode !== 200 || !response.json) {\n logger.error(`Surveys API could not be loaded, status: ${statusCode}`)\n return callback([])\n }\n const surveys = response.json.surveys || []\n\n const eventOrActionBasedSurveys = surveys.filter(\n (survey: Survey) =>\n (survey.conditions?.events &&\n survey.conditions?.events?.values &&\n survey.conditions?.events?.values?.length > 0) ||\n (survey.conditions?.actions &&\n survey.conditions?.actions?.values &&\n survey.conditions?.actions?.values?.length > 0)\n )\n\n if (eventOrActionBasedSurveys.length > 0) {\n this._surveyEventReceiver?.register(eventOrActionBasedSurveys)\n }\n\n this.instance.persistence?.register({ [SURVEYS]: surveys })\n return callback(surveys)\n },\n })\n } catch (e) {\n this._isFetchingSurveys = false\n throw e\n }\n } else {\n return callback(existingSurveys)\n }\n }\n\n private isSurveyFeatureFlagEnabled(flagKey: string | null) {\n if (!flagKey) {\n return true\n }\n return this.instance.featureFlags.isFeatureEnabled(flagKey)\n }\n\n getActiveMatchingSurveys(callback: SurveyCallback, forceReload = false) {\n this.getSurveys((surveys) => {\n const activeSurveys = surveys.filter((survey) => {\n return !!(survey.start_date && !survey.end_date)\n })\n\n const conditionMatchedSurveys = activeSurveys.filter((survey) => {\n if (!survey.conditions) {\n return true\n }\n\n const urlCheck = doesSurveyUrlMatch(survey)\n const selectorCheck = survey.conditions?.selector\n ? document?.querySelector(survey.conditions.selector)\n : true\n const deviceTypeCheck = doesSurveyDeviceTypesMatch(survey)\n return urlCheck && selectorCheck && deviceTypeCheck\n })\n\n // get all the surveys that have been activated so far with user actions.\n const activatedSurveys: string[] | undefined = this._surveyEventReceiver?.getSurveys()\n const targetingMatchedSurveys = conditionMatchedSurveys.filter((survey) => {\n if (\n !survey.linked_flag_key &&\n !survey.targeting_flag_key &&\n !survey.internal_targeting_flag_key &&\n !survey.feature_flag_keys?.length\n ) {\n return true\n }\n const linkedFlagCheck = this.isSurveyFeatureFlagEnabled(survey.linked_flag_key)\n const targetingFlagCheck = this.isSurveyFeatureFlagEnabled(survey.targeting_flag_key)\n\n const hasEvents = (survey.conditions?.events?.values?.length ?? 0) > 0\n const hasActions = (survey.conditions?.actions?.values?.length ?? 0) > 0\n\n const eventBasedTargetingFlagCheck =\n hasEvents || hasActions ? activatedSurveys?.includes(survey.id) : true\n\n const overrideInternalTargetingFlagCheck = this._canActivateRepeatedly(survey)\n const internalTargetingFlagCheck =\n overrideInternalTargetingFlagCheck ||\n this.isSurveyFeatureFlagEnabled(survey.internal_targeting_flag_key)\n\n const flagsCheck = this.checkFlags(survey)\n return (\n linkedFlagCheck &&\n targetingFlagCheck &&\n internalTargetingFlagCheck &&\n eventBasedTargetingFlagCheck &&\n flagsCheck\n )\n })\n\n return callback(targetingMatchedSurveys)\n }, forceReload)\n }\n\n checkFlags(survey: Survey): boolean {\n if (!survey.feature_flag_keys?.length) {\n return true\n }\n\n return survey.feature_flag_keys.every(({ key, value }) => {\n if (!key || !value) {\n return true\n }\n return this.instance.featureFlags.isFeatureEnabled(value)\n })\n }\n\n // this method is lazily loaded onto the window to avoid loading preact and other dependencies if surveys is not enabled\n private _canActivateRepeatedly(survey: Survey) {\n if (isNullish(assignableWindow.__PosthogExtensions__?.canActivateRepeatedly)) {\n logger.warn('init was not called')\n return false // TODO does it make sense to have a default here?\n }\n return assignableWindow.__PosthogExtensions__.canActivateRepeatedly(survey)\n }\n\n canRenderSurvey(surveyId: string) {\n if (isNullish(this._surveyManager)) {\n logger.warn('init was not called')\n return\n }\n this.getSurveys((surveys) => {\n const survey = surveys.filter((x) => x.id === surveyId)[0]\n this._surveyManager.canRenderSurvey(survey)\n })\n }\n\n renderSurvey(surveyId: string, selector: string) {\n if (isNullish(this._surveyManager)) {\n logger.warn('init was not called')\n return\n }\n this.getSurveys((surveys) => {\n const survey = surveys.filter((x) => x.id === surveyId)[0]\n this._surveyManager.renderSurvey(survey, document?.querySelector(selector))\n })\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","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 width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\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 { IconPosthogLogo } from '../icons'\n// import { getContrastingTextColor } from '../surveys-utils'\n\nexport function PostHogLogo() {\n // const textColor = getContrastingTextColor(backgroundColor)\n\n return (\n <a\n href=\"https://posthog.com\"\n target=\"_blank\"\n rel=\"noopener\"\n // style={{ backgroundColor: backgroundColor, color: textColor }}\n className=\"footer-branding\"\n >\n Survey by {IconPosthogLogo}\n </a>\n )\n}\n","import { window } from '../../../utils/globals'\n\nimport { SurveyAppearance } from '../../../posthog-surveys-types'\n\nimport { useContext } from 'preact/hooks'\nimport { SurveyContext, defaultSurveyAppearance, getContrastingTextColor } from '../surveys-utils'\nimport { PostHogLogo } from './PostHogLogo'\n\nexport function BottomSection({\n text,\n submitDisabled,\n appearance,\n onSubmit,\n link,\n onPreviewSubmit,\n}: {\n text: string\n submitDisabled: boolean\n appearance: SurveyAppearance\n onSubmit: () => void\n link?: string | null\n onPreviewSubmit?: () => void\n}) {\n const { isPreviewMode, isPopup } = useContext(SurveyContext)\n const textColor =\n appearance.submitButtonTextColor ||\n getContrastingTextColor(appearance.submitButtonColor || defaultSurveyAppearance.submitButtonColor)\n return (\n <div className=\"bottom-section\">\n <div className=\"buttons\">\n <button\n className=\"form-submit\"\n disabled={submitDisabled}\n type=\"button\"\n style={isPopup ? { color: textColor } : {}}\n onClick={() => {\n if (link) {\n window?.open(link)\n }\n if (isPreviewMode) {\n onPreviewSubmit?.()\n } else {\n onSubmit()\n }\n }}\n >\n {text}\n </button>\n </div>\n {!appearance.whiteLabel && <PostHogLogo />}\n </div>\n )\n}\n","import { SurveyContext, defaultSurveyAppearance, renderChildrenAsTextOrHtml } from '../surveys-utils'\nimport { cancelSVG } from '../icons'\nimport { useContext } from 'preact/hooks'\nimport { SurveyQuestionDescriptionContentType } from '../../../posthog-surveys-types'\nimport { h } from 'preact'\n\nexport function QuestionHeader({\n question,\n description,\n descriptionContentType,\n backgroundColor,\n forceDisableHtml,\n}: {\n question: string\n description?: string | null\n descriptionContentType?: SurveyQuestionDescriptionContentType\n forceDisableHtml: boolean\n backgroundColor?: string\n}) {\n const { isPopup } = useContext(SurveyContext)\n return (\n <div style={isPopup ? { backgroundColor: backgroundColor || defaultSurveyAppearance.backgroundColor } : {}}>\n <div className=\"survey-question\">{question}</div>\n {description &&\n renderChildrenAsTextOrHtml({\n component: h('div', { className: 'survey-question-description' }),\n children: description,\n renderAsHtml: !forceDisableHtml && descriptionContentType !== 'text',\n })}\n </div>\n )\n}\n\nexport function Cancel({ onClick }: { onClick: () => void }) {\n const { isPreviewMode } = useContext(SurveyContext)\n\n return (\n <div className=\"cancel-btn-wrapper\" onClick={onClick} disabled={isPreviewMode}>\n <button className=\"form-cancel\" onClick={onClick} disabled={isPreviewMode}>\n {cancelSVG}\n </button>\n </div>\n )\n}\n","import { BottomSection } from './BottomSection'\nimport { Cancel } from './QuestionHeader'\nimport { SurveyAppearance, SurveyQuestionDescriptionContentType } from '../../../posthog-surveys-types'\nimport { defaultSurveyAppearance, getContrastingTextColor, renderChildrenAsTextOrHtml } from '../surveys-utils'\nimport { h } from 'preact'\n\nimport { useContext } from 'preact/hooks'\nimport { SurveyContext } from '../../surveys/surveys-utils'\n\nexport function ConfirmationMessage({\n header,\n description,\n contentType,\n forceDisableHtml,\n appearance,\n onClose,\n styleOverrides,\n}: {\n header: string\n description: string\n forceDisableHtml: boolean\n contentType?: SurveyQuestionDescriptionContentType\n appearance: SurveyAppearance\n onClose: () => void\n styleOverrides?: React.CSSProperties\n}) {\n const textColor = getContrastingTextColor(appearance.backgroundColor || defaultSurveyAppearance.backgroundColor)\n\n const { isPopup } = useContext(SurveyContext)\n\n return (\n <>\n <div className=\"thank-you-message\" style={{ ...styleOverrides }}>\n <div className=\"thank-you-message-container\">\n {isPopup && <Cancel onClick={() => onClose()} />}\n <h3 className=\"thank-you-message-header\" style={{ color: textColor }}>\n {header}\n </h3>\n {description &&\n renderChildrenAsTextOrHtml({\n component: h('div', { className: 'thank-you-message-body' }),\n children: description,\n renderAsHtml: !forceDisableHtml && contentType !== 'text',\n style: { color: textColor },\n })}\n {isPopup && (\n <BottomSection\n text={appearance.thankYouMessageCloseButtonText || 'Close'}\n submitDisabled={false}\n appearance={appearance}\n onSubmit={() => onClose()}\n />\n )}\n </div>\n </div>\n </>\n )\n}\n","import { useEffect, useRef, useState } from 'preact/hooks'\nimport { SurveyAppearance } from '../../../posthog-surveys-types'\nimport * as Preact from 'preact'\nimport { getTextColor } from '../surveys-utils'\n\nexport function useContrastingTextColor(options: {\n appearance: SurveyAppearance\n defaultTextColor?: string\n forceUpdate?: boolean\n}): {\n ref: Preact.RefObject<HTMLElement>\n textColor: string\n} {\n const ref = useRef<HTMLElement>(null)\n const [textColor, setTextColor] = useState(options.defaultTextColor ?? 'black')\n\n // TODO: useContext to get the background colors instead of querying the DOM\n useEffect(() => {\n if (ref.current) {\n const color = getTextColor(ref.current)\n setTextColor(color)\n }\n }, [options.appearance, options.forceUpdate])\n\n return {\n ref,\n textColor,\n }\n}\n","import { RefObject } from 'preact'\nimport { useMemo, useRef, useState } from 'preact/hooks'\nimport {\n BasicSurveyQuestion,\n LinkSurveyQuestion,\n MultipleSurveyQuestion,\n RatingSurveyQuestion,\n SurveyAppearance,\n SurveyQuestionType,\n} from '../../../posthog-surveys-types'\nimport { isArray, isNull } from '../../../utils/type-utils'\nimport { useContrastingTextColor } from '../hooks/useContrastingTextColor'\nimport {\n checkSVG,\n dissatisfiedEmoji,\n neutralEmoji,\n satisfiedEmoji,\n veryDissatisfiedEmoji,\n verySatisfiedEmoji,\n} from '../icons'\nimport { getDisplayOrderChoices } from '../surveys-utils'\nimport { BottomSection } from './BottomSection'\nimport { QuestionHeader } from './QuestionHeader'\n\ninterface CommonProps {\n forceDisableHtml: boolean\n appearance: SurveyAppearance\n onSubmit: (res: string | string[] | number | null) => void\n onPreviewSubmit: (res: string | string[] | number | null) => void\n}\n\nexport function OpenTextQuestion({\n question,\n forceDisableHtml,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: CommonProps & {\n question: BasicSurveyQuestion\n}) {\n const textRef = useRef(null)\n const [text, setText] = useState('')\n\n return (\n <div ref={textRef}>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n backgroundColor={appearance.backgroundColor}\n forceDisableHtml={forceDisableHtml}\n />\n <textarea rows={4} placeholder={appearance?.placeholder} onInput={(e) => setText(e.currentTarget.value)} />\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={!text && !question.optional}\n appearance={appearance}\n onSubmit={() => onSubmit(text)}\n onPreviewSubmit={() => onPreviewSubmit(text)}\n />\n </div>\n )\n}\n\nexport function LinkQuestion({\n question,\n forceDisableHtml,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: CommonProps & {\n question: LinkSurveyQuestion\n}) {\n return (\n <>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\n />\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={false}\n link={question.link}\n appearance={appearance}\n onSubmit={() => onSubmit('link clicked')}\n onPreviewSubmit={() => onPreviewSubmit('link clicked')}\n />\n </>\n )\n}\n\nexport function RatingQuestion({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: CommonProps & {\n question: RatingSurveyQuestion\n displayQuestionIndex: number\n}) {\n const scale = question.scale\n const starting = question.scale === 10 ? 0 : 1\n const [rating, setRating] = useState<number | null>(null)\n\n return (\n <>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\n backgroundColor={appearance.backgroundColor}\n />\n <div className=\"rating-section\">\n <div className=\"rating-options\">\n {question.display === 'emoji' && (\n <div className=\"rating-options-emoji\">\n {(question.scale === 3 ? threeScaleEmojis : fiveScaleEmojis).map((emoji, idx) => {\n const active = idx + 1 === rating\n return (\n <button\n className={`ratings-emoji question-${displayQuestionIndex}-rating-${idx} ${\n active ? 'rating-active' : null\n }`}\n value={idx + 1}\n key={idx}\n type=\"button\"\n onClick={() => {\n setRating(idx + 1)\n }}\n style={{\n fill: active\n ? appearance.ratingButtonActiveColor\n : appearance.ratingButtonColor,\n borderColor: appearance.borderColor,\n }}\n >\n {emoji}\n </button>\n )\n })}\n </div>\n )}\n {question.display === 'number' && (\n <div\n className=\"rating-options-number\"\n style={{ gridTemplateColumns: `repeat(${scale - starting + 1}, minmax(0, 1fr))` }}\n >\n {getScaleNumbers(question.scale).map((number, idx) => {\n const active = rating === number\n return (\n <RatingButton\n key={idx}\n displayQuestionIndex={displayQuestionIndex}\n active={active}\n appearance={appearance}\n num={number}\n setActiveNumber={(num) => {\n setRating(num)\n }}\n />\n )\n })}\n </div>\n )}\n </div>\n <div className=\"rating-text\">\n <div>{question.lowerBoundLabel}</div>\n <div>{question.upperBoundLabel}</div>\n </div>\n </div>\n <BottomSection\n text={question.buttonText || appearance?.submitButtonText || 'Submit'}\n submitDisabled={isNull(rating) && !question.optional}\n appearance={appearance}\n onSubmit={() => onSubmit(rating)}\n onPreviewSubmit={() => onPreviewSubmit(rating)}\n />\n </>\n )\n}\n\nexport function RatingButton({\n num,\n active,\n displayQuestionIndex,\n appearance,\n setActiveNumber,\n}: {\n num: number\n active: boolean\n displayQuestionIndex: number\n appearance: SurveyAppearance\n setActiveNumber: (num: number) => void\n}) {\n const { textColor, ref } = useContrastingTextColor({ appearance, defaultTextColor: 'black', forceUpdate: active })\n return (\n <button\n ref={ref as RefObject<HTMLButtonElement>}\n className={`ratings-number question-${displayQuestionIndex}-rating-${num} ${\n active ? 'rating-active' : null\n }`}\n type=\"button\"\n onClick={() => {\n setActiveNumber(num)\n }}\n style={{\n color: textColor,\n backgroundColor: active ? appearance.ratingButtonActiveColor : appearance.ratingButtonColor,\n borderColor: appearance.borderColor,\n }}\n >\n {num}\n </button>\n )\n}\n\nexport function MultipleChoiceQuestion({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: CommonProps & {\n question: MultipleSurveyQuestion\n displayQuestionIndex: number\n}) {\n const textRef = useRef(null)\n const choices = useMemo(() => getDisplayOrderChoices(question), [question])\n const [selectedChoices, setSelectedChoices] = useState<string | string[] | null>(\n question.type === SurveyQuestionType.MultipleChoice ? [] : null\n )\n const [openChoiceSelected, setOpenChoiceSelected] = useState(false)\n const [openEndedInput, setOpenEndedInput] = useState('')\n\n const inputType = question.type === SurveyQuestionType.SingleChoice ? 'radio' : 'checkbox'\n return (\n <div ref={textRef}>\n <QuestionHeader\n question={question.question}\n description={question.description}\n descriptionContentType={question.descriptionContentType}\n forceDisableHtml={forceDisableHtml}\n backgroundColor={appearance.backgroundColor}\n />\n <div className=\"multiple-choice-options limit-height\">\n {/* Remove the last element from the choices, if hasOpenChoice is set */}\n {/* shuffle all other options here if question.shuffleOptions is set */}\n {/* Always ensure that the open ended choice is the last option */}\n {choices.map((choice: string, idx: number) => {\n let choiceClass = 'choice-option'\n const val = choice\n const option = choice\n if (!!question.hasOpenChoice && idx === question.choices.length - 1) {\n choiceClass += ' choice-option-open'\n }\n return (\n <div className={choiceClass}>\n <input\n type={inputType}\n id={`surveyQuestion${displayQuestionIndex}Choice${idx}`}\n name={`question${displayQuestionIndex}`}\n value={val}\n disabled={!val}\n onInput={() => {\n if (question.hasOpenChoice && idx === question.choices.length - 1) {\n return setOpenChoiceSelected(!openChoiceSelected)\n }\n if (question.type === SurveyQuestionType.SingleChoice) {\n return setSelectedChoices(val)\n }\n if (\n question.type === SurveyQuestionType.MultipleChoice &&\n isArray(selectedChoices)\n ) {\n if (selectedChoices.includes(val)) {\n // filter out values because clicking on a selected choice should deselect it\n return setSelectedChoices(\n selectedChoices.filter((choice) => choice !== val)\n )\n }\n return setSelectedChoices([...selectedChoices, val])\n }\n }}\n />\n <label\n htmlFor={`surveyQuestion${displayQuestionIndex}Choice${idx}`}\n style={{ color: 'black' }}\n >\n {question.hasOpenChoice && idx === question.choices.length - 1 ? (\n <>\n <span>{option}:</span>\n <input\n type=\"text\"\n id={`surveyQuestion${displayQuestionIndex}Choice${idx}Open`}\n name={`question${displayQuestionIndex}`}\n onInput={(e) => {\n const userValue = e.currentTarget.value\n if (question.type === SurveyQuestionType.SingleChoice) {\n return setSelectedChoices(userValue)\n }\n if (\n question.type === SurveyQuestionType.MultipleChoice &&\n isArray(selectedChoices)\n ) {\n return setOpenEndedInput(userValue)\n }\n }}\n />\n </>\n ) : (\n option\n )}\n </label>\n <span className=\"choice-check\" style={{ color: 'black' }}>\n {checkSVG}\n </span>\n </div>\n )\n })}\n </div>\n <BottomSection\n text={question.buttonText || 'Submit'}\n submitDisabled={\n (isNull(selectedChoices) ||\n (isArray(selectedChoices) && !openChoiceSelected && selectedChoices.length === 0) ||\n (isArray(selectedChoices) &&\n openChoiceSelected &&\n !openEndedInput &&\n selectedChoices.length === 0 &&\n !question.optional)) &&\n !question.optional\n }\n appearance={appearance}\n onSubmit={() => {\n if (openChoiceSelected && question.type === SurveyQuestionType.MultipleChoice) {\n if (isArray(selectedChoices)) {\n onSubmit([...selectedChoices, openEndedInput])\n }\n } else {\n onSubmit(selectedChoices)\n }\n }}\n onPreviewSubmit={() => {\n if (openChoiceSelected && question.type === SurveyQuestionType.MultipleChoice) {\n if (isArray(selectedChoices)) {\n onPreviewSubmit([...selectedChoices, openEndedInput])\n }\n } else {\n onPreviewSubmit(selectedChoices)\n }\n }}\n />\n </div>\n )\n}\n\nconst threeScaleEmojis = [dissatisfiedEmoji, neutralEmoji, satisfiedEmoji]\nconst fiveScaleEmojis = [veryDissatisfiedEmoji, dissatisfiedEmoji, neutralEmoji, satisfiedEmoji, verySatisfiedEmoji]\nconst fiveScaleNumbers = [1, 2, 3, 4, 5]\nconst sevenScaleNumbers = [1, 2, 3, 4, 5, 6, 7]\nconst tenScaleNumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n\nfunction getScaleNumbers(scale: number): number[] {\n switch (scale) {\n case 5:\n return fiveScaleNumbers\n case 7:\n return sevenScaleNumbers\n case 10:\n return tenScaleNumbers\n default:\n return fiveScaleNumbers\n }\n}\n","import { PostHog } from '../posthog-core'\nimport { doesSurveyUrlMatch } from '../posthog-surveys'\nimport {\n Survey,\n SurveyAppearance,\n SurveyQuestion,\n SurveyQuestionBranchingType,\n SurveyQuestionType,\n SurveyRenderReason,\n SurveyType,\n} from '../posthog-surveys-types'\n\nimport * as Preact from 'preact'\nimport { useContext, useEffect, useMemo, useRef, useState } from 'preact/hooks'\nimport { addEventListener } from '../utils'\nimport { document as _document, window as _window } from '../utils/globals'\nimport { createLogger } from '../utils/logger'\nimport { isNull, isNumber } from '../utils/type-utils'\nimport { createWidgetShadow, createWidgetStyle } from './surveys-widget'\nimport { ConfirmationMessage } from './surveys/components/ConfirmationMessage'\nimport { Cancel } from './surveys/components/QuestionHeader'\nimport {\n LinkQuestion,\n MultipleChoiceQuestion,\n OpenTextQuestion,\n RatingQuestion,\n} from './surveys/components/QuestionTypes'\nimport {\n createShadow,\n defaultSurveyAppearance,\n dismissedSurveyEvent,\n getContrastingTextColor,\n getDisplayOrderQuestions,\n getSurveyResponseKey,\n getSurveySeen,\n hasWaitPeriodPassed,\n sendSurveyEvent,\n style,\n SURVEY_DEFAULT_Z_INDEX,\n SurveyContext,\n} from './surveys/surveys-utils'\nimport { prepareStylesheet } from './utils/stylesheet-loader'\nconst logger = createLogger('[Surveys]')\n\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\n\nfunction getPosthogWidgetClass(surveyId: string) {\n return `.PostHogWidget${surveyId}`\n}\n\nfunction getRatingBucketForResponseValue(responseValue: number, scale: number) {\n if (scale === 3) {\n if (responseValue < 1 || responseValue > 3) {\n throw new Error('The response must be in range 1-3')\n }\n\n return responseValue === 1 ? 'negative' : responseValue === 2 ? 'neutral' : 'positive'\n } else if (scale === 5) {\n if (responseValue < 1 || responseValue > 5) {\n throw new Error('The response must be in range 1-5')\n }\n\n return responseValue <= 2 ? 'negative' : responseValue === 3 ? 'neutral' : 'positive'\n } else if (scale === 7) {\n if (responseValue < 1 || responseValue > 7) {\n throw new Error('The response must be in range 1-7')\n }\n\n return responseValue <= 3 ? 'negative' : responseValue === 4 ? 'neutral' : 'positive'\n } else if (scale === 10) {\n if (responseValue < 0 || responseValue > 10) {\n throw new Error('The response must be in range 0-10')\n }\n\n return responseValue <= 6 ? 'detractors' : responseValue <= 8 ? 'passives' : 'promoters'\n }\n\n throw new Error('The scale must be one of: 3, 5, 7, 10')\n}\n\nexport function getNextSurveyStep(\n survey: Survey,\n currentQuestionIndex: number,\n response: string | string[] | number | null\n) {\n const question = survey.questions[currentQuestionIndex]\n const nextQuestionIndex = currentQuestionIndex + 1\n\n if (!question.branching?.type) {\n if (currentQuestionIndex === survey.questions.length - 1) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n\n if (question.branching.type === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n } else if (question.branching.type === SurveyQuestionBranchingType.SpecificQuestion) {\n if (Number.isInteger(question.branching.index)) {\n return question.branching.index\n }\n } else if (question.branching.type === SurveyQuestionBranchingType.ResponseBased) {\n // Single choice\n if (question.type === SurveyQuestionType.SingleChoice) {\n // :KLUDGE: for now, look up the choiceIndex based on the response\n // TODO: once QuestionTypes.MultipleChoiceQuestion is refactored, pass the selected choiceIndex into this method\n const selectedChoiceIndex = question.choices.indexOf(`${response}`)\n\n if (question.branching?.responseValues?.hasOwnProperty(selectedChoiceIndex)) {\n const nextStep = question.branching.responseValues[selectedChoiceIndex]\n\n // Specific question\n if (Number.isInteger(nextStep)) {\n return nextStep\n }\n\n if (nextStep === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n } else if (question.type === SurveyQuestionType.Rating) {\n if (typeof response !== 'number' || !Number.isInteger(response)) {\n throw new Error('The response type must be an integer')\n }\n\n const ratingBucket = getRatingBucketForResponseValue(response, question.scale)\n\n if (question.branching?.responseValues?.hasOwnProperty(ratingBucket)) {\n const nextStep = question.branching.responseValues[ratingBucket]\n\n // Specific question\n if (Number.isInteger(nextStep)) {\n return nextStep\n }\n\n if (nextStep === SurveyQuestionBranchingType.End) {\n return SurveyQuestionBranchingType.End\n }\n\n return nextQuestionIndex\n }\n }\n\n return nextQuestionIndex\n }\n\n logger.warn('Falling back to next question index due to unexpected branching type')\n return nextQuestionIndex\n}\n\nexport class SurveyManager {\n private posthog: PostHog\n private surveyInFocus: string | null\n private surveyTimeouts: Map<string, NodeJS.Timeout> = new Map()\n\n constructor(posthog: PostHog) {\n this.posthog = posthog\n // This is used to track the survey that is currently in focus. We only show one survey at a time.\n this.surveyInFocus = null\n }\n\n private canShowNextEventBasedSurvey = (): boolean => {\n // with event based surveys, we need to show the next survey without reloading the page.\n // A simple check for div elements with the class name pattern of PostHogSurvey_xyz doesn't work here\n // because preact leaves behind the div element for any surveys responded/dismissed with a <style> node.\n // To alleviate this, we check the last div in the dom and see if it has any elements other than a Style node.\n // if the last PostHogSurvey_xyz div has only one style node, we can show the next survey in the queue\n // without reloading the page.\n const surveyPopups = document.querySelectorAll(`div[class^=PostHogSurvey]`)\n if (surveyPopups.length > 0) {\n return surveyPopups[surveyPopups.length - 1].shadowRoot?.childElementCount === 1\n }\n return true\n }\n\n private clearSurveyTimeout(surveyId: string) {\n const timeout = this.surveyTimeouts.get(surveyId)\n if (timeout) {\n clearTimeout(timeout)\n this.surveyTimeouts.delete(surveyId)\n }\n }\n\n private handlePopoverSurvey = (survey: Survey): void => {\n const surveyWaitPeriodInDays = survey.conditions?.seenSurveyWaitPeriodInDays\n const lastSeenSurveyDate = localStorage.getItem(`lastSeenSurveyDate`)\n\n if (!hasWaitPeriodPassed(lastSeenSurveyDate, surveyWaitPeriodInDays)) {\n return\n }\n\n const surveySeen = getSurveySeen(survey)\n if (!surveySeen) {\n this.clearSurveyTimeout(survey.id)\n this.addSurveyToFocus(survey.id)\n const delaySeconds = survey.appearance?.surveyPopupDelaySeconds || 0\n const shadow = createShadow(style(survey?.appearance), survey.id, undefined, this.posthog)\n if (delaySeconds <= 0) {\n return Preact.render(\n <SurveyPopup\n key={'popover-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n isPopup={true}\n />,\n shadow\n )\n }\n const timeoutId = setTimeout(() => {\n if (!doesSurveyUrlMatch(survey)) {\n return this.removeSurveyFromFocus(survey.id)\n }\n // rendering with surveyPopupDelaySeconds = 0 because we're already handling the timeout here\n Preact.render(\n <SurveyPopup\n key={'popover-survey'}\n posthog={this.posthog}\n survey={{ ...survey, appearance: { ...survey.appearance, surveyPopupDelaySeconds: 0 } }}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n isPopup={true}\n />,\n shadow\n )\n }, delaySeconds * 1000)\n this.surveyTimeouts.set(survey.id, timeoutId)\n }\n }\n\n private handleWidget = (survey: Survey): void => {\n const shadow = createWidgetShadow(survey, this.posthog)\n\n const stylesheetContent = style(survey.appearance)\n const stylesheet = prepareStylesheet(document, stylesheetContent, this.posthog)\n\n if (stylesheet) {\n shadow.appendChild(stylesheet)\n }\n\n Preact.render(\n <FeedbackWidget\n key={'feedback-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n />,\n shadow\n )\n }\n\n private handleWidgetSelector = (survey: Survey): void => {\n const selectorOnPage =\n survey.appearance?.widgetSelector && document.querySelector(survey.appearance.widgetSelector)\n if (selectorOnPage) {\n if (document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 0) {\n this.handleWidget(survey)\n } else if (document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 1) {\n // we have to check if user selector already has a survey listener attached to it because we always have to check if it's on the page or not\n if (!selectorOnPage.getAttribute('PHWidgetSurveyClickListener')) {\n const surveyPopup = document\n .querySelector(getPosthogWidgetClass(survey.id))\n ?.shadowRoot?.querySelector(`.survey-form`) as HTMLFormElement\n\n addEventListener(selectorOnPage, 'click', () => {\n if (surveyPopup) {\n surveyPopup.style.display = surveyPopup.style.display === 'none' ? 'block' : 'none'\n addEventListener(surveyPopup, 'PHSurveyClosed', () => {\n this.removeSurveyFromFocus(survey.id)\n surveyPopup.style.display = 'none'\n })\n }\n })\n\n selectorOnPage.setAttribute('PHWidgetSurveyClickListener', 'true')\n }\n }\n }\n }\n\n /**\n * Sorts surveys by their appearance delay in ascending order. If a survey does not have an appearance delay,\n * it is considered to have a delay of 0.\n * @param surveys\n * @returns The surveys sorted by their appearance delay\n */\n private sortSurveysByAppearanceDelay(surveys: Survey[]): Survey[] {\n return surveys.sort(\n (a, b) => (a.appearance?.surveyPopupDelaySeconds || 0) - (b.appearance?.surveyPopupDelaySeconds || 0)\n )\n }\n\n /**\n * Checks the feature flags associated with this Survey to see if the survey can be rendered.\n * @param survey\n * @param instance\n */\n public canRenderSurvey = (survey: Survey): SurveyRenderReason => {\n const renderReason: SurveyRenderReason = {\n visible: false,\n }\n\n if (survey.end_date) {\n renderReason.disabledReason = `survey was completed on ${survey.end_date}`\n return renderReason\n }\n\n if (survey.type != SurveyType.Popover) {\n renderReason.disabledReason = `Only Popover survey types can be rendered`\n return renderReason\n }\n\n const linkedFlagCheck = survey.linked_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.linked_flag_key)\n : true\n\n if (!linkedFlagCheck) {\n renderReason.disabledReason = `linked feature flag ${survey.linked_flag_key} is false`\n return renderReason\n }\n\n const targetingFlagCheck = survey.targeting_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.targeting_flag_key)\n : true\n\n if (!targetingFlagCheck) {\n renderReason.disabledReason = `targeting feature flag ${survey.targeting_flag_key} is false`\n return renderReason\n }\n\n const internalTargetingFlagCheck = survey.internal_targeting_flag_key\n ? this.posthog.featureFlags.isFeatureEnabled(survey.internal_targeting_flag_key)\n : true\n\n if (!internalTargetingFlagCheck) {\n renderReason.disabledReason = `internal targeting feature flag ${survey.internal_targeting_flag_key} is false`\n return renderReason\n }\n\n renderReason.visible = true\n return renderReason\n }\n\n public renderSurvey = (survey: Survey, selector: Element): void => {\n Preact.render(\n <SurveyPopup\n key={'popover-survey'}\n posthog={this.posthog}\n survey={survey}\n removeSurveyFromFocus={this.removeSurveyFromFocus}\n isPopup={false}\n />,\n selector\n )\n }\n\n public callSurveysAndEvaluateDisplayLogic = (forceReload: boolean = false): void => {\n this.posthog?.getActiveMatchingSurveys((surveys) => {\n const nonAPISurveys = surveys.filter((survey) => survey.type !== 'api')\n\n // Create a queue of surveys sorted by their appearance delay. We will evaluate the display logic\n // for each survey in the queue in order, and only display one survey at a time.\n const nonAPISurveyQueue = this.sortSurveysByAppearanceDelay(nonAPISurveys)\n\n nonAPISurveyQueue.forEach((survey) => {\n // We only evaluate the display logic for one survey at a time\n if (!isNull(this.surveyInFocus)) {\n return\n }\n if (survey.type === SurveyType.Widget) {\n if (\n survey.appearance?.widgetType === 'tab' &&\n document.querySelectorAll(`.PostHogWidget${survey.id}`).length === 0\n ) {\n this.handleWidget(survey)\n }\n if (survey.appearance?.widgetType === 'selector' && survey.appearance?.widgetSelector) {\n this.handleWidgetSelector(survey)\n }\n }\n\n if (survey.type === SurveyType.Popover && this.canShowNextEventBasedSurvey()) {\n this.handlePopoverSurvey(survey)\n }\n })\n }, forceReload)\n }\n\n private addSurveyToFocus = (id: string): void => {\n if (!isNull(this.surveyInFocus)) {\n logger.error(`Survey ${[...this.surveyInFocus]} already in focus. Cannot add survey ${id}.`)\n }\n this.surveyInFocus = id\n }\n\n private removeSurveyFromFocus = (id: string): void => {\n if (this.surveyInFocus !== id) {\n logger.error(`Survey ${id} is not in focus. Cannot remove survey ${id}.`)\n }\n this.clearSurveyTimeout(id)\n this.surveyInFocus = null\n }\n\n // Expose internal state and methods for testing\n public getTestAPI() {\n return {\n addSurveyToFocus: this.addSurveyToFocus,\n removeSurveyFromFocus: this.removeSurveyFromFocus,\n surveyInFocus: this.surveyInFocus,\n surveyTimeouts: this.surveyTimeouts,\n canShowNextEventBasedSurvey: this.canShowNextEventBasedSurvey,\n handleWidget: this.handleWidget,\n handlePopoverSurvey: this.handlePopoverSurvey,\n handleWidgetSelector: this.handleWidgetSelector,\n sortSurveysByAppearanceDelay: this.sortSurveysByAppearanceDelay,\n }\n }\n}\n\nexport const renderSurveysPreview = ({\n survey,\n parentElement,\n previewPageIndex,\n forceDisableHtml,\n onPreviewSubmit,\n posthog,\n}: {\n survey: Survey\n parentElement: HTMLElement\n previewPageIndex: number\n forceDisableHtml?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n posthog?: PostHog\n}) => {\n const stylesheetContent = style(survey.appearance)\n const stylesheet = prepareStylesheet(document, stylesheetContent, posthog)\n\n // Remove previously attached <style>\n Array.from(parentElement.children).forEach((child) => {\n if (child instanceof HTMLStyleElement) {\n parentElement.removeChild(child)\n }\n })\n\n if (stylesheet) {\n parentElement.appendChild(stylesheet)\n }\n\n const textColor = getContrastingTextColor(\n survey.appearance?.backgroundColor || defaultSurveyAppearance.backgroundColor || 'white'\n )\n\n Preact.render(\n <SurveyPopup\n key=\"surveys-render-preview\"\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={{\n position: 'relative',\n right: 0,\n borderBottom: `1px solid ${survey.appearance?.borderColor}`,\n borderRadius: 10,\n color: textColor,\n }}\n onPreviewSubmit={onPreviewSubmit}\n previewPageIndex={previewPageIndex}\n removeSurveyFromFocus={() => {}}\n isPopup={true}\n />,\n parentElement\n )\n}\n\nexport const renderFeedbackWidgetPreview = ({\n survey,\n root,\n forceDisableHtml,\n posthog,\n}: {\n survey: Survey\n root: HTMLElement\n forceDisableHtml?: boolean\n posthog?: PostHog\n}) => {\n const stylesheetContent = createWidgetStyle(survey.appearance?.widgetColor)\n const stylesheet = prepareStylesheet(document, stylesheetContent, posthog)\n if (stylesheet) {\n root.appendChild(stylesheet)\n }\n\n Preact.render(\n <FeedbackWidget\n key={'feedback-render-preview'}\n forceDisableHtml={forceDisableHtml}\n survey={survey}\n readOnly={true}\n removeSurveyFromFocus={() => {}}\n />,\n root\n )\n}\n\n// This is the main exported function\nexport function generateSurveys(posthog: PostHog) {\n // NOTE: Important to ensure we never try and run surveys without a window environment\n if (!document || !window) {\n return\n }\n\n const surveyManager = new SurveyManager(posthog)\n surveyManager.callSurveysAndEvaluateDisplayLogic(true)\n\n // recalculate surveys every second to check if URL or selectors have changed\n setInterval(() => {\n surveyManager.callSurveysAndEvaluateDisplayLogic(false)\n }, 1000)\n return surveyManager\n}\n\ntype UseHideSurveyOnURLChangeProps = {\n survey: Pick<Survey, 'id' | 'conditions'>\n removeSurveyFromFocus: (id: string) => void\n setSurveyVisible: (visible: boolean) => void\n isPreviewMode?: boolean\n}\n\n/**\n * This hook handles URL-based survey visibility after the initial mount.\n * The initial URL check is handled by the `getActiveMatchingSurveys` method in the `PostHogSurveys` class,\n * which ensures the URL matches before displaying a survey for the first time.\n * That is the method that is called every second to see if there's a matching survey.\n *\n * This separation of concerns means:\n * 1. Initial URL matching is done by `getActiveMatchingSurveys` before displaying the survey\n * 2. Subsequent URL changes are handled here to hide the survey as the user navigates\n */\nexport function useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus,\n setSurveyVisible,\n isPreviewMode = false,\n}: UseHideSurveyOnURLChangeProps) {\n useEffect(() => {\n if (isPreviewMode || !survey.conditions?.url) {\n return\n }\n\n const checkUrlMatch = () => {\n const urlCheck = doesSurveyUrlMatch(survey)\n if (!urlCheck) {\n setSurveyVisible(false)\n return removeSurveyFromFocus(survey.id)\n }\n }\n\n // Listen for browser back/forward browser history changes\n addEventListener(window, 'popstate', checkUrlMatch)\n // Listen for hash changes, for SPA frameworks that use hash-based routing\n // The hashchange event is fired when the fragment identifier of the URL has changed (the part of the URL beginning with and following the # symbol).\n addEventListener(window, 'hashchange', checkUrlMatch)\n\n // Listen for SPA navigation\n const originalPushState = window.history.pushState\n const originalReplaceState = window.history.replaceState\n\n window.history.pushState = function (...args) {\n originalPushState.apply(this, args)\n checkUrlMatch()\n }\n\n window.history.replaceState = function (...args) {\n originalReplaceState.apply(this, args)\n checkUrlMatch()\n }\n\n return () => {\n window.removeEventListener('popstate', checkUrlMatch)\n window.removeEventListener('hashchange', checkUrlMatch)\n window.history.pushState = originalPushState\n window.history.replaceState = originalReplaceState\n }\n }, [isPreviewMode, survey, removeSurveyFromFocus, setSurveyVisible])\n}\n\nexport function usePopupVisibility(\n survey: Survey,\n posthog: PostHog | undefined,\n millisecondDelay: number,\n isPreviewMode: boolean,\n removeSurveyFromFocus: (id: string) => void\n) {\n const [isPopupVisible, setIsPopupVisible] = useState(isPreviewMode || millisecondDelay === 0)\n const [isSurveySent, setIsSurveySent] = useState(false)\n\n useEffect(() => {\n if (!posthog) {\n logger.error('usePopupVisibility hook called without a PostHog instance.')\n return\n }\n if (isPreviewMode) {\n return\n }\n\n const handleSurveyClosed = () => {\n removeSurveyFromFocus(survey.id)\n setIsPopupVisible(false)\n }\n\n const handleSurveySent = () => {\n if (!survey.appearance?.displayThankYouMessage) {\n removeSurveyFromFocus(survey.id)\n setIsPopupVisible(false)\n } else {\n setIsSurveySent(true)\n removeSurveyFromFocus(survey.id)\n if (survey.appearance?.autoDisappear) {\n setTimeout(() => {\n setIsPopupVisible(false)\n }, 5000)\n }\n }\n }\n\n const showSurvey = () => {\n // check if the url is still matching, necessary for delayed surveys, as the URL may have changed\n if (!doesSurveyUrlMatch(survey)) {\n return\n }\n\n setIsPopupVisible(true)\n window.dispatchEvent(new Event('PHSurveyShown'))\n posthog.capture('survey shown', {\n $survey_name: survey.name,\n $survey_id: survey.id,\n $survey_iteration: survey.current_iteration,\n $survey_iteration_start_date: survey.current_iteration_start_date,\n sessionRecordingUrl: posthog.get_session_replay_url?.(),\n })\n localStorage.setItem('lastSeenSurveyDate', new Date().toISOString())\n setTimeout(() => {\n const inputField = document\n .querySelector(getPosthogWidgetClass(survey.id))\n ?.shadowRoot?.querySelector('textarea, input[type=\"text\"]') as HTMLElement\n if (inputField) {\n inputField.focus()\n }\n }, 100)\n }\n\n addEventListener(window, 'PHSurveyClosed', handleSurveyClosed)\n addEventListener(window, 'PHSurveySent', handleSurveySent)\n\n if (millisecondDelay > 0) {\n // This path is only used for direct usage of SurveyPopup,\n // not for surveys managed by SurveyManager\n const timeoutId = setTimeout(showSurvey, millisecondDelay)\n return () => {\n clearTimeout(timeoutId)\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed)\n window.removeEventListener('PHSurveySent', handleSurveySent)\n }\n } else {\n // This is the path used for surveys managed by SurveyManager\n showSurvey()\n return () => {\n window.removeEventListener('PHSurveyClosed', handleSurveyClosed)\n window.removeEventListener('PHSurveySent', handleSurveySent)\n }\n }\n }, [])\n\n useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus,\n setSurveyVisible: setIsPopupVisible,\n isPreviewMode,\n })\n\n return { isPopupVisible, isSurveySent, setIsPopupVisible }\n}\n\ninterface SurveyPopupProps {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n style?: React.CSSProperties\n previewPageIndex?: number | undefined\n removeSurveyFromFocus: (id: string) => void\n isPopup?: boolean\n onPreviewSubmit?: (res: string | string[] | number | null) => void\n onPopupSurveyDismissed?: () => void\n onPopupSurveySent?: () => void\n}\n\nexport function SurveyPopup({\n survey,\n forceDisableHtml,\n posthog,\n style,\n previewPageIndex,\n removeSurveyFromFocus,\n isPopup,\n onPreviewSubmit = () => {},\n onPopupSurveyDismissed = () => {},\n onPopupSurveySent = () => {},\n}: SurveyPopupProps) {\n const isPreviewMode = Number.isInteger(previewPageIndex)\n // NB: The client-side code passes the millisecondDelay in seconds, but setTimeout expects milliseconds, so we multiply by 1000\n const surveyPopupDelayMilliseconds = survey.appearance?.surveyPopupDelaySeconds\n ? survey.appearance.surveyPopupDelaySeconds * 1000\n : 0\n const { isPopupVisible, isSurveySent, setIsPopupVisible } = usePopupVisibility(\n survey,\n posthog,\n surveyPopupDelayMilliseconds,\n isPreviewMode,\n removeSurveyFromFocus\n )\n const shouldShowConfirmation = isSurveySent || previewPageIndex === survey.questions.length\n const confirmationBoxLeftStyle = style?.left && isNumber(style?.left) ? { left: style.left - 40 } : {}\n\n if (isPreviewMode) {\n style = style || {}\n style.left = 'unset'\n style.right = 'unset'\n style.transform = 'unset'\n }\n\n return isPopupVisible ? (\n <SurveyContext.Provider\n value={{\n isPreviewMode,\n previewPageIndex: previewPageIndex,\n onPopupSurveyDismissed: () => {\n dismissedSurveyEvent(survey, posthog, isPreviewMode)\n onPopupSurveyDismissed()\n },\n isPopup: isPopup || false,\n onPreviewSubmit,\n onPopupSurveySent: () => {\n onPopupSurveySent()\n },\n }}\n >\n {!shouldShowConfirmation ? (\n <Questions\n survey={survey}\n forceDisableHtml={!!forceDisableHtml}\n posthog={posthog}\n styleOverrides={style}\n />\n ) : (\n <ConfirmationMessage\n header={survey.appearance?.thankYouMessageHeader || 'Thank you!'}\n description={survey.appearance?.thankYouMessageDescription || ''}\n forceDisableHtml={!!forceDisableHtml}\n contentType={survey.appearance?.thankYouMessageDescriptionContentType}\n appearance={survey.appearance || defaultSurveyAppearance}\n styleOverrides={{ ...style, ...confirmationBoxLeftStyle }}\n onClose={() => setIsPopupVisible(false)}\n />\n )}\n </SurveyContext.Provider>\n ) : null\n}\n\nexport function Questions({\n survey,\n forceDisableHtml,\n posthog,\n styleOverrides,\n}: {\n survey: Survey\n forceDisableHtml: boolean\n posthog?: PostHog\n styleOverrides?: React.CSSProperties\n}) {\n const textColor = getContrastingTextColor(\n survey.appearance?.backgroundColor || defaultSurveyAppearance.backgroundColor\n )\n const [questionsResponses, setQuestionsResponses] = useState({})\n const { previewPageIndex, onPopupSurveyDismissed, isPopup, onPreviewSubmit, onPopupSurveySent } =\n useContext(SurveyContext)\n const [currentQuestionIndex, setCurrentQuestionIndex] = useState(previewPageIndex || 0)\n const surveyQuestions = useMemo(() => getDisplayOrderQuestions(survey), [survey])\n\n // Sync preview state\n useEffect(() => {\n setCurrentQuestionIndex(previewPageIndex ?? 0)\n }, [previewPageIndex])\n\n const onNextButtonClick = ({\n res,\n displayQuestionIndex,\n questionId,\n }: {\n res: string | string[] | number | null\n displayQuestionIndex: number\n questionId?: string\n }) => {\n if (!posthog) {\n logger.error('onNextButtonClick called without a PostHog instance.')\n return\n }\n\n if (!questionId) {\n logger.error('onNextButtonClick called without a questionId.')\n return\n }\n\n const responseKey = getSurveyResponseKey(questionId)\n\n setQuestionsResponses({ ...questionsResponses, [responseKey]: res })\n\n const nextStep = getNextSurveyStep(survey, displayQuestionIndex, res)\n if (nextStep === SurveyQuestionBranchingType.End) {\n sendSurveyEvent({ ...questionsResponses, [responseKey]: res }, survey, posthog)\n onPopupSurveySent()\n } else {\n setCurrentQuestionIndex(nextStep)\n }\n }\n\n return (\n <form\n className=\"survey-form\"\n style={\n isPopup\n ? {\n color: textColor,\n borderColor: survey.appearance?.borderColor,\n ...styleOverrides,\n }\n : {}\n }\n >\n {surveyQuestions.map((question, displayQuestionIndex) => {\n const isVisible = currentQuestionIndex === displayQuestionIndex\n return (\n isVisible && (\n <div\n className=\"survey-box\"\n style={\n isPopup\n ? {\n backgroundColor:\n survey.appearance?.backgroundColor ||\n defaultSurveyAppearance.backgroundColor,\n }\n : {}\n }\n >\n {isPopup && (\n <Cancel\n onClick={() => {\n onPopupSurveyDismissed()\n }}\n />\n )}\n {getQuestionComponent({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance: survey.appearance || defaultSurveyAppearance,\n onSubmit: (res) =>\n onNextButtonClick({\n res,\n displayQuestionIndex,\n questionId: question.id,\n }),\n onPreviewSubmit,\n })}\n </div>\n )\n )\n })}\n </form>\n )\n}\n\nexport function FeedbackWidget({\n survey,\n forceDisableHtml,\n posthog,\n readOnly,\n removeSurveyFromFocus,\n}: {\n survey: Survey\n forceDisableHtml?: boolean\n posthog?: PostHog\n readOnly?: boolean\n removeSurveyFromFocus: (id: string) => void\n}): JSX.Element | null {\n const [isFeedbackButtonVisible, setIsFeedbackButtonVisible] = useState(true)\n const [showSurvey, setShowSurvey] = useState(false)\n const [styleOverrides, setStyle] = useState({})\n const widgetRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (!posthog) {\n logger.error('FeedbackWidget called without a PostHog instance.')\n return\n }\n if (readOnly) {\n return\n }\n\n if (survey.appearance?.widgetType === 'tab') {\n if (widgetRef.current) {\n const widgetPos = widgetRef.current.getBoundingClientRect()\n const style = {\n top: '50%',\n left: parseInt(`${widgetPos.right - 360}`),\n bottom: 'auto',\n borderRadius: 10,\n borderBottom: `1.5px solid ${survey.appearance?.borderColor || '#c9c6c6'}`,\n }\n setStyle(style)\n }\n }\n if (survey.appearance?.widgetType === 'selector') {\n const widget = document.querySelector(survey.appearance.widgetSelector || '') ?? undefined\n\n addEventListener(widget, 'click', (event) => {\n // Calculate position based on the selector button\n const buttonRect = (event.currentTarget as HTMLElement).getBoundingClientRect()\n const viewportHeight = window.innerHeight\n\n // Get survey width from maxWidth or default to 300px\n const surveyWidth = parseInt(survey.appearance?.maxWidth || '300')\n\n // Calculate horizontal center position of the button\n const buttonCenterX = buttonRect.left + buttonRect.width / 2\n\n // Calculate horizontal center position\n let left = buttonCenterX - surveyWidth / 2\n\n // Ensure the survey doesn't go off-screen horizontally\n const rightEdge = left + surveyWidth\n if (rightEdge > window.innerWidth) {\n left = window.innerWidth - surveyWidth - 20 // 20px padding from right edge\n }\n if (left < 20) {\n left = 20 // 20px padding from left edge\n }\n\n // Determine if we should show above or below\n let showAbove = false\n\n // Check if there's enough space below (need at least 300px)\n // If not enough space below, show above\n if (buttonRect.bottom + 300 > viewportHeight) {\n showAbove = true\n }\n\n // Simple spacing between button and survey\n const spacing = 12\n\n // Calculate positions\n let topPosition\n\n if (showAbove) {\n // Problem: When showing above, we're trying to position based on an estimated height,\n // but we don't know the actual height of the survey yet.\n // Solution: Instead of using top positioning for above, use bottom positioning\n // This will anchor the survey to the bottom edge at the button's top position\n topPosition = null // We'll use bottom positioning instead\n } else {\n // When showing below, position the top of the survey below the button plus spacing\n topPosition = buttonRect.bottom + window.scrollY + spacing\n }\n\n // Set style overrides for positioning\n setStyle({\n position: 'fixed',\n top: showAbove ? 'auto' : topPosition + 'px',\n left: left + 'px',\n right: 'auto',\n bottom: showAbove ? window.innerHeight - buttonRect.top + spacing + 'px' : 'auto',\n transform: 'none',\n border: `1.5px solid ${survey.appearance?.borderColor || '#c9c6c6'}`,\n borderRadius: '10px',\n width: `${surveyWidth}px`,\n zIndex: SURVEY_DEFAULT_Z_INDEX,\n boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',\n maxHeight: showAbove\n ? `calc(100vh - 40px - ${spacing * 2}px)`\n : `calc(100vh - ${topPosition}px - 20px)`,\n })\n\n setShowSurvey(!showSurvey)\n })\n\n widget?.setAttribute('PHWidgetSurveyClickListener', 'true')\n }\n }, [])\n\n useHideSurveyOnURLChange({\n survey,\n removeSurveyFromFocus,\n setSurveyVisible: setIsFeedbackButtonVisible,\n })\n\n if (!isFeedbackButtonVisible) {\n return null\n }\n\n const resetShowSurvey = () => {\n setShowSurvey(false)\n }\n\n return (\n <Preact.Fragment>\n {survey.appearance?.widgetType === 'tab' && (\n <div\n className=\"ph-survey-widget-tab\"\n ref={widgetRef}\n onClick={() => !readOnly && setShowSurvey(!showSurvey)}\n style={{ color: getContrastingTextColor(survey.appearance.widgetColor) }}\n >\n <div className=\"ph-survey-widget-tab-icon\"></div>\n {survey.appearance?.widgetLabel || ''}\n </div>\n )}\n {showSurvey && (\n <SurveyPopup\n key={'feedback-widget-survey'}\n posthog={posthog}\n survey={survey}\n forceDisableHtml={forceDisableHtml}\n style={styleOverrides}\n removeSurveyFromFocus={removeSurveyFromFocus}\n isPopup={true}\n onPopupSurveyDismissed={resetShowSurvey}\n onPopupSurveySent={resetShowSurvey}\n />\n )}\n </Preact.Fragment>\n )\n}\n\ninterface GetQuestionComponentProps {\n question: SurveyQuestion\n forceDisableHtml: boolean\n displayQuestionIndex: number\n appearance: SurveyAppearance\n onSubmit: (res: string | string[] | number | null) => void\n onPreviewSubmit: (res: string | string[] | number | null) => void\n}\n\nconst getQuestionComponent = ({\n question,\n forceDisableHtml,\n displayQuestionIndex,\n appearance,\n onSubmit,\n onPreviewSubmit,\n}: GetQuestionComponentProps): JSX.Element => {\n const questionComponents = {\n [SurveyQuestionType.Open]: OpenTextQuestion,\n [SurveyQuestionType.Link]: LinkQuestion,\n [SurveyQuestionType.Rating]: RatingQuestion,\n [SurveyQuestionType.SingleChoice]: MultipleChoiceQuestion,\n [SurveyQuestionType.MultipleChoice]: MultipleChoiceQuestion,\n }\n\n const commonProps = {\n question,\n forceDisableHtml,\n appearance,\n onPreviewSubmit: (res: string | string[] | number | null) => {\n onPreviewSubmit(res)\n },\n onSubmit: (res: string | string[] | number | null) => {\n onSubmit(res)\n },\n }\n\n const additionalProps: Record<SurveyQuestionType, any> = {\n [SurveyQuestionType.Open]: {},\n [SurveyQuestionType.Link]: {},\n [SurveyQuestionType.Rating]: { displayQuestionIndex },\n [SurveyQuestionType.SingleChoice]: { displayQuestionIndex },\n [SurveyQuestionType.MultipleChoice]: { displayQuestionIndex },\n }\n\n const Component = questionComponents[question.type]\n const componentProps = { ...commonProps, ...additionalProps[question.type] }\n\n return <Component {...componentProps} />\n}\n","import { PostHog } from '../posthog-core'\nimport { Survey } from '../posthog-surveys-types'\nimport { document as _document } from '../utils/globals'\nimport { SURVEY_DEFAULT_Z_INDEX } from './surveys/surveys-utils'\nimport { prepareStylesheet } from './utils/stylesheet-loader'\n\n// We cast the types here which is dangerous but protected by the top level generateSurveys call\nconst document = _document as Document\n\nexport function createWidgetShadow(survey: Survey, posthog?: PostHog) {\n const div = document.createElement('div')\n div.className = `PostHogWidget${survey.id}`\n const shadow = div.attachShadow({ mode: 'open' })\n const widgetStyleSheet = createWidgetStyle(survey.appearance?.widgetColor)\n\n const stylesheet = prepareStylesheet(document, widgetStyleSheet, posthog)\n if (stylesheet) {\n shadow.append(stylesheet)\n }\n\n document.body.appendChild(div)\n return shadow\n}\n\nexport function createWidgetStyle(widgetColor?: string) {\n return `\n .ph-survey-widget-tab {\n position: fixed;\n top: 50%;\n right: 0;\n background: ${widgetColor || '#e0a045'};\n color: white;\n transform: rotate(-90deg) translate(0, -100%);\n transform-origin: right top;\n min-width: 40px;\n padding: 8px 12px;\n font-weight: 500;\n border-radius: 3px 3px 0 0;\n text-align: center;\n cursor: pointer;\n z-index: ${SURVEY_DEFAULT_Z_INDEX};\n }\n .ph-survey-widget-tab:hover {\n padding-bottom: 13px;\n }\n .ph-survey-widget-button {\n position: fixed;\n }\n `\n}\n"],"names":["SurveyType","SurveyQuestionType","SurveyQuestionBranchingType","SurveySchedule","SURVEYS_ACTIVATED","EMPTY_OBJ","EMPTY_ARR","IS_NON_DIMENSIONAL","__u","win","window","undefined","global","globalThis","nativeForEach","Array","prototype","forEach","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","Compression","assignableWindow","nativeIsArray","isArray","toString","Object","obj","call","isUndefined","x","isNull","isNumber","_createLogger","prefix","logger","_log","level","console","consoleLog","_len","arguments","length","args","_key","info","_len2","_key2","warn","_len3","_key3","error","_len4","_key4","critical","_len5","_key5","uninitializedWarning","methodName","concat","createLogger","additionalPrefix","prepareStylesheet","innerText","posthog","_posthog$config","stylesheet","createElement","config","prepare_external_dependency_stylesheet","_window","SurveySeenPrefix","SURVEY_DEFAULT_Z_INDEX","getFontFamily","fontFamily","defaultFontStack","hex2rgb","c","hexColor","replace","parseInt","slice","getContrastingTextColor","rgb","color","defaultBackgroundColor","startsWith","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","toLowerCase","colorMatch","match","r","g","b","Math","sqrt","defaultSurveyAppearance","backgroundColor","submitButtonColor","submitButtonTextColor","ratingButtonColor","ratingButtonActiveColor","borderColor","placeholder","whiteLabel","displayThankYouMessage","thankYouMessageHeader","position","sendSurveyEvent","_posthog$get_session_","responses","survey","localStorage","setItem","getSurveySeenKey","capture","_objectSpread","$survey_name","name","$survey_id","id","$survey_iteration","current_iteration","$survey_iteration_start_date","current_iteration_start_date","$survey_questions","questions","map","question","index","sessionRecordingUrl","get_session_replay_url","$set","getSurveyInteractionProperty","dispatchEvent","Event","dismissedSurveyEvent","readOnly","_posthog$get_session_2","shuffle","array","a","sort","floor","random","value","reverseIfUnshuffled","unshuffled","shuffled","every","val","reverse","getDisplayOrderQuestions","appearance","shuffleQuestions","surveySeenKey","action","surveyProperty","SurveyContext","createContext","isPreviewMode","previewPageIndex","onPopupSurveyDismissed","isPopup","onPreviewSubmit","onPopupSurveySent","renderChildrenAsTextOrHtml","_ref","component","children","renderAsHtml","style","cloneElement","dangerouslySetInnerHTML","__html","breaker","eachArray","iterator","thisArg","i","l","addEventListener","element","event","callback","options","passive","source","item","push","extendArray","isMatchingRegex","pattern","str","RegExp","_unused","isValidRegex","test","_unused2","SimpleEventEmitter","constructor","_defineProperty","this","events","on","listener","filter","emit","payload","ActionMatcher","instance","step","checkStepEvent","checkStepUrl","checkStepElement","actionEvents","Set","actionRegistry","init","_this$instance","_addCaptureHook","_this$instance2","matchEventToAction","eventName","eventPayload","register","actions","_this$instance3","_this$instance4","_this$actionRegistry","_action$steps","add","steps","_this$actionEvents","autocapture","_this$instance5","selectorsToWatch","_action$steps2","selector","setElementSelectors","_this$actionRegistry2","has","size","checkAction","_debugEventEmitter","_addActionHook","onAction","data","checkStep","cb","url","_event$properties","eventUrl","properties","$current_url","matchString","url_matching","matching","adjustedRegExpStringPattern","escapeStringRegexp","href","tag_name","text","getElementsList","some","href_matching","text_matching","$el_text","_event$properties2","elementSelectors","$element_selectors","includes","$elements","SurveyEventReceiver","eventToSurveys","Map","actionToSurveys","surveys","setupEventBasedSurveys","setupActionBasedSurveys","actionBasedSurveys","_survey$conditions","_survey$conditions2","_survey$conditions2$a","_survey$conditions2$a2","conditions","values","actionMatcher","actionName","_survey$conditions3","_survey$conditions4","_survey$conditions4$a","_survey$conditions5","_survey$conditions5$a","_survey$conditions5$a2","_this$actionMatcher","_survey$conditions6","_survey$conditions6$a","_survey$conditions6$a2","knownSurveys","get","set","_survey$conditions7","_survey$conditions8","_survey$conditions8$e","_survey$conditions8$e2","matchEventToSurvey","onEvent","_survey$conditions9","_survey$conditions9$e","_survey$conditions9$e2","_this$instance3$persi","existingActivatedSurveys","persistence","props","SURVEY_SHOWN_EVENT_NAME","_eventPayload$propert","surveyId","indexOf","splice","_updateActivatedSurveys","_this$instance4$persi","activatedSurveys","_this$instance5$persi","getSurveys","_this$instance6","_this$instance6$persi","getEventToSurveys","_getActionMatcher","surveyValidationMap","icontains","targets","target","not_icontains","regex","not_regex","exact","is_not","doesSurveyUrlMatch","_window$location","matchType","urlMatchType","currentIndex","currentComponent","previousComponent","prevRaf","currentHook","afterPaintEffects","EMPTY","oldBeforeDiff","__b","oldBeforeRender","__r","oldAfterDiff","diffed","oldCommit","__c","oldBeforeUnmount","unmount","getHookState","type","__h","hooks","__H","__","__V","useState","initialState","useReducer","reducer","hookState","_reducer","invokeOrReturn","n","currentValue","__N","nextValue","setState","_hasScuFromHooks","updateHookState","f","p","s","stateHooks","prevScu","shouldUpdate","hookItem","shouldComponentUpdate","prevCWU","componentWillUpdate","__e","tmp","useEffect","state","__s","argsChanged","_pendingArgs","useRef","initialValue","useMemo","current","factory","useContext","context","provider","sub","flushAfterPaintEffects","shift","__P","invokeCleanup","invokeEffect","e","__v","vnode","t","requestAnimationFrame","afterNextFrame","commitQueue","hasErrored","HAS_RAF","raf","done","clearTimeout","timeout","cancelAnimationFrame","setTimeout","hook","comp","cleanup","oldArgs","newArgs","arg","satisfiedEmoji","_jsx","className","xmlns","height","viewBox","width","d","neutralEmoji","dissatisfiedEmoji","veryDissatisfiedEmoji","verySatisfiedEmoji","cancelSVG","fill","IconPosthogLogo","_jsxs","maskType","maskUnits","y","mask","transform","checkSVG","PostHogLogo","rel","BottomSection","submitDisabled","onSubmit","link","textColor","disabled","onClick","open","QuestionHeader","description","descriptionContentType","forceDisableHtml","h","Cancel","_ref2","ConfirmationMessage","header","contentType","onClose","styleOverrides","_Fragment","thankYouMessageCloseButtonText","useContrastingTextColor","_options$defaultTextC","ref","setTextColor","defaultTextColor","el","getComputedStyle","getTextColor","forceUpdate","OpenTextQuestion","textRef","setText","rows","onInput","currentTarget","buttonText","optional","LinkQuestion","RatingQuestion","_ref3","displayQuestionIndex","scale","starting","rating","setRating","display","threeScaleEmojis","fiveScaleEmojis","emoji","idx","active","gridTemplateColumns","getScaleNumbers","number","RatingButton","num","setActiveNumber","lowerBoundLabel","upperBoundLabel","submitButtonText","_ref4","MultipleChoiceQuestion","_ref5","choices","shuffleOptions","displayOrderChoices","openEndedChoice","hasOpenChoice","pop","shuffledOptions","getDisplayOrderChoices","selectedChoices","setSelectedChoices","MultipleChoice","openChoiceSelected","setOpenChoiceSelected","openEndedInput","setOpenEndedInput","inputType","SingleChoice","choice","choiceClass","option","htmlFor","userValue","fiveScaleNumbers","sevenScaleNumbers","tenScaleNumbers","_document","getNextSurveyStep","currentQuestionIndex","response","_question$branching","nextQuestionIndex","branching","End","SpecificQuestion","Number","isInteger","ResponseBased","_question$branching2","_question$branching2$","selectedChoiceIndex","responseValues","hasOwnProperty","nextStep","Rating","_question$branching3","_question$branching3$","Error","ratingBucket","responseValue","getRatingBucketForResponseValue","renderSurveysPreview","_survey$appearance6","_survey$appearance7","parentElement","stylesheetContent","maxWidth","zIndex","left","right","center","disabledButtonOpacity","from","child","HTMLStyleElement","removeChild","appendChild","Preact","SurveyPopup","borderBottom","borderRadius","removeSurveyFromFocus","renderFeedbackWidgetPreview","_survey$appearance8","widgetColor","root","FeedbackWidget","useHideSurveyOnURLChange","setSurveyVisible","checkUrlMatch","originalPushState","history","pushState","originalReplaceState","replaceState","apply","removeEventListener","_survey$appearance11","_style","_style2","_survey$appearance12","_survey$appearance13","_survey$appearance14","surveyPopupDelayMilliseconds","surveyPopupDelaySeconds","isPopupVisible","isSurveySent","setIsPopupVisible","millisecondDelay","setIsSurveySent","handleSurveyClosed","handleSurveySent","_survey$appearance9","_survey$appearance10","autoDisappear","showSurvey","Date","toISOString","_document$querySelect3","_document$querySelect4","inputField","querySelector","shadowRoot","focus","timeoutId","usePopupVisibility","shouldShowConfirmation","confirmationBoxLeftStyle","Provider","thankYouMessageDescription","thankYouMessageDescriptionContentType","Questions","_survey$appearance15","_survey$appearance16","questionsResponses","setQuestionsResponses","setCurrentQuestionIndex","surveyQuestions","_survey$appearance17","getQuestionComponent","res","_ref6","questionId","responseKey","getSurveyResponseKey","onNextButtonClick","_ref7","_survey$appearance23","_survey$appearance24","isFeedbackButtonVisible","setIsFeedbackButtonVisible","setShowSurvey","setStyle","widgetRef","_survey$appearance18","_survey$appearance20","widgetType","_survey$appearance19","widgetPos","getBoundingClientRect","top","bottom","_document$querySelect5","widget","widgetSelector","_survey$appearance21","_survey$appearance22","buttonRect","viewportHeight","innerHeight","surveyWidth","innerWidth","showAbove","topPosition","scrollY","border","boxShadow","maxHeight","spacing","setAttribute","resetShowSurvey","widgetLabel","_ref8","questionComponents","Open","Link","commonProps","additionalProps","Component","componentProps"],"mappings":"urBAqCO,oBCMKA,EA4CAC,EAQAC,EAoDAC,ED9GCC,EAAoB,qBEzBpBC,EAAgC,CAAA,EAChCC,EAAY,GACZC,EACZ,06CAd2B,sCAAA,uoBAML,8EAFK,iFAAAC,KAAA,qIAEL,gTAFK,oeAEL,qEAAA,iFAAA,mxCAJO,iBAFF,kyDASF,sGATE,w2GD8C3B,SAJWR,GAAAA,EAAU,QAAA,UAAVA,EAAU,IAAA,MAAVA,EAAU,OAAA,QAAVA,CAIX,CAJWA,IAAAA,EAAU,CAAA,IAkDrB,SANWC,GAAAA,EAAkB,KAAA,OAAlBA,EAAkB,eAAA,kBAAlBA,EAAkB,aAAA,gBAAlBA,EAAkB,OAAA,SAAlBA,EAAkB,KAAA,MAAlBA,CAMX,CANWA,IAAAA,EAAkB,CAAA,IAa7B,SALWC,GAAA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