@accurix/centrinfo-widget 5.2.1 → 5.4.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.
Files changed (49) hide show
  1. package/README.md +231 -38
  2. package/dist/bundle-ar-D_Sk4igF.mjs +1 -0
  3. package/dist/bundle-ar-fKjs-fvS.cjs +1 -0
  4. package/dist/bundle-de-BST4qEm1.cjs +1 -0
  5. package/dist/bundle-de-BWnVOyv0.mjs +1 -0
  6. package/dist/bundle-es-Bes8ddxv.mjs +1 -0
  7. package/dist/bundle-es-Bfphsx9c.cjs +1 -0
  8. package/dist/bundle-fr-D1QlfFID.mjs +1 -0
  9. package/dist/bundle-fr-X5Ian15d.cjs +1 -0
  10. package/dist/bundle-it-9j6g91Cu.mjs +1 -0
  11. package/dist/bundle-it-C2HPnGql.cjs +1 -0
  12. package/dist/bundle-pt-BK9LBxix.mjs +1 -0
  13. package/dist/bundle-pt-BMcCSSgB.cjs +1 -0
  14. package/dist/bundle-sw-BKWnwk-0.cjs +1 -0
  15. package/dist/bundle-sw-DA2XuFS_.mjs +1 -0
  16. package/dist/cdn/centrinfo-widget-dev.js +35 -23
  17. package/dist/cdn/centrinfo-widget-locale-ar.js +4 -0
  18. package/dist/cdn/centrinfo-widget-locale-de.js +4 -0
  19. package/dist/cdn/centrinfo-widget-locale-es.js +4 -0
  20. package/dist/cdn/centrinfo-widget-locale-fr.js +4 -0
  21. package/dist/cdn/centrinfo-widget-locale-it.js +4 -0
  22. package/dist/cdn/centrinfo-widget-locale-pt.js +4 -0
  23. package/dist/cdn/centrinfo-widget-locale-sw.js +4 -0
  24. package/dist/cdn/centrinfo-widget-voice.js +272 -0
  25. package/dist/cdn/centrinfo-widget.js +154 -128
  26. package/dist/cdn/manifest.json +57 -9
  27. package/dist/dev-transports-DP4ilDW1.mjs +13 -0
  28. package/dist/dev-transports-uGHAao9W.cjs +13 -0
  29. package/dist/index.cjs +2 -1
  30. package/dist/index.d.cts +2 -2
  31. package/dist/index.d.mts +2 -2
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.mjs +2 -1
  34. package/dist/runtime.cjs +2 -2
  35. package/dist/runtime.d.cts +128 -11
  36. package/dist/runtime.d.mts +122 -8
  37. package/dist/runtime.d.ts +479 -0
  38. package/dist/runtime.mjs +2 -2
  39. package/dist/speech-detector-runtime-D5GpV8VJ.cjs +68 -0
  40. package/dist/speech-detector-runtime-D7gguFpP.mjs +68 -0
  41. package/dist/styles-BWPJrttg.cjs +3563 -0
  42. package/dist/styles-C8MXPiR-.mjs +3563 -0
  43. package/dist/{types-95uGbSpk.d.mts → types-M-juCXr7.d.mts} +558 -93
  44. package/dist/{types-DAYxNBhI.d.cts → types-sRV3p0Gu.d.cts} +549 -87
  45. package/package.json +4 -3
  46. package/dist/dev-transports-DqSPyIEz.mjs +0 -1
  47. package/dist/dev-transports-KlSdSZpj.cjs +0 -1
  48. package/dist/styles-CCw1cP6m.cjs +0 -3543
  49. package/dist/styles-CiqV_OsG.mjs +0 -3543
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "packageName": "@accurix/centrinfo-widget",
3
- "version": "5.2.1",
3
+ "version": "5.4.0",
4
4
  "fileName": "centrinfo-widget.js",
5
- "cdnPath": "centrinfo/js/sdk-centrinfo-widget-v5.2.1/centrinfo-widget.js",
6
- "bytes": 425967,
7
- "gzipBytes": 124406,
8
- "sha256": "062df02eef0473b262f77bf00c205bc52abec6cb3bef85bc36b325492aab5aeb",
9
- "sri": "sha256-Bi3wLu8Ec7Ji93vwDCBbxSq+xss774W8NrMlSSqrWus=",
5
+ "cdnPath": "centrinfo/js/sdk-centrinfo-widget-v5.4.0/centrinfo-widget.js",
6
+ "bytes": 550650,
7
+ "gzipBytes": 164062,
8
+ "sha256": "1c63cd0d25e31a84aa246f96ff42623a56b2c4bbc66cbd6e80af16ffb97c3715",
9
+ "sri": "sha256-HGPNDSXjGoSqJG+W/0JiOlayxLvGbL1ugK8W/7l8NxU=",
10
10
  "chunks": [
11
11
  {
12
12
  "fileName": "centrinfo-widget-charts.js",
@@ -16,9 +16,57 @@
16
16
  },
17
17
  {
18
18
  "fileName": "centrinfo-widget-dev.js",
19
- "bytes": 15339,
20
- "gzipBytes": 4970,
21
- "sri": "sha256-AhvOMKbTFFzXwDiNZOPUR8bESECXAU81E/cjm1J7eyY="
19
+ "bytes": 18364,
20
+ "gzipBytes": 5610,
21
+ "sri": "sha256-BaSafv0Zt/NtDJYjsaMLjm/PZj9b1ObVU3JRAEAR6JA="
22
+ },
23
+ {
24
+ "fileName": "centrinfo-widget-voice.js",
25
+ "bytes": 7389475,
26
+ "gzipBytes": 3166276,
27
+ "sri": "sha256-Yfdfd6zeARxpCTJ+2VzmcguVycOY8qIZc5ucF+P5aKU="
28
+ },
29
+ {
30
+ "fileName": "centrinfo-widget-locale-fr.js",
31
+ "bytes": 28928,
32
+ "gzipBytes": 9669,
33
+ "sri": "sha256-tAimTupTTBwmLt70uWGSO4737cGLcyllj2aY2PjsWd0="
34
+ },
35
+ {
36
+ "fileName": "centrinfo-widget-locale-es.js",
37
+ "bytes": 27338,
38
+ "gzipBytes": 9290,
39
+ "sri": "sha256-H3wfXNxOkuX7HWFlByE/qUnR49ygexCzlD+c4nukLuM="
40
+ },
41
+ {
42
+ "fileName": "centrinfo-widget-locale-pt.js",
43
+ "bytes": 27498,
44
+ "gzipBytes": 9254,
45
+ "sri": "sha256-K3MQVp4EklSORPIYfVkincEkK+bUZod0r24E3c2p+UE="
46
+ },
47
+ {
48
+ "fileName": "centrinfo-widget-locale-de.js",
49
+ "bytes": 28032,
50
+ "gzipBytes": 9572,
51
+ "sri": "sha256-VnJkULDGYGOE0hi38g6ikDic8u5KT3QfzHefGHI5HBk="
52
+ },
53
+ {
54
+ "fileName": "centrinfo-widget-locale-it.js",
55
+ "bytes": 27422,
56
+ "gzipBytes": 9156,
57
+ "sri": "sha256-RYeeUshG3U8/e8HOo5MXs9chndpzR3mNxDOfCpEbZFw="
58
+ },
59
+ {
60
+ "fileName": "centrinfo-widget-locale-ar.js",
61
+ "bytes": 34012,
62
+ "gzipBytes": 10082,
63
+ "sri": "sha256-6iZ144/8OLeGuu7CqeCTAHVtIJE2k49P8fdagSZeyRQ="
64
+ },
65
+ {
66
+ "fileName": "centrinfo-widget-locale-sw.js",
67
+ "bytes": 26487,
68
+ "gzipBytes": 8890,
69
+ "sri": "sha256-pQ53ZaZvSNAlVmsZcJLR8XcqFRrvuWu5YksZwuM6f74="
22
70
  }
23
71
  ]
24
72
  }
