@feathery/react 2.51.0 → 2.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/{fthry_AssistantChat.BsoCfMXK.js → fthry_AssistantChat.B45jvKBe.js} +10 -10
- package/cjs/{fthry_FormControl.BzA7qxHZ.js → fthry_FormControl.EOj0LE3M.js} +1 -1
- package/cjs/{fthry_InlineTooltip.Bw9pgDIw.js → fthry_InlineTooltip.BhdsWEoD.js} +1 -1
- package/cjs/{fthry_PaymentMethodField.D98f9UKS.js → fthry_PaymentMethodField.DYVjg4Fj.js} +3 -3
- package/cjs/{fthry_Placeholder.B_zjw43E.js → fthry_Placeholder.CcwNoUeW.js} +1 -1
- package/cjs/{fthry_ShowEyeIcon.ZLwZPfRq.js → fthry_ShowEyeIcon.DuZqZCnN.js} +1 -1
- package/cjs/{fthry_TabsElement.CCCOq9GT.js → fthry_TabsElement.COJxjNgU.js} +1 -1
- package/cjs/{fthry_auto-track.BAWPFWe0.js → fthry_auto-track.B15NDwyR.js} +2 -2
- package/cjs/{fthry_highlighted-body-TPN3WLV5.CdZUMLQu.js → fthry_highlighted-body-TPN3WLV5.DVEo7HUb.js} +3 -3
- package/cjs/{fthry_index.nZ_8ejIM.js → fthry_index.2QppVzJs.js} +7 -7
- package/cjs/{fthry_index.BUOiRJ-D.js → fthry_index.5X9_5jk4.js} +1 -1
- package/cjs/{fthry_index.Dh6IJZjX.js → fthry_index.5xuF2U9h.js} +1 -1
- package/cjs/{fthry_index.B6G4rkBG.js → fthry_index.B4C3wGGx.js} +29 -29
- package/cjs/{fthry_index.BjYlt6vi.js → fthry_index.B7S5dgOG.js} +2 -2
- package/cjs/{fthry_index.D7EJH94c.js → fthry_index.BBp1wUpf.js} +4 -4
- package/cjs/{fthry_index.DMobY2-N.js → fthry_index.BU6ItWDI.js} +4 -4
- package/cjs/{fthry_index.B7OIkL1Q.js → fthry_index.BkdG1KiI.js} +3 -3
- package/cjs/{fthry_index.unASrteD.js → fthry_index.BoejAzGy.js} +5 -5
- package/cjs/{fthry_index.BpTdFmKU.js → fthry_index.CDnYVEIO.js} +2 -2
- package/cjs/{fthry_index.CSSbMDBw.js → fthry_index.CEqgOh3U.js} +1 -1
- package/cjs/{fthry_index.BJg_1W9K.js → fthry_index.CJ3Hch09.js} +1 -1
- package/cjs/{fthry_index.w57aibSs.js → fthry_index.CacFIYgr.js} +1 -1
- package/cjs/{fthry_index.CCzbgjfm.js → fthry_index.Cmuje9sY.js} +4 -4
- package/cjs/{fthry_index.DIwRTqno.js → fthry_index.CqhOLSKT.js} +5 -5
- package/cjs/{fthry_index.dSgl1CCN.js → fthry_index.CvfYbjM3.js} +2 -2
- package/cjs/{fthry_index.DMslw-i3.js → fthry_index.CyHvGApA.js} +4 -4
- package/cjs/{fthry_index.CMsArMm_.js → fthry_index.D0m2Paql.js} +5 -5
- package/cjs/{fthry_index.BYS0fHe3.js → fthry_index.DJW8jwjF.js} +5 -5
- package/cjs/{fthry_index.C18Er2za.js → fthry_index.DNDEeQCP.js} +1 -1
- package/cjs/{fthry_index.B-OZzdzm.js → fthry_index.DOmwK88R.js} +1 -1
- package/cjs/{fthry_index.BEwHwA6j.js → fthry_index.DPeoLKPF.js} +1 -1
- package/cjs/{fthry_index.Di05NX_O.js → fthry_index.DaU9mnVx.js} +3 -3
- package/cjs/{fthry_index.B2VYo_3L.js → fthry_index.DjKpsFXX.js} +2 -2
- package/cjs/{fthry_index.B3cX_SU8.js → fthry_index.DzwfTsQg.js} +10 -10
- package/cjs/{fthry_index.B-hWSgmS.js → fthry_index.HB6IRHEd.js} +2 -2
- package/cjs/{fthry_index.C9qlOTHf.js → fthry_index.RBFHmwlK.js} +3 -3
- package/cjs/{fthry_index.Bl1Ijmtp.js → fthry_index.Z-VNWfPY.js} +2 -2
- package/cjs/{fthry_index.CC6FOTfH.js → fthry_index.isQxfXbE.js} +1 -1
- package/cjs/{fthry_index.BhDU-naO.js → fthry_index.j-6Dmxvi.js} +1 -1
- package/cjs/{fthry_index.Dr0P3X74.js → fthry_index.l-vIwCek.js} +1 -1
- package/cjs/{fthry_index.Bai03VA8.js → fthry_index.sb9ekedx.js} +2 -2
- package/cjs/{fthry_index.umd.DgFvyHQa.js → fthry_index.umd.BsAzT2x5.js} +1 -1
- package/cjs/{fthry_input.C7BKq5z_.js → fthry_input.BN_eHBxf.js} +1 -1
- package/cjs/{fthry_logging.CfOLa3Tt.js → fthry_logging.DwsvHsLI.js} +1 -1
- package/cjs/{fthry_mermaid-O7DHMXV3.B8USB1Kg.js → fthry_mermaid-O7DHMXV3.Dk3DbMjU.js} +3 -3
- package/cjs/{fthry_script.DrniTFOi.js → fthry_script.CMlEfgqJ.js} +1 -1
- package/cjs/{fthry_styles.2fRCqt5B.js → fthry_styles.CDAJkFkv.js} +1 -1
- package/cjs/{fthry_useElementSize.Dl5cv1ek.js → fthry_useElementSize.CdR9C9j1.js} +1 -1
- package/cjs/{fthry_useSalesforceSync.AymUQfjs.js → fthry_useSalesforceSync.BbSpWhT1.js} +1 -1
- package/cjs/{fthry_webfontloader.BPEBfvjW.js → fthry_webfontloader.CRX0Ppbc.js} +1 -1
- package/cjs/index.js +1 -1
- package/cjs/thumbnail-renderer.js +1 -1
- package/dist/{fthry_AssistantChat.Ib6E1Bq3.js → fthry_AssistantChat.DT_xLu9j.js} +10 -10
- package/dist/{fthry_FormControl.hTupl7ck.js → fthry_FormControl.CjDYAhmh.js} +1 -1
- package/dist/{fthry_InlineTooltip.BssUbqg_.js → fthry_InlineTooltip.BXJBh9xO.js} +1 -1
- package/dist/{fthry_PaymentMethodField.Djyo2xTk.js → fthry_PaymentMethodField.Bmc0ADLl.js} +3 -3
- package/dist/{fthry_Placeholder.CzouKHi6.js → fthry_Placeholder.D2CT1bF2.js} +1 -1
- package/dist/{fthry_ShowEyeIcon.AJJvDqNQ.js → fthry_ShowEyeIcon.2gnnZQwI.js} +1 -1
- package/dist/{fthry_TabsElement.Bs_irzqq.js → fthry_TabsElement.CmDA3WMs.js} +1 -1
- package/dist/{fthry_auto-track.Daz0pfsh.js → fthry_auto-track.C318Fmfp.js} +2 -2
- package/dist/{fthry_highlighted-body-TPN3WLV5.eroZTbSq.js → fthry_highlighted-body-TPN3WLV5.DvjFQ-wQ.js} +3 -3
- package/dist/{fthry_index.DhXWu2Ea.js → fthry_index.BAS9Rj3B.js} +4 -4
- package/dist/{fthry_index.2Sl9-JNb.js → fthry_index.BBVonB9-.js} +1 -1
- package/dist/{fthry_index.C2d1jRBW.js → fthry_index.BGwZT3G8.js} +5 -5
- package/dist/{fthry_index.v__0hwR7.js → fthry_index.BIOOaSUh.js} +4 -4
- package/dist/{fthry_index.OJS8SYip.js → fthry_index.BMLNnooL.js} +2 -2
- package/dist/{fthry_index.BX0Co6y1.js → fthry_index.BdT62ac-.js} +4 -4
- package/dist/{fthry_index.D7M_cXXa.js → fthry_index.Bh5Hgqlr.js} +2 -2
- package/dist/{fthry_index.jn5SIgUf.js → fthry_index.BiAwHsSn.js} +4 -4
- package/dist/{fthry_index.CbJ1X4oH.js → fthry_index.BmPja_lN.js} +7 -7
- package/dist/{fthry_index.Dn7ecnQb.js → fthry_index.BxsXFBiA.js} +4 -4
- package/dist/{fthry_index.B8HUJJnP.js → fthry_index.CHcVd9z4.js} +2 -2
- package/dist/{fthry_index.CvJSciOO.js → fthry_index.CI4tFg9l.js} +29 -29
- package/dist/{fthry_index.BT0EqM-G.js → fthry_index.CREmWhTB.js} +5 -5
- package/dist/{fthry_index.D8-SD3eU.js → fthry_index.CSdrmFzH.js} +5 -5
- package/dist/{fthry_index.D4AWnyyX.js → fthry_index.CUyyWToU.js} +1 -1
- package/dist/{fthry_index.B4Nb9Sji.js → fthry_index.ClcVCvSd.js} +3 -3
- package/dist/{fthry_index.GEWCIsa9.js → fthry_index.CmEl9AjF.js} +1 -1
- package/dist/{fthry_index.BFkYtZJ2.js → fthry_index.CxZihOJg.js} +2 -2
- package/dist/{fthry_index.BVPj0lva.js → fthry_index.D0VQUqXz.js} +1 -1
- package/dist/{fthry_index.r4Ruls8S.js → fthry_index.D2U9Y4Jc.js} +1 -1
- package/dist/{fthry_index.pJdw8fzl.js → fthry_index.D7coWJsd.js} +1 -1
- package/dist/{fthry_index.BUsitTZS.js → fthry_index.DGl27K_w.js} +1 -1
- package/dist/{fthry_index.D7GXEV6M.js → fthry_index.DlEhwT48.js} +1 -1
- package/dist/{fthry_index.B9PcKkAq.js → fthry_index.Dmsa_IWB.js} +1 -1
- package/dist/{fthry_index.Dk2qH_mD.js → fthry_index.Dvdg0UC6.js} +1 -1
- package/dist/{fthry_index.zmnisF_Z.js → fthry_index.DxoyRmcK.js} +2 -2
- package/dist/{fthry_index.rteqieKy.js → fthry_index.SqN7TeCH.js} +2 -2
- package/dist/{fthry_index.D09J5ND-.js → fthry_index.Vno16k5B.js} +3 -3
- package/dist/{fthry_index.Bi7P0Xct.js → fthry_index.ZMPDKzng.js} +2 -2
- package/dist/{fthry_index.BhzPTCxe.js → fthry_index.cZ4fV2Jh.js} +3 -3
- package/dist/{fthry_index.BbVR1AtA.js → fthry_index.eGwSNYvd.js} +1 -1
- package/dist/{fthry_index.CbFfAKDZ.js → fthry_index.fOZIYWtf.js} +10 -10
- package/dist/{fthry_index.umd.B6z1ClBd.js → fthry_index.umd.xldORs1x.js} +1 -1
- package/dist/{fthry_input.Cpq5jq9k.js → fthry_input.6Rwsft76.js} +1 -1
- package/dist/{fthry_logging.DzR9660y.js → fthry_logging.DWvo9mx5.js} +1 -1
- package/dist/fthry_mermaid-O7DHMXV3.CpHtnz5w.js +8 -0
- package/dist/{fthry_script.DnFzekPL.js → fthry_script.DNhdCztr.js} +1 -1
- package/dist/{fthry_styles.DhyJBYwb.js → fthry_styles.DPXDsQxq.js} +1 -1
- package/dist/{fthry_useElementSize.Dbmsu96w.js → fthry_useElementSize.orrnTjTM.js} +1 -1
- package/dist/{fthry_useSalesforceSync.BzPu52nT.js → fthry_useSalesforceSync.C66IFKe6.js} +1 -1
- package/dist/{fthry_webfontloader.DpJa4nSy.js → fthry_webfontloader.BZYYUrT8.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/thumbnail-renderer.js +1 -1
- package/package.json +1 -1
- package/umd/AssistantChat.f4f1a5ab9a911c339fd1.js +1 -0
- package/umd/index.js +1 -1
- package/dist/fthry_mermaid-O7DHMXV3.Bz4-4YvV.js +0 -8
- package/umd/AssistantChat.dc0944bf4eba51ea8102.js +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { u as Mermaid } from './fthry_AssistantChat.Ib6E1Bq3.js';
|
|
2
|
-
import './fthry_index.CvJSciOO.js';
|
|
3
|
-
import 'react/jsx-runtime';
|
|
4
|
-
import 'react';
|
|
5
|
-
import 'jszip';
|
|
6
|
-
import 'react-dom';
|
|
7
|
-
import './fthry_clsx.ChV9xqsO.js';
|
|
8
|
-
import './fthry_index.D4AWnyyX.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(this.webpackChunkFeathery=this.webpackChunkFeathery||[]).push([[917],{33900:(e,t,n)=>{n.r(t),n.d(t,{default:()=>At});var r=n(35944),o=n(67294),i=n(91247),a=n(74790),l=n(74438),u=function(){return u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},u.apply(this,arguments)},s=function(e){return(0,r.tZ)("svg",u({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none"},e,{children:(0,r.tZ)("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})}))},c=function(e){return(0,r.tZ)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:(0,r.tZ)("path",{d:"m6 9 6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))},d=function(e){return(0,r.BX)("svg",u({width:"20",height:"20",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("path",{d:"m22 2-7 20-4-9-9-4 20-7z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.tZ)("path",{d:"m22 2-11 11",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}))},p=function(e){return(0,r.BX)("svg",u({width:"16",height:"16",style:{borderRadius:"50%"},viewBox:"0 0 50 50"},e,{children:[(0,r.tZ)("circle",{cx:25,cy:25,r:22.5,style:{fill:"none",stroke:"#f5cbcb",strokeWidth:3,opacity:1}}),(0,r.tZ)("circle",{cx:25,cy:25,r:22.5,style:{fill:"none",stroke:"#e2626e",strokeWidth:3,opacity:1,strokeLinecap:"round",transformOrigin:"50% 50%",transform:"rotate3d(0,0,1,0deg)",animation:"2156ms ease-in-out 0s infinite normal none running feathery-spinner-arc,1829ms linear 0s infinite normal none running feathery-spinner-rotate"}})]}))},f=function(e){return(0,r.BX)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("path",{d:"M18 6 6 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.tZ)("path",{d:"m6 6 12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}))},h=function(e){return(0,r.tZ)("svg",u({width:"14",height:"14",viewBox:"0 0 24 24",fill:"none"},e,{children:(0,r.tZ)("polyline",{points:"20 6 9 17 4 12",stroke:"#10b981",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))},v=function(e){return(0,r.tZ)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:(0,r.tZ)("path",{d:"m6 9 6 6 6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))},y=function(e){return(0,r.BX)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),(0,r.tZ)("rect",{x:"12",y:"12",width:"7",height:"7",rx:"1",stroke:"currentColor",strokeWidth:"2"})]}))},g=function(e){return(0,r.BX)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),(0,r.tZ)("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"})]}))},b=function(e){return(0,r.BX)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),(0,r.tZ)("path",{d:"M15 3v18",stroke:"currentColor",strokeWidth:"2"})]}))},m=function(e){return(0,r.BX)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("path",{d:"M4 9V5a1 1 0 0 1 1-1h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.tZ)("path",{d:"M20 9V5a1 1 0 0 0-1-1h-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.tZ)("path",{d:"M4 15v4a1 1 0 0 0 1 1h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.tZ)("path",{d:"M20 15v4a1 1 0 0 1-1 1h-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}))},x=function(e){return(0,r.tZ)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:(0,r.tZ)("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}))},w=function(e){return(0,r.BX)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("path",{d:"m11 17-5-5 5-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.tZ)("path",{d:"m18 17-5-5 5-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}))},k=function(e){return(0,r.BX)("svg",u({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("path",{d:"m6 17 5-5-5-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.tZ)("path",{d:"m13 17 5-5-5-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}))},S=function(e){return(0,r.BX)("svg",u({width:"12",height:"12",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.tZ)("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}))},C=function(e){return(0,r.BX)("svg",u({width:"20",height:"20",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3",stroke:"currentColor",strokeWidth:"2"}),(0,r.tZ)("path",{d:"M5 11a7 7 0 0 0 14 0",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,r.tZ)("path",{d:"M12 18v3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}))},A=function(e){return(0,r.BX)("svg",u({width:"18",height:"18",viewBox:"0 0 24 24",fill:"none"},e,{children:[(0,r.tZ)("path",{d:"M4 12v0",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,r.tZ)("path",{d:"M8 9v6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,r.tZ)("path",{d:"M12 5v14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,r.tZ)("path",{d:"M16 9v6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,r.tZ)("path",{d:"M20 11v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}))},_=n(39479),I=function(){function e(e){void 0===e&&(e={}),this.building=[],this.queue=[],this.playIndex=0,this.ended=!1,this.playing=!1,this.audio=null,this.objectUrl=null,this.rafId=null,this.opts=e}return Object.defineProperty(e.prototype,"isPlaying",{get:function(){return this.playing},enumerable:!1,configurable:!0}),e.prototype.pushChunk=function(e){this.building.push(function(e){for(var t=(0,_.Kv)().atob(e),n=new Uint8Array(t.length),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}(e))},e.prototype.pushSegment=function(e){this.queue.push({text:e,bytes:this.building}),this.building=[],this.playing=!0,this.playNext()},e.prototype.end=function(){this.ended=!0,this.playNext()},e.prototype.skip=function(){this.teardown()},e.prototype.playNext=function(){var e,t,n,r,o=this;if(!this.audio){var i=this.queue[this.playIndex];if(i){if(0===i.bytes.length)return null===(r=(n=this.opts).onSegmentEnd)||void 0===r||r.call(n,i.text),this.playIndex+=1,void this.playNext();var a=URL.createObjectURL(new Blob(i.bytes,{type:"audio/mpeg"})),l=new Audio(a);this.audio=l,this.objectUrl=a,l.onplaying=function(){var e,t;o.audio===l&&(null===(t=(e=o.opts).onSegmentStart)||void 0===t||t.call(e,i.text),o.startReveal(l,i.text))},l.onended=function(){return o.finishClip(l,i.text)},l.onerror=function(){return o.finishClip(l,i.text)},l.play().catch((function(){return o.finishClip(l,i.text)}))}else this.ended&&this.playing&&(this.playing=!1,null===(t=(e=this.opts).onIdle)||void 0===t||t.call(e))}},e.prototype.startReveal=function(e,t){var n=this,r=(0,_.Kv)(),o=function(){var i,a;if(n.audio===e){var l=e.duration,u=l&&isFinite(l)&&l>0?Math.min(1,e.currentTime/l*1.5):0;null===(a=(i=n.opts).onSegmentProgress)||void 0===a||a.call(i,t,u),n.rafId=r.requestAnimationFrame(o)}else n.rafId=null};this.rafId=r.requestAnimationFrame(o)},e.prototype.stopReveal=function(){null!==this.rafId&&((0,_.Kv)().cancelAnimationFrame(this.rafId),this.rafId=null)},e.prototype.finishClip=function(e,t){var n,r;this.audio===e&&(this.stopReveal(),null===(r=(n=this.opts).onSegmentEnd)||void 0===r||r.call(n,t),e.pause(),e.src="",this.audio=null,this.objectUrl&&(URL.revokeObjectURL(this.objectUrl),this.objectUrl=null),this.playIndex+=1,this.playNext())},e.prototype.teardown=function(){var e,t;this.stopReveal(),this.audio&&(this.audio.pause(),this.audio.src="",this.audio=null),this.objectUrl&&(URL.revokeObjectURL(this.objectUrl),this.objectUrl=null),this.building=[],this.queue=[],this.playIndex=0,this.ended=!1,this.playing=!1,null===(t=(e=this.opts).onIdle)||void 0===t||t.call(e)},e}(),T=function(){function e(e){this.vad=null,this.paused=!1,this.opts=e}return e.prototype.start=function(){return e=this,t=void 0,o=function(){var e,t,r,o,i=this;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,Promise.all([n.e(762),n.e(129)]).then(n.bind(n,39762))];case 1:return e=a.sent(),t=e.MicVAD,r=e.utils,[4,n.e(968).then(n.bind(n,66968))];case 2:return a.sent().log.debug=function(){},o=this,[4,t.new({baseAssetPath:"https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.30/dist/",onnxWASMBasePath:"https://cdn.jsdelivr.net/npm/onnxruntime-web@1.27.0/dist/",getStream:function(){return(0,_.Kv)().navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}})},onSpeechStart:function(){i.paused||i.opts.onSpeechStart()},onSpeechEnd:function(e){if(!(i.paused||e.length<6400)){var t=new Blob([r.encodeWAV(e)],{type:"audio/wav"});i.opts.onUtterance(t)}}})];case 3:return o.vad=a.sent(),this.vad.start(),[2,!0];case 4:return a.sent(),this.vad=null,[2,!1];case 5:return[2]}}))},new((r=void 0)||(r=Promise))((function(n,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function l(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,l)}u((o=o.apply(e,t||[])).next())}));var e,t,r,o},e.prototype.pause=function(){var e;this.paused=!0,null===(e=this.vad)||void 0===e||e.pause()},e.prototype.resume=function(){var e;this.paused=!1,null===(e=this.vad)||void 0===e||e.start()},e.prototype.destroy=function(){var e;null===(e=this.vad)||void 0===e||e.destroy(),this.vad=null},e}();function Z(){var e;try{var t=null===(e=(0,_.Kv)().navigator)||void 0===e?void 0:e.mediaDevices;return!!t&&"function"==typeof t.getUserMedia}catch(e){return!1}}var R=function(){return R=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},R.apply(this,arguments)},L=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},j=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},E=function(e){return e.replace(/\s/g,"").length},B="#6b7280",O="#f9fafb",M="#e5e7eb",W="#9ca3af",K="#6b7280",z="#1f2937",F="#ef4444",N=function(e,t){var n=parseInt(e.replace("#",""),16),r=Math.min(255,Math.max(0,(n>>16)+Math.round(2.55*t))),o=Math.min(255,Math.max(0,(n>>8&255)+Math.round(2.55*t))),i=Math.min(255,Math.max(0,(255&n)+Math.round(2.55*t)));return"#".concat((r<<16|o<<8|i).toString(16).padStart(6,"0"))},D=function(){return D=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},D.apply(this,arguments)},P=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},X=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},U={searchWeb:{running:"Searching the web...",done:"Searched the web"},scrapeUrl:{running:"Reading web page...",done:"Read the web page"},searchDocuments:{running:"Searching documents...",done:"Searched the documents"},setFieldValue:{running:"Updating form fields...",done:"Updated form fields"},clickElement:{running:"Running form action...",done:"Ran the form action"},addTableRow:{running:"Adding a row...",done:"Added a row"},deleteTableRow:{running:"Deleting a row...",done:"Deleted a row"},setTableCellValue:{running:"Updating table cells...",done:"Updated table cells"},triggerTableAction:{running:"Running table action...",done:"Ran the table action"},getPanelSnapshot:{running:"Reading the form...",done:"Reviewed the form"},getFuserSnapshot:{running:"Looking up your submission...",done:"Reviewed the submission"},getExtractionSnapshot:{running:"Reading extraction setup...",done:"Reviewed the extraction setup"},getExtractionResults:{running:"Reading extraction results...",done:"Reviewed the extraction results"},listFormExtractions:{running:"Looking up extractions...",done:"Reviewed available extractions"},getLogicRules:{running:"Reading form logic...",done:"Reviewed form logic"},listFormHubs:{running:"Looking up records on file...",done:"Reviewed available records"},getHubSchema:{running:"Reading record setup...",done:"Reviewed the record setup"},queryHub:{running:"Searching records on file...",done:"Searched the records on file"}},V=function(e){try{var t=new URL(e);return t.hostname+("/"!==t.pathname?t.pathname:"")}catch(t){return e}},q=function(e){if(!e||"object"!=typeof e)return[];var t=e,n=[],r=function(e){return e.map((function(e){return"object"==typeof e&&null!==e&&e.url||""})).filter(Boolean)};return Array.isArray(t.web)&&n.push.apply(n,X([],P(r(t.web)),!1)),Array.isArray(t.news)&&n.push.apply(n,X([],P(r(t.news)),!1)),Array.isArray(t.images)&&n.push.apply(n,X([],P(r(t.images)),!1)),"string"==typeof t.url&&t.url&&n.push(t.url),n.length>0?Array.from(new Set(n)):Array.isArray(e)?Array.from(new Set(r(e))):[]},H=function(e){return"input-streaming"===e||"input-available"===e},Y=function(e){return"output-error"===e.state||"object"==typeof e.output&&null!==e.output&&!1===e.output.ok},G=function(e){var t,n=e.row,o=e.linkColor,i=e.indent,a=void 0===i?24:i,l=null===(t=n.input)||void 0===t?void 0:t.query,u=q(n.output);return l||u.length>0?(0,r.BX)("div",D({css:{display:"flex",flexDirection:"column",gap:"4px",paddingLeft:"".concat(a,"px"),marginTop:"2px",marginBottom:"4px"}},{children:[l&&(0,r.BX)("div",D({css:{color:W,fontSize:"12px",fontStyle:"italic"}},{children:['"',l.length>80?l.substring(0,80)+"...":l,'"']})),u.map((function(e,t){return(0,r.BX)("a",D({href:e,target:"_blank",rel:"noopener noreferrer",css:{fontSize:"12px",color:o,textDecoration:"none",display:"flex",alignItems:"center",gap:"4px",minWidth:0,":hover":{textDecoration:"underline"}}},{children:[(0,r.tZ)(S,{css:{flexShrink:0}}),(0,r.tZ)("span",D({css:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:V(e)}))]}),t)}))]})):null},J=function(e){var t;return!!(null===(t=e.input)||void 0===t?void 0:t.query)||q(e.output).length>0},$=function(e){var t,n,r=U[e.toolName]||{running:"Working...",done:"Done"};return H(e.state)?r.running:Y(e)?null!==(t=r.done)&&void 0!==t?t:"Failed":null!==(n=r.done)&&void 0!==n?n:r.running},Q={backgroundImage:"linear-gradient(90deg, ".concat(K," 25%, #d1d5db 50%, ").concat(K," 75%)"),backgroundSize:"220% 100%",backgroundClip:"text",WebkitBackgroundClip:"text",color:"transparent",animation:"feathery-tool-shimmer 1.6s linear infinite","@keyframes feathery-tool-shimmer":{from:{backgroundPosition:"160% 0"},to:{backgroundPosition:"-60% 0"}}},ee=function(e){var t=e.rows,n=e.followedByText,i=e.turnFinished,a=e.audioPending,l=void 0!==a&&a,u=e.linkColor,s=void 0===u?B:u,d=e.isFirstChunk,p=void 0!==d&&d,h=t.some((function(e){return H(e.state)})),v=!h&&!l&&(n||i),y=!(!h&&!l&&n),g=P((0,o.useState)(null),2),b=g[0],m=g[1],x=null!=b?b:y,w=function(){return m(!x)},k=D({display:"flex",flexDirection:"column",gap:"2px",fontSize:"13px",minWidth:0,paddingLeft:"".concat(14,"px")},p?{}:{animation:"feathery-chunk-fade-in 220ms ease-out both","@keyframes feathery-chunk-fade-in":{from:{opacity:0,transform:"translateY(4px)"},to:{opacity:1,transform:"translateY(0)"}}}),S=t.filter((function(e){return e.toolName in U}));if(v&&1===S.length){var C=S[0],A=Y(C),_=J(C);return(0,r.BX)("div",D({css:k},{children:[(0,r.BX)("button",D({type:"button",onClick:_?w:void 0,css:{display:"inline-flex",alignItems:"center",gap:"6px",background:"none",border:"none",padding:"4px 0",cursor:_?"pointer":"default",color:K,textAlign:"left",font:"inherit",fontSize:"13px",alignSelf:"flex-start"}},{children:[A&&(0,r.tZ)(f,{css:{width:"12px",height:"12px",color:F}}),(0,r.tZ)("span",{children:$(C)}),_&&(0,r.tZ)(c,{css:{width:"12px",height:"12px",color:W,transform:x?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",flexShrink:0}})]})),_&&x&&(0,r.tZ)(G,{row:C,linkColor:s,indent:6})]}))}var I=v?"Finished working":"Working on it...",T=S.length>0;return(0,r.BX)("div",D({css:k},{children:[(0,r.BX)("button",D({type:"button",onClick:T?w:void 0,css:{display:"inline-flex",alignItems:"center",gap:"6px",background:"none",border:"none",padding:"4px 0",cursor:T?"pointer":"default",color:K,textAlign:"left",font:"inherit",fontSize:"13px",alignSelf:"flex-start"}},{children:[(0,r.tZ)("span",D({css:v?void 0:Q},{children:I})),T&&(0,r.tZ)(c,{css:{width:"12px",height:"12px",color:W,transform:x?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",flexShrink:0}})]})),T&&x&&(0,r.tZ)("div",D({css:{display:"flex",flexDirection:"column",gap:"2px",marginLeft:"5px",paddingLeft:"13px",borderLeft:"2px solid ".concat(M)}},{children:S.map((function(e){return(0,r.tZ)(te,{row:e,linkColor:s},e.key)}))}))]}))},te=function(e){var t=e.row,n=e.linkColor,i=J(t),a=H(t.state),l=Y(t),u=P((0,o.useState)(null),2),s=u[0],d=u[1],v=null!=s?s:a,y=i?"button":"div";return(0,r.BX)("div",D({css:{display:"flex",flexDirection:"column",gap:"2px"}},{children:[(0,r.BX)(y,D({type:i?"button":void 0,onClick:i?function(){return d(!v)}:void 0,css:{display:"inline-flex",alignItems:"center",gap:"6px",color:l?F:K,background:"none",border:"none",padding:"2px 0",textAlign:"left",cursor:i?"pointer":"default",font:"inherit",fontSize:"13px",alignSelf:"flex-start"}},{children:[a?(0,r.tZ)(p,{css:{width:"12px",height:"12px"}}):l?(0,r.tZ)(f,{css:{width:"12px",height:"12px"}}):(0,r.tZ)(h,{css:{width:"12px",height:"12px"}}),(0,r.tZ)("span",D({css:a?Q:void 0},{children:$(t)})),i&&(0,r.tZ)(c,{css:{width:"10px",height:"10px",color:W,transform:v?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",flexShrink:0}})]})),i&&v&&(0,r.tZ)(G,{row:t,linkColor:n})]}))},ne=function(){return(0,r.tZ)("div",D({css:{display:"flex",flexDirection:"column",gap:"2px",fontSize:"13px",minWidth:0,paddingLeft:"14px",animation:"feathery-chunk-fade-in 220ms ease-out both","@keyframes feathery-chunk-fade-in":{from:{opacity:0,transform:"translateY(4px)"},to:{opacity:1,transform:"translateY(0)"}}}},{children:(0,r.tZ)("div",D({css:{padding:"4px 0",color:K,fontSize:"13px",alignSelf:"flex-start"}},{children:(0,r.tZ)("span",D({css:Q},{children:"Working on it..."}))}))}))},re=n(70917),oe=n(14123),ie=function(){return ie=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},ie.apply(this,arguments)},ae=(0,re.iv)({color:"#2563eb",fontWeight:400,textDecoration:"underline",textUnderlineOffset:"0.12em",textDecorationSkipInk:"auto",overflowWrap:"break-word","&:visited":{color:"#6d28d9"},"&:hover":{color:"#1d4ed8"}}),le=(0,re.iv)('\n & p,\n & [data-streamdown="ordered-list"],\n & [data-streamdown="unordered-list"],\n & [data-streamdown="blockquote"],\n & [data-streamdown="code-block"],\n & [data-streamdown^="heading-"],\n & [data-streamdown="horizontal-rule"] {\n margin-top: 0 !important;\n margin-bottom: 0.6em !important;\n }\n & > *:last-child,\n & p:last-child,\n & [data-streamdown="ordered-list"]:last-child,\n & [data-streamdown="unordered-list"]:last-child,\n & [data-streamdown="blockquote"]:last-child,\n & [data-streamdown="code-block"]:last-child,\n & [data-streamdown^="heading-"]:last-child {\n margin-bottom: 0 !important;\n }\n\n & [data-streamdown="strong"],\n & strong,\n & b {\n font-weight: 600 !important;\n }\n & em,\n & i {\n font-style: italic !important;\n }\n\n & [data-streamdown="heading-1"] {\n font-size: 1.25em !important;\n font-weight: 600 !important;\n }\n & [data-streamdown="heading-2"] {\n font-size: 1.15em !important;\n font-weight: 600 !important;\n }\n & [data-streamdown="heading-3"] {\n font-size: 1.05em !important;\n font-weight: 600 !important;\n }\n & [data-streamdown="heading-4"],\n & [data-streamdown="heading-5"],\n & [data-streamdown="heading-6"] {\n font-size: 1em !important;\n font-weight: 600 !important;\n }\n\n & [data-streamdown="ordered-list"],\n & [data-streamdown="unordered-list"] {\n padding-left: 1.25em !important;\n }\n & [data-streamdown="ordered-list"] {\n list-style: decimal !important;\n }\n & [data-streamdown="unordered-list"] {\n list-style: disc !important;\n }\n & [data-streamdown="list-item"] {\n margin-bottom: 0.2em !important;\n }\n & [data-streamdown="list-item"]:last-child {\n margin-bottom: 0 !important;\n }\n\n & [data-streamdown="inline-code"] {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;\n font-size: 0.9em !important;\n padding: 0.1em 0.3em !important;\n border-radius: 4px !important;\n background-color: rgba(0, 0, 0, 0.06) !important;\n }\n & [data-streamdown="code-block"] {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;\n font-size: 0.9em !important;\n padding: 0.5em 0.75em !important;\n border-radius: 6px !important;\n background-color: rgba(0, 0, 0, 0.06) !important;\n overflow-x: auto !important;\n }\n\n & [data-streamdown="blockquote"] {\n padding-left: 0.75em !important;\n border-left: 3px solid rgba(0, 0, 0, 0.15) !important;\n color: rgba(0, 0, 0, 0.75) !important;\n }\n\n & [data-streamdown="horizontal-rule"] {\n border: 0 !important;\n border-top: 1px solid rgba(0, 0, 0, 0.12) !important;\n margin: 0.6em 0 !important;\n }\n'),ue={a:function(e){var t=e.href,n=e.children;return(0,r.tZ)("a",ie({href:t,target:"_blank",rel:"noopener noreferrer",css:ae},{children:n}))}},se=(0,o.memo)((function(e){var t=e.text,n=e.isStreaming,o=void 0!==n&&n;return(0,r.tZ)("div",ie({css:le},{children:(0,r.tZ)(oe.qI,ie({components:ue,isAnimating:o,parseIncompleteMarkdown:o},{children:t}))}))}));se.displayName="MarkdownText";const ce=se;var de=function(){return de=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},de.apply(this,arguments)},pe=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function l(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}u((r=r.apply(e,t||[])).next())}))},fe=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}},he=function(e,t){return pe(void 0,void 0,void 0,(function(){var n;return fe(this,(function(r){switch(r.label){case 0:return[4,fetch("".concat(e,"threads/"),{headers:t()})];case 1:return(n=r.sent()).ok?[2,n.json()]:[2,null]}}))}))},ve=function(e,t,n){return pe(void 0,void 0,void 0,(function(){var r;return fe(this,(function(o){switch(o.label){case 0:return[4,fetch("".concat(e,"threads/").concat(n,"/"),{headers:t()})];case 1:return(r=o.sent()).ok?[2,r.json()]:[2,null]}}))}))},ye=function(e,t,n){return pe(void 0,void 0,void 0,(function(){return fe(this,(function(r){switch(r.label){case 0:return[4,fetch("".concat(e,"threads/").concat(n,"/"),{method:"DELETE",headers:t()})];case 1:return r.sent(),[2]}}))}))},ge=n(95710),be=n(14428),me=n(54665),xe=n(93861),we=n(18837),ke=n(7193),Se=n(67948),Ce=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Ae=function(e){var t,n,r,o,i={},a=null!==(r=null==e?void 0:e.inlineErrors)&&void 0!==r?r:{};try{for(var l=Ce(Object.keys(a)),u=l.next();!u.done;u=l.next()){var s=u.value,c=null===(o=a[s])||void 0===o?void 0:o.message;"string"==typeof c&&c.length>0&&(i[s]=c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}return i},_e=function(e,t){var n,r;if(!Array.isArray(e)||!Array.isArray(t)||0===t.length)return[];var o=[];try{for(var i=Ce(e),a=i.next();!a.done;a=i.next()){var l=a.value,u=Array.isArray(null==l?void 0:l.position)?l.position:[];if(!(u.length>=t.length)){for(var s=!0,c=0;c<u.length;c++)if(u[c]!==t[c]){s=!1;break}s&&o.push(l)}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return o.sort((function(e,t){return t.position.length-e.position.length})),o};function Ie(e,t,n,r){if(!t)return"number"==typeof e?{errorType:"repeated_index_unexpected",error:"'".concat(r,"' is not in a repeated container; do not pass repeatIndex.")}:null;if("number"!=typeof e){var o=0===n?"(none yet - add a row first)":"0..".concat(n-1);return{errorType:"repeated_index_missing",error:"'".concat(r,"' is in a repeated container; pass repeatIndex ").concat(o,".")}}return e<0||e>=n?{errorType:"repeated_index_out_of_range",error:"repeatIndex ".concat(e," is out of range for '").concat(r,"' (rowCount ").concat(n,").")}:null}var Te=function(e,t){var n,r,o,i,a;if(!e)return{ok:!1,errorType:"no_form_state",error:"Form has not loaded yet."};var l=be.Z[e];if(!l||!l.currentStep||!l.assistantClient)return{ok:!1,errorType:"no_form_state",error:"Form has not loaded yet."};if("string"!=typeof t||0===t.length)return{ok:!1,errorType:"shape_mismatch",error:"tableId is required."};var u=(null!==(n=l.currentStep.tables)&&void 0!==n?n:[]).find((function(e){return(null==e?void 0:e.id)===t}));if(!u)return{ok:!1,errorType:"not_on_step",error:"Table '".concat(t,"' is not on the current step.")};var s=null===(r=l.visiblePositions)||void 0===r?void 0:r[null!==(o=(0,we.gh)(u))&&void 0!==o?o:"root"];if(Array.isArray(s)&&!s.some(Boolean))return{ok:!1,errorType:"hidden",error:"Table '".concat(t,"' is on the current step but is hidden right now.")};var c=Array.isArray(null===(i=null==u?void 0:u.properties)||void 0===i?void 0:i.columns)?u.properties.columns:[],d=null!==(a=l.fields)&&void 0!==a?a:{},p=c.reduce((function(e,t){var n,r=(null==t?void 0:t.field_key)?null===(n=d[t.field_key])||void 0===n?void 0:n.value:void 0;return Array.isArray(r)?Math.max(e,r.length):e}),0);return{ok:!0,found:{state:l,table:u,columns:c,rowCount:p}}},Ze=function(e,t){var n,r=null!==(n=null==e?void 0:e.properties)&&void 0!==n?n:{},o=!(!r.enable_editing||r.transpose&&t>0),i=o&&!!r.add_delete_rows;return{canEditCells:o,canAddRows:i,canDeleteRows:i}},Re=function(){return Re=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Re.apply(this,arguments)},Le=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},je=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},Ee=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Be=function(e){var t=e.text;if("string"==typeof t&&t.trim())return t;var n=e.text_formatted,r=Array.isArray(n)?n:null==n?void 0:n.ops;return Array.isArray(r)?r.map((function(e){return"string"==typeof(null==e?void 0:e.insert)?e.insert:""})).join("").trim():""},Oe=function(e,t){if(!e)return"";try{return(0,me.xf)(e,t)}catch(t){return e}},Me=new Set(["submit","load"]),We=function(e,t,n,r){return(null!=e?e:[]).some((function(e){if((null==e?void 0:e.trigger_event)!==t)return!1;if(!1===e.enabled||!1===e.valid)return!1;var o=e.steps,i=e.elements;return!(Array.isArray(o)&&o.length>0&&!o.includes(n))&&(!!Me.has(t)||Array.isArray(i)&&i.includes(r))}))},Ke=n(99234),ze=n(81075),Fe=function(){return Fe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Fe.apply(this,arguments)},Ne=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function l(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}u((r=r.apply(e,t||[])).next())}))},De=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}},Pe=new Set(["file_upload","signature"]),Xe=new Set(["text_field","text_area","email","phone_number","url","password","ssn","ein","gmap_line_1","gmap_line_2","gmap_city","gmap_state","gmap_country","gmap_zip"]),Ue=new Set(["integer_field","slider","rating"]),Ve=new Set(["dropdown","radio"]),qe=new Set(["dropdown_multi","multiselect","checkbox_group","button_group"]);function He(e,t){var n,r=null!==(n=e.metadata)&&void 0!==n?n:{},o=Array.isArray(r.repeat_options)?r.repeat_options:null;if("number"==typeof t&&o&&Array.isArray(o[t]))return o[t].map((function(e){var t,n,r,o,i;return{value:String(null!==(n=null!==(t=null==e?void 0:e.value)&&void 0!==t?t:e)&&void 0!==n?n:""),label:String(null!==(i=null!==(o=null!==(r=null==e?void 0:e.label)&&void 0!==r?r:null==e?void 0:e.value)&&void 0!==o?o:e)&&void 0!==i?i:"")}}));var i=Array.isArray(r.options)?r.options:null;if(!i)return[];var a=Array.isArray(r.labels)?r.labels:[];return i.map((function(e,t){var n,r;return{value:String(null!=e?e:""),label:String(null!==(r=null!==(n=a[t])&&void 0!==n?n:e)&&void 0!==r?r:"")}}))}function Ye(e,t,n,r){return Ne(this,void 0,void 0,(function(){var o,i,a;return De(this,(function(l){switch(l.label){case 0:return(o="number"==typeof e?String(Math.trunc(e)):"string"==typeof e?e:"").replace(/\D/g,"")?(Ke.BZ||(0,Ke.bq)(),[4,Ke.hV]):[2,e];case 1:return l.sent(),Ke.BZ?(i=function(e,t,n){var r,o,i,a=null===(o=null===(r=e.fields)||void 0===r?void 0:r[t])||void 0===o?void 0:o.value;if(a&&"string"==typeof a&&Ke.BZ)try{var l=Ke.BZ.parsePhoneNumber("+".concat(a));if(null==l?void 0:l.country)return l.country}catch(e){}var u=null===(i=n.metadata)||void 0===i?void 0:i.default_country;return u&&"auto"!==u?u:"US"}(n,r,t),(null==(a=function(){try{return Ke.BZ.parsePhoneNumber(o,i)}catch(e){return}}())?void 0:a.isValid())?[2,a.number.replace(/^\+/,"")]:[2,e]):[2,e]}}))}))}function Ge(e,t){var n,r;return Ne(this,void 0,void 0,(function(){var o,i,a,l,u,s,c=this;return De(this,(function(d){switch(d.label){case 0:return o=e?be.Z[e]:void 0,i=null==o?void 0:o.assistantClient,o&&i?(a=new Set(t.map((function(e){return"string"==typeof(null==e?void 0:e.fieldKey)?e.fieldKey:""})).filter(Boolean)),l=new Map((null!==(r=null===(n=o.currentStep)||void 0===n?void 0:n.servar_fields)&&void 0!==r?r:[]).filter((function(e){var t;return a.has(null===(t=null==e?void 0:e.servar)||void 0===t?void 0:t.key)})).map((function(e){var t,n,r=e.servar.key,i=null===(n=null===(t=o.fields)||void 0===t?void 0:t[r])||void 0===n?void 0:n.value;return[r,null==i?null:JSON.parse(JSON.stringify(i))]}))),[4,Promise.all(t.map((function(e){return Ne(c,void 0,void 0,(function(){var t,n,r,i,a,l;return De(this,(function(u){switch(u.label){case 0:return t="string"==typeof(null==e?void 0:e.fieldKey)?e.fieldKey:"",n=Number.isInteger(null==e?void 0:e.repeatIndex)?e.repeatIndex:void 0,t?(r=function(e,t,n,r){var o,i,a,l,u,s,c,d,p=null==e?void 0:e.currentStep,f=null!==(o=null==p?void 0:p.servar_fields)&&void 0!==o?o:[],h=f.find((function(e){var n;return(null===(n=null==e?void 0:e.servar)||void 0===n?void 0:n.key)===t}));if(!h){var v=f.map((function(e){var t;return null===(t=null==e?void 0:e.servar)||void 0===t?void 0:t.key})).filter(Boolean).join(", ")||"(none)";return{ok:!1,errorType:"not_on_step",error:"Field '".concat(t,"' is not on the current step. Available field keys here: ").concat(v,".")}}var y=null!==(i=h.servar)&&void 0!==i?i:{},g=y.type,b=null!==(a=e.visiblePositions)&&void 0!==a?a:{},m=b[null!==(l=(0,we.gh)(h))&&void 0!==l?l:"root"];if(Array.isArray(m)&&!m.some(Boolean))return{ok:!1,errorType:"hidden",error:"Field '".concat(t,"' is on the current step but is hidden right now.")};var x=!(!(null===(u=e.formSettings)||void 0===u?void 0:u.readOnly)&&"readOnly"!==ge.Hi.collaboratorReview);if((null===(s=h.properties)||void 0===s?void 0:s.disabled)||x)return{ok:!1,errorType:"disabled",error:"Field '".concat(t,"' is disabled and cannot be written.")};if(Pe.has(g))return{ok:!1,errorType:"unwriteable_type",error:"Field '".concat(t,"' (").concat(g,") cannot be filled by the assistant; the user has to provide this themselves.")};var w=y.repeated?(0,xe.o$)(p,h):void 0,k=Ie(r,!!w,w?(null!==(d=b[null!==(c=(0,we.gh)(w))&&void 0!==c?c:"root"])&&void 0!==d?d:[]).length:0,t);if(k)return Fe({ok:!1},k);if("number"==typeof r&&Array.isArray(m)&&!m[r])return{ok:!1,errorType:"hidden",error:"Row ".concat(r," of field '").concat(t,"' is hidden right now.")};var S=n;"phone_number"===g&&"number"==typeof S&&Number.isFinite(S)&&(S=String(Math.trunc(S)));var C=function(e,t,n){var r,o=e.type,i=e.key,a=null!==(r=e.metadata)&&void 0!==r?r:{},l="number"==typeof e.min_length?e.min_length:void 0,u="number"==typeof e.max_length?e.max_length:void 0;if("checkbox"===o)return"boolean"==typeof t?null:"Field '".concat(i,"' (checkbox) expects a boolean.");if(Ue.has(o))return"number"==typeof t&&Number.isFinite(t)?"number"==typeof l&&t<l?"Value below minimum (".concat(l,")."):"number"==typeof u&&t>u?"Value above maximum (".concat(u,")."):null:"Field '".concat(i,"' (").concat(o,") expects a number.");if("date_selector"===o)return"string"!=typeof t?"Field '".concat(i,"' (date_selector) expects a string."):/^\d{4}-\d{2}-\d{2}$/.test(t)?null:"Field '".concat(i,"' expects ISO date 'YYYY-MM-DD'.");if(Ve.has(o)){if("string"!=typeof t)return"Field '".concat(i,"' (").concat(o,") expects a single option value (string).");var s=He(e,n).map((function(e){return e.value}));return s.length>0&&!s.includes(t)?"Value not in allowed options. Allowed: ".concat(s.join(", "),"."):null}if(qe.has(o)){if(!Array.isArray(t)||!t.every((function(e){return"string"==typeof e})))return"Field '".concat(i,"' (").concat(o,") expects an array of option-value strings.");if("button_group"===o&&!a.multiple&&t.length>1)return"Field '".concat(i,"' (button_group) is single-select; pass at most one option.");var c=new Set(He(e,n).map((function(e){return e.value})));if(c.size>0){var d=t.filter((function(e){return!c.has(e)}));if(d.length>0)return"Values not in allowed options: ".concat(d.join(", "),".")}return null}return Xe.has(o)?"string"!=typeof t?"Field '".concat(i,"' (").concat(o,") expects a string."):"number"==typeof l&&t.length<l?"Value shorter than minimum length (".concat(l,")."):"number"==typeof u&&t.length>u?"Value exceeds maximum length (".concat(u,")."):null:null}(y,S,r);return C?{ok:!1,errorType:"shape_mismatch",error:C}:{ok:!0,field:h,servar:y,value:S}}(o,t,e.value,n)).ok?(i=r.field,a=r.servar,l=r.value,"gmap_state"!==a.type?[3,1]:(l=function(e,t){var n,r;if("string"!=typeof e||!e)return e;var o=!!(null===(n=t.metadata)||void 0===n?void 0:n.store_abbreviation),i=null===(r=t.metadata)||void 0===r?void 0:r.default_country,a=(i&&"auto"!==i?i:"us").toLowerCase(),l=ze.P3[a];if(!l||0===l.length)return e;var u=e.toLowerCase(),s=l.find((function(e){return e.code.toLowerCase()===u||e.name.toLowerCase()===u}));return s?o?s.code:s.name:e}(l,a),[3,3])):[2,{fieldKey:t,repeatIndex:n,ok:!1,errorType:r.errorType,error:r.error}]:[2,{fieldKey:t,repeatIndex:n,ok:!1,errorType:"shape_mismatch",error:"fieldKey is required."}];case 1:return"phone_number"!==a.type?[3,3]:[4,Ye(l,a,o,t)];case 2:l=u.sent(),u.label=3;case 3:return[2,{fieldKey:t,repeatIndex:n,field:i,normalized:l}]}}))}))})))]):[2,{results:t.map((function(e){var t="string"==typeof(null==e?void 0:e.fieldKey)?e.fieldKey:"",n=Number.isInteger(null==e?void 0:e.repeatIndex)?e.repeatIndex:void 0;return t?{fieldKey:t,repeatIndex:n,ok:!1,errorType:"no_form_state",error:"Form has not loaded yet."}:{fieldKey:t,repeatIndex:n,ok:!1,errorType:"shape_mismatch",error:"fieldKey is required."}}))}];case 1:return u=d.sent(),s=u.map((function(e){var t,n;if("ok"in e)return e;var r="number"==typeof e.repeatIndex?Fe(Fe({},e.field),{repeat:e.repeatIndex}):e.field;try{i.changeValue(e.normalized,r,null!==(t=e.repeatIndex)&&void 0!==t?t:null)}catch(t){return{fieldKey:e.fieldKey,repeatIndex:e.repeatIndex,ok:!1,errorType:"dispatch_failed",error:t instanceof Error?t.message:String(t)}}var o=l.get(e.fieldKey),a=void 0!==e.repeatIndex?Array.isArray(o)&&null!==(n=o[e.repeatIndex])&&void 0!==n?n:null:null!=o?o:null;return{fieldKey:e.fieldKey,repeatIndex:e.repeatIndex,ok:!0,value:e.normalized,priorValue:a}})),[2,{results:s}]}}))}))}var Je=function(){return Je=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Je.apply(this,arguments)},$e=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Qe=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a};function et(e,t,n){var r,o,i,a,l,u,s,c,d,p,f,h;return d=this,p=void 0,h=function(){var d,p,f,h,v,y,g,b,m,x,w,k,S,C,A,_,I,T,Z,R,L,j,E,B,O,M,W,K,z,F,N,D;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,(function(P){switch(P.label){case 0:if(d=Number.isInteger(n)?n:null,!e)return[2,{ok:!1,errorType:"no_form_state",error:"Form has not loaded yet."}];if(!(p=be.Z[e])||!p.currentStep||!p.assistantClient)return[2,{ok:!1,errorType:"no_form_state",error:"Form has not loaded yet."}];if("string"!=typeof t||0===t.length)return[2,{ok:!1,errorType:"shape_mismatch",error:"elementId is required."}];if(f=function(e,t){var n,r,o,i=null==e?void 0:e.currentStep;if(!i)return null;var a=[[i.buttons,"button"],[i.texts,"text"],[i.subgrids,"container"]];try{for(var l=$e(a),u=l.next();!u.done;u=l.next()){var s=Qe(u.value,2),c=s[0],d=s[1],p=(null!=c?c:[]).find((function(e){return(null==e?void 0:e.id)===t}));if(p){var f=null===(o=null==p?void 0:p.properties)||void 0===o?void 0:o.actions;return{element:p,elementType:d,actions:Array.isArray(f)?f:[],position:Array.isArray(p.position)?p.position:[]}}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return null}(p,t),!f)return[2,{ok:!1,errorType:"not_on_step",error:"Element '".concat(t,"' is not on the current step.")}];if(h=null!==(r=p.visiblePositions)&&void 0!==r?r:{},v=h[null!==(o=(0,we.gh)(f.element))&&void 0!==o?o:"root"],Array.isArray(v)&&!v.some(Boolean))return[2,{ok:!1,errorType:"hidden",error:"Element '".concat(t,"' is on the current step but is hidden right now.")}];if("button"===f.elementType&&(y=!(!(null===(i=p.formSettings)||void 0===i?void 0:i.readOnly)&&"readOnly"!==ge.Hi.collaboratorReview),(0,Se.A)(f.element,p.currentStep,h,y)))return[2,{ok:!1,errorType:"disabled",error:"Button '".concat(t,"' is disabled and cannot be clicked.")}];if(g=f.element.repeated?f.element:(0,xe.o$)(p.currentStep,f.element),b=g?(null!==(l=h[null!==(a=(0,we.gh)(g))&&void 0!==a?a:"root"])&&void 0!==l?l:[]).length:0,m=Ie(d,!!g,b,t))return[2,Je({ok:!1},m)];if("number"==typeof d&&Array.isArray(v)&&!v[d])return[2,{ok:!1,errorType:"hidden",error:"Row ".concat(d," of element '").concat(t,"' is hidden right now.")}];x=p.assistantClient,w=p.currentStep.key,k=Ae(p),S="number"==typeof d?Je(Je({},f.element),{repeat:d}):f.element,P.label=1;case 1:return P.trys.push([1,13,,14]),"button"!==f.elementType?[3,3]:[4,x.click(S)];case 2:return P.sent(),[3,12];case 3:return C=_e(p.currentStep.subgrids,f.position),[4,x.runActions({actions:f.actions,element:S,elementType:f.elementType})];case 4:P.sent(),P.label=5;case 5:P.trys.push([5,10,11,12]),A=$e(C),_=A.next(),P.label=6;case 6:return _.done?[3,9]:(I=_.value,T=null===(u=null==I?void 0:I.properties)||void 0===u?void 0:u.actions,Z="number"==typeof d&&!!g&&I.position.length>=g.position.length,[4,x.runActions({actions:Array.isArray(T)?T:[],element:Z?Je(Je({},I),{repeat:d}):I,elementType:"container"})]);case 7:P.sent(),P.label=8;case 8:return _=A.next(),[3,6];case 9:return[3,12];case 10:return R=P.sent(),z={error:R},[3,12];case 11:try{_&&!_.done&&(F=A.return)&&F.call(A)}finally{if(z)throw z.error}return[7];case 12:return[3,14];case 13:return[2,{ok:!1,errorType:"dispatch_failed",error:(L=P.sent())instanceof Error?L.message:String(L)}];case 14:j=null!==(c=null===(s=p.currentStep)||void 0===s?void 0:s.key)&&void 0!==c?c:w,E=Ae(p),B={};try{for(O=$e(Object.keys(E)),M=O.next();!M.done;M=O.next())W=M.value,E[W]!==k[W]&&(B[W]=E[W])}catch(e){N={error:e}}finally{try{M&&!M.done&&(D=O.return)&&D.call(O)}finally{if(N)throw N.error}}return K="button"===f.elementType?B[t]:void 0,delete B[t],[2,Je(Je({ok:!0,navigated:j!==w?{fromStepKey:w,toStepKey:j}:null},K?{buttonError:K}:{}),Object.keys(B).length>0?{fieldErrors:B}:{})]}}))},new((f=void 0)||(f=Promise))((function(e,t){function n(e){try{o(h.next(e))}catch(e){t(e)}}function r(e){try{o(h.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof f?o:new f((function(e){e(o)}))).then(n,r)}o((h=h.apply(d,p||[])).next())}))}var tt=function(){return tt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},tt.apply(this,arguments)};function nt(e,t,n,r){var o,i,a,l,u,s,c;return l=this,u=void 0,c=function(){var l,u,s,c,d,p,f,h,v,y,g,b,m,x,w,k,S,C;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,(function(A){switch(A.label){case 0:if(!(l=Te(e,t)).ok)return[2,l];if(u=l.found,s=u.state,c=u.table,d=u.rowCount,p="string"==typeof r&&r.length>0,void 0!==r&&!p)return[2,{ok:!1,errorType:"shape_mismatch",error:"actionLabel must be a non-empty string when provided."}];if(!Number.isInteger(n)||n<0)return[2,{ok:!1,errorType:"shape_mismatch",error:"rowIndex must be a non-negative integer."}];if(p){if(!(Array.isArray(null===(o=null==c?void 0:c.properties)||void 0===o?void 0:o.actions)?c.properties.actions:[]).some((function(e){return(null==e?void 0:e.label)===r})))return[2,{ok:!1,errorType:"unknown_action",error:"Table '".concat(t,"' has no action labeled '").concat(r,"'.")}]}else if(Ze(c,d).canEditCells)return[2,{ok:!1,errorType:"not_allowed",error:"Table '".concat(t,"' is editable, so bare row clicks are not wired; use a named action.")}];if(n>=d)return[2,{ok:!1,errorType:"row_out_of_range",error:"Row ".concat(n," is out of range (table has ").concat(d," row").concat(1===d?"":"s",").")}];f=function(e,t){var n,r,o,i,a={};try{for(var l=Ce(e.columns),u=l.next();!u.done;u=l.next()){var s=u.value;if(null==s?void 0:s.field_key){var c=null===(i=null===(o=e.state.fields)||void 0===o?void 0:o[s.field_key])||void 0===i?void 0:i.value,d=Array.isArray(c)?c[t]:c;a[s.name]=d}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}return a}(l.found,n),h=s.currentStep.key,v=Ae(s),A.label=1;case 1:return A.trys.push([1,3,,4]),[4,s.assistantClient.runTableAction({table:c,payload:p?{action:r,rowIndex:n,rowData:f}:{rowIndex:n,rowData:f}})];case 2:return A.sent(),[3,4];case 3:return[2,{ok:!1,errorType:"dispatch_failed",error:(y=A.sent())instanceof Error?y.message:String(y)}];case 4:g=null!==(a=null===(i=s.currentStep)||void 0===i?void 0:i.key)&&void 0!==a?a:h,b=Ae(s),m={};try{for(x=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(b)),w=x.next();!w.done;w=x.next())k=w.value,b[k]!==v[k]&&(m[k]=b[k])}catch(e){S={error:e}}finally{try{w&&!w.done&&(C=x.return)&&C.call(x)}finally{if(S)throw S.error}}return[2,tt({ok:!0,navigated:g!==h?{fromStepKey:h,toStepKey:g}:null},Object.keys(m).length>0?{fieldErrors:m}:{})]}}))},new((s=void 0)||(s=Promise))((function(e,t){function n(e){try{o(c.next(e))}catch(e){t(e)}}function r(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof s?o:new s((function(e){e(o)}))).then(n,r)}o((c=c.apply(l,u||[])).next())}))}var rt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function l(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}u((r=r.apply(e,t||[])).next())}))},ot=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}},it=function(e,t){return!Number.isInteger(e)||e<0?{ok:!1,errorType:"shape_mismatch",error:"rowIndex must be a non-negative integer."}:e>=t?{ok:!1,errorType:"row_out_of_range",error:"Row ".concat(e," is out of range (table has ").concat(t," row").concat(1===t?"":"s",").")}:null},at={add:"adding rows",del:"deleting rows",edit:"cell editing"},lt=function(e,t,n,r){var o=Ze(e,r);return"add"===n&&o.canAddRows||"del"===n&&o.canDeleteRows||"edit"===n&&o.canEditCells?null:{ok:!1,errorType:"not_allowed",error:"Table '".concat(t,"' does not allow ").concat(at[n],".")}};function ut(e,t){return rt(this,void 0,void 0,(function(){var n,r,o,i,a,l;return ot(this,(function(u){if(!(n=Te(e,t)).ok)return[2,n];if(r=n.found,o=r.state,i=r.table,a=r.rowCount,l=lt(i,t,"add",a))return[2,l];try{if(!o.assistantClient.addTableRow(t))return[2,{ok:!1,errorType:"not_mounted",error:"Table '".concat(t,"' is not mounted yet.")}]}catch(e){return[2,{ok:!1,errorType:"dispatch_failed",error:e instanceof Error?e.message:String(e)}]}return[2,{ok:!0}]}))}))}function st(e,t,n){return rt(this,void 0,void 0,(function(){var r,o,i,a,l,u,s;return ot(this,(function(c){if(!(r=Te(e,t)).ok)return[2,r];if(o=r.found,i=o.state,a=o.table,l=o.rowCount,u=lt(a,t,"del",l))return[2,u];if(s=it(n,l))return[2,s];try{if(!i.assistantClient.deleteTableRow(t,n))return[2,{ok:!1,errorType:"not_mounted",error:"Table '".concat(t,"' is not mounted yet.")}]}catch(e){return[2,{ok:!1,errorType:"dispatch_failed",error:e instanceof Error?e.message:String(e)}]}return[2,{ok:!0}]}))}))}function ct(e,t,n){var r;return rt(this,void 0,void 0,(function(){var o,i,a,l,u,s,c,d,p,f,h,v,y,g,b,m,x;return ot(this,(function(w){if(o=(Array.isArray(n)?n:[]).map((function(e){return{rowIndex:"number"==typeof(null==e?void 0:e.rowIndex)?e.rowIndex:NaN,fieldKey:"string"==typeof(null==e?void 0:e.fieldKey)?e.fieldKey:"",value:null==e?void 0:e.value}})),i=function(e,t){return{results:o.map((function(n){return{rowIndex:n.rowIndex,fieldKey:n.fieldKey,ok:!1,errorType:e,error:t}}))}},!(a=Te(e,t)).ok)return[2,i(a.errorType,a.error)];if(l=a.found,u=l.state,s=l.table,c=l.columns,d=l.rowCount,p=lt(s,t,"edit",d))return[2,i(p.errorType,p.error)];f=new Map(o.filter((function(e){return e.fieldKey})).map((function(e){var t,n,r=null===(n=null===(t=u.fields)||void 0===t?void 0:t[e.fieldKey])||void 0===n?void 0:n.value,o=Array.isArray(r)?r[e.rowIndex]:void 0;return["".concat(e.fieldKey,":").concat(e.rowIndex),null==o?null:JSON.parse(JSON.stringify(o))]}))),h=[],v=function(e){var n=e.rowIndex,o=e.fieldKey,i=e.value;if(!o)return h.push({rowIndex:n,fieldKey:o,ok:!1,errorType:"shape_mismatch",error:"fieldKey is required."}),"continue";if(!c.some((function(e){return(null==e?void 0:e.field_key)===o})))return h.push({rowIndex:n,fieldKey:o,ok:!1,errorType:"unknown_field",error:"Table '".concat(t,"' has no column with fieldKey '").concat(o,"'.")}),"continue";var a=it(n,d);if(a)return h.push({rowIndex:n,fieldKey:o,ok:!1,errorType:a.errorType,error:a.error}),"continue";var l=null==i?"":String(i);try{if(!u.assistantClient.editTableCell(t,n,o,l))return h.push({rowIndex:n,fieldKey:o,ok:!1,errorType:"not_mounted",error:"Table '".concat(t,"' is not mounted yet.")}),"continue"}catch(e){return h.push({rowIndex:n,fieldKey:o,ok:!1,errorType:"dispatch_failed",error:e instanceof Error?e.message:String(e)}),"continue"}h.push({rowIndex:n,fieldKey:o,ok:!0,value:l,priorValue:null!==(r=f.get("".concat(o,":").concat(n)))&&void 0!==r?r:null})};try{for(y=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(o),g=y.next();!g.done;g=y.next())b=g.value,v(b)}catch(e){m={error:e}}finally{try{g&&!g.done&&(x=y.return)&&x.call(y)}finally{if(m)throw m.error}}return[2,{results:h}]}))}))}var dt=function(){return dt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},dt.apply(this,arguments)},pt=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function l(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,l)}u((r=r.apply(e,t||[])).next())}))},ft=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}},ht=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},vt=function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))},yt="feathery.assistant.mode",gt="current",bt=function(){try{var e=(0,_.Kv)().localStorage.getItem(yt);return"current"===(t=e)||"sidebar-left"===t||"sidebar-right"===t||"fullscreen"===t?e:gt}catch(e){return gt}var t},mt="feathery.assistant.sidebarWidth",xt=400,wt=function(e){var t=Math.max(280,function(){try{return Math.min(800,Math.floor(.6*(0,_.Kv)().innerWidth))}catch(e){return 800}}());return e<280?280:e>t?t:e},kt=function(){try{var e=(0,_.Kv)().localStorage.getItem(mt),t=e?parseInt(e,10):NaN;return Number.isFinite(t)&&t>0?wt(t):xt}catch(e){return xt}},St=function(e){try{(0,_.Kv)().localStorage.setItem(mt,String(e))}catch(e){}},Ct=["current","sidebar-left","sidebar-right","fullscreen"];const At=function(e){var t,n,u,c=e.instanceId,p=e.getTargets,h=e.getJwt,S=e.baseUrl,K=e.bottom,F=void 0===K?20:K,D=e.color,P=e.voiceEnabled,X=void 0!==P&&P,U=e.workflowActions,V=void 0===U?[]:U,q=e.allowedModes,H=void 0===q?Ct:q,Y=e.onLayoutChange,G=(0,o.useMemo)((function(){if(h)return function(){return{Authorization:"Bearer ".concat(h())}};var e=(0,ge.JQ)().sdkKey;return function(){var t={Authorization:"Token ".concat(e)},n=(0,_.ej)("feathery_session_token");return n&&(t["X-Feathery-Session"]=n),t}}),[h]),J=ht((0,o.useState)(!1),2),$=J[0],Q=J[1],te=ht((0,o.useState)(bt),2),re=te[0],oe=te[1],ie=(0,o.useCallback)((function(e){oe(e),function(e){try{(0,_.Kv)().localStorage.setItem(yt,e)}catch(e){}}(e)}),[]),ae=ht((0,o.useState)(kt),2),le=ae[0],ue=ae[1],se=ht((0,o.useState)(!1),2),me=se[0],Ce=se[1];(0,o.useEffect)((function(){var e=function(){ue((function(e){var t=wt(e);return t!==e&&St(t),t}))};return(0,_.Kv)().addEventListener("resize",e),function(){return(0,_.Kv)().removeEventListener("resize",e)}}),[]);var Ae=(0,o.useCallback)((function(e){return function(t){if(0===t.button){t.preventDefault(),Ce(!0);var n=(0,_.me)().body;n.style.cursor="col-resize",n.style.userSelect="none";var r=le,o=function(t){var n="right"===e?(0,_.Kv)().innerWidth-t.clientX:t.clientX;r=wt(n),ue(r)},i=function(){(0,_.Kv)().removeEventListener("pointermove",o),(0,_.Kv)().removeEventListener("pointerup",i),(0,_.Kv)().removeEventListener("pointercancel",i),Ce(!1),n.style.cursor="",n.style.userSelect="",St(r)};(0,_.Kv)().addEventListener("pointermove",o),(0,_.Kv)().addEventListener("pointerup",i),(0,_.Kv)().addEventListener("pointercancel",i)}}}),[le]),Ie=(0,o.useCallback)((function(){ue(xt),St(xt)}),[]),Te=ht((0,o.useState)(""),2),Me=Te[0],Ke=Te[1],ze=ht((0,o.useState)([]),2),Fe=ze[0],Ne=ze[1],De=ht((0,o.useState)(null),2),Pe=De[0],Xe=De[1],Ue=ht((0,o.useState)(!1),2),Ve=Ue[0],qe=Ue[1],He=ht((0,o.useState)(!1),2),Ye=He[0],Je=He[1],$e=ht((0,o.useState)(null),2),Qe=$e[0],tt=$e[1],rt=(0,o.useRef)(null),ot=(0,o.useRef)(!0),it=(0,o.useRef)(!1),at=(0,o.useRef)(null),lt=(0,o.useRef)(null),gt=(0,o.useCallback)((function(){var e=rt.current;if(e){var t=e.scrollHeight-e.scrollTop-e.clientHeight;ot.current=t<60}}),[]),mt=(0,o.useCallback)((function(){var e=rt.current;e&&ot.current&&(e.scrollTop=e.scrollHeight)}),[]),At=(0,o.useMemo)((function(){return{primary:e=D||B,hover:N(e,-15),disabled:N(e,30),light:(t=e,90,n=parseInt(t.replace("#",""),16),r=n>>16&255,o=n>>8&255,i=255&n,.9,a=Math.round(r+.9*(255-r)),l=Math.round(o+.9*(255-o)),u=Math.round(i+.9*(255-i)),"#".concat((a<<16|l<<8|u).toString(16).padStart(6,"0")))};var e,t,n,r,o,i,a,l,u}),[D]),_t=function(e,t,n){void 0===t&&(t=[]);var r=e,o=!!n,i=function(e){if(!o&&e){o=!0;var t=r||null,n={},i=p();if(i.length>0&&(n.targets=i),c){var a=function(e){var t,n;return null===(n=null===(t=be.Z[e])||void 0===t?void 0:t.currentStep)||void 0===n?void 0:n.key}(c);a&&(n.current_step=a)}(function(e,t,n,r,o){return pe(void 0,void 0,void 0,(function(){var i,a,l;return fe(this,(function(u){switch(u.label){case 0:return[4,fetch("".concat(e,"threads/title/"),{method:"POST",headers:de(de({},t()),{"Content-Type":"application/json"}),body:JSON.stringify(de({message:r,thread_id:null!=n?n:void 0},null!=o?o:{}))})];case 1:return(i=u.sent()).ok?[4,i.json()]:[2,null];case 2:return a=u.sent(),[2,null!==(l=a.title)&&void 0!==l?l:null]}}))}))})(S,G,t,e,n).then((function(e){e&&Ne((function(n){return n.map((function(n){return n.id===t||n.chat===s?dt(dt({},n),{title:e}):n}))}))}))}},u=new l.PD({api:S,headers:G,body:function(){return dt(dt({},function(){var e={},t=p();if(t.length>0&&(e.targets=t),c){var n=function(e){var t,n,r,o,i,a,l,u,s,c,d,p,f,h,v,y,g,b,m,x,w=be.Z[e];if(!w||!w.currentStep)return null;var k=w.currentStep,S=null!==(i=w.visiblePositions)&&void 0!==i?i:{},C=null!==(a=w.fields)&&void 0!==a?a:{},A=null!==(l=w.inlineErrors)&&void 0!==l?l:{},_=w.logicRules,I=!(!(null===(u=w.formSettings)||void 0===u?void 0:u.readOnly)&&"readOnly"!==ge.Hi.collaboratorReview),T=(null!==(s=k.subgrids)&&void 0!==s?s:[]).filter((function(e){var t,n,r=null===(t=null==e?void 0:e.properties)||void 0===t?void 0:t.actions;return!!(Array.isArray(r)&&r.length>0)||We(_,"action",k.id,null!==(n=e.id)&&void 0!==n?n:"")})),Z=function(e){return _e(T,Array.isArray(null==e?void 0:e.position)?e.position:[]).map((function(e){var t;return null!==(t=e.id)&&void 0!==t?t:""}))},R={};(0,xe.bW)(k).forEach((function(e){var t=null==e?void 0:e.id;if(t){var n=S[(0,we.gh)(e)];Array.isArray(n)&&(R[t]=n.length)}}));var L=(null!==(c=k.servar_fields)&&void 0!==c?c:[]).map((function(e){var t,n,r,o,i,a,l,u,s,c,d,p=(null===(t=e.position)||void 0===t?void 0:t.join(","))||"root",f=S[p],h=!Array.isArray(f)||f.some(Boolean),v=C[e.servar.key],y=null!==(n=e.properties)&&void 0!==n?n:{},g="string"==typeof y.placeholder&&y.placeholder.trim()?Oe(y.placeholder):void 0,b="string"==typeof y.tooltipText&&y.tooltipText.trim()?Oe(y.tooltipText):void 0,m=null===(r=A[e.servar.key])||void 0===r?void 0:r.message,x=null!==(o=e.servar)&&void 0!==o?o:{},w=null!==(i=x.metadata)&&void 0!==i?i:{},T=!!x.repeated,L=T?(0,xe.o$)(k,e):void 0,j=null!==(a=null==L?void 0:L.id)&&void 0!==a?a:"",E=Array.isArray(w.options)?w.options:null,B=Array.isArray(w.labels)?w.labels:[],O=E?E.map((function(e,t){var n,r;return{value:String(null!=e?e:""),label:String(null!==(r=null!==(n=B[t])&&void 0!==n?n:e)&&void 0!==r?r:"")}})):void 0,M=Array.isArray(w.repeat_options)?w.repeat_options.map((function(e){return Array.isArray(e)?e.map((function(e){var t,n,r,o,i;return{value:String(null!==(n=null!==(t=null==e?void 0:e.value)&&void 0!==t?t:e)&&void 0!==n?n:""),label:String(null!==(i=null!==(o=null!==(r=null==e?void 0:e.label)&&void 0!==r?r:null==e?void 0:e.value)&&void 0!==o?o:e)&&void 0!==i?i:"")}})):null})):void 0,W=null!==(u=null!==(l=R[j])&&void 0!==l?l:null==M?void 0:M.length)&&void 0!==u?u:0,K=M?Array.from({length:W},(function(e,t){return Array.isArray(M[t])?M[t]:null})):void 0,z=Array.isArray(w.questions)?w.questions:null,F=z?z.map((function(e){var t,n;return{id:String(null!==(t=null==e?void 0:e.id)&&void 0!==t?t:""),label:String(null!==(n=null==e?void 0:e.label)&&void 0!==n?n:"")}})).filter((function(e){return e.id||e.label})):void 0,N=je(je([],Le(Array.isArray(w.file_types)?w.file_types:[]),!1),Le(Array.isArray(w.custom_file_types)?w.custom_file_types.map((function(e){return".".concat(e)})):[]),!1),D=w.min_val_label||w.max_val_label?Re(Re({},w.min_val_label?{min:String(w.min_val_label)}:{}),w.max_val_label?{max:String(w.max_val_label)}:{}):void 0,P=!(!y.disabled&&!I),X=We(_,"change",k.id,null!==(s=x.id)&&void 0!==s?s:""),U=Z(e),V=null!==(c=null==v?void 0:v.value)&&void 0!==c?c:null,q=T?null!==(d=R[j])&&void 0!==d?d:Array.isArray(V)?V.length:0:void 0;if("number"==typeof q&&q>0){var H=Array.isArray(V)?V:[];H.length<q&&(V=je(je([],Le(H),!1),Le(Array(q-H.length).fill((0,ke.oe)(e))),!1))}return Re(Re(Re(Re(Re(Re(Re(Re(Re(Re(Re(Re(Re(Re(Re(Re(Re(Re({key:x.key,type:x.type,value:V,visible:h,disabled:P,required:!!x.required},"number"==typeof q?{rowCount:q}:{}),(null==L?void 0:L.id)?{repeatContainerId:L.id}:{}),X?{hasLogicRules:!0}:{}),U.length>0?{clickableAncestorIds:U}:{}),g?{placeholder:g}:{}),b?{tooltip:b}:{}),m?{error:m}:{}),O?{options:O}:{}),K?{rowOptions:K}:{}),F?{questions:F}:{}),"number"==typeof x.min_length?{minLength:x.min_length}:{}),"number"==typeof x.max_length?{maxLength:x.max_length}:{}),x.format?{format:String(x.format)}:{}),N.length>0?{fileTypes:N}:{}),w.multiple?{multipleFiles:!0}:{}),"button_group"===x.type?{multiple:!!w.multiple}:{}),D?{sliderLabels:D}:{}),"number"==typeof w.step_size?{stepSize:w.step_size}:{})})),j=new Set;try{for(var E=Ee(Object.keys(null!==(d=w.steps)&&void 0!==d?d:{})),B=E.next();!B.done;B=E.next()){var O=B.value,M=w.steps[O];(null!==(p=null==M?void 0:M.servar_fields)&&void 0!==p?p:[]).forEach((function(e){var t;(null===(t=null==e?void 0:e.servar)||void 0===t?void 0:t.key)&&j.add(e.servar.key)}))}}catch(e){t={error:e}}finally{try{B&&!B.done&&(n=E.return)&&n.call(E)}finally{if(t)throw t.error}}var W=function(e){return!(null==e||"string"==typeof e&&""===e||Array.isArray(e)&&0===e.length)},K={},z={};try{for(var F=Ee(Object.keys(C)),N=F.next();!N.done;N=F.next()){var D=N.value,P=null!==(h=null===(f=C[D])||void 0===f?void 0:f.value)&&void 0!==h?h:null;j.has(D)?K[D]=P:W(P)&&(z[D]=P)}}catch(e){r={error:e}}finally{try{N&&!N.done&&(o=F.return)&&o.call(F)}finally{if(r)throw r.error}}var X=[],U=function(e){var t,n=(null===(t=e.position)||void 0===t?void 0:t.join(","))||"root",r=S[n];return!Array.isArray(r)||r.some(Boolean)};T.forEach((function(e){var t,n,r,o=e.properties.actions,i=We(_,"action",k.id,null!==(t=e.id)&&void 0!==t?t:""),a=Z(e),l=e.repeated?e.id:null===(n=(0,xe.o$)(k,e))||void 0===n?void 0:n.id;X.push(Re(Re(Re({type:"container",id:null!==(r=e.id)&&void 0!==r?r:"",visible:U(e),actions:o},i?{hasLogicRules:!0}:{}),a.length>0?{clickableAncestorIds:a}:{}),l?{repeatContainerId:l}:{}))})),(null!==(v=k.texts)&&void 0!==v?v:[]).forEach((function(e){var t,n,r,o,i=Be(null!==(t=null==e?void 0:e.properties)&&void 0!==t?t:{});if(i){var a=Oe(i),l=null!==(n=null==e?void 0:e.properties)&&void 0!==n?n:{},u=Array.isArray(l.actions)?l.actions:[],s=We(_,"action",k.id,null!==(r=e.id)&&void 0!==r?r:""),c=Z(e),d=null===(o=(0,xe.o$)(k,e))||void 0===o?void 0:o.id;X.push(Re(Re(Re(Re(Re(Re({type:"text",text:a,visible:U(e)},e.id?{id:e.id}:{}),i!==a?{templateText:i}:{}),u.length>0?{actions:u}:{}),s?{hasLogicRules:!0}:{}),c.length>0?{clickableAncestorIds:c}:{}),d?{repeatContainerId:d}:{}))}})),(null!==(y=k.buttons)&&void 0!==y?y:[]).forEach((function(e){var t,n,r,o,i,a=Be(null!==(t=null==e?void 0:e.properties)&&void 0!==t?t:{}),l=null!==(n=null==e?void 0:e.properties)&&void 0!==n?n:{},u=Array.isArray(l.actions)?l.actions:[],s=We(_,"action",k.id,null!==(r=e.id)&&void 0!==r?r:"")||!!l.submit&&(We(_,"submit",k.id,"")||We(_,"form_complete",k.id,""));if(a||0!==u.length||l.submit||s){var c=null===(o=(0,xe.o$)(k,e))||void 0===o?void 0:o.id;X.push(Re(Re({type:"button",id:null!==(i=e.id)&&void 0!==i?i:"",text:Oe(a),visible:U(e),disabled:(0,Se.A)(e,k,S,I),submit:!!l.submit,actions:u},s?{hasLogicRules:!0}:{}),c?{repeatContainerId:c}:{}))}})),(null!==(g=k.images)&&void 0!==g?g:[]).forEach((function(e){var t,n=null!==(t=null==e?void 0:e.properties)&&void 0!==t?t:{},r="string"==typeof n.alt_text&&n.alt_text||"string"==typeof n.caption&&n.caption||"";if(r){var o=Z(e);X.push(Re({type:"image",text:Oe(r),visible:U(e)},o.length>0?{clickableAncestorIds:o}:{}))}})),(null!==(b=k.progress_bars)&&void 0!==b?b:[]).forEach((function(e){var t,n=null===(t=null==e?void 0:e.properties)||void 0===t?void 0:t.num_segments;X.push(Re(Re({type:"progress"},"number"==typeof n?{segments:n}:{}),{visible:U(e)}))}));var V=[];return(null!==(m=k.tables)&&void 0!==m?m:[]).forEach((function(e){var t,n,r,o,i,a=null!==(n=null===(t=null==e?void 0:e.properties)||void 0===t?void 0:t.columns)&&void 0!==n?n:[];if(0!==a.length){var l=a.reduce((function(e,t){var n,r=t.field_key?null===(n=C[t.field_key])||void 0===n?void 0:n.value:void 0;return Array.isArray(r)?Math.max(e,r.length):e}),0),u=Array.from({length:l},(function(e,t){return a.map((function(e){var n,r,o=e.field_key?null===(n=C[e.field_key])||void 0===n?void 0:n.value:null;return Array.isArray(o)?null!==(r=o[t])&&void 0!==r?r:null:null!=o?o:null}))})),s=(Array.isArray(null===(r=null==e?void 0:e.properties)||void 0===r?void 0:r.actions)?e.properties.actions:[]).map((function(e){return{label:"string"==typeof(null==e?void 0:e.label)?e.label:""}})).filter((function(e){return e.label.trim().length>0})),c=Ze(e,l),d=c.canEditCells,p=c.canAddRows,f=c.canDeleteRows,h=We(_,"action",k.id,null!==(o=e.id)&&void 0!==o?o:"");V.push(Re(Re(Re(Re(Re(Re({id:null!==(i=e.id)&&void 0!==i?i:"",columns:a.map((function(e){var t,n,r;return{name:null!==(n=null!==(t=e.name)&&void 0!==t?t:e.field_key)&&void 0!==n?n:"",fieldKey:null!==(r=e.field_key)&&void 0!==r?r:""}})),rows:u},s.length>0?{actions:s}:{}),p?{canAddRows:!0}:{}),f?{canDeleteRows:!0}:{}),d?{canEditCells:!0}:{}),h?{hasLogicRules:!0}:{}),{visible:U(e)}))}})),{currentStep:{id:k.id,key:k.key},previousStepName:w.previousStepName||void 0,totalSteps:Object.keys(null!==(x=w.steps)&&void 0!==x?x:{}).length,currentStepFields:L,currentStepElements:X,currentStepTables:V,values:K,hiddenFieldValues:z}}(c);n&&(e.panel_runtime=n)}return e}()),{thread_id:r||null})},fetch:function(e,t){return pt(void 0,void 0,void 0,(function(){var n,o,a,l,u,c,d,p;return ft(this,(function(f){switch(f.label){case 0:return it.current?((o=new FormData).append("payload","string"==typeof(null==t?void 0:t.body)?t.body:JSON.stringify(null!==(u=null==t?void 0:t.body)&&void 0!==u?u:{})),(a=at.current)&&(o.append("audio",a,"speech.wav"),at.current=null),[4,fetch("".concat(S,"voice/turn/"),{method:"POST",headers:G(),body:o,signal:null==t?void 0:t.signal})]):[3,2];case 1:return n=f.sent(),[3,4];case 2:return[4,fetch(e,t)];case 3:n=f.sent(),f.label=4;case 4:return(l=n.headers.get("X-Thread-Id"))&&!r&&(r=l,Ne((function(e){return e.map((function(e){return e.chat===s?dt(dt({},e),{id:l,isTemporary:!1}):e}))})),Xe(l),ve(S,G,l).then((function(e){e&&Ne((function(t){return t.map((function(t){return t.id===l?dt(dt({},e),{chat:s,title:t.title||e.title}):t}))}))}))),i(null===(p=null===(d=null===(c=s.messages.find((function(e){return"user"===e.role})))||void 0===c?void 0:c.parts)||void 0===d?void 0:d[0])||void 0===p?void 0:p.text),[2,n]}}))}))}}),s=new a.en({transport:u,messages:t,sendAutomaticallyWhen:l.Qk,onData:function(e){var t,n;"data-transcript"===(null==e?void 0:e.type)&&i(null===(t=e.data)||void 0===t?void 0:t.text),null===(n=lt.current)||void 0===n||n.call(lt,e)},onToolCall:function(e){var t=e.toolCall;return pt(void 0,void 0,void 0,(function(){var e,n,r,o,i,a,l,u,d,p,f,h,v,y,g,b,m,x,w;return ft(this,(function(k){switch(k.label){case 0:return t.dynamic?[2]:"setFieldValue"!==t.toolName?[3,2]:(e=null!==(y=t.input)&&void 0!==y?y:{},n=Array.isArray(e.fields)?e.fields:[],[4,Ge(c,n)]);case 1:return v=k.sent(),s.addToolOutput({tool:"setFieldValue",toolCallId:t.toolCallId,output:v}),[3,12];case 2:return"clickElement"!==t.toolName?[3,4]:(r=null!==(g=t.input)&&void 0!==g?g:{},o="string"==typeof r.elementId?r.elementId:"",[4,et(c,o,r.repeatIndex)]);case 3:return v=k.sent(),s.addToolOutput({tool:"clickElement",toolCallId:t.toolCallId,output:v}),[3,12];case 4:return"triggerTableAction"!==t.toolName?[3,6]:(i=null!==(b=t.input)&&void 0!==b?b:{},f="string"==typeof i.tableId?i.tableId:"",d="number"==typeof i.rowIndex?i.rowIndex:NaN,a="string"==typeof i.actionLabel?i.actionLabel:void 0,[4,nt(c,f,d,a)]);case 5:return v=k.sent(),s.addToolOutput({tool:"triggerTableAction",toolCallId:t.toolCallId,output:v}),[3,12];case 6:return"addTableRow"!==t.toolName?[3,8]:(l=null!==(m=t.input)&&void 0!==m?m:{},f="string"==typeof l.tableId?l.tableId:"",[4,ut(c,f)]);case 7:return v=k.sent(),s.addToolOutput({tool:"addTableRow",toolCallId:t.toolCallId,output:v}),[3,12];case 8:return"deleteTableRow"!==t.toolName?[3,10]:(u=null!==(x=t.input)&&void 0!==x?x:{},f="string"==typeof u.tableId?u.tableId:"",d="number"==typeof u.rowIndex?u.rowIndex:NaN,[4,st(c,f,d)]);case 9:return v=k.sent(),s.addToolOutput({tool:"deleteTableRow",toolCallId:t.toolCallId,output:v}),[3,12];case 10:return"setTableCellValue"!==t.toolName?[3,12]:(p=null!==(w=t.input)&&void 0!==w?w:{},f="string"==typeof p.tableId?p.tableId:"",h=Array.isArray(p.cells)?p.cells:[],[4,ct(c,f,h)]);case 11:v=k.sent(),s.addToolOutput({tool:"setTableCellValue",toolCallId:t.toolCallId,output:v}),k.label=12;case 12:return[2]}}))}))},onFinish:function(e){var t=e.isAbort,n=e.isError;t||n||!r||Ne((function(e){var t=e.find((function(e){return e.id===r}));return t?vt([dt(dt({},t),{updated_at:(new Date).toISOString()})],ht(e.filter((function(e){return e.id!==r}))),!1):e}))}});return s},It=(0,o.useMemo)((function(){return _t(null)}),[G,p,h]),Tt=Fe.find((function(e){return e.id===Pe})),Zt=null!==(u=null==Tt?void 0:Tt.chat)&&void 0!==u?u:It,Rt=(0,a.RJ)({chat:Zt}),Lt=Rt.messages,jt=Rt.sendMessage,Et=Rt.setMessages,Bt=Rt.status,Ot=Rt.error,Mt=(0,o.useMemo)((function(){var e,t,n,r,o=[];try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(Lt),a=i.next();!a.done;a=i.next()){var l=a.value,u=o[o.length-1];u&&"assistant"===u.role&&"assistant"===l.role?o[o.length-1]=dt(dt({},u),{parts:vt(vt([],ht(null!==(n=u.parts)&&void 0!==n?n:[]),!1),ht(null!==(r=l.parts)&&void 0!==r?r:[]),!1)}):o.push(l)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return o}),[Lt]);(0,o.useEffect)((function(){mt()}),[Mt,mt]),(0,o.useEffect)((function(){if("ready"===Bt){var e=(0,_.Kv)().requestAnimationFrame(mt);return function(){return(0,_.Kv)().cancelAnimationFrame(e)}}}),[Bt,mt]);var Wt=(0,o.useCallback)((function(){return pt(void 0,void 0,void 0,(function(){var e;return ft(this,(function(t){switch(t.label){case 0:return[4,he(S,G)];case 1:return(e=t.sent())?(Ne((function(t){return vt(vt([],ht(e.map((function(e){var n;return dt(dt({},e),{chat:null===(n=t.find((function(t){return t.id===e.id})))||void 0===n?void 0:n.chat})}))),!1),ht(t.filter((function(t){return!e.find((function(e){return e.id===t.id}))}))),!1)})),[2]):[2]}}))}))}),[G,S]);(0,o.useEffect)((function(){$&&Wt()}),[$,Wt]);var Kt=function(){qt(),ot.current=!0;var e=(0,i.Z)(),t=(new Date).toISOString(),n=_t(null);Ne((function(r){return vt([{id:e,title:"",created_at:t,updated_at:t,isTemporary:!0,chat:n}],ht(r.filter((function(e){return!e.isTemporary||e.title}))),!1)})),Xe(e)},zt=(0,o.useCallback)((function(){ot.current=!0;var e=(new Date).toISOString();if(Pe)Tt&&!Tt.title&&Ne((function(t){return vt([dt(dt({},Tt),{title:"New Chat",updated_at:e})],ht(t.filter((function(e){return e.id!==Pe}))),!1)}));else{var t=(0,i.Z)();Ne((function(n){return vt([{id:t,title:"New Chat",created_at:e,updated_at:e,isTemporary:!0,chat:Zt}],ht(n),!1)})),Xe(t)}}),[Pe,Tt,Zt]),Ft=function(e){var t=this,n=e.status,r=e.sendMessage,a=e.setMessages,l=e.ensureThread,u=e.voiceActiveRef,s=e.pendingAudioRef,c=e.voiceDataRef,d=L((0,o.useState)("idle"),2),p=d[0],f=d[1],h=L((0,o.useState)(Z),1)[0],v=L((0,o.useState)(0),2),y=v[0],g=v[1],b=L((0,o.useState)(!1),2),m=b[0],x=b[1],w=(0,o.useRef)("idle"),k=(0,o.useRef)(n),S=(0,o.useRef)(null),C=(0,o.useRef)(null),A=(0,o.useRef)(0),_=(0,o.useRef)(!1),B=(0,o.useCallback)((function(e){w.current=e,f(e)}),[]),O=(0,o.useCallback)((function(){var e,t;u.current&&("ready"!==k.current&&"error"!==k.current||(null===(e=C.current)||void 0===e?void 0:e.isPlaying)||"transcribing"!==w.current&&"thinking"!==w.current&&"speaking"!==w.current||(null===(t=S.current)||void 0===t||t.resume(),B("listening")))}),[u,B]),M=(0,o.useCallback)((function(e){var t,n;"recording"!==w.current&&"listening"!==w.current||(s.current=e,null===(t=S.current)||void 0===t||t.pause(),null===(n=C.current)||void 0===n||n.skip(),A.current=0,_.current=!1,g(0),B("transcribing"),l(),r({text:""}))}),[s,l,r,B]),W=(0,o.useRef)(M);W.current=M;var K=(0,o.useCallback)((function(){return e=t,n=void 0,o=function(){var e,t;return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,(function(n){switch(n.label){case 0:return"idle"!==w.current&&"error"!==w.current?[2]:(e=new I({onSegmentStart:function(){u.current&&B("speaking")},onSegmentProgress:function(e,t){return g(A.current+Math.floor(E(e)*t))},onSegmentEnd:function(e){A.current+=E(e),g(A.current)},onIdle:function(){x(!1),O()}}),t=new T({onSpeechStart:function(){"listening"===w.current&&B("recording")},onUtterance:function(e){return W.current(e)}}),C.current=e,S.current=t,u.current=!0,B("loading"),[4,t.start()]);case 1:return n.sent()?B("listening"):(u.current=!1,B("error")),[2]}}))},new((r=void 0)||(r=Promise))((function(t,i){function a(e){try{u(o.next(e))}catch(e){i(e)}}function l(e){try{u(o.throw(e))}catch(e){i(e)}}function u(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(e){e(n)}))).then(a,l)}u((o=o.apply(e,n||[])).next())}));var e,n,r,o}),[u,O,B]),z=(0,o.useCallback)((function(){var e,t;null===(e=S.current)||void 0===e||e.destroy(),S.current=null,null===(t=C.current)||void 0===t||t.skip(),C.current=null,s.current=null,u.current=!1,B("idle")}),[u,s,B]),F=(0,o.useCallback)((function(){var e;"speaking"===w.current&&(_.current=!0,null===(e=C.current)||void 0===e||e.skip(),g(Number.MAX_SAFE_INTEGER))}),[]);return(0,o.useEffect)((function(){return c.current=function(e){var t,n,r,o,l,s,c;if(u.current)if("data-audio"===e.type)(null===(t=e.data)||void 0===t?void 0:t.done)?null===(n=C.current)||void 0===n||n.end():(null===(r=e.data)||void 0===r?void 0:r.chunk)&&!_.current&&(null===(o=C.current)||void 0===o||o.pushChunk(e.data.chunk));else if("data-segment"===e.type&&(null===(l=e.data)||void 0===l?void 0:l.text)){if(_.current)return;x(!0),null===(s=C.current)||void 0===s||s.pushSegment(e.data.text)}else if("data-transcript"===e.type&&(null===(c=e.data)||void 0===c?void 0:c.text)){var d=e.data.text;"transcribing"===w.current&&B("thinking"),a((function(e){for(var t=e.length-1;t>=0;t--)if("user"===e[t].role){var n=j([],L(e),!1);return n[t]=R(R({},e[t]),{parts:[{type:"text",text:d}]}),n}return j(j([],L(e),!1),[{id:(0,i.Z)(),role:"user",parts:[{type:"text",text:d}]}],!1)}))}},function(){c.current=null}}),[c,u,a,B]),(0,o.useEffect)((function(){k.current=n,"ready"!==n&&"error"!==n||!u.current||a((function(e){var t,n=e[e.length-1],r="user"===(null==n?void 0:n.role)&&!(null!==(t=n.parts)&&void 0!==t?t:[]).some((function(e){var t;return"text"===e.type&&(null!==(t=e.text)&&void 0!==t?t:"").trim()}));return r?e.slice(0,-1):e})),O()}),[n,O,u,a]),(0,o.useEffect)((function(){return function(){return z()}}),[z]),{voiceState:p,voiceActive:"idle"!==p&&"error"!==p,micAvailable:h,spokenChars:y,audioDraining:m,startVoice:K,stopVoice:z,skipSpeaking:F}}({status:Bt,sendMessage:function(e){return jt(e)},setMessages:Et,ensureThread:zt,voiceActiveRef:it,pendingAudioRef:at,voiceDataRef:lt}),Nt=Ft.voiceState,Dt=Ft.voiceActive,Pt=Ft.micAvailable,Xt=Ft.spokenChars,Ut=Ft.audioDraining,Vt=Ft.startVoice,qt=Ft.stopVoice,Ht=Ft.skipSpeaking;(0,o.useEffect)((function(){mt()}),[Xt,Ut,mt]);var Yt=function(){Me.trim()&&"ready"===Bt&&(zt(),jt({text:Me}),Ke(""))},Gt=Fe.filter((function(e){return e.title})),Jt="submitted"===Bt||"streaming"===Bt,$t={padding:"10px",backgroundColor:At.primary,color:"white",border:"none",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s",":hover:not(:disabled)":{backgroundColor:At.hover},":disabled":{backgroundColor:At.disabled,cursor:"not-allowed"}},Qt="sidebar-left"===re?"left":"sidebar-right"===re?"right":null,en=$&&Qt?le:0,tn=(0,o.useRef)(Y);tn.current=Y,(0,o.useEffect)((function(){var e;null===(e=tn.current)||void 0===e||e.call(tn,{mode:re,isOpen:$,side:Qt,width:en,isResizing:me})}),[re,$,Qt,en,me]);var nn="sidebar-left"===re?w:"sidebar-right"===re?k:"fullscreen"===re?f:x,rn="sidebar-left"===re?g:"sidebar-right"===re?b:"fullscreen"===re?m:y,on="sidebar-left"===re,an=on?{left:"20px"}:{right:"20px"},ln=on?20:F;if(!$)return(0,r.tZ)("button",dt({type:"button",onClick:function(){return Q(!0)},css:dt(dt({position:"fixed",bottom:"".concat(ln,"px")},an),{width:"".concat(56,"px"),height:"".concat(56,"px"),borderRadius:"50%",backgroundColor:At.primary,color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",transition:"transform 0.2s, box-shadow 0.2s, background-color 0.2s",zIndex:1e3,":hover":{backgroundColor:At.hover,transform:"scale(1.05)",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)"}})},{children:(0,r.tZ)(s,{})}));var un="sidebar-left"===re?{top:0,left:0,width:"".concat(le,"px"),height:"100vh",borderRadius:0,boxShadow:"4px 0 24px rgba(0, 0, 0, 0.12)"}:"sidebar-right"===re?{top:0,right:0,width:"".concat(le,"px"),height:"100vh",borderRadius:0,boxShadow:"-4px 0 24px rgba(0, 0, 0, 0.12)"}:"fullscreen"===re?{inset:0,borderRadius:0,boxShadow:"none",border:"none"}:{bottom:"".concat(F,"px"),right:"20px",width:"".concat(380,"px"),height:"".concat(500,"px"),borderRadius:"12px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.12)",border:"1px solid ".concat(M)};return(0,r.BX)("div",dt({css:dt({position:"fixed",backgroundColor:"white",display:"flex",flexDirection:"column",overflow:"hidden",zIndex:1e3},un)},{children:[Qt&&(0,r.tZ)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize assistant panel",title:"Drag to resize, double-click to reset",onPointerDown:Ae(Qt),onDoubleClick:Ie,css:(t={position:"absolute",top:0},t["right"===Qt?"left":"right"]=0,t.width="6px",t.height="100%",t.cursor="col-resize",t.zIndex=2,t.touchAction="none",t.userSelect="none",t["::after"]=(n={content:'""',position:"absolute",top:0},n["right"===Qt?"left":"right"]="2px",n.width="2px",n.height="100%",n.backgroundColor="transparent",n.transition="background-color 120ms ease",n),t[":hover::after"]={backgroundColor:"rgba(0, 0, 0, 0.15)"},t)}),(0,r.BX)("div",dt({css:dt({display:"flex",alignItems:"center",justifyContent:"space-between",gap:"2px",padding:"12px 16px",backgroundColor:At.primary,color:"white",position:"relative"},Qt?{minHeight:"var(--main-nav-height, 55px)",boxSizing:"border-box"}:{})},{children:[(0,r.BX)("div",dt({css:{display:"flex",alignItems:"center",gap:"8px",minWidth:0,flex:1,overflow:"hidden"}},{children:[(0,r.tZ)(s,{}),(0,r.BX)("button",dt({type:"button",onClick:function(){return qe((function(e){return!e}))},css:{background:"none",border:"none",color:"white",cursor:"pointer",fontWeight:600,fontSize:"14px",padding:"4px",borderRadius:"4px",display:"flex",alignItems:"center",gap:"4px",minWidth:0,maxWidth:"100%",":hover":{backgroundColor:"rgba(255, 255, 255, 0.1)"}}},{children:[(0,r.tZ)("span",dt({css:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0}},{children:(null==Tt?void 0:Tt.title)||"AI Assistant"})),(0,r.tZ)("span",dt({css:{display:"flex",opacity:.8,flexShrink:0}},{children:(0,r.tZ)(v,{})}))]}))]})),(0,r.BX)("div",dt({css:{display:"flex",alignItems:"center",gap:"2px",position:"relative",flexShrink:0}},{children:[(0,r.tZ)("button",dt({type:"button",onClick:function(){return Je((function(e){return!e}))},css:{background:"none",border:"none",color:"white",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",":hover":{backgroundColor:"rgba(255, 255, 255, 0.1)"}}},{children:(0,r.tZ)(rn,{})})),(0,r.tZ)("button",dt({type:"button",onClick:function(){qt(),Q(!1)},css:{background:"none",border:"none",color:"white",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",":hover":{backgroundColor:"rgba(255, 255, 255, 0.1)"}}},{children:(0,r.tZ)(nn,{})})),Ye&&(0,r.BX)(r.HY,{children:[(0,r.tZ)("div",{css:{position:"fixed",inset:0,zIndex:1e3},onClick:function(){return Je(!1)}}),(0,r.tZ)("div",dt({css:{position:"absolute",top:"100%",right:0,marginTop:"4px",minWidth:"180px",backgroundColor:"white",border:"1px solid ".concat(M),borderRadius:"8px",boxShadow:"0 8px 16px rgba(0,0,0,0.12)",zIndex:1001,overflow:"hidden"}},{children:[{value:"current",label:"Floating",Icon:y},{value:"sidebar-left",label:"Sidebar left",Icon:g},{value:"sidebar-right",label:"Sidebar right",Icon:b},{value:"fullscreen",label:"Fullscreen",Icon:m}].filter((function(e){var t=e.value;return H.includes(t)})).map((function(e){var t=e.value,n=e.label,o=e.Icon;return(0,r.BX)("button",dt({type:"button",onClick:function(){ie(t),Je(!1)},css:{width:"100%",padding:"10px 14px",background:t===re?At.light:"white",border:"none",cursor:"pointer",fontSize:"13px",color:z,textAlign:"left",display:"flex",alignItems:"center",gap:"10px",":hover":{backgroundColor:O}}},{children:[(0,r.tZ)("span",dt({css:{display:"flex",color:W,flexShrink:0}},{children:(0,r.tZ)(o,{})})),(0,r.tZ)("span",{children:n})]}),t)}))}))]})]})),Ve&&(0,r.BX)(r.HY,{children:[(0,r.tZ)("div",{css:{position:"fixed",inset:0,zIndex:1e3},onClick:function(){return qe(!1)}}),(0,r.BX)("div",dt({css:{position:"absolute",top:"100%",left:0,width:"100%",backgroundColor:"white",border:"1px solid ".concat(M),borderTop:"none",borderRadius:"0 0 8px 8px",boxShadow:"0 8px 16px rgba(0,0,0,0.12)",zIndex:1001,maxHeight:"240px",overflowY:"scroll"}},{children:[(0,r.tZ)("button",dt({type:"button",onClick:function(){Kt(),qe(!1)},css:{width:"100%",padding:"10px 14px",background:"none",border:"none",borderBottom:"1px solid ".concat("#f3f4f6"),cursor:"pointer",fontSize:"13px",fontWeight:600,color:At.primary,textAlign:"left",":hover":{backgroundColor:O}}},{children:"+ New Chat"})),0===Gt.length&&(0,r.tZ)("div",dt({css:{padding:"12px 14px",fontSize:"13px",color:W}},{children:"No chats yet"})),Gt.map((function(e){return(0,r.BX)("div",dt({onClick:function(){return t=e.id,pt(void 0,void 0,void 0,(function(){var e,n,r,o;return ft(this,(function(i){switch(i.label){case 0:return qt(),ot.current=!0,(null===(r=Fe.find((function(e){return e.id===t})))||void 0===r?void 0:r.chat)?(Xe(t),qe(!1),[2]):[4,ve(S,G,t)];case 1:return(e=i.sent())?(n=_t(t,null!==(o=e.messages)&&void 0!==o?o:[],e.title),Ne((function(r){return r.map((function(r){return r.id===t?dt(dt({},e),{chat:n}):r}))})),Xe(t),qe(!1),[2]):[2]}}))}));var t},css:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",cursor:"pointer",backgroundColor:e.id===Pe?At.light:"white",":hover":{backgroundColor:O}}},{children:[(0,r.BX)("div",dt({css:{flex:1,minWidth:0}},{children:[(0,r.tZ)("div",dt({css:{fontSize:"13px",fontWeight:500,color:z,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:e.title||"Untitled conversation"})),(0,r.tZ)("div",dt({css:{fontSize:"11px",color:W,marginTop:"2px"}},{children:new Date(e.updated_at).toLocaleDateString()}))]})),(0,r.tZ)("button",dt({type:"button",onClick:function(t){return function(e,t){return pt(void 0,void 0,void 0,(function(){var n;return ft(this,(function(r){switch(r.label){case 0:return t.stopPropagation(),(null==(n=Fe.find((function(t){return t.id===e})))?void 0:n.isTemporary)?[3,2]:[4,ye(S,G,e)];case 1:r.sent(),r.label=2;case 2:return Ne((function(t){return t.filter((function(t){return t.id!==e}))})),Pe===e&&Kt(),[2]}}))}))}(e.id,t)},css:{background:"none",border:"none",cursor:"pointer",color:W,fontSize:"16px",padding:"2px 6px",marginLeft:"8px",borderRadius:"4px",lineHeight:1,":hover":{color:"#dc2626",backgroundColor:"#fef2f2"}}},{children:"×"}))]}),e.id)}))]}))]})]})),(0,r.BX)("div",dt({ref:rt,onScroll:gt,css:{flex:1,overflowY:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px"}},{children:[0===Mt.length&&(0,r.tZ)("div",dt({css:{textAlign:"center",color:W,fontSize:"14px",marginTop:"40px"}},{children:"How can I help?"})),Mt.map((function(e,t){var n,i,a,l,u,s,c,d;return"user"===e.role?(null!==(n=e.parts)&&void 0!==n?n:[]).some((function(e){var t;return"text"===e.type&&(null!==(t=e.text)&&void 0!==t?t:"").trim()}))?(0,r.tZ)("div",dt({css:{display:"flex",justifyContent:"flex-end"}},{children:(0,r.tZ)("div",dt({css:{maxWidth:"80%",padding:"10px 14px",borderRadius:"12px",fontSize:"14px",lineHeight:"1.5",backgroundColor:At.primary,color:"white",overflowWrap:"anywhere",wordBreak:"break-word"}},{children:e.parts.filter((function(e){return!e.hidden})).map((function(e,t){return"text"===e.type?(0,r.tZ)("span",{children:e.text},t):null}))}))}),e.id):null:(0,r.tZ)(o.Fragment,{children:(i=t===Mt.length-1,a=function(e){var t=[];return e.forEach((function(e,n){if("text"===e.type&&e.text.trim()){var r=t[t.length-1];r&&"text"===r.kind?r.text="".concat(r.text,"\n\n").concat(e.text):t.push({kind:"text",key:"text-".concat(n),text:e.text})}else{var o=function(e){if("text"===(null==e?void 0:e.type))return{kind:"text"};var t="string"==typeof(null==e?void 0:e.type)&&e.type.startsWith("tool-"),n="dynamic-tool"===(null==e?void 0:e.type);return t||n?{kind:"tool",toolName:t?e.type.replace("tool-",""):e.toolName||"unknown"}:null}(e);if(o&&"tool"===o.kind&&o.toolName){var i={key:"tool-".concat(n),toolName:o.toolName,state:e.state,input:e.input,output:e.output},a=t[t.length-1];a&&"tools"===a.kind?a.rows.push(i):t.push({kind:"tools",key:"tools-".concat(n),rows:[i]})}}})),t}(e.parts),l=e.parts[e.parts.length-1],u=!i||"ready"===Bt&&"text"===(null==l?void 0:l.type),s=it.current&&i&&(Jt||Ut),c=s?Xt:1/0,d=!1,a.map((function(e,t){if(d)return null;if("text"===e.kind){for(var n=0;n<e.text.length&&(c>0||/\s/.test(e.text[n]));)/\s/.test(e.text[n])||(c-=1),n+=1;return n<e.text.length&&(d=!0),n<=0?null:(0,r.tZ)("div",dt({css:{display:"flex",justifyContent:"flex-start"}},{children:(0,r.tZ)("div",dt({css:{maxWidth:"80%",padding:"10px 14px",borderRadius:"12px",fontSize:"14px",lineHeight:"1.5",backgroundColor:At.light,color:z,overflowWrap:"anywhere",wordBreak:"break-word"}},{children:(0,r.tZ)(ce,{text:e.text.slice(0,n),isStreaming:Jt&&i&&t===a.length-1})}))}),e.key)}var o=a.slice(t+1).some((function(e){return"text"===e.kind})),l=s&&o&&c<=0;return(0,r.tZ)("div",dt({css:{display:"flex",justifyContent:"flex-start",maxWidth:"80%",minWidth:0}},{children:(0,r.tZ)(ee,{rows:e.rows,turnFinished:u,followedByText:o,audioPending:l,linkColor:At.primary,isFirstChunk:0===t})}),e.key)})))},e.id)})),function(){var e;if(!Jt)return null;var t=Mt[Mt.length-1];if(!t)return null;var n=t.parts||[],o=function(e){var t;if("text"===(null==e?void 0:e.type))return(null!==(t=e.text)&&void 0!==t?t:"").trim().length>0;var n="string"==typeof(null==e?void 0:e.type)?e.type:"";return n.startsWith("tool-")||"dynamic-tool"===n},i=n.some(o);if("user"===t.role){if(!i)return null}else{var a=it.current&&Xt<=0&&"text"===(null===(e=n.find(o))||void 0===e?void 0:e.type);if(i&&!a)return null}return(0,r.tZ)(ne,{})}(),Ot&&(0,r.tZ)("div",dt({css:{padding:"10px 14px",borderRadius:"8px",backgroundColor:"#fef2f2",color:"#dc2626",fontSize:"14px"}},{children:"Something went wrong. Please try again."}))]})),V.length>0&&(0,r.BX)("div",dt({css:{position:"relative",zIndex:1,borderTop:"1px solid ".concat(M),backgroundColor:O,padding:"8px 16px",display:"flex",gap:"6px",overflowX:"auto"}},{children:[V.map((function(e,t){return(0,r.tZ)("button",dt({type:"button",disabled:Jt,onClick:function(){return function(e){"ready"===Bt&&(zt(),jt({parts:[{type:"text",text:e.name},{type:"text",text:e.instructions,hidden:!0,interpolate:!0}]}))}(e)},onMouseEnter:function(t){if(e.description){var n=t.currentTarget.getBoundingClientRect();tt({text:e.description,x:n.left+n.width/2,y:n.top})}},onMouseLeave:function(){return tt(null)},css:{flexShrink:0,padding:"4px 10px",fontSize:"12px",border:"1px solid ".concat(At.primary),borderRadius:"12px",backgroundColor:"white",color:At.primary,cursor:"pointer",whiteSpace:"nowrap",":disabled":{opacity:.5,cursor:"not-allowed"},":hover:not(:disabled)":{backgroundColor:At.light},transition:"background-color 0.15s, color 0.15s"}},{children:e.name}),t)})),Qe&&(0,r.tZ)("div",dt({css:{position:"fixed",top:Qe.y-34,left:Qe.x,transform:"translateX(-50%)",backgroundColor:"rgba(0,0,0,0.9)",color:"white",fontSize:"12px",padding:"4px 8px",borderRadius:"4px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:1e4}},{children:Qe.text}))]})),(0,r.BX)("div",dt({css:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",borderTop:"1px solid ".concat(M),backgroundColor:O}},{children:[Dt?(0,r.BX)("button",dt({type:"button",onClick:"speaking"===Nt?Ht:void 0,css:{flex:1,display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",border:"1px solid ".concat(M),borderRadius:"8px",backgroundColor:"white",fontSize:"14px",color:z,cursor:"speaking"===Nt?"pointer":"default"}},{children:[(0,r.tZ)(A,{css:{color:At.primary}}),"loading"===Nt?"Loading…":"transcribing"===Nt?"Transcribing…":"thinking"===Nt?"Thinking…":"speaking"===Nt?"Tap to skip":"Listening…"]})):(0,r.tZ)("input",{type:"text",value:Me,onChange:function(e){return Ke(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),e.stopPropagation(),Yt())},placeholder:"Type a message...",css:{flex:1,padding:"10px 14px",border:"1px solid ".concat(M),borderRadius:"8px",fontSize:"14px",outline:"none",transition:"border-color 0.2s",":focus":{borderColor:At.primary}}}),Dt?(0,r.tZ)("button",dt({type:"button",onClick:qt,"aria-label":"Exit voice mode",css:$t},{children:(0,r.tZ)(f,{})})):!X||Me.trim()?(0,r.tZ)("button",dt({type:"button",onClick:Yt,disabled:Jt||!Me.trim(),css:$t},{children:(0,r.tZ)(d,{})})):(0,r.tZ)("button",dt({type:"button",onClick:Vt,disabled:Jt||!Pt,"aria-label":"Start voice mode",title:Pt?void 0:"Microphone unavailable",css:$t},{children:(0,r.tZ)(C,{})}))]}))]}))}}}]);
|