@apteva/apteva-darwin-arm64 0.4.41 → 0.4.48
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/apteva +0 -0
- package/dist/ActivityPage.9v5ha2p7.js +3 -0
- package/dist/{ActivityPage.7907h64p.js.map → ActivityPage.9v5ha2p7.js.map} +3 -3
- package/dist/ApiDocsPage.qsehxvkb.js +4 -0
- package/dist/ApiDocsPage.qsehxvkb.js.map +10 -0
- package/dist/App.168av39e.js +221 -0
- package/dist/{App.qcknavjz.js.map → App.168av39e.js.map} +15 -15
- package/dist/App.2j20h2gt.js +8 -0
- package/dist/App.2j20h2gt.js.map +12 -0
- package/dist/App.7gj4jht5.js +53 -0
- package/dist/{App.apjrmctz.js.map → App.7gj4jht5.js.map} +50 -52
- package/dist/App.aexwv4rk.js +4 -0
- package/dist/App.aexwv4rk.js.map +10 -0
- package/dist/App.anvw0hjc.js +61 -0
- package/dist/App.anvw0hjc.js.map +13 -0
- package/dist/App.cjcyr5aj.js +4 -0
- package/dist/App.cjcyr5aj.js.map +10 -0
- package/dist/App.dmvykj97.js +4 -0
- package/dist/App.dmvykj97.js.map +10 -0
- package/dist/App.e2kkda2a.js +4 -0
- package/dist/App.e2kkda2a.js.map +10 -0
- package/dist/App.j4ec9k18.js +13 -0
- package/dist/App.j4ec9k18.js.map +10 -0
- package/dist/{App.7fb3e7mp.js → App.jdkx6eqd.js} +1 -1
- package/dist/App.kz3qyyre.js +4 -0
- package/dist/{App.myxqcj9x.js.map → App.kz3qyyre.js.map} +3 -3
- package/dist/App.sd685nt9.js +4 -0
- package/dist/App.sd685nt9.js.map +10 -0
- package/dist/App.shfd8tp9.js +20 -0
- package/dist/{App.3qw8nben.js.map → App.shfd8tp9.js.map} +6 -4
- package/dist/App.wghtdzsk.js +1 -0
- package/dist/App.x6x8s16g.js +4 -0
- package/dist/App.x6x8s16g.js.map +14 -0
- package/dist/App.y2vn8m06.js +4 -0
- package/dist/App.y2vn8m06.js.map +10 -0
- package/dist/ConnectionsPage.1dyyfqbk.js +3 -0
- package/dist/McpPage.xvr8hk05.js +3 -0
- package/dist/SettingsPage.5jmnefwe.js +3 -0
- package/dist/SkillsPage.jw7carjq.js +3 -0
- package/dist/TasksPage.r8txe0e9.js +3 -0
- package/dist/TasksPage.r8txe0e9.js.map +9 -0
- package/dist/TelemetryPage.pcafk41x.js +3 -0
- package/dist/TelemetryPage.pcafk41x.js.map +9 -0
- package/dist/TestsPage.pkymr7yt.js +3 -0
- package/dist/ThreadsPage.49tgq4fq.js +3 -0
- package/dist/apteva-kit.css +1 -1
- package/dist/index.html +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/ActivityPage.7907h64p.js +0 -3
- package/dist/ApiDocsPage.k3jjenpq.js +0 -4
- package/dist/ApiDocsPage.k3jjenpq.js.map +0 -10
- package/dist/App.01nq20st.js +0 -4
- package/dist/App.01nq20st.js.map +0 -10
- package/dist/App.1maqvamf.js +0 -4
- package/dist/App.1maqvamf.js.map +0 -14
- package/dist/App.2yjrh32f.js +0 -4
- package/dist/App.2yjrh32f.js.map +0 -10
- package/dist/App.3qw8nben.js +0 -20
- package/dist/App.7sy3wq8c.js +0 -4
- package/dist/App.7sy3wq8c.js.map +0 -10
- package/dist/App.apjrmctz.js +0 -57
- package/dist/App.av6t2yhe.js +0 -4
- package/dist/App.av6t2yhe.js.map +0 -10
- package/dist/App.jqj5a094.js +0 -46
- package/dist/App.jqj5a094.js.map +0 -13
- package/dist/App.mc7xf85h.js +0 -4
- package/dist/App.mc7xf85h.js.map +0 -10
- package/dist/App.myxqcj9x.js +0 -4
- package/dist/App.nm91r1mp.js +0 -13
- package/dist/App.nm91r1mp.js.map +0 -10
- package/dist/App.p02f4ret.js +0 -1
- package/dist/App.qcknavjz.js +0 -221
- package/dist/App.vc7vfhg4.js +0 -4
- package/dist/App.vc7vfhg4.js.map +0 -10
- package/dist/App.z4s9zkw5.js +0 -4
- package/dist/App.z4s9zkw5.js.map +0 -10
- package/dist/ConnectionsPage.z1pw5xe2.js +0 -3
- package/dist/McpPage.8vc97z0b.js +0 -3
- package/dist/SettingsPage.p61bz8kd.js +0 -3
- package/dist/SkillsPage.r9x43g3g.js +0 -3
- package/dist/TasksPage.1e0zkye4.js +0 -3
- package/dist/TasksPage.1e0zkye4.js.map +0 -9
- package/dist/TelemetryPage.p9vbe4gf.js +0 -3
- package/dist/TelemetryPage.p9vbe4gf.js.map +0 -9
- package/dist/TestsPage.d4xy504e.js +0 -3
- package/dist/ThreadsPage.m016am3x.js +0 -3
- /package/dist/{App.7fb3e7mp.js.map → App.jdkx6eqd.js.map} +0 -0
- /package/dist/{ConnectionsPage.z1pw5xe2.js.map → ConnectionsPage.1dyyfqbk.js.map} +0 -0
- /package/dist/{McpPage.8vc97z0b.js.map → McpPage.xvr8hk05.js.map} +0 -0
- /package/dist/{SettingsPage.p61bz8kd.js.map → SettingsPage.5jmnefwe.js.map} +0 -0
- /package/dist/{SkillsPage.r9x43g3g.js.map → SkillsPage.jw7carjq.js.map} +0 -0
- /package/dist/{TestsPage.d4xy504e.js.map → TestsPage.pkymr7yt.js.map} +0 -0
- /package/dist/{ThreadsPage.m016am3x.js.map → ThreadsPage.49tgq4fq.js.map} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import{V as iQ,W as y$}from"./App.2j20h2gt.js";import{$ as F0,X as w,Y as lQ,aa as QQ,ca as ZQ,ea as zQ,ja as YQ,ma as JQ,oa as HQ}from"./App.shfd8tp9.js";var r=lQ((dQ)=>{var LX=w(F0());(function(){function X(U){if(U==null)return null;if(typeof U==="function")return U.$$typeof===N?null:U.displayName||U.name||null;if(typeof U==="string")return U;switch(U){case A:return"Fragment";case T:return"Profiler";case M:return"StrictMode";case e:return"Suspense";case v:return"SuspenseList";case k:return"Activity"}if(typeof U==="object")switch(typeof U.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),U.$$typeof){case V:return"Portal";case a:return U.displayName||"Context";case g:return(U._context.displayName||"Context")+".Consumer";case t:var I=U.render;return U=U.displayName,U||(U=I.displayName||I.name||"",U=U!==""?"ForwardRef("+U+")":"ForwardRef"),U;case P:return I=U.displayName||null,I!==null?I:X(U.type)||"Memo";case b:I=U._payload,U=U._init;try{return X(U(I))}catch(F){}}return null}function $(U){return""+U}function Q(U){try{$(U);var I=!1}catch(X0){I=!0}if(I){I=console;var F=I.error,h=typeof Symbol==="function"&&Symbol.toStringTag&&U[Symbol.toStringTag]||U.constructor.name||"Object";return F.call(I,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",h),$(U)}}function Z(U){if(U===A)return"<>";if(typeof U==="object"&&U!==null&&U.$$typeof===b)return"<...>";try{var I=X(U);return I?"<"+I+">":"<...>"}catch(F){return"<...>"}}function z(){var U=E.A;return U===null?null:U.getOwner()}function H(){return Error("react-stack-top-frame")}function G(U){if(D.call(U,"key")){var I=Object.getOwnPropertyDescriptor(U,"key").get;if(I&&I.isReactWarning)return!1}return U.key!==void 0}function Y(U,I){function F(){y0||(y0=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",I))}F.isReactWarning=!0,Object.defineProperty(U,"key",{get:F,configurable:!0})}function K(){var U=X(this.type);return w0[U]||(w0[U]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),U=this.props.ref,U!==void 0?U:null}function q(U,I,F,h,X0,J0){var H0=F.ref;return U={$$typeof:B,type:U,key:I,props:F,_owner:h},(H0!==void 0?H0:null)!==null?Object.defineProperty(U,"ref",{enumerable:!1,get:K}):Object.defineProperty(U,"ref",{enumerable:!1,value:null}),U._store={},Object.defineProperty(U._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(U,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(U,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:X0}),Object.defineProperty(U,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:J0}),Object.freeze&&(Object.freeze(U.props),Object.freeze(U)),U}function _(U,I,F,h,X0,J0){var H0=I.children;if(H0!==void 0)if(h)if(U0(H0)){for(h=0;h<H0.length;h++)J(H0[h]);Object.freeze&&Object.freeze(H0)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else J(H0);if(D.call(I,"key")){H0=X(U);var h0=Object.keys(I).filter(function(OX){return OX!=="key"});h=0<h0.length?"{key: someKey, "+h0.join(": ..., ")+": ...}":"{key: someKey}",A0[H0+h]||(h0=0<h0.length?"{"+h0.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
+
let props = %s;
|
|
3
|
+
<%s {...props} />
|
|
4
|
+
React keys must be passed directly to JSX without using spread:
|
|
5
|
+
let props = %s;
|
|
6
|
+
<%s key={someKey} {...props} />`,h,H0,h0,H0),A0[H0+h]=!0)}if(H0=null,F!==void 0&&(Q(F),H0=""+F),G(I)&&(Q(I.key),H0=""+I.key),"key"in I){F={};for(var zX in I)zX!=="key"&&(F[zX]=I[zX])}else F=I;return H0&&Y(F,typeof U==="function"?U.displayName||U.name||"Unknown":U),q(U,H0,F,z(),X0,J0)}function J(U){O(U)?U._store&&(U._store.validated=1):typeof U==="object"&&U!==null&&U.$$typeof===b&&(U._payload.status==="fulfilled"?O(U._payload.value)&&U._payload.value._store&&(U._payload.value._store.validated=1):U._store&&(U._store.validated=1))}function O(U){return typeof U==="object"&&U!==null&&U.$$typeof===B}var B=Symbol.for("react.transitional.element"),V=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),g=Symbol.for("react.consumer"),a=Symbol.for("react.context"),t=Symbol.for("react.forward_ref"),e=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),k=Symbol.for("react.activity"),N=Symbol.for("react.client.reference"),E=LX.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,U0=Array.isArray,n=console.createTask?console.createTask:function(){return null};LX={react_stack_bottom_frame:function(U){return U()}};var y0,w0={},f0=LX.react_stack_bottom_frame.bind(LX,H)(),v0=n(Z(H)),A0={};dQ.Fragment=A,dQ.jsx=function(U,I,F){var h=1e4>E.recentlyCreatedOwnerStacks++;return _(U,I,F,!1,h?Error("react-stack-top-frame"):f0,h?n(Z(U)):v0)},dQ.jsxs=function(U,I,F){var h=1e4>E.recentlyCreatedOwnerStacks++;return _(U,I,F,!0,h?Error("react-stack-top-frame"):f0,h?n(Z(U)):v0)}})()});var M0=w(F0(),1);var i=w(F0(),1),RX=w(F0(),1),FX=w(F0(),1);var OQ=(X)=>{let $=BQ(X),{conflictingClassGroups:Q,conflictingClassGroupModifiers:Z}=X;return{getClassGroupId:(G)=>{let Y=G.split("-");if(Y[0]===""&&Y.length!==1)Y.shift();return E$(Y,$)||VQ(G)},getConflictingClassGroupIds:(G,Y)=>{let K=Q[G]||[];if(Y&&Z[G])return[...K,...Z[G]];return K}}},E$=(X,$)=>{if(X.length===0)return $.classGroupId;let Q=X[0],Z=$.nextPart.get(Q),z=Z?E$(X.slice(1),Z):void 0;if(z)return z;if($.validators.length===0)return;let H=X.join("-");return $.validators.find(({validator:G})=>G(H))?.classGroupId},N$=/^\[(.+)\]$/,VQ=(X)=>{if(N$.test(X)){let $=N$.exec(X)[1],Q=$?.substring(0,$.indexOf(":"));if(Q)return"arbitrary.."+Q}},BQ=(X)=>{let{theme:$,prefix:Q}=X,Z={nextPart:new Map,validators:[]};return DQ(Object.entries(X.classGroups),Q).forEach(([H,G])=>{Y$(G,Z,H,$)}),Z},Y$=(X,$,Q,Z)=>{X.forEach((z)=>{if(typeof z==="string"){let H=z===""?$:A$($,z);H.classGroupId=Q;return}if(typeof z==="function"){if(LQ(z)){Y$(z(Z),$,Q,Z);return}$.validators.push({validator:z,classGroupId:Q});return}Object.entries(z).forEach(([H,G])=>{Y$(G,A$($,H),Q,Z)})})},A$=(X,$)=>{let Q=X;return $.split("-").forEach((Z)=>{if(!Q.nextPart.has(Z))Q.nextPart.set(Z,{nextPart:new Map,validators:[]});Q=Q.nextPart.get(Z)}),Q},LQ=(X)=>X.isThemeGetter,DQ=(X,$)=>{if(!$)return X;return X.map(([Q,Z])=>{let z=Z.map((H)=>{if(typeof H==="string")return $+H;if(typeof H==="object")return Object.fromEntries(Object.entries(H).map(([G,Y])=>[$+G,Y]));return H});return[Q,z]})},FQ=(X)=>{if(X<1)return{get:()=>{return},set:()=>{}};let $=0,Q=new Map,Z=new Map,z=(H,G)=>{if(Q.set(H,G),$++,$>X)$=0,Z=Q,Q=new Map};return{get(H){let G=Q.get(H);if(G!==void 0)return G;if((G=Z.get(H))!==void 0)return z(H,G),G},set(H,G){if(Q.has(H))Q.set(H,G);else z(H,G)}}};var WQ=(X)=>{let{separator:$,experimentalParseClassName:Q}=X,Z=$.length===1,z=$[0],H=$.length,G=(Y)=>{let K=[],q=0,_=0,J;for(let M=0;M<Y.length;M++){let T=Y[M];if(q===0){if(T===z&&(Z||Y.slice(M,M+H)===$)){K.push(Y.slice(_,M)),_=M+H;continue}if(T==="/"){J=M;continue}}if(T==="[")q++;else if(T==="]")q--}let O=K.length===0?Y:Y.substring(_),B=O.startsWith("!"),V=B?O.substring(1):O,A=J&&J>_?J-_:void 0;return{modifiers:K,hasImportantModifier:B,baseClassName:V,maybePostfixModifierPosition:A}};if(Q)return(Y)=>Q({className:Y,parseClassName:G});return G},NQ=(X)=>{if(X.length<=1)return X;let $=[],Q=[];return X.forEach((Z)=>{if(Z[0]==="[")$.push(...Q.sort(),Z),Q=[];else Q.push(Z)}),$.push(...Q.sort()),$},AQ=(X)=>({cache:FQ(X.cacheSize),parseClassName:WQ(X),...OQ(X)}),EQ=/\s+/,PQ=(X,$)=>{let{parseClassName:Q,getClassGroupId:Z,getConflictingClassGroupIds:z}=$,H=[],G=X.trim().split(EQ),Y="";for(let K=G.length-1;K>=0;K-=1){let q=G[K],{modifiers:_,hasImportantModifier:J,baseClassName:O,maybePostfixModifierPosition:B}=Q(q),V=Boolean(B),A=Z(V?O.substring(0,B):O);if(!A){if(!V){Y=q+(Y.length>0?" "+Y:Y);continue}if(A=Z(O),!A){Y=q+(Y.length>0?" "+Y:Y);continue}V=!1}let M=NQ(_).join(":"),T=J?M+"!":M,g=T+A;if(H.includes(g))continue;H.push(g);let a=z(A,V);for(let t=0;t<a.length;++t){let e=a[t];H.push(T+e)}Y=q+(Y.length>0?" "+Y:Y)}return Y};function MQ(){let X=0,$,Q,Z="";while(X<arguments.length)if($=arguments[X++]){if(Q=P$($))Z&&(Z+=" "),Z+=Q}return Z}var P$=(X)=>{if(typeof X==="string")return X;let $,Q="";for(let Z=0;Z<X.length;Z++)if(X[Z]){if($=P$(X[Z]))Q&&(Q+=" "),Q+=$}return Q};function RQ(X,...$){let Q,Z,z,H=G;function G(K){let q=$.reduce((_,J)=>J(_),X());return Q=AQ(q),Z=Q.cache.get,z=Q.cache.set,H=Y,Y(K)}function Y(K){let q=Z(K);if(q)return q;let _=PQ(K,Q);return z(K,_),_}return function(){return H(MQ.apply(null,arguments))}}var B0=(X)=>{let $=(Q)=>Q[X]||[];return $.isThemeGetter=!0,$},M$=/^\[(?:([a-z-]+):)?(.+)\]$/i,TQ=/^\d+\/\d+$/,IQ=new Set(["px","full","screen"]),bQ=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,vQ=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,kQ=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,wQ=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,SQ=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,$X=(X)=>EX(X)||IQ.has(X)||TQ.test(X),UX=(X)=>PX(X,"length",gQ),EX=(X)=>Boolean(X)&&!Number.isNaN(Number(X)),z$=(X)=>PX(X,"number",EX),jX=(X)=>Boolean(X)&&Number.isInteger(Number(X)),yQ=(X)=>X.endsWith("%")&&EX(X.slice(0,-1)),l=(X)=>M$.test(X),_X=(X)=>bQ.test(X),CQ=new Set(["length","size","percentage"]),fQ=(X)=>PX(X,CQ,R$),jQ=(X)=>PX(X,"position",R$),hQ=new Set(["image","url"]),xQ=(X)=>PX(X,hQ,pQ),uQ=(X)=>PX(X,"",mQ),hX=()=>!0,PX=(X,$,Q)=>{let Z=M$.exec(X);if(Z){if(Z[1])return typeof $==="string"?Z[1]===$:$.has(Z[1]);return Q(Z[2])}return!1},gQ=(X)=>vQ.test(X)&&!kQ.test(X),R$=()=>!1,mQ=(X)=>wQ.test(X),pQ=(X)=>SQ.test(X);var cQ=()=>{let X=B0("colors"),$=B0("spacing"),Q=B0("blur"),Z=B0("brightness"),z=B0("borderColor"),H=B0("borderRadius"),G=B0("borderSpacing"),Y=B0("borderWidth"),K=B0("contrast"),q=B0("grayscale"),_=B0("hueRotate"),J=B0("invert"),O=B0("gap"),B=B0("gradientColorStops"),V=B0("gradientColorStopPositions"),A=B0("inset"),M=B0("margin"),T=B0("opacity"),g=B0("padding"),a=B0("saturate"),t=B0("scale"),e=B0("sepia"),v=B0("skew"),P=B0("space"),b=B0("translate"),k=()=>["auto","contain","none"],N=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto",l,$],D=()=>[l,$],U0=()=>["",$X,UX],n=()=>["auto",EX,l],y0=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],w0=()=>["solid","dashed","dotted","double","none"],f0=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],v0=()=>["start","end","center","between","around","evenly","stretch"],A0=()=>["","0",l],U=()=>["auto","avoid","all","avoid-page","page","left","right","column"],I=()=>[EX,l];return{cacheSize:500,separator:":",theme:{colors:[hX],spacing:[$X,UX],blur:["none","",_X,l],brightness:I(),borderColor:[X],borderRadius:["none","","full",_X,l],borderSpacing:D(),borderWidth:U0(),contrast:I(),grayscale:A0(),hueRotate:I(),invert:A0(),gap:D(),gradientColorStops:[X],gradientColorStopPositions:[yQ,UX],inset:E(),margin:E(),opacity:I(),padding:D(),saturate:I(),scale:I(),sepia:A0(),skew:I(),space:D(),translate:D()},classGroups:{aspect:[{aspect:["auto","square","video",l]}],container:["container"],columns:[{columns:[_X]}],"break-after":[{"break-after":U()}],"break-before":[{"break-before":U()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...y0(),l]}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[A]}],"inset-x":[{"inset-x":[A]}],"inset-y":[{"inset-y":[A]}],start:[{start:[A]}],end:[{end:[A]}],top:[{top:[A]}],right:[{right:[A]}],bottom:[{bottom:[A]}],left:[{left:[A]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",jX,l]}],basis:[{basis:E()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",l]}],grow:[{grow:A0()}],shrink:[{shrink:A0()}],order:[{order:["first","last","none",jX,l]}],"grid-cols":[{"grid-cols":[hX]}],"col-start-end":[{col:["auto",{span:["full",jX,l]},l]}],"col-start":[{"col-start":n()}],"col-end":[{"col-end":n()}],"grid-rows":[{"grid-rows":[hX]}],"row-start-end":[{row:["auto",{span:[jX,l]},l]}],"row-start":[{"row-start":n()}],"row-end":[{"row-end":n()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",l]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",l]}],gap:[{gap:[O]}],"gap-x":[{"gap-x":[O]}],"gap-y":[{"gap-y":[O]}],"justify-content":[{justify:["normal",...v0()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...v0(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...v0(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[g]}],px:[{px:[g]}],py:[{py:[g]}],ps:[{ps:[g]}],pe:[{pe:[g]}],pt:[{pt:[g]}],pr:[{pr:[g]}],pb:[{pb:[g]}],pl:[{pl:[g]}],m:[{m:[M]}],mx:[{mx:[M]}],my:[{my:[M]}],ms:[{ms:[M]}],me:[{me:[M]}],mt:[{mt:[M]}],mr:[{mr:[M]}],mb:[{mb:[M]}],ml:[{ml:[M]}],"space-x":[{"space-x":[P]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[P]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",l,$]}],"min-w":[{"min-w":[l,$,"min","max","fit"]}],"max-w":[{"max-w":[l,$,"none","full","min","max","fit","prose",{screen:[_X]},_X]}],h:[{h:[l,$,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[l,$,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[l,$,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[l,$,"auto","min","max","fit"]}],"font-size":[{text:["base",_X,UX]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",z$]}],"font-family":[{font:[hX]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",l]}],"line-clamp":[{"line-clamp":["none",EX,z$]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",$X,l]}],"list-image":[{"list-image":["none",l]}],"list-style-type":[{list:["none","disc","decimal",l]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[X]}],"placeholder-opacity":[{"placeholder-opacity":[T]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[X]}],"text-opacity":[{"text-opacity":[T]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...w0(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",$X,UX]}],"underline-offset":[{"underline-offset":["auto",$X,l]}],"text-decoration-color":[{decoration:[X]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:D()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",l]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",l]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[T]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...y0(),jQ]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",fQ]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},xQ]}],"bg-color":[{bg:[X]}],"gradient-from-pos":[{from:[V]}],"gradient-via-pos":[{via:[V]}],"gradient-to-pos":[{to:[V]}],"gradient-from":[{from:[B]}],"gradient-via":[{via:[B]}],"gradient-to":[{to:[B]}],rounded:[{rounded:[H]}],"rounded-s":[{"rounded-s":[H]}],"rounded-e":[{"rounded-e":[H]}],"rounded-t":[{"rounded-t":[H]}],"rounded-r":[{"rounded-r":[H]}],"rounded-b":[{"rounded-b":[H]}],"rounded-l":[{"rounded-l":[H]}],"rounded-ss":[{"rounded-ss":[H]}],"rounded-se":[{"rounded-se":[H]}],"rounded-ee":[{"rounded-ee":[H]}],"rounded-es":[{"rounded-es":[H]}],"rounded-tl":[{"rounded-tl":[H]}],"rounded-tr":[{"rounded-tr":[H]}],"rounded-br":[{"rounded-br":[H]}],"rounded-bl":[{"rounded-bl":[H]}],"border-w":[{border:[Y]}],"border-w-x":[{"border-x":[Y]}],"border-w-y":[{"border-y":[Y]}],"border-w-s":[{"border-s":[Y]}],"border-w-e":[{"border-e":[Y]}],"border-w-t":[{"border-t":[Y]}],"border-w-r":[{"border-r":[Y]}],"border-w-b":[{"border-b":[Y]}],"border-w-l":[{"border-l":[Y]}],"border-opacity":[{"border-opacity":[T]}],"border-style":[{border:[...w0(),"hidden"]}],"divide-x":[{"divide-x":[Y]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[Y]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[T]}],"divide-style":[{divide:w0()}],"border-color":[{border:[z]}],"border-color-x":[{"border-x":[z]}],"border-color-y":[{"border-y":[z]}],"border-color-s":[{"border-s":[z]}],"border-color-e":[{"border-e":[z]}],"border-color-t":[{"border-t":[z]}],"border-color-r":[{"border-r":[z]}],"border-color-b":[{"border-b":[z]}],"border-color-l":[{"border-l":[z]}],"divide-color":[{divide:[z]}],"outline-style":[{outline:["",...w0()]}],"outline-offset":[{"outline-offset":[$X,l]}],"outline-w":[{outline:[$X,UX]}],"outline-color":[{outline:[X]}],"ring-w":[{ring:U0()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[X]}],"ring-opacity":[{"ring-opacity":[T]}],"ring-offset-w":[{"ring-offset":[$X,UX]}],"ring-offset-color":[{"ring-offset":[X]}],shadow:[{shadow:["","inner","none",_X,uQ]}],"shadow-color":[{shadow:[hX]}],opacity:[{opacity:[T]}],"mix-blend":[{"mix-blend":[...f0(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":f0()}],filter:[{filter:["","none"]}],blur:[{blur:[Q]}],brightness:[{brightness:[Z]}],contrast:[{contrast:[K]}],"drop-shadow":[{"drop-shadow":["","none",_X,l]}],grayscale:[{grayscale:[q]}],"hue-rotate":[{"hue-rotate":[_]}],invert:[{invert:[J]}],saturate:[{saturate:[a]}],sepia:[{sepia:[e]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[Q]}],"backdrop-brightness":[{"backdrop-brightness":[Z]}],"backdrop-contrast":[{"backdrop-contrast":[K]}],"backdrop-grayscale":[{"backdrop-grayscale":[q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[_]}],"backdrop-invert":[{"backdrop-invert":[J]}],"backdrop-opacity":[{"backdrop-opacity":[T]}],"backdrop-saturate":[{"backdrop-saturate":[a]}],"backdrop-sepia":[{"backdrop-sepia":[e]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[G]}],"border-spacing-x":[{"border-spacing-x":[G]}],"border-spacing-y":[{"border-spacing-y":[G]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",l]}],duration:[{duration:I()}],ease:[{ease:["linear","in","out","in-out",l]}],delay:[{delay:I()}],animate:[{animate:["none","spin","ping","pulse","bounce",l]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[t]}],"scale-x":[{"scale-x":[t]}],"scale-y":[{"scale-y":[t]}],rotate:[{rotate:[jX,l]}],"translate-x":[{"translate-x":[b]}],"translate-y":[{"translate-y":[b]}],"skew-x":[{"skew-x":[v]}],"skew-y":[{"skew-y":[v]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",l]}],accent:[{accent:["auto",X]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",l]}],"caret-color":[{caret:[X]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":D()}],"scroll-mx":[{"scroll-mx":D()}],"scroll-my":[{"scroll-my":D()}],"scroll-ms":[{"scroll-ms":D()}],"scroll-me":[{"scroll-me":D()}],"scroll-mt":[{"scroll-mt":D()}],"scroll-mr":[{"scroll-mr":D()}],"scroll-mb":[{"scroll-mb":D()}],"scroll-ml":[{"scroll-ml":D()}],"scroll-p":[{"scroll-p":D()}],"scroll-px":[{"scroll-px":D()}],"scroll-py":[{"scroll-py":D()}],"scroll-ps":[{"scroll-ps":D()}],"scroll-pe":[{"scroll-pe":D()}],"scroll-pt":[{"scroll-pt":D()}],"scroll-pr":[{"scroll-pr":D()}],"scroll-pb":[{"scroll-pb":D()}],"scroll-pl":[{"scroll-pl":D()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",l]}],fill:[{fill:[X,"none"]}],"stroke-w":[{stroke:[$X,UX,z$]}],stroke:[{stroke:[X,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}};var T$=RQ(cQ);var h$=w(F0(),1),n0=w(r(),1),IX=w(F0(),1),S0=w(r(),1),x$=w(r(),1),q$=w(r(),1),bX=w(F0(),1),P0=w(r(),1),E0=w(F0(),1),u$=w(iQ(),1),y=w(r(),1),uX=w(r(),1),W=w(r(),1),u0=w(r(),1),x0=w(r(),1),oX=w(r(),1),d0=w(F0(),1),G0=w(r(),1),k0=w(r(),1),K$=w(r(),1),C=w(r(),1),W0=w(r(),1),p=w(r(),1),m$=w(F0(),1),O0=w(r(),1),TX=w(r(),1),R=w(r(),1),m=w(r(),1),xX=w(r(),1),z0=w(F0(),1),L=w(r(),1),ZX=w(F0(),1),S=w(r(),1),p$=w(F0(),1),l0=w(r(),1),N0=w(F0(),1),b0=w(r(),1),rZ=w(F0(),1),l$=w(r(),1),_$=w(F0(),1),O$=w(r(),1),nZ=w(F0(),1),d$=w(r(),1),i$=w(F0(),1),o$=w(r(),1),aZ=w(F0(),1),r$=w(r(),1),n$=w(r(),1),a$=w(r(),1),aX=w(F0(),1),sZ=w(F0(),1),V$=w(r(),1),s$=w(r(),1),t$=w(r(),1),e$=w(r(),1),XQ=w(F0(),1),$Q=w(F0(),1),oQ=Object.defineProperty,rQ=(X,$,Q)=>($ in X)?oQ(X,$,{enumerable:!0,configurable:!0,writable:!0,value:Q}):X[$]=Q,nQ=(X,$,Q)=>rQ(X,typeof $!=="symbol"?$+"":$,Q);function Y0(...X){return T$(y$(X))}var qz=[{id:"msg-1",role:"assistant",content:"Hello! I'm your AI assistant. How can I help you today?",timestamp:new Date(Date.now()-3600000)},{id:"msg-2",role:"user",content:"I want to plan a trip to Europe",timestamp:new Date(Date.now()-3500000)},{id:"msg-3",role:"assistant",content:"Great choice! Europe has amazing destinations. What's your budget and how many days do you have?",timestamp:new Date(Date.now()-3400000)},{id:"msg-4",role:"user",content:"Around $2000 for 5 days",timestamp:new Date(Date.now()-3300000)},{id:"msg-5",role:"assistant",content:"Perfect! I found some great destinations that fit your budget:",widgets:[{type:"list",id:"destinations-1",props:{items:[{id:"paris",title:"Paris, France",subtitle:"5 days • $1,850",description:"The City of Light with iconic landmarks",metadata:{city:"Paris",country:"France",lat:48.8566,lng:2.3522,price:1850,days:5}},{id:"rome",title:"Rome, Italy",subtitle:"5 days • $1,650",description:"Ancient history meets modern culture",metadata:{city:"Rome",country:"Italy",lat:41.9028,lng:12.4964,price:1650,days:5}},{id:"barcelona",title:"Barcelona, Spain",subtitle:"5 days • $1,450",description:"Beautiful beaches and Gaudí architecture",metadata:{city:"Barcelona",country:"Spain",lat:41.3851,lng:2.1734,price:1450,days:5}}]},actions:[{type:"select_destination",label:"Select",handler:"client",payload:{}},{type:"view_details",label:"Details",handler:"server",payload:{}}]}],timestamp:new Date(Date.now()-3200000)}],Kz=[{id:"thread-1",title:"Trip to Europe",preview:"Planning a 5-day trip...",createdAt:new Date(Date.now()-86400000),updatedAt:new Date(Date.now()-3600000),messageCount:12},{id:"thread-2",title:"Restaurant Recommendations",preview:"Looking for good places...",createdAt:new Date(Date.now()-172800000),updatedAt:new Date(Date.now()-86400000),messageCount:8},{id:"thread-3",title:"Budget Planning",preview:"Help with monthly budget",createdAt:new Date(Date.now()-259200000),updatedAt:new Date(Date.now()-172800000),messageCount:15}];function aQ(X=1000){return new Promise(($)=>{setTimeout(()=>{$({id:`msg-${Date.now()}`,role:"assistant",content:"This is a mock response. In production, this would come from your AI agent API.",timestamp:new Date})},X)})}function sQ(X){let $=X.toLowerCase();if($.includes("analyze")||$.includes("analysis"))return`Analysis complete for "${X}". Found 247 records with an average value of $1,234. The data shows a 23% increase compared to last quarter. Key insights: Revenue is up, customer satisfaction improved by 15%, and operational costs decreased by 8%.`;if($.includes("sales")||$.includes("revenue"))return"Sales data processed: Q4 2024 revenue reached $2.4M, representing 18% growth year-over-year. Top performing products: Enterprise Plan (+45%), Pro Plan (+32%), Basic Plan (+12%). Regional breakdown: North America (52%), Europe (31%), APAC (17%).";if($.includes("report")||$.includes("summary"))return"Report generated successfully. Executive Summary: Overall performance exceeded targets by 12%. Marketing ROI improved to 3.2x, customer acquisition cost reduced by 18%, and lifetime value increased by 24%. Detailed breakdown available in attached widgets.";if($.includes("data")||$.includes("metrics"))return"Data metrics retrieved: 1,847 active users, 12,394 sessions this month, 94.2% uptime, average response time 127ms. Performance is within acceptable parameters. No critical issues detected.";if($.includes("customer")||$.includes("user"))return"Customer analysis complete: 523 new customers this month, 89% retention rate, average satisfaction score 4.6/5. Top feedback themes: excellent support (87%), easy to use (72%), good value (68%). 3 support tickets pending review.";return"This is a mock response showing how your agent would process and respond to commands. The actual response would be generated by your AI agent based on real data and context."}function tQ(X){let $=sQ(X),Q=X.toLowerCase(),Z=[],z;if(Q.includes("sales")||Q.includes("revenue")||Q.includes("analyze"))Z.push({type:"card",id:`widget-${Date.now()}-1`,props:{title:"Q4 2024 Performance",description:"Revenue: $2.4M (+18% YoY)",footer:"Updated: "+new Date().toLocaleDateString()},actions:[{type:"view_details",label:"View Details",handler:"client",payload:{reportId:"q4-2024"}}]});if(Q.includes("customer")||Q.includes("user"))Z.push({type:"list",id:`widget-${Date.now()}-2`,props:{items:[{id:"metric-1",title:"Active Users",subtitle:"1,847 users",description:"+12% from last month"},{id:"metric-2",title:"Retention Rate",subtitle:"89%",description:"Above industry average"},{id:"metric-3",title:"Satisfaction Score",subtitle:"4.6/5",description:"Based on 234 reviews"}]}});if(Q.includes("task")||Q.includes("todo")||Q.includes("work")||Q.includes("completed"))Z.push({type:"list",id:`widget-${Date.now()}-tasks`,props:{items:[{id:"task-1",title:"Implement user authentication",subtitle:"Created just now",description:"Added OAuth 2.0 support with Google and GitHub providers",backgroundColor:"rgba(59, 130, 246, 0.15)",metadata:{status:"created",priority:"high",tags:["backend","security"]}},{id:"task-2",title:"Update API documentation",subtitle:"Modified 2 minutes ago",description:"Changed endpoint descriptions and added new examples",backgroundColor:"rgba(234, 179, 8, 0.15)",metadata:{status:"modified",priority:"medium",tags:["docs"]}},{id:"task-3",title:"Fix login redirect bug",subtitle:"Completed 5 minutes ago",description:"Users now properly redirected after successful login",backgroundColor:"rgba(34, 197, 94, 0.15)",metadata:{status:"completed",priority:"urgent",tags:["bugfix","auth"]}}]},actions:[{type:"view_task",label:"View",handler:"client",payload:{}},{type:"undo",label:"Undo",handler:"server",payload:{}}]}),z={type:"update_database",payload:{table:"tasks",operation:"mark_as_viewed",taskIds:["task-1","task-2","task-3"],timestamp:new Date().toISOString()}};if(Q.includes("analyze")||Q.includes("analysis"))z={type:"send_notification",payload:{recipient:"team@company.com",subject:"Analysis Complete",message:"Your requested analysis has been completed and is ready for review."}};return{message:$,widgets:Z,action:z}}function eQ(X,$,Q,Z,z=30){let{message:H,widgets:G}=tQ(X),Y=H.split(" "),K=0,q=setInterval(()=>{try{if(K<Y.length)$({type:"token",content:Y[K]+" "}),K++;else{clearInterval(q),G.forEach((J)=>{$({type:"widget",widget:J})});let _=`mock_thread_${Date.now()}`;$({type:"complete"}),Q(_)}}catch(_){clearInterval(q),Z(_ instanceof Error?_:Error("Mock streaming error"))}},z)}function XZ(X){return new Promise(($,Q)=>{let Z=new FileReader;Z.onload=()=>{let H=Z.result.split(",")[1];$(H)},Z.onerror=()=>Q(Error("Failed to read file")),Z.readAsDataURL(X)})}function $Z(X){if(X.startsWith("image/"))return"image";return"document"}function QZ(X){return["image/jpeg","image/png","image/gif","image/webp","application/pdf","text/plain","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"].includes(X.type)}async function ZZ(X){let $=await XZ(X);return{type:$Z(X.type),source:{type:"base64",media_type:X.type,data:$}}}async function zZ(X){let $=Array.from(X);return await Promise.all($.map((Z)=>ZZ(Z)))}async function I$(X,$){if(!$||$.length===0)return X;let Q=[];if(X.trim())Q.push({type:"text",text:X.trim()});let Z=await zZ($);return Q.push(...Z),Q}function rX(X){if(X<1024)return`${X} B`;if(X<1048576)return`${(X/1024).toFixed(1)} KB`;return`${(X/1048576).toFixed(1)} MB`}var b$=10485760;function C$(X){if(!QZ(X))return{valid:!1,error:`Unsupported file type: ${X.type}`};if(X.size>b$)return{valid:!1,error:`File too large: ${rX(X.size)} (max ${rX(b$)})`};return{valid:!0}}var YZ=["list","table"];function JZ(X){let $=[],Q=!1,Z=X.match(/"items"\s*:\s*\[/);if(!Z)return{items:$,isStreaming:!1};let z=X.indexOf("[",Z.index);if(z===-1)return{items:$,isStreaming:!0};let H=0,G=!1,Y=!1,K=-1;for(let J=z+1;J<X.length;J++){let O=X[J];if(Y){Y=!1;continue}if(O==="\\"&&G){Y=!0;continue}if(O==='"'){G=!G;continue}if(G)continue;if(O==="{"){if(H===0)K=J;H++}else if(O==="}"){if(H--,H===0&&K!==-1){let B=X.slice(K,J+1);try{let V=JSON.parse(B);if(!V.id)V.id=`item-${$.length}-${H$(B)}`;$.push(V)}catch(V){}K=-1}}else if(O==="]"&&H===0){Q=!1;break}}if(H>0||K!==-1)Q=!0;let q=X.slice(z);if(G$(q,0)===-1)Q=!0;return{items:$,isStreaming:Q}}function H$(X){let $=0;for(let Q=0;Q<X.length;Q++){let Z=X.charCodeAt(Q);$=($<<5)-$+Z,$=$&$}return Math.abs($).toString(36)}function G$(X,$){let Q=0,Z=!1,z=!1;for(let H=$;H<X.length;H++){let G=X[H];if(z){z=!1;continue}if(G==="\\"&&Z){z=!0;continue}if(G==='"'){Z=!Z;continue}if(Z)continue;if(G==="["||G==="{")Q++;else if(G==="]"||G==="}"){if(Q--,Q===0)return H}}return-1}function dX(X){let $=[],Q=!1,Z=!1,z=0,H=null,G=X.replace(/<\/?ui\s*\/?>/gi,""),Y=X.lastIndexOf("@ui:");if(Y!==-1){let _=X.slice(Y),J=_.match(/^@ui:(\w+)/);if(J){let O=J[1],B=_.indexOf("[");if(B===-1)G=X.slice(0,Y),H=O,Z=!0;else{let V=Y+B;if(G$(X,V)===-1)if(YZ.includes(O)){let M=X.slice(V+1),{items:T,isStreaming:g}=JZ(M);if(T.length>0){G=X.slice(0,Y);let a=`widget-${O}-streaming-${H$(M)}`,t=G.replace(/[\s:;\-–—\.]+$/g,"").trim();if(t)$.push({type:"text",content:t});$.push({type:"widget",widget:{type:O,id:a,props:O==="table"?{rows:T,columns:[]}:{items:T},isStreaming:g}}),Q=!0,Z=!1,G=""}else G=X.slice(0,Y),H=O,Z=!0}else G=X.slice(0,Y),H=O,Z=!0}}}if(Z)G=G.replace(/[\s:;\-–—\.]+$/g,"");let K=/@ui:(\w+)\[/g,q;while((q=K.exec(G))!==null){let _=q[1],J=q.index+q[0].length-1,O=G$(G,J);if(O===-1)continue;let B=G.slice(J+1,O);if(q.index>z){let V=G.slice(z,q.index).trim();if(V)$.push({type:"text",content:V})}try{let V=B.trim(),A=JSON.parse(V),M=`widget-${_}-${H$(V)}`,{metadata:T,actions:g,...a}=A;$.push({type:"widget",widget:{type:_,id:M,props:a,...g&&{actions:g},...T&&{metadata:T}}}),Q=!0}catch(V){}z=O+1,K.lastIndex=z}if(z<G.length){let _=G.slice(z).trim();if(_)$.push({type:"text",content:_})}if($.length===0&&G.trim())$.push({type:"text",content:G.trim()});if(H)$.push({type:"widget_pending",pendingType:H});return{segments:$,hasWidgets:Q,hasPendingWidget:Z}}var U$={card:{schema:"title, description?, image?(url), footer?, actions?: [{type, label}]",example:'@ui:card[{"title": "Summary", "description": "Details here"}]'},list:{schema:"items: [{id, title, subtitle?, description?, image?(url), metadata?: {…}}], actions?: [{type, label}]",example:'@ui:list[{"items": [{"id": "1", "title": "Item", "subtitle": "Info", "metadata": {"key": "value"}}]}]'},button_group:{schema:'buttons: [{id, label, variant?: "default"|"primary"|"danger"}]',example:'@ui:button_group[{"buttons": [{"id": "ok", "label": "OK"}]}]'},form:{schema:'title?, fields: [{name, type: "text"|"password"|"number"|"select"|"checkbox"|"textarea"|"date", label, required?, placeholder?, options?: [{label, value}]}], submitLabel?: string',example:'@ui:form[{"title": "Settings", "fields": [{"name": "key", "type": "password", "label": "API Key", "required": true}]}]'},table:{schema:"columns: [{key, label}], rows: [{key: value, …}], striped?, compact?",example:'@ui:table[{"columns": [{"key": "name", "label": "Name"}], "rows": [{"name": "Alice"}]}]'},image:{schema:"src(url), alt, caption?",example:'@ui:image[{"src": "https://example.com/img.png", "alt": "Photo"}]'},chart:{schema:'chartType: "line"|"bar"|"pie", data: {labels: [...], datasets: [{label, data: [numbers]}]}',example:'@ui:chart[{"chartType": "bar", "data": {"labels": ["Q1", "Q2"], "datasets": [{"label": "Revenue", "data": [100, 150]}]}}]'},flow:{schema:'title, subtitle?, icon?: "research"|"schedule"|"analyze"|"deploy"|"recurring"|"automation"|"data", steps: [{id, label, color?: "blue"|"purple"|"cyan"|"amber"|"emerald"|"rose"|"indigo"|"orange", status?: "pending"|"active"|"completed"|"error"|"skipped"}]',example:'@ui:flow[{"title": "Pipeline", "steps": [{"id": "1", "label": "Test", "color": "cyan"}, {"id": "2", "label": "Deploy", "color": "rose"}]}]'}},HZ=Object.keys(U$),GZ=["flow"],f$=HZ.filter((X)=>!GZ.includes(X));function qZ(X){let $=X||f$,Q=`
|
|
7
|
+
## UI Widgets
|
|
8
|
+
|
|
9
|
+
You can render interactive UI widgets inline in your responses. Use them when structured display is clearer than plain text (showing data, forms, actions, images). You may include normal text before or after a widget.
|
|
10
|
+
|
|
11
|
+
**Syntax:** \`@ui:type[{json}]\` — the JSON object MUST be wrapped in square brackets \`[]\`.
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
@ui:list[{"items": [{"id": "1", "title": "First item"}]}]
|
|
15
|
+
|
|
16
|
+
Do NOT wrap widgets in code blocks or backticks. Write them directly in your response text.
|
|
17
|
+
|
|
18
|
+
### Available widgets
|
|
19
|
+
|
|
20
|
+
`;for(let Z of $){let z=U$[Z];if(!z)continue;Q+=`**${Z}** — ${z.schema}
|
|
21
|
+
`,Q+=` ${z.example}
|
|
22
|
+
|
|
23
|
+
`}return Q+='### Notes\n- **actions**: the `type` field is a custom string you choose (e.g. "edit", "delete"). It is returned to the app when the user clicks the button.\n- **metadata** on list items: any extra data attached to an item. Returned as the action payload when the user clicks that item.\n- **form**: always has a submit button (label defaults to "Submit"). When clicked, the form data is sent as a chat message automatically. Do NOT add a separate button_group for form submission.\n- **select fields**: `options` is an array of `{label, value}` objects.\n',Q}function KZ(X){let $=X||f$,Q=`
|
|
24
|
+
## UI Widgets
|
|
25
|
+
Render widgets inline: \`@ui:type[{json}]\` (square brackets required, no code blocks).
|
|
26
|
+
Use when structured display is clearer than plain text. Normal text can surround widgets.
|
|
27
|
+
|
|
28
|
+
`;for(let Z of $){let z=U$[Z];if(!z)continue;Q+=`**${Z}**: ${z.schema}
|
|
29
|
+
`}return Q+=`
|
|
30
|
+
actions.type = custom string returned on click. list metadata = payload on item click. form submit sends data as chat message automatically, no button_group needed.
|
|
31
|
+
`,Q}function j$(X){let $=[],Q=null;for(let Z=0;Z<X.length;Z++){let z=X[Z],H=z.created_at||z.timestamp?new Date(z.created_at||z.timestamp):new Date;if(typeof z.content==="string"){let G={id:z.id||`thread-msg-${Z}`,role:z.role,content:z.content,timestamp:H};$.push(G),Q=null}else if(Array.isArray(z.content)){if(z.role==="assistant"){let G=[],Y="";for(let q of z.content)if(q.type==="text"&&q.text)G.push({type:"text",content:q.text}),Y+=q.text;else if(q.type==="tool_use")G.push({type:"tool",id:q.id||`tool-${Z}-${G.length}`,name:q.name||"unknown",status:"completed"});let K={id:z.id||`thread-msg-${Z}`,role:"assistant",content:Y,timestamp:H,metadata:G.length>0?{content_segments:G}:void 0};$.push(K),Q=G}else if(z.role==="user")if(z.content.some((Y)=>Y.type==="tool_result")&&Q){for(let Y of z.content)if(Y.type==="tool_result"&&Y.tool_use_id){let K=Q.find((q)=>q.type==="tool"&&q.id===Y.tool_use_id);if(K&&K.type==="tool")K.result=typeof Y.content==="string"?Y.content:Array.isArray(Y.content)?Y.content.map((q)=>q.text||"").join(""):void 0,K.status=Y.is_error?"error":"completed"}}else{let Y=z.content.filter((K)=>K.type==="text").map((K)=>K.text||"").join("");if(Y)$.push({id:z.id||`thread-msg-${Z}`,role:"user",content:Y,timestamp:H});Q=null}}}return $}function UZ({widget:X,onAction:$}){let{title:Q,description:Z,image:z,footer:H}=X.props;return n0.jsxs("div",{className:"border border-neutral-200 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 overflow-hidden",children:[z&&n0.jsx("img",{src:z,alt:Q,className:"w-full h-48 object-cover"}),n0.jsxs("div",{className:"p-4",children:[n0.jsx("h3",{className:"!text-lg font-semibold !text-neutral-900 dark:!text-white",children:Q}),Z&&n0.jsx("p",{className:"!text-neutral-600 dark:!text-neutral-400 mt-2",children:Z})]}),(H||X.actions&&X.actions.length>0)&&n0.jsxs("div",{className:"border-t border-neutral-200 dark:border-neutral-700 p-4 flex justify-between items-center",children:[H&&n0.jsx("span",{className:"!text-sm !text-neutral-600 dark:!text-neutral-400",children:H}),X.actions&&X.actions.length>0&&n0.jsx("div",{className:"flex gap-2",children:X.actions.map((G,Y)=>n0.jsx("button",{onClick:()=>$?.({type:G.type,payload:G.payload,widgetId:X.id,timestamp:new Date}),className:"px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors bg-blue-500 !text-white hover:bg-blue-600",children:G.label},Y))})]})]})}function _Z({widget:X,onAction:$}){let{items:Q}=X.props,Z=X.isStreaming??!1,z=IX.useRef(new Set),[H,G]=IX.useState(new Set);return IX.useEffect(()=>{let Y=new Set(Q.map((q)=>q.id)),K=new Set;if(Q.forEach((q)=>{if(!z.current.has(q.id))K.add(q.id)}),Q.forEach((q)=>z.current.add(q.id)),K.size>0){G(K);let q=setTimeout(()=>{G(new Set)},500);return()=>clearTimeout(q)}},[Q]),S0.jsxs("div",{className:"border border-neutral-200 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 overflow-hidden",children:[Q.map((Y,K)=>{let q=H.has(Y.id),_=K===Q.length-1;return S0.jsxs("div",{className:`apteva-list-item flex items-center p-4 transition-colors ${!_||Z?"border-b border-neutral-200 dark:border-neutral-700":""} ${!Y.backgroundColor?"hover:bg-neutral-50 dark:hover:bg-neutral-800":""} ${q?"apteva-list-item-new":""}`,style:Y.backgroundColor?{backgroundColor:Y.backgroundColor}:void 0,children:[Y.image&&S0.jsx("img",{src:Y.image,alt:Y.title,className:"w-16 h-16 rounded object-cover"}),S0.jsxs("div",{className:`flex-1 ${Y.image?"ml-4":""}`,children:[S0.jsx("h4",{className:"font-semibold !text-neutral-900 dark:!text-white",children:Y.title}),Y.subtitle&&S0.jsx("p",{className:"!text-sm !text-neutral-600 dark:!text-neutral-400",children:Y.subtitle}),Y.description&&S0.jsx("p",{className:"!text-xs !text-neutral-500 dark:!text-neutral-500 mt-1",children:Y.description})]}),X.actions&&X.actions.length>0&&S0.jsx("div",{className:"flex gap-2",children:X.actions.map((J,O)=>S0.jsx("button",{onClick:()=>$?.({type:J.type,payload:Y.metadata||Y,widgetId:X.id,timestamp:new Date}),className:"px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors bg-blue-500 !text-white hover:bg-blue-600",children:J.label},O))})]},Y.id)}),Z&&S0.jsxs("div",{className:"apteva-list-streaming flex items-center gap-3 p-4 text-neutral-500 dark:text-neutral-400",children:[S0.jsxs("div",{className:"apteva-streaming-dots flex gap-1",children:[S0.jsx("span",{className:"w-2 h-2 bg-current rounded-full animate-pulse",style:{animationDelay:"0ms"}}),S0.jsx("span",{className:"w-2 h-2 bg-current rounded-full animate-pulse",style:{animationDelay:"150ms"}}),S0.jsx("span",{className:"w-2 h-2 bg-current rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),S0.jsx("span",{className:"text-sm",children:"Loading more..."})]})]})}function OZ({widget:X,onAction:$}){let{label:Q,variant:Z="primary",disabled:z=!1}=X.props;return x$.jsx("button",{onClick:()=>X.actions?.[0]&&$?.({type:X.actions[0].type,payload:X.actions[0].payload,widgetId:X.id,timestamp:new Date}),disabled:z,className:Y0("px-4 py-2 rounded-lg font-medium transition-colors",{primary:"bg-blue-500 !text-white hover:bg-blue-600",secondary:"bg-neutral-500 !text-white hover:bg-neutral-600",outline:"border-2 border-blue-500 !text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900",ghost:"!text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900"}[Z],{"opacity-50 cursor-not-allowed":z}),children:Q})}function VZ({widget:X,onAction:$}){let{layout:Q="horizontal",buttons:Z}=X.props,z={primary:"bg-blue-500 !text-white hover:bg-blue-600",secondary:"bg-neutral-200 dark:bg-neutral-700 !text-neutral-800 dark:!text-neutral-200 hover:bg-neutral-300 dark:hover:bg-neutral-600",outline:"border border-neutral-300 dark:border-neutral-600 !text-neutral-700 dark:!text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-800"},H=(G)=>{return X.actions?.find((Y)=>Y.payload?.buttonId===G)||X.actions?.[0]};return q$.jsx("div",{className:Y0("flex gap-2",Q==="vertical"?"flex-col":"flex-row flex-wrap"),children:Z.map((G)=>{let Y=H(G.id);return q$.jsx("button",{onClick:()=>{if(Y)$?.({type:Y.type,payload:{...Y.payload,buttonId:G.id},widgetId:X.id,timestamp:new Date})},className:Y0("px-4 py-2 rounded-lg font-medium transition-colors text-sm",z[G.variant||"secondary"]),children:G.label},G.id)})})}function BZ({widget:X,onAction:$}){let{columns:Q,rows:Z,caption:z,compact:H=!1,striped:G=!1}=X.props,Y=X.isStreaming??!1,K=bX.useRef(new Set),[q,_]=bX.useState(new Set);bX.useEffect(()=>{let O=new Set;if(Z.forEach((B,V)=>{let A=B.id||`row-${V}`;if(!K.current.has(A))O.add(A)}),Z.forEach((B,V)=>{let A=B.id||`row-${V}`;K.current.add(A)}),O.size>0){_(O);let B=setTimeout(()=>{_(new Set)},500);return()=>clearTimeout(B)}},[Z]);let J=(O)=>{switch(O){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}};return P0.jsx("div",{className:"border border-neutral-200 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 overflow-hidden",children:P0.jsx("div",{className:"overflow-x-auto",children:P0.jsxs("table",{className:"w-full",children:[z&&P0.jsx("caption",{className:"px-4 py-2 text-sm text-neutral-600 dark:text-neutral-400 text-left bg-neutral-50 dark:bg-neutral-800 border-b border-neutral-200 dark:border-neutral-700",children:z}),P0.jsx("thead",{children:P0.jsx("tr",{className:"bg-neutral-50 dark:bg-neutral-800 border-b border-neutral-200 dark:border-neutral-700",children:Q.map((O)=>P0.jsx("th",{className:Y0("font-semibold text-neutral-900 dark:text-white",H?"px-3 py-2 text-xs":"px-4 py-3 text-sm",J(O.align)),style:O.width?{width:O.width}:void 0,children:O.label},O.key))})}),P0.jsxs("tbody",{children:[Z.map((O,B)=>{let V=O.id||`row-${B}`,A=q.has(V);return P0.jsx("tr",{className:Y0("apteva-table-row border-b border-neutral-200 dark:border-neutral-700 last:border-b-0","transition-colors hover:bg-neutral-50 dark:hover:bg-neutral-800",G&&B%2===1&&"bg-neutral-50/50 dark:bg-neutral-800/50",A&&"apteva-table-row-new"),onClick:()=>{if(X.actions&&X.actions.length>0)$?.({type:X.actions[0].type,payload:O,widgetId:X.id,timestamp:new Date})},style:{cursor:X.actions?.length?"pointer":"default"},children:Q.map((M)=>P0.jsx("td",{className:Y0("text-neutral-700 dark:text-neutral-300",H?"px-3 py-2 text-xs":"px-4 py-3 text-sm",J(M.align)),children:O[M.key]??"—"},M.key))},V)}),Z.length===0&&!Y&&P0.jsx("tr",{children:P0.jsx("td",{colSpan:Q.length||1,className:"px-4 py-8 text-center text-sm text-neutral-500 dark:text-neutral-400",children:"No data available"})}),Y&&P0.jsx("tr",{className:"apteva-table-streaming",children:P0.jsx("td",{colSpan:Q.length||1,className:"px-4 py-3 text-center",children:P0.jsxs("div",{className:"flex items-center justify-center gap-3 text-neutral-500 dark:text-neutral-400",children:[P0.jsxs("div",{className:"flex gap-1",children:[P0.jsx("span",{className:"w-2 h-2 bg-current rounded-full animate-pulse",style:{animationDelay:"0ms"}}),P0.jsx("span",{className:"w-2 h-2 bg-current rounded-full animate-pulse",style:{animationDelay:"150ms"}}),P0.jsx("span",{className:"w-2 h-2 bg-current rounded-full animate-pulse",style:{animationDelay:"300ms"}})]}),P0.jsx("span",{className:"text-sm",children:"Loading more..."})]})})})]})]})})})}function g$({anchorRef:X,open:$,onClose:Q,width:Z,children:z}){let H=E0.useRef(null),[G,Y]=E0.useState(null),[K,q]=E0.useState("");if(E0.useEffect(()=>{if(!$||!X.current)return;let _=X.current.closest(".apteva-chat");if(_)if(_.classList.contains("apteva-force-light"))q("apteva-force-light");else if(_.classList.contains("apteva-force-dark"))q("apteva-force-dark");else q("")},[$,X]),E0.useEffect(()=>{if(!$||!X.current){Y(null);return}let _=()=>{let J=X.current.getBoundingClientRect();Y({top:J.bottom+window.scrollY+4,left:J.left+window.scrollX,width:J.width})};return _(),window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),()=>{window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_)}},[$,X]),E0.useEffect(()=>{if(!$)return;let _=(J)=>{let O=J.target;if(H.current&&!H.current.contains(O)&&X.current&&!X.current.contains(O))Q()};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[$,Q,X]),E0.useEffect(()=>{if(!$)return;let _=(J)=>{if(J.key==="Escape")Q()};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[$,Q]),!$||!G)return null;return u$.createPortal(y.jsx("div",{ref:H,className:`apteva-widget ${K}`,style:{position:"absolute",top:G.top,left:G.left,width:Z==="match"?G.width:void 0,zIndex:99999},children:z}),document.body)}function LZ({name:X,value:$,options:Q,placeholder:Z,required:z,onChange:H}){let[G,Y]=E0.useState(!1),K=E0.useRef(null),q=Q?.find((J)=>J.label===$||J.value===$),_=E0.useCallback(()=>Y(!1),[]);return y.jsxs("div",{className:"apteva-select relative",children:[y.jsxs("select",{name:X,value:$,required:z,onChange:()=>{},tabIndex:-1,className:"absolute inset-0 opacity-0 pointer-events-none","aria-hidden":!0,children:[y.jsx("option",{value:""}),Q?.map((J)=>y.jsx("option",{value:J.label,children:J.label},J.value))]}),y.jsxs("button",{ref:K,type:"button",onClick:()=>Y(!G),className:"apteva-select-trigger w-full flex items-center justify-between px-3 py-2 rounded-lg border transition-colors text-left",children:[y.jsx("span",{className:q?"apteva-select-value":"apteva-select-placeholder",children:q?q.label:Z||"Select..."}),y.jsx("svg",{className:`apteva-select-chevron w-4 h-4 flex-shrink-0 transition-transform ${G?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),y.jsx(g$,{anchorRef:K,open:G,onClose:_,width:"match",children:y.jsx("div",{className:"apteva-select-dropdown rounded-lg border shadow-lg overflow-hidden",children:y.jsxs("div",{className:"max-h-48 overflow-y-auto py-1",children:[Q?.map((J)=>y.jsx("button",{type:"button",onClick:()=>{H(J.label),_()},className:`apteva-select-option w-full text-left px-3 py-2 text-sm transition-colors ${$===J.label?"apteva-select-option-active":""}`,children:J.label},J.value)),(!Q||Q.length===0)&&y.jsx("div",{className:"px-3 py-2 text-sm apteva-select-placeholder",children:"No options"})]})})})]})}function DZ({name:X,value:$,placeholder:Q,required:Z,onChange:z}){let[H,G]=E0.useState(!1),Y=E0.useRef(null),K=E0.useCallback(()=>G(!1),[]),q=(N)=>{if(N){let[D,U0,n]=N.split("-").map(Number);return{year:D,month:U0-1,day:n}}let E=new Date;return{year:E.getFullYear(),month:E.getMonth(),day:0}},_=q($),[J,O]=E0.useState(_.year),[B,V]=E0.useState(_.month);E0.useEffect(()=>{if($){let N=q($);O(N.year),V(N.month)}},[$]);let A=new Date(J,B+1,0).getDate(),T=(new Date(J,B,1).getDay()+6)%7,g=()=>{if(B===0)V(11),O(J-1);else V(B-1)},a=()=>{if(B===11)V(0),O(J+1);else V(B+1)},t=(N)=>{let E=String(B+1).padStart(2,"0"),D=String(N).padStart(2,"0");z(`${J}-${E}-${D}`),K()},e=(N)=>{if(!N)return"";let[E,D,U0]=N.split("-");return`${U0}/${D}/${E}`},v=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],P=["Mo","Tu","We","Th","Fr","Sa","Su"],b=(N)=>{if(!$)return!1;let E=q($);return E.year===J&&E.month===B&&E.day===N},k=(N)=>{let E=new Date;return E.getFullYear()===J&&E.getMonth()===B&&E.getDate()===N};return y.jsxs("div",{className:"apteva-datepicker relative",children:[y.jsx("input",{type:"text",name:X,value:$,required:Z,onChange:()=>{},tabIndex:-1,className:"absolute inset-0 opacity-0 pointer-events-none","aria-hidden":!0}),y.jsxs("button",{ref:Y,type:"button",onClick:()=>G(!H),className:"apteva-datepicker-trigger w-full flex items-center justify-between px-3 py-2 rounded-lg border transition-colors text-left",children:[y.jsx("span",{className:$?"apteva-datepicker-value":"apteva-select-placeholder",children:$?e($):Q||"Select date..."}),y.jsx("svg",{className:"apteva-select-chevron w-4 h-4 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})]}),y.jsx(g$,{anchorRef:Y,open:H,onClose:K,width:"auto",children:y.jsxs("div",{className:"apteva-datepicker-dropdown rounded-lg border shadow-lg overflow-hidden",children:[y.jsxs("div",{className:"apteva-datepicker-header flex items-center justify-between px-3 py-2",children:[y.jsx("button",{type:"button",onClick:g,className:"apteva-datepicker-nav p-1 rounded transition-colors",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),y.jsxs("span",{className:"apteva-datepicker-title text-sm font-semibold",children:[v[B]," ",J]}),y.jsx("button",{type:"button",onClick:a,className:"apteva-datepicker-nav p-1 rounded transition-colors",children:y.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),y.jsx("div",{className:"grid grid-cols-7 px-2",children:P.map((N)=>y.jsx("div",{className:"apteva-datepicker-daylabel text-center text-xs font-medium py-1",children:N},N))}),y.jsxs("div",{className:"grid grid-cols-7 px-2 pb-2",children:[Array.from({length:T}).map((N,E)=>y.jsx("div",{},`empty-${E}`)),Array.from({length:A}).map((N,E)=>{let D=E+1,U0=b(D),n=k(D);return y.jsx("button",{type:"button",onClick:()=>t(D),className:["apteva-datepicker-day text-center text-sm py-1 rounded transition-colors",U0?"apteva-datepicker-day-selected":"",n&&!U0?"apteva-datepicker-day-today":""].join(" "),children:D},D)})]})]})})]})}function FZ({widget:X,onAction:$}){let{title:Q,fields:Z}=X.props,z=E0.useRef({}),[H,G]=E0.useState(()=>{let J={};return Z.forEach((O)=>{if(O.type==="file")J[O.name]=[];else J[O.name]=O.defaultValue??(O.type==="checkbox"?!1:"")}),J}),Y=E0.useCallback((J,O)=>{G((B)=>({...B,[J]:O}))},[]),K=(J)=>{if(J.preventDefault(),$)$({type:"submit",payload:{formData:H},widgetId:X.id,timestamp:new Date})},q=(J)=>{switch(J.type){case"text":case"password":case"number":return y.jsx("input",{type:J.type,name:J.name,value:H[J.name]||"",onChange:(B)=>Y(J.name,J.type==="number"?Number(B.target.value):B.target.value),placeholder:J.placeholder,required:J.required,className:"apteva-input w-full px-3 py-2 rounded-lg border transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"});case"date":return y.jsx(DZ,{name:J.name,value:H[J.name]||"",placeholder:J.placeholder,required:J.required,onChange:(B)=>Y(J.name,B)});case"textarea":return y.jsx("textarea",{name:J.name,value:H[J.name]||"",onChange:(B)=>Y(J.name,B.target.value),placeholder:J.placeholder,required:J.required,rows:3,className:"apteva-input w-full px-3 py-2 rounded-lg border transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"});case"select":return y.jsx(LZ,{name:J.name,value:H[J.name]||"",options:J.options,placeholder:J.placeholder,required:J.required,onChange:(B)=>Y(J.name,B)});case"checkbox":return y.jsxs("label",{className:"apteva-checkbox flex items-center gap-2 cursor-pointer",children:[y.jsx("input",{type:"checkbox",name:J.name,checked:H[J.name]||!1,onChange:(B)=>Y(J.name,B.target.checked),className:"w-4 h-4 rounded"}),y.jsx("span",{children:J.label})]});case"file":{let B=H[J.name]||[];return y.jsxs("div",{className:"space-y-2",children:[y.jsx("input",{ref:(V)=>{z.current[J.name]=V},type:"file",name:J.name,multiple:J.multiple??!0,accept:J.accept,onChange:(V)=>{let A=Array.from(V.target.files||[]);if(J.multiple!==!1)Y(J.name,[...B,...A]);else Y(J.name,A);if(z.current[J.name])z.current[J.name].value=""},className:"hidden"}),y.jsx("button",{type:"button",onClick:()=>z.current[J.name]?.click(),className:"apteva-file-drop w-full px-3 py-3 rounded-lg border-2 border-dashed transition-colors cursor-pointer !text-sm",children:J.placeholder||"Click to add files"}),B.length>0&&y.jsx("ul",{className:"space-y-1",children:B.map((V,A)=>y.jsxs("li",{className:"apteva-file-item-row flex items-center justify-between px-2 py-1.5 rounded-lg !text-sm",children:[y.jsxs("span",{className:"truncate mr-2",children:[V.name,y.jsxs("span",{className:"ml-1",style:{opacity:0.6},children:["(",(V.size/1024).toFixed(0)," KB)"]})]}),y.jsx("button",{type:"button",onClick:()=>Y(J.name,B.filter((M,T)=>T!==A)),className:"apteva-file-remove-btn transition-colors flex-shrink-0",children:"✕"})]},`${V.name}-${A}`))})]})}default:return null}},_=X.props.submitLabel||X.actions?.find((J)=>J.type==="submit")?.label||X.actions?.[0]?.label||"Submit";return y.jsxs("form",{onSubmit:K,className:"border rounded-xl overflow-hidden",children:[y.jsxs("div",{className:"p-4",children:[Q&&y.jsx("h3",{className:"!text-lg font-semibold mb-4",children:Q}),y.jsx("div",{className:"space-y-3",children:Z.map((J)=>y.jsxs("div",{className:J.type==="checkbox"?"":"space-y-1",children:[J.type!=="checkbox"&&y.jsxs("label",{className:"apteva-field-label block !text-sm font-medium",children:[J.label,J.required&&y.jsx("span",{style:{color:"var(--aw-danger)"},className:"ml-1",children:"*"})]}),q(J)]},J.name))})]}),y.jsx("div",{className:"px-4 pb-4",children:y.jsx("button",{type:"submit",className:"px-3 py-1.5 !text-sm rounded-lg font-medium transition-colors",children:_})})]})}function WZ({widget:X}){let{src:$,alt:Q,caption:Z}=X.props;return uX.jsxs("figure",{className:"overflow-hidden rounded-xl",children:[uX.jsx("img",{src:$,alt:Q,className:"w-full h-auto object-contain bg-neutral-100 dark:bg-neutral-800",loading:"lazy"}),Z&&uX.jsx("figcaption",{className:"mt-2 text-center text-sm text-neutral-600 dark:text-neutral-400",children:Z})]})}function NZ({type:X,status:$}){if($==="completed")return W.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M5 13l4 4L19 7"})});if($==="error")return W.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M6 18L18 6M6 6l12 12"})});if($==="active")return W.jsx("div",{className:"w-3.5 h-3.5 rounded-full bg-current animate-pulse"});let Q="w-4 h-4";if(X==="time"||X==="schedule"||X==="clock")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})});if(X==="recurring"||X==="repeat")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})});if(X==="agent"||X?.startsWith("@"))return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"})});if(X==="email"||X==="mail")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})});if(X==="slack"||X==="message"||X==="chat")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})});if(X==="webhook"||X==="api")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})});if(X==="build"||X==="compile"||X==="package")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})});if(X==="test"||X==="check"||X==="verify")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})});if(X==="deploy"||X==="rocket"||X==="launch")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})});if(X==="push"||X==="upload"||X==="cloud")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})});if(X==="generate"||X==="create"||X==="document"||X==="file")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})});if(X==="review"||X==="inspect"||X==="eye")return W.jsxs("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]});if(X==="analyze"||X==="research"||X==="chart")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})});if(X==="scrape"||X==="crawl"||X==="spider")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})});if(X==="data"||X==="database"||X==="storage")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"})});if(X==="notification"||X==="bell"||X==="alert")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"})});if(X==="transform"||X==="process"||X==="convert")return W.jsx("svg",{className:Q,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})});return W.jsx("div",{className:"w-2 h-2 rounded-full bg-current opacity-50"})}function AZ({icon:X}){if(X==="research"||X==="multi-agent"||X==="agents")return W.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-100 dark:bg-purple-500/20 flex items-center justify-center",children:W.jsx("svg",{className:"w-6 h-6 text-purple-600 dark:text-purple-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})});if(X==="schedule"||X==="report"||X==="calendar")return W.jsx("div",{className:"w-10 h-10 rounded-lg bg-amber-100 dark:bg-amber-500/20 flex items-center justify-center",children:W.jsx("svg",{className:"w-6 h-6 text-amber-600 dark:text-amber-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})});if(X==="recurring"||X==="repeat"||X==="sync")return W.jsx("div",{className:"w-10 h-10 rounded-lg bg-cyan-100 dark:bg-cyan-500/20 flex items-center justify-center",children:W.jsx("svg",{className:"w-6 h-6 text-cyan-600 dark:text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})});if(X==="analyze"||X==="analysis"||X==="chart")return W.jsx("div",{className:"w-10 h-10 rounded-lg bg-cyan-100 dark:bg-cyan-500/20 flex items-center justify-center",children:W.jsx("svg",{className:"w-6 h-6 text-cyan-600 dark:text-cyan-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})});if(X==="deploy"||X==="rocket"||X==="launch")return W.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center",children:W.jsx("svg",{className:"w-6 h-6 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})});if(X==="automation"||X==="workflow"||X==="process")return W.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 dark:bg-indigo-500/20 flex items-center justify-center",children:W.jsx("svg",{className:"w-6 h-6 text-indigo-600 dark:text-indigo-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z"})})});if(X==="data"||X==="pipeline"||X==="etl")return W.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-100 dark:bg-emerald-500/20 flex items-center justify-center",children:W.jsx("svg",{className:"w-6 h-6 text-emerald-600 dark:text-emerald-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4"})})});return W.jsx("div",{className:"w-10 h-10 rounded-lg bg-neutral-100 dark:bg-neutral-700 flex items-center justify-center",children:W.jsx("svg",{className:"w-6 h-6 text-neutral-600 dark:text-neutral-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})})}function EZ(){return W.jsx("svg",{className:"w-4 h-4 text-neutral-400 dark:text-neutral-500 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:W.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}var r0={blue:"bg-blue-100 dark:bg-blue-900/40 !text-blue-700 dark:!text-blue-300 border-blue-300 dark:border-blue-500",purple:"bg-purple-100 dark:bg-purple-900/40 !text-purple-700 dark:!text-purple-300 border-purple-300 dark:border-purple-500",cyan:"bg-cyan-100 dark:bg-cyan-900/40 !text-cyan-700 dark:!text-cyan-300 border-cyan-300 dark:border-cyan-500",amber:"bg-amber-100 dark:bg-amber-900/40 !text-amber-700 dark:!text-amber-300 border-amber-300 dark:border-amber-500",emerald:"bg-emerald-100 dark:bg-emerald-900/40 !text-emerald-700 dark:!text-emerald-300 border-emerald-300 dark:border-emerald-500",rose:"bg-rose-100 dark:bg-rose-900/40 !text-rose-700 dark:!text-rose-300 border-rose-300 dark:border-rose-500",indigo:"bg-indigo-100 dark:bg-indigo-900/40 !text-indigo-700 dark:!text-indigo-300 border-indigo-300 dark:border-indigo-500",orange:"bg-orange-100 dark:bg-orange-900/40 !text-orange-700 dark:!text-orange-300 border-orange-300 dark:border-orange-500",neutral:"bg-neutral-100 dark:bg-neutral-800 !text-neutral-600 dark:!text-neutral-300 border-neutral-300 dark:border-neutral-600"};function PZ(X,$){if(X.color&&r0[X.color])return r0[X.color];if($==="time"||$==="schedule"||$==="clock")return r0.blue;if($==="agent"||$?.startsWith("@"))return r0.purple;if($==="email"||$==="slack"||$==="message"||$==="notification")return r0.cyan;if($==="generate"||$==="document"||$==="create")return r0.amber;if($==="deploy"||$==="rocket"||$==="launch")return r0.rose;if($==="build"||$==="compile"||$==="package")return r0.indigo;if($==="test"||$==="check"||$==="verify")return r0.emerald;if($==="data"||$==="database"||$==="storage")return r0.orange;return r0.blue}function MZ({widget:X}){let{title:$,subtitle:Q,icon:Z,steps:z}=X.props;return W.jsxs("div",{className:"rounded-xl bg-white dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-700 overflow-hidden",children:[W.jsxs("div",{className:"px-4 py-4 flex items-center gap-4",children:[W.jsx(AZ,{icon:Z}),W.jsxs("div",{className:"flex-1 min-w-0",children:[W.jsx("h3",{className:"font-semibold text-base text-neutral-900 dark:text-white truncate",children:$}),Q&&W.jsx("p",{className:"text-sm text-neutral-500 dark:text-neutral-400 truncate mt-0.5",children:Q})]})]}),W.jsx("div",{className:"px-4 pb-4",children:W.jsx("div",{className:"flex flex-wrap items-center gap-2",children:z.map((H,G)=>{let Y=G===z.length-1,K=H.status==="active",q=H.status==="completed",_=H.status==="error",J=H.status==="skipped",O=H.label,B=H.type;if(!B)if(O.startsWith("@"))B="agent";else if(/^\d+[ap]m$/i.test(O)||/^(mon|tue|wed|thu|fri|sat|sun)/i.test(O))B="time";else{let M=O.toLowerCase();B={test:"test",build:"build",push:"push",deploy:"deploy",email:"email",slack:"slack",generate:"generate",review:"review",analyze:"analyze",scrape:"scrape",transform:"transform",notify:"notification",alert:"notification",webhook:"webhook",api:"api",data:"data",process:"process"}[M]}let V,A="";if(K)V="bg-blue-100 dark:bg-blue-900/40 !text-blue-700 dark:!text-blue-300 border-blue-400 dark:border-blue-400 ring-2 ring-blue-400";else if(q)V="bg-emerald-100 dark:bg-emerald-900/40 !text-emerald-700 dark:!text-emerald-300 border-emerald-400 dark:border-emerald-400";else if(_)V="bg-red-100 dark:bg-red-900/40 !text-red-700 dark:!text-red-300 border-red-400 dark:border-red-400";else if(J)V="bg-neutral-100 dark:bg-neutral-800 !text-neutral-400 dark:!text-neutral-500 border-neutral-300 dark:border-neutral-600",A="line-through";else V=PZ(H,B);return W.jsxs("div",{className:"flex items-center gap-2",children:[W.jsxs("span",{className:`inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium border transition-colors ${V} ${A}`,children:[W.jsx(NZ,{type:B,status:H.status}),O]}),!Y&&W.jsx(EZ,{})]},H.id)})})})]})}var RZ={up:{symbol:"↑",color:"text-emerald-500"},down:{symbol:"↓",color:"text-red-500"},flat:{symbol:"→",color:"text-neutral-400"}};function TZ({widget:X,onAction:$}){let{title:Q,label:Z="",value:z="",change:H,trend:G}=X.props||{},Y=G?RZ[G]:null;return u0.jsxs("div",{className:"border border-neutral-200 dark:border-neutral-700 rounded-xl bg-white dark:bg-neutral-900 p-5",children:[Q&&u0.jsx("h3",{className:"!text-base font-semibold !text-neutral-900 dark:!text-white mb-3",children:Q}),u0.jsx("div",{className:"!text-sm font-medium !text-neutral-500 dark:!text-neutral-400 mb-1",children:Z}),u0.jsxs("div",{className:"flex items-end gap-2",children:[u0.jsx("div",{className:"apteva-kpi-value !text-2xl font-bold !text-neutral-900 dark:!text-white",children:z}),H&&Y&&u0.jsxs("div",{className:`flex items-center gap-0.5 !text-sm font-medium ${Y.color} mb-0.5`,children:[u0.jsx("span",{children:Y.symbol}),u0.jsx("span",{children:H})]}),H&&!Y&&u0.jsx("div",{className:"!text-sm font-medium !text-neutral-400 mb-0.5",children:H})]}),X.actions&&X.actions.length>0&&u0.jsx("div",{className:"flex gap-2 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700",children:X.actions.map((K,q)=>u0.jsx("button",{onClick:()=>$?.({type:K.type,payload:K.payload,widgetId:X.id,timestamp:new Date}),className:"px-2 py-1 !text-xs rounded font-medium transition-colors bg-neutral-100 dark:bg-neutral-800 !text-neutral-600 dark:!text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700",children:K.label},q))})]})}function IZ({widget:X}){let{content:$="",variant:Q="body"}=X.props||{},Z={heading:"!text-xl font-bold !text-neutral-900 dark:!text-white",body:"!text-sm !text-neutral-700 dark:!text-neutral-300 leading-relaxed",caption:"!text-xs !text-neutral-500 dark:!text-neutral-400"},z=(G)=>{let Y=G.split(`
|
|
32
|
+
`),K=[],q=0;while(q<Y.length){let _=Y[q];if(_.startsWith("### "))K.push(x0.jsx("h3",{className:"!text-base font-semibold !text-neutral-900 dark:!text-white mt-3 mb-1",children:H(_.slice(4))},q));else if(_.startsWith("## "))K.push(x0.jsx("h2",{className:"!text-lg font-bold !text-neutral-900 dark:!text-white mt-4 mb-1",children:H(_.slice(3))},q));else if(/^[-*+]\s/.test(_)){let J=[];while(q<Y.length&&/^[-*+]\s/.test(Y[q]))J.push(x0.jsx("li",{className:"ml-4 list-disc",children:H(Y[q].slice(2))},q)),q++;K.push(x0.jsx("ul",{className:"my-1 space-y-0.5",children:J},`list-${q}`));continue}else if(_.trim()==="")K.push(x0.jsx("div",{className:"h-2"},q));else K.push(x0.jsx("p",{className:"my-0.5",children:H(_)},q));q++}return K},H=(G)=>{let Y=[],K=G,q=0;while(K.length>0){let _=K.match(/\*\*(.+?)\*\*/),J=K.match(/`(.+?)`/),O=K.match(/\[(.+?)\]\((.+?)\)/),B=[_?{type:"bold",index:_.index,match:_}:null,J?{type:"code",index:J.index,match:J}:null,O?{type:"link",index:O.index,match:O}:null].filter(Boolean).sort((A,M)=>A.index-M.index);if(B.length===0){Y.push(K);break}let V=B[0];if(V.index>0)Y.push(K.slice(0,V.index));if(V.type==="bold")Y.push(x0.jsx("strong",{className:"font-semibold",children:V.match[1]},q++)),K=K.slice(V.index+V.match[0].length);else if(V.type==="code")Y.push(x0.jsx("code",{className:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded text-xs font-mono",children:V.match[1]},q++)),K=K.slice(V.index+V.match[0].length);else if(V.type==="link")Y.push(x0.jsx("a",{href:V.match[2],className:"text-blue-500 hover:underline",target:"_blank",rel:"noopener noreferrer",children:V.match[1]},q++)),K=K.slice(V.index+V.match[0].length)}return Y.length===1?Y[0]:x0.jsx(x0.Fragment,{children:Y})};return x0.jsx("div",{className:Z[Q]||Z.body,children:z($)})}var iX={sm:"h-2",md:"h-4",lg:"h-8"};function bZ({widget:X}){let{height:$="md",variant:Q="space"}=X.props||{};if(Q==="line")return oX.jsx("div",{className:iX[$]||iX.md+" flex items-center",children:oX.jsx("hr",{className:"w-full border-neutral-200 dark:border-neutral-700"})});return oX.jsx("div",{className:iX[$]||iX.md})}function vZ({widget:X}){let{src:$,title:Q,height:Z,aspectRatio:z="16/9",allowFullscreen:H=!0,sandbox:G,allow:Y,refreshInterval:K,showToolbar:q=!0}=X.props,_=d0.useRef(null),[J,O]=d0.useState(!0),[B,V]=d0.useState(!1),[A,M]=d0.useState(0),T=d0.useCallback(()=>{O(!0),V(!1),M((v)=>v+1)},[]),g=d0.useCallback(()=>{_.current?.requestFullscreen?.()},[]),a=d0.useCallback(()=>{window.open($,"_blank","noopener,noreferrer")},[$]);d0.useEffect(()=>{if(!K||K<=0)return;let v=setInterval(T,K*1000);return()=>clearInterval(v)},[K,T]);let t={"16/9":"56.25%","4/3":"75%","1/1":"100%"},e=!!Z;return G0.jsxs("div",{className:"rounded-xl overflow-hidden border border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900",children:[q&&G0.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-neutral-100 dark:bg-neutral-800 border-b border-neutral-200 dark:border-neutral-700",children:[G0.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[G0.jsx("div",{className:Y0("w-2 h-2 rounded-full flex-shrink-0",B?"bg-red-500":J?"bg-amber-500 animate-pulse":"bg-emerald-500")}),G0.jsx("span",{className:"text-sm font-medium text-neutral-700 dark:text-neutral-300 truncate",children:Q||"Live View"})]}),G0.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[G0.jsx("button",{onClick:T,className:"p-1.5 rounded-md text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",title:"Refresh",children:G0.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:G0.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),G0.jsx("button",{onClick:a,className:"p-1.5 rounded-md text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",title:"Open in new tab",children:G0.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:G0.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),H&&G0.jsx("button",{onClick:g,className:"p-1.5 rounded-md text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",title:"Fullscreen",children:G0.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:G0.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5v-4m0 4h-4m4 0l-5-5"})})})]})]}),G0.jsxs("div",{className:"relative bg-white dark:bg-neutral-950",style:e?{height:Z}:{paddingBottom:t[z]||t["16/9"]},children:[J&&G0.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-900 z-10",children:G0.jsxs("div",{className:"flex flex-col items-center gap-2",children:[G0.jsx("div",{className:"w-6 h-6 border-2 border-neutral-300 dark:border-neutral-600 border-t-blue-500 rounded-full animate-spin"}),G0.jsx("span",{className:"text-xs text-neutral-500",children:"Loading..."})]})}),B&&G0.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-900 z-10",children:G0.jsxs("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[G0.jsx("svg",{className:"w-8 h-8 text-neutral-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:G0.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"})}),G0.jsx("span",{className:"text-sm text-neutral-500",children:"Failed to load"}),G0.jsx("button",{onClick:T,className:"text-xs text-blue-500 hover:text-blue-600 underline",children:"Try again"})]})}),G0.jsx("iframe",{ref:_,src:$,title:Q||"Live View",className:Y0("border-0 bg-white dark:bg-neutral-950",e?"w-full h-full":"absolute inset-0 w-full h-full"),allowFullScreen:H,sandbox:G,allow:Y,onLoad:()=>O(!1),onError:()=>{O(!1),V(!0)}},A)]})]})}function nX({widget:X,onAction:$}){return k0.jsx("div",{className:"apteva-widget",children:(()=>{switch(X.type){case"card":return k0.jsx(UZ,{widget:X,onAction:$});case"list":return k0.jsx(_Z,{widget:X,onAction:$});case"button":return k0.jsx(OZ,{widget:X,onAction:$});case"button_group":return k0.jsx(VZ,{widget:X,onAction:$});case"table":return k0.jsx(BZ,{widget:X,onAction:$});case"form":return k0.jsx(FZ,{widget:X,onAction:$});case"image":return k0.jsx(WZ,{widget:X});case"flow":return k0.jsx(MZ,{widget:X});case"kpi":return k0.jsx(TZ,{widget:X,onAction:$});case"text_block":return k0.jsx(IZ,{widget:X});case"spacer":return k0.jsx(bZ,{widget:X});case"live_view":return k0.jsx(vZ,{widget:X});default:return k0.jsxs("div",{className:"p-4 border border-yellow-300 bg-yellow-50 rounded-lg",children:[k0.jsxs("p",{className:"text-sm text-yellow-800",children:["Unknown widget type: ",X.type]}),k0.jsx("pre",{className:"text-xs mt-2 overflow-auto",children:JSON.stringify(X,null,2)})]})}})()})}function kZ({widgets:X,onAction:$,onWidgetMount:Q,layout:Z="stack",spacing:z="normal",columns:H=3,className:G}){h$.useEffect(()=>{X.forEach((q)=>{Q?.(q.id)})},[X,Q]);let Y={stack:"flex flex-col",grid:`grid grid-cols-1 md:grid-cols-${H}`,masonry:"columns-1 md:columns-2 lg:columns-3"},K={tight:"gap-2",normal:"gap-4",loose:"gap-6"};return K$.jsx("div",{className:Y0(Y[Z],K[z],G),children:X.map((q)=>K$.jsx(nX,{widget:q,onAction:$},q.id))})}function v$({type:X,className:$}){switch(X){case"card":return C.jsx("div",{className:Y0("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden",$),children:C.jsxs("div",{className:"p-4 space-y-3",children:[C.jsx("div",{className:"h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-3/4"}),C.jsx("div",{className:"h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-full"}),C.jsx("div",{className:"h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-5/6"})]})});case"list":return C.jsx("div",{className:Y0("apteva-widget-skeleton animate-pulse space-y-2",$),children:[1,2,3].map((Q)=>C.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border border-neutral-200 dark:border-neutral-800",children:[C.jsx("div",{className:"w-10 h-10 bg-neutral-200 dark:bg-neutral-700 rounded-full flex-shrink-0"}),C.jsxs("div",{className:"flex-1 space-y-2",children:[C.jsx("div",{className:"h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2"}),C.jsx("div",{className:"h-2 bg-neutral-200 dark:bg-neutral-700 rounded w-3/4"})]})]},Q))});case"button_group":return C.jsxs("div",{className:Y0("apteva-widget-skeleton animate-pulse flex gap-2",$),children:[C.jsx("div",{className:"h-9 bg-neutral-200 dark:bg-neutral-700 rounded-lg w-20"}),C.jsx("div",{className:"h-9 bg-neutral-200 dark:bg-neutral-700 rounded-lg w-20"}),C.jsx("div",{className:"h-9 bg-neutral-200 dark:bg-neutral-700 rounded-lg w-20"})]});case"form":return C.jsxs("div",{className:Y0("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 p-4 space-y-4",$),children:[C.jsx("div",{className:"h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/3"}),C.jsxs("div",{className:"space-y-3",children:[C.jsx("div",{className:"h-10 bg-neutral-200 dark:bg-neutral-700 rounded"}),C.jsx("div",{className:"h-10 bg-neutral-200 dark:bg-neutral-700 rounded"})]}),C.jsx("div",{className:"h-9 bg-neutral-200 dark:bg-neutral-700 rounded w-24"})]});case"chart":return C.jsxs("div",{className:Y0("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 p-4",$),children:[C.jsx("div",{className:"h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/4 mb-4"}),C.jsxs("div",{className:"flex items-end gap-2 h-32",children:[C.jsx("div",{className:"flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-1/2"}),C.jsx("div",{className:"flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-3/4"}),C.jsx("div",{className:"flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-1/3"}),C.jsx("div",{className:"flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-full"}),C.jsx("div",{className:"flex-1 bg-neutral-200 dark:bg-neutral-700 rounded-t h-2/3"})]})]});case"image":return C.jsx("div",{className:Y0("apteva-widget-skeleton animate-pulse",$),children:C.jsx("div",{className:"aspect-video bg-neutral-200 dark:bg-neutral-700 rounded-lg"})});case"gallery":return C.jsx("div",{className:Y0("apteva-widget-skeleton animate-pulse grid grid-cols-3 gap-2",$),children:[1,2,3].map((Q)=>C.jsx("div",{className:"aspect-square bg-neutral-200 dark:bg-neutral-700 rounded-lg"},Q))});case"map":return C.jsx("div",{className:Y0("apteva-widget-skeleton animate-pulse",$),children:C.jsx("div",{className:"h-48 bg-neutral-200 dark:bg-neutral-700 rounded-lg flex items-center justify-center",children:C.jsxs("svg",{className:"w-8 h-8 text-neutral-400 dark:text-neutral-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"}),C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 11a3 3 0 11-6 0 3 3 0 016 0z"})]})})});case"table":return C.jsxs("div",{className:Y0("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden",$),children:[C.jsxs("div",{className:"flex bg-neutral-100 dark:bg-neutral-800 border-b border-neutral-200 dark:border-neutral-700",children:[C.jsx("div",{className:"flex-1 px-4 py-3",children:C.jsx("div",{className:"h-3 bg-neutral-300 dark:bg-neutral-600 rounded w-16"})}),C.jsx("div",{className:"flex-1 px-4 py-3",children:C.jsx("div",{className:"h-3 bg-neutral-300 dark:bg-neutral-600 rounded w-20"})}),C.jsx("div",{className:"flex-1 px-4 py-3",children:C.jsx("div",{className:"h-3 bg-neutral-300 dark:bg-neutral-600 rounded w-14"})})]}),[1,2,3].map((Q)=>C.jsxs("div",{className:"flex border-b border-neutral-200 dark:border-neutral-800 last:border-b-0",children:[C.jsx("div",{className:"flex-1 px-4 py-3",children:C.jsx("div",{className:"h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-24"})}),C.jsx("div",{className:"flex-1 px-4 py-3",children:C.jsx("div",{className:"h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-16"})}),C.jsx("div",{className:"flex-1 px-4 py-3",children:C.jsx("div",{className:"h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-20"})})]},Q))]});default:return C.jsxs("div",{className:Y0("apteva-widget-skeleton animate-pulse rounded-lg border border-neutral-200 dark:border-neutral-800 p-4",$),children:[C.jsx("div",{className:"h-4 bg-neutral-200 dark:bg-neutral-700 rounded w-1/2 mb-2"}),C.jsx("div",{className:"h-3 bg-neutral-200 dark:bg-neutral-700 rounded w-full"})]})}}function wZ(X){return/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)(\?.*)?$/i.test(X)}function DX(X,$=""){let Q=[],Z=/!\[([^\]]*)\]\(([^)]+)\)|\[([^\]]+)\]\(([^)]+)\)|(\*\*|__)(.+?)\5|`([^`]+)`/g,z=0,H,G=0;while((H=Z.exec(X))!==null){if(H.index>z)Q.push(X.slice(z,H.index));if(H[1]!==void 0||H[2]!==void 0){let Y=H[1]||"",K=H[2];Q.push(W0.jsx("img",{src:K,alt:Y,className:"apteva-md-img"},`${$}img${G++}`))}else if(H[3]!==void 0||H[4]!==void 0){let Y=H[3],K=H[4];if(wZ(K))Q.push(W0.jsx("img",{src:K,alt:Y,className:"apteva-md-img"},`${$}img${G++}`));else Q.push(W0.jsx("a",{href:K,target:"_blank",rel:"noopener noreferrer",className:"apteva-md-link",children:Y},`${$}a${G++}`))}else if(H[5]!==void 0)Q.push(W0.jsx("strong",{children:H[6]},`${$}b${G++}`));else if(H[7]!==void 0)Q.push(W0.jsx("code",{className:"apteva-md-inline-code",children:H[7]},`${$}code${G++}`));z=H.index+H[0].length}if(z<X.length)Q.push(X.slice(z));return Q.length>0?Q:[X]}function SZ(X){let $=X.split(`
|
|
33
|
+
`),Q=[],Z=0,z=0;while(z<$.length){let H=$[z],G=H.match(/^##\s+(.*)$/);if(G){Q.push(W0.jsx("h2",{className:"apteva-md-h2",children:DX(G[1],`${Z}`)},`h2${Z++}`)),z++;continue}let Y=H.match(/^###\s+(.*)$/);if(Y){Q.push(W0.jsx("h3",{className:"apteva-md-h3",children:DX(Y[1],`${Z}`)},`h3${Z++}`)),z++;continue}let K=H.match(/^(\s*)([-*+])\s+(.*)$/);if(K){let J=[],O=K[1].length;while(z<$.length){let B=$[z].match(/^(\s*)([-*+])\s+(.*)$/);if(B&&B[1].length===O)J.push(W0.jsx("li",{className:"apteva-md-li",children:DX(B[3],`${Z}`)},`li${Z++}`)),z++;else break}Q.push(W0.jsx("ul",{className:"apteva-md-ul",children:J},`ul${Z++}`));continue}let q=H.match(/^(\s*)(\d+)\.\s+(.*)$/);if(q){let J=[],O=q[1].length;while(z<$.length){let B=$[z].match(/^(\s*)(\d+)\.\s+(.*)$/);if(B&&B[1].length===O)J.push(W0.jsx("li",{className:"apteva-md-li",children:DX(B[3],`${Z}`)},`li${Z++}`)),z++;else break}Q.push(W0.jsx("ol",{className:"apteva-md-ol",children:J},`ol${Z++}`));continue}if(H.match(/^\|(.+)\|$/)&&z+1<$.length){if($[z+1].match(/^\|([\s:-]+\|)+$/)){let B=H.split("|").filter((A)=>A.trim()!=="").map((A)=>A.trim());z+=2;let V=[];while(z<$.length)if($[z].match(/^\|(.+)\|$/)){let M=$[z].split("|").filter((T)=>T.trim()!=="").map((T)=>T.trim());V.push(M),z++}else break;Q.push(W0.jsx("div",{className:"apteva-md-table-wrapper",children:W0.jsxs("table",{className:"apteva-md-table",children:[W0.jsx("thead",{children:W0.jsx("tr",{children:B.map((A,M)=>W0.jsx("th",{className:"apteva-md-th",children:DX(A,`th${Z}${M}`)},`th${M}`))})}),W0.jsx("tbody",{children:V.map((A,M)=>W0.jsx("tr",{children:A.map((T,g)=>W0.jsx("td",{className:"apteva-md-td",children:DX(T,`td${Z}${M}${g}`)},`td${g}`))},`tr${M}`))})]})},`table-wrapper${Z++}`));continue}}if(H==="")Q.push(W0.jsx("br",{},`br${Z++}`));else Q.push(W0.jsxs("span",{children:[DX(H,`${Z}`),z<$.length-1?`
|
|
34
|
+
`:""]},`p${Z++}`));z++}return Q}function QX({content:X,className:$=""}){let Q=X.replace(/<\/?ui\s*\/?>/gi,"");return W0.jsx("div",{className:`apteva-md ${$}`,children:SZ(Q)})}function k$({name:X,status:$,isReceiving:Q=!1,inputLength:Z=0,streamOutput:z,variant:H="card"}){if(H==="inline"){let G=$==="preparing"?`${X} preparing...`:$==="running"?z?`${X} · ${z}`:`${X}...`:$==="error"?`${X} failed`:X;return p.jsxs("div",{className:"apteva-tool-inline",children:[p.jsx("div",{className:"apteva-tool-inline-line"}),p.jsxs("div",{className:"apteva-tool-inline-content",children:[$==="running"||$==="preparing"?p.jsxs("svg",{className:"apteva-tool-inline-icon apteva-tool-icon-spin",width:"14",height:"14",fill:"none",viewBox:"0 0 24 24",children:[p.jsx("circle",{className:"apteva-tool-spinner-track",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),p.jsx("path",{className:"apteva-tool-spinner-fill",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):p.jsx("svg",{className:"apteva-tool-inline-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:p.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",fill:"currentColor"})}),p.jsx("span",{className:"apteva-tool-inline-text",children:G})]}),p.jsx("div",{className:"apteva-tool-inline-line"})]})}if($==="preparing")return p.jsxs("div",{className:"apteva-tool-card apteva-tool-card-preparing",children:[p.jsxs("svg",{className:"apteva-tool-icon apteva-tool-icon-spin",fill:"none",viewBox:"0 0 24 24",children:[p.jsx("circle",{className:"apteva-tool-spinner-track",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),p.jsx("path",{className:"apteva-tool-spinner-fill",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),p.jsxs("span",{className:"apteva-tool-label",children:[p.jsx("strong",{children:X}),p.jsx("span",{className:"apteva-tool-status-text",children:" preparing..."})]})]});if($==="running")return p.jsxs("div",{className:"apteva-tool-card apteva-tool-card-running",children:[p.jsxs("svg",{className:"apteva-tool-icon apteva-tool-icon-spin",fill:"none",viewBox:"0 0 24 24",children:[p.jsx("circle",{className:"apteva-tool-spinner-track",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),p.jsx("path",{className:"apteva-tool-spinner-fill",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),p.jsxs("span",{className:"apteva-tool-label",children:[p.jsx("strong",{children:X}),z?p.jsx("span",{className:"apteva-tool-stream-separator",children:" · "}):null,z?p.jsx("span",{className:"apteva-tool-stream-output",children:z}):p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"apteva-tool-status-text",children:" running"}),p.jsxs("span",{className:"apteva-tool-dots",children:[p.jsx("span",{children:"."}),p.jsx("span",{children:"."}),p.jsx("span",{children:"."})]})]})]})]});if($==="completed")return p.jsxs("div",{className:"apteva-tool-card apteva-tool-card-completed",children:[p.jsx("svg",{className:"apteva-tool-icon",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),p.jsx("span",{className:"apteva-tool-label",children:X})]});return p.jsxs("div",{className:"apteva-tool-card apteva-tool-card-error",children:[p.jsx("svg",{className:"apteva-tool-icon",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:p.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),p.jsxs("span",{className:"apteva-tool-label",children:[X," failed"]})]})}function yZ(X){if(X==null)return"";let Q=(typeof X==="string"?X:JSON.stringify(X)).replace(/\s+/g," ").trim();return Q.length>120?Q.slice(0,117)+"...":Q}function CZ({tools:X}){let $=X.filter((J)=>J.status==="completed").length,Q=X.filter((J)=>J.status==="error").length,Z=X.length,z=$+Q===Z,[H,G]=m$.useState(!1),Y=H,K=X.find((J)=>J.status==="running")||X.find((J)=>J.status==="preparing"),q;if(z)if(Q>0)q=`Used ${Z} tools · ${Q} failed`;else q=`Used ${Z} tools`;else{let J=[`Using ${Z} tools`];if($>0)J.push(`${$} done`);if(K){let O=K.streamOutput||(K.status==="preparing"?"preparing":"running");J.push(`${K.name} ${O==="preparing"||O==="running"?O+"...":"· "+O}`)}q=J.join(" · ")}let _=z?Q>0?"apteva-tool-group apteva-tool-group-error":"apteva-tool-group apteva-tool-group-completed":"apteva-tool-group apteva-tool-group-running";return O0.jsxs("div",{className:_,children:[O0.jsxs("button",{className:"apteva-tool-group-header",onClick:()=>G(!H),children:[O0.jsxs("div",{className:"apteva-tool-group-header-left",children:[z?O0.jsx("svg",{className:"apteva-tool-group-icon",width:"14",height:"14",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:O0.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):O0.jsxs("svg",{className:"apteva-tool-group-icon apteva-tool-icon-spin",width:"14",height:"14",fill:"none",viewBox:"0 0 24 24",children:[O0.jsx("circle",{className:"apteva-tool-spinner-track",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),O0.jsx("path",{className:"apteva-tool-spinner-fill",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),O0.jsx("span",{className:"apteva-tool-group-status",children:q})]}),O0.jsx("svg",{className:`apteva-tool-group-chevron ${Y?"apteva-tool-group-chevron-open":""}`,width:"14",height:"14",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:O0.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),Y&&O0.jsx("div",{className:"apteva-tool-group-list",children:X.map((J)=>{let O=J.status==="completed"&&J.result?yZ(J.result):"",B=J.status==="running"&&J.streamOutput||O;return O0.jsxs("div",{className:`apteva-tool-group-item ${B?"apteva-tool-group-item-has-detail":""}`,children:[O0.jsxs("div",{className:"apteva-tool-group-item-row",children:[J.status==="completed"?O0.jsx("svg",{className:"apteva-tool-group-item-icon apteva-tool-group-item-done",width:"12",height:"12",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:O0.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})}):J.status==="error"?O0.jsx("svg",{className:"apteva-tool-group-item-icon apteva-tool-group-item-error",width:"12",height:"12",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:O0.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M6 18L18 6M6 6l12 12"})}):O0.jsx("div",{className:"apteva-tool-group-item-icon apteva-tool-group-item-spinner"}),O0.jsx("span",{className:"apteva-tool-group-item-name",children:J.name}),J.status==="running"&&!J.streamOutput&&O0.jsx("span",{className:"apteva-tool-group-item-running-label",children:"running..."}),J.status==="preparing"&&O0.jsx("span",{className:"apteva-tool-group-item-running-label",children:"preparing..."})]}),J.status==="running"&&J.streamOutput&&O0.jsx("div",{className:"apteva-tool-group-item-detail",children:J.streamOutput}),O&&O0.jsx("div",{className:"apteva-tool-group-item-detail apteva-tool-group-item-result-text",children:O})]},J.id)})})]})}function fZ({widget:X}){let $=X.props.title||X.type.replace(/_/g," ");return TX.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 text-sm",children:[TX.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse flex-shrink-0"}),TX.jsx("span",{className:"text-neutral-600 dark:text-neutral-400 capitalize",children:$}),TX.jsx("span",{className:"text-neutral-400 dark:text-neutral-500 text-xs ml-auto",children:"pinned above"})]})}function jZ({message:X,onAction:$,enableWidgets:Q,onWidgetRender:Z,persistentWidgetIds:z,toolCallStyle:H="card"}){let G=X.role==="user",Y=X.metadata?.content_segments,K=X.metadata?.isStreaming===!0,q=X.content||Y&&Y.length>0,_=FX.useRef(new Set),J=FX.useMemo(()=>{if(!Q||G||!X.content)return[];return dX(X.content).segments.filter((P)=>P.type==="widget"&&!!P.widget).map((P)=>P.widget)},[Q,G,X.content]);FX.useEffect(()=>{if(Z&&X.widgets){for(let v of X.widgets)if(!_.current.has(v.id))_.current.add(v.id),Z(v)}},[X.widgets,Z]),FX.useEffect(()=>{if(Z&&J.length>0){for(let v of J)if(!_.current.has(v.id))_.current.add(v.id),Z(v)}},[J,Z]);let O=(v)=>{if(!Q||G)return R.jsx(QX,{content:v});let b=dX(v).segments.filter((k)=>k.type==="text"&&k.content).map((k)=>k.content).join("");if(!b.trim())return null;return R.jsx(QX,{content:b})},B=()=>{if(!Q||G||!X.content)return null;let v=dX(X.content),P=[],b="";if(v.segments.forEach((k,N)=>{if(k.type==="text"&&k.content)b+=k.content;else if(k.type==="widget"&&k.widget){if(b.trim())P.push(R.jsx("div",{className:"apteva-message-bubble apteva-message-assistant",children:R.jsx("div",{className:"apteva-message-content-assistant",children:R.jsx(QX,{content:b})})},`text-${N}`)),b="";P.push(R.jsx("div",{className:"apteva-widget-standalone",children:R.jsx(nX,{widget:k.widget,onAction:$})},`widget-${N}`))}else if(k.type==="widget_pending"&&k.pendingType){if(b.trim())P.push(R.jsx("div",{className:"apteva-message-bubble apteva-message-assistant",children:R.jsx("div",{className:"apteva-message-content-assistant",children:R.jsx(QX,{content:b})})},`text-${N}`)),b="";P.push(R.jsx("div",{className:"apteva-widget-standalone",children:R.jsx(v$,{type:k.pendingType})},`pending-${N}`))}}),b.trim())P.push(R.jsx("div",{className:"apteva-message-bubble apteva-message-assistant",children:R.jsx("div",{className:"apteva-message-content-assistant",children:R.jsx(QX,{content:b})})},"text-final"));return P.length>0?P:null},V=X.metadata?.attachments||[],A=V.length>0,M=()=>{if(!A)return null;return R.jsx("div",{className:"apteva-message-attachments flex flex-wrap gap-2 mb-2 justify-end",children:V.map((v,P)=>{let b=v.type.startsWith("image/"),k=v.type==="application/pdf";if(b&&v.preview)return R.jsx("div",{className:"apteva-attachment-image relative rounded-lg overflow-hidden shadow-sm",children:R.jsx("img",{src:v.preview,alt:v.name,className:"max-w-[150px] max-h-[150px] object-cover"})},P);return R.jsxs("div",{className:"apteva-attachment-doc flex items-center gap-3 px-4 py-3 bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-xl shadow-sm",children:[R.jsx("div",{className:"w-10 h-10 flex items-center justify-center bg-red-100 dark:bg-red-900/30 rounded-lg text-red-600 dark:text-red-400",children:k?R.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}):R.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:R.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),R.jsxs("div",{className:"flex flex-col min-w-0",children:[R.jsx("span",{className:"text-sm font-medium text-neutral-800 dark:text-neutral-200 truncate max-w-[180px]",children:v.name}),R.jsxs("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:[k?"PDF":"Document"," · ",rX(v.size)]})]})]},P)})})},T=()=>{if(G)return R.jsx("div",{className:"apteva-message-text",children:X.content});if(K&&!q)return R.jsxs("div",{className:"apteva-typing-indicator",children:[R.jsx("span",{}),R.jsx("span",{}),R.jsx("span",{})]});if(Y&&Y.length>0)return null;return O(X.content)},g=(v,P)=>{if(!Q)return R.jsx("div",{className:"apteva-message-bubble apteva-message-assistant",children:R.jsx("div",{className:"apteva-message-content-assistant",children:R.jsx(QX,{content:v})})},P);let b=dX(v),k=[],N="";if(b.segments.forEach((E,D)=>{if(E.type==="text"&&E.content)N+=E.content;else if(E.type==="widget"&&E.widget){if(N.trim())k.push(R.jsx("div",{className:"apteva-message-bubble apteva-message-assistant",children:R.jsx("div",{className:"apteva-message-content-assistant",children:R.jsx(QX,{content:N})})},`${P}-text-${D}`)),N="";k.push(R.jsx("div",{className:"apteva-widget-standalone",children:R.jsx(nX,{widget:E.widget,onAction:$})},`${P}-widget-${D}`))}else if(E.type==="widget_pending"&&E.pendingType){if(N.trim())k.push(R.jsx("div",{className:"apteva-message-bubble apteva-message-assistant",children:R.jsx("div",{className:"apteva-message-content-assistant",children:R.jsx(QX,{content:N})})},`${P}-text-${D}`)),N="";k.push(R.jsx("div",{className:"apteva-widget-standalone",children:R.jsx(v$,{type:E.pendingType})},`${P}-pending-${D}`))}}),N.trim())k.push(R.jsx("div",{className:"apteva-message-bubble apteva-message-assistant",children:R.jsx("div",{className:"apteva-message-content-assistant",children:R.jsx(QX,{content:N})})},`${P}-text-final`));return k},a=()=>{if(!Y||Y.length===0)return null;let v=[],P=[],b=()=>{if(P.length>0)v.push({type:"tools",tools:[...P]}),P=[]};Y.forEach((N,E)=>{if(N.type==="tool")P.push(N);else if(b(),N.type==="text"&&N.content)v.push({type:"text",content:N.content,index:E})}),b();let k=[];return v.forEach((N,E)=>{if(N.type==="text"){let D=g(N.content,`seg-${N.index}`);if(Array.isArray(D))k.push(...D);else k.push(D)}else if(N.type==="tools")if(H==="inline")N.tools.forEach((D)=>{if(D.type==="tool")k.push(R.jsx("div",{className:"apteva-tool-call-standalone",children:R.jsx(k$,{name:D.name,status:D.status||(D.result!==void 0?"completed":"running"),isReceiving:D.isReceiving,inputLength:D.inputLength,streamOutput:D.streamOutput,variant:"inline"})},D.id))});else if(N.tools.length>=3){let D=N.tools.map((U0)=>{let n=U0;return{id:n.id,name:n.name,status:n.status||(n.result!==void 0?"completed":"running"),isReceiving:n.isReceiving,streamOutput:n.streamOutput,result:n.result}});k.push(R.jsx("div",{className:"apteva-tool-call-standalone",children:R.jsx(CZ,{tools:D})},`tool-group-${E}`))}else N.tools.forEach((D)=>{if(D.type==="tool")k.push(R.jsx("div",{className:"apteva-tool-call-standalone",children:R.jsx(k$,{name:D.name,status:D.status||(D.result!==void 0?"completed":"running"),isReceiving:D.isReceiving,inputLength:D.inputLength,streamOutput:D.streamOutput})},D.id))})}),k},t=()=>{if(!X.widgets||X.widgets.length===0)return null;let v=X.widgets.filter((b)=>!z?.has(b.id)),P=X.widgets.filter((b)=>z?.has(b.id));return R.jsxs(R.Fragment,{children:[P.map((b)=>R.jsx("div",{className:"apteva-widget-standalone",children:R.jsx(fZ,{widget:b})},`ref-${b.id}`)),v.length>0&&R.jsx("div",{className:"apteva-widget-standalone",children:R.jsx(kZ,{widgets:v,onAction:$,layout:"stack"})})]})};if(!G&&(Y&&Y.length>0))return R.jsxs("div",{className:"apteva-message-segmented",children:[a(),t(),R.jsx("div",{className:"apteva-message-timestamp apteva-message-timestamp-assistant",suppressHydrationWarning:!0,children:X.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]});let e=B();if(!G&&Q&&e)return R.jsxs("div",{className:"apteva-message-segmented",children:[e,t(),R.jsx("div",{className:"apteva-message-timestamp apteva-message-timestamp-assistant",suppressHydrationWarning:!0,children:X.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]});if(G&&A)return R.jsxs("div",{className:"apteva-message-segmented apteva-message-user-with-attachments flex flex-col items-end",children:[M(),X.content&&R.jsx("div",{className:"apteva-message-bubble apteva-message-user",children:R.jsx("div",{className:"apteva-message-content-user",children:R.jsx("div",{className:"apteva-message-text",children:X.content})})}),R.jsx("div",{className:"apteva-message-timestamp apteva-message-timestamp-user",suppressHydrationWarning:!0,children:X.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]});return R.jsxs("div",{className:Y0("apteva-message-bubble",G?"apteva-message-user":"apteva-message-assistant"),children:[R.jsx("div",{className:G?"apteva-message-content-user":"apteva-message-content-assistant",children:T()}),t(),R.jsx("div",{className:Y0("apteva-message-timestamp",G?"apteva-message-timestamp-user":"apteva-message-timestamp-assistant"),suppressHydrationWarning:!0,children:X.timestamp.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})}var w$=()=>m.jsx("svg",{className:"w-12 h-12 sm:w-16 sm:h-16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),J$=()=>m.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})});function hZ({title:X,subtitle:$,icon:Q,prompts:Z,variant:z="centered",chatVariant:H="default",onPromptClick:G}){let Y=(Z||[]).map((_)=>typeof _==="string"?{text:_}:_),K=Y.length>0,q=X||$||Q;if(!q&&!K)return m.jsx("div",{className:"apteva-welcome-empty flex items-center justify-center h-full",children:m.jsxs("div",{className:"text-center space-y-2",children:[m.jsx("div",{className:"flex justify-center",children:m.jsx(w$,{})}),m.jsx("p",{className:"text-sm",children:"No messages yet. Start a conversation!"})]})});if(z==="minimal")return m.jsxs("div",{className:"flex flex-col h-full px-4 py-4",children:[q&&m.jsxs("div",{className:"mb-4",children:[X&&m.jsx("h2",{className:"apteva-welcome-title text-lg font-semibold",children:X}),$&&m.jsx("p",{className:"apteva-welcome-subtitle text-sm mt-1",children:$})]}),K&&m.jsx("div",{className:"flex-1 space-y-2",children:Y.map((_,J)=>m.jsx("button",{onClick:()=>G(_.text),className:Y0("apteva-prompt-card w-full text-left px-4 py-3 rounded-xl","border transition-all duration-200","group"),children:m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"apteva-prompt-icon flex-shrink-0 transition-colors",children:_.icon||m.jsx(J$,{})}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"apteva-prompt-text text-sm font-medium truncate",children:_.text}),_.description&&m.jsx("p",{className:"apteva-prompt-desc text-xs mt-0.5 truncate",children:_.description})]})]})},J))})]});return m.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-4 py-6 sm:py-8",children:[m.jsxs("div",{className:"text-center mb-6 sm:mb-8 max-w-md",children:[m.jsx("div",{className:"apteva-welcome-icon mb-4 flex justify-center",children:Q||m.jsx(w$,{})}),X&&m.jsx("h1",{className:"apteva-welcome-title text-xl sm:text-2xl font-semibold mb-2",children:X}),$&&m.jsx("p",{className:"apteva-welcome-subtitle text-sm sm:text-base",children:$})]}),K&&m.jsxs("div",{className:"w-full max-w-2xl",children:[m.jsx("div",{className:"sm:hidden space-y-2",children:Y.map((_,J)=>m.jsx("button",{onClick:()=>G(_.text),className:Y0("apteva-prompt-card w-full text-left px-4 py-3 rounded-xl","border transition-all duration-200","active:scale-[0.98]","shadow-sm hover:shadow","group"),children:m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"apteva-prompt-icon-box flex-shrink-0 w-8 h-8 rounded-lg flex items-center justify-center transition-colors",children:_.icon||m.jsx(J$,{})}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"apteva-prompt-text text-sm font-medium",children:_.text}),_.description&&m.jsx("p",{className:"apteva-prompt-desc text-xs mt-0.5 line-clamp-1",children:_.description})]}),m.jsx("svg",{className:"apteva-prompt-chevron w-4 h-4 transition-colors flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:m.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]})},J))}),m.jsx("div",{className:"hidden sm:grid sm:grid-cols-2 gap-3",children:Y.map((_,J)=>m.jsx("button",{onClick:()=>G(_.text),className:Y0("apteva-prompt-card text-left p-4 rounded-xl","border transition-all duration-200","hover:shadow-md","active:scale-[0.98]","group"),children:m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsx("div",{className:"apteva-prompt-icon-box flex-shrink-0 w-9 h-9 rounded-lg flex items-center justify-center transition-colors",children:_.icon||m.jsx(J$,{})}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"apteva-prompt-text text-sm font-medium leading-snug",children:_.text}),_.description&&m.jsx("p",{className:"apteva-prompt-desc text-xs mt-1 line-clamp-2",children:_.description})]})]})},J))})]})]})}function xZ({messages:X,onAction:$,welcomeTitle:Q,welcomeSubtitle:Z,welcomeIcon:z,suggestedPrompts:H,welcomeVariant:G,chatVariant:Y,onPromptClick:K,enableWidgets:q,onWidgetRender:_,persistentWidgetIds:J,toolCallStyle:O}){let B=RX.useRef(null),V=RX.useRef(!0),A=RX.useRef(0),M=()=>{if(B.current){let{scrollTop:T,scrollHeight:g,clientHeight:a}=B.current;V.current=g-T-a<100}};return RX.useEffect(()=>{if(B.current&&V.current){let T=B.current.scrollHeight;if(T!==A.current)B.current.scrollTop=T,A.current=T}},[X]),xX.jsx("div",{ref:B,className:"apteva-message-list apteva-scrollbar-hidden",onScroll:M,children:X.length===0?xX.jsx(hZ,{title:Q,subtitle:Z,icon:z,prompts:H,variant:G,chatVariant:Y,onPromptClick:K||(()=>{})}):X.map((T)=>xX.jsx("div",{className:T.role==="user"?"apteva-message-row-user":"apteva-message-row-assistant",children:xX.jsx(jZ,{message:T,onAction:$,enableWidgets:q,onWidgetRender:_,persistentWidgetIds:J,toolCallStyle:O})},T.id))})}var S$=()=>{if(typeof window>"u")return null;return window.SpeechRecognition||window.webkitSpeechRecognition||null};function uZ({onSendMessage:X,placeholder:$="Type a message...",disabled:Q=!1,isLoading:Z=!1,onStop:z,onFileUpload:H,onSwitchMode:G,speechToText:Y,enableVoice:K=!1,voiceState:q="idle",voicePartialTranscript:_="",voiceDuration:J=0,onVoiceStart:O,onVoiceStop:B}){let[V,A]=z0.useState(""),[M,T]=z0.useState(!1),[g,a]=z0.useState([]),[t,e]=z0.useState(null),[v,P]=z0.useState(!1),b=z0.useRef(null),k=z0.useRef(null),N=z0.useRef(null),[E,D]=z0.useState(!1),[U0,n]=z0.useState(0),[y0,w0]=z0.useState(null),f0=z0.useRef(null),v0=z0.useRef(null),A0=z0.useRef(null),U=z0.useRef(null),I=z0.useRef(null),F=z0.useRef(0),h=z0.useRef(null),X0=z0.useRef(null),J0=z0.useRef(""),H0=z0.useRef(!1),h0=Y?typeof Y==="object"?Y:{}:null,zX=!!h0&&!!S$(),OX=h0?.silenceTimeout??2000,gX=h0?.autoSend!==!1;z0.useEffect(()=>{return()=>{i0(!0)}},[]);let YX=z0.useCallback(()=>{let f=I.current,o=U.current;if(!f||!o)return;let _0=window.devicePixelRatio||1,T0=f.getBoundingClientRect();f.width=T0.width*_0,f.height=T0.height*_0;let V0=f.getContext("2d");if(!V0)return;V0.scale(_0,_0);let I0=o.frequencyBinCount,C0=new Uint8Array(I0),j0=new Float32Array(40).fill(2),BX=()=>{F.current=requestAnimationFrame(BX),o.getByteTimeDomainData(C0);let{width:p0,height:s0}=T0;V0.clearRect(0,0,p0,s0);let t0=40,pX=2,SX=Math.max(2,(p0-(t0-1)*pX)/t0),NX=Math.floor(I0/t0);for(let e0=0;e0<t0;e0++){let eX=0;for(let yX=0;yX<NX;yX++){let XX=(C0[e0*NX+yX]-128)/128;eX+=XX*XX}let X$=Math.sqrt(eX/NX),c0=Math.max(2,X$*s0*3);j0[e0]+=(c0-j0[e0])*(c0>j0[e0]?0.4:0.15);let GX=Math.min(j0[e0],s0-2),$$=e0*(SX+pX),cX=(s0-GX)/2,lX=Math.min(SX/2,GX/2);V0.fillStyle="#3b82f6",V0.beginPath(),V0.roundRect($$,cX,SX,GX,lX),V0.fill()}};BX()},[]);z0.useEffect(()=>{if(E&&I.current&&U.current)YX()},[E,YX]);let a0=z0.useCallback(async()=>{let f=S$();if(!f)return;try{let o=await navigator.mediaDevices.getUserMedia({audio:!0});v0.current=o;let _0=new AudioContext;A0.current=_0;let T0=_0.createMediaStreamSource(o),V0=_0.createAnalyser();V0.fftSize=256,T0.connect(V0),U.current=V0;let I0=new f;I0.continuous=!0,I0.interimResults=!0,I0.lang=h0?.language||navigator.language||"en-US",f0.current=I0,J0.current="",H0.current=!1,I0.onresult=(C0)=>{let j0="",BX="";for(let p0=0;p0<C0.results.length;p0++){let s0=C0.results[p0];if(s0.isFinal)j0+=s0[0].transcript;else BX+=s0[0].transcript}if(J0.current=j0,h.current)clearTimeout(h.current);h.current=setTimeout(()=>{i0(!1)},OX)},I0.onerror=(C0)=>{if(C0.error!=="aborted")console.warn("Speech recognition error:",C0.error);i0(!0)},I0.onend=()=>{if(!H0.current&&E)JX()},I0.start(),D(!0),n(0),X0.current=setInterval(()=>{n((C0)=>C0+1)},1000),h.current=setTimeout(()=>{i0(!1)},OX+1000)}catch(o){console.warn("Microphone access denied or error:",o),e("Microphone access denied"),setTimeout(()=>e(null),3000)}},[h0?.language,OX]),JX=z0.useCallback(()=>{let f=J0.current.trim();if(D(!1),n(0),f)if(gX)w0(f),setTimeout(()=>{w0(null),X(f)},600);else A((o)=>o?`${o} ${f}`:f)},[gX,X]),i0=z0.useCallback((f)=>{if(H0.current=!0,h.current)clearTimeout(h.current),h.current=null;if(X0.current)clearInterval(X0.current),X0.current=null;if(F.current)cancelAnimationFrame(F.current),F.current=0;if(f0.current){try{f0.current.stop()}catch(o){}f0.current=null}if(v0.current)v0.current.getTracks().forEach((o)=>o.stop()),v0.current=null;if(A0.current){try{A0.current.close()}catch(o){}A0.current=null}if(U.current=null,!f)JX();else D(!1),n(0)},[JX]),g0=(f)=>{let o=Math.floor(f/60),_0=f%60;return`${o.toString().padStart(2,"0")}:${_0.toString().padStart(2,"0")}`},vX=(f)=>{if(f.key==="Enter"&&!f.shiftKey)f.preventDefault(),VX()},VX=()=>{let f=V.trim(),o=g.length>0;if((f||o)&&!Q){let _0=g.map((T0)=>T0.file);if(X(V.trim(),_0.length>0?_0:void 0),A(""),a([]),e(null),P(!1),b.current)b.current.style.height="auto"}},sX=(f)=>{A(f.target.value),f.target.style.height="auto";let o=f.target.scrollHeight;f.target.style.height=`${o}px`;let _0=f.target.value.includes(`
|
|
35
|
+
`),V0=o>36;if(!v&&(_0||V0))P(!0);else if(v&&!_0&&!V0&&f.target.value.length<20)P(!1)},kX=(f)=>{if(f.target.files&&f.target.files.length>0){let o=Array.from(f.target.files),_0=[],T0=[];if(o.forEach((V0)=>{let I0=C$(V0);if(I0.valid){let C0={file:V0};if(V0.type.startsWith("image/"))C0.preview=URL.createObjectURL(V0);_0.push(C0)}else T0.push(I0.error||"Invalid file")}),_0.length>0)a((V0)=>[...V0,..._0]);if(T0.length>0)e(T0.join(", ")),setTimeout(()=>e(null),5000);H?.(f.target.files),T(!1),f.target.value=""}},WX=(f)=>{a((o)=>{let _0=o[f];if(_0.preview)URL.revokeObjectURL(_0.preview);return o.filter((T0,V0)=>V0!==f)})},wX=(f)=>{if(f.startsWith("image/"))return L.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:L.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})});if(f==="application/pdf")return L.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:L.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})});return L.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:L.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})},R0=zX&&!E,mX=R0?"auto 1fr auto auto":"auto 1fr auto",HX=E?'"plus waveform waveform stop"':v?R0?'"textarea textarea textarea textarea" "plus . mic send"':'"textarea textarea textarea" "plus . send"':R0?'"plus textarea mic send"':'"plus textarea send"',tX="auto 1fr auto",m0=q==="active"||q==="connecting",B$=(f)=>{let o=Math.floor(f/60),_0=f%60;return`${o}:${_0.toString().padStart(2,"0")}`},o0=K&&!V.trim()&&g.length===0&&!Z&&!m0;if(m0)return L.jsx("div",{className:"px-4 py-3 relative",children:L.jsxs("div",{className:"apteva-voice-overlay",children:[L.jsx("div",{className:"apteva-voice-transcript-area",children:_?L.jsx("span",{className:"apteva-voice-partial",children:_}):q==="connecting"?L.jsx("span",{className:"apteva-voice-connecting",children:"Connecting..."}):L.jsx("span",{className:"apteva-voice-listening",children:"Listening..."})}),L.jsxs("div",{className:"apteva-voice-controls",children:[L.jsx("span",{className:"apteva-voice-duration",children:B$(J)}),L.jsx("button",{onClick:B,className:"apteva-voice-stop-btn",title:"Stop voice mode",children:L.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:L.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1",fill:"currentColor"})})})]}),L.jsx("div",{className:"apteva-voice-indicator",children:L.jsx("div",{className:`apteva-voice-pulse ${q==="active"?"apteva-voice-pulse-active":""}`})})]})});return L.jsxs("div",{className:"px-4 py-3 relative",children:[t&&L.jsx("div",{className:"apteva-file-error",children:L.jsxs("div",{className:"apteva-file-error-content",children:[L.jsx("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:L.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),L.jsx("span",{children:t})]})}),y0&&L.jsx("div",{className:"apteva-transcript-flash",children:L.jsx("span",{children:y0})}),g.length>0&&!E&&L.jsx("div",{className:"apteva-file-preview",children:g.map((f,o)=>L.jsxs("div",{className:"apteva-file-item",children:[f.preview?L.jsx("img",{src:f.preview,alt:f.file.name,className:"apteva-file-thumb"}):L.jsx("div",{className:"apteva-file-icon",children:wX(f.file.type)}),L.jsxs("div",{className:"apteva-file-info",children:[L.jsx("span",{className:"apteva-file-name",children:f.file.name}),L.jsx("span",{className:"apteva-file-size",children:rX(f.file.size)})]}),L.jsx("button",{onClick:()=>WX(o),className:"apteva-file-remove",title:"Remove file",children:L.jsx("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:L.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},o))}),L.jsxs("div",{className:"apteva-composer",style:{gridTemplateColumns:E?tX:mX,gridTemplateAreas:E?'"plus waveform stop"':HX,alignItems:E?"center":"end"},children:[L.jsx("div",{className:"relative flex-shrink-0",style:{gridArea:"plus",alignSelf:E?"center":"end"},children:E?L.jsx("div",{className:"apteva-composer-rec-dot",title:"Recording...",children:L.jsx("span",{})}):L.jsxs(L.Fragment,{children:[L.jsx("button",{ref:N,onClick:()=>T(!M),className:"apteva-composer-menu-btn w-8 h-8 rounded-lg flex items-center justify-center transition-all",title:"More options",children:L.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:L.jsx("path",{d:"M10 5v10M5 10h10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),M&&L.jsxs(L.Fragment,{children:[L.jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>T(!1)}),L.jsxs("div",{className:"apteva-composer-menu fixed rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",style:{left:N.current?.getBoundingClientRect().left??0,bottom:window.innerHeight-(N.current?.getBoundingClientRect().top??0)+8},children:[L.jsxs("button",{onClick:()=>{k.current?.click(),T(!1)},className:"apteva-composer-menu-item w-full flex items-center gap-3 px-4 py-3 transition-colors text-left",children:[L.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:L.jsx("path",{d:"M10.5 3.5L5.5 8.5C4.67157 9.32843 4.67157 10.6716 5.5 11.5C6.32843 12.3284 7.67157 12.3284 8.5 11.5L14.5 5.5C15.8807 4.11929 15.8807 1.88071 14.5 0.5C13.1193 -0.880711 10.8807 -0.880711 9.5 0.5L3.5 6.5C1.56846 8.43154 1.56846 11.5685 3.5 13.5C5.43154 15.4315 8.56846 15.4315 10.5 13.5L15.5 8.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(2, 3)"})}),L.jsx("span",{className:"!text-sm font-medium",children:"Add photos & files"})]}),G&&L.jsxs("button",{onClick:()=>{G(),T(!1)},className:"apteva-composer-menu-item w-full flex items-center gap-3 px-4 py-3 transition-colors text-left apteva-composer-menu-item-border",children:[L.jsx("svg",{className:"w-4.5 h-4.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:L.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),L.jsx("span",{className:"!text-sm font-medium",children:"Switch to command mode"})]})]})]})]})}),E?L.jsxs(L.Fragment,{children:[L.jsxs("div",{className:"apteva-composer-waveform",style:{gridArea:"waveform"},children:[L.jsx("canvas",{ref:I,className:"apteva-composer-waveform-canvas"}),L.jsx("span",{className:"apteva-composer-recording-timer",children:g0(U0)})]}),L.jsx("div",{className:"self-center",style:{gridArea:"stop"},children:L.jsx("button",{onClick:()=>i0(!1),className:"apteva-composer-stop-btn",title:"Stop recording",children:L.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:L.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"1",fill:"currentColor"})})})})]}):L.jsxs(L.Fragment,{children:[L.jsx("textarea",{ref:b,value:V,onChange:sX,onKeyDown:vX,placeholder:$,className:"apteva-composer-textarea resize-none bg-transparent border-none focus:outline-none !text-neutral-900 dark:!text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 py-1 overflow-y-auto max-h-[200px]",style:{gridArea:"textarea"},rows:1}),zX&&L.jsx("div",{className:"self-end",style:{gridArea:"mic"},children:L.jsx("button",{onClick:a0,disabled:Q||Z,className:"apteva-composer-mic-btn",title:"Voice input",children:L.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[L.jsx("path",{d:"M12 1a3 3 0 00-3 3v8a3 3 0 006 0V4a3 3 0 00-3-3z",fill:"currentColor"}),L.jsx("path",{d:"M19 10v2a7 7 0 01-14 0v-2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),L.jsx("path",{d:"M12 19v4M8 23h8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),L.jsx("div",{className:"self-end",style:{gridArea:"send"},children:Z&&z?L.jsx("button",{onClick:z,className:"apteva-composer-stop-btn",title:"Stop generation",children:L.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:L.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"1",fill:"currentColor"})})}):o0?L.jsx("button",{onClick:O,className:"apteva-composer-voice-btn w-8 h-8 rounded-lg flex items-center justify-center transition-all flex-shrink-0",title:"Start voice mode",children:L.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[L.jsx("path",{d:"M12 1a3 3 0 00-3 3v8a3 3 0 006 0V4a3 3 0 00-3-3z",fill:"currentColor"}),L.jsx("path",{d:"M19 10v2a7 7 0 01-14 0v-2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),L.jsx("path",{d:"M12 19v4M8 23h8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}):L.jsx("button",{onClick:VX,disabled:!V.trim()&&g.length===0||Q,className:"apteva-composer-send-btn w-8 h-8 rounded-lg flex items-center justify-center font-bold transition-all flex-shrink-0 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 !text-neutral-700 dark:!text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed !text-lg",title:"Send message",children:L.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:L.jsx("path",{d:"M8 3L8 13M8 3L4 7M8 3L12 7",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})})]})]}),L.jsx("input",{ref:k,type:"file",multiple:!0,onChange:kX,className:"hidden",accept:"image/*,application/pdf,.doc,.docx,.txt"})]})}function gZ({onExecute:X,state:$,response:Q,error:Z,plan:z,streamedContent:H,toolName:G,onApprove:Y,onReject:K,onReset:q,onStop:_,onExpand:J,placeholder:O="Enter your command...",disabled:B=!1}){let[V,A]=ZX.useState(""),[M,T]=ZX.useState([]),[g,a]=ZX.useState(null),[t,e]=ZX.useState(!1),v=ZX.useRef(null),P=ZX.useRef(null),b=ZX.useRef(null),k=()=>{let U=V.trim(),I=M.length>0;if((U||I)&&!B&&$==="idle"){let F=M.map((h)=>h.file);X(V.trim(),F.length>0?F:void 0),A(""),T([])}},N=(U)=>{if(U.key==="Enter"&&!U.shiftKey)U.preventDefault(),k()},E=()=>{q?.(),v.current?.focus()},D=(U)=>{if(A(U),v.current)v.current.style.height="auto",v.current.style.height=`${Math.min(v.current.scrollHeight,120)}px`},U0=(U)=>{if(U.target.files&&U.target.files.length>0){let I=Array.from(U.target.files),F=[],h=[];if(I.forEach((X0)=>{let J0=C$(X0);if(J0.valid){let H0={file:X0};if(X0.type.startsWith("image/"))H0.preview=URL.createObjectURL(X0);F.push(H0)}else h.push(J0.error||"Invalid file")}),F.length>0)T((X0)=>[...X0,...F]);if(h.length>0)a(h.join(", ")),setTimeout(()=>a(null),5000);e(!1),U.target.value=""}},n=(U)=>{T((I)=>{let F=I[U];if(F.preview)URL.revokeObjectURL(F.preview);return I.filter((h,X0)=>X0!==U)})},y0=(U)=>{if(U.startsWith("image/"))return S.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})});if(U==="application/pdf")return S.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})});return S.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})},w0=()=>{if($==="loading"){if(G)return{text:G,isToolCall:!0};if(H)return{text:H,isToolCall:!1};return{text:"Processing...",isToolCall:!1}}if($==="success"&&Q)return{text:Q,isToolCall:!1};if($==="error"&&Z)return{text:Z,isToolCall:!1};if($==="plan-pending"&&z)return{text:z,isToolCall:!1};return{text:"",isToolCall:!1}},f0=$!=="idle",{text:v0,isToolCall:A0}=w0();return S.jsxs("div",{className:"w-full relative",children:[g&&S.jsx("div",{className:"apteva-file-error",style:{top:"-3rem",bottom:"auto"},children:S.jsxs("div",{className:"apteva-file-error-content",children:[S.jsx("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),S.jsx("span",{children:g})]})}),S.jsxs("div",{className:Y0("apteva-composer flex items-center gap-2 px-3 py-2 border-2 bg-white dark:bg-neutral-900 transition-all duration-200",$==="idle"&&"border-neutral-200 dark:border-neutral-700",$==="loading"&&"border-blue-400 dark:border-blue-500",$==="plan-pending"&&"border-amber-400 dark:border-amber-500",$==="success"&&"border-green-400 dark:border-green-500",$==="error"&&"border-red-400 dark:border-red-500"),children:[S.jsxs("div",{className:"w-8 h-8 flex items-center justify-center flex-shrink-0",children:[$==="idle"&&S.jsxs("div",{className:"relative",children:[S.jsx("button",{ref:b,onClick:()=>e(!t),className:"apteva-composer-menu-btn w-8 h-8 rounded-lg flex items-center justify-center transition-all !text-neutral-500 dark:!text-neutral-400 hover:!text-neutral-700 dark:hover:!text-neutral-200 hover:bg-neutral-100 dark:hover:bg-neutral-800",title:"More options",children:S.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{d:"M10 5v10M5 10h10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),t&&S.jsxs(S.Fragment,{children:[S.jsx("div",{className:"fixed inset-0 z-[9998]",onClick:()=>e(!1)}),S.jsxs("div",{className:"apteva-composer-menu fixed bg-neutral-800 dark:bg-neutral-800 rounded-xl shadow-lg overflow-hidden z-[9999] min-w-[200px]",style:{left:b.current?.getBoundingClientRect().left??0,top:(b.current?.getBoundingClientRect().bottom??0)+8},children:[S.jsxs("button",{onClick:()=>{P.current?.click(),e(!1)},className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left",children:[S.jsx("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("path",{d:"M10.5 3.5L5.5 8.5C4.67157 9.32843 4.67157 10.6716 5.5 11.5C6.32843 12.3284 7.67157 12.3284 8.5 11.5L14.5 5.5C15.8807 4.11929 15.8807 1.88071 14.5 0.5C13.1193 -0.880711 10.8807 -0.880711 9.5 0.5L3.5 6.5C1.56846 8.43154 1.56846 11.5685 3.5 13.5C5.43154 15.4315 8.56846 15.4315 10.5 13.5L15.5 8.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(2, 3)"})}),S.jsx("span",{className:"!text-sm font-medium",children:"Add photos & files"})]}),J&&S.jsxs("button",{onClick:()=>{J(),e(!1)},className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-neutral-700 dark:hover:bg-neutral-700 transition-colors !text-white text-left border-t border-neutral-700 dark:border-neutral-700",children:[S.jsx("svg",{className:"w-4.5 h-4.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),S.jsx("span",{className:"!text-sm font-medium",children:"Expand to chat"})]})]})]})]}),$==="loading"&&!G&&S.jsx("div",{className:"w-4 h-4 border-2 border-blue-200 border-t-blue-500 rounded-full animate-spin"}),$==="loading"&&G&&S.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500 animate-pulse"})]}),M.length>0&&$==="idle"&&S.jsx("div",{className:"apteva-file-badges",children:M.map((U,I)=>S.jsxs("div",{className:"apteva-file-badge",title:U.file.name,children:[U.preview?S.jsx("img",{src:U.preview,alt:U.file.name,className:"apteva-file-badge-img"}):S.jsx("span",{className:"apteva-file-badge-icon",children:y0(U.file.type)}),S.jsx("button",{onClick:()=>n(I),className:"apteva-file-badge-remove",title:"Remove",children:S.jsx("svg",{fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]},I))}),$==="idle"?S.jsx("textarea",{ref:v,value:V,onChange:(U)=>D(U.target.value),onKeyDown:N,placeholder:M.length>0?"Add a message...":O,disabled:B,rows:1,className:Y0("flex-1 resize-none bg-transparent border-none focus:outline-none","!text-neutral-900 dark:!text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500","text-sm leading-relaxed py-1","disabled:opacity-50"),style:{minHeight:"24px",maxHeight:"120px"}}):S.jsx("div",{className:Y0("flex-1 text-sm py-1 truncate flex items-center gap-2",$==="loading"&&!A0&&"!text-neutral-600 dark:!text-neutral-400",$==="loading"&&A0&&"!text-blue-600 dark:!text-blue-400",$==="success"&&"!text-neutral-900 dark:!text-neutral-100",$==="error"&&"!text-red-600 dark:!text-red-400",$==="plan-pending"&&"!text-amber-700 dark:!text-amber-300"),children:A0?S.jsxs(S.Fragment,{children:[S.jsx("span",{className:"font-mono",children:v0}),S.jsx("span",{className:"text-neutral-400 dark:text-neutral-500",children:"Running..."})]}):v0}),S.jsx("div",{className:"w-8 h-8 flex items-center justify-center flex-shrink-0",children:$==="plan-pending"?S.jsxs("div",{className:"flex items-center gap-1",children:[S.jsx("button",{onClick:Y,className:"px-2 py-1 bg-amber-500 text-white rounded-lg hover:bg-amber-600 transition-colors text-xs font-medium",children:"Approve"}),S.jsx("button",{onClick:K,className:"px-2 py-1 bg-neutral-200 dark:bg-neutral-700 text-neutral-700 dark:text-neutral-300 rounded-lg hover:bg-neutral-300 dark:hover:bg-neutral-600 transition-colors text-xs font-medium",children:"Modify"})]}):S.jsxs(S.Fragment,{children:[$==="loading"&&_&&S.jsx("button",{onClick:_,className:"apteva-composer-stop-btn",title:"Stop generation",children:S.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:S.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"1",fill:"currentColor"})})}),($==="success"||$==="error")&&S.jsx("button",{onClick:E,className:"w-8 h-8 rounded-lg flex items-center justify-center !text-neutral-400 hover:!text-neutral-600 dark:hover:!text-neutral-300 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors",title:"New command",children:S.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),$==="idle"&&S.jsx("button",{onClick:k,disabled:!V.trim()&&M.length===0||B,className:Y0("apteva-composer-send-btn w-8 h-8 rounded-lg flex items-center justify-center transition-all","border border-neutral-200 dark:border-neutral-700","disabled:opacity-30 disabled:cursor-not-allowed",V.trim()||M.length>0?"bg-neutral-900 dark:bg-white !text-white dark:!text-neutral-900 border-neutral-900 dark:border-white":"bg-white dark:bg-neutral-800 !text-neutral-400"),title:"Execute command",children:S.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:S.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 12h14M12 5l7 7-7 7"})})})]})})]}),S.jsx("input",{ref:P,type:"file",multiple:!0,onChange:U0,className:"hidden",accept:"image/*,application/pdf,.doc,.docx,.txt"})]})}var mZ=class{constructor(X){nQ(this,"config"),this.config={apiUrl:X?.apiUrl??"",apiKey:X?.apiKey??""}}configure(X){if(X.apiUrl!==void 0)this.config.apiUrl=X.apiUrl;if(X.apiKey!==void 0)this.config.apiKey=X.apiKey}getConfig(){return{...this.config}}async chat(X){try{console.log("[AptevaClient] Chat request:",{agent_id:X.agent_id,message:typeof X.message==="string"?X.message.substring(0,100)+"...":"[multi-part message]",system:X.system,stream:X.stream});let $=await fetch(`${this.config.apiUrl}/chat`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify(X)});if(!$.ok){let Z=await $.json().catch(()=>({error:"Request failed"}));throw Error(Z.error||`Request failed with status ${$.status}`)}let Q=await $.json();return{message:Q.response||Q.message||"",thread_id:Q.thread_id,widgets:Q.widgets}}catch($){throw console.error("Chat API error:",$),$}}async chatStream(X,$,Q,Z){try{console.log("[AptevaClient] Chat stream request:",{agent_id:X.agent_id,message:typeof X.message==="string"?X.message.substring(0,100)+"...":"[multi-part message]",system:X.system,stream:X.stream});let z=await fetch(`${this.config.apiUrl}/chat`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey,Accept:"text/event-stream"},body:JSON.stringify({...X,stream:!0})});if(!z.ok){let q=await z.json().catch(()=>({error:"Request failed"}));throw Error(q.error||`Request failed with status ${z.status}`)}let H=z.body?.getReader();if(!H)throw Error("Response body is not readable");let G=new TextDecoder,Y="",K="";while(!0){let{done:q,value:_}=await H.read();if(q)break;Y+=G.decode(_,{stream:!0});let J=Y.split(`
|
|
36
|
+
`);Y=J.pop()||"";for(let O of J){if(!O.trim()||O.startsWith(":"))continue;if(O.startsWith("data: ")){let B=O.slice(6);if(B==="[DONE]"){Q?.(K);return}try{let V=JSON.parse(B);if(V.thread_id)K=V.thread_id;$(V)}catch(V){console.warn("[AptevaClient] Failed to parse SSE data:",B)}}}}Q?.(K)}catch(z){let H=z instanceof Error?z:Error("Unknown error");throw Z?.(H),H}}async createThread(X,$){let Q=await fetch(`${this.config.apiUrl}/agents/${X}/threads`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({metadata:$})});if(!Q.ok){let z=await Q.json().catch(()=>({error:"Request failed"}));throw Error(z.error||`Request failed with status ${Q.status}`)}return(await Q.json()).thread_id}async getThreadMessages(X){let $=await fetch(`${this.config.apiUrl}/threads/${X}/messages`,{method:"GET",headers:{"X-API-Key":this.config.apiKey}});if(!$.ok){let Z=await $.json().catch(()=>({error:"Request failed"}));throw Error(Z.error||`Request failed with status ${$.status}`)}return(await $.json()).messages}async cancelRequest(X,$){try{let Q=await fetch(`${this.config.apiUrl}/agents/${X}/requests/${$}/cancel`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey}});if(!Q.ok){let Z=await Q.json().catch(()=>({error:"Cancel request failed"}));throw Error(Z.error||`Cancel request failed with status ${Q.status}`)}}catch(Q){throw console.error("[AptevaClient] Cancel request error:",Q),Q}}},MX=new mZ;function pZ({widgets:X,onAction:$}){let[Q,Z]=p$.useState(!1);if(X.length===0)return null;return l0.jsxs("div",{className:"apteva-persistent-panel border-b border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900",children:[l0.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",children:[l0.jsxs("div",{className:"flex items-center gap-2",children:[l0.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),l0.jsx("span",{className:"text-xs font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wider",children:"Live"})]}),l0.jsx("button",{onClick:()=>Z((z)=>!z),className:"p-1 rounded text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 hover:bg-neutral-200 dark:hover:bg-neutral-700 transition-colors",children:l0.jsx("svg",{className:Y0("w-3.5 h-3.5 transition-transform",Q&&"rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:l0.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})})]}),!Q&&l0.jsx("div",{className:"px-3 pb-3 flex flex-col gap-3",children:X.map((z)=>l0.jsx(nX,{widget:z,onAction:$},z.id))})]})}function cZ(X){let $=new Int16Array(X.length);for(let Q=0;Q<X.length;Q++){let Z=Math.max(-1,Math.min(1,X[Q]));$[Q]=Z<0?Z*32768:Z*32767}return $}function lZ(X){let $=new Uint8Array(X.buffer),Q="";for(let Z=0;Z<$.length;Z++)Q+=String.fromCharCode($[Z]);return btoa(Q)}function dZ(X){let $=atob(X),Q=new Int16Array($.length/2);for(let z=0;z<Q.length;z++)Q[z]=$.charCodeAt(z*2+1)<<8|$.charCodeAt(z*2);let Z=new Float32Array(Q.length);for(let z=0;z<Q.length;z++)Z[z]=Q[z]/(Q[z]<0?32768:32767);return Z}function iZ(X,$,Q){if($===Q)return X;let Z=$/Q,z=Math.floor(X.length/Z),H=new Float32Array(z);for(let G=0;G<z;G++){let Y=G*Z,K=Math.floor(Y),q=Math.min(K+1,X.length-1),_=Y-K;H[G]=X[K]*(1-_)+X[q]*_}return H}function oZ(X){let[$,Q]=N0.useState("idle"),[Z,z]=N0.useState(""),[H,G]=N0.useState(0),Y=N0.useRef(null),K=N0.useRef(null),q=N0.useRef(null),_=N0.useRef(null),J=N0.useRef(null),O=N0.useRef(0),B=N0.useRef(null),V=N0.useRef(0),A=N0.useRef(X);A.current=X;let M=N0.useCallback(()=>{if(B.current)clearInterval(B.current),B.current=null;if(J.current)J.current.disconnect(),J.current=null;if(_.current)_.current.getTracks().forEach((P)=>P.stop()),_.current=null;if(K.current){try{K.current.close()}catch(P){}K.current=null}if(q.current){try{q.current.close()}catch(P){}q.current=null}if(Y.current){try{Y.current.close()}catch(P){}Y.current=null}O.current=0,z(""),G(0)},[]);N0.useEffect(()=>{return()=>{M()}},[M]);let T=N0.useCallback((P)=>{if(!q.current)q.current=new AudioContext({sampleRate:24000});let b=q.current;if(b.state==="suspended")b.resume();let k=dZ(P),N=b.createBuffer(1,k.length,24000);N.getChannelData(0).set(k);let E=b.createBufferSource();E.buffer=N,E.connect(b.destination);let D=b.currentTime,U0=Math.max(D,O.current);E.start(U0),O.current=U0+N.duration},[]),g=N0.useCallback((P)=>{let b=A.current;switch(P.type){case"session_created":Q("active"),V.current=Date.now(),B.current=setInterval(()=>{G(Math.floor((Date.now()-V.current)/1000))},1000);break;case"audio_delta":if(P.data?.chunk)T(P.data.chunk);break;case"transcript":if(P.data)if(P.data.partial)z(P.data.content);else z(""),b.onTranscript?.({id:`vt-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,role:P.data.role,content:P.data.content,partial:!1,timestamp:new Date});break;case"tool_call":if(P.data)O.current=0,b.onTranscript?.({id:`vt-tool-${Date.now()}`,role:"system",content:`Using ${P.data.name}...`,partial:!1,timestamp:new Date});break;case"tool_result":if(P.data)O.current=0;break;case"error":Q("error"),b.onError?.(Error(P.data?.message||"Voice session error"));break}},[T]),a=N0.useCallback(async()=>{let P=Y.current;if(!P)return;try{K.current=new AudioContext;let b=K.current.sampleRate;_.current=await navigator.mediaDevices.getUserMedia({audio:!0});let k=K.current.createMediaStreamSource(_.current);J.current=K.current.createScriptProcessor(2048,1,1),J.current.onaudioprocess=(N)=>{if(!P||P.readyState!==WebSocket.OPEN)return;let E=N.inputBuffer.getChannelData(0),D=iZ(E,b,16000),U0=cZ(D),n=lZ(U0);P.send(JSON.stringify({type:"audio",data:{chunk:n}}))},k.connect(J.current),J.current.connect(K.current.destination)}catch(b){A.current.onError?.(Error("Microphone access denied")),M(),Q("idle")}},[M]),t=N0.useCallback(()=>{if($!=="idle")return;Q("connecting");let b=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${X.apiUrl}/voice`,k=new WebSocket(b);Y.current=k,k.onopen=()=>{let N=A.current.provider||"openai",E=A.current.voice||"ash";k.send(JSON.stringify({type:"start",data:{provider:N,voice:E}})),a()},k.onmessage=(N)=>{try{let E=JSON.parse(N.data);g(E)}catch(E){}},k.onerror=()=>{Q("error"),A.current.onError?.(Error("WebSocket connection failed"))},k.onclose=()=>{M(),Q("idle")}},[$,X.apiUrl,a,g,M]),e=N0.useCallback(()=>{M(),Q("idle")},[M]),v=N0.useCallback((P)=>{let b=Y.current;if(!b||b.readyState!==WebSocket.OPEN)return;b.send(JSON.stringify({type:"text",data:{content:P}}))},[]);return{state:$,partialTranscript:Z,duration:H,start:t,stop:e,sendText:v}}var c$=i.forwardRef(function({agentId:$,threadId:Q,initialMessages:Z=[],context:z,apiUrl:H,apiKey:G,useMock:Y=!1,initialMode:K="chat",showModeToggle:q=!1,onModeChange:_,commandVariant:J="default",planMode:O=!1,onPlanModeChange:B,enableStreaming:V=!0,showProgress:A=!0,loadingText:M="Processing...",welcomeTitle:T,welcomeSubtitle:g,welcomeIcon:a,suggestedPrompts:t,welcomeVariant:e,onThreadChange:v,onMessageSent:P,onAction:b,onFileUpload:k,onComplete:N,onError:E,onToolCall:D,onToolResult:U0,variant:n="default",theme:y0,placeholder:w0,showHeader:f0=!0,headerTitle:v0="Chat",onHeaderBack:A0,toolCallStyle:U="card",enableWidgets:I=!1,availableWidgets:F,compactWidgetContext:h=!1,onWidgetRender:X0,speechToText:J0,enableVoice:H0=!1,voiceProvider:h0,voiceId:zX,className:OX},gX){let[YX,a0]=i.useState(Z),[JX,i0]=i.useState(!1),[g0,vX]=i.useState(Q||null),[VX,sX]=i.useState(K),[kX,WX]=i.useState(null),[wX,R0]=i.useState("idle"),[mX,HX]=i.useState(null),[tX,m0]=i.useState(null),[B$,o0]=i.useState(0),[f,o]=i.useState(""),[_0,T0]=i.useState(""),[V0,I0]=i.useState(null),[C0,j0]=i.useState(null),[BX,p0]=i.useState(""),[s0,t0]=i.useState(""),[pX,SX]=i.useState(O),[NX,e0]=i.useState(!1),eX=i.useRef(null),X$=i.useCallback((c)=>{let L0={id:c.id,role:c.role==="system"?"assistant":c.role,content:c.content,timestamp:c.timestamp,metadata:c.role==="system"?{isVoiceSystem:!0}:{isVoice:!0}};a0((D0)=>[...D0,L0])},[]),c0=oZ({apiUrl:H||"",provider:h0,voice:zX,onTranscript:X$,onError:E}),[GX,$$]=i.useState(new Map),cX=i.useCallback((c)=>{$$((L0)=>{let D0=new Map(L0),Z0=!1;for(let d of c){if(!d.widgets)continue;for(let $0 of d.widgets){if(!$0.persistent)continue;let s=D0.get($0.id);if(!s||s!==$0)D0.set($0.id,$0),Z0=!0}}return Z0?D0:L0})},[]);i.useEffect(()=>{cX(YX)},[YX,cX]);let lX=i.useMemo(()=>Array.from(GX.values()),[GX]),yX=i.useMemo(()=>new Set(GX.keys()),[GX]),XX=i.useRef(null);i.useImperativeHandle(gX,()=>({sendMessage:async(c)=>{if(XX.current)await XX.current(c)},sendSystemMessage:async(c)=>{if(XX.current)await XX.current(c,void 0,!0)},getMessages:()=>YX,clearMessages:()=>a0([])}),[YX]);let AX=i.useMemo(()=>{if(!I)return z;let c=h?KZ(F):qZ(F);return z?`${z}
|
|
37
|
+
${c}`:c},[z,I,F,h]);i.useEffect(()=>{if(H||G)MX.configure({...H&&{apiUrl:H},...G&&{apiKey:G}})},[H,G]),i.useEffect(()=>{if(Q)v?.(Q)},[Q,v]),i.useEffect(()=>{SX(O)},[O]),i.useEffect(()=>{let c=(L0)=>{let D0=L0.target;if(NX&&!D0.closest(".settings-menu-container"))e0(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[NX]);let L$=(c)=>{if(sX(c),_?.(c),c==="command")R0("idle"),HX(null),m0(null)},GQ=VX==="chat"?"Type a message...":"Enter your command...",D$=i.useCallback((c)=>{if(b?.(c),c.type==="submit"&&c.payload?.formData){let L0=c.payload.formData,D0=[];for(let[Z0,d]of Object.entries(L0))if(Array.isArray(d)&&d.length>0&&d[0]instanceof File){let $0=d.map((s)=>s.name).join(", ");D0.push(`${Z0}: ${$0}`)}else if(d!==""&&d!==!1&&d!=null)D0.push(`${Z0}: ${d}`);if(D0.length>0&&XX.current){let Z0=[];for(let d of Object.values(L0))if(Array.isArray(d)&&d.length>0&&d[0]instanceof File)Z0.push(...d);XX.current(D0.join(`
|
|
38
|
+
`),Z0.length>0?Z0:void 0)}}},[b]),Q$=async(c,L0,D0)=>{let Z0=L0&&L0.length>0,d=Z0?L0.map(($0)=>({name:$0.name,type:$0.type,size:$0.size,preview:$0.type.startsWith("image/")?URL.createObjectURL($0):void 0})):[];if(!D0){let $0={id:`msg-${Date.now()}`,role:"user",content:c,timestamp:new Date,metadata:Z0?{attachments:d}:void 0};a0((s)=>[...s,$0]),P?.($0)}i0(!0);try{let $0=await I$(c,L0);if(Y){let s=await aQ(1000);a0((q0)=>[...q0,s])}else{let s=[],q0="",Q0=[],qX=g0,CX={},Z$={},_Q=`msg-${Date.now()}-res`,KX=()=>{let j=[...s];if(q0){let x=j[j.length-1];if(x&&x.type==="text")x.content=q0;else j.push({type:"text",content:q0})}a0((x)=>{let K0=x[x.length-1];if(K0&&K0.role==="assistant")return[...x.slice(0,-1),{...K0,content:q0,widgets:Q0.length>0?Q0:void 0,metadata:{...K0.metadata,content_segments:j,isStreaming:!0}}];else return[...x,{id:_Q,role:"assistant",content:q0,widgets:Q0.length>0?Q0:void 0,timestamp:new Date,metadata:{content_segments:j,isStreaming:!0}}]})};await MX.chatStream({agent_id:$,message:$0,stream:!0,...g0&&{thread_id:g0},...AX&&{system:AX}},(j)=>{switch(j.type){case"thread_id":if(j.thread_id){if(qX=j.thread_id,!g0)vX(j.thread_id),v?.(j.thread_id)}break;case"request_id":if(j.request_id)j0(j.request_id);break;case"content":case"token":if(j.content){if(!q0)q0=j.content.trimStart();else q0+=j.content;if(q0)KX()}break;case"tool_call":if(j.tool_id&&j.tool_name){let x=j.tool_display_name||j.tool_name;if(q0)s.push({type:"text",content:q0.trimEnd()}),q0="";s.push({type:"tool",id:j.tool_id,name:x,status:"preparing"}),CX[j.tool_id]="",WX(x),D?.(j.tool_name,j.tool_id),KX()}break;case"tool_input_delta":if(j.tool_id&&j.content){let x=j.tool_id;if(CX[x]===void 0)CX[x]="";CX[x]+=j.content;let K0=s.find((fX)=>fX.type==="tool"&&fX.id===x);if(K0){if(K0.isReceiving=!0,K0.inputLength=CX[x].length,KX(),Z$[x])clearTimeout(Z$[x]);Z$[x]=setTimeout(()=>{if(K0.status==="preparing")K0.isReceiving=!1,KX()},150)}}break;case"tool_use":if(j.tool_id){let x=s.find((K0)=>K0.type==="tool"&&K0.id===j.tool_id);if(x&&x.status==="preparing")x.status="running",x.isReceiving=!1,KX()}break;case"tool_stream":if(j.tool_id){let x=s.find((K0)=>K0.type==="tool"&&K0.id===j.tool_id);if(x){if(j.event==="chunk"&&j.content){if(x.pendingReset)x.streamOutput="",x.pendingReset=!1;x.streamOutput=(x.streamOutput||"")+j.content,KX()}else if(j.event==="log"||j.event==="progress")x.pendingReset=!0}}break;case"tool_result":if(j.tool_id){let x=s.find((K0)=>K0.type==="tool"&&K0.id===j.tool_id);if(x)x.result=j.content,x.status="completed",x.isReceiving=!1,U0?.(x.name,j.content);WX(null),KX()}break;case"widget":if(j.widget)Q0.push(j.widget),KX();break;case"error":throw Error(j.message||"Stream error")}},(j)=>{if(q0=q0.trimEnd(),q0){let x=s[s.length-1];if(x&&x.type==="text")x.content=q0;else s.push({type:"text",content:q0})}if(a0((x)=>{let K0=x[x.length-1];if(K0&&K0.role==="assistant")return[...x.slice(0,-1),{...K0,content:q0||"Response received",widgets:Q0.length>0?Q0:void 0,metadata:{thread_id:j,content_segments:s,isStreaming:!1}}];return x}),j&&j!==g0)vX(j),v?.(j);i0(!1),j0(null),WX(null)},(j)=>{let x={id:`msg-${Date.now()}-error`,role:"assistant",content:`Error: ${j.message}`,timestamp:new Date,metadata:{error:!0}};a0((K0)=>{let fX=K0[K0.length-1];if(fX&&fX.id.includes("streaming"))return[...K0.slice(0,-1),x];return[...K0,x]}),i0(!1),j0(null),WX(null),E?.(j)})}}catch($0){let s={id:`msg-${Date.now()}-error`,role:"assistant",content:$0 instanceof Error?`Error: ${$0.message}`:"An error occurred",timestamp:new Date,metadata:{error:!0}};a0((q0)=>[...q0,s]),E?.($0 instanceof Error?$0:Error("Unknown error"))}finally{i0(!1)}};XX.current=Q$;let F$=async(c,L0)=>{let D0=c||f;if(!D0.trim()&&(!L0||L0.length===0)){m0(Error("Please enter a command")),R0("error");return}if(pX&&wX!=="plan-pending"){if(R0("loading"),m0(null),o(""),Y)setTimeout(()=>{let Z0=`1. Analyze the request: "${D0}"
|
|
39
|
+
2. Process the data
|
|
40
|
+
3. Generate response
|
|
41
|
+
4. Return results`;p0(Z0),t0(D0),R0("plan-pending")},800);else try{let d=AX?`${AX}
|
|
42
|
+
|
|
43
|
+
CRITICAL PLANNING MODE: You are ONLY creating a plan. Write a numbered list of steps describing what WOULD be done. DO NOT execute anything.`:"CRITICAL PLANNING MODE: You are ONLY creating a plan. Write a numbered list of steps describing what WOULD be done. DO NOT execute anything.",$0=await MX.chat({agent_id:$,message:D0,stream:!1,system:d});p0($0.message),t0(D0),R0("plan-pending")}catch(Z0){let d=Z0 instanceof Error?Z0:Error("Failed to generate plan");m0(d),R0("error"),E?.(d)}return}R0("loading"),m0(null),o0(0),T0(""),o("");try{if(Y)if(V){let Z0="";eQ(D0,(d)=>{if(d.type==="token"&&d.content){Z0+=d.content,T0(Z0);let $0=Math.min(Math.round(Z0.length/10),90);o0($0)}},(d)=>{let $0={success:!0,data:{summary:Z0,thread_id:d},message:Z0||"Command executed successfully"};HX($0),R0("success"),o0(100),N?.($0)},(d)=>{m0(d),R0("error"),E?.(d)})}else{await new Promise((d)=>setTimeout(d,1500));let Z0={success:!0,data:{summary:`Executed: ${D0}`},message:"Command executed successfully"};HX(Z0),R0("success"),o0(100),N?.(Z0)}else{let d=AX?`${AX}
|
|
44
|
+
|
|
45
|
+
CRITICAL COMMAND MODE: Maximum 10 words per response. Execute the command immediately. Make reasonable assumptions based on context. Use sensible defaults for missing details. DO NOT ask questions unless something is truly impossible without user input (e.g., missing required password). State what you're doing or the result. Examples: "Analyzing customer data from last quarter..." or "Created 5 new database entries successfully" or "Search complete: found 12 matching results". NO greetings, NO filler words, NO clarification requests. Action/result only.`:`CRITICAL COMMAND MODE: Maximum 10 words per response. Execute the command immediately. Make reasonable assumptions based on context. Use sensible defaults for missing details. DO NOT ask questions unless something is truly impossible without user input (e.g., missing required password). State what you're doing or the result. Examples: "Analyzing customer data from last quarter..." or "Created 5 new database entries successfully" or "Search complete: found 12 matching results". NO greetings, NO filler words, NO clarification requests. Action/result only.`,$0=L0&&L0.length>0?await I$(D0,L0):D0;if(V){let s="",q0="";await MX.chatStream({agent_id:$,message:$0,stream:!0,...g0&&{thread_id:g0},system:d},(Q0)=>{if((Q0.type==="token"||Q0.type==="content")&&Q0.content){s+=Q0.content,T0(s),I0(null);let qX=Math.min(Math.round(s.length/10),90);o0(qX)}else if(Q0.type==="tool_call"&&Q0.tool_name){let qX=Q0.tool_display_name||Q0.tool_name;q0=Q0.tool_name,I0(qX),D?.(Q0.tool_name,Q0.tool_id||""),s="",T0("")}else if(Q0.type==="tool_result")U0?.(q0,Q0.content),I0(null);else if(Q0.type==="thread_id"&&Q0.thread_id){if(!g0)vX(Q0.thread_id),v?.(Q0.thread_id)}else if(Q0.type==="request_id"&&Q0.request_id)j0(Q0.request_id)},(Q0)=>{let qX={success:!0,data:{summary:s,thread_id:Q0},message:s||"Command executed successfully"};HX(qX),R0("success"),o0(100),j0(null),N?.(qX)},(Q0)=>{m0(Q0),R0("error"),j0(null),E?.(Q0)})}else{let s=await MX.chat({agent_id:$,message:$0,stream:!1,...g0&&{thread_id:g0},system:d}),q0={success:!0,data:{summary:s.message,thread_id:s.thread_id},widgets:s.widgets,message:s.message};HX(q0),R0("success"),o0(100),N?.(q0)}}}catch(Z0){let d=Z0 instanceof Error?Z0:Error("Unknown error");m0(d),R0("error"),E?.(d)}},qQ=()=>{R0("idle"),HX(null),m0(null),o0(0),o(""),p0(""),t0(""),T0(""),I0(null)},KQ=()=>{let c=BX;p0(""),t0("");let L0=`Execute this plan now:
|
|
46
|
+
|
|
47
|
+
${c}`;F$(L0)},UQ=()=>{o(s0),p0(""),t0(""),R0("idle")},W$=async()=>{if(C0&&$)try{await MX.cancelRequest($,C0)}catch(c){console.error("Failed to cancel request:",c)}if(i0(!1),wX==="loading")R0("idle"),T0(""),I0(null),o0(0);j0(null)},Xz=J==="compact";return b0.jsxs("div",{className:Y0("apteva-chat flex flex-col h-full",n!=="default"&&`apteva-chat-${n}`,y0==="dark"&&"apteva-force-dark",y0==="light"&&"apteva-force-light",OX),children:[f0&&VX==="chat"&&b0.jsx("div",{className:"apteva-chat-header px-4 py-3",children:b0.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[A0&&b0.jsx("button",{onClick:A0,className:"apteva-chat-back",style:{flexShrink:0},children:b0.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:b0.jsx("path",{d:"M10 12L6 8l4-4"})})}),b0.jsxs("div",{children:[b0.jsx("div",{className:"apteva-chat-title",children:v0}),b0.jsx("div",{className:Y0("apteva-chat-status",c0.state==="active"?"apteva-chat-status-voice":c0.state==="connecting"?"apteva-chat-status-thinking":JX?kX?"apteva-chat-status-tool":"apteva-chat-status-thinking":"apteva-chat-status-ready"),children:c0.state==="active"?"Voice active":c0.state==="connecting"?"Connecting voice...":JX?kX?`Using ${kX}...`:"Thinking...":"Ready"})]})]})}),VX==="chat"&&b0.jsxs(b0.Fragment,{children:[lX.length>0&&b0.jsx(pZ,{widgets:lX,onAction:D$}),b0.jsx(xZ,{messages:YX,onAction:D$,welcomeTitle:T,welcomeSubtitle:g,welcomeIcon:a,suggestedPrompts:t,welcomeVariant:e,chatVariant:n,onPromptClick:(c)=>Q$(c),enableWidgets:I,onWidgetRender:X0,persistentWidgetIds:yX,toolCallStyle:U}),b0.jsx(uZ,{onSendMessage:Q$,placeholder:w0||GQ,disabled:JX,isLoading:JX,onStop:W$,onFileUpload:k,onSwitchMode:q?()=>L$("command"):void 0,speechToText:J0,enableVoice:H0,voiceState:c0.state,voicePartialTranscript:c0.partialTranscript,voiceDuration:c0.duration,onVoiceStart:c0.start,onVoiceStop:c0.stop})]}),VX==="command"&&b0.jsx("div",{className:"w-full",children:b0.jsx(gZ,{onExecute:(c,L0)=>{o(c),F$(c,L0)},state:wX,response:mX?.data?.summary||mX?.message,error:tX?.message,plan:BX,streamedContent:_0,toolName:V0,onApprove:KQ,onReject:UQ,onReset:qQ,onStop:W$,onExpand:q?()=>L$("chat"):void 0,placeholder:w0||"Enter your command..."})}),b0.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
48
|
+
@keyframes pulse-border {
|
|
49
|
+
0%, 100% { border-color: rgb(59, 130, 246); }
|
|
50
|
+
50% { border-color: rgb(147, 197, 253); }
|
|
51
|
+
}
|
|
52
|
+
.animate-pulse-border {
|
|
53
|
+
animation: pulse-border 2s ease-in-out infinite;
|
|
54
|
+
}
|
|
55
|
+
.apteva-composer {
|
|
56
|
+
border-radius: var(--apteva-border-radius, 1rem) !important;
|
|
57
|
+
}
|
|
58
|
+
`}})]})});var u=w(QQ(),1);function Lz({agents:X,onNavigate:$}){let{theme:Q}=HQ(),{authFetch:Z}=YQ(),{currentProjectId:z}=JQ(),{events:H,statusChangeCounter:G}=ZQ(),[Y,K]=M0.useState([]),[q,_]=M0.useState(null),[J,O]=M0.useState(null),[B,V]=M0.useState([]),[A,M]=M0.useState(!0),[T,g]=M0.useState(!1),[a,t]=M0.useState([]),[e,v]=M0.useState(!1),[P,b]=M0.useState(0),k=M0.useMemo(()=>{if(z===null)return X;if(z==="unassigned")return X.filter((F)=>!F.projectId);return X.filter((F)=>F.projectId===z)},[X,z]),N=M0.useMemo(()=>k.filter((F)=>F.status==="running"),[k]),E=M0.useMemo(()=>new Set(k.map((F)=>F.id)),[k]),D=M0.useCallback(async()=>{try{let F=z?`?project_id=${encodeURIComponent(z)}`:"",[h,X0]=await Promise.all([Z(`/api/threads${F}`).catch(()=>null),Z(`/api/telemetry/events?type=thread_activity&limit=100${F?`&${F}`:""}`).catch(()=>null)]);if(h?.ok){let J0=await h.json();K(J0.threads||[])}if(X0?.ok){let J0=await X0.json();t(J0.events||[])}}catch(F){console.error("Failed to fetch threads:",F)}finally{M(!1)}},[Z,z]);M0.useEffect(()=>{D()},[D,G]),M0.useEffect(()=>{let F=setInterval(D,15000);return()=>clearInterval(F)},[D]);let U0=M0.useCallback(async(F)=>{O(null),g(!0),_(F);try{let h=await Z(`/api/agents/${F.agent_id}/threads/${F.id}/messages`);if(h.ok){let X0=await h.json();V(j$(X0.messages||[]))}else V([])}catch{V([])}g(!1)},[Z]),n=(F)=>{_(null),V([]),O(F),b((h)=>h+1),v(!1)},y0=M0.useMemo(()=>{let F=H.filter((J0)=>J0.type==="thread_activity"&&!J0.data?.parent_id),h=new Set(F.map((J0)=>J0.id)),X0=[...F];for(let J0 of a)if(!h.has(J0.id)&&!J0.data?.parent_id)X0.push(J0),h.add(J0.id);return X0.filter((J0)=>E.has(J0.agent_id)).sort((J0,H0)=>new Date(H0.timestamp).getTime()-new Date(J0.timestamp).getTime()).slice(0,100)},[H,a,E]),w0=M0.useMemo(()=>{let F=new Map;for(let h of y0){let X0=h.thread_id||h.data?.thread_id;if(X0){if(!F.has(X0))F.set(X0,[]);F.get(X0).push(h)}}return F},[y0]),f0=N.length,v0=q?.agent_id||J?.id,A0=q?.agent_name||J?.name,U=q?.id,I=q?`${q.agent_id}-${q.id}`:J?`new-${J.id}-${P}`:null;return u.jsxDEV("div",{className:"flex-1 flex flex-col overflow-hidden",children:[u.jsxDEV("div",{className:"px-6 pt-6 pb-4 shrink-0",children:u.jsxDEV("div",{className:"flex items-center justify-between",children:[u.jsxDEV("h1",{className:"text-xl font-semibold",children:"Threads"},void 0,!1,void 0,this),u.jsxDEV("span",{className:"text-sm text-[var(--color-text-muted)]",children:[Y.length," threads from ",f0," running agents"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),u.jsxDEV("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[u.jsxDEV("div",{className:"w-1/4 min-w-[260px] max-w-[360px] flex flex-col overflow-hidden",children:[u.jsxDEV("div",{className:"p-2 shrink-0",children:u.jsxDEV("div",{className:"relative",children:[u.jsxDEV("button",{onClick:()=>v(!e),disabled:N.length===0,className:"w-full flex items-center justify-center gap-2 px-3 py-2 btn bg-[var(--color-accent-10)] text-[var(--color-accent)] text-sm font-medium hover:bg-[var(--color-accent-20)] transition disabled:opacity-30 disabled:cursor-not-allowed",children:[u.jsxDEV("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"},void 0,!1,void 0,this)},void 0,!1,void 0,this),"New conversation"]},void 0,!0,void 0,this),e&&u.jsxDEV(u.Fragment,{children:[u.jsxDEV("div",{className:"fixed inset-0 z-40",onClick:()=>v(!1)},void 0,!1,void 0,this),u.jsxDEV("div",{className:"absolute top-full left-0 right-0 mt-1 bg-[var(--color-surface)] card shadow-xl z-50 max-h-60 overflow-auto",children:N.map((F)=>u.jsxDEV("button",{onClick:()=>n(F),className:"w-full text-left px-3 py-2.5 hover:bg-[var(--color-surface-raised)] transition",children:[u.jsxDEV("p",{className:"text-sm font-medium truncate",children:F.name},void 0,!1,void 0,this),u.jsxDEV("p",{className:"text-[10px] text-[var(--color-text-faint)]",children:[F.provider," · ",F.model]},void 0,!0,void 0,this)]},F.id,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),u.jsxDEV("div",{className:"flex-1 overflow-auto px-2 pb-2",children:A?u.jsxDEV("div",{className:"p-6 text-center text-[var(--color-text-faint)] text-sm",children:"Loading threads..."},void 0,!1,void 0,this):Y.length===0?u.jsxDEV("div",{className:"p-6 text-center text-[var(--color-text-faint)] text-sm",children:[u.jsxDEV("p",{children:"No threads yet"},void 0,!1,void 0,this),u.jsxDEV("p",{className:"mt-1 text-[var(--color-text-faint)]",children:"Start a conversation or wait for agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):u.jsxDEV("div",{className:"space-y-0.5",children:Y.map((F)=>u.jsxDEV(tZ,{thread:F,selected:q?.id===F.id&&q?.agent_id===F.agent_id,activities:w0.get(F.id)||[],onSelect:()=>U0(F)},`${F.agent_id}-${F.id}`,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:v0&&I?T?u.jsxDEV("div",{className:"flex-1 flex items-center justify-center text-[var(--color-text-muted)]",children:"Loading messages..."},void 0,!1,void 0,this):u.jsxDEV(c$,{agentId:"default",apiUrl:`/api/agents/${v0}`,threadId:U,initialMessages:B,placeholder:`Message ${A0}...`,headerTitle:A0,variant:"terminal",theme:Q.id,showHeader:!0},I,!1,void 0,this):u.jsxDEV("div",{className:"flex-1 flex items-center justify-center",children:u.jsxDEV("div",{className:"text-center text-[var(--color-text-faint)]",children:[u.jsxDEV("svg",{className:"w-12 h-12 mx-auto mb-3 text-[var(--color-border-light)]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:u.jsxDEV("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),u.jsxDEV("p",{className:"text-sm",children:"Select a thread or start a new conversation"},void 0,!1,void 0,this),u.jsxDEV("p",{className:"text-xs text-[var(--color-text-faint)] mt-1",children:"Chat with any running agent"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function tZ({thread:X,selected:$,activities:Q,onSelect:Z}){let{isActive:z}=zQ(X.agent_id),G=Q[0]?.data?.activity;return u.jsxDEV("button",{onClick:Z,className:`w-full text-left px-3 py-2.5 rounded-lg transition ${$?"bg-[var(--color-accent-10)]":"hover:bg-[var(--color-bg-secondary)]"}`,children:[u.jsxDEV("div",{className:"flex items-center justify-between gap-2 mb-1",children:[u.jsxDEV("span",{className:"text-sm font-medium truncate",children:X.title||`Thread ${X.id.slice(0,8)}`},void 0,!1,void 0,this),u.jsxDEV("span",{className:"text-[10px] text-[var(--color-text-faint)] shrink-0",children:eZ(X.updated_at)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV("div",{className:"flex items-center gap-1.5",children:[u.jsxDEV("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${z?"bg-green-400 animate-pulse":"bg-[var(--color-scrollbar)]"}`},void 0,!1,void 0,this),u.jsxDEV("span",{className:"text-[11px] text-[var(--color-accent)]",children:X.agent_name},void 0,!1,void 0,this),X.message_count!=null&&u.jsxDEV(u.Fragment,{children:[u.jsxDEV("span",{className:"text-[var(--color-border-light)]",children:"·"},void 0,!1,void 0,this),u.jsxDEV("span",{className:"text-[10px] text-[var(--color-text-faint)]",children:[X.message_count," msgs"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G&&u.jsxDEV("p",{className:"text-[11px] text-[var(--color-text-faint)] truncate mt-1",children:G},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function eZ(X){let $=Math.floor((Date.now()-new Date(X).getTime())/1000);if($<5)return"just now";if($<60)return`${$}s ago`;let Q=Math.floor($/60);if(Q<60)return`${Q}m ago`;let Z=Math.floor(Q/60);if(Z<24)return`${Z}h ago`;return`${Math.floor(Z/24)}d ago`}
|
|
59
|
+
export{j$ as Q,c$ as R,Lz as S};
|
|
60
|
+
|
|
61
|
+
//# debugId=5E94DC841F4524F564756E2164756E21
|