@opencx/widget-react 5.0.0-beta.7 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Chart.impl--lw4WUeY.cjs +2 -0
- package/dist/Chart.impl--lw4WUeY.cjs.map +1 -0
- package/dist/Chart.impl-B5gmO6Us.js +207 -0
- package/dist/Chart.impl-B5gmO6Us.js.map +1 -0
- package/dist/{index-D_f1MZUH.js → index-BiL9m1to.js} +6452 -5051
- package/dist/index-BiL9m1to.js.map +1 -0
- package/dist/index-rkpSpEfw.cjs +375 -0
- package/dist/index-rkpSpEfw.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json.d.ts +1 -1
- package/dist/src/WidgetPopoverContent.d.ts.map +1 -1
- package/dist/src/companion/CompanionContent.d.ts.map +1 -1
- package/dist/src/companion/CompanionFrame.d.ts +2 -1
- package/dist/src/companion/CompanionFrame.d.ts.map +1 -1
- package/dist/src/companion/CompanionQuestions.d.ts +11 -0
- package/dist/src/companion/CompanionQuestions.d.ts.map +1 -0
- package/dist/src/companion/WidgetCompanion.d.ts.map +1 -1
- package/dist/src/companion/message-styles.d.ts +8 -1
- package/dist/src/companion/message-styles.d.ts.map +1 -1
- package/dist/src/components/ClarificationQuestions.d.ts.map +1 -1
- package/dist/src/components/ConnectionsSettings.d.ts.map +1 -1
- package/dist/src/components/Header.d.ts.map +1 -1
- package/dist/src/components/PageActionCard.d.ts +17 -0
- package/dist/src/components/PageActionCard.d.ts.map +1 -0
- package/dist/src/components/ReplyQuote.d.ts +7 -0
- package/dist/src/components/ReplyQuote.d.ts.map +1 -0
- package/dist/src/components/RichText.d.ts +6 -2
- package/dist/src/components/RichText.d.ts.map +1 -1
- package/dist/src/components/StreamingTurn.d.ts +7 -1
- package/dist/src/components/StreamingTurn.d.ts.map +1 -1
- package/dist/src/components/UserMessage.d.ts.map +1 -1
- package/dist/src/components/configured-text-styles.d.ts +11 -0
- package/dist/src/components/configured-text-styles.d.ts.map +1 -0
- package/dist/src/components/custom-components/AgentMessageDefaultComponent.d.ts.map +1 -1
- package/dist/src/hooks/useInitialQuestionRequired.d.ts +3 -0
- package/dist/src/hooks/useInitialQuestionRequired.d.ts.map +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/json-render/Chart.impl.d.ts.map +1 -1
- package/dist/src/json-render/SpecRenderer.d.ts +6 -1
- package/dist/src/json-render/SpecRenderer.d.ts.map +1 -1
- package/dist/src/json-render/StreamingShimmer.d.ts +12 -0
- package/dist/src/json-render/StreamingShimmer.d.ts.map +1 -0
- package/dist/src/json-render/chart-axis.d.ts +30 -0
- package/dist/src/json-render/chart-axis.d.ts.map +1 -0
- package/dist/src/json-render/registry.d.ts.map +1 -1
- package/dist/src/json-render/segment-content.d.ts +14 -6
- package/dist/src/json-render/segment-content.d.ts.map +1 -1
- package/dist/src/page-controls/accessible-name.d.ts +7 -0
- package/dist/src/page-controls/accessible-name.d.ts.map +1 -0
- package/dist/src/page-controls/act-input.d.ts +18 -0
- package/dist/src/page-controls/act-input.d.ts.map +1 -0
- package/dist/src/page-controls/act-types.d.ts +28 -0
- package/dist/src/page-controls/act-types.d.ts.map +1 -0
- package/dist/src/page-controls/act.d.ts +10 -0
- package/dist/src/page-controls/act.d.ts.map +1 -0
- package/dist/src/page-controls/action-meaning.d.ts +7 -0
- package/dist/src/page-controls/action-meaning.d.ts.map +1 -0
- package/dist/src/page-controls/control-ref.d.ts +18 -0
- package/dist/src/page-controls/control-ref.d.ts.map +1 -0
- package/dist/src/page-controls/cursor.d.ts +72 -0
- package/dist/src/page-controls/cursor.d.ts.map +1 -0
- package/dist/src/page-controls/guard.d.ts +47 -0
- package/dist/src/page-controls/guard.d.ts.map +1 -0
- package/dist/src/page-controls/native-setter.d.ts +16 -0
- package/dist/src/page-controls/native-setter.d.ts.map +1 -0
- package/dist/src/page-controls/off-limits.d.ts +16 -0
- package/dist/src/page-controls/off-limits.d.ts.map +1 -0
- package/dist/src/page-controls/pointer-sequence.d.ts +16 -0
- package/dist/src/page-controls/pointer-sequence.d.ts.map +1 -0
- package/dist/src/page-controls/read-controls.d.ts +4 -0
- package/dist/src/page-controls/read-controls.d.ts.map +1 -0
- package/dist/src/page-controls/select-option.d.ts +3 -0
- package/dist/src/page-controls/select-option.d.ts.map +1 -0
- package/dist/src/page-controls/send-context.d.ts +20 -0
- package/dist/src/page-controls/send-context.d.ts.map +1 -0
- package/dist/src/page-controls/types.d.ts +52 -0
- package/dist/src/page-controls/types.d.ts.map +1 -0
- package/dist/src/page-marks/agent-mark.d.ts +6 -5
- package/dist/src/page-marks/agent-mark.d.ts.map +1 -1
- package/dist/src/page-marks/mark-source.d.ts +6 -0
- package/dist/src/page-marks/mark-source.d.ts.map +1 -0
- package/dist/src/page-marks/mark-thumbnail.d.ts +2 -0
- package/dist/src/page-marks/mark-thumbnail.d.ts.map +1 -1
- package/dist/src/page-marks/page-element.d.ts +1 -7
- package/dist/src/page-marks/page-element.d.ts.map +1 -1
- package/dist/src/page-marks/usePageMarking.d.ts +1 -6
- package/dist/src/page-marks/usePageMarking.d.ts.map +1 -1
- package/dist/src/page-privacy.d.ts +11 -0
- package/dist/src/page-privacy.d.ts.map +1 -0
- package/dist/src/screens/chat/ChatFooter.d.ts.map +1 -1
- package/dist/src/screens/chat/ChatInput.d.ts +3 -1
- package/dist/src/screens/chat/ChatInput.d.ts.map +1 -1
- package/dist/src/screens/chat/agent/AgentChatPageActions.d.ts +13 -0
- package/dist/src/screens/chat/agent/AgentChatPageActions.d.ts.map +1 -0
- package/dist/src/screens/chat/agent/AgentChatPageEffects.d.ts.map +1 -1
- package/dist/src/screens/chat/agent/use-page-effect-is-current.d.ts +5 -0
- package/dist/src/screens/chat/agent/use-page-effect-is-current.d.ts.map +1 -0
- package/dist/src/screens/chat/agent/useStreamFollow.d.ts +4 -0
- package/dist/src/screens/chat/agent/useStreamFollow.d.ts.map +1 -1
- package/dist/src/screens/chat/usePageMarkComposer.d.ts +1 -0
- package/dist/src/screens/chat/usePageMarkComposer.d.ts.map +1 -1
- package/dist/src/screens/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/Chart.impl-C-1c9nkk.js +0 -153
- package/dist/Chart.impl-C-1c9nkk.js.map +0 -1
- package/dist/Chart.impl-Ck7Md2bC.cjs +0 -2
- package/dist/Chart.impl-Ck7Md2bC.cjs.map +0 -1
- package/dist/index-B3pRBUF2.cjs +0 -343
- package/dist/index-B3pRBUF2.cjs.map +0 -1
- package/dist/index-D_f1MZUH.js.map +0 -1
package/dist/index-B3pRBUF2.cjs
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
"use strict";var Qs=Object.defineProperty;var ea=(e,t,n)=>t in e?Qs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var lr=(e,t,n)=>ea(e,typeof t!="symbol"?t+"":t,n);const r=require("react/jsx-runtime"),ta=require("@radix-ui/react-popover"),H=require("framer-motion"),l=require("react"),C=require("@opencx/widget-react-headless"),x=require("zod"),ee=require("@opencx/widget-core"),T=require("lucide-react"),na=require("clsx"),ra=require("tailwind-merge"),oa=require("@radix-ui/react-slot"),oo=require("class-variance-authority"),so=require("remark-gfm"),sa=require("react-markdown"),ao=require("rehype-raw"),gt=require("rehype-sanitize"),aa=require("@radix-ui/react-avatar"),io=require("@uiw/react-iframe"),dr=require("tinycolor2"),ia=require("@radix-ui/react-tooltip"),kt=require("react-dom"),ca=require("@radix-ui/react-menu"),la=require("html-to-image"),da=require("react-dropzone"),co=require("@shardsui/notation"),ua=require("react-use/lib/useAsyncFn");function Ct(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 We=Ct(ta),qe=Ct(l),dt=Ct(aa),Se=Ct(ia),ke=Ct(ca);var lo=x.z.union([x.z.string(),x.z.number(),x.z.boolean(),x.z.null(),x.z.object({$state:x.z.string()})]);x.z.union([x.z.string(),x.z.object({$state:x.z.string()})]);x.z.union([x.z.number(),x.z.object({$state:x.z.string()})]);x.z.union([x.z.boolean(),x.z.object({$state:x.z.string()})]);function uo(e,t){if(e!=null)return typeof e=="object"&&"$state"in e?ae(t,e.$state):e}function pa(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function St(e){return(e.startsWith("/")?e.slice(1).split("/"):e.split("/")).map(pa)}function ae(e,t){if(!t||t==="/")return e;const n=St(t);let o=e;for(const s of n){if(o==null)return;if(Array.isArray(o)){const i=parseInt(s,10);o=o[i]}else if(typeof o=="object")o=o[s];else return}return o}function po(e){return/^\d+$/.test(e)}function ma(e,t,n){const o=St(t);if(o.length===0)return;let s=e;for(let a=0;a<o.length-1;a++){const c=o[a],d=o[a+1],u=d!==void 0&&(po(d)||d==="-");if(Array.isArray(s)){const p=parseInt(c,10);(s[p]===void 0||typeof s[p]!="object")&&(s[p]=u?[]:{}),s=s[p]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=u?[]:{}),s=s[c]}const i=o[o.length-1];if(Array.isArray(s))if(i==="-")s.push(n);else{const a=parseInt(i,10);s[a]=n}else s[i]=n}function nn(e,t,n){const o=St(t);if(o.length===0)return;let s=e;for(let a=0;a<o.length-1;a++){const c=o[a],d=o[a+1],u=d!==void 0&&(po(d)||d==="-");if(Array.isArray(s)){const p=parseInt(c,10);(s[p]===void 0||typeof s[p]!="object")&&(s[p]=u?[]:{}),s=s[p]}else(!(c in s)||typeof s[c]!="object")&&(s[c]=u?[]:{}),s=s[c]}const i=o[o.length-1];if(Array.isArray(s))if(i==="-")s.push(n);else{const a=parseInt(i,10);s.splice(a,0,n)}else s[i]=n}function ur(e,t){const n=St(t);if(n.length===0)return;let o=e;for(let i=0;i<n.length-1;i++){const a=n[i];if(Array.isArray(o)){const c=parseInt(a,10);if(o[c]===void 0||typeof o[c]!="object")return;o=o[c]}else{if(!(a in o)||typeof o[a]!="object")return;o=o[a]}}const s=n[n.length-1];if(Array.isArray(o)){const i=parseInt(s,10);i>=0&&i<o.length&&o.splice(i,1)}else delete o[s]}function pn(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!=typeof t||typeof e!="object")return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((a,c)=>pn(a,t[c]));const n=e,o=t,s=Object.keys(n),i=Object.keys(o);return s.length!==i.length?!1:s.every(a=>pn(n[a],o[a]))}function mo(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 ho(e,t){switch(t.op){case"add":nn(e,t.path,t.value);break;case"replace":ma(e,t.path,t.value);break;case"remove":ur(e,t.path);break;case"move":{if(!t.from)break;const n=ae(e,t.from);ur(e,t.from),nn(e,t.path,n);break}case"copy":{if(!t.from)break;const n=ae(e,t.from);nn(e,t.path,n);break}case"test":{const n=ae(e,t.path);if(!pn(n,t.value))throw new Error(`Test operation failed: value at "${t.path}" does not match`);break}}return e}function ha(e,t){return ho(e,t),e}function fa(e){const t={};let n=0;function o(a){const c=`el-${n++}`,{type:d,props:u,children:p,...h}=a,f=[];if(Array.isArray(p))for(const k of p)k&&typeof k=="object"&&"type"in k&&f.push(o(k));const m={type:d??"unknown",props:u??{},children:f};for(const[k,w]of Object.entries(h))k!=="state"&&w!==void 0&&(m[k]=w);return t[c]=m,c}const i={root:o(e),elements:t};return e.state&&typeof e.state=="object"&&!Array.isArray(e.state)&&(i.state=e.state),i}function ga(e,t={}){const n=e.split(`
|
|
2
|
-
`),o={...t};for(const s of n){const i=mo(s);i&&ho(o,i)}return o}var xa="spec",ba=`data-${xa}`;function pr(e,t,n){const o=St(t);if(o.length===0)return e;const s={...e};let i=s;for(let c=0;c<o.length-1;c++){const d=o[c],u=i[d];if(Array.isArray(u))i[d]=[...u];else if(u!==null&&typeof u=="object")i[d]={...u};else{const p=o[c+1];i[d]=p!==void 0&&/^\d+$/.test(p)?[]:{}}i=i[d]}const a=o[o.length-1];return Array.isArray(i)?a==="-"?i.push(n):i[parseInt(a,10)]=n:i[a]=n,s}function wa(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,i){ae(t,s)!==i&&(t=pr(t,s,i),o())},update(s){let i=!1,a=t;for(const[c,d]of Object.entries(s))ae(a,c)!==d&&(a=pr(a,c,d),i=!0);i&&(t=a,o())},getSnapshot(){return t},getServerSnapshot(){return t},subscribe(s){return n.add(s),()=>{n.delete(s)}}}}var rn=20;function zn(e,t="",n=0,o,s){const i=o??new Set,a=s??{current:!1},c={};for(const[d,u]of Object.entries(e)){const p=`${t}/${d}`;n<rn&&u!==null&&typeof u=="object"&&!Array.isArray(u)&&Object.getPrototypeOf(u)===Object.prototype&&!i.has(u)?(i.add(u),Object.assign(c,zn(u,p,n+1,i,a))):(process.env.NODE_ENV!=="production"&&!a.current&&n>=rn&&u!==null&&typeof u=="object"&&!Array.isArray(u)&&Object.getPrototypeOf(u)===Object.prototype&&!i.has(u)&&(a.current=!0,console.warn(`flattenToPointers: depth limit (${rn}) reached. Nested state beyond this depth will be treated as a leaf value.`)),c[p]=u)}return c}var Pt=x.z.union([x.z.number(),x.z.object({$state:x.z.string()})]),En={eq:x.z.unknown().optional(),neq:x.z.unknown().optional(),gt:Pt.optional(),gte:Pt.optional(),lt:Pt.optional(),lte:Pt.optional(),not:x.z.literal(!0).optional()},ya=x.z.object({$state:x.z.string(),...En}),va=x.z.object({$item:x.z.string(),...En}),ja=x.z.object({$index:x.z.literal(!0),...En}),mr=x.z.union([ya,va,ja]),mn=x.z.lazy(()=>x.z.union([x.z.boolean(),mr,x.z.array(mr),x.z.object({$and:x.z.array(mn)}),x.z.object({$or:x.z.array(mn)})]));function nt(e,t){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"?ae(t.stateModel,e.$state):e}function ka(e){return"$item"in e}function Ca(e){return"$index"in e}function Sa(e,t){return Ca(e)?t.repeatIndex:ka(e)?t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ae(t.repeatItem,e.$item):ae(t.stateModel,e.$state)}function hr(e,t){const n=Sa(e,t);let o;if(e.eq!==void 0){const s=nt(e.eq,t);o=n===s}else if(e.neq!==void 0){const s=nt(e.neq,t);o=n!==s}else if(e.gt!==void 0){const s=nt(e.gt,t);o=typeof n=="number"&&typeof s=="number"?n>s:!1}else if(e.gte!==void 0){const s=nt(e.gte,t);o=typeof n=="number"&&typeof s=="number"?n>=s:!1}else if(e.lt!==void 0){const s=nt(e.lt,t);o=typeof n=="number"&&typeof s=="number"?n<s:!1}else if(e.lte!==void 0){const s=nt(e.lte,t);o=typeof n=="number"&&typeof s=="number"?n<=s:!1}else o=!!n;return e.not===!0?!o:o}function Na(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$and"in e}function _a(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"$or"in e}function at(e,t){return e===void 0?!0:typeof e=="boolean"?e:Array.isArray(e)?e.every(n=>hr(n,t)):Na(e)?e.$and.every(n=>at(n,t)):_a(e)?e.$or.some(n=>at(n,t)):hr(e,t)}function za(e){const t=new Map;for(const n of e)t.set(n.name,n);return t}function Ea(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 Ia(e){return typeof e=="object"&&e!==null&&"$state"in e&&typeof e.$state=="string"}function fo(e){return typeof e=="object"&&e!==null&&"$item"in e&&typeof e.$item=="string"}function go(e){return typeof e=="object"&&e!==null&&"$index"in e&&e.$index===!0}function xo(e){return typeof e=="object"&&e!==null&&"$bindState"in e&&typeof e.$bindState=="string"}function bo(e){return typeof e=="object"&&e!==null&&"$bindItem"in e&&typeof e.$bindItem=="string"}function Aa(e){return typeof e=="object"&&e!==null&&"$cond"in e&&"$then"in e&&"$else"in e}function Ta(e){return typeof e=="object"&&e!==null&&"$computed"in e&&typeof e.$computed=="string"}function Pa(e){return typeof e=="object"&&e!==null&&"$template"in e&&typeof e.$template=="string"}var Ma=100,on=new Set;function In(e,t){if(t.repeatBasePath==null){console.warn(`$bindItem used outside repeat scope: "${e}"`);return}return e===""?t.repeatBasePath:t.repeatBasePath+"/"+e}function Ge(e,t){var n;if(e==null)return e;if(Ia(e))return ae(t.stateModel,e.$state);if(fo(e))return t.repeatItem===void 0?void 0:e.$item===""?t.repeatItem:ae(t.repeatItem,e.$item);if(go(e))return t.repeatIndex;if(xo(e))return ae(t.stateModel,e.$bindState);if(bo(e)){const o=In(e.$bindItem,t);return o===void 0?void 0:ae(t.stateModel,o)}if(Aa(e)){const o=at(e.$cond,t);return Ge(o?e.$then:e.$else,t)}if(Ta(e)){const o=(n=t.functions)==null?void 0:n[e.$computed];if(!o){on.has(e.$computed)||(on.size<Ma&&on.add(e.$computed),console.warn(`Unknown $computed function: "${e.$computed}"`));return}const s={};if(e.args)for(const[i,a]of Object.entries(e.args))s[i]=Ge(a,t);return o(s)}if(Pa(e))return e.$template.replace(/\$\{([^}]+)\}/g,(o,s)=>{if(s.startsWith("/")){const a=ae(t.stateModel,s);return a!=null?String(a):""}if(t.repeatItem!==void 0){const a=ae(t.repeatItem,s);if(a!=null)return String(a)}const i=ae(t.stateModel,"/"+s);return i!=null?String(i):""});if(Array.isArray(e))return e.map(o=>Ge(o,t));if(typeof e=="object"){const o=Ea(e,t.directives);if(o)return o.resolve(e,t);const s={};for(const[i,a]of Object.entries(e))s[i]=Ge(a,t);return s}return e}function Ra(e,t){const n={};for(const[o,s]of Object.entries(e))n[o]=Ge(s,t);return n}function $a(e,t){let n;for(const[o,s]of Object.entries(e))if(xo(s))n||(n={}),n[o]=s.$bindState;else if(bo(s)){const i=In(s.$bindItem,t);i!==void 0&&(n||(n={}),n[o]=i)}return n}function fr(e,t){return fo(e)?In(e.$item,t):go(e)?t.repeatIndex:Ge(e,t)}var wo=new Set;function Oa(e){for(const t of wo){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 Da(e){for(const t of wo){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 gr=0;function La(){return gr+=1,`${Date.now()}-${gr}`}var Fa=0,xr=new Set;function Wa(){return Fa>0}function Ha(e){return xr.add(e),()=>{xr.delete(e)}}var Ba=x.z.object({title:x.z.string(),message:x.z.string(),confirmLabel:x.z.string().optional(),cancelLabel:x.z.string().optional(),variant:x.z.enum(["default","danger"]).optional()}),qa=x.z.union([x.z.object({navigate:x.z.string()}),x.z.object({set:x.z.record(x.z.string(),x.z.unknown())}),x.z.object({action:x.z.string()})]),Ua=x.z.union([x.z.object({set:x.z.record(x.z.string(),x.z.unknown())}),x.z.object({action:x.z.string()})]);x.z.object({action:x.z.string(),params:x.z.record(x.z.string(),lo).optional(),confirm:Ba.optional(),onSuccess:qa.optional(),onError:Ua.optional(),preventDefault:x.z.boolean().optional()});function Va(e,t){const n={};if(e.params)for(const[s,i]of Object.entries(e.params))n[s]=uo(i,t);let o=e.confirm;return o&&(o={...o,message:br(o.message,t),title:br(o.title,t)}),{action:e.action,params:n,confirm:o,onSuccess:e.onSuccess,onError:e.onError}}function br(e,t){return e.replace(/\$\{([^}]+)\}/g,(n,o)=>{const s=uo({$state:o},t);return String(s??"")})}async function wr(e){const{action:t,handler:n,setState:o,navigate:s,executeAction:i}=e;try{if(await n(t.params),t.onSuccess)if("navigate"in t.onSuccess&&s)s(t.onSuccess.navigate);else if("set"in t.onSuccess)for(const[a,c]of Object.entries(t.onSuccess.set))o(a,c);else"action"in t.onSuccess&&i&&await i(t.onSuccess.action)}catch(a){if(t.onError)if("set"in t.onError)for(const[c,d]of Object.entries(t.onError.set)){const u=typeof d=="string"&&d==="$error.message"?a.message:d;o(c,u)}else"action"in t.onError&&i&&await i(t.onError.action);else throw a}}var Ya=x.z.object({type:x.z.string(),args:x.z.record(x.z.string(),lo).optional(),message:x.z.string()});x.z.object({checks:x.z.array(Ya).optional(),validateOn:x.z.enum(["change","blur","submit"]).optional(),enabled:mn.optional()});var yr=(e,t)=>{const n=t==null?void 0:t.other;return e===n},Xa={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:yr,equalTo:yr,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 Ga(e,t){const{value:n,stateModel:o,customFunctions:s}=t,i={};if(e.args)for(const[d,u]of Object.entries(e.args))i[d]=Ge(u,{stateModel:o});const a=Xa[e.type]??(s==null?void 0:s[e.type]);if(!a)return console.warn(`Unknown validation function: ${e.type}`),{type:e.type,valid:!0,message:e.message};const c=a(n,i);return{type:e.type,valid:c,message:e.message}}function Ka(e,t){const n=[],o=[];if(e.enabled&&!at(e.enabled,{stateModel:t.stateModel}))return{valid:!0,errors:[],checks:[]};if(e.checks)for(const s of e.checks){const i=Ga(s,t);n.push(i),i.valid||o.push(i.message)}return{valid:o.length===0,errors:o,checks:n}}var Za=["patch"];function Ja(e){var t;return(t=e==null?void 0:e.modes)!=null&&t.length?e.modes:Za}function Qa(){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 ei(){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 ti(){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 ni(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 ri(e,t){const n=Ja(e),o=[];o.push("EDITING EXISTING SPECS:"),o.push("");const s=ni(n);s&&(o.push(s),o.push(""));for(const i of n){switch(i){case"patch":o.push(Qa());break;case"merge":o.push(ei());break;case"diff":o.push(ti());break}o.push("")}return o.join(`
|
|
7
|
-
`)}function yo(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 oi(){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 si(e,t){const n=oi();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 ai(this,s)}}}function ai(e,t){const n=t.components,o=t.actions,s=n?Object.keys(n):[],i=o?Object.keys(o):[],a=ii(e.definition,t);return{schema:e,data:t,componentNames:s,actionNames:i,prompt(c={}){return di(this,c)},jsonSchema(c={}){return Le(a,c.strict??!1)},validate(c){const d=a.safeParse(c);return d.success?{success:!0,data:d.data}:{success:!1,error:d.error}},zodSchema(){return a},get _specType(){throw new Error("_specType is only for type inference")}}}function ii(e,t){return Dt(e.spec,t)}function Dt(e,t){switch(e.kind){case"string":return x.z.string();case"number":return x.z.number();case"boolean":return x.z.boolean();case"any":return x.z.any();case"array":{const n=Dt(e.inner,t);return x.z.array(n)}case"object":{const n=e.inner,o={};for(const[s,i]of Object.entries(n)){let a=Dt(i,t);i.optional&&(a=a.optional()),o[s]=a}return x.z.object(o)}case"record":{const n=Dt(e.inner,t);return x.z.record(x.z.string(),n)}case"ref":{const n=e.inner,o=ci(n,t);return o.length===0?x.z.string():o.length===1?x.z.literal(o[0]):x.z.enum(o)}case"propsOf":{const n=e.inner,o=li(n,t);return o.length===0?x.z.record(x.z.string(),x.z.unknown()):o.length===1?o[0]:x.z.record(x.z.string(),x.z.unknown())}default:return x.z.unknown()}}function ci(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 li(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 di(e,t){if(e.schema.promptTemplate){const I={catalog:e.data,componentNames:e.componentNames,actionNames:e.actionNames,options:t,formatZodType:Ce};return e.schema.promptTemplate(I)}const{system:n="You are a UI generator that outputs JSON.",customRules:o=[],mode:s="standalone"}=t,i=s==="chat"?(console.warn('[json-render] mode "chat" is deprecated, use "inline" instead'),"inline"):s==="generate"?(console.warn('[json-render] mode "generate" is deprecated, use "standalone" instead'),"standalone"):s,a=[];a.push(n),a.push(""),i==="inline"?(a.push("OUTPUT FORMAT (text + JSONL, RFC 6902 JSON Patch):"),a.push("You respond conversationally. When generating UI, first write a brief explanation (1-3 sentences), then output JSONL patch lines wrapped in a ```spec code fence."),a.push("The JSONL lines use RFC 6902 JSON Patch operations to build a UI tree. Always wrap them in a ```spec fence block:"),a.push(" ```spec"),a.push(' {"op":"add","path":"/root","value":"main"}'),a.push(' {"op":"add","path":"/elements/main","value":{"type":"Card","props":{"title":"Hello"},"children":[]}}'),a.push(" ```"),a.push("If the user's message does not require a UI (e.g. a greeting or clarifying question), respond with text only — no JSONL.")):(a.push("OUTPUT FORMAT (JSONL, RFC 6902 JSON Patch):"),a.push("Output JSONL (one JSON object per line) using RFC 6902 JSON Patch operations to build a UI tree.")),a.push("Each line is a JSON patch operation (add, remove, replace). Start with /root, then stream /elements and /state patches interleaved so the UI fills in progressively as it streams."),a.push(""),a.push("Example output (each line is a separate JSON object):"),a.push("");const c=e.data.components,d=e.componentNames,u=d[0]||"Component",p=d.length>1?d[1]:u,h=c==null?void 0:c[u],f=c==null?void 0:c[p],m=h?vr(h):{},k=f?vr(f):{},w=f!=null&&f.props?ui(f.props):null,y=w?{...k,[w]:{$item:"title"}}:k,v=[JSON.stringify({op:"add",path:"/root",value:"main"}),JSON.stringify({op:"add",path:"/elements/main",value:{type:u,props:m,children:["child-1","list"]}}),JSON.stringify({op:"add",path:"/elements/child-1",value:{type:p,props:k,children:[]}}),JSON.stringify({op:"add",path:"/elements/list",value:{type:u,props:m,repeat:{statePath:"/items",key:"id"},children:["item"]}}),JSON.stringify({op:"add",path:"/elements/item",value:{type:p,props:y,children:[]}}),JSON.stringify({op:"add",path:"/state/items",value:[]}),JSON.stringify({op:"add",path:"/state/items/0",value:{id:"1",title:"First Item"}}),JSON.stringify({op:"add",path:"/state/items/1",value:{id:"2",title:"Second Item"}})].join(`
|
|
8
|
-
`);a.push(`${v}
|
|
9
|
-
|
|
10
|
-
Note: state patches appear right after the elements that use them, so the UI fills in as it streams. ONLY use component types from the AVAILABLE COMPONENTS list below.`),a.push(""),a.push("INITIAL STATE:"),a.push("Specs include a /state field to seed the state model. Components with { $bindState } or { $bindItem } read from and write to this state, and $state expressions read from it."),a.push("CRITICAL: You MUST include state patches whenever your UI displays data via $state, $bindState, $bindItem, $item, or $index expressions, or uses repeat to iterate over arrays. Without state, these references resolve to nothing and repeat lists render zero items."),a.push("Output state patches right after the elements that reference them, so the UI fills in progressively as it streams."),a.push("Stream state progressively - output one patch per array item instead of one giant blob:"),a.push(' For arrays: {"op":"add","path":"/state/posts/0","value":{"id":"1","title":"First Post",...}} then /state/posts/1, /state/posts/2, etc.'),a.push(' For scalars: {"op":"add","path":"/state/newTodoText","value":""}'),a.push(' Initialize the array first if needed: {"op":"add","path":"/state/posts","value":[]}'),a.push('When content comes from the state model, use { "$state": "/some/path" } dynamic props to display it instead of hardcoding the same value in both state and props. The state model is the single source of truth.'),a.push("Include realistic sample data in state. For blogs: 3-4 posts with titles, excerpts, authors, dates. For product lists: 3-5 items with names, prices, descriptions. Never leave arrays empty."),a.push(""),a.push("DYNAMIC LISTS (repeat field):"),a.push('Any element can have a top-level "repeat" field to render its children once per item in a state array: { "repeat": { "statePath": "/arrayPath", "key": "id" } }.'),a.push('The element itself renders once (as the container), and its children are expanded once per array item. "statePath" is the state array path. "key" is an optional field name on each item for stable React keys.'),a.push(`Example: ${JSON.stringify({type:u,props:m,repeat:{statePath:"/todos",key:"id"},children:["todo-item"]})}`),a.push('Inside children of a repeated element, use { "$item": "field" } to read a field from the current item, and { "$index": true } to get the current array index. For two-way binding to an item field use { "$bindItem": "completed" } on the appropriate prop.'),a.push("ALWAYS use the repeat field for lists backed by state arrays. NEVER hardcode individual elements for each array item."),a.push('IMPORTANT: "repeat" is a top-level field on the element (sibling of type/props/children), NOT inside props.'),a.push(""),a.push("ARRAY STATE ACTIONS:"),a.push('Use action "pushState" to append items to arrays. Params: { statePath: "/arrayPath", value: { ...item }, clearStatePath: "/inputPath" }.'),a.push('Values inside pushState can contain { "$state": "/statePath" } references to read current state (e.g. the text from an input field).'),a.push('Use "$id" inside a pushState value to auto-generate a unique ID.'),a.push('Example: on: { "press": { "action": "pushState", "params": { "statePath": "/todos", "value": { "id": "$id", "title": { "$state": "/newTodoText" }, "completed": false }, "clearStatePath": "/newTodoText" } } }'),a.push(`Use action "removeState" to remove items from arrays by index. Params: { statePath: "/arrayPath", index: N }. Inside a repeated element's children, use { "$index": true } for the current item index. Action params support the same expressions as props: { "$item": "field" } resolves to the absolute state path, { "$index": true } resolves to the index number, and { "$state": "/path" } reads a value from state.`),a.push("For lists where users can add/remove items (todos, carts, etc.), use pushState and removeState instead of hardcoding with setState."),a.push(""),a.push('IMPORTANT: State paths use RFC 6901 JSON Pointer syntax (e.g. "/todos/0/title"). Do NOT use JavaScript-style dot notation (e.g. "/todos.length" is WRONG). To generate unique IDs for new items, use "$id" instead of trying to read array length.'),a.push("");const z=c;if(z){a.push(`AVAILABLE COMPONENTS (${e.componentNames.length}):`),a.push("");for(const[I,P]of Object.entries(z)){const L=P.props?Ce(P.props):"{}",V=P.slots&&P.slots.length>0?" [accepts children]":"",U=P.events&&P.events.length>0?` [events: ${P.events.join(", ")}]`:"",q=P.description?` - ${P.description}`:"";a.push(`- ${I}: ${L}${q}${V}${U}`)}a.push("")}const g=e.data.actions,S=e.schema.builtInActions??[],j=g&&e.actionNames.length>0,b=S.length>0;if(j||b){a.push("AVAILABLE ACTIONS:"),a.push("");for(const I of S)a.push(`- ${I.name}: ${I.description} [built-in]`);if(j)for(const[I,P]of Object.entries(g))a.push(`- ${I}${P.description?`: ${P.description}`:""}`);a.push("")}a.push("EVENTS (the `on` field):"),a.push("Elements can have an optional `on` field to bind events to actions. The `on` field is a top-level field on the element (sibling of type/props/children), NOT inside props."),a.push('Each key in `on` is an event name (from the component\'s supported events), and the value is an action binding: `{ "action": "<actionName>", "params": { ... } }`.'),a.push(""),a.push("Example:"),a.push(` ${JSON.stringify({type:u,props:m,on:{press:{action:"setState",params:{statePath:"/saved",value:!0}}},children:[]})}`),a.push(""),a.push('Action params can use dynamic references to read from state: { "$state": "/statePath" }.'),a.push("IMPORTANT: Do NOT put action/actionParams inside props. Always use the `on` field for event bindings."),a.push(""),a.push("VISIBILITY CONDITIONS:"),a.push("Elements can have an optional `visible` field to conditionally show/hide based on state. IMPORTANT: `visible` is a top-level field on the element object (sibling of type/props/children), NOT inside props."),a.push(`Correct: ${JSON.stringify({type:u,props:m,visible:{$state:"/activeTab",eq:"home"},children:["..."]})}`),a.push('- `{ "$state": "/path" }` - visible when state at path is truthy'),a.push('- `{ "$state": "/path", "not": true }` - visible when state at path is falsy'),a.push('- `{ "$state": "/path", "eq": "value" }` - visible when state equals value'),a.push('- `{ "$state": "/path", "neq": "value" }` - visible when state does not equal value'),a.push('- `{ "$state": "/path", "gt": N }` / `gte` / `lt` / `lte` - numeric comparisons'),a.push("- Use ONE operator per condition (eq, neq, gt, gte, lt, lte). Do not combine multiple operators."),a.push('- Any condition can add `"not": true` to invert its result'),a.push("- `[condition, condition]` - all conditions must be true (implicit AND)"),a.push('- `{ "$and": [condition, condition] }` - explicit AND (use when nesting inside $or)'),a.push('- `{ "$or": [condition, condition] }` - at least one must be true (OR)'),a.push("- `true` / `false` - always visible/hidden"),a.push(""),a.push("Use a component with on.press bound to setState to update state and drive visibility."),a.push(`Example: A ${u} with on: { "press": { "action": "setState", "params": { "statePath": "/activeTab", "value": "home" } } } sets state, then a container with visible: { "$state": "/activeTab", "eq": "home" } shows only when that tab is active.`),a.push(""),a.push('For tab patterns where the first/default tab should be visible when no tab is selected yet, use $or to handle both cases: visible: { "$or": [{ "$state": "/activeTab", "eq": "home" }, { "$state": "/activeTab", "not": true }] }. This ensures the first tab is visible both when explicitly selected AND when /activeTab is not yet set.'),a.push(""),a.push("DYNAMIC PROPS:"),a.push("Any prop value can be a dynamic expression that resolves based on state. Three forms are supported:"),a.push(""),a.push('1. Read-only state: `{ "$state": "/statePath" }` - resolves to the value at that state path (one-way read).'),a.push(' Example: `"color": { "$state": "/theme/primary" }` reads the color from state.'),a.push(""),a.push('2. Two-way binding: `{ "$bindState": "/statePath" }` - resolves to the value at the state path AND enables write-back. Use on form input props (value, checked, pressed, etc.).'),a.push(' Example: `"value": { "$bindState": "/form/email" }` binds the input value to /form/email.'),a.push(' Inside repeat scopes: `"checked": { "$bindItem": "completed" }` binds to the current item\'s completed field.'),a.push(""),a.push('3. Conditional: `{ "$cond": <condition>, "$then": <value>, "$else": <value> }` - evaluates the condition (same syntax as visibility conditions) and picks the matching value.'),a.push(' Example: `"color": { "$cond": { "$state": "/activeTab", "eq": "home" }, "$then": "#007AFF", "$else": "#8E8E93" }`'),a.push(""),a.push("Use $bindState for form inputs (text fields, checkboxes, selects, sliders, etc.) and $state for read-only data display. Inside repeat scopes, use $bindItem for form inputs bound to the current item. Use dynamic props instead of duplicating elements with opposing visible conditions when only prop values differ."),a.push(""),a.push('4. Template: `{ "$template": "Hello, ${/name}!" }` - interpolates references in the string. Absolute paths like `${/path}` resolve against the state model. Bare names like `${field}` resolve against the current repeat item first, then fall back to the state model at `/<field>`.'),a.push(' Example: `"label": { "$template": "Items: ${/cart/count} | Total: ${/cart/total}" }` renders "Items: 3 | Total: 42.00" when /cart/count is 3 and /cart/total is 42.00. Inside a repeat, `{ "$template": "${name} - ${email}" }` reads name and email from each item.'),a.push("");const E=e.data.functions;if(E&&Object.keys(E).length>0){a.push('5. Computed: `{ "$computed": "<functionName>", "args": { "key": <expression> } }` - calls a registered function with resolved args and returns the result.'),a.push(' Example: `"value": { "$computed": "fullName", "args": { "first": { "$state": "/form/firstName" }, "last": { "$state": "/form/lastName" } } }`'),a.push(" Available functions:");for(const I of Object.keys(E))a.push(` - ${I}`);a.push("")}const $=t.directives;if($&&$.length>0){a.push("CUSTOM DYNAMIC VALUES:"),a.push("");for(const I of $){const P=I.description?` (${I.description})`:"";a.push(`- ${I.name}${P}: ${Ce(I.schema)}`)}a.push(""),a.push("Directives compose: any value field can contain another directive or a $state expression, resolved inside-out."),a.push("")}(c?Object.entries(c).some(([,I])=>I.props?Ce(I.props).includes("checks"):!1):!1)&&(a.push("VALIDATION:"),a.push("Form components that accept a `checks` prop support client-side validation."),a.push('Each check is an object: { "type": "<name>", "message": "...", "args": { ... } }'),a.push(""),a.push("Built-in validation types:"),a.push(" - required — value must be non-empty"),a.push(" - email — valid email format"),a.push(' - minLength — minimum string length (args: { "min": N })'),a.push(' - maxLength — maximum string length (args: { "max": N })'),a.push(' - pattern — match a regex (args: { "pattern": "regex" })'),a.push(' - min — minimum numeric value (args: { "min": N })'),a.push(' - max — maximum numeric value (args: { "max": N })'),a.push(" - numeric — value must be a number"),a.push(" - url — valid URL format"),a.push(' - matches — must equal another field (args: { "other": { "$state": "/path" } })'),a.push(' - equalTo — alias for matches (args: { "other": { "$state": "/path" } })'),a.push(' - lessThan — value must be less than another field (args: { "other": { "$state": "/path" } })'),a.push(' - greaterThan — value must be greater than another field (args: { "other": { "$state": "/path" } })'),a.push(' - requiredIf — required only when another field is truthy (args: { "field": { "$state": "/path" } })'),a.push(""),a.push("Example:"),a.push(' "checks": [{ "type": "required", "message": "Email is required" }, { "type": "email", "message": "Invalid email" }]'),a.push(""),a.push("IMPORTANT: When using checks, the component must also have a { $bindState } or { $bindItem } on its value/checked prop for two-way binding."),a.push("Always include validation checks on form inputs for a good user experience (e.g. required, email, minLength)."),a.push("")),(j||b)&&(a.push("STATE WATCHERS:"),a.push("Elements can have an optional `watch` field to react to state changes and trigger actions. The `watch` field is a top-level field on the element (sibling of type/props/children), NOT inside props."),a.push("Maps state paths (JSON Pointers) to action bindings. When the value at a watched path changes, the bound actions fire automatically."),a.push(""),a.push("Example (cascading select — country changes trigger city loading):"),a.push(` ${JSON.stringify({type:"Select",props:{value:{$bindState:"/form/country"},options:["US","Canada","UK"]},watch:{"/form/country":{action:"loadCities",params:{country:{$state:"/form/country"}}}},children:[]})}`),a.push(""),a.push("Use `watch` for cascading dependencies where changing one field should trigger side effects (loading data, resetting dependent fields, computing derived values)."),a.push("IMPORTANT: `watch` is a top-level field on the element (sibling of type/props/children), NOT inside props. Watchers only fire when the value changes, not on initial render."),a.push(""));const N=t.editModes;N&&N.length>0&&a.push(ri({modes:N})),a.push("RULES:");const _=i==="inline"?["When generating UI, wrap all JSONL patches in a ```spec code fence - one JSON object per line inside the fence","Write a brief conversational response before any JSONL output",'First set root: {"op":"add","path":"/root","value":"<root-key>"}','Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.","ONLY use components listed above","Each element value needs: type, props, children (array of child keys)","Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"]:["Output ONLY JSONL patches - one JSON object per line, no markdown, no code fences",'First set root: {"op":"add","path":"/root","value":"<root-key>"}','Then add each element: {"op":"add","path":"/elements/<key>","value":{...}}',"Output /state patches right after the elements that use them, one per array item for progressive loading. REQUIRED whenever using $state, $bindState, $bindItem, $item, $index, or repeat.","ONLY use components listed above","Each element value needs: type, props, children (array of child keys)","Use unique keys for the element map entries (e.g., 'header', 'metric-1', 'chart-revenue')"],W=e.schema.defaultRules??[];return[..._,...W,...o].forEach((I,P)=>{a.push(`${P+1}. ${I}`)}),a.join(`
|
|
11
|
-
`)}function vr(e){return e.example&&Object.keys(e.example).length>0?e.example:e.props?vo(e.props):{}}function vo(e){if(!e||!e._def)return{};const t=e._def,n=Ze(e);if(n!=="ZodObject"&&n!=="object")return{};const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return{};const s={};for(const[i,a]of Object.entries(o)){const c=Ze(a);c==="ZodOptional"||c==="optional"||c==="ZodNullable"||c==="nullable"||(s[i]=hn(a))}return s}function hn(e){if(!e||!e._def)return"...";const t=e._def;switch(Ze(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?hn(o):null}case"ZodArray":case"array":return[];case"ZodObject":case"object":return vo(e);case"ZodUnion":case"union":{const o=t.options;return o&&o.length>0?hn(o[0]):"..."}default:return"..."}}function ui(e){if(!e||!e._def)return null;const t=e._def,n=Ze(e);if(n!=="ZodObject"&&n!=="object")return null;const o=typeof t.shape=="function"?t.shape():t.shape;if(!o)return null;for(const[s,i]of Object.entries(o)){const a=Ze(i);if(!(a==="ZodOptional"||a==="optional"||a==="ZodNullable"||a==="nullable")&&(a==="ZodString"||a==="string"))return s}return null}function Ze(e){if(!e||!e._def)return"";const t=e._def;return t.typeName??t.type??""}function Ce(e){if(!e||!e._def)return"unknown";const t=e._def;switch(Ze(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<${Ce(o)}>`:"Array<unknown>"}case"ZodObject":case"object":{const o=typeof t.shape=="function"?t.shape():t.shape;return o?`{ ${Object.entries(o).map(([i,a])=>{const c=Ze(a);return`${i}${c==="ZodOptional"||c==="ZodNullable"||c==="optional"||c==="nullable"?"?":""}: ${Ce(a)}`}).join(", ")} }`:"object"}case"ZodOptional":case"optional":case"ZodNullable":case"nullable":{const o=t.innerType??t.wrapped;return o?Ce(o):"unknown"}case"ZodUnion":case"union":{const o=t.options;return o?o.map(s=>Ce(s)).join(" | "):"unknown"}case"ZodRecord":case"record":{const o=t.keyType??void 0,s=t.valueType??t.element??void 0,i=o?Ce(o):"string",a=s?Ce(s):"unknown";return`Record<${i}, ${a}>`}case"ZodDefault":case"default":{const o=t.innerType??t.wrapped;return o?Ce(o):"unknown"}default:return"unknown"}}function jr(e){return typeof e.type=="string"?e.type:typeof e.typeName=="string"?e.typeName:""}function kr(e){return e.startsWith("Zod")?e.slice(3).toLowerCase():e.toLowerCase()}function Le(e,t=!1){const n=e._def;switch(kr(jr(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?Le(s,t):{}}}case"object":{const s=n.shape,i=typeof s=="function"?s():s;if(!i)return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object"};const a={},c=[];for(const[d,u]of Object.entries(i)){const p=u._def,h=kr(jr(p)),f=h==="optional"||h==="nullable";if(t)if(c.push(d),f){const m=Le(u,t);a[d]={anyOf:[m,{type:"null"}]}}else a[d]=Le(u,t);else a[d]=Le(u),f||c.push(d)}return{type:"object",properties:a,required:c.length>0?c:void 0,additionalProperties:!1}}case"record":{const s=n.valueType;return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{type:"object",additionalProperties:s?Le(s):!0}}case"optional":case"nullable":{const s=n.innerType;return s?Le(s,t):{}}case"union":{const s=n.options;return s?{anyOf:s.map(i=>Le(i,t))}:{}}case"any":case"unknown":return t?{type:"object",properties:{},required:[],additionalProperties:!1}:{};default:return{}}}function pi(e,t){return e.createCatalog(t)}var mi=si(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."]}),jo=l.createContext(null);function hi(e,t){return e?null:Object.keys(t).length===0?{}:zn(t)}function fi({store:e,initialState:t={},onStateChange:n,children:o}){const s=l.useRef(void 0);!e&&!s.current&&(s.current=wa(t));const i=e??s.current,a=l.useRef(i);a.current=i;const c=l.useRef(!!e);c.current=!!e;const d=l.useRef(e?"controlled":"uncontrolled"),u=l.useRef(!1);if(process.env.NODE_ENV!=="production"){const g=e?"controlled":"uncontrolled";g!==d.current&&!u.current&&(u.current=!0,console.warn(`StateProvider: switching from ${d.current} to ${g} mode is not supported.`))}const p=l.useRef(t),h=l.useRef(hi(!!e,t));l.useEffect(()=>{if(e||t===p.current)return;p.current=t;const g=t&&Object.keys(t).length>0?zn(t):{},S=h.current??{},j=new Set([...Object.keys(S),...Object.keys(g)]),b={};for(const E of j)S[E]!==g[E]&&(b[E]=E in g?g[E]:void 0);h.current=g,Object.keys(b).length>0&&i.update(b)},[e,t,i]);const f=l.useSyncExternalStore(i.subscribe,i.getSnapshot,i.getServerSnapshot??i.getSnapshot),m=l.useRef(n);m.current=n;const k=l.useCallback((g,S)=>{var E;const j=a.current,b=j.getSnapshot();j.set(g,S),!c.current&&j.getSnapshot()!==b&&((E=m.current)==null||E.call(m,[{path:g,value:S}]))},[]),w=l.useCallback(g=>{var b;const S=a.current,j=S.getSnapshot();if(S.update(g),!c.current&&S.getSnapshot()!==j){const E=[];for(const[$,M]of Object.entries(g))ae(j,$)!==M&&E.push({path:$,value:M});E.length>0&&((b=m.current)==null||b.call(m,E))}},[]),y=l.useCallback(g=>a.current.get(g),[]),v=l.useCallback(()=>a.current.getSnapshot(),[]),z=l.useMemo(()=>({state:f,get:y,set:k,update:w,getSnapshot:v}),[f,y,k,w,v]);return r.jsx(jo.Provider,{value:z,children:o})}function Nt(){const e=l.useContext(jo);if(!e)throw new Error("useStateStore must be used within a StateProvider");return e}var ko=l.createContext(null);function gi({children:e}){const{state:t}=Nt(),n=l.useMemo(()=>({stateModel:t}),[t]),o=l.useMemo(()=>i=>at(i,n),[n]),s=l.useMemo(()=>({isVisible:o,ctx:n}),[o,n]);return r.jsx(ko.Provider,{value:s,children:e})}function xi(){const e=l.useContext(ko);if(!e)throw new Error("useVisibility must be used within a VisibilityProvider");return e}var Co=l.createContext(null);function bi(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const s of n){const i=e[s],a=t[s];if(i!==a){if(typeof i=="object"&&i!==null&&typeof a=="object"&&a!==null){const c=i.$state,d=a.$state;if(typeof c=="string"&&c===d)continue}return!1}}return!0}function wi(e,t){if(e===t)return!0;if(e.validateOn!==t.validateOn)return!1;const n=e.checks??[],o=t.checks??[];if(n.length!==o.length)return!1;for(let s=0;s<n.length;s++){const i=n[s],a=o[s];if(i.type!==a.type||i.message!==a.message||!bi(i.args,a.args))return!1}return!0}function yi({customFunctions:e={},children:t}){const{state:n,getSnapshot:o}=Nt(),[s,i]=l.useState({}),a=l.useRef({}),[c,d]=l.useState({}),u=l.useCallback((w,y)=>{d(v=>{const z=v[w];return z&&wi(z,y)?v:{...v,[w]:y}})},[]),p=l.useCallback((w,y)=>{var b;const v=o(),z=w.split("/").filter(Boolean);let g=v;for(const E of z)if(g!=null&&typeof g=="object")g=g[E];else{g=void 0;break}const S=Ka(y,{value:g,stateModel:v,customFunctions:e}),j={touched:((b=a.current[w])==null?void 0:b.touched)??!0,validated:!0,result:S};return a.current={...a.current,[w]:j},i(a.current),S},[e,o]),h=l.useCallback(w=>{var y,v;a.current={...a.current,[w]:{...a.current[w],touched:!0,validated:((y=a.current[w])==null?void 0:y.validated)??!1,result:((v=a.current[w])==null?void 0:v.result)??null}},i(a.current)},[]),f=l.useCallback(w=>{const{[w]:y,...v}=a.current;a.current=v,i(v)},[]),m=l.useCallback(()=>{let w=!0;for(const[y,v]of Object.entries(c))p(y,v).valid||(w=!1);return w},[c,p]),k=l.useMemo(()=>({customFunctions:e,get fieldStates(){return a.current},validate:p,touch:h,clear:f,validateAll:m,registerField:u}),[e,s,p,h,f,m,u]);return r.jsx(Co.Provider,{value:k,children:t})}function vi(){return l.useContext(Co)}var Cr=0;function Sr(){return Cr+=1,`${Date.now()}-${Cr}`}function fn(e,t){if(e==null)return e;if(e==="$id")return Sr();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 Sr()}if(Array.isArray(e))return e.map(n=>fn(n,t));if(typeof e=="object"){const n={};for(const[o,s]of Object.entries(e))n[o]=fn(s,t);return n}return e}var So=l.createContext(null);function ji({handlers:e={},navigate:t,children:n}){const{get:o,set:s,getSnapshot:i}=Nt(),a=vi(),[c,d]=l.useState(e),[u,p]=l.useState(new Set),[h,f]=l.useState(null),m=l.useCallback((z,g)=>{d(S=>({...S,[z]:g}))},[]),k=l.useCallback(async z=>{var $;const g=Va(z,i()),S=La(),j=Date.now();Oa({id:S,name:g.action,params:g.params,at:j});let b=!0,E;try{if(g.action==="setState"&&g.params){const N=g.params.statePath,_=g.params.value;N&&s(N,_);return}if(g.action==="pushState"&&g.params){const N=g.params.statePath,_=g.params.value;if(N){const W=fn(_,o),B=o(N)??[];s(N,[...B,W]);const I=g.params.clearStatePath;I&&s(I,"")}return}if(g.action==="removeState"&&g.params){const N=g.params.statePath,_=g.params.index;if(N!==void 0&&_!==void 0){const W=o(N)??[];s(N,W.filter((B,I)=>I!==_))}return}if(g.action==="push"&&g.params){const N=g.params.screen;if(N){const _=o("/currentScreen"),W=o("/navStack")??[];_?s("/navStack",[...W,_]):s("/navStack",[...W,""]),s("/currentScreen",N)}return}if(g.action==="pop"){const N=o("/navStack")??[];if(N.length>0){const _=N[N.length-1];s("/navStack",N.slice(0,-1)),_?s("/currentScreen",_):s("/currentScreen",void 0)}return}if(g.action==="validateForm"){const N=a==null?void 0:a.validateAll;if(!N){console.warn("validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.");return}const _=N(),W={};for(const[I,P]of Object.entries(a.fieldStates))P.result&&!P.result.valid&&(W[I]=P.result.errors);const B=(($=g.params)==null?void 0:$.statePath)||"/formValidation";s(B,{valid:_,errors:W});return}const M=c[g.action];if(!M){console.warn(`No handler registered for action: ${g.action}`);return}if(g.confirm)return new Promise((N,_)=>{f({action:g,handler:M,resolve:()=>{f(null),N()},reject:()=>{f(null),_(new Error("Action cancelled"))}})}).then(async()=>{p(N=>new Set(N).add(g.action));try{await wr({action:g,handler:M,setState:s,navigate:t,executeAction:async N=>{await k({action:N})}})}finally{p(N=>{const _=new Set(N);return _.delete(g.action),_})}});p(N=>new Set(N).add(g.action));try{await wr({action:g,handler:M,setState:s,navigate:t,executeAction:async N=>{await k({action:N})}})}finally{p(N=>{const _=new Set(N);return _.delete(g.action),_})}}catch(M){throw b=!1,E=M,M}finally{const M=Date.now();Da({id:S,name:g.action,ok:b,at:M,durationMs:M-j,error:E})}},[c,o,s,i,t,a]),w=l.useCallback(()=>{h==null||h.resolve()},[h]),y=l.useCallback(()=>{h==null||h.reject()},[h]),v=l.useMemo(()=>({handlers:c,loadingActions:u,pendingConfirmation:h,execute:k,confirm:w,cancel:y,registerHandler:m}),[c,u,h,k,w,y,m]);return r.jsx(So.Provider,{value:v,children:n})}function No(){const e=l.useContext(So);if(!e)throw new Error("useActions must be used within an ActionProvider");return e}function ki({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 _o=l.createContext(null);function Ci({item:e,index:t,basePath:n,children:o}){return r.jsx(_o.Provider,{value:{item:e,index:t,basePath:n},children:o})}function Si(){return l.useContext(_o)}var Ni=class extends l.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}},zo={},Eo=l.createContext(zo);function _i(){return l.useContext(Eo)}var Io=l.createContext(void 0);function zi(){return l.useContext(Io)}function Ei(){return l.useSyncExternalStore(Ha,Wa,()=>!1)}var Ao=l.memo(function e({element:t,elementKey:n,spec:o,registry:s,loading:i,fallback:a}){var L;const c=Ei(),d=Si(),{ctx:u}=xi(),{execute:p}=No(),{getSnapshot:h,state:f}=Nt(),m=_i(),k=zi(),w=l.useMemo(()=>{const O=d?{...u,repeatItem:d.item,repeatIndex:d.index,repeatBasePath:d.basePath}:{...u};return O.functions=m,O.directives=k,O},[u,d,m,k]),y=t.visible===void 0?!0:at(t.visible,w),v=t.on,z=l.useCallback(async O=>{const V=v==null?void 0:v[O];if(!V)return;const U=Array.isArray(V)?V:[V];for(const q of U){if(!q.params){await p(q);continue}const F={...w,stateModel:h()},K={};for(const[ne,re]of Object.entries(q.params))K[ne]=fr(re,F);await p({...q,params:K})}},[v,p,w,h]),g=l.useCallback(O=>{const V=v==null?void 0:v[O];if(!V)return{emit:()=>{},shouldPreventDefault:!1,bound:!1};const q=(Array.isArray(V)?V:[V]).some(F=>F.preventDefault);return{emit:()=>z(O),shouldPreventDefault:q,bound:!0}},[v,z]),S=t.watch,j=l.useRef(null),b=l.useRef(void 0),E=l.useMemo(()=>{if(!S)return;const O={};for(const U of Object.keys(S))O[U]=ae(f,U);const V=b.current;if(V){const U=Object.keys(O);if(U.length===Object.keys(V).length&&U.every(q=>O[q]===V[q]))return V}return b.current=O,O},[S,f]);if(l.useEffect(()=>{if(!S||!E)return;const O=Object.keys(S);if(O.length===0)return;const V=j.current;if(j.current=E,V===null)return;let U=!1;return(async()=>{for(const q of O){if(U)break;if(E[q]!==V[q]){const F=S[q];if(!F)continue;const K=Array.isArray(F)?F:[F];for(const ne of K){if(U)break;if(!ne.params){if(await p(ne),U)break;continue}const re={...w,stateModel:h()},R={};for(const[X,J]of Object.entries(ne.params))R[X]=fr(J,re);if(await p({...ne,params:R}),U)break}}}})().catch(console.error),()=>{U=!0}},[S,E,p,w,h]),!y)return null;const $=t.props,M=$a($,w),N=Ra($,w),_=N!==t.props?{...t,props:N}:t,W=s[_.type]??a;if(!W)return console.warn(`No renderer for component type: ${_.type}`),null;const B=_.repeat?r.jsx(Ii,{element:_,spec:o,registry:s,loading:i,fallback:a}):(L=_.children)==null?void 0:L.map(O=>{const V=o.elements[O];return V?r.jsx(e,{element:V,elementKey:O,spec:o,registry:s,loading:i,fallback:a},O):(i||console.warn(`[json-render] Missing element "${O}" referenced as child of "${_.type}". This element will not render.`),null)}),I=r.jsx(W,{element:_,emit:z,on:g,bindings:M,loading:i,children:B}),P=c&&n?r.jsx("span",{"data-jr-key":n,style:{display:"contents"},children:I}):I;return r.jsx(Ni,{elementType:_.type,children:P})});function Ii({element:e,spec:t,registry:n,loading:o,fallback:s}){const{state:i}=Nt(),a=e.repeat,c=a.statePath,d=ae(i,c)??[];return r.jsx(r.Fragment,{children:d.map((u,p)=>{var f;const h=a.key&&typeof u=="object"&&u!==null?String(u[a.key]??p):String(p);return r.jsx(Ci,{item:u,index:p,basePath:`${c}/${p}`,children:(f=e.children)==null?void 0:f.map(m=>{const k=t.elements[m];return k?r.jsx(Ao,{element:k,elementKey:m,spec:t,registry:n,loading:o,fallback:s},m):(o||console.warn(`[json-render] Missing element "${m}" referenced as child of "${e.type}" (repeat). This element will not render.`),null)})},h)})})}function Ai({spec:e,registry:t,loading:n,fallback:o}){if(!e||!e.root)return null;const s=e.elements[e.root];return s?r.jsx(Ao,{element:s,elementKey:e.root,spec:e,registry:t,loading:n,fallback:o}):null}function Ti({registry:e,store:t,initialState:n,handlers:o,navigate:s,validationFunctions:i,functions:a,directives:c,onStateChange:d,children:u}){const p=l.useMemo(()=>c?za(c):void 0,[c]);return r.jsx(fi,{store:t,initialState:n,onStateChange:d,children:r.jsx(gi,{children:r.jsx(yi,{customFunctions:i,children:r.jsx(ji,{handlers:o,navigate:s,children:r.jsx(Eo.Provider,{value:a??zo,children:r.jsxs(Io.Provider,{value:p,children:[u,r.jsx(Pi,{})]})})})})})})}function Pi(){const{pendingConfirmation:e,confirm:t,cancel:n}=No();return e!=null&&e.action.confirm?r.jsx(ki,{confirm:e.action.confirm,onConfirm:t,onCancel:n}):null}function Mi(e,t){const n={};if(t.components)for(const[a,c]of Object.entries(t.components))n[a]=({element:d,children:u,emit:p,on:h,bindings:f,loading:m})=>c({props:d.props,children:u,emit:p,on:h,bindings:f,loading:m});const o=t.actions?Object.entries(t.actions):[];return{registry:n,handlers:(a,c)=>{const d={};for(const[u,p]of o)d[u]=async h=>{const f=a(),m=c();f&&await p(h,f,m)};return d},executeAction:async(a,c,d,u={})=>{const p=o.find(([h])=>h===a);p?await p[1](c,d,u):console.warn(`Unknown action: ${a}`)}}}function Ri(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 $i(e){const t={root:"",elements:{}};let n=!1;for(const o of e)if(o.type===ba){if(!Ri(o.data))continue;const s=o.data;if(s.type==="patch")n=!0,ha(t,s.patch);else if(s.type==="flat")n=!0,Object.assign(t,s.spec);else if(s.type==="nested"){n=!0;const i=fa(s.spec);Object.assign(t,i)}}return n?t:null}function Z(){const{dir:e}=C.useDocumentDir(),t=C.useConfig();return l.useMemo(()=>{const n=ee.resolveLanguage(t.language);return{t:(s,i)=>ee.getTranslation(s,n,t.translationOverrides,i),language:n,dir:ee.isRtlLanguage(n)?"rtl":"ltr",hostDocumentDir:e}},[t.language,t.translationOverrides,e])}function To(e){const t=ee.resolveLanguage(e);return(n,o)=>ee.getTranslation(n,t,void 0,o)}const Oi={t:To("en"),anchorTarget:"_blank"},Po=l.createContext(Oi);function Di({host:e,children:t}){return r.jsx(Po.Provider,{value:e,children:t})}function _t(){return l.useContext(Po)}function Li({language:e,onUiAction:t,anchorTarget:n="_blank"}){return l.useMemo(()=>({t:To(e),anchorTarget:n,onUiAction:t}),[e,n,t])}class Fi extends l.Component{constructor(){super(...arguments);lr(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n){ee.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 Wi(e){if(!e.elements)return e;let t=!1;const n={};for(const[o,s]of Object.entries(e.elements)){const i=Hi(s,e);i!==s&&(t=!0),n[o]=i}return t?{...e,elements:n}:e}function Hi(e,t){if(e.type!=="List")return e;const n=e.repeat;if(!n||typeof n.statePath!="string")return e;const o=ee.isRecord(e.props)?e.props:{},s=o.items;if(Array.isArray(s)&&s.length>0)return e;const a=ae(t.state??{},n.statePath);if(!Array.isArray(a)||a.length===0)return e;const{repeat:c,...d}=e;return{...d,props:{...o,items:a}}}function A(...e){return ra.twMerge(na.clsx(e))}const Bi=l.lazy(()=>Promise.resolve().then(()=>require("./Chart.impl-Ck7Md2bC.cjs")));function qi(e){const t=e.height??220;return r.jsx(l.Suspense,{fallback:r.jsx(Ui,{height:t}),children:r.jsx(Bi,{...e})})}function Ui({height:e}){return r.jsx("div",{className:"w-full animate-pulse rounded-lg bg-muted-foreground/10",style:{height:e},"aria-hidden":!0})}const Mo=x.z.object({title:x.z.string().nullish(),description:x.z.string().nullish()}),Ro=x.z.object({direction:x.z.enum(["row","column"]).nullish(),gap:x.z.enum(["sm","md","lg"]).nullish(),align:x.z.enum(["start","center","end","stretch"]).nullish(),justify:x.z.enum(["start","center","end","between"]).nullish()}),$o=x.z.object({columns:x.z.union([x.z.literal(1),x.z.literal(2),x.z.literal(3)]).nullish(),gap:x.z.enum(["sm","md","lg"]).nullish()}),Oo=x.z.object({text:x.z.string(),level:x.z.union([x.z.literal(1),x.z.literal(2),x.z.literal(3),x.z.literal(4)]).nullish()}),Do=x.z.object({text:x.z.string(),variant:x.z.enum(["body","caption","muted","code"]).nullish()}),Lo=x.z.object({text:x.z.string(),variant:x.z.enum(["default","secondary","success","warning","destructive"]).nullish()}),Vi=new Set(["http:","https:","mailto:"]),Yi=x.z.string().nullish().transform(e=>{if(!e)return null;try{return Vi.has(new URL(e).protocol)?e:null}catch{return null}}),Fo=x.z.object({id:x.z.string().nullish(),label:x.z.string(),secondary:x.z.string().nullish(),badge:x.z.string().nullish(),status:x.z.enum(["success","warning","error","info","neutral"]).nullish(),href:Yi}),Wo=x.z.object({items:x.z.array(Fo),maxVisible:x.z.number().int().positive().nullish()}),Xi=x.z.object({items:x.z.array(Fo.extend({href:x.z.string().nullish()})),maxVisible:Wo.shape.maxVisible}),Ho=x.z.object({columns:x.z.array(x.z.string()),rows:x.z.array(x.z.array(x.z.string())),caption:x.z.string().nullish()}),Gi=x.z.object({value:x.z.string(),direction:x.z.enum(["up","down","flat"]),label:x.z.string().nullish()}),Bo=x.z.object({label:x.z.string(),value:x.z.string(),description:x.z.string().nullish(),trend:x.z.enum(["up","down","neutral"]).nullish(),delta:Gi.nullish()}),qo=x.z.object({type:x.z.enum(["info","tip","warning","important"]).nullish(),title:x.z.string().nullish(),content:x.z.string()}),Ki=x.z.object({label:x.z.string(),value:x.z.number()}),Uo=x.z.object({type:x.z.enum(["bar","line","pie"]),data:x.z.array(Ki),title:x.z.string().nullish(),height:x.z.number().int().positive().nullish(),centerLabel:x.z.string().nullish()}),Vo=x.z.object({agentId:x.z.string(),agentName:x.z.string(),model:x.z.string().nullish()});function be(e,t,n){const o=e.safeParse(t);return o.success?o.data:n}const Zi=pi(mi,{components:{Card:{props:Mo,slots:["default"],description:"Container card with an optional title/description. Group related content.",example:{title:"Order summary",description:"Placed 2 days ago"}},Stack:{props:Ro,slots:["default"],description:'Flex layout. Use direction="row" for side-by-side, "column" (default) to stack.'},Grid:{props:$o,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:Oo,description:"Section heading. level 1 (largest) to 4.",example:{text:"Your orders",level:3}},Text:{props:Do,description:'A paragraph of text. variant "muted"/"caption" for secondary text, "code" for monospace.'},Badge:{props:Lo,description:"Small status pill. Use variant to convey state (success/warning/destructive).",example:{text:"Delivered",variant:"success"}},List:{props:Xi,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:Ho,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:Bo,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:qo,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:Vo,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:Uo,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:{}}),Nr={sm:"gap-1.5",md:"gap-3",lg:"gap-4"},Ji="10rem";function Qi(e){return e===1?"minmax(0, 1fr)":`repeat(auto-fit, minmax(max(${Ji}, calc(100% / ${e} - 1rem)), 1fr))`}const{registry:_r}=Mi(Zi,{components:{Card:({props:e,children:t})=>{const n=be(Mo,e,{});return r.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border border-muted-foreground/15 p-3",children:[(n.title||n.description)&&r.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.title&&r.jsx("div",{className:"text-sm font-semibold text-foreground",children:n.title}),n.description&&r.jsx("div",{className:"text-xs text-muted-foreground",children:n.description})]}),t]})},Stack:({props:e,children:t})=>{const n=be(Ro,e,{}),o={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch"}[n.align??"stretch"],s={start:"justify-start",center:"justify-center",end:"justify-end",between:"justify-between"}[n.justify??"start"];return r.jsx("div",{className:A("flex",n.direction==="row"?"flex-row":"flex-col",Nr[n.gap??"md"],o,s),children:t})},Grid:({props:e,children:t})=>{const n=be($o,e,{});return r.jsx("div",{className:A("grid",Nr[n.gap??"md"]),style:{gridTemplateColumns:Qi(n.columns??1)},children:t})},Heading:({props:e})=>{const t=be(Oo,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 l.createElement(`h${n}`,{className:A("text-foreground",o)},t.text)},Text:({props:e})=>{const t=be(Do,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=be(Lo,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})=>{const t=be(Wo,e,{items:[]});return t.items.length===0?r.jsx(zr,{translationKey:"json_no_items"}):r.jsx(uc,{items:t.items,maxVisible:t.maxVisible})},Table:({props:e})=>{const t=be(Ho,e,{columns:[],rows:[]});return t.columns.length===0?r.jsx(zr,{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:[t.caption&&r.jsx("caption",{className:"px-3 py-2 text-start text-xs text-muted-foreground",children:t.caption}),r.jsx("thead",{children:r.jsx("tr",{className:"border-b border-muted-foreground/15 bg-muted/40",children:t.columns.map((n,o)=>r.jsx("th",{className:"px-3 py-2 text-start font-medium text-foreground",children:n},o))})}),r.jsx("tbody",{children:t.rows.map((n,o)=>r.jsx("tr",{className:"border-b border-muted-foreground/10 last:border-0",children:n.map((s,i)=>r.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:s},i))},o))})]})})},Metric:({props:e})=>{const t=be(Bo,e,{label:"",value:""});return r.jsx(cc,{label:t.label,value:t.value,description:t.description,trend:t.trend,delta:t.delta})},Callout:({props:e})=>{const t=be(qo,e,{content:""}),n=tc[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=be(Vo,e,{agentId:"",agentName:""});return r.jsx(rc,{...t})},Chart:({props:e})=>{const t=be(Uo,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(qi,{...t})]})}}}),ec=({element:e})=>{const{t}=_t();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})})},tc={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 zr({translationKey:e}){const{t}=_t();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 nc="oppie-vox-livekit";function rc({agentId:e,agentName:t,model:n}){const{t:o,onUiAction:s}=_t(),i=!!s&&!!e&&n===nc;return r.jsxs("div",{className:"flex w-full flex-col gap-3 rounded-xl border border-muted-foreground/15 p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:r.jsx(T.Phone,{className:"size-4","aria-hidden":!0})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:t}),r.jsx("div",{className:"text-xs text-muted-foreground",children:o("json_phone_agent")})]})]}),i&&r.jsxs("button",{type:"button",className:"flex w-full items-center justify-center gap-2 rounded-lg bg-secondary px-3 py-2 text-sm font-medium text-secondary-foreground hover:bg-secondary/80",onClick:()=>s==null?void 0:s({type:"test-phone-agent",payload:{agentId:e,model:n??null}}),children:[r.jsx(T.Play,{className:"size-4","aria-hidden":!0}),o("json_phone_agent_test")]})]})}const oc={up:"↑",down:"↓",neutral:"→"},sc={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",neutral:"text-muted-foreground"},ac={up:"↑",down:"↓",flat:"→"},ic={up:"text-emerald-600 dark:text-emerald-400",down:"text-red-600 dark:text-red-400",flat:"text-muted-foreground"};function cc({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",sc[o]),children:oc[o]}):null]}),s?r.jsxs("div",{className:"flex items-baseline gap-1 text-xs",children:[r.jsxs("span",{className:A("font-medium",ic[s.direction]),children:[ac[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 lc={success:"bg-emerald-500",warning:"bg-amber-500",error:"bg-red-500",info:"bg-blue-500",neutral:"bg-muted-foreground/40"};function dc({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",lc[e.status]),"aria-hidden":!0}):r.jsx("span",{}))]})}function uc({items:e,maxVisible:t}){const n=t??10,{anchorTarget:o,t:s}=_t(),[i,a]=l.useState(!1),c=e.length>n,d=i?e:e.slice(0,n),u=d.some(k=>!!k.badge),p=d.some(k=>!!k.secondary),h=d.some(k=>!!k.status),f=[u&&"auto","minmax(0,1fr)",p&&"minmax(0,2fr)",h&&"auto"].filter(Boolean).join(" "),m="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((k,w)=>{const y=k.id??`row-${w}`,v=r.jsx(dc,{item:k,showBadge:u,showSecondary:p,showStatus:h});return k.href?r.jsx("a",{href:k.href,target:o||"_top",rel:"noopener noreferrer",className:A(m,"transition-colors hover:bg-muted/50",w>0&&"border-t border-muted-foreground/10"),children:v},y):r.jsx("div",{className:A(m,w>0&&"border-t border-muted-foreground/10"),children:v},y)}),c&&r.jsx("button",{type:"button",className:"col-span-full flex w-full items-center justify-center gap-1 border-t border-muted-foreground/10 py-2 text-xs text-muted-foreground transition-colors hover:bg-muted/50",onClick:()=>a(k=>!k),children:i?r.jsxs(r.Fragment,{children:[r.jsx(T.ChevronUp,{className:"size-3"}),s("json_see_less")]}):r.jsxs(r.Fragment,{children:[r.jsx(T.ChevronDown,{className:"size-3"}),s("json_see_more",{count:e.length-n})]})})]})}function Yo({spec:e}){const{anchorTarget:t,onUiAction:n}=C.useConfig(),{t:o}=Z(),s=l.useMemo(()=>({t:o,anchorTarget:t??"_blank",onUiAction:n}),[o,t,n]);return r.jsx(Xo,{spec:e,host:s})}function pc({spec:e,language:t,onUiAction:n,anchorTarget:o}){const s=Li({language:t,onUiAction:n,anchorTarget:o});return r.jsx(Xo,{spec:e,host:s})}function Xo({spec:e,host:t}){const n=l.useMemo(()=>e?Wi(e):null,[e]);return!n||!yo(n)?null:r.jsx(Di,{host:t,children:r.jsx(Fi,{resetKey:n,children:r.jsx(Ti,{registry:_r,initialState:n.state,children:r.jsx(Ai,{spec:n,registry:_r,fallback:ec})})})})}function Go(e){if(!e)return[];const t=e.split(`
|
|
12
|
-
`),n=[];let o=[],s=[],i=[],a=!1;function c(){if(o.length===0)return;const u=o.join(`
|
|
13
|
-
`);u.trim()&&n.push({type:"markdown",content:u}),o=[]}function d(){if(i.length===0)return;let u=null;if(s.length>0)try{u=ga(s.join(`
|
|
14
|
-
`),{root:"",elements:{}})}catch{}u&&yo(u)?(c(),n.push({type:"ui",spec:u})):o.push(...i),s=[],i=[]}for(const u of t){const p=u.trim();if(!a&&p==="```spec"){a=!0,i=[u];continue}if(a&&p==="```"){i.push(u),d(),a=!1;continue}if(a){i.push(u),p!==""&&mo(u)&&s.push(u);continue}o.push(u)}return d(),c(),n}function mc(e){return $i(e)}function D(e){return{"data-component":e}}const gn=[{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"]}],hc=Object.fromEntries(gn.flatMap(e=>e.mimes.map(t=>[t,e.extensions.map(n=>`.${n}`)]))),fc={"video/mp4":[".mp4"],"video/webm":[".webm"],"video/quicktime":[".mov"]};function Ko({type:e,name:t}){var s,i;const n=((s=t.split(".").pop())==null?void 0:s.toLowerCase())??"",o=((i=e.toLowerCase().split(";")[0])==null?void 0:i.trim())??"";return gn.find(a=>n&&a.extensions.includes(n))??gn.find(a=>o&&a.mimes.includes(o))??null}function qt(){const[e]=l.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(hover: hover) and (pointer: fine)").matches);return e}const it={x:2,y:2},Ae=l.memo(l.forwardRef(({children:e,className:t,scale:n=1.02,off:o=!1},s)=>{const[i,a]=l.useState(!1),[c,d]=l.useState({x:0,y:0}),u=qt(),p=H.useReducedMotion();if(o||!u||p)return l.cloneElement(e,{ref:s??e.props.ref});if(/translate/.test(e.props.className||""))return e;const f=y=>{var N,_;const{clientX:v,clientY:z}=y,g=y.currentTarget.getBoundingClientRect(),S=v-(g.left+g.width/2),j=z-(g.top+g.height/2),b=Math.max(-1,Math.min(1,S/(g.width/2))),E=Math.max(-1,Math.min(1,j/(g.height/2))),$=b*it.x,M=E*it.y;d({x:$,y:M}),(_=(N=e.props).onMouseMove)==null||_.call(N,y)},m=y=>{var v,z;a(!0),(z=(v=e.props).onMouseEnter)==null||z.call(v,y)},k=y=>{var v,z;a(!1),d({x:0,y:0}),(z=(v=e.props).onMouseLeave)==null||z.call(v,y)},w={"--wobble-x":i?`${c.x}px`:"0px","--wobble-y":i?`${c.y}px`:"0px","--scale":1-(n-1)};return l.cloneElement(e,{ref:s,onMouseMove:f,onMouseEnter:m,onMouseLeave:k,style:{...w,...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)]")})}));Ae.displayName="Wobble";const zt=[.23,1,.32,1],gc=`cubic-bezier(${zt.join(", ")})`,ze={duration:.2,ease:zt},ge={duration:.15,ease:zt},ct={type:"spring",stiffness:500,damping:45,mass:1},xc=[.32,.72,.24,1],bc=`cubic-bezier(${xc.join(", ")})`,wc="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)",yc="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)",vc="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)",jc="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)",kc=10,Cc=(e,t,n)=>({initial:{opacity:0,x:-e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...ze,delay:n}},exit:{opacity:0,x:e,...t.exit,transition:ge},transition:ze}),Sc=(e,t,n)=>({initial:{opacity:0,x:e,...t.initial},animate:{opacity:1,x:0,...t.animate,transition:{...ze,delay:n}},exit:{opacity:0,x:-e,...t.exit,transition:ge},transition:ze}),Nc=(e,t,n)=>({initial:{opacity:0,y:e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...ze,delay:n}},exit:{opacity:0,y:-e,...t.exit,transition:ge},transition:ze}),_c=(e,t,n)=>({initial:{opacity:0,y:-e,...t.initial},animate:{opacity:1,y:0,...t.animate,transition:{...ze,delay:n}},exit:{opacity:0,y:e,...t.exit,transition:ge},transition:ze}),zc={right:Cc,left:Sc,up:Nc,down:_c},te=l.forwardRef(({fadeIn:e="down",distance:t=kc,children:n,snapExit:o=!1,overrides:s={},delay:i=0,...a},c)=>{const d=e?zc[e](t,s,i):{};return o&&d.exit&&typeof d.exit=="object"&&!Array.isArray(d.exit)&&(d.exit.transition={duration:0}),r.jsx(H.motion.div,{ref:c,...a,...d,children:n})});te.displayName="MotionDiv";const xn=oo.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"}}),G=qe.forwardRef(({className:e,variant:t="default",size:n,asChild:o=!1,wobble:s=!0,...i},a)=>{const c=o?oa.Slot:"button";return r.jsx(Ae,{ref:a,off:!s,children:r.jsx(c,{...D("ui_lib/btn"),"data-variant":t,className:A(xn({variant:t,size:n,className:e})),...i})})});G.displayName="Button";const Zo=l.createContext(null);function Ec({children:e}){const[t,n]=l.useState(!1),[o,s]=l.useState(null),i=c=>{s(c),n(!0)},a=l.useCallback(()=>{n(!1),setTimeout(()=>{s(null)},200)},[]);return r.jsxs(Zo.Provider,{value:{open:i,close:a,isOpen:t,content:o},children:[r.jsx(Ic,{}),e]})}function Ut(){const e=l.useContext(Zo);return e||(ee.log.error("useDialoger must be used within a DialogerProvider"),{open:()=>{},close:()=>{},isOpen:!1,content:null})}function Ic(){const{contentIframeRef:e}=C.useWidget(),{isOpen:t,content:n,close:o}=Ut();return l.useEffect(()=>{var a,c;if(!t)return;const s=d=>{d.defaultPrevented||d.key!=="Escape"||(d.preventDefault(),o())},i=(c=(a=e==null?void 0:e.current)==null?void 0:a.contentWindow)==null?void 0:c.document;return i==null||i.addEventListener("keydown",s),()=>i==null?void 0:i.removeEventListener("keydown",s)},[o,e,t]),r.jsx(H.AnimatePresence,{mode:"wait",children:t&&n&&r.jsx(te,{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 Vt({children:e,className:t,withClose:n=!1}){const{close:o}=Ut(),{t:s}=Z();return r.jsxs("div",{"data-opencx-escape-scope":!0,className:A("fixed left-[50%] top-[50%] z-50 flex flex-col gap-4 w-full max-w-[61.8%] translate-x-[-50%] translate-y-[-50%] border bg-background p-4 rounded-3xl",t),onClick:i=>i.stopPropagation(),children:[e,n&&r.jsxs(G,{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 An=({className:e,...t})=>r.jsx("div",{className:A("flex flex-col gap-2 text-center pt-2",e),...t});An.displayName="DialogerHeader";const Tn=({className:e,...t})=>r.jsx("div",{className:A("flex flex-col gap-2 text-center",e),...t});Tn.displayName="DialogerBody";const Jo=({className:e,...t})=>r.jsx("div",{className:A("flex flex-col gap-2",e),...t});Jo.displayName="DialogerFooter";const Pn=l.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:A("text-lg font-semibold leading-none tracking-tight",e),...t}));Pn.displayName="DialogerTitle";const Mn=l.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:A("text-sm text-muted-foreground",e),...t}));Mn.displayName="DialogerDescription";function Yt({children:e,trigger:t}){const{open:n}=Ut();return l.cloneElement(t,{onClick:()=>{var s,i;n(e),(i=(s=t.props).onClick)==null||i.call(s)}})}const Er=1,Ir=5,Ar=.5,Ac=2.5;function Tc(e,t,n,o){if(!n||!o||t<=1)return{x:0,y:0};const s=n.getBoundingClientRect(),i=o.offsetWidth,a=o.offsetHeight,c=Math.max(0,(i*t-s.width)/(2*t)),d=Math.max(0,(a*t-s.height)/(2*t));return{x:Math.min(c,Math.max(-c,e.x)),y:Math.min(d,Math.max(-d,e.y))}}function Qo({src:e,alt:t}){const{t:n}=Z(),[o,s]=l.useState(1),[i,a]=l.useState({x:0,y:0}),[c,d]=l.useState(!1),u=l.useRef({x:0,y:0}),p=l.useRef({x:0,y:0}),h=l.useRef(null),f=l.useRef(null),m=l.useRef(!1),k=b=>Math.min(Ir,Math.max(Er,b)),w=l.useCallback(()=>{s(1),a({x:0,y:0})},[]),y=l.useCallback(()=>{s(b=>k(b+Ar))},[]),v=l.useCallback(()=>{s(b=>{const E=k(b-Ar);return E<=1&&a({x:0,y:0}),E})},[]),z=l.useCallback(b=>{b.preventDefault(),m.current=!1,d(!0),u.current={x:b.clientX,y:b.clientY},p.current={...i},b.target.setPointerCapture(b.pointerId)},[i]),g=l.useCallback(b=>{if(!c)return;const E=b.clientX-u.current.x,$=b.clientY-u.current.y;if((Math.abs(E)>3||Math.abs($)>3)&&(m.current=!0),o<=1)return;const M={x:p.current.x+E/o,y:p.current.y+$/o};a(Tc(M,o,h.current,f.current))},[c,o]),S=l.useCallback(()=>{const b=m.current;d(!1),!b&&s(E=>E>1?(a({x:0,y:0}),1):Ac)},[]),j=o>1;return r.jsxs("div",{className:"relative size-full flex items-center justify-center select-none",onClick:b=>b.stopPropagation(),children:[r.jsx("div",{ref:h,className:A("overflow-hidden max-h-full max-w-full rounded-2xl flex items-center justify-center",j&&"size-full"),onPointerDown:z,onPointerMove:g,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(${i.x}px, ${i.y}px)`,transformOrigin:"center center"}})}),r.jsxs("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1 bg-black/60 backdrop-blur-sm rounded-full px-1.5 py-1 transition opacity-50 hover:opacity-100",children:[r.jsx(sn,{onClick:v,label:n("zoom_out"),disabled:o<=Er,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(sn,{onClick:y,label:n("zoom_in"),disabled:o>=Ir,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(sn,{onClick:w,label:n("reset_zoom"),children:r.jsx(T.RotateCcw,{className:"size-3.5"})})]})]})]})}function sn({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 Tr({url:e,name:t,size:n,icon:o,label:s}){return r.jsx(Ae,{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 es({attachment:e}){const{name:t,size:n,type:o,url:s}=e,i=o.startsWith("image/"),a=o.startsWith("video/"),c=o.startsWith("audio/"),d=o==="application/pdf";if(c)return r.jsx(Ae,{children:r.jsx("div",{className:"w-full shrink-0 overflow-hidden",children:r.jsxs("audio",{controls:!0,className:"w-full",children:[r.jsx("source",{src:s,type:o}),"Your browser does not support the audio tag."]})})});if(a)return r.jsx(Ae,{children:r.jsx("div",{className:"w-full border shrink-0 rounded-2xl overflow-hidden",children:r.jsxs("video",{controls:!0,children:[r.jsx("source",{src:s,type:o}),"Your browser does not support the video tag."]})})});if(i)return r.jsx(Yt,{trigger:r.jsx("div",{children:r.jsx(Ae,{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(Vt,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(Qo,{src:s,alt:t})})});if(d)return r.jsx(Tr,{url:s,name:t,size:n,icon:r.jsx(T.FileText,{className:"size-5",strokeWidth:1.75}),label:"PDF"});const u=Ko({type:o,name:t});return u?r.jsx(Tr,{url:s,name:t,size:n,icon:r.jsx(T.FileSpreadsheet,{className:"size-5",strokeWidth:1.75}),label:u.label}):r.jsx(Ae,{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"]})]})})})}const ts=l.memo(sa,(e,t)=>e.children===t.children&&e.className===t.className);function ns(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()}var no,ro;const Pc={...gt.defaultSchema,attributes:{...gt.defaultSchema.attributes,code:[...((no=gt.defaultSchema.attributes)==null?void 0:no.code)??[],"className"],pre:[...((ro=gt.defaultSchema.attributes)==null?void 0:ro.pre)??[],"className"]}};function Xt({children:e,messageType:t,messageId:n}){const{anchorTarget:o}=C.useConfig();return r.jsx(ts,{"data-type":t,"data-id":n,remarkPlugins:[so],rehypePlugins:[ao,[gt,Pc]],components:{a:({children:s,...i})=>r.jsx("a",{target:i.target||o||"_top",...i,children:s}),img:({src:s,alt:i,...a})=>s?r.jsx(Yt,{trigger:r.jsx("img",{src:s,alt:i,...a,className:"cursor-pointer rounded-xl"}),children:r.jsx(Vt,{className:"size-full max-w-full rounded-3xl flex items-center justify-center bg-transparent border-none gap-0",withClose:!0,children:r.jsx(Qo,{src:s,alt:i})})}):r.jsx("img",{src:s,alt:i,...a})},children:ns(e)})}function Me(){const{widgetCtx:{org:e}}=C.useWidget(),{sessionState:{session:t}}=C.useSessions(),n=C.useConfig(),{messagesState:{messages:o}}=C.useMessages(),{routerState:{screen:s}}=C.useWidgetRouter();return{react:l,org:e,session:t,config:n,messages:o,currentScreen:s}}function Mc({currentMessage:e}){var o;const t=Me(),n=(o=t.config.customComponents)==null?void 0:o["message::after"];return n?r.jsx(n,{...t,currentMessage:e}):null}function bn(e){const{data:t,id:n,type:o,attachments:s,isFirstInGroup:i,isLastInGroup:a,isAloneInGroup:c,dataComponentNames:d,classNames:u}=e,p=o==="AI"||o==="AGENT"?t.message:"",h=l.useMemo(()=>o==="AI"?Go(p):null,[o,p]);if(o!=="AI"&&o!=="AGENT")return null;const{variant:f="default"}=t,m=(y,v,z=!0)=>r.jsxs("div",{className:"flex flex-row gap-2",children:[r.jsx("div",{...D((d==null?void 0:d.message)??"chat/agent_msg/msg"),"data-first":i,"data-last":a,"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","break-words [word-break:break-word]",f==="error"&&"bg-destructive/15 text-destructive",i&&!c&&"rounded-bl-md",a&&!c&&"rounded-tl-md",!i&&!a&&!c&&"rounded-l-md",u==null?void 0:u.message),children:r.jsx(Xt,{messageType:o,messageId:n,children:y})}),z&&r.jsx(Mc,{currentMessage:e})]},v),k=(h==null?void 0:h.some(y=>y.type==="ui"))??!1,w=(h==null?void 0:h.reduce((y,v,z)=>v.type==="markdown"?z:y,-1))??-1;return r.jsxs("div",{...D((d==null?void 0:d.messageContainer)??"chat/agent_msg/root"),className:A("w-5/6 flex flex-col items-start gap-1",u==null?void 0:u.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(y=>r.jsx(es,{attachment:y},y.id))}),k&&h?h.map((y,v)=>y.type==="markdown"?m(y.content,`md-${v}`,v===w):r.jsx("div",{className:"w-full",children:r.jsx(Yo,{spec:y.spec})},`ui-${v}`)):p.length>0&&m(p)]})}function Rc(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 Rn=qe.forwardRef(({className:e,...t},n)=>r.jsx(dt.Root,{ref:n,className:A("relative flex size-6 aspect-square shrink-0 overflow-hidden rounded-full bg-secondary",e),...t}));Rn.displayName=dt.Root.displayName;const $n=qe.forwardRef(({className:e,...t},n)=>r.jsx(dt.Image,{ref:n,className:A("aspect-square h-full w-full",e),...t}));$n.displayName=dt.Image.displayName;const On=qe.forwardRef(({className:e,...t},n)=>r.jsx(dt.Fallback,{ref:n,className:A("flex size-full text-xs items-center justify-center rounded-lg",e),...t}));On.displayName=dt.Fallback.displayName;function wn({agent:e,...t}){var n,o;return r.jsxs(Rn,{...t,children:[r.jsx($n,{src:(e==null?void 0:e.avatarUrl)||(e==null?void 0:e.avatar)||"",alt:"Agent Icon"}),(e==null?void 0:e.name)&&r.jsx(On,{children:(o=(n=e==null?void 0:e.name)==null?void 0:n.slice(0,1))==null?void 0:o.toUpperCase()})]})}function $c({agent:e}){return r.jsx(H.AnimatePresence,{children:r.jsxs(te,{...D("chat/bot_loading/root"),className:"flex flex-row items-end w-full gap-2 animate-pulse",children:[r.jsx(wn,{agent:e}),r.jsxs("div",{...D("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(H.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.3s]"}),r.jsx(H.motion.span,{className:"rounded-full animate-bounce [animation-delay:-0.15s]"}),r.jsx(H.motion.span,{className:"rounded-full animate-bounce"})]})]})})}const Oc='*,: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}.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-6{inset-inline-end:1.5rem}.left-1\\/2,.left-\\[50\\%\\]{left:50%}.right-4{right:1rem}.start-2{inset-inline-start:.5rem}.top-1{top:.25rem}.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-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}.-mt-0\\.5{margin-top:-.125rem}.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-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}.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-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-3\\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.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}.w-0{width:0px}.w-1\\/2{width:50%}.w-10{width:2.5rem}.w-14{width:3.5rem}.w-2\\/5{width:40%}.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-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}.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,.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-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-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-\\[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-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-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\\/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\\/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-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}.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-\\[3px\\]{padding-top:3px;padding-bottom:3px}.pb-0{padding-bottom:0}.pb-0\\.5{padding-bottom:.125rem}.pb-1{padding-bottom:.25rem}.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\\.5{padding-inline-end:.625rem}.pe-4{padding-inline-end:1rem}.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-2{padding-inline-start:.5rem}.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-3{padding-top:.75rem}.pt-4{padding-top:1rem}.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-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-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-muted-foreground\\)\\)\\]{--tw-prose-body: hsl(var(--opencx-muted-foreground))}.\\[--tw-prose-bold\\:hsl\\(var\\(--opencx-foreground\\)\\)\\]{--tw-prose-bold: hsl(var(--opencx-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-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-hr\\:hsl\\(var\\(--opencx-border\\)\\)\\]{--tw-prose-hr: hsl(var(--opencx-border))}.\\[--tw-prose-links\\:hsl\\(var\\(--opencx-primary\\)\\)\\]{--tw-prose-links: hsl(var(--opencx-primary))}.\\[--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))}.\\[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-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\\/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-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-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-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}}',Dc="5.0.0-beta.7";function Lc(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 Pr=450;function Ee(){const[e,t]=l.useState(()=>(window.top||window).innerWidth<Pr);return l.useEffect(()=>{const n=window.top||window,o=()=>{t(n.innerWidth<Pr)};return o(),n.addEventListener("resize",o),()=>{n.removeEventListener("resize",o)}},[]),{isSmallScreen:e}}const Mt={transitionTimingFunction:"cubic-bezier(0.16, 1, 0.3, 1)",transitionDuration:"1000ms"};function he(){var f,m,k,w,y,v,z,g,S,j,b,E,$,M,N,_,W,B,I,P,L,O,V,U,q,F,K,ne,re,R,X,J,se,oe,ue,pe,ye,ve,de,Re,$e,Ie,xe,Qe,Ue,le,Oe,et;const{dir:e}=C.useDocumentDir(),{isSmallScreen:t}=Ee(),{theme:n,inline:o}=C.useConfig(),s=me=>o?"100%":me,i=(me,Ve)=>t?`100dv${me}`:Ve,a=(me,Ve)=>s(i(me,Ve)),c=Lc((f=n==null?void 0:n.widgetTrigger)==null?void 0:f.offset,e),d={zIndex:((m=n==null?void 0:n.widgetTrigger)==null?void 0:m.zIndex)??1e7,offset:{bottom:((w=(k=n==null?void 0:n.widgetTrigger)==null?void 0:k.offset)==null?void 0:w.bottom)??20,right:((v=(y=n==null?void 0:n.widgetTrigger)==null?void 0:y.offset)==null?void 0:v.right)??(c==="right"?20:"initial"),left:((g=(z=n==null?void 0:n.widgetTrigger)==null?void 0:z.offset)==null?void 0:g.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:((E=(b=n==null?void 0:n.widgetTrigger)==null?void 0:b.size)==null?void 0:E.icon)??24}},u=(()=>{const me=c==="right"?d.offset.right:d.offset.left;return typeof me!="number"?0:me})(),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":(($=n==null?void 0:n.widgetContentContainer)==null?void 0:$.borderRadius)??"32px",zIndex:((M=n==null?void 0:n.widgetContentContainer)==null?void 0:M.zIndex)??d.zIndex+1,outline:((N=n==null?void 0:n.widgetContentContainer)==null?void 0:N.outline)??"none",outlineColor:((_=n==null?void 0:n.widgetContentContainer)==null?void 0:_.outlineColor)??"hsl(0 0% 50% / .5)",boxShadow:((W=n==null?void 0:n.widgetContentContainer)==null?void 0:W.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:((I=n==null?void 0:n.widgetContentContainer)==null?void 0:I.transitionTimingFunction)??Mt.transitionTimingFunction,transitionDuration:((P=n==null?void 0:n.widgetContentContainer)==null?void 0:P.transitionDuration)??Mt.transitionDuration,offset:{side:t?0:d.offset.bottom+d.size.button+it.y*2+(((O=(L=n==null?void 0:n.widgetContentContainer)==null?void 0:L.offset)==null?void 0:O.side)??10),align:t?0:u+(((U=(V=n==null?void 0:n.widgetContentContainer)==null?void 0:V.offset)==null?void 0:U.align)??0)}},screens:{welcome:{width:a("w",((F=(q=n==null?void 0:n.screens)==null?void 0:q.welcome)==null?void 0:F.width)??"400px"),minHeight:a("h",((ne=(K=n==null?void 0:n.screens)==null?void 0:K.welcome)==null?void 0:ne.minHeight)??"1px")},sessions:{width:a("w",((R=(re=n==null?void 0:n.screens)==null?void 0:re.sessions)==null?void 0:R.width)??"450px"),height:a("h",((J=(X=n==null?void 0:n.screens)==null?void 0:X.sessions)==null?void 0:J.height)??"600px")},chat:{width:a("w",((oe=(se=n==null?void 0:n.screens)==null?void 0:se.chat)==null?void 0:oe.width)??"525px"),height:a("h",((pe=(ue=n==null?void 0:n.screens)==null?void 0:ue.chat)==null?void 0:pe.height)??"700px"),withCanvas:{width:a("w",((de=(ve=(ye=n==null?void 0:n.screens)==null?void 0:ye.chat)==null?void 0:ve.withCanvas)==null?void 0:de.width)??"min(1050px, 100vw)"),height:a("h",((Ie=($e=(Re=n==null?void 0:n.screens)==null?void 0:Re.chat)==null?void 0:$e.withCanvas)==null?void 0:Ie.height)??"min(800px, 100vh)"),transitionTimingFunction:((Ue=(Qe=(xe=n==null?void 0:n.screens)==null?void 0:xe.chat)==null?void 0:Qe.withCanvas)==null?void 0:Ue.transitionTimingFunction)??Mt.transitionTimingFunction,transitionDuration:((et=(Oe=(le=n==null?void 0:n.screens)==null?void 0:le.chat)==null?void 0:Oe.withCanvas)==null?void 0:et.transitionDuration)??Mt.transitionDuration}}}},h={maxHeight:a("h",`calc(
|
|
15
|
-
100vh
|
|
16
|
-
- ${p.widgetTrigger.offset.bottom}px
|
|
17
|
-
- ${p.widgetContentContainer.offset.side}px
|
|
18
|
-
- ${it.y*2}px
|
|
19
|
-
)`),maxWidth:a("w",`calc(
|
|
20
|
-
100vw
|
|
21
|
-
- ${u*2}px
|
|
22
|
-
)`),minHeight:a("h",`min(
|
|
23
|
-
${p.screens.welcome.minHeight},
|
|
24
|
-
${p.screens.sessions.height},
|
|
25
|
-
${p.screens.chat.height}
|
|
26
|
-
)`),minWidth:a("w",`min(
|
|
27
|
-
${p.screens.welcome.width},
|
|
28
|
-
${p.screens.sessions.width},
|
|
29
|
-
${p.screens.chat.width}
|
|
30
|
-
)`)};return{theme:p,triggerSide:c,computed:h,cssVars:Fc({palette:p.palette,primary:p.primaryColor})}}function Fc({palette:e,primary:t}){const n=rs(e),o=dr(t).toHsl(),s=dr(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 rs(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 ee.isExhaustive(e,rs.name),t}}const Wc=Se.Provider,Hc=Se.Root,Bc=Se.Trigger,os=qe.forwardRef(({className:e,sideOffset:t=4,...n},o)=>r.jsx(Se.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}));os.displayName=Se.Content.displayName;const ss=qe.createContext(!1);function qc({children:e}){return r.jsx(ss.Provider,{value:!0,children:e})}function _e({children:e,content:t,side:n,align:o,shortcut:s}){const{disableTooltips:i}=C.useConfig(),a=qe.useContext(ss);return!t||i||a?e:r.jsxs(Hc,{children:[r.jsx(Bc,{asChild:!0,children:e}),r.jsxs(os,{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 as="OpenCX Live Chat";function Dn({transparent:e=!1}={}){return`<!DOCTYPE html>
|
|
31
|
-
<html>
|
|
32
|
-
<head>
|
|
33
|
-
<style>
|
|
34
|
-
${Oc}
|
|
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 Ln({overrides:e,rootRef:t,style:n,shellRadius:o,children:s}){const{cssOverrides:i}=C.useConfig(),{cssVars:a,theme:c}=he(),{dir:d}=Z(),u={"--opencx-shell-radius":o??c.widgetContentContainer.borderRadius,"--opencx-inset-radius":"max(0.75rem, calc(var(--opencx-shell-radius) - 0.5rem))"};return r.jsxs(r.Fragment,{children:[e?r.jsx("style",{children:e}):null,i?r.jsx("style",{children:i}):null,r.jsx("div",{ref:t,style:{...a,...u,...n},"data-version":Dc,dir:d,className:A("antialiased font-sans size-full overflow-hidden relative text-secondary-foreground isolate"),children:r.jsx(Wc,{delayDuration:200,disableHoverableContent:!0,children:r.jsx(Ec,{children:s})})})]})}function is(){const{contentIframeRef:e}=C.useWidget(),{inline:t}=C.useConfig();return{setWidth:n=>{var o;(o=e==null?void 0:e.current)==null||o.style.setProperty("--opencx-widget-width",t?"100%":n)},setHeight:n=>{var o;(o=e==null?void 0:e.current)==null||o.style.setProperty("--opencx-widget-height",t?"100%":n)}}}function Fn({width:e,height:t}){const{isSmallScreen:n}=Ee(),{setWidth:o,setHeight:s}=is();l.useEffect(()=>{e&&o(e),t&&s(t)},[n,t,e,o,s])}const Mr=T.CircleDashedIcon;function lt({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 Mr;default:return ee.isExhaustive(e,lt.name),Mr}})();return r.jsx(n,{className:A("size-4",t)})}function Wn(e){const{t}=Z(),{session:n}=C.usePrimitiveState(e.ctx.sessionCtx.sessionState),{messages:o}=C.usePrimitiveState(e.ctx.messageCtx.state),s=C.usePrimitiveState(e.ctx.messageCtx.draftState),i=e.title||(n==null?void 0:n.title)||t("companion_chat_number",{count:e.id});let a=(n==null?void 0:n.lastMessage)??s.text??"";for(let u=o.length-1;u>=0;u--){const p=o[u],h=p.type==="USER"?p.content:p.type==="SYSTEM"?"":p.data.message;if(h.trim()){a=h;break}}const c=e.working?t("companion_working"):n!=null&&n.isOpened?t("companion_open"):t(n?"companion_closed":"companion_draft");return{title:!e.hasDraft&&!e.hasSession&&!e.working&&!n&&!e.title&&!o.length&&!s.text&&!s.mentions.length?t("new_conversation"):i,preview:a.replace(/\s+/g," ").trim(),status:c}}function Hn(){const e=qt(),[t,n]=l.useState(null),[o,s]=l.useState(!1),[i,a]=l.useState(!1),[c,d]=l.useState(!1),u=l.useRef(!1),p=l.useRef(void 0),h=l.useCallback(()=>clearTimeout(p.current),[]);l.useEffect(()=>h,[h]);const f=l.useCallback((m=!1)=>{h(),u.current=!1,m&&a(!1),s(!1)},[h]);return{anchor:t,open:o,animate:i,autoFocus:c,close:f,toggle(m,k=!1){if(h(),o&&u.current){f(!k);return}u.current=!0,n(m),a(k),d(!0),s(!0)},hover(m){h(),!(!e||o)&&(p.current=setTimeout(()=>{u.current=!1,n(m),a(!0),d(!1),s(!0)},100))},enter:h,leave(){h(),u.current||(p.current=setTimeout(()=>f(),200))}}}function Bn(){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 Uc({picker:e,...t}){return r.jsxs(r.Fragment,{children:[r.jsx(Bn,{}),r.jsx(G,{...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 Vc({chat:e,selected:t,onSelect:n,onClose:o}){const{t:s}=Z(),{title:i,preview:a,status:c}=Wn(e);return r.jsx(Ae,{children:r.jsxs("div",{"data-chat-row":"","data-companion-action":"","data-selected":t||void 0,children:[r.jsx(ke.RadioItem,{asChild:!0,value:String(e.id),textValue:i,onSelect:d=>{d.preventDefault(),n()},children:r.jsxs("button",{className:xn({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-description":a||void 0,"aria-label":`${i} — ${c}${t?` — ${s("companion_viewing")}`:""}`,"data-chat-select":e.id,children:[r.jsx("span",{"data-chat-indicator":"","aria-hidden":!0,children:r.jsx(ke.ItemIndicator,{children:r.jsx(T.CheckIcon,{size:14})})}),r.jsx("span",{"data-chat-title":"",children:i}),e.working&&r.jsx(T.LoaderCircleIcon,{size:14,"data-working":"","aria-hidden":!0})]})}),r.jsx(ke.Item,{asChild:!0,textValue:s("companion_close_chat",{title:i}),onSelect:d=>{d.preventDefault(),o()},children:r.jsx("button",{className:xn({size:"selfless",className:"bg-transparent"}),type:"button","data-companion-action":"","aria-label":s("companion_close_chat",{title:i}),"data-chat-close":e.id,children:r.jsx(T.XIcon,{size:14,"aria-hidden":!0})})})]})})}function qn(e){const{picker:t,portalTarget:n}=e;return t.anchor&&n?r.jsx(Yc,{...e,anchor:t.anchor,portalTarget:n}):null}function Yc({picker:e,anchor:t,portalTarget:n,placement:o,onSelected:s}){const{open:i,animate:a,autoFocus:c,close:d,enter:u,leave:p}=e,{chats:h,activeId:f,selectChat:m,newChat:k,closeChat:w}=C.useCompanionChats(),{canCreateNewSession:y}=C.useSessions(),{t:v,dir:z}=Z(),{cssVars:g,theme:S}=he(),j=l.useRef(null),b=l.useRef(t.ownerDocument.activeElement),E=l.useCallback(I=>{I&&!j.current&&(b.current=t.ownerDocument.activeElement),j.current=I},[t]),$=l.useRef(!1),M=l.useRef({onClose:d,onSelected:s});M.current={onClose:d,onSelected:s};const N=l.useMemo(()=>({current:{getBoundingClientRect(){let I=t.getBoundingClientRect(),P=t.ownerDocument.defaultView;const L=n.ownerDocument.defaultView;for(;P&&P!==L;){const O=P.frameElement;if(!O)break;const V=O.getBoundingClientRect(),U=V.width/O.offsetWidth||1,q=V.height/O.offsetHeight||1;I=new DOMRect(V.left+I.left*U,V.top+I.top*q,I.width*U,I.height*q),P=O.ownerDocument.defaultView}return I}}}),[t,n]),_=h.filter(I=>I.working).length;l.useEffect(()=>{if(!i||t.ownerDocument===n.ownerDocument)return;const I=L=>{L.composedPath().includes(t)||L.type==="focusin"&&!c&&L.target===b.current||M.current.onClose(L.type==="focusin")},P=t.ownerDocument;return P.addEventListener("pointerdown",I,!0),P.addEventListener("focusin",I),()=>{P.removeEventListener("pointerdown",I,!0),P.removeEventListener("focusin",I)}},[t,n,i,c]),l.useLayoutEffect(()=>{var I,P,L;(I=j.current)==null||I.toggleAttribute("inert",!i),i&&c&&((L=(P=j.current)==null?void 0:P.querySelector('[aria-checked="true"]'))==null||L.focus({preventScroll:!0}))},[i,c]);function W(I){var P,L;t.focus({preventScroll:!0}),I===void 0?k():m(I),M.current.onClose(!0),(L=(P=M.current).onSelected)==null||L.call(P)}function B(I){var O,V,U,q;const P=h.findIndex(F=>F.id===I),L=h[P+1]??h[P-1];I===f?(t.focus({preventScroll:!0}),M.current.onClose(!0)):(V=(O=j.current)==null?void 0:O.querySelector(L?`[data-chat-select="${L.id}"]`:"[data-new-chat]"))==null||V.focus({preventScroll:!0}),w(I),I===f&&((q=(U=M.current).onSelected)==null||q.call(U))}return kt.createPortal(r.jsxs(ke.Root,{open:i,onOpenChange:I=>{!I&&!$.current&&M.current.onClose()},modal:!1,dir:z==="rtl"?"rtl":"ltr",children:[r.jsx(ke.Anchor,{virtualRef:N}),r.jsxs(ke.Content,{ref:E,loop:!0,side:o==="above"?"top":"bottom",align:o==="below"?"start":"center",sideOffset:6,collisionPadding:12,updatePositionStrategy:"always","aria-label":v("companion_chats"),"data-companion-chat-picker":"","data-motion":a?"pointer":"instant",onEntryFocus:I=>{var P,L,O;I.preventDefault(),c?(L=(P=j.current)==null?void 0:P.querySelector('[aria-checked="true"]'))==null||L.focus({preventScroll:!0}):($.current=!0,(O=b.current)==null||O.focus({preventScroll:!0}),$.current=!1)},onCloseAutoFocus:I=>{I.preventDefault()},onEscapeKeyDown:I=>{I.preventDefault(),t.focus({preventScroll:!0}),M.current.onClose(!0)},onFocusOutside:I=>{var P,L;((P=j.current)!=null&&P.contains(I.detail.originalEvent.target)||I.detail.originalEvent.target===t||I.detail.originalEvent.target===((L=t.ownerDocument.defaultView)==null?void 0:L.frameElement)||!c&&I.detail.originalEvent.target===b.current)&&I.preventDefault()},onInteractOutside:I=>{I.detail.originalEvent.composedPath().includes(t)&&I.preventDefault()},onPointerEnter:u,onPointerLeave:p,onPointerDown:I=>I.stopPropagation(),onMouseDown:I=>I.stopPropagation(),onClick:I=>I.stopPropagation(),onKeyDown:I=>{I.key==="Tab"&&(I.preventDefault(),t.focus({preventScroll:!0}),M.current.onClose(!0))},style:{...g,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(Bn,{}),r.jsx("style",{children:`
|
|
61
|
-
[data-companion-chat-picker] {
|
|
62
|
-
transform-origin: var(--radix-popper-transform-origin);
|
|
63
|
-
animation: opencx-menu-in ${ge.duration*1e3}ms ${gc};
|
|
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(ke.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:v("companion_chats")}),_>0&&r.jsx("span",{role:"status",children:v("companion_working_chats",{count:_})})]}),r.jsx(ke.RadioGroup,{value:String(f),children:h.map(I=>r.jsx(Vc,{chat:I,selected:I.id===f,onSelect:()=>W(I.id),onClose:()=>B(I.id)},I.id))}),r.jsx(ke.Separator,{style:{height:1,background:"hsl(var(--opencx-border) / .4)",margin:"5px 4px"}}),r.jsx(ke.Group,{children:r.jsx(ke.Item,{asChild:!0,disabled:!y,onSelect:I=>{I.preventDefault(),W()},children:r.jsxs(G,{variant:"ghost",size:"selfless",type:"button","data-companion-action":"","data-new-chat":"",disabled:!y,children:[r.jsx(T.PlusIcon,{size:14,"aria-hidden":!0}),v("new_conversation")]})})})]})]}),n)}function Gt(){const[e,t]=l.useState(null);return l.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 Xc(){const{chats:e,openChats:t,activeId:n}=C.useCompanionChats(),o=e.find(m=>m.id===n),s=Wn(o),{t:i}=Z(),a=Hn(),c=Gt(),d=s.title,u=t.filter(m=>m.id!==n),p=u.filter(m=>m.working).length,h=`${i("companion_other_sessions",{count:u.length})}${p?` · ${i("companion_working_chats",{count:p})}`:""}`,f=`${i("companion_switch_chat")}: ${d}${u.length?` · ${h}`:""}`;return r.jsxs(r.Fragment,{children:[r.jsxs(Uc,{picker:a,"data-companion-conversation-title":"",className:"flex h-8 min-w-0 max-w-full items-center gap-1.5 rounded-md px-1 text-[13px] leading-5 text-start hover:bg-muted aria-expanded:bg-muted focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring","aria-label":f,children:[o.working&&r.jsx(T.LoaderCircleIcon,{"aria-label":i("companion_working"),className:"size-3.5 shrink-0 animate-spin motion-reduce:animate-none"}),r.jsx("span",{className:"truncate font-medium",children:d}),u.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:h}),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:["+",u.length]})]}),r.jsx(T.ChevronsUpDownIcon,{"aria-hidden":!0,className:"size-3 shrink-0 text-muted-foreground"})]}),a.anchor&&c&&r.jsx(qn,{picker:a,portalTarget:c,placement:"below"})]})}function Gc(){var n;const e=Me(),t=(n=e.config.customComponents)==null?void 0:n.headerBottom;return t?r.jsx(t,{...e}):null}function Kc({fallback:e}){var o;const t=Me(),n=(o=t.config.customComponents)==null?void 0:o.headerTitle;return n?r.jsx(n,{...t}):e}function cs(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":return n;default:return ee.isExhaustive(e,cs.name),n}}function ls(){const{widgetCtx:{org:e}}=C.useWidget(),{routerState:{screen:t}}=C.useWidgetRouter(),{textContent:n}=C.useConfig();return cs(t,n,e.name)}function Zc(e){switch(e){case"chat":return D("chat/header");case"sessions":return D("sessions/header");case"welcome":return;default:ee.isExhaustive(e,ls.name);return}}function Jc(){const{router:e}=C.useConfig(),{routerState:{screen:t},toSessionsScreen:n}=C.useWidgetRouter();return t!=="chat"||e!=null&&e.chatScreenOnly?null:r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",onClick:n,children:r.jsx(T.ChevronLeftIcon,{className:"size-4 rtl:-scale-100"})})}function Qc({button:e}){const{setIsOpen:t}=C.useWidgetTrigger(),{isSmallScreen:n}=Ee(),o=Me();if(n&&e.hideOnSmallScreen||!n&&e.hideOnLargeScreen)return null;const s=()=>{var i;e.handleClick?e.handleClick():t(!1),(i=e.onClicked)==null||i.call(e,o)};return r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",onClick:s,children:r.jsx(lt,{name:e.icon})})}function yn({button:e}){const[t,n]=l.useState(!1),{routerState:{screen:o}}=C.useWidgetRouter(),{isSmallScreen:s}=Ee(),{theme:i}=he(),{setWidth:a,setHeight:c}=is(),d=Me();if(o!=="chat"&&o!=="sessions")return null;const u=(()=>{switch(o){case"chat":return i.screens.chat.height;case"sessions":return i.screens.sessions.height;default:return ee.isExhaustive(o,yn.name),i.screens.chat.height}})(),p=(()=>{switch(o){case"chat":return i.screens.chat.width;case"sessions":return i.screens.sessions.width;default:return ee.isExhaustive(o,yn.name),i.screens.chat.width}})(),h=()=>{var f;n(m=>{const k=!m;return c(k?"100vh":u),a(k?`max(40vw, ${p})`:p),k}),(f=e.onClicked)==null||f.call(e,d)};return s&&e.hideOnSmallScreen||!s&&e.hideOnLargeScreen?null:r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",onClick:h,children:r.jsx(lt,{name:e.icon||(t?e.shrinkIcon:e.expandIcon)})})}function ds({button:e}){var v,z;const{close:t}=Ut(),{widgetCtx:n}=C.useWidget(),{setIsOpen:o}=C.useWidgetTrigger(),{resolveSession:s,sessionState:i}=C.useSessions(),{isSmallScreen:a}=Ee(),c=Me(),{t:d}=Z(),u=!i.session,p=((v=i.session)==null?void 0:v.isOpened)===!1,h=e.onResolved||"stay-in-chat",f=e.behaviorBeforeSessionCreation||"disabled",m=e.behaviorIfSessionIsResolved||"disabled",k=!!(i.isResolvingSession||u&&f==="disabled"||p&&m==="disabled"),w=async()=>{const{success:g,error:S}=await s();if(t(),!g)return ee.log.error("failed to resolve session",S),!1;switch(h){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:ee.isExhaustive(h,ds.name);break}return!0},y=()=>{if(u)switch(f){case"disabled":return;case"close-widget":o(!1);break;default:ee.isExhaustive(f,y.name)}if(p)switch(m){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:ee.isExhaustive(m,y.name)}};return a&&e.hideOnSmallScreen||!a&&e.hideOnLargeScreen?null:((z=e.confirmation)==null?void 0:z.type)==="modal"&&!p&&!u?r.jsx(Yt,{trigger:r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",disabled:k,onClick:()=>{var g;return(g=e.onClicked)==null?void 0:g.call(e,c)},children:r.jsx(lt,{name:e.icon})}),children:r.jsxs(Vt,{children:[r.jsx(An,{children:r.jsx(Pn,{children:e.confirmation.title||d("close_conversation_title")})}),r.jsx(Tn,{children:r.jsx(Mn,{children:e.confirmation.description||d("close_conversation_description")})}),r.jsxs(Jo,{children:[r.jsx(G,{variant:"secondary",onClick:t,disabled:i.isResolvingSession,children:e.confirmation.cancelButtonText||d("close_conversation_cancel")}),r.jsx(G,{variant:"destructive",onClick:async()=>{var S,j;await w()&&((j=(S=e.confirmation)==null?void 0:S.onResolved)==null||j.call(S,c))},disabled:i.isResolvingSession,children:e.confirmation.confirmButtonText||d("close_conversation_confirm")})]})]})}):r.jsx(G,{variant:"ghost",size:"fit",className:"rounded-full",onClick:()=>{var g;p||u?y():w(),(g=e.onClicked)==null||g.call(e,c)},disabled:k,children:r.jsx(lt,{name:e.icon})})}function vn({button:e}){switch(e.functionality){case"close-widget":return r.jsx(Qc,{button:e});case"expand-shrink":return r.jsx(yn,{button:e});case"resolve-session":return r.jsx(ds,{button:e});default:return ee.isExhaustive(e,vn.name),null}}const el={functionality:"close-widget",hideOnLargeScreen:!0,icon:"X"};function tl(){const{routerState:{screen:e}}=C.useWidgetRouter(),{headerButtons:t}=C.useConfig(),n=e==="chat"?t==null?void 0:t.chatScreen:e==="sessions"?t==null?void 0:t.sessionsScreen:[];return!n||n.length===0?r.jsx(vn,{button:el}):r.jsx(r.Fragment,{children:n.map(o=>r.jsx(vn,{button:o},`${o.functionality}-${o.icon}`))})}function us(){const e=C.useConfig(),t=e.displayMode==="companion"&&!e.inline,{routerState:{screen:n}}=C.useWidgetRouter(),o=Zc(n),s=ls();return r.jsxs("header",{...o,className:"py-2 px-4 shrink-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Jc,{}),r.jsx("div",{className:A("min-w-0 flex-1 h-8 flex items-center",n==="sessions"&&"ps-2"),style:{paddingInlineEnd:t?64:void 0},children:r.jsx(Kc,{fallback:t&&n!=="sessions"?r.jsx(Xc,{}):r.jsx("h2",{className:"font-semibold",children:s})})}),r.jsx(tl,{})]}),r.jsx(Gc,{})]})}function ps({className:e}){return r.jsx(T.LoaderIcon,{className:A("size-4 animate-spin",e)})}function nl(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{isSmallScreen:t}=Ee(),{activeMode:n,Component:o}=C.useModes();return{isCanvasOpen:!e&&!t&&!!n&&!!o}}function rl({isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n,...o}){const{componentStore:s}=C.useWidget();if(o.type!=="AGENT"&&o.type!=="AI")return null;if(o.data.action){const a=s.getComponent(o.data.action.name);if(a)return r.jsx(a,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}const i=s.getComponent(o.component);return i?r.jsx(i,{...o,id:o.id,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n}):r.jsx(bn,{...o,isFirstInGroup:e,isLastInGroup:t,isAloneInGroup:n})}function Un({suggestion:e,className:t,...n}){const{sendMessage:o}=C.useMessages(),s=()=>{const i=e.trim();i&&o({content:i})};return r.jsx(G,{...D("chat/suggested_reply_btn"),size:"sm",className:A("rounded-xl w-fit",t),...n,onClick:s,children:e})}function ms({messages:e,className:t,containerClassName:n}){var a,c;const{timestamps:o}=C.useConfig();if(!((a=o==null?void 0:o.perMessageGroup)!=null&&a.enabled))return null;const s=(c=e[e.length-1])==null?void 0:c.timestamp;if(!s)return null;const i=(()=>{try{return new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}catch(d){return ee.log.error("failed to format timestamp",d),null}})();return i?r.jsx("div",{className:n,children:r.jsx("span",{className:A("text-xs text-muted-foreground",t),children:i})}):null}const ol=2e3;function sl(e){return e.map(t=>ns(t.data.message).trim()).filter(t=>t.length>0).join(`
|
|
109
|
-
|
|
110
|
-
`)}function hs(){const{messageActions:e}=C.useConfig(),t=C.useDisplayMode();return(e==null?void 0:e.copy)??t==="companion"}function fs({messages:e}){const{t}=Z(),{messageActions:n}=C.useConfig(),o=(n==null?void 0:n.display)==="always",[s,i]=l.useState(!1),a=l.useRef(null);l.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const c=sl(e),d=typeof navigator<"u"?navigator.clipboard:void 0;if(!d||c.length===0)return null;const u=()=>{d.writeText(c).then(()=>{i(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(!1),ol)},h=>ee.log.warn("copying the reply failed",h))},p=t(s?"copied":"copy_reply");return r.jsx("div",{...D("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(_e,{content:p,side:"bottom",align:"start",children:r.jsx("button",{...D("chat/agent_msg_group/actions/copy"),type:"button","aria-label":p,"aria-live":"polite",onClick:u,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 al(e){return e.type==="AI"&&e.data.variant!=="error"}function Wt({messages:e,agent:t,suggestedReplies:n,actions:o=!0}){const s=hs(),i=e.filter(al);return r.jsxs("div",{...D("chat/agent_msg_group/root"),className:A("group flex items-end gap-2"),children:[r.jsx(_e,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(wn,{...D("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",{...D("chat/agent_msg_group/avatar_and_msgs/root"),className:A("flex items-end gap-2"),children:[r.jsx(_e,{content:t==null?void 0:t.name,side:"right",align:"end",children:r.jsx(wn,{...D("chat/agent_msg_group/avatar_and_msgs/avatar"),agent:t})}),r.jsxs("div",{...D("chat/agent_msg_group/avatar_and_msgs/msgs"),className:A("flex-1 flex flex-col gap-1"),children:[e.map((a,c,d)=>r.jsx(rl,{isFirstInGroup:c===0,isLastInGroup:c===d.length-1,isAloneInGroup:d.length===1,...a},a.id)),r.jsx(ms,{messages:e}),o&&s&&i.length>0&&r.jsx(fs,{messages:i})]})]}),n&&n.length>0&&r.jsx("div",{...D("chat/agent_msg_group/suggestions"),className:A("flex flex-col gap-1 ps-8"),children:n==null?void 0:n.map((a,c)=>r.jsx(Un,{suggestion:a},`${a}-${c}`))})]})]})}const Rr=["⠏","⠗","⠧","⠷","⠾","⠽","⠻","⠟"];function Vn({className:e}){const t=H.useReducedMotion(),[n,o]=l.useState(0);return l.useEffect(()=>{if(t)return;const s=setInterval(()=>o(i=>(i+1)%Rr.length),80);return()=>clearInterval(s)},[t]),r.jsx("span",{className:A("select-none",e),"aria-hidden":!0,children:Rr[n]})}function $r({turn:e,agent:t,timestamp:n}){const{componentStore:o,config:s,widgetCtx:i}=C.useWidget(),a=hs(),c=o.getComponent("agent_chat_steps"),d=o.getComponent("agent_chat_spec"),u=o.getComponent("loading"),[p]=l.useState(()=>new Date().toISOString()),h=n??p,f=ee.resolveClientPresentation(i.agent.presentation,s.presentation),m=C.applyPresentation(e.items,f),k=e.active&&(f==null?void 0:f.streaming)===!1&&!m.some(w=>w.kind==="questions");return r.jsxs("div",{...D("chat/streaming_turn/root"),className:"group flex flex-col gap-2",children:[m.map((w,y)=>w.kind==="text"?r.jsx(Wt,{messages:[{id:`streaming-${y}`,type:"AI",component:"bot_message",timestamp:h,data:{message:w.text},agent:t}],agent:t,actions:!1},`text-${y}`):w.kind==="spec"?d&&r.jsx(d,{parts:w.parts},`spec-${y}`):w.kind==="questions"||w.kind==="plan"||w.kind==="connection"?null:c&&r.jsx(c,{active:e.active,steps:w.steps},`steps-${y}`)),k&&u?r.jsx(u,{agent:t}):e.active&&!il(m)&&r.jsx("div",{...D("chat/streaming_turn/working"),className:"flex h-5 items-center ps-1",children:r.jsx(Vn,{className:"text-[14px] leading-none text-primary/70"})}),!e.active&&a&&r.jsx(fs,{messages:m.flatMap(w=>w.kind==="text"?[{data:{message:w.text}}]:[])})]})}function il(e){const t=e.at(-1);return(t==null?void 0:t.kind)==="steps"&&t.steps.some(n=>!n.done)}function cl({parts:e}){const t=l.useMemo(()=>mc(e),[e]);return r.jsx(Yo,{spec:t})}function ll({plan:e,active:t}){const[n,o]=l.useState(!1),s=l.useId(),i=H.useReducedMotion(),a=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,u=d*(1-(e.length>0?a/e.length:0));return r.jsxs("div",{className:"overflow-hidden rounded-xl border border-primary/10 bg-background shadow-sm","data-task-plan":!0,children:[r.jsxs("button",{type:"button",onClick:()=>o(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(H.motion.circle,{cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeDasharray:d,initial:!1,animate:{strokeDashoffset:u},transition:i?{duration:0}:ze,className:"text-emerald-600 dark:text-emerald-400"})]}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-primary",children:c==null?void 0:c.step}),r.jsxs("span",{className:"shrink-0 text-[0.8125rem] tabular-nums text-primary/50",children:[a,"/",e.length]}),r.jsx(H.motion.span,{"aria-hidden":"true",className:"flex size-3.5 shrink-0 items-center justify-center text-primary/50",initial:!1,animate:{rotate:n?0:180},transition:i?{duration:0}:ge,children:r.jsx(T.ChevronUp,{className:"size-3.5"})})]}),r.jsx("div",{id:s,"aria-hidden":!n,children:r.jsx(H.AnimatePresence,{initial:!1,children:n&&r.jsx(H.motion.div,{initial:{height:i?"auto":0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:i?"auto":0,opacity:0,transition:ge},transition:i?ge:ze,className:"overflow-hidden",children:r.jsx("ol",{className:"max-h-60 overflow-y-auto border-t border-primary/10 px-3.5 py-2",children:e.map((p,h)=>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(H.AnimatePresence,{initial:!1,children:r.jsx(H.motion.span,{className:"absolute inset-0 flex items-center justify-center",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:ge,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})]},h))})},"plan-steps")})})]})}function gs(){var n,o;const e=Me();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 xs(){var n;const e=Me(),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 bs(e){const t=[];let n=null;return e.forEach(o=>{var s,i,a,c,d,u;(((s=n==null?void 0:n[0])==null?void 0:s.type)!==o.type||((i=n[0])==null?void 0:i.type)==="AGENT"&&o.type==="AGENT"&&(((a=o.agent)==null?void 0:a.id)!==((c=n[0].agent)==null?void 0:c.id)||((d=o.agent)==null?void 0:d.name)!==((u=n[0].agent)==null?void 0:u.name)))&&(n=[],t.push(n)),n.push(o)}),t}function jn(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="USER"}function dl(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AI"}function ul(e){var t;return((t=e==null?void 0:e[0])==null?void 0:t.type)==="AGENT"}function ws(){const{messagesState:{messages:e}}=C.useMessages(),{chatBannerItems:t}=C.useConfig();return!(t!=null&&t.length)||e.length>0&&t.every(n=>!n.persistent)?null:r.jsx("div",{className:"w-full text-center text-xs",children:t.map(({message:n,persistent:o},s)=>e.length>0&&!o?null:r.jsx("div",{children:r.jsx(Xt,{children:n})},`${n}-${s}`))})}const pl=10*1024,Or=new Map;function ml(e){const t=Or.get(e);if(t!==void 0)return t;const n=hl(e);return Or.set(e,n),n}function hl(e){const t=e.trim();if(!t||t.length>pl||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 fl=oo.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 gl({className:e,variant:t,...n}){return r.jsx("div",{className:A(fl({variant:t}),e),...n})}function ys({customStatus:e,className:t,dotClassName:n}){const o=e.icon?ml(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 vs({customStatus:e,className:t}){return r.jsxs(gl,{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(ys,{customStatus:e}),r.jsx("span",{className:"truncate",children:e.name})]})}function js(){const{sessionState:{session:e}}=C.useSessions(),t=e==null?void 0:e.customStatus;return r.jsx(H.AnimatePresence,{mode:"wait",children:t&&r.jsx(te,{className:"sticky top-2 z-10 self-center max-w-full",snapExit:!0,children:r.jsx(Yt,{trigger:r.jsx(G,{variant:"ghost",size:"selfless",className:"rounded-full",children:r.jsx(vs,{customStatus:t})}),children:r.jsxs(Vt,{withClose:!0,children:[r.jsxs(An,{children:[r.jsx(ys,{customStatus:t,className:"size-8 mx-auto",dotClassName:"size-3 mx-auto"}),r.jsx(Pn,{children:t.name})]}),t.description&&r.jsx(Tn,{children:r.jsx(Mn,{children:t.description})})]})})},t.id)})}function ks(){var c;const{messagesState:{messages:e}}=C.useMessages(),t=C.useConfig(),n=C.useBot(),{advancedInitialMessages:o=[],initialQuestions:s,initialQuestionsPosition:i}=t;if(e.length>0)return null;const a=o.length?o.map(d=>d.message):(c=t.initialMessages)!=null&&c.length?t.initialMessages:["Hello, how can I help you?"];return r.jsx(Wt,{messages:a.map((d,u)=>({component:"bot_message",data:{message:d},id:`${u}-${d}`,type:"AI",timestamp:null})),suggestedReplies:i==="below-initial-messages"?s:void 0,agent:n})}function Cs({src:e,alt:t,title:n,note:o,shape:s="strip",className:i,children:a,...c}){const d=s==="tile";return r.jsxs("div",{...c,className:A("relative overflow-hidden bg-background ring-1 ring-border",d?"size-12 shrink-0 rounded-2xl":"max-w-full rounded-xl",i),children:[r.jsx("img",{src:e,alt:t,title:n,draggable:!1,className:A("block object-cover object-left-top",d?"size-full":"h-10 w-auto max-w-40")}),o&&r.jsx("div",{className:A("absolute inset-x-0 bottom-0 truncate px-1.5 py-0.5","bg-gradient-to-t from-foreground/70 to-foreground/0","text-[10px] font-medium leading-tight text-background"),children:o}),a]})}const xl=60;function Fe(e,t){return e.length>t?`${e.slice(0,t)}…`:e}function Yn(e){return(e.textContent??"").replace(/\s+/g," ").trim()}function bl(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 wl(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)&&!bl(o))??null:null}function yl(e){const t=e.tagName.toLowerCase(),n=e.getAttribute("aria-label"),o=Yn(e);if(t==="button"||e.getAttribute("role")==="button")return n?`button [${n}]`:o?`button "${Fe(o,30)}"`:"button";if(t==="a"){if(o)return`link "${Fe(o,30)}"`;const i=e.getAttribute("href");return i?`link to ${Fe(i,40)}`:"link"}if(t==="input"||t==="textarea"||t==="select"){const i=e.getAttribute("placeholder"),a=e.getAttribute("name");return i?`${t} "${Fe(i,30)}"`:n?`${t} [${n}]`:a?`${t} [${a}]`:t==="input"?`${e.getAttribute("type")??"text"} input`:t}if(/^h[1-6]$/.test(t))return o?`${t} "${Fe(o,40)}"`:t;if(t==="img"){const i=e.getAttribute("alt");return i?`image "${Fe(i,30)}"`:"image"}if(t==="svg")return"icon";if(n)return`${t} [${n}]`;if(o&&o.length<=xl)return`${t} "${Fe(o,40)}"`;const s=wl(e);return s||(t==="div"?"container":t)}function Dr(e,t){try{return e.querySelectorAll(t).length===1}catch{return!1}}function vl(e){const t=e.ownerDocument;if(e.id){const s=`#${CSS.escape(e.id)}`;if(Dr(t,s))return s}const n=[];let o=e;for(;o&&o.tagName.toLowerCase()!=="html";){const s=o.tagName.toLowerCase();if(o.id){n.unshift(`${s}#${CSS.escape(o.id)}`);break}let i=s;const a=o.parentElement;if(a){const d=Array.from(a.children).filter(u=>u.tagName===(o==null?void 0:o.tagName));d.length>1&&(i+=`:nth-of-type(${d.indexOf(o)+1})`)}n.unshift(i);const c=n.join(" > ");if(Dr(t,c))return c;o=a}return n.join(" > ")}function jl(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 kl=8;function Lr(e,t=kl){const n=document.documentElement.clientWidth||window.innerWidth,o=document.documentElement.clientHeight||window.innerHeight,s=Math.max(e.x,t),i=Math.max(e.y,t),a=Math.min(e.x+e.width,n-t),c=Math.min(e.y+e.height,o-t);return{x:Math.round(s),y:Math.round(i),width:Math.round(Math.max(0,a-s)),height:Math.round(Math.max(0,c-i))}}function Cl(e){const t=Yn(e);return{name:yl(e),selector:vl(e),tag:e.tagName.toLowerCase(),text:t?Fe(t,200):void 0}}const Ss=["#opencx-root","[data-opencx-root]","[data-opencx-overlay]"],Sl=Ss.join(", ");function yt(e){return e.closest(Sl)!==null}function kn(e,t){let n=document.elementFromPoint(e,t);if(!n)return null;const o=n.getRootNode();typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(n=o.host);let i=n.closest('button, a, input, textarea, select, [role="button"], [role="link"]')??n;for(;i&&!(i instanceof HTMLElement);)i=i.parentElement;if(!(i instanceof HTMLElement)||yt(i))return null;const a=i.tagName.toLowerCase();return a==="html"||a==="body"?null:i}function Nl(e){var i;if(e.selector)try{const a=document.querySelector(e.selector);if(a instanceof HTMLElement&&!yt(a))return a}catch{}const t=(i=e.text)==null?void 0:i.replace(/\s+/g," ").trim().toLowerCase();if(!t)return null;let n=null,o=Number.POSITIVE_INFINITY;const s=Array.from(document.body.querySelectorAll("*"));for(const a of s){const c=a.tagName.toLowerCase();if(c==="script"||c==="style"||c==="noscript"||yt(a))continue;const d=Yn(a).toLowerCase();d.includes(t)&&d.length<=o&&(n=a,o=d.length)}return n}const _l=480,zl=3e3,Xn=new WeakMap;async function El(e){const t=e.getBoundingClientRect();if(t.width<1||t.height<1)return null;const n=Math.min(2,Math.max(.5,_l/Math.max(t.width,t.height))),o=la.toJpeg(e,{quality:.85,pixelRatio:n,backgroundColor:"#ffffff",filter:i=>!(i instanceof Element)||!yt(i)}),s=new Promise(i=>setTimeout(()=>i(null),zl));try{return await Promise.race([o,s])}catch{return null}}function Il(e,t){Xn.set(e,El(t))}const Ns=new WeakMap;function Al(e,t){const n=Xn.get(e);if(!n)return;const o=n.then(s=>{const i=s?Pl(s,"page-mark.jpg"):null;return i?t(i):null}).catch(()=>null).then(s=>(s&&(e.snapshotUrl=s),s));Ns.set(e,o)}async function Tl(e,t){if(e.snapshotUrl)return e.snapshotUrl;const n=Ns.get(e);if(!n)return null;const o=new Promise(s=>setTimeout(()=>s(null),t));return Promise.race([n,o])}function Pl(e,t){const n=/^data:([^;,]+);base64,([\s\S]*)$/.exec(e);if(!n)return null;const[,o,s]=n;if(!o||s===void 0)return null;try{const i=atob(s),a=new Uint8Array(i.length);for(let c=0;c<i.length;c++)a[c]=i.charCodeAt(c);return new File([a],t,{type:o})}catch{return null}}function Ml(e){return Xn.get(e)}function _s(e){const[t,n]=l.useState(null);return l.useEffect(()=>{var s;if(n(null),!e)return;let o=!1;return(s=Ml(e))==null||s.then(i=>{!o&&i&&n(i)}),()=>{o=!0}},[e]),t}function Rl({element:e}){const t=_s(e.mark)??e.snapshotUrl??null,n=e.note??e.name;return t?r.jsx(Cs,{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 $l=150,Ol=40,Dl=3;function Ll(e,t){const n=new Map;for(const i of e){const a=n.get(i.type);a?a.push(i):n.set(i.type,[i])}const o=[],s=[];for(const[i,a]of Array.from(n)){const c=t.has(i)?a:a.slice(0,Dl);o.push({type:i,items:c,hidden:a.length-c.length}),s.push(...c)}return{groups:o,visible:s}}function Fl(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 Wl(e,t){const n=t.trim().toLowerCase();if(!n)return[...e];const o=s=>{var a;const i=s.title.toLowerCase();return i.startsWith(n)?0:i.includes(n)?1:(a=s.description)!=null&&a.toLowerCase().includes(n)?2:-1};return e.map((s,i)=>({item:s,index:i,rank:o(s)})).filter(s=>s.rank>=0).sort((s,i)=>s.rank-i.rank||s.index-i.index).map(s=>s.item)}const wt=e=>`@${e.title}`;function Fr(e,t){const n=[];for(const o of t){const s=wt(o);let i=0;for(;;){const a=e.indexOf(s,i);if(a===-1)break;n.push({start:a,end:a+s.length}),i=a+s.length}}return n}function Hl({text:e,setText:t,inputRef:n}){const{mentions:o}=C.useConfig(),{widgetCtx:s}=C.useWidget(),i=o==null?void 0:o.items,a=o==null?void 0:o.search,c=l.useMemo(()=>{if(a)return a;if(i)return P=>Wl(i,P)},[a,i]),d=!!c&&s.features.pageContext,{mentions:u,setMentions:p}=C.useComposerDraft(),[h,f]=l.useState(null),[m,k]=l.useState([]),[w,y]=l.useState(()=>new Set),[v,z]=l.useState(0),[g,S]=l.useState(!1),{groups:j,visible:b}=l.useMemo(()=>Ll(m,w),[w,m]);l.useEffect(()=>{p(P=>{const L=P.filter(O=>e.includes(wt(O)));return L.length===P.length?P:L})},[e,p]);const E=l.useCallback((P="nearest")=>{if(!d)return;const L=n.current;let O=(L==null?void 0:L.selectionStart)??e.length;if(L&&L.selectionStart===L.selectionEnd){const q=Fr(e,u).find(F=>O>F.start&&O<F.end);q&&(O=P==="forward"?q.end:P==="backward"||O-q.start<q.end-O?q.start:q.end,L.setSelectionRange(O,O))}const V=Fl(e,O),U=V&&u.some(q=>e.startsWith(wt(q),V.start))?null:V;f(q=>(q==null?void 0:q.start)===(U==null?void 0:U.start)&&(q==null?void 0:q.query)===(U==null?void 0:U.query)?q:U)},[d,n,u,e]);l.useEffect(()=>E(),[E]);const $=l.useRef(0);l.useEffect(()=>{if(!h||!c){k([]),S(!1);return}const P=++$.current;S(!0);const L=setTimeout(()=>{Promise.resolve().then(()=>c(h.query)).then(O=>{P===$.current&&(k(O.slice(0,Ol)),y(new Set),z(0),S(!1))},O=>{P===$.current&&(ee.log.warn("mentions search failed",O),k([]),S(!1))})},$l);return()=>clearTimeout(L)},[h,c]);const M=l.useCallback(()=>{$.current+=1,f(null),k([]),S(!1)},[]),N=l.useCallback(P=>{if(!h)return;const L=h.start+1+h.query.length,O=`${wt(P)} `,V=e.slice(0,h.start)+O+e.slice(L);t(V),p(q=>q.some(F=>F.type===P.type&&F.id===P.id)?q:[...q,P]),M();const U=h.start+O.length;requestAnimationFrame(()=>{const q=n.current;q&&(q.focus(),q.setSelectionRange(U,U))})},[h,M,n,t,p,e]),_=l.useCallback(P=>{y(L=>new Set(L).add(P))},[]),W=d&&h!==null,B=l.useCallback(P=>{const L=n.current;if(d&&L&&L.selectionStart===L.selectionEnd&&(P.key==="Backspace"||P.key==="Delete")){const O=L.selectionStart,V=Fr(e,u).find(U=>P.key==="Backspace"?U.end===O:U.start===O);if(V){P.preventDefault();const U=e[V.end]===" "?V.end+1:V.end;return t(e.slice(0,V.start)+e.slice(U)),requestAnimationFrame(()=>L.setSelectionRange(V.start,V.start)),!0}}if(!W)return!1;if(P.key==="Escape")return P.preventDefault(),M(),!0;if(b.length===0)return!1;if(P.key==="ArrowDown")return P.preventDefault(),z(O=>(O+1)%b.length),!0;if(P.key==="ArrowUp")return P.preventDefault(),z(O=>(O-1+b.length)%b.length),!0;if(P.key==="Enter"||P.key==="Tab"){P.preventDefault();const O=b[v];return O&&N(O),!0}return!1},[M,d,v,n,W,N,u,t,e,b]),I=l.useCallback(()=>{p([]),M()},[M,p]);return l.useMemo(()=>({picked:u,isOpen:W,anchorIndex:(h==null?void 0:h.start)??null,preview:(o==null?void 0:o.preview)!==!1,groups:j,visible:b,expandGroup:_,searching:g,highlighted:v,setHighlighted:z,pick:N,onKeyDown:B,onCaretMove:E,reset:I}),[u,W,h,o==null?void 0:o.preview,j,b,_,g,v,N,B,E,I])}function zs({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(wt))).sort((c,d)=>d.length-c.length),s=[];let i=e,a=0;for(;i.length>0;){let c=-1,d="";for(const u of o){const p=i.indexOf(u);p!==-1&&(c===-1||p<c)&&(c=p,d=u)}if(c===-1){s.push(i);break}c>0&&s.push(i.slice(0,c)),s.push(l.createElement("span",{...D("chat/mention"),key:a++,className:A("rounded-sm px-0.5 -mx-0.5",n)},d)),i=i.slice(c+d.length)}return r.jsx(r.Fragment,{children:s})}function Bl({message:e,isFirstInGroup:t,isLastInGroup:n,isAloneInGroup:o}){var s;return r.jsxs("div",{...D("chat/user_msg/root"),className:"w-5/6 flex flex-col items-end gap-1",children:[e.markedElements&&e.markedElements.length>0&&r.jsx("div",{...D("chat/user_msg/marked_elements"),className:"w-full flex gap-1 flex-wrap justify-end",children:e.markedElements.map((i,a)=>r.jsx(Rl,{element:i},`${i.name}-${a}`))}),e.attachments&&e.attachments.length>0&&r.jsx("div",{className:"w-full flex gap-1 flex-wrap justify-end",children:(s=e.attachments)==null?void 0:s.map(i=>r.jsx(es,{attachment:i},i.id))}),e.content.length>0&&r.jsx("div",{...D("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(zs,{text:e.content,mentions:e.mentions,tokenClassName:"bg-primary-foreground/20 font-medium"})})]})}function ql({messages:e}){return r.jsxs("div",{...D("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(Bl,{message:t,isFirstInGroup:n===0,isLastInGroup:n===o.length-1,isAloneInGroup:o.length===1},t.id)),r.jsx(ms,{messages:e,containerClassName:"ms-auto"})]})}function Cn({groups:e,pendingReply:t=!1}){const{humanAgent:n}=C.useConfig(),o=C.useBot();return r.jsx(r.Fragment,{children:e.map((s,i)=>{var c,d;const a=(c=s[0])==null?void 0:c.id;if(!a)return null;if(jn(s))return r.jsx(ql,{messages:s},a);if(dl(s))return r.jsx(Wt,{messages:s,agent:o,actions:!t||i!==e.length-1},a);if(ul(s)){const u=(d=s[0])==null?void 0:d.agent;return r.jsx(Wt,{messages:s,agent:u?{...u,name:(n==null?void 0:n.name)||u.name||"",avatarUrl:(n==null?void 0:n.avatarUrl)||u.avatarUrl||null}:n?{isAi:!1,id:null,name:n.name||"",avatarUrl:n.avatarUrl||null}:void 0},a)}return null})})}const Ul=150;function Vl({scrollHeight:e,scrollTop:t,clientHeight:n},o=Ul){return e-t-n<o}function Yl(e){const t=l.useRef(null),n=l.useRef(!0),[o,s]=l.useState(!1),i=l.useCallback(()=>{const c=t.current,d=c?Vl(c):!0;n.current=d,s(!d)},[]),a=l.useCallback(()=>{const c=t.current;c&&(c.scrollTo({top:c.scrollHeight,behavior:"smooth"}),n.current=!0,s(!1))},[]);return l.useEffect(()=>{if(!n.current)return;const c=setTimeout(()=>{const d=t.current;d&&(d.scrollTop=d.scrollHeight)},0);return()=>clearTimeout(c)},e),{containerRef:t,handleScroll:i,showScrollDown:o,scrollToBottom:a}}function Xl(){const{messagesState:{messages:e}}=C.useMessages(),{isStreaming:t,liveItems:n,turnSources:o,liveTurnKey:s,turnFailed:i,retryFailedTurn:a}=C.useAgentChatUi(),{componentStore:c}=C.useWidget(),{t:d}=Z(),u=C.useBot(),{sessionState:{session:p}}=C.useSessions(),h=l.useMemo(()=>C.sessionPlan({liveItems:n,turnSources:o}),[n,o]),f=l.useMemo(()=>bs(e),[e]),m=l.useMemo(()=>{const $=new Map;for(const M of o)for(const N of M.rowIds)$.set(N,M);return $},[o]),k=l.useMemo(()=>{for(let $=f.length-1;$>=0;$-=1){const M=f[$];if(M&&jn(M))return $}return-1},[f]),w=n.length>0,{nodes:y,renderedSourceKeys:v}=l.useMemo(()=>{const $=[],M=new Set;return f.forEach((N,_)=>{var P;const W=(P=N[0])==null?void 0:P.id;if(!W)return;if(jn(N)){$.push(r.jsx(Cn,{groups:[N]},W));return}let B=[];const I=()=>{var O;const L=(O=B[0])==null?void 0:O.id;L&&$.push(r.jsx(Cn,{groups:[B]},L)),B=[]};for(const L of N){const O=m.get(L.id);O?(I(),M.has(O.key)||(M.add(O.key),$.push(r.jsx($r,{turn:{active:!1,items:O.items},agent:u,timestamp:L.timestamp},O.key)))):w&&_>k||B.push(L)}I()}),{nodes:$,renderedSourceKeys:M}},[f,m,w,k,u]),z=s!==null&&n.length>0&&!v.has(s),g=c.getComponent("loading"),{containerRef:S,handleScroll:j,showScrollDown:b,scrollToBottom:E}=Yl([e,n]);return r.jsxs(r.Fragment,{children:[r.jsxs("div",{...D("chat/msgs/wrapper"),className:"relative flex flex-1 flex-col min-h-0",children:[r.jsxs("div",{...D("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(js,{}),r.jsx(ws,{}),r.jsx(ks,{}),[...y,...z?[r.jsx($r,{turn:{active:t,items:n},agent:u},s)]:[]],t&&n.length===0&&g&&r.jsx(g,{agent:u}),i&&!t&&r.jsxs("div",{...D("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",{...D("chat/turn_failed/retry"),type:"button",onClick:a,className:"font-medium underline underline-offset-2 hover:opacity-80",children:d("turn_failed_retry")})]}),r.jsx(xs,{}),r.jsx(gs,{})]}),r.jsx(H.AnimatePresence,{children:b&&l.createElement(H.motion.button,{...D("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:E,"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"}))})]}),h&&h.length>0&&r.jsx("div",{...D("chat/session-plan"),className:"shrink-0 px-4 pb-2",children:r.jsx(ll,{plan:h,active:t},(p==null?void 0:p.id)??"new-session")})]})}function Gl(){const e=Me(),{activeMode:t,Component:n}=C.useModes(),{sendMessage:o}=C.useMessages(),{createStateCheckpoint:s}=C.useSessions(),[i,a]=l.useState(!1),c=async d=>{try{a(!0),await o(d)}catch(u){ee.log.error("mode component send failed",u)}finally{a(!1)}};return!t||!n?null:r.jsx(n,{...e,mode:t,createStateCheckpoint:s,sendMessage:c,isSendingMessage:i})}const we=l.forwardRef((e,t)=>{var n,o,s;return r.jsx(te,{...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}}})});we.displayName="MotionDiv__VerticalReveal";const Kl=[{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 Zl(){const{isSmallScreen:e}=Ee(),{t}=Z(),{submitCsat:n,isCsatRequested:o,isCsatSubmitted:s,submittedScore:i,submittedFeedback:a}=C.useCsat(),[c,d]=l.useState(null),[u,p]=l.useState(null),h=m=>{d(k=>k===m?null:m)},f=()=>{c&&n({score:c,feedback:u||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(H.AnimatePresence,{mode:"wait",children:o&&!c?r.jsx(we,{children:r.jsx("p",{className:"text-sm text-muted-foreground text-center pt-2",children:t("csat_title")})},"csat-requested-title"):s?r.jsx(we,{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:Kl.map(m=>r.jsx(G,{variant:m.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",m.value===c&&"opacity-100",s&&m.value!==i&&"opacity-0 size-0",s&&m.value===i&&"opacity-100 size-fit text-4xl"),onClick:o?()=>h(m.value):void 0,children:m.emoji},m.value))}),r.jsx(H.AnimatePresence,{mode:"wait",children:(c||i)&&r.jsx(we,{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?a||"":u||"",onChange:o?m=>p(m.target.value):void 0,readOnly:s,placeholder:o?t("csat_feedback_placeholder"):void 0}),r.jsx(G,{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 Jl(){const{t:e}=Z(),t=[e("i_need_more_help"),e("this_was_helpful")];return r.jsx("div",{...D("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(Un,{suggestion:n,className:"flex-1"},n))})}function Wr(){const{sessionState:e}=C.useSessions(),{chatFooterItems:t}=C.useConfig(),n=!!e.session&&!e.session.isOpened,o=!n;return r.jsx(H.AnimatePresence,{mode:"wait",children:t==null?void 0:t.map((s,i)=>s.showWhenSessionIsOpen===!1&&o||s.showWhenSessionIsResolved===!1&&n?null:r.jsx(we,{children:r.jsx("div",{className:"pb-2 text-center text-xs",children:r.jsx(Xt,{children:s.message})})},`${s.message}-${i}`))})}function Ht(){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 Ql({sessionId:e,active:t}){var a;const{widgetCtx:n,config:o}=C.useWidget(),[s,i]=l.useState(null);return l.useEffect(()=>{var p;if(i(null),!t||((p=o.capabilities)==null?void 0:p.connections)===!1)return;const c=new AbortController;let d;const u=async()=>{try{const h=await n.api.listElicitations(e,c.signal);c.signal.aborted||i(h[0]??null)}catch{i(h=>h&&h.expiresAt>Date.now()?h:null)}c.signal.aborted||(d=setTimeout(u,1500))};return u(),()=>{c.abort(),clearTimeout(d)}},[n,e,t,(a=o.capabilities)==null?void 0:a.connections]),r.jsxs(r.Fragment,{children:[" ",s&&s.expiresAt>Date.now()?r.jsx(ed,{request:s,onAnswer:async c=>{await n.api.answerElicitation(e,s.id,c),i(null)}},s.id):null]})}function ed({request:e,onAnswer:t}){var p,h;const[n,o]=l.useState(!1),[s,i]=l.useState(""),a=async f=>{if(!n){o(!0),i("");try{await t(f)}catch(m){i(m instanceof Error?m.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"&&((h=e.form.requestedSchema.required)==null?void 0:h.includes("approve")),u="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){a({action:"accept",content:{approve:!0}});return}const m=new FormData(f.currentTarget),k={};for(const[w,y]of Object.entries(c)){const v=m.get(w);if(y.type==="boolean")k[w]=v==="on";else if(y.type==="array"){const z=m.getAll(w).filter(g=>typeof g=="string");if(y.minItems!==void 0&&z.length<y.minItems){i(`${y.title??w}: select at least ${y.minItems} options.`);return}if(y.maxItems!==void 0&&z.length>y.maxItems){i(`${y.title??w}: select no more than ${y.maxItems} options.`);return}k[w]=z}else typeof v=="string"&&v!==""&&(k[w]=y.type==="number"||y.type==="integer"?Number(v):v)}a({action:"accept",content:k})},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(Ht,{})}),r.jsx("p",{className:"min-w-0 flex-1 text-sm leading-5 break-words",children:e.form.message}),r.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-foreground/50",wobble:!1,"aria-label":"Cancel request",disabled:n,onClick:()=>void a({action:"cancel"}),children:r.jsx(T.X,{className:"size-3.5"})})]}),!d&&r.jsx("fieldset",{disabled:n,className:"space-y-3",children:Object.entries(c).map(([f,m])=>{var v,z,g,S,j;const k=`${e.id}-${f}`,w=m.oneOf??((v=m.enum)==null?void 0:v.map(b=>({const:b,title:b})))??((z=m.items)==null?void 0:z.anyOf)??((S=(g=m.items)==null?void 0:g.enum)==null?void 0:S.map(b=>({const:b,title:b}))),y=(j=e.form.requestedSchema.required)==null?void 0:j.includes(f);return r.jsxs("div",{children:[r.jsxs("label",{htmlFor:k,className:"block text-sm font-medium mb-1",children:[m.title??f,y?" *":""]}),m.description&&r.jsx("p",{className:"text-sm text-foreground/60 mb-1",children:m.description}),m.type==="boolean"?r.jsx("input",{id:k,name:f,type:"checkbox",defaultChecked:m.default===!0,className:"size-5 accent-current"}):w?r.jsxs("select",{id:k,name:f,multiple:m.type==="array",required:y,className:u,defaultValue:typeof m.default=="string"||Array.isArray(m.default)?m.default:m.type==="array"?[]:"",children:[m.type!=="array"&&r.jsx("option",{value:"",children:"Choose…"}),w.map(b=>r.jsx("option",{value:b.const,children:b.title??b.const},b.const))]}):r.jsx("input",{id:k,name:f,className:u,type:m.type==="number"||m.type==="integer"?"number":m.format==="email"?"email":m.format==="uri"?"url":m.format==="date"?"date":"text",required:y,min:m.minimum,max:m.maximum,step:m.type==="integer"?1:"any",minLength:m.minLength,maxLength:m.maxLength,defaultValue:typeof m.default=="string"||typeof m.default=="number"?m.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(G,{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(G,{type:"button",size:"sm",variant:"secondary",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,title:"Allow the same tool, account and inputs. Reset anytime.",onClick:()=>void a({action:"accept",content:{approve:!0},remember:!0}),children:"Always allow"}),r.jsx(G,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-lg px-2.5 py-0 text-xs",wobble:!1,disabled:n,onClick:()=>void a({action:"decline"}),children:"Decline"})]})]})}function td({request:e}){const t=C.useConnection(e),{phase:n,authorization:o,continuation:s,error:i}=t,c=n==="loading"||n==="waiting"||s!==null,d=n==="connected"||n==="external",u=(i==null?void 0:i.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",h=s?s==="renew"?"Requesting…":"Continuing…":n==="loading"?"Preparing…":n==="waiting"?"Waiting…":u?"Reconnect":i?"Try again":d?"Continue":"Connect",f=()=>i||d?t.retryContinuation():t.start();return r.jsxs("section",{"aria-label":`Connect ${e.name}`,"data-component":"chat/connection",className:"min-w-0 rounded-2xl border border-foreground/10 bg-background p-2 text-foreground",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-secondary p-2",children:r.jsx(Ht,{})}),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(G,{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(G,{type:"button",wobble:!1,size:"sm",className:"h-7 shrink-0 px-2.5 text-xs order-2",disabled:c,"aria-busy":c,title:u?"Your access expired. Connect again to continue.":void 0,onClick:()=>void f(),children:[c&&r.jsx(Vn,{}),h]}),r.jsx(G,{type:"button",wobble:!1,variant:"ghost",size:"fit",className:"h-7 shrink-0 px-2 text-xs order-1","aria-label":"Not now",title:"Not now",disabled:s!==null,onClick:()=>void t.cancel(),children:"Not now"})]}),i&&r.jsx("p",{role:"alert",className:"px-1 pt-2 text-sm text-pretty text-destructive",children:i})]})}const nd=["box","circle","arrow","bracket","underline","highlight","strike-through","crossed-off"];function rd(e){const t=new Map,n=[];for(const o of e){let s;for(const i of o.elements){const a=i.selector||i.name,c=t.get(a);if(c){s??(s=c);continue}const d={...i};t.set(a,d),n.push(d),s??(s=d)}o.note&&s&&(s.note=s.note?`${s.note}
|
|
111
|
-
${o.note}`:o.note)}return n}const Hr=20,od=4e3;function Sn(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 sd(e,t,n,o){const s=document.createElement("div");s.setAttribute("data-opencx-overlay",""),Object.assign(s.style,{position:"absolute",left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`,pointerEvents:"none",zIndex:String(o)}),document.documentElement.appendChild(s);let i=null;try{i=co.annotate(s,{type:t,color:n,strokeWidth:2,wobble:.8}),i.show(),Sn(s,o)}catch(u){ee.log.warn("page mark: could not be drawn",u)}let a=!1;const c=()=>{if(!a){a=!0;try{i==null||i.remove()}catch{}s.remove()}},d=u=>{if(!a)try{i==null||i.update(u),Sn(s,o)}catch{}};return{setRect(u){a||(s.style.left=`${u.x}px`,s.style.top=`${u.y}px`,s.style.width=`${u.width}px`,s.style.height=`${u.height}px`,d({}))},setShape(u){d({type:u})},undraw(){if(!a){if(!i)return c();try{i.hide(),i.finished.then(c)}catch{return c()}window.setTimeout(c,od)}},remove:c}}const Lt="rounded-full size-8 flex items-center justify-center p-0 overflow-hidden",Es="bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground",ad=A("rounded-full p-0.5 text-muted-foreground","hover:bg-muted hover:text-foreground","transition-transform active:scale-90");function id({entity:e,onRemove:t}){const{t:n}=Z();return r.jsxs("div",{...D("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:ad,onClick:t,children:r.jsx(T.XIcon,{className:"size-3"})})]})}const cd=x.z.object({type:x.z.string().min(1),id:x.z.string().min(1),title:x.z.string().min(1),meta:x.z.record(x.z.string(),x.z.unknown()).optional()});function ld(){var o;const e=C.useConfig(),{widgetCtx:t}=C.useWidget();if(C.useHostLocation(),!t.features.pageContext)return null;const n=cd.safeParse((o=ee.resolveConfigContext(e))==null?void 0:o.entity);return n.success?n.data:null}function Rt(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 Gn({cssVars:e,primaryColor:t,contentZIndex:n}){return{accent:t,surface:Rt(e,"--opencx-background"),foreground:Rt(e,"--opencx-foreground"),mutedForeground:Rt(e,"--opencx-muted-foreground"),border:Rt(e,"--opencx-border"),inkZIndex:n-2,chromeZIndex:n-1,editorZIndex:n+1}}function dd({isActive:e,draft:t,hover:n,onShapeChange:o,onAttach:s,onDiscard:i}){const a=Gt(),{theme:c,cssVars:d}=he(),{t:u}=Z();if(!a||!e)return null;const p=Gn({cssVars:d,primaryColor:c.primaryColor,contentZIndex:c.widgetContentContainer.zIndex}),{accent:h}=p;return kt.createPortal(r.jsxs("div",{"data-opencx-overlay":"",style:{pointerEvents:"none"},children:[r.jsx("style",{children:`
|
|
112
|
-
@keyframes opencx-mark-hint-in {
|
|
113
|
-
from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
|
|
114
|
-
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
115
|
-
}
|
|
116
|
-
@keyframes opencx-mark-editor-in {
|
|
117
|
-
from { opacity: 0; transform: translateY(4px); }
|
|
118
|
-
to { opacity: 1; transform: translateY(0); }
|
|
119
|
-
}
|
|
120
|
-
@keyframes opencx-mark-frame-in {
|
|
121
|
-
from { opacity: 0; transform: scale(1.015); }
|
|
122
|
-
to { opacity: 1; transform: scale(1); }
|
|
123
|
-
}
|
|
124
|
-
@media (prefers-reduced-motion: reduce) {
|
|
125
|
-
[data-opencx-mark-hint], [data-opencx-mark-editor],
|
|
126
|
-
[data-opencx-mark-frame] { animation: none !important; }
|
|
127
|
-
}
|
|
128
|
-
`}),!t&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{"data-opencx-mark-hint":"",style:{position:"fixed",top:16,left:"50%",transform:"translateX(-50%)",zIndex: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:h}}),u("page_mark_hint"),r.jsx(ud,{theme:p,children:u("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 ${h}, 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,m],k)=>r.jsx("div",{style:{position:"fixed",left:f-5,top:m-5,width:10,height:10,borderRadius:999,background:p.surface,boxShadow:`0 0 0 2px ${h}, 0 2px 6px color-mix(in srgb, ${p.foreground} 25%, transparent)`,zIndex:p.chromeZIndex,pointerEvents:"none"}},k)),r.jsx(hd,{draft:t,theme:p,onShapeChange:o,onAttach:s,onDiscard:i},"editor")]})]}),a)}function ud({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 pd={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"})]})},md={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 hd({draft:e,theme:t,onShapeChange:n,onAttach:o,onDiscard:s}){const{accent:i}=t,{t:a}=Z(),[c,d]=l.useState(""),u=l.useRef(null);l.useEffect(()=>{var v;(v=u.current)==null||v.focus()},[]);const p=320,h=window.innerWidth,f=window.innerHeight,{rect:m}=e,k=Math.max(12,Math.min(m.x+m.width/2-p/2,h-p-12)),w=m.y+m.height+16,y=w+120>f?Math.max(12,m.y-116):w;return r.jsxs("div",{"data-opencx-mark-editor":"",style:{position:"fixed",left:k,top:y,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:nd.map(v=>{const z=v===e.shape,g=a(md[v]);return r.jsx("button",{type:"button",title:g,"aria-label":a("page_mark_shape_aria",{shape:g}),"aria-pressed":z,onClick:()=>n(v),style:{border:"none",cursor:"pointer",borderRadius:8,width:32,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:z?i:"transparent",color:z?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:pd[v]})},v)})}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("input",{ref:u,value:c,onChange:v=>d(v.target.value),onKeyDown:v=>{v.key==="Enter"?(v.preventDefault(),o(c)):v.key==="Escape"&&(v.preventDefault(),v.stopPropagation(),s())},placeholder:a("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":a("page_mark_attach"),onClick:()=>o(c),style:{border:"none",borderRadius:999,width:26,height:26,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:i,color:t.surface,font:"600 13px/1 system-ui, sans-serif",cursor:"pointer"},children:"↑"})]})]})}function fd({mark:e,onRemove:t}){var c;const{t:n}=Z(),o=_s(e),s=e.note??((c=e.elements[0])==null?void 0:c.name)??n("page_mark_region"),i=n("page_mark_remove",{label:s}),a=e.elements.map(d=>d.name).join(", ");return o?r.jsx(Cs,{...D("chat/input_box/page_mark_pill"),className:"group",shape:"tile",src:o,alt:s,title:a,note:e.note,children:r.jsx("button",{type:"button","aria-label":i,className:A("absolute top-1 end-1 rounded-full p-0.5","bg-foreground/60 text-background backdrop-blur-sm","opacity-0 group-hover:opacity-100 focus-visible:opacity-100","transition-opacity active:scale-90"),onClick:t,children:r.jsx(T.XIcon,{className:"size-3"})})}):r.jsxs("div",{...D("chat/input_box/page_mark_pill"),title:a,className:A("group relative size-12 shrink-0 overflow-hidden","flex items-center justify-center","rounded-2xl bg-background ring-1 ring-border"),children:[r.jsx(T.PenLineIcon,{className:"size-4 shrink-0 text-primary"}),r.jsx("span",{className:A("absolute inset-x-0 bottom-0 truncate px-1.5 py-0.5","bg-gradient-to-t from-foreground/70 to-foreground/0","text-[10px] font-medium leading-tight text-background"),children:s}),r.jsx("button",{type:"button","aria-label":i,className:A("absolute top-1 end-1 rounded-full p-0.5","bg-foreground/60 text-background backdrop-blur-sm","opacity-0 group-hover:opacity-100 focus-visible:opacity-100","transition-opacity active:scale-90"),onClick:t,children:r.jsx(T.XIcon,{className:"size-3"})})]})}const Te={"close-panel":"Escape","toggle-fullscreen":"Mod+Shift+F",send:"Enter","send-alt":"Mod+Enter","history-prev":"ArrowUp","history-next":"ArrowDown"};function Is(){return typeof navigator>"u"?!1:/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent)}function Je(e,t,n=Is()){const o=t.split("+"),s=o.at(-1)??"",i=new Set(o.slice(0,-1)),a=i.has("Cmd")||i.has("Mod")&&n,c=i.has("Ctrl")||i.has("Mod")&&!n;return e.metaKey!==a||e.ctrlKey!==c||e.altKey!==i.has("Alt")||e.shiftKey!==i.has("Shift")?!1:e.key.toLowerCase()===s.toLowerCase()}const gd={Mod:"⌘",Cmd:"⌘",Ctrl:"⌃",Alt:"⌥",Shift:"⇧"},xd={Escape:"Esc",Enter:"⏎",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→"};function Kn(e,t=Is()){const n=e.split("+"),o=n.at(-1)??"",s=n.slice(0,-1),i=xd[o]??(o.length===1?o.toUpperCase():o);return t?[...s.map(a=>gd[a]??a),i].join(""):[...s.map(a=>a==="Mod"?"Ctrl":a),i].join("+")}const bd=25*1024*1024,As={"application/pdf":[".pdf"],...hc,...fc},wd={"text/*":[".txt"],"image/*":[".png",".jpg",".jpeg",".gif"],...As},yd={"image/png":[".png"],"image/jpeg":[".jpg",".jpeg"],"image/gif":[".gif"],"image/webp":[".webp"],...As};function vd({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 jd({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"}):Ko({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 kd({file:{status:e,file:t,error:n},onCancel:o}){const{t:s}=Z(),[i,a]=l.useState(null);return l.useEffect(()=>{if(!t.type.startsWith("image/"))return;const c=new FileReader;return c.onload=()=>a(c.result),c.onerror=()=>ee.log.error("failed to read file for preview"),c.readAsDataURL(t),()=>c.abort()},[t]),r.jsx(_e,{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(vd,{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(jd,{file:t,fileContent:i})]})})}function Cd(){const{queuedUserMessages:e,removeQueued:t,stop:n}=C.useAgentChatUi(),{messagesState:{messages:o}}=C.useMessages(),{t:s}=Z(),i=l.useMemo(()=>e.filter(a=>!o.some(c=>c.id===a.id)),[e,o]);return r.jsx(H.AnimatePresence,{children:i.length>0&&r.jsx(we,{children:r.jsxs("div",{...D("chat/queued_sends/root"),className:"mb-1 rounded-2xl border border-muted-foreground/15 bg-background shadow-sm",children:[r.jsxs("div",{...D("chat/queued_sends/header"),className:"flex items-center justify-between px-3 pt-2 pb-1",children:[r.jsx("span",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s("queued_label",{count:i.length})}),r.jsx("button",{type:"button",...D("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",{...D("chat/queued_sends/list"),className:"flex flex-col pb-1",children:i.map(a=>r.jsxs("li",{...D("chat/queued_sends/item"),className:"group flex items-center gap-2 px-3 py-1",children:[r.jsx("button",{type:"button",title:s("send_queued_now"),onClick:n,className:"min-w-0 flex-1 truncate text-start text-xs text-foreground/80 hover:text-foreground",children:a.content}),r.jsx("button",{type:"button",...D("chat/queued_sends/remove"),"aria-label":s("remove_queued_message"),onClick:()=>t(a.id),className:"shrink-0 rounded-md p-0.5 text-muted-foreground/60 transition-colors hover:text-foreground hover:bg-muted",children:r.jsx(T.XIcon,{className:"size-3.5"})})]},a.id))})]})},"queued-sends-pill")})}function Sd({levelRef:e}){const t=l.useRef(null);return l.useEffect(()=>{let n=0;const o=new ee.DictationLevelSmoother({attack:.2,release:.07}),s=[],i=()=>{var c;const a=(c=t.current)==null?void 0:c.children;if(a){const d=o.next(e.current);for(let u=0;u<a.length;u++){const p=a[u];if(p instanceof HTMLElement){const h=.75+.25*Math.sin(Date.now()/260+u*1.7),f=`scaleY(${Math.max(.25,Math.min(1,d*1.8*h)).toFixed(3)})`;s[u]!==f&&(p.style.transform=f,s[u]=f)}}}n=requestAnimationFrame(i)};return n=requestAnimationFrame(i),()=>cancelAnimationFrame(n)},[e]),r.jsx("div",{ref:t,"aria-hidden":"true",className:"flex h-3.5 shrink-0 items-center gap-[3px]",children:[0,1,2,3].map(n=>r.jsx("span",{className:"h-full w-[3px] origin-center scale-y-50 rounded-full bg-current transition-transform duration-100 ease-out"},n))})}function Nd({status:e,levelRef:t,onToggle:n,onPrewarm:o}){const{t:s}=Z(),i=e==="listening",a=e==="connecting",c=s(i||a?"stop_dictation":"dictate");return r.jsx(_e,{side:"top",align:"start",content:c,children:r.jsxs(G,{...D("chat/input_box/dictate_btn"),onClick:n,onPointerDown:d=>d.preventDefault(),onPointerEnter:o,onFocus:o,"aria-pressed":i||a,"aria-label":c,size:"fit",variant:"ghost",className:A("relative",Lt,i&&Es),children:[a&&r.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0.5 animate-spin rounded-full border-[1.5px] border-current/20 border-t-current"}),r.jsx(H.AnimatePresence,{mode:"wait",children:i?r.jsx(te,{distance:0,children:r.jsx(Sd,{levelRef:t})},"bars"):r.jsx(te,{distance:0,children:r.jsx(T.MicIcon,{className:A("size-4",a&&"opacity-60")})},"mic")})]})})}function _d(e,t){const n=e.ownerDocument;if(!n.defaultView)return null;const s=n.createElement("div");Ts(e,s),Object.assign(s.style,{position:"absolute",visibility:"hidden",top:"0",left:"-9999px",height:"auto",overflow:"hidden",whiteSpace:"pre-wrap",overflowWrap:"break-word",width:`${e.clientWidth}px`}),s.textContent=e.value.slice(0,t);const i=n.createElement("span");i.textContent="",s.appendChild(i),n.body.appendChild(s);const a=i.offsetLeft,c=i.offsetTop-e.scrollTop;return s.remove(),{left:a,top:c}}function Ts(e,t){const n=e.ownerDocument.defaultView;if(!n)return;const o=n.getComputedStyle(e);for(const s of zd)t.style.setProperty(s,o.getPropertyValue(s))}const zd=["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"],Ed=300,Ps=260,Id=8,Ms="rounded-xl border border-border bg-background shadow-lg";function Ad({anchorRef:e,inputRef:t,anchorIndex:n,preview:o,groups:s,visible:i,searching:a,highlighted:c,onHighlight:d,onPick:u,onExpand:p}){var z;const{t:h}=Z(),[f,m]=l.useState(null);l.useLayoutEffect(()=>{const g=e.current;if(!g)return;const S=g.ownerDocument.defaultView,j=()=>{const E=g.getBoundingClientRect(),$=(S==null?void 0:S.innerWidth)??E.right,M=Math.min(Ed,Math.max(0,$-16)),N=t.current,_=N&&n!==null?_d(N,n):null,W=N==null?void 0:N.getBoundingClientRect(),B=_&&W?W.left+_.left:E.left+8,I=Math.max(8,Math.min(B,$-8-M)),P=_&&W?W.top+_.top-4:E.top-4;m({left:I,width:M,top:P,detailBeside:o&&I+M+Id+Ps<=$-8})};j(),S==null||S.addEventListener("resize",j);const b=typeof ResizeObserver>"u"?null:new ResizeObserver(j);return b==null||b.observe(g),()=>{S==null||S.removeEventListener("resize",j),b==null||b.disconnect()}},[n,e,t,o,i.length]);const k=(z=e.current)==null?void 0:z.closest("[data-version]");if(!k||!f||i.length===0&&a)return null;const w=i[c],y=w!=null&&w.description?w:null;let v=-1;return kt.createPortal(r.jsxs("div",{...D("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",Ms),children:r.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-1",children:i.length===0?r.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:h("mentions_empty")}):s.map(g=>l.createElement("div",{...D("chat/input_box/mention_picker/group"),key:g.type,role:"group","aria-label":g.type},r.jsx("div",{className:"px-2 pb-0.5 pt-1.5 text-xs capitalize text-muted-foreground",children:g.type}),g.items.map(S=>{const j=++v;return l.createElement("button",{...D("chat/input_box/mention_picker/option"),key:`${S.type}:${S.id}`,type:"button",role:"option","aria-selected":j===c,onMouseDown:b=>b.preventDefault(),onMouseEnter:()=>d(j),onClick:()=>u(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(Rs,{item:S}),r.jsx("span",{className:"min-w-0 flex-1 truncate text-foreground",children:S.title}))}),g.hidden>0&&r.jsx("button",{...D("chat/input_box/mention_picker/more"),type:"button",onMouseDown:S=>S.preventDefault(),onClick:()=>p(g.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:h("json_see_more",{count:String(g.hidden)})})))})}),y&&f.detailBeside&&r.jsx(Td,{item:y})]}),k)}function Td({item:e}){return r.jsxs("div",{...D("chat/input_box/mention_picker/detail"),style:{width:Ps},className:A("flex gap-3 p-3",Ms),children:[r.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted",children:r.jsx(Rs,{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 Rs({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(lt,{name:e.iconName??"AtSign",className:A("size-3.5 shrink-0 text-primary",t)})}const $s=l.createContext(null);function Pd({children:e}){const[t,n]=l.useState([]),[o,s]=l.useState(!1),i=l.useRef(new Map),a=l.useCallback(h=>{s(h)},[]),c=l.useCallback((h,f)=>{i.current.set(h,f),n(m=>[...m,h])},[]),d=l.useCallback(h=>{const f=i.current.get(h);f&&(i.current.delete(h),f.undraw()),n(m=>m.filter(k=>k!==h))},[]),u=l.useCallback(()=>{const h=Array.from(i.current.values());i.current.clear();for(const f of h)f.undraw();n([])},[]);l.useEffect(()=>()=>{i.current.forEach(h=>h.remove()),i.current.clear()},[]);const p=l.useMemo(()=>({marks:t,isArmed:o,setArmed:a,attach:c,detach:d,detachAll:u}),[t,o,a,c,d,u]);return r.jsx($s.Provider,{value:p,children:e})}function Zn(){const e=l.useContext($s);if(!e)throw new Error("usePageMarks must be used within a PageMarksProvider");return e}const Md="data-opencx-mark-cursor",Rd=5,$t=4,Ot=6,an={width:160,height:100},$d=10,Od=Ss.map(e=>`:not(${e}):not(${e} *)`).join(""),Dd=e=>e==="nw"||e==="se"?"nwse-resize":"nesw-resize";function Ld({enabled:e,onAttach:t,uploadSnapshot:n,accentColor:o,zIndex:s}){const{isArmed:i,setArmed:a,attach:c}=Zn(),d=e&&i,[u,p]=l.useState(null),[h,f]=l.useState(null),m=l.useRef(null),k=l.useRef(null);k.current=u;const w=l.useCallback(()=>{var j;(j=m.current)==null||j.undraw(),m.current=null,p(null)},[]),y=l.useCallback(()=>a(!1),[a]),v=l.useCallback(j=>{var b;p(E=>E&&{...E,rect:j}),(b=m.current)==null||b.setRect({x:j.x+window.scrollX,y:j.y+window.scrollY,width:j.width,height:j.height})},[]),z=l.useCallback(j=>{var b;p(E=>E&&{...E,shape:j}),(b=m.current)==null||b.setShape(j)},[]);l.useEffect(()=>{!e&&i&&a(!1)},[e,i,a]),l.useEffect(()=>{if(!d)return;const j=document.createElement("style");j.setAttribute(Md,"");let b=null;const E=R=>{R!==b&&(b=R,j.textContent=`*${Od} { cursor: ${R} !important; }`)};E("crosshair"),document.head.appendChild(j);let $=null;const M=R=>R.target instanceof Element&&yt(R.target),N=R=>M(R)?!1:(R.preventDefault(),R.stopPropagation(),R.stopImmediatePropagation(),!0),_=(R,X,J)=>{const se=[["nw",R.x,R.y],["ne",R.x+R.width,R.y],["sw",R.x,R.y+R.height],["se",R.x+R.width,R.y+R.height]];for(const[oe,ue,pe]of se)if(Math.hypot(X-ue,J-pe)<=$d)return oe;return null},W=(R,X,J)=>X>=R.x&&X<=R.x+R.width&&J>=R.y&&J<=R.y+R.height,B=(R,X)=>{var ue;const J=kn(R,X),se=Lr(J?(()=>{const pe=J.getBoundingClientRect();return{x:pe.left-Ot,y:pe.top-Ot,width:pe.width+Ot*2,height:pe.height+Ot*2}})():{x:R-an.width/2,y:X-an.height/2,...an}),oe=((ue=k.current)==null?void 0:ue.shape)??"box";f(null),m.current=sd({x:se.x+window.scrollX,y:se.y+window.scrollY,width:se.width,height:se.height},oe,o,s),p({rect:se,shape:oe})},I=R=>{var se;if(!N(R)||R.button!==0)return;const X=k.current;if(!X){B(R.clientX,R.clientY);return}const J=_(X.rect,R.clientX,R.clientY);if(J){$={kind:"resize",corner:J};return}if(W(X.rect,R.clientX,R.clientY)){$={kind:"move",grabX:R.clientX-X.rect.x,grabY:R.clientY-X.rect.y};return}(se=m.current)==null||se.undraw(),m.current=null,B(R.clientX,R.clientY)};let P=null,L=0;const O=R=>{if(!N(R))return;const X=k.current;if(!X){E("crosshair");const de=kn(R.clientX,R.clientY);if(!de){P=null,f(null);return}de!==P&&(P=de,L+=1),f({rect:Lr(jl(de)),key:L});return}if(!$){const de=_(X.rect,R.clientX,R.clientY);E(de?Dd(de):W(X.rect,R.clientX,R.clientY)?"move":"crosshair");return}const{rect:J}=X;if($.kind==="move"){v({...J,x:R.clientX-$.grabX,y:R.clientY-$.grabY});return}const se=$.corner.includes("w")?J.x+J.width:J.x,oe=$.corner.includes("n")?J.y+J.height:J.y,ue=Math.min(se,R.clientX),pe=Math.max(se,R.clientX),ye=Math.min(oe,R.clientY),ve=Math.max(oe,R.clientY);v({x:ue,y:ye,width:Math.max(Hr,pe-ue),height:Math.max(Hr,ve-ye)})},V=R=>{N(R)&&($=null)},U=R=>{M(R)||N(R),$=null},q=R=>{N(R)},F=R=>{var X;if(R.key==="Escape"){if(R.preventDefault(),R.stopPropagation(),$=null,k.current){(X=m.current)==null||X.undraw(),m.current=null,p(null),E("crosshair");return}a(!1)}};let K=window.scrollX,ne=window.scrollY;const re=()=>{f(null);const R=window.scrollX-K,X=window.scrollY-ne;K=window.scrollX,ne=window.scrollY,!(R===0&&X===0)&&p(J=>J&&{...J,rect:{...J.rect,x:J.rect.x-R,y:J.rect.y-X}})};return document.addEventListener("pointerdown",I,!0),document.addEventListener("pointermove",O,!0),document.addEventListener("pointerup",V,!0),document.addEventListener("pointercancel",U,!0),document.addEventListener("click",q,!0),document.addEventListener("keydown",F,!0),document.addEventListener("scroll",re,!0),()=>{j.remove(),document.removeEventListener("pointerdown",I,!0),document.removeEventListener("pointermove",O,!0),document.removeEventListener("pointerup",V,!0),document.removeEventListener("pointercancel",U,!0),document.removeEventListener("click",q,!0),document.removeEventListener("keydown",F,!0),document.removeEventListener("scroll",re,!0),f(null)}},[d,o,s,v,a]),l.useEffect(()=>{!d&&k.current&&w()},[d,w]),l.useEffect(()=>()=>{var j;(j=m.current)==null||j.remove(),m.current=null},[]);const g=l.useCallback(j=>{if(!e)return;const b=k.current,E=m.current;if(!b||!E)return;const $=j.trim(),M=Fd(b.rect),N={shape:b.shape,...$?{note:$}:{},pageUrl:window.location.href,rect:b.rect,elements:M.map(Cl)};M[0]&&(Il(N,M[0]),n&&Al(N,n)),m.current=null,p(null),a(!1),c(N,E),t==null||t(N)},[c,e,t,a,n]),S=l.useCallback(()=>{e&&a(!i)},[e,i,a]);return{isActive:d,draft:u,hover:h,setShape:z,attach:g,dropDraft:w,disarm:y,toggle:S}}function Fd(e){const t=new Set,n=(o,s)=>{const i=kn(o,s);i&&t.add(i)};n(e.x+e.width/2,e.y+e.height/2);for(let o=0;o<=$t;o++)for(let s=0;s<=$t;s++)n(e.x+e.width*o/$t,e.y+e.height*s/$t);return Array.from(t).slice(0,Rd)}function Wd({enabled:e,inputRef:t}){const{widgetCtx:n}=C.useWidget(),{theme:o,cssVars:s}=he(),i=Gn({cssVars:s,primaryColor:o.primaryColor,contentZIndex:o.widgetContentContainer.zIndex}),{marks:a,detach:c}=Zn(),d=l.useCallback(()=>{var h;(h=t.current)==null||h.focus()},[t]),u=l.useCallback(async h=>{try{const{fileUrl:f}=await n.api.uploadFile({file:h,abortSignal:new AbortController().signal});return f??null}catch(f){return ee.log.warn("page mark snapshot upload failed",f),null}},[n.api]),p=Ld({enabled:e,onAttach:d,uploadSnapshot:u,accentColor:i.accent,zIndex:i.inkZIndex});return{marks:a,detach:c,marking:p}}function Hd({inputText:e,setInputText:t,inputRef:n,getSentTextHistory:o}){const s=l.useRef(null),i=l.useRef(""),a=()=>{const h=n.current;h&&(h.classList.remove("opencx-input-recall"),h.offsetWidth,h.classList.add("opencx-input-recall"))},c=(h,{animate:f=!0}={})=>{t(h),f&&a(),requestAnimationFrame(()=>{var m;return(m=n.current)==null?void 0:m.setSelectionRange(h.length,h.length)})};return{onKeyDown:h=>{if(Je(h,Te["history-prev"])){const f=o();if(f.length===0)return!1;const m=s.current;if(m===null){const k=n.current;if(!((k==null?void 0:k.selectionStart)===0&&(k==null?void 0:k.selectionEnd)===0)&&e!=="")return!1;i.current=e,s.current=f.length-1}else{if(m===0)return!1;s.current=m-1}return h.preventDefault(),c(f[s.current],{animate:!h.repeat}),!0}if(Je(h,Te["history-next"])){const f=s.current;if(f===null)return!1;h.preventDefault();const m=o();return f>=m.length-1?(s.current=null,c(i.current,{animate:!h.repeat}),i.current=""):(s.current=f+1,c(m[s.current],{animate:!h.repeat})),!0}return!1},onEdit:()=>{s.current=null},onSent:()=>{s.current=null,i.current=""}}}const Br="max-h-16 [field-sizing:content] w-full px-2";function Os({trailingActions:e,placeholder:t,hideAttachTools:n}={}){var It;const{isSmallScreen:o}=Ee(),s=l.useRef(null),i=l.useRef(null),a=l.useRef(null),c=l.useRef(!0),{sendMessage:d,rememberSentText:u,getSentTextHistory:p}=C.useMessages(),{widgetCtx:h,componentStore:f}=C.useWidget(),{attachments:m,pageContext:k}=h.features,{isStreaming:w,stop:y,queuedUserMessages:v,pendingClarification:z,pendingConnection:g}=C.useAgentChatUi(),{sessionState:S}=C.useSessions(),{t:j}=Z(),{text:b,setText:E,clearSubmitted:$}=C.useComposerDraft(),M=ld(),N=Hl({text:b,setText:E,inputRef:s}),_=N.picked.length>0;l.useLayoutEffect(()=>{const Y=s.current,ie=a.current;!Y||!ie||Ts(Y,ie)},[_,b]);const[W,B]=l.useState(!1),I=M?`${M.type}:${M.id}`:"";l.useEffect(()=>{B(!1)},[I]);const[P,L]=l.useState(null),O=l.useRef(b);O.current=b;const V=l.useRef(()=>{}),U=C.useDictation({getValue:()=>O.current,setValue:Y=>{O.current=Y,E(Y)},onSend:()=>V.current()});l.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]);const q=Hd({inputText:b,setInputText:E,inputRef:s,getSentTextHistory:p}),F=k&&!o,K=F&&n!==!0,{marks:ne,detach:re,marking:R}=Wd({enabled:K,inputRef:s}),{allFiles:X,handleCancelUpload:J,appendFiles:se,isUploading:oe,successFiles:ue}=C.useUploadFiles(),pe=!!((It=S.session)!=null&&It.isHandedOff),{isAwaitingBotReply:ye}=C.useIsAwaitingBotReply(),ve=h.messageCtx.blocksSendWhileAwaitingReply&&ye,de=Y=>{m&&(L(null),se(Y))},Re=M!==null&&!W,$e=X.length>0||ne.length>0,Ie=!b.trim()&&ue.length===0&&ne.length===0,xe=w&&Ie,Qe=xe&&v.length>0,Ue=oe||ve||Ie,le=()=>{if(U.stop(),ve||Ie||oe)return;const Y=b,ie=[...ne],ut=[...ue],pt=X.map(De=>De.id);Promise.all(ie.map(De=>Tl(De,Bd))).then(()=>Oe({submittedText:Y,submittedMarks:ie,submittedFiles:ut,submittedFileIds:pt}))},Oe=({submittedText:Y,submittedMarks:ie,submittedFiles:ut,submittedFileIds:pt})=>{const De=Y.trim()||(ie.length>0?qd(ie)??j("page_mark_default_message"):"");let At=!1;const Ye=N.picked;d({content:De,withPageEntity:!W,mentions:Ye.length>0?Ye:void 0,attachments:ut.flatMap(fe=>fe.fileUrl?[{url:fe.fileUrl,type:fe.file.type,name:fe.file.name,id:fe.id,size:fe.file.size}]:[]),clientContext:ie.length>0?{page_marks:ie,picked_elements:rd(ie)}:void 0,onAccepted:()=>{if(At)return;At=!0,u(De),ie.forEach(mt=>re(mt)),pt.forEach(mt=>J(mt));const fe=$();c.current&&(q.onSent(),B(!1),fe&&N.reset())}}).catch(fe=>{ee.log.error("failed to send message",fe)})},{getRootProps:et,getInputProps:me,open:Ve}=da.useDropzone({onDrop:de,noClick:!0,disabled:!m,onDropRejected(){L(j("file_rejected"))},maxSize:bd,accept:pe?wd:yd}),Kt=Y=>{const ie=Y.clipboardData;ie&&ie.files.length>0&&de(Array.from(ie.files))};V.current=le;const Et=f.getComponent("agent_chat_questions");return!g&&z&&Et?r.jsx("div",{...D("chat/input_box/root"),className:"p-2 relative space-y-1",children:r.jsx(Et,{request:z})}):r.jsxs("div",{...D("chat/input_box/root"),className:"p-2 relative space-y-1",...et({ref:i}),children:[S.session&&r.jsx(Ql,{sessionId:S.session.id,active:w||ye},S.session.id),g&&r.jsx(td,{request:g},g.request_id),r.jsx("input",{...me()}),N.isOpen&&r.jsx(Ad,{anchorRef:i,inputRef:s,anchorIndex:N.anchorIndex,preview:N.preview,groups:N.groups,visible:N.visible,searching:N.searching,highlighted:N.highlighted,onHighlight:N.setHighlighted,onPick:N.pick,onExpand:N.expandGroup}),K&&r.jsx(dd,{isActive:R.isActive,draft:R.draft,hover:R.hover,onShapeChange:R.setShape,onAttach:R.attach,onDiscard:R.dropDraft}),r.jsx(Cd,{}),P&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:P}),U.error&&r.jsx("p",{role:"alert",className:"px-2 text-xs text-destructive",children:U.error==="microphone"?j("dictation_mic_blocked"):j("dictation_unavailable")}),r.jsxs("div",{...D("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",Re?"bg-muted":"bg-transparent"),children:[r.jsx(H.AnimatePresence,{children:Re&&r.jsx(we,{children:r.jsx("div",{...D("chat/input_box/page_context_container"),className:"flex items-center gap-1 flex-wrap ps-3 pe-1 py-1",children:r.jsx(H.AnimatePresence,{mode:"popLayout",children:M&&!W&&r.jsx(te,{snapExit:!0,children:r.jsx(id,{entity:M,onRemove:()=>B(!0)})},"page-entity")})})},"attached-context")}),r.jsxs("div",{...D("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",{...D("chat/input_box/textarea_and_attachments_container"),className:"flex flex-col gap-2",children:[$e&&r.jsx("div",{...D("chat/input_box/attachments_container"),className:"flex items-center gap-1 overflow-x-auto",children:r.jsxs(H.AnimatePresence,{mode:"popLayout",children:[X.map(Y=>r.jsx(te,{snapExit:!0,children:r.jsx(kd,{onCancel:()=>J(Y.id),file:Y})},Y.id)),ne.map((Y,ie)=>r.jsx(te,{snapExit:!0,children:r.jsx(fd,{mark:Y,onRemove:()=>re(Y)})},`mark-${ie}-${Y.note??""}`))]})}),r.jsxs("div",{className:"relative",children:[_&&r.jsx("div",{ref:a,"aria-hidden":!0,className:A(Br,"pointer-events-none absolute inset-0 overflow-hidden","whitespace-pre-wrap break-words text-foreground",!$e&&"pt-1",o?"text-[16px]":"text-sm"),children:r.jsx(zs,{text:b,mentions:N.picked,tokenClassName:"bg-primary/10 text-primary"})}),r.jsx("textarea",{...D("chat/input_box/textarea"),onPaste:Kt,ref:s,id:"chat-input",value:b,rows:3,className:A(Br,"relative resize-none",!$e&&"pt-1","bg-transparent outline-none","placeholder:text-muted-foreground",_&&"text-transparent caret-foreground",o?"text-[16px]":"text-sm"),onScroll:Y=>{a.current&&(a.current.scrollTop=Y.currentTarget.scrollTop)},onChange:Y=>{q.onEdit(),E(Y.target.value)},onClick:()=>N.onCaretMove("nearest"),onKeyUp:Y=>{Y.key==="ArrowRight"||Y.key==="ArrowDown"?N.onCaretMove("forward"):Y.key==="ArrowLeft"||Y.key==="ArrowUp"?N.onCaretMove("backward"):(Y.key==="Home"||Y.key==="End")&&N.onCaretMove("nearest")},onKeyDown:Y=>{if(!Y.nativeEvent.isComposing&&!N.onKeyDown(Y)){if(Je(Y,Te.send)||Je(Y,Te["send-alt"])){Y.preventDefault(),Qe?y():le();return}if(Y.key==="Escape"&&R.isActive){R.disarm();return}q.onKeyDown(Y)}},placeholder:t??j("write_a_message_placeholder")})]})]}),r.jsxs("div",{className:"gap-2 flex justify-between",children:[r.jsx("div",{className:"flex items-center gap-1",children:!n&&r.jsxs(r.Fragment,{children:[m&&r.jsx(_e,{side:"top",align:"start",content:j("attach_files"),children:r.jsx(G,{onClick:Ve,"aria-label":j("attach_files"),size:"fit",variant:"ghost",className:Lt,children:r.jsx(H.AnimatePresence,{mode:"wait",children:ve?r.jsx(te,{distance:0,children:r.jsx(T.PaperclipIcon,{className:"size-4 opacity-50"})},"paper-clip-disabled"):r.jsx(te,{distance:0,children:r.jsx(T.PaperclipIcon,{className:"size-4"})},"paper-clip")})})}),U.enabled&&r.jsx(Nd,{status:U.status,levelRef:U.levelRef,onToggle:U.toggle,onPrewarm:U.prewarm}),F&&r.jsx(_e,{side:"top",align:"start",content:R.isActive?j("mark_page_active"):j("mark_page"),children:r.jsx(G,{...D("chat/input_box/page_mark_btn"),onClick:R.toggle,"aria-label":R.isActive?j("mark_page_active"):j("mark_page"),size:"fit",variant:"ghost",className:A(Lt,R.isActive&&Es),children:r.jsx(T.MousePointerClickIcon,{className:"size-4"})})})]})}),r.jsxs("div",{className:"flex items-center gap-1",children:[e,r.jsx(_e,{content:j(xe?"stop_response":"send_message"),shortcut:xe?void 0:Kn(Te.send),side:"top",align:"end",children:r.jsx(G,{size:"fit",onClick:xe?y:le,"aria-label":j(xe?"stop_response":"send_message"),disabled:!xe&&Ue,className:Lt,children:r.jsx(H.AnimatePresence,{mode:"wait",children:xe?r.jsx(te,{snapExit:!0,distance:0,children:r.jsx(T.SquareIcon,{className:"size-3 fill-current"})},"stop"):!w&&(ve||oe)?r.jsx(te,{snapExit:!0,distance:0,children:r.jsx(T.CircleDashed,{className:"size-4 animate-spin animate-iteration-infinite"})},"loading"):r.jsx(te,{snapExit:!0,distance:0,children:r.jsx(T.ArrowUpIcon,{className:"size-4"})},"send")})})})]})]})]})]})]})}const Bd=1500;function qd(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 qr(){const{widgetCtx:e}=C.useWidget(),{router:t}=C.useConfig(),{canCreateNewSession:n}=C.useSessions(),{toSessionsScreen:o}=C.useWidgetRouter(),{t:s}=Z();return r.jsx(r.Fragment,{children:n||t!=null&&t.chatScreenOnly?r.jsx(G,{onClick:e.resetChat,className:"rounded-2xl w-full",children:s("new_conversation")}):r.jsx(G,{onClick:o,className:"rounded-2xl w-full",children:s("back_to_conversations")})})}function Ud(){const{t:e}=Z(),{isCsatRequested:t,isCsatSubmitted:n}=C.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(H.AnimatePresence,{mode:"wait",children:t||n?r.jsxs(we,{children:[r.jsx(Zl,{}),r.jsx(H.AnimatePresence,{mode:"wait",children:n&&r.jsx(we,{children:r.jsx(qr,{})},"new-conv-or-back-to-convs-button")})]},"csat"):r.jsxs(we,{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(qr,{})]},"session-closed")})})})}function Vd(){var a;const{initialQuestions:e,initialQuestionsPosition:t,thisWasHelpfulOrNot:n}=C.useConfig(),{sessionState:o}=C.useSessions(),{messagesState:s}=C.useMessages(),i=s.messages.length===0;return r.jsx("footer",{children:r.jsx(H.AnimatePresence,{mode:"wait",children:o.session&&!((a=o.session)!=null&&a.isOpened)?r.jsxs(we,{children:[r.jsx(Ud,{}),r.jsx(Wr,{})]},"session-closed"):r.jsxs(we,{children:[s.lastAIResMightSolveUserIssue&&(n==null?void 0:n.enabled)!==!1&&r.jsx(Jl,{}),i&&e&&t!=="below-initial-messages"&&r.jsx("div",{className:"flex items-center flex-row justify-end gap-2 flex-wrap px-2",children:e==null?void 0:e.map((c,d)=>r.jsx(Un,{suggestion:c},`${c}-${d}`))}),r.jsx(Os,{}),r.jsx(Wr,{})]},"chat-input")})})}function Yd(){const{messagesState:{messages:e}}=C.useMessages(),{isAwaitingBotReply:t}=C.useIsAwaitingBotReply(),{componentStore:n}=C.useWidget(),o=C.useBot(),s=l.useMemo(()=>bs(e),[e]),i=e.at(-1),a=i==null?void 0:i.id,c=i==null?void 0:i.type,d=l.useRef(a),[u,p]=l.useState(!1),h=t&&!u;l.useEffect(()=>{const w=d.current!==a;if(d.current=a,!t||c!=="AI"){p(!1);return}if(!w)return;p(!0);const y=setTimeout(()=>p(!1),600);return()=>clearTimeout(y)},[t,a,c]);const f=n.getComponent("loading"),m=l.useRef(null);function k(){setTimeout(()=>{const w=m.current;w&&(w.scrollTop=w.scrollHeight)},0)}return l.useEffect(()=>{k()},[e,h]),r.jsxs("div",{...D("chat/msgs/root"),ref:m,className:"max-h-full scroll-smooth relative flex-1 py-2 px-4 flex flex-col gap-2 overflow-auto",children:[r.jsx(js,{}),r.jsx(ws,{}),r.jsx(ks,{}),r.jsx(Cn,{groups:s,pendingReply:t}),h&&f&&r.jsx(f,{agent:o}),r.jsx(xs,{}),r.jsx(gs,{})]})}function Xd(){const{messagesState:{isInitialFetchLoading:e}}=C.useMessages(),{widgetCtx:t}=C.useWidget(),n=t.streaming,{sessionState:{session:o}}=C.useSessions(),{isCanvasOpen:s}=nl(),{theme:i}=he();Fn({width:s?i.screens.chat.withCanvas.width:i.screens.chat.width,height:s?i.screens.chat.withCanvas.height:i.screens.chat.height});const a=l.useRef((o==null?void 0:o.id)||"chat").current;return r.jsx("div",{...D("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(us,{}),r.jsx(H.AnimatePresence,{mode:"wait",children:e?r.jsx(te,{className:"flex flex-col items-center justify-center w-full flex-1",children:r.jsx(ps,{})},"loading"):r.jsxs(te,{className:"flex items-start h-full flex-1 overflow-auto",snapExit:!0,children:[r.jsxs("div",{...D("chat/main/root"),className:A("flex flex-col h-full overflow-auto transition-all",s?"w-2/5":"w-full"),style:{transitionTimingFunction:i.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:i.screens.chat.withCanvas.transitionDuration},children:[n?r.jsx(Xl,{}):r.jsx(Yd,{}),r.jsx(Vd,{})]}),r.jsx("div",{...D("chat/canvas/root"),className:A("h-full overflow-auto transition-all",s?"w-3/5":"w-0"),style:{transitionTimingFunction:i.screens.chat.withCanvas.transitionTimingFunction,transitionDuration:i.screens.chat.withCanvas.transitionDuration},children:r.jsx(Gl,{})})]},a)})]})})}function Gd({children:e}){var z;const{widgetCtx:t,config:n}=C.useWidget(),[o,s]=l.useState(!1),[i,a]=l.useState(null),[c,d]=l.useState(""),[u,p]=l.useState([]),[h,f]=l.useState([]),[m,k]=l.useState(!1),[w,y]=l.useState("");l.useEffect(()=>{var S;let g=!1;if(((S=n.capabilities)==null?void 0:S.connections)!==!1)return Promise.all([t.api.listConnections(),t.api.listApprovalPreferences()]).then(([j,b])=>{g||(p(j.filter(E=>E.status!=="not_connected")),f(b))}).catch(()=>{}),()=>{g=!0}},[t,(z=n.capabilities)==null?void 0:z.connections]);const v=async g=>{k(!0),y("");try{await g()}catch{y("Could not save the change. Try again.")}finally{k(!1)}};return o?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(G,{variant:"ghost",size:"icon",className:"size-7","aria-label":i?"Back to connections":"Back to sessions",onClick:()=>i?a(null):s(!1),children:r.jsx(T.ArrowLeft,{className:"size-4"})}),r.jsx("h2",{className:"text-sm font-medium",children:"Connections"})]}),!u.length&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"No connected services."}),!i&&r.jsxs(r.Fragment,{children:[r.jsx("input",{type:"search","aria-label":"Search connections",placeholder:"Search connections",value:c,onChange:g=>d(g.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"}),u.filter(g=>g.name.toLowerCase().includes(c.toLowerCase())).map(g=>r.jsxs("button",{type:"button",onClick:()=>a(g.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(Ht,{})}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block text-sm font-medium",children:g.name}),r.jsx("span",{className:"block text-xs text-muted-foreground",children:g.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(T.ChevronRight,{className:"size-4 text-muted-foreground"})]},g.server_id)),u.length>0&&!u.some(g=>g.name.toLowerCase().includes(c.toLowerCase()))&&r.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No matching connections."})]})]}),u.filter(g=>g.server_id===i).map(g=>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(Ht,{})}),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:g.name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:g.status==="connected"?"Connected":"Reconnect required"})]}),r.jsx(G,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:m,onClick:()=>void v(async()=>{await t.api.disconnectConnection(g.server_id),a(null),p(S=>S.filter(j=>j.server_id!==g.server_id)),f(S=>S.filter(j=>j.serverId!==g.server_id))}),children:"Disconnect"})]}),h.some(S=>S.serverId===g.server_id)?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("h3",{className:"text-xs font-medium",children:["Saved approvals (",h.filter(S=>S.serverId===g.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":`${g.name} saved approvals`,children:h.filter(S=>S.serverId===g.server_id).map(S=>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:S.toolName.replace(/[_-]+/g," ")}),r.jsx("p",{className:"text-xs text-muted-foreground break-words",children:S.message})]}),r.jsx(G,{variant:"secondary",size:"sm",className:"h-7 shrink-0 px-2 text-xs",disabled:m,onClick:()=>void v(async()=>{await t.api.revokeApprovalPreference(S.serverId,S.key),f(j=>j.filter(b=>b.serverId!==S.serverId||b.key!==S.key))}),children:"Remove approval"})]},S.key))})]}):r.jsx("p",{className:"text-xs text-muted-foreground",children:"No saved approvals"})]},g.server_id)),w&&r.jsx("p",{role:"alert",className:"text-xs text-destructive",children:w})]}):r.jsxs(r.Fragment,{children:[r.jsx(us,{}),u.length>0&&r.jsxs(G,{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]})}function Kd({className:e,...t}){return r.jsx("div",{className:A("animate-pulse rounded-md bg-secondary",e),...t})}function Zd({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 Ds({className:e}){const{token:t}=C.useConfig();return r.jsx("div",{className:A("flex items-center justify-center gap-2 p-2 pt-0",e),children:r.jsx(Ae,{children:r.jsxs("a",{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(Zd,{className:"size-3 inline-block"})}),r.jsx("span",{className:"font-semibold",children:"open"})]})]})})})}function Jd({children:e}){return r.jsx("p",{className:"ps-4 text-xs text-muted-foreground/75 uppercase font-semibold tracking-tight",children:e})}function Ur({session:e,className:t}){const{humanAgent:n}=C.useConfig(),o=C.useBot(),{toChatScreen:s}=C.useWidgetRouter(),i=e.assignee.kind==="human"?(n==null?void 0:n.name)||e.assignee.name||"Support Agent":o.name,a=e.assignee.kind==="human"?(n==null?void 0:n.avatarUrl)||e.assignee.avatarUrl||"":o.avatarUrl||o.avatar||"";return r.jsxs(G,{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(H.AnimatePresence,{mode:"wait",children:r.jsx(te,{snapExit:!0,children:r.jsxs(Rn,{className:"size-10",children:[r.jsx($n,{src:a,alt:"Agent Icon"}),r.jsx(On,{children:r.jsx(T.UserRoundIcon,{className:"size-4"})})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx(H.AnimatePresence,{mode:"wait",children:r.jsx(te,{snapExit:!0,children:i},i)}),r.jsx(H.AnimatePresence,{mode:"wait",children:e.lastMessage?r.jsx(te,{snapExit:!0,children:r.jsx(ts,{remarkPlugins:[so],rehypePlugins:[ao],className:"line-clamp-1 overflow-hidden text-ellipsis text-xs text-muted-foreground",children:e.lastMessage})},e.lastMessage||"content"):r.jsx(te,{className:"w-1/2",snapExit:!0,children:r.jsx(Kd,{className:"h-4 w-full"})},"skeleton")}),r.jsx(H.AnimatePresence,{mode:"wait",children:e.customStatus&&r.jsx(te,{className:"mt-1",snapExit:!0,children:r.jsx(vs,{customStatus:e.customStatus})},e.customStatus.id)})]})]}),r.jsx(T.ChevronRightIcon,{className:"size-4 text-muted-foreground shrink-0 rtl:-scale-100"})]})}function Qd(){const{t:e}=Z(),{toChatScreen:t}=C.useWidgetRouter(),{sessionsState:{data:n,isInitialFetchLoading:o},openSessions:s,closedSessions:i,canCreateNewSession:a}=C.useSessions();return r.jsx("div",{...D("sessions/list"),className:"flex-1 flex flex-col overflow-scroll py-2 px-2",children:r.jsx(H.AnimatePresence,{mode:"wait",children:o?r.jsx(te,{className:"flex-1 flex items-center justify-center",children:r.jsx(ps,{})},"loading"):r.jsx(te,{className:"flex-1 flex flex-col gap-2 relative",children:n.length?r.jsxs(r.Fragment,{children:[r.jsxs(H.AnimatePresence,{children:[s.length>0&&r.jsx(te,{fadeIn:"up",delay:.2,className:"space-y-2",snapExit:!0,children:s.map(c=>r.jsx(Ur,{session:c},c.id))},"open-sessions"),i.length>0&&r.jsxs(te,{className:"space-y-2",delay:.2,snapExit:!0,children:[r.jsx(Jd,{children:e("closed_conversations")}),i.map(c=>r.jsx(Ur,{session:c,className:"opacity-50 hover:opacity-100"},c.id))]},"closed-sessions")]}),a&&r.jsx("div",{className:"mt-auto w-full rounded-3xl sticky bottom-0 outline outline-8 outline-background bg-background",children:l.createElement(G,{...D("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")})}),l.createElement(G,{...D("sessions/new_conversation_btn"),size:"lg",key:"new-session",className:"w-full",onClick:()=>t()},e("new_conversation"))]})},"sessions")})})}function eu(){const{theme:e}=he();return Fn({width:e.screens.sessions.width,height:e.screens.sessions.height}),r.jsx("div",{...D("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(Gd,{children:r.jsx(Qd,{})}),r.jsx(Ds,{})]})})}const Ft=qe.forwardRef(({className:e,type:t,...n},o)=>{const{isSmallScreen:s}=Ee();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})});Ft.displayName="Input";function tu(){const{contentIframeRef:e}=C.useWidget(),{inline:t}=C.useConfig(),n=l.useRef(null);return l.useEffect(()=>{const o=e==null?void 0:e.current;if(o&&n.current){const s=n.current;let i;const a=new ResizeObserver(()=>{i=requestAnimationFrame(()=>{const c=s.offsetHeight;o.style.setProperty("--opencx-widget-height",t?"100%":`${c.toFixed(1)}px`)})});return a.observe(s),()=>{cancelAnimationFrame(i),a.unobserve(s)}}},[e,t]),{observedElementRef:n}}const nu=x.z.object({name:x.z.string().min(2),email:x.z.string().email()});function ru(){var v,z,g,S,j,b,E,$;const{widgetCtx:{org:e}}=C.useWidget(),{setIsOpen:t}=C.useWidgetTrigger(),{createUnverifiedContact:n}=C.useContact(),{isSmallScreen:o}=Ee(),s=C.useConfig(),{theme:i}=he(),{t:a}=Z(),{observedElementRef:c}=tu();Fn({height:void 0,width:i.screens.welcome.width});const[d,u]=l.useState(((v=s.prefillUserData)==null?void 0:v.name)||""),[p,h]=l.useState(((z=s.prefillUserData)==null?void 0:z.email)||""),f=(s.extraDataCollectionFields||[]).filter(M=>M!=="name"&&M!=="email"&&!!M),[m,k]=l.useState({}),[w,y]=ua(async M=>{M.preventDefault();const N=nu.safeParse({name:d,email:p});N.success&&await n({email:N.data.email,non_verified_name:N.data.name},Object.values(m).filter(Boolean).length?m:void 0)},[d,p,m]);return r.jsx("div",{style:{width:"100vw",maxWidth:"100vw",minHeight:i.screens.welcome.minHeight,height:"100vh",maxHeight:"100vh",overflowY:"auto"},children:r.jsxs("div",{ref:c,className:A("flex flex-col",o&&"h-full","bg-[radial-gradient(ellipse_at_top_left,hsl(var(--opencx-primary)),transparent),radial-gradient(ellipse_at_top_right,hsl(var(--opencx-primary)),transparent)]"),children:[r.jsxs("div",{className:A("flex-1 flex flex-col px-4 py-12 text-start space-y-4 relative z-10","text-primary-foreground"),children:[o&&r.jsx(te,{className:"absolute top-6 end-6",children:r.jsx(G,{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:(g=s.assets)!=null&&g.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:((b=(j=s.textContent)==null?void 0:j.welcomeScreen)==null?void 0:b.title)||a("welcome_screen_title")}),r.jsx("p",{className:"text-sm",children:(($=(E=s.textContent)==null?void 0:E.welcomeScreen)==null?void 0:$.description)||a("welcome_screen_description")})]})]}),r.jsxs("div",{className:A("z-10 m-2 px-2 pt-2 bp-0 space-y-2","bg-[white]","border shadow","rounded-3xl"),children:[r.jsxs("form",{onSubmit:y,className:"space-y-2",children:[r.jsx(Ft,{value:d,onChange:M=>u(M.target.value),required:!0,placeholder:a("your_name_placeholder"),name:"name"}),r.jsx(Ft,{required:!0,value:p,onChange:M=>h(M.target.value),type:"email",placeholder:a("your_email_placeholder"),name:"email"}),f.map(M=>r.jsx(Ft,{value:m[M],onChange:N=>k(_=>({..._,[M]:N.target.value})),placeholder:`${M} (${a("optional")})`},M)),r.jsxs(G,{disabled:w.loading,className:"w-full",size:"lg",children:[w.loading?a("start_chat_button_loading"):a("start_chat_button"),r.jsx(T.SendHorizontal,{className:"size-4 rtl:-scale-100"})]})]}),r.jsx(Ds,{})]})]})})}function Jn(){const{routerState:{screen:e}}=C.useWidgetRouter();return r.jsx("div",{className:"relative bg-background size-full",children:r.jsx(H.AnimatePresence,{mode:"wait",children:(()=>{switch(e){case"welcome":return r.jsx(te,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(ru,{})},e);case"sessions":return r.jsx(te,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(eu,{})},e);case"chat":return r.jsx(te,{fadeIn:"right",className:"size-full",snapExit:!0,children:r.jsx(Xd,{})},e);default:return ee.isExhaustive(e,Jn.name),null}})()})})}const ou=Dn();function Ls(){const{isOpen:e}=C.useWidgetTrigger(),{contentIframeRef:t}=C.useWidget(),{inline:n}=C.useConfig(),{theme:o,computed:s}=he();return r.jsx(H.motion.div,{animate:e?"visible":"hidden",initial:"hidden",style:{transformOrigin:n?void 0:"bottom right"},variants:{hidden:{opacity:0,scale:n?1:.9,y:8,transitionEnd:{display:"none"},transition:ct},visible:{opacity:1,scale:1,y:0,display:"block",height:n?"100%":void 0,transition:{...ct,height:{duration:0}}}},children:r.jsx(io,{ref:t,initialContent:ou,allowFullScreen:!0,title:as,style:{"--opencx-widget-width":s.minWidth,"--opencx-widget-height":s.minHeight,minWidth:s.minWidth,width:"var(--opencx-widget-width)",maxWidth:s.maxWidth,minHeight:s.minHeight,height:"var(--opencx-widget-height)",maxHeight:s.maxHeight,overflow:"hidden",outline:o.widgetContentContainer.outline,outlineColor:o.widgetContentContainer.outlineColor,borderRadius:o.widgetContentContainer.borderRadius,boxShadow:o.widgetContentContainer.boxShadow,transitionProperty:o.widgetContentContainer.transitionProperty,transitionTimingFunction:o.widgetContentContainer.transitionTimingFunction,transitionDuration:o.widgetContentContainer.transitionDuration,boxSizing:"border-box",borderWidth:"0px"},children:r.jsx(Ln,{style:{zIndex:o.widgetContentContainer.zIndex},children:r.jsx(Jn,{})})})})}function su(){const{theme:e,triggerSide:t}=he(),{dir:n}=C.useDocumentDir(),{t:o}=Z(),s=(n==="rtl"?t==="left":t==="right")?"end":"start";return r.jsx(We.Content,{onInteractOutside:i=>i.preventDefault(),forceMount:!0,style:{zIndex:e.widgetContentContainer.zIndex,fontSize:"16px"},side:"top",align:s,"aria-modal":"false","aria-label":o("support_chat_aria_label"),sideOffset:e.widgetContentContainer.offset.side,alignOffset:e.widgetContentContainer.offset.align,avoidCollisions:!1,children:r.jsx(Ls,{})})}function au({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 Fs(){var t;const{accessibility:e}=C.useConfig();return((t=e==null?void 0:e.widgetTriggerButton)==null?void 0:t.label)??"Chat with us"}function Ws(e,t,n){return e({react:l,isOpen:t,setIsOpen:o=>n(o)})}const iu=Dn();function cu(){var a,c;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{assets:n,customComponents:o}=C.useConfig(),{theme:s}=he(),i=Fs();return o!=null&&o.widgetTrigger?Ws(o.widgetTrigger,e,t):r.jsx(io,{initialContent:iu,title:"OpenCX Live Chat Trigger",style:{height:`calc(${s.widgetTrigger.size.button}px + ${it.x*2}px)`,width:`calc(${s.widgetTrigger.size.button}px + ${it.y*2}px)`,fontSize:"16px",position:"fixed",zIndex:s.widgetTrigger.zIndex,right:s.widgetTrigger.offset.right,bottom:s.widgetTrigger.offset.bottom,left:s.widgetTrigger.offset.left,boxSizing:"border-box",borderWidth:"0px",borderRadius:"100%"},children:r.jsx(Ln,{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:r.jsx(We.PopoverTrigger,{"aria-label":i,title:i,className:A("font-sans flex items-center justify-center rounded-full"),style:{height:s.widgetTrigger.size.button,width:s.widgetTrigger.size.button},children:r.jsx(Ae,{children:r.jsx("div",{...D("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(H.AnimatePresence,{mode:"wait",children:e?r.jsx(te,{snapExit:!0,fadeIn:"up",overrides:{initial:{rotate:45},animate:{rotate:0}},children:(a=n==null?void 0:n.widgetTrigger)!=null&&a.closeIcon?r.jsx("img",{src:n.widgetTrigger.closeIcon,alt:"Widget trigger close icon",style:{width:s.widgetTrigger.size.icon,height:s.widgetTrigger.size.icon}}):r.jsx(T.ChevronDownIcon,{style:{width:s.widgetTrigger.size.icon,height:s.widgetTrigger.size.icon}})},"x-icon"):r.jsx(te,{snapExit:!0,overrides:{initial:{rotate:45},animate:{rotate:0}},children:(c=n==null?void 0:n.widgetTrigger)!=null&&c.openIcon?r.jsx("img",{src:n.widgetTrigger.openIcon,alt:"Widget trigger open icon",style:{width:s.widgetTrigger.size.icon,height:s.widgetTrigger.size.icon}}):r.jsx(au,{style:{width:s.widgetTrigger.size.icon,height:s.widgetTrigger.size.icon},className:"mt-0.5 opacity-95"})},"message-icon")})})})})})})}function lu(){const{triggerSide:e}=he();return r.jsx(We.Anchor,{style:{position:"fixed",bottom:0,right:e==="right"?0:void 0,left:e==="left"?0:void 0}})}function Xe(e,t,n){return Math.min(Math.max(e,t),n)}const Nn=16,Ne=16,xt=32,du=44,uu=240,pu=440,Hs=32,mu=280,hu=420,fu=640,gu=48,cn=12,Qn=400,Bs=320,xu=560,bu="#f4f4f5",qs=120,Us=Bs+qs+Ne*3,He={pill:999,input:16,fullscreen:16,sidebar:20,compact:20};function er(e,t){if(e.width<=Us)return Math.max(0,e.width-Ne*2);const n=e.width-qs-Ne*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 Vs(e,t={}){const n=Math.max(0,e.width),o=st(t.maxWidth,pu),s=Math.min(o,st(t.minWidth,mu));return Math.min(n,o,Math.max(s,n-Hs))}function wu(e,t,n={}){const o=Math.max(0,e.height),s=st(n.minHeight,hu),i=st(n.maxHeight,fu,s),a=Math.min(1,st(n.viewportHeightRatio,.65)),c=Math.max(0,o-Math.max(0,t)-gu);return Math.min(i,c,Math.max(s,o*a))}function yu(e){const{layout:t,region:n,sidebarWidth:o,bottomOffset:s,compact:i}=e;return t==="fullscreen"?{width:Math.max(0,n.width-Nn*2),height:Math.max(0,n.height-Nn*2),borderRadius:He.fullscreen}:t==="sidebar"?{width:er(n,o),height:Math.max(0,n.height-Ne*2),borderRadius:He.sidebar}:{width:Vs(n,i),height:wu(n,s,i),borderRadius:st(i==null?void 0:i.borderRadius,He.compact)}}function vu(e){const{isChatOpen:t,layout:n,region:o,sidebarWidth:s,sidebarSide:i,bottomOffset:a}=e,c=t?n:"compact",d=er(o,s),u=c==="fullscreen"?Nn:c==="sidebar"?Ne:a;return{centerX:c==="sidebar"?i==="left"?Ne+d/2:o.width-Ne-d/2:o.width/2,bottom:u}}const je="[data-companion-root]",ju=`
|
|
130
|
-
${je} [data-component="chat/msgs/root"] {
|
|
131
|
-
overflow-x: hidden !important;
|
|
132
|
-
}
|
|
133
|
-
${je} [data-component="chat/agent_msg_group/root"],
|
|
134
|
-
${je} [data-component="chat/agent_msg_group/avatar_and_msgs/root"],
|
|
135
|
-
${je} [data-component="chat/agent_msg_group/avatar_and_msgs/msgs"] {
|
|
136
|
-
min-width: 0 !important;
|
|
137
|
-
max-width: 100% !important;
|
|
138
|
-
}
|
|
139
|
-
${je} [data-component="chat/agent_msg/msg"] {
|
|
140
|
-
background: transparent !important;
|
|
141
|
-
padding: 2px 0 !important;
|
|
142
|
-
border-radius: 0 !important;
|
|
143
|
-
max-width: 100% !important;
|
|
144
|
-
min-width: 0 !important;
|
|
145
|
-
overflow-wrap: break-word !important;
|
|
146
|
-
}
|
|
147
|
-
${je} [data-component="chat/agent_msg/msg"] table {
|
|
148
|
-
display: block;
|
|
149
|
-
max-width: 100%;
|
|
150
|
-
overflow-x: auto;
|
|
151
|
-
border-collapse: collapse;
|
|
152
|
-
}
|
|
153
|
-
${je} [data-component="chat/agent_msg/msg"] th,
|
|
154
|
-
${je} [data-component="chat/agent_msg/msg"] td {
|
|
155
|
-
overflow-wrap: normal;
|
|
156
|
-
word-break: normal;
|
|
157
|
-
white-space: normal;
|
|
158
|
-
vertical-align: top;
|
|
159
|
-
text-align: start;
|
|
160
|
-
padding: 4px 10px 4px 0;
|
|
161
|
-
border-bottom: 1px solid hsl(var(--opencx-border));
|
|
162
|
-
}
|
|
163
|
-
${je} [data-component="chat/agent_msg_group/root/avatar"],
|
|
164
|
-
${je} [data-component="chat/agent_msg_group/avatar_and_msgs/avatar"] {
|
|
165
|
-
display: none !important;
|
|
166
|
-
}
|
|
167
|
-
${je} [data-component="chat/user_msg/msg"] {
|
|
168
|
-
background: hsl(var(--opencx-secondary)) !important;
|
|
169
|
-
color: hsl(var(--opencx-secondary-foreground)) !important;
|
|
170
|
-
padding: 8px 12px !important;
|
|
171
|
-
border-radius: 10px !important;
|
|
172
|
-
}
|
|
173
|
-
`,Ys=l.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 Vr({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 ku({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 Cu({anchored:e,side:t,onSelectSide:n,docked:o,onToggleDock:s}){const{t:i}=Z();return r.jsx(H.motion.div,{...D("companion/layout_picker/sidebar_options"),initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.18,ease:zt},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(Yr,{label:i("companion_sidebar_dock_label"),children:r.jsx(Su,{label:i("companion_sidebar_dock_label"),checked:o,onToggle:s})}),r.jsx(Yr,{label:i("companion_sidebar_side_label"),children:r.jsx(Nu,{label:i("companion_sidebar_side_label"),side:t,onSelect:n})})]})})}function Yr({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 Su({label:e,checked:t,onToggle:n}){return r.jsx("button",{...D("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(H.motion.span,{"aria-hidden":!0,initial:!1,animate:{x:t?12:0},transition:ct,className:"size-3 rounded-full bg-background shadow-sm"})})}function Nu({label:e,side:t,onSelect:n}){const{t:o}=Z(),s=[{value:"left",labelKey:"companion_sidebar_left"},{value:"right",labelKey:"companion_sidebar_right"}];return r.jsx("div",{role:"radiogroup","aria-label":e,className:"flex items-center gap-0.5 rounded-full bg-secondary-foreground/10 p-0.5",children:s.map(({value:i,labelKey:a})=>{const c=i===t;return r.jsxs("button",{...D("companion/layout_picker/sidebar_option"),type:"button",role:"radio","aria-checked":c,"aria-label":o(a),onClick:()=>n(i),className:A("relative flex items-center justify-center rounded-full p-1","transition-colors duration-150","active:scale-[0.97]",c?"text-primary":"text-secondary-foreground/60"),children:[c&&r.jsx(H.motion.span,{"aria-hidden":!0,layoutId:"opencx-sidebar-side-indicator",transition:ct,className:"absolute inset-0 rounded-full bg-background shadow-sm"}),r.jsx("span",{className:"relative",children:r.jsx(ku,{side:i})})]},i)})})}const _u={compact:"companion_layout_floating",sidebar:"companion_layout_sidebar",fullscreen:"companion_layout_fullscreen"};function zu(e){try{return e.matches(":focus-visible")}catch{return!0}}function Eu({current:e,onSelect:t}){const{t:n}=Z(),{allowedLayouts:o,sidebarSide:s,setSidebarSide:i,sidebarMode:a,setSidebarMode:c}=C.useWidgetLayout(),[d,u]=l.useState(!1),p=qt(),h=o.map(v=>({layout:v,label:_u[v]})),f=h.length>=2,m=o.includes("sidebar");if(!f&&!m)return null;const k=m&&(f?p?d:e==="sidebar":!0),w=v=>{v(),e!=="sidebar"&&t("sidebar")},y=r.jsx(H.AnimatePresence,{initial:!1,children:k&&r.jsx(Cu,{anchored:f,side:s,onSelectSide:v=>w(()=>i(v)),docked:a==="docked",onToggleDock:()=>w(()=>c(a==="docked"?"floating":"docked"))})});return r.jsxs(We.Root,{onOpenChange:()=>u(!1),children:[r.jsx(_e,{content:n("companion_layout_label"),side:"bottom",children:r.jsx(We.Trigger,{asChild:!0,children:r.jsx(Ys,{...D("companion/layout_picker/trigger"),label:n("companion_layout_label"),className:"size-7",children:r.jsx(Vr,{layout:e,sidebarSide:s})})})}),r.jsx(We.Content,{...D("companion/layout_picker/menu"),"data-opencx-escape-scope":"",side:"bottom",align:"end",sideOffset:6,collisionPadding:8,onPointerLeave:()=>u(!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:h.map(({layout:v,label:z})=>{const g=v===e,S=n(z),j=v==="sidebar",b=r.jsx(We.Close,{asChild:!0,children:r.jsxs("button",{...D("companion/layout_picker/option"),type:"button","aria-label":S,"aria-pressed":g,"aria-expanded":j?k:void 0,onClick:()=>t(v),onPointerEnter:()=>u(j),onFocus:E=>u(j&&zu(E.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",g?"bg-primary/10 text-primary":"text-secondary-foreground/60 hover:bg-muted hover:text-secondary-foreground"),children:[r.jsx(Vr,{layout:v,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:[b,y]},v):v!=="fullscreen"?r.jsx(l.Fragment,{children:b},v):r.jsx(_e,{content:S,shortcut:Kn(Te["toggle-fullscreen"]),side:"bottom",children:b},v)})}):y})]})}function Iu({layout:e,onSelectLayout:t,onClose:n}){const{t:o}=Z();return r.jsxs("div",{...D("companion/controls/root"),className:"absolute top-2 z-10 flex items-center gap-1",style:{insetInlineEnd:8},children:[r.jsx(Eu,{current:e,onSelect:t}),r.jsx(_e,{content:o("companion_close"),shortcut:Kn(Te["close-panel"]),side:"bottom",children:r.jsx(Ys,{...D("companion/close_btn"),label:o("companion_close"),onClick:n,className:"size-7",children:r.jsx(T.XIcon,{className:"size-4"})})})]})}const Au="[data-opencx-escape-scope]";function Tu(e){var n;const t=e.target;return((n=t==null?void 0:t.closest)==null?void 0:n.call(t,Au))!=null}function Pu(e,{state:t,onToggleFullscreen:n}){e.defaultPrevented||t!=="chat"||Je(e,Te["toggle-fullscreen"])&&(e.preventDefault(),n())}function Mu(e,{state:t,onDismiss:n,onToggleFullscreen:o}){if(!e.defaultPrevented){if(Je(e,Te["close-panel"])){Tu(e)||n();return}t==="chat"&&Je(e,Te["toggle-fullscreen"])&&(e.preventDefault(),o())}}function Ru({panelLayout:e,previousLayout:t,defaultLayout:n,allowedLayouts:o}){if(e!=="fullscreen")return{kind:"close"};const s=[t,n];for(const a of s)if(a!=="fullscreen"&&o.includes(a))return{kind:"layout",layout:a};const i=o.find(a=>a!=="fullscreen");return i?{kind:"layout",layout:i}:{kind:"close"}}const Xr=`
|
|
174
|
-
/* Quick-ask (resting) composer: the stock card is a two-row layout (textarea
|
|
175
|
-
over an attach/send row) wrapped in outer padding. In the companion pill it
|
|
176
|
-
reads as a single quick-ask bar, so drop the outer pad and lay the card out
|
|
177
|
-
on ONE row — textarea flex-fills, attach + send sit inline at the end.
|
|
178
|
-
Scoped to the quick-ask pane only; the full chat panel keeps the stock
|
|
179
|
-
two-row composer. */
|
|
180
|
-
[data-companion-input] [data-component="chat/input_box/root"] {
|
|
181
|
-
padding: 0 !important;
|
|
182
|
-
}
|
|
183
|
-
/* The attached-context tray is a FULL-composer affordance. In the one-row
|
|
184
|
-
quick-ask bar it stacks a second row and paints a second surface inside the
|
|
185
|
-
shell — a grey box with its own padding and radius sitting inside the white
|
|
186
|
-
pill, which is not what the resting bar is. Flatten the tray to a pure
|
|
187
|
-
pass-through here and hide its row; the entity still rides the send, and
|
|
188
|
-
the full chat panel (one rung up) is where you see and remove it. */
|
|
189
|
-
[data-companion-input] [data-component="chat/input_box/attached_context_tray"] {
|
|
190
|
-
padding: 0 !important;
|
|
191
|
-
background: transparent !important;
|
|
192
|
-
/* The root's space-y-1 puts a 4px top margin on the tray (its first sibling
|
|
193
|
-
is the hidden dropzone input); with the outer padding gone that margin
|
|
194
|
-
shows as a strip of shell background above the bar. */
|
|
195
|
-
margin-top: 0 !important;
|
|
196
|
-
}
|
|
197
|
-
[data-companion-input]
|
|
198
|
-
[data-component="chat/input_box/attached_context_tray"]
|
|
199
|
-
> *:not([data-component="chat/input_box/inner_root"]) {
|
|
200
|
-
display: none !important;
|
|
201
|
-
}
|
|
202
|
-
[data-companion-input] [data-component="chat/input_box/inner_root"] {
|
|
203
|
-
flex-direction: row !important;
|
|
204
|
-
align-items: center !important;
|
|
205
|
-
margin-top: 0 !important;
|
|
206
|
-
/* The stock card is rounded-3xl (24px), but the companion shell that frames
|
|
207
|
-
it clips at RADII.input in the resting-input state. A mismatch leaves the
|
|
208
|
-
shell's background token peeking out as a two-tone crescent at each
|
|
209
|
-
corner, so the card takes the shell radius via the custom property set on
|
|
210
|
-
the quick-ask pane — one clean rounded bar. */
|
|
211
|
-
border-radius: var(--opencx-companion-input-radius) !important;
|
|
212
|
-
}
|
|
213
|
-
[data-companion-input] [data-component="chat/input_box/textarea_and_attachments_container"] {
|
|
214
|
-
flex: 1 1 auto !important;
|
|
215
|
-
min-width: 0 !important;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/* Fullscreen reading column: the panel is a full-width window, but message
|
|
219
|
-
text across a 1900px panel wraps at ~200 characters. Cap the conversation
|
|
220
|
-
and composer to one centered column; the header and corner controls stay
|
|
221
|
-
full-width window chrome. The messages keep the cap as PADDING on the
|
|
222
|
-
scroll container so the scrollbar stays at the panel edge; the footer gets
|
|
223
|
-
a real max-width (+16px compensates the input card's own p-2) so the
|
|
224
|
-
composer card's edges land exactly on the message column's edges. */
|
|
225
|
-
[data-companion-root][data-layout="fullscreen"] [data-component="chat/msgs/root"] {
|
|
226
|
-
padding-inline: max(16px, calc((100% - var(--opencx-companion-content-max-width)) / 2)) !important;
|
|
227
|
-
}
|
|
228
|
-
[data-companion-root][data-layout="fullscreen"] [data-component="chat/main/root"] > footer {
|
|
229
|
-
width: 100%;
|
|
230
|
-
max-width: calc(var(--opencx-companion-content-max-width) + 16px);
|
|
231
|
-
margin-inline: auto;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/* Sessions (conversation history) gets the same reading column: cards and the
|
|
235
|
-
sticky new-conversation button stretch edge-to-edge otherwise. Padding (not
|
|
236
|
-
max-width) for the same reason as the messages — the list IS the scroll
|
|
237
|
-
container, so the scrollbar stays at the panel edge. */
|
|
238
|
-
[data-companion-root][data-layout="fullscreen"] [data-component="sessions/list"] {
|
|
239
|
-
padding-inline: max(16px, calc((100% - var(--opencx-companion-content-max-width)) / 2)) !important;
|
|
240
|
-
}
|
|
241
|
-
`;function $u({state:e,layout:t,shellRadius:n,onMinimize:o,onDismiss:s,onToggleFullscreen:i,onSelectLayout:a,onExpand:c,canExpand:d,placeholder:u,hideAttachTools:p,onInputHeightChange:h}){const{companion:f}=C.useConfig(),{t:m}=Z(),k=l.useRef(null),w=l.useRef(null),y=l.useRef(null),v=(f==null?void 0:f.bubbles)===!0?Xr:Xr+ju;return l.useEffect(()=>{var S;const z=(S=k.current)==null?void 0:S.ownerDocument;if(!z)return;function g(j){Mu(j,{state:e,onDismiss:s,onToggleFullscreen:i})}return z.addEventListener("keydown",g),()=>z.removeEventListener("keydown",g)},[s,i,e]),l.useLayoutEffect(()=>{var b;if(e!=="input")return;const z=w.current,g=(b=z==null?void 0:z.ownerDocument.defaultView)==null?void 0:b.ResizeObserver;if(!z||!g)return;const S=()=>h(z.offsetHeight);S();const j=new g(S);return j.observe(z),()=>j.disconnect()},[e,h]),l.useLayoutEffect(()=>{e!=="input"||d||ln(w.current)},[e,d]),l.useLayoutEffect(()=>{var S;if(e!=="chat"||ln(y.current))return;const z=(S=y.current)==null?void 0:S.ownerDocument.defaultView;if(!z)return;const g=z.requestAnimationFrame(()=>ln(y.current));return()=>z.cancelAnimationFrame(g)},[e]),r.jsx(Ln,{overrides:v,rootRef:k,shellRadius:`${n}px`,children:e==="input"?r.jsxs("div",{ref:w,"data-companion-input":!0,style:{position:"absolute",left:0,right:0,bottom:0,"--opencx-companion-input-radius":`${He.input}px`},children:[r.jsx(qc,{children:r.jsx(Os,{hideAttachTools:p,placeholder:u})}),d?r.jsx("button",{type:"button","aria-label":m("companion_expand_chat"),onClick:c,className:"absolute inset-0 z-10 cursor-pointer"}):null]}):r.jsxs("div",{ref:y,"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(Jn,{}),r.jsx(Iu,{layout:t,onSelectLayout:a,onClose:o})]})})}function ln(e){const t=e==null?void 0:e.querySelector("textarea");return t?(t.focus({preventScroll:!0}),!0):!1}function Ou({initialContent:e,style:t,iframeRef:n,children:o}){const[s,i]=l.useState(null),a=l.useCallback(c=>{if(n&&(n.current=c),!c)return;const d=c.contentDocument;d&&(d.open(),d.write(e),d.close(),i(d.body))},[]);return r.jsxs(r.Fragment,{children:[r.jsx("iframe",{ref:a,title:as,style:t,allowFullScreen:!0}),s&&kt.createPortal(o,s)]})}function Du({size:e,headColor:t,eyeColor:n}){const o=l.useRef(null),[s,i]=l.useState(!1),[a,c]=l.useState(!1),d=H.useReducedMotion(),u=H.useMotionValue(0),p=H.useMotionValue(0),h=H.useSpring(u,{stiffness:300,damping:30}),f=H.useSpring(p,{stiffness:300,damping:30}),m=H.useTransform(h,g=>8+g*1.2),k=H.useTransform(f,g=>11.5+g*1.2),w=H.useTransform(h,g=>16+g*1.2),y=H.useTransform(f,g=>11.5+g*1.2),v=l.useCallback(g=>{const S=o.current;if(!S)return;const j=S.getBoundingClientRect(),b=j.left+j.width/2,E=j.top+j.height/2,$=(g.clientX-b)/(j.width*2),M=(g.clientY-E)/(j.height*2),N=Math.min(Math.sqrt($*$+M*M),1),_=Math.atan2(M,$);u.set(Math.cos(_)*N),p.set(Math.sin(_)*N)},[u,p]);l.useEffect(()=>(s&&!d?window.addEventListener("mousemove",v):(u.set(0),p.set(0)),()=>window.removeEventListener("mousemove",v)),[s,v,u,p,d]),l.useEffect(()=>{if(d)return;let g,S;function j(){clearTimeout(g),clearTimeout(S)}function b(){g=setTimeout(()=>{c(!0),S=setTimeout(()=>c(!1),150),b()},1200+Math.random()*1800)}function E(){j(),document.visibilityState==="visible"&&b()}return document.visibilityState==="visible"&&b(),document.addEventListener("visibilitychange",E),()=>{j(),document.removeEventListener("visibilitychange",E)}},[d]);const z=a?.15:1;return r.jsxs("svg",{ref:o,viewBox:"0 0 24 24",style:{width:e,height:e,flexShrink:0,display:"block"},"aria-hidden":!0,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[r.jsx("circle",{cx:12,cy:12,r:11,fill:t}),r.jsx("circle",{cx:8,cy:11.5,r:3.2,fill:n}),r.jsx("circle",{cx:16,cy:11.5,r:3.2,fill:n}),r.jsx(H.motion.circle,{cx:m,cy:k,r:1.4,fill:t,animate:{scaleY:z},style:{originX:"8px",originY:"11.5px"},transition:{duration:.08}}),r.jsx(H.motion.circle,{cx:w,cy:y,r:1.4,fill:t,animate:{scaleY:z},style:{originX:"16px",originY:"11.5px"},transition:{duration:.08}})]})}function Lu({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(Du,{size:n,headColor:t,eyeColor:"hsl(var(--opencx-primary-foreground))"})}function Fu(e){return{initial:!1,animate:{opacity:e?1:0},transition:{...ge,delay:e?.25:0}}}function Wu({visible:e,docked:t,label:n,icon:o,pillBackground:s,dir:i,measureRef:a,activeCount:c=0,countLabel:d,onOpenChats:u,pickerOpen:p=!1,working:h=!1,sessions:f}){const m=H.useReducedMotion();return r.jsxs(H.motion.div,{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",borderRadius:"inherit",overflow:"hidden",pointerEvents:"none",userSelect:"none",background:"hsl(var(--opencx-background))"},...Fu(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:k=>{k.stopPropagation(),u==null||u(k.currentTarget,k.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,h&&r.jsx(H.motion.span,{style:{position:"absolute",inset:-2,display:"flex"},animate:m?void 0:{rotate:360},transition:{duration:1.2,repeat:1/0,ease:"linear"},children:r.jsx(T.LoaderCircleIcon,{size:18})})]})}),r.jsxs("div",{ref:a,dir:i,style:{display:"flex",alignItems:"center",gap:8,height:"100%",width:"max-content",paddingInlineEnd:12,fontFamily:"ui-sans-serif, system-ui, sans-serif"},children:[r.jsx(Lu,{icon:o,pillBackground:s,size:xt}),r.jsx(H.motion.span,{initial:!1,animate:{opacity:t?1:0},transition:{duration:.12,ease:zt},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 Hu({chat:e,number:t,selected:n,interactive:o,onSelect:s,onClose:i,portalTarget:a}){const{t:c}=Z(),{cssVars:d,theme:u}=he(),[p,h]=l.useState(!1);l.useEffect(()=>{o||h(!1)},[o]);const{title:f}=Wn(e),m=`${f}${e.working?` — ${c("thinking")}`:""}`;function k(y){return a&&r.jsx(Se.Portal,{container:a,children:r.jsxs(Se.Content,{side:"top",sideOffset:8,collisionPadding:12,"data-companion-session-tooltip":"",style:{...d,zIndex:u.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:[y,r.jsx(Se.Arrow,{width:8,height:4,style:{fill:"hsl(var(--opencx-foreground))"}})]})})}const w=c("companion_close_chat",{title:f});return r.jsxs("div",{"data-session-item":"",children:[r.jsxs(Se.Root,{open:o&&p,onOpenChange:h,children:[r.jsx(Se.Trigger,{asChild:!0,children:r.jsxs(G,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-session-circle":e.id,"aria-label":m,"aria-pressed":n,tabIndex:o?0:-1,onClick:y=>{y.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})]})}),k(m)]}),r.jsx(G,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-session-close":e.id,"aria-label":w,tabIndex:o?0:-1,onClick:y=>{y.stopPropagation(),h(!1),i(y.currentTarget)},children:r.jsx(T.XIcon,{size:10,"aria-hidden":!0})})]})}function Bu({onSelected:e=()=>{},onLastClosed:t=()=>{},interactive:n=!0}){const{openChats:o,activeId:s,selectChat:i,newChat:a,closeChat:c}=C.useCompanionChats(),{canCreateNewSession:d}=C.useSessions(),{isSmallScreen:u}=Ee(),{t:p,dir:h}=Z(),f=Hn(),m=Gt(),k=u?2:3,w=o.slice(0,o.length>k?k-1:k),y=o.find(b=>b.id===s);y&&!w.includes(y)&&(w[w.length-1]=y);const v=o.length-w.length,z=o.some(b=>b.working&&!w.includes(b)),g=l.useRef(f.close);g.current=f.close,l.useEffect(()=>{n||g.current(!0)},[n]);function S(b){f.close(!0),b===void 0?a():i(b),e()}function j(b,E){var N,_;f.close(!0);const $=w.findIndex(W=>W.id===b),M=w[$+1]??w[$-1];(_=(N=E.closest("[data-companion-session-circles]"))==null?void 0:N.querySelector(M?`[data-session-circle="${M.id}"]`:"[data-new-session]"))==null||_.focus({preventScroll:!0}),c(b),o.length===1&&t()}return r.jsx(Se.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:h,onPointerDown:b=>b.stopPropagation(),style:{position:"relative",zIndex:0,display:"flex",alignItems:"center",gap:4,flexShrink:0,pointerEvents:n?"auto":"none"},children:[r.jsx(Bn,{}),r.jsx("style",{children:`
|
|
242
|
-
[data-companion-session-tooltip][data-state="delayed-open"] { animation: opencx-session-tooltip-in 120ms ease-out; }
|
|
243
|
-
@keyframes opencx-session-tooltip-in { from { opacity: 0; } to { opacity: 1; } }
|
|
244
|
-
@media (prefers-reduced-motion: reduce) { [data-companion-session-tooltip] { animation: none !important; } }
|
|
245
|
-
[data-companion-session-circles] > button,
|
|
246
|
-
[data-companion-session-circles] [data-session-circle] {
|
|
247
|
-
position: relative; display: grid; place-items: center; flex: 0 0 28px;
|
|
248
|
-
width: 28px; height: 28px; padding: 0; border-radius: 50%;
|
|
249
|
-
border: 1px solid hsl(var(--opencx-border));
|
|
250
|
-
background: transparent; color: hsl(var(--opencx-muted-foreground));
|
|
251
|
-
font: 11px ui-sans-serif, system-ui, sans-serif; font-variant-numeric: tabular-nums;
|
|
252
|
-
cursor: pointer;
|
|
253
|
-
}
|
|
254
|
-
[data-companion-session-circles] [data-session-circle][aria-pressed="true"] {
|
|
255
|
-
border-color: hsl(var(--opencx-primary) / .45);
|
|
256
|
-
background: hsl(var(--opencx-primary) / .08);
|
|
257
|
-
color: hsl(var(--opencx-foreground));
|
|
258
|
-
}
|
|
259
|
-
@media (hover: hover) and (pointer: fine) {
|
|
260
|
-
[data-companion-session-circles] > button:hover,
|
|
261
|
-
[data-companion-session-circles] [data-session-item]:hover [data-session-circle] { background: hsl(var(--opencx-muted)); color: hsl(var(--opencx-foreground)); }
|
|
262
|
-
}
|
|
263
|
-
[data-companion-session-circles] button:focus-visible { outline: 2px solid hsl(var(--opencx-ring)); outline-offset: 2px; }
|
|
264
|
-
[data-companion-session-circles] > button:disabled { opacity: .4; cursor: default; }
|
|
265
|
-
[data-companion-session-circles] [data-session-item] { position: relative; display: flex; align-items: center; width: 36px; height: 32px; flex-shrink: 0; }
|
|
266
|
-
[data-companion-session-circles] [data-session-close] {
|
|
267
|
-
position: absolute; inset-inline-end: 0; top: -1px; z-index: 1;
|
|
268
|
-
width: 16px; height: 16px; display: grid; place-items: center; padding: 0;
|
|
269
|
-
border: 1px solid hsl(var(--opencx-border) / .7); border-radius: 50%;
|
|
270
|
-
background: hsl(var(--opencx-background)); color: hsl(var(--opencx-muted-foreground)); cursor: pointer;
|
|
271
|
-
}
|
|
272
|
-
@media (hover: hover) and (pointer: fine) {
|
|
273
|
-
[data-companion-session-circles] [data-session-close] { opacity: 0; pointer-events: none; }
|
|
274
|
-
[data-companion-session-circles] [data-session-item]:hover [data-session-close],
|
|
275
|
-
[data-companion-session-circles] [data-session-item]:focus-within [data-session-close] { opacity: 1; pointer-events: auto; }
|
|
276
|
-
[data-companion-session-circles] [data-session-close]:hover { color: hsl(var(--opencx-foreground)); }
|
|
277
|
-
}
|
|
278
|
-
@media (pointer: coarse) {
|
|
279
|
-
[data-companion-session-circles] [data-session-item] { width: 42px; }
|
|
280
|
-
[data-companion-session-circles] [data-session-close] { width: 24px; height: 24px; top: -3px; }
|
|
281
|
-
[data-companion-session-circles] [data-session-close] svg { width: 12px; height: 12px; }
|
|
282
|
-
}
|
|
283
|
-
[data-companion-session-circles] > button[data-new-session] { border-style: dashed; }
|
|
284
|
-
[data-companion-session-circles] [data-session-working] {
|
|
285
|
-
position: absolute; inset: -1px; color: hsl(var(--opencx-primary));
|
|
286
|
-
animation: opencx-session-spin 1.2s linear infinite;
|
|
287
|
-
}
|
|
288
|
-
@keyframes opencx-session-spin { to { transform: rotate(360deg); } }
|
|
289
|
-
@media (prefers-reduced-motion: reduce) { [data-companion-session-circles] [data-session-working] { animation: none; } }
|
|
290
|
-
`}),w.map(b=>r.jsx(Hu,{chat:b,number:b.id,selected:b.id===s,interactive:n,portalTarget:m,onSelect:()=>S(b.id),onClose:E=>j(b.id,E)},b.id)),v>0&&r.jsxs(G,{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:b=>f.hover(b.currentTarget),onPointerLeave:f.leave,onClick:b=>{b.stopPropagation(),f.toggle(b.currentTarget,b.detail>0)},children:[z&&r.jsx(T.LoaderCircleIcon,{size:28,"aria-hidden":!0,"data-session-working":""}),r.jsxs("span",{"aria-hidden":!0,children:["+",v]})]}),r.jsx(G,{variant:"ghost",size:"selfless","data-companion-action":"",type:"button","data-new-session":"","aria-label":p("new_conversation"),disabled:!d,tabIndex:n?0:-1,onClick:b=>{b.stopPropagation(),S()},children:r.jsx(T.PlusIcon,{size:14,"aria-hidden":!0})}),f.anchor&&m&&r.jsx(qn,{picker:f,portalTarget:m,placement:"above",onSelected:e})]})})}function qu({panelOpen:e,isOpen:t,setIsOpen:n,onOpen:o,onClose:s}){const i=l.useRef(t),a=l.useRef({onOpen:o,onClose:s});a.current={onOpen:o,onClose:s},l.useEffect(()=>{i.current=e,n(e)},[e,n]),l.useEffect(()=>{t!==i.current&&(i.current=t,t?a.current.onOpen():a.current.onClose())},[t])}const Ke="data-opencx-app-frame",Uu="data-opencx-app-frame-style",vt="data-opencx-sidebar-open",Bt="data-opencx-frame-no-anim",jt="data-opencx-fixed-fit",tr="--opencx-sidebar-w",rt=bc;let Be=null,ot=null,Gr=0;const bt=new Map,Kr={setOpen:()=>{},setWidth:()=>{},setAnimated:()=>{},release:()=>{}};function Vu(){let e,t;return bt.forEach(n=>{(!e||n.order>e.order)&&(e=n),n.open&&(!t||n.order>t.order)&&(t=n)}),t??e}function dn(){const e=Vu();if(!e||!Be)return;Be.textContent=Yu(e.canvas,e.side,e.pageBackground);const t=document.documentElement;e.open?t.setAttribute(vt,""):t.removeAttribute(vt),e.animated?t.removeAttribute(Bt):t.setAttribute(Bt,""),t.style.setProperty(tr,`${e.width}px`)}function Zr(e){getComputedStyle(e).position==="fixed"&&e.setAttribute(jt,"");for(const t of Array.from(e.querySelectorAll("*")))getComputedStyle(t).position==="fixed"&&t.setAttribute(jt,"")}function Yu(e,t,n){const[o,s]=t==="left"?["right","left"]:["left","right"];return`
|
|
291
|
-
html[${Ke}] {
|
|
292
|
-
overflow: hidden !important;
|
|
293
|
-
background: ${e} !important;
|
|
294
|
-
}
|
|
295
|
-
html[${Ke}] body {
|
|
296
|
-
position: fixed !important;
|
|
297
|
-
inset: 0 !important;
|
|
298
|
-
margin: 0 !important;
|
|
299
|
-
width: auto !important;
|
|
300
|
-
height: auto !important;
|
|
301
|
-
min-width: 0 !important;
|
|
302
|
-
min-height: 0 !important;
|
|
303
|
-
max-width: none !important;
|
|
304
|
-
max-height: none !important;
|
|
305
|
-
overflow: auto !important;
|
|
306
|
-
contain: strict !important;
|
|
307
|
-
background: ${n} !important;
|
|
308
|
-
border-radius: 0 !important;
|
|
309
|
-
/* Transparent ring+shadow, NOT none — none can't interpolate */
|
|
310
|
-
box-shadow: 0 0 0 1px rgba(0,0,0,0), 0 10px 24px -6px rgba(0,0,0,0) !important;
|
|
311
|
-
}
|
|
312
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
313
|
-
html[${Ke}] body {
|
|
314
|
-
transition:
|
|
315
|
-
top 0.3s ${rt}, bottom 0.3s ${rt},
|
|
316
|
-
left 0.3s ${rt}, right 0.3s ${rt},
|
|
317
|
-
border-radius 0.3s ${rt}, box-shadow 0.3s ${rt} !important;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
html[${Bt}] body { transition: none !important; }
|
|
321
|
-
html[${Ke}] body [${jt}] {
|
|
322
|
-
max-width: 100% !important;
|
|
323
|
-
max-height: 100% !important;
|
|
324
|
-
}
|
|
325
|
-
html[${vt}] body {
|
|
326
|
-
top: ${Ne}px !important;
|
|
327
|
-
bottom: ${Ne}px !important;
|
|
328
|
-
${o}: ${Ne}px !important;
|
|
329
|
-
${s}: calc(var(${tr}, ${Qn}px) + ${Ne*2}px) !important;
|
|
330
|
-
border-radius: ${He.sidebar}px !important;
|
|
331
|
-
box-shadow: 0 0 0 1px rgba(0,0,0,0.06), 0 10px 24px -6px rgba(0,0,0,0.10) !important;
|
|
332
|
-
}
|
|
333
|
-
@media (max-width: ${Us}px) {
|
|
334
|
-
html[${vt}] body {
|
|
335
|
-
inset: 0 !important;
|
|
336
|
-
border-radius: 0 !important;
|
|
337
|
-
box-shadow: 0 0 0 1px rgba(0,0,0,0), 0 10px 24px -6px rgba(0,0,0,0) !important;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
`}function Xu({canvas:e,side:t,pageBackground:n}){if(typeof document>"u")return Kr;const o=document.documentElement;if(!Be&&o.hasAttribute(Ke))return Kr;if(!Be){const d=document.createElement("style");d.setAttribute(Uu,""),document.head.appendChild(d);const u=window.scrollY;o.setAttribute(Ke,""),document.body.scrollTop=u,Zr(document.body),ot=new MutationObserver(p=>{for(const h of p)for(const f of Array.from(h.addedNodes))f instanceof Element&&Zr(f)}),ot.observe(document.body,{childList:!0,subtree:!0}),Be=d}const s=Symbol("opencx-app-frame-owner"),i={canvas:e,side:t,pageBackground:n,open:!1,width:Qn,animated:!0,order:++Gr};bt.set(s,i),dn();let a=!1;const c=d=>{if(a)return;const u=bt.get(s);u&&(d(u),dn())};return{setOpen(d){c(u=>{u.open=d,d&&(u.order=++Gr)})},setWidth(d){c(u=>{u.width=d})},setAnimated(d){c(u=>{u.animated=d})},release(){a||(a=!0,bt.delete(s),bt.size===0?Gu():dn())}}}function Gu(){if(!Be)return;const e=document.body.scrollTop,t=document.documentElement;t.removeAttribute(Ke),t.removeAttribute(vt),t.removeAttribute(Bt),t.style.removeProperty(tr),ot==null||ot.disconnect(),ot=null;for(const n of Array.from(document.querySelectorAll(`[${jt}]`)))n.removeAttribute(jt);Be.remove(),Be=null,window.scrollTo({top:e})}let ft=0,un="";function Ku(){if(typeof document>"u")return()=>{};ft===0&&(un=document.body.style.overflow,document.body.style.overflow="hidden"),ft+=1;let e=!1;return()=>{e||(e=!0,ft=Math.max(0,ft-1),ft===0&&(document.body.style.overflow=un,un=""))}}function Zu(e,t){return e[t]??""}function Ju({companion:e,layout:t,state:n,region:o,sidebarSide:s,sidebarMode:i,cssVars:a,storage:c,resizeLabel:d}){var P,L,O,V,U,q;const u=Math.max(0,((P=e==null?void 0:e.sidebar)==null?void 0:P.minWidth)??Bs),p=Math.max(u,((L=e==null?void 0:e.sidebar)==null?void 0:L.maxWidth)??xu),[h,f]=l.useState(()=>{var F;return Xe(((F=e==null?void 0:e.sidebar)==null?void 0:F.width)??Qn,u,p)}),[m,k]=l.useState(!1),w=l.useRef(null);l.useEffect(()=>{f(F=>{var K;return Xe(((K=e==null?void 0:e.sidebar)==null?void 0:K.width)??F,u,p)})},[(O=e==null?void 0:e.sidebar)==null?void 0:O.width,p,u]),l.useEffect(()=>{var K;let F=!1;if(!(!c||((K=e==null?void 0:e.sidebar)==null?void 0:K.width)!==void 0))return c.getCompanionSidebarWidth().then(ne=>{F||ne===null||f(Xe(ne,u,p))}).catch(()=>{}),()=>{F=!0}},[(V=e==null?void 0:e.sidebar)==null?void 0:V.width,p,u,c]);const y=l.useCallback(F=>Xe(s==="left"?F:window.innerWidth-F,u,p),[p,u,s]),v=l.useCallback(F=>{var K;F.currentTarget.setPointerCapture(F.pointerId),k(!0),(K=w.current)==null||K.setAnimated(!1)},[]),z=l.useCallback(F=>{F.currentTarget.hasPointerCapture(F.pointerId)&&f(y(F.clientX))},[y]),g=l.useCallback(F=>{var ne;const K=y(F.clientX);F.currentTarget.hasPointerCapture(F.pointerId)&&F.currentTarget.releasePointerCapture(F.pointerId),f(K),k(!1),(ne=w.current)==null||ne.setAnimated(!0),c==null||c.setCompanionSidebarWidth(K).catch(()=>{})},[c,y]),S=l.useCallback(F=>{var K;F.currentTarget.hasPointerCapture(F.pointerId)&&F.currentTarget.releasePointerCapture(F.pointerId),k(!1),(K=w.current)==null||K.setAnimated(!0)},[]),j=l.useCallback(F=>{let K=null;if(F.key==="Home"&&(K=u),F.key==="End"&&(K=p),F.key==="ArrowLeft"||F.key==="ArrowRight"){const ne=F.key===(s==="left"?"ArrowRight":"ArrowLeft");K=Xe(h+(ne?16:-16),u,p)}K!==null&&(F.preventDefault(),f(K),c==null||c.setCompanionSidebarWidth(K).catch(()=>{}))},[p,u,s,h,c]),b=t==="sidebar",E=i==="docked",$=er(o,h),M=((U=e==null?void 0:e.sidebar)==null?void 0:U.canvasColor)??bu,N=`hsl(${Zu(a,"--opencx-background")})`,_=l.useRef({open:n!=="pill",width:$});_.current={open:n!=="pill",width:$},l.useEffect(()=>{if(!b||!E)return;const F=Xu({canvas:M,side:s,pageBackground:N});return w.current=F,F.setWidth(_.current.width),F.setOpen(_.current.open),()=>{w.current===F&&(w.current=null),F.release()}},[M,E,b,N,s]),l.useEffect(()=>{var F;b&&E&&((F=w.current)==null||F.setWidth($))},[$,E,b]),l.useEffect(()=>{var F;b&&E&&((F=w.current)==null||F.setOpen(n!=="pill"))},[E,b,n]);const W=n==="chat"&&t==="fullscreen",B=((q=e==null?void 0:e.fullscreen)==null?void 0:q.lockScroll)!==!1;l.useEffect(()=>{if(!(!W||!B))return Ku()},[W,B]);const I=l.useMemo(()=>({role:"separator",tabIndex:0,"aria-orientation":"vertical","aria-label":d,"aria-valuemin":u,"aria-valuemax":p,"aria-valuenow":h,onPointerDown:v,onPointerMove:z,onPointerUp:g,onPointerCancel:S,onKeyDown:j}),[p,u,j,v,z,S,g,d,h]);return{sidebarWidth:h,sidebarResizing:m,resizeHandleProps:I}}const Qu={width:1440,height:900};function Jr(){return typeof window>"u"?Qu:{width:window.innerWidth,height:window.innerHeight}}function ep(){const[e,t]=l.useState(Jr),[n,o]=l.useState(null),s=l.useRef(null),i=l.useCallback(c=>{var u;if((u=s.current)==null||u.disconnect(),s.current=null,!c)return;const d=new ResizeObserver(()=>{o(c.offsetWidth)});d.observe(c),s.current=d},[]);l.useEffect(()=>{function c(){t(Jr())}return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),l.useEffect(()=>()=>{var c;(c=s.current)==null||c.disconnect(),s.current=null},[]);const a=Math.min(n??uu,Math.max(0,e.width-Hs));return{region:e,dockWidth:a,dockContentRef:i}}function tp({storage:e,state:t,layout:n,viewportWidth:o,currentWidth:s,restingWidth:i,shouldReduceMotion:a}){const[c,d]=l.useState(0),u=H.useMotionValue(0),p=l.useRef(!1);l.useEffect(()=>{let y=!1;if(e)return e.getCompanionPillOffsetX().then(v=>{y||v===null||d(v)}).catch(()=>{}),()=>{y=!0}},[u,e]),l.useEffect(()=>{const y=a?ge:ct;if(t==="pill"){const z=Math.max(0,o/2-i/2-cn),g=Xe(c,-z,z);Math.abs(u.get())>z?u.set(g):H.animate(u,g,y);return}if(t==="chat"&&(n==="fullscreen"||n==="sidebar")){H.animate(u,0,y);return}const v=Math.max(0,o/2-s/2-cn);H.animate(u,Xe(c,-v,v),y)},[s,u,n,c,i,a,t,o]);const h=Math.max(0,o/2-i/2-cn),f=l.useMemo(()=>({left:-h,right:h,top:0,bottom:0}),[h]),m=l.useCallback(()=>{p.current=!0},[]),k=l.useCallback(()=>{const y=u.get();d(v=>v===y?v:y),e==null||e.setCompanionPillOffsetX(y).catch(()=>{}),requestAnimationFrame(()=>{p.current=!1})},[u,e]),w=l.useCallback(()=>p.current,[]);return{dragX:u,dragConstraints:f,onDragStart:m,onDragEnd:k,shouldIgnoreLaunch:w}}function np({state:e,layout:t,sidebarMode:n,isPageMarkModeArmed:o}){return e==="pill"||o?!1:!(t==="sidebar"&&n==="docked")}const rp=96,op=Dn({transparent:!0});function sp(){var ar,ir,cr;const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger(),{openChats:n,activeId:o}=C.useCompanionChats(),s=n.length,i=n.filter(Q=>Q.working).length,{widgetCtx:a,contentIframeRef:c}=C.useWidget(),{companion:d,assets:u,customComponents:p}=C.useConfig(),{theme:h,cssVars:f}=he(),{t:m,dir:k}=Z(),{sessionState:w}=C.useSessions(),{messagesState:y}=C.useMessages(),{isArmed:v}=Zn(),{region:z,dockWidth:g,dockContentRef:S}=ep(),[j,b]=l.useState(e?"chat":"pill"),{layout:E,setLayout:$,setLayoutPreference:M,allowedLayouts:N,defaultLayout:_,sidebarSide:W,sidebarMode:B}=C.useWidgetLayout(),[I,P]=l.useState(rp),{sidebarWidth:L,sidebarResizing:O,resizeHandleProps:V}=Ju({companion:d,layout:E,state:j,region:z,sidebarSide:W,sidebarMode:B,cssVars:f,storage:a.storageCtx,resizeLabel:m("companion_resize_chat")}),U=H.useReducedMotion(),q=O?{duration:0}:U?ge:ct,F=qt(),K=l.useRef(null),ne=l.useRef(!1),re=j==="pill",R=s>0,X=Hn(),J=l.useRef(X.close);J.current=X.close,l.useEffect(()=>{(!re||!R)&&J.current(!0)},[re,R]);const se=p==null?void 0:p.widgetTrigger,oe=!!se,ue=(d==null?void 0:d.pillBackground)??"hsl(var(--opencx-primary))",pe=(d==null?void 0:d.icon)??((ar=u==null?void 0:u.widgetTrigger)==null?void 0:ar.openIcon),ye=h.widgetTrigger.offset.bottom,ve=Fs(),de=!!((ir=w.session)!=null&&ir.id),Re=de?m("follow_up_placeholder"):void 0,$e=(d==null?void 0:d.pillLabel)??(d==null?void 0:d.placeholder)??Re??m("write_a_message_placeholder"),Ie=(d==null?void 0:d.pillLabelDisplay)??"always",xe=(d==null?void 0:d.placeholder)??Re??m("write_a_message_placeholder"),[Qe,Ue]=l.useState(!1),le=re&&!oe&&Ie!=="never"&&(Ie==="always"||F&&Qe),Oe=Vs(z,d==null?void 0:d.compact),et=E==="sidebar",me=yu({layout:E,region:z,sidebarWidth:L,bottomOffset:ye,compact:d==null?void 0:d.compact}),Ve=j==="chat"?me.width:Oe,Kt=me.height,{centerX:Et,bottom:It}=vu({isChatOpen:j==="chat",layout:E,region:z,sidebarWidth:L,sidebarSide:W,bottomOffset:ye}),Y=l.useMemo(()=>j==="pill"?le?{width:g,height:du,borderRadius:He.pill}:{width:xt,height:xt,borderRadius:He.pill}:j==="input"?{width:Oe,height:I,borderRadius:He.input}:me,[j,le,g,Oe,me,I]),ie=j==="pill"&&le&&Ie==="hover"?(k==="rtl"?-1:1)*(g-xt)/2:0,{dragX:ut,dragConstraints:pt,onDragStart:De,onDragEnd:At,shouldIgnoreLaunch:Ye}=tp({storage:a.storageCtx,state:j,layout:E,viewportWidth:z.width,currentWidth:Y.width,restingWidth:le?g:xt,shouldReduceMotion:U}),fe=l.useCallback(()=>{var ht;const Q=a.routerCtx.state.get().screen,ce=!!((ht=a.sessionCtx.sessionState.get().session)!=null&&ht.id);b(Q==="welcome"||ce?"chat":"input")},[a]),mt=l.useCallback(()=>{if(!Ye()){if(J.current(!0),E==="sidebar"){b("chat");return}fe()}},[fe,E,Ye]),Zt=l.useCallback(()=>{if(E==="fullscreen"&&_!=="fullscreen"){$(_);return}if(E==="sidebar"){b("pill");return}b(Q=>{var ce;return Q==="chat"&&((ce=a.sessionCtx.sessionState.get().session)!=null&&ce.id)?"input":"pill"})},[_,E,$,a]),Ks=l.useCallback(()=>{const Q=Ru({panelLayout:E,previousLayout:tt.current,defaultLayout:_,allowedLayouts:N});if(Q.kind==="layout"){$(Q.layout);return}b("pill")},[N,_,E,$]),Zs=l.useCallback(()=>{b("pill")},[]);l.useEffect(()=>{j==="chat"&&(ne.current=!0)},[j]),l.useEffect(()=>{j!=="chat"&&ne.current&&E==="fullscreen"&&_!=="fullscreen"&&$(_)},[_,E,$,j]);const or=j==="chat"&&E==="fullscreen";qu({panelOpen:j!=="pill",isOpen:e,setIsOpen:t,onOpen:fe,onClose:Zs}),l.useEffect(()=>{if(!np({state:j,layout:E,sidebarMode:B,isPageMarkModeArmed:v}))return;function Q(ce){const ht=K.current;ht&&(ce.composedPath().includes(ht)||Zt())}return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[Zt,j,E,B,v]);const Jt=((cr=y.messages.findLast(Q=>Q.type==="USER"))==null?void 0:cr.id)??null,sr=l.useRef(null);l.useEffect(()=>{j==="input"&&(sr.current=Jt)},[j]),l.useEffect(()=>{j==="input"&&Jt!==sr.current&&(a.routerCtx.state.get().screen!=="chat"&&a.routerCtx.state.setPartial({screen:"chat"}),b("chat"))},[Jt,j,a]);const Js=l.useCallback(()=>{var Q;a.routerCtx.state.get().screen!=="chat"&&((Q=a.sessionCtx.sessionState.get().session)!=null&&Q.id)&&a.routerCtx.state.setPartial({screen:"chat"}),b("chat")},[a]),Tt=l.useCallback(Q=>{var ce;N.includes(Q)&&(Q==="fullscreen"&&a.routerCtx.state.get().screen==="sessions"&&a.routerCtx.toChatScreen((ce=a.sessionCtx.sessionState.get().session)==null?void 0:ce.id),M(Q))},[N,a,M]),Qt=N.find(Q=>Q!=="fullscreen"),tt=l.useRef(Qt??_);l.useEffect(()=>{E!=="fullscreen"&&N.includes(E)?tt.current=E:(tt.current==="fullscreen"||!N.includes(tt.current))&&(tt.current=Qt??_)},[N,_,Qt,E]);const en=l.useCallback(()=>{if(!N.includes("fullscreen"))return;if(E!=="fullscreen"){Tt("fullscreen");return}const Q=tt.current;Q!=="fullscreen"&&N.includes(Q)&&Tt(Q)},[N,E,Tt]);l.useEffect(()=>{function Q(ce){Pu(ce,{state:j,onToggleFullscreen:en})}return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[en,j]);const tn=Gt();return tn?kt.createPortal(r.jsxs(r.Fragment,{children:[se&&Ws(se,e,t),re&&X.anchor&&!oe&&r.jsx(qn,{placement:"above",picker:X,portalTarget:tn,onSelected:()=>b("chat")}),r.jsx(H.motion.div,{"aria-hidden":!0,style:{position:"fixed",inset:0,background:"transparent",zIndex:h.widgetContentContainer.zIndex,pointerEvents:or?"auto":"none"},initial:!1,animate:{opacity:or?1:0},transition:ze}),r.jsx(H.motion.div,{ref:K,style:{...f,position:"fixed",x:ut,translateX:"-50%",zIndex:h.widgetContentContainer.zIndex,visibility:oe&&re?"hidden":void 0},initial:!1,animate:{left:Et,bottom:It},drag:re&&!oe&&!X.open?"x":!1,dragMomentum:!1,dragElastic:.15,dragConstraints:pt,onDragStart:De,onDragEnd:At,transition:q,children:r.jsxs(H.motion.div,{onPointerEnter:re&&!oe?Q=>{Ue(!0);const ce=Q.currentTarget.querySelector("[data-companion-count-trigger]");ce&&!Ye()&&X.hover(ce)}:void 0,onPointerLeave:()=>{Ue(!1),X.leave()},style:{position:"relative",overflow:"hidden",transformOrigin:"center bottom",cursor:re&&!oe?le?"pointer":"grab":"default",background:"hsl(var(--opencx-background))"},initial:!1,animate:{x:ie,width:Y.width,height:Y.height,borderTopLeftRadius:Y.borderRadius,borderTopRightRadius:Y.borderRadius,borderBottomLeftRadius:Y.borderRadius,borderBottomRightRadius:Y.borderRadius,boxShadow:re?le?yc:wc:j==="input"?vc:jc},whileHover:re&&!oe&&F&&!U?{scale:le?1.01:1.12}:void 0,whileTap:re&&!oe?{scale:le?.995:.92}:void 0,transition:q,children:[re&&!oe&&r.jsx("button",{type:"button","data-companion-launcher":"",onClick:mt,"aria-label":ve,"aria-expanded":!1,style:{position:"absolute",inset:0,zIndex:1,border:0,padding:0,background:"transparent",cursor:"pointer",borderRadius:"inherit"}}),!oe&&r.jsx(Wu,{visible:re,docked:le,label:$e,sessions:s>0?r.jsx(Bu,{interactive:re&&le,onSelected:()=>b("chat"),onLastClosed:()=>{requestAnimationFrame(()=>{var Q,ce;(ce=(Q=K.current)==null?void 0:Q.querySelector("[data-companion-launcher]"))==null||ce.focus({preventScroll:!0})})}}):void 0,activeCount:s,countLabel:`${m("companion_chats")} · ${m("companion_active_chats",{count:s})}${i?` · ${m("companion_working_chats",{count:i})}`:""}`,pickerOpen:X.open,onOpenChats:(Q,ce)=>{Ye()||X.toggle(Q,ce)},working:i>0,icon:pe,pillBackground:ue,dir:k,measureRef:S}),j!=="pill"&&r.jsx(H.motion.div,{style:{position:"absolute",bottom:0,left:"50%",translateX:"-50%",width:Ve,height:Kt},initial:{opacity:0},animate:{opacity:1,transition:{...ge,delay:U?0:.1}},children:r.jsx(Ou,{iframeRef:c,initialContent:op,style:{width:"100%",height:"100%",overflow:"hidden",backgroundColor:"transparent",boxSizing:"border-box",borderWidth:"0px"},children:r.jsx($u,{state:j==="chat"?"chat":"input",layout:E,shellRadius:Y.borderRadius,onMinimize:Zt,onDismiss:Ks,onToggleFullscreen:en,onSelectLayout:Tt,onExpand:Js,canExpand:de,placeholder:xe,hideAttachTools:((d==null?void 0:d.quickAskTools)??"history-only")==="history-only",onInputHeightChange:P},o)})}),et&&j==="chat"&&r.jsx("div",{...V,style:{position:"absolute",top:0,bottom:0,...W==="left"?{right:0}:{left:0},width:8,cursor:"ew-resize",zIndex:2}})]})})]}),tn):null}const ap=["circle","box","underline","bracket","arrow"],ip=x.z.object({selector:x.z.string().optional(),text:x.z.string().optional(),label:x.z.string().optional(),type:x.z.enum(ap).optional().catch(void 0)}),cp=8e3;function lp(e,t,n){return t.display==="inline"&&e.height<=n*2.5?"underline":e.width<=220&&e.height<=80?"circle":"box"}let Pe=null;function dp(){Pe==null||Pe()}function up(e,{accentColor:t="hsl(0 0% 9%)",surfaceColor:n="hsl(0 0% 9%)",foregroundColor:o="hsl(0 0% 98%)",zIndex:s=10000002,durationMs:i=cp,seed:a}={}){const c=Nl(e);if(!c)return!1;Pe==null||Pe();const d=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;c.scrollIntoView({behavior:d?"auto":"smooth",block:"center",inline:"nearest"});const u=c.getBoundingClientRect(),p=getComputedStyle(c),h=parseFloat(p.fontSize)||16,f=u.width<160&&u.height<56,m=co.annotate(c,{type:e.type??lp(u,p,h),color:t,strokeWidth:Math.min(3,Math.max(1.6,h*.11)),wobble:f?.6:.9,rtl:p.direction==="rtl",seed:a});let k=!1;const w=()=>{if(!k)try{m.show(),Sn(c,s)}catch(N){ee.log.warn("highlight_element: mark could not be drawn",N)}},y=document.fonts;y!=null&&y.ready&&typeof y.ready.then=="function"?y.ready.then(w):w();const v=document.createElement("div");v.setAttribute("data-opencx-overlay",""),v.style.pointerEvents="none";let z=null,g=null;e.label&&(z=document.createElement("div"),z.setAttribute("data-cx-role","callout"),Object.assign(z.style,{position:"fixed",zIndex:String(s+1),background:n,color:o,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, ${o} 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"}),z.textContent=e.label,g=document.createElement("div"),Object.assign(g.style,{position:"absolute",width:"10px",height:"10px",background:n,transform:"rotate(45deg)"}),z.appendChild(g),v.appendChild(z)),document.documentElement.appendChild(v);let S=0;if(z&&g){const N=z,_=g,W=()=>{const B=c.getBoundingClientRect(),I=window.innerWidth,P=B.top>90?"top":"bottom",L=Math.min(240,N.offsetWidth||240),O=Math.max(12,Math.min(B.left+B.width/2-L/2,I-L-12));N.style.left=`${O}px`,N.style.width=`${L}px`,N.style.top=P==="top"?`${B.top-N.offsetHeight-12}px`:`${B.bottom+12}px`,_.style.left=`${Math.max(10,Math.min(B.left+B.width/2-O-5,L-20))}px`,P==="top"?(_.style.bottom="-4px",_.style.top=""):(_.style.top="-4px",_.style.bottom=""),S=requestAnimationFrame(W)};W()}const j=z?window.setTimeout(()=>{z&&(z.style.opacity="1",z.style.transform="translateY(0)")},350):0,b=()=>{if(!k){k=!0,Pe===b&&(Pe=null),cancelAnimationFrame(S),window.clearTimeout(M),window.clearTimeout(j),document.removeEventListener("click",E,!0),document.removeEventListener("keydown",$,!0),z&&(z.style.opacity="0",z.style.transform=d?"none":"translateY(4px)");try{m.hide(),m.finished.then(()=>m.remove())}catch{m.remove()}window.setTimeout(()=>v.remove(),300)}},E=()=>b(),$=N=>{N.key==="Escape"&&b()},M=window.setTimeout(b,Math.max(0,i));return document.addEventListener("click",E,!0),document.addEventListener("keydown",$,!0),Pe=b,!0}const pp=200;function mp(){const{pageMarkHighlightDurationMs:e}=C.useConfig(),{pageEffects:t}=C.useAgentChatUi(),{theme:n,cssVars:o}=he(),s=Gn({cssVars:o,primaryColor:n.primaryColor,contentZIndex:n.widgetContentContainer.zIndex}),i=l.useRef(new Set);return l.useEffect(()=>()=>dp(),[]),l.useEffect(()=>{const a=i.current;for(const c of t){if(c.type!=="highlight-element"||a.has(c.key))continue;for(a.add(c.key);a.size>pp;){const p=a.values().next().value;if(p===void 0)break;a.delete(p)}const d=ip.safeParse(c.input);if(!d.success){ee.log.warn("highlight_element: invalid tool input",{issues:d.error.issues});continue}up(d.data,{accentColor:s.accent,surfaceColor:s.surface,foregroundColor:s.foreground,zIndex:s.inkZIndex,durationMs:e})||ee.log.warn("highlight_element: element not found on page",d.data)}},[t,e,s.accent,s.surface,s.foreground,s.inkZIndex]),null}const hp=/(\*\*\*|\*\*|\*|~~|`+)(?=\S)([\s\S]*?\S)\1/g,fp=/(^|[^\w`])(___|__|_)(?=\S)([\s\S]*?\S)\2(?!\w)/g,gp=3;function _n(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<gp;n++){const o=t.replace(hp,"$2").replace(fp,"$1$3");if(o===t)break;t=o}return t.trim()}function Xs({className:e}){const[t,n]=l.useState(()=>new Set);return l.useEffect(()=>{const o=Array.from({length:9},(i,a)=>a),s=setInterval(()=>{const i=2+Math.floor(Math.random()*3),a=[...o].sort(()=>Math.random()-.5).slice(0,i);n(new Set(a))},110);return()=>clearInterval(s)},[]),r.jsx("div",{className:A("inline-grid shrink-0 grid-cols-3",e),style:{gap:1,width:14,height:14},children:Array.from({length:9},(o,s)=>r.jsx("div",{className:"rounded-[1px]",style:{width:4,height:4,background:t.has(s)?"hsl(var(--opencx-foreground))":"hsl(var(--opencx-border))",transition:"background 66ms ease"}},s))})}function xp({labels:e,active:t}){const n=l.useRef(e);n.current=e;const[o,s]=l.useState(()=>e[e.length-1]??""),[i,a]=l.useState("in"),c=l.useRef(e.length);return l.useEffect(()=>{const d=n.current.length;if(!t||d<=c.current){c.current=d;return}c.current=d;const u=n.current[d-1]??"";a("out");const p=setTimeout(()=>{s(u),a("in")},180);return()=>clearTimeout(p)},[t,e.length]),r.jsx("span",{className:A("truncate text-[12px] text-muted-foreground/60",t&&(i==="in"?"opencx-placeholder-in":"opencx-placeholder-out")),children:o})}function nr(e,t){if(e.kind==="tool")return rr(e.label);const n=e.label.split(`
|
|
341
|
-
`).find(s=>s.trim());if(!n)return t;const o=_n(n);return o?o.length>40?`${o.slice(0,40)}...`:o:t}function bp(e,t,n=3){const o=e.filter(s=>s.kind==="tool").map(s=>rr(s.label));if(o.length===0){const s=e.find(i=>i.kind==="reasoning");return s?nr(s,t):t}return o.length<=n?o.join(" → "):`${o.slice(0,n).join(" → ")} → ...`}const wp=["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 yp({step:e,isLive:t,thinkingLabel:n}){const[o,s]=l.useState(!1),i=nr(e,n),a=i!==_n(e.label),c=t?(()=>{const d=e.label.split(`
|
|
342
|
-
`).filter(p=>p.trim()),u=_n(d[d.length-1]??"");return u?u.length>80?`${u.slice(0,80)}...`:u:n})():i;return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:A("flex min-w-0 items-center gap-2.5 py-[3px]",a&&"cursor-pointer"),onClick:()=>a&&s(d=>!d),children:[r.jsx("div",{className:"relative z-10 flex size-[18px] shrink-0 items-center justify-center rounded-full bg-background",children:t?r.jsx(Vn,{className:"text-[14px] leading-none text-primary/70"}):r.jsx("span",{className:"text-[14px] leading-none text-muted-foreground/40",children:"⠿"})}),r.jsx("span",{className:A("min-w-0 truncate text-[13px] italic text-muted-foreground/60",t&&"opencx-text-shimmer"),children:c}),a&&r.jsx(T.ChevronRightIcon,{className:A("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),a&&o&&r.jsx("div",{className:"opencx-fade-up ms-[30px]",children:r.jsx("div",{className:A("max-h-[160px] overflow-y-auto py-1.5 text-[13px] leading-relaxed [overflow-wrap:anywhere]",wp),children:r.jsx(Xt,{children:e.label})})})]})}const Qr=4e3;function vp(e){const t=typeof e=="string"?e:jp(e)??String(e);return t.length>Qr?`${t.slice(0,Qr)}…`:t}function jp(e){try{return JSON.stringify(e,null,2)}catch{return null}}function eo({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:vp(t)})]})}function kp({step:e,showIO:t}){const{t:n}=Z(),[o,s]=l.useState(!1),i=t&&(e.input!==void 0||e.output!==void 0);return r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:A("flex min-w-0 items-center gap-2.5 py-[3px]",i&&"cursor-pointer"),onClick:()=>i&&s(a=>!a),children:[r.jsx("div",{className:"relative z-10 flex size-[18px] shrink-0 items-center justify-center rounded-full bg-background",children:e.done?r.jsx("div",{className:"size-1.5 rounded-full bg-muted-foreground/30"}):r.jsx(Xs,{})}),r.jsx("span",{className:A("min-w-0 truncate text-[13px] text-muted-foreground/70",!e.done&&"opencx-text-shimmer"),children:rr(e.label)}),i&&r.jsx(T.ChevronRightIcon,{className:A("size-2.5 shrink-0 text-muted-foreground/40 transition-transform duration-200",o&&"rotate-90")})]}),i&&o&&r.jsxs("div",{className:"opencx-fade-up ms-[30px] pb-1",children:[e.input!==void 0&&r.jsx(eo,{label:n("step_arguments"),value:e.input}),e.output!==void 0&&r.jsx(eo,{label:n("step_result"),value:e.output})]})]})}function Cp({steps:e,active:t}){var k;const{t:n}=Z(),{showStepToolIO:o,presentation:s}=C.useConfig(),{widgetCtx:i}=C.useWidget(),a=(k=ee.resolveClientPresentation(i.agent.presentation,s))==null?void 0:k.toolActivity,c=o!==!1&&(a==="details"||a===void 0&&o===!0),d=n("thinking"),u=t?e:e.map(w=>w.done?w:{...w,done:!0}),p=u.some(w=>!w.done),[h,f]=l.useState(t),m=l.useRef(t);return l.useEffect(()=>{m.current&&!t?f(!1):!m.current&&t&&f(!0),m.current=t},[t]),u.length===0?null:r.jsxs("div",{...D("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(w=>!w),children:h?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:u.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(Xs,{className:"opacity-70"}),r.jsx("span",{className:"text-[11px] font-medium tabular-nums",children:u.length}),r.jsx(xp,{labels:u.map(w=>nr(w,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:bp(u,d)})]})}),h&&r.jsxs("div",{className:"relative pt-1",children:[u.length>1&&r.jsx("div",{className:"absolute bottom-3 start-2 top-3 border-s border-dashed border-muted-foreground/20"}),u.map((w,y)=>r.jsx("div",{className:"opencx-fade-up",style:{animationDelay:`${y*40}ms`},children:w.kind==="reasoning"?r.jsx(yp,{step:w,isLive:p&&y===u.length-1,thinkingLabel:d}):r.jsx(kp,{step:w,showIO:c})},y))]})]})}function rr(e){const n=e.replace(/^mcp_[a-f0-9]{16}__/,"").replaceAll(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}function to(e){var n;if(e.manual){const o=e.manualText.trim();return o.length>0?o:void 0}if(e.question.selection==="single")return e.singleId?(n=e.question.options.find(o=>o.id===e.singleId))==null?void 0:n.label:void 0;const t=Array.from(e.multiIds).map(o=>{var s;return(s=e.question.options.find(i=>i.id===o))==null?void 0:s.label}).filter(o=>typeof o=="string"&&o.length>0);return t.length>0?t.join(", "):void 0}function Sp({request:e}){const{t}=Z(),{sendMessage:n}=C.useMessages(),o=e.questions,[s,i]=l.useState(0),[a,c]=l.useState(!1),[d,u]=l.useState({}),[p,h]=l.useState({}),[f,m]=l.useState({}),[k,w]=l.useState({}),y=o[s],v=o.length,z=l.useCallback(_=>to({question:_,manual:!!d[_.id],manualText:p[_.id]??"",singleId:f[_.id],multiIds:k[_.id]??new Set})!==void 0,[d,p,k,f]),g=y?z(y):!1,S=l.useMemo(()=>o.every(_=>z(_)),[z,o]),j=l.useCallback((_,W)=>{m(B=>({...B,[_]:W})),u(B=>({...B,[_]:!1}))},[]),b=l.useCallback((_,W)=>{w(B=>{const I=new Set(B[_]??[]);return I.has(W)?I.delete(W):I.add(W),{...B,[_]:I}}),u(B=>({...B,[_]:!1}))},[]),E=l.useCallback(_=>{u(W=>({...W,[_]:!0})),m(W=>({...W,[_]:void 0})),w(W=>({...W,[_]:new Set}))},[]),$=l.useCallback(()=>{g&&i(_=>Math.min(v-1,_+1))},[g,v]),M=l.useCallback(()=>{if(a||!S)return;const _=new Map;for(const B of o){const I=to({question:B,manual:!!d[B.id],manualText:p[B.id]??"",singleId:f[B.id],multiIds:k[B.id]??new Set});I&&_.set(B.id,I)}const W=C.formatAskQuestionsAnswers(e,_);W.trim().length!==0&&(c(!0),n({content:W}))},[S,a,d,p,k,o,e,n,f]);if(!y)return null;const N=!!d[y.id];return r.jsxs("div",{...D("chat/clarification_questions/root"),className:A("w-full rounded-2xl border border-border bg-background shadow-sm",a&&"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",{...D("chat/clarification_questions/prompt"),className:"min-w-0 flex-1 text-sm font-medium leading-snug text-foreground",children:y.prompt})]}),r.jsx("div",{className:"px-4 pb-3 pt-3",children:N?r.jsx("textarea",{...D("chat/clarification_questions/manual_input"),value:p[y.id]??"",onChange:_=>h(W=>({...W,[y.id]:_.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:_=>{_.key!=="Enter"||_.shiftKey||(_.preventDefault(),s<v-1?$():M())}}):r.jsxs("div",{className:"flex flex-wrap gap-2",children:[y.options.map(_=>{var B;const W=y.selection==="single"?f[y.id]===_.id:((B=k[y.id])==null?void 0:B.has(_.id))??!1;return l.createElement("button",{...D("chat/clarification_questions/option"),key:_.id,type:"button","aria-pressed":W,onClick:()=>y.selection==="single"?j(y.id,_.id):b(y.id,_.id),className:A("rounded-full border px-3 py-1.5 text-sm transition-colors",W?"border-primary bg-primary/10 text-foreground":"border-border bg-muted/40 text-foreground/90 hover:bg-muted")},_.label)}),r.jsx("button",{...D("chat/clarification_questions/type_it"),type:"button",onClick:()=>E(y.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",{...D("chat/clarification_questions/back"),type:"button",onClick:()=>i(_=>Math.max(0,_-1)),disabled:s===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")]}),v>1?r.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[s+1," / ",v]}):null,s<v-1?r.jsxs("button",{...D("chat/clarification_questions/next"),type:"button",onClick:$,disabled:!g,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",{...D("chat/clarification_questions/send"),type:"button",onClick:M,disabled:!S,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:`${(s+1)/Math.max(1,v)*100}%`}})})]})}function Np({widgetRef:e}){const{contactState:t}=C.useContact(),{setIsOpen:n}=C.useWidgetTrigger(),{toChatScreen:o}=C.useWidgetRouter();return l.useImperativeHandle(e,()=>({newChat:async s=>{var a;if(!((a=t.contact)!=null&&a.token)){ee.log.warn("cannot start a new chat: contact not yet initialized");return}n(!0);const i=o();i&&(s!=null&&s.message)&&await i.messageCtx.sendMessage({content:s.message})}}),[t,n,o]),null}function _p(){const{isOpen:e,setIsOpen:t}=C.useWidgetTrigger();return r.jsxs(We.Root,{open:e,onOpenChange:t,children:[r.jsx(lu,{}),r.jsx(cu,{}),r.jsx(su,{})]})}function zp(){return C.useDisplayMode()==="companion"?r.jsx(C.WidgetLayoutProvider,{children:r.jsx(sp,{})}):r.jsx(_p,{})}const Ep=[{key:"loading",component:$c},{key:"fallback",component:Rc},{key:"bot_message",component:bn},{key:"agent_message",component:bn},{key:"agent_chat_steps",component:Cp},{key:"agent_chat_spec",component:cl},{key:"agent_chat_questions",component:Sp}],Ip={get:async e=>localStorage.getItem(e),set:async(e,t)=>{localStorage.setItem(e,t)},remove:async e=>{localStorage.removeItem(e)}},Gs=l.forwardRef(function({options:t,components:n=[],loadingComponent:o,errorComponent:s},i){var a,c,d,u;return r.jsx(H.MotionConfig,{reducedMotion:"user",children:r.jsx(C.WidgetProvider,{components:[...Ep,...n],options:{...t,capabilities:{...t.capabilities,richReplies:((a=t.capabilities)==null?void 0:a.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:((u=t.capabilities)==null?void 0:u.structuredQuestions)??!n.some(({key:p})=>p.toUpperCase()==="AGENT_CHAT_QUESTIONS")}},storage:Ip,loadingComponent:o,errorComponent:s,children:r.jsx(C.WidgetTriggerProvider,{children:r.jsxs(Pd,{children:[r.jsx(mp,{}),r.jsx(Np,{widgetRef:i}),t.inline?r.jsx(Ls,{}):r.jsx(zp,{})]})})})})});Gs.displayName="Widget";exports.HostedSpecRenderer=pc;exports.Widget=Gs;exports.segmentContent=Go;exports.useJsonRenderHost=_t;
|
|
343
|
-
//# sourceMappingURL=index-B3pRBUF2.cjs.map
|