@brainfish-ai/widgets-initiator 1.15.0 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/initIframeTrigger/constants/breakpoints.d.ts +1 -0
- package/dist/types/initIframeTrigger/managers/IframeStateManager.d.ts +1 -0
- package/dist/types/initIframeTrigger/managers/WidgetDOMController.d.ts +7 -0
- package/dist/types/initIframeTrigger/utils/createSearchTrigger.d.ts +1 -1
- package/dist/web.cjs.js +1 -1
- package/dist/web.js +128 -29
- package/package.json +1 -1
|
@@ -23,6 +23,7 @@ export declare class IframeStateManager implements IWidgetInstance {
|
|
|
23
23
|
closeWidget(): void;
|
|
24
24
|
showTriggerButton(): void;
|
|
25
25
|
hideTriggerButton(): void;
|
|
26
|
+
resizeContainer(height: number): void;
|
|
26
27
|
trackCustomEvent(eventName: string, data?: Record<string, any>): void;
|
|
27
28
|
destroy(): void;
|
|
28
29
|
static initialize(options: {
|
|
@@ -7,17 +7,24 @@ export declare class WidgetDOMController {
|
|
|
7
7
|
private widgetType;
|
|
8
8
|
private button;
|
|
9
9
|
private icon;
|
|
10
|
+
private closeCallback;
|
|
10
11
|
constructor(widgetType: WidgetType);
|
|
12
|
+
setCloseCallback(callback: () => void): void;
|
|
11
13
|
get containerClass(): string;
|
|
14
|
+
get container(): HTMLDivElement | null;
|
|
15
|
+
get iframe(): HTMLIFrameElement | null;
|
|
16
|
+
get backdrop(): HTMLElement | null;
|
|
12
17
|
setElements(button?: HTMLElement, icon?: HTMLElement): void;
|
|
13
18
|
openWidget(options?: {
|
|
14
19
|
newConversation?: boolean;
|
|
15
20
|
}): void;
|
|
21
|
+
focusNextElement(): void;
|
|
16
22
|
closeWidget(): void;
|
|
17
23
|
private updateButtonForOpen;
|
|
18
24
|
private updateButtonForClose;
|
|
19
25
|
showTriggerButton(): void;
|
|
20
26
|
hideTriggerButton(): void;
|
|
27
|
+
resizeContainer(height: number): void;
|
|
21
28
|
private isMobile;
|
|
22
29
|
setupButtonClickListener(callback: () => void): void;
|
|
23
30
|
}
|
package/dist/web.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,a=(t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,s=(e,t)=>{for(var n in t||(t={}))i.call(t,n)&&a(e,n,t[n]);if(r)for(var n of r(t))o.call(t,n)&&a(e,n,t[n]);return e},l=(e,r)=>t(e,n(r)),d=(e,t,n)=>a(e,"symbol"!=typeof t?t+"":t,n),u=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(t){i(t)}},a=e=>{try{s(n.throw(e))}catch(t){i(t)}},s=e=>e.done?r(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]="ed931542-0cb4-452a-859d-89349d0d0730",e._sentryDebugIdIdentifier="sentry-dbid-ed931542-0cb4-452a-859d-89349d0d0730")}catch(n){}}(),Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),new TextEncoder;const c=new TextDecoder;const f=e=>{let t=e;t instanceof Uint8Array&&(t=c.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 r=0;r<t.length;r++)n[r]=t.charCodeAt(r);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(c.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:"a78428dd0393f7306b3a5d99b998727c646efbb9"},(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),d(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,r)=>{let i=n,o={};if(t instanceof Error)try{o=JSON.parse(t.message),i+=` - ${o.message||t.message}`}catch(a){i+=` - ${t.message}`}else i+=` - ${String(t)}`;((e,t,n)=>{if(!navigator||navigator.userAgent.toLowerCase().includes("headless"))return;const r=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.15.0. ${t.message}`,stack:t.stack,cause:{message:r.message,stack:r.stack,cause:r.cause}})})})(e,new y(i,{cause:o}),r)};const v=e=>u(null,[e],function*({widgetKey:e,apiHost:t}){return function(e,t,n){return u(this,null,function*(){let r,i=0;for(;i<3;)try{const r=yield fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","api-key":n}});if(!r.ok)throw new Error(`API call failed with status: ${r.status}`);const i=yield r.json();if(!i)throw new Error("Error loading config: empty response");return i}catch(o){if(r=o,i++,i>=3)throw w(e,o,"Error fetching config",n),r;yield new Promise(e=>setTimeout(e,500))}})}(t,"/api/searchWidgets.getConfigByKey",e)}),x=({config:e,apiKey:t,apiHost:n})=>{const r=e.settings||{};return["bodyActionButtons","footerActionButtons","nextBestActions"].forEach(e=>{r[e]&&(r[e]=r[e].map(e=>e.type===b.CALLBACK&&e.value?l(s({},e),{value:new Function(`return ${e.value}`)()}):e))}),l(s({},e),{settings:r,apiHost:n,widgetMode:e.widgetType,apiKey:t})},C=e=>(null==e?void 0:e.apiHost)||"https://app.brainfi.sh",k=e=>u(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=>u(null,null,function*(){return document.getElementById("brainfish-widget")?window.Brainfish:new Promise((t,n)=>{const r=document.createElement("script");r.id="brainfish-widget",r.src=e,r.type="module",r.async=!0,r.crossOrigin="anonymous",r.onload=()=>{setTimeout(()=>{const e=window.Brainfish;e?t(e):n(new Error("Failed to load Brainfish module"))},200)},r.onerror=t=>{const r=t,i={message:`Failed to load script: ${e}`,type:r.type,fileName:r.filename,lineNumber:r.lineno,columnNumber:r.colno,error:r.error?r.error.toString():"Unknown error"};n(new Error(JSON.stringify(i)))},document.head.appendChild(r)})}))(e);return{widget:t}}catch(r){w(e,r,r.message,t)}});const S=new Set,E=(e,t)=>u(null,null,function*(){const n=C(e.overrides);try{if(S.has(e.widgetKey))return;const r=yield k({apiHost:n,widgetKey:e.widgetKey,version:t.version||"latest"});if(r){const{widget:i}=r,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)}(i,o),S.add(e.widgetKey),i}}catch(r){w(n,r,r.message,e.widgetKey)}});let T=!1;const _=(e,t,n,...r)=>u(null,[e,t,n,...r],function*(e,t,n,r="",i=!1,o=[],a,s){if(t||w(n,new Error("Access key is required"),"Access key is required",e),!T)try{const l=(()=>{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)})();window.BrainfishAnalytics("init",{apiUrl:r,accessKey:t,trackScreenViews:!0,trackAttributes:!l,trackOutgoingLinks:!l,enableRecording:!l&&i,recordingBlocklist:o,_allowLocalhostRecording:a,_allowScreenRecording:s}),T=!0,yield((e,t)=>u(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(l){w(n,l,"Failed to initialize BrainfishAnalytics",e)}});function O(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 A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I,W={exports:{}},B={exports:{}},P={exports:{}};function j(){return I||(I=1,function(e,t){function n(e){return Math.round(255*e)}function r(e,t,r){return n(e)+","+n(t)+","+n(r)}t.__esModule=!0,t.default=void 0,t.default=function(e,t,n,i){if(void 0===i&&(i=r),0===t)return i(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)),l=0,d=0,u=0;o>=0&&o<1?(l=a,d=s):o>=1&&o<2?(l=s,d=a):o>=2&&o<3?(d=a,u=s):o>=3&&o<4?(d=s,u=a):o>=4&&o<5?(l=s,u=a):o>=5&&o<6&&(l=a,u=s);var c=n-a/2;return i(l+c,d+c,u+c)},e.exports=t.default}(P,P.exports)),P.exports}var M,L={exports:{}};function H(){return M||(M=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}(L,L.exports)),L.exports}var F,K,$,z={exports:{}};function N(){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(r())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,t);var a=new(e.bind.apply(e,o));return n&&i(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}}),i(n,e)},n(e)}function r(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!e})()}function i(e,t){return(i=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 r,i=t[0],o=[];for(r=1;r<t.length;r+=1)o.push(t[r]);return o.forEach(function(e){i=i.replace(/%[a-z]/,e)}),i}t.default=function(e){var t,n;function r(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 r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];n=e.call(this,s.apply(void 0,[a[t]].concat(i)))||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=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,i(t,n),r}(n(Error)),e.exports=t.default}(z,z.exports)),z.exports}function R(){return K||(K=1,function(e,t){t.__esModule=!0,t.default=function(e){if("string"!=typeof e)throw new i.default(3);var t=(0,r.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(l))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(d)){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=u.exec(t);if(h)return{red:parseInt(""+h[1],10),green:parseInt(""+h[2],10),blue:parseInt(""+h[3],10)};var b=c.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=u.exec(x);if(!C)throw new i.default(4,t,x);return{red:parseInt(""+C[1],10),green:parseInt(""+C[2],10),blue:parseInt(""+C[3],10)}}var k=p.exec(t.substring(0,50));if(k){var S=parseInt(""+k[1],10),E=parseInt(""+k[2],10)/100,T=parseInt(""+k[3],10)/100,_="rgb("+(0,n.default)(S,E,T)+")",O=u.exec(_);if(!O)throw new i.default(4,t,_);return{red:parseInt(""+O[1],10),green:parseInt(""+O[2],10),blue:parseInt(""+O[3],10),alpha:parseFloat(""+k[4])>1?parseFloat(""+k[4])/100:parseFloat(""+k[4])}}throw new i.default(5)};var n=o(j()),r=o(H()),i=o(N());function o(e){return e&&e.__esModule?e:{default:e}}var a=/^#[a-fA-F0-9]{6}$/,s=/^#[a-fA-F0-9]{8}$/,l=/^#[a-fA-F0-9]{3}$/,d=/^#[a-fA-F0-9]{4}$/,u=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,c=/^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,r.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)}),i=n[0],o=n[1],a=n[2];return parseFloat((.2126*i+.7152*o+.0722*a).toFixed(3))};var n,r=(n=R())&&n.__esModule?n:{default:n};e.exports=t.default}(W,W.exports)),W.exports}const D=A(q());var U,J={exports:{}},Y={exports:{}};function G(){return U||(U=1,function(e,t){function n(e,t,r){return function(){var i=r.concat(Array.prototype.slice.call(arguments));return i.length>=t?e.apply(this,i):n(e,t,i)}}t.__esModule=!0,t.default=function(e){return n(e,e.length,[])},e.exports=t.default}(Y,Y.exports)),Y.exports}var V,Z={exports:{}};function X(){return V||(V=1,e=Z,(t=Z.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),Z.exports;var e,t}var Q,ee,te={exports:{}},ne={exports:{}};function re(){return Q||(Q=1,e=ne,(t=ne.exports).__esModule=!0,t.default=void 0,t.default=function(e){var t,n=e.red/255,r=e.green/255,i=e.blue/255,o=Math.max(n,r,i),a=Math.min(n,r,i),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 l=o-a,d=s>.5?l/(2-o-a):l/(o+a);switch(o){case n:t=(r-i)/l+(r<i?6:0);break;case r:t=(i-n)/l+2;break;default:t=(n-r)/l+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:d,lightness:s,alpha:e.alpha}:{hue:t,saturation:d,lightness:s}},e.exports=t.default),ne.exports;var e,t}function ie(){return ee||(ee=1,function(e,t){t.__esModule=!0,t.default=function(e){return(0,r.default)((0,n.default)(e))};var n=i(R()),r=i(re());function i(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(te,te.exports)),te.exports}var oe,ae={exports:{}},se={exports:{}},le={exports:{}},de={exports:{}};function ue(){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}(de,de.exports)),de.exports}var ce,fe,pe,ge={exports:{}};function he(){return ce||(ce=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(j()),r=o(ue()),i=o(he());function o(e){return e&&e.__esModule?e:{default:e}}function a(e){return(0,i.default)(Math.round(255*e))}function s(e,t,n){return(0,r.default)("#"+a(e)+a(t)+a(n))}t.default=function(e,t,r){return(0,n.default)(e,t,r,s)},e.exports=t.default}(le,le.exports)),le.exports}function me(){return pe||(pe=1,function(e,t){t.__esModule=!0,t.default=function(e,t,i){if("number"==typeof e&&"number"==typeof t&&"number"==typeof i)return(0,n.default)(e,t,i);if("object"==typeof e&&void 0===t&&void 0===i)return(0,n.default)(e.hue,e.saturation,e.lightness);throw new r.default(1)};var n=i(be()),r=i(N());function i(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,r.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,r.default)(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new i.default(2)};var n=o(be()),r=o(j()),i=o(N());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(we,we.exports)),we.exports}var xe,Ce={exports:{}};function ke(){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,r.default)(e)+(0,r.default)(t)+(0,r.default)(o));if("object"==typeof e&&void 0===t&&void 0===o)return(0,n.default)("#"+(0,r.default)(e.red)+(0,r.default)(e.green)+(0,r.default)(e.blue));throw new i.default(6)};var n=o(ue()),r=o(he()),i=o(N());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(Ce,Ce.exports)),Ce.exports}var Se,Ee,Te,_e={exports:{}};function Oe(){return Se||(Se=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,r.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,r.default)(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new i.default(7)};var n=o(R()),r=o(ke()),i=o(N());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(_e,_e.exports)),_e.exports}function Ae(){return Ee||(Ee=1,function(e,t){t.__esModule=!0,t.default=function(e){if("object"!=typeof e)throw new a.default(8);if(d(e))return(0,o.default)(e);if(l(e))return(0,i.default)(e);if(c(e))return(0,r.default)(e);if(u(e))return(0,n.default)(e);throw new a.default(8)};var n=s(me()),r=s(ve()),i=s(ke()),o=s(Oe()),a=s(N());function s(e){return e&&e.__esModule?e:{default:e}}var l=function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)},d=function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha},u=function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)},c=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 Ie(){return Te||(Te=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=a(G()),r=a(X()),i=a(ie()),o=a(Ae());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 r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}var l=(0,n.default)(function(e,t){if("transparent"===t)return t;var n=(0,i.default)(t);return(0,o.default)(s({},n,{lightness:(0,r.default)(0,1,n.lightness-parseFloat(e))}))});t.default=l,e.exports=t.default}(J,J.exports)),J.exports}const We=A(Ie());var Be,Pe={exports:{}};function je(){return Be||(Be=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=a(G()),r=a(X()),i=a(ie()),o=a(Ae());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 r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}var l=(0,n.default)(function(e,t){if("transparent"===t)return t;var n=(0,i.default)(t);return(0,o.default)(s({},n,{lightness:(0,r.default)(0,1,n.lightness+parseFloat(e))}))});t.default=l,e.exports=t.default}(Pe,Pe.exports)),Pe.exports}const Me=A(je()),Le="bf-iframe-container",He="bf-trigger-button",Fe="bf-search-bar-iframe-container";function Ke(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 r=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}.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)}.bf-iframe-container,.bf-search-bar-iframe-container{display:none;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}.bf-iframe-container.open,.bf-search-bar-iframe-container.open{display:block;opacity:1;transform:translateY(0);pointer-events:auto;top:env(safe-area-inset-top);left:0}@media (min-width: 576px){.bf-iframe-container,.bf-search-bar-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-search-bar-iframe-container.open{width:100vw;height:calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));position:fixed;top:0;left:0}.bf-iframe-container.expanded,.bf-search-bar-iframe-container.expanded{width:min(calc(448px * 1.35),calc(100vw - 16px));height:min(calc(750px * 1.35),calc(100vh - 80px))}}@media (min-width: 962px){.bf-search-bar-iframe-container.open{width:80vw;height:auto;top:50%;left:50%;transform:translateY(-50%) translate(-50%)}}@media (min-width: 1200px){.bf-search-bar-iframe-container.open{width:60vw;min-width:770px}}@media (min-width: 1400px){.bf-search-bar-iframe-container.open{width:50vw;min-width:770px}}brainfish-search-widget{display:flex;align-items:center;height:46px;width:100%;background-color:#fff;border-radius:8px;border:1px solid #ccc;box-shadow:0 2px 4px #0000001a;font-size:16px;color:#171717;padding-left:46px;cursor:text;&:after{content:attr(data-placeholder)}&:before{content:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><circle cx="112" cy="112" r="80" fill="none" stroke="%23737373" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="168.57" y1="168.57" x2="224" y2="224" fill="none" stroke="%23737373" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>');display:block;width:24px;height:24px;position:absolute;left:12px;top:50%;transform:translateY(-50%)}}.bf-search-bar-iframe-backdrop{display:block;position:fixed;top:0;left:0;width:100%;height:100%;z-index:9999;background-color:#d9d9d905;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.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: ${r?We(.05,e):Me(.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 $e{constructor(e,t){d(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}}class ze{constructor(e){d(this,"button",null),d(this,"icon",null),this.widgetType=e}get containerClass(){return this.widgetType===g.Searchbar?Fe:Le}setElements(e,t){this.button=e||null,this.icon=t||null}openWidget(e={}){var t,n;const r=document.querySelector(`.${this.containerClass}`),i=null==r?void 0:r.querySelector("iframe");e.newConversation&&(null==(t=null==i?void 0:i.contentWindow)||t.postMessage({type:"NEW_CONVERSATION"},"*")),null==(n=null==i?void 0:i.contentWindow)||n.postMessage({type:"FOCUS_SEARCH_FIELD"},"*"),null==r||r.classList.add("open"),null==r||r.setAttribute("aria-hidden","false"),this.updateButtonForOpen()}closeWidget(){const e=document.querySelector(`.${this.containerClass}`);null==e||e.classList.remove("open"),null==e||e.setAttribute("aria-hidden","true"),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")}isMobile(){return document.body.clientWidth<=576}setupButtonClickListener(e){this.button&&this.button.addEventListener("click",e)}}class Ne{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()}}d(Ne,"instances",new Map);class Re{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=()=>this.openCurrentlyClosedPopupWidget(),window.Brainfish.Widgets.close=()=>this.closeCurrentlyOpenWidget())}static closeCurrentlyOpenWidget(){const e=Ne.getOpenInstance();e&&e.closeWidget()}static openCurrentlyClosedPopupWidget(e){const t=Ne.getClosedPopupInstance();if(t){const n=e?{newConversation:!0,trigger:e}:{};t.openWidget(n)}}}d(Re,"isInitialized",!1);class qe{constructor(e,t){this.widgetType=e,this.widgetKey=t}trackOpenWidget(e){this.dispatchEvent("onBrainfishWidgetOpen"),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={}){window.BrainfishAnalytics&&window.BrainfishAnalytics("track",e,l(s({},t),{widgetKey:this.widgetKey}),{source:this.widgetType,widgetKey:this.widgetKey})}}class De{constructor(e,t){d(this,"state"),d(this,"domController"),d(this,"analyticsTracker"),this.state=new $e(e,t),this.domController=new ze(t),this.analyticsTracker=new qe(t,e)}static getInstance(e){return Ne.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()),Ne.register(this.widgetKey,this),Re.initialize()}toggleIframeVisibility(){this.state.toggleWidget()?this.openWidget():this.closeWidget()}openWidget(e={}){this.state.openWidget(),this.domController.openWidget(e),this.analyticsTracker.trackOpenWidget(e.trigger)}closeWidget(){this.state.closeWidget(),this.domController.closeWidget(),this.analyticsTracker.trackCloseWidget()}showTriggerButton(){this.domController.showTriggerButton()}hideTriggerButton(){this.domController.hideTriggerButton()}trackCustomEvent(e,t={}){this.analyticsTracker.trackCustomEvent(e,t)}destroy(){Ne.unregister(this.widgetKey)}static initialize(e){const t=new De(e.widgetKey,e.widgetType);return t.initialize(e),t}}function Ue(e,t,n={}){const r=document.createElement(e);return r.className=t,Object.entries(n).forEach(([e,t])=>{r.setAttribute(e,t)}),r}function Je({widgetUrl:e,widgetType:t,props:n}){const r=t===g.Searchbar?Fe:Le,i=Ue("div",r,s({id:r,"aria-live":"polite","aria-hidden":"true"},n||{})),o=Ue("div","iframe-loading-indicator"),a=Ue("div","spinner");o.setAttribute("aria-label","Loading content"),o.setAttribute("role","status"),o.appendChild(a),i.appendChild(o);const l=Ue("iframe","trigger-iframe",{src:e,sandbox:"allow-scripts allow-same-origin allow-popups allow-forms",allow:"clipboard-write",role:"dialog"});return l.style.opacity="0",l.addEventListener("load",()=>{o.style.display="none",l.style.opacity="1"}),l.addEventListener("error",e=>{console.error("Error loading iframe:",e),o.innerHTML="";const t=Ue("div","loading-error");o.appendChild(t),o.setAttribute("aria-label","Failed to load content")}),i.appendChild(l),{iframeContainer:i,iframe:l}}function Ye(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 Ge=new Map,Ve=(e,t)=>`Error executing Client Action with key ${e}. Details: ${t instanceof Error?t.message:String(t)}`,Ze=(e,t)=>u(null,null,function*(){if(Ge.has(e)){const i=Ge.get(e);if("function"!=typeof i)return{success:!1,reason:`Client Action registered with key ${e} is not a function`};try{const e=yield i(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(r){return{success:!1,reason:Ve(e,r)}}}var n;return{success:!1,reason:`No Client Action registered with key ${e}`}});function Xe(e,{widgetHost:t,apiHost:n,widgetKey:r,widgetType:i,signal:o,stateManager:a}){window.addEventListener("message",i=>u(null,null,function*(){var o;if(i.origin!==t)return;const{type:s,widgetKey:l}=i.data;if(!l||l===r){if("TOGGLE_WIDGET_SIZE"===s&&function(){const e=document.querySelector(`.${Le}`);e.classList.contains("expanded")?e.classList.remove("expanded"):e.classList.add("expanded")}(),"TRACK_EVENT"===s){const{eventName:e,data:t}=i.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}=i.data,s={action:e,searchQueryId:t};if(!["function","callback"].includes(e.type))return void console.error("Invalid action type",e);if(window.__bfCallbacks=window.__bfCallbacks||{},window.__bfCallbacks[e.id])return void window.__bfCallbacks[e.id](o,a,s);const l=`${n}/api/searchWidgets.callback.codeblocks?apiKey=${r}&codeblockId=${e.id}`,d=document.createElement("script");d.src=l,document.head.appendChild(d),d.onload=()=>{window.__bfCallbacks[e.id](o,a,s),setTimeout(()=>{document.head.removeChild(d)},300)}}if("CLIENT_EXECUTION"===s){const{actionKey:t,inputs:n,messageId:r}=i.data,a=yield Ze(t,n);null==(o=e.contentWindow)||o.postMessage({type:"CLIENT_EXECUTION_RESULT",messageId:r,result:a},"*")}}}),{signal:o})}function Qe(e,t,n){let r;const i=()=>{(t=>{var r;const i={type:"UPDATE_BODY_CLASS",isMobile:t};null==(r=e.contentWindow)||r.postMessage(i,"*"),t&&(n.isWidgetOpen?n.hideTriggerButton():n.showTriggerButton())})(document.body.clientWidth<=576)},o=()=>{r&&clearTimeout(r),r=window.setTimeout(i,300)};i(),(()=>{const e=new ResizeObserver(o);e.observe(document.body),t.addEventListener("abort",()=>e.disconnect())})()}const et=new Set;function tt(e,t,{isButtonHidden:n,triggerButtonIcon:r}){const i=document.createDocumentFragment();let o;if(n)o=De.initialize({isButtonHidden:n,widgetType:g.Popup,widgetKey:e});else{const{button:t,icon:n}=function(e,t){const n=Ue("button",He,{id:`trigger-button-${e}`,"aria-controls":Le,"aria-expanded":"false","data-name":He}),r=Ue("div","trigger-button-icon",{"aria-hidden":"true"});return r.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" height="32" width="32" 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(r),{button:n,icon:r}}(e,r);i.appendChild(t),o=De.initialize({button:t,icon:n,widgetType:g.Popup,widgetKey:e})}const{iframeContainer:a,iframe:s}=Je({widgetUrl:t,widgetType:g.Popup});return i.appendChild(a),{fragment:i,iframe:s,stateManager:o}}const nt=({config:e,widgetUrl:t,apiHost:n,widgetHost:r,widgetKey:i})=>{const{settings:o}=e,a=null==o?void 0:o.hideTriggerButton,s=null==o?void 0:o.triggerButtonIcon;try{if(function(e){return et.has(e)}(i))return;if(function(e){return!!document.getElementById(`trigger-button-${e}`)}(i))return;Ke(e);const{fragment:o,iframe:l,stateManager:d}=tt(i,t,{isButtonHidden:a||!1,triggerButtonIcon:s||""}),u=new AbortController,{signal:c}=u;l.onload=()=>{setTimeout(()=>{Ye(l,c),Xe(l,{widgetHost:r,apiHost:n,widgetKey:i,widgetType:g.Popup,signal:c,stateManager:d}),Qe(l,c,d)},0)},document.body.appendChild(o),et.add(i);const f=()=>{u.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,i)}};const rt=({config:e,widgetUrl:t,apiHost:n,widgetHost:r,widgetKey:i})=>{const{settings:o}=e;let a=De.getInstance(i);const s=new AbortController,l=function({widgetKey:e,settings:t}){const n=document.querySelector("brainfish-search-widget");if(!n)return;n.setAttribute("data-widget-key",e),n.setAttribute("tabindex","0");const r=(null==t?void 0:t.placeholder)||"Ask your question here...";return n.setAttribute("data-placeholder",r),n.setAttribute("aria-label",`${r} - Click to open search`),n.setAttribute("role","button"),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-haspopup","dialog"),n}({widgetKey:i,settings:o});if(l){Ke(e);try{if(!function(e){return!!document.querySelector(`.${Fe}[data-widget-key="${e}"]`)}(i)){const e=document.createDocumentFragment();a||(a=De.initialize({isButtonHidden:!0,widgetType:g.Searchbar,widgetKey:i}));const{iframeContainer:o,iframe:l}=Je({widgetUrl:t,widgetType:g.Searchbar,props:{"data-widget-type":"searchbar","data-widget-key":i}}),{signal:d}=s;l.onload=()=>{setTimeout(()=>{Ye(l,d),Xe(l,{widgetHost:r,apiHost:n,widgetKey:i,widgetType:g.Searchbar,signal:d,stateManager:a}),Qe(l,d,a)},0)},e.appendChild(o),document.body.appendChild(e)}const e=()=>{if(document.body.clientWidth>=962){const e=Ue("div","bf-search-bar-iframe-backdrop");e.onclick=()=>{e.remove(),null==a||a.closeWidget()},document.body.appendChild(e)}Re.closeCurrentlyOpenWidget(),null==a||a.openWidget({newConversation:!0})};l.onclick=()=>{e()},l.onfocus=()=>{e()};const o=()=>{s.abort(),window.removeEventListener("beforeunload",o)};return void window.addEventListener("beforeunload",o)}catch(d){!function(e,t,n){w(e,t,t.message,n)}(n,d,i)}}},it=(e,t)=>{var n,r,i;const o=C(e.overrides),a=(null==(s=e.overrides)?void 0:s.widgetHost)||"https://agent.brainfi.sh";var s;const{theme:l,settings:d}=t,u=O(JSON.stringify(null==(n=e.overrides)?void 0:n.redirectRules)),c={theme:O(JSON.stringify(l)),settings:O(JSON.stringify(d)),redirectRules:u};(null==(r=e.overrides)?void 0:r.regions)&&(c.regions=O(JSON.stringify(null==(i=e.overrides)?void 0:i.regions)));const f=`${a}/?widgetKey=${e.widgetKey}#${new URLSearchParams(c).toString()}`;"Search"===t.widgetType?rt({config:t,widgetUrl:f,apiHost:o,widgetHost:a,widgetKey:e.widgetKey}):nt({config:t,widgetUrl:f,apiHost:o,widgetHost:a,widgetKey:e.widgetKey})};var ot=(e=>(e.FRESHCHAT="freshchat",e.INTERCOM="intercom",e.ZENDESK="zendesk",e.HELPSCOUT="helpscout",e))(ot||{});const at=e=>u(null,null,function*(){if(e.widgetType===g.Popup){const e=window.fcWidget?ot.FRESHCHAT:null;e&&e===ot.FRESHCHAT&&(yield u(null,null,function*(){window.fcWidget||(yield new Promise(e=>setTimeout(e,100))),window.fcWidget.hide(),window.fcWidget.on("widget:closed",()=>{window.fcWidget.hide()})}))}}),st="brainfish-nudges",lt=(e,t)=>u(null,null,function*(){try{yield((e,t)=>u(null,null,function*(){if(document.getElementById(st))return;const n=document.createElement("script");n.id=st,n.src="https://cdn.jsdelivr.net/npm/@brainfish-ai/nudge-widget@latest/dist/index.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)}))(e,t)}catch(n){w(e,n,"Failed to initialize Nudge widget",t)}});let dt,ut,ct,ft=!1;const pt=e=>{null==dt||dt.abort(),dt=new AbortController;const{signal:t}=dt;let n=window.location.pathname;const r=()=>{if(t.aborted)return;const r=window.location.pathname;r!==n&&(n=r,e())};window.addEventListener("popstate",r,{signal:t}),ft||(ut=history.pushState,ct=history.replaceState,history.pushState=function(...e){ut.apply(this,e),setTimeout(r,0)},history.replaceState=function(...e){ct.apply(this,e),setTimeout(r,0)},ft=!0),t.addEventListener("abort",()=>{ft&&(history.pushState=ut,history.replaceState=ct,ft=!1)})};let gt=null;const ht="undefined"!=typeof window&&window.Brainfish?window.Brainfish:(gt||(gt=function(){let e=[],t=null;function n(n,r){if(t){const e=n.split(".");let i=t;for(let t=0;t<e.length-1;t++)i=i[e[t]];const o=i[e[e.length-1]];if("function"==typeof o)return o.apply(i,r)}else e.push([n,r])}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",[]),registerClientActionHandler:(...e)=>n("Widgets.registerClientActionHandler",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(r){for(t=r;e.length>0;){const[t,r]=e.shift();n(t,r)}}}}(),"undefined"!=typeof window&&(window.Brainfish=gt)),gt),bt=new Map,mt=new Map;let yt=!1;ht.Widgets.isReady=!1,ht.Widgets.identify=e=>{window.BrainfishAnalytics("identify",e)},ht.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)}},ht.Widgets.init=e=>u(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==(r=e.overrides)?void 0:r.analyticsApiHost)||"";var r;let i;if(e.config)i=JSON.parse((e=>{if("undefined"!=typeof window&&"function"==typeof window.atob){const t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return(new TextDecoder).decode(r)}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});i=n}let o=bt.get(e.widgetKey);o||(o=function(e,t,n,r){return u(this,null,function*(){var i,o,a,s,l,d;const u=(null==(i=e.overrides)?void 0:i.enableRecording)||(null==(o=null==t?void 0:t.settings)?void 0:o.enableRecording)||!1,c=(null==(a=e.overrides)?void 0:a.version)||(null==t?void 0:t.version);mt.set(e.widgetKey,{options:e,config:t,apiHost:n,analyticsApiHost:r});const f=[];(null==c?void 0:c.startsWith("2."))?(it(e,t),yt||(yt=!0,pt(()=>{mt.forEach(({options:e,config:t})=>{var n;const r=(null==(n=e.overrides)?void 0:n.version)||(null==t?void 0:t.version);(null==r?void 0:r.startsWith("2."))&&it(e,t)})}))):f.push(E(e,t)),f.push(_(e.widgetKey,t.trackingToken||"",n,r,u,(null==(s=null==t?void 0:t.settings)?void 0:s.recordingBlocklist)||[],null==(l=null==t?void 0:t.settings)?void 0:l._allowLocalhostRecording,null==(d=null==t?void 0:t.settings)?void 0:d._allowScreenRecording)),f.push(lt(n,e.widgetKey));const[p]=yield Promise.allSettled(f);p&&"fulfilled"===p.status&&p.value&&ht._setRealBrainfish(p.value)})}(e,i,t,n),bt.set(e.widgetKey,o)),yield o,yield at(i),ht.Widgets.isReady=!0,window.dispatchEvent(new Event("onBrainfishReady"))}),ht.Widgets.registerClientActionHandler=(e,t)=>{((e,t)=>{Ge.set(e,t)})(e,t)};exports.BrainfishAnalytics=(...e)=>{"undefined"!=typeof window&&window.BrainfishAnalytics&&window.BrainfishAnalytics(...e)},exports.default=ht;
|
|
1
|
+
"use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,a=(t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r,s=(e,t)=>{for(var n in t||(t={}))i.call(t,n)&&a(e,n,t[n]);if(r)for(var n of r(t))o.call(t,n)&&a(e,n,t[n]);return e},l=(e,r)=>t(e,n(r)),d=(e,t,n)=>a(e,"symbol"!=typeof t?t+"":t,n),c=(e,t,n)=>new Promise((r,i)=>{var o=e=>{try{s(n.next(e))}catch(t){i(t)}},a=e=>{try{s(n.throw(e))}catch(t){i(t)}},s=e=>e.done?r(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]="d53b75e6-a041-46bd-9ea8-d1a2f2252f94",e._sentryDebugIdIdentifier="sentry-dbid-d53b75e6-a041-46bd-9ea8-d1a2f2252f94")}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 r=0;r<t.length;r++)n[r]=t.charCodeAt(r);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:"41b97a88d3629c0b7d16dab72cded3212811891c"},(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),d(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,r)=>{let i=n,o={};if(t instanceof Error)try{o=JSON.parse(t.message),i+=` - ${o.message||t.message}`}catch(a){i+=` - ${t.message}`}else i+=` - ${String(t)}`;((e,t,n)=>{if(!navigator||navigator.userAgent.toLowerCase().includes("headless"))return;const r=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.15.2. ${t.message}`,stack:t.stack,cause:{message:r.message,stack:r.stack,cause:r.cause}})})})(e,new y(i,{cause:o}),r)};const v=e=>c(null,[e],function*({widgetKey:e,apiHost:t}){return function(e,t,n){return c(this,null,function*(){let r,i=0;for(;i<3;)try{const r=yield fetch(`${e}${t}`,{method:"POST",headers:{"Content-Type":"application/json","api-key":n}});if(!r.ok)throw new Error(`API call failed with status: ${r.status}`);const i=yield r.json();if(!i)throw new Error("Error loading config: empty response");return i}catch(o){if(r=o,i++,i>=3)throw w(e,o,"Error fetching config",n),r;yield new Promise(e=>setTimeout(e,500))}})}(t,"/api/searchWidgets.getConfigByKey",e)}),x=({config:e,apiKey:t,apiHost:n})=>{const r=e.settings||{};return["bodyActionButtons","footerActionButtons","nextBestActions"].forEach(e=>{r[e]&&(r[e]=r[e].map(e=>e.type===b.CALLBACK&&e.value?l(s({},e),{value:new Function(`return ${e.value}`)()}):e))}),l(s({},e),{settings:r,apiHost:n,widgetMode:e.widgetType,apiKey:t})},C=e=>(null==e?void 0:e.apiHost)||"https://app.brainfi.sh",k=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 r=document.createElement("script");r.id="brainfish-widget",r.src=e,r.type="module",r.async=!0,r.crossOrigin="anonymous",r.onload=()=>{setTimeout(()=>{const e=window.Brainfish;e?t(e):n(new Error("Failed to load Brainfish module"))},200)},r.onerror=t=>{const r=t,i={message:`Failed to load script: ${e}`,type:r.type,fileName:r.filename,lineNumber:r.lineno,columnNumber:r.colno,error:r.error?r.error.toString():"Unknown error"};n(new Error(JSON.stringify(i)))},document.head.appendChild(r)})}))(e);return{widget:t}}catch(r){w(e,r,r.message,t)}});const S=new Set,E=(e,t)=>c(null,null,function*(){const n=C(e.overrides);try{if(S.has(e.widgetKey))return;const r=yield k({apiHost:n,widgetKey:e.widgetKey,version:t.version||"latest"});if(r){const{widget:i}=r,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)}(i,o),S.add(e.widgetKey),i}}catch(r){w(n,r,r.message,e.widgetKey)}});let T=!1;const _=(e,t,n,...r)=>c(null,[e,t,n,...r],function*(e,t,n,r="",i=!1,o=[],a,s){if(t||w(n,new Error("Access key is required"),"Access key is required",e),!T)try{const l=(()=>{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)})();window.BrainfishAnalytics("init",{apiUrl:r,accessKey:t,trackScreenViews:!0,trackAttributes:!l,trackOutgoingLinks:!l,enableRecording:!l&&i,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(l){w(n,l,"Failed to initialize BrainfishAnalytics",e)}});function O(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 A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I,W={exports:{}},B={exports:{}},P={exports:{}};function M(){return I||(I=1,function(e,t){function n(e){return Math.round(255*e)}function r(e,t,r){return n(e)+","+n(t)+","+n(r)}t.__esModule=!0,t.default=void 0,t.default=function(e,t,n,i){if(void 0===i&&(i=r),0===t)return i(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)),l=0,d=0,c=0;o>=0&&o<1?(l=a,d=s):o>=1&&o<2?(l=s,d=a):o>=2&&o<3?(d=a,c=s):o>=3&&o<4?(d=s,c=a):o>=4&&o<5?(l=s,c=a):o>=5&&o<6&&(l=a,c=s);var u=n-a/2;return i(l+u,d+u,c+u)},e.exports=t.default}(P,P.exports)),P.exports}var j,H={exports:{}};function L(){return j||(j=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}(H,H.exports)),H.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(r())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,t);var a=new(e.bind.apply(e,o));return n&&i(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}}),i(n,e)},n(e)}function r(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!e})()}function i(e,t){return(i=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 r,i=t[0],o=[];for(r=1;r<t.length;r+=1)o.push(t[r]);return o.forEach(function(e){i=i.replace(/%[a-z]/,e)}),i}t.default=function(e){var t,n;function r(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 r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];n=e.call(this,s.apply(void 0,[a[t]].concat(i)))||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=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,i(t,n),r}(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 i.default(3);var t=(0,r.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(l))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(d)){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 i.default(4,t,x);return{red:parseInt(""+C[1],10),green:parseInt(""+C[2],10),blue:parseInt(""+C[3],10)}}var k=p.exec(t.substring(0,50));if(k){var S=parseInt(""+k[1],10),E=parseInt(""+k[2],10)/100,T=parseInt(""+k[3],10)/100,_="rgb("+(0,n.default)(S,E,T)+")",O=c.exec(_);if(!O)throw new i.default(4,t,_);return{red:parseInt(""+O[1],10),green:parseInt(""+O[2],10),blue:parseInt(""+O[3],10),alpha:parseFloat(""+k[4])>1?parseFloat(""+k[4])/100:parseFloat(""+k[4])}}throw new i.default(5)};var n=o(M()),r=o(L()),i=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}$/,l=/^#[a-fA-F0-9]{3}$/,d=/^#[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,r.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)}),i=n[0],o=n[1],a=n[2];return parseFloat((.2126*i+.7152*o+.0722*a).toFixed(3))};var n,r=(n=R())&&n.__esModule?n:{default:n};e.exports=t.default}(W,W.exports)),W.exports}const D=A(q());var U,J={exports:{}},Y={exports:{}};function G(){return U||(U=1,function(e,t){function n(e,t,r){return function(){var i=r.concat(Array.prototype.slice.call(arguments));return i.length>=t?e.apply(this,i):n(e,t,i)}}t.__esModule=!0,t.default=function(e){return n(e,e.length,[])},e.exports=t.default}(Y,Y.exports)),Y.exports}var Z,V={exports:{}};function X(){return Z||(Z=1,e=V,(t=V.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),V.exports;var e,t}var Q,ee,te={exports:{}},ne={exports:{}};function re(){return Q||(Q=1,e=ne,(t=ne.exports).__esModule=!0,t.default=void 0,t.default=function(e){var t,n=e.red/255,r=e.green/255,i=e.blue/255,o=Math.max(n,r,i),a=Math.min(n,r,i),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 l=o-a,d=s>.5?l/(2-o-a):l/(o+a);switch(o){case n:t=(r-i)/l+(r<i?6:0);break;case r:t=(i-n)/l+2;break;default:t=(n-r)/l+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:d,lightness:s,alpha:e.alpha}:{hue:t,saturation:d,lightness:s}},e.exports=t.default),ne.exports;var e,t}function ie(){return ee||(ee=1,function(e,t){t.__esModule=!0,t.default=function(e){return(0,r.default)((0,n.default)(e))};var n=i(R()),r=i(re());function i(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(te,te.exports)),te.exports}var oe,ae={exports:{}},se={exports:{}},le={exports:{}},de={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}(de,de.exports)),de.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()),r=o(ce()),i=o(he());function o(e){return e&&e.__esModule?e:{default:e}}function a(e){return(0,i.default)(Math.round(255*e))}function s(e,t,n){return(0,r.default)("#"+a(e)+a(t)+a(n))}t.default=function(e,t,r){return(0,n.default)(e,t,r,s)},e.exports=t.default}(le,le.exports)),le.exports}function me(){return pe||(pe=1,function(e,t){t.__esModule=!0,t.default=function(e,t,i){if("number"==typeof e&&"number"==typeof t&&"number"==typeof i)return(0,n.default)(e,t,i);if("object"==typeof e&&void 0===t&&void 0===i)return(0,n.default)(e.hue,e.saturation,e.lightness);throw new r.default(1)};var n=i(be()),r=i(z());function i(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,r.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,r.default)(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new i.default(2)};var n=o(be()),r=o(M()),i=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 ke(){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,r.default)(e)+(0,r.default)(t)+(0,r.default)(o));if("object"==typeof e&&void 0===t&&void 0===o)return(0,n.default)("#"+(0,r.default)(e.red)+(0,r.default)(e.green)+(0,r.default)(e.blue));throw new i.default(6)};var n=o(ce()),r=o(he()),i=o(z());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(Ce,Ce.exports)),Ce.exports}var Se,Ee,Te,_e={exports:{}};function Oe(){return Se||(Se=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,r.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,r.default)(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new i.default(7)};var n=o(R()),r=o(ke()),i=o(z());function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default}(_e,_e.exports)),_e.exports}function Ae(){return Ee||(Ee=1,function(e,t){t.__esModule=!0,t.default=function(e){if("object"!=typeof e)throw new a.default(8);if(d(e))return(0,o.default)(e);if(l(e))return(0,i.default)(e);if(u(e))return(0,r.default)(e);if(c(e))return(0,n.default)(e);throw new a.default(8)};var n=s(me()),r=s(ve()),i=s(ke()),o=s(Oe()),a=s(z());function s(e){return e&&e.__esModule?e:{default:e}}var l=function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)},d=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 Ie(){return Te||(Te=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=a(G()),r=a(X()),i=a(ie()),o=a(Ae());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 r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}var l=(0,n.default)(function(e,t){if("transparent"===t)return t;var n=(0,i.default)(t);return(0,o.default)(s({},n,{lightness:(0,r.default)(0,1,n.lightness-parseFloat(e))}))});t.default=l,e.exports=t.default}(J,J.exports)),J.exports}const We=A(Ie());var Be,Pe={exports:{}};function Me(){return Be||(Be=1,function(e,t){t.__esModule=!0,t.default=void 0;var n=a(G()),r=a(X()),i=a(ie()),o=a(Ae());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 r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}var l=(0,n.default)(function(e,t){if("transparent"===t)return t;var n=(0,i.default)(t);return(0,o.default)(s({},n,{lightness:(0,r.default)(0,1,n.lightness+parseFloat(e))}))});t.default=l,e.exports=t.default}(Pe,Pe.exports)),Pe.exports}const je=A(Me()),He="bf-iframe-container",Le="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 r=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}.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,.bf-search-bar-iframe-container{display:none;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}.bf-iframe-container.open,.bf-search-bar-iframe-container.open{display:block;opacity:1;transform:translateY(0);pointer-events:auto;top:env(safe-area-inset-top);left:0}@media (min-width: 576px){.bf-iframe-container,.bf-search-bar-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-search-bar-iframe-container{min-height:30px;overflow:hidden;&.open{width:100vw;height:calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));position:fixed;top:0;left:0}}.bf-iframe-container.expanded,.bf-search-bar-iframe-container.expanded{width:min(calc(448px * 1.35),calc(100vw - 16px));height:min(calc(750px * 1.35),calc(100vh - 80px))}}@media (min-width: 962px){.bf-search-bar-iframe-container.open{width:80vw;height:auto;max-height:70vh;top:50%;left:50%;transform:translateY(-50%) translate(-50%)}}@media (min-width: 1200px){.bf-search-bar-iframe-container.open{width:50vw;min-width:770px;max-width:1024px}}brainfish-search-widget .search-trigger{display:flex;align-items:center;height:100%;width:100%;min-width:200px;min-height:30px;max-height:48px;background-color:#fff;border-radius:8px;border:1px solid #ccc;box-shadow:0 2px 4px #0000001a;font-size:16px;color:#171717;padding-left:46px;cursor:text;&:after{content:attr(data-placeholder)}&:before{content:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><circle cx="112" cy="112" r="80" fill="none" stroke="%23737373" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="168.57" y1="168.57" x2="224" y2="224" fill="none" stroke="%23737373" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>');display:block;width:24px;height:24px;position:absolute;left:12px;top:50%;transform:translateY(-50%)}}.bf-search-bar-iframe-backdrop{display:block;position:fixed;top:0;left:0;width:100%;height:100%;z-index:9999;background-color:#d9d9d905;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.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 .${Le} { background: ${e}; }\n .${Le}:hover {\n background: ${r?We(.05,e):je(.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){d(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 r=document.createElement(e);return r.className=t,Object.entries(n).forEach(([e,t])=>{r.setAttribute(e,t)}),r}const Re="brainfish-search-widget";class qe{constructor(e){d(this,"button",null),d(this,"icon",null),d(this,"closeCallback",null),this.widgetType=e}setCloseCallback(e){this.closeCallback=e}get containerClass(){return this.widgetType===g.Searchbar?Fe:He}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;const r=document.querySelector(`.${this.containerClass}`),i=null==r?void 0:r.querySelector("iframe");if(e.newConversation&&(null==(t=null==i?void 0:i.contentWindow)||t.postMessage({type:"NEW_CONVERSATION"},"*")),null==(n=null==i?void 0:i.contentWindow)||n.postMessage({type:"FOCUS_SEARCH_FIELD"},"*"),null==r||r.classList.add("open"),null==r||r.setAttribute("aria-hidden","false"),document.body.clientWidth>=962&&this.widgetType===g.Searchbar&&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=document.querySelector(`.${this.containerClass}`);null==e||e.classList.remove("open"),null==e||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){var t,n;if(this.widgetType!==g.Searchbar)return;if(!this.container||!this.iframe)return;if(window.innerWidth<768)return this.container.style.removeProperty("height"),void this.iframe.style.removeProperty("height");if(document.body.clientWidth<=962?this.container.style.removeProperty("height"):this.container.style.height=`${e}px`,this.iframe.style.height=`${e}px`,0===e){const n={type:"CONSTRAINED_HEIGHT",height:e};return void(null==(t=this.iframe.contentWindow)||t.postMessage(n,"*"))}const r=.7*window.innerHeight;if(e>r){this.container.style.height=`${r}px`,this.iframe.style.height=`${r}px`;const e={type:"CONSTRAINED_HEIGHT",height:r};null==(n=this.iframe.contentWindow)||n.postMessage(e,"*")}}isMobile(){return document.body.clientWidth<=576}setupButtonClickListener(e){this.button&&this.button.addEventListener("click",e)}}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()}}d(De,"instances",new Map);class Ue{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=()=>this.openCurrentlyClosedPopupWidget(),window.Brainfish.Widgets.close=()=>this.closeCurrentlyOpenWidget())}static closeCurrentlyOpenWidget(){const e=De.getOpenInstance();e&&e.closeWidget()}static openCurrentlyClosedPopupWidget(e){const t=De.getClosedPopupInstance();if(t){const n=e?{newConversation:!0,trigger:e}:{};t.openWidget(n)}}}d(Ue,"isInitialized",!1);class Je{constructor(e,t){this.widgetType=e,this.widgetKey=t}trackOpenWidget(e){this.dispatchEvent("onBrainfishWidgetOpen"),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={}){window.BrainfishAnalytics&&window.BrainfishAnalytics("track",e,l(s({},t),{widgetKey:this.widgetKey}),{source:this.widgetType,widgetKey:this.widgetKey})}}class Ye{constructor(e,t){d(this,"state"),d(this,"domController"),d(this,"analyticsTracker"),this.state=new Ne(e,t),this.domController=new qe(t),this.domController.setCloseCallback(()=>this.closeWidget()),this.analyticsTracker=new Je(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),Ue.initialize()}toggleIframeVisibility(){this.state.toggleWidget()?this.openWidget():this.closeWidget()}openWidget(e={}){this.state.openWidget(),this.domController.openWidget(e),this.analyticsTracker.trackOpenWidget(e.trigger)}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 Ye(e.widgetKey,e.widgetType);return t.initialize(e),t}}function Ge({widgetUrl:e,widgetType:t,props:n}){const r=t===g.Searchbar?Fe:He,i=ze("div",r,s({id:r,"aria-live":"polite","aria-hidden":"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),i.appendChild(o);const l=ze("iframe","trigger-iframe",{src:e,sandbox:"allow-scripts allow-same-origin allow-popups allow-forms",allow:"clipboard-write",role:"dialog"});return l.style.opacity="0",l.addEventListener("load",()=>{o.style.display="none",l.style.opacity="1"}),l.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")}),i.appendChild(l),{iframeContainer:i,iframe:l}}function Ze(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 Ve=new Map,Xe=(e,t)=>`Error executing Client Action with key ${e}. Details: ${t instanceof Error?t.message:String(t)}`,Qe=(e,t)=>c(null,null,function*(){if(Ve.has(e)){const i=Ve.get(e);if("function"!=typeof i)return{success:!1,reason:`Client Action registered with key ${e} is not a function`};try{const e=yield i(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(r){return{success:!1,reason:Xe(e,r)}}}var n;return{success:!1,reason:`No Client Action registered with key ${e}`}});function et(e,{widgetHost:t,apiHost:n,widgetKey:r,widgetType:i,signal:o,stateManager:a}){window.addEventListener("message",i=>c(null,null,function*(){var o;if(i.origin!==t)return;const{type:s,widgetKey:l}=i.data;if(!l||l===r){if("TOGGLE_WIDGET_SIZE"===s&&function(){const e=document.querySelector(`.${He}`);e.classList.contains("expanded")?e.classList.remove("expanded"):e.classList.add("expanded")}(),"RESIZE_IFRAME"===s){const{height:e}=i.data;a.resizeContainer(e)}if("TRACK_EVENT"===s){const{eventName:e,data:t}=i.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}=i.data,s={action:e,searchQueryId:t};if(!["function","callback"].includes(e.type))return void console.error("Invalid action type",e);if(window.__bfCallbacks=window.__bfCallbacks||{},window.__bfCallbacks[e.id])return void window.__bfCallbacks[e.id](o,a,s);const l=`${n}/api/searchWidgets.callback.codeblocks?apiKey=${r}&codeblockId=${e.id}`,d=document.createElement("script");d.src=l,document.head.appendChild(d),d.onload=()=>{window.__bfCallbacks[e.id](o,a,s),setTimeout(()=>{document.head.removeChild(d)},300)}}if("CLIENT_EXECUTION"===s){const{actionKey:t,inputs:n,messageId:r}=i.data,a=yield Qe(t,n);null==(o=e.contentWindow)||o.postMessage({type:"CLIENT_EXECUTION_RESULT",messageId:r,result:a},"*")}}}),{signal:o})}function tt(e,t,n){let r;const i=()=>{(t=>{var r;const i={type:"UPDATE_BODY_CLASS",isMobile:t};null==(r=e.contentWindow)||r.postMessage(i,"*"),t&&(n.isWidgetOpen?n.hideTriggerButton():n.showTriggerButton())})(document.body.clientWidth<=576)},o=()=>{r&&clearTimeout(r),r=window.setTimeout(i,300)};i(),(()=>{const e=new ResizeObserver(o);e.observe(document.body),t.addEventListener("abort",()=>e.disconnect())})()}const nt=new Set;function rt(e,t,{isButtonHidden:n,triggerButtonIcon:r}){const i=document.createDocumentFragment();let o;if(n)o=Ye.initialize({isButtonHidden:n,widgetType:g.Popup,widgetKey:e});else{const{button:t,icon:n}=function(e,t){const n=ze("button",Le,{id:`trigger-button-${e}`,"aria-controls":He,"aria-expanded":"false","data-name":Le}),r=ze("div","trigger-button-icon",{"aria-hidden":"true"});return r.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" height="32" width="32" 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(r),{button:n,icon:r}}(e,r);i.appendChild(t),o=Ye.initialize({button:t,icon:n,widgetType:g.Popup,widgetKey:e})}const{iframeContainer:a,iframe:s}=Ge({widgetUrl:t,widgetType:g.Popup});return i.appendChild(a),{fragment:i,iframe:s,stateManager:o}}const it=({config:e,widgetUrl:t,apiHost:n,widgetHost:r,widgetKey:i})=>{const{settings:o}=e,a=null==o?void 0:o.hideTriggerButton,s=null==o?void 0:o.triggerButtonIcon;try{if(function(e){return nt.has(e)}(i))return;if(function(e){return!!document.getElementById(`trigger-button-${e}`)}(i))return;$e(e);const{fragment:o,iframe:l,stateManager:d}=rt(i,t,{isButtonHidden:a||!1,triggerButtonIcon:s||""}),c=new AbortController,{signal:u}=c;l.onload=()=>{setTimeout(()=>{Ze(l,u),et(l,{widgetHost:r,apiHost:n,widgetKey:i,widgetType:g.Popup,signal:u,stateManager:d}),tt(l,u,d)},0)},document.body.appendChild(o),nt.add(i);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,i)}};const ot=({config:e,widgetUrl:t,apiHost:n,widgetHost:r,widgetKey:i})=>{const{settings:o}=e;let a=Ye.getInstance(i);const s=new AbortController,l=function({widgetKey:e,settings:t}){var n;const r=document.querySelector(Re);if(!r)return;if("absolute"===(null==(n=r.computedStyleMap().get("position"))?void 0:n.toString())){const e=r.offsetWidth,t=r.offsetHeight;if(0===e||0===t)return void console.warn("Brainfish: Search bar is absolute positioned but has no width or height");if(e<200||t<30)return void console.warn("Brainfish: Search bar is too small")}const i=ze("div","search-trigger");r.appendChild(i),i.setAttribute("data-widget-key",e),i.setAttribute("tabindex","0");const o=(null==t?void 0:t.placeholder)||"Ask your question here...";return i.setAttribute("data-placeholder",o),i.setAttribute("aria-label",`${o} - Click to open search`),i.setAttribute("role","button"),i.setAttribute("aria-expanded","false"),i.setAttribute("aria-haspopup","dialog"),i}({widgetKey:i,settings:o});if(l){$e(e);try{if(!function(e){return!!document.querySelector(`.${Fe}[data-widget-key="${e}"]`)}(i)){const e=document.createDocumentFragment();a||(a=Ye.initialize({isButtonHidden:!0,widgetType:g.Searchbar,widgetKey:i}));const{iframeContainer:o,iframe:l}=Ge({widgetUrl:t,widgetType:g.Searchbar,props:{"data-widget-type":"searchbar","data-widget-key":i}}),{signal:d}=s;l.onload=()=>{setTimeout(()=>{Ze(l,d),et(l,{widgetHost:r,apiHost:n,widgetKey:i,widgetType:g.Searchbar,signal:d,stateManager:a}),tt(l,d,a)},0)},e.appendChild(o),document.body.appendChild(e)}const e=()=>{Ue.closeCurrentlyOpenWidget(),null==a||a.openWidget({newConversation:!0})};l.onclick=()=>{e()},l.onfocus=()=>{e()};const o=()=>{s.abort(),window.removeEventListener("beforeunload",o)};return void window.addEventListener("beforeunload",o)}catch(d){!function(e,t,n){w(e,t,t.message,n)}(n,d,i)}}},at=(e,t)=>{var n,r,i;const o=C(e.overrides),a=(null==(s=e.overrides)?void 0:s.widgetHost)||"https://agent.brainfi.sh";var s;const{theme:l,settings:d}=t,c=O(JSON.stringify(null==(n=e.overrides)?void 0:n.redirectRules)),u={theme:O(JSON.stringify(l)),settings:O(JSON.stringify(d)),redirectRules:c};(null==(r=e.overrides)?void 0:r.regions)&&(u.regions=O(JSON.stringify(null==(i=e.overrides)?void 0:i.regions)));const f=`${a}/?widgetKey=${e.widgetKey}#${new URLSearchParams(u).toString()}`;"Search"===t.widgetType?ot({config:t,widgetUrl:f,apiHost:o,widgetHost:a,widgetKey:e.widgetKey}):it({config:t,widgetUrl:f,apiHost:o,widgetHost:a,widgetKey:e.widgetKey})};var st=(e=>(e.FRESHCHAT="freshchat",e.INTERCOM="intercom",e.ZENDESK="zendesk",e.HELPSCOUT="helpscout",e))(st||{});const lt=e=>c(null,null,function*(){if(e.widgetType===g.Popup){const e=window.fcWidget?st.FRESHCHAT:null;e&&e===st.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()})}))}}),dt="brainfish-nudges",ct=(e,t)=>c(null,null,function*(){try{yield((e,t)=>c(null,null,function*(){if(document.getElementById(dt))return;const n=document.createElement("script");n.id=dt,n.src="https://cdn.jsdelivr.net/npm/@brainfish-ai/nudge-widget@latest/dist/index.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)}))(e,t)}catch(n){w(e,n,"Failed to initialize Nudge widget",t)}});let ut,ft,pt,gt=!1;const ht=e=>{null==ut||ut.abort(),ut=new AbortController;const{signal:t}=ut;let n=window.location.pathname;const r=()=>{if(t.aborted)return;const r=window.location.pathname;r!==n&&(n=r,e())};window.addEventListener("popstate",r,{signal:t}),gt||(ft=history.pushState,pt=history.replaceState,history.pushState=function(...e){ft.apply(this,e),setTimeout(r,0)},history.replaceState=function(...e){pt.apply(this,e),setTimeout(r,0)},gt=!0),t.addEventListener("abort",()=>{gt&&(history.pushState=ft,history.replaceState=pt,gt=!1)})};let bt=null;const mt="undefined"!=typeof window&&window.Brainfish?window.Brainfish:(bt||(bt=function(){let e=[],t=null;function n(n,r){if(t){const e=n.split(".");let i=t;for(let t=0;t<e.length-1;t++)i=i[e[t]];const o=i[e[e.length-1]];if("function"==typeof o)return o.apply(i,r)}else e.push([n,r])}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",[]),registerClientActionHandler:(...e)=>n("Widgets.registerClientActionHandler",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(r){for(t=r;e.length>0;){const[t,r]=e.shift();n(t,r)}}}}(),"undefined"!=typeof window&&(window.Brainfish=bt)),bt),yt=new Map,wt=new Map;let vt=!1;mt.Widgets.isReady=!1,mt.Widgets.identify=e=>{window.BrainfishAnalytics("identify",e)},mt.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)}},mt.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==(r=e.overrides)?void 0:r.analyticsApiHost)||"";var r;let i;if(e.config)i=JSON.parse((e=>{if("undefined"!=typeof window&&"function"==typeof window.atob){const t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return(new TextDecoder).decode(r)}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});i=n}let o=yt.get(e.widgetKey);o||(o=function(e,t,n,r){return c(this,null,function*(){var i,o,a,s,l,d;const c=(null==(i=e.overrides)?void 0:i.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);wt.set(e.widgetKey,{options:e,config:t,apiHost:n,analyticsApiHost:r});const f=[];(null==u?void 0:u.startsWith("2."))?(at(e,t),vt||(vt=!0,ht(()=>{wt.forEach(({options:e,config:t})=>{var n;const r=(null==(n=e.overrides)?void 0:n.version)||(null==t?void 0:t.version);(null==r?void 0:r.startsWith("2."))&&at(e,t)})}))):f.push(E(e,t)),f.push(_(e.widgetKey,t.trackingToken||"",n,r,c,(null==(s=null==t?void 0:t.settings)?void 0:s.recordingBlocklist)||[],null==(l=null==t?void 0:t.settings)?void 0:l._allowLocalhostRecording,null==(d=null==t?void 0:t.settings)?void 0:d._allowScreenRecording)),f.push(ct(n,e.widgetKey));const[p]=yield Promise.allSettled(f);p&&"fulfilled"===p.status&&p.value&&mt._setRealBrainfish(p.value)})}(e,i,t,n),yt.set(e.widgetKey,o)),yield o,yield lt(i),mt.Widgets.isReady=!0,window.dispatchEvent(new Event("onBrainfishReady"))}),mt.Widgets.registerClientActionHandler=(e,t)=>{((e,t)=>{Ve.set(e,t)})(e,t)};exports.BrainfishAnalytics=(...e)=>{"undefined"!=typeof window&&window.BrainfishAnalytics&&window.BrainfishAnalytics(...e)},exports.default=mt;
|
|
2
2
|
//# sourceMappingURL=web.cjs.js.map
|
package/dist/web.js
CHANGED
|
@@ -42,7 +42,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
42
42
|
!function() {
|
|
43
43
|
try {
|
|
44
44
|
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
45
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "
|
|
45
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "71b7533f-bb0a-423b-9e05-092d7e7415fc", e._sentryDebugIdIdentifier = "sentry-dbid-71b7533f-bb0a-423b-9e05-092d7e7415fc");
|
|
46
46
|
} catch (e2) {
|
|
47
47
|
}
|
|
48
48
|
}();
|
|
@@ -113,7 +113,7 @@ function decodeProtectedHeader(token) {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
var _global = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : {};
|
|
116
|
-
_global.SENTRY_RELEASE = { id: "
|
|
116
|
+
_global.SENTRY_RELEASE = { id: "41b97a88d3629c0b7d16dab72cded3212811891c" };
|
|
117
117
|
var WidgetType;
|
|
118
118
|
(function(WidgetType2) {
|
|
119
119
|
WidgetType2["Sidebar"] = "sidebar";
|
|
@@ -171,7 +171,7 @@ const sendErrors = (apiHost, error, widgetKey) => {
|
|
|
171
171
|
"api-key": widgetKey
|
|
172
172
|
},
|
|
173
173
|
body: JSON.stringify({
|
|
174
|
-
error: `WebWidgetVersion: ${"1.15.
|
|
174
|
+
error: `WebWidgetVersion: ${"1.15.2"}. ${error.message}`,
|
|
175
175
|
stack: error.stack,
|
|
176
176
|
cause: {
|
|
177
177
|
message: errorData.message,
|
|
@@ -543,7 +543,7 @@ const base64Decode = (text) => {
|
|
|
543
543
|
}
|
|
544
544
|
throw new Error("[utils.base64Decode]: Unsupported environment");
|
|
545
545
|
};
|
|
546
|
-
const styles = `.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}.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)}.bf-iframe-container,.bf-search-bar-iframe-container{display:none;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}.bf-iframe-container.open,.bf-search-bar-iframe-container.open{display:block;opacity:1;transform:translateY(0);pointer-events:auto;top:env(safe-area-inset-top);left:0}@media (min-width: 576px){.bf-iframe-container,.bf-search-bar-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-search-bar-iframe-container
|
|
546
|
+
const styles = `.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}.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,.bf-search-bar-iframe-container{display:none;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}.bf-iframe-container.open,.bf-search-bar-iframe-container.open{display:block;opacity:1;transform:translateY(0);pointer-events:auto;top:env(safe-area-inset-top);left:0}@media (min-width: 576px){.bf-iframe-container,.bf-search-bar-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-search-bar-iframe-container{min-height:30px;overflow:hidden;&.open{width:100vw;height:calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));position:fixed;top:0;left:0}}.bf-iframe-container.expanded,.bf-search-bar-iframe-container.expanded{width:min(calc(448px * 1.35),calc(100vw - 16px));height:min(calc(750px * 1.35),calc(100vh - 80px))}}@media (min-width: 962px){.bf-search-bar-iframe-container.open{width:80vw;height:auto;max-height:70vh;top:50%;left:50%;transform:translateY(-50%) translate(-50%)}}@media (min-width: 1200px){.bf-search-bar-iframe-container.open{width:50vw;min-width:770px;max-width:1024px}}brainfish-search-widget .search-trigger{display:flex;align-items:center;height:100%;width:100%;min-width:200px;min-height:30px;max-height:48px;background-color:#fff;border-radius:8px;border:1px solid #ccc;box-shadow:0 2px 4px #0000001a;font-size:16px;color:#171717;padding-left:46px;cursor:text;&:after{content:attr(data-placeholder)}&:before{content:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><circle cx="112" cy="112" r="80" fill="none" stroke="%23737373" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/><line x1="168.57" y1="168.57" x2="224" y2="224" fill="none" stroke="%23737373" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>');display:block;width:24px;height:24px;position:absolute;left:12px;top:50%;transform:translateY(-50%)}}.bf-search-bar-iframe-backdrop{display:block;position:fixed;top:0;left:0;width:100%;height:100%;z-index:9999;background-color:#d9d9d905;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.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)}`;
|
|
547
547
|
function getDefaultExportFromCjs(x) {
|
|
548
548
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
549
549
|
}
|
|
@@ -1571,16 +1571,44 @@ class WidgetState {
|
|
|
1571
1571
|
}
|
|
1572
1572
|
}
|
|
1573
1573
|
const MOBILE_BREAKPOINT = 576;
|
|
1574
|
+
const TABLET_BREAKPOINT = 768;
|
|
1574
1575
|
const DESKTOP_BREAKPOINT = 962;
|
|
1576
|
+
function createElementWithClass(tagName, className, attributes = {}) {
|
|
1577
|
+
const element = document.createElement(tagName);
|
|
1578
|
+
element.className = className;
|
|
1579
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
|
1580
|
+
element.setAttribute(key, value);
|
|
1581
|
+
});
|
|
1582
|
+
return element;
|
|
1583
|
+
}
|
|
1584
|
+
const SEARCH_BAR_SELECTOR = "brainfish-search-widget";
|
|
1575
1585
|
class WidgetDOMController {
|
|
1576
1586
|
constructor(widgetType) {
|
|
1577
1587
|
__publicField(this, "button", null);
|
|
1578
1588
|
__publicField(this, "icon", null);
|
|
1589
|
+
__publicField(this, "closeCallback", null);
|
|
1579
1590
|
this.widgetType = widgetType;
|
|
1580
1591
|
}
|
|
1592
|
+
setCloseCallback(callback) {
|
|
1593
|
+
this.closeCallback = callback;
|
|
1594
|
+
}
|
|
1581
1595
|
get containerClass() {
|
|
1582
1596
|
return this.widgetType === WidgetType.Searchbar ? SEARCH_BAR_IFRAME_CONTAINER_CLASS : IFRAME_CONTAINER_CLASS;
|
|
1583
1597
|
}
|
|
1598
|
+
get container() {
|
|
1599
|
+
return document.querySelector(
|
|
1600
|
+
`.${this.containerClass}`
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
get iframe() {
|
|
1604
|
+
var _a;
|
|
1605
|
+
return (_a = this.container) == null ? void 0 : _a.querySelector("iframe");
|
|
1606
|
+
}
|
|
1607
|
+
get backdrop() {
|
|
1608
|
+
return document.querySelector(
|
|
1609
|
+
`.${SEARCH_BAR_IFRAME_BACKDROP_CLASS}`
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1584
1612
|
setElements(button, icon) {
|
|
1585
1613
|
this.button = button || null;
|
|
1586
1614
|
this.icon = icon || null;
|
|
@@ -1595,12 +1623,45 @@ class WidgetDOMController {
|
|
|
1595
1623
|
(_b = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _b.postMessage({ type: "FOCUS_SEARCH_FIELD" }, "*");
|
|
1596
1624
|
iframeContainer == null ? void 0 : iframeContainer.classList.add("open");
|
|
1597
1625
|
iframeContainer == null ? void 0 : iframeContainer.setAttribute("aria-hidden", "false");
|
|
1626
|
+
if (document.body.clientWidth >= DESKTOP_BREAKPOINT && this.widgetType === WidgetType.Searchbar && this.backdrop === null) {
|
|
1627
|
+
const backdrop = createElementWithClass(
|
|
1628
|
+
"div",
|
|
1629
|
+
SEARCH_BAR_IFRAME_BACKDROP_CLASS
|
|
1630
|
+
);
|
|
1631
|
+
if (this.closeCallback) {
|
|
1632
|
+
backdrop.addEventListener("click", this.closeCallback);
|
|
1633
|
+
}
|
|
1634
|
+
document.body.appendChild(backdrop);
|
|
1635
|
+
}
|
|
1598
1636
|
this.updateButtonForOpen();
|
|
1599
1637
|
}
|
|
1638
|
+
focusNextElement() {
|
|
1639
|
+
const searchInput = document.querySelector(
|
|
1640
|
+
SEARCH_BAR_SELECTOR
|
|
1641
|
+
);
|
|
1642
|
+
if (searchInput) {
|
|
1643
|
+
const focusableElements = Array.from(
|
|
1644
|
+
document.querySelectorAll(
|
|
1645
|
+
'a, button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'
|
|
1646
|
+
)
|
|
1647
|
+
).filter((el) => !el.hasAttribute("disabled"));
|
|
1648
|
+
const currentIndex = focusableElements.indexOf(searchInput);
|
|
1649
|
+
if (currentIndex !== -1) {
|
|
1650
|
+
const nextElement = focusableElements[currentIndex + 1];
|
|
1651
|
+
if (nextElement) {
|
|
1652
|
+
nextElement.focus();
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1600
1657
|
closeWidget() {
|
|
1601
1658
|
const iframeContainer = document.querySelector(`.${this.containerClass}`);
|
|
1602
1659
|
iframeContainer == null ? void 0 : iframeContainer.classList.remove("open");
|
|
1603
1660
|
iframeContainer == null ? void 0 : iframeContainer.setAttribute("aria-hidden", "true");
|
|
1661
|
+
if (this.backdrop) {
|
|
1662
|
+
this.backdrop.remove();
|
|
1663
|
+
this.focusNextElement();
|
|
1664
|
+
}
|
|
1604
1665
|
this.updateButtonForClose();
|
|
1605
1666
|
}
|
|
1606
1667
|
updateButtonForOpen() {
|
|
@@ -1633,6 +1694,36 @@ class WidgetDOMController {
|
|
|
1633
1694
|
var _a;
|
|
1634
1695
|
(_a = this.button) == null ? void 0 : _a.classList.add("hidden");
|
|
1635
1696
|
}
|
|
1697
|
+
resizeContainer(height) {
|
|
1698
|
+
var _a, _b;
|
|
1699
|
+
if (this.widgetType !== WidgetType.Searchbar) {
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
if (!this.container || !this.iframe) return;
|
|
1703
|
+
if (window.innerWidth < TABLET_BREAKPOINT) {
|
|
1704
|
+
this.container.style.removeProperty("height");
|
|
1705
|
+
this.iframe.style.removeProperty("height");
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
if (document.body.clientWidth <= DESKTOP_BREAKPOINT) {
|
|
1709
|
+
this.container.style.removeProperty("height");
|
|
1710
|
+
} else {
|
|
1711
|
+
this.container.style.height = `${height}px`;
|
|
1712
|
+
}
|
|
1713
|
+
this.iframe.style.height = `${height}px`;
|
|
1714
|
+
if (height === 0) {
|
|
1715
|
+
const message = { type: "CONSTRAINED_HEIGHT", height };
|
|
1716
|
+
(_a = this.iframe.contentWindow) == null ? void 0 : _a.postMessage(message, "*");
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
const maxHeight = window.innerHeight * 0.7;
|
|
1720
|
+
if (height > maxHeight) {
|
|
1721
|
+
this.container.style.height = `${maxHeight}px`;
|
|
1722
|
+
this.iframe.style.height = `${maxHeight}px`;
|
|
1723
|
+
const message = { type: "CONSTRAINED_HEIGHT", height: maxHeight };
|
|
1724
|
+
(_b = this.iframe.contentWindow) == null ? void 0 : _b.postMessage(message, "*");
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1636
1727
|
isMobile() {
|
|
1637
1728
|
return document.body.clientWidth <= MOBILE_BREAKPOINT;
|
|
1638
1729
|
}
|
|
@@ -1745,6 +1836,7 @@ class IframeStateManager {
|
|
|
1745
1836
|
__publicField(this, "analyticsTracker");
|
|
1746
1837
|
this.state = new WidgetState(widgetKey, widgetType);
|
|
1747
1838
|
this.domController = new WidgetDOMController(widgetType);
|
|
1839
|
+
this.domController.setCloseCallback(() => this.closeWidget());
|
|
1748
1840
|
this.analyticsTracker = new AnalyticsTracker(widgetType, widgetKey);
|
|
1749
1841
|
}
|
|
1750
1842
|
static getInstance(widgetKey) {
|
|
@@ -1798,6 +1890,9 @@ class IframeStateManager {
|
|
|
1798
1890
|
hideTriggerButton() {
|
|
1799
1891
|
this.domController.hideTriggerButton();
|
|
1800
1892
|
}
|
|
1893
|
+
resizeContainer(height) {
|
|
1894
|
+
this.domController.resizeContainer(height);
|
|
1895
|
+
}
|
|
1801
1896
|
trackCustomEvent(eventName, data = {}) {
|
|
1802
1897
|
this.analyticsTracker.trackCustomEvent(eventName, data);
|
|
1803
1898
|
}
|
|
@@ -1811,14 +1906,6 @@ class IframeStateManager {
|
|
|
1811
1906
|
return instance;
|
|
1812
1907
|
}
|
|
1813
1908
|
}
|
|
1814
|
-
function createElementWithClass(tagName, className, attributes = {}) {
|
|
1815
|
-
const element = document.createElement(tagName);
|
|
1816
|
-
element.className = className;
|
|
1817
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
1818
|
-
element.setAttribute(key, value);
|
|
1819
|
-
});
|
|
1820
|
-
return element;
|
|
1821
|
-
}
|
|
1822
1909
|
function createTriggerButton(widgetKey, triggerButtonIcon) {
|
|
1823
1910
|
const button = createElementWithClass("button", TRIGGER_BUTTON_CLASS, {
|
|
1824
1911
|
id: `trigger-button-${widgetKey}`,
|
|
@@ -1978,6 +2065,10 @@ function initMessageListener(iframe, {
|
|
|
1978
2065
|
if (type === "TOGGLE_WIDGET_SIZE") {
|
|
1979
2066
|
toggleIframeSize();
|
|
1980
2067
|
}
|
|
2068
|
+
if (type === "RESIZE_IFRAME") {
|
|
2069
|
+
const { height } = event.data;
|
|
2070
|
+
stateManager.resizeContainer(height);
|
|
2071
|
+
}
|
|
1981
2072
|
if (type === "TRACK_EVENT") {
|
|
1982
2073
|
const { eventName, data } = event.data;
|
|
1983
2074
|
stateManager.trackCustomEvent(eventName, data);
|
|
@@ -2135,19 +2226,35 @@ const initWidgetButton = ({ config, widgetUrl, apiHost, widgetHost, widgetKey })
|
|
|
2135
2226
|
handleInitializationError$1(apiHost, error, widgetKey);
|
|
2136
2227
|
}
|
|
2137
2228
|
};
|
|
2138
|
-
const SEARCH_BAR_SELECTOR = "brainfish-search-widget";
|
|
2139
2229
|
function createSearchTrigger({ widgetKey, settings }) {
|
|
2230
|
+
var _a;
|
|
2140
2231
|
const searchBar = document.querySelector(SEARCH_BAR_SELECTOR);
|
|
2141
2232
|
if (!searchBar) return void 0;
|
|
2142
|
-
searchBar.
|
|
2143
|
-
|
|
2233
|
+
const computedStyle = searchBar.computedStyleMap();
|
|
2234
|
+
const isAbsolutePositioned = ((_a = computedStyle.get("position")) == null ? void 0 : _a.toString()) === "absolute";
|
|
2235
|
+
if (isAbsolutePositioned) {
|
|
2236
|
+
const width = searchBar.offsetWidth;
|
|
2237
|
+
const height = searchBar.offsetHeight;
|
|
2238
|
+
if (width === 0 || height === 0) {
|
|
2239
|
+
console.warn("Brainfish: Search bar is absolute positioned but has no width or height");
|
|
2240
|
+
return void 0;
|
|
2241
|
+
}
|
|
2242
|
+
if (width < 200 || height < 30) {
|
|
2243
|
+
console.warn("Brainfish: Search bar is too small");
|
|
2244
|
+
return void 0;
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
const trigger = createElementWithClass("div", "search-trigger");
|
|
2248
|
+
searchBar.appendChild(trigger);
|
|
2249
|
+
trigger.setAttribute("data-widget-key", widgetKey);
|
|
2250
|
+
trigger.setAttribute("tabindex", "0");
|
|
2144
2251
|
const placeholderText = (settings == null ? void 0 : settings.placeholder) || "Ask your question here...";
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
return
|
|
2252
|
+
trigger.setAttribute("data-placeholder", placeholderText);
|
|
2253
|
+
trigger.setAttribute("aria-label", `${placeholderText} - Click to open search`);
|
|
2254
|
+
trigger.setAttribute("role", "button");
|
|
2255
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
2256
|
+
trigger.setAttribute("aria-haspopup", "dialog");
|
|
2257
|
+
return trigger;
|
|
2151
2258
|
}
|
|
2152
2259
|
function handleInitializationError(apiHost, error, widgetKey) {
|
|
2153
2260
|
sendBrainfishWidgetError(apiHost, error, error.message, widgetKey);
|
|
@@ -2199,14 +2306,6 @@ const initSearchBar = ({ config, widgetUrl, apiHost, widgetHost, widgetKey }) =>
|
|
|
2199
2306
|
document.body.appendChild(fragment);
|
|
2200
2307
|
}
|
|
2201
2308
|
const displaySearchBar = () => {
|
|
2202
|
-
if (document.body.clientWidth >= DESKTOP_BREAKPOINT) {
|
|
2203
|
-
const backdrop = createElementWithClass("div", SEARCH_BAR_IFRAME_BACKDROP_CLASS);
|
|
2204
|
-
backdrop.onclick = () => {
|
|
2205
|
-
backdrop.remove();
|
|
2206
|
-
stateManager == null ? void 0 : stateManager.closeWidget();
|
|
2207
|
-
};
|
|
2208
|
-
document.body.appendChild(backdrop);
|
|
2209
|
-
}
|
|
2210
2309
|
WidgetGlobalAPI.closeCurrentlyOpenWidget();
|
|
2211
2310
|
stateManager == null ? void 0 : stateManager.openWidget({ newConversation: true });
|
|
2212
2311
|
};
|