@brainfish-ai/widgets-initiator 1.20.4 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,6 @@
1
- export declare const initBrainfishAnalytics: (widgetKey: string, accessKey: string, apiHost: string, analyticsApiHost?: string, enableRecording?: boolean, recordingBlocklist?: string[], _allowLocalhostRecording?: boolean, _allowScreenRecording?: boolean) => Promise<void>;
1
+ export interface RecordingOptions {
2
+ blocklist?: string[];
3
+ sampleRate?: number;
4
+ _allowLocalhostRecording?: boolean;
5
+ }
6
+ export declare const initBrainfishAnalytics: (widgetKey: string, accessKey: string, apiHost: string, analyticsApiHost?: string, enableRecording?: boolean, recordingOptions?: RecordingOptions) => Promise<void>;
@@ -1,4 +1,4 @@
1
- import { type Config } from "@brainfish-ai/widgets-common";
1
+ import { type Config } from '@brainfish-ai/widgets-common';
2
2
  interface Props {
3
3
  config: Config;
4
4
  widgetUrl: string;
@@ -6,5 +6,5 @@ interface Props {
6
6
  widgetHost: string;
7
7
  widgetKey: string;
8
8
  }
9
- export declare const initSearchBar: ({ config, widgetUrl, apiHost, widgetHost, widgetKey }: Props) => undefined;
9
+ export declare const initSearchBar: ({ config, widgetUrl, apiHost, widgetHost, widgetKey, }: Props) => undefined;
10
10
  export {};
@@ -1,6 +1,6 @@
1
1
  import { IframeStateManager } from '../managers/IframeStateManager';
2
2
  import { WidgetType } from '@brainfish-ai/widgets-common';
3
- export declare function initMessageListener(iframe: HTMLIFrameElement, { widgetHost, apiHost, widgetKey, widgetType, signal, stateManager, }: {
3
+ export declare function initMessageListener(iframe: HTMLIFrameElement, { widgetHost, apiHost, widgetKey, widgetType: _widgetType, signal, stateManager, }: {
4
4
  widgetHost: string;
5
5
  apiHost: string;
6
6
  widgetKey: string;
@@ -10,7 +10,7 @@ export declare class IframeStateManager implements IWidgetInstance {
10
10
  get widgetType(): WidgetType;
11
11
  get isWidgetOpen(): boolean;
12
12
  get containerClass(): string;
13
- initialize({ button, icon, isButtonHidden, }: {
13
+ initialize({ button, icon, isButtonHidden: _isButtonHidden, }: {
14
14
  button?: HTMLElement;
15
15
  icon?: HTMLElement;
16
16
  isButtonHidden?: boolean;
@@ -1,3 +1,3 @@
1
1
  import { type Config } from '@brainfish-ai/widgets-common';
2
2
  import { HandOffType } from '../../types/brainfish';
3
- export declare const detectHandoff: (config: Config) => HandOffType.FRESHCHAT | null;
3
+ export declare const detectHandoff: (_config: Config) => HandOffType.FRESHCHAT | null;
package/dist/web.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,a=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,s=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&a(e,n,t[n]);if(i)for(var n of i(t))o.call(t,n)&&a(e,n,t[n]);return e},d=(e,i)=>t(e,n(i)),l=(e,t,n)=>a(e,"symbol"!=typeof t?t+"":t,n),c=(e,t,n)=>new Promise((i,r)=>{var o=e=>{try{s(n.next(e))}catch(t){r(t)}},a=e=>{try{s(n.throw(e))}catch(t){r(t)}},s=e=>e.done?i(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="095dca53-7bbf-4ece-b8de-0b1af771c0c2",e._sentryDebugIdIdentifier="sentry-dbid-095dca53-7bbf-4ece-b8de-0b1af771c0c2")}catch(n){}}(),Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),new TextEncoder;const u=new TextDecoder;const f=e=>{let t=e;t instanceof Uint8Array&&(t=u.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return(e=>{const t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n})(t)}catch(n){throw new TypeError("The input to be decoded is not correctly encoded.")}};function p(e){let t;if("string"==typeof e){const n=e.split(".");3!==n.length&&5!==n.length||([t]=n)}else if("object"==typeof e&&e){if(!("protected"in e))throw new TypeError("Token does not contain a Protected Header");t=e.protected}try{if("string"!=typeof t||!t)throw new Error;const e=JSON.parse(u.decode(f(t)));if(!function(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return!1;var t;if(null===Object.getPrototypeOf(e))return!0;let n=e;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}(e))throw new Error;return e}catch(n){throw new TypeError("Invalid Token or Protected Header formatting")}}var g,h,b,m;("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"web-widget@1.20.4"},(h=g||(g={})).Sidebar="sidebar",h.Searchbar="searchbar",h.Popup="popup",g.Sidebar,g.Searchbar,g.Popup;class y extends Error{constructor(e,t){super(e,t),l(this,"cause"),this.name="BrainfishWidgetError",this.cause=null==t?void 0:t.cause,Error.captureStackTrace&&Error.captureStackTrace(this,y),this.cause instanceof Error&&this.cause.stack&&(this.stack=this.stack+"\nCaused by: "+this.cause.stack)}toJSON(){return{name:this.name,message:this.message,stack:this.stack,cause:this.cause instanceof Error?{name:this.cause.name,message:this.cause.message,stack:this.cause.stack}:this.cause}}}(m=b||(b={})).LINK="link",m.CALLBACK="callback",m.EMAIL="email",m.PHONE="phone";const w=(e,t,n,i)=>{let r=n,o={};if(t instanceof Error)try{o=JSON.parse(t.message),r+=` - ${o.message||t.message}`}catch(a){r+=` - ${t.message}`}else r+=` - ${String(t)}`;((e,t,n)=>{if(!navigator||navigator.userAgent.toLowerCase().includes("headless"))return;const i=t.toJSON();fetch(`${e||"https://app.brainfi.sh"}/api/trackError.widget.create`,{method:"POST",headers:{"Content-Type":"application/json","api-key":n},body:JSON.stringify({error:`WebWidgetVersion: 1.20.4. ${t.message}`,stack:t.stack,cause:{message:i.message,stack:i.stack,cause:i.cause}})})})(e,new y(r,{cause:o}),i)};const v=e=>c(null,[e],function*({widgetKey:e,apiHost:t}){return function(e,t,n){return c(this,null,function*(){let i,r=0;for(;r<3;)try{const i=yield fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","api-key":n}});if(!i.ok)throw new Error(`API call failed with status: ${i.status}`);const r=yield i.json();if(!r)throw new Error("Error loading config: empty response");return r}catch(o){if(i=o,r++,r>=3)throw w(e,o,"Error fetching config",n),i;yield new Promise(e=>setTimeout(e,500))}})}(t,"/api/searchWidgets.getConfigByKey",e)}),x=({config:e,apiKey:t,apiHost:n})=>{const i=e.settings||{};return["bodyActionButtons","footerActionButtons","nextBestActions"].forEach(e=>{i[e]&&(i[e]=i[e].map(e=>e.type===b.CALLBACK&&e.value?d(s({},e),{value:new Function(`return ${e.value}`)()}):e))}),d(s({},e),{settings:i,apiHost:n,widgetMode:e.widgetType,apiKey:t})},C=e=>(null==e?void 0:e.apiHost)||"https://app.brainfi.sh",S=e=>c(null,[e],function*({apiHost:e,widgetKey:t,version:n}){try{const e=`https://cdn.jsdelivr.net/npm/@brainfish-ai/search-widget@${n}/dist/web.js`,t=yield(e=>c(null,null,function*(){return document.getElementById("brainfish-widget")?window.Brainfish:new Promise((t,n)=>{const i=document.createElement("script");i.id="brainfish-widget",i.src=e,i.type="module",i.async=!0,i.crossOrigin="anonymous",i.onload=()=>{setTimeout(()=>{const e=window.Brainfish;e?t(e):n(new Error("Failed to load Brainfish module"))},200)},i.onerror=t=>{const i=t,r={message:`Failed to load script: ${e}`,type:i.type,fileName:i.filename,lineNumber:i.lineno,columnNumber:i.colno,error:i.error?i.error.toString():"Unknown error"};n(new Error(JSON.stringify(r)))},document.head.appendChild(i)})}))(e);return{widget:t}}catch(i){w(e,i,i.message,t)}});const k=new Set,E=(e,t)=>c(null,null,function*(){const n=C(e.overrides);try{if(k.has(e.widgetKey))return;const i=yield S({apiHost:n,widgetKey:e.widgetKey,version:t.version||"latest"});if(i){const{widget:r}=i,o=x({config:t,apiKey:e.widgetKey,apiHost:n});return e.overrides&&t.settings&&Object.entries(e.overrides).forEach(([e,n])=>{t.settings&&e in t.settings&&(t.settings[e]=((e=[],t)=>{const n=new Map(e.map(e=>[e.label,e]));return t.forEach(e=>n.set(e.label,e)),Array.from(n.values())})(t.settings[e],n))}),function(e,t){t.widgetType===g.Searchbar||"Search"===t.widgetType?e.SearchWidget.initStandard(t):e.HelpWidget.initPopup(t)}(r,o),k.add(e.widgetKey),r}}catch(i){w(n,i,i.message,e.widgetKey)}});let T=!1;const O=(e,t,n,...i)=>c(null,[e,t,n,...i],function*(e,t,n,i="",r=!1,o=[],a,s){if(t||void 0!==console.warn&&console.warn("[Brainfish] BrainfishAnalytics not initialized. Access key is required."),!T)try{const d=(()=>{if("undefined"==typeof window||"undefined"==typeof navigator)return!1;const e=navigator,t=window,n=(e.doNotTrack||t.doNotTrack||e.msDoNotTrack||"0").toString().toLowerCase();return["1","yes","true"].includes(n)})(),l="undefined"!=typeof localStorage&&"true"===localStorage.getItem("bf_tracking_disabled"),u=d||l;window.BrainfishAnalytics("init",{apiUrl:i,accessKey:t,trackScreenViews:!0,trackAttributes:!u,trackOutgoingLinks:!u,enableRecording:!u&&r,recordingBlocklist:o,_allowLocalhostRecording:a,_allowScreenRecording:s}),T=!0,yield((e,t)=>c(null,null,function*(){if(document.getElementById("brainfish-analytics"))return window.BrainfishAnalytics;const n=document.createElement("script");n.id="brainfish-analytics",n.src="https://cdn.jsdelivr.net/npm/@brainfish-ai/web-tracker@latest/dist/tracker.js",n.type="module",n.async=!0,n.crossOrigin="anonymous",n.onerror=()=>{w(e,new Error(`Failed to load script: ${n.src}`),`Failed to load script: ${n.src}`,t)},document.head.appendChild(n)}))(n,e)}catch(d){w(n,d,"Failed to initialize BrainfishAnalytics",e)}});function _(e){const t=(new TextEncoder).encode(e);if("undefined"!=typeof window&&"function"==typeof window.btoa){const e=Array.from(t,e=>String.fromCharCode(e)).join("");return btoa(e)}if("undefined"!=typeof Buffer)return Buffer.from(t).toString("base64");throw new Error("[utils.base64Encode]: Unsupported environment")}function I(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var W,A={exports:{}},B={exports:{}},P={exports:{}};function M(){return W||(W=1,function(e,t){function n(e){return Math.round(255*e)}function i(e,t,i){return n(e)+","+n(t)+","+n(i)}t.__esModule=!0,t.default=void 0,t.default=function(e,t,n,r){if(void 0===r&&(r=i),0===t)return r(n,n,n);var o=(e%360+360)%360/60,a=(1-Math.abs(2*n-1))*t,s=a*(1-Math.abs(o%2-1)),d=0,l=0,c=0;o>=0&&o<1?(d=a,l=s):o>=1&&o<2?(d=s,l=a):o>=2&&o<3?(l=a,c=s):o>=3&&o<4?(l=s,c=a):o>=4&&o<5?(d=s,c=a):o>=5&&o<6&&(d=a,c=s);var u=n-a/2;return r(d+u,l+u,c+u)},e.exports=t.default}(P,P.exports)),P.exports}var L,j={exports:{}};function H(){return L||(L=1,function(e,t){t.__esModule=!0,t.default=void 0;var n={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};t.default=function(e){if("string"!=typeof e)return e;var t=e.toLowerCase();return n[t]?"#"+n[t]:e},e.exports=t.default}(j,j.exports)),j.exports}var F,K,$,N={exports:{}};function z(){return F||(F=1,function(e,t){function n(e){var t="function"==typeof Map?new Map:void 0;return n=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(i())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,t);var a=new(e.bind.apply(e,o));return n&&r(a,n.prototype),a}(e,arguments,o(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),r(n,e)},n(e)}function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(i=function(){return!!e})()}function r(e,t){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}t.__esModule=!0,t.default=void 0;var a={1:"Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",2:"Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",3:"Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",4:"Couldn't generate valid rgb string from %s, it returned %s.\n\n",5:"Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",6:"Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",7:"Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",8:"Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",9:"Please provide a number of steps to the modularScale helper.\n\n",10:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",11:'Invalid value passed as base to modularScale, expected number or em string but got "%s"\n\n',12:'Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.\n\n',13:'Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.\n\n',14:'Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',15:'Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',16:"You must provide a template to this method.\n\n",17:"You passed an unsupported selector state to this method.\n\n",18:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",19:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",20:"expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:"fontFace expects a name of a font-family.\n\n",24:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",25:"fontFace expects localFonts to be an array.\n\n",26:"fontFace expects fileFormats to be an array.\n\n",27:"radialGradient requries at least 2 color-stops to properly render.\n\n",28:"Please supply a filename to retinaImage() as the first argument.\n\n",29:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",32:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",33:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",34:"borderRadius expects a radius value as a string or number as the second argument.\n\n",35:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',36:"Property must be a string value.\n\n",37:"Syntax Error at %s.\n\n",38:"Formula contains a function that needs parentheses at %s.\n\n",39:"Formula is missing closing parenthesis at %s.\n\n",40:"Formula has too many closing parentheses at %s.\n\n",41:"All values in a formula must have the same unit or be unitless.\n\n",42:"Please provide a number of steps to the modularScale helper.\n\n",43:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",44:"Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",45:"Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",46:"Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",47:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",48:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",49:"Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",50:"Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",51:"Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",52:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",53:"fontFace expects localFonts to be an array.\n\n",54:"fontFace expects fileFormats to be an array.\n\n",55:"fontFace expects a name of a font-family.\n\n",56:"linearGradient requries at least 2 color-stops to properly render.\n\n",57:"radialGradient requries at least 2 color-stops to properly render.\n\n",58:"Please supply a filename to retinaImage() as the first argument.\n\n",59:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:"Property must be a string value.\n\n",62:"borderRadius expects a radius value as a string or number as the second argument.\n\n",63:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',64:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",65:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",66:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",67:"You must provide a template to this method.\n\n",68:"You passed an unsupported selector state to this method.\n\n",69:'Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.\n\n',70:'Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.\n\n',71:'Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.\n\n',72:'Passed invalid base value %s to %s(), please pass a value like "12px" or 12.\n\n',73:"Please provide a valid CSS variable.\n\n",74:"CSS variable not found and no default was provided.\n\n",75:"important requires a valid style object, got a %s instead.\n\n",76:"fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",77:'remToPx expects a value in "rem" but you provided it in "%s".\n\n',78:'base must be set in "px" or "%" but you set it in "%s".\n'};function s(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i,r=t[0],o=[];for(i=1;i<t.length;i+=1)o.push(t[i]);return o.forEach(function(e){r=r.replace(/%[a-z]/,e)}),r}t.default=function(e){var t,n;function i(t){var n;if("production"===process.env.NODE_ENV)n=e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this;else{for(var i=arguments.length,r=new Array(i>1?i-1:0),o=1;o<i;o++)r[o-1]=arguments[o];n=e.call(this,s.apply(void 0,[a[t]].concat(r)))||this}return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,r(t,n),i}(n(Error)),e.exports=t.default}(N,N.exports)),N.exports}function R(){return K||(K=1,function(e,t){t.__esModule=!0,t.default=function(e){if("string"!=typeof e)throw new r.default(3);var t=(0,i.default)(e);if(t.match(a))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(s)){var o=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:o}}if(t.match(d))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(l)){var g=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:g}}var h=c.exec(t);if(h)return{red:parseInt(""+h[1],10),green:parseInt(""+h[2],10),blue:parseInt(""+h[3],10)};var b=u.exec(t.substring(0,50));if(b)return{red:parseInt(""+b[1],10),green:parseInt(""+b[2],10),blue:parseInt(""+b[3],10),alpha:parseFloat(""+b[4])>1?parseFloat(""+b[4])/100:parseFloat(""+b[4])};var m=f.exec(t);if(m){var y=parseInt(""+m[1],10),w=parseInt(""+m[2],10)/100,v=parseInt(""+m[3],10)/100,x="rgb("+(0,n.default)(y,w,v)+")",C=c.exec(x);if(!C)throw new r.default(4,t,x);return{red:parseInt(""+C[1],10),green:parseInt(""+C[2],10),blue:parseInt(""+C[3],10)}}var S=p.exec(t.substring(0,50));if(S){var k=parseInt(""+S[1],10),E=parseInt(""+S[2],10)/100,T=parseInt(""+S[3],10)/100,O="rgb("+(0,n.default)(k,E,T)+")",_=c.exec(O);if(!_)throw new r.default(4,t,O);return{red:parseInt(""+_[1],10),green:parseInt(""+_[2],10),blue:parseInt(""+_[3],10),alpha:parseFloat(""+S[4])>1?parseFloat(""+S[4])/100:parseFloat(""+S[4])}}throw new r.default(5)};var n=o(M()),i=o(H()),r=o(z());function o(e){return e&&e.__esModule?e:{default:e}}var a=/^#[a-fA-F0-9]{6}$/,s=/^#[a-fA-F0-9]{8}$/,d=/^#[a-fA-F0-9]{3}$/,l=/^#[a-fA-F0-9]{4}$/,c=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,u=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,f=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,p=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;e.exports=t.default}(B,B.exports)),B.exports}function q(){return $||($=1,function(e,t){t.__esModule=!0,t.default=function(e){if("transparent"===e)return 0;var t=(0,i.default)(e),n=Object.keys(t).map(function(e){var n=t[e]/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)}),r=n[0],o=n[1],a=n[2];return parseFloat((.2126*r+.7152*o+.0722*a).toFixed(3))};var n,i=(n=R())&&n.__esModule?n:{default:n};e.exports=t.default}(A,A.exports)),A.exports}const D=I(q());var U,J={exports:{}},Y={exports:{}};function V(){return U||(U=1,function(e,t){function n(e,t,i){return function(){var r=i.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):n(e,t,r)}}t.__esModule=!0,t.default=function(e){return n(e,e.length,[])},e.exports=t.default}(Y,Y.exports)),Y.exports}var Z,G={exports:{}};function Q(){return Z||(Z=1,e=G,(t=G.exports).__esModule=!0,t.default=void 0,t.default=function(e,t,n){return Math.max(e,Math.min(t,n))},e.exports=t.default),G.exports;var e,t}var X,ee,te={exports:{}},ne={exports:{}};function ie(){return X||(X=1,e=ne,(t=ne.exports).__esModule=!0,t.default=void 0,t.default=function(e){var t,n=e.red/255,i=e.green/255,r=e.blue/255,o=Math.max(n,i,r),a=Math.min(n,i,r),s=(o+a)/2;if(o===a)return void 0!==e.alpha?{hue:0,saturation:0,lightness:s,alpha:e.alpha}:{hue:0,saturation:0,lightness:s};var d=o-a,l=s>.5?d/(2-o-a):d/(o+a);switch(o){case n:t=(i-r)/d+(i<r?6:0);break;case i:t=(r-n)/d+2;break;default:t=(n-i)/d+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:l,lightness:s,alpha:e.alpha}:{hue:t,saturation:l,lightness:s}},e.exports=t.default),ne.exports;var e,t}function re(){return ee||(ee=1,function(e,t){t.__esModule=!0,t.default=function(e){return(0,i.default)((0,n.default)(e))};var n=r(R()),i=r(ie());function r(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(te,te.exports)),te.exports}var oe,ae={exports:{}},se={exports:{}},de={exports:{}},le={exports:{}};function ce(){return oe||(oe=1,function(e,t){t.__esModule=!0,t.default=void 0;t.default=function(e){return 7===e.length&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e},e.exports=t.default}(le,le.exports)),le.exports}var ue,fe,pe,ge={exports:{}};function he(){return ue||(ue=1,e=ge,(t=ge.exports).__esModule=!0,t.default=void 0,t.default=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},e.exports=t.default),ge.exports;var e,t}function be(){return fe||(fe=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=o(M()),i=o(ce()),r=o(he());function o(e){return e&&e.__esModule?e:{default:e}}function a(e){return(0,r.default)(Math.round(255*e))}function s(e,t,n){return(0,i.default)("#"+a(e)+a(t)+a(n))}t.default=function(e,t,i){return(0,n.default)(e,t,i,s)},e.exports=t.default}(de,de.exports)),de.exports}function me(){return pe||(pe=1,function(e,t){t.__esModule=!0,t.default=function(e,t,r){if("number"==typeof e&&"number"==typeof t&&"number"==typeof r)return(0,n.default)(e,t,r);if("object"==typeof e&&void 0===t&&void 0===r)return(0,n.default)(e.hue,e.saturation,e.lightness);throw new i.default(1)};var n=r(be()),i=r(z());function r(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(se,se.exports)),se.exports}var ye,we={exports:{}};function ve(){return ye||(ye=1,function(e,t){t.__esModule=!0,t.default=function(e,t,o,a){if("number"==typeof e&&"number"==typeof t&&"number"==typeof o&&"number"==typeof a)return a>=1?(0,n.default)(e,t,o):"rgba("+(0,i.default)(e,t,o)+","+a+")";if("object"==typeof e&&void 0===t&&void 0===o&&void 0===a)return e.alpha>=1?(0,n.default)(e.hue,e.saturation,e.lightness):"rgba("+(0,i.default)(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new r.default(2)};var n=o(be()),i=o(M()),r=o(z());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(we,we.exports)),we.exports}var xe,Ce={exports:{}};function Se(){return xe||(xe=1,function(e,t){t.__esModule=!0,t.default=function(e,t,o){if("number"==typeof e&&"number"==typeof t&&"number"==typeof o)return(0,n.default)("#"+(0,i.default)(e)+(0,i.default)(t)+(0,i.default)(o));if("object"==typeof e&&void 0===t&&void 0===o)return(0,n.default)("#"+(0,i.default)(e.red)+(0,i.default)(e.green)+(0,i.default)(e.blue));throw new r.default(6)};var n=o(ce()),i=o(he()),r=o(z());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(Ce,Ce.exports)),Ce.exports}var ke,Ee,Te,Oe={exports:{}};function _e(){return ke||(ke=1,function(e,t){t.__esModule=!0,t.default=function(e,t,o,a){if("string"==typeof e&&"number"==typeof t){var s=(0,n.default)(e);return"rgba("+s.red+","+s.green+","+s.blue+","+t+")"}if("number"==typeof e&&"number"==typeof t&&"number"==typeof o&&"number"==typeof a)return a>=1?(0,i.default)(e,t,o):"rgba("+e+","+t+","+o+","+a+")";if("object"==typeof e&&void 0===t&&void 0===o&&void 0===a)return e.alpha>=1?(0,i.default)(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new r.default(7)};var n=o(R()),i=o(Se()),r=o(z());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(Oe,Oe.exports)),Oe.exports}function Ie(){return Ee||(Ee=1,function(e,t){t.__esModule=!0,t.default=function(e){if("object"!=typeof e)throw new a.default(8);if(l(e))return(0,o.default)(e);if(d(e))return(0,r.default)(e);if(u(e))return(0,i.default)(e);if(c(e))return(0,n.default)(e);throw new a.default(8)};var n=s(me()),i=s(ve()),r=s(Se()),o=s(_e()),a=s(z());function s(e){return e&&e.__esModule?e:{default:e}}var d=function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)},l=function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha},c=function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)},u=function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&"number"==typeof e.alpha};e.exports=t.default}(ae,ae.exports)),ae.exports}function We(){return Te||(Te=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=a(V()),i=a(Q()),r=a(re()),o=a(Ie());function a(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},s.apply(this,arguments)}var d=(0,n.default)(function(e,t){if("transparent"===t)return t;var n=(0,r.default)(t);return(0,o.default)(s({},n,{lightness:(0,i.default)(0,1,n.lightness-parseFloat(e))}))});t.default=d,e.exports=t.default}(J,J.exports)),J.exports}const Ae=I(We());var Be,Pe={exports:{}};function Me(){return Be||(Be=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=a(V()),i=a(Q()),r=a(re()),o=a(Ie());function a(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},s.apply(this,arguments)}var d=(0,n.default)(function(e,t){if("transparent"===t)return t;var n=(0,r.default)(t);return(0,o.default)(s({},n,{lightness:(0,i.default)(0,1,n.lightness+parseFloat(e))}))});t.default=d,e.exports=t.default}(Pe,Pe.exports)),Pe.exports}const Le=I(Me()),je="bf-iframe-container",He="bf-trigger-button",Fe="bf-search-bar-iframe-container",Ke="bf-search-bar-iframe-backdrop";function $e(e){var t,n;if(!document.querySelector("style[data-widget-styles]")){!function(e="#000",t="FFF"){const n=document.createElement("style");n.attributes.setNamedItem(document.createAttribute("data-widget-styles"));const i=D(e)>.5;n.textContent=`\n .bf-trigger-button{position:fixed;bottom:16px;right:16px;width:36px;height:36px;border-radius:50%;border:none;box-shadow:0 1px 6px #0000000f,0 2px 32px #00000029;transition:transform 167ms cubic-bezier(.33,0,0,1);box-sizing:content-box;display:flex;align-items:center;justify-content:center;cursor:pointer;z-index:1000;padding:12px;gap:10px;overflow:hidden}.bf-trigger-button.hidden{display:none}.trigger-button-icon{display:flex;align-items:center;justify-content:center;width:36px;height:36px;position:relative}.trigger-button-icon svg{width:100%;height:100%;position:absolute;inset:0}.trigger-button-icon>svg>path{transition:transform .3s ease,opacity .3s ease;transform:scale(.5);transform-origin:center;opacity:0}.trigger-button-icon .fish-icon{display:none}.trigger-button-icon .fish-icon.visible{display:block;max-width:36px;max-height:36px}.trigger-button-icon svg.visible{display:block}.trigger-button-icon>svg.visible>path{opacity:1;transform:scale(1)}.trigger-iframe{position:relative;width:100%;height:100%;border:none;outline:none;transform:translateZ(0);overflow:hidden}.bf-iframe-container{visibility:hidden;position:fixed;z-index:2147483000000;background-color:#fff;bottom:0;right:0;width:100vw;height:calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));border:none;overflow:hidden;opacity:0;pointer-events:none;transform:translateY(20px);transition:opacity .3s ease,transform .3s ease,width .2s ease-in-out,height .2s ease-in-out,visibility 0s .3s}.bf-iframe-container.open{visibility:visible;opacity:1;transform:translateY(0);pointer-events:auto;top:env(safe-area-inset-top);left:0;transition-delay:0s}@media (min-width: 576px){.bf-iframe-container{bottom:80px;right:24px;width:448px;height:min(750px,calc(100vh - 80px));border-radius:8px;border:1px solid var(--Dark-300, #d4d4d4);box-shadow:0 20px 25px -5px #1212171a,0 10px 10px -5px #1212170a}.bf-iframe-container.open{top:unset;left:unset}.bf-iframe-container.position-bottom-left{right:auto;left:24px}.bf-iframe-container.position-top-left{inset:80px auto auto 24px}.bf-iframe-container.position-top-right{bottom:auto;top:80px;right:24px}.bf-iframe-container.expanded{width:min(calc(448px * 1.35),calc(100vw - 16px));height:min(calc(750px * 1.35),calc(100vh - 80px))}}.bf-search-bar-iframe-container{position:relative;width:100%;min-height:200px;background-color:#fff;border:1px solid var(--dark-300, #d4d4d4);border-radius:8px;overflow:hidden;pointer-events:auto;transition:height .2s ease-in-out}.iframe-loading-indicator{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;align-items:center;justify-content:center;z-index:10}.spinner{width:24px;height:24px;border:2px solid rgba(0,0,0,.1);border-radius:50%;border-top-color:#3498db;animation:spin 1s ease-in-out infinite}@keyframes spin{to{transform:rotate(360deg)}}.loading-error{width:24px;height:24px;position:relative;display:flex;align-items:center;justify-content:center}.loading-error:before,.loading-error:after{content:"";position:absolute;width:16px;height:2px;background-color:#e74c3c;border-radius:2px}.loading-error:before{transform:rotate(45deg)}.loading-error:after{transform:rotate(-45deg)}\n .${He} { background: ${e}; }\n .${He}:hover {\n background: ${i?Ae(.05,e):Le(.05,e)};\n }\n .trigger-button-icon { color: ${t}; }\n `,document.head.appendChild(n)}((null==(t=null==e?void 0:e.theme)?void 0:t.inputButtonBgColor)||"#007bff",(null==(n=null==e?void 0:e.theme)?void 0:n.textBaseColor)||"#ffffff")}}class Ne{constructor(e,t){l(this,"isOpen",!1),this.widgetKey=e,this.widgetType=t}get isWidgetOpen(){return this.isOpen}openWidget(){this.isOpen=!0}closeWidget(){this.isOpen=!1}toggleWidget(){return this.isOpen=!this.isOpen,this.isOpen}}function ze(e,t,n={}){const i=document.createElement(e);return i.className=t,Object.entries(n).forEach(([e,t])=>{i.setAttribute(e,t)}),i}const Re="brainfish-search-widget";class qe{constructor(e){l(this,"button",null),l(this,"icon",null),l(this,"closeCallback",null),this.widgetType=e}setCloseCallback(e){this.closeCallback=e}get containerClass(){return this.widgetType===g.Searchbar?Fe:je}get container(){return document.querySelector(`.${this.containerClass}`)}get iframe(){var e;return null==(e=this.container)?void 0:e.querySelector("iframe")}get backdrop(){return document.querySelector(`.${Ke}`)}setElements(e,t){this.button=e||null,this.icon=t||null}openWidget(e={}){var t,n,i;const r=document.querySelector(`.${this.containerClass}`),o=null==r?void 0:r.querySelector("iframe");if(e.newConversation&&e.contextualQuestion?null==(t=null==o?void 0:o.contentWindow)||t.postMessage({type:"CONTEXTUAL_QUESTION",question:e.contextualQuestion},"*"):e.newConversation&&(null==(n=null==o?void 0:o.contentWindow)||n.postMessage({type:"NEW_CONVERSATION"},"*")),null==(i=null==o?void 0:o.contentWindow)||i.postMessage({type:"FOCUS_SEARCH_FIELD"},"*"),this.widgetType!==g.Searchbar&&(null==r||r.classList.add("open"),e.position&&(null==r||r.classList.add(`position-${e.position}`),null==r||r.setAttribute("data-current-position",e.position))),null==r||r.setAttribute("aria-hidden","false"),this.widgetType!==g.Searchbar&&document.body.clientWidth>=962&&null===this.backdrop){const e=ze("div",Ke);this.closeCallback&&e.addEventListener("click",this.closeCallback),document.body.appendChild(e)}this.updateButtonForOpen()}focusNextElement(){const e=document.querySelector(Re);if(e){const t=Array.from(document.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')).filter(e=>!e.hasAttribute("disabled")),n=t.indexOf(e);if(-1!==n){const e=t[n+1];e&&e.focus()}}}closeWidget(){const e=this.container;if(!e)return;const t=e.dataset.currentPosition;if(t){const n=()=>{e.dataset.currentPosition===t&&(e.classList.remove(`position-${t}`),delete e.dataset.currentPosition)};e.addEventListener("transitionend",n,{once:!0})}e.classList.remove("open"),e.setAttribute("aria-hidden","true"),this.backdrop&&(this.backdrop.remove(),this.focusNextElement()),this.updateButtonForClose()}updateButtonForOpen(){if(!this.button||!this.icon)return;const e=this.icon.querySelector(".fish-icon"),t=this.icon.querySelector(".close-icon");this.button.setAttribute("aria-expanded","true"),null==e||e.classList.remove("visible"),null==t||t.classList.add("visible"),this.isMobile()&&this.hideTriggerButton()}updateButtonForClose(){if(!this.button||!this.icon)return;const e=this.icon.querySelector(".fish-icon"),t=this.icon.querySelector(".close-icon");this.button.setAttribute("aria-expanded","false"),null==e||e.classList.add("visible"),null==t||t.classList.remove("visible"),this.isMobile()&&this.showTriggerButton()}showTriggerButton(){var e;null==(e=this.button)||e.classList.remove("hidden")}hideTriggerButton(){var e;null==(e=this.button)||e.classList.add("hidden")}resizeContainer(e){if(this.widgetType!==g.Searchbar)return;if(!this.container||!this.iframe)return;const t=Math.max(e,200);this.container.style.height=`${t}px`,this.iframe.style.height=`${t}px`}isMobile(){return document.body.clientWidth<=576}setupButtonClickListener(e){this.button&&this.button.addEventListener("click",e)}static isWidgetDOMExisting(e,t){const n=document.querySelector(`.${Fe}[data-widget-key="${e}"]`);if(n){const e=document.querySelector("brainfish-search-widget");return!e||e.contains(n)}if(document.getElementById(`trigger-button-${e}`))return!0;if("Search"!==t.widgetType){if(document.querySelector(`.${je}`))return!0}return!1}}class De{static register(e,t){this.instances.set(e,t)}static getInstance(e){return this.instances.get(e)}static unregister(e){this.instances.delete(e)}static getAllInstances(){return Array.from(this.instances.values())}static getOpenInstance(){return this.getAllInstances().find(e=>e.isWidgetOpen)}static getClosedPopupInstance(){return this.getAllInstances().find(e=>!e.isWidgetOpen&&e.widgetType===g.Popup)}static clear(){this.instances.clear()}}l(De,"instances",new Map);const Ue=({formUrl:e,width:t="500px",height:n="600px"})=>{const i=document.createElement("div");i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("tabindex","-1"),i.style.cssText="\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background: white;\n padding: 20px;\n border-radius: 8px;\n box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n z-index: 300000000;\n ";const r=document.createElement("button");r.innerHTML="×",r.style.cssText="\n position: absolute;\n right: -16px;\n top: -16px;\n width: 32px;\n height: 32px;\n border: 2px solid #666;\n border-radius: 50%;\n background: #FFF;\n font-size: 20px;\n cursor: pointer;\n ";const o=document.createElement("iframe");o.src=e,o.style.cssText=`width: ${t}; height: ${n}; border: none;`;let a=document.activeElement;const s=e=>{if("Tab"===e.key){const t=[r,o],n=document.activeElement,i=n?t.indexOf(n):-1;e.preventDefault(),e.shiftKey?i<=0?t[t.length-1].focus():t[i-1].focus():i>=t.length-1?t[0].focus():t[i+1].focus()}else"Escape"===e.key&&d()},d=()=>{i.remove(),l.remove(),document.removeEventListener("keydown",s),null==a||a.focus()},l=document.createElement("div");l.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0,0,0,0.5);\n z-index: 299999999;\n ",r.onclick=d,l.onclick=d,document.addEventListener("keydown",s),i.appendChild(r),i.appendChild(o),document.body.appendChild(l),document.body.appendChild(i),i.focus(),o.onload=()=>{o.setAttribute("tabindex","0"),r.focus()}};class Je{static initialize(){this.isInitialized||(this.setupDeprecatedAPI(),this.setupNewAPI(),this.isInitialized=!0)}static setupDeprecatedAPI(){var e;(null==(e=window.Brainfish)?void 0:e.HelpWidget)&&(window.Brainfish.HelpWidget.close=e=>this.closeCurrentlyOpenWidget(),window.Brainfish.HelpWidget.open=e=>this.openCurrentlyClosedPopupWidget(e))}static setupNewAPI(){var e;(null==(e=window.Brainfish)?void 0:e.Widgets)&&(window.Brainfish.Widgets.open=e=>this.openCurrentlyClosedPopupWidget(e,!0),window.Brainfish.Widgets.close=()=>this.closeCurrentlyOpenWidget(),window.Brainfish.Widgets.createNewThread=()=>this.createNewThread(),window.Brainfish.Widgets.openModalForm=Ue,window.Brainfish.Widgets.onContextHelp=(e,t)=>this.openContextualHelp(e,t))}static closeCurrentlyOpenWidget(){const e=De.getOpenInstance();e&&e.closeWidget()}static openCurrentlyClosedPopupWidget(e,t){const n=De.getClosedPopupInstance();if(n){const i="string"==typeof e?{trigger:e}:e,r={};t&&(r.newConversation=!0),(null==i?void 0:i.trigger)&&(r.newConversation=!0,r.trigger=i.trigger),(null==i?void 0:i.position)&&(r.position=i.position),n.openWidget(r)}}static createNewThread(){var e;const t=De.getOpenInstance();if(t){const n=t.widgetType===g.Searchbar?Fe:je,i=t.widgetType===g.Searchbar?`.${n}[data-widget-key="${t.widgetKey}"]`:`.${n}`,r=document.querySelector(i),o=null==r?void 0:r.querySelector("iframe");return void(null==(e=null==o?void 0:o.contentWindow)||e.postMessage({type:"NEW_CONVERSATION"},"*"))}const n=De.getClosedPopupInstance();n&&n.openWidget({newConversation:!0})}static openContextualHelp(e,t={}){if(!e||"string"!=typeof e||0===e.trim().length)return void console.warn("Brainfish.Widgets.onContextHelp: Invalid question provided");let n=De.getOpenInstance();if(n||(n=De.getClosedPopupInstance()),!n)return void console.warn("Brainfish.Widgets.onContextHelp: No popup widget available");const i=d(s({},t),{newConversation:!0,trigger:"contextual-help",contextualQuestion:e.trim()});n.openWidget(i)}}l(Je,"isInitialized",!1);class Ye{constructor(e,t){this.widgetType=e,this.widgetKey=t}trackOpenWidget(e,t){this.dispatchEvent("onBrainfishWidgetOpen"),"contextual-help"===e?this.trackAnalytics("Open Widget - Contextual Help",{trigger:e,question:t}):e?this.trackAnalytics("Open Widget - Custom Trigger",{trigger:e}):this.trackAnalytics("Open Widget")}trackCloseWidget(){this.dispatchEvent("onBrainfishWidgetClose"),this.trackAnalytics("Close Widget")}trackCustomEvent(e,t={}){this.trackAnalytics(e,t)}dispatchEvent(e){window.dispatchEvent(new Event(e))}trackAnalytics(e,t={}){if(window.BrainfishAnalytics){let n;switch(this.widgetType){case g.Searchbar:n="searchbar_widget";break;case g.Sidebar:default:n="search_widget"}window.BrainfishAnalytics("track",e,d(s({},t),{widgetKey:this.widgetKey}),{source:n,widgetKey:this.widgetKey})}}}class Ve{constructor(e,t){l(this,"state"),l(this,"domController"),l(this,"analyticsTracker"),this.state=new Ne(e,t),this.domController=new qe(t),this.domController.setCloseCallback(()=>this.closeWidget()),this.analyticsTracker=new Ye(t,e)}static getInstance(e){return De.getInstance(e)}get widgetKey(){return this.state.widgetKey}get widgetType(){return this.state.widgetType}get isWidgetOpen(){return this.state.isWidgetOpen}get containerClass(){return this.domController.containerClass}initialize({button:e,icon:t,isButtonHidden:n}){this.domController.setElements(e,t),this.domController.setupButtonClickListener(()=>this.toggleIframeVisibility()),De.register(this.widgetKey,this),Je.initialize()}toggleIframeVisibility(){this.state.toggleWidget()?this.openWidget():this.closeWidget()}openWidget(e={}){this.state.openWidget(),this.domController.openWidget(e),this.analyticsTracker.trackOpenWidget(e.trigger,e.contextualQuestion)}closeWidget(){this.state.closeWidget(),this.domController.closeWidget(),this.analyticsTracker.trackCloseWidget()}showTriggerButton(){this.domController.showTriggerButton()}hideTriggerButton(){this.domController.hideTriggerButton()}resizeContainer(e){this.domController.resizeContainer(e)}trackCustomEvent(e,t={}){this.analyticsTracker.trackCustomEvent(e,t)}destroy(){De.unregister(this.widgetKey)}static initialize(e){const t=new Ve(e.widgetKey,e.widgetType);return t.initialize(e),t}}function Ze({widgetUrl:e,widgetType:t,props:n}){const i=t===g.Searchbar?Fe:je,r=ze("div",i,s({id:i,"aria-live":"polite","aria-hidden":t===g.Searchbar?"false":"true"},n||{})),o=ze("div","iframe-loading-indicator"),a=ze("div","spinner");o.setAttribute("aria-label","Loading content"),o.setAttribute("role","status"),o.appendChild(a),r.appendChild(o);const d=ze("iframe","trigger-iframe",{src:e,sandbox:"allow-scripts allow-same-origin allow-popups allow-forms",allow:"clipboard-write",role:"dialog"});return d.style.opacity="0",d.addEventListener("load",()=>{o.style.display="none",d.style.opacity="1"}),d.addEventListener("error",e=>{console.error("Error loading iframe:",e),o.innerHTML="";const t=ze("div","loading-error");o.appendChild(t),o.setAttribute("aria-label","Failed to load content")}),r.appendChild(d),{iframeContainer:r,iframe:d}}function Ge(e,t){const n=()=>{(t=>{var n;null==(n=e.contentWindow)||n.postMessage({type:"UPDATE_BODY_CLASS",isDarkMode:t},"*")})(document.body.classList.contains("dark"))};n(),(()=>{const e=new MutationObserver(n);e.observe(document.body,{attributes:!0,attributeFilter:["class"]}),t.addEventListener("abort",()=>e.disconnect())})()}const Qe=new Map,Xe=(e,t)=>`Error executing Client Action with key ${e}. Details: ${t instanceof Error?t.message:String(t)}`,et=(e,t)=>c(null,null,function*(){if(Qe.has(e)){const r=Qe.get(e);if("function"!=typeof r)return{success:!1,reason:`Client Action registered with key ${e} is not a function`};try{const e=yield r(t);if(n=e,"[object Object]"!==Object.prototype.toString.call(n))throw new TypeError("Invalid result, expecting object type");return{success:!0,data:e}}catch(i){return{success:!1,reason:Xe(e,i)}}}var n;return{success:!1,reason:`No Client Action registered with key ${e}`}});function tt(e,{widgetHost:t,apiHost:n,widgetKey:i,widgetType:r,signal:o,stateManager:a}){window.addEventListener("message",r=>c(null,null,function*(){var o;if(r.origin!==t)return;const{type:s,widgetKey:d}=r.data;if(!d||d===i){if("TOGGLE_WIDGET_SIZE"===s&&function(){const e=document.querySelector(`.${je}`);e.classList.contains("expanded")?e.classList.remove("expanded"):e.classList.add("expanded")}(),"RESIZE_IFRAME"===s){const{height:e}=r.data;a.resizeContainer(e)}if("TRACK_EVENT"===s){const{eventName:e,data:t}=r.data;a.trackCustomEvent(e,t)}if("CLOSE_WIDGET"===s&&a.closeWidget(),"NEXT_BEST_ACTION_CLICKED"===s){const{action:e,searchQueryId:t,query:o,answer:a}=r.data;if(!["function","callback"].includes(e.type))return void console.error("[Brainfish] Invalid action type:",e);const s={query:o,answer:a,searchIntentId:e.searchIntentId,actionId:e.id,conversationId:r.data.conversationId||"",searchQueryId:t,metadata:e.metadata||{}};try{if(window.__bfCallbacks=window.__bfCallbacks||{},window.__bfCallbacks[e.id])return void window.__bfCallbacks[e.id](o,a,s);const t=new URL(`${n}/api/searchWidgets.callback.codeblocks`);t.searchParams.set("apiKey",i),t.searchParams.set("codeblockId",e.id),s.searchIntentId&&t.searchParams.set("searchIntentId",s.searchIntentId);const r=document.createElement("script");r.src=t.toString(),document.head.appendChild(r),r.onload=()=>{window.__bfCallbacks[e.id](o,a,s),setTimeout(()=>{document.head.removeChild(r)},300)},r.onerror=()=>{console.error("[Brainfish] Failed to load callback script from server")}}catch(l){console.error("[Brainfish] Error executing callback:",l)}}if("CLIENT_EXECUTION"===s){const{actionKey:t,inputs:n,messageId:i}=r.data,a=yield et(t,n);null==(o=e.contentWindow)||o.postMessage({type:"CLIENT_EXECUTION_RESULT",messageId:i,result:a},"*")}}}),{signal:o})}function nt(e,t,n){let i;const r=()=>{(t=>{var i;const r={type:"UPDATE_BODY_CLASS",isMobile:t};null==(i=e.contentWindow)||i.postMessage(r,"*"),t&&(n.isWidgetOpen?n.hideTriggerButton():n.showTriggerButton())})(document.body.clientWidth<=576)},o=()=>{i&&clearTimeout(i),i=window.setTimeout(r,300)};r(),(()=>{const e=new ResizeObserver(o);e.observe(document.body),t.addEventListener("abort",()=>e.disconnect())})()}const it=new Set;function rt(e,t,{isButtonHidden:n,triggerButtonIcon:i}){const r=document.createDocumentFragment();let o;if(n)o=Ve.initialize({isButtonHidden:n,widgetType:g.Popup,widgetKey:e});else{const{button:t,icon:n}=function(e,t){const n=ze("button",He,{id:`trigger-button-${e}`,"aria-controls":je,"aria-expanded":"false","data-name":He}),i=ze("div","trigger-button-icon",{"aria-hidden":"true"});return i.innerHTML=t?`\n <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">\n <path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path>\n </svg>\n <img src="${t}" class="fish-icon visible" alt="Trigger button icon" aria-hidden="true" aria-label="help button icon" />\n `:'\n <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">\n <path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path>\n </svg>\n <svg width="24" height="14" viewBox="0 0 24 14" fill="none" xmlns="http://www.w3.org/2000/svg" class="fish-icon visible">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M1.71844 10.3882L4.60606 6.98384L1.71844 3.58375C1.4014 3.21362 1.44424 2.65841 1.81269 2.33993C1.97978 2.1979 2.65242 1.98701 3.04657 2.43461L5.78425 5.65824C6.14281 5.29523 6.51693 4.95924 6.90479 4.65114C8.88976 3.07437 11.2345 2.22803 13.6931 2.22803C16.9492 2.22803 20.0039 3.71718 22.2917 6.41142C22.5702 6.74282 22.5702 7.22916 22.2917 7.56056C20.0039 10.2591 16.9492 11.744 13.6931 11.744C11.2348 11.744 8.89035 10.8948 6.90554 9.31995C6.51741 9.01199 6.14304 8.67628 5.78425 8.31374L3.04657 11.5374C2.72953 11.9075 2.18114 11.9505 1.81269 11.632C1.44852 11.3179 1.40568 10.7584 1.71844 10.3882ZM5.93026 10.4683C8.17161 12.2599 10.8546 13.25 13.6931 13.25C17.4881 13.25 21.019 11.4034 23.4447 8.52942C24.1873 7.64571 24.1843 6.31801 23.4397 5.43663C20.8944 2.43919 17.4337 0.722025 13.6931 0.722025C10.8555 0.722025 8.17194 1.70845 5.92952 3.50276L4.17682 1.43933C3.57943 0.760929 2.79325 0.630009 2.25286 0.662947C1.98116 0.679506 1.73125 0.736852 1.51895 0.811846C1.26839 0.900352 1.03017 1.02718 0.827835 1.20058C-0.165283 2.05903 -0.283916 3.561 0.574656 4.56345L2.63075 6.98445L0.568104 9.41623C-0.272133 10.4106 -0.166523 11.9125 0.827835 12.7714C1.81372 13.6243 3.34308 13.5062 4.19036 12.5171L5.93026 10.4683Z" fill="currentColor"/>\n </svg>\n ',n.setAttribute("aria-label","Open Brainfish widget"),n.appendChild(i),{button:n,icon:i}}(e,i);r.appendChild(t),o=Ve.initialize({button:t,icon:n,widgetType:g.Popup,widgetKey:e})}const{iframeContainer:a,iframe:s}=Ze({widgetUrl:t,widgetType:g.Popup});return r.appendChild(a),{fragment:r,iframe:s,stateManager:o}}const ot=({config:e,widgetUrl:t,apiHost:n,widgetHost:i,widgetKey:r,hideTriggerButton:o})=>{const{settings:a}=e,s=null!=o?o:null==a?void 0:a.hideTriggerButton,d=null==a?void 0:a.triggerButtonIcon;try{if(function(e){return it.has(e)}(r))return;if(function(e){return!!document.getElementById(`trigger-button-${e}`)}(r))return;$e(e);const{fragment:o,iframe:a,stateManager:l}=rt(r,t,{isButtonHidden:s||!1,triggerButtonIcon:d||""}),c=new AbortController,{signal:u}=c;a.onload=()=>{setTimeout(()=>{Ge(a,u),tt(a,{widgetHost:i,apiHost:n,widgetKey:r,widgetType:g.Popup,signal:u,stateManager:l}),nt(a,u,l)},0)},document.body?document.body.appendChild(o):(console.warn("[Brainfish] document.body not ready. Widget initialization deferred."),document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(o)},{once:!0})),it.add(r);const f=()=>{c.abort(),window.removeEventListener("beforeunload",f)};return void window.addEventListener("beforeunload",f)}catch(l){!function(e,t,n){w(e,t,t.message,n)}(n,l,r)}};const at=({config:e,widgetUrl:t,apiHost:n,widgetHost:i,widgetKey:r})=>{var o,a,s;const{settings:d}=e;let l=Ve.getInstance(r);const c=new AbortController;$e(e);try{const e=document.querySelector(`.${Fe}[data-widget-key="${r}"]`),d=document.querySelector(Re);e&&d&&!d.contains(e)&&(d.appendChild(e),null==(o=d.parentElement)||o.style.setProperty("width","100%")),l||(l=Ve.initialize({isButtonHidden:!0,widgetType:g.Searchbar,widgetKey:r}));const{signal:u}=c,f=e=>{Ge(e,u),tt(e,{widgetHost:i,apiHost:n,widgetKey:r,widgetType:g.Searchbar,signal:u,stateManager:l}),nt(e,u,l)};if(e){const t=e.querySelector("iframe");t&&("complete"===(null==(s=t.contentDocument)?void 0:s.readyState)?setTimeout(()=>{f(t)},0):t.onload=()=>{setTimeout(()=>{f(t)},0)})}else{const e=document.createDocumentFragment(),{iframeContainer:n,iframe:i}=Ze({widgetUrl:t,widgetType:g.Searchbar,props:{"data-widget-type":"searchbar","data-widget-key":r}});i.onload=()=>{setTimeout(()=>{f(i)},0)},e.appendChild(n),d?(d.appendChild(e),null==(a=d.parentElement)||a.style.setProperty("width","100%")):document.body.appendChild(e)}const p=()=>{c.abort(),window.removeEventListener("beforeunload",p)};return void window.addEventListener("beforeunload",p)}catch(u){!function(e,t,n){w(e,t,t.message,n)}(n,u,r)}},st=(e,t)=>{var n;const a=C(e.overrides),d=(null==(l=e.overrides)?void 0:l.widgetHost)||"https://agent.brainfi.sh";var l;const c=null==(n=e.overrides)?void 0:n.hideTriggerButton,{theme:u,settings:f}=t,p=e.overrides||{},{theme:g,redirectRules:h,regions:b,customCss:m}=p,y=((e,t)=>{var n={};for(var a in e)r.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&i)for(var a of i(e))t.indexOf(a)<0&&o.call(e,a)&&(n[a]=e[a]);return n})(p,["theme","redirectRules","regions","customCss"]),w=s(s({},u),g),v=s(s({},f),y),x=_(JSON.stringify(h)),S={theme:_(JSON.stringify(w)),settings:_(JSON.stringify(v)),redirectRules:x};b&&(S.regions=_(JSON.stringify(b))),m&&(S.customCss=_(m));const k=`${d}/?widgetKey=${e.widgetKey}#${new URLSearchParams(S).toString()}`;"Search"===t.widgetType?at({config:t,widgetUrl:k,apiHost:a,widgetHost:d,widgetKey:e.widgetKey}):ot({config:t,widgetUrl:k,apiHost:a,widgetHost:d,widgetKey:e.widgetKey,hideTriggerButton:c})};var dt=(e=>(e.FRESHCHAT="freshchat",e.INTERCOM="intercom",e.ZENDESK="zendesk",e.HELPSCOUT="helpscout",e))(dt||{});const lt=e=>c(null,null,function*(){if(e.widgetType===g.Popup){const e=window.fcWidget?dt.FRESHCHAT:null;e&&e===dt.FRESHCHAT&&(yield c(null,null,function*(){window.fcWidget||(yield new Promise(e=>setTimeout(e,100))),window.fcWidget.hide(),window.fcWidget.on("widget:closed",()=>{window.fcWidget.hide()})}))}}),ct="brainfish-nudges",ut=(e,t)=>c(null,null,function*(){try{yield c(null,null,function*(){if(document.getElementById(ct))return;const e=document.createElement("script");e.id=ct,e.src="https://cdn.jsdelivr.net/npm/@brainfish-ai/nudge-widget@latest/dist/index.es.js",e.type="module",e.async=!0,e.crossOrigin="anonymous",e.onerror=()=>{void 0!==console.warn&&console.warn("[Brainfish] Nudge widget failed to load. This may be due to CSP or network restrictions.")},document.head.appendChild(e)})}catch(n){w(e,n,"Failed to initialize Nudge widget",t)}});let ft,pt,gt,ht=!1;const bt=e=>{null==ft||ft.abort(),ft=new AbortController;const{signal:t}=ft;let n=window.location.pathname;const i=()=>{if(t.aborted)return;const i=window.location.pathname;i!==n&&(n=i,e())};window.addEventListener("popstate",i,{signal:t}),ht||(pt=history.pushState,gt=history.replaceState,history.pushState=function(...e){pt.apply(this,e),setTimeout(i,0)},history.replaceState=function(...e){gt.apply(this,e),setTimeout(i,0)},ht=!0),t.addEventListener("abort",()=>{ht&&(history.pushState=pt,history.replaceState=gt,ht=!1)})};let mt=null;const yt="undefined"!=typeof window&&window.Brainfish?window.Brainfish:(mt||(mt=function(){let e=[],t=null;function n(n,i){if(t){const e=n.split(".");let r=t;for(let t=0;t<e.length-1;t++)r=r[e[t]];const o=r[e[e.length-1]];if("function"==typeof o)return o.apply(r,i)}else e.push([n,i])}return{Widgets:{init:(...e)=>n("Widgets.init",e),identify:(...e)=>n("Widgets.identify",e),setSecretAttributes:(...e)=>n("Widgets.setSecretAttributes",e),open:()=>n("Widgets.open",[]),close:()=>n("Widgets.close",[]),createNewThread:()=>n("Widgets.createNewThread",[]),openModalForm:({formUrl:e,width:t,height:i})=>n("Widgets.openModalForm",[{formUrl:e,width:t,height:i}]),registerClientActionHandler:(...e)=>n("Widgets.registerClientActionHandler",e),onContextHelp:(...e)=>n("Widgets.onContextHelp",e),isReady:!1},SearchWidget:{initStandard:(...e)=>n("SearchWidget.initStandard",e)},HelpWidget:{initPopup:(...e)=>n("HelpWidget.initPopup",e),close:(...e)=>n("HelpWidget.close",e),open:(...e)=>n("HelpWidget.open",e),toggle:(...e)=>n("HelpWidget.toggle",e)},_setRealBrainfish:function(i){for(t=i;e.length>0;){const[t,i]=e.shift();n(t,i)}}}}(),"undefined"!=typeof window&&(window.Brainfish=mt)),mt),wt=new Map,vt=new Map;let xt=!1;function Ct(e,t,n,i){return c(this,null,function*(){var r,o,a,s,d,l;const c=(null==(r=e.overrides)?void 0:r.enableRecording)||(null==(o=null==t?void 0:t.settings)?void 0:o.enableRecording)||!1,u=(null==(a=e.overrides)?void 0:a.version)||(null==t?void 0:t.version);vt.set(e.widgetKey,{options:e,config:t,apiHost:n,analyticsApiHost:i});const f=[];(null==u?void 0:u.startsWith("2."))?(st(e,t),xt||(xt=!0,bt(()=>{vt.forEach(({options:e,config:t})=>{var n;const i=(null==(n=e.overrides)?void 0:n.version)||(null==t?void 0:t.version);(null==i?void 0:i.startsWith("2."))&&st(e,t)})}))):f.push(E(e,t)),f.push(O(e.widgetKey,t.trackingToken||"",n,i,c,(null==(s=null==t?void 0:t.settings)?void 0:s.recordingBlocklist)||[],null==(d=null==t?void 0:t.settings)?void 0:d._allowLocalhostRecording,null==(l=null==t?void 0:t.settings)?void 0:l._allowScreenRecording)),f.push(ut(n,e.widgetKey));const[p]=yield Promise.allSettled(f);p&&"fulfilled"===p.status&&p.value&&yt._setRealBrainfish(p.value)})}yt.Widgets.isReady=!1,yt.Widgets.identify=e=>{window.BrainfishAnalytics("identify",e)},yt.Widgets.setSecretAttributes=e=>{try{const{alg:t}=p(e);if("dir"!==t)throw new Error("Invalid algorithm")}catch(n){return void console.error("[Brainfish] Invalid JWE provided to setSecretAttributes:",n)}const t=document.querySelector("#bf-iframe-container .trigger-iframe");if(t){const n=()=>{t.contentWindow&&t.contentWindow.postMessage({type:"SET_SECRET_ATTRIBUTES",secretAttributes:e},"*")};t.contentWindow&&n(),t.addEventListener("load",n)}},yt.Widgets.init=e=>c(null,null,function*(){window&&(window.BrainfishAnalytics=window.BrainfishAnalytics||function(...e){(window.BrainfishAnalytics.q=window.BrainfishAnalytics.q||[]).push(e)});const t=C(e.overrides),n=(null==(i=e.overrides)?void 0:i.analyticsApiHost)||"";var i;let r;if(e.config)r=JSON.parse((e=>{if("undefined"!=typeof window&&"function"==typeof window.atob){const t=atob(e),n=t.length,i=new Uint8Array(n);for(let e=0;e<n;e++)i[e]=t.charCodeAt(e);return(new TextDecoder).decode(i)}if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");throw new Error("[utils.base64Decode]: Unsupported environment")})(e.config));else{const{config:n}=yield v({widgetKey:e.widgetKey,apiHost:t});r=n}let o=wt.get(e.widgetKey);if(o||(o=Ct(e,r,t,n),wt.set(e.widgetKey,o)),yield o,!qe.isWidgetDOMExisting(e.widgetKey,r)){wt.delete(e.widgetKey);const i=Ct(e,r,t,n);wt.set(e.widgetKey,i),yield i}yield lt(r),yt.Widgets.isReady=!0,window.dispatchEvent(new Event("onBrainfishReady"))}),yt.Widgets.registerClientActionHandler=(e,t)=>{((e,t)=>{Qe.set(e,t)})(e,t)};exports.BrainfishAnalytics=(...e)=>{"undefined"!=typeof window&&window.BrainfishAnalytics&&window.BrainfishAnalytics(...e)},exports.default=yt;
1
+ "use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,a=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,s=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&a(e,n,t[n]);if(i)for(var n of i(t))o.call(t,n)&&a(e,n,t[n]);return e},d=(e,i)=>t(e,n(i)),l=(e,t,n)=>a(e,"symbol"!=typeof t?t+"":t,n),c=(e,t,n)=>new Promise((i,r)=>{var o=e=>{try{s(n.next(e))}catch(t){r(t)}},a=e=>{try{s(n.throw(e))}catch(t){r(t)}},s=e=>e.done?i(e.value):Promise.resolve(e.value).then(o,a);s((n=n.apply(e,t)).next())});!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d32d5cef-5bfc-4916-9a09-83c0ec4961cd",e._sentryDebugIdIdentifier="sentry-dbid-d32d5cef-5bfc-4916-9a09-83c0ec4961cd")}catch(n){}}(),Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),new TextEncoder;const u=new TextDecoder;const f=e=>{let t=e;t instanceof Uint8Array&&(t=u.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return(e=>{const t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n})(t)}catch(n){throw new TypeError("The input to be decoded is not correctly encoded.")}};function p(e){let t;if("string"==typeof e){const n=e.split(".");3!==n.length&&5!==n.length||([t]=n)}else if("object"==typeof e&&e){if(!("protected"in e))throw new TypeError("Token does not contain a Protected Header");t=e.protected}try{if("string"!=typeof t||!t)throw new Error;const e=JSON.parse(u.decode(f(t)));if(!function(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return!1;var t;if(null===Object.getPrototypeOf(e))return!0;let n=e;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}(e))throw new Error;return e}catch(n){throw new TypeError("Invalid Token or Protected Header formatting")}}var g,h,b,m;("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{}).SENTRY_RELEASE={id:"web-widget@1.21.0"},(h=g||(g={})).Sidebar="sidebar",h.Searchbar="searchbar",h.Popup="popup",g.Sidebar,g.Searchbar,g.Popup;class y extends Error{constructor(e,t){super(e,t),l(this,"cause"),this.name="BrainfishWidgetError",this.cause=null==t?void 0:t.cause,Error.captureStackTrace&&Error.captureStackTrace(this,y),this.cause instanceof Error&&this.cause.stack&&(this.stack=this.stack+"\nCaused by: "+this.cause.stack)}toJSON(){return{name:this.name,message:this.message,stack:this.stack,cause:this.cause instanceof Error?{name:this.cause.name,message:this.cause.message,stack:this.cause.stack}:this.cause}}}(m=b||(b={})).LINK="link",m.CALLBACK="callback",m.EMAIL="email",m.PHONE="phone";const w=(e,t,n,i)=>{let r=n,o={};if(t instanceof Error)try{o=JSON.parse(t.message),r+=` - ${o.message||t.message}`}catch(a){r+=` - ${t.message}`}else r+=` - ${String(t)}`;((e,t,n)=>{if(!navigator||navigator.userAgent.toLowerCase().includes("headless"))return;const i=t.toJSON();fetch(`${e||"https://app.brainfi.sh"}/api/trackError.widget.create`,{method:"POST",headers:{"Content-Type":"application/json","api-key":n},body:JSON.stringify({error:`WebWidgetVersion: 1.21.0. ${t.message}`,stack:t.stack,cause:{message:i.message,stack:i.stack,cause:i.cause}})})})(e,new y(r,{cause:o}),i)};const v=e=>c(null,[e],function*({widgetKey:e,apiHost:t}){return function(e,t,n){return c(this,null,function*(){let i,r=0;for(;r<3;)try{const i=yield fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","api-key":n}});if(!i.ok)throw new Error(`API call failed with status: ${i.status}`);const r=yield i.json();if(!r)throw new Error("Error loading config: empty response");return r}catch(o){if(i=o,r++,r>=3)throw w(e,o,"Error fetching config",n),i;yield new Promise(e=>setTimeout(e,500))}})}(t,"/api/searchWidgets.getConfigByKey",e)}),x=({config:e,apiKey:t,apiHost:n})=>{const i=e.settings||{};return["bodyActionButtons","footerActionButtons","nextBestActions"].forEach(e=>{i[e]&&(i[e]=i[e].map(e=>e.type===b.CALLBACK&&e.value?d(s({},e),{value:new Function(`return ${e.value}`)()}):e))}),d(s({},e),{settings:i,apiHost:n,widgetMode:e.widgetType,apiKey:t})},C=e=>(null==e?void 0:e.apiHost)||"https://app.brainfi.sh",S=e=>c(null,[e],function*({apiHost:e,widgetKey:t,version:n}){try{const e=`https://cdn.jsdelivr.net/npm/@brainfish-ai/search-widget@${n}/dist/web.js`,t=yield(e=>c(null,null,function*(){return document.getElementById("brainfish-widget")?window.Brainfish:new Promise((t,n)=>{const i=document.createElement("script");i.id="brainfish-widget",i.src=e,i.type="module",i.async=!0,i.crossOrigin="anonymous",i.onload=()=>{setTimeout(()=>{const e=window.Brainfish;e?t(e):n(new Error("Failed to load Brainfish module"))},200)},i.onerror=t=>{const i=t,r={message:`Failed to load script: ${e}`,type:i.type,fileName:i.filename,lineNumber:i.lineno,columnNumber:i.colno,error:i.error?i.error.toString():"Unknown error"};n(new Error(JSON.stringify(r)))},document.head.appendChild(i)})}))(e);return{widget:t}}catch(i){w(e,i,i.message,t)}});const k=new Set,E=(e,t)=>c(null,null,function*(){const n=C(e.overrides);try{if(k.has(e.widgetKey))return;const i=yield S({apiHost:n,widgetKey:e.widgetKey,version:t.version||"latest"});if(i){const{widget:r}=i,o=x({config:t,apiKey:e.widgetKey,apiHost:n});return e.overrides&&t.settings&&Object.entries(e.overrides).forEach(([e,n])=>{t.settings&&e in t.settings&&(t.settings[e]=((e=[],t)=>{const n=new Map(e.map(e=>[e.label,e]));return t.forEach(e=>n.set(e.label,e)),Array.from(n.values())})(t.settings[e],n))}),function(e,t){t.widgetType===g.Searchbar||"Search"===t.widgetType?e.SearchWidget.initStandard(t):e.HelpWidget.initPopup(t)}(r,o),k.add(e.widgetKey),r}}catch(i){w(n,i,i.message,e.widgetKey)}});let T=!1;const O=(e,t,n,...i)=>c(null,[e,t,n,...i],function*(e,t,n,i="",r=!1,o){if(t||void 0!==console.warn&&console.warn("[Brainfish] BrainfishAnalytics not initialized. Access key is required."),!T)try{const a=(()=>{if("undefined"==typeof window||"undefined"==typeof navigator)return!1;const e=navigator,t=window,n=(e.doNotTrack||t.doNotTrack||e.msDoNotTrack||"0").toString().toLowerCase();return["1","yes","true"].includes(n)})(),s="undefined"!=typeof localStorage&&"true"===localStorage.getItem("bf_tracking_disabled"),d=a||s;window.BrainfishAnalytics("init",{apiUrl:i,accessKey:t,trackScreenViews:!0,trackAttributes:!d,trackOutgoingLinks:!d,enableRecording:!d&&r,recordingOptions:o}),T=!0,yield((e,t)=>c(null,null,function*(){if(document.getElementById("brainfish-analytics"))return window.BrainfishAnalytics;const n=document.createElement("script");n.id="brainfish-analytics",n.src="https://cdn.jsdelivr.net/npm/@brainfish-ai/web-tracker@latest/dist/tracker.js",n.type="module",n.async=!0,n.crossOrigin="anonymous",n.onerror=()=>{w(e,new Error(`Failed to load script: ${n.src}`),`Failed to load script: ${n.src}`,t)},document.head.appendChild(n)}))(n,e)}catch(a){w(n,a,"Failed to initialize BrainfishAnalytics",e)}});function I(e){const t=(new TextEncoder).encode(e);if("undefined"!=typeof window&&"function"==typeof window.btoa){const e=Array.from(t,e=>String.fromCharCode(e)).join("");return btoa(e)}if("undefined"!=typeof Buffer)return Buffer.from(t).toString("base64");throw new Error("[utils.base64Encode]: Unsupported environment")}function _(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var W,A={exports:{}},B={exports:{}},P={exports:{}};function M(){return W||(W=1,function(e,t){function n(e){return Math.round(255*e)}function i(e,t,i){return n(e)+","+n(t)+","+n(i)}t.__esModule=!0,t.default=void 0,t.default=function(e,t,n,r){if(void 0===r&&(r=i),0===t)return r(n,n,n);var o=(e%360+360)%360/60,a=(1-Math.abs(2*n-1))*t,s=a*(1-Math.abs(o%2-1)),d=0,l=0,c=0;o>=0&&o<1?(d=a,l=s):o>=1&&o<2?(d=s,l=a):o>=2&&o<3?(l=a,c=s):o>=3&&o<4?(l=s,c=a):o>=4&&o<5?(d=s,c=a):o>=5&&o<6&&(d=a,c=s);var u=n-a/2;return r(d+u,l+u,c+u)},e.exports=t.default}(P,P.exports)),P.exports}var L,j={exports:{}};function H(){return L||(L=1,function(e,t){t.__esModule=!0,t.default=void 0;var n={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};t.default=function(e){if("string"!=typeof e)return e;var t=e.toLowerCase();return n[t]?"#"+n[t]:e},e.exports=t.default}(j,j.exports)),j.exports}var F,K,$,N={exports:{}};function z(){return F||(F=1,function(e,t){function n(e){var t="function"==typeof Map?new Map:void 0;return n=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(i())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,t);var a=new(e.bind.apply(e,o));return n&&r(a,n.prototype),a}(e,arguments,o(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),r(n,e)},n(e)}function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(i=function(){return!!e})()}function r(e,t){return(r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}t.__esModule=!0,t.default=void 0;var a={1:"Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",2:"Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",3:"Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",4:"Couldn't generate valid rgb string from %s, it returned %s.\n\n",5:"Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",6:"Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",7:"Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",8:"Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",9:"Please provide a number of steps to the modularScale helper.\n\n",10:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",11:'Invalid value passed as base to modularScale, expected number or em string but got "%s"\n\n',12:'Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.\n\n',13:'Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.\n\n',14:'Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',15:'Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.\n\n',16:"You must provide a template to this method.\n\n",17:"You passed an unsupported selector state to this method.\n\n",18:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",19:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",20:"expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:"fontFace expects a name of a font-family.\n\n",24:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",25:"fontFace expects localFonts to be an array.\n\n",26:"fontFace expects fileFormats to be an array.\n\n",27:"radialGradient requries at least 2 color-stops to properly render.\n\n",28:"Please supply a filename to retinaImage() as the first argument.\n\n",29:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",32:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",33:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",34:"borderRadius expects a radius value as a string or number as the second argument.\n\n",35:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',36:"Property must be a string value.\n\n",37:"Syntax Error at %s.\n\n",38:"Formula contains a function that needs parentheses at %s.\n\n",39:"Formula is missing closing parenthesis at %s.\n\n",40:"Formula has too many closing parentheses at %s.\n\n",41:"All values in a formula must have the same unit or be unitless.\n\n",42:"Please provide a number of steps to the modularScale helper.\n\n",43:"Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",44:"Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",45:"Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",46:"Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",47:"minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",48:"fromSize and toSize must be provided as stringified numbers with the same units.\n\n",49:"Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",50:"Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",51:"Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",52:"fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",53:"fontFace expects localFonts to be an array.\n\n",54:"fontFace expects fileFormats to be an array.\n\n",55:"fontFace expects a name of a font-family.\n\n",56:"linearGradient requries at least 2 color-stops to properly render.\n\n",57:"radialGradient requries at least 2 color-stops to properly render.\n\n",58:"Please supply a filename to retinaImage() as the first argument.\n\n",59:"Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:"Property must be a string value.\n\n",62:"borderRadius expects a radius value as a string or number as the second argument.\n\n",63:'borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.\n\n',64:"The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",65:"To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",66:"The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",67:"You must provide a template to this method.\n\n",68:"You passed an unsupported selector state to this method.\n\n",69:'Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.\n\n',70:'Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.\n\n',71:'Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.\n\n',72:'Passed invalid base value %s to %s(), please pass a value like "12px" or 12.\n\n',73:"Please provide a valid CSS variable.\n\n",74:"CSS variable not found and no default was provided.\n\n",75:"important requires a valid style object, got a %s instead.\n\n",76:"fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",77:'remToPx expects a value in "rem" but you provided it in "%s".\n\n',78:'base must be set in "px" or "%" but you set it in "%s".\n'};function s(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i,r=t[0],o=[];for(i=1;i<t.length;i+=1)o.push(t[i]);return o.forEach(function(e){r=r.replace(/%[a-z]/,e)}),r}t.default=function(e){var t,n;function i(t){var n;if("production"===process.env.NODE_ENV)n=e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this;else{for(var i=arguments.length,r=new Array(i>1?i-1:0),o=1;o<i;o++)r[o-1]=arguments[o];n=e.call(this,s.apply(void 0,[a[t]].concat(r)))||this}return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,r(t,n),i}(n(Error)),e.exports=t.default}(N,N.exports)),N.exports}function R(){return K||(K=1,function(e,t){t.__esModule=!0,t.default=function(e){if("string"!=typeof e)throw new r.default(3);var t=(0,i.default)(e);if(t.match(a))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(s)){var o=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:o}}if(t.match(d))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(l)){var g=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:g}}var h=c.exec(t);if(h)return{red:parseInt(""+h[1],10),green:parseInt(""+h[2],10),blue:parseInt(""+h[3],10)};var b=u.exec(t.substring(0,50));if(b)return{red:parseInt(""+b[1],10),green:parseInt(""+b[2],10),blue:parseInt(""+b[3],10),alpha:parseFloat(""+b[4])>1?parseFloat(""+b[4])/100:parseFloat(""+b[4])};var m=f.exec(t);if(m){var y=parseInt(""+m[1],10),w=parseInt(""+m[2],10)/100,v=parseInt(""+m[3],10)/100,x="rgb("+(0,n.default)(y,w,v)+")",C=c.exec(x);if(!C)throw new r.default(4,t,x);return{red:parseInt(""+C[1],10),green:parseInt(""+C[2],10),blue:parseInt(""+C[3],10)}}var S=p.exec(t.substring(0,50));if(S){var k=parseInt(""+S[1],10),E=parseInt(""+S[2],10)/100,T=parseInt(""+S[3],10)/100,O="rgb("+(0,n.default)(k,E,T)+")",I=c.exec(O);if(!I)throw new r.default(4,t,O);return{red:parseInt(""+I[1],10),green:parseInt(""+I[2],10),blue:parseInt(""+I[3],10),alpha:parseFloat(""+S[4])>1?parseFloat(""+S[4])/100:parseFloat(""+S[4])}}throw new r.default(5)};var n=o(M()),i=o(H()),r=o(z());function o(e){return e&&e.__esModule?e:{default:e}}var a=/^#[a-fA-F0-9]{6}$/,s=/^#[a-fA-F0-9]{8}$/,d=/^#[a-fA-F0-9]{3}$/,l=/^#[a-fA-F0-9]{4}$/,c=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,u=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,f=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,p=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;e.exports=t.default}(B,B.exports)),B.exports}function q(){return $||($=1,function(e,t){t.__esModule=!0,t.default=function(e){if("transparent"===e)return 0;var t=(0,i.default)(e),n=Object.keys(t).map(function(e){var n=t[e]/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)}),r=n[0],o=n[1],a=n[2];return parseFloat((.2126*r+.7152*o+.0722*a).toFixed(3))};var n,i=(n=R())&&n.__esModule?n:{default:n};e.exports=t.default}(A,A.exports)),A.exports}const D=_(q());var U,J={exports:{}},Y={exports:{}};function V(){return U||(U=1,function(e,t){function n(e,t,i){return function(){var r=i.concat(Array.prototype.slice.call(arguments));return r.length>=t?e.apply(this,r):n(e,t,r)}}t.__esModule=!0,t.default=function(e){return n(e,e.length,[])},e.exports=t.default}(Y,Y.exports)),Y.exports}var Z,G={exports:{}};function Q(){return Z||(Z=1,e=G,(t=G.exports).__esModule=!0,t.default=void 0,t.default=function(e,t,n){return Math.max(e,Math.min(t,n))},e.exports=t.default),G.exports;var e,t}var X,ee,te={exports:{}},ne={exports:{}};function ie(){return X||(X=1,e=ne,(t=ne.exports).__esModule=!0,t.default=void 0,t.default=function(e){var t,n=e.red/255,i=e.green/255,r=e.blue/255,o=Math.max(n,i,r),a=Math.min(n,i,r),s=(o+a)/2;if(o===a)return void 0!==e.alpha?{hue:0,saturation:0,lightness:s,alpha:e.alpha}:{hue:0,saturation:0,lightness:s};var d=o-a,l=s>.5?d/(2-o-a):d/(o+a);switch(o){case n:t=(i-r)/d+(i<r?6:0);break;case i:t=(r-n)/d+2;break;default:t=(n-i)/d+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:l,lightness:s,alpha:e.alpha}:{hue:t,saturation:l,lightness:s}},e.exports=t.default),ne.exports;var e,t}function re(){return ee||(ee=1,function(e,t){t.__esModule=!0,t.default=function(e){return(0,i.default)((0,n.default)(e))};var n=r(R()),i=r(ie());function r(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(te,te.exports)),te.exports}var oe,ae={exports:{}},se={exports:{}},de={exports:{}},le={exports:{}};function ce(){return oe||(oe=1,function(e,t){t.__esModule=!0,t.default=void 0;t.default=function(e){return 7===e.length&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e},e.exports=t.default}(le,le.exports)),le.exports}var ue,fe,pe,ge={exports:{}};function he(){return ue||(ue=1,e=ge,(t=ge.exports).__esModule=!0,t.default=void 0,t.default=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},e.exports=t.default),ge.exports;var e,t}function be(){return fe||(fe=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=o(M()),i=o(ce()),r=o(he());function o(e){return e&&e.__esModule?e:{default:e}}function a(e){return(0,r.default)(Math.round(255*e))}function s(e,t,n){return(0,i.default)("#"+a(e)+a(t)+a(n))}t.default=function(e,t,i){return(0,n.default)(e,t,i,s)},e.exports=t.default}(de,de.exports)),de.exports}function me(){return pe||(pe=1,function(e,t){t.__esModule=!0,t.default=function(e,t,r){if("number"==typeof e&&"number"==typeof t&&"number"==typeof r)return(0,n.default)(e,t,r);if("object"==typeof e&&void 0===t&&void 0===r)return(0,n.default)(e.hue,e.saturation,e.lightness);throw new i.default(1)};var n=r(be()),i=r(z());function r(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(se,se.exports)),se.exports}var ye,we={exports:{}};function ve(){return ye||(ye=1,function(e,t){t.__esModule=!0,t.default=function(e,t,o,a){if("number"==typeof e&&"number"==typeof t&&"number"==typeof o&&"number"==typeof a)return a>=1?(0,n.default)(e,t,o):"rgba("+(0,i.default)(e,t,o)+","+a+")";if("object"==typeof e&&void 0===t&&void 0===o&&void 0===a)return e.alpha>=1?(0,n.default)(e.hue,e.saturation,e.lightness):"rgba("+(0,i.default)(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new r.default(2)};var n=o(be()),i=o(M()),r=o(z());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(we,we.exports)),we.exports}var xe,Ce={exports:{}};function Se(){return xe||(xe=1,function(e,t){t.__esModule=!0,t.default=function(e,t,o){if("number"==typeof e&&"number"==typeof t&&"number"==typeof o)return(0,n.default)("#"+(0,i.default)(e)+(0,i.default)(t)+(0,i.default)(o));if("object"==typeof e&&void 0===t&&void 0===o)return(0,n.default)("#"+(0,i.default)(e.red)+(0,i.default)(e.green)+(0,i.default)(e.blue));throw new r.default(6)};var n=o(ce()),i=o(he()),r=o(z());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(Ce,Ce.exports)),Ce.exports}var ke,Ee,Te,Oe={exports:{}};function Ie(){return ke||(ke=1,function(e,t){t.__esModule=!0,t.default=function(e,t,o,a){if("string"==typeof e&&"number"==typeof t){var s=(0,n.default)(e);return"rgba("+s.red+","+s.green+","+s.blue+","+t+")"}if("number"==typeof e&&"number"==typeof t&&"number"==typeof o&&"number"==typeof a)return a>=1?(0,i.default)(e,t,o):"rgba("+e+","+t+","+o+","+a+")";if("object"==typeof e&&void 0===t&&void 0===o&&void 0===a)return e.alpha>=1?(0,i.default)(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new r.default(7)};var n=o(R()),i=o(Se()),r=o(z());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(Oe,Oe.exports)),Oe.exports}function _e(){return Ee||(Ee=1,function(e,t){t.__esModule=!0,t.default=function(e){if("object"!=typeof e)throw new a.default(8);if(l(e))return(0,o.default)(e);if(d(e))return(0,r.default)(e);if(u(e))return(0,i.default)(e);if(c(e))return(0,n.default)(e);throw new a.default(8)};var n=s(me()),i=s(ve()),r=s(Se()),o=s(Ie()),a=s(z());function s(e){return e&&e.__esModule?e:{default:e}}var d=function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)},l=function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha},c=function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)},u=function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&"number"==typeof e.alpha};e.exports=t.default}(ae,ae.exports)),ae.exports}function We(){return Te||(Te=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=a(V()),i=a(Q()),r=a(re()),o=a(_e());function a(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},s.apply(this,arguments)}var d=(0,n.default)(function(e,t){if("transparent"===t)return t;var n=(0,r.default)(t);return(0,o.default)(s({},n,{lightness:(0,i.default)(0,1,n.lightness-parseFloat(e))}))});t.default=d,e.exports=t.default}(J,J.exports)),J.exports}const Ae=_(We());var Be,Pe={exports:{}};function Me(){return Be||(Be=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=a(V()),i=a(Q()),r=a(re()),o=a(_e());function a(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},s.apply(this,arguments)}var d=(0,n.default)(function(e,t){if("transparent"===t)return t;var n=(0,r.default)(t);return(0,o.default)(s({},n,{lightness:(0,i.default)(0,1,n.lightness+parseFloat(e))}))});t.default=d,e.exports=t.default}(Pe,Pe.exports)),Pe.exports}const Le=_(Me()),je="bf-iframe-container",He="bf-trigger-button",Fe="bf-search-bar-iframe-container",Ke="bf-search-bar-iframe-backdrop";function $e(e){var t,n;if(!document.querySelector("style[data-widget-styles]")){!function(e="#000",t="FFF"){const n=document.createElement("style");n.attributes.setNamedItem(document.createAttribute("data-widget-styles"));const i=D(e)>.5;n.textContent=`\n .bf-trigger-button{position:fixed;bottom:16px;right:16px;width:36px;height:36px;border-radius:50%;border:none;box-shadow:0 1px 6px #0000000f,0 2px 32px #00000029;transition:transform 167ms cubic-bezier(.33,0,0,1);box-sizing:content-box;display:flex;align-items:center;justify-content:center;cursor:pointer;z-index:1000;padding:12px;gap:10px;overflow:hidden}.bf-trigger-button.hidden{display:none}.trigger-button-icon{display:flex;align-items:center;justify-content:center;width:36px;height:36px;position:relative}.trigger-button-icon svg{width:100%;height:100%;position:absolute;inset:0}.trigger-button-icon>svg>path{transition:transform .3s ease,opacity .3s ease;transform:scale(.5);transform-origin:center;opacity:0}.trigger-button-icon .fish-icon{display:none}.trigger-button-icon .fish-icon.visible{display:block;max-width:36px;max-height:36px}.trigger-button-icon svg.visible{display:block}.trigger-button-icon>svg.visible>path{opacity:1;transform:scale(1)}.trigger-iframe{position:relative;width:100%;height:100%;border:none;outline:none;transform:translateZ(0);overflow:hidden}.bf-iframe-container{visibility:hidden;position:fixed;z-index:2147483000000;background-color:#fff;bottom:0;right:0;width:100vw;height:calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));border:none;overflow:hidden;opacity:0;pointer-events:none;transform:translateY(20px);transition:opacity .3s ease,transform .3s ease,width .2s ease-in-out,height .2s ease-in-out,visibility 0s .3s}.bf-iframe-container.open{visibility:visible;opacity:1;transform:translateY(0);pointer-events:auto;top:env(safe-area-inset-top);left:0;transition-delay:0s}@media (min-width: 576px){.bf-iframe-container{bottom:80px;right:24px;width:448px;height:min(750px,calc(100vh - 80px));border-radius:8px;border:1px solid var(--Dark-300, #d4d4d4);box-shadow:0 20px 25px -5px #1212171a,0 10px 10px -5px #1212170a}.bf-iframe-container.open{top:unset;left:unset}.bf-iframe-container.position-bottom-left{right:auto;left:24px}.bf-iframe-container.position-top-left{inset:80px auto auto 24px}.bf-iframe-container.position-top-right{bottom:auto;top:80px;right:24px}.bf-iframe-container.expanded{width:min(calc(448px * 1.35),calc(100vw - 16px));height:min(calc(750px * 1.35),calc(100vh - 80px))}}.bf-search-bar-iframe-container{position:relative;width:100%;min-height:200px;background-color:#fff;border:1px solid var(--dark-300, #d4d4d4);border-radius:8px;overflow:hidden;pointer-events:auto;transition:height .2s ease-in-out}.iframe-loading-indicator{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:flex;align-items:center;justify-content:center;z-index:10}.spinner{width:24px;height:24px;border:2px solid rgba(0,0,0,.1);border-radius:50%;border-top-color:#3498db;animation:spin 1s ease-in-out infinite}@keyframes spin{to{transform:rotate(360deg)}}.loading-error{width:24px;height:24px;position:relative;display:flex;align-items:center;justify-content:center}.loading-error:before,.loading-error:after{content:"";position:absolute;width:16px;height:2px;background-color:#e74c3c;border-radius:2px}.loading-error:before{transform:rotate(45deg)}.loading-error:after{transform:rotate(-45deg)}\n .${He} { background: ${e}; }\n .${He}:hover {\n background: ${i?Ae(.05,e):Le(.05,e)};\n }\n .trigger-button-icon { color: ${t}; }\n `,document.head.appendChild(n)}((null==(t=null==e?void 0:e.theme)?void 0:t.inputButtonBgColor)||"#007bff",(null==(n=null==e?void 0:e.theme)?void 0:n.textBaseColor)||"#ffffff")}}class Ne{constructor(e,t){l(this,"isOpen",!1),this.widgetKey=e,this.widgetType=t}get isWidgetOpen(){return this.isOpen}openWidget(){this.isOpen=!0}closeWidget(){this.isOpen=!1}toggleWidget(){return this.isOpen=!this.isOpen,this.isOpen}}function ze(e,t,n={}){const i=document.createElement(e);return i.className=t,Object.entries(n).forEach(([e,t])=>{i.setAttribute(e,t)}),i}const Re="brainfish-search-widget";class qe{constructor(e){l(this,"button",null),l(this,"icon",null),l(this,"closeCallback",null),this.widgetType=e}setCloseCallback(e){this.closeCallback=e}get containerClass(){return this.widgetType===g.Searchbar?Fe:je}get container(){return document.querySelector(`.${this.containerClass}`)}get iframe(){var e;return null==(e=this.container)?void 0:e.querySelector("iframe")}get backdrop(){return document.querySelector(`.${Ke}`)}setElements(e,t){this.button=e||null,this.icon=t||null}openWidget(e={}){var t,n,i;const r=document.querySelector(`.${this.containerClass}`),o=null==r?void 0:r.querySelector("iframe");if(e.newConversation&&e.contextualQuestion?null==(t=null==o?void 0:o.contentWindow)||t.postMessage({type:"CONTEXTUAL_QUESTION",question:e.contextualQuestion},"*"):e.newConversation&&(null==(n=null==o?void 0:o.contentWindow)||n.postMessage({type:"NEW_CONVERSATION"},"*")),null==(i=null==o?void 0:o.contentWindow)||i.postMessage({type:"FOCUS_SEARCH_FIELD"},"*"),this.widgetType!==g.Searchbar&&(null==r||r.classList.add("open"),e.position&&(null==r||r.classList.add(`position-${e.position}`),null==r||r.setAttribute("data-current-position",e.position))),null==r||r.setAttribute("aria-hidden","false"),this.widgetType!==g.Searchbar&&document.body.clientWidth>=962&&null===this.backdrop){const e=ze("div",Ke);this.closeCallback&&e.addEventListener("click",this.closeCallback),document.body.appendChild(e)}this.updateButtonForOpen()}focusNextElement(){const e=document.querySelector(Re);if(e){const t=Array.from(document.querySelectorAll('a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')).filter(e=>!e.hasAttribute("disabled")),n=t.indexOf(e);if(-1!==n){const e=t[n+1];e&&e.focus()}}}closeWidget(){const e=this.container;if(!e)return;const t=e.dataset.currentPosition;if(t){const n=()=>{e.dataset.currentPosition===t&&(e.classList.remove(`position-${t}`),delete e.dataset.currentPosition)};e.addEventListener("transitionend",n,{once:!0})}e.classList.remove("open"),e.setAttribute("aria-hidden","true"),this.backdrop&&(this.backdrop.remove(),this.focusNextElement()),this.updateButtonForClose()}updateButtonForOpen(){if(!this.button||!this.icon)return;const e=this.icon.querySelector(".fish-icon"),t=this.icon.querySelector(".close-icon");this.button.setAttribute("aria-expanded","true"),null==e||e.classList.remove("visible"),null==t||t.classList.add("visible"),this.isMobile()&&this.hideTriggerButton()}updateButtonForClose(){if(!this.button||!this.icon)return;const e=this.icon.querySelector(".fish-icon"),t=this.icon.querySelector(".close-icon");this.button.setAttribute("aria-expanded","false"),null==e||e.classList.add("visible"),null==t||t.classList.remove("visible"),this.isMobile()&&this.showTriggerButton()}showTriggerButton(){var e;null==(e=this.button)||e.classList.remove("hidden")}hideTriggerButton(){var e;null==(e=this.button)||e.classList.add("hidden")}resizeContainer(e){if(this.widgetType!==g.Searchbar)return;if(!this.container||!this.iframe)return;const t=Math.max(e,200);this.container.style.height=`${t}px`,this.iframe.style.height=`${t}px`}isMobile(){return document.body.clientWidth<=576}setupButtonClickListener(e){this.button&&this.button.addEventListener("click",e)}static isWidgetDOMExisting(e,t){const n=document.querySelector(`.${Fe}[data-widget-key="${e}"]`);if(n){const e=document.querySelector("brainfish-search-widget");return!e||e.contains(n)}if(document.getElementById(`trigger-button-${e}`))return!0;if("Search"!==t.widgetType){if(document.querySelector(`.${je}`))return!0}return!1}}class De{static register(e,t){this.instances.set(e,t)}static getInstance(e){return this.instances.get(e)}static unregister(e){this.instances.delete(e)}static getAllInstances(){return Array.from(this.instances.values())}static getOpenInstance(){return this.getAllInstances().find(e=>e.isWidgetOpen)}static getClosedPopupInstance(){return this.getAllInstances().find(e=>!e.isWidgetOpen&&e.widgetType===g.Popup)}static clear(){this.instances.clear()}}l(De,"instances",new Map);const Ue=({formUrl:e,width:t="500px",height:n="600px"})=>{const i=document.createElement("div");i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("tabindex","-1"),i.style.cssText="\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background: white;\n padding: 20px;\n border-radius: 8px;\n box-shadow: 0 2px 10px rgba(0,0,0,0.1);\n z-index: 300000000;\n ";const r=document.createElement("button");r.innerHTML="×",r.style.cssText="\n position: absolute;\n right: -16px;\n top: -16px;\n width: 32px;\n height: 32px;\n border: 2px solid #666;\n border-radius: 50%;\n background: #FFF;\n font-size: 20px;\n cursor: pointer;\n ";const o=document.createElement("iframe");o.src=e,o.style.cssText=`width: ${t}; height: ${n}; border: none;`;const a=document.activeElement,s=e=>{if("Tab"===e.key){const t=[r,o],n=document.activeElement,i=n?t.indexOf(n):-1;e.preventDefault(),e.shiftKey?i<=0?t[t.length-1].focus():t[i-1].focus():i>=t.length-1?t[0].focus():t[i+1].focus()}else"Escape"===e.key&&d()},d=()=>{i.remove(),l.remove(),document.removeEventListener("keydown",s),null==a||a.focus()},l=document.createElement("div");l.style.cssText="\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0,0,0,0.5);\n z-index: 299999999;\n ",r.onclick=d,l.onclick=d,document.addEventListener("keydown",s),i.appendChild(r),i.appendChild(o),document.body.appendChild(l),document.body.appendChild(i),i.focus(),o.onload=()=>{o.setAttribute("tabindex","0"),r.focus()}};class Je{static initialize(){this.isInitialized||(this.setupDeprecatedAPI(),this.setupNewAPI(),this.isInitialized=!0)}static setupDeprecatedAPI(){var e;(null==(e=window.Brainfish)?void 0:e.HelpWidget)&&(window.Brainfish.HelpWidget.close=e=>this.closeCurrentlyOpenWidget(),window.Brainfish.HelpWidget.open=e=>this.openCurrentlyClosedPopupWidget(e))}static setupNewAPI(){var e;(null==(e=window.Brainfish)?void 0:e.Widgets)&&(window.Brainfish.Widgets.open=e=>this.openCurrentlyClosedPopupWidget(e,!0),window.Brainfish.Widgets.close=()=>this.closeCurrentlyOpenWidget(),window.Brainfish.Widgets.createNewThread=()=>this.createNewThread(),window.Brainfish.Widgets.openModalForm=Ue,window.Brainfish.Widgets.onContextHelp=(e,t)=>this.openContextualHelp(e,t))}static closeCurrentlyOpenWidget(){const e=De.getOpenInstance();e&&e.closeWidget()}static openCurrentlyClosedPopupWidget(e,t){const n=De.getClosedPopupInstance();if(n){const i="string"==typeof e?{trigger:e}:e,r={};t&&(r.newConversation=!0),(null==i?void 0:i.trigger)&&(r.newConversation=!0,r.trigger=i.trigger),(null==i?void 0:i.position)&&(r.position=i.position),n.openWidget(r)}}static createNewThread(){var e;const t=De.getOpenInstance();if(t){const n=t.widgetType===g.Searchbar?Fe:je,i=t.widgetType===g.Searchbar?`.${n}[data-widget-key="${t.widgetKey}"]`:`.${n}`,r=document.querySelector(i),o=null==r?void 0:r.querySelector("iframe");return void(null==(e=null==o?void 0:o.contentWindow)||e.postMessage({type:"NEW_CONVERSATION"},"*"))}const n=De.getClosedPopupInstance();n&&n.openWidget({newConversation:!0})}static openContextualHelp(e,t={}){if(!e||"string"!=typeof e||0===e.trim().length)return void console.warn("Brainfish.Widgets.onContextHelp: Invalid question provided");let n=De.getOpenInstance();if(n||(n=De.getClosedPopupInstance()),!n)return void console.warn("Brainfish.Widgets.onContextHelp: No popup widget available");const i=d(s({},t),{newConversation:!0,trigger:"contextual-help",contextualQuestion:e.trim()});n.openWidget(i)}}l(Je,"isInitialized",!1);class Ye{constructor(e,t){this.widgetType=e,this.widgetKey=t}trackOpenWidget(e,t){this.dispatchEvent("onBrainfishWidgetOpen"),"contextual-help"===e?this.trackAnalytics("Open Widget - Contextual Help",{trigger:e,question:t}):e?this.trackAnalytics("Open Widget - Custom Trigger",{trigger:e}):this.trackAnalytics("Open Widget")}trackCloseWidget(){this.dispatchEvent("onBrainfishWidgetClose"),this.trackAnalytics("Close Widget")}trackCustomEvent(e,t={}){this.trackAnalytics(e,t)}dispatchEvent(e){window.dispatchEvent(new Event(e))}trackAnalytics(e,t={}){if(window.BrainfishAnalytics){let n;switch(this.widgetType){case g.Searchbar:n="searchbar_widget";break;case g.Sidebar:default:n="search_widget"}window.BrainfishAnalytics("track",e,d(s({},t),{widgetKey:this.widgetKey}),{source:n,widgetKey:this.widgetKey})}}}class Ve{constructor(e,t){l(this,"state"),l(this,"domController"),l(this,"analyticsTracker"),this.state=new Ne(e,t),this.domController=new qe(t),this.domController.setCloseCallback(()=>this.closeWidget()),this.analyticsTracker=new Ye(t,e)}static getInstance(e){return De.getInstance(e)}get widgetKey(){return this.state.widgetKey}get widgetType(){return this.state.widgetType}get isWidgetOpen(){return this.state.isWidgetOpen}get containerClass(){return this.domController.containerClass}initialize({button:e,icon:t,isButtonHidden:n}){this.domController.setElements(e,t),this.domController.setupButtonClickListener(()=>this.toggleIframeVisibility()),De.register(this.widgetKey,this),Je.initialize()}toggleIframeVisibility(){this.state.toggleWidget()?this.openWidget():this.closeWidget()}openWidget(e={}){this.state.openWidget(),this.domController.openWidget(e),this.analyticsTracker.trackOpenWidget(e.trigger,e.contextualQuestion)}closeWidget(){this.state.closeWidget(),this.domController.closeWidget(),this.analyticsTracker.trackCloseWidget()}showTriggerButton(){this.domController.showTriggerButton()}hideTriggerButton(){this.domController.hideTriggerButton()}resizeContainer(e){this.domController.resizeContainer(e)}trackCustomEvent(e,t={}){this.analyticsTracker.trackCustomEvent(e,t)}destroy(){De.unregister(this.widgetKey)}static initialize(e){const t=new Ve(e.widgetKey,e.widgetType);return t.initialize(e),t}}function Ze({widgetUrl:e,widgetType:t,props:n}){const i=t===g.Searchbar?Fe:je,r=ze("div",i,s({id:i,"aria-live":"polite","aria-hidden":t===g.Searchbar?"false":"true"},n||{})),o=ze("div","iframe-loading-indicator"),a=ze("div","spinner");o.setAttribute("aria-label","Loading content"),o.setAttribute("role","status"),o.appendChild(a),r.appendChild(o);const d=ze("iframe","trigger-iframe",{src:e,sandbox:"allow-scripts allow-same-origin allow-popups allow-forms",allow:"clipboard-write",role:"dialog"});return d.style.opacity="0",d.addEventListener("load",()=>{o.style.display="none",d.style.opacity="1"}),d.addEventListener("error",e=>{console.error("Error loading iframe:",e),o.innerHTML="";const t=ze("div","loading-error");o.appendChild(t),o.setAttribute("aria-label","Failed to load content")}),r.appendChild(d),{iframeContainer:r,iframe:d}}function Ge(e,t){const n=()=>{(t=>{var n;null==(n=e.contentWindow)||n.postMessage({type:"UPDATE_BODY_CLASS",isDarkMode:t},"*")})(document.body.classList.contains("dark"))};n(),(()=>{const e=new MutationObserver(n);e.observe(document.body,{attributes:!0,attributeFilter:["class"]}),t.addEventListener("abort",()=>e.disconnect())})()}const Qe=new Map,Xe=(e,t)=>`Error executing Client Action with key ${e}. Details: ${t instanceof Error?t.message:String(t)}`,et=(e,t)=>c(null,null,function*(){if(Qe.has(e)){const r=Qe.get(e);if("function"!=typeof r)return{success:!1,reason:`Client Action registered with key ${e} is not a function`};try{const e=yield r(t);if(n=e,"[object Object]"!==Object.prototype.toString.call(n))throw new TypeError("Invalid result, expecting object type");return{success:!0,data:e}}catch(i){return{success:!1,reason:Xe(e,i)}}}var n;return{success:!1,reason:`No Client Action registered with key ${e}`}});function tt(e,{widgetHost:t,apiHost:n,widgetKey:i,widgetType:r,signal:o,stateManager:a}){window.addEventListener("message",r=>c(null,null,function*(){var o;if(r.origin!==t)return;const{type:s,widgetKey:d}=r.data;if(!d||d===i){if("TOGGLE_WIDGET_SIZE"===s&&function(){const e=document.querySelector(`.${je}`);e.classList.contains("expanded")?e.classList.remove("expanded"):e.classList.add("expanded")}(),"RESIZE_IFRAME"===s){const{height:e}=r.data;a.resizeContainer(e)}if("TRACK_EVENT"===s){const{eventName:e,data:t}=r.data;a.trackCustomEvent(e,t)}if("CLOSE_WIDGET"===s&&a.closeWidget(),"NEXT_BEST_ACTION_CLICKED"===s){const{action:e,searchQueryId:t,query:o,answer:a,conversation:s}=r.data;if(!["function","callback"].includes(e.type))return void console.error("[Brainfish] Invalid action type:",e);const d={query:o,answer:a,searchIntentId:e.searchIntentId,actionId:e.id,conversationId:(null==s?void 0:s.conversationId)||"",searchQueryId:t,metadata:e.metadata||{},conversation:s||null};try{if(window.__bfCallbacks=window.__bfCallbacks||{},window.__bfCallbacks[e.id])return void window.__bfCallbacks[e.id](o,a,d);const t=new URL(`${n}/api/searchWidgets.callback.codeblocks`);t.searchParams.set("apiKey",i),t.searchParams.set("codeblockId",e.id),d.searchIntentId&&t.searchParams.set("searchIntentId",d.searchIntentId);const r=document.createElement("script");r.src=t.toString(),document.head.appendChild(r),r.onload=()=>{window.__bfCallbacks[e.id](o,a,d),setTimeout(()=>{document.head.removeChild(r)},300)},r.onerror=()=>{console.error("[Brainfish] Failed to load callback script from server")}}catch(l){console.error("[Brainfish] Error executing callback:",l)}}if("CLIENT_EXECUTION"===s){const{actionKey:t,inputs:n,messageId:i}=r.data,a=yield et(t,n);null==(o=e.contentWindow)||o.postMessage({type:"CLIENT_EXECUTION_RESULT",messageId:i,result:a},"*")}}}),{signal:o})}function nt(e,t,n){let i;const r=()=>{(t=>{var i;const r={type:"UPDATE_BODY_CLASS",isMobile:t};null==(i=e.contentWindow)||i.postMessage(r,"*"),t&&(n.isWidgetOpen?n.hideTriggerButton():n.showTriggerButton())})(document.body.clientWidth<=576)},o=()=>{i&&clearTimeout(i),i=window.setTimeout(r,300)};r(),(()=>{const e=new ResizeObserver(o);e.observe(document.body),t.addEventListener("abort",()=>e.disconnect())})()}const it=new Set;function rt(e,t,{isButtonHidden:n,triggerButtonIcon:i}){const r=document.createDocumentFragment();let o;if(n)o=Ve.initialize({isButtonHidden:n,widgetType:g.Popup,widgetKey:e});else{const{button:t,icon:n}=function(e,t){const n=ze("button",He,{id:`trigger-button-${e}`,"aria-controls":je,"aria-expanded":"false","data-name":He}),i=ze("div","trigger-button-icon",{"aria-hidden":"true"});return i.innerHTML=t?`\n <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">\n <path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path>\n </svg>\n <img src="${t}" class="fish-icon visible" alt="Trigger button icon" aria-hidden="true" aria-label="help button icon" />\n `:'\n <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256" class="close-icon">\n <path d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"></path>\n </svg>\n <svg width="24" height="14" viewBox="0 0 24 14" fill="none" xmlns="http://www.w3.org/2000/svg" class="fish-icon visible">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M1.71844 10.3882L4.60606 6.98384L1.71844 3.58375C1.4014 3.21362 1.44424 2.65841 1.81269 2.33993C1.97978 2.1979 2.65242 1.98701 3.04657 2.43461L5.78425 5.65824C6.14281 5.29523 6.51693 4.95924 6.90479 4.65114C8.88976 3.07437 11.2345 2.22803 13.6931 2.22803C16.9492 2.22803 20.0039 3.71718 22.2917 6.41142C22.5702 6.74282 22.5702 7.22916 22.2917 7.56056C20.0039 10.2591 16.9492 11.744 13.6931 11.744C11.2348 11.744 8.89035 10.8948 6.90554 9.31995C6.51741 9.01199 6.14304 8.67628 5.78425 8.31374L3.04657 11.5374C2.72953 11.9075 2.18114 11.9505 1.81269 11.632C1.44852 11.3179 1.40568 10.7584 1.71844 10.3882ZM5.93026 10.4683C8.17161 12.2599 10.8546 13.25 13.6931 13.25C17.4881 13.25 21.019 11.4034 23.4447 8.52942C24.1873 7.64571 24.1843 6.31801 23.4397 5.43663C20.8944 2.43919 17.4337 0.722025 13.6931 0.722025C10.8555 0.722025 8.17194 1.70845 5.92952 3.50276L4.17682 1.43933C3.57943 0.760929 2.79325 0.630009 2.25286 0.662947C1.98116 0.679506 1.73125 0.736852 1.51895 0.811846C1.26839 0.900352 1.03017 1.02718 0.827835 1.20058C-0.165283 2.05903 -0.283916 3.561 0.574656 4.56345L2.63075 6.98445L0.568104 9.41623C-0.272133 10.4106 -0.166523 11.9125 0.827835 12.7714C1.81372 13.6243 3.34308 13.5062 4.19036 12.5171L5.93026 10.4683Z" fill="currentColor"/>\n </svg>\n ',n.setAttribute("aria-label","Open Brainfish widget"),n.appendChild(i),{button:n,icon:i}}(e,i);r.appendChild(t),o=Ve.initialize({button:t,icon:n,widgetType:g.Popup,widgetKey:e})}const{iframeContainer:a,iframe:s}=Ze({widgetUrl:t,widgetType:g.Popup});return r.appendChild(a),{fragment:r,iframe:s,stateManager:o}}const ot=({config:e,widgetUrl:t,apiHost:n,widgetHost:i,widgetKey:r,hideTriggerButton:o})=>{const{settings:a}=e,s=null!=o?o:null==a?void 0:a.hideTriggerButton,d=null==a?void 0:a.triggerButtonIcon;try{if(function(e){return it.has(e)}(r))return;if(function(e){return!!document.getElementById(`trigger-button-${e}`)}(r))return;$e(e);const{fragment:o,iframe:a,stateManager:l}=rt(r,t,{isButtonHidden:s||!1,triggerButtonIcon:d||""}),c=new AbortController,{signal:u}=c;a.onload=()=>{setTimeout(()=>{Ge(a,u),tt(a,{widgetHost:i,apiHost:n,widgetKey:r,widgetType:g.Popup,signal:u,stateManager:l}),nt(a,u,l)},0)},document.body?document.body.appendChild(o):(console.warn("[Brainfish] document.body not ready. Widget initialization deferred."),document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(o)},{once:!0})),it.add(r);const f=()=>{c.abort(),window.removeEventListener("beforeunload",f)};return void window.addEventListener("beforeunload",f)}catch(l){!function(e,t,n){w(e,t,t.message,n)}(n,l,r)}};const at=({config:e,widgetUrl:t,apiHost:n,widgetHost:i,widgetKey:r})=>{var o,a,s;const{settings:d}=e;let l=Ve.getInstance(r);const c=new AbortController;$e(e);try{const e=document.querySelector(`.${Fe}[data-widget-key="${r}"]`),d=document.querySelector(Re);e&&d&&!d.contains(e)&&(d.appendChild(e),null==(o=d.parentElement)||o.style.setProperty("width","100%")),l||(l=Ve.initialize({isButtonHidden:!0,widgetType:g.Searchbar,widgetKey:r}));const{signal:u}=c,f=e=>{Ge(e,u),tt(e,{widgetHost:i,apiHost:n,widgetKey:r,widgetType:g.Searchbar,signal:u,stateManager:l}),nt(e,u,l)};if(e){const t=e.querySelector("iframe");t&&("complete"===(null==(s=t.contentDocument)?void 0:s.readyState)?setTimeout(()=>{f(t)},0):t.onload=()=>{setTimeout(()=>{f(t)},0)})}else{const e=document.createDocumentFragment(),{iframeContainer:n,iframe:i}=Ze({widgetUrl:t,widgetType:g.Searchbar,props:{"data-widget-type":"searchbar","data-widget-key":r}});i.onload=()=>{setTimeout(()=>{f(i)},0)},e.appendChild(n),d?(d.appendChild(e),null==(a=d.parentElement)||a.style.setProperty("width","100%")):document.body.appendChild(e)}const p=()=>{c.abort(),window.removeEventListener("beforeunload",p)};return void window.addEventListener("beforeunload",p)}catch(u){!function(e,t,n){w(e,t,t.message,n)}(n,u,r)}},st=(e,t)=>{var n;const a=C(e.overrides),d=(null==(l=e.overrides)?void 0:l.widgetHost)||"https://agent.brainfi.sh";var l;const c=null==(n=e.overrides)?void 0:n.hideTriggerButton,{theme:u,settings:f}=t,p=e.overrides||{},{theme:g,redirectRules:h,regions:b,customCss:m}=p,y=((e,t)=>{var n={};for(var a in e)r.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&i)for(var a of i(e))t.indexOf(a)<0&&o.call(e,a)&&(n[a]=e[a]);return n})(p,["theme","redirectRules","regions","customCss"]),w=s(s({},u),g),v=s(s({},f),y),x=I(JSON.stringify(h)),S={theme:I(JSON.stringify(w)),settings:I(JSON.stringify(v)),redirectRules:x};b&&(S.regions=I(JSON.stringify(b))),m&&(S.customCss=I(m));const k=`${d}/?widgetKey=${e.widgetKey}#${new URLSearchParams(S).toString()}`;"Search"===t.widgetType?at({config:t,widgetUrl:k,apiHost:a,widgetHost:d,widgetKey:e.widgetKey}):ot({config:t,widgetUrl:k,apiHost:a,widgetHost:d,widgetKey:e.widgetKey,hideTriggerButton:c})};var dt=(e=>(e.FRESHCHAT="freshchat",e.INTERCOM="intercom",e.ZENDESK="zendesk",e.HELPSCOUT="helpscout",e))(dt||{});const lt=e=>c(null,null,function*(){if(e.widgetType===g.Popup){const e=window.fcWidget?dt.FRESHCHAT:null;e&&e===dt.FRESHCHAT&&(yield c(null,null,function*(){window.fcWidget||(yield new Promise(e=>setTimeout(e,100))),window.fcWidget.hide(),window.fcWidget.on("widget:closed",()=>{window.fcWidget.hide()})}))}}),ct="brainfish-nudges",ut=(e,t)=>c(null,null,function*(){try{yield c(null,null,function*(){if(document.getElementById(ct))return;const e=document.createElement("script");e.id=ct,e.src="https://cdn.jsdelivr.net/npm/@brainfish-ai/nudge-widget@latest/dist/index.es.js",e.type="module",e.async=!0,e.crossOrigin="anonymous",e.onerror=()=>{void 0!==console.warn&&console.warn("[Brainfish] Nudge widget failed to load. This may be due to CSP or network restrictions.")},document.head.appendChild(e)})}catch(n){w(e,n,"Failed to initialize Nudge widget",t)}});let ft,pt,gt,ht=!1;const bt=e=>{null==ft||ft.abort(),ft=new AbortController;const{signal:t}=ft;let n=window.location.pathname;const i=()=>{if(t.aborted)return;const i=window.location.pathname;i!==n&&(n=i,e())};window.addEventListener("popstate",i,{signal:t}),ht||(pt=history.pushState,gt=history.replaceState,history.pushState=function(...e){pt.apply(this,e),setTimeout(i,0)},history.replaceState=function(...e){gt.apply(this,e),setTimeout(i,0)},ht=!0),t.addEventListener("abort",()=>{ht&&(history.pushState=pt,history.replaceState=gt,ht=!1)})};let mt=null;const yt="undefined"!=typeof window&&window.Brainfish?window.Brainfish:(mt||(mt=function(){const e=[];let t=null;function n(n,i){if(t){const e=n.split(".");let r=t;for(let t=0;t<e.length-1;t++)r=r[e[t]];const o=r[e[e.length-1]];if("function"==typeof o)return o.apply(r,i)}else e.push([n,i])}return{Widgets:{init:(...e)=>n("Widgets.init",e),identify:(...e)=>n("Widgets.identify",e),setSecretAttributes:(...e)=>n("Widgets.setSecretAttributes",e),open:()=>n("Widgets.open",[]),close:()=>n("Widgets.close",[]),createNewThread:()=>n("Widgets.createNewThread",[]),openModalForm:({formUrl:e,width:t,height:i})=>n("Widgets.openModalForm",[{formUrl:e,width:t,height:i}]),registerClientActionHandler:(...e)=>n("Widgets.registerClientActionHandler",e),onContextHelp:(...e)=>n("Widgets.onContextHelp",e),isReady:!1},SearchWidget:{initStandard:(...e)=>n("SearchWidget.initStandard",e)},HelpWidget:{initPopup:(...e)=>n("HelpWidget.initPopup",e),close:(...e)=>n("HelpWidget.close",e),open:(...e)=>n("HelpWidget.open",e),toggle:(...e)=>n("HelpWidget.toggle",e)},_setRealBrainfish(i){for(t=i;e.length>0;){const[t,i]=e.shift();n(t,i)}}}}(),"undefined"!=typeof window&&(window.Brainfish=mt)),mt),wt=new Map,vt=new Map;let xt=!1;function Ct(e,t,n,i){return c(this,null,function*(){var r,o,a,s,d,l,c;const u=(null==(r=e.overrides)?void 0:r.enableRecording)||(null==(o=null==t?void 0:t.settings)?void 0:o.enableRecording)||!1,f=(null==(a=e.overrides)?void 0:a.version)||(null==t?void 0:t.version);vt.set(e.widgetKey,{options:e,config:t,apiHost:n,analyticsApiHost:i});const p=[];(null==f?void 0:f.startsWith("2."))?(st(e,t),xt||(xt=!0,bt(()=>{vt.forEach(({options:e,config:t})=>{var n;const i=(null==(n=e.overrides)?void 0:n.version)||(null==t?void 0:t.version);(null==i?void 0:i.startsWith("2."))&&st(e,t)})}))):p.push(E(e,t)),p.push(O(e.widgetKey,t.trackingToken||"",n,i,u,{blocklist:null==(s=null==t?void 0:t.settings)?void 0:s.recordingBlocklist,sampleRate:null==(l=null==(d=null==t?void 0:t.settings)?void 0:d.ambientSettings)?void 0:l.sampleRate,_allowLocalhostRecording:null==(c=null==t?void 0:t.settings)?void 0:c._allowLocalhostRecording})),p.push(ut(n,e.widgetKey));const[g]=yield Promise.allSettled(p);g&&"fulfilled"===g.status&&g.value&&yt._setRealBrainfish(g.value)})}yt.Widgets.isReady=!1,yt.Widgets.identify=e=>{window.BrainfishAnalytics("identify",e)},yt.Widgets.setSecretAttributes=e=>{try{const{alg:t}=p(e);if("dir"!==t)throw new Error("Invalid algorithm")}catch(n){return void console.error("[Brainfish] Invalid JWE provided to setSecretAttributes:",n)}const t=document.querySelector("#bf-iframe-container .trigger-iframe");if(t){const n=()=>{t.contentWindow&&t.contentWindow.postMessage({type:"SET_SECRET_ATTRIBUTES",secretAttributes:e},"*")};t.contentWindow&&n(),t.addEventListener("load",n)}},yt.Widgets.init=e=>c(null,null,function*(){window&&(window.BrainfishAnalytics=window.BrainfishAnalytics||function(...e){(window.BrainfishAnalytics.q=window.BrainfishAnalytics.q||[]).push(e)});const t=C(e.overrides),n=(null==(i=e.overrides)?void 0:i.analyticsApiHost)||"";var i;let r;if(e.config)r=JSON.parse((e=>{if("undefined"!=typeof window&&"function"==typeof window.atob){const t=atob(e),n=t.length,i=new Uint8Array(n);for(let e=0;e<n;e++)i[e]=t.charCodeAt(e);return(new TextDecoder).decode(i)}if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");throw new Error("[utils.base64Decode]: Unsupported environment")})(e.config));else{const{config:n}=yield v({widgetKey:e.widgetKey,apiHost:t});r=n}let o=wt.get(e.widgetKey);if(o||(o=Ct(e,r,t,n),wt.set(e.widgetKey,o)),yield o,!qe.isWidgetDOMExisting(e.widgetKey,r)){wt.delete(e.widgetKey);const i=Ct(e,r,t,n);wt.set(e.widgetKey,i),yield i}yield lt(r),yt.Widgets.isReady=!0,window.dispatchEvent(new Event("onBrainfishReady"))}),yt.Widgets.registerClientActionHandler=(e,t)=>{((e,t)=>{Qe.set(e,t)})(e,t)};exports.BrainfishAnalytics=(...e)=>{"undefined"!=typeof window&&window.BrainfishAnalytics&&window.BrainfishAnalytics(...e)},exports.default=yt;
2
2
  //# sourceMappingURL=web.cjs.js.map
package/dist/web.js CHANGED
@@ -54,7 +54,7 @@ var __async = (__this, __arguments, generator) => {
54
54
  !function() {
55
55
  try {
56
56
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
57
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "f817a00c-ccc7-49d6-9743-2125375c5818", e._sentryDebugIdIdentifier = "sentry-dbid-f817a00c-ccc7-49d6-9743-2125375c5818");
57
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "5b3efe4b-3013-41ac-9cb6-a8d426c7069a", e._sentryDebugIdIdentifier = "sentry-dbid-5b3efe4b-3013-41ac-9cb6-a8d426c7069a");
58
58
  } catch (e2) {
59
59
  }
60
60
  }();
@@ -125,7 +125,7 @@ function decodeProtectedHeader(token) {
125
125
  }
126
126
  }
127
127
  var _global = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : {};
128
- _global.SENTRY_RELEASE = { id: "web-widget@1.20.4" };
128
+ _global.SENTRY_RELEASE = { id: "web-widget@1.21.0" };
129
129
  var WidgetType;
130
130
  (function(WidgetType2) {
131
131
  WidgetType2["Sidebar"] = "sidebar";
@@ -183,7 +183,7 @@ const sendErrors = (apiHost, error, widgetKey) => {
183
183
  "api-key": widgetKey
184
184
  },
185
185
  body: JSON.stringify({
186
- error: `WebWidgetVersion: ${"1.20.4"}. ${error.message}`,
186
+ error: `WebWidgetVersion: ${"1.21.0"}. ${error.message}`,
187
187
  stack: error.stack,
188
188
  cause: {
189
189
  message: errorData.message,
@@ -432,10 +432,12 @@ const isDoNotTrackEnabled = () => {
432
432
  "0").toString().toLowerCase();
433
433
  return dntEnabledValues.includes(dnt);
434
434
  };
435
- const initBrainfishAnalytics = (_0, _1, _2, ..._3) => __async(null, [_0, _1, _2, ..._3], function* (widgetKey, accessKey, apiHost, analyticsApiHost = ANALYTICS_API_HOST, enableRecording = false, recordingBlocklist = [], _allowLocalhostRecording, _allowScreenRecording) {
435
+ const initBrainfishAnalytics = (_0, _1, _2, ..._3) => __async(null, [_0, _1, _2, ..._3], function* (widgetKey, accessKey, apiHost, analyticsApiHost = ANALYTICS_API_HOST, enableRecording = false, recordingOptions) {
436
436
  if (!accessKey) {
437
437
  if (typeof console.warn !== "undefined") {
438
- console.warn("[Brainfish] BrainfishAnalytics not initialized. Access key is required.");
438
+ console.warn(
439
+ "[Brainfish] BrainfishAnalytics not initialized. Access key is required."
440
+ );
439
441
  }
440
442
  }
441
443
  if (isTrackerInitialized) {
@@ -452,9 +454,7 @@ const initBrainfishAnalytics = (_0, _1, _2, ..._3) => __async(null, [_0, _1, _2,
452
454
  trackAttributes: !shouldDisablePrivacyFeatures,
453
455
  trackOutgoingLinks: !shouldDisablePrivacyFeatures,
454
456
  enableRecording: !shouldDisablePrivacyFeatures && enableRecording,
455
- recordingBlocklist,
456
- _allowLocalhostRecording,
457
- _allowScreenRecording
457
+ recordingOptions
458
458
  });
459
459
  isTrackerInitialized = true;
460
460
  yield loadTrackerScript(apiHost, widgetKey);
@@ -468,7 +468,7 @@ const initBrainfishAnalytics = (_0, _1, _2, ..._3) => __async(null, [_0, _1, _2,
468
468
  }
469
469
  });
470
470
  function createBrainfishQueue() {
471
- let queue = [];
471
+ const queue = [];
472
472
  let realBrainfish = null;
473
473
  function queueOrExecute(method, args) {
474
474
  if (realBrainfish) {
@@ -507,7 +507,7 @@ function createBrainfishQueue() {
507
507
  open: (...args) => queueOrExecute("HelpWidget.open", args),
508
508
  toggle: (...args) => queueOrExecute("HelpWidget.toggle", args)
509
509
  },
510
- _setRealBrainfish: function(bf) {
510
+ _setRealBrainfish(bf) {
511
511
  realBrainfish = bf;
512
512
  while (queue.length > 0) {
513
513
  const [method, args] = queue.shift();
@@ -1648,7 +1648,10 @@ class WidgetDOMController {
1648
1648
  iframeContainer == null ? void 0 : iframeContainer.classList.add("open");
1649
1649
  if (options.position) {
1650
1650
  iframeContainer == null ? void 0 : iframeContainer.classList.add(`position-${options.position}`);
1651
- iframeContainer == null ? void 0 : iframeContainer.setAttribute("data-current-position", options.position);
1651
+ iframeContainer == null ? void 0 : iframeContainer.setAttribute(
1652
+ "data-current-position",
1653
+ options.position
1654
+ );
1652
1655
  }
1653
1656
  }
1654
1657
  iframeContainer == null ? void 0 : iframeContainer.setAttribute("aria-hidden", "false");
@@ -1772,7 +1775,9 @@ class WidgetDOMController {
1772
1775
  const buttonWidget = document.getElementById(`trigger-button-${widgetKey}`);
1773
1776
  if (buttonWidget) return true;
1774
1777
  if (config.widgetType !== "Search") {
1775
- const iframeContainer = document.querySelector(`.${IFRAME_CONTAINER_CLASS}`);
1778
+ const iframeContainer = document.querySelector(
1779
+ `.${IFRAME_CONTAINER_CLASS}`
1780
+ );
1776
1781
  if (iframeContainer) return true;
1777
1782
  }
1778
1783
  return false;
@@ -1841,7 +1846,7 @@ const openModalForm = ({
1841
1846
  const iframe = document.createElement("iframe");
1842
1847
  iframe.src = formUrl;
1843
1848
  iframe.style.cssText = `width: ${width}; height: ${height}; border: none;`;
1844
- let previousActiveElement = document.activeElement;
1849
+ const previousActiveElement = document.activeElement;
1845
1850
  const handleKeyDown = (e) => {
1846
1851
  if (e.key === "Tab") {
1847
1852
  const focusableElements = [closeBtn, iframe];
@@ -1904,7 +1909,7 @@ class WidgetGlobalAPI {
1904
1909
  static setupDeprecatedAPI() {
1905
1910
  var _a;
1906
1911
  if ((_a = window.Brainfish) == null ? void 0 : _a.HelpWidget) {
1907
- window.Brainfish.HelpWidget.close = (trigger) => this.closeCurrentlyOpenWidget();
1912
+ window.Brainfish.HelpWidget.close = (_trigger) => this.closeCurrentlyOpenWidget();
1908
1913
  window.Brainfish.HelpWidget.open = (trigger) => this.openCurrentlyClosedPopupWidget(trigger);
1909
1914
  }
1910
1915
  }
@@ -1950,7 +1955,9 @@ class WidgetGlobalAPI {
1950
1955
  const containerClass = openInstance.widgetType === WidgetType.Searchbar ? SEARCH_BAR_IFRAME_CONTAINER_CLASS : IFRAME_CONTAINER_CLASS;
1951
1956
  const selector = openInstance.widgetType === WidgetType.Searchbar ? `.${containerClass}[data-widget-key="${openInstance.widgetKey}"]` : `.${containerClass}`;
1952
1957
  const iframeContainer = document.querySelector(selector);
1953
- const iframe = iframeContainer == null ? void 0 : iframeContainer.querySelector("iframe");
1958
+ const iframe = iframeContainer == null ? void 0 : iframeContainer.querySelector(
1959
+ "iframe"
1960
+ );
1954
1961
  (_a = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _a.postMessage({ type: "NEW_CONVERSATION" }, "*");
1955
1962
  return;
1956
1963
  }
@@ -2027,12 +2034,17 @@ class AnalyticsTracker {
2027
2034
  source = "search_widget";
2028
2035
  break;
2029
2036
  }
2030
- window.BrainfishAnalytics("track", eventName, __spreadProps(__spreadValues({}, data), {
2031
- widgetKey: this.widgetKey
2032
- }), {
2033
- source,
2034
- widgetKey: this.widgetKey
2035
- });
2037
+ window.BrainfishAnalytics(
2038
+ "track",
2039
+ eventName,
2040
+ __spreadProps(__spreadValues({}, data), {
2041
+ widgetKey: this.widgetKey
2042
+ }),
2043
+ {
2044
+ source,
2045
+ widgetKey: this.widgetKey
2046
+ }
2047
+ );
2036
2048
  }
2037
2049
  }
2038
2050
  }
@@ -2064,7 +2076,7 @@ class IframeStateManager {
2064
2076
  initialize({
2065
2077
  button,
2066
2078
  icon,
2067
- isButtonHidden
2079
+ isButtonHidden: _isButtonHidden
2068
2080
  }) {
2069
2081
  this.domController.setElements(button, icon);
2070
2082
  this.domController.setupButtonClickListener(
@@ -2268,7 +2280,7 @@ function initMessageListener(iframe, {
2268
2280
  widgetHost,
2269
2281
  apiHost,
2270
2282
  widgetKey,
2271
- widgetType,
2283
+ widgetType: _widgetType,
2272
2284
  signal,
2273
2285
  stateManager
2274
2286
  }) {
@@ -2292,7 +2304,7 @@ function initMessageListener(iframe, {
2292
2304
  stateManager.closeWidget();
2293
2305
  }
2294
2306
  if (type === "NEXT_BEST_ACTION_CLICKED") {
2295
- const { action, searchQueryId, query, answer } = event.data;
2307
+ const { action, searchQueryId, query, answer, conversation } = event.data;
2296
2308
  if (!["function", "callback"].includes(action.type)) {
2297
2309
  console.error("[Brainfish] Invalid action type:", action);
2298
2310
  return;
@@ -2302,9 +2314,10 @@ function initMessageListener(iframe, {
2302
2314
  answer,
2303
2315
  searchIntentId: action.searchIntentId,
2304
2316
  actionId: action.id,
2305
- conversationId: event.data.conversationId || "",
2317
+ conversationId: (conversation == null ? void 0 : conversation.conversationId) || "",
2306
2318
  searchQueryId,
2307
- metadata: action.metadata || {}
2319
+ metadata: action.metadata || {},
2320
+ conversation: conversation || null
2308
2321
  };
2309
2322
  try {
2310
2323
  window.__bfCallbacks = window.__bfCallbacks || {};
@@ -2312,7 +2325,9 @@ function initMessageListener(iframe, {
2312
2325
  window.__bfCallbacks[action.id](query, answer, context);
2313
2326
  return;
2314
2327
  }
2315
- const scriptUrl = new URL(`${apiHost}/api/searchWidgets.callback.codeblocks`);
2328
+ const scriptUrl = new URL(
2329
+ `${apiHost}/api/searchWidgets.callback.codeblocks`
2330
+ );
2316
2331
  scriptUrl.searchParams.set("apiKey", widgetKey);
2317
2332
  scriptUrl.searchParams.set("codeblockId", action.id);
2318
2333
  if (context.searchIntentId) {
@@ -2328,7 +2343,9 @@ function initMessageListener(iframe, {
2328
2343
  }, 300);
2329
2344
  };
2330
2345
  script.onerror = () => {
2331
- console.error("[Brainfish] Failed to load callback script from server");
2346
+ console.error(
2347
+ "[Brainfish] Failed to load callback script from server"
2348
+ );
2332
2349
  };
2333
2350
  } catch (error) {
2334
2351
  console.error("[Brainfish] Error executing callback:", error);
@@ -2471,14 +2488,22 @@ const initWidgetButton = ({ config, widgetUrl, apiHost, widgetHost, widgetKey, h
2471
2488
  function handleInitializationError(apiHost, error, widgetKey) {
2472
2489
  sendBrainfishWidgetError(apiHost, error, error.message, widgetKey);
2473
2490
  }
2474
- const initSearchBar = ({ config, widgetUrl, apiHost, widgetHost, widgetKey }) => {
2491
+ const initSearchBar = ({
2492
+ config,
2493
+ widgetUrl,
2494
+ apiHost,
2495
+ widgetHost,
2496
+ widgetKey
2497
+ }) => {
2475
2498
  var _a, _b, _c;
2476
- const { settings } = config;
2499
+ const { settings: _settings } = config;
2477
2500
  let stateManager = IframeStateManager.getInstance(widgetKey);
2478
2501
  const controller = new AbortController();
2479
2502
  insertStylesIfNeeded(config);
2480
2503
  try {
2481
- const existingContainer = document.querySelector(`.${SEARCH_BAR_IFRAME_CONTAINER_CLASS}[data-widget-key="${widgetKey}"]`);
2504
+ const existingContainer = document.querySelector(
2505
+ `.${SEARCH_BAR_IFRAME_CONTAINER_CLASS}[data-widget-key="${widgetKey}"]`
2506
+ );
2482
2507
  const searchWidget = document.querySelector(SEARCH_BAR_SELECTOR);
2483
2508
  if (existingContainer && searchWidget && !searchWidget.contains(existingContainer)) {
2484
2509
  searchWidget.appendChild(existingContainer);
@@ -2527,7 +2552,9 @@ const initSearchBar = ({ config, widgetUrl, apiHost, widgetHost, widgetKey }) =>
2527
2552
  document.body.appendChild(fragment);
2528
2553
  }
2529
2554
  } else {
2530
- const iframe = existingContainer.querySelector("iframe");
2555
+ const iframe = existingContainer.querySelector(
2556
+ "iframe"
2557
+ );
2531
2558
  if (iframe) {
2532
2559
  if (((_c = iframe.contentDocument) == null ? void 0 : _c.readyState) === "complete") {
2533
2560
  setTimeout(() => {
@@ -2602,7 +2629,7 @@ var HandOffType = /* @__PURE__ */ ((HandOffType2) => {
2602
2629
  HandOffType2["HELPSCOUT"] = "helpscout";
2603
2630
  return HandOffType2;
2604
2631
  })(HandOffType || {});
2605
- const detectHandoff = (config) => {
2632
+ const detectHandoff = (_config) => {
2606
2633
  const usesFreshChat = !!window.fcWidget;
2607
2634
  if (usesFreshChat) {
2608
2635
  return HandOffType.FRESHCHAT;
@@ -2627,7 +2654,7 @@ const initHandOffs = (config) => __async(null, null, function* () {
2627
2654
  }
2628
2655
  });
2629
2656
  const scriptElementId = "brainfish-nudges";
2630
- const loadNudgeWidgetScript = (apiHost, widgetKey) => __async(null, null, function* () {
2657
+ const loadNudgeWidgetScript = (_apiHost, _widgetKey) => __async(null, null, function* () {
2631
2658
  if (document.getElementById(scriptElementId)) {
2632
2659
  return;
2633
2660
  }
@@ -2639,7 +2666,9 @@ const loadNudgeWidgetScript = (apiHost, widgetKey) => __async(null, null, functi
2639
2666
  script.crossOrigin = "anonymous";
2640
2667
  script.onerror = () => {
2641
2668
  if (typeof console.warn !== "undefined") {
2642
- console.warn("[Brainfish] Nudge widget failed to load. This may be due to CSP or network restrictions.");
2669
+ console.warn(
2670
+ "[Brainfish] Nudge widget failed to load. This may be due to CSP or network restrictions."
2671
+ );
2643
2672
  }
2644
2673
  };
2645
2674
  document.head.appendChild(script);
@@ -2714,7 +2743,7 @@ const initializedWidgets = /* @__PURE__ */ new Map();
2714
2743
  let routeChangeListenerSetup = false;
2715
2744
  function initializeBrainfish(options, config, apiHost, analyticsApiHost) {
2716
2745
  return __async(this, null, function* () {
2717
- var _a, _b, _c, _d, _e, _f;
2746
+ var _a, _b, _c, _d, _e, _f, _g;
2718
2747
  const enableRecording = ((_a = options.overrides) == null ? void 0 : _a.enableRecording) || ((_b = config == null ? void 0 : config.settings) == null ? void 0 : _b.enableRecording) || false;
2719
2748
  const requestedVersion = ((_c = options.overrides) == null ? void 0 : _c.version) || (config == null ? void 0 : config.version);
2720
2749
  initializedWidgets.set(options.widgetKey, {
@@ -2729,13 +2758,15 @@ function initializeBrainfish(options, config, apiHost, analyticsApiHost) {
2729
2758
  if (!routeChangeListenerSetup) {
2730
2759
  routeChangeListenerSetup = true;
2731
2760
  listenToRouteChanges(() => {
2732
- initializedWidgets.forEach(({ options: widgetOptions, config: widgetConfig }) => {
2733
- var _a2;
2734
- const widgetVersion = ((_a2 = widgetOptions.overrides) == null ? void 0 : _a2.version) || (widgetConfig == null ? void 0 : widgetConfig.version);
2735
- if (widgetVersion == null ? void 0 : widgetVersion.startsWith("2.")) {
2736
- initIframeTrigger(widgetOptions, widgetConfig);
2761
+ initializedWidgets.forEach(
2762
+ ({ options: widgetOptions, config: widgetConfig }) => {
2763
+ var _a2;
2764
+ const widgetVersion = ((_a2 = widgetOptions.overrides) == null ? void 0 : _a2.version) || (widgetConfig == null ? void 0 : widgetConfig.version);
2765
+ if (widgetVersion == null ? void 0 : widgetVersion.startsWith("2.")) {
2766
+ initIframeTrigger(widgetOptions, widgetConfig);
2767
+ }
2737
2768
  }
2738
- });
2769
+ );
2739
2770
  });
2740
2771
  }
2741
2772
  } else {
@@ -2748,9 +2779,11 @@ function initializeBrainfish(options, config, apiHost, analyticsApiHost) {
2748
2779
  apiHost,
2749
2780
  analyticsApiHost,
2750
2781
  enableRecording,
2751
- ((_d = config == null ? void 0 : config.settings) == null ? void 0 : _d.recordingBlocklist) || [],
2752
- (_e = config == null ? void 0 : config.settings) == null ? void 0 : _e._allowLocalhostRecording,
2753
- (_f = config == null ? void 0 : config.settings) == null ? void 0 : _f._allowScreenRecording
2782
+ {
2783
+ blocklist: (_d = config == null ? void 0 : config.settings) == null ? void 0 : _d.recordingBlocklist,
2784
+ sampleRate: (_f = (_e = config == null ? void 0 : config.settings) == null ? void 0 : _e.ambientSettings) == null ? void 0 : _f.sampleRate,
2785
+ _allowLocalhostRecording: (_g = config == null ? void 0 : config.settings) == null ? void 0 : _g._allowLocalhostRecording
2786
+ }
2754
2787
  )
2755
2788
  // Even if this fails, it won't block the widget
2756
2789
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brainfish-ai/widgets-initiator",
3
- "version": "1.20.4",
3
+ "version": "1.21.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",