@cimulate/copilot-widget 1.12.0 → 1.12.1

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.
@@ -5397,7 +5397,7 @@ const HC = {
5397
5397
  if (!e)
5398
5398
  throw new Error("useConfig must be used within a ConfigProvider");
5399
5399
  return e;
5400
- }, jC = ["markdown", "product_carousel", "suggestions"], Al = -1;
5400
+ }, jC = ["markdown", "product_carousel", "suggestions", "cart"], Al = -1;
5401
5401
  function $C(e) {
5402
5402
  if (!e || !e.trim()) return null;
5403
5403
  try {
@@ -13,7 +13,7 @@
13
13
  `);return u===-1?"":o.stack.slice(u+1)})();try{if(!r.stack)r.stack=a;else if(a){const u=a.indexOf(`
14
14
  `),c=u===-1?-1:a.indexOf(`
15
15
  `,u+1),d=c===-1?"":a.slice(c+1);String(r.stack).endsWith(d)||(r.stack+=`
16
- `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=vi(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&Tu.assertOptions(r,{silentJSONParsing:In.transitional(In.boolean),forcedJSONParsing:In.transitional(In.boolean),clarifyTimeoutError:In.transitional(In.boolean),legacyInterceptorReqResOrdering:In.transitional(In.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Tu.assertOptions(o,{encode:In.function,serialize:In.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Tu.assertOptions(n,{baseUrl:In.spelling("baseURL"),withXsrfToken:In.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&V.merge(a.common,a[n.method]);a&&V.forEach(["delete","get","head","post","put","patch","query","common"],x=>{delete a[x]}),n.headers=tn.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(_){if(typeof _.runWhen=="function"&&_.runWhen(n)===!1)return;d=d&&_.synchronous;const S=n.transitional||ud;S&&S.legacyInterceptorReqResOrdering?c.unshift(_.fulfilled,_.rejected):c.push(_.fulfilled,_.rejected)});const h=[];this.interceptors.response.forEach(function(_){h.push(_.fulfilled,_.rejected)});let p,E=0,T;if(!d){const x=[x0.bind(this),void 0];for(x.unshift(...c),x.push(...h),T=x.length,p=Promise.resolve(n);E<T;)p=p.then(x[E++],x[E++]);return p}T=c.length;let y=n;for(;E<T;){const x=c[E++],_=c[E++];try{y=x(y)}catch(S){_.call(this,S);break}}try{p=x0.call(this,y)}catch(x){return Promise.reject(x)}for(E=0,T=h.length;E<T;)p=p.then(h[E++],h[E++]);return p}getUri(t){t=vi(this.defaults,t);const n=f0(t.baseURL,t.url,t.allowAbsoluteUrls);return o0(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Si.prototype[t]=function(n,r){return this.request(vi(r||{},{method:t,url:n,data:(r||{}).data}))}}),V.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(vi(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}Si.prototype[t]=n(),t!=="query"&&(Si.prototype[t+"Form"]=n(!0))});let Fv=class tw{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(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(o);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new Ns(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 tw(function(o){t=o}),cancel:t}}};function Bv(e){return function(n){return e.apply(null,n)}}function Uv(e){return V.isObject(e)&&e.isAxiosError===!0}const md={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(md).forEach(([e,t])=>{md[t]=e});function _0(e){const t=new Si(e),n=Vm(Si.prototype.request,t);return V.extend(n,Si.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return _0(vi(e,o))},n}const xt=_0(ks);xt.Axios=Si,xt.CanceledError=Ns,xt.CancelToken=Fv,xt.isCancel=u0,xt.VERSION=fd,xt.toFormData=gu,xt.AxiosError=ke,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Bv,xt.isAxiosError=Uv,xt.mergeConfig=vi,xt.AxiosHeaders=tn,xt.formToJSON=e=>a0(V.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=T0.getAdapter,xt.HttpStatusCode=md,xt.default=xt;const{Axios:q9,AxiosError:Y9,CanceledError:W9,isCancel:G9,CancelToken:K9,VERSION:Q9,all:X9,Cancel:J9,isAxiosError:Z9,spread:eF,toFormData:tF,AxiosHeaders:nF,HttpStatusCode:rF,formToJSON:iF,getAdapter:oF,mergeConfig:sF,create:aF}=xt;class Hv{constructor(t,n,r,o=!1,a,u){Ze(this,"CIMULATE_API_HEADER","x-cimulate-api-key");Ze(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");Ze(this,"CIMULATE_SEARCH_API_PATH","api/v1");Ze(this,"baseApiUrl");Ze(this,"headers",{});Ze(this,"fetchConfig",()=>$e(this,null,function*(){try{const t=yield xt.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}}));Ze(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const o=new URL(t);return o.hostname=o.hostname.replace(/^copilot\./,"api."),o.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,o)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class zv{constructor(t,n,r,o=!1,a,u){Ze(this,"apiService");Ze(this,"config",null);Ze(this,"getConfig",()=>$e(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}}));Ze(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));Ze(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));Ze(this,"getDescription",t=>this.getProductFieldValue(t,"description"));Ze(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));Ze(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));Ze(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));Ze(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));Ze(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));Ze(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});Ze(this,"getProductField",t=>this.config?this.config[t]:"");Ze(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new Hv(t,n,r,o,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 Ai=(e,t,n,...r)=>{if(!e)return;const o=["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]",o,n,...r)};class jv{constructor(t=!1){Ze(this,"isDevelopment");Ze(this,"_log",(t,n,...r)=>{Ai(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 $v={copilot:"Your Search Assistant",messaging:"Commerce Client"},v0=Z.createContext(null),Vv=({mode:e,logoUrl:t,headerText:n="Your Search Assistant",headerConfig:r,globalClassName:o="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:h,baseCatalogParams:p,searchPlaceholder:E,searchButtonLabel:T,searchConfig:y,componentConfig:x,conversationHistory:_,resetConversationMessage:S="",apiKey:A,apiToken:O,baseUrl:R,customerId:z,tenantId:W,theme:M,isDevelopment:K,__features:de,children:xe})=>{const D=e==="messaging",ne=Z.useMemo(()=>D?{config:null}:new zv(R,A,O,K,z,W),[D,R,A,O,K,z,W]),J=Z.useMemo(()=>new jv(K),[K]);Z.useEffect(()=>{D||!ne||ne.config||ne.getConfig()},[ne,D]);const re=Z.useMemo(()=>n_(M),[M]),oe=Z.useMemo(()=>{const fe=(y==null?void 0:y.placeholder)||E,Q=(y==null?void 0:y.buttonLabel)||T;let se="icon";return y!=null&&y.buttonType?se=y.buttonType:T&&(se="text"),ae(H({},y||{}),{placeholder:fe,buttonLabel:Q,buttonType:se})},[y,E,T]),be=Z.useMemo(()=>ae(H({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:n||$v[e!=null?e:"copilot"]}),[r,t,n,e]),Ie=Z.useMemo(()=>({configModule:ne,mode:e!=null?e:"copilot",headerConfig:be,entryMessage:a,globalClassName:o,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:h,baseCatalogParams:p,themeVariables:re,logger:J,searchConfig:oe,enableMinimize:!!(x!=null&&x.enableMinimize),resetConversationMessage:S,conversationHistory:{sinceHours:typeof(_==null?void 0:_.sinceHours)=="number"?_.sinceHours:1,limit:_==null?void 0:_.limit},features:de}),[ne,e,be,a,o,h,p,c,d,u,oe,x,S,J,re,_,de]);return v.jsx(v0.Provider,{value:Ie,children:xe})},At=()=>{const e=Z.useContext(v0);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e},qv=["markdown","product_carousel","suggestions"],xu=-1;function Yv(e){if(!e||!e.trim())return null;try{const t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.type=="string"&&typeof t.index=="number")return qv.includes(t.type)?t:null}catch(t){}return{type:"markdown",index:xu,data:{content:e}}}function Wv(e,t){if(t.index===xu){const o=e[e.length-1];if(o&&o.type==="markdown"&&o.index===xu&&t.type==="markdown"){const a={type:"markdown",index:xu,data:{content:o.data.content+t.data.content}};return[...e.slice(0,-1),a]}return[...e,t]}const n=e.findIndex(o=>o.index===t.index);return[...n>=0?e.map((o,a)=>a===n?t:o):[...e,t]].sort((o,a)=>o.index-a.index)}const S0={connectionStatus:"disconnected",loading:!0,conversationId:null,messages:[],streamingBlocks:[],isAgentTyping:!1,progressMessage:"",routingResult:null,error:null};function Gv(e,t){switch(t.type){case"SET_CONNECTION_STATUS":return H(ae(H({},e),{connectionStatus:t.status}),t.status==="connected"||t.status==="connecting"?{error:null}:{});case"SET_LOADING":return ae(H({},e),{loading:t.isLoading});case"SET_CONVERSATION_ID":return ae(H({},e),{conversationId:t.id});case"ADD_MESSAGE":return ae(H({},e),{messages:[...e.messages,ae(H({},t.message),{type:"ADD_MESSAGE"})]});case"APPEND_STREAMING_TOKEN":{const n=Yv(t.token);return n?ae(H({},e),{streamingBlocks:Wv(e.streamingBlocks,n)}):e}case"FLUSH_STREAMING":return ae(H({},e),{messages:[...e.messages,ae(H({},t.message),{type:"FLUSH_STREAMING"})],streamingBlocks:[],isAgentTyping:!1,loading:!1,progressMessage:""});case"SET_AGENT_TYPING":return ae(H({},e),{isAgentTyping:t.isTyping,loading:t.isTyping});case"SET_PROGRESS_MESSAGE":return ae(H({},e),{progressMessage:t.message});case"SET_ROUTING_RESULT":return ae(H({},e),{routingResult:t.result});case"SET_ERROR":return ae(H({},e),{error:t.error,loading:!1,progressMessage:""});case"LOAD_HISTORY":return ae(H({},e),{messages:t.messages,loading:!1});case"RESET":return ae(H({},S0),{connectionStatus:e.connectionStatus,loading:!0});default:return e}}const A0=Z.createContext({connectionStatus:"disconnected",isConnected:!1,isAgentTyping:!1,conversationId:null,messages:[],streamingBlocks:[],progressMessage:"",loading:!0,error:null,sendMessage:()=>{},resetConversation:()=>{}});function gd(e,t){return`cim_af_conv_${e}_${t}`}function Ed(e,t){return Date.now()-e>t}function Kv(e,t,n){try{const r=gd(e,t),o=sessionStorage.getItem(r);if(!o)return null;const a=JSON.parse(o);if(!a||typeof a!="object"||!("conversationId"in a)||!("storedAt"in a))return null;const u=a;return typeof u.conversationId!="string"||!u.conversationId?null:typeof u.storedAt!="number"||Ed(u.storedAt,n)?(sessionStorage.removeItem(r),null):u}catch(r){return null}}function Os(e,t,n){try{const r=gd(e,t),o={conversationId:n,storedAt:Date.now()};sessionStorage.setItem(r,JSON.stringify(o))}catch(r){}}function wu(e,t){try{const n=gd(e,t);sessionStorage.removeItem(n)}catch(n){}}function yd(e,t){return`cim_af_ct_${e}_${t}`}function C0(e,t,n){try{const r=yd(e,t),o=sessionStorage.getItem(r);if(!o)return null;const a=JSON.parse(o);if(!a||typeof a!="object"||!("accessToken"in a)||!("lastEventId"in a)||!("storedAt"in a))return null;const u=a;return typeof u.accessToken!="string"||!u.accessToken||typeof u.lastEventId!="string"||!u.lastEventId?null:typeof u.storedAt!="number"||Date.now()-u.storedAt>n?(sessionStorage.removeItem(r),null):u}catch(r){return null}}function Qv(e,t,n,r){try{const o=yd(e,t),a={accessToken:n,lastEventId:r,storedAt:Date.now()};sessionStorage.setItem(o,JSON.stringify(a))}catch(o){}}function Xv(e,t){try{const n=yd(e,t);sessionStorage.removeItem(n)}catch(n){}}function Jv(e,t){return`cim_af_conv_${e}_${t}`}function Zv(e,t){try{if(typeof BroadcastChannel=="undefined")return null;const n=Jv(e,t);return new BroadcastChannel(n)}catch(n){return null}}function eS(e,t=500){return e?new Promise(n=>{let r=!1;const o=setTimeout(()=>{r||(r=!0,e.removeEventListener("message",a),n(null))},t);function a(u){var c;r||((c=u.data)==null?void 0:c.type)==="conversation_response"&&(r=!0,clearTimeout(o),e.removeEventListener("message",a),n({conversationId:u.data.conversationId,storedAt:u.data.storedAt,continuationToken:u.data.continuationToken,lastEventId:u.data.lastEventId}))}e.addEventListener("message",a);try{e.postMessage({type:"request_conversation"})}catch(u){r||(r=!0,clearTimeout(o),e.removeEventListener("message",a),n(null))}}):Promise.resolve(null)}function tS(e,t,n){if(!e)return()=>{};function r(o){var a;if((a=o.data)!=null&&a.type)switch(o.data.type){case"request_conversation":{const u=t();if(u!=null&&u.conversationId)try{e.postMessage({type:"conversation_response",conversationId:u.conversationId,storedAt:Date.now(),continuationToken:u.continuationToken,lastEventId:u.lastEventId})}catch(c){}break}case"conversation_cleared":{n==null||n();break}}}return e.addEventListener("message",r),()=>{e.removeEventListener("message",r)}}function nS(e){if(e)try{e.postMessage({type:"conversation_cleared"})}catch(t){}}function rS(e){if(e)try{e.close()}catch(t){}}function iS(e){switch(e){case"EndUser":case"Customer":return"user";case"Agent":case"Chatbot":return"agent";default:return"system"}}function oS(e){if(!e)return{};if(typeof e=="string")try{return JSON.parse(e)}catch(t){return{}}return e}function k0(e,...t){let n=e;for(const r of t){if(n==null||typeof n!="object")return"";n=n[r]}return typeof n=="string"?n:""}function sS(e){if(e.entryType!=="Message")return null;const n=oS(e.entryPayload).abstractMessage;if(!n)return null;const r=k0(n,"staticContent","text")||k0(n,"content","text")||"";if(!r)return null;const o=iS(e.sender.role);return{id:e.identifier,role:o,content:r,timestamp:new Date(e.transcriptedTimestamp).toISOString(),sender:{role:e.sender.role,name:e.senderDisplayName}}}function aS(e){const t=[];for(const n of e){const r=sS(n);r&&t.push(r)}return t}function uS(e){const{orgId:t,esDeveloperName:n,routingAttributes:r,conversationHistory:o}=e,a=Z.useRef(null),u=Z.useRef(null),c=Z.useRef(null),d=o.sinceHours*60*60*1e3,h=Z.useCallback(()=>(c.current||(c.current=eS(a.current)),c.current),[]);Z.useEffect(()=>{const S=Zv(t,n);a.current=S,c.current=null;const A=tS(S,()=>{const O=u.current;if(!O)return null;const R=C0(t,n,d);return{conversationId:O,continuationToken:R==null?void 0:R.accessToken,lastEventId:R==null?void 0:R.lastEventId}},()=>{wu(t,n),u.current=null});return()=>{A(),rS(S),a.current=null}},[t,n,d]);const p=Z.useCallback(S=>$e(null,null,function*(){let A=Kv(t,n,d);if(!A){const O=yield h();O&&!Ed(O.storedAt,d)&&(A=O)}if(!A){const O=yield S.createConversation(r);return Os(t,n,O),u.current=O,{conversationId:O,restoredMessages:[],resumed:!1}}try{const O=Date.now()-d,z=(yield S.listConversations({conversationId:A.conversationId,startTimestamp:O})).conversations.find(M=>M.conversationId===A.conversationId&&!M.isConversationClosed);if(!z){wu(t,n);const M=yield S.createConversation(r);return Os(t,n,M),u.current=M,{conversationId:M,restoredMessages:[],resumed:!1}}S.resumeConversation(z.conversationId),u.current=z.conversationId,Os(t,n,z.conversationId);let W=[];try{const M=yield S.listConversationEntries(z.conversationId,{limit:o.limit,startTimestamp:O,direction:"FromStart"});W=aS(M.conversationEntries)}catch(M){}return{conversationId:z.conversationId,restoredMessages:W,resumed:!0}}catch(O){wu(t,n);const R=yield S.createConversation(r);return Os(t,n,R),u.current=R,{conversationId:R,restoredMessages:[],resumed:!1}}}),[t,n,r,o,d,h]),E=Z.useCallback(S=>{Os(t,n,S),u.current=S},[t,n]),T=Z.useCallback(()=>{wu(t,n),Xv(t,n),nS(a.current),u.current=null},[t,n]),y=Z.useCallback(()=>{const S=C0(t,n,d);return S?{continuationToken:S.accessToken,lastEventId:S.lastEventId}:null},[t,n,d]),x=Z.useCallback(()=>$e(null,null,function*(){const S=yield h();return!(S!=null&&S.continuationToken)||Ed(S.storedAt,d)?null:{continuationToken:S.continuationToken,lastEventId:S.lastEventId}}),[d,h]),_=Z.useCallback(S=>$e(null,null,function*(){try{const{accessToken:A,lastEventId:O}=yield S.generateContinuationToken();Qv(t,n,A,O)}catch(A){}}),[t,n]);return{initializeConversation:p,persistConversationId:E,clearPersistedConversation:T,getStoredConnectOptions:y,getPeerConnectOptions:x,persistContinuationToken:_}}const lS="Your session ended due to inactivity. Starting a new session…";function cS(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="auth"?!0:t.type==="api"&&(t.statusCode===401||t.statusCode===403)}const N0=({scrt2Url:e,orgId:t,esDeveloperName:n,routingAttributes:r,capabilitiesVersion:o,enableLogging:a=!1,onConnect:u,onMessage:c,onError:d,children:h})=>{const{logger:p,conversationHistory:E}=At(),[T,y]=Z.useReducer(Gv,S0),x=uS({orgId:t,esDeveloperName:n,routingAttributes:r,conversationHistory:E}),_=Z.useRef(null),S=Z.useRef(c),A=Z.useRef(d),O=Z.useRef(u),R=Z.useRef(!1),z=Z.useRef(0);S.current=c,A.current=d,O.current=u,Z.useEffect(()=>{const D=new t_({baseURL:e,orgId:t,esDeveloperName:n,options:H({enableLogging:a},o?{capabilitiesVersion:o}:{})});return _.current=D,D.on("connected",()=>{var J;y({type:"SET_CONNECTION_STATUS",status:"connected"}),(J=O.current)==null||J.call(O)}),D.on("disconnected",()=>{y({type:"SET_CONNECTION_STATUS",status:"disconnected"})}),D.on("reconnecting",()=>{y({type:"SET_CONNECTION_STATUS",status:"reconnecting"})}),D.on("message",J=>{var oe;const re={id:J.messageId||crypto.randomUUID(),role:"agent",content:J.content,timestamp:J.timestamp,sender:J.sender,raw:J};p==null||p.log("🦜 MessagingProvider message received (FLUSH_STREAMING)",{messageId:re.id,tokensBeforeFlush:z.current,streamedFinalOnly:z.current===0}),z.current=0,y({type:"FLUSH_STREAMING",message:re}),(oe=S.current)==null||oe.call(S,re)}),D.on("streaming_token",J=>{z.current+=1,y({type:"APPEND_STREAMING_TOKEN",token:J.token})}),D.on("typing_started",()=>{y({type:"SET_AGENT_TYPING",isTyping:!0})}),D.on("typing_stopped",()=>{y({type:"SET_AGENT_TYPING",isTyping:!1})}),D.on("progress_indicator",J=>{y({type:"SET_PROGRESS_MESSAGE",message:J.message})}),D.on("routing_result",J=>{var re;if(y({type:"SET_ROUTING_RESULT",result:J}),!J.isSuccessful){const oe=`Routing failed: ${J.failureType||"unknown"}`;y({type:"SET_ERROR",error:oe}),(re=A.current)==null||re.call(A,oe)}}),D.on("participant_changed",J=>{if(J.participant.name==="Automated Process")return;const re={id:crypto.randomUUID(),role:"system",content:J.action==="add"?`${J.participant.name||"Agent"} joined the conversation`:`${J.participant.name||"Agent"} left the conversation`,timestamp:new Date().toISOString()};p==null||p.log("🦜 MessagingProvider participant_changed event received",{event:J}),y({type:"ADD_MESSAGE",message:re})}),D.on("conversation_closed",()=>{const J={id:crypto.randomUUID(),role:"system",content:"Conversation reset",timestamp:new Date().toISOString()};y({type:"ADD_MESSAGE",message:J}),y({type:"SET_CONVERSATION_ID",id:null}),x.clearPersistedConversation()}),D.on("error",J=>{var re;if(p==null||p.log("🦜 MessagingProvider ERROR event received",{event:J}),J.code==="SESSION_EXPIRED"){M.current();return}y({type:"SET_ERROR",error:J.message}),J.recoverable||y({type:"SET_CONNECTION_STATUS",status:"error"}),(re=A.current)==null||re.call(A,J.message)}),y({type:"SET_CONNECTION_STATUS",status:"connecting"}),$e(null,null,function*(){let J=x.getStoredConnectOptions(),re=!1;J||(J=yield x.getPeerConnectOptions(),re=!!J);try{yield D.connect(J!=null?J:void 0)}catch(be){if(J)p==null||p.log("Continuation token failed, falling back to fresh connect"),re||x.clearPersistedConversation(),yield D.connect();else throw be}yield x.persistContinuationToken(D);const oe=yield x.initializeConversation(D);y({type:"SET_CONVERSATION_ID",id:oe.conversationId}),oe.resumed&&oe.restoredMessages.length>0&&y({type:"LOAD_HISTORY",messages:oe.restoredMessages})}).catch(J=>{var re;y({type:"SET_CONNECTION_STATUS",status:"error"}),y({type:"SET_ERROR",error:J.message}),(re=A.current)==null||re.call(A,J.message)}),()=>{D.disconnect(),D.off(),_.current=null}},[e,t,n,o]),Z.useEffect(()=>{const D=()=>{document.visibilityState==="visible"&&_.current&&_.current.reconnect()};return document.addEventListener("visibilitychange",D),()=>{document.removeEventListener("visibilitychange",D)}},[]);const W=Z.useCallback(D=>$e(null,null,function*(){var J;const ne=_.current;if(!(!ne||R.current)){R.current=!0,y({type:"ADD_MESSAGE",message:{id:crypto.randomUUID(),role:"system",content:lS,timestamp:new Date().toISOString()}}),x.clearPersistedConversation(),y({type:"SET_CONNECTION_STATUS",status:"connecting"});try{ne.disconnect(),yield ne.connect(),yield x.persistContinuationToken(ne);const re=yield ne.createConversation(r);y({type:"SET_CONVERSATION_ID",id:re}),y({type:"SET_CONNECTION_STATUS",status:"connected"}),x.persistConversationId(re),D&&(y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),yield ne.sendMessage(D))}catch(re){const oe=re instanceof Error?re.message:String(re);y({type:"SET_ERROR",error:oe}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(J=A.current)==null||J.call(A,oe)}finally{R.current=!1}}}),[r,x]),M=Z.useRef(W);M.current=W;const K=Z.useCallback(D=>{if(!D.trim())return;const ne=_.current;if(!ne)return;const J={id:crypto.randomUUID(),role:"user",content:D,timestamp:new Date().toISOString()};y({type:"ADD_MESSAGE",message:J}),y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),ne.sendMessage(D).catch(re=>{var oe;if(cS(re)){M.current(D);return}y({type:"SET_ERROR",error:re.message}),(oe=A.current)==null||oe.call(A,re.message)})},[]),de=Z.useCallback(()=>{const D=_.current;D&&(x.clearPersistedConversation(),y({type:"RESET"}),y({type:"SET_CONNECTION_STATUS",status:"connecting"}),D.endConversation().then(()=>(D.disconnect(),D.connect())).then(()=>$e(null,null,function*(){return yield x.persistContinuationToken(D),D.createConversation(r)})).then(ne=>{y({type:"SET_CONVERSATION_ID",id:ne}),y({type:"SET_CONNECTION_STATUS",status:"connected"}),x.persistConversationId(ne)}).catch(ne=>{var J;y({type:"SET_ERROR",error:ne.message}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(J=A.current)==null||J.call(A,ne.message)}))},[r,x]),xe=Z.useMemo(()=>({connectionStatus:T.connectionStatus,isConnected:T.connectionStatus==="connected"&&T.conversationId!==null,isAgentTyping:T.isAgentTyping,conversationId:T.conversationId,messages:T.messages,streamingBlocks:T.streamingBlocks,progressMessage:T.progressMessage,error:T.error,loading:T.loading,sendMessage:K,resetConversation:de}),[T,K,de]);return v.jsx(A0.Provider,{value:xe,children:h})};function dS(){var e=Z.useRef(!0);return e.current?(e.current=!1,!0):e.current}function fS(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function hS(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var bd=typeof window!="undefined",_u=function(e){Z.useEffect(e,[])},pS=function(e){var t=Z.useRef(e);t.current=e,_u(function(){return function(){return t.current()}})},mS=function(e){var t=Z.useRef(0),n=Z.useState(e),r=n[0],o=n[1],a=Z.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){o(u)})},[]);return pS(function(){cancelAnimationFrame(t.current)}),[r,a]},gS=function(e,t){return e===t};function ES(e,t){t===void 0&&(t=gS);var n=Z.useRef(),r=Z.useRef(e),o=dS();return!o&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var yS=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,o=t.initialHeight,a=o===void 0?1/0:o,u=t.onChange,c=mS({width:bd?window.innerWidth:r,height:bd?window.innerHeight:a}),d=c[0],h=c[1];return Z.useEffect(function(){if(bd){var p=function(){var E=window.innerWidth,T=window.innerHeight;h({width:E,height:T}),u&&u(E,T)};return fS(window,"resize",p),function(){hS(window,"resize",p)}}},[]),d};const Td="cimulate:ui-state-update",bS=e=>{window.addEventListener(Td,e)},TS=e=>{window.removeEventListener(Td,e)},xS=(e,t)=>{const n=new CustomEvent(Td,{detail:{property:e,value:t}});window.dispatchEvent(n)},O0=e=>{if(!["ask_cim","search","browse","pdp"].includes(e))throw new Error(`Invalid entryType: "${e}". Must be 'ask_cim', 'search', 'browse', or 'pdp'.`);tt.entryTypeProxy.entryType=e},Ci=e=>{const t=tt.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;tt.statusProxy.isOpen=n,n&&(tt.statusProxy.isMinimized=!1)},vu=e=>{const t=tt.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;tt.statusProxy.isMinimized=n,n&&(tt.statusProxy.isOpen=!1)},xd=e=>{tt.modalProxy.isFullscreen=e},Su=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);tt.statusProxy.type=e,e==="dialog"||e==="chat"?tt.modeProxy.mode="embedded":tt.modeProxy.mode="standalone"},wd=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(", ")}.`);tt.dialogProxy.position=e},wS=e=>{const t=tt.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;tt.dialogProxy.isFullHeight=n};class _S{constructor(){Ze(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}});Ze(this,"connectedProxy");Ze(this,"modeProxy");Ze(this,"entryTypeProxy");Ze(this,"statusProxy");Ze(this,"dialogProxy");Ze(this,"modalProxy",{isFullscreen:!1});Ze(this,"_fullGet",(t,n)=>Reflect.get(t,n));Ze(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return xS(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 tt=new _S,I0=Z.createContext({mode:tt.modeProxy.mode,entryType:tt.entryType,status:tt.statusProxy,dialogPosition:tt.dialogProxy.position,isDialogFullHeight:tt.dialogProxy.isFullHeight,dialogWidth:tt.dialogProxy.width,isModalFullscreen:tt.modalProxy.isFullscreen,previousComponentType:tt.statusProxy.type}),vS=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[o,a]=Z.useState(e!=null?e:tt.entryTypeProxy.entryType),[u,c]=Z.useState(tt.modeProxy.mode),[d,h]=Z.useState({type:n||tt.statusProxy.type,isOpen:tt.statusProxy.isOpen,isMinimized:tt.statusProxy.isMinimized}),[p,E]=Z.useState(tt.dialogProxy.position),[T,y]=Z.useState(tt.dialogProxy.isFullHeight),[x,_]=Z.useState(tt.dialogProxy.width),[S,A]=Z.useState(tt.modalProxy.isFullscreen),O=ES(d.type);Z.useEffect(()=>{const z=W=>{const{property:M,value:K}=W.detail||{};if(!(!M||K===void 0)){if(M==="mode"){c(K);return}if(M==="entryType"){a(K);return}if(M==="isMinimized"){h(de=>ae(H({},de),{isMinimized:K}));return}if(M==="isOpen"){h(de=>ae(H({},de),{isOpen:K}));return}if(M==="type"){h(de=>ae(H({},de),{type:K}));return}if(M==="position"){E(K);return}if(M==="isFullHeight"){y(K);return}if(M==="width"){_(K);return}if(M==="isFullscreen"){A(K);return}}};return bS(z),()=>{TS(z)}},[]),_u(()=>{e&&O0(e)}),_u(()=>{const z=n||(t==null?void 0:t.type);z&&Su(z),t&&"isOpen"in t&&Ci(!!t.isOpen),t&&"isMinimized"in t&&vu(!!t.isMinimized)}),_u(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:z}=t.options;z&&wd(z),"dialogFullHeight"in t.options&&wS(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&_(t.options.dialogWidth),"isModalFullscreen"in t.options&&xd(!!t.options.isModalFullscreen)});const R=Z.useMemo(()=>({mode:u,entryType:o,status:d,previousComponentType:O||"dialog",dialogPosition:p,isDialogFullHeight:T,dialogWidth:x,isModalFullscreen:S}),[u,o,d,O,p,T,x,S]);return v.jsx(I0.Provider,{value:R,children:r})},R0=({mode:e,apiKey:t,apiToken:n,baseUrl:r,logoUrl:o,headerText:a,headerConfig:u,theme:c,openLinksInNewTab:d,globalClassName:h,isDevelopment:p=!1,componentType:E,componentConfig:T,entryType:y,entryMessage:x,disclaimerText:_,disclaimerMarkdown:S,clientContext:A,searchPlaceholder:O,searchButtonLabel:R,searchConfig:z,resetConversationMessage:W,conversationHistory:M,messagingConfig:K,__features:de,children:xe})=>v.jsx(Vv,{mode:e,baseUrl:r,apiKey:t,apiToken:n,logoUrl:o,headerText:a,headerConfig:u,entryMessage:x,theme:c,globalClassName:h,openLinksInNewTab:d,searchPlaceholder:O,searchButtonLabel:R,searchConfig:z,componentConfig:T,clientContext:A,disclaimerMarkdown:S,disclaimerText:_,resetConversationMessage:W,conversationHistory:M,isDevelopment:p,__features:de,children:v.jsx(vS,{entryType:y,componentConfig:T,componentType:E,children:v.jsx(N0,{scrt2Url:(K==null?void 0:K.scrt2Url)||"",orgId:(K==null?void 0:K.orgId)||"",esDeveloperName:(K==null?void 0:K.esDeveloperName)||"",routingAttributes:(K==null?void 0:K.routingAttributes)||{},capabilitiesVersion:K==null?void 0:K.capabilitiesVersion,enableLogging:p,children:xe})})}),ki=()=>{const e=Z.useContext(I0);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e};var _d={exports:{}},ln={},vd={exports:{}},Sd={};var P0;function SS(){return P0||(P0=1,(function(e){function t(Q,se){var C=Q.length;Q.push(se);e:for(;0<C;){var F=C-1>>>1,te=Q[F];if(0<o(te,se))Q[F]=se,Q[C]=te,C=F;else break e}}function n(Q){return Q.length===0?null:Q[0]}function r(Q){if(Q.length===0)return null;var se=Q[0],C=Q.pop();if(C!==se){Q[0]=C;e:for(var F=0,te=Q.length,k=te>>>1;F<k;){var pe=2*(F+1)-1,Se=Q[pe],Ae=pe+1,Be=Q[Ae];if(0>o(Se,C))Ae<te&&0>o(Be,Se)?(Q[F]=Be,Q[Ae]=C,F=Ae):(Q[F]=Se,Q[pe]=C,F=pe);else if(Ae<te&&0>o(Be,C))Q[F]=Be,Q[Ae]=C,F=Ae;else break e}}return se}function o(Q,se){var C=Q.sortIndex-se.sortIndex;return C!==0?C:Q.id-se.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=[],h=[],p=1,E=null,T=3,y=!1,x=!1,_=!1,S=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function R(Q){for(var se=n(h);se!==null;){if(se.callback===null)r(h);else if(se.startTime<=Q)r(h),se.sortIndex=se.expirationTime,t(d,se);else break;se=n(h)}}function z(Q){if(_=!1,R(Q),!x)if(n(d)!==null)x=!0,Ie(W);else{var se=n(h);se!==null&&fe(z,se.startTime-Q)}}function W(Q,se){x=!1,_&&(_=!1,A(de),de=-1),y=!0;var C=T;try{for(R(se),E=n(d);E!==null&&(!(E.expirationTime>se)||Q&&!ne());){var F=E.callback;if(typeof F=="function"){E.callback=null,T=E.priorityLevel;var te=F(E.expirationTime<=se);se=e.unstable_now(),typeof te=="function"?E.callback=te:E===n(d)&&r(d),R(se)}else r(d);E=n(d)}if(E!==null)var k=!0;else{var pe=n(h);pe!==null&&fe(z,pe.startTime-se),k=!1}return k}finally{E=null,T=C,y=!1}}var M=!1,K=null,de=-1,xe=5,D=-1;function ne(){return!(e.unstable_now()-D<xe)}function J(){if(K!==null){var Q=e.unstable_now();D=Q;var se=!0;try{se=K(!0,Q)}finally{se?re():(M=!1,K=null)}}else M=!1}var re;if(typeof O=="function")re=function(){O(J)};else if(typeof MessageChannel!="undefined"){var oe=new MessageChannel,be=oe.port2;oe.port1.onmessage=J,re=function(){be.postMessage(null)}}else re=function(){S(J,0)};function Ie(Q){K=Q,M||(M=!0,re())}function fe(Q,se){de=S(function(){Q(e.unstable_now())},se)}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(){x||y||(x=!0,Ie(W))},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"):xe=0<Q?Math.floor(1e3/Q):5},e.unstable_getCurrentPriorityLevel=function(){return T},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(Q){switch(T){case 1:case 2:case 3:var se=3;break;default:se=T}var C=T;T=se;try{return Q()}finally{T=C}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Q,se){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var C=T;T=Q;try{return se()}finally{T=C}},e.unstable_scheduleCallback=function(Q,se,C){var F=e.unstable_now();switch(typeof C=="object"&&C!==null?(C=C.delay,C=typeof C=="number"&&0<C?F+C:F):C=F,Q){case 1:var te=-1;break;case 2:te=250;break;case 5:te=1073741823;break;case 4:te=1e4;break;default:te=5e3}return te=C+te,Q={id:p++,callback:se,priorityLevel:Q,startTime:C,expirationTime:te,sortIndex:-1},C>F?(Q.sortIndex=C,t(h,Q),n(d)===null&&Q===n(h)&&(_?(A(de),de=-1):_=!0,fe(z,C-F))):(Q.sortIndex=te,t(d,Q),x||y||(x=!0,Ie(W))),Q},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(Q){var se=T;return function(){var C=T;T=se;try{return Q.apply(this,arguments)}finally{T=C}}}})(Sd)),Sd}var L0;function AS(){return L0||(L0=1,vd.exports=SS()),vd.exports}var D0;function CS(){if(D0)return ln;D0=1;var e=lo(),t=AS();function n(i){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function a(i,s){u(i,s),u(i+"Capture",s)}function u(i,s){for(o[i]=s,i=0;i<s.length;i++)r.add(s[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,h=/^[: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={},E={};function T(i){return d.call(E,i)?!0:d.call(p,i)?!1:h.test(i)?E[i]=!0:(p[i]=!0,!1)}function y(i,s,l,f){if(l!==null&&l.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return f?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function x(i,s,l,f){if(s===null||typeof s=="undefined"||y(i,s,l,f))return!0;if(f)return!1;if(l!==null)switch(l.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function _(i,s,l,f,g,b,w){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=f,this.attributeNamespace=g,this.mustUseProperty=l,this.propertyName=i,this.type=s,this.sanitizeURL=b,this.removeEmptyString=w}var S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){S[i]=new _(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var s=i[0];S[s]=new _(s,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){S[i]=new _(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){S[i]=new _(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){S[i]=new _(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){S[i]=new _(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){S[i]=new _(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){S[i]=new _(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){S[i]=new _(i,5,!1,i.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function O(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 s=i.replace(A,O);S[s]=new _(s,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var s=i.replace(A,O);S[s]=new _(s,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var s=i.replace(A,O);S[s]=new _(s,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){S[i]=new _(i,1,!1,i.toLowerCase(),null,!1,!1)}),S.xlinkHref=new _("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){S[i]=new _(i,1,!1,i.toLowerCase(),null,!0,!0)});function R(i,s,l,f){var g=S.hasOwnProperty(s)?S[s]:null;(g!==null?g.type!==0:f||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(x(s,l,g,f)&&(l=null),f||g===null?T(s)&&(l===null?i.removeAttribute(s):i.setAttribute(s,""+l)):g.mustUseProperty?i[g.propertyName]=l===null?g.type===3?!1:"":l:(s=g.attributeName,f=g.attributeNamespace,l===null?i.removeAttribute(s):(g=g.type,l=g===3||g===4&&l===!0?"":""+l,f?i.setAttributeNS(f,s,l):i.setAttribute(s,l))))}var z=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,W=Symbol.for("react.element"),M=Symbol.for("react.portal"),K=Symbol.for("react.fragment"),de=Symbol.for("react.strict_mode"),xe=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),ne=Symbol.for("react.context"),J=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),be=Symbol.for("react.memo"),Ie=Symbol.for("react.lazy"),fe=Symbol.for("react.offscreen"),Q=Symbol.iterator;function se(i){return i===null||typeof i!="object"?null:(i=Q&&i[Q]||i["@@iterator"],typeof i=="function"?i:null)}var C=Object.assign,F;function te(i){if(F===void 0)try{throw Error()}catch(l){var s=l.stack.trim().match(/\n( *(at )?)/);F=s&&s[1]||""}return`
16
+ `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=vi(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&Tu.assertOptions(r,{silentJSONParsing:In.transitional(In.boolean),forcedJSONParsing:In.transitional(In.boolean),clarifyTimeoutError:In.transitional(In.boolean),legacyInterceptorReqResOrdering:In.transitional(In.boolean)},!1),o!=null&&(V.isFunction(o)?n.paramsSerializer={serialize:o}:Tu.assertOptions(o,{encode:In.function,serialize:In.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Tu.assertOptions(n,{baseUrl:In.spelling("baseURL"),withXsrfToken:In.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&V.merge(a.common,a[n.method]);a&&V.forEach(["delete","get","head","post","put","patch","query","common"],x=>{delete a[x]}),n.headers=tn.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(_){if(typeof _.runWhen=="function"&&_.runWhen(n)===!1)return;d=d&&_.synchronous;const S=n.transitional||ud;S&&S.legacyInterceptorReqResOrdering?c.unshift(_.fulfilled,_.rejected):c.push(_.fulfilled,_.rejected)});const h=[];this.interceptors.response.forEach(function(_){h.push(_.fulfilled,_.rejected)});let p,E=0,T;if(!d){const x=[x0.bind(this),void 0];for(x.unshift(...c),x.push(...h),T=x.length,p=Promise.resolve(n);E<T;)p=p.then(x[E++],x[E++]);return p}T=c.length;let y=n;for(;E<T;){const x=c[E++],_=c[E++];try{y=x(y)}catch(S){_.call(this,S);break}}try{p=x0.call(this,y)}catch(x){return Promise.reject(x)}for(E=0,T=h.length;E<T;)p=p.then(h[E++],h[E++]);return p}getUri(t){t=vi(this.defaults,t);const n=f0(t.baseURL,t.url,t.allowAbsoluteUrls);return o0(n,t.params,t.paramsSerializer)}};V.forEach(["delete","get","head","options"],function(t){Si.prototype[t]=function(n,r){return this.request(vi(r||{},{method:t,url:n,data:(r||{}).data}))}}),V.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(vi(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}Si.prototype[t]=n(),t!=="query"&&(Si.prototype[t+"Form"]=n(!0))});let Fv=class tw{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(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(o);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new Ns(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 tw(function(o){t=o}),cancel:t}}};function Bv(e){return function(n){return e.apply(null,n)}}function Uv(e){return V.isObject(e)&&e.isAxiosError===!0}const md={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(md).forEach(([e,t])=>{md[t]=e});function _0(e){const t=new Si(e),n=Vm(Si.prototype.request,t);return V.extend(n,Si.prototype,t,{allOwnKeys:!0}),V.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return _0(vi(e,o))},n}const xt=_0(ks);xt.Axios=Si,xt.CanceledError=Ns,xt.CancelToken=Fv,xt.isCancel=u0,xt.VERSION=fd,xt.toFormData=gu,xt.AxiosError=ke,xt.Cancel=xt.CanceledError,xt.all=function(t){return Promise.all(t)},xt.spread=Bv,xt.isAxiosError=Uv,xt.mergeConfig=vi,xt.AxiosHeaders=tn,xt.formToJSON=e=>a0(V.isHTMLForm(e)?new FormData(e):e),xt.getAdapter=T0.getAdapter,xt.HttpStatusCode=md,xt.default=xt;const{Axios:q9,AxiosError:Y9,CanceledError:W9,isCancel:G9,CancelToken:K9,VERSION:Q9,all:X9,Cancel:J9,isAxiosError:Z9,spread:eF,toFormData:tF,AxiosHeaders:nF,HttpStatusCode:rF,formToJSON:iF,getAdapter:oF,mergeConfig:sF,create:aF}=xt;class Hv{constructor(t,n,r,o=!1,a,u){Ze(this,"CIMULATE_API_HEADER","x-cimulate-api-key");Ze(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");Ze(this,"CIMULATE_SEARCH_API_PATH","api/v1");Ze(this,"baseApiUrl");Ze(this,"headers",{});Ze(this,"fetchConfig",()=>$e(this,null,function*(){try{const t=yield xt.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}}));Ze(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const o=new URL(t);return o.hostname=o.hostname.replace(/^copilot\./,"api."),o.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,o)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class zv{constructor(t,n,r,o=!1,a,u){Ze(this,"apiService");Ze(this,"config",null);Ze(this,"getConfig",()=>$e(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}}));Ze(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));Ze(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));Ze(this,"getDescription",t=>this.getProductFieldValue(t,"description"));Ze(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));Ze(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));Ze(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));Ze(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));Ze(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));Ze(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});Ze(this,"getProductField",t=>this.config?this.config[t]:"");Ze(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new Hv(t,n,r,o,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 Ai=(e,t,n,...r)=>{if(!e)return;const o=["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]",o,n,...r)};class jv{constructor(t=!1){Ze(this,"isDevelopment");Ze(this,"_log",(t,n,...r)=>{Ai(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 $v={copilot:"Your Search Assistant",messaging:"Commerce Client"},v0=Z.createContext(null),Vv=({mode:e,logoUrl:t,headerText:n="Your Search Assistant",headerConfig:r,globalClassName:o="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:h,baseCatalogParams:p,searchPlaceholder:E,searchButtonLabel:T,searchConfig:y,componentConfig:x,conversationHistory:_,resetConversationMessage:S="",apiKey:A,apiToken:O,baseUrl:R,customerId:z,tenantId:W,theme:M,isDevelopment:K,__features:de,children:xe})=>{const D=e==="messaging",ne=Z.useMemo(()=>D?{config:null}:new zv(R,A,O,K,z,W),[D,R,A,O,K,z,W]),J=Z.useMemo(()=>new jv(K),[K]);Z.useEffect(()=>{D||!ne||ne.config||ne.getConfig()},[ne,D]);const re=Z.useMemo(()=>n_(M),[M]),oe=Z.useMemo(()=>{const fe=(y==null?void 0:y.placeholder)||E,Q=(y==null?void 0:y.buttonLabel)||T;let se="icon";return y!=null&&y.buttonType?se=y.buttonType:T&&(se="text"),ae(H({},y||{}),{placeholder:fe,buttonLabel:Q,buttonType:se})},[y,E,T]),be=Z.useMemo(()=>ae(H({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:n||$v[e!=null?e:"copilot"]}),[r,t,n,e]),Ie=Z.useMemo(()=>({configModule:ne,mode:e!=null?e:"copilot",headerConfig:be,entryMessage:a,globalClassName:o,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:h,baseCatalogParams:p,themeVariables:re,logger:J,searchConfig:oe,enableMinimize:!!(x!=null&&x.enableMinimize),resetConversationMessage:S,conversationHistory:{sinceHours:typeof(_==null?void 0:_.sinceHours)=="number"?_.sinceHours:1,limit:_==null?void 0:_.limit},features:de}),[ne,e,be,a,o,h,p,c,d,u,oe,x,S,J,re,_,de]);return v.jsx(v0.Provider,{value:Ie,children:xe})},At=()=>{const e=Z.useContext(v0);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e},qv=["markdown","product_carousel","suggestions","cart"],xu=-1;function Yv(e){if(!e||!e.trim())return null;try{const t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.type=="string"&&typeof t.index=="number")return qv.includes(t.type)?t:null}catch(t){}return{type:"markdown",index:xu,data:{content:e}}}function Wv(e,t){if(t.index===xu){const o=e[e.length-1];if(o&&o.type==="markdown"&&o.index===xu&&t.type==="markdown"){const a={type:"markdown",index:xu,data:{content:o.data.content+t.data.content}};return[...e.slice(0,-1),a]}return[...e,t]}const n=e.findIndex(o=>o.index===t.index);return[...n>=0?e.map((o,a)=>a===n?t:o):[...e,t]].sort((o,a)=>o.index-a.index)}const S0={connectionStatus:"disconnected",loading:!0,conversationId:null,messages:[],streamingBlocks:[],isAgentTyping:!1,progressMessage:"",routingResult:null,error:null};function Gv(e,t){switch(t.type){case"SET_CONNECTION_STATUS":return H(ae(H({},e),{connectionStatus:t.status}),t.status==="connected"||t.status==="connecting"?{error:null}:{});case"SET_LOADING":return ae(H({},e),{loading:t.isLoading});case"SET_CONVERSATION_ID":return ae(H({},e),{conversationId:t.id});case"ADD_MESSAGE":return ae(H({},e),{messages:[...e.messages,ae(H({},t.message),{type:"ADD_MESSAGE"})]});case"APPEND_STREAMING_TOKEN":{const n=Yv(t.token);return n?ae(H({},e),{streamingBlocks:Wv(e.streamingBlocks,n)}):e}case"FLUSH_STREAMING":return ae(H({},e),{messages:[...e.messages,ae(H({},t.message),{type:"FLUSH_STREAMING"})],streamingBlocks:[],isAgentTyping:!1,loading:!1,progressMessage:""});case"SET_AGENT_TYPING":return ae(H({},e),{isAgentTyping:t.isTyping,loading:t.isTyping});case"SET_PROGRESS_MESSAGE":return ae(H({},e),{progressMessage:t.message});case"SET_ROUTING_RESULT":return ae(H({},e),{routingResult:t.result});case"SET_ERROR":return ae(H({},e),{error:t.error,loading:!1,progressMessage:""});case"LOAD_HISTORY":return ae(H({},e),{messages:t.messages,loading:!1});case"RESET":return ae(H({},S0),{connectionStatus:e.connectionStatus,loading:!0});default:return e}}const A0=Z.createContext({connectionStatus:"disconnected",isConnected:!1,isAgentTyping:!1,conversationId:null,messages:[],streamingBlocks:[],progressMessage:"",loading:!0,error:null,sendMessage:()=>{},resetConversation:()=>{}});function gd(e,t){return`cim_af_conv_${e}_${t}`}function Ed(e,t){return Date.now()-e>t}function Kv(e,t,n){try{const r=gd(e,t),o=sessionStorage.getItem(r);if(!o)return null;const a=JSON.parse(o);if(!a||typeof a!="object"||!("conversationId"in a)||!("storedAt"in a))return null;const u=a;return typeof u.conversationId!="string"||!u.conversationId?null:typeof u.storedAt!="number"||Ed(u.storedAt,n)?(sessionStorage.removeItem(r),null):u}catch(r){return null}}function Os(e,t,n){try{const r=gd(e,t),o={conversationId:n,storedAt:Date.now()};sessionStorage.setItem(r,JSON.stringify(o))}catch(r){}}function wu(e,t){try{const n=gd(e,t);sessionStorage.removeItem(n)}catch(n){}}function yd(e,t){return`cim_af_ct_${e}_${t}`}function C0(e,t,n){try{const r=yd(e,t),o=sessionStorage.getItem(r);if(!o)return null;const a=JSON.parse(o);if(!a||typeof a!="object"||!("accessToken"in a)||!("lastEventId"in a)||!("storedAt"in a))return null;const u=a;return typeof u.accessToken!="string"||!u.accessToken||typeof u.lastEventId!="string"||!u.lastEventId?null:typeof u.storedAt!="number"||Date.now()-u.storedAt>n?(sessionStorage.removeItem(r),null):u}catch(r){return null}}function Qv(e,t,n,r){try{const o=yd(e,t),a={accessToken:n,lastEventId:r,storedAt:Date.now()};sessionStorage.setItem(o,JSON.stringify(a))}catch(o){}}function Xv(e,t){try{const n=yd(e,t);sessionStorage.removeItem(n)}catch(n){}}function Jv(e,t){return`cim_af_conv_${e}_${t}`}function Zv(e,t){try{if(typeof BroadcastChannel=="undefined")return null;const n=Jv(e,t);return new BroadcastChannel(n)}catch(n){return null}}function eS(e,t=500){return e?new Promise(n=>{let r=!1;const o=setTimeout(()=>{r||(r=!0,e.removeEventListener("message",a),n(null))},t);function a(u){var c;r||((c=u.data)==null?void 0:c.type)==="conversation_response"&&(r=!0,clearTimeout(o),e.removeEventListener("message",a),n({conversationId:u.data.conversationId,storedAt:u.data.storedAt,continuationToken:u.data.continuationToken,lastEventId:u.data.lastEventId}))}e.addEventListener("message",a);try{e.postMessage({type:"request_conversation"})}catch(u){r||(r=!0,clearTimeout(o),e.removeEventListener("message",a),n(null))}}):Promise.resolve(null)}function tS(e,t,n){if(!e)return()=>{};function r(o){var a;if((a=o.data)!=null&&a.type)switch(o.data.type){case"request_conversation":{const u=t();if(u!=null&&u.conversationId)try{e.postMessage({type:"conversation_response",conversationId:u.conversationId,storedAt:Date.now(),continuationToken:u.continuationToken,lastEventId:u.lastEventId})}catch(c){}break}case"conversation_cleared":{n==null||n();break}}}return e.addEventListener("message",r),()=>{e.removeEventListener("message",r)}}function nS(e){if(e)try{e.postMessage({type:"conversation_cleared"})}catch(t){}}function rS(e){if(e)try{e.close()}catch(t){}}function iS(e){switch(e){case"EndUser":case"Customer":return"user";case"Agent":case"Chatbot":return"agent";default:return"system"}}function oS(e){if(!e)return{};if(typeof e=="string")try{return JSON.parse(e)}catch(t){return{}}return e}function k0(e,...t){let n=e;for(const r of t){if(n==null||typeof n!="object")return"";n=n[r]}return typeof n=="string"?n:""}function sS(e){if(e.entryType!=="Message")return null;const n=oS(e.entryPayload).abstractMessage;if(!n)return null;const r=k0(n,"staticContent","text")||k0(n,"content","text")||"";if(!r)return null;const o=iS(e.sender.role);return{id:e.identifier,role:o,content:r,timestamp:new Date(e.transcriptedTimestamp).toISOString(),sender:{role:e.sender.role,name:e.senderDisplayName}}}function aS(e){const t=[];for(const n of e){const r=sS(n);r&&t.push(r)}return t}function uS(e){const{orgId:t,esDeveloperName:n,routingAttributes:r,conversationHistory:o}=e,a=Z.useRef(null),u=Z.useRef(null),c=Z.useRef(null),d=o.sinceHours*60*60*1e3,h=Z.useCallback(()=>(c.current||(c.current=eS(a.current)),c.current),[]);Z.useEffect(()=>{const S=Zv(t,n);a.current=S,c.current=null;const A=tS(S,()=>{const O=u.current;if(!O)return null;const R=C0(t,n,d);return{conversationId:O,continuationToken:R==null?void 0:R.accessToken,lastEventId:R==null?void 0:R.lastEventId}},()=>{wu(t,n),u.current=null});return()=>{A(),rS(S),a.current=null}},[t,n,d]);const p=Z.useCallback(S=>$e(null,null,function*(){let A=Kv(t,n,d);if(!A){const O=yield h();O&&!Ed(O.storedAt,d)&&(A=O)}if(!A){const O=yield S.createConversation(r);return Os(t,n,O),u.current=O,{conversationId:O,restoredMessages:[],resumed:!1}}try{const O=Date.now()-d,z=(yield S.listConversations({conversationId:A.conversationId,startTimestamp:O})).conversations.find(M=>M.conversationId===A.conversationId&&!M.isConversationClosed);if(!z){wu(t,n);const M=yield S.createConversation(r);return Os(t,n,M),u.current=M,{conversationId:M,restoredMessages:[],resumed:!1}}S.resumeConversation(z.conversationId),u.current=z.conversationId,Os(t,n,z.conversationId);let W=[];try{const M=yield S.listConversationEntries(z.conversationId,{limit:o.limit,startTimestamp:O,direction:"FromStart"});W=aS(M.conversationEntries)}catch(M){}return{conversationId:z.conversationId,restoredMessages:W,resumed:!0}}catch(O){wu(t,n);const R=yield S.createConversation(r);return Os(t,n,R),u.current=R,{conversationId:R,restoredMessages:[],resumed:!1}}}),[t,n,r,o,d,h]),E=Z.useCallback(S=>{Os(t,n,S),u.current=S},[t,n]),T=Z.useCallback(()=>{wu(t,n),Xv(t,n),nS(a.current),u.current=null},[t,n]),y=Z.useCallback(()=>{const S=C0(t,n,d);return S?{continuationToken:S.accessToken,lastEventId:S.lastEventId}:null},[t,n,d]),x=Z.useCallback(()=>$e(null,null,function*(){const S=yield h();return!(S!=null&&S.continuationToken)||Ed(S.storedAt,d)?null:{continuationToken:S.continuationToken,lastEventId:S.lastEventId}}),[d,h]),_=Z.useCallback(S=>$e(null,null,function*(){try{const{accessToken:A,lastEventId:O}=yield S.generateContinuationToken();Qv(t,n,A,O)}catch(A){}}),[t,n]);return{initializeConversation:p,persistConversationId:E,clearPersistedConversation:T,getStoredConnectOptions:y,getPeerConnectOptions:x,persistContinuationToken:_}}const lS="Your session ended due to inactivity. Starting a new session…";function cS(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="auth"?!0:t.type==="api"&&(t.statusCode===401||t.statusCode===403)}const N0=({scrt2Url:e,orgId:t,esDeveloperName:n,routingAttributes:r,capabilitiesVersion:o,enableLogging:a=!1,onConnect:u,onMessage:c,onError:d,children:h})=>{const{logger:p,conversationHistory:E}=At(),[T,y]=Z.useReducer(Gv,S0),x=uS({orgId:t,esDeveloperName:n,routingAttributes:r,conversationHistory:E}),_=Z.useRef(null),S=Z.useRef(c),A=Z.useRef(d),O=Z.useRef(u),R=Z.useRef(!1),z=Z.useRef(0);S.current=c,A.current=d,O.current=u,Z.useEffect(()=>{const D=new t_({baseURL:e,orgId:t,esDeveloperName:n,options:H({enableLogging:a},o?{capabilitiesVersion:o}:{})});return _.current=D,D.on("connected",()=>{var J;y({type:"SET_CONNECTION_STATUS",status:"connected"}),(J=O.current)==null||J.call(O)}),D.on("disconnected",()=>{y({type:"SET_CONNECTION_STATUS",status:"disconnected"})}),D.on("reconnecting",()=>{y({type:"SET_CONNECTION_STATUS",status:"reconnecting"})}),D.on("message",J=>{var oe;const re={id:J.messageId||crypto.randomUUID(),role:"agent",content:J.content,timestamp:J.timestamp,sender:J.sender,raw:J};p==null||p.log("🦜 MessagingProvider message received (FLUSH_STREAMING)",{messageId:re.id,tokensBeforeFlush:z.current,streamedFinalOnly:z.current===0}),z.current=0,y({type:"FLUSH_STREAMING",message:re}),(oe=S.current)==null||oe.call(S,re)}),D.on("streaming_token",J=>{z.current+=1,y({type:"APPEND_STREAMING_TOKEN",token:J.token})}),D.on("typing_started",()=>{y({type:"SET_AGENT_TYPING",isTyping:!0})}),D.on("typing_stopped",()=>{y({type:"SET_AGENT_TYPING",isTyping:!1})}),D.on("progress_indicator",J=>{y({type:"SET_PROGRESS_MESSAGE",message:J.message})}),D.on("routing_result",J=>{var re;if(y({type:"SET_ROUTING_RESULT",result:J}),!J.isSuccessful){const oe=`Routing failed: ${J.failureType||"unknown"}`;y({type:"SET_ERROR",error:oe}),(re=A.current)==null||re.call(A,oe)}}),D.on("participant_changed",J=>{if(J.participant.name==="Automated Process")return;const re={id:crypto.randomUUID(),role:"system",content:J.action==="add"?`${J.participant.name||"Agent"} joined the conversation`:`${J.participant.name||"Agent"} left the conversation`,timestamp:new Date().toISOString()};p==null||p.log("🦜 MessagingProvider participant_changed event received",{event:J}),y({type:"ADD_MESSAGE",message:re})}),D.on("conversation_closed",()=>{const J={id:crypto.randomUUID(),role:"system",content:"Conversation reset",timestamp:new Date().toISOString()};y({type:"ADD_MESSAGE",message:J}),y({type:"SET_CONVERSATION_ID",id:null}),x.clearPersistedConversation()}),D.on("error",J=>{var re;if(p==null||p.log("🦜 MessagingProvider ERROR event received",{event:J}),J.code==="SESSION_EXPIRED"){M.current();return}y({type:"SET_ERROR",error:J.message}),J.recoverable||y({type:"SET_CONNECTION_STATUS",status:"error"}),(re=A.current)==null||re.call(A,J.message)}),y({type:"SET_CONNECTION_STATUS",status:"connecting"}),$e(null,null,function*(){let J=x.getStoredConnectOptions(),re=!1;J||(J=yield x.getPeerConnectOptions(),re=!!J);try{yield D.connect(J!=null?J:void 0)}catch(be){if(J)p==null||p.log("Continuation token failed, falling back to fresh connect"),re||x.clearPersistedConversation(),yield D.connect();else throw be}yield x.persistContinuationToken(D);const oe=yield x.initializeConversation(D);y({type:"SET_CONVERSATION_ID",id:oe.conversationId}),oe.resumed&&oe.restoredMessages.length>0&&y({type:"LOAD_HISTORY",messages:oe.restoredMessages})}).catch(J=>{var re;y({type:"SET_CONNECTION_STATUS",status:"error"}),y({type:"SET_ERROR",error:J.message}),(re=A.current)==null||re.call(A,J.message)}),()=>{D.disconnect(),D.off(),_.current=null}},[e,t,n,o]),Z.useEffect(()=>{const D=()=>{document.visibilityState==="visible"&&_.current&&_.current.reconnect()};return document.addEventListener("visibilitychange",D),()=>{document.removeEventListener("visibilitychange",D)}},[]);const W=Z.useCallback(D=>$e(null,null,function*(){var J;const ne=_.current;if(!(!ne||R.current)){R.current=!0,y({type:"ADD_MESSAGE",message:{id:crypto.randomUUID(),role:"system",content:lS,timestamp:new Date().toISOString()}}),x.clearPersistedConversation(),y({type:"SET_CONNECTION_STATUS",status:"connecting"});try{ne.disconnect(),yield ne.connect(),yield x.persistContinuationToken(ne);const re=yield ne.createConversation(r);y({type:"SET_CONVERSATION_ID",id:re}),y({type:"SET_CONNECTION_STATUS",status:"connected"}),x.persistConversationId(re),D&&(y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),yield ne.sendMessage(D))}catch(re){const oe=re instanceof Error?re.message:String(re);y({type:"SET_ERROR",error:oe}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(J=A.current)==null||J.call(A,oe)}finally{R.current=!1}}}),[r,x]),M=Z.useRef(W);M.current=W;const K=Z.useCallback(D=>{if(!D.trim())return;const ne=_.current;if(!ne)return;const J={id:crypto.randomUUID(),role:"user",content:D,timestamp:new Date().toISOString()};y({type:"ADD_MESSAGE",message:J}),y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),ne.sendMessage(D).catch(re=>{var oe;if(cS(re)){M.current(D);return}y({type:"SET_ERROR",error:re.message}),(oe=A.current)==null||oe.call(A,re.message)})},[]),de=Z.useCallback(()=>{const D=_.current;D&&(x.clearPersistedConversation(),y({type:"RESET"}),y({type:"SET_CONNECTION_STATUS",status:"connecting"}),D.endConversation().then(()=>(D.disconnect(),D.connect())).then(()=>$e(null,null,function*(){return yield x.persistContinuationToken(D),D.createConversation(r)})).then(ne=>{y({type:"SET_CONVERSATION_ID",id:ne}),y({type:"SET_CONNECTION_STATUS",status:"connected"}),x.persistConversationId(ne)}).catch(ne=>{var J;y({type:"SET_ERROR",error:ne.message}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(J=A.current)==null||J.call(A,ne.message)}))},[r,x]),xe=Z.useMemo(()=>({connectionStatus:T.connectionStatus,isConnected:T.connectionStatus==="connected"&&T.conversationId!==null,isAgentTyping:T.isAgentTyping,conversationId:T.conversationId,messages:T.messages,streamingBlocks:T.streamingBlocks,progressMessage:T.progressMessage,error:T.error,loading:T.loading,sendMessage:K,resetConversation:de}),[T,K,de]);return v.jsx(A0.Provider,{value:xe,children:h})};function dS(){var e=Z.useRef(!0);return e.current?(e.current=!1,!0):e.current}function fS(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function hS(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var bd=typeof window!="undefined",_u=function(e){Z.useEffect(e,[])},pS=function(e){var t=Z.useRef(e);t.current=e,_u(function(){return function(){return t.current()}})},mS=function(e){var t=Z.useRef(0),n=Z.useState(e),r=n[0],o=n[1],a=Z.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){o(u)})},[]);return pS(function(){cancelAnimationFrame(t.current)}),[r,a]},gS=function(e,t){return e===t};function ES(e,t){t===void 0&&(t=gS);var n=Z.useRef(),r=Z.useRef(e),o=dS();return!o&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var yS=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,o=t.initialHeight,a=o===void 0?1/0:o,u=t.onChange,c=mS({width:bd?window.innerWidth:r,height:bd?window.innerHeight:a}),d=c[0],h=c[1];return Z.useEffect(function(){if(bd){var p=function(){var E=window.innerWidth,T=window.innerHeight;h({width:E,height:T}),u&&u(E,T)};return fS(window,"resize",p),function(){hS(window,"resize",p)}}},[]),d};const Td="cimulate:ui-state-update",bS=e=>{window.addEventListener(Td,e)},TS=e=>{window.removeEventListener(Td,e)},xS=(e,t)=>{const n=new CustomEvent(Td,{detail:{property:e,value:t}});window.dispatchEvent(n)},O0=e=>{if(!["ask_cim","search","browse","pdp"].includes(e))throw new Error(`Invalid entryType: "${e}". Must be 'ask_cim', 'search', 'browse', or 'pdp'.`);tt.entryTypeProxy.entryType=e},Ci=e=>{const t=tt.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;tt.statusProxy.isOpen=n,n&&(tt.statusProxy.isMinimized=!1)},vu=e=>{const t=tt.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;tt.statusProxy.isMinimized=n,n&&(tt.statusProxy.isOpen=!1)},xd=e=>{tt.modalProxy.isFullscreen=e},Su=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);tt.statusProxy.type=e,e==="dialog"||e==="chat"?tt.modeProxy.mode="embedded":tt.modeProxy.mode="standalone"},wd=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(", ")}.`);tt.dialogProxy.position=e},wS=e=>{const t=tt.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;tt.dialogProxy.isFullHeight=n};class _S{constructor(){Ze(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}});Ze(this,"connectedProxy");Ze(this,"modeProxy");Ze(this,"entryTypeProxy");Ze(this,"statusProxy");Ze(this,"dialogProxy");Ze(this,"modalProxy",{isFullscreen:!1});Ze(this,"_fullGet",(t,n)=>Reflect.get(t,n));Ze(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return xS(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 tt=new _S,I0=Z.createContext({mode:tt.modeProxy.mode,entryType:tt.entryType,status:tt.statusProxy,dialogPosition:tt.dialogProxy.position,isDialogFullHeight:tt.dialogProxy.isFullHeight,dialogWidth:tt.dialogProxy.width,isModalFullscreen:tt.modalProxy.isFullscreen,previousComponentType:tt.statusProxy.type}),vS=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[o,a]=Z.useState(e!=null?e:tt.entryTypeProxy.entryType),[u,c]=Z.useState(tt.modeProxy.mode),[d,h]=Z.useState({type:n||tt.statusProxy.type,isOpen:tt.statusProxy.isOpen,isMinimized:tt.statusProxy.isMinimized}),[p,E]=Z.useState(tt.dialogProxy.position),[T,y]=Z.useState(tt.dialogProxy.isFullHeight),[x,_]=Z.useState(tt.dialogProxy.width),[S,A]=Z.useState(tt.modalProxy.isFullscreen),O=ES(d.type);Z.useEffect(()=>{const z=W=>{const{property:M,value:K}=W.detail||{};if(!(!M||K===void 0)){if(M==="mode"){c(K);return}if(M==="entryType"){a(K);return}if(M==="isMinimized"){h(de=>ae(H({},de),{isMinimized:K}));return}if(M==="isOpen"){h(de=>ae(H({},de),{isOpen:K}));return}if(M==="type"){h(de=>ae(H({},de),{type:K}));return}if(M==="position"){E(K);return}if(M==="isFullHeight"){y(K);return}if(M==="width"){_(K);return}if(M==="isFullscreen"){A(K);return}}};return bS(z),()=>{TS(z)}},[]),_u(()=>{e&&O0(e)}),_u(()=>{const z=n||(t==null?void 0:t.type);z&&Su(z),t&&"isOpen"in t&&Ci(!!t.isOpen),t&&"isMinimized"in t&&vu(!!t.isMinimized)}),_u(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:z}=t.options;z&&wd(z),"dialogFullHeight"in t.options&&wS(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&_(t.options.dialogWidth),"isModalFullscreen"in t.options&&xd(!!t.options.isModalFullscreen)});const R=Z.useMemo(()=>({mode:u,entryType:o,status:d,previousComponentType:O||"dialog",dialogPosition:p,isDialogFullHeight:T,dialogWidth:x,isModalFullscreen:S}),[u,o,d,O,p,T,x,S]);return v.jsx(I0.Provider,{value:R,children:r})},R0=({mode:e,apiKey:t,apiToken:n,baseUrl:r,logoUrl:o,headerText:a,headerConfig:u,theme:c,openLinksInNewTab:d,globalClassName:h,isDevelopment:p=!1,componentType:E,componentConfig:T,entryType:y,entryMessage:x,disclaimerText:_,disclaimerMarkdown:S,clientContext:A,searchPlaceholder:O,searchButtonLabel:R,searchConfig:z,resetConversationMessage:W,conversationHistory:M,messagingConfig:K,__features:de,children:xe})=>v.jsx(Vv,{mode:e,baseUrl:r,apiKey:t,apiToken:n,logoUrl:o,headerText:a,headerConfig:u,entryMessage:x,theme:c,globalClassName:h,openLinksInNewTab:d,searchPlaceholder:O,searchButtonLabel:R,searchConfig:z,componentConfig:T,clientContext:A,disclaimerMarkdown:S,disclaimerText:_,resetConversationMessage:W,conversationHistory:M,isDevelopment:p,__features:de,children:v.jsx(vS,{entryType:y,componentConfig:T,componentType:E,children:v.jsx(N0,{scrt2Url:(K==null?void 0:K.scrt2Url)||"",orgId:(K==null?void 0:K.orgId)||"",esDeveloperName:(K==null?void 0:K.esDeveloperName)||"",routingAttributes:(K==null?void 0:K.routingAttributes)||{},capabilitiesVersion:K==null?void 0:K.capabilitiesVersion,enableLogging:p,children:xe})})}),ki=()=>{const e=Z.useContext(I0);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e};var _d={exports:{}},ln={},vd={exports:{}},Sd={};var P0;function SS(){return P0||(P0=1,(function(e){function t(Q,se){var C=Q.length;Q.push(se);e:for(;0<C;){var F=C-1>>>1,te=Q[F];if(0<o(te,se))Q[F]=se,Q[C]=te,C=F;else break e}}function n(Q){return Q.length===0?null:Q[0]}function r(Q){if(Q.length===0)return null;var se=Q[0],C=Q.pop();if(C!==se){Q[0]=C;e:for(var F=0,te=Q.length,k=te>>>1;F<k;){var pe=2*(F+1)-1,Se=Q[pe],Ae=pe+1,Be=Q[Ae];if(0>o(Se,C))Ae<te&&0>o(Be,Se)?(Q[F]=Be,Q[Ae]=C,F=Ae):(Q[F]=Se,Q[pe]=C,F=pe);else if(Ae<te&&0>o(Be,C))Q[F]=Be,Q[Ae]=C,F=Ae;else break e}}return se}function o(Q,se){var C=Q.sortIndex-se.sortIndex;return C!==0?C:Q.id-se.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=[],h=[],p=1,E=null,T=3,y=!1,x=!1,_=!1,S=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function R(Q){for(var se=n(h);se!==null;){if(se.callback===null)r(h);else if(se.startTime<=Q)r(h),se.sortIndex=se.expirationTime,t(d,se);else break;se=n(h)}}function z(Q){if(_=!1,R(Q),!x)if(n(d)!==null)x=!0,Ie(W);else{var se=n(h);se!==null&&fe(z,se.startTime-Q)}}function W(Q,se){x=!1,_&&(_=!1,A(de),de=-1),y=!0;var C=T;try{for(R(se),E=n(d);E!==null&&(!(E.expirationTime>se)||Q&&!ne());){var F=E.callback;if(typeof F=="function"){E.callback=null,T=E.priorityLevel;var te=F(E.expirationTime<=se);se=e.unstable_now(),typeof te=="function"?E.callback=te:E===n(d)&&r(d),R(se)}else r(d);E=n(d)}if(E!==null)var k=!0;else{var pe=n(h);pe!==null&&fe(z,pe.startTime-se),k=!1}return k}finally{E=null,T=C,y=!1}}var M=!1,K=null,de=-1,xe=5,D=-1;function ne(){return!(e.unstable_now()-D<xe)}function J(){if(K!==null){var Q=e.unstable_now();D=Q;var se=!0;try{se=K(!0,Q)}finally{se?re():(M=!1,K=null)}}else M=!1}var re;if(typeof O=="function")re=function(){O(J)};else if(typeof MessageChannel!="undefined"){var oe=new MessageChannel,be=oe.port2;oe.port1.onmessage=J,re=function(){be.postMessage(null)}}else re=function(){S(J,0)};function Ie(Q){K=Q,M||(M=!0,re())}function fe(Q,se){de=S(function(){Q(e.unstable_now())},se)}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(){x||y||(x=!0,Ie(W))},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"):xe=0<Q?Math.floor(1e3/Q):5},e.unstable_getCurrentPriorityLevel=function(){return T},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(Q){switch(T){case 1:case 2:case 3:var se=3;break;default:se=T}var C=T;T=se;try{return Q()}finally{T=C}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Q,se){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var C=T;T=Q;try{return se()}finally{T=C}},e.unstable_scheduleCallback=function(Q,se,C){var F=e.unstable_now();switch(typeof C=="object"&&C!==null?(C=C.delay,C=typeof C=="number"&&0<C?F+C:F):C=F,Q){case 1:var te=-1;break;case 2:te=250;break;case 5:te=1073741823;break;case 4:te=1e4;break;default:te=5e3}return te=C+te,Q={id:p++,callback:se,priorityLevel:Q,startTime:C,expirationTime:te,sortIndex:-1},C>F?(Q.sortIndex=C,t(h,Q),n(d)===null&&Q===n(h)&&(_?(A(de),de=-1):_=!0,fe(z,C-F))):(Q.sortIndex=te,t(d,Q),x||y||(x=!0,Ie(W))),Q},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(Q){var se=T;return function(){var C=T;T=se;try{return Q.apply(this,arguments)}finally{T=C}}}})(Sd)),Sd}var L0;function AS(){return L0||(L0=1,vd.exports=SS()),vd.exports}var D0;function CS(){if(D0)return ln;D0=1;var e=lo(),t=AS();function n(i){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function a(i,s){u(i,s),u(i+"Capture",s)}function u(i,s){for(o[i]=s,i=0;i<s.length;i++)r.add(s[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,h=/^[: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={},E={};function T(i){return d.call(E,i)?!0:d.call(p,i)?!1:h.test(i)?E[i]=!0:(p[i]=!0,!1)}function y(i,s,l,f){if(l!==null&&l.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return f?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function x(i,s,l,f){if(s===null||typeof s=="undefined"||y(i,s,l,f))return!0;if(f)return!1;if(l!==null)switch(l.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function _(i,s,l,f,g,b,w){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=f,this.attributeNamespace=g,this.mustUseProperty=l,this.propertyName=i,this.type=s,this.sanitizeURL=b,this.removeEmptyString=w}var S={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){S[i]=new _(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var s=i[0];S[s]=new _(s,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){S[i]=new _(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){S[i]=new _(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){S[i]=new _(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){S[i]=new _(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){S[i]=new _(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){S[i]=new _(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){S[i]=new _(i,5,!1,i.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function O(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 s=i.replace(A,O);S[s]=new _(s,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var s=i.replace(A,O);S[s]=new _(s,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var s=i.replace(A,O);S[s]=new _(s,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){S[i]=new _(i,1,!1,i.toLowerCase(),null,!1,!1)}),S.xlinkHref=new _("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){S[i]=new _(i,1,!1,i.toLowerCase(),null,!0,!0)});function R(i,s,l,f){var g=S.hasOwnProperty(s)?S[s]:null;(g!==null?g.type!==0:f||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(x(s,l,g,f)&&(l=null),f||g===null?T(s)&&(l===null?i.removeAttribute(s):i.setAttribute(s,""+l)):g.mustUseProperty?i[g.propertyName]=l===null?g.type===3?!1:"":l:(s=g.attributeName,f=g.attributeNamespace,l===null?i.removeAttribute(s):(g=g.type,l=g===3||g===4&&l===!0?"":""+l,f?i.setAttributeNS(f,s,l):i.setAttribute(s,l))))}var z=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,W=Symbol.for("react.element"),M=Symbol.for("react.portal"),K=Symbol.for("react.fragment"),de=Symbol.for("react.strict_mode"),xe=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),ne=Symbol.for("react.context"),J=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),be=Symbol.for("react.memo"),Ie=Symbol.for("react.lazy"),fe=Symbol.for("react.offscreen"),Q=Symbol.iterator;function se(i){return i===null||typeof i!="object"?null:(i=Q&&i[Q]||i["@@iterator"],typeof i=="function"?i:null)}var C=Object.assign,F;function te(i){if(F===void 0)try{throw Error()}catch(l){var s=l.stack.trim().match(/\n( *(at )?)/);F=s&&s[1]||""}return`
17
17
  `+F+i}var k=!1;function pe(i,s){if(!i||k)return"";k=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(X){var f=X}Reflect.construct(i,[],s)}else{try{s.call()}catch(X){f=X}i.call(s.prototype)}else{try{throw Error()}catch(X){f=X}i()}}catch(X){if(X&&f&&typeof X.stack=="string"){for(var g=X.stack.split(`
18
18
  `),b=f.stack.split(`
19
19
  `),w=g.length-1,P=b.length-1;1<=w&&0<=P&&g[w]!==b[P];)P--;for(;1<=w&&0<=P;w--,P--)if(g[w]!==b[P]){if(w!==1||P!==1)do if(w--,P--,0>P||g[w]!==b[P]){var B=`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cimulate/copilot-widget",
3
3
  "description": "A frontend SDK for Cimulate Copilot",
4
- "version": "1.12.0",
4
+ "version": "1.12.1",
5
5
  "keywords": [
6
6
  "cimulate",
7
7
  "copilot",