@accurix/centrinfo-widget 1.1.0 → 4.0.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.
- package/dist/cdn/centrinfo-widget.js +303 -61
- package/dist/cdn/manifest.json +6 -6
- package/dist/{config-CHvO9tW1.mjs → config-CkU4urQY.mjs} +7 -7
- package/dist/{config-BfVMFkZ4.cjs → config-DsNMbdKp.cjs} +7 -7
- package/dist/index.cjs +284 -42
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +284 -42
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.cts +36 -7
- package/dist/runtime.d.mts +36 -7
- package/dist/runtime.mjs +1 -1
- package/dist/{types-BwixZ4yh.d.mts → types-1ZJJY7Da.d.mts} +280 -8
- package/dist/{types-CiW6Ilds.d.cts → types-B0r4SXaT.d.cts} +280 -8
- package/package.json +4 -4
package/dist/cdn/manifest.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "@accurix/centrinfo-widget",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"fileName": "centrinfo-widget.js",
|
|
5
|
-
"cdnPath": "centrinfo/js/sdk-centrinfo-widget-
|
|
6
|
-
"bytes":
|
|
7
|
-
"gzipBytes":
|
|
8
|
-
"sha256": "
|
|
9
|
-
"sri": "sha256-
|
|
5
|
+
"cdnPath": "centrinfo/js/sdk-centrinfo-widget-v4.0.0/centrinfo-widget.js",
|
|
6
|
+
"bytes": 802027,
|
|
7
|
+
"gzipBytes": 251867,
|
|
8
|
+
"sha256": "03fb3eb2cc132bb8db6150a3eb0c6e80006d1c3fbcc1420a42807e2140765b0f",
|
|
9
|
+
"sri": "sha256-A/s+sswTK7jbYVCj6wxugABtHD+8wUIKQoB+IUB2Ww8="
|
|
10
10
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{createContext as e}from"preact";import{useCallback as t,useContext as n,useEffect as r,useMemo as i,useRef as a,useState as o}from"preact/hooks";import{Fragment as s,jsx as c,jsxs as l}from"preact/jsx-runtime";var u=Object.defineProperty,d=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t&&u(n,Symbol.toStringTag,{value:`Module`}),n},f=class extends Error{constructor(e,t){super(t),this.status=e,this.name=`ApiError`}};const p=()=>({agentName:`Accurix`,greeting:`Hi! 👋 How can I help you today?`,widgetModule:`chat`,assistantMediaKind:`image`,soundEnabled:!0,voiceOutputEnabled:!1,talkbackMode:`text`,allowVoiceInput:!1,memoryEnabled:!0,memoryRetentionDays:30,memoryMessageCap:50,availableActions:[]}),m=e=>{typeof console>`u`||console.warn(`[centrinfo-widget] Could not load saved widget configuration from the API (${e}). Showing default widget chrome. Check data-token, data-api-base, CORS, and backend availability.`)},h=(e,t={})=>{let n=(e.disclaimerText?.trim())?.toLowerCase(),r=t.agentName?.trim()||e.agentName?.trim()||`Accurix`,i=t.agentAvatarUrl?.trim()||e.agentAvatarUrl?.trim();return{...e,agentName:r,agentAvatarUrl:i||void 0,disclaimerText:n===`sara is an ai assistant; answers may be imperfect.`||n?.includes(`sara is an ai assistant`)?`Accurix is an AI assistant; answers may be imperfect.`:e.disclaimerText}};var g=class{constructor(e,t,n,r,i={},a,o,s=`floating`){this.baseUrl=e,this.token=t,this.gifApiKey=n,this.analyticsContextToken=r,this.bootstrapOverrides=i,this.identityToken=a,this.identityTokenProvider=o,this.chatSurface=s}async currentIdentityToken(){return this.identityTokenProvider&&(this.identityToken=(await this.identityTokenProvider())?.trim()||void 0),this.identityToken}headers(e=!0){let t={Authorization:`Bearer ${this.token}`};return e&&(t[`Content-Type`]=`application/json`),t}async json(e){let t;try{t=await e.json()}catch{t=void 0}if(!e.ok){let n=v(t)??`request failed (${e.status})`;throw new f(e.status,n)}return t?.data??t}async bootstrap(){try{let e=await fetch(`${this.baseUrl}/public-chat/bootstrap`,{headers:this.headers(!1)});if(!e.ok)return m(`bootstrap request failed with ${e.status}`),h(p(),this.bootstrapOverrides);let t=await this.json(e);return h({...p(),...t},this.bootstrapOverrides)}catch(e){return m(e instanceof Error?e.message:`bootstrap request failed`),h(p(),this.bootstrapOverrides)}}async history(){let e=await this.currentIdentityToken();if(!e)return{conversations:[]};let t=await fetch(`${this.baseUrl}/public-chat/history`,{method:`POST`,headers:this.headers(),body:JSON.stringify({identityToken:e,surface:this.chatSurface})}),n=await this.json(t);return{activeSessionId:n.activeSessionId,conversations:Array.isArray(n.conversations)?n.conversations:[]}}async stream(e,t,n){let r=await this.currentIdentityToken(),i=await fetch(`${this.baseUrl}/public-chat/stream`,{method:`POST`,headers:this.headers(),body:JSON.stringify({question:e,sessionId:t,voicePlaybackRequested:!!n.voicePlaybackRequested,analyticsContextToken:this.analyticsContextToken,identityToken:r,surface:this.chatSurface}),signal:n.signal});return!i.ok||!i.body?this.send(e,t,n):y(i.body,n)}async liveEvents(e,t){let n=`sessionId=${encodeURIComponent(e)}&after=${encodeURIComponent(t)}`,r=await fetch(`${this.baseUrl}/public-chat/live-events?${n}`,{headers:this.headers(!1)}),i=await this.json(r);return{mode:i.mode??`ai`,assignedAgentName:i.assignedAgentName,agentTyping:!!i.agentTyping,agentTypingName:i.agentTypingName,conversationEnded:!!i.conversationEnded,events:i.events??[]}}async typing(e,t){try{let n=await fetch(`${this.baseUrl}/public-chat/typing`,{method:`POST`,headers:this.headers(),body:JSON.stringify({sessionId:e,isTyping:t})});if(!n.ok)try{await n.text()}catch{}}catch{}}async send(e,t,n){let r=await this.currentIdentityToken(),i=await fetch(`${this.baseUrl}/public-chat`,{method:`POST`,headers:this.headers(),body:JSON.stringify({question:e,sessionId:t,voicePlaybackRequested:!!n.voicePlaybackRequested,analyticsContextToken:this.analyticsContextToken,identityToken:r,surface:this.chatSurface}),signal:n.signal}),a=await this.json(i);return n.onChunk(a.answer??``),{answer:a.answer??``,sources:a.sources??[],suggestedReplies:a.suggestedReplies??[],availableActions:a.availableActions??[],handoffOffered:a.handoffOffered??!1,requestedContactFields:x(a.requestedContactFields),conversationEnded:a.conversationEnded??!1,liveMode:a.liveMode,assignedAgentName:a.assignedAgentName,audioBase64:a.audioBase64,mimeType:a.mimeType,visualization:a.visualization}}async action(e,t){let n=await fetch(`${this.baseUrl}/public-chat/${
|
|
1
|
+
import{createContext as e}from"preact";import{useCallback as t,useContext as n,useEffect as r,useMemo as i,useRef as a,useState as o}from"preact/hooks";import{Fragment as s,jsx as c,jsxs as l}from"preact/jsx-runtime";var u=Object.defineProperty,d=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t&&u(n,Symbol.toStringTag,{value:`Module`}),n},f=class extends Error{constructor(e,t){super(t),this.status=e,this.name=`ApiError`}};const p=()=>({agentName:`Accurix`,greeting:`Hi! 👋 How can I help you today?`,widgetModule:`chat`,assistantMediaKind:`image`,soundEnabled:!0,voiceOutputEnabled:!1,talkbackMode:`text`,allowVoiceInput:!1,memoryEnabled:!0,memoryRetentionDays:30,memoryMessageCap:50,availableActions:[]}),m=e=>{typeof console>`u`||console.warn(`[centrinfo-widget] Could not load saved widget configuration from the API (${e}). Showing default widget chrome. Check data-token, data-api-base, CORS, and backend availability.`)},h=(e,t={})=>{let n=(e.disclaimerText?.trim())?.toLowerCase(),r=t.agentName?.trim()||e.agentName?.trim()||`Accurix`,i=t.agentAvatarUrl?.trim()||e.agentAvatarUrl?.trim();return{...e,agentName:r,agentAvatarUrl:i||void 0,disclaimerText:n===`sara is an ai assistant; answers may be imperfect.`||n?.includes(`sara is an ai assistant`)?`Accurix is an AI assistant; answers may be imperfect.`:e.disclaimerText}};var g=class{constructor(e,t,n,r,i={},a,o,s=`floating`){this.baseUrl=e,this.token=t,this.gifApiKey=n,this.analyticsContextToken=r,this.bootstrapOverrides=i,this.identityToken=a,this.identityTokenProvider=o,this.chatSurface=s}async currentIdentityToken(){return this.identityTokenProvider&&(this.identityToken=(await this.identityTokenProvider())?.trim()||void 0),this.identityToken}headers(e=!0){let t={Authorization:`Bearer ${this.token}`};return e&&(t[`Content-Type`]=`application/json`),t}async json(e){let t;try{t=await e.json()}catch{t=void 0}if(!e.ok){let n=v(t)??`request failed (${e.status})`;throw new f(e.status,n)}return t?.data??t}async bootstrap(){try{let e=await fetch(`${this.baseUrl}/public-chat/bootstrap`,{headers:this.headers(!1)});if(!e.ok)return m(`bootstrap request failed with ${e.status}`),h(p(),this.bootstrapOverrides);let t=await this.json(e);return h({...p(),...t},this.bootstrapOverrides)}catch(e){return m(e instanceof Error?e.message:`bootstrap request failed`),h(p(),this.bootstrapOverrides)}}async history(){let e=await this.currentIdentityToken();if(!e)return{conversations:[]};let t=await fetch(`${this.baseUrl}/public-chat/history`,{method:`POST`,headers:this.headers(),body:JSON.stringify({identityToken:e,surface:this.chatSurface})}),n=await this.json(t);return{activeSessionId:n.activeSessionId,conversations:Array.isArray(n.conversations)?n.conversations:[]}}async stream(e,t,n){let r=await this.currentIdentityToken(),i=await fetch(`${this.baseUrl}/public-chat/stream`,{method:`POST`,headers:this.headers(),body:JSON.stringify({question:e,sessionId:t,voicePlaybackRequested:!!n.voicePlaybackRequested,analyticsContextToken:this.analyticsContextToken,identityToken:r,surface:this.chatSurface}),signal:n.signal});return!i.ok||!i.body?this.send(e,t,n):y(i.body,n)}async liveEvents(e,t){let n=`sessionId=${encodeURIComponent(e)}&after=${encodeURIComponent(t)}`,r=await fetch(`${this.baseUrl}/public-chat/live-events?${n}`,{headers:this.headers(!1)}),i=await this.json(r);return{mode:i.mode??`ai`,assignedAgentName:i.assignedAgentName,agentTyping:!!i.agentTyping,agentTypingName:i.agentTypingName,conversationEnded:!!i.conversationEnded,events:i.events??[]}}async typing(e,t){try{let n=await fetch(`${this.baseUrl}/public-chat/typing`,{method:`POST`,headers:this.headers(),body:JSON.stringify({sessionId:e,isTyping:t})});if(!n.ok)try{await n.text()}catch{}}catch{}}async send(e,t,n){let r=await this.currentIdentityToken(),i=await fetch(`${this.baseUrl}/public-chat`,{method:`POST`,headers:this.headers(),body:JSON.stringify({question:e,sessionId:t,voicePlaybackRequested:!!n.voicePlaybackRequested,analyticsContextToken:this.analyticsContextToken,identityToken:r,surface:this.chatSurface}),signal:n.signal}),a=await this.json(i);return n.onChunk(a.answer??``),{answer:a.answer??``,sources:a.sources??[],suggestedReplies:a.suggestedReplies??[],availableActions:a.availableActions??[],actions:a.actions??[],selectedAction:a.selectedAction,handoffOffered:a.handoffOffered??!1,requestedContactFields:x(a.requestedContactFields),conversationEnded:a.conversationEnded??!1,liveMode:a.liveMode,assignedAgentName:a.assignedAgentName,audioBase64:a.audioBase64,mimeType:a.mimeType,visualization:a.visualization,artifacts:a.artifacts}}async action(e,t,n){let r=n?.trim()||(e===`contact-support`?`inquiry`:e),i=await fetch(`${this.baseUrl}/public-chat/${r}`,{method:`POST`,headers:this.headers(),body:JSON.stringify(t)}),a=await this.json(i);return{ok:!0,note:a?.note,booking:a?.booking}}async speak(e){let t=await fetch(`${this.baseUrl}/public-chat/speak`,{method:`POST`,headers:this.headers(),body:JSON.stringify({text:e})}),n=await this.json(t);return{providerReady:!!n.providerReady,message:n.message,audioBase64:n.audioBase64,mimeType:n.mimeType}}async identify(e,t){if(!(!e||!t))try{let n=await fetch(`${this.baseUrl}/public-chat/identify`,{method:`POST`,headers:this.headers(),body:JSON.stringify(_(e,t))});if(!n.ok)try{await n.text()}catch{}}catch{}}async transcribe(e,t,n,r){let i=await fetch(`${this.baseUrl}/public-chat/transcribe`,{method:`POST`,headers:this.headers(),body:JSON.stringify({audioBase64:e,mimeType:t,languageHint:n,durationSeconds:r})});return(await this.json(i)).text??``}async transcribeAudio(e,t,n,r){let i=new FormData;i.append(`audio`,e,`voice-recording`),i.append(`mimeType`,t||e.type||`audio/webm`),n&&i.append(`languageHint`,n),r!==void 0&&Number.isFinite(r)&&i.append(`durationSeconds`,String(r));let a=await fetch(`${this.baseUrl}/public-chat/transcribe`,{method:`POST`,headers:this.headers(!1),body:i});return(await this.json(a)).text??``}async endConversation(e){try{let t=await fetch(`${this.baseUrl}/public-chat/end`,{method:`POST`,headers:this.headers(),body:JSON.stringify({sessionId:e})});if(!t.ok)try{await t.text()}catch{}}catch{}}async sendFeedback(e){try{let t=await fetch(`${this.baseUrl}/public-chat/feedback`,{method:`POST`,headers:this.headers(),body:JSON.stringify(e)});if(!t.ok)try{await t.text()}catch{}}catch{}}async extract(e,t,n){let r=await fetch(`${this.baseUrl}/public-chat/extract`,{method:`POST`,headers:this.headers(),body:JSON.stringify({fileBase64:e,mimeType:t,filename:n})});return(await this.json(r)).text??``}async demoSlots(e,t){let n=`from=${encodeURIComponent(e)}&to=${encodeURIComponent(t)}`,r=await fetch(`${this.baseUrl}/public-chat/demo-slots?${n}`,{headers:this.headers(!1)});if(!r.ok){let e=Error(`Calendar availability is temporarily unavailable.`);throw e.status=r.status,e}let i=await this.json(r);return{status:i?.status,reason:i?.reason,timezone:i?.timezone,slotDurationMinutes:i?.slotDurationMinutes,available:i?.available,taken:i?.taken??[],busy:i?.busy??[]}}async searchGifs(e){if(!this.gifApiKey)return[];let t=`https://tenor.googleapis.com/v2/search?q=${encodeURIComponent(e.trim()||`trending`)}&key=${this.gifApiKey}&limit=24&media_filter=tinygif,gif&contentfilter=high`;try{let e=await fetch(t);return e.ok?((await e.json()).results??[]).map(e=>({id:e.id,url:e.media_formats?.gif?.url??e.media_formats?.tinygif?.url??``,preview:e.media_formats?.tinygif?.url??e.media_formats?.gif?.url??``,alt:e.content_description||`GIF`})).filter(e=>e.url):[]}catch{return[]}}};const _=(e,t)=>{let n={...t.customAttributes??{},...t.metadata??{}};t.createdAt!==void 0&&(n.createdAt=t.createdAt),t.avatarUrl&&(n.avatarUrl=t.avatarUrl),t.company&&(n.company=t.company);let r={sessionId:e},i=t.externalId??t.userId;return i&&(r.externalId=i),t.email&&(r.email=t.email),t.firstName&&(r.firstName=t.firstName),t.lastName&&(r.lastName=t.lastName),t.name&&(r.name=t.name),t.phone&&(r.phone=t.phone),Object.keys(n).length>0&&(r.metadata=n),r},v=e=>{let t=e?.message;if(Array.isArray(t))return t.join(`, `);if(typeof t==`string`)return t},y=async(e,t)=>{let n=e.getReader(),r=new TextDecoder,i={answer:``,sources:[],suggestedReplies:[],availableActions:[],handoffOffered:!1,requestedContactFields:[],conversationEnded:!1},a=``;for(;;){let{done:e,value:o}=await n.read();if(e)break;a+=r.decode(o,{stream:!0});let s;for(;(s=a.indexOf(`
|
|
2
2
|
|
|
3
|
-
`))!==-1;){let e=a.slice(0,s);a=a.slice(s+2);let n=b(e);if(n){if(n.event===`error`)throw new f(502,n.data?.message??`stream error`);if(n.event===`chunk`&&typeof n.data?.text==`string`)i.answer+=n.data.text,t.onChunk(n.data.text);else if(n.event===`final`&&n.data)i.sources=n.data.sources??[],i.suggestedReplies=n.data.suggestedReplies??[],i.availableActions=n.data.availableActions??[],i.handoffOffered=!!n.data.handoffOffered,i.requestedContactFields=x(n.data.requestedContactFields),i.conversationEnded=!!n.data.conversationEnded,i.liveMode=n.data.liveMode,i.assignedAgentName=n.data.assignedAgentName,i.visualization=n.data.visualization,i.audioBase64=n.data.audioBase64,i.mimeType=n.data.mimeType;else if(n.event===`done`)return i}}}return i},b=e=>{let t=`message`,n=[];for(let r of e.split(`
|
|
3
|
+
`))!==-1;){let e=a.slice(0,s);a=a.slice(s+2);let n=b(e);if(n){if(n.event===`error`)throw new f(502,n.data?.message??`stream error`);if(n.event===`chunk`&&typeof n.data?.text==`string`)i.answer+=n.data.text,t.onChunk(n.data.text);else if(n.event===`final`&&n.data)i.sources=n.data.sources??[],i.suggestedReplies=n.data.suggestedReplies??[],i.availableActions=n.data.availableActions??[],i.actions=n.data.actions??[],i.selectedAction=n.data.selectedAction,i.handoffOffered=!!n.data.handoffOffered,i.requestedContactFields=x(n.data.requestedContactFields),i.conversationEnded=!!n.data.conversationEnded,i.liveMode=n.data.liveMode,i.assignedAgentName=n.data.assignedAgentName,i.visualization=n.data.visualization,i.artifacts=n.data.artifacts,i.audioBase64=n.data.audioBase64,i.mimeType=n.data.mimeType;else if(n.event===`done`)return i}}}return i},b=e=>{let t=`message`,n=[];for(let r of e.split(`
|
|
4
4
|
`))r.startsWith(`event:`)?t=r.slice(6).trim():r.startsWith(`data:`)&&n.push(r.slice(5).trim());if(n.length===0)return{event:t};try{return{event:t,data:JSON.parse(n.join(`
|
|
5
|
-
`))}}catch{return{event:t}}},x=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],S=e=>new Promise(t=>setTimeout(t,e)),C={agentName:`Accurix`,agentAvatarUrl:``,widgetModule:`assistant`,assistantMediaUrl:`https://images.unsplash.com/photo-1494790108377-be9c29b29330`,assistantMediaKind:`image`,assistantPrivacyUrl:`https://accurix.tech/privacy`,soundEnabled:!0,voiceOutputEnabled:!1,talkbackMode:`avatar`,avatarProvider:`demo`,avatarId:`accurix-demo`,greeting:`Hi! I'm Accurix, the AI assistant for Accurix. Ask me anything about products, pricing, or documentation — or book a demo.`,allowVoiceInput:!1,memoryEnabled:!0,memoryRetentionDays:30,memoryMessageCap:50,availableActions:[`public_book_demo`,`public_capture_contact`,`public_submit_inquiry`],agentDescription:`I help with Accurix products, pricing, and documentation.`,welcomeSubtitle:`Ask me anything — most answers are instant.`,disclaimerText:`Accurix is an AI assistant; answers may be imperfect.`,starterQuestions:[`What can Accurix help with?`,`How do I get started?`,`What's your pricing?`],featuredLinks:[{label:`Accurix founders`,url:`https://accurix.tech/about`},{label:`Pricing`,url:`https://accurix.tech/pricing`}]},w=[{match:/demo chart|monthly orders|orders by status/i,result:{answer:`Orders moved in different directions by status in the latest month. The chart below shows one line for submitted, approved, and fulfilled orders.`,sources:[],suggestedReplies:[`Show a demo KPI`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`chart`,type:`line`,title:`Monthly orders by status`,columns:[`month`,`status`,`order_count`],rows:[{month:`2025-01-01`,status:`Submitted`,order_count:12},{month:`2025-01-01`,status:`Approved`,order_count:16},{month:`2025-01-01`,status:`Fulfilled`,order_count:14},{month:`2025-02-01`,status:`Submitted`,order_count:14},{month:`2025-02-01`,status:`Approved`,order_count:15},{month:`2025-02-01`,status:`Fulfilled`,order_count:15},{month:`2025-03-01`,status:`Submitted`,order_count:13},{month:`2025-03-01`,status:`Approved`,order_count:17},{month:`2025-03-01`,status:`Fulfilled`,order_count:16},{month:`2025-04-01`,status:`Submitted`,order_count:15},{month:`2025-04-01`,status:`Approved`,order_count:16},{month:`2025-04-01`,status:`Fulfilled`,order_count:17},{month:`2025-05-01`,status:`Submitted`,order_count:16},{month:`2025-05-01`,status:`Approved`,order_count:18},{month:`2025-05-01`,status:`Fulfilled`,order_count:17},{month:`2025-06-01`,status:`Submitted`,order_count:17},{month:`2025-06-01`,status:`Approved`,order_count:17},{month:`2025-06-01`,status:`Fulfilled`,order_count:18},{month:`2025-07-01`,status:`Submitted`,order_count:18},{month:`2025-07-01`,status:`Approved`,order_count:19},{month:`2025-07-01`,status:`Fulfilled`,order_count:18},{month:`2025-08-01`,status:`Submitted`,order_count:19},{month:`2025-08-01`,status:`Approved`,order_count:18},{month:`2025-08-01`,status:`Fulfilled`,order_count:19}],rowCount:24,timezone:`UTC`,columnMetadata:[{key:`month`,label:`Order month`,dataType:`date`,semanticRole:`date`},{key:`status`,label:`Status`,dataType:`text`,semanticRole:`dimension`},{key:`order_count`,label:`Distinct order count`,dataType:`number`,semanticRole:`measure`,aggregation:`count_distinct`}],chartRecommendation:{type:`line`,mode:`time_series`,categoryField:`month`,valueFields:[`order_count`],seriesField:`status`},expandable:!0,tableAvailable:!1,explanation:{headline:`The latest results moved in different directions by status.`,summary:`Submitted and fulfilled orders increased, while approved orders decreased.`,evidence:[`Submitted orders increased from 18 in July to 19 in August.`,`Approved orders decreased from 19 in July to 18 in August.`,`Fulfilled orders increased from 18 in July to 19 in August.`],businessMeaning:`Overall order activity is steady, but the small approval decline is worth watching if it continues.`,followUps:[`Which status changed the most?`,`How does this compare with the prior quarter?`],source:`governed_result`}}}},{match:/demo kpi|active accounts/i,result:{answer:`There are 5,632 active accounts in the current demo result.`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`kpi`,type:`kpi`,title:`Active accounts`,columns:[`active_accounts`],value:`active_accounts`,rows:[{active_accounts:5632}],rowCount:1,columnMetadata:[{key:`active_accounts`,label:`Active accounts`,dataType:`number`,semanticRole:`measure`,aggregation:`count_distinct`}],explanation:{headline:`Active accounts are 5,632.`,summary:`This is the latest value in the demo result.`,evidence:[`The displayed active-account count is 5,632.`],source:`governed_result`}}}},{match:/demo table|account health/i,result:{answer:`Nine accounts are included in this governed result. The table shows a compact preview and can be expanded to inspect every permitted row.`,sources:[],suggestedReplies:[`Show a demo chart`,`Test the hidden table response`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,title:`Account health`,columns:[`account_name`,`region`,`health_score`,`renewal_month`],rows:[{account_name:`Northstar Industries`,region:`West`,health_score:94,renewal_month:`August`},{account_name:`Apex Group`,region:`East`,health_score:91,renewal_month:`September`},{account_name:`Summit Retail`,region:`North`,health_score:88,renewal_month:`August`},{account_name:`Harbor Logistics`,region:`South`,health_score:86,renewal_month:`October`},{account_name:`Brightline Media`,region:`West`,health_score:84,renewal_month:`November`},{account_name:`Redwood Labs`,region:`East`,health_score:82,renewal_month:`September`},{account_name:`Atlas Foods`,region:`North`,health_score:79,renewal_month:`December`},{account_name:`Cedar Health`,region:`South`,health_score:77,renewal_month:`October`},{account_name:`Bluewave Energy`,region:`West`,health_score:74,renewal_month:`December`}],rowCount:9,columnMetadata:[{key:`account_name`,label:`Account`,dataType:`text`,semanticRole:`dimension`},{key:`region`,label:`Region`,dataType:`text`,semanticRole:`geography`},{key:`health_score`,label:`Health score`,dataType:`number`,semanticRole:`measure`},{key:`renewal_month`,label:`Renewal month`,dataType:`text`,semanticRole:`date`}],expandable:!0,tableAvailable:!0,downloadAvailable:!0,explanation:{headline:`Nine accounts are available for review.`,summary:`Health scores range from 74 to 94 across four regions.`,evidence:[`Northstar Industries has the highest health score at 94.`],source:`governed_result`}}}},{match:/hidden table|table response/i,result:{answer:`Three accounts need attention. The public widget explains the result without exposing its underlying rows.`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo KPI`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,columns:[`account_name`,`risk_score`],rows:[{account_name:`Private account A`,risk_score:91},{account_name:`Private account B`,risk_score:87},{account_name:`Private account C`,risk_score:82}],rowCount:3,tableAvailable:!1,explanation:{headline:`Three accounts need attention.`,summary:`The written result is available without displaying a public data table.`,evidence:[`Three accounts matched the approved attention rule.`],source:`governed_result`}}}},{match:/^\s*(hi+|hey+|hello|yo|sup|howdy|hola|thanks|thank you|thx|good (morning|afternoon|evening))\b/i,result:{answer:`Hello! 👋 How can I help you today?`,sources:[],suggestedReplies:[`How do I track a shipment?`,`How does customs work?`],handoffOffered:!1}},{match:/track|shipment|where|status/i,result:{answer:`Centrinfo can answer from your indexed knowledge base, public website, connected files, and approved organization tools. It keeps answers grounded in your configured sources and can hand a conversation to your team when the AI is not enough.`,sources:[{title:`Centrinfo public widget`,url:`https://accurix.tech/centrinfo`}],suggestedReplies:[`How does the widget work?`,`Can a human take over?`],handoffOffered:!1}},{match:/custom|clear|duty|tariff|import/i,result:{answer:`Accurix connects your organization knowledge, channels, integrations, and public widget in one place. You can configure which sources the AI can use, which tools visitors can trigger, and when your team should take over live chat.`,sources:[{title:`Accurix documentation`,url:`https://accurix.tech/docs`}],suggestedReplies:[`Which tools can I connect?`,`How do permissions work?`],handoffOffered:!1}},{match:/price|cost|pricing|plan|quote/i,result:{answer:`Accurix uses a usage-based pricing model. Organizations keep an active subscription and spend credits as the AI answers, searches, and uses tools. Credit top-ups can extend usage when the subscription grant runs low.`,sources:[{title:`Pricing`,url:`https://accurix.tech/pricing`}],suggestedReplies:[`How do credits work?`,`Can I top up credits?`],handoffOffered:!1}}],T={answer:`That's a great question — I don't have a confident answer from Accurix's published docs yet. Want me to pass it to the team so a human can follow up? You can also book a quick demo.`,sources:[],suggestedReplies:[`What can you help with?`],handoffOffered:!0},E=e=>w.find(t=>t.match.test(e))?.result??T;var D=class{async history(){return{conversations:[]}}async bootstrap(){return await S(180),C}async stream(e,t,n){await S(550);let r=E(e),i=r.answer.split(/(\s+)/);for(let e of i){if(n.signal?.aborted)break;n.onChunk(e),await S(18+Math.min(40,e.length*6))}return{...r,availableActions:C.availableActions}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async typing(){await S(20)}async action(e,t){return await S(450),{ok:!0,note:{"book-demo":`Demo requested — we'll email you a few times that work. 📅`,contact:`Got it — saved your details. ✅`,inquiry:`Thanks! We'll get back to you shortly. ✉️`,"request-callback":`We'll call you back soon. 📞`,"subscribe-newsletter":`You're subscribed. 🎉`}[e]}}async speak(){return await S(120),{providerReady:!1,message:`Demo voice provider is not connected.`}}async transcribe(e,t,n,r){return await S(700),`How do I track a shipment?`}async extract(e,t,n){return await S(600),`[Attached file${n?`: ${n}`:``}] Invoice #4821 — 3 pallets, Rotterdam → Lagos, ETA 12 days.`}async identify(e,t){await S(50)}async endConversation(e){await S(50)}async sendFeedback(){await S(50)}async demoSlots(e,t){return await S(150),{taken:[[11,0],[15,0]].map(([e,t])=>{let n=new Date;return n.setHours(e,t,0,0),n.toISOString()}),busy:[]}}async searchGifs(e){await S(280);let t=e.trim().toLowerCase(),n=t?j.filter(e=>e.alt.includes(t)||e.tags.some(e=>e.includes(t)||t.includes(e))):j;return(n.length>0?n:j).map(e=>({id:e.id,url:A(e.emoji,e.anim),preview:A(e.emoji,e.anim),alt:e.alt}))}};const O=`<animateTransform attributeName='transform' attributeType='XML' type='translate' values='0 0;0 -16;0 0' dur='0.7s' repeatCount='indefinite'/>`,k=`<animateTransform attributeName='transform' attributeType='XML' type='rotate' values='-14 64 110;14 64 110;-14 64 110' dur='0.9s' repeatCount='indefinite'/>`,A=(e,t)=>{let n=`<svg xmlns='http://www.w3.org/2000/svg' width='128' height='128'><rect width='128' height='128' rx='14' fill='#eef1f4'/><text x='64' y='88' font-size='64' text-anchor='middle'>${e}${t}</text></svg>`;return`data:image/svg+xml,${encodeURIComponent(n)}`},j=[{id:`g1`,emoji:`👍`,alt:`thumbs up`,tags:[`thumbs`,`yes`,`ok`,`great`,`good`],anim:O},{id:`g2`,emoji:`🎉`,alt:`celebrate`,tags:[`party`,`yay`,`congrats`,`celebrate`],anim:k},{id:`g3`,emoji:`👋`,alt:`wave hello`,tags:[`hi`,`hello`,`hey`,`wave`,`bye`],anim:k},{id:`g4`,emoji:`❤️`,alt:`heart`,tags:[`love`,`thanks`,`heart`],anim:O},{id:`g5`,emoji:`🤔`,alt:`thinking`,tags:[`hmm`,`think`,`thinking`],anim:k},{id:`g6`,emoji:`😂`,alt:`laughing`,tags:[`lol`,`funny`,`haha`,`laugh`],anim:O},{id:`g7`,emoji:`🔥`,alt:`fire`,tags:[`fire`,`hot`,`lit`,`awesome`],anim:O},{id:`g8`,emoji:`🚀`,alt:`rocket`,tags:[`rocket`,`launch`,`fast`,`go`],anim:k}],M=e=>new Promise(t=>setTimeout(t,e));var N=class{constructor(e,t){this.real=e,this.strings=t}bootstrap(){return this.real.bootstrap()}async history(){return{conversations:[]}}async stream(e,t,n){await M(300);for(let e of this.strings.previewReply.split(/(\s+)/)){if(n.signal?.aborted)break;n.onChunk(e),await M(16)}return{answer:this.strings.previewReply,sources:[],suggestedReplies:[],availableActions:[],handoffOffered:!1}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async typing(){}async action(){return await M(250),{ok:!0,note:this.strings.previewActionNote}}async speak(){return{providerReady:!1,message:`Preview voice provider is not connected.`}}async identify(){}async endConversation(){}async sendFeedback(){}async transcribe(e,t,n,r){return``}async extract(){return``}async searchGifs(){return[]}async demoSlots(){return{taken:[],busy:[]}}},P=function(e,t){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},P(e,t)};function F(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);P(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ee=12,I=ee+`px sans-serif`,te=20,ne=100,re=`007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N`;function ie(e){var t={};if(typeof JSON>`u`)return t;for(var n=0;n<e.length;n++){var r=String.fromCharCode(n+32);t[r]=(e.charCodeAt(n)-te)/ne}return t}var ae=ie(re),oe={createCanvas:function(){return typeof document<`u`&&document.createElement(`canvas`)},measureText:(function(){var e,t;return function(n,r){if(!e){var i=oe.createCanvas();e=i&&i.getContext(`2d`)}if(e)return t!==r&&(t=e.font=r||I),e.measureText(n);n=n||``,r=r||I;var a=/((?:\d+)?\.?\d*)px/.exec(r),o=a&&+a[1]||ee,s=0;if(r.indexOf(`mono`)>=0)s=o*n.length;else for(var c=0;c<n.length;c++){var l=ae[n[c]];s+=l==null?o:l*o}return{width:s}}})(),loadImage:function(e,t,n){var r=new Image;return r.onload=t,r.onerror=n,r.src=e,r}},se=Se([`Function`,`RegExp`,`Date`,`Error`,`CanvasGradient`,`CanvasPattern`,`Image`,`Canvas`],function(e,t){return e[`[object `+t+`]`]=!0,e},{}),ce=Se([`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`],function(e,t){return e[`[object `+t+`Array]`]=!0,e},{}),L=Object.prototype.toString,R=Array.prototype,le=R.forEach,ue=R.filter,de=R.slice,fe=R.map,pe=function(){}.constructor,me=pe?pe.prototype:null,he=`__proto__`,ge=2311;function _e(){return ge++}function ve(){var e=[...arguments];typeof console<`u`&&console.error.apply(console,e)}function z(e){if(typeof e!=`object`||!e)return e;var t=e,n=L.call(e);if(n===`[object Array]`){if(!Ue(e)){t=[];for(var r=0,i=e.length;r<i;r++)t[r]=z(e[r])}}else if(ce[n]){if(!Ue(e)){var a=e.constructor;if(a.from)t=a.from(e);else{t=new a(e.length);for(var r=0,i=e.length;r<i;r++)t[r]=e[r]}}}else if(!se[n]&&!Ue(e)&&!je(e))for(var o in t={},e)e.hasOwnProperty(o)&&o!==he&&(t[o]=z(e[o]));return t}function B(e,t,n){if(!X(t)||!X(e))return n?z(t):e;for(var r in t)if(t.hasOwnProperty(r)&&r!==he){var i=e[r],a=t[r];X(a)&&X(i)&&!q(a)&&!q(i)&&!je(a)&&!je(i)&&!ke(a)&&!ke(i)&&!Ue(a)&&!Ue(i)?B(i,a,n):(n||!(r in e))&&(e[r]=z(t[r]))}return e}function V(e,t){if(Object.assign)Object.assign(e,t);else for(var n in t)t.hasOwnProperty(n)&&n!==he&&(e[n]=t[n]);return e}function H(e,t,n){for(var r=we(t),i=0,a=r.length;i<a;i++){var o=r[i];(n?t[o]!=null:e[o]==null)&&(e[o]=t[o])}return e}oe.createCanvas;function U(e,t){if(e){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n}return-1}function ye(e,t){var n=e.prototype;function r(){}for(var i in r.prototype=t.prototype,e.prototype=new r,n)n.hasOwnProperty(i)&&(e.prototype[i]=n[i]);e.prototype.constructor=e,e.superClass=t}function be(e,t,n){if(e=`prototype`in e?e.prototype:e,t=`prototype`in t?t.prototype:t,Object.getOwnPropertyNames)for(var r=Object.getOwnPropertyNames(t),i=0;i<r.length;i++){var a=r[i];a!==`constructor`&&(n?t[a]!=null:e[a]==null)&&(e[a]=t[a])}else H(e,t,n)}function xe(e){return!e||typeof e==`string`?!1:typeof e.length==`number`}function W(e,t,n){if(e&&t)if(e.forEach&&e.forEach===le)e.forEach(t,n);else if(e.length===+e.length)for(var r=0,i=e.length;r<i;r++)t.call(n,e[r],r,e);else for(var a in e)e.hasOwnProperty(a)&&t.call(n,e[a],a,e)}function G(e,t,n){if(!e)return[];if(!t)return Le(e);if(e.map&&e.map===fe)return e.map(t,n);for(var r=[],i=0,a=e.length;i<a;i++)r.push(t.call(n,e[i],i,e));return r}function Se(e,t,n,r){if(e&&t){for(var i=0,a=e.length;i<a;i++)n=t.call(r,n,e[i],i,e);return n}}function Ce(e,t,n){if(!e)return[];if(!t)return Le(e);if(e.filter&&e.filter===ue)return e.filter(t,n);for(var r=[],i=0,a=e.length;i<a;i++)t.call(n,e[i],i,e)&&r.push(e[i]);return r}function we(e){if(!e)return[];if(Object.keys)return Object.keys(e);var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t}function Te(e,t){var n=[...arguments].slice(2);return function(){return e.apply(t,n.concat(de.call(arguments)))}}var K=me&&J(me.bind)?me.call.bind(me.bind):Te;function Ee(e){var t=[...arguments].slice(1);return function(){return e.apply(this,t.concat(de.call(arguments)))}}function q(e){return Array.isArray?Array.isArray(e):L.call(e)===`[object Array]`}function J(e){return typeof e==`function`}function Y(e){return typeof e==`string`}function De(e){return L.call(e)===`[object String]`}function Oe(e){return typeof e==`number`}function X(e){var t=typeof e;return t===`function`||!!e&&t===`object`}function ke(e){return!!se[L.call(e)]}function Ae(e){return!!ce[L.call(e)]}function je(e){return typeof e==`object`&&typeof e.nodeType==`number`&&typeof e.ownerDocument==`object`}function Me(e){return e.colorStops!=null}function Ne(e){return e.image!=null}function Pe(e){return e!==e}function Fe(){for(var e=[...arguments],t=0,n=e.length;t<n;t++)if(e[t]!=null)return e[t]}function Z(e,t){return e??t}function Ie(e,t,n){return e??t??n}function Le(e){var t=[...arguments].slice(1);return de.apply(e,t)}function Re(e){if(typeof e==`number`)return[e,e,e,e];var t=e.length;return t===2?[e[0],e[1],e[0],e[1]]:t===3?[e[0],e[1],e[2],e[1]]:e}function ze(e,t){if(!e)throw Error(t)}function Be(e){return e==null?null:typeof e.trim==`function`?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``)}var Ve=`__ec_primitive__`;function He(e){e[Ve]=!0}function Ue(e){return e[Ve]}var We=function(){function e(){this.data={}}return e.prototype.delete=function(e){var t=this.has(e);return t&&delete this.data[e],t},e.prototype.has=function(e){return this.data.hasOwnProperty(e)},e.prototype.get=function(e){return this.data[e]},e.prototype.set=function(e,t){return this.data[e]=t,this},e.prototype.keys=function(){return we(this.data)},e.prototype.forEach=function(e){var t=this.data;for(var n in t)t.hasOwnProperty(n)&&e(t[n],n)},e}(),Ge=typeof Map==`function`;function Ke(){return Ge?new Map:new We}var qe=function(){function e(t){var n=q(t);this.data=Ke();var r=this;t instanceof e?t.each(i):t&&W(t,i);function i(e,t){n?r.set(e,t):r.set(t,e)}}return e.prototype.hasKey=function(e){return this.data.has(e)},e.prototype.get=function(e){return this.data.get(e)},e.prototype.set=function(e,t){return this.data.set(e,t),t},e.prototype.each=function(e,t){this.data.forEach(function(n,r){e.call(t,n,r)})},e.prototype.keys=function(){var e=this.data.keys();return Ge?Array.from(e):e},e.prototype.removeKey=function(e){this.data.delete(e)},e}();function Q(e){return new qe(e)}function Je(e,t){for(var n=new e.constructor(e.length+t.length),r=0;r<e.length;r++)n[r]=e[r];for(var i=e.length,r=0;r<t.length;r++)n[r+i]=t[r];return n}function Ye(e,t){var n;if(Object.create)n=Object.create(e);else{var r=function(){};r.prototype=e,n=new r}return t&&V(n,t),n}function Xe(e){var t=e.style;t.webkitUserSelect=`none`,t.userSelect=`none`,t.webkitTapHighlightColor=`rgba(0,0,0,0)`,t[`-webkit-touch-callout`]=`none`}function Ze(e,t){return e.hasOwnProperty(t)}function Qe(){}var $e=180/Math.PI,et=function(){function e(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1}return e}(),tt=new(function(){function e(){this.browser=new et,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow=typeof window<`u`}return e}());typeof wx==`object`&&typeof wx.getSystemInfoSync==`function`?(tt.wxa=!0,tt.touchEventsSupported=!0):typeof document>`u`&&typeof self<`u`?tt.worker=!0:!tt.hasGlobalWindow||`Deno`in window?(tt.node=!0,tt.svgSupported=!0):nt(navigator.userAgent,tt);function nt(e,t){var n=t.browser,r=e.match(/Firefox\/([\d.]+)/),i=e.match(/MSIE\s([\d.]+)/)||e.match(/Trident\/.+?rv:(([\d.]+))/),a=e.match(/Edge?\/([\d.]+)/),o=/micromessenger/i.test(e);r&&(n.firefox=!0,n.version=r[1]),i&&(n.ie=!0,n.version=i[1]),a&&(n.edge=!0,n.version=a[1],n.newEdge=+a[1].split(`.`)[0]>18),o&&(n.weChat=!0),t.svgSupported=typeof SVGRect<`u`,t.touchEventsSupported=`ontouchstart`in window&&!n.ie&&!n.edge,t.pointerEventsSupported=`onpointerdown`in window&&(n.edge||n.ie&&+n.version>=11),t.domSupported=typeof document<`u`;var s=document.documentElement.style;t.transform3dSupported=(n.ie&&`transition`in s||n.edge||`WebKitCSSMatrix`in window&&`m11`in new WebKitCSSMatrix||`MozPerspective`in s)&&!(`OTransition`in s),t.transformSupported=t.transform3dSupported||n.ie&&+n.version>=9}var $=tt,rt=`.`,it=`___EC__COMPONENT__CONTAINER___`,at=`___EC__EXTENDED_CLASS___`;function ot(e){var t={main:``,sub:``};if(e){var n=e.split(rt);t.main=n[0]||``,t.sub=n[1]||``}return t}function st(e){ze(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(e),`componentType "`+e+`" illegal`)}function ct(e){return!!(e&&e[at])}function lt(e,t){e.$constructor=e,e.extend=function(e){var t=this,n;return ut(t)?n=function(e){F(t,e);function t(){return e.apply(this,arguments)||this}return t}(t):(n=function(){(e.$constructor||t).apply(this,arguments)},ye(n,this)),V(n.prototype,e),n[at]=!0,n.extend=this.extend,n.superCall=mt,n.superApply=ht,n.superClass=t,n}}function ut(e){return J(e)&&/^class\s/.test(Function.prototype.toString.call(e))}function dt(e,t){e.extend=t.extend}var ft=Math.round(Math.random()*10);function pt(e){var t=[`__\0is_clz`,ft++].join(`_`);e.prototype[t]=!0,e.isInstance=function(e){return!!(e&&e[t])}}function mt(e,t){var n=[...arguments].slice(2);return this.superClass.prototype[t].apply(e,n)}function ht(e,t,n){return this.superClass.prototype[t].apply(e,n)}function gt(e){var t={};e.registerClass=function(e){var r=e.type||e.prototype.type;if(r){st(r),e.prototype.type=r;var i=ot(r);if(!i.sub)t[i.main]=e;else if(i.sub!==it){var a=n(i);a[i.sub]=e}}return e},e.getClass=function(e,n,r){var i=t[e];if(i&&i[it]&&(i=n?i[n]:null),r&&!i)throw Error(n?`Component `+e+`.`+(n||``)+` is used but not imported.`:e+`.type should be specified.`);return i},e.getClassesByMainType=function(e){var n=ot(e),r=[],i=t[n.main];return i&&i[it]?W(i,function(e,t){t!==it&&r.push(e)}):r.push(i),r},e.hasClass=function(e){return!!t[ot(e).main]},e.getAllClassMainTypes=function(){var e=[];return W(t,function(t,n){e.push(n)}),e},e.hasSubTypes=function(e){var n=t[ot(e).main];return n&&n[it]};function n(e){var n=t[e.main];return(!n||!n[it])&&(n=t[e.main]={},n[it]=!0),n}}function _t(e,t){for(var n=0;n<e.length;n++)e[n][1]||(e[n][1]=e[n][0]);return t=t||!1,function(n,r,i){for(var a={},o=0;o<e.length;o++){var s=e[o][1];if(!(r&&U(r,s)>=0||i&&U(i,s)<0)){var c=n.getShallow(s,t);c!=null&&(a[e[o][0]]=c)}}return a}}var vt=_t([[`fill`,`color`],[`shadowBlur`],[`shadowOffsetX`],[`shadowOffsetY`],[`opacity`],[`shadowColor`]]),yt=function(){function e(){}return e.prototype.getAreaStyle=function(e,t){return vt(this,e,t)},e}(),bt=function(){function e(e){this.value=e}return e}(),xt=function(){function e(){this._len=0}return e.prototype.insert=function(e){var t=new bt(e);return this.insertEntry(t),t},e.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e):this.head=this.tail=e,this._len++},e.prototype.remove=function(e){var t=e.prev,n=e.next;t?t.next=n:this.head=n,n?n.prev=t:this.tail=t,e.next=e.prev=null,this._len--},e.prototype.len=function(){return this._len},e.prototype.clear=function(){this.head=this.tail=null,this._len=0},e}(),St=function(){function e(e){this._list=new xt,this._maxSize=10,this._map={},this._maxSize=e}return e.prototype.put=function(e,t){var n=this._list,r=this._map,i=null;if(r[e]==null){var a=n.len(),o=this._lastRemovedEntry;if(a>=this._maxSize&&a>0){var s=n.head;n.remove(s),delete r[s.key],i=s.value,this._lastRemovedEntry=s}o?o.value=t:o=new bt(t),o.key=e,n.insertEntry(o),r[e]=o}return i},e.prototype.get=function(e){var t=this._map[e],n=this._list;if(t!=null)return t!==n.tail&&(n.remove(t),n.insertEntry(t)),t.value},e.prototype.clear=function(){this._list.clear(),this._map={}},e.prototype.len=function(){return this._list.len()},e}(),Ct=new St(50);function wt(e){if(typeof e==`string`){var t=Ct.get(e);return t&&t.image}else return e}function Tt(e,t,n,r,i){if(e)if(typeof e==`string`){if(t&&t.__zrImageSrc===e||!n)return t;var a=Ct.get(e),o={hostEl:n,cb:r,cbPayload:i};return a?(t=a.image,!Dt(t)&&a.pending.push(o)):(t=oe.loadImage(e,Et,Et),t.__zrImageSrc=e,Ct.put(e,t.__cachedImgObj={image:t,pending:[o]})),t}else return e;else return t}function Et(){var e=this.__cachedImgObj;this.onload=this.onerror=this.__cachedImgObj=null;for(var t=0;t<e.pending.length;t++){var n=e.pending[t],r=n.cb;r&&r(this,n.cbPayload),n.hostEl.dirty()}e.pending.length=0}function Dt(e){return e&&e.width&&e.height}function Ot(){return[1,0,0,1,0,0]}function kt(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e}function At(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function jt(e,t,n){var r=t[0]*n[0]+t[2]*n[1],i=t[1]*n[0]+t[3]*n[1],a=t[0]*n[2]+t[2]*n[3],o=t[1]*n[2]+t[3]*n[3],s=t[0]*n[4]+t[2]*n[5]+t[4],c=t[1]*n[4]+t[3]*n[5]+t[5];return e[0]=r,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=c,e}function Mt(e,t,n){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4]+n[0],e[5]=t[5]+n[1],e}function Nt(e,t,n,r){r===void 0&&(r=[0,0]);var i=t[0],a=t[2],o=t[4],s=t[1],c=t[3],l=t[5],u=Math.sin(n),d=Math.cos(n);return e[0]=i*d+s*u,e[1]=-i*u+s*d,e[2]=a*d+c*u,e[3]=-a*u+d*c,e[4]=d*(o-r[0])+u*(l-r[1])+r[0],e[5]=d*(l-r[1])-u*(o-r[0])+r[1],e}function Pt(e,t,n){var r=n[0],i=n[1];return e[0]=t[0]*r,e[1]=t[1]*i,e[2]=t[2]*r,e[3]=t[3]*i,e[4]=t[4]*r,e[5]=t[5]*i,e}function Ft(e,t){var n=t[0],r=t[2],i=t[4],a=t[1],o=t[3],s=t[5],c=n*o-a*r;return c?(c=1/c,e[0]=o*c,e[1]=-a*c,e[2]=-r*c,e[3]=n*c,e[4]=(r*s-o*i)*c,e[5]=(a*i-n*s)*c,e):null}var It=function(){function e(e,t){this.x=e||0,this.y=t||0}return e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this},e.prototype.clone=function(){return new e(this.x,this.y)},e.prototype.set=function(e,t){return this.x=e,this.y=t,this},e.prototype.equal=function(e){return e.x===this.x&&e.y===this.y},e.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this},e.prototype.scale=function(e){this.x*=e,this.y*=e},e.prototype.scaleAndAdd=function(e,t){this.x+=e.x*t,this.y+=e.y*t},e.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this},e.prototype.dot=function(e){return this.x*e.x+this.y*e.y},e.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lenSquare=function(){return this.x*this.x+this.y*this.y},e.prototype.normalize=function(){var e=this.len();return this.x/=e,this.y/=e,this},e.prototype.distance=function(e){var t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)},e.prototype.distanceSquare=function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},e.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},e.prototype.transform=function(e){if(e){var t=this.x,n=this.y;return this.x=e[0]*t+e[2]*n+e[4],this.y=e[1]*t+e[3]*n+e[5],this}},e.prototype.toArray=function(e){return e[0]=this.x,e[1]=this.y,e},e.prototype.fromArray=function(e){this.x=e[0],this.y=e[1]},e.set=function(e,t,n){e.x=t,e.y=n},e.copy=function(e,t){e.x=t.x,e.y=t.y},e.len=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},e.lenSquare=function(e){return e.x*e.x+e.y*e.y},e.dot=function(e,t){return e.x*t.x+e.y*t.y},e.add=function(e,t,n){e.x=t.x+n.x,e.y=t.y+n.y},e.sub=function(e,t,n){e.x=t.x-n.x,e.y=t.y-n.y},e.scale=function(e,t,n){e.x=t.x*n,e.y=t.y*n},e.scaleAndAdd=function(e,t,n,r){e.x=t.x+n.x*r,e.y=t.y+n.y*r},e.lerp=function(e,t,n,r){var i=1-r;e.x=i*t.x+r*n.x,e.y=i*t.y+r*n.y},e}(),Lt=Math.min,Rt=Math.max,zt=new It,Bt=new It,Vt=new It,Ht=new It,Ut=new It,Wt=new It,Gt=function(){function e(e,t,n,r){n<0&&(e+=n,n=-n),r<0&&(t+=r,r=-r),this.x=e,this.y=t,this.width=n,this.height=r}return e.prototype.union=function(e){var t=Lt(e.x,this.x),n=Lt(e.y,this.y);isFinite(this.x)&&isFinite(this.width)?this.width=Rt(e.x+e.width,this.x+this.width)-t:this.width=e.width,isFinite(this.y)&&isFinite(this.height)?this.height=Rt(e.y+e.height,this.y+this.height)-n:this.height=e.height,this.x=t,this.y=n},e.prototype.applyTransform=function(t){e.applyTransform(this,this,t)},e.prototype.calculateTransform=function(e){var t=this,n=e.width/t.width,r=e.height/t.height,i=Ot();return Mt(i,i,[-t.x,-t.y]),Pt(i,i,[n,r]),Mt(i,i,[e.x,e.y]),i},e.prototype.intersect=function(t,n){if(!t)return!1;t instanceof e||(t=e.create(t));var r=this,i=r.x,a=r.x+r.width,o=r.y,s=r.y+r.height,c=t.x,l=t.x+t.width,u=t.y,d=t.y+t.height,f=!(a<c||l<i||s<u||d<o);if(n){var p=1/0,m=0,h=Math.abs(a-c),g=Math.abs(l-i),_=Math.abs(s-u),v=Math.abs(d-o),y=Math.min(h,g),b=Math.min(_,v);a<c||l<i?y>m&&(m=y,h<g?It.set(Wt,-h,0):It.set(Wt,g,0)):y<p&&(p=y,h<g?It.set(Ut,h,0):It.set(Ut,-g,0)),s<u||d<o?b>m&&(m=b,_<v?It.set(Wt,0,-_):It.set(Wt,0,v)):y<p&&(p=y,_<v?It.set(Ut,0,_):It.set(Ut,0,-v))}return n&&It.copy(n,f?Ut:Wt),f},e.prototype.contain=function(e,t){var n=this;return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e.prototype.copy=function(t){e.copy(this,t)},e.prototype.plain=function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},e.prototype.isFinite=function(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)},e.prototype.isZero=function(){return this.width===0||this.height===0},e.create=function(t){return new e(t.x,t.y,t.width,t.height)},e.copy=function(e,t){e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height},e.applyTransform=function(t,n,r){if(!r){t!==n&&e.copy(t,n);return}if(r[1]<1e-5&&r[1]>-1e-5&&r[2]<1e-5&&r[2]>-1e-5){var i=r[0],a=r[3],o=r[4],s=r[5];t.x=n.x*i+o,t.y=n.y*a+s,t.width=n.width*i,t.height=n.height*a,t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height);return}zt.x=Vt.x=n.x,zt.y=Ht.y=n.y,Bt.x=Ht.x=n.x+n.width,Bt.y=Vt.y=n.y+n.height,zt.transform(r),Ht.transform(r),Bt.transform(r),Vt.transform(r),t.x=Lt(zt.x,Bt.x,Vt.x,Ht.x),t.y=Lt(zt.y,Bt.y,Vt.y,Ht.y);var c=Rt(zt.x,Bt.x,Vt.x,Ht.x),l=Rt(zt.y,Bt.y,Vt.y,Ht.y);t.width=c-t.x,t.height=l-t.y},e}(),Kt={};function qt(e,t){t=t||I;var n=Kt[t];n||(n=Kt[t]=new St(500));var r=n.get(e);return r??(r=oe.measureText(e,t).width,n.put(e,r)),r}function Jt(e,t,n,r){var i=qt(e,t),a=Qt(t);return new Gt(Xt(0,i,n),Zt(0,a,r),i,a)}function Yt(e,t,n,r){var i=((e||``)+``).split(`
|
|
5
|
+
`))}}catch{return{event:t}}},x=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],S=e=>new Promise(t=>setTimeout(t,e)),C={agentName:`Accurix`,agentAvatarUrl:``,widgetModule:`assistant`,assistantMediaUrl:`https://images.unsplash.com/photo-1494790108377-be9c29b29330`,assistantMediaKind:`image`,assistantPrivacyUrl:`https://accurix.tech/privacy`,soundEnabled:!0,voiceOutputEnabled:!1,talkbackMode:`avatar`,avatarProvider:`demo`,avatarId:`accurix-demo`,greeting:`Hi! I'm Accurix, the AI assistant for Accurix. Ask me anything about products, pricing, or documentation — or book a demo.`,allowVoiceInput:!1,memoryEnabled:!0,memoryRetentionDays:30,memoryMessageCap:50,availableActions:[`public_book_demo`,`public_capture_contact`,`public_submit_inquiry`],agentDescription:`I help with Accurix products, pricing, and documentation.`,welcomeSubtitle:`Ask me anything — most answers are instant.`,disclaimerText:`Accurix is an AI assistant; answers may be imperfect.`,starterQuestions:[`What can Accurix help with?`,`How do I get started?`,`What's your pricing?`],featuredLinks:[{label:`Accurix founders`,url:`https://accurix.tech/about`},{label:`Pricing`,url:`https://accurix.tech/pricing`}]},w=[{match:/demo chart|monthly orders|orders by status/i,result:{answer:`Orders moved in different directions by status in the latest month. The chart below shows one line for submitted, approved, and fulfilled orders.`,sources:[],suggestedReplies:[`Show a demo KPI`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`chart`,type:`line`,title:`Monthly orders by status`,columns:[`month`,`status`,`order_count`],rows:[{month:`2025-01-01`,status:`Submitted`,order_count:12},{month:`2025-01-01`,status:`Approved`,order_count:16},{month:`2025-01-01`,status:`Fulfilled`,order_count:14},{month:`2025-02-01`,status:`Submitted`,order_count:14},{month:`2025-02-01`,status:`Approved`,order_count:15},{month:`2025-02-01`,status:`Fulfilled`,order_count:15},{month:`2025-03-01`,status:`Submitted`,order_count:13},{month:`2025-03-01`,status:`Approved`,order_count:17},{month:`2025-03-01`,status:`Fulfilled`,order_count:16},{month:`2025-04-01`,status:`Submitted`,order_count:15},{month:`2025-04-01`,status:`Approved`,order_count:16},{month:`2025-04-01`,status:`Fulfilled`,order_count:17},{month:`2025-05-01`,status:`Submitted`,order_count:16},{month:`2025-05-01`,status:`Approved`,order_count:18},{month:`2025-05-01`,status:`Fulfilled`,order_count:17},{month:`2025-06-01`,status:`Submitted`,order_count:17},{month:`2025-06-01`,status:`Approved`,order_count:17},{month:`2025-06-01`,status:`Fulfilled`,order_count:18},{month:`2025-07-01`,status:`Submitted`,order_count:18},{month:`2025-07-01`,status:`Approved`,order_count:19},{month:`2025-07-01`,status:`Fulfilled`,order_count:18},{month:`2025-08-01`,status:`Submitted`,order_count:19},{month:`2025-08-01`,status:`Approved`,order_count:18},{month:`2025-08-01`,status:`Fulfilled`,order_count:19}],rowCount:24,timezone:`UTC`,columnMetadata:[{key:`month`,label:`Order month`,dataType:`date`,semanticRole:`date`},{key:`status`,label:`Status`,dataType:`text`,semanticRole:`dimension`},{key:`order_count`,label:`Distinct order count`,dataType:`number`,semanticRole:`measure`,aggregation:`count_distinct`}],chartRecommendation:{type:`line`,mode:`time_series`,categoryField:`month`,valueFields:[`order_count`],seriesField:`status`},expandable:!0,tableAvailable:!1,explanation:{headline:`The latest results moved in different directions by status.`,summary:`Submitted and fulfilled orders increased, while approved orders decreased.`,evidence:[`Submitted orders increased from 18 in July to 19 in August.`,`Approved orders decreased from 19 in July to 18 in August.`,`Fulfilled orders increased from 18 in July to 19 in August.`],businessMeaning:`Overall order activity is steady, but the small approval decline is worth watching if it continues.`,followUps:[`Which status changed the most?`,`How does this compare with the prior quarter?`],source:`governed_result`}}}},{match:/demo kpi|active accounts/i,result:{answer:`There are 5,632 active accounts in the current demo result.`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`kpi`,type:`kpi`,title:`Active accounts`,columns:[`active_accounts`],value:`active_accounts`,rows:[{active_accounts:5632}],rowCount:1,columnMetadata:[{key:`active_accounts`,label:`Active accounts`,dataType:`number`,semanticRole:`measure`,aggregation:`count_distinct`}],explanation:{headline:`Active accounts are 5,632.`,summary:`This is the latest value in the demo result.`,evidence:[`The displayed active-account count is 5,632.`],source:`governed_result`}}}},{match:/demo table|account health/i,result:{answer:`Nine accounts are included in this governed result. The table shows a compact preview and can be expanded to inspect every permitted row.`,sources:[],suggestedReplies:[`Show a demo chart`,`Test the hidden table response`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,title:`Account health`,columns:[`account_name`,`region`,`health_score`,`renewal_month`],rows:[{account_name:`Northstar Industries`,region:`West`,health_score:94,renewal_month:`August`},{account_name:`Apex Group`,region:`East`,health_score:91,renewal_month:`September`},{account_name:`Summit Retail`,region:`North`,health_score:88,renewal_month:`August`},{account_name:`Harbor Logistics`,region:`South`,health_score:86,renewal_month:`October`},{account_name:`Brightline Media`,region:`West`,health_score:84,renewal_month:`November`},{account_name:`Redwood Labs`,region:`East`,health_score:82,renewal_month:`September`},{account_name:`Atlas Foods`,region:`North`,health_score:79,renewal_month:`December`},{account_name:`Cedar Health`,region:`South`,health_score:77,renewal_month:`October`},{account_name:`Bluewave Energy`,region:`West`,health_score:74,renewal_month:`December`}],rowCount:9,columnMetadata:[{key:`account_name`,label:`Account`,dataType:`text`,semanticRole:`dimension`},{key:`region`,label:`Region`,dataType:`text`,semanticRole:`geography`},{key:`health_score`,label:`Health score`,dataType:`number`,semanticRole:`measure`},{key:`renewal_month`,label:`Renewal month`,dataType:`text`,semanticRole:`date`}],expandable:!0,tableAvailable:!0,downloadAvailable:!0,explanation:{headline:`Nine accounts are available for review.`,summary:`Health scores range from 74 to 94 across four regions.`,evidence:[`Northstar Industries has the highest health score at 94.`],source:`governed_result`}}}},{match:/hidden table|table response/i,result:{answer:`Three accounts need attention. The public widget explains the result without exposing its underlying rows.`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo KPI`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,columns:[`account_name`,`risk_score`],rows:[{account_name:`Private account A`,risk_score:91},{account_name:`Private account B`,risk_score:87},{account_name:`Private account C`,risk_score:82}],rowCount:3,tableAvailable:!1,explanation:{headline:`Three accounts need attention.`,summary:`The written result is available without displaying a public data table.`,evidence:[`Three accounts matched the approved attention rule.`],source:`governed_result`}}}},{match:/^\s*(hi+|hey+|hello|yo|sup|howdy|hola|thanks|thank you|thx|good (morning|afternoon|evening))\b/i,result:{answer:`Hello! 👋 How can I help you today?`,sources:[],suggestedReplies:[`How do I track a shipment?`,`How does customs work?`],handoffOffered:!1}},{match:/track|shipment|where|status/i,result:{answer:`Centrinfo can answer from your indexed knowledge base, public website, connected files, and approved organization tools. It keeps answers grounded in your configured sources and can hand a conversation to your team when the AI is not enough.`,sources:[{title:`Centrinfo public widget`,url:`https://accurix.tech/centrinfo`}],suggestedReplies:[`How does the widget work?`,`Can a human take over?`],handoffOffered:!1}},{match:/custom|clear|duty|tariff|import/i,result:{answer:`Accurix connects your organization knowledge, channels, integrations, and public widget in one place. You can configure which sources the AI can use, which tools visitors can trigger, and when your team should take over live chat.`,sources:[{title:`Accurix documentation`,url:`https://accurix.tech/docs`}],suggestedReplies:[`Which tools can I connect?`,`How do permissions work?`],handoffOffered:!1}},{match:/price|cost|pricing|plan|quote/i,result:{answer:`Accurix uses a usage-based pricing model. Organizations keep an active subscription and spend credits as the AI answers, searches, and uses tools. Credit top-ups can extend usage when the subscription grant runs low.`,sources:[{title:`Pricing`,url:`https://accurix.tech/pricing`}],suggestedReplies:[`How do credits work?`,`Can I top up credits?`],handoffOffered:!1}}],T={answer:`That's a great question — I don't have a confident answer from Accurix's published docs yet. Want me to pass it to the team so a human can follow up? You can also book a quick demo.`,sources:[],suggestedReplies:[`What can you help with?`],handoffOffered:!0},E=e=>w.find(t=>t.match.test(e))?.result??T;var D=class{async history(){return{conversations:[]}}async bootstrap(){return await S(180),C}async stream(e,t,n){await S(550);let r=E(e),i=r.answer.split(/(\s+)/);for(let e of i){if(n.signal?.aborted)break;n.onChunk(e),await S(18+Math.min(40,e.length*6))}return{...r,availableActions:C.availableActions}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async typing(){await S(20)}async action(e,t){return await S(450),{ok:!0,note:{"book-demo":`Demo requested — we'll email you a few times that work. 📅`,contact:`Got it — saved your details. ✅`,"contact-support":`Support has been notified and can join this conversation. ✅`,inquiry:`Thanks! We'll get back to you shortly. ✉️`,"request-callback":`We'll call you back soon. 📞`,"subscribe-newsletter":`You're subscribed. 🎉`}[e]}}async speak(){return await S(120),{providerReady:!1,message:`Demo voice provider is not connected.`}}async transcribe(e,t,n,r){return await S(700),`How do I track a shipment?`}async extract(e,t,n){return await S(600),`[Attached file${n?`: ${n}`:``}] Invoice #4821 — 3 pallets, Rotterdam → Lagos, ETA 12 days.`}async identify(e,t){await S(50)}async endConversation(e){await S(50)}async sendFeedback(){await S(50)}async demoSlots(e,t){return await S(150),{taken:[[11,0],[15,0]].map(([e,t])=>{let n=new Date;return n.setHours(e,t,0,0),n.toISOString()}),busy:[]}}async searchGifs(e){await S(280);let t=e.trim().toLowerCase(),n=t?j.filter(e=>e.alt.includes(t)||e.tags.some(e=>e.includes(t)||t.includes(e))):j;return(n.length>0?n:j).map(e=>({id:e.id,url:A(e.emoji,e.anim),preview:A(e.emoji,e.anim),alt:e.alt}))}};const O=`<animateTransform attributeName='transform' attributeType='XML' type='translate' values='0 0;0 -16;0 0' dur='0.7s' repeatCount='indefinite'/>`,k=`<animateTransform attributeName='transform' attributeType='XML' type='rotate' values='-14 64 110;14 64 110;-14 64 110' dur='0.9s' repeatCount='indefinite'/>`,A=(e,t)=>{let n=`<svg xmlns='http://www.w3.org/2000/svg' width='128' height='128'><rect width='128' height='128' rx='14' fill='#eef1f4'/><text x='64' y='88' font-size='64' text-anchor='middle'>${e}${t}</text></svg>`;return`data:image/svg+xml,${encodeURIComponent(n)}`},j=[{id:`g1`,emoji:`👍`,alt:`thumbs up`,tags:[`thumbs`,`yes`,`ok`,`great`,`good`],anim:O},{id:`g2`,emoji:`🎉`,alt:`celebrate`,tags:[`party`,`yay`,`congrats`,`celebrate`],anim:k},{id:`g3`,emoji:`👋`,alt:`wave hello`,tags:[`hi`,`hello`,`hey`,`wave`,`bye`],anim:k},{id:`g4`,emoji:`❤️`,alt:`heart`,tags:[`love`,`thanks`,`heart`],anim:O},{id:`g5`,emoji:`🤔`,alt:`thinking`,tags:[`hmm`,`think`,`thinking`],anim:k},{id:`g6`,emoji:`😂`,alt:`laughing`,tags:[`lol`,`funny`,`haha`,`laugh`],anim:O},{id:`g7`,emoji:`🔥`,alt:`fire`,tags:[`fire`,`hot`,`lit`,`awesome`],anim:O},{id:`g8`,emoji:`🚀`,alt:`rocket`,tags:[`rocket`,`launch`,`fast`,`go`],anim:k}],M=e=>new Promise(t=>setTimeout(t,e));var N=class{constructor(e,t){this.real=e,this.strings=t}bootstrap(){return this.real.bootstrap()}async history(){return{conversations:[]}}async stream(e,t,n){await M(300);for(let e of this.strings.previewReply.split(/(\s+)/)){if(n.signal?.aborted)break;n.onChunk(e),await M(16)}return{answer:this.strings.previewReply,sources:[],suggestedReplies:[],availableActions:[],handoffOffered:!1}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async typing(){}async action(){return await M(250),{ok:!0,note:this.strings.previewActionNote}}async speak(){return{providerReady:!1,message:`Preview voice provider is not connected.`}}async identify(){}async endConversation(){}async sendFeedback(){}async transcribe(e,t,n,r){return``}async extract(){return``}async searchGifs(){return[]}async demoSlots(){return{taken:[],busy:[]}}},P=function(e,t){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},P(e,t)};function F(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);P(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ee=12,I=ee+`px sans-serif`,te=20,ne=100,re=`007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N`;function ie(e){var t={};if(typeof JSON>`u`)return t;for(var n=0;n<e.length;n++){var r=String.fromCharCode(n+32);t[r]=(e.charCodeAt(n)-te)/ne}return t}var ae=ie(re),oe={createCanvas:function(){return typeof document<`u`&&document.createElement(`canvas`)},measureText:(function(){var e,t;return function(n,r){if(!e){var i=oe.createCanvas();e=i&&i.getContext(`2d`)}if(e)return t!==r&&(t=e.font=r||I),e.measureText(n);n=n||``,r=r||I;var a=/((?:\d+)?\.?\d*)px/.exec(r),o=a&&+a[1]||ee,s=0;if(r.indexOf(`mono`)>=0)s=o*n.length;else for(var c=0;c<n.length;c++){var l=ae[n[c]];s+=l==null?o:l*o}return{width:s}}})(),loadImage:function(e,t,n){var r=new Image;return r.onload=t,r.onerror=n,r.src=e,r}},se=Se([`Function`,`RegExp`,`Date`,`Error`,`CanvasGradient`,`CanvasPattern`,`Image`,`Canvas`],function(e,t){return e[`[object `+t+`]`]=!0,e},{}),ce=Se([`Int8`,`Uint8`,`Uint8Clamped`,`Int16`,`Uint16`,`Int32`,`Uint32`,`Float32`,`Float64`],function(e,t){return e[`[object `+t+`Array]`]=!0,e},{}),L=Object.prototype.toString,R=Array.prototype,le=R.forEach,ue=R.filter,de=R.slice,fe=R.map,pe=function(){}.constructor,me=pe?pe.prototype:null,he=`__proto__`,ge=2311;function _e(){return ge++}function ve(){var e=[...arguments];typeof console<`u`&&console.error.apply(console,e)}function z(e){if(typeof e!=`object`||!e)return e;var t=e,n=L.call(e);if(n===`[object Array]`){if(!Ue(e)){t=[];for(var r=0,i=e.length;r<i;r++)t[r]=z(e[r])}}else if(ce[n]){if(!Ue(e)){var a=e.constructor;if(a.from)t=a.from(e);else{t=new a(e.length);for(var r=0,i=e.length;r<i;r++)t[r]=e[r]}}}else if(!se[n]&&!Ue(e)&&!je(e))for(var o in t={},e)e.hasOwnProperty(o)&&o!==he&&(t[o]=z(e[o]));return t}function B(e,t,n){if(!X(t)||!X(e))return n?z(t):e;for(var r in t)if(t.hasOwnProperty(r)&&r!==he){var i=e[r],a=t[r];X(a)&&X(i)&&!q(a)&&!q(i)&&!je(a)&&!je(i)&&!ke(a)&&!ke(i)&&!Ue(a)&&!Ue(i)?B(i,a,n):(n||!(r in e))&&(e[r]=z(t[r]))}return e}function V(e,t){if(Object.assign)Object.assign(e,t);else for(var n in t)t.hasOwnProperty(n)&&n!==he&&(e[n]=t[n]);return e}function H(e,t,n){for(var r=we(t),i=0,a=r.length;i<a;i++){var o=r[i];(n?t[o]!=null:e[o]==null)&&(e[o]=t[o])}return e}oe.createCanvas;function U(e,t){if(e){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n}return-1}function ye(e,t){var n=e.prototype;function r(){}for(var i in r.prototype=t.prototype,e.prototype=new r,n)n.hasOwnProperty(i)&&(e.prototype[i]=n[i]);e.prototype.constructor=e,e.superClass=t}function be(e,t,n){if(e=`prototype`in e?e.prototype:e,t=`prototype`in t?t.prototype:t,Object.getOwnPropertyNames)for(var r=Object.getOwnPropertyNames(t),i=0;i<r.length;i++){var a=r[i];a!==`constructor`&&(n?t[a]!=null:e[a]==null)&&(e[a]=t[a])}else H(e,t,n)}function xe(e){return!e||typeof e==`string`?!1:typeof e.length==`number`}function W(e,t,n){if(e&&t)if(e.forEach&&e.forEach===le)e.forEach(t,n);else if(e.length===+e.length)for(var r=0,i=e.length;r<i;r++)t.call(n,e[r],r,e);else for(var a in e)e.hasOwnProperty(a)&&t.call(n,e[a],a,e)}function G(e,t,n){if(!e)return[];if(!t)return Le(e);if(e.map&&e.map===fe)return e.map(t,n);for(var r=[],i=0,a=e.length;i<a;i++)r.push(t.call(n,e[i],i,e));return r}function Se(e,t,n,r){if(e&&t){for(var i=0,a=e.length;i<a;i++)n=t.call(r,n,e[i],i,e);return n}}function Ce(e,t,n){if(!e)return[];if(!t)return Le(e);if(e.filter&&e.filter===ue)return e.filter(t,n);for(var r=[],i=0,a=e.length;i<a;i++)t.call(n,e[i],i,e)&&r.push(e[i]);return r}function we(e){if(!e)return[];if(Object.keys)return Object.keys(e);var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t}function Te(e,t){var n=[...arguments].slice(2);return function(){return e.apply(t,n.concat(de.call(arguments)))}}var K=me&&J(me.bind)?me.call.bind(me.bind):Te;function Ee(e){var t=[...arguments].slice(1);return function(){return e.apply(this,t.concat(de.call(arguments)))}}function q(e){return Array.isArray?Array.isArray(e):L.call(e)===`[object Array]`}function J(e){return typeof e==`function`}function Y(e){return typeof e==`string`}function De(e){return L.call(e)===`[object String]`}function Oe(e){return typeof e==`number`}function X(e){var t=typeof e;return t===`function`||!!e&&t===`object`}function ke(e){return!!se[L.call(e)]}function Ae(e){return!!ce[L.call(e)]}function je(e){return typeof e==`object`&&typeof e.nodeType==`number`&&typeof e.ownerDocument==`object`}function Me(e){return e.colorStops!=null}function Ne(e){return e.image!=null}function Pe(e){return e!==e}function Fe(){for(var e=[...arguments],t=0,n=e.length;t<n;t++)if(e[t]!=null)return e[t]}function Z(e,t){return e??t}function Ie(e,t,n){return e??t??n}function Le(e){var t=[...arguments].slice(1);return de.apply(e,t)}function Re(e){if(typeof e==`number`)return[e,e,e,e];var t=e.length;return t===2?[e[0],e[1],e[0],e[1]]:t===3?[e[0],e[1],e[2],e[1]]:e}function ze(e,t){if(!e)throw Error(t)}function Be(e){return e==null?null:typeof e.trim==`function`?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``)}var Ve=`__ec_primitive__`;function He(e){e[Ve]=!0}function Ue(e){return e[Ve]}var We=function(){function e(){this.data={}}return e.prototype.delete=function(e){var t=this.has(e);return t&&delete this.data[e],t},e.prototype.has=function(e){return this.data.hasOwnProperty(e)},e.prototype.get=function(e){return this.data[e]},e.prototype.set=function(e,t){return this.data[e]=t,this},e.prototype.keys=function(){return we(this.data)},e.prototype.forEach=function(e){var t=this.data;for(var n in t)t.hasOwnProperty(n)&&e(t[n],n)},e}(),Ge=typeof Map==`function`;function Ke(){return Ge?new Map:new We}var qe=function(){function e(t){var n=q(t);this.data=Ke();var r=this;t instanceof e?t.each(i):t&&W(t,i);function i(e,t){n?r.set(e,t):r.set(t,e)}}return e.prototype.hasKey=function(e){return this.data.has(e)},e.prototype.get=function(e){return this.data.get(e)},e.prototype.set=function(e,t){return this.data.set(e,t),t},e.prototype.each=function(e,t){this.data.forEach(function(n,r){e.call(t,n,r)})},e.prototype.keys=function(){var e=this.data.keys();return Ge?Array.from(e):e},e.prototype.removeKey=function(e){this.data.delete(e)},e}();function Q(e){return new qe(e)}function Je(e,t){for(var n=new e.constructor(e.length+t.length),r=0;r<e.length;r++)n[r]=e[r];for(var i=e.length,r=0;r<t.length;r++)n[r+i]=t[r];return n}function Ye(e,t){var n;if(Object.create)n=Object.create(e);else{var r=function(){};r.prototype=e,n=new r}return t&&V(n,t),n}function Xe(e){var t=e.style;t.webkitUserSelect=`none`,t.userSelect=`none`,t.webkitTapHighlightColor=`rgba(0,0,0,0)`,t[`-webkit-touch-callout`]=`none`}function Ze(e,t){return e.hasOwnProperty(t)}function Qe(){}var $e=180/Math.PI,et=function(){function e(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1}return e}(),tt=new(function(){function e(){this.browser=new et,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow=typeof window<`u`}return e}());typeof wx==`object`&&typeof wx.getSystemInfoSync==`function`?(tt.wxa=!0,tt.touchEventsSupported=!0):typeof document>`u`&&typeof self<`u`?tt.worker=!0:!tt.hasGlobalWindow||`Deno`in window?(tt.node=!0,tt.svgSupported=!0):nt(navigator.userAgent,tt);function nt(e,t){var n=t.browser,r=e.match(/Firefox\/([\d.]+)/),i=e.match(/MSIE\s([\d.]+)/)||e.match(/Trident\/.+?rv:(([\d.]+))/),a=e.match(/Edge?\/([\d.]+)/),o=/micromessenger/i.test(e);r&&(n.firefox=!0,n.version=r[1]),i&&(n.ie=!0,n.version=i[1]),a&&(n.edge=!0,n.version=a[1],n.newEdge=+a[1].split(`.`)[0]>18),o&&(n.weChat=!0),t.svgSupported=typeof SVGRect<`u`,t.touchEventsSupported=`ontouchstart`in window&&!n.ie&&!n.edge,t.pointerEventsSupported=`onpointerdown`in window&&(n.edge||n.ie&&+n.version>=11),t.domSupported=typeof document<`u`;var s=document.documentElement.style;t.transform3dSupported=(n.ie&&`transition`in s||n.edge||`WebKitCSSMatrix`in window&&`m11`in new WebKitCSSMatrix||`MozPerspective`in s)&&!(`OTransition`in s),t.transformSupported=t.transform3dSupported||n.ie&&+n.version>=9}var $=tt,rt=`.`,it=`___EC__COMPONENT__CONTAINER___`,at=`___EC__EXTENDED_CLASS___`;function ot(e){var t={main:``,sub:``};if(e){var n=e.split(rt);t.main=n[0]||``,t.sub=n[1]||``}return t}function st(e){ze(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(e),`componentType "`+e+`" illegal`)}function ct(e){return!!(e&&e[at])}function lt(e,t){e.$constructor=e,e.extend=function(e){var t=this,n;return ut(t)?n=function(e){F(t,e);function t(){return e.apply(this,arguments)||this}return t}(t):(n=function(){(e.$constructor||t).apply(this,arguments)},ye(n,this)),V(n.prototype,e),n[at]=!0,n.extend=this.extend,n.superCall=mt,n.superApply=ht,n.superClass=t,n}}function ut(e){return J(e)&&/^class\s/.test(Function.prototype.toString.call(e))}function dt(e,t){e.extend=t.extend}var ft=Math.round(Math.random()*10);function pt(e){var t=[`__\0is_clz`,ft++].join(`_`);e.prototype[t]=!0,e.isInstance=function(e){return!!(e&&e[t])}}function mt(e,t){var n=[...arguments].slice(2);return this.superClass.prototype[t].apply(e,n)}function ht(e,t,n){return this.superClass.prototype[t].apply(e,n)}function gt(e){var t={};e.registerClass=function(e){var r=e.type||e.prototype.type;if(r){st(r),e.prototype.type=r;var i=ot(r);if(!i.sub)t[i.main]=e;else if(i.sub!==it){var a=n(i);a[i.sub]=e}}return e},e.getClass=function(e,n,r){var i=t[e];if(i&&i[it]&&(i=n?i[n]:null),r&&!i)throw Error(n?`Component `+e+`.`+(n||``)+` is used but not imported.`:e+`.type should be specified.`);return i},e.getClassesByMainType=function(e){var n=ot(e),r=[],i=t[n.main];return i&&i[it]?W(i,function(e,t){t!==it&&r.push(e)}):r.push(i),r},e.hasClass=function(e){return!!t[ot(e).main]},e.getAllClassMainTypes=function(){var e=[];return W(t,function(t,n){e.push(n)}),e},e.hasSubTypes=function(e){var n=t[ot(e).main];return n&&n[it]};function n(e){var n=t[e.main];return(!n||!n[it])&&(n=t[e.main]={},n[it]=!0),n}}function _t(e,t){for(var n=0;n<e.length;n++)e[n][1]||(e[n][1]=e[n][0]);return t=t||!1,function(n,r,i){for(var a={},o=0;o<e.length;o++){var s=e[o][1];if(!(r&&U(r,s)>=0||i&&U(i,s)<0)){var c=n.getShallow(s,t);c!=null&&(a[e[o][0]]=c)}}return a}}var vt=_t([[`fill`,`color`],[`shadowBlur`],[`shadowOffsetX`],[`shadowOffsetY`],[`opacity`],[`shadowColor`]]),yt=function(){function e(){}return e.prototype.getAreaStyle=function(e,t){return vt(this,e,t)},e}(),bt=function(){function e(e){this.value=e}return e}(),xt=function(){function e(){this._len=0}return e.prototype.insert=function(e){var t=new bt(e);return this.insertEntry(t),t},e.prototype.insertEntry=function(e){this.head?(this.tail.next=e,e.prev=this.tail,e.next=null,this.tail=e):this.head=this.tail=e,this._len++},e.prototype.remove=function(e){var t=e.prev,n=e.next;t?t.next=n:this.head=n,n?n.prev=t:this.tail=t,e.next=e.prev=null,this._len--},e.prototype.len=function(){return this._len},e.prototype.clear=function(){this.head=this.tail=null,this._len=0},e}(),St=function(){function e(e){this._list=new xt,this._maxSize=10,this._map={},this._maxSize=e}return e.prototype.put=function(e,t){var n=this._list,r=this._map,i=null;if(r[e]==null){var a=n.len(),o=this._lastRemovedEntry;if(a>=this._maxSize&&a>0){var s=n.head;n.remove(s),delete r[s.key],i=s.value,this._lastRemovedEntry=s}o?o.value=t:o=new bt(t),o.key=e,n.insertEntry(o),r[e]=o}return i},e.prototype.get=function(e){var t=this._map[e],n=this._list;if(t!=null)return t!==n.tail&&(n.remove(t),n.insertEntry(t)),t.value},e.prototype.clear=function(){this._list.clear(),this._map={}},e.prototype.len=function(){return this._list.len()},e}(),Ct=new St(50);function wt(e){if(typeof e==`string`){var t=Ct.get(e);return t&&t.image}else return e}function Tt(e,t,n,r,i){if(e)if(typeof e==`string`){if(t&&t.__zrImageSrc===e||!n)return t;var a=Ct.get(e),o={hostEl:n,cb:r,cbPayload:i};return a?(t=a.image,!Dt(t)&&a.pending.push(o)):(t=oe.loadImage(e,Et,Et),t.__zrImageSrc=e,Ct.put(e,t.__cachedImgObj={image:t,pending:[o]})),t}else return e;else return t}function Et(){var e=this.__cachedImgObj;this.onload=this.onerror=this.__cachedImgObj=null;for(var t=0;t<e.pending.length;t++){var n=e.pending[t],r=n.cb;r&&r(this,n.cbPayload),n.hostEl.dirty()}e.pending.length=0}function Dt(e){return e&&e.width&&e.height}function Ot(){return[1,0,0,1,0,0]}function kt(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e}function At(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function jt(e,t,n){var r=t[0]*n[0]+t[2]*n[1],i=t[1]*n[0]+t[3]*n[1],a=t[0]*n[2]+t[2]*n[3],o=t[1]*n[2]+t[3]*n[3],s=t[0]*n[4]+t[2]*n[5]+t[4],c=t[1]*n[4]+t[3]*n[5]+t[5];return e[0]=r,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=c,e}function Mt(e,t,n){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4]+n[0],e[5]=t[5]+n[1],e}function Nt(e,t,n,r){r===void 0&&(r=[0,0]);var i=t[0],a=t[2],o=t[4],s=t[1],c=t[3],l=t[5],u=Math.sin(n),d=Math.cos(n);return e[0]=i*d+s*u,e[1]=-i*u+s*d,e[2]=a*d+c*u,e[3]=-a*u+d*c,e[4]=d*(o-r[0])+u*(l-r[1])+r[0],e[5]=d*(l-r[1])-u*(o-r[0])+r[1],e}function Pt(e,t,n){var r=n[0],i=n[1];return e[0]=t[0]*r,e[1]=t[1]*i,e[2]=t[2]*r,e[3]=t[3]*i,e[4]=t[4]*r,e[5]=t[5]*i,e}function Ft(e,t){var n=t[0],r=t[2],i=t[4],a=t[1],o=t[3],s=t[5],c=n*o-a*r;return c?(c=1/c,e[0]=o*c,e[1]=-a*c,e[2]=-r*c,e[3]=n*c,e[4]=(r*s-o*i)*c,e[5]=(a*i-n*s)*c,e):null}var It=function(){function e(e,t){this.x=e||0,this.y=t||0}return e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this},e.prototype.clone=function(){return new e(this.x,this.y)},e.prototype.set=function(e,t){return this.x=e,this.y=t,this},e.prototype.equal=function(e){return e.x===this.x&&e.y===this.y},e.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this},e.prototype.scale=function(e){this.x*=e,this.y*=e},e.prototype.scaleAndAdd=function(e,t){this.x+=e.x*t,this.y+=e.y*t},e.prototype.sub=function(e){return this.x-=e.x,this.y-=e.y,this},e.prototype.dot=function(e){return this.x*e.x+this.y*e.y},e.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lenSquare=function(){return this.x*this.x+this.y*this.y},e.prototype.normalize=function(){var e=this.len();return this.x/=e,this.y/=e,this},e.prototype.distance=function(e){var t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)},e.prototype.distanceSquare=function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},e.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},e.prototype.transform=function(e){if(e){var t=this.x,n=this.y;return this.x=e[0]*t+e[2]*n+e[4],this.y=e[1]*t+e[3]*n+e[5],this}},e.prototype.toArray=function(e){return e[0]=this.x,e[1]=this.y,e},e.prototype.fromArray=function(e){this.x=e[0],this.y=e[1]},e.set=function(e,t,n){e.x=t,e.y=n},e.copy=function(e,t){e.x=t.x,e.y=t.y},e.len=function(e){return Math.sqrt(e.x*e.x+e.y*e.y)},e.lenSquare=function(e){return e.x*e.x+e.y*e.y},e.dot=function(e,t){return e.x*t.x+e.y*t.y},e.add=function(e,t,n){e.x=t.x+n.x,e.y=t.y+n.y},e.sub=function(e,t,n){e.x=t.x-n.x,e.y=t.y-n.y},e.scale=function(e,t,n){e.x=t.x*n,e.y=t.y*n},e.scaleAndAdd=function(e,t,n,r){e.x=t.x+n.x*r,e.y=t.y+n.y*r},e.lerp=function(e,t,n,r){var i=1-r;e.x=i*t.x+r*n.x,e.y=i*t.y+r*n.y},e}(),Lt=Math.min,Rt=Math.max,zt=new It,Bt=new It,Vt=new It,Ht=new It,Ut=new It,Wt=new It,Gt=function(){function e(e,t,n,r){n<0&&(e+=n,n=-n),r<0&&(t+=r,r=-r),this.x=e,this.y=t,this.width=n,this.height=r}return e.prototype.union=function(e){var t=Lt(e.x,this.x),n=Lt(e.y,this.y);isFinite(this.x)&&isFinite(this.width)?this.width=Rt(e.x+e.width,this.x+this.width)-t:this.width=e.width,isFinite(this.y)&&isFinite(this.height)?this.height=Rt(e.y+e.height,this.y+this.height)-n:this.height=e.height,this.x=t,this.y=n},e.prototype.applyTransform=function(t){e.applyTransform(this,this,t)},e.prototype.calculateTransform=function(e){var t=this,n=e.width/t.width,r=e.height/t.height,i=Ot();return Mt(i,i,[-t.x,-t.y]),Pt(i,i,[n,r]),Mt(i,i,[e.x,e.y]),i},e.prototype.intersect=function(t,n){if(!t)return!1;t instanceof e||(t=e.create(t));var r=this,i=r.x,a=r.x+r.width,o=r.y,s=r.y+r.height,c=t.x,l=t.x+t.width,u=t.y,d=t.y+t.height,f=!(a<c||l<i||s<u||d<o);if(n){var p=1/0,m=0,h=Math.abs(a-c),g=Math.abs(l-i),_=Math.abs(s-u),v=Math.abs(d-o),y=Math.min(h,g),b=Math.min(_,v);a<c||l<i?y>m&&(m=y,h<g?It.set(Wt,-h,0):It.set(Wt,g,0)):y<p&&(p=y,h<g?It.set(Ut,h,0):It.set(Ut,-g,0)),s<u||d<o?b>m&&(m=b,_<v?It.set(Wt,0,-_):It.set(Wt,0,v)):y<p&&(p=y,_<v?It.set(Ut,0,_):It.set(Ut,0,-v))}return n&&It.copy(n,f?Ut:Wt),f},e.prototype.contain=function(e,t){var n=this;return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e.prototype.copy=function(t){e.copy(this,t)},e.prototype.plain=function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},e.prototype.isFinite=function(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)},e.prototype.isZero=function(){return this.width===0||this.height===0},e.create=function(t){return new e(t.x,t.y,t.width,t.height)},e.copy=function(e,t){e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height},e.applyTransform=function(t,n,r){if(!r){t!==n&&e.copy(t,n);return}if(r[1]<1e-5&&r[1]>-1e-5&&r[2]<1e-5&&r[2]>-1e-5){var i=r[0],a=r[3],o=r[4],s=r[5];t.x=n.x*i+o,t.y=n.y*a+s,t.width=n.width*i,t.height=n.height*a,t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height);return}zt.x=Vt.x=n.x,zt.y=Ht.y=n.y,Bt.x=Ht.x=n.x+n.width,Bt.y=Vt.y=n.y+n.height,zt.transform(r),Ht.transform(r),Bt.transform(r),Vt.transform(r),t.x=Lt(zt.x,Bt.x,Vt.x,Ht.x),t.y=Lt(zt.y,Bt.y,Vt.y,Ht.y);var c=Rt(zt.x,Bt.x,Vt.x,Ht.x),l=Rt(zt.y,Bt.y,Vt.y,Ht.y);t.width=c-t.x,t.height=l-t.y},e}(),Kt={};function qt(e,t){t=t||I;var n=Kt[t];n||(n=Kt[t]=new St(500));var r=n.get(e);return r??(r=oe.measureText(e,t).width,n.put(e,r)),r}function Jt(e,t,n,r){var i=qt(e,t),a=Qt(t);return new Gt(Xt(0,i,n),Zt(0,a,r),i,a)}function Yt(e,t,n,r){var i=((e||``)+``).split(`
|
|
6
6
|
`);if(i.length===1)return Jt(i[0],t,n,r);for(var a=new Gt(0,0,0,0),o=0;o<i.length;o++){var s=Jt(i[o],t,n,r);o===0?a.copy(s):a.union(s)}return a}function Xt(e,t,n){return n===`right`?e-=t:n===`center`&&(e-=t/2),e}function Zt(e,t,n){return n===`middle`?e-=t/2:n===`bottom`&&(e-=t),e}function Qt(e){return qt(`国`,e)}function $t(e,t){return typeof e==`string`?e.lastIndexOf(`%`)>=0?parseFloat(e)/100*t:parseFloat(e):e}function en(e,t,n){var r=t.position||`inside`,i=t.distance==null?5:t.distance,a=n.height,o=n.width,s=a/2,c=n.x,l=n.y,u=`left`,d=`top`;if(r instanceof Array)c+=$t(r[0],n.width),l+=$t(r[1],n.height),u=null,d=null;else switch(r){case`left`:c-=i,l+=s,u=`right`,d=`middle`;break;case`right`:c+=i+o,l+=s,d=`middle`;break;case`top`:c+=o/2,l-=i,u=`center`,d=`bottom`;break;case`bottom`:c+=o/2,l+=a+i,u=`center`;break;case`inside`:c+=o/2,l+=s,u=`center`,d=`middle`;break;case`insideLeft`:c+=i,l+=s,d=`middle`;break;case`insideRight`:c+=o-i,l+=s,u=`right`,d=`middle`;break;case`insideTop`:c+=o/2,l+=i,u=`center`;break;case`insideBottom`:c+=o/2,l+=a-i,u=`center`,d=`bottom`;break;case`insideTopLeft`:c+=i,l+=i;break;case`insideTopRight`:c+=o-i,l+=i,u=`right`;break;case`insideBottomLeft`:c+=i,l+=a-i,d=`bottom`;break;case`insideBottomRight`:c+=o-i,l+=a-i,u=`right`,d=`bottom`;break}return e=e||{},e.x=c,e.y=l,e.align=u,e.verticalAlign=d,e}var tn=/\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;function nn(e,t,n,r,i,a){if(!n){e.text=``,e.isTruncated=!1;return}var o=(t+``).split(`
|
|
7
7
|
`);a=rn(n,r,i,a);for(var s=!1,c={},l=0,u=o.length;l<u;l++)an(c,o[l],a),o[l]=c.textLine,s=s||c.isTruncated;e.text=o.join(`
|
|
8
8
|
`),e.isTruncated=s}function rn(e,t,n,r){r=r||{};var i=V({},r);i.font=t,n=Z(n,`...`),i.maxIterations=Z(r.maxIterations,2);var a=i.minChar=Z(r.minChar,0);i.cnCharWidth=qt(`国`,t);var o=i.ascCharWidth=qt(`a`,t);i.placeholder=Z(r.placeholder,``);for(var s=e=Math.max(0,e-1),c=0;c<a&&s>=o;c++)s-=o;var l=qt(n,t);return l>s&&(n=``,l=0),s=e-l,i.ellipsis=n,i.ellipsisWidth=l,i.contentWidth=s,i.containerWidth=e,i}function an(e,t,n){var r=n.containerWidth,i=n.font,a=n.contentWidth;if(!r){e.textLine=``,e.isTruncated=!1;return}var o=qt(t,i);if(o<=r){e.textLine=t,e.isTruncated=!1;return}for(var s=0;;s++){if(o<=a||s>=n.maxIterations){t+=n.ellipsis;break}var c=s===0?on(t,a,n.ascCharWidth,n.cnCharWidth):o>0?Math.floor(t.length*a/o):0;t=t.substr(0,c),o=qt(t,i)}t===``&&(t=n.placeholder),e.textLine=t,e.isTruncated=!0}function on(e,t,n,r){for(var i=0,a=0,o=e.length;a<o&&i<t;a++){var s=e.charCodeAt(a);i+=0<=s&&s<=127?n:r}return a}function sn(e,t){e!=null&&(e+=``);var n=t.overflow,r=t.padding,i=t.font,a=n===`truncate`,o=Qt(i),s=Z(t.lineHeight,o),c=!!t.backgroundColor,l=t.lineOverflow===`truncate`,u=!1,d=t.width,f=d!=null&&(n===`break`||n===`breakAll`)?e?gn(e,t.font,d,n===`breakAll`,0).lines:[]:e?e.split(`
|
|
@@ -20,11 +20,11 @@ import{createContext as e}from"preact";import{useCallback as t,useContext as n,u
|
|
|
20
20
|
`:`<br/>`,m=l.join(p);this._showOrMove(a,function(){this._updateContentNotChangedOnAxis(e,s)?this._updatePosition(a,d,i[0],i[1],this._tooltipContent,s):this._showTooltipContent(a,m,s,Math.random()+``,i[0],i[1],d,null,u)})},t.prototype._showSeriesItemTooltip=function(e,t,n){var r=this._ecModel,i=Ps(t),a=i.seriesIndex,o=r.getSeriesByIndex(a),s=i.dataModel||o,c=i.dataIndex,l=i.dataType,u=s.getData(l),d=this._renderMode,f=e.positionDefault,p=hk([u.getItemModel(c),s,o&&(o.coordinateSystem||{}).model],this._tooltipModel,f?{position:f}:null),m=p.get(`trigger`);if(!(m!=null&&m!==`item`)){var h=s.getDataParams(c,l),g=new fg;h.marker=g.makeTooltipMarker(`item`,ih(h.color),d);var _=Oh(s.formatTooltip(c,!1,l)),v=p.get(`order`),y=p.get(`valueFormatter`),b=_.frag,x=b?rg(y?V({valueFormatter:y},b):b,g,d,v,r.get(`useUTC`),p.get(`textStyle`)):_.text,S=`item_`+s.name+`_`+c;this._showOrMove(p,function(){this._showTooltipContent(p,x,h,S,e.offsetX,e.offsetY,e.position,e.target,g)}),n({type:`showTip`,dataIndexInside:c,dataIndex:u.getRawIndex(c),seriesIndex:a,from:this.uid})}},t.prototype._showComponentItemTooltip=function(e,t,n){var r=this._renderMode===`html`,i=Ps(t),a=i.tooltipConfig.option||{},o=a.encodeHTMLContent;if(Y(a)){var s=a;a={content:s,formatter:s},o=!0}o&&r&&a.content&&(a=z(a),a.content=am(a.content));var c=[a],l=this._ecModel.getComponent(i.componentMainType,i.componentIndex);l&&c.push(l),c.push({formatter:a.content});var u=e.positionDefault,d=hk(c,this._tooltipModel,u?{position:u}:null),f=d.get(`content`),p=Math.random()+``,m=new fg;this._showOrMove(d,function(){var n=z(d.get(`formatterParams`)||{});this._showTooltipContent(d,f,n,p,e.offsetX,e.offsetY,e.position,t,m)}),n({type:`showTip`,from:this.uid})},t.prototype._showTooltipContent=function(e,t,n,r,i,a,o,s,c){if(this._ticket=``,!(!e.get(`showContent`)||!e.get(`show`))){var l=this._tooltipContent;l.setEnterable(e.get(`enterable`));var u=e.get(`formatter`);o=o||e.get(`position`);var d=t,f=this._getNearestPoint([i,a],n,e.get(`trigger`),e.get(`borderColor`)).color;if(u)if(Y(u)){var p=e.ecModel.get(`useUTC`),m=q(n)?n[0]:n,h=m&&m.axisType&&m.axisType.indexOf(`time`)>=0;d=u,h&&(d=Mm(m.axisValue,d,p)),d=nh(d,n,!0)}else if(J(u)){var g=K(function(t,r){t===this._ticket&&(l.setContent(r,c,e,f,o),this._updatePosition(e,o,i,a,l,n,s))},this);this._ticket=r,d=u(n,r,g)}else d=u;l.setContent(d,c,e,f,o),l.show(e,f),this._updatePosition(e,o,i,a,l,n,s)}},t.prototype._getNearestPoint=function(e,t,n,r){if(n===`axis`||q(t))return{color:r||(this._renderMode===`html`?`#fff`:`none`)};if(!q(t))return{color:r||t.color||t.borderColor}},t.prototype._updatePosition=function(e,t,n,r,i,a,o){var s=this._api.getWidth(),c=this._api.getHeight();t=t||e.get(`position`);var l=i.getSize(),u=e.get(`align`),d=e.get(`verticalAlign`),f=o&&o.getBoundingRect().clone();if(o&&f.applyTransform(o.transform),J(t)&&(t=t([n,r],a,i.el,f,{viewSize:[s,c],contentSize:l.slice()})),q(t))n=Po(t[0],s),r=Po(t[1],c);else if(X(t)){var p=t;p.width=l[0],p.height=l[1];var m=uh(p,{width:s,height:c});n=m.x,r=m.y,u=null,d=null}else if(Y(t)&&o){var h=yk(t,f,l,e.get(`borderWidth`));n=h[0],r=h[1]}else{var h=_k(n,r,i,s,c,u?null:20,d?null:20);n=h[0],r=h[1]}if(u&&(n-=bk(u)?l[0]/2:u===`right`?l[0]:0),d&&(r-=bk(d)?l[1]/2:d===`bottom`?l[1]:0),GO(e)){var h=vk(n,r,i,s,c);n=h[0],r=h[1]}i.moveTo(n,r)},t.prototype._updateContentNotChangedOnAxis=function(e,t){var n=this._lastDataByCoordSys,r=this._cbParamsList,i=!!n&&n.length===e.length;return i&&W(n,function(n,a){var o=n.dataByAxis||[],s=(e[a]||{}).dataByAxis||[];i=i&&o.length===s.length,i&&W(o,function(e,n){var a=s[n]||{},o=e.seriesDataIndices||[],c=a.seriesDataIndices||[];i=i&&e.value===a.value&&e.axisType===a.axisType&&e.axisId===a.axisId&&o.length===c.length,i&&W(o,function(e,t){var n=c[t];i=i&&e.seriesIndex===n.seriesIndex&&e.dataIndex===n.dataIndex}),r&&W(e.seriesDataIndices,function(e){var n=e.seriesIndex,a=t[n],o=r[n];a&&o&&o.data!==a.data&&(i=!1)})})}),this._lastDataByCoordSys=e,this._cbParamsList=t,!!i},t.prototype._hide=function(e){this._lastDataByCoordSys=null,e({type:`hideTip`,from:this.uid})},t.prototype.dispose=function(e,t){$.node||!t.getDom()||(pv(this,`_updatePosition`),this._tooltipContent.dispose(),oO(`itemTooltip`,t))},t.type=`tooltip`,t}(hx);function hk(e,t,n){var r=t.ecModel,i;n?(i=new Ld(n,r,r),i=new Ld(t.option,i,r)):i=t;for(var a=e.length-1;a>=0;a--){var o=e[a];o&&(o instanceof Ld&&(o=o.get(`tooltip`,!0)),Y(o)&&(o={formatter:o}),o&&(i=new Ld(o,i,r)))}return i}function gk(e,t){return e.dispatchAction||K(t.dispatchAction,t)}function _k(e,t,n,r,i,a,o){var s=n.getSize(),c=s[0],l=s[1];return a!=null&&(e+c+a+2>r?e-=c+a:e+=a),o!=null&&(t+l+o>i?t-=l+o:t+=o),[e,t]}function vk(e,t,n,r,i){var a=n.getSize(),o=a[0],s=a[1];return e=Math.min(e+o,r)-o,t=Math.min(t+s,i)-s,e=Math.max(e,0),t=Math.max(t,0),[e,t]}function yk(e,t,n,r){var i=n[0],a=n[1],o=Math.ceil(Math.SQRT2*r)+8,s=0,c=0,l=t.width,u=t.height;switch(e){case`inside`:s=t.x+l/2-i/2,c=t.y+u/2-a/2;break;case`top`:s=t.x+l/2-i/2,c=t.y-a-o;break;case`bottom`:s=t.x+l/2-i/2,c=t.y+u+o;break;case`left`:s=t.x-i-o,c=t.y+u/2-a/2;break;case`right`:s=t.x+l+o,c=t.y+u/2-a/2}return[s,c]}function bk(e){return e===`center`||e===`middle`}function xk(e,t,n){var r=Es(e).queryOptionMap,i=r.keys()[0];if(!(!i||i===`series`)){var a=ks(t,i,r.get(i),{useDefault:!1,enableAll:!1,enableNone:!1}).models[0];if(a){var o=n.getViewOfComponentModel(a),s;if(o.group.traverse(function(t){var n=Ps(t).tooltipConfig;if(n&&n.name===e.name)return s=t,!0}),s)return{componentMainType:i,componentIndex:a.componentIndex,el:s}}}}var Sk=mk;function Ck(e){Nw(xO),e.registerComponentModel(WO),e.registerComponentView(Sk),e.registerAction({type:`showTip`,event:`showTip`,update:`tooltip:manuallyShowTip`},Qe),e.registerAction({type:`hideTip`,event:`hideTip`,update:`tooltip:manuallyHideTip`},Qe)}var wk=function(e,t){if(t===`all`)return{type:`all`,title:e.getLocaleModel().get([`legend`,`selector`,`all`])};if(t===`inverse`)return{type:`inverse`,title:e.getLocaleModel().get([`legend`,`selector`,`inverse`])}},Tk=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.layoutMode={type:`box`,ignoreSize:!0},n}return t.prototype.init=function(e,t,n){this.mergeDefaultAndTheme(e,n),e.selected=e.selected||{},this._updateSelector(e)},t.prototype.mergeOption=function(t,n){e.prototype.mergeOption.call(this,t,n),this._updateSelector(t)},t.prototype._updateSelector=function(e){var t=e.selector,n=this.ecModel;t===!0&&(t=e.selector=[`all`,`inverse`]),q(t)&&W(t,function(e,r){Y(e)&&(e={type:e}),t[r]=B(e,wk(n,e.type))})},t.prototype.optionUpdated=function(){this._updateData(this.ecModel);var e=this._data;if(e[0]&&this.get(`selectedMode`)===`single`){for(var t=!1,n=0;n<e.length;n++){var r=e[n].get(`name`);if(this.isSelected(r)){this.select(r),t=!0;break}}!t&&this.select(e[0].get(`name`))}},t.prototype._updateData=function(e){var t=[],n=[];e.eachRawSeries(function(r){var i=r.name;n.push(i);var a;if(r.legendVisualProvider){var o=r.legendVisualProvider.getAllNames();e.isSeriesFiltered(r)||(n=n.concat(o)),o.length?t=t.concat(o):a=!0}else a=!0;a&&vs(r)&&t.push(r.name)}),this._availableNames=n;var r=this.get(`data`)||t,i=Q();this._data=Ce(G(r,function(e){return(Y(e)||Oe(e))&&(e={name:e}),i.get(e.name)?null:(i.set(e.name,!0),new Ld(e,this,this.ecModel))},this),function(e){return!!e})},t.prototype.getData=function(){return this._data},t.prototype.select=function(e){var t=this.option.selected;if(this.get(`selectedMode`)===`single`){var n=this._data;W(n,function(e){t[e.get(`name`)]=!1})}t[e]=!0},t.prototype.unSelect=function(e){this.get(`selectedMode`)!==`single`&&(this.option.selected[e]=!1)},t.prototype.toggleSelected=function(e){var t=this.option.selected;t.hasOwnProperty(e)||(t[e]=!0),this[t[e]?`unSelect`:`select`](e)},t.prototype.allSelect=function(){var e=this._data,t=this.option.selected;W(e,function(e){t[e.get(`name`,!0)]=!0})},t.prototype.inverseSelect=function(){var e=this._data,t=this.option.selected;W(e,function(e){var n=e.get(`name`,!0);t.hasOwnProperty(n)||(t[n]=!0),t[n]=!t[n]})},t.prototype.isSelected=function(e){var t=this.option.selected;return!(t.hasOwnProperty(e)&&!t[e])&&U(this._availableNames,e)>=0},t.prototype.getOrient=function(){return this.get(`orient`)===`vertical`?{index:1,name:`vertical`}:{index:0,name:`horizontal`}},t.type=`legend.plain`,t.dependencies=[`series`],t.defaultOption={z:4,show:!0,orient:`horizontal`,left:`center`,top:0,align:`auto`,backgroundColor:`rgba(0,0,0,0)`,borderColor:`#ccc`,borderRadius:0,borderWidth:0,padding:5,itemGap:10,itemWidth:25,itemHeight:14,symbolRotate:`inherit`,symbolKeepAspect:!0,inactiveColor:`#ccc`,inactiveBorderColor:`#ccc`,inactiveBorderWidth:`auto`,itemStyle:{color:`inherit`,opacity:`inherit`,borderColor:`inherit`,borderWidth:`auto`,borderCap:`inherit`,borderJoin:`inherit`,borderDashOffset:`inherit`,borderMiterLimit:`inherit`},lineStyle:{width:`auto`,color:`inherit`,inactiveColor:`#ccc`,inactiveWidth:2,opacity:`inherit`,type:`inherit`,cap:`inherit`,join:`inherit`,dashOffset:`inherit`,miterLimit:`inherit`},textStyle:{color:`#333`},selectedMode:!0,selector:!1,selectorLabel:{show:!0,borderRadius:10,padding:[3,5,3,5],fontSize:12,fontFamily:`sans-serif`,color:`#666`,borderWidth:1,borderColor:`#666`},emphasis:{selectorLabel:{show:!0,color:`#eee`,backgroundColor:`#666`}},selectorPosition:`auto`,selectorItemGap:7,selectorButtonGap:10,tooltip:{show:!1}},t}(vh),Ek=Ee,Dk=W,Ok=gl,kk=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!1,n}return t.prototype.init=function(){this.group.add(this._contentGroup=new Ok),this.group.add(this._selectorGroup=new Ok),this._isFirstRender=!0},t.prototype.getContentGroup=function(){return this._contentGroup},t.prototype.getSelectorGroup=function(){return this._selectorGroup},t.prototype.render=function(e,t,n){var r=this._isFirstRender;if(this._isFirstRender=!1,this.resetInner(),e.get(`show`,!0)){var i=e.get(`align`),a=e.get(`orient`);(!i||i===`auto`)&&(i=e.get(`left`)===`right`&&a===`vertical`?`right`:`left`);var o=e.get(`selector`,!0),s=e.get(`selectorPosition`,!0);o&&(!s||s===`auto`)&&(s=a===`horizontal`?`end`:`start`),this.renderInner(i,e,t,n,o,a,s);var c=e.getBoxLayoutParams(),l={width:n.getWidth(),height:n.getHeight()},u=e.get(`padding`),d=uh(c,l,u),f=this.layoutInner(e,i,d,r,o,s),p=uh(H({width:f.width,height:f.height},c),l,u);this.group.x=p.x-f.x,this.group.y=p.y-f.y,this.group.markRedraw(),this.group.add(this._backgroundEl=UO(f,e))}},t.prototype.resetInner=function(){this.getContentGroup().removeAll(),this._backgroundEl&&this.group.remove(this._backgroundEl),this.getSelectorGroup().removeAll()},t.prototype.renderInner=function(e,t,n,r,i,a,o){var s=this.getContentGroup(),c=Q(),l=t.get(`selectedMode`),u=[];n.eachRawSeries(function(e){!e.get(`legendHoverLink`)&&u.push(e.id)}),Dk(t.getData(),function(i,a){var o=i.get(`name`);if(!this.newlineDisabled&&(o===``||o===`
|
|
21
21
|
`)){var d=new Ok;d.newline=!0,s.add(d);return}var f=n.getSeriesByName(o)[0];if(!c.get(o))if(f){var p=f.getData(),m=p.getVisual(`legendLineStyle`)||{},h=p.getVisual(`legendIcon`),g=p.getVisual(`style`),_=this._createItem(f,o,a,i,t,e,m,g,h,l,r);_.on(`click`,Ek(Mk,o,null,r,u)).on(`mouseover`,Ek(Pk,f.name,null,r,u)).on(`mouseout`,Ek(Fk,f.name,null,r,u)),n.ssr&&_.eachChild(function(e){var t=Ps(e);t.seriesIndex=f.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),c.set(o,!0)}else n.eachRawSeries(function(s){if(!c.get(o)&&s.legendVisualProvider){var d=s.legendVisualProvider;if(!d.containName(o))return;var f=d.indexOfName(o),p=d.getItemVisual(f,`style`),m=d.getItemVisual(f,`legendIcon`),h=jr(p.fill);h&&h[3]===0&&(h[3]=.2,p=V(V({},p),{fill:Fr(h,`rgba`)}));var g=this._createItem(s,o,a,i,t,e,{},p,m,l,r);g.on(`click`,Ek(Mk,null,o,r,u)).on(`mouseover`,Ek(Pk,null,o,r,u)).on(`mouseout`,Ek(Fk,null,o,r,u)),n.ssr&&g.eachChild(function(e){var t=Ps(e);t.seriesIndex=s.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),c.set(o,!0)}},this)},this),i&&this._createSelector(i,t,r,a,o)},t.prototype._createSelector=function(e,t,n,r,i){var a=this.getSelectorGroup();Dk(e,function(e){var r=e.type,i=new ko({style:{x:0,y:0,align:`center`,verticalAlign:`middle`},onclick:function(){n.dispatchAction({type:r===`all`?`legendAllSelect`:`legendInverseSelect`,legendId:t.id})}});a.add(i),pd(i,{normal:t.getModel(`selectorLabel`),emphasis:t.getModel([`emphasis`,`selectorLabel`])},{defaultText:e.title}),Pc(i)})},t.prototype._createItem=function(e,t,n,r,i,a,o,s,c,l,u){var d=e.visualDrawType,f=i.get(`itemWidth`),p=i.get(`itemHeight`),m=i.isSelected(t),h=r.get(`symbolRotate`),g=r.get(`symbolKeepAspect`),_=r.get(`icon`);c=_||c||`roundRect`;var v=Ak(c,r,o,s,d,m,u),y=new Ok,b=r.getModel(`textStyle`);if(J(e.getLegendIcon)&&(!_||_===`inherit`))y.add(e.getLegendIcon({itemWidth:f,itemHeight:p,icon:c,iconRotate:h,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}));else{var x=_===`inherit`&&e.getData().getVisual(`symbol`)?h===`inherit`?e.getData().getVisual(`symbolRotate`):h:0;y.add(jk({itemWidth:f,itemHeight:p,icon:c,iconRotate:x,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}))}var S=a===`left`?f+5:-5,C=a,w=i.get(`formatter`),T=t;Y(w)&&w?T=w.replace(`{name}`,t??``):J(w)&&(T=w(t));var E=m?b.getTextColor():r.get(`inactiveColor`);y.add(new ko({style:hd(b,{text:T,x:S,y:p/2,fill:E,align:C,verticalAlign:`middle`},{inheritColor:E})}));var D=new uo({shape:y.getBoundingRect(),style:{fill:`transparent`}}),O=r.getModel(`tooltip`);return O.get(`show`)&&sd({el:D,componentModel:i,itemName:t,itemTooltipOption:O.option}),y.add(D),y.eachChild(function(e){e.silent=!0}),D.silent=!l,this.getContentGroup().add(y),Pc(y),y.__legendDataIndex=n,y},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getContentGroup(),s=this.getSelectorGroup();lh(e.get(`orient`),o,e.get(`itemGap`),n.width,n.height);var c=o.getBoundingRect(),l=[-c.x,-c.y];if(s.markRedraw(),o.markRedraw(),i){lh(`horizontal`,s,e.get(`selectorItemGap`,!0));var u=s.getBoundingRect(),d=[-u.x,-u.y],f=e.get(`selectorButtonGap`,!0),p=e.getOrient().index,m=p===0?`width`:`height`,h=p===0?`height`:`width`,g=p===0?`y`:`x`;a===`end`?d[p]+=c[m]+f:l[p]+=u[m]+f,d[1-p]+=c[h]/2-u[h]/2,s.x=d[0],s.y=d[1],o.x=l[0],o.y=l[1];var _={x:0,y:0};return _[m]=c[m]+f+u[m],_[h]=Math.max(c[h],u[h]),_[g]=Math.min(0,u[g]+d[1-p]),_}else return o.x=l[0],o.y=l[1],this.group.getBoundingRect()},t.prototype.remove=function(){this.getContentGroup().removeAll(),this._isFirstRender=!0},t.type=`legend.plain`,t}(hx);function Ak(e,t,n,r,i,a,o){function s(e,t){e.lineWidth===`auto`&&(e.lineWidth=t.lineWidth>0?2:0),Dk(e,function(n,r){e[r]===`inherit`&&(e[r]=t[r])})}var c=t.getModel(`itemStyle`),l=c.getItemStyle(),u=e.lastIndexOf(`empty`,0)===0?`fill`:`stroke`,d=c.getShallow(`decal`);l.decal=!d||d===`inherit`?r.decal:YS(d,o),l.fill===`inherit`&&(l.fill=r[i]),l.stroke===`inherit`&&(l.stroke=r[u]),l.opacity===`inherit`&&(l.opacity=(i===`fill`?r:n).opacity),s(l,r);var f=t.getModel(`lineStyle`),p=f.getLineStyle();if(s(p,n),l.fill===`auto`&&(l.fill=r.fill),l.stroke===`auto`&&(l.stroke=r.fill),p.stroke===`auto`&&(p.stroke=r.fill),!a){var m=t.get(`inactiveBorderWidth`),h=l[u];l.lineWidth=m===`auto`?r.lineWidth>0&&h?2:0:l.lineWidth,l.fill=t.get(`inactiveColor`),l.stroke=t.get(`inactiveBorderColor`),p.stroke=f.get(`inactiveColor`),p.lineWidth=f.get(`inactiveWidth`)}return{itemStyle:l,lineStyle:p}}function jk(e){var t=e.icon||`roundRect`,n=Pg(t,0,0,e.itemWidth,e.itemHeight,e.itemStyle.fill,e.symbolKeepAspect);return n.setStyle(e.itemStyle),n.rotation=(e.iconRotate||0)*Math.PI/180,n.setOrigin([e.itemWidth/2,e.itemHeight/2]),t.indexOf(`empty`)>-1&&(n.style.stroke=n.style.fill,n.style.fill=`#fff`,n.style.lineWidth=2),n}function Mk(e,t,n,r){Fk(e,t,n,r),n.dispatchAction({type:`legendToggleSelect`,name:e??t}),Pk(e,t,n,r)}function Nk(e){for(var t=e.getZr().storage.getDisplayList(),n,r=0,i=t.length;r<i&&!(n=t[r].states.emphasis);)r++;return n&&n.hoverLayer}function Pk(e,t,n,r){Nk(n)||n.dispatchAction({type:`highlight`,seriesName:e,name:t,excludeSeriesId:r})}function Fk(e,t,n,r){Nk(n)||n.dispatchAction({type:`downplay`,seriesName:e,name:t,excludeSeriesId:r})}var Ik=kk;function Lk(e){var t=e.findComponents({mainType:`legend`});t&&t.length&&e.filterSeries(function(e){for(var n=0;n<t.length;n++)if(!t[n].isSelected(e.name))return!1;return!0})}function Rk(e,t,n){var r=e===`allSelect`||e===`inverseSelect`,i={},a=[];n.eachComponent({mainType:`legend`,query:t},function(n){r?n[e]():n[e](t.name),zk(n,i),a.push(n.componentIndex)});var o={};return n.eachComponent(`legend`,function(e){W(i,function(t,n){e[t?`select`:`unSelect`](n)}),zk(e,o)}),r?{selected:o,legendIndex:a}:{name:t.name,selected:o}}function zk(e,t){var n=t||{};return W(e.getData(),function(t){var r=t.get(`name`);if(!(r===`
|
|
22
22
|
`||r===``)){var i=e.isSelected(r);Ze(n,r)?n[r]=n[r]&&i:n[r]=i}}),n}function Bk(e){e.registerAction(`legendToggleSelect`,`legendselectchanged`,Ee(Rk,`toggleSelected`)),e.registerAction(`legendAllSelect`,`legendselectall`,Ee(Rk,`allSelect`)),e.registerAction(`legendInverseSelect`,`legendinverseselect`,Ee(Rk,`inverseSelect`)),e.registerAction(`legendSelect`,`legendselected`,Ee(Rk,`select`)),e.registerAction(`legendUnSelect`,`legendunselected`,Ee(Rk,`unSelect`))}function Vk(e){e.registerComponentModel(Tk),e.registerComponentView(Ik),e.registerProcessor(e.PRIORITY.PROCESSOR.SERIES_FILTER,Lk),e.registerSubTypeDefaulter(`legend`,function(){return`plain`}),Bk(e)}var Hk=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.setScrollDataIndex=function(e){this.option.scrollDataIndex=e},t.prototype.init=function(t,n,r){var i=ph(t);e.prototype.init.call(this,t,n,r),Uk(this,t,i)},t.prototype.mergeOption=function(t,n){e.prototype.mergeOption.call(this,t,n),Uk(this,this.option,t)},t.type=`legend.scroll`,t.defaultOption=Kp(Tk.defaultOption,{scrollDataIndex:0,pageButtonItemGap:5,pageButtonGap:null,pageButtonPosition:`end`,pageFormatter:`{current}/{total}`,pageIcons:{horizontal:[`M0,0L12,-10L12,10z`,`M0,0L-12,-10L-12,10z`],vertical:[`M0,0L20,0L10,-20z`,`M0,0L20,0L10,20z`]},pageIconColor:`#2f4554`,pageIconInactiveColor:`#aaa`,pageIconSize:15,pageTextStyle:{color:`#333`},animationDurationUpdate:800}),t}(Tk);function Uk(e,t,n){var r=e.getOrient(),i=[1,1];i[r.index]=0,fh(t,n,{type:`box`,ignoreSize:!!i})}var Wk=Hk,Gk=gl,Kk=[`width`,`height`],qk=[`x`,`y`],Jk=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!0,n._currentIndex=0,n}return t.prototype.init=function(){e.prototype.init.call(this),this.group.add(this._containerGroup=new Gk),this._containerGroup.add(this.getContentGroup()),this.group.add(this._controllerGroup=new Gk)},t.prototype.resetInner=function(){e.prototype.resetInner.call(this),this._controllerGroup.removeAll(),this._containerGroup.removeClipPath(),this._containerGroup.__rectSize=null},t.prototype.renderInner=function(t,n,r,i,a,o,s){var c=this;e.prototype.renderInner.call(this,t,n,r,i,a,o,s);var l=this._controllerGroup,u=n.get(`pageIconSize`,!0),d=q(u)?u:[u,u];p(`pagePrev`,0);var f=n.getModel(`pageTextStyle`);l.add(new ko({name:`pageText`,style:{text:`xx/xx`,fill:f.getTextColor(),font:f.getFont(),verticalAlign:`middle`,align:`center`},silent:!0})),p(`pageNext`,1);function p(e,t){var r=e+`DataIndex`,a=nd(n.get(`pageIcons`,!0)[n.getOrient().name][t],{onclick:K(c._pageGo,c,r,n,i)},{x:-d[0]/2,y:-d[1]/2,width:d[0],height:d[1]});a.name=e,l.add(a)}},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getSelectorGroup(),s=e.getOrient().index,c=Kk[s],l=qk[s],u=Kk[1-s],d=qk[1-s];i&&lh(`horizontal`,o,e.get(`selectorItemGap`,!0));var f=e.get(`selectorButtonGap`,!0),p=o.getBoundingRect(),m=[-p.x,-p.y],h=z(n);i&&(h[c]=n[c]-p[c]-f);var g=this._layoutContentAndController(e,r,h,s,c,u,d,l);if(i){if(a===`end`)m[s]+=g[c]+f;else{var _=p[c]+f;m[s]-=_,g[l]-=_}g[c]+=p[c]+f,m[1-s]+=g[d]+g[u]/2-p[u]/2,g[u]=Math.max(g[u],p[u]),g[d]=Math.min(g[d],p[d]+m[1-s]),o.x=m[0],o.y=m[1],o.markRedraw()}return g},t.prototype._layoutContentAndController=function(e,t,n,r,i,a,o,s){var c=this.getContentGroup(),l=this._containerGroup,u=this._controllerGroup;lh(e.get(`orient`),c,e.get(`itemGap`),r?n.width:null,r?null:n.height),lh(`horizontal`,u,e.get(`pageButtonItemGap`,!0));var d=c.getBoundingRect(),f=u.getBoundingRect(),p=this._showController=d[i]>n[i],m=[-d.x,-d.y];t||(m[r]=c[s]);var h=[0,0],g=[-f.x,-f.y],_=Z(e.get(`pageButtonGap`,!0),e.get(`itemGap`,!0));p&&(e.get(`pageButtonPosition`,!0)===`end`?g[r]+=n[i]-f[i]:h[r]+=f[i]+_),g[1-r]+=d[a]/2-f[a]/2,c.setPosition(m),l.setPosition(h),u.setPosition(g);var v={x:0,y:0};if(v[i]=p?n[i]:d[i],v[a]=Math.max(d[a],f[a]),v[o]=Math.min(0,f[o]+g[1-r]),l.__rectSize=n[i],p){var y={x:0,y:0};y[i]=Math.max(n[i]-f[i]-_,0),y[a]=v[a],l.setClipPath(new uo({shape:y})),l.__rectSize=y[i]}else u.eachChild(function(e){e.attr({invisible:!0,silent:!0})});var b=this._getPageInfo(e);return b.pageIndex!=null&&wu(c,{x:b.contentPosition[0],y:b.contentPosition[1]},p?e:null),this._updatePageInfoView(e,b),v},t.prototype._pageGo=function(e,t,n){var r=this._getPageInfo(t)[e];r!=null&&n.dispatchAction({type:`legendScroll`,scrollDataIndex:r,legendId:t.id})},t.prototype._updatePageInfoView=function(e,t){var n=this._controllerGroup;W([`pagePrev`,`pageNext`],function(r){var i=t[r+`DataIndex`]!=null,a=n.childOfName(r);a&&(a.setStyle(`fill`,i?e.get(`pageIconColor`,!0):e.get(`pageIconInactiveColor`,!0)),a.cursor=i?`pointer`:`default`)});var r=n.childOfName(`pageText`),i=e.get(`pageFormatter`),a=t.pageIndex,o=a==null?0:a+1,s=t.pageCount;r&&i&&r.setStyle(`text`,Y(i)?i.replace(`{current}`,o==null?``:o+``).replace(`{total}`,s==null?``:s+``):i({current:o,total:s}))},t.prototype._getPageInfo=function(e){var t=e.get(`scrollDataIndex`,!0),n=this.getContentGroup(),r=this._containerGroup.__rectSize,i=e.getOrient().index,a=Kk[i],o=qk[i],s=this._findTargetItemIndex(t),c=n.children(),l=c[s],u=c.length,d=u?1:0,f={contentPosition:[n.x,n.y],pageCount:d,pageIndex:d-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!l)return f;var p=v(l);f.contentPosition[i]=-p.s;for(var m=s+1,h=p,g=p,_=null;m<=u;++m)_=v(c[m]),(!_&&g.e>h.s+r||_&&!y(_,h.s))&&(h=g.i>h.i?g:_,h&&(f.pageNextDataIndex??(f.pageNextDataIndex=h.i),++f.pageCount)),g=_;for(var m=s-1,h=p,g=p,_=null;m>=-1;--m)_=v(c[m]),(!_||!y(g,_.s))&&h.i<g.i&&(g=h,f.pagePrevDataIndex??(f.pagePrevDataIndex=h.i),++f.pageCount,++f.pageIndex),h=_;return f;function v(e){if(e){var t=e.getBoundingRect(),n=t[o]+e[o];return{s:n,e:n+t[a],i:e.__legendDataIndex}}}function y(e,t){return e.e>=t&&e.s<=t+r}},t.prototype._findTargetItemIndex=function(e){if(!this._showController)return 0;var t,n=this.getContentGroup(),r;return n.eachChild(function(n,i){var a=n.__legendDataIndex;r==null&&a!=null&&(r=i),a===e&&(t=i)}),t??r},t.type=`legend.scroll`,t}(Ik);function Yk(e){e.registerAction(`legendScroll`,`legendscroll`,function(e,t){var n=e.scrollDataIndex;n!=null&&t.eachComponent({mainType:`legend`,subType:`scroll`,query:e},function(e){e.setScrollDataIndex(n)})})}function Xk(e){Nw(Vk),e.registerComponentModel(Wk),e.registerComponentView(Jk),Yk(e)}function Zk(e){Nw(Vk),Nw(Xk)}var Qk=function(e){F(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.type=`dataZoom.inside`,t.defaultOption=Kp(MO.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t}(MO),$k=Cs();function eA(e,t,n){$k(e).coordSysRecordMap.each(function(e){var r=e.dataZoomInfoMap.get(t.uid);r&&(r.getRange=n)})}function tA(e,t){for(var n=$k(e).coordSysRecordMap,r=n.keys(),i=0;i<r.length;i++){var a=r[i],o=n.get(a),s=o.dataZoomInfoMap;if(s){var c=t.uid;s.get(c)&&(s.removeKey(c),s.keys().length||nA(n,o))}}}function nA(e,t){if(t){e.removeKey(t.model.uid);var n=t.controller;n&&n.dispose()}}function rA(e,t){var n={model:t,containsPoint:Ee(aA,t),dispatchAction:Ee(iA,e),dataZoomInfoMap:null,controller:null},r=n.controller=new wD(e.getZr());return W([`pan`,`zoom`,`scrollMove`],function(e){r.on(e,function(t){var r=[];n.dataZoomInfoMap.each(function(i){if(t.isAvailableBehavior(i.model.option)){var a=(i.getRange||{})[e],o=a&&a(i.dzReferCoordSysInfo,n.model.mainType,n.controller,t);!i.model.get(`disabled`,!0)&&o&&r.push({dataZoomId:i.model.id,start:o[0],end:o[1]})}}),r.length&&n.dispatchAction(r)})}),n}function iA(e,t){e.isDisposed()||e.dispatchAction({type:`dataZoom`,animation:{easing:`cubicOut`,duration:100},batch:t})}function aA(e,t,n,r){return e.coordinateSystem.containPoint([n,r])}function oA(e){var t,n=`type_`,r={type_true:2,type_move:1,type_false:0,type_undefined:-1},i=!0;return e.each(function(e){var a=e.model,o=a.get(`disabled`,!0)?!1:a.get(`zoomLock`,!0)?`move`:!0;r[n+o]>r[n+t]&&(t=o),i=i&&a.get(`preventDefaultMouseMove`,!0)}),{controlType:t,opt:{zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!0,preventDefaultMouseMove:!!i}}}function sA(e){e.registerProcessor(e.PRIORITY.PROCESSOR.FILTER,function(e,t){var n=$k(t),r=n.coordSysRecordMap||(n.coordSysRecordMap=Q());r.each(function(e){e.dataZoomInfoMap=null}),e.eachComponent({mainType:`dataZoom`,subType:`inside`},function(e){W(OO(e).infoList,function(n){var i=n.model.uid,a=r.get(i)||r.set(i,rA(t,n.model));(a.dataZoomInfoMap||(a.dataZoomInfoMap=Q())).set(e.uid,{dzReferCoordSysInfo:n,model:e,getRange:null})})}),r.each(function(e){var t=e.controller,n,i=e.dataZoomInfoMap;if(i){var a=i.keys()[0];a!=null&&(n=i.get(a))}if(!n){nA(r,e);return}var o=oA(i);t.enable(o.controlType,o.opt),t.setPointerChecker(e.containsPoint),fv(e,`dispatchAction`,n.model.get(`throttle`,!0),`fixRate`)})})}var cA=function(e){F(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;return t.type=`dataZoom.inside`,t}return t.prototype.render=function(t,n,r){if(e.prototype.render.apply(this,arguments),t.noTarget()){this._clear();return}this.range=t.getPercentRange(),eA(r,t,{pan:K(lA.pan,this),zoom:K(lA.zoom,this),scrollMove:K(lA.scrollMove,this)})},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){tA(this.api,this.dataZoomModel),this.range=null},t.type=`dataZoom.inside`,t}(NO),lA={zoom:function(e,t,n,r){var i=this.range,a=i.slice(),o=e.axisModels[0];if(o){var s=dA[t](null,[r.originX,r.originY],o,n,e),c=(s.signal>0?s.pixelStart+s.pixelLength-s.pixel:s.pixel-s.pixelStart)/s.pixelLength*(a[1]-a[0])+a[0],l=Math.max(1/r.scale,0);a[0]=(a[0]-c)*l+c,a[1]=(a[1]-c)*l+c;var u=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();if(TD(0,a,[0,100],0,u.minSpan,u.maxSpan),this.range=a,i[0]!==a[0]||i[1]!==a[1])return a}},pan:uA(function(e,t,n,r,i,a){var o=dA[r]([a.oldX,a.oldY],[a.newX,a.newY],t,i,n);return o.signal*(e[1]-e[0])*o.pixel/o.pixelLength}),scrollMove:uA(function(e,t,n,r,i,a){return dA[r]([0,0],[a.scrollDelta,a.scrollDelta],t,i,n).signal*(e[1]-e[0])*a.scrollDelta})};function uA(e){return function(t,n,r,i){var a=this.range,o=a.slice(),s=t.axisModels[0];if(s&&(TD(e(o,s,t,n,r,i),o,[0,100],`all`),this.range=o,a[0]!==o[0]||a[1]!==o[1]))return o}}var dA={grid:function(e,t,n,r,i){var a=n.axis,o={},s=i.model.coordinateSystem.getRect();return e=e||[0,0],a.dim===`x`?(o.pixel=t[0]-e[0],o.pixelLength=s.width,o.pixelStart=s.x,o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=s.height,o.pixelStart=s.y,o.signal=a.inverse?-1:1),o},polar:function(e,t,n,r,i){var a=n.axis,o={},s=i.model.coordinateSystem,c=s.getRadiusAxis().getExtent(),l=s.getAngleAxis().getExtent();return e=e?s.pointToCoord(e):[0,0],t=s.pointToCoord(t),n.mainType===`radiusAxis`?(o.pixel=t[0]-e[0],o.pixelLength=c[1]-c[0],o.pixelStart=c[0],o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=l[1]-l[0],o.pixelStart=l[0],o.signal=a.inverse?-1:1),o},singleAxis:function(e,t,n,r,i){var a=n.axis,o=i.model.coordinateSystem.getRect(),s={};return e=e||[0,0],a.orient===`horizontal`?(s.pixel=t[0]-e[0],s.pixelLength=o.width,s.pixelStart=o.x,s.signal=a.inverse?1:-1):(s.pixel=t[1]-e[1],s.pixelLength=o.height,s.pixelStart=o.y,s.signal=a.inverse?-1:1),s}},fA=cA;function pA(e){HO(e),e.registerComponentModel(Qk),e.registerComponentView(fA),sA(e)}var mA={label:{enabled:!0},decal:{show:!1}},hA=Cs(),gA={};function _A(e,t){var n=e.getModel(`aria`);if(!n.get(`enabled`))return;var r=z(mA);B(r.label,e.getLocaleModel().get(`aria`),!1),B(n.option,r,!1),i(),a();function i(){if(n.getModel(`decal`).get(`show`)){var t=Q();e.eachSeries(function(e){if(!e.isColorBySeries()){var n=t.get(e.type);n||(n={},t.set(e.type,n)),hA(e).scope=n}}),e.eachRawSeries(function(t){if(e.isSeriesFiltered(t))return;if(J(t.enableAriaDecal)){t.enableAriaDecal();return}var n=t.getData();if(t.isColorBySeries()){var r=Sh(t.ecModel,t.name,gA,e.getSeriesCount()),i=n.getVisual(`decal`);n.setVisual(`decal`,l(i,r))}else{var a=t.getRawData(),o={},s=hA(t).scope;n.each(function(e){var t=n.getRawIndex(e);o[t]=e});var c=a.count();a.each(function(e){var r=o[e],i=a.getName(e)||e+``,u=Sh(t.ecModel,i,s,c),d=n.getItemVisual(r,`decal`);n.setItemVisual(r,`decal`,l(d,u))})}function l(e,t){var n=e?V(V({},t),e):t;return n.dirty=!0,n}})}}function a(){var r=t.getZr().dom;if(r){var i=e.getLocaleModel().get(`aria`),a=n.getModel(`label`);if(a.option=H(a.option,i),a.get(`enabled`)){if(r.setAttribute(`role`,`img`),a.get(`description`)){r.setAttribute(`aria-label`,a.get(`description`));return}var l=e.getSeriesCount(),u=a.get([`data`,`maxCount`])||10,d=a.get([`series`,`maxCount`])||10,f=Math.min(l,d),p;if(!(l<1)){var m=s();p=m?o(a.get([`general`,`withTitle`]),{title:m}):a.get([`general`,`withoutTitle`]);var h=[],g=l>1?a.get([`series`,`multiple`,`prefix`]):a.get([`series`,`single`,`prefix`]);p+=o(g,{seriesCount:l}),e.eachSeries(function(e,t){if(t<f){var n=void 0,r=e.get(`name`)?`withName`:`withoutName`;n=l>1?a.get([`series`,`multiple`,r]):a.get([`series`,`single`,r]),n=o(n,{seriesId:e.seriesIndex,seriesName:e.get(`name`),seriesType:c(e.subType)});var i=e.getData();if(i.count()>u){var s=a.get([`data`,`partialData`]);n+=o(s,{displayCnt:u})}else n+=a.get([`data`,`allData`]);for(var d=a.get([`data`,`separator`,`middle`]),p=a.get([`data`,`separator`,`end`]),m=a.get([`data`,`excludeDimensionId`]),g=[],_=0;_<i.count();_++)if(_<u){var v=i.getName(_),y=m?Ce(i.getValues(_),function(e,t){return U(m,t)===-1}):i.getValues(_),b=a.get([`data`,v?`withName`:`withoutName`]);g.push(o(b,{name:v,value:y.join(d)}))}n+=g.join(d)+p,h.push(n)}});var _=a.getModel([`series`,`multiple`,`separator`]),v=_.get(`middle`),y=_.get(`end`);p+=h.join(v)+y,r.setAttribute(`aria-label`,p)}}}}function o(e,t){if(!Y(e))return e;var n=e;return W(t,function(e,t){n=n.replace(RegExp(`\\{\\s*`+t+`\\s*\\}`,`g`),e)}),n}function s(){var t=e.get(`title`);return t&&t.length&&(t=t[0]),t&&t.text}function c(t){var n=e.getLocaleModel().get([`series`,`typeNames`]);return n[t]||n.chart}}function vA(e){if(!(!e||!e.aria)){var t=e.aria;t.show!=null&&(t.enabled=t.show),t.label=t.label||{},W([`description`,`general`,`series`,`data`],function(e){t[e]!=null&&(t.label[e]=t[e])})}}function yA(e){e.registerPreprocessor(vA),e.registerVisual(e.PRIORITY.VISUAL.ARIA,_A)}function bA(e,t,n){var r=oe.createCanvas(),i=t.getWidth(),a=t.getHeight(),o=r.style;return o&&(o.position=`absolute`,o.left=`0`,o.top=`0`,o.width=i+`px`,o.height=a+`px`,r.setAttribute(`data-zr-dom-id`,e)),r.width=i*n,r.height=a*n,r}var xA=function(e){F(t,e);function t(t,n,r){var i=e.call(this)||this;i.motionBlur=!1,i.lastFrameAlpha=.7,i.dpr=1,i.virtual=!1,i.config={},i.incremental=!1,i.zlevel=0,i.maxRepaintRectCount=5,i.__dirty=!0,i.__firstTimePaint=!0,i.__used=!1,i.__drawIndex=0,i.__startIndex=0,i.__endIndex=0,i.__prevStartIndex=null,i.__prevEndIndex=null;var a;r=r||fi,typeof t==`string`?a=bA(t,n,r):X(t)&&(a=t,t=a.id),i.id=t,i.dom=a;var o=a.style;return o&&(Xe(a),a.onselectstart=function(){return!1},o.padding=`0`,o.margin=`0`,o.borderWidth=`0`),i.painter=n,i.dpr=r,i}return t.prototype.getElementCount=function(){return this.__endIndex-this.__startIndex},t.prototype.afterBrush=function(){this.__prevStartIndex=this.__startIndex,this.__prevEndIndex=this.__endIndex},t.prototype.initContext=function(){this.ctx=this.dom.getContext(`2d`),this.ctx.dpr=this.dpr},t.prototype.setUnpainted=function(){this.__firstTimePaint=!0},t.prototype.createBackBuffer=function(){var e=this.dpr;this.domBack=bA(`back-`+this.id,this.painter,e),this.ctxBack=this.domBack.getContext(`2d`),e!==1&&this.ctxBack.scale(e,e)},t.prototype.createRepaintRects=function(e,t,n,r){if(this.__firstTimePaint)return this.__firstTimePaint=!1,null;var i=[],a=this.maxRepaintRectCount,o=!1,s=new Gt(0,0,0,0);function c(e){if(!(!e.isFinite()||e.isZero()))if(i.length===0){var t=new Gt(0,0,0,0);t.copy(e),i.push(t)}else{for(var n=!1,r=1/0,c=0,l=0;l<i.length;++l){var u=i[l];if(u.intersect(e)){var d=new Gt(0,0,0,0);d.copy(u),d.union(e),i[l]=d,n=!0;break}else if(o){s.copy(e),s.union(u);var f=e.width*e.height,p=u.width*u.height,m=s.width*s.height-f-p;m<r&&(r=m,c=l)}}if(o&&(i[c].union(e),n=!0),!n){var t=new Gt(0,0,0,0);t.copy(e),i.push(t)}o||(o=i.length>=a)}}for(var l=this.__startIndex;l<this.__endIndex;++l){var u=e[l];if(u){var d=u.shouldBePainted(n,r,!0,!0),f=u.__isRendered&&(u.__dirty&_i||!d)?u.getPrevPaintRect():null;f&&c(f);var p=d&&(u.__dirty&_i||!u.__isRendered)?u.getPaintRect():null;p&&c(p)}}for(var l=this.__prevStartIndex;l<this.__prevEndIndex;++l){var u=t[l],d=u&&u.shouldBePainted(n,r,!0,!0);if(u&&(!d||!u.__zr)&&u.__isRendered){var f=u.getPrevPaintRect();f&&c(f)}}var m;do{m=!1;for(var l=0;l<i.length;){if(i[l].isZero()){i.splice(l,1);continue}for(var h=l+1;h<i.length;)i[l].intersect(i[h])?(m=!0,i[l].union(i[h]),i.splice(h,1)):h++;l++}}while(m);return this._paintRects=i,i},t.prototype.debugGetPaintRects=function(){return(this._paintRects||[]).slice()},t.prototype.resize=function(e,t){var n=this.dpr,r=this.dom,i=r.style,a=this.domBack;i&&(i.width=e+`px`,i.height=t+`px`),r.width=e*n,r.height=t*n,a&&(a.width=e*n,a.height=t*n,n!==1&&this.ctxBack.scale(n,n))},t.prototype.clear=function(e,t,n){var r=this.dom,i=this.ctx,a=r.width,o=r.height;t=t||this.clearColor;var s=this.motionBlur&&!e,c=this.lastFrameAlpha,l=this.dpr,u=this;s&&(this.domBack||this.createBackBuffer(),this.ctxBack.globalCompositeOperation=`copy`,this.ctxBack.drawImage(r,0,0,a/l,o/l));var d=this.domBack;function f(e,n,r,a){if(i.clearRect(e,n,r,a),t&&t!==`transparent`){var o=void 0;Me(t)?(o=(t.global||t.__width===r&&t.__height===a)&&t.__canvasGradient||fS(i,t,{x:0,y:0,width:r,height:a}),t.__canvasGradient=o,t.__width=r,t.__height=a):Ne(t)&&(t.scaleX=t.scaleX||l,t.scaleY=t.scaleY||l,o=wS(i,t,{dirty:function(){u.setUnpainted(),u.painter.refresh()}})),i.save(),i.fillStyle=o||t,i.fillRect(e,n,r,a),i.restore()}s&&(i.save(),i.globalAlpha=c,i.drawImage(d,e,n,r,a),i.restore())}!n||s?f(0,0,a,o):n.length&&W(n,function(e){f(e.x*l,e.y*l,e.width*l,e.height*l)})},t}(ui),SA=1e5,CA=314159,wA=.01,TA=.001;function EA(e){return e?e.__builtin__?!0:!(typeof e.resize!=`function`||typeof e.refresh!=`function`):!1}function DA(e,t){var n=document.createElement(`div`);return n.style.cssText=[`position:relative`,`width:`+e+`px`,`height:`+t+`px`,`padding:0`,`margin:0`,`border-width:0`].join(`;`)+`;`,n}var OA=function(){function e(e,t,n,r){this.type=`canvas`,this._zlevelList=[],this._prevDisplayList=[],this._layers={},this._layerConfig={},this._needsManuallyCompositing=!1,this.type=`canvas`;var i=!e.nodeName||e.nodeName.toUpperCase()===`CANVAS`;this._opts=n=V({},n||{}),this.dpr=n.devicePixelRatio||fi,this._singleCanvas=i,this.root=e,e.style&&(Xe(e),e.innerHTML=``),this.storage=t;var a=this._zlevelList;this._prevDisplayList=[];var o=this._layers;if(i){var s=e,c=s.width,l=s.height;n.width!=null&&(c=n.width),n.height!=null&&(l=n.height),this.dpr=n.devicePixelRatio||1,s.width=c*this.dpr,s.height=l*this.dpr,this._width=c,this._height=l;var u=new xA(s,this,this.dpr);u.__builtin__=!0,u.initContext(),o[CA]=u,u.zlevel=CA,a.push(CA),this._domRoot=e}else{this._width=hS(e,0,n),this._height=hS(e,1,n);var d=this._domRoot=DA(this._width,this._height);e.appendChild(d)}}return e.prototype.getType=function(){return`canvas`},e.prototype.isSingleCanvas=function(){return this._singleCanvas},e.prototype.getViewportRoot=function(){return this._domRoot},e.prototype.getViewportRootOffset=function(){var e=this.getViewportRoot();if(e)return{offsetLeft:e.offsetLeft||0,offsetTop:e.offsetTop||0}},e.prototype.refresh=function(e){var t=this.storage.getDisplayList(!0),n=this._prevDisplayList,r=this._zlevelList;this._redrawId=Math.random(),this._paintList(t,n,e,this._redrawId);for(var i=0;i<r.length;i++){var a=r[i],o=this._layers[a];if(!o.__builtin__&&o.refresh){var s=i===0?this._backgroundColor:null;o.refresh(s)}}return this._opts.useDirtyRect&&(this._prevDisplayList=t.slice()),this},e.prototype.refreshHover=function(){this._paintHoverList(this.storage.getDisplayList(!1))},e.prototype._paintHoverList=function(e){var t=e.length,n=this._hoverlayer;if(n&&n.clear(),t){for(var r={inHover:!0,viewWidth:this._width,viewHeight:this._height},i,a=0;a<t;a++){var o=e[a];o.__inHover&&(n||(n=this._hoverlayer=this.getLayer(SA)),i||(i=n.ctx,i.save()),WS(i,o,r,a===t-1))}i&&i.restore()}},e.prototype.getHoverLayer=function(){return this.getLayer(SA)},e.prototype.paintOne=function(e,t){US(e,t)},e.prototype._paintList=function(e,t,n,r){if(this._redrawId===r){n=n||!1,this._updateLayerStatus(e);var i=this._doPaintList(e,t,n),a=i.finished,o=i.needsRefreshHover;if(this._needsManuallyCompositing&&this._compositeManually(),o&&this._paintHoverList(e),a)this.eachLayer(function(e){e.afterBrush&&e.afterBrush()});else{var s=this;Vy(function(){s._paintList(e,t,n,r)})}}},e.prototype._compositeManually=function(){var e=this.getLayer(CA).ctx,t=this._domRoot.width,n=this._domRoot.height;e.clearRect(0,0,t,n),this.eachBuiltinLayer(function(r){r.virtual&&e.drawImage(r.dom,0,0,t,n)})},e.prototype._doPaintList=function(e,t,n){for(var r=this,i=[],a=this._opts.useDirtyRect,o=0;o<this._zlevelList.length;o++){var s=this._zlevelList[o],c=this._layers[s];c.__builtin__&&c!==this._hoverlayer&&(c.__dirty||n)&&i.push(c)}for(var l=!0,u=!1,d=function(o){var s=i[o],c=s.ctx,d=a&&s.createRepaintRects(e,t,f._width,f._height),p=n?s.__startIndex:s.__drawIndex,m=!n&&s.incremental&&Date.now,h=m&&Date.now(),g=s.zlevel===f._zlevelList[0]?f._backgroundColor:null;if(s.__startIndex===s.__endIndex)s.clear(!1,g,d);else if(p===s.__startIndex){var _=e[p];(!_.incremental||!_.notClear||n)&&s.clear(!1,g,d)}p===-1&&(console.error(`For some unknown reason. drawIndex is -1`),p=s.__startIndex);var v,y=function(t){var n={inHover:!1,allClipped:!1,prevEl:null,viewWidth:r._width,viewHeight:r._height};for(v=p;v<s.__endIndex;v++){var i=e[v];if(i.__inHover&&(u=!0),r._doPaintEl(i,s,a,t,n,v===s.__endIndex-1),m&&Date.now()-h>15)break}n.prevElClipPaths&&c.restore()};if(d)if(d.length===0)v=s.__endIndex;else for(var b=f.dpr,x=0;x<d.length;++x){var S=d[x];c.save(),c.beginPath(),c.rect(S.x*b,S.y*b,S.width*b,S.height*b),c.clip(),y(S),c.restore()}else c.save(),y(),c.restore();s.__drawIndex=v,s.__drawIndex<s.__endIndex&&(l=!1)},f=this,p=0;p<i.length;p++)d(p);return $.wxa&&W(this._layers,function(e){e&&e.ctx&&e.ctx.draw&&e.ctx.draw()}),{finished:l,needsRefreshHover:u}},e.prototype._doPaintEl=function(e,t,n,r,i,a){var o=t.ctx;if(n){var s=e.getPaintRect();(!r||s&&s.intersect(r))&&(WS(o,e,i,a),e.setPrevPaintRect(s))}else WS(o,e,i,a)},e.prototype.getLayer=function(e,t){this._singleCanvas&&!this._needsManuallyCompositing&&(e=CA);var n=this._layers[e];return n||(n=new xA(`zr_`+e,this,this.dpr),n.zlevel=e,n.__builtin__=!0,this._layerConfig[e]?B(n,this._layerConfig[e],!0):this._layerConfig[e-wA]&&B(n,this._layerConfig[e-wA],!0),t&&(n.virtual=t),this.insertLayer(e,n),n.initContext()),n},e.prototype.insertLayer=function(e,t){var n=this._layers,r=this._zlevelList,i=r.length,a=this._domRoot,o=null,s=-1;if(!n[e]&&EA(t)){if(i>0&&e>r[0]){for(s=0;s<i-1&&!(r[s]<e&&r[s+1]>e);s++);o=n[r[s]]}if(r.splice(s+1,0,e),n[e]=t,!t.virtual)if(o){var c=o.dom;c.nextSibling?a.insertBefore(t.dom,c.nextSibling):a.appendChild(t.dom)}else a.firstChild?a.insertBefore(t.dom,a.firstChild):a.appendChild(t.dom);t.painter||(t.painter=this)}},e.prototype.eachLayer=function(e,t){for(var n=this._zlevelList,r=0;r<n.length;r++){var i=n[r];e.call(t,this._layers[i],i)}},e.prototype.eachBuiltinLayer=function(e,t){for(var n=this._zlevelList,r=0;r<n.length;r++){var i=n[r],a=this._layers[i];a.__builtin__&&e.call(t,a,i)}},e.prototype.eachOtherLayer=function(e,t){for(var n=this._zlevelList,r=0;r<n.length;r++){var i=n[r],a=this._layers[i];a.__builtin__||e.call(t,a,i)}},e.prototype.getLayers=function(){return this._layers},e.prototype._updateLayerStatus=function(e){this.eachBuiltinLayer(function(e,t){e.__dirty=e.__used=!1});function t(e){i&&(i.__endIndex!==e&&(i.__dirty=!0),i.__endIndex=e)}if(this._singleCanvas)for(var n=1;n<e.length;n++){var r=e[n];if(r.zlevel!==e[n-1].zlevel||r.incremental){this._needsManuallyCompositing=!0;break}}var i=null,a=0,o,s;for(s=0;s<e.length;s++){var r=e[s],c=r.zlevel,l=void 0;o!==c&&(o=c,a=0),r.incremental?(l=this.getLayer(c+TA,this._needsManuallyCompositing),l.incremental=!0,a=1):l=this.getLayer(c+(a>0?wA:0),this._needsManuallyCompositing),l.__builtin__||ve(`ZLevel `+c+` has been used by unkown layer `+l.id),l!==i&&(l.__used=!0,l.__startIndex!==s&&(l.__dirty=!0),l.__startIndex=s,l.incremental?l.__drawIndex=-1:l.__drawIndex=s,t(s),i=l),r.__dirty&_i&&!r.__inHover&&(l.__dirty=!0,l.incremental&&l.__drawIndex<0&&(l.__drawIndex=s))}t(s),this.eachBuiltinLayer(function(e,t){!e.__used&&e.getElementCount()>0&&(e.__dirty=!0,e.__startIndex=e.__endIndex=e.__drawIndex=0),e.__dirty&&e.__drawIndex<0&&(e.__drawIndex=e.__startIndex)})},e.prototype.clear=function(){return this.eachBuiltinLayer(this._clearLayer),this},e.prototype._clearLayer=function(e){e.clear()},e.prototype.setBackgroundColor=function(e){this._backgroundColor=e,W(this._layers,function(e){e.setUnpainted()})},e.prototype.configLayer=function(e,t){if(t){var n=this._layerConfig;n[e]?B(n[e],t,!0):n[e]=t;for(var r=0;r<this._zlevelList.length;r++){var i=this._zlevelList[r];if(i===e||i===e+wA){var a=this._layers[i];B(a,n[e],!0)}}}},e.prototype.delLayer=function(e){var t=this._layers,n=this._zlevelList,r=t[e];r&&(r.dom.parentNode.removeChild(r.dom),delete t[e],n.splice(U(n,e),1))},e.prototype.resize=function(e,t){if(this._domRoot.style){var n=this._domRoot;n.style.display=`none`;var r=this._opts,i=this.root;if(e!=null&&(r.width=e),t!=null&&(r.height=t),e=hS(i,0,r),t=hS(i,1,r),n.style.display=``,this._width!==e||t!==this._height){for(var a in n.style.width=e+`px`,n.style.height=t+`px`,this._layers)this._layers.hasOwnProperty(a)&&this._layers[a].resize(e,t);this.refresh(!0)}this._width=e,this._height=t}else{if(e==null||t==null)return;this._width=e,this._height=t,this.getLayer(CA).resize(e,t)}return this},e.prototype.clearLayer=function(e){var t=this._layers[e];t&&t.clear()},e.prototype.dispose=function(){this.root.innerHTML=``,this.root=this.storage=this._domRoot=this._layers=null},e.prototype.getRenderedCanvas=function(e){if(e=e||{},this._singleCanvas&&!this._compositeManually)return this._layers[CA].dom;var t=new xA(`image`,this,e.pixelRatio||this.dpr);t.initContext(),t.clear(!1,e.backgroundColor||this._backgroundColor);var n=t.ctx;if(e.pixelRatio<=this.dpr){this.refresh();var r=t.dom.width,i=t.dom.height;this.eachLayer(function(e){e.__builtin__?n.drawImage(e.dom,0,0,r,i):e.renderToCanvas&&(n.save(),e.renderToCanvas(n),n.restore())})}else for(var a={inHover:!1,viewWidth:this._width,viewHeight:this._height},o=this.storage.getDisplayList(!0),s=0,c=o.length;s<c;s++){var l=o[s];WS(n,l,a,s===c-1)}return t.dom},e.prototype.getWidth=function(){return this._width},e.prototype.getHeight=function(){return this._height},e}();function kA(e){e.registerPainter(`canvas`,OA)}Nw([yA,Kv,kA,pA,SO,Zk,G_,Ck]);const AA={background:`#ffffff`,border:`#dce4e9`,muted:`#5b7186`,surface:`#ffffff`,text:`#0f1e2a`,colors:[`#2f7f55`,`#2563eb`,`#d97706`,`#7c3aed`]},jA=`cf-widget-category-zoom`,MA=.68,NA=e=>({startIndex:0,endIndex:Math.max(0,e-1)}),PA=(e,t)=>{if(t<=0)return NA(0);let n=t-1,r=Math.max(0,Math.min(n,Math.floor(Math.min(e.startIndex,e.endIndex))));return{startIndex:r,endIndex:Math.max(r,Math.min(n,Math.floor(Math.max(e.startIndex,e.endIndex))))}},FA=(e,t,n)=>{let r=PA(e,n);if(n<=2)return NA(n);let i=r.endIndex-r.startIndex+1,a=t===`in`?Math.max(2,Math.floor(i*MA)):Math.min(n,Math.ceil(i/MA));if(a===i)return r;let o=(r.startIndex+r.endIndex)/2,s=n-a,c=Math.max(0,Math.min(s,Math.round(o-(a-1)/2)));return{startIndex:c,endIndex:c+a-1}},IA=(e,t)=>{let n=e.length;if(n===0)return`No chart points`;let r=PA(t,n);if(r.startIndex===0&&r.endIndex===n-1)return`All ${n} ${n===1?`point`:`points`}`;let i=r.endIndex-r.startIndex+1;return`${e[r.startIndex]} – ${e[r.endIndex]} · ${i} of ${n} points`},LA=e=>{let t=e.replaceAll(`_`,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).trim();return t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:`Value`},RA=e=>{let t=new Set,n=[];return e.forEach(e=>{let r=e?.trim();!r||t.has(r)||(t.add(r),n.push(r))}),n},zA=e=>{if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t))return t}return null},BA=e=>{if(e===null)return`null:`;if(e===void 0)return`undefined:`;if(typeof e==`object`)try{return`object:${JSON.stringify(e)}`}catch{return`object:`}return`${typeof e}:${String(e)}`},VA=(e,t)=>t?e.columnMetadata?.find(e=>e.key===t):void 0,HA=(e,t)=>VA(e,t)?.label?.trim()||LA(t),UA=(e,t,n)=>{if(n==null||n===``)return`Not set`;let r=VA(e,t);if(r?.dataType===`boolean`){let e=String(n).trim().toLowerCase();return n===!1||n===0||[`0`,`false`,`no`].includes(e)?`No`:`Yes`}if(r?.dataType===`date`||r?.dataType===`datetime`){let t=new Date(n);if(!Number.isNaN(t.getTime()))try{return new Intl.DateTimeFormat(void 0,{month:`short`,year:`numeric`,timeZone:e.timezone||`UTC`}).format(t)}catch{return new Intl.DateTimeFormat(void 0,{month:`short`,year:`numeric`,timeZone:`UTC`}).format(t)}}return String(n)},WA=(e,t,n,r=!1)=>{if(t?.dataType===`currency`){let i=t.currencyCode||n?.currency?.code;if(i)return new Intl.NumberFormat(void 0,{style:`currency`,currency:i,notation:r&&Math.abs(e)>=1e4?`compact`:`standard`,maximumFractionDigits:2}).format(e)}return t?.dataType===`percent`?new Intl.NumberFormat(void 0,{style:`percent`,maximumFractionDigits:2}).format(Math.abs(e)>1?e/100:e):new Intl.NumberFormat(void 0,{notation:r&&Math.abs(e)>=1e4?`compact`:`standard`,maximumFractionDigits:2}).format(e)},GA=(e,t)=>{if(e.presentation===`table`||e.presentation===`kpi`)return null;if(t)return t;let n=e.chartRecommendation?.type;return n===`line`||n===`bar`||n===`stacked_bar`?n:e.type===`line`||e.type===`bar`||e.type===`stacked_bar`?e.type:null},KA=e=>e.chartRecommendation?.categoryField?.trim()||e.label?.trim()||e.columnMetadata?.find(e=>[`date`,`dimension`,`geography`,`boolean`].includes(e.semanticRole))?.key||e.columns?.[0],qA=e=>e.chartRecommendation?.seriesField?.trim()||e.seriesField?.trim()||e.series?.trim()||void 0,JA=(e,t,n)=>{let r=RA([...e.chartRecommendation?.valueFields??[],...e.valueFields??[],e.value,...e.columnMetadata?.filter(e=>e.semanticRole===`measure`).map(e=>e.key)??[]]),i=new Set([...e.columns??[],...e.columnMetadata?.map(e=>e.key)??[],...Object.keys(e.rows?.[0]??{})]);return r.filter(e=>e!==t&&e!==n&&i.has(e)).filter(t=>e.rows?.some(e=>zA(e[t])!==null))},YA=(e,t,n,r,i)=>{let a=i?` Showing 4 of ${r.length+i} series.`:``;if(t===`line`){let t=n.length-1,i=r.map(n=>{let r=n.values[t];return r==null?null:`${n.name}: ${WA(r,n.valueColumn,e)}`}).filter(e=>!!e);return i.length?`Latest (${n[t]}): ${i.join(`; `)}.${a}`:`No numeric trend values are available.${a}`}let o;return r.forEach(e=>{e.values.forEach((t,r)=>{t===null||o&&t<=o.value||(o={category:n[r]??`Not set`,series:e,value:t})})}),o?`Highest: ${o.category}, ${o.series.name} ${WA(o.value,o.series.valueColumn,e)}.${a}`:`No numeric comparison values are available.${a}`},XA=(e,t)=>{let n=GA(e,t),r=KA(e),i=e.rows??[];if(!n||!r||i.length===0)return null;let a=qA(e),o=JA(e,r,a);if(o.length===0)return null;let s=o.length===1?a:void 0,c=[],l=new Set;i.forEach(t=>{let n=BA(t[r]);l.has(n)||(l.add(n),c.push({key:n,label:UA(e,r,t[r])}))});let u=c.map(e=>e.label),d=0,f;if(s){let t=[],n=new Set;i.forEach(r=>{let i=BA(r[s]);n.has(i)||(n.add(i),t.push({key:i,label:UA(e,s,r[s])}))});let a=t.slice(0,4);d=Math.max(0,t.length-a.length);let l=o[0];f=a.map(t=>{let n=new Map;return i.forEach(e=>{if(BA(e[s])!==t.key)return;let i=BA(e[r]);n.has(i)||n.set(i,zA(e[l]))}),{field:l,name:t.label,values:c.map(e=>n.get(e.key)??null),valueColumn:VA(e,l)}})}else d=Math.max(0,o.length-4),f=o.slice(0,4).map(t=>({field:t,name:HA(e,t),values:i.map(e=>zA(e[t])),valueColumn:VA(e,t)}));if(f.length===0)return null;let p=HA(e,r),m=`Values`;return s?m=HA(e,o[0]):f.length===1&&(m=f[0].name),{type:n,title:e.title?.trim()||`${m} by ${p}`,xAxisTitle:p,yAxisTitle:m,categories:u,series:f,omittedSeriesCount:d,summary:YA(e,n,u,f,d)}},ZA=e=>{if(e.presentation===`table`||e.presentation===`kpi`)return[];let t=XA(e);if(!t)return[];let n=[{type:`line`,label:`Line`},{type:`bar`,label:`Bar`}];return t.series.length>1&&n.push({type:`stacked_bar`,label:`Stacked bar`}),n},QA=(e,{expanded:t=!1,reducedMotion:n=!1,theme:r=AA,zoomWindow:i=NA(e.categories.length)}={})=>{let a=e.series.length>1,o=e.type===`stacked_bar`,s=e.categories.length>2,c=PA(i,e.categories.length);return{animation:!n,animationDuration:n?0:260,aria:{enabled:!0,decal:{show:!0},label:{description:`${e.title}. ${e.summary}`}},backgroundColor:`transparent`,color:r.colors,textStyle:{color:r.text,fontFamily:`inherit`},grid:{top:a?t?48:42:14,right:12,bottom:t?18:10,left:10,containLabel:!0},legend:{show:a,type:`scroll`,top:0,left:`center`,itemWidth:12,itemHeight:8,textStyle:{color:r.muted,fontSize:t?11:10}},tooltip:{trigger:`axis`,triggerOn:`mousemove|click`,confine:!0,backgroundColor:r.surface,borderColor:r.border,borderWidth:1,textStyle:{color:r.text,fontSize:12},axisPointer:{type:`line`,lineStyle:{color:r.muted,opacity:.5}}},dataZoom:s?[{id:jA,type:`inside`,xAxisIndex:0,startValue:c.startIndex,endValue:c.endIndex,minValueSpan:1,filterMode:`filter`,disabled:!0}]:void 0,xAxis:{type:`category`,data:e.categories,name:e.xAxisTitle,nameLocation:`middle`,nameGap:t?38:32,nameTextStyle:{color:r.muted,fontSize:t?11:10},axisLine:{lineStyle:{color:r.border}},axisTick:{show:!1},axisLabel:{color:r.muted,fontSize:t?11:9,hideOverlap:!0,interval:`auto`,rotate:!t&&e.categories.length>5?28:0,formatter:e=>e.length>(t?18:11)?`${e.slice(0,t?16:9)}…`:e}},yAxis:{type:`value`,name:e.yAxisTitle,nameLocation:`middle`,nameGap:t?52:44,nameTextStyle:{color:r.muted,fontSize:t?11:10},axisLabel:{color:r.muted,fontSize:t?11:9,formatter:t=>WA(t,e.series[0]?.valueColumn,void 0,!0)},axisLine:{show:!1},axisTick:{show:!1},splitNumber:4,splitLine:{lineStyle:{color:r.border,opacity:.75}}},series:e.series.map(n=>({type:e.type===`line`?`line`:`bar`,name:n.name,data:n.values,stack:o?`total`:void 0,connectNulls:!1,showSymbol:e.type===`line`&&e.categories.length<=18,symbol:`circle`,symbolSize:t?7:6,smooth:!1,maxBarWidth:t?38:28,lineStyle:e.type===`line`?{width:t?3:2.5}:void 0,itemStyle:e.type===`line`?{borderColor:r.background,borderWidth:2}:{borderRadius:o?0:[4,4,0,0]},emphasis:{focus:`series`},tooltip:{valueFormatter:e=>WA(e,n.valueColumn)}}))}},$A=e=>{let t=getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n,r=n(`--cf-accent`,AA.colors[0]);return{background:n(`--cf-bg`,AA.background),border:n(`--cf-border`,AA.border),muted:n(`--cf-muted`,AA.muted),surface:n(`--cf-surface`,AA.surface),text:n(`--cf-text`,AA.text),colors:[r,`#2563eb`,`#d97706`,`#7c3aed`]}},ej=({model:e,expanded:t=!1})=>{let n=a(null),i=a(null),[u,d]=o(()=>({model:e,window:NA(e.categories.length)})),[f,p]=o(!1),m=u.model===e?PA(u.window,e.categories.length):NA(e.categories.length),h=a(m);h.current=m;let g=t=>{let n=PA(t,e.categories.length);h.current=n,d({model:e,window:n}),i.current?.dispatchAction({type:`dataZoom`,dataZoomId:jA,startValue:n.startIndex,endValue:n.endIndex})};r(()=>{let e=n.current;if(!(!e||typeof navigator<`u`&&navigator.userAgent.toLowerCase().includes(`jsdom`)))try{let t=mw(e,null,{renderer:`canvas`,devicePixelRatio:Math.min(window.devicePixelRatio||1,2)});i.current=t;let n=()=>t.resize(),r=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return r?.observe(e),r||window.addEventListener(`resize`,n,{passive:!0}),()=>{r?.disconnect(),r||window.removeEventListener(`resize`,n),t.dispose(),i.current=null}}catch{p(!0);return}},[]),r(()=>{let r=n.current,a=i.current;if(!r||!a)return;let o=typeof matchMedia<`u`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;a.setOption(QA(e,{expanded:t,reducedMotion:o,theme:$A(r),zoomWindow:h.current}),{lazyUpdate:!0,notMerge:!0}),a.resize()},[t,e]);let _=!f&&e.categories.length>2,v=m.endIndex-m.startIndex+1,y=m.startIndex===0&&m.endIndex===e.categories.length-1,b=_&&v>2,x=_&&!y;return l(s,{children:[c(`div`,{ref:n,class:`cf-analytics-echart${t?` is-expanded`:``}`,role:`img`,"aria-label":`${e.title}. ${e.summary}`,"data-chart-status":f?`fallback`:`ready`,children:f?c(`span`,{class:`cf-analytics-echart__fallback`,children:e.summary}):null}),_?l(`div`,{class:`cf-analytics-zoom`,children:[c(`span`,{class:`cf-analytics-zoom__range`,"aria-live":`polite`,"aria-atomic":`true`,children:IA(e.categories,m)}),l(`div`,{class:`cf-analytics-zoom__controls`,role:`group`,"aria-label":`Chart zoom controls`,children:[c(`button`,{type:`button`,"aria-label":`Zoom out chart`,title:`Zoom out`,disabled:!x,onClick:()=>g(FA(h.current,`out`,e.categories.length)),children:`−`}),c(`button`,{type:`button`,class:`cf-analytics-zoom__reset`,"aria-label":`Reset chart zoom`,title:`Reset zoom`,disabled:y,onClick:()=>g(NA(e.categories.length)),children:`Reset`}),c(`button`,{type:`button`,"aria-label":`Zoom in chart`,title:`Zoom in`,disabled:!b,onClick:()=>g(FA(h.current,`in`,e.categories.length)),children:`+`})]})]}):null]})},tj=e=>{let t=e.replaceAll(`_`,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).trim();return t?`${t.charAt(0).toUpperCase()}${t.slice(1)}`:`Value`},nj=(e,t)=>(t?.length?t:Object.keys(e[0]??{})).map(e=>typeof e==`string`?{key:e,label:tj(e)}:{...e,label:e.label?.trim()||tj(e.key)}),rj=(e,t,n)=>{if(e==null||e===``)return`—`;if((n?.dataType===`date`||n?.dataType===`datetime`)&&typeof e==`string`){let r=new Date(e);if(!Number.isNaN(r.getTime()))return new Intl.DateTimeFormat(t,{dateStyle:`medium`,...n.dataType===`datetime`?{timeStyle:`short`}:{}}).format(r)}return n?.dataType===`currency`&&typeof e==`number`?new Intl.NumberFormat(t,{style:`currency`,currency:n.currencyCode||`USD`,maximumFractionDigits:2}).format(e):typeof e==`number`&&Number.isFinite(e)?new Intl.NumberFormat(t,{maximumFractionDigits:4}).format(e):typeof e==`boolean`?e?`Yes`:`No`:String(e)},ij=e=>{let t=String(e??``);return/[",\r\n]/.test(t)?`"${t.replaceAll(`"`,`""`)}"`:t},aj=(e,t)=>{let n=nj(e,t);return[n.map(e=>ij(e.label)).join(`,`),...e.map(e=>n.map(t=>ij(e[t.key])).join(`,`))].join(`\r
|
|
23
|
-
`)},oj=({rows:e,columns:t,maxRows:n=6,locale:r,expanded:i=!1,classNames:a,emptyLabel:o=`No rows returned.`})=>{let u=nj(e,t),d=i?e:e.slice(0,Math.max(1,n));return e.length===0||u.length===0?c(`div`,{class:a?.note,children:o}):l(s,{children:[c(`div`,{class:a?.wrap,role:`region`,"aria-label":`Result table with ${e.length} ${e.length===1?`row`:`rows`}`,tabIndex:0,children:l(`table`,{class:a?.table,children:[l(`caption`,{style:`position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)`,children:[`Result table with `,e.length,` `,e.length===1?`row`:`rows`]}),c(`thead`,{children:c(`tr`,{children:u.map(e=>c(`th`,{scope:`col`,children:e.label},e.key))})}),c(`tbody`,{children:d.map((e,t)=>c(`tr`,{children:u.map(t=>c(`td`,{children:rj(e[t.key],r,t)},t.key))},t))})]})}),!i&&e.length>d.length?l(`div`,{class:a?.note,children:[`Showing `,d.length,` of `,e.length,` rows. Expand to view all rows.`]}):null]})},sj=({rows:e,columns:t,maxRows:n=100,locale:a,expanded:s=!1,classPrefix:u=`cr`,pageSize:d=10})=>{let f=i(()=>nj(e,t),[t,e]),p=f.map(e=>e.key).join(`\0`),[m,h]=o(()=>f.map(e=>e.key)),[g,_]=o(``),[v,y]=o(),[b,x]=o(`asc`),[S,C]=o([]),[w,T]=o(`table`),[E,D]=o(1),[O,k]=o(d);r(()=>{h(f.map(e=>e.key)),y(void 0),C([]),D(1)},[p]);let A=f.filter(e=>m.includes(e.key)),j=i(()=>{let t=g.toLocaleLowerCase(a),n=e.map((e,t)=>({row:e,index:t})).filter(({row:e})=>A.some(n=>rj(e[n.key],a,n).toLocaleLowerCase(a).includes(t)));return v?n.sort((e,t)=>{let n=e.row[v],r=t.row[v],i=typeof n==`number`?n:NaN,o=typeof r==`number`?r:NaN,s=!Number.isNaN(i)&&!Number.isNaN(o)?i-o:String(n??``).localeCompare(String(r??``),a,{numeric:!0,sensitivity:`base`});return b===`asc`?s:-s}):n},[A,a,g,e,b,v]),M=j.slice(0,Math.max(1,n)),N=Math.max(1,Math.ceil(M.length/O)),P=Math.min(E,N),F=s?M:M.slice((P-1)*O,P*O),ee=F.length>0&&F.every(({index:e})=>S.includes(e)),I=e=>`${u}-${e}`;if(e.length===0||f.length===0)return c(`div`,{class:I(`table-note`),children:`No rows returned.`});let te=e=>{let t=new Set(F.map(({index:e})=>e));C(n=>e?[...new Set([...n,...t])]:n.filter(e=>!t.has(e)))};return l(`section`,{class:I(`data-table`),children:[l(`div`,{class:I(`table-fields`),children:[c(`strong`,{children:`Fields`}),c(`div`,{class:I(`field-list`),children:f.map(e=>c(`span`,{class:I(`field-chip`),children:e.label},e.key))}),l(`span`,{class:I(`table-field-count`),children:[e.length.toLocaleString(a),` rows`]})]}),l(`div`,{class:I(`table-controls`),children:[l(`label`,{class:I(`table-search`),children:[c(`span`,{"aria-hidden":`true`,children:`⌕`}),c(`input`,{type:`search`,value:g,placeholder:`Search this result...`,"aria-label":`Search this result`,onInput:e=>{_(e.currentTarget.value.trim()),D(1)}})]}),c(`div`,{class:I(`table-modes`),role:`group`,"aria-label":`Table display mode`,children:[`table`,`matrix`].map(e=>c(`button`,{type:`button`,class:`${I(`segment`)}${w===e?` is-active`:``}`,"aria-pressed":w===e,onClick:()=>T(e),children:e===`table`?`Table`:`Matrix`},e))})]}),c(`div`,{class:I(`table-column-bar`),children:l(`details`,{class:I(`column-picker`),children:[c(`summary`,{children:`Columns`}),c(`div`,{class:I(`column-menu`),children:f.map(e=>l(`label`,{children:[c(`input`,{type:`checkbox`,checked:m.includes(e.key),onChange:t=>{let n=t.currentTarget.checked;h(t=>n?[...new Set([...t,e.key])]:t.length>1?t.filter(t=>t!==e.key):t)}}),c(`span`,{children:e.label})]},e.key))})]})}),c(`div`,{class:I(`table-wrap`),role:`region`,"aria-label":`Scrollable result table`,tabIndex:0,children:l(`table`,{class:`${I(`table`)}${w===`matrix`?` is-matrix`:``}`,children:[l(`caption`,{class:I(`visually-hidden`),children:[`Result table with `,j.length,` `,j.length===1?`row`:`rows`]}),c(`thead`,{children:l(`tr`,{children:[c(`th`,{class:I(`select-cell`),children:c(`input`,{type:`checkbox`,"aria-label":`Select all visible rows`,checked:ee,onChange:e=>te(e.currentTarget.checked)})}),A.map(e=>c(`th`,{scope:`col`,children:l(`button`,{type:`button`,class:I(`table-sort`),"aria-label":`Sort by ${e.label}`,onClick:()=>{v===e.key?x(e=>e===`asc`?`desc`:`asc`):(y(e.key),x(`asc`)),D(1)},children:[c(`span`,{children:e.label}),c(`span`,{class:I(`sort-direction`),"aria-hidden":`true`,children:v===e.key?b===`asc`?`↑`:`↓`:`↕`})]})},e.key))]})}),c(`tbody`,{children:F.map(({row:e,index:t})=>l(`tr`,{class:S.includes(t)?`is-selected`:void 0,children:[c(`td`,{class:I(`select-cell`),children:c(`input`,{type:`checkbox`,"aria-label":`Select row ${t+1}`,checked:S.includes(t),onChange:e=>C(n=>e.currentTarget.checked?[...new Set([...n,t])]:n.filter(e=>e!==t))})}),A.map(t=>c(`td`,{children:rj(e[t.key],a,t)},t.key))]},t))})]})}),l(`div`,{class:I(`table-summary`),children:[c(`span`,{children:M.length?`${((P-1)*O+1).toLocaleString(a)}-${Math.min(P*O,M.length).toLocaleString(a)} of ${j.length.toLocaleString(a)}`:`0 of ${j.length.toLocaleString(a)}`}),s?c(`span`,{children:e.length>n?`First ${n.toLocaleString(a)} rows available`:`All returned rows loaded`}):l(`div`,{class:I(`table-pagination`),"aria-label":`Table pagination`,children:[l(`label`,{children:[c(`span`,{children:`Rows`}),c(`select`,{"aria-label":`Rows per page`,value:O,onChange:e=>{k(Number(e.currentTarget.value)),D(1)},children:[10,25,50].map(e=>c(`option`,{value:e,children:e},e))})]}),c(`button`,{type:`button`,"aria-label":`Previous page`,disabled:P<=1,onClick:()=>D(e=>Math.max(1,e-1)),children:`‹`}),l(`span`,{children:[P,` / `,N]}),c(`button`,{type:`button`,"aria-label":`Next page`,disabled:P>=N,onClick:()=>D(e=>Math.min(N,e+1)),children:`›`})]})]})]})},cj={openChat:`Open chat`,closeChat:`Close chat`,muteSounds:`Mute sounds`,unmuteSounds:`Unmute sounds`,statusOnline:`Online · replies instantly`,statusOffline:`Away · leave a message`,composerPlaceholder:`Type your message…`,send:`Send message`,emoji:`Emoji`,gifs:`GIFs`,attachFile:`Attach a file`,recordVoice:`Record a voice message`,stopRecording:`Stop recording`,stop:`Stop`,copy:`Copy`,copied:`Copied`,retry:`Retry`,clearChat:`Clear conversation`,clearChatConfirm:`Clear this conversation?`,clearChatConfirmBody:`This clears the messages on this device and starts a fresh chat.`,clearConfirmCta:`Clear chat`,endChat:`End conversation`,endChatConfirm:`End this conversation?`,endChatConfirmBody:`You won't be able to send more messages in this chat, but you can start a new one anytime.`,endConfirmCta:`End conversation`,conversationEnded:`This conversation has ended.`,startNewChat:`Start a new conversation`,pastConversations:`Past conversations`,viewingPast:`Viewing a past conversation (read-only)`,backToChat:`Back to current chat`,historyEnded:`ended`,feedbackHelpful:`Helpful`,feedbackNotHelpful:`Not helpful`,feedbackThanks:`Thanks for the feedback`,csatPrompt:`How was this chat?`,feedbackCommentPlaceholder:`What went wrong? (optional)`,feedbackSend:`Send`,cancel:`Cancel`,newMessages:`New messages`,poweredBy:`Powered by`,searchGifs:`Search GIFs…`,searchingGifs:`Searching…`,noGifs:`No GIFs found`,assistantTyping:`Assistant is typing`,emptyReply:`Sorry, I couldn't generate a reply.`,errorGeneric:`Something went wrong reaching the assistant. Please try again.`,errorRateLimit:`You’re sending messages a little fast — give it a second and try again.`,attaching:`Reading file…`,attachTooLarge:`That file is too large (max 8 MB).`,attachFailed:`Couldn’t read that file — try another.`,handoffTitle:`Want our team to follow up?`,handoffName:`Name (optional)`,handoffEmail:`Your email`,handoffNotify:`Notify the team`,sending:`Sending…`,handoffShared:`I’ve shared this with our team — they’ll get back to you at {email}.`,formThanks:`Thanks! We’ll be in touch.`,formError:`Something went wrong — please try again.`,bookingPickTime:`What time works best?`,bookingDuration:`30-minute demo`,bookingRequested:`Requested for {when} — we’ll confirm by email.`,bookingConfirmed:`You’re booked for {when}! A calendar invite is on its way. 📅`,bookingSlotTaken:`That time was just taken — please pick another.`,bookingViaProvider:`Pick a time that works for you on {provider}.`,bookingOpenScheduler:`Open the scheduler`,bookingLinkOpened:`Opening the scheduler — pick a time that suits you. 📅`,bookingMeetingLink:`Meeting link`,previewReply:`👋 This is a preview — replies here are samples. Publish the widget on your site to chat with the live AI.`,previewActionNote:`Preview — nothing was actually sent. This works for real once you publish.`,previewBanner:`Preview — sample replies, no AI`},lj=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??``),uj=e=>e?{...cj,...e}:cj,dj=e(cj),fj=dj.Provider,pj=()=>n(dj),mj=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\(https?:\/\/[^\s)]+\))|(https?:\/\/[^\s)]+)/g,hj=e=>e.replace(/([^\n])\s+((?:[-*•]|\d+\.)\s+)(?=(?:\*\*[^*\n]{1,80}\*\*|[A-Z][A-Za-z0-9/& -]{1,50}:))/g,`$1
|
|
24
|
-
$2`),
|
|
23
|
+
`)},oj=({rows:e,columns:t,maxRows:n=6,locale:r,expanded:i=!1,classNames:a,emptyLabel:o=`No rows returned.`})=>{let u=nj(e,t),d=i?e:e.slice(0,Math.max(1,n));return e.length===0||u.length===0?c(`div`,{class:a?.note,children:o}):l(s,{children:[c(`div`,{class:a?.wrap,role:`region`,"aria-label":`Result table with ${e.length} ${e.length===1?`row`:`rows`}`,tabIndex:0,children:l(`table`,{class:a?.table,children:[l(`caption`,{style:`position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)`,children:[`Result table with `,e.length,` `,e.length===1?`row`:`rows`]}),c(`thead`,{children:c(`tr`,{children:u.map(e=>c(`th`,{scope:`col`,children:e.label},e.key))})}),c(`tbody`,{children:d.map((e,t)=>c(`tr`,{children:u.map(t=>c(`td`,{children:rj(e[t.key],r,t)},t.key))},t))})]})}),!i&&e.length>d.length?l(`div`,{class:a?.note,children:[`Showing `,d.length,` of `,e.length,` rows. Expand to view all rows.`]}):null]})},sj=({rows:e,columns:t,maxRows:n=100,locale:a,expanded:s=!1,classPrefix:u=`cr`,pageSize:d=10})=>{let f=i(()=>nj(e,t),[t,e]),p=f.map(e=>e.key).join(`\0`),[m,h]=o(()=>f.map(e=>e.key)),[g,_]=o(``),[v,y]=o(),[b,x]=o(`asc`),[S,C]=o([]),[w,T]=o(`table`),[E,D]=o(1),[O,k]=o(d);r(()=>{h(f.map(e=>e.key)),y(void 0),C([]),D(1)},[p]);let A=f.filter(e=>m.includes(e.key)),j=i(()=>{let t=g.toLocaleLowerCase(a),n=e.map((e,t)=>({row:e,index:t})).filter(({row:e})=>A.some(n=>rj(e[n.key],a,n).toLocaleLowerCase(a).includes(t)));return v?n.sort((e,t)=>{let n=e.row[v],r=t.row[v],i=typeof n==`number`?n:NaN,o=typeof r==`number`?r:NaN,s=!Number.isNaN(i)&&!Number.isNaN(o)?i-o:String(n??``).localeCompare(String(r??``),a,{numeric:!0,sensitivity:`base`});return b===`asc`?s:-s}):n},[A,a,g,e,b,v]),M=j.slice(0,Math.max(1,n)),N=Math.max(1,Math.ceil(M.length/O)),P=Math.min(E,N),F=s?M:M.slice((P-1)*O,P*O),ee=F.length>0&&F.every(({index:e})=>S.includes(e)),I=e=>`${u}-${e}`;if(e.length===0||f.length===0)return c(`div`,{class:I(`table-note`),children:`No rows returned.`});let te=e=>{let t=new Set(F.map(({index:e})=>e));C(n=>e?[...new Set([...n,...t])]:n.filter(e=>!t.has(e)))};return l(`section`,{class:I(`data-table`),children:[l(`div`,{class:I(`table-fields`),children:[c(`strong`,{children:`Fields`}),c(`div`,{class:I(`field-list`),children:f.map(e=>c(`span`,{class:I(`field-chip`),children:e.label},e.key))}),l(`span`,{class:I(`table-field-count`),children:[e.length.toLocaleString(a),` rows`]})]}),l(`div`,{class:I(`table-controls`),children:[l(`label`,{class:I(`table-search`),children:[c(`span`,{"aria-hidden":`true`,children:`⌕`}),c(`input`,{type:`search`,value:g,placeholder:`Search this result...`,"aria-label":`Search this result`,onInput:e=>{_(e.currentTarget.value.trim()),D(1)}})]}),c(`div`,{class:I(`table-modes`),role:`group`,"aria-label":`Table display mode`,children:[`table`,`matrix`].map(e=>c(`button`,{type:`button`,class:`${I(`segment`)}${w===e?` is-active`:``}`,"aria-pressed":w===e,onClick:()=>T(e),children:e===`table`?`Table`:`Matrix`},e))})]}),c(`div`,{class:I(`table-column-bar`),children:l(`details`,{class:I(`column-picker`),children:[c(`summary`,{children:`Columns`}),c(`div`,{class:I(`column-menu`),children:f.map(e=>l(`label`,{children:[c(`input`,{type:`checkbox`,checked:m.includes(e.key),onChange:t=>{let n=t.currentTarget.checked;h(t=>n?[...new Set([...t,e.key])]:t.length>1?t.filter(t=>t!==e.key):t)}}),c(`span`,{children:e.label})]},e.key))})]})}),c(`div`,{class:I(`table-wrap`),role:`region`,"aria-label":`Scrollable result table`,tabIndex:0,children:l(`table`,{class:`${I(`table`)}${w===`matrix`?` is-matrix`:``}`,children:[l(`caption`,{class:I(`visually-hidden`),children:[`Result table with `,j.length,` `,j.length===1?`row`:`rows`]}),c(`thead`,{children:l(`tr`,{children:[c(`th`,{class:I(`select-cell`),children:c(`input`,{type:`checkbox`,"aria-label":`Select all visible rows`,checked:ee,onChange:e=>te(e.currentTarget.checked)})}),A.map(e=>c(`th`,{scope:`col`,children:l(`button`,{type:`button`,class:I(`table-sort`),"aria-label":`Sort by ${e.label}`,onClick:()=>{v===e.key?x(e=>e===`asc`?`desc`:`asc`):(y(e.key),x(`asc`)),D(1)},children:[c(`span`,{children:e.label}),c(`span`,{class:I(`sort-direction`),"aria-hidden":`true`,children:v===e.key?b===`asc`?`↑`:`↓`:`↕`})]})},e.key))]})}),c(`tbody`,{children:F.map(({row:e,index:t})=>l(`tr`,{class:S.includes(t)?`is-selected`:void 0,children:[c(`td`,{class:I(`select-cell`),children:c(`input`,{type:`checkbox`,"aria-label":`Select row ${t+1}`,checked:S.includes(t),onChange:e=>C(n=>e.currentTarget.checked?[...new Set([...n,t])]:n.filter(e=>e!==t))})}),A.map(t=>c(`td`,{children:rj(e[t.key],a,t)},t.key))]},t))})]})}),l(`div`,{class:I(`table-summary`),children:[c(`span`,{children:M.length?`${((P-1)*O+1).toLocaleString(a)}-${Math.min(P*O,M.length).toLocaleString(a)} of ${j.length.toLocaleString(a)}`:`0 of ${j.length.toLocaleString(a)}`}),s?c(`span`,{children:e.length>n?`First ${n.toLocaleString(a)} rows available`:`All returned rows loaded`}):l(`div`,{class:I(`table-pagination`),"aria-label":`Table pagination`,children:[l(`label`,{children:[c(`span`,{children:`Rows`}),c(`select`,{"aria-label":`Rows per page`,value:O,onChange:e=>{k(Number(e.currentTarget.value)),D(1)},children:[10,25,50].map(e=>c(`option`,{value:e,children:e},e))})]}),c(`button`,{type:`button`,"aria-label":`Previous page`,disabled:P<=1,onClick:()=>D(e=>Math.max(1,e-1)),children:`‹`}),l(`span`,{children:[P,` / `,N]}),c(`button`,{type:`button`,"aria-label":`Next page`,disabled:P>=N,onClick:()=>D(e=>Math.min(N,e+1)),children:`›`})]})]})]})},cj=[`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`,`audio/ogg`],lj=()=>{if(typeof navigator>`u`||!navigator.mediaDevices?.getSupportedConstraints)return{};try{return navigator.mediaDevices.getSupportedConstraints()}catch{return{}}},uj=(e=``,t=lj())=>{let n={...e?{deviceId:{exact:e}}:{}};return t.echoCancellation&&(n.echoCancellation={ideal:!0}),t.noiseSuppression&&(n.noiseSuppression={ideal:!0}),t.autoGainControl&&(n.autoGainControl={ideal:!0}),t.channelCount&&(n.channelCount={ideal:1}),t.voiceIsolation&&(n.voiceIsolation={ideal:!0}),n},dj=(e={})=>{let t=Math.max(2,e.calibrationSamples??6),n=Math.max(t,e.ambientWindowSamples??72),r=Math.min(.5,Math.max(0,e.ambientPercentile??.2)),i=Math.min(1,Math.max(.01,e.smoothing??.22)),a=Math.max(2**-52,e.minimumNoiseFloor??5e-4),o=Math.max(1.1,e.speechToNoiseRatio??2.7),s=Math.min(o,Math.max(1,e.quietToNoiseRatio??1.55)),c=Math.max(250,e.minimumEndSilenceMs??650),l=Math.max(c,e.maximumEndSilenceMs??1100),u=[],d=a,f=d*o,p=0;return{observe:e=>{let m=Number.isFinite(e)?Math.max(0,e):0;if(u.length<t||m<=f){u.push(m),u.length>n&&u.shift();let e=[...u].sort((e,t)=>e-t),t=Math.min(e.length-1,Math.floor((e.length-1)*r)),o=Math.max(a,e[t]??a);d+=(o-d)*i}f=d*o;let h=d*s,g=u.length>=t,_=g&&m>=f;_&&(p=Math.max(p,m/Math.max(d,a)));let v=Math.min(1,Math.max(0,(p-o)/o)),y=Math.round(l-(l-c)*v);return{speech:_,quiet:g&&m<=h,calibrated:g,noiseFloor:d,speechThreshold:f,quietThreshold:h,endOfSpeechDelayMs:y}},reset:()=>{u=[],d=a,f=d*o,p=0}}},fj=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result??``).split(`,`)[1]??``),r.onerror=()=>n(r.error),r.readAsDataURL(e)}),pj=e=>{let t=globalThis.MediaRecorder;if(typeof t?.isTypeSupported==`function`){for(let n of cj)if(t.isTypeSupported(n))try{return new t(e,{mimeType:n})}catch{}}return new t(e)},mj=e=>{if(!(!e||e.state!==`recording`)){try{e.requestData()}catch{}e.stop()}},hj={openChat:`Open chat`,closeChat:`Close chat`,closeHistory:`Close conversation history`,unreadMessage:`1 unread message`,unreadMessages:`{count} unread messages`,muteSounds:`Mute sounds`,unmuteSounds:`Unmute sounds`,statusOnline:`Online · replies instantly`,statusOffline:`Away · leave a message`,liveSupport:`Live support`,waitingForTeam:`Waiting for the team`,assistantName:`Assistant`,chatName:`Chat`,welcomeLabel:`{name} welcome`,welcomeEyebrow:`Ready when you are`,welcomePrompt:`Ask a question, leave a message, or book a demo.`,agentTyping:`{name} is typing…`,expandedAnalyticsResult:`Expanded analytics result`,privacyAndData:`Privacy and local data`,muteMicrophone:`Mute microphone`,unmuteMicrophone:`Unmute microphone`,chooseMicrophone:`Choose microphone`,defaultMicrophone:`Default microphone`,microphone:`Microphone`,talkNow:`Talk now`,expandView:`Expand view`,exitExpandedView:`Exit expanded view`,minimizeVoiceChat:`Minimize voice chat`,endVoiceChat:`End voice chat`,restoreVoiceChat:`Restore voice chat`,reopenVoiceChat:`Reopen voice chat with {name}`,voiceConnecting:`Connecting…`,voiceListening:`Listening…`,voiceProcessing:`Thinking…`,voiceSpeaking:`Speaking…`,voiceNoise:`Background noise detected`,voiceMisunderstood:`I could not understand that audio`,voiceDenied:`Microphone access is unavailable`,composerPlaceholder:`Type your message…`,send:`Send message`,emoji:`Emoji`,gifs:`GIFs`,attachFile:`Attach a file`,recordVoice:`Record a voice message`,stopRecording:`Stop recording`,actionTestMode:`Test mode`,stop:`Stop`,copy:`Copy`,copied:`Copied`,retry:`Retry`,clearChat:`Clear conversation`,clearChatConfirm:`Clear this conversation?`,clearChatConfirmBody:`This clears the messages on this device and starts a fresh chat.`,clearConfirmCta:`Clear chat`,endChat:`End conversation`,endChatConfirm:`End this conversation?`,endChatConfirmBody:`You won't be able to send more messages in this chat, but you can start a new one anytime.`,endConfirmCta:`End conversation`,conversationEnded:`This conversation has ended.`,startNewChat:`Start a new conversation`,pastConversations:`Past conversations`,viewingPast:`Viewing a past conversation (read-only)`,backToChat:`Back to current chat`,historyEnded:`ended`,feedbackHelpful:`Helpful`,feedbackNotHelpful:`Not helpful`,feedbackThanks:`Thanks for the feedback`,csatPrompt:`How was this chat?`,feedbackCommentPlaceholder:`What went wrong? (optional)`,feedbackSend:`Send`,cancel:`Cancel`,newMessages:`New messages`,poweredBy:`Powered by`,searchGifs:`Search GIFs…`,searchingGifs:`Searching…`,noGifs:`No GIFs found`,assistantTyping:`Assistant is typing`,emptyReply:`Sorry, I couldn't generate a reply.`,errorGeneric:`Something went wrong reaching the assistant. Please try again.`,errorRateLimit:`You’re sending messages a little fast — give it a second and try again.`,attaching:`Reading file…`,attachTooLarge:`That file is too large (max 8 MB).`,attachFailed:`Couldn’t read that file — try another.`,removeAttachment:`Remove attachment`,dropFileHere:`Drop the file here`,clearDeviceData:`Clear conversations from this device`,clearDeviceDataBody:`This removes locally stored conversations and visitor details from this browser. It cannot be undone.`,clearDeviceDataCta:`Clear this device`,handoffTitle:`Want our team to follow up?`,handoffName:`Name (optional)`,handoffEmail:`Your email`,handoffNotify:`Notify the team`,sending:`Sending…`,handoffShared:`I’ve shared this with our team — they’ll get back to you at {email}.`,formThanks:`Thanks! We’ll be in touch.`,formError:`Something went wrong — please try again.`,actionContactOptions:`Contact options`,actionGetInTouch:`Get in touch`,actionMore:`+{count} more`,actionNeedHelp:`Need help?`,actionChoose:`Choose what you want to do`,actionFooter:`We’ll ask for your full name and the best email or phone so the team can reach you.`,actionCategorySupport:`Support`,actionCategorySales:`Talk to sales`,actionCategoryMarketing:`Stay in touch`,actionClose:`Close`,actionAs:`as {identity}`,bookingPickTime:`What time works best?`,bookingPickDay:`Pick a day`,bookingPickTimeLabel:`Pick a time`,bookingDuration:`{count}-minute demo`,bookingTimezone:`Times shown in {timezone}`,bookingSchedulerFallback:`the scheduler`,bookingCheckingAvailability:`Checking calendar availability…`,bookingNoSlots:`No available times were found in this booking window.`,bookingAvailabilityUnavailable:`Calendar availability is temporarily unavailable. Please try again shortly.`,bookingEarlierToday:`Earlier today`,bookingCalendarBusy:`Busy on the calendar`,bookingAlreadyBooked:`Already booked`,bookingNotOffered:`Not offered by the calendar`,bookingRequested:`Requested for {when} — we’ll confirm by email.`,bookingConfirmed:`You’re booked for {when}! A calendar invite is on its way. 📅`,bookingSlotTaken:`That time was just taken — please pick another.`,bookingViaProvider:`Pick a time that works for you on {provider}.`,bookingOpenScheduler:`Open the scheduler`,bookingLinkOpened:`Opening the scheduler — pick a time that suits you. 📅`,bookingMeetingLink:`Meeting link`,previewReply:`👋 This is a preview — replies here are samples. Publish the widget on your site to chat with the live AI.`,previewActionNote:`Preview — nothing was actually sent. This works for real once you publish.`,previewBanner:`Preview — sample replies, no AI`},gj=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??``),_j=e=>e?{...hj,...e}:hj,vj=e(hj),yj=vj.Provider,bj=()=>n(vj),xj=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\(https?:\/\/[^\s)]+\))|(https?:\/\/[^\s)]+)/g,Sj=e=>e.replace(/([^\n])\s+((?:[-*•]|\d+\.)\s+)(?=(?:\*\*[^*\n]{1,80}\*\*|[A-Z][A-Za-z0-9/& -]{1,50}:))/g,`$1
|
|
24
|
+
$2`),Cj=e=>{let t=[],n=0,r=0,i;for(xj.lastIndex=0;(i=xj.exec(e))!==null;){i.index>n&&t.push(e.slice(n,i.index));let a=i[0];if(a.startsWith("`"))t.push(c(`code`,{class:`cf-md-code`,children:a.slice(1,-1)},r++));else if(a.startsWith(`**`))t.push(c(`strong`,{children:a.slice(2,-2)},r++));else if(a.startsWith(`[`)){let e=/^\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)$/.exec(a),n=e?e[1]:a,i=e?e[2]:`#`;t.push(c(`a`,{href:i,target:`_blank`,rel:`noopener noreferrer nofollow`,children:n},r++))}else t.push(c(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer nofollow`,children:a},r++));n=i.index+a.length}return n<e.length&&t.push(e.slice(n)),t},wj=/^(```|#{1,6}\s|\s*[-*•]\s|\s*\d+\.\s)/,Tj=(e,t,n)=>{let r=`cf-md-h cf-md-h--${Math.min(e,6)}`;return c(e<=2?`h3`:e===3?`h4`:`h5`,{class:r,children:t},n)},Ej=e=>{let t=Sj(e.replace(/\r\n/g,`
|
|
25
25
|
`)).split(`
|
|
26
26
|
`),n=[],r=0,i=0;for(;i<t.length;){let e=t[i];if(e.trim().startsWith("```")){let e=[];for(i++;i<t.length&&!t[i].trim().startsWith("```");)e.push(t[i]),i++;i++,n.push(c(`pre`,{class:`cf-md-pre`,children:c(`code`,{children:e.join(`
|
|
27
|
-
`)})},r++));continue}if(e.trim()===``){i++;continue}let a=/^(#{1,6})\s+(.*)$/.exec(e);if(a){n.push(
|
|
27
|
+
`)})},r++));continue}if(e.trim()===``){i++;continue}let a=/^(#{1,6})\s+(.*)$/.exec(e);if(a){n.push(Tj(a[1].length,Cj(a[2]),r++)),i++;continue}if(/^\s*[-*•]\s+/.test(e)){let e=[];for(;i<t.length&&/^\s*[-*•]\s+/.test(t[i]);)e.push(c(`li`,{children:Cj(t[i].replace(/^\s*[-*•]\s+/,``))},e.length)),i++;n.push(c(`ul`,{class:`cf-md-list`,children:e},r++));continue}if(/^\s*\d+\.\s+/.test(e)){let e=[];for(;i<t.length&&/^\s*\d+\.\s+/.test(t[i]);)e.push(c(`li`,{children:Cj(t[i].replace(/^\s*\d+\.\s+/,``))},e.length)),i++;n.push(c(`ol`,{class:`cf-md-list`,children:e},r++));continue}let o=[e];for(i++;i<t.length&&t[i].trim()!==``&&!wj.test(t[i]);)o.push(t[i]),i++;let s=o.join(` `);if(/:\s*$/.test(s)&&i<t.length&&/^(?:\s*[-*•]\s+|\s*\d+\.\s+)/.test(t[i])){let e=/^(.*[.!?])\s+([^.!?]{2,120}:)$/.exec(s);e&&n.push(c(`p`,{children:Cj(e[1])},r++)),n.push(c(`p`,{class:`cf-md-list-intro`,children:Cj(e?.[2]??s)},r++))}else n.push(c(`p`,{children:Cj(s)},r++))}return n};let Dj=!0,Oj=null;const kj=e=>{Dj=e},Aj=()=>{let e=typeof window<`u`?window.AudioContext??window.webkitAudioContext:void 0;if(!e)return null;if(!Oj)try{Oj=new e}catch{return null}return Oj.state===`suspended`&&Oj.resume(),Oj},jj=(e,t,n,r,i,a)=>{let o=e.createOscillator(),s=e.createGain();o.type=i,o.frequency.setValueAtTime(t,n),o.connect(s),s.connect(e.destination),s.gain.setValueAtTime(1e-4,n),s.gain.exponentialRampToValueAtTime(a,n+.012),s.gain.exponentialRampToValueAtTime(1e-4,n+r),o.start(n),o.stop(n+r+.03)},Mj=e=>{if(!Dj)return;let t=Aj();if(!t)return;let n=t.currentTime;try{e===`open`?(jj(t,523,n,.12,`sine`,.05),jj(t,784,n+.08,.16,`sine`,.05)):e===`send`?jj(t,660,n,.08,`triangle`,.04):e===`receive`&&(jj(t,880,n,.1,`sine`,.045),jj(t,1175,n+.09,.14,`sine`,.045))}catch{}},Nj=(e,t)=>e?.status===429?t.errorRateLimit:t.errorGeneric,Pj=()=>typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),Fj=(e,t)=>{let n=Pj(),r={stage:e,durationMs:Math.max(0,n-t)};try{performance.measure(`centrinfo-widget:${e}`,{start:t,end:n})}catch{}return typeof window<`u`&&typeof CustomEvent<`u`&&window.dispatchEvent(new CustomEvent(`centrinfo:performance`,{detail:r})),r},Ij=/!?\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,Lj=/https?:\/\/[^\s)]+/g,Rj=e=>e.replace(/```[\s\S]*?```/g,e=>e.replace(/^```[^\n]*\n?/,``).replace(/```$/,``).trim()),zj=e=>Rj(e).replace(Ij,`$1`).replace(/`([^`]+)`/g,`$1`).replace(/\*\*([^*]+)\*\*/g,`$1`).replace(/__([^_]+)__/g,`$1`).replace(/(^|[\s([{])\*([^*\n]{1,120})\*(?=[\s.,;:!?)}\]]|$)/g,`$1$2`).replace(/(^|[\s([{])_([^_\n]{1,120})_(?=[\s.,;:!?)}\]]|$)/g,`$1$2`).replace(/^\s{0,3}#{1,6}\s+/gm,``).replace(/^\s{0,3}[-*+]\s+/gm,``).replace(/^\s{0,3}\d+\.\s+/gm,``).replace(/\s+\*/g,` `).replace(/\*\s+/g,` `).replace(/[*_]{2,}/g,``).replace(Lj,e=>e.replace(/^https?:\/\//,``).replace(/^www\./,``).replace(/\/$/,``)).replace(/[ \t]+\n/g,`
|
|
28
28
|
`).replace(/\n{3,}/g,`
|
|
29
29
|
|
|
30
|
-
`).replace(/[ \t]{2,}/g,` `).trim(),jj=()=>typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.round(Math.random()*1e9)}`,Mj=(e,t)=>{typeof console>`u`||console.warn(`[centrinfo-widget] ${e}`,t??{})},Nj=(e,t,n,r,i=1,a,o=!1,s,c)=>{e.current?.pause(),e.current=null,typeof window<`u`&&`speechSynthesis`in window&&window.speechSynthesis.cancel(),t.current=null;let l=()=>{let e=a?.trim();if(!o||!e||typeof window>`u`||!(`speechSynthesis`in window)||typeof SpeechSynthesisUtterance>`u`)return!1;let n=new SpeechSynthesisUtterance(e),r=!1,l=()=>{r||(r=!0,t.current===n&&(t.current=null,c?.()))};return n.rate=i,n.lang=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||`en-US`,n.onend=l,n.onerror=l,t.current=n,s?.(),window.speechSynthesis.cancel(),window.speechSynthesis.speak(n),!0};if(!n||typeof Audio>`u`)return l();let u=new Audio(`data:${r||`audio/mpeg`};base64,${n}`),d=!1,f=()=>{d||(d=!0,e.current===u&&(e.current=null,c?.()))};return u.playbackRate=i,u.onended=f,u.onerror=f,e.current=u,u.play().then(()=>{if(e.current!==u){f();return}s?.(Number.isFinite(u.duration)?u.duration*1e3:void 0)}).catch(()=>{l()||f()}),!0},Pj=e=>{try{return e===`none`?null:e===`session`?sessionStorage:localStorage}catch{return null}},Fj=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Ij=e=>{try{let t=e?.split(`.`)[1];if(!t)return;let n=t.replace(/-/g,`+`).replace(/_/g,`/`),r=JSON.parse(atob(n.padEnd(Math.ceil(n.length/4)*4,`=`)));for(let e of[`sub`,`external_user_id`,`user_id`]){let t=r[e];if(typeof t==`string`&&t.trim())return t.trim()}}catch{}},Lj=e=>{let t=e.user?.externalId?.trim()||e.user?.userId?.trim()||e.user?.email?.trim().toLowerCase()||Ij(e.identityToken)||(e.identityToken||e.getIdentityToken?`authenticated`:`anonymous`);return`${e.token.slice(0,12)}:${e.chatSurface}:${Fj(t)}`},Rj=e=>`${e.chatSurface}:${jj()}`,zj=e=>e.slice(0,12),Bj=e=>`centrinfo:session:${e}`,Vj=e=>`centrinfo:visitor:${e}`,Hj=(e,t)=>`centrinfo:chat:${e}:${t}`,Uj=e=>`centrinfo:history:${e}`,Wj=720*60*60*1e3,Gj=(e,t)=>{try{return JSON.parse(e?.getItem(Vj(t))||`{}`)}catch{return{}}},Kj=(e,t,n)=>{if(!e)return Rj(n);try{let r=Bj(t),i=e.getItem(r);if(i)return i;let a=Rj(n);return e.setItem(r,a),a}catch{return Rj(n)}},qj=(e,t,n)=>{if(!e)return{};try{let r=e.getItem(Hj(t,n));return r?JSON.parse(r):{}}catch{return{}}},Jj=(e,t,n)=>{let{ts:r,expiresAt:i,messages:a}=qj(e,t,n);return!Array.isArray(a)||typeof i==`number`&&Date.now()>i||typeof r==`number`&&Date.now()-r>Wj?[]:a},Yj=(e,t,n)=>{let{ts:r,expiresAt:i,messages:a,ended:o}=qj(e,t,n);return!Array.isArray(a)||a.length===0||typeof i==`number`&&Date.now()>i||typeof r==`number`&&Date.now()-r>Wj?!1:o===!0||typeof r==`number`&&Date.now()-r>864e5},Xj=e=>Number.isFinite(e??NaN)?Math.max(5,Math.min(200,Math.round(e))):50,Zj=e=>Number.isFinite(e??NaN)?Math.max(1,Math.min(365,Math.round(e)))*24*60*60*1e3:Wj,Qj=(e,t,n,r,i,a,o,s)=>{if(e)try{if(!a){e.removeItem(Hj(t,n));return}let c=r.filter(e=>!e.pending).slice(-o);if(c.length===0)return;let l=Date.now();e.setItem(Hj(t,n),JSON.stringify({ts:l,expiresAt:l+s,messages:c,ended:i}))}catch{}},$j=(e,t)=>{if(!e)return[];try{let n=e.getItem(Uj(t)),r=n?JSON.parse(n):[];return Array.isArray(r)?r:[]}catch{return[]}},eM=(e,t,n)=>{if(e)try{e.setItem(Uj(t),JSON.stringify(n.slice(0,20)))}catch{}},tM=(e,t)=>{if(e)try{let n=`centrinfo:chat:${t}:`,r=new Set([Bj(t),Vj(t),Uj(t)]),i=[];for(let t=0;t<e.length;t++){let a=e.key(t);a&&(r.has(a)||a.startsWith(n))&&i.push(a)}i.forEach(t=>e.removeItem(t))}catch{}},nM=e=>{let t=(e.find(e=>e.role===`user`&&e.content.trim())?.content||e.find(e=>e.content.trim())?.content||``).trim().replace(/\s+/g,` `);return t.length>60?t.slice(0,60)+`…`:t||`Conversation`},rM=e=>({id:`live:${e.id}`,role:e.type===`chat`||e.type===`ai_resume`?`assistant`:`system`,content:e.content,authorName:e.authorName,liveEventType:e.type,createdAt:e.createdAt}),iM=(e,n,i=!0)=>{let s=a(Pj(n.persistence)).current,c=Lj(n),l=a(Kj(s,c,n)),u=a(null),d=a(null),f=a(null),p=a(void 0),m=a(null),h=a({}),[g,_]=o(null),[v,y]=o(()=>Jj(s,c,l.current)),b=a(v.length>0),x=a(v.some(e=>e.role===`user`)),[S,C]=o(!1),[w,T]=o(!1),[E,D]=o(()=>Yj(s,c,l.current)),[O,k]=o(()=>Gj(s,c)),[A,j]=o(()=>$j(s,c)),[M,N]=o(null),[P,F]=o([]),[ee,I]=o(`ai`),[te,ne]=o(void 0),[re,ie]=o(void 0),ae=a(new Date().toISOString()),oe=a(void 0),se=a(!1),ce=a(0),L=a(O);r(()=>{L.current=O},[O]);let R=g?.memoryEnabled!==!1,le=Xj(g?.memoryMessageCap),ue=Zj(g?.memoryRetentionDays),de=t(()=>{u.current?.abort(),tM(s,c),tM(s,zj(n.token));let e=Rj(n);l.current=e;try{s?.setItem(Bj(c),e)}catch{}N(null),F([]),D(!1),j([]),k({}),I(`ai`),ne(void 0),ie(void 0),ae.current=new Date().toISOString(),y(g?[{id:jj(),role:`assistant`,content:g.greeting,availableActions:g.availableActions}]:[])},[s,c,n.token,g]),fe=t(e=>{try{s?.setItem(Vj(c),JSON.stringify(e))}catch{}},[s,c]),pe=t(t=>{let n=(t.email??``).trim().toLowerCase(),r=(L.current.email??``).trim().toLowerCase();n&&r&&n!==r&&de();let i={};t.email?.trim()&&(i.email=t.email.trim()),t.phone?.trim()&&(i.phone=t.phone.trim());let a=[t.firstName,t.lastName].filter(e=>!!e?.trim()).join(` `).trim()||t.name?.trim()||``;a&&(i.name=a),Object.keys(i).length>0&&k(e=>{let t={...i,...e};return fe(t),t}),e.identify(l.current,t).catch(()=>{})},[e,fe,de]),me=t(e=>{_(e),y(t=>{if(t.length===0)return[{id:jj(),role:`assistant`,content:e.greeting,availableActions:e.availableActions}];let n=t.some(e=>e.role===`user`),r=t[0];return!n&&r?.role===`assistant`?[{...r,content:e.greeting,availableActions:e.availableActions},...t.slice(1)]:t})},[]);r(()=>{if(g?.memoryEnabled===!1){try{s?.removeItem(Hj(c,l.current))}catch{}eM(s,c,[]),j([]),N(null),F([]),y(e=>b.current?(b.current=!1,g?[{id:jj(),role:`assistant`,content:g.greeting,availableActions:g.availableActions}]:[]):e)}},[g,s,c]);let he=t(async()=>{me(await e.bootstrap())},[me,e]);r(()=>{let t=!0,n=e=>e.messages.map(e=>({id:e.id,role:e.role,content:e.content,authorName:e.authorName,liveEventType:e.messageType,sources:e.sources,visualization:e.visualization,createdAt:e.createdAt}));return e.history().then(e=>{if(!t||e.conversations.length===0)return;let r=e.conversations.map(e=>({sessionId:e.sessionId,ts:Date.parse(e.lastSeenAt)||Date.now(),title:e.title,ended:e.ended}));for(let t of e.conversations)Qj(s,c,t.sessionId,n(t),t.ended,!0,le,ue);eM(s,c,r),j(r);let i=e.conversations.find(t=>t.sessionId===e.activeSessionId);if(!i||x.current)return;let a=n(i);l.current=i.sessionId,b.current=a.length>0;try{s?.setItem(Bj(c),i.sessionId)}catch{}let o=a[a.length-1]?.createdAt;o&&(ae.current=o),D(i.ended),y(a)}).catch(()=>{}),()=>{t=!1}},[le,ue,c,s,e]),r(()=>{let t=!0;return e.bootstrap().then(e=>{t&&me(e)}),n.user&&pe(n.user),()=>{t=!1}},[me,e]),r(()=>{let e=n.configRefreshSeconds;if(!i||e<=0||typeof window>`u`)return;let t=!0,r=!1,a=Math.max(10,e)*1e3,o=()=>typeof document>`u`||document.visibilityState!==`hidden`,s=async()=>{if(!(!t||r||!o())){r=!0;try{await he()}catch{}finally{r=!1}}};s();let c=window.setInterval(s,a),l=()=>void s(),u=()=>void s();return window.addEventListener(`focus`,l),document?.addEventListener?.(`visibilitychange`,u),()=>{t=!1,window.clearInterval(c),window.removeEventListener(`focus`,l),document?.removeEventListener?.(`visibilitychange`,u)}},[i,n.configRefreshSeconds,he]),r(()=>{Qj(s,c,l.current,v,E,R,le,ue)},[v,E,s,c,R,le,ue]),r(()=>{if(E||M)return;let t=!0,r=!1,i=async()=>{if(!r){r=!0;try{let r=await e.liveEvents(l.current,ae.current);if(!t)return;if(I(r.mode),ne(r.assignedAgentName||void 0),ie(r.agentTyping?r.agentTypingName||r.assignedAgentName||`Agent`:void 0),r.conversationEnded){D(!0),I(`ai`),ne(void 0),ie(void 0),y(e=>e.some(e=>e.id===`live:conversation-ended`)?e:[...e,{id:`live:conversation-ended`,role:`system`,content:n.strings.conversationEnded,liveEventType:`conversation_ended`,createdAt:new Date().toISOString()}]);return}if(r.events.length>0){let e=ae.current,t=Date.parse(e),n=r.events.map(n=>{let r=Date.parse(n.createdAt);return Number.isFinite(r)&&r>t&&(t=r,e=n.createdAt),rM(n)});ae.current=e,y(e=>{let t=new Set(e.map(e=>e.id)),r=n.filter(e=>!t.has(e.id));return r.length>0?[...e,...r]:e}),n.some(e=>e.role===`assistant`)&&Tj(`receive`)}}catch{}finally{r=!1}}};i();let a=window.setInterval(i,2200);return()=>{t=!1,window.clearInterval(a)}},[n.strings.conversationEnded,e,E,M]),r(()=>{if(!R){eM(s,c,[]),j(e=>e.length>0?[]:e);return}v.some(e=>e.role===`user`)&&j(e=>{let t=l.current,n=[{sessionId:t,ts:Date.now(),title:nM(v),ended:E},...e.filter(e=>e.sessionId!==t)];return eM(s,c,n),n.slice(0,20)})},[v,E,s,c,R]);let ge=t((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),_e=t(()=>{p.current!==void 0&&typeof window<`u`&&window.clearInterval(p.current),p.current=void 0},[]),ve=t((e,t)=>{_e(),m.current===e&&(m.current=null),ge(e,{content:t,pending:!1,streaming:!1})},[_e,ge]),z=t((e,t,n)=>{let r=t.trim();if(!r||typeof window>`u`){ve(e,r);return}_e(),m.current=e;let i=r.match(/\S+\s*/g)??[r],a=n&&n>0?n:i.length*95,o=Math.max(28,Math.min(150,a/Math.max(i.length,1))),s=0;ge(e,{content:``,pending:!1,streaming:!0}),p.current=window.setInterval(()=>{s+=1,ge(e,{content:i.slice(0,s).join(``),pending:!1,streaming:s<i.length}),s>=i.length&&(_e(),m.current===e&&(m.current=null),ge(e,{content:r,pending:!1,streaming:!1}))},o)},[_e,ve,ge]),B=t(()=>{let e=m.current;_e(),m.current=null,e&&ge(e,{pending:!1,streaming:!1})},[_e,ge]),V=t(t=>{if(E||M||ee===`ai`||typeof window>`u`)return;if(oe.current!==void 0&&window.clearTimeout(oe.current),!t){if(!se.current)return;se.current=!1,ce.current=0,e.typing(l.current,!1).catch(()=>{});return}let n=Date.now();(!se.current||n-ce.current>2500)&&(se.current=!0,ce.current=n,e.typing(l.current,!0).catch(()=>{})),oe.current=window.setTimeout(()=>{se.current&&(se.current=!1,ce.current=0,e.typing(l.current,!1).catch(()=>{}))},1600)},[e,E,M,ee]);r(()=>()=>{oe.current!==void 0&&typeof window<`u`&&window.clearTimeout(oe.current)},[]),r(()=>()=>_e(),[_e]);let H=t((t,r,i={})=>{B(),C(!0);let a=new AbortController;u.current=a;let o=!!(g?.allowVoiceInput&&g?.voiceOutputEnabled&&g.talkbackMode!==`text`),s=!!(i.forceVoicePlayback&&o);e.stream(t,l.current,{voicePlaybackRequested:!!i.forceVoicePlayback,signal:a.signal,onChunk:e=>{s||(i.forceVoicePlayback&&e&&(h.current[r]=!0),y(t=>t.map(t=>t.id===r?{...t,content:t.content+e,pending:!1,streaming:!0}:t)))}}).then(e=>{if(e.liveMode&&(I(e.liveMode),ne(e.assignedAgentName||void 0)),e.liveMode&&e.liveMode!==`ai`&&!e.answer.trim()){y(e=>e.filter(e=>e.id!==r));return}let t=!!h.current[r];delete h.current[r];let a=!!(i.forceVoicePlayback&&o&&e.audioBase64&&e.answer.trim()&&!t);if(y(t=>t.map(t=>t.id===r?{...t,content:a?``:e.answer||t.content||n.strings.emptyReply,pending:!1,streaming:a,error:!1,retryText:void 0,sources:e.sources,suggestedReplies:e.suggestedReplies,availableActions:e.availableActions,handoffOffered:e.handoffOffered,requestedContactFields:e.requestedContactFields,visualization:e.visualization}:t)),Tj(`receive`),i.forceVoicePlayback&&!e.audioBase64&&Mj(o?`Talkback expected backend TTS audio, but the chat response did not include audioBase64.`:`Talkback voice was requested, but the loaded widget token config does not enable provider TTS.`,{voiceOutputEnabled:g?.voiceOutputEnabled,talkbackMode:g?.talkbackMode,voiceProvider:g?.voiceProvider,hasAudioBase64:!!e.audioBase64}),i.forceVoicePlayback){let t=Nj(d,f,e.audioBase64,e.mimeType,g?.voiceSpeed??1,e.answer,!0,t=>{T(!0),a&&z(r,e.answer,t)},()=>{T(!1),a&&ve(r,e.answer)});a&&!t&&ve(r,e.answer)}e.answer&&n.onMessage?.({role:`assistant`,content:e.answer}),e.handoffOffered&&n.onHandoff?.(),e.conversationEnded&&D(!0)}).catch(e=>{if(a.signal.aborted){delete h.current[r],ge(r,{pending:!1,streaming:!1});return}delete h.current[r],ge(r,{content:Ej(e,n.strings),pending:!1,streaming:!1,error:!0,retryText:t})}).finally(()=>{delete h.current[r],C(!1),u.current=null})},[e,n,ge,g?.allowVoiceInput,g?.talkbackMode,g?.voiceOutputEnabled,g?.voiceSpeed,B]),U=t((e,t={})=>{let r=e.trim(),{imageUrl:i,attachmentName:a,attachmentText:o,forceVoicePlayback:s,userMessageId:c}=t;if(!r&&!i&&!o||S||E)return;x.current=!0;let l=r;o?l=`${r}\n\n[Attached file${a?` "${a}"`:``}]:\n${o}`.trim():!l&&i&&(l=i);let u={id:c||jj(),role:`user`,content:r,imageUrl:i,attachmentName:a},d=jj();y(e=>[...c&&e.some(e=>e.id===c)?e.map(e=>e.id===c?{...e,content:r,pending:!1,streaming:!1,imageUrl:i,attachmentName:a}:e):[...e,u],{id:d,role:`assistant`,content:``,pending:!0}]),Tj(`send`),n.onMessage?.({role:`user`,content:l}),H(l,d,{forceVoicePlayback:s})},[S,E,n,H]),ye=t(()=>u.current?.abort(),[]),be=t(()=>{B(),d.current?.pause(),d.current=null,typeof window<`u`&&`speechSynthesis`in window&&window.speechSynthesis.cancel(),f.current=null,T(!1)},[B]),xe=t(t=>{let n=Aj(t);if(!n)return Promise.resolve(!1);let r=!!(g?.allowVoiceInput&&g?.voiceOutputEnabled&&g.talkbackMode!==`text`),i=(e,t)=>new Promise(r=>{let i=!1;Nj(d,f,e,t,g?.voiceSpeed??1,n,!0,()=>{i=!0,T(!0)},()=>{T(!1),r(i)})||(T(!1),r(!1))});return r?e.speak(n).then(e=>e.audioBase64?i(e.audioBase64,e.mimeType):(Mj(`Talkback prompt TTS did not return provider audio.`,{providerReady:e.providerReady,message:e.message,voiceProvider:g?.voiceProvider,voiceOutputEnabled:g?.voiceOutputEnabled,talkbackMode:g?.talkbackMode}),i())).catch(e=>(Mj(`Talkback prompt TTS request failed before audio playback.`,{error:e instanceof Error?e.message:String(e),voiceProvider:g?.voiceProvider,voiceOutputEnabled:g?.voiceOutputEnabled,talkbackMode:g?.talkbackMode}),i())):(Mj(`Talkback prompt wanted voice, but the loaded widget token config has provider TTS disabled.`,{voiceOutputEnabled:g?.voiceOutputEnabled,talkbackMode:g?.talkbackMode,voiceProvider:g?.voiceProvider}),i())},[g?.allowVoiceInput,g?.talkbackMode,g?.voiceOutputEnabled,g?.voiceSpeed,e]),W=t((e,t)=>{S||E||!t||(ge(e,{content:``,pending:!0,streaming:!1,error:!1}),Tj(`send`),H(t,e))},[S,E,ge,H]),G=t((t,n,r)=>{ge(t,{feedback:n});let i=v.findIndex(e=>e.id===t),a=i>=0?v[i]?.content:void 0,o;for(let e=i-1;e>=0;e--)if(v[e]?.role===`user`){o=v[e]?.content;break}e.sendFeedback({sessionId:l.current,messageId:t,rating:n,comment:r,question:o,answer:a}).catch(()=>{})},[e,ge,v]),Se=t(async(t,r,i={})=>{n.onAction?.(t);let a=await e.action(t,{sessionId:l.current,...r}),o={};return i.name?.trim()&&(o.name=i.name.trim()),i.email?.trim()&&(o.email=i.email.trim()),i.phone?.trim()&&(o.phone=i.phone.trim()),Object.keys(o).length>0&&(k(e=>{let t={...e,...o};return fe(t),t}),o.email&&t!==`contact`&&e.action(`contact`,{sessionId:l.current,...o}).catch(()=>{})),Tj(`receive`),a},[e,n,fe]),Ce=t(e=>{let t=e.trim();t&&y(e=>e.some(e=>e.role===`assistant`&&e.content===t)?e:[...e,{id:jj(),role:`assistant`,content:t}])},[]),we=t(e=>{x.current=!0;let t=jj();return y(n=>[...n,{id:t,role:`user`,content:e.trim(),pending:!0}]),t},[]),Te=t((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),K=t(e=>{y(t=>t.filter(t=>t.id!==e))},[]),Ee=t((t,n)=>{e.sendFeedback({sessionId:l.current,messageId:`__csat__`,rating:t,comment:n}).catch(()=>{})},[e]),q=t((t,n,r,i)=>e.transcribe(t,n,r,i),[e]),J=t((t,n,r)=>e.extract(t,n,r),[e]),Y=t(t=>e.searchGifs(t),[e]),De=t((t,n)=>e.demoSlots(t,n),[e]),Oe=t(e=>U(``,{imageUrl:e}),[U]),X=n.demo||!!n.gifApiKey,ke=t(()=>{u.current?.abort(),D(!0),e.endConversation(l.current).catch(()=>{})},[e]),Ae=t(()=>{u.current?.abort();let e=Rj(n);l.current=e;try{s?.setItem(Bj(c),e)}catch{}N(null),F([]),D(!1),I(`ai`),ne(void 0),ie(void 0),ae.current=new Date().toISOString(),y(g?[{id:jj(),role:`assistant`,content:g.greeting,availableActions:g.availableActions}]:[])},[s,c,g]),je=t(e=>{if(R){if(e===l.current){N(null);return}F(Jj(s,c,e)),N(e)}},[s,c,R]),Me=t(()=>{N(null),F([])},[]);return{persona:g,messages:v,sending:S,assistantSpeaking:w,visitor:O,starters:n.starters.length>0?n.starters:g?.starterQuestions??[],featuredLinks:g?.featuredLinks??[],hasEmail:!!O.email,liveMode:ee,assignedAgentName:te,agentTypingName:re,send:U,sendGif:Oe,notifyTyping:V,stop:ye,retry:W,rateMessage:G,injectAssistant:Ce,appendUserDraft:we,patchMessage:Te,removeMessage:K,submitCsat:Ee,submitForm:Se,transcribe:q,extract:J,searchGifs:Y,demoSlots:De,gifEnabled:X,identify:pe,ended:E,endConversation:ke,startNew:Ae,history:R?A:[],viewingSessionId:M,viewMessages:P,openConversation:je,closeHistoryView:Me,shutdown:de,stopSpeaking:be,speakAssistantText:xe}},aM=e=>{if(!e||typeof e.token!=`string`||e.token.length===0)throw Error("[centrinfo-widget] `token` is required — pass your pub_* token to Centrinfo.init({ token }).");return{token:e.token,chatSurface:e.chatSurface??`floating`,analyticsContextToken:e.analyticsContextToken,identityToken:e.identityToken,getIdentityToken:e.getIdentityToken,apiBaseUrl:(e.apiBaseUrl??`https://api.accurixtech.com`).replace(/\/$/,``),accentColor:e.accentColor,themeTokens:e.themeTokens,agentName:e.agentName?.trim()||void 0,agentAvatarUrl:e.agentAvatarUrl?.trim()||void 0,launcherIcon:e.launcherIcon,gifApiKey:e.gifApiKey,theme:e.theme??`auto`,openByDefault:e.openByDefault??!1,sound:e.sound??!0,starters:e.starters??[],strings:uj(e.labels),persistence:e.persistence??`local`,attachments:e.attachments??!0,zIndex:e.zIndex??2147483e3,demo:e.demo??!1,preview:e.preview??!1,alignment:e.alignment===`left`?`left`:`right`,horizontalPadding:typeof e.horizontalPadding==`number`?e.horizontalPadding:20,verticalPadding:typeof e.verticalPadding==`number`?e.verticalPadding:20,hideDefaultLauncher:e.hideDefaultLauncher??!1,customLauncherSelector:e.customLauncherSelector,sessionDurationMinutes:typeof e.sessionDurationMinutes==`number`?e.sessionDurationMinutes:0,configRefreshSeconds:typeof e.configRefreshSeconds==`number`?e.configRefreshSeconds:30,proactiveMessage:e.proactiveMessage,proactiveDelaySeconds:typeof e.proactiveDelaySeconds==`number`?e.proactiveDelaySeconds:5,proactiveOnPaths:e.proactiveOnPaths,csat:e.csat??!0,user:e.user,onOpen:e.onOpen,onClose:e.onClose,onShow:e.onShow,onHide:e.onHide,onUnreadChange:e.onUnreadChange,onMessage:e.onMessage,onAction:e.onAction,onHandoff:e.onHandoff}};export{N as _,yj as a,pj as c,rj as d,aj as f,ZA as g,WA as h,Sj as i,sj as l,XA as m,iM as n,fj as o,ej as p,Tj as r,lj as s,aM as t,oj as u,D as v,g as y};
|
|
30
|
+
`).replace(/[ \t]{2,}/g,` `).trim(),Bj=()=>typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.round(Math.random()*1e9)}`,Vj=(e,t)=>{typeof console>`u`||console.warn(`[centrinfo-widget] ${e}`,t??{})},Hj=(e,t,n,r,i=1,a,o=!1,s,c)=>{e.current?.pause(),e.current=null,typeof window<`u`&&`speechSynthesis`in window&&window.speechSynthesis.cancel(),t.current=null;let l=()=>{let e=a?.trim();if(!o||!e||typeof window>`u`||!(`speechSynthesis`in window)||typeof SpeechSynthesisUtterance>`u`)return!1;let n=new SpeechSynthesisUtterance(e),r=!1,l=()=>{r||(r=!0,t.current===n&&(t.current=null,c?.()))};return n.rate=i,n.lang=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||`en-US`,n.onend=l,n.onerror=l,t.current=n,s?.(),window.speechSynthesis.cancel(),window.speechSynthesis.speak(n),!0};if(!n||typeof Audio>`u`)return l();let u=new Audio(`data:${r||`audio/mpeg`};base64,${n}`),d=!1,f=()=>{d||(d=!0,e.current===u&&(e.current=null,c?.()))};return u.playbackRate=i,u.onended=f,u.onerror=f,e.current=u,u.play().then(()=>{if(e.current!==u){f();return}s?.(Number.isFinite(u.duration)?u.duration*1e3:void 0)}).catch(()=>{l()||f()}),!0},Uj=e=>{try{return e===`none`?null:e===`session`?sessionStorage:localStorage}catch{return null}},Wj=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},Gj=e=>{try{let t=e?.split(`.`)[1];if(!t)return;let n=t.replace(/-/g,`+`).replace(/_/g,`/`),r=JSON.parse(atob(n.padEnd(Math.ceil(n.length/4)*4,`=`)));for(let e of[`sub`,`external_user_id`,`user_id`]){let t=r[e];if(typeof t==`string`&&t.trim())return t.trim()}}catch{}},Kj=e=>{let t=e.user?.externalId?.trim()||e.user?.userId?.trim()||e.user?.email?.trim().toLowerCase()||Gj(e.identityToken)||(e.identityToken||e.getIdentityToken?`authenticated`:`anonymous`);return`${e.token.slice(0,12)}:${e.chatSurface}:${Wj(t)}`},qj=e=>`${e.chatSurface}:${Bj()}`,Jj=e=>e.slice(0,12),Yj=e=>`centrinfo:session:${e}`,Xj=e=>`centrinfo:visitor:${e}`,Zj=(e,t)=>`centrinfo:chat:${e}:${t}`,Qj=e=>`centrinfo:history:${e}`,$j=720*60*60*1e3,eM=(e,t)=>{try{return JSON.parse(e?.getItem(Xj(t))||`{}`)}catch{return{}}},tM=(e,t,n)=>{if(!e)return qj(n);try{let r=Yj(t),i=e.getItem(r);if(i)return i;let a=qj(n);return e.setItem(r,a),a}catch{return qj(n)}},nM=(e,t,n)=>{if(!e)return{};try{let r=e.getItem(Zj(t,n));return r?JSON.parse(r):{}}catch{return{}}},rM=(e,t,n)=>{let{ts:r,expiresAt:i,messages:a}=nM(e,t,n);return!Array.isArray(a)||typeof i==`number`&&Date.now()>i||typeof r==`number`&&Date.now()-r>$j?[]:a},iM=(e,t,n)=>{let{ts:r,expiresAt:i,messages:a,ended:o}=nM(e,t,n);return!Array.isArray(a)||a.length===0||typeof i==`number`&&Date.now()>i||typeof r==`number`&&Date.now()-r>$j?!1:o===!0||typeof r==`number`&&Date.now()-r>864e5},aM=e=>Number.isFinite(e??NaN)?Math.max(5,Math.min(200,Math.round(e))):50,oM=e=>Number.isFinite(e??NaN)?Math.max(1,Math.min(365,Math.round(e)))*24*60*60*1e3:$j,sM=(e,t,n,r,i,a,o,s)=>{if(e)try{if(!a){e.removeItem(Zj(t,n));return}let c=r.filter(e=>!e.pending).slice(-o);if(c.length===0)return;let l=Date.now();e.setItem(Zj(t,n),JSON.stringify({ts:l,expiresAt:l+s,messages:c,ended:i}))}catch{}},cM=(e,t)=>{if(!e)return[];try{let n=e.getItem(Qj(t)),r=n?JSON.parse(n):[];return Array.isArray(r)?r:[]}catch{return[]}},lM=(e,t,n)=>{if(e)try{e.setItem(Qj(t),JSON.stringify(n.slice(0,20)))}catch{}},uM=(e,t)=>{if(e)try{let n=`centrinfo:chat:${t}:`,r=new Set([Yj(t),Xj(t),Qj(t)]),i=[];for(let t=0;t<e.length;t++){let a=e.key(t);a&&(r.has(a)||a.startsWith(n))&&i.push(a)}i.forEach(t=>e.removeItem(t))}catch{}},dM=e=>{let t=(e.find(e=>e.role===`user`&&e.content.trim())?.content||e.find(e=>e.content.trim())?.content||``).trim().replace(/\s+/g,` `);return t.length>60?t.slice(0,60)+`…`:t||`Conversation`},fM=e=>({id:`live:${e.id}`,role:e.type===`chat`||e.type===`ai_resume`?`assistant`:`system`,content:e.content,authorName:e.authorName,liveEventType:e.type,createdAt:e.createdAt}),pM=(e,n,i=!0)=>{let s=a(Uj(n.persistence)).current,c=Kj(n),l=a(tM(s,c,n)),u=a(null),d=a(null),f=a(null),p=a(void 0),m=a(null),h=a({}),[g,_]=o(null),[v,y]=o(()=>rM(s,c,l.current)),b=a(v.length>0),x=a(v.some(e=>e.role===`user`)),[S,C]=o(!1),[w,T]=o(!1),[E,D]=o(()=>iM(s,c,l.current)),[O,k]=o(()=>eM(s,c)),[A,j]=o(()=>cM(s,c)),[M,N]=o(null),[P,F]=o([]),[ee,I]=o(`ai`),[te,ne]=o(void 0),[re,ie]=o(void 0),ae=a(new Date().toISOString()),oe=a(void 0),se=a(!1),ce=a(0),L=a(O);r(()=>{L.current=O},[O]);let R=g?.memoryEnabled!==!1,le=aM(g?.memoryMessageCap),ue=oM(g?.memoryRetentionDays),de=t(()=>{u.current?.abort(),uM(s,c),uM(s,Jj(n.token));let e=qj(n);l.current=e;try{s?.setItem(Yj(c),e)}catch{}N(null),F([]),D(!1),j([]),k({}),I(`ai`),ne(void 0),ie(void 0),ae.current=new Date().toISOString(),y(g?[{id:Bj(),role:`assistant`,content:g.greeting,availableActions:g.availableActions,actions:g.actions}]:[])},[s,c,n.token,g]),fe=t(e=>{try{s?.setItem(Xj(c),JSON.stringify(e))}catch{}},[s,c]),pe=t(t=>{let n=(t.email??``).trim().toLowerCase(),r=(L.current.email??``).trim().toLowerCase();n&&r&&n!==r&&de();let i={};t.email?.trim()&&(i.email=t.email.trim()),t.phone?.trim()&&(i.phone=t.phone.trim());let a=[t.firstName,t.lastName].filter(e=>!!e?.trim()).join(` `).trim()||t.name?.trim()||``;a&&(i.name=a),Object.keys(i).length>0&&k(e=>{let t={...i,...e};return fe(t),t}),e.identify(l.current,t).catch(()=>{})},[e,fe,de]),me=t(e=>{_(e),y(t=>{if(t.length===0)return[{id:Bj(),role:`assistant`,content:e.greeting,availableActions:e.availableActions,actions:e.actions}];let n=t.some(e=>e.role===`user`),r=t[0];return!n&&r?.role===`assistant`?[{...r,content:e.greeting,availableActions:e.availableActions,actions:e.actions},...t.slice(1)]:t})},[]);r(()=>{if(g?.memoryEnabled===!1){try{s?.removeItem(Zj(c,l.current))}catch{}lM(s,c,[]),j([]),N(null),F([]),y(e=>b.current?(b.current=!1,g?[{id:Bj(),role:`assistant`,content:g.greeting,availableActions:g.availableActions,actions:g.actions}]:[]):e)}},[g,s,c]);let he=t(async()=>{me(await e.bootstrap())},[me,e]);r(()=>{let t=!0,n=e=>e.messages.map(e=>({id:e.id,role:e.role,content:e.content,authorName:e.authorName,liveEventType:e.messageType,sources:e.sources,visualization:e.visualization,artifacts:e.artifacts,createdAt:e.createdAt}));return e.history().then(e=>{if(!t||e.conversations.length===0)return;let r=e.conversations.map(e=>({sessionId:e.sessionId,ts:Date.parse(e.lastSeenAt)||Date.now(),title:e.title,ended:e.ended}));for(let t of e.conversations)sM(s,c,t.sessionId,n(t),t.ended,!0,le,ue);lM(s,c,r),j(r);let i=e.conversations.find(t=>t.sessionId===e.activeSessionId);if(!i||x.current)return;let a=n(i);l.current=i.sessionId,b.current=a.length>0;try{s?.setItem(Yj(c),i.sessionId)}catch{}let o=a[a.length-1]?.createdAt;o&&(ae.current=o),D(i.ended),y(a)}).catch(()=>{}),()=>{t=!1}},[le,ue,c,s,e]),r(()=>{let t=!0;return e.bootstrap().then(e=>{t&&me(e)}),n.user&&pe(n.user),()=>{t=!1}},[me,e]),r(()=>{let e=n.configRefreshSeconds;if(!i||e<=0||typeof window>`u`)return;let t=!0,r=!1,a=Math.max(10,e)*1e3,o=()=>typeof document>`u`||document.visibilityState!==`hidden`,s=async()=>{if(!(!t||r||!o())){r=!0;try{await he()}catch{}finally{r=!1}}};s();let c=window.setInterval(s,a),l=()=>void s(),u=()=>void s();return window.addEventListener(`focus`,l),document?.addEventListener?.(`visibilitychange`,u),()=>{t=!1,window.clearInterval(c),window.removeEventListener(`focus`,l),document?.removeEventListener?.(`visibilitychange`,u)}},[i,n.configRefreshSeconds,he]),r(()=>{sM(s,c,l.current,v,E,R,le,ue)},[v,E,s,c,R,le,ue]),r(()=>{if(E||M)return;let t=!0,r=!1,i=async()=>{if(!r){r=!0;try{let r=await e.liveEvents(l.current,ae.current);if(!t)return;if(I(r.mode),ne(r.assignedAgentName||void 0),ie(r.agentTyping?r.agentTypingName||r.assignedAgentName||`Agent`:void 0),r.conversationEnded){D(!0),I(`ai`),ne(void 0),ie(void 0),y(e=>e.some(e=>e.id===`live:conversation-ended`)?e:[...e,{id:`live:conversation-ended`,role:`system`,content:n.strings.conversationEnded,liveEventType:`conversation_ended`,createdAt:new Date().toISOString()}]);return}if(r.events.length>0){let e=ae.current,t=Date.parse(e),n=r.events.map(n=>{let r=Date.parse(n.createdAt);return Number.isFinite(r)&&r>t&&(t=r,e=n.createdAt),fM(n)});ae.current=e,y(e=>{let t=new Set(e.map(e=>e.id)),r=n.filter(e=>!t.has(e.id));return r.length>0?[...e,...r]:e}),n.some(e=>e.role===`assistant`)&&Mj(`receive`)}}catch{}finally{r=!1}}};i();let a=window.setInterval(i,2200);return()=>{t=!1,window.clearInterval(a)}},[n.strings.conversationEnded,e,E,M]),r(()=>{if(!R){lM(s,c,[]),j(e=>e.length>0?[]:e);return}v.some(e=>e.role===`user`)&&j(e=>{let t=l.current,n=[{sessionId:t,ts:Date.now(),title:dM(v),ended:E},...e.filter(e=>e.sessionId!==t)];return lM(s,c,n),n.slice(0,20)})},[v,E,s,c,R]);let ge=t((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),_e=t(()=>{p.current!==void 0&&typeof window<`u`&&window.clearInterval(p.current),p.current=void 0},[]),ve=t((e,t)=>{_e(),m.current===e&&(m.current=null),ge(e,{content:t,pending:!1,streaming:!1})},[_e,ge]),z=t((e,t,n)=>{let r=t.trim();if(!r||typeof window>`u`){ve(e,r);return}_e(),m.current=e;let i=r.match(/\S+\s*/g)??[r],a=n&&n>0?n:i.length*95,o=Math.max(28,Math.min(150,a/Math.max(i.length,1))),s=0;ge(e,{content:``,pending:!1,streaming:!0}),p.current=window.setInterval(()=>{s+=1,ge(e,{content:i.slice(0,s).join(``),pending:!1,streaming:s<i.length}),s>=i.length&&(_e(),m.current===e&&(m.current=null),ge(e,{content:r,pending:!1,streaming:!1}))},o)},[_e,ve,ge]),B=t(()=>{let e=m.current;_e(),m.current=null,e&&ge(e,{pending:!1,streaming:!1})},[_e,ge]),V=t(t=>{if(E||M||ee===`ai`||typeof window>`u`)return;if(oe.current!==void 0&&window.clearTimeout(oe.current),!t){if(!se.current)return;se.current=!1,ce.current=0,e.typing(l.current,!1).catch(()=>{});return}let n=Date.now();(!se.current||n-ce.current>2500)&&(se.current=!0,ce.current=n,e.typing(l.current,!0).catch(()=>{})),oe.current=window.setTimeout(()=>{se.current&&(se.current=!1,ce.current=0,e.typing(l.current,!1).catch(()=>{}))},1600)},[e,E,M,ee]);r(()=>()=>{oe.current!==void 0&&typeof window<`u`&&window.clearTimeout(oe.current)},[]),r(()=>()=>_e(),[_e]);let H=t((t,r,i={})=>{B(),C(!0);let a=Pj(),o=!1,s=new AbortController;u.current=s;let c=!!(g?.allowVoiceInput&&g?.voiceOutputEnabled&&g.talkbackMode!==`text`),p=!!(i.forceVoicePlayback&&c);e.stream(t,l.current,{voicePlaybackRequested:!!i.forceVoicePlayback,signal:s.signal,onChunk:e=>{e&&!o&&(o=!0,Fj(`data-first-chunk`,a)),!p&&(i.forceVoicePlayback&&e&&(h.current[r]=!0),y(t=>t.map(t=>t.id===r?{...t,content:t.content+e,pending:!1,streaming:!0}:t)))}}).then(e=>{if(e.liveMode&&(I(e.liveMode),ne(e.assignedAgentName||void 0)),e.liveMode&&e.liveMode!==`ai`&&!e.answer.trim()){y(e=>e.filter(e=>e.id!==r));return}let t=!!h.current[r];delete h.current[r];let a=!!(i.forceVoicePlayback&&c&&e.audioBase64&&e.answer.trim()&&!t);if(y(t=>t.map(t=>t.id===r?{...t,content:a?``:e.answer||t.content||n.strings.emptyReply,pending:!1,streaming:a,error:!1,retryText:void 0,sources:e.sources,suggestedReplies:e.suggestedReplies,availableActions:e.availableActions,actions:e.actions,selectedAction:e.selectedAction,handoffOffered:e.handoffOffered,requestedContactFields:e.requestedContactFields,visualization:e.visualization,artifacts:e.artifacts}:t)),Mj(`receive`),i.forceVoicePlayback&&!e.audioBase64&&Vj(c?`Talkback expected backend TTS audio, but the chat response did not include audioBase64.`:`Talkback voice was requested, but the loaded widget token config does not enable provider TTS.`,{voiceOutputEnabled:g?.voiceOutputEnabled,talkbackMode:g?.talkbackMode,voiceProvider:g?.voiceProvider,hasAudioBase64:!!e.audioBase64}),i.forceVoicePlayback){let t=Hj(d,f,e.audioBase64,e.mimeType,g?.voiceSpeed??1,e.answer,!0,t=>{T(!0),a&&z(r,e.answer,t)},()=>{T(!1),a&&ve(r,e.answer)});a&&!t&&ve(r,e.answer)}e.answer&&n.onMessage?.({role:`assistant`,content:e.answer}),e.handoffOffered&&n.onHandoff?.(),e.conversationEnded&&D(!0)}).catch(e=>{if(s.signal.aborted){delete h.current[r],ge(r,{pending:!1,streaming:!1});return}delete h.current[r],ge(r,{content:Nj(e,n.strings),pending:!1,streaming:!1,error:!0,retryText:t})}).finally(()=>{Fj(`data-complete`,a),delete h.current[r],C(!1),u.current=null})},[e,n,ge,g?.allowVoiceInput,g?.talkbackMode,g?.voiceOutputEnabled,g?.voiceSpeed,B]),U=t((e,t={})=>{let r=e.trim(),{imageUrl:i,attachmentName:a,attachmentText:o,forceVoicePlayback:s,userMessageId:c}=t;if(!r&&!i&&!o||S||E)return;x.current=!0;let l=r;o?l=`${r}\n\n[Attached file${a?` "${a}"`:``}]:\n${o}`.trim():!l&&i&&(l=i);let u={id:c||Bj(),role:`user`,content:r,imageUrl:i,attachmentName:a},d=Bj();y(e=>[...c&&e.some(e=>e.id===c)?e.map(e=>e.id===c?{...e,content:r,pending:!1,streaming:!1,imageUrl:i,attachmentName:a}:e):[...e,u],{id:d,role:`assistant`,content:``,pending:!0}]),Mj(`send`),n.onMessage?.({role:`user`,content:l}),H(l,d,{forceVoicePlayback:s})},[S,E,n,H]),ye=t(()=>u.current?.abort(),[]),be=t(()=>{B(),d.current?.pause(),d.current=null,typeof window<`u`&&`speechSynthesis`in window&&window.speechSynthesis.cancel(),f.current=null,T(!1)},[B]),xe=t(t=>{let n=zj(t);if(!n)return Promise.resolve(!1);let r=!!(g?.allowVoiceInput&&g?.voiceOutputEnabled&&g.talkbackMode!==`text`),i=(e,t)=>new Promise(r=>{let i=!1;Hj(d,f,e,t,g?.voiceSpeed??1,n,!0,()=>{i=!0,T(!0)},()=>{T(!1),r(i)})||(T(!1),r(!1))});return r?e.speak(n).then(e=>e.audioBase64?i(e.audioBase64,e.mimeType):(Vj(`Talkback prompt TTS did not return provider audio.`,{providerReady:e.providerReady,message:e.message,voiceProvider:g?.voiceProvider,voiceOutputEnabled:g?.voiceOutputEnabled,talkbackMode:g?.talkbackMode}),i())).catch(e=>(Vj(`Talkback prompt TTS request failed before audio playback.`,{error:e instanceof Error?e.message:String(e),voiceProvider:g?.voiceProvider,voiceOutputEnabled:g?.voiceOutputEnabled,talkbackMode:g?.talkbackMode}),i())):(Vj(`Talkback prompt wanted voice, but the loaded widget token config has provider TTS disabled.`,{voiceOutputEnabled:g?.voiceOutputEnabled,talkbackMode:g?.talkbackMode,voiceProvider:g?.voiceProvider}),i())},[g?.allowVoiceInput,g?.talkbackMode,g?.voiceOutputEnabled,g?.voiceSpeed,e]),W=t((e,t)=>{S||E||!t||(ge(e,{content:``,pending:!0,streaming:!1,error:!1}),Mj(`send`),H(t,e))},[S,E,ge,H]),G=t((t,n,r)=>{ge(t,{feedback:n});let i=v.findIndex(e=>e.id===t),a=i>=0?v[i]?.content:void 0,o;for(let e=i-1;e>=0;e--)if(v[e]?.role===`user`){o=v[e]?.content;break}e.sendFeedback({sessionId:l.current,messageId:t,rating:n,comment:r,question:o,answer:a}).catch(()=>{})},[e,ge,v]),Se=t(async(t,r,i={},a)=>{n.onAction?.(t);let o=await e.action(t,{sessionId:l.current,...r},a),s={};return i.name?.trim()&&(s.name=i.name.trim()),i.email?.trim()&&(s.email=i.email.trim()),i.phone?.trim()&&(s.phone=i.phone.trim()),Object.keys(s).length>0&&(k(e=>{let t={...e,...s};return fe(t),t}),s.email&&t!==`contact`&&e.action(`contact`,{sessionId:l.current,...s}).catch(()=>{})),Mj(`receive`),o},[e,n,fe]),Ce=t(e=>{let t=e.trim();t&&y(e=>e.some(e=>e.role===`assistant`&&e.content===t)?e:[...e,{id:Bj(),role:`assistant`,content:t}])},[]),we=t(e=>{x.current=!0;let t=Bj();return y(n=>[...n,{id:t,role:`user`,content:e.trim(),pending:!0}]),t},[]),Te=t((e,t)=>{y(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),K=t(e=>{y(t=>t.filter(t=>t.id!==e))},[]),Ee=t((t,n)=>{e.sendFeedback({sessionId:l.current,messageId:`__csat__`,rating:t,comment:n}).catch(()=>{})},[e]),q=t(async(t,n,r,i)=>{let a=Pj();try{if(typeof t!=`string`&&e.transcribeAudio)return await e.transcribeAudio(t,n,r,i);let a=typeof t==`string`?t:await fj(t);return await e.transcribe(a,n,r,i)}finally{Fj(`voice-transcription`,a)}},[e]),J=t((t,n,r)=>e.extract(t,n,r),[e]),Y=t(t=>e.searchGifs(t),[e]),De=t((t,n)=>e.demoSlots(t,n),[e]),Oe=t(e=>U(``,{imageUrl:e}),[U]),X=n.demo||!!n.gifApiKey,ke=t(()=>{u.current?.abort(),D(!0),e.endConversation(l.current).catch(()=>{})},[e]),Ae=t(()=>{u.current?.abort();let e=qj(n);l.current=e;try{s?.setItem(Yj(c),e)}catch{}N(null),F([]),D(!1),I(`ai`),ne(void 0),ie(void 0),ae.current=new Date().toISOString(),y(g?[{id:Bj(),role:`assistant`,content:g.greeting,availableActions:g.availableActions,actions:g.actions}]:[])},[s,c,g]),je=t(e=>{if(R){if(e===l.current){N(null);return}F(rM(s,c,e)),N(e)}},[s,c,R]),Me=t(()=>{N(null),F([])},[]);return{persona:g,messages:v,sending:S,assistantSpeaking:w,visitor:O,starters:n.starters.length>0?n.starters:g?.starterQuestions??[],featuredLinks:g?.featuredLinks??[],hasEmail:!!O.email,liveMode:ee,assignedAgentName:te,agentTypingName:re,send:U,sendGif:Oe,notifyTyping:V,stop:ye,retry:W,rateMessage:G,injectAssistant:Ce,appendUserDraft:we,patchMessage:Te,removeMessage:K,submitCsat:Ee,submitForm:Se,transcribe:q,extract:J,searchGifs:Y,demoSlots:De,gifEnabled:X,identify:pe,ended:E,endConversation:ke,startNew:Ae,history:R?A:[],viewingSessionId:M,viewMessages:P,openConversation:je,closeHistoryView:Me,shutdown:de,stopSpeaking:be,speakAssistantText:xe}},mM=()=>typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||`en`,hM=(e,t)=>{if(!e)return;let n=t.trim().toLowerCase(),r=n.split(`-`)[0]??n,i=Object.entries(e);return i.find(([e])=>e.toLowerCase()===n)?.[1]??i.find(([e])=>e.toLowerCase()===r)?.[1]},gM=e=>{if(!e||typeof e.token!=`string`||e.token.length===0)throw Error("[centrinfo-widget] `token` is required — pass your pub_* token to Centrinfo.init({ token }).");let t=e.locale?.trim()||mM(),n=hM(e.translations,t);return{token:e.token,chatSurface:e.chatSurface??`floating`,analyticsContextToken:e.analyticsContextToken,identityToken:e.identityToken,getIdentityToken:e.getIdentityToken,apiBaseUrl:(e.apiBaseUrl??`https://api.accurixtech.com`).replace(/\/$/,``),accentColor:e.accentColor,themeTokens:e.themeTokens,agentName:e.agentName?.trim()||void 0,agentAvatarUrl:e.agentAvatarUrl?.trim()||void 0,launcherIcon:e.launcherIcon,gifApiKey:e.gifApiKey,theme:e.theme??`auto`,openByDefault:e.openByDefault??!1,sound:e.sound??!0,starters:e.starters??[],strings:_j({...n?.labels,...e.labels}),locale:t,actionTranslations:n?.actions??{},persistence:e.persistence??`local`,attachments:e.attachments??!0,zIndex:e.zIndex??2147483e3,styleNonce:e.styleNonce?.trim()??``,demo:e.demo??!1,preview:e.preview??!1,alignment:e.alignment===`left`?`left`:`right`,horizontalPadding:typeof e.horizontalPadding==`number`?e.horizontalPadding:20,verticalPadding:typeof e.verticalPadding==`number`?e.verticalPadding:20,hideDefaultLauncher:e.hideDefaultLauncher??!1,customLauncherSelector:e.customLauncherSelector,sessionDurationMinutes:typeof e.sessionDurationMinutes==`number`?e.sessionDurationMinutes:0,configRefreshSeconds:typeof e.configRefreshSeconds==`number`?e.configRefreshSeconds:30,proactiveMessage:e.proactiveMessage,proactiveDelaySeconds:typeof e.proactiveDelaySeconds==`number`?e.proactiveDelaySeconds:5,proactiveOnPaths:e.proactiveOnPaths,csat:e.csat??!0,user:e.user,onOpen:e.onOpen,onClose:e.onClose,onShow:e.onShow,onHide:e.onHide,onUnreadChange:e.onUnreadChange,onMessage:e.onMessage,onAction:e.onAction,onHandoff:e.onHandoff}};export{g as C,D as S,ej as _,Ej as a,ZA as b,bj as c,uj as d,mj as f,aj as g,rj as h,kj as i,dj as l,oj as m,pM as n,yj as o,sj as p,Mj as r,gj as s,gM as t,pj as u,XA as v,N as x,WA as y};
|