@@ -0,0 +1,13 @@
1
+ const e=e=>new Promise(t=>setTimeout(t,e)),t={agentName:`Accurix`,agentAvatarUrl:``,widgetModule:`assistant`,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`}]},n=[{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`,reportingPeriod:{label:`January–August 2025`,timezone:`Africa/Lagos`},timezone:`Africa/Lagos`,freshness:{status:`live`,answeredAt:`2026-10-09T10:00:00Z`},appliedFilters:[{field:`status`,operator:`in`,value:[`Submitted`,`Approved`,`Fulfilled`]}],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,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:/demo ranking|most purchased/i,result:{answer:`Top 5 most purchased products this week: Security License Global 11 (352).
2
+
3
+ Top region for each product by quantity purchased this week:
4
+ 1. Security License Global 11: 352 — Southeast (Brazil): 80
5
+ 2. Sensor Pack Basic 18: 319 — West (Germany): 52
6
+ 3. Cloud Backup Plus 4: 301 — APAC (Singapore): 61
7
+ 4. Router Pro 7: 288 — North (Canada): 49
8
+ 5. Analytics Seat 2: 270 — South (Mexico): 58`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,title:`Top 5 most purchased products this week`,columns:[`name`,`region`,`ranked_total`,`breakdown_value`],rows:[{name:`Security License Global 11`,region:`Southeast (Brazil)`,ranked_total:352,breakdown_value:80},{name:`Sensor Pack Basic 18`,region:`West (Germany)`,ranked_total:319,breakdown_value:52},{name:`Cloud Backup Plus 4`,region:`APAC (Singapore)`,ranked_total:301,breakdown_value:61},{name:`Router Pro 7`,region:`North (Canada)`,ranked_total:288,breakdown_value:49},{name:`Analytics Seat 2`,region:`South (Mexico)`,ranked_total:270,breakdown_value:58}],rowCount:5,tableAvailable:!0,columnMetadata:[{key:`name`,label:`Product`,dataType:`text`,semanticRole:`dimension`},{key:`region`,label:`Region`,dataType:`text`,semanticRole:`dimension`},{key:`ranked_total`,label:`Quantity`,dataType:`number`,semanticRole:`measure`},{key:`breakdown_value`,label:`Quantity · Region`,dataType:`number`,semanticRole:`measure`}],rankedAnswer:{version:1,lead:`Top 5 most purchased products this week: Security License Global 11 (352).`,title:`Top 5 most purchased products this week`,detailTitle:`Top region for each product by quantity purchased this week`,itemField:`name`,detailFields:[`region`],labels:{item:`Product`,value:`Quantity`,detail:`Region`,detailValue:`Quantity · Region`},items:[{rank:1,label:`Security License Global 11`,value:352,display:`352`,details:[{rank:1,label:`Southeast (Brazil)`,value:80,display:`80`}]},{rank:2,label:`Sensor Pack Basic 18`,value:319,display:`319`,details:[{rank:1,label:`West (Germany)`,value:52,display:`52`}]},{rank:3,label:`Cloud Backup Plus 4`,value:301,display:`301`,details:[{rank:1,label:`APAC (Singapore)`,value:61,display:`61`}]},{rank:4,label:`Router Pro 7`,value:288,display:`288`,details:[{rank:1,label:`North (Canada)`,value:49,display:`49`}]},{rank:5,label:`Analytics Seat 2`,value:270,display:`270`,details:[{rank:1,label:`South (Mexico)`,value:58,display:`58`}]}],text:`Top region for each product by quantity purchased this week:
9
+ 1. Security License Global 11: 352 — Southeast (Brazil): 80
10
+ 2. Sensor Pack Basic 18: 319 — West (Germany): 52
11
+ 3. Cloud Backup Plus 4: 301 — APAC (Singapore): 61
12
+ 4. Router Pro 7: 288 — North (Canada): 49
13
+ 5. Analytics Seat 2: 270 — South (Mexico): 58`}}}},{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}}],r={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},i=e=>n.find(t=>t.match.test(e))?.result??r;var a=class{async history(){return{conversations:[]}}async bootstrap(){return await e(180),t}async stream(n,r,a){await e(550);let o=i(n),s=o.answer.split(/(\s+)/);for(let t of s){if(a.signal?.aborted)break;a.onChunk(t),await e(18+Math.min(40,t.length*6))}return{...o,availableActions:t.availableActions}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async presence(e){}async typing(){await e(20)}async action(t,n){return await e(450),{ok:!0,note:{"book-demo":`Demo requested. The team will follow up. 📅`,contact:`Got it — saved your details. ✅`,"contact-support":`Support request sent. The team can follow up from this chat. ✅`,inquiry:`Thanks! We'll get back to you shortly. ✉️`,"request-callback":`We'll call you back soon. 📞`,"schedule-callback":`Your callback has been scheduled.`,"subscribe-newsletter":`You're subscribed. 🎉`}[t]}}async speak(){return await e(120),{providerReady:!1,message:`Demo voice provider is not connected.`}}async transcribe(t,n,r,i){return await e(700),`How do I track a shipment?`}async uploadAttachment(e,t,n){return{id:`demo-${Date.now()}`,text:`Attached file: ${n}`,analysisFailed:!1}}async identify(t,n){await e(50)}async endConversation(t){await e(50)}async sendFeedback(){await e(50)}async sendExplanationFeedback(){await e(50)}async demoSlots(t,n){return await e(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(t){await e(280);let n=t.trim().toLowerCase(),r=n?l.filter(e=>e.alt.includes(n)||e.tags.some(e=>e.includes(n)||n.includes(e))):l;return(r.length>0?r:l).map(e=>({id:e.id,url:c(e.emoji,e.anim),preview:c(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'/>`,s=`<animateTransform attributeName='transform' attributeType='XML' type='rotate' values='-14 64 110;14 64 110;-14 64 110' dur='0.9s' repeatCount='indefinite'/>`,c=(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)}`},l=[{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:s},{id:`g3`,emoji:`👋`,alt:`wave hello`,tags:[`hi`,`hello`,`hey`,`wave`,`bye`],anim:s},{id:`g4`,emoji:`❤️`,alt:`heart`,tags:[`love`,`thanks`,`heart`],anim:o},{id:`g5`,emoji:`🤔`,alt:`thinking`,tags:[`hmm`,`think`,`thinking`],anim:s},{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:s}],u=e=>new Promise(t=>setTimeout(t,e));var d=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 u(300);for(let e of this.strings.previewReply.split(/(\s+)/)){if(n.signal?.aborted)break;n.onChunk(e),await u(16)}return{answer:this.strings.previewReply,sources:[],suggestedReplies:[],availableActions:[],handoffOffered:!1}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async presence(e){}async typing(){}async action(){return await u(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 sendExplanationFeedback(){}async transcribe(e,t,n,r){return``}async uploadAttachment(e,t,n){return{id:`preview-${Date.now()}`,text:`Attached file: ${n}`,analysisFailed:!1}}async searchGifs(){return[]}async demoSlots(){return{taken:[],busy:[]}}};export{a as MockTransport,d as PreviewTransport};
@@ -0,0 +1,13 @@
1
+ const e=e=>new Promise(t=>setTimeout(t,e)),t={agentName:`Accurix`,agentAvatarUrl:``,widgetModule:`assistant`,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`}]},n=[{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`,reportingPeriod:{label:`January–August 2025`,timezone:`Africa/Lagos`},timezone:`Africa/Lagos`,freshness:{status:`live`,answeredAt:`2026-10-09T10:00:00Z`},appliedFilters:[{field:`status`,operator:`in`,value:[`Submitted`,`Approved`,`Fulfilled`]}],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,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:/demo ranking|most purchased/i,result:{answer:`Top 5 most purchased products this week: Security License Global 11 (352).
2
+
3
+ Top region for each product by quantity purchased this week:
4
+ 1. Security License Global 11: 352 — Southeast (Brazil): 80
5
+ 2. Sensor Pack Basic 18: 319 — West (Germany): 52
6
+ 3. Cloud Backup Plus 4: 301 — APAC (Singapore): 61
7
+ 4. Router Pro 7: 288 — North (Canada): 49
8
+ 5. Analytics Seat 2: 270 — South (Mexico): 58`,sources:[],suggestedReplies:[`Show a demo chart`,`Show a demo table`],handoffOffered:!1,visualization:{version:1,presentation:`table`,type:`table`,title:`Top 5 most purchased products this week`,columns:[`name`,`region`,`ranked_total`,`breakdown_value`],rows:[{name:`Security License Global 11`,region:`Southeast (Brazil)`,ranked_total:352,breakdown_value:80},{name:`Sensor Pack Basic 18`,region:`West (Germany)`,ranked_total:319,breakdown_value:52},{name:`Cloud Backup Plus 4`,region:`APAC (Singapore)`,ranked_total:301,breakdown_value:61},{name:`Router Pro 7`,region:`North (Canada)`,ranked_total:288,breakdown_value:49},{name:`Analytics Seat 2`,region:`South (Mexico)`,ranked_total:270,breakdown_value:58}],rowCount:5,tableAvailable:!0,columnMetadata:[{key:`name`,label:`Product`,dataType:`text`,semanticRole:`dimension`},{key:`region`,label:`Region`,dataType:`text`,semanticRole:`dimension`},{key:`ranked_total`,label:`Quantity`,dataType:`number`,semanticRole:`measure`},{key:`breakdown_value`,label:`Quantity · Region`,dataType:`number`,semanticRole:`measure`}],rankedAnswer:{version:1,lead:`Top 5 most purchased products this week: Security License Global 11 (352).`,title:`Top 5 most purchased products this week`,detailTitle:`Top region for each product by quantity purchased this week`,itemField:`name`,detailFields:[`region`],labels:{item:`Product`,value:`Quantity`,detail:`Region`,detailValue:`Quantity · Region`},items:[{rank:1,label:`Security License Global 11`,value:352,display:`352`,details:[{rank:1,label:`Southeast (Brazil)`,value:80,display:`80`}]},{rank:2,label:`Sensor Pack Basic 18`,value:319,display:`319`,details:[{rank:1,label:`West (Germany)`,value:52,display:`52`}]},{rank:3,label:`Cloud Backup Plus 4`,value:301,display:`301`,details:[{rank:1,label:`APAC (Singapore)`,value:61,display:`61`}]},{rank:4,label:`Router Pro 7`,value:288,display:`288`,details:[{rank:1,label:`North (Canada)`,value:49,display:`49`}]},{rank:5,label:`Analytics Seat 2`,value:270,display:`270`,details:[{rank:1,label:`South (Mexico)`,value:58,display:`58`}]}],text:`Top region for each product by quantity purchased this week:
9
+ 1. Security License Global 11: 352 — Southeast (Brazil): 80
10
+ 2. Sensor Pack Basic 18: 319 — West (Germany): 52
11
+ 3. Cloud Backup Plus 4: 301 — APAC (Singapore): 61
12
+ 4. Router Pro 7: 288 — North (Canada): 49
13
+ 5. Analytics Seat 2: 270 — South (Mexico): 58`}}}},{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}}],r={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},i=e=>n.find(t=>t.match.test(e))?.result??r;var a=class{async history(){return{conversations:[]}}async bootstrap(){return await e(180),t}async stream(n,r,a){await e(550);let o=i(n),s=o.answer.split(/(\s+)/);for(let t of s){if(a.signal?.aborted)break;a.onChunk(t),await e(18+Math.min(40,t.length*6))}return{...o,availableActions:t.availableActions}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async presence(e){}async typing(){await e(20)}async action(t,n){return await e(450),{ok:!0,note:{"book-demo":`Demo requested. The team will follow up. 📅`,contact:`Got it — saved your details. ✅`,"contact-support":`Support request sent. The team can follow up from this chat. ✅`,inquiry:`Thanks! We'll get back to you shortly. ✉️`,"request-callback":`We'll call you back soon. 📞`,"schedule-callback":`Your callback has been scheduled.`,"subscribe-newsletter":`You're subscribed. 🎉`}[t]}}async speak(){return await e(120),{providerReady:!1,message:`Demo voice provider is not connected.`}}async transcribe(t,n,r,i){return await e(700),`How do I track a shipment?`}async uploadAttachment(e,t,n){return{id:`demo-${Date.now()}`,text:`Attached file: ${n}`,analysisFailed:!1}}async identify(t,n){await e(50)}async endConversation(t){await e(50)}async sendFeedback(){await e(50)}async sendExplanationFeedback(){await e(50)}async demoSlots(t,n){return await e(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(t){await e(280);let n=t.trim().toLowerCase(),r=n?l.filter(e=>e.alt.includes(n)||e.tags.some(e=>e.includes(n)||n.includes(e))):l;return(r.length>0?r:l).map(e=>({id:e.id,url:c(e.emoji,e.anim),preview:c(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'/>`,s=`<animateTransform attributeName='transform' attributeType='XML' type='rotate' values='-14 64 110;14 64 110;-14 64 110' dur='0.9s' repeatCount='indefinite'/>`,c=(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)}`},l=[{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:s},{id:`g3`,emoji:`👋`,alt:`wave hello`,tags:[`hi`,`hello`,`hey`,`wave`,`bye`],anim:s},{id:`g4`,emoji:`❤️`,alt:`heart`,tags:[`love`,`thanks`,`heart`],anim:o},{id:`g5`,emoji:`🤔`,alt:`thinking`,tags:[`hmm`,`think`,`thinking`],anim:s},{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:s}],u=e=>new Promise(t=>setTimeout(t,e));var d=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 u(300);for(let e of this.strings.previewReply.split(/(\s+)/)){if(n.signal?.aborted)break;n.onChunk(e),await u(16)}return{answer:this.strings.previewReply,sources:[],suggestedReplies:[],availableActions:[],handoffOffered:!1}}async liveEvents(){return{mode:`ai`,conversationEnded:!1,events:[]}}async presence(e){}async typing(){}async action(){return await u(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 sendExplanationFeedback(){}async transcribe(e,t,n,r){return``}async uploadAttachment(e,t,n){return{id:`preview-${Date.now()}`,text:`Attached file: ${n}`,analysisFailed:!1}}async searchGifs(){return[]}async demoSlots(){return{taken:[],busy:[]}}};exports.MockTransport=a,exports.PreviewTransport=d;
package/dist/index.cjs CHANGED
@@ -1 +1,2 @@
1
- const e=require(`./styles-CCw1cP6m.cjs`);let t=require(`preact`),n=require(`preact/hooks`),r=require(`preact/jsx-runtime`);const i=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom();n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},a=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,o=({state:t,onClose:i})=>{let o=e.q(),s=(0,n.useRef)(null);(0,n.useEffect)(()=>{s.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),i())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i]);let c=t.status===`ready`?a(t.mimeType):`other`;return(0,r.jsx)(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":e.K(o.attachPreviewTitle,{name:t.name}),onClick:e=>{e.target===e.currentTarget&&i()},children:(0,r.jsxs)(`div`,{class:`cf-preview__frame`,children:[(0,r.jsxs)(`div`,{class:`cf-preview__bar`,children:[(0,r.jsx)(`span`,{class:`cf-preview__name`,title:t.name,children:t.name}),t.status===`ready`&&(0,r.jsx)(`a`,{class:`cf-preview__btn`,href:t.url,download:t.name,children:o.attachDownload}),(0,r.jsx)(`button`,{ref:s,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":o.attachPreviewClose,onClick:i,children:`✕`})]}),(0,r.jsxs)(`div`,{class:`cf-preview__body`,children:[t.status===`loading`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewLoading}),t.status===`error`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewFailed}),t.status===`ready`&&c===`image`&&(0,r.jsx)(`img`,{class:`cf-preview__image`,src:t.url,alt:t.name}),t.status===`ready`&&c===`pdf`&&(0,r.jsx)(`iframe`,{class:`cf-preview__pdf`,src:t.url,title:t.name}),t.status===`ready`&&c===`other`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:o.attachPreviewUnsupported})]})]})})},s=({name:t,greeting:n})=>{let i=e.q();return(0,r.jsxs)(`section`,{class:`cf-empty-welcome`,"aria-label":e.K(i.welcomeLabel,{name:t}),children:[(0,r.jsx)(`span`,{class:`cf-empty-welcome__eyebrow`,children:i.welcomeEyebrow}),(0,r.jsx)(`h2`,{children:t}),(0,r.jsx)(`p`,{children:n||i.welcomePrompt})]})},c=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],c=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),c.focus()):!e.shiftKey&&(o===c||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},l=new Map,ee=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},te=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(l.has(n))return l.get(n);let r=ee(e),i=ee(t)??[255,255,255,1];if(!r){l.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,c=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return l.set(n,c),c},ne=e=>{let[t,r]=(0,n.useState)(`light`);return(0,n.useEffect)(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>r(t.matches?`dark`:`light`);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),e===`auto`?t:e},u=6e4,d=90,re={end:`end the call`,mute:`mute your microphone`,minimize:`minimize the chat`,expand:`expand the view`,shrink:`exit the expanded view`},ie=e=>e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s']/gu,` `).replace(/\s+/g,` `).trim(),ae=[{action:`shrink`,re:/\b(?:exit|leave|quit|close)\b[\s\w]*\b(?:full ?screen|expanded|theat(?:er|re))\b|\bshrink\b|\bsmaller view\b/},{action:`end`,re:/\b(?:end|close|stop|finish|hang ?up|quit|exit)\b[\s\w]*\b(?:call|chat|conversation|convo|session|talking)\b|\bhang ?up\b|\bgood ?bye\b|^bye(?: bye)?$/},{action:`mute`,re:/\bmute\b|\bstop listening\b/},{action:`minimize`,re:/\bminimi[sz]e\b|\bhide\b[\s\w]*\b(?:chat|call|window|widget)\b/},{action:`expand`,re:/\bexpand\b|\bmaximi[sz]e\b|\bfull ?screen\b|\btheat(?:er|re) mode\b|\bbigger view\b/}],oe=/^(?:yes|yeah|yep|yup|sure|correct|confirm|affirmative|go ahead|do it|please do|ok(?:ay)?)\b/,se=/^(?:no|nope|nah|cancel|never ?mind|don'?t|stop)\b/,ce=/^(?:end|close|stop|finish|hang ?up|quit|exit|bye|good ?bye)\b/,le=e=>{let t=ie(e);if(!t)return null;for(let{action:e,re:n}of ae)if(n.test(t)){let n=t.split(` `).length;return{action:e,confident:e===`end`?n<=10:n<=6}}return null},ue=e=>`I didn't catch yes or no. Say yes to ${re[e]}, or no to keep talking.`,f=({transport:t,config:a,bindControls:l,composerDraftStore:ee})=>{let u=a.strings,[d,ae]=(0,n.useState)(a.openByDefault),{persona:f,messages:p,sending:m,assistantSpeaking:h,visitor:de,hasEmail:fe,liveMode:g,assignedAgentName:pe,agentTypingName:me,starters:he,featuredLinks:ge,send:_,sendGif:_e,notifyTyping:ve,stop:ye,amend:be,hold:xe,resumeHeld:Se,duckSpeaking:Ce,retry:we,rateMessage:Te,doubleCheckResponse:Ee,retryResponse:De,rateExplanation:Oe,explanationTransport:ke,injectAssistant:Ae,reconnectSupport:je,appendUserDraft:Me,patchMessage:v,removeMessage:Ne,submitCsat:Pe,submitForm:Fe,confirmHostedBooking:Ie,transcribe:Le,uploadAttachment:Re,loadAttachment:ze,searchGifs:Be,demoSlots:Ve,gifEnabled:He,identify:Ue,ended:y,endConversation:We,startNew:Ge,history:Ke,viewingSessionId:qe,viewMessages:Je,openConversation:Ye,closeHistoryView:Xe,shutdown:Ze,stopSpeaking:b,speakAssistantText:Qe,analyticsModels:$e,analyticsModelId:et,selectAnalyticsModel:tt}=e.o(t,a,d),nt=e.a(p,g),[rt,it]=(0,n.useState)(null),at=(0,n.useRef)(0),ot=(0,n.useCallback)((e,t,n)=>{n===at.current&&it({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),st=(0,n.useCallback)((e,t,n)=>{let r=t.name,i=++at.current;it({status:`loading`,name:r}),ze(e,t,n).then(e=>ot(e,r,i),()=>{i===at.current&&it({status:`error`,name:r})})},[ze,ot]),ct=(0,n.useCallback)((e,t)=>ot(e,t,++at.current),[ot]),lt=(0,n.useCallback)(()=>{at.current+=1,it(null)},[]);(0,n.useEffect)(()=>()=>{rt?.status===`ready`&&URL.revokeObjectURL(rt.url)},[rt]);let ut=!!e.i(f?.actions),[x,dt]=(0,n.useState)(0),[S,ft]=(0,n.useState)({mic:`off`,processing:!1}),[pt,mt]=(0,n.useState)(null),[ht,gt]=(0,n.useState)(!1),[C,_t]=(0,n.useState)(!1),[vt,yt]=(0,n.useState)(!1),[bt,xt]=(0,n.useState)(!1),[St,Ct]=(0,n.useState)(0),[w,T]=(0,n.useState)(!1),[wt,E]=(0,n.useState)(null),[Tt,Et]=(0,n.useState)(null),[Dt,Ot]=(0,n.useState)([]),[kt,At]=(0,n.useState)(``),[jt,Mt]=(0,n.useState)(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),Nt=ne(a.theme),Pt=f?.soundEnabled??!0;(0,n.useEffect)(()=>{e.f(a.sound&&Pt&&!jt)},[a.sound,Pt,jt]);let Ft=(0,n.useCallback)(()=>{Mt(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),D=(0,n.useRef)(null),It=(0,n.useRef)(null),Lt=(0,n.useRef)(null),Rt=(0,n.useRef)(0),O=(0,n.useRef)(!1),k=(0,n.useRef)(!1),A=(0,n.useRef)(null),j=(0,n.useRef)(0),zt=(0,n.useRef)(void 0),Bt=(0,n.useRef)(0),Vt=(0,n.useRef)(null),M=(0,n.useRef)(!1),N=(0,n.useRef)(null),P=(0,n.useRef)(``),Ht=(0,n.useRef)(()=>{}),Ut=(0,n.useRef)(``),Wt=(0,n.useRef)(m),Gt=(0,n.useRef)(_);Gt.current=_;let Kt=(0,n.useRef)(be);Kt.current=be;let qt=(0,n.useRef)(Le);qt.current=Le;let F=(0,n.useRef)(!1),I=(0,n.useRef)(!1),Jt=(0,n.useRef)(``);Jt.current=[...p].reverse().find(e=>e.role===`assistant`)?.content??``;let Yt=(0,n.useRef)(h);Wt.current=m,Yt.current=h;let L=C?ht?`timeout`:bt||S.mic===`muted`?`muted`:S.mic===`unavailable`?S.reason===`permission-denied`||S.reason===`unsupported`?`denied`:`unavailable`:S.mic===`off`||S.mic===`starting`?`connecting`:S.mic===`hearing`?`hearing`:h?`speaking`:pt??(S.processing||m?`processing`:`listening`):`idle`,[Xt,Zt]=(0,n.useState)(!0),[Qt,R]=(0,n.useState)(!1),$t=(0,n.useRef)(0),[z,B]=(0,n.useState)(!1),[V,H]=(0,n.useState)(!1),en=(0,n.useRef)(null),[U,W]=(0,n.useState)(!1),tn=(0,n.useRef)({value:``}),nn=ee??tn.current,rn=(0,n.useRef)({confirmEnd:z,confirmClear:V,showHistory:U});rn.current={confirmEnd:z,confirmClear:V,showHistory:U};let[an,on]=(0,n.useState)(!1),G=!!qe,sn=G?Je:p,cn=sn.find(e=>e.id===wt&&e.visualization)?.visualization,ln=sn.find(e=>e.id===Tt&&e.visualization);(0,n.useEffect)(()=>{!Tt||ln||(Et(null),T(!1))},[Tt,ln]),(0,n.useEffect)(()=>{!wt||cn||(E(null),T(!1))},[cn,wt]);let K=(0,n.useCallback)(()=>{ae(!0),dt(0),e.d(`open`),a.onOpen?.(),a.onShow?.()},[a]),q=(0,n.useCallback)(()=>{ae(!1),T(!1),E(null),a.onClose?.(),a.onHide?.(),It.current?.focus()},[a]),J=(0,n.useCallback)(()=>d?q():K(),[d,K,q]),un=(0,n.useCallback)(()=>B(!0),[]),dn=(0,n.useCallback)(()=>{We(),B(!1)},[We]),fn=(0,n.useCallback)(()=>{Ge(),R(!1),Zt(!0)},[Ge]);(0,n.useEffect)(()=>{z&&en.current?.focus()},[z]),(0,n.useEffect)(()=>{l({open:K,close:q,toggle:J,identify:Ue,startNew:Ge,endConversation:We,shutdown:Ze})},[l,K,q,J,Ue,Ge,We,Ze]),(0,n.useEffect)(()=>{let e=p.filter(e=>e.role===`assistant`&&!e.pending).length;if(d){Rt.current=e;return}e>Rt.current&&dt(e-Rt.current)},[p,d]),(0,n.useEffect)(()=>{a.onUnreadChange?.(x)},[x,a]),(0,n.useEffect)(()=>{let e=a.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>Ze(),e*60*1e3);return()=>clearTimeout(t)},[a.sessionDurationMinutes,p,d,Ze]),(0,n.useEffect)(()=>{let e=a.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),J()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[a.customLauncherSelector,J]);let pn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let e=a.proactiveMessage?.trim();if(!e||pn.current)return;let t=a.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${a.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(d||y||p.some(e=>e.role===`user`))){pn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}Ae(e),K()}},Math.max(0,a.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[a.proactiveMessage]),(0,n.useEffect)(()=>{let e=Lt.current;if(!d||!e)return;let t=p[p.length-1],n=Date.now()<$t.current;t?.role===`user`||Xt||n?(requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight}),R(!1),n&&Zt(!0)):R(!0)},[p,d,m,Xt]);let mn=(0,n.useRef)(!0);mn.current=Xt,(0,n.useEffect)(()=>{let e=Lt.current;if(!(!d||!e))return i(e,{isAtBottom:()=>mn.current,onUnseen:()=>R(!0)})},[d,G]);let hn=(0,n.useCallback)(()=>{let e=Lt.current;if(!e)return;if(O.current&&!G){Zt(!0),R(!1);return}let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;Zt(t),t&&R(!1)},[G]),Y=(0,n.useCallback)(()=>{let e=Lt.current;e&&(e.scrollTop=e.scrollHeight),R(!1),Zt(!0)},[]),gn=(0,n.useCallback)(()=>{$t.current=Date.now()+3e3,requestAnimationFrame(Y)},[Y]);(0,n.useEffect)(()=>{if(!d||G||!C||L===`connecting`)return;$t.current=Date.now()+6e4,Y();let e=requestAnimationFrame(()=>{Y(),requestAnimationFrame(Y)}),t=[80,180,360].map(e=>window.setTimeout(Y,e));return()=>{cancelAnimationFrame(e),t.forEach(e=>window.clearTimeout(e))}},[h,p,d,Y,m,C,G,L]);let _n=(0,n.useCallback)(()=>{D.current?.querySelector(`.cf-textarea`)?.focus()},[]),vn=(0,n.useCallback)((e,t)=>{mt(e),zt.current&&window.clearTimeout(zt.current),zt.current=window.setTimeout(()=>mt(null),3e3),t&&!k.current&&Qe(t)},[Qe]),yn=(0,n.useCallback)(e=>{let t=N.current;if(t)return t;gn();let n=Me(e);return N.current=n,v(n,{content:P.current||e,pending:!0,streaming:!1}),n},[Me,gn,v]),X=(0,n.useCallback)(()=>{let e=N.current;if(e){if(P.current){v(e,{content:P.current,pending:!0});return}N.current=null,Ne(e)}},[v,Ne]),Z=(0,n.useCallback)(()=>{I.current&&(I.current=!1,Ce(!1)),F.current&&(F.current=!1,Se())},[Ce,Se]),Q=(0,n.useCallback)(()=>{O.current=!1,A.current?.stop(`call-ended`),A.current=null,F.current=!1,I.current=!1,k.current=!1,Vt.current=null,M.current=!1;let e=N.current;N.current=null,P.current=``,e&&Ne(e),zt.current&&window.clearTimeout(zt.current),mt(null),gt(!1),ft({mic:`off`,processing:!1}),Ct(0),_t(!1),yt(!1),xt(!1),T(!1),E(null),b()},[Ne,b]),bn=(0,n.useCallback)(()=>{w&&E(null),T(!w)},[w]),xn=(0,n.useCallback)(e=>{E(e),T(!0)},[]),Sn=(0,n.useCallback)(e=>{Et(e),T(!0)},[]),Cn=(0,n.useCallback)(()=>{let e=wt,t=Tt;E(null),Et(null),T(!1),window.requestAnimationFrame(()=>{(t?D.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(D.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[wt,Tt]),wn=(0,n.useCallback)(()=>{E(null),Et(null),T(!1)},[]),Tn=(0,n.useCallback)((e,t,n=!1)=>{if(gn(),t&&(v(t,{content:e,pending:!1,streaming:!1}),N.current===t&&(N.current=null)),P.current=``,n){b(),Kt.current(e,{forceVoicePlayback:!0,userMessageId:t});return}O.current&&(xe()?Kt.current(e,{forceVoicePlayback:!0,userMessageId:t}):Gt.current(e,{forceVoicePlayback:!0,userMessageId:t}))},[gn,xe,v,b]),$=(0,n.useCallback)(e=>{Ae(e),Qe(e)},[Ae,Qe]),En=(0,n.useCallback)(()=>{if(j.current=Date.now(),mt(null),Yt.current){I.current=!0,Ce(!0);return}F.current||(F.current=xe()),yn(`Listening...`)},[Ce,yn,xe]),Dn=(0,n.useCallback)(e=>{let t=N.current;!t||I.current||v(t,{content:`${[P.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[v]),On=(0,n.useCallback)(t=>{j.current=Date.now();let n=[P.current,t.text].map(e=>e.trim()).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();if((I.current||t.overlappedOutput)&&e.V(t.text,Jt.current)){X(),Z();return}if(!n||e.m(n)||e.h(n)){let e=I.current||F.current;X(),Z(),e||vn(`misunderstood`);return}I.current&&(I.current=!1,ye(),b());let r=Vt.current;if(r){P.current=``,X();let e=ie(n);if(oe.test(e)||r===`end`&&ce.test(e)){Vt.current=null,Ht.current(r);return}if(se.test(e)){Vt.current=null,$(`Okay, never mind — what would you like to know?`);return}$(ue(r));return}let i=le(n);if(i){if(P.current=``,X(),Z(),i.confident){Ht.current(i.action);return}Vt.current=i.action,$(`Just to confirm — you want me to ${re[i.action]}? Please say yes or no.`);return}let a=yn(n);v(a,{content:n,pending:!0});let o=F.current;F.current=!1,Tn(n,a,o)},[yn,v,Z,Tn,X,vn,$,ye,b]),kn=(0,n.useCallback)(e=>{j.current=Date.now();let t=I.current||F.current;if(X(),Z(),!(t||e.overlappedOutput||e.reason===`too-short`)){if(e.reason===`transcribe-failed`){vn(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`);return}vn(`noise`)}},[Z,X,vn]),An=(0,n.useRef)({speechStart:En,partial:Dn,turn:On,noise:kn});An.current={speechStart:En,partial:Dn,turn:On,noise:kn};let jn=(0,n.useCallback)(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{Ot(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||`Microphone ${t+1}`})))}).catch(()=>{})},[]),Mn=(0,n.useCallback)(()=>{if(O.current){Q();return}if(_n(),!f?.allowVoiceInput||!f.talkbackMode||f.talkbackMode===`text`||Wt.current||y||G)return;j.current=Date.now(),k.current=!1,O.current=!0,xt(!1),_t(!0),yt(!1),gt(!1);let t=!1,n=new e.B({deviceId:Ut.current||void 0,transcribe:async({audio:t,mimeType:n,durationSeconds:r})=>{let i=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return e.g(await qt.current(t,n,i,r))},listener:{state:e=>{ft(e),e.mic!==`starting`&&e.mic!==`off`&&yt(!0),!t&&e.mic===`listening`&&(t=!0,jn())},speechStart:()=>An.current.speechStart(),partial:({text:e})=>An.current.partial(e),turn:e=>An.current.turn(e),noise:e=>An.current.noise(e),level:e=>{let t=performance.now();t-Bt.current<90||(Bt.current=t,Ct(e))}}});A.current=n,n.setOutputActive(Yt.current),n.start()},[Q,y,_n,f,jn,G]),Nn=(0,n.useCallback)(()=>{let e=!k.current;k.current=e,xt(e),A.current?.setMuted(e),e?(P.current=``,X(),Z()):j.current=Date.now()},[Z,X]),Pn=(0,n.useCallback)(e=>{switch(j.current=Date.now(),e){case`end`:M.current=!0,$(`Okay — ending our call now. Goodbye!`),window.setTimeout(()=>{M.current&&(M.current=!1,Q())},2e3);break;case`mute`:k.current||Nn(),$(`Muted. Tap the mic button when you want me to listen again.`);break;case`minimize`:q(),$(`Minimized — I'm still listening. Tap the call pill to bring the chat back.`);break;case`expand`:T(!0),$(`Sure — expanding the view.`);break;case`shrink`:E(null),T(!1),$(`Okay — back to the smaller view.`);break}},[q,Q,$,Nn]);(0,n.useEffect)(()=>{Ht.current=Pn},[Pn]);let Fn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Fn.current&&!h&&M.current&&(M.current=!1,Q()),Fn.current=h},[h,Q]);let In=(0,n.useCallback)(e=>{Ut.current=e,At(e),A.current?.selectDevice(e||void 0)},[]),Ln=(0,n.useCallback)(()=>{!O.current||k.current||(I.current=!1,F.current=!1,ye(),b(),j.current=Date.now())},[ye,b]);(0,n.useEffect)(()=>{A.current?.setOutputActive(h),j.current=Date.now()},[h]),(0,n.useEffect)(()=>{if(L!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,L]),(0,n.useEffect)(()=>{if(!C)return;let e=window.setInterval(()=>{let e=A.current;!e||k.current||Wt.current||Yt.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-j.current<6e4||(A.current?.log.add(`call-timeout`),gt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,C]);let Rn=C&&!bt&&(m||h);(0,n.useEffect)(()=>()=>Q(),[Q]);let[zn,Bn]=(0,n.useState)(``),Vn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(Vn.current&&!m){let e=[...p].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&Bn(e.content)}Vn.current=m},[m,p]),(0,n.useLayoutEffect)(()=>{if(!d)return;let e=D.current,t=z||V?e?.querySelector(`.cf-confirm__card`):U?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[V,z,d,U]),(0,n.useEffect)(()=>{if(!d)return;let e=D.current,t=z||V?e?.querySelector(`.cf-confirm__card`):U?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=rn.current;if(t.confirmEnd){B(!1);return}if(t.confirmClear){H(!1);return}if(t.showHistory){W(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;q();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[d,q,z,V,U]),(0,n.useEffect)(()=>{let e=D.current;e&&(d?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[d]);let Hn=a.accentColor??a.themeTokens?.accent??f?.accentColor,Un=a.themeTokens?.accentText??te(Hn,a.themeTokens?.background??(Nt===`dark`?`#0f1c27`:`#ffffff`)),Wn={zIndex:a.zIndex,"--cf-h-pad":`${a.horizontalPadding}px`,"--cf-v-pad":`${a.verticalPadding}px`,...Un?{"--cf-accent-ink":Un}:{},...a.themeTokens?.accentStrong?{"--cf-accent-2":a.themeTokens.accentStrong}:{},...a.themeTokens?.background?{"--cf-bg":a.themeTokens.background}:{},...a.themeTokens?.surface?{"--cf-surface":a.themeTokens.surface}:{},...a.themeTokens?.surfaceMuted?{"--cf-surface-2":a.themeTokens.surfaceMuted}:{},...a.themeTokens?.text?{"--cf-text":a.themeTokens.text}:{},...a.themeTokens?.mutedText?{"--cf-muted":a.themeTokens.mutedText}:{},...a.themeTokens?.border?{"--cf-border":a.themeTokens.border}:{},...a.themeTokens?.shadow?{"--cf-shadow":a.themeTokens.shadow}:{},...a.themeTokens?.radius?{"--cf-radius":a.themeTokens.radius}:{},...a.themeTokens?.fontFamily?{"--cf-font":a.themeTokens.fontFamily}:{},...a.themeTokens?.success?{"--cf-success":a.themeTokens.success}:{},...a.themeTokens?.warning?{"--cf-warning":a.themeTokens.warning}:{},...a.themeTokens?.danger?{"--cf-danger":a.themeTokens.danger}:{},...Hn?{"--cf-accent":Hn,"--cf-accent-2":a.themeTokens?.accentStrong??`color-mix(in oklab, ${Hn} 76%, #14141f)`}:{}},Gn=e=>_(e),Kn=[...p].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,qn=p.some(e=>e.role===`user`),Jn=!!(f?.allowVoiceInput&&f?.talkbackMode&&f.talkbackMode!==`text`),Yn=Jn,Xn=!G&&Yn&&!qn?sn.filter((e,t)=>!(t===0&&e.role===`assistant`)):sn,Zn=g===`human`&&pe?pe:f?.agentName??u.chatName,Qn=g===`human`?u.liveSupport:g===`queued`?u.waitingForTeam:f?.offline?u.statusOffline:u.statusOnline,$n=!y&&!G?f?.availableActions:void 0,er=!y&&!G?f?.actions:void 0,tr=C&&!vt&&L===`connecting`&&!G;return(0,r.jsx)(e.G,{value:u,children:(0,r.jsx)(e.W,{value:a.locale,children:(0,r.jsxs)(`div`,{class:`cf-root`,dir:a.dir,"data-theme":Nt,"data-align":a.alignment,"data-display":`floating`,style:Wn,children:[w&&d&&(0,r.jsx)(`div`,{class:`cf-theater-backdrop`,onClick:wn}),(0,r.jsxs)(`div`,{ref:D,class:`cf-panel ${d?`is-open`:``} ${C?`cf-panel--call`:``} ${tr?`cf-panel--voice-connecting`:``} ${w&&d?`cf-panel--theater`:``} ${cn||ln?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${u.chatName}: ${f?.agentName??u.assistantName}`,"aria-hidden":!d,children:[rt&&d&&(0,r.jsx)(o,{state:rt,onClose:lt}),(0,r.jsxs)(`div`,{class:`cf-header`,children:[(0,r.jsx)(e.y,{persona:f,hideWhenMissing:!0}),(0,r.jsxs)(`div`,{class:`cf-header__meta`,children:[(0,r.jsx)(`div`,{class:`cf-header__name`,children:Zn}),a.token.startsWith(`pub_test_`)?(0,r.jsx)(`small`,{role:`status`,children:u.testMode}):null,(0,r.jsx)(`div`,{class:`cf-header__status ${g===`ai`&&f?.offline?`cf-header__status--offline`:``}`,children:(0,r.jsx)(`span`,{class:`cf-header__status-text`,children:Qn})})]}),(0,r.jsxs)(`div`,{class:`cf-header__actions`,children:[Ke.length>0&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.pastConversations,title:u.pastConversations,"aria-pressed":U,onClick:()=>W(e=>!e),children:(0,r.jsx)(e.N,{})}),qn&&!y&&!G&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.endChat,title:u.endChat,onClick:un,children:(0,r.jsx)(e.M,{})}),a.sound&&Pt&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":jt?u.unmuteSounds:u.muteSounds,"aria-pressed":jt,onClick:Ft,children:jt?(0,r.jsx)(e.P,{}):(0,r.jsx)(e.F,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":u.closeChat,onClick:q,children:(0,r.jsx)(e.j,{})})]})]}),(0,r.jsx)(`div`,{class:`cf-panel__video`,children:cn?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:(0,r.jsx)(e.D,{visualization:cn,expanded:!0,onFollowUp:e=>{Cn(),_(e)},onClose:Cn})}):ln?.visualization?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:(0,r.jsx)(e.E,{visualization:ln.visualization,onClose:Cn,onFollowUp:e=>{Cn(),_(e)},onFeedback:G?void 0:Oe,transport:G?void 0:ke(`widget`),onOpenSource:a.onOpenAnalyticsSource})}):!G&&Yn?(0,r.jsx)(e.b,{persona:f,starters:[],onPick:_,onFocusComposer:Mn,speaking:h,voiceState:L,replyPending:C&&m&&!h,pinned:!0,muted:bt,onToggleMute:Nn,onEndCall:Q,onTalkNow:Ln,showTalkNow:Rn,micLevel:St,theaterMode:w,onToggleTheater:bn,onMinimize:q,audioDevices:Dt,selectedAudioDeviceId:kt,onSelectAudioDevice:In,connectingOnly:tr}):null}),!tr&&(0,r.jsxs)(`div`,{class:`cf-panel__chat`,children:[a.preview&&(0,r.jsx)(`div`,{class:`cf-preview-banner`,children:u.previewBanner}),G&&(0,r.jsx)(`div`,{class:`cf-viewing-banner`,children:u.viewingPast}),(0,r.jsxs)(`div`,{class:`cf-body`,ref:Lt,role:`log`,onScroll:hn,children:[Xn.map((t,n)=>(0,r.jsx)(e.w,{msg:t,persona:f,isLast:!G&&n===Xn.length-1,visitor:de,hasEmail:fe,lastQuestion:Kn,showActions:!G&&n===Xn.length-1&&!!(t.handoffOffered||t.selectedAction),onPickReply:Gn,onSubmitForm:Fe,onDemoSlots:Ve,onConfirmHostedBooking:Ie,onRetry:we,ratable:!G&&Xn.slice(0,n).some(e=>e.role===`user`),onRate:Te,onDoubleCheck:G||y?void 0:Ee,onRetryResponse:G||y||g!==`ai`?void 0:De,doubleCheckDisabled:m,onExplanationFeedback:G?void 0:Oe,explanationTransport:G?void 0:ke(`widget`),onOpenAnalyticsSource:a.onOpenAnalyticsSource,onExpandVisualization:G?void 0:xn,onExpandExplanation:G?void 0:Sn,onOpenAttachment:st,onReconnect:!G&&!y&&ut&&t.id===nt?je:void 0},t.id)),!qn&&!G&&(0,r.jsxs)(r.Fragment,{children:[Xn.length===0&&(0,r.jsx)(s,{name:f?.agentName??u.assistantName,greeting:f?.greeting}),(0,r.jsx)(e.T,{items:he,onPick:_}),(0,r.jsx)(e.S,{items:ge})]}),Qt&&(0,r.jsxs)(`button`,{type:`button`,class:`cf-newmsg`,onClick:Y,children:[(0,r.jsx)(e.k,{}),u.newMessages]})]}),(0,r.jsx)(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:zn}),m&&!y&&!G&&(0,r.jsx)(`div`,{class:`cf-stopbar`,children:(0,r.jsxs)(`button`,{type:`button`,class:`cf-stop`,onClick:ye,children:[(0,r.jsx)(e.I,{}),u.stop]})}),G?(0,r.jsx)(`div`,{class:`cf-ended`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Xe,children:u.backToChat})}):y?(0,r.jsxs)(`div`,{class:`cf-ended`,children:[(0,r.jsx)(`p`,{class:`cf-ended__text`,children:u.conversationEnded}),a.csat&&qn?an?(0,r.jsx)(`p`,{class:`cf-ended__text`,children:u.feedbackThanks}):(0,r.jsxs)(`div`,{class:`cf-csat`,children:[(0,r.jsx)(`span`,{class:`cf-csat__q`,children:u.csatPrompt}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackHelpful,onClick:()=>{Pe(`up`),on(!0)},children:(0,r.jsx)(e.R,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackNotHelpful,onClick:()=>{Pe(`down`),on(!0)},children:(0,r.jsx)(e.L,{})})]}):null,(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:fn,children:u.startNewChat})]}):(0,r.jsxs)(r.Fragment,{children:[me?(0,r.jsx)(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:e.K(u.agentTyping,{name:me})}):null,$n&&$n.length>0&&(0,r.jsx)(`div`,{class:`cf-footer-actions`,children:(0,r.jsx)(e.v,{actions:$n,descriptors:er,visitor:de,onSubmitForm:Fe,onDemoSlots:Ve,onConfirmHostedBooking:Ie,scheduler:f?.scheduler,translations:a.actionTranslations})},`footer-actions`),(0,r.jsx)(e.x,{toolbarContent:a.showAnalyticsModelSelector?(0,r.jsx)(e.U,{models:$e,value:et,onChange:tt,disabled:m}):null,draftStore:nn,onSend:_,onSendGif:_e,onTyping:ve,disabled:m,allowVoice:Jn&&a.composer?.voice!==!1,onTranscribe:Le,gifEnabled:He,onSearchGifs:Be,allowAttach:a.attachments,analyzeAttachments:!0,onUpload:Re,onPreviewAttachment:ct},`composer`)]}),!y&&f?.disclaimerText&&(0,r.jsx)(`div`,{class:`cf-disclaimer`,children:f.disclaimerText}),(0,r.jsxs)(`div`,{class:`cf-footer`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":u.clearDeviceData,onClick:()=>H(!0),children:u.privacyAndData}),(0,r.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),u.poweredBy,` `,(0,r.jsx)(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),z&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>B(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>B(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:u.endChatConfirm}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:u.endChatConfirmBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{ref:en,type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>B(!1),children:u.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:dn,children:u.endConfirmCta})]})]})},`confirm-end`),U&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>W(!1),children:(0,r.jsxs)(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":u.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>W(!1)),children:[(0,r.jsxs)(`div`,{class:`cf-history__head`,children:[(0,r.jsx)(`span`,{children:u.pastConversations}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.closeHistory,onClick:()=>W(!1),children:(0,r.jsx)(e.j,{})})]}),(0,r.jsx)(`div`,{class:`cf-history__list`,children:Ke.map(e=>(0,r.jsxs)(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===qe?`is-active`:``}`,onClick:()=>{Ye(e.sessionId),W(!1)},children:[(0,r.jsx)(`span`,{class:`cf-history__title`,children:e.title}),(0,r.jsxs)(`span`,{class:`cf-history__meta`,children:[new Date(e.ts).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),e.ended?` · ${u.historyEnded}`:``]})]},e.sessionId))}),(0,r.jsx)(`div`,{class:`cf-history__footer`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{W(!1),H(!0)},children:u.clearDeviceData})})]})},`history`),V&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>H(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>c(e,e.currentTarget,()=>H(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:u.clearDeviceData}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:u.clearDeviceDataBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>H(!1),children:u.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{H(!1),Ze()},children:u.clearDeviceDataCta})]})]})},`confirm-clear`)]}),C&&!d?(0,r.jsx)(e.C,{persona:f,voiceState:L,muted:bt,onToggleMute:Nn,onEndCall:Q,micLevel:St,onExpand:K}):w&&d?null:!a.hideDefaultLauncher&&(0,r.jsxs)(`button`,{ref:It,type:`button`,class:`cf-launcher`,"aria-label":d?u.closeChat:x>0?`${u.openChat}. ${x===1?u.unreadMessage:e.K(u.unreadMessages,{count:String(x)})}`:u.openChat,"aria-expanded":d,onClick:J,children:[a.launcherIcon?(0,r.jsx)(`img`,{class:`cf-launcher__img`,src:a.launcherIcon,alt:``}):(0,r.jsx)(e.A,{}),!d&&x>0&&(0,r.jsx)(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:x>99?`99+`:x})]})]})})})},p=`centrinfo-widget`;var m=class extends HTMLElement{constructor(...t){super(...t),e.tt(this,`controls`,null),e.tt(this,`composerDraftStore`,{value:``})}mountWith(n){let i=e.n(n),a=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(i.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let t=new CSSStyleSheet;t.replaceSync(e.t),a.adoptedStyleSheets=[t]}else{let t=document.createElement(`style`);i.styleNonce&&(t.nonce=i.styleNonce),t.textContent=e.t,a.appendChild(t)}(0,t.render)((0,r.jsx)(f,{transport:e.et(i),config:i,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore}),a)}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.shadowRoot&&(0,t.render)(null,this.shadowRoot)}};typeof customElements<`u`&&!customElements.get(p)&&customElements.define(p,m);const h=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(p);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),destroy:()=>{n.unmount(),n.remove()}}},de=e=>h(e);let fe=null;const g=e=>{fe?.destroy();let t=de(e);return fe=t,t},pe={init:g,createWidget:de};exports.Centrinfo=pe,exports.createWidget=de,exports.init=g;
1
+ const e=require(`./styles-BWPJrttg.cjs`);let t=require(`preact`),n=require(`preact/hooks`),r=require(`preact/jsx-runtime`);const i=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom()||n-e.scrollTop-e.clientHeight<80;n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`style`,`height`]}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},a={en:[`Still working on that, one moment.`,`Nearly there, thanks for waiting.`,`Still on it, just a little longer.`],fr:[`Je m’en occupe toujours, un instant.`,`Presque fini, merci de patienter.`,`Toujours en cours, encore un petit moment.`],es:[`Sigo con ello, un momento.`,`Ya casi está, gracias por esperar.`,`Todavía en ello, solo un poco más.`],pt:[`Ainda estou a tratar disso, um momento.`,`Quase pronto, obrigado por esperar.`,`Continuo nisso, só mais um pouco.`],de:[`Ich arbeite noch daran, einen Moment.`,`Fast fertig, danke fürs Warten.`,`Bin noch dran, nur noch kurz.`],it:[`Ci sto ancora lavorando, un momento.`,`Quasi fatto, grazie per l’attesa.`,`Ancora un attimo, ci sono quasi.`],ar:[`ما زلت أعمل على ذلك، لحظة من فضلك.`,`اقتربنا، شكرًا على انتظارك.`,`ما زلت أتابع، لحظات قليلة فقط.`],sw:[`Bado ninashughulikia hilo, subiri kidogo.`,`Karibu tayari, asante kwa kusubiri.`,`Bado niko kazini, muda mfupi tu.`]},o=e=>a[(e??``).replace(`_`,`-`).split(`-`)[0].trim().toLowerCase()]??a.en,s=(e,t)=>{let n=globalThis.speechSynthesis;if(!n||typeof SpeechSynthesisUtterance>`u`)return null;let r=new SpeechSynthesisUtterance(e);t&&(r.lang=t);let i=!1,a=new Promise(e=>{r.onend=r.onerror=()=>{i=!0,e()}});return n.speak(r),{done:a,stop:()=>{!i&&!n.pending&&n.cancel()}}},c=6e4,l=[`mute`,`end`,`wait`,`resume`],ee=2e3,u=2e4,d=5e3,f=250,p=6e3,te=14e3,ne=3,m={mic:`off`,processing:!1};var re=class{constructor(t){this.options=t,e.vt(this,`engine`,null),e.vt(this,`snapshot`,m),e.vt(this,`muted`,!1),e.vt(this,`partialText`,``),e.vt(this,`queue`,[]),e.vt(this,`overAnswer`,!1),e.vt(this,`overPending`,!1),e.vt(this,`answerEchoes`,!1),e.vt(this,`spokenAnswer`,``),e.vt(this,`lastActivity`,0),e.vt(this,`idleTimer`,null),e.vt(this,`outputActive`,!1),e.vt(this,`lastStateKey`,``),e.vt(this,`delivering`,null),e.vt(this,`ending`,null),e.vt(this,`waiting`,!1),e.vt(this,`progressTimer`,null),e.vt(this,`answeringSince`,0),e.vt(this,`progressSpoken`,0),e.vt(this,`lastProgressAt`,0),e.vt(this,`progressSpeech`,null),e.vt(this,`progressHeard`,[])}static supported(){return e.K()}get active(){return this.engine!==null}get voiceEngine(){return this.engine}get state(){let{chat:e}=this.options,t=this.engine!==null,n=t&&this.answering(),r=t&&e.speaking(),i=this.snapshot,a=this.muted||i.mic===`muted`;return{active:t,phase:t?i.mic===`off`||i.mic===`starting`?`connecting`:i.mic===`unavailable`?`unavailable`:a?r?`speaking`:n||this.queue.length?`thinking`:`muted`:i.mic===`hearing`?`hearing`:r?`speaking`:this.waiting?`waiting`:n||this.queue.length?`thinking`:i.processing?`transcribing`:`listening`:`off`,mic:i,muted:a,partial:this.partialText,queued:this.queue.map(e=>e.text),answerPending:n||this.queue.length>0,waiting:t&&this.waiting,stillWorking:t&&this.stillWorking(),reason:i.mic===`unavailable`?i.reason:void 0}}async start(){if(this.engine)return;let{options:t}=this;this.lastActivity=Date.now(),this.muted=!1,this.partialText=``,this.queue=[],this.overAnswer=!1,this.overPending=!1,this.waiting=!1,this.snapshot={mic:`starting`,processing:!1};let n=new e.G({live:t.live?{...t.live,controls:this.controls,delegate:(e,n)=>(this.touch(),t.live.delegate(e,n,{waiting:this.waiting}))}:void 0,transcribe:t.transcribe,deviceId:t.deviceId,endSilenceMs:t.endSilenceMs,media:t.media,listener:{speaking:e=>t.events?.liveSpeaking?.(e),state:e=>{this.engine===n&&this.onState(e)},speechStart:()=>{this.engine===n&&this.onSpeechStart()},partial:({text:e})=>{this.engine===n&&this.onPartial(e)},turn:e=>{this.engine===n&&this.onTurn(e)},noise:e=>{this.engine===n&&this.onDropped(e.reason,e.overlappedOutput)},level:e=>t.events?.level?.(e),control:e=>{this.engine===n&&this.control(e)}}});this.engine=n,this.outputActive=t.chat.speaking(),n.setOutputActive(this.outputActive),this.startIdleTimer(),this.startProgressTimer(),this.emit(!0),await n.start()}end(e=`user`){let t=this.engine;if(!t)return;this.engine=null,t.stop(`conversation-${e}`),this.idleTimer&&clearInterval(this.idleTimer),this.idleTimer=null;let{chat:n}=this.options;(this.delivering!==null||n.busy())&&n.cancel(),this.delivering&&clearTimeout(this.delivering),this.delivering=null,this.ending&&clearInterval(this.ending),this.ending=null,this.stopProgress(!0),this.waiting=!1,n.silence(),this.overAnswer=!1,this.overPending=!1,this.answerEchoes=!1,this.queue=[],this.partialText=``,this.muted=!1,this.snapshot=m,this.options.events?.ended?.(e),this.emit(!0)}setMuted(e){let t=this.engine;t&&(this.muted=e,t.setMuted(e),e?(this.partialText=``,t.snapshot.processing||this.release()):this.touch(),this.emit(!0))}toggleMute(){this.setMuted(!this.state.muted)}finishTurn(){this.engine?.finishTurn()}interrupt(){if(!this.engine)return;this.engine.interrupt(),this.overAnswer=!1,this.overPending=!1;let{chat:e}=this.options;e.cancel(),e.silence(),this.touch(),this.sync()}get controls(){return this.options.controls??l}control(t){let n=e.q(t,this.controls),r=this.engine;return!n||!r?null:(r.log.add(`voice-control`,{action:n}),this.touch(),n===`mute`?this.setMuted(!0):n===`end`?this.endAfterAnswer():n===`wait`?this.waiting=!0:n===`resume`&&(this.waiting=!1),this.options.events?.control?.(n),this.emit(!0),n)}wait(){!this.engine||this.waiting||(this.waiting=!0,this.touch(),this.emit(!0))}resume(){!this.engine||!this.waiting||(this.waiting=!1,this.touch(),this.emit(!0))}endAfterAnswer(){if(this.ending)return;let e=Date.now(),t=!1;this.ending=setInterval(()=>{if(!this.engine)return;let{chat:n}=this.options,r=n.speaking();r&&(t=!0);let i=Date.now()-e;(!r&&!this.answering()&&(t||i>=2e3)||i>=2e4)&&this.end(`user`)},200)}async selectDevice(e){await this.engine?.selectDevice(e)}sync(){if(!this.engine)return;let{chat:e}=this.options;this.delivering&&(e.busy()||e.speaking())&&(clearTimeout(this.delivering),this.delivering=null);let t=e.speaking();t&&this.rememberSpokenAnswer(),(t||!this.answering())&&this.stopProgress(),t!==this.outputActive&&!this.progressSpeech&&(this.outputActive=t,this.answerEchoes=!1,this.engine.setOutputActive(t),this.touch()),this.flush(),this.emit()}answering(){return this.delivering!==null||this.options.chat.busy()}rememberSpokenAnswer(){let e=this.options.chat.lastAnswer();e.trim()&&(this.spokenAnswer=e)}isEcho(t){return e.Y(t,this.options.chat.lastAnswer())||!!(this.spokenAnswer&&e.Y(t,this.spokenAnswer))||this.progressHeard.some(n=>e.Y(t,n))}touch(){this.lastActivity=Date.now()}flush(){let{chat:e}=this.options;if(!this.engine||!this.queue.length||this.answering()||e.speaking())return;let t=this.queue.shift();this.touch(),this.delivering=setTimeout(()=>{this.delivering=null,this.sync()},400),e.deliver(t.text,t.token,{waiting:this.waiting})}release(){return!this.overAnswer&&!this.overPending?!1:(this.overAnswer=!1,this.overPending=!1,this.options.chat.duck(!1),!0)}onState(e){if(this.snapshot=e,(e.mic===`muted`||e.mic===`listening`||e.mic===`hearing`)&&(this.muted=e.mic===`muted`),e.mic===`off`){this.end(`mic-off`);return}e.mic!==`hearing`&&!e.processing&&this.release(),this.emit()}onSpeechStart(){this.touch();let{chat:e}=this.options,t=e.speaking(),n=e.busy();t?(this.rememberSpokenAnswer(),this.overAnswer=!0,this.answerEchoes||e.duck(!0)):n&&(this.overPending=!0,e.duck(!0)),this.partialText=``,this.options.events?.speechStart?.({overAnswer:t,answerPending:n}),this.emit()}onPartial(e){this.touch(),!this.overAnswer&&(this.partialText=e,this.options.events?.partial?.(e),this.emit())}onDropped(e,t){this.touch(),this.partialText=``;let n=this.release();this.options.events?.dropped?.({reason:e,heldSomething:n,overlappedOutput:t}),this.emit()}onTurn(e){this.touch();let{chat:t,screen:n,intercept:r,events:i}=this.options,a=n?n(e.text):e.text.trim(),o=this.overAnswer||e.overlappedOutput;if(a&&o&&this.isEcho(a)){t.speaking()&&(this.answerEchoes=!0),this.onDropped(`echo`,e.overlappedOutput);return}if(!a){this.onDropped(`unusable`,e.overlappedOutput);return}if(this.partialText=``,r?.(a)){this.release(),this.emit();return}this.overAnswer||t.speaking()?(this.overAnswer=!1,this.overPending=!1,t.silence()):this.release();let s=this.answering()||this.queue.length>0,c=i?.heard?.(a,{queued:s});this.queue.push({text:a,token:c}),this.flush(),this.emit(!0)}stillWorking(){return this.answeringSince>0&&!this.waiting&&Date.now()-this.answeringSince>=(this.options.progress?.delayMs??6e3)}startProgressTimer(){this.progressTimer=setInterval(()=>this.checkProgress(),250)}checkProgress(){let e=this.engine;if(!e)return;let{chat:t}=this.options;if(!(this.answering()&&!t.speaking())){this.answeringSince&&(this.answeringSince=0,this.progressSpoken=0,this.stopProgress(),this.emit());return}let n=Date.now();this.answeringSince||(this.answeringSince=n);let r=this.options.progress??{},i=this.stillWorking(),a=r.repeatMs??14e3;i&&!this.progressSpeech&&!this.waiting&&!this.state.muted&&e.snapshot.mic!==`hearing`&&this.progressSpoken<(r.maxLines??3)&&(this.progressSpoken===0||n-this.lastProgressAt>=a)&&this.sayProgress(e),this.emit()}sayProgress(e){let t=this.options.progress??{},n=t.language?.(),r=t.lines?.().filter(e=>e.trim())??[],i=r.length?r:o(n),a=i[this.progressSpoken%i.length];this.progressSpoken+=1,this.lastProgressAt=Date.now(),this.progressHeard=[...this.progressHeard.slice(-5),a],e.log.add(`progress-line`,{index:this.progressSpoken}),this.options.events?.progress?.(a);let c=(t.say??s)(a,n);c&&(this.progressSpeech=c,e.setOutputActive(!0),c.done.then(()=>{this.progressSpeech===c&&(this.progressSpeech=null,this.engine&&this.engine.setOutputActive(this.outputActive))}))}stopProgress(e=!1){let t=this.progressSpeech;this.progressSpeech=null,t?.stop(),t&&this.engine&&this.engine.setOutputActive(this.options.chat.speaking()),e&&(this.progressTimer&&clearInterval(this.progressTimer),this.progressTimer=null,this.answeringSince=0,this.progressSpoken=0,this.progressHeard=[])}startIdleTimer(){let e=this.options.idleLimitMs??6e4;e&&(this.idleTimer=setInterval(()=>{let t=this.engine;if(!t)return;let{chat:n}=this.options,{mic:r,processing:i}=t.snapshot;this.state.muted||r===`hearing`||i||this.answering()||n.speaking()||this.queue.length||Date.now()-this.lastActivity<(this.waiting?e*5:e)||(t.log.add(`conversation-idle`),this.end(`idle`))},5e3))}emit(e=!1){let t=this.state,n=JSON.stringify(t);!e&&n===this.lastStateKey||(this.lastStateKey=n,this.options.events?.change?.(t))}};const ie=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,ae=({state:t,onClose:i})=>{let a=e.rt(),o=(0,n.useRef)(null);(0,n.useEffect)(()=>{o.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),i())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[i]);let s=t.status===`ready`?ie(t.mimeType):`other`;return(0,r.jsx)(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":e.nt(a.attachPreviewTitle,{name:t.name}),onClick:e=>{e.target===e.currentTarget&&i()},children:(0,r.jsxs)(`div`,{class:`cf-preview__frame`,children:[(0,r.jsxs)(`div`,{class:`cf-preview__bar`,children:[(0,r.jsx)(`span`,{class:`cf-preview__name`,title:t.name,children:t.name}),t.status===`ready`&&(0,r.jsx)(`a`,{class:`cf-preview__btn`,href:t.url,download:t.name,children:a.attachDownload}),(0,r.jsx)(`button`,{ref:o,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":a.attachPreviewClose,onClick:i,children:`✕`})]}),(0,r.jsxs)(`div`,{class:`cf-preview__body`,children:[t.status===`loading`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:a.attachPreviewLoading}),t.status===`error`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:a.attachPreviewFailed}),t.status===`ready`&&s===`image`&&(0,r.jsx)(`img`,{class:`cf-preview__image`,src:t.url,alt:t.name}),t.status===`ready`&&s===`pdf`&&(0,r.jsx)(`iframe`,{class:`cf-preview__pdf`,src:t.url,title:t.name}),t.status===`ready`&&s===`other`&&(0,r.jsx)(`p`,{class:`cf-preview__note`,children:a.attachPreviewUnsupported})]})]})})},oe=({name:t,greeting:n})=>{let i=e.rt();return(0,r.jsxs)(`section`,{class:`cf-empty-welcome`,"aria-label":e.nt(i.welcomeLabel,{name:t}),children:[(0,r.jsx)(`span`,{class:`cf-empty-welcome__eyebrow`,children:i.welcomeEyebrow}),(0,r.jsx)(`h2`,{children:t}),(0,r.jsx)(`p`,{children:n||i.welcomePrompt})]})},se=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],c=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),c.focus()):!e.shiftKey&&(o===c||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},h=new Map,ce=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},le=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(h.has(n))return h.get(n);let r=ce(e),i=ce(t)??[255,255,255,1];if(!r){h.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,c=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return h.set(n,c),c},ue=e=>{let[t,r]=(0,n.useState)(`light`);return(0,n.useEffect)(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>r(t.matches?`dark`:`light`);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),e===`auto`?t:e},de=6e4,g=90,fe=[`mute`,`end`,`minimize`,`expand`,`shrink`,`wait`,`resume`],pe=({transport:t,config:a,bindControls:o,composerDraftStore:s})=>{let c=a.strings,[l,ee]=(0,n.useState)(a.openByDefault),{persona:u,messages:d,sending:f,assistantSpeaking:p,visitor:te,hasEmail:ne,liveMode:m,assignedAgentName:ie,agentTypingName:h,starters:ce,featuredLinks:de,send:g,sendGif:pe,notifyTyping:me,stop:_,voiceForms:v,voiceReply:y,duckSpeaking:he,retry:ge,rateMessage:_e,doubleCheckResponse:ve,retryResponse:ye,rateExplanation:be,explanationTransport:xe,injectAssistant:Se,reconnectSupport:Ce,appendUserDraft:we,patchMessage:b,removeMessage:Te,submitCsat:Ee,submitForm:De,confirmHostedBooking:Oe,transcribe:ke,liveVoice:Ae,delegateVoice:je,setLiveSpeaking:Me,uploadAttachment:Ne,loadAttachment:Pe,searchGifs:Fe,demoSlots:Ie,gifEnabled:Le,identify:Re,ended:x,endConversation:ze,startNew:Be,history:Ve,viewingSessionId:He,viewMessages:Ue,openConversation:We,closeHistoryView:Ge,shutdown:S,stopSpeaking:C,speakAssistantText:Ke,analyticsModels:qe,analyticsModelId:Je,selectAnalyticsModel:Ye}=e.l(t,a,l),Xe=e.c(d,m),[w,Ze]=(0,n.useState)(null),T=(0,n.useRef)(0),Qe=(0,n.useCallback)((e,t,n)=>{n===T.current&&Ze({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),$e=(0,n.useCallback)((e,t,n)=>{let r=t.name,i=++T.current;Ze({status:`loading`,name:r}),Pe(e,t,n).then(e=>Qe(e,r,i),()=>{i===T.current&&Ze({status:`error`,name:r})})},[Pe,Qe]),et=(0,n.useCallback)((e,t)=>Qe(e,t,++T.current),[Qe]),tt=(0,n.useCallback)(()=>{T.current+=1,Ze(null)},[]);(0,n.useEffect)(()=>()=>{w?.status===`ready`&&URL.revokeObjectURL(w.url)},[w]);let nt=!!e.s(u?.actions),[E,rt]=(0,n.useState)(0),[it,at]=(0,n.useState)(null),ot=e.J(it),[D,st]=(0,n.useState)({mic:`off`,processing:!1}),[ct,lt]=(0,n.useState)(null),[ut,dt]=(0,n.useState)(!1),[O,ft]=(0,n.useState)(!1),[pt,mt]=(0,n.useState)(!1),[ht,gt]=(0,n.useState)(!1),[_t,vt]=(0,n.useState)(0),[k,A]=(0,n.useState)(!1),[j,M]=(0,n.useState)(null),[yt,bt]=(0,n.useState)(null),[xt,St]=(0,n.useState)([]),[Ct,wt]=(0,n.useState)(``),[N,Tt]=(0,n.useState)(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),Et=ue(a.theme),Dt=u?.soundEnabled??!0;(0,n.useEffect)(()=>{e.h(a.sound&&Dt&&!N)},[a.sound,Dt,N]);let Ot=(0,n.useCallback)(()=>{Tt(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),P=(0,n.useRef)(null),kt=(0,n.useRef)(null),At=(0,n.useRef)(null),jt=(0,n.useRef)(0),F=(0,n.useRef)(!1),I=(0,n.useRef)(!1),L=(0,n.useRef)(null),R=(0,n.useRef)(0),Mt=(0,n.useRef)(void 0),Nt=(0,n.useRef)(0),z=(0,n.useRef)(null),B=(0,n.useRef)(``),Pt=(0,n.useRef)(()=>{}),Ft=(0,n.useRef)(``),It=(0,n.useRef)(f),Lt=(0,n.useRef)(g);Lt.current=g;let Rt=(0,n.useRef)(ke);Rt.current=ke;let zt=(0,n.useRef)(y);zt.current=y;let Bt=(0,n.useRef)({liveVoice:Ae,delegateVoice:je,messages:d});Bt.current={liveVoice:Ae,delegateVoice:je,messages:d};let Vt=(0,n.useRef)(``);Vt.current=[...d].reverse().find(e=>e.role===`assistant`&&e.content.trim())?.content??``;let Ht=(0,n.useRef)(p);It.current=f||v.busy,Ht.current=p;let Ut=O?ut?`timeout`:ht||D.mic===`muted`?`muted`:D.mic===`unavailable`?D.reason===`permission-denied`||D.reason===`unsupported`?`denied`:`unavailable`:D.mic===`off`||D.mic===`starting`?`connecting`:D.mic===`hearing`?`hearing`:p?`speaking`:ot.waiting?`waiting`:ct??(D.processing||f||v.busy?`processing`:`listening`):`idle`;(0,n.useEffect)(()=>{v.setEnabled(O&&pt&&!x&&!He&&m===`ai`,L.current?.voiceEngine?.usingLiveAudio)},[v,O,pt,x,He,m]);let[Wt,Gt]=(0,n.useState)(!0),[Kt,V]=(0,n.useState)(!1),qt=(0,n.useRef)(!0);qt.current=Wt;let[H,U]=(0,n.useState)(!1),[W,G]=(0,n.useState)(!1),[K,q]=(0,n.useState)(!1),Jt=(0,n.useRef)({value:``}),Yt=s??Jt.current,Xt=(0,n.useRef)({confirmEnd:H,confirmClear:W,showHistory:K});Xt.current={confirmEnd:H,confirmClear:W,showHistory:K};let[Zt,Qt]=(0,n.useState)(!1),J=!!He,$t=J?Ue:d,en=$t.find(e=>e.id===j&&e.visualization)?.visualization,tn=$t.find(e=>e.id===yt&&e.visualization);(0,n.useEffect)(()=>{!yt||tn||(bt(null),A(!1))},[yt,tn]),(0,n.useEffect)(()=>{!j||en||(M(null),A(!1))},[en,j]);let Y=(0,n.useCallback)(()=>{ee(!0),rt(0),e.m(`open`),a.onOpen?.(),a.onShow?.()},[a]),X=(0,n.useCallback)(()=>{ee(!1),A(!1),M(null),a.onClose?.(),a.onHide?.(),kt.current?.focus()},[a]),nn=(0,n.useCallback)(()=>l?X():Y(),[l,Y,X]),rn=(0,n.useCallback)(()=>U(!0),[]),an=(0,n.useCallback)(()=>{ze(),U(!1)},[ze]),on=(0,n.useCallback)(()=>{Be(),V(!1),Gt(!0)},[Be]);(0,n.useEffect)(()=>{o({open:Y,close:X,toggle:nn,identify:Re,startNew:Be,endConversation:ze,shutdown:S})},[o,Y,X,nn,Re,Be,ze,S]),(0,n.useEffect)(()=>{let e=d.filter(e=>e.role===`assistant`&&!e.pending).length;if(l){jt.current=e;return}e>jt.current&&rt(e-jt.current)},[d,l]),(0,n.useEffect)(()=>{a.onUnreadChange?.(E)},[E,a]),(0,n.useEffect)(()=>{let e=a.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>S(),e*60*1e3);return()=>clearTimeout(t)},[a.sessionDurationMinutes,d,l,S]),(0,n.useEffect)(()=>{let e=a.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),nn()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[a.customLauncherSelector,nn]);let sn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let e=a.proactiveMessage?.trim();if(!e||sn.current)return;let t=a.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${a.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(l||x||d.some(e=>e.role===`user`))){sn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}Se(e),Y()}},Math.max(0,a.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[a.proactiveMessage]),(0,n.useEffect)(()=>{let e=At.current;if(!l||!e)return;let t=d[d.length-1];if(!O&&t?.role===`user`||Wt){let t=requestAnimationFrame(()=>{qt.current&&(e.scrollTop=e.scrollHeight)});return V(!1),()=>cancelAnimationFrame(t)}else V(!0)},[d,l,f,Wt,O]),(0,n.useEffect)(()=>{let e=At.current;if(!(!l||!e))return i(e,{isAtBottom:()=>qt.current,onUnseen:()=>V(!0)})},[l,J]);let cn=(0,n.useCallback)(()=>{let e=At.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;qt.current=t,Gt(t),t&&V(!1)},[]),ln=(0,n.useCallback)(()=>{let e=At.current;e&&(e.scrollTop=e.scrollHeight),qt.current=!0,V(!1),Gt(!0)},[]),un=(0,n.useCallback)(()=>{P.current?.querySelector(`.cf-textarea`)?.focus()},[]),dn=(0,n.useCallback)((e,t)=>{lt(e),Mt.current&&window.clearTimeout(Mt.current),Mt.current=window.setTimeout(()=>lt(null),3e3),t&&!I.current&&Ke(t)},[Ke]),fn=(0,n.useCallback)(e=>{let t=z.current;if(t)return t;let n=we(e);return z.current=n,b(n,{content:B.current||e,pending:!0,streaming:!1}),n},[we,b]),pn=(0,n.useCallback)(()=>{let e=z.current;if(e){if(B.current){b(e,{content:B.current,pending:!0});return}z.current=null,Te(e)}},[b,Te]),Z=(0,n.useCallback)(()=>{F.current&&_(),F.current=!1;let e=L.current;L.current=null,e?.end(`user`),I.current=!1;let t=z.current;z.current=null,B.current=``,t&&Te(t),Mt.current&&window.clearTimeout(Mt.current),lt(null),dt(!1),st({mic:`off`,processing:!1}),at(null),vt(0),ft(!1),mt(!1),gt(!1),A(!1),M(null),C()},[Te,_,C]),mn=(0,n.useCallback)(()=>{k&&M(null),A(!k)},[k]),hn=(0,n.useCallback)(e=>{M(e),A(!0)},[]),gn=(0,n.useCallback)(e=>{bt(e),A(!0)},[]),_n=(0,n.useCallback)(()=>{let e=j,t=yt;M(null),bt(null),A(!1),window.requestAnimationFrame(()=>{(t?P.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(P.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[j,yt]),vn=(0,n.useCallback)(()=>{M(null),bt(null),A(!1)},[]),yn=(0,n.useCallback)((e,t,n=!1)=>{t&&(b(t,{content:e,pending:!1,streaming:!1}),z.current===t&&(z.current=null)),B.current=``,F.current&&(_(),C(),!v.handleTranscript(e,t)&&Lt.current(e,{forceVoicePlayback:!0,userMessageId:t,voiceWaiting:n,onVoiceControl:e=>L.current?.control(e)}))},[b,_,C,v]),bn=(0,n.useCallback)(({overAnswer:e})=>{R.current=Date.now(),lt(null),e||fn(c.voiceDraftListening)},[fn,c.voiceDraftListening]),xn=(0,n.useCallback)(e=>{let t=z.current;t&&b(t,{content:`${[B.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[b]),Sn=(0,n.useCallback)(e=>{R.current=Date.now();let t=fn(e);return b(t,{content:e,pending:!0}),z.current===t&&(z.current=null),B.current=``,t},[fn,b]),Cn=(0,n.useCallback)(({reason:e,heldSomething:t,overlappedOutput:n})=>{R.current=Date.now(),pn(),!t&&(e===`unusable`?dn(`misunderstood`):e===`transcribe-failed`&&!n&&dn(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`))},[pn,dn]),Q=(0,n.useRef)({speechStart:bn,partial:xn,heard:Sn,dropped:Cn,deliver:yn,stop:_,stopSpeaking:C,duckSpeaking:he});Q.current={speechStart:bn,partial:xn,heard:Sn,dropped:Cn,deliver:yn,stop:_,stopSpeaking:C,duckSpeaking:he};let wn=(0,n.useCallback)(()=>{navigator.mediaDevices?.enumerateDevices().then(t=>{St(t.filter(e=>e.kind===`audioinput`).map((t,n)=>({deviceId:t.deviceId,label:t.label||e.nt(a.strings.microphoneNumbered,{number:String(n+1)})})))}).catch(()=>{})},[a]),Tn=(0,n.useCallback)(()=>{if(F.current){Z();return}if(un(),!u?.allowVoiceInput||!u.talkbackMode||u.talkbackMode===`text`||It.current||x||J)return;R.current=Date.now(),I.current=!1,F.current=!0,gt(!1),ft(!0),mt(!1),dt(!1);let t=!1,n=new re({chat:{busy:()=>It.current||zt.current.status===`answering`,speaking:()=>Ht.current,lastAnswer:()=>Vt.current,deliver:(e,t,n)=>Q.current.deliver(e,t,n.waiting),cancel:()=>Q.current.stop(),silence:()=>Q.current.stopSpeaking(),duck:e=>Q.current.duckSpeaking(e)},live:Bt.current.liveVoice?{transport:(e,t)=>Bt.current.liveVoice(e,t),delegate:async(e,t,n)=>(R.current=Date.now(),Bt.current.delegateVoice(e,t,n)),context:()=>Bt.current.messages.slice(-8).map(e=>`${e.role}: ${e.content}`).join(`
2
+ `)}:void 0,deviceId:Ft.current||void 0,transcribe:async({audio:t,mimeType:n,durationSeconds:r})=>{let i=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return e._(await Rt.current(t,n,i,r))},screen:e.v,controls:fe,progress:{language:()=>a.locale},idleLimitMs:0,events:{change:e=>{if(L.current!==n)return;let r=e.mic;at(e),I.current=e.muted,gt(e.muted),st(r),r.mic!==`starting`&&r.mic!==`off`&&mt(!0),!t&&r.mic===`listening`&&(t=!0,wn())},ended:()=>{L.current===n&&Z()},liveSpeaking:Me,control:e=>Pt.current(e),speechStart:e=>Q.current.speechStart(e),partial:e=>Q.current.partial(e),heard:e=>Q.current.heard(e),dropped:e=>Q.current.dropped(e),level:e=>{let t=performance.now();t-Nt.current<90||(Nt.current=t,vt(e))}}});L.current=n,n.start()},[a.locale,Z,x,un,u,wn,J,Me]),En=(0,n.useCallback)(()=>{let e=!I.current;I.current=e,gt(e);let t=L.current?.voiceEngine?.snapshot.processing;L.current?.setMuted(e),e&&!t?(B.current=``,pn()):e||(R.current=Date.now())},[pn]),Dn=(0,n.useCallback)(e=>{switch(R.current=Date.now(),e){case`minimize`:X();break;case`expand`:A(!0);break;case`shrink`:M(null),A(!1);break}},[X]);(0,n.useEffect)(()=>{Pt.current=Dn},[Dn]);let On=(0,n.useCallback)(e=>{Ft.current=e,wt(e),L.current?.selectDevice(e||void 0)},[]),kn=(0,n.useCallback)(()=>{!F.current||I.current||(L.current?.interrupt(),R.current=Date.now())},[]);(0,n.useEffect)(()=>{L.current?.sync(),R.current=Date.now()},[p]),(0,n.useEffect)(()=>{L.current?.sync()},[f,v.busy,y]),(0,n.useEffect)(()=>{if(Ut!==`denied`)return;let e=window.setTimeout(()=>Z(),3500);return()=>window.clearTimeout(e)},[Z,Ut]),(0,n.useEffect)(()=>{if(!O)return;let e=window.setInterval(()=>{let e=L.current?.voiceEngine;!e||(L.current?.state.queued.length??0)>0||I.current||It.current||Ht.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-R.current<6e4||(e.log.add(`call-timeout`),dt(!0),window.setTimeout(()=>Z(),2400))},5e3);return()=>window.clearInterval(e)},[Z,O]);let An=O&&!ht&&(f||p);(0,n.useEffect)(()=>()=>Z(),[Z]);let[jn,Mn]=(0,n.useState)(``),Nn=(0,n.useRef)(!1);(0,n.useEffect)(()=>{if(Nn.current&&!f){let e=[...d].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&Mn(e.content)}Nn.current=f},[f,d]),(0,n.useLayoutEffect)(()=>{if(!l)return;let e=P.current,t=H||W?e?.querySelector(`.cf-confirm__card`):K?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[W,H,l,K]),(0,n.useEffect)(()=>{if(!l)return;let e=P.current,t=H||W?e?.querySelector(`.cf-confirm__card`):K?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=Xt.current;if(t.confirmEnd){U(!1);return}if(t.confirmClear){G(!1);return}if(t.showHistory){q(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;X();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[l,X,H,W,K]),(0,n.useEffect)(()=>{let e=P.current;e&&(l?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[l]);let Pn=a.accentColor??a.themeTokens?.accent??u?.accentColor,Fn=a.themeTokens?.accentText??le(Pn,a.themeTokens?.background??(Et===`dark`?`#0f1c27`:`#ffffff`)),In={zIndex:a.zIndex,"--cf-h-pad":`${a.horizontalPadding}px`,"--cf-v-pad":`${a.verticalPadding}px`,...Fn?{"--cf-accent-ink":Fn}:{},...a.themeTokens?.accentStrong?{"--cf-accent-2":a.themeTokens.accentStrong}:{},...a.themeTokens?.background?{"--cf-bg":a.themeTokens.background}:{},...a.themeTokens?.surface?{"--cf-surface":a.themeTokens.surface}:{},...a.themeTokens?.surfaceMuted?{"--cf-surface-2":a.themeTokens.surfaceMuted}:{},...a.themeTokens?.text?{"--cf-text":a.themeTokens.text}:{},...a.themeTokens?.mutedText?{"--cf-muted":a.themeTokens.mutedText}:{},...a.themeTokens?.border?{"--cf-border":a.themeTokens.border}:{},...a.themeTokens?.shadow?{"--cf-shadow":a.themeTokens.shadow}:{},...a.themeTokens?.radius?{"--cf-radius":a.themeTokens.radius}:{},...a.themeTokens?.fontFamily?{"--cf-font":a.themeTokens.fontFamily}:{},...a.themeTokens?.success?{"--cf-success":a.themeTokens.success}:{},...a.themeTokens?.warning?{"--cf-warning":a.themeTokens.warning}:{},...a.themeTokens?.danger?{"--cf-danger":a.themeTokens.danger}:{},...Pn?{"--cf-accent":Pn,"--cf-accent-2":a.themeTokens?.accentStrong??`color-mix(in oklab, ${Pn} 76%, #14141f)`}:{}},Ln=e=>g(e),Rn=[...d].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,zn=d.some(e=>e.role===`user`),Bn=!!(u?.allowVoiceInput&&u?.talkbackMode&&u.talkbackMode!==`text`),$=!J&&Bn&&!zn?$t.filter((e,t)=>!(t===0&&e.role===`assistant`)):$t,Vn=m===`human`&&ie?ie:u?.agentName??c.chatName,Hn=m===`human`?c.liveSupport:m===`queued`?c.waitingForTeam:u?.offline?c.statusOffline:c.statusOnline,Un=!x&&!J?u?.availableActions:void 0,Wn=!x&&!J?u?.actions:void 0,Gn=O&&!pt&&Ut===`connecting`&&!J;return(0,r.jsx)(e.et,{value:c,children:(0,r.jsx)(e.H,{value:v,children:(0,r.jsx)(e.$,{value:a.locale,children:(0,r.jsxs)(`div`,{class:`cf-root`,dir:a.dir,"data-theme":Et,"data-align":a.alignment,"data-display":`floating`,style:In,children:[k&&l&&(0,r.jsx)(`div`,{class:`cf-theater-backdrop`,onClick:vn}),(0,r.jsxs)(`div`,{ref:P,class:`cf-panel ${l?`is-open`:``} ${O?`cf-panel--call`:``} ${Gn?`cf-panel--voice-connecting`:``} ${k&&l?`cf-panel--theater`:``} ${en||tn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${c.chatName}: ${u?.agentName??c.assistantName}`,"aria-hidden":!l,children:[w&&l&&(0,r.jsx)(ae,{state:w,onClose:tt}),(0,r.jsxs)(`div`,{class:`cf-header`,children:[(0,r.jsx)(e.b,{persona:u,hideWhenMissing:!0}),(0,r.jsxs)(`div`,{class:`cf-header__meta`,children:[(0,r.jsx)(`div`,{class:`cf-header__name`,children:Vn}),a.token.startsWith(`pub_test_`)?(0,r.jsx)(`small`,{role:`status`,children:c.testMode}):null,(0,r.jsx)(`div`,{class:`cf-header__status ${m===`ai`&&u?.offline?`cf-header__status--offline`:``}`,children:(0,r.jsx)(`span`,{class:`cf-header__status-text`,children:Hn})})]}),(0,r.jsxs)(`div`,{class:`cf-header__actions`,children:[Ve.length>0&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":c.pastConversations,title:c.pastConversations,"aria-pressed":K,onClick:()=>q(e=>!e),children:(0,r.jsx)(e.I,{})}),zn&&!x&&!J&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":c.endChat,title:c.endChat,onClick:rn,children:(0,r.jsx)(e.F,{})}),a.sound&&Dt&&(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":N?c.unmuteSounds:c.muteSounds,"aria-pressed":N,onClick:Ot,children:N?(0,r.jsx)(e.L,{}):(0,r.jsx)(e.R,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":c.closeChat,onClick:X,children:(0,r.jsx)(e.P,{})})]})]}),(0,r.jsx)(`div`,{class:`cf-panel__video`,children:en?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":c.expandedAnalyticsResult,children:(0,r.jsx)(e.A,{visualization:en,explanationTransport:J?void 0:xe(`widget`),onExplanationFeedback:J?void 0:be,onOpenAnalyticsSource:a.onOpenAnalyticsSource,expanded:!0,onFollowUp:e=>{_n(),g(e)},onClose:_n})}):tn?.visualization?(0,r.jsx)(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":c.expandedAnalyticsResult,children:(0,r.jsx)(e.k,{visualization:tn.visualization,onClose:_n,onFollowUp:e=>{_n(),g(e)},onFeedback:J?void 0:be,transport:J?void 0:xe(`widget`),onOpenSource:a.onOpenAnalyticsSource})}):!J&&Bn?(0,r.jsx)(e.S,{persona:u,starters:[],onPick:g,onFocusComposer:Tn,speaking:p,voiceState:Ut,replyPending:O&&f&&!p,pinned:!0,muted:ht,onToggleMute:En,onEndCall:Z,onTalkNow:kn,showTalkNow:An,micLevel:_t,theaterMode:k,onToggleTheater:mn,onMinimize:X,audioDevices:xt,selectedAudioDeviceId:Ct,onSelectAudioDevice:On,connectingOnly:Gn,answerStillComing:ot.answerStillComing,stillWorking:ot.stillWorking,onResume:()=>L.current?.resume()}):null}),!Gn&&(0,r.jsxs)(`div`,{class:`cf-panel__chat`,children:[a.preview&&(0,r.jsx)(`div`,{class:`cf-preview-banner`,children:c.previewBanner}),J&&(0,r.jsx)(`div`,{class:`cf-viewing-banner`,children:c.viewingPast}),(0,r.jsxs)(`div`,{class:`cf-body`,ref:At,role:`log`,onScroll:cn,children:[$.map((t,n)=>(0,r.jsx)(e.E,{msg:t,persona:u,isLast:!J&&n===$.length-1,visitor:te,hasEmail:ne,lastQuestion:Rn,showActions:!J&&n===$.length-1&&!!(t.handoffOffered||t.selectedAction),onPickReply:Ln,onSubmitForm:De,onDemoSlots:Ie,onConfirmHostedBooking:Oe,onRetry:ge,ratable:!J&&$.slice(0,n).some(e=>e.role===`user`),onRate:_e,onDoubleCheck:J||x?void 0:ve,onRetryResponse:J||x||m!==`ai`?void 0:ye,doubleCheckDisabled:f,onExplanationFeedback:J?void 0:be,explanationTransport:J?void 0:xe(`widget`),onOpenAnalyticsSource:a.onOpenAnalyticsSource,onExpandVisualization:J?void 0:hn,onExpandExplanation:J?void 0:gn,onOpenAttachment:$e,onReconnect:!J&&!x&&nt&&t.id===Xe?Ce:void 0},t.id)),!zn&&!J&&(0,r.jsxs)(r.Fragment,{children:[$.length===0&&(0,r.jsx)(oe,{name:u?.agentName??c.assistantName,greeting:u?.greeting}),(0,r.jsx)(e.O,{items:ce,onPick:g}),(0,r.jsx)(e.w,{items:de})]}),Kt&&(0,r.jsxs)(`button`,{type:`button`,class:`cf-newmsg`,onClick:ln,children:[(0,r.jsx)(e.M,{}),c.newMessages]})]}),(0,r.jsx)(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:jn}),f&&!x&&!J&&(0,r.jsx)(`div`,{class:`cf-stopbar`,children:(0,r.jsxs)(`button`,{type:`button`,class:`cf-stop`,onClick:_,children:[(0,r.jsx)(e.z,{}),c.stop]})}),J?(0,r.jsx)(`div`,{class:`cf-ended`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Ge,children:c.backToChat})}):x?(0,r.jsxs)(`div`,{class:`cf-ended`,children:[(0,r.jsx)(`p`,{class:`cf-ended__text`,children:c.conversationEnded}),a.csat&&zn?Zt?(0,r.jsx)(`p`,{class:`cf-ended__text`,children:c.feedbackThanks}):(0,r.jsxs)(`div`,{class:`cf-csat`,children:[(0,r.jsx)(`span`,{class:`cf-csat__q`,children:c.csatPrompt}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":c.feedbackHelpful,onClick:()=>{Ee(`up`),Qt(!0)},children:(0,r.jsx)(e.V,{})}),(0,r.jsx)(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":c.feedbackNotHelpful,onClick:()=>{Ee(`down`),Qt(!0)},children:(0,r.jsx)(e.B,{})})]}):null,(0,r.jsx)(`button`,{type:`button`,class:`cf-ended__btn`,onClick:on,children:c.startNewChat})]}):(0,r.jsxs)(r.Fragment,{children:[h?(0,r.jsx)(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:e.nt(c.agentTyping,{name:h})}):null,Un&&Un.length>0&&(0,r.jsx)(`div`,{class:`cf-footer-actions`,children:(0,r.jsx)(e.y,{actions:Un,descriptors:Wn,visitor:te,onSubmitForm:De,onDemoSlots:Ie,onConfirmHostedBooking:Oe,scheduler:u?.scheduler,translations:a.actionTranslations})},`footer-actions`),(0,r.jsx)(e.C,{toolbarContent:a.showAnalyticsModelSelector?(0,r.jsx)(e.Z,{models:qe,value:Je,onChange:Ye,disabled:f}):null,draftStore:Yt,onSend:g,onSendGif:pe,onTyping:me,disabled:f,allowVoice:!1,onTranscribe:ke,gifEnabled:Le,onSearchGifs:Fe,allowAttach:a.attachments,analyzeAttachments:!0,onUpload:Ne,onPreviewAttachment:et},`composer`)]}),!x&&u?.disclaimerText&&(0,r.jsx)(`div`,{class:`cf-disclaimer`,children:u.disclaimerText}),(0,r.jsxs)(`div`,{class:`cf-footer`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":c.clearDeviceData,onClick:()=>G(!0),children:c.privacyAndData}),(0,r.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),c.poweredBy,` `,(0,r.jsx)(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),H&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>U(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":c.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>se(e,e.currentTarget,()=>U(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:c.endChatConfirm}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:c.endChatConfirmBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>U(!1),children:c.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:an,children:c.endConfirmCta})]})]})},`confirm-end`),K&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>q(!1),children:(0,r.jsxs)(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":c.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>se(e,e.currentTarget,()=>q(!1)),children:[(0,r.jsxs)(`div`,{class:`cf-history__head`,children:[(0,r.jsx)(`span`,{children:c.pastConversations}),(0,r.jsx)(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":c.closeHistory,onClick:()=>q(!1),children:(0,r.jsx)(e.P,{})})]}),(0,r.jsx)(`div`,{class:`cf-history__list`,children:Ve.map(t=>(0,r.jsxs)(`button`,{type:`button`,class:`cf-history__item ${t.sessionId===He?`is-active`:``}`,onClick:()=>{We(t.sessionId),q(!1)},children:[(0,r.jsx)(`span`,{class:`cf-history__title`,children:t.title}),(0,r.jsxs)(`span`,{class:`cf-history__meta`,children:[e.gt(t.ts,a.locale,{month:`short`,day:`numeric`}),t.ended?` · ${c.historyEnded}`:``]})]},t.sessionId))}),(0,r.jsx)(`div`,{class:`cf-history__footer`,children:(0,r.jsx)(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{q(!1),G(!0)},children:c.clearDeviceData})})]})},`history`),W&&(0,r.jsx)(`div`,{class:`cf-confirm`,onClick:()=>G(!1),children:(0,r.jsxs)(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":c.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>se(e,e.currentTarget,()=>G(!1)),children:[(0,r.jsx)(`div`,{class:`cf-confirm__title`,children:c.clearDeviceData}),(0,r.jsx)(`div`,{class:`cf-confirm__body`,children:c.clearDeviceDataBody}),(0,r.jsxs)(`div`,{class:`cf-confirm__actions`,children:[(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>G(!1),children:c.cancel}),(0,r.jsx)(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{G(!1),S()},children:c.clearDeviceDataCta})]})]})},`confirm-clear`)]}),O&&!l?(0,r.jsx)(e.T,{persona:u,voiceState:Ut,muted:ht,onToggleMute:En,onEndCall:Z,micLevel:_t,onExpand:Y}):k&&l?null:!a.hideDefaultLauncher&&(0,r.jsxs)(`button`,{ref:kt,type:`button`,class:`cf-launcher`,"aria-label":l?c.closeChat:E>0?`${c.openChat}. ${e.nt(e._t(a.locale,E,c.unreadMessage,c.unreadMessages),{count:String(E)})}`:c.openChat,"aria-expanded":l,onClick:nn,children:[a.launcherIcon?(0,r.jsx)(`img`,{class:`cf-launcher__img`,src:a.launcherIcon,alt:``}):(0,r.jsx)(e.N,{}),!l&&E>0&&(0,r.jsx)(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:E>99?`99+`:E})]})]})})})})},me=`centrinfo-widget`;var _=class extends HTMLElement{constructor(...t){super(...t),e.vt(this,`controls`,null),e.vt(this,`composerDraftStore`,{value:``}),e.vt(this,`input`,null),e.vt(this,`resolved`,null),e.vt(this,`transport`,null),e.vt(this,`localeRequest`,0),e.vt(this,`localeAbort`,void 0),e.vt(this,`automaticLocale`,void 0)}mountWith(t){let n=e.a(t);this.input=t,this.resolved=n;let r=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(n.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let t=new CSSStyleSheet;t.replaceSync(e.t),r.adoptedStyleSheets=[t]}else{let t=document.createElement(`style`);n.styleNonce&&(t.nonce=n.styleNonce),t.textContent=e.t,r.appendChild(t)}this.transport=e.it(n),n.autoTranslate&&this.transport.loadUITranslations&&!n.demo&&!n.preview&&(this.automaticLocale=e.at(this.transport.loadUITranslations.bind(this.transport))),this.renderApp(),this.applyLocale()}renderApp(){let n=this.shadowRoot,i=this.resolved,a=this.transport;!n||!i||!a||(0,t.render)((0,r.jsx)(e.st,{value:i.analyticsRenderer===`local`?void 0:e.ct(i.apiBaseUrl,i.workspaceUrl),children:(0,r.jsx)(pe,{transport:a,config:i,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore})}),n)}async applyLocale(){let t=this.input;if(!t||!this.resolved)return;this.localeAbort?.abort();let n=new AbortController;this.localeAbort=n;let r=++this.localeRequest,i=e.o(t),a=e.i(i).locale,o=await e.n(a);if(r!==this.localeRequest||!this.resolved||this.input!==t||(Object.assign(this.resolved,e.i(i,o)),this.renderApp(),!this.automaticLocale))return;let s={};for(let t of[`widget`,`results`,`viewer`])this.automaticLocale.load({namespace:t,locale:a,signal:n.signal,onCatalog:a=>{if(n.signal.aborted||r!==this.localeRequest||!this.resolved)return;s[t]=a;let c={widget:e.ot(o.widget,s.widget),results:e.ot(o.results,s.results,{viewerMessages:s.viewer??{}})};Object.assign(this.resolved,e.i(i,c)),this.renderApp()}})}setLocale(e){return this.input?(this.input={...this.input,...e.locale===void 0?{}:{locale:e.locale},...e.dir===void 0?{}:{dir:e.dir},...e.strings?{strings:{...this.input.strings,...e.strings}}:{}},this.applyLocale()):Promise.resolve()}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.localeAbort?.abort(),this.localeRequest+=1,this.resolved=null,this.shadowRoot&&(0,t.render)(null,this.shadowRoot)}disconnectedCallback(){this.localeAbort?.abort()}};typeof customElements<`u`&&!customElements.get(me)&&customElements.define(me,_);const v=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(me);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),setLocale:e=>n.setLocale(e),destroy:()=>{n.unmount(),n.remove()}}},y=e=>v(e);let he=null;const ge=e=>{he?.destroy();let t=y(e);return he=t,t},_e={init:ge,createWidget:y};exports.Centrinfo=_e,exports.SDK_LANGUAGES=e.ht,exports.createWidget=y,exports.init=ge;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { T as WidgetStrings, d as WidgetHandle, f as WidgetThemeTokens, p as WidgetUser, u as WidgetConfig } from "./types-DAYxNBhI.cjs";
1
+ import { A as WidgetStrings, M as SDK_LANGUAGES, d as WidgetHandle, f as WidgetLocaleUpdate, m as WidgetUser, p as WidgetThemeTokens, u as WidgetConfig } from "./types-sRV3p0Gu.cjs";
2
2
 
3
3
  //#region src/mount.d.ts
4
4
  /** Create + mount the floating public messenger. */
@@ -15,4 +15,4 @@ declare const Centrinfo: {
15
15
  createWidget: (config: WidgetConfig) => WidgetHandle;
16
16
  };
17
17
  //#endregion
18
- export { Centrinfo, type WidgetConfig, type WidgetHandle, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
18
+ export { Centrinfo, SDK_LANGUAGES, type WidgetConfig, type WidgetHandle, type WidgetLocaleUpdate, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { T as WidgetStrings, d as WidgetHandle, f as WidgetThemeTokens, p as WidgetUser, u as WidgetConfig } from "./types-95uGbSpk.mjs";
1
+ import { A as WidgetStrings, M as SDK_LANGUAGES, d as WidgetHandle, f as WidgetLocaleUpdate, m as WidgetUser, p as WidgetThemeTokens, u as WidgetConfig } from "./types-M-juCXr7.mjs";
2
2
 
3
3
  //#region src/mount.d.ts
4
4
  /** Create + mount the floating public messenger. */
@@ -15,4 +15,4 @@ declare const Centrinfo: {
15
15
  createWidget: (config: WidgetConfig) => WidgetHandle;
16
16
  };
17
17
  //#endregion
18
- export { Centrinfo, type WidgetConfig, type WidgetHandle, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
18
+ export { Centrinfo, SDK_LANGUAGES, type WidgetConfig, type WidgetHandle, type WidgetLocaleUpdate, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { T as WidgetStrings, d as WidgetHandle, f as WidgetThemeTokens, p as WidgetUser, u as WidgetConfig } from "./types-95uGbSpk.mjs";
1
+ import { A as WidgetStrings, M as SDK_LANGUAGES, d as WidgetHandle, f as WidgetLocaleUpdate, m as WidgetUser, p as WidgetThemeTokens, u as WidgetConfig } from "./types-M-juCXr7.mjs";
2
2
 
3
3
  //#region src/mount.d.ts
4
4
  /** Create + mount the floating public messenger. */
@@ -15,4 +15,4 @@ declare const Centrinfo: {
15
15
  createWidget: (config: WidgetConfig) => WidgetHandle;
16
16
  };
17
17
  //#endregion
18
- export { Centrinfo, type WidgetConfig, type WidgetHandle, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
18
+ export { Centrinfo, SDK_LANGUAGES, type WidgetConfig, type WidgetHandle, type WidgetLocaleUpdate, type WidgetStrings, type WidgetThemeTokens, type WidgetUser, createWidget, init };
package/dist/index.mjs CHANGED
@@ -1 +1,2 @@
1
- import{A as e,B as t,C as n,D as r,E as i,F as a,G as o,I as ee,K as s,L as te,M as ne,N as re,P as ie,R as ae,S as oe,T as se,U as ce,V as le,W as ue,a as de,b as fe,d as pe,et as me,f as he,g as ge,h as _e,i as ve,j as ye,k as be,m as xe,n as c,o as Se,q as Ce,t as we,tt as l,v as Te,w as Ee,x as De,y as Oe}from"./styles-CiqV_OsG.mjs";import{render as u}from"preact";import{useCallback as d,useEffect as f,useLayoutEffect as ke,useRef as p,useState as m}from"preact/hooks";import{Fragment as Ae,jsx as h,jsxs as g}from"preact/jsx-runtime";const je=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom();n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},Me=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,Ne=({state:e,onClose:t})=>{let n=Ce(),r=p(null);f(()=>{r.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let i=e.status===`ready`?Me(e.mimeType):`other`;return h(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":s(n.attachPreviewTitle,{name:e.name}),onClick:e=>{e.target===e.currentTarget&&t()},children:g(`div`,{class:`cf-preview__frame`,children:[g(`div`,{class:`cf-preview__bar`,children:[h(`span`,{class:`cf-preview__name`,title:e.name,children:e.name}),e.status===`ready`&&h(`a`,{class:`cf-preview__btn`,href:e.url,download:e.name,children:n.attachDownload}),h(`button`,{ref:r,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":n.attachPreviewClose,onClick:t,children:`✕`})]}),g(`div`,{class:`cf-preview__body`,children:[e.status===`loading`&&h(`p`,{class:`cf-preview__note`,children:n.attachPreviewLoading}),e.status===`error`&&h(`p`,{class:`cf-preview__note`,children:n.attachPreviewFailed}),e.status===`ready`&&i===`image`&&h(`img`,{class:`cf-preview__image`,src:e.url,alt:e.name}),e.status===`ready`&&i===`pdf`&&h(`iframe`,{class:`cf-preview__pdf`,src:e.url,title:e.name}),e.status===`ready`&&i===`other`&&h(`p`,{class:`cf-preview__note`,children:n.attachPreviewUnsupported})]})]})})},Pe=({name:e,greeting:t})=>{let n=Ce();return g(`section`,{class:`cf-empty-welcome`,"aria-label":s(n.welcomeLabel,{name:e}),children:[h(`span`,{class:`cf-empty-welcome__eyebrow`,children:n.welcomeEyebrow}),h(`h2`,{children:e}),h(`p`,{children:t||n.welcomePrompt})]})},Fe=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,ee=r[0],s=r[r.length-1];e.shiftKey&&(o===ee||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),s.focus()):!e.shiftKey&&(o===s||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),ee.focus())},_=new Map,v=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},Ie=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(_.has(n))return _.get(n);let r=v(e),i=v(t)??[255,255,255,1];if(!r){_.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),ee=o[0]*.2126+o[1]*.7152+o[2]*.0722,s=1.05/(ee+.05)>=(ee+.05)/.059?`#ffffff`:`#0f1e2a`;return _.set(n,s),s},Le=e=>{let[t,n]=m(`light`);return f(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),r=()=>n(t.matches?`dark`:`light`);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`auto`?t:e},Re={end:`end the call`,mute:`mute your microphone`,minimize:`minimize the chat`,expand:`expand the view`,shrink:`exit the expanded view`},ze=e=>e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s']/gu,` `).replace(/\s+/g,` `).trim(),y=[{action:`shrink`,re:/\b(?:exit|leave|quit|close)\b[\s\w]*\b(?:full ?screen|expanded|theat(?:er|re))\b|\bshrink\b|\bsmaller view\b/},{action:`end`,re:/\b(?:end|close|stop|finish|hang ?up|quit|exit)\b[\s\w]*\b(?:call|chat|conversation|convo|session|talking)\b|\bhang ?up\b|\bgood ?bye\b|^bye(?: bye)?$/},{action:`mute`,re:/\bmute\b|\bstop listening\b/},{action:`minimize`,re:/\bminimi[sz]e\b|\bhide\b[\s\w]*\b(?:chat|call|window|widget)\b/},{action:`expand`,re:/\bexpand\b|\bmaximi[sz]e\b|\bfull ?screen\b|\btheat(?:er|re) mode\b|\bbigger view\b/}],Be=/^(?:yes|yeah|yep|yup|sure|correct|confirm|affirmative|go ahead|do it|please do|ok(?:ay)?)\b/,Ve=/^(?:no|nope|nah|cancel|never ?mind|don'?t|stop)\b/,He=/^(?:end|close|stop|finish|hang ?up|quit|exit|bye|good ?bye)\b/,Ue=e=>{let t=ze(e);if(!t)return null;for(let{action:e,re:n}of y)if(n.test(t)){let n=t.split(` `).length;return{action:e,confident:e===`end`?n<=10:n<=6}}return null},We=e=>`I didn't catch yes or no. Say yes to ${Re[e]}, or no to keep talking.`,b=({transport:me,config:c,bindControls:Ce,composerDraftStore:we})=>{let l=c.strings,[u,Me]=m(c.openByDefault),{persona:_,messages:v,sending:y,assistantSpeaking:b,visitor:Ge,hasEmail:Ke,liveMode:x,assignedAgentName:qe,agentTypingName:Je,starters:Ye,featuredLinks:Xe,send:S,sendGif:Ze,notifyTyping:Qe,stop:$e,amend:et,hold:tt,resumeHeld:nt,duckSpeaking:rt,retry:it,rateMessage:at,doubleCheckResponse:ot,retryResponse:st,rateExplanation:ct,explanationTransport:lt,injectAssistant:ut,reconnectSupport:dt,appendUserDraft:ft,patchMessage:C,removeMessage:pt,submitCsat:mt,submitForm:ht,confirmHostedBooking:gt,transcribe:_t,uploadAttachment:vt,loadAttachment:yt,searchGifs:bt,demoSlots:xt,gifEnabled:St,identify:Ct,ended:w,endConversation:wt,startNew:Tt,history:Et,viewingSessionId:Dt,viewMessages:Ot,openConversation:kt,closeHistoryView:At,shutdown:jt,stopSpeaking:T,speakAssistantText:Mt,analyticsModels:Nt,analyticsModelId:Pt,selectAnalyticsModel:Ft}=Se(me,c,u),It=de(v,x),[Lt,Rt]=m(null),zt=p(0),Bt=d((e,t,n)=>{n===zt.current&&Rt({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),Vt=d((e,t,n)=>{let r=t.name,i=++zt.current;Rt({status:`loading`,name:r}),yt(e,t,n).then(e=>Bt(e,r,i),()=>{i===zt.current&&Rt({status:`error`,name:r})})},[yt,Bt]),Ht=d((e,t)=>Bt(e,t,++zt.current),[Bt]),Ut=d(()=>{zt.current+=1,Rt(null)},[]);f(()=>()=>{Lt?.status===`ready`&&URL.revokeObjectURL(Lt.url)},[Lt]);let Wt=!!ve(_?.actions),[E,Gt]=m(0),[D,Kt]=m({mic:`off`,processing:!1}),[qt,Jt]=m(null),[Yt,Xt]=m(!1),[O,Zt]=m(!1),[Qt,$t]=m(!1),[en,tn]=m(!1),[nn,rn]=m(0),[k,A]=m(!1),[an,j]=m(null),[on,sn]=m(null),[cn,ln]=m([]),[un,dn]=m(``),[fn,pn]=m(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),mn=Le(c.theme),hn=_?.soundEnabled??!0;f(()=>{he(c.sound&&hn&&!fn)},[c.sound,hn,fn]);let gn=d(()=>{pn(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),M=p(null),_n=p(null),vn=p(null),yn=p(0),bn=p(!1),N=p(!1),P=p(null),F=p(0),xn=p(void 0),Sn=p(0),Cn=p(null),wn=p(!1),I=p(null),L=p(``),Tn=p(()=>{}),En=p(``),Dn=p(y),On=p(S);On.current=S;let kn=p(et);kn.current=et;let An=p(_t);An.current=_t;let R=p(!1),z=p(!1),jn=p(``);jn.current=[...v].reverse().find(e=>e.role===`assistant`)?.content??``;let Mn=p(b);Dn.current=y,Mn.current=b;let B=O?Yt?`timeout`:en||D.mic===`muted`?`muted`:D.mic===`unavailable`?D.reason===`permission-denied`||D.reason===`unsupported`?`denied`:`unavailable`:D.mic===`off`||D.mic===`starting`?`connecting`:D.mic===`hearing`?`hearing`:b?`speaking`:qt??(D.processing||y?`processing`:`listening`):`idle`,[Nn,Pn]=m(!0),[Fn,V]=m(!1),In=p(0),[H,Ln]=m(!1),[U,W]=m(!1),Rn=p(null),[G,K]=m(!1),zn=p({value:``}),Bn=we??zn.current,Vn=p({confirmEnd:H,confirmClear:U,showHistory:G});Vn.current={confirmEnd:H,confirmClear:U,showHistory:G};let[Hn,Un]=m(!1),q=!!Dt,Wn=q?Ot:v,Gn=Wn.find(e=>e.id===an&&e.visualization)?.visualization,Kn=Wn.find(e=>e.id===on&&e.visualization);f(()=>{!on||Kn||(sn(null),A(!1))},[on,Kn]),f(()=>{!an||Gn||(j(null),A(!1))},[Gn,an]);let qn=d(()=>{Me(!0),Gt(0),pe(`open`),c.onOpen?.(),c.onShow?.()},[c]),J=d(()=>{Me(!1),A(!1),j(null),c.onClose?.(),c.onHide?.(),_n.current?.focus()},[c]),Jn=d(()=>u?J():qn(),[u,qn,J]),Yn=d(()=>Ln(!0),[]),Xn=d(()=>{wt(),Ln(!1)},[wt]),Zn=d(()=>{Tt(),V(!1),Pn(!0)},[Tt]);f(()=>{H&&Rn.current?.focus()},[H]),f(()=>{Ce({open:qn,close:J,toggle:Jn,identify:Ct,startNew:Tt,endConversation:wt,shutdown:jt})},[Ce,qn,J,Jn,Ct,Tt,wt,jt]),f(()=>{let e=v.filter(e=>e.role===`assistant`&&!e.pending).length;if(u){yn.current=e;return}e>yn.current&&Gt(e-yn.current)},[v,u]),f(()=>{c.onUnreadChange?.(E)},[E,c]),f(()=>{let e=c.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>jt(),e*60*1e3);return()=>clearTimeout(t)},[c.sessionDurationMinutes,v,u,jt]),f(()=>{let e=c.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),Jn()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[c.customLauncherSelector,Jn]);let Qn=p(!1);f(()=>{let e=c.proactiveMessage?.trim();if(!e||Qn.current)return;let t=c.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${c.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(u||w||v.some(e=>e.role===`user`))){Qn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}ut(e),qn()}},Math.max(0,c.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[c.proactiveMessage]),f(()=>{let e=vn.current;if(!u||!e)return;let t=v[v.length-1],n=Date.now()<In.current;t?.role===`user`||Nn||n?(requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight}),V(!1),n&&Pn(!0)):V(!0)},[v,u,y,Nn]);let $n=p(!0);$n.current=Nn,f(()=>{let e=vn.current;if(!(!u||!e))return je(e,{isAtBottom:()=>$n.current,onUnseen:()=>V(!0)})},[u,q]);let er=d(()=>{let e=vn.current;if(!e)return;if(bn.current&&!q){Pn(!0),V(!1);return}let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;Pn(t),t&&V(!1)},[q]),Y=d(()=>{let e=vn.current;e&&(e.scrollTop=e.scrollHeight),V(!1),Pn(!0)},[]),tr=d(()=>{In.current=Date.now()+3e3,requestAnimationFrame(Y)},[Y]);f(()=>{if(!u||q||!O||B===`connecting`)return;In.current=Date.now()+6e4,Y();let e=requestAnimationFrame(()=>{Y(),requestAnimationFrame(Y)}),t=[80,180,360].map(e=>window.setTimeout(Y,e));return()=>{cancelAnimationFrame(e),t.forEach(e=>window.clearTimeout(e))}},[b,v,u,Y,y,O,q,B]);let nr=d(()=>{M.current?.querySelector(`.cf-textarea`)?.focus()},[]),rr=d((e,t)=>{Jt(e),xn.current&&window.clearTimeout(xn.current),xn.current=window.setTimeout(()=>Jt(null),3e3),t&&!N.current&&Mt(t)},[Mt]),ir=d(e=>{let t=I.current;if(t)return t;tr();let n=ft(e);return I.current=n,C(n,{content:L.current||e,pending:!0,streaming:!1}),n},[ft,tr,C]),X=d(()=>{let e=I.current;if(e){if(L.current){C(e,{content:L.current,pending:!0});return}I.current=null,pt(e)}},[C,pt]),Z=d(()=>{z.current&&(z.current=!1,rt(!1)),R.current&&(R.current=!1,nt())},[rt,nt]),Q=d(()=>{bn.current=!1,P.current?.stop(`call-ended`),P.current=null,R.current=!1,z.current=!1,N.current=!1,Cn.current=null,wn.current=!1;let e=I.current;I.current=null,L.current=``,e&&pt(e),xn.current&&window.clearTimeout(xn.current),Jt(null),Xt(!1),Kt({mic:`off`,processing:!1}),rn(0),Zt(!1),$t(!1),tn(!1),A(!1),j(null),T()},[pt,T]),ar=d(()=>{k&&j(null),A(!k)},[k]),or=d(e=>{j(e),A(!0)},[]),sr=d(e=>{sn(e),A(!0)},[]),cr=d(()=>{let e=an,t=on;j(null),sn(null),A(!1),window.requestAnimationFrame(()=>{(t?M.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(M.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[an,on]),lr=d(()=>{j(null),sn(null),A(!1)},[]),ur=d((e,t,n=!1)=>{if(tr(),t&&(C(t,{content:e,pending:!1,streaming:!1}),I.current===t&&(I.current=null)),L.current=``,n){T(),kn.current(e,{forceVoicePlayback:!0,userMessageId:t});return}bn.current&&(tt()?kn.current(e,{forceVoicePlayback:!0,userMessageId:t}):On.current(e,{forceVoicePlayback:!0,userMessageId:t}))},[tr,tt,C,T]),$=d(e=>{ut(e),Mt(e)},[ut,Mt]),dr=d(()=>{if(F.current=Date.now(),Jt(null),Mn.current){z.current=!0,rt(!0);return}R.current||(R.current=tt()),ir(`Listening...`)},[rt,ir,tt]),fr=d(e=>{let t=I.current;!t||z.current||C(t,{content:`${[L.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[C]),pr=d(e=>{F.current=Date.now();let t=[L.current,e.text].map(e=>e.trim()).filter(Boolean).join(` `).replace(/\s+/g,` `).trim();if((z.current||e.overlappedOutput)&&le(e.text,jn.current)){X(),Z();return}if(!t||xe(t)||_e(t)){let e=z.current||R.current;X(),Z(),e||rr(`misunderstood`);return}z.current&&(z.current=!1,$e(),T());let n=Cn.current;if(n){L.current=``,X();let e=ze(t);if(Be.test(e)||n===`end`&&He.test(e)){Cn.current=null,Tn.current(n);return}if(Ve.test(e)){Cn.current=null,$(`Okay, never mind — what would you like to know?`);return}$(We(n));return}let r=Ue(t);if(r){if(L.current=``,X(),Z(),r.confident){Tn.current(r.action);return}Cn.current=r.action,$(`Just to confirm — you want me to ${Re[r.action]}? Please say yes or no.`);return}let i=ir(t);C(i,{content:t,pending:!0});let a=R.current;R.current=!1,ur(t,i,a)},[ir,C,Z,ur,X,rr,$,$e,T]),mr=d(e=>{F.current=Date.now();let t=z.current||R.current;if(X(),Z(),!(t||e.overlappedOutput||e.reason===`too-short`)){if(e.reason===`transcribe-failed`){rr(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`);return}rr(`noise`)}},[Z,X,rr]),hr=p({speechStart:dr,partial:fr,turn:pr,noise:mr});hr.current={speechStart:dr,partial:fr,turn:pr,noise:mr};let gr=d(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{ln(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||`Microphone ${t+1}`})))}).catch(()=>{})},[]),_r=d(()=>{if(bn.current){Q();return}if(nr(),!_?.allowVoiceInput||!_.talkbackMode||_.talkbackMode===`text`||Dn.current||w||q)return;F.current=Date.now(),N.current=!1,bn.current=!0,tn(!1),Zt(!0),$t(!1),Xt(!1);let e=!1,n=new t({deviceId:En.current||void 0,transcribe:async({audio:e,mimeType:t,durationSeconds:n})=>{let r=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return ge(await An.current(e,t,r,n))},listener:{state:t=>{Kt(t),t.mic!==`starting`&&t.mic!==`off`&&$t(!0),!e&&t.mic===`listening`&&(e=!0,gr())},speechStart:()=>hr.current.speechStart(),partial:({text:e})=>hr.current.partial(e),turn:e=>hr.current.turn(e),noise:e=>hr.current.noise(e),level:e=>{let t=performance.now();t-Sn.current<90||(Sn.current=t,rn(e))}}});P.current=n,n.setOutputActive(Mn.current),n.start()},[Q,w,nr,_,gr,q]),vr=d(()=>{let e=!N.current;N.current=e,tn(e),P.current?.setMuted(e),e?(L.current=``,X(),Z()):F.current=Date.now()},[Z,X]),yr=d(e=>{switch(F.current=Date.now(),e){case`end`:wn.current=!0,$(`Okay — ending our call now. Goodbye!`),window.setTimeout(()=>{wn.current&&(wn.current=!1,Q())},2e3);break;case`mute`:N.current||vr(),$(`Muted. Tap the mic button when you want me to listen again.`);break;case`minimize`:J(),$(`Minimized — I'm still listening. Tap the call pill to bring the chat back.`);break;case`expand`:A(!0),$(`Sure — expanding the view.`);break;case`shrink`:j(null),A(!1),$(`Okay — back to the smaller view.`);break}},[J,Q,$,vr]);f(()=>{Tn.current=yr},[yr]);let br=p(!1);f(()=>{br.current&&!b&&wn.current&&(wn.current=!1,Q()),br.current=b},[b,Q]);let xr=d(e=>{En.current=e,dn(e),P.current?.selectDevice(e||void 0)},[]),Sr=d(()=>{!bn.current||N.current||(z.current=!1,R.current=!1,$e(),T(),F.current=Date.now())},[$e,T]);f(()=>{P.current?.setOutputActive(b),F.current=Date.now()},[b]),f(()=>{if(B!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,B]),f(()=>{if(!O)return;let e=window.setInterval(()=>{let e=P.current;!e||N.current||Dn.current||Mn.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-F.current<6e4||(P.current?.log.add(`call-timeout`),Xt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,O]);let Cr=O&&!en&&(y||b);f(()=>()=>Q(),[Q]);let[wr,Tr]=m(``),Er=p(!1);f(()=>{if(Er.current&&!y){let e=[...v].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&Tr(e.content)}Er.current=y},[y,v]),ke(()=>{if(!u)return;let e=M.current,t=H||U?e?.querySelector(`.cf-confirm__card`):G?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[U,H,u,G]),f(()=>{if(!u)return;let e=M.current,t=H||U?e?.querySelector(`.cf-confirm__card`):G?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=Vn.current;if(t.confirmEnd){Ln(!1);return}if(t.confirmClear){W(!1);return}if(t.showHistory){K(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;J();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],ee=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&ee===a?(n.preventDefault(),o.focus()):!n.shiftKey&&ee===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[u,J,H,U,G]),f(()=>{let e=M.current;e&&(u?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[u]);let Dr=c.accentColor??c.themeTokens?.accent??_?.accentColor,Or=c.themeTokens?.accentText??Ie(Dr,c.themeTokens?.background??(mn===`dark`?`#0f1c27`:`#ffffff`)),kr={zIndex:c.zIndex,"--cf-h-pad":`${c.horizontalPadding}px`,"--cf-v-pad":`${c.verticalPadding}px`,...Or?{"--cf-accent-ink":Or}:{},...c.themeTokens?.accentStrong?{"--cf-accent-2":c.themeTokens.accentStrong}:{},...c.themeTokens?.background?{"--cf-bg":c.themeTokens.background}:{},...c.themeTokens?.surface?{"--cf-surface":c.themeTokens.surface}:{},...c.themeTokens?.surfaceMuted?{"--cf-surface-2":c.themeTokens.surfaceMuted}:{},...c.themeTokens?.text?{"--cf-text":c.themeTokens.text}:{},...c.themeTokens?.mutedText?{"--cf-muted":c.themeTokens.mutedText}:{},...c.themeTokens?.border?{"--cf-border":c.themeTokens.border}:{},...c.themeTokens?.shadow?{"--cf-shadow":c.themeTokens.shadow}:{},...c.themeTokens?.radius?{"--cf-radius":c.themeTokens.radius}:{},...c.themeTokens?.fontFamily?{"--cf-font":c.themeTokens.fontFamily}:{},...c.themeTokens?.success?{"--cf-success":c.themeTokens.success}:{},...c.themeTokens?.warning?{"--cf-warning":c.themeTokens.warning}:{},...c.themeTokens?.danger?{"--cf-danger":c.themeTokens.danger}:{},...Dr?{"--cf-accent":Dr,"--cf-accent-2":c.themeTokens?.accentStrong??`color-mix(in oklab, ${Dr} 76%, #14141f)`}:{}},Ar=e=>S(e),jr=[...v].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,Mr=v.some(e=>e.role===`user`),Nr=!!(_?.allowVoiceInput&&_?.talkbackMode&&_.talkbackMode!==`text`),Pr=Nr,Fr=!q&&Pr&&!Mr?Wn.filter((e,t)=>!(t===0&&e.role===`assistant`)):Wn,Ir=x===`human`&&qe?qe:_?.agentName??l.chatName,Lr=x===`human`?l.liveSupport:x===`queued`?l.waitingForTeam:_?.offline?l.statusOffline:l.statusOnline,Rr=!w&&!q?_?.availableActions:void 0,zr=!w&&!q?_?.actions:void 0,Br=O&&!Qt&&B===`connecting`&&!q;return h(o,{value:l,children:h(ue,{value:c.locale,children:g(`div`,{class:`cf-root`,dir:c.dir,"data-theme":mn,"data-align":c.alignment,"data-display":`floating`,style:kr,children:[k&&u&&h(`div`,{class:`cf-theater-backdrop`,onClick:lr}),g(`div`,{ref:M,class:`cf-panel ${u?`is-open`:``} ${O?`cf-panel--call`:``} ${Br?`cf-panel--voice-connecting`:``} ${k&&u?`cf-panel--theater`:``} ${Gn||Kn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${l.chatName}: ${_?.agentName??l.assistantName}`,"aria-hidden":!u,children:[Lt&&u&&h(Ne,{state:Lt,onClose:Ut}),g(`div`,{class:`cf-header`,children:[h(Oe,{persona:_,hideWhenMissing:!0}),g(`div`,{class:`cf-header__meta`,children:[h(`div`,{class:`cf-header__name`,children:Ir}),c.token.startsWith(`pub_test_`)?h(`small`,{role:`status`,children:l.testMode}):null,h(`div`,{class:`cf-header__status ${x===`ai`&&_?.offline?`cf-header__status--offline`:``}`,children:h(`span`,{class:`cf-header__status-text`,children:Lr})})]}),g(`div`,{class:`cf-header__actions`,children:[Et.length>0&&h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.pastConversations,title:l.pastConversations,"aria-pressed":G,onClick:()=>K(e=>!e),children:h(re,{})}),Mr&&!w&&!q&&h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.endChat,title:l.endChat,onClick:Yn,children:h(ne,{})}),c.sound&&hn&&h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":fn?l.unmuteSounds:l.muteSounds,"aria-pressed":fn,onClick:gn,children:h(fn?ie:a,{})}),h(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":l.closeChat,onClick:J,children:h(ye,{})})]})]}),h(`div`,{class:`cf-panel__video`,children:Gn?h(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":l.expandedAnalyticsResult,children:h(r,{visualization:Gn,expanded:!0,onFollowUp:e=>{cr(),S(e)},onClose:cr})}):Kn?.visualization?h(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":l.expandedAnalyticsResult,children:h(i,{visualization:Kn.visualization,onClose:cr,onFollowUp:e=>{cr(),S(e)},onFeedback:q?void 0:ct,transport:q?void 0:lt(`widget`),onOpenSource:c.onOpenAnalyticsSource})}):!q&&Pr?h(fe,{persona:_,starters:[],onPick:S,onFocusComposer:_r,speaking:b,voiceState:B,replyPending:O&&y&&!b,pinned:!0,muted:en,onToggleMute:vr,onEndCall:Q,onTalkNow:Sr,showTalkNow:Cr,micLevel:nn,theaterMode:k,onToggleTheater:ar,onMinimize:J,audioDevices:cn,selectedAudioDeviceId:un,onSelectAudioDevice:xr,connectingOnly:Br}):null}),!Br&&g(`div`,{class:`cf-panel__chat`,children:[c.preview&&h(`div`,{class:`cf-preview-banner`,children:l.previewBanner}),q&&h(`div`,{class:`cf-viewing-banner`,children:l.viewingPast}),g(`div`,{class:`cf-body`,ref:vn,role:`log`,onScroll:er,children:[Fr.map((e,t)=>h(Ee,{msg:e,persona:_,isLast:!q&&t===Fr.length-1,visitor:Ge,hasEmail:Ke,lastQuestion:jr,showActions:!q&&t===Fr.length-1&&!!(e.handoffOffered||e.selectedAction),onPickReply:Ar,onSubmitForm:ht,onDemoSlots:xt,onConfirmHostedBooking:gt,onRetry:it,ratable:!q&&Fr.slice(0,t).some(e=>e.role===`user`),onRate:at,onDoubleCheck:q||w?void 0:ot,onRetryResponse:q||w||x!==`ai`?void 0:st,doubleCheckDisabled:y,onExplanationFeedback:q?void 0:ct,explanationTransport:q?void 0:lt(`widget`),onOpenAnalyticsSource:c.onOpenAnalyticsSource,onExpandVisualization:q?void 0:or,onExpandExplanation:q?void 0:sr,onOpenAttachment:Vt,onReconnect:!q&&!w&&Wt&&e.id===It?dt:void 0},e.id)),!Mr&&!q&&g(Ae,{children:[Fr.length===0&&h(Pe,{name:_?.agentName??l.assistantName,greeting:_?.greeting}),h(se,{items:Ye,onPick:S}),h(oe,{items:Xe})]}),Fn&&g(`button`,{type:`button`,class:`cf-newmsg`,onClick:Y,children:[h(be,{}),l.newMessages]})]}),h(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:wr}),y&&!w&&!q&&h(`div`,{class:`cf-stopbar`,children:g(`button`,{type:`button`,class:`cf-stop`,onClick:$e,children:[h(ee,{}),l.stop]})}),q?h(`div`,{class:`cf-ended`,children:h(`button`,{type:`button`,class:`cf-ended__btn`,onClick:At,children:l.backToChat})}):w?g(`div`,{class:`cf-ended`,children:[h(`p`,{class:`cf-ended__text`,children:l.conversationEnded}),c.csat&&Mr?Hn?h(`p`,{class:`cf-ended__text`,children:l.feedbackThanks}):g(`div`,{class:`cf-csat`,children:[h(`span`,{class:`cf-csat__q`,children:l.csatPrompt}),h(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":l.feedbackHelpful,onClick:()=>{mt(`up`),Un(!0)},children:h(ae,{})}),h(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":l.feedbackNotHelpful,onClick:()=>{mt(`down`),Un(!0)},children:h(te,{})})]}):null,h(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Zn,children:l.startNewChat})]}):g(Ae,{children:[Je?h(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:s(l.agentTyping,{name:Je})}):null,Rr&&Rr.length>0&&h(`div`,{class:`cf-footer-actions`,children:h(Te,{actions:Rr,descriptors:zr,visitor:Ge,onSubmitForm:ht,onDemoSlots:xt,onConfirmHostedBooking:gt,scheduler:_?.scheduler,translations:c.actionTranslations})},`footer-actions`),h(De,{toolbarContent:c.showAnalyticsModelSelector?h(ce,{models:Nt,value:Pt,onChange:Ft,disabled:y}):null,draftStore:Bn,onSend:S,onSendGif:Ze,onTyping:Qe,disabled:y,allowVoice:Nr&&c.composer?.voice!==!1,onTranscribe:_t,gifEnabled:St,onSearchGifs:bt,allowAttach:c.attachments,analyzeAttachments:!0,onUpload:vt,onPreviewAttachment:Ht},`composer`)]}),!w&&_?.disclaimerText&&h(`div`,{class:`cf-disclaimer`,children:_.disclaimerText}),g(`div`,{class:`cf-footer`,children:[h(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":l.clearDeviceData,onClick:()=>W(!0),children:l.privacyAndData}),h(`span`,{"aria-hidden":`true`,children:`·`}),l.poweredBy,` `,h(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),H&&h(`div`,{class:`cf-confirm`,onClick:()=>Ln(!1),children:g(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":l.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Fe(e,e.currentTarget,()=>Ln(!1)),children:[h(`div`,{class:`cf-confirm__title`,children:l.endChatConfirm}),h(`div`,{class:`cf-confirm__body`,children:l.endChatConfirmBody}),g(`div`,{class:`cf-confirm__actions`,children:[h(`button`,{ref:Rn,type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>Ln(!1),children:l.cancel}),h(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:Xn,children:l.endConfirmCta})]})]})},`confirm-end`),G&&h(`div`,{class:`cf-confirm`,onClick:()=>K(!1),children:g(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":l.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Fe(e,e.currentTarget,()=>K(!1)),children:[g(`div`,{class:`cf-history__head`,children:[h(`span`,{children:l.pastConversations}),h(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":l.closeHistory,onClick:()=>K(!1),children:h(ye,{})})]}),h(`div`,{class:`cf-history__list`,children:Et.map(e=>g(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===Dt?`is-active`:``}`,onClick:()=>{kt(e.sessionId),K(!1)},children:[h(`span`,{class:`cf-history__title`,children:e.title}),g(`span`,{class:`cf-history__meta`,children:[new Date(e.ts).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),e.ended?` · ${l.historyEnded}`:``]})]},e.sessionId))}),h(`div`,{class:`cf-history__footer`,children:h(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{K(!1),W(!0)},children:l.clearDeviceData})})]})},`history`),U&&h(`div`,{class:`cf-confirm`,onClick:()=>W(!1),children:g(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":l.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>Fe(e,e.currentTarget,()=>W(!1)),children:[h(`div`,{class:`cf-confirm__title`,children:l.clearDeviceData}),h(`div`,{class:`cf-confirm__body`,children:l.clearDeviceDataBody}),g(`div`,{class:`cf-confirm__actions`,children:[h(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>W(!1),children:l.cancel}),h(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{W(!1),jt()},children:l.clearDeviceDataCta})]})]})},`confirm-clear`)]}),O&&!u?h(n,{persona:_,voiceState:B,muted:en,onToggleMute:vr,onEndCall:Q,micLevel:nn,onExpand:qn}):k&&u?null:!c.hideDefaultLauncher&&g(`button`,{ref:_n,type:`button`,class:`cf-launcher`,"aria-label":u?l.closeChat:E>0?`${l.openChat}. ${E===1?l.unreadMessage:s(l.unreadMessages,{count:String(E)})}`:l.openChat,"aria-expanded":u,onClick:Jn,children:[c.launcherIcon?h(`img`,{class:`cf-launcher__img`,src:c.launcherIcon,alt:``}):h(e,{}),!u&&E>0&&h(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:E>99?`99+`:E})]})]})})})},Ge=`centrinfo-widget`;var Ke=class extends HTMLElement{constructor(...e){super(...e),l(this,`controls`,null),l(this,`composerDraftStore`,{value:``})}mountWith(e){let t=c(e),n=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(t.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let e=new CSSStyleSheet;e.replaceSync(we),n.adoptedStyleSheets=[e]}else{let e=document.createElement(`style`);t.styleNonce&&(e.nonce=t.styleNonce),e.textContent=we,n.appendChild(e)}u(h(b,{transport:me(t),config:t,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore}),n)}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.shadowRoot&&u(null,this.shadowRoot)}};typeof customElements<`u`&&!customElements.get(Ge)&&customElements.define(Ge,Ke);const x=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(Ge);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),destroy:()=>{n.unmount(),n.remove()}}},qe=e=>x(e);let Je=null;const Ye=e=>{Je?.destroy();let t=qe(e);return Je=t,t},Xe={init:Ye,createWidget:qe};export{Xe as Centrinfo,qe as createWidget,Ye as init};
1
+ import{$ as e,A as t,B as n,C as r,E as i,F as a,G as o,H as s,I as c,J as ee,K as l,L as te,M as ne,N as re,O as ie,P as ae,R as oe,S as se,T as ce,V as le,Y as ue,Z as de,_ as fe,_t as pe,a as me,at as u,b as he,c as ge,ct as d,et as _e,gt as ve,h as ye,ht as be,i as f,it as p,k as xe,l as Se,m as Ce,n as m,nt as we,o as h,ot as Te,q as Ee,rt as g,s as De,st as Oe,t as ke,v as Ae,vt as _,w as je,y as Me,z as Ne}from"./styles-C8MXPiR-.mjs";import{render as Pe}from"preact";import{useCallback as v,useEffect as y,useLayoutEffect as Fe,useRef as b,useState as x}from"preact/hooks";import{Fragment as Ie,jsx as S,jsxs as C}from"preact/jsx-runtime";const Le=(e,t)=>{if(typeof MutationObserver>`u`)return()=>void 0;let n=e.scrollHeight,r=0,i=()=>{r=0;let i=e.scrollHeight,a=i>n,o=t.isAtBottom()||n-e.scrollTop-e.clientHeight<80;n=i,a&&(o?(e.scrollTop=e.scrollHeight,t.onFollow?.()):t.onUnseen?.())},a=new MutationObserver(()=>{r||(r=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,0))});return a.observe(e,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`style`,`height`]}),()=>{a.disconnect(),r&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r)}},w={en:[`Still working on that, one moment.`,`Nearly there, thanks for waiting.`,`Still on it, just a little longer.`],fr:[`Je m’en occupe toujours, un instant.`,`Presque fini, merci de patienter.`,`Toujours en cours, encore un petit moment.`],es:[`Sigo con ello, un momento.`,`Ya casi está, gracias por esperar.`,`Todavía en ello, solo un poco más.`],pt:[`Ainda estou a tratar disso, um momento.`,`Quase pronto, obrigado por esperar.`,`Continuo nisso, só mais um pouco.`],de:[`Ich arbeite noch daran, einen Moment.`,`Fast fertig, danke fürs Warten.`,`Bin noch dran, nur noch kurz.`],it:[`Ci sto ancora lavorando, un momento.`,`Quasi fatto, grazie per l’attesa.`,`Ancora un attimo, ci sono quasi.`],ar:[`ما زلت أعمل على ذلك، لحظة من فضلك.`,`اقتربنا، شكرًا على انتظارك.`,`ما زلت أتابع، لحظات قليلة فقط.`],sw:[`Bado ninashughulikia hilo, subiri kidogo.`,`Karibu tayari, asante kwa kusubiri.`,`Bado niko kazini, muda mfupi tu.`]},Re=e=>w[(e??``).replace(`_`,`-`).split(`-`)[0].trim().toLowerCase()]??w.en,ze=(e,t)=>{let n=globalThis.speechSynthesis;if(!n||typeof SpeechSynthesisUtterance>`u`)return null;let r=new SpeechSynthesisUtterance(e);t&&(r.lang=t);let i=!1,a=new Promise(e=>{r.onend=r.onerror=()=>{i=!0,e()}});return n.speak(r),{done:a,stop:()=>{!i&&!n.pending&&n.cancel()}}},T=[`mute`,`end`,`wait`,`resume`],E={mic:`off`,processing:!1};var Be=class{constructor(e){this.options=e,_(this,`engine`,null),_(this,`snapshot`,E),_(this,`muted`,!1),_(this,`partialText`,``),_(this,`queue`,[]),_(this,`overAnswer`,!1),_(this,`overPending`,!1),_(this,`answerEchoes`,!1),_(this,`spokenAnswer`,``),_(this,`lastActivity`,0),_(this,`idleTimer`,null),_(this,`outputActive`,!1),_(this,`lastStateKey`,``),_(this,`delivering`,null),_(this,`ending`,null),_(this,`waiting`,!1),_(this,`progressTimer`,null),_(this,`answeringSince`,0),_(this,`progressSpoken`,0),_(this,`lastProgressAt`,0),_(this,`progressSpeech`,null),_(this,`progressHeard`,[])}static supported(){return l()}get active(){return this.engine!==null}get voiceEngine(){return this.engine}get state(){let{chat:e}=this.options,t=this.engine!==null,n=t&&this.answering(),r=t&&e.speaking(),i=this.snapshot,a=this.muted||i.mic===`muted`;return{active:t,phase:t?i.mic===`off`||i.mic===`starting`?`connecting`:i.mic===`unavailable`?`unavailable`:a?r?`speaking`:n||this.queue.length?`thinking`:`muted`:i.mic===`hearing`?`hearing`:r?`speaking`:this.waiting?`waiting`:n||this.queue.length?`thinking`:i.processing?`transcribing`:`listening`:`off`,mic:i,muted:a,partial:this.partialText,queued:this.queue.map(e=>e.text),answerPending:n||this.queue.length>0,waiting:t&&this.waiting,stillWorking:t&&this.stillWorking(),reason:i.mic===`unavailable`?i.reason:void 0}}async start(){if(this.engine)return;let{options:e}=this;this.lastActivity=Date.now(),this.muted=!1,this.partialText=``,this.queue=[],this.overAnswer=!1,this.overPending=!1,this.waiting=!1,this.snapshot={mic:`starting`,processing:!1};let t=new o({live:e.live?{...e.live,controls:this.controls,delegate:(t,n)=>(this.touch(),e.live.delegate(t,n,{waiting:this.waiting}))}:void 0,transcribe:e.transcribe,deviceId:e.deviceId,endSilenceMs:e.endSilenceMs,media:e.media,listener:{speaking:t=>e.events?.liveSpeaking?.(t),state:e=>{this.engine===t&&this.onState(e)},speechStart:()=>{this.engine===t&&this.onSpeechStart()},partial:({text:e})=>{this.engine===t&&this.onPartial(e)},turn:e=>{this.engine===t&&this.onTurn(e)},noise:e=>{this.engine===t&&this.onDropped(e.reason,e.overlappedOutput)},level:t=>e.events?.level?.(t),control:e=>{this.engine===t&&this.control(e)}}});this.engine=t,this.outputActive=e.chat.speaking(),t.setOutputActive(this.outputActive),this.startIdleTimer(),this.startProgressTimer(),this.emit(!0),await t.start()}end(e=`user`){let t=this.engine;if(!t)return;this.engine=null,t.stop(`conversation-${e}`),this.idleTimer&&clearInterval(this.idleTimer),this.idleTimer=null;let{chat:n}=this.options;(this.delivering!==null||n.busy())&&n.cancel(),this.delivering&&clearTimeout(this.delivering),this.delivering=null,this.ending&&clearInterval(this.ending),this.ending=null,this.stopProgress(!0),this.waiting=!1,n.silence(),this.overAnswer=!1,this.overPending=!1,this.answerEchoes=!1,this.queue=[],this.partialText=``,this.muted=!1,this.snapshot=E,this.options.events?.ended?.(e),this.emit(!0)}setMuted(e){let t=this.engine;t&&(this.muted=e,t.setMuted(e),e?(this.partialText=``,t.snapshot.processing||this.release()):this.touch(),this.emit(!0))}toggleMute(){this.setMuted(!this.state.muted)}finishTurn(){this.engine?.finishTurn()}interrupt(){if(!this.engine)return;this.engine.interrupt(),this.overAnswer=!1,this.overPending=!1;let{chat:e}=this.options;e.cancel(),e.silence(),this.touch(),this.sync()}get controls(){return this.options.controls??T}control(e){let t=Ee(e,this.controls),n=this.engine;return!t||!n?null:(n.log.add(`voice-control`,{action:t}),this.touch(),t===`mute`?this.setMuted(!0):t===`end`?this.endAfterAnswer():t===`wait`?this.waiting=!0:t===`resume`&&(this.waiting=!1),this.options.events?.control?.(t),this.emit(!0),t)}wait(){!this.engine||this.waiting||(this.waiting=!0,this.touch(),this.emit(!0))}resume(){!this.engine||!this.waiting||(this.waiting=!1,this.touch(),this.emit(!0))}endAfterAnswer(){if(this.ending)return;let e=Date.now(),t=!1;this.ending=setInterval(()=>{if(!this.engine)return;let{chat:n}=this.options,r=n.speaking();r&&(t=!0);let i=Date.now()-e;(!r&&!this.answering()&&(t||i>=2e3)||i>=2e4)&&this.end(`user`)},200)}async selectDevice(e){await this.engine?.selectDevice(e)}sync(){if(!this.engine)return;let{chat:e}=this.options;this.delivering&&(e.busy()||e.speaking())&&(clearTimeout(this.delivering),this.delivering=null);let t=e.speaking();t&&this.rememberSpokenAnswer(),(t||!this.answering())&&this.stopProgress(),t!==this.outputActive&&!this.progressSpeech&&(this.outputActive=t,this.answerEchoes=!1,this.engine.setOutputActive(t),this.touch()),this.flush(),this.emit()}answering(){return this.delivering!==null||this.options.chat.busy()}rememberSpokenAnswer(){let e=this.options.chat.lastAnswer();e.trim()&&(this.spokenAnswer=e)}isEcho(e){return ue(e,this.options.chat.lastAnswer())||!!(this.spokenAnswer&&ue(e,this.spokenAnswer))||this.progressHeard.some(t=>ue(e,t))}touch(){this.lastActivity=Date.now()}flush(){let{chat:e}=this.options;if(!this.engine||!this.queue.length||this.answering()||e.speaking())return;let t=this.queue.shift();this.touch(),this.delivering=setTimeout(()=>{this.delivering=null,this.sync()},400),e.deliver(t.text,t.token,{waiting:this.waiting})}release(){return!this.overAnswer&&!this.overPending?!1:(this.overAnswer=!1,this.overPending=!1,this.options.chat.duck(!1),!0)}onState(e){if(this.snapshot=e,(e.mic===`muted`||e.mic===`listening`||e.mic===`hearing`)&&(this.muted=e.mic===`muted`),e.mic===`off`){this.end(`mic-off`);return}e.mic!==`hearing`&&!e.processing&&this.release(),this.emit()}onSpeechStart(){this.touch();let{chat:e}=this.options,t=e.speaking(),n=e.busy();t?(this.rememberSpokenAnswer(),this.overAnswer=!0,this.answerEchoes||e.duck(!0)):n&&(this.overPending=!0,e.duck(!0)),this.partialText=``,this.options.events?.speechStart?.({overAnswer:t,answerPending:n}),this.emit()}onPartial(e){this.touch(),!this.overAnswer&&(this.partialText=e,this.options.events?.partial?.(e),this.emit())}onDropped(e,t){this.touch(),this.partialText=``;let n=this.release();this.options.events?.dropped?.({reason:e,heldSomething:n,overlappedOutput:t}),this.emit()}onTurn(e){this.touch();let{chat:t,screen:n,intercept:r,events:i}=this.options,a=n?n(e.text):e.text.trim(),o=this.overAnswer||e.overlappedOutput;if(a&&o&&this.isEcho(a)){t.speaking()&&(this.answerEchoes=!0),this.onDropped(`echo`,e.overlappedOutput);return}if(!a){this.onDropped(`unusable`,e.overlappedOutput);return}if(this.partialText=``,r?.(a)){this.release(),this.emit();return}this.overAnswer||t.speaking()?(this.overAnswer=!1,this.overPending=!1,t.silence()):this.release();let s=this.answering()||this.queue.length>0,c=i?.heard?.(a,{queued:s});this.queue.push({text:a,token:c}),this.flush(),this.emit(!0)}stillWorking(){return this.answeringSince>0&&!this.waiting&&Date.now()-this.answeringSince>=(this.options.progress?.delayMs??6e3)}startProgressTimer(){this.progressTimer=setInterval(()=>this.checkProgress(),250)}checkProgress(){let e=this.engine;if(!e)return;let{chat:t}=this.options;if(!(this.answering()&&!t.speaking())){this.answeringSince&&(this.answeringSince=0,this.progressSpoken=0,this.stopProgress(),this.emit());return}let n=Date.now();this.answeringSince||(this.answeringSince=n);let r=this.options.progress??{},i=this.stillWorking(),a=r.repeatMs??14e3;i&&!this.progressSpeech&&!this.waiting&&!this.state.muted&&e.snapshot.mic!==`hearing`&&this.progressSpoken<(r.maxLines??3)&&(this.progressSpoken===0||n-this.lastProgressAt>=a)&&this.sayProgress(e),this.emit()}sayProgress(e){let t=this.options.progress??{},n=t.language?.(),r=t.lines?.().filter(e=>e.trim())??[],i=r.length?r:Re(n),a=i[this.progressSpoken%i.length];this.progressSpoken+=1,this.lastProgressAt=Date.now(),this.progressHeard=[...this.progressHeard.slice(-5),a],e.log.add(`progress-line`,{index:this.progressSpoken}),this.options.events?.progress?.(a);let o=(t.say??ze)(a,n);o&&(this.progressSpeech=o,e.setOutputActive(!0),o.done.then(()=>{this.progressSpeech===o&&(this.progressSpeech=null,this.engine&&this.engine.setOutputActive(this.outputActive))}))}stopProgress(e=!1){let t=this.progressSpeech;this.progressSpeech=null,t?.stop(),t&&this.engine&&this.engine.setOutputActive(this.options.chat.speaking()),e&&(this.progressTimer&&clearInterval(this.progressTimer),this.progressTimer=null,this.answeringSince=0,this.progressSpoken=0,this.progressHeard=[])}startIdleTimer(){let e=this.options.idleLimitMs??6e4;e&&(this.idleTimer=setInterval(()=>{let t=this.engine;if(!t)return;let{chat:n}=this.options,{mic:r,processing:i}=t.snapshot;this.state.muted||r===`hearing`||i||this.answering()||n.speaking()||this.queue.length||Date.now()-this.lastActivity<(this.waiting?e*5:e)||(t.log.add(`conversation-idle`),this.end(`idle`))},5e3))}emit(e=!1){let t=this.state,n=JSON.stringify(t);!e&&n===this.lastStateKey||(this.lastStateKey=n,this.options.events?.change?.(t))}};const Ve=e=>e.startsWith(`image/`)?`image`:e===`application/pdf`?`pdf`:`other`,He=({state:e,onClose:t})=>{let n=g(),r=b(null);y(()=>{r.current?.focus();let e=e=>{e.key===`Escape`&&(e.stopPropagation(),t())};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[t]);let i=e.status===`ready`?Ve(e.mimeType):`other`;return S(`div`,{class:`cf-preview`,role:`dialog`,"aria-modal":`true`,"aria-label":we(n.attachPreviewTitle,{name:e.name}),onClick:e=>{e.target===e.currentTarget&&t()},children:C(`div`,{class:`cf-preview__frame`,children:[C(`div`,{class:`cf-preview__bar`,children:[S(`span`,{class:`cf-preview__name`,title:e.name,children:e.name}),e.status===`ready`&&S(`a`,{class:`cf-preview__btn`,href:e.url,download:e.name,children:n.attachDownload}),S(`button`,{ref:r,type:`button`,class:`cf-preview__btn cf-preview__close`,"aria-label":n.attachPreviewClose,onClick:t,children:`✕`})]}),C(`div`,{class:`cf-preview__body`,children:[e.status===`loading`&&S(`p`,{class:`cf-preview__note`,children:n.attachPreviewLoading}),e.status===`error`&&S(`p`,{class:`cf-preview__note`,children:n.attachPreviewFailed}),e.status===`ready`&&i===`image`&&S(`img`,{class:`cf-preview__image`,src:e.url,alt:e.name}),e.status===`ready`&&i===`pdf`&&S(`iframe`,{class:`cf-preview__pdf`,src:e.url,title:e.name}),e.status===`ready`&&i===`other`&&S(`p`,{class:`cf-preview__note`,children:n.attachPreviewUnsupported})]})]})})},Ue=({name:e,greeting:t})=>{let n=g();return C(`section`,{class:`cf-empty-welcome`,"aria-label":we(n.welcomeLabel,{name:e}),children:[S(`span`,{class:`cf-empty-welcome__eyebrow`,children:n.welcomeEyebrow}),S(`h2`,{children:e}),S(`p`,{children:t||n.welcomePrompt})]})},We=(e,t,n)=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n();return}if(e.key!==`Tab`)return;let r=Array.from(t.querySelectorAll(`button, [href], textarea, input, select, [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`&&e.tabIndex>=0);if(r.length===0)return;let i=t.getRootNode(),a=e.composedPath()[0],o=a instanceof HTMLElement?a:`activeElement`in i?i.activeElement:document.activeElement,s=r[0],c=r[r.length-1];e.shiftKey&&(o===s||!t.contains(o))?(e.preventDefault(),e.stopPropagation(),c.focus()):!e.shiftKey&&(o===c||!t.contains(o))&&(e.preventDefault(),e.stopPropagation(),s.focus())},D=new Map,Ge=e=>{if(!e||typeof document>`u`||typeof CanvasRenderingContext2D>`u`)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.fillStyle=`#010203`,t.fillStyle=e;let n=t.fillStyle;if(n===`#010203`&&e.trim().toLowerCase()!==`#010203`)return;let r=n.match(/^#([\da-f]{6})$/i)?.[1];if(r)return[Number.parseInt(r.slice(0,2),16),Number.parseInt(r.slice(2,4),16),Number.parseInt(r.slice(4,6),16),1];let i=n.match(/^rgba?\(([\d.]+)[, ]+([\d.]+)[, ]+([\d.]+)(?:[, /]+([\d.]+))?\)$/i);if(!i)return;let a=i.slice(1,5).map(Number);if(!a.some(e=>!Number.isFinite(e)))return[a[0],a[1],a[2],a[3]??1]},Ke=(e,t=`#ffffff`)=>{let n=`${e??``}|${t}`;if(D.has(n))return D.get(n);let r=Ge(e),i=Ge(t)??[255,255,255,1];if(!r){D.set(n,void 0);return}let a=r[3],o=r.slice(0,3).map((e,t)=>e*a+i[t]*(1-a)).map(e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}),s=o[0]*.2126+o[1]*.7152+o[2]*.0722,c=1.05/(s+.05)>=(s+.05)/.059?`#ffffff`:`#0f1e2a`;return D.set(n,c),c},qe=e=>{let[t,n]=x(`light`);return y(()=>{if(e!==`auto`||typeof matchMedia>`u`)return;let t=matchMedia(`(prefers-color-scheme: dark)`),r=()=>n(t.matches?`dark`:`light`);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),e===`auto`?t:e},Je=[`mute`,`end`,`minimize`,`expand`,`shrink`,`wait`,`resume`],Ye=({transport:o,config:l,bindControls:ue,composerDraftStore:me})=>{let u=l.strings,[d,be]=x(l.openByDefault),{persona:f,messages:p,sending:m,assistantSpeaking:h,visitor:Te,hasEmail:Ee,liveMode:g,assignedAgentName:Oe,agentTypingName:ke,starters:_,featuredLinks:Pe,send:w,sendGif:Re,notifyTyping:ze,stop:T,voiceForms:E,voiceReply:Ve,duckSpeaking:D,retry:Ge,rateMessage:Ye,doubleCheckResponse:Xe,retryResponse:Ze,rateExplanation:Qe,explanationTransport:O,injectAssistant:$e,reconnectSupport:et,appendUserDraft:tt,patchMessage:k,removeMessage:nt,submitCsat:rt,submitForm:it,confirmHostedBooking:at,transcribe:ot,liveVoice:st,delegateVoice:ct,setLiveSpeaking:lt,uploadAttachment:ut,loadAttachment:dt,searchGifs:ft,demoSlots:pt,gifEnabled:mt,identify:ht,ended:A,endConversation:gt,startNew:_t,history:vt,viewingSessionId:yt,viewMessages:bt,openConversation:xt,closeHistoryView:St,shutdown:Ct,stopSpeaking:j,speakAssistantText:wt,analyticsModels:Tt,analyticsModelId:Et,selectAnalyticsModel:Dt}=Se(o,l,d),Ot=ge(p,g),[kt,At]=x(null),jt=b(0),Mt=v((e,t,n)=>{n===jt.current&&At({status:`ready`,name:t,url:URL.createObjectURL(e),mimeType:e.type||`application/octet-stream`})},[]),Nt=v((e,t,n)=>{let r=t.name,i=++jt.current;At({status:`loading`,name:r}),dt(e,t,n).then(e=>Mt(e,r,i),()=>{i===jt.current&&At({status:`error`,name:r})})},[dt,Mt]),Pt=v((e,t)=>Mt(e,t,++jt.current),[Mt]),Ft=v(()=>{jt.current+=1,At(null)},[]);y(()=>()=>{kt?.status===`ready`&&URL.revokeObjectURL(kt.url)},[kt]);let It=!!De(f?.actions),[M,Lt]=x(0),[Rt,zt]=x(null),Bt=ee(Rt),[N,Vt]=x({mic:`off`,processing:!1}),[Ht,Ut]=x(null),[Wt,Gt]=x(!1),[P,Kt]=x(!1),[qt,Jt]=x(!1),[Yt,Xt]=x(!1),[Zt,Qt]=x(0),[F,I]=x(!1),[$t,L]=x(null),[en,tn]=x(null),[nn,rn]=x([]),[an,on]=x(``),[sn,cn]=x(()=>{try{return localStorage.getItem(`centrinfo:muted`)===`1`}catch{return!1}}),ln=qe(l.theme),un=f?.soundEnabled??!0;y(()=>{ye(l.sound&&un&&!sn)},[l.sound,un,sn]);let dn=v(()=>{cn(e=>{let t=!e;try{localStorage.setItem(`centrinfo:muted`,t?`1`:`0`)}catch{}return t})},[]),R=b(null),fn=b(null),pn=b(null),mn=b(0),z=b(!1),B=b(!1),V=b(null),H=b(0),hn=b(void 0),gn=b(0),U=b(null),W=b(``),_n=b(()=>{}),vn=b(``),yn=b(m),bn=b(w);bn.current=w;let xn=b(ot);xn.current=ot;let Sn=b(Ve);Sn.current=Ve;let Cn=b({liveVoice:st,delegateVoice:ct,messages:p});Cn.current={liveVoice:st,delegateVoice:ct,messages:p};let wn=b(``);wn.current=[...p].reverse().find(e=>e.role===`assistant`&&e.content.trim())?.content??``;let Tn=b(h);yn.current=m||E.busy,Tn.current=h;let En=P?Wt?`timeout`:Yt||N.mic===`muted`?`muted`:N.mic===`unavailable`?N.reason===`permission-denied`||N.reason===`unsupported`?`denied`:`unavailable`:N.mic===`off`||N.mic===`starting`?`connecting`:N.mic===`hearing`?`hearing`:h?`speaking`:Bt.waiting?`waiting`:Ht??(N.processing||m||E.busy?`processing`:`listening`):`idle`;y(()=>{E.setEnabled(P&&qt&&!A&&!yt&&g===`ai`,V.current?.voiceEngine?.usingLiveAudio)},[E,P,qt,A,yt,g]);let[Dn,On]=x(!0),[kn,An]=x(!1),jn=b(!0);jn.current=Dn;let[G,Mn]=x(!1),[K,q]=x(!1),[J,Y]=x(!1),Nn=b({value:``}),Pn=me??Nn.current,Fn=b({confirmEnd:G,confirmClear:K,showHistory:J});Fn.current={confirmEnd:G,confirmClear:K,showHistory:J};let[In,Ln]=x(!1),X=!!yt,Rn=X?bt:p,zn=Rn.find(e=>e.id===$t&&e.visualization)?.visualization,Bn=Rn.find(e=>e.id===en&&e.visualization);y(()=>{!en||Bn||(tn(null),I(!1))},[en,Bn]),y(()=>{!$t||zn||(L(null),I(!1))},[zn,$t]);let Vn=v(()=>{be(!0),Lt(0),Ce(`open`),l.onOpen?.(),l.onShow?.()},[l]),Z=v(()=>{be(!1),I(!1),L(null),l.onClose?.(),l.onHide?.(),fn.current?.focus()},[l]),Hn=v(()=>d?Z():Vn(),[d,Vn,Z]),Un=v(()=>Mn(!0),[]),Wn=v(()=>{gt(),Mn(!1)},[gt]),Gn=v(()=>{_t(),An(!1),On(!0)},[_t]);y(()=>{ue({open:Vn,close:Z,toggle:Hn,identify:ht,startNew:_t,endConversation:gt,shutdown:Ct})},[ue,Vn,Z,Hn,ht,_t,gt,Ct]),y(()=>{let e=p.filter(e=>e.role===`assistant`&&!e.pending).length;if(d){mn.current=e;return}e>mn.current&&Lt(e-mn.current)},[p,d]),y(()=>{l.onUnreadChange?.(M)},[M,l]),y(()=>{let e=l.sessionDurationMinutes;if(!e||e<=0)return;let t=setTimeout(()=>Ct(),e*60*1e3);return()=>clearTimeout(t)},[l.sessionDurationMinutes,p,d,Ct]),y(()=>{let e=l.customLauncherSelector;if(!e||typeof document>`u`)return;let t=[];try{t=Array.from(document.querySelectorAll(e))}catch{return}let n=e=>{e.preventDefault(),Hn()};return t.forEach(e=>e.addEventListener(`click`,n)),()=>t.forEach(e=>e.removeEventListener(`click`,n))},[l.customLauncherSelector,Hn]);let Kn=b(!1);y(()=>{let e=l.proactiveMessage?.trim();if(!e||Kn.current)return;let t=l.proactiveOnPaths??[],n=typeof location<`u`?location.pathname:``;if(t.length>0&&!t.some(e=>n.includes(e)))return;let r=`centrinfo:proactive:${l.token.slice(0,12)}`;try{if(sessionStorage.getItem(r)===`1`)return}catch{}let i=setTimeout(()=>{if(!(d||A||p.some(e=>e.role===`user`))){Kn.current=!0;try{sessionStorage.setItem(r,`1`)}catch{}$e(e),Vn()}},Math.max(0,l.proactiveDelaySeconds)*1e3);return()=>clearTimeout(i)},[l.proactiveMessage]),y(()=>{let e=pn.current;if(!d||!e)return;let t=p[p.length-1];if(!P&&t?.role===`user`||Dn){let t=requestAnimationFrame(()=>{jn.current&&(e.scrollTop=e.scrollHeight)});return An(!1),()=>cancelAnimationFrame(t)}else An(!0)},[p,d,m,Dn,P]),y(()=>{let e=pn.current;if(!(!d||!e))return Le(e,{isAtBottom:()=>jn.current,onUnseen:()=>An(!0)})},[d,X]);let qn=v(()=>{let e=pn.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight<80;jn.current=t,On(t),t&&An(!1)},[]),Jn=v(()=>{let e=pn.current;e&&(e.scrollTop=e.scrollHeight),jn.current=!0,An(!1),On(!0)},[]),Yn=v(()=>{R.current?.querySelector(`.cf-textarea`)?.focus()},[]),Xn=v((e,t)=>{Ut(e),hn.current&&window.clearTimeout(hn.current),hn.current=window.setTimeout(()=>Ut(null),3e3),t&&!B.current&&wt(t)},[wt]),Zn=v(e=>{let t=U.current;if(t)return t;let n=tt(e);return U.current=n,k(n,{content:W.current||e,pending:!0,streaming:!1}),n},[tt,k]),Qn=v(()=>{let e=U.current;if(e){if(W.current){k(e,{content:W.current,pending:!0});return}U.current=null,nt(e)}},[k,nt]),Q=v(()=>{z.current&&T(),z.current=!1;let e=V.current;V.current=null,e?.end(`user`),B.current=!1;let t=U.current;U.current=null,W.current=``,t&&nt(t),hn.current&&window.clearTimeout(hn.current),Ut(null),Gt(!1),Vt({mic:`off`,processing:!1}),zt(null),Qt(0),Kt(!1),Jt(!1),Xt(!1),I(!1),L(null),j()},[nt,T,j]),$n=v(()=>{F&&L(null),I(!F)},[F]),er=v(e=>{L(e),I(!0)},[]),tr=v(e=>{tn(e),I(!0)},[]),nr=v(()=>{let e=$t,t=en;L(null),tn(null),I(!1),window.requestAnimationFrame(()=>{(t?R.current?.querySelector(`[data-explanation-message="${t}"]`)?.querySelector(`[data-testid="analytics-explanation-expand"]`):Array.from(R.current?.querySelectorAll(`[data-visualization-message]`)??[]).find(t=>t.dataset.visualizationMessage===e))?.focus()})},[$t,en]),rr=v(()=>{L(null),tn(null),I(!1)},[]),ir=v((e,t,n=!1)=>{t&&(k(t,{content:e,pending:!1,streaming:!1}),U.current===t&&(U.current=null)),W.current=``,z.current&&(T(),j(),!E.handleTranscript(e,t)&&bn.current(e,{forceVoicePlayback:!0,userMessageId:t,voiceWaiting:n,onVoiceControl:e=>V.current?.control(e)}))},[k,T,j,E]),ar=v(({overAnswer:e})=>{H.current=Date.now(),Ut(null),e||Zn(u.voiceDraftListening)},[Zn,u.voiceDraftListening]),or=v(e=>{let t=U.current;t&&k(t,{content:`${[W.current,e].filter(Boolean).join(` `)} ...`,pending:!0})},[k]),sr=v(e=>{H.current=Date.now();let t=Zn(e);return k(t,{content:e,pending:!0}),U.current===t&&(U.current=null),W.current=``,t},[Zn,k]),cr=v(({reason:e,heldSomething:t,overlappedOutput:n})=>{H.current=Date.now(),Qn(),!t&&(e===`unusable`?Xn(`misunderstood`):e===`transcribe-failed`&&!n&&Xn(`misunderstood`,`I couldn't transcribe that. Please try again, or type your question.`))},[Qn,Xn]),$=b({speechStart:ar,partial:or,heard:sr,dropped:cr,deliver:ir,stop:T,stopSpeaking:j,duckSpeaking:D});$.current={speechStart:ar,partial:or,heard:sr,dropped:cr,deliver:ir,stop:T,stopSpeaking:j,duckSpeaking:D};let lr=v(()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{rn(e.filter(e=>e.kind===`audioinput`).map((e,t)=>({deviceId:e.deviceId,label:e.label||we(l.strings.microphoneNumbered,{number:String(t+1)})})))}).catch(()=>{})},[l]),ur=v(()=>{if(z.current){Q();return}if(Yn(),!f?.allowVoiceInput||!f.talkbackMode||f.talkbackMode===`text`||yn.current||A||X)return;H.current=Date.now(),B.current=!1,z.current=!0,Xt(!1),Kt(!0),Jt(!1),Gt(!1);let e=!1,t=new Be({chat:{busy:()=>yn.current||Sn.current.status===`answering`,speaking:()=>Tn.current,lastAnswer:()=>wn.current,deliver:(e,t,n)=>$.current.deliver(e,t,n.waiting),cancel:()=>$.current.stop(),silence:()=>$.current.stopSpeaking(),duck:e=>$.current.duckSpeaking(e)},live:Cn.current.liveVoice?{transport:(e,t)=>Cn.current.liveVoice(e,t),delegate:async(e,t,n)=>(H.current=Date.now(),Cn.current.delegateVoice(e,t,n)),context:()=>Cn.current.messages.slice(-8).map(e=>`${e.role}: ${e.content}`).join(`
2
+ `)}:void 0,deviceId:vn.current||void 0,transcribe:async({audio:e,mimeType:t,durationSeconds:n})=>{let r=typeof navigator<`u`&&(navigator.languages?.[0]||navigator.language)||void 0;return fe(await xn.current(e,t,r,n))},screen:Ae,controls:Je,progress:{language:()=>l.locale},idleLimitMs:0,events:{change:n=>{if(V.current!==t)return;let r=n.mic;zt(n),B.current=n.muted,Xt(n.muted),Vt(r),r.mic!==`starting`&&r.mic!==`off`&&Jt(!0),!e&&r.mic===`listening`&&(e=!0,lr())},ended:()=>{V.current===t&&Q()},liveSpeaking:lt,control:e=>_n.current(e),speechStart:e=>$.current.speechStart(e),partial:e=>$.current.partial(e),heard:e=>$.current.heard(e),dropped:e=>$.current.dropped(e),level:e=>{let t=performance.now();t-gn.current<90||(gn.current=t,Qt(e))}}});V.current=t,t.start()},[l.locale,Q,A,Yn,f,lr,X,lt]),dr=v(()=>{let e=!B.current;B.current=e,Xt(e);let t=V.current?.voiceEngine?.snapshot.processing;V.current?.setMuted(e),e&&!t?(W.current=``,Qn()):e||(H.current=Date.now())},[Qn]),fr=v(e=>{switch(H.current=Date.now(),e){case`minimize`:Z();break;case`expand`:I(!0);break;case`shrink`:L(null),I(!1);break}},[Z]);y(()=>{_n.current=fr},[fr]);let pr=v(e=>{vn.current=e,on(e),V.current?.selectDevice(e||void 0)},[]),mr=v(()=>{!z.current||B.current||(V.current?.interrupt(),H.current=Date.now())},[]);y(()=>{V.current?.sync(),H.current=Date.now()},[h]),y(()=>{V.current?.sync()},[m,E.busy,Ve]),y(()=>{if(En!==`denied`)return;let e=window.setTimeout(()=>Q(),3500);return()=>window.clearTimeout(e)},[Q,En]),y(()=>{if(!P)return;let e=window.setInterval(()=>{let e=V.current?.voiceEngine;!e||(V.current?.state.queued.length??0)>0||B.current||yn.current||Tn.current||e.snapshot.mic===`hearing`||e.snapshot.processing||Date.now()-H.current<6e4||(e.log.add(`call-timeout`),Gt(!0),window.setTimeout(()=>Q(),2400))},5e3);return()=>window.clearInterval(e)},[Q,P]);let hr=P&&!Yt&&(m||h);y(()=>()=>Q(),[Q]);let[gr,_r]=x(``),vr=b(!1);y(()=>{if(vr.current&&!m){let e=[...p].reverse().find(e=>e.role===`assistant`&&!e.streaming&&!e.pending&&e.content);e&&_r(e.content)}vr.current=m},[m,p]),Fe(()=>{if(!d)return;let e=R.current,t=G||K?e?.querySelector(`.cf-confirm__card`):J?e?.querySelector(`.cf-history`):null;if(!t)return;let n=t.getRootNode(),r=`activeElement`in n?n.activeElement:document.activeElement;(!r||!t.contains(r))&&t.querySelector(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`)?.focus()},[K,G,d,J]),y(()=>{if(!d)return;let e=R.current,t=G||K?e?.querySelector(`.cf-confirm__card`):J?e?.querySelector(`.cf-history`):null,n=e?.querySelectorAll(`:scope > .cf-header, :scope > .cf-panel__video, :scope > .cf-panel__chat`);n?.forEach(e=>{t?(e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`)):(e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`))}),t||requestAnimationFrame(()=>e?.querySelector(`.cf-textarea`)?.focus());let r=n=>{if(n.key===`Escape`){n.preventDefault();let t=Fn.current;if(t.confirmEnd){Mn(!1);return}if(t.confirmClear){q(!1);return}if(t.showHistory){Y(!1);return}if(e?.querySelector(`.cf-action-drawer`))return;Z();return}if(n.key!==`Tab`||!t)return;let r=t.querySelectorAll(`button, [href], textarea, input, [tabindex]:not([tabindex="-1"])`),i=Array.from(r).filter(e=>!e.hasAttribute(`disabled`));if(i.length===0)return;let a=i[0],o=i[i.length-1],s=t.getRootNode()instanceof ShadowRoot?t.getRootNode().activeElement:document.activeElement;n.shiftKey&&s===a?(n.preventDefault(),o.focus()):!n.shiftKey&&s===o&&(n.preventDefault(),a.focus())};return e?.addEventListener(`keydown`,r),()=>{e?.removeEventListener(`keydown`,r),n?.forEach(e=>{e.removeAttribute(`inert`),e.removeAttribute(`aria-hidden`)})}},[d,Z,G,K,J]),y(()=>{let e=R.current;e&&(d?e.removeAttribute(`inert`):e.setAttribute(`inert`,``))},[d]);let yr=l.accentColor??l.themeTokens?.accent??f?.accentColor,br=l.themeTokens?.accentText??Ke(yr,l.themeTokens?.background??(ln===`dark`?`#0f1c27`:`#ffffff`)),xr={zIndex:l.zIndex,"--cf-h-pad":`${l.horizontalPadding}px`,"--cf-v-pad":`${l.verticalPadding}px`,...br?{"--cf-accent-ink":br}:{},...l.themeTokens?.accentStrong?{"--cf-accent-2":l.themeTokens.accentStrong}:{},...l.themeTokens?.background?{"--cf-bg":l.themeTokens.background}:{},...l.themeTokens?.surface?{"--cf-surface":l.themeTokens.surface}:{},...l.themeTokens?.surfaceMuted?{"--cf-surface-2":l.themeTokens.surfaceMuted}:{},...l.themeTokens?.text?{"--cf-text":l.themeTokens.text}:{},...l.themeTokens?.mutedText?{"--cf-muted":l.themeTokens.mutedText}:{},...l.themeTokens?.border?{"--cf-border":l.themeTokens.border}:{},...l.themeTokens?.shadow?{"--cf-shadow":l.themeTokens.shadow}:{},...l.themeTokens?.radius?{"--cf-radius":l.themeTokens.radius}:{},...l.themeTokens?.fontFamily?{"--cf-font":l.themeTokens.fontFamily}:{},...l.themeTokens?.success?{"--cf-success":l.themeTokens.success}:{},...l.themeTokens?.warning?{"--cf-warning":l.themeTokens.warning}:{},...l.themeTokens?.danger?{"--cf-danger":l.themeTokens.danger}:{},...yr?{"--cf-accent":yr,"--cf-accent-2":l.themeTokens?.accentStrong??`color-mix(in oklab, ${yr} 76%, #14141f)`}:{}},Sr=e=>w(e),Cr=[...p].reverse().find(e=>e.role===`user`&&e.content.trim())?.content??``,wr=p.some(e=>e.role===`user`),Tr=!!(f?.allowVoiceInput&&f?.talkbackMode&&f.talkbackMode!==`text`),Er=!X&&Tr&&!wr?Rn.filter((e,t)=>!(t===0&&e.role===`assistant`)):Rn,Dr=g===`human`&&Oe?Oe:f?.agentName??u.chatName,Or=g===`human`?u.liveSupport:g===`queued`?u.waitingForTeam:f?.offline?u.statusOffline:u.statusOnline,kr=!A&&!X?f?.availableActions:void 0,Ar=!A&&!X?f?.actions:void 0,jr=P&&!qt&&En===`connecting`&&!X;return S(_e,{value:u,children:S(s,{value:E,children:S(e,{value:l.locale,children:C(`div`,{class:`cf-root`,dir:l.dir,"data-theme":ln,"data-align":l.alignment,"data-display":`floating`,style:xr,children:[F&&d&&S(`div`,{class:`cf-theater-backdrop`,onClick:rr}),C(`div`,{ref:R,class:`cf-panel ${d?`is-open`:``} ${P?`cf-panel--call`:``} ${jr?`cf-panel--voice-connecting`:``} ${F&&d?`cf-panel--theater`:``} ${zn||Bn?`cf-panel--analytics-focus`:``}`,role:`dialog`,"aria-modal":`false`,"aria-label":`${u.chatName}: ${f?.agentName??u.assistantName}`,"aria-hidden":!d,children:[kt&&d&&S(He,{state:kt,onClose:Ft}),C(`div`,{class:`cf-header`,children:[S(he,{persona:f,hideWhenMissing:!0}),C(`div`,{class:`cf-header__meta`,children:[S(`div`,{class:`cf-header__name`,children:Dr}),l.token.startsWith(`pub_test_`)?S(`small`,{role:`status`,children:u.testMode}):null,S(`div`,{class:`cf-header__status ${g===`ai`&&f?.offline?`cf-header__status--offline`:``}`,children:S(`span`,{class:`cf-header__status-text`,children:Or})})]}),C(`div`,{class:`cf-header__actions`,children:[vt.length>0&&S(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.pastConversations,title:u.pastConversations,"aria-pressed":J,onClick:()=>Y(e=>!e),children:S(c,{})}),wr&&!A&&!X&&S(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.endChat,title:u.endChat,onClick:Un,children:S(a,{})}),l.sound&&un&&S(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":sn?u.unmuteSounds:u.muteSounds,"aria-pressed":sn,onClick:dn,children:S(sn?te:oe,{})}),S(`button`,{type:`button`,class:`cf-header__btn cf-header__close`,"aria-label":u.closeChat,onClick:Z,children:S(ae,{})})]})]}),S(`div`,{class:`cf-panel__video`,children:zn?S(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:S(t,{visualization:zn,explanationTransport:X?void 0:O(`widget`),onExplanationFeedback:X?void 0:Qe,onOpenAnalyticsSource:l.onOpenAnalyticsSource,expanded:!0,onFollowUp:e=>{nr(),w(e)},onClose:nr})}):Bn?.visualization?S(`div`,{class:`cf-analytics-focus`,role:`region`,"aria-label":u.expandedAnalyticsResult,children:S(xe,{visualization:Bn.visualization,onClose:nr,onFollowUp:e=>{nr(),w(e)},onFeedback:X?void 0:Qe,transport:X?void 0:O(`widget`),onOpenSource:l.onOpenAnalyticsSource})}):!X&&Tr?S(se,{persona:f,starters:[],onPick:w,onFocusComposer:ur,speaking:h,voiceState:En,replyPending:P&&m&&!h,pinned:!0,muted:Yt,onToggleMute:dr,onEndCall:Q,onTalkNow:mr,showTalkNow:hr,micLevel:Zt,theaterMode:F,onToggleTheater:$n,onMinimize:Z,audioDevices:nn,selectedAudioDeviceId:an,onSelectAudioDevice:pr,connectingOnly:jr,answerStillComing:Bt.answerStillComing,stillWorking:Bt.stillWorking,onResume:()=>V.current?.resume()}):null}),!jr&&C(`div`,{class:`cf-panel__chat`,children:[l.preview&&S(`div`,{class:`cf-preview-banner`,children:u.previewBanner}),X&&S(`div`,{class:`cf-viewing-banner`,children:u.viewingPast}),C(`div`,{class:`cf-body`,ref:pn,role:`log`,onScroll:qn,children:[Er.map((e,t)=>S(i,{msg:e,persona:f,isLast:!X&&t===Er.length-1,visitor:Te,hasEmail:Ee,lastQuestion:Cr,showActions:!X&&t===Er.length-1&&!!(e.handoffOffered||e.selectedAction),onPickReply:Sr,onSubmitForm:it,onDemoSlots:pt,onConfirmHostedBooking:at,onRetry:Ge,ratable:!X&&Er.slice(0,t).some(e=>e.role===`user`),onRate:Ye,onDoubleCheck:X||A?void 0:Xe,onRetryResponse:X||A||g!==`ai`?void 0:Ze,doubleCheckDisabled:m,onExplanationFeedback:X?void 0:Qe,explanationTransport:X?void 0:O(`widget`),onOpenAnalyticsSource:l.onOpenAnalyticsSource,onExpandVisualization:X?void 0:er,onExpandExplanation:X?void 0:tr,onOpenAttachment:Nt,onReconnect:!X&&!A&&It&&e.id===Ot?et:void 0},e.id)),!wr&&!X&&C(Ie,{children:[Er.length===0&&S(Ue,{name:f?.agentName??u.assistantName,greeting:f?.greeting}),S(ie,{items:_,onPick:w}),S(je,{items:Pe})]}),kn&&C(`button`,{type:`button`,class:`cf-newmsg`,onClick:Jn,children:[S(ne,{}),u.newMessages]})]}),S(`div`,{class:`cf-sr-live`,"aria-live":`polite`,"aria-atomic":`true`,children:gr}),m&&!A&&!X&&S(`div`,{class:`cf-stopbar`,children:C(`button`,{type:`button`,class:`cf-stop`,onClick:T,children:[S(Ne,{}),u.stop]})}),X?S(`div`,{class:`cf-ended`,children:S(`button`,{type:`button`,class:`cf-ended__btn`,onClick:St,children:u.backToChat})}):A?C(`div`,{class:`cf-ended`,children:[S(`p`,{class:`cf-ended__text`,children:u.conversationEnded}),l.csat&&wr?In?S(`p`,{class:`cf-ended__text`,children:u.feedbackThanks}):C(`div`,{class:`cf-csat`,children:[S(`span`,{class:`cf-csat__q`,children:u.csatPrompt}),S(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackHelpful,onClick:()=>{rt(`up`),Ln(!0)},children:S(le,{})}),S(`button`,{type:`button`,class:`cf-csat__btn`,"aria-label":u.feedbackNotHelpful,onClick:()=>{rt(`down`),Ln(!0)},children:S(n,{})})]}):null,S(`button`,{type:`button`,class:`cf-ended__btn`,onClick:Gn,children:u.startNewChat})]}):C(Ie,{children:[ke?S(`div`,{class:`cf-live-typing`,"aria-live":`polite`,children:we(u.agentTyping,{name:ke})}):null,kr&&kr.length>0&&S(`div`,{class:`cf-footer-actions`,children:S(Me,{actions:kr,descriptors:Ar,visitor:Te,onSubmitForm:it,onDemoSlots:pt,onConfirmHostedBooking:at,scheduler:f?.scheduler,translations:l.actionTranslations})},`footer-actions`),S(r,{toolbarContent:l.showAnalyticsModelSelector?S(de,{models:Tt,value:Et,onChange:Dt,disabled:m}):null,draftStore:Pn,onSend:w,onSendGif:Re,onTyping:ze,disabled:m,allowVoice:!1,onTranscribe:ot,gifEnabled:mt,onSearchGifs:ft,allowAttach:l.attachments,analyzeAttachments:!0,onUpload:ut,onPreviewAttachment:Pt},`composer`)]}),!A&&f?.disclaimerText&&S(`div`,{class:`cf-disclaimer`,children:f.disclaimerText}),C(`div`,{class:`cf-footer`,children:[S(`button`,{type:`button`,class:`cf-footer__privacy`,"aria-label":u.clearDeviceData,onClick:()=>q(!0),children:u.privacyAndData}),S(`span`,{"aria-hidden":`true`,children:`·`}),u.poweredBy,` `,S(`a`,{href:`https://accurixtech.com/centrinfo`,target:`_blank`,rel:`noopener noreferrer`,children:`Centrinfo`})]})]}),G&&S(`div`,{class:`cf-confirm`,onClick:()=>Mn(!1),children:C(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.endChatConfirm,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>We(e,e.currentTarget,()=>Mn(!1)),children:[S(`div`,{class:`cf-confirm__title`,children:u.endChatConfirm}),S(`div`,{class:`cf-confirm__body`,children:u.endChatConfirmBody}),C(`div`,{class:`cf-confirm__actions`,children:[S(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>Mn(!1),children:u.cancel}),S(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:Wn,children:u.endConfirmCta})]})]})},`confirm-end`),J&&S(`div`,{class:`cf-confirm`,onClick:()=>Y(!1),children:C(`div`,{class:`cf-history`,role:`dialog`,"aria-modal":`true`,"aria-label":u.pastConversations,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>We(e,e.currentTarget,()=>Y(!1)),children:[C(`div`,{class:`cf-history__head`,children:[S(`span`,{children:u.pastConversations}),S(`button`,{type:`button`,class:`cf-header__btn`,"aria-label":u.closeHistory,onClick:()=>Y(!1),children:S(ae,{})})]}),S(`div`,{class:`cf-history__list`,children:vt.map(e=>C(`button`,{type:`button`,class:`cf-history__item ${e.sessionId===yt?`is-active`:``}`,onClick:()=>{xt(e.sessionId),Y(!1)},children:[S(`span`,{class:`cf-history__title`,children:e.title}),C(`span`,{class:`cf-history__meta`,children:[ve(e.ts,l.locale,{month:`short`,day:`numeric`}),e.ended?` · ${u.historyEnded}`:``]})]},e.sessionId))}),S(`div`,{class:`cf-history__footer`,children:S(`button`,{type:`button`,class:`cf-history__clear`,onClick:()=>{Y(!1),q(!0)},children:u.clearDeviceData})})]})},`history`),K&&S(`div`,{class:`cf-confirm`,onClick:()=>q(!1),children:C(`div`,{class:`cf-confirm__card`,role:`alertdialog`,"aria-modal":`true`,"aria-label":u.clearDeviceData,onClick:e=>e.stopPropagation(),onKeyDownCapture:e=>We(e,e.currentTarget,()=>q(!1)),children:[S(`div`,{class:`cf-confirm__title`,children:u.clearDeviceData}),S(`div`,{class:`cf-confirm__body`,children:u.clearDeviceDataBody}),C(`div`,{class:`cf-confirm__actions`,children:[S(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--cancel`,onClick:()=>q(!1),children:u.cancel}),S(`button`,{type:`button`,class:`cf-confirm__btn cf-confirm__btn--danger`,onClick:()=>{q(!1),Ct()},children:u.clearDeviceDataCta})]})]})},`confirm-clear`)]}),P&&!d?S(ce,{persona:f,voiceState:En,muted:Yt,onToggleMute:dr,onEndCall:Q,micLevel:Zt,onExpand:Vn}):F&&d?null:!l.hideDefaultLauncher&&C(`button`,{ref:fn,type:`button`,class:`cf-launcher`,"aria-label":d?u.closeChat:M>0?`${u.openChat}. ${we(pe(l.locale,M,u.unreadMessage,u.unreadMessages),{count:String(M)})}`:u.openChat,"aria-expanded":d,onClick:Hn,children:[l.launcherIcon?S(`img`,{class:`cf-launcher__img`,src:l.launcherIcon,alt:``}):S(re,{}),!d&&M>0&&S(`span`,{class:`cf-launcher__badge`,"aria-hidden":`true`,children:M>99?`99+`:M})]})]})})})})},Xe=`centrinfo-widget`;var Ze=class extends HTMLElement{constructor(...e){super(...e),_(this,`controls`,null),_(this,`composerDraftStore`,{value:``}),_(this,`input`,null),_(this,`resolved`,null),_(this,`transport`,null),_(this,`localeRequest`,0),_(this,`localeAbort`,void 0),_(this,`automaticLocale`,void 0)}mountWith(e){let t=me(e);this.input=e,this.resolved=t;let n=this.shadowRoot??this.attachShadow({mode:`open`});if(this.style.zIndex=String(t.zIndex),`adoptedStyleSheets`in Document.prototype&&typeof CSSStyleSheet<`u`&&typeof CSSStyleSheet.prototype.replaceSync==`function`){let e=new CSSStyleSheet;e.replaceSync(ke),n.adoptedStyleSheets=[e]}else{let e=document.createElement(`style`);t.styleNonce&&(e.nonce=t.styleNonce),e.textContent=ke,n.appendChild(e)}this.transport=p(t),t.autoTranslate&&this.transport.loadUITranslations&&!t.demo&&!t.preview&&(this.automaticLocale=u(this.transport.loadUITranslations.bind(this.transport))),this.renderApp(),this.applyLocale()}renderApp(){let e=this.shadowRoot,t=this.resolved,n=this.transport;!e||!t||!n||Pe(S(Oe,{value:t.analyticsRenderer===`local`?void 0:d(t.apiBaseUrl,t.workspaceUrl),children:S(Ye,{transport:n,config:t,bindControls:e=>this.controls=e,composerDraftStore:this.composerDraftStore})}),e)}async applyLocale(){let e=this.input;if(!e||!this.resolved)return;this.localeAbort?.abort();let t=new AbortController;this.localeAbort=t;let n=++this.localeRequest,r=h(e),i=f(r).locale,a=await m(i);if(n!==this.localeRequest||!this.resolved||this.input!==e||(Object.assign(this.resolved,f(r,a)),this.renderApp(),!this.automaticLocale))return;let o={};for(let e of[`widget`,`results`,`viewer`])this.automaticLocale.load({namespace:e,locale:i,signal:t.signal,onCatalog:i=>{if(t.signal.aborted||n!==this.localeRequest||!this.resolved)return;o[e]=i;let s={widget:Te(a.widget,o.widget),results:Te(a.results,o.results,{viewerMessages:o.viewer??{}})};Object.assign(this.resolved,f(r,s)),this.renderApp()}})}setLocale(e){return this.input?(this.input={...this.input,...e.locale===void 0?{}:{locale:e.locale},...e.dir===void 0?{}:{dir:e.dir},...e.strings?{strings:{...this.input.strings,...e.strings}}:{}},this.applyLocale()):Promise.resolve()}open(){this.controls?.open()}close(){this.controls?.close()}toggle(){this.controls?.toggle()}identify(e){this.controls?.identify(e)}clear(){this.controls?.startNew()}shutdown(){this.controls?.shutdown()}unmount(){this.localeAbort?.abort(),this.localeRequest+=1,this.resolved=null,this.shadowRoot&&Pe(null,this.shadowRoot)}disconnectedCallback(){this.localeAbort?.abort()}};typeof customElements<`u`&&!customElements.get(Xe)&&customElements.define(Xe,Ze);const Qe=(e,t=document.body)=>{if(typeof document>`u`)throw Error(`[centrinfo-widget] createWidget must run in a browser.`);let n=document.createElement(Xe);return n.style.pointerEvents=`none`,n.style.position=`fixed`,n.style.inset=`0`,n.style.width=`0`,n.style.height=`0`,t.appendChild(n),n.mountWith(e),{open:()=>n.open(),close:()=>n.close(),toggle:()=>n.toggle(),show:()=>n.open(),hide:()=>n.close(),identify:e=>n.identify(e),update:e=>n.identify(e),clear:()=>n.clear(),shutdown:()=>n.shutdown(),logout:()=>n.shutdown(),setLocale:e=>n.setLocale(e),destroy:()=>{n.unmount(),n.remove()}}},O=e=>Qe(e);let $e=null;const et=e=>{$e?.destroy();let t=O(e);return $e=t,t},tt={init:et,createWidget:O};export{tt as Centrinfo,be as SDK_LANGUAGES,O as createWidget,et as init};