@opencx/widget-react 5.8.0 → 5.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/{Chart.impl-DIHCDiID.cjs → Chart.impl-CgiXedqT.cjs} +2 -2
  2. package/dist/{Chart.impl-DIHCDiID.cjs.map → Chart.impl-CgiXedqT.cjs.map} +1 -1
  3. package/dist/{Chart.impl-CY5LjWPd.js → Chart.impl-D-e-ljB-.js} +2 -2
  4. package/dist/{Chart.impl-CY5LjWPd.js.map → Chart.impl-D-e-ljB-.js.map} +1 -1
  5. package/dist/index-Cbc5wgsq.cjs +390 -0
  6. package/dist/index-Cbc5wgsq.cjs.map +1 -0
  7. package/dist/{index-D5kgeyBH.js → index-Dr5xAVxl.js} +6076 -5032
  8. package/dist/index-Dr5xAVxl.js.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/package.json.d.ts +1 -1
  12. package/dist/src/components/Header.d.ts.map +1 -1
  13. package/dist/src/components/RichText.d.ts +6 -0
  14. package/dist/src/components/RichText.d.ts.map +1 -1
  15. package/dist/src/screens/home/HomeArticle.d.ts +13 -0
  16. package/dist/src/screens/home/HomeArticle.d.ts.map +1 -0
  17. package/dist/src/screens/home/HomeRows.d.ts +27 -0
  18. package/dist/src/screens/home/HomeRows.d.ts.map +1 -0
  19. package/dist/src/screens/home/HomeTabs.d.ts +5 -0
  20. package/dist/src/screens/home/HomeTabs.d.ts.map +1 -0
  21. package/dist/src/screens/home/HomeTopic.d.ts +11 -0
  22. package/dist/src/screens/home/HomeTopic.d.ts.map +1 -0
  23. package/dist/src/screens/home/home-data.d.ts +14 -0
  24. package/dist/src/screens/home/home-data.d.ts.map +1 -0
  25. package/dist/src/screens/home/home-tree.d.ts +13 -0
  26. package/dist/src/screens/home/home-tree.d.ts.map +1 -0
  27. package/dist/src/screens/home/index.d.ts +3 -0
  28. package/dist/src/screens/home/index.d.ts.map +1 -0
  29. package/dist/src/screens/home/tab-swap.d.ts +17 -0
  30. package/dist/src/screens/home/tab-swap.d.ts.map +1 -0
  31. package/dist/src/screens/home/use-home-search.d.ts +16 -0
  32. package/dist/src/screens/home/use-home-search.d.ts.map +1 -0
  33. package/dist/src/screens/home/use-paged-list.d.ts +22 -0
  34. package/dist/src/screens/home/use-paged-list.d.ts.map +1 -0
  35. package/dist/src/screens/home/use-topic-articles.d.ts +18 -0
  36. package/dist/src/screens/home/use-topic-articles.d.ts.map +1 -0
  37. package/dist/src/screens/index.d.ts.map +1 -1
  38. package/dist/src/screens/sessions/index.d.ts.map +1 -1
  39. package/dist/src/utils/article-embed.d.ts +10 -0
  40. package/dist/src/utils/article-embed.d.ts.map +1 -0
  41. package/package.json +3 -3
  42. package/dist/index-D5kgeyBH.js.map +0 -1
  43. package/dist/index-DkqDf7-h.cjs +0 -390
  44. package/dist/index-DkqDf7-h.cjs.map +0 -1
@@ -0,0 +1,390 @@
1
+ "use strict";var ec=Object.defineProperty;var tc=(e,t,n)=>t in e?ec(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ko=(e,t,n)=>tc(e,typeof t!="symbol"?t+"":t,n);const r=require("react/jsx-runtime"),nc=require("@radix-ui/react-popover"),W=require("framer-motion"),u=require("react"),k=require("@opencx/widget-react-headless"),y=require("zod"),Z=require("@opencx/widget-core"),T=require("lucide-react"),rc=require("clsx"),oc=require("tailwind-merge"),sc=require("@radix-ui/react-slot"),Ds=require("class-variance-authority"),Fs=require("remark-gfm"),ac=require("react-markdown"),Qn=require("rehype-raw"),ve=require("rehype-sanitize"),ic=require("@radix-ui/react-avatar"),Hs=require("@uiw/react-iframe"),jo=require("tinycolor2"),cc=require("@radix-ui/react-tooltip"),Vt=require("react-dom"),lc=require("@radix-ui/react-menu"),dc=require("html-to-image"),uc=require("react-dropzone"),Ws=require("@shardsui/notation"),Bs=require("react-use/lib/useAsync"),pc=require("react-use/lib/useDebounce"),mc=require("react-use/lib/useAsyncFn");function Yt(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 Xe=Yt(nc),Je=Yt(u),zt=Yt(ic),Ne=Yt(cc),Ce=Yt(lc);var Us=y.z.union([y.z.string(),y.z.number(),y.z.boolean(),y.z.null(),y.z.object({$state:y.z.string()})]);y.z.union([y.z.string(),y.z.object({$state:y.z.string()})]);y.z.union([y.z.number(),y.z.object({$state:y.z.string()})]);y.z.union([y.z.boolean(),y.z.object({$state:y.z.string()})]);function qs(e,t){if(e!=null)return typeof e=="object"&&"$state"in e?ae(t,e.$state):e}function hc(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Xt(e){return(e.startsWith("/")?e.slice(1).split("/"):e.split("/")).map(hc)}function ae(e,t){if(!t||t==="/")return e;const n=Xt(t);let o=e;for(const s of n){if(o==null)return;if(Array.isArray(o)){const a=parseInt(s,10);o=o[a]}else if(typeof o=="object")o=o[s];else return}return o}function Vs(e){return/^\d+$/.test(e)}function fc(e,t,n){const o=Xt(t);if(o.length===0)return;let s=e;for(let i=0;i<o.length-1;i++){const c=o[i],d=o[i+1],l=d!==void 0&&(Vs(d)||d==="-");if(Array.isArray(s)){const p=parseInt(c,10);(s[p]===void 0||typeof s[p]!="object")&&(s[p]=l?[]:{}),s=s[p]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=l?[]:{}),s=s[c]}const a=o[o.length-1];if(Array.isArray(s))if(a==="-")s.push(n);else{const i=parseInt(a,10);s[i]=n}else s[a]=n}function Fn(e,t,n){const o=Xt(t);if(o.length===0)return;let s=e;for(let i=0;i<o.length-1;i++){const c=o[i],d=o[i+1],l=d!==void 0&&(Vs(d)||d==="-");if(Array.isArray(s)){const p=parseInt(c,10);(s[p]===void 0||typeof s[p]!="object")&&(s[p]=l?[]:{}),s=s[p]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=l?[]:{}),s=s[c]}const a=o[o.length-1];if(Array.isArray(s))if(a==="-")s.push(n);else{const i=parseInt(a,10);s.splice(i,0,n)}else s[a]=n}function Co(e,t){const n=Xt(t);if(n.length===0)return;let o=e;for(let a=0;a<n.length-1;a++){const i=n[a];if(Array.isArray(o)){const c=parseInt(i,10);if(o[c]===void 0||typeof o[c]!="object")return;o=o[c]}else{if(!(i in o)||typeof o[i]!="object")return;o=o[i]}}const s=n[n.length-1];if(Array.isArray(o)){const a=parseInt(s,10);a>=0&&a<o.length&&o.splice(a,1)}else delete o[s]}function er(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((i,c)=>er(i,t[c]));const n=e,o=t,s=Object.keys(n),a=Object.keys(o);return s.length!==a.length?!1:s.every(i=>er(n[i],o[i]))}function tr(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 Ys(e,t){switch(t.op){case"add":Fn(e,t.path,t.value);break;case"replace":fc(e,t.path,t.value);break;case"remove":Co(e,t.path);break;case"move":{if(!t.from)break;const n=ae(e,t.from);Co(e,t.from),Fn(e,t.path,n);break}case"copy":{if(!t.from)break;const n=ae(e,t.from);Fn(e,t.path,n);break}case"test":{const n=ae(e,t.path);if(!er(n,t.value))throw new Error(`Test operation failed: value at "${t.path}" does not match`);break}}return e}function gc(e,t){return Ys(e,t),e}function xc(e){const t={};let n=0;function o(i){const c=`el-${n++}`,{type:d,props:l,children:p,...m}=i,f=[];if(Array.isArray(p))for(const b of p)b&&typeof b=="object"&&"type"in b&&f.push(o(b));const h={type:d??"unknown",props:l??{},children:f};for(const[b,g]of Object.entries(m))b!=="state"&&g!==void 0&&(h[b]=g);return t[c]=h,c}const a={root:o(e),elements:t};return e.state&&typeof e.state=="object"&&!Array.isArray(e.state)&&(a.state=e.state),a}function bc(e,t={}){const n=e.split(`
2
+ `),o={...t};for(const s of n){const a=tr(s);a&&Ys(o,a)}return o}var wc="spec",vc=`data-${wc}`;function So(e,t,n){const o=Xt(t);if(o.length===0)return e;const s={...e};let a=s;for(let c=0;c<o.length-1;c++){const d=o[c],l=a[d];if(Array.isArray(l))a[d]=[...l];else if(l!==null&&typeof l=="object")a[d]={...l};else{const p=o[c+1];a[d]=p!==void 0&&/^\d+$/.test(p)?[]:{}}a=a[d]}const i=o[o.length-1];return Array.isArray(a)?i==="-"?a.push(n):a[parseInt(i,10)]=n:a[i]=n,s}function yc(e={}){let t={...e};const n=new Set;function o(){for(const s of n)s()}return{get(s){return ae(t,s)},set(s,a){ae(t,s)!==a&&(t=So(t,s,a),o())},update(s){let a=!1,i=t;for(const[c,d]of Object.entries(s))ae(i,c)!==d&&(i=So(i,c,d),a=!0);a&&(t=i,o())},getSnapshot(){return t},getServerSnapshot(){return t},subscribe(s){return n.add(s),()=>{n.delete(s)}}}}var Hn=20;function Mr(e,t="",n=0,o,s){const a=o??new Set,i=s??{current:!1},c={};for(const[d,l]of Object.entries(e)){const p=`${t}/${d}`;n<Hn&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&Object.getPrototypeOf(l)===Object.prototype&&!a.has(l)?(a.add(l),Object.assign(c,Mr(l,p,n+1,a,i))):(process.env.NODE_ENV!=="production"&&!i.current&&n>=Hn&&l!==null&&typeof l=="object"&&!Array.isArray(l)&&Object.getPrototypeOf(l)===Object.prototype&&!a.has(l)&&(i.current=!0,console.warn(`flattenToPointers: depth limit (${Hn}) reached. Nested state beyond this depth will be treated as a leaf value.`)),c[p]=l)}return c}var ln=y.z.union([y.z.number(),y.z.object({$state:y.z.string()})]),Rr={eq:y.z.unknown().optional(),neq:y.z.unknown().optional(),gt:ln.optional(),gte:ln.optional(),lt:ln.optional(),lte:ln.optional(),not:y.z.literal(!0).optional()},kc=y.z.object({$state:y.z.string(),...Rr}),jc=y.z.object({$item:y.z.string(),...Rr}),Cc=y.z.object({$index:y.z.literal(!0),...Rr}),No=y.z.union([kc,jc,Cc]),nr=y.z.lazy(()=>y.z.union([y.z.boolean(),No,y.z.array(No),y.z.object({$and:y.z.array(nr)}),y.z.object({$or:y.z.array(nr)})]));function yt(e,t){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"?ae(t.stateModel,e.$state):e}function Sc(e){return"$item"in e}function Nc(e){return"$index"in e}function _c(e,t){return Nc(e)?t.repeatIndex:Sc(e)?t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ae(t.repeatItem,e.$item):ae(t.stateModel,e.$state)}function _o(e,t){const n=_c(e,t);let o;if(e.eq!==void 0){const s=yt(e.eq,t);o=n===s}else if(e.neq!==void 0){const s=yt(e.neq,t);o=n!==s}else if(e.gt!==void 0){const s=yt(e.gt,t);o=typeof n=="number"&&typeof s=="number"?n>s:!1}else if(e.gte!==void 0){const s=yt(e.gte,t);o=typeof n=="number"&&typeof s=="number"?n>=s:!1}else if(e.lt!==void 0){const s=yt(e.lt,t);o=typeof n=="number"&&typeof s=="number"?n<s:!1}else if(e.lte!==void 0){const s=yt(e.lte,t);o=typeof n=="number"&&typeof s=="number"?n<=s:!1}else o=!!n;return e.not===!0?!o:o}function Ec(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$and"in e}function Tc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$or"in e}function Nt(e,t){return e===void 0?!0:typeof e=="boolean"?e:Array.isArray(e)?e.every(n=>_o(n,t)):Ec(e)?e.$and.every(n=>Nt(n,t)):Tc(e)?e.$or.some(n=>Nt(n,t)):_o(e,t)}function Ac(e){const t=new Map;for(const n of e)t.set(n.name,n);return t}function zc(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 Ic(e){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"}function Xs(e){return typeof e=="object"&&e!==null&&"$item"in e&&typeof e.$item=="string"}function Gs(e){return typeof e=="object"&&e!==null&&"$index"in e&&e.$index===!0}function Ks(e){return typeof e=="object"&&e!==null&&"$bindState"in e&&typeof e.$bindState=="string"}function Zs(e){return typeof e=="object"&&e!==null&&"$bindItem"in e&&typeof e.$bindItem=="string"}function Mc(e){return typeof e=="object"&&e!==null&&"$cond"in e&&"$then"in e&&"$else"in e}function Rc(e){return typeof e=="object"&&e!==null&&"$computed"in e&&typeof e.$computed=="string"}function Pc(e){return typeof e=="object"&&e!==null&&"$template"in e&&typeof e.$template=="string"}var Oc=100,Wn=new Set;function Pr(e,t){if(t.repeatBasePath==null){console.warn(`$bindItem used outside repeat scope: "${e}"`);return}return e===""?t.repeatBasePath:t.repeatBasePath+"/"+e}function it(e,t){var n;if(e==null)return e;if(Ic(e))return ae(t.stateModel,e.$state);if(Xs(e))return t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ae(t.repeatItem,e.$item);if(Gs(e))return t.repeatIndex;if(Ks(e))return ae(t.stateModel,e.$bindState);if(Zs(e)){const o=Pr(e.$bindItem,t);return o===void 0?void 0:ae(t.stateModel,o)}if(Mc(e)){const o=Nt(e.$cond,t);return it(o?e.$then:e.$else,t)}if(Rc(e)){const o=(n=t.functions)==null?void 0:n[e.$computed];if(!o){Wn.has(e.$computed)||(Wn.size<Oc&&Wn.add(e.$computed),console.warn(`Unknown $computed function: "${e.$computed}"`));return}const s={};if(e.args)for(const[a,i]of Object.entries(e.args))s[a]=it(i,t);return o(s)}if(Pc(e))return e.$template.replace(/\$\{([^}]+)\}/g,(o,s)=>{if(s.startsWith("/")){const i=ae(t.stateModel,s);return i!=null?String(i):""}if(t.repeatItem!==void 0){const i=ae(t.repeatItem,s);if(i!=null)return String(i)}const a=ae(t.stateModel,"/"+s);return a!=null?String(a):""});if(Array.isArray(e))return e.map(o=>it(o,t));if(typeof e=="object"){const o=zc(e,t.directives);if(o)return o.resolve(e,t);const s={};for(const[a,i]of Object.entries(e))s[a]=it(i,t);return s}return e}function $c(e,t){const n={};for(const[o,s]of Object.entries(e))n[o]=it(s,t);return n}function Lc(e,t){let n;for(const[o,s]of Object.entries(e))if(Ks(s))n||(n={}),n[o]=s.$bindState;else if(Zs(s)){const a=Pr(s.$bindItem,t);a!==void 0&&(n||(n={}),n[o]=a)}return n}function Eo(e,t){return Xs(e)?Pr(e.$item,t):Gs(e)?t.repeatIndex:it(e,t)}var Js=new Set;function Dc(e){for(const t of Js){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 Fc(e){for(const t of Js){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 To=0;function Hc(){return To+=1,`${Date.now()}-${To}`}var Wc=0,Ao=new Set;function Bc(){return Wc>0}function Uc(e){return Ao.add(e),()=>{Ao.delete(e)}}var qc=y.z.object({title:y.z.string(),message:y.z.string(),confirmLabel:y.z.string().optional(),cancelLabel:y.z.string().optional(),variant:y.z.enum(["default","danger"]).optional()}),Vc=y.z.union([y.z.object({navigate:y.z.string()}),y.z.object({set:y.z.record(y.z.string(),y.z.unknown())}),y.z.object({action:y.z.string()})]),Yc=y.z.union([y.z.object({set:y.z.record(y.z.string(),y.z.unknown())}),y.z.object({action:y.z.string()})]);y.z.object({action:y.z.string(),params:y.z.record(y.z.string(),Us).optional(),confirm:qc.optional(),onSuccess:Vc.optional(),onError:Yc.optional(),preventDefault:y.z.boolean().optional()});function Xc(e,t){const n={};if(e.params)for(const[s,a]of Object.entries(e.params))n[s]=qs(a,t);let o=e.confirm;return o&&(o={...o,message:zo(o.message,t),title:zo(o.title,t)}),{action:e.action,params:n,confirm:o,onSuccess:e.onSuccess,onError:e.onError}}function zo(e,t){return e.replace(/\$\{([^}]+)\}/g,(n,o)=>{const s=qs({$state:o},t);return String(s??"")})}async function Io(e){const{action:t,handler:n,setState:o,navigate:s,executeAction:a}=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[i,c]of Object.entries(t.onSuccess.set))o(i,c);else"action"in t.onSuccess&&a&&await a(t.onSuccess.action)}catch(i){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"?i.message:d;o(c,l)}else"action"in t.onError&&a&&await a(t.onError.action);else throw i}}var Gc=y.z.object({type:y.z.string(),args:y.z.record(y.z.string(),Us).optional(),message:y.z.string()});y.z.object({checks:y.z.array(Gc).optional(),validateOn:y.z.enum(["change","blur","submit"]).optional(),enabled:nr.optional()});var Mo=(e,t)=>{const n=t==null?void 0:t.other;return e===n},Kc={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:Mo,equalTo:Mo,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 Zc(e,t){const{value:n,stateModel:o,customFunctions:s}=t,a={};if(e.args)for(const[d,l]of Object.entries(e.args))a[d]=it(l,{stateModel:o});const i=Kc[e.type]??(s==null?void 0:s[e.type]);if(!i)return console.warn(`Unknown validation function: ${e.type}`),{type:e.type,valid:!0,message:e.message};const c=i(n,a);return{type:e.type,valid:c,message:e.message}}function Jc(e,t){const n=[],o=[];if(e.enabled&&!Nt(e.enabled,{stateModel:t.stateModel}))return{valid:!0,errors:[],checks:[]};if(e.checks)for(const s of e.checks){const a=Zc(s,t);n.push(a),a.valid||o.push(a.message)}return{valid:o.length===0,errors:o,checks:n}}var Qc=["patch"];function el(e){var t;return(t=e==null?void 0:e.modes)!=null&&t.length?e.modes:Qc}function tl(){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 nl(){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 rl(){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 ol(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 sl(e,t){const n=el(e),o=[];o.push("EDITING EXISTING SPECS:"),o.push("");const s=ol(n);s&&(o.push(s),o.push(""));for(const a of n){switch(a){case"patch":o.push(tl());break;case"merge":o.push(nl());break;case"diff":o.push(rl());break}o.push("")}return o.join(`
7
+ `)}function Qs(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 al(){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 il(e,t){const n=al();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 cl(this,s)}}}function cl(e,t){const n=t.components,o=t.actions,s=n?Object.keys(n):[],a=o?Object.keys(o):[],i=ll(e.definition,t);return{schema:e,data:t,componentNames:s,actionNames:a,prompt(c={}){return pl(this,c)},jsonSchema(c={}){return Ve(i,c.strict??!1)},validate(c){const d=i.safeParse(c);return d.success?{success:!0,data:d.data}:{success:!1,error:d.error}},zodSchema(){return i},get _specType(){throw new Error("_specType is only for type inference")}}}function ll(e,t){return fn(e.spec,t)}function fn(e,t){switch(e.kind){case"string":return y.z.string();case"number":return y.z.number();case"boolean":return y.z.boolean();case"any":return y.z.any();case"array":{const n=fn(e.inner,t);return y.z.array(n)}case"object":{const n=e.inner,o={};for(const[s,a]of Object.entries(n)){let i=fn(a,t);a.optional&&(i=i.optional()),o[s]=i}return y.z.object(o)}case"record":{const n=fn(e.inner,t);return y.z.record(y.z.string(),n)}case"ref":{const n=e.inner,o=dl(n,t);return o.length===0?y.z.string():o.length===1?y.z.literal(o[0]):y.z.enum(o)}case"propsOf":{const n=e.inner,o=ul(n,t);return o.length===0?y.z.record(y.z.string(),y.z.unknown()):o.length===1?o[0]:y.z.record(y.z.string(),y.z.unknown())}default:return y.z.unknown()}}function dl(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 ul(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 pl(e,t){if(e.schema.promptTemplate){const E={catalog:e.data,componentNames:e.componentNames,actionNames:e.actionNames,options:t,formatZodType:Se};return e.schema.promptTemplate(E)}const{system:n="You are a UI generator that outputs JSON.",customRules:o=[],mode:s="standalone"}=t,a=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,i=[];i.push(n),i.push(""),a==="inline"?(i.push("OUTPUT FORMAT (text + JSONL, RFC 6902 JSON Patch):"),i.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."),i.push("The JSONL lines use RFC 6902 JSON Patch operations to build a UI tree. Always wrap them in a ```spec fence block:"),i.push(" ```spec"),i.push(' {"op":"add","path":"/root","value":"main"}'),i.push(' {"op":"add","path":"/elements/main","value":{"type":"Card","props":{"title":"Hello"},"children":[]}}'),i.push(" ```"),i.push("If the user's message does not require a UI (e.g. a greeting or clarifying question), respond with text only — no JSONL.")):(i.push("OUTPUT FORMAT (JSONL, RFC 6902 JSON Patch):"),i.push("Output JSONL (one JSON object per line) using RFC 6902 JSON Patch operations to build a UI tree.")),i.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."),i.push(""),i.push("Example output (each line is a separate JSON object):"),i.push("");const c=e.data.components,d=e.componentNames,l=d[0]||"Component",p=d.length>1?d[1]:l,m=c==null?void 0:c[l],f=c==null?void 0:c[p],h=m?Ro(m):{},b=f?Ro(f):{},g=f!=null&&f.props?ml(f.props):null,C=g?{...b,[g]:{$item:"title"}}:b,x=[JSON.stringify({op:"add",path:"/root",value:"main"}),JSON.stringify({op:"add",path:"/elements/main",value:{type:l,props:h,children:["child-1","list"]}}),JSON.stringify({op:"add",path:"/elements/child-1",value:{type:p,props:b,children:[]}}),JSON.stringify({op:"add",path:"/elements/list",value:{type:l,props:h,repeat:{statePath:"/items",key:"id"},children:["item"]}}),JSON.stringify({op:"add",path:"/elements/item",value:{type:p,props:C,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
+ `);i.push(`${x}
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.`),i.push(""),i.push("INITIAL STATE:"),i.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."),i.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."),i.push("Output state patches right after the elements that reference them, so the UI fills in progressively as it streams."),i.push("Stream state progressively - output one patch per array item instead of one giant blob:"),i.push(' For arrays: {"op":"add","path":"/state/posts/0","value":{"id":"1","title":"First Post",...}} then /state/posts/1, /state/posts/2, etc.'),i.push(' For scalars: {"op":"add","path":"/state/newTodoText","value":""}'),i.push(' Initialize the array first if needed: {"op":"add","path":"/state/posts","value":[]}'),i.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.'),i.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."),i.push(""),i.push("DYNAMIC LISTS (repeat field):"),i.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" } }.'),i.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.'),i.push(`Example: ${JSON.stringify({type:l,props:h,repeat:{statePath:"/todos",key:"id"},children:["todo-item"]})}`),i.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.'),i.push("ALWAYS use the repeat field for lists backed by state arrays. NEVER hardcode individual elements for each array item."),i.push('IMPORTANT: "repeat" is a top-level field on the element (sibling of type/props/children), NOT inside props.'),i.push(""),i.push("ARRAY STATE ACTIONS:"),i.push('Use action "pushState" to append items to arrays. Params: { statePath: "/arrayPath", value: { ...item }, clearStatePath: "/inputPath" }.'),i.push('Values inside pushState can contain { "$state": "/statePath" } references to read current state (e.g. the text from an input field).'),i.push('Use "$id" inside a pushState value to auto-generate a unique ID.'),i.push('Example: on: { "press": { "action": "pushState", "params": { "statePath": "/todos", "value": { "id": "$id", "title": { "$state": "/newTodoText" }, "completed": false }, "clearStatePath": "/newTodoText" } } }'),i.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.`),i.push("For lists where users can add/remove items (todos, carts, etc.), use pushState and removeState instead of hardcoding with setState."),i.push(""),i.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.'),i.push("");const N=c;if(N){i.push(`AVAILABLE COMPONENTS (${e.componentNames.length}):`),i.push("");for(const[E,z]of Object.entries(N)){const H=z.props?Se(z.props):"{}",q=z.slots&&z.slots.length>0?" [accepts children]":"",X=z.events&&z.events.length>0?` [events: ${z.events.join(", ")}]`:"",U=z.description?` - ${z.description}`:"";i.push(`- ${E}: ${H}${U}${q}${X}`)}i.push("")}const w=e.data.actions,S=e.schema.builtInActions??[],j=w&&e.actionNames.length>0,v=S.length>0;if(j||v){i.push("AVAILABLE ACTIONS:"),i.push("");for(const E of S)i.push(`- ${E.name}: ${E.description} [built-in]`);if(j)for(const[E,z]of Object.entries(w))i.push(`- ${E}${z.description?`: ${z.description}`:""}`);i.push("")}i.push("EVENTS (the `on` field):"),i.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."),i.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": { ... } }`.'),i.push(""),i.push("Example:"),i.push(` ${JSON.stringify({type:l,props:h,on:{press:{action:"setState",params:{statePath:"/saved",value:!0}}},children:[]})}`),i.push(""),i.push('Action params can use dynamic references to read from state: { "$state": "/statePath" }.'),i.push("IMPORTANT: Do NOT put action/actionParams inside props. Always use the `on` field for event bindings."),i.push(""),i.push("VISIBILITY CONDITIONS:"),i.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."),i.push(`Correct: ${JSON.stringify({type:l,props:h,visible:{$state:"/activeTab",eq:"home"},children:["..."]})}`),i.push('- `{ "$state": "/path" }` - visible when state at path is truthy'),i.push('- `{ "$state": "/path", "not": true }` - visible when state at path is falsy'),i.push('- `{ "$state": "/path", "eq": "value" }` - visible when state equals value'),i.push('- `{ "$state": "/path", "neq": "value" }` - visible when state does not equal value'),i.push('- `{ "$state": "/path", "gt": N }` / `gte` / `lt` / `lte` - numeric comparisons'),i.push("- Use ONE operator per condition (eq, neq, gt, gte, lt, lte). Do not combine multiple operators."),i.push('- Any condition can add `"not": true` to invert its result'),i.push("- `[condition, condition]` - all conditions must be true (implicit AND)"),i.push('- `{ "$and": [condition, condition] }` - explicit AND (use when nesting inside $or)'),i.push('- `{ "$or": [condition, condition] }` - at least one must be true (OR)'),i.push("- `true` / `false` - always visible/hidden"),i.push(""),i.push("Use a component with on.press bound to setState to update state and drive visibility."),i.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.`),i.push(""),i.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.'),i.push(""),i.push("DYNAMIC PROPS:"),i.push("Any prop value can be a dynamic expression that resolves based on state. Three forms are supported:"),i.push(""),i.push('1. Read-only state: `{ "$state": "/statePath" }` - resolves to the value at that state path (one-way read).'),i.push(' Example: `"color": { "$state": "/theme/primary" }` reads the color from state.'),i.push(""),i.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.).'),i.push(' Example: `"value": { "$bindState": "/form/email" }` binds the input value to /form/email.'),i.push(' Inside repeat scopes: `"checked": { "$bindItem": "completed" }` binds to the current item\'s completed field.'),i.push(""),i.push('3. Conditional: `{ "$cond": <condition>, "$then": <value>, "$else": <value> }` - evaluates the condition (same syntax as visibility conditions) and picks the matching value.'),i.push(' Example: `"color": { "$cond": { "$state": "/activeTab", "eq": "home" }, "$then": "#007AFF", "$else": "#8E8E93" }`'),i.push(""),i.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."),i.push(""),i.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>`.'),i.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.'),i.push("");const _=e.data.functions;if(_&&Object.keys(_).length>0){i.push('5. Computed: `{ "$computed": "<functionName>", "args": { "key": <expression> } }` - calls a registered function with resolved args and returns the result.'),i.push(' Example: `"value": { "$computed": "fullName", "args": { "first": { "$state": "/form/firstName" }, "last": { "$state": "/form/lastName" } } }`'),i.push(" Available functions:");for(const E of Object.keys(_))i.push(` - ${E}`);i.push("")}const R=t.directives;if(R&&R.length>0){i.push("CUSTOM DYNAMIC VALUES:"),i.push("");for(const E of R){const z=E.description?` (${E.description})`:"";i.push(`- ${E.name}${z}: ${Se(E.schema)}`)}i.push(""),i.push("Directives compose: any value field can contain another directive or a $state expression, resolved inside-out."),i.push("")}(c?Object.entries(c).some(([,E])=>E.props?Se(E.props).includes("checks"):!1):!1)&&(i.push("VALIDATION:"),i.push("Form components that accept a `checks` prop support client-side validation."),i.push('Each check is an object: { "type": "<name>", "message": "...", "args": { ... } }'),i.push(""),i.push("Built-in validation types:"),i.push(" - required — value must be non-empty"),i.push(" - email — valid email format"),i.push(' - minLength — minimum string length (args: { "min": N })'),i.push(' - maxLength — maximum string length (args: { "max": N })'),i.push(' - pattern — match a regex (args: { "pattern": "regex" })'),i.push(' - min — minimum numeric value (args: { "min": N })'),i.push(' - max — maximum numeric value (args: { "max": N })'),i.push(" - numeric — value must be a number"),i.push(" - url — valid URL format"),i.push(' - matches — must equal another field (args: { "other": { "$state": "/path" } })'),i.push(' - equalTo — alias for matches (args: { "other": { "$state": "/path" } })'),i.push(' - lessThan — value must be less than another field (args: { "other": { "$state": "/path" } })'),i.push(' - greaterThan — value must be greater than another field (args: { "other": { "$state": "/path" } })'),i.push(' - requiredIf — required only when another field is truthy (args: { "field": { "$state": "/path" } })'),i.push(""),i.push("Example:"),i.push(' "checks": [{ "type": "required", "message": "Email is required" }, { "type": "email", "message": "Invalid email" }]'),i.push(""),i.push("IMPORTANT: When using checks, the component must also have a { $bindState } or { $bindItem } on its value/checked prop for two-way binding."),i.push("Always include validation checks on form inputs for a good user experience (e.g. required, email, minLength)."),i.push("")),(j||v)&&(i.push("STATE WATCHERS:"),i.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."),i.push("Maps state paths (JSON Pointers) to action bindings. When the value at a watched path changes, the bound actions fire automatically."),i.push(""),i.push("Example (cascading select — country changes trigger city loading):"),i.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:[]})}`),i.push(""),i.push("Use `watch` for cascading dependencies where changing one field should trigger side effects (loading data, resetting dependent fields, computing derived values)."),i.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."),i.push(""));const M=t.editModes;M&&M.length>0&&i.push(sl({modes:M})),i.push("RULES:");const D=a==="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[...D,...O,...o].forEach((E,z)=>{i.push(`${z+1}. ${E}`)}),i.join(`
11
+ `)}function Ro(e){return e.example&&Object.keys(e.example).length>0?e.example:e.props?ea(e.props):{}}function ea(e){if(!e||!e._def)return{};const t=e._def,n=ut(e);if(n!=="ZodObject"&&n!=="object")return{};const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return{};const s={};for(const[a,i]of Object.entries(o)){const c=ut(i);c==="ZodOptional"||c==="optional"||c==="ZodNullable"||c==="nullable"||(s[a]=rr(i))}return s}function rr(e){if(!e||!e._def)return"...";const t=e._def;switch(ut(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?rr(o):null}case"ZodArray":case"array":return[];case"ZodObject":case"object":return ea(e);case"ZodUnion":case"union":{const o=t.options;return o&&o.length>0?rr(o[0]):"..."}default:return"..."}}function ml(e){if(!e||!e._def)return null;const t=e._def,n=ut(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,a]of Object.entries(o)){const i=ut(a);if(!(i==="ZodOptional"||i==="optional"||i==="ZodNullable"||i==="nullable")&&(i==="ZodString"||i==="string"))return s}return null}function ut(e){if(!e||!e._def)return"";const t=e._def;return t.typeName??t.type??""}function Se(e){if(!e||!e._def)return"unknown";const t=e._def;switch(ut(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<${Se(o)}>`:"Array<unknown>"}case"ZodObject":case"object":{const o=typeof t.shape=="function"?t.shape():t.shape;return o?`{ ${Object.entries(o).map(([a,i])=>{const c=ut(i);return`${a}${c==="ZodOptional"||c==="ZodNullable"||c==="optional"||c==="nullable"?"?":""}: ${Se(i)}`}).join(", ")} }`:"object"}case"ZodOptional":case"optional":case"ZodNullable":case"nullable":{const o=t.innerType??t.wrapped;return o?Se(o):"unknown"}case"ZodUnion":case"union":{const o=t.options;return o?o.map(s=>Se(s)).join(" | "):"unknown"}case"ZodRecord":case"record":{const o=t.keyType??void 0,s=t.valueType??t.element??void 0,a=o?Se(o):"string",i=s?Se(s):"unknown";return`Record<${a}, ${i}>`}case"ZodDefault":case"default":{const o=t.innerType??t.wrapped;return o?Se(o):"unknown"}default:return"unknown"}}function Po(e){return typeof e.type=="string"?e.type:typeof e.typeName=="string"?e.typeName:""}function Oo(e){return e.startsWith("Zod")?e.slice(3).toLowerCase():e.toLowerCase()}function Ve(e,t=!1){const n=e._def;switch(Oo(Po(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?Ve(s,t):{}}}case"object":{const s=n.shape,a=typeof s=="function"?s():s;if(!a)return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object"};const i={},c=[];for(const[d,l]of Object.entries(a)){const p=l._def,m=Oo(Po(p)),f=m==="optional"||m==="nullable";if(t)if(c.push(d),f){const h=Ve(l,t);i[d]={anyOf:[h,{type:"null"}]}}else i[d]=Ve(l,t);else i[d]=Ve(l),f||c.push(d)}return{type:"object",properties:i,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?Ve(s):!0}}case"optional":case"nullable":{const s=n.innerType;return s?Ve(s,t):{}}case"union":{const s=n.options;return s?{anyOf:s.map(a=>Ve(a,t))}:{}}case"any":case"unknown":return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{};default:return{}}}function hl(e,t){return e.createCatalog(t)}var fl=il(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."]}),ta=u.createContext(null);function gl(e,t){return e?null:Object.keys(t).length===0?{}:Mr(t)}function xl({store:e,initialState:t={},onStateChange:n,children:o}){const s=u.useRef(void 0);!e&&!s.current&&(s.current=yc(t));const a=e??s.current,i=u.useRef(a);i.current=a;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 p=u.useRef(t),m=u.useRef(gl(!!e,t));u.useEffect(()=>{if(e||t===p.current)return;p.current=t;const w=t&&Object.keys(t).length>0?Mr(t):{},S=m.current??{},j=new Set([...Object.keys(S),...Object.keys(w)]),v={};for(const _ of j)S[_]!==w[_]&&(v[_]=_ in w?w[_]:void 0);m.current=w,Object.keys(v).length>0&&a.update(v)},[e,t,a]);const f=u.useSyncExternalStore(a.subscribe,a.getSnapshot,a.getServerSnapshot??a.getSnapshot),h=u.useRef(n);h.current=n;const b=u.useCallback((w,S)=>{var _;const j=i.current,v=j.getSnapshot();j.set(w,S),!c.current&&j.getSnapshot()!==v&&((_=h.current)==null||_.call(h,[{path:w,value:S}]))},[]),g=u.useCallback(w=>{var v;const S=i.current,j=S.getSnapshot();if(S.update(w),!c.current&&S.getSnapshot()!==j){const _=[];for(const[R,I]of Object.entries(w))ae(j,R)!==I&&_.push({path:R,value:I});_.length>0&&((v=h.current)==null||v.call(h,_))}},[]),C=u.useCallback(w=>i.current.get(w),[]),x=u.useCallback(()=>i.current.getSnapshot(),[]),N=u.useMemo(()=>({state:f,get:C,set:b,update:g,getSnapshot:x}),[f,C,b,g,x]);return r.jsx(ta.Provider,{value:N,children:o})}function Gt(){const e=u.useContext(ta);if(!e)throw new Error("useStateStore must be used within a StateProvider");return e}var na=u.createContext(null);function bl({children:e}){const{state:t}=Gt(),n=u.useMemo(()=>({stateModel:t}),[t]),o=u.useMemo(()=>a=>Nt(a,n),[n]),s=u.useMemo(()=>({isVisible:o,ctx:n}),[o,n]);return r.jsx(na.Provider,{value:s,children:e})}function wl(){const e=u.useContext(na);if(!e)throw new Error("useVisibility must be used within a VisibilityProvider");return e}var ra=u.createContext(null);function vl(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 a=e[s],i=t[s];if(a!==i){if(typeof a=="object"&&a!==null&&typeof i=="object"&&i!==null){const c=a.$state,d=i.$state;if(typeof c=="string"&&c===d)continue}return!1}}return!0}function yl(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 a=n[s],i=o[s];if(a.type!==i.type||a.message!==i.message||!vl(a.args,i.args))return!1}return!0}function kl({customFunctions:e={},children:t}){const{state:n,getSnapshot:o}=Gt(),[s,a]=u.useState({}),i=u.useRef({}),[c,d]=u.useState({}),l=u.useCallback((g,C)=>{d(x=>{const N=x[g];return N&&yl(N,C)?x:{...x,[g]:C}})},[]),p=u.useCallback((g,C)=>{var v;const x=o(),N=g.split("/").filter(Boolean);let w=x;for(const _ of N)if(w!=null&&typeof w=="object")w=w[_];else{w=void 0;break}const S=Jc(C,{value:w,stateModel:x,customFunctions:e}),j={touched:((v=i.current[g])==null?void 0:v.touched)??!0,validated:!0,result:S};return i.current={...i.current,[g]:j},a(i.current),S},[e,o]),m=u.useCallback(g=>{var C,x;i.current={...i.current,[g]:{...i.current[g],touched:!0,validated:((C=i.current[g])==null?void 0:C.validated)??!1,result:((x=i.current[g])==null?void 0:x.result)??null}},a(i.current)},[]),f=u.useCallback(g=>{const{[g]:C,...x}=i.current;i.current=x,a(x)},[]),h=u.useCallback(()=>{let g=!0;for(const[C,x]of Object.entries(c))p(C,x).valid||(g=!1);return g},[c,p]),b=u.useMemo(()=>({customFunctions:e,get fieldStates(){return i.current},validate:p,touch:m,clear:f,validateAll:h,registerField:l}),[e,s,p,m,f,h,l]);return r.jsx(ra.Provider,{value:b,children:t})}function jl(){return u.useContext(ra)}var $o=0;function Lo(){return $o+=1,`${Date.now()}-${$o}`}function or(e,t){if(e==null)return e;if(e==="$id")return Lo();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 Lo()}if(Array.isArray(e))return e.map(n=>or(n,t));if(typeof e=="object"){const n={};for(const[o,s]of Object.entries(e))n[o]=or(s,t);return n}return e}var oa=u.createContext(null);function Cl({handlers:e={},navigate:t,children:n}){const{get:o,set:s,getSnapshot:a}=Gt(),i=jl(),[c,d]=u.useState(e),[l,p]=u.useState(new Set),[m,f]=u.useState(null),h=u.useCallback((N,w)=>{d(S=>({...S,[N]:w}))},[]),b=u.useCallback(async N=>{var R;const w=Xc(N,a()),S=Hc(),j=Date.now();Dc({id:S,name:w.action,params:w.params,at:j});let v=!0,_;try{if(w.action==="setState"&&w.params){const M=w.params.statePath,D=w.params.value;M&&s(M,D);return}if(w.action==="pushState"&&w.params){const M=w.params.statePath,D=w.params.value;if(M){const O=or(D,o),B=o(M)??[];s(M,[...B,O]);const E=w.params.clearStatePath;E&&s(E,"")}return}if(w.action==="removeState"&&w.params){const M=w.params.statePath,D=w.params.index;if(M!==void 0&&D!==void 0){const O=o(M)??[];s(M,O.filter((B,E)=>E!==D))}return}if(w.action==="push"&&w.params){const M=w.params.screen;if(M){const D=o("/currentScreen"),O=o("/navStack")??[];D?s("/navStack",[...O,D]):s("/navStack",[...O,""]),s("/currentScreen",M)}return}if(w.action==="pop"){const M=o("/navStack")??[];if(M.length>0){const D=M[M.length-1];s("/navStack",M.slice(0,-1)),D?s("/currentScreen",D):s("/currentScreen",void 0)}return}if(w.action==="validateForm"){const M=i==null?void 0:i.validateAll;if(!M){console.warn("validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.");return}const D=M(),O={};for(const[E,z]of Object.entries(i.fieldStates))z.result&&!z.result.valid&&(O[E]=z.result.errors);const B=((R=w.params)==null?void 0:R.statePath)||"/formValidation";s(B,{valid:D,errors:O});return}const I=c[w.action];if(!I){console.warn(`No handler registered for action: ${w.action}`);return}if(w.confirm)return new Promise((M,D)=>{f({action:w,handler:I,resolve:()=>{f(null),M()},reject:()=>{f(null),D(new Error("Action cancelled"))}})}).then(async()=>{p(M=>new Set(M).add(w.action));try{await Io({action:w,handler:I,setState:s,navigate:t,executeAction:async M=>{await b({action:M})}})}finally{p(M=>{const D=new Set(M);return D.delete(w.action),D})}});p(M=>new Set(M).add(w.action));try{await Io({action:w,handler:I,setState:s,navigate:t,executeAction:async M=>{await b({action:M})}})}finally{p(M=>{const D=new Set(M);return D.delete(w.action),D})}}catch(I){throw v=!1,_=I,I}finally{const I=Date.now();Fc({id:S,name:w.action,ok:v,at:I,durationMs:I-j,error:_})}},[c,o,s,a,t,i]),g=u.useCallback(()=>{m==null||m.resolve()},[m]),C=u.useCallback(()=>{m==null||m.reject()},[m]),x=u.useMemo(()=>({handlers:c,loadingActions:l,pendingConfirmation:m,execute:b,confirm:g,cancel:C,registerHandler:h}),[c,l,m,b,g,C,h]);return r.jsx(oa.Provider,{value:x,children:n})}function sa(){const e=u.useContext(oa);if(!e)throw new Error("useActions must be used within an ActionProvider");return e}function Sl({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 aa=u.createContext(null);function Nl({item:e,index:t,basePath:n,children:o}){return r.jsx(aa.Provider,{value:{item:e,index:t,basePath:n},children:o})}function _l(){return u.useContext(aa)}var El=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}},ia={},ca=u.createContext(ia);function Tl(){return u.useContext(ca)}var la=u.createContext(void 0);function Al(){return u.useContext(la)}function zl(){return u.useSyncExternalStore(Uc,Bc,()=>!1)}var da=u.memo(function e({element:t,elementKey:n,spec:o,registry:s,loading:a,fallback:i}){var H;const c=zl(),d=_l(),{ctx:l}=wl(),{execute:p}=sa(),{getSnapshot:m,state:f}=Gt(),h=Tl(),b=Al(),g=u.useMemo(()=>{const L=d?{...l,repeatItem:d.item,repeatIndex:d.index,repeatBasePath:d.basePath}:{...l};return L.functions=h,L.directives=b,L},[l,d,h,b]),C=t.visible===void 0?!0:Nt(t.visible,g),x=t.on,N=u.useCallback(async L=>{const q=x==null?void 0:x[L];if(!q)return;const X=Array.isArray(q)?q:[q];for(const U of X){if(!U.params){await p(U);continue}const F={...g,stateModel:m()},J={};for(const[re,$]of Object.entries(U.params))J[re]=Eo($,F);await p({...U,params:J})}},[x,p,g,m]),w=u.useCallback(L=>{const q=x==null?void 0:x[L];if(!q)return{emit:()=>{},shouldPreventDefault:!1,bound:!1};const U=(Array.isArray(q)?q:[q]).some(F=>F.preventDefault);return{emit:()=>N(L),shouldPreventDefault:U,bound:!0}},[x,N]),S=t.watch,j=u.useRef(null),v=u.useRef(void 0),_=u.useMemo(()=>{if(!S)return;const L={};for(const X of Object.keys(S))L[X]=ae(f,X);const q=v.current;if(q){const X=Object.keys(L);if(X.length===Object.keys(q).length&&X.every(U=>L[U]===q[U]))return q}return v.current=L,L},[S,f]);if(u.useEffect(()=>{if(!S||!_)return;const L=Object.keys(S);if(L.length===0)return;const q=j.current;if(j.current=_,q===null)return;let X=!1;return(async()=>{for(const U of L){if(X)break;if(_[U]!==q[U]){const F=S[U];if(!F)continue;const J=Array.isArray(F)?F:[F];for(const re of J){if(X)break;if(!re.params){if(await p(re),X)break;continue}const $={...g,stateModel:m()},te={};for(const[K,oe]of Object.entries(re.params))te[K]=Eo(oe,$);if(await p({...re,params:te}),X)break}}}})().catch(console.error),()=>{X=!0}},[S,_,p,g,m]),!C)return null;const R=t.props,I=Lc(R,g),M=$c(R,g),D=M!==t.props?{...t,props:M}:t,O=s[D.type]??i;if(!O)return console.warn(`No renderer for component type: ${D.type}`),null;const B=D.repeat?r.jsx(Il,{element:D,spec:o,registry:s,loading:a,fallback:i}):(H=D.children)==null?void 0:H.map(L=>{const q=o.elements[L];return q?r.jsx(e,{element:q,elementKey:L,spec:o,registry:s,loading:a,fallback:i},L):(a||console.warn(`[json-render] Missing element "${L}" referenced as child of "${D.type}". This element will not render.`),null)}),E=r.jsx(O,{element:D,emit:N,on:w,bindings:I,loading:a,children:B}),z=c&&n?r.jsx("span",{"data-jr-key":n,style:{display:"contents"},children:E}):E;return r.jsx(El,{elementType:D.type,children:z})});function Il({element:e,spec:t,registry:n,loading:o,fallback:s}){const{state:a}=Gt(),i=e.repeat,c=i.statePath,d=ae(a,c)??[];return r.jsx(r.Fragment,{children:d.map((l,p)=>{var f;const m=i.key&&typeof l=="object"&&l!==null?String(l[i.key]??p):String(p);return r.jsx(Nl,{item:l,index:p,basePath:`${c}/${p}`,children:(f=e.children)==null?void 0:f.map(h=>{const b=t.elements[h];return b?r.jsx(da,{element:b,elementKey:h,spec:t,registry:n,loading:o,fallback:s},h):(o||console.warn(`[json-render] Missing element "${h}" referenced as child of "${e.type}" (repeat). This element will not render.`),null)})},m)})})}function Ml({spec:e,registry:t,loading:n,fallback:o}){if(!e||!e.root)return null;const s=e.elements[e.root];return s?r.jsx(da,{element:s,elementKey:e.root,spec:e,registry:t,loading:n,fallback:o}):null}function Rl({registry:e,store:t,initialState:n,handlers:o,navigate:s,validationFunctions:a,functions:i,directives:c,onStateChange:d,children:l}){const p=u.useMemo(()=>c?Ac(c):void 0,[c]);return r.jsx(xl,{store:t,initialState:n,onStateChange:d,children:r.jsx(bl,{children:r.jsx(kl,{customFunctions:a,children:r.jsx(Cl,{handlers:o,navigate:s,children:r.jsx(ca.Provider,{value:i??ia,children:r.jsxs(la.Provider,{value:p,children:[l,r.jsx(Pl,{})]})})})})})})}function Pl(){const{pendingConfirmation:e,confirm:t,cancel:n}=sa();return e!=null&&e.action.confirm?r.jsx(Sl,{confirm:e.action.confirm,onConfirm:t,onCancel:n}):null}function Ol(e,t){const n={};if(t.components)for(const[i,c]of Object.entries(t.components))n[i]=({element:d,children:l,emit:p,on:m,bindings:f,loading:h})=>c({props:d.props,children:l,emit:p,on:m,bindings:f,loading:h});const o=t.actions?Object.entries(t.actions):[];return{registry:n,handlers:(i,c)=>{const d={};for(const[l,p]of o)d[l]=async m=>{const f=i(),h=c();f&&await p(m,f,h)};return d},executeAction:async(i,c,d,l={})=>{const p=o.find(([m])=>m===i);p?await p[1](c,d,l):console.warn(`Unknown action: ${i}`)}}}function $l(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 Ll(e){const t={root:"",elements:{}};let n=!1;for(const o of e)if(o.type===vc){if(!$l(o.data))continue;const s=o.data;if(s.type==="patch")n=!0,gc(t,s.patch);else if(s.type==="flat")n=!0,Object.assign(t,s.spec);else if(s.type==="nested"){n=!0;const a=xc(s.spec);Object.assign(t,a)}}return n?t:null}function G(){const{dir:e}=k.useDocumentDir(),t=k.useConfig();return u.useMemo(()=>{const n=Z.resolveLanguage(t.language);return{t:(s,a)=>Z.getTranslation(s,n,t.translationOverrides,a),language:n,dir:Z.isRtlLanguage(n)?"rtl":"ltr",hostDocumentDir:e}},[t.language,t.translationOverrides,e])}function ua(e){const t=Z.resolveLanguage(e);return(n,o)=>Z.getTranslation(n,t,void 0,o)}const Dl={t:ua("en"),anchorTarget:"_blank"},pa=u.createContext(Dl);function Fl({host:e,children:t}){return r.jsx(pa.Provider,{value:e,children:t})}function Kt(){return u.useContext(pa)}function Hl({language:e,onUiAction:t,anchorTarget:n="_blank"}){return u.useMemo(()=>({t:ua(e),anchorTarget:n,onUiAction:t}),[e,n,t])}class Wl extends u.Component{constructor(){super(...arguments);ko(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){Z.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 Bl(e){if(!e.elements)return e;let t=!1;const n={};for(const[o,s]of Object.entries(e.elements)){const a=Ul(s,e);a!==s&&(t=!0),n[o]=a}return t?{...e,elements:n}:e}function Ul(e,t){if(e.type!=="List")return e;const n=e.repeat;if(!n||typeof n.statePath!="string")return e;const o=Z.isRecord(e.props)?e.props:{},s=o.items;if(Array.isArray(s)&&s.length>0)return e;const i=ae(t.state??{},n.statePath);if(!Array.isArray(i)||i.length===0)return e;const{repeat:c,...d}=e;return{...d,props:{...o,items:i}}}function A(...e){return oc.twMerge(rc.clsx(e))}const ql=u.lazy(()=>Promise.resolve().then(()=>require("./Chart.impl-CgiXedqT.cjs")));function Vl(e){const t=e.height??220;return r.jsx(u.Suspense,{fallback:r.jsx(Yl,{height:t}),children:r.jsx(ql,{...e})})}function Yl({height:e}){return r.jsx("div",{className:"w-full animate-pulse rounded-lg bg-muted-foreground/10",style:{height:e},"aria-hidden":!0})}const ma=y.z.object({title:y.z.string().nullish(),description:y.z.string().nullish()}),ha=y.z.object({direction:y.z.enum(["row","column"]).nullish(),gap:y.z.enum(["sm","md","lg"]).nullish(),align:y.z.enum(["start","center","end","stretch"]).nullish(),justify:y.z.enum(["start","center","end","between"]).nullish()}),fa=y.z.object({columns:y.z.union([y.z.literal(1),y.z.literal(2),y.z.literal(3)]).nullish(),gap:y.z.enum(["sm","md","lg"]).nullish()}),ga=y.z.object({text:y.z.string(),level:y.z.union([y.z.literal(1),y.z.literal(2),y.z.literal(3),y.z.literal(4)]).nullish()}),xa=y.z.object({text:y.z.string(),variant:y.z.enum(["body","caption","muted","code"]).nullish()}),ba=y.z.object({text:y.z.string(),variant:y.z.enum(["default","secondary","success","warning","destructive"]).nullish()}),Xl=new Set(["http:","https:","mailto:"]),Gl=y.z.string().nullish().transform(e=>{if(!e)return null;try{return Xl.has(new URL(e).protocol)?e:null}catch{return null}}),wa=y.z.object({id:y.z.string().nullish(),label:y.z.string(),secondary:y.z.string().nullish(),badge:y.z.string().nullish(),status:y.z.enum(["success","warning","error","info","neutral"]).nullish(),href:Gl}),va=y.z.object({items:y.z.array(wa),maxVisible:y.z.number().int().positive().nullish()}),Kl=y.z.object({items:y.z.array(wa.extend({href:y.z.string().nullish()})),maxVisible:va.shape.maxVisible}),ya=y.z.object({columns:y.z.array(y.z.string()),rows:y.z.array(y.z.array(y.z.string())),caption:y.z.string().nullish()}),Zl=y.z.object({value:y.z.string(),direction:y.z.enum(["up","down","flat"]),label:y.z.string().nullish()}),ka=y.z.object({label:y.z.string(),value:y.z.string(),description:y.z.string().nullish(),trend:y.z.enum(["up","down","neutral"]).nullish(),delta:Zl.nullish()}),ja=y.z.object({type:y.z.enum(["info","tip","warning","important"]).nullish(),title:y.z.string().nullish(),content:y.z.string()}),Jl=y.z.object({label:y.z.string(),value:y.z.number()}),Ca=y.z.object({type:y.z.enum(["bar","line","pie"]),data:y.z.array(Jl),title:y.z.string().nullish(),height:y.z.number().int().positive().nullish(),centerLabel:y.z.string().nullish()}),Sa=y.z.object({agentId:y.z.string(),agentName:y.z.string(),model:y.z.string().nullish()});function ke(e,t,n){const o=e.safeParse(t);return o.success?o.data:n}const Ql=hl(fl,{components:{Card:{props:ma,slots:["default"],description:"Container card with an optional title/description. Group related content.",example:{title:"Order summary",description:"Placed 2 days ago"}},Stack:{props:ha,slots:["default"],description:'Flex layout. Use direction="row" for side-by-side, "column" (default) to stack.'},Grid:{props:fa,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:ga,description:"Section heading. level 1 (largest) to 4.",example:{text:"Your orders",level:3}},Text:{props:xa,description:'A paragraph of text. variant "muted"/"caption" for secondary text, "code" for monospace.'},Badge:{props:ba,description:"Small status pill. Use variant to convey state (success/warning/destructive).",example:{text:"Delivered",variant:"success"}},List:{props:Kl,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:ya,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:ka,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:ja,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:Sa,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:Ca,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 sr({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 Do={sm:"gap-1.5",md:"gap-3",lg:"gap-4"},ed="10rem";function td(e){return e===1?"minmax(0, 1fr)":`repeat(auto-fit, minmax(max(${ed}, calc(100% / ${e} - 1rem)), 1fr))`}const{registry:Fo}=Ol(Ql,{components:{Card:({props:e,children:t,loading:n})=>{const o=ke(ma,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})]}),Bn(t,n)]})},Stack:({props:e,children:t,loading:n})=>{const o=ke(ha,e,{}),s={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"}[o.align??"stretch"],a={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",Do[o.gap??"md"],s,a),children:Bn(t,n)})},Grid:({props:e,children:t,loading:n})=>{const o=ke(fa,e,{});return r.jsx("div",{className:A("grid",Do[o.gap??"md"]),style:{gridTemplateColumns:td(o.columns??1)},children:Bn(t,n)})},Heading:({props:e})=>{const t=ke(ga,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=ke(xa,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=ke(ba,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=ke(va,e,{items:[]});return n.items.length===0?t?r.jsx(sr,{}):r.jsx(Ho,{translationKey:"json_no_items"}):r.jsx(md,{items:n.items,maxVisible:n.maxVisible})},Table:({props:e,loading:t})=>{const n=ke(ya,e,{columns:[],rows:[]});return t&&n.rows.length===0?r.jsx(sr,{}):n.columns.length===0?r.jsx(Ho,{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((a,i)=>r.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:a},i))},s))})]})})},Metric:({props:e})=>{const t=ke(ka,e,{label:"",value:""});return r.jsx(dd,{label:t.label,value:t.value,description:t.description,trend:t.trend,delta:t.delta})},Callout:({props:e})=>{const t=ke(ja,e,{content:""}),n=rd[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=ke(Sa,e,{agentId:"",agentName:""});return r.jsx(sd,{...t})},Chart:({props:e})=>{const t=ke(Ca,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(Vl,{...t})]})}}}),nd=({element:e})=>{const{t}=Kt();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})})},rd={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 Bn(e,t){return u.Children.toArray(e).length>0?e:t?r.jsx(sr,{}):null}function Ho({translationKey:e}){const{t}=Kt();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 od="oppie-vox-livekit";function sd({agentId:e,agentName:t,model:n}){const{t:o,onUiAction:s}=Kt(),a=!!s&&!!e&&n===od;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")})]})]}),a&&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 ad={up:"↑",down:"↓",neutral:"→"},id={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",neutral:"text-muted-foreground"},cd={up:"↑",down:"↓",flat:"→"},ld={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",flat:"text-muted-foreground"};function dd({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",id[o]),children:ad[o]}):null]}),s?r.jsxs("div",{className:"flex items-baseline gap-1 text-xs",children:[r.jsxs("span",{className:A("font-medium",ld[s.direction]),children:[cd[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 ud={success:"bg-emerald-500",warning:"bg-amber-500",error:"bg-red-500",info:"bg-blue-500",neutral:"bg-muted-foreground/40"};function pd({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",ud[e.status]),"aria-hidden":!0}):r.jsx("span",{}))]})}function md({items:e,maxVisible:t}){const n=t??10,{anchorTarget:o,t:s}=Kt(),[a,i]=u.useState(!1),c=e.length>n,d=a?e:e.slice(0,n),l=d.some(b=>!!b.badge),p=d.some(b=>!!b.secondary),m=d.some(b=>!!b.status),f=[l&&"auto","minmax(0,1fr)",p&&"minmax(0,2fr)",m&&"auto"].filter(Boolean).join(" "),h="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:f},children:[d.map((b,g)=>{const C=b.id??`row-${g}`,x=r.jsx(pd,{item:b,showBadge:l,showSecondary:p,showStatus:m});return b.href?r.jsx("a",{href:b.href,target:o||"_top",rel:"noopener noreferrer",className:A(h,"transition-colors hover:bg-muted/50",g>0&&"border-t border-muted-foreground/10"),children:x},C):r.jsx("div",{className:A(h,g>0&&"border-t border-muted-foreground/10"),children:x},C)}),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:()=>i(b=>!b),children:a?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 Na({spec:e,active:t=!1}){const{anchorTarget:n,onUiAction:o}=k.useConfig(),{t:s}=G(),a=u.useMemo(()=>({t:s,anchorTarget:n??"_blank",onUiAction:o}),[s,n,o]);return r.jsx(_a,{spec:e,host:a,active:t})}function hd({spec:e,language:t,onUiAction:n,anchorTarget:o}){const s=Hl({language:t,onUiAction:n,anchorTarget:o});return r.jsx(_a,{spec:e,host:s})}function _a({spec:e,host:t,active:n=!1}){return r.jsx(Fl,{host:t,children:r.jsx(Wl,{resetKey:e,children:r.jsx(fd,{spec:e,active:n})})})}function fd({spec:e,active:t}){const n=u.useMemo(()=>e?Bl(e):null,[e]);return!n||!Qs(n)?null:r.jsx(Rl,{registry:Fo,initialState:n.state,children:r.jsx(Ml,{spec:n,registry:Fo,loading:t,fallback:nd})})}function Ea(e){if(!e)return[];const t=e.split(`
12
+ `),n=[];let o=[],s=[],a=[],i=!1,c=!1;function d(){if(o.length===0)return;const m=o.join(`
13
+ `);m.trim()&&n.push({type:"markdown",content:m}),o=[]}function l(){if(s.length===0)return;let m=null;if(a.length>0)try{m=bc(a.join(`
14
+ `),{root:"",elements:{}})}catch{}m&&gd(m)?(d(),n.push({type:"ui",spec:m})):o.push(...s),a=[],s=[]}function p(){c&&(l(),c=!1)}for(let m=0;m<t.length;m+=1){const f=t[m]??"",h=f.trim(),b=m===t.length-1;if(!i&&h==="```spec"){p(),i=!0,s=[f];continue}if(i&&h==="```"){s.push(f),l(),i=!1;continue}if(i){s.push(f),h!==""&&tr(f)&&a.push(f);continue}if(h!==""&&tr(f)){c=!0,s.push(f),a.push(f);continue}if(c){if(h===""||b&&bd(h)){s.push(f);continue}p()}o.push(f)}return l(),d(),n}function gd(e){return Qs(e)&&e.elements[e.root]!==void 0}const xd='{"op":';function bd(e){return!e.startsWith("{")||e.endsWith("}")?!1:/"op"\s*:/.test(e)?!0:xd.startsWith(e.replace(/\s+/g,""))}function wd(e){return Ll(e)}function P(e){return{"data-component":e}}const ar=[{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"]}],vd=Object.fromEntries(ar.flatMap(e=>e.mimes.map(t=>[t,e.extensions.map(n=>`.${n}`)]))),yd={"video/mp4":[".mp4"],"video/webm":[".webm"],"video/quicktime":[".mov"],"video/x-m4v":[".m4v"],"video/x-matroska":[".mkv"],"video/3gpp":[".3gp"]};function Ta({type:e,name:t}){var s,a;const n=((s=t.split(".").pop())==null?void 0:s.toLowerCase())??"",o=((a=e.toLowerCase().split(";")[0])==null?void 0:a.trim())??"";return ar.find(i=>n&&i.extensions.includes(n))??ar.find(i=>o&&i.mimes.includes(o))??null}function _n(){const[e]=u.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(hover: hover) and (pointer: fine)").matches);return e}const _t={x:2,y:2},Re=u.memo(u.forwardRef(({children:e,className:t,scale:n=1.02,off:o=!1},s)=>{const[a,i]=u.useState(!1),[c,d]=u.useState({x:0,y:0}),l=_n(),p=W.useReducedMotion();if(o||!l||p)return u.cloneElement(e,{ref:s??e.props.ref});if(/translate/.test(e.props.className||""))return e;const f=C=>{var M,D;const{clientX:x,clientY:N}=C,w=C.currentTarget.getBoundingClientRect(),S=x-(w.left+w.width/2),j=N-(w.top+w.height/2),v=Math.max(-1,Math.min(1,S/(w.width/2))),_=Math.max(-1,Math.min(1,j/(w.height/2))),R=v*_t.x,I=_*_t.y;d({x:R,y:I}),(D=(M=e.props).onMouseMove)==null||D.call(M,C)},h=C=>{var x,N;i(!0),(N=(x=e.props).onMouseEnter)==null||N.call(x,C)},b=C=>{var x,N;i(!1),d({x:0,y:0}),(N=(x=e.props).onMouseLeave)==null||N.call(x,C)},g={"--wobble-x":a?`${c.x}px`:"0px","--wobble-y":a?`${c.y}px`:"0px","--scale":1-(n-1)};return u.cloneElement(e,{ref:s,onMouseMove:f,onMouseEnter:h,onMouseLeave:b,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)]")})}));Re.displayName="Wobble";const Qe=[.23,1,.32,1],kd=`cubic-bezier(${Qe.join(", ")})`,Te={duration:.2,ease:Qe},we={duration:.15,ease:Qe},Et={type:"spring",stiffness:500,damping:45,mass:1},jd=[.32,.72,.24,1],Cd=`cubic-bezier(${jd.join(", ")})`,Sd="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)",Nd="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)",_d="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)",Ed="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)",Td=10,Ad=(e,t,n)=>({initial:{opacity:0,x:-e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...Te,delay:n}},exit:{opacity:0,x:e,...t.exit,transition:we},transition:Te}),zd=(e,t,n)=>({initial:{opacity:0,x:e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...Te,delay:n}},exit:{opacity:0,x:-e,...t.exit,transition:we},transition:Te}),Id=(e,t,n)=>({initial:{opacity:0,y:e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...Te,delay:n}},exit:{opacity:0,y:-e,...t.exit,transition:we},transition:Te}),Md=(e,t,n)=>({initial:{opacity:0,y:-e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...Te,delay:n}},exit:{opacity:0,y:e,...t.exit,transition:we},transition:Te}),Rd={right:Ad,left:zd,up:Id,down:Md},ee=u.forwardRef(({fadeIn:e="down",distance:t=Td,children:n,snapExit:o=!1,overrides:s={},delay:a=0,...i},c)=>{const d=e?Rd[e](t,s,a):{};return o&&d.exit&&typeof d.exit=="object"&&!Array.isArray(d.exit)&&(d.exit.transition={duration:0}),r.jsx(W.motion.div,{ref:c,...i,...d,children:n})});ee.displayName="MotionDiv";const ir=Ds.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=Je.forwardRef(({className:e,variant:t="default",size:n,asChild:o=!1,wobble:s=!0,...a},i)=>{const c=o?sc.Slot:"button";return r.jsx(Re,{ref:i,off:!s,children:r.jsx(c,{...P("ui_lib/btn"),"data-variant":t,className:A(ir({variant:t,size:n,className:e})),...a})})});V.displayName="Button";const Aa=u.createContext(null);function Pd({children:e}){const[t,n]=u.useState(!1),[o,s]=u.useState(null),a=c=>{s(c),n(!0)},i=u.useCallback(()=>{n(!1),setTimeout(()=>{s(null)},200)},[]);return r.jsxs(Aa.Provider,{value:{open:a,close:i,isOpen:t,content:o},children:[r.jsx(Od,{}),e]})}function En(){const e=u.useContext(Aa);return e||(Z.log.error("useDialoger must be used within a DialogerProvider"),{open:()=>{},close:()=>{},isOpen:!1,content:null})}function Od(){const{contentIframeRef:e}=k.useWidget(),{isOpen:t,content:n,close:o}=En();return u.useEffect(()=>{var i,c;if(!t)return;const s=d=>{d.defaultPrevented||d.key!=="Escape"||(d.preventDefault(),o())},a=(c=(i=e==null?void 0:e.current)==null?void 0:i.contentWindow)==null?void 0:c.document;return a==null||a.addEventListener("keydown",s),()=>a==null?void 0:a.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 Zt({children:e,className:t,withClose:n=!1}){const{close:o}=En(),{t:s}=G();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:a=>a.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 Or=({className:e,...t})=>r.jsx("div",{className:A("flex flex-col gap-2 text-center pt-2",e),...t});Or.displayName="DialogerHeader";const $r=({className:e,...t})=>r.jsx("div",{className:A("flex flex-col gap-2 text-center",e),...t});$r.displayName="DialogerBody";const za=({className:e,...t})=>r.jsx("div",{className:A("flex flex-col gap-2",e),...t});za.displayName="DialogerFooter";const Lr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:A("text-lg font-semibold leading-none tracking-tight",e),...t}));Lr.displayName="DialogerTitle";const Dr=u.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Dr.displayName="DialogerDescription";function Jt({children:e,trigger:t}){const{open:n}=En();return u.cloneElement(t,{onClick:()=>{var s,a;n(e),(a=(s=t.props).onClick)==null||a.call(s)}})}const Wo=1,Bo=5,Uo=.5,$d=2.5;function Ld(e,t,n,o){if(!n||!o||t<=1)return{x:0,y:0};const s=n.getBoundingClientRect(),a=o.offsetWidth,i=o.offsetHeight,c=Math.max(0,(a*t-s.width)/(2*t)),d=Math.max(0,(i*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 Ia({src:e,alt:t}){const{t:n}=G(),[o,s]=u.useState(1),[a,i]=u.useState({x:0,y:0}),[c,d]=u.useState(!1),l=u.useRef({x:0,y:0}),p=u.useRef({x:0,y:0}),m=u.useRef(null),f=u.useRef(null),h=u.useRef(!1),b=v=>Math.min(Bo,Math.max(Wo,v)),g=u.useCallback(()=>{s(1),i({x:0,y:0})},[]),C=u.useCallback(()=>{s(v=>b(v+Uo))},[]),x=u.useCallback(()=>{s(v=>{const _=b(v-Uo);return _<=1&&i({x:0,y:0}),_})},[]),N=u.useCallback(v=>{v.preventDefault(),h.current=!1,d(!0),l.current={x:v.clientX,y:v.clientY},p.current={...a},v.target.setPointerCapture(v.pointerId)},[a]),w=u.useCallback(v=>{if(!c)return;const _=v.clientX-l.current.x,R=v.clientY-l.current.y;if((Math.abs(_)>3||Math.abs(R)>3)&&(h.current=!0),o<=1)return;const I={x:p.current.x+_/o,y:p.current.y+R/o};i(Ld(I,o,m.current,f.current))},[c,o]),S=u.useCallback(()=>{const v=h.current;d(!1),!v&&s(_=>_>1?(i({x:0,y:0}),1):$d)},[]),j=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:m,className:A("overflow-hidden max-h-full max-w-full rounded-2xl flex items-center justify-center",j&&"size-full"),onPointerDown:N,onPointerMove:w,onPointerUp:S,onPointerCancel:S,style:{cursor:c?"grabbing":j?"grab":"zoom-in",touchAction:"none"},children:r.jsx("img",{ref:f,src:e,alt:t,className:"block max-w-full object-contain pointer-events-none",draggable:!1,style:{maxHeight:"100vh",transform:`scale(${o}) translate(${a.x}px, ${a.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(Un,{onClick:x,label:n("zoom_out"),disabled:o<=Wo,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(Un,{onClick:C,label:n("zoom_in"),disabled:o>=Bo,children:r.jsx(T.ZoomIn,{className:"size-3.5"})}),j&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-px h-4 bg-white/30 mx-0.5"}),r.jsx(Un,{onClick:g,label:n("reset_zoom"),children:r.jsx(T.RotateCcw,{className:"size-3.5"})})]})]})]})}function Un({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 qo({url:e,name:t,size:n,icon:o,label:s}){return r.jsx(Re,{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 Ma({attachment:e}){const{name:t,size:n,type:o,url:s}=e,a=o.startsWith("image/"),i=o.startsWith("video/"),c=o.startsWith("audio/"),d=o==="application/pdf";if(c)return r.jsx(Re,{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(i)return r.jsx(Re,{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(a)return r.jsx(Jt,{trigger:r.jsx("div",{children:r.jsx(Re,{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(Zt,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(Ia,{src:s,alt:t})})});if(d)return r.jsx(qo,{url:s,name:t,size:n,icon:r.jsx(T.FileText,{className:"size-5",strokeWidth:1.75}),label:"PDF"});const l=Ta({type:o,name:t});return l?r.jsx(qo,{url:s,name:t,size:n,icon:r.jsx(T.FileSpreadsheet,{className:"size-5",strokeWidth:1.75}),label:l.label}):r.jsx(Re,{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 Dd({replyTo:e}){const t=k.useBot(),{humanAgent:n}=k.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:a=>{const i=a.currentTarget.ownerDocument.querySelector(`[data-message-id="${CSS.escape(e.id)}"]`);i==null||i.scrollIntoView({behavior:"smooth",block:"center"}),i==null||i.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 Ra=u.memo(ac,(e,t)=>e.children===t.children&&e.className===t.className);var Is,Ms,Rs;const Fd={...ve.defaultSchema,attributes:{...ve.defaultSchema.attributes,"*":[...((Is=ve.defaultSchema.attributes)==null?void 0:Is["*"])??[],"style"],code:[...((Ms=ve.defaultSchema.attributes)==null?void 0:Ms.code)??[],"className"],pre:[...((Rs=ve.defaultSchema.attributes)==null?void 0:Rs.pre)??[],"className"]}},Hd=/^(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,Wd=/^[\w\s#.,%()'"+-]+$/,Bd=/\b(url|expression|var|attr)\s*\(/i;function Ud(){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(a=>{const i=a.indexOf(":");if(i<0)return!1;const c=a.slice(0,i).trim(),d=a.slice(i+1).trim();return Hd.test(c)&&Wd.test(d)&&!Bd.test(d)}).join(";")),(s=t.children)==null||s.forEach(e)}}function Pa(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 qd=/^[\w-]{11}$/,Vd=new Set(["youtube.com","www.youtube.com","m.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com"]);function Yd(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const n=Xd(t);return n&&qd.test(n)?n:null}function Xd(e){const[t,n]=e.pathname.split("/").filter(Boolean);return e.hostname==="youtu.be"?t:Vd.has(e.hostname)?t==="watch"?e.searchParams.get("v"):t==="shorts"||t==="embed"?n:null:null}function Gd({id:e,title:t}){return r.jsx(Jt,{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(Zt,{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 Kd=new Map([["youtube",/^[\w-]{11}$/],["vimeo",/^\d+(?:\/[\da-f]+)?$/],["loom",/^[\da-f]{32}$/],["wistia",/^[\da-z]{10}$/]]),Zd=new Map([["youtube","YouTube video"],["vimeo","Vimeo video"],["loom","Loom video"],["wistia","Wistia video"]]);function Jd(e,t){var o;if(typeof e!="string"||typeof t!="string"||!((o=Kd.get(e))!=null&&o.test(t)))return;const n=Zd.get(e)??"Video";switch(e){case"youtube":return{src:`https://www.youtube-nocookie.com/embed/${t}`,title:n};case"vimeo":{const[s,a]=t.split("/");return{src:`https://player.vimeo.com/video/${s}${a?`?h=${a}`:""}`,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 Ps,Os;const cr={...ve.defaultSchema,attributes:{...ve.defaultSchema.attributes,code:[...((Ps=ve.defaultSchema.attributes)==null?void 0:Ps.code)??[],"className"],pre:[...((Os=ve.defaultSchema.attributes)==null?void 0:Os.pre)??[],"className"]}};var $s,Ls;const Qd={...cr,attributes:{...cr.attributes,div:[...(($s=ve.defaultSchema.attributes)==null?void 0:$s.div)??[],"dataEmbed","dataEmbedId"],a:[...((Ls=ve.defaultSchema.attributes)==null?void 0:Ls.a)??[],"dataArticleSlug"]}};function Fr(e){return r.jsx(Hr,{...e})}function eu({openArticle:e,...t}){return r.jsx(Hr,{...t,articleEmbeds:!0,openArticle:e})}function tu(e){return r.jsx(Hr,{...e,configuredStyles:!0})}function Hr({children:e,messageType:t,messageId:n,configuredStyles:o=!1,articleEmbeds:s=!1,openArticle:a}){const{anchorTarget:i}=k.useConfig();return r.jsx(Ra,{"data-type":t,"data-id":n,remarkPlugins:[Fs],rehypePlugins:o?[Qn,Ud,[ve,Fd]]:[Qn,[ve,s?Qd:cr]],components:{div:({node:c,...d})=>{const l=s?Jd(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:p}=l,m=s?c==null?void 0:c.properties.dataArticleSlug:void 0;if(typeof m=="string")return a?r.jsx("a",{href:"#",onClick:h=>{h.preventDefault(),a(m)},children:d}):r.jsx(r.Fragment,{children:d});const f=p?Yd(p):null;return p&&f?r.jsx(Gd,{id:f,title:typeof d=="string"?d:p}):r.jsx("a",{target:l.target||i||"_top",...l,children:d})},img:({src:c,alt:d,...l})=>c?r.jsx(Jt,{trigger:r.jsx("img",{src:c,alt:d,...l,className:"cursor-pointer rounded-xl"}),children:r.jsx(Zt,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(Ia,{src:c,alt:d})})}):r.jsx("img",{src:c,alt:d,...l})},children:Pa(e)})}function Fe(){const{widgetCtx:{org:e}}=k.useWidget(),{sessionState:{session:t}}=k.useSessions(),n=k.useConfig(),{messagesState:{messages:o}}=k.useMessages(),{routerState:{screen:s}}=k.useWidgetRouter();return{react:u,org:e,session:t,config:n,messages:o,currentScreen:s}}function nu({currentMessage:e}){var o;const t=Fe(),n=(o=t.config.customComponents)==null?void 0:o["message::after"];return n?r.jsx(n,{...t,currentMessage:e}):null}function ru({messageId:e,messageOptions:t}){var d;const{messagesState:n,sendMessage:o}=k.useMessages(),{sessionState:s}=k.useSessions(),{pickedOptionId:a}=t,i=((d=Z.tappableOptionsMessage(n.messages,s.session))==null?void 0:d.id)===e,c=t.options.find(l=>l.id===a);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]})}):i?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 ou=["[--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 lr(e){const{data:t,id:n,type:o,attachments:s,isFirstInGroup:a,isLastInGroup:i,isAloneInGroup:c,dataComponentNames:d,classNames:l}=e,p=o==="AI"||o==="AGENT"?t.message:"",m=u.useMemo(()=>o==="AI"?Ea(p):null,[o,p]);if(o!=="AI"&&o!=="AGENT")return null;const{variant:f="default"}=t,h=e.replyTo?r.jsx(Dd,{replyTo:e.replyTo}):null,b=(N,w,S=!0,j=!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":a,"data-last":i,"data-alone":c,"data-variant":f,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",ou,"break-words [word-break:break-word]",f==="error"&&"bg-destructive/15 text-destructive",a&&!c&&"rounded-bl-md",i&&!c&&"rounded-tl-md",!a&&!i&&!c&&"rounded-l-md",l==null?void 0:l.message),children:[j&&h,r.jsx(Fr,{messageType:o,messageId:n,children:N})]}),S&&r.jsx(nu,{currentMessage:e})]},w),g=(m==null?void 0:m.some(N=>N.type==="ui"))??!1,C=(m==null?void 0:m.reduce((N,w,S)=>w.type==="markdown"?S:N,-1))??-1,x=(m==null?void 0:m.findIndex(N=>N.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(N=>r.jsx(Ma,{attachment:N},N.id))}),g&&m?m.map((N,w)=>N.type==="markdown"?b(N.content,`md-${w}`,w===C,w===x):r.jsx("div",{className:"w-full",children:r.jsx(Na,{spec:N.spec})},`ui-${w}`)):p.length>0&&b(p),e.messageOptions&&r.jsx(ru,{messageId:n,messageOptions:e.messageOptions})]})}function su(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 Wr=Je.forwardRef(({className:e,...t},n)=>r.jsx(zt.Root,{ref:n,className:A("relative flex size-6 aspect-square shrink-0 overflow-hidden rounded-full bg-secondary",e),...t}));Wr.displayName=zt.Root.displayName;const Br=Je.forwardRef(({className:e,...t},n)=>r.jsx(zt.Image,{ref:n,className:A("aspect-square h-full w-full",e),...t}));Br.displayName=zt.Image.displayName;const Ur=Je.forwardRef(({className:e,...t},n)=>r.jsx(zt.Fallback,{ref:n,className:A("flex size-full text-xs items-center justify-center rounded-lg",e),...t}));Ur.displayName=zt.Fallback.displayName;function dr({agent:e,...t}){var n,o;return r.jsxs(Wr,{...t,children:[r.jsx(Br,{src:(e==null?void 0:e.avatarUrl)||(e==null?void 0:e.avatar)||"",alt:"Agent Icon"}),(e==null?void 0:e.name)&&r.jsx(Ur,{children:(o=(n=e==null?void 0:e.name)==null?void 0:n.slice(0,1))==null?void 0:o.toUpperCase()})]})}function au({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(dr,{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 iu='*,: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}.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-40{max-width:10rem}.max-w-48{max-width:12rem}.max-w-64{max-width:16rem}.max-w-96{max-width:24rem}.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-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\\/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}}',cu="5.9.0";function lu(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 Vo=450;function ye(){const[e,t]=u.useState(()=>(window.top||window).innerWidth<Vo);return u.useEffect(()=>{const n=window.top||window,o=()=>{t(n.innerWidth<Vo)};return o(),n.addEventListener("resize",o),()=>{n.removeEventListener("resize",o)}},[]),{isSmallScreen:e}}const dn={transitionTimingFunction:"cubic-bezier(0.16, 1, 0.3, 1)",transitionDuration:"1000ms"};function de(){var f,h,b,g,C,x,N,w,S,j,v,_,R,I,M,D,O,B,E,z,H,L,q,X,U,F,J,re,$,te,K,oe,he,le,se,ne,ze,ie,ue,ft,et,Ie,He,tt,We,Oe,Be,Ue;const{dir:e}=k.useDocumentDir(),{isSmallScreen:t}=ye(),{theme:n,inline:o}=k.useConfig(),s=ge=>o?"100%":ge,a=(ge,Me)=>t?`100dv${ge}`:Me,i=(ge,Me)=>s(a(ge,Me)),c=lu((f=n==null?void 0:n.widgetTrigger)==null?void 0:f.offset,e),d={zIndex:((h=n==null?void 0:n.widgetTrigger)==null?void 0:h.zIndex)??1e7,offset:{bottom:((g=(b=n==null?void 0:n.widgetTrigger)==null?void 0:b.offset)==null?void 0:g.bottom)??20,right:((x=(C=n==null?void 0:n.widgetTrigger)==null?void 0:C.offset)==null?void 0:x.right)??(c==="right"?20:"initial"),left:((w=(N=n==null?void 0:n.widgetTrigger)==null?void 0:N.offset)==null?void 0:w.left)??(c==="left"?20:"initial")},size:{button:((j=(S=n==null?void 0:n.widgetTrigger)==null?void 0:S.size)==null?void 0:j.button)??48,icon:((_=(v=n==null?void 0:n.widgetTrigger)==null?void 0:v.size)==null?void 0:_.icon)??24}},l=(()=>{const ge=c==="right"?d.offset.right:d.offset.left;return typeof ge!="number"?0:ge})(),p={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:((I=n==null?void 0:n.widgetContentContainer)==null?void 0:I.zIndex)??d.zIndex+1,outline:((M=n==null?void 0:n.widgetContentContainer)==null?void 0:M.outline)??"none",outlineColor:((D=n==null?void 0:n.widgetContentContainer)==null?void 0:D.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:((B=n==null?void 0:n.widgetContentContainer)==null?void 0:B.transitionProperty)??"all",transitionTimingFunction:((E=n==null?void 0:n.widgetContentContainer)==null?void 0:E.transitionTimingFunction)??dn.transitionTimingFunction,transitionDuration:((z=n==null?void 0:n.widgetContentContainer)==null?void 0:z.transitionDuration)??dn.transitionDuration,offset:{side:t?0:d.offset.bottom+d.size.button+_t.y*2+(((L=(H=n==null?void 0:n.widgetContentContainer)==null?void 0:H.offset)==null?void 0:L.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:i("w",((F=(U=n==null?void 0:n.screens)==null?void 0:U.welcome)==null?void 0:F.width)??"400px"),minHeight:i("h",((re=(J=n==null?void 0:n.screens)==null?void 0:J.welcome)==null?void 0:re.minHeight)??"1px")},sessions:{width:i("w",((te=($=n==null?void 0:n.screens)==null?void 0:$.sessions)==null?void 0:te.width)??"450px"),height:i("h",((oe=(K=n==null?void 0:n.screens)==null?void 0:K.sessions)==null?void 0:oe.height)??"600px")},chat:{width:i("w",((le=(he=n==null?void 0:n.screens)==null?void 0:he.chat)==null?void 0:le.width)??"525px"),height:i("h",((ne=(se=n==null?void 0:n.screens)==null?void 0:se.chat)==null?void 0:ne.height)??"700px"),withCanvas:{width:i("w",((ue=(ie=(ze=n==null?void 0:n.screens)==null?void 0:ze.chat)==null?void 0:ie.withCanvas)==null?void 0:ue.width)??"min(1050px, 100vw)"),height:i("h",((Ie=(et=(ft=n==null?void 0:n.screens)==null?void 0:ft.chat)==null?void 0:et.withCanvas)==null?void 0:Ie.height)??"min(800px, 100vh)"),transitionTimingFunction:((We=(tt=(He=n==null?void 0:n.screens)==null?void 0:He.chat)==null?void 0:tt.withCanvas)==null?void 0:We.transitionTimingFunction)??dn.transitionTimingFunction,transitionDuration:((Ue=(Be=(Oe=n==null?void 0:n.screens)==null?void 0:Oe.chat)==null?void 0:Be.withCanvas)==null?void 0:Ue.transitionDuration)??dn.transitionDuration}}}},m={maxHeight:i("h",`calc(
15
+ 100vh
16
+ - ${p.widgetTrigger.offset.bottom}px
17
+ - ${p.widgetContentContainer.offset.side}px
18
+ - ${_t.y*2}px
19
+ )`),maxWidth:i("w",`calc(
20
+ 100vw
21
+ - ${l*2}px
22
+ )`),minHeight:i("h",`min(
23
+ ${p.screens.welcome.minHeight},
24
+ ${p.screens.sessions.height},
25
+ ${p.screens.chat.height}
26
+ )`),minWidth:i("w",`min(
27
+ ${p.screens.welcome.width},
28
+ ${p.screens.sessions.width},
29
+ ${p.screens.chat.width}
30
+ )`)};return{theme:p,triggerSide:c,computed:m,cssVars:du({palette:p.palette,primary:p.primaryColor})}}function du({palette:e,primary:t}){const n=Oa(e),o=jo(t).toHsl(),s=jo(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 Oa(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 Z.isExhaustive(e,Oa.name),t}}const uu=Ne.Provider,pu=Ne.Root,mu=Ne.Trigger,$a=Je.forwardRef(({className:e,sideOffset:t=4,...n},o)=>r.jsx(Ne.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}));$a.displayName=Ne.Content.displayName;const La=Je.createContext(!1);function hu({children:e}){return r.jsx(La.Provider,{value:!0,children:e})}function Ee({children:e,content:t,side:n,align:o,shortcut:s}){const{disableTooltips:a}=k.useConfig(),i=Je.useContext(La);return!t||a||i?e:r.jsxs(pu,{children:[r.jsx(mu,{asChild:!0,children:e}),r.jsxs($a,{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 Da="OpenCX Live Chat";function qr({transparent:e=!1}={}){return`<!DOCTYPE html>
31
+ <html>
32
+ <head>
33
+ <style>
34
+ ${iu}
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 Tn({overrides:e,rootRef:t,style:n,shellRadius:o,children:s}){const{cssOverrides:a}=k.useConfig(),{cssVars:i,theme:c}=de(),{dir:d}=G(),l={"--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,a?r.jsx("style",{children:a}):null,r.jsx("div",{ref:t,style:{...i,...l,...n},"data-version":cu,dir:d,className:A("antialiased font-sans size-full overflow-hidden relative text-secondary-foreground isolate"),children:r.jsx(uu,{delayDuration:200,disableHoverableContent:!0,children:r.jsx(Pd,{children:s})})})]})}function Fa(){const{contentIframeRef:e}=k.useWidget(),{inline:t}=k.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 It({width:e,height:t}){const{isSmallScreen:n}=ye(),{setWidth:o,setHeight:s}=Fa();u.useEffect(()=>{e&&o(e),t&&s(t)},[n,t,e,o,s])}const Yo=T.CircleDashedIcon;function Tt({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 Yo;default:return Z.isExhaustive(e,Tt.name),Yo}})();return r.jsx(n,{className:A("size-4",t)})}function Vr(e){const{t}=G(),{session:n}=k.usePrimitiveState(e.ctx.sessionCtx.sessionState),{messages:o}=k.usePrimitiveState(e.ctx.messageCtx.state),s=k.usePrimitiveState(e.ctx.messageCtx.draftState),a=e.title||(n==null?void 0:n.title)||t("companion_chat_number",{count:e.id});let i=(n==null?void 0:n.lastMessage)??s.text??"";for(let l=o.length-1;l>=0;l--){const p=o[l],m=p.type==="USER"?p.content:p.type==="SYSTEM"?"":p.data.message;if(m.trim()){i=m;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"):a,preview:i.replace(/\s+/g," ").trim(),status:c}}function Yr(){const e=_n(),[t,n]=u.useState(null),[o,s]=u.useState(!1),[a,i]=u.useState(!1),[c,d]=u.useState(!1),l=u.useRef(!1),p=u.useRef(void 0),m=u.useCallback(()=>clearTimeout(p.current),[]);u.useEffect(()=>m,[m]);const f=u.useCallback((h=!1)=>{m(),l.current=!1,h&&i(!1),s(!1)},[m]);return{anchor:t,open:o,animate:a,autoFocus:c,close:f,toggle(h,b=!1){if(m(),o&&l.current){f(!b);return}l.current=!0,n(h),i(b),d(!0),s(!0)},hover(h){m(),!(!e||o)&&(p.current=setTimeout(()=>{l.current=!1,n(h),i(!0),d(!1),s(!0)},100))},enter:m,leave(){m(),l.current||(p.current=setTimeout(()=>f(),200))}}}function Xr(){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 fu({picker:e,...t}){return r.jsxs(r.Fragment,{children:[r.jsx(Xr,{}),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 gu({chat:e,selected:t,onSelect:n,onClose:o}){const{t:s}=G(),{title:a,preview:i,status:c}=Vr(e);return r.jsx(Re,{children:r.jsxs("div",{"data-chat-row":"","data-companion-action":"","data-selected":t||void 0,children:[r.jsx(Ce.RadioItem,{asChild:!0,value:String(e.id),textValue:a,onSelect:d=>{d.preventDefault(),n()},children:r.jsxs("button",{className:ir({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-description":i||void 0,"aria-label":`${a} — ${c}${t?` — ${s("companion_viewing")}`:""}`,"data-chat-select":e.id,children:[r.jsx("span",{"data-chat-indicator":"","aria-hidden":!0,children:r.jsx(Ce.ItemIndicator,{children:r.jsx(T.CheckIcon,{size:14})})}),r.jsx("span",{"data-chat-title":"",children:a}),e.working&&r.jsx(T.LoaderCircleIcon,{size:14,"data-working":"","aria-hidden":!0})]})}),r.jsx(Ce.Item,{asChild:!0,textValue:s("companion_close_chat",{title:a}),onSelect:d=>{d.preventDefault(),o()},children:r.jsx("button",{className:ir({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-label":s("companion_close_chat",{title:a}),"data-chat-close":e.id,children:r.jsx(T.XIcon,{size:14,"aria-hidden":!0})})})]})})}function Gr(e){const{picker:t,portalTarget:n}=e;return t.anchor&&n?r.jsx(xu,{...e,anchor:t.anchor,portalTarget:n}):null}function xu({picker:e,anchor:t,portalTarget:n,placement:o,onSelected:s}){const{open:a,animate:i,autoFocus:c,close:d,enter:l,leave:p}=e,{chats:m,activeId:f,selectChat:h,newChat:b,closeChat:g}=k.useCompanionChats(),{canCreateNewSession:C}=k.useSessions(),{t:x,dir:N}=G(),{cssVars:w,theme:S}=de(),j=u.useRef(null),v=u.useRef(t.ownerDocument.activeElement),_=u.useCallback(E=>{E&&!j.current&&(v.current=t.ownerDocument.activeElement),j.current=E},[t]),R=u.useRef(!1),I=u.useRef({onClose:d,onSelected:s});I.current={onClose:d,onSelected:s};const M=u.useMemo(()=>({current:{getBoundingClientRect(){let E=t.getBoundingClientRect(),z=t.ownerDocument.defaultView;const H=n.ownerDocument.defaultView;for(;z&&z!==H;){const L=z.frameElement;if(!L)break;const q=L.getBoundingClientRect(),X=q.width/L.offsetWidth||1,U=q.height/L.offsetHeight||1;E=new DOMRect(q.left+E.left*X,q.top+E.top*U,E.width*X,E.height*U),z=L.ownerDocument.defaultView}return E}}}),[t,n]),D=m.filter(E=>E.working).length;u.useEffect(()=>{if(!a||t.ownerDocument===n.ownerDocument)return;const E=H=>{H.composedPath().includes(t)||H.type==="focusin"&&!c&&H.target===v.current||I.current.onClose(H.type==="focusin")},z=t.ownerDocument;return z.addEventListener("pointerdown",E,!0),z.addEventListener("focusin",E),()=>{z.removeEventListener("pointerdown",E,!0),z.removeEventListener("focusin",E)}},[t,n,a,c]),u.useLayoutEffect(()=>{var E,z,H;(E=j.current)==null||E.toggleAttribute("inert",!a),a&&c&&((H=(z=j.current)==null?void 0:z.querySelector('[aria-checked="true"]'))==null||H.focus({preventScroll:!0}))},[a,c]);function O(E){var z,H;t.focus({preventScroll:!0}),E===void 0?b():h(E),I.current.onClose(!0),(H=(z=I.current).onSelected)==null||H.call(z)}function B(E){var L,q,X,U;const z=m.findIndex(F=>F.id===E),H=m[z+1]??m[z-1];E===f?(t.focus({preventScroll:!0}),I.current.onClose(!0)):(q=(L=j.current)==null?void 0:L.querySelector(H?`[data-chat-select="${H.id}"]`:"[data-new-chat]"))==null||q.focus({preventScroll:!0}),g(E),E===f&&((U=(X=I.current).onSelected)==null||U.call(X))}return Vt.createPortal(r.jsxs(Ce.Root,{open:a,onOpenChange:E=>{!E&&!R.current&&I.current.onClose()},modal:!1,dir:N==="rtl"?"rtl":"ltr",children:[r.jsx(Ce.Anchor,{virtualRef:M}),r.jsxs(Ce.Content,{ref:_,loop:!0,side:o==="above"?"top":"bottom",align:o==="below"?"start":"center",sideOffset:6,collisionPadding:12,updatePositionStrategy:"always","aria-label":x("companion_chats"),"data-companion-chat-picker":"","data-motion":i?"pointer":"instant",onEntryFocus:E=>{var z,H,L;E.preventDefault(),c?(H=(z=j.current)==null?void 0:z.querySelector('[aria-checked="true"]'))==null||H.focus({preventScroll:!0}):(R.current=!0,(L=v.current)==null||L.focus({preventScroll:!0}),R.current=!1)},onCloseAutoFocus:E=>{E.preventDefault()},onEscapeKeyDown:E=>{E.preventDefault(),t.focus({preventScroll:!0}),I.current.onClose(!0)},onFocusOutside:E=>{var z,H;((z=j.current)!=null&&z.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:p,onPointerDown:E=>E.stopPropagation(),onMouseDown:E=>E.stopPropagation(),onClick:E=>E.stopPropagation(),onKeyDown:E=>{E.key==="Tab"&&(E.preventDefault(),t.focus({preventScroll:!0}),I.current.onClose(!0))},style:{...w,zIndex:S.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(Xr,{}),r.jsx("style",{children:`
61
+ [data-companion-chat-picker] {
62
+ transform-origin: var(--radix-popper-transform-origin);
63
+ animation: opencx-menu-in ${we.duration*1e3}ms ${kd};
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(Ce.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:x("companion_chats")}),D>0&&r.jsx("span",{role:"status",children:x("companion_working_chats",{count:D})})]}),r.jsx(Ce.RadioGroup,{value:String(f),children:m.map(E=>r.jsx(gu,{chat:E,selected:E.id===f,onSelect:()=>O(E.id),onClose:()=>B(E.id)},E.id))}),r.jsx(Ce.Separator,{style:{height:1,background:"hsl(var(--opencx-border) / .4)",margin:"5px 4px"}}),r.jsx(Ce.Group,{children:r.jsx(Ce.Item,{asChild:!0,disabled:!C,onSelect:E=>{E.preventDefault(),O()},children:r.jsxs(V,{variant:"ghost",size:"selfless",type:"button","data-companion-action":"","data-new-chat":"",disabled:!C,children:[r.jsx(T.PlusIcon,{size:14,"aria-hidden":!0}),x("new_conversation")]})})})]})]}),n)}function An(){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)}},[]),e}function bu(){const{chats:e,openChats:t,activeId:n}=k.useCompanionChats(),o=e.find(h=>h.id===n),s=Vr(o),{t:a}=G(),i=Yr(),c=An(),d=s.title,l=t.filter(h=>h.id!==n),p=l.filter(h=>h.working).length,m=`${a("companion_other_sessions",{count:l.length})}${p?` · ${a("companion_working_chats",{count:p})}`:""}`,f=`${a("companion_switch_chat")}: ${d}${l.length?` · ${m}`:""}`;return r.jsxs(r.Fragment,{children:[r.jsxs(fu,{picker:i,"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":f,children:[o.working&&r.jsx(T.LoaderCircleIcon,{"aria-label":a("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:m}),p>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"})]}),i.anchor&&c&&r.jsx(Gr,{picker:i,portalTarget:c,placement:"below"})]})}function wu(){var n;const e=Fe(),t=(n=e.config.customComponents)==null?void 0:n.headerBottom;return t?r.jsx(t,{...e}):null}function vu({fallback:e}){var o;const t=Fe(),n=(o=t.config.customComponents)==null?void 0:o.headerTitle;return n?r.jsx(n,{...t}):e}function Ha(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 Z.isExhaustive(e,Ha.name),n}}function Wa(){const{widgetCtx:{org:e}}=k.useWidget(),{routerState:{screen:t}}=k.useWidgetRouter(),{textContent:n}=k.useConfig();return Ha(t,n,e.name)}function yu(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:Z.isExhaustive(e,Wa.name);return}}function ku(){const{router:e}=k.useConfig(),{routerState:{screen:t},toLandingScreen:n}=k.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 ju({button:e}){const{setIsOpen:t}=k.useWidgetTrigger(),{isSmallScreen:n}=ye(),o=Fe();if(n&&e.hideOnSmallScreen||!n&&e.hideOnLargeScreen)return null;const s=()=>{var a;e.handleClick?e.handleClick():t(!1),(a=e.onClicked)==null||a.call(e,o)};return r.jsx(V,{variant:"ghost",size:"fit",className:"rounded-full",onClick:s,children:r.jsx(Tt,{name:e.icon})})}function ur({button:e}){const[t,n]=u.useState(!1),{routerState:{screen:o}}=k.useWidgetRouter(),{isSmallScreen:s}=ye(),{theme:a}=de(),{setWidth:i,setHeight:c}=Fa(),d=Fe();if(o!=="chat"&&o!=="sessions")return null;const l=(()=>{switch(o){case"chat":return a.screens.chat.height;case"sessions":return a.screens.sessions.height;default:return Z.isExhaustive(o,ur.name),a.screens.chat.height}})(),p=(()=>{switch(o){case"chat":return a.screens.chat.width;case"sessions":return a.screens.sessions.width;default:return Z.isExhaustive(o,ur.name),a.screens.chat.width}})(),m=()=>{var f;n(h=>{const b=!h;return c(b?"100vh":l),i(b?`max(40vw, ${p})`:p),b}),(f=e.onClicked)==null||f.call(e,d)};return s&&e.hideOnSmallScreen||!s&&e.hideOnLargeScreen?null:r.jsx(V,{variant:"ghost",size:"fit",className:"rounded-full",onClick:m,children:r.jsx(Tt,{name:e.icon||(t?e.shrinkIcon:e.expandIcon)})})}function Ba({button:e}){var x,N;const{close:t}=En(),{widgetCtx:n}=k.useWidget(),{setIsOpen:o}=k.useWidgetTrigger(),{resolveSession:s,sessionState:a}=k.useSessions(),{isSmallScreen:i}=ye(),c=Fe(),{t:d}=G(),l=!a.session,p=((x=a.session)==null?void 0:x.isOpened)===!1,m=e.onResolved||"stay-in-chat",f=e.behaviorBeforeSessionCreation||"disabled",h=e.behaviorIfSessionIsResolved||"disabled",b=!!(a.isResolvingSession||l&&f==="disabled"||p&&h==="disabled"),g=async()=>{const{success:w,error:S}=await s();if(t(),!w)return Z.log.error("failed to resolve session",S),!1;switch(m){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:Z.isExhaustive(m,Ba.name);break}return!0},C=()=>{if(l)switch(f){case"disabled":return;case"close-widget":o(!1);break;default:Z.isExhaustive(f,C.name)}if(p)switch(h){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:Z.isExhaustive(h,C.name)}};return i&&e.hideOnSmallScreen||!i&&e.hideOnLargeScreen?null:((N=e.confirmation)==null?void 0:N.type)==="modal"&&!p&&!l?r.jsx(Jt,{trigger:r.jsx(V,{variant:"ghost",size:"fit",className:"rounded-full",disabled:b,onClick:()=>{var w;return(w=e.onClicked)==null?void 0:w.call(e,c)},children:r.jsx(Tt,{name:e.icon})}),children:r.jsxs(Zt,{children:[r.jsx(Or,{children:r.jsx(Lr,{children:e.confirmation.title||d("close_conversation_title")})}),r.jsx($r,{children:r.jsx(Dr,{children:e.confirmation.description||d("close_conversation_description")})}),r.jsxs(za,{children:[r.jsx(V,{variant:"secondary",onClick:t,disabled:a.isResolvingSession,children:e.confirmation.cancelButtonText||d("close_conversation_cancel")}),r.jsx(V,{variant:"destructive",onClick:async()=>{var S,j;await g()&&((j=(S=e.confirmation)==null?void 0:S.onResolved)==null||j.call(S,c))},disabled:a.isResolvingSession,children:e.confirmation.confirmButtonText||d("close_conversation_confirm")})]})]})}):r.jsx(V,{variant:"ghost",size:"fit",className:"rounded-full",onClick:()=>{var w;p||l?C():g(),(w=e.onClicked)==null||w.call(e,c)},disabled:b,children:r.jsx(Tt,{name:e.icon})})}function pr({button:e}){switch(e.functionality){case"close-widget":return r.jsx(ju,{button:e});case"expand-shrink":return r.jsx(ur,{button:e});case"resolve-session":return r.jsx(Ba,{button:e});default:return Z.isExhaustive(e,pr.name),null}}const Cu={functionality:"close-widget",hideOnLargeScreen:!0,icon:"X"};function Su(){const{routerState:{screen:e}}=k.useWidgetRouter(),{headerButtons:t}=k.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(pr,{button:Cu}):r.jsx(r.Fragment,{children:n.map(o=>r.jsx(pr,{button:o},`${o.functionality}-${o.icon}`))})}function Ua(){const e=k.useConfig(),t=e.displayMode==="companion"&&!e.inline,{routerState:{screen:n}}=k.useWidgetRouter(),o=yu(n),s=Wa();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(ku,{}),r.jsx("div",{className:A("min-w-0 flex-1 h-8 flex items-center",n==="sessions"&&"ps-2"),children:r.jsx(vu,{fallback:t&&n!=="sessions"?r.jsx(bu,{}):r.jsx("h2",{className:"font-semibold",children:s})})}),r.jsx(Su,{})]}),r.jsx(wu,{})]})}function qa({className:e}){return r.jsx(T.LoaderIcon,{className:A("size-4 animate-spin",e)})}function Nu(){const{messagesState:{isInitialFetchLoading:e}}=k.useMessages(),{isSmallScreen:t}=ye(),{activeMode:n,Component:o}=k.useModes();return{isCanvasOpen:!e&&!t&&!!n&&!!o}}function _u({isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n,...o}){const{componentStore:s}=k.useWidget();if(o.type!=="AGENT"&&o.type!=="AI")return null;if(o.data.action){const i=s.getComponent(o.data.action.name);if(i)return r.jsx(i,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}const a=s.getComponent(o.component);return a?r.jsx(a,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n}):r.jsx(lr,{...o,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}function zn({suggestion:e,className:t,...n}){const{sendMessage:o}=k.useMessages(),s=()=>{const a=e.trim();a&&o({content:a})};return r.jsx(V,{...P("chat/suggested_reply_btn"),size:"sm",className:A("rounded-xl w-fit",t),...n,onClick:s,children:e})}function Va({messages:e,className:t,containerClassName:n}){var i,c;const{timestamps:o}=k.useConfig();if(!((i=o==null?void 0:o.perMessageGroup)!=null&&i.enabled))return null;const s=(c=e[e.length-1])==null?void 0:c.timestamp;if(!s)return null;const a=(()=>{try{return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}catch(d){return Z.log.error("failed to format timestamp",d),null}})();return a?r.jsx("div",{className:n,children:r.jsx("span",{className:A("text-xs text-muted-foreground",t),children:a})}):null}const Eu=2e3;function Tu(e){return e.map(t=>Pa(t.data.message).trim()).filter(t=>t.length>0).join(`
109
+
110
+ `)}function Ya(){const{messageActions:e}=k.useConfig(),t=k.useDisplayMode();return(e==null?void 0:e.copy)??t==="companion"}function Xa({messages:e}){const{t}=G(),{messageActions:n}=k.useConfig(),o=(n==null?void 0:n.display)==="always",[s,a]=u.useState(!1),i=u.useRef(null);u.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const c=Tu(e),d=typeof navigator<"u"?navigator.clipboard:void 0;if(!d||c.length===0)return null;const l=()=>{d.writeText(c).then(()=>{a(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),Eu)},m=>Z.log.warn("copying the reply failed",m))},p=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(Ee,{content:p,side:"bottom",align:"start",children:r.jsx("button",{...P("chat/agent_msg_group/actions/copy"),type:"button","aria-label":p,"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 Au(e){return e.type==="AI"&&e.data.variant!=="error"}function vn({messages:e,agent:t,suggestedReplies:n,actions:o=!0}){const s=Ya(),a=e.filter(Au);return r.jsxs("div",{...P("chat/agent_msg_group/root"),className:A("group flex items-end gap-2"),children:[r.jsx(Ee,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(dr,{...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(Ee,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(dr,{...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((i,c,d)=>r.jsx(_u,{isFirstInGroup:c===0,isLastInGroup:c===d.length-1,isAloneInGroup:d.length===1,...i},i.id)),r.jsx(Va,{messages:e}),o&&s&&a.length>0&&r.jsx(Xa,{messages:a})]})]}),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((i,c)=>r.jsx(zn,{suggestion:i},`${i}-${c}`))})]})]})}const Xo=["⠏","⠗","⠧","⠷","⠾","⠽","⠻","⠟"];function Kr({className:e}){const t=W.useReducedMotion(),[n,o]=u.useState(0);return u.useEffect(()=>{if(t)return;const s=setInterval(()=>o(a=>(a+1)%Xo.length),80);return()=>clearInterval(s)},[t]),r.jsx("span",{className:A("select-none",e),"aria-hidden":!0,children:Xo[n]})}function Go({turn:e,agent:t,timestamp:n}){const{componentStore:o,config:s,widgetCtx:a}=k.useWidget(),i=Ya(),c=o.getComponent("agent_chat_steps"),d=o.getComponent("agent_chat_spec"),l=o.getComponent("loading"),[p]=u.useState(()=>new Date().toISOString()),m=n??p,f=Z.resolveClientPresentation(a.agent.presentation,s.presentation),h=k.applyPresentation(e.items,f),b=e.active&&(f==null?void 0:f.streaming)===!1&&!h.some(g=>g.kind==="questions");return r.jsxs("div",{...P("chat/streaming_turn/root"),className:"group flex flex-col gap-2",children:[h.map((g,C)=>g.kind==="text"?r.jsx(vn,{messages:[{id:`streaming-${C}`,type:"AI",component:"bot_message",timestamp:m,data:{message:g.text},agent:t}],agent:t,actions:!1},`text-${C}`):g.kind==="spec"?d&&r.jsx(d,{parts:g.parts,active:e.active},`spec-${C}`):g.kind==="questions"||g.kind==="plan"||g.kind==="connection"?null:c&&r.jsx(c,{active:e.active,steps:g.steps},`steps-${C}`)),b&&l?r.jsx(l,{agent:t}):e.active&&!zu(h)&&r.jsx("div",{...P("chat/streaming_turn/working"),className:"flex h-5 items-center ps-1",children:r.jsx(Kr,{className:"text-[14px] leading-none text-primary/70"})}),!e.active&&i&&r.jsx(Xa,{messages:h.flatMap(g=>g.kind==="text"?[{data:{message:g.text}}]:[])})]})}function zu(e){const t=e.at(-1);return(t==null?void 0:t.kind)==="steps"&&t.steps.some(n=>!n.done)}function Iu({parts:e,active:t=!1}){const n=u.useMemo(()=>wd(e),[e]);return r.jsx(Na,{spec:n,active:t})}function Mu({plan:e,active:t}){const[n,o]=u.useState(!1),s=u.useId(),a=W.useReducedMotion(),i=e.filter(p=>p.status==="completed").length,c=e.find(p=>p.status==="in_progress")??e.find(p=>p.status==="pending")??e[0],d=2*Math.PI*8,l=d*(1-(e.length>0?i/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(p=>!p),"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:a?{duration:0}:Te,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:[i,"/",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:a?{duration:0}:we,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:a?"auto":0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:a?"auto":0,opacity:0,transition:we},transition:a?we:Te,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((p,m)=>r.jsxs("li",{className:"flex items-start gap-2.5 py-1.5 text-sm","data-plan-status":p.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:we,children:p.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"})}):p.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"})},p.status)})}),r.jsx("span",{className:A(p.status==="completed"?"text-primary/50 line-through":p.status==="in_progress"?"font-medium text-primary":"text-primary/60"),children:p.step})]},m))})},"plan-steps")})})]})}function Ga(){var n,o;const e=Fe();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 Ka(){var n;const e=Fe(),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 Za(e){const t=[];let n=null;return e.forEach(o=>{var s,a,i,c,d,l;(((s=n==null?void 0:n[0])==null?void 0:s.type)!==o.type||((a=n[0])==null?void 0:a.type)==="AGENT"&&o.type==="AGENT"&&(((i=o.agent)==null?void 0:i.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 mr(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="USER"}function Ru(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AI"}function Pu(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AGENT"}function Ja(){const{messagesState:{messages:e}}=k.useMessages(),{chatBannerItems:t}=k.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(Fr,{children:n})},`${n}-${s}`))})}const Ou=10*1024,Ko=new Map;function $u(e){const t=Ko.get(e);if(t!==void 0)return t;const n=Lu(e);return Ko.set(e,n),n}function Lu(e){const t=e.trim();if(!t||t.length>Ou||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 Du=Ds.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 Fu({className:e,variant:t,...n}){return r.jsx("div",{className:A(Du({variant:t}),e),...n})}function Qa({customStatus:e,className:t,dotClassName:n}){const o=e.icon?$u(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 ei({customStatus:e,className:t}){return r.jsxs(Fu,{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(Qa,{customStatus:e}),r.jsx("span",{className:"truncate",children:e.name})]})}function ti(){const{sessionState:{session:e}}=k.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(Jt,{trigger:r.jsx(V,{variant:"ghost",size:"selfless",className:"rounded-full",children:r.jsx(ei,{customStatus:t})}),children:r.jsxs(Zt,{withClose:!0,children:[r.jsxs(Or,{children:[r.jsx(Qa,{customStatus:t,className:"size-8 mx-auto",dotClassName:"size-3 mx-auto"}),r.jsx(Lr,{children:t.name})]}),t.description&&r.jsx($r,{children:r.jsx(Dr,{children:t.description})})]})})},t.id)})}function ni(){var c;const{messagesState:{messages:e}}=k.useMessages(),t=k.useConfig(),n=k.useBot(),{advancedInitialMessages:o=[],initialQuestions:s,initialQuestionsPosition:a}=t;if(e.length>0)return null;const i=o.length?o.map(d=>d.message):(c=t.initialMessages)!=null&&c.length?t.initialMessages:["Hello, how can I help you?"];return r.jsx(vn,{messages:i.map((d,l)=>({component:"bot_message",data:{message:d},id:`${l}-${d}`,type:"AI",timestamp:null})),suggestedReplies:a==="below-initial-messages"?s:void 0,agent:n})}function ri({src:e,alt:t,title:n,note:o,shape:s="strip",className:a,children:i,...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",a),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}),i]})}const Zr=["#opencx-root","[data-opencx-root]","[data-opencx-overlay]"],pt='input,textarea,select,[contenteditable]:not([contenteditable="false"]),[role="textbox"],[role="searchbox"],[role="combobox"]',Hu=[...Zr,"[data-opencx-private]",'[aria-hidden="true"]',"[hidden]","script","style","noscript"].join(",");function oi(e){var n;if(e.matches(Hu))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 Ae(e){for(let t=e;t;t=t.parentElement)if(oi(t))return!0;return!1}function si(e){if(Ae(e)||e.closest(pt))return"";const t=[],n=o=>{if(o instanceof Element){if(o!==e&&oi(o)||o.matches(pt))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 Jr(e){try{const t=new URL(e,window.location.href);return t.protocol==="http:"||t.protocol==="https:"?`${t.origin}${t.pathname}`:""}catch{return""}}function Wt(e){return e.getRootNode()===document&&!Ae(e)&&!e.closest(pt)&&!e.matches("canvas,iframe,video,object,embed")&&!Array.from(e.querySelectorAll("*")).some(t=>Ae(t)||t.matches(`${pt},canvas,iframe,video,object,embed`))}const Wu=480,Bu=3e3,Bt=new WeakMap,hr=new WeakMap;async function Uu(e){if(!Wt(e))return null;const t=e.getBoundingClientRect();if(t.width<1||t.height<1)return null;const n=Math.min(2,Math.max(.5,Wu/Math.max(t.width,t.height))),o=dc.toJpeg(e,{quality:.85,pixelRatio:n,backgroundColor:"#ffffff",filter:a=>!(a instanceof Element)||Wt(a)}),s=new Promise(a=>setTimeout(()=>a(null),Bu));try{return await Promise.race([o,s])}catch{return null}}function qu(e,t){hr.set(e,t),Bt.set(e,Uu(t))}const fr=new WeakMap;function Vu(e,t){if(fr.has(e))return;const n=Bt.get(e);if(!n)return;const o=n.then(s=>{const a=hr.get(e);if(!(a!=null&&a.isConnected)||!Wt(a))return null;const i=s?Xu(s,"page-mark.jpg"):null;return i?t(i):null}).catch(()=>null).then(s=>{const a=hr.get(e);return!(a!=null&&a.isConnected)||!Wt(a)?null:(s&&(e.snapshotUrl=s),s)});fr.set(e,o)}async function Yu(e,t){if(e.snapshotUrl)return e.snapshotUrl;const n=fr.get(e);if(!n)return null;const o=new Promise(s=>setTimeout(()=>s(null),t));return Promise.race([n,o])}function Xu(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 a=atob(s),i=new Uint8Array(a.length);for(let c=0;c<a.length;c++)i[c]=a.charCodeAt(c);return new File([i],t,{type:o})}catch{return null}}function Gu(e){return Bt.get(e)}function Ku(e,t){const n=Bt.get(e);n&&Bt.set(t,n)}function ai(e){const[t,n]=u.useState(null);return u.useEffect(()=>{var s;if(n(null),!e)return;let o=!1;return(s=Gu(e))==null||s.then(a=>{!o&&a&&n(a)}),()=>{o=!0}},[e]),t}function Zu({element:e}){const t=ai(e.mark)??e.snapshotUrl??null,n=e.note??e.name;return t?r.jsx(ri,{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 Ju=150,Qu=40,ep=3;function tp(e,t){const n=new Map;for(const a of e){const i=n.get(a.type);i?i.push(a):n.set(a.type,[a])}const o=[],s=[];for(const[a,i]of Array.from(n)){const c=t.has(a)?i:i.slice(0,ep);o.push({type:a,items:c,hidden:i.length-c.length}),s.push(...c)}return{groups:o,visible:s}}function np(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 rp(e,t){const n=t.trim().toLowerCase();if(!n)return[...e];const o=s=>{var i;const a=s.title.toLowerCase();return a.startsWith(n)?0:a.includes(n)?1:(i=s.description)!=null&&i.toLowerCase().includes(n)?2:-1};return e.map((s,a)=>({item:s,index:a,rank:o(s)})).filter(s=>s.rank>=0).sort((s,a)=>s.rank-a.rank||s.index-a.index).map(s=>s.item)}const Ft=e=>`@${e.title}`;function Zo(e,t){const n=[];for(const o of t){const s=Ft(o);let a=0;for(;;){const i=e.indexOf(s,a);if(i===-1)break;n.push({start:i,end:i+s.length}),a=i+s.length}}return n}function op({text:e,setText:t,inputRef:n}){const{mentions:o}=k.useConfig(),{widgetCtx:s}=k.useWidget(),a=o==null?void 0:o.items,i=o==null?void 0:o.search,c=u.useMemo(()=>{if(i)return i;if(a)return z=>rp(a,z)},[i,a]),d=!!c&&s.features.pageContext,{mentions:l,setMentions:p}=k.useComposerDraft(),[m,f]=u.useState(null),[h,b]=u.useState([]),[g,C]=u.useState(()=>new Set),[x,N]=u.useState(0),[w,S]=u.useState(!1),{groups:j,visible:v}=u.useMemo(()=>tp(h,g),[g,h]);u.useEffect(()=>{p(z=>{const H=z.filter(L=>e.includes(Ft(L)));return H.length===z.length?z:H})},[e,p]);const _=u.useCallback((z="nearest")=>{if(!d)return;const H=n.current;let L=(H==null?void 0:H.selectionStart)??e.length;if(H&&H.selectionStart===H.selectionEnd){const U=Zo(e,l).find(F=>L>F.start&&L<F.end);U&&(L=z==="forward"?U.end:z==="backward"||L-U.start<U.end-L?U.start:U.end,H.setSelectionRange(L,L))}const q=np(e,L),X=q&&l.some(U=>e.startsWith(Ft(U),q.start))?null:q;f(U=>(U==null?void 0:U.start)===(X==null?void 0:X.start)&&(U==null?void 0:U.query)===(X==null?void 0:X.query)?U:X)},[d,n,l,e]);u.useEffect(()=>_(),[_]);const R=u.useRef(0);u.useEffect(()=>{if(!m||!c){b([]),S(!1);return}const z=++R.current;S(!0);const H=setTimeout(()=>{Promise.resolve().then(()=>c(m.query)).then(L=>{z===R.current&&(b(L.slice(0,Qu)),C(new Set),N(0),S(!1))},L=>{z===R.current&&(Z.log.warn("mentions search failed",L),b([]),S(!1))})},Ju);return()=>clearTimeout(H)},[m,c]);const I=u.useCallback(()=>{R.current+=1,f(null),b([]),S(!1)},[]),M=u.useCallback(z=>{if(!m)return;const H=m.start+1+m.query.length,L=`${Ft(z)} `,q=e.slice(0,m.start)+L+e.slice(H);t(q),p(U=>U.some(F=>F.type===z.type&&F.id===z.id)?U:[...U,z]),I();const X=m.start+L.length;requestAnimationFrame(()=>{const U=n.current;U&&(U.focus(),U.setSelectionRange(X,X))})},[m,I,n,t,p,e]),D=u.useCallback(z=>{C(H=>new Set(H).add(z))},[]),O=d&&m!==null,B=u.useCallback(z=>{const H=n.current;if(d&&H&&H.selectionStart===H.selectionEnd&&(z.key==="Backspace"||z.key==="Delete")){const L=H.selectionStart,q=Zo(e,l).find(X=>z.key==="Backspace"?X.end===L:X.start===L);if(q){z.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(z.key==="Escape")return z.preventDefault(),I(),!0;if(v.length===0)return!1;if(z.key==="ArrowDown")return z.preventDefault(),N(L=>(L+1)%v.length),!0;if(z.key==="ArrowUp")return z.preventDefault(),N(L=>(L-1+v.length)%v.length),!0;if(z.key==="Enter"||z.key==="Tab"){z.preventDefault();const L=v[x];return L&&M(L),!0}return!1},[I,d,x,n,O,M,l,t,e,v]),E=u.useCallback(()=>{p([]),I()},[I,p]);return u.useMemo(()=>({picked:l,isOpen:O,anchorIndex:(m==null?void 0:m.start)??null,preview:(o==null?void 0:o.preview)!==!1,groups:j,visible:v,expandGroup:D,searching:w,highlighted:x,setHighlighted:N,pick:M,onKeyDown:B,onCaretMove:_,reset:E}),[l,O,m,o==null?void 0:o.preview,j,v,D,w,x,M,B,_,E])}function ii({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(Ft))).sort((c,d)=>d.length-c.length),s=[];let a=e,i=0;for(;a.length>0;){let c=-1,d="";for(const l of o){const p=a.indexOf(l);p!==-1&&(c===-1||p<c)&&(c=p,d=l)}if(c===-1){s.push(a);break}c>0&&s.push(a.slice(0,c)),s.push(u.createElement("span",{...P("chat/mention"),key:i++,className:A("rounded-sm px-0.5 -mx-0.5",n)},d)),a=a.slice(c+d.length)}return r.jsx(r.Fragment,{children:s})}function sp({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((a,i)=>r.jsx(Zu,{element:a},`${a.name}-${i}`))}),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(a=>r.jsx(Ma,{attachment:a},a.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(ii,{text:e.content,mentions:e.mentions,tokenClassName:"bg-primary-foreground/20 font-medium"})})]})}function ap({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(sp,{message:t,isFirstInGroup:n===0,isLastInGroup:n===o.length-1,isAloneInGroup:o.length===1},t.id)),r.jsx(Va,{messages:e,containerClassName:"ms-auto"})]})}function gr({groups:e,pendingReply:t=!1}){const{humanAgent:n}=k.useConfig(),o=k.useBot();return r.jsx(r.Fragment,{children:e.map((s,a)=>{var c,d;const i=(c=s[0])==null?void 0:c.id;if(!i)return null;if(mr(s))return r.jsx(ap,{messages:s},i);if(Ru(s))return r.jsx(vn,{messages:s,agent:o,actions:!t||a!==e.length-1},i);if(Pu(s)){const l=(d=s[0])==null?void 0:d.agent;return r.jsx(vn,{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},i)}return null})})}const ip=150;function cp({scrollHeight:e,scrollTop:t,clientHeight:n},o=ip){return e-t-n<o}function lp(e){const t=u.useRef(null),n=u.useRef(!0),[o,s]=u.useState(!1),a=u.useRef(null),[i]=u.useState(()=>new Set),c=u.useCallback(()=>{const l=t.current,p=l?cp(l):!0;n.current=p,s(!p)},[]),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 p=t.current;p&&(p.scrollTop=p.scrollHeight)},0);return()=>clearTimeout(l)},e),u.useEffect(()=>{const l=t.current;if(!l)return;const p=new ResizeObserver(()=>{n.current&&(l.scrollTop=l.scrollHeight)});return a.current=p,()=>{p.disconnect(),a.current=null,i.clear()}},[i]),u.useEffect(()=>{const l=t.current,p=a.current;!l||!p||(i.forEach(m=>{m.isConnected||(p.unobserve(m),i.delete(m))}),Array.from(l.children).forEach(m=>{i.has(m)||(p.observe(m),i.add(m))}))}),{containerRef:t,handleScroll:c,showScrollDown:o,scrollToBottom:d}}function dp(){const{messagesState:{messages:e}}=k.useMessages(),{isStreaming:t,liveItems:n,turnSources:o,liveTurnKey:s,turnFailed:a,retryFailedTurn:i}=k.useAgentChatUi(),{componentStore:c}=k.useWidget(),{t:d}=G(),l=k.useBot(),{sessionState:{session:p}}=k.useSessions(),m=u.useMemo(()=>k.sessionPlan({liveItems:n,turnSources:o}),[n,o]),f=u.useMemo(()=>Za(e),[e]),h=u.useMemo(()=>{const R=new Map;for(const I of o)for(const M of I.rowIds)R.set(M,I);return R},[o]),b=u.useMemo(()=>{for(let R=f.length-1;R>=0;R-=1){const I=f[R];if(I&&mr(I))return R}return-1},[f]),g=n.length>0,{nodes:C,renderedSourceKeys:x}=u.useMemo(()=>{const R=[],I=new Set;return f.forEach((M,D)=>{var z;const O=(z=M[0])==null?void 0:z.id;if(!O)return;if(mr(M)){R.push(r.jsx(gr,{groups:[M]},O));return}let B=[];const E=()=>{var L;const H=(L=B[0])==null?void 0:L.id;H&&R.push(r.jsx(gr,{groups:[B]},H)),B=[]};for(const H of M){const L=h.get(H.id);L?(E(),I.has(L.key)||(I.add(L.key),R.push(r.jsx(Go,{turn:{active:!1,items:L.items},agent:l,timestamp:H.timestamp},L.key)))):g&&D>b||B.push(H)}E()}),{nodes:R,renderedSourceKeys:I}},[f,h,g,b,l]),N=s!==null&&n.length>0&&!x.has(s),w=c.getComponent("loading"),{containerRef:S,handleScroll:j,showScrollDown:v,scrollToBottom:_}=lp([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:S,onScroll:j,className:"max-h-full relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(ti,{}),r.jsx(Ja,{}),r.jsx(ni,{}),[...C,...N?[r.jsx(Go,{turn:{active:t,items:n},agent:l},s)]:[]],t&&n.length===0&&w&&r.jsx(w,{agent:l}),a&&!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:i,className:"font-medium underline underline-offset-2 hover:opacity-80",children:d("turn_failed_retry")})]}),r.jsx(Ka,{}),r.jsx(Ga,{})]}),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:_,"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"}))})]}),m&&m.length>0&&r.jsx("div",{...P("chat/session-plan"),className:"shrink-0 px-4 pb-2",children:r.jsx(Mu,{plan:m,active:t},(p==null?void 0:p.id)??"new-session")})]})}function up(){const e=Fe(),{activeMode:t,Component:n}=k.useModes(),{sendMessage:o}=k.useMessages(),{createStateCheckpoint:s}=k.useSessions(),[a,i]=u.useState(!1),c=async d=>{try{i(!0),await o(d)}catch(l){Z.log.error("mode component send failed",l)}finally{i(!1)}};return!t||!n?null:r.jsx(n,{...e,mode:t,createStateCheckpoint:s,sendMessage:c,isSendingMessage:a})}function ci(){const{requireInitialQuestion:e,initialQuestions:t}=k.useConfig(),{messagesState:n}=k.useMessages();return e===!0&&n.messages.length===0&&(t==null?void 0:t.some(o=>o.trim().length>0))===!0}function xr({isStreaming:e,messages:t,session:n}){return!e&&Z.isAwaitingRequiredTap(t,n)}const je=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}}})});je.displayName="MotionDiv__VerticalReveal";const pp=[{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 mp(){const{isSmallScreen:e}=ye(),{t}=G(),{submitCsat:n,isCsatRequested:o,isCsatSubmitted:s,submittedScore:a,submittedFeedback:i}=k.useCsat(),[c,d]=u.useState(null),[l,p]=u.useState(null),m=h=>{d(b=>b===h?null:h)},f=()=>{c&&n({score:c,feedback:l||void 0})};return!o&&!s?null:r.jsxs("div",{className:"w-1/2 min-w-80 max-w-96 mx-auto overflow-hidden",children:[r.jsx(W.AnimatePresence,{mode:"wait",children:o&&!c?r.jsx(je,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:t("csat_title")})},"csat-requested-title"):s?r.jsx(je,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:t("csat_submitted_title")})},"csat-submitted-title"):null}),r.jsx("div",{dir:"ltr",className:A("flex gap-4 justify-between pt-2 px-2 pb-2","transition-all",s&&"gap-0 justify-center"),children:pp.map(h=>r.jsx(V,{variant:h.value===c?"secondary":"ghost",size:"selfless",className:A("transition-all overflow-hidden","text-2xl size-8 rounded-full","opacity-35","hover:opacity-100",!c&&"opacity-100",h.value===c&&"opacity-100",s&&h.value!==a&&"opacity-0 size-0",s&&h.value===a&&"opacity-100 size-fit text-4xl"),onClick:o?()=>m(h.value):void 0,children:h.emoji},h.value))}),r.jsx(W.AnimatePresence,{mode:"wait",children:(c||a)&&r.jsx(je,{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",e?"text-[16px]":"text-sm",s&&"text-center"),value:s?i||"":l||"",onChange:o?h=>p(h.target.value):void 0,readOnly:s,placeholder:o?t("csat_feedback_placeholder"):void 0}),r.jsx(V,{size:"fit",onClick:f,disabled:!c,className:A("transition-all overflow-hidden","rounded-full size-8 flex items-center justify-center p-0",s&&"opacity-0 size-0"),children:r.jsx(T.ArrowUpIcon,{className:"size-4"})})]})},"feedback-box")}),r.jsx("div",{className:A("h-0 transition-[height]",s&&"h-4")})]})}function hp(){const{t:e}=G(),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(zn,{suggestion:n,className:"flex-1"},n))})}function br(){const{sessionState:e}=k.useSessions(),{chatFooterItems:t}=k.useConfig(),n=!!e.session&&!e.session.isOpened,o=!n;return r.jsx(W.AnimatePresence,{mode:"wait",children:t==null?void 0:t.map((s,a)=>s.showWhenSessionIsOpen===!1&&o||s.showWhenSessionIsResolved===!1&&n?null:r.jsx(je,{children:r.jsx("div",{className:"pb-2 text-center text-xs",children:r.jsx(tu,{children:s.message})})},`${s.message}-${a}`))})}function yn(){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 fp({sessionId:e,active:t}){var i;const{widgetCtx:n,config:o}=k.useWidget(),[s,a]=u.useState(null);return u.useEffect(()=>{var p;if(a(null),!t||((p=o.capabilities)==null?void 0:p.connections)!==!0)return;const c=new AbortController;let d;const l=async()=>{try{const m=await n.api.listElicitations(e,c.signal);c.signal.aborted||a(m[0]??null)}catch{a(m=>m&&m.expiresAt>Date.now()?m:null)}c.signal.aborted||(d=setTimeout(l,1500))};return l(),()=>{c.abort(),clearTimeout(d)}},[n,e,t,(i=o.capabilities)==null?void 0:i.connections]),r.jsxs(r.Fragment,{children:[" ",s&&s.expiresAt>Date.now()?r.jsx(gp,{request:s,onAnswer:async c=>{await n.api.answerElicitation(e,s.id,c),a(null)}},s.id):null]})}function gp({request:e,onAnswer:t}){var p,m;const[n,o]=u.useState(!1),[s,a]=u.useState(""),i=async f=>{if(!n){o(!0),a("");try{await t(f)}catch(h){a(h instanceof Error?h.message:"Could not submit. Try again.")}finally{o(!1)}}},c=e.form.requestedSchema.properties,d=Object.keys(c).length===1&&((p=c.approve)==null?void 0:p.type)==="boolean"&&((m=e.form.requestedSchema.required)==null?void 0:m.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:f=>{if(f.preventDefault(),d){i({action:"accept",content:{approve:!0}});return}const h=new FormData(f.currentTarget),b={};for(const[g,C]of Object.entries(c)){const x=h.get(g);if(C.type==="boolean")b[g]=x==="on";else if(C.type==="array"){const N=h.getAll(g).filter(w=>typeof w=="string");if(C.minItems!==void 0&&N.length<C.minItems){a(`${C.title??g}: select at least ${C.minItems} options.`);return}if(C.maxItems!==void 0&&N.length>C.maxItems){a(`${C.title??g}: select no more than ${C.maxItems} options.`);return}b[g]=N}else typeof x=="string"&&x!==""&&(b[g]=C.type==="number"||C.type==="integer"?Number(x):x)}i({action:"accept",content:b})},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(yn,{})}),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 i({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(([f,h])=>{var x,N,w,S,j;const b=`${e.id}-${f}`,g=h.oneOf??((x=h.enum)==null?void 0:x.map(v=>({const:v,title:v})))??((N=h.items)==null?void 0:N.anyOf)??((S=(w=h.items)==null?void 0:w.enum)==null?void 0:S.map(v=>({const:v,title:v}))),C=(j=e.form.requestedSchema.required)==null?void 0:j.includes(f);return r.jsxs("div",{children:[r.jsxs("label",{htmlFor:b,className:"block text-sm font-medium mb-1",children:[h.title??f,C?" *":""]}),h.description&&r.jsx("p",{className:"text-sm text-foreground/60 mb-1",children:h.description}),h.type==="boolean"?r.jsx("input",{id:b,name:f,type:"checkbox",defaultChecked:h.default===!0,className:"size-5 accent-current"}):g?r.jsxs("select",{id:b,name:f,multiple:h.type==="array",required:C,className:l,defaultValue:typeof h.default=="string"||Array.isArray(h.default)?h.default:h.type==="array"?[]:"",children:[h.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:b,name:f,className:l,type:h.type==="number"||h.type==="integer"?"number":h.format==="email"?"email":h.format==="uri"?"url":h.format==="date"?"date":"text",required:C,min:h.minimum,max:h.maximum,step:h.type==="integer"?1:"any",minLength:h.minLength,maxLength:h.maxLength,defaultValue:typeof h.default=="string"||typeof h.default=="number"?h.default:""})]},f)})}),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 i({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 i({action:"decline"}),children:"Decline"})]})]})}function xp({request:e}){const t=k.useConnection(e),{phase:n,authorization:o,continuation:s,error:a}=t,c=n==="loading"||n==="waiting"||s!==null,d=n==="connected"||n==="external",l=(a==null?void 0:a.toLowerCase().includes("expired"))??!1,p=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",m=s?s==="renew"?"Requesting…":"Continuing…":n==="loading"?"Preparing…":n==="waiting"?"Waiting…":l?"Reconnect":a?"Try again":d?"Continue":"Connect",f=()=>a||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(yn,{})}),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,": ",p]}),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 f(),children:[c&&r.jsx(Kr,{}),m]}),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"})]}),a&&r.jsx("p",{role:"alert",className:"px-1 pt-2 text-sm text-pretty text-destructive",children:a})]})}const bp=["box","circle","arrow","bracket","underline","highlight","strike-through","crossed-off"];function wp(e){const t=new Map,n=[];for(const o of e){let s;for(const a of o.elements){const i=a.selector||a.name,c=t.get(i);if(c){s??(s=c);continue}const d={...a};t.set(i,d),n.push(d),s??(s=d)}o.note&&s&&(s.note=s.note?`${s.note}
111
+ ${o.note}`:o.note)}return n}const Jo=20,vp=4e3;function wr(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 yp(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 a=null;try{a=Ws.annotate(s,{type:t,color:n,strokeWidth:2,wobble:.8}),a.show(),wr(s,o)}catch(l){Z.log.warn("page mark: could not be drawn",l)}let i=!1;const c=()=>{if(!i){i=!0;try{a==null||a.remove()}catch{}s.remove()}},d=l=>{if(!i)try{a==null||a.update(l),wr(s,o)}catch{}};return{setRect(l){i||(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(!i){if(!a)return c();try{a.hide(),a.finished.then(c)}catch{return c()}window.setTimeout(c,vp)}},remove:c}}const kp=60;function Ye(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function li(e){return si(e)}function jp(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 Cp(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)&&!jp(o))??null:null}function Sp(e){if(Ae(e))return"private region";const t=e.tagName.toLowerCase(),n=e.getAttribute("aria-label"),o=li(e);if(t==="button"||e.getAttribute("role")==="button")return n?`button [${n}]`:o?`button "${Ye(o,30)}"`:"button";if(t==="a"){if(o)return`link "${Ye(o,30)}"`;const a=e.getAttribute("href"),i=a?Jr(a):"",c=a!=null&&a.startsWith("/")&&!a.startsWith("//")&&i?new URL(i).pathname:i;return c?`link to ${Ye(c,40)}`:"link"}if(t==="input"||t==="textarea"||t==="select"){const a=e.getAttribute("placeholder"),i=e.getAttribute("name");return a?`${t} "${Ye(a,30)}"`:n?`${t} [${n}]`:i?`${t} [${i}]`:t==="input"?`${e.getAttribute("type")??"text"} input`:t}if(/^h[1-6]$/.test(t))return o?`${t} "${Ye(o,40)}"`:t;if(t==="img"){const a=e.getAttribute("alt");return a?`image "${Ye(a,30)}"`:"image"}if(t==="svg")return"icon";if(n)return`${t} [${n}]`;if(o&&o.length<=kp)return`${t} "${Ye(o,40)}"`;const s=Cp(e);return s||(t==="div"?"container":t)}function Qo(e,t){try{return e.querySelectorAll(t).length===1}catch{return!1}}function Np(e){const t=e.ownerDocument;if(e.id){const s=`#${CSS.escape(e.id)}`;if(Qo(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 a=s;const i=o.parentElement;if(i){const d=Array.from(i.children).filter(l=>l.tagName===(o==null?void 0:o.tagName));d.length>1&&(a+=`:nth-of-type(${d.indexOf(o)+1})`)}n.unshift(a);const c=n.join(" > ");if(Qo(t,c))return c;o=i}return n.join(" > ")}function _p(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 Ep=8;function es(e,t=Ep){const n=document.documentElement.clientWidth||window.innerWidth,o=document.documentElement.clientHeight||window.innerHeight,s=Math.max(e.x,t),a=Math.max(e.y,t),i=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(a),width:Math.round(Math.max(0,i-s)),height:Math.round(Math.max(0,c-a))}}function di(e){if(Ae(e)||e.closest(pt))return{name:"private region",selector:"",tag:"div"};const t=li(e);return{name:Sp(e),selector:Np(e),tag:e.tagName.toLowerCase(),text:t?Ye(t,200):void 0}}const Tp=Zr.join(", ");function Qt(e){return e.closest(Tp)!==null}function vr(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 a=n.closest('button, a, input, textarea, select, [role="button"], [role="link"]')??n;for(;a&&!(a instanceof HTMLElement);)a=a.parentElement;if(!(a instanceof HTMLElement)||Ae(n)||Ae(a)||a.closest(pt))return null;const i=a.tagName.toLowerCase();return i==="html"||i==="body"?null:a}const Qr=new WeakMap;function Ap(e,t){Qr.set(e,[...t])}function gn(e){const t=Qr.get(e);return t!==void 0&&e.pageUrl===Jr(window.location.href)&&t.every(n=>n.isConnected&&n.getRootNode()===document&&!Ae(n)&&!n.closest(pt))}function zp(e){const t=Qr.get(e);if(!t||!gn(e))return null;const n=t.map(di),o=t.length>0&&t.every(Wt)&&JSON.stringify(n)===JSON.stringify(e.elements),s={...e,elements:n};return o?Ku(e,s):delete s.snapshotUrl,s}const ts=120,ot=e=>e.replace(/\s+/g," ").trim(),qe=e=>e.length>ts?`${e.slice(0,ts)}…`:e,kn=si;function Ip(e){const t=e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?e.labels:null,n=t?Array.from(t).map(a=>kn(a)).join(" "):"";if(n)return ot(n);const o=e.closest("fieldset"),s=o==null?void 0:o.querySelector("legend");return s?kn(s):""}function At(e){if(Ae(e))return"";const t=e.getAttribute("aria-labelledby");if(t){const i=t.split(/\s+/).map(c=>e.ownerDocument.getElementById(c)).filter(c=>c!==null).map(c=>kn(c)).filter(Boolean).join(" ");if(i)return qe(ot(i))}const n=e.getAttribute("aria-label");if(n!=null&&n.trim())return qe(ot(n));const o=e.tagName.toLowerCase();if(o==="img"){const i=e.getAttribute("alt");if(i!=null&&i.trim())return qe(ot(i))}if(o==="input"||o==="select"||o==="textarea"){const i=Ip(e);if(i)return qe(i);const c=e.getAttribute("placeholder");if(c!=null&&c.trim())return qe(ot(c));const d=e.getAttribute("title");return d!=null&&d.trim()?qe(ot(d)):""}const s=kn(e);if(s)return qe(s);const a=e.getAttribute("title");return a!=null&&a.trim()?qe(ot(a)):""}const Mp=["click","fill","select","check","uncheck"],Rp=3e3,ui=new Set(["password","file","hidden"]);function pi(e){const t=new WeakRef(e),n=ns(e).map(o=>{const s=rs(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=ns(o).map(rs);return s.length===n.length&&s.every((a,i)=>{var d,l;const c=n[i];return a.allowed&&a.element===c.element.deref()&&a.form===(((d=c.form)==null?void 0:d.deref())??null)&&a.labelControl===(((l=c.labelControl)==null?void 0:l.deref())??null)&&a.semantics===c.semantics})}}function ns(e){const t=[],n=new Set,o=s=>{for(let a=s;a&&!n.has(a);a=a.parentElement)n.add(a),(a===e||a.matches("a[href],area[href],button,input,select,textarea,label"))&&t.push(a),a instanceof HTMLLabelElement&&a.control&&o(a.control)};return o(e),t}function rs(e){var a;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=(a=e.ownerDocument.querySelector("base[target]"))==null?void 0:a.getAttribute("target");return{element:e,form:o,labelControl:e instanceof HTMLLabelElement?e.control:null,allowed:!(e instanceof HTMLInputElement&&ui.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(i=>e.getAttribute(i)),e instanceof HTMLButtonElement||e instanceof HTMLInputElement?[e.formAction,e.formMethod,e.formTarget,e.formEnctype,e.formNoValidate]:null])}}const Pp=2,jt=[];let Op=0,os=new WeakMap,st,ss,eo=new WeakMap,to=new WeakMap,jn=new WeakMap;const $p='tr,li,article,form,fieldset,section,dialog,aside,nav,main,header,footer,[role="row"],[role="listitem"],[role="group"],[role="region"],[role="dialog"],[role="tooltip"]',no='tr,li,article,[role="row"],[role="listitem"]',qn='section,form,fieldset,dialog,[role="group"],[role="region"],[role="dialog"]',Lp=new Set(["class","style","aria-busy"]);function Dp(e){var a,i;const t=e.closest(no);if(t)return t;let n=e.closest(qn);if(n){let c=(a=n.parentElement)==null?void 0:a.closest(qn);for(;c;)n=c,c=(i=n.parentElement)==null?void 0:i.closest(qn);return n}const o=e.closest($p);if(o)return o;const s=e.parentElement;return s&&s!==e.ownerDocument.body&&s!==e.ownerDocument.documentElement?s:e}function Fp(e){return Qt(e)||e.closest('[role="tooltip"]')!==null}function Hp(e){const t=e.target.nodeType===1?e.target:e.target.parentElement;if(t&&Qt(t)||e.type==="attributes"&&Lp.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&&Fp(o)))return!1}return!0}function mi(e){const t=new Set;for(const n of e){for(const s of Array.from(n.removedNodes)){const a=jn.get(s);a&&t.add(a)}if(!Hp(n))continue;if(n.type==="attributes"){const s=jn.get(n.target);s&&t.add(s)}let o=!0;for(let s=n.target;s;s=s.parentNode){const a=eo.get(s);if(a&&t.add(a),o){const i=to.get(s);i&&t.add(i)}if(s instanceof Element&&(s.matches(no)&&(o=!1),s.matches('[role="tooltip"]')&&!(n.type==="attributes"&&n.attributeName==="role")))break}}t.forEach(n=>n.value++)}function Wp(e){const t=[],n=(s,a)=>{let i=a.get(s);i||(i={value:0},a.set(s,i)),t.push({revision:i,value:i.value})},o=Dp(e);n(o,eo);for(let s=e;s;s=s.parentNode)n(s,jn),s!==o&&s instanceof Element&&s.matches(no)&&n(s,to);return()=>t.every(({revision:s,value:a})=>s.value===a)}function yr(){st&&mi(st.takeRecords())}function Bp(e){if(ss!==e){st==null||st.disconnect();for(const t of jt)for(const n of Array.from(t.values()))n.valid=!1;ss=e,eo=new WeakMap,to=new WeakMap,jn=new WeakMap,st=new MutationObserver(mi),st.observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0})}}function hi(e,t,n=At(t)){return e.valid&&(e.valid=t.isConnected&&e.url===t.ownerDocument.location.href&&e.name===n&&e.sameContext()&&e.sameMeaning()),e.valid}function Up(){yr();const e=new Map;jt.unshift(e),jt.length=Math.min(jt.length,Pp);let t=0;const n=`s${++Op}`;return(o,s=At(o))=>{Bp(o.ownerDocument),yr();const a=os.get(o),i=a?jt.map(l=>l.get(a)).find(l=>l!==void 0):void 0,c=a&&i&&hi(i,o,s)?a:`${n}c${t+=1}`,d=c===a&&i?i:{element:new WeakRef(o),sameContext:Wp(o),name:s,url:o.ownerDocument.location.href,sameMeaning:pi(o),valid:!0};return e.set(c,d),os.set(o,c),c}}function as(e){const t=fi(e);return t!=null&&t.isCurrent?t.element:null}function fi(e){yr();for(const t of jt){const n=t.get(e);if(!n)continue;const o=n.element.deref();if(o&&o.isConnected)return{element:o,isCurrent:hi(n,o)}}return null}const qp="data-opencx-private",Vp=new Set(["password","file","hidden"]),is=300;function kr(e){if(Qt(e))return"widget-owned";if(e.closest(`[${qp}]`))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(Vp.has(t))return"credential-field"}return null}const Yp={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."},cs=["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(","),Xp=["tr","li",'[role="row"]','[role="listitem"]','[role="gridcell"]',"[tabindex]","[onclick]"].join(","),Gp=400;function Kp(e){var t;try{return((t=e.ownerDocument.defaultView)==null?void 0:t.getComputedStyle(e).cursor)==="pointer"}catch{return!1}}function Zp(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 Jp(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 ls(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 Qp(e){return"disabled"in e&&e.disabled===!0?!0:e.getAttribute("aria-disabled")==="true"}function jr(e=document){const t=[],n=new Set;let o=!1;try{const s=Up(),a=Array.from(e.querySelectorAll(cs));for(const c of a){if(kr(c)||!ls(c))continue;const d=At(c);if(!d)continue;if(t.length>=is){o=!0;break}const l={ref:s(c,d),role:Zp(c),name:d};Qp(c)&&(l.disabled=!0),t.push(l),n.add(c)}let i=0;if(!o){const c=Array.from(e.querySelectorAll(Xp));for(const d of c){if(t.length>=is){o=!0;break}if(i>=Gp)break;if(n.has(d)||kr(d)||d.querySelector(cs)||!ls(d))continue;const l=At(d);l&&(i+=1,Kp(d)&&(t.push({ref:s(d,l),role:Jp(d),name:l}),n.add(d)))}}}catch{return{controls:[],truncated:!1}}return{controls:t,truncated:o}}function gi({marks:e,readsPage:t}){if(!t)return;const n={},o=e.flatMap(i=>{const c=zp(i);return c?[c]:[]});o.length>0&&(n.page_marks=o,n.picked_elements=wp(o));const{controls:s,truncated:a}=jr();return s.length>0&&(n.page_controls=s,a&&(n.page_controls_truncated=!0)),Object.keys(n).length>0?n:void 0}const em={click:"click",fill:"type into",select:"change",check:"switch on",uncheck:"switch off"};function tm({request:e}){const{resolvePageAction:t}=k.useAgentChatUi(),n=em[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 xn="rounded-full size-8 flex items-center justify-center p-0 overflow-hidden",xi="bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",nm=A("rounded-full p-0.5 text-muted-foreground","hover:bg-muted hover:text-foreground","transition-transform active:scale-90");function rm({entity:e,onRemove:t}){const{t:n}=G();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:nm,onClick:t,children:r.jsx(T.XIcon,{className:"size-3"})})]})}const om=y.z.object({type:y.z.string().min(1),id:y.z.string().min(1),title:y.z.string().min(1),meta:y.z.record(y.z.string(),y.z.unknown()).optional()});function sm(){var o;const e=k.useConfig(),{widgetCtx:t}=k.useWidget();if(k.useHostLocation(),!t.features.pageContext)return null;const n=om.safeParse((o=Z.resolveConfigContext(e))==null?void 0:o.entity);return n.success?n.data:null}function un(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 ro({cssVars:e,primaryColor:t,contentZIndex:n}){return{accent:t,surface:un(e,"--opencx-background"),foreground:un(e,"--opencx-foreground"),mutedForeground:un(e,"--opencx-muted-foreground"),border:un(e,"--opencx-border"),inkZIndex:n-2,chromeZIndex:n-1,editorZIndex:n+1}}function am({isActive:e,draft:t,hover:n,onShapeChange:o,onAttach:s,onDiscard:a}){const i=An(),{theme:c,cssVars:d}=de(),{t:l}=G();if(!i||!e)return null;const p=ro({cssVars:d,primaryColor:c.primaryColor,contentZIndex:c.widgetContentContainer.zIndex}),{accent:m}=p;return Vt.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:p.chromeZIndex,display:"flex",alignItems:"center",gap:8,background:`color-mix(in srgb, ${p.surface} 92%, transparent)`,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",color:p.foreground,font:"500 12px/1.4 system-ui, sans-serif",padding:"7px 12px 7px 10px",borderRadius:999,whiteSpace:"nowrap",boxShadow:`0 0 0 1px ${p.border}, 0 8px 24px color-mix(in srgb, ${p.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}}),l("page_mark_hint"),r.jsx(im,{theme:p,children:l("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:p.chromeZIndex,borderRadius:10,boxShadow:`0 0 0 2px ${p.surface}, 0 0 0 3.5px ${m}, 0 12px 32px color-mix(in srgb, ${p.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(([f,h],b)=>r.jsx("div",{style:{position:"fixed",left:f-5,top:h-5,width:10,height:10,borderRadius:999,background:p.surface,boxShadow:`0 0 0 2px ${m}, 0 2px 6px color-mix(in srgb, ${p.foreground} 25%, transparent)`,zIndex:p.chromeZIndex,pointerEvents:"none"}},b)),r.jsx(dm,{draft:t,theme:p,onShapeChange:o,onAttach:s,onDiscard:a},"editor")]})]}),i)}function im({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 cm={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"})]})},lm={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 dm({draft:e,theme:t,onShapeChange:n,onAttach:o,onDiscard:s}){const{accent:a}=t,{t:i}=G(),[c,d]=u.useState(""),l=u.useRef(null);u.useEffect(()=>{var x;(x=l.current)==null||x.focus()},[]);const p=320,m=window.innerWidth,f=window.innerHeight,{rect:h}=e,b=Math.max(12,Math.min(h.x+h.width/2-p/2,m-p-12)),g=h.y+h.height+16,C=g+120>f?Math.max(12,h.y-116):g;return r.jsxs("div",{"data-opencx-mark-editor":"",style:{position:"fixed",left:b,top:C,width:p,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:bp.map(x=>{const N=x===e.shape,w=i(lm[x]);return r.jsx("button",{type:"button",title:w,"aria-label":i("page_mark_shape_aria",{shape:w}),"aria-pressed":N,onClick:()=>n(x),style:{border:"none",cursor:"pointer",borderRadius:8,width:32,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:N?a:"transparent",color:N?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:cm[x]})},x)})}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("input",{ref:l,value:c,onChange:x=>d(x.target.value),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),o(c)):x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),s())},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",paddingInlineStart:4}}),r.jsx("button",{type:"button","aria-label":i("page_mark_attach"),onClick:()=>o(c),style:{border:"none",borderRadius:999,width:26,height:26,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:a,color:t.surface,font:"600 13px/1 system-ui, sans-serif",cursor:"pointer"},children:"↑"})]})]})}function um({mark:e,onRemove:t}){var c;const{t:n}=G(),o=ai(e),s=e.note??((c=e.elements[0])==null?void 0:c.name)??n("page_mark_region"),a=n("page_mark_remove",{label:s}),i=e.elements.map(d=>d.name).join(", ");return o?r.jsx(ri,{...P("chat/input_box/page_mark_pill"),className:"group",shape:"tile",src:o,alt:s,title:i,note:e.note,children:r.jsx("button",{type:"button","aria-label":a,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:i,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":a,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 Pe={"close-panel":"Escape","toggle-fullscreen":"Mod+Shift+F",send:"Enter","send-alt":"Mod+Enter","history-prev":"ArrowUp","history-next":"ArrowDown"};function bi(){return typeof navigator>"u"?!1:/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}function mt(e,t,n=bi()){const o=t.split("+"),s=o.at(-1)??"",a=new Set(o.slice(0,-1)),i=a.has("Cmd")||a.has("Mod")&&n,c=a.has("Ctrl")||a.has("Mod")&&!n;return e.metaKey!==i||e.ctrlKey!==c||e.altKey!==a.has("Alt")||e.shiftKey!==a.has("Shift")?!1:e.key.toLowerCase()===s.toLowerCase()}const pm={Mod:"⌘",Cmd:"⌘",Ctrl:"⌃",Alt:"⌥",Shift:"⇧"},mm={Escape:"Esc",Enter:"⏎",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→"};function oo(e,t=bi()){const n=e.split("+"),o=n.at(-1)??"",s=n.slice(0,-1),a=mm[o]??(o.length===1?o.toUpperCase():o);return t?[...s.map(i=>pm[i]??i),a].join(""):[...s.map(i=>i==="Mod"?"Ctrl":i),a].join("+")}const hm=50*1024*1024,wi={"application/pdf":[".pdf"],...vd,...yd},fm={"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],...wi},gm={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"],...wi};function xm({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 bm({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"}):Ta({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 wm({file:{status:e,file:t,error:n},onCancel:o}){const{t:s}=G(),[a,i]=u.useState(null);return u.useEffect(()=>{if(!t.type.startsWith("image/"))return;const c=new FileReader;return c.onload=()=>i(c.result),c.onerror=()=>Z.log.error("failed to read file for preview"),c.readAsDataURL(t),()=>c.abort()},[t]),r.jsx(Ee,{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(xm,{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(bm,{file:t,fileContent:a})]})})}function vm(){const{queuedUserMessages:e,removeQueued:t,stop:n}=k.useAgentChatUi(),{messagesState:{messages:o}}=k.useMessages(),{t:s}=G(),a=u.useMemo(()=>e.filter(i=>!o.some(c=>c.id===i.id)),[e,o]);return r.jsx(W.AnimatePresence,{children:a.length>0&&r.jsx(je,{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:a.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:a.map(i=>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:i.content}),r.jsx("button",{type:"button",...P("chat/queued_sends/remove"),"aria-label":s("remove_queued_message"),onClick:()=>t(i.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"})})]},i.id))})]})},"queued-sends-pill")})}function ym({levelRef:e}){const t=u.useRef(null);return u.useEffect(()=>{let n=0;const o=new Z.DictationLevelSmoother({attack:.2,release:.07}),s=[],a=()=>{var c;const i=(c=t.current)==null?void 0:c.children;if(i){const d=o.next(e.current);for(let l=0;l<i.length;l++){const p=i[l];if(p instanceof HTMLElement){const m=.75+.25*Math.sin(Date.now()/260+l*1.7),f=`scaleY(${Math.max(.25,Math.min(1,d*1.8*m)).toFixed(3)})`;s[l]!==f&&(p.style.transform=f,s[l]=f)}}}n=requestAnimationFrame(a)};return n=requestAnimationFrame(a),()=>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 km({status:e,levelRef:t,onToggle:n,onPrewarm:o}){const{t:s}=G(),a=e==="listening",i=e==="connecting",c=s(a||i?"stop_dictation":"dictate");return r.jsx(Ee,{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":a||i,"aria-label":c,size:"fit",variant:"ghost",className:A("relative",xn,a&&xi),children:[i&&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:a?r.jsx(ee,{distance:0,children:r.jsx(ym,{levelRef:t})},"bars"):r.jsx(ee,{distance:0,children:r.jsx(T.MicIcon,{className:A("size-4",i&&"opacity-60")})},"mic")})]})})}function jm(e,t){const n=e.ownerDocument;if(!n.defaultView)return null;const s=n.createElement("div");vi(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 a=n.createElement("span");a.textContent="​",s.appendChild(a),n.body.appendChild(s);const i=a.offsetLeft,c=a.offsetTop-e.scrollTop;return s.remove(),{left:i,top:c}}function vi(e,t){const n=e.ownerDocument.defaultView;if(!n)return;const o=n.getComputedStyle(e);for(const s of Cm)t.style.setProperty(s,o.getPropertyValue(s))}const Cm=["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"],Sm=300,yi=260,Nm=8,ki="rounded-xl border border-border bg-background shadow-lg";function _m({anchorRef:e,inputRef:t,anchorIndex:n,preview:o,groups:s,visible:a,searching:i,highlighted:c,onHighlight:d,onPick:l,onExpand:p}){var N;const{t:m}=G(),[f,h]=u.useState(null);u.useLayoutEffect(()=>{const w=e.current;if(!w)return;const S=w.ownerDocument.defaultView,j=()=>{const _=w.getBoundingClientRect(),R=(S==null?void 0:S.innerWidth)??_.right,I=Math.min(Sm,Math.max(0,R-16)),M=t.current,D=M&&n!==null?jm(M,n):null,O=M==null?void 0:M.getBoundingClientRect(),B=D&&O?O.left+D.left:_.left+8,E=Math.max(8,Math.min(B,R-8-I)),z=D&&O?O.top+D.top-4:_.top-4;h({left:E,width:I,top:z,detailBeside:o&&E+I+Nm+yi<=R-8})};j(),S==null||S.addEventListener("resize",j);const v=typeof ResizeObserver>"u"?null:new ResizeObserver(j);return v==null||v.observe(w),()=>{S==null||S.removeEventListener("resize",j),v==null||v.disconnect()}},[n,e,t,o,a.length]);const b=(N=e.current)==null?void 0:N.closest("[data-version]");if(!b||!f||a.length===0&&i)return null;const g=a[c],C=g!=null&&g.description?g:null;let x=-1;return Vt.createPortal(r.jsxs("div",{...P("chat/input_box/mention_picker"),style:{position:"fixed",left:f.left,top:f.top,transform:"translateY(-100%)"},className:"z-50 flex items-end gap-2",children:[r.jsx("div",{role:"listbox",style:{width:f.width},className:A("flex max-h-72 flex-col overflow-hidden",ki),children:r.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-1",children:a.length===0?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:m("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(S=>{const j=++x;return u.createElement("button",{...P("chat/input_box/mention_picker/option"),key:`${S.type}:${S.id}`,type:"button",role:"option","aria-selected":j===c,onMouseDown:v=>v.preventDefault(),onMouseEnter:()=>d(j),onClick:()=>l(S),className:A("flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-start text-sm",j===c?"bg-muted":"hover:bg-muted/60")},r.jsx(ji,{item:S}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:S.title}))}),w.hidden>0&&r.jsx("button",{...P("chat/input_box/mention_picker/more"),type:"button",onMouseDown:S=>S.preventDefault(),onClick:()=>p(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:m("json_see_more",{count:String(w.hidden)})})))})}),C&&f.detailBeside&&r.jsx(Em,{item:C})]}),b)}function Em({item:e}){return r.jsxs("div",{...P("chat/input_box/mention_picker/detail"),style:{width:yi},className:A("flex gap-3 p-3",ki),children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted",children:r.jsx(ji,{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 ji({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(Tt,{name:e.iconName??"AtSign",className:A("size-3.5 shrink-0 text-primary",t)})}const Ci=u.createContext(null);function Tm({children:e}){const[t,n]=u.useState([]),[o,s]=u.useState(!1),a=u.useRef(new Map),i=u.useCallback(m=>{s(m)},[]),c=u.useCallback((m,f)=>{a.current.set(m,f),n(h=>[...h,m])},[]),d=u.useCallback(m=>{const f=a.current.get(m);f&&(a.current.delete(m),f.undraw()),n(h=>h.filter(b=>b!==m))},[]),l=u.useCallback(()=>{const m=Array.from(a.current.values());a.current.clear();for(const f of m)f.undraw();n([])},[]);u.useEffect(()=>()=>{a.current.forEach(m=>m.remove()),a.current.clear()},[]);const p=u.useMemo(()=>({marks:t,isArmed:o,setArmed:i,attach:c,detach:d,detachAll:l}),[t,o,i,c,d,l]);return r.jsx(Ci.Provider,{value:p,children:e})}function so(){const e=u.useContext(Ci);if(!e)throw new Error("usePageMarks must be used within a PageMarksProvider");return e}const Am="data-opencx-mark-cursor",zm=5,pn=4,mn=6,Vn={width:160,height:100},Im=10,Mm=Zr.map(e=>`:not(${e}):not(${e} *)`).join(""),Rm=e=>e==="nw"||e==="se"?"nwse-resize":"nesw-resize";function Pm({enabled:e,onAttach:t,accentColor:n,zIndex:o}){const{isArmed:s,setArmed:a,attach:i}=so(),c=e&&s,[d,l]=u.useState(null),[p,m]=u.useState(null),f=u.useRef(null),h=u.useRef(null);h.current=d;const b=u.useCallback(()=>{var S;(S=f.current)==null||S.undraw(),f.current=null,l(null)},[]),g=u.useCallback(()=>a(!1),[a]),C=u.useCallback(S=>{var j;l(v=>v&&{...v,rect:S}),(j=f.current)==null||j.setRect({x:S.x+window.scrollX,y:S.y+window.scrollY,width:S.width,height:S.height})},[]),x=u.useCallback(S=>{var j;l(v=>v&&{...v,shape:S}),(j=f.current)==null||j.setShape(S)},[]);u.useEffect(()=>{!e&&s&&a(!1)},[e,s,a]),u.useEffect(()=>{if(!c)return;const S=document.createElement("style");S.setAttribute(Am,"");let j=null;const v=$=>{$!==j&&(j=$,S.textContent=`*${Mm} { cursor: ${$} !important; }`)};v("crosshair"),document.head.appendChild(S);let _=null;const R=$=>$.target instanceof Element&&Qt($.target),I=$=>R($)?!1:($.preventDefault(),$.stopPropagation(),$.stopImmediatePropagation(),!0),M=($,te,K)=>{const oe=[["nw",$.x,$.y],["ne",$.x+$.width,$.y],["sw",$.x,$.y+$.height],["se",$.x+$.width,$.y+$.height]];for(const[he,le,se]of oe)if(Math.hypot(te-le,K-se)<=Im)return he;return null},D=($,te,K)=>te>=$.x&&te<=$.x+$.width&&K>=$.y&&K<=$.y+$.height,O=($,te)=>{var le;const K=vr($,te),oe=es(K?(()=>{const se=K.getBoundingClientRect();return{x:se.left-mn,y:se.top-mn,width:se.width+mn*2,height:se.height+mn*2}})():{x:$-Vn.width/2,y:te-Vn.height/2,...Vn}),he=((le=h.current)==null?void 0:le.shape)??"box";m(null),f.current=yp({x:oe.x+window.scrollX,y:oe.y+window.scrollY,width:oe.width,height:oe.height},he,n,o),l({rect:oe,shape:he})},B=$=>{var oe;if(!I($)||$.button!==0)return;const te=h.current;if(!te){O($.clientX,$.clientY);return}const K=M(te.rect,$.clientX,$.clientY);if(K){_={kind:"resize",corner:K};return}if(D(te.rect,$.clientX,$.clientY)){_={kind:"move",grabX:$.clientX-te.rect.x,grabY:$.clientY-te.rect.y};return}(oe=f.current)==null||oe.undraw(),f.current=null,O($.clientX,$.clientY)};let E=null,z=0;const H=$=>{if(!I($))return;const te=h.current;if(!te){v("crosshair");const ie=vr($.clientX,$.clientY);if(!ie){E=null,m(null);return}ie!==E&&(E=ie,z+=1),m({rect:es(_p(ie)),key:z});return}if(!_){const ie=M(te.rect,$.clientX,$.clientY);v(ie?Rm(ie):D(te.rect,$.clientX,$.clientY)?"move":"crosshair");return}const{rect:K}=te;if(_.kind==="move"){C({...K,x:$.clientX-_.grabX,y:$.clientY-_.grabY});return}const oe=_.corner.includes("w")?K.x+K.width:K.x,he=_.corner.includes("n")?K.y+K.height:K.y,le=Math.min(oe,$.clientX),se=Math.max(oe,$.clientX),ne=Math.min(he,$.clientY),ze=Math.max(he,$.clientY);C({x:le,y:ne,width:Math.max(Jo,se-le),height:Math.max(Jo,ze-ne)})},L=$=>{I($)&&(_=null)},q=$=>{R($)||I($),_=null},X=$=>{I($)},U=$=>{var te;if($.key==="Escape"){if($.preventDefault(),$.stopPropagation(),_=null,h.current){(te=f.current)==null||te.undraw(),f.current=null,l(null),v("crosshair");return}a(!1)}};let F=window.scrollX,J=window.scrollY;const re=()=>{m(null);const $=window.scrollX-F,te=window.scrollY-J;F=window.scrollX,J=window.scrollY,!($===0&&te===0)&&l(K=>K&&{...K,rect:{...K.rect,x:K.rect.x-$,y:K.rect.y-te}})};return document.addEventListener("pointerdown",B,!0),document.addEventListener("pointermove",H,!0),document.addEventListener("pointerup",L,!0),document.addEventListener("pointercancel",q,!0),document.addEventListener("click",X,!0),document.addEventListener("keydown",U,!0),document.addEventListener("scroll",re,!0),()=>{S.remove(),document.removeEventListener("pointerdown",B,!0),document.removeEventListener("pointermove",H,!0),document.removeEventListener("pointerup",L,!0),document.removeEventListener("pointercancel",q,!0),document.removeEventListener("click",X,!0),document.removeEventListener("keydown",U,!0),document.removeEventListener("scroll",re,!0),m(null)}},[c,n,o,C,a]),u.useEffect(()=>{!c&&h.current&&b()},[c,b]),u.useEffect(()=>()=>{var S;(S=f.current)==null||S.remove(),f.current=null},[]);const N=u.useCallback(S=>{if(!e)return;const j=h.current,v=f.current;if(!j||!v)return;const _=S.trim(),R=Om(j.rect),I={shape:j.shape,..._?{note:_}:{},pageUrl:Jr(window.location.href),rect:j.rect,elements:R.map(di)};Ap(I,R),R[0]&&qu(I,R[0]),f.current=null,l(null),a(!1),i(I,v),t==null||t(I)},[i,e,t,a]),w=u.useCallback(()=>{e&&a(!s)},[e,s,a]);return{isActive:c,draft:d,hover:p,setShape:x,attach:N,dropDraft:b,disarm:g,toggle:w}}function Om(e){const t=new Set,n=(o,s)=>{const a=vr(o,s);a&&t.add(a)};n(e.x+e.width/2,e.y+e.height/2);for(let o=0;o<=pn;o++)for(let s=0;s<=pn;s++)n(e.x+e.width*o/pn,e.y+e.height*s/pn);return Array.from(t).slice(0,zm)}function $m({enabled:e,inputRef:t}){const{widgetCtx:n}=k.useWidget(),{theme:o,cssVars:s}=de(),a=ro({cssVars:s,primaryColor:o.primaryColor,contentZIndex:o.widgetContentContainer.zIndex}),{marks:i,detach:c}=so(),d=u.useCallback(()=>{var m;(m=t.current)==null||m.focus()},[t]),l=u.useCallback(async m=>{if(!n.features.pageContext||!n.features.attachments)return null;try{const{fileUrl:f}=await n.api.uploadFile({file:m,abortSignal:new AbortController().signal});return f??null}catch(f){return Z.log.warn("page mark snapshot upload failed",f),null}},[n]),p=Pm({enabled:e,onAttach:d,accentColor:a.accent,zIndex:a.inkZIndex});return{marks:i,detach:c,marking:p,uploadSnapshot:l}}function Lm({inputText:e,setInputText:t,inputRef:n,getSentTextHistory:o}){const s=u.useRef(null),a=u.useRef(""),i=()=>{const m=n.current;m&&(m.classList.remove("opencx-input-recall"),m.offsetWidth,m.classList.add("opencx-input-recall"))},c=(m,{animate:f=!0}={})=>{t(m),f&&i(),requestAnimationFrame(()=>{var h;return(h=n.current)==null?void 0:h.setSelectionRange(m.length,m.length)})};return{onKeyDown:m=>{if(mt(m,Pe["history-prev"])){const f=o();if(f.length===0)return!1;const h=s.current;if(h===null){const b=n.current;if(!((b==null?void 0:b.selectionStart)===0&&(b==null?void 0:b.selectionEnd)===0)&&e!=="")return!1;a.current=e,s.current=f.length-1}else{if(h===0)return!1;s.current=h-1}return m.preventDefault(),c(f[s.current],{animate:!m.repeat}),!0}if(mt(m,Pe["history-next"])){const f=s.current;if(f===null)return!1;m.preventDefault();const h=o();return f>=h.length-1?(s.current=null,c(a.current,{animate:!m.repeat}),a.current=""):(s.current=f+1,c(h[s.current],{animate:!m.repeat})),!0}return!1},onEdit:()=>{s.current=null},onSent:()=>{s.current=null,a.current=""}}}const ds="max-h-16 [field-sizing:content] w-full px-2";function Si({trailingActions:e,placeholder:t,hideAttachTools:n,disabled:o=!1}={}){var on;const{isSmallScreen:s}=ye(),a=u.useRef(null),i=u.useRef(null),c=u.useRef(null),d=u.useRef(!0),{messagesState:l,sendMessage:p,rememberSentText:m,getSentTextHistory:f}=k.useMessages(),{widgetCtx:h,componentStore:b}=k.useWidget(),{attachments:g,pageContext:C}=h.features,{isStreaming:x,stop:N,queuedUserMessages:w,pendingClarification:S,pendingConnection:j,pendingPageAction:v}=k.useAgentChatUi(),{sessionState:_}=k.useSessions(),R=o||xr({isStreaming:x,messages:l.messages,session:_.session}),I=u.useRef(x);I.current=x;const{t:M}=G(),{text:D,setText:O,clearSubmitted:B}=k.useComposerDraft(),E=sm(),z=op({text:D,setText:O,inputRef:a}),H=z.picked.length>0;u.useLayoutEffect(()=>{const Y=a.current,fe=c.current;!Y||!fe||vi(Y,fe)},[H,D]);const[L,q]=u.useState(!1),X=E?`${E.type}:${E.id}`:"";u.useEffect(()=>{q(!1)},[X]);const[U,F]=u.useState(null),J=u.useRef(D);J.current=D;const re=u.useRef(()=>{}),$=k.useDictation({getValue:()=>J.current,setValue:Y=>{J.current=Y,O(Y)},onSend:()=>re.current()}),{stop:te}=$;u.useEffect(()=>{R&&te({executeFinalCommand:!1})},[R,te]),u.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]);const K=Lm({inputText:D,setInputText:O,inputRef:a,getSentTextHistory:f}),oe=C&&!s,he=!R&&oe&&n!==!0,{marks:le,detach:se,marking:ne,uploadSnapshot:ze}=$m({enabled:he,inputRef:a});u.useEffect(()=>{C||le.forEach(se)},[C,le,se]);const{allFiles:ie,handleCancelUpload:ue,appendFiles:ft,emptyTheFiles:et,isUploading:Ie,successFiles:He}=k.useUploadFiles();u.useEffect(()=>{!g&&ie.length>0&&et()},[g,ie.length,et]);const tt=!!((on=_.session)!=null&&on.isHandedOff),{isAwaitingBotReply:We}=k.useIsAwaitingBotReply(),Oe=h.messageCtx.blocksSendWhileAwaitingReply&&We,Be=Y=>{R||!g||(F(null),ft(Y))},Ue=E!==null&&!L,ge=ie.length>0||le.length>0,Me=!D.trim()&&He.length===0&&(!C||!le.some(gn)),$e=x&&Me,Pn=$e&&w.length>0,tn=R||Ie||Oe||Me,xe=()=>{if($.stop({executeFinalCommand:!1}),R||Oe||Ie)return;const Y=J.current,fe=h.messageCtx.captureConversation(),Rt=h.messageCtx.draftState.get(),Le=le.filter(be=>h.features.pageContext&&gn(be)?!0:(se(be),!1)),nt=h.features.attachments?[...He]:[];if(!Y.trim()&&nt.length===0&&Le.length===0)return;const Pt=ie.map(be=>be.id);Le.forEach(be=>Vu(be,ze)),Promise.all(Le.map(be=>Yu(be,Dm))).then(()=>Mt({isCurrentConversation:fe,submittedText:Y,submittedDraft:Rt,submittedMarks:Le,submittedFiles:nt,submittedFileIds:Pt}))},Mt=({isCurrentConversation:Y,submittedText:fe,submittedDraft:Rt,submittedMarks:Le,submittedFiles:nt,submittedFileIds:Pt})=>{if(!Y()||xr({isStreaming:I.current,messages:h.messageCtx.state.get().messages,session:h.sessionCtx.sessionState.get().session}))return;const xt=h.features.pageContext,bt=Le.filter(pe=>xt&&gn(pe)?!0:(se(pe),!1));if(!fe.trim()&&nt.length===0&&bt.length===0)return;const wt=fe.trim()||(bt.length>0?Fm(bt)??M("page_mark_default_message"):"");let Ot=!1;const sn=z.picked;p({content:wt,withPageEntity:!L,mentions:sn.length>0?sn:void 0,attachments:nt.flatMap(pe=>pe.fileUrl?[{url:pe.fileUrl,type:pe.file.type,name:pe.file.name,id:pe.id,size:pe.file.size}]:[]),clientContext:gi({marks:bt,readsPage:xt}),onAccepted:()=>{if(Ot||!Y())return;Ot=!0,m(wt),Le.forEach(rt=>se(rt)),Pt.forEach(rt=>ue(rt));const pe=B(Rt);d.current&&(K.onSent(),q(!1),pe&&z.reset())}}).catch(pe=>{Z.log.error("failed to send message",pe)})},{getRootProps:On,getInputProps:gt,open:nn}=uc.useDropzone({onDrop:Be,noClick:!0,disabled:R||!g,onDropRejected(){F(M("file_rejected"))},maxSize:hm,accept:tt?fm:gm}),$n=Y=>{const fe=Y.clipboardData;fe&&fe.files.length>0&&Be(Array.from(fe.files))};re.current=xe;const rn=b.getComponent("agent_chat_questions");return!j&&S&&rn?r.jsx("div",{...P("chat/input_box/root"),className:"p-2 relative space-y-1",children:r.jsx(rn,{request:S})}):r.jsxs("div",{...P("chat/input_box/root"),className:"p-2 relative space-y-1",...On({ref:i}),children:[_.session&&r.jsx(fp,{sessionId:_.session.id,active:x||We},_.session.id),j&&r.jsx(xp,{request:j},j.request_id),v&&r.jsx(tm,{request:v},v.callId),r.jsx("input",{...gt()}),z.isOpen&&r.jsx(_m,{anchorRef:i,inputRef:a,anchorIndex:z.anchorIndex,preview:z.preview,groups:z.groups,visible:z.visible,searching:z.searching,highlighted:z.highlighted,onHighlight:z.setHighlighted,onPick:z.pick,onExpand:z.expandGroup}),he&&r.jsx(am,{isActive:ne.isActive,draft:ne.draft,hover:ne.hover,onShapeChange:ne.setShape,onAttach:ne.attach,onDiscard:ne.dropDraft}),r.jsx(vm,{}),U&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:U}),$.error&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:$.error==="microphone"?M("dictation_mic_blocked"):M("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",Ue?"bg-muted":"bg-transparent"),children:[r.jsx(W.AnimatePresence,{children:Ue&&r.jsx(je,{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&&!L&&r.jsx(ee,{snapExit:!0,children:r.jsx(rm,{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:[ge&&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:[ie.map(Y=>r.jsx(ee,{snapExit:!0,children:r.jsx(wm,{onCancel:()=>ue(Y.id),file:Y})},Y.id)),le.map((Y,fe)=>r.jsx(ee,{snapExit:!0,children:r.jsx(um,{mark:Y,onRemove:()=>se(Y)})},`mark-${fe}-${Y.note??""}`))]})}),r.jsxs("div",{className:"relative",children:[H&&r.jsx("div",{ref:c,"aria-hidden":!0,className:A(ds,"pointer-events-none absolute inset-0 overflow-hidden","whitespace-pre-wrap break-words text-foreground",!ge&&"pt-1",s?"text-[16px]":"text-sm"),children:r.jsx(ii,{text:D,mentions:z.picked,tokenClassName:"bg-primary/10 text-primary"})}),r.jsx("textarea",{...P("chat/input_box/textarea"),disabled:R,onPaste:$n,ref:a,id:"chat-input",value:D,rows:3,className:A(ds,"relative resize-none",!ge&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground",H&&"text-transparent caret-foreground",s?"text-[16px]":"text-sm"),onScroll:Y=>{c.current&&(c.current.scrollTop=Y.currentTarget.scrollTop)},onChange:Y=>{K.onEdit(),O(Y.target.value)},onClick:()=>z.onCaretMove("nearest"),onKeyUp:Y=>{Y.key==="ArrowRight"||Y.key==="ArrowDown"?z.onCaretMove("forward"):Y.key==="ArrowLeft"||Y.key==="ArrowUp"?z.onCaretMove("backward"):(Y.key==="Home"||Y.key==="End")&&z.onCaretMove("nearest")},onKeyDown:Y=>{if(!Y.nativeEvent.isComposing&&!z.onKeyDown(Y)){if(mt(Y,Pe.send)||mt(Y,Pe["send-alt"])){Y.preventDefault(),Pn?N():xe();return}if(Y.key==="Escape"&&ne.isActive){ne.disarm();return}K.onKeyDown(Y)}},placeholder:t??M("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(Ee,{side:"top",align:"start",content:M("attach_files"),children:r.jsx(V,{onClick:nn,"aria-label":M("attach_files"),size:"fit",variant:"ghost",className:xn,children:r.jsx(W.AnimatePresence,{mode:"wait",children:Oe?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")})})}),$.enabled&&r.jsx(km,{status:$.status,levelRef:$.levelRef,onToggle:$.toggle,onPrewarm:$.prewarm}),oe&&r.jsx(Ee,{side:"top",align:"start",content:ne.isActive?M("mark_page_active"):M("mark_page"),children:r.jsx(V,{...P("chat/input_box/page_mark_btn"),onClick:ne.toggle,"aria-label":ne.isActive?M("mark_page_active"):M("mark_page"),size:"fit",variant:"ghost",className:A(xn,ne.isActive&&xi),children:r.jsx(T.MousePointerClickIcon,{className:"size-4"})})})]})}),r.jsxs("div",{className:"flex items-center gap-1",children:[e,r.jsx(Ee,{content:M($e?"stop_response":"send_message"),shortcut:$e?void 0:oo(Pe.send),side:"top",align:"end",children:r.jsx(V,{size:"fit",onClick:$e?N:xe,"aria-label":M($e?"stop_response":"send_message"),disabled:R||!$e&&tn,className:xn,children:r.jsx(W.AnimatePresence,{mode:"wait",children:$e?r.jsx(ee,{snapExit:!0,distance:0,children:r.jsx(T.SquareIcon,{className:"size-3 fill-current"})},"stop"):!x&&(Oe||Ie)?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 Dm=1500;function Fm(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 us(){const{widgetCtx:e}=k.useWidget(),{router:t}=k.useConfig(),{canCreateNewSession:n}=k.useSessions(),{toSessionsScreen:o}=k.useWidgetRouter(),{t:s}=G();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 Hm(){const{t:e}=G(),{isCsatRequested:t,isCsatSubmitted:n}=k.useCsat();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:t||n?r.jsxs(je,{children:[r.jsx(mp,{}),r.jsx(W.AnimatePresence,{mode:"wait",children:n&&r.jsx(je,{children:r.jsx(us,{})},"new-conv-or-back-to-convs-button")})]},"csat"):r.jsxs(je,{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(us,{})]},"session-closed")})})})}function Wm(){var l;const{initialQuestions:e,initialQuestionsPosition:t,thisWasHelpfulOrNot:n}=k.useConfig(),{sessionState:o}=k.useSessions(),{messagesState:s}=k.useMessages(),{isStreaming:a}=k.useAgentChatUi(),i=s.messages.length===0,c=ci(),d=xr({isStreaming:a,messages:s.messages,session:o.session});return r.jsx("footer",{children:r.jsx(W.AnimatePresence,{mode:"wait",children:o.session&&!((l=o.session)!=null&&l.isOpened)?r.jsxs(je,{children:[r.jsx(Hm,{}),r.jsx(br,{})]},"session-closed"):r.jsxs(je,{children:[s.lastAIResMightSolveUserIssue&&(n==null?void 0:n.enabled)!==!1&&r.jsx(hp,{}),i&&e&&t!=="below-initial-messages"&&r.jsx("div",{className:A("flex items-center flex-row justify-end gap-2 flex-wrap px-2",c&&"pb-4"),children:e==null?void 0:e.map((p,m)=>r.jsx(zn,{suggestion:p},`${p}-${m}`))}),!c&&!d&&r.jsx(Si,{}),r.jsx(br,{})]},"chat-input")})})}function Bm(){const{messagesState:{messages:e}}=k.useMessages(),{isAwaitingBotReply:t}=k.useIsAwaitingBotReply(),{componentStore:n}=k.useWidget(),o=k.useBot(),s=u.useMemo(()=>Za(e),[e]),a=e.at(-1),i=a==null?void 0:a.id,c=a==null?void 0:a.type,d=u.useRef(i),[l,p]=u.useState(!1),m=t&&!l;u.useEffect(()=>{const g=d.current!==i;if(d.current=i,!t||c!=="AI"){p(!1);return}if(!g)return;p(!0);const C=setTimeout(()=>p(!1),600);return()=>clearTimeout(C)},[t,i,c]);const f=n.getComponent("loading"),h=u.useRef(null);function b(){setTimeout(()=>{const g=h.current;g&&(g.scrollTop=g.scrollHeight)},0)}return u.useEffect(()=>{b()},[e,m]),r.jsxs("div",{...P("chat/msgs/root"),ref:h,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(ti,{}),r.jsx(Ja,{}),r.jsx(ni,{}),r.jsx(gr,{groups:s,pendingReply:t}),m&&f&&r.jsx(f,{agent:o}),r.jsx(Ka,{}),r.jsx(Ga,{})]})}function Um(){const{messagesState:{isInitialFetchLoading:e}}=k.useMessages(),{widgetCtx:t}=k.useWidget(),n=t.streaming,{sessionState:{session:o}}=k.useSessions(),{isCanvasOpen:s}=Nu(),{theme:a}=de();It({width:s?a.screens.chat.withCanvas.width:a.screens.chat.width,height:s?a.screens.chat.withCanvas.height:a.screens.chat.height});const i=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(Ua,{}),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(qa,{})},"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:a.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:a.screens.chat.withCanvas.transitionDuration},children:[n?r.jsx(dp,{}):r.jsx(Bm,{}),r.jsx(Wm,{})]}),r.jsx("div",{...P("chat/canvas/root"),className:A("h-full overflow-auto transition-all",s?"w-3/5":"w-0"),style:{transitionTimingFunction:a.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:a.screens.chat.withCanvas.transitionDuration},children:r.jsx(up,{})})]},i)})]})})}const Ht=Je.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})});Ht.displayName="Input";function qm({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 en({className:e}){const{token:t}=k.useConfig();return r.jsx("div",{className:A("flex items-center justify-center gap-2 p-2 pt-0",e),children:r.jsx(Re,{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(qm,{className:"size-3 inline-block"})}),r.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function ct({className:e,...t}){return r.jsx("div",{className:A("animate-pulse rounded-md bg-secondary",e),...t})}const Vm=3;function Ni(e,t){for(const n of e){if(n.id===t)return n;const o=Ni(n.topics,t);if(o)return o}}function Ym({articleId:e,siblings:t,popular:n}){const o=new Set([e]),s=[];for(const{id:a,title:i,slug:c}of[...t,...n])if(!o.has(a)&&(o.add(a),s.push({id:a,title:i,slug:c}),s.length===Vm))break;return s}const ao="w-full justify-between gap-3 rounded-[19px] px-3 py-2.5 text-start whitespace-normal";function ht({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:ao,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 Ei({article:e,onOpen:t}){return r.jsxs(V,{...P("home/article_link"),variant:"ghost",wobble:!1,size:"free",className:ao,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 Ti({component:e,onBack:t,children:n}){const{setIsOpen:o}=k.useWidgetTrigger(),{isSmallScreen:s}=ye(),{t:a}=G();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":a("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 Cn(){return r.jsxs("div",{className:"px-3 py-2.5 space-y-1.5",children:[r.jsx(ct,{className:"h-4 w-2/3"}),r.jsx(ct,{className:"h-3 w-full"})]})}function Ai({onClick:e}){const{t}=G();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 ps=99,Xm=e=>e?16:9,zi=(e,t)=>e/2*(1-Math.SQRT1_2)-Xm(t)/2;function Ii({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:we,style:o,children:t?e>ps?`${ps}+`:e:null})}function Gm(){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 In(){return k.useConfig().unreadIndicator??"dot"}function io({count:e,indicator:t,component:n,style:o}){const s=In();return s===!1?null:r.jsx(Ii,{count:e,showCount:(t??s)==="count",component:n,style:o})}function Mn(e){const t=In(),{t:n}=G();return t===!1||e<=0?null:n("unread_sessions",{count:e})}const Km={duration:.3,ease:Qe};function Rn({onArticles:e}={}){const{widgetCtx:t}=k.useWidget(),{routerState:{screen:n},toHomeScreen:o,toSessionsScreen:s}=k.useWidgetRouter(),{count:a}=k.useUnread(),i=Mn(a),{t:c}=G();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:a}];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:p,Icon:m,onClick:f,onReselect:h,unread:b})=>{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?h:f},g&&r.jsx(W.motion.span,{layoutId:"home-tab-pill",className:"absolute inset-0 rounded-full border border-border bg-background shadow-sm",transition:Km},"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(m,{className:"size-4"}),r.jsx(io,{count:b,indicator:"dot",component:"home/tab_unread"})]}),r.jsx("span",{className:"truncate",children:p}),b>0&&i&&r.jsx("span",{className:"sr-only",children:i})]},"label"))})})})}function Mi({key:e,fetchPage:t}){const[n,o]=u.useState(null),s=u.useRef(t);u.useEffect(()=>{s.current=t});const a=u.useCallback((m,f)=>{o(h=>({key:m,items:(h==null?void 0:h.key)===m&&f>0?h.items:[],nextOffset:(h==null?void 0:h.key)===m?h.nextOffset:null,fetching:!0,error:void 0})),s.current(f).then(h=>o(b=>(b==null?void 0:b.key)===m?{key:m,items:f===0?h.items:[...b.items,...h.items],nextOffset:h.nextOffset,fetching:!1,error:void 0}:b),h=>o(b=>(b==null?void 0:b.key)===m?{...b,fetching:!1,error:h}:b))},[]);u.useEffect(()=>{e!==null&&a(e,0)},[e,a]);const i=e!==null&&(n==null?void 0:n.key)===e?n:null,c=e!==null&&(!i||i.fetching),d=(i==null?void 0:i.nextOffset)??null,l=u.useCallback(()=>{e!==null&&d!==null&&!c&&a(e,d)},[e,d,c,a]),p=u.useCallback(()=>{e!==null&&a(e,0)},[e,a]);return{items:(i==null?void 0:i.items)??[],loading:c,error:i==null?void 0:i.error,hasMore:d!==null,loadMore:l,reload:p}}function Ri({helpCenterId:e,topicId:t}){const{widgetCtx:n}=k.useWidget(),o=Mi({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(a=>({items:a.articles,nextOffset:a.next_offset}))});return u.useEffect(()=>{o.error&&Z.log.error("home: could not load the topic articles",{_e:o.error,helpCenterId:e,topicId:t})},[o.error,e,t]),o}const Zm=["[--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 Jm({helpCenterId:e,slug:t,popular:n,onBack:o,onHome:s,onOpenArticle:a,onOpenTopicPath:i,onRedirect:c}){var x,N,w;const{widgetCtx:d}=k.useWidget(),{t:l}=G(),{theme:p}=de();It({width:p.screens.chat.width,height:p.screens.chat.height});const m=Bs(()=>d.api.getHelpCenterArticle({helpCenterId:e,slug:t}),[d,e,t]),f=(x=m.value)==null?void 0:x.article,h=f?null:(N=m.value)==null?void 0:N.redirect_slug;u.useEffect(()=>{h&&c(h)},[h,c]),u.useEffect(()=>{m.error?Z.log.error("home: could not load the article",{_e:m.error,helpCenterId:e,slug:t}):m.value&&!m.value.article&&!m.value.redirect_slug&&Z.log.warn("home: article not found",{helpCenterId:e,slug:t})},[m.error,m.value,e,t]);const b=(f==null?void 0:f.topic_path)??[],g=Ri({helpCenterId:e,topicId:((w=b.at(-1))==null?void 0:w.id)??null}),C=f?Ym({articleId:f.id,siblings:g.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(Ti,{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:b.map((S,j)=>r.jsxs(u.Fragment,{children:[j>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",j===b.length-1?"font-semibold":"shrink-[2] text-muted-foreground"),onClick:()=>i(b.slice(0,j+1).map(v=>v.id)),children:r.jsx("span",{className:"truncate",children:S.name})})]},S.id))})}),r.jsx("article",{...P("article/content"),className:"flex-1 overflow-y-auto px-5 py-4",children:m.loading||h?r.jsxs("div",{className:"space-y-3",children:[r.jsx(ct,{className:"h-6 w-3/4"}),r.jsx(ct,{className:"h-3 w-1/4"}),r.jsx(ct,{className:"h-4 w-full"}),r.jsx(ct,{className:"h-4 w-5/6"})]}):f?r.jsxs(r.Fragment,{children:[r.jsx("h1",{className:"text-xl font-semibold tracking-tight leading-snug",children:f.title}),r.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l("article_reading_minutes",{count:f.reading_minutes})}),f.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",Zm),children:r.jsx(eu,{openArticle:a,children:f.content_html})}),C.length>0&&r.jsx("div",{...P("article/suggested"),className:"mt-6 -mx-2",children:r.jsx(ht,{component:"home/articles",title:l("home_suggested_articles"),children:C.map(S=>r.jsx(Ei,{article:S,onOpen:a},S.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(Rn,{onArticles:s}),r.jsx(en,{})]})]})}function Qm({helpCenterId:e,topic:t,onBack:n,onHome:o,onOpenTopic:s,onOpenArticle:a}){const{theme:i}=de(),{t:c}=G();It({width:i.screens.sessions.width,height:i.screens.sessions.height});const d=t.topics.filter(p=>p.article_count>0),l=Ri({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(Ti,{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}),d.length>0&&r.jsx(ht,{component:"home/topics",title:c("home_topics"),children:d.map(p=>r.jsx(_i,{topic:p,onOpen:s},p.id))}),l.error&&l.items.length===0?r.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:c("home_load_failed")}):(l.loading||l.items.length>0)&&r.jsxs(ht,{component:"home/articles",title:c("home_tab_articles"),children:[l.items.map(p=>r.jsx(Ei,{article:p,onOpen:a},p.id)),l.loading?r.jsx(Cn,{}):l.hasMore?r.jsx(Ai,{onClick:l.loadMore}):null]})]}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Rn,{onArticles:o}),r.jsx(en,{})]})]})}const Pi=u.createContext({data:void 0,loading:!1,failed:!1,request:()=>{}});function eh({children:e}){var c;const{widgetCtx:t}=k.useWidget(),n=(c=t.home)==null?void 0:c.helpCenterId,[o,s]=u.useState(!1),a=u.useCallback(()=>s(!0),[]),i=Bs(async()=>o&&n?t.api.listHomeArticles({helpCenterId:n}):void 0,[t,n,o]);return u.useEffect(()=>{i.error&&Z.log.error("home: could not load the help center",{_e:i.error,helpCenterId:n})},[i.error,n]),r.jsx(Pi.Provider,{value:{data:i.value,loading:i.loading||!o&&!!n,failed:!!i.error,request:a},children:e})}function th(){const e=u.useContext(Pi),{request:t}=e;return u.useEffect(t,[t]),e}const nh=400,rh=6;function oh(e){const[t,n]=u.useState(""),[o,s]=u.useState(""),[a,i]=u.useState(0),c=p=>p.length>=rh||e.includes(p),d=p=>{const m=p.trim();s(c(m)?m:"")};return pc(()=>d(t),nh,[t]),{query:t,setQuery:n,search:o,searchNow:p=>{n(p),d(p),i(m=>m+1)},retry:a}}const sh=24,ah={initial:{opacity:1,x:0}},Oi=u.createContext({direction:null,settle:()=>{}}),Cr={home:0,sessions:1};function ms(e){return e in Cr}function ih({from:e,to:t,rtl:n}){return!ms(e)||!ms(t)||e===t?null:Cr[t]>Cr[e]!==n?"left":"right"}function $i({children:e,...t}){const{direction:n,settle:o}=u.useContext(Oi);return u.useEffect(()=>{n&&o()},[n,o]),r.jsx(ee,{...t,fadeIn:n??"right",distance:sh,overrides:n?{}:ah,children:e})}const ch=200,lh=3,dh=3500,uh={duration:.55,ease:Qe};function ph(){var C,x,N,w;const{widgetCtx:e}=k.useWidget(),t=(C=e.home)==null?void 0:C.helpCenterId,[n,o]=u.useState([]),s=th(),a=oh(((x=s.data)==null?void 0:x.popularSearches)??[]),i=u.useCallback(S=>o(j=>[...j.slice(0,-1),{kind:"article",slug:S}]),[]);if(!t)return null;const c=S=>o(j=>[...j,S]),d=()=>o(S=>S.slice(0,-1)),l=()=>o([]),p=S=>c({kind:"article",slug:S}),m=S=>c({kind:"topic",topicId:S}),f=S=>o(S.map(j=>({kind:"topic",topicId:j}))),h=n[n.length-1],b=((N=s.data)==null?void 0:N.topics)??[],g=(h==null?void 0:h.kind)==="topic"?Ni(b,h.topicId):null;return r.jsx(W.AnimatePresence,{mode:"wait",initial:!1,children:(h==null?void 0:h.kind)==="article"?r.jsx(ee,{fadeIn:"left",snapExit:!0,className:"size-full",children:r.jsx(Jm,{helpCenterId:t,slug:h.slug,popular:((w=s.data)==null?void 0:w.articles)??[],onBack:d,onHome:l,onOpenArticle:p,onRedirect:i,onOpenTopicPath:f})},`${n.length}:${h.slug}`):g?r.jsx(ee,{fadeIn:"left",snapExit:!0,className:"size-full",children:r.jsx(Qm,{helpCenterId:t,topic:g,onBack:d,onHome:l,onOpenTopic:m,onOpenArticle:p})},`${n.length}:${g.id}`):r.jsx(ee,{fadeIn:"right",snapExit:!0,className:"size-full",children:r.jsx(mh,{helpCenterId:t,data:s.data,loading:s.loading,failed:s.failed,homeSearch:a,onOpenArticle:p,onOpenTopic:m})},"home")})}function mh({helpCenterId:e,data:t,loading:n,failed:o,homeSearch:{query:s,setQuery:a,search:i,searchNow:c,retry:d},onOpenArticle:l,onOpenTopic:p}){const{theme:m}=de(),{t:f}=G(),h=(t==null?void 0:t.popularSearches)??[],b=((t==null?void 0:t.topics)??[]).filter(g=>g.article_count>0);return It({width:m.screens.sessions.width,height:m.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($i,{className:"flex-1 min-h-0 flex flex-col",children:[r.jsx(hh,{}),r.jsx("div",{className:"shrink-0 px-3 -mt-6 relative z-10",children:r.jsx(fh,{value:s,hints:h,onChange:a,onSubmit:()=>c(s)})}),r.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex flex-col gap-3 p-3",children:i?r.jsx(wh,{helpCenterId:e,search:i,retry:d,onOpenArticle:l}):r.jsxs(r.Fragment,{children:[r.jsx(xh,{searches:h,onPick:c}),r.jsx(bh,{articles:t==null?void 0:t.articles,loading:n,failed:o,onOpenArticle:l}),b.length>0&&r.jsx(ht,{component:"home/topics",title:f("home_topics"),children:b.map(g=>r.jsx(_i,{topic:g,onOpen:p},g.id))})]})})]}),r.jsxs("footer",{className:"shrink-0 pt-1",children:[r.jsx(Rn,{}),r.jsx(en,{})]})]})}function hh(){var i,c;const{widgetCtx:{org:e}}=k.useWidget(),{assets:t,textContent:n}=k.useConfig(),{setIsOpen:o}=k.useWidgetTrigger(),{isSmallScreen:s}=ye(),{t:a}=G();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:((i=n==null?void 0:n.homeScreen)==null?void 0:i.title)||a("home_title")}),r.jsx("p",{className:"text-sm opacity-90",children:((c=n==null?void 0:n.homeScreen)==null?void 0:c.description)||a("home_description")})]})]})}function fh({value:e,hints:t,onChange:n,onSubmit:o}){const{t:s}=G();return r.jsxs("form",{...P("home/search"),role:"search",className:"relative block",onSubmit:a=>{a.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(Ht,{type:"text",enterKeyHint:"search",maxLength:ch,value:e,onChange:a=>n(a.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(gh,{hints:t})]})}function gh({hints:e}){const t=W.useReducedMotion(),[n,o]=u.useState(0);u.useEffect(()=>{if(e.length<2||t)return;const a=setInterval(()=>o(i=>(i+1)%e.length),dh);return()=>clearInterval(a)},[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:uh,children:s},s)})})}function xh({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 bh({articles:e,loading:t,failed:n,onOpenArticle:o}){const{t:s}=G();return n?r.jsx(Sr,{children:s("home_load_failed")}):!t&&(e==null?void 0:e.length)===0?null:r.jsx(ht,{component:"home/articles",title:s("home_suggested_articles"),children:t||!e?Array.from({length:lh},(a,i)=>r.jsx(Cn,{},i)):e.map(a=>r.jsx(Li,{article:a,onOpen:o},a.id))})}function wh({helpCenterId:e,search:t,retry:n,onOpenArticle:o}){const{widgetCtx:s}=k.useWidget(),{t:a}=G(),i=Mi({key:`${e}:${t}`,fetchPage:m=>s.api.searchHelpCenter({helpCenterId:e,query:t,offset:m}).then(f=>({items:f.results,nextOffset:f.next_offset}))}),c=i.error instanceof Z.HelpCenterSearchError&&i.error.busy;u.useEffect(()=>{i.error&&!c&&Z.log.error("home: help center search failed",{_e:i.error,helpCenterId:e})},[i.error,c,e]);const d=u.useRef(n),{error:l,reload:p}=i;return u.useEffect(()=>{n!==d.current&&(d.current=n,l&&p())},[n,l,p]),i.items.length===0?i.error?r.jsx(Sr,{onRetry:i.reload,children:a(c?"home_search_busy":"home_load_failed")}):i.loading?r.jsx(ht,{component:"home/articles",children:r.jsx(Cn,{})}):r.jsx(Sr,{children:a("home_search_no_results")}):r.jsxs(ht,{component:"home/articles",children:[i.items.map(m=>r.jsx(Li,{article:m,topicName:m.topic.name,onOpen:o},m.id)),i.loading?r.jsx(Cn,{}):i.hasMore?r.jsx(Ai,{onClick:i.loadMore}):null]})}function Li({article:e,topicName:t,onOpen:n}){return r.jsxs(V,{...P("home/article_card"),variant:"ghost",wobble:!1,size:"free",className:ao,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 Sr({children:e,onRetry:t}){const{t:n}=G();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 vh({children:e}){var N,w,S;const{widgetCtx:t,config:n}=k.useWidget(),[o,s]=u.useState(!1),[a,i]=u.useState(null),[c,d]=u.useState(""),[l,p]=u.useState([]),[m,f]=u.useState([]),[h,b]=u.useState(!1),[g,C]=u.useState("");u.useEffect(()=>{var v;let j=!1;if(((v=n.capabilities)==null?void 0:v.connections)===!0)return Promise.all([t.api.listConnections(),t.api.listApprovalPreferences()]).then(([_,R])=>{j||(p(_.filter(I=>I.status!=="not_connected")),f(R))}).catch(()=>{}),()=>{j=!0}},[t,(N=n.capabilities)==null?void 0:N.connections]);const x=async j=>{b(!0),C("");try{await j()}catch{C("Could not save the change. Try again.")}finally{b(!1)}};return!o||((w=n.capabilities)==null?void 0:w.connections)!==!0?r.jsxs(r.Fragment,{children:[r.jsx(Ua,{}),((S=n.capabilities)==null?void 0:S.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":a?"Back to connections":"Back to sessions",onClick:()=>a?i(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."}),!a&&r.jsxs(r.Fragment,{children:[r.jsx("input",{type:"search","aria-label":"Search connections",placeholder:"Search connections",value:c,onChange:j=>d(j.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(j=>j.name.toLowerCase().includes(c.toLowerCase())).map(j=>r.jsxs("button",{type:"button",onClick:()=>i(j.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(yn,{})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium",children:j.name}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:j.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(T.ChevronRight,{className:"size-4 text-muted-foreground"})]},j.server_id)),l.length>0&&!l.some(j=>j.name.toLowerCase().includes(c.toLowerCase()))&&r.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No matching connections."})]})]}),l.filter(j=>j.server_id===a).map(j=>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(yn,{})}),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:j.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:j.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(V,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:h,onClick:()=>void x(async()=>{await t.api.disconnectConnection(j.server_id),i(null),p(v=>v.filter(_=>_.server_id!==j.server_id)),f(v=>v.filter(_=>_.serverId!==j.server_id))}),children:"Disconnect"})]}),m.some(v=>v.serverId===j.server_id)?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("h3",{className:"text-xs font-medium",children:["Saved approvals (",m.filter(v=>v.serverId===j.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":`${j.name} saved approvals`,children:m.filter(v=>v.serverId===j.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:h,onClick:()=>void x(async()=>{await t.api.revokeApprovalPreference(v.serverId,v.key),f(_=>_.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"})]},j.server_id)),g&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:g})]})}function yh({children:e}){return r.jsx("p",{className:"ps-4 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:e})}function hs({session:e,className:t}){const{humanAgent:n}=k.useConfig(),o=k.useBot(),{toChatScreen:s}=k.useWidgetRouter(),{isUnread:a}=k.useUnread(),i=Mn(a(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(Wr,{className:"size-10",children:[r.jsx(Br,{src:d,alt:"Agent Icon"}),r.jsx(Ur,{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(Ra,{remarkPlugins:[Fs],rehypePlugins:[Qn],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(ct,{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(ei,{customStatus:e.customStatus})},e.customStatus.id)})]})]}),i&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"sr-only",children:i}),r.jsx(io,{count:1,indicator:"dot",component:"sessions/unread"})]}),r.jsx(T.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0 rtl:-scale-100"})]})}function kh(){const{t:e}=G(),{toChatScreen:t}=k.useWidgetRouter(),{sessionsState:{data:n,isInitialFetchLoading:o},openSessions:s,closedSessions:a,canCreateNewSession:i}=k.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(qa,{})},"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(hs,{session:c},c.id))},"open-sessions"),a.length>0&&r.jsxs(ee,{className:"space-y-2",delay:.2,snapExit:!0,children:[r.jsx(yh,{children:e("closed_conversations")}),a.map(c=>r.jsx(hs,{session:c,className:"opacity-50 hover:opacity-100"},c.id))]},"closed-sessions")]}),i&&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 jh(){const{theme:e}=de();return It({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($i,{className:"flex-1 min-h-0 flex flex-col",children:r.jsx(vh,{children:r.jsx(kh,{})})}),r.jsx(Rn,{}),r.jsx(en,{})]})})}function Ch(){const{contentIframeRef:e}=k.useWidget(),{inline:t}=k.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 a;const i=new ResizeObserver(()=>{a=requestAnimationFrame(()=>{const c=s.offsetHeight;o.style.setProperty("--opencx-widget-height",t?"100%":`${c.toFixed(1)}px`)})});return i.observe(s),()=>{cancelAnimationFrame(a),i.unobserve(s)}}},[e,t]),{observedElementRef:n}}const Sh=y.z.object({name:y.z.string().min(2),email:y.z.string().email()});function Nh(){var x,N,w,S,j,v,_,R;const{widgetCtx:{org:e}}=k.useWidget(),{setIsOpen:t}=k.useWidgetTrigger(),{createUnverifiedContact:n}=k.useContact(),{isSmallScreen:o}=ye(),s=k.useConfig(),{theme:a}=de(),{t:i}=G(),{observedElementRef:c}=Ch();It({height:void 0,width:a.screens.welcome.width});const[d,l]=u.useState(((x=s.prefillUserData)==null?void 0:x.name)||""),[p,m]=u.useState(((N=s.prefillUserData)==null?void 0:N.email)||""),f=(s.extraDataCollectionFields||[]).filter(I=>I!=="name"&&I!=="email"&&!!I),[h,b]=u.useState({}),[g,C]=mc(async I=>{I.preventDefault();const M=Sh.safeParse({name:d,email:p});M.success&&await n({email:M.data.email,non_verified_name:M.data.name},Object.values(h).filter(Boolean).length?h:void 0)},[d,p,h]);return r.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:a.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=s.assets)==null?void 0:S.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=(j=s.textContent)==null?void 0:j.welcomeScreen)==null?void 0:v.title)||i("welcome_screen_title")}),r.jsx("p",{className:"text-sm",children:((R=(_=s.textContent)==null?void 0:_.welcomeScreen)==null?void 0:R.description)||i("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:C,className:"space-y-2",children:[r.jsx(Ht,{value:d,onChange:I=>l(I.target.value),required:!0,placeholder:i("your_name_placeholder"),name:"name"}),r.jsx(Ht,{required:!0,value:p,onChange:I=>m(I.target.value),type:"email",placeholder:i("your_email_placeholder"),name:"email"}),f.map(I=>r.jsx(Ht,{value:h[I],onChange:M=>b(D=>({...D,[I]:M.target.value})),placeholder:`${I} (${i("optional")})`},I)),r.jsxs(V,{disabled:g.loading,className:"w-full",size:"lg",children:[g.loading?i("start_chat_button_loading"):i("start_chat_button"),r.jsx(T.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),r.jsx(en,{})]})]})})}const _h={initial:{opacity:1,x:0}};function Eh(e){const{dir:t}=G(),[,n]=u.useReducer(a=>a+1,0),o=u.useRef({screen:e,direction:null});o.current.screen!==e&&(o.current={screen:e,direction:ih({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 co(){const{routerState:{screen:e}}=k.useWidgetRouter(),t=Eh(e),n=t.direction?_h:void 0;return r.jsx(eh,{children:r.jsx(Oi.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(Nh,{})},e);case"home":return r.jsx(ee,{fadeIn:"right",className:"size-full",snapExit:!0,overrides:n,children:r.jsx(ph,{})},e);case"sessions":return r.jsx(ee,{fadeIn:"right",className:"size-full",snapExit:!0,overrides:n,children:r.jsx(jh,{})},e);case"chat":return r.jsx(ee,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(Um,{})},e);default:return Z.isExhaustive(e,co.name),null}})()})})})}const Th=qr(),Ah=()=>{};function Di(){const{isOpen:e}=k.useWidgetTrigger(),{contentIframeRef:t,widgetCtx:n}=k.useWidget(),{inline:o}=k.useConfig(),{theme:s,computed:a}=de();return u.useEffect(()=>{e||n.dictationCtx.stop({executeFinalCommand:!1})},[e,n]),r.jsx(W.motion.div,{onUpdate:Ah,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:Et},visible:{opacity:1,scale:1,y:0,display:"block",height:o?"100%":void 0,transition:{...Et,height:{duration:0}}}},children:r.jsx(Hs,{ref:t,initialContent:Th,allowFullScreen:!0,title:Da,style:{"--opencx-widget-width":a.minWidth,"--opencx-widget-height":a.minHeight,minWidth:a.minWidth,width:"var(--opencx-widget-width)",maxWidth:a.maxWidth,minHeight:a.minHeight,height:"var(--opencx-widget-height)",maxHeight:a.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(Tn,{style:{zIndex:s.widgetContentContainer.zIndex},children:r.jsx(co,{})})})})}function zh(){const{theme:e,triggerSide:t}=de(),{dir:n}=k.useDocumentDir(),{t:o}=G(),s=(n==="rtl"?t==="left":t==="right")?"end":"start";return r.jsx(Xe.Content,{onInteractOutside:a=>a.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(Di,{})})}function Ih({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 Fi(){var t;const{accessibility:e}=k.useConfig();return((t=e==null?void 0:e.widgetTriggerButton)==null?void 0:t.label)??"Chat with us"}function Hi(e,t,n,o){return e({react:u,isOpen:t,setIsOpen:s=>n(s),unreadCount:o})}const Mh=qr({transparent:!0}),Nr=6,fs={x:_t.x+Nr,y:_t.y+Nr},Yn=e=>typeof e=="number"?e-Nr:e;function Rh(){var f,h;const{isOpen:e,setIsOpen:t}=k.useWidgetTrigger(),{assets:n,customComponents:o}=k.useConfig(),{count:s}=k.useUnread(),a=Mn(s),i=In()==="count",{theme:c,triggerSide:d}=de(),l=zi(c.widgetTrigger.size.button,i),p=Fi(),m=a&&!e?`${p} · ${a}`:p;return o!=null&&o.widgetTrigger?Hi(o.widgetTrigger,e,t,s):r.jsx(Hs,{initialContent:Mh,title:"OpenCX Live Chat Trigger",style:{height:`calc(${c.widgetTrigger.size.button}px + ${fs.y*2}px)`,width:`calc(${c.widgetTrigger.size.button}px + ${fs.x*2}px)`,fontSize:"16px",position:"fixed",zIndex:c.widgetTrigger.zIndex,right:Yn(c.widgetTrigger.offset.right),bottom:Yn(c.widgetTrigger.offset.bottom),left:Yn(c.widgetTrigger.offset.left),boxSizing:"border-box",borderWidth:"0px",background:"transparent"},children:r.jsx(Tn,{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsxs(Xe.PopoverTrigger,{"aria-label":m,title:m,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(io,{count:s,style:{top:l,[d]:l}}),r.jsx(Re,{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:(f=n==null?void 0:n.widgetTrigger)!=null&&f.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:(h=n==null?void 0:n.widgetTrigger)!=null&&h.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(Ih,{style:{width:c.widgetTrigger.size.icon,height:c.widgetTrigger.size.icon},className:"mt-0.5 opacity-95"})},"message-icon")})})})]})})})}function Ph(){const{triggerSide:e}=de();return r.jsx(Xe.Anchor,{style:{position:"fixed",bottom:0,right:e==="right"?0:void 0,left:e==="left"?0:void 0}})}const Oh="[data-opencx-escape-scope]";function $h(e){var n;const t=e.target;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,Oh))!=null}function Lh(e,{state:t,onToggleFullscreen:n}){e.defaultPrevented||t!=="chat"||mt(e,Pe["toggle-fullscreen"])&&(e.preventDefault(),n())}function Wi(e,{state:t,onDismiss:n,onToggleFullscreen:o}){if(!e.defaultPrevented){if(mt(e,Pe["close-panel"])){$h(e)||n();return}t==="chat"&&mt(e,Pe["toggle-fullscreen"])&&(e.preventDefault(),o())}}function Dh({panelLayout:e,previousLayout:t,defaultLayout:n,allowedLayouts:o}){if(e!=="fullscreen")return{kind:"close"};const s=[t,n];for(const i of s)if(i!=="fullscreen"&&o.includes(i))return{kind:"layout",layout:i};const a=o.find(i=>i!=="fullscreen");return a?{kind:"layout",layout:a}:{kind:"close"}}function Fh({onHeightChange:e,maxHeight:t,onDismiss:n,onToggleFullscreen:o}){const s=u.useRef(null);return u.useLayoutEffect(()=>{var l;const a=s.current;if(!a)return;const i=()=>e(a.offsetHeight);i();const c=(l=a.ownerDocument.defaultView)==null?void 0:l.ResizeObserver;if(!c)return;const d=new c(i);return d.observe(a),()=>d.disconnect()},[e,t]),r.jsx(Tn,{children:r.jsx("div",{ref:s,onKeyDown:a=>Wi(a.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(Hh,{})})})}function Hh(){const{initialQuestions:e}=k.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:Qe},children:r.jsx(zn,{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 Bi=new WeakSet;function Wh(e){return Bi.has(e)}function gs(e,t=()=>!0){var m;let n=!1;const o=f=>f?"completed":n?"interrupted":"not-started",s=e.getBoundingClientRect(),a=s.left+s.width/2,i=s.top+s.height/2,c={bubbles:!0,cancelable:!0,composed:!0,clientX:a,clientY:i},d=f=>t()?(n=!0,Bi.add(f),e.dispatchEvent(f),!0):!1,l=f=>d(new PointerEvent(f,{...c,pointerId:1,pointerType:"mouse",isPrimary:!0})),p=(f,h=0)=>d(new MouseEvent(f,{...c,detail:h,button:0,buttons:1}));return!l("pointerover")||!l("pointerenter")||!p("mouseover")||!p("mousemove")||!l("pointerdown")||!p("mousedown",1)||!t()?o(!1):((m=e.focus)==null||m.call(e),o(l("pointerup")&&p("mouseup",1)&&p("click",1)))}const lo=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 at(e,t,n){return Math.min(Math.max(e,t),n)}const _r=16,_e=16,Ge=32,Bh=44,Uh=240,qh=440,Ui=32,Vh=280,Yh=420,Xh=640,Gh=48,Xn=12,uo=400,qi=320,Kh=560,Zh="#f4f4f5",Vi=120,Yi=qi+Vi+_e*3,Ke={pill:999,input:16,fullscreen:16,sidebar:20,compact:20};function po(e,t){if(e.width<=Yi)return Math.max(0,e.width-_e*2);const n=e.width-Vi-_e*3;return Math.max(0,Math.min(t,n))}function St(e,t,n=0){return typeof e=="number"&&Number.isFinite(e)?Math.max(n,e):t}function Xi(e,t={}){const n=Math.max(0,e.width),o=St(t.maxWidth,qh),s=Math.min(o,St(t.minWidth,Vh));return Math.min(n,o,Math.max(s,n-Ui))}function Jh(e,t,n={}){const o=Math.max(0,e.height),s=St(n.minHeight,Yh),a=St(n.maxHeight,Xh,s),i=Math.min(1,St(n.viewportHeightRatio,.65)),c=Math.max(0,o-Math.max(0,t)-Gh);return Math.min(a,c,Math.max(s,o*i))}function Qh(e){const{layout:t,region:n,sidebarWidth:o,bottomOffset:s,compact:a}=e;return t==="fullscreen"?{width:Math.max(0,n.width-_r*2),height:Math.max(0,n.height-_r*2),borderRadius:Ke.fullscreen}:t==="sidebar"?{width:po(n,o),height:Math.max(0,n.height-_e*2),borderRadius:Ke.sidebar}:{width:Xi(n,a),height:Jh(n,s,a),borderRadius:St(a==null?void 0:a.borderRadius,Ke.compact)}}function ef(e){const{isChatOpen:t,layout:n,region:o,sidebarWidth:s,sidebarSide:a,bottomOffset:i}=e,c=t?n:"compact",d=po(o,s),l=c==="fullscreen"?_r:c==="sidebar"?_e:i;return{centerX:c==="sidebar"?a==="left"?_e+d/2:o.width-_e-d/2:o.width/2,bottom:l}}const me="[data-companion-root]",tf=`
145
+ ${me} [data-component="chat/msgs/root"] {
146
+ overflow-x: hidden !important;
147
+ }
148
+ ${me} [data-component="chat/agent_msg_group/root"],
149
+ ${me} [data-component="chat/agent_msg_group/avatar_and_msgs/root"],
150
+ ${me} [data-component="chat/agent_msg_group/avatar_and_msgs/msgs"] {
151
+ min-width: 0 !important;
152
+ max-width: 100% !important;
153
+ }
154
+ ${me} [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
+ ${me} [data-component="chat/agent_msg/msg"] table {
163
+ display: block;
164
+ max-width: 100%;
165
+ overflow-x: auto;
166
+ border-collapse: collapse;
167
+ }
168
+ ${me} [data-component="chat/agent_msg/msg"] th,
169
+ ${me} [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
+ ${me} [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
+ `,nf=`
185
+ ${me} [data-component="chat/agent_msg_group/root/avatar"],
186
+ ${me} [data-component="chat/agent_msg_group/avatar_and_msgs/avatar"] {
187
+ display: none !important;
188
+ }
189
+ `,rf=`
190
+ ${me} [data-component="chat/agent_msg_group/avatar_and_msgs/root"] {
191
+ align-items: flex-start !important;
192
+ }
193
+ ${me} [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
+ ${me} [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
+ ${me} [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
+ ${me} [data-component="chat/bot_loading/root"] > :first-child {
212
+ width: 20px !important;
213
+ height: 20px !important;
214
+ margin-top: 2px !important;
215
+ }
216
+ `;function xs({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 of({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 sf({anchored:e,side:t,onSelectSide:n,docked:o,onToggleDock:s}){const{t:a}=G();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:Qe},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(bs,{label:a("companion_sidebar_dock_label"),children:r.jsx(af,{label:a("companion_sidebar_dock_label"),checked:o,onToggle:s})}),r.jsx(bs,{label:a("companion_sidebar_side_label"),children:r.jsx(cf,{label:a("companion_sidebar_side_label"),side:t,onSelect:n})})]})})}function bs({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 af({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:Et,className:"size-3 rounded-full bg-background shadow-sm"})})}function cf({label:e,side:t,onSelect:n}){const{t:o}=G(),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:a,labelKey:i})=>{const c=a===t;return r.jsxs("button",{...P("companion/layout_picker/sidebar_option"),type:"button",role:"radio","aria-checked":c,"aria-label":o(i),onClick:()=>n(a),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:Et,className:"absolute inset-0 rounded-full bg-background shadow-sm"}),r.jsx("span",{className:"relative",children:r.jsx(of,{side:a})})]},a)})})}const lf={compact:"companion_layout_floating",sidebar:"companion_layout_sidebar",fullscreen:"companion_layout_fullscreen"};function df(e){try{return e.matches(":focus-visible")}catch{return!0}}function uf({current:e,onSelect:t}){const{t:n}=G(),{allowedLayouts:o,sidebarSide:s,setSidebarSide:a,sidebarMode:i,setSidebarMode:c}=k.useWidgetLayout(),[d,l]=u.useState(!1),p=_n(),m=o.map(x=>({layout:x,label:lf[x]})),f=m.length>=2,h=o.includes("sidebar");if(!f&&!h)return null;const b=h&&(f?p?d:e==="sidebar":!0),g=x=>{x(),e!=="sidebar"&&t("sidebar")},C=r.jsx(W.AnimatePresence,{initial:!1,children:b&&r.jsx(sf,{anchored:f,side:s,onSelectSide:x=>g(()=>a(x)),docked:i==="docked",onToggleDock:()=>g(()=>c(i==="docked"?"floating":"docked"))})});return r.jsxs(Xe.Root,{onOpenChange:()=>l(!1),children:[r.jsx(Ee,{content:n("companion_layout_label"),side:"bottom",children:r.jsx(Xe.Trigger,{asChild:!0,children:r.jsx(lo,{...P("companion/layout_picker/trigger"),label:n("companion_layout_label"),className:"size-7",children:r.jsx(xs,{layout:e,sidebarSide:s})})})}),r.jsx(Xe.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:f?r.jsx("div",{className:"flex items-stretch gap-0.5",children:m.map(({layout:x,label:N})=>{const w=x===e,S=n(N),j=x==="sidebar",v=r.jsx(Xe.Close,{asChild:!0,children:r.jsxs("button",{...P("companion/layout_picker/option"),type:"button","aria-label":S,"aria-pressed":w,"aria-expanded":j?b:void 0,onClick:()=>t(x),onPointerEnter:()=>l(j),onFocus:_=>l(j&&df(_.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(xs,{layout:x,sidebarSide:s}),r.jsx("span",{className:"whitespace-nowrap text-[10px] font-medium leading-none",children:S})]})});return j?r.jsxs("div",{className:"relative flex",children:[v,C]},x):x!=="fullscreen"?r.jsx(u.Fragment,{children:v},x):r.jsx(Ee,{content:S,shortcut:oo(Pe["toggle-fullscreen"]),side:"bottom",children:v},x)})}):C})]})}function pf({layout:e,onSelectLayout:t,onClose:n}){const{t:o}=G();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(uf,{current:e,onSelect:t}),r.jsx(Ee,{content:o("companion_close"),shortcut:oo(Pe["close-panel"]),side:"bottom",children:r.jsx(lo,{...P("companion/close_btn"),label:o("companion_close"),onClick:n,className:"size-7",children:r.jsx(T.XIcon,{className:"size-4"})})})]})}const mf=`
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 hf({state:e,layout:t,shellRadius:n,onMinimize:o,onDismiss:s,onToggleFullscreen:a,onSelectLayout:i,onExpand:c,canExpand:d,placeholder:l,hideAttachTools:p,onInputHeightChange:m}){const{companion:f}=k.useConfig(),h=ci(),{t:b}=G(),g=u.useRef(null),C=u.useRef(null),x=u.useRef(null),N=(f==null?void 0:f.bubbles)===!0,w=(f==null?void 0:f.avatars)??N,S=mf+(N?"":tf)+(w?"":nf)+(w&&!N?rf:"");return u.useEffect(()=>{var _;const j=(_=g.current)==null?void 0:_.ownerDocument;if(!j)return;function v(R){Wi(R,{state:e,onDismiss:s,onToggleFullscreen:a})}return j.addEventListener("keydown",v),()=>j.removeEventListener("keydown",v)},[s,a,e]),u.useLayoutEffect(()=>{var I;if(e!=="input")return;const j=C.current,v=(I=j==null?void 0:j.ownerDocument.defaultView)==null?void 0:I.ResizeObserver;if(!j||!v)return;const _=()=>m(j.offsetHeight);_();const R=new v(_);return R.observe(j),()=>R.disconnect()},[e,m]),u.useLayoutEffect(()=>{e!=="input"||d||h||Gn(C.current)},[e,d,h]),u.useLayoutEffect(()=>{var _;if(e!=="chat"||Gn(x.current))return;const j=(_=x.current)==null?void 0:_.ownerDocument.defaultView;if(!j)return;const v=j.requestAnimationFrame(()=>Gn(x.current));return()=>j.cancelAnimationFrame(v)},[e]),r.jsx(Tn,{overrides:S,rootRef:g,shellRadius:`${n}px`,children:e==="input"?r.jsxs("div",{ref:C,"data-companion-input":!0,style:{position:"absolute",left:0,right:0,bottom:0,"--opencx-companion-input-radius":`${Ke.input}px`},children:[r.jsxs("div",{className:"relative",children:[r.jsx(hu,{children:r.jsx(Si,{disabled:h,hideAttachTools:p,placeholder:l,trailingActions:h?r.jsx(lo,{label:b("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":b("companion_expand_chat"),onClick:c,className:"absolute inset-0 z-10 cursor-pointer"}):null]}),r.jsx(br,{})]}):r.jsxs("div",{ref:x,"data-companion-root":!0,"data-layout":t,style:{position:"absolute",inset:0,"--opencx-companion-content-max-width":(f==null?void 0:f.contentMaxWidth)??"48rem"},children:[r.jsx(co,{}),r.jsx(pf,{layout:t,onSelectLayout:i,onClose:o})]})})}function Gn(e){const t=e==null?void 0:e.querySelector("textarea");return t?(t.focus({preventScroll:!0}),!0):!1}function ws({initialContent:e,title:t=Da,style:n,iframeRef:o,children:s}){const[a,i]=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(),i(l.body))},[]);return r.jsxs(r.Fragment,{children:[r.jsx("iframe",{ref:c,title:t,style:n,allowFullScreen:!0}),a&&Vt.createPortal(s,a)]})}function ff({size:e,headColor:t,eyeColor:n}){const o=u.useRef(null),[s,a]=u.useState(!1),[i,c]=u.useState(!1),d=W.useReducedMotion(),l=W.useMotionValue(0),p=W.useMotionValue(0),m=W.useSpring(l,{stiffness:300,damping:30}),f=W.useSpring(p,{stiffness:300,damping:30}),h=W.useTransform(m,w=>8+w*1.2),b=W.useTransform(f,w=>11.5+w*1.2),g=W.useTransform(m,w=>16+w*1.2),C=W.useTransform(f,w=>11.5+w*1.2),x=u.useCallback(w=>{const S=o.current;if(!S)return;const j=S.getBoundingClientRect(),v=j.left+j.width/2,_=j.top+j.height/2,R=(w.clientX-v)/(j.width*2),I=(w.clientY-_)/(j.height*2),M=Math.min(Math.sqrt(R*R+I*I),1),D=Math.atan2(I,R);l.set(Math.cos(D)*M),p.set(Math.sin(D)*M)},[l,p]);u.useEffect(()=>(s&&!d?window.addEventListener("mousemove",x):(l.set(0),p.set(0)),()=>window.removeEventListener("mousemove",x)),[s,x,l,p,d]),u.useEffect(()=>{if(d)return;let w,S;function j(){clearTimeout(w),clearTimeout(S)}function v(){w=setTimeout(()=>{c(!0),S=setTimeout(()=>c(!1),150),v()},1200+Math.random()*1800)}function _(){j(),document.visibilityState==="visible"&&v()}return document.visibilityState==="visible"&&v(),document.addEventListener("visibilitychange",_),()=>{j(),document.removeEventListener("visibilitychange",_)}},[d]);const N=i?.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:()=>a(!0),onMouseLeave:()=>a(!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:h,cy:b,r:1.4,fill:t,animate:{scaleY:N},style:{originX:"8px",originY:"11.5px"},transition:{duration:.08}}),r.jsx(W.motion.circle,{cx:g,cy:C,r:1.4,fill:t,animate:{scaleY:N},style:{originX:"16px",originY:"11.5px"},transition:{duration:.08}})]})}function gf({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(ff,{size:n,headColor:t,eyeColor:"hsl(var(--opencx-primary-foreground))"})}function xf(e){return{initial:!1,animate:{opacity:e?1:0},transition:{...we,delay:e?.25:0}}}function bf({visible:e,docked:t,label:n,icon:o,pillBackground:s,dir:a,measureRef:i,activeCount:c=0,countLabel:d,onOpenChats:l,pickerOpen:p=!1,working:m=!1,sessions:f,unreadCount:h=0,unreadShowCount:b=!1}){const g=W.useReducedMotion(),C=Math.max(3,zi(Ge,b));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))"},...xf(e),children:[e&&!t&&c>0&&r.jsx("button",{type:"button","data-companion-count-trigger":"","aria-label":d,"aria-haspopup":"menu","aria-expanded":p,onClick:x=>{x.stopPropagation(),l==null||l(x.currentTarget,x.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,m&&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:i,dir:a,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:Ge,height:Ge},children:[r.jsx(gf,{icon:o,pillBackground:s,size:Ge}),e&&h>0&&r.jsxs(r.Fragment,{children:[r.jsx(Gm,{}),r.jsx(Ii,{count:h,showCount:b,style:{top:C,insetInlineEnd:C}})]})]}),r.jsx(W.motion.span,{initial:!1,animate:{opacity:t?1:0},transition:{duration:.12,ease:Qe},style:{fontSize:13,color:"hsl(var(--opencx-muted-foreground))",whiteSpace:"nowrap"},children:n}),f&&r.jsx("div",{style:{position:"relative",zIndex:2,paddingInlineStart:4,opacity:t?1:0},children:f})]})]})}function wf({chat:e,number:t,selected:n,interactive:o,onSelect:s,onClose:a,portalTarget:i}){const{t:c}=G(),{cssVars:d,theme:l}=de(),[p,m]=u.useState(!1);u.useEffect(()=>{o||m(!1)},[o]);const{title:f}=Vr(e),h=`${f}${e.working?` — ${c("thinking")}`:""}`;function b(C){return i&&r.jsx(Ne.Portal,{container:i,children:r.jsxs(Ne.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:[C,r.jsx(Ne.Arrow,{width:8,height:4,style:{fill:"hsl(var(--opencx-foreground))"}})]})})}const g=c("companion_close_chat",{title:f});return r.jsxs("div",{"data-session-item":"",children:[r.jsxs(Ne.Root,{open:o&&p,onOpenChange:m,children:[r.jsx(Ne.Trigger,{asChild:!0,children:r.jsxs(V,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-session-circle":e.id,"aria-label":h,"aria-pressed":n,tabIndex:o?0:-1,onClick:C=>{C.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})]})}),b(h)]}),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:C=>{C.stopPropagation(),m(!1),a(C.currentTarget)},children:r.jsx(T.XIcon,{size:10,"aria-hidden":!0})})]})}function vf({onSelected:e=()=>{},onLastClosed:t=()=>{},interactive:n=!0}){const{openChats:o,activeId:s,selectChat:a,newChat:i,closeChat:c}=k.useCompanionChats(),{canCreateNewSession:d}=k.useSessions(),{isSmallScreen:l}=ye(),{t:p,dir:m}=G(),f=Yr(),h=An(),b=l?2:3,g=o.slice(0,o.length>b?b-1:b),C=o.find(v=>v.id===s);C&&!g.includes(C)&&(g[g.length-1]=C);const x=o.length-g.length,N=o.some(v=>v.working&&!g.includes(v)),w=u.useRef(f.close);w.current=f.close,u.useEffect(()=>{n||w.current(!0)},[n]);function S(v){f.close(!0),v===void 0?i():a(v),e()}function j(v,_){var M,D;f.close(!0);const R=g.findIndex(O=>O.id===v),I=g[R+1]??g[R-1];(D=(M=_.closest("[data-companion-session-circles]"))==null?void 0:M.querySelector(I?`[data-session-circle="${I.id}"]`:"[data-new-session]"))==null||D.focus({preventScroll:!0}),c(v),o.length===1&&t()}return r.jsx(Ne.Provider,{delayDuration:150,skipDelayDuration:300,children:r.jsxs("div",{role:"group","aria-label":p("companion_active_chats",{count:o.length}),"aria-hidden":!n||void 0,"data-companion-session-circles":"",dir:m,onPointerDown:v=>v.stopPropagation(),style:{position:"relative",zIndex:0,display:"flex",alignItems:"center",gap:4,flexShrink:0,pointerEvents:n?"auto":"none"},children:[r.jsx(Xr,{}),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(wf,{chat:v,number:v.id,selected:v.id===s,interactive:n,portalTarget:h,onSelect:()=>S(v.id),onClose:_=>j(v.id,_)},v.id)),x>0&&r.jsxs(V,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","aria-label":p("companion_chats"),"aria-haspopup":"menu","aria-expanded":f.open,tabIndex:n?0:-1,onPointerEnter:v=>f.hover(v.currentTarget),onPointerLeave:f.leave,onClick:v=>{v.stopPropagation(),f.toggle(v.currentTarget,v.detail>0)},children:[N&&r.jsx(T.LoaderCircleIcon,{size:28,"aria-hidden":!0,"data-session-working":""}),r.jsxs("span",{"aria-hidden":!0,children:["+",x]})]}),r.jsx(V,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-new-session":"","aria-label":p("new_conversation"),disabled:!d,tabIndex:n?0:-1,onClick:v=>{v.stopPropagation(),S()},children:r.jsx(T.PlusIcon,{size:14,"aria-hidden":!0})}),f.anchor&&h&&r.jsx(Gr,{picker:f,portalTarget:h,placement:"above",onSelected:e})]})})}function yf({panelOpen:e,isOpen:t,setIsOpen:n,onOpen:o,onClose:s}){const a=u.useRef(t),i=u.useRef({onOpen:o,onClose:s});i.current={onOpen:o,onClose:s},u.useEffect(()=>{a.current=e,n(e)},[e,n]),u.useEffect(()=>{t!==a.current&&(a.current=t,t?i.current.onOpen():i.current.onClose())},[t])}function mo({transcriptVisible:e=!0}){return k.useUnreadViewing({transcriptVisible:e}),null}const lt="data-opencx-app-frame",kf="data-opencx-app-frame-style",Ut="data-opencx-sidebar-open",Sn="data-opencx-frame-no-anim",qt="data-opencx-fixed-fit",ho="--opencx-sidebar-w",kt=Cd;let Ze=null,Ct=null,vs=0;const Dt=new Map,ys={setOpen:()=>{},setWidth:()=>{},setAnimated:()=>{},release:()=>{}};function jf(){let e,t;return Dt.forEach(n=>{(!e||n.order>e.order)&&(e=n),n.open&&(!t||n.order>t.order)&&(t=n)}),t??e}function Kn(){const e=jf();if(!e||!Ze)return;Ze.textContent=Cf(e.canvas,e.side,e.pageBackground);const t=document.documentElement;e.open?t.setAttribute(Ut,""):t.removeAttribute(Ut),e.animated?t.removeAttribute(Sn):t.setAttribute(Sn,""),t.style.setProperty(ho,`${e.width}px`)}function ks(e){getComputedStyle(e).position==="fixed"&&e.setAttribute(qt,"");for(const t of Array.from(e.querySelectorAll("*")))getComputedStyle(t).position==="fixed"&&t.setAttribute(qt,"")}function Cf(e,t,n){const[o,s]=t==="left"?["right","left"]:["left","right"];return`
334
+ html[${lt}] {
335
+ overflow: hidden !important;
336
+ background: ${e} !important;
337
+ }
338
+ html[${lt}] 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[${lt}] body {
357
+ transition:
358
+ top 0.3s ${kt}, bottom 0.3s ${kt},
359
+ left 0.3s ${kt}, right 0.3s ${kt},
360
+ border-radius 0.3s ${kt}, box-shadow 0.3s ${kt} !important;
361
+ }
362
+ }
363
+ html[${Sn}] body { transition: none !important; }
364
+ html[${lt}] body [${qt}] {
365
+ max-width: 100% !important;
366
+ max-height: 100% !important;
367
+ }
368
+ html[${Ut}] body {
369
+ top: ${_e}px !important;
370
+ bottom: ${_e}px !important;
371
+ ${o}: ${_e}px !important;
372
+ ${s}: calc(var(${ho}, ${uo}px) + ${_e*2}px) !important;
373
+ border-radius: ${Ke.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: ${Yi}px) {
377
+ html[${Ut}] 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 Sf({canvas:e,side:t,pageBackground:n}){if(typeof document>"u")return ys;const o=document.documentElement;if(!Ze&&o.hasAttribute(lt))return ys;if(!Ze){const d=document.createElement("style");d.setAttribute(kf,""),document.head.appendChild(d);const l=window.scrollY;o.setAttribute(lt,""),document.body.scrollTop=l,ks(document.body),Ct=new MutationObserver(p=>{for(const m of p)for(const f of Array.from(m.addedNodes))f instanceof Element&&ks(f)}),Ct.observe(document.body,{childList:!0,subtree:!0}),Ze=d}const s=Symbol("opencx-app-frame-owner"),a={canvas:e,side:t,pageBackground:n,open:!1,width:uo,animated:!0,order:++vs};Dt.set(s,a),Kn();let i=!1;const c=d=>{if(i)return;const l=Dt.get(s);l&&(d(l),Kn())};return{setOpen(d){c(l=>{l.open=d,d&&(l.order=++vs)})},setWidth(d){c(l=>{l.width=d})},setAnimated(d){c(l=>{l.animated=d})},release(){i||(i=!0,Dt.delete(s),Dt.size===0?Nf():Kn())}}}function Nf(){if(!Ze)return;const e=document.body.scrollTop,t=document.documentElement;t.removeAttribute(lt),t.removeAttribute(Ut),t.removeAttribute(Sn),t.style.removeProperty(ho),Ct==null||Ct.disconnect(),Ct=null;for(const n of Array.from(document.querySelectorAll(`[${qt}]`)))n.removeAttribute(qt);Ze.remove(),Ze=null,window.scrollTo({top:e})}let Lt=0,Zn="";function _f(){if(typeof document>"u")return()=>{};Lt===0&&(Zn=document.body.style.overflow,document.body.style.overflow="hidden"),Lt+=1;let e=!1;return()=>{e||(e=!0,Lt=Math.max(0,Lt-1),Lt===0&&(document.body.style.overflow=Zn,Zn=""))}}function Ef(e,t){return e[t]??""}function Tf({companion:e,layout:t,state:n,region:o,sidebarSide:s,sidebarMode:a,cssVars:i,storage:c,resizeLabel:d}){var z,H,L,q,X,U;const l=Math.max(0,((z=e==null?void 0:e.sidebar)==null?void 0:z.minWidth)??qi),p=Math.max(l,((H=e==null?void 0:e.sidebar)==null?void 0:H.maxWidth)??Kh),[m,f]=u.useState(()=>{var F;return at(((F=e==null?void 0:e.sidebar)==null?void 0:F.width)??uo,l,p)}),[h,b]=u.useState(!1),g=u.useRef(null);u.useEffect(()=>{f(F=>{var J;return at(((J=e==null?void 0:e.sidebar)==null?void 0:J.width)??F,l,p)})},[(L=e==null?void 0:e.sidebar)==null?void 0:L.width,p,l]),u.useEffect(()=>{var J;let F=!1;if(!(!c||((J=e==null?void 0:e.sidebar)==null?void 0:J.width)!==void 0))return c.getCompanionSidebarWidth().then(re=>{F||re===null||f(at(re,l,p))}).catch(()=>{}),()=>{F=!0}},[(q=e==null?void 0:e.sidebar)==null?void 0:q.width,p,l,c]);const C=u.useCallback(F=>at(s==="left"?F:window.innerWidth-F,l,p),[p,l,s]),x=u.useCallback(F=>{var J;F.currentTarget.setPointerCapture(F.pointerId),b(!0),(J=g.current)==null||J.setAnimated(!1)},[]),N=u.useCallback(F=>{F.currentTarget.hasPointerCapture(F.pointerId)&&f(C(F.clientX))},[C]),w=u.useCallback(F=>{var re;const J=C(F.clientX);F.currentTarget.hasPointerCapture(F.pointerId)&&F.currentTarget.releasePointerCapture(F.pointerId),f(J),b(!1),(re=g.current)==null||re.setAnimated(!0),c==null||c.setCompanionSidebarWidth(J).catch(()=>{})},[c,C]),S=u.useCallback(F=>{var J;F.currentTarget.hasPointerCapture(F.pointerId)&&F.currentTarget.releasePointerCapture(F.pointerId),b(!1),(J=g.current)==null||J.setAnimated(!0)},[]),j=u.useCallback(F=>{let J=null;if(F.key==="Home"&&(J=l),F.key==="End"&&(J=p),F.key==="ArrowLeft"||F.key==="ArrowRight"){const re=F.key===(s==="left"?"ArrowRight":"ArrowLeft");J=at(m+(re?16:-16),l,p)}J!==null&&(F.preventDefault(),f(J),c==null||c.setCompanionSidebarWidth(J).catch(()=>{}))},[p,l,s,m,c]),v=t==="sidebar",_=a==="docked",R=po(o,m),I=((X=e==null?void 0:e.sidebar)==null?void 0:X.canvasColor)??Zh,M=`hsl(${Ef(i,"--opencx-background")})`,D=u.useRef({open:n!=="pill",width:R});D.current={open:n!=="pill",width:R},u.useEffect(()=>{if(!v||!_)return;const F=Sf({canvas:I,side:s,pageBackground:M});return g.current=F,F.setWidth(D.current.width),F.setOpen(D.current.open),()=>{g.current===F&&(g.current=null),F.release()}},[I,_,v,M,s]),u.useEffect(()=>{var F;v&&_&&((F=g.current)==null||F.setWidth(R))},[R,_,v]),u.useEffect(()=>{var F;v&&_&&((F=g.current)==null||F.setOpen(n!=="pill"))},[_,v,n]);const O=n==="chat"&&t==="fullscreen",B=((U=e==null?void 0:e.fullscreen)==null?void 0:U.lockScroll)!==!1;u.useEffect(()=>{if(!(!O||!B))return _f()},[O,B]);const E=u.useMemo(()=>({role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":d,"aria-valuemin":l,"aria-valuemax":p,"aria-valuenow":m,onPointerDown:x,onPointerMove:N,onPointerUp:w,onPointerCancel:S,onKeyDown:j}),[p,l,j,x,N,S,w,d,m]);return{sidebarWidth:m,sidebarResizing:h,resizeHandleProps:E}}const Af={width:1440,height:900};function js(){return typeof window>"u"?Af:{width:window.innerWidth,height:window.innerHeight}}function zf(){const[e,t]=u.useState(js),[n,o]=u.useState(null),s=u.useRef(null),a=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(js())}return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),u.useEffect(()=>()=>{var c;(c=s.current)==null||c.disconnect(),s.current=null},[]);const i=Math.min(n??Uh,Math.max(0,e.width-Ui));return{region:e,dockWidth:i,dockContentRef:a}}function If({storage:e,state:t,layout:n,viewportWidth:o,currentWidth:s,restingWidth:a,shouldReduceMotion:i}){const[c,d]=u.useState(0),l=W.useMotionValue(0),p=u.useRef(!1);u.useEffect(()=>{let C=!1;if(e)return e.getCompanionPillOffsetX().then(x=>{C||x===null||d(x)}).catch(()=>{}),()=>{C=!0}},[l,e]),u.useEffect(()=>{const C=i?we:Et;if(t==="pill"){const N=Math.max(0,o/2-a/2-Xn),w=at(c,-N,N);Math.abs(l.get())>N?l.set(w):W.animate(l,w,C);return}if(t==="chat"&&(n==="fullscreen"||n==="sidebar")){W.animate(l,0,C);return}const x=Math.max(0,o/2-s/2-Xn);W.animate(l,at(c,-x,x),C)},[s,l,n,c,a,i,t,o]);const m=Math.max(0,o/2-a/2-Xn),f=u.useMemo(()=>({left:-m,right:m,top:0,bottom:0}),[m]),h=u.useCallback(()=>{p.current=!0},[]),b=u.useCallback(()=>{const C=l.get();d(x=>x===C?x:C),e==null||e.setCompanionPillOffsetX(C).catch(()=>{}),requestAnimationFrame(()=>{p.current=!1})},[l,e]),g=u.useCallback(()=>p.current,[]);return{dragX:l,dragConstraints:f,onDragStart:h,onDragEnd:b,shouldIgnoreLaunch:g}}function Mf({state:e,layout:t,sidebarMode:n,isPageMarkModeArmed:o}){return e==="pill"||o?!1:!(t==="sidebar"&&n==="docked")}const Rf=96,Cs=qr({transparent:!0});function Pf(){var wo,vo,yo;const{isOpen:e,setIsOpen:t}=k.useWidgetTrigger(),{openChats:n,activeId:o}=k.useCompanionChats(),s=n.length,{count:a}=k.useUnread(),i=n.filter(Q=>Q.working).length,{widgetCtx:c,contentIframeRef:d}=k.useWidget(),{companion:l,assets:p,customComponents:m,initialQuestions:f}=k.useConfig(),{theme:h,cssVars:b}=de(),{t:g,dir:C}=G(),{sessionState:x}=k.useSessions(),{messagesState:N}=k.useMessages(),{isArmed:w}=so(),{region:S,dockWidth:j,dockContentRef:v}=zf(),[_,R]=u.useState(e?"chat":"pill"),{layout:I,setLayout:M,setLayoutPreference:D,allowedLayouts:O,defaultLayout:B,sidebarSide:E,sidebarMode:z}=k.useWidgetLayout(),[H,L]=u.useState(Rf),{sidebarWidth:q,sidebarResizing:X,resizeHandleProps:U}=Tf({companion:l,layout:I,state:_,region:S,sidebarSide:E,sidebarMode:z,cssVars:b,storage:c.storageCtx,resizeLabel:g("companion_resize_chat")}),F=W.useReducedMotion(),J=X?{duration:0}:F?we:Et,re=_n(),$=u.useRef(null),te=u.useRef(!1),K=_==="pill",oe=_==="input"&&N.messages.length===0&&(f==null?void 0:f.some(Q=>Q.trim().length>0))===!0,[he,le]=u.useState(0),se=s>0,ne=Yr(),ze=u.useRef(ne.close);ze.current=ne.close,u.useEffect(()=>{(!K||!se)&&ze.current(!0)},[K,se]);const ie=m==null?void 0:m.widgetTrigger,ue=!!ie,ft=(l==null?void 0:l.pillBackground)??"hsl(var(--opencx-primary))",et=(l==null?void 0:l.icon)??((wo=p==null?void 0:p.widgetTrigger)==null?void 0:wo.openIcon),Ie=h.widgetTrigger.offset.bottom,He=In(),tt=Mn(a),We=Fi(),Oe=tt?`${We} · ${tt}`:We,Be=!!((vo=x.session)!=null&&vo.id),Ue=Be?g("follow_up_placeholder"):void 0,ge=(l==null?void 0:l.pillLabel)??(l==null?void 0:l.placeholder)??Ue??g("write_a_message_placeholder"),Me=(l==null?void 0:l.pillLabelDisplay)??"always",$e=(l==null?void 0:l.placeholder)??Ue??g("write_a_message_placeholder"),[Pn,tn]=u.useState(!1),xe=K&&!ue&&Me!=="never"&&(Me==="always"||re&&Pn),Mt=Xi(S,l==null?void 0:l.compact),On=I==="sidebar",gt=Qh({layout:I,region:S,sidebarWidth:q,bottomOffset:Ie,compact:l==null?void 0:l.compact}),nn=_==="chat"?gt.width:Mt,$n=gt.height,{centerX:rn,bottom:on}=ef({isChatOpen:_==="chat",layout:I,region:S,sidebarWidth:q,sidebarSide:E,bottomOffset:Ie}),Y=u.useMemo(()=>_==="pill"?xe?{width:j,height:Bh,borderRadius:Ke.pill}:{width:Ge,height:Ge,borderRadius:Ke.pill}:_==="input"?{width:Mt,height:H,borderRadius:Ke.input}:gt,[_,xe,j,Mt,gt,H]),fe=_==="pill"&&xe&&Me==="hover"?(C==="rtl"?-1:1)*(j-Ge)/2:0,{dragX:Rt,dragConstraints:Le,onDragStart:nt,onDragEnd:Pt,shouldIgnoreLaunch:be}=If({storage:c.storageCtx,state:_,layout:I,viewportWidth:S.width,currentWidth:Y.width,restingWidth:xe?j:Ge,shouldReduceMotion:F}),xt=u.useCallback(()=>{var $t;const Q=c.routerCtx.state.get().screen,ce=!!(($t=c.sessionCtx.sessionState.get().session)!=null&&$t.id);R(Q==="welcome"||ce?"chat":"input")},[c]),bt=u.useCallback(()=>{if(!be()){if(ze.current(!0),I==="sidebar"){R("chat");return}xt()}},[xt,I,be]),wt=u.useCallback(()=>{if(I==="fullscreen"&&B!=="fullscreen"){M(B);return}if(I==="sidebar"){R("pill");return}R(Q=>{var ce;return Q==="chat"&&((ce=c.sessionCtx.sessionState.get().session)!=null&&ce.id)?"input":"pill"})},[B,I,M,c]),Ot=u.useCallback(()=>{const Q=Dh({panelLayout:I,previousLayout:vt.current,defaultLayout:B,allowedLayouts:O});if(Q.kind==="layout"){M(Q.layout);return}R("pill")},[O,B,I,M]),sn=u.useCallback(()=>{R("pill")},[]);u.useEffect(()=>{_==="chat"&&(te.current=!0)},[_]),u.useEffect(()=>{_!=="chat"&&te.current&&I==="fullscreen"&&B!=="fullscreen"&&M(B)},[B,I,M,_]);const pe=_==="chat"&&I==="fullscreen";yf({panelOpen:_!=="pill",isOpen:e,setIsOpen:t,onOpen:xt,onClose:sn}),u.useEffect(()=>{if(!Mf({state:_,layout:I,sidebarMode:z,isPageMarkModeArmed:w}))return;function Q(ce){if(Wh(ce))return;const $t=$.current;$t&&(ce.composedPath().includes($t)||wt())}return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[wt,_,I,z,w]);const rt=((yo=N.messages.findLast(Q=>Q.type==="USER"))==null?void 0:yo.id)??null,bo=u.useRef(null);u.useEffect(()=>{_==="input"&&(bo.current=rt)},[_]),u.useEffect(()=>{_==="input"&&rt!==bo.current&&(c.routerCtx.state.get().screen!=="chat"&&c.routerCtx.state.setPartial({screen:"chat"}),R("chat"))},[rt,_,c]);const Qi=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]),an=u.useCallback(Q=>{var ce;O.includes(Q)&&(Q==="fullscreen"&&c.routerCtx.state.get().screen==="sessions"&&c.routerCtx.toChatScreen((ce=c.sessionCtx.sessionState.get().session)==null?void 0:ce.id),D(Q))},[O,c,D]),Ln=O.find(Q=>Q!=="fullscreen"),vt=u.useRef(Ln??B);u.useEffect(()=>{I!=="fullscreen"&&O.includes(I)?vt.current=I:(vt.current==="fullscreen"||!O.includes(vt.current))&&(vt.current=Ln??B)},[O,B,Ln,I]);const cn=u.useCallback(()=>{if(!O.includes("fullscreen"))return;if(I!=="fullscreen"){an("fullscreen");return}const Q=vt.current;Q!=="fullscreen"&&O.includes(Q)&&an(Q)},[O,I,an]);u.useEffect(()=>{function Q(ce){Lh(ce,{state:_,onToggleFullscreen:cn})}return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[cn,_]);const Dn=An();return Dn?Vt.createPortal(r.jsxs(r.Fragment,{children:[r.jsx(mo,{transcriptVisible:_==="chat"}),ie&&Hi(ie,e,t,a),K&&ne.anchor&&!ue&&r.jsx(Gr,{placement:"above",picker:ne,portalTarget:Dn,onSelected:()=>R("chat")}),r.jsx(W.motion.div,{"aria-hidden":!0,style:{position:"fixed",inset:0,background:"transparent",zIndex:h.widgetContentContainer.zIndex,pointerEvents:pe?"auto":"none"},initial:!1,animate:{opacity:pe?1:0},transition:Te}),r.jsxs(W.motion.div,{ref:$,style:{...b,position:"fixed",x:Rt,translateX:"-50%",zIndex:h.widgetContentContainer.zIndex,visibility:ue&&K?"hidden":void 0},initial:!1,animate:{left:rn,bottom:on},drag:K&&!ue&&!ne.open?"x":!1,dragMomentum:!1,dragElastic:.15,dragConstraints:Le,onDragStart:nt,onDragEnd:Pt,transition:J,children:[oe&&r.jsx("div",{"data-companion-starters":!0,style:{position:"absolute",bottom:"calc(100% + 12px)",left:"50%",transform:"translateX(-50%)",width:nn,height:he},children:r.jsx(ws,{title:"Suggested questions",initialContent:Cs,style:{width:"100%",height:"100%",border:0,background:"transparent"},children:r.jsx(Fh,{onHeightChange:le,onDismiss:Ot,onToggleFullscreen:cn,maxHeight:Math.max(48,S.height-Y.height-Ie-32)})})}),r.jsxs(W.motion.div,{onPointerEnter:K&&!ue?Q=>{tn(!0);const ce=Q.currentTarget.querySelector("[data-companion-count-trigger]");ce&&!be()&&ne.hover(ce)}:void 0,onPointerLeave:()=>{tn(!1),ne.leave()},style:{position:"relative",overflow:"hidden",transformOrigin:"center bottom",cursor:K&&!ue?xe?"pointer":"grab":"default",background:"hsl(var(--opencx-background))"},initial:!1,animate:{x:fe,width:Y.width,height:Y.height,borderTopLeftRadius:Y.borderRadius,borderTopRightRadius:Y.borderRadius,borderBottomLeftRadius:Y.borderRadius,borderBottomRightRadius:Y.borderRadius,boxShadow:K?xe?Nd:Sd:_==="input"?_d:Ed},whileHover:K&&!ue&&re&&!F?{scale:xe?1.01:1.12}:void 0,whileTap:K&&!ue?{scale:xe?.995:.92}:void 0,transition:J,children:[K&&!ue&&r.jsx("button",{type:"button","data-companion-launcher":"",onClick:bt,"aria-label":Oe,"aria-expanded":!1,style:{position:"absolute",inset:0,zIndex:1,border:0,padding:0,background:"transparent",cursor:"pointer",borderRadius:"inherit"}}),!ue&&r.jsx(bf,{visible:K,docked:xe,label:ge,sessions:s>0?r.jsx(vf,{interactive:K&&xe,onSelected:()=>R("chat"),onLastClosed:()=>{requestAnimationFrame(()=>{var Q,ce;(ce=(Q=$.current)==null?void 0:Q.querySelector("[data-companion-launcher]"))==null||ce.focus({preventScroll:!0})})}}):void 0,activeCount:s,countLabel:`${g("companion_chats")} · ${g("companion_active_chats",{count:s})}${i?` · ${g("companion_working_chats",{count:i})}`:""}`,pickerOpen:ne.open,onOpenChats:(Q,ce)=>{be()||ne.toggle(Q,ce)},working:i>0,icon:et,pillBackground:ft,dir:C,measureRef:v,unreadCount:He===!1?0:a,unreadShowCount:He==="count"}),_!=="pill"&&r.jsx(W.motion.div,{style:{position:"absolute",bottom:0,left:"50%",translateX:"-50%",width:nn,height:$n},initial:{opacity:0},animate:{opacity:1,transition:{...we,delay:F?0:.1}},children:r.jsx(ws,{iframeRef:d,initialContent:Cs,style:{width:"100%",height:"100%",overflow:"hidden",backgroundColor:"transparent",boxSizing:"border-box",borderWidth:"0px"},children:r.jsx(hf,{state:_==="chat"?"chat":"input",layout:I,shellRadius:Y.borderRadius,onMinimize:wt,onDismiss:Ot,onToggleFullscreen:cn,onSelectLayout:an,onExpand:Qi,canExpand:Be,placeholder:$e,hideAttachTools:((l==null?void 0:l.quickAskTools)??"history-only")==="history-only",onInputHeightChange:L},o)})}),On&&_==="chat"&&r.jsx("div",{...U,style:{position:"absolute",top:0,bottom:0,...E==="left"?{right:0}:{left:0},width:8,cursor:"ew-resize",zIndex:2}})]})]})]}),Dn):null}function Of(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,s=e.ownerDocument,a=s.documentElement.clientWidth||window.innerWidth,i=s.documentElement.clientHeight||window.innerHeight;if(n<0||o<0||n>a||o>i||typeof s.elementFromPoint!="function")return!0;const c=s.elementFromPoint(n,o);return c?c===e||e.contains(c)||c.contains(e):!0}function Er(e){const t=fi(e);if(!t)return{ok:!1,reason:"gone"};const{element:n}=t,o=kr(n);if(o)return{ok:!1,reason:"off-limits",detail:Yp[o]};const s=typeof n.checkVisibility=="function"?n.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}):n.isConnected,a=n.getBoundingClientRect();return!s||a.width===0||a.height===0?{ok:!1,reason:"hidden"}:Of(n)?t.isCurrent?{ok:!0,element:n}:{ok:!1,reason:"gone"}:{ok:!1,reason:"covered"}}function Ss(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 Tr(e,t){if(!(e instanceof HTMLSelectElement)||t===void 0)return null;const n=Array.from(e.options),o=n.filter(a=>a.value===t||a.label.trim().toLowerCase()===t.trim().toLowerCase()),[s]=o;return o.length!==1||!s||s.disabled||s.parentElement instanceof HTMLOptGroupElement&&s.parentElement.disabled||n.filter(a=>a.value===s.value).length!==1?null:s}function hn(e,t,n){const o=e.ownerDocument,s=f=>f.contains(e)||e.contains(f)||(e.getAttribute("aria-controls")??"").split(/\s+/).some(h=>{const b=o.getElementById(h);return b!==null&&(f.contains(b)||b.contains(f))}),a=Array.from(o.querySelectorAll('[aria-busy="true"]')).filter(f=>!Ae(f)&&!s(f)),i=f=>{for(let h=a.length-1;h>=0;h--)s(a[h])&&a.splice(h,1);return a.some(h=>h.contains(f))};let c=!1,d=performance.now(),l;const p=new MutationObserver(f=>{f.some(b=>{const g=b.target instanceof Element?b.target:b.target.parentElement;return g!==null&&!Qt(g)&&!i(g)})&&(c=!0,d=performance.now())});p.observe(o.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const m=()=>{clearTimeout(l),p.disconnect()};return{settle:()=>new Promise(f=>{const h=performance.now()+t,b=()=>{if(!n()){m(),f({mutated:c,loading:!1});return}const g=Array.from(o.querySelectorAll('[aria-busy="true"]')).some(x=>!i(x)&&!Ae(x)),C=performance.now();C>=h||!g&&C-d>=100?(m(),f({mutated:c,loading:g})):l=setTimeout(b,Math.min(100,h-C))};l=setTimeout(b,Math.min(100,t))}),cancel:m}}function $f(e){if(e.tagName.toLowerCase()==="input"){const t=(e.getAttribute("type")??"text").toLowerCase();if(ui.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 Lf(e){try{return await Df(e)}catch{return{outcome:"unsupported",detail:"That could not be done on this page."}}}async function Df({ref:e,action:t,value:n,settleMs:o=Rp,consentIsCurrent:s=()=>!0,observationIsCurrent:a=()=>!0}){var b;if(!s())return{outcome:"declined"};const i=Er(e);if(!i.ok)return i.reason==="off-limits"?{outcome:"unsupported",detail:i.detail}:{outcome:i.reason};const c=i.element,d=$f(c);if(d)return{outcome:"unsupported",detail:d};const l=c.ownerDocument,p=l.location.href;let m,f,h=!1;try{switch(t){case"click":{m=hn(c,o,a);const N=gs(c,s);if(N==="not-started")return m.cancel(),{outcome:"declined"};h=N==="interrupted";break}case"fill":{if(n===void 0)return{outcome:"unsupported",detail:"No value was given to type."};if(m=hn(c,o,a),(b=c.focus)==null||b.call(c),!s()){h=!0;break}if(!Ss(c,n))return m.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 N=Tr(c,n);if(!N)return{outcome:"no_change",detail:"That option is not in the list or cannot be selected unambiguously."};m=hn(c,o,a),f=N.value,Ss(c,N.value);break}case"check":case"uncheck":{const N=t==="check",w=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null,S=c.getAttribute("aria-checked");if(!w&&S===null)return{outcome:"unsupported",detail:"That control is not a checkbox or switch."};if((w?w.checked:S==="true")===N)return{outcome:"no_change",detail:`It is already ${N?"on":"off"}.`};m=hn(c,o,a);const v=gs(c,s);if(v==="not-started")return m.cancel(),{outcome:"declined"};h=v==="interrupted";break}}const{mutated:g,loading:C}=await(m==null?void 0:m.settle())??{mutated:!1,loading:!1};if(h)return{outcome:"no_change",detail:(g||l.location.href!==p?"The page changed. ":"")+"The requested action was interrupted after input events were dispatched. Its final result is unknown. Do not repeat it automatically."};const x=C?"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 N=c instanceof HTMLInputElement||c instanceof HTMLTextAreaElement||c instanceof HTMLSelectElement?c.value:null;return t==="fill"&&N!==n?{outcome:"no_change",detail:"The field did not keep what was typed."}:t==="select"&&N!==f?{outcome:"no_change",detail:"The dropdown did not keep the selected option."}:{outcome:"done",...x?{detail:x}:{}}}if(t==="check"||t==="uncheck"){const N=t==="check",w=c instanceof HTMLInputElement&&(c.type==="checkbox"||c.type==="radio")?c:null;return(w?w.checked:c.getAttribute("aria-checked")==="true")===N?{outcome:"done",...x?{detail:x}:{}}:{outcome:"no_change",detail:"It did not change."}}return g||l.location.href!==p?{outcome:"done",...x?{detail:x}:{}}:{outcome:"no_change",detail:x??"The control was clicked and nothing on the page changed during observation. Its final result is unknown. Do not repeat it automatically."}}finally{m==null||m.cancel()}}const Ff="cubic-bezier(0.32, 0.72, 0, 1)",Jn=260,Hf=1600,Wf=180,Ns=240,_s=.13,Bf=e=>e*e*e*(10-15*e+6*e*e);function Uf(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 qf(e,t,n=48){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s)||1,i={x:e.x+o/2-s/a*a*_s,y:e.y+s/2+o/a*a*_s},c=[];for(let d=0;d<=n;d+=1){const l=Uf(e,i,t,Bf(d/n));c.push({transform:`translate(${l.x-bn}px, ${l.y-wn}px)`})}return c}const bn=2,wn=1.7,Vf="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 fo(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const Es=e=>new Promise(t=>{window.setTimeout(t,fo()?0:e)});let dt=null,Ar;const Yf=4e3;function Nn(){clearTimeout(Ar),dt==null||dt.release(),dt=null,document.querySelectorAll("[data-opencx-cursor]").forEach(e=>e.remove())}function zr(){clearTimeout(Ar),Ar=setTimeout(Nn,Yf)}function Xf(e){if(dt)return zr(),dt;try{Nn();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 ${Jn}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="${Vf}" fill="currentColor" stroke="currentColor" stroke-width="1.7"
385
+ stroke-linejoin="round" stroke-linecap="round" paint-order="stroke"
386
+ style="transition: transform ${Ns}ms ${Ff}; transform-origin: ${bn}px ${wn}px"/>
387
+ </svg>`;const o=e??{x:window.innerWidth-40,y:window.innerHeight-40};let s=o;n.style.transform=`translate(${o.x-bn}px, ${o.y-wn}px)`,document.documentElement.appendChild(t);const a=n.querySelector("path");n.offsetWidth,n.style.opacity="1";let i=!1;const c={async moveTo(d,l){if(i)return;const p=`translate(${d-bn}px, ${l-wn}px)`;if(fo()||typeof n.animate!="function"){n.style.transform=p;return}n.style.transition=`opacity ${Jn}ms ease`;const m=qf(s,{x:d,y:l});await n.animate(m,{duration:Hf,easing:"linear",fill:"forwards"}).finished.catch(()=>{}),!i&&(n.style.transform=p,s={x:d,y:l},await Es(Wf))},async press(){i||!a||(a.style.transform="scale(0.86)",await Es(Ns),a.style.transform="")},release(){i||(i=!0,n.style.opacity="0",window.setTimeout(()=>t.remove(),Jn+60))}};return dt=c,zr(),c}catch{return null}}function Gf(e){const t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}async function Gi(e,{press:t=!1}={}){var o;const n=Xf();if(!n)return{done:()=>{}};try{(o=e.scrollIntoView)==null||o.call(e,{behavior:fo()?"auto":"smooth",block:"center",inline:"nearest"});const{x:s,y:a}=Gf(e);await n.moveTo(s,a),t&&await n.press()}catch{}return{done:zr}}const Kf=y.z.object({ref:y.z.string().min(1),action:y.z.enum(Mp),value:y.z.string().max(500).optional()});function Ki(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(a=>a.key===s),[])}const Zf=200;function Jf(){const{widgetCtx:e}=k.useWidget(),{pageEffects:t,replyToPageCall:n,requestPageActionConsent:o,isStreaming:s}=k.useAgentChatUi(),a=u.useRef(new Set),i=Ki(t,s);return u.useEffect(()=>{const c=a.current;for(const d of t){if(d.type!=="act-on-page"||c.has(d.key))continue;for(c.add(d.key);c.size>Zf;){const h=c.values().next().value;if(h===void 0)break;c.delete(h)}const l=Kf.safeParse(d.input);if(!l.success){Z.log.warn("act_on_page: invalid tool input",{issues:l.error.issues}),n(d.callId,"unsupported");continue}const{ref:p,action:m,value:f}=l.data;(async()=>{let h;try{const b=()=>i(d.key)&&e.features.pageContext&&e.features.clientTools&&e.features.pageActions;if(!b()){n(d.callId,"declined");return}const g=as(p);if(!g){n(d.callId,"gone",void 0,b()?jr():void 0);return}const C=At(g)||"this control",x=m==="select"?Tr(g,f):null;if(m==="select"&&!x){n(d.callId,"no_change","That option is unavailable or ambiguous.");return}const N=x==null?void 0:x.value,w=x==null?void 0:x.label.trim(),S=pi(g),j=()=>b()&&as(p)===g&&S()&&C===(At(g)||"this control")&&(!x||Tr(g,f)===x&&x.value===N&&x.label.trim()===w);if(!await o({callId:d.callId,action:m,controlName:C,...m==="fill"||m==="select"?{value:f}:{},...x?{valueLabel:w||"(empty option)"}:{}})){n(d.callId,"declined");return}if(!j()){n(d.callId,"declined");return}if(h=await Gi(g,{press:!0}),!j()){n(d.callId,"declined");return}const _=await Lf({ref:p,action:m,value:f,consentIsCurrent:j,observationIsCurrent:b}),R=b()&&_.outcome!=="declined"&&_.outcome!=="unsupported"?jr():null;n(d.callId,_.outcome,_.detail,R?{controls:R.controls,truncated:R.truncated}:void 0)}catch{n(d.callId,"unsupported","The page action could not be completed.")}finally{h==null||h.done()}})()}},[t,n,o,e,i]),null}const Qf=["circle","box","underline","bracket","arrow"],eg=y.z.object({ref:y.z.string().min(1),label:y.z.string().optional(),type:y.z.enum(Qf).optional().catch(void 0)}),tg=8e3;function ng(e,t,n){return t.display==="inline"&&e.height<=n*2.5?"underline":e.width<=220&&e.height<=80?"circle":"box"}let De=null;function rg(){De==null||De()}function og(e,t,{accentColor:n="hsl(0 0% 9%)",surfaceColor:o="hsl(0 0% 9%)",foregroundColor:s="hsl(0 0% 98%)",zIndex:a=10000002,durationMs:i=tg,seed:c}={}){if(!e.isConnected)return!1;De==null||De();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(),p=getComputedStyle(e),m=parseFloat(p.fontSize)||16,f=l.width<160&&l.height<56,h=Ws.annotate(e,{type:t.type??ng(l,p,m),color:n,strokeWidth:Math.min(3,Math.max(1.6,m*.11)),wobble:f?.6:.9,rtl:p.direction==="rtl",seed:c});let b=!1;const g=()=>{if(!b)try{h.show(),wr(e,a)}catch(M){Z.log.warn("highlight_element: mark could not be drawn",M)}},C=document.fonts;C!=null&&C.ready&&typeof C.ready.then=="function"?C.ready.then(g):g();const x=document.createElement("div");x.setAttribute("data-opencx-overlay",""),x.style.pointerEvents="none";let N=null,w=null;t.label&&(N=document.createElement("div"),N.setAttribute("data-cx-role","callout"),Object.assign(N.style,{position:"fixed",zIndex:String(a+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"}),N.textContent=t.label,w=document.createElement("div"),Object.assign(w.style,{position:"absolute",width:"10px",height:"10px",background:o,transform:"rotate(45deg)"}),N.appendChild(w),x.appendChild(N)),document.documentElement.appendChild(x);let S=0;if(N&&w){const M=N,D=w,O=()=>{const B=e.getBoundingClientRect(),E=window.innerWidth,z=B.top>90?"top":"bottom",H=Math.min(240,M.offsetWidth||240),L=Math.max(12,Math.min(B.left+B.width/2-H/2,E-H-12));M.style.left=`${L}px`,M.style.width=`${H}px`,M.style.top=z==="top"?`${B.top-M.offsetHeight-12}px`:`${B.bottom+12}px`,D.style.left=`${Math.max(10,Math.min(B.left+B.width/2-L-5,H-20))}px`,z==="top"?(D.style.bottom="-4px",D.style.top=""):(D.style.top="-4px",D.style.bottom=""),S=requestAnimationFrame(O)};O()}const j=N?window.setTimeout(()=>{N&&(N.style.opacity="1",N.style.transform="translateY(0)")},350):0,v=()=>{if(!b){b=!0,De===v&&(De=null),cancelAnimationFrame(S),window.clearTimeout(I),window.clearTimeout(j),document.removeEventListener("click",_,!0),document.removeEventListener("keydown",R,!0),N&&(N.style.opacity="0",N.style.transform=d?"none":"translateY(4px)");try{h.hide(),h.finished.then(()=>h.remove())}catch{h.remove()}window.setTimeout(()=>x.remove(),300)}},_=()=>v(),R=M=>{M.key==="Escape"&&v()},I=window.setTimeout(v,Math.max(0,i));return document.addEventListener("click",_,!0),document.addEventListener("keydown",R,!0),De=v,!0}const sg=200;function ag(){const{pageMarkHighlightDurationMs:e}=k.useConfig(),{pageEffects:t,replyToPageCall:n,isStreaming:o}=k.useAgentChatUi(),{widgetCtx:s}=k.useWidget(),a=Ki(t,o),{theme:i,cssVars:c}=de(),d=ro({cssVars:c,primaryColor:i.primaryColor,contentZIndex:i.widgetContentContainer.zIndex}),l=u.useRef(new Set);return u.useEffect(()=>()=>{rg(),Nn()},[]),u.useEffect(()=>{o||Nn()},[o]),u.useEffect(()=>{const p=l.current;for(const m of t){if(m.type!=="highlight-element"||p.has(m.key))continue;for(p.add(m.key);p.size>sg;){const N=p.values().next().value;if(N===void 0)break;p.delete(N)}const f=()=>a(m.key)&&s.features.pageContext&&s.features.clientTools;if(!f()){n(m.callId,"declined");continue}const h=eg.safeParse(m.input);if(!h.success){Z.log.warn("highlight_element: invalid tool input",{issues:h.error.issues}),n(m.callId,"unsupported");continue}const b=Er(h.data.ref);if(!b.ok){Z.log.warn("highlight_element: not drawn",{ref:h.data.ref,reason:b.reason}),b.reason==="off-limits"?n(m.callId,"unsupported",b.detail):n(m.callId,b.reason);continue}const g=b.element,C=m.callId,x=h.data;(async()=>{let N;try{if(N=await Gi(g),!f()){n(C,"declined");return}const w=Er(x.ref);if(!w.ok){n(C,w.reason==="off-limits"?"unsupported":w.reason);return}const S=og(g,x,{accentColor:d.accent,surfaceColor:d.surface,foregroundColor:d.foreground,zIndex:d.inkZIndex,durationMs:e});n(C,S?"done":"gone"),S||Z.log.warn("highlight_element: the mark could not be drawn",x)}catch{n(C,"unsupported","The page highlight could not be completed.")}finally{N==null||N.done()}})()}},[t,n,e,d.accent,d.surface,d.foreground,d.inkZIndex,a,s]),null}const ig=/(\*\*\*|\*\*|\*|~~|`+)(?=\S)([\s\S]*?\S)\1/g,cg=/(^|[^\w`])(___|__|_)(?=\S)([\s\S]*?\S)\2(?!\w)/g,lg=3;function Ir(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<lg;n++){const o=t.replace(ig,"$2").replace(cg,"$1$3");if(o===t)break;t=o}return t.trim()}function Zi({className:e}){const[t,n]=u.useState(()=>new Set);return u.useEffect(()=>{const o=Array.from({length:9},(a,i)=>i),s=setInterval(()=>{const a=2+Math.floor(Math.random()*3),i=[...o].sort(()=>Math.random()-.5).slice(0,a);n(new Set(i))},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 dg({labels:e,active:t}){const n=u.useRef(e);n.current=e;const[o,s]=u.useState(()=>e[e.length-1]??""),[a,i]=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]??"";i("out");const p=setTimeout(()=>{s(l),i("in")},180);return()=>clearTimeout(p)},[t,e.length]),r.jsx("span",{className:A("truncate text-[12px] text-muted-foreground/60",t&&(a==="in"?"opencx-placeholder-in":"opencx-placeholder-out")),children:o})}function go(e,t){if(e.kind==="tool")return xo(e.label);const n=e.label.split(`
388
+ `).find(s=>s.trim());if(!n)return t;const o=Ir(n);return o?o.length>40?`${o.slice(0,40)}...`:o:t}function ug(e,t,n=3){const o=e.filter(s=>s.kind==="tool").map(s=>xo(s.label));if(o.length===0){const s=e.find(a=>a.kind==="reasoning");return s?go(s,t):t}return o.length<=n?o.join(" → "):`${o.slice(0,n).join(" → ")} → ...`}const pg=["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 mg({step:e,isLive:t,thinkingLabel:n}){const[o,s]=u.useState(!1),a=go(e,n),i=a!==Ir(e.label),c=t?(()=>{const d=e.label.split(`
389
+ `).filter(p=>p.trim()),l=Ir(d[d.length-1]??"");return l?l.length>80?`${l.slice(0,80)}...`:l:n})():a;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(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(Kr,{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}),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.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]",pg),children:r.jsx(Fr,{children:e.label})})})]})}const Ts=4e3;function hg(e){const t=typeof e=="string"?e:fg(e)??String(e);return t.length>Ts?`${t.slice(0,Ts)}…`:t}function fg(e){try{return JSON.stringify(e,null,2)}catch{return null}}function As({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:hg(t)})]})}function gg({step:e,showIO:t}){const{t:n}=G(),[o,s]=u.useState(!1),a=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]",a&&"cursor-pointer"),onClick:()=>a&&s(i=>!i),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(Zi,{})}),r.jsx("span",{className:A("min-w-0 truncate text-[13px] text-muted-foreground/70",!e.done&&"opencx-text-shimmer"),children:xo(e.label)}),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.jsxs("div",{className:"opencx-fade-up ms-[30px] pb-1",children:[e.input!==void 0&&r.jsx(As,{label:n("step_arguments"),value:e.input}),e.output!==void 0&&r.jsx(As,{label:n("step_result"),value:e.output})]})]})}function xg({steps:e,active:t}){var b;const{t:n}=G(),{showStepToolIO:o,presentation:s}=k.useConfig(),{widgetCtx:a}=k.useWidget(),i=(b=Z.resolveClientPresentation(a.agent.presentation,s))==null?void 0:b.toolActivity,c=o!==!1&&(i==="details"||i===void 0&&o===!0),d=n("thinking"),l=t?e:e.map(g=>g.done?g:{...g,done:!0}),p=l.some(g=>!g.done),[m,f]=u.useState(t),h=u.useRef(t);return u.useEffect(()=>{h.current&&!t?f(!1):!h.current&&t&&f(!0),h.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:()=>f(g=>!g),children:m?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",p&&"opencx-text-shimmer"),children:n(p?"running":"steps")})]}):p?r.jsxs(r.Fragment,{children:[r.jsx(Zi,{className:"opacity-70"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:l.length}),r.jsx(dg,{labels:l.map(g=>go(g,d)),active:p})]}):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:ug(l,d)})]})}),m&&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,C)=>r.jsx("div",{className:"opencx-fade-up",style:{animationDelay:`${C*40}ms`},children:g.kind==="reasoning"?r.jsx(mg,{step:g,isLive:p&&C===l.length-1,thinkingLabel:d}):r.jsx(gg,{step:g,showIO:c})},C))]})]})}function xo(e){const n=e.replace(/^mcp_[a-f0-9]{16}__/,"").replaceAll(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}function zs(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(a=>a.id===o))==null?void 0:s.label}).filter(o=>typeof o=="string"&&o.length>0);return t.length>0?t.join(", "):void 0}function bg({request:e}){const{t}=G(),{sendMessage:n}=k.useMessages(),{widgetCtx:o}=k.useWidget(),s=e.questions,[a,i]=u.useState(0),[c,d]=u.useState(!1),[l,p]=u.useState({}),[m,f]=u.useState({}),[h,b]=u.useState({}),[g,C]=u.useState({}),x=s[a],N=s.length,w=u.useCallback(O=>zs({question:O,manual:!!l[O.id],manualText:m[O.id]??"",singleId:h[O.id],multiIds:g[O.id]??new Set})!==void 0,[l,m,g,h]),S=x?w(x):!1,j=u.useMemo(()=>s.every(O=>w(O)),[w,s]),v=u.useCallback((O,B)=>{b(E=>({...E,[O]:B})),p(E=>({...E,[O]:!1}))},[]),_=u.useCallback((O,B)=>{C(E=>{const z=new Set(E[O]??[]);return z.has(B)?z.delete(B):z.add(B),{...E,[O]:z}}),p(E=>({...E,[O]:!1}))},[]),R=u.useCallback(O=>{p(B=>({...B,[O]:!0})),b(B=>({...B,[O]:void 0})),C(B=>({...B,[O]:new Set}))},[]),I=u.useCallback(()=>{S&&i(O=>Math.min(N-1,O+1))},[S,N]),M=u.useCallback(()=>{if(c||!j)return;const O=new Map;for(const E of s){const z=zs({question:E,manual:!!l[E.id],manualText:m[E.id]??"",singleId:h[E.id],multiIds:g[E.id]??new Set});z&&O.set(E.id,z)}const B=k.formatAskQuestionsAnswers(e,O);B.trim().length!==0&&(d(!0),n({content:B,clientContext:gi({marks:[],readsPage:o.features.pageContext})}))},[j,c,l,m,g,s,e,n,h,o]);if(!x)return null;const D=!!l[x.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:x.prompt})]}),r.jsx("div",{className:"px-4 pb-3 pt-3",children:D?r.jsx("textarea",{...P("chat/clarification_questions/manual_input"),value:m[x.id]??"",onChange:O=>f(B=>({...B,[x.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(),a<N-1?I():M())}}):r.jsxs("div",{className:"flex flex-wrap gap-2",children:[x.options.map(O=>{var E;const B=x.selection==="single"?h[x.id]===O.id:((E=g[x.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":B,onClick:()=>x.selection==="single"?v(x.id,O.id):_(x.id,O.id),className:A("rounded-full border px-3 py-1.5 text-sm transition-colors",B?"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(x.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:()=>i(O=>Math.max(0,O-1)),disabled:a===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")]}),N>1?r.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[a+1," / ",N]}):null,a<N-1?r.jsxs("button",{...P("chat/clarification_questions/next"),type:"button",onClick:I,disabled:!S,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:M,disabled:!j,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:`${(a+1)/Math.max(1,N)*100}%`}})})]})}function wg({widgetRef:e}){const{contactState:t}=k.useContact(),{setIsOpen:n}=k.useWidgetTrigger(),{toChatScreen:o}=k.useWidgetRouter();return u.useImperativeHandle(e,()=>({newChat:async s=>{var i;if(!((i=t.contact)!=null&&i.token)){Z.log.warn("cannot start a new chat: contact not yet initialized");return}n(!0);const a=o();a&&(s!=null&&s.message)&&await a.messageCtx.sendMessage({content:s.message})}}),[t,n,o]),null}function vg(){const{isOpen:e,setIsOpen:t}=k.useWidgetTrigger();return r.jsxs(Xe.Root,{open:e,onOpenChange:t,children:[r.jsx(mo,{}),r.jsx(Ph,{}),r.jsx(Rh,{}),r.jsx(zh,{})]})}function yg(){return k.useDisplayMode()==="companion"?r.jsx(k.WidgetLayoutProvider,{children:r.jsx(Pf,{})}):r.jsx(vg,{})}const kg=[{key:"loading",component:au},{key:"fallback",component:su},{key:"bot_message",component:lr},{key:"agent_message",component:lr},{key:"agent_chat_steps",component:xg},{key:"agent_chat_spec",component:Iu},{key:"agent_chat_questions",component:bg}],jg={get:async e=>localStorage.getItem(e),set:async(e,t)=>{localStorage.setItem(e,t)},remove:async e=>{localStorage.removeItem(e)}},Ji=u.forwardRef(function({options:t,components:n=[],loadingComponent:o,errorComponent:s},a){var i,c,d,l;return r.jsx(W.MotionConfig,{reducedMotion:"user",children:r.jsx(k.WidgetProvider,{components:[...kg,...n],options:{...t,capabilities:{...t.capabilities,richReplies:((i=t.capabilities)==null?void 0:i.richReplies)??!n.some(({key:p})=>["AGENT_CHAT_SPEC","BOT_MESSAGE","AGENT_MESSAGE"].includes(p.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:p})=>p.toUpperCase()==="AGENT_CHAT_QUESTIONS")}},storage:jg,loadingComponent:o,errorComponent:s,children:r.jsx(k.WidgetTriggerProvider,{children:r.jsxs(Tm,{children:[r.jsx(ag,{}),r.jsx(Jf,{}),r.jsx(wg,{widgetRef:a}),t.inline?r.jsxs(r.Fragment,{children:[r.jsx(mo,{}),r.jsx(Di,{})]}):r.jsx(yg,{})]})})})})});Ji.displayName="Widget";exports.HostedSpecRenderer=hd;exports.Widget=Ji;exports.segmentContent=Ea;exports.useJsonRenderHost=Kt;
390
+ //# sourceMappingURL=index-Cbc5wgsq.cjs.map