@opencx/widget-react 5.15.3 → 5.16.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/dist/{Chart.impl-2YWCdHAu.js → Chart.impl-BV-FDx2F.js} +2 -2
- package/dist/{Chart.impl-2YWCdHAu.js.map → Chart.impl-BV-FDx2F.js.map} +1 -1
- package/dist/{Chart.impl-BFdGxrv2.cjs → Chart.impl-D9ZC6NM1.cjs} +2 -2
- package/dist/{Chart.impl-BFdGxrv2.cjs.map → Chart.impl-D9ZC6NM1.cjs.map} +1 -1
- package/dist/index-B5DF6TVa.cjs +460 -0
- package/dist/index-B5DF6TVa.cjs.map +1 -0
- package/dist/{index-DlDapUIF.js → index-ZDE0vbgt.js} +6235 -5154
- package/dist/index-ZDE0vbgt.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/load-voice-sdk.cjs +2 -0
- package/dist/load-voice-sdk.cjs.map +1 -0
- package/dist/load-voice-sdk.d.ts +2 -0
- package/dist/load-voice-sdk.js +7 -0
- package/dist/load-voice-sdk.js.map +1 -0
- package/dist/package.json.d.ts +2 -1
- package/dist/src/WidgetImperativeHandler.d.ts +6 -0
- package/dist/src/WidgetImperativeHandler.d.ts.map +1 -1
- package/dist/src/WidgetPopoverContent.d.ts.map +1 -1
- package/dist/src/companion/CompanionContent.d.ts.map +1 -1
- package/dist/src/companion/WidgetCompanion.d.ts.map +1 -1
- package/dist/src/companion/useCompanionHostEffects.d.ts.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/screens/chat/ChatInput.d.ts.map +1 -1
- package/dist/src/screens/chat/ChatMain.d.ts.map +1 -1
- package/dist/src/screens/chat/agent/AgentChatMain.d.ts.map +1 -1
- package/dist/src/voice/VoiceCallButton.d.ts +4 -0
- package/dist/src/voice/VoiceCallButton.d.ts.map +1 -0
- package/dist/src/voice/VoiceCallCard.d.ts +11 -0
- package/dist/src/voice/VoiceCallCard.d.ts.map +1 -0
- package/dist/src/voice/VoiceCallProvider.d.ts +64 -0
- package/dist/src/voice/VoiceCallProvider.d.ts.map +1 -0
- package/dist/src/voice/VoiceCallScreen.d.ts +9 -0
- package/dist/src/voice/VoiceCallScreen.d.ts.map +1 -0
- package/dist/src/voice/VoiceOrb.d.ts +19 -0
- package/dist/src/voice/VoiceOrb.d.ts.map +1 -0
- package/dist/src/voice/VoiceTranscript.d.ts +14 -0
- package/dist/src/voice/VoiceTranscript.d.ts.map +1 -0
- package/dist/src/voice/load-voice-sdk.d.ts +10 -0
- package/dist/src/voice/load-voice-sdk.d.ts.map +1 -0
- package/dist/src/voice/orb/LiquidOrb.d.ts +13 -0
- package/dist/src/voice/orb/LiquidOrb.d.ts.map +1 -0
- package/dist/src/voice/orb/renderer.d.ts +12 -0
- package/dist/src/voice/orb/renderer.d.ts.map +1 -0
- package/dist/src/voice/spoken-text.d.ts +8 -0
- package/dist/src/voice/spoken-text.d.ts.map +1 -0
- package/dist/src/voice/voice-call-placement.d.ts +9 -0
- package/dist/src/voice/voice-call-placement.d.ts.map +1 -0
- package/dist/src/voice/voice-copy.d.ts +40 -0
- package/dist/src/voice/voice-copy.d.ts.map +1 -0
- package/package.json +6 -5
- package/dist/index-Cv8Wst3d.cjs +0 -390
- package/dist/index-Cv8Wst3d.cjs.map +0 -1
- package/dist/index-DlDapUIF.js.map +0 -1
package/dist/index-Cv8Wst3d.cjs
DELETED
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
"use strict";var lc=Object.defineProperty;var dc=(e,t,n)=>t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Io=(e,t,n)=>dc(e,typeof t!="symbol"?t+"":t,n);const r=require("react/jsx-runtime"),uc=require("@radix-ui/react-popover"),W=require("framer-motion"),u=require("react"),C=require("@opencx/widget-react-headless"),k=require("zod"),G=require("@opencx/widget-core"),T=require("lucide-react"),pc=require("clsx"),mc=require("tailwind-merge"),hc=require("@radix-ui/react-slot"),Xs=require("class-variance-authority"),Gs=require("remark-gfm"),fc=require("react-markdown"),ar=require("rehype-raw"),ve=require("rehype-sanitize"),gc=require("@radix-ui/react-avatar"),Ks=require("@uiw/react-iframe"),zo=require("tinycolor2"),xc=require("@radix-ui/react-tooltip"),Kt=require("react-dom"),bc=require("@radix-ui/react-menu"),wc=require("html-to-image"),vc=require("react-dropzone"),Zs=require("@shardsui/notation"),zn=require("react-use");function Zt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Qe=Zt(uc),rt=Zt(u),Mt=Zt(gc),Te=Zt(xc),_e=Zt(bc);var Js=k.z.union([k.z.string(),k.z.number(),k.z.boolean(),k.z.null(),k.z.object({$state:k.z.string()})]);k.z.union([k.z.string(),k.z.object({$state:k.z.string()})]);k.z.union([k.z.number(),k.z.object({$state:k.z.string()})]);k.z.union([k.z.boolean(),k.z.object({$state:k.z.string()})]);function Qs(e,t){if(e!=null)return typeof e=="object"&&"$state"in e?ie(t,e.$state):e}function yc(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Jt(e){return(e.startsWith("/")?e.slice(1).split("/"):e.split("/")).map(yc)}function ie(e,t){if(!t||t==="/")return e;const n=Jt(t);let o=e;for(const s of n){if(o==null)return;if(Array.isArray(o)){const i=parseInt(s,10);o=o[i]}else if(typeof o=="object")o=o[s];else return}return o}function ea(e){return/^\d+$/.test(e)}function kc(e,t,n){const o=Jt(t);if(o.length===0)return;let s=e;for(let a=0;a<o.length-1;a++){const c=o[a],d=o[a+1],l=d!==void 0&&(ea(d)||d==="-");if(Array.isArray(s)){const m=parseInt(c,10);(s[m]===void 0||typeof s[m]!="object")&&(s[m]=l?[]:{}),s=s[m]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=l?[]:{}),s=s[c]}const i=o[o.length-1];if(Array.isArray(s))if(i==="-")s.push(n);else{const a=parseInt(i,10);s[a]=n}else s[i]=n}function Vn(e,t,n){const o=Jt(t);if(o.length===0)return;let s=e;for(let a=0;a<o.length-1;a++){const c=o[a],d=o[a+1],l=d!==void 0&&(ea(d)||d==="-");if(Array.isArray(s)){const m=parseInt(c,10);(s[m]===void 0||typeof s[m]!="object")&&(s[m]=l?[]:{}),s=s[m]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=l?[]:{}),s=s[c]}const i=o[o.length-1];if(Array.isArray(s))if(i==="-")s.push(n);else{const a=parseInt(i,10);s.splice(a,0,n)}else s[i]=n}function Mo(e,t){const n=Jt(t);if(n.length===0)return;let o=e;for(let i=0;i<n.length-1;i++){const a=n[i];if(Array.isArray(o)){const c=parseInt(a,10);if(o[c]===void 0||typeof o[c]!="object")return;o=o[c]}else{if(!(a in o)||typeof o[a]!="object")return;o=o[a]}}const s=n[n.length-1];if(Array.isArray(o)){const i=parseInt(s,10);i>=0&&i<o.length&&o.splice(i,1)}else delete o[s]}function ir(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!=typeof t||typeof e!="object")return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((a,c)=>ir(a,t[c]));const n=e,o=t,s=Object.keys(n),i=Object.keys(o);return s.length!==i.length?!1:s.every(a=>ir(n[a],o[a]))}function cr(e){const t=e.trim();if(!t||!t.startsWith("{"))return null;try{const n=JSON.parse(t);return n.op&&n.path!==void 0?n:null}catch{return null}}function ta(e,t){switch(t.op){case"add":Vn(e,t.path,t.value);break;case"replace":kc(e,t.path,t.value);break;case"remove":Mo(e,t.path);break;case"move":{if(!t.from)break;const n=ie(e,t.from);Mo(e,t.from),Vn(e,t.path,n);break}case"copy":{if(!t.from)break;const n=ie(e,t.from);Vn(e,t.path,n);break}case"test":{const n=ie(e,t.path);if(!ir(n,t.value))throw new Error(`Test operation failed: value at "${t.path}" does not match`);break}}return e}function jc(e,t){return ta(e,t),e}function Cc(e){const t={};let n=0;function o(a){const c=`el-${n++}`,{type:d,props:l,children:m,...p}=a,h=[];if(Array.isArray(m))for(const x of m)x&&typeof x=="object"&&"type"in x&&h.push(o(x));const f={type:d??"unknown",props:l??{},children:h};for(const[x,g]of Object.entries(p))x!=="state"&&g!==void 0&&(f[x]=g);return t[c]=f,c}const i={root:o(e),elements:t};return e.state&&typeof e.state=="object"&&!Array.isArray(e.state)&&(i.state=e.state),i}function Sc(e,t={}){const n=e.split(`
|
|
2
|
-
`),o={...t};for(const s of n){const i=cr(s);i&&ta(o,i)}return o}var Nc="spec",_c=`data-${Nc}`;function Ro(e,t,n){const o=Jt(t);if(o.length===0)return e;const s={...e};let i=s;for(let c=0;c<o.length-1;c++){const d=o[c],l=i[d];if(Array.isArray(l))i[d]=[...l];else if(l!==null&&typeof l=="object")i[d]={...l};else{const m=o[c+1];i[d]=m!==void 0&&/^\d+$/.test(m)?[]:{}}i=i[d]}const a=o[o.length-1];return Array.isArray(i)?a==="-"?i.push(n):i[parseInt(a,10)]=n:i[a]=n,s}function Ec(e={}){let t={...e};const n=new Set;function o(){for(const s of n)s()}return{get(s){return ie(t,s)},set(s,i){ie(t,s)!==i&&(t=Ro(t,s,i),o())},update(s){let i=!1,a=t;for(const[c,d]of Object.entries(s))ie(a,c)!==d&&(a=Ro(a,c,d),i=!0);i&&(t=a,o())},getSnapshot(){return t},getServerSnapshot(){return t},subscribe(s){return n.add(s),()=>{n.delete(s)}}}}var Yn=20;function Fr(e,t="",n=0,o,s){const i=o??new Set,a=s??{current:!1},c={};for(const[d,l]of Object.entries(e)){const m=`${t}/${d}`;n<Yn&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&Object.getPrototypeOf(l)===Object.prototype&&!i.has(l)?(i.add(l),Object.assign(c,Fr(l,m,n+1,i,a))):(process.env.NODE_ENV!=="production"&&!a.current&&n>=Yn&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&Object.getPrototypeOf(l)===Object.prototype&&!i.has(l)&&(a.current=!0,console.warn(`flattenToPointers: depth limit (${Yn}) reached. Nested state beyond this depth will be treated as a leaf value.`)),c[m]=l)}return c}var mn=k.z.union([k.z.number(),k.z.object({$state:k.z.string()})]),Hr={eq:k.z.unknown().optional(),neq:k.z.unknown().optional(),gt:mn.optional(),gte:mn.optional(),lt:mn.optional(),lte:mn.optional(),not:k.z.literal(!0).optional()},Tc=k.z.object({$state:k.z.string(),...Hr}),Ac=k.z.object({$item:k.z.string(),...Hr}),Ic=k.z.object({$index:k.z.literal(!0),...Hr}),Po=k.z.union([Tc,Ac,Ic]),lr=k.z.lazy(()=>k.z.union([k.z.boolean(),Po,k.z.array(Po),k.z.object({$and:k.z.array(lr)}),k.z.object({$or:k.z.array(lr)})]));function jt(e,t){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"?ie(t.stateModel,e.$state):e}function zc(e){return"$item"in e}function Mc(e){return"$index"in e}function Rc(e,t){return Mc(e)?t.repeatIndex:zc(e)?t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ie(t.repeatItem,e.$item):ie(t.stateModel,e.$state)}function Oo(e,t){const n=Rc(e,t);let o;if(e.eq!==void 0){const s=jt(e.eq,t);o=n===s}else if(e.neq!==void 0){const s=jt(e.neq,t);o=n!==s}else if(e.gt!==void 0){const s=jt(e.gt,t);o=typeof n=="number"&&typeof s=="number"?n>s:!1}else if(e.gte!==void 0){const s=jt(e.gte,t);o=typeof n=="number"&&typeof s=="number"?n>=s:!1}else if(e.lt!==void 0){const s=jt(e.lt,t);o=typeof n=="number"&&typeof s=="number"?n<s:!1}else if(e.lte!==void 0){const s=jt(e.lte,t);o=typeof n=="number"&&typeof s=="number"?n<=s:!1}else o=!!n;return e.not===!0?!o:o}function Pc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$and"in e}function Oc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$or"in e}function Et(e,t){return e===void 0?!0:typeof e=="boolean"?e:Array.isArray(e)?e.every(n=>Oo(n,t)):Pc(e)?e.$and.every(n=>Et(n,t)):Oc(e)?e.$or.some(n=>Et(n,t)):Oo(e,t)}function $c(e){const t=new Map;for(const n of e)t.set(n.name,n);return t}function Lc(e,t){if(!t||t.size===0)return;let n;for(const[o,s]of t)if(o in e){if(n)throw new Error(`Ambiguous directive: object has multiple directive keys ("${n.name}" and "${o}")`);n=s}return n}function Dc(e){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"}function na(e){return typeof e=="object"&&e!==null&&"$item"in e&&typeof e.$item=="string"}function ra(e){return typeof e=="object"&&e!==null&&"$index"in e&&e.$index===!0}function oa(e){return typeof e=="object"&&e!==null&&"$bindState"in e&&typeof e.$bindState=="string"}function sa(e){return typeof e=="object"&&e!==null&&"$bindItem"in e&&typeof e.$bindItem=="string"}function Fc(e){return typeof e=="object"&&e!==null&&"$cond"in e&&"$then"in e&&"$else"in e}function Hc(e){return typeof e=="object"&&e!==null&&"$computed"in e&&typeof e.$computed=="string"}function Wc(e){return typeof e=="object"&&e!==null&&"$template"in e&&typeof e.$template=="string"}var Uc=100,Xn=new Set;function Wr(e,t){if(t.repeatBasePath==null){console.warn(`$bindItem used outside repeat scope: "${e}"`);return}return e===""?t.repeatBasePath:t.repeatBasePath+"/"+e}function ut(e,t){var n;if(e==null)return e;if(Dc(e))return ie(t.stateModel,e.$state);if(na(e))return t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ie(t.repeatItem,e.$item);if(ra(e))return t.repeatIndex;if(oa(e))return ie(t.stateModel,e.$bindState);if(sa(e)){const o=Wr(e.$bindItem,t);return o===void 0?void 0:ie(t.stateModel,o)}if(Fc(e)){const o=Et(e.$cond,t);return ut(o?e.$then:e.$else,t)}if(Hc(e)){const o=(n=t.functions)==null?void 0:n[e.$computed];if(!o){Xn.has(e.$computed)||(Xn.size<Uc&&Xn.add(e.$computed),console.warn(`Unknown $computed function: "${e.$computed}"`));return}const s={};if(e.args)for(const[i,a]of Object.entries(e.args))s[i]=ut(a,t);return o(s)}if(Wc(e))return e.$template.replace(/\$\{([^}]+)\}/g,(o,s)=>{if(s.startsWith("/")){const a=ie(t.stateModel,s);return a!=null?String(a):""}if(t.repeatItem!==void 0){const a=ie(t.repeatItem,s);if(a!=null)return String(a)}const i=ie(t.stateModel,"/"+s);return i!=null?String(i):""});if(Array.isArray(e))return e.map(o=>ut(o,t));if(typeof e=="object"){const o=Lc(e,t.directives);if(o)return o.resolve(e,t);const s={};for(const[i,a]of Object.entries(e))s[i]=ut(a,t);return s}return e}function Bc(e,t){const n={};for(const[o,s]of Object.entries(e))n[o]=ut(s,t);return n}function qc(e,t){let n;for(const[o,s]of Object.entries(e))if(oa(s))n||(n={}),n[o]=s.$bindState;else if(sa(s)){const i=Wr(s.$bindItem,t);i!==void 0&&(n||(n={}),n[o]=i)}return n}function $o(e,t){return na(e)?Wr(e.$item,t):ra(e)?t.repeatIndex:ut(e,t)}var aa=new Set;function Vc(e){for(const t of aa){const n=t.onDispatch;if(n)try{n(e)}catch(o){process.env.NODE_ENV!=="production"&&console.error("[json-render] action observer threw in onDispatch:",o)}}}function Yc(e){for(const t of aa){const n=t.onSettle;if(n)try{n(e)}catch(o){process.env.NODE_ENV!=="production"&&console.error("[json-render] action observer threw in onSettle:",o)}}}var Lo=0;function Xc(){return Lo+=1,`${Date.now()}-${Lo}`}var Gc=0,Do=new Set;function Kc(){return Gc>0}function Zc(e){return Do.add(e),()=>{Do.delete(e)}}var Jc=k.z.object({title:k.z.string(),message:k.z.string(),confirmLabel:k.z.string().optional(),cancelLabel:k.z.string().optional(),variant:k.z.enum(["default","danger"]).optional()}),Qc=k.z.union([k.z.object({navigate:k.z.string()}),k.z.object({set:k.z.record(k.z.string(),k.z.unknown())}),k.z.object({action:k.z.string()})]),el=k.z.union([k.z.object({set:k.z.record(k.z.string(),k.z.unknown())}),k.z.object({action:k.z.string()})]);k.z.object({action:k.z.string(),params:k.z.record(k.z.string(),Js).optional(),confirm:Jc.optional(),onSuccess:Qc.optional(),onError:el.optional(),preventDefault:k.z.boolean().optional()});function tl(e,t){const n={};if(e.params)for(const[s,i]of Object.entries(e.params))n[s]=Qs(i,t);let o=e.confirm;return o&&(o={...o,message:Fo(o.message,t),title:Fo(o.title,t)}),{action:e.action,params:n,confirm:o,onSuccess:e.onSuccess,onError:e.onError}}function Fo(e,t){return e.replace(/\$\{([^}]+)\}/g,(n,o)=>{const s=Qs({$state:o},t);return String(s??"")})}async function Ho(e){const{action:t,handler:n,setState:o,navigate:s,executeAction:i}=e;try{if(await n(t.params),t.onSuccess)if("navigate"in t.onSuccess&&s)s(t.onSuccess.navigate);else if("set"in t.onSuccess)for(const[a,c]of Object.entries(t.onSuccess.set))o(a,c);else"action"in t.onSuccess&&i&&await i(t.onSuccess.action)}catch(a){if(t.onError)if("set"in t.onError)for(const[c,d]of Object.entries(t.onError.set)){const l=typeof d=="string"&&d==="$error.message"?a.message:d;o(c,l)}else"action"in t.onError&&i&&await i(t.onError.action);else throw a}}var nl=k.z.object({type:k.z.string(),args:k.z.record(k.z.string(),Js).optional(),message:k.z.string()});k.z.object({checks:k.z.array(nl).optional(),validateOn:k.z.enum(["change","blur","submit"]).optional(),enabled:lr.optional()});var Wo=(e,t)=>{const n=t==null?void 0:t.other;return e===n},rl={required:e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0,email:e=>typeof e!="string"?!1:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),minLength:(e,t)=>{if(typeof e!="string")return!1;const n=t==null?void 0:t.min;return typeof n!="number"?!1:e.length>=n},maxLength:(e,t)=>{if(typeof e!="string")return!1;const n=t==null?void 0:t.max;return typeof n!="number"?!1:e.length<=n},pattern:(e,t)=>{if(typeof e!="string")return!1;const n=t==null?void 0:t.pattern;if(typeof n!="string")return!1;try{return new RegExp(n).test(e)}catch{return!1}},min:(e,t)=>{if(typeof e!="number")return!1;const n=t==null?void 0:t.min;return typeof n!="number"?!1:e>=n},max:(e,t)=>{if(typeof e!="number")return!1;const n=t==null?void 0:t.max;return typeof n!="number"?!1:e<=n},numeric:e=>typeof e=="number"?!isNaN(e):typeof e=="string"?!isNaN(parseFloat(e)):!1,url:e=>{if(typeof e!="string")return!1;try{return new URL(e),!0}catch{return!1}},matches:Wo,equalTo:Wo,lessThan:(e,t)=>{const n=t==null?void 0:t.other;if(e==null||n==null||e===""||n==="")return!1;if(typeof e=="number"&&typeof n=="number"||typeof e=="string"&&typeof n=="string")return e<n;const o=Number(e),s=Number(n);return!isNaN(o)&&!isNaN(s)?o<s:!1},greaterThan:(e,t)=>{const n=t==null?void 0:t.other;if(e==null||n==null||e===""||n==="")return!1;if(typeof e=="number"&&typeof n=="number"||typeof e=="string"&&typeof n=="string")return e>n;const o=Number(e),s=Number(n);return!isNaN(o)&&!isNaN(s)?o>s:!1},requiredIf:(e,t)=>(t==null?void 0:t.field)?e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:!0:!0};function ol(e,t){const{value:n,stateModel:o,customFunctions:s}=t,i={};if(e.args)for(const[d,l]of Object.entries(e.args))i[d]=ut(l,{stateModel:o});const a=rl[e.type]??(s==null?void 0:s[e.type]);if(!a)return console.warn(`Unknown validation function: ${e.type}`),{type:e.type,valid:!0,message:e.message};const c=a(n,i);return{type:e.type,valid:c,message:e.message}}function sl(e,t){const n=[],o=[];if(e.enabled&&!Et(e.enabled,{stateModel:t.stateModel}))return{valid:!0,errors:[],checks:[]};if(e.checks)for(const s of e.checks){const i=ol(s,t);n.push(i),i.valid||o.push(i.message)}return{valid:o.length===0,errors:o,checks:n}}var al=["patch"];function il(e){var t;return(t=e==null?void 0:e.modes)!=null&&t.length?e.modes:al}function cl(){return["PATCH MODE (RFC 6902 JSON Patch):","Output one JSON object per line. Each line is a patch operation.",'- Add: {"op":"add","path":"/elements/new-key","value":{...}}','- Replace: {"op":"replace","path":"/elements/existing-key","value":{...}}','- Remove: {"op":"remove","path":"/elements/old-key"}',"Only output patches for what needs to change."].join(`
|
|
3
|
-
`)}function ll(){return["MERGE MODE (RFC 7396 JSON Merge Patch):","Output a single JSON object on one line with __json_edit set to true.","Include only the keys that changed. Unmentioned keys are preserved.","Set a key to null to delete it.","","Example (update a title and add an element):",'{"__json_edit":true,"elements":{"main":{"props":{"title":"New Title"}},"new-el":{"type":"Card","props":{},"children":[]}}}',"","Example (delete an element):",'{"__json_edit":true,"elements":{"old-widget":null}}'].join(`
|
|
4
|
-
`)}function dl(){return["DIFF MODE (unified diff):","Output a unified diff inside a ```diff code fence.","The diff applies against the JSON-serialized current spec.","","Example:","```diff","--- a/spec.json","+++ b/spec.json","@@ -3,1 +3,1 @@",'- "title": "Login"','+ "title": "Welcome Back"',"```"].join(`
|
|
5
|
-
`)}function ul(e){if(e.length===1)return"";const t=["Choose the best edit strategy for the requested change:"];return e.includes("patch")&&t.push("- PATCH: best for precise, targeted single-field updates"),e.includes("merge")&&t.push("- MERGE: best for structural changes (add/remove elements, reparent children, update multiple props at once)"),e.includes("diff")&&t.push("- DIFF: best for small text-level changes when you can see the exact lines to change"),t.join(`
|
|
6
|
-
`)}function pl(e,t){const n=il(e),o=[];o.push("EDITING EXISTING SPECS:"),o.push("");const s=ul(n);s&&(o.push(s),o.push(""));for(const i of n){switch(i){case"patch":o.push(cl());break;case"merge":o.push(ll());break;case"diff":o.push(dl());break}o.push("")}return o.join(`
|
|
7
|
-
`)}function ia(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.root=="string"&&typeof t.elements=="object"&&t.elements!==null&&Object.keys(t.elements).length>0}function ml(){return{string:()=>({kind:"string"}),number:()=>({kind:"number"}),boolean:()=>({kind:"boolean"}),array:e=>({kind:"array",inner:e}),object:e=>({kind:"object",inner:e}),record:e=>({kind:"record",inner:e}),any:()=>({kind:"any"}),zod:()=>({kind:"zod"}),ref:e=>({kind:"ref",inner:e}),propsOf:e=>({kind:"propsOf",inner:e}),map:e=>({kind:"map",inner:e}),optional:()=>({optional:!0})}}function hl(e,t){const n=ml();return{definition:e(n),promptTemplate:t==null?void 0:t.promptTemplate,defaultRules:t==null?void 0:t.defaultRules,builtInActions:t==null?void 0:t.builtInActions,createCatalog(s){return fl(this,s)}}}function fl(e,t){const n=t.components,o=t.actions,s=n?Object.keys(n):[],i=o?Object.keys(o):[],a=gl(e.definition,t);return{schema:e,data:t,componentNames:s,actionNames:i,prompt(c={}){return wl(this,c)},jsonSchema(c={}){return Ze(a,c.strict??!1)},validate(c){const d=a.safeParse(c);return d.success?{success:!0,data:d.data}:{success:!1,error:d.error}},zodSchema(){return a},get _specType(){throw new Error("_specType is only for type inference")}}}function gl(e,t){return vn(e.spec,t)}function vn(e,t){switch(e.kind){case"string":return k.z.string();case"number":return k.z.number();case"boolean":return k.z.boolean();case"any":return k.z.any();case"array":{const n=vn(e.inner,t);return k.z.array(n)}case"object":{const n=e.inner,o={};for(const[s,i]of Object.entries(n)){let a=vn(i,t);i.optional&&(a=a.optional()),o[s]=a}return k.z.object(o)}case"record":{const n=vn(e.inner,t);return k.z.record(k.z.string(),n)}case"ref":{const n=e.inner,o=xl(n,t);return o.length===0?k.z.string():o.length===1?k.z.literal(o[0]):k.z.enum(o)}case"propsOf":{const n=e.inner,o=bl(n,t);return o.length===0?k.z.record(k.z.string(),k.z.unknown()):o.length===1?o[0]:k.z.record(k.z.string(),k.z.unknown())}default:return k.z.unknown()}}function xl(e,t){const n=e.split(".");let o={catalog:t};for(const s of n)if(o&&typeof o=="object")o=o[s];else return[];return o&&typeof o=="object"?Object.keys(o):[]}function bl(e,t){const n=e.split(".");let o={catalog:t};for(const s of n)if(o&&typeof o=="object")o=o[s];else return[];return o&&typeof o=="object"?Object.values(o).map(s=>s.props).filter(s=>s!==void 0):[]}function wl(e,t){if(e.schema.promptTemplate){const E={catalog:e.data,componentNames:e.componentNames,actionNames:e.actionNames,options:t,formatZodType:Ee};return e.schema.promptTemplate(E)}const{system:n="You are a UI generator that outputs JSON.",customRules:o=[],mode:s="standalone"}=t,i=s==="chat"?(console.warn('[json-render] mode "chat" is deprecated, use "inline" instead'),"inline"):s==="generate"?(console.warn('[json-render] mode "generate" is deprecated, use "standalone" instead'),"standalone"):s,a=[];a.push(n),a.push(""),i==="inline"?(a.push("OUTPUT FORMAT (text + JSONL, RFC 6902 JSON Patch):"),a.push("You respond conversationally. When generating UI, first write a brief explanation (1-3 sentences), then output JSONL patch lines wrapped in a ```spec code fence."),a.push("The JSONL lines use RFC 6902 JSON Patch operations to build a UI tree. Always wrap them in a ```spec fence block:"),a.push(" ```spec"),a.push(' {"op":"add","path":"/root","value":"main"}'),a.push(' {"op":"add","path":"/elements/main","value":{"type":"Card","props":{"title":"Hello"},"children":[]}}'),a.push(" ```"),a.push("If the user's message does not require a UI (e.g. a greeting or clarifying question), respond with text only — no JSONL.")):(a.push("OUTPUT FORMAT (JSONL, RFC 6902 JSON Patch):"),a.push("Output JSONL (one JSON object per line) using RFC 6902 JSON Patch operations to build a UI tree.")),a.push("Each line is a JSON patch operation (add, remove, replace). Start with /root, then stream /elements and /state patches interleaved so the UI fills in progressively as it streams."),a.push(""),a.push("Example output (each line is a separate JSON object):"),a.push("");const c=e.data.components,d=e.componentNames,l=d[0]||"Component",m=d.length>1?d[1]:l,p=c==null?void 0:c[l],h=c==null?void 0:c[m],f=p?Uo(p):{},x=h?Uo(h):{},g=h!=null&&h.props?vl(h.props):null,j=g?{...x,[g]:{$item:"title"}}:x,b=[JSON.stringify({op:"add",path:"/root",value:"main"}),JSON.stringify({op:"add",path:"/elements/main",value:{type:l,props:f,children:["child-1","list"]}}),JSON.stringify({op:"add",path:"/elements/child-1",value:{type:m,props:x,children:[]}}),JSON.stringify({op:"add",path:"/elements/list",value:{type:l,props:f,repeat:{statePath:"/items",key:"id"},children:["item"]}}),JSON.stringify({op:"add",path:"/elements/item",value:{type:m,props:j,children:[]}}),JSON.stringify({op:"add",path:"/state/items",value:[]}),JSON.stringify({op:"add",path:"/state/items/0",value:{id:"1",title:"First Item"}}),JSON.stringify({op:"add",path:"/state/items/1",value:{id:"2",title:"Second Item"}})].join(`
|
|
8
|
-
`);a.push(`${b}
|
|
9
|
-
|
|
10
|
-
Note: state patches appear right after the elements that use them, so the UI fills in as it streams. ONLY use component types from the AVAILABLE COMPONENTS list below.`),a.push(""),a.push("INITIAL STATE:"),a.push("Specs include a /state field to seed the state model. Components with { $bindState } or { $bindItem } read from and write to this state, and $state expressions read from it."),a.push("CRITICAL: You MUST include state patches whenever your UI displays data via $state, $bindState, $bindItem, $item, or $index expressions, or uses repeat to iterate over arrays. Without state, these references resolve to nothing and repeat lists render zero items."),a.push("Output state patches right after the elements that reference them, so the UI fills in progressively as it streams."),a.push("Stream state progressively - output one patch per array item instead of one giant blob:"),a.push(' For arrays: {"op":"add","path":"/state/posts/0","value":{"id":"1","title":"First Post",...}} then /state/posts/1, /state/posts/2, etc.'),a.push(' For scalars: {"op":"add","path":"/state/newTodoText","value":""}'),a.push(' Initialize the array first if needed: {"op":"add","path":"/state/posts","value":[]}'),a.push('When content comes from the state model, use { "$state": "/some/path" } dynamic props to display it instead of hardcoding the same value in both state and props. The state model is the single source of truth.'),a.push("Include realistic sample data in state. For blogs: 3-4 posts with titles, excerpts, authors, dates. For product lists: 3-5 items with names, prices, descriptions. Never leave arrays empty."),a.push(""),a.push("DYNAMIC LISTS (repeat field):"),a.push('Any element can have a top-level "repeat" field to render its children once per item in a state array: { "repeat": { "statePath": "/arrayPath", "key": "id" } }.'),a.push('The element itself renders once (as the container), and its children are expanded once per array item. "statePath" is the state array path. "key" is an optional field name on each item for stable React keys.'),a.push(`Example: ${JSON.stringify({type:l,props:f,repeat:{statePath:"/todos",key:"id"},children:["todo-item"]})}`),a.push('Inside children of a repeated element, use { "$item": "field" } to read a field from the current item, and { "$index": true } to get the current array index. For two-way binding to an item field use { "$bindItem": "completed" } on the appropriate prop.'),a.push("ALWAYS use the repeat field for lists backed by state arrays. NEVER hardcode individual elements for each array item."),a.push('IMPORTANT: "repeat" is a top-level field on the element (sibling of type/props/children), NOT inside props.'),a.push(""),a.push("ARRAY STATE ACTIONS:"),a.push('Use action "pushState" to append items to arrays. Params: { statePath: "/arrayPath", value: { ...item }, clearStatePath: "/inputPath" }.'),a.push('Values inside pushState can contain { "$state": "/statePath" } references to read current state (e.g. the text from an input field).'),a.push('Use "$id" inside a pushState value to auto-generate a unique ID.'),a.push('Example: on: { "press": { "action": "pushState", "params": { "statePath": "/todos", "value": { "id": "$id", "title": { "$state": "/newTodoText" }, "completed": false }, "clearStatePath": "/newTodoText" } } }'),a.push(`Use action "removeState" to remove items from arrays by index. Params: { statePath: "/arrayPath", index: N }. Inside a repeated element's children, use { "$index": true } for the current item index. Action params support the same expressions as props: { "$item": "field" } resolves to the absolute state path, { "$index": true } resolves to the index number, and { "$state": "/path" } reads a value from state.`),a.push("For lists where users can add/remove items (todos, carts, etc.), use pushState and removeState instead of hardcoding with setState."),a.push(""),a.push('IMPORTANT: State paths use RFC 6901 JSON Pointer syntax (e.g. "/todos/0/title"). Do NOT use JavaScript-style dot notation (e.g. "/todos.length" is WRONG). To generate unique IDs for new items, use "$id" instead of trying to read array length.'),a.push("");const S=c;if(S){a.push(`AVAILABLE COMPONENTS (${e.componentNames.length}):`),a.push("");for(const[E,I]of Object.entries(S)){const H=I.props?Ee(I.props):"{}",q=I.slots&&I.slots.length>0?" [accepts children]":"",X=I.events&&I.events.length>0?` [events: ${I.events.join(", ")}]`:"",B=I.description?` - ${I.description}`:"";a.push(`- ${E}: ${H}${B}${q}${X}`)}a.push("")}const w=e.data.actions,_=e.schema.builtInActions??[],y=w&&e.actionNames.length>0,v=_.length>0;if(y||v){a.push("AVAILABLE ACTIONS:"),a.push("");for(const E of _)a.push(`- ${E.name}: ${E.description} [built-in]`);if(y)for(const[E,I]of Object.entries(w))a.push(`- ${E}${I.description?`: ${I.description}`:""}`);a.push("")}a.push("EVENTS (the `on` field):"),a.push("Elements can have an optional `on` field to bind events to actions. The `on` field is a top-level field on the element (sibling of type/props/children), NOT inside props."),a.push('Each key in `on` is an event name (from the component\'s supported events), and the value is an action binding: `{ "action": "<actionName>", "params": { ... } }`.'),a.push(""),a.push("Example:"),a.push(` ${JSON.stringify({type:l,props:f,on:{press:{action:"setState",params:{statePath:"/saved",value:!0}}},children:[]})}`),a.push(""),a.push('Action params can use dynamic references to read from state: { "$state": "/statePath" }.'),a.push("IMPORTANT: Do NOT put action/actionParams inside props. Always use the `on` field for event bindings."),a.push(""),a.push("VISIBILITY CONDITIONS:"),a.push("Elements can have an optional `visible` field to conditionally show/hide based on state. IMPORTANT: `visible` is a top-level field on the element object (sibling of type/props/children), NOT inside props."),a.push(`Correct: ${JSON.stringify({type:l,props:f,visible:{$state:"/activeTab",eq:"home"},children:["..."]})}`),a.push('- `{ "$state": "/path" }` - visible when state at path is truthy'),a.push('- `{ "$state": "/path", "not": true }` - visible when state at path is falsy'),a.push('- `{ "$state": "/path", "eq": "value" }` - visible when state equals value'),a.push('- `{ "$state": "/path", "neq": "value" }` - visible when state does not equal value'),a.push('- `{ "$state": "/path", "gt": N }` / `gte` / `lt` / `lte` - numeric comparisons'),a.push("- Use ONE operator per condition (eq, neq, gt, gte, lt, lte). Do not combine multiple operators."),a.push('- Any condition can add `"not": true` to invert its result'),a.push("- `[condition, condition]` - all conditions must be true (implicit AND)"),a.push('- `{ "$and": [condition, condition] }` - explicit AND (use when nesting inside $or)'),a.push('- `{ "$or": [condition, condition] }` - at least one must be true (OR)'),a.push("- `true` / `false` - always visible/hidden"),a.push(""),a.push("Use a component with on.press bound to setState to update state and drive visibility."),a.push(`Example: A ${l} with on: { "press": { "action": "setState", "params": { "statePath": "/activeTab", "value": "home" } } } sets state, then a container with visible: { "$state": "/activeTab", "eq": "home" } shows only when that tab is active.`),a.push(""),a.push('For tab patterns where the first/default tab should be visible when no tab is selected yet, use $or to handle both cases: visible: { "$or": [{ "$state": "/activeTab", "eq": "home" }, { "$state": "/activeTab", "not": true }] }. This ensures the first tab is visible both when explicitly selected AND when /activeTab is not yet set.'),a.push(""),a.push("DYNAMIC PROPS:"),a.push("Any prop value can be a dynamic expression that resolves based on state. Three forms are supported:"),a.push(""),a.push('1. Read-only state: `{ "$state": "/statePath" }` - resolves to the value at that state path (one-way read).'),a.push(' Example: `"color": { "$state": "/theme/primary" }` reads the color from state.'),a.push(""),a.push('2. Two-way binding: `{ "$bindState": "/statePath" }` - resolves to the value at the state path AND enables write-back. Use on form input props (value, checked, pressed, etc.).'),a.push(' Example: `"value": { "$bindState": "/form/email" }` binds the input value to /form/email.'),a.push(' Inside repeat scopes: `"checked": { "$bindItem": "completed" }` binds to the current item\'s completed field.'),a.push(""),a.push('3. Conditional: `{ "$cond": <condition>, "$then": <value>, "$else": <value> }` - evaluates the condition (same syntax as visibility conditions) and picks the matching value.'),a.push(' Example: `"color": { "$cond": { "$state": "/activeTab", "eq": "home" }, "$then": "#007AFF", "$else": "#8E8E93" }`'),a.push(""),a.push("Use $bindState for form inputs (text fields, checkboxes, selects, sliders, etc.) and $state for read-only data display. Inside repeat scopes, use $bindItem for form inputs bound to the current item. Use dynamic props instead of duplicating elements with opposing visible conditions when only prop values differ."),a.push(""),a.push('4. Template: `{ "$template": "Hello, ${/name}!" }` - interpolates references in the string. Absolute paths like `${/path}` resolve against the state model. Bare names like `${field}` resolve against the current repeat item first, then fall back to the state model at `/<field>`.'),a.push(' Example: `"label": { "$template": "Items: ${/cart/count} | Total: ${/cart/total}" }` renders "Items: 3 | Total: 42.00" when /cart/count is 3 and /cart/total is 42.00. Inside a repeat, `{ "$template": "${name} - ${email}" }` reads name and email from each item.'),a.push("");const N=e.data.functions;if(N&&Object.keys(N).length>0){a.push('5. Computed: `{ "$computed": "<functionName>", "args": { "key": <expression> } }` - calls a registered function with resolved args and returns the result.'),a.push(' Example: `"value": { "$computed": "fullName", "args": { "first": { "$state": "/form/firstName" }, "last": { "$state": "/form/lastName" } } }`'),a.push(" Available functions:");for(const E of Object.keys(N))a.push(` - ${E}`);a.push("")}const R=t.directives;if(R&&R.length>0){a.push("CUSTOM DYNAMIC VALUES:"),a.push("");for(const E of R){const I=E.description?` (${E.description})`:"";a.push(`- ${E.name}${I}: ${Ee(E.schema)}`)}a.push(""),a.push("Directives compose: any value field can contain another directive or a $state expression, resolved inside-out."),a.push("")}(c?Object.entries(c).some(([,E])=>E.props?Ee(E.props).includes("checks"):!1):!1)&&(a.push("VALIDATION:"),a.push("Form components that accept a `checks` prop support client-side validation."),a.push('Each check is an object: { "type": "<name>", "message": "...", "args": { ... } }'),a.push(""),a.push("Built-in validation types:"),a.push(" - required — value must be non-empty"),a.push(" - email — valid email format"),a.push(' - minLength — minimum string length (args: { "min": N })'),a.push(' - maxLength — maximum string length (args: { "max": N })'),a.push(' - pattern — match a regex (args: { "pattern": "regex" })'),a.push(' - min — minimum numeric value (args: { "min": N })'),a.push(' - max — maximum numeric value (args: { "max": N })'),a.push(" - numeric — value must be a number"),a.push(" - url — valid URL format"),a.push(' - matches — must equal another field (args: { "other": { "$state": "/path" } })'),a.push(' - equalTo — alias for matches (args: { "other": { "$state": "/path" } })'),a.push(' - lessThan — value must be less than another field (args: { "other": { "$state": "/path" } })'),a.push(' - greaterThan — value must be greater than another field (args: { "other": { "$state": "/path" } })'),a.push(' - requiredIf — required only when another field is truthy (args: { "field": { "$state": "/path" } })'),a.push(""),a.push("Example:"),a.push(' "checks": [{ "type": "required", "message": "Email is required" }, { "type": "email", "message": "Invalid email" }]'),a.push(""),a.push("IMPORTANT: When using checks, the component must also have a { $bindState } or { $bindItem } on its value/checked prop for two-way binding."),a.push("Always include validation checks on form inputs for a good user experience (e.g. required, email, minLength)."),a.push("")),(y||v)&&(a.push("STATE WATCHERS:"),a.push("Elements can have an optional `watch` field to react to state changes and trigger actions. The `watch` field is a top-level field on the element (sibling of type/props/children), NOT inside props."),a.push("Maps state paths (JSON Pointers) to action bindings. When the value at a watched path changes, the bound actions fire automatically."),a.push(""),a.push("Example (cascading select — country changes trigger city loading):"),a.push(` ${JSON.stringify({type:"Select",props:{value:{$bindState:"/form/country"},options:["US","Canada","UK"]},watch:{"/form/country":{action:"loadCities",params:{country:{$state:"/form/country"}}}},children:[]})}`),a.push(""),a.push("Use `watch` for cascading dependencies where changing one field should trigger side effects (loading data, resetting dependent fields, computing derived values)."),a.push("IMPORTANT: `watch` is a top-level field on the element (sibling of type/props/children), NOT inside props. Watchers only fire when the value changes, not on initial render."),a.push(""));const z=t.editModes;z&&z.length>0&&a.push(pl({modes:z})),a.push("RULES:");const L=i==="inline"?["When generating UI, wrap all JSONL patches in a ```spec code fence - one JSON object per line inside the fence","Write a brief conversational response before any JSONL output",'First set root: {"op":"add","path":"/root","value":"<root-key>"}','Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.","ONLY use components listed above","Each element value needs: type, props, children (array of child keys)","Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"]:["Output ONLY JSONL patches - one JSON object per line, no markdown, no code fences",'First set root: {"op":"add","path":"/root","value":"<root-key>"}','Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.","ONLY use components listed above","Each element value needs: type, props, children (array of child keys)","Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"],O=e.schema.defaultRules??[];return[...L,...O,...o].forEach((E,I)=>{a.push(`${I+1}. ${E}`)}),a.join(`
|
|
11
|
-
`)}function Uo(e){return e.example&&Object.keys(e.example).length>0?e.example:e.props?ca(e.props):{}}function ca(e){if(!e||!e._def)return{};const t=e._def,n=ft(e);if(n!=="ZodObject"&&n!=="object")return{};const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return{};const s={};for(const[i,a]of Object.entries(o)){const c=ft(a);c==="ZodOptional"||c==="optional"||c==="ZodNullable"||c==="nullable"||(s[i]=dr(a))}return s}function dr(e){if(!e||!e._def)return"...";const t=e._def;switch(ft(e)){case"ZodString":case"string":return"example";case"ZodNumber":case"number":return 0;case"ZodBoolean":case"boolean":return!0;case"ZodLiteral":case"literal":return t.value;case"ZodEnum":case"enum":{if(Array.isArray(t.values)&&t.values.length>0)return t.values[0];if(t.entries&&typeof t.entries=="object"){const o=Object.values(t.entries);return o.length>0?o[0]:"example"}return"example"}case"ZodOptional":case"optional":case"ZodNullable":case"nullable":case"ZodDefault":case"default":{const o=t.innerType??t.wrapped;return o?dr(o):null}case"ZodArray":case"array":return[];case"ZodObject":case"object":return ca(e);case"ZodUnion":case"union":{const o=t.options;return o&&o.length>0?dr(o[0]):"..."}default:return"..."}}function vl(e){if(!e||!e._def)return null;const t=e._def,n=ft(e);if(n!=="ZodObject"&&n!=="object")return null;const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return null;for(const[s,i]of Object.entries(o)){const a=ft(i);if(!(a==="ZodOptional"||a==="optional"||a==="ZodNullable"||a==="nullable")&&(a==="ZodString"||a==="string"))return s}return null}function ft(e){if(!e||!e._def)return"";const t=e._def;return t.typeName??t.type??""}function Ee(e){if(!e||!e._def)return"unknown";const t=e._def;switch(ft(e)){case"ZodString":case"string":return"string";case"ZodNumber":case"number":return"number";case"ZodBoolean":case"boolean":return"boolean";case"ZodLiteral":case"literal":{const o=t.values,s=(o==null?void 0:o[0])??t.value;return JSON.stringify(s)}case"ZodEnum":case"enum":{let o;if(Array.isArray(t.values))o=t.values;else if(t.entries&&typeof t.entries=="object")o=Object.values(t.entries);else return"enum";return o.map(s=>`"${s}"`).join(" | ")}case"ZodArray":case"array":{const o=typeof t.element=="object"?t.element:typeof t.type=="object"?t.type:void 0;return o?`Array<${Ee(o)}>`:"Array<unknown>"}case"ZodObject":case"object":{const o=typeof t.shape=="function"?t.shape():t.shape;return o?`{ ${Object.entries(o).map(([i,a])=>{const c=ft(a);return`${i}${c==="ZodOptional"||c==="ZodNullable"||c==="optional"||c==="nullable"?"?":""}: ${Ee(a)}`}).join(", ")} }`:"object"}case"ZodOptional":case"optional":case"ZodNullable":case"nullable":{const o=t.innerType??t.wrapped;return o?Ee(o):"unknown"}case"ZodUnion":case"union":{const o=t.options;return o?o.map(s=>Ee(s)).join(" | "):"unknown"}case"ZodRecord":case"record":{const o=t.keyType??void 0,s=t.valueType??t.element??void 0,i=o?Ee(o):"string",a=s?Ee(s):"unknown";return`Record<${i}, ${a}>`}case"ZodDefault":case"default":{const o=t.innerType??t.wrapped;return o?Ee(o):"unknown"}default:return"unknown"}}function Bo(e){return typeof e.type=="string"?e.type:typeof e.typeName=="string"?e.typeName:""}function qo(e){return e.startsWith("Zod")?e.slice(3).toLowerCase():e.toLowerCase()}function Ze(e,t=!1){const n=e._def;switch(qo(Bo(n))){case"string":return{type:"string"};case"number":return{type:"number"};case"boolean":return{type:"boolean"};case"literal":{const s=n.values;return{const:s?s[0]:n.value}}case"enum":{const s=n.entries;return{enum:(s?Object.values(s):n.values)??[]}}case"array":{const s=n.element??n.type;return{type:"array",items:s?Ze(s,t):{}}}case"object":{const s=n.shape,i=typeof s=="function"?s():s;if(!i)return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object"};const a={},c=[];for(const[d,l]of Object.entries(i)){const m=l._def,p=qo(Bo(m)),h=p==="optional"||p==="nullable";if(t)if(c.push(d),h){const f=Ze(l,t);a[d]={anyOf:[f,{type:"null"}]}}else a[d]=Ze(l,t);else a[d]=Ze(l),h||c.push(d)}return{type:"object",properties:a,required:c.length>0?c:void 0,additionalProperties:!1}}case"record":{const s=n.valueType;return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object",additionalProperties:s?Ze(s):!0}}case"optional":case"nullable":{const s=n.innerType;return s?Ze(s,t):{}}case"union":{const s=n.options;return s?{anyOf:s.map(i=>Ze(i,t))}:{}}case"any":case"unknown":return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{};default:return{}}}function yl(e,t){return e.createCatalog(t)}var kl=hl(e=>({spec:e.object({root:e.string(),elements:e.record(e.object({type:e.ref("catalog.components"),props:e.propsOf("catalog.components"),children:e.array(e.string()),visible:e.any()}))}),catalog:e.object({components:e.map({props:e.zod(),slots:e.array(e.string()),description:e.string(),example:e.any()}),actions:e.map({params:e.zod(),description:e.string()})})}),{builtInActions:[{name:"setState",description:"Update a value in the state model at the given statePath. Params: { statePath: string, value: any }"},{name:"pushState",description:'Append an item to an array in state. Params: { statePath: string, value: any, clearStatePath?: string }. Value can contain {"$state":"/path"} refs and "$id" for auto IDs.'},{name:"removeState",description:"Remove an item from an array in state by index. Params: { statePath: string, index: number }"},{name:"validateForm",description:"Validate all registered form fields and write the result to state. Params: { statePath?: string }. Defaults to /formValidation. Result: { valid: boolean, errors: Record<string, string[]> }."}],defaultRules:["CRITICAL INTEGRITY CHECK: Before outputting ANY element that references children, you MUST have already output (or will output) each child as its own element. If an element has children: ['a', 'b'], then elements 'a' and 'b' MUST exist. A missing child element causes that entire branch of the UI to be invisible.","SELF-CHECK: After generating all elements, mentally walk the tree from root. Every key in every children array must resolve to a defined element. If you find a gap, output the missing element immediately.",'CRITICAL: The "visible" field goes on the ELEMENT object, NOT inside "props". Correct: {"type":"<ComponentName>","props":{},"visible":{"$state":"/tab","eq":"home"},"children":[...]}.','CRITICAL: The "on" field goes on the ELEMENT object, NOT inside "props". Use on.press, on.change, on.submit etc. NEVER put action/actionParams inside props.',"When the user asks for a UI that displays data (e.g. blog posts, products, users), ALWAYS include a state field with realistic sample data. The state field is a top-level field on the spec (sibling of root/elements).",'When building repeating content backed by a state array (e.g. posts, products, items), use the "repeat" field on a container element. Example: { "type": "<ContainerComponent>", "props": {}, "repeat": { "statePath": "/posts", "key": "id" }, "children": ["post-card"] }. Replace <ContainerComponent> with an appropriate component from the AVAILABLE COMPONENTS list. Inside repeated children, use { "$item": "field" } to read a field from the current item, and { "$index": true } for the current array index. For two-way binding to an item field use { "$bindItem": "completed" }. Do NOT hardcode individual elements for each array item.',"Design with visual hierarchy: use container components to group content, heading components for section titles, proper spacing, and status indicators. ONLY use components from the AVAILABLE COMPONENTS list.","For data-rich UIs, use multi-column layout components if available. For forms and single-column content, use vertical layout components. ONLY use components from the AVAILABLE COMPONENTS list.","Always include realistic, professional-looking sample data. For blogs include 3-4 posts with varied titles, authors, dates, categories. For products include names, prices, images. Never leave data empty."]}),la=u.createContext(null);function jl(e,t){return e?null:Object.keys(t).length===0?{}:Fr(t)}function Cl({store:e,initialState:t={},onStateChange:n,children:o}){const s=u.useRef(void 0);!e&&!s.current&&(s.current=Ec(t));const i=e??s.current,a=u.useRef(i);a.current=i;const c=u.useRef(!!e);c.current=!!e;const d=u.useRef(e?"controlled":"uncontrolled"),l=u.useRef(!1);if(process.env.NODE_ENV!=="production"){const w=e?"controlled":"uncontrolled";w!==d.current&&!l.current&&(l.current=!0,console.warn(`StateProvider: switching from ${d.current} to ${w} mode is not supported.`))}const m=u.useRef(t),p=u.useRef(jl(!!e,t));u.useEffect(()=>{if(e||t===m.current)return;m.current=t;const w=t&&Object.keys(t).length>0?Fr(t):{},_=p.current??{},y=new Set([...Object.keys(_),...Object.keys(w)]),v={};for(const N of y)_[N]!==w[N]&&(v[N]=N in w?w[N]:void 0);p.current=w,Object.keys(v).length>0&&i.update(v)},[e,t,i]);const h=u.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getServerSnapshot??i.getSnapshot),f=u.useRef(n);f.current=n;const x=u.useCallback((w,_)=>{var N;const y=a.current,v=y.getSnapshot();y.set(w,_),!c.current&&y.getSnapshot()!==v&&((N=f.current)==null||N.call(f,[{path:w,value:_}]))},[]),g=u.useCallback(w=>{var v;const _=a.current,y=_.getSnapshot();if(_.update(w),!c.current&&_.getSnapshot()!==y){const N=[];for(const[R,M]of Object.entries(w))ie(y,R)!==M&&N.push({path:R,value:M});N.length>0&&((v=f.current)==null||v.call(f,N))}},[]),j=u.useCallback(w=>a.current.get(w),[]),b=u.useCallback(()=>a.current.getSnapshot(),[]),S=u.useMemo(()=>({state:h,get:j,set:x,update:g,getSnapshot:b}),[h,j,x,g,b]);return r.jsx(la.Provider,{value:S,children:o})}function Qt(){const e=u.useContext(la);if(!e)throw new Error("useStateStore must be used within a StateProvider");return e}var da=u.createContext(null);function Sl({children:e}){const{state:t}=Qt(),n=u.useMemo(()=>({stateModel:t}),[t]),o=u.useMemo(()=>i=>Et(i,n),[n]),s=u.useMemo(()=>({isVisible:o,ctx:n}),[o,n]);return r.jsx(da.Provider,{value:s,children:e})}function Nl(){const e=u.useContext(da);if(!e)throw new Error("useVisibility must be used within a VisibilityProvider");return e}var ua=u.createContext(null);function _l(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const s of n){const i=e[s],a=t[s];if(i!==a){if(typeof i=="object"&&i!==null&&typeof a=="object"&&a!==null){const c=i.$state,d=a.$state;if(typeof c=="string"&&c===d)continue}return!1}}return!0}function El(e,t){if(e===t)return!0;if(e.validateOn!==t.validateOn)return!1;const n=e.checks??[],o=t.checks??[];if(n.length!==o.length)return!1;for(let s=0;s<n.length;s++){const i=n[s],a=o[s];if(i.type!==a.type||i.message!==a.message||!_l(i.args,a.args))return!1}return!0}function Tl({customFunctions:e={},children:t}){const{state:n,getSnapshot:o}=Qt(),[s,i]=u.useState({}),a=u.useRef({}),[c,d]=u.useState({}),l=u.useCallback((g,j)=>{d(b=>{const S=b[g];return S&&El(S,j)?b:{...b,[g]:j}})},[]),m=u.useCallback((g,j)=>{var v;const b=o(),S=g.split("/").filter(Boolean);let w=b;for(const N of S)if(w!=null&&typeof w=="object")w=w[N];else{w=void 0;break}const _=sl(j,{value:w,stateModel:b,customFunctions:e}),y={touched:((v=a.current[g])==null?void 0:v.touched)??!0,validated:!0,result:_};return a.current={...a.current,[g]:y},i(a.current),_},[e,o]),p=u.useCallback(g=>{var j,b;a.current={...a.current,[g]:{...a.current[g],touched:!0,validated:((j=a.current[g])==null?void 0:j.validated)??!1,result:((b=a.current[g])==null?void 0:b.result)??null}},i(a.current)},[]),h=u.useCallback(g=>{const{[g]:j,...b}=a.current;a.current=b,i(b)},[]),f=u.useCallback(()=>{let g=!0;for(const[j,b]of Object.entries(c))m(j,b).valid||(g=!1);return g},[c,m]),x=u.useMemo(()=>({customFunctions:e,get fieldStates(){return a.current},validate:m,touch:p,clear:h,validateAll:f,registerField:l}),[e,s,m,p,h,f,l]);return r.jsx(ua.Provider,{value:x,children:t})}function Al(){return u.useContext(ua)}var Vo=0;function Yo(){return Vo+=1,`${Date.now()}-${Vo}`}function ur(e,t){if(e==null)return e;if(e==="$id")return Yo();if(typeof e=="object"&&!Array.isArray(e)){const n=e,o=Object.keys(n);if(o.length===1&&typeof n.$state=="string")return t(n.$state);if(o.length===1&&"$id"in n)return Yo()}if(Array.isArray(e))return e.map(n=>ur(n,t));if(typeof e=="object"){const n={};for(const[o,s]of Object.entries(e))n[o]=ur(s,t);return n}return e}var pa=u.createContext(null);function Il({handlers:e={},navigate:t,children:n}){const{get:o,set:s,getSnapshot:i}=Qt(),a=Al(),[c,d]=u.useState(e),[l,m]=u.useState(new Set),[p,h]=u.useState(null),f=u.useCallback((S,w)=>{d(_=>({..._,[S]:w}))},[]),x=u.useCallback(async S=>{var R;const w=tl(S,i()),_=Xc(),y=Date.now();Vc({id:_,name:w.action,params:w.params,at:y});let v=!0,N;try{if(w.action==="setState"&&w.params){const z=w.params.statePath,L=w.params.value;z&&s(z,L);return}if(w.action==="pushState"&&w.params){const z=w.params.statePath,L=w.params.value;if(z){const O=ur(L,o),U=o(z)??[];s(z,[...U,O]);const E=w.params.clearStatePath;E&&s(E,"")}return}if(w.action==="removeState"&&w.params){const z=w.params.statePath,L=w.params.index;if(z!==void 0&&L!==void 0){const O=o(z)??[];s(z,O.filter((U,E)=>E!==L))}return}if(w.action==="push"&&w.params){const z=w.params.screen;if(z){const L=o("/currentScreen"),O=o("/navStack")??[];L?s("/navStack",[...O,L]):s("/navStack",[...O,""]),s("/currentScreen",z)}return}if(w.action==="pop"){const z=o("/navStack")??[];if(z.length>0){const L=z[z.length-1];s("/navStack",z.slice(0,-1)),L?s("/currentScreen",L):s("/currentScreen",void 0)}return}if(w.action==="validateForm"){const z=a==null?void 0:a.validateAll;if(!z){console.warn("validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.");return}const L=z(),O={};for(const[E,I]of Object.entries(a.fieldStates))I.result&&!I.result.valid&&(O[E]=I.result.errors);const U=((R=w.params)==null?void 0:R.statePath)||"/formValidation";s(U,{valid:L,errors:O});return}const M=c[w.action];if(!M){console.warn(`No handler registered for action: ${w.action}`);return}if(w.confirm)return new Promise((z,L)=>{h({action:w,handler:M,resolve:()=>{h(null),z()},reject:()=>{h(null),L(new Error("Action cancelled"))}})}).then(async()=>{m(z=>new Set(z).add(w.action));try{await Ho({action:w,handler:M,setState:s,navigate:t,executeAction:async z=>{await x({action:z})}})}finally{m(z=>{const L=new Set(z);return L.delete(w.action),L})}});m(z=>new Set(z).add(w.action));try{await Ho({action:w,handler:M,setState:s,navigate:t,executeAction:async z=>{await x({action:z})}})}finally{m(z=>{const L=new Set(z);return L.delete(w.action),L})}}catch(M){throw v=!1,N=M,M}finally{const M=Date.now();Yc({id:_,name:w.action,ok:v,at:M,durationMs:M-y,error:N})}},[c,o,s,i,t,a]),g=u.useCallback(()=>{p==null||p.resolve()},[p]),j=u.useCallback(()=>{p==null||p.reject()},[p]),b=u.useMemo(()=>({handlers:c,loadingActions:l,pendingConfirmation:p,execute:x,confirm:g,cancel:j,registerHandler:f}),[c,l,p,x,g,j,f]);return r.jsx(pa.Provider,{value:b,children:n})}function ma(){const e=u.useContext(pa);if(!e)throw new Error("useActions must be used within an ActionProvider");return e}function zl({confirm:e,onConfirm:t,onCancel:n}){const o=e.variant==="danger";return r.jsx("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:50},onClick:n,children:r.jsxs("div",{style:{backgroundColor:"white",borderRadius:"8px",padding:"24px",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1)"},onClick:s=>s.stopPropagation(),children:[r.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:600},children:e.title}),r.jsx("p",{style:{margin:"0 0 24px 0",color:"#6b7280"},children:e.message}),r.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[r.jsx("button",{onClick:n,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #d1d5db",backgroundColor:"white",cursor:"pointer"},children:e.cancelLabel??"Cancel"}),r.jsx("button",{onClick:t,style:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:o?"#dc2626":"#3b82f6",color:"white",cursor:"pointer"},children:e.confirmLabel??"Confirm"})]})]})})}var ha=u.createContext(null);function Ml({item:e,index:t,basePath:n,children:o}){return r.jsx(ha.Provider,{value:{item:e,index:t,basePath:n},children:o})}function Rl(){return u.useContext(ha)}var Pl=class extends u.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`[json-render] Rendering error in <${this.props.elementType}>:`,e,t.componentStack)}render(){return this.state.hasError?null:this.props.children}},fa={},ga=u.createContext(fa);function Ol(){return u.useContext(ga)}var xa=u.createContext(void 0);function $l(){return u.useContext(xa)}function Ll(){return u.useSyncExternalStore(Zc,Kc,()=>!1)}var ba=u.memo(function e({element:t,elementKey:n,spec:o,registry:s,loading:i,fallback:a}){var H;const c=Ll(),d=Rl(),{ctx:l}=Nl(),{execute:m}=ma(),{getSnapshot:p,state:h}=Qt(),f=Ol(),x=$l(),g=u.useMemo(()=>{const $=d?{...l,repeatItem:d.item,repeatIndex:d.index,repeatBasePath:d.basePath}:{...l};return $.functions=f,$.directives=x,$},[l,d,f,x]),j=t.visible===void 0?!0:Et(t.visible,g),b=t.on,S=u.useCallback(async $=>{const q=b==null?void 0:b[$];if(!q)return;const X=Array.isArray(q)?q:[q];for(const B of X){if(!B.params){await m(B);continue}const F={...g,stateModel:p()},Z={};for(const[re,ae]of Object.entries(B.params))Z[re]=$o(ae,F);await m({...B,params:Z})}},[b,m,g,p]),w=u.useCallback($=>{const q=b==null?void 0:b[$];if(!q)return{emit:()=>{},shouldPreventDefault:!1,bound:!1};const B=(Array.isArray(q)?q:[q]).some(F=>F.preventDefault);return{emit:()=>S($),shouldPreventDefault:B,bound:!0}},[b,S]),_=t.watch,y=u.useRef(null),v=u.useRef(void 0),N=u.useMemo(()=>{if(!_)return;const $={};for(const X of Object.keys(_))$[X]=ie(h,X);const q=v.current;if(q){const X=Object.keys($);if(X.length===Object.keys(q).length&&X.every(B=>$[B]===q[B]))return q}return v.current=$,$},[_,h]);if(u.useEffect(()=>{if(!_||!N)return;const $=Object.keys(_);if($.length===0)return;const q=y.current;if(y.current=N,q===null)return;let X=!1;return(async()=>{for(const B of $){if(X)break;if(N[B]!==q[B]){const F=_[B];if(!F)continue;const Z=Array.isArray(F)?F:[F];for(const re of Z){if(X)break;if(!re.params){if(await m(re),X)break;continue}const ae={...g,stateModel:p()},fe={};for(const[oe,ke]of Object.entries(re.params))fe[oe]=$o(ke,ae);if(await m({...re,params:fe}),X)break}}}})().catch(console.error),()=>{X=!0}},[_,N,m,g,p]),!j)return null;const R=t.props,M=qc(R,g),z=Bc(R,g),L=z!==t.props?{...t,props:z}:t,O=s[L.type]??a;if(!O)return console.warn(`No renderer for component type: ${L.type}`),null;const U=L.repeat?r.jsx(Dl,{element:L,spec:o,registry:s,loading:i,fallback:a}):(H=L.children)==null?void 0:H.map($=>{const q=o.elements[$];return q?r.jsx(e,{element:q,elementKey:$,spec:o,registry:s,loading:i,fallback:a},$):(i||console.warn(`[json-render] Missing element "${$}" referenced as child of "${L.type}". This element will not render.`),null)}),E=r.jsx(O,{element:L,emit:S,on:w,bindings:M,loading:i,children:U}),I=c&&n?r.jsx("span",{"data-jr-key":n,style:{display:"contents"},children:E}):E;return r.jsx(Pl,{elementType:L.type,children:I})});function Dl({element:e,spec:t,registry:n,loading:o,fallback:s}){const{state:i}=Qt(),a=e.repeat,c=a.statePath,d=ie(i,c)??[];return r.jsx(r.Fragment,{children:d.map((l,m)=>{var h;const p=a.key&&typeof l=="object"&&l!==null?String(l[a.key]??m):String(m);return r.jsx(Ml,{item:l,index:m,basePath:`${c}/${m}`,children:(h=e.children)==null?void 0:h.map(f=>{const x=t.elements[f];return x?r.jsx(ba,{element:x,elementKey:f,spec:t,registry:n,loading:o,fallback:s},f):(o||console.warn(`[json-render] Missing element "${f}" referenced as child of "${e.type}" (repeat). This element will not render.`),null)})},p)})})}function Fl({spec:e,registry:t,loading:n,fallback:o}){if(!e||!e.root)return null;const s=e.elements[e.root];return s?r.jsx(ba,{element:s,elementKey:e.root,spec:e,registry:t,loading:n,fallback:o}):null}function Hl({registry:e,store:t,initialState:n,handlers:o,navigate:s,validationFunctions:i,functions:a,directives:c,onStateChange:d,children:l}){const m=u.useMemo(()=>c?$c(c):void 0,[c]);return r.jsx(Cl,{store:t,initialState:n,onStateChange:d,children:r.jsx(Sl,{children:r.jsx(Tl,{customFunctions:i,children:r.jsx(Il,{handlers:o,navigate:s,children:r.jsx(ga.Provider,{value:a??fa,children:r.jsxs(xa.Provider,{value:m,children:[l,r.jsx(Wl,{})]})})})})})})}function Wl(){const{pendingConfirmation:e,confirm:t,cancel:n}=ma();return e!=null&&e.action.confirm?r.jsx(zl,{confirm:e.action.confirm,onConfirm:t,onCancel:n}):null}function Ul(e,t){const n={};if(t.components)for(const[a,c]of Object.entries(t.components))n[a]=({element:d,children:l,emit:m,on:p,bindings:h,loading:f})=>c({props:d.props,children:l,emit:m,on:p,bindings:h,loading:f});const o=t.actions?Object.entries(t.actions):[];return{registry:n,handlers:(a,c)=>{const d={};for(const[l,m]of o)d[l]=async p=>{const h=a(),f=c();h&&await m(p,h,f)};return d},executeAction:async(a,c,d,l={})=>{const m=o.find(([p])=>p===a);m?await m[1](c,d,l):console.warn(`Unknown action: ${a}`)}}}function Bl(e){if(typeof e!="object"||e===null)return!1;const t=e;switch(t.type){case"patch":return typeof t.patch=="object"&&t.patch!==null;case"flat":case"nested":return typeof t.spec=="object"&&t.spec!==null;default:return!1}}function ql(e){const t={root:"",elements:{}};let n=!1;for(const o of e)if(o.type===_c){if(!Bl(o.data))continue;const s=o.data;if(s.type==="patch")n=!0,jc(t,s.patch);else if(s.type==="flat")n=!0,Object.assign(t,s.spec);else if(s.type==="nested"){n=!0;const i=Cc(s.spec);Object.assign(t,i)}}return n?t:null}function Y(){const{dir:e}=C.useDocumentDir(),t=C.useConfig();return u.useMemo(()=>{const n=G.resolveLanguage(t.language);return{t:(s,i)=>G.getTranslation(s,n,t.translationOverrides,i),language:n,dir:G.isRtlLanguage(n)?"rtl":"ltr",hostDocumentDir:e}},[t.language,t.translationOverrides,e])}function wa(e){const t=G.resolveLanguage(e);return(n,o)=>G.getTranslation(n,t,void 0,o)}const Vl={t:wa("en"),anchorTarget:"_blank"},va=u.createContext(Vl);function Yl({host:e,children:t}){return r.jsx(va.Provider,{value:e,children:t})}function en(){return u.useContext(va)}function Xl({language:e,onUiAction:t,anchorTarget:n="_blank"}){return u.useMemo(()=>({t:wa(e),anchorTarget:n,onUiAction:t}),[e,n,t])}class Gl extends u.Component{constructor(){super(...arguments);Io(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){G.log.error("json-render: spec failed to render",{_e:n instanceof Error?n.message:String(n)})}componentDidUpdate(n){this.state.hasError&&n.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}render(){return this.state.hasError?null:this.props.children}}function Kl(e){if(!e.elements)return e;let t=!1;const n={};for(const[o,s]of Object.entries(e.elements)){const i=Zl(s,e);i!==s&&(t=!0),n[o]=i}return t?{...e,elements:n}:e}function Zl(e,t){if(e.type!=="List")return e;const n=e.repeat;if(!n||typeof n.statePath!="string")return e;const o=G.isRecord(e.props)?e.props:{},s=o.items;if(Array.isArray(s)&&s.length>0)return e;const a=ie(t.state??{},n.statePath);if(!Array.isArray(a)||a.length===0)return e;const{repeat:c,...d}=e;return{...d,props:{...o,items:a}}}function A(...e){return mc.twMerge(pc.clsx(e))}const Jl=u.lazy(()=>Promise.resolve().then(()=>require("./Chart.impl-BFdGxrv2.cjs")));function Ql(e){const t=e.height??220;return r.jsx(u.Suspense,{fallback:r.jsx(ed,{height:t}),children:r.jsx(Jl,{...e})})}function ed({height:e}){return r.jsx("div",{className:"w-full animate-pulse rounded-lg bg-muted-foreground/10",style:{height:e},"aria-hidden":!0})}const ya=k.z.object({title:k.z.string().nullish(),description:k.z.string().nullish()}),ka=k.z.object({direction:k.z.enum(["row","column"]).nullish(),gap:k.z.enum(["sm","md","lg"]).nullish(),align:k.z.enum(["start","center","end","stretch"]).nullish(),justify:k.z.enum(["start","center","end","between"]).nullish()}),ja=k.z.object({columns:k.z.union([k.z.literal(1),k.z.literal(2),k.z.literal(3)]).nullish(),gap:k.z.enum(["sm","md","lg"]).nullish()}),Ca=k.z.object({text:k.z.string(),level:k.z.union([k.z.literal(1),k.z.literal(2),k.z.literal(3),k.z.literal(4)]).nullish()}),Sa=k.z.object({text:k.z.string(),variant:k.z.enum(["body","caption","muted","code"]).nullish()}),Na=k.z.object({text:k.z.string(),variant:k.z.enum(["default","secondary","success","warning","destructive"]).nullish()}),td=new Set(["http:","https:","mailto:"]),nd=k.z.string().nullish().transform(e=>{if(!e)return null;try{return td.has(new URL(e).protocol)?e:null}catch{return null}}),_a=k.z.object({id:k.z.string().nullish(),label:k.z.string(),secondary:k.z.string().nullish(),badge:k.z.string().nullish(),status:k.z.enum(["success","warning","error","info","neutral"]).nullish(),href:nd}),Ea=k.z.object({items:k.z.array(_a),maxVisible:k.z.number().int().positive().nullish()}),rd=k.z.object({items:k.z.array(_a.extend({href:k.z.string().nullish()})),maxVisible:Ea.shape.maxVisible}),Ta=k.z.object({columns:k.z.array(k.z.string()),rows:k.z.array(k.z.array(k.z.string())),caption:k.z.string().nullish()}),od=k.z.object({value:k.z.string(),direction:k.z.enum(["up","down","flat"]),label:k.z.string().nullish()}),Aa=k.z.object({label:k.z.string(),value:k.z.string(),description:k.z.string().nullish(),trend:k.z.enum(["up","down","neutral"]).nullish(),delta:od.nullish()}),Ia=k.z.object({type:k.z.enum(["info","tip","warning","important"]).nullish(),title:k.z.string().nullish(),content:k.z.string()}),sd=k.z.object({label:k.z.string(),value:k.z.number()}),za=k.z.object({type:k.z.enum(["bar","line","pie"]),data:k.z.array(sd),title:k.z.string().nullish(),height:k.z.number().int().positive().nullish(),centerLabel:k.z.string().nullish()}),Ma=k.z.object({agentId:k.z.string(),agentName:k.z.string(),model:k.z.string().nullish()});function Ce(e,t,n){const o=e.safeParse(t);return o.success?o.data:n}const ad=yl(kl,{components:{Card:{props:ya,slots:["default"],description:"Container card with an optional title/description. Group related content.",example:{title:"Order summary",description:"Placed 2 days ago"}},Stack:{props:ka,slots:["default"],description:'Flex layout. Use direction="row" for side-by-side, "column" (default) to stack.'},Grid:{props:ja,slots:["default"],description:"Column grid that wraps on narrow screens. columns=2 for side-by-side metrics or cards; columns=3 only for three short metrics — the chat panel is about 400px wide, so three wide cells wrap."},Heading:{props:Ca,description:"Section heading. level 1 (largest) to 4.",example:{text:"Your orders",level:3}},Text:{props:Sa,description:'A paragraph of text. variant "muted"/"caption" for secondary text, "code" for monospace.'},Badge:{props:Na,description:"Small status pill. Use variant to convey state (success/warning/destructive).",example:{text:"Delivered",variant:"success"}},List:{props:rd,description:"A vertical list of items, each with a label and optional secondary text, badge, and status dot. Pass the full array in `items` — do NOT use repeat/state for the rows.",example:{items:[{label:"Order #1024",secondary:"Shipped",status:"success"},{label:"Order #1025",secondary:"Processing",status:"warning"}]}},Table:{props:Ta,description:"A data table. `columns` are header strings; `rows` is a 2D array of cell strings (each row same length as columns).",example:{columns:["Item","Qty","Price"],rows:[["Widget","2","$20"],["Gadget","1","$15"]]}},Metric:{props:Aa,description:"A single key figure (KPI / insight card) with a label, big value, optional description, trend arrow, and an optional period-over-period delta ({ value, direction, label }).",example:{label:"Total spent",value:"$1,240",description:"Last 30 days",trend:"up",delta:{value:"+8%",direction:"up",label:"vs previous 30d"}}},Callout:{props:Ia,description:"A highlighted info / tip / warning box for a single important note. Use for one call-out, not for long prose.",example:{type:"tip",title:"Heads up",content:"Free shipping over $50."}},PhoneAgentCard:{props:Ma,description:'A phone agent card with a "Test via web" action. NEVER author this yourself: it only comes back, already fenced, from the phone-agent tools — carry that fence verbatim.',example:{agentId:"00000000-0000-4000-8000-000000000000",agentName:"Support line",model:"oppie-vox-livekit"}},Chart:{props:za,description:"A bar, line, or pie (donut) chart. `data` is an array of { label, value } points. Choose by the question: line = trend over time, bar = comparison across categories, pie = share of a total (optional `centerLabel` shows a big number in the donut hole). Use for trends or distributions, not for a handful of numbers (use Metric for those). Colours, axes, legend, and tooltips are handled for you.",example:{type:"bar",title:"Orders per month",data:[{label:"Jan",value:12},{label:"Feb",value:18}]}}},actions:{}});function pr({height:e=64}){return r.jsx("div",{className:"w-full animate-pulse rounded-lg bg-muted-foreground/10",style:{height:e},"aria-hidden":!0})}const Xo={sm:"gap-1.5",md:"gap-3",lg:"gap-4"},id="10rem";function cd(e){return e===1?"minmax(0, 1fr)":`repeat(auto-fit, minmax(max(${id}, calc(100% / ${e} - 1rem)), 1fr))`}const{registry:Go}=Ul(ad,{components:{Card:({props:e,children:t,loading:n})=>{const o=Ce(ya,e,{});return r.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border border-muted-foreground/15 p-3",children:[(o.title||o.description)&&r.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.title&&r.jsx("div",{className:"text-sm font-semibold text-foreground",children:o.title}),o.description&&r.jsx("div",{className:"text-xs text-muted-foreground",children:o.description})]}),Gn(t,n)]})},Stack:({props:e,children:t,loading:n})=>{const o=Ce(ka,e,{}),s={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"}[o.align??"stretch"],i={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between"}[o.justify??"start"];return r.jsx("div",{className:A("flex",o.direction==="row"?"flex-row":"flex-col",Xo[o.gap??"md"],s,i),children:Gn(t,n)})},Grid:({props:e,children:t,loading:n})=>{const o=Ce(ja,e,{});return r.jsx("div",{className:A("grid",Xo[o.gap??"md"]),style:{gridTemplateColumns:cd(o.columns??1)},children:Gn(t,n)})},Heading:({props:e})=>{const t=Ce(Ca,e,{text:""}),n=t.level??3,o={1:"text-xl font-bold",2:"text-lg font-bold",3:"text-base font-semibold",4:"text-sm font-semibold"}[n]??"text-base font-semibold";return u.createElement(`h${n}`,{className:A("text-foreground",o)},t.text)},Text:({props:e})=>{const t=Ce(Sa,e,{text:""});if(t.variant==="code")return r.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:t.text});const n=t.variant==="muted"||t.variant==="caption";return r.jsx("p",{className:A("whitespace-pre-wrap",n?"text-xs text-muted-foreground":"text-sm text-foreground"),children:t.text})},Badge:({props:e})=>{const t=Ce(Na,e,{text:""}),n={default:"bg-primary text-primary-foreground",secondary:"bg-secondary text-secondary-foreground",success:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",warning:"bg-amber-500/15 text-amber-600 dark:text-amber-400",destructive:"bg-destructive/15 text-destructive"}[t.variant??"secondary"];return r.jsx("span",{className:A("inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium",n),children:t.text})},List:({props:e,loading:t})=>{const n=Ce(Ea,e,{items:[]});return n.items.length===0?t?r.jsx(pr,{}):r.jsx(Ko,{translationKey:"json_no_items"}):r.jsx(vd,{items:n.items,maxVisible:n.maxVisible})},Table:({props:e,loading:t})=>{const n=Ce(Ta,e,{columns:[],rows:[]});return t&&n.rows.length===0?r.jsx(pr,{}):n.columns.length===0?r.jsx(Ko,{translationKey:"json_no_data"}):r.jsx("div",{className:"overflow-x-auto rounded-lg border border-muted-foreground/15",children:r.jsxs("table",{className:"w-full text-sm",children:[n.caption&&r.jsx("caption",{className:"px-3 py-2 text-start text-xs text-muted-foreground",children:n.caption}),r.jsx("thead",{children:r.jsx("tr",{className:"border-b border-muted-foreground/15 bg-muted/40",children:n.columns.map((o,s)=>r.jsx("th",{className:"px-3 py-2 text-start font-medium text-foreground",children:o},s))})}),r.jsx("tbody",{children:n.rows.map((o,s)=>r.jsx("tr",{className:"border-b border-muted-foreground/10 last:border-0",children:o.map((i,a)=>r.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:i},a))},s))})]})})},Metric:({props:e})=>{const t=Ce(Aa,e,{label:"",value:""});return r.jsx(xd,{label:t.label,value:t.value,description:t.description,trend:t.trend,delta:t.delta})},Callout:({props:e})=>{const t=Ce(Ia,e,{content:""}),n=dd[t.type??"info"],o=n.Icon;return r.jsxs("div",{className:A("flex gap-2 rounded-lg border-l-2 p-3",n.cls),children:[r.jsx(o,{className:"mt-0.5 size-4 shrink-0"}),r.jsxs("div",{className:"flex flex-col gap-0.5",children:[t.title&&r.jsx("span",{className:"text-sm font-semibold",children:t.title}),r.jsx("span",{className:"text-sm",children:t.content})]})]})},PhoneAgentCard:({props:e})=>{const t=Ce(Ma,e,{agentId:"",agentName:""});return r.jsx(pd,{...t})},Chart:({props:e})=>{const t=Ce(za,e,{type:"bar",data:[]});return r.jsxs("div",{className:"flex flex-col gap-1",children:[t.title&&r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:t.title}),r.jsx(Ql,{...t})]})}}}),ld=({element:e})=>{const{t}=en();return r.jsx("div",{className:"rounded-lg border border-dashed border-muted-foreground/30 px-2 py-1.5 text-xs text-muted-foreground",children:t("json_unsupported",{type:e.type})})},dd={info:{Icon:T.Info,cls:"border-l-blue-500 bg-blue-500/5 text-foreground"},tip:{Icon:T.Lightbulb,cls:"border-l-emerald-500 bg-emerald-500/5 text-foreground"},warning:{Icon:T.AlertTriangle,cls:"border-l-amber-500 bg-amber-500/5 text-foreground"},important:{Icon:T.AlertCircle,cls:"border-l-red-500 bg-red-500/5 text-foreground"}};function Gn(e,t){return u.Children.toArray(e).length>0?e:t?r.jsx(pr,{}):null}function Ko({translationKey:e}){const{t}=en();return r.jsx("div",{className:"rounded-lg border border-muted-foreground/15 px-3 py-2 text-xs text-muted-foreground",children:t(e)})}const ud="oppie-vox-livekit";function pd({agentId:e,agentName:t,model:n}){const{t:o,onUiAction:s}=en(),i=!!s&&!!e&&n===ud;return r.jsxs("div",{className:"flex w-full flex-col gap-3 rounded-xl border border-muted-foreground/15 p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:r.jsx(T.Phone,{className:"size-4","aria-hidden":!0})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t}),r.jsx("div",{className:"text-xs text-muted-foreground",children:o("json_phone_agent")})]})]}),i&&r.jsxs("button",{type:"button",className:"flex w-full items-center justify-center gap-2 rounded-lg bg-secondary px-3 py-2 text-sm font-medium text-secondary-foreground hover:bg-secondary/80",onClick:()=>s==null?void 0:s({type:"test-phone-agent",payload:{agentId:e,model:n??null}}),children:[r.jsx(T.Play,{className:"size-4","aria-hidden":!0}),o("json_phone_agent_test")]})]})}const md={up:"↑",down:"↓",neutral:"→"},hd={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",neutral:"text-muted-foreground"},fd={up:"↑",down:"↓",flat:"→"},gd={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",flat:"text-muted-foreground"};function xd({label:e,value:t,description:n,trend:o,delta:s}){return r.jsxs("div",{className:"min-w-[140px] space-y-1 rounded-xl border border-muted-foreground/15 p-3",children:[r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:e}),r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsx("span",{className:"text-2xl font-medium tracking-tight text-foreground",children:t}),o?r.jsx("span",{className:A("text-sm font-medium",hd[o]),children:md[o]}):null]}),s?r.jsxs("div",{className:"flex items-baseline gap-1 text-xs",children:[r.jsxs("span",{className:A("font-medium",gd[s.direction]),children:[fd[s.direction]," ",s.value]}),s.label?r.jsx("span",{className:"text-muted-foreground",children:s.label}):null]}):null,n?r.jsx("span",{className:"block text-xs text-muted-foreground",children:n}):null]})}const bd={success:"bg-emerald-500",warning:"bg-amber-500",error:"bg-red-500",info:"bg-blue-500",neutral:"bg-muted-foreground/40"};function wd({item:e,showBadge:t,showSecondary:n,showStatus:o}){return r.jsxs(r.Fragment,{children:[t&&(e.badge?r.jsx("span",{className:"block min-w-0 truncate text-xs font-medium",title:e.badge,children:e.badge}):r.jsx("span",{})),r.jsx("span",{className:"block min-w-0 truncate",title:e.label,children:e.label}),n&&(e.secondary?r.jsx("span",{className:"block min-w-0 truncate text-xs text-muted-foreground",title:e.secondary,children:e.secondary}):r.jsx("span",{})),o&&(e.status?r.jsx("span",{className:A("size-2 rounded-full",bd[e.status]),"aria-hidden":!0}):r.jsx("span",{}))]})}function vd({items:e,maxVisible:t}){const n=t??10,{anchorTarget:o,t:s}=en(),[i,a]=u.useState(!1),c=e.length>n,d=i?e:e.slice(0,n),l=d.some(x=>!!x.badge),m=d.some(x=>!!x.secondary),p=d.some(x=>!!x.status),h=[l&&"auto","minmax(0,1fr)",m&&"minmax(0,2fr)",p&&"auto"].filter(Boolean).join(" "),f="grid min-w-0 grid-cols-[subgrid] col-span-full items-center gap-x-2.5 px-3 py-2 text-sm text-foreground";return r.jsxs("div",{className:"grid overflow-hidden rounded-lg border border-muted-foreground/15",style:{gridTemplateColumns:h},children:[d.map((x,g)=>{const j=x.id??`row-${g}`,b=r.jsx(wd,{item:x,showBadge:l,showSecondary:m,showStatus:p});return x.href?r.jsx("a",{href:x.href,target:o||"_top",rel:"noopener noreferrer",className:A(f,"transition-colors hover:bg-muted/50",g>0&&"border-t border-muted-foreground/10"),children:b},j):r.jsx("div",{className:A(f,g>0&&"border-t border-muted-foreground/10"),children:b},j)}),c&&r.jsx("button",{type:"button",className:"col-span-full flex w-full items-center justify-center gap-1 border-t border-muted-foreground/10 py-2 text-xs text-muted-foreground transition-colors hover:bg-muted/50",onClick:()=>a(x=>!x),children:i?r.jsxs(r.Fragment,{children:[r.jsx(T.ChevronUp,{className:"size-3"}),s("json_see_less")]}):r.jsxs(r.Fragment,{children:[r.jsx(T.ChevronDown,{className:"size-3"}),s("json_see_more",{count:e.length-n})]})})]})}function Ra({spec:e,active:t=!1}){const{anchorTarget:n,onUiAction:o}=C.useConfig(),{t:s}=Y(),i=u.useMemo(()=>({t:s,anchorTarget:n??"_blank",onUiAction:o}),[s,n,o]);return r.jsx(Pa,{spec:e,host:i,active:t})}function yd({spec:e,language:t,onUiAction:n,anchorTarget:o}){const s=Xl({language:t,onUiAction:n,anchorTarget:o});return r.jsx(Pa,{spec:e,host:s})}function Pa({spec:e,host:t,active:n=!1}){return r.jsx(Yl,{host:t,children:r.jsx(Gl,{resetKey:e,children:r.jsx(kd,{spec:e,active:n})})})}function kd({spec:e,active:t}){const n=u.useMemo(()=>e?Kl(e):null,[e]);return!n||!ia(n)?null:r.jsx(Hl,{registry:Go,initialState:n.state,children:r.jsx(Fl,{spec:n,registry:Go,loading:t,fallback:ld})})}function Oa(e){if(!e)return[];const t=e.split(`
|
|
12
|
-
`),n=[];let o=[],s=[],i=[],a=!1,c=!1;function d(){if(o.length===0)return;const p=o.join(`
|
|
13
|
-
`);p.trim()&&n.push({type:"markdown",content:p}),o=[]}function l(){if(s.length===0)return;let p=null;if(i.length>0)try{p=Sc(i.join(`
|
|
14
|
-
`),{root:"",elements:{}})}catch{}p&&jd(p)?(d(),n.push({type:"ui",spec:p})):o.push(...s),i=[],s=[]}function m(){c&&(l(),c=!1)}for(let p=0;p<t.length;p+=1){const h=t[p]??"",f=h.trim(),x=p===t.length-1;if(!a&&f==="```spec"){m(),a=!0,s=[h];continue}if(a&&f==="```"){s.push(h),l(),a=!1;continue}if(a){s.push(h),f!==""&&cr(h)&&i.push(h);continue}if(f!==""&&cr(h)){c=!0,s.push(h),i.push(h);continue}if(c){if(f===""||x&&Sd(f)){s.push(h);continue}m()}o.push(h)}return l(),d(),n}function jd(e){return ia(e)&&e.elements[e.root]!==void 0}const Cd='{"op":';function Sd(e){return!e.startsWith("{")||e.endsWith("}")?!1:/"op"\s*:/.test(e)?!0:Cd.startsWith(e.replace(/\s+/g,""))}function Nd(e){return ql(e)}function P(e){return{"data-component":e}}const mr=[{kind:"csv",label:"CSV",mimes:["text/csv","application/csv"],extensions:["csv"]},{kind:"excel",label:"Excel",mimes:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],extensions:["xls","xlsx"]}],_d=Object.fromEntries(mr.flatMap(e=>e.mimes.map(t=>[t,e.extensions.map(n=>`.${n}`)]))),Ed={"video/mp4":[".mp4"],"video/webm":[".webm"],"video/quicktime":[".mov"],"video/x-m4v":[".m4v"],"video/x-matroska":[".mkv"],"video/3gpp":[".3gp"]};function $a({type:e,name:t}){var s,i;const n=((s=t.split(".").pop())==null?void 0:s.toLowerCase())??"",o=((i=e.toLowerCase().split(";")[0])==null?void 0:i.trim())??"";return mr.find(a=>n&&a.extensions.includes(n))??mr.find(a=>o&&a.mimes.includes(o))??null}function Mn(){const[e]=u.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(hover: hover) and (pointer: fine)").matches);return e}const Tt={x:2,y:2},Oe=u.memo(u.forwardRef(({children:e,className:t,scale:n=1.02,off:o=!1},s)=>{const[i,a]=u.useState(!1),[c,d]=u.useState({x:0,y:0}),l=Mn(),m=W.useReducedMotion();if(o||!l||m)return u.cloneElement(e,{ref:s??e.props.ref});if(/translate/.test(e.props.className||""))return e;const h=j=>{var z,L;const{clientX:b,clientY:S}=j,w=j.currentTarget.getBoundingClientRect(),_=b-(w.left+w.width/2),y=S-(w.top+w.height/2),v=Math.max(-1,Math.min(1,_/(w.width/2))),N=Math.max(-1,Math.min(1,y/(w.height/2))),R=v*Tt.x,M=N*Tt.y;d({x:R,y:M}),(L=(z=e.props).onMouseMove)==null||L.call(z,j)},f=j=>{var b,S;a(!0),(S=(b=e.props).onMouseEnter)==null||S.call(b,j)},x=j=>{var b,S;a(!1),d({x:0,y:0}),(S=(b=e.props).onMouseLeave)==null||S.call(b,j)},g={"--wobble-x":i?`${c.x}px`:"0px","--wobble-y":i?`${c.y}px`:"0px","--scale":1-(n-1)};return u.cloneElement(e,{ref:s,onMouseMove:h,onMouseEnter:f,onMouseLeave:x,style:{...g,...e.props.style},className:A("translate-x-[var(--wobble-x)]","translate-y-[var(--wobble-y)]","hover:scale-[var(--scale)] active:hover:scale-[calc(var(--scale)-0.02)]",t,e.props.className,"transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)]")})}));Oe.displayName="Wobble";const ot=[.23,1,.32,1],Td=`cubic-bezier(${ot.join(", ")})`,ze={duration:.2,ease:ot},be={duration:.15,ease:ot},At={type:"spring",stiffness:500,damping:45,mass:1},Ad=[.32,.72,.24,1],Id=`cubic-bezier(${Ad.join(", ")})`,zd="0 2px 12px 0 rgba(0,0,0,0.18), 0 1px 4px 0 rgba(0,0,0,0), 0 0 0 1px rgba(255,255,255,0.08), inset 0 1px 0 0 rgba(255,255,255,0)",Md="0 8px 28px 0 rgba(0,0,0,0.10), 0 1px 4px 0 rgba(0,0,0,0), 0 0 0 1px rgba(0,0,0,0.05), inset 0 1px 0 0 rgba(255,255,255,0.5)",Rd="0 12px 40px 0 rgba(0,0,0,0.12), 0 2px 8px 0 rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.05), inset 0 1px 0 0 rgba(255,255,255,0.5)",Pd="0 24px 48px -16px rgba(0,0,0,0.18), 0 4px 16px 0 rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.05), inset 0 1px 0 0 rgba(255,255,255,0.5)",Od=10,$d=(e,t,n)=>({initial:{opacity:0,x:-e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...ze,delay:n}},exit:{opacity:0,x:e,...t.exit,transition:be},transition:ze}),Ld=(e,t,n)=>({initial:{opacity:0,x:e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...ze,delay:n}},exit:{opacity:0,x:-e,...t.exit,transition:be},transition:ze}),Dd=(e,t,n)=>({initial:{opacity:0,y:e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...ze,delay:n}},exit:{opacity:0,y:-e,...t.exit,transition:be},transition:ze}),Fd=(e,t,n)=>({initial:{opacity:0,y:-e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...ze,delay:n}},exit:{opacity:0,y:e,...t.exit,transition:be},transition:ze}),Hd={right:$d,left:Ld,up:Dd,down:Fd},ee=u.forwardRef(({fadeIn:e="down",distance:t=Od,children:n,snapExit:o=!1,overrides:s={},delay:i=0,...a},c)=>{const d=e?Hd[e](t,s,i):{};return o&&d.exit&&typeof d.exit=="object"&&!Array.isArray(d.exit)&&(d.exit.transition={duration:0}),r.jsx(W.motion.div,{ref:c,...a,...d,children:n})});ee.displayName="MotionDiv";const hr=Xs.cva(A("inline-flex shrink-0 items-center justify-center gap-2","text-sm font-medium whitespace-nowrap","ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","active:scale-[0.97] motion-reduce:active:scale-100","rounded-xl","transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)]"),{variants:{variant:{default:"bg-primary text-primary-foreground",destructive:"bg-destructive text-destructive-foreground",outline:"bg-background border",secondary:"bg-secondary text-secondary-foreground",ghost:"hover:bg-secondary",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"py-2 px-3.5 text-xs",lg:"min-h-12 px-4 rounded-[20px]",icon:"h-10 w-10",fit:"size-fit p-2",free:"p-2",selfless:"p-0"}},defaultVariants:{variant:"default",size:"default"}}),V=rt.forwardRef(({className:e,variant:t="default",size:n,asChild:o=!1,wobble:s=!0,...i},a)=>{const c=o?hc.Slot:"button";return r.jsx(Oe,{ref:a,off:!s,children:r.jsx(c,{...P("ui_lib/btn"),"data-variant":t,className:A(hr({variant:t,size:n,className:e})),...i})})});V.displayName="Button";const La=u.createContext(null);function Wd({children:e}){const[t,n]=u.useState(!1),[o,s]=u.useState(null),i=c=>{s(c),n(!0)},a=u.useCallback(()=>{n(!1),setTimeout(()=>{s(null)},200)},[]);return r.jsxs(La.Provider,{value:{open:i,close:a,isOpen:t,content:o},children:[r.jsx(Ud,{}),e]})}function Rn(){const e=u.useContext(La);return e||(G.log.error("useDialoger must be used within a DialogerProvider"),{open:()=>{},close:()=>{},isOpen:!1,content:null})}function Ud(){const{contentIframeRef:e}=C.useWidget(),{isOpen:t,content:n,close:o}=Rn();return u.useEffect(()=>{var a,c;if(!t)return;const s=d=>{d.defaultPrevented||d.key!=="Escape"||(d.preventDefault(),o())},i=(c=(a=e==null?void 0:e.current)==null?void 0:a.contentWindow)==null?void 0:c.document;return i==null||i.addEventListener("keydown",s),()=>i==null?void 0:i.removeEventListener("keydown",s)},[o,e,t]),r.jsx(W.AnimatePresence,{mode:"wait",children:t&&n&&r.jsx(ee,{overrides:{initial:{y:0},exit:{y:0}},className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",tabIndex:-1,onClick:o,children:n},"dialog-content")})}function tn({children:e,className:t,withClose:n=!1}){const{close:o}=Rn(),{t:s}=Y();return r.jsxs("div",{"data-opencx-escape-scope":!0,className:A("fixed left-[50%] top-[50%] z-50 flex flex-col gap-4 w-full max-w-[61.8%] translate-x-[-50%] translate-y-[-50%] border bg-background p-4 rounded-3xl",t),onClick:i=>i.stopPropagation(),children:[e,n&&r.jsxs(V,{size:"fit",className:"rounded-full absolute top-4 right-4 opacity-50 hover:opacity-100",onClick:o,children:[r.jsx(T.X,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:s("dialog_close")})]})]})}const Ur=({className:e,...t})=>r.jsx("div",{className:A("flex flex-col gap-2 text-center pt-2",e),...t});Ur.displayName="DialogerHeader";const Br=({className:e,...t})=>r.jsx("div",{className:A("flex flex-col gap-2 text-center",e),...t});Br.displayName="DialogerBody";const Da=({className:e,...t})=>r.jsx("div",{className:A("flex flex-col gap-2",e),...t});Da.displayName="DialogerFooter";const qr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:A("text-lg font-semibold leading-none tracking-tight",e),...t}));qr.displayName="DialogerTitle";const Vr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Vr.displayName="DialogerDescription";function nn({children:e,trigger:t}){const{open:n}=Rn();return u.cloneElement(t,{onClick:()=>{var s,i;n(e),(i=(s=t.props).onClick)==null||i.call(s)}})}const Zo=1,Jo=5,Qo=.5,Bd=2.5;function qd(e,t,n,o){if(!n||!o||t<=1)return{x:0,y:0};const s=n.getBoundingClientRect(),i=o.offsetWidth,a=o.offsetHeight,c=Math.max(0,(i*t-s.width)/(2*t)),d=Math.max(0,(a*t-s.height)/(2*t));return{x:Math.min(c,Math.max(-c,e.x)),y:Math.min(d,Math.max(-d,e.y))}}function Fa({src:e,alt:t}){const{t:n}=Y(),[o,s]=u.useState(1),[i,a]=u.useState({x:0,y:0}),[c,d]=u.useState(!1),l=u.useRef({x:0,y:0}),m=u.useRef({x:0,y:0}),p=u.useRef(null),h=u.useRef(null),f=u.useRef(!1),x=v=>Math.min(Jo,Math.max(Zo,v)),g=u.useCallback(()=>{s(1),a({x:0,y:0})},[]),j=u.useCallback(()=>{s(v=>x(v+Qo))},[]),b=u.useCallback(()=>{s(v=>{const N=x(v-Qo);return N<=1&&a({x:0,y:0}),N})},[]),S=u.useCallback(v=>{v.preventDefault(),f.current=!1,d(!0),l.current={x:v.clientX,y:v.clientY},m.current={...i},v.target.setPointerCapture(v.pointerId)},[i]),w=u.useCallback(v=>{if(!c)return;const N=v.clientX-l.current.x,R=v.clientY-l.current.y;if((Math.abs(N)>3||Math.abs(R)>3)&&(f.current=!0),o<=1)return;const M={x:m.current.x+N/o,y:m.current.y+R/o};a(qd(M,o,p.current,h.current))},[c,o]),_=u.useCallback(()=>{const v=f.current;d(!1),!v&&s(N=>N>1?(a({x:0,y:0}),1):Bd)},[]),y=o>1;return r.jsxs("div",{className:"relative size-full flex items-center justify-center select-none",onClick:v=>v.stopPropagation(),children:[r.jsx("div",{ref:p,className:A("overflow-hidden max-h-full max-w-full rounded-2xl flex items-center justify-center",y&&"size-full"),onPointerDown:S,onPointerMove:w,onPointerUp:_,onPointerCancel:_,style:{cursor:c?"grabbing":y?"grab":"zoom-in",touchAction:"none"},children:r.jsx("img",{ref:h,src:e,alt:t,className:"block max-w-full object-contain pointer-events-none",draggable:!1,style:{maxHeight:"100vh",transform:`scale(${o}) translate(${i.x}px, ${i.y}px)`,transformOrigin:"center center"}})}),r.jsxs("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1 bg-black/60 backdrop-blur-sm rounded-full px-1.5 py-1 transition opacity-50 hover:opacity-100",children:[r.jsx(Kn,{onClick:b,label:n("zoom_out"),disabled:o<=Zo,children:r.jsx(T.ZoomOut,{className:"size-3.5"})}),r.jsxs("span",{className:"text-white text-xs font-medium min-w-[3ch] text-center tabular-nums",children:[Math.round(o*100),"%"]}),r.jsx(Kn,{onClick:j,label:n("zoom_in"),disabled:o>=Jo,children:r.jsx(T.ZoomIn,{className:"size-3.5"})}),y&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-px h-4 bg-white/30 mx-0.5"}),r.jsx(Kn,{onClick:g,label:n("reset_zoom"),children:r.jsx(T.RotateCcw,{className:"size-3.5"})})]})]})]})}function Kn({onClick:e,label:t,children:n,disabled:o}){return r.jsx("button",{onClick:e,"aria-label":t,disabled:o,className:"text-white/80 hover:text-white disabled:text-white/30 disabled:hover:bg-transparent p-1.5 rounded-full hover:bg-white/15 transition-colors",children:n})}function es({url:e,name:t,size:n,icon:o,label:s}){return r.jsx(Oe,{children:r.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:A("block size-fit max-w-[min(100%,16rem)] shrink-0 rounded-2xl border","bg-background/80 transition-colors hover:bg-accent/60","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),children:r.jsxs("div",{className:"flex items-center gap-3 p-3 min-w-0",children:[r.jsx("div",{className:A("flex size-10 shrink-0 items-center justify-center rounded-xl","bg-secondary text-muted-foreground"),"aria-hidden":!0,children:o}),r.jsxs("div",{className:"min-w-0 flex-1 flex flex-col gap-0.5 text-left",children:[r.jsx("span",{className:A("text-xs font-medium text-foreground line-clamp-1","break-words [word-break:break-word]"),children:t}),r.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[(n/1024).toFixed(2)," KB · ",s]})]})]})})})}function Ha({attachment:e}){const{name:t,size:n,type:o,url:s}=e,i=o.startsWith("image/"),a=o.startsWith("video/"),c=o.startsWith("audio/"),d=o==="application/pdf";if(c)return r.jsx(Oe,{children:r.jsx("div",{className:"w-full shrink-0 overflow-hidden",children:r.jsxs("audio",{controls:!0,className:"w-full",children:[r.jsx("source",{src:s,type:o}),"Your browser does not support the audio tag."]})})});if(a)return r.jsx(Oe,{children:r.jsx("div",{className:"w-full border shrink-0 rounded-2xl overflow-hidden",children:r.jsxs("video",{controls:!0,children:[r.jsx("source",{src:s,type:o}),"Your browser does not support the video tag."]})})});if(i)return r.jsx(nn,{trigger:r.jsx("div",{children:r.jsx(Oe,{children:r.jsx("div",{className:"size-fit border shrink-0 rounded-2xl overflow-hidden",children:r.jsx("img",{src:s,className:"object-cover size-16",alt:t})})})}),children:r.jsx(tn,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(Fa,{src:s,alt:t})})});if(d)return r.jsx(es,{url:s,name:t,size:n,icon:r.jsx(T.FileText,{className:"size-5",strokeWidth:1.75}),label:"PDF"});const l=$a({type:o,name:t});return l?r.jsx(es,{url:s,name:t,size:n,icon:r.jsx(T.FileSpreadsheet,{className:"size-5",strokeWidth:1.75}),label:l.label}):r.jsx(Oe,{children:r.jsx("div",{className:"size-fit border shrink-0 rounded-2xl overflow-hidden",children:r.jsxs("div",{className:"flex items-end gap-2 p-2",children:[r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:A("text-xs text-blue-500 line-clamp-2 underline hover:text-blue-600","break-words [word-break:break-word]"),children:t}),r.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[(n/1024).toFixed(2)," KB"]})]})})})}function Vd({replyTo:e}){const t=C.useBot(),{humanAgent:n}=C.useConfig(),{sender:o}=e,s=o.kind==="user"?"You":o.kind==="ai"?t.name:o.kind==="agent"?(n==null?void 0:n.name)||o.name||"Team":o.name;return r.jsxs("button",{...P("chat/agent_msg/reply_to"),type:"button",onClick:i=>{const a=i.currentTarget.ownerDocument.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);a==null||a.scrollIntoView({behavior:"smooth",block:"center"}),a==null||a.animate([{opacity:.35},{opacity:1}],{duration:900,easing:"ease-out"})},className:A("not-prose mb-2 block w-full min-w-0 text-start","rounded-xl border-s-2 border-primary/50 bg-primary/[0.07] ps-2.5 pe-2 py-1.5","text-xs leading-snug text-muted-foreground","transition-colors hover:bg-primary/10 hover:text-foreground"),children:[s&&r.jsx("span",{className:"block font-medium text-foreground/80",children:s}),r.jsx("span",{className:"line-clamp-2 break-words",children:e.text})]})}const Wa=u.memo(fc,(e,t)=>e.children===t.children&&e.className===t.className);var Hs,Ws,Us;const Yd={...ve.defaultSchema,attributes:{...ve.defaultSchema.attributes,"*":[...((Hs=ve.defaultSchema.attributes)==null?void 0:Hs["*"])??[],"style"],code:[...((Ws=ve.defaultSchema.attributes)==null?void 0:Ws.code)??[],"className"],pre:[...((Us=ve.defaultSchema.attributes)==null?void 0:Us.pre)??[],"className"]}},Xd=/^(color|background-color|font-(family|size|style|weight)|text-(align|decoration|transform)|line-height|letter-spacing|white-space|display|width|height|max-width|min-width|margin(-top|-right|-bottom|-left)?|padding(-top|-right|-bottom|-left)?|border(-width|-style|-color|-radius)?)$/i,Gd=/^[\w\s#.,%()'"+-]+$/,Kd=/\b(url|expression|var|attr)\s*\(/i;function Zd(){return function e(t){var o,s;const n=(o=t.properties)==null?void 0:o.style;typeof n=="string"&&t.properties&&(t.properties.style=n.split(";").filter(i=>{const a=i.indexOf(":");if(a<0)return!1;const c=i.slice(0,a).trim(),d=i.slice(a+1).trim();return Xd.test(c)&&Gd.test(d)&&!Kd.test(d)}).join(";")),(s=t.children)==null||s.forEach(e)}}function Ua(e){return e.replace(/<citations>[\s\S]*?<\/citations>/g,"").replace(/<citations[\s\S]*$/,"").replace(/<(?:ref|cite)\s[^>]*?\/?>/g,"").replace(/<r(?:e(?:f[^>]*)?)?$/,"").replace(/<c(?:i(?:t(?:a(?:t(?:i(?:o(?:n(?:s)?)?)?)?)?)?(?:e[^>]*)?)?)?$/,"").trimEnd()}const Jd=/^[\w-]{11}$/,Qd=new Set(["youtube.com","www.youtube.com","m.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com"]);function eu(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const n=tu(t);return n&&Jd.test(n)?n:null}function tu(e){const[t,n]=e.pathname.split("/").filter(Boolean);return e.hostname==="youtu.be"?t:Qd.has(e.hostname)?t==="watch"?e.searchParams.get("v"):t==="shorts"||t==="embed"?n:null:null}function nu({id:e,title:t}){return r.jsx(nn,{trigger:r.jsxs("button",{type:"button",className:"not-prose relative block w-full max-w-64 overflow-hidden rounded-xl border",children:[r.jsx("img",{src:`https://i.ytimg.com/vi/${e}/hqdefault.jpg`,alt:t,className:"aspect-video w-full object-cover"}),r.jsx("span",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx("span",{className:"flex size-10 items-center justify-center rounded-full bg-black/60 text-white",children:r.jsx(T.Play,{className:"size-5 fill-current"})})})]}),children:r.jsx(tn,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx("iframe",{src:`https://www.youtube-nocookie.com/embed/${e}?autoplay=1`,title:t,allow:"autoplay; encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0,className:"aspect-video w-full rounded-2xl"})})})}const ru=new Map([["youtube",/^[\w-]{11}$/],["vimeo",/^\d+(?:\/[\da-f]+)?$/],["loom",/^[\da-f]{32}$/],["wistia",/^[\da-z]{10}$/]]),ou=new Map([["youtube","YouTube video"],["vimeo","Vimeo video"],["loom","Loom video"],["wistia","Wistia video"]]);function su(e,t){var o;if(typeof e!="string"||typeof t!="string"||!((o=ru.get(e))!=null&&o.test(t)))return;const n=ou.get(e)??"Video";switch(e){case"youtube":return{src:`https://www.youtube-nocookie.com/embed/${t}`,title:n};case"vimeo":{const[s,i]=t.split("/");return{src:`https://player.vimeo.com/video/${s}${i?`?h=${i}`:""}`,title:n}}case"loom":return{src:`https://www.loom.com/embed/${t}`,title:n};case"wistia":return{src:`https://fast.wistia.net/embed/iframe/${t}`,title:n};default:return}}var Bs,qs;const fr={...ve.defaultSchema,attributes:{...ve.defaultSchema.attributes,code:[...((Bs=ve.defaultSchema.attributes)==null?void 0:Bs.code)??[],"className"],pre:[...((qs=ve.defaultSchema.attributes)==null?void 0:qs.pre)??[],"className"]}};var Vs,Ys;const au={...fr,attributes:{...fr.attributes,div:[...((Vs=ve.defaultSchema.attributes)==null?void 0:Vs.div)??[],"dataEmbed","dataEmbedId"],a:[...((Ys=ve.defaultSchema.attributes)==null?void 0:Ys.a)??[],"dataArticleSlug"]}};function Yr(e){return r.jsx(Xr,{...e})}function iu({openArticle:e,...t}){return r.jsx(Xr,{...t,articleEmbeds:!0,openArticle:e})}function cu(e){return r.jsx(Xr,{...e,configuredStyles:!0})}function Xr({children:e,messageType:t,messageId:n,configuredStyles:o=!1,articleEmbeds:s=!1,openArticle:i}){const{anchorTarget:a}=C.useConfig();return r.jsx(Wa,{"data-type":t,"data-id":n,remarkPlugins:[Gs],rehypePlugins:o?[ar,Zd,[ve,Yd]]:[ar,[ve,s?au:fr]],components:{div:({node:c,...d})=>{const l=s?su(c==null?void 0:c.properties.dataEmbed,c==null?void 0:c.properties.dataEmbedId):void 0;return l?r.jsx("iframe",{src:l.src,title:l.title,loading:"lazy",allow:"encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0,className:"not-prose my-4 aspect-video w-full rounded-xl border"}):r.jsx("div",{...d})},a:({node:c,children:d,...l})=>{const{href:m}=l,p=s?c==null?void 0:c.properties.dataArticleSlug:void 0;if(typeof p=="string")return i?r.jsx("a",{href:"#",onClick:f=>{f.preventDefault(),i(p)},children:d}):r.jsx(r.Fragment,{children:d});const h=m?eu(m):null;return m&&h?r.jsx(nu,{id:h,title:typeof d=="string"?d:m}):r.jsx("a",{target:l.target||a||"_top",...l,children:d})},img:({src:c,alt:d,...l})=>c?r.jsx(nn,{trigger:r.jsx("img",{src:c,alt:d,...l,className:"cursor-pointer rounded-xl"}),children:r.jsx(tn,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(Fa,{src:c,alt:d})})}):r.jsx("img",{src:c,alt:d,...l})},children:Ua(e)})}function Be(){const{widgetCtx:{org:e}}=C.useWidget(),{sessionState:{session:t}}=C.useSessions(),n=C.useConfig(),{messagesState:{messages:o}}=C.useMessages(),{routerState:{screen:s}}=C.useWidgetRouter();return{react:u,org:e,session:t,config:n,messages:o,currentScreen:s}}function lu({currentMessage:e}){var o;const t=Be(),n=(o=t.config.customComponents)==null?void 0:o["message::after"];return n?r.jsx(n,{...t,currentMessage:e}):null}const Ba=u.createContext(null);function du({children:e}){const{widgetCtx:t,config:n}=C.useWidget(),o=u.useRef({widgetCtx:t,config:n});u.useLayoutEffect(()=>{o.current={widgetCtx:t,config:n}},[t,n]);const s=u.useRef({kind:"main"}),i=u.useMemo(()=>({report:a=>{var x;const{widgetCtx:c,config:d}=o.current,l=(x=d.hooks)==null?void 0:x.onUserActivity;if(!l)return;const{screen:m}=c.routerCtx.state.get(),p=m==="home"?{screen:m,view:s.current}:{screen:m},{session:h}=c.sessionCtx.sessionState.get(),f=h?{...a,session:h,page:p}:{...a,page:p};try{l(f)}catch(g){G.log.error("onUserActivity hook failed",g)}},setHomeView:a=>{s.current=a}}),[]);return r.jsx(Ba.Provider,{value:i,children:e})}function Gr(){return u.useContext(Ba)}function Kr(e){var n;const t=(n=Gr())==null?void 0:n.setHomeView;u.useLayoutEffect(()=>{t==null||t(e)},[t,e])}function rn(){var n;const{sendMessage:e}=C.useMessages(),t=(n=Gr())==null?void 0:n.report;return u.useCallback(o=>e(t?{...o,onSubmitted:s=>{var i;(i=o.onSubmitted)==null||i.call(o,s),t({type:"message-sent",message:s})}}:o),[e,t])}function uu({messageId:e,messageOptions:t}){var d;const{messagesState:n}=C.useMessages(),o=rn(),{sessionState:s}=C.useSessions(),{pickedOptionId:i}=t,a=((d=G.tappableOptionsMessage(n.messages,s.session))==null?void 0:d.id)===e,c=t.options.find(l=>l.id===i);return c?r.jsx("div",{...P("chat/agent_msg/options"),className:"flex",children:r.jsxs(V,{...P("chat/agent_msg/option_btn"),"data-picked":!0,"aria-pressed":!0,size:"sm",variant:"outline",className:"w-fit pl-2 text-sm text-muted-foreground disabled:opacity-100",disabled:!0,children:[r.jsx(T.CheckIcon,{"aria-hidden":"true",className:"size-3.5 shrink-0"}),c.label]})}):a?r.jsx("div",{...P("chat/agent_msg/options"),role:"group",className:"flex flex-row flex-wrap gap-1.5 [@media(pointer:coarse)]:gap-y-3",children:t.options.map(l=>r.jsxs(V,{...P("chat/agent_msg/option_btn"),size:"sm",variant:"outline",className:"relative w-fit text-sm hover:bg-secondary",onClick:()=>o({content:l.label,optionReply:{messageId:e,optionId:l.id}}),children:[r.jsx("span",{"aria-hidden":"true",className:"absolute top-1/2 left-1/2 size-[max(100%,3rem)] -translate-x-1/2 -translate-y-1/2 [@media(pointer:fine)]:hidden"}),l.label]},l.id))}):null}const pu=["[--tw-prose-body:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-headings:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-lead:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-bold:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-links:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-code:hsl(var(--opencx-secondary-foreground))]","[--tw-prose-counters:hsl(var(--opencx-muted-foreground))]","[--tw-prose-bullets:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quotes:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quote-borders:hsl(var(--opencx-border))]","[--tw-prose-hr:hsl(var(--opencx-border))]","[--tw-prose-th-borders:hsl(var(--opencx-border))]","[--tw-prose-td-borders:hsl(var(--opencx-border))]","[--tw-prose-pre-bg:hsl(var(--opencx-muted))]","[--tw-prose-pre-code:hsl(var(--opencx-foreground))]"].join(" ");function gr(e){const{data:t,id:n,type:o,attachments:s,isFirstInGroup:i,isLastInGroup:a,isAloneInGroup:c,dataComponentNames:d,classNames:l}=e,m=o==="AI"||o==="AGENT"?t.message:"",p=u.useMemo(()=>o==="AI"?Oa(m):null,[o,m]);if(o!=="AI"&&o!=="AGENT")return null;const{variant:h="default"}=t,f=e.replyTo?r.jsx(Vd,{replyTo:e.replyTo}):null,x=(S,w,_=!0,y=!0)=>r.jsxs("div",{className:"flex flex-row gap-2",children:[r.jsxs("div",{...P((d==null?void 0:d.message)??"chat/agent_msg/msg"),"data-first":i,"data-last":a,"data-alone":c,"data-variant":h,className:A("transition-all","w-fit py-3 px-4 rounded-3xl bg-secondary text-secondary-foreground","leading-snug text-sm prose prose-sm prose-a:decoration-primary prose-a:underline",pu,"break-words [word-break:break-word]",h==="error"&&"bg-destructive/15 text-destructive",i&&!c&&"rounded-bl-md",a&&!c&&"rounded-tl-md",!i&&!a&&!c&&"rounded-l-md",l==null?void 0:l.message),children:[y&&f,r.jsx(Yr,{messageType:o,messageId:n,children:S})]}),_&&r.jsx(lu,{currentMessage:e})]},w),g=(p==null?void 0:p.some(S=>S.type==="ui"))??!1,j=(p==null?void 0:p.reduce((S,w,_)=>w.type==="markdown"?_:S,-1))??-1,b=(p==null?void 0:p.findIndex(S=>S.type==="markdown"))??-1;return r.jsxs("div",{...P((d==null?void 0:d.messageContainer)??"chat/agent_msg/root"),"data-message-id":n,className:A("w-5/6 flex flex-col items-start gap-1",l==null?void 0:l.messageContainer),children:[s&&s.length>0&&r.jsx("div",{className:"w-full gap-1 flex flex-row flex-wrap items-center justify-start",children:s==null?void 0:s.map(S=>r.jsx(Ha,{attachment:S},S.id))}),g&&p?p.map((S,w)=>S.type==="markdown"?x(S.content,`md-${w}`,w===j,w===b):r.jsx("div",{className:"w-full",children:r.jsx(Ra,{spec:S.spec})},`ui-${w}`)):m.length>0&&x(m),e.messageOptions&&r.jsx(uu,{messageId:n,messageOptions:e.messageOptions})]})}function mu(e){return r.jsx("div",{className:"w-full max-w-full overflow-auto shrink-0",children:r.jsx("pre",{className:"text-xs leading-tight whitespace-pre-wrap break-word",children:JSON.stringify(e,null,1)})})}const Zr=rt.forwardRef(({className:e,...t},n)=>r.jsx(Mt.Root,{ref:n,className:A("relative flex size-6 aspect-square shrink-0 overflow-hidden rounded-full bg-secondary",e),...t}));Zr.displayName=Mt.Root.displayName;const Jr=rt.forwardRef(({className:e,...t},n)=>r.jsx(Mt.Image,{ref:n,className:A("aspect-square h-full w-full",e),...t}));Jr.displayName=Mt.Image.displayName;const Qr=rt.forwardRef(({className:e,...t},n)=>r.jsx(Mt.Fallback,{ref:n,className:A("flex size-full text-xs items-center justify-center rounded-lg",e),...t}));Qr.displayName=Mt.Fallback.displayName;function xr({agent:e,...t}){var n,o;return r.jsxs(Zr,{...t,children:[r.jsx(Jr,{src:(e==null?void 0:e.avatarUrl)||(e==null?void 0:e.avatar)||"",alt:"Agent Icon"}),(e==null?void 0:e.name)&&r.jsx(Qr,{children:(o=(n=e==null?void 0:e.name)==null?void 0:n.slice(0,1))==null?void 0:o.toUpperCase()})]})}function hu({agent:e}){return r.jsx(W.AnimatePresence,{children:r.jsxs(ee,{...P("chat/bot_loading/root"),className:"flex flex-row items-end w-full gap-2 animate-pulse",children:[r.jsx(xr,{agent:e}),r.jsxs("div",{...P("chat/bot_loading/bouncing_dots_container"),className:A("flex items-center [&_span]:bg-secondary-foreground [&_span]:size-1 gap-1 p-2 rounded-xl bg-secondary"),children:[r.jsx(W.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.3s]"}),r.jsx(W.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.15s]"}),r.jsx(W.motion.span,{className:"rounded-full animate-bounce"})]})]})})}const fu='*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}*{-ms-overflow-style:none;scrollbar-width:none}*::-webkit-scrollbar{display:none}*{border-color:hsl(var(--opencx-border))}.\\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\\!container{max-width:1536px!important}.container{max-width:1536px}}.prose{color:var(--tw-prose-body);max-width:65ch}.prose :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-lead);font-size:1.25em;line-height:1.6;margin-top:1.2em;margin-bottom:1.2em}.prose :where(a):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-links);text-decoration:underline;font-weight:500}.prose :where(strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.prose :where(a strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(blockquote strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(thead th strong):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal;margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em}.prose :where(ol[type=A]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=A s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-alpha}.prose :where(ol[type=a s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-alpha}.prose :where(ol[type=I]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type=I s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:upper-roman}.prose :where(ol[type=i s]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:lower-roman}.prose :where(ol[type="1"]):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:decimal}.prose :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){list-style-type:disc;margin-top:1.25em;margin-bottom:1.25em;padding-inline-start:1.625em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{font-weight:400;color:var(--tw-prose-counters)}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.prose :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.25em}.prose :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.prose :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:500;font-style:italic;color:var(--tw-prose-quotes);border-inline-start-width:.25rem;border-inline-start-color:var(--tw-prose-quote-borders);quotes:"“""”""‘""’";margin-top:1.6em;margin-bottom:1.6em;padding-inline-start:1em}.prose :where(blockquote p:first-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:open-quote}.prose :where(blockquote p:last-of-type):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:close-quote}.prose :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:800;font-size:2.25em;margin-top:0;margin-bottom:.8888889em;line-height:1.1111111}.prose :where(h1 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:900;color:inherit}.prose :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:700;font-size:1.5em;margin-top:2em;margin-bottom:1em;line-height:1.3333333}.prose :where(h2 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:800;color:inherit}.prose :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;font-size:1.25em;margin-top:1.6em;margin-bottom:.6em;line-height:1.6}.prose :where(h3 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:700;color:inherit}.prose :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.5em;margin-bottom:.5em;line-height:1.5}.prose :where(h4 strong):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:700;color:inherit}.prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){display:block;margin-top:2em;margin-bottom:2em}.prose :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){font-weight:500;font-family:inherit;color:var(--tw-prose-kbd);box-shadow:0 0 0 1px rgb(var(--tw-prose-kbd-shadows) / 10%),0 3px rgb(var(--tw-prose-kbd-shadows) / 10%);font-size:.875em;border-radius:.3125rem;padding-top:.1875em;padding-inline-end:.375em;padding-bottom:.1875em;padding-inline-start:.375em}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-code);font-weight:600;font-size:.875em}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:"`"}.prose :where(code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:"`"}.prose :where(a code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h1 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.875em}.prose :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit;font-size:.9em}.prose :where(h4 code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(blockquote code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(thead th code):not(:where([class~=not-prose],[class~=not-prose] *)){color:inherit}.prose :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);overflow-x:auto;font-weight:400;font-size:.875em;line-height:1.7142857;margin-top:1.7142857em;margin-bottom:1.7142857em;border-radius:.375rem;padding-top:.8571429em;padding-inline-end:1.1428571em;padding-bottom:.8571429em;padding-inline-start:1.1428571em}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)){background-color:transparent;border-width:0;border-radius:0;padding:0;font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):before{content:none}.prose :where(pre code):not(:where([class~=not-prose],[class~=not-prose] *)):after{content:none}.prose :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){width:100%;table-layout:auto;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.7142857}.prose :where(thead):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.prose :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;vertical-align:bottom;padding-inline-end:.5714286em;padding-bottom:.5714286em;padding-inline-start:.5714286em}.prose :where(tbody tr):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.prose :where(tbody tr:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){border-bottom-width:0}.prose :where(tbody td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:baseline}.prose :where(tfoot):not(:where([class~=not-prose],[class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.prose :where(tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){vertical-align:top}.prose :where(th,td):not(:where([class~=not-prose],[class~=not-prose] *)){text-align:start}.prose :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){color:var(--tw-prose-captions);font-size:.875em;line-height:1.4285714;margin-top:.8571429em}.prose{--tw-prose-body: #374151;--tw-prose-headings: #111827;--tw-prose-lead: #4b5563;--tw-prose-links: #111827;--tw-prose-bold: #111827;--tw-prose-counters: #6b7280;--tw-prose-bullets: #d1d5db;--tw-prose-hr: #e5e7eb;--tw-prose-quotes: #111827;--tw-prose-quote-borders: #e5e7eb;--tw-prose-captions: #6b7280;--tw-prose-kbd: #111827;--tw-prose-kbd-shadows: 17 24 39;--tw-prose-code: #111827;--tw-prose-pre-code: #e5e7eb;--tw-prose-pre-bg: #1f2937;--tw-prose-th-borders: #d1d5db;--tw-prose-td-borders: #e5e7eb;--tw-prose-invert-body: #d1d5db;--tw-prose-invert-headings: #fff;--tw-prose-invert-lead: #9ca3af;--tw-prose-invert-links: #fff;--tw-prose-invert-bold: #fff;--tw-prose-invert-counters: #9ca3af;--tw-prose-invert-bullets: #4b5563;--tw-prose-invert-hr: #374151;--tw-prose-invert-quotes: #f3f4f6;--tw-prose-invert-quote-borders: #374151;--tw-prose-invert-captions: #9ca3af;--tw-prose-invert-kbd: #fff;--tw-prose-invert-kbd-shadows: 255 255 255;--tw-prose-invert-code: #fff;--tw-prose-invert-pre-code: #d1d5db;--tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);--tw-prose-invert-th-borders: #4b5563;--tw-prose-invert-td-borders: #374151;font-size:1rem;line-height:1.75}.prose :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.prose :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.375em}.prose :where(.prose>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(.prose>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(.prose>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em}.prose :where(.prose>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.25em}.prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.prose :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.prose :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5em;padding-inline-start:1.625em}.prose :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.5714286em;padding-inline-end:.5714286em;padding-bottom:.5714286em;padding-inline-start:.5714286em}.prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.prose :where(.prose>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose :where(.prose>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.prose-sm{font-size:.875rem;line-height:1.7142857}.prose-sm :where(p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em}.prose-sm :where([class~=lead]):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.2857143em;line-height:1.5555556;margin-top:.8888889em;margin-bottom:.8888889em}.prose-sm :where(blockquote):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.3333333em;margin-bottom:1.3333333em;padding-inline-start:1.1111111em}.prose-sm :where(h1):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:2.1428571em;margin-top:0;margin-bottom:.8em;line-height:1.2}.prose-sm :where(h2):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.4285714em;margin-top:1.6em;margin-bottom:.8em;line-height:1.4}.prose-sm :where(h3):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:1.2857143em;margin-top:1.5555556em;margin-bottom:.4444444em;line-height:1.5555556}.prose-sm :where(h4):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.4285714em;margin-bottom:.5714286em;line-height:1.4285714}.prose-sm :where(img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(picture):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(picture>img):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose-sm :where(video):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(kbd):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;border-radius:.3125rem;padding-top:.1428571em;padding-inline-end:.3571429em;padding-bottom:.1428571em;padding-inline-start:.3571429em}.prose-sm :where(code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em}.prose-sm :where(h2 code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.9em}.prose-sm :where(h3 code):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8888889em}.prose-sm :where(pre):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.6666667;margin-top:1.6666667em;margin-bottom:1.6666667em;border-radius:.25rem;padding-top:.6666667em;padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em;padding-inline-start:1.5714286em}.prose-sm :where(ul):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em;padding-inline-start:1.5714286em}.prose-sm :where(li):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.2857143em;margin-bottom:.2857143em}.prose-sm :where(ol>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.4285714em}.prose-sm :where(ul>li):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:.4285714em}.prose-sm :where(.prose-sm>ul>li p):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5714286em;margin-bottom:.5714286em}.prose-sm :where(.prose-sm>ul>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(.prose-sm>ul>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.1428571em}.prose-sm :where(.prose-sm>ol>li>p:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(.prose-sm>ol>li>p:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:1.1428571em}.prose-sm :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.5714286em;margin-bottom:.5714286em}.prose-sm :where(dl):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em;margin-bottom:1.1428571em}.prose-sm :where(dt):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.1428571em}.prose-sm :where(dd):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:.2857143em;padding-inline-start:1.5714286em}.prose-sm :where(hr):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:2.8571429em;margin-bottom:2.8571429em}.prose-sm :where(hr+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h2+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h3+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(h4+*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(table):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.5}.prose-sm :where(thead th):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(thead th:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose-sm :where(thead th:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose-sm :where(tbody td,tfoot td):not(:where([class~=not-prose],[class~=not-prose] *)){padding-top:.6666667em;padding-inline-end:1em;padding-bottom:.6666667em;padding-inline-start:1em}.prose-sm :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-start:0}.prose-sm :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){padding-inline-end:0}.prose-sm :where(figure):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:1.7142857em;margin-bottom:1.7142857em}.prose-sm :where(figure>*):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0;margin-bottom:0}.prose-sm :where(figcaption):not(:where([class~=not-prose],[class~=not-prose] *)){font-size:.8571429em;line-height:1.3333333;margin-top:.6666667em}.prose-sm :where(.prose-sm>:first-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-top:0}.prose-sm :where(.prose-sm>:last-child):not(:where([class~=not-prose],[class~=not-prose] *)){margin-bottom:0}.opencx-text-shimmer{animation:opencx-text-shimmer 2.5s ease-in-out infinite}.opencx-fade-up{animation:opencx-fade-up .3s cubic-bezier(.23,1,.32,1) both}[data-component="trigger/unread"],[data-component="sessions/unread"],[data-component="home/tab_unread"]{pointer-events:none;border-radius:9999px;background-color:hsl(var(--opencx-destructive));text-align:center;font-weight:600;--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction);color:hsl(var(--opencx-destructive-foreground));font-size:11px;line-height:18px;box-shadow:0 0 0 2px hsl(var(--opencx-background))}[data-component="trigger/unread"]{position:absolute;z-index:1}[data-component="sessions/unread"]{flex-shrink:0;box-shadow:none}[data-component="home/tab_unread"]{position:absolute;top:-2px;inset-inline-end:-2px}[data-unread-look=dot]{width:9px;height:9px}[data-unread-look=count]{min-width:16px;height:16px;padding:0 4px;font-size:10px;line-height:16px}.opencx-placeholder-in{animation:opencx-placeholder-in .2s cubic-bezier(.23,1,.32,1) both}.opencx-placeholder-out{animation:opencx-placeholder-out .18s cubic-bezier(.23,1,.32,1) both}@keyframes opencx-text-shimmer{0%,to{opacity:.45}50%{opacity:1}}@keyframes opencx-fade-up{0%{opacity:0;filter:blur(4px);transform:translateY(8px)}to{opacity:1;filter:blur(0px);transform:translateY(0)}}@keyframes opencx-placeholder-in{0%{opacity:0;transform:translateY(4px);filter:blur(1px)}to{opacity:1;transform:translateY(0);filter:blur(0)}}@keyframes opencx-placeholder-out{0%{opacity:1;transform:translateY(0);filter:blur(0)}to{opacity:0;transform:translateY(-8px);filter:blur(1px)}}.opencx-input-recall{animation:opencx-input-recall .15s cubic-bezier(.23,1,.32,1)}@keyframes opencx-input-recall{0%{opacity:.25;translate:0 -3px}to{opacity:1;translate:0 0}}@media(prefers-reduced-motion:reduce){.opencx-text-shimmer,.opencx-fade-up,.opencx-placeholder-in,.opencx-placeholder-out,.opencx-input-recall{animation:none}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.\\!visible{visibility:visible!important}.visible{visibility:visible}.invisible{visibility:hidden}.collapse{visibility:collapse}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.\\!sticky{position:sticky!important}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-0\\.5{top:.125rem;right:.125rem;bottom:.125rem;left:.125rem}.inset-x-0{left:0;right:0}.bottom-0{bottom:0}.bottom-3{bottom:.75rem}.end-1{inset-inline-end:.25rem}.end-4{inset-inline-end:1rem}.end-6{inset-inline-end:1.5rem}.left-1\\/2,.left-\\[50\\%\\]{left:50%}.right-4{right:1rem}.start-10{inset-inline-start:2.5rem}.start-2{inset-inline-start:.5rem}.start-4{inset-inline-start:1rem}.top-1{top:.25rem}.top-1\\/2{top:50%}.top-2{top:.5rem}.top-3{top:.75rem}.top-4{top:1rem}.top-6{top:1.5rem}.top-\\[50\\%\\]{top:50%}.top-full{top:100%}.isolate{isolation:isolate}.-z-10{z-index:-10}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.order-1{order:1}.order-2{order:2}.col-span-full{grid-column:1 / -1}.m-2{margin:.5rem}.-mx-0\\.5{margin-left:-.125rem;margin-right:-.125rem}.-mx-2{margin-left:-.5rem;margin-right:-.5rem}.mx-0\\.5{margin-left:.125rem;margin-right:.125rem}.mx-3{margin-left:.75rem;margin-right:.75rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.my-4{margin-top:1rem;margin-bottom:1rem}.-mt-0\\.5{margin-top:-.125rem}.-mt-6{margin-top:-1.5rem}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.ml-auto{margin-left:auto}.ms-1\\.5{margin-inline-start:.375rem}.ms-\\[30px\\]{margin-inline-start:30px}.ms-auto{margin-inline-start:auto}.mt-0\\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-12{margin-top:3rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.inline-grid{display:inline-grid}.contents{display:contents}.hidden{display:none}.aspect-square{aspect-ratio:1 / 1}.aspect-video{aspect-ratio:16 / 9}.size-0{width:0px;height:0px}.size-1\\.5{width:.375rem;height:.375rem}.size-10{width:2.5rem;height:2.5rem}.size-12{width:3rem;height:3rem}.size-16{width:4rem;height:4rem}.size-2{width:.5rem;height:.5rem}.size-2\\.5{width:.625rem;height:.625rem}.size-3{width:.75rem;height:.75rem}.size-3\\.5{width:.875rem;height:.875rem}.size-4{width:1rem;height:1rem}.size-5{width:1.25rem;height:1.25rem}.size-6{width:1.5rem;height:1.5rem}.size-7{width:1.75rem;height:1.75rem}.size-8{width:2rem;height:2rem}.size-9{width:2.25rem;height:2.25rem}.size-\\[18px\\]{width:18px;height:18px}.size-\\[max\\(100\\%\\,3rem\\)\\]{width:max(100%,3rem);height:max(100%,3rem)}.size-fit{width:fit-content;height:fit-content}.size-full{width:100%;height:100%}.h-0{height:0px}.h-1{height:.25rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-3{height:.75rem}.h-3\\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-full{height:100%}.max-h-16{max-height:4rem}.max-h-40{max-height:10rem}.max-h-60{max-height:15rem}.max-h-64{max-height:16rem}.max-h-72{max-height:18rem}.max-h-\\[160px\\]{max-height:160px}.max-h-\\[200px\\]{max-height:200px}.max-h-\\[50vh\\]{max-height:50vh}.max-h-full{max-height:100%}.min-h-0{min-height:0px}.min-h-12{min-height:3rem}.min-h-8{min-height:2rem}.w-0{width:0px}.w-1\\/2{width:50%}.w-1\\/4{width:25%}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-2\\/3{width:66.666667%}.w-2\\/5{width:40%}.w-3\\/4{width:75%}.w-3\\/5{width:60%}.w-4{width:1rem}.w-5\\/6{width:83.333333%}.w-7{width:1.75rem}.w-\\[32px\\]{width:32px}.w-\\[3px\\]{width:3px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-px{width:1px}.w-screen{width:100vw}.w-svw{width:100svw}.min-w-0{min-width:0px}.min-w-80{min-width:20rem}.min-w-\\[140px\\]{min-width:140px}.min-w-\\[3ch\\]{min-width:3ch}.max-w-11{max-width:2.75rem}.max-w-40{max-width:10rem}.max-w-48{max-width:12rem}.max-w-64{max-width:16rem}.max-w-80{max-width:20rem}.max-w-96{max-width:24rem}.max-w-\\[30rem\\]{max-width:30rem}.max-w-\\[61\\.8\\%\\]{max-width:61.8%}.max-w-\\[min\\(100\\%\\,16rem\\)\\]{max-width:min(100%,16rem)}.max-w-full{max-width:100%}.max-w-none{max-width:none}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-none{flex:none}.flex-shrink,.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.shrink-\\[2\\]{flex-shrink:2}.grow{flex-grow:1}.border-collapse{border-collapse:collapse}.origin-\\[var\\(--radix-popover-content-transform-origin\\)\\]{transform-origin:var(--radix-popover-content-transform-origin)}.origin-\\[var\\(--radix-tooltip-content-transform-origin\\)\\]{transform-origin:var(--radix-tooltip-content-transform-origin)}.origin-center{transform-origin:center}.origin-top{transform-origin:top}.-translate-x-1\\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\\[-50\\%\\]{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-\\[var\\(--wobble-x\\)\\]{--tw-translate-x: var(--wobble-x);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\\[-50\\%\\]{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-\\[var\\(--wobble-y\\)\\]{--tw-translate-y: var(--wobble-y);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-rotate-90{--tw-rotate: -90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-y-50{--tw-scale-y: .5;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.animate-bounce{animation:bounce 1s infinite}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;user-select:none}.resize-none{resize:none}.resize{resize:both}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-\\[subgrid\\]{grid-template-columns:subgrid}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-baseline{align-items:baseline}.items-stretch{align-items:stretch}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0{gap:0px}.gap-0\\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-2\\.5{gap:.625rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-\\[1px\\]{gap:1px}.gap-\\[3px\\]{gap:3px}.gap-x-2\\.5{column-gap:.625rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-foreground\\/10>:not([hidden])~:not([hidden]){border-color:hsl(var(--opencx-foreground) / .1)}.self-start{align-self:flex-start}.self-center{align-self:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-scroll{overflow:scroll}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.scroll-smooth{scroll-behavior:smooth}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-ellipsis{text-overflow:ellipsis}.whitespace-normal{white-space:normal}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-pretty{text-wrap:pretty}.break-words{overflow-wrap:break-word}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-3xl{border-radius:1.5rem}.rounded-\\[19px\\]{border-radius:19px}.rounded-\\[1px\\]{border-radius:1px}.rounded-\\[20px\\]{border-radius:20px}.rounded-\\[calc\\(var\\(--opencx-inset-radius\\)\\+var\\(--cx-p\\)\\)\\]{border-radius:calc(var(--opencx-inset-radius) + var(--cx-p))}.rounded-\\[calc\\(var\\(--pk-r\\)-var\\(--pk-p\\)\\)\\]{border-radius:calc(var(--pk-r) - var(--pk-p))}.rounded-\\[var\\(--opencx-inset-radius\\)\\]{border-radius:var(--opencx-inset-radius)}.rounded-\\[var\\(--pk-r\\)\\]{border-radius:var(--pk-r)}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.rounded-b-2xl{border-bottom-right-radius:1rem;border-bottom-left-radius:1rem}.rounded-l-md{border-top-left-radius:.375rem;border-bottom-left-radius:.375rem}.rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.rounded-bl-md{border-bottom-left-radius:.375rem}.rounded-br-md{border-bottom-right-radius:.375rem}.rounded-tl-md{border-top-left-radius:.375rem}.rounded-tr-md{border-top-right-radius:.375rem}.border{border-width:1px}.border-\\[1\\.5px\\]{border-width:1.5px}.border-b{border-bottom-width:1px}.border-l-2{border-left-width:2px}.border-s{border-inline-start-width:1px}.border-s-2{border-inline-start-width:2px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-none{border-style:none}.border-border{border-color:hsl(var(--opencx-border))}.border-destructive\\/30{border-color:hsl(var(--opencx-destructive) / .3)}.border-foreground\\/10{border-color:hsl(var(--opencx-foreground) / .1)}.border-foreground\\/15{border-color:hsl(var(--opencx-foreground) / .15)}.border-muted-foreground\\/10{border-color:hsl(var(--opencx-muted-foreground) / .1)}.border-muted-foreground\\/15{border-color:hsl(var(--opencx-muted-foreground) / .15)}.border-muted-foreground\\/20{border-color:hsl(var(--opencx-muted-foreground) / .2)}.border-muted-foreground\\/30{border-color:hsl(var(--opencx-muted-foreground) / .3)}.border-primary{border-color:hsl(var(--opencx-primary))}.border-primary\\/10{border-color:hsl(var(--opencx-primary) / .1)}.border-primary\\/50{border-color:hsl(var(--opencx-primary) / .5)}.border-l-amber-500{--tw-border-opacity: 1;border-left-color:rgb(245 158 11 / var(--tw-border-opacity, 1))}.border-l-blue-500{--tw-border-opacity: 1;border-left-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-l-emerald-500{--tw-border-opacity: 1;border-left-color:rgb(16 185 129 / var(--tw-border-opacity, 1))}.border-l-red-500{--tw-border-opacity: 1;border-left-color:rgb(239 68 68 / var(--tw-border-opacity, 1))}.border-t-current{border-top-color:currentColor}.bg-\\[white\\]{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(245 158 11 / var(--tw-bg-opacity, 1))}.bg-amber-500\\/15{background-color:#f59e0b26}.bg-amber-500\\/5{background-color:#f59e0b0d}.bg-background{background-color:hsl(var(--opencx-background))}.bg-background\\/80{background-color:hsl(var(--opencx-background) / .8)}.bg-black\\/50{background-color:#00000080}.bg-black\\/60{background-color:#0009}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\\/5{background-color:#3b82f60d}.bg-current{background-color:currentColor}.bg-destructive{background-color:hsl(var(--opencx-destructive))}.bg-destructive\\/10{background-color:hsl(var(--opencx-destructive) / .1)}.bg-destructive\\/15{background-color:hsl(var(--opencx-destructive) / .15)}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-emerald-500\\/10{background-color:#10b9811a}.bg-emerald-500\\/15{background-color:#10b98126}.bg-emerald-500\\/5{background-color:#10b9810d}.bg-foreground{background-color:hsl(var(--opencx-foreground))}.bg-foreground\\/5{background-color:hsl(var(--opencx-foreground) / .05)}.bg-foreground\\/50{background-color:hsl(var(--opencx-foreground) / .5)}.bg-foreground\\/60{background-color:hsl(var(--opencx-foreground) / .6)}.bg-muted{background-color:hsl(var(--opencx-muted))}.bg-muted-foreground{background-color:hsl(var(--opencx-muted-foreground))}.bg-muted-foreground\\/10{background-color:hsl(var(--opencx-muted-foreground) / .1)}.bg-muted-foreground\\/30{background-color:hsl(var(--opencx-muted-foreground) / .3)}.bg-muted-foreground\\/40{background-color:hsl(var(--opencx-muted-foreground) / .4)}.bg-muted\\/30{background-color:hsl(var(--opencx-muted) / .3)}.bg-muted\\/40{background-color:hsl(var(--opencx-muted) / .4)}.bg-primary{background-color:hsl(var(--opencx-primary))}.bg-primary-foreground\\/20{background-color:hsl(var(--opencx-primary-foreground) / .2)}.bg-primary\\/10{background-color:hsl(var(--opencx-primary) / .1)}.bg-primary\\/25{background-color:hsl(var(--opencx-primary) / .25)}.bg-primary\\/\\[0\\.07\\]{background-color:hsl(var(--opencx-primary) / .07)}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\\/5{background-color:#ef44440d}.bg-secondary{background-color:hsl(var(--opencx-secondary))}.bg-secondary-foreground\\/10{background-color:hsl(var(--opencx-secondary-foreground) / .1)}.bg-secondary-foreground\\/20{background-color:hsl(var(--opencx-secondary-foreground) / .2)}.bg-transparent{background-color:transparent}.bg-white\\/30{background-color:#ffffff4d}.bg-\\[radial-gradient\\(ellipse_at_top_left\\,hsl\\(var\\(--opencx-primary\\)\\)\\,transparent\\)\\,radial-gradient\\(ellipse_at_top_right\\,hsl\\(var\\(--opencx-primary\\)\\)\\,transparent\\)\\]{background-image:radial-gradient(ellipse at top left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse at top right,hsl(var(--opencx-primary)),transparent)}.bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.from-foreground\\/70{--tw-gradient-from: hsl(var(--opencx-foreground) / .7) var(--tw-gradient-from-position);--tw-gradient-to: hsl(var(--opencx-foreground) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.to-foreground\\/0{--tw-gradient-to: hsl(var(--opencx-foreground) / 0) var(--tw-gradient-to-position)}.fill-current{fill:currentColor}.fill-foreground{fill:hsl(var(--opencx-foreground))}.stroke-current{stroke:currentColor}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left-top{object-position:left top}.p-0{padding:0}.p-0\\.5{padding:.125rem}.p-1{padding:.25rem}.p-1\\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-\\[var\\(--cx-p\\)\\]{padding:var(--cx-p)}.p-\\[var\\(--pk-p\\)\\]{padding:var(--pk-p)}.px-0\\.5{padding-left:.125rem;padding-right:.125rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-3\\.5{padding-left:.875rem;padding-right:.875rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.py-0{padding-top:0;padding-bottom:0}.py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-\\[3px\\]{padding-top:3px;padding-bottom:3px}.pb-0{padding-bottom:0}.pb-0\\.5{padding-bottom:.125rem}.pb-1{padding-bottom:.25rem}.pb-14{padding-bottom:3.5rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pb-4{padding-bottom:1rem}.pb-5{padding-bottom:1.25rem}.pe-1{padding-inline-end:.25rem}.pe-2{padding-inline-end:.5rem}.pe-2\\.5{padding-inline-end:.625rem}.pe-4{padding-inline-end:1rem}.pl-2{padding-left:.5rem}.pl-6{padding-left:1.5rem}.pr-16{padding-right:4rem}.ps-1{padding-inline-start:.25rem}.ps-1\\.5{padding-inline-start:.375rem}.ps-10{padding-inline-start:2.5rem}.ps-2{padding-inline-start:.5rem}.ps-2\\.5{padding-inline-start:.625rem}.ps-3{padding-inline-start:.75rem}.ps-4{padding-inline-start:1rem}.ps-8{padding-inline-start:2rem}.pt-0{padding-top:0}.pt-1{padding-top:.25rem}.pt-1\\.5{padding-top:.375rem}.pt-2{padding-top:.5rem}.pt-2\\.5{padding-top:.625rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-start{text-align:start}.align-middle{vertical-align:middle}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.font-sans{font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji"}.text-2xl{font-size:1.5rem;line-height:2rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-\\[0\\.8125rem\\]{font-size:.8125rem}.text-\\[1\\.75rem\\]{font-size:1.75rem}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.text-\\[12px\\]{font-size:12px}.text-\\[13px\\]{font-size:13px}.text-\\[14px\\]{font-size:14px}.text-\\[16px\\]{font-size:16px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-5{line-height:1.25rem}.leading-6{line-height:1.5rem}.leading-none{line-height:1}.leading-relaxed{line-height:1.625}.leading-snug{line-height:1.375}.leading-tight{line-height:1.25}.tracking-tight{letter-spacing:-.025em}.tracking-wide{letter-spacing:.025em}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-background{color:hsl(var(--opencx-background))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-destructive{color:hsl(var(--opencx-destructive))}.text-destructive-foreground{color:hsl(var(--opencx-destructive-foreground))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-foreground{color:hsl(var(--opencx-foreground))}.text-foreground\\/50{color:hsl(var(--opencx-foreground) / .5)}.text-foreground\\/60{color:hsl(var(--opencx-foreground) / .6)}.text-foreground\\/80{color:hsl(var(--opencx-foreground) / .8)}.text-foreground\\/90{color:hsl(var(--opencx-foreground) / .9)}.text-muted-foreground{color:hsl(var(--opencx-muted-foreground))}.text-muted-foreground\\/40{color:hsl(var(--opencx-muted-foreground) / .4)}.text-muted-foreground\\/50{color:hsl(var(--opencx-muted-foreground) / .5)}.text-muted-foreground\\/60{color:hsl(var(--opencx-muted-foreground) / .6)}.text-muted-foreground\\/70{color:hsl(var(--opencx-muted-foreground) / .7)}.text-muted-foreground\\/75{color:hsl(var(--opencx-muted-foreground) / .75)}.text-primary{color:hsl(var(--opencx-primary))}.text-primary-foreground{color:hsl(var(--opencx-primary-foreground))}.text-primary-foreground\\/60{color:hsl(var(--opencx-primary-foreground) / .6)}.text-primary\\/10{color:hsl(var(--opencx-primary) / .1)}.text-primary\\/40{color:hsl(var(--opencx-primary) / .4)}.text-primary\\/50{color:hsl(var(--opencx-primary) / .5)}.text-primary\\/60{color:hsl(var(--opencx-primary) / .6)}.text-primary\\/70{color:hsl(var(--opencx-primary) / .7)}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-secondary-foreground{color:hsl(var(--opencx-secondary-foreground))}.text-secondary-foreground\\/60{color:hsl(var(--opencx-secondary-foreground) / .6)}.text-secondary-foreground\\/70{color:hsl(var(--opencx-secondary-foreground) / .7)}.text-transparent{color:transparent}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-white\\/80{color:#fffc}.underline{text-decoration-line:underline}.line-through{text-decoration-line:line-through}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.caret-foreground{caret-color:hsl(var(--opencx-foreground))}.accent-current{accent-color:currentColor}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-20{opacity:.2}.opacity-35{opacity:.35}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-90{opacity:.9}.opacity-95{opacity:.95}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.outline{outline-style:solid}.outline-8{outline-width:8px}.outline-background{outline-color:hsl(var(--opencx-background))}.ring{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-border{--tw-ring-color: hsl(var(--opencx-border))}.ring-offset-background{--tw-ring-offset-color: hsl(var(--opencx-background))}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.drop-shadow{--tw-drop-shadow: drop-shadow(0 1px 2px rgb(0 0 0 / .1)) drop-shadow(0 1px 1px rgb(0 0 0 / .06));filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[background-color\\,color\\,transform\\]{transition-property:background-color,color,transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[height\\]{transition-property:height;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-\\[width\\]{transition-property:width;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-100{transition-duration:.1s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.ease-opencx{transition-timing-function:cubic-bezier(.23,1,.32,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.animate-in{animation-name:enter;animation-duration:.15s;--tw-enter-opacity: initial;--tw-enter-scale: initial;--tw-enter-rotate: initial;--tw-enter-translate-x: initial;--tw-enter-translate-y: initial}.fade-in-0{--tw-enter-opacity: 0}.zoom-in{--tw-enter-scale: 0}.zoom-in-95{--tw-enter-scale: .95}.duration-100{animation-duration:.1s}.duration-150{animation-duration:.15s}.duration-200{animation-duration:.2s}.duration-300{animation-duration:.3s}.ease-opencx{animation-timing-function:cubic-bezier(.23,1,.32,1)}.ease-out{animation-timing-function:cubic-bezier(0,0,.2,1)}.running{animation-play-state:running}.paused{animation-play-state:paused}.\\[--tw-prose-body\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-foreground))}.\\[--tw-prose-body\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-body\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-bold\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-bold: hsl(var(--opencx-foreground))}.\\[--tw-prose-bold\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-bold: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-bullets\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-bullets: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-code\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-code: hsl(var(--opencx-foreground))}.\\[--tw-prose-code\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-code: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-counters\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-counters: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-headings\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-headings: hsl(var(--opencx-foreground))}.\\[--tw-prose-headings\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-headings: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-hr\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-hr: hsl(var(--opencx-border))}.\\[--tw-prose-lead\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-lead: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-links\\:hsl\\(var\\(--opencx-primary\\)\\)\\]{--tw-prose-links: hsl(var(--opencx-primary))}.\\[--tw-prose-links\\:hsl\\(var\\(--opencx-secondary-foreground\\)\\)\\]{--tw-prose-links: hsl(var(--opencx-secondary-foreground))}.\\[--tw-prose-pre-bg\\:hsl\\(var\\(--opencx-muted\\)\\)\\]{--tw-prose-pre-bg: hsl(var(--opencx-muted))}.\\[--tw-prose-pre-code\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-pre-code: hsl(var(--opencx-foreground))}.\\[--tw-prose-quote-borders\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-quote-borders: hsl(var(--opencx-border))}.\\[--tw-prose-quotes\\:hsl\\(var\\(--opencx-muted-foreground\\)\\)\\]{--tw-prose-quotes: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-td-borders\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-td-borders: hsl(var(--opencx-border))}.\\[--tw-prose-th-borders\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-th-borders: hsl(var(--opencx-border))}.\\[animation-delay\\:-0\\.15s\\]{animation-delay:-.15s}.\\[animation-delay\\:-0\\.3s\\]{animation-delay:-.3s}.\\[field-sizing\\:content\\;\\],.\\[field-sizing\\:content\\]{field-sizing:content}.\\[overflow-wrap\\:anywhere\\]{overflow-wrap:anywhere}.\\[word-break\\:break-word\\]{word-break:break-word}.file\\:border-0::file-selector-button{border-width:0px}.file\\:bg-transparent::file-selector-button{background-color:transparent}.file\\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:font-medium::file-selector-button{font-weight:500}.file\\:text-primary-foreground::file-selector-button{color:hsl(var(--opencx-primary-foreground))}.placeholder\\:text-muted-foreground::placeholder{color:hsl(var(--opencx-muted-foreground))}.placeholder\\:text-muted-foreground\\/75::placeholder{color:hsl(var(--opencx-muted-foreground) / .75)}.last\\:border-0:last-child{border-width:0px}.focus-within\\:opacity-100:focus-within{opacity:1}.hover\\:scale-\\[var\\(--scale\\)\\]:hover{--tw-scale-x: var(--scale);--tw-scale-y: var(--scale);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\\:bg-accent\\/60:hover{background-color:hsl(var(--opencx-accent) / .6)}.hover\\:bg-foreground:hover{background-color:hsl(var(--opencx-foreground))}.hover\\:bg-muted:hover{background-color:hsl(var(--opencx-muted))}.hover\\:bg-muted\\/50:hover{background-color:hsl(var(--opencx-muted) / .5)}.hover\\:bg-muted\\/60:hover{background-color:hsl(var(--opencx-muted) / .6)}.hover\\:bg-primary\\/10:hover{background-color:hsl(var(--opencx-primary) / .1)}.hover\\:bg-primary\\/90:hover{background-color:hsl(var(--opencx-primary) / .9)}.hover\\:bg-primary\\/\\[0\\.02\\]:hover{background-color:hsl(var(--opencx-primary) / .02)}.hover\\:bg-red-500:hover{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.hover\\:bg-secondary:hover{background-color:hsl(var(--opencx-secondary))}.hover\\:bg-secondary\\/80:hover{background-color:hsl(var(--opencx-secondary) / .8)}.hover\\:bg-transparent:hover{background-color:transparent}.hover\\:bg-white\\/15:hover{background-color:#ffffff26}.hover\\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\\:text-foreground:hover{color:hsl(var(--opencx-foreground))}.hover\\:text-muted-foreground:hover{color:hsl(var(--opencx-muted-foreground))}.hover\\:text-primary:hover{color:hsl(var(--opencx-primary))}.hover\\:text-primary-foreground:hover{color:hsl(var(--opencx-primary-foreground))}.hover\\:text-secondary-foreground:hover{color:hsl(var(--opencx-secondary-foreground))}.hover\\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.hover\\:underline:hover{text-decoration-line:underline}.hover\\:opacity-100:hover{opacity:1}.hover\\:opacity-80:hover{opacity:.8}.focus-visible\\:opacity-100:focus-visible{opacity:1}.focus-visible\\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:outline:focus-visible{outline-style:solid}.focus-visible\\:outline-2:focus-visible{outline-width:2px}.focus-visible\\:outline-ring:focus-visible{outline-color:hsl(var(--opencx-ring))}.focus-visible\\:ring-1:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\\:ring-inset:focus-visible{--tw-ring-inset: inset}.focus-visible\\:ring-primary\\/40:focus-visible{--tw-ring-color: hsl(var(--opencx-primary) / .4)}.focus-visible\\:ring-ring:focus-visible{--tw-ring-color: hsl(var(--opencx-ring))}.focus-visible\\:ring-offset-2:focus-visible{--tw-ring-offset-width: 2px}.active\\:scale-90:active{--tw-scale-x: .9;--tw-scale-y: .9;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:scale-95:active{--tw-scale-x: .95;--tw-scale-y: .95;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:scale-\\[0\\.97\\]:active{--tw-scale-x: .97;--tw-scale-y: .97;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.active\\:hover\\:scale-\\[calc\\(var\\(--scale\\)-0\\.02\\)\\]:hover:active{--tw-scale-x: calc(var(--scale) - .02);--tw-scale-y: calc(var(--scale) - .02);transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.disabled\\:pointer-events-none:disabled{pointer-events:none}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:text-white\\/30:disabled{color:#ffffff4d}.disabled\\:opacity-100:disabled{opacity:1}.disabled\\:opacity-40:disabled{opacity:.4}.disabled\\:opacity-50:disabled{opacity:.5}.disabled\\:hover\\:bg-transparent:hover:disabled{background-color:transparent}.group:hover .group-hover\\:opacity-100{opacity:1}.aria-expanded\\:bg-muted[aria-expanded=true]{background-color:hsl(var(--opencx-muted))}.data-\\[state\\=closed\\]\\:animate-out[data-state=closed]{animation-name:exit;animation-duration:.15s;--tw-exit-opacity: initial;--tw-exit-scale: initial;--tw-exit-rotate: initial;--tw-exit-translate-x: initial;--tw-exit-translate-y: initial}.data-\\[state\\=closed\\]\\:fade-out-0[data-state=closed]{--tw-exit-opacity: 0}.data-\\[state\\=closed\\]\\:zoom-out-95[data-state=closed]{--tw-exit-scale: .95}.data-\\[side\\=bottom\\]\\:slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y: -.5rem}.data-\\[side\\=left\\]\\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x: .5rem}.data-\\[side\\=right\\]\\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x: -.5rem}.data-\\[side\\=top\\]\\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y: .5rem}.prose-headings\\:my-1\\.5 :is(:where(h1,h2,h3,h4,h5,h6,th):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.375rem;margin-bottom:.375rem}.prose-headings\\:text-\\[13px\\] :is(:where(h1,h2,h3,h4,h5,h6,th):not(:where([class~=not-prose],[class~=not-prose] *))){font-size:13px}.prose-p\\:my-1 :is(:where(p):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.25rem;margin-bottom:.25rem}.prose-a\\:underline :is(:where(a):not(:where([class~=not-prose],[class~=not-prose] *))){text-decoration-line:underline}.prose-a\\:decoration-primary :is(:where(a):not(:where([class~=not-prose],[class~=not-prose] *))){text-decoration-color:hsl(var(--opencx-primary))}.prose-pre\\:my-1\\.5 :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.375rem;margin-bottom:.375rem}.prose-pre\\:p-2 :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){padding:.5rem}.prose-pre\\:text-\\[11px\\] :is(:where(pre):not(:where([class~=not-prose],[class~=not-prose] *))){font-size:11px}.prose-ol\\:my-1 :is(:where(ol):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.25rem;margin-bottom:.25rem}.prose-ul\\:my-1 :is(:where(ul):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.25rem;margin-bottom:.25rem}.prose-li\\:my-0\\.5 :is(:where(li):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.125rem;margin-bottom:.125rem}.prose-table\\:block :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){display:block}.prose-table\\:overflow-x-auto :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){overflow-x:auto}.prose-table\\:\\[overflow-wrap\\:normal\\] :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){overflow-wrap:normal}.prose-table\\:\\[word-break\\:normal\\] :is(:where(table):not(:where([class~=not-prose],[class~=not-prose] *))){word-break:normal}.prose-img\\:rounded-xl :is(:where(img):not(:where([class~=not-prose],[class~=not-prose] *))){border-radius:.75rem}.prose-hr\\:my-2 :is(:where(hr):not(:where([class~=not-prose],[class~=not-prose] *))){margin-top:.5rem;margin-bottom:.5rem}@media(prefers-reduced-motion:reduce){.motion-reduce\\:animate-none{animation:none}.motion-reduce\\:active\\:scale-100:active{--tw-scale-x: 1;--tw-scale-y: 1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}}@media(min-width:640px){.sm\\:text-sm{font-size:.875rem;line-height:1.25rem}}.rtl\\:-scale-100:where([dir=rtl],[dir=rtl] *){--tw-scale-x: -1;--tw-scale-y: -1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@media(prefers-color-scheme:dark){.dark\\:text-amber-400{--tw-text-opacity: 1;color:rgb(251 191 36 / var(--tw-text-opacity, 1))}.dark\\:text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.dark\\:text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}}.\\[\\&\\>\\*\\:first-child\\]\\:mt-0>*:first-child{margin-top:0}.\\[\\&\\>\\*\\:last-child\\]\\:mb-0>*:last-child{margin-bottom:0}.\\[\\&_\\.animate-spin\\]\\:animate-none .animate-spin{animation:none}.\\[\\&_span\\]\\:size-1 span{width:.25rem;height:.25rem}.\\[\\&_span\\]\\:bg-secondary-foreground span{background-color:hsl(var(--opencx-secondary-foreground))}.\\[\\&_svg\\]\\:text-muted-foreground\\/70 svg{color:hsl(var(--opencx-muted-foreground) / .7)}.\\[\\&_svg\\]\\:hover\\:text-primary:hover svg{color:hsl(var(--opencx-primary))}@media(hover:none){.\\[\\@media\\(hover\\:none\\)\\]\\:opacity-100{opacity:1}}@media(pointer:coarse){.\\[\\@media\\(pointer\\:coarse\\)\\]\\:min-h-12{min-height:3rem}.\\[\\@media\\(pointer\\:coarse\\)\\]\\:gap-y-3{row-gap:.75rem}}@media(pointer:fine){.\\[\\@media\\(pointer\\:fine\\)\\]\\:hidden{display:none}}',gu="5.15.3";function xu(e,t){const n=typeof(e==null?void 0:e.right)=="number",o=typeof(e==null?void 0:e.left)=="number";return n&&!o?"right":o&&!n||t==="rtl"?"left":"right"}const ts=450;function ye(){const[e,t]=u.useState(()=>(window.top||window).innerWidth<ts);return u.useEffect(()=>{const n=window.top||window,o=()=>{t(n.innerWidth<ts)};return o(),n.addEventListener("resize",o),()=>{n.removeEventListener("resize",o)}},[]),{isSmallScreen:e}}const hn={transitionTimingFunction:"cubic-bezier(0.16, 1, 0.3, 1)",transitionDuration:"1000ms"};function ue(){var h,f,x,g,j,b,S,w,_,y,v,N,R,M,z,L,O,U,E,I,H,$,q,X,B,F,Z,re,ae,fe,oe,ke,D,te,J,ne,pe,ce,se,Le,De,de,qe,st,Ve,Fe,Ye,Xe;const{dir:e}=C.useDocumentDir(),{isSmallScreen:t}=ye(),{theme:n,inline:o}=C.useConfig(),s=xe=>o?"100%":xe,i=(xe,Re)=>t?`100dv${xe}`:Re,a=(xe,Re)=>s(i(xe,Re)),c=xu((h=n==null?void 0:n.widgetTrigger)==null?void 0:h.offset,e),d={zIndex:((f=n==null?void 0:n.widgetTrigger)==null?void 0:f.zIndex)??1e7,offset:{bottom:((g=(x=n==null?void 0:n.widgetTrigger)==null?void 0:x.offset)==null?void 0:g.bottom)??20,right:((b=(j=n==null?void 0:n.widgetTrigger)==null?void 0:j.offset)==null?void 0:b.right)??(c==="right"?20:"initial"),left:((w=(S=n==null?void 0:n.widgetTrigger)==null?void 0:S.offset)==null?void 0:w.left)??(c==="left"?20:"initial")},size:{button:((y=(_=n==null?void 0:n.widgetTrigger)==null?void 0:_.size)==null?void 0:y.button)??48,icon:((N=(v=n==null?void 0:n.widgetTrigger)==null?void 0:v.size)==null?void 0:N.icon)??24}},l=(()=>{const xe=c==="right"?d.offset.right:d.offset.left;return typeof xe!="number"?0:xe})(),m={palette:(n==null?void 0:n.palette)??"neutral",primaryColor:(n==null?void 0:n.primaryColor)??"hsl(0 0% 9%)",widgetTrigger:d,widgetContentContainer:{borderRadius:t?"0px":((R=n==null?void 0:n.widgetContentContainer)==null?void 0:R.borderRadius)??"32px",zIndex:((M=n==null?void 0:n.widgetContentContainer)==null?void 0:M.zIndex)??d.zIndex+1,outline:((z=n==null?void 0:n.widgetContentContainer)==null?void 0:z.outline)??"none",outlineColor:((L=n==null?void 0:n.widgetContentContainer)==null?void 0:L.outlineColor)??"hsl(0 0% 50% / .5)",boxShadow:((O=n==null?void 0:n.widgetContentContainer)==null?void 0:O.boxShadow)??"0 0px 100px 0px rgb(0 0 0 / 0.25)",transitionProperty:((U=n==null?void 0:n.widgetContentContainer)==null?void 0:U.transitionProperty)??"all",transitionTimingFunction:((E=n==null?void 0:n.widgetContentContainer)==null?void 0:E.transitionTimingFunction)??hn.transitionTimingFunction,transitionDuration:((I=n==null?void 0:n.widgetContentContainer)==null?void 0:I.transitionDuration)??hn.transitionDuration,offset:{side:t?0:d.offset.bottom+d.size.button+Tt.y*2+((($=(H=n==null?void 0:n.widgetContentContainer)==null?void 0:H.offset)==null?void 0:$.side)??10),align:t?0:l+(((X=(q=n==null?void 0:n.widgetContentContainer)==null?void 0:q.offset)==null?void 0:X.align)??0)}},screens:{welcome:{width:a("w",((F=(B=n==null?void 0:n.screens)==null?void 0:B.welcome)==null?void 0:F.width)??"400px"),minHeight:a("h",((re=(Z=n==null?void 0:n.screens)==null?void 0:Z.welcome)==null?void 0:re.minHeight)??"1px")},sessions:{width:a("w",((fe=(ae=n==null?void 0:n.screens)==null?void 0:ae.sessions)==null?void 0:fe.width)??"450px"),height:a("h",((ke=(oe=n==null?void 0:n.screens)==null?void 0:oe.sessions)==null?void 0:ke.height)??"600px")},chat:{width:a("w",((te=(D=n==null?void 0:n.screens)==null?void 0:D.chat)==null?void 0:te.width)??"525px"),height:a("h",((ne=(J=n==null?void 0:n.screens)==null?void 0:J.chat)==null?void 0:ne.height)??"700px"),withCanvas:{width:a("w",((se=(ce=(pe=n==null?void 0:n.screens)==null?void 0:pe.chat)==null?void 0:ce.withCanvas)==null?void 0:se.width)??"min(1050px, 100vw)"),height:a("h",((de=(De=(Le=n==null?void 0:n.screens)==null?void 0:Le.chat)==null?void 0:De.withCanvas)==null?void 0:de.height)??"min(800px, 100vh)"),transitionTimingFunction:((Ve=(st=(qe=n==null?void 0:n.screens)==null?void 0:qe.chat)==null?void 0:st.withCanvas)==null?void 0:Ve.transitionTimingFunction)??hn.transitionTimingFunction,transitionDuration:((Xe=(Ye=(Fe=n==null?void 0:n.screens)==null?void 0:Fe.chat)==null?void 0:Ye.withCanvas)==null?void 0:Xe.transitionDuration)??hn.transitionDuration}}}},p={maxHeight:a("h",`calc(
|
|
15
|
-
100vh
|
|
16
|
-
- ${m.widgetTrigger.offset.bottom}px
|
|
17
|
-
- ${m.widgetContentContainer.offset.side}px
|
|
18
|
-
- ${Tt.y*2}px
|
|
19
|
-
)`),maxWidth:a("w",`calc(
|
|
20
|
-
100vw
|
|
21
|
-
- ${l*2}px
|
|
22
|
-
)`),minHeight:a("h",`min(
|
|
23
|
-
${m.screens.welcome.minHeight},
|
|
24
|
-
${m.screens.sessions.height},
|
|
25
|
-
${m.screens.chat.height}
|
|
26
|
-
)`),minWidth:a("w",`min(
|
|
27
|
-
${m.screens.welcome.width},
|
|
28
|
-
${m.screens.sessions.width},
|
|
29
|
-
${m.screens.chat.width}
|
|
30
|
-
)`)};return{theme:m,triggerSide:c,computed:p,cssVars:bu({palette:m.palette,primary:m.primaryColor})}}function bu({palette:e,primary:t}){const n=qa(e),o=zo(t).toHsl(),s=zo(t).isLight()?n[950]:n[50];return{"--opencx-primary":`${o.h} ${o.s*100}% ${o.l*100}%`,"--opencx-primary-foreground":s,"--opencx-background":n[100],"--opencx-foreground":n[950],"--opencx-destructive":"0 72.2% 50.6%","--opencx-destructive-foreground":n[50],"--opencx-accent":n[200],"--opencx-accent-foreground":"var(--opencx-foreground)","--opencx-secondary":n[200],"--opencx-secondary-foreground":"var(--opencx-foreground)","--opencx-muted":n[200],"--opencx-muted-foreground":n[500],"--opencx-input":n[300],"--opencx-border":n[300],"--opencx-ring":"var(--opencx-foreground)"}}function qa(e){const t={50:"0 0% 98%",100:"0 0% 96.1%",200:"0 0% 89.8%",300:"0 0% 83.1%",400:"0 0% 63.9%",500:"0 0% 45.1%",600:"0 0% 32.2%",700:"0 0% 25.1%",800:"0 0% 14.9%",900:"0 0% 9%",950:"0 0% 3.9%"},n={50:"60 9.1% 97.8%",100:"60 4.8% 95.9%",200:"20 5.9% 90%",300:"24 5.7% 82.9%",400:"24 5.4% 63.9%",500:"25 5.3% 44.7%",600:"33.3 5.5% 32.4%",700:"30 6.3% 25.1%",800:"12 6.5% 15.1%",900:"24 9.8% 10%",950:"20 14.3% 4.1%"},o={50:"0 0% 98%",100:"240 4.8% 95.9%",200:"240 5.9% 90%",300:"240 4.9% 83.9%",400:"240 5% 64.9%",500:"240 3.8% 46.1%",600:"240 5.2% 33.9%",700:"240 5.3% 26.1%",800:"240 3.7% 15.9%",900:"240 5.9% 10%",950:"240 10% 3.9%"},s={50:"210 40% 98%",100:"210 40% 96.1%",200:"214.3 31.8% 91.4%",300:"212.7 26.8% 83.9%",400:"215 20.2% 65.1%",500:"215.4 16.3% 46.9%",600:"215.3 19.3% 34.5%",700:"215.3 25% 26.7%",800:"217.2 32.6% 17.5%",900:"222.2 47.4% 11.2%",950:"222.2 84% 4.9%"};switch(e){case"neutral":return t;case"stone":return n;case"zinc":return o;case"slate":return s;default:return G.isExhaustive(e,qa.name),t}}const wu=150,fn={capture:!0},Ge={capture:!0,passive:!0};function Va(e,{scroll:t}){var o;const n=(o=Gr())==null?void 0:o.report;u.useEffect(()=>{if(!e||!n)return;const s=h=>{h.isTrusted&&(!("detail"in h)||typeof h.detail!="number"||h.detail>0&&n({type:"click"}))},i=h=>{h.isTrusted&&n({type:"keyboard"})};let a=!1,c;const d=()=>{a&&(a=!1,clearTimeout(c),n({type:"scroll-end"}))},l=()=>{clearTimeout(c),c=setTimeout(d,wu)},m=h=>{h.isTrusted&&(a||(a=!0,n({type:"scroll-start"})),l())},p=()=>{a&&l()};return e.addEventListener("click",s,fn),e.addEventListener("keydown",i,fn),t&&(e.addEventListener("wheel",m,Ge),e.addEventListener("touchmove",m,Ge),e.addEventListener("scroll",p,Ge),e.addEventListener("scrollend",d,Ge)),()=>{e.removeEventListener("click",s,fn),e.removeEventListener("keydown",i,fn),e.removeEventListener("wheel",m,Ge),e.removeEventListener("touchmove",m,Ge),e.removeEventListener("scroll",p,Ge),e.removeEventListener("scrollend",d,Ge),d()}},[e,n,t])}const vu=Te.Provider,yu=Te.Root,ku=Te.Trigger,Ya=rt.forwardRef(({className:e,sideOffset:t=4,...n},o)=>r.jsx(Te.Content,{ref:o,sideOffset:t,className:A("z-50 overflow-hidden max-w-xs rounded-xl bg-primary border text-primary-foreground p-2 text-center align-middle text-xs origin-[var(--radix-tooltip-content-transform-origin)] animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n}));Ya.displayName=Te.Content.displayName;const Xa=rt.createContext(!1);function ju({children:e}){return r.jsx(Xa.Provider,{value:!0,children:e})}function Ie({children:e,content:t,side:n,align:o,shortcut:s}){const{disableTooltips:i}=C.useConfig(),a=rt.useContext(Xa);return!t||i||a?e:r.jsxs(yu,{children:[r.jsx(ku,{asChild:!0,children:e}),r.jsxs(Ya,{side:n,align:o,collisionPadding:8,avoidCollisions:!0,children:[t,s&&r.jsx("span",{className:"ms-1.5 whitespace-nowrap text-primary-foreground/60",children:s})]})]})}const Ga="OpenCX Live Chat";function eo({transparent:e=!1}={}){return`<!DOCTYPE html>
|
|
31
|
-
<html>
|
|
32
|
-
<head>
|
|
33
|
-
<style>
|
|
34
|
-
${fu}
|
|
35
|
-
html, body {
|
|
36
|
-
height: 100%;
|
|
37
|
-
width: 100%;
|
|
38
|
-
margin: 0;
|
|
39
|
-
padding: 0;
|
|
40
|
-
font-size: 16px;${e?`
|
|
41
|
-
background: transparent;`:""}
|
|
42
|
-
}
|
|
43
|
-
</style>
|
|
44
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">
|
|
45
|
-
</head>
|
|
46
|
-
<body>
|
|
47
|
-
</body>
|
|
48
|
-
</html>`}function Pn({overrides:e,rootRef:t,style:n,shellRadius:o,children:s}){const{cssOverrides:i}=C.useConfig(),{cssVars:a,theme:c}=ue(),{dir:d}=Y(),[l,m]=u.useState(null),p=u.useCallback(f=>{m((f==null?void 0:f.ownerDocument)??null),typeof t=="function"?t(f):t&&(t.current=f)},[t]);Va(l,{scroll:!0});const h={"--opencx-shell-radius":o??c.widgetContentContainer.borderRadius,"--opencx-inset-radius":"max(0.75rem, calc(var(--opencx-shell-radius) - 0.5rem))"};return r.jsxs(r.Fragment,{children:[e?r.jsx("style",{children:e}):null,i?r.jsx("style",{children:i}):null,r.jsx("div",{ref:p,style:{...a,...h,...n},"data-version":gu,dir:d,className:A("antialiased font-sans size-full overflow-hidden relative text-secondary-foreground isolate"),children:r.jsx(vu,{delayDuration:200,disableHoverableContent:!0,children:r.jsx(Wd,{children:s})})})]})}function Ka(){const{contentIframeRef:e}=C.useWidget(),{inline:t}=C.useConfig();return{setWidth:n=>{var o;(o=e==null?void 0:e.current)==null||o.style.setProperty("--opencx-widget-width",t?"100%":n)},setHeight:n=>{var o;(o=e==null?void 0:e.current)==null||o.style.setProperty("--opencx-widget-height",t?"100%":n)}}}function Rt({width:e,height:t}){const{isSmallScreen:n}=ye(),{setWidth:o,setHeight:s}=Ka();u.useEffect(()=>{e&&o(e),t&&s(t)},[n,t,e,o,s])}const ns=T.CircleDashedIcon;function It({name:e,className:t}){const n=(()=>{switch(e){case"Check":return T.CheckIcon;case"CheckCheck":return T.CheckCheckIcon;case"CircleCheck":return T.CircleCheckIcon;case"CircleCheckBig":return T.CircleCheckBigIcon;case"CircleX":return T.CircleXIcon;case"Expand":return T.ExpandIcon;case"Maximize":return T.MaximizeIcon;case"Maximize2":return T.Maximize2Icon;case"Minimize":return T.MinimizeIcon;case"Minimize2":return T.Minimize2Icon;case"Shrink":return T.ShrinkIcon;case"SquareCheck":return T.SquareCheckIcon;case"SquareCheckBig":return T.SquareCheckBigIcon;case"SquareX":return T.SquareXIcon;case"X":return T.XIcon;case"AtSign":return T.AtSignIcon;case"Bot":return T.BotIcon;case"Book":return T.BookIcon;case"BookOpen":return T.BookOpenIcon;case"Building2":return T.Building2Icon;case"Calendar":return T.CalendarIcon;case"CreditCard":return T.CreditCardIcon;case"Database":return T.DatabaseIcon;case"FileText":return T.FileTextIcon;case"Folder":return T.FolderIcon;case"Globe":return T.GlobeIcon;case"Link":return T.LinkIcon;case"Mail":return T.MailIcon;case"Package":return T.PackageIcon;case"Plug":return T.PlugIcon;case"Settings":return T.SettingsIcon;case"ShoppingCart":return T.ShoppingCartIcon;case"Tag":return T.TagIcon;case"Ticket":return T.TicketIcon;case"User":return T.UserIcon;case"Users":return T.UsersIcon;case"Workflow":return T.WorkflowIcon;case"Zap":return T.ZapIcon;case void 0:return ns;default:return G.isExhaustive(e,It.name),ns}})();return r.jsx(n,{className:A("size-4",t)})}function to(e){const{t}=Y(),{session:n}=C.usePrimitiveState(e.ctx.sessionCtx.sessionState),{messages:o}=C.usePrimitiveState(e.ctx.messageCtx.state),s=C.usePrimitiveState(e.ctx.messageCtx.draftState),i=e.title||(n==null?void 0:n.title)||t("companion_chat_number",{count:e.id});let a=(n==null?void 0:n.lastMessage)??s.text??"";for(let l=o.length-1;l>=0;l--){const m=o[l],p=m.type==="USER"?m.content:m.type==="SYSTEM"?"":m.data.message;if(p.trim()){a=p;break}}const c=e.working?t("companion_working"):n!=null&&n.isOpened?t("companion_open"):t(n?"companion_closed":"companion_draft");return{title:!e.hasDraft&&!e.hasSession&&!e.working&&!n&&!e.title&&!o.length&&!s.text&&!s.mentions.length?t("new_conversation"):i,preview:a.replace(/\s+/g," ").trim(),status:c}}function no(){const e=Mn(),[t,n]=u.useState(null),[o,s]=u.useState(!1),[i,a]=u.useState(!1),[c,d]=u.useState(!1),l=u.useRef(!1),m=u.useRef(void 0),p=u.useCallback(()=>clearTimeout(m.current),[]);u.useEffect(()=>p,[p]);const h=u.useCallback((f=!1)=>{p(),l.current=!1,f&&a(!1),s(!1)},[p]);return{anchor:t,open:o,animate:i,autoFocus:c,close:h,toggle(f,x=!1){if(p(),o&&l.current){h(!x);return}l.current=!0,n(f),a(x),d(!0),s(!0)},hover(f){p(),!(!e||o)&&(m.current=setTimeout(()=>{l.current=!1,n(f),a(!0),d(!1),s(!0)},100))},enter:p,leave(){p(),l.current||(m.current=setTimeout(()=>h(),200))}}}function ro(){return r.jsx("style",{children:`
|
|
49
|
-
[data-companion-action] {
|
|
50
|
-
transition: transform 150ms ease-out, background-color 150ms ease-out, color 150ms ease-out, opacity 100ms ease-out;
|
|
51
|
-
}
|
|
52
|
-
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
|
|
53
|
-
[data-companion-action] { transform: translate(var(--wobble-x, 0px), var(--wobble-y, 0px)); }
|
|
54
|
-
[data-companion-action]:hover { transform: translate(var(--wobble-x, 0px), var(--wobble-y, 0px)) scale(var(--scale, .98)); }
|
|
55
|
-
[data-companion-action]:hover:active { transform: translate(var(--wobble-x, 0px), var(--wobble-y, 0px)) scale(calc(var(--scale, .98) - .02)); }
|
|
56
|
-
}
|
|
57
|
-
@media (prefers-reduced-motion: reduce), (pointer: coarse) {
|
|
58
|
-
[data-companion-action] { transform: none !important; transition: none; }
|
|
59
|
-
}
|
|
60
|
-
`})}function Cu({picker:e,...t}){return r.jsxs(r.Fragment,{children:[r.jsx(ro,{}),r.jsx(V,{...t,variant:"ghost",size:"selfless",type:"button","data-companion-action":"","aria-haspopup":"menu","aria-expanded":e.open,onPointerEnter:n=>e.hover(n.currentTarget),onPointerLeave:e.leave,onPointerDown:n=>{e.open&&n.preventDefault()},onClick:n=>{n.stopPropagation(),e.toggle(n.currentTarget,n.detail>0)},onKeyDown:n=>{(n.key==="ArrowDown"||n.key==="ArrowUp")&&(n.preventDefault(),e.toggle(n.currentTarget))}})]})}function Su({chat:e,selected:t,onSelect:n,onClose:o}){const{t:s}=Y(),{title:i,preview:a,status:c}=to(e);return r.jsx(Oe,{children:r.jsxs("div",{"data-chat-row":"","data-companion-action":"","data-selected":t||void 0,children:[r.jsx(_e.RadioItem,{asChild:!0,value:String(e.id),textValue:i,onSelect:d=>{d.preventDefault(),n()},children:r.jsxs("button",{className:hr({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-description":a||void 0,"aria-label":`${i} — ${c}${t?` — ${s("companion_viewing")}`:""}`,"data-chat-select":e.id,children:[r.jsx("span",{"data-chat-indicator":"","aria-hidden":!0,children:r.jsx(_e.ItemIndicator,{children:r.jsx(T.CheckIcon,{size:14})})}),r.jsx("span",{"data-chat-title":"",children:i}),e.working&&r.jsx(T.LoaderCircleIcon,{size:14,"data-working":"","aria-hidden":!0})]})}),r.jsx(_e.Item,{asChild:!0,textValue:s("companion_close_chat",{title:i}),onSelect:d=>{d.preventDefault(),o()},children:r.jsx("button",{className:hr({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-label":s("companion_close_chat",{title:i}),"data-chat-close":e.id,children:r.jsx(T.XIcon,{size:14,"aria-hidden":!0})})})]})})}function oo(e){const{picker:t,portalTarget:n}=e;return t.anchor&&n?r.jsx(Nu,{...e,anchor:t.anchor,portalTarget:n}):null}function Nu({picker:e,anchor:t,portalTarget:n,placement:o,onSelected:s}){const{open:i,animate:a,autoFocus:c,close:d,enter:l,leave:m}=e,{chats:p,activeId:h,selectChat:f,newChat:x,closeChat:g}=C.useCompanionChats(),{canCreateNewSession:j}=C.useSessions(),{t:b,dir:S}=Y(),{cssVars:w,theme:_}=ue(),y=u.useRef(null),v=u.useRef(t.ownerDocument.activeElement),N=u.useCallback(E=>{E&&!y.current&&(v.current=t.ownerDocument.activeElement),y.current=E},[t]),R=u.useRef(!1),M=u.useRef({onClose:d,onSelected:s});M.current={onClose:d,onSelected:s};const z=u.useMemo(()=>({current:{getBoundingClientRect(){let E=t.getBoundingClientRect(),I=t.ownerDocument.defaultView;const H=n.ownerDocument.defaultView;for(;I&&I!==H;){const $=I.frameElement;if(!$)break;const q=$.getBoundingClientRect(),X=q.width/$.offsetWidth||1,B=q.height/$.offsetHeight||1;E=new DOMRect(q.left+E.left*X,q.top+E.top*B,E.width*X,E.height*B),I=$.ownerDocument.defaultView}return E}}}),[t,n]),L=p.filter(E=>E.working).length;u.useEffect(()=>{if(!i||t.ownerDocument===n.ownerDocument)return;const E=H=>{H.composedPath().includes(t)||H.type==="focusin"&&!c&&H.target===v.current||M.current.onClose(H.type==="focusin")},I=t.ownerDocument;return I.addEventListener("pointerdown",E,!0),I.addEventListener("focusin",E),()=>{I.removeEventListener("pointerdown",E,!0),I.removeEventListener("focusin",E)}},[t,n,i,c]),u.useLayoutEffect(()=>{var E,I,H;(E=y.current)==null||E.toggleAttribute("inert",!i),i&&c&&((H=(I=y.current)==null?void 0:I.querySelector('[aria-checked="true"]'))==null||H.focus({preventScroll:!0}))},[i,c]);function O(E){var I,H;t.focus({preventScroll:!0}),E===void 0?x():f(E),M.current.onClose(!0),(H=(I=M.current).onSelected)==null||H.call(I)}function U(E){var $,q,X,B;const I=p.findIndex(F=>F.id===E),H=p[I+1]??p[I-1];E===h?(t.focus({preventScroll:!0}),M.current.onClose(!0)):(q=($=y.current)==null?void 0:$.querySelector(H?`[data-chat-select="${H.id}"]`:"[data-new-chat]"))==null||q.focus({preventScroll:!0}),g(E),E===h&&((B=(X=M.current).onSelected)==null||B.call(X))}return Kt.createPortal(r.jsxs(_e.Root,{open:i,onOpenChange:E=>{!E&&!R.current&&M.current.onClose()},modal:!1,dir:S==="rtl"?"rtl":"ltr",children:[r.jsx(_e.Anchor,{virtualRef:z}),r.jsxs(_e.Content,{ref:N,loop:!0,side:o==="above"?"top":"bottom",align:o==="below"?"start":"center",sideOffset:6,collisionPadding:12,updatePositionStrategy:"always","aria-label":b("companion_chats"),"data-companion-chat-picker":"","data-motion":a?"pointer":"instant",onEntryFocus:E=>{var I,H,$;E.preventDefault(),c?(H=(I=y.current)==null?void 0:I.querySelector('[aria-checked="true"]'))==null||H.focus({preventScroll:!0}):(R.current=!0,($=v.current)==null||$.focus({preventScroll:!0}),R.current=!1)},onCloseAutoFocus:E=>{E.preventDefault()},onEscapeKeyDown:E=>{E.preventDefault(),t.focus({preventScroll:!0}),M.current.onClose(!0)},onFocusOutside:E=>{var I,H;((I=y.current)!=null&&I.contains(E.detail.originalEvent.target)||E.detail.originalEvent.target===t||E.detail.originalEvent.target===((H=t.ownerDocument.defaultView)==null?void 0:H.frameElement)||!c&&E.detail.originalEvent.target===v.current)&&E.preventDefault()},onInteractOutside:E=>{E.detail.originalEvent.composedPath().includes(t)&&E.preventDefault()},onPointerEnter:l,onPointerLeave:m,onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>E.stopPropagation(),onKeyDown:E=>{E.key==="Tab"&&(E.preventDefault(),t.focus({preventScroll:!0}),M.current.onClose(!0))},style:{...w,zIndex:_.widgetContentContainer.zIndex+1,boxSizing:"border-box",width:"min(248px, calc(100vw - 24px))",maxHeight:"min(360px, var(--radix-popper-available-height))",padding:6,borderRadius:10,border:"1px solid hsl(var(--opencx-border) / .5)",background:"hsl(var(--opencx-background))",color:"hsl(var(--opencx-foreground))",boxShadow:"0 4px 16px rgb(0 0 0 / .08), 0 1px 3px rgb(0 0 0 / .06)",font:"13px/1.4 ui-sans-serif, system-ui, sans-serif",overflowY:"auto",outline:"none"},children:[r.jsx(ro,{}),r.jsx("style",{children:`
|
|
61
|
-
[data-companion-chat-picker] {
|
|
62
|
-
transform-origin: var(--radix-popper-transform-origin);
|
|
63
|
-
animation: opencx-menu-in ${be.duration*1e3}ms ${Td};
|
|
64
|
-
}
|
|
65
|
-
[data-companion-chat-picker][data-state="closed"] { animation-name: opencx-menu-out; pointer-events: none; }
|
|
66
|
-
[data-companion-chat-picker][data-motion="instant"] { animation: none; }
|
|
67
|
-
@media (prefers-reduced-motion: reduce) {
|
|
68
|
-
[data-companion-chat-picker] { animation: none !important; }
|
|
69
|
-
}
|
|
70
|
-
@keyframes opencx-menu-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
|
|
71
|
-
@keyframes opencx-menu-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.96); } }
|
|
72
|
-
[data-companion-chat-picker] button {
|
|
73
|
-
display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; min-height: 34px;
|
|
74
|
-
padding: 7px 8px; border: 0; border-radius: 7px; background: transparent;
|
|
75
|
-
color: inherit; font: inherit; text-align: start; cursor: pointer; box-sizing: border-box;
|
|
76
|
-
}
|
|
77
|
-
[data-companion-chat-picker] [data-chat-row] { display: flex; align-items: center; border-radius: 7px; }
|
|
78
|
-
[data-companion-chat-picker] [data-chat-row] + [data-chat-row] { margin-top: 4px; }
|
|
79
|
-
[data-companion-chat-picker] [data-chat-select] { flex: 1; min-width: 0; min-height: 36px; color: hsl(var(--opencx-foreground) / .8); }
|
|
80
|
-
[data-companion-chat-picker] [data-selected] [data-chat-select] { color: hsl(var(--opencx-foreground)); }
|
|
81
|
-
[data-companion-chat-picker] [data-chat-indicator] { width: 14px; height: 14px; display: flex; align-items: center; flex-shrink: 0; color: hsl(var(--opencx-muted-foreground)); }
|
|
82
|
-
[data-companion-chat-picker] [data-selected] [data-chat-indicator],
|
|
83
|
-
[data-companion-chat-picker] [data-working] { color: hsl(var(--opencx-foreground)); }
|
|
84
|
-
[data-companion-chat-picker] [data-chat-title] { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; line-height: 20px; }
|
|
85
|
-
[data-companion-chat-picker] [data-chat-close] { width: 28px; min-height: 28px; padding: 0; margin-inline-end: 4px; flex-shrink: 0; justify-content: center; color: hsl(var(--opencx-muted-foreground)); }
|
|
86
|
-
[data-companion-chat-picker] [data-chat-row]:focus-within { background: hsl(var(--opencx-secondary)); }
|
|
87
|
-
@media (hover: hover) and (pointer: fine) {
|
|
88
|
-
[data-companion-chat-picker] [data-chat-row]:hover,
|
|
89
|
-
[data-companion-chat-picker] [data-new-chat][data-highlighted] { background: hsl(var(--opencx-secondary)); }
|
|
90
|
-
[data-companion-chat-picker] [data-chat-close]:hover { color: hsl(var(--opencx-foreground)); }
|
|
91
|
-
}
|
|
92
|
-
[data-companion-chat-picker] [data-chat-row] button {
|
|
93
|
-
background: transparent; transform: none;
|
|
94
|
-
}
|
|
95
|
-
[data-companion-chat-picker] [data-chat-close][data-highlighted] { color: hsl(var(--opencx-foreground)); }
|
|
96
|
-
[data-companion-chat-picker] button:active { background: hsl(var(--opencx-foreground) / .065); }
|
|
97
|
-
[data-companion-chat-picker] button:focus { outline: none; }
|
|
98
|
-
[data-companion-chat-picker] button:disabled { opacity: .45; cursor: default; }
|
|
99
|
-
@media (pointer: coarse) {
|
|
100
|
-
[data-companion-chat-picker] button, [data-companion-chat-picker] [data-chat-select] { min-height: 48px; }
|
|
101
|
-
[data-companion-chat-picker] [data-chat-close] { width: 48px; min-height: 48px; }
|
|
102
|
-
[data-companion-chat-picker] [data-chat-title], [data-companion-chat-picker] [data-new-chat] { font-size: 16px; }
|
|
103
|
-
}
|
|
104
|
-
[data-companion-chat-picker] svg { flex-shrink: 0; }
|
|
105
|
-
[data-companion-chat-picker] [data-working] { animation: opencx-picker-spin 1.2s linear infinite; }
|
|
106
|
-
@keyframes opencx-picker-spin { to { transform: rotate(360deg); } }
|
|
107
|
-
@media (prefers-reduced-motion: reduce) { [data-companion-chat-picker] [data-working] { animation: none; } }
|
|
108
|
-
`}),r.jsxs(_e.Label,{style:{display:"flex",justifyContent:"space-between",gap:8,padding:"5px 8px 7px",fontSize:12,color:"hsl(var(--opencx-muted-foreground))"},children:[r.jsx("span",{children:b("companion_chats")}),L>0&&r.jsx("span",{role:"status",children:b("companion_working_chats",{count:L})})]}),r.jsx(_e.RadioGroup,{value:String(h),children:p.map(E=>r.jsx(Su,{chat:E,selected:E.id===h,onSelect:()=>O(E.id),onClose:()=>U(E.id)},E.id))}),r.jsx(_e.Separator,{style:{height:1,background:"hsl(var(--opencx-border) / .4)",margin:"5px 4px"}}),r.jsx(_e.Group,{children:r.jsx(_e.Item,{asChild:!0,disabled:!j,onSelect:E=>{E.preventDefault(),O()},children:r.jsxs(V,{variant:"ghost",size:"selfless",type:"button","data-companion-action":"","data-new-chat":"",disabled:!j,children:[r.jsx(T.PlusIcon,{size:14,"aria-hidden":!0}),b("new_conversation")]})})})]})]}),n)}function On(){const[e,t]=u.useState(null);return u.useEffect(()=>{const n=document.createElement("div");return n.setAttribute("data-opencx-root",""),n.style.display="contents",document.documentElement.appendChild(n),t(n),()=>{n.remove(),t(null)}},[]),Va(e,{scroll:!1}),e}function _u(){const{chats:e,openChats:t,activeId:n}=C.useCompanionChats(),o=e.find(f=>f.id===n),s=to(o),{t:i}=Y(),a=no(),c=On(),d=s.title,l=t.filter(f=>f.id!==n),m=l.filter(f=>f.working).length,p=`${i("companion_other_sessions",{count:l.length})}${m?` · ${i("companion_working_chats",{count:m})}`:""}`,h=`${i("companion_switch_chat")}: ${d}${l.length?` · ${p}`:""}`;return r.jsxs(r.Fragment,{children:[r.jsxs(Cu,{picker:a,"data-companion-conversation-title":"",className:"flex h-8 min-w-0 max-w-full items-center gap-1.5 rounded-md px-1 text-[13px] leading-5 text-start hover:bg-muted aria-expanded:bg-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring","aria-label":h,children:[o.working&&r.jsx(T.LoaderCircleIcon,{"aria-label":i("companion_working"),className:"size-3.5 shrink-0 animate-spin motion-reduce:animate-none"}),r.jsx("span",{className:"truncate font-medium",children:d}),l.length>0&&r.jsxs("span",{"data-other-session-count":"",role:"status","aria-atomic":"true",className:"flex shrink-0 items-center gap-1 text-[11px] font-normal text-muted-foreground",children:[r.jsx("span",{className:"sr-only",children:p}),m>0&&r.jsx(T.LoaderCircleIcon,{"data-other-sessions-working":"","aria-hidden":!0,className:"size-3 animate-spin motion-reduce:animate-none"}),r.jsxs("span",{"aria-hidden":!0,className:"tabular-nums",children:["+",l.length]})]}),r.jsx(T.ChevronsUpDownIcon,{"aria-hidden":!0,className:"size-3 shrink-0 text-muted-foreground"})]}),a.anchor&&c&&r.jsx(oo,{picker:a,portalTarget:c,placement:"below"})]})}function Eu(){var n;const e=Be(),t=(n=e.config.customComponents)==null?void 0:n.headerBottom;return t?r.jsx(t,{...e}):null}function Tu({fallback:e}){var o;const t=Be(),n=(o=t.config.customComponents)==null?void 0:o.headerTitle;return n?r.jsx(n,{...t}):e}function Za(e,t,n){var o,s;switch(e){case"chat":return((o=t==null?void 0:t.chatScreen)==null?void 0:o.headerTitle)??n;case"sessions":return((s=t==null?void 0:t.sessionsScreen)==null?void 0:s.headerTitle)??n;case"welcome":case"home":return n;default:return G.isExhaustive(e,Za.name),n}}function Ja(){const{widgetCtx:{org:e}}=C.useWidget(),{routerState:{screen:t}}=C.useWidgetRouter(),{textContent:n}=C.useConfig();return Za(t,n,e.name)}function Au(e){switch(e){case"chat":return P("chat/header");case"sessions":return P("sessions/header");case"welcome":return;case"home":return P("home/header");default:G.isExhaustive(e,Ja.name);return}}function Iu(){const{router:e}=C.useConfig(),{routerState:{screen:t},toLandingScreen:n}=C.useWidgetRouter();return t!=="chat"||e!=null&&e.chatScreenOnly?null:r.jsx(V,{variant:"ghost",size:"fit",className:"rounded-full",onClick:n,children:r.jsx(T.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})})}function zu({button:e}){const{setIsOpen:t}=C.useWidgetTrigger(),{isSmallScreen:n}=ye(),o=Be();if(n&&e.hideOnSmallScreen||!n&&e.hideOnLargeScreen)return null;const s=()=>{var i;e.handleClick?e.handleClick():t(!1),(i=e.onClicked)==null||i.call(e,o)};return r.jsx(V,{variant:"ghost",size:"fit",className:"rounded-full",onClick:s,children:r.jsx(It,{name:e.icon})})}function br({button:e}){const[t,n]=u.useState(!1),{routerState:{screen:o}}=C.useWidgetRouter(),{isSmallScreen:s}=ye(),{theme:i}=ue(),{setWidth:a,setHeight:c}=Ka(),d=Be();if(o!=="chat"&&o!=="sessions")return null;const l=(()=>{switch(o){case"chat":return i.screens.chat.height;case"sessions":return i.screens.sessions.height;default:return G.isExhaustive(o,br.name),i.screens.chat.height}})(),m=(()=>{switch(o){case"chat":return i.screens.chat.width;case"sessions":return i.screens.sessions.width;default:return G.isExhaustive(o,br.name),i.screens.chat.width}})(),p=()=>{var h;n(f=>{const x=!f;return c(x?"100vh":l),a(x?`max(40vw, ${m})`:m),x}),(h=e.onClicked)==null||h.call(e,d)};return s&&e.hideOnSmallScreen||!s&&e.hideOnLargeScreen?null:r.jsx(V,{variant:"ghost",size:"fit",className:"rounded-full",onClick:p,children:r.jsx(It,{name:e.icon||(t?e.shrinkIcon:e.expandIcon)})})}function Qa({button:e}){var b,S;const{close:t}=Rn(),{widgetCtx:n}=C.useWidget(),{setIsOpen:o}=C.useWidgetTrigger(),{resolveSession:s,sessionState:i}=C.useSessions(),{isSmallScreen:a}=ye(),c=Be(),{t:d}=Y(),l=!i.session,m=((b=i.session)==null?void 0:b.isOpened)===!1,p=e.onResolved||"stay-in-chat",h=e.behaviorBeforeSessionCreation||"disabled",f=e.behaviorIfSessionIsResolved||"disabled",x=!!(i.isResolvingSession||l&&h==="disabled"||m&&f==="disabled"),g=async()=>{const{success:w,error:_}=await s();if(t(),!w)return G.log.error("failed to resolve session",_),!1;switch(p){case"stay-in-chat":break;case"close-widget":o(!1);break;case"reset-chat":n.resetChat();break;case"reset-chat-and-close-widget":o(!1),n.resetChat();break;default:G.isExhaustive(p,Qa.name);break}return!0},j=()=>{if(l)switch(h){case"disabled":return;case"close-widget":o(!1);break;default:G.isExhaustive(h,j.name)}if(m)switch(f){case"disabled":return;case"close-widget":o(!1);break;case"reset-chat":n.resetChat();break;case"reset-chat-and-close-widget":o(!1),setTimeout(()=>{n.resetChat()},200);break;default:G.isExhaustive(f,j.name)}};return a&&e.hideOnSmallScreen||!a&&e.hideOnLargeScreen?null:((S=e.confirmation)==null?void 0:S.type)==="modal"&&!m&&!l?r.jsx(nn,{trigger:r.jsx(V,{variant:"ghost",size:"fit",className:"rounded-full",disabled:x,onClick:()=>{var w;return(w=e.onClicked)==null?void 0:w.call(e,c)},children:r.jsx(It,{name:e.icon})}),children:r.jsxs(tn,{children:[r.jsx(Ur,{children:r.jsx(qr,{children:e.confirmation.title||d("close_conversation_title")})}),r.jsx(Br,{children:r.jsx(Vr,{children:e.confirmation.description||d("close_conversation_description")})}),r.jsxs(Da,{children:[r.jsx(V,{variant:"secondary",onClick:t,disabled:i.isResolvingSession,children:e.confirmation.cancelButtonText||d("close_conversation_cancel")}),r.jsx(V,{variant:"destructive",onClick:async()=>{var _,y;await g()&&((y=(_=e.confirmation)==null?void 0:_.onResolved)==null||y.call(_,c))},disabled:i.isResolvingSession,children:e.confirmation.confirmButtonText||d("close_conversation_confirm")})]})]})}):r.jsx(V,{variant:"ghost",size:"fit",className:"rounded-full",onClick:()=>{var w;m||l?j():g(),(w=e.onClicked)==null||w.call(e,c)},disabled:x,children:r.jsx(It,{name:e.icon})})}function wr({button:e}){switch(e.functionality){case"close-widget":return r.jsx(zu,{button:e});case"expand-shrink":return r.jsx(br,{button:e});case"resolve-session":return r.jsx(Qa,{button:e});default:return G.isExhaustive(e,wr.name),null}}const Mu={functionality:"close-widget",hideOnLargeScreen:!0,icon:"X"};function Ru(){const{routerState:{screen:e}}=C.useWidgetRouter(),{headerButtons:t}=C.useConfig(),n=e==="chat"?t==null?void 0:t.chatScreen:e==="sessions"?t==null?void 0:t.sessionsScreen:[];return!n||n.length===0?r.jsx(wr,{button:Mu}):r.jsx(r.Fragment,{children:n.map(o=>r.jsx(wr,{button:o},`${o.functionality}-${o.icon}`))})}function ei(){const e=C.useConfig(),t=e.displayMode==="companion"&&!e.inline,{routerState:{screen:n}}=C.useWidgetRouter(),o=Au(n),s=Ja();return r.jsxs("header",{...o,className:"py-2 px-4 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2",style:{paddingInlineEnd:t?64:void 0},children:[r.jsx(Iu,{}),r.jsx("div",{className:A("min-w-0 flex-1 h-8 flex items-center",n==="sessions"&&"ps-2"),children:r.jsx(Tu,{fallback:t&&n!=="sessions"?r.jsx(_u,{}):r.jsx("h2",{className:"font-semibold",children:s})})}),r.jsx(Ru,{})]}),r.jsx(Eu,{})]})}function ti({className:e}){return r.jsx(T.LoaderIcon,{className:A("size-4 animate-spin",e)})}function Pu(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{isSmallScreen:t}=ye(),{activeMode:n,Component:o}=C.useModes();return{isCanvasOpen:!e&&!t&&!!n&&!!o}}function Ou({isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n,...o}){const{componentStore:s}=C.useWidget();if(o.type!=="AGENT"&&o.type!=="AI")return null;if(o.data.action){const a=s.getComponent(o.data.action.name);if(a)return r.jsx(a,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}const i=s.getComponent(o.component);return i?r.jsx(i,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n}):r.jsx(gr,{...o,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}function qt({suggestion:e,className:t,...n}){const o=rn(),s=()=>{const i=e.trim();i&&o({content:i})};return r.jsx(V,{...P("chat/suggested_reply_btn"),size:"sm",className:A("rounded-xl w-fit",t),...n,onClick:s,children:e})}function ni({messages:e,className:t,containerClassName:n}){var a,c;const{timestamps:o}=C.useConfig();if(!((a=o==null?void 0:o.perMessageGroup)!=null&&a.enabled))return null;const s=(c=e[e.length-1])==null?void 0:c.timestamp;if(!s)return null;const i=(()=>{try{return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}catch(d){return G.log.error("failed to format timestamp",d),null}})();return i?r.jsx("div",{className:n,children:r.jsx("span",{className:A("text-xs text-muted-foreground",t),children:i})}):null}const $u=2e3;function Lu(e){return e.map(t=>Ua(t.data.message).trim()).filter(t=>t.length>0).join(`
|
|
109
|
-
|
|
110
|
-
`)}function ri(){const{messageActions:e}=C.useConfig(),t=C.useDisplayMode();return(e==null?void 0:e.copy)??t==="companion"}function oi({messages:e}){const{t}=Y(),{messageActions:n}=C.useConfig(),o=(n==null?void 0:n.display)==="always",[s,i]=u.useState(!1),a=u.useRef(null);u.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const c=Lu(e),d=typeof navigator<"u"?navigator.clipboard:void 0;if(!d||c.length===0)return null;const l=()=>{d.writeText(c).then(()=>{i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),$u)},p=>G.log.warn("copying the reply failed",p))},m=t(s?"copied":"copy_reply");return r.jsx("div",{...P("chat/agent_msg_group/actions"),className:A("flex items-center gap-1 -mt-0.5 transition-opacity duration-150",o?"opacity-100":A("opacity-0 group-hover:opacity-100 focus-within:opacity-100","[@media(hover:none)]:opacity-100")),children:r.jsx(Ie,{content:m,side:"bottom",align:"start",children:r.jsx("button",{...P("chat/agent_msg_group/actions/copy"),type:"button","aria-label":m,"aria-live":"polite",onClick:l,className:A("flex size-6 items-center justify-center rounded-md","text-muted-foreground/70 hover:bg-muted hover:text-foreground","transition-colors active:scale-95"),children:s?r.jsx(T.CheckIcon,{className:"size-3.5"}):r.jsx(T.CopyIcon,{className:"size-3.5"})})})})}function Du(e){return e.type==="AI"&&e.data.variant!=="error"}function Sn({messages:e,agent:t,suggestedReplies:n,actions:o=!0}){const s=ri(),i=e.filter(Du);return r.jsxs("div",{...P("chat/agent_msg_group/root"),className:A("group flex items-end gap-2"),children:[r.jsx(Ie,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(xr,{...P("chat/agent_msg_group/root/avatar"),agent:t,className:"hidden"})}),r.jsxs("div",{className:A("flex-1 flex flex-col gap-1"),children:[r.jsxs("div",{...P("chat/agent_msg_group/avatar_and_msgs/root"),className:A("flex items-end gap-2"),children:[r.jsx(Ie,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(xr,{...P("chat/agent_msg_group/avatar_and_msgs/avatar"),agent:t})}),r.jsxs("div",{...P("chat/agent_msg_group/avatar_and_msgs/msgs"),className:A("flex-1 flex flex-col gap-1"),children:[e.map((a,c,d)=>r.jsx(Ou,{isFirstInGroup:c===0,isLastInGroup:c===d.length-1,isAloneInGroup:d.length===1,...a},a.id)),r.jsx(ni,{messages:e}),o&&s&&i.length>0&&r.jsx(oi,{messages:i})]})]}),n&&n.length>0&&r.jsx("div",{...P("chat/agent_msg_group/suggestions"),className:A("flex flex-col gap-1 ps-8"),children:n==null?void 0:n.map((a,c)=>r.jsx(qt,{suggestion:a},`${a}-${c}`))})]})]})}const rs=["⠏","⠗","⠧","⠷","⠾","⠽","⠻","⠟"];function so({className:e}){const t=W.useReducedMotion(),[n,o]=u.useState(0);return u.useEffect(()=>{if(t)return;const s=setInterval(()=>o(i=>(i+1)%rs.length),80);return()=>clearInterval(s)},[t]),r.jsx("span",{className:A("select-none",e),"aria-hidden":!0,children:rs[n]})}function os({turn:e,agent:t,timestamp:n}){const{componentStore:o,config:s,widgetCtx:i}=C.useWidget(),a=ri(),c=o.getComponent("agent_chat_steps"),d=o.getComponent("agent_chat_spec"),l=o.getComponent("loading"),[m]=u.useState(()=>new Date().toISOString()),p=n??m,h=G.resolveClientPresentation(i.agent.presentation,s.presentation),f=C.applyPresentation(e.items,h),x=e.active&&(h==null?void 0:h.streaming)===!1&&!f.some(g=>g.kind==="questions");return r.jsxs("div",{...P("chat/streaming_turn/root"),className:"group flex flex-col gap-2",children:[f.map((g,j)=>g.kind==="text"?r.jsx(Sn,{messages:[{id:`streaming-${j}`,type:"AI",component:"bot_message",timestamp:p,data:{message:g.text},agent:t}],agent:t,actions:!1},`text-${j}`):g.kind==="spec"?d&&r.jsx(d,{parts:g.parts,active:e.active},`spec-${j}`):g.kind==="questions"||g.kind==="plan"||g.kind==="connection"?null:c&&r.jsx(c,{active:e.active,steps:g.steps},`steps-${j}`)),x&&l?r.jsx(l,{agent:t}):e.active&&!Fu(f)&&r.jsx("div",{...P("chat/streaming_turn/working"),className:"flex h-5 items-center ps-1",children:r.jsx(so,{className:"text-[14px] leading-none text-primary/70"})}),!e.active&&a&&r.jsx(oi,{messages:f.flatMap(g=>g.kind==="text"?[{data:{message:g.text}}]:[])})]})}function Fu(e){const t=e.at(-1);return(t==null?void 0:t.kind)==="steps"&&t.steps.some(n=>!n.done)}function Hu({parts:e,active:t=!1}){const n=u.useMemo(()=>Nd(e),[e]);return r.jsx(Ra,{spec:n,active:t})}function Wu({plan:e,active:t}){const[n,o]=u.useState(!1),s=u.useId(),i=W.useReducedMotion(),a=e.filter(m=>m.status==="completed").length,c=e.find(m=>m.status==="in_progress")??e.find(m=>m.status==="pending")??e[0],d=2*Math.PI*8,l=d*(1-(e.length>0?a/e.length:0));return r.jsxs("div",{className:"overflow-hidden rounded-xl border border-primary/10 bg-background shadow-sm","data-task-plan":!0,children:[r.jsxs("button",{type:"button",onClick:()=>o(m=>!m),"aria-expanded":n,"aria-controls":s,className:"flex w-full cursor-pointer items-center gap-3 px-3.5 py-2.5 text-start hover:bg-primary/[0.02] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/40",children:[r.jsxs("svg",{"aria-hidden":"true",className:"size-5 shrink-0 -rotate-90",viewBox:"0 0 20 20",children:[r.jsx("circle",{cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-primary/10"}),r.jsx(W.motion.circle,{cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:d,initial:!1,animate:{strokeDashoffset:l},transition:i?{duration:0}:ze,className:"text-emerald-600 dark:text-emerald-400"})]}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-primary",children:c==null?void 0:c.step}),r.jsxs("span",{className:"shrink-0 text-[0.8125rem] tabular-nums text-primary/50",children:[a,"/",e.length]}),r.jsx(W.motion.span,{"aria-hidden":"true",className:"flex size-3.5 shrink-0 items-center justify-center text-primary/50",initial:!1,animate:{rotate:n?0:180},transition:i?{duration:0}:be,children:r.jsx(T.ChevronUp,{className:"size-3.5"})})]}),r.jsx("div",{id:s,"aria-hidden":!n,children:r.jsx(W.AnimatePresence,{initial:!1,children:n&&r.jsx(W.motion.div,{initial:{height:i?"auto":0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:i?"auto":0,opacity:0,transition:be},transition:i?be:ze,className:"overflow-hidden",children:r.jsx("ol",{className:"max-h-60 overflow-y-auto border-t border-primary/10 px-3.5 py-2",children:e.map((m,p)=>r.jsxs("li",{className:"flex items-start gap-2.5 py-1.5 text-sm","data-plan-status":m.status,children:[r.jsx("span",{"aria-hidden":"true",className:A("relative mt-0.5 size-4 shrink-0",!t&&"[&_.animate-spin]:animate-none"),children:r.jsx(W.AnimatePresence,{initial:!1,children:r.jsx(W.motion.span,{className:"absolute inset-0 flex items-center justify-center",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:be,children:m.status==="completed"?r.jsx("span",{className:"flex size-4 items-center justify-center rounded-full bg-emerald-500/10",children:r.jsx(T.Check,{className:"size-2.5 text-emerald-600 dark:text-emerald-400"})}):m.status==="in_progress"?t?r.jsx(T.Loader2,{className:"size-4 animate-spin text-primary/60 motion-reduce:animate-none"}):r.jsx(T.CircleDashed,{className:"size-4 text-primary/40"}):r.jsx("span",{className:"size-1.5 rounded-full bg-primary/25"})},m.status)})}),r.jsx("span",{className:A(m.status==="completed"?"text-primary/50 line-through":m.status==="in_progress"?"font-medium text-primary":"text-primary/60"),children:m.step})]},p))})},"plan-steps")})})]})}function si(){var n,o;const e=Be();if((n=e.session)!=null&&n.isOpened||!e.session)return null;const t=(o=e.config.customComponents)==null?void 0:o.onSessionResolved;return t?r.jsx(t,{...e}):null}function ai(){var n;const e=Be(),t=(n=e.config.customComponents)==null?void 0:n.chatBottomComponents;return t?r.jsx("div",{children:t.map(({key:o,component:s})=>r.jsx(s,{...e},o))}):null}function ii(e){const t=[];let n=null;return e.forEach(o=>{var s,i,a,c,d,l;(((s=n==null?void 0:n[0])==null?void 0:s.type)!==o.type||((i=n[0])==null?void 0:i.type)==="AGENT"&&o.type==="AGENT"&&(((a=o.agent)==null?void 0:a.id)!==((c=n[0].agent)==null?void 0:c.id)||((d=o.agent)==null?void 0:d.name)!==((l=n[0].agent)==null?void 0:l.name)))&&(n=[],t.push(n)),n.push(o)}),t}function vr(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="USER"}function Uu(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AI"}function Bu(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AGENT"}function ci(){const{messagesState:{messages:e}}=C.useMessages(),{chatBannerItems:t}=C.useConfig();return!(t!=null&&t.length)||e.length>0&&t.every(n=>!n.persistent)?null:r.jsx("div",{className:"w-full text-center text-xs",children:t.map(({message:n,persistent:o},s)=>e.length>0&&!o?null:r.jsx("div",{children:r.jsx(Yr,{children:n})},`${n}-${s}`))})}const qu=10*1024,ss=new Map;function Vu(e){const t=ss.get(e);if(t!==void 0)return t;const n=Yu(e);return ss.set(e,n),n}function Yu(e){const t=e.trim();if(!t||t.length>qu||typeof DOMParser>"u")return null;const n=new DOMParser().parseFromString(t,"image/svg+xml"),o=n.documentElement;return o.localName!=="svg"||o.namespaceURI!=="http://www.w3.org/2000/svg"||n.getElementsByTagName("parsererror").length>0?null:`data:image/svg+xml,${encodeURIComponent(t)}`}const Xu=Xs.cva("inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"bg-primary text-primary-foreground",secondary:"bg-secondary text-secondary-foreground",outline:"border text-foreground"}},defaultVariants:{variant:"default"}});function Gu({className:e,variant:t,...n}){return r.jsx("div",{className:A(Xu({variant:t}),e),...n})}function li({customStatus:e,className:t,dotClassName:n}){const o=e.icon?Vu(e.icon):null,s=e.color||"currentColor";return o?r.jsx("span",{"aria-hidden":!0,className:A("size-3.5 shrink-0",t),style:{backgroundColor:s,maskImage:`url("${o}")`,maskSize:"contain",maskRepeat:"no-repeat",maskPosition:"center",WebkitMaskImage:`url("${o}")`,WebkitMaskSize:"contain",WebkitMaskRepeat:"no-repeat",WebkitMaskPosition:"center"}}):r.jsx("span",{"aria-hidden":!0,className:A("size-2 shrink-0 rounded-full",n),style:{backgroundColor:s}})}function di({customStatus:e,className:t}){return r.jsxs(Gu,{variant:"secondary",className:A("relative isolate overflow-hidden max-w-full text-primary",t),title:e.description||void 0,style:e.color?{color:`color-mix(in srgb, ${e.color} 55%, hsl(var(--opencx-foreground)))`}:void 0,children:[e.color&&r.jsx("span",{"aria-hidden":!0,className:"absolute inset-0 -z-10 opacity-20",style:{backgroundColor:e.color}}),r.jsx(li,{customStatus:e}),r.jsx("span",{className:"truncate",children:e.name})]})}function ui(){const{sessionState:{session:e}}=C.useSessions(),t=e==null?void 0:e.customStatus;return r.jsx(W.AnimatePresence,{mode:"wait",children:t&&r.jsx(ee,{className:"sticky top-2 z-10 self-center max-w-full",snapExit:!0,children:r.jsx(nn,{trigger:r.jsx(V,{variant:"ghost",size:"selfless",className:"rounded-full",children:r.jsx(di,{customStatus:t})}),children:r.jsxs(tn,{withClose:!0,children:[r.jsxs(Ur,{children:[r.jsx(li,{customStatus:t,className:"size-8 mx-auto",dotClassName:"size-3 mx-auto"}),r.jsx(qr,{children:t.name})]}),t.description&&r.jsx(Br,{children:r.jsx(Vr,{children:t.description})})]})})},t.id)})}function pi(){var c;const{messagesState:{messages:e}}=C.useMessages(),t=C.useConfig(),n=C.useBot(),{advancedInitialMessages:o=[],initialQuestions:s,initialQuestionsPosition:i}=t;if(e.length>0)return null;const a=o.length?o.map(d=>d.message):(c=t.initialMessages)!=null&&c.length?t.initialMessages:["Hello, how can I help you?"];return r.jsx(Sn,{messages:a.map((d,l)=>({component:"bot_message",data:{message:d},id:`${l}-${d}`,type:"AI",timestamp:null})),suggestedReplies:i==="below-initial-messages"?s:void 0,agent:n})}function mi({src:e,alt:t,title:n,note:o,shape:s="strip",className:i,children:a,...c}){const d=s==="tile";return r.jsxs("div",{...c,className:A("relative overflow-hidden bg-background ring-1 ring-border",d?"size-12 shrink-0 rounded-2xl":"max-w-full rounded-xl",i),children:[r.jsx("img",{src:e,alt:t,title:n,draggable:!1,className:A("block object-cover object-left-top",d?"size-full":"h-10 w-auto max-w-40")}),o&&r.jsx("div",{className:A("absolute inset-x-0 bottom-0 truncate px-1.5 py-0.5","bg-gradient-to-t from-foreground/70 to-foreground/0","text-[10px] font-medium leading-tight text-background"),children:o}),a]})}const ao=["#opencx-root","[data-opencx-root]","[data-opencx-overlay]"],gt='input,textarea,select,[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="searchbox"],[role="combobox"]',Ku=[...ao,"[data-opencx-private]",'[aria-hidden="true"]',"[hidden]","script","style","noscript"].join(",");function hi(e){var n;if(e.matches(Ku))return!0;const t=(n=e.ownerDocument.defaultView)==null?void 0:n.getComputedStyle(e);return(t==null?void 0:t.display)==="none"||(t==null?void 0:t.visibility)==="hidden"||(t==null?void 0:t.visibility)==="collapse"||(t==null?void 0:t.opacity)==="0"}function Me(e){for(let t=e;t;t=t.parentElement)if(hi(t))return!0;return!1}function fi(e){if(Me(e)||e.closest(gt))return"";const t=[],n=o=>{if(o instanceof Element){if(o!==e&&hi(o)||o.matches(gt))return;const s=/^(ADDRESS|ARTICLE|ASIDE|BLOCKQUOTE|BR|DD|DETAILS|DIV|DL|DT|FIELDSET|FIGCAPTION|FIGURE|FOOTER|FORM|H[1-6]|HEADER|HR|LI|MAIN|NAV|OL|P|PRE|SECTION|SUMMARY|TABLE|TD|TH|TR|UL)$/.test(o.tagName);s&&t.push(" "),o.childNodes.forEach(n),s&&t.push(" ")}else o.nodeType===Node.TEXT_NODE&&t.push(o.textContent??"")};return n(e),t.join("").replace(/\s+/g," ").trim()}function io(e){try{const t=new URL(e,window.location.href);return t.protocol==="http:"||t.protocol==="https:"?`${t.origin}${t.pathname}`:""}catch{return""}}function Vt(e){return e.getRootNode()===document&&!Me(e)&&!e.closest(gt)&&!e.matches("canvas,iframe,video,object,embed")&&!Array.from(e.querySelectorAll("*")).some(t=>Me(t)||t.matches(`${gt},canvas,iframe,video,object,embed`))}const Zu=480,Ju=3e3,Yt=new WeakMap,yr=new WeakMap;async function Qu(e){if(!Vt(e))return null;const t=e.getBoundingClientRect();if(t.width<1||t.height<1)return null;const n=Math.min(2,Math.max(.5,Zu/Math.max(t.width,t.height))),o=wc.toJpeg(e,{quality:.85,pixelRatio:n,backgroundColor:"#ffffff",filter:i=>!(i instanceof Element)||Vt(i)}),s=new Promise(i=>setTimeout(()=>i(null),Ju));try{return await Promise.race([o,s])}catch{return null}}function ep(e,t){yr.set(e,t),Yt.set(e,Qu(t))}const kr=new WeakMap;function tp(e,t){if(kr.has(e))return;const n=Yt.get(e);if(!n)return;const o=n.then(s=>{const i=yr.get(e);if(!(i!=null&&i.isConnected)||!Vt(i))return null;const a=s?rp(s,"page-mark.jpg"):null;return a?t(a):null}).catch(()=>null).then(s=>{const i=yr.get(e);return!(i!=null&&i.isConnected)||!Vt(i)?null:(s&&(e.snapshotUrl=s),s)});kr.set(e,o)}async function np(e,t){if(e.snapshotUrl)return e.snapshotUrl;const n=kr.get(e);if(!n)return null;const o=new Promise(s=>setTimeout(()=>s(null),t));return Promise.race([n,o])}function rp(e,t){const n=/^data:([^;,]+);base64,([\s\S]*)$/.exec(e);if(!n)return null;const[,o,s]=n;if(!o||s===void 0)return null;try{const i=atob(s),a=new Uint8Array(i.length);for(let c=0;c<i.length;c++)a[c]=i.charCodeAt(c);return new File([a],t,{type:o})}catch{return null}}function op(e){return Yt.get(e)}function sp(e,t){const n=Yt.get(e);n&&Yt.set(t,n)}function gi(e){const[t,n]=u.useState(null);return u.useEffect(()=>{var s;if(n(null),!e)return;let o=!1;return(s=op(e))==null||s.then(i=>{!o&&i&&n(i)}),()=>{o=!0}},[e]),t}function ap({element:e}){const t=gi(e.mark)??e.snapshotUrl??null,n=e.note??e.name;return t?r.jsx(mi,{src:t,alt:n,title:e.name,note:e.note}):r.jsxs("span",{className:A("inline-flex items-center gap-1.5 max-w-48","rounded-full py-1 ps-2 pe-2.5","bg-background ring-1 ring-border","text-xs text-foreground"),title:e.name,children:[r.jsx(T.PenLineIcon,{className:"size-3 shrink-0 text-primary"}),r.jsx("span",{className:"truncate",children:n})]})}const ip=150,cp=40,lp=3;function dp(e,t){const n=new Map;for(const i of e){const a=n.get(i.type);a?a.push(i):n.set(i.type,[i])}const o=[],s=[];for(const[i,a]of Array.from(n)){const c=t.has(i)?a:a.slice(0,lp);o.push({type:i,items:c,hidden:a.length-c.length}),s.push(...c)}return{groups:o,visible:s}}function up(e,t){const n=e.slice(0,t),o=/(?:^|\s)@(\S*)$/.exec(n);return o?{start:t-o[1].length-1,query:o[1]}:null}function pp(e,t){const n=t.trim().toLowerCase();if(!n)return[...e];const o=s=>{var a;const i=s.title.toLowerCase();return i.startsWith(n)?0:i.includes(n)?1:(a=s.description)!=null&&a.toLowerCase().includes(n)?2:-1};return e.map((s,i)=>({item:s,index:i,rank:o(s)})).filter(s=>s.rank>=0).sort((s,i)=>s.rank-i.rank||s.index-i.index).map(s=>s.item)}const Ut=e=>`@${e.title}`;function as(e,t){const n=[];for(const o of t){const s=Ut(o);let i=0;for(;;){const a=e.indexOf(s,i);if(a===-1)break;n.push({start:a,end:a+s.length}),i=a+s.length}}return n}function mp({text:e,setText:t,inputRef:n}){const{mentions:o}=C.useConfig(),{widgetCtx:s}=C.useWidget(),i=o==null?void 0:o.items,a=o==null?void 0:o.search,c=u.useMemo(()=>{if(a)return a;if(i)return I=>pp(i,I)},[a,i]),d=!!c&&s.features.pageContext,{mentions:l,setMentions:m}=C.useComposerDraft(),[p,h]=u.useState(null),[f,x]=u.useState([]),[g,j]=u.useState(()=>new Set),[b,S]=u.useState(0),[w,_]=u.useState(!1),{groups:y,visible:v}=u.useMemo(()=>dp(f,g),[g,f]);u.useEffect(()=>{m(I=>{const H=I.filter($=>e.includes(Ut($)));return H.length===I.length?I:H})},[e,m]);const N=u.useCallback((I="nearest")=>{if(!d)return;const H=n.current;let $=(H==null?void 0:H.selectionStart)??e.length;if(H&&H.selectionStart===H.selectionEnd){const B=as(e,l).find(F=>$>F.start&&$<F.end);B&&($=I==="forward"?B.end:I==="backward"||$-B.start<B.end-$?B.start:B.end,H.setSelectionRange($,$))}const q=up(e,$),X=q&&l.some(B=>e.startsWith(Ut(B),q.start))?null:q;h(B=>(B==null?void 0:B.start)===(X==null?void 0:X.start)&&(B==null?void 0:B.query)===(X==null?void 0:X.query)?B:X)},[d,n,l,e]);u.useEffect(()=>N(),[N]);const R=u.useRef(0);u.useEffect(()=>{if(!p||!c){x([]),_(!1);return}const I=++R.current;_(!0);const H=setTimeout(()=>{Promise.resolve().then(()=>c(p.query)).then($=>{I===R.current&&(x($.slice(0,cp)),j(new Set),S(0),_(!1))},$=>{I===R.current&&(G.log.warn("mentions search failed",$),x([]),_(!1))})},ip);return()=>clearTimeout(H)},[p,c]);const M=u.useCallback(()=>{R.current+=1,h(null),x([]),_(!1)},[]),z=u.useCallback(I=>{if(!p)return;const H=p.start+1+p.query.length,$=`${Ut(I)} `,q=e.slice(0,p.start)+$+e.slice(H);t(q),m(B=>B.some(F=>F.type===I.type&&F.id===I.id)?B:[...B,I]),M();const X=p.start+$.length;requestAnimationFrame(()=>{const B=n.current;B&&(B.focus(),B.setSelectionRange(X,X))})},[p,M,n,t,m,e]),L=u.useCallback(I=>{j(H=>new Set(H).add(I))},[]),O=d&&p!==null,U=u.useCallback(I=>{const H=n.current;if(d&&H&&H.selectionStart===H.selectionEnd&&(I.key==="Backspace"||I.key==="Delete")){const $=H.selectionStart,q=as(e,l).find(X=>I.key==="Backspace"?X.end===$:X.start===$);if(q){I.preventDefault();const X=e[q.end]===" "?q.end+1:q.end;return t(e.slice(0,q.start)+e.slice(X)),requestAnimationFrame(()=>H.setSelectionRange(q.start,q.start)),!0}}if(!O)return!1;if(I.key==="Escape")return I.preventDefault(),M(),!0;if(v.length===0)return!1;if(I.key==="ArrowDown")return I.preventDefault(),S($=>($+1)%v.length),!0;if(I.key==="ArrowUp")return I.preventDefault(),S($=>($-1+v.length)%v.length),!0;if(I.key==="Enter"||I.key==="Tab"){I.preventDefault();const $=v[b];return $&&z($),!0}return!1},[M,d,b,n,O,z,l,t,e,v]),E=u.useCallback(()=>{m([]),M()},[M,m]);return u.useMemo(()=>({picked:l,isOpen:O,anchorIndex:(p==null?void 0:p.start)??null,preview:(o==null?void 0:o.preview)!==!1,groups:y,visible:v,expandGroup:L,searching:w,highlighted:b,setHighlighted:S,pick:z,onKeyDown:U,onCaretMove:N,reset:E}),[l,O,p,o==null?void 0:o.preview,y,v,L,w,b,z,U,N,E])}function xi({text:e,mentions:t,tokenClassName:n}){if(!t||t.length===0)return r.jsx(r.Fragment,{children:e});const o=Array.from(new Set(t.map(Ut))).sort((c,d)=>d.length-c.length),s=[];let i=e,a=0;for(;i.length>0;){let c=-1,d="";for(const l of o){const m=i.indexOf(l);m!==-1&&(c===-1||m<c)&&(c=m,d=l)}if(c===-1){s.push(i);break}c>0&&s.push(i.slice(0,c)),s.push(u.createElement("span",{...P("chat/mention"),key:a++,className:A("rounded-sm px-0.5 -mx-0.5",n)},d)),i=i.slice(c+d.length)}return r.jsx(r.Fragment,{children:s})}function hp({message:e,isFirstInGroup:t,isLastInGroup:n,isAloneInGroup:o}){var s;return r.jsxs("div",{...P("chat/user_msg/root"),"data-message-id":e.id,className:"w-5/6 flex flex-col items-end gap-1",children:[e.markedElements&&e.markedElements.length>0&&r.jsx("div",{...P("chat/user_msg/marked_elements"),className:"w-full flex gap-1 flex-wrap justify-end",children:e.markedElements.map((i,a)=>r.jsx(ap,{element:i},`${i.name}-${a}`))}),e.attachments&&e.attachments.length>0&&r.jsx("div",{className:"w-full flex gap-1 flex-wrap justify-end",children:(s=e.attachments)==null?void 0:s.map(i=>r.jsx(Ha,{attachment:i},i.id))}),e.content.length>0&&r.jsx("div",{...P("chat/user_msg/msg"),"data-first":t,"data-last":n,"data-alone":o,"data-pending":e.pending===!0,className:A("transition-all","w-fit py-3 px-4 rounded-3xl text-sm","bg-primary text-primary-foreground",e.pending&&"opacity-60","break-words [word-break:break-word]","whitespace-pre-wrap",t&&!o&&"rounded-br-md",n&&!o&&"rounded-tr-md",!t&&!n&&!o&&"rounded-r-md"),children:r.jsx(xi,{text:e.content,mentions:e.mentions,tokenClassName:"bg-primary-foreground/20 font-medium"})})]})}function fp({messages:e}){return r.jsxs("div",{...P("chat/user_msg_group/root"),className:A("group","flex flex-col gap-1 justify-end items-end"),children:[e.map((t,n,o)=>r.jsx(hp,{message:t,isFirstInGroup:n===0,isLastInGroup:n===o.length-1,isAloneInGroup:o.length===1},t.id)),r.jsx(ni,{messages:e,containerClassName:"ms-auto"})]})}function jr({groups:e,pendingReply:t=!1}){const{humanAgent:n}=C.useConfig(),o=C.useBot();return r.jsx(r.Fragment,{children:e.map((s,i)=>{var c,d;const a=(c=s[0])==null?void 0:c.id;if(!a)return null;if(vr(s))return r.jsx(fp,{messages:s},a);if(Uu(s))return r.jsx(Sn,{messages:s,agent:o,actions:!t||i!==e.length-1},a);if(Bu(s)){const l=(d=s[0])==null?void 0:d.agent;return r.jsx(Sn,{messages:s,agent:l?{...l,name:(n==null?void 0:n.name)||l.name||"",avatarUrl:(n==null?void 0:n.avatarUrl)||l.avatarUrl||null}:n?{isAi:!1,id:null,name:n.name||"",avatarUrl:n.avatarUrl||null}:void 0},a)}return null})})}const gp=150;function xp({scrollHeight:e,scrollTop:t,clientHeight:n},o=gp){return e-t-n<o}function bp(e){const t=u.useRef(null),n=u.useRef(!0),[o,s]=u.useState(!1),i=u.useRef(null),[a]=u.useState(()=>new Set),c=u.useCallback(()=>{const l=t.current,m=l?xp(l):!0;n.current=m,s(!m)},[]),d=u.useCallback(()=>{const l=t.current;l&&(l.scrollTo({top:l.scrollHeight,behavior:"smooth"}),n.current=!0,s(!1))},[]);return u.useEffect(()=>{if(!n.current)return;const l=setTimeout(()=>{const m=t.current;m&&(m.scrollTop=m.scrollHeight)},0);return()=>clearTimeout(l)},e),u.useEffect(()=>{const l=t.current;if(!l)return;const m=new ResizeObserver(()=>{n.current&&(l.scrollTop=l.scrollHeight)});return i.current=m,()=>{m.disconnect(),i.current=null,a.clear()}},[a]),u.useEffect(()=>{const l=t.current,m=i.current;!l||!m||(a.forEach(p=>{p.isConnected||(m.unobserve(p),a.delete(p))}),Array.from(l.children).forEach(p=>{a.has(p)||(m.observe(p),a.add(p))}))}),{containerRef:t,handleScroll:c,showScrollDown:o,scrollToBottom:d}}function wp(){const{messagesState:{messages:e}}=C.useMessages(),{isStreaming:t,liveItems:n,turnSources:o,liveTurnKey:s,turnFailed:i,retryFailedTurn:a}=C.useAgentChatUi(),{componentStore:c}=C.useWidget(),{t:d}=Y(),l=C.useBot(),{sessionState:{session:m}}=C.useSessions(),p=u.useMemo(()=>C.sessionPlan({liveItems:n,turnSources:o}),[n,o]),h=u.useMemo(()=>ii(e),[e]),f=u.useMemo(()=>{const R=new Map;for(const M of o)for(const z of M.rowIds)R.set(z,M);return R},[o]),x=u.useMemo(()=>{for(let R=h.length-1;R>=0;R-=1){const M=h[R];if(M&&vr(M))return R}return-1},[h]),g=n.length>0,{nodes:j,renderedSourceKeys:b}=u.useMemo(()=>{const R=[],M=new Set;return h.forEach((z,L)=>{var I;const O=(I=z[0])==null?void 0:I.id;if(!O)return;if(vr(z)){R.push(r.jsx(jr,{groups:[z]},O));return}let U=[];const E=()=>{var $;const H=($=U[0])==null?void 0:$.id;H&&R.push(r.jsx(jr,{groups:[U]},H)),U=[]};for(const H of z){const $=f.get(H.id);$?(E(),M.has($.key)||(M.add($.key),R.push(r.jsx(os,{turn:{active:!1,items:$.items},agent:l,timestamp:H.timestamp},$.key)))):g&&L>x||U.push(H)}E()}),{nodes:R,renderedSourceKeys:M}},[h,f,g,x,l]),S=s!==null&&n.length>0&&!b.has(s),w=c.getComponent("loading"),{containerRef:_,handleScroll:y,showScrollDown:v,scrollToBottom:N}=bp([e,n]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{...P("chat/msgs/wrapper"),className:"relative flex flex-1 flex-col min-h-0",children:[r.jsxs("div",{...P("chat/msgs/root"),ref:_,onScroll:y,className:"max-h-full relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(ui,{}),r.jsx(ci,{}),r.jsx(pi,{}),[...j,...S?[r.jsx(os,{turn:{active:t,items:n},agent:l},s)]:[]],t&&n.length===0&&w&&r.jsx(w,{agent:l}),i&&!t&&r.jsxs("div",{...P("chat/turn_failed/root"),className:"flex items-center gap-2 self-start rounded-xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[r.jsx("span",{children:d("turn_failed_message")}),r.jsx("button",{...P("chat/turn_failed/retry"),type:"button",onClick:a,className:"font-medium underline underline-offset-2 hover:opacity-80",children:d("turn_failed_retry")})]}),r.jsx(ai,{}),r.jsx(si,{})]}),r.jsx(W.AnimatePresence,{children:v&&u.createElement(W.motion.button,{...P("chat/msgs/scroll-to-bottom"),key:"scroll-to-bottom",type:"button",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.15},onClick:N,"aria-label":d("scroll_to_bottom"),className:"absolute bottom-3 left-1/2 z-20 flex size-8 -translate-x-1/2 items-center justify-center rounded-full border border-border bg-background text-muted-foreground shadow-lg transition-colors hover:text-foreground"},r.jsx(T.ArrowDown,{className:"size-4"}))})]}),p&&p.length>0&&r.jsx("div",{...P("chat/session-plan"),className:"shrink-0 px-4 pb-2",children:r.jsx(Wu,{plan:p,active:t},(m==null?void 0:m.id)??"new-session")})]})}function vp(){const e=Be(),{activeMode:t,Component:n}=C.useModes(),o=rn(),{createStateCheckpoint:s}=C.useSessions(),[i,a]=u.useState(!1),c=async d=>{try{a(!0),await o(d)}catch(l){G.log.error("mode component send failed",l)}finally{a(!1)}};return!t||!n?null:r.jsx(n,{...e,mode:t,createStateCheckpoint:s,sendMessage:c,isSendingMessage:i})}function bi(){const{requireInitialQuestion:e,initialQuestions:t}=C.useConfig(),{messagesState:n}=C.useMessages();return e===!0&&n.messages.length===0&&(t==null?void 0:t.some(o=>o.trim().length>0))===!0}const yp=5e3;function kp({stickyQuestions:e,messages:t,isHandedOff:n,isStreaming:o,isTyping:s,otherSuggestionsShowing:i}){const a=(e==null?void 0:e.filter(h=>h.trim().length>0))??[],c=t.findLast(h=>h.type!=="SYSTEM"),d=a.length>0&&!n&&!o&&(c==null?void 0:c.type)==="AI"&&c.data.variant!=="error"?c.id:null,[l,m]=u.useState(null);return u.useEffect(()=>{if(d===null)return;const h=setTimeout(()=>m(d),yp);return()=>clearTimeout(h)},[d]),d!==null&&l===d&&!s&&!i?a:[]}function Cr({isStreaming:e,messages:t,session:n}){return!e&&G.isAwaitingRequiredTap(t,n)}const Se=u.forwardRef((e,t)=>{var n,o,s;return r.jsx(ee,{...e,ref:t,className:A("overflow-hidden",e.className),overrides:{initial:{height:0,opacity:0,...(n=e.overrides)==null?void 0:n.initial},animate:{height:"auto",opacity:1,...(o=e.overrides)==null?void 0:o.animate},exit:{height:0,opacity:0,...(s=e.overrides)==null?void 0:s.exit}}})});Se.displayName="MotionDiv__VerticalReveal";const jp=[{label:"Terrible",value:1,emoji:"😡"},{label:"Poor",value:2,emoji:"😞"},{label:"Okay",value:3,emoji:"😐"},{label:"Good",value:4,emoji:"😊"},{label:"Great",value:5,emoji:"😍"}];function Zn({surveyType:e="csat"}){var n,o;const t=C.useCsat(e);return r.jsx(Cp,{surveyType:e,survey:t},((n=t.csatRequestedMessage)==null?void 0:n.id)??((o=t.csatSubmittedMessage)==null?void 0:o.id)??e)}function Cp({surveyType:e,survey:t}){const{isSmallScreen:n}=ye(),{t:o}=Y(),{submitCsat:s,isCsatRequested:i,isCsatSubmitted:a,submittedScore:c,submittedFeedback:d,question:l}=t,[m,p]=u.useState(!1),[h,f]=u.useState(!1),x=e==="csat"?jp:Array.from({length:e==="nps"?11:5},(y,v)=>({value:v+(e==="nps"?0:1),emoji:String(v+(e==="nps"?0:1)),label:String(v+(e==="nps"?0:1))})),[g,j]=u.useState(null),[b,S]=u.useState(null),w=y=>{j(v=>v===y?null:y)},_=async()=>{if(!(g===null||m)){p(!0),f(!1);try{const y=await s({score:g,feedback:b||void 0});f(!!y.error)}catch(y){console.error("Unable to submit survey",{_e:y}),f(!0)}finally{p(!1)}}};return!i&&!a?null:r.jsxs("div",{className:A("mx-auto overflow-hidden",e==="csat"&&"w-1/2 min-w-80 max-w-96",e==="nps"&&"w-full max-w-[30rem]",e==="ces"&&"w-full max-w-80"),children:[r.jsx(W.AnimatePresence,{mode:"wait",children:i&&g===null?r.jsx(Se,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:l??o("csat_title")})},"csat-requested-title"):a?r.jsx(Se,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:o("csat_submitted_title")})},"csat-submitted-title"):null}),r.jsx("div",{dir:"ltr",className:A("flex pt-2 px-2 pb-2",e==="csat"?"gap-4 justify-between":"gap-0.5 justify-between","transition-all",a&&"gap-0 justify-center"),children:x.map(y=>r.jsx(V,{"aria-label":y.label,"aria-pressed":e==="csat"?void 0:y.value===(c??g),disabled:m||a,variant:y.value===g?"secondary":"ghost",size:"selfless",className:A("transition-all overflow-hidden",e==="csat"?"text-2xl size-8 rounded-full":"h-10 min-w-0 max-w-11 flex-1 rounded-full text-sm tabular-nums",e!=="csat"&&y.value===g&&"bg-foreground text-background hover:bg-foreground","opacity-35","hover:opacity-100",g===null&&"opacity-100",y.value===g&&"opacity-100",a&&y.value!==c&&"opacity-0 size-0",a&&y.value===c&&"opacity-100 size-fit text-4xl",e!=="csat"&&a&&(y.value===c?"flex-none bg-transparent text-foreground disabled:opacity-100":"hidden")),onClick:i?()=>w(y.value):void 0,children:y.emoji},y.value))}),e!=="csat"&&i&&g===null&&r.jsxs("p",{dir:"ltr",className:"flex justify-between gap-2 px-2 text-xs text-muted-foreground",children:[r.jsx("span",{dir:"auto",children:o(e==="nps"?"nps_low_label":"ces_low_label")}),r.jsx("span",{dir:"auto",children:o(e==="nps"?"nps_high_label":"ces_high_label")})]}),h&&r.jsx("p",{role:"alert",className:"text-sm text-center",children:o("survey_submit_error")}),r.jsx(W.AnimatePresence,{mode:"wait",children:(g!==null||a&&c!=null)&&r.jsx(Se,{children:r.jsxs("div",{className:"pb-2 px-2 flex items-end",children:[r.jsx("textarea",{rows:3,className:A("transition-all","max-h-40 [field-sizing:content]","w-full resize-none","bg-transparent outline-none","placeholder:text-muted-foreground",n?"text-[16px]":"text-sm",a&&"text-center"),value:a?d||"":b||"",onChange:i?y=>S(y.target.value):void 0,readOnly:a,placeholder:i?o("csat_feedback_placeholder"):void 0}),r.jsx(V,{size:"fit",onClick:()=>void _(),disabled:g===null||m,className:A("transition-all overflow-hidden","rounded-full size-8 flex items-center justify-center p-0",a&&"opacity-0 size-0"),children:r.jsx(T.ArrowUpIcon,{className:"size-4"})})]})},"feedback-box")}),r.jsx("div",{className:A("h-0 transition-[height]",a&&"h-4")})]})}function Sp(){const{t:e}=Y(),t=[e("i_need_more_help"),e("this_was_helpful")];return r.jsx("div",{...P("chat/might_solve_user_issue_suggested_replies_container"),className:"flex items-center gap-2 p-2 pb-0 flex-wrap",children:t.map(n=>r.jsx(qt,{suggestion:n,className:"flex-1"},n))})}function Sr(){const{sessionState:e}=C.useSessions(),{chatFooterItems:t}=C.useConfig(),n=!!e.session&&!e.session.isOpened,o=!n;return r.jsx(W.AnimatePresence,{mode:"wait",children:t==null?void 0:t.map((s,i)=>s.showWhenSessionIsOpen===!1&&o||s.showWhenSessionIsResolved===!1&&n?null:r.jsx(Se,{children:r.jsx("div",{className:"pb-2 text-center text-xs",children:r.jsx(cu,{children:s.message})})},`${s.message}-${i}`))})}function Nn(){return r.jsxs("svg",{viewBox:"0 0 180 180",fill:"none",className:"size-5 shrink-0 stroke-current",strokeWidth:"12",strokeLinecap:"round","aria-hidden":!0,"data-mcp-icon":!0,children:[r.jsx("path",{d:"M18 84.8528L85.8822 16.9706C95.2548 7.59798 110.451 7.59798 119.823 16.9706V16.9706C129.196 26.3431 129.196 41.5391 119.823 50.9117L68.5581 102.177"}),r.jsx("path",{d:"M69.2652 101.47L119.823 50.9117C129.196 41.5391 144.392 41.5391 153.765 50.9117L154.118 51.2652C163.491 60.6378 163.491 75.8338 154.118 85.2063L92.7248 146.6C89.6006 149.724 89.6006 154.789 92.7248 157.913L105.331 170.52"}),r.jsx("path",{d:"M102.853 33.9411L52.6482 84.1457C43.2756 93.5183 43.2756 108.714 52.6482 118.087V118.087C62.0208 127.459 77.2167 127.459 86.5893 118.087L136.794 67.8822"})]})}function Np({sessionId:e,active:t}){var a;const{widgetCtx:n,config:o}=C.useWidget(),[s,i]=u.useState(null);return u.useEffect(()=>{var m;if(i(null),!t||((m=o.capabilities)==null?void 0:m.connections)!==!0)return;const c=new AbortController;let d;const l=async()=>{try{const p=await n.api.listElicitations(e,c.signal);c.signal.aborted||i(p[0]??null)}catch{i(p=>p&&p.expiresAt>Date.now()?p:null)}c.signal.aborted||(d=setTimeout(l,1500))};return l(),()=>{c.abort(),clearTimeout(d)}},[n,e,t,(a=o.capabilities)==null?void 0:a.connections]),r.jsxs(r.Fragment,{children:[" ",s&&s.expiresAt>Date.now()?r.jsx(_p,{request:s,onAnswer:async c=>{await n.api.answerElicitation(e,s.id,c),i(null)}},s.id):null]})}function _p({request:e,onAnswer:t}){var m,p;const[n,o]=u.useState(!1),[s,i]=u.useState(""),a=async h=>{if(!n){o(!0),i("");try{await t(h)}catch(f){i(f instanceof Error?f.message:"Could not submit. Try again.")}finally{o(!1)}}},c=e.form.requestedSchema.properties,d=Object.keys(c).length===1&&((m=c.approve)==null?void 0:m.type)==="boolean"&&((p=e.form.requestedSchema.required)==null?void 0:p.includes("approve")),l="w-full rounded-lg border border-foreground/15 bg-background px-2 py-1.5 text-base sm:text-sm";return r.jsxs("form",{"aria-label":`Request from ${e.serverName}`,className:`min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 space-y-2 text-foreground ${d?"overflow-visible":"max-h-[50vh] overflow-y-auto"}`,onSubmit:h=>{if(h.preventDefault(),d){a({action:"accept",content:{approve:!0}});return}const f=new FormData(h.currentTarget),x={};for(const[g,j]of Object.entries(c)){const b=f.get(g);if(j.type==="boolean")x[g]=b==="on";else if(j.type==="array"){const S=f.getAll(g).filter(w=>typeof w=="string");if(j.minItems!==void 0&&S.length<j.minItems){i(`${j.title??g}: select at least ${j.minItems} options.`);return}if(j.maxItems!==void 0&&S.length>j.maxItems){i(`${j.title??g}: select no more than ${j.maxItems} options.`);return}x[g]=S}else typeof b=="string"&&b!==""&&(x[g]=j.type==="number"||j.type==="integer"?Number(b):b)}a({action:"accept",content:x})},children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx("div",{className:"mt-0.5 size-4 shrink-0 text-foreground/50",title:e.serverName,children:r.jsx(Nn,{})}),r.jsx("p",{className:"min-w-0 flex-1 text-sm leading-5 break-words",children:e.form.message}),r.jsx(V,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-foreground/50",wobble:!1,"aria-label":"Cancel request",disabled:n,onClick:()=>void a({action:"cancel"}),children:r.jsx(T.X,{className:"size-3.5"})})]}),!d&&r.jsx("fieldset",{disabled:n,className:"space-y-3",children:Object.entries(c).map(([h,f])=>{var b,S,w,_,y;const x=`${e.id}-${h}`,g=f.oneOf??((b=f.enum)==null?void 0:b.map(v=>({const:v,title:v})))??((S=f.items)==null?void 0:S.anyOf)??((_=(w=f.items)==null?void 0:w.enum)==null?void 0:_.map(v=>({const:v,title:v}))),j=(y=e.form.requestedSchema.required)==null?void 0:y.includes(h);return r.jsxs("div",{children:[r.jsxs("label",{htmlFor:x,className:"block text-sm font-medium mb-1",children:[f.title??h,j?" *":""]}),f.description&&r.jsx("p",{className:"text-sm text-foreground/60 mb-1",children:f.description}),f.type==="boolean"?r.jsx("input",{id:x,name:h,type:"checkbox",defaultChecked:f.default===!0,className:"size-5 accent-current"}):g?r.jsxs("select",{id:x,name:h,multiple:f.type==="array",required:j,className:l,defaultValue:typeof f.default=="string"||Array.isArray(f.default)?f.default:f.type==="array"?[]:"",children:[f.type!=="array"&&r.jsx("option",{value:"",children:"Choose…"}),g.map(v=>r.jsx("option",{value:v.const,children:v.title??v.const},v.const))]}):r.jsx("input",{id:x,name:h,className:l,type:f.type==="number"||f.type==="integer"?"number":f.format==="email"?"email":f.format==="uri"?"url":f.format==="date"?"date":"text",required:j,min:f.minimum,max:f.maximum,step:f.type==="integer"?1:"any",minLength:f.minLength,maxLength:f.maxLength,defaultValue:typeof f.default=="string"||typeof f.default=="number"?f.default:""})]},h)})}),s&&r.jsx("p",{role:"alert",className:"text-sm text-destructive",children:s}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2 pl-6",children:[r.jsx(V,{type:"submit",size:"sm",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,children:n?"Submitting…":d?"Approve once":"Submit"}),d&&e.approvalKey&&r.jsx(V,{type:"button",size:"sm",variant:"secondary",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,title:"Allow the same tool, account and inputs. Reset anytime.",onClick:()=>void a({action:"accept",content:{approve:!0},remember:!0}),children:"Always allow"}),r.jsx(V,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,onClick:()=>void a({action:"decline"}),children:"Decline"})]})]})}function Ep({request:e}){const t=C.useConnection(e),{phase:n,authorization:o,continuation:s,error:i}=t,c=n==="loading"||n==="waiting"||s!==null,d=n==="connected"||n==="external",l=(i==null?void 0:i.toLowerCase().includes("expired"))??!1,m=s?s==="renew"?"Preparing a new connection request":"Continuing your request":n==="waiting"?"Waiting for approval":n==="loading"?"Preparing connection":n==="connected"?"Connected":n==="external"?"Setup page completed":"Not connected",p=s?s==="renew"?"Requesting…":"Continuing…":n==="loading"?"Preparing…":n==="waiting"?"Waiting…":l?"Reconnect":i?"Try again":d?"Continue":"Connect",h=()=>i||d?t.retryContinuation():t.start();return r.jsxs("section",{"aria-label":`Connect ${e.name}`,"data-component":"chat/connection",className:"min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 text-foreground",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-secondary p-2",children:r.jsx(Nn,{})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"truncate text-sm font-medium",title:(o==null?void 0:o.host)??e.name,children:e.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect your account to continue."})]}),r.jsxs("p",{role:"status","aria-live":"polite",className:"sr-only",children:[e.name,": ",m]}),n==="ready"&&o&&!s?r.jsx(V,{asChild:!0,wobble:!1,size:"sm",className:"h-7 shrink-0 px-2.5 text-xs order-2",children:r.jsx("a",{href:o.url,target:"_blank",rel:"noopener noreferrer",onClick:t.opened,"aria-label":`Connect on ${o.host} (opens in a new tab)`,children:"Connect"})}):r.jsxs(V,{type:"button",wobble:!1,size:"sm",className:"h-7 shrink-0 px-2.5 text-xs order-2",disabled:c,"aria-busy":c,title:l?"Your access expired. Connect again to continue.":void 0,onClick:()=>void h(),children:[c&&r.jsx(so,{}),p]}),r.jsx(V,{type:"button",wobble:!1,variant:"ghost",size:"fit",className:"h-7 shrink-0 px-2 text-xs order-1","aria-label":"Not now",title:"Not now",disabled:s!==null,onClick:()=>void t.cancel(),children:"Not now"})]}),i&&r.jsx("p",{role:"alert",className:"px-1 pt-2 text-sm text-pretty text-destructive",children:i})]})}const Tp=["box","circle","crossed-off","arrow","bracket","underline","highlight","strike-through"];function Ap(e){const t=new Map,n=[];for(const o of e){let s;for(const i of o.elements){const a=i.selector||i.name,c=t.get(a);if(c){s??(s=c);continue}const d={...i};t.set(a,d),n.push(d),s??(s=d)}o.note&&s&&(s.note=s.note?`${s.note}
|
|
111
|
-
${o.note}`:o.note)}return n}const is=20,Ip=4e3;function Nr(e,t){for(let n=e.nextElementSibling;n instanceof SVGSVGElement&&n.classList.contains("notation");n=n.nextElementSibling)n.setAttribute("data-opencx-overlay",""),n.style.zIndex=String(t),n.style.filter="drop-shadow(0 0 1px rgb(255 255 255 / 0.85))"}function zp(e,t,n,o){const s=document.createElement("div");s.setAttribute("data-opencx-overlay",""),Object.assign(s.style,{position:"absolute",left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",zIndex:String(o)}),document.documentElement.appendChild(s);let i=null;try{i=Zs.annotate(s,{type:t,color:n,strokeWidth:2,wobble:.8}),i.show(),Nr(s,o)}catch(l){G.log.warn("page mark: could not be drawn",l)}let a=!1;const c=()=>{if(!a){a=!0;try{i==null||i.remove()}catch{}s.remove()}},d=l=>{if(!a)try{i==null||i.update(l),Nr(s,o)}catch{}};return{setRect(l){a||(s.style.left=`${l.x}px`,s.style.top=`${l.y}px`,s.style.width=`${l.width}px`,s.style.height=`${l.height}px`,d({}))},setShape(l){d({type:l})},undraw(){if(!a){if(!i)return c();try{i.hide(),i.finished.then(c)}catch{return c()}window.setTimeout(c,Ip)}},remove:c}}const Mp=60;function Je(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function wi(e){return fi(e)}function Rp(e){return/[!/[\]():]/.test(e)||/^-?[a-z]{1,6}-\d/.test(e)||/^(flex|grid|block|inline|hidden|absolute|relative|fixed|sticky|static|truncate|container)$/.test(e)}function Pp(e){const t=e.getAttribute("class");return t?t.split(/\s+/).map(o=>o.replace(/[_-][a-zA-Z0-9]{5,}.*$/,"")).find(o=>o.length>2&&!/^[a-z]{1,2}$/.test(o)&&!/[A-Z0-9]{5,}/.test(o)&&!Rp(o))??null:null}function Op(e){if(Me(e))return"private region";const t=e.tagName.toLowerCase(),n=e.getAttribute("aria-label"),o=wi(e);if(t==="button"||e.getAttribute("role")==="button")return n?`button [${n}]`:o?`button "${Je(o,30)}"`:"button";if(t==="a"){if(o)return`link "${Je(o,30)}"`;const i=e.getAttribute("href"),a=i?io(i):"",c=i!=null&&i.startsWith("/")&&!i.startsWith("//")&&a?new URL(a).pathname:a;return c?`link to ${Je(c,40)}`:"link"}if(t==="input"||t==="textarea"||t==="select"){const i=e.getAttribute("placeholder"),a=e.getAttribute("name");return i?`${t} "${Je(i,30)}"`:n?`${t} [${n}]`:a?`${t} [${a}]`:t==="input"?`${e.getAttribute("type")??"text"} input`:t}if(/^h[1-6]$/.test(t))return o?`${t} "${Je(o,40)}"`:t;if(t==="img"){const i=e.getAttribute("alt");return i?`image "${Je(i,30)}"`:"image"}if(t==="svg")return"icon";if(n)return`${t} [${n}]`;if(o&&o.length<=Mp)return`${t} "${Je(o,40)}"`;const s=Pp(e);return s||(t==="div"?"container":t)}function cs(e,t){try{return e.querySelectorAll(t).length===1}catch{return!1}}function $p(e){const t=e.ownerDocument;if(e.id){const s=`#${CSS.escape(e.id)}`;if(cs(t,s))return s}const n=[];let o=e;for(;o&&o.tagName.toLowerCase()!=="html";){const s=o.tagName.toLowerCase();if(o.id){n.unshift(`${s}#${CSS.escape(o.id)}`);break}let i=s;const a=o.parentElement;if(a){const d=Array.from(a.children).filter(l=>l.tagName===(o==null?void 0:o.tagName));d.length>1&&(i+=`:nth-of-type(${d.indexOf(o)+1})`)}n.unshift(i);const c=n.join(" > ");if(cs(t,c))return c;o=a}return n.join(" > ")}function Lp(e){const t=e.getBoundingClientRect();return{x:Math.round(t.x),y:Math.round(t.y),width:Math.round(t.width),height:Math.round(t.height)}}const Dp=8;function ls(e,t=Dp){const n=document.documentElement.clientWidth||window.innerWidth,o=document.documentElement.clientHeight||window.innerHeight,s=Math.max(e.x,t),i=Math.max(e.y,t),a=Math.min(e.x+e.width,n-t),c=Math.min(e.y+e.height,o-t);return{x:Math.round(s),y:Math.round(i),width:Math.round(Math.max(0,a-s)),height:Math.round(Math.max(0,c-i))}}function vi(e){if(Me(e)||e.closest(gt))return{name:"private region",selector:"",tag:"div"};const t=wi(e);return{name:Op(e),selector:$p(e),tag:e.tagName.toLowerCase(),text:t?Je(t,200):void 0}}const Fp=ao.join(", ");function on(e){return e.closest(Fp)!==null}function _r(e,t){let n=document.elementFromPoint(e,t);if(!n)return null;const o=n.getRootNode();typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(n=o.host);let i=n.closest('button, a, input, textarea, select, [role="button"], [role="link"]')??n;for(;i&&!(i instanceof HTMLElement);)i=i.parentElement;if(!(i instanceof HTMLElement)||Me(n)||Me(i)||i.closest(gt))return null;const a=i.tagName.toLowerCase();return a==="html"||a==="body"?null:i}const co=new WeakMap;function Hp(e,t){co.set(e,[...t])}function yn(e){const t=co.get(e);return t!==void 0&&e.pageUrl===io(window.location.href)&&t.every(n=>n.isConnected&&n.getRootNode()===document&&!Me(n)&&!n.closest(gt))}function Wp(e){const t=co.get(e);if(!t||!yn(e))return null;const n=t.map(vi),[o]=t,s=o!==void 0&&Vt(o)&&JSON.stringify(n[0])===JSON.stringify(e.elements[0]),i={...e,elements:n};return s?sp(e,i):delete i.snapshotUrl,i}const ds=120,ct=e=>e.replace(/\s+/g," ").trim(),Ke=e=>e.length>ds?`${e.slice(0,ds)}…`:e,_n=fi;function Up(e){const t=e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,n=t?Array.from(t).map(i=>_n(i)).join(" "):"";if(n)return ct(n);const o=e.closest("fieldset"),s=o==null?void 0:o.querySelector("legend");return s?_n(s):""}function zt(e){if(Me(e))return"";const t=e.getAttribute("aria-labelledby");if(t){const a=t.split(/\s+/).map(c=>e.ownerDocument.getElementById(c)).filter(c=>c!==null).map(c=>_n(c)).filter(Boolean).join(" ");if(a)return Ke(ct(a))}const n=e.getAttribute("aria-label");if(n!=null&&n.trim())return Ke(ct(n));const o=e.tagName.toLowerCase();if(o==="img"){const a=e.getAttribute("alt");if(a!=null&&a.trim())return Ke(ct(a))}if(o==="input"||o==="select"||o==="textarea"){const a=Up(e);if(a)return Ke(a);const c=e.getAttribute("placeholder");if(c!=null&&c.trim())return Ke(ct(c));const d=e.getAttribute("title");return d!=null&&d.trim()?Ke(ct(d)):""}const s=_n(e);if(s)return Ke(s);const i=e.getAttribute("title");return i!=null&&i.trim()?Ke(ct(i)):""}const Bp=["click","fill","select","check","uncheck"],qp=3e3,yi=new Set(["password","file","hidden"]);function ki(e){const t=new WeakRef(e),n=us(e).map(o=>{const s=ps(o);return{...s,element:new WeakRef(s.element),form:s.form?new WeakRef(s.form):null,labelControl:s.labelControl?new WeakRef(s.labelControl):null}});return()=>{const o=t.deref();if(!o||!o.isConnected||o.getRootNode()!==document)return!1;const s=us(o).map(ps);return s.length===n.length&&s.every((i,a)=>{var d,l;const c=n[a];return i.allowed&&i.element===c.element.deref()&&i.form===(((d=c.form)==null?void 0:d.deref())??null)&&i.labelControl===(((l=c.labelControl)==null?void 0:l.deref())??null)&&i.semantics===c.semantics})}}function us(e){const t=[],n=new Set,o=s=>{for(let i=s;i&&!n.has(i);i=i.parentElement)n.add(i),(i===e||i.matches("a[href],area[href],button,input,select,textarea,label"))&&t.push(i),i instanceof HTMLLabelElement&&i.control&&o(i.control)};return o(e),t}function ps(e){var i;const t=e instanceof HTMLAnchorElement||e instanceof HTMLAreaElement?e:null,n=e instanceof HTMLButtonElement||e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e:null,o=(n==null?void 0:n.form)??null,s=(i=e.ownerDocument.querySelector("base[target]"))==null?void 0:i.getAttribute("target");return{element:e,form:o,labelControl:e instanceof HTMLLabelElement?e.control:null,allowed:!(e instanceof HTMLInputElement&&yi.has(e.type)),semantics:JSON.stringify([e.tagName,e.getAttribute("role"),n==null?void 0:n.type,n==null?void 0:n.name,e instanceof HTMLButtonElement||e instanceof HTMLInputElement&&["submit","image","reset"].includes(e.type)?e.value:null,t==null?void 0:t.href,(t==null?void 0:t.getAttribute("target"))??s,t==null?void 0:t.getAttribute("download"),t==null?void 0:t.getAttribute("rel"),t==null?void 0:t.getAttribute("ping"),o==null?void 0:o.action,o==null?void 0:o.method,(o==null?void 0:o.getAttribute("target"))??s,o==null?void 0:o.enctype,o==null?void 0:o.noValidate,...["formaction","formmethod","formtarget","formenctype","formnovalidate"].map(a=>e.getAttribute(a)),e instanceof HTMLButtonElement||e instanceof HTMLInputElement?[e.formAction,e.formMethod,e.formTarget,e.formEnctype,e.formNoValidate]:null])}}const Vp=2,St=[];let Yp=0,ms=new WeakMap,lt,hs,lo=new WeakMap,uo=new WeakMap,En=new WeakMap;const Xp='tr,li,article,form,fieldset,section,dialog,aside,nav,main,header,footer,[role="row"],[role="listitem"],[role="group"],[role="region"],[role="dialog"],[role="tooltip"]',po='tr,li,article,[role="row"],[role="listitem"]',Jn='section,form,fieldset,dialog,[role="group"],[role="region"],[role="dialog"]',Gp=new Set(["class","style","aria-busy"]);function Kp(e){var i,a;const t=e.closest(po);if(t)return t;let n=e.closest(Jn);if(n){let c=(i=n.parentElement)==null?void 0:i.closest(Jn);for(;c;)n=c,c=(a=n.parentElement)==null?void 0:a.closest(Jn);return n}const o=e.closest(Xp);if(o)return o;const s=e.parentElement;return s&&s!==e.ownerDocument.body&&s!==e.ownerDocument.documentElement?s:e}function Zp(e){return on(e)||e.closest('[role="tooltip"]')!==null}function Jp(e){const t=e.target.nodeType===1?e.target:e.target.parentElement;if(t&&on(t)||e.type==="attributes"&&Gp.has(e.attributeName??""))return!1;if(e.type==="childList"){const n=[...Array.from(e.addedNodes),...Array.from(e.removedNodes)];if(n.length&&n.every(o=>o.nodeType===1&&Zp(o)))return!1}return!0}function ji(e){const t=new Set;for(const n of e){for(const s of Array.from(n.removedNodes)){const i=En.get(s);i&&t.add(i)}if(!Jp(n))continue;if(n.type==="attributes"){const s=En.get(n.target);s&&t.add(s)}let o=!0;for(let s=n.target;s;s=s.parentNode){const i=lo.get(s);if(i&&t.add(i),o){const a=uo.get(s);a&&t.add(a)}if(s instanceof Element&&(s.matches(po)&&(o=!1),s.matches('[role="tooltip"]')&&!(n.type==="attributes"&&n.attributeName==="role")))break}}t.forEach(n=>n.value++)}function Qp(e){const t=[],n=(s,i)=>{let a=i.get(s);a||(a={value:0},i.set(s,a)),t.push({revision:a,value:a.value})},o=Kp(e);n(o,lo);for(let s=e;s;s=s.parentNode)n(s,En),s!==o&&s instanceof Element&&s.matches(po)&&n(s,uo);return()=>t.every(({revision:s,value:i})=>s.value===i)}function Er(){lt&&ji(lt.takeRecords())}function em(e){if(hs!==e){lt==null||lt.disconnect();for(const t of St)for(const n of Array.from(t.values()))n.valid=!1;hs=e,lo=new WeakMap,uo=new WeakMap,En=new WeakMap,lt=new MutationObserver(ji),lt.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}}function Ci(e,t,n=zt(t)){return e.valid&&(e.valid=t.isConnected&&e.url===t.ownerDocument.location.href&&e.name===n&&e.sameContext()&&e.sameMeaning()),e.valid}function tm(){Er();const e=new Map;St.unshift(e),St.length=Math.min(St.length,Vp);let t=0;const n=`s${++Yp}`;return(o,s=zt(o))=>{em(o.ownerDocument),Er();const i=ms.get(o),a=i?St.map(l=>l.get(i)).find(l=>l!==void 0):void 0,c=i&&a&&Ci(a,o,s)?i:`${n}c${t+=1}`,d=c===i&&a?a:{element:new WeakRef(o),sameContext:Qp(o),name:s,url:o.ownerDocument.location.href,sameMeaning:ki(o),valid:!0};return e.set(c,d),ms.set(o,c),c}}function fs(e){const t=Si(e);return t!=null&&t.isCurrent?t.element:null}function Si(e){Er();for(const t of St){const n=t.get(e);if(!n)continue;const o=n.element.deref();if(o&&o.isConnected)return{element:o,isCurrent:Ci(n,o)}}return null}const nm="data-opencx-private",rm=new Set(["password","file","hidden"]),gs=300;function Tr(e){if(on(e))return"widget-owned";if(e.closest(`[${nm}]`))return"private";if(e.getAttribute("aria-hidden")==="true"||e.closest('[aria-hidden="true"]'))return"hidden-from-assistive-tech";if(e.tagName.toLowerCase()==="input"){const t=(e.getAttribute("type")??"text").toLowerCase();if(rm.has(t))return"credential-field"}return null}const om={private:"That part of the page is marked private and the agent never reads or uses it.","hidden-from-assistive-tech":"That control is hidden from assistive technology, so it is not treated as being on the page.","credential-field":"Password and file fields are never filled or clicked by the agent.","widget-owned":"That is part of the chat widget, not the page."},xs=["a[href]","button","input","select","textarea","summary",'[contenteditable=""]','[contenteditable="true"]','[role="button"]','[role="link"]','[role="checkbox"]','[role="radio"]','[role="switch"]','[role="tab"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="combobox"]','[role="slider"]','[role="textbox"]','[role="searchbox"]'].join(","),sm=["tr","li",'[role="row"]','[role="listitem"]','[role="gridcell"]',"[tabindex]","[onclick]"].join(","),am=400;function im(e){var t;try{return((t=e.ownerDocument.defaultView)==null?void 0:t.getComputedStyle(e).cursor)==="pointer"}catch{return!1}}function cm(e){const t=e.getAttribute("role");if(t!=null&&t.trim())return t.trim().toLowerCase();const n=e.tagName.toLowerCase();if(n==="a")return"link";if(n==="button"||n==="summary")return"button";if(n==="select")return"combobox";if(n==="textarea")return"textbox";if(n==="input"){const o=(e.getAttribute("type")??"text").toLowerCase();return o==="checkbox"?"checkbox":o==="radio"?"radio":o==="submit"||o==="button"||o==="reset"?"button":o==="range"?"slider":o==="search"?"searchbox":"textbox"}return"textbox"}function lm(e){const t=e.getAttribute("role");if(t!=null&&t.trim())return t.trim().toLowerCase();const n=e.tagName.toLowerCase();return n==="tr"?"row":n==="li"?"listitem":"button"}function bs(e){if(typeof e.checkVisibility=="function"){if(!e.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}))return!1}else if(!e.isConnected)return!1;const t=e.getBoundingClientRect();return t.width>0&&t.height>0}function dm(e){return"disabled"in e&&e.disabled===!0?!0:e.getAttribute("aria-disabled")==="true"}function Ar(e=document){const t=[],n=new Set;let o=!1;try{const s=tm(),i=Array.from(e.querySelectorAll(xs));for(const c of i){if(Tr(c)||!bs(c))continue;const d=zt(c);if(!d)continue;if(t.length>=gs){o=!0;break}const l={ref:s(c,d),role:cm(c),name:d};dm(c)&&(l.disabled=!0),t.push(l),n.add(c)}let a=0;if(!o){const c=Array.from(e.querySelectorAll(sm));for(const d of c){if(t.length>=gs){o=!0;break}if(a>=am)break;if(n.has(d)||Tr(d)||d.querySelector(xs)||!bs(d))continue;const l=zt(d);l&&(a+=1,im(d)&&(t.push({ref:s(d,l),role:lm(d),name:l}),n.add(d)))}}}catch{return{controls:[],truncated:!1}}return{controls:t,truncated:o}}function Ni({marks:e,readsPage:t}){if(!t)return;const n={},o=e.flatMap(a=>{const c=Wp(a);return c?[c]:[]});o.length>0&&(n.page_marks=o,n.picked_elements=Ap(o));const{controls:s,truncated:i}=Ar();return s.length>0&&(n.page_controls=s,i&&(n.page_controls_truncated=!0)),Object.keys(n).length>0?n:void 0}const um={click:"click",fill:"type into",select:"change",check:"switch on",uncheck:"switch off"};function pm({request:e}){const{resolvePageAction:t}=C.useAgentChatUi(),n=um[e.action]??e.action,o=e.action==="select"?e.valueLabel??e.value:e.value;return r.jsxs("section",{"aria-label":`Allow the agent to ${n} ${e.controlName}`,"data-component":"chat/page_action",className:"min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 text-foreground",children:[r.jsxs("p",{className:"px-1 pb-2 text-sm",children:["Let the agent ",n," ",r.jsx("span",{className:"font-medium",children:e.controlName})," on this page?"]}),(e.action==="fill"||e.action==="select")&&e.value!==void 0&&r.jsxs("div",{className:"mb-2 max-h-40 overflow-auto rounded-lg bg-foreground/5 px-2 py-1 text-sm",children:[r.jsx("span",{className:"font-medium",children:"New value: "}),r.jsx("span",{className:"whitespace-pre-wrap break-words",children:o===""?"(empty)":o})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(V,{size:"sm",className:"flex-1",onClick:()=>t(e.callId,!0),children:"Allow"}),r.jsx(V,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>t(e.callId,!1),children:"No"})]})]})}const kn="rounded-full size-8 flex items-center justify-center p-0 overflow-hidden",_i="bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",mm=A("rounded-full p-0.5 text-muted-foreground","hover:bg-muted hover:text-foreground","transition-transform active:scale-90");function hm({entity:e,onRemove:t}){const{t:n}=Y();return r.jsxs("div",{...P("chat/input_box/page_context_pill"),className:A("flex items-center gap-1.5 max-w-full","rounded-full py-0.5 pe-1","text-xs text-foreground"),title:`${e.type}: ${e.title}`,children:[r.jsx(T.FileTextIcon,{className:"size-3 shrink-0 text-primary"}),r.jsx("span",{className:"truncate max-w-48 font-medium",children:e.title}),r.jsx("button",{type:"button","aria-label":n("page_context_remove"),className:mm,onClick:t,children:r.jsx(T.XIcon,{className:"size-3"})})]})}const fm=k.z.object({type:k.z.string().min(1),id:k.z.string().min(1),title:k.z.string().min(1),meta:k.z.record(k.z.string(),k.z.unknown()).optional()});function gm(){var o;const e=C.useConfig(),{widgetCtx:t}=C.useWidget();if(C.useHostLocation(),!t.features.pageContext)return null;const n=fm.safeParse((o=G.resolveConfigContext(e))==null?void 0:o.entity);return n.success?n.data:null}function gn(e,t){var o;const n=(o=Object.entries(e).find(([s])=>s===t))==null?void 0:o[1];return typeof n=="string"?`hsl(${n})`:"currentColor"}function mo({cssVars:e,primaryColor:t,contentZIndex:n}){return{accent:t,surface:gn(e,"--opencx-background"),foreground:gn(e,"--opencx-foreground"),mutedForeground:gn(e,"--opencx-muted-foreground"),border:gn(e,"--opencx-border"),inkZIndex:n-2,chromeZIndex:n-1,editorZIndex:n+1}}function xm({isActive:e,draft:t,hover:n,onShapeChange:o,onAttach:s}){const i=On(),{theme:a,cssVars:c}=ue(),{t:d}=Y();if(!i||!e)return null;const l=mo({cssVars:c,primaryColor:a.primaryColor,contentZIndex:a.widgetContentContainer.zIndex}),{accent:m}=l;return Kt.createPortal(r.jsxs("div",{"data-opencx-overlay":"",style:{pointerEvents:"none"},children:[r.jsx("style",{children:`
|
|
112
|
-
@keyframes opencx-mark-hint-in {
|
|
113
|
-
from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
|
|
114
|
-
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
115
|
-
}
|
|
116
|
-
@keyframes opencx-mark-editor-in {
|
|
117
|
-
from { opacity: 0; transform: translateY(4px); }
|
|
118
|
-
to { opacity: 1; transform: translateY(0); }
|
|
119
|
-
}
|
|
120
|
-
@keyframes opencx-mark-frame-in {
|
|
121
|
-
from { opacity: 0; transform: scale(1.015); }
|
|
122
|
-
to { opacity: 1; transform: scale(1); }
|
|
123
|
-
}
|
|
124
|
-
@media (prefers-reduced-motion: reduce) {
|
|
125
|
-
[data-opencx-mark-hint], [data-opencx-mark-editor],
|
|
126
|
-
[data-opencx-mark-frame] { animation: none !important; }
|
|
127
|
-
}
|
|
128
|
-
`}),!t&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{"data-opencx-mark-hint":"",style:{position:"fixed",top:16,left:"50%",transform:"translateX(-50%)",zIndex:l.chromeZIndex,display:"flex",alignItems:"center",gap:8,background:`color-mix(in srgb, ${l.surface} 92%, transparent)`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",color:l.foreground,font:"500 12px/1.4 system-ui, sans-serif",padding:"7px 12px 7px 10px",borderRadius:999,whiteSpace:"nowrap",boxShadow:`0 0 0 1px ${l.border}, 0 8px 24px color-mix(in srgb, ${l.foreground} 14%, transparent)`,animation:"opencx-mark-hint-in 200ms cubic-bezier(0.23, 1, 0.32, 1)"},children:[r.jsx("span",{style:{width:7,height:7,borderRadius:999,background:m}}),d("page_mark_hint"),r.jsx(bm,{theme:l,children:d("page_mark_escape")})]}),n&&r.jsx("div",{"data-opencx-mark-frame":"",style:{position:"fixed",left:n.rect.x-4,top:n.rect.y-4,width:n.rect.width+8,height:n.rect.height+8,zIndex:l.chromeZIndex,borderRadius:10,boxShadow:`0 0 0 2px ${l.surface}, 0 0 0 3.5px ${m}, 0 12px 32px color-mix(in srgb, ${l.foreground} 16%, transparent)`,animation:"opencx-mark-frame-in 140ms cubic-bezier(0.23, 1, 0.32, 1)",transitionProperty:"left, top, width, height",transitionDuration:"90ms",transitionTimingFunction:"cubic-bezier(0.23, 1, 0.32, 1)",pointerEvents:"none"}},n.key)]}),t&&r.jsxs(r.Fragment,{children:[[[t.rect.x,t.rect.y],[t.rect.x+t.rect.width,t.rect.y],[t.rect.x,t.rect.y+t.rect.height],[t.rect.x+t.rect.width,t.rect.y+t.rect.height]].map(([p,h],f)=>r.jsx("div",{style:{position:"fixed",left:p-5,top:h-5,width:10,height:10,borderRadius:999,background:l.surface,boxShadow:`0 0 0 2px ${m}, 0 2px 6px color-mix(in srgb, ${l.foreground} 25%, transparent)`,zIndex:l.chromeZIndex,pointerEvents:"none"}},f)),r.jsx(ym,{draft:t,theme:l,onShapeChange:o,onAttach:s},"editor")]})]}),i)}function bm({children:e,theme:t}){return r.jsx("span",{style:{font:"600 10px/1 system-ui, sans-serif",color:t.mutedForeground,background:`color-mix(in srgb, ${t.foreground} 7%, transparent)`,border:`1px solid ${t.border}`,borderRadius:5,padding:"3px 5px 2px"},children:e})}const wm={box:r.jsx("rect",{x:"3",y:"5",width:"14",height:"10",rx:"1"}),circle:r.jsx("ellipse",{cx:"10",cy:"10",rx:"7",ry:"5.5"}),arrow:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3 10h13"}),r.jsx("path",{d:"M12 6l4 4-4 4"})]}),bracket:r.jsx("path",{d:"M7 4H4v12h3"}),underline:r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5 8h10",opacity:"0.35"}),r.jsx("path",{d:"M4 14h12"})]}),highlight:r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"7",width:"14",height:"6",rx:"1",fill:"currentColor",opacity:"0.3",stroke:"none"}),r.jsx("path",{d:"M5 10h10"})]}),"strike-through":r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M6 6h8",opacity:"0.35"}),r.jsx("path",{d:"M6 14h8",opacity:"0.35"}),r.jsx("path",{d:"M4 10h12"})]}),"crossed-off":r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M4 5l12 10"}),r.jsx("path",{d:"M16 5L4 15"})]})},vm={box:"page_mark_shape_box",circle:"page_mark_shape_circle",arrow:"page_mark_shape_arrow",bracket:"page_mark_shape_bracket",underline:"page_mark_shape_underline",highlight:"page_mark_shape_highlight","strike-through":"page_mark_shape_strike_through","crossed-off":"page_mark_shape_crossed_off"};function ym({draft:e,theme:t,onShapeChange:n,onAttach:o}){const{accent:s}=t,{t:i}=Y(),[a,c]=u.useState(""),d=u.useRef(null);u.useEffect(()=>{var j;(j=d.current)==null||j.focus()},[]);const l=320,m=window.innerWidth,p=window.innerHeight,{rect:h}=e,f=Math.max(12,Math.min(h.x+h.width/2-l/2,m-l-12)),x=h.y+h.height+16,g=x+138>p?Math.max(12,h.y-134):x;return r.jsxs("div",{"data-opencx-mark-editor":"",style:{position:"fixed",left:f,top:g,width:l,zIndex:t.editorZIndex,pointerEvents:"auto",display:"flex",flexDirection:"column",gap:6,background:`color-mix(in srgb, ${t.surface} 96%, transparent)`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",padding:8,borderRadius:14,boxShadow:`0 0 0 1px ${t.border}, 0 12px 32px color-mix(in srgb, ${t.foreground} 18%, transparent)`,animation:"opencx-mark-editor-in 180ms cubic-bezier(0.23, 1, 0.32, 1)"},children:[r.jsx("div",{style:{display:"flex",gap:2,justifyContent:"space-between"},children:Tp.map(j=>{const b=j===e.shape,S=i(vm[j]);return r.jsx("button",{type:"button",title:S,"aria-label":i("page_mark_shape_aria",{shape:S}),"aria-pressed":b,onClick:()=>n(j),style:{border:"none",cursor:"pointer",borderRadius:8,width:32,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:b?s:"transparent",color:b?t.surface:t.mutedForeground},children:r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:wm[j]})},j)})}),r.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:8},children:[r.jsx("textarea",{ref:d,rows:2,value:a,onChange:j=>c(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),o(a))},placeholder:i("page_mark_note_placeholder"),style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:t.foreground,font:"500 13px/1.4 system-ui, sans-serif",margin:0,paddingBlock:0,paddingInlineStart:4,paddingInlineEnd:0,resize:"none"}}),r.jsx("button",{type:"button","aria-label":i("page_mark_attach"),onClick:()=>o(a),style:{border:"none",borderRadius:999,width:26,height:26,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:s,color:t.surface,font:"600 13px/1 system-ui, sans-serif",cursor:"pointer"},children:"↑"})]})]})}function km({mark:e,onRemove:t}){var c;const{t:n}=Y(),o=gi(e),s=e.note??((c=e.elements[0])==null?void 0:c.name)??n("page_mark_region"),i=n("page_mark_remove",{label:s}),a=e.elements.map(d=>d.name).join(", ");return o?r.jsx(mi,{...P("chat/input_box/page_mark_pill"),className:"group",shape:"tile",src:o,alt:s,title:a,note:e.note,children:r.jsx("button",{type:"button","aria-label":i,className:A("absolute top-1 end-1 rounded-full p-0.5","bg-foreground/60 text-background backdrop-blur-sm","opacity-0 group-hover:opacity-100 focus-visible:opacity-100","transition-opacity active:scale-90"),onClick:t,children:r.jsx(T.XIcon,{className:"size-3"})})}):r.jsxs("div",{...P("chat/input_box/page_mark_pill"),title:a,className:A("group relative size-12 shrink-0 overflow-hidden","flex items-center justify-center","rounded-2xl bg-background ring-1 ring-border"),children:[r.jsx(T.PenLineIcon,{className:"size-4 shrink-0 text-primary"}),r.jsx("span",{className:A("absolute inset-x-0 bottom-0 truncate px-1.5 py-0.5","bg-gradient-to-t from-foreground/70 to-foreground/0","text-[10px] font-medium leading-tight text-background"),children:s}),r.jsx("button",{type:"button","aria-label":i,className:A("absolute top-1 end-1 rounded-full p-0.5","bg-foreground/60 text-background backdrop-blur-sm","opacity-0 group-hover:opacity-100 focus-visible:opacity-100","transition-opacity active:scale-90"),onClick:t,children:r.jsx(T.XIcon,{className:"size-3"})})]})}const $e={"close-panel":"Escape","toggle-fullscreen":"Mod+Shift+F",send:"Enter","send-alt":"Mod+Enter","history-prev":"ArrowUp","history-next":"ArrowDown"};function Ei(){return typeof navigator>"u"?!1:/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}function xt(e,t,n=Ei()){const o=t.split("+"),s=o.at(-1)??"",i=new Set(o.slice(0,-1)),a=i.has("Cmd")||i.has("Mod")&&n,c=i.has("Ctrl")||i.has("Mod")&&!n;return e.metaKey!==a||e.ctrlKey!==c||e.altKey!==i.has("Alt")||e.shiftKey!==i.has("Shift")?!1:e.key.toLowerCase()===s.toLowerCase()}const jm={Mod:"⌘",Cmd:"⌘",Ctrl:"⌃",Alt:"⌥",Shift:"⇧"},Cm={Escape:"Esc",Enter:"⏎",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→"};function ho(e,t=Ei()){const n=e.split("+"),o=n.at(-1)??"",s=n.slice(0,-1),i=Cm[o]??(o.length===1?o.toUpperCase():o);return t?[...s.map(a=>jm[a]??a),i].join(""):[...s.map(a=>a==="Mod"?"Ctrl":a),i].join("+")}const Sm=50*1024*1024,Ti={"application/pdf":[".pdf"],..._d,...Ed},Nm={"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],...Ti},_m={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"],...Ti};function Em({status:e}){switch(e){case"uploading":return r.jsx(T.Loader2,{className:"size-4 animate-spin"});case"error":return r.jsx(T.AlertCircle,{className:"size-4 text-destructive"});default:return null}}function Tm({file:e,fileContent:t}){const n=e.type.split("/")[0];return n==="image"&&t?r.jsx("img",{src:typeof t=="string"?t:"",className:"object-cover bg-secondary size-full",alt:e.name}):n==="audio"?r.jsx(T.FileAudio2Icon,{className:"size-4 text-muted-foreground"}):n==="video"?r.jsx(T.FileVideo2Icon,{className:"size-4 text-muted-foreground"}):e.type==="application/pdf"?r.jsx(T.FileText,{className:"size-4 text-muted-foreground"}):$a({type:e.type,name:e.name})?r.jsx(T.FileSpreadsheet,{className:"size-4 text-muted-foreground"}):r.jsx(T.FileIcon,{className:"size-4 text-muted-foreground"})}function Am({file:{status:e,file:t,error:n},onCancel:o}){const{t:s}=Y(),[i,a]=u.useState(null);return u.useEffect(()=>{if(!t.type.startsWith("image/"))return;const c=new FileReader;return c.onload=()=>a(c.result),c.onerror=()=>G.log.error("failed to read file for preview"),c.readAsDataURL(t),()=>c.abort()},[t]),r.jsx(Ie,{side:"bottom",content:e==="error"?r.jsx("span",{className:"text-destructive",children:s("upload_failed",{error:n??""})}):t.name,children:r.jsxs("div",{className:A(e==="uploading"&&"opacity-50","group","size-12 border rounded-2xl overflow-hidden relative","flex items-center justify-center shrink-0"),children:[r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx(Em,{status:e})}),r.jsx("button",{type:"button",className:A("absolute bg-foreground/50 inset-0 size-full z-10","flex items-center justify-center","opacity-0 group-hover:opacity-100 transition"),onClick:o,"aria-label":s("remove_attachment"),children:r.jsx(T.XIcon,{className:"size-4 text-primary-foreground"})}),r.jsx(Tm,{file:t,fileContent:i})]})})}function Im(){const{queuedUserMessages:e,removeQueued:t,stop:n}=C.useAgentChatUi(),{messagesState:{messages:o}}=C.useMessages(),{t:s}=Y(),i=u.useMemo(()=>e.filter(a=>!o.some(c=>c.id===a.id)),[e,o]);return r.jsx(W.AnimatePresence,{children:i.length>0&&r.jsx(Se,{children:r.jsxs("div",{...P("chat/queued_sends/root"),className:"mb-1 rounded-2xl border border-muted-foreground/15 bg-background shadow-sm",children:[r.jsxs("div",{...P("chat/queued_sends/header"),className:"flex items-center justify-between px-3 pt-2 pb-1",children:[r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("queued_label",{count:i.length})}),r.jsx("button",{type:"button",...P("chat/queued_sends/send_now"),"aria-label":s("send_queued_now"),title:s("send_queued_now"),onClick:n,className:"rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground hover:bg-muted",children:r.jsx(T.CornerDownLeftIcon,{className:"size-3"})})]}),r.jsx("ul",{...P("chat/queued_sends/list"),className:"flex flex-col pb-1",children:i.map(a=>r.jsxs("li",{...P("chat/queued_sends/item"),className:"group flex items-center gap-2 px-3 py-1",children:[r.jsx("button",{type:"button",title:s("send_queued_now"),onClick:n,className:"min-w-0 flex-1 truncate text-start text-xs text-foreground/80 hover:text-foreground",children:a.content}),r.jsx("button",{type:"button",...P("chat/queued_sends/remove"),"aria-label":s("remove_queued_message"),onClick:()=>t(a.id),className:"shrink-0 rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground hover:bg-muted",children:r.jsx(T.XIcon,{className:"size-3.5"})})]},a.id))})]})},"queued-sends-pill")})}function zm({levelRef:e}){const t=u.useRef(null);return u.useEffect(()=>{let n=0;const o=new G.DictationLevelSmoother({attack:.2,release:.07}),s=[],i=()=>{var c;const a=(c=t.current)==null?void 0:c.children;if(a){const d=o.next(e.current);for(let l=0;l<a.length;l++){const m=a[l];if(m instanceof HTMLElement){const p=.75+.25*Math.sin(Date.now()/260+l*1.7),h=`scaleY(${Math.max(.25,Math.min(1,d*1.8*p)).toFixed(3)})`;s[l]!==h&&(m.style.transform=h,s[l]=h)}}}n=requestAnimationFrame(i)};return n=requestAnimationFrame(i),()=>cancelAnimationFrame(n)},[e]),r.jsx("div",{ref:t,"aria-hidden":"true",className:"flex h-3.5 shrink-0 items-center gap-[3px]",children:[0,1,2,3].map(n=>r.jsx("span",{className:"h-full w-[3px] origin-center scale-y-50 rounded-full bg-current transition-transform duration-100 ease-out"},n))})}function Mm({status:e,levelRef:t,onToggle:n,onPrewarm:o}){const{t:s}=Y(),i=e==="listening",a=e==="connecting",c=s(i||a?"stop_dictation":"dictate");return r.jsx(Ie,{side:"top",align:"start",content:c,children:r.jsxs(V,{...P("chat/input_box/dictate_btn"),onClick:n,onPointerDown:d=>d.preventDefault(),onPointerEnter:o,onFocus:o,"aria-pressed":i||a,"aria-label":c,size:"fit",variant:"ghost",className:A("relative",kn,i&&_i),children:[a&&r.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0.5 animate-spin rounded-full border-[1.5px] border-current/20 border-t-current"}),r.jsx(W.AnimatePresence,{mode:"wait",children:i?r.jsx(ee,{distance:0,children:r.jsx(zm,{levelRef:t})},"bars"):r.jsx(ee,{distance:0,children:r.jsx(T.MicIcon,{className:A("size-4",a&&"opacity-60")})},"mic")})]})})}function Rm(e,t){const n=e.ownerDocument;if(!n.defaultView)return null;const s=n.createElement("div");Ai(e,s),Object.assign(s.style,{position:"absolute",visibility:"hidden",top:"0",left:"-9999px",height:"auto",overflow:"hidden",whiteSpace:"pre-wrap",overflowWrap:"break-word",width:`${e.clientWidth}px`}),s.textContent=e.value.slice(0,t);const i=n.createElement("span");i.textContent="",s.appendChild(i),n.body.appendChild(s);const a=i.offsetLeft,c=i.offsetTop-e.scrollTop;return s.remove(),{left:a,top:c}}function Ai(e,t){const n=e.ownerDocument.defaultView;if(!n)return;const o=n.getComputedStyle(e);for(const s of Pm)t.style.setProperty(s,o.getPropertyValue(s))}const Pm=["box-sizing","font-family","font-size","font-weight","font-style","letter-spacing","line-height","text-transform","text-indent","word-spacing","tab-size","padding-top","padding-right","padding-bottom","padding-left","border-top-width","border-right-width","border-bottom-width","border-left-width"],Om=300,Ii=260,$m=8,zi="rounded-xl border border-border bg-background shadow-lg";function Lm({anchorRef:e,inputRef:t,anchorIndex:n,preview:o,groups:s,visible:i,searching:a,highlighted:c,onHighlight:d,onPick:l,onExpand:m}){var S;const{t:p}=Y(),[h,f]=u.useState(null);u.useLayoutEffect(()=>{const w=e.current;if(!w)return;const _=w.ownerDocument.defaultView,y=()=>{const N=w.getBoundingClientRect(),R=(_==null?void 0:_.innerWidth)??N.right,M=Math.min(Om,Math.max(0,R-16)),z=t.current,L=z&&n!==null?Rm(z,n):null,O=z==null?void 0:z.getBoundingClientRect(),U=L&&O?O.left+L.left:N.left+8,E=Math.max(8,Math.min(U,R-8-M)),I=L&&O?O.top+L.top-4:N.top-4;f({left:E,width:M,top:I,detailBeside:o&&E+M+$m+Ii<=R-8})};y(),_==null||_.addEventListener("resize",y);const v=typeof ResizeObserver>"u"?null:new ResizeObserver(y);return v==null||v.observe(w),()=>{_==null||_.removeEventListener("resize",y),v==null||v.disconnect()}},[n,e,t,o,i.length]);const x=(S=e.current)==null?void 0:S.closest("[data-version]");if(!x||!h||i.length===0&&a)return null;const g=i[c],j=g!=null&&g.description?g:null;let b=-1;return Kt.createPortal(r.jsxs("div",{...P("chat/input_box/mention_picker"),style:{position:"fixed",left:h.left,top:h.top,transform:"translateY(-100%)"},className:"z-50 flex items-end gap-2",children:[r.jsx("div",{role:"listbox",style:{width:h.width},className:A("flex max-h-72 flex-col overflow-hidden",zi),children:r.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-1",children:i.length===0?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:p("mentions_empty")}):s.map(w=>u.createElement("div",{...P("chat/input_box/mention_picker/group"),key:w.type,role:"group","aria-label":w.type},r.jsx("div",{className:"px-2 pb-0.5 pt-1.5 text-xs capitalize text-muted-foreground",children:w.type}),w.items.map(_=>{const y=++b;return u.createElement("button",{...P("chat/input_box/mention_picker/option"),key:`${_.type}:${_.id}`,type:"button",role:"option","aria-selected":y===c,onMouseDown:v=>v.preventDefault(),onMouseEnter:()=>d(y),onClick:()=>l(_),className:A("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-sm",y===c?"bg-muted":"hover:bg-muted/60")},r.jsx(Mi,{item:_}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:_.title}))}),w.hidden>0&&r.jsx("button",{...P("chat/input_box/mention_picker/more"),type:"button",onMouseDown:_=>_.preventDefault(),onClick:()=>m(w.type),className:A("w-full rounded-lg px-2 py-1 text-start text-xs","text-muted-foreground hover:bg-muted/60 hover:text-foreground"),children:p("json_see_more",{count:String(w.hidden)})})))})}),j&&h.detailBeside&&r.jsx(Dm,{item:j})]}),x)}function Dm({item:e}){return r.jsxs("div",{...P("chat/input_box/mention_picker/detail"),style:{width:Ii},className:A("flex gap-3 p-3",zi),children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted",children:r.jsx(Mi,{item:e,className:"size-4"})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-[10px] uppercase tracking-wide text-muted-foreground",children:e.type}),r.jsx("span",{className:"block truncate text-sm font-medium text-foreground",children:e.title}),r.jsx("span",{className:"mt-0.5 line-clamp-3 text-xs text-muted-foreground",children:e.description})]})]})}function Mi({item:e,className:t}){return e.icon?r.jsx("img",{src:e.icon,alt:"",className:A("size-4 shrink-0 rounded-sm object-contain",t)}):r.jsx(It,{name:e.iconName??"AtSign",className:A("size-3.5 shrink-0 text-primary",t)})}const Ri=u.createContext(null);function Fm({children:e}){const[t,n]=u.useState([]),[o,s]=u.useState(!1),i=u.useRef(new Map),a=u.useCallback(p=>{s(p)},[]),c=u.useCallback((p,h)=>{i.current.set(p,h),n(f=>[...f,p])},[]),d=u.useCallback(p=>{const h=i.current.get(p);h&&(i.current.delete(p),h.undraw()),n(f=>f.filter(x=>x!==p))},[]),l=u.useCallback(()=>{const p=Array.from(i.current.values());i.current.clear();for(const h of p)h.undraw();n([])},[]);u.useEffect(()=>()=>{i.current.forEach(p=>p.remove()),i.current.clear()},[]);const m=u.useMemo(()=>({marks:t,isArmed:o,setArmed:a,attach:c,detach:d,detachAll:l}),[t,o,a,c,d,l]);return r.jsx(Ri.Provider,{value:m,children:e})}function fo(){const e=u.useContext(Ri);if(!e)throw new Error("usePageMarks must be used within a PageMarksProvider");return e}const Hm="data-opencx-mark-cursor",Wm=5,xn=4,bn=6,Qn={width:160,height:100},Um=10,Bm=ao.map(e=>`:not(${e}):not(${e} *)`).join(""),qm=e=>e==="nw"||e==="se"?"nwse-resize":"nesw-resize";function Vm({enabled:e,composerRef:t,onAttach:n,accentColor:o,zIndex:s}){const{isArmed:i,setArmed:a,attach:c}=fo(),d=e&&i,[l,m]=u.useState(null),[p,h]=u.useState(null),f=u.useRef(null),x=u.useRef(null);x.current=l;const g=u.useCallback(()=>{var y;(y=f.current)==null||y.undraw(),f.current=null,m(null)},[]),j=u.useCallback(()=>a(!1),[a]),b=u.useCallback(y=>{var v;m(N=>N&&{...N,rect:y}),(v=f.current)==null||v.setRect({x:y.x+window.scrollX,y:y.y+window.scrollY,width:y.width,height:y.height})},[]),S=u.useCallback(y=>{var v;m(N=>N&&{...N,shape:y}),(v=f.current)==null||v.setShape(y)},[]);u.useEffect(()=>{!e&&i&&a(!1)},[e,i,a]),u.useEffect(()=>{var ke;if(!d)return;const y=document.createElement("style");y.setAttribute(Hm,"");let v=null;const N=D=>{D!==v&&(v=D,y.textContent=`*${Bm} { cursor: ${D} !important; }`)};N("crosshair"),document.head.appendChild(y);let R=null;const M=D=>D.target instanceof Element&&on(D.target),z=D=>M(D)?!1:(D.preventDefault(),D.stopPropagation(),D.stopImmediatePropagation(),!0),L=(D,te,J)=>{const ne=[["nw",D.x,D.y],["ne",D.x+D.width,D.y],["sw",D.x,D.y+D.height],["se",D.x+D.width,D.y+D.height]];for(const[pe,ce,se]of ne)if(Math.hypot(te-ce,J-se)<=Um)return pe;return null},O=(D,te,J)=>te>=D.x&&te<=D.x+D.width&&J>=D.y&&J<=D.y+D.height,U=(D,te)=>{var ce;const J=_r(D,te),ne=ls(J?(()=>{const se=J.getBoundingClientRect();return{x:se.left-bn,y:se.top-bn,width:se.width+bn*2,height:se.height+bn*2}})():{x:D-Qn.width/2,y:te-Qn.height/2,...Qn}),pe=((ce=x.current)==null?void 0:ce.shape)??"box";h(null),f.current=zp({x:ne.x+window.scrollX,y:ne.y+window.scrollY,width:ne.width,height:ne.height},pe,o,s),m({rect:ne,shape:pe})},E=D=>{var ne;if(!z(D)||D.button!==0)return;const te=x.current;if(!te){U(D.clientX,D.clientY);return}const J=L(te.rect,D.clientX,D.clientY);if(J){R={kind:"resize",corner:J};return}if(O(te.rect,D.clientX,D.clientY)){R={kind:"move",grabX:D.clientX-te.rect.x,grabY:D.clientY-te.rect.y};return}(ne=f.current)==null||ne.undraw(),f.current=null,U(D.clientX,D.clientY)};let I=null,H=0;const $=D=>{if(!z(D))return;const te=x.current;if(!te){N("crosshair");const de=_r(D.clientX,D.clientY);if(!de){I=null,h(null);return}de!==I&&(I=de,H+=1),h({rect:ls(Lp(de)),key:H});return}if(!R){const de=L(te.rect,D.clientX,D.clientY);N(de?qm(de):O(te.rect,D.clientX,D.clientY)?"move":"crosshair");return}const{rect:J}=te;if(R.kind==="move"){b({...J,x:D.clientX-R.grabX,y:D.clientY-R.grabY});return}const ne=R.corner.includes("w")?J.x+J.width:J.x,pe=R.corner.includes("n")?J.y+J.height:J.y,ce=Math.min(ne,D.clientX),se=Math.max(ne,D.clientX),Le=Math.min(pe,D.clientY),De=Math.max(pe,D.clientY);b({x:ce,y:Le,width:Math.max(is,se-ce),height:Math.max(is,De-Le)})},q=D=>{z(D)&&(R=null)},X=D=>{M(D)||z(D),R=null},B=D=>{z(D)},F=D=>{var te;if(D.key==="Escape"){if(D.preventDefault(),D.stopImmediatePropagation(),R=null,x.current){(te=f.current)==null||te.undraw(),f.current=null,m(null),N("crosshair");return}a(!1)}};let Z=window.scrollX,re=window.scrollY;const ae=()=>{h(null);const D=window.scrollX-Z,te=window.scrollY-re;Z=window.scrollX,re=window.scrollY,!(D===0&&te===0)&&m(J=>J&&{...J,rect:{...J.rect,x:J.rect.x-D,y:J.rect.y-te}})};document.addEventListener("pointerdown",E,!0),document.addEventListener("pointermove",$,!0),document.addEventListener("pointerup",q,!0),document.addEventListener("pointercancel",X,!0),document.addEventListener("click",B,!0);const fe=new Set([window]),oe=(ke=t==null?void 0:t.current)==null?void 0:ke.ownerDocument.defaultView;return oe&&fe.add(oe),fe.forEach(D=>D.addEventListener("keydown",F,!0)),document.addEventListener("scroll",ae,!0),()=>{y.remove(),document.removeEventListener("pointerdown",E,!0),document.removeEventListener("pointermove",$,!0),document.removeEventListener("pointerup",q,!0),document.removeEventListener("pointercancel",X,!0),document.removeEventListener("click",B,!0),fe.forEach(D=>D.removeEventListener("keydown",F,!0)),document.removeEventListener("scroll",ae,!0),h(null)}},[d,t,o,s,b,a]),u.useEffect(()=>{!d&&x.current&&g()},[d,g]),u.useEffect(()=>()=>{var y;(y=f.current)==null||y.remove(),f.current=null},[]);const w=u.useCallback(y=>{if(!e)return;const v=x.current,N=f.current;if(!v||!N)return;const R=y.trim(),M=Ym(v.rect),z={shape:v.shape,...R?{note:R}:{},pageUrl:io(window.location.href),rect:v.rect,elements:M.map(vi)};Hp(z,M),M[0]&&ep(z,M[0]),f.current=null,m(null),a(!1),c(z,N),n==null||n(z)},[c,e,n,a]),_=u.useCallback(()=>{e&&a(!i)},[e,i,a]);return{isActive:d,draft:l,hover:p,setShape:S,attach:w,dropDraft:g,disarm:j,toggle:_}}function Ym(e){const t=new Set,n=(o,s)=>{const i=_r(o,s);i&&t.add(i)};n(e.x+e.width/2,e.y+e.height/2);for(let o=0;o<=xn;o++)for(let s=0;s<=xn;s++)n(e.x+e.width*o/xn,e.y+e.height*s/xn);return Array.from(t).slice(0,Wm)}function Xm({enabled:e,inputRef:t}){const{widgetCtx:n}=C.useWidget(),{theme:o,cssVars:s}=ue(),i=mo({cssVars:s,primaryColor:o.primaryColor,contentZIndex:o.widgetContentContainer.zIndex}),{marks:a,detach:c}=fo(),d=u.useCallback(()=>{var p;(p=t.current)==null||p.focus()},[t]),l=u.useCallback(async p=>{if(!n.features.pageContext||!n.features.attachments)return null;try{const{fileUrl:h}=await n.api.uploadFile({file:p,abortSignal:new AbortController().signal});return h??null}catch(h){return G.log.warn("page mark snapshot upload failed",h),null}},[n]),m=Vm({enabled:e,composerRef:t,onAttach:d,accentColor:i.accent,zIndex:i.inkZIndex});return{marks:a,detach:c,marking:m,uploadSnapshot:l}}function Gm({inputText:e,setInputText:t,inputRef:n,getSentTextHistory:o}){const s=u.useRef(null),i=u.useRef(""),a=()=>{const p=n.current;p&&(p.classList.remove("opencx-input-recall"),p.offsetWidth,p.classList.add("opencx-input-recall"))},c=(p,{animate:h=!0}={})=>{t(p),h&&a(),requestAnimationFrame(()=>{var f;return(f=n.current)==null?void 0:f.setSelectionRange(p.length,p.length)})};return{onKeyDown:p=>{if(xt(p,$e["history-prev"])){const h=o();if(h.length===0)return!1;const f=s.current;if(f===null){const x=n.current;if(!((x==null?void 0:x.selectionStart)===0&&(x==null?void 0:x.selectionEnd)===0)&&e!=="")return!1;i.current=e,s.current=h.length-1}else{if(f===0)return!1;s.current=f-1}return p.preventDefault(),c(h[s.current],{animate:!p.repeat}),!0}if(xt(p,$e["history-next"])){const h=s.current;if(h===null)return!1;p.preventDefault();const f=o();return h>=f.length-1?(s.current=null,c(i.current,{animate:!p.repeat}),i.current=""):(s.current=h+1,c(f[s.current],{animate:!p.repeat})),!0}return!1},onEdit:()=>{s.current=null},onSent:()=>{s.current=null,i.current=""}}}const ws="max-h-16 [field-sizing:content] w-full px-2",Km=1e3;function Pi(e={}){const{sessionEnded:t}=C.useTokenRenewal();return t?r.jsx(Zm,{}):r.jsx(Jm,{...e})}function Zm(){const{t:e}=Y();return r.jsx("div",{className:"p-2",...P("chat/session_ended"),children:r.jsxs("div",{role:"status",className:"flex items-center gap-2 p-3 bg-muted rounded-[var(--opencx-inset-radius)] text-sm",children:[r.jsx(T.LockIcon,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx("span",{children:e("session_ended_sign_in_again")})]})})}function Jm({trailingActions:e,placeholder:t,hideAttachTools:n,disabled:o=!1}){var ln;const{isSmallScreen:s}=ye(),i=u.useRef(null),a=u.useRef(null),c=u.useRef(null),d=u.useRef(!0),{messagesState:l,rememberSentText:m,getSentTextHistory:p}=C.useMessages(),h=rn(),{widgetCtx:f,componentStore:x}=C.useWidget(),{attachments:g,pageContext:j}=f.features,{isStreaming:b,stop:S,queuedUserMessages:w,pendingClarification:_,pendingConnection:y,pendingPageAction:v}=C.useAgentChatUi(),{sessionState:N}=C.useSessions(),R=o||Cr({isStreaming:b,messages:l.messages,session:N.session}),M=u.useRef(b);M.current=b;const{t:z}=Y(),{text:L,setText:O,clearSubmitted:U}=C.useComposerDraft(),E=gm(),I=mp({text:L,setText:O,inputRef:i}),H=I.picked.length>0;u.useLayoutEffect(()=>{const K=i.current,ge=c.current;!K||!ge||Ai(K,ge)},[H,L]);const[$,q]=u.useState(!1),X=E?`${E.type}:${E.id}`:"";u.useEffect(()=>{q(!1)},[X]);const[B,F]=u.useState(null),Z=u.useRef(L);Z.current=L;const re=u.useRef(()=>{}),ae=C.useDictation({getValue:()=>Z.current,setValue:K=>{Z.current=K,O(K)},onSend:()=>re.current()}),{stop:fe}=ae;u.useEffect(()=>{R&&fe({executeFinalCommand:!1})},[R,fe]),u.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const oe=Gm({inputText:L,setInputText:O,inputRef:i,getSentTextHistory:p}),ke=j&&!s,D=!R&&ke&&n!==!0,{marks:te,detach:J,marking:ne,uploadSnapshot:pe}=Xm({enabled:D,inputRef:i});u.useEffect(()=>{j||te.forEach(J)},[j,te,J]);const{allFiles:ce,handleCancelUpload:se,appendFiles:Le,emptyTheFiles:De,isUploading:de,successFiles:qe}=C.useUploadFiles();u.useEffect(()=>{!g&&ce.length>0&&De()},[g,ce.length,De]);const st=!!((ln=N.session)!=null&&ln.isHandedOff),{isAwaitingBotReply:Ve}=C.useIsAwaitingBotReply(),Fe=f.messageCtx.blocksSendWhileAwaitingReply&&Ve,Ye=K=>{R||!g||(F(null),Le(K))},Xe=E!==null&&!$,xe=ce.length>0||te.length>0,Re=!L.trim()&&qe.length===0&&(!j||!te.some(yn)),He=b&&Re,Fn=He&&w.length>0,an=R||de||Fe||Re,we=u.useRef(0),Pt=()=>{Date.now()-we.current<Km||S()},Ot=()=>{if(ae.stop({executeFinalCommand:!1}),R||Fe||de)return;const K=Z.current,ge=f.messageCtx.captureConversation(),$t=f.messageCtx.draftState.get(),We=te.filter(Ne=>f.features.pageContext&&yn(Ne)?!0:(J(Ne),!1)),Pe=f.features.attachments?[...qe]:[];if(!K.trim()&&Pe.length===0&&We.length===0)return;we.current=Date.now();const at=ce.map(Ne=>Ne.id);We.forEach(Ne=>tp(Ne,pe)),Promise.all(We.map(Ne=>np(Ne,Qm))).then(()=>wt({isCurrentConversation:ge,submittedText:K,submittedDraft:$t,submittedMarks:We,submittedFiles:Pe,submittedFileIds:at}))},wt=({isCurrentConversation:K,submittedText:ge,submittedDraft:$t,submittedMarks:We,submittedFiles:Pe,submittedFileIds:at})=>{if(!K()||Cr({isStreaming:M.current,messages:f.messageCtx.state.get().messages,session:f.sessionCtx.sessionState.get().session}))return;const vt=f.features.pageContext,it=We.filter(me=>vt&&yn(me)?!0:(J(me),!1));if(!ge.trim()&&Pe.length===0&&it.length===0)return;const dn=ge.trim()||(it.length>0?eh(it)??z("page_mark_default_message"):"");let Lt=!1;const yt=I.picked;h({content:dn,withPageEntity:!$,mentions:yt.length>0?yt:void 0,attachments:Pe.flatMap(me=>me.fileUrl?[{url:me.fileUrl,type:me.file.type,name:me.file.name,id:me.id,size:me.file.size}]:[]),clientContext:Ni({marks:it,readsPage:vt}),onAccepted:()=>{if(Lt||!K())return;Lt=!0,m(dn),We.forEach(Dt=>J(Dt)),at.forEach(Dt=>se(Dt));const me=U($t);d.current&&(oe.onSent(),q(!1),me&&I.reset())}}).catch(me=>{G.log.error("failed to send message",me)})},{getRootProps:cn,getInputProps:Hn,open:Wn}=vc.useDropzone({onDrop:Ye,noClick:!0,disabled:R||!g,onDropRejected(){F(z("file_rejected"))},maxSize:Sm,accept:st?Nm:_m}),Un=K=>{const ge=K.clipboardData;ge&&ge.files.length>0&&Ye(Array.from(ge.files))};re.current=Ot;const je=x.getComponent("agent_chat_questions");return!y&&_&&je?r.jsx("div",{...P("chat/input_box/root"),className:"p-2 relative space-y-1",children:r.jsx(je,{request:_})}):r.jsxs("div",{...P("chat/input_box/root"),className:"p-2 relative space-y-1",...cn({ref:a}),children:[N.session&&r.jsx(Np,{sessionId:N.session.id,active:b||Ve},N.session.id),y&&r.jsx(Ep,{request:y},y.request_id),v&&r.jsx(pm,{request:v},v.callId),r.jsx("input",{...Hn()}),I.isOpen&&r.jsx(Lm,{anchorRef:a,inputRef:i,anchorIndex:I.anchorIndex,preview:I.preview,groups:I.groups,visible:I.visible,searching:I.searching,highlighted:I.highlighted,onHighlight:I.setHighlighted,onPick:I.pick,onExpand:I.expandGroup}),D&&r.jsx(xm,{isActive:ne.isActive,draft:ne.draft,hover:ne.hover,onShapeChange:ne.setShape,onAttach:ne.attach}),r.jsx(Im,{}),B&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:B}),ae.error&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:ae.error==="microphone"?z("dictation_mic_blocked"):z("dictation_unavailable")}),r.jsxs("div",{...P("chat/input_box/attached_context_tray"),style:{"--cx-p":"0.25rem"},className:A("flex flex-col","rounded-[calc(var(--opencx-inset-radius)+var(--cx-p))] p-[var(--cx-p)]","transition-colors duration-200 ease-opencx",Xe?"bg-muted":"bg-transparent"),children:[r.jsx(W.AnimatePresence,{children:Xe&&r.jsx(Se,{children:r.jsx("div",{...P("chat/input_box/page_context_container"),className:"flex items-center gap-1 flex-wrap ps-3 pe-1 py-1",children:r.jsx(W.AnimatePresence,{mode:"popLayout",children:E&&!$&&r.jsx(ee,{snapExit:!0,children:r.jsx(hm,{entity:E,onRemove:()=>q(!0)})},"page-entity")})})},"attached-context")}),r.jsxs("div",{...P("chat/input_box/inner_root"),className:A("transition-colors","bg-background","border border-border","relative rounded-[var(--opencx-inset-radius)] flex flex-col gap-2 p-2"),children:[r.jsxs("div",{...P("chat/input_box/textarea_and_attachments_container"),className:"flex flex-col gap-2",children:[xe&&r.jsx("div",{...P("chat/input_box/attachments_container"),className:"flex items-center gap-1 overflow-x-auto",children:r.jsxs(W.AnimatePresence,{mode:"popLayout",children:[ce.map(K=>r.jsx(ee,{snapExit:!0,children:r.jsx(Am,{onCancel:()=>se(K.id),file:K})},K.id)),te.map((K,ge)=>r.jsx(ee,{snapExit:!0,children:r.jsx(km,{mark:K,onRemove:()=>J(K)})},`mark-${ge}-${K.note??""}`))]})}),r.jsxs("div",{className:"relative",children:[H&&r.jsx("div",{ref:c,"aria-hidden":!0,className:A(ws,"pointer-events-none absolute inset-0 overflow-hidden","whitespace-pre-wrap break-words text-foreground",!xe&&"pt-1",s?"text-[16px]":"text-sm"),children:r.jsx(xi,{text:L,mentions:I.picked,tokenClassName:"bg-primary/10 text-primary"})}),r.jsx("textarea",{...P("chat/input_box/textarea"),disabled:R,onPaste:Un,ref:i,id:"chat-input",value:L,rows:3,className:A(ws,"relative resize-none",!xe&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground",H&&"text-transparent caret-foreground",s?"text-[16px]":"text-sm"),onScroll:K=>{c.current&&(c.current.scrollTop=K.currentTarget.scrollTop)},onChange:K=>{oe.onEdit(),O(K.target.value),f.messageCtx.notifyTyping()},onClick:()=>I.onCaretMove("nearest"),onKeyUp:K=>{K.key==="ArrowRight"||K.key==="ArrowDown"?I.onCaretMove("forward"):K.key==="ArrowLeft"||K.key==="ArrowUp"?I.onCaretMove("backward"):(K.key==="Home"||K.key==="End")&&I.onCaretMove("nearest")},onKeyDown:K=>{if(!K.nativeEvent.isComposing&&!I.onKeyDown(K)){if(xt(K,$e.send)||xt(K,$e["send-alt"])){K.preventDefault(),Fn?S():Ot();return}oe.onKeyDown(K)}},placeholder:t??z("write_a_message_placeholder")})]})]}),r.jsxs("div",{className:"gap-2 flex justify-between",children:[r.jsx("div",{className:"flex items-center gap-1",children:!R&&!n&&r.jsxs(r.Fragment,{children:[g&&r.jsx(Ie,{side:"top",align:"start",content:z("attach_files"),children:r.jsx(V,{onClick:Wn,"aria-label":z("attach_files"),size:"fit",variant:"ghost",className:kn,children:r.jsx(W.AnimatePresence,{mode:"wait",children:Fe?r.jsx(ee,{distance:0,children:r.jsx(T.PaperclipIcon,{className:"size-4 opacity-50"})},"paper-clip-disabled"):r.jsx(ee,{distance:0,children:r.jsx(T.PaperclipIcon,{className:"size-4"})},"paper-clip")})})}),ae.enabled&&r.jsx(Mm,{status:ae.status,levelRef:ae.levelRef,onToggle:ae.toggle,onPrewarm:ae.prewarm}),ke&&r.jsx(Ie,{side:"top",align:"start",content:ne.isActive?z("mark_page_active"):z("mark_page"),children:r.jsx(V,{...P("chat/input_box/page_mark_btn"),onClick:ne.toggle,"aria-label":ne.isActive?z("mark_page_active"):z("mark_page"),size:"fit",variant:"ghost",className:A(kn,ne.isActive&&_i),children:r.jsx(T.MousePointerClickIcon,{className:"size-4"})})})]})}),r.jsxs("div",{className:"flex items-center gap-1",children:[e,r.jsx(Ie,{content:z(He?"stop_response":"send_message"),shortcut:He?void 0:ho($e.send),side:"top",align:"end",children:r.jsx(V,{size:"fit",onClick:He?Pt:Ot,"aria-label":z(He?"stop_response":"send_message"),disabled:R||!He&&an,className:kn,children:r.jsx(W.AnimatePresence,{mode:"wait",children:He?r.jsx(ee,{snapExit:!0,distance:0,children:r.jsx(T.SquareIcon,{className:"size-3 fill-current"})},"stop"):!b&&(Fe||de)?r.jsx(ee,{snapExit:!0,distance:0,children:r.jsx(T.CircleDashed,{className:"size-4 animate-spin animate-iteration-infinite"})},"loading"):r.jsx(ee,{snapExit:!0,distance:0,children:r.jsx(T.ArrowUpIcon,{className:"size-4"})},"send")})})})]})]})]})]})]})}const Qm=1500;function eh(e){const t=e.flatMap(n=>{var s;const o=(s=n.note)==null?void 0:s.trim();return o?[o]:[]});return t.length>0?t.join(`
|
|
129
|
-
`):null}function vs(){const{widgetCtx:e}=C.useWidget(),{router:t}=C.useConfig(),{canCreateNewSession:n}=C.useSessions(),{toSessionsScreen:o}=C.useWidgetRouter(),{t:s}=Y();return r.jsx(r.Fragment,{children:n||t!=null&&t.chatScreenOnly?r.jsx(V,{onClick:e.resetChat,className:"rounded-2xl w-full",children:s("new_conversation")}):r.jsx(V,{onClick:o,className:"rounded-2xl w-full",children:s("back_to_conversations")})})}function th(){const{t:e}=Y(),t=C.useCsat(),n=C.useCsat("nps"),o=C.useCsat("ces"),s=t.isCsatRequested||n.isCsatRequested||o.isCsatRequested,i=!s&&(t.isCsatSubmitted||n.isCsatSubmitted||o.isCsatSubmitted);return r.jsx("div",{className:"p-2",children:r.jsx("div",{className:"p-2 bg-muted rounded-[var(--opencx-inset-radius)]",children:r.jsx(W.AnimatePresence,{mode:"wait",children:s||i?r.jsxs(Se,{children:[r.jsx(Zn,{}),r.jsx(Zn,{surveyType:"nps"}),r.jsx(Zn,{surveyType:"ces"}),r.jsx(W.AnimatePresence,{mode:"wait",children:i&&r.jsx(Se,{children:r.jsx(vs,{})},"new-conv-or-back-to-convs-button")})]},"csat"):r.jsxs(Se,{children:[r.jsxs("div",{className:"ps-2 flex items-center gap-1 pb-2",children:[r.jsx(T.CircleCheckIcon,{className:"size-4 text-emerald-600"}),r.jsx("h2",{className:"text-sm font-medium",children:e("your_issue_has_been_resolved")})]}),r.jsx(vs,{})]},"session-closed")})})})}function nh(){var j,b;const{initialQuestions:e,initialQuestionsPosition:t,stickyQuestions:n,thisWasHelpfulOrNot:o}=C.useConfig(),{sessionState:s}=C.useSessions(),{messagesState:i}=C.useMessages(),{isStreaming:a,pendingClarification:c,pendingConnection:d,pendingPageAction:l}=C.useAgentChatUi(),{text:m}=C.useComposerDraft(),p=i.messages.length===0,h=bi(),f=Cr({isStreaming:a,messages:i.messages,session:s.session}),x=i.lastAIResMightSolveUserIssue&&(o==null?void 0:o.enabled)!==!1,g=kp({stickyQuestions:n,messages:i.messages,isHandedOff:!!((j=s.session)!=null&&j.isHandedOff),isStreaming:a,isTyping:m.trim().length>0,otherSuggestionsShowing:x||f||c!==null||d!==null||l!==null});return r.jsx("footer",{children:r.jsx(W.AnimatePresence,{mode:"wait",children:s.session&&!((b=s.session)!=null&&b.isOpened)?r.jsxs(Se,{children:[r.jsx(th,{}),r.jsx(Sr,{})]},"session-closed"):r.jsxs(Se,{children:[x&&r.jsx(Sp,{}),p&&e&&t!=="below-initial-messages"&&r.jsx("div",{className:A("flex items-center flex-row justify-end gap-2 flex-wrap px-2",h&&"pb-4"),children:e==null?void 0:e.map((S,w)=>r.jsx(qt,{suggestion:S},`${S}-${w}`))}),g.length>0&&r.jsx("div",{className:"flex items-center flex-row justify-end gap-2 flex-wrap px-2",children:g.map((S,w)=>r.jsx(qt,{suggestion:S},`${S}-${w}`))}),!h&&!f&&r.jsx(Pi,{}),r.jsx(Sr,{})]},"chat-input")})})}function rh(){var j;const{messagesState:{messages:e,isAgentTyping:t}}=C.useMessages(),{isAwaitingBotReply:n}=C.useIsAwaitingBotReply(),{componentStore:o}=C.useWidget(),s=C.useBot(),i=u.useMemo(()=>ii(e),[e]),a=e.at(-1),c=a==null?void 0:a.id,d=a==null?void 0:a.type,l=u.useRef(c),[m,p]=u.useState(!1),h=n&&!m;u.useEffect(()=>{const b=l.current!==c;if(l.current=c,!n||d!=="AI"){p(!1);return}if(!b)return;p(!0);const S=setTimeout(()=>p(!1),600);return()=>clearTimeout(S)},[n,c,d]);const f=o.getComponent("loading"),x=u.useRef(null);function g(){setTimeout(()=>{const b=x.current;b&&(b.scrollTop=b.scrollHeight)},0)}return u.useEffect(()=>{g()},[e,h,t]),r.jsxs("div",{...P("chat/msgs/root"),ref:x,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(ui,{}),r.jsx(ci,{}),r.jsx(pi,{}),r.jsx(jr,{groups:i,pendingReply:n}),h&&f&&r.jsx(f,{agent:s}),t&&!h&&f&&r.jsx(f,{agent:(j=e.findLast(b=>b.type==="AGENT"))==null?void 0:j.agent}),r.jsx(ai,{}),r.jsx(si,{})]})}function oh(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{widgetCtx:t}=C.useWidget(),n=t.streaming,{sessionState:{session:o}}=C.useSessions(),{isCanvasOpen:s}=Pu(),{theme:i}=ue();Rt({width:s?i.screens.chat.withCanvas.width:i.screens.chat.width,height:s?i.screens.chat.withCanvas.height:i.screens.chat.height});const a=u.useRef((o==null?void 0:o.id)||"chat").current;return r.jsx("div",{...P("chat/root"),className:A("flex flex-col overflow-hidden"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:r.jsxs("div",{className:"relative size-full justify-between flex flex-col",children:[r.jsx(ei,{}),r.jsx(W.AnimatePresence,{mode:"wait",children:e?r.jsx(ee,{className:"flex flex-col items-center justify-center w-full flex-1",children:r.jsx(ti,{})},"loading"):r.jsxs(ee,{className:"flex items-start h-full flex-1 overflow-auto",snapExit:!0,children:[r.jsxs("div",{...P("chat/main/root"),className:A("flex flex-col h-full overflow-auto transition-all",s?"w-2/5":"w-full"),style:{transitionTimingFunction:i.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:i.screens.chat.withCanvas.transitionDuration},children:[n?r.jsx(wp,{}):r.jsx(rh,{}),r.jsx(nh,{})]}),r.jsx("div",{...P("chat/canvas/root"),className:A("h-full overflow-auto transition-all",s?"w-3/5":"w-0"),style:{transitionTimingFunction:i.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:i.screens.chat.withCanvas.transitionDuration},children:r.jsx(vp,{})})]},a)})]})})}const Bt=rt.forwardRef(({className:e,type:t,...n},o)=>{const{isSmallScreen:s}=ye();return r.jsx("input",{ref:o,type:t,className:A(s?"text-[16px]":"text-sm","flex w-full rounded-xl p-2 ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-primary-foreground placeholder:text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 transition","rounded-2xl px-4","border shadow-sm",e),...n})});Bt.displayName="Input";function sh({className:e}){return r.jsx("svg",{width:"26",height:"32",viewBox:"0 0 26 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:A("text-primary-foreground",e),children:r.jsx("path",{d:"M1.34103 25.6132H5.44245C5.74203 25.6228 6.02673 25.7462 6.23867 25.9582C6.45062 26.1703 6.5739 26.4551 6.58348 26.7548V30.8584C6.59305 31.1581 6.71634 31.443 6.92828 31.655C7.14023 31.8671 7.42492 31.9904 7.7245 32H18.2894C18.589 31.9904 18.8737 31.8671 19.0856 31.655C19.2976 31.443 19.4209 31.1581 19.4304 30.8584V26.7548C19.4401 26.4545 19.5638 26.1692 19.7765 25.957C19.9892 25.7449 20.2748 25.6219 20.5749 25.6132H24.659C24.9586 25.6036 25.2433 25.4803 25.4552 25.2682C25.6671 25.0562 25.7904 24.7713 25.8 24.4716V7.52839C25.7904 7.22865 25.6671 6.94381 25.4552 6.73176C25.2433 6.5197 24.9586 6.39635 24.659 6.38677H20.561C20.2603 6.37802 19.9742 6.25457 19.7614 6.04169C19.5487 5.82881 19.4253 5.54261 19.4165 5.24168V1.14161C19.4072 0.84419 19.2858 0.561291 19.0768 0.349589C18.8678 0.137887 18.5865 0.0130193 18.2894 0L7.7245 0C7.42492 0.00957792 7.14023 0.132929 6.92828 0.344983C6.71634 0.557036 6.59305 0.841878 6.58348 1.14161V5.24168C6.57477 5.54203 6.45187 5.82773 6.23983 6.04052C6.0278 6.25331 5.74262 6.37715 5.44245 6.38677H1.34103C1.04144 6.39635 0.756749 6.5197 0.544805 6.73176C0.332861 6.94381 0.209574 7.22865 0.200001 7.52839V24.4716C0.209574 24.7713 0.332861 25.0562 0.544805 25.2682C0.756749 25.4803 1.04144 25.6036 1.34103 25.6132ZM6.58348 24.4716V7.52839C6.59305 7.22865 6.71634 6.94381 6.92828 6.73176C7.14023 6.5197 7.42492 6.39635 7.7245 6.38677H18.2894C18.589 6.39635 18.8737 6.5197 19.0856 6.73176C19.2976 6.94381 19.4209 7.22865 19.4304 7.52839V24.4716C19.4209 24.7713 19.2976 25.0562 19.0856 25.2682C18.8737 25.4803 18.589 25.6036 18.2894 25.6132H7.7245C7.42492 25.6036 7.14023 25.4803 6.92828 25.2682C6.71634 25.0562 6.59305 24.7713 6.58348 24.4716Z",fill:"currentColor"})})}function sn({className:e}){const{token:t}=C.useConfig();return r.jsx("div",{className:A("flex items-center justify-center gap-2 p-2 pt-0",e),children:r.jsx(Oe,{children:r.jsxs("a",{dir:"ltr",href:`https://open.cx/?ref=${t}`,target:"_blank",rel:"noreferrer",className:A("text-[10px] flex items-center","text-muted-foreground/70 [&_svg]:text-muted-foreground/70","hover:text-primary [&_svg]:hover:text-primary"),children:[r.jsx("span",{children:"Powered by"}),r.jsx("span",{children:" "}),r.jsxs("span",{className:"flex items-center gap-[1px]",children:[r.jsx("span",{children:r.jsx(sh,{className:"size-3 inline-block"})}),r.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function pt({className:e,...t}){return r.jsx("div",{className:A("animate-pulse rounded-md bg-secondary",e),...t})}const ah=3;function Oi(e,t){for(const n of e){if(n.id===t)return n;const o=Oi(n.topics,t);if(o)return o}}function ih({articleId:e,siblings:t,popular:n}){const o=new Set([e]),s=[];for(const{id:i,title:a,slug:c}of[...t,...n])if(!o.has(i)&&(o.add(i),s.push({id:i,title:a,slug:c}),s.length===ah))break;return s}const go="w-full justify-between gap-3 rounded-[19px] px-3 py-2.5 text-start whitespace-normal";function bt({title:e,children:t,component:n}){return r.jsxs("section",{...P(n),className:"rounded-3xl border bg-background p-1",children:[e&&r.jsx("p",{className:"px-3 pt-2.5 pb-1 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:e}),r.jsx("div",{className:"flex flex-col",children:t})]})}function $i({topic:e,onOpen:t}){return r.jsxs(V,{...P("home/topic_row"),variant:"ghost",wobble:!1,size:"free",className:go,onClick:()=>t(e.id),children:[r.jsx(T.FolderIcon,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium leading-snug [overflow-wrap:anywhere]",children:e.name}),r.jsx("span",{className:"shrink-0 text-xs text-muted-foreground tabular-nums",children:e.article_count}),r.jsx(T.ChevronRightIcon,{className:"size-4 shrink-0 text-muted-foreground rtl:-scale-100"})]})}function Li({article:e,onOpen:t}){return r.jsxs(V,{...P("home/article_link"),variant:"ghost",wobble:!1,size:"free",className:go,onClick:()=>t(e.slug),children:[r.jsx("span",{className:"min-w-0 flex-1 text-sm leading-snug [overflow-wrap:anywhere]",children:e.title}),r.jsx(T.ChevronRightIcon,{className:"size-4 shrink-0 text-muted-foreground rtl:-scale-100"})]})}function Di({component:e,onBack:t,children:n}){const{setIsOpen:o}=C.useWidgetTrigger(),{isSmallScreen:s}=ye(),{t:i}=Y();return r.jsxs("header",{...P(e),className:"shrink-0 flex items-center gap-2 px-4 py-2 border-b",children:[r.jsx(V,{variant:"ghost",size:"fit",className:"shrink-0 rounded-full","aria-label":i("article_back"),onClick:t,children:r.jsx(T.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})}),n,s&&r.jsx(V,{variant:"ghost",size:"fit",className:"shrink-0 rounded-full",onClick:()=>o(!1),children:r.jsx(T.XIcon,{className:"size-4"})})]})}function Tn(){return r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[r.jsx(pt,{className:"h-4 w-2/3"}),r.jsx(pt,{className:"h-3 w-full"})]})}function Fi({onClick:e}){const{t}=Y();return r.jsx(V,{...P("home/show_more"),variant:"ghost",wobble:!1,size:"free",className:"w-full justify-center rounded-[19px] px-3 py-2.5 text-sm font-medium text-primary",onClick:e,children:t("home_show_more")})}const ys=99,ch=e=>e?16:9,Hi=(e,t)=>e/2*(1-Math.SQRT1_2)-ch(t)/2;function Wi({count:e,showCount:t,component:n="trigger/unread",style:o}){return e<=0?null:r.jsx(W.motion.span,{...P(n),"data-unread-look":t?"count":"dot","aria-hidden":!0,initial:{scale:0},animate:{scale:1},transition:be,style:o,children:t?e>ys?`${ys}+`:e:null})}function lh(){return r.jsx("style",{children:`
|
|
130
|
-
[data-component='trigger/unread'] {
|
|
131
|
-
position: absolute;
|
|
132
|
-
z-index: 1;
|
|
133
|
-
pointer-events: none;
|
|
134
|
-
border-radius: 999px;
|
|
135
|
-
background: hsl(var(--opencx-destructive));
|
|
136
|
-
color: hsl(var(--opencx-destructive-foreground));
|
|
137
|
-
box-shadow: 0 0 0 2px hsl(var(--opencx-background));
|
|
138
|
-
font: 600 10px/16px ui-sans-serif, system-ui, sans-serif;
|
|
139
|
-
font-variant-numeric: tabular-nums;
|
|
140
|
-
text-align: center;
|
|
141
|
-
}
|
|
142
|
-
[data-unread-look='dot'] { width: 9px; height: 9px; }
|
|
143
|
-
[data-unread-look='count'] { min-width: 16px; height: 16px; padding: 0 4px; }
|
|
144
|
-
`})}function $n(){return C.useConfig().unreadIndicator??"dot"}function xo({count:e,indicator:t,component:n,style:o}){const s=$n();return s===!1?null:r.jsx(Wi,{count:e,showCount:(t??s)==="count",component:n,style:o})}function Ln(e){const t=$n(),{t:n}=Y();return t===!1||e<=0?null:n("unread_sessions",{count:e})}const dh={duration:.3,ease:ot};function Dn({onArticles:e}={}){const{widgetCtx:t}=C.useWidget(),{routerState:{screen:n},toHomeScreen:o,toSessionsScreen:s}=C.useWidgetRouter(),{count:i}=C.useUnread(),a=Ln(i),{t:c}=Y();if(!t.home)return null;const d=[{key:"home",label:c("home_tab_articles"),Icon:T.BookOpenIcon,onClick:o,onReselect:e,unread:0},{key:"sessions",label:c("home_tab_chat"),Icon:T.MessageCircleIcon,onClick:s,onReselect:void 0,unread:i}];return r.jsx("nav",{...P("home/tabs"),className:"px-3 py-2",children:r.jsx("div",{role:"tablist",className:"grid grid-cols-2 gap-0.5 rounded-full border bg-secondary p-0.5",children:d.map(({key:l,label:m,Icon:p,onClick:h,onReselect:f,unread:x})=>{const g=n===l;return u.createElement(V,{...P("home/tab"),key:l,role:"tab","aria-selected":g,variant:"ghost",size:"free",className:A("relative h-9 min-w-0 rounded-full px-3 text-sm font-medium",g?"text-foreground hover:bg-transparent":"z-10 text-muted-foreground"),onClick:g?f:h},g&&r.jsx(W.motion.span,{layoutId:"home-tab-pill",className:"absolute inset-0 rounded-full border border-border bg-background shadow-sm",transition:dh},"pill"),r.jsxs("span",{className:"relative z-10 flex min-w-0 items-center justify-center gap-1.5",children:[r.jsxs("span",{className:"relative shrink-0",children:[r.jsx(p,{className:"size-4"}),r.jsx(xo,{count:x,indicator:"dot",component:"home/tab_unread"})]}),r.jsx("span",{className:"truncate",children:m}),x>0&&a&&r.jsx("span",{className:"sr-only",children:a})]},"label"))})})})}function Ui({key:e,fetchPage:t}){const[n,o]=u.useState(null),s=u.useRef(t);u.useEffect(()=>{s.current=t});const i=u.useCallback((p,h)=>{o(f=>({key:p,items:(f==null?void 0:f.key)===p&&h>0?f.items:[],nextOffset:(f==null?void 0:f.key)===p?f.nextOffset:null,fetching:!0,error:void 0})),s.current(h).then(f=>o(x=>(x==null?void 0:x.key)===p?{key:p,items:h===0?f.items:[...x.items,...f.items],nextOffset:f.nextOffset,fetching:!1,error:void 0}:x),f=>o(x=>(x==null?void 0:x.key)===p?{...x,fetching:!1,error:f}:x))},[]);u.useEffect(()=>{e!==null&&i(e,0)},[e,i]);const a=e!==null&&(n==null?void 0:n.key)===e?n:null,c=e!==null&&(!a||a.fetching),d=(a==null?void 0:a.nextOffset)??null,l=u.useCallback(()=>{e!==null&&d!==null&&!c&&i(e,d)},[e,d,c,i]),m=u.useCallback(()=>{e!==null&&i(e,0)},[e,i]);return{items:(a==null?void 0:a.items)??[],loading:c,error:a==null?void 0:a.error,hasMore:d!==null,loadMore:l,reload:m}}function Bi({helpCenterId:e,topicId:t}){const{widgetCtx:n}=C.useWidget(),o=Ui({key:t===null?null:`${e}:${t}`,fetchPage:s=>t===null?Promise.resolve({items:[],nextOffset:null}):n.api.listTopicArticles({helpCenterId:e,topicId:t,offset:s}).then(i=>({items:i.articles,nextOffset:i.next_offset}))});return u.useEffect(()=>{o.error&&G.log.error("home: could not load the topic articles",{_e:o.error,helpCenterId:e,topicId:t})},[o.error,e,t]),o}const uh=["[--tw-prose-body:hsl(var(--opencx-foreground))]","[--tw-prose-headings:hsl(var(--opencx-foreground))]","[--tw-prose-bold:hsl(var(--opencx-foreground))]","[--tw-prose-links:hsl(var(--opencx-primary))]","[--tw-prose-code:hsl(var(--opencx-foreground))]","[--tw-prose-counters:hsl(var(--opencx-muted-foreground))]","[--tw-prose-bullets:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quotes:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quote-borders:hsl(var(--opencx-border))]","[--tw-prose-hr:hsl(var(--opencx-border))]","[--tw-prose-th-borders:hsl(var(--opencx-border))]","[--tw-prose-td-borders:hsl(var(--opencx-border))]","[--tw-prose-pre-bg:hsl(var(--opencx-muted))]","[--tw-prose-pre-code:hsl(var(--opencx-foreground))]"].join(" ");function ph({helpCenterId:e,slug:t,popular:n,onBack:o,onHome:s,onOpenArticle:i,onOpenTopicPath:a,onRedirect:c}){var S,w,_;const{widgetCtx:d}=C.useWidget(),{t:l}=Y(),{theme:m}=ue();Rt({width:m.screens.chat.width,height:m.screens.chat.height});const p=zn.useAsync(()=>d.api.getHelpCenterArticle({helpCenterId:e,slug:t}),[d,e,t]),h=(S=p.value)==null?void 0:S.article,f=u.useMemo(()=>({kind:"article",article:h?{slug:t,id:h.id,title:h.title}:{slug:t}}),[t,h]);Kr(f);const x=h?null:(w=p.value)==null?void 0:w.redirect_slug;u.useEffect(()=>{x&&c(x)},[x,c]),u.useEffect(()=>{p.error?G.log.error("home: could not load the article",{_e:p.error,helpCenterId:e,slug:t}):p.value&&!p.value.article&&!p.value.redirect_slug&&G.log.warn("home: article not found",{helpCenterId:e,slug:t})},[p.error,p.value,e,t]);const g=(h==null?void 0:h.topic_path)??[],j=Bi({helpCenterId:e,topicId:((_=g.at(-1))==null?void 0:_.id)??null}),b=h?ih({articleId:h.id,siblings:j.items,popular:n}):[];return r.jsxs("div",{...P("article/root"),className:"flex flex-col bg-background",style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[r.jsx(Di,{component:"article/header",onBack:o,children:r.jsx("nav",{...P("article/trail"),className:"min-w-0 flex-1 flex items-center gap-0.5 text-sm",children:g.map((y,v)=>r.jsxs(u.Fragment,{children:[v>0&&r.jsx(T.ChevronRightIcon,{className:"size-3 shrink-0 text-muted-foreground rtl:-scale-100"}),r.jsx(V,{variant:"ghost",size:"free",wobble:!1,className:A("min-w-0 rounded-full px-1.5 py-1",v===g.length-1?"font-semibold":"shrink-[2] text-muted-foreground"),onClick:()=>a(g.slice(0,v+1).map(N=>N.id)),children:r.jsx("span",{className:"truncate",children:y.name})})]},y.id))})}),r.jsx("article",{...P("article/content"),className:"flex-1 overflow-y-auto px-5 py-4",children:p.loading||x?r.jsxs("div",{className:"space-y-3",children:[r.jsx(pt,{className:"h-6 w-3/4"}),r.jsx(pt,{className:"h-3 w-1/4"}),r.jsx(pt,{className:"h-4 w-full"}),r.jsx(pt,{className:"h-4 w-5/6"})]}):h?r.jsxs(r.Fragment,{children:[r.jsx("h1",{className:"text-xl font-semibold tracking-tight leading-snug",children:h.title}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l("article_reading_minutes",{count:h.reading_minutes})}),h.content_html&&r.jsx("div",{className:A("mt-4 prose prose-sm max-w-none break-words [word-break:break-word]","prose-table:block prose-table:overflow-x-auto prose-table:[word-break:normal] prose-table:[overflow-wrap:normal]","prose-a:underline prose-img:rounded-xl",uh),children:r.jsx(iu,{openArticle:i,children:h.content_html})}),b.length>0&&r.jsx("div",{...P("article/suggested"),className:"mt-6 -mx-2",children:r.jsx(bt,{component:"home/articles",title:l("home_suggested_articles"),children:b.map(y=>r.jsx(Li,{article:y,onOpen:i},y.id))})})]}):r.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:l("home_load_failed")})}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Dn,{onArticles:s}),r.jsx(sn,{})]})]})}function mh({helpCenterId:e,topic:t,onBack:n,onHome:o,onOpenTopic:s,onOpenArticle:i}){const{theme:a}=ue(),{t:c}=Y();Rt({width:a.screens.sessions.width,height:a.screens.sessions.height});const d=u.useMemo(()=>({kind:"topic",topic:{id:t.id,name:t.name}}),[t.id,t.name]);Kr(d);const l=t.topics.filter(p=>p.article_count>0),m=Bi({helpCenterId:e,topicId:t.id});return r.jsxs("div",{...P("topic/root"),className:"flex flex-col overflow-hidden bg-background",style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[r.jsx(Di,{component:"topic/header",onBack:n,children:r.jsx("h1",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:t.name})}),r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col gap-3 p-3",children:[t.description&&r.jsx("p",{className:"px-2 text-sm text-muted-foreground [overflow-wrap:anywhere]",children:t.description}),l.length>0&&r.jsx(bt,{component:"home/topics",title:c("home_topics"),children:l.map(p=>r.jsx($i,{topic:p,onOpen:s},p.id))}),m.error&&m.items.length===0?r.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:c("home_load_failed")}):(m.loading||m.items.length>0)&&r.jsxs(bt,{component:"home/articles",title:c("home_tab_articles"),children:[m.items.map(p=>r.jsx(Li,{article:p,onOpen:i},p.id)),m.loading?r.jsx(Tn,{}):m.hasMore?r.jsx(Fi,{onClick:m.loadMore}):null]})]}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Dn,{onArticles:o}),r.jsx(sn,{})]})]})}const bo=u.createContext({data:void 0,loading:!1,failed:!1,request:()=>{}});function hh({children:e}){var c;const{widgetCtx:t}=C.useWidget(),n=(c=t.home)==null?void 0:c.helpCenterId,[o,s]=u.useState(!1),i=u.useCallback(()=>s(!0),[]),a=zn.useAsync(async()=>o&&n?t.api.listHomeArticles({helpCenterId:n}):void 0,[t,n,o]);return u.useEffect(()=>{a.error&&G.log.error("home: could not load the help center",{_e:a.error,helpCenterId:n})},[a.error,n]),r.jsx(bo.Provider,{value:{data:a.value,loading:a.loading||!o&&!!n,failed:!!a.error,request:i},children:e})}function fh(){const e=u.useContext(bo),{request:t}=e;return u.useEffect(t,[t]),e}const gh=400,xh=6;function bh(e){const[t,n]=u.useState(""),[o,s]=u.useState(""),[i,a]=u.useState(0),c=p=>p.length>=xh||e.includes(p),d=p=>{const h=p.trim();s(c(h)?h:"")};return zn.useDebounce(()=>d(t),gh,[t]),{query:t,setQuery:n,search:o,searchNow:p=>{n(p),d(p),a(h=>h+1)},retry:i,reset:()=>{n(""),s("")}}}const qi=u.createContext(null);function wh({children:e}){var l;const{widgetCtx:t}=C.useWidget(),n=((l=t.home)==null?void 0:l.helpCenterId)??null,{data:o}=u.useContext(bo),[s,i]=u.useState([]),a=bh((o==null?void 0:o.popularSearches)??[]),[c,d]=u.useState(n);return c!==n&&(d(n),i([]),a.reset()),r.jsx(qi.Provider,{value:{stack:s,setStack:i,homeSearch:a},children:e})}function vh(){const e=u.useContext(qi);if(!e)throw new Error("useHomeState must be used inside HomeStateProvider");return e}const yh=24,kh={initial:{opacity:1,x:0}},Vi=u.createContext({direction:null,settle:()=>{}}),Ir={home:0,sessions:1};function ks(e){return e in Ir}function jh({from:e,to:t,rtl:n}){return!ks(e)||!ks(t)||e===t?null:Ir[t]>Ir[e]!==n?"left":"right"}function Yi({children:e,...t}){const{direction:n,settle:o}=u.useContext(Vi);return u.useEffect(()=>{n&&o()},[n,o]),r.jsx(ee,{...t,fadeIn:n??"right",distance:yh,overrides:n?{}:kh,children:e})}const Ch=200,Sh=3,Nh=3500,_h={kind:"main"},Eh={duration:.55,ease:ot};function Th(){var j,b,S;const{widgetCtx:e}=C.useWidget(),t=(j=e.home)==null?void 0:j.helpCenterId,{stack:n,setStack:o,homeSearch:s}=vh(),i=fh(),a=u.useCallback(w=>o(_=>[..._.slice(0,-1),{kind:"article",slug:w}]),[o]);if(!t)return null;const c=w=>o(_=>[..._,w]),d=()=>o(w=>w.slice(0,-1)),l=()=>o([]),m=w=>c({kind:"article",slug:w}),p=w=>c({kind:"topic",topicId:w}),h=w=>o(w.map(_=>({kind:"topic",topicId:_}))),f=n[n.length-1],x=((b=i.data)==null?void 0:b.topics)??[],g=(f==null?void 0:f.kind)==="topic"?Oi(x,f.topicId):null;return r.jsx(W.AnimatePresence,{mode:"wait",initial:!1,children:(f==null?void 0:f.kind)==="article"?r.jsx(ee,{fadeIn:"left",snapExit:!0,className:"size-full",children:r.jsx(ph,{helpCenterId:t,slug:f.slug,popular:((S=i.data)==null?void 0:S.articles)??[],onBack:d,onHome:l,onOpenArticle:m,onRedirect:a,onOpenTopicPath:h})},`${n.length}:${f.slug}`):g?r.jsx(ee,{fadeIn:"left",snapExit:!0,className:"size-full",children:r.jsx(mh,{helpCenterId:t,topic:g,onBack:d,onHome:l,onOpenTopic:p,onOpenArticle:m})},`${n.length}:${g.id}`):r.jsx(ee,{fadeIn:"right",snapExit:!0,className:"size-full",children:r.jsx(Ah,{helpCenterId:t,data:i.data,loading:i.loading,failed:i.failed,homeSearch:s,onOpenArticle:m,onOpenTopic:p})},"home")})}function Ah({helpCenterId:e,data:t,loading:n,failed:o,homeSearch:{query:s,setQuery:i,search:a,searchNow:c,retry:d},onOpenArticle:l,onOpenTopic:m}){const{theme:p}=ue(),{t:h}=Y();Kr(_h);const f=(t==null?void 0:t.popularSearches)??[],x=((t==null?void 0:t.topics)??[]).filter(g=>g.article_count>0);return Rt({width:p.screens.sessions.width,height:p.screens.sessions.height}),r.jsxs("div",{...P("home/root"),className:"flex flex-col overflow-hidden bg-background",style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:[r.jsxs(Yi,{className:"flex-1 min-h-0 flex flex-col",children:[r.jsx(Ih,{}),r.jsx("div",{className:"shrink-0 px-3 -mt-6 relative z-10",children:r.jsx(zh,{value:s,hints:f,onChange:i,onSubmit:()=>c(s)})}),r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col gap-3 p-3",children:a?r.jsx(Oh,{helpCenterId:e,search:a,retry:d,onOpenArticle:l}):r.jsxs(r.Fragment,{children:[r.jsx(Rh,{searches:f,onPick:c}),r.jsx(Ph,{articles:t==null?void 0:t.articles,loading:n,failed:o,onOpenArticle:l}),x.length>0&&r.jsx(bt,{component:"home/topics",title:h("home_topics"),children:x.map(g=>r.jsx($i,{topic:g,onOpen:m},g.id))})]})})]}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Dn,{}),r.jsx(sn,{})]})]})}function Ih(){var a,c;const{widgetCtx:{org:e}}=C.useWidget(),{assets:t,textContent:n}=C.useConfig(),{setIsOpen:o}=C.useWidgetTrigger(),{isSmallScreen:s}=ye(),{t:i}=Y();return r.jsxs("header",{...P("home/header"),className:A("shrink-0 px-5 pt-6 pb-14 space-y-4 text-primary-foreground","bg-[radial-gradient(ellipse_at_top_left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse_at_top_right,hsl(var(--opencx-primary)),transparent)]"),children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 min-h-8",children:[t!=null&&t.organizationLogo?r.jsx("img",{src:t.organizationLogo,alt:e.name,className:"h-8 w-auto object-contain"}):r.jsx("h2",{className:"font-bold text-sm",children:e.name}),s&&r.jsx(V,{size:"selfless",onClick:()=>o(!1),children:r.jsx(T.XIcon,{className:"size-4"})})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight leading-tight",children:((a=n==null?void 0:n.homeScreen)==null?void 0:a.title)||i("home_title")}),r.jsx("p",{className:"text-sm opacity-90",children:((c=n==null?void 0:n.homeScreen)==null?void 0:c.description)||i("home_description")})]})]})}function zh({value:e,hints:t,onChange:n,onSubmit:o}){const{t:s}=Y();return r.jsxs("form",{...P("home/search"),role:"search",className:"relative block",onSubmit:i=>{i.preventDefault(),o()},children:[r.jsx(T.SearchIcon,{className:"pointer-events-none absolute start-4 top-1/2 -translate-y-1/2 size-4 text-muted-foreground"}),r.jsx(Bt,{type:"text",enterKeyHint:"search",maxLength:Ch,value:e,onChange:i=>n(i.target.value),placeholder:t.length>0?void 0:s("home_search_placeholder"),"aria-label":s("home_search_placeholder"),className:"h-12 ps-10 rounded-3xl bg-background"}),t.length>0&&!e&&r.jsx(Mh,{hints:t})]})}function Mh({hints:e}){const t=W.useReducedMotion(),[n,o]=u.useState(0);u.useEffect(()=>{if(e.length<2||t)return;const i=setInterval(()=>o(a=>(a+1)%e.length),Nh);return()=>clearInterval(i)},[e.length,t]);const s=e[n%e.length];return r.jsx("span",{"aria-hidden":!0,className:"pointer-events-none absolute top-1/2 start-10 end-4 h-6 -translate-y-1/2 overflow-hidden text-muted-foreground/75",children:r.jsx(W.AnimatePresence,{initial:!1,children:r.jsx(W.motion.span,{className:"absolute inset-0 truncate leading-6",initial:{y:"70%",opacity:0,filter:"blur(2px)"},animate:{y:0,opacity:1,filter:"blur(0px)"},exit:{y:"-70%",opacity:0,filter:"blur(2px)"},transition:Eh,children:s},s)})})}function Rh({searches:e,onPick:t}){return e.length===0?null:r.jsx("div",{...P("home/popular_searches"),className:"flex flex-wrap gap-1.5",children:e.map(n=>r.jsx(V,{variant:"outline",size:"free",title:n,className:"max-w-full rounded-full bg-background px-3 py-1 text-xs font-normal",onClick:()=>t(n),children:r.jsx("span",{className:"min-w-0 truncate",children:n})},n))})}function Ph({articles:e,loading:t,failed:n,onOpenArticle:o}){const{t:s}=Y();return n?r.jsx(zr,{children:s("home_load_failed")}):!t&&(e==null?void 0:e.length)===0?null:r.jsx(bt,{component:"home/articles",title:s("home_suggested_articles"),children:t||!e?Array.from({length:Sh},(i,a)=>r.jsx(Tn,{},a)):e.map(i=>r.jsx(Xi,{article:i,onOpen:o},i.id))})}function Oh({helpCenterId:e,search:t,retry:n,onOpenArticle:o}){const{widgetCtx:s}=C.useWidget(),{t:i}=Y(),a=Ui({key:`${e}:${t}`,fetchPage:p=>s.api.searchHelpCenter({helpCenterId:e,query:t,offset:p}).then(h=>({items:h.results,nextOffset:h.next_offset}))}),c=a.error instanceof G.HelpCenterSearchError&&a.error.busy;u.useEffect(()=>{a.error&&!c&&G.log.error("home: help center search failed",{_e:a.error,helpCenterId:e})},[a.error,c,e]);const d=u.useRef(n),{error:l,reload:m}=a;return u.useEffect(()=>{n!==d.current&&(d.current=n,l&&m())},[n,l,m]),a.items.length===0?a.error?r.jsx(zr,{onRetry:a.reload,children:i(c?"home_search_busy":"home_load_failed")}):a.loading?r.jsx(bt,{component:"home/articles",children:r.jsx(Tn,{})}):r.jsx(zr,{children:i("home_search_no_results")}):r.jsxs(bt,{component:"home/articles",children:[a.items.map(p=>r.jsx(Xi,{article:p,topicName:p.topic.name,onOpen:o},p.id)),a.loading?r.jsx(Tn,{}):a.hasMore?r.jsx(Fi,{onClick:a.loadMore}):null]})}function Xi({article:e,topicName:t,onOpen:n}){return r.jsxs(V,{...P("home/article_card"),variant:"ghost",wobble:!1,size:"free",className:go,onClick:()=>n(e.slug),children:[r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium leading-snug [overflow-wrap:anywhere]",children:e.title}),t&&r.jsxs("span",{className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground",children:[r.jsx(T.FolderIcon,{className:"size-3 shrink-0"}),r.jsx("span",{className:"truncate",children:t})]}),e.excerpt&&r.jsx("span",{className:A("mt-0.5 text-xs text-muted-foreground [overflow-wrap:anywhere]",t?"line-clamp-2":"line-clamp-1"),children:e.excerpt})]}),r.jsx(T.ChevronRightIcon,{className:"size-4 shrink-0 text-muted-foreground rtl:-scale-100"})]})}function zr({children:e,onRetry:t}){const{t:n}=Y();return r.jsxs("div",{className:"rounded-3xl border bg-background px-4 py-6 text-center text-sm text-muted-foreground",children:[r.jsx("p",{children:e}),t&&r.jsx(V,{variant:"outline",size:"free",className:"mt-3 rounded-full bg-background px-3 py-1 text-xs",onClick:t,children:n("turn_failed_retry")})]})}function $h({children:e}){var S,w,_;const{widgetCtx:t,config:n}=C.useWidget(),[o,s]=u.useState(!1),[i,a]=u.useState(null),[c,d]=u.useState(""),[l,m]=u.useState([]),[p,h]=u.useState([]),[f,x]=u.useState(!1),[g,j]=u.useState("");u.useEffect(()=>{var v;let y=!1;if(((v=n.capabilities)==null?void 0:v.connections)===!0)return Promise.all([t.api.listConnections(),t.api.listApprovalPreferences()]).then(([N,R])=>{y||(m(N.filter(M=>M.status!=="not_connected")),h(R))}).catch(()=>{}),()=>{y=!0}},[t,(S=n.capabilities)==null?void 0:S.connections]);const b=async y=>{x(!0),j("");try{await y()}catch{j("Could not save the change. Try again.")}finally{x(!1)}};return!o||((w=n.capabilities)==null?void 0:w.connections)!==!0?r.jsxs(r.Fragment,{children:[r.jsx(ei,{}),((_=n.capabilities)==null?void 0:_.connections)===!0&&l.length>0&&r.jsxs(V,{variant:"ghost",className:"mx-3 my-1 h-9 justify-start gap-2 text-sm",onClick:()=>s(!0),children:[r.jsx(T.Unplug,{className:"size-4"})," Connections"," ",r.jsx(T.ChevronRight,{className:"ml-auto size-4"})]}),e]}):r.jsxs("section",{className:"flex-1 overflow-y-auto px-4 pb-4 pt-3 space-y-5","aria-label":"Connections",children:[r.jsxs("div",{className:"flex h-8 items-center gap-2 pr-16",children:[r.jsx(V,{variant:"ghost",size:"icon",className:"size-7","aria-label":i?"Back to connections":"Back to sessions",onClick:()=>i?a(null):s(!1),children:r.jsx(T.ArrowLeft,{className:"size-4"})}),r.jsx("h2",{className:"text-sm font-medium",children:"Connections"})]}),!l.length&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"No connected services."}),!i&&r.jsxs(r.Fragment,{children:[r.jsx("input",{type:"search","aria-label":"Search connections",placeholder:"Search connections",value:c,onChange:y=>d(y.target.value),className:"h-8 w-full rounded-full border border-foreground/15 bg-transparent px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"border-b border-foreground/10 pb-2 text-xs font-medium",children:"Connected services"}),l.filter(y=>y.name.toLowerCase().includes(c.toLowerCase())).map(y=>r.jsxs("button",{type:"button",onClick:()=>a(y.server_id),className:"flex w-full items-center gap-3 rounded-xl px-2 py-3 text-left hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[r.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-xl border border-foreground/10 bg-background p-2",children:r.jsx(Nn,{})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium",children:y.name}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:y.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(T.ChevronRight,{className:"size-4 text-muted-foreground"})]},y.server_id)),l.length>0&&!l.some(y=>y.name.toLowerCase().includes(c.toLowerCase()))&&r.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No matching connections."})]})]}),l.filter(y=>y.server_id===i).map(y=>r.jsxs("div",{className:"border-b border-foreground/10 pb-5 space-y-3 last:border-0",children:[r.jsx("div",{className:"flex size-12 items-center justify-center rounded-xl border border-foreground/10 bg-background p-3",children:r.jsx(Nn,{})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium",children:y.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:y.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(V,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:f,onClick:()=>void b(async()=>{await t.api.disconnectConnection(y.server_id),a(null),m(v=>v.filter(N=>N.server_id!==y.server_id)),h(v=>v.filter(N=>N.serverId!==y.server_id))}),children:"Disconnect"})]}),p.some(v=>v.serverId===y.server_id)?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("h3",{className:"text-xs font-medium",children:["Saved approvals (",p.filter(v=>v.serverId===y.server_id).length,")"]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Removing an approval makes the widget ask again next time."}),r.jsx("ul",{className:"max-h-64 overflow-y-auto divide-y divide-foreground/10 rounded-xl border border-foreground/10","aria-label":`${y.name} saved approvals`,children:p.filter(v=>v.serverId===y.server_id).map(v=>r.jsxs("li",{className:"flex items-start gap-3 p-3",children:[r.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[r.jsx("p",{className:"text-xs font-medium break-words",children:v.toolName.replace(/[_-]+/g," ")}),r.jsx("p",{className:"text-xs text-muted-foreground break-words",children:v.message})]}),r.jsx(V,{variant:"secondary",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:f,onClick:()=>void b(async()=>{await t.api.revokeApprovalPreference(v.serverId,v.key),h(N=>N.filter(R=>R.serverId!==v.serverId||R.key!==v.key))}),children:"Remove approval"})]},v.key))})]}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"No saved approvals"})]},y.server_id)),g&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:g})]})}function Lh({children:e}){return r.jsx("p",{className:"ps-4 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:e})}function js({session:e,className:t}){const{humanAgent:n}=C.useConfig(),o=C.useBot(),{toChatScreen:s}=C.useWidgetRouter(),{isUnread:i}=C.useUnread(),a=Ln(i(e.id)?1:0),c=e.assignee.kind==="human"?(n==null?void 0:n.name)||e.assignee.name||"Support Agent":o.name,d=e.assignee.kind==="human"?(n==null?void 0:n.avatarUrl)||e.assignee.avatarUrl||"":o.avatarUrl||o.avatar||"";return r.jsxs(V,{variant:"ghost",size:"lg",className:A("rounded-full p-2 pe-4 flex text-start justify-between w-full whitespace-normal",t),onClick:()=>s(e.id),children:[r.jsxs("div",{className:"flex-1 flex gap-2 items-center min-w-0",children:[r.jsx(W.AnimatePresence,{mode:"wait",children:r.jsx(ee,{snapExit:!0,children:r.jsxs(Zr,{className:"size-10",children:[r.jsx(Jr,{src:d,alt:"Agent Icon"}),r.jsx(Qr,{children:r.jsx(T.UserRoundIcon,{className:"size-4"})})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx(W.AnimatePresence,{mode:"wait",children:r.jsx(ee,{snapExit:!0,children:c},c)}),r.jsx(W.AnimatePresence,{mode:"wait",children:e.lastMessage?r.jsx(ee,{snapExit:!0,children:r.jsx(Wa,{remarkPlugins:[Gs],rehypePlugins:[ar],className:"line-clamp-1 overflow-hidden text-ellipsis text-xs text-muted-foreground",children:e.lastMessage})},e.lastMessage||"content"):r.jsx(ee,{className:"w-1/2",snapExit:!0,children:r.jsx(pt,{className:"h-4 w-full"})},"skeleton")}),r.jsx(W.AnimatePresence,{mode:"wait",children:e.customStatus&&r.jsx(ee,{className:"mt-1",snapExit:!0,children:r.jsx(di,{customStatus:e.customStatus})},e.customStatus.id)})]})]}),a&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sr-only",children:a}),r.jsx(xo,{count:1,indicator:"dot",component:"sessions/unread"})]}),r.jsx(T.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0 rtl:-scale-100"})]})}function Dh(){const{t:e}=Y(),{toChatScreen:t}=C.useWidgetRouter(),{sessionsState:{data:n,isInitialFetchLoading:o},openSessions:s,closedSessions:i,canCreateNewSession:a}=C.useSessions();return r.jsx("div",{...P("sessions/list"),className:"flex-1 flex flex-col overflow-scroll py-2 px-2",children:r.jsx(W.AnimatePresence,{mode:"wait",children:o?r.jsx(ee,{className:"flex-1 flex items-center justify-center",children:r.jsx(ti,{})},"loading"):r.jsx(ee,{className:"flex-1 flex flex-col gap-2 relative",children:n.length?r.jsxs(r.Fragment,{children:[r.jsxs(W.AnimatePresence,{children:[s.length>0&&r.jsx(ee,{fadeIn:"up",delay:.2,className:"space-y-2",snapExit:!0,children:s.map(c=>r.jsx(js,{session:c},c.id))},"open-sessions"),i.length>0&&r.jsxs(ee,{className:"space-y-2",delay:.2,snapExit:!0,children:[r.jsx(Lh,{children:e("closed_conversations")}),i.map(c=>r.jsx(js,{session:c,className:"opacity-50 hover:opacity-100"},c.id))]},"closed-sessions")]}),a&&r.jsx("div",{className:"mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background",children:u.createElement(V,{...P("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>t()},e("new_conversation"))})]}):r.jsxs("div",{className:"flex-1 flex flex-col gap-2 items-center",children:[r.jsx("div",{className:"flex-1 flex items-center justify-center",children:r.jsx("p",{className:"text-muted-foreground",children:e("no_conversations_yet")})}),u.createElement(V,{...P("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>t()},e("new_conversation"))]})},"sessions")})})}function Fh(){const{theme:e}=ue();return Rt({width:e.screens.sessions.width,height:e.screens.sessions.height}),r.jsx("div",{...P("sessions/root"),className:A("flex flex-col overflow-hidden bg-background"),style:{width:"100vw",maxWidth:"100vw",height:"100vh",maxHeight:"100vh"},children:r.jsxs("div",{className:"size-full flex flex-col",children:[r.jsx(Yi,{className:"flex-1 min-h-0 flex flex-col",children:r.jsx($h,{children:r.jsx(Dh,{})})}),r.jsx(Dn,{}),r.jsx(sn,{})]})})}function Hh(){const{contentIframeRef:e}=C.useWidget(),{inline:t}=C.useConfig(),n=u.useRef(null);return u.useEffect(()=>{const o=e==null?void 0:e.current;if(o&&n.current){const s=n.current;let i;const a=new ResizeObserver(()=>{i=requestAnimationFrame(()=>{const c=s.offsetHeight;o.style.setProperty("--opencx-widget-height",t?"100%":`${c.toFixed(1)}px`)})});return a.observe(s),()=>{cancelAnimationFrame(i),a.unobserve(s)}}},[e,t]),{observedElementRef:n}}const Wh=k.z.object({name:k.z.string().min(2),email:k.z.string().email()});function Uh(){var b,S,w,_,y,v,N,R;const{widgetCtx:{org:e}}=C.useWidget(),{setIsOpen:t}=C.useWidgetTrigger(),{createUnverifiedContact:n}=C.useContact(),{isSmallScreen:o}=ye(),s=C.useConfig(),{theme:i}=ue(),{t:a}=Y(),{observedElementRef:c}=Hh();Rt({height:void 0,width:i.screens.welcome.width});const[d,l]=u.useState(((b=s.prefillUserData)==null?void 0:b.name)||""),[m,p]=u.useState(((S=s.prefillUserData)==null?void 0:S.email)||""),h=(s.extraDataCollectionFields||[]).filter(M=>M!=="name"&&M!=="email"&&!!M),[f,x]=u.useState({}),[g,j]=zn.useAsyncFn(async M=>{M.preventDefault();const z=Wh.safeParse({name:d,email:m});z.success&&await n({email:z.data.email,non_verified_name:z.data.name},Object.values(f).filter(Boolean).length?f:void 0)},[d,m,f]);return r.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:i.screens.welcome.minHeight,height:"100vh",maxHeight:"100vh",overflowY:"auto"},children:r.jsxs("div",{ref:c,className:A("flex flex-col",o&&"h-full","bg-[radial-gradient(ellipse_at_top_left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse_at_top_right,hsl(var(--opencx-primary)),transparent)]"),children:[r.jsxs("div",{className:A("flex-1 flex flex-col px-4 py-12 text-start space-y-4 relative z-10","text-primary-foreground"),children:[o&&r.jsx(ee,{className:"absolute top-6 end-6",children:r.jsx(V,{size:"selfless",onClick:()=>t(!1),children:r.jsx(T.XIcon,{className:"size-4"})})}),r.jsx("div",{className:"flex items-center justify-between w-full mb-2",children:(w=s.assets)!=null&&w.organizationLogo?r.jsx("img",{src:(_=s.assets)==null?void 0:_.organizationLogo,alt:"Company Logo",className:"h-8 w-auto object-contain"}):r.jsx("h2",{className:"font-bold text-sm",children:e.name})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("h1",{className:"text-[1.75rem] font-semibold tracking-tight leading-none",children:((v=(y=s.textContent)==null?void 0:y.welcomeScreen)==null?void 0:v.title)||a("welcome_screen_title")}),r.jsx("p",{className:"text-sm",children:((R=(N=s.textContent)==null?void 0:N.welcomeScreen)==null?void 0:R.description)||a("welcome_screen_description")})]})]}),r.jsxs("div",{className:A("z-10 m-2 px-2 pt-2 bp-0 space-y-2","bg-[white]","border shadow","rounded-3xl"),children:[r.jsxs("form",{onSubmit:j,className:"space-y-2",children:[r.jsx(Bt,{value:d,onChange:M=>l(M.target.value),required:!0,placeholder:a("your_name_placeholder"),name:"name"}),r.jsx(Bt,{required:!0,value:m,onChange:M=>p(M.target.value),type:"email",placeholder:a("your_email_placeholder"),name:"email"}),h.map(M=>r.jsx(Bt,{value:f[M],onChange:z=>x(L=>({...L,[M]:z.target.value})),placeholder:`${M} (${a("optional")})`},M)),r.jsxs(V,{disabled:g.loading,className:"w-full",size:"lg",children:[g.loading?a("start_chat_button_loading"):a("start_chat_button"),r.jsx(T.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),r.jsx(sn,{})]})]})})}const Bh={initial:{opacity:1,x:0}};function qh(e){const{dir:t}=Y(),[,n]=u.useReducer(i=>i+1,0),o=u.useRef({screen:e,direction:null});o.current.screen!==e&&(o.current={screen:e,direction:jh({from:o.current.screen,to:e,rtl:t==="rtl"})});const s=u.useCallback(()=>{o.current.direction&&(o.current={...o.current,direction:null},n())},[]);return{direction:o.current.direction,settle:s}}function wo(){const{routerState:{screen:e}}=C.useWidgetRouter(),t=qh(e),n=t.direction?Bh:void 0;return r.jsx(hh,{children:r.jsx(wh,{children:r.jsx(Vi.Provider,{value:t,children:r.jsx("div",{className:"relative bg-background size-full",children:(()=>{switch(e){case"welcome":return r.jsx(ee,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(Uh,{})},e);case"home":return r.jsx(ee,{fadeIn:"right",className:"size-full",snapExit:!0,overrides:n,children:r.jsx(Th,{})},e);case"sessions":return r.jsx(ee,{fadeIn:"right",className:"size-full",snapExit:!0,overrides:n,children:r.jsx(Fh,{})},e);case"chat":return r.jsx(ee,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(oh,{})},e);default:return G.isExhaustive(e,wo.name),null}})()})})})})}const Vh=eo(),Yh=()=>{};function Gi(){const{isOpen:e}=C.useWidgetTrigger(),{contentIframeRef:t,widgetCtx:n}=C.useWidget(),{inline:o}=C.useConfig(),{theme:s,computed:i}=ue();return u.useEffect(()=>{e||n.dictationCtx.stop({executeFinalCommand:!1})},[e,n]),r.jsx(W.motion.div,{onUpdate:Yh,animate:e?"visible":"hidden",initial:"hidden",style:{transformOrigin:o?void 0:"bottom right"},variants:{hidden:{opacity:0,scale:o?1:.9,y:8,transitionEnd:{display:"none"},transition:At},visible:{opacity:1,scale:1,y:0,display:"block",height:o?"100%":void 0,transition:{...At,height:{duration:0}}}},children:r.jsx(Ks,{ref:t,initialContent:Vh,allowFullScreen:!0,title:Ga,style:{"--opencx-widget-width":i.minWidth,"--opencx-widget-height":i.minHeight,minWidth:i.minWidth,width:"var(--opencx-widget-width)",maxWidth:i.maxWidth,minHeight:i.minHeight,height:"var(--opencx-widget-height)",maxHeight:i.maxHeight,overflow:"hidden",outline:s.widgetContentContainer.outline,outlineColor:s.widgetContentContainer.outlineColor,borderRadius:s.widgetContentContainer.borderRadius,boxShadow:s.widgetContentContainer.boxShadow,transitionProperty:s.widgetContentContainer.transitionProperty,transitionTimingFunction:s.widgetContentContainer.transitionTimingFunction,transitionDuration:s.widgetContentContainer.transitionDuration,boxSizing:"border-box",borderWidth:"0px"},children:r.jsx(Pn,{style:{zIndex:s.widgetContentContainer.zIndex},children:r.jsx(wo,{})})})})}function Xh(){const{theme:e,triggerSide:t}=ue(),{dir:n}=C.useDocumentDir(),{t:o}=Y(),s=(n==="rtl"?t==="left":t==="right")?"end":"start";return r.jsx(Qe.Content,{onInteractOutside:i=>i.preventDefault(),forceMount:!0,style:{zIndex:e.widgetContentContainer.zIndex,fontSize:"16px"},side:"top",align:s,"aria-modal":"false","aria-label":o("support_chat_aria_label"),sideOffset:e.widgetContentContainer.offset.side,alignOffset:e.widgetContentContainer.offset.align,avoidCollisions:!1,children:r.jsx(Gi,{})})}function Gh({className:e,style:t}){return r.jsxs("svg",{width:"32",height:"30",viewBox:"0 0 32 30",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:A("text-primary-foreground",e),style:t,children:[r.jsx("path",{d:"M0 6.94263C0 3.62892 2.68629 0.942627 6 0.942627H26C29.3137 0.942627 32 3.62892 32 6.94263V17.9426C32 21.2563 29.3137 23.9426 26 23.9426H6C2.68629 23.9426 0 21.2563 0 17.9426V6.94263Z",fill:"currentColor"}),r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19.9945 23.8935L26.237 23.8934C26.1982 24.3557 26.1712 25.2778 26.1704 26.2318C26.1688 28.2839 26.1376 28.7041 25.974 28.868C25.583 29.2598 25.2686 29.0967 24.0616 27.8754C23.4162 27.2222 22.1141 25.9522 21.1682 25.0531L19.9945 23.8935Z",fill:"currentColor"})]})}function Ki(){var t;const{accessibility:e}=C.useConfig();return((t=e==null?void 0:e.widgetTriggerButton)==null?void 0:t.label)??"Chat with us"}function Zi(e,t,n,o){return e({react:u,isOpen:t,setIsOpen:s=>n(s),unreadCount:o})}const Kh=eo({transparent:!0}),Mr=6,Cs={x:Tt.x+Mr,y:Tt.y+Mr},er=e=>typeof e=="number"?e-Mr:e;function Zh(){var h,f;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{assets:n,customComponents:o}=C.useConfig(),{count:s}=C.useUnread(),i=Ln(s),a=$n()==="count",{theme:c,triggerSide:d}=ue(),l=Hi(c.widgetTrigger.size.button,a),m=Ki(),p=i&&!e?`${m} · ${i}`:m;return o!=null&&o.widgetTrigger?Zi(o.widgetTrigger,e,t,s):r.jsx(Ks,{initialContent:Kh,title:"OpenCX Live Chat Trigger",style:{height:`calc(${c.widgetTrigger.size.button}px + ${Cs.y*2}px)`,width:`calc(${c.widgetTrigger.size.button}px + ${Cs.x*2}px)`,fontSize:"16px",position:"fixed",zIndex:c.widgetTrigger.zIndex,right:er(c.widgetTrigger.offset.right),bottom:er(c.widgetTrigger.offset.bottom),left:er(c.widgetTrigger.offset.left),boxSizing:"border-box",borderWidth:"0px",background:"transparent"},children:r.jsx(Pn,{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsxs(Qe.PopoverTrigger,{"aria-label":p,title:p,className:A("relative font-sans flex items-center justify-center rounded-full"),style:{height:c.widgetTrigger.size.button,width:c.widgetTrigger.size.button},children:[!e&&r.jsx(xo,{count:s,style:{top:l,[d]:l}}),r.jsx(Oe,{children:r.jsx("div",{...P("trigger/btn"),className:A("relative size-full rounded-full","flex items-center justify-center","overflow-hidden","transition-all","bg-primary","text-primary-foreground"),children:r.jsx(W.AnimatePresence,{mode:"wait",children:e?r.jsx(ee,{snapExit:!0,fadeIn:"up",overrides:{initial:{rotate:45},animate:{rotate:0}},children:(h=n==null?void 0:n.widgetTrigger)!=null&&h.closeIcon?r.jsx("img",{src:n.widgetTrigger.closeIcon,alt:"Widget trigger close icon",style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon}}):r.jsx(T.ChevronDownIcon,{style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon}})},"x-icon"):r.jsx(ee,{snapExit:!0,overrides:{initial:{rotate:45},animate:{rotate:0}},children:(f=n==null?void 0:n.widgetTrigger)!=null&&f.openIcon?r.jsx("img",{src:n.widgetTrigger.openIcon,alt:"Widget trigger open icon",style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon}}):r.jsx(Gh,{style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon},className:"mt-0.5 opacity-95"})},"message-icon")})})})]})})})}function Jh(){const{triggerSide:e}=ue();return r.jsx(Qe.Anchor,{style:{position:"fixed",bottom:0,right:e==="right"?0:void 0,left:e==="left"?0:void 0}})}const Qh="[data-opencx-escape-scope]";function ef(e){var n;const t=e.target;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,Qh))!=null}function tf(e,{state:t,onToggleFullscreen:n}){e.defaultPrevented||t!=="chat"||xt(e,$e["toggle-fullscreen"])&&(e.preventDefault(),n())}function Ji(e,{state:t,onDismiss:n,onToggleFullscreen:o}){if(!e.defaultPrevented){if(xt(e,$e["close-panel"])){ef(e)||n();return}t==="chat"&&xt(e,$e["toggle-fullscreen"])&&(e.preventDefault(),o())}}function nf({panelLayout:e,previousLayout:t,defaultLayout:n,allowedLayouts:o}){if(e!=="fullscreen")return{kind:"close"};const s=[t,n];for(const a of s)if(a!=="fullscreen"&&o.includes(a))return{kind:"layout",layout:a};const i=o.find(a=>a!=="fullscreen");return i?{kind:"layout",layout:i}:{kind:"close"}}function rf({onHeightChange:e,maxHeight:t,onDismiss:n,onToggleFullscreen:o}){const s=u.useRef(null);return u.useLayoutEffect(()=>{var l;const i=s.current;if(!i)return;const a=()=>e(i.offsetHeight);a();const c=(l=i.ownerDocument.defaultView)==null?void 0:l.ResizeObserver;if(!c)return;const d=new c(a);return d.observe(i),()=>d.disconnect()},[e,t]),r.jsx(Pn,{children:r.jsx("div",{ref:s,onKeyDown:i=>Ji(i.nativeEvent,{state:"input",onDismiss:n,onToggleFullscreen:o}),"data-companion-questions":!0,style:{maxHeight:t},className:"flex min-w-0 flex-col items-start gap-2 overflow-y-auto p-1",children:r.jsx(of,{})})})}function of(){const{initialQuestions:e}=C.useConfig(),t=W.useReducedMotion();return r.jsx(r.Fragment,{children:e==null?void 0:e.filter(n=>n.trim().length>0).map((n,o)=>r.jsx(W.motion.div,{className:"max-w-full",initial:{opacity:0,y:t?0:8},animate:{opacity:1,y:0},transition:{duration:t?0:.3,delay:t?0:.2+Math.min(o,5)*.1,ease:ot},children:r.jsx(qt,{suggestion:n,type:"button",variant:"secondary",wobble:!1,className:"max-w-full whitespace-normal break-words rounded-full bg-muted-foreground px-4 py-2 text-start text-base text-background hover:bg-foreground [@media(pointer:coarse)]:min-h-12"})},`${n}-${o}`))})}const Qi=new WeakSet;function sf(e){return Qi.has(e)}function Ss(e,t=()=>!0){var p;let n=!1;const o=h=>h?"completed":n?"interrupted":"not-started",s=e.getBoundingClientRect(),i=s.left+s.width/2,a=s.top+s.height/2,c={bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:a},d=h=>t()?(n=!0,Qi.add(h),e.dispatchEvent(h),!0):!1,l=h=>d(new PointerEvent(h,{...c,pointerId:1,pointerType:"mouse",isPrimary:!0})),m=(h,f=0)=>d(new MouseEvent(h,{...c,detail:f,button:0,buttons:1}));return!l("pointerover")||!l("pointerenter")||!m("mouseover")||!m("mousemove")||!l("pointerdown")||!m("mousedown",1)||!t()?o(!1):((p=e.focus)==null||p.call(e),o(l("pointerup")&&m("mouseup",1)&&m("click",1)))}const vo=u.forwardRef(function({label:t,className:n,...o},s){return r.jsx("button",{ref:s,type:"button","aria-label":t,...o,className:A("flex shrink-0 items-center justify-center rounded-lg","text-secondary-foreground/60 hover:text-secondary-foreground hover:bg-muted","active:scale-[0.97] transition-[background-color,color,transform] duration-150 ease-out",n)})});function dt(e,t,n){return Math.min(Math.max(e,t),n)}const Rr=16,Ae=16,et=32,af=44,cf=240,lf=440,ec=32,df=280,uf=420,pf=640,mf=48,tr=12,yo=400,tc=320,hf=560,ff="#f4f4f5",nc=120,rc=tc+nc+Ae*3,tt={pill:999,input:16,fullscreen:16,sidebar:20,compact:20};function ko(e,t){if(e.width<=rc)return Math.max(0,e.width-Ae*2);const n=e.width-nc-Ae*3;return Math.max(0,Math.min(t,n))}function _t(e,t,n=0){return typeof e=="number"&&Number.isFinite(e)?Math.max(n,e):t}function oc(e,t={}){const n=Math.max(0,e.width),o=_t(t.maxWidth,lf),s=Math.min(o,_t(t.minWidth,df));return Math.min(n,o,Math.max(s,n-ec))}function gf(e,t,n={}){const o=Math.max(0,e.height),s=_t(n.minHeight,uf),i=_t(n.maxHeight,pf,s),a=Math.min(1,_t(n.viewportHeightRatio,.65)),c=Math.max(0,o-Math.max(0,t)-mf);return Math.min(i,c,Math.max(s,o*a))}function xf(e){const{layout:t,region:n,sidebarWidth:o,bottomOffset:s,compact:i}=e;return t==="fullscreen"?{width:Math.max(0,n.width-Rr*2),height:Math.max(0,n.height-Rr*2),borderRadius:tt.fullscreen}:t==="sidebar"?{width:ko(n,o),height:Math.max(0,n.height-Ae*2),borderRadius:tt.sidebar}:{width:oc(n,i),height:gf(n,s,i),borderRadius:_t(i==null?void 0:i.borderRadius,tt.compact)}}function bf(e){const{isChatOpen:t,layout:n,region:o,sidebarWidth:s,sidebarSide:i,bottomOffset:a}=e,c=t?n:"compact",d=ko(o,s),l=c==="fullscreen"?Rr:c==="sidebar"?Ae:a;return{centerX:c==="sidebar"?i==="left"?Ae+d/2:o.width-Ae-d/2:o.width/2,bottom:l}}const he="[data-companion-root]",wf=`
|
|
145
|
-
${he} [data-component="chat/msgs/root"] {
|
|
146
|
-
overflow-x: hidden !important;
|
|
147
|
-
}
|
|
148
|
-
${he} [data-component="chat/agent_msg_group/root"],
|
|
149
|
-
${he} [data-component="chat/agent_msg_group/avatar_and_msgs/root"],
|
|
150
|
-
${he} [data-component="chat/agent_msg_group/avatar_and_msgs/msgs"] {
|
|
151
|
-
min-width: 0 !important;
|
|
152
|
-
max-width: 100% !important;
|
|
153
|
-
}
|
|
154
|
-
${he} [data-component="chat/agent_msg/msg"] {
|
|
155
|
-
background: transparent !important;
|
|
156
|
-
padding: 2px 0 !important;
|
|
157
|
-
border-radius: 0 !important;
|
|
158
|
-
max-width: 100% !important;
|
|
159
|
-
min-width: 0 !important;
|
|
160
|
-
overflow-wrap: break-word !important;
|
|
161
|
-
}
|
|
162
|
-
${he} [data-component="chat/agent_msg/msg"] table {
|
|
163
|
-
display: block;
|
|
164
|
-
max-width: 100%;
|
|
165
|
-
overflow-x: auto;
|
|
166
|
-
border-collapse: collapse;
|
|
167
|
-
}
|
|
168
|
-
${he} [data-component="chat/agent_msg/msg"] th,
|
|
169
|
-
${he} [data-component="chat/agent_msg/msg"] td {
|
|
170
|
-
overflow-wrap: normal;
|
|
171
|
-
word-break: normal;
|
|
172
|
-
white-space: normal;
|
|
173
|
-
vertical-align: top;
|
|
174
|
-
text-align: start;
|
|
175
|
-
padding: 4px 10px 4px 0;
|
|
176
|
-
border-bottom: 1px solid hsl(var(--opencx-border));
|
|
177
|
-
}
|
|
178
|
-
${he} [data-component="chat/user_msg/msg"] {
|
|
179
|
-
background: hsl(var(--opencx-secondary)) !important;
|
|
180
|
-
color: hsl(var(--opencx-secondary-foreground)) !important;
|
|
181
|
-
padding: 8px 12px !important;
|
|
182
|
-
border-radius: 10px !important;
|
|
183
|
-
}
|
|
184
|
-
`,vf=`
|
|
185
|
-
${he} [data-component="chat/agent_msg_group/root/avatar"],
|
|
186
|
-
${he} [data-component="chat/agent_msg_group/avatar_and_msgs/avatar"] {
|
|
187
|
-
display: none !important;
|
|
188
|
-
}
|
|
189
|
-
`,yf=`
|
|
190
|
-
${he} [data-component="chat/agent_msg_group/avatar_and_msgs/root"] {
|
|
191
|
-
align-items: flex-start !important;
|
|
192
|
-
}
|
|
193
|
-
${he} [data-component="chat/agent_msg_group/avatar_and_msgs/avatar"] {
|
|
194
|
-
width: 20px !important;
|
|
195
|
-
height: 20px !important;
|
|
196
|
-
margin-top: 2px !important;
|
|
197
|
-
}
|
|
198
|
-
/* Steps, rendered blocks, the working spinner and the actions row are siblings
|
|
199
|
-
of the text groups in a streamed turn: indent them by the avatar gutter
|
|
200
|
-
(20px avatar + 8px gap) so everything shares the text's left edge. The
|
|
201
|
-
typing row carries its own avatar, so it keeps the gutter instead — indenting
|
|
202
|
-
it would jump the avatar sideways when the reply replaces it. */
|
|
203
|
-
${he} [data-component="chat/streaming_turn/root"] > :not([data-component="chat/agent_msg_group/root"]):not([data-component="chat/bot_loading/root"]) {
|
|
204
|
-
margin-inline-start: 28px !important;
|
|
205
|
-
}
|
|
206
|
-
${he} [data-component="chat/bot_loading/root"] {
|
|
207
|
-
align-items: flex-start !important;
|
|
208
|
-
}
|
|
209
|
-
/* Its avatar is the row's first child (LoadingDefaultComponent renders no
|
|
210
|
-
data-component on it), sized to match a reply's. */
|
|
211
|
-
${he} [data-component="chat/bot_loading/root"] > :first-child {
|
|
212
|
-
width: 20px !important;
|
|
213
|
-
height: 20px !important;
|
|
214
|
-
margin-top: 2px !important;
|
|
215
|
-
}
|
|
216
|
-
`;function Ns({layout:e,sidebarSide:t}){const n={width:18,height:18,viewBox:"0 0 18 18",fill:"none","aria-hidden":!0},o=r.jsx("rect",{x:2,y:2.5,width:14,height:13,rx:2.5,stroke:"currentColor",strokeWidth:1.4});return e==="fullscreen"?r.jsxs("svg",{...n,children:[o,r.jsx("rect",{x:4.5,y:5,width:9,height:8,rx:1.4,fill:"currentColor"})]}):e==="sidebar"?r.jsxs("svg",{...n,children:[o,r.jsx("rect",{x:t==="left"?2:10.5,y:2.5,width:5.5,height:13,rx:2.5,fill:"currentColor"})]}):r.jsxs("svg",{...n,children:[o,r.jsx("rect",{x:5,y:9,width:8,height:4.5,rx:1.6,fill:"currentColor"})]})}function kf({side:e}){return r.jsxs("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,children:[r.jsx("rect",{x:1,y:2,width:12,height:10,rx:2,stroke:"currentColor",strokeWidth:1.2,opacity:.5}),r.jsx("rect",{x:e==="left"?1:8.5,y:2,width:4.5,height:10,rx:2,fill:"currentColor"})]})}function jf({anchored:e,side:t,onSelectSide:n,docked:o,onToggleDock:s}){const{t:i}=Y();return r.jsx(W.motion.div,{...P("companion/layout_picker/sidebar_options"),initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.18,ease:ot},style:e?{left:"50%",x:"-50%"}:void 0,className:A("origin-top",e&&"absolute top-full z-10 pt-3"),children:r.jsxs("div",{className:A("flex flex-col gap-1.5 whitespace-nowrap",e&&"rounded-[var(--pk-r)] border bg-background p-[var(--pk-p)] shadow-lg"),children:[r.jsx(_s,{label:i("companion_sidebar_dock_label"),children:r.jsx(Cf,{label:i("companion_sidebar_dock_label"),checked:o,onToggle:s})}),r.jsx(_s,{label:i("companion_sidebar_side_label"),children:r.jsx(Sf,{label:i("companion_sidebar_side_label"),side:t,onSelect:n})})]})})}function _s({label:e,children:t}){return r.jsxs("div",{className:"flex items-center justify-between gap-4 ps-1.5",children:[r.jsx("span",{"aria-hidden":!0,className:"text-[11px] font-medium leading-none text-secondary-foreground/70",children:e}),t]})}function Cf({label:e,checked:t,onToggle:n}){return r.jsx("button",{...P("companion/layout_picker/sidebar_option"),type:"button",role:"switch","aria-checked":t,"aria-label":e,onClick:n,className:A("relative flex h-4 w-7 shrink-0 items-center rounded-full px-0.5","transition-colors duration-150","active:scale-[0.97]",t?"bg-primary":"bg-secondary-foreground/20"),children:r.jsx(W.motion.span,{"aria-hidden":!0,initial:!1,animate:{x:t?12:0},transition:At,className:"size-3 rounded-full bg-background shadow-sm"})})}function Sf({label:e,side:t,onSelect:n}){const{t:o}=Y(),s=[{value:"left",labelKey:"companion_sidebar_left"},{value:"right",labelKey:"companion_sidebar_right"}];return r.jsx("div",{role:"radiogroup","aria-label":e,className:"flex items-center gap-0.5 rounded-full bg-secondary-foreground/10 p-0.5",children:s.map(({value:i,labelKey:a})=>{const c=i===t;return r.jsxs("button",{...P("companion/layout_picker/sidebar_option"),type:"button",role:"radio","aria-checked":c,"aria-label":o(a),onClick:()=>n(i),className:A("relative flex items-center justify-center rounded-full p-1","transition-colors duration-150","active:scale-[0.97]",c?"text-primary":"text-secondary-foreground/60"),children:[c&&r.jsx(W.motion.span,{"aria-hidden":!0,layoutId:"opencx-sidebar-side-indicator",transition:At,className:"absolute inset-0 rounded-full bg-background shadow-sm"}),r.jsx("span",{className:"relative",children:r.jsx(kf,{side:i})})]},i)})})}const Nf={compact:"companion_layout_floating",sidebar:"companion_layout_sidebar",fullscreen:"companion_layout_fullscreen"};function _f(e){try{return e.matches(":focus-visible")}catch{return!0}}function Ef({current:e,onSelect:t}){const{t:n}=Y(),{allowedLayouts:o,sidebarSide:s,setSidebarSide:i,sidebarMode:a,setSidebarMode:c}=C.useWidgetLayout(),[d,l]=u.useState(!1),m=Mn(),p=o.map(b=>({layout:b,label:Nf[b]})),h=p.length>=2,f=o.includes("sidebar");if(!h&&!f)return null;const x=f&&(h?m?d:e==="sidebar":!0),g=b=>{b(),e!=="sidebar"&&t("sidebar")},j=r.jsx(W.AnimatePresence,{initial:!1,children:x&&r.jsx(jf,{anchored:h,side:s,onSelectSide:b=>g(()=>i(b)),docked:a==="docked",onToggleDock:()=>g(()=>c(a==="docked"?"floating":"docked"))})});return r.jsxs(Qe.Root,{onOpenChange:()=>l(!1),children:[r.jsx(Ie,{content:n("companion_layout_label"),side:"bottom",children:r.jsx(Qe.Trigger,{asChild:!0,children:r.jsx(vo,{...P("companion/layout_picker/trigger"),label:n("companion_layout_label"),className:"size-7",children:r.jsx(Ns,{layout:e,sidebarSide:s})})})}),r.jsx(Qe.Content,{...P("companion/layout_picker/menu"),"data-opencx-escape-scope":"",side:"bottom",align:"end",sideOffset:6,collisionPadding:8,onPointerLeave:()=>l(!1),style:{"--pk-r":"16px","--pk-p":"6px"},className:A("z-50 flex flex-col rounded-[var(--pk-r)] border bg-background p-[var(--pk-p)] shadow-lg","origin-[var(--radix-popover-content-transform-origin)]","animate-in fade-in-0 zoom-in-95","data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"),children:h?r.jsx("div",{className:"flex items-stretch gap-0.5",children:p.map(({layout:b,label:S})=>{const w=b===e,_=n(S),y=b==="sidebar",v=r.jsx(Qe.Close,{asChild:!0,children:r.jsxs("button",{...P("companion/layout_picker/option"),type:"button","aria-label":_,"aria-pressed":w,"aria-expanded":y?x:void 0,onClick:()=>t(b),onPointerEnter:()=>l(y),onFocus:N=>l(y&&_f(N.currentTarget)),className:A("flex w-14 flex-col items-center gap-1 rounded-[calc(var(--pk-r)-var(--pk-p))] px-1.5 py-1.5","transition-colors duration-150",w?"bg-primary/10 text-primary":"text-secondary-foreground/60 hover:bg-muted hover:text-secondary-foreground"),children:[r.jsx(Ns,{layout:b,sidebarSide:s}),r.jsx("span",{className:"whitespace-nowrap text-[10px] font-medium leading-none",children:_})]})});return y?r.jsxs("div",{className:"relative flex",children:[v,j]},b):b!=="fullscreen"?r.jsx(u.Fragment,{children:v},b):r.jsx(Ie,{content:_,shortcut:ho($e["toggle-fullscreen"]),side:"bottom",children:v},b)})}):j})]})}function Tf({layout:e,onSelectLayout:t,onClose:n}){const{t:o}=Y();return r.jsxs("div",{...P("companion/controls/root"),className:"absolute top-2 z-10 flex items-center gap-1",style:{insetInlineEnd:8},children:[r.jsx(Ef,{current:e,onSelect:t}),r.jsx(Ie,{content:o("companion_close"),shortcut:ho($e["close-panel"]),side:"bottom",children:r.jsx(vo,{...P("companion/close_btn"),label:o("companion_close"),onClick:n,className:"size-7",children:r.jsx(T.XIcon,{className:"size-4"})})})]})}const Af=`
|
|
217
|
-
/* Quick-ask (resting) composer: the stock card is a two-row layout (textarea
|
|
218
|
-
over an attach/send row) wrapped in outer padding. In the companion pill it
|
|
219
|
-
reads as a single quick-ask bar, so drop the outer pad and lay the card out
|
|
220
|
-
on ONE row — textarea flex-fills, attach + send sit inline at the end.
|
|
221
|
-
Scoped to the quick-ask pane only; the full chat panel keeps the stock
|
|
222
|
-
two-row composer. */
|
|
223
|
-
[data-companion-input] [data-component="chat/input_box/root"] {
|
|
224
|
-
padding: 0 !important;
|
|
225
|
-
}
|
|
226
|
-
/* The attached-context tray is a FULL-composer affordance. In the one-row
|
|
227
|
-
quick-ask bar it stacks a second row and paints a second surface inside the
|
|
228
|
-
shell — a grey box with its own padding and radius sitting inside the white
|
|
229
|
-
pill, which is not what the resting bar is. Flatten the tray to a pure
|
|
230
|
-
pass-through here and hide its row; the entity still rides the send, and
|
|
231
|
-
the full chat panel (one rung up) is where you see and remove it. */
|
|
232
|
-
[data-companion-input] [data-component="chat/input_box/attached_context_tray"] {
|
|
233
|
-
padding: 0 !important;
|
|
234
|
-
background: transparent !important;
|
|
235
|
-
/* The root's space-y-1 puts a 4px top margin on the tray (its first sibling
|
|
236
|
-
is the hidden dropzone input); with the outer padding gone that margin
|
|
237
|
-
shows as a strip of shell background above the bar. */
|
|
238
|
-
margin-top: 0 !important;
|
|
239
|
-
}
|
|
240
|
-
[data-companion-input]
|
|
241
|
-
[data-component="chat/input_box/attached_context_tray"]
|
|
242
|
-
> *:not([data-component="chat/input_box/inner_root"]) {
|
|
243
|
-
display: none !important;
|
|
244
|
-
}
|
|
245
|
-
[data-companion-input] [data-component="chat/input_box/inner_root"] {
|
|
246
|
-
flex-direction: row !important;
|
|
247
|
-
align-items: center !important;
|
|
248
|
-
margin-top: 0 !important;
|
|
249
|
-
/* The stock card is rounded-3xl (24px), but the companion shell that frames
|
|
250
|
-
it clips at RADII.input in the resting-input state. A mismatch leaves the
|
|
251
|
-
shell's background token peeking out as a two-tone crescent at each
|
|
252
|
-
corner, so the card takes the shell radius via the custom property set on
|
|
253
|
-
the quick-ask pane — one clean rounded bar. */
|
|
254
|
-
border-radius: var(--opencx-companion-input-radius) !important;
|
|
255
|
-
}
|
|
256
|
-
[data-companion-input] [data-component="chat/input_box/textarea_and_attachments_container"] {
|
|
257
|
-
flex: 1 1 auto !important;
|
|
258
|
-
min-width: 0 !important;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/* Fullscreen reading column: the panel is a full-width window, but message
|
|
262
|
-
text across a 1900px panel wraps at ~200 characters. Cap the conversation
|
|
263
|
-
and composer to one centered column; the header and corner controls stay
|
|
264
|
-
full-width window chrome. The messages keep the cap as PADDING on the
|
|
265
|
-
scroll container so the scrollbar stays at the panel edge; the footer gets
|
|
266
|
-
a real max-width (+16px compensates the input card's own p-2) so the
|
|
267
|
-
composer card's edges land exactly on the message column's edges. */
|
|
268
|
-
[data-companion-root][data-layout="fullscreen"] [data-component="chat/msgs/root"] {
|
|
269
|
-
padding-inline: max(16px, calc((100% - var(--opencx-companion-content-max-width)) / 2)) !important;
|
|
270
|
-
}
|
|
271
|
-
[data-companion-root][data-layout="fullscreen"] [data-component="chat/main/root"] > footer {
|
|
272
|
-
width: 100%;
|
|
273
|
-
max-width: calc(var(--opencx-companion-content-max-width) + 16px);
|
|
274
|
-
margin-inline: auto;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/* Sessions (conversation history) gets the same reading column: cards and the
|
|
278
|
-
sticky new-conversation button stretch edge-to-edge otherwise. Padding (not
|
|
279
|
-
max-width) for the same reason as the messages — the list IS the scroll
|
|
280
|
-
container, so the scrollbar stays at the panel edge. */
|
|
281
|
-
[data-companion-root][data-layout="fullscreen"] [data-component="sessions/list"] {
|
|
282
|
-
padding-inline: max(16px, calc((100% - var(--opencx-companion-content-max-width)) / 2)) !important;
|
|
283
|
-
}
|
|
284
|
-
`;function If({state:e,layout:t,shellRadius:n,onMinimize:o,onDismiss:s,onToggleFullscreen:i,onSelectLayout:a,onExpand:c,canExpand:d,placeholder:l,hideAttachTools:m,onInputHeightChange:p}){const{companion:h}=C.useConfig(),f=bi(),{t:x}=Y(),g=u.useRef(null),j=u.useRef(null),b=u.useRef(null),S=(h==null?void 0:h.bubbles)===!0,w=(h==null?void 0:h.avatars)??S,_=Af+(S?"":wf)+(w?"":vf)+(w&&!S?yf:"");return u.useEffect(()=>{var N;const y=(N=g.current)==null?void 0:N.ownerDocument;if(!y)return;function v(R){Ji(R,{state:e,onDismiss:s,onToggleFullscreen:i})}return y.addEventListener("keydown",v),()=>y.removeEventListener("keydown",v)},[s,i,e]),u.useLayoutEffect(()=>{var M;if(e!=="input")return;const y=j.current,v=(M=y==null?void 0:y.ownerDocument.defaultView)==null?void 0:M.ResizeObserver;if(!y||!v)return;const N=()=>p(y.offsetHeight);N();const R=new v(N);return R.observe(y),()=>R.disconnect()},[e,p]),u.useLayoutEffect(()=>{e!=="input"||d||f||nr(j.current)},[e,d,f]),u.useLayoutEffect(()=>{var N;if(e!=="chat"||nr(b.current))return;const y=(N=b.current)==null?void 0:N.ownerDocument.defaultView;if(!y)return;const v=y.requestAnimationFrame(()=>nr(b.current));return()=>y.cancelAnimationFrame(v)},[e]),r.jsx(Pn,{overrides:_,rootRef:g,shellRadius:`${n}px`,children:e==="input"?r.jsxs("div",{ref:j,"data-companion-input":!0,style:{position:"absolute",left:0,right:0,bottom:0,"--opencx-companion-input-radius":`${tt.input}px`},children:[r.jsxs("div",{className:"relative",children:[r.jsx(ju,{children:r.jsx(Pi,{disabled:f,hideAttachTools:m,placeholder:l,trailingActions:f?r.jsx(vo,{label:x("companion_close"),onClick:s,className:"size-8",children:r.jsx(T.XIcon,{className:"size-4"})}):void 0})}),d?r.jsx("button",{type:"button","aria-label":x("companion_expand_chat"),onClick:c,className:"absolute inset-0 z-10 cursor-pointer"}):null]}),r.jsx(Sr,{})]}):r.jsxs("div",{ref:b,"data-companion-root":!0,"data-layout":t,style:{position:"absolute",inset:0,"--opencx-companion-content-max-width":(h==null?void 0:h.contentMaxWidth)??"48rem"},children:[r.jsx(wo,{}),r.jsx(Tf,{layout:t,onSelectLayout:a,onClose:o})]})})}function nr(e){const t=e==null?void 0:e.querySelector("textarea");return t?(t.focus({preventScroll:!0}),!0):!1}function Es({initialContent:e,title:t=Ga,style:n,iframeRef:o,children:s}){const[i,a]=u.useState(null),c=u.useCallback(d=>{if(o&&(o.current=d),!d)return;const l=d.contentDocument;l&&(l.open(),l.write(e),l.close(),a(l.body))},[]);return r.jsxs(r.Fragment,{children:[r.jsx("iframe",{ref:c,title:t,style:n,allowFullScreen:!0}),i&&Kt.createPortal(s,i)]})}function zf({size:e,headColor:t,eyeColor:n}){const o=u.useRef(null),[s,i]=u.useState(!1),[a,c]=u.useState(!1),d=W.useReducedMotion(),l=W.useMotionValue(0),m=W.useMotionValue(0),p=W.useSpring(l,{stiffness:300,damping:30}),h=W.useSpring(m,{stiffness:300,damping:30}),f=W.useTransform(p,w=>8+w*1.2),x=W.useTransform(h,w=>11.5+w*1.2),g=W.useTransform(p,w=>16+w*1.2),j=W.useTransform(h,w=>11.5+w*1.2),b=u.useCallback(w=>{const _=o.current;if(!_)return;const y=_.getBoundingClientRect(),v=y.left+y.width/2,N=y.top+y.height/2,R=(w.clientX-v)/(y.width*2),M=(w.clientY-N)/(y.height*2),z=Math.min(Math.sqrt(R*R+M*M),1),L=Math.atan2(M,R);l.set(Math.cos(L)*z),m.set(Math.sin(L)*z)},[l,m]);u.useEffect(()=>(s&&!d?window.addEventListener("mousemove",b):(l.set(0),m.set(0)),()=>window.removeEventListener("mousemove",b)),[s,b,l,m,d]),u.useEffect(()=>{if(d)return;let w,_;function y(){clearTimeout(w),clearTimeout(_)}function v(){w=setTimeout(()=>{c(!0),_=setTimeout(()=>c(!1),150),v()},1200+Math.random()*1800)}function N(){y(),document.visibilityState==="visible"&&v()}return document.visibilityState==="visible"&&v(),document.addEventListener("visibilitychange",N),()=>{y(),document.removeEventListener("visibilitychange",N)}},[d]);const S=a?.15:1;return r.jsxs("svg",{ref:o,viewBox:"0 0 24 24",style:{width:e,height:e,flexShrink:0,display:"block"},"aria-hidden":!0,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[r.jsx("circle",{cx:12,cy:12,r:11,fill:t}),r.jsx("circle",{cx:8,cy:11.5,r:3.2,fill:n}),r.jsx("circle",{cx:16,cy:11.5,r:3.2,fill:n}),r.jsx(W.motion.circle,{cx:f,cy:x,r:1.4,fill:t,animate:{scaleY:S},style:{originX:"8px",originY:"11.5px"},transition:{duration:.08}}),r.jsx(W.motion.circle,{cx:g,cy:j,r:1.4,fill:t,animate:{scaleY:S},style:{originX:"16px",originY:"11.5px"},transition:{duration:.08}})]})}function Mf({icon:e,pillBackground:t,size:n}){return e?r.jsx("img",{src:e,alt:"",style:{width:n,height:n,objectFit:"cover",borderRadius:999,flexShrink:0}}):r.jsx(zf,{size:n,headColor:t,eyeColor:"hsl(var(--opencx-primary-foreground))"})}function Rf(e){return{initial:!1,animate:{opacity:e?1:0},transition:{...be,delay:e?.25:0}}}function Pf({visible:e,docked:t,label:n,icon:o,pillBackground:s,dir:i,measureRef:a,activeCount:c=0,countLabel:d,onOpenChats:l,pickerOpen:m=!1,working:p=!1,sessions:h,unreadCount:f=0,unreadShowCount:x=!1}){const g=W.useReducedMotion(),j=Math.max(3,Hi(et,x));return r.jsxs(W.motion.div,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",borderRadius:"inherit",overflow:"hidden",pointerEvents:"none",userSelect:"none",background:"hsl(var(--opencx-background))"},...Rf(e),children:[e&&!t&&c>0&&r.jsx("button",{type:"button","data-companion-count-trigger":"","aria-label":d,"aria-haspopup":"menu","aria-expanded":m,onClick:b=>{b.stopPropagation(),l==null||l(b.currentTarget,b.detail>0)},style:{position:"absolute",insetInlineStart:12,top:0,zIndex:2,width:24,height:24,padding:0,border:0,background:"transparent",pointerEvents:"auto",cursor:"pointer"},children:r.jsxs("span",{"aria-hidden":!0,style:{position:"absolute",insetInlineStart:6,top:0,width:14,height:14,display:"grid",placeItems:"center",borderRadius:999,background:"hsl(var(--opencx-background))",color:"hsl(var(--opencx-foreground))",font:"9px ui-sans-serif,system-ui,sans-serif",fontVariantNumeric:"tabular-nums"},children:[c,p&&r.jsx(W.motion.span,{style:{position:"absolute",inset:-2,display:"flex"},animate:g?void 0:{rotate:360},transition:{duration:1.2,repeat:1/0,ease:"linear"},children:r.jsx(T.LoaderCircleIcon,{size:18})})]})}),r.jsxs("div",{ref:a,dir:i,style:{display:"flex",alignItems:"center",gap:8,height:"100%",width:"max-content",paddingInlineEnd:12,fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[r.jsxs("span",{style:{position:"relative",display:"flex",flexShrink:0,width:et,height:et},children:[r.jsx(Mf,{icon:o,pillBackground:s,size:et}),e&&f>0&&r.jsxs(r.Fragment,{children:[r.jsx(lh,{}),r.jsx(Wi,{count:f,showCount:x,style:{top:j,insetInlineEnd:j}})]})]}),r.jsx(W.motion.span,{initial:!1,animate:{opacity:t?1:0},transition:{duration:.12,ease:ot},style:{fontSize:13,color:"hsl(var(--opencx-muted-foreground))",whiteSpace:"nowrap"},children:n}),h&&r.jsx("div",{style:{position:"relative",zIndex:2,paddingInlineStart:4,opacity:t?1:0},children:h})]})]})}function Of({chat:e,number:t,selected:n,interactive:o,onSelect:s,onClose:i,portalTarget:a}){const{t:c}=Y(),{cssVars:d,theme:l}=ue(),[m,p]=u.useState(!1);u.useEffect(()=>{o||p(!1)},[o]);const{title:h}=to(e),f=`${h}${e.working?` — ${c("thinking")}`:""}`;function x(j){return a&&r.jsx(Te.Portal,{container:a,children:r.jsxs(Te.Content,{side:"top",sideOffset:8,collisionPadding:12,"data-companion-session-tooltip":"",style:{...d,zIndex:l.widgetContentContainer.zIndex+2,maxWidth:"min(280px, calc(100vw - 24px))",padding:"7px 10px",borderRadius:9,background:"hsl(var(--opencx-foreground))",color:"hsl(var(--opencx-background))",font:"12px/1.4 ui-sans-serif, system-ui, sans-serif",overflowWrap:"anywhere",textAlign:"center",boxShadow:"0 4px 14px rgb(0 0 0 / .12)"},children:[j,r.jsx(Te.Arrow,{width:8,height:4,style:{fill:"hsl(var(--opencx-foreground))"}})]})})}const g=c("companion_close_chat",{title:h});return r.jsxs("div",{"data-session-item":"",children:[r.jsxs(Te.Root,{open:o&&m,onOpenChange:p,children:[r.jsx(Te.Trigger,{asChild:!0,children:r.jsxs(V,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-session-circle":e.id,"aria-label":f,"aria-pressed":n,tabIndex:o?0:-1,onClick:j=>{j.stopPropagation(),s()},children:[e.working&&r.jsx(T.LoaderCircleIcon,{size:28,"aria-hidden":!0,"data-session-working":""}),r.jsx("span",{"aria-hidden":!0,children:t})]})}),x(f)]}),r.jsx(V,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-session-close":e.id,"aria-label":g,tabIndex:o?0:-1,onClick:j=>{j.stopPropagation(),p(!1),i(j.currentTarget)},children:r.jsx(T.XIcon,{size:10,"aria-hidden":!0})})]})}function $f({onSelected:e=()=>{},onLastClosed:t=()=>{},interactive:n=!0}){const{openChats:o,activeId:s,selectChat:i,newChat:a,closeChat:c}=C.useCompanionChats(),{canCreateNewSession:d}=C.useSessions(),{isSmallScreen:l}=ye(),{t:m,dir:p}=Y(),h=no(),f=On(),x=l?2:3,g=o.slice(0,o.length>x?x-1:x),j=o.find(v=>v.id===s);j&&!g.includes(j)&&(g[g.length-1]=j);const b=o.length-g.length,S=o.some(v=>v.working&&!g.includes(v)),w=u.useRef(h.close);w.current=h.close,u.useEffect(()=>{n||w.current(!0)},[n]);function _(v){h.close(!0),v===void 0?a():i(v),e()}function y(v,N){var z,L;h.close(!0);const R=g.findIndex(O=>O.id===v),M=g[R+1]??g[R-1];(L=(z=N.closest("[data-companion-session-circles]"))==null?void 0:z.querySelector(M?`[data-session-circle="${M.id}"]`:"[data-new-session]"))==null||L.focus({preventScroll:!0}),c(v),o.length===1&&t()}return r.jsx(Te.Provider,{delayDuration:150,skipDelayDuration:300,children:r.jsxs("div",{role:"group","aria-label":m("companion_active_chats",{count:o.length}),"aria-hidden":!n||void 0,"data-companion-session-circles":"",dir:p,onPointerDown:v=>v.stopPropagation(),style:{position:"relative",zIndex:0,display:"flex",alignItems:"center",gap:4,flexShrink:0,pointerEvents:n?"auto":"none"},children:[r.jsx(ro,{}),r.jsx("style",{children:`
|
|
285
|
-
[data-companion-session-tooltip][data-state="delayed-open"] { animation: opencx-session-tooltip-in 120ms ease-out; }
|
|
286
|
-
@keyframes opencx-session-tooltip-in { from { opacity: 0; } to { opacity: 1; } }
|
|
287
|
-
@media (prefers-reduced-motion: reduce) { [data-companion-session-tooltip] { animation: none !important; } }
|
|
288
|
-
[data-companion-session-circles] > button,
|
|
289
|
-
[data-companion-session-circles] [data-session-circle] {
|
|
290
|
-
position: relative; display: grid; place-items: center; flex: 0 0 28px;
|
|
291
|
-
width: 28px; height: 28px; padding: 0; border-radius: 50%;
|
|
292
|
-
border: 1px solid hsl(var(--opencx-border));
|
|
293
|
-
background: transparent; color: hsl(var(--opencx-muted-foreground));
|
|
294
|
-
font: 11px ui-sans-serif, system-ui, sans-serif; font-variant-numeric: tabular-nums;
|
|
295
|
-
cursor: pointer;
|
|
296
|
-
}
|
|
297
|
-
[data-companion-session-circles] [data-session-circle][aria-pressed="true"] {
|
|
298
|
-
border-color: hsl(var(--opencx-primary) / .45);
|
|
299
|
-
background: hsl(var(--opencx-primary) / .08);
|
|
300
|
-
color: hsl(var(--opencx-foreground));
|
|
301
|
-
}
|
|
302
|
-
@media (hover: hover) and (pointer: fine) {
|
|
303
|
-
[data-companion-session-circles] > button:hover,
|
|
304
|
-
[data-companion-session-circles] [data-session-item]:hover [data-session-circle] { background: hsl(var(--opencx-muted)); color: hsl(var(--opencx-foreground)); }
|
|
305
|
-
}
|
|
306
|
-
[data-companion-session-circles] button:focus-visible { outline: 2px solid hsl(var(--opencx-ring)); outline-offset: 2px; }
|
|
307
|
-
[data-companion-session-circles] > button:disabled { opacity: .4; cursor: default; }
|
|
308
|
-
[data-companion-session-circles] [data-session-item] { position: relative; display: flex; align-items: center; width: 36px; height: 32px; flex-shrink: 0; }
|
|
309
|
-
[data-companion-session-circles] [data-session-close] {
|
|
310
|
-
position: absolute; inset-inline-end: 0; top: -1px; z-index: 1;
|
|
311
|
-
width: 16px; height: 16px; display: grid; place-items: center; padding: 0;
|
|
312
|
-
border: 1px solid hsl(var(--opencx-border) / .7); border-radius: 50%;
|
|
313
|
-
background: hsl(var(--opencx-background)); color: hsl(var(--opencx-muted-foreground)); cursor: pointer;
|
|
314
|
-
}
|
|
315
|
-
@media (hover: hover) and (pointer: fine) {
|
|
316
|
-
[data-companion-session-circles] [data-session-close] { opacity: 0; pointer-events: none; }
|
|
317
|
-
[data-companion-session-circles] [data-session-item]:hover [data-session-close],
|
|
318
|
-
[data-companion-session-circles] [data-session-item]:focus-within [data-session-close] { opacity: 1; pointer-events: auto; }
|
|
319
|
-
[data-companion-session-circles] [data-session-close]:hover { color: hsl(var(--opencx-foreground)); }
|
|
320
|
-
}
|
|
321
|
-
@media (pointer: coarse) {
|
|
322
|
-
[data-companion-session-circles] [data-session-item] { width: 42px; }
|
|
323
|
-
[data-companion-session-circles] [data-session-close] { width: 24px; height: 24px; top: -3px; }
|
|
324
|
-
[data-companion-session-circles] [data-session-close] svg { width: 12px; height: 12px; }
|
|
325
|
-
}
|
|
326
|
-
[data-companion-session-circles] > button[data-new-session] { border-style: dashed; }
|
|
327
|
-
[data-companion-session-circles] [data-session-working] {
|
|
328
|
-
position: absolute; inset: -1px; color: hsl(var(--opencx-primary));
|
|
329
|
-
animation: opencx-session-spin 1.2s linear infinite;
|
|
330
|
-
}
|
|
331
|
-
@keyframes opencx-session-spin { to { transform: rotate(360deg); } }
|
|
332
|
-
@media (prefers-reduced-motion: reduce) { [data-companion-session-circles] [data-session-working] { animation: none; } }
|
|
333
|
-
`}),g.map(v=>r.jsx(Of,{chat:v,number:v.id,selected:v.id===s,interactive:n,portalTarget:f,onSelect:()=>_(v.id),onClose:N=>y(v.id,N)},v.id)),b>0&&r.jsxs(V,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","aria-label":m("companion_chats"),"aria-haspopup":"menu","aria-expanded":h.open,tabIndex:n?0:-1,onPointerEnter:v=>h.hover(v.currentTarget),onPointerLeave:h.leave,onClick:v=>{v.stopPropagation(),h.toggle(v.currentTarget,v.detail>0)},children:[S&&r.jsx(T.LoaderCircleIcon,{size:28,"aria-hidden":!0,"data-session-working":""}),r.jsxs("span",{"aria-hidden":!0,children:["+",b]})]}),r.jsx(V,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-new-session":"","aria-label":m("new_conversation"),disabled:!d,tabIndex:n?0:-1,onClick:v=>{v.stopPropagation(),_()},children:r.jsx(T.PlusIcon,{size:14,"aria-hidden":!0})}),h.anchor&&f&&r.jsx(oo,{picker:h,portalTarget:f,placement:"above",onSelected:e})]})})}function Lf({panelOpen:e,isOpen:t,setIsOpen:n,onOpen:o,onClose:s}){const i=u.useRef(t),a=u.useRef({onOpen:o,onClose:s});a.current={onOpen:o,onClose:s},u.useEffect(()=>{i.current=e,n(e)},[e,n]),u.useEffect(()=>{t!==i.current&&(i.current=t,t?a.current.onOpen():a.current.onClose())},[t])}function jo({transcriptVisible:e=!0}){return C.useUnreadViewing({transcriptVisible:e}),null}const mt="data-opencx-app-frame",Df="data-opencx-app-frame-style",Xt="data-opencx-sidebar-open",An="data-opencx-frame-no-anim",Gt="data-opencx-fixed-fit",Co="--opencx-sidebar-w",Ct=Id;let nt=null,Nt=null,Ts=0;const Wt=new Map,As={setOpen:()=>{},setWidth:()=>{},setAnimated:()=>{},release:()=>{}};function Ff(){let e,t;return Wt.forEach(n=>{(!e||n.order>e.order)&&(e=n),n.open&&(!t||n.order>t.order)&&(t=n)}),t??e}function rr(){const e=Ff();if(!e||!nt)return;nt.textContent=Hf(e.canvas,e.side,e.pageBackground);const t=document.documentElement;e.open?t.setAttribute(Xt,""):t.removeAttribute(Xt),e.animated?t.removeAttribute(An):t.setAttribute(An,""),t.style.setProperty(Co,`${e.width}px`)}function Is(e){getComputedStyle(e).position==="fixed"&&e.setAttribute(Gt,"");for(const t of Array.from(e.querySelectorAll("*")))getComputedStyle(t).position==="fixed"&&t.setAttribute(Gt,"")}function Hf(e,t,n){const[o,s]=t==="left"?["right","left"]:["left","right"];return`
|
|
334
|
-
html[${mt}] {
|
|
335
|
-
overflow: hidden !important;
|
|
336
|
-
background: ${e} !important;
|
|
337
|
-
}
|
|
338
|
-
html[${mt}] body {
|
|
339
|
-
position: fixed !important;
|
|
340
|
-
inset: 0 !important;
|
|
341
|
-
margin: 0 !important;
|
|
342
|
-
width: auto !important;
|
|
343
|
-
height: auto !important;
|
|
344
|
-
min-width: 0 !important;
|
|
345
|
-
min-height: 0 !important;
|
|
346
|
-
max-width: none !important;
|
|
347
|
-
max-height: none !important;
|
|
348
|
-
overflow: auto !important;
|
|
349
|
-
contain: strict !important;
|
|
350
|
-
background: ${n} !important;
|
|
351
|
-
border-radius: 0 !important;
|
|
352
|
-
/* Transparent ring+shadow, NOT none — none can't interpolate */
|
|
353
|
-
box-shadow: 0 0 0 1px rgba(0,0,0,0), 0 10px 24px -6px rgba(0,0,0,0) !important;
|
|
354
|
-
}
|
|
355
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
356
|
-
html[${mt}] body {
|
|
357
|
-
transition:
|
|
358
|
-
top 0.3s ${Ct}, bottom 0.3s ${Ct},
|
|
359
|
-
left 0.3s ${Ct}, right 0.3s ${Ct},
|
|
360
|
-
border-radius 0.3s ${Ct}, box-shadow 0.3s ${Ct} !important;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
html[${An}] body { transition: none !important; }
|
|
364
|
-
html[${mt}] body [${Gt}] {
|
|
365
|
-
max-width: 100% !important;
|
|
366
|
-
max-height: 100% !important;
|
|
367
|
-
}
|
|
368
|
-
html[${Xt}] body {
|
|
369
|
-
top: ${Ae}px !important;
|
|
370
|
-
bottom: ${Ae}px !important;
|
|
371
|
-
${o}: ${Ae}px !important;
|
|
372
|
-
${s}: calc(var(${Co}, ${yo}px) + ${Ae*2}px) !important;
|
|
373
|
-
border-radius: ${tt.sidebar}px !important;
|
|
374
|
-
box-shadow: 0 0 0 1px rgba(0,0,0,0.06), 0 10px 24px -6px rgba(0,0,0,0.10) !important;
|
|
375
|
-
}
|
|
376
|
-
@media (max-width: ${rc}px) {
|
|
377
|
-
html[${Xt}] body {
|
|
378
|
-
inset: 0 !important;
|
|
379
|
-
border-radius: 0 !important;
|
|
380
|
-
box-shadow: 0 0 0 1px rgba(0,0,0,0), 0 10px 24px -6px rgba(0,0,0,0) !important;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
`}function Wf({canvas:e,side:t,pageBackground:n}){if(typeof document>"u")return As;const o=document.documentElement;if(!nt&&o.hasAttribute(mt))return As;if(!nt){const d=document.createElement("style");d.setAttribute(Df,""),document.head.appendChild(d);const l=window.scrollY;o.setAttribute(mt,""),document.body.scrollTop=l,Is(document.body),Nt=new MutationObserver(m=>{for(const p of m)for(const h of Array.from(p.addedNodes))h instanceof Element&&Is(h)}),Nt.observe(document.body,{childList:!0,subtree:!0}),nt=d}const s=Symbol("opencx-app-frame-owner"),i={canvas:e,side:t,pageBackground:n,open:!1,width:yo,animated:!0,order:++Ts};Wt.set(s,i),rr();let a=!1;const c=d=>{if(a)return;const l=Wt.get(s);l&&(d(l),rr())};return{setOpen(d){c(l=>{l.open=d,d&&(l.order=++Ts)})},setWidth(d){c(l=>{l.width=d})},setAnimated(d){c(l=>{l.animated=d})},release(){a||(a=!0,Wt.delete(s),Wt.size===0?Uf():rr())}}}function Uf(){if(!nt)return;const e=document.body.scrollTop,t=document.documentElement;t.removeAttribute(mt),t.removeAttribute(Xt),t.removeAttribute(An),t.style.removeProperty(Co),Nt==null||Nt.disconnect(),Nt=null;for(const n of Array.from(document.querySelectorAll(`[${Gt}]`)))n.removeAttribute(Gt);nt.remove(),nt=null,window.scrollTo({top:e})}let Ht=0,or="";function Bf(){if(typeof document>"u")return()=>{};Ht===0&&(or=document.body.style.overflow,document.body.style.overflow="hidden"),Ht+=1;let e=!1;return()=>{e||(e=!0,Ht=Math.max(0,Ht-1),Ht===0&&(document.body.style.overflow=or,or=""))}}function qf(e,t){return e[t]??""}function Vf({companion:e,layout:t,state:n,region:o,sidebarSide:s,sidebarMode:i,cssVars:a,storage:c,resizeLabel:d}){var I,H,$,q,X,B;const l=Math.max(0,((I=e==null?void 0:e.sidebar)==null?void 0:I.minWidth)??tc),m=Math.max(l,((H=e==null?void 0:e.sidebar)==null?void 0:H.maxWidth)??hf),[p,h]=u.useState(()=>{var F;return dt(((F=e==null?void 0:e.sidebar)==null?void 0:F.width)??yo,l,m)}),[f,x]=u.useState(!1),g=u.useRef(null);u.useEffect(()=>{h(F=>{var Z;return dt(((Z=e==null?void 0:e.sidebar)==null?void 0:Z.width)??F,l,m)})},[($=e==null?void 0:e.sidebar)==null?void 0:$.width,m,l]),u.useEffect(()=>{var Z;let F=!1;if(!(!c||((Z=e==null?void 0:e.sidebar)==null?void 0:Z.width)!==void 0))return c.getCompanionSidebarWidth().then(re=>{F||re===null||h(dt(re,l,m))}).catch(()=>{}),()=>{F=!0}},[(q=e==null?void 0:e.sidebar)==null?void 0:q.width,m,l,c]);const j=u.useCallback(F=>dt(s==="left"?F:window.innerWidth-F,l,m),[m,l,s]),b=u.useCallback(F=>{var Z;F.currentTarget.setPointerCapture(F.pointerId),x(!0),(Z=g.current)==null||Z.setAnimated(!1)},[]),S=u.useCallback(F=>{F.currentTarget.hasPointerCapture(F.pointerId)&&h(j(F.clientX))},[j]),w=u.useCallback(F=>{var re;const Z=j(F.clientX);F.currentTarget.hasPointerCapture(F.pointerId)&&F.currentTarget.releasePointerCapture(F.pointerId),h(Z),x(!1),(re=g.current)==null||re.setAnimated(!0),c==null||c.setCompanionSidebarWidth(Z).catch(()=>{})},[c,j]),_=u.useCallback(F=>{var Z;F.currentTarget.hasPointerCapture(F.pointerId)&&F.currentTarget.releasePointerCapture(F.pointerId),x(!1),(Z=g.current)==null||Z.setAnimated(!0)},[]),y=u.useCallback(F=>{let Z=null;if(F.key==="Home"&&(Z=l),F.key==="End"&&(Z=m),F.key==="ArrowLeft"||F.key==="ArrowRight"){const re=F.key===(s==="left"?"ArrowRight":"ArrowLeft");Z=dt(p+(re?16:-16),l,m)}Z!==null&&(F.preventDefault(),h(Z),c==null||c.setCompanionSidebarWidth(Z).catch(()=>{}))},[m,l,s,p,c]),v=t==="sidebar",N=i==="docked",R=ko(o,p),M=((X=e==null?void 0:e.sidebar)==null?void 0:X.canvasColor)??ff,z=`hsl(${qf(a,"--opencx-background")})`,L=u.useRef({open:n!=="pill",width:R});L.current={open:n!=="pill",width:R},u.useEffect(()=>{if(!v||!N)return;const F=Wf({canvas:M,side:s,pageBackground:z});return g.current=F,F.setWidth(L.current.width),F.setOpen(L.current.open),()=>{g.current===F&&(g.current=null),F.release()}},[M,N,v,z,s]),u.useEffect(()=>{var F;v&&N&&((F=g.current)==null||F.setWidth(R))},[R,N,v]),u.useEffect(()=>{var F;v&&N&&((F=g.current)==null||F.setOpen(n!=="pill"))},[N,v,n]);const O=n==="chat"&&t==="fullscreen",U=((B=e==null?void 0:e.fullscreen)==null?void 0:B.lockScroll)!==!1;u.useEffect(()=>{if(!(!O||!U))return Bf()},[O,U]);const E=u.useMemo(()=>({role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":d,"aria-valuemin":l,"aria-valuemax":m,"aria-valuenow":p,onPointerDown:b,onPointerMove:S,onPointerUp:w,onPointerCancel:_,onKeyDown:y}),[m,l,y,b,S,_,w,d,p]);return{sidebarWidth:p,sidebarResizing:f,resizeHandleProps:E}}const Yf={width:1440,height:900};function zs(){return typeof window>"u"?Yf:{width:window.innerWidth,height:window.innerHeight}}function Xf(){const[e,t]=u.useState(zs),[n,o]=u.useState(null),s=u.useRef(null),i=u.useCallback(c=>{var l;if((l=s.current)==null||l.disconnect(),s.current=null,!c)return;const d=new ResizeObserver(()=>{o(c.offsetWidth)});d.observe(c),s.current=d},[]);u.useEffect(()=>{function c(){t(zs())}return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),u.useEffect(()=>()=>{var c;(c=s.current)==null||c.disconnect(),s.current=null},[]);const a=Math.min(n??cf,Math.max(0,e.width-ec));return{region:e,dockWidth:a,dockContentRef:i}}function Gf({storage:e,state:t,layout:n,viewportWidth:o,currentWidth:s,restingWidth:i,shouldReduceMotion:a}){const[c,d]=u.useState(0),l=W.useMotionValue(0),m=u.useRef(!1);u.useEffect(()=>{let j=!1;if(e)return e.getCompanionPillOffsetX().then(b=>{j||b===null||d(b)}).catch(()=>{}),()=>{j=!0}},[l,e]),u.useEffect(()=>{const j=a?be:At;if(t==="pill"){const S=Math.max(0,o/2-i/2-tr),w=dt(c,-S,S);Math.abs(l.get())>S?l.set(w):W.animate(l,w,j);return}if(t==="chat"&&(n==="fullscreen"||n==="sidebar")){W.animate(l,0,j);return}const b=Math.max(0,o/2-s/2-tr);W.animate(l,dt(c,-b,b),j)},[s,l,n,c,i,a,t,o]);const p=Math.max(0,o/2-i/2-tr),h=u.useMemo(()=>({left:-p,right:p,top:0,bottom:0}),[p]),f=u.useCallback(()=>{m.current=!0},[]),x=u.useCallback(()=>{const j=l.get();d(b=>b===j?b:j),e==null||e.setCompanionPillOffsetX(j).catch(()=>{}),requestAnimationFrame(()=>{m.current=!1})},[l,e]),g=u.useCallback(()=>m.current,[]);return{dragX:l,dragConstraints:h,onDragStart:f,onDragEnd:x,shouldIgnoreLaunch:g}}function Kf({state:e,layout:t,sidebarMode:n,isPageMarkModeArmed:o}){return e==="pill"||o?!1:!(t==="sidebar"&&n==="docked")}const Zf=96,Ms=eo({transparent:!0});function Jf(){var Eo,To,Ao;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{openChats:n,activeId:o}=C.useCompanionChats(),s=n.length,{count:i}=C.useUnread(),a=n.filter(Q=>Q.working).length,{widgetCtx:c,contentIframeRef:d}=C.useWidget(),{companion:l,assets:m,customComponents:p,initialQuestions:h}=C.useConfig(),{theme:f,cssVars:x}=ue(),{t:g,dir:j}=Y(),{sessionState:b}=C.useSessions(),{messagesState:S}=C.useMessages(),{isArmed:w}=fo(),{region:_,dockWidth:y,dockContentRef:v}=Xf(),[N,R]=u.useState(e?"chat":"pill"),{layout:M,setLayout:z,setLayoutPreference:L,allowedLayouts:O,defaultLayout:U,sidebarSide:E,sidebarMode:I}=C.useWidgetLayout(),[H,$]=u.useState(Zf),{sidebarWidth:q,sidebarResizing:X,resizeHandleProps:B}=Vf({companion:l,layout:M,state:N,region:_,sidebarSide:E,sidebarMode:I,cssVars:x,storage:c.storageCtx,resizeLabel:g("companion_resize_chat")}),F=W.useReducedMotion(),Z=X?{duration:0}:F?be:At,re=Mn(),ae=u.useRef(null),fe=u.useRef(!1),oe=N==="pill",ke=N==="input"&&S.messages.length===0&&(h==null?void 0:h.some(Q=>Q.trim().length>0))===!0,[D,te]=u.useState(0),J=s>0,ne=no(),pe=u.useRef(ne.close);pe.current=ne.close,u.useEffect(()=>{(!oe||!J)&&pe.current(!0)},[oe,J]);const ce=p==null?void 0:p.widgetTrigger,se=!!ce,Le=(l==null?void 0:l.pillBackground)??"hsl(var(--opencx-primary))",De=(l==null?void 0:l.icon)??((Eo=m==null?void 0:m.widgetTrigger)==null?void 0:Eo.openIcon),de=f.widgetTrigger.offset.bottom,qe=$n(),st=Ln(i),Ve=Ki(),Fe=st?`${Ve} · ${st}`:Ve,Ye=!!((To=b.session)!=null&&To.id),Xe=Ye?g("follow_up_placeholder"):void 0,xe=(l==null?void 0:l.pillLabel)??(l==null?void 0:l.placeholder)??Xe??g("write_a_message_placeholder"),Re=(l==null?void 0:l.pillLabelDisplay)??"always",He=(l==null?void 0:l.placeholder)??Xe??g("write_a_message_placeholder"),[Fn,an]=u.useState(!1),we=oe&&!se&&Re!=="never"&&(Re==="always"||re&&Fn),Pt=oc(_,l==null?void 0:l.compact),Ot=M==="sidebar",wt=xf({layout:M,region:_,sidebarWidth:q,bottomOffset:de,compact:l==null?void 0:l.compact}),cn=N==="chat"?wt.width:Pt,Hn=wt.height,{centerX:Wn,bottom:Un}=bf({isChatOpen:N==="chat",layout:M,region:_,sidebarWidth:q,sidebarSide:E,bottomOffset:de}),je=u.useMemo(()=>N==="pill"?we?{width:y,height:af,borderRadius:tt.pill}:{width:et,height:et,borderRadius:tt.pill}:N==="input"?{width:Pt,height:H,borderRadius:tt.input}:wt,[N,we,y,Pt,wt,H]),ln=N==="pill"&&we&&Re==="hover"?(j==="rtl"?-1:1)*(y-et)/2:0,{dragX:K,dragConstraints:ge,onDragStart:$t,onDragEnd:We,shouldIgnoreLaunch:Pe}=Gf({storage:c.storageCtx,state:N,layout:M,viewportWidth:_.width,currentWidth:je.width,restingWidth:we?y:et,shouldReduceMotion:F}),at=u.useCallback(()=>{var Ft;const Q=c.routerCtx.state.get().screen,le=!!((Ft=c.sessionCtx.sessionState.get().session)!=null&&Ft.id);R(Q==="welcome"||le?"chat":"input")},[c]),Ne=u.useCallback(()=>{if(!Pe()){if(pe.current(!0),M==="sidebar"){R("chat");return}at()}},[at,M,Pe]),vt=u.useCallback(()=>{if(M==="fullscreen"&&U!=="fullscreen"){z(U);return}if(M==="sidebar"){R("pill");return}R(Q=>{var le;return Q==="chat"&&((le=c.sessionCtx.sessionState.get().session)!=null&&le.id)?"input":"pill"})},[U,M,z,c]),it=u.useCallback(()=>{const Q=nf({panelLayout:M,previousLayout:kt.current,defaultLayout:U,allowedLayouts:O});if(Q.kind==="layout"){z(Q.layout);return}R("pill")},[O,U,M,z]),dn=u.useCallback(()=>{R("pill")},[]);u.useEffect(()=>{N==="chat"&&(fe.current=!0)},[N]),u.useEffect(()=>{N!=="chat"&&fe.current&&M==="fullscreen"&&U!=="fullscreen"&&z(U)},[U,M,z,N]);const Lt=N==="chat"&&M==="fullscreen";Lf({panelOpen:N!=="pill",isOpen:e,setIsOpen:t,onOpen:at,onClose:dn}),u.useEffect(()=>{if(!Kf({state:N,layout:M,sidebarMode:I,isPageMarkModeArmed:w}))return;function Q(le){if(sf(le))return;const Ft=ae.current;Ft&&(le.composedPath().includes(Ft)||vt())}return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[vt,N,M,I,w]);const yt=((Ao=S.messages.findLast(Q=>Q.type==="USER"))==null?void 0:Ao.id)??null,me=u.useRef(null);u.useEffect(()=>{N==="input"&&(me.current=yt)},[N]),u.useEffect(()=>{N==="input"&&yt!==me.current&&(c.routerCtx.state.get().screen!=="chat"&&c.routerCtx.state.setPartial({screen:"chat"}),R("chat"))},[yt,N,c]);const Dt=u.useCallback(()=>{var Q;c.routerCtx.state.get().screen!=="chat"&&((Q=c.sessionCtx.sessionState.get().session)!=null&&Q.id)&&c.routerCtx.state.setPartial({screen:"chat"}),R("chat")},[c]),un=u.useCallback(Q=>{var le;O.includes(Q)&&(Q==="fullscreen"&&c.routerCtx.state.get().screen==="sessions"&&c.routerCtx.toChatScreen((le=c.sessionCtx.sessionState.get().session)==null?void 0:le.id),L(Q))},[O,c,L]),Bn=O.find(Q=>Q!=="fullscreen"),kt=u.useRef(Bn??U);u.useEffect(()=>{M!=="fullscreen"&&O.includes(M)?kt.current=M:(kt.current==="fullscreen"||!O.includes(kt.current))&&(kt.current=Bn??U)},[O,U,Bn,M]);const pn=u.useCallback(()=>{if(!O.includes("fullscreen"))return;if(M!=="fullscreen"){un("fullscreen");return}const Q=kt.current;Q!=="fullscreen"&&O.includes(Q)&&un(Q)},[O,M,un]);u.useEffect(()=>{function Q(le){tf(le,{state:N,onToggleFullscreen:pn})}return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[pn,N]);const qn=On();return qn?Kt.createPortal(r.jsxs(r.Fragment,{children:[r.jsx(jo,{transcriptVisible:N==="chat"}),ce&&Zi(ce,e,t,i),oe&&ne.anchor&&!se&&r.jsx(oo,{placement:"above",picker:ne,portalTarget:qn,onSelected:()=>R("chat")}),r.jsx(W.motion.div,{"aria-hidden":!0,style:{position:"fixed",inset:0,background:"transparent",zIndex:f.widgetContentContainer.zIndex,pointerEvents:Lt?"auto":"none"},initial:!1,animate:{opacity:Lt?1:0},transition:ze}),r.jsxs(W.motion.div,{ref:ae,style:{...x,position:"fixed",x:K,translateX:"-50%",zIndex:f.widgetContentContainer.zIndex,visibility:se&&oe?"hidden":void 0},initial:!1,animate:{left:Wn,bottom:Un},drag:oe&&!se&&!ne.open?"x":!1,dragMomentum:!1,dragElastic:.15,dragConstraints:ge,onDragStart:$t,onDragEnd:We,transition:Z,children:[ke&&r.jsx("div",{"data-companion-starters":!0,style:{position:"absolute",bottom:"calc(100% + 12px)",left:"50%",transform:"translateX(-50%)",width:cn,height:D},children:r.jsx(Es,{title:"Suggested questions",initialContent:Ms,style:{width:"100%",height:"100%",border:0,background:"transparent"},children:r.jsx(rf,{onHeightChange:te,onDismiss:it,onToggleFullscreen:pn,maxHeight:Math.max(48,_.height-je.height-de-32)})})}),r.jsxs(W.motion.div,{onPointerEnter:oe&&!se?Q=>{an(!0);const le=Q.currentTarget.querySelector("[data-companion-count-trigger]");le&&!Pe()&&ne.hover(le)}:void 0,onPointerLeave:()=>{an(!1),ne.leave()},style:{position:"relative",overflow:"hidden",transformOrigin:"center bottom",cursor:oe&&!se?we?"pointer":"grab":"default",background:"hsl(var(--opencx-background))"},initial:!1,animate:{x:ln,width:je.width,height:je.height,borderTopLeftRadius:je.borderRadius,borderTopRightRadius:je.borderRadius,borderBottomLeftRadius:je.borderRadius,borderBottomRightRadius:je.borderRadius,boxShadow:oe?we?Md:zd:N==="input"?Rd:Pd},whileHover:oe&&!se&&re&&!F?{scale:we?1.01:1.12}:void 0,whileTap:oe&&!se?{scale:we?.995:.92}:void 0,transition:Z,children:[oe&&!se&&r.jsx("button",{type:"button","data-companion-launcher":"",onClick:Ne,"aria-label":Fe,"aria-expanded":!1,style:{position:"absolute",inset:0,zIndex:1,border:0,padding:0,background:"transparent",cursor:"pointer",borderRadius:"inherit"}}),!se&&r.jsx(Pf,{visible:oe,docked:we,label:xe,sessions:s>0?r.jsx($f,{interactive:oe&&we,onSelected:()=>R("chat"),onLastClosed:()=>{requestAnimationFrame(()=>{var Q,le;(le=(Q=ae.current)==null?void 0:Q.querySelector("[data-companion-launcher]"))==null||le.focus({preventScroll:!0})})}}):void 0,activeCount:s,countLabel:`${g("companion_chats")} · ${g("companion_active_chats",{count:s})}${a?` · ${g("companion_working_chats",{count:a})}`:""}`,pickerOpen:ne.open,onOpenChats:(Q,le)=>{Pe()||ne.toggle(Q,le)},working:a>0,icon:De,pillBackground:Le,dir:j,measureRef:v,unreadCount:qe===!1?0:i,unreadShowCount:qe==="count"}),N!=="pill"&&r.jsx(W.motion.div,{style:{position:"absolute",bottom:0,left:"50%",translateX:"-50%",width:cn,height:Hn},initial:{opacity:0},animate:{opacity:1,transition:{...be,delay:F?0:.1}},children:r.jsx(Es,{iframeRef:d,initialContent:Ms,style:{width:"100%",height:"100%",overflow:"hidden",backgroundColor:"transparent",boxSizing:"border-box",borderWidth:"0px"},children:r.jsx(If,{state:N==="chat"?"chat":"input",layout:M,shellRadius:je.borderRadius,onMinimize:vt,onDismiss:it,onToggleFullscreen:pn,onSelectLayout:un,onExpand:Dt,canExpand:Ye,placeholder:He,hideAttachTools:((l==null?void 0:l.quickAskTools)??"history-only")==="history-only",onInputHeightChange:$},o)})}),Ot&&N==="chat"&&r.jsx("div",{...B,style:{position:"absolute",top:0,bottom:0,...E==="left"?{right:0}:{left:0},width:8,cursor:"ew-resize",zIndex:2}})]})]})]}),qn):null}function Qf(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,s=e.ownerDocument,i=s.documentElement.clientWidth||window.innerWidth,a=s.documentElement.clientHeight||window.innerHeight;if(n<0||o<0||n>i||o>a||typeof s.elementFromPoint!="function")return!0;const c=s.elementFromPoint(n,o);return c?c===e||e.contains(c)||c.contains(e):!0}function Pr(e){const t=Si(e);if(!t)return{ok:!1,reason:"gone"};const{element:n}=t,o=Tr(n);if(o)return{ok:!1,reason:"off-limits",detail:om[o]};const s=typeof n.checkVisibility=="function"?n.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}):n.isConnected,i=n.getBoundingClientRect();return!s||i.width===0||i.height===0?{ok:!1,reason:"hidden"}:Qf(n)?t.isCurrent?{ok:!0,element:n}:{ok:!1,reason:"gone"}:{ok:!1,reason:"covered"}}function Rs(e,t){var s;const n=e instanceof HTMLInputElement?HTMLInputElement.prototype:e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:e instanceof HTMLSelectElement?HTMLSelectElement.prototype:null;if(!n)return!1;const o=(s=Object.getOwnPropertyDescriptor(n,"value"))==null?void 0:s.set;return o?(o.call(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),!0):!1}function Or(e,t){if(!(e instanceof HTMLSelectElement)||t===void 0)return null;const n=Array.from(e.options),o=n.filter(i=>i.value===t||i.label.trim().toLowerCase()===t.trim().toLowerCase()),[s]=o;return o.length!==1||!s||s.disabled||s.parentElement instanceof HTMLOptGroupElement&&s.parentElement.disabled||n.filter(i=>i.value===s.value).length!==1?null:s}function wn(e,t,n){const o=e.ownerDocument,s=h=>h.contains(e)||e.contains(h)||(e.getAttribute("aria-controls")??"").split(/\s+/).some(f=>{const x=o.getElementById(f);return x!==null&&(h.contains(x)||x.contains(h))}),i=Array.from(o.querySelectorAll('[aria-busy="true"]')).filter(h=>!Me(h)&&!s(h)),a=h=>{for(let f=i.length-1;f>=0;f--)s(i[f])&&i.splice(f,1);return i.some(f=>f.contains(h))};let c=!1,d=performance.now(),l;const m=new MutationObserver(h=>{h.some(x=>{const g=x.target instanceof Element?x.target:x.target.parentElement;return g!==null&&!on(g)&&!a(g)})&&(c=!0,d=performance.now())});m.observe(o.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const p=()=>{clearTimeout(l),m.disconnect()};return{settle:()=>new Promise(h=>{const f=performance.now()+t,x=()=>{if(!n()){p(),h({mutated:c,loading:!1});return}const g=Array.from(o.querySelectorAll('[aria-busy="true"]')).some(b=>!a(b)&&!Me(b)),j=performance.now();j>=f||!g&&j-d>=100?(p(),h({mutated:c,loading:g})):l=setTimeout(x,Math.min(100,f-j))};l=setTimeout(x,Math.min(100,t))}),cancel:p}}function eg(e){if(e.tagName.toLowerCase()==="input"){const t=(e.getAttribute("type")??"text").toLowerCase();if(yi.has(t))return"Password and file fields are never filled or clicked by the agent."}return e.ownerDocument!==document?"That control is inside another site embedded in this page.":null}async function tg(e){try{return await ng(e)}catch{return{outcome:"unsupported",detail:"That could not be done on this page."}}}async function ng({ref:e,action:t,value:n,settleMs:o=qp,consentIsCurrent:s=()=>!0,observationIsCurrent:i=()=>!0}){var x;if(!s())return{outcome:"declined"};const a=Pr(e);if(!a.ok)return a.reason==="off-limits"?{outcome:"unsupported",detail:a.detail}:{outcome:a.reason};const c=a.element,d=eg(c);if(d)return{outcome:"unsupported",detail:d};const l=c.ownerDocument,m=l.location.href;let p,h,f=!1;try{switch(t){case"click":{p=wn(c,o,i);const S=Ss(c,s);if(S==="not-started")return p.cancel(),{outcome:"declined"};f=S==="interrupted";break}case"fill":{if(n===void 0)return{outcome:"unsupported",detail:"No value was given to type."};if(p=wn(c,o,i),(x=c.focus)==null||x.call(c),!s()){f=!0;break}if(!Rs(c,n))return p.cancel(),{outcome:"unsupported",detail:"That control is not something text can be typed into."};break}case"select":{if(!(c instanceof HTMLSelectElement))return{outcome:"unsupported",detail:"That control is not a dropdown."};if(n===void 0)return{outcome:"unsupported",detail:"No option was given to choose."};const S=Or(c,n);if(!S)return{outcome:"no_change",detail:"That option is not in the list or cannot be selected unambiguously."};p=wn(c,o,i),h=S.value,Rs(c,S.value);break}case"check":case"uncheck":{const S=t==="check",w=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null,_=c.getAttribute("aria-checked");if(!w&&_===null)return{outcome:"unsupported",detail:"That control is not a checkbox or switch."};if((w?w.checked:_==="true")===S)return{outcome:"no_change",detail:`It is already ${S?"on":"off"}.`};p=wn(c,o,i);const v=Ss(c,s);if(v==="not-started")return p.cancel(),{outcome:"declined"};f=v==="interrupted";break}}const{mutated:g,loading:j}=await(p==null?void 0:p.settle())??{mutated:!1,loading:!1};if(f)return{outcome:"no_change",detail:(g||l.location.href!==m?"The page changed. ":"")+"The requested action was interrupted after input events were dispatched. Its final result is unknown. Do not repeat it automatically."};const b=j?"The page is still loading. The action was dispatched; its final result is unknown. Do not repeat it automatically.":void 0;if(t==="fill"||t==="select"){const S=c instanceof HTMLInputElement||c instanceof HTMLTextAreaElement||c instanceof HTMLSelectElement?c.value:null;return t==="fill"&&S!==n?{outcome:"no_change",detail:"The field did not keep what was typed."}:t==="select"&&S!==h?{outcome:"no_change",detail:"The dropdown did not keep the selected option."}:{outcome:"done",...b?{detail:b}:{}}}if(t==="check"||t==="uncheck"){const S=t==="check",w=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null;return(w?w.checked:c.getAttribute("aria-checked")==="true")===S?{outcome:"done",...b?{detail:b}:{}}:{outcome:"no_change",detail:"It did not change."}}return g||l.location.href!==m?{outcome:"done",...b?{detail:b}:{}}:{outcome:"no_change",detail:b??"The control was clicked and nothing on the page changed during observation. Its final result is unknown. Do not repeat it automatically."}}finally{p==null||p.cancel()}}const rg="cubic-bezier(0.32, 0.72, 0, 1)",sr=260,og=1600,sg=180,Ps=240,Os=.13,ag=e=>e*e*e*(10-15*e+6*e*e);function ig(e,t,n,o){const s=1-o;return{x:s*s*e.x+2*s*o*t.x+o*o*n.x,y:s*s*e.y+2*s*o*t.y+o*o*n.y}}function cg(e,t,n=48){const o=t.x-e.x,s=t.y-e.y,i=Math.hypot(o,s)||1,a={x:e.x+o/2-s/i*i*Os,y:e.y+s/2+o/i*i*Os},c=[];for(let d=0;d<=n;d+=1){const l=ig(e,a,t,ag(d/n));c.push({transform:`translate(${l.x-jn}px, ${l.y-Cn}px)`})}return c}const jn=2,Cn=1.7,lg="M2 1.7 L9.6 8 L6.5 8.4 L7.7 11 L6.3 11.6 L5.1 9 L2.6 10.6 Z";function So(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const $s=e=>new Promise(t=>{window.setTimeout(t,So()?0:e)});let ht=null,$r;const dg=4e3;function In(){clearTimeout($r),ht==null||ht.release(),ht=null,document.querySelectorAll("[data-opencx-cursor]").forEach(e=>e.remove())}function Lr(){clearTimeout($r),$r=setTimeout(In,dg)}function ug(e){if(ht)return Lr(),ht;try{In();const t=document.createElement("div");t.setAttribute("data-opencx-overlay",""),t.setAttribute("data-opencx-cursor",""),t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"fixed",inset:"0",overflow:"hidden",pointerEvents:"none",zIndex:"2147483646",contain:"strict"});const n=document.createElement("div");n.setAttribute("data-opencx-cursor-tip",""),Object.assign(n.style,{position:"absolute",left:"0",top:"0",width:"14px",height:"14px",pointerEvents:"none",opacity:"0",transition:`opacity ${sr}ms ease`,willChange:"transform"}),t.appendChild(n),n.innerHTML=`<svg viewBox="0 0 14 14" width="14" height="14" style="display:block">
|
|
384
|
-
<path d="${lg}" fill="currentColor" stroke="currentColor" stroke-width="1.7"
|
|
385
|
-
stroke-linejoin="round" stroke-linecap="round" paint-order="stroke"
|
|
386
|
-
style="transition: transform ${Ps}ms ${rg}; transform-origin: ${jn}px ${Cn}px"/>
|
|
387
|
-
</svg>`;const o=e??{x:window.innerWidth-40,y:window.innerHeight-40};let s=o;n.style.transform=`translate(${o.x-jn}px, ${o.y-Cn}px)`,document.documentElement.appendChild(t);const i=n.querySelector("path");n.offsetWidth,n.style.opacity="1";let a=!1;const c={async moveTo(d,l){if(a)return;const m=`translate(${d-jn}px, ${l-Cn}px)`;if(So()||typeof n.animate!="function"){n.style.transform=m;return}n.style.transition=`opacity ${sr}ms ease`;const p=cg(s,{x:d,y:l});await n.animate(p,{duration:og,easing:"linear",fill:"forwards"}).finished.catch(()=>{}),!a&&(n.style.transform=m,s={x:d,y:l},await $s(sg))},async press(){a||!i||(i.style.transform="scale(0.86)",await $s(Ps),i.style.transform="")},release(){a||(a=!0,n.style.opacity="0",window.setTimeout(()=>t.remove(),sr+60))}};return ht=c,Lr(),c}catch{return null}}function pg(e){const t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}async function sc(e,{press:t=!1}={}){var o;const n=ug();if(!n)return{done:()=>{}};try{(o=e.scrollIntoView)==null||o.call(e,{behavior:So()?"auto":"smooth",block:"center",inline:"nearest"});const{x:s,y:i}=pg(e);await n.moveTo(s,i),t&&await n.press()}catch{}return{done:Lr}}const mg=k.z.object({ref:k.z.string().min(1),action:k.z.enum(Bp),value:k.z.string().max(500).optional()});function ac(e,t){const n=u.useRef({effects:e,isStreaming:t});n.current={effects:e,isStreaming:t};const o=u.useRef(!1);return u.useEffect(()=>(o.current=!0,()=>{o.current=!1}),[]),u.useCallback(s=>o.current&&n.current.isStreaming&&n.current.effects.some(i=>i.key===s),[])}const hg=200;function fg(){const{widgetCtx:e}=C.useWidget(),{pageEffects:t,replyToPageCall:n,requestPageActionConsent:o,isStreaming:s}=C.useAgentChatUi(),i=u.useRef(new Set),a=ac(t,s);return u.useEffect(()=>{const c=i.current;for(const d of t){if(d.type!=="act-on-page"||c.has(d.key))continue;for(c.add(d.key);c.size>hg;){const f=c.values().next().value;if(f===void 0)break;c.delete(f)}const l=mg.safeParse(d.input);if(!l.success){G.log.warn("act_on_page: invalid tool input",{issues:l.error.issues}),n(d.callId,"unsupported");continue}const{ref:m,action:p,value:h}=l.data;(async()=>{let f;try{const x=()=>a(d.key)&&e.features.pageContext&&e.features.clientTools&&e.features.pageActions;if(!x()){n(d.callId,"declined");return}const g=fs(m);if(!g){n(d.callId,"gone",void 0,x()?Ar():void 0);return}const j=zt(g)||"this control",b=p==="select"?Or(g,h):null;if(p==="select"&&!b){n(d.callId,"no_change","That option is unavailable or ambiguous.");return}const S=b==null?void 0:b.value,w=b==null?void 0:b.label.trim(),_=ki(g),y=()=>x()&&fs(m)===g&&_()&&j===(zt(g)||"this control")&&(!b||Or(g,h)===b&&b.value===S&&b.label.trim()===w);if(!await o({callId:d.callId,action:p,controlName:j,...p==="fill"||p==="select"?{value:h}:{},...b?{valueLabel:w||"(empty option)"}:{}})){n(d.callId,"declined");return}if(!y()){n(d.callId,"declined");return}if(f=await sc(g,{press:!0}),!y()){n(d.callId,"declined");return}const N=await tg({ref:m,action:p,value:h,consentIsCurrent:y,observationIsCurrent:x}),R=x()&&N.outcome!=="declined"&&N.outcome!=="unsupported"?Ar():null;n(d.callId,N.outcome,N.detail,R?{controls:R.controls,truncated:R.truncated}:void 0)}catch{n(d.callId,"unsupported","The page action could not be completed.")}finally{f==null||f.done()}})()}},[t,n,o,e,a]),null}const gg=["circle","box","underline","bracket","arrow"],xg=k.z.object({ref:k.z.string().min(1),label:k.z.string().optional(),type:k.z.enum(gg).optional().catch(void 0)}),bg=8e3;function wg(e,t,n){return t.display==="inline"&&e.height<=n*2.5?"underline":e.width<=220&&e.height<=80?"circle":"box"}let Ue=null;function vg(){Ue==null||Ue()}function yg(e,t,{accentColor:n="hsl(0 0% 9%)",surfaceColor:o="hsl(0 0% 9%)",foregroundColor:s="hsl(0 0% 98%)",zIndex:i=10000002,durationMs:a=bg,seed:c}={}){if(!e.isConnected)return!1;Ue==null||Ue();const d=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;e.scrollIntoView({behavior:d?"auto":"smooth",block:"center",inline:"nearest"});const l=e.getBoundingClientRect(),m=getComputedStyle(e),p=parseFloat(m.fontSize)||16,h=l.width<160&&l.height<56,f=Zs.annotate(e,{type:t.type??wg(l,m,p),color:n,strokeWidth:Math.min(3,Math.max(1.6,p*.11)),wobble:h?.6:.9,rtl:m.direction==="rtl",seed:c});let x=!1;const g=()=>{if(!x)try{f.show(),Nr(e,i)}catch(z){G.log.warn("highlight_element: mark could not be drawn",z)}},j=document.fonts;j!=null&&j.ready&&typeof j.ready.then=="function"?j.ready.then(g):g();const b=document.createElement("div");b.setAttribute("data-opencx-overlay",""),b.style.pointerEvents="none";let S=null,w=null;t.label&&(S=document.createElement("div"),S.setAttribute("data-cx-role","callout"),Object.assign(S.style,{position:"fixed",zIndex:String(i+1),background:o,color:s,font:"500 13px/1.4 system-ui, sans-serif",padding:"9px 13px",borderRadius:"11px",maxWidth:"240px",boxShadow:`0 10px 30px -8px color-mix(in srgb, ${s} 35%, transparent)`,opacity:"0",transform:d?"none":"translateY(4px)",transition:"opacity 280ms cubic-bezier(0.23, 1, 0.32, 1), transform 280ms cubic-bezier(0.23, 1, 0.32, 1)",pointerEvents:"none"}),S.textContent=t.label,w=document.createElement("div"),Object.assign(w.style,{position:"absolute",width:"10px",height:"10px",background:o,transform:"rotate(45deg)"}),S.appendChild(w),b.appendChild(S)),document.documentElement.appendChild(b);let _=0;if(S&&w){const z=S,L=w,O=()=>{const U=e.getBoundingClientRect(),E=window.innerWidth,I=U.top>90?"top":"bottom",H=Math.min(240,z.offsetWidth||240),$=Math.max(12,Math.min(U.left+U.width/2-H/2,E-H-12));z.style.left=`${$}px`,z.style.width=`${H}px`,z.style.top=I==="top"?`${U.top-z.offsetHeight-12}px`:`${U.bottom+12}px`,L.style.left=`${Math.max(10,Math.min(U.left+U.width/2-$-5,H-20))}px`,I==="top"?(L.style.bottom="-4px",L.style.top=""):(L.style.top="-4px",L.style.bottom=""),_=requestAnimationFrame(O)};O()}const y=S?window.setTimeout(()=>{S&&(S.style.opacity="1",S.style.transform="translateY(0)")},350):0,v=()=>{if(!x){x=!0,Ue===v&&(Ue=null),cancelAnimationFrame(_),window.clearTimeout(M),window.clearTimeout(y),document.removeEventListener("click",N,!0),document.removeEventListener("keydown",R,!0),S&&(S.style.opacity="0",S.style.transform=d?"none":"translateY(4px)");try{f.hide(),f.finished.then(()=>f.remove())}catch{f.remove()}window.setTimeout(()=>b.remove(),300)}},N=()=>v(),R=z=>{z.key==="Escape"&&v()},M=window.setTimeout(v,Math.max(0,a));return document.addEventListener("click",N,!0),document.addEventListener("keydown",R,!0),Ue=v,!0}const kg=200;function jg(){const{pageMarkHighlightDurationMs:e}=C.useConfig(),{pageEffects:t,replyToPageCall:n,isStreaming:o}=C.useAgentChatUi(),{widgetCtx:s}=C.useWidget(),i=ac(t,o),{theme:a,cssVars:c}=ue(),d=mo({cssVars:c,primaryColor:a.primaryColor,contentZIndex:a.widgetContentContainer.zIndex}),l=u.useRef(new Set);return u.useEffect(()=>()=>{vg(),In()},[]),u.useEffect(()=>{o||In()},[o]),u.useEffect(()=>{const m=l.current;for(const p of t){if(p.type!=="highlight-element"||m.has(p.key))continue;for(m.add(p.key);m.size>kg;){const S=m.values().next().value;if(S===void 0)break;m.delete(S)}const h=()=>i(p.key)&&s.features.pageContext&&s.features.clientTools;if(!h()){n(p.callId,"declined");continue}const f=xg.safeParse(p.input);if(!f.success){G.log.warn("highlight_element: invalid tool input",{issues:f.error.issues}),n(p.callId,"unsupported");continue}const x=Pr(f.data.ref);if(!x.ok){G.log.warn("highlight_element: not drawn",{ref:f.data.ref,reason:x.reason}),x.reason==="off-limits"?n(p.callId,"unsupported",x.detail):n(p.callId,x.reason);continue}const g=x.element,j=p.callId,b=f.data;(async()=>{let S;try{if(S=await sc(g),!h()){n(j,"declined");return}const w=Pr(b.ref);if(!w.ok){n(j,w.reason==="off-limits"?"unsupported":w.reason);return}const _=yg(g,b,{accentColor:d.accent,surfaceColor:d.surface,foregroundColor:d.foreground,zIndex:d.inkZIndex,durationMs:e});n(j,_?"done":"gone"),_||G.log.warn("highlight_element: the mark could not be drawn",b)}catch{n(j,"unsupported","The page highlight could not be completed.")}finally{S==null||S.done()}})()}},[t,n,e,d.accent,d.surface,d.foreground,d.inkZIndex,i,s]),null}const Cg=/(\*\*\*|\*\*|\*|~~|`+)(?=\S)([\s\S]*?\S)\1/g,Sg=/(^|[^\w`])(___|__|_)(?=\S)([\s\S]*?\S)\2(?!\w)/g,Ng=3;function Dr(e){let t=e.replace(/^\s{0,3}(?:```+|~~~+)\S*\s*/,"").replace(/^\s{0,3}(?:#{1,6}\s+|>\s?|[-*+]\s+|\d+[.)]\s+)/,"").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1");for(let n=0;n<Ng;n++){const o=t.replace(Cg,"$2").replace(Sg,"$1$3");if(o===t)break;t=o}return t.trim()}function ic({className:e}){const[t,n]=u.useState(()=>new Set);return u.useEffect(()=>{const o=Array.from({length:9},(i,a)=>a),s=setInterval(()=>{const i=2+Math.floor(Math.random()*3),a=[...o].sort(()=>Math.random()-.5).slice(0,i);n(new Set(a))},110);return()=>clearInterval(s)},[]),r.jsx("div",{className:A("inline-grid shrink-0 grid-cols-3",e),style:{gap:1,width:14,height:14},children:Array.from({length:9},(o,s)=>r.jsx("div",{className:"rounded-[1px]",style:{width:4,height:4,background:t.has(s)?"hsl(var(--opencx-foreground))":"hsl(var(--opencx-border))",transition:"background 66ms ease"}},s))})}function _g({labels:e,active:t}){const n=u.useRef(e);n.current=e;const[o,s]=u.useState(()=>e[e.length-1]??""),[i,a]=u.useState("in"),c=u.useRef(e.length);return u.useEffect(()=>{const d=n.current.length;if(!t||d<=c.current){c.current=d;return}c.current=d;const l=n.current[d-1]??"";a("out");const m=setTimeout(()=>{s(l),a("in")},180);return()=>clearTimeout(m)},[t,e.length]),r.jsx("span",{className:A("truncate text-[12px] text-muted-foreground/60",t&&(i==="in"?"opencx-placeholder-in":"opencx-placeholder-out")),children:o})}function No(e,t){if(e.kind==="tool")return _o(e.label);const n=e.label.split(`
|
|
388
|
-
`).find(s=>s.trim());if(!n)return t;const o=Dr(n);return o?o.length>40?`${o.slice(0,40)}...`:o:t}function Eg(e,t,n=3){const o=e.filter(s=>s.kind==="tool").map(s=>_o(s.label));if(o.length===0){const s=e.find(i=>i.kind==="reasoning");return s?No(s,t):t}return o.length<=n?o.join(" → "):`${o.slice(0,n).join(" → ")} → ...`}const Tg=["prose prose-sm max-w-none","[--tw-prose-body:hsl(var(--opencx-muted-foreground))]","[--tw-prose-headings:hsl(var(--opencx-foreground))]","[--tw-prose-bold:hsl(var(--opencx-foreground))]","[--tw-prose-code:hsl(var(--opencx-foreground))]","[--tw-prose-links:hsl(var(--opencx-primary))]","[--tw-prose-bullets:hsl(var(--opencx-muted-foreground))]","[--tw-prose-counters:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quotes:hsl(var(--opencx-muted-foreground))]","[--tw-prose-quote-borders:hsl(var(--opencx-border))]","[--tw-prose-hr:hsl(var(--opencx-border))]","[--tw-prose-pre-bg:hsl(var(--opencx-muted))]","[--tw-prose-pre-code:hsl(var(--opencx-foreground))]","prose-p:my-1 prose-headings:my-1.5 prose-headings:text-[13px]","prose-ul:my-1 prose-ol:my-1 prose-li:my-0.5","prose-pre:my-1.5 prose-pre:p-2 prose-pre:text-[11px] prose-hr:my-2","[&>*:first-child]:mt-0 [&>*:last-child]:mb-0"].join(" ");function Ag({step:e,isLive:t,thinkingLabel:n}){const[o,s]=u.useState(!1),i=No(e,n),a=i!==Dr(e.label),c=t?(()=>{const d=e.label.split(`
|
|
389
|
-
`).filter(m=>m.trim()),l=Dr(d[d.length-1]??"");return l?l.length>80?`${l.slice(0,80)}...`:l:n})():i;return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:A("flex min-w-0 items-center gap-2.5 py-[3px]",a&&"cursor-pointer"),onClick:()=>a&&s(d=>!d),children:[r.jsx("div",{className:"relative z-10 flex size-[18px] shrink-0 items-center justify-center rounded-full bg-background",children:t?r.jsx(so,{className:"text-[14px] leading-none text-primary/70"}):r.jsx("span",{className:"text-[14px] leading-none text-muted-foreground/40",children:"⠿"})}),r.jsx("span",{className:A("min-w-0 truncate text-[13px] italic text-muted-foreground/60",t&&"opencx-text-shimmer"),children:c}),a&&r.jsx(T.ChevronRightIcon,{className:A("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),a&&o&&r.jsx("div",{className:"opencx-fade-up ms-[30px]",children:r.jsx("div",{className:A("max-h-[160px] overflow-y-auto py-1.5 text-[13px] leading-relaxed [overflow-wrap:anywhere]",Tg),children:r.jsx(Yr,{children:e.label})})})]})}const Ls=4e3;function Ig(e){const t=typeof e=="string"?e:zg(e)??String(e);return t.length>Ls?`${t.slice(0,Ls)}…`:t}function zg(e){try{return JSON.stringify(e,null,2)}catch{return null}}function Ds({label:e,value:t}){return r.jsxs("div",{className:"pt-1.5",children:[r.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground/50",children:e}),r.jsx("pre",{className:"mt-0.5 max-h-[200px] overflow-auto whitespace-pre-wrap [overflow-wrap:anywhere] rounded-lg bg-muted/40 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground",children:Ig(t)})]})}function Mg({step:e,showIO:t}){const{t:n}=Y(),[o,s]=u.useState(!1),i=t&&(e.input!==void 0||e.output!==void 0);return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:A("flex min-w-0 items-center gap-2.5 py-[3px]",i&&"cursor-pointer"),onClick:()=>i&&s(a=>!a),children:[r.jsx("div",{className:"relative z-10 flex size-[18px] shrink-0 items-center justify-center rounded-full bg-background",children:e.done?r.jsx("div",{className:"size-1.5 rounded-full bg-muted-foreground/30"}):r.jsx(ic,{})}),r.jsx("span",{className:A("min-w-0 truncate text-[13px] text-muted-foreground/70",!e.done&&"opencx-text-shimmer"),children:_o(e.label)}),i&&r.jsx(T.ChevronRightIcon,{className:A("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),i&&o&&r.jsxs("div",{className:"opencx-fade-up ms-[30px] pb-1",children:[e.input!==void 0&&r.jsx(Ds,{label:n("step_arguments"),value:e.input}),e.output!==void 0&&r.jsx(Ds,{label:n("step_result"),value:e.output})]})]})}function Rg({steps:e,active:t}){var x;const{t:n}=Y(),{showStepToolIO:o,presentation:s}=C.useConfig(),{widgetCtx:i}=C.useWidget(),a=(x=G.resolveClientPresentation(i.agent.presentation,s))==null?void 0:x.toolActivity,c=o!==!1&&(a==="details"||a===void 0&&o===!0),d=n("thinking"),l=t?e:e.map(g=>g.done?g:{...g,done:!0}),m=l.some(g=>!g.done),[p,h]=u.useState(t),f=u.useRef(t);return u.useEffect(()=>{f.current&&!t?h(!1):!f.current&&t&&h(!0),f.current=t},[t]),l.length===0?null:r.jsxs("div",{...P("chat/streaming_turn/steps"),className:"w-full min-w-0 overflow-hidden",children:[r.jsx("button",{type:"button",className:"flex min-w-0 max-w-full items-center gap-1.5 py-0.5 text-[12px] text-muted-foreground/60 transition-colors duration-150 hover:text-muted-foreground",onClick:()=>h(g=>!g),children:p?r.jsxs(r.Fragment,{children:[r.jsx(T.ChevronDownIcon,{className:"size-2.5 shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:l.length}),r.jsx("span",{className:A("text-muted-foreground/40",m&&"opencx-text-shimmer"),children:n(m?"running":"steps")})]}):m?r.jsxs(r.Fragment,{children:[r.jsx(ic,{className:"opacity-70"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:l.length}),r.jsx(_g,{labels:l.map(g=>No(g,d)),active:m})]}):r.jsxs(r.Fragment,{children:[r.jsx(T.ChevronRightIcon,{className:"size-2.5 shrink-0"}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-start text-[12px] text-muted-foreground/50",children:Eg(l,d)})]})}),p&&r.jsxs("div",{className:"relative pt-1",children:[l.length>1&&r.jsx("div",{className:"absolute bottom-3 start-2 top-3 border-s border-dashed border-muted-foreground/20"}),l.map((g,j)=>r.jsx("div",{className:"opencx-fade-up",style:{animationDelay:`${j*40}ms`},children:g.kind==="reasoning"?r.jsx(Ag,{step:g,isLive:m&&j===l.length-1,thinkingLabel:d}):r.jsx(Mg,{step:g,showIO:c})},j))]})]})}function _o(e){const n=e.replace(/^mcp_[a-f0-9]{16}__/,"").replaceAll(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}function Fs(e){var n;if(e.manual){const o=e.manualText.trim();return o.length>0?o:void 0}if(e.question.selection==="single")return e.singleId?(n=e.question.options.find(o=>o.id===e.singleId))==null?void 0:n.label:void 0;const t=Array.from(e.multiIds).map(o=>{var s;return(s=e.question.options.find(i=>i.id===o))==null?void 0:s.label}).filter(o=>typeof o=="string"&&o.length>0);return t.length>0?t.join(", "):void 0}function Pg({request:e}){const{t}=Y(),n=rn(),{widgetCtx:o}=C.useWidget(),s=e.questions,[i,a]=u.useState(0),[c,d]=u.useState(!1),[l,m]=u.useState({}),[p,h]=u.useState({}),[f,x]=u.useState({}),[g,j]=u.useState({}),b=s[i],S=s.length,w=u.useCallback(O=>Fs({question:O,manual:!!l[O.id],manualText:p[O.id]??"",singleId:f[O.id],multiIds:g[O.id]??new Set})!==void 0,[l,p,g,f]),_=b?w(b):!1,y=u.useMemo(()=>s.every(O=>w(O)),[w,s]),v=u.useCallback((O,U)=>{x(E=>({...E,[O]:U})),m(E=>({...E,[O]:!1}))},[]),N=u.useCallback((O,U)=>{j(E=>{const I=new Set(E[O]??[]);return I.has(U)?I.delete(U):I.add(U),{...E,[O]:I}}),m(E=>({...E,[O]:!1}))},[]),R=u.useCallback(O=>{m(U=>({...U,[O]:!0})),x(U=>({...U,[O]:void 0})),j(U=>({...U,[O]:new Set}))},[]),M=u.useCallback(()=>{_&&a(O=>Math.min(S-1,O+1))},[_,S]),z=u.useCallback(()=>{if(c||!y)return;const O=new Map;for(const E of s){const I=Fs({question:E,manual:!!l[E.id],manualText:p[E.id]??"",singleId:f[E.id],multiIds:g[E.id]??new Set});I&&O.set(E.id,I)}const U=C.formatAskQuestionsAnswers(e,O);U.trim().length!==0&&(d(!0),n({content:U,clientContext:Ni({marks:[],readsPage:o.features.pageContext})}))},[y,c,l,p,g,s,e,n,f,o]);if(!b)return null;const L=!!l[b.id];return r.jsxs("div",{...P("chat/clarification_questions/root"),className:A("w-full rounded-2xl border border-border bg-background shadow-sm",c&&"pointer-events-none opacity-60"),children:[r.jsxs("div",{className:"flex items-start gap-2.5 px-4 pt-4",children:[r.jsx("span",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-primary text-primary-foreground",children:r.jsx(T.SparklesIcon,{className:"size-4"})}),r.jsx("p",{...P("chat/clarification_questions/prompt"),className:"min-w-0 flex-1 text-sm font-medium leading-snug text-foreground",children:b.prompt})]}),r.jsx("div",{className:"px-4 pb-3 pt-3",children:L?r.jsx("textarea",{...P("chat/clarification_questions/manual_input"),value:p[b.id]??"",onChange:O=>h(U=>({...U,[b.id]:O.target.value})),placeholder:t("questions_answer_placeholder"),rows:3,className:A("w-full resize-none rounded-xl border border-border bg-muted/30 px-3 py-2.5","text-sm text-foreground placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"),onKeyDown:O=>{O.key!=="Enter"||O.shiftKey||(O.preventDefault(),i<S-1?M():z())}}):r.jsxs("div",{className:"flex flex-wrap gap-2",children:[b.options.map(O=>{var E;const U=b.selection==="single"?f[b.id]===O.id:((E=g[b.id])==null?void 0:E.has(O.id))??!1;return u.createElement("button",{...P("chat/clarification_questions/option"),key:O.id,type:"button","aria-pressed":U,onClick:()=>b.selection==="single"?v(b.id,O.id):N(b.id,O.id),className:A("rounded-full border px-3 py-1.5 text-sm transition-colors",U?"border-primary bg-primary/10 text-foreground":"border-border bg-muted/40 text-foreground/90 hover:bg-muted")},O.label)}),r.jsx("button",{...P("chat/clarification_questions/type_it"),type:"button",onClick:()=>R(b.id),className:A("rounded-full border border-dashed border-border px-3 py-1.5 text-sm","text-muted-foreground hover:bg-muted hover:text-foreground"),children:t("questions_type_answer")})]})}),r.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-border px-3 py-2",children:[r.jsxs("button",{...P("chat/clarification_questions/back"),type:"button",onClick:()=>a(O=>Math.max(0,O-1)),disabled:i===0,className:"inline-flex items-center gap-1 rounded-lg px-2 py-1.5 text-xs font-medium text-muted-foreground hover:bg-muted disabled:opacity-40",children:[r.jsx(T.ChevronLeftIcon,{className:"size-3.5"}),t("questions_back")]}),S>1?r.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[i+1," / ",S]}):null,i<S-1?r.jsxs("button",{...P("chat/clarification_questions/next"),type:"button",onClick:M,disabled:!_,className:"inline-flex items-center gap-1 rounded-lg px-2 py-1.5 text-xs font-medium text-primary hover:bg-muted disabled:opacity-40",children:[t("questions_next"),r.jsx(T.ChevronRightIcon,{className:"size-3.5"})]}):r.jsx("button",{...P("chat/clarification_questions/send"),type:"button",onClick:z,disabled:!y,className:"inline-flex items-center gap-1 rounded-lg px-3 py-1.5 text-xs font-medium text-primary hover:bg-muted disabled:opacity-40",children:t("questions_send")})]}),r.jsx("div",{className:"h-1 w-full overflow-hidden rounded-b-2xl bg-muted",children:r.jsx("div",{className:"h-full bg-primary transition-[width] duration-300 ease-out",style:{width:`${(i+1)/Math.max(1,S)*100}%`}})})]})}function Og({widgetRef:e}){const{contactState:t}=C.useContact(),{setIsOpen:n}=C.useWidgetTrigger(),{toChatScreen:o}=C.useWidgetRouter(),{renewUserToken:s}=C.useTokenRenewal();return u.useImperativeHandle(e,()=>({newChat:async i=>{var c;if(!((c=t.contact)!=null&&c.token)){G.log.warn("cannot start a new chat: contact not yet initialized");return}n(!0);const a=o();a&&(i!=null&&i.message)&&await a.messageCtx.sendMessage({content:i.message})},renewUserToken:s}),[t,n,o,s]),null}function $g(){const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger();return r.jsxs(Qe.Root,{open:e,onOpenChange:t,children:[r.jsx(jo,{}),r.jsx(Jh,{}),r.jsx(Zh,{}),r.jsx(Xh,{})]})}function Lg(){return C.useDisplayMode()==="companion"?r.jsx(C.WidgetLayoutProvider,{children:r.jsx(Jf,{})}):r.jsx($g,{})}const Dg=[{key:"loading",component:hu},{key:"fallback",component:mu},{key:"bot_message",component:gr},{key:"agent_message",component:gr},{key:"agent_chat_steps",component:Rg},{key:"agent_chat_spec",component:Hu},{key:"agent_chat_questions",component:Pg}],Fg={get:async e=>localStorage.getItem(e),set:async(e,t)=>{localStorage.setItem(e,t)},remove:async e=>{localStorage.removeItem(e)}},cc=u.forwardRef(function({options:t,components:n=[],loadingComponent:o,errorComponent:s},i){var a,c,d,l;return r.jsx(W.MotionConfig,{reducedMotion:"user",children:r.jsx(C.WidgetProvider,{components:[...Dg,...n],options:{...t,capabilities:{...t.capabilities,richReplies:((a=t.capabilities)==null?void 0:a.richReplies)??!n.some(({key:m})=>["AGENT_CHAT_SPEC","BOT_MESSAGE","AGENT_MESSAGE"].includes(m.toUpperCase())),connections:((c=t.capabilities)==null?void 0:c.connections)===!0,pageEffects:((d=t.capabilities)==null?void 0:d.pageEffects)??!0,structuredQuestions:((l=t.capabilities)==null?void 0:l.structuredQuestions)??!n.some(({key:m})=>m.toUpperCase()==="AGENT_CHAT_QUESTIONS")}},storage:Fg,loadingComponent:o,errorComponent:s,children:r.jsx(du,{children:r.jsx(C.WidgetTriggerProvider,{children:r.jsxs(Fm,{children:[r.jsx(jg,{}),r.jsx(fg,{}),r.jsx(Og,{widgetRef:i}),t.inline?r.jsxs(r.Fragment,{children:[r.jsx(jo,{}),r.jsx(Gi,{})]}):r.jsx(Lg,{})]})})})})})});cc.displayName="Widget";exports.HostedSpecRenderer=yd;exports.Widget=cc;exports.segmentContent=Oa;exports.useJsonRenderHost=en;
|
|
390
|
-
//# sourceMappingURL=index-Cv8Wst3d.cjs.map
|