@cimulate/copilot-widget 1.30.7 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@
7
7
  `);return u===-1?"":s.stack.slice(u+1)})();try{if(!r.stack)r.stack=a;else if(a){const u=a.indexOf(`
8
8
  `),c=u===-1?-1:a.indexOf(`
9
9
  `,u+1),d=c===-1?"":a.slice(c+1);String(r.stack).endsWith(d)||(r.stack+=`
10
- `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ns(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:a}=n;r!==void 0&&ll.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean),legacyInterceptorReqResOrdering:hn.transitional(hn.boolean),advertiseZstdAcceptEncoding:hn.transitional(hn.boolean),validateStatusUndefinedResolves:hn.transitional(hn.boolean)},!1),s!=null&&($.isFunction(s)?n.paramsSerializer={serialize:s}:ll.assertOptions(s,{encode:hn.function,serialize:hn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ll.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&$.merge(a.common,a[n.method]);a&&$.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete a[_]}),n.headers=fn.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(A){if(typeof A.runWhen=="function"&&A.runWhen(n)===!1)return;d=d&&A.synchronous;const v=n.transitional||cf;v&&v.legacyInterceptorReqResOrdering?c.unshift(A.fulfilled,A.rejected):c.push(A.fulfilled,A.rejected)});const f=[];this.interceptors.response.forEach(function(A){f.push(A.fulfilled,A.rejected)});let p,m=0,b;if(!d){const _=[Ig.bind(this),void 0];for(_.unshift(...c),_.push(...f),b=_.length,p=Promise.resolve(n);m<b;)p=p.then(_[m++],_[m++]);return p}b=c.length;let y=n;for(;m<b;){const _=c[m++],A=c[m++];try{y=_(y)}catch(v){A.call(this,v);break}}try{p=Ig.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,b=f.length;m<b;)p=p.then(f[m++],f[m++]);return p}getUri(t){t=ns(this.defaults,t);const n=Sg(t.baseURL,t.url,t.allowAbsoluteUrls,t);return fg(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){rs.prototype[t]=function(n,r){return this.request(ns(r||{},{method:t,url:n,data:r&&$.hasOwnProp(r,"data")?r.data:void 0}))}}),$.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(ns(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}rs.prototype[t]=n(),t!=="query"&&(rs.prototype[t+"Form"]=n(!0))});let ev=class R2{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(s=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](s);r._listeners=null}),this.promise.then=s=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(s);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new fa(a,u,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new R2(function(s){t=s}),cancel:t}}};function tv(e){return function(n){return e.apply(null,n)}}function nv(e){return $.isObject(e)&&e.isAxiosError===!0}const Ef={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ef).forEach(([e,t])=>{Ef[t]=e});function Lg(e){const t=new rs(e),n=X0(rs.prototype.request,t);return $.extend(n,rs.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Lg(ns(e,s))},n}const Rt=Lg(da);Rt.Axios=rs,Rt.CanceledError=fa,Rt.CancelToken=ev,Rt.isCancel=Eg,Rt.VERSION=pf,Rt.toFormData=il,Rt.AxiosError=be,Rt.Cancel=Rt.CanceledError,Rt.all=function(t){return Promise.all(t)},Rt.spread=tv,Rt.isAxiosError=nv,Rt.mergeConfig=ns,Rt.AxiosHeaders=fn,Rt.formToJSON=e=>gg($.isHTMLForm(e)?new FormData(e):e),Rt.getAdapter=Og.getAdapter,Rt.HttpStatusCode=Ef,Rt.default=Rt;const{Axios:D7,AxiosError:M7,CanceledError:F7,isCancel:B7,CancelToken:U7,VERSION:H7,all:z7,Cancel:j7,isAxiosError:$7,spread:V7,toFormData:q7,AxiosHeaders:Y7,HttpStatusCode:G7,formToJSON:W7,getAdapter:X7,mergeConfig:K7,create:Q7}=Rt;class rv{constructor(t,n,r,s=!1,a,u){Se(this,"CIMULATE_API_HEADER","x-cimulate-api-key");Se(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");Se(this,"CIMULATE_SEARCH_API_PATH","api/v1");Se(this,"baseApiUrl");Se(this,"headers",{});Se(this,"fetchConfig",()=>Ke(this,null,function*(){try{const t=yield Rt.get(`${this.apiUrl}/configs/copilot`,{headers:this.headers}),{customer_config:n}=t.data,r=atob(n);return JSON.parse(r)}catch(t){throw console.error("Error fetching customer config:",t),t}}));Se(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const s=new URL(t);return s.hostname=s.hostname.replace(/^copilot\./,"api."),s.origin}return n?`https://staging.${this.CIMULATE_SEARCH_API_HOST}.ai`:`https://prod.${this.CIMULATE_SEARCH_API_HOST}.ai`});if(n&&r||!n&&!r)throw new Error("Provide exactly one authentication method: either 'apiKey' or 'apiToken', but not both.");n?this.headers[this.CIMULATE_API_HEADER]=n:r&&(this.headers.Authorization=`Bearer ${r}`),a&&(this.headers["x-cimulate-customer-id"]=a),u&&(this.headers["Tenant-ID"]=u),this.baseApiUrl=this._mapCopilotUrlToSearchUrl(t,s)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class iv{constructor(t,n,r,s=!1,a,u){Se(this,"apiService");Se(this,"config",null);Se(this,"getConfig",()=>Ke(this,null,function*(){if(this.config)return this.config;try{const t=yield this.apiService.fetchConfig();return this.config=t,this.config}catch(t){throw console.error("Failed to fetch customer config:",t),t}}));Se(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));Se(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));Se(this,"getDescription",t=>this.getProductFieldValue(t,"description"));Se(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));Se(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));Se(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));Se(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));Se(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));Se(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});Se(this,"getProductField",t=>this.config?this.config[t]:"");Se(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new rv(t,n,r,s,a,u)}getPriceDisplay(t){const n=this.getPrice(t);return n?typeof n=="string"?n.includes("$")?n:`$${n}`:typeof n=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(n):n:""}}const Ws=(e,t,n,...r)=>{if(!e)return;const s=["background: linear-gradient(90deg,rgba(253, 99, 99, 1) 0%, rgba(245, 139, 35, 1) 65%)","font-weight: bold","color: transparent","background-clip: text","text-fill-color: transparent"].join(";");console[t]("%c[cimulate-widget]",s,n,...r)};class sv{constructor(t=!1){Se(this,"isDevelopment");Se(this,"_log",(t,n,...r)=>{Ws(this.isDevelopment,t,n,...r)});this.isDevelopment=t}log(t,...n){this._log("log",t,...n)}warn(t,...n){this._log("warn",t,...n)}error(t,...n){this._log("error",t,...n)}info(t,...n){this._log("info",t,...n)}debug(t,...n){this._log("debug",t,...n)}}const ov={copilot:"Your Search Assistant",messaging:"Commerce Client"},Dg=B.createContext(null),av=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:s="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:b,searchConfig:y,suggestionButtonConfig:_,progressStepsLimit:A=3,messageAlignment:v="start",autoScroll:w=!0,showProductDescription:N=!1,componentConfig:C,conversationHistory:U,resetConversationMessage:Y="",apiKey:R,apiToken:q,baseUrl:ne,customerId:me,tenantId:V,theme:se,isDevelopment:he,__features:ve,routingAttributes:re,enableDownloadTranscript:oe=!0,enableEscalationToAgent:xe=!1,showProductCaptions:ae=!1,children:Q})=>{const ie=e==="messaging",k=B.useMemo(()=>{const Re=re==null?void 0:re.isCartMgmtSupported;return Re===!0||Re==="true"},[re]),D=B.useMemo(()=>ie?{config:null}:new iv(ne,R,q,he,me,V),[ie,ne,R,q,he,me,V]),ee=B.useMemo(()=>new sv(he),[he]);B.useEffect(()=>{ie||!D||D.config||D.getConfig()},[D,ie]);const I=B.useMemo(()=>cA(se),[se]),_e=B.useMemo(()=>{const Re=(y==null?void 0:y.placeholder)||m,He=(y==null?void 0:y.buttonLabel)||b;let Ye="icon";return y!=null&&y.buttonType?Ye=y.buttonType:b&&(Ye="text"),de(F({},y||{}),{placeholder:Re,buttonLabel:He,buttonType:Ye})},[y,m,b]),Ue=B.useMemo(()=>de(F({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||ov[e!=null?e:"copilot"]}),[r,t,n,e]),ye=B.useMemo(()=>({configModule:D,mode:e!=null?e:"copilot",headerConfig:Ue,entryMessage:a,globalClassName:s,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,themeVariables:I,logger:ee,searchConfig:_e,suggestionButtonConfig:_,progressStepsLimit:A,messageAlignment:v,autoScroll:w,showProductDescription:!!N,enableMinimize:!!(C!=null&&C.enableMinimize),enableDownloadTranscript:oe,enableEscalationToAgent:xe,showProductCaptions:!!ae,resetConversationMessage:Y,conversationHistory:{sinceHours:typeof(U==null?void 0:U.sinceHours)=="number"?U.sinceHours:1,limit:U==null?void 0:U.limit},features:ve,isCartMgmtSupported:k}),[D,e,Ue,a,s,f,p,c,d,u,_e,_,v,w,N,C,oe,xe,ae,Y,ee,I,U,ve,k]);return x.jsx(Dg.Provider,{value:ye,children:Q})},tt=()=>{const e=B.useContext(Dg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};class uv{constructor(){Se(this,"initialState",{connected:!1,mode:"embedded",entryType:"search",status:{type:"dialog",isOpen:!1,isMinimized:!1},dialog:{position:"bottom-left",isFullHeight:!1,width:""},modal:{isFullscreen:!1}});Se(this,"connectedProxy");Se(this,"modeProxy");Se(this,"entryTypeProxy");Se(this,"statusProxy");Se(this,"dialogProxy");Se(this,"modalProxy",{isFullscreen:!1});Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return dv(n,r),Reflect.set(t,n,r)});this.connectedProxy=new Proxy({connected:this.initialState.connected},{get:this._fullGet,set:this._fullSet}),this.modeProxy=new Proxy({mode:this.initialState.mode},{get:this._fullGet,set:this._fullSet}),this.entryTypeProxy=new Proxy({entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.statusProxy=new Proxy({type:this.initialState.status.type,isOpen:this.initialState.status.isOpen,isMinimized:this.initialState.status.isMinimized},{get:this._fullGet,set:this._fullSet}),this.dialogProxy=new Proxy({position:this.initialState.dialog.position,isFullHeight:this.initialState.dialog.isFullHeight,width:this.initialState.dialog.width},{get:this._fullGet,set:this._fullSet}),this.modalProxy=new Proxy({isFullscreen:this.initialState.modal.isFullscreen},{get:this._fullGet,set:this._fullSet})}get connected(){return this.connectedProxy.connected}get mode(){return this.modeProxy.mode}get isOpen(){return!!this.statusProxy.isOpen}get isMinimized(){return!!this.statusProxy.isMinimized}get type(){return this.statusProxy.type}get entryType(){return this.entryTypeProxy.entryType}get position(){return this.dialogProxy.position}get state(){return{connected:this.connected,mode:this.mode,entryType:this.entryType,status:{type:this.type,isOpen:this.isOpen,isMinimized:this.isMinimized},dialog:{position:this.position,isFullHeight:this.dialogProxy.isFullHeight,width:this.dialogProxy.width},modal:{isFullscreen:this.modalProxy.isFullscreen}}}}const Je=new uv,is=()=>Je.connected,ha=()=>Je.isOpen,lv=e=>{window.addEventListener(Zd,e)},cv=e=>{window.removeEventListener(Zd,e)},dv=(e,t)=>{const n=new CustomEvent(Zd,{detail:{property:e,value:t}});window.dispatchEvent(n)},fv=e=>{Je.connectedProxy.connected=e},pa=e=>{if(!sA(e)){const t=q0.map(r=>`'${r}'`),n=`${t.slice(0,-1).join(", ")}, or ${t[t.length-1]}`;throw new Error(`Invalid entryType: "${e}". Must be ${n}.`)}Je.entryTypeProxy.entryType=e},ti=e=>{const t=Je.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;Je.statusProxy.isOpen=n,n&&(Je.statusProxy.isMinimized=!1)},cl=e=>{const t=Je.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;Je.statusProxy.isMinimized=n,n&&(Je.statusProxy.isOpen=!1)},yf=e=>{Je.modalProxy.isFullscreen=e},dl=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);Je.statusProxy.type=e,e==="dialog"||e==="chat"?Je.modeProxy.mode="embedded":Je.modeProxy.mode="standalone"},Tf=e=>{const t=["top","top-left","top-right","bottom","bottom-left","bottom-right","left","right","center"];if(!t.includes(e))throw new Error(`Invalid position: ${e}. Must be one of ${t.join(", ")}.`);Je.dialogProxy.position=e},hv=e=>{const t=Je.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;Je.dialogProxy.isFullHeight=n},pv=({onCopilotEvent:e,children:t,dispatch:n})=>{const{logger:r}=tt(),s=B.useCallback(C=>{n({type:pt.SET_COPILOT,payload:C})},[n]),a=B.useCallback(C=>{fv(C),n({type:pt.SET_CONNECTED,payload:C})},[n]),u=B.useCallback(()=>{n({type:pt.RESET_COPILOT,payload:{}})},[n]),c=B.useCallback(()=>{n({type:pt.RESET_STATE,payload:{}})},[n]),d=B.useCallback(C=>{r==null||r.log(`${C.name} event received`,C),n({type:pt.ADD_MESSAGE,payload:C}),C.bypassHandlers||e==null||e(C)},[e,r,n]),f=B.useCallback(C=>{n({type:pt.ADD_LOADING_MESSAGE,payload:C})},[n]),p=B.useCallback(C=>{n({type:pt.REMOVE_LOADING_MESSAGE,payload:C})},[n]),m=B.useCallback(C=>{d(C),f(C.id)},[d,f]),b=B.useCallback(C=>{n({type:pt.SET_ACTIVE_CONVERSATION_ID,payload:C})},[n]),y=B.useCallback(C=>{n({type:pt.ADD_CONVERSATION_ID,payload:C})},[n]),_=B.useCallback(C=>{n({type:pt.SET_CONVERSATION_IDS,payload:C})},[n]),A=B.useCallback(C=>{n({type:pt.SET_IMAGE_FILE,payload:C})},[n]),v=B.useCallback(C=>{n({type:pt.SET_ASK_CIM_PROMPTS,payload:C})},[n]),w=B.useCallback(C=>{n({type:pt.SET_CONVERSATION_HISTORY_LOADED,payload:C})},[n]),N=B.useMemo(()=>({setCopilot:s,setConnected:a,resetCopilot:u,resetCopilotState:c,addCopilotEvent:d,addLoadingMessage:f,removeLoadingMessage:p,handleCopilotRequestAck:m,setActiveConversationId:b,addConversationId:y,setConversationIds:_,setImageFile:A,setAskCimPrompts:v,setConversationHistoryLoaded:w}),[s,a,u,c,d,f,p,m,b,y,_,A,v,w]);return x.jsx(W0.Provider,{value:N,children:t})};nA();const mv=(e,t)=>{const{type:n,payload:r}=t;if(n===pt.ADD_MESSAGE){const s=r;if(e.messages.push(s),s.eventSourceId){const a=e.groupedMessages.findIndex(u=>u.eventSourceId===s.eventSourceId);if(a!==-1){let u=e.groupedMessages[a].messages;u||(u=[]);const c=u.findIndex(d=>d.id===s.id);if(c!==-1){u[c]=s;return}u.push(s);return}else{e.groupedMessages.push({type:"group",eventSourceId:s.eventSourceId,messages:[s],createdAt:new Date(s.createdAt)});return}}e.groupedMessages.push({type:"individual",message:s,createdAt:new Date(s.createdAt)});return}switch(n){case pt.RESET_STATE:e.messages=Zi.messages,e.groupedMessages=Zi.groupedMessages,e.loadingMessages=Zi.loadingMessages,e.imageFile=Zi.imageFile,e.askCimPrompts=Zi.askCimPrompts,e.conversationHistoryLoaded=Zi.conversationHistoryLoaded;break;case pt.RESET_COPILOT:e.copilot=null;break;case pt.SET_COPILOT:e.copilot=r;break;case pt.SET_CONNECTED:e.connected=r;break;case pt.ADD_LOADING_MESSAGE:e.loadingMessages.add(r);break;case pt.REMOVE_LOADING_MESSAGE:e.loadingMessages.delete(r);break;case pt.SET_ACTIVE_CONVERSATION_ID:e.activeConversationId=r;break;case pt.ADD_CONVERSATION_ID:{const s=r;e.conversationIds.includes(s)||e.conversationIds.push(s)}break;case pt.SET_CONVERSATION_IDS:e.conversationIds=r;break;case pt.SET_IMAGE_FILE:e.imageFile=r;break;case pt.SET_ASK_CIM_PROMPTS:e.askCimPrompts.requestId=(r==null?void 0:r.requestId)||null,e.askCimPrompts.message=(r==null?void 0:r.message)||null;break;case pt.SET_CONVERSATION_HISTORY_LOADED:e.conversationHistoryLoaded=r;break}},gv=({onCopilotEvent:e,children:t})=>{const[n,r]=$0(mv,Zi);return x.jsx(G0.Provider,{value:n,children:x.jsx(pv,{onCopilotEvent:e,dispatch:r,children:t})})};function Ev(){var e=B.useRef(!0);return e.current?(e.current=!1,!0):e.current}function yv(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function Tv(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var bf=typeof window!="undefined",ma=function(e){B.useEffect(e,[])},bv=function(e){var t=B.useRef(e);t.current=e,ma(function(){return function(){return t.current()}})},_v=function(e){var t=B.useRef(0),n=B.useState(e),r=n[0],s=n[1],a=B.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){s(u)})},[]);return bv(function(){cancelAnimationFrame(t.current)}),[r,a]},Sv=function(e,t){return e===t};function xv(e,t){t===void 0&&(t=Sv);var n=B.useRef(),r=B.useRef(e),s=Ev();return!s&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var wv=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,s=t.initialHeight,a=s===void 0?1/0:s,u=t.onChange,c=_v({width:bf?window.innerWidth:r,height:bf?window.innerHeight:a}),d=c[0],f=c[1];return B.useEffect(function(){if(bf){var p=function(){var m=window.innerWidth,b=window.innerHeight;f({width:m,height:b}),u&&u(m,b)};return yv(window,"resize",p),function(){Tv(window,"resize",p)}}},[]),d};class Av{constructor(){Se(this,"items",[]);Se(this,"add",t=>{const n=this.first();n&&n.context===t.context&&this.remove(),this.items.push(t)});Se(this,"remove",()=>this.items.shift());Se(this,"first",()=>this.items.length>0?this.items[0]:null);Se(this,"clear",()=>{this.items.length=0});Se(this,"processQueue",t=>{new Array(pn.size).fill(1).forEach(()=>{const r=pn.first();r&&(t(r),pn.remove())})})}get size(){return this.items.length}}const pn=new Av,Mg=e=>{window.addEventListener(Jd,e)},Fg=e=>{window.removeEventListener(Jd,e)},Cv=(e,t,n)=>{const r=new CustomEvent(Jd,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Bg=e=>{window.addEventListener(Qd,e)},Ug=e=>{window.removeEventListener(Qd,e)},vv=(e,t,n)=>{const r=new CustomEvent(Qd,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Hg=e=>{window.addEventListener(Kd,e)},zg=e=>{window.removeEventListener(Kd,e)},jg=(e,t,n)=>{const r=new CustomEvent(Kd,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)},kv=e=>{window.addEventListener(tf,e)},Nv=e=>{window.removeEventListener(tf,e)},fl=(e,t,n)=>{const r=new CustomEvent(tf,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)};class Pv{constructor(){Se(this,"initialParams",{categoryId:"",categoryName:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});Se(this,"categoryIdProxy");Se(this,"facetFiltersProxy");Se(this,"rangeFiltersProxy");Se(this,"catalogSegmentProxy");Se(this,"pricebooksProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{const s=uA[n];return vv(s,n,r),Reflect.set(t,n,r)});Se(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.categoryIdProxy=new Proxy({categoryId:this.initialParams.categoryId,categoryName:this.initialParams.categoryName},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get categoryId(){return this.categoryIdProxy.categoryId||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{categoryId:this.categoryId,categoryName:this.categoryIdProxy.categoryName,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const at=new Pv,$g=(e,t)=>{const n=t.updateFacetFiltersProxy(e);t.facetFiltersProxy.facetFilters=n.facetFilters},Vg=(e,t,n)=>{var u,c;const r=F({},((u=n.facetFiltersProxy)==null?void 0:u.facetFilters)||{});if(!!((c=r[e])!=null&&c.includes(t))){const d=r[e].filter(f=>f!==t);d.length>0?r[e]=d:delete r[e]}else r[e]=r[e]?[...r[e],t]:[t];const a=n.updateFacetFiltersProxy(r);n.facetFiltersProxy.facetFilters=a.facetFilters},qg=(e,t)=>{const n=t.updateRangeFiltersProxy(e);t.rangeFiltersProxy.rangeFilters=n.rangeFilters},Yg=({field:e,value:t},n)=>{const[r,s]=Array.isArray(t)?t:[];if(typeof r=="undefined"||typeof s=="undefined")throw new Error("Range values must be an array with two numbers for min and max");const a=[...n.rangeFiltersProxy.rangeFilters||[]],u=a.findIndex(d=>d.field===e);if(u!==-1){a[u]={field:e,min:r,max:s},n.rangeFiltersProxy.rangeFilters=a;return}a.push({field:e,min:r,max:s});const c=n.updateRangeFiltersProxy(a);n.rangeFiltersProxy.rangeFilters=c.rangeFilters},Gg=(e,t)=>{t.catalogSegmentProxy.catalogSegment=e},Wg=(e,t)=>{const n=t.updatePricebooksProxy(e);t.pricebooksProxy.pricebooks=n.pricebooks},Ov=e=>{if(!is()||!ha()){is()&&pn.clear(),pn.add({context:"browse",payload:de(F({},at.state),{categoryId:e})});return}at.categoryIdProxy.categoryId=e},Xg=e=>{$g(e,at)},Iv=(e,t)=>{Vg(e,t,at)},Kg=e=>{qg(e,at)},Rv=({field:e,value:t})=>{Yg({field:e,value:t},at)},Lv=e=>{Gg(e,at)},Qg=e=>{Wg(e,at)},Jg=e=>{if(!e||!("categoryId"in e))throw new Error("Browse context must include a categoryId");const t=is(),n=ha();if(!t||!n){t&&pn.clear(),pn.add({context:"browse",payload:F({},e)});return}"facetFilters"in e&&Xg(e.facetFilters||{}),"rangeFilters"in e&&Kg(e.rangeFilters||[]),"catalogSegment"in e&&(at.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&Qg(e.pricebooks||[]),"categoryName"in e&&(at.categoryIdProxy.categoryName=e.categoryName||""),at.categoryIdProxy.categoryId=e.categoryId},Dv=Object.freeze(Object.defineProperty({__proto__:null,setBrowseContext:Jg,updateBrowseCategoryId:Ov,updateCatalogSegment:Lv,updateFacetFilter:Iv,updateFacetFilters:Xg,updatePricebooks:Qg,updateRangeFilter:Rv,updateRangeFilters:Kg},Symbol.toStringTag,{value:"Module"}));class Mv{constructor(){Se(this,"initialParams",{productId:"",productName:"",pdpLink:""});Se(this,"proxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>(jg(n,r),Reflect.set(t,n,r)));Se(this,"updateProxy",t=>{t.productId&&(this.proxy=new Proxy({productId:t.productId,productName:t.productName||"",pdpLink:t.pdpLink||""},{get:this._fullGet,set:this._fullSet}))});this.proxy=new Proxy({productId:this.initialParams.productId,productName:this.initialParams.productName,pdpLink:this.initialParams.pdpLink},{get:this._fullGet,set:this._fullSet})}get productId(){return this.proxy.productId}get pdpLink(){return this.proxy.pdpLink}get state(){return{productId:this.productId,productName:this.proxy.productName,pdpLink:this.pdpLink}}}const mr=new Mv,Zg=e=>{if(!e||!e.productId)throw new Error("PDP context must include a productId");const t=is(),n=ha();if(!t||!n){t&&pn.clear(),pn.add({context:"pdp",payload:F({},e)});return}mr.updateProxy(e),jg("pdp-context",e)},Fv=e=>{mr.proxy.productId=e,is()||pn.add({context:"pdp",payload:F({},mr.state)})},Bv=e=>{mr.proxy.pdpLink=e},mt={SET_PROMPTS_EXTENSION_INITIALIZED:"SET_PROMPTS_EXTENSION_INITIALIZED",SET_PROMPTS_EXTENSION_OPEN:"SET_PROMPTS_EXTENSION_OPEN",SET_PROMPTS_EXTENSION_INLINE:"SET_PROMPTS_EXTENSION_INLINE",SET_PROMPTS_EXTENSION_ELEMENT_ID:"SET_PROMPTS_EXTENSION_ELEMENT_ID",SET_PROMPTS_EXTENSION_ENTRY_TYPE:"SET_PROMPTS_EXTENSION_ENTRY_TYPE",SET_PROMPTS_EXTENSION_PARAMS:"SET_PROMPTS_EXTENSION_PARAMS",RESET_PROMPTS_EXTENSION_PARAMS:"RESET_PROMPTS_EXTENSION_PARAMS",SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",SET_PROMPTS_EXTENSION_USER_PROMPT:"SET_PROMPTS_EXTENSION_USER_PROMPT",SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_LOADING:"SET_PROMPTS_EXTENSION_RESPONSE_LOADING"},e1={isInitialized:!1,isOpen:!1,isInline:!1,elementId:null,placeholder:null,askElseButtonLabel:null,entryType:null,params:null,activePromptsId:null,userPrompt:null,promptsMessage:null,isResponseLoading:!1,responseMessage:null,promptsDisplay:"both",staticQuestions:[],staticQuestionsStrategy:"append",disableAskElseButton:!1};class Uv{constructor(){Se(this,"initialState",e1);Se(this,"promptsStateProxy");Se(this,"promptsParamsProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on PromptsExtensionState`);return ga(n,r),Reflect.set(t,n,r)});Se(this,"_paramsFullGet",(t,n)=>Reflect.get(t,n));Se(this,"_paramsFullSet",(t,n,r)=>Reflect.set(t,n,r));Se(this,"updatePromptsParamsProxy",t=>new Proxy(F({},t),{get:this._paramsFullGet,set:this._paramsFullSet}));this.promptsStateProxy=new Proxy({isOpen:this.initialState.isOpen,isInline:this.initialState.isInline,elementId:this.initialState.elementId,entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.promptsParamsProxy=this.updatePromptsParamsProxy({})}get isOpen(){return this.promptsStateProxy.isOpen}get isInline(){return this.promptsStateProxy.isInline}get state(){return{isOpen:this.isOpen,isInline:this.isInline}}get params(){return this.promptsParamsProxy}}const Bt=new Uv,Hv=e=>{window.addEventListener(ef,e)},zv=e=>{window.removeEventListener(ef,e)},ga=(e,t)=>{const n=new CustomEvent(ef,{detail:{property:e,value:t}});window.dispatchEvent(n)},t1=e=>{const t=Bt.isOpen,n=typeof e=="boolean"?e:!t;Bt.promptsStateProxy.isOpen=n},n1=e=>{const t=Bt.isInline,n=typeof e=="boolean"?e:!t;Bt.promptsStateProxy.isInline=n},jv=e=>{Bt.promptsParamsProxy=Bt.updatePromptsParamsProxy(e),ga("params",e),Bt.promptsStateProxy.entryType="ask_cim"},$v=e=>{Bt.promptsParamsProxy=Bt.updatePromptsParamsProxy(e),ga("params",e),Bt.promptsStateProxy.entryType="search"},Vv=e=>{Bt.promptsParamsProxy=Bt.updatePromptsParamsProxy(e),ga("params",e),Bt.promptsStateProxy.entryType="browse"},qv=e=>{Bt.promptsParamsProxy=Bt.updatePromptsParamsProxy(e),ga("params",e),Bt.promptsStateProxy.entryType="pdp"},Yv=({elementId:e,entryType:t,params:n,isInline:r})=>{Bt.promptsStateProxy.elementId=e,t&&(Bt.promptsStateProxy.entryType=t),typeof r=="boolean"&&n1(r),n&&Bt.updatePromptsParamsProxy(n),Bt.isOpen||t1(!0)},Gv=Object.freeze(Object.defineProperty({__proto__:null,getConversationMessages:({payload:e,callback:t})=>{fl("getConversationMessages",{payload:e,callback:t},bi.GET_CONVERSATION_MESSAGES)},getSessionInformation:e=>{fl("getSessionInformation",{callback:e},bi.GET_SESSION_INFORMATION)},loadConversation:e=>{fl("loadConversation",e,bi.LOAD_CONVERSATION)},resetConversation:()=>{fl("resetConversation",!0,bi.RESET_CONVERSATION)}},Symbol.toStringTag,{value:"Module"}));class Wv{constructor(){Se(this,"initialParams",{query:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});Se(this,"queryProxy");Se(this,"facetFiltersProxy");Se(this,"rangeFiltersProxy");Se(this,"catalogSegmentProxy");Se(this,"pricebooksProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{const s=lA[n];return Cv(s,n,r),Reflect.set(t,n,r)});Se(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.queryProxy=new Proxy({query:this.initialParams.query},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get query(){return this.queryProxy.query||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{query:this.query,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const Tt=new Wv,Xv=e=>{const t=ha(),n=is();if(!n||!t){n&&pn.clear(),pn.add({context:"search",payload:de(F({},Tt.state),{query:e})});return}Tt.queryProxy.query=e},r1=e=>{$g(e,Tt)},Kv=(e,t)=>{Vg(e,t,Tt)},i1=e=>{qg(e,Tt)},Qv=({field:e,value:t})=>{Yg({field:e,value:t},Tt)},Jv=e=>{Gg(e,Tt)},s1=e=>{Wg(e,Tt)},o1=e=>{if(!e||!e.query)throw new Error("Search context must include a query");const t=ha(),n=is();if(!n||!t){n&&pn.clear(),pn.add({context:"search",payload:F({},e)});return}"facetFilters"in e&&r1(e.facetFilters||{}),"rangeFilters"in e&&i1(e.rangeFilters||[]),"catalogSegment"in e&&(Tt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&s1(e.pricebooks||[]),Tt.queryProxy.query=e.query},Zv=Object.freeze(Object.defineProperty({__proto__:null,setSearchContext:o1,updateCatalogSegment:Jv,updateFacetFilter:Kv,updateFacetFilters:r1,updatePricebooks:s1,updateRangeFilter:Qv,updateRangeFilters:i1,updateSearchQuery:Xv},Symbol.toStringTag,{value:"Module"})),ek={categoryId:at.categoryId,categoryName:at.categoryIdProxy.categoryName||"",facetFilters:at.facetFilters,rangeFilters:at.rangeFilters,catalogSegment:at.catalogSegment,pricebooks:at.pricebooks},a1=B.createContext(ek),tk=({children:e})=>{const[t,n]=B.useState(at.categoryId),[r,s]=B.useState(at.categoryIdProxy.categoryName||""),[a,u]=B.useState(at.facetFilters||{}),[c,d]=B.useState(at.rangeFilters||[]),[f,p]=B.useState(at.catalogSegment||null),[m,b]=B.useState(at.pricebooks||null);B.useEffect(()=>{const _=({detail:A})=>{(A==null?void 0:A.property)==="categoryId"&&n(A.value),(A==null?void 0:A.property)==="categoryName"&&s(A.value),(A==null?void 0:A.property)==="facetFilters"&&u(A.value),(A==null?void 0:A.property)==="rangeFilters"&&d(A.value),(A==null?void 0:A.property)==="catalogSegment"&&p(A.value),(A==null?void 0:A.property)==="pricebooks"&&b(A.value)};return Bg(_),()=>{Ug(_)}},[]);const y=B.useMemo(()=>({categoryId:t,categoryName:r,facetFilters:a,rangeFilters:c,catalogSegment:f,pricebooks:m}),[t,r,a,c,f,m]);return x.jsx(a1.Provider,{value:y,children:e})},nk=()=>{const e=B.useContext(a1);if(!e)throw new Error("useBrowse must be used within a BrowseProvider");return e},rk={searchQuery:Tt.query,facetFilters:Tt.facetFilters,rangeFilters:Tt.rangeFilters,catalogSegment:Tt.catalogSegment,pricebooks:Tt.pricebooks},u1=B.createContext(rk),ik=({children:e})=>{const[t,n]=B.useState(Tt.query),[r,s]=B.useState(Tt.facetFilters),[a,u]=B.useState(Tt.rangeFilters),[c,d]=B.useState(Tt.catalogSegment),[f,p]=B.useState(Tt.pricebooks);B.useEffect(()=>{const b=({detail:y})=>{(y==null?void 0:y.property)==="query"&&n(y.value),(y==null?void 0:y.property)==="facetFilters"&&s(y.value),(y==null?void 0:y.property)==="rangeFilters"&&u(y.value),(y==null?void 0:y.property)==="catalogSegment"&&d(y.value),(y==null?void 0:y.property)==="pricebooks"&&p(y.value)};return Mg(b),()=>{Fg(b)}},[]);const m=B.useMemo(()=>({searchQuery:t,facetFilters:r,rangeFilters:a,catalogSegment:c,pricebooks:f}),[t,r,a,c,f]);return x.jsx(u1.Provider,{value:m,children:e})},sk=()=>{const e=B.useContext(u1);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e},ok={productId:mr.productId,pdpLink:mr.pdpLink},l1=B.createContext(ok),ak=({children:e})=>{const[t,n]=B.useState(mr.productId),[r,s]=B.useState(mr.pdpLink);B.useEffect(()=>{const u=({detail:c})=>{if((c==null?void 0:c.property)==="pdp-context"){const d=c.value;n(d.productId),s(d.pdpLink);return}(c==null?void 0:c.property)==="productId"&&n(c.value),(c==null?void 0:c.property)==="pdpLink"&&s(c.value)};return Hg(u),()=>{zg(u)}},[]);const a=B.useMemo(()=>({productId:t,pdpLink:r}),[t,r]);return x.jsx(l1.Provider,{value:a,children:e})},uk=()=>{const e=B.useContext(l1);if(!e)throw new Error("usePdp must be used within a PdpProvider");return e},c1=B.createContext({mode:Je.modeProxy.mode,entryType:Je.entryType,status:Je.statusProxy,dialogPosition:Je.dialogProxy.position,isDialogFullHeight:Je.dialogProxy.isFullHeight,dialogWidth:Je.dialogProxy.width,isModalFullscreen:Je.modalProxy.isFullscreen,previousComponentType:Je.statusProxy.type}),lk=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[s,a]=B.useState(e!=null?e:Je.entryTypeProxy.entryType),[u,c]=B.useState(Je.modeProxy.mode),[d,f]=B.useState({type:n||Je.statusProxy.type,isOpen:Je.statusProxy.isOpen,isMinimized:Je.statusProxy.isMinimized}),[p,m]=B.useState(Je.dialogProxy.position),[b,y]=B.useState(Je.dialogProxy.isFullHeight),[_,A]=B.useState(Je.dialogProxy.width),[v,w]=B.useState(Je.modalProxy.isFullscreen),N=xv(d.type);B.useEffect(()=>{const U=Y=>{const{property:R,value:q}=Y.detail||{};if(!(!R||q===void 0)){if(R==="mode"){c(q);return}if(R==="entryType"){a(q);return}if(R==="isMinimized"){f(ne=>de(F({},ne),{isMinimized:q}));return}if(R==="isOpen"){f(ne=>de(F({},ne),{isOpen:q}));return}if(R==="type"){f(ne=>de(F({},ne),{type:q}));return}if(R==="position"){m(q);return}if(R==="isFullHeight"){y(q);return}if(R==="width"){A(q);return}if(R==="isFullscreen"){w(q);return}}};return lv(U),()=>{cv(U)}},[]),ma(()=>{e&&pa(e)}),ma(()=>{const U=n||(t==null?void 0:t.type);U&&dl(U),t&&"isOpen"in t&&ti(!!t.isOpen),t&&"isMinimized"in t&&cl(!!t.isMinimized)}),ma(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:U}=t.options;U&&Tf(U),"dialogFullHeight"in t.options&&hv(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&A(t.options.dialogWidth),"isModalFullscreen"in t.options&&yf(!!t.options.isModalFullscreen)});const C=B.useMemo(()=>({mode:u,entryType:s,status:d,previousComponentType:N||"dialog",dialogPosition:p,isDialogFullHeight:b,dialogWidth:_,isModalFullscreen:v}),[u,s,d,N,p,b,_,v]);return x.jsx(c1.Provider,{value:C,children:r})},er=()=>{const e=B.useContext(c1);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e},d1=B.createContext(null),f1=B.createContext(null),_f=()=>{const e=B.useContext(f1);if(!e)throw new Error("usePromptsExtensionDispatch must be used within a PromptsExtensionProvider");return e||{}},ni=()=>{const e=B.useContext(d1);if(!e)throw new Error("usePromptsExtensionState must be used within a PromptsExtensionProvider");return e||{}},Xs=()=>{const e=B.useContext(W0);if(!e)throw new Error("useCopilotDispatch must be used within a CopilotProvider");return e},tr=()=>{const e=B.useContext(G0);if(!e)throw new Error("useCopilotState must be used within a CopilotProvider");return e},ck=({copilot:e})=>{const{logger:t,conversationHistory:n}=tt(),{isInline:r}=ni(),{addCopilotEvent:s,setConversationHistoryLoaded:a}=Xs(),{activeConversationId:u}=tr(),c=B.useCallback(f=>{e&&e.requestSessionInformation(p=>{t==null||t.log("Retrieved session information: ",p),f==null||f(p)})},[e,t]),d=B.useCallback((f,p)=>{e&&f.conversationId&&e.getConversationEvents(f,m=>{t==null||t.log("Retrieved conversation messages: ",m),p==null||p(m)})},[e,t]);return B.useEffect(()=>{if(r||!u)return;if(n.sinceHours===0||(n==null?void 0:n.limit)===0){a(!0);return}const f=3600*1e3*n.sinceHours,p=new Date(Date.now()-f).toISOString(),m={conversationId:u,since:p,excludeEvents:["done","error","connection_error","refined_browse","refined_search","conversation_reset"]};typeof n.limit=="number"&&(m.limit=n.limit),d(m,b=>{const y=[];[...b.reverse()||[]].forEach(A=>{var w;const v=b.find(N=>N.id===A.eventSourceId);(w=v==null?void 0:v.name)!=null&&w.endsWith("_suggestions")||(A.bypassHandlers=!0,y.unshift(A))}),y.forEach(A=>{s(A)}),a(!0)})},[t,r,u,d,s,a,n]),{getSessionInformation:c,getConversationMessages:d}},h1=B.createContext({copilot:null,messages:[],groupedMessages:[],isLoading:!1,isResponseLoading:()=>!1,handleAskCim:()=>{},handleSearch:()=>{},handleBrowse:()=>{},handlePdp:()=>{},handleSuggestion:()=>{},handleUserInput:()=>{},handleCancel:()=>{},resetConversation:()=>{},getSessionInformation:()=>{},getConversationMessages:()=>{}}),dk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>{const{logger:p,clientContext:m,baseCatalogParams:b}=tt(),on=sk(),{searchQuery:y}=on,_=dn(on,["searchQuery"]),Fn=nk(),{categoryId:A}=Fn,v=dn(Fn,["categoryId"]),{productId:w,pdpLink:N}=uk(),{setCopilot:C,setConnected:U,resetCopilot:Y,resetCopilotState:R,addCopilotEvent:q,removeLoadingMessage:ne,handleCopilotRequestAck:me,setActiveConversationId:V,setConversationIds:se,setAskCimPrompts:he}=Xs(),{connected:ve,copilot:re,messages:oe,groupedMessages:xe,loadingMessages:ae,askCimPrompts:Q}=tr(),{status:ie,entryType:k}=er(),{isInline:D}=ni(),{getConversationMessages:ee,getSessionInformation:I}=ck({copilot:re}),_e=B.useMemo(()=>ae.size>0,[ae]),Ue=B.useCallback(we=>ae.has(we),[ae]),ye=B.useCallback(({query:we,facetFilters:Pe,rangeFilters:Me,catalogSegment:rt,pricebooks:ht,userPrompt:J,imageFile:ge})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const Ce={searchParams:{query:we}};J&&(Ce.userPrompt=J),ge&&(Ce.attachments={image:ge}),Pe&&Object.keys(Pe).length>0&&(Ce.searchParams.facetFilters=Pe),Me&&Me.length>0&&(Ce.searchParams.rangeFilters=Me),rt&&(Ce.searchParams.catalogSegment=rt),ht&&(Ce.searchParams.pricebooks=ht),m&&(Ce.clientContext=m),pa("search"),re.search(Ce,qe=>{const Ie=F({},qe);me(Ie)})},[p,me,re,m]),Re=B.useCallback(({categoryId:we,categoryName:Pe,facetFilters:Me,rangeFilters:rt,catalogSegment:ht,pricebooks:J,userPrompt:ge,imageFile:Ce})=>{if(!re){p==null||p.error("Copilot is not initialized");return}const qe=Me&&Object.keys(Me).length>0;if(we===""&&!qe){p==null||p.error("Browse event must include facetFilters when categoryId is empty");return}const Ie={browseParams:{categoryId:we||""}};ge&&(Ie.userPrompt=ge),Ce&&(Ie.attachments={image:Ce}),qe&&(Ie.browseParams.facetFilters=Me),rt&&rt.length>0&&(Ie.browseParams.rangeFilters=rt),ht&&(Ie.browseParams.catalogSegment=ht),Array.isArray(J)&&J.length>0&&(Ie.browseParams.pricebooks=J),(m||Pe)&&(Ie.clientContext={},m&&(Ie.clientContext=F({},m)),Pe&&(Ie.clientContext.cimLabel=Pe)),pa("browse"),re.browse(Ie,ut=>{var Vr;const Vt=F({},ut),Ht=((Vr=Vt.request)==null?void 0:Vr.clientContext)||{},an=(Ht==null?void 0:Ht.cimLabel)||Pe;an&&Vt.request&&(Vt.request.label=an),me(Vt)})},[p,me,re,m]),He=B.useCallback(({productId:we,productName:Pe,pdpLink:Me,userPrompt:rt,imageFile:ht})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const J={productId:we};rt&&(J.userPrompt=rt),Me&&(J.pdpLink=Me),ht&&(J.attachments={image:ht}),(m||Pe)&&(J.clientContext={},m&&(J.clientContext=F({},m)),Pe&&(J.clientContext.cimLabel=Pe)),b&&(J.baseCatalogParams=b),pa("pdp"),re.productView(J,ge=>{var ut;const Ce=F({},ge),qe=((ut=Ce.request)==null?void 0:ut.clientContext)||{},Ie=(qe==null?void 0:qe.cimLabel)||Pe;Ie&&Ce.request&&(Ce.request.label=Ie),me(Ce)})},[p,re,me,m,b]),Ye=B.useCallback(({userPrompt:we,imageFile:Pe})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const Me={userPrompt:we};Pe&&(Me.attachments={image:Pe}),m&&(Me.clientContext=m),b&&(Me.baseCatalogParams=b),re.askCim(Me,rt=>{const ht=F({},rt);me(ht)})},[p,re,me,m,b]),bt=B.useCallback(we=>{q(we),c==null||c(we)},[q,c]),Cn=B.useCallback(we=>{q(we),d==null||d(we)},[q,d]),sn=B.useCallback(we=>{u==null||u(we),U(!0)},[u,U]);B.useEffect(()=>{!re||!ve||!ie.isOpen||pn.size>0&&pn.processQueue(we=>{if(we.context==="search"){const Pe=F({},we.payload);o1(Pe)}if(we.context==="browse"){const Pe=F({},we.payload);Jg(Pe)}if(we.context==="pdp"){const Pe=F({},we.payload);Zg(Pe)}})},[ie.isOpen,re,ve]);const _r=B.useCallback(we=>{const Pe=Me=>{const rt=de(F({},Me),{id:Me.inquiryLinkId||Me.id});q(rt)};we.on("connect_ack",sn),we.on("partial_inquiry",Pe),we.on("display_products",q),we.on("progress",q),we.on("refined_search",bt),we.on("refined_browse",Cn),we.on("done",Me=>{ne(Me.eventSourceId)}),we.on("error",Me=>{q(Me),ne(Me.eventSourceId)}),we.onDisconnect(Me=>{const rt=["io server disconnect","transport error","server shutting down"];if(p==null||p.log("Connection disconnected with reason: ",Me),!rt.includes(Me)){U(!1);return}p==null||p.log("De-registering event listeners");const ht=new Date().toISOString();q({name:"error",message:"Connection was lost. Please try again.",createdAt:ht,id:`error-${ht}`,sessionId:"session"}),we.off()})},[p,U,ne,bt,Cn,q,sn]);B.useEffect(()=>{if(!re)return;const we=Pe=>{if(!D){if(!Pe.message&&Pe.eventSourceId&&Pe.eventSourceId===Q.requestId){he({requestId:Pe.eventSourceId,message:Pe});return}q(Pe)}};return re.on("follow_up",we),()=>{re.off("follow_up",we)}},[re,oe,Q.requestId,D,q,he]),B.useEffect(()=>{if(!re)return;const we=Pe=>{if(D)return;const Me=de(F({},Pe),{id:Pe.inquiryLinkId||Pe.id});q(Me)};return re.on("inquiry",we),()=>{re.off("inquiry",we)}},[re,D,q]),ma(()=>{let we;n?we=n:we=a?"https://staging.copilot.search.cimulate.ai":"https://prod.copilot.search.cimulate.ai";const Pe={baseUrl:we};e?Pe.apiKey=e:t&&(Pe.apiToken=t),r&&(Pe.customerId=r),s&&(Pe.tenantId=s);const Me=new Yw(Pe);return C(Me),_r(Me),Me.connect(),Me.requestSessionInformation(rt=>{p==null||p.log("Session Information: ",rt);const{activeConversationId:ht,conversationIds:J}=rt.data||{};ht&&V(ht),J!=null&&J.length&&se(J)}),()=>{Me.disconnect(),Me.off(),Y()}});const sr=B.useCallback(we=>{if(!re)return;const Pe={eventId:we,reason:"User cancelled the request"};re.cancelRequest(Pe,Me=>{q(Me),ne(we)})},[q,ne,re]),Jt=B.useCallback(()=>{re&&re.conversationReset({},we=>{R(),q(we),re.requestSessionInformation(Pe=>{p==null||p.log("Session Information: ",Pe);const{activeConversationId:Me,conversationIds:rt}=Pe.data||{};Me&&V(Me),rt!=null&&rt.length&&se(rt)})})},[re,p,q,R,V,se]),Ve=B.useCallback((we,Pe)=>{if(!we)return;const Me={userPrompt:we};switch(Pe&&(Me.imageFile=Pe),k){case"ask_cim":Ye(Me);return;case"search":y?ye(F(F({query:y},_),Me)):Ye(Me);return;case"browse":Re(F(F({categoryId:A},v),Me));return;case"pdp":w?He(F({productId:w,pdpLink:N||""},Me)):Ye(Me);return}},[k,y,_,ye,Ye,A,v,Re,He,w,N]),kt=B.useCallback((we,Pe)=>{var ge,Ce,qe;const rt=we.params.userPrompt||"";if(!rt)return;const ht=oe.find(Ie=>Ie.id===Pe);if(!ht)return;const J=ht.name.replace("_suggestions","");if(J==="ask_cim"){Ye({userPrompt:rt});return}if(J==="copilot_search"){const Ie=((ge=ht.request)==null?void 0:ge.searchParams)||{},Vt=Ie.query===y;ye(de(F({query:Ie.query||y},Vt?_:{}),{userPrompt:rt}));return}if(J==="copilot_browse"){const Ie=ht.request,ut=Ie.browseParams||{},Ht=ut.categoryId===A,an=((Ce=Ie.clientContext)==null?void 0:Ce.cimLabel)||"";Re(de(F({categoryId:ut.categoryId||A||""},Ht?v:{}),{categoryName:an,userPrompt:rt}));return}if(J==="product_view"){const Ie=ht.request||{},ut=Ie.productId,Vt=ut===w,Ht=((qe=Ie.clientContext)==null?void 0:qe.cimLabel)||"";let an="";Vt?an=N||"":an=Ie.pdpLink||"",He({productId:ut||w,pdpLink:an,productName:Ht,userPrompt:rt})}},[oe,y,_,ye,Ye,A,v,Re,He,w,N]),vn=B.useMemo(()=>({copilot:re,messages:oe,groupedMessages:xe,isLoading:_e,isResponseLoading:Ue,handleAskCim:Ye,handleSearch:ye,handleBrowse:Re,handlePdp:He,handleUserInput:Ve,handleSuggestion:kt,handleCancel:sr,resetConversation:Jt,getSessionInformation:I,getConversationMessages:ee}),[re,oe,xe,_e,Ue,Ye,ye,Re,He,Ve,kt,sr,Jt,I,ee]);return x.jsx(h1.Provider,{value:vn,children:f})},p1=()=>{const{copilot:e}=tr(),{addCopilotEvent:t}=Xs();return{getCopilotSuggestions:B.useCallback((r,s,a)=>{if(!e||!s||!r)return;const u=c=>{t(c),a(c)};switch(s){case"ask_cim":e.askCimSuggestions(r,u);break;case"search":e.searchSuggestions({searchParams:r},u);break;case"browse":e.browseSuggestions({browseParams:r},u);break;case"pdp":e.productViewSuggestions({productId:r.productId},u);break}},[e,t])}},Ir=()=>{const e=B.useContext(h1);if(!e)throw new Error("useCopilot must be used within a CopilotProvider");return e},fk=()=>{const{copilot:e,activeConversationId:t,askCimPrompts:n,conversationHistoryLoaded:r}=tr(),{entryType:s}=er(),{resetCopilotState:a,addCopilotEvent:u,setAskCimPrompts:c}=Xs(),{handleSearch:d,handleBrowse:f,handlePdp:p,resetConversation:m,getSessionInformation:b,getConversationMessages:y}=Ir(),{getCopilotSuggestions:_}=p1();B.useEffect(()=>{!e||!s||!t||!r||n.requestId||s==="ask_cim"&&_({},s,N=>{c({requestId:N.id,message:null})})},[e,t,n.requestId,s,r,_,c]);const A=B.useCallback(({query:N})=>{if(!e||!N)return;const{facetFilters:C}=Tt.facetFiltersProxy,{rangeFilters:U}=Tt.rangeFiltersProxy,{catalogSegment:Y}=Tt.catalogSegmentProxy,{pricebooks:R}=Tt.pricebooksProxy,q={query:N};q.facetFilters=C||{},q.rangeFilters=U||[],q.catalogSegment=Y||"",q.pricebooks=R||[],d(F({},q))},[e,d]),v=B.useCallback(({categoryId:N})=>{if(!e)return;const C=at.categoryIdProxy.categoryName,{facetFilters:U}=at.facetFiltersProxy,{rangeFilters:Y}=at.rangeFiltersProxy,{catalogSegment:R}=at.catalogSegmentProxy,{pricebooks:q}=at.pricebooksProxy,ne={categoryId:N};ne.categoryName=C||"",ne.facetFilters=U||{},ne.rangeFilters=Y||[],ne.catalogSegment=R||"",ne.pricebooks=q||[],f(F({},ne))},[e,f]),w=B.useCallback(({productId:N})=>{if(!e||!N)return;const C={productId:N,pdpLink:mr.pdpLink,productName:mr.proxy.productName||""};p(C)},[e,p]);return B.useEffect(()=>{const N=({detail:C})=>{(C==null?void 0:C.property)==="query"&&A({query:C.value})};return Mg(N),()=>{Fg(N)}},[A]),B.useEffect(()=>{const N=({detail:C})=>{if((C==null?void 0:C.property)==="pdp-context"){const U=C.value;w({productId:U.productId});return}(C==null?void 0:C.property)==="productId"&&w({productId:C.value})};return Hg(N),()=>{zg(N)}},[w]),B.useEffect(()=>{const N=({detail:C})=>{(C==null?void 0:C.property)==="categoryId"&&v({categoryId:C.value})};return Bg(N),()=>{Ug(N)}},[v]),B.useEffect(()=>{const N=({detail:C})=>{if((C==null?void 0:C.event)==bi.RESET_CONVERSATION&&m(),(C==null?void 0:C.event)==bi.GET_SESSION_INFORMATION){const U=C.value.callback;b(U)}if((C==null?void 0:C.event)==bi.GET_CONVERSATION_MESSAGES){const{payload:U,callback:Y}=C.value;if(!U.conversationId||typeof Y!="function")return;y(U,Y)}if((C==null?void 0:C.event)==bi.LOAD_CONVERSATION){const U=C.value;if(!U.conversationId)return;y(U,R=>{a(),R.forEach(q=>{u(q)})})}};return kv(N),()=>{Nv(N)}},[m,b,y,a,u]),null},hk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>x.jsxs(dk,{apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:[x.jsx(fk,{}),f]}),pk=e=>Array.from(new Set((e!=null?e:[]).map(t=>t.trim()).filter(Boolean))),mk=({children:e,dispatch:t})=>{const n=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_INITIALIZED,payload:_})},[t]),r=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_OPEN,payload:_})},[t]),s=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_INLINE,payload:_})},[t]),a=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_ELEMENT_ID,payload:_})},[t]),u=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_ENTRY_TYPE,payload:_})},[t]),c=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID,payload:_})},[t]),d=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_USER_PROMPT,payload:_})},[t]),f=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_PARAMS,payload:_})},[t]),p=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE,payload:_})},[t]),m=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE,payload:_})},[t]),b=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=B.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:s,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:f,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:b}),[n,r,s,a,u,c,d,f,p,m,b]);return x.jsx(f1.Provider,{value:y,children:e})},gk=(e,t)=>{const{type:n,payload:r}=t;switch(n){case mt.SET_PROMPTS_EXTENSION_INITIALIZED:e.isInitialized=r;break;case mt.SET_PROMPTS_EXTENSION_OPEN:e.isOpen=r;break;case mt.SET_PROMPTS_EXTENSION_INLINE:e.isInline=r;break;case mt.SET_PROMPTS_EXTENSION_ELEMENT_ID:e.elementId=r;break;case mt.SET_PROMPTS_EXTENSION_ENTRY_TYPE:e.entryType=r;break;case mt.SET_PROMPTS_EXTENSION_PARAMS:e.params=r;break;case mt.RESET_PROMPTS_EXTENSION_PARAMS:e.params=null;break;case mt.SET_PROMPTS_EXTENSION_USER_PROMPT:e.userPrompt=r;break;case mt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=r;break;case mt.RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=null;break;case mt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=r;break;case mt.RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=null;break;case mt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=r;break;case mt.RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=null;break;case mt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING:e.isResponseLoading=r;break}},Ek=({promptsConfig:e,children:t})=>{const[n,r]=$0(gk,de(F(F({},e1),e||{}),{staticQuestions:pk((e==null?void 0:e.staticQuestions)||[])}));return x.jsx(d1.Provider,{value:n,children:x.jsx(mk,{dispatch:r,children:t})})},m1=({mode:e,apiKey:t,apiToken:n,baseUrl:r,customerId:s,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,theme:f,openLinksInNewTab:p,globalClassName:m,isDevelopment:b=!1,componentType:y,componentConfig:_,entryType:A,entryMessage:v,disclaimerText:w,disclaimerMarkdown:N,clientContext:C,baseCatalogParams:U,searchPlaceholder:Y,searchButtonLabel:R,searchConfig:q,suggestionButtonConfig:ne,messageAlignment:me,autoScroll:V,promptsConfig:se,resetConversationMessage:he,conversationHistory:ve,onConnect:re,onCopilotEvent:oe,onRefinedSearch:xe,onRefinedBrowse:ae,__features:Q,children:ie})=>x.jsx(av,{mode:e,baseUrl:r,apiKey:t,apiToken:n,customerId:s,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,entryMessage:v,theme:f,globalClassName:m,openLinksInNewTab:p,searchPlaceholder:Y,searchButtonLabel:R,searchConfig:q,suggestionButtonConfig:ne,messageAlignment:me,autoScroll:V,componentConfig:_,clientContext:C,baseCatalogParams:U,disclaimerMarkdown:N,disclaimerText:w,resetConversationMessage:he,conversationHistory:ve,isDevelopment:b,__features:Q,children:x.jsx(lk,{entryType:A,componentConfig:_,componentType:y,children:x.jsx(gv,{onCopilotEvent:oe,children:x.jsx(ak,{children:x.jsx(tk,{children:x.jsx(ik,{children:x.jsx(Ek,{promptsConfig:se,children:x.jsx(hk,{apiKey:t,apiToken:n,baseUrl:r,customerId:s,tenantId:a,isDevelopment:b,entryType:A,onConnect:re,onRefinedSearch:xe,onRefinedBrowse:ae,onCopilotEvent:oe,children:ie})})})})})})})});var Sf={exports:{}},In={},xf={exports:{}},wf={};var g1;function yk(){return g1||(g1=1,(function(e){function t(Q,ie){var k=Q.length;Q.push(ie);e:for(;0<k;){var D=k-1>>>1,ee=Q[D];if(0<s(ee,ie))Q[D]=ie,Q[k]=ee,k=D;else break e}}function n(Q){return Q.length===0?null:Q[0]}function r(Q){if(Q.length===0)return null;var ie=Q[0],k=Q.pop();if(k!==ie){Q[0]=k;e:for(var D=0,ee=Q.length,I=ee>>>1;D<I;){var _e=2*(D+1)-1,Ue=Q[_e],ye=_e+1,Re=Q[ye];if(0>s(Ue,k))ye<ee&&0>s(Re,Ue)?(Q[D]=Re,Q[ye]=k,D=ye):(Q[D]=Ue,Q[_e]=k,D=_e);else if(ye<ee&&0>s(Re,k))Q[D]=Re,Q[ye]=k,D=ye;else break e}}return ie}function s(Q,ie){var k=Q.sortIndex-ie.sortIndex;return k!==0?k:Q.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,b=3,y=!1,_=!1,A=!1,v=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(Q){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=Q)r(f),ie.sortIndex=ie.expirationTime,t(d,ie);else break;ie=n(f)}}function U(Q){if(A=!1,C(Q),!_)if(n(d)!==null)_=!0,xe(Y);else{var ie=n(f);ie!==null&&ae(U,ie.startTime-Q)}}function Y(Q,ie){_=!1,A&&(A=!1,w(ne),ne=-1),y=!0;var k=b;try{for(C(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||Q&&!se());){var D=m.callback;if(typeof D=="function"){m.callback=null,b=m.priorityLevel;var ee=D(m.expirationTime<=ie);ie=e.unstable_now(),typeof ee=="function"?m.callback=ee:m===n(d)&&r(d),C(ie)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var _e=n(f);_e!==null&&ae(U,_e.startTime-ie),I=!1}return I}finally{m=null,b=k,y=!1}}var R=!1,q=null,ne=-1,me=5,V=-1;function se(){return!(e.unstable_now()-V<me)}function he(){if(q!==null){var Q=e.unstable_now();V=Q;var ie=!0;try{ie=q(!0,Q)}finally{ie?ve():(R=!1,q=null)}}else R=!1}var ve;if(typeof N=="function")ve=function(){N(he)};else if(typeof MessageChannel!="undefined"){var re=new MessageChannel,oe=re.port2;re.port1.onmessage=he,ve=function(){oe.postMessage(null)}}else ve=function(){v(he,0)};function xe(Q){q=Q,R||(R=!0,ve())}function ae(Q,ie){ne=v(function(){Q(e.unstable_now())},ie)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Q){Q.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,xe(Y))},e.unstable_forceFrameRate=function(Q){0>Q||125<Q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):me=0<Q?Math.floor(1e3/Q):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(Q){switch(b){case 1:case 2:case 3:var ie=3;break;default:ie=b}var k=b;b=ie;try{return Q()}finally{b=k}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Q,ie){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var k=b;b=Q;try{return ie()}finally{b=k}},e.unstable_scheduleCallback=function(Q,ie,k){var D=e.unstable_now();switch(typeof k=="object"&&k!==null?(k=k.delay,k=typeof k=="number"&&0<k?D+k:D):k=D,Q){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=k+ee,Q={id:p++,callback:ie,priorityLevel:Q,startTime:k,expirationTime:ee,sortIndex:-1},k>D?(Q.sortIndex=k,t(f,Q),n(d)===null&&Q===n(f)&&(A?(w(ne),ne=-1):A=!0,ae(U,k-D))):(Q.sortIndex=ee,t(d,Q),_||y||(_=!0,xe(Y))),Q},e.unstable_shouldYield=se,e.unstable_wrapCallback=function(Q){var ie=b;return function(){var k=b;b=ie;try{return Q.apply(this,arguments)}finally{b=k}}}})(wf)),wf}var E1;function Tk(){return E1||(E1=1,xf.exports=yk()),xf.exports}var y1;function bk(){if(y1)return In;y1=1;var e=fr(),t=Tk();function n(i){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)o+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function a(i,o){u(i,o),u(i+"Capture",o)}function u(i,o){for(s[i]=o,i=0;i<o.length;i++)r.add(o[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function b(i){return d.call(m,i)?!0:d.call(p,i)?!1:f.test(i)?m[i]=!0:(p[i]=!0,!1)}function y(i,o,l,h){if(l!==null&&l.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return h?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function _(i,o,l,h){if(o===null||typeof o=="undefined"||y(i,o,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function A(i,o,l,h,E,T,S){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=h,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=o,this.sanitizeURL=T,this.removeEmptyString=S}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){v[i]=new A(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var o=i[0];v[o]=new A(o,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){v[i]=new A(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){v[i]=new A(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){v[i]=new A(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){v[i]=new A(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){v[i]=new A(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){v[i]=new A(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){v[i]=new A(i,5,!1,i.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function N(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){v[i]=new A(i,1,!1,i.toLowerCase(),null,!1,!1)}),v.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){v[i]=new A(i,1,!1,i.toLowerCase(),null,!0,!0)});function C(i,o,l,h){var E=v.hasOwnProperty(o)?v[o]:null;(E!==null?E.type!==0:h||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(_(o,l,E,h)&&(l=null),h||E===null?b(o)&&(l===null?i.removeAttribute(o):i.setAttribute(o,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(o=E.attributeName,h=E.attributeNamespace,l===null?i.removeAttribute(o):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,h?i.setAttributeNS(h,o,l):i.setAttribute(o,l))))}var U=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y=Symbol.for("react.element"),R=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),ne=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),se=Symbol.for("react.context"),he=Symbol.for("react.forward_ref"),ve=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),oe=Symbol.for("react.memo"),xe=Symbol.for("react.lazy"),ae=Symbol.for("react.offscreen"),Q=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=Q&&i[Q]||i["@@iterator"],typeof i=="function"?i:null)}var k=Object.assign,D;function ee(i){if(D===void 0)try{throw Error()}catch(l){var o=l.stack.trim().match(/\n( *(at )?)/);D=o&&o[1]||""}return`
10
+ `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ns(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:a}=n;r!==void 0&&ll.assertOptions(r,{silentJSONParsing:hn.transitional(hn.boolean),forcedJSONParsing:hn.transitional(hn.boolean),clarifyTimeoutError:hn.transitional(hn.boolean),legacyInterceptorReqResOrdering:hn.transitional(hn.boolean),advertiseZstdAcceptEncoding:hn.transitional(hn.boolean),validateStatusUndefinedResolves:hn.transitional(hn.boolean)},!1),s!=null&&($.isFunction(s)?n.paramsSerializer={serialize:s}:ll.assertOptions(s,{encode:hn.function,serialize:hn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ll.assertOptions(n,{baseUrl:hn.spelling("baseURL"),withXsrfToken:hn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&$.merge(a.common,a[n.method]);a&&$.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete a[_]}),n.headers=fn.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(A){if(typeof A.runWhen=="function"&&A.runWhen(n)===!1)return;d=d&&A.synchronous;const v=n.transitional||cf;v&&v.legacyInterceptorReqResOrdering?c.unshift(A.fulfilled,A.rejected):c.push(A.fulfilled,A.rejected)});const f=[];this.interceptors.response.forEach(function(A){f.push(A.fulfilled,A.rejected)});let p,m=0,b;if(!d){const _=[Ig.bind(this),void 0];for(_.unshift(...c),_.push(...f),b=_.length,p=Promise.resolve(n);m<b;)p=p.then(_[m++],_[m++]);return p}b=c.length;let y=n;for(;m<b;){const _=c[m++],A=c[m++];try{y=_(y)}catch(v){A.call(this,v);break}}try{p=Ig.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,b=f.length;m<b;)p=p.then(f[m++],f[m++]);return p}getUri(t){t=ns(this.defaults,t);const n=Sg(t.baseURL,t.url,t.allowAbsoluteUrls,t);return fg(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){rs.prototype[t]=function(n,r){return this.request(ns(r||{},{method:t,url:n,data:r&&$.hasOwnProp(r,"data")?r.data:void 0}))}}),$.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(ns(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}rs.prototype[t]=n(),t!=="query"&&(rs.prototype[t+"Form"]=n(!0))});let ev=class R2{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(s=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](s);r._listeners=null}),this.promise.then=s=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(s);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new fa(a,u,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new R2(function(s){t=s}),cancel:t}}};function tv(e){return function(n){return e.apply(null,n)}}function nv(e){return $.isObject(e)&&e.isAxiosError===!0}const Ef={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ef).forEach(([e,t])=>{Ef[t]=e});function Lg(e){const t=new rs(e),n=X0(rs.prototype.request,t);return $.extend(n,rs.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Lg(ns(e,s))},n}const Rt=Lg(da);Rt.Axios=rs,Rt.CanceledError=fa,Rt.CancelToken=ev,Rt.isCancel=Eg,Rt.VERSION=pf,Rt.toFormData=il,Rt.AxiosError=be,Rt.Cancel=Rt.CanceledError,Rt.all=function(t){return Promise.all(t)},Rt.spread=tv,Rt.isAxiosError=nv,Rt.mergeConfig=ns,Rt.AxiosHeaders=fn,Rt.formToJSON=e=>gg($.isHTMLForm(e)?new FormData(e):e),Rt.getAdapter=Og.getAdapter,Rt.HttpStatusCode=Ef,Rt.default=Rt;const{Axios:D7,AxiosError:M7,CanceledError:F7,isCancel:B7,CancelToken:U7,VERSION:H7,all:z7,Cancel:j7,isAxiosError:$7,spread:V7,toFormData:q7,AxiosHeaders:Y7,HttpStatusCode:G7,formToJSON:W7,getAdapter:X7,mergeConfig:K7,create:Q7}=Rt;class rv{constructor(t,n,r,s=!1,a,u){Se(this,"CIMULATE_API_HEADER","x-cimulate-api-key");Se(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");Se(this,"CIMULATE_SEARCH_API_PATH","api/v1");Se(this,"baseApiUrl");Se(this,"headers",{});Se(this,"fetchConfig",()=>Ke(this,null,function*(){try{const t=yield Rt.get(`${this.apiUrl}/configs/copilot`,{headers:this.headers}),{customer_config:n}=t.data,r=atob(n);return JSON.parse(r)}catch(t){throw console.error("Error fetching customer config:",t),t}}));Se(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const s=new URL(t);return s.hostname=s.hostname.replace(/^copilot\./,"api."),s.origin}return n?`https://staging.${this.CIMULATE_SEARCH_API_HOST}.ai`:`https://prod.${this.CIMULATE_SEARCH_API_HOST}.ai`});if(n&&r||!n&&!r)throw new Error("Provide exactly one authentication method: either 'apiKey' or 'apiToken', but not both.");n?this.headers[this.CIMULATE_API_HEADER]=n:r&&(this.headers.Authorization=`Bearer ${r}`),a&&(this.headers["x-cimulate-customer-id"]=a),u&&(this.headers["Tenant-ID"]=u),this.baseApiUrl=this._mapCopilotUrlToSearchUrl(t,s)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class iv{constructor(t,n,r,s=!1,a,u){Se(this,"apiService");Se(this,"config",null);Se(this,"getConfig",()=>Ke(this,null,function*(){if(this.config)return this.config;try{const t=yield this.apiService.fetchConfig();return this.config=t,this.config}catch(t){throw console.error("Failed to fetch customer config:",t),t}}));Se(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));Se(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));Se(this,"getDescription",t=>this.getProductFieldValue(t,"description"));Se(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));Se(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));Se(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));Se(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));Se(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));Se(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});Se(this,"getProductField",t=>this.config?this.config[t]:"");Se(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new rv(t,n,r,s,a,u)}getPriceDisplay(t){const n=this.getPrice(t);return n?typeof n=="string"?n.includes("$")?n:`$${n}`:typeof n=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(n):n:""}}const Ws=(e,t,n,...r)=>{if(!e)return;const s=["background: linear-gradient(90deg,rgba(253, 99, 99, 1) 0%, rgba(245, 139, 35, 1) 65%)","font-weight: bold","color: transparent","background-clip: text","text-fill-color: transparent"].join(";");console[t]("%c[cimulate-widget]",s,n,...r)};class sv{constructor(t=!1){Se(this,"isDevelopment");Se(this,"_log",(t,n,...r)=>{Ws(this.isDevelopment,t,n,...r)});this.isDevelopment=t}log(t,...n){this._log("log",t,...n)}warn(t,...n){this._log("warn",t,...n)}error(t,...n){this._log("error",t,...n)}info(t,...n){this._log("info",t,...n)}debug(t,...n){this._log("debug",t,...n)}}const ov={copilot:"Your Search Assistant",messaging:"Commerce Client"},Dg=B.createContext(null),av=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:s="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:b,searchConfig:y,suggestionButtonConfig:_,progressStepsLimit:A=3,messageAlignment:v="start",autoScroll:w=!0,showProductDescription:N=!1,componentConfig:C,conversationHistory:U,resetConversationMessage:Y="",apiKey:R,apiToken:q,baseUrl:ne,customerId:me,tenantId:V,theme:se,isDevelopment:he,__features:ve,routingAttributes:re,enableDownloadTranscript:oe=!0,enableEscalationToAgent:xe=!1,showProductCaptions:ae=!1,children:Q})=>{const ie=e==="messaging",k=B.useMemo(()=>{const Re=re==null?void 0:re.isCartMgmtSupported;return Re===!0||Re==="true"},[re]),D=B.useMemo(()=>ie?{config:null}:new iv(ne,R,q,he,me,V),[ie,ne,R,q,he,me,V]),ee=B.useMemo(()=>new sv(he),[he]);B.useEffect(()=>{ie||!D||D.config||D.getConfig()},[D,ie]);const I=B.useMemo(()=>cA(se),[se]),_e=B.useMemo(()=>{const Re=(y==null?void 0:y.placeholder)||m,He=(y==null?void 0:y.buttonLabel)||b;let Ye="icon";return y!=null&&y.buttonType?Ye=y.buttonType:b&&(Ye="text"),de(F({},y||{}),{placeholder:Re,buttonLabel:He,buttonType:Ye})},[y,m,b]),Ue=B.useMemo(()=>de(F({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||ov[e!=null?e:"copilot"]}),[r,t,n,e]),ye=B.useMemo(()=>({configModule:D,mode:e!=null?e:"copilot",headerConfig:Ue,entryMessage:a,globalClassName:s,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,themeVariables:I,logger:ee,searchConfig:_e,suggestionButtonConfig:_,progressStepsLimit:A,messageAlignment:v,autoScroll:w,showProductDescription:!!N,enableMinimize:!!(C!=null&&C.enableMinimize),enableDownloadTranscript:oe,enableEscalationToAgent:xe,showProductCaptions:!!ae,resetConversationMessage:Y,conversationHistory:{sinceHours:typeof(U==null?void 0:U.sinceHours)=="number"?U.sinceHours:1,limit:U==null?void 0:U.limit},features:ve,isCartMgmtSupported:k}),[D,e,Ue,a,s,f,p,c,d,u,_e,_,v,w,N,C,oe,xe,ae,Y,ee,I,U,ve,k]);return x.jsx(Dg.Provider,{value:ye,children:Q})},tt=()=>{const e=B.useContext(Dg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};class uv{constructor(){Se(this,"initialState",{connected:!1,mode:"embedded",entryType:"search",status:{type:"dialog",isOpen:!1,isMinimized:!1},dialog:{position:"bottom-left",isFullHeight:!1,width:""},modal:{isFullscreen:!1}});Se(this,"connectedProxy");Se(this,"modeProxy");Se(this,"entryTypeProxy");Se(this,"statusProxy");Se(this,"dialogProxy");Se(this,"modalProxy",{isFullscreen:!1});Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return dv(n,r),Reflect.set(t,n,r)});this.connectedProxy=new Proxy({connected:this.initialState.connected},{get:this._fullGet,set:this._fullSet}),this.modeProxy=new Proxy({mode:this.initialState.mode},{get:this._fullGet,set:this._fullSet}),this.entryTypeProxy=new Proxy({entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.statusProxy=new Proxy({type:this.initialState.status.type,isOpen:this.initialState.status.isOpen,isMinimized:this.initialState.status.isMinimized},{get:this._fullGet,set:this._fullSet}),this.dialogProxy=new Proxy({position:this.initialState.dialog.position,isFullHeight:this.initialState.dialog.isFullHeight,width:this.initialState.dialog.width},{get:this._fullGet,set:this._fullSet}),this.modalProxy=new Proxy({isFullscreen:this.initialState.modal.isFullscreen},{get:this._fullGet,set:this._fullSet})}get connected(){return this.connectedProxy.connected}get mode(){return this.modeProxy.mode}get isOpen(){return!!this.statusProxy.isOpen}get isMinimized(){return!!this.statusProxy.isMinimized}get type(){return this.statusProxy.type}get entryType(){return this.entryTypeProxy.entryType}get position(){return this.dialogProxy.position}get state(){return{connected:this.connected,mode:this.mode,entryType:this.entryType,status:{type:this.type,isOpen:this.isOpen,isMinimized:this.isMinimized},dialog:{position:this.position,isFullHeight:this.dialogProxy.isFullHeight,width:this.dialogProxy.width},modal:{isFullscreen:this.modalProxy.isFullscreen}}}}const Je=new uv,is=()=>Je.connected,ha=()=>Je.isOpen,lv=e=>{window.addEventListener(Zd,e)},cv=e=>{window.removeEventListener(Zd,e)},dv=(e,t)=>{const n=new CustomEvent(Zd,{detail:{property:e,value:t}});window.dispatchEvent(n)},fv=e=>{Je.connectedProxy.connected=e},pa=e=>{if(!sA(e)){const t=q0.map(r=>`'${r}'`),n=`${t.slice(0,-1).join(", ")}, or ${t[t.length-1]}`;throw new Error(`Invalid entryType: "${e}". Must be ${n}.`)}Je.entryTypeProxy.entryType=e},ti=e=>{const t=Je.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;Je.statusProxy.isOpen=n,n&&(Je.statusProxy.isMinimized=!1)},cl=e=>{const t=Je.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;Je.statusProxy.isMinimized=n,n&&(Je.statusProxy.isOpen=!1)},yf=e=>{Je.modalProxy.isFullscreen=e},dl=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);Je.statusProxy.type=e,e==="dialog"||e==="chat"?Je.modeProxy.mode="embedded":Je.modeProxy.mode="standalone"},Tf=e=>{const t=["top","top-left","top-right","bottom","bottom-left","bottom-right","left","right","center"];if(!t.includes(e))throw new Error(`Invalid position: ${e}. Must be one of ${t.join(", ")}.`);Je.dialogProxy.position=e},hv=e=>{const t=Je.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;Je.dialogProxy.isFullHeight=n},pv=({onCopilotEvent:e,children:t,dispatch:n})=>{const{logger:r}=tt(),s=B.useCallback(C=>{n({type:pt.SET_COPILOT,payload:C})},[n]),a=B.useCallback(C=>{fv(C),n({type:pt.SET_CONNECTED,payload:C})},[n]),u=B.useCallback(()=>{n({type:pt.RESET_COPILOT,payload:{}})},[n]),c=B.useCallback(()=>{n({type:pt.RESET_STATE,payload:{}})},[n]),d=B.useCallback(C=>{r==null||r.log(`${C.name} event received`,C),n({type:pt.ADD_MESSAGE,payload:C}),C.bypassHandlers||e==null||e(C)},[e,r,n]),f=B.useCallback(C=>{n({type:pt.ADD_LOADING_MESSAGE,payload:C})},[n]),p=B.useCallback(C=>{n({type:pt.REMOVE_LOADING_MESSAGE,payload:C})},[n]),m=B.useCallback(C=>{d(C),f(C.id)},[d,f]),b=B.useCallback(C=>{n({type:pt.SET_ACTIVE_CONVERSATION_ID,payload:C})},[n]),y=B.useCallback(C=>{n({type:pt.ADD_CONVERSATION_ID,payload:C})},[n]),_=B.useCallback(C=>{n({type:pt.SET_CONVERSATION_IDS,payload:C})},[n]),A=B.useCallback(C=>{n({type:pt.SET_IMAGE_FILE,payload:C})},[n]),v=B.useCallback(C=>{n({type:pt.SET_ASK_CIM_PROMPTS,payload:C})},[n]),w=B.useCallback(C=>{n({type:pt.SET_CONVERSATION_HISTORY_LOADED,payload:C})},[n]),N=B.useMemo(()=>({setCopilot:s,setConnected:a,resetCopilot:u,resetCopilotState:c,addCopilotEvent:d,addLoadingMessage:f,removeLoadingMessage:p,handleCopilotRequestAck:m,setActiveConversationId:b,addConversationId:y,setConversationIds:_,setImageFile:A,setAskCimPrompts:v,setConversationHistoryLoaded:w}),[s,a,u,c,d,f,p,m,b,y,_,A,v,w]);return x.jsx(W0.Provider,{value:N,children:t})};nA();const mv=(e,t)=>{const{type:n,payload:r}=t;if(n===pt.ADD_MESSAGE){const s=r;if(e.messages.push(s),s.eventSourceId){const a=e.groupedMessages.findIndex(u=>u.eventSourceId===s.eventSourceId);if(a!==-1){let u=e.groupedMessages[a].messages;u||(u=[]);const c=u.findIndex(d=>d.id===s.id);if(c!==-1){u[c]=s;return}u.push(s);return}else{e.groupedMessages.push({type:"group",eventSourceId:s.eventSourceId,messages:[s],createdAt:new Date(s.createdAt)});return}}e.groupedMessages.push({type:"individual",message:s,createdAt:new Date(s.createdAt)});return}switch(n){case pt.RESET_STATE:e.messages=Zi.messages,e.groupedMessages=Zi.groupedMessages,e.loadingMessages=Zi.loadingMessages,e.imageFile=Zi.imageFile,e.askCimPrompts=Zi.askCimPrompts,e.conversationHistoryLoaded=Zi.conversationHistoryLoaded;break;case pt.RESET_COPILOT:e.copilot=null;break;case pt.SET_COPILOT:e.copilot=r;break;case pt.SET_CONNECTED:e.connected=r;break;case pt.ADD_LOADING_MESSAGE:e.loadingMessages.add(r);break;case pt.REMOVE_LOADING_MESSAGE:e.loadingMessages.delete(r);break;case pt.SET_ACTIVE_CONVERSATION_ID:e.activeConversationId=r;break;case pt.ADD_CONVERSATION_ID:{const s=r;e.conversationIds.includes(s)||e.conversationIds.push(s)}break;case pt.SET_CONVERSATION_IDS:e.conversationIds=r;break;case pt.SET_IMAGE_FILE:e.imageFile=r;break;case pt.SET_ASK_CIM_PROMPTS:e.askCimPrompts.requestId=(r==null?void 0:r.requestId)||null,e.askCimPrompts.message=(r==null?void 0:r.message)||null;break;case pt.SET_CONVERSATION_HISTORY_LOADED:e.conversationHistoryLoaded=r;break}},gv=({onCopilotEvent:e,children:t})=>{const[n,r]=$0(mv,Zi);return x.jsx(G0.Provider,{value:n,children:x.jsx(pv,{onCopilotEvent:e,dispatch:r,children:t})})};function Ev(){var e=B.useRef(!0);return e.current?(e.current=!1,!0):e.current}function yv(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function Tv(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var bf=typeof window!="undefined",ma=function(e){B.useEffect(e,[])},bv=function(e){var t=B.useRef(e);t.current=e,ma(function(){return function(){return t.current()}})},_v=function(e){var t=B.useRef(0),n=B.useState(e),r=n[0],s=n[1],a=B.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){s(u)})},[]);return bv(function(){cancelAnimationFrame(t.current)}),[r,a]},Sv=function(e,t){return e===t};function xv(e,t){t===void 0&&(t=Sv);var n=B.useRef(),r=B.useRef(e),s=Ev();return!s&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var wv=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,s=t.initialHeight,a=s===void 0?1/0:s,u=t.onChange,c=_v({width:bf?window.innerWidth:r,height:bf?window.innerHeight:a}),d=c[0],f=c[1];return B.useEffect(function(){if(bf){var p=function(){var m=window.innerWidth,b=window.innerHeight;f({width:m,height:b}),u&&u(m,b)};return yv(window,"resize",p),function(){Tv(window,"resize",p)}}},[]),d};class Av{constructor(){Se(this,"items",[]);Se(this,"add",t=>{const n=this.first();n&&n.context===t.context&&this.remove(),this.items.push(t)});Se(this,"remove",()=>this.items.shift());Se(this,"first",()=>this.items.length>0?this.items[0]:null);Se(this,"clear",()=>{this.items.length=0});Se(this,"processQueue",t=>{new Array(pn.size).fill(1).forEach(()=>{const r=pn.first();r&&(t(r),pn.remove())})})}get size(){return this.items.length}}const pn=new Av,Mg=e=>{window.addEventListener(Jd,e)},Fg=e=>{window.removeEventListener(Jd,e)},Cv=(e,t,n)=>{const r=new CustomEvent(Jd,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Bg=e=>{window.addEventListener(Qd,e)},Ug=e=>{window.removeEventListener(Qd,e)},vv=(e,t,n)=>{const r=new CustomEvent(Qd,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Hg=e=>{window.addEventListener(Kd,e)},zg=e=>{window.removeEventListener(Kd,e)},jg=(e,t,n)=>{const r=new CustomEvent(Kd,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)},kv=e=>{window.addEventListener(tf,e)},Nv=e=>{window.removeEventListener(tf,e)},fl=(e,t,n)=>{const r=new CustomEvent(tf,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)};class Pv{constructor(){Se(this,"initialParams",{categoryId:"",categoryName:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});Se(this,"categoryIdProxy");Se(this,"facetFiltersProxy");Se(this,"rangeFiltersProxy");Se(this,"catalogSegmentProxy");Se(this,"pricebooksProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{const s=uA[n];return vv(s,n,r),Reflect.set(t,n,r)});Se(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.categoryIdProxy=new Proxy({categoryId:this.initialParams.categoryId,categoryName:this.initialParams.categoryName},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get categoryId(){return this.categoryIdProxy.categoryId||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{categoryId:this.categoryId,categoryName:this.categoryIdProxy.categoryName,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const at=new Pv,$g=(e,t)=>{const n=t.updateFacetFiltersProxy(e);t.facetFiltersProxy.facetFilters=n.facetFilters},Vg=(e,t,n)=>{var u,c;const r=F({},((u=n.facetFiltersProxy)==null?void 0:u.facetFilters)||{});if(!!((c=r[e])!=null&&c.includes(t))){const d=r[e].filter(f=>f!==t);d.length>0?r[e]=d:delete r[e]}else r[e]=r[e]?[...r[e],t]:[t];const a=n.updateFacetFiltersProxy(r);n.facetFiltersProxy.facetFilters=a.facetFilters},qg=(e,t)=>{const n=t.updateRangeFiltersProxy(e);t.rangeFiltersProxy.rangeFilters=n.rangeFilters},Yg=({field:e,value:t},n)=>{const[r,s]=Array.isArray(t)?t:[];if(typeof r=="undefined"||typeof s=="undefined")throw new Error("Range values must be an array with two numbers for min and max");const a=[...n.rangeFiltersProxy.rangeFilters||[]],u=a.findIndex(d=>d.field===e);if(u!==-1){a[u]={field:e,min:r,max:s},n.rangeFiltersProxy.rangeFilters=a;return}a.push({field:e,min:r,max:s});const c=n.updateRangeFiltersProxy(a);n.rangeFiltersProxy.rangeFilters=c.rangeFilters},Gg=(e,t)=>{t.catalogSegmentProxy.catalogSegment=e},Wg=(e,t)=>{const n=t.updatePricebooksProxy(e);t.pricebooksProxy.pricebooks=n.pricebooks},Ov=e=>{if(!is()||!ha()){is()&&pn.clear(),pn.add({context:"browse",payload:de(F({},at.state),{categoryId:e})});return}at.categoryIdProxy.categoryId=e},Xg=e=>{$g(e,at)},Iv=(e,t)=>{Vg(e,t,at)},Kg=e=>{qg(e,at)},Rv=({field:e,value:t})=>{Yg({field:e,value:t},at)},Lv=e=>{Gg(e,at)},Qg=e=>{Wg(e,at)},Jg=e=>{if(!e||!("categoryId"in e))throw new Error("Browse context must include a categoryId");const t=is(),n=ha();if(!t||!n){t&&pn.clear(),pn.add({context:"browse",payload:F({},e)});return}"facetFilters"in e&&Xg(e.facetFilters||{}),"rangeFilters"in e&&Kg(e.rangeFilters||[]),"catalogSegment"in e&&(at.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&Qg(e.pricebooks||[]),"categoryName"in e&&(at.categoryIdProxy.categoryName=e.categoryName||""),at.categoryIdProxy.categoryId=e.categoryId},Dv=Object.freeze(Object.defineProperty({__proto__:null,setBrowseContext:Jg,updateBrowseCategoryId:Ov,updateCatalogSegment:Lv,updateFacetFilter:Iv,updateFacetFilters:Xg,updatePricebooks:Qg,updateRangeFilter:Rv,updateRangeFilters:Kg},Symbol.toStringTag,{value:"Module"}));class Mv{constructor(){Se(this,"initialParams",{productId:"",productName:"",pdpLink:""});Se(this,"proxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>(jg(n,r),Reflect.set(t,n,r)));Se(this,"updateProxy",t=>{t.productId&&(this.proxy=new Proxy({productId:t.productId,productName:t.productName||"",pdpLink:t.pdpLink||""},{get:this._fullGet,set:this._fullSet}))});this.proxy=new Proxy({productId:this.initialParams.productId,productName:this.initialParams.productName,pdpLink:this.initialParams.pdpLink},{get:this._fullGet,set:this._fullSet})}get productId(){return this.proxy.productId}get pdpLink(){return this.proxy.pdpLink}get state(){return{productId:this.productId,productName:this.proxy.productName,pdpLink:this.pdpLink}}}const mr=new Mv,Zg=e=>{if(!e||!e.productId)throw new Error("PDP context must include a productId");const t=is(),n=ha();if(!t||!n){t&&pn.clear(),pn.add({context:"pdp",payload:F({},e)});return}mr.updateProxy(e),jg("pdp-context",e)},Fv=e=>{mr.proxy.productId=e,is()||pn.add({context:"pdp",payload:F({},mr.state)})},Bv=e=>{mr.proxy.pdpLink=e},mt={SET_PROMPTS_EXTENSION_INITIALIZED:"SET_PROMPTS_EXTENSION_INITIALIZED",SET_PROMPTS_EXTENSION_OPEN:"SET_PROMPTS_EXTENSION_OPEN",SET_PROMPTS_EXTENSION_INLINE:"SET_PROMPTS_EXTENSION_INLINE",SET_PROMPTS_EXTENSION_ELEMENT_ID:"SET_PROMPTS_EXTENSION_ELEMENT_ID",SET_PROMPTS_EXTENSION_ENTRY_TYPE:"SET_PROMPTS_EXTENSION_ENTRY_TYPE",SET_PROMPTS_EXTENSION_PARAMS:"SET_PROMPTS_EXTENSION_PARAMS",RESET_PROMPTS_EXTENSION_PARAMS:"RESET_PROMPTS_EXTENSION_PARAMS",SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",SET_PROMPTS_EXTENSION_USER_PROMPT:"SET_PROMPTS_EXTENSION_USER_PROMPT",SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_LOADING:"SET_PROMPTS_EXTENSION_RESPONSE_LOADING"},e1={isInitialized:!1,isOpen:!1,isInline:!1,elementId:null,placeholder:null,askElseButtonLabel:null,entryType:null,params:null,activePromptsId:null,userPrompt:null,promptsMessage:null,isResponseLoading:!1,responseMessage:null,promptsDisplay:"both",staticQuestions:[],staticQuestionsStrategy:"append",disableAskElseButton:!1};class Uv{constructor(){Se(this,"initialState",e1);Se(this,"promptsStateProxy");Se(this,"promptsParamsProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on PromptsExtensionState`);return ga(n,r),Reflect.set(t,n,r)});Se(this,"_paramsFullGet",(t,n)=>Reflect.get(t,n));Se(this,"_paramsFullSet",(t,n,r)=>Reflect.set(t,n,r));Se(this,"updatePromptsParamsProxy",t=>new Proxy(F({},t),{get:this._paramsFullGet,set:this._paramsFullSet}));this.promptsStateProxy=new Proxy({isOpen:this.initialState.isOpen,isInline:this.initialState.isInline,elementId:this.initialState.elementId,entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.promptsParamsProxy=this.updatePromptsParamsProxy({})}get isOpen(){return this.promptsStateProxy.isOpen}get isInline(){return this.promptsStateProxy.isInline}get state(){return{isOpen:this.isOpen,isInline:this.isInline}}get params(){return this.promptsParamsProxy}}const Bt=new Uv,Hv=e=>{window.addEventListener(ef,e)},zv=e=>{window.removeEventListener(ef,e)},ga=(e,t)=>{const n=new CustomEvent(ef,{detail:{property:e,value:t}});window.dispatchEvent(n)},t1=e=>{const t=Bt.isOpen,n=typeof e=="boolean"?e:!t;Bt.promptsStateProxy.isOpen=n},n1=e=>{const t=Bt.isInline,n=typeof e=="boolean"?e:!t;Bt.promptsStateProxy.isInline=n},jv=e=>{Bt.promptsParamsProxy=Bt.updatePromptsParamsProxy(e),ga("params",e),Bt.promptsStateProxy.entryType="ask_cim"},$v=e=>{Bt.promptsParamsProxy=Bt.updatePromptsParamsProxy(e),ga("params",e),Bt.promptsStateProxy.entryType="search"},Vv=e=>{Bt.promptsParamsProxy=Bt.updatePromptsParamsProxy(e),ga("params",e),Bt.promptsStateProxy.entryType="browse"},qv=e=>{Bt.promptsParamsProxy=Bt.updatePromptsParamsProxy(e),ga("params",e),Bt.promptsStateProxy.entryType="pdp"},Yv=({elementId:e,entryType:t,params:n,isInline:r})=>{Bt.promptsStateProxy.elementId=e,t&&(Bt.promptsStateProxy.entryType=t),typeof r=="boolean"&&n1(r),n&&Bt.updatePromptsParamsProxy(n),Bt.isOpen||t1(!0)},Gv=Object.freeze(Object.defineProperty({__proto__:null,getConversationMessages:({payload:e,callback:t})=>{fl("getConversationMessages",{payload:e,callback:t},bi.GET_CONVERSATION_MESSAGES)},getSessionInformation:e=>{fl("getSessionInformation",{callback:e},bi.GET_SESSION_INFORMATION)},loadConversation:e=>{fl("loadConversation",e,bi.LOAD_CONVERSATION)},resetConversation:()=>{fl("resetConversation",!0,bi.RESET_CONVERSATION)}},Symbol.toStringTag,{value:"Module"}));class Wv{constructor(){Se(this,"initialParams",{query:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});Se(this,"queryProxy");Se(this,"facetFiltersProxy");Se(this,"rangeFiltersProxy");Se(this,"catalogSegmentProxy");Se(this,"pricebooksProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{const s=lA[n];return Cv(s,n,r),Reflect.set(t,n,r)});Se(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.queryProxy=new Proxy({query:this.initialParams.query},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get query(){return this.queryProxy.query||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{query:this.query,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const Tt=new Wv,Xv=e=>{const t=ha(),n=is();if(!n||!t){n&&pn.clear(),pn.add({context:"search",payload:de(F({},Tt.state),{query:e})});return}Tt.queryProxy.query=e},r1=e=>{$g(e,Tt)},Kv=(e,t)=>{Vg(e,t,Tt)},i1=e=>{qg(e,Tt)},Qv=({field:e,value:t})=>{Yg({field:e,value:t},Tt)},Jv=e=>{Gg(e,Tt)},s1=e=>{Wg(e,Tt)},o1=e=>{if(!e||!e.query)throw new Error("Search context must include a query");const t=ha(),n=is();if(!n||!t){n&&pn.clear(),pn.add({context:"search",payload:F({},e)});return}"facetFilters"in e&&r1(e.facetFilters||{}),"rangeFilters"in e&&i1(e.rangeFilters||[]),"catalogSegment"in e&&(Tt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&s1(e.pricebooks||[]),Tt.queryProxy.query=e.query},Zv=Object.freeze(Object.defineProperty({__proto__:null,setSearchContext:o1,updateCatalogSegment:Jv,updateFacetFilter:Kv,updateFacetFilters:r1,updatePricebooks:s1,updateRangeFilter:Qv,updateRangeFilters:i1,updateSearchQuery:Xv},Symbol.toStringTag,{value:"Module"})),ek={categoryId:at.categoryId,categoryName:at.categoryIdProxy.categoryName||"",facetFilters:at.facetFilters,rangeFilters:at.rangeFilters,catalogSegment:at.catalogSegment,pricebooks:at.pricebooks},a1=B.createContext(ek),tk=({children:e})=>{const[t,n]=B.useState(at.categoryId),[r,s]=B.useState(at.categoryIdProxy.categoryName||""),[a,u]=B.useState(at.facetFilters||{}),[c,d]=B.useState(at.rangeFilters||[]),[f,p]=B.useState(at.catalogSegment||null),[m,b]=B.useState(at.pricebooks||null);B.useEffect(()=>{const _=({detail:A})=>{(A==null?void 0:A.property)==="categoryId"&&n(A.value),(A==null?void 0:A.property)==="categoryName"&&s(A.value),(A==null?void 0:A.property)==="facetFilters"&&u(A.value),(A==null?void 0:A.property)==="rangeFilters"&&d(A.value),(A==null?void 0:A.property)==="catalogSegment"&&p(A.value),(A==null?void 0:A.property)==="pricebooks"&&b(A.value)};return Bg(_),()=>{Ug(_)}},[]);const y=B.useMemo(()=>({categoryId:t,categoryName:r,facetFilters:a,rangeFilters:c,catalogSegment:f,pricebooks:m}),[t,r,a,c,f,m]);return x.jsx(a1.Provider,{value:y,children:e})},nk=()=>{const e=B.useContext(a1);if(!e)throw new Error("useBrowse must be used within a BrowseProvider");return e},rk={searchQuery:Tt.query,facetFilters:Tt.facetFilters,rangeFilters:Tt.rangeFilters,catalogSegment:Tt.catalogSegment,pricebooks:Tt.pricebooks},u1=B.createContext(rk),ik=({children:e})=>{const[t,n]=B.useState(Tt.query),[r,s]=B.useState(Tt.facetFilters),[a,u]=B.useState(Tt.rangeFilters),[c,d]=B.useState(Tt.catalogSegment),[f,p]=B.useState(Tt.pricebooks);B.useEffect(()=>{const b=({detail:y})=>{(y==null?void 0:y.property)==="query"&&n(y.value),(y==null?void 0:y.property)==="facetFilters"&&s(y.value),(y==null?void 0:y.property)==="rangeFilters"&&u(y.value),(y==null?void 0:y.property)==="catalogSegment"&&d(y.value),(y==null?void 0:y.property)==="pricebooks"&&p(y.value)};return Mg(b),()=>{Fg(b)}},[]);const m=B.useMemo(()=>({searchQuery:t,facetFilters:r,rangeFilters:a,catalogSegment:c,pricebooks:f}),[t,r,a,c,f]);return x.jsx(u1.Provider,{value:m,children:e})},sk=()=>{const e=B.useContext(u1);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e},ok={productId:mr.productId,pdpLink:mr.pdpLink},l1=B.createContext(ok),ak=({children:e})=>{const[t,n]=B.useState(mr.productId),[r,s]=B.useState(mr.pdpLink);B.useEffect(()=>{const u=({detail:c})=>{if((c==null?void 0:c.property)==="pdp-context"){const d=c.value;n(d.productId),s(d.pdpLink);return}(c==null?void 0:c.property)==="productId"&&n(c.value),(c==null?void 0:c.property)==="pdpLink"&&s(c.value)};return Hg(u),()=>{zg(u)}},[]);const a=B.useMemo(()=>({productId:t,pdpLink:r}),[t,r]);return x.jsx(l1.Provider,{value:a,children:e})},uk=()=>{const e=B.useContext(l1);if(!e)throw new Error("usePdp must be used within a PdpProvider");return e},c1=B.createContext({mode:Je.modeProxy.mode,entryType:Je.entryType,status:Je.statusProxy,dialogPosition:Je.dialogProxy.position,isDialogFullHeight:Je.dialogProxy.isFullHeight,dialogWidth:Je.dialogProxy.width,isModalFullscreen:Je.modalProxy.isFullscreen,previousComponentType:Je.statusProxy.type}),lk=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[s,a]=B.useState(e!=null?e:Je.entryTypeProxy.entryType),[u,c]=B.useState(Je.modeProxy.mode),[d,f]=B.useState({type:n||Je.statusProxy.type,isOpen:t&&"isOpen"in t?!!t.isOpen:Je.statusProxy.isOpen,isMinimized:t&&"isMinimized"in t?!!t.isMinimized:Je.statusProxy.isMinimized}),[p,m]=B.useState(Je.dialogProxy.position),[b,y]=B.useState(Je.dialogProxy.isFullHeight),[_,A]=B.useState(Je.dialogProxy.width),[v,w]=B.useState(Je.modalProxy.isFullscreen),N=xv(d.type);B.useEffect(()=>{const U=Y=>{const{property:R,value:q}=Y.detail||{};if(!(!R||q===void 0)){if(R==="mode"){c(q);return}if(R==="entryType"){a(q);return}if(R==="isMinimized"){f(ne=>de(F({},ne),{isMinimized:q}));return}if(R==="isOpen"){f(ne=>de(F({},ne),{isOpen:q}));return}if(R==="type"){f(ne=>de(F({},ne),{type:q}));return}if(R==="position"){m(q);return}if(R==="isFullHeight"){y(q);return}if(R==="width"){A(q);return}if(R==="isFullscreen"){w(q);return}}};return lv(U),()=>{cv(U)}},[]),ma(()=>{e&&pa(e)}),ma(()=>{const U=n||(t==null?void 0:t.type);U&&dl(U),t&&"isOpen"in t&&ti(!!t.isOpen),t&&"isMinimized"in t&&cl(!!t.isMinimized)}),ma(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:U}=t.options;U&&Tf(U),"dialogFullHeight"in t.options&&hv(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&A(t.options.dialogWidth),"isModalFullscreen"in t.options&&yf(!!t.options.isModalFullscreen)});const C=B.useMemo(()=>({mode:u,entryType:s,status:d,previousComponentType:N||"dialog",dialogPosition:p,isDialogFullHeight:b,dialogWidth:_,isModalFullscreen:v}),[u,s,d,N,p,b,_,v]);return x.jsx(c1.Provider,{value:C,children:r})},er=()=>{const e=B.useContext(c1);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e},d1=B.createContext(null),f1=B.createContext(null),_f=()=>{const e=B.useContext(f1);if(!e)throw new Error("usePromptsExtensionDispatch must be used within a PromptsExtensionProvider");return e||{}},ni=()=>{const e=B.useContext(d1);if(!e)throw new Error("usePromptsExtensionState must be used within a PromptsExtensionProvider");return e||{}},Xs=()=>{const e=B.useContext(W0);if(!e)throw new Error("useCopilotDispatch must be used within a CopilotProvider");return e},tr=()=>{const e=B.useContext(G0);if(!e)throw new Error("useCopilotState must be used within a CopilotProvider");return e},ck=({copilot:e})=>{const{logger:t,conversationHistory:n}=tt(),{isInline:r}=ni(),{addCopilotEvent:s,setConversationHistoryLoaded:a}=Xs(),{activeConversationId:u}=tr(),c=B.useCallback(f=>{e&&e.requestSessionInformation(p=>{t==null||t.log("Retrieved session information: ",p),f==null||f(p)})},[e,t]),d=B.useCallback((f,p)=>{e&&f.conversationId&&e.getConversationEvents(f,m=>{t==null||t.log("Retrieved conversation messages: ",m),p==null||p(m)})},[e,t]);return B.useEffect(()=>{if(r||!u)return;if(n.sinceHours===0||(n==null?void 0:n.limit)===0){a(!0);return}const f=3600*1e3*n.sinceHours,p=new Date(Date.now()-f).toISOString(),m={conversationId:u,since:p,excludeEvents:["done","error","connection_error","refined_browse","refined_search","conversation_reset"]};typeof n.limit=="number"&&(m.limit=n.limit),d(m,b=>{const y=[];[...b.reverse()||[]].forEach(A=>{var w;const v=b.find(N=>N.id===A.eventSourceId);(w=v==null?void 0:v.name)!=null&&w.endsWith("_suggestions")||(A.bypassHandlers=!0,y.unshift(A))}),y.forEach(A=>{s(A)}),a(!0)})},[t,r,u,d,s,a,n]),{getSessionInformation:c,getConversationMessages:d}},h1=B.createContext({copilot:null,messages:[],groupedMessages:[],isLoading:!1,isResponseLoading:()=>!1,handleAskCim:()=>{},handleSearch:()=>{},handleBrowse:()=>{},handlePdp:()=>{},handleSuggestion:()=>{},handleUserInput:()=>{},handleCancel:()=>{},resetConversation:()=>{},getSessionInformation:()=>{},getConversationMessages:()=>{}}),dk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>{const{logger:p,clientContext:m,baseCatalogParams:b}=tt(),on=sk(),{searchQuery:y}=on,_=dn(on,["searchQuery"]),Fn=nk(),{categoryId:A}=Fn,v=dn(Fn,["categoryId"]),{productId:w,pdpLink:N}=uk(),{setCopilot:C,setConnected:U,resetCopilot:Y,resetCopilotState:R,addCopilotEvent:q,removeLoadingMessage:ne,handleCopilotRequestAck:me,setActiveConversationId:V,setConversationIds:se,setAskCimPrompts:he}=Xs(),{connected:ve,copilot:re,messages:oe,groupedMessages:xe,loadingMessages:ae,askCimPrompts:Q}=tr(),{status:ie,entryType:k}=er(),{isInline:D}=ni(),{getConversationMessages:ee,getSessionInformation:I}=ck({copilot:re}),_e=B.useMemo(()=>ae.size>0,[ae]),Ue=B.useCallback(we=>ae.has(we),[ae]),ye=B.useCallback(({query:we,facetFilters:Pe,rangeFilters:Me,catalogSegment:rt,pricebooks:ht,userPrompt:J,imageFile:ge})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const Ce={searchParams:{query:we}};J&&(Ce.userPrompt=J),ge&&(Ce.attachments={image:ge}),Pe&&Object.keys(Pe).length>0&&(Ce.searchParams.facetFilters=Pe),Me&&Me.length>0&&(Ce.searchParams.rangeFilters=Me),rt&&(Ce.searchParams.catalogSegment=rt),ht&&(Ce.searchParams.pricebooks=ht),m&&(Ce.clientContext=m),pa("search"),re.search(Ce,qe=>{const Ie=F({},qe);me(Ie)})},[p,me,re,m]),Re=B.useCallback(({categoryId:we,categoryName:Pe,facetFilters:Me,rangeFilters:rt,catalogSegment:ht,pricebooks:J,userPrompt:ge,imageFile:Ce})=>{if(!re){p==null||p.error("Copilot is not initialized");return}const qe=Me&&Object.keys(Me).length>0;if(we===""&&!qe){p==null||p.error("Browse event must include facetFilters when categoryId is empty");return}const Ie={browseParams:{categoryId:we||""}};ge&&(Ie.userPrompt=ge),Ce&&(Ie.attachments={image:Ce}),qe&&(Ie.browseParams.facetFilters=Me),rt&&rt.length>0&&(Ie.browseParams.rangeFilters=rt),ht&&(Ie.browseParams.catalogSegment=ht),Array.isArray(J)&&J.length>0&&(Ie.browseParams.pricebooks=J),(m||Pe)&&(Ie.clientContext={},m&&(Ie.clientContext=F({},m)),Pe&&(Ie.clientContext.cimLabel=Pe)),pa("browse"),re.browse(Ie,ut=>{var Vr;const Vt=F({},ut),Ht=((Vr=Vt.request)==null?void 0:Vr.clientContext)||{},an=(Ht==null?void 0:Ht.cimLabel)||Pe;an&&Vt.request&&(Vt.request.label=an),me(Vt)})},[p,me,re,m]),He=B.useCallback(({productId:we,productName:Pe,pdpLink:Me,userPrompt:rt,imageFile:ht})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const J={productId:we};rt&&(J.userPrompt=rt),Me&&(J.pdpLink=Me),ht&&(J.attachments={image:ht}),(m||Pe)&&(J.clientContext={},m&&(J.clientContext=F({},m)),Pe&&(J.clientContext.cimLabel=Pe)),b&&(J.baseCatalogParams=b),pa("pdp"),re.productView(J,ge=>{var ut;const Ce=F({},ge),qe=((ut=Ce.request)==null?void 0:ut.clientContext)||{},Ie=(qe==null?void 0:qe.cimLabel)||Pe;Ie&&Ce.request&&(Ce.request.label=Ie),me(Ce)})},[p,re,me,m,b]),Ye=B.useCallback(({userPrompt:we,imageFile:Pe})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const Me={userPrompt:we};Pe&&(Me.attachments={image:Pe}),m&&(Me.clientContext=m),b&&(Me.baseCatalogParams=b),re.askCim(Me,rt=>{const ht=F({},rt);me(ht)})},[p,re,me,m,b]),bt=B.useCallback(we=>{q(we),c==null||c(we)},[q,c]),Cn=B.useCallback(we=>{q(we),d==null||d(we)},[q,d]),sn=B.useCallback(we=>{u==null||u(we),U(!0)},[u,U]);B.useEffect(()=>{!re||!ve||!ie.isOpen||pn.size>0&&pn.processQueue(we=>{if(we.context==="search"){const Pe=F({},we.payload);o1(Pe)}if(we.context==="browse"){const Pe=F({},we.payload);Jg(Pe)}if(we.context==="pdp"){const Pe=F({},we.payload);Zg(Pe)}})},[ie.isOpen,re,ve]);const _r=B.useCallback(we=>{const Pe=Me=>{const rt=de(F({},Me),{id:Me.inquiryLinkId||Me.id});q(rt)};we.on("connect_ack",sn),we.on("partial_inquiry",Pe),we.on("display_products",q),we.on("progress",q),we.on("refined_search",bt),we.on("refined_browse",Cn),we.on("done",Me=>{ne(Me.eventSourceId)}),we.on("error",Me=>{q(Me),ne(Me.eventSourceId)}),we.onDisconnect(Me=>{const rt=["io server disconnect","transport error","server shutting down"];if(p==null||p.log("Connection disconnected with reason: ",Me),!rt.includes(Me)){U(!1);return}p==null||p.log("De-registering event listeners");const ht=new Date().toISOString();q({name:"error",message:"Connection was lost. Please try again.",createdAt:ht,id:`error-${ht}`,sessionId:"session"}),we.off()})},[p,U,ne,bt,Cn,q,sn]);B.useEffect(()=>{if(!re)return;const we=Pe=>{if(!D){if(!Pe.message&&Pe.eventSourceId&&Pe.eventSourceId===Q.requestId){he({requestId:Pe.eventSourceId,message:Pe});return}q(Pe)}};return re.on("follow_up",we),()=>{re.off("follow_up",we)}},[re,oe,Q.requestId,D,q,he]),B.useEffect(()=>{if(!re)return;const we=Pe=>{if(D)return;const Me=de(F({},Pe),{id:Pe.inquiryLinkId||Pe.id});q(Me)};return re.on("inquiry",we),()=>{re.off("inquiry",we)}},[re,D,q]),ma(()=>{let we;n?we=n:we=a?"https://staging.copilot.search.cimulate.ai":"https://prod.copilot.search.cimulate.ai";const Pe={baseUrl:we};e?Pe.apiKey=e:t&&(Pe.apiToken=t),r&&(Pe.customerId=r),s&&(Pe.tenantId=s);const Me=new Yw(Pe);return C(Me),_r(Me),Me.connect(),Me.requestSessionInformation(rt=>{p==null||p.log("Session Information: ",rt);const{activeConversationId:ht,conversationIds:J}=rt.data||{};ht&&V(ht),J!=null&&J.length&&se(J)}),()=>{Me.disconnect(),Me.off(),Y()}});const sr=B.useCallback(we=>{if(!re)return;const Pe={eventId:we,reason:"User cancelled the request"};re.cancelRequest(Pe,Me=>{q(Me),ne(we)})},[q,ne,re]),Jt=B.useCallback(()=>{re&&re.conversationReset({},we=>{R(),q(we),re.requestSessionInformation(Pe=>{p==null||p.log("Session Information: ",Pe);const{activeConversationId:Me,conversationIds:rt}=Pe.data||{};Me&&V(Me),rt!=null&&rt.length&&se(rt)})})},[re,p,q,R,V,se]),Ve=B.useCallback((we,Pe)=>{if(!we)return;const Me={userPrompt:we};switch(Pe&&(Me.imageFile=Pe),k){case"ask_cim":Ye(Me);return;case"search":y?ye(F(F({query:y},_),Me)):Ye(Me);return;case"browse":Re(F(F({categoryId:A},v),Me));return;case"pdp":w?He(F({productId:w,pdpLink:N||""},Me)):Ye(Me);return}},[k,y,_,ye,Ye,A,v,Re,He,w,N]),kt=B.useCallback((we,Pe)=>{var ge,Ce,qe;const rt=we.params.userPrompt||"";if(!rt)return;const ht=oe.find(Ie=>Ie.id===Pe);if(!ht)return;const J=ht.name.replace("_suggestions","");if(J==="ask_cim"){Ye({userPrompt:rt});return}if(J==="copilot_search"){const Ie=((ge=ht.request)==null?void 0:ge.searchParams)||{},Vt=Ie.query===y;ye(de(F({query:Ie.query||y},Vt?_:{}),{userPrompt:rt}));return}if(J==="copilot_browse"){const Ie=ht.request,ut=Ie.browseParams||{},Ht=ut.categoryId===A,an=((Ce=Ie.clientContext)==null?void 0:Ce.cimLabel)||"";Re(de(F({categoryId:ut.categoryId||A||""},Ht?v:{}),{categoryName:an,userPrompt:rt}));return}if(J==="product_view"){const Ie=ht.request||{},ut=Ie.productId,Vt=ut===w,Ht=((qe=Ie.clientContext)==null?void 0:qe.cimLabel)||"";let an="";Vt?an=N||"":an=Ie.pdpLink||"",He({productId:ut||w,pdpLink:an,productName:Ht,userPrompt:rt})}},[oe,y,_,ye,Ye,A,v,Re,He,w,N]),vn=B.useMemo(()=>({copilot:re,messages:oe,groupedMessages:xe,isLoading:_e,isResponseLoading:Ue,handleAskCim:Ye,handleSearch:ye,handleBrowse:Re,handlePdp:He,handleUserInput:Ve,handleSuggestion:kt,handleCancel:sr,resetConversation:Jt,getSessionInformation:I,getConversationMessages:ee}),[re,oe,xe,_e,Ue,Ye,ye,Re,He,Ve,kt,sr,Jt,I,ee]);return x.jsx(h1.Provider,{value:vn,children:f})},p1=()=>{const{copilot:e}=tr(),{addCopilotEvent:t}=Xs();return{getCopilotSuggestions:B.useCallback((r,s,a)=>{if(!e||!s||!r)return;const u=c=>{t(c),a(c)};switch(s){case"ask_cim":e.askCimSuggestions(r,u);break;case"search":e.searchSuggestions({searchParams:r},u);break;case"browse":e.browseSuggestions({browseParams:r},u);break;case"pdp":e.productViewSuggestions({productId:r.productId},u);break}},[e,t])}},Ir=()=>{const e=B.useContext(h1);if(!e)throw new Error("useCopilot must be used within a CopilotProvider");return e},fk=()=>{const{copilot:e,activeConversationId:t,askCimPrompts:n,conversationHistoryLoaded:r}=tr(),{entryType:s}=er(),{resetCopilotState:a,addCopilotEvent:u,setAskCimPrompts:c}=Xs(),{handleSearch:d,handleBrowse:f,handlePdp:p,resetConversation:m,getSessionInformation:b,getConversationMessages:y}=Ir(),{getCopilotSuggestions:_}=p1();B.useEffect(()=>{!e||!s||!t||!r||n.requestId||s==="ask_cim"&&_({},s,N=>{c({requestId:N.id,message:null})})},[e,t,n.requestId,s,r,_,c]);const A=B.useCallback(({query:N})=>{if(!e||!N)return;const{facetFilters:C}=Tt.facetFiltersProxy,{rangeFilters:U}=Tt.rangeFiltersProxy,{catalogSegment:Y}=Tt.catalogSegmentProxy,{pricebooks:R}=Tt.pricebooksProxy,q={query:N};q.facetFilters=C||{},q.rangeFilters=U||[],q.catalogSegment=Y||"",q.pricebooks=R||[],d(F({},q))},[e,d]),v=B.useCallback(({categoryId:N})=>{if(!e)return;const C=at.categoryIdProxy.categoryName,{facetFilters:U}=at.facetFiltersProxy,{rangeFilters:Y}=at.rangeFiltersProxy,{catalogSegment:R}=at.catalogSegmentProxy,{pricebooks:q}=at.pricebooksProxy,ne={categoryId:N};ne.categoryName=C||"",ne.facetFilters=U||{},ne.rangeFilters=Y||[],ne.catalogSegment=R||"",ne.pricebooks=q||[],f(F({},ne))},[e,f]),w=B.useCallback(({productId:N})=>{if(!e||!N)return;const C={productId:N,pdpLink:mr.pdpLink,productName:mr.proxy.productName||""};p(C)},[e,p]);return B.useEffect(()=>{const N=({detail:C})=>{(C==null?void 0:C.property)==="query"&&A({query:C.value})};return Mg(N),()=>{Fg(N)}},[A]),B.useEffect(()=>{const N=({detail:C})=>{if((C==null?void 0:C.property)==="pdp-context"){const U=C.value;w({productId:U.productId});return}(C==null?void 0:C.property)==="productId"&&w({productId:C.value})};return Hg(N),()=>{zg(N)}},[w]),B.useEffect(()=>{const N=({detail:C})=>{(C==null?void 0:C.property)==="categoryId"&&v({categoryId:C.value})};return Bg(N),()=>{Ug(N)}},[v]),B.useEffect(()=>{const N=({detail:C})=>{if((C==null?void 0:C.event)==bi.RESET_CONVERSATION&&m(),(C==null?void 0:C.event)==bi.GET_SESSION_INFORMATION){const U=C.value.callback;b(U)}if((C==null?void 0:C.event)==bi.GET_CONVERSATION_MESSAGES){const{payload:U,callback:Y}=C.value;if(!U.conversationId||typeof Y!="function")return;y(U,Y)}if((C==null?void 0:C.event)==bi.LOAD_CONVERSATION){const U=C.value;if(!U.conversationId)return;y(U,R=>{a(),R.forEach(q=>{u(q)})})}};return kv(N),()=>{Nv(N)}},[m,b,y,a,u]),null},hk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>x.jsxs(dk,{apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:[x.jsx(fk,{}),f]}),pk=e=>Array.from(new Set((e!=null?e:[]).map(t=>t.trim()).filter(Boolean))),mk=({children:e,dispatch:t})=>{const n=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_INITIALIZED,payload:_})},[t]),r=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_OPEN,payload:_})},[t]),s=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_INLINE,payload:_})},[t]),a=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_ELEMENT_ID,payload:_})},[t]),u=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_ENTRY_TYPE,payload:_})},[t]),c=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID,payload:_})},[t]),d=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_USER_PROMPT,payload:_})},[t]),f=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_PARAMS,payload:_})},[t]),p=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE,payload:_})},[t]),m=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE,payload:_})},[t]),b=B.useCallback(_=>{t({type:mt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=B.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:s,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:f,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:b}),[n,r,s,a,u,c,d,f,p,m,b]);return x.jsx(f1.Provider,{value:y,children:e})},gk=(e,t)=>{const{type:n,payload:r}=t;switch(n){case mt.SET_PROMPTS_EXTENSION_INITIALIZED:e.isInitialized=r;break;case mt.SET_PROMPTS_EXTENSION_OPEN:e.isOpen=r;break;case mt.SET_PROMPTS_EXTENSION_INLINE:e.isInline=r;break;case mt.SET_PROMPTS_EXTENSION_ELEMENT_ID:e.elementId=r;break;case mt.SET_PROMPTS_EXTENSION_ENTRY_TYPE:e.entryType=r;break;case mt.SET_PROMPTS_EXTENSION_PARAMS:e.params=r;break;case mt.RESET_PROMPTS_EXTENSION_PARAMS:e.params=null;break;case mt.SET_PROMPTS_EXTENSION_USER_PROMPT:e.userPrompt=r;break;case mt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=r;break;case mt.RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=null;break;case mt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=r;break;case mt.RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=null;break;case mt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=r;break;case mt.RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=null;break;case mt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING:e.isResponseLoading=r;break}},Ek=({promptsConfig:e,children:t})=>{const[n,r]=$0(gk,de(F(F({},e1),e||{}),{staticQuestions:pk((e==null?void 0:e.staticQuestions)||[])}));return x.jsx(d1.Provider,{value:n,children:x.jsx(mk,{dispatch:r,children:t})})},m1=({mode:e,apiKey:t,apiToken:n,baseUrl:r,customerId:s,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,theme:f,openLinksInNewTab:p,globalClassName:m,isDevelopment:b=!1,componentType:y,componentConfig:_,entryType:A,entryMessage:v,disclaimerText:w,disclaimerMarkdown:N,clientContext:C,baseCatalogParams:U,searchPlaceholder:Y,searchButtonLabel:R,searchConfig:q,suggestionButtonConfig:ne,messageAlignment:me,autoScroll:V,promptsConfig:se,resetConversationMessage:he,conversationHistory:ve,onConnect:re,onCopilotEvent:oe,onRefinedSearch:xe,onRefinedBrowse:ae,__features:Q,children:ie})=>x.jsx(av,{mode:e,baseUrl:r,apiKey:t,apiToken:n,customerId:s,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,entryMessage:v,theme:f,globalClassName:m,openLinksInNewTab:p,searchPlaceholder:Y,searchButtonLabel:R,searchConfig:q,suggestionButtonConfig:ne,messageAlignment:me,autoScroll:V,componentConfig:_,clientContext:C,baseCatalogParams:U,disclaimerMarkdown:N,disclaimerText:w,resetConversationMessage:he,conversationHistory:ve,isDevelopment:b,__features:Q,children:x.jsx(lk,{entryType:A,componentConfig:_,componentType:y,children:x.jsx(gv,{onCopilotEvent:oe,children:x.jsx(ak,{children:x.jsx(tk,{children:x.jsx(ik,{children:x.jsx(Ek,{promptsConfig:se,children:x.jsx(hk,{apiKey:t,apiToken:n,baseUrl:r,customerId:s,tenantId:a,isDevelopment:b,entryType:A,onConnect:re,onRefinedSearch:xe,onRefinedBrowse:ae,onCopilotEvent:oe,children:ie})})})})})})})});var Sf={exports:{}},In={},xf={exports:{}},wf={};var g1;function yk(){return g1||(g1=1,(function(e){function t(Q,ie){var k=Q.length;Q.push(ie);e:for(;0<k;){var D=k-1>>>1,ee=Q[D];if(0<s(ee,ie))Q[D]=ie,Q[k]=ee,k=D;else break e}}function n(Q){return Q.length===0?null:Q[0]}function r(Q){if(Q.length===0)return null;var ie=Q[0],k=Q.pop();if(k!==ie){Q[0]=k;e:for(var D=0,ee=Q.length,I=ee>>>1;D<I;){var _e=2*(D+1)-1,Ue=Q[_e],ye=_e+1,Re=Q[ye];if(0>s(Ue,k))ye<ee&&0>s(Re,Ue)?(Q[D]=Re,Q[ye]=k,D=ye):(Q[D]=Ue,Q[_e]=k,D=_e);else if(ye<ee&&0>s(Re,k))Q[D]=Re,Q[ye]=k,D=ye;else break e}}return ie}function s(Q,ie){var k=Q.sortIndex-ie.sortIndex;return k!==0?k:Q.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,b=3,y=!1,_=!1,A=!1,v=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(Q){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=Q)r(f),ie.sortIndex=ie.expirationTime,t(d,ie);else break;ie=n(f)}}function U(Q){if(A=!1,C(Q),!_)if(n(d)!==null)_=!0,xe(Y);else{var ie=n(f);ie!==null&&ae(U,ie.startTime-Q)}}function Y(Q,ie){_=!1,A&&(A=!1,w(ne),ne=-1),y=!0;var k=b;try{for(C(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||Q&&!se());){var D=m.callback;if(typeof D=="function"){m.callback=null,b=m.priorityLevel;var ee=D(m.expirationTime<=ie);ie=e.unstable_now(),typeof ee=="function"?m.callback=ee:m===n(d)&&r(d),C(ie)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var _e=n(f);_e!==null&&ae(U,_e.startTime-ie),I=!1}return I}finally{m=null,b=k,y=!1}}var R=!1,q=null,ne=-1,me=5,V=-1;function se(){return!(e.unstable_now()-V<me)}function he(){if(q!==null){var Q=e.unstable_now();V=Q;var ie=!0;try{ie=q(!0,Q)}finally{ie?ve():(R=!1,q=null)}}else R=!1}var ve;if(typeof N=="function")ve=function(){N(he)};else if(typeof MessageChannel!="undefined"){var re=new MessageChannel,oe=re.port2;re.port1.onmessage=he,ve=function(){oe.postMessage(null)}}else ve=function(){v(he,0)};function xe(Q){q=Q,R||(R=!0,ve())}function ae(Q,ie){ne=v(function(){Q(e.unstable_now())},ie)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(Q){Q.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,xe(Y))},e.unstable_forceFrameRate=function(Q){0>Q||125<Q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):me=0<Q?Math.floor(1e3/Q):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(Q){switch(b){case 1:case 2:case 3:var ie=3;break;default:ie=b}var k=b;b=ie;try{return Q()}finally{b=k}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Q,ie){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var k=b;b=Q;try{return ie()}finally{b=k}},e.unstable_scheduleCallback=function(Q,ie,k){var D=e.unstable_now();switch(typeof k=="object"&&k!==null?(k=k.delay,k=typeof k=="number"&&0<k?D+k:D):k=D,Q){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=k+ee,Q={id:p++,callback:ie,priorityLevel:Q,startTime:k,expirationTime:ee,sortIndex:-1},k>D?(Q.sortIndex=k,t(f,Q),n(d)===null&&Q===n(f)&&(A?(w(ne),ne=-1):A=!0,ae(U,k-D))):(Q.sortIndex=ee,t(d,Q),_||y||(_=!0,xe(Y))),Q},e.unstable_shouldYield=se,e.unstable_wrapCallback=function(Q){var ie=b;return function(){var k=b;b=ie;try{return Q.apply(this,arguments)}finally{b=k}}}})(wf)),wf}var E1;function Tk(){return E1||(E1=1,xf.exports=yk()),xf.exports}var y1;function bk(){if(y1)return In;y1=1;var e=fr(),t=Tk();function n(i){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)o+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function a(i,o){u(i,o),u(i+"Capture",o)}function u(i,o){for(s[i]=o,i=0;i<o.length;i++)r.add(o[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function b(i){return d.call(m,i)?!0:d.call(p,i)?!1:f.test(i)?m[i]=!0:(p[i]=!0,!1)}function y(i,o,l,h){if(l!==null&&l.type===0)return!1;switch(typeof o){case"function":case"symbol":return!0;case"boolean":return h?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function _(i,o,l,h){if(o===null||typeof o=="undefined"||y(i,o,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function A(i,o,l,h,E,T,S){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=h,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=o,this.sanitizeURL=T,this.removeEmptyString=S}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){v[i]=new A(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var o=i[0];v[o]=new A(o,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){v[i]=new A(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){v[i]=new A(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){v[i]=new A(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){v[i]=new A(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){v[i]=new A(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){v[i]=new A(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){v[i]=new A(i,5,!1,i.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function N(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){v[i]=new A(i,1,!1,i.toLowerCase(),null,!1,!1)}),v.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){v[i]=new A(i,1,!1,i.toLowerCase(),null,!0,!0)});function C(i,o,l,h){var E=v.hasOwnProperty(o)?v[o]:null;(E!==null?E.type!==0:h||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(_(o,l,E,h)&&(l=null),h||E===null?b(o)&&(l===null?i.removeAttribute(o):i.setAttribute(o,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(o=E.attributeName,h=E.attributeNamespace,l===null?i.removeAttribute(o):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,h?i.setAttributeNS(h,o,l):i.setAttribute(o,l))))}var U=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y=Symbol.for("react.element"),R=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),ne=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),se=Symbol.for("react.context"),he=Symbol.for("react.forward_ref"),ve=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),oe=Symbol.for("react.memo"),xe=Symbol.for("react.lazy"),ae=Symbol.for("react.offscreen"),Q=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=Q&&i[Q]||i["@@iterator"],typeof i=="function"?i:null)}var k=Object.assign,D;function ee(i){if(D===void 0)try{throw Error()}catch(l){var o=l.stack.trim().match(/\n( *(at )?)/);D=o&&o[1]||""}return`
11
11
  `+D+i}var I=!1;function _e(i,o){if(!i||I)return"";I=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(o)if(o=function(){throw Error()},Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(Z){var h=Z}Reflect.construct(i,[],o)}else{try{o.call()}catch(Z){h=Z}i.call(o.prototype)}else{try{throw Error()}catch(Z){h=Z}i()}}catch(Z){if(Z&&h&&typeof Z.stack=="string"){for(var E=Z.stack.split(`
12
12
  `),T=h.stack.split(`
13
13
  `),S=E.length-1,L=T.length-1;1<=S&&0<=L&&E[S]!==T[L];)L--;for(;1<=S&&0<=L;S--,L--)if(E[S]!==T[L]){if(S!==1||L!==1)do if(S--,L--,0>L||E[S]!==T[L]){var H=`
@@ -437,9 +437,10 @@ export declare interface MessagingContextType {
437
437
  error: string | null;
438
438
  sendError: SendError | null;
439
439
  sessionExpired: boolean;
440
+ canInitialize?: boolean;
440
441
  sendMessage: SendMessage;
441
442
  addToCart: (params: AddToCartParams) => void;
442
- resetConversation: () => void;
443
+ resetConversation: () => Promise<void>;
443
444
  retryLastMessage: () => ReturnType<SendMessage> | undefined;
444
445
  retryConnection: () => void;
445
446
  downloadTranscript: () => Promise<void>;