PageSourceSearch

https://chat.lampi.ai/_next/static/chunks/6512.219bbf5b02e10657.js

js lampi.ai collected 2026-10-04 16:29:29 UTC 140,547 bytes, 51 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6512],{11512:(e,t,r)=>{r.d(t,{R:()=>n});let a=/#\[(.*?)\]\(id:([\w-]+)(?::row:(\d+))?\)/g,l=e=>e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");function n(e,t,r=!1,s=0){return e?t?e.replace(a,(e,a,n,i)=>{let o=t({row:i?parseInt(i,10):s,id:n});if(o?.value!==void 0&&null!==o.value){var d;let e="string"==typeof(d=o.value)?d:"number"==typeof d||"boolean"==typeof d?String(d):null==d?"":JSON.stringify(d);return r?l(e):e}let c=`[${a}]`;return r?l(c):c}):e:""}},19861:(e,t,r)=>{r.d(t,{A:()=>D});var a=r(37876),l=r(9419),n=r.n(l),s=r(14232),i=r(15137),o=r(19211),d=r(27992),c=r(92217),u=r(99032),m=r(10651),x=r(60528),h=r(20506),g=r(35949),p=r(60809),b=r(35107),f=r(27917),y=r(70893),v=r(37456),k=r(13316),j=r(92196),w=r(90481),N=r(29660),_=r(41262),C=r(76606);let S=e=>{let t;if(!e)return"";try{t=e.storage.markdown?.getMarkdown?.()||e.getHTML()}catch(r){t=e.getHTML()}return(e=>{if(!e)return e;let t=e;t=t.replace(/<span[^>]*data-type=["']columnMention["'][^>]*>[^<]*<\/span>/gi,e=>{let t=e.match(/data-id=["']([^"']+)["']/),r=t?t[1]:null,a=e.match(/data-label=["']([^"']+)["']/),l=a?a[1]:"unknown",n=e.match(/data-row-id=["']([^"']+)["']/),s=n?n[1]:null;return r?s?`#[${l}](id:${r}:row:${s})`:`#[${l}](id:${r})`:e});let r=[];for(let e of[/<span[^>]*data-type="fileDownload"[^>]*data-path="([^"]*)"[^>]*(?:data-filename="([^"]*)")?[^>]*>(?:<\/span>)?/g,/<span[^>]*data-path="([^"]*)"[^>]*data-type="fileDownload"[^>]*(?:data-filename="([^"]*)")?[^>]*>(?:<\/span>)?/g,/<span[^>]*data-path="([^"]*)"[^>]*(?:data-filename="([^"]*)")?[^>]*data-type="fileDownload"[^>]*>(?:<\/span>)?/g])t=t.replace(e,(e,t,a)=>{if(t){let e=a||t.split("/").pop()||"file";r.push({path:t,filename:e})}return""});if(r.length>0){let e=JSON.stringify(r.map(e=>({path:e.path,filename:e.filename,mimeType:"application/octet-stream"})));t=t.trimEnd()+`
2
3<generated_files>${e}</generated_files>`}let a=[];for(let e of[/<span[^>]*data-type="inlineImage"[^>]*data-path="([^"]*)"[^>]*(?:data-mime-type="([^"]*)")?[^>]*>(?:<\/span>)?/g,/<span[^>]*data-path="([^"]*)"[^>]*data-type="inlineImage"[^>]*(?:data-mime-type="([^"]*)")?[^>]*>(?:<\/span>)?/g,/<span[^>]*data-path="([^"]*)"[^>]*(?:data-mime-type="([^"]*)")?[^>]*data-type="inlineImage"[^>]*>(?:<\/span>)?/g])t=t.replace(e,(e,t,r)=>(t&&a.push({path:t,mimeType:r||"image/png"}),""));if(a.length>0){let e=JSON.stringify(a);t=t.trimEnd()+`
4
5<generated_images>${e}</generated_images>`}return t=(t=(t=t.replace(/\n{4,}/g,"\n\n\n")).replace(/<p><\/p>/g,"")).replace(/(<p><br><\/p>){3,}/g,"<p><br></p><p><br></p>"),(0,N.mV)(t.trim())})(t)};function M(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function A(e){if(!e||"string"!=typeof e)return e;let t=(0,N.nv)(e);return t=(t=t.replace(/<generated_images>([\s\S]*?)<\/generated_images>/g,(e,t)=>{try{let e=JSON.parse(t.trim());if(Array.isArray(e)&&e.length>0)return e.map(e=>{let t=e.path||e.url||"";if(!t)return"";let r=e.mimeType||"image/png";return`<span data-type="inlineImage" data-path="${M(t)}" data-mime-type="${M(r)}"></span>`}).filter(Boolean).join(" ")}catch(e){console.error("Failed to parse generated_images:",e)}return e})).replace(/<generated_files>([\s\S]*?)<\/generated_files>/g,(e,t)=>{try{let e=JSON.parse(t.trim());if(Array.isArray(e)&&e.length>0)return e.map(e=>{var t;if("image"==(t=e.path,["png","jpg","jpeg","gif","webp","svg"].includes(t.split(".").pop()?.toLowerCase()||"")?"image":"other"))return"";let r=e.filename||e.name||e.path.split("/").pop()||"file";return`<span data-type="fileDownload" data-path="${M(e.path)}" data-filename="${M(r)}"></span>`}).filter(Boolean).join(" ")}catch(e){console.error("Failed to parse generated_files:",e)}return e}),(0,_.oc)((0,_.FG)(t))}let $=e=>{if(!e)return"<p></p>";let t=A(e);return t=(t=(t=(t=t.replace(/#\[([^\]]+)\]\(column:([^:]+):row:(\d+)\)/g,'<span data-type="columnMention" data-id="$2" data-label="$1" data-row-id="$3" class="column-mention">#$1[R$3]</span>')).replace(/#\[([^\]]+)\]\(column:([^)]+)\)/g,'<span data-type="columnMention" data-id="$2" data-label="$1" class="column-mention">#$1</span>')).replace(/#\[([^\]]+)\]\(id:([^:)]+):row:(\d+)\)/g,'<span data-type="columnMention" data-id="$2" data-label="$1" data-row-id="$3" class="column-mention">#$1[R$3]</span>')).replace(/#\[([^\]]+)\]\(id:([^)]+)\)/g,'<span data-type="columnMention" data-id="$2" data-label="$1" class="column-mention">#$1</span>'),/<(p|div|br)\b/i.test(t),t}
5,E=(0,s.forwardRef)(({value:e,onChange:t,onInitialValueResolved:r,placeholder:l="Type # to mention a column...",className:N="",contentPaddingClassName:_="p-4",style:M={},columns:E,theme:D="light",nbrOfRows:L=0,readOnly:B=!1,autoFocus:T=!0,onSave:R,onCancel:U,disableMentions:z=!1},F)=>{let[H,O]=(0,s.useState)(null),P=(0,s.useRef)(E);P.current=E;let I=(0,s.useRef)(L);I.current=L;let K=(0,s.useRef)(B);K.current=B;let W=(0,s.useRef)(t);W.current=t;let G=(0,s.useRef)(r);G.current=r;let V=(0,s.useRef)(O);V.current=O;let q=(0,s.useRef)(R);q.current=R;let J=(0,s.useRef)(U);J.current=U;let Q=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{Q.current&&(Q.current(),Q.current=null)},[]);let Y=(0,s.useMemo)(()=>({char:"#",items:({query:e})=>P.current.filter(t=>t.display.toLowerCase().includes(e.toLowerCase())).map(e=>({id:e.id,title:e.display})),render:()=>{let e=null,t=null,r=[],a=null,l=()=>{a&&(document.removeEventListener("keydown",a,!0),a=null),t?.[0]?.destroy(),e?.destroy()};return{onStart:n=>{r=n.items||[],e=new i.NV(p.A,{props:{...n,nbrOfRows:I.current},editor:n.editor}),n.clientRect&&(t=(0,j.Ay)("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",zIndex:99999}),a=l=>{"Enter"===l.key&&r.length>0&&(l.preventDefault(),l.stopPropagation(),e?.ref?.onKeyDown({event:l})&&(t?.[0]?.hide(),document.removeEventListener("keydown",a,!0),a=null))},document.addEventListener("keydown",a,!0),Q.current=l)},onUpdate(a){r=a.items||[],e?.updateProps({...a,nbrOfRows:I.current}),a.clientRect&&t?.[0]?.setProps({getReferenceClientRect:a.clientRect})},onKeyDown(a){if("Escape"===a.event.key)return t?.[0]?.hide(),!0;if(r.length>0&&("ArrowUp"===a.event.key||"ArrowDown"===a.event.key||"ArrowRight"===a.event.key||"ArrowLeft"===a.event.key||"Enter"===a.event.key||"Tab"===a.event.key)){let r=e?.ref?.onKeyDown?.(a)??!1;return r&&("Enter"===a.event.key||"Tab"===a.event.key)&&t?.[0]?.hide(),r}return!1},onExit(){l(),Q.current=null}}}}),[]),X=(0,s.useRef)(e),Z=(0,s.useMemo)(()=>({onImageClick:e=>V.current(e)}),[]),ee=(0,i.hG)({immediatelyRender:!1,extensions:[o.A.configure({heading:{levels:[1,2,3]},bulletList:{},orderedList:{},codeBlock:{},blockquote:{},horizontalRule:{},bold:{},italic:{},strike:{},code:{}}),d.o.configure({html:!0,transformPastedText:!0,transformCopiedText:!1}),c.Ay.configure({resizable:!0}),x.A,m.h,u.A,h.Ay.configure({openOnClick:!0,autolink:!0}),...z?[]:[g.l7.configure({suggestion:Y})],b.f.configure(Z),f.n,y.F,v.q,k.U],content:"",editable:!K.current,autofocus:!K.current&&!!T&&"end",editorProps:{attributes:{class:"prompt-mention-editor focus:outline-none min-h-full h-full w-full"},handleKeyDown:(e,t)=>"Escape"===t.key&&J.current?(t.preventDefault(),t.stopPropagation(),J.current(),!0):"s"===t.key&&(!!t.ctrlKey||!!t.metaKey)&&!!q.current&&(t.preventDefault(),t.stopPropagation(),q.current(),!0)},onUpdate:({editor:e})=>{let t=S(e);W.current(t)}},[]);(0,s.useEffect)(()=>{if(ee&&X.current){let e=X.current,t=A(e);if(/#\[[^\]]+\]\((id|column):[^)]+\)/g.test(t))ee.commands.setContent($(t),!1);else{let e,r,a,l;(e=/^\s*\|.*\|/m.test(t)&&/^\s*\|[\s\-:|]+\|/m.test(t),r=/^#{1,6}\s+/m.test(t),a=/^[\s]*[-*+]\s+/m.test(t)||/^[\s]*\d+\.\s+/m.test(t),l=/^```/m.test(t),(e||r||a||l)&&!/<span data-type=/.test(t))?ee.commands.setContent(t,!1):ee.commands.setContent($(t),!1)}let r=S(ee);r!==e&&G.current?.(r,e)}},[ee]),(0,s.useEffect)(()=>{ee&&ee.setEditable(!B)},[ee,B]);let et="dark"===D,er=(0,s.useRef)(null);return(0,s.useImperativeHandle)(F,()=>({insertDependencyReferences:e=>!!ee&&0!==e.length&&(ee.chain().focus().insertContent((0,C.PS)(e)).run(),window.getSelection()?.collapseToEnd(),!0),insertTextBlock:e=>{if(!ee)return!1;let t=(0,C.X9)(e,S(ee).trim().length>0);return 0!==t.length&&(ee.commands.focus("end"),ee.chain().insertContent(t).run(),window.getSelection()?.collapseToEnd(),!0)},focusEditor:()=>{ee?.commands.focus()}}),[ee]),(0,a.jsxs)("div",{ref:er,style:M,onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),ee?.commands.focus()},onKeyDown:e=>{},"data-prompt-mention-editor":"true",className:n().dynamic([["9033043d14956084",[l,et?"#6b7280":"#9ca3af",et?"#1e3a8a":"#dbeafe",et?"#60a5fa":"#1e40af",et?"#374151":"#e5e7eb",et?"#1f2937":"#f3f4f6",et?"#111827":"#f9fafb",et?"#1f2937":"#f3f4f6",et?"#1f2937":"#f3f4f6",et?"#4b5563":"#d1d5db",et?"#9ca3af":"#6b7280",et?"#60a5fa":"#2563eb",et?"#93c5fd":"#1d4ed8",et?"#854d0e":"#fef08a",et?"#374151":"#e5e7eb"]]])+" prompt-mention-wrapper relative h-full w-full cursor-text",children:[(0,a.jsx)(i.$Z,{editor:ee,className:`h-full w-full overflow-auto ${_} ${N}`}),H&&(0,a.jsx)(w.A,{src:H,onClose:()=>O(null)}),(0,a.jsx)(n(),{id:"9033043d14956084",dynamic:[l,et?"#6b7280":"#9ca3af",et?"#1e3a8a":"#dbeafe",et?"#60a5fa":"#1e40af",et?"#374151":"#e5e7eb",et?"#1f2937":"#f3f4f6",et?"#111827":"#f9fafb",et?"#1f2937":"#f3f4f6",et?"#1f2937":"#f3f4f6",et?"#4b5563":"#d1d5db",et?"#9ca3af":"#6b7280",et?"#60a5fa":"#2563eb",et?"#93c5fd":"#1d4ed8",et?"#854d0e":"#fef08a",et?"#374151":"#e5e7eb"],children:`.prompt-mention-editor{white-space:pre-wrap;word-wrap:break-word;outline:none}.prompt-mention-editor p{margin:0;min-height:1.5em}.prompt-mention-editor.ProseMirror-focused p.is-editor-empty:first-child::before,.prompt-mention-editor p.is-empty:first-child::before{content:"${l}";color:${et?"#6b7280":"#9ca3af"};pointer-events:none;float:left;height:0}.prompt-mention-editor span[data-type="columnMention"]{background-color:${et?"#1e3a8a":"#dbeafe"};color:${et?"#60a5fa":"#1e40af"};border-radius:4px;padding:2px 6px;font-weight:500}.prompt-mention-wrapper .ProseMirror{min-height:100%;height:100%;outline:none}.prompt-mention-wrapper .ProseMirror:focus{outline:none}.prompt-mention-editor table{border-collapse:collapse;width:100%;margin:1em 0;table-layout:auto}.prompt-mention-editor th,.prompt-mention-editor td{border:1px solid ${et?"#374151":"#e5e7eb"};padding:8px 12px;text-align:left}.prompt-mention-editor th{background-color:${et?"#1f2937":"#f3f4f6"};font-weight:600}.prompt-mention-editor tr:nth-child(even){background-color:${et?"#111827":"#f9fafb"}}.prompt-mention-editor h1{font-size:1.75em;font-weight:700;margin:.67em 0}.prompt-mention-editor h2{font-size:1.5em;font-weight:600;margin:.75em 0}.prompt-mention-editor h3{font-size:1.25em;font-weight:600;margin:.83em 0}.prompt-mention-editor ul{list-style-type:disc;padding-left:1.5em;margin:.5em 0}.prompt-mention-editor ol{list-style-type:decimal;padding-left:1.5em;margin:.5em 0}.prompt-mention-editor li{margin:.25em 0}.prompt-mention-editor code{background-color:${et?"#1f2937":"#f3f4f6"};padding:.2em .4em;border-radius:3px;font-family:monospace;font-size:.9em}.prompt-mention-editor pre{background-color:${et?"#1f2937":"#f3f4f6"};padding:1em;border-radius:6px;overflow-x:auto;margin:1em 0}.prompt-mention-editor pre code{background:none;padding:0}.prompt-mention-editor blockquote{border-left:4px solid ${et?"#4b5563":"#d1d5db"};padding-left:1em;margin:1em 0;
5color:${et?"#9ca3af":"#6b7280"};font-style:italic}.prompt-mention-editor a{color:${et?"#60a5fa":"#2563eb"};text-decoration:underline;cursor:pointer}.prompt-mention-editor a:hover{color:${et?"#93c5fd":"#1d4ed8"}}.prompt-mention-editor mark{background-color:${et?"#854d0e":"#fef08a"};padding:.1em .2em;border-radius:2px}.prompt-mention-editor hr{border:none;border-top:2px solid ${et?"#374151":"#e5e7eb"};margin:1.5em 0}`})]})});E.displayName="PromptMentionEditor";let D=E},36802:(e,t,r)=>{r.d(t,{A:()=>o});var a=r(37876),l=r(14232),n=r(18847);let s=r.n(n)()(()=>r.e(850).then(r.bind(r,10850)),{loadableGenerated:{webpack:()=>[10850]},ssr:!1}),i={html:"html",css:"css",js:"javascript"},o=l.memo(function({value:e,language:t,theme:r="light",onChange:n,readOnly:o=!1}){let d=(0,l.useRef)(n);d.current=n;let c=(0,l.useCallback)(e=>{d.current(e??"")},[]);return(0,a.jsx)(s,{height:"100%",language:i[t],value:e,theme:"dark"===r?"vs-dark":"vs",onChange:c,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",readOnly:o,scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2}})})},56512:(e,t,r)=>{r.r(t),r.d(t,{default:()=>e$});var a,l=r(37876),n=r(14232),s=r(98477),i=r(43900),o=r(45832),d=r.n(o);r(72178),r(96098);var c=r(21808),u=r(31376);let m=({config:e,data:t})=>{if(!e||!t)return(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-gray-500",children:"No metric data"});let r=t.data;return!r||"object"!=typeof r||Array.isArray(r)?(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-gray-500",children:"Invalid metric data format"}):(0,l.jsxs)("div",{className:"flex h-full flex-col justify-center space-y-2",children:[(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)("div",{className:"text-sm text-gray-600 dark:text-neutral-400",children:r.label}),(0,l.jsxs)("div",{className:`text-2xl font-semibold ${(()=>{if(!e.metric?.threshold||"number"!=typeof r.value)return"text-gray-900 dark:text-neutral-100";let t=r.value;return t>=e.metric.threshold.critical?"text-red-600 dark:text-red-400":t>=e.metric.threshold.warning?"text-yellow-600 dark:text-yellow-400":"text-green-600 dark:text-green-400"})()}`,children:["number"==typeof r.value?r.value.toLocaleString():r.value,r.unit&&(0,l.jsx)("span",{className:"ml-1 text-base text-gray-500 dark:text-neutral-400",children:r.unit})]})]}),r.trend&&(0,l.jsxs)("div",{className:"flex items-center justify-center space-x-1",children:[(()=>{if(!r.trend)return null;switch(r.trend.direction){case"up":return(0,l.jsx)(u.uCC,{className:"text-green-500"});case"down":return(0,l.jsx)(u.$TP,{className:"text-red-500"});case"stable":return(0,l.jsx)(u.iu5,{className:"text-gray-500"});default:return null}})(),(0,l.jsxs)("span",{className:`text-sm font-medium ${(()=>{if(!r.trend)return"text-gray-500";if(r.trend.color)return r.trend.color;switch(r.trend.direction){case"up":return"text-green-500";case"down":return"text-red-500";default:return"text-gray-500"}})()}`,children:[Math.abs(r.trend.value),"%"]})]}),e.metric?.threshold&&"number"==typeof r.value&&(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsxs)("div",{className:"flex justify-between text-xs text-gray-500",children:[(0,l.jsxs)("span",{children:["Warning: ",e.metric.threshold.warning]}),(0,l.jsxs)("span",{children:["Critical: ",e.metric.threshold.critical]})]}),(0,l.jsx)("div",{className:"h-1 w-full rounded bg-gray-200 dark:bg-neutral-700",children:(0,l.jsx)("div",{className:`h-1 rounded transition-all duration-300 ${r.value>=e.metric.threshold.critical?"bg-red-500":r.value>=e.metric.threshold.warning?"bg-yellow-500":"bg-green-500"}`,style:{width:`${Math.min(100,r.value/e.metric.threshold.critical*100)}%`}})})]})]})};var x=r(72498),h=r(41505),g=r(34745),p=r(22551),b=r(89936),f=r(40803),y=r(68213),v=r(63013),k=r(98710),j=r(41220),w=r(60700),N=r(75162),_=r(69677),C=r(68493),S=r(47388),M=r(20947),A=r(18653);let $=["#3B82F6","#EF4444","#10B981","#F59E0B","#8B5CF6","#06B6D4","#F97316","#84CC16","#EC4899","#6B7280"],E="#00D26B",D=({config:e,data:t=null})=>{let r=e.chart,{resolvedTheme:a}
5=(0,x.D)(),[s,i]=(0,n.useState)(null),o=(0,n.useMemo)(()=>({backgroundColor:"dark"===a?"#1F2937":"#FFFFFF",border:"dark"===a?"none":"1px solid #E5E7EB",borderRadius:"12px",color:"dark"===a?"#F9FAFB":"#1F2937",fontSize:"13px",boxShadow:"dark"===a?"0 4px 12px rgba(0, 0, 0, 0.25)":"0 4px 12px rgba(0, 0, 0, 0.08)",padding:"8px 12px"}),[a]),d=(0,n.useMemo)(()=>({color:"dark"===a?"#D1D5DB":"#6B7280"}),[a]),c=(0,n.useMemo)(()=>({color:"dark"===a?"#F9FAFB":"#1F2937"}),[a]),u=(0,n.useMemo)(()=>t&&Array.isArray(t?.data)&&t?.data.length!==0?t.data:r?.type==="area"?Array.from({length:50},(e,t)=>{let r=Math.pow(1.15,t/10),a=5e3*Math.sin(.3*t)+8e3*Math.random();return{x:`${2016+Math.floor(t/5)}`,y:Math.floor(2e4*r+a),label:`Price ${t+1}`}}):Array.from({length:7},(e,t)=>({x:`Day ${t+1}`,y:Math.floor(100*Math.random())+20,label:`Sample ${t+1}`})),[t,r?.type]),m=s??u[u.length-1]?.y??null,D=e=>{e?.activePayload?.[0]&&i(e.activePayload[0].value)},L=()=>{i(null)};return(0,l.jsxs)("div",{className:"relative flex h-full w-full flex-col",children:[(()=>{if(r?.type!=="area")return null;let e=r?.label||"",t=u&&u.length>0?u[0].y:0,a=(m||0)-t,n=t>0?a/t*100:0;return(0,l.jsx)("div",{className:"mb-2 w-full rounded-xl bg-gray-900/95 p-4 dark:bg-neutral-800/95",children:(0,l.jsxs)("div",{className:"text-left",children:[(0,l.jsx)("div",{className:"mb-1 text-sm font-medium text-neutral-400",children:e}),(0,l.jsxs)("div",{className:"text-2xl font-bold text-white",children:["$",m?.toLocaleString()||"0"]}),a>0&&(0,l.jsxs)("div",{className:"mt-1 text-xs font-medium text-green-400",children:["+$",a.toLocaleString()," (+",n.toFixed(2),"%) Max"]})]})})})(),(0,l.jsx)("div",{className:"flex-1",children:(()=>{if(!r)return(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-neutral-500 dark:text-neutral-400",children:"No chart configuration"});switch(r.type){case"line":return(0,l.jsx)(h.u,{width:"100%",height:"100%",children:(0,l.jsxs)(g.b,{data:u,children:[(0,l.jsx)(p.d,{vertical:!1,strokeDasharray:"3 3",stroke:"#374151",strokeOpacity:.5}),(0,l.jsx)(b.W,{dataKey:"x",tick:{fontSize:11,fill:"#9CA3AF"},axisLine:!1,tickLine:!1}),(0,l.jsx)(f.h,{tick:{fontSize:11,fill:"#9CA3AF"},axisLine:!1,tickLine:!1}),(0,l.jsx)(y.m,{contentStyle:o,labelStyle:d,itemStyle:c}),(0,l.jsx)(v.N,{type:"natural",dataKey:"y",stroke:$[0],strokeWidth:2.5,dot:{fill:$[0],stroke:$[0],strokeWidth:2,r:3},activeDot:{r:5,stroke:$[0],strokeWidth:3,fill:"#FFFFFF"}})]})});case"bar":return(0,l.jsx)(h.u,{width:"100%",height:"100%",children:(0,l.jsxs)(k.E,{data:u,barCategoryGap:"20%",children:[(0,l.jsx)(p.d,{vertical:!1,strokeDasharray:"3 3",stroke:"#374151",strokeOpacity:.5}),(0,l.jsx)(b.W,{dataKey:"x",tick:{fontSize:11,fill:"#9CA3AF"},axisLine:!1,tickLine:!1}),(0,l.jsx)(f.h,{tick:{fontSize:11,fill:"#9CA3AF"},axisLine:!1,tickLine:!1}),(0,l.jsx)(y.m,{contentStyle:o,labelStyle:d,itemStyle:c,cursor:{fill:"rgba(255,255,255,0.04)"}}),(0,l.jsx)(j.y,{dataKey:"y",fill:$[0],fillOpacity:.7,radius:[6,6,0,0],stroke:$[0],strokeWidth:2})]})});case"area":return(0,l.jsx)(h.u,{width:"100%",height:"100%",children:(0,l.jsxs)(w.Q,{data:u,onMouseMove:D,onMouseLeave:L,children:[(0,l.jsx)("defs",{children:(0,l.jsxs)("linearGradient",{id:"bitcoinGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,l.jsx)("stop",{offset:"5%",stopColor:E,stopOpacity:.3}),(0,l.jsx)("stop",{offset:"95%",stopColor:E,stopOpacity:0})]})}),(0,l.jsx)(b.W,{dataKey:"x",tick:{fontSize:11,fill:"#9CA3AF"},stroke:"#4B5563",axisLine:!1,tickLine:!1}),(0,l.jsx)(f.h,{tick:{fontSize:11,fill:"#9CA3AF"},stroke:"#4B5563",axisLine:!1,tickLine:!1,tickFormatter:e=>e>=1e3?`$${(e/1e3).toFixed(0)}k`:`$${e}`}),(0,l.jsx)(y.m,{contentStyle:o,labelStyle:d,itemStyle:c,formatter:e=>[`$${e.toLocaleString()}`,"Price"]}),(0,l.jsx)(N.G,{type:"monotone",dataKey:"y",stroke:E,fill:"url(#bitcoinGradient)",strokeWidth:2.5,dot:!1,activeDot:{r:6,stroke:E,strokeWidth:3,fill:"#FFFFFF"}})]})});case"pie":return(0,l.jsx)(h.u,{width:"100%",height:"100%",children:(0,l.jsxs)(_.r,{children:[(0,l.jsx)(C.F,{data:u,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:3,fill:"#8884d8",dataKey:"y",nameKey:"x",label:({x:e,y:t,name:r,percent:a,fill:n})=>{let s=e>
5200?"start":"end";return(0,l.jsxs)("text",{x:e,y:t,fill:n,fillOpacity:1,fontSize:11,textAnchor:s,dominantBaseline:"central",children:[(0,l.jsx)("tspan",{x:e,dy:-6,textAnchor:s,children:r||""}),(0,l.jsx)("tspan",{x:e,dy:14,textAnchor:s,fontSize:11,fontWeight:600,children:`${(100*a).toFixed(0)}%`})]})},labelLine:{stroke:"#9CA3AF",strokeWidth:1},strokeWidth:2,children:(u||[]).map((e,t)=>(0,l.jsx)(S.f,{fill:$[t%$.length],fillOpacity:.7,stroke:$[t%$.length]},`cell-${t}`))}),(0,l.jsx)(y.m,{contentStyle:o,labelStyle:d,itemStyle:c})]})});case"scatter":return(0,l.jsx)(h.u,{width:"100%",height:"100%",children:(0,l.jsxs)(M.t,{data:u,children:[(0,l.jsx)(p.d,{vertical:!1,strokeDasharray:"3 3",stroke:"#374151",strokeOpacity:.5}),(0,l.jsx)(b.W,{dataKey:"x",tick:{fontSize:11,fill:"#9CA3AF"},axisLine:!1,tickLine:!1}),(0,l.jsx)(f.h,{tick:{fontSize:11,fill:"#9CA3AF"},axisLine:!1,tickLine:!1}),(0,l.jsx)(y.m,{contentStyle:o,labelStyle:d,itemStyle:c}),(0,l.jsx)(A.X,{dataKey:"y",fill:$[0],fillOpacity:.7,stroke:$[0],strokeWidth:2})]})});default:return(0,l.jsxs)("div",{className:"flex h-full items-center justify-center text-neutral-500 dark:text-neutral-400",children:["Unsupported chart type: ",r.type]})}})()})]})};var L=r(98312);let B=({config:e,data:t=null})=>{let r=e.table;if(!r)return(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-gray-500",children:"No table configuration"});let a=r.columns||[],n=r.max_rows||10,s=r.sort_by,i=r.sort_order||L.xB.Asc,o=Array.isArray(t?.data)?t?.data:Array.from({length:5},(e,t)=>{let r={id:`row-${t}`};return 0===a.length?(r.name=`Name ${t+1}`,r.value=`Value ${t+1}`,r.status=t%2==0?"Active":"Inactive"):a.forEach(e=>{r[e]=`Sample ${e} ${t+1}`}),r}),d=a.length>0?a.filter(e=>"id"!==e):Object.keys(o[0]||{}).filter(e=>"id"!==e),c=[...o].sort((e,t)=>{if(!s)return 0;let r=e[s],a=t[s];if("number"==typeof r&&"number"==typeof a)return i===L.xB.Asc?r-a:a-r;let l=String(r).toLowerCase(),n=String(a).toLowerCase();return i===L.xB.Asc?l.localeCompare(n):n.localeCompare(l)}).slice(0,n);return(0,l.jsx)("div",{className:"overflow-auto",children:(0,l.jsxs)("div",{className:"min-w-full",children:[(0,l.jsxs)("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[(0,l.jsx)("thead",{className:"bg-gray-50 dark:bg-neutral-800",children:(0,l.jsx)("tr",{children:d.map(e=>(0,l.jsxs)("th",{className:"px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-neutral-300",children:[e,s===e&&(0,l.jsx)("span",{className:"ml-1",children:i===L.xB.Asc?"↑":"↓"})]},e))})}),(0,l.jsx)("tbody",{className:"divide-y divide-gray-200 bg-white dark:divide-neutral-700 dark:bg-neutral-900",children:c.map((e,t)=>(0,l.jsx)("tr",{className:"hover:bg-gray-50 dark:hover:bg-neutral-800",children:d.map(t=>(0,l.jsx)("td",{className:"whitespace-nowrap px-3 py-2 text-sm text-gray-900 dark:text-neutral-100",children:"object"==typeof e[t]?JSON.stringify(e[t]):String(e[t]||"-")},t))},e.id||t))})]}),0===o.length&&(0,l.jsx)("div",{className:"flex h-32 items-center justify-center text-gray-500",children:"No data available"}),o.length>n&&(0,l.jsxs)("div",{className:"p-3 text-center text-sm text-gray-500",children:["Showing ",n," of ",o.length," rows"]})]})})},T=({config:e,data:t})=>{let r=Array.isArray(t?.data)?t.data:[],a=r.length>0&&"x"in r[0]&&"y"in r[0],n=a||r.length>0?r:Array.from({length:7},(e,t)=>Array.from({length:24},(e,r)=>({row:t,col:r,value:Math.floor(100*Math.random()),label:`${t}:${r}`}))).flat();if(a){let t=Math.max(...r.map(e=>e.y||0)),a=Math.min(...r.map(e=>e.y||0)),n=e=>{let t=Math.max(.1,e);return`rgba(59, 130, 246, ${t})`};return(0,l.jsx)("div",{className:"h-full overflow-auto p-4",children:(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("div",{className:"text-center",children:(0,l.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-neutral-100",children:e.metric?.label||"Heatmap"})}),(0,l.jsx)("div",{className:"flex flex-wrap gap-2",children:r.map((e,r)=>{var s;let i=(s=e.y,t===a?.5:(s-a)/(t-a));return(0,l.jsxs)("div",{className:"flex flex-col items-center space-y-1",children:[(0,l.jsx)("div",{className:"flex h-16 w-16 items-center justify-center rounded-md border border-gray-200 dark:border-neutral-700",style:{backgroundColor:n(i)},title:`${e.x}: ${e.y}`,children:(0,l.jsx)("span",{className:"text-xs font-semibold text-white drop-shadow-md",children:e.y})}),(0,l.jsx)("div",{className:"max-w-[64px] truncate text-xs text-gray-600 dark:text-neutral-400",children:e.label||e.x})]},r)})}),(0,l.jsxs)("div",{className:"flex items-center justify-between pt-2 text-xs text-gray-500",children:[(0,l.jsx)("span",{children:"Less"}),(0,l.jsx)("div",{className:"flex space-x-1",children:Array.from({length:5},(e,t)=>(0,l.jsx)("div",{className:"h-3 w-3 rounded-sm border border-gray-200",style:{backgroundColor:n(t/4)}},t))}),(0,l.jsx)("span",{children:"More"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-3 gap-2 pt-2 text-center text-xs",children:[(0,l.jsxs)("div",{className:"rounded bg-gray-50 p-2 dark:bg-neutral-800",children:[(0,l.jsx)("div",{className:"font-medium text-gray-900 dark:text-neutral-100",children:t}),(0,l.jsx)("div",{className:"text-gray-600 dark:text-neutral-400",children:"Max"})]}),(0,l.jsxs)("div",{className:"rounded bg-gray-50 p-2 dark:bg-neutral-800",children:[(0,l.jsx)("div",{className:"font-medium text-gray-900 dark:text-neutral-100",children:Math.round(r.reduce((e,t)=>
5e+t.y,0)/r.length)}),(0,l.jsx)("div",{className:"text-gray-600 dark:text-neutral-400",children:"Avg"})]}),(0,l.jsxs)("div",{className:"rounded bg-gray-50 p-2 dark:bg-neutral-800",children:[(0,l.jsx)("div",{className:"font-medium text-gray-900 dark:text-neutral-100",children:a}),(0,l.jsx)("div",{className:"text-gray-600 dark:text-neutral-400",children:"Min"})]})]})]})})}let s=Math.max(...n.map(e=>e.value||0)),i=Math.min(...n.map(e=>e.value||0)),o=e=>{let t=Math.max(.1,e);return`rgba(59, 130, 246, ${t})`},d=Array.from({length:24},(e,t)=>t);return(0,l.jsx)("div",{className:"h-full overflow-auto",children:(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("div",{className:"text-center",children:(0,l.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-neutral-100",children:"Activity Heatmap"})}),(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsxs)("div",{className:"flex",children:[(0,l.jsx)("div",{className:"w-12"})," ",d.filter((e,t)=>t%4==0).map(e=>(0,l.jsx)("div",{className:"flex-1 text-center text-xs text-gray-500",style:{marginLeft:0===e?0:"12px"},children:e},e))]}),["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map((e,t)=>(0,l.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,l.jsx)("div",{className:"w-12 text-xs text-gray-500 dark:text-neutral-400",children:e}),(0,l.jsx)("div",{className:"flex space-x-1",children:d.map(r=>{let a=n.find(e=>e.row===t&&e.col===r),d=a?.value||0;return(0,l.jsx)("div",{className:"h-3 w-3 rounded-sm border border-gray-200 dark:border-neutral-700",style:{backgroundColor:o(s===i?.5:(d-i)/(s-i))},title:`${e} ${r}:00 - ${d}`},`${t}-${r}`)})})]},e))]}),(0,l.jsxs)("div",{className:"flex items-center justify-between pt-2 text-xs text-gray-500",children:[(0,l.jsx)("span",{children:"Less"}),(0,l.jsx)("div",{className:"flex space-x-1",children:Array.from({length:5},(e,t)=>(0,l.jsx)("div",{className:"h-3 w-3 rounded-sm border border-gray-200",style:{backgroundColor:o(t/4)}},t))}),(0,l.jsx)("span",{children:"More"})]}),(0,l.jsxs)("div",{className:"grid grid-cols-3 gap-2 pt-2 text-center text-xs",children:[(0,l.jsxs)("div",{className:"rounded bg-gray-50 p-2 dark:bg-neutral-800",children:[(0,l.jsx)("div",{className:"font-medium text-gray-900 dark:text-neutral-100",children:s}),(0,l.jsx)("div",{className:"text-gray-600 dark:text-neutral-400",children:"Max"})]}),(0,l.jsxs)("div",{className:"rounded bg-gray-50 p-2 dark:bg-neutral-800",children:[(0,l.jsx)("div",{className:"font-medium text-gray-900 dark:text-neutral-100",children:Math.round((s+i)/2)}),(0,l.jsx)("div",{className:"text-gray-600 dark:text-neutral-400",children:"Avg"})]}),(0,l.jsxs)("div",{className:"rounded bg-gray-50 p-2 dark:bg-neutral-800",children:[(0,l.jsx)("div",{className:"font-medium text-gray-900 dark:text-neutral-100",children:i}),(0,l.jsx)("div",{className:"text-gray-600 dark:text-neutral-400",children:"Min"})]})]})]})})},R=({config:e,data:t})=>{let r=t?.data??t,a=r?.value??75,n=r?.min??0,s=r?.max??100,i=r?.label??e.metric?.label??"Performance",o=r?.unit??e.metric?.unit??"%",d=Math.max(0,Math.min(1,(a-n)/(s-n))),c=d<.3?"#EF4444":d<.7?"#F59E0B":"#10B981",u=46*Math.PI,m=`${u*d} ${u}`;return(0,l.jsxs)("div",{className:"flex h-full flex-col items-center justify-center space-y-4",children:[(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsxs)("svg",{width:164,height:94,className:"-rotate-90 transform",children:[(0,l.jsx)("path",{d:"M 12 82 A 46 46 0 0 1 152 82",fill:"none",stroke:"#E5E7EB",strokeWidth:12,strokeLinecap:"round"}),(0,l.jsx)("path",{d:"M 12 82 A 46 46 0 0 1 152 82",fill:"none",stroke:c,strokeWidth:12,strokeLinecap:"round",strokeDasharray:m,className:"transition-all duration-1000 ease-out"})]}),(0,l.jsx)("div",{className:"absolute left-1/2 top-0 origin-bottom",style:{width:"2px",height:"70px",backgroundColor:"#374151",transform:`translateX(-50%) rotate(${-90+180*d}deg)`,transition:"transform 1s ease-out"},children:(0,l.jsx)("div",{className:"absolute -left-1 -top-1 h-3 w-3 rounded-full bg-gray-700"})}),(0,l.jsx)("div",{className:"absolute rounded-full bg-gray-700",style:{width:"8px",height:"8px",top:"78px",left:"78px"}})]}),(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsxs)("div",{className:"text-2xl font-semibold",style:{color:c},children:["number"==typeof a?a.toFixed(1):a,(0,l.jsx)("span",{className:"ml-1 text-base text-gray-500",children:o})]}),(0,l.jsx)("div",{className:"text-sm text-gray-600 dark:text-neutral-400",children:i})]}),(0,l.jsxs)("div",{className:"flex w-full justify-between text-xs text-gray-500",children:[(0,l.jsxs)("span",{children:[n,o]}),(0,l.jsxs)("span",{children:[s,o]})]}),(0,l.jsxs)("div",{className:"inline-flex items-center rounded-full px-2 py-1 text-xs font-medium",style:{backgroundColor:`${c}20`,color:c},children:[(0,l.jsx)("div",{className:"mr-1 h-2 w-2 rounded-full",style:{backgroundColor:c}}),d<.3?"Low":d<.7?"Medium":"High"]})]})},U=({config:e,data:t=null})=>{let r=Array.isArray(t?.data)?t.data:[{x:"0-20",y:5,label:"0-20%"},{x:"21-40",y:12,label:"21-40%"},{x:"41-60",y:25,label:"41-60%"},{x:"61-80",y:35,label:"61-80%"},{x:"81-100",y:23,label:"81-100%"}],a=r.reduce((e,t)=>
5e+(t.y||0),0),n=Math.max(...r.map(e=>e.y||0));return(0,l.jsxs)("div",{className:"h-full space-y-4",children:[(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)("h3",{className:"text-sm font-medium text-gray-900 dark:text-neutral-100",children:"Distribution"}),(0,l.jsxs)("p",{className:"text-xs text-gray-600 dark:text-neutral-400",children:["Total: ",a.toLocaleString()]})]}),(0,l.jsx)("div",{className:"h-32",children:(0,l.jsx)(h.u,{width:"100%",height:"100%",children:(0,l.jsxs)(k.E,{data:r,margin:{top:5,right:5,left:5,bottom:5},children:[(0,l.jsx)(b.W,{dataKey:"x",axisLine:!1,tickLine:!1,tick:{fontSize:10,fill:"#6B7280"}}),(0,l.jsx)(f.h,{hide:!0}),(0,l.jsx)(y.m,{contentStyle:{backgroundColor:"#1F2937",border:"none",borderRadius:"8px",color:"#F9FAFB",fontSize:"12px"},formatter:(e,t)=>[`${e} (${(e/a*100).toFixed(1)}%)`,"Count"]}),(0,l.jsx)(j.y,{dataKey:"y",fill:"#3B82F6",radius:[2,2,0,0]})]})})}),(0,l.jsx)("div",{className:"space-y-2",children:r.map((e,t)=>{let r=a>0?e.y/a*100:0,s=n>0?e.y/n*100:0;return(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsxs)("div",{className:"flex justify-between text-xs",children:[(0,l.jsx)("span",{className:"text-gray-700 dark:text-neutral-300",children:e.label||e.x}),(0,l.jsxs)("span",{className:"text-gray-600 dark:text-neutral-400",children:[e.y," (",r.toFixed(1),"%)"]})]}),(0,l.jsx)("div",{className:"h-1 w-full rounded-full bg-gray-200 dark:bg-neutral-700",children:(0,l.jsx)("div",{className:"h-1 rounded-full bg-blue-500 transition-all duration-300",style:{width:`${s}%`}})})]},e.x||t)})}),(0,l.jsxs)("div",{className:"grid grid-cols-3 gap-2 border-t border-gray-200 pt-2 dark:border-neutral-700",children:[(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-neutral-100",children:Math.max(...r.map(e=>e.y||0))}),(0,l.jsx)("div",{className:"text-xs text-gray-600 dark:text-neutral-400",children:"Max"})]}),(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-neutral-100",children:Math.round(a/r.length)}),(0,l.jsx)("div",{className:"text-xs text-gray-600 dark:text-neutral-400",children:"Avg"})]}),(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-neutral-100",children:Math.min(...r.map(e=>e.y||0))}),(0,l.jsx)("div",{className:"text-xs text-gray-600 dark:text-neutral-400",children:"Min"})]})]})]})};var z=r(26206);let F=({config:e,data:t,structured:r=!0,theme:a,size:n})=>{let s;return t?(s="string"==typeof t.data?t.data:t.data&&"object"==typeof t.data?JSON.stringify(t.data,null,2):"No content available",(0,l.jsx)("div",{className:"h-full",children:(0,l.jsx)("div",{className:"h-full overflow-auto text-sm text-gray-900 dark:text-neutral-100",children:(0,l.jsx)(z.A,{content:s,size:n??"text-xs",fontcolor:"dark"==a?"white":"black",activationMode:"viewport",viewDensity:"expanded"})})})):(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-gray-500",children:"No text data"})};var H=r(42252),O=r(77542),P=r(90864),I=r(70997),K=r(66332),W=r(98132),G=r(70087);let V=({cardId:e,channel:t,theme:r="light",isEditing:a=!1})=>{let s=t||`dashboard_card_${e}`;(0,K.d)({channelId:s});let i=(0,P.b)(e=>e.editorsByChannel[s]),o=(0,P.b)(e=>e.setEditor),{agentId:d}=(0,I.J)(),{data:c}=(0,H.I)({queryKey:["html_editors_by_channel",s],queryFn:async()=>(await O.ApiClient.htmlEditor.getHtmlEditorsByChannelHtmlEditorGetHtmlEditorsByChannelPost({channel:s,agent_id:d})).data,staleTime:3e4,refetchOnWindowFocus:!1}),u=c?.[0]?.editor_id,{data:m}=(0,H.I)({queryKey:["html_editor_by_id",u],queryFn:async()=>u?(await O.ApiClient.htmlEditor.getHtmlEditorByIdHtmlEditorGetHtmlEditorByIdPost({editor_id:u,agent_id:d})).data:null,enabled:!!u,staleTime:3e4,refetchOnWindowFocus:!1});return((0,n.useEffect)(()=>{!m||P.b.getState().editorsByChannel[s]||o(s,{editor_id:m.editor_id,title:m.title,html_content:m.html_content??"",css_content:m.css_content??"",js_content:m.js_content??"",dependencies:m.dependencies??[],updatedAt:m.updated_at??new Date().toISOString(),lastAction:"idle",exportReady:!1})},[m,s,o]),i)?(0,l.jsxs)("div",{className:"relative h-full",children:[(0,l.jsx)("div",{className:a?"absolute inset-0 z-10":"hidden",children:(0,l.jsx)(G.A,{channelId:s,theme:r})}),(0,l.jsx)("div",{className:a?"invisible h-full":"h-full",children:(0,l.jsx)(W.A,{htmlContent:i.html_content,cssContent:i.css_content,jsContent:i.js_content,dependencies:i.dependencies,theme:r})})]}):(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-gray-400",children:"No HTML content"})};var q=r(9642),J=r(11512),Q=r(53013),Y=r(1144),X=r(49756),Z=r(93991);let ee={[L.bU.Chart]:u.YYR,[L.bU.PlainText]:Y.MRc,[L.bU.Metric]:Z.KZj,[L.bU.Gauge]:i.YSH,[L.bU.Table]:u.ist,[L.bU.Heatmap]:i.XP9,[L.bU.Distribution]:X.iZI,[L.bU.HtmlEditor]:X.CWz,[L.bU.Row]:X.aKs},et=({card:e,onEdit:t,onDirectEdit:r,onDelete:a,onDuplicate:i,onResize:o,onMove:d,onLlmChange:u,editMode:x=!1,data:h,isRunning:g=!1,hasError:p=!1,errorMessage:b,onClearError:f,onRun:y,panelTitle:v,theme:k})=>{let{t:j,i18n:w}
5=(0,c.Bd)("user"),N=(0,n.useRef)(null),[_,C]=(0,n.useState)(!1),[S,M]=(0,n.useState)({x:0,y:0}),[A,$]=(0,n.useState)(!1),[E,L]=(0,n.useState)(!1),z=ee[e.type]??X.aKs,H=(0,n.useMemo)(()=>(e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()})(h?.last_updated),[h?.last_updated]),O=function(e,t=!1,r=0){let{getGridCellData:a}=(0,q.u)();return(0,n.useMemo)(()=>(0,J.R)(e,a,t,r),[e,a,t,r])}("mirror"===e.content_mode?e.content_template:null,"plain_text"!==e.type),P=(0,n.useMemo)(()=>{if("mirror"!==e.content_mode||!e.content_template)return h;if("plain_text"===e.type)return{card_id:e.id,data:O,last_updated:new Date().toISOString()};try{let t=JSON.parse(O);return{card_id:e.id,data:t,last_updated:new Date().toISOString()}}catch{return h}},[e.content_mode,e.content_template,e.type,e.id,O,h]);return"row"===e.type?null:(0,l.jsxs)("div",{ref:N,className:`
6        group relative flex h-full w-full flex-col rounded-lg border p-2
7        ${x?"border-blue-100 bg-blue-50 dark:border-blue-800/40 dark:bg-blue-900/20":"border-gray-100 bg-white/50 dark:border-neutral-800 dark:bg-neutral-900/30"}
8        ${_?"shadow-md":""}
9        ${g?"ring-1 ring-orange-400 dark:ring-orange-500":""}
10        ${p?"ring-1 ring-red-500 dark:ring-red-400":""}
11        transition-[background-color,border-color,box-shadow] duration-150 ease-out
12      `,style:{zIndex:_?1e3:1},onMouseDown:e=>{},children:[g&&(0,l.jsx)("div",{className:"absolute inset-0 rounded-lg bg-orange-100/50 dark:bg-orange-900/30",children:(0,l.jsxs)("div",{className:"absolute right-2 top-2 flex items-center space-x-2",children:[(0,l.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,l.jsx)("div",{className:"h-2 w-2 animate-pulse rounded-full bg-orange-500"}),(0,l.jsx)("div",{className:"h-2 w-2 animate-pulse rounded-full bg-orange-500",style:{animationDelay:"0.2s"}}),(0,l.jsx)("div",{className:"h-2 w-2 animate-pulse rounded-full bg-orange-500",style:{animationDelay:"0.4s"}})]}),(0,l.jsx)("span",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:"Processing..."})]})}),p&&!g&&(0,l.jsx)("div",{className:"absolute inset-0 rounded-lg bg-red-100/50 dark:bg-red-900/30",children:(0,l.jsxs)("div",{className:"absolute right-2 top-2 flex items-center space-x-2",children:[(0,l.jsx)("div",{className:"flex items-center space-x-1",children:(0,l.jsx)("svg",{className:"h-4 w-4 text-red-500",fill:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})})}),(0,l.jsx)("span",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:"Error"}),f&&(0,l.jsx)("button",{onClick:t=>{t.stopPropagation(),f(e.id)},className:"rounded-full p-1 text-red-500 hover:bg-red-200 dark:hover:bg-red-800",title:"Effacer l'erreur",children:(0,l.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),(!1!==e.config.show_header||x)&&(0,l.jsxs)("div",{className:`mb-2 flex flex-shrink-0 items-center justify-between gap-2 px-2 py-1 ${g?"relative z-10":""}`,onMouseDown:e=>{x&&e.target!==e.currentTarget&&e.stopPropagation()},children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,l.jsx)(z,{className:"h-4 w-4 flex-shrink-0 text-gray-400 dark:text-neutral-500"}),(0,l.jsxs)("h3",{className:"min-w-0 flex-1 truncate text-sm font-medium text-gray-900 dark:text-neutral-100",children:[e.title,g&&(0,l.jsx)("span",{className:"ml-2 inline-flex items-center",children:(0,l.jsxs)("svg",{className:"h-4 w-4 animate-spin text-orange-500",fill:"none",viewBox:"0 0 24 24",children:[(0,l.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,l.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})]}),v&&(0,l.jsx)("span",{className:"max-w-32 flex-shrink-0 truncate rounded-md border border-gray-200 bg-gray-50 px-1.5 py-0.5 text-[11px] font-medium text-gray-500 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-400",title:`Panel: ${v}`,children:v}),H&&!x&&(0,l.jsx)("div",{className:"flex-shrink-0 opacity-0 transition-opacity duration-150 ease-out group-hover:opacity-100",children:(0,l.jsx)(Q.A,{text:`Last Ru
12n: ${H}`,options:"bottom",children:(0,l.jsx)("button",{type:"button",className:"flex h-6 w-6 items-center justify-center rounded-md text-gray-400 transition-colors duration-150 ease-out hover:bg-gray-100 hover:text-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500/40 dark:text-neutral-500 dark:hover:bg-neutral-700 dark:hover:text-neutral-300","aria-label":`Last Run: ${H}`,onMouseDown:e=>e.stopPropagation(),children:(0,l.jsx)(X.CwO,{className:"h-4 w-4"})})})})]}),(y&&!g&&!x||x||r)&&(0,l.jsxs)("div",{className:`flex space-x-1 ${!x?"opacity-0 transition-opacity group-hover:opacity-100":""} ${g?"relative z-10":""}`,onMouseDown:e=>e.stopPropagation(),children:[!x&&"plain_text"===e.type&&(0,l.jsx)("button",{onClick:()=>$(!0),className:"rounded p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-neutral-700 dark:hover:text-neutral-300",title:"Expand card",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M2
120.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})})}),r&&!x&&(0,l.jsx)("button",{onClick:()=>r(e),className:"rounded p-1 text-gray-400 hover:bg-blue-100 hover:text-blue-600 dark:hover:bg-blue-900 dark:hover:text-blue-400",title:"Edit this card",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),"html_editor"===e.type&&!x&&(0,l.jsx)("button",{onClick:()=>L(e=>!e),className:`rounded p-1 transition-colors ${E?"bg-blue-100 text-blue-600 dark:bg-blue-900 dark:text-blue-400":"text-gray-400 hover:bg-blue-100 hover:text-blue-600 dark:hover:bg-blue-900 dark:hover:text-blue-400"}`,title:E?"Close code editor":"Edit HTML code",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.25 6.75 22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3-4.5 16.5"})})}),y&&!g&&!x&&(0,l.jsx)("button",{onClick:()=>y({agent_options:{run_dashboard:!0},list_of_card_ids:[e.id],success_message:"Card executed successfully"}),className:"rounded p-1 text-gray-400 hover:bg-green-100 hover:text-green-600 dark:hover:bg-green-900 dark:hover:text-green-400",title:"Run this card only",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{d:"M8 5v14l11-7z"})})}),x&&t&&(0,l.jsx)("button",{onClick:()=>t(e),className:"rounded p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:"Edit card",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),x&&i&&(0,l.jsx)("button",{onClick:()=>i(e),className:"rounded p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-700 dark:hover:text-gray-300",title:"Duplicate card",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75"})})}),x&&a&&(0,l.jsx)("button",{onClick:()=>a(e.id),className:"rounded p-1 text-gray-400 hover:bg-red-100 hover:text-red-600 dark:hover:bg-red-900 dark:hover:text-red-400",title:"Delete card",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),!1===e.config.show_header&&!x&&(y&&!g||r)&&(0,l.jsxs)("div",{className:"absolute right-2 top-2 z-10 flex space-x-1 rounded-md bg-black/30 p-1 opacity-0 transition-opacity hover:opacity-100 group-hover:opacity-100",onMouseDown:e=>e.stopPropagation(),children:["plain_text"===e.type&&(0,l.jsx)("button",{onClick:()=>$(!0),className:"rounded p-1 text-white/70 hover:bg-white/20 hover:text-white",title:"Expand card",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M2
120.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})})}),r&&(0,l.jsx)("button",{onClick:()=>r(e),className:"rounded p-1 text-white/70 hover:bg-white/20 hover:text-white",title:"Edit this card",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),"html_editor"===e.type&&(0,l.jsx)("button",{onClick:()=>L(e=>!e),className:`rounded p-1 transition-colors ${E?"bg-white/30 text-white":"text-white/70 hover:bg-white/20 hover:text-white"}`,title:E?"Close code editor":"Edit HTML code",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.25 6.75 22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3-4.5 16.5"})})}),y&&!g&&(0,l.jsx)("button",{onClick:()=>y({agent_options:{run_dashboard:!0},list_of_card_ids:[e.id],success_message:"Card executed successfully"}),className:"rounded p-1 text-white/70 hover:bg-white/20 hover:text-white",title:"Run this card only",children:(0,l.jsx)("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{d:"M8 5v14l11-7z"})})})]}),(0,l.jsx)("div",{className:`min-h-0 flex-1 overflow-hidden rounded-lg border border-gray-200 bg-white p-2 shadow-sm dark:border-neutral-700 dark:bg-neutral-800 ${g?"relative z-10":""} ${!1===e.config.show_header&&E?"pt-10":""}`,children:(()=>{switch(e.type){case"row":return null;case"metric":return(0,l.jsx)(m,{config:e.config,data:P});case"chart":return(0,l.jsx)(D,{config:e.config,data:P});case"table":return(0,l.jsx)(B,{config:e.config,data:P});case"heatmap":return(0,l.jsx)(T,{config:e.config,data:P});case"gauge":return(0,l.jsx)(R,{config:e.config,data:P});case"distribution":return(0,l.jsx)(U,{config:e.config,data:P});case"plain_text":return(0,l.jsx)(F,{config:e.config,data:P,structured:e.structured,theme:k});case"html_editor":return(0,l.jsx)(V,{config:e.config,data:P,cardId:e.id,channel:e.channel??void 0,theme:k,isEditing:E});default:return(0,l.jsx)("div",{className:"p-4 text-gray-500",children:"Unknown card type"})}})()}),A&&(0,s.createPortal)((0,l.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/50",onClick:()=>$(!1),children:(0,l.jsxs)("div",{className:"relative mx-4 flex max-h-[85vh] w-full max-w-4xl flex-col rounded-xl bg-white shadow-2xl dark:border dark:border-neutral-700 dark:bg-neutral-800",onClick:e=>e.stopPropagation(),children:[(0,l.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-neutral-700",children:[(0,l.jsx)("h2",{className:"text-lg font-semibold text-gray-900 dark:text-neutral-100",children:e.title}),(0,l.jsx)("button",{onClick:()=>$(!1),className:"rounded-full p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-neutral-700 dark:hover:text-neutral-300",children:(0,l.jsx)("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,l.jsx)("div",{className:"flex-1 overflow-auto p-6",children:(0,l.jsx)("div",{className:"text-base text-gray-900 dark:text-neutral-100",children:(0,l.jsx)(F,{config:e.config,data:P,structured:e.structured,theme:k,size:"text-sm"})})})]})}),document.body)]})},er=[{id:"metric",label:"Metric",icon:Z.KZj,action:"card",cardType:L.bU.Metric},{id:"chart",label:"Chart",icon:u.YYR,action:"card",cardType:L.bU.Chart},{id:"table",label:"Table",icon:u.ist,action:"card",cardType:L.bU.Table},{id:"heatmap",label:"Heatmap",icon:i.XP9,action:"card",cardType:L.bU.Heatmap},{id:"gauge",label:"Gauge",icon:i.YSH,action:"card",cardType:L.bU.Gauge},{id:"distribution",label:"Distribution",icon:X.iZI,action:"card",cardType:L.bU.Distribution},{id:"plain-text",label:"Plain Text",icon:Y.MRc,action:"card",cardType:L.bU.PlainText},{id:"html-editor",label:"HTML Editor",icon:X.CWz,action:"card",cardType:L.bU.HtmlEditor},{id:"grid-data",label:"Grid Data",icon:X.Lcf,action:"grid-data"}],ea=({triggerLabel:e,align:t="right",variant:r="secondary",onAddCardType:a,onOpenGridData:s})=>
12{let[i,o]=(0,n.useState)(!1),d=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!i)return;let e=e=>{d.current?.contains(e.target)||o(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),(0,l.jsxs)("div",{ref:d,className:"relative inline-flex",children:[(0,l.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:"primary"===r?"inline-flex h-9 items-center gap-1.5 rounded-lg bg-blue-500 px-4 text-sm font-medium text-white transition-[background-color,transform] duration-150 ease-out hover:bg-blue-600 active:scale-[0.96]":"flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 bg-white px-4 text-sm font-medium text-gray-700 shadow-sm transition-[background-color,border-color,box-shadow,transform] duration-150 ease-out hover:bg-gray-50 active:scale-[0.96] dark:border-neutral-600 dark:bg-neutral-800 dark:text-neutral-200 dark:hover:bg-neutral-700",title:"Add to dashboard",children:[(0,l.jsx)(u.OiG,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:e}),(0,l.jsx)(u.Vr3,{className:"h-3 w-3"})]}),i&&(0,l.jsxs)("div",{className:`absolute top-full z-50 mt-2 w-72 rounded-xl border border-gray-200 bg-white p-3 shadow-lg dark:border-neutral-700 dark:bg-neutral-800 ${"center"===t?"left-1/2 -translate-x-1/2":"right-0"}`,children:[(0,l.jsx)("p",{className:"mb-2 px-1 text-xs font-medium text-gray-400 dark:text-neutral-500",children:"Add to dashboard"}),(0,l.jsx)("div",{className:"grid grid-cols-4 gap-1",children:er.map(e=>{let t=e.icon;return(0,l.jsxs)("button",{type:"button",onClick:()=>{(o(!1),"card"===e.action&&e.cardType)?a(e.cardType):s()},className:"flex flex-col items-center gap-1.5 rounded-lg px-1 py-2.5 text-center transition-colors duration-150 ease-out hover:bg-gray-100 dark:hover:bg-neutral-700",children:[(0,l.jsx)(t,{className:"h-5 w-5 text-gray-600 dark:text-neutral-300"}),(0,l.jsx)("span",{className:"text-[11px] font-medium leading-tight text-gray-600 dark:text-neutral-300",children:e.label})]},e.id)})})]})]})};var el=r(62549),en=r(60984),es=r(68835),ei=r(55668),eo=r(19861);let ed={[L.bU.Metric]:"Metric",[L.bU.Chart]:"Chart",[L.bU.Table]:"Table",[L.bU.Heatmap]:"Heatmap",[L.bU.Gauge]:"Gauge",[L.bU.Distribution]:"Distribution",[L.bU.PlainText]:"Plain Text",[L.bU.HtmlEditor]:"HTML Editor",[L.bU.Row]:"Section"},ec=(e,t,r)=>{let a={...r,show_header:r?.show_header??!0,data_source:r?.data_source??{type:L.ol.AgentData,agent_id:t}},l=r?.metric?.label||"";return e===L.bU.Metric||e===L.bU.Gauge||e===L.bU.Heatmap?{...a,metric:{value:null,label:l,unit:null,trend:null,threshold:null},chart:null,table:null}:e===L.bU.Chart?{...a,chart:{type:L.NB.Pie,x_axis:null,y_axis:null,aggregation:null,time_range:null,group_by:null},metric:null,table:null}:e===L.bU.Table?{...a,table:{columns:[],max_rows:10,sort_by:null,sort_order:null,filters:null},metric:null,chart:null}:e===L.bU.Distribution?{...a,chart:{type:L.NB.Bar,x_axis:null,y_axis:null,aggregation:L.DF.Count,time_range:null,group_by:null},metric:null,table:null}:e===L.bU.Row?{...a,show_header:!1,metric:null,chart:null,table:null}:{...a,metric:null,chart:null,table:null}},eu=(e,t,r)=>({title:"",type:t,position:{x:0,y:0},size:{width:300,height:200},structured:!0,row_id:t===L.bU.Row?null:r??null,config:ec(t,e)}),em=({llmId:e,reasoningEffort:t,onChange:r,onReasoningEffortChange:a})=>{let{data:n}=(0,el.K)({networkMode:"offlineFirst"}),{userSettings:s}=(0,en.t0)(),i=e??s?.configSettings?.llm_id??null,o=t??s?.configSettings?.reasoning_effort??null;return(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"LLM Model"}),(0,l.jsx)(es.A,{llmId:i,llmOptions:n,reasoningEffort:o,onSelectLLM:(e,t)=>{e.enabled&&r(e.id,t||(0,ei.LW)(e))},onSelectReasoningEffort:a,onSelectDefault:()=>r(void 0,(0,ei.SP)(s?.configSettings?.reasoning_effort)),defaultLabel:"Use default LLM",className:"mt-1 w-full",buttonClassName:"w-full",menuClassName:"w-full",ariaLabel:"Select dashboard card model"})]})},ex=({isOpen:e,onClose:t,card:r,cardData:a,initialCardType:s,hideTypeSelectorOnCreate:i=!1,agentId:o,columns:d,panelOptions:c=[],initialPanelId:m=null,onSave:x,theme:h,nbrOfRows:g=0})=>{let{userSettings:p}
12=(0,en.t0)(),b=s??L.bU.Metric,f=eu(o,b,m),[y,v]=(0,n.useState)(r||f),[k,j]=(0,n.useState)(()=>r?.content_mode==="mirror"?"mirror":"nlp"),[w,N]=(0,n.useState)(!1),_=(0,n.useCallback)(()=>{let e=a?.data;return null==e?"":"string"==typeof e?e:JSON.stringify(e,null,2)},[a]),C={agentId:o,card:r,createCardType:b,initialPanelId:m},[S,M]=(0,n.useState)(null);if(!S||S.agentId!==C.agentId||S.card!==C.card||S.createCardType!==C.createCardType||S.initialPanelId!==C.initialPanelId)if(M(C),r){let e=r.content_template||("mirror"===r.content_mode?_():"");v({...r,content_template:e||r.content_template}),j("mirror"===r.content_mode?"mirror":"nlp")}else v(eu(o,b,m)),j("nlp");let A=async()=>{N(!0);let e=r?.id||`card-${Date.now()}`,t=y.type||L.bU.Metric,a=t===L.bU.HtmlEditor,l={id:e,title:y.title||"Untitled Card",type:t,position:y.position||{x:0,y:0},size:y.size||{width:300,height:200},prompt:y.prompt||"",structured:!a&&(void 0===y.structured||y.structured),llm_id:y.llm_id||p?.configSettings?.llm_id,reasoning_effort:y.reasoning_effort??p?.configSettings?.reasoning_effort??null,content_template:y.content_template||null,content_mode:k,row_id:t===L.bU.Row?null:y.row_id??null,config:y.config||{show_header:!0,data_source:{type:L.ol.AgentData,agent_id:o}},...a&&{channel:r?.channel||`dashboard_card_${e}`,tools:["spawn_sub_agent"]}};try{await x(l)}finally{N(!1)}},$=e=>{v(t=>({...t,config:{...t.config,...e}}))},E=!r,D=y.type===L.bU.Row||r?.type===L.bU.Row,B=!D&&c.length>0,T=!D&&!(E&&i&&s);return e?(0,l.jsx)("div",{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/50 p-4 transition-opacity ${e?"opacity-100":"pointer-events-none opacity-0"}`,children:(0,l.jsxs)("div",{className:"relative flex max-h-[90vh] w-full max-w-5xl flex-col rounded-lg bg-white shadow-xl dark:border dark:border-neutral-700 dark:bg-neutral-800",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 px-6 py-4 dark:border-neutral-700",children:[(0,l.jsx)("h3",{className:"text-xl font-semibold text-gray-900 dark:text-neutral-200",children:r?D?"Edit Section":"Edit Card":s?`Add ${ed[s]} Card`:"Add Card"}),(0,l.jsx)("button",{className:"rounded-full p-1 text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-neutral-700 dark:hover:text-neutral-300",onClick:t,children:(0,l.jsx)("svg",{className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,l.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),(0,l.jsxs)("div",{className:"space-y-6 overflow-y-auto px-6 py-4",children:[(0,l.jsxs)("div",{className:`grid gap-4 ${T?"grid-cols-2":"grid-cols-1"}`,children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Title"}),(0,l.jsx)("input",{type:"text",value:y.title||"",onChange:e=>v(t=>({...t,title:e.target.value})),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",placeholder:"Card title"})]}),T&&(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Type"}),(0,l.jsxs)("select",{value:y.type||L.bU.Metric,onChange:e=>{let t=e.target.value;(t===L.bU.HtmlEditor||t===L.bU.Row)&&j("nlp"),v(e=>({...e,type:t,row_id:t===L.bU.Row?null:e.row_id??null,config:ec(t,o,e.config)}))},className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dark:focus:ring-neutral-600",children:[(0,l.jsx)("option",{value:L.bU.Metric,children:"Metric"}),(0,l.jsx)("option",{value:L.bU.Chart,children:"Chart"}),(0,l.jsx)("option",{value:L.bU.Table,children:"Table"}),(0,l.jsx)("option",{value:L.bU.Heatmap,children:"Heatmap"}),(0,l.jsx)("option",{value:L.bU.Gauge,children:"Gauge"}),(0,l.jsx)("option",{value:L.bU.Distribution,children:"Distribution"}),(0,l.jsx)("option",{value:L.bU.PlainText,children:"Plain Text"}),(0,l.jsx)("option",{value:L.bU.HtmlEditor,children:"HTML Editor"})]})]})]}),B&&(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-neutral-300",children:"Panel"}),(0,l.jsxs)("select",{value:y.row_id??"",onChange:e=>{let t=e.target.value||null;v(e=>({...e,row_id:t}))},className:"block h-10 w-full rounded-lg border border-gray-300 bg-white px-3 text-sm text-gray-900 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-600 dar
12k:bg-neutral-800 dark:text-neutral-200",children:[(0,l.jsx)("option",{value:"",children:"No panel"}),c.map(e=>(0,l.jsx)("option",{value:e.id,children:e.title},e.id))]}),(0,l.jsx)("p",{className:"mt-1.5 text-xs text-gray-500 dark:text-neutral-400",children:"Move this card between dashboard panels without dragging it."})]}),y.type!==L.bU.HtmlEditor&&y.type!==L.bU.Row&&(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-neutral-300",children:"Content Mode"}),(0,l.jsxs)("div",{className:"inline-flex rounded-lg border border-gray-200 bg-gray-50 p-0.5 dark:border-neutral-700 dark:bg-neutral-900",children:[(0,l.jsx)("button",{type:"button",onClick:()=>j("nlp"),className:`rounded-md px-4 py-1.5 text-sm font-medium transition-all ${"nlp"===k?"bg-white text-gray-900 shadow-sm dark:bg-neutral-700 dark:text-neutral-100":"text-gray-500 hover:text-gray-700 dark:text-neutral-400 dark:hover:text-neutral-200"}`,children:"NLP"}),(0,l.jsx)("button",{type:"button",onClick:()=>{if(j("mirror"),!y.content_template){let e=_();e&&v(t=>({...t,content_template:e}))}},className:`rounded-md px-4 py-1.5 text-sm font-medium transition-all ${"mirror"===k?"bg-white text-gray-900 shadow-sm dark:bg-neutral-700 dark:text-neutral-100":"text-gray-500 hover:text-gray-700 dark:text-neutral-400 dark:hover:text-neutral-200"}`,children:"Live Template"})]}),(0,l.jsx)("p",{className:"mt-1.5 text-xs text-gray-500 dark:text-neutral-400",children:"nlp"===k?"Card data is processed via LLM. Use the prompt field below.":"Card content is resolved live from the grid. Use #column mentions to reference grid data."})]}),"nlp"===k&&y.type===L.bU.HtmlEditor&&(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-neutral-300",children:"Prompt"}),(0,l.jsx)("div",{className:"h-48 overflow-hidden rounded border border-gray-300 dark:border-neutral-700",children:(0,l.jsx)(eo.A,{value:y.prompt||"",onChange:e=>v(t=>({...t,prompt:e})),className:"h-full w-full resize-none dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",placeholder:"Describe what the HTML editor card should display. Use # to mention column data.",theme:h,nbrOfRows:g,columns:d.filter(e=>"question"===e.type).map(e=>({id:e.id,display:e.title})),style:{height:"100%",minHeight:"100%",maxHeight:"100%",overflow:"auto",backgroundColor:"dark"===h?"#000000":"#ffffff",color:"dark"===h?"#ffffff":"#000000"}},r?.id||"new-card")})]}),"nlp"===k&&y.type!==L.bU.HtmlEditor&&y.type!==L.bU.Row&&(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-neutral-300",children:"Prompt"}),(0,l.jsx)("div",{className:"h-48 overflow-hidden rounded border border-gray-300 dark:border-neutral-700",children:(0,l.jsx)(eo.A,{value:y.prompt||"",onChange:e=>v(t=>({...t,prompt:e})),className:"h-full w-full resize-none dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dark:focus:ring-neutral-600",placeholder:"Type # to mention an AI output of a column.",theme:h,nbrOfRows:g,columns:d.filter(e=>"question"===e.type).map(e=>({id:e.id,display:e.title})),style:{height:"100%",minHeight:"100%",maxHeight:"100%",overflow:"auto",backgroundColor:"dark"===h?"#000000":"#ffffff",color:"dark"===h?"#ffffff":"#000000"}},r?.id||"new-card")})]}),"mirror"===k&&(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Live Template"}),y.type===L.bU.PlainText?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("p",{className:"mb-2 mt-1 text-xs text-gray-500 dark:text-gray-400",children:["Type text with ",(0,l.jsx)("strong",{children:"#column"})," mentions to reference grid data. Values auto-resolve live. Markdown supported."]}),(0,l.jsx)("div",{className:"h-48 overflow-hidden rounded border border-gray-300 dark:border-neutral-700",children:(0,l.jsx)(eo.A,{value:y.content_template||"",onChange:e=>v(t=>({...t,content_template:e})),className:"h-full w-full resize-none dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",placeholder:"e.g. Hello #column:row — values resolve live from the grid.",theme:h,nbrOfRows:g,columns:d.filter(e=>"question"===e.type).map(e=>({id:e.id,display:e.title})),style:{height:"100%",minHeight:"100%",maxHeight:"100%",overflow:"auto",backgroundColor:"dark"===h?"#000000":"#ffffff",color:"dark"===h?"#ffffff":"#000000"}},`template-${r?.id||"new-card"}`)})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("p",{className:"mb-2 mt-1 text-xs text-gray-500 dark:text-gray-400",children:["Write the JSON data directly for this"," ",(0,l.jsx)("strong",{children:y.type})," card. No LLM call — the data below is used as-is."]}),(0,l.jsx)("textarea",{value:y.content_template||"",onChange:e=>v(t=>({...t,content_template:e.target.value})),className:"block h-48 w-full resize-none rounded-md border border-gray-300 px-3 py-2 font-mono text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",placeholder:(e=>{switch(e){case L.bU.Metric:return'{"value": 42, "label": "Revenue", "unit": "$", "trend": {"direction": "up", "value": 12.5}}';case L.bU.Chart:case L.bU.Distribution:return'[{"x": "Jan", "y": 120, "label": "January"}, {"x": "Feb", "y": 250, "label": "February"}]';case L.bU.Table:return'[{"name": "Alice", "status": "Active", "score": 95}, {"name": "Bob", "status": "Inactive", "score": 72}]';case L.bU.Gauge:return'{"value": 75, "min": 0, "max": 100, "label": "Performance", "unit": "%"}';case L.bU.Heatmap:return'[{"x": "Monday", "y": 85, "label": "Mon"}, {"x": "Tuesday", "y": 42, "label": "Tue"}]';default:return"{}"}})(y.type)})]})]}),(0,l.jsxs)("div",{className:"hidden grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Width"}),(0,l.jsx)("input",{type:"number",value:y.size?.width||300,onChange:e=>v(t=>({...t,size:{...t.size,width:parseInt(e.target.value)||300}})),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white",min:"200",max:"800"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Height"}),(0,l.jsx)("input",{type:"number",value:y.size?.height||200,onChange:e=>v(t=>({...t,size:{...t.size,height:parseInt(e.target.value)||200}})),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white",min:"150",max:"600"})]})]}),y.type===L.bU.Metric&&(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Metric Configuration"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Label"}),(0,l.jsx)("input",{type:"text",value:y.config?.metric?.label||"",onChange:e=>$({metric:{...y.config?.metric,label:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",placeholder:"Metric label"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Unit"}),(0,l.jsx)("input",{type:"text",value:y.config?.metric?.unit||"",onChange:e=>$({metric:{...y.config?.metric,unit:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dark:focus:ring-neutral-600",placeholder:"e.g., %, ms, $"})]})]})]}),y.type===L.bU.Gauge&&(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Gauge Configuration"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Label"}),(0,l.jsx)("input",{type:"text",value:y.config?.metric?.label||"",onChange:e=>$({metric:{...y.config?.metric,label:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",placeholder:"Gauge label"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Unit"}),(0,l.jsx)("input",{type:"text",value:y.config?.metric?.unit||"",onChange:e=>$({metric:{...y.config?.metric,unit:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dark:focus:ring-neutral-600",placeholder:"e.g., %, ms, $"})]})]})]}),y.type===L.bU.Table&&(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Table Configuration"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Max Rows"}),(0,l.jsx)("input",{type:"number",value:y.config?.table?.max_rows||10,onChange:e=>$({table:{...y.config?.table,columns:y.config?.table?.columns||[],max_rows:parseInt(e.target.value)||10}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",placeholder:"Number of rows to display",min:"1",max:"100"})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Sort By"}),(0,l.jsxs)("select",{value:y.config?.table?.sort_by||"",onChange:e=>$({table:{...y.config?.table,columns:y.config?.table?.columns||[],sort_by:e.target.value||null}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dark:focus:ring-neutral-600",children:[(0,l.jsx)("option",{value:"",children:"No sorting column"}),d.map(e=>(0,l.jsx)("option",{value:e.title,children:e.title},e.id))]})]})]}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Sort Order"}),(0,l.jsxs)("select",{value:y.config?.table?.sort_order||L.xB.Asc,onChange:e=>$({table:{...y.config?.table,columns:y.config?.table?.columns||[],sort_order:"none"===e.target.value?null:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",children:[(0,l.jsx)("option",{value:"none",children:"No sorting"}),(0,l.jsx)("option",{value:L.xB.Asc,children:"Ascending"}),(0,l.jsx)("option",{value:L.xB.Desc,children:"Descending"})]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Columns"}),(0,l.jsx)("input",{type:"text",value:(y.config?.table?.columns||[]).join(", "),onChange:e=>$({table:{...y.config?.table,columns:e.target.value.split(",").map(e=>e.trim()).filter(Boolean)}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dark:focus:ring-neutral-600",placeholder:"Column names (comma separated)"}),d.length>0&&(0,l.jsxs)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:["Available columns:"," ",d.map(e=>e.title).join(", ")]})]})]})]}),y.type===L.bU.Distribution&&(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Distribution Configuration"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Chart Type"}),(0,l.jsxs)("select",{value:y.config?.chart?.type||L.NB.Bar,onChange:e=>$({chart:{...y.config?.chart,type:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",children:[(0,l.jsx)("option",{value:L.NB.Bar,children:"Bar"}),(0,l.jsx)("option",{value:L.NB.Pie,children:"Pie"}),(0,l.jsx)("option",{value:L.NB.Line,children:"Line"})]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Aggregation"}),(0,l.jsxs)("select",{value:y.config?.chart?.aggregation||L.DF.Count,onChange:e=>$({chart:{...y.config?.chart,aggregation:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dark:focus:ring-neutral-600",children:[(0,l.jsx)("option",{value:L.DF.Count,children:"Count"}),(0,l.jsx)("option",{value:L.DF.Sum,children:"Sum"}),(0,l.jsx)("option",{value:L.DF.Avg,children:"Average"})]})]})]})]}),y.type===L.bU.Chart&&(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:"Chart Configuration"}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Chart Type"}),(0,l.jsxs)("select",{value:y.config?.chart?.type||L.NB.Line,onChange:e=>$({chart:{...y.config?.chart,type:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dar
12k:focus:ring-neutral-600",children:[(0,l.jsx)("option",{value:L.NB.Line,children:"Line"}),(0,l.jsx)("option",{value:L.NB.Bar,children:"Bar"}),(0,l.jsx)("option",{value:L.NB.Area,children:"Area"}),(0,l.jsx)("option",{value:L.NB.Pie,children:"Pie"}),(0,l.jsx)("option",{value:L.NB.Scatter,children:"Scatter"})]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Aggregation"}),(0,l.jsxs)("select",{value:y.config?.chart?.aggregation||L.DF.Count,onChange:e=>$({chart:{...y.config?.chart,aggregation:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dark:focus:ring-neutral-600",children:[(0,l.jsx)("option",{value:L.DF.Count,children:"Count"}),(0,l.jsx)("option",{value:L.DF.Sum,children:"Sum"}),(0,l.jsx)("option",{value:L.DF.Avg,children:"Average"}),(0,l.jsx)("option",{value:L.DF.Min,children:"Minimum"}),(0,l.jsx)("option",{value:L.DF.Max,children:"Maximum"})]})]})]}
12),y.config?.chart?.type===L.NB.Area&&(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-neutral-200",children:"Chart Label"}),(0,l.jsx)("input",{type:"text",value:y.config?.chart?.label||"",onChange:e=>$({chart:{...y.config?.chart,label:e.target.value}}),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-200 dark:shadow-lg dark:shadow-black/20 dark:focus:border-neutral-600 dark:focus:ring-neutral-600",placeholder:"e.g., Bitcoin (BTC), Ethereum (ETH), Stock Price"}),(0,l.jsx)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"This label will be displayed above the price in the chart"})]})]}),y.type!==L.bU.Row&&(0,l.jsxs)("div",{className:"ml-1 flex items-center",children:[(0,l.jsx)("input",{type:"checkbox",id:"showHeader",checked:y.config?.show_header!==!1,onChange:e=>$({show_header:e.target.checked}),className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),(0,l.jsx)("label",{htmlFor:"showHeader",className:"ml-2 text-sm text-gray-700 dark:text-gray-300",children:"Show header"})]}),y.type!==L.bU.Row&&(0,l.jsx)(em,{llmId:y.llm_id,reasoningEffort:y.reasoning_effort,onChange:(e,t)=>
12v(r=>({...r,llm_id:e,reasoning_effort:t})),onReasoningEffortChange:e=>v(t=>({...t,reasoning_effort:e}))})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t border-gray-200 px-6 py-4 dark:border-neutral-700",children:[(0,l.jsx)("button",{onClick:t,className:"flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 bg-white px-4 text-sm font-medium text-gray-700 shadow-sm transition-all hover:bg-gray-50 dark:border-neutral-600 dark:bg-neutral-800 dark:text-neutral-200 dark:hover:bg-neutral-700",children:"Cancel"}),(0,l.jsx)("button",{onClick:A,disabled:w,className:"flex h-9 items-center gap-1.5 rounded-lg bg-blue-500 px-4 text-sm font-medium text-white transition-all hover:bg-blue-600 disabled:cursor-not-allowed disabled:bg-blue-400",children:w?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("svg",{className:"h-4 w-4 animate-spin",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,l.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,l.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Saving..."]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(u.dIn,{className:"h-4 w-4"}),D?"Save Section":"Save Card"]})})]})]})}):null};var eh=r(89988);let eg=({cardCount:e,runningCards:t,runningCardTitles:r,isSaving:a,editMode:n,isFullscreen:s,onRunDashboard:i,onSaveDashboard:o,onAddCardType:d,onOpenGridData:c,onToggleEditMode:m,onToggleFullscreen:x})=>{let h=0===t.length&&!n;return(0,l.jsxs)("div",{className:"flex min-w-0 items-center justify-end gap-2",children:[t.length>0&&(0,l.jsxs)("div",{className:"flex h-9 items-center gap-1.5 rounded-lg bg-orange-50 px-3 text-xs font-medium text-orange-700 dark:bg-orange-900 dark:text-orange-300",title:`Processing: ${r}`,children:[(0,l.jsxs)("svg",{className:"h-3.5 w-3.5 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,l.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,l.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),(0,l.jsx)("span",{className:"hidden xs:inline",children:t.length})]}),e>0&&(0,l.jsx)(l.Fragment,{children:h&&(0,l.jsxs)("button",{onClick:i,className:"flex h-9 items-center gap-1.5 rounded-md bg-green-500 px-4 text-sm font-medium text-white transition-[background-color,transform] duration-150 ease-out hover:bg-green-600 active:scale-[0.96]",title:"Run entire dashboard",children:[(0,l.jsx)("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 24 24",children:(0,l.jsx)("path",{d:"M8 5v14l11-7z"})}),(0,l.jsx)("span",{className:"hidden sm:inline",children:"Run Dashboard"})]})}),e>0&&(0,l.jsx)("div",{className:"h-6 w-px bg-gray-300 dark:bg-neutral-600"}),(0,l.jsx)(ea,{triggerLabel:"Add",align:"right",variant:"secondary",onAddCardType:d,onOpenGridData:c}),(0,l.jsx)("div",{className:"h-6 w-px bg-gray-300 dark:bg-neutral-600"}),(0,l.jsxs)("button",{onClick:n?o:m,disabled:a,className:`flex h-9 items-center gap-1.5 rounded-lg border px-4 text-sm font-medium shadow-sm transition-[background-color,border-color,box-shadow,transform] duration-150 ease-out active:scale-[0.96] ${n?"border-blue-500 bg-blue-500 text-white hover:bg-blue-600 disabled:cursor-not-allowed disabled:border-blue-400 disabled:bg-blue-400 disabled:active:scale-100 dark:border-blue-500 dark:bg-blue-500 dark:text-white dark:hover:bg-blue-600":"border-gray-300 bg-white text-gray-600 hover:bg-gray-50 dark:border-neutral-600 dar
12k:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700"}`,title:n?"Save and exit edit mode":"Edit mode",children:[a?(0,l.jsx)(eh.A,{isLoading:a}):n?(0,l.jsx)(u.CMH,{className:"h-4 w-4"}):(0,l.jsx)(u.uO9,{className:"h-4 w-4"}),(0,l.jsx)("span",{children:n?"Done":"Edit"})]}),(0,l.jsx)("button",{onClick:x,className:"flex h-9 w-9 items-center justify-center rounded-lg border border-gray-300 bg-white text-gray-600 shadow-sm transition-[background-color,border-color,box-shadow,transform] duration-150 ease-out hover:bg-gray-50 active:scale-[0.96] dark:border-neutral-600 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700",title:s?"Exit fullscreen":"Fullscreen",children:s?(0,l.jsx)(u.Wsx,{className:"h-4 w-4"}):(0,l.jsx)(u._AH,{className:"h-4 w-4"})})]})},ep=e=>`flex h-8 min-w-0 items-center gap-1.5 rounded-lg px-2.5 text-xs font-medium transition-[background-color,color,box-shadow] duration-150 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-neutral-900 ${e?"bg-blue-50 text-blue-700 shadow-sm dark:bg-blue-900/30 dark:text-blue-300":"text-gray-600 hover:bg-gray-50 hover:text-gray-900 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-100"}`,eb=n.memo(({sections:e,activeSectionId:t,contentCardCount:r,editMode:a,onSelectSection:s,onAddSection:i,onRenameSection:o,onDeleteSection:d,onReorderSection:c})=>{let[m,x]=(0,n.useState)(null),[h,g]=(0,n.useState)(""),p=(0,n.useRef)(null);(0,n.useEffect)(()=>{m&&(p.current?.focus(),p.current?.select())},[m]);let b=()=>{if(!m)return;let e=h.trim();e&&o(m,e),x(null),g("")};return(0,l.jsx)("div",{className:"sticky top-0 z-20 mb-3 bg-gray-50/95 pb-2 backdrop-blur dark:bg-gray-900/95",children:(0,l.jsxs)("div",{className:"inline-flex max-w-full items-center gap-1 rounded-xl border border-gray-200 bg-white p-0.5 shadow-sm dark:border-neutral-700 dark:bg-neutral-900",children:[(0,l.jsxs)("button",{type:"button",onClick:()=>s("all"),"data-dashboard-section-drop-id":"all",className:ep("all"===t),title:"Show all dashboard cards",children:[(0,l.jsx)(Y.s_k,{className:"h-3.5 w-3.5 flex-shrink-0"}),(0,l.jsx)("span",{children:"All"}),(0,l.jsx)("span",{className:"rounded-lg bg-gray-100 px-1.5 py-0.5 text-[11px] text-gray-500 dark:bg-neutral-700 dark:text-neutral-300",children:r})]}),(0,l.jsx)("div",{className:"h-4 w-px flex-shrink-0 bg-gray-200 dark:bg-neutral-700"}),(0,l.jsxs)("div",{className:"flex min-w-0 items-center gap-1 overflow-x-auto",children:[e.map(e=>{let r=t===e.id,n=m===e.id;return(0,l.jsxs)("div",{draggable:a&&!n,onDragStart:t=>{var r;return r=e.id,void(a&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",r)))},onDragOver:e=>{a&&e.preventDefault()},onDrop:t=>((e,t)=>{if(!a)return;e.preventDefault();let r=e.dataTransfer.getData("text/plain");r&&r!==t&&c(r,t)})(t,e.id),className:`flex min-w-0 flex-shrink-0 items-center rounded-lg ${a&&!r?"cursor-grab active:cursor-grabbing":""}`,children:[n?(0,l.jsxs)("div",{className:ep(r),title:e.title,children:[(0,l.jsx)("input",{ref:p,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),b()),"Escape"===e.key&&(e.preventDefault(),x(null),g(""))},onBlur:b,className:"h-6 w-36 rounded-lg border border-blue-300 bg-white px-2 text-xs font-medium text-gray-900 shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-blue-700 dark:bg-neutral-900 dark:text-neutral-100"}),(0,l.jsx)("span",{className:"rounded-lg bg-gray-100 px-1.5 py-0.5 text-[11px] text-gray-500 dark:bg-neutral-700 dark:text-neutral-300",children:e.cardCount})]}):(0,l.jsxs)("button",{type:"button",onClick:()=>s(e.id),"data-dashboard-section-drop-id":e.id,className:ep(r),title:e.title,children:[(0,l.jsx)("span",{className:"max-w-48 truncate",onClick:t=>{a&&(t.stopPropagation(),x(e.id),g(e.title),s(e.id))},children:e.title}),(0,l.jsx)("span",{className:"rounded-lg bg-gray-100 px-1.5 py-0.5 text-[11px] text-gray-500 dark:bg-neutral-700 dark:text-neutral-300",children:e.cardCount})]}),a&&r&&(0,l.jsx)("div",{className:"mr-1 flex items-center",children:(0,l.jsx)("button",{type:"button",onClick:()=>d(e.id),className:"flex h-8 w-8 items-center justify-center rounded-lg text-gray-400 transition-colors duration-150 ease-out hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/30 dark:hover:text-red-300",title:"Delete section",children:(0,l.jsx)(Y.yGN,{className:"h-3.5 w-3.5"})})})]},e.id)}),(0,l.jsx)("button",{type:"button",onClick:i,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-gray-500 transition-[color,transform] duration-150 ease-out hover:text-blue-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-white active:scale-[0.96] dark:text-neutral-400 dark:hover:text-blue-300 dark:focus-visible:ring-offset-neutral-900",title:"Add section",children:(0,l.jsx)(u.OiG,{className:"h-3.5 w-3.5"})})]})]})})}),ef=(e,t,r)=>({show_header:t,metric:null,chart:null,table:null,data_source:{type:L.ol.AgentData,agent_id:e,columns:r&&r.length>0?r:null}}),ey=(e,t)=>`#[${e.title.replace(/\]/g,")").replace(/\n/g," ")}](id:${e.id}:row:${t})`,ev=(e,t)=>
12`card-${Date.now()}-${e}-${t}`,ek=(e,t)=>t.map(t=>`**${t.title}**
13
14${ey(t,e)}`).join("\n\n"),ej=({id:e,title:t,agentId:r,contentTemplate:a,position:l,size:n,rowId:s,columns:i})=>({id:e,title:t,type:L.bU.PlainText,position:l,size:n,structured:!1,prompt:"",content_template:a,content_mode:"mirror",row_id:s??null,config:ef(r,!0,i)}),ew=({isOpen:e,mode:t,agentId:r,columns:a,rowKeys:s,nbrOfRows:i,onClose:o,onAddCards:d})=>{let c=(0,n.useMemo)(()=>a.filter(e=>"question"===e.type),[a]),m=(0,n.useMemo)(()=>s.length>0?s:Array.from({length:i},(e,t)=>t),[i,s]),[x,h]=(0,n.useState)(()=>new Set),[g,p]=(0,n.useState)(()=>new Set),[b,f]=(0,n.useState)(""),[y,v]=(0,n.useState)(""),[k,j]=(0,n.useState)("cells"),[w,N]=(0,n.useState)("metrics"),[_,C]=(0,n.useState)(!1),S=JSON.stringify([m,e,t,c.map(e=>e.id)]),[M,A]=(0,n.useState)("");if(e&&M!==S){A(S);let e=c.slice(0,"visualization"===t?1:3).map(e=>e.id),r=m.slice(0,1);h(new Set(e)),p(new Set(r)),f(""),v(""),j("grid-data"===t?"cells":"rows"),N("metrics")}let $=(0,n.useMemo)(()=>({columns:c.filter(e=>x.has(e.id)),rowKeys:m.filter(e=>g.has(e))}),[m,c,x,g]),E=(0,n.useMemo)(()=>{let e=b.trim().toLowerCase();return e?c.filter(t=>t.title.toLowerCase().includes(e)):c},[b,c]),D=(0,n.useMemo)(()=>{let e=y.trim();return e?m.filter(t=>String(t).includes(e)):m},[m,y]),B=(0,n.useCallback)(e=>{h(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),T=(0,n.useCallback)(e=>{p(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),R=(0,n.useCallback)(()=>{h(new Set(E.map(e=>e.id)))},[E]),U=(0,n.useCallback)(()=>{p(new Set(D))},[D]),z=(0,n.useCallback)(()=>{h(new Set)},[]),F=(0,n.useCallback)(()=>{p(new Set)},[]),H=(0,n.useCallback)(()=>{if(0===$.columns.length||0===$.rowKeys.length)return[];if("rows"===t){let e=[],t=0;return $.rowKeys.forEach((a,l)=>{let n,s=ev("bulk-row",l),i=Math.max(200,72*$.columns.length);e.push((n=t,{id:s,title:`Grid Row ${a}`,type:L.bU.Row,position:{x:0,y:n},size:{width:2400,height:40},config:ef(r,!1),collapsed:!1})),e.push(ej({id:ev("bulk-row-summary",l),title:`Row ${a} data`,agentId:r,contentTemplate:ek(a,$.columns),position:{x:0,y:t+40},size:{width:700,height:i},rowId:s,columns:$.columns.map(e=>e.id)})),t+=i+40+40}),e}if("visualization"===t){if("table"===w){var e,a;return[(({id:e,title:t,agentId:r,contentTemplate:a,position:l,rowsCount:n,columns:s})=>({id:e,title:t,type:L.bU.Table,position:l,size:{width:900,height:320},structured:!0,prompt:"",content_template:a,content_mode:"mirror",row_id:null,config:{...ef(r,!0,s.map(e=>e.id)),table:{columns:["Row",...s.map(e=>e.title)],max_rows:n,sort_by:null,sort_order:null,filters:null}}}))({id:ev("bulk-visual-table",0),title:"Grid data table",agentId:r,contentTemplate:(e=$.rowKeys,a=$.columns,JSON.stringify(e.map(e=>{let t={id:`row-${e}`,Row:String(e)};return a.forEach(r=>{t[r.title]=ey(r,e)}),t}),null,2)),position:{x:0,y:0},rowsCount:$.rowKeys.length,columns:$.columns})]}let t=0;return $.rowKeys.flatMap((e,a)=>$.columns.map((l,n)=>{let s=(({id:e,title:t,agentId:r,contentTemplate:a,position:l,column:n})=>({id:e,title:t,type:L.bU.Metric,position:l,size:{width:300,height:180},structured:!0,prompt:"",content_template:a,content_mode:"mirror",row_id:null,config:{...ef(r,!0,[n.id]),metric:{value:null,label:n.title,unit:null,trend:null,threshold:null}}}))({id:ev("bulk-metric",t),title:`${l.title} - Row ${e}`,agentId:r,contentTemplate:JSON.stringify({value:ey(l,e),label:l.title},null,2),position:{x:320*n,y:220*a},column:l});return t+=1,s}))}if("columns"===k)return $.columns.map((e,t)=>{let a;return ej({id:ev("bulk-grid-column",t),title:`${e.title} data`,agentId:r,contentTemplate:(a=$.rowKeys,a.map(t=>`**Row ${t}**
15
16${ey(e,t)}`).join("\n\n")),position:{x:0,y:240*t},size:{width:700,height:Math.max(200,72*$.rowKeys.length)},columns:[e.id]})});if("rows"===k)return $.rowKeys.map((e,t)=>ej({id:ev("bulk-grid-row",t),title:`Grid row ${e}`,agentId:r,contentTemplate:ek(e,$.columns),position:{x:0,y:240*t},size:{width:700,height:Math.max(200,72*$.columns.length)},columns:$.columns.map(e=>e.id)}));let l=0;return $.rowKeys.flatMap((e,t)=>$.columns.map((a,n)=>
16{let s=ej({id:ev("bulk-grid-cell",l),title:`${a.title} - Row ${e}`,agentId:r,contentTemplate:`**${a.title}**
17
18${ey(a,e)}
19
20_Row ${e}_`,position:{x:400*n,y:200*t},size:{width:400,height:160},columns:[a.id]});return l+=1,s}))},[r,k,t,$.columns,$.rowKeys,w]),O=(0,n.useMemo)(()=>H(),[H]),P=O.length>0&&!_,I=(0,n.useMemo)(()=>{if("grid-data"!==t)return null;if("cells"===k)return"Cells: one card per selected cell. Each card contains one live reference to one grid cell.";if("rows"===k){let e=$.columns.length;return`Rows: one card per selected row. Each card contains ${e} live column reference${1===e?"":"s"} for that row.`}let e=$.rowKeys.length;return`Columns: one card per selected column. Each card contains ${e} live row reference${1===e?"":"s"} for that column.`},[k,t,$.columns.length,$.rowKeys.length]),K="visualization"===t?"Add Visualization Cards":"rows"===t?"Add Row Cards":"Add Grid Data Cards",W="visualization"===t?"Create live metric or table cards from selected grid cells.":"rows"===t?"Create dashboard row sections with live summaries from selected grid rows.":"Create live-bound cards from selected rows, cells, or columns.",G=async()=>{if(P){C(!0);try{await d(O)}finally{C(!1)}}};return e?(0,l.jsx)("div",{className:"fixed inset-0 z-[10050] flex items-center justify-center bg-black/50 p-4",children:(0,l.jsxs)("div",{className:"flex max-h-[90vh] w-full max-w-5xl flex-col rounded-lg bg-white shadow-xl dark:border dark:border-neutral-700 dark:bg-neutral-800",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between border-b border-gray-200 px-6 py-4 dark:border-neutral-700",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"text-xl font-semibold text-gray-900 dark:text-neutral-100",children:K}),(0,l.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-neutral-400",children:W})]}),(0,l.jsx)("button",{type:"button",onClick:o,className:"flex h-10 w-10 items-center justify-center rounded-lg text-gray-400 transition-colors duration-150 ease-out hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-neutral-700 dark:hover:text-neutral-200",title:"Close",children:(0,l.jsx)(u.QCr,{className:"h-4 w-4"})})]}),(0,l.jsxs)("div",{className:"grid min-h-0 flex-1 grid-cols-1 gap-6 overflow-y-auto px-6 py-4 lg:grid-cols-[1fr_1fr]",children:[(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-neutral-100",children:"Columns"}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("button",{type:"button",onClick:R,className:"text-xs font-medium text-blue-600 transition-colors hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Select all"}),(0,l.jsx)("button",{type:"button",onClick:z,className:"text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-neutral-400 dark:hover:text-neutral-200",children:"Clear"})]})]}),(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsx)(Y.CKj,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-neutral-500"}),(0,l.jsx)("input",{value:b,onChange:e=>f(e.target.value),className:"h-10 w-full rounded-lg border border-gray-300 bg-white pl-10 pr-3 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-600 dar
20k:bg-neutral-900 dark:text-neutral-100 dark:placeholder:text-neutral-500",placeholder:"Search columns"})]}),(0,l.jsx)("div",{className:"max-h-72 overflow-y-auto rounded-lg border border-gray-200 bg-white p-1 dark:border-neutral-700 dark:bg-neutral-900",children:E.length>0?E.map(e=>(0,l.jsxs)("label",{className:"flex cursor-pointer items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors hover:bg-gray-50 dark:hover:bg-neutral-800",children:[(0,l.jsx)("input",{type:"checkbox",checked:x.has(e.id),onChange:()=>B(e.id),className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),(0,l.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,l.jsx)("div",{className:"truncate font-medium text-gray-800 dark:text-neutral-100",children:e.title}),(0,l.jsx)("div",{className:"truncate text-xs text-gray-500 dark:text-neutral-400",children:e.format||"text"})]})]},e.id)):(0,l.jsx)("div",{className:"p-4 text-center text-sm text-gray-500 dark:text-neutral-400",children:"No columns found"})})]}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-neutral-100",children:"Rows"}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("button",{type:"button",onClick:U,className:"text-xs font-medium text-blue-600 transition-colors hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300",children:"Select all"}),(0,l.jsx)("button",{type:"button",onClick:F,className:"text-xs font-medium text-gray-500 transition-colors hover:text-gray-700 dark:text-neutral-400 dark:hover:text-neutral-200",children:"Clear"})]})]}),(0,l.jsxs)("div",{className:"relative",children:[(0,l.jsx)(Y.CKj,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-neutral-500"}),(0,l.jsx)("input",{value:y,onChange:e=>v(e.target.value),className:"h-10 w-full rounded-lg border border-gray-300 bg-white pl-10 pr-3 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 dark:border-neutral-600 dar
20k:bg-neutral-900 dark:text-neutral-100 dark:placeholder:text-neutral-500",placeholder:"Search rows"})]}),(0,l.jsx)("div",{className:"max-h-72 overflow-y-auto rounded-lg border border-gray-200 bg-white p-1 dark:border-neutral-700 dark:bg-neutral-900",children:D.length>0?D.map(e=>(0,l.jsxs)("label",{className:"flex cursor-pointer items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors hover:bg-gray-50 dark:hover:bg-neutral-800",children:[(0,l.jsx)("input",{type:"checkbox",checked:g.has(e),onChange:()=>T(e),className:"h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),(0,l.jsxs)("span",{className:"font-medium text-gray-800 dark:text-neutral-100",children:["Row ",e]})]},e)):(0,l.jsx)("div",{className:"p-4 text-center text-sm text-gray-500 dark:text-neutral-400",children:"No rows found"})})]}),(0,l.jsxs)("div",{className:"space-y-3 lg:col-span-2",children:["grid-data"===t&&(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-neutral-300",children:"Card layout"}),(0,l.jsx)("div",{className:"inline-flex rounded-lg border border-gray-200 bg-gray-50 p-0.5 dark:border-neutral-700 dark:bg-neutral-900",children:[["cells","Cells"],["rows","Rows"],["columns","Columns"]].map(([e,t])=>(0,l.jsx)("button",{type:"button",onClick:()=>j(e),className:`rounded-md px-4 py-1.5 text-sm font-medium transition-colors duration-150 ease-out ${k===e?"bg-white text-gray-900 shadow-sm dark:bg-neutral-700 dark:text-neutral-100":"text-gray-500 hover:text-gray-700 dark:text-neutral-400 dark:hover:text-neutral-200"}`,children:t},e))}),I&&(0,l.jsx)("p",{className:"mt-2 text-sm text-gray-600 dark:text-neutral-400",children:I})]}),"visualization"===t&&(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-gray-700 dark:text-neutral-300",children:"Visualization type"}),(0,l.jsx)("div",{className:"inline-flex rounded-lg border border-gray-200 bg-gray-50 p-0.5 dark:border-neutral-700 dark:bg-neutral-900",children:[["metrics","Metric cards"],["table","Table card"]].map(([e,t])=>(0,l.jsx)("button",{type:"button",onClick:()=>N(e),className:`rounded-md px-4 py-1.5 text-sm font-medium transition-colors duration-150 ease-out ${w===e?"bg-white text-gray-900 shadow-sm dark:bg-neutral-700 dark:text-neutral-100":"text-gray-500 hover:text-gray-700 dark:text-neutral-400 dark:hover:text-neutral-200"}`,children:t},e))})]}),(0,l.jsxs)("div",{className:"rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-neutral-700 dark:bg-neutral-900",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-neutral-100",children:["visualization"===t?(0,l.jsx)(u.ist,{className:"h-4 w-4 text-blue-500"}):(0,l.jsx)(Y.QPV,{className:"h-4 w-4 text-blue-500"}),"Preview"]}),(0,l.jsxs)("p",{className:"mt-1 text-sm text-gray-600 dark:text-neutral-400",children:[$.columns.length," column",1===$.columns.length?"":"s"," and"," ",$.rowKeys.length," row",1===$.rowKeys.length?"":"s"," selected."," ",1===O.length?"This will create 1 card":`This will create ${O.length} cards`," ","with live grid references."]}),O.length>0&&(0,l.jsxs)("div",{className:"mt-3 max-h-32 overflow-y-auto text-xs text-gray-500 dark:text-neutral-400",children:[O.slice(0,8).map(e=>(0,l.jsx)("div",{className:"truncate py-0.5",children:e.title},e.id)),O.length>8&&(0,l.jsxs)("div",{className:"py-0.5",children:["+",O.length-8," more"]})]})]})]})]}),(0,l.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t border-gray-200 px-6 py-4 dark:border-neutral-700",children:[(0,l.jsx)("button",{type:"button",onClick:o,className:"flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 bg-white px-4 text-sm font-medium text-gray-700 shadow-sm transition-[background-color,border-color,box-shadow,transform] duration-150 ease-out hover:bg-gray-50 active:scale-[0.96] dark:border-neutral-600 dar
20k:bg-neutral-800 dark:text-neutral-200 dark:hover:bg-neutral-700",children:"Cancel"}),(0,l.jsxs)("button",{type:"button",onClick:G,disabled:!P,className:"flex h-9 items-center gap-1.5 rounded-lg bg-blue-500 px-4 text-sm font-medium text-white transition-[background-color,transform] duration-150 ease-out hover:bg-blue-600 active:scale-[0.96] disabled:cursor-not-allowed disabled:bg-blue-400 disabled:active:scale-100",children:[(0,l.jsx)(u.OiG,{className:"h-4 w-4"}),_?"Adding...":`Add ${O.length} cards`]})]})]})}):null};var eN=((a={}).Analytics="analytics",a.Monitoring="monitoring",a.Reporting="reporting",a);let e_=[{id:"analytics-overview",name:"Analytics Overview",description:"Complete analytics dashboard with key metrics, charts, and performance indicators",category:eN.Analytics,preview:"/dashboard-templates/analytics-overview.png",cards:[{id:"task-completion-rate",title:"Task Completion Rate",type:L.bU.Metric,config:{show_header:!0,metric:{label:"Completion Rate",unit:"%",threshold:{warning:70,critical:50}},data_source:{type:L.ol.AgentData,columns:["completed_tasks","total_tasks"]}},position:{x:0,y:0},size:{width:280,height:200}},{id:"performance-trend",title:"Performance Trend",type:L.bU.Chart,config:{show_header:!0,chart:{type:L.NB.Line,x_axis:"date",y_axis:"performance_score",aggregation:L.DF.Avg},data_source:{type:L.ol.AgentData,columns:["date","performance_score"]}},position:{x:300,y:0},size:{width:400,height:300}}]},{id:"monitoring-dashboard",name:"Monitoring Dashboard",description:"Real-time monitoring with gauges, progress bars, and system health indicators",category:eN.Monitoring,preview:"/dashboard-templates/monitoring.png",cards:[{id:"system-health",title:"System Health",type:L.bU.Gauge,config:{show_header:!0,data_source:{type:L.ol.AgentData,columns:["health_score"]}},position:{x:0,y:0},size:{width:300,height:250}},{id:"activity-heatmap",title:"Activity Heatmap",type:L.bU.Heatmap,config:{show_header:!0,data_source:{type:L.ol.AgentData,columns:["activity_level","time_period"]}},position:{x:640,y:0},size:{width:350,height:250}}]},{id:"reporting-suite",name:"Reporting Suite",description:"Comprehensive reporting with tables, distributions, and detailed analytics",category:eN.Reporting,preview:"/dashboard-templates/reporting.png",cards:[{id:"task-distribution",title:"Task Distribution",type:L.bU.Distribution,config:{show_header:!0,data_source:{type:L.ol.AgentData,columns:["task_type","count"]}},position:{x:0,y:0},size:{width:300,height:300}},{id:"detailed-results",title:"Detailed Results",type:L.bU.Table,config:{show_header:!0,table:{columns:["task_id","name","status","completion_time"],max_rows:10,sort_by:"completion_time",sort_order:L.xB.Desc},data_source:{type:L.ol.TaskData,columns:["task_id","name","status","completion_time"]}},position:{x:320,y:0},size:{width:500,height:300}},{id:"error-rate",title:"Error Rate",type:L.bU.Metric,config:{show_header:!0,metric:{label:"Error Rate",unit:"%",threshold:{warning:5,critical:10}},data_source:{type:L.ol.AgentData,columns:["error_count","total_count"]}},position:{x:840,y:0},size:{width:280,height:200}}]}],eC=({isOpen:e,onClose:t,onApplyTemplate:r})=>e?(0,l.jsx)("div",{className:`fixed inset-0 z-[1000] flex h-full items-center justify-center bg-black bg-opacity-25 transition-opacity duration-300 ${e?"opacity-100":"pointer-events-none opacity-0"}`,children:(0,l.jsxs)("div",{className:"border-1 relative m-2 flex w-full max-w-4xl flex-col overflow-hidden rounded-lg bg-slate-100 p-6 shadow-lg dark:border-neutral-700 dark:bg-neutral-800 dark:shadow-lg dark:shadow-black/20 dark:ring-1 dark:ring-neutral-600",children:[(0,l.jsx)("button",{className:"absolute right-4 top-4 text-gray-500 hover:text-gray-900 dark:hover:text-gray-200",onClick:t,children:"X"}),(0,l.jsx)("div",{className:"mb-2 text-xl",children:"Dashboard Templates"}),(0,l.jsx)("div",{className:"text-md mb-6 dark:text-neutral-400",children:"Select a template to add its cards to your dashboard"}),(0,l.jsx)("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3",children:e_.map(e=>(0,l.jsxs)("div",{className:"group cursor-pointer rounded-lg border border-slate-300 bg-slate-50 p-4 transition-all hover:border-blue-300 hover:shadow-md dark:border-neutral-700 dark:bg-neutral-800 dark:hover:border-blue-600",onClick:()=>r(e),children:[(0,l.jsxs)("div",{className:"mb-3 flex items-center space-x-3",children:[(e=>{switch(e){case"analytics":return(0,l.jsx)(i.gLv,{className:"text-2xl text-blue-600"});case"monitoring":return(0,l.jsx)(i.YSH,{className:"text-2xl text-green-600"});case"reporting":return(0,l.jsx)(i.Uhn,{className:"text-2xl text-purple-600"});default:return(0,l.jsx)(i.Uhn,{className:"text-2xl text-gray-600"})}})(e.category),(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:"font-semibold text-gray-900 dark:text-white",children:e.name}),(0,l.jsx)("span",{className:"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:e.category})]})]}),(0,l.jsx)("div",{className:"mb-3 h-24 rounded-md bg-gray-100 dark:bg-neutral-700",children:(0,l.jsx)("div",{className:"flex h-full items-center justify-center text-gray-400",children:(0,l.jsx)(i.Uhn,{className:"text-3xl"})})}),(0,l.jsx)("p",{className:"mb-3 text-sm text-gray-600 dark:text-neutral-400",children:e.description}),(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[e.cards.length," cards"]}),(0,l.jsx)("div",{className:"rounded-full bg-blue-100 p-1 opacity-0 transition-opacity group-hover:opacity-100 dark:bg-blue-900",children:(0,l.jsx)(u.CMH,{className:"h-3 w-3 text-blue-600 dar
20k:text-blue-400"})})]})]},e.id))}),(0,l.jsx)("div",{className:"mt-6 border-t border-slate-300 pt-4 dark:border-neutral-700",children:(0,l.jsx)("p",{className:"text-sm text-gray-500 dark:text-neutral-400",children:"Select a template to add its cards to your dashboard. You can customize each card after adding it."})})]})}):null;var eS=r(26603),eM=r(4786),eA=r(90566);let e$=({agentId:e,dashboardData:t,dashboard:r,className:a="",agentExtraction:o,refetch:c,columns:u,theme:m,onRun:x,rowKeys:h=[],toolbarPortalElement:g=null})=>{let p=(0,eA.eo)(e),{handleUpdateAgentExtractor:b}=(0,eM.A)({refetch:c}),f=(0,n.useCallback)(e=>{if(!e.some(e=>e.type!==L.bU.Row&&void 0===e.row_id))return e;let t=e.filter(e=>e.type===L.bU.Row).sort((e,t)=>Math.round(e.position.y/40)-Math.round(t.position.y/40));return e.map(e=>{if(e.type===L.bU.Row||void 0!==e.row_id)return e;let r=Math.round(e.position.y/40),a=null;for(let e=t.length-1;e>=0;e--)if(r>Math.round(t[e].position.y/40)){a=t[e].id;break}return{...e,row_id:a}})},[]),[y,v]=(0,n.useState)(()=>
20{let t=o?.template?.dashboard||r||{id:`dashboard-${e}`,name:"Agent Dashboard",description:"Analytics dashboard for the agent grid",agent_id:e,cards:[],layout:{grid_size:{cols:12,rows:8},card_spacing:16,auto_size:!1},settings:{auto_refresh:!0,refresh_interval:30,theme:L.Q7.Auto,show_grid:!0,allow_edit:!0},created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return{...t,cards:f(t.cards)}}),[k,j]=(0,n.useState)(!1),[w,N]=(0,n.useState)(null),[_,C]=(0,n.useState)(!1),[S,M]=(0,n.useState)(null),[A,$]=(0,n.useState)("all"),[E,D]=(0,n.useState)(null),[B,T]=(0,n.useState)(!1),[R,U]=(0,n.useState)(!1),[z,F]=(0,n.useState)(!1),[H,P]=(0,n.useState)(!1),[I,K]=(0,n.useState)(!1),[W,G]=(0,n.useState)(!1),[V,q]=(0,n.useState)(null),[J,Q]=(0,n.useState)({}),Y=(0,n.useRef)(null),[X,Z]=(0,n.useState)(1200),[ee,er]=(0,n.useState)(!1),el=o?.template?.dashboard,[en,es]=(0,n.useState)({backendDashboard:el,isCardEditorOpen:_});if((en.backendDashboard!==el||en.isCardEditorOpen!==_)&&(es({backendDashboard:el,isCardEditorOpen:_}),el&&!_))if(ee)er(!1);else{let e=f(el.cards);v({...el,cards:e}),K(!1)}let ei=(0,n.useCallback)(e=>({i:e.id,x:Math.max(0,Math.round(e.position.x/100)),y:Math.max(0,Math.round(e.position.y/40)),w:Math.max(2,Math.round(e.size.width/100)||4),h:Math.max(4,Math.round(e.size.height/40)||6)}),[]),eo=(0,n.useCallback)(e=>({position:{x:100*e.x,y:40*e.y},size:{width:100*e.w,height:40*e.h}}),[]),ed=(0,n.useMemo)(()=>y.cards.filter(e=>e.type!==L.bU.Row),[y.cards]),ec=(0,n.useMemo)(()=>y.cards.filter(e=>e.type===L.bU.Row).sort((e,t)=>ei(e).y-ei(t).y).map(e=>({row:e,cards:ed.filter(t=>t.row_id===e.id)})),[y.cards,ed,ei]),eu=(0,n.useMemo)(()=>new Set(ec.map(e=>e.row.id)),[ec]),em=(0,n.useMemo)(()=>ed.filter(e=>!e.row_id||!eu.has(e.row_id)),[ed,eu]),eh=ed.length;"all"===A||eu.has(A)||$("all");let ep=(0,n.useMemo)(()=>ec.map(e=>({id:e.row.id,title:e.row.title||"Untitled Section",cardCount:e.cards.length})),[ec]),ef=(0,n.useMemo)(()=>ep.map(e=>({id:e.id,title:e.title})),[ep]),ey=(0,n.useMemo)(()=>new Map(ep.map(e=>[e.id,e.title])),[ep]),ev=ec.find(e=>e.row.id===A)?.row.title||"this section",ek=(0,n.useMemo)(()=>"all"===A?[...em,...ec.flatMap(e=>e.cards)]:ec.find(e=>e.row.id===A)?.cards??[],[A,ec,em]),ej=(0,n.useMemo)(()=>{let e=[],t=0,r=r=>{if(0===r.length)return;let a=r.map(e=>ei(e)).sort((e,t)=>e.y-t.y||e.x-t.x),l=a[0].y,n=t;for(let r of a){let a=t+(r.y-l);e.push({...r,y:a}),n=Math.max(n,a+r.h)}t=n};if("all"===A){for(let e of(r(em),ec))r(e.cards);return e}return r(ek),e},[A,ec,em,ek,ei]);(0,n.useEffect)(()=>{if(!Y.current)return;let e=()=>{let e=Y.current?.parentElement;e&&Z(Math.max(1200,e.clientWidth-32))};e();let t=new ResizeObserver(e),r=Y.current.parentElement;return r&&t.observe(r),()=>t.disconnect()},[]);let eN=(0,n.useCallback)(e=>{N(null),D(e),C(!0),T(!1)},[]),e_=(0,n.useCallback)(e=>{$(e)},[]),e$=(0,n.useCallback)(()=>{let t=`card-${Date.now()}`,r=y.cards.reduce((e,t)=>Math.max(e,t.position.y+t.size.height),0),a=0===y.cards.length?0:40*Math.ceil(r/40)+40,l={id:t,title:"New Section",type:L.bU.Row,position:{x:0,y:a},size:{width:2400,height:40},config:{show_header:!1,metric:null,chart:null,table:null,data_source:{type:L.ol.AgentData,agent_id:e}}};v({...y,cards:[...y.cards,l],updated_at:new Date().toISOString()}),$(t),j(!0),K(!0)},[e,y]),eE=(0,n.useCallback)(e=>{M(e)},[]),eD=(0,n.useCallback)(e=>{N(e),D(null),C(!0),T(!1)},[]),eL=(0,n.useCallback)(e=>{k?T(!1):(j(!0),T(!0)),D(null),N(e),C(!0)},[k]),eB=(0,n.useCallback)(e=>{q(e),G(!0)},[]),eT=(0,n.useCallback)((e,t)=>{let r=y.cards.find(t=>t.id===e);r&&r.title!==t&&(v(r=>{let a=r.cards.map(r=>r.id===e?{...r,title:t}:r);return{...r,cards:a,updated_at:new Date().toISOString()}}),K(!0))},[y.cards]),eR=(0,n.useCallback)(e=>{eB(e)},[eB]),eU=(0,n.useCallback)((e,t)=>{v(r=>{let a=r.cards.filter(e=>e.type===L.bU.Row).sort((e,t)=>ei(e).y-ei(t).y),l=a.findIndex(t=>t.id===e),n=a.findIndex(e=>e.id===t);if(l<0||n<0||l===n)return r;let s=a.map(e=>e.position.y),i=[...a],[o]=i.splice(l,1);i.splice(n,0,o);let d=!1,c=r.cards.map(e=>{let t=i.findIndex(t=>t.id===e.id);if(t<0)return e;let r=s[t];return e.position.y===r?e:(d=!0,{...e,position:{...e.position,x:0,y:r}})});return d?{...r,cards:c,updated_at:new Date().toISOString()}:r}),$(e),K(!0)},[ei]),ez=(0,n.useCallback)(async()=>
20{if(V){let e=y.cards.find(e=>e.id===V),t=y.cards.filter(e=>e.id!==V),r=e?.type===L.bU.Row?t.map(e=>e.row_id===V?{...e,row_id:null}:e):t,a={...y,cards:r,updated_at:new Date().toISOString()};if(v(a),e?.type===L.bU.Row&&A===V&&$("all"),q(null),G(!1),er(!0),e?.type===L.bU.HtmlEditor){let t=e.channel??`dashboard_card_${e.id}`;O.ApiClient.htmlEditor.deleteHtmlEditorsByChannelHtmlEditorDeleteHtmlEditorsByChannelPost({channel:t}).catch(e=>console.error("Failed to delete HTML editor data:",e))}try{let e={...o.template,dashboard:a},t={id:o?.id,title:o?.title,description:o?.description,image:o?.image,template:e,custom_tool_id:o?.custom_tool_id};await b(t),c()}catch(e){console.error("Failed to auto-save dashboard after deleting card:",e)}}},[V,y,A,o,b,c]),eF=(0,n.useCallback)(async e=>{let t=y.cards.findIndex(t=>t.id===e.id),r=e;if(t>=0){let a=y.cards[t];r={...a,...e,row_id:void 0!==e.row_id?e.row_id:a.row_id,collapsed:void 0!==e.collapsed?e.collapsed:a.collapsed}}let a=y.cards;if(t<0)if(e.type===L.bU.Row)r={...e,position:{x:0,y:0},size:{width:2400,height:40}},a=y.cards.map(e=>({...e,position:{...e.position,y:e.position.y+40}}));else{let t=e.size??{width:600,height:240},l=40*Math.max(4,Math.round(t.height/40)),n=void 0!==e.row_id?e.row_id:"all"===A?null:A;r={...e,position:{x:0,y:0},size:t,row_id:n},a=y.cards.map(e=>({...e,position:{...e.position,y:e.position.y+l}}))}let l=t>=0?a.map((e,a)=>a===t?r:e):[...a,r],n={...y,cards:l,updated_at:new Date().toISOString()};v(n),er(!0),C(!1),N(null),D(null),B&&(j(!1),T(!1));try{let e={...o.template,dashboard:n},t={id:o?.id,title:o?.title,description:o?.description,image:o?.image,template:e,custom_tool_id:o?.custom_tool_id};await b(t),c()}catch(e){console.error("Failed to auto-save dashboard after card update:",e)}},[o,y,b,c,B,A]),eH=(0,n.useCallback)(async e=>{if(0===e.length)return;let t="all"===A?e:e.map(e=>e.type===L.bU.Row||e.row_id?e:{...e,row_id:A}),r=Math.max(40,t.reduce((e,t)=>Math.max(e,t.position.y+t.size.height),0)),a=y.cards.map(e=>({...e,position:{...e.position,y:e.position.y+r+40}})),l={...y,cards:[...a,...t],updated_at:new Date().toISOString()};v(l),M(null),er(!0);try{let e={...o.template,dashboard:l},t={id:o?.id,title:o?.title,description:o?.description,image:o?.image,template:e,custom_tool_id:o?.custom_tool_id};await b(t),c(),K(!1)}catch(e){K(!0),console.error("Failed to auto-save dashboard after bulk add:",e)}},[A,o,y,b,c]),eO=(0,n.useCallback)((e,t)=>{for(let r of Array.from(document.querySelectorAll("[data-dashboard-section-drop-id]"))){let a=r.getBoundingClientRect();if(e>=a.left&&e<=a.right&&t>=a.top&&t<=a.bottom)return r.dataset.dashboardSectionDropId??null}return null},[]),eP=(0,n.useCallback)(async e=>{let t=`card-${Date.now()}`,r=e.type===L.bU.HtmlEditor?`dashboard_card_${t}`:e.channel,a={...e,id:t,title:`${e.title} (Copy)`,channel:r??null,data:null};if(e.type===L.bU.HtmlEditor&&r){let t=e.channel??`dashboard_card_${e.id}`;try{await O.ApiClient.htmlEditor.duplicateHtmlEditorsByChannelHtmlEditorDuplicateHtmlEditorsByChannelPost({source_channel:t,target_channel:r})}catch(e){console.error("Failed to duplicate HTML editor data:",e)}}await eF(a)},[eF]),eI=(0,n.useCallback)(e=>{v(t=>{let r=new Set(t.cards.filter(e=>e.type===L.bU.Row).map(e=>e.id)),a=!1,l=t.cards.map(t=>{let l=e.find(e=>e.i===t.id);if(!l)return t;if(r.has(t.id)){let e=40*l.y;return t.position.y===e?t:(a=!0,{...t,position:{x:0,y:e}})}let{position:n,size:s}=eo(l);return t.position.x===n.x&&t.position.y===n.y&&t.size.width===s.width&&t.size.height===s.height?t:(a=!0,{...t,position:n,size:s})});return a?{...t,cards:l,updated_at:new Date().toISOString()}:t}),K(!0)},[eo]),eK=(0,n.useCallback)((e,t,r,a,l)=>{let n=r.i,s=eO(l.clientX,l.clientY),i=null===s?void 0:"all"===s?null:s;v(t=>{let r=t.cards.find(e=>e.id===n),a="all"===A?void 0:A,l=void 0!==i?i:a,s=!1,o=t.cards.map(t=>{let a=e.find(e=>e.i===t.id);if(!a)return t;let{position:i,size:o}=eo(a),d=t.position.x!==i.x||t.position.y!==i.y||t.size.width!==o.width||t.size.height!==o.height,c=r?.type!==L.bU.Row&&t.id===n&&void 0!==l&&t.row_id!==l;return d||c?(s=!0,{...t,position:i,size:o,...c?{row_id:l}:{}}):t});return s?{...t,cards:o,updated_at:new Date().toISOString()}:t}),s&&$(s),K(!0)},[A,eO,eo]),eW=(0,n.useCallback)(e=>{eI(e)},[eI]),eG=(0,n.useCallback)((e,t)=>{v(r=>({...r,cards:r.cards.map(r=>r.id===e?{...r,llm_id:t}:r),updated_at:new Date().toISOString()})),K(!0)},[]),eV=(0,n.useCallback)(async()=>{P(!0),er(!0);try{let e={...o.template,dashboard:y}
20,t={id:o?.id,title:o?.title,description:o?.description,image:o?.image,template:e,custom_tool_id:o?.custom_tool_id};await b(t),c(),j(!1),K(!1)}catch(e){console.error("Failed to save dashboard:",e)}finally{P(!1)}},[o,y,b,c]),eq=(0,n.useCallback)(()=>{j(e=>!e)},[]),eJ=(0,n.useCallback)(()=>{F(e=>!e)},[]),eQ=(0,n.useCallback)(()=>{x({agent_options:{run_dashboard:!0},list_of_card_ids:y.cards.map(e=>e.id),success_message:"Dashboard executed successfully"})},[y.cards,x]);(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&z&&F(!1)};if(z)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[z]);let eY=(0,n.useCallback)(()=>p.map(e=>{let t=y.cards.find(t=>t.id===e.id);return t?.title||`Card ${e.id}`}).join(", "),[p,y.cards]);(0,n.useCallback)((e,t)=>{Q(r=>({...r,[e]:t}))},[]);let eX=(0,n.useCallback)(e=>{Q(t=>{let r={...t};return delete r[e],r})},[]),eZ=(0,n.useMemo)(()=>y.cards.find(e=>e.id===V),[V,y.cards]),e0=eZ?.type===L.bU.Row,e1=(0,l.jsx)(eg,{cardCount:eh,runningCards:p,runningCardTitles:eY(),isSaving:H,editMode:k,isFullscreen:z,onRunDashboard:eQ,onSaveDashboard:eV,onAddCardType:eN,onOpenGridData:()=>eE("grid-data"),onToggleEditMode:eq,onToggleFullscreen:eJ}),e2=!z&&g?(0,s.createPortal)(e1,g):null;return(0,l.jsxs)(l.Fragment,{children:[e2,(0,l.jsxs)("div",{className:`${z?"fixed inset-0 z-[9999] flex flex-col bg-white dark:bg-gray-900":"flex h-full min-h-0 w-full flex-col"} ${a}`,children:[z&&(0,l.jsx)("div",{className:"flex items-center justify-end border-b border-gray-200 px-6 py-3 dark:border-neutral-700",children:e1}),(0,l.jsx)("div",{className:"relative min-h-0 flex-1 overflow-auto bg-gray-50 dark:bg-gray-900",style:{backgroundImage:y.settings.show_grid&&k?"radial-gradient(circle, #d1d5db 1px, transparent 1px)":"none",backgroundSize:y.settings.show_grid&&k?"24px 24px":"auto"},children:(0,l.jsxs)("div",{ref:Y,className:"relative p-4",style:{minWidth:X,minHeight:"1000px",width:"max-content",height:"max-content"},children:[(0,l.jsx)(eb,{sections:ep,activeSectionId:A,contentCardCount:eh,editMode:k,onSelectSection:e_,onAddSection:e$,onRenameSection:eT,onDeleteSection:eR,onReorderSection:eU}),(0,l.jsx)(d(),{className:"layout",layout:ej,cols:24,rowHeight:40,width:2400,isDraggable:k,isResizable:k,draggableCancel:".row-no-drag",onDragStop:eK,onResizeStop:eW,compactType:"vertical",preventCollision:!1,allowOverlap:!1,margin:[12,12],containerPadding:[0,8],useCSSTransforms:!0,autoSize:!0,children:ek.map(e=>{let r=p.some(t=>t.id===e.id),a=J[e.id];return(0,l.jsx)("div",{children:(0,l.jsx)(et,{card:e,editMode:k,onEdit:eD,onDirectEdit:eL,onDelete:eB,onDuplicate:eP,onResize:()=>{},onMove:()=>{},onLlmChange:eG,data:t[e.id]||{},isRunning:r,hasError:!!a,errorMessage:a,onRun:x,onClearError:eX,panelTitle:e.row_id?ey.get(e.row_id)??"Unknown panel":"No panel",theme:m})},e.id)})}),0===eh&&(0,l.jsx)("div",{className:"flex h-64 items-center justify-center",children:(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)(i.Uhn,{className:"mx-auto mb-4 text-6xl text-gray-400"}),(0,l.jsx)("h3",{className:"mb-2 text-lg font-medium text-gray-900 dark:text-neutral-100",children:"No cards yet"}),(0,l.jsx)("p",{className:"mb-4 text-gray-500 dark:text-neutral-400",children:"Add your first dashboard card to get started"}),(0,l.jsx)(ea,{triggerLabel:"Add Card",align:"center",variant:"primary",onAddCardType:eN,onOpenGridData:()=>eE("grid-data")})]})}),eh>0&&"all"!==A&&0===ek.length&&(0,l.jsx)("div",{className:"flex h-64 items-center justify-center",children:(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)(i.Uhn,{className:"mx-auto mb-4 text-6xl text-gray-400"}),(0,l.jsxs)("h3",{className:"mb-2 text-lg font-medium text-gray-900 dark:text-neutral-100",children:["No cards in ",ev]}),(0,l.jsx)("p",{className:"mb-4 text-gray-500 dark:text-neutral-400",children:"Add a card while this section is selected."}),(0,l.jsx)(ea,{triggerLabel:"Add Card",align:"center",variant:"primary",onAddCardType:eN,onOpenGridData:()=>eE("grid-data")})]})})]})}),_&&(0,l.jsx)(ex,{theme:m,columns:u,nbrOfRows:o?.nbr_of_rows||0,isOpen:_,onClose:()=>{C(!1),N(null),D(null),B&&(j(!1),T(!1))},card:w,cardData:w?.id?t[w.id]??null:null,agentId:e,initialCardType:E??void 0,hideTypeSelectorOnCreate:null!==E,panelOptions:ef,initialPanelId:"all"===A?null:A,onSave:eF},w?.id||`new-card-${E??L.bU.Metric}`),S&&(0,l.jsx)(ew,{isOpen:null!==S,mode:S,agentId:e,columns:u,rowKeys:h,nbrOfRows:o?.nbr_of_rows||0,onClose:()=>M(null),onAddCards:eH}),(0,l.jsx)(eC,{isOpen:R,onClose:()=>U(!1),onApplyTemplate:e=>{v(t=>{let r=e.cards.map((e,t)=>({...e,id:`card-${Date.now()}-${t}`,position:{x:350*t,y:0}
20,size:{width:300,height:200}}));return{...t,cards:[...t.cards,...r],updated_at:new Date().toISOString()}}),U(!1)}}),(0,l.jsx)(eS.default,{show:W,onClose:()=>{G(!1),q(null)},onDelete:ez,title:e0?"Delete Section":"Delete Dashboard Card",text:e0?"Delete this section? Cards in this section will move to All.":"Are you sure you want to delete this card?"})]})]})}},66332:(e,t,r)=>{r.d(t,{d:()=>i});var a=r(14232),l=r(90864),n=r(71963),s=r(93764);let i=(e={})=>{let{channelId:t,onAutoOpen:r}=e,i=(0,l.b)(e=>e.handleHtmlEditorUpdate),{agentDataEvents:o,agentDataFirstRetainedIndex:d=0}=(0,n.G)()||{},c=(0,a.useRef)(0),u=(0,a.useRef)(null);(0,a.useEffect)(()=>{u.current!==t&&(c.current=0,u.current=t??null)},[t]),(0,a.useEffect)(()=>{if(!o||0===o.length||!t)return;let{startIndex:e,nextCursor:a}=(0,s.K)(c.current,d,o.length);for(let a=e;a<o.length;a++){let e=o[a];if(e&&"html_editor_update"===e.type){let a=e.html_editor,l=e.action||"update",n=e.channel_id||e.channel||a?.channel_id;if(n&&n!==t)continue;if(a)try{let e="html_editor_update";"init"===l?e="html_editor_init":"delete"===l&&(e="html_editor_delete"),i({type:e,action:l,channelId:t,payload:{editor_id:a.editor_id,title:a.title,html_content:a.html_content,css_content:a.css_content,js_content:a.js_content,dependencies:a.dependencies,updated_at:a.updated_at,action:a.action}}),"html_editor_delete"!==e&&r?.()}catch(e){console.error("[useHtmlEditorEvents] Failed to process event:",e)}}}c.current=a},[o,d,t,i,r])}},70087:(e,t,r)=>{r.d(t,{A:()=>y});var a=r(37876),l=r(14232),n=r(90864),s=r(36802),i=r(98132),o=r(1144),d=r(31376),c=r(43900),u=r(49756),m=r(53013),x=r(89988),h=r(77542),g=r(26258),p=r(77148),b=r(70997);let f={html:"HTML",css:"CSS",js:"JS"},y=l.memo(function({channelId:e,theme:t="light",panelMode:r=!1,onClose:y}){let v=(0,n.b)(t=>t.editorsByChannel[e]),k=(0,n.b)(e=>e.setEditor),{agentId:j}=(0,b.J)(),w=(0,n.b)(t=>t.getVisibility(e)),N=(0,n.b)(e=>e.toggleFullscreen),[_,C]=(0,l.useState)("html"),[S,M]=(0,l.useState)("split"),{isSaving:A,isDirty:$,markDirty:E,setIsDirty:D,saveEditor:L}=(e=>{let{successToast:t,errorToast:r}=(0,g.Ay)(),a=(0,n.b)(t=>e?t.editorsByChannel[e]??null:null),s=(0,n.b)(e=>e.setEditor),[i,o]=(0,l.useState)(!1),[d,c]=(0,l.useState)(!1),u=(0,l.useRef)(0),{departmentId:m,promoteDraftArtifactChat:x}=(0,p.A)(),b=(0,l.useCallback)(()=>{c(!0)},[]),f=(0,l.useCallback)(async()=>{if(!e||!a)return!1;let l=Date.now();if(l-u.current<1e3)return!1;u.current=l,o(!0);try{let r=(await h.ApiClient.htmlEditor.updateHtmlEditorHtmlEditorUpdateHtmlEditorPost({editor_id:a.editor_id,html_content:a.html_content,css_content:a.css_content,js_content:a.js_content,title:a.title,channel:e,department_id:m})).data;return s(e,{...a,updatedAt:r.updated_at,lastAction:"update"}),c(!1),x(e),t("HTML editor saved"),!0}catch(t){let e=t?.error?.detail??t.message??"Unknown error";return r(`Failed to save: ${e}`),!1}finally{o(!1)}},[e,m,a,r,x,s,t]);return{isSaving:i,isDirty:d,markDirty:b,setIsDirty:c,saveEditor:f}})(e),B=(0,l.useCallback)(async()=>{if(v?.editor_id&&e)try{let t=(await h.ApiClient.htmlEditor.getHtmlEditorByIdHtmlEditorGetHtmlEditorByIdPost({editor_id:v.editor_id,agent_id:j})).data;k(e,{editor_id:t.editor_id,title:t.title||"Untitled",html_content:t.html_content||"",css_content:t.css_content||"",js_content:t.js_content||"",dependencies:t.dependencies||[],updatedAt:t.updated_at||new Date().toISOString(),lastAction:"update",exportReady:!1}),D(!1)}catch{}},[j,v?.editor_id,e,k,D]),{versions:T,isLoading:R,isRestoring:U,showVersions:z,setShowVersions:F,fetchVersions:H,toggleVersions:O,restoreVersion:P}=((e,t)=>{let{successToast:r,errorToast:a}=(0,g.Ay)(),[n,s]=(0,l.useState)([]),[i,o]=(0,l.useState)(0),[d,c]=(0,l.useState)(!1),[u,m]=(0,l.useState)(!1),[x,p]=(0,l.useState)(!1),b=(0,l.useCallback)(async()=>{if(e){c(!0);try{let t=(await h.ApiClient.htmlEditor.getHtmlEditorVersionsHtmlEditorGetHtmlEditorVersionsPost({editor_id:e})).data;s(t.versions??[]),o(t.current_version),p(!0)}catch(t){let e=t?.error?.detail??t.message??"Unknown error";a(`Failed to fetch versions: ${e}`)}finally{c(!1)}}},[e,a]),f=(0,l.useCallback)(()=>{x?p(!1):b()},[x,b]),y=(0,l.useCallback)(async t=>{if(!e)return null;try{return(await h.ApiClient.htmlEditor.getHtmlEditorVersionContentHtmlEditorGetHtmlEditorVersionContentPost({editor_id:e,version_index:t})).data}catch(t){let e=t?.error?.detail??t.message??"Unknown error";return a(`Failed to fetch version content: ${e}`),null}},[e,a]),v=(0,l.useCallback)(async l=>{if(!e)return!1;m(!0);try{return await h.ApiClient.htmlEditor.restoreHtmlEditorVersionHtmlEditorRestoreHtmlEditorVersionPost({editor_id:e,version_index:l}),t?.(),r(`Restored to version ${l+1}`),p(!1),!0}catch(t){let e=t?.error?.detail??t.message??"Unknown error";return a(`Failed to restore version: ${e}`),!1}finally{m(!1)}},[e,t,r,a]);return{versions:n,currentVersion:i,isLoading:d,isRestoring:u,showVersions:x,setShowVersions:p,fetchVersions:b,toggleVersions:f,getVersionContent:y,restoreVersion:v}})(v?.editor_id,B),I=(0,l.useRef)(v);I.current=v;let K=(0,l.useCallback)(t=>{let r=I.current;if(!r)return;let a="html"===_?"html_content":"css"===_?"css_content":"js_content";k(e,{...r,[a]:t,lastAction:"update",updatedAt:new Date().toISOString()}),E()},[_,e,k,E]),W=(0,l.useRef)(L);W.current=L,(0,l.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key&&(e.preventDefault(),W.current())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]);let G=(0,l.useCallback)(async()=>{await L()&&z&&H()},[L,z,H]),V=(0,l.useCallback)(()=>{N(e)},[e,N]),q=(0,l.useMemo)(()=>v?"html"===_?v.html_content:"css"===_?v.css_content:v.js_content:"",[v,_]);if(!v)return(0,a.jsx)("div",{className:"flex h-full items-center justify-center text-sm text-[var(--lampi-context-muted)]",children:"No HTML editor active for this channel."});let J=r?"flex h-full flex-col overflow-hidden bg-[var(--lampi-artifact-bg)] text-[var(--lampi-context-text)]":"flex h-full flex-col overflow-hidden rounded-lg border border-[var(--lampi-context-border)] bg-[var(--lampi-context-surface)] text-[var(--lampi-context-text)]",Q="flex h-8 w-8 items-center justify-center rounded-lg text-[var(--lampi-context-icon)] transition-colors duration-150 ease-out hover:bg-[var(--lampi-context-hover)] hover:text-[var(--lampi-context-text)]",Y=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m.A,{text:$?"Save changes (Ctrl+S)":"No changes",options:"bottom",children:(0,a.jsx)("button",{onClick:G,disabled:!$||A,className:`flex h-8 w-8 items-center justify-center rounded-lg transition-colors duration-150 ease-out disabled:cursor-not-allowed ${$?"text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/30":"text-[var(--lampi-context-border)]"}`,children:(0,a.jsx)(x.A,{isLoading:A,children:(0,a.jsx)(o.Bc_,{size:14})})})}),(0,a.jsx)(m.A,{text:"Version history",options:"bottom",children:(0,a.jsx)("button",{onClick:O,disabled:R,className:`${Q} disabled:cursor-not-allowed disabled:opacity-50 ${z?"bg-[var(--lampi-context-hover)] text-[var(--lampi-context-text-strong)]":""}`,children:(0,a.jsx)(x.A,{isLoading:R,children:(0,a.jsx)(c.QtE,{size:14})})})}),(0,a.jsx)("div",{className:"mx-1 h-5 w-px bg-[var(--lampi-context-border)]"}),(0,a.jsx)("button",{onClick:V,className:Q,title:w.isFullscreen?"Exit fullscreen":"Fullscreen",children:w.isFullscreen?(0,a.jsx)(d.Wsx,{size:14}):(0,a.jsx)(d._AH,{size:14})}),r&&y&&(0,a.jsx)("button",{onClick:y,className:Q,title:"Close HTML Editor","aria-label":"Close HTML Editor",children:(0,a.jsx)(d.QCr,{size:14})})]});return(0,a.jsxs)("div",{className:w.isFullscreen?"fixed inset-0 z-[9999] flex flex-col overflow-hidden bg-[var(--lampi-artifact-bg)] text-[var(--lampi-context-text)]":J,children:[r&&(0,a.jsxs)("div",{className:"flex h-11 flex-shrink-0 items-center justify-between border-b border-[var(--lampi-context-border)] bg-[var(--lampi-context-surface)] px-3",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,a.jsx)("div",{className:"hidden h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-[var(--lampi-context-subtle)] sm:flex",children:(0,a.jsx)(u.CWz,{className:"h-3.5 w-3.5 text-[var(--lampi-context-icon)]"})}),(0,a.jsx)("h3",{className:"truncate text-sm font-medium text-[var(--lampi-context-text-strong)]",children:v.title||"HTML Editor"})]}),(0,a.jsx)("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:Y})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-[var(--lampi-context-border)] bg-[var(--lampi-artifact-bg)] px-3 py-1.5",children:[(0,a.jsx)("div",{className:"flex gap-1 rounded-lg bg-[var(--lampi-context-subtle)] p-0.5",children:["html","css","js"].map(e=>(0,a.jsx)("button",{onClick:()=>C(e),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors duration-150 ease-out ${_===e?"bg-[var(--lampi-context-surface)] text-[var(--lampi-context-text-strong)] shadow-black smooth-shadow-ring-xs smooth-ring-neutral-300/30 dark:smooth-ring-neutral-400/30":"text-[var(--lampi-context-muted)] hover:bg-[var(--lampi-context-hover)] hover:text-[var(--lampi-context-text)]"}`,children:f[e]},e))}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("button",{onClick:()=>M("editor"),className:`${Q} ${"editor"===S?"bg-[var(--lampi-context-hover)] text-[var(--lampi-context-text-strong)]":""}`,title:"Code only",children:(0,a.jsx)(o.PjK,{size:14})}),(0,a.jsx)("button",{onClick:()=>M("preview"),className:`${Q} ${"preview"===S?"bg-[var(--lampi-context-hover)] text-[var(--lampi-context-text-strong)]":""}`,title:"Preview only",children:(0,a.jsx)(d.Ny1,{size:14})}),(0,a.jsx)("button",{onClick:()=>M("split"),className:`${Q} ${"split"===S?"bg-[var(--lampi-context-hover)] text-[var(--lampi-context-text-strong)]":""}`,title:"Split view",children:(0,a.jsx)(d.vgu,{size:14})}),!r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mx-1 h-5 w-px bg-[var(--lampi-context-border)]"}),Y]})]})]}),z&&(0,a.jsxs)("div",{className:"border-b border-[var(--lampi-context-border)] bg-[var(--lampi-context-subtle)] px-4 py-3",children:[(0,a.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,a.jsx)("h4",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--lampi-context-muted)]",children:"Version History"}),(0,a.jsx)("button",{onClick:()=>F(!1),className:"rounded px-2 py-1 text-xs text-[var(--lampi-context-muted)] transition-colors duration-150 ease-out hover:bg-[var(--lampi-context-hover)] hover:text-[var(--lampi-context-text)]",children:"Close"})]}),0===T.length?(0,a.jsx)("p",{className:"text-sm text-[var(--lampi-context-muted)]",children:"No previous versions available"}):(0,a.jsx)("div",{className:"max-h-40 space-y-1.5 overflow-y-auto",children:T.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-[var(--lampi-context-border)] bg-[var(--lampi-context-surface)] p-2.5",children:[(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsxs)("span",{className:"font-medium text-[var(--lampi-context-text)]",children:["v",e.version]}),(0,a.jsx)("span",{className:"ml-2 text-[var(--lampi-context-muted)]",children:e.operation}),(0,a.jsx)("span",{className:"ml-2 text-xs text-[var(--lampi-context-muted)]",children:new Date(e.timestamp).toLocaleStr
20ing()})]}),(0,a.jsx)("button",{onClick:()=>P(t),disabled:U,className:"rounded bg-blue-50 px-2.5 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-100 disabled:opacity-50 dark:bg-blue-900/30 dark:text-blue-400 dark:hover:bg-blue-800/40",children:U?"Restoring...":"Restore"})]},t))})]}),(0,a.jsxs)("div",{className:"border-b border-[var(--lampi-context-border)] px-3 py-1 text-xs text-[var(--lampi-context-muted)]",children:[v.title,v.dependencies.length>0&&(0,a.jsxs)("span",{className:"ml-2 text-blue-400",children:["[",v.dependencies.join(", "),"]"]})]}),(0,a.jsxs)("div",{className:"flex min-h-0 flex-1",children:[("editor"===S||"split"===S)&&(0,a.jsx)("div",{className:`${"split"===S?"w-1/2":"w-full"} h-full ${"split"===S?"border-r border-[var(--lampi-context-border)]":""}`,children:(0,a.jsx)(s.A,{value:q,language:_,theme:t,onChange:K})}),(0,a.jsx)("div",{className:`${"split"===S?"w-1/2":"w-full"} h-full ${"editor"===S?"invisible absolute":""}`,children:(0,a.jsx)(i.A,{htmlContent:v.html_content,cssContent:v.css_content,jsContent:v.js_content,dependencies:v.dependencies,theme:t})})]})]})})},76606:(e,t,r)=>{r.d(t,{PS:()=>a,X9:()=>n,cF:()=>l});let a=e=>{let t=[];return e.forEach((r,a)=>{t.push({type:"columnMention",attrs:{id:r.id,label:r.display,rowId:r.rowId??null}}),a<e.length-1&&(t.push({type:"hardBreak"}),t.push({type:"text",text:"--"}),t.push({type:"hardBreak"}))}),t},l=e=>e.map(e=>null!==e.rowId&&void 0!==e.rowId?`#[${e.display}](id:${e.id}:row:${e.rowId})`:`#[${e.display}](id:${e.id})`).join("\n--\n"),n=(e,t)=>{let r=e.trim();if(!r)return[];let a=[];return t&&(a.push({type:"hardBreak"}),a.push({type:"hardBreak"})),a.push({type:"text",text:r}),a}},77148:(e,t,r)=>{r.d(t,{A:()=>i});var a=r(14232),l=r(89099),n=r(85461),s=r(70150);function i(){let e=(0,l.useRouter)(),t=(0,n.jE)(),r=function(e){if("string"!=typeof e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}(e.query.chat),i=(0,a.useCallback)(a=>{void 0!==r&&(0,s.Sj)(e.query.draft)&&(t.invalidateQueries({queryKey:["list_messages_per_channel"]}),t.invalidateQueries({queryKey:["list_messages_per_space",{department_id:r}]}),t.invalidateQueries({queryKey:["messages_encrypted",{channel:a}]}),t.invalidateQueries({queryKey:["name_for_channel",{channel:a}]}),e.replace({pathname:e.pathname,query:(0,s.ig)(e.query)},void 0,{shallow:!0}))},[r,t,e]);return{departmentId:r,promoteDraftArtifactChat:i}}},90864:(e,t,r)=>{r.d(t,{b:()=>i});var a=r(55691),l=r(4319);let n={isVisible:!1,isFullscreen:!1};function s(e,t){let r=Object.keys(e);if(r.length<=5)return e;let a=r.filter(e=>e!==t).sort((t,r)=>new Date(e[t].updatedAt).getTime()-new Date(e[r].updatedAt).getTime()).slice(0,r.length-5);if(0===a.length)return e;let l={...e};for(let e of a)delete l[e];return l}let i=(0,a.vt)()((0,l.lt)((e,t)=>({editorsByChannel:{},visibilityByChannel:{},_idleTimeouts:{},getEditor:e=>t().editorsByChannel[e]??null,setEditor:(t,r)=>{e(e=>{if(null===r){let{[t]:r,...a}=e.editorsByChannel;return{editorsByChannel:a}}return{editorsByChannel:s({...e.editorsByChannel,[t]:r},t)}},!1,"setEditor")},handleHtmlEditorUpdate:r=>{let{type:a,channelId:l,payload:i}=r;if(!l)return void console.warn("[HtmlEditorStore] Update rejected: missing channelId");let o=t()._idleTimeouts[l];if(o&&clearTimeout(o),"html_editor_delete"===a)return void e(e=>{let{[l]:t,...r}=e.editorsByChannel;return{editorsByChannel:r}},!1,"html_editor_delete");if("html_editor_init"===a){let t={editor_id:i.editor_id,title:i.title||"Untitled",html_content:i.html_content||"",css_content:i.css_content||"",js_content:i.js_content||"",dependencies:i.dependencies||[],updatedAt:i.updated_at||new Date().toISOString(),lastAction:"init",exportReady:!1};e(e=>({editorsByChannel:s({...e.editorsByChannel,[l]:t},l),visibilityByChannel:{...e.visibilityByChannel,[l]:{...e.visibilityByChannel[l]||n,isVisible:!0}}}),!1,"html_editor_init")}else if("html_editor_update"===a){e(e=>{let t=e.editorsByChannel[l],r=i.action||"update";if(!t){let t={editor_id:i.editor_id,title:i.title||"Untitled",html_content:i.html_content||"",css_content:i.css_content||"",js_content:i.js_content||"",depen
20dencies:i.dependencies||[],updatedAt:i.updated_at||new Date().toISOString(),lastAction:r,exportReady:!1};return{editorsByChannel:s({...e.editorsByChannel,[l]:t},l),visibilityByChannel:{...e.visibilityByChannel,[l]:{...e.visibilityByChannel[l]||n,isVisible:!0}}}}let a={...t,title:i.title||t.title,html_content:void 0!==i.html_content?i.html_content:t.html_content,css_content:void 0!==i.css_content?i.css_content:t.css_content,js_content:void 0!==i.js_content?i.js_content:t.js_content,dependencies:i.dependencies||t.dependencies,updatedAt:i.updated_at||new Date().toISOString(),lastAction:r};return{editorsByChannel:{...e.editorsByChannel,[l]:a}}},!1,"html_editor_update");let t=setTimeout(()=>{e(e=>{let t=e.editorsByChannel[l];return t&&"idle"!==t.lastAction?{editorsByChannel:{...e.editorsByChannel,[l]:{...t,lastAction:"idle"}}}:e},!1,"html_editor_idle")},5e3);e(e=>({_idleTimeouts:{...e._idleTimeouts,[l]:t}}),!1,"html_editor_set_idle_timeout")}},getVisibility:e=>t().visibilityByChannel[e]||n,toggleVisibility:t=>{e(e=>{let r=e.visibilityByChannel[t]||n;return{visibilityByChannel:{...e.visibilityByChannel,[t]:{...r,isVisible:!r.isVisible}}}},!1,"toggleVisibility")},setVisibility:(t,r)=>{e(e=>{let a=e.visibilityByChannel[t]||n;return{visibilityByChannel:{...e.visibilityByChannel,[t]:{...a,isVisible:r}}}},!1,"setVisibility")},toggleFullscreen:t=>{e(e=>{let r=e.visibilityByChannel[t]||n;return{visibilityByChannel:{...e.visibilityByChannel,[t]:{...r,isFullscreen:!r.isFullscreen}}}},!1,"toggleFullscreen")},clearEditor:t=>{e(e=>{let{[t]:r,...a}=e.editorsByChannel,{[t]:l,...n}=e.visibilityByChannel,s=e._idleTimeouts[t];s&&clearTimeout(s);let{[t]:i,...o}=e._idleTimeouts;return{editorsByChannel:a,visibilityByChannel:n,_idleTimeouts:o}},!1,"clearEditor")},clearAll:()=>{Object.values(t()._idleTimeouts).forEach(e=>clearTimeout(e)),e({editorsByChannel:{},visibilityByChannel:{},_idleTimeouts:{}},!1,"clearAll")}}),{name:"HtmlEditorStore"}))},98132:(e,t,r)=>{r.d(t,{A:()=>i});var a=r(37876),l=r(14232),n=r(12227);let s={"chart.js":"https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js",d3:"https://cdn.jsdelivr.net/npm/d3@7/dist/d3.min.js",mermaid:"https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js","plotly.js":"https://cdn.jsdelivr.net/npm/plotly.js-dist-min@2/plotly.min.js",leaflet:"https://cdn.jsdelivr.net/npm/leaflet@1/dist/leaflet.js","three.js":"https://cdn.jsdelivr.net/npm/[email protected]/build/three.min.js","anime.js":"https://cdn.jsdelivr.net/npm/animejs@3/lib/anime.min.js",gsap:"https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js",prismjs:"https://cdn.jsdelivr.net/npm/prismjs@1/prism.min.js","highlight.js":"https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11/build/highlight.min.js",katex:"https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js",mathjax:"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"},i=l.memo(function({htmlContent:e,cssContent:t,jsContent:r,dependencies:i=[],theme:o="light"}){let d=(0,l.useMemo)(()=>{let a=n.A.sanitize(e,{ADD_TAGS:["style","canvas","iframe","svg","path","circle","rect","line","polyline","polygon","text","g","defs","use","clipPath","mask","pattern","linearGradient","radialGradient","stop","foreignObject"],ADD_ATTR:["viewBox","xmlns","fill","stroke","stroke-width","d","cx","cy","r","x","y","width","height","transform","style","class","id","src","allowfullscreen","frameborder","allow","loading"],ALLOW_DATA_ATTR:!0}),l=i.map(e=>{let t=s[e.toLowerCase()];return t?`<script src="${t}"></script>`:""}).filter(Boolean).join("\n"),d="dark"===o?"#1e1e1e":"#ffffff",c="dark"===o?"#d4d4d4":"#1e1e1e";return`<!DOCTYPE html>
21<html>
22<head>
23<meta charset="UTF-8">
24<base target="_blank">
25<style>
26body { background: ${d}; color: ${c}; }
27${t}
28</style>
29${l}
30</head>
31<body>
32${a}
33<script>
34// Force all link clicks to open in a new tab
35document.addEventListener('click', function(e) {
36  var a = e.target.closest('a[href]');
37  if (a && a.href && !a.href.startsWith('javascript:')) {
38    e.preventDefault();
39    window.open(a.href, '_blank', 'noopener,noreferrer');
40  }
41}, true);
42window.addEventListener('DOMContentLoaded', function() {
43  try {
44    ${r}
45  } catch(e) {
46    document.body.innerHTML += '<pre style="color:red;padding:1rem;font-size:12px;">JS Error: ' + e.message + '</pre>';
47  }
48});
49</script>
50</body>
51</html>`},[e,t,r,i,o]);return(0,a.jsx)("iframe",{srcDoc:d,sandbox:"allow-scripts allow-same-origin allow-popups allow-presentation",title:"HTML Preview",className:"h-full w-full border-0",style:{minHeight:"200px"}})})}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.