PageSourceSearch

https://app.wisemelon.ai/_next/static/chunks/337-52641080ba7f21ee.js

js wisemelon.ai collected 2026-10-05 13:20:33 UTC 110,721 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[337],{33485:function(e,t,n){n.d(t,{W:function(){return l}});var r=n(35944),i=n(67294),a=n(73935),l=function(e){var t=e.tooltipTitle,n=void 0===t?"":t,l=e.tooltipDescription,o=void 0===l?"":l,c=e.children,s=e.IconComponent,d=e.disabled,u=void 0!==d&&d,f=(0,i.useState)(!1),h=f[0],p=f[1],m=(0,i.useState)({top:0,left:0}),g=m[0],v=m[1],b=(0,i.useRef)(null),x=(0,i.useRef)(null),y=function(){x.current=setTimeout((function(){if(b.current){var e=b.current.getBoundingClientRect();v({top:e.bottom+window.scrollY+6,left:e.left+e.width/2+window.scrollX}),p(!0)}}),150)},Z=function(){x.current&&clearTimeout(x.current),p(!1)};if(u)return c;var w=i.cloneElement(c,{ref:b,onMouseEnter:function(e){var t,n;null===(n=(t=c.props).onMouseEnter)||void 0===n||n.call(t,e),y()},onMouseLeave:function(e){var t,n;null===(n=(t=c.props).onMouseLeave)||void 0===n||n.call(t,e),Z()},onFocus:function(e){var t,n;null===(n=(t=c.props).onFocus)||void 0===n||n.call(t,e),y()},onBlur:function(e){var t,n;null===(n=(t=c.props).onBlur)||void 0===n||n.call(t,e),Z()}}),N=(0,r.tZ)("div",{role:"tooltip","aria-hidden":!h,className:"\n        fixed z-[999999] drop-shadow-xl\n        bg-[#f9fafb] backdrop-blur-3xl text-[#111827] border border-[#e5e7eb] \n        p-2 pr-[50px] tracking-tight rounded text-sm pointer-events-none\n        max-w-xs transform transition-all duration-200 ease-out\n        ".concat(h?"opacity-100 scale-100 visible":"opacity-0 scale-95 invisible","\n        flex items-center gap-1\n      "),style:{top:g.top,left:g.left,transform:"translate(-50%, 0)"},children:(0,r.BX)("div",{className:"flex flex-col w-full",children:[n&&(0,r.tZ)("span",{className:"font-semibold pb-2",children:n}),(0,r.BX)("div",{className:"flex gap-2 flex-row items-center justify-center p-0 w-full",children:[s&&(0,r.tZ)(s,{size:14,weight:"regular"}),(0,r.tZ)("span",{className:"break-all",children:o})]})]})});return(0,r.BX)(r.HY,{children:[w,h&&(0,a.createPortal)(N,document.body)]})}},46314:function(e,t,n){n.d(t,{Ds:function(){return r}});function r(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:300,r=this;return function(){for(var i=arguments.length,a=new Array(i),l=0;l<i;l++)a[l]=arguments[l];clearTimeout(t),t=setTimeout((function(){e.apply(r,a)}),n)}}},82946:function(e,t,n){n.d(t,{w:function(){return Z}});var r=n(35944),i=n(67294),a=n(73935),l=n(51646),o=n(96014),c=n(28198),s=n(42010),d=n(14397),u=n(38999),f=n(4355),h=n(90889),p=n(45582),m=n(34001),g=n(73456),v=n(3518),b=function(e){switch(e){case"CHART":return(0,r.tZ)(l.Z,{size:11});case"TABLE":return(0,r.tZ)(o.Z,{size:11});case"MIXED":return(0,r.tZ)(c.Z,{size:11});default:return(0,r.tZ)(s.Z,{size:11})}},x=function(e){switch(e){case"CHART":return"bg-blue-100 text-blue-700";case"TABLE":return"bg-emerald-100 text-emerald-700";case"MIXED":return"bg-violet-100 text-violet-700";default:return"bg-slate-100 text-slate-600"}};function y(e){var t=e.text.split("\n");return(0,r.tZ)("div",{className:"space-y-1",children:t.map((function(e,t){if(!e.trim())return(0,r.tZ)("div",{className:"h-2"},t);var n=e.startsWith("## "),i=e.startsWith("### "),a=/^[-\u2022*]/.test(e.trim()),l=e.replace(/^##+ /,"").replace(/^[-\u2022*] /,"").split(/(\*\*[^*]+\*\*|`[^`]+`)/).map((function(e,t){return e.startsWith("**")&&e.endsWith("**")?(0,r.tZ)("strong",{className:"font-semibold text-slate-800",children:e.slice(2,-2)},t):e.startsWith("`")&&e.endsWith("`")?(0,r.tZ)("code",{className:"font-mono text-[11px] bg-slate-100 text-blue-700 px-1 py-0.5 rounded",children:e.slice(1,-1)},t):e}));return n?(0,r.tZ)("p",{className:"font-semibold text-sm text-slate-800 mt-2",children:l},t):i?(0,r.tZ)("p",{className:"font-medium text-xs text-slate-700 mt-1",children:l},t):a?(0,r.BX)("div",{className:"flex gap-1.5 items-start",children:[(0,r.tZ)("span",{className:"text-blue-400 mt-0.5 shrink-0",children:"\u2022"}),(0,r.tZ)("p",{className:"text-xs text-slate-600 leading-relaxed",children:l})]},t):(0,r.tZ)("p",{className:"text-xs text-slate-600 leading-relaxed",children:l},t)}))})}function Z(e){var t,n,i=e.option,o=e.onClose,c=null!==(n=null===i||void 0===i||null===(t=i.title)||void 0===t?void 0:t.text)&&void 0!==n?n:"Chart";return a.createPortal((0,r.tZ)("div",{className:"fixed inset-0 z-[10002] flex items-center justify-center p-6",style:{background:"rgba(118, 119, 122, 0.17)",backdropFilter:"blur(6px)"},onClick:o,children:(0,r.BX)("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden flex flex-col",style:{width:"min(92vw, 900px)",maxHeight:"88vh"},onClick:function(e){return e.stopPropagation()},children:[(0,r.BX)("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-slate-100",children:[(0,r.BX)("div",{className:"flex items-center gap-2.5",children:[(0,r.tZ)("div",{className:"w-7 h-7 rounded-lg bg-blue-50 flex items-center justify-center",children:(0,r.tZ)(l.Z,{size:14,className:"text-green-600"})}),(0,r.tZ)("span",{className:"font-semibold text-slate-800 text-sm",children:c})]}),(0,r.tZ)("button",{onClick:o,className:"p-1.5 rounded-xl text-slate-400 hover:text-slate-700 hover:bg-slate-100 transition-colors",children:(0,r.tZ)(d.Z,{size:16})})]}),(0,r.tZ)("div",{className:"flex-1 p-6",style:{minHeight:420},children:(0,r.tZ)(v.Z,{option:i,height:420})})]})}),document.body)}function w(e){var t,n,a,o=e.option,c=e.isPinned,s=e.onPin,p=e.onUnpin,m=(0,i.useState)(!1),g=m[0],b=m[1],x=(0,i.useState)(!1),y=x[0],w=x[1],N=null!==(a=null===o||void 0===o||null===(t=o.series)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.type)&&void 0!==a?a:"chart";return(0,r.BX)(r.HY,{children:[(0,r.BX)("div",{className:"relative rounded-xl overflow-hidden border border-slate-200 bg-white shadow-sm\n        transition-all duration-300 ".concat(g?"mt-1":"mt-2"),children:[(0,r.BX)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-slate-100 bg-slate-50",children:[(0,r.BX)("span",{className:"text-[11px] font-semibold text-slate-500 tracking-wide uppercase",children:[N," chart"]}),(0,r.BX)("div",{className:"flex items-center gap-1",children:[(0,r.BX)("button",{onClick:c?p:s,title:c?"Unpin from dashboard":"Pin to dashboard",className:"flex items-center gap-1 text-[10px] px-2 py-0.5 rounded-full border transition-all duration-200\n                ".concat(c?"bg-green-100 text-green-700 border-green-700 hover:bg-green-200":"text-slate-500 border-slate-200 hover:bg-blue-50 hover:text-blue-600 hover:border-blue-200"),children:[c?(0,r.tZ)(u.Z,{size:10}):(0,r.tZ)(f.Z,{size:10}),c?"Pinned":"Pin"]}),(0,r.tZ)("button",{onClick:function(){return w(!0)},className:"p-1 rounded-md text-slate-400 hover:text-slate-700 hover:bg-slate-200 transition-colors",title:"Fullscreen",children:(0,r.tZ)(h.Z,{size:13})}),(0,r.tZ)("button",{onClick:function(){return b((function(e){return!e}))},className:"p-1 rounded-md text-slate-400 hover:text-slate-700 hover:bg-slate-200 transition-colors",title:g?"Collapse":"Expand",children:g?(0,r.tZ)(d.Z,{size:13}):(0,r.tZ)(l.Z,{size:13})})]})]}),(0,r.tZ)("div",{className:"transition-all duration-300 ease-in-out overflow-hidden",style:{height:g?380:220},children:(0,r.tZ)("div",{className:"p-3 h-full",children:(0,r.tZ)(v.Z,{option:o,height:g?355:195})})})]}),y&&(0,r.tZ)(Z,{option:o,onClose:function(){return w(!1)}})]})}function N(e){var t=e.headers,n=e.rows;return(0,r.tZ)("div",{className:"mt-2 rounded-xl overflow-hidden border border-slate-200 bg-white shadow-sm",children:(0,r.tZ)("div",{className:"overflow-x-auto max-h-40",children:(0,r.BX)("table",{className:"w-full text-[11px]",children:[(0,r.tZ)("thead",{children:(0,r.tZ)("tr",{className:"bg-slate-700 text-white",children:t.map((function(e,t){return(0,r.tZ)("th",{className:"px-3 py-2 text-left font-semibold tracking-wide whitespace-nowrap",children:e},t)}))})}),(0,r.tZ)("tbody",{children:n.map((function(e,t){return(0,r.tZ)("tr",{className:t%2===0?"bg-white":"bg-slate-50",children:e.map((function(e,t){return(0,r.tZ)("td",{className:"px-3 py-1.5 text-slate-600 whitespace-nowrap",children:null!=e?String(e):"\u2014"},t)}))},t)}))})]})})})}t.Z=function(e){var t=e.chat,n=e.isPinned,a=e.onPin,l=e.onUnpin,o=e.isNew,c=(0,i.useState)(!1),s=c[0],d=c[1],u="user"===t.role,f=(0,i.useCallback)((function(){navigator.clipboard.writeText(t.prompt||t.message||"").then((function(){d(!0),setTimeout((function(){return d(!1)}),1500)}))}),[t]);return(0,r.BX)("div",{className:"flex gap-2.5 items-end group ".concat(u?"flex-row-reverse":"flex-row"),style:o?{animation:"slideIn 0.25s cubic-bezier(0.34,1.56,0.64,1) both"}:{},children:[(0,r.tZ)("div",{className:"shrink-0 w-7 h-7 rounded-full flex items-center justify-center shadow-sm\n        ".concat(u?"bg-[#55D284] text-white":"bg-black text-[#16a34a]"),children:u?(0,r.tZ)(p.Z,{size:14}):(0,r.tZ)("img",{src:"/wiselens.png",className:"w-5"})}),(0,r.BX)("div",{className:"relative max-w-[82%] ".concat(u?"items-end":"items-start"," flex flex-col gap-1"),children:[!u&&t.responseType&&(0,r.BX)("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold\n            self
1-start ".concat(x(t.responseType)),children:[b(t.responseType),t.responseType]}),(0,r.BX)("div",{className:"relative rounded-2xl px-3.5 py-2.5 shadow-sm max-w-[450px]\n          ".concat(u?"bg-[#55D284] text-white rounded-br-sm":"bg-white border border-slate-200/80 rounded-bl-sm"),children:[u&&(0,r.tZ)("p",{className:"text-sm text-white leading-relaxed",children:t.prompt}),!u&&t.message&&(0,r.tZ)(y,{text:t.message}),(0,r.tZ)("button",{onClick:f,className:"absolute -top-2 ".concat(u?"-left-6":"-right-6","\n              opacity-0 group-hover:opacity-100 transition-opacity\n              p-1 rounded-md bg-white border border-slate-200 shadow-sm text-slate-400 hover:text-slate-700"),children:s?(0,r.tZ)(m.Z,{size:11,className:"text-emerald-500"}):(0,r.tZ)(g.Z,{size:11})})]}),!u&&t.echartsOption&&(0,r.tZ)("div",{className:"w-full",children:(0,r.tZ)(w,{option:t.echartsOption,isPinned:n,onPin:a?function(){return a(t)}:void 0,onUnpin:l?function(){return l(t)}:void 0})}),!u&&t.tableData&&(0,r.tZ)("div",{className:"w-full",children:(0,r.tZ)(N,{headers:t.tableData.headers,rows:t.tableData.rows})}),(0,r.tZ)("span",{className:"text-[9px] text-slate-400 px-1 ".concat(u?"text-right self-end":"self-start"),children:new Date(t.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]})}},3518:function(e,t,n){var r=n(26042),i=n(69396),a=n(35944),l=n(67294),o=n(18007);t.Z=function(e){var t=e.option,n=e.height,s=void 0===n?220:n,d=e.className,u=e.width,f=void 0===u?"100%":u,h=(0,l.useRef)(null),p=(0,l.useRef)(null);return(0,l.useEffect)((function(){var e,n=h.current;if(n){null===(e=p.current)||void 0===e||e.dispose(),p.current=null;var a=requestAnimationFrame((function(){h.current&&(p.current=o.S1(h.current,void 0,{renderer:"canvas"}),p.current.setOption((0,i.Z)((0,r.Z)({},t),{title:{show:!1},color:c(100)}),{notMerge:!0}))})),l=new ResizeObserver((function(){var e;return null===(e=p.current)||void 0===e?void 0:e.resize()}));return l.observe(n),function(){var e;cancelAnimationFrame(a),l.disconnect(),null===(e=p.current)||void 0===e||e.dispose(),p.current=null}}}),[JSON.stringify(t)]),(0,a.tZ)("div",{ref:h,className:d,style:{width:f,height:s}})};var c=function(e){for(var t=["#61CD93","#389764"],n=function(e,t,n){n/=100;var r=function(t){return(t+e/30)%12},i=(t/=100)*Math.min(n,1-n),a=function(e){return Math.round(255*(n-i*Math.max(-1,Math.min(r(e)-3,Math.min(9-r(e),1)))))};return"#".concat([a(0),a(8),a(4)].map((function(e){return e.toString(16).padStart(2,"0")})).join(""))},r=2;r<e;r++){var i=Math.floor(360*Math.random()),a=55+25*Math.random(),l=45+20*Math.random();t.push(n(i,a,l))}return t}},75562:function(e,t,n){n.d(t,{E:function(){return o}});var r=n(35944),i=n(67294),a=n(85155),l=n(49300);function o(e){var t=e.column,n=e.onApply,o=(0,i.useState)(!1),c=o[0],s=o[1],d=(0,i.useRef)(null);return(0,r.BX)(r.HY,{children:[(0,r.tZ)("button",{ref:d,onClick:function(e){e.stopPropagation(),e.preventDefault(),s((function(e){return!e}))},className:" p-1 rounded text-gray-500 hover:bg-gray-200 hover:text-gray-700 transition ",children:(0,r.tZ)(a.o,{size:16})}),(0,r.tZ)(l.PV,{isOpen:c,onClose:function(){return s(!1)},onApply:function(e){n(e),s(!1)},anchorEl:d.current,columnConfig:{key:t.field,label:t.headerName,type:t.type,acceptedValues:t.acceptedValues}})]})}},49300:function(e,t,n){n.d(t,{PV:function(){return g},xy:function(){return m}});var r,i,a=n(14924),l=n(26042),o=n(69396),c=n(10253),s=n(29815),d=n(35944),u=n(67294),f=n(73935),h=n(2151),p=n(46796);function m(e){var t=[];return Object.entries(e).forEach((function(e){var n=(0,c.Z)(e,2),r=n[0],l=n[1];if(l)switch(l.operator){case i.CONTAINS:var o=l.value;if(!o)return;t.push({field:r,operator:"$regex",value:o,ignore_case:!0});break;case i.EQUALS:var s=l.value;if(""===s||void 0===s)return;t.push({field:r,operator:"$eq",value:s});break;case i.NOT_EQUALS:var d=l.value;if(""===d||void 0===d)return;t.push({field:r,operator:"$ne",value:d});break;case i.GREATER_THAN:case i.GREATER_THAN_OR_EQUAL:case i.LESS_THAN:case i.LESS_THAN_OR_EQUAL:var u,f=l.value;if(null===f||void 0===f)return;var h=(u={},(0,a.Z)(u,i.GREATER_THAN,"$gt"),(0,a.Z)(u,i.GREATER_THAN_OR_EQUAL,"$gte"),(0,a.Z)(u,i.LESS_THAN,"$lt"),(0,a.Z)(u,i.LESS_THAN_OR_EQUAL,"$lte"),u);t.push({field:r,operator:h[l.operator],value:f});break;case i.DATE_RANGE:var p=l.from,m=l.to;p&&t.push({field:r,operator:"$gte",value:p}),m&&t.push({field:r,operator:"$lte",value:m});break;case i.IS_TRUE:t.push({field:r,operator:"$eq",value:!0});break;case i.IS_FALSE:t.push({field:r,operator:"$eq",value:!1});break;case i.IN:var g=l.values;if(!g||0===g.length)return;t.push({field:r,operator:"$in",value:g})}})),t}function g(e){var t=e.isOpen,n=e.onClose,r=e.anchorEl,i=e.onApply,l=e.columnConfig,o=e.initialFilters,c=(0,u.useRef)(null),s=(0,u.useState)({top:0,left:0,placement:"bottom"}),h=s[0],p=s[1],m=(0,u.useState)(!1),g=m[0],x=m[1],y=(0,u.useState)(""),Z=y[0],w=y[1],N=(0,u.useState)(!1),k=N[0],C=N[1],S=(0,u.useState)(!1),A=(S[0],S[1],(0,u.useState)((function(){return o&&o[l.key]?o[l.key]:v(l.type,l.acceptedValues)}))),E=A[0],B=A[1];(0,u.useEffect)((function(){return x(!0),function(){return x(!1)}}),[]),(0,u.useEffect)((function(){B(v(l.type,l.acceptedValues))}),[l.key]),(0,u.useLayoutEffect)((function(){if(t&&r&&c.current){var e=function(){if(c.current&&r){var e=r.getBoundingClientRect(),t=c.current.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=e.left,l=e.bottom+8;l+t.height>i&&(l=e.top-t.height-8),a+t.width>n&&(a=n-t.width-16),a<16&&(a=16),p({top:l,left:a,placement:l<e.top?"top":"bottom"})}};return requestAnimationFrame((function(){e()})),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),function(){window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}}}),[t,r]),(0,u.useEffect)((function(){if(t){var e=function(e){var t=e.target;c.current&&!c.current.contains(t)&&r&&!r.contains(t)&&n()},i=function(e){"Escape"===e.key&&n()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",i),function(){document.removeEventListener("mousedown",e),document.removeEventListener("keydown",i)}}}),[t,n,r]);return(0,u.useEffect)((function(){if(!t){var e=setTimeout((function(){return C(!1)}),150);return function(){return clearTimeout(e)}}C(!0)}),[t]),g&&t?(0,f.createPortal)((0,d.tZ)("div",{ref:c,onClick:function(e){return e.stopPropagation()},onMouseDown:function(e){return e.stopPropagation()},className:"\n    fixed z-50 w-[305px]\n    bg-white rounded-2xl shadow-xl border border-gray-200\n    transition-opacity duration-250 ease-out\n    ".concat(k?"opacity-100":"opacity-0","\n  "),style:{to
1p:"".concat(h.top,"px"),left:"".concat(h.left,"px")},children:(0,d.BX)("div",{className:"p-4",children:[(0,d.tZ)("h2",{className:"text-xl font-bold text-black mb-4",children:"Apply Filter"}),b(l,E,B,Z,w),(0,d.BX)("div",{className:"flex justify-between items-center gap-3 mt-6",children:[(0,d.tZ)("button",{onClick:function(){B(v(l.type,l.acceptedValues))},className:"px-5 py-2 text-sm font-medium text-gray-700 border border-gray-200 rounded-lg hover:bg-gray-100 transition",children:"Clear"}),(0,d.tZ)("button",{onClick:function(){var e=(0,a.Z)({},l.key,E);i(e),n()},className:"px-8 py-2 bg-black text-white font-small rounded-lg hover:bg-gray-800 transition-colors",children:"Apply"})]})]})}),document.body):null}function v(e,t){if(t&&t.length>0)return{operator:i.IN,values:[]};switch(e){case r.string:return{operator:i.EQUALS,value:""};case r.number:return{operator:i.EQUALS,value:0};case r.date:return{operator:i.DATE_RANGE,from:null,to:null};case r.boolean:return{operator:i.IS_TRUE};case r.Array:case r.file:case r.Object:default:return null}}function b(e,t,n,a,c){if(e.acceptedValues&&e.acceptedValues.length>0)return function(e,t,n,r,a){var l=(null===t||void 0===t?void 0:t.values)||[],o=e.filter((function(e){return e.toLowerCase().includes(r.toLowerCase())})),c=function(e){var t=l.includes(e)?l.filter((function(t){return t!==e})):(0,s.Z)(l).concat([e]);n({operator:i.IN,values:t})};return(0,d.BX)("div",{className:"space-y-4",children:[(0,d.BX)("div",{className:"relative",children:[(0,d.tZ)(h.Z,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400"}),(0,d.tZ)("input",{type:"text",placeholder:"Search",value:r,onChange:function(e){return a(e.target.value)},className:"w-full pl-10 pr-4 py-2.5 bg-gray-100 rounded-lg text-gray-900 placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-black"})]}),(0,d.tZ)("div",{className:"space-y-3 max-h-64 overflow-y-auto",children:0===o.length?(0,d.tZ)("p",{className:"text-gray-500 text-sm text-center py-4",children:"No values found"}):o.map((function(e){var t=l.includes(e);return(0,d.BX)("label",{className:"flex items-center gap-3 cursor-pointer group",children:[(0,d.BX)("div",{className:"relative flex items-center justify-center",children:[(0,d.tZ)("input",{type:"checkbox",checked:t,onChange:function(){return c(e)},className:"peer sr-only"}),(0,d.tZ)("div",{className:"w-6 h-6 border-2 border-black rounded bg-white peer-checked:bg-black transition-colors flex items-center justify-center",children:t&&(0,d.tZ)("svg",{className:"w-4 h-4 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:(0,d.tZ)("polyline",{points:"20 6 9 17 4 12"})})})]}),(0,d.tZ)("span",{className:"text-lg text-black",children:e})]},e)}))})]})}(e.acceptedValues,t,n,a,c);switch(e.type){case r.string:return function(e,t){return(0,d.BX)("div",{className:"space-y-4",children:[(0,d.BX)("div",{children:[(0,d.tZ)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Condition"}),(0,d.BX)("select",{value:(null===e||void 0===e?void 0:e.operator)||i.EQUALS,onChange:function(n){return t((0,o.Z)((0,l.Z)({},e),{operator:n.target.value}))},className:"w-full px-4 py-2 bg-gray-100 rounded-lg text-gray-900 focus:outline-none focus:ring-2 focus:ring-black",children:[(0,d.tZ)("option",{value:i.EQUALS,children:"Equals to"}),(0,d.tZ)("option",{value:i.NOT_EQUALS,children:"Not equals to"}),(0,d.tZ)("option",{value:i.CONTAINS,children:"Contains"})]})]}),(0,d.BX)("div",{children:[(0,d.tZ)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Value"}),(0,d.tZ)("div",{className:"relative",children:(0,d.tZ)("input",{type:"text",placeholder:"Enter value",value:(null===e||void 0===e?void 0:e.value)||"",onChange:function(n){return t((0,o.Z)((0,l.Z)({},e),{operator:(null===e||void 0===e?void 0:e.operator)||i.EQUALS,value:n.target.value}))},className:"w-full pl-4 pr-4 py-2 bg-gray-100 rounded-lg text-gray-900 placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-black"})})]})]})}(t,n);case r.number:return function(e,t){return(0,d.BX)("div",{className:"space-y-4",children:[(0,d.BX)("div",{children:[(0,d.tZ)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Condition"}),(0,d.BX)("select",{value:(null===e||void 0===e?void 0:e.operator)||i.EQUALS,onChange:function(n){return t((0,o.Z)((0,l.Z)({},e),{operator:n.target.value}))},className:"w-full px-4 py-3 bg-gray-100 rounded-lg text-gray-900 focus:outline-none focus:ring-2 focus:ring-black",children:[(0,d.tZ)("option",{value:i.EQUALS,children:"Equals to"}),(0,d.tZ)("option",{value:i.LESS_THAN,children:"Less than"}),(0,d.tZ)("option",{value:i.GREATER_THAN,children:"Greater than"}),(0,d.tZ)("option",{value:i.LESS_THAN_OR_EQUAL,children:"Less than or equal"}),(0,d.tZ)("option",{value:i.GREATER_THAN_OR_EQUAL,children:"Greater than or equal"})]})]}),(0,d.BX)("div",{children:[(0,d.tZ)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Value"}),(0,d.tZ)("input",{type:"number",placeholder:"Enter number",value:(null===e||void 0===e?void 0:e.value)||0,onChange:function(n){return t((0,o.Z)((0,l.Z)({},e),{operator:(null===e||void 0===e?void 0:e.operator)||i.EQUALS,value:Number.parseFloat(n.target.value)||0}))},className:"w-full px-4 py-3 bg-gray-100 rounded-lg text-gray-900 placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-black"})]})]})}
1(t,n);case r.date:return function(e,t){return(0,d.BX)("div",{className:"space-y-4",children:[(0,d.BX)("div",{children:[(0,d.tZ)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"From Date"}),(0,d.BX)("div",{className:"relative",children:[(0,d.tZ)(p.Z,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400"}),(0,d.tZ)("input",{type:"date",value:(null===e||void 0===e?void 0:e.from)||"",onChange:function(n){return t((0,o.Z)((0,l.Z)({},e),{operator:i.DATE_RANGE,from:n.target.value}))},className:"w-full pl-10 pr-4 py-3 bg-gray-100 rounded-lg text-gray-900 focus:outline-none focus:ring-2 focus:ring-black"})]})]}),(0,d.BX)("div",{children:[(0,d.tZ)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"To Date"}),(0,d.BX)("div",{className:"relative",children:[(0,d.tZ)(p.Z,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400"}),(0,d.tZ)("input",{type:"date",value:(null===e||void 0===e?void 0:e.to)||"",onChange:function(n){return t((0,o.Z)((0,l.Z)({},e),{operator:i.DATE_RANGE,from:(null===e||void 0===e?void 0:e.from)||null,to:n.target.value}))},className:"w-full pl-10 pr-4 py-3 bg-gray-100 rounded-lg text-gray-900 focus:outline-none focus:ring-2 focus:ring-black"})]})]})]})}(t,n);case r.boolean:return function(e,t){var n=(null===e||void 0===e?void 0:e.operator)===i.IS_TRUE;return(0,d.BX)("div",{className:"space-y-4",children:[(0,d.BX)("label",{className:"flex items-center gap-3 cursor-pointer group",children:[(0,d.BX)("div",{className:"relative",children:[(0,d.tZ)("input",{type:"radio",name:"boolean-filter",checked:n,onChange:function(){return t({operator:i.IS_TRUE})},className:"peer sr-only"}),(0,d.tZ)("div",{className:"w-6 h-6 border-2 border-black rounded-full bg-white peer-checked:bg-black transition-colors flex items-center justify-center",children:n&&(0,d.tZ)("div",{className:"w-3 h-3 bg-white rounded-full"})})]}),(0,d.tZ)("span",{className:"text-sm text-gray-900 font-medium",children:"True"})]}),(0,d.BX)("label",{className:"flex items-center gap-3 cursor-pointer group",children:[(0,d.BX)("div",{className:"relative",children:[(0,d.tZ)("input",{type:"radio",name:"boolean-filter",checked:!n,onChange:function(){return t({operator:i.IS_FALSE})},className:"peer sr-only"}),(0,d.tZ)("div",{className:"w-6 h-6 border-2 border-black rounded-full bg-white peer-checked:bg-black transition-colors flex items-center justify-center",children:!n&&(0,d.tZ)("div",{className:"w-3 h-3 bg-white rounded-full"})})]}),(0,d.tZ)("span",{className:"text-sm text-gray-900 font-medium",children:"False"})]})]})}(t,n);case r.Array:return x("Array filters coming soon...");case r.file:return x("File filters coming soon...");case r.Object:return x("Object filters coming soon...");default:return null}}function x(e){return(0,d.tZ)("div",{className:"py-8 text-center",children:(0,d.tZ)("p",{className:"text-gray-500 text-sm",children:e})})}!function(e){e.string="string",e.date="date",e.number="number",e.boolean="boolean",e.Object="Object",e.Array="Array",e.file="file"}(r||(r={})),function(e){e.EQUALS="equals",e.NOT_EQUALS="not_equals",e.LESS_THAN="less_than",e.GREATER_THAN="greater_than",e.LESS_THAN_OR_EQUAL="less_than_or_equal",e.GREATER_THAN_OR_EQUAL="greater_than_or_equal",e.CONTAINS="contains",e.DATE_RANGE="date_range",e.IS_TRUE="is_true",e.IS_FALSE="is_false",e.IN="in"}(i||(i={}))},81878:function(e,t,n){n.d(t,{LE:function(){return fe},ln:function(){return N},TX:function(){return E},Nz:function(){return ge},hz:function(){return Ze},zN:function(){return _},RH:function(){return j},VS:function(){return O},aR:function(){return Z}});var r=n(35944),i=n(67294),a=n(52044),l=n(33485),o=n(41248),c=function(e){var t=e.value,n=e.columnName,i=(0,o.v9)((function(e){return e.collection})).editingModalOpen;return t?(0,r.tZ)(l.W,{tooltipTitle:n,tooltipDescription:"Mail to:"+t,disabled:i,children:(0,r.BX)("div",{className:"flex items-center gap-2 cursor-pointer",onClick:function(e){e.stopPropagation(),window.location.href="mailto:"+t},children:[(0,r.tZ)(a.w,{size:18,color:"#FFB87E"}),(0,r.tZ)("span",{className:"text-gray-600 max-w-[150px] font-medium truncate hover:font-semibold transition-all duration-150",children:t})]})}):null},s=n(59347),d=n(3635),u=function(e){var t=e.value,n=e.columnName,i=(0,o.v9)((function(e){return e.collection})).editingModalOpen;return t?(0,r.tZ)(l.W,{tooltipTitle:n,tooltipDescription:"Open url",IconComponent:s.G,disabled:i,children:(0,r.BX)("div",{className:"flex items-center gap-2",onClick:function(e){e.stopPropagation();var n=t;t.startsWith("http://")||t.startsWith("https://")||(n="https://".concat(t)),window.open(n,"_blank")},children:[(0,r.tZ)(d.j,{size:16,color:"#219BFF"}),(0,r.tZ)("span",{className:"text-gray-600 font-medium truncate max-w-[200px] hover:text-blue-500 cursor-pointer transition-colors",children:t})]})}):null},f=n(73299),h=function(e){var t=e.value,n=e.columnName,i=(0,o.v9)((function(e){return e.collection})).editingModalOpen;return t?(0,r.tZ)(l.W,{tooltipTitle:n,tooltipDescription:t,disabled:i,children:(0,r.BX)("div",{className:"flex items-center gap-2 ",children:[(0,r.tZ)(f.$,{size:18,color:"red"}),(0,r.tZ)("span",{className:"text-gray-600 truncate max-w-[180px] overflow-hidden",children:t})]})}):null}
1,p=n(9572),m=n(51493),g=function(e){var t=e.value,n=e.onChange;if(!t)return null;var a="",l="";if("string"===typeof t){var o=t.trim().replace(/^\+/,"").replace(/\s/g,"").replace(/\D/g,"");if(o)if(o.length>10){for(var c=function(e){var t=o.substring(0,e),n=o.substring(e);if(m.J.find((function(e){return e.code===t}))&&n.length>=7&&n.length<=15)return a=t,l=n,s=!0,"break"},s=!1,d=3;d>=1;d--){if("break"===c(d))break}s||(a=o.substring(0,2),l=o.substring(2))}else a="91",l=o}i.useEffect((function(){var e="".concat(a," ").concat(l).trim(),r=t.trim().replace(/^\+/,"");n&&e!==r&&a&&l&&n(e)}),[a,l,n,t]);var u=m.J.find((function(e){return e.code===a})),f=u?u.iso:"in";return(0,r.BX)("div",{className:"flex items-center gap-2",children:[(0,r.tZ)(p.L,{size:22,className:"text-green-500"}),(0,r.BX)("span",{className:"text-[#8A8A8A] font-semibold tracking-tight text-base",children:["+",a," ",l]}),(0,r.tZ)("img",{src:"https://flagcdn.com/24x18/".concat(f,".png"),alt:f,className:"w-6 h-4 ml-2",style:{objectFit:"cover"}})]})},v=n(72576),b=function(e){var t=e.value,n=e.columnName,i=(0,o.v9)((function(e){return e.collection})).editingModalOpen;return t?(0,r.tZ)(l.W,{tooltipTitle:n,tooltipDescription:t,disabled:i,children:(0,r.BX)("div",{className:"flex items-center gap-2 truncate",children:[(0,r.tZ)(v.n,{size:16}),t]})}):null},x=n(14564),y=function(e){var t,n=e.value,a=e.isInlineEditing,l=e.inlineEditValue,o=e.updateInlineEditValue,c=e.field,s=e.columnName,d=(0,i.useState)(!1),u=d[0],f=d[1],h=(0,i.useState)(null!==(t=null!==l&&void 0!==l?l:n)&&void 0!==t?t:""),p=h[0],m=h[1],g=(0,i.useRef)(null),v=(null===n||void 0===n?void 0:n.length)>60?n.slice(0,60)+"...":n;return(0,i.useEffect)((function(){var e;m(null!==(e=null!==l&&void 0!==l?l:n)&&void 0!==e?e:"")}),[n,l,u]),(0,r.BX)(r.HY,{children:[(0,r.tZ)("span",{ref:g,className:"text-gray-600 w-[180px] block truncate overflow-hidden whitespace-nowrap cursor-pointer",onClick:function(){return f(!0)},title:n,style:{display:"inline-block"},children:v||(0,r.tZ)("span",{className:"text-gray-400",children:"(empty)"})}),(0,r.tZ)(x.ZP,{open:u,anchorEl:g.current,onClose:function(){return f(!1)},anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{overflow:"visible",padding:0,background:"transparent",boxShadow:"none"}},children:(0,r.BX)("div",{className:"bg-white border border-gray-300 rounded-lg p-4 resize overflow-auto flex flex-col",style:{minWidth:300,minHeight:200,maxWidth:"90vw",maxHeight:"80vh",resize:"both",boxShadow:"0 2px 12px rgba(0,0,0,0.15)"},children:[(0,r.tZ)("h2",{className:"font-bold mb-2",children:s||"Text"}),(0,r.tZ)("textarea",{className:"border border-gray-300 rounded px-2 py-1 w-full h-full",style:{resize:"none",flexGrow:1},value:p,onChange:function(e){return m(e.target.value)},readOnly:!a,autoFocus:!0}),a&&(0,r.tZ)("div",{className:"flex gap-2 justify-end mt-4",children:(0,r.tZ)("button",{onClick:function(){a&&o&&c&&o(c,p),f(!1)},className:"px-4 py-2 rounded text-white font-semibold ",children:"Save"})})]})})]})},Z=function(e){var t=e.value,n=e.subtype,i=e.columnName,a=e.column,l=e.isInlineEditing,o=e.inlineEditValue,s=e.updateInlineEditValue,d=e.field,f=(null===a||void 0===a?void 0:a.acceptedValues)&&a.acceptedValues.length>0;if(l&&s&&d)return f?(0,r.BX)("select",{id:"datagrid-field-".concat(d,"-row-").concat(o),name:"datagrid-field-".concat(d,"-row-").concat(o),className:"w-full border border-gray-300 rounded px-2 py-1 bg-white",value:null!==o&&void 0!==o?o:"",onChange:function(e){return s(d,e.target.value)},children:[(0,r.tZ)("option",{value:"",children:"Select a value"}),a.acceptedValues.map((function(e){return(0,r.tZ)("option",{value:e,children:e},e)}))]}):(0,r.tZ)("input",{id:"datagrid-field-".concat(d,"-row-").concat(o),name:"datagrid-field-".concat(d,"-row-").concat(o),type:"text",className:"w-full border border-gray-300 rounded px-2 py-1",value:null!==o&&void 0!==o?o:"",onChange:function(e){return s(d,e.target.value)}});var p=(0,r.tZ)("span",{className:"text-gray-600 w-[180px] block truncate overflow-hidden whitespace-nowrap",children:t});switch(n){case"email":p=(0,r.tZ)(c,{value:t,columnName:i});break;case"url":p=(0,r.tZ)(u,{value:t,columnName:i});break;case"address":p=(0,r.tZ)(h,{value:t,columnName:i});break;case"phone":p=(0,r.tZ)(g,{value:t});break;case"name":p=(0,r.tZ)(b,{value:t,columnName:i});break;case"textarea":p=(0,r.tZ)(y,{value:t,isInlineEditing:l,inlineEditValue:o,updateInlineEditValue:s,field:d,columnName:i})}return p},w=n(48119),N=function(e){var t=e.value,n=e.isInlineEditing,i=e.inlineEditValue,a=e.updateInlineEditValue,l=e.field;return n&&a&&l?(0,r.tZ)(w.r,{checked:!!i,onChange:function(e){return a(l,e)},size:"md",variant:"success"}):(0,r.tZ)(w.r,{checked:!0===t,disabled:!0,size:"md",variant:"default"})}
1,k=n(84110),C=n(82581),S=n(32912),A=n(2141),E=function(e){var t=e.value,n=e.subtype,i=e.columnName,a=(0,o.v9)((function(e){return e.collection})).editingModalOpen,c=new Date(t),s="",d=!1;switch(n){case"time":s=(0,S.default)(c,"hh:mm a"),d=!0;break;case"dd-mm-yyyy":default:s=(0,S.default)(c,"dd MMM yyyy");break;case"mm-yyyy":s=(0,S.default)(c,"MMM yyyy");break;case"yyyy":s=(0,S.default)(c,"yyyy")}var u=(0,A.Z)(c,{addSuffix:!0});return(0,r.tZ)(l.W,{tooltipTitle:i,tooltipDescription:s,disabled:a,children:(0,r.BX)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,r.BX)("div",{className:"flex items-center gap-1",children:[d?(0,r.tZ)(k.S,{size:18}):(0,r.tZ)(C.W,{size:18}),(0,r.tZ)("span",{className:"font-semibold tracking-tight",children:s})]}),!d&&(0,r.tZ)("div",{className:"flex items-center gap-1.5 tracking-tight text-[#8A8A8A] text-sm",children:u})]})})},B=n(75885),X={Rupees:"\u20b9",Dollars:"$",Euros:"\u20ac",Pounds:"\xa3"},_=function(e){var t=e.value,n=e.subtype,i=e.columnName,a=e.children,c=e.isInlineEditing,s=e.inlineEditValue,d=e.updateInlineEditValue,u=e.field,f=(0,o.v9)((function(e){return e.collection})).editingModalOpen;if(null===t||void 0===t||""===t)return null;var h="string"===typeof t?parseFloat(t):t;if(isNaN(h))return null;var p=String(h);if("currency"===n){var m,g=(null===(m=null===a||void 0===a?void 0:a.find((function(e){return"currencyname"===e.name})))||void 0===m?void 0:m.default)||"Rupees";p="".concat(X[g]||"\u20b9").concat(h.toFixed(2))}else p=String(h);return t?c&&d&&u?(0,r.tZ)("input",{id:"datagrid-field-".concat(u,"-row-").concat(s),name:"datagrid-field-".concat(u,"-row-").concat(s),type:"number",className:"w-full border border-gray-300 rounded px-2 py-1",value:null!==s&&void 0!==s?s:"",onChange:function(e){return d(u,e.target.value)}}):(0,r.tZ)(l.W,{tooltipTitle:i,tooltipDescription:p,disabled:f,children:(0,r.BX)("div",{className:"flex items-center gap-2",children:["currency"===n&&(0,r.tZ)(B.P,{size:18,fill:"green"}),(0,r.tZ)("span",{className:"text-[#8A8A8A] truncate font-semibold",children:p})]})}):null},z=n(10253),I=n(21023),D=n(15249),T=n(95318),R={src:"/_next/static/media/google-loc-logo.9f03bc14.png",height:80,width:56,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAICAYAAADaxo44AAAAw0lEQVR42mNgmPKfg6Hyw2K+ouf/jWve/nfp/LwkIP0/J8NzL/cVc+J2/eepfHPJvf3jJafm7//tJ95YxfBKT/3/hzSGhwxQ4Djp/APjZfH/Gd6VGXz9vlPsx/+TDD4z1oV6667w+WG2wvs7w/dDbPX/9zL8f7NT/n/CKv//GstD/tusDm9mAIHXe+RWl672+c+wLPS//eqQ9QxwMGMrs/yKkEdWK4OfMZxKZWUAgcS1AWwg2m51cIHxqpASENtkVQgbAL2gVWvyIolnAAAAAElFTkSuQmCC",blurWidth:6,blurHeight:8},O=function(e){var t=e.value,n=(0,i.useState)(null),a=n[0],l=n[1],o=(0,i.useRef)(null),c=null===t||void 0===t?void 0:t.latitude,s=null===t||void 0===t?void 0:t.longitude;if(!c||!s)return null;var d,u=Boolean(a),h="https://www.google.com/maps?q=".concat(c,",").concat(s);return(0,r.BX)(r.HY,{children:[(0,r.BX)("div",{ref:o,onClick:function(e){l(e.currentTarget)},className:"inline-flex  tracking-tight  items-center border border-dashed border-gray-300 rounded-lg px-4 py-1.5 bg-white text-gray-700 font-medium text-sm cursor-pointer gap-2 ".concat(u?"ring-1 ring-gray":""),children:[(0,r.tZ)(f.$,{size:18,color:"#ef4444"}),"Open In Maps",(0,r.tZ)(T.T,{size:16})]}),(0,r.tZ)(x.ZP,{open:u,anchorEl:a,onClose:function(){l(null)},anchorOrigin:{vertical:"center",horizontal:"left"},transformOrigin:{vertical:"center",horizontal:"right"},PaperProps:{className:"!rounded-xl !p-0",style:{minWidth:350,maxWidth:900}},children:(0,r.BX)("div",{className:"p-4 flex flex-col items-start",children:[(0,r.BX)("div",{className:"flex flex-row w-full items-center align-center justify-between",children:[(0,r.tZ)("p",{className:"font-bold tracking-tight text-black",children:"Location"}),(0,r.BX)("div",{className:"flex mb-2 gap-2 items-center justify-center",children:[(0,r.tZ)("img",{src:null!==(d=R.src)&&void 0!==d?d:R,alt:"Google Location",className:"w-5"}),(0,r.tZ)("button",{onClick:function(){return window.open(h,"_blank","noopener,noreferrer")},className:" border text-[#909090] font-semibold tracking-tight text-sm px-3 py-1.5 rounded-md hover:bg-gray-50 transition",children:"View in Google Maps"})]})]}),(0,r.tZ)("iframe",{width:"634",height:"637",className:"rounded-lg border-0",loading:"lazy",allowFullScreen:!0,referrerPolicy:"no-referrer-when-downgrade",src:"https://www.google.com/maps?q=".concat(c,",").concat(s,"&z=15&output=embed")})]})})]})},j=function(e){var t=e.value,n=e.subtype,i=t;if("string"===typeof t)try{var a=JSON.parse(t);i=a}catch(o){i=t}if(Array.isArray(i)&&i.length>0&&Array.isArray(i[0])&&i[0].length>0&&"object"===typeof i[0][0]&&(i=i.flat()),null==i||"object"===typeof i&&!Array.isArray(i)&&0===Object.keys(i).length||Array.isArray(i)&&0===i.length)return(0,r.tZ)("span",{className:"text-gray-400",children:"-"});if(Array.isArray(i)&&i.length>0&&Array.isArray(i[0])&&i[0].length>0&&"object"===typeof i[0][0]&&(i=i.flat()),"loc-lat-long"===n&&!Array.isArray(i))return(0,r.tZ)(O,{value:i});var l=function(e,t){return"object"!==typeof e||null===e?(0,r.tZ)("div",{className:"text-sm mb-1 break-all",children:(0,r.tZ)("span",{className:"text-[#555]",children:String(e)})}):(0,r.BX)("div",{className:void 0!==t?"mb-3 pb-3 border-b border-gray-300 last:border-b-0":"",children:[void 0!==t&&(0,r.BX)("div",{className:"font-semibold text-[#333] mb-2",children:["Item ",t+1]}),Object.entries(e).map((function(e){var t=(0,z.Z)(e,2),n=t[0],i=t[1];return(0,r.BX)("div",{className:"text-sm mb-1 break-all",children:[(0,r.tZ)("span",{className:"font-semibold text-[#333]",children:n}),(0,r.BX)("span",{className:"text-[#555]",children:[": ","object"===typeof i?JSON.stringify(i):String(i)]})]},n)}))]},t)};return(0,r.tZ)(I.Z,{title:Array.isArray(i)?(0,r.BX)("div",{children:[(0,r.BX)("div",{className:"font-semibold mb-1",children:["Array of Objects (",i.length," ",1===i.length?"item":"items",")"]}),(0,r.tZ)("div",{className:"bg-[#f6f8fa] rounded-lg p-3 text-[14px] m-0 text-[#222] max-w-[400px] max-h-[400px] overflow-y-auto whitespace-pre-wrap break-all",children:i.map((function(e,t){return l(e,t)}))})]}):(0,r.BX)("div",{children:[(0,r.tZ)("div",{className:"font-semibold mb-1",children:"Object Properties"}),(0,r.tZ)("div",{className:"bg-[#f6f8fa] rounded-lg p-3 text-[14px] m-0 text-[#222] max-w-[320px] whitespace-pre-wrap break-all",children:l(i)})]}),placement:"right",arrow:!0,children:(0,r.BX)("div",{className:"flex items-center text-[#909090] rounded-lg px-4 py-2 bg-[#E9E9E94F] font-medium text-base gap-1 select-none w-fit min-w-[90px] hover:bg-[#
1E9E9E9] hover:text-gray-600 cursor-pointer",children:[(0,r.tZ)("span",{className:"font-light",children:Array.isArray(i)?"[  ]":"{   }"}),(0,r.tZ)("span",{className:"tracking-tight text-sm mr-2",children:Array.isArray(i)?"View Array (".concat(i.length,")"):"View Object"}),(0,r.tZ)(D.Z,{size:18})]})})},L=n(11273),F=n(14924),P=n(26042),W=n(69396),M=n(29815),H=n(62770),U=n(21851),V=n(15861),q=n(22715),Y=n(54799),G=n(80822),Q=n(11057),K=n(63387),J=n(85748),$=n(63048),ee=function(e){var t=e.open,n=e.anchorEl,a=e.text,l=e.setText,o=e.onClose,c=e.onAdd,s=(0,i.useRef)(null),d=(0,i.useState)(null),u=d[0],f=d[1],h=function(){f(null)};return(0,r.tZ)(x.ZP,{open:t,anchorEl:n,onClose:o,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{"& .MuiPaper-root":{borderRadius:"8px"}},children:(0,r.BX)("div",{className:"p-4 w-[400px] flex flex-col gap-3",children:[(0,r.tZ)(V.Z,{variant:"h6",className:"text-base font-semibold text-black",children:"Add Timeline Entry"}),(0,r.tZ)(q.Z,{inputRef:s,value:a,onChange:function(e){return l(e.target.value)},multiline:!0,rows:4,fullWidth:!0,variant:"outlined",sx:{"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"transparent"},"&:hover fieldset":{borderColor:"transparent"},"&.Mui-focused fieldset":{borderColor:"transparent"},backgroundColor:"#F6F6F6",borderRadius:"8px"},"& .MuiInputBase-input":{padding:"4px"}}}),(0,r.BX)("div",{className:"flex items-center justify-between mt-2",children:[(0,r.BX)("div",{className:"flex gap-2",children:[(0,r.tZ)(Y.Z,{size:"small",onClick:function(e){f(e.currentTarget)},children:(0,r.tZ)(K.L,{size:20,color:"#606060"})}),(0,r.tZ)(x.ZP,{open:Boolean(u),anchorEl:u,onClose:h,anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"},sx:{"& .MuiPaper-root":{borderRadius:"8px"}},children:(0,r.tZ)(G.Z,{sx:{p:1},children:(0,r.tZ)($.ZP,{onEmojiClick:function(e){var t=e.emoji,n=s.current;if(n){var r=n.selectionStart||0,i=n.selectionEnd||0,o=a.slice(0,r)+t+a.slice(i);l(o),setTimeout((function(){n.focus(),n.setSelectionRange(r+t.length,r+t.length)}),0)}else l(a+t);h()},height:350,width:300})})})]}),(0,r.tZ)(Q.Z,{variant:"contained",className:"normal-case bg-black text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-gray-800",startIcon:(0,r.tZ)(J.L,{size:20,weight:"fill"}),sx:{boxShadow:"none"},onClick:c,children:"Add to Timeline"})]})]})})},te=n(51233),ne=n(69661),re=n(36599),ie=n(87413),ae=n(9601),le=n(17494),oe=n(51221),ce=n(72162),se=n(15398),de=function(e){var t=e.open,n=e.anchorEl,i=e.onClose,a=e.entries;return(0,r.tZ)(x.ZP,{open:t,anchorEl:n,onClose:i,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},sx:{"& .MuiPaper-root":{borderRadius:"8px",minWidth:350,maxWidth:400,p:0,boxShadow:"0px 4px 10px rgba(0, 0, 0, 0.1)"}},children:(0,r.BX)(G.Z,{sx:{p:3,maxHeight:400,overflowY:"auto",minHeight:120},children:[(0,r.tZ)(V.Z,{variant:"h6",className:"font-semibold text-[#414141]",sx:{fontSize:"1.1rem",textAlign:"left",mb:2},children:"User's Timeline"}),0===a.length?(0,r.tZ)(G.Z,{sx:{display:"flex",alignItems:"center",justifyContent:"center",height:120},children:(0,r.tZ)(V.Z,{variant:"body1",sx:{color:"#888",fontSize:"1.05rem",textAlign:"center"},children:"No timeline present"})}):(0,r.tZ)(re.Z,{sx:{padding:0,margin:0,"& .MuiTimelineItem-root":{minHeight:"auto","&:before":{display:"none"}},"& .MuiTimelineContent-root":{paddingLeft:"0px",paddingRight:0}},children:(0,M.Z)(a).reverse().map((function(e,t){return(0,r.BX)(ie.Z,{sx:{minHeight:"auto"},children:[(0,r.BX)(ae.Z,{children:[(0,r.tZ)(le.Z,{sx:{background:"#07C537",width:14,height:14,marginTop:"8px"}}),t<a.length-1&&(0,r.tZ)(oe.Z,{sx:{background:"#E0E0E0",width:2}})]}),(0,r.tZ)(ce.Z,{sx:{py:1,px:0,ml:1},children:(0,r.BX)(te.Z,{direction:"row",alignItems:"flex-start",spacing:1,children:[(0,r.tZ)(ne.Z,{src:e.image||void 0,alt:e.name,sx:{width:40,height:40,mt:"-4px"},children:!e.image&&(0,r.tZ)(se.Z,{})}),(0,r.BX)(G.Z,{children:[(0,r.tZ)(V.Z,{variant:"body1",sx:{fontWeight:700,color:"#222",fontSize:"1.05rem",lineHeight:1.2}
1,children:new Date(e.date).toLocaleString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0})}),e.name&&(0,r.tZ)(V.Z,{variant:"body1",sx:{color:"#222",fontWeight:600,fontSize:"1rem",mt:.2,fontStyle:"italic"},children:e.name}),e.role&&(0,r.tZ)(V.Z,{variant:"body2",sx:{color:"#888",fontSize:"0.95rem",fontStyle:"italic",mb:.2},children:e.role}),(0,r.tZ)(V.Z,{variant:"body2",sx:{color:"#444",fontSize:"1rem",mt:.2,wordBreak:"break-word"},children:e.text})]})]})})]},e.id)}))})]})})},ue=function(e){e.value;var t=e.row,n=e.column,a=e.onRowChange,l=(0,o.v9)((function(e){return e.organization.organizationData})),c=(0,o.v9)((function(e){return e.user.userData})),s=(0,i.useState)(""),d=s[0],u=s[1],f=(0,i.useState)(null),h=f[0],p=f[1],m=(0,i.useState)(!1),g=m[0],v=m[1],b=(0,i.useState)(null),x=b[0],y=b[1],Z=Boolean(h),w=n.field,N=w&&Array.isArray(t[w])?t[w].flat().filter((function(e){return e&&"object"===typeof e&&e.date})):[];return(0,r.BX)("div",{className:"flex items-center gap-1",children:[(0,r.BX)("button",{className:"flex items-center gap-2 px-4 py-2 rounded-sm bg-[#E9E9E94F] text-[#909090] font-semibold text-sm hover:bg-gray-50",onClick:function(e){p(e.currentTarget)},children:["Add Entry ",(0,r.tZ)(H.v,{size:18})]}),(0,r.tZ)("button",{className:"flex items-center gap-2 px-2 py-2 rounded-sm bg-[#E9E9E94F] text-[#909090] font-semibold text-sm hover:bg-gray-50",onClick:function(e){var r=n.field;Array.isArray(t[r])&&t[r].flat().filter((function(e){return e&&"object"===typeof e&&e.date}));y(e.currentTarget),v(!0)},children:(0,r.tZ)(U.M,{size:18,color:"#909090"})}),(0,r.tZ)(ee,{open:Z,anchorEl:h,text:d,setText:u,onClose:function(){p(null)},onAdd:function(){if(d.trim()&&a){var e={id:"".concat((null===l||void 0===l?void 0:l.workspaceName)||"system","-").concat(Date.now()),text:d.trim(),date:(new Date).toISOString(),image:(null===l||void 0===l?void 0:l.logo)||"",name:(null===c||void 0===c?void 0:c.fullName)||"system"};if(w){var n,r=Array.isArray(t[w])?t[w].flat().filter((function(e){return e&&"object"===typeof e&&e.date})):[],i=(0,M.Z)(r).concat([e]),o=(0,W.Z)((0,P.Z)({},t),(n={},(0,F.Z)(n,w,i),(0,F.Z)(n,"_id",t._id||t.id),n));a(o,!0),u(""),p(null)}else console.error("No timeline field found in row:",t)}}}),(0,r.tZ)(de,{open:g,anchorEl:x,onClose:function(){v(!1),y(null)},entries:N})]})},fe=function(e){var t=e.value,n=e.subtype,i=e.columnName,a=e.row,c=e.column,s=e.onRowChange,d=(0,o.v9)((function(e){return e.collection})).editingModalOpen;if("timeline"===n)return(0,r.tZ)(ue,{value:t,row:a,column:c,onRowChange:s});var u=t.flat().filter((function(e){return!!e&&""!==e}));if(0===u.length)return null;var f=u.slice(0,3),h=u.length-3,p=u.join(", ");return(0,r.tZ)(l.W,{tooltipTitle:i,tooltipDescription:p,disabled:d,children:(0,r.BX)("div",{className:"flex gap-2 flex-wrap",children:[f.map((function(e,t){return(0,r.BX)("span",{className:"inline-flex items-center border border-gray-200 rounded-md pl-1 pr-4 py-0.5 text-sm tracking-tighter shadow-sm text-gray-800 font-semibold gap-1",children:[(0,r.tZ)(L.V,{size:16}),e]},t)})),h>0&&(0,r.BX)("span",{className:"inline-flex items-center border border-gray-500 rounded-full px-3.5 py-0.5 text-sm bg-gray-50 text-gray-500 font-medium",children:["+",h]})]})})},he=n(47568),pe=n(97582),me=n(86501),ge=function(e){var t=e.value,n=e.acceptedValues,i=e.field,a=e.row,l=e.onRowChange,o=(e.showToast,e.placeholder),c=void 0===o?"Select...":o,s=e.disabled,d=void 0!==s&&s,u=function(){var e=(0,he.Z)((function(e){var n,r,o;return(0,pe.__generator)(this,(function(c){if((n=e.target.value)===t)return[2];try{r=(0,W.Z)((0,P.Z)({},a),(0,F.Z)({},i,n||null)),l(r,!0),o=n||"cleared",me.ZP.success("".concat(i,' updated to "').concat(o,'"'))}catch(s){me.ZP.error("Failed to update ".concat(i)),console.error("Error updating dropdown value:",s)}return[2]}))}));return function(t){return e.apply(this,arguments)}}();return(0,r.tZ)("div",{className:"relative w-full",children:(0,r.BX)("select",{id:"datagrid-field-".concat(i,"-row-").concat((null===a||void 0===a?void 0:a._id)||(null===a||void 0===a?void 0:a.id)),name:"datagrid-field-".concat(i,"-row-").concat((null===a||void 0===a?void 0:a._id)||(null===a||void 0===a?void 0:a.id)),value:t||"",onChange:u,disabled:d,className:"\n          w-full px-3 py-2 text-sm\n          border border-gray-300 rounded-md\n          bg-white text-gray-900\n          focus:outline-none focus:ring-2 focus:ring-gray-900 focus:border-transparent\n          hover:border-gray-400\n          transition-colors duration-200\n          ".concat(d?"bg-gray-100 text-gray-500 cursor-not-allowed":"cursor-pointer","\n        "),style:{minWidth:"120px"},title:"Select ".concat(i),children:[(0,r.tZ)("option",{value:"",className:"text-gray-500",children:c}),n.map((function(e){return(0,r.tZ)("option",{value:e,className:"text-gray-900 cursor-pointer hover:bg-gray-900 hover:text-white",children:e},e)}))]})})},ve=n(86315),be=n(53998),xe=["jpg","jpeg","png","gif","webp"],ye={pdf:"/datagrid/PDF.png",xls:"/datagrid/XLS.png",xlsx:"/datagrid/XLS.png",csv:"/datagrid/XLS.png",doc:"/datagrid/Word File.png",docx:"/datagrid/Word File.png",js:"/datagrid/Code File.png",jsx:"/datagrid/Code File.png",ts:"/datagrid/Code File.png",tsx:"/datagrid/Code File.png",html:"/datagrid/Code File.png",css:"/datagrid/Code File.png"},Ze=function(e){var t=e.value,n=e.openFileModals,a=e.onRowChange,c=e.row,s=e.column,d=(0,o.v9)((function(e){return e.collection})).editingModalOpen,u=(0,i.useRef)(null),f=function(){var e=(0,he.Z)((function(e){var t,n,r,i,l,o,d,f,h,p,m,g,v,b,x,y,Z;return(0,pe.__generator)(this,(function(w){switch(w.label){case 0:if(!a||!c||!s)return[2];if(t=Array.from(e.target.files||[]),n=s.field,(r=Array.isArray(c[n])?c[n]:[]).length+t.length>10)return me.ZP.error("You can upload a maximum of 10 files."),u.current&&(u.current.value=""),[2];i=[],l=!0,o=!1,d=void 0,w.label=1;case 1:w.trys.push([1,8,9,10]),f=t[Symbol.iterator](),w.label=2;case 2:if(l=(h=f.next()).done)return[3,7];if((p=h.value).size>5242880)return me.ZP.error("Try to upload less than 5MB"),[3,6];w.label=3;case 3:return w.trys.push([3,5,,6]),(m=new FormData).append("file",p),[4,be.ZP.post("/file",m)];case 4:return g=w.sent(),i.push([g.data.webUrl]),[3,6];case 5:return v=w.sent(),me.ZP.error((null===(b=v.response)||void 0===b||null===(x=b.data)||void 0===x?void 0:x.message)||v.message||"Failed..."),[3,6];case 6:return l=!0,[3,2];case 7:return[3,10];case 8:return y=w.sent(),o=!0,d=y,[3,10];case 9:try{l||null==f.return||f.return()}finally{if(o)throw d}
1return[7];case 10:return i.length>0&&(Z=(0,W.Z)((0,P.Z)({},c),(0,F.Z)({},n,(0,M.Z)(r).concat((0,M.Z)(i)))),a(Z,!0)),u.current&&(u.current.value=""),[2]}}))}));return function(t){return e.apply(this,arguments)}}();if(!t||0===t.length)return(0,r.BX)(r.HY,{children:[(0,r.tZ)("input",{type:"file",multiple:!0,ref:u,style:{display:"none"},onChange:function(e){console.log("File input changed",e.target.files),f(e)}}),(0,r.BX)("button",{className:"flex items-center border-2 border-dotted hover:bg-slate-800 transition-all duration-200 hover:border-0 border-gray-500 rounded-md px-6 py-1 bg-gray-100 text-gray-500 font-semibold text-base cursor-pointer gap-2",tabIndex:-1,type:"button",onClick:function(){console.log("Upload button clicked",{onRowChange:a,fileInputRef:!!u.current}),u.current&&(u.current.click(),console.log("File input triggered"))},children:[(0,r.tZ)(ve.$,{size:18,weight:"bold",color:"#909090"}),(0,r.tZ)("span",{className:"text-nowrap tracking-tighter text-[#909090]",children:"Upload Files"})]})]});var h=t.slice(0,3),p=t.length-3;return(0,r.tZ)(l.W,{tooltipDescription:"View Files",disabled:d,children:(0,r.BX)("div",{className:"relative cursor-pointer",style:{width:1===h.length?55:180,height:55},onClick:function(){return n(t)},children:[h.map((function(e,t){var n,i=e[1]||e[0],a=(null===(n=null===i||void 0===i?void 0:i.split(".").pop())||void 0===n?void 0:n.toLowerCase())||"",l=xe.includes(a),o=l?i:ye[a]||"/datagrid/File.png",c={zIndex:10+t,left:1===h.length?0:40*t,top:1===h.length?-1:0===t?0:1===t?-10:5,transform:1===h.length?"none":0===t?"rotate(-15deg) scale(0.97)":1===t?"rotate(5deg) scale(1.03)":"rotate(-8deg) scale(0.95)",position:"absolute",transition:"all 0.3s ease-out",boxShadow:1===t?"0 2px 8px rgba(0,0,0,0.10)":"0 1px 4px rgba(0,0,0,0.07)"};return(0,r.tZ)("img",{src:o,alt:l?"preview":a.toUpperCase()+" file",className:"w-[55px] h-[55px] object-cover rounded border border-gray-200 shadow-md ".concat(l?"":"bg-white p-2"),style:c},i+t)})),p>0&&(0,r.BX)("span",{className:"text-xs absolute right-4 top-[50%] items-end text-gray-500 p-1 rounded-sm bg-gray-100",children:["+",p]})]})})}},88669:function(e,t,n){n.d(t,{d:function(){return f}});var r=n(47568),i=n(26042),a=n(99534),l=n(29815),o=n(97582),c=n(67294),s=n(41248),d=n(53522),u=n(11163);var f=function(e){var t=(0,u.useRouter)(),n=(0,s.I0)(),f=e||t.query.id,h=(0,c.useState)("createdAt"),p=h[0],m=h[1],g=(0,c.useState)(-1),v=g[0],b=g[1],x=(0,c.useState)(30),y=x[0],Z=x[1],w=(0,c.useState)(0),N=w[0],k=w[1],C=(0,c.useState)([]),S=C[0],A=C[1],E=(0,c.useState)({}),B=E[0],X=E[1],_=(0,c.useState)(0),z=_[0],I=_[1],D=(0,c.useState)(""),T=D[0],R=D[1],O=(0,c.useState)(!1),j=O[0],L=O[1],F=(0,c.useState)(!1),P=F[0],W=F[1],M=(0,c.useState)(""),H=M[0],U=M[1],V=(0,c.useState)([]),q=V[0],Y=V[1],G=(0,c.useState)(""),Q=G[0],K=G[1],J=(0,c.useState)(!1),$=J[0],ee=J[1],te=(0,c.useMemo)((function(){return S.map((function(e){return Object.keys(e).reduce((function(t,n){return Array.isArray(e[n])?t[n]=e[n]:"object"===typeof e[n]&&null!==e[n]?t[n]=JSON.stringify(e[n]):t[n]=e[n],t}),{})}))}),[S]),ne=function(){var e=(0,r.Z)((function(){var e,t;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return f?[4,n((0,d.m0)(f))]:[2,null];case 1:return"fulfilled"===(null===(t=r.sent())||void 0===t||null===(e=t.meta)||void 0===e?void 0:e.requestStatus)?(X(t.payload),m(t.payload.sortBy),b(t.payload.sortOrder),[2,t.payload]):[2,B]}}))}));return function(){return e.apply(this,arguments)}}(),re=function(){var e=(0,r.Z)((function(e){var t,r,i,a,l,c,s,u,h,p,m,g,v;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t=e.limit,r=void 0===t?y:t,i=e.ski
1p,a=void 0===i?0:i,l=e.query,c=void 0===l?"":l,s=e.filters,u=void 0===s?q:s,h=e.sortBy,p=e.sortOrder,f?[4,n((0,d.pv)({id:f,limit:r,skip:a,query:c,filters:u,sortBy:h,sortOrder:p}))]:[2,null];case 1:return(m=o.sent()).payload?(g=(null===(b=B)||void 0===b?void 0:b.schema)||{},v=function(e,t){return e.map((function(e){var n={};for(var r in e)if("createdAt"!==r&&"updatedAt"!==r){var i=null===t||void 0===t?void 0:t[r];if(i)switch(i.type){case"String":n[r]=String(e[r]);break;case"Number":n[r]=Number(e[r]);break;case"Boolean":n[r]="true"===e[r];break;case"Date":n[r]=new Date(e[r]).toLocaleString();break;default:n[r]=e[r]}else n[r]=e[r]}else n[r]=new Date(e[r]).toLocaleString();return n}))}(m.payload.data,g),[2,{finalData:v,count:m.payload.count}]):[2,null]}var b}))}));return function(t){return e.apply(this,arguments)}}(),ie=function(){var e=(0,r.Z)((function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:if(!f)return[2,[]];t.label=1;case 1:return t.trys.push([1,3,,4]),console.log("Fetching all data for export..."),[4,re({limit:1/0,skip:0})];case 2:return[2,(t.sent()||{}).finalData||[]];case 3:throw e=t.sent(),console.error("Error in fetchAllData:",e),e;case 4:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}(),ae=function(){var e=(0,r.Z)((function(){var e,t,n,r=arguments;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return e=r.length>0&&void 0!==r[0]?r[0]:y,r.length>1&&void 0!==r[1]?r[1]:N*y,t=r.length>2&&void 0!==r[2]?r[2]:Q,n=r.length>3&&void 0!==r[3]?r[3]:q,[4,le(e,t,p,v,!0,n)];case 1:return i.sent(),[2]}}))}));return function(){return e.apply(this,arguments)}}(),le=function(){var e=(0,r.Z)((function(){var e,t,n,r,i,a,c,s,d=arguments;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return e=d.length>0&&void 0!==d[0]?d[0]:y,t=d.length>1&&void 0!==d[1]?d[1]:Q,n=d.length>2&&void 0!==d[2]?d[2]:p,r=d.length>3&&void 0!==d[3]?d[3]:v,i=d.length>4&&void 0!==d[4]&&d[4],a=d.length>5&&void 0!==d[5]?d[5]:q,f?!i&&S.length>=z?[2]:(c=i?0:S.length,[4,re({limit:e,skip:c,query:t,filters:a,sortBy:n,sortOrder:r})]):[2];case 1:return(s=o.sent())&&(I(s.count),A(i?s.finalData:function(e){return(0,l.Z)(e).concat((0,l.Z)(s.finalData))})),[2]}}))}));return function(){return e.apply(this,arguments)}}(),oe=function(){A([]),I(0)},ce=((0,c.useCallback)((function(e){oe(),le(y,e,p,v,!0,q)}),[y,p,v,q]),function(){var e=(0,r.Z)((function(e){return(0,o.__generator)(this,(function(t){return Y(e),oe(),[2]}))}));return function(t){return e.apply(this,arguments)}}()),se=function(){var e=(0,r.Z)((function(e){var t,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:t=e.collection_id,r=e.entry_id,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n((0,d.pO)({collection_id:t,entry_id:r})).then((function(){A((function(e){return e.filter((function(e){return e._id!==r}))}))}))];case 2:return i.sent(),W(!1),U(""),[3,4];case 3:throw i.sent(),Error;case 4:return[2]}}
1))}));return function(t){return e.apply(this,arguments)}}();(0,c.useEffect)((function(){if(f){var e=function(){var e=(0,r.Z)((function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,ne()];case 1:return(e=t.sent())&&ee(!0),ae(30,0,"",(null===e||void 0===e?void 0:e.columnFilters)||[]),[2]}}))}));return function(){return e.apply(this,arguments)}}();e()}}),[f]),(0,c.useEffect)((function(){f&&$&&le(y,Q,p,v,!0,q)}),[f,Q,q,p,v]);var de=(0,s.v9)((function(e){return e.collection.socketEvent})),ue=(0,c.useState)(!1),fe=ue[0],he=ue[1];(0,c.useEffect)((function(){if(de&&f&&de.collection_id===f){n((0,d.IT)(null));var e=de.action,t=de.affectedData;if(de.reload)he(!0);else if(t)switch(e){case"create":t._id&&(A((function(e){return e.some((function(e){return e._id===t._id}))?e:[t].concat((0,l.Z)(e))})),I((function(e){return e+1})));break;case"update":if(t._id)A((function(e){return e.map((function(e){return e._id===t._id?(0,i.Z)({},e,t):e}))}));else if(t.ids){var r=new Set(t.ids),o=(t.ids,t.modifiedCount,(0,a.Z)(t,["ids","modifiedCount"]));A((function(e){return e.map((function(e){return r.has(e._id)?(0,i.Z)({},e,o):e}))}))}break;case"delete":if(t.ids){var c=new Set(t.ids);A((function(e){return e.filter((function(e){return!c.has(e._id)}))})),I((function(e){return Math.max(0,e-t.ids.length)}))}else t._id&&(A((function(e){return e.filter((function(e){return e._id!==t._id}))})),I((function(e){return Math.max(0,e-1)})));break;case"meta_update":he(!0)}}}),[de,f]);var pe=function(){var e=(0,r.Z)((function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return he(!1),[4,ne()];case 1:return e.sent(),le(y,Q,p,v,!0,q),[2]}}))}));return function(){return e.apply(this,arguments)}}(),me=function(){var e=(0,r.Z)((function(e,t){var r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:if(!t)return console.log("No commit flag, returning early"),[2];if(!(r=e[0])||!r._id)return console.log("No valid row found for update"),[2];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n((0,d.If)({collection_id:f,rowId:r._id,data:r}))];case 2:return a.sent(),A((function(e){return e.map((function(e){return e._id===r._id?r:e}))})),[3,4];case 3:return i=a.sent(),console.error("Failed to update row:",i),[3,4];case 4:return[2]}}
1))}));return function(t,n){return e.apply(this,arguments)}}();return{pageSize:y,setPageSize:Z,page:N,setPage:k,collectionData:S,handleSetCollectionData:A,collectionMetaData:B,totalRows:z,fetchData:ae,fetchAllData:ie,editId:T,setEditId:R,show:j,setShow:L,deleteDialogOpen:P,setDeleteDialogOpen:W,selectedWebhookId:H,setSelectedWebhookId:U,webhookListDataFiltered:te,handleDeleteEntry:se,handleEdit:function(e){R(e)},handleDeleteDialog:function(e){U(e),W(!0)},searchQuery:Q,handleSearch:K,handleRowsChange:function(e,t){return me(e,t)},fetchMore:le,setSortBy:m,setSortOrder:b,applyColumnFilters:ce,sortBy:p,sortOrder:v,stale:fe,handleReload:pe}}},80187:function(e,t,n){var r=n(35944),i=(n(67294),n(80822)),a=n(11057),l=n(64666),o=n(15861),c=n(6514),s=n(31425),d=n(37645),u=["jpg","jpeg","png","gif","webp"],f={pdf:"/datagrid/PDF.png",xls:"/datagrid/XLS.png",xlsx:"/datagrid/XLS.png",csv:"/datagrid/XLS.png",doc:"/datagrid/Word File.png",docx:"/datagrid/Word File.png",js:"/datagrid/Code File.png",jsx:"/datagrid/Code File.png",ts:"/datagrid/Code File.png",tsx:"/datagrid/Code File.png",html:"/datagrid/Code File.png",css:"/datagrid/Code File.png"};t.Z=function(e){var t=e.open,n=e.modalData,h=e.handleViewModalData,p=e.onClose;return(0,r.BX)(l.Z,{fullWidth:!0,open:t,onClose:p,maxWidth:"md",sx:{"& .MuiPaper-root":{width:"100%",maxWidth:700}},children:[(0,r.tZ)(d.Z,{children:"Files"}),(0,r.tZ)(c.Z,{sx:{overflowY:"auto",maxHeight:"60vh"},children:(0,r.tZ)(i.Z,{display:"flex",flexWrap:"wrap",gap:3,justifyContent:"flex-start",children:n.length>0?n.map((function(e,t){var n,a=e[0],l=(null===(n=null===a||void 0===a?void 0:a.split(".").pop())||void 0===n?void 0:n.toLowerCase())||"",c=u.includes(l),s=c?a:f[l]||"/datagrid/File.png",d=function(e){try{var t=e.split("/").pop();return t?decodeURIComponent(t):e}catch(n){return e}}(a);return(0,r.BX)(i.Z,{width:120,textAlign:"center",sx:{cursor:"pointer"},onClick:function(){return h(a,l)},children:[(0,r.tZ)("img",{src:s,alt:c?"preview":l.toUpperCase()+" file",style:{width:c?80:60,height:c?80:60,objectFit:c?"cover":"contain",borderRadius:c?8:0,background:c?"#f5f5f5":"transparent",margin:c?void 0:"10px auto",display:"block"}}),(0,r.tZ)(o.Z,{variant:"body2",sx:{mt:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:d,children:d})]},t)})):(0,r.tZ)(o.Z,{children:"No files available."})})}),(0,r.tZ)(s.Z,{children:(0,r.tZ)(a.Z,{onClick:p,color:"primary",children:"Close"})})]})}},81407:function(e,t,n){n.d(t,{Z:function(){return Le}});var r=n(47568),i=n(99534),a=n(10253),l=n(29815),o=n(97582),c=n(35944),s=n(67294),d=n(80822),u=n(11057),f=n(15861),h=n(41248),p=n(53522),m=n(14924),g=n(26042),v=n(69396),b=n(84105),x=n(57460),y=n.n(x),Z=n(64666),w=n(37645),N=n(6514),k=n(62482),C=n(63931),S=n(31425),A=n(42462),E=n(86501);function B(e){var t=e.collectionMeta,n=e.fetchData,i=e.buttonText,d=void 0===i?"Import From Excel":i,f=e.buttonIcon,x=void 0===f?(0,c.tZ)(A.Q,{}):f,B=e.triggerUpload,X=void 0!==B&&B,_=e.onUploadComplete,z=(0,s.useState)([]),I=z[0],D=z[1],T=(0,s.useState)([]),R=T[0],O=T[1],j=(0,s.useState)({}),L=j[0],F=j[1],P=(0,s.useState)(!1),W=P[0],M=P[1],H=(0,s.useState)(!1),U=H[0],V=H[1],q=(0,s.useRef)(null),Y=(0,h.I0)();(0,s.useEffect)((function(){X&&q.current&&(q.current.click(),_&&_())}),[X,_]);var G=function(e){return Object.values(e).some((function(e){return""!==e}))};s.useEffect((function(){if(0!==R.length){var e,n=null!==(e=null===t||void 0===t?void 0:t.schema)&&void 0!==e?e:{},r={};R.forEach((function(e){var t=Object.keys(n).find((function(t){return t.toLowerCase()===e.toLowerCase()}));t&&(r[t]=e)})),F(r)}}),[R,t]);var Q,K=function(){var e=(0,r.Z)((function(){var e,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:e=[],I.map((function(t){var n={};Object.keys(L).forEach((function(e){void 0!==t[L[e]]&&(n[e]=t[L[e]])})),Object.keys(n).length>0&&e.push(n)})),a.label=1;case 1:return a.trys.push([1,7,8,9]),V(!0),"function"!==typeof(null===(r=Y((0,p.sj)({collection_id:t._id,data:e})))||void 0===r?void 0:r.unwrap)?[3,3]:[4,r.unwrap()];case 2:return a.sent(),[3,5];case 3:return[4,r];case 4:a.sent(),a.label=5;case 5:return E.ZP.success("Data imported successfully"),[4,Promise.resolve(n())];case 6:return a.sent(),M(!1),[3,9];case 7:return i=a.sent(),console.error(i),E.ZP.error("Failed to import data"),[3,9];case 8:return V(!1),[7];case 9:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}(),J=function(){M(!1)},$=null!==(Q=null===t||void 0===t?void 0:t.schema)&&void 0!==Q?Q:{};return(0,c.BX)("div",{style:{display:void 0!==X?"none":"block"},children:[(0,c.tZ)("input",{type:"file",accept:".csv, .xls, .xlsx",style:{display:"none"},ref:q,onChange:function(e){if(e.target.files){var t,n=e.target.files,r=n[0],i=null===(t=r.name.split(".").pop())||void 0===t?void 0:t.toLowerCase();if("csv"===i)o=n,y().parse(o[0],{header:!0,skipEmptyLines:!0,complete:function(e){var t=e.data.filter(G).map((function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=(0,a.Z)(e,2),n=t[0],r=t[1];return""!==n&&""!==r})))}));D(t);var n=(0,l.Z)(new Set(e.data.flatMap(Object.keys))).filter((function(e){return""!==e})).map((function(e){return e.replace(/\./g,"_")}));O(n)}});else{if(!["xls","xlsx"].includes(i||""))return void alert("Please upload a valid CSV or XLSX file.");!function(e){if(e){var t=new FileReader;t.onload=function(e){var t=new Uint8Array(e.target.result),n=b.read(t,{type:"array"}),r=n.SheetNames[0],i=n.Sheets[r],o=b.utils.sheet_to_json(i,{header:1}),c=o[0],s=o.slice(1).map((function(e){var t={};return c.forEach((function(n,r){t[n]=e[r]})),t})),d=s.filter(G).map((function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=(0,a.Z)(e,2),n=t[0],r=t[1];return""!==n&&""!==r})))}));D(d);var u=(0,l.Z)(new Set(s.flatMap(Object.keys))).filter((function(e){return""!==e})).map((function(e){return e.replace(/\./g,"_")}));O(u)},t.readAsArrayBuffer(e)}}(r)}M(!0)}var o;e.target.value=""}}),(0,c.tZ)(u.Z,{sx:{textTransform:"none"},startIcon:x,variant:"contained",onClick:function(){var e;q.current&&(null===(e=q.current)||void 0===e||e.click())},children:d}),(0,c.BX)(Z.Z,{open:W,fullWidth:!0,onClose:J,children:[(0,c.tZ)(w.Z,{children:"Map Fields"}),(0,c.tZ)(N.Z,{children:(0,c.tZ)("div",{className:"w-full max-h-[18rem] overflow-scroll",children:Object.keys($).map((function(e){return(0,c.BX)("div",{className:"mb-4 w-full grid items-center ",children:[(0,c.tZ)("p",{children:e}),(0,c.tZ)(k.Z,{size:"small",value:L[e]||"",onChange:function(t){return function(e,t){F((function(n){return(0,v.Z)((0,g.Z)({},n),(0,m.Z)({},e,t))}))}(e,t.target.value)},children:R.map((function(e){return(0,c.tZ)(C.Z,{value:e,children:e},e)}))})]},e)}))})}),(0,c.BX)(S.Z,{children:[(0,c.tZ)(u.Z,{onClick:J,disabled:U,children:"Cancel"}),(0,c.tZ)(u.Z,{onClick:K,variant:"contained",disabled:U,children:U?"Importing...":"Save"})]})]})]})}var X=n(39006),_=n(9834),z=n(49278),I=n(25478),D=n(62770),T=n(87668),R=n(48584),O=n(7924),j=n(84935),L=n(21023),F=n(72852),P=n(54799),W=n(70010),M=n(64228),H=n(86948),U=n(94054),V=n(47312),q=n(22715),Y=n(64460),G=n(7227),Q=n(11163),K=n(36976),J=function(e){var t=e.collectionMeta,n=e.open,i=e.onClose,a=e.automation,d=(0,s.useState)(""),p=(d[0],d[1]),m=(0,s.useState)(""),g=m[0],v=m[1],b=(0,s.useState)([]),x=b[0],y=b[1],w=(0,s.useState)(""),A=w[0],B=w[1],X=(0,s.useState)({}),_=X[0],z=X[1],I=(0,h.v9)((function(e){return e.triggers})).list;(0,s.useEffect)((function(){if(t.schema)try{var e=t.schema;z(e)}catch(n){console.error("Error parsing collection string:",n)}}),[t]);var T=function(e,t,n){var r=JSON.parse(JSON.stringify((0,l.Z)(x)));r[e][t]=n,"field"===t&&(r[e].value=""),y(r)},R=(0,Q.useRouter)(),O=(0,h.I0)(),j=function(){var e=(0,r.Z)((function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return(null===a||void 0===a?void 0:a._id)?(e={_id:a._id,collectionId:R.query.id,operation:g,filters:x,trigger:A,active:!0},[4,O((0,G.P6)(e))]):[3,2];case 1:return n.sent(),E.ZP.success("Automation updated successfully"),O((0,G.Ys)({collectionId:R.query.id})),[3,3];case 2:t={collectionId:R.query.id,operation:g,filters:x,trigger:A,active:!0},O((0,G.To)(t)),E.ZP.success("Automation created successfully"),O((0,G.Ys)({collectionId:R.query.id})),n.label=3;case 3:return L(),[2]}}))}));return function(){return e.apply(this,arguments)}}(),L=function(){p(""),v(""),y([{field:"",value:""}]),B(""),i()};return(0,s.useEffect)((function(){if(null===a||void 0===a?void 0:a._id){var e,t;v(a.operation),y(a.filters);var n="string"===typeof a.trigger?a.trigger:null!==(t=null===(e=a.trigger)||void 0===e?void 0:e._id)&&void 0!==t?t:"";B(n)}}),[a]),(0,s.useEffect)((function(){O((0,K.DJ)({limit:100,skip:0,type:K.uS.WEBHOOK}))}),[O]),0===Object.keys(_).length?null:(0,c.BX)(Z.Z,{fullWidth:!0,open:n,onClose:i,sx:{"& .MuiPaper-root":{width:"100%",maxWidth:"70vw"}},children:[(0,c.BX)(N.Z,{children:[(0,c.tZ)(f.Z,{variant:"h6",className:"text-xl font-bold mb-4",children:"Create Automation"}),(0,c.BX)("div",{className:"w-full flex min-h-[60vh] mt-6",children:[(0,c.BX)("div",{className:"flex relative w-[calc(50%-0.5px)] items-center px-4 h-fit flex-col",children:[(0,c.tZ)("div",{className:"w-[1px] bg-[#BCBCBC6E] h-full absolute translate-x-1/2"}),(0,c.BX)("div",{className:"w-full mb-4 bg-white z-30 border-[#
1EBEDED] border-2 rounded-md p-2 grid grid-cols-2 justify-between items-center",children:[(0,c.BX)("div",{children:[(0,c.tZ)(f.Z,{variant:"subtitle1",className:"text-lg font-bold",children:"When"}),(0,c.tZ)(f.Z,{variant:"body2",className:"text-base font-medium",children:"This happens on..."})]}),(0,c.BX)(U.Z,{fullWidth:!0,size:"small",children:[(0,c.tZ)(V.Z,{id:"operation-label",children:"Operation"}),(0,c.tZ)(k.Z,{labelId:"operation-label",value:g,onChange:function(e){return v(e.target.value)},label:"Operation",children:Object.values(G.v_).map((function(e){return(0,c.tZ)(C.Z,{value:e,children:e.toUpperCase()},e)}))})]})]}),x.map((function(e,t){var n,r,i;return(0,c.BX)("div",{className:"w-full mb-4 bg-white z-30 border-[#EBEDED] border-2 rounded-md p-2 flex flex-col gap-2",children:[(0,c.BX)("div",{className:"grid grid-cols-2 items-center w-full gap-2",children:[(0,c.tZ)(f.Z,{children:"Field"}),(0,c.tZ)(U.Z,{fullWidth:!0,size:"small",children:(0,c.tZ)(k.Z,{value:e.field,onChange:function(e){return T(t,"field",e.target.value)},displayEmpty:!0,children:Object.keys(_).map((function(e){return(0,c.tZ)(C.Z,{value:e,children:e},e)}))})})]}),(0,c.BX)("div",{className:"grid grid-cols-2 items-center w-full gap-2",children:[(0,c.tZ)(f.Z,{children:"Is equal to"}),e.field&&(null===(n=_[e.field])||void 0===n||null===(r=n.acceptedValues)||void 0===r?void 0:r.length)?(0,c.tZ)(U.Z,{fullWidth:!0,size:"small",children:(0,c.tZ)(k.Z,{value:e.value,onChange:function(e){return T(t,"value",e.target.value)},displayEmpty:!0,children:null===(i=_[e.field].acceptedValues)||void 0===i?void 0:i.map((function(e){return(0,c.tZ)(C.Z,{value:e,children:e},e)}))})}):(0,c.tZ)(q.Z,{size:"small",variant:"outlined",fullWidth:!0,value:e.value,onChange:function(e){return T(t,"value",e.target.value)},placeholder:"Enter value"})]}),(0,c.tZ)(u.Z,{variant:"outlined",color:"error",size:"small",onClick:function(){return function(e){var t=JSON.parse(JSON.stringify((0,l.Z)(x)));t.splice(e,1),y(t)}(t)},className:"mt-2",children:"Remove Filter"})]},t)})),(0,c.tZ)("div",{className:"bg-white z-30 border-[#16C542] border-2 rounded-md p-1 flex justify-between items-center mt-4 cursor-pointer",onClick:function(){y((0,l.Z)(x).concat([{field:"",value:""}]))},children:(0,c.tZ)(D.v,{size:20,color:"#16C542"})})]}),(0,c.tZ)("div",{className:"w-[1px] bg-[#BCBCBC6E] relative",children:(0,c.tZ)("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2",children:(0,c.tZ)("div",{className:"w-6 h-6 p-1 bg-[#F3F3F3] rounded-sm flex items-center justify-center",children:(0,c.tZ)(Y.o,{size:24,color:"#000"})})})}),(0,c.tZ)("div",{className:"flex w-[calc(50%-0.5px)] px-4",children:(0,c.BX)("div",{className:"w-full mb-4 bg-white z-30 border-[#EBEDED] border-2 rounded-md p-2 grid grid-cols-2 justify-between items-center h-fit",children:[(0,c.BX)("div",{children:[(0,c.tZ)(f.Z,{variant:"subtitle1",className:"text-lg font-bold",children:"Then"}),(0,c.tZ)(f.Z,{variant:"body2",className:"text-base font-medium",children:"Trigger this trigger"})]}),(0,c.BX)(U.Z,{fullWidth:!0,size:"small",children:[(0,c.tZ)(V.Z,{id:"operation-label",children:"Trigger"}),(0,c.tZ)(k.Z,{labelId:"operation-label",value:A,onChange:function(e){return B(e.target.value)},label:"Operation",children:I.map((function(e){return(0,c.tZ)(C.Z,{value:e._id,children:e.name},e._id)}))})]})]})})]})]}),(0,c.BX)(S.Z,{children:[(0,c.tZ)(u.Z,{onClick:L,color:"secondary",children:"Cancel"}),(0,c.tZ)(u.Z,{onClick:j,color:"primary",variant:"contained",disabled:!g||""===A,children:"Save Automation"})]})]})};function $(e){var t=e.open,n=e.onClose,r=e.collectionMeta,i=(0,s.useState)(!1),a=i[0],l=i[1],o=(0,s.useState)(void 0),d=o[0],f=o[1],p=(0,h.v9)((function(e){return e.automations})).automations,m=(0,h.v9)((function(e){return e.triggers})).list,g=(0,Q.useRouter)(),v=(0,h.I0)();(0,s.useEffect)((function(){t&&v((0,K.DJ)({limit:100,skip:0,type:K.uS.WEBHOOK}))}),[t,v]);var b=function(e){var t,n;if("object"===typeof e.trigger&&(null===(t=e.trigger)||void 0===t?void 0:t.name))return e.trigger.name;var r,i="string"===typeof e.trigger?e.trigger:null===(n=e.trigger)||void 0===n?void 0:n._id,a=m.find((function(e){return e._id===i}));return null!==(r=null===a||void 0===a?void 0:a.name)&&void 0!==r?r:""};return(0,c.tZ)(c.HY,{children:(0,c.BX)(Z.Z,{fullWidth:!0,open:t,onClose:n,sx:{"& .MuiPaper-root":{width:"100%",maxWidth:700}},children:[(0,c.BX)(N.Z,{children:[(0,c.BX)("div",{className:"p-2",children:[(0,c.tZ)("p",{className:"text-xl text-black font-bold",children:"Automations"}),(0,c.BX)("p",{className:"flex gap-2 py-2 items-center",children:[(0,c.tZ)(W.k,{className:"text-blue-500"}),"Manage automations for this collection"]})]}),(0,c.tZ)("div",{className:"min-h-[60vh] overflow-y-auto",children:p.length>0?p.map((function(e,t){return(0,c.BX)("div",{className:"p-4 border-b border-gray-200 flex items-center justify-between hover:bg-gray-50 transition-colors",children:[(0,c.tZ)("div",{className:"flex-grow",children:(0,c.BX)("div",{children:[(0,c.BX)("p",{className:"text-lg font-semibold line-clamp-1",children:["Automation #",t+1
1]}),(0,c.BX)("p",{className:"font-semibold line-clamp-1",children:["When operation ",(0,c.tZ)("span",{className:"capitalize",children:e.operation})," ",(0,c.BX)("span",{children:["& ",e.filters.map((function(e){return e.field+" is equal to "+e.value})).join(" & ")]})]}),(0,c.BX)("p",{className:"text-sm",children:["Then ",(0,c.tZ)("span",{className:"font-bold cursor-pointer",onClick:function(t){return g.push("/triggers/edit/"+function(e){var t;return"object"===typeof e.trigger&&(null===(t=e.trigger)||void 0===t?void 0:t._id)?e.trigger._id:"string"===typeof e.trigger?e.trigger:""}(e))},children:b(e)})," this trigger"]})]})}),(0,c.BX)("div",{className:"flex items-center space-x-2",children:[(0,c.tZ)(L.Z,{title:"Toggle Automation",children:(0,c.tZ)(F.Z,{checked:e.active,onChange:function(t){return n=e._id,i=t.target.checked,v((0,G.x2)({_id:n,status:i,collectionId:r._id})),void E.ZP.success("Automation ".concat(i?"enabled":"disabled"," successfully"));var n,i},color:"primary"})}),(0,c.tZ)(L.Z,{title:"Edit Automation",children:(0,c.tZ)(P.Z,{onClick:function(){return function(e){f(e),l(!0)}(e)},size:"small",color:"primary",children:(0,c.tZ)(M.z,{})})}),(0,c.tZ)(L.Z,{title:"Delete Automation",children:(0,c.tZ)(P.Z,{onClick:function(){return t=e._id,v((0,G.SC)({_id:t,collectionId:r._id})),void E.ZP.success("Automation deleted successfully");var t},size:"small",color:"error",children:(0,c.tZ)(H.r,{})})})]})]},e._id)})):(0,c.tZ)("p",{className:"text-center text-gray-500 p-4",children:"No automations found for this collection"})}),(0,c.tZ)(J,{open:a,onClose:function(){l(!1),f(void 0)},collectionMeta:r,automation:d})]}),(0,c.BX)(S.Z,{children:[(0,c.tZ)(u.Z,{onClick:n,color:"primary",variant:"outlined",children:"Cancel"}),(0,c.tZ)(u.Z,{color:"primary",variant:"contained",onClick:function(){return l(!0)},children:"Add New Automation"})]})]})})}var ee=n(8946),te=n(73456),ne=n(56465),re=n(38066),ie=function(e){var t=e.open,n=e.onClose,i=e.tableId,a=e.collectionData,d=(0,s.useState)(""),u=d[0],f=d[1],m=(0,s.useState)([]),g=m[0],v=m[1],b=(0,s.useState)(""),x=b[0],y=b[1],Z=(0,s.useState)(!1),w=Z[0],N=Z[1],k=((0,s.useRef)(null),(0,h.I0)()),C="".concat("https://api.wisemelon.ai","/api/external/collection/").concat(i,"/data"),S=function(e,t){e?(navigator.clipboard.writeText(e),f("".concat(t," copied to clipboard")),setTimeout((function(){return f("")}),3e3)):E.ZP.error("No ".concat(t," available to copy"))},A=function(){var e=(0,r.Z)((function(e){var t,n,r;return(0,o.__generator)(this,(function(l){switch(l.label){case 0:if(!a)return E.ZP.error("Collection data not available"),[2];N(!0),l.label=1;case 1:return l.trys.push([1,3,4,5]),t={name:a.name,schema:a.schema,_id:i,isAPIAccessable:a.isAPIAccessable,whitelistedDomains:e},[4,k((0,p.Rm)(t))];case 2:if("fulfilled"!==l.sent().meta.requestStatus)throw new Error("Failed to update whitelisted domains");return E.ZP.success("Whitelisted domains updated successfully"),[3,5];case 3:return n=l.sent(),console.error("Error updating whitelisted domains:",n),E.ZP.error("Error updating whitelisted domains"),r=(null===a||void 0===a?void 0:a.whitelistedDomains)||[],v(r),[3,5];case 4:return N(!1),[7];case 5:return[2]}}
1))}));return function(t){return e.apply(this,arguments)}}(),B=function(){var e=(0,r.Z)((function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return e=(null===a||void 0===a?void 0:a.whitelistedDomains)||[],JSON.stringify(g.sort())===JSON.stringify(e.sort())?[3,2]:[4,A(g)];case 1:t.sent(),t.label=2;case 2:return n(),f(""),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,s.useEffect)((function(){t&&a&&(a.whitelistedDomains&&Array.isArray(a.whitelistedDomains)?v(a.whitelistedDomains):v([]))}),[t,a]),(0,c.tZ)(re.Z,{textAlign:"left",dialogHeight:"min-h-[300px]",Component:function(){return(0,c.BX)("div",{className:"space-y-4",children:[u&&(0,c.BX)("div",{className:"flex items-center gap-2 bg-[#E4F3E9] border-[#A1D7B9] text-[#228F52] px-4 py-2 rounded-md text-sm font-medium tracking-tight",children:[(0,c.tZ)(ee.Z,{className:"w-4 h-4"}),u]}),(0,c.BX)("div",{children:[(0,c.tZ)("label",{className:"text-[0.9rem] text-[#4A4A4A] font-bold block mb-1 tracking-tight",children:"API Key"}),(0,c.BX)("div",{className:"relative",children:[(0,c.tZ)("input",{type:"text",value:(null===a||void 0===a?void 0:a.apiKey)||"No API Key available",className:"w-full border border-gray-300 rounded-md px-4 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",readOnly:!0}),(0,c.tZ)(te.Z,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500 cursor-pointer hover:text-gray-700",onClick:function(){return S((null===a||void 0===a?void 0:a.apiKey)||"","API Key")}})]})]}),(0,c.BX)("div",{children:[(0,c.tZ)("label",{className:"text-[0.9rem] text-[#4A4A4A] font-bold block mb-1 tracking-tight",children:"API Secret"}),(0,c.BX)("div",{className:"relative",children:[(0,c.tZ)("input",{type:"password",value:(null===a||void 0===a?void 0:a.apiSecret)||"No API Secret available",className:"w-full border border-gray-300 rounded-md px-4 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",readOnly:!0}),(0,c.tZ)(te.Z,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500 cursor-pointer hover:text-gray-700",onClick:function(){return S((null===a||void 0===a?void 0:a.apiSecret)||"","API Secret")}})]})]}),(0,c.BX)("div",{children:[(0,c.tZ)("label",{className:"text-[0.9rem] text-[#4A4A4A] font-bold block mb-1 tracking-tight",children:"API URL"}),(0,c.BX)("div",{className:"relative",children:[(0,c.tZ)("input",{type:"text",value:C,className:"w-full border border-gray-300 rounded-md px-4 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 truncate overflow-hidden text-ellipsis whitespace-nowrap",readOnly:!0}),(0,c.tZ)(te.Z,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500 cursor-pointer hover:text-gray-700",onClick:function(){return S(C,"API URL")}})]})]}),(0,c.BX)("div",{children:[(0,c.tZ)("span",{className:"text-[0.9rem] text-[#4A4A4A] font-bold block mb-1 tracking-tight",children:"Whitelist Domain"}),(0,c.tZ)("div",{className:"border border-gray-900 rounded-lg min-h-[350px] p-3 mb-6 bg-white overflow-y-auto",style:{height:220},children:(0,c.BX)("div",{className:"flex flex-wrap gap-2",children:[g.map((function(e,t){return(0,c.BX)("span",{className:"flex items-center bg-gray-800 text-white rounded-lg",children:[(0,c.tZ)("span",{className:"font-semibold text-xs px-2 py-1",children:e}),(0,c.tZ)("button",{className:"flex items-center justify-center px-2 py-1",onClick:function(){return e=t,void v(g.filter((function(t,n){return n!==e})));var e},type:"button",disabled:w,style:{height:"100%"},children:(0,c.tZ)(ne.Z,{size:18,className:"hover:text-red-500 ".concat(w?"opacity-50":"")})})]},t)})),(0,c.tZ)("input",{type:"text",className:"outline-none border-none px-3 py-1 text-base min-w-[120px] bg-transparent text-gray-700 placeholder-gray-400",placeholder:"Enter Domains",value:x,onChange:function(e){return t=e.target.value,void y(t);var t},disabled:w,onKeyDown:function(e){"Enter"===e.key&&x.trim()&&!w&&x.trim()&&!g.includes(x.trim())&&(v((0,l.Z)(g).concat([x.trim()])),y(""))}})]})})]}),(0,c.BX)("div",{className:"flex justify-end pt-4 items-center gap-3",children:[w&&(0,c.BX)("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[(0,c.tZ)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-900"}),"Updating..."]}),(0,c.tZ)("button",{onClick:B,disabled:w,className:"bg-black text-white text-sm px-6 py-2 rounded-md hover:bg-gray-900 transition disabled:opacity-50 disabled:cursor-not-allowed",children:"Done"})]})]})},open:t,onClose:function(){w||B()},ActionComponent:void 0,title:"API Key and Secret",description:"Check your API key and secret for the API trigger you created. Please copy from the dialog instead of copying manually."})},ae=n(24486),le=n(12381),oe=n(28583),ce=n(43927),se=n(73935),de=n(2112),ue=n(87788),fe=n(36961),he=n(86450),pe=n(25658),me=n(62472),ge=n(14397),ve=n(85119),be=n(90889),xe=n(99375),ye=n(82946),Ze=n(45582),we=n(79341),Ne=n(34001),ke=n(2151),Ce=n(4355),Se=n(51646),Ae=n(52292),Ee=n(73810),Be=n(24238);function Xe(e){for(var t=["#6366f1","#8b5cf6","#ec4899","#f59e0b","#10b981","#3b82f6","#ef4444","#14b8a6","#f97316","#06b6d4"],n=0,r=0;r<e.length;r++)n=31*n+e.charCodeAt(r)>>>0;return t[n%t.length]}function _e(e){var t=e.agent,n=e.onRemove;return(0,c.BX)("span",{className:"inline-flex items-center gap-1 pl-1.5 pr-1 py-0.5 rounded-full text-[11px] font-semibold bg-[#fef3c7] text-[#92400e] border border-[#fde68a] shrink-0",children:[(0,c.tZ)(Ze.Z,{size:10}),t.name,(0,c.tZ)("button",{onClick:function(e){e.stopPropagation(),n()},className:"ml-0.5 rounded-full hover:bg-[#fde68a] p-0.5 transition-colors",children:(0,c.tZ)(ne.Z,{size:9})})]})}function ze(e){var t=e.agents,n=e.loading,r=e.selected,i=e.onToggle,a=(0,s.use
1State)(""),l=a[0],o=a[1],d=(0,s.useState)(!1),u=d[0],f=d[1],h=(0,s.useState)(null),p=h[0],m=h[1],g=(0,s.useRef)(null),v=(0,s.useRef)(null),b=(0,s.useMemo)((function(){return t.filter((function(e){var t;return e.name.toLowerCase().includes(l.toLowerCase())||(null===(t=e.email)||void 0===t?void 0:t.toLowerCase().includes(l.toLowerCase()))}))}),[t,l]),x=function(){var e;g.current&&m(g.current.getBoundingClientRect()),f(!0),null===(e=v.current)||void 0===e||e.focus()};(0,s.useEffect)((function(){var e=function(e){var t,n,r=e.target;(null===(t=g.current)||void 0===t?void 0:t.contains(r))||(null===(n=document.getElementById("agent-drop-portal"))||void 0===n?void 0:n.contains(r))||f(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}),[]);var y=u&&p?se.createPortal((0,c.BX)("div",{id:"agent-drop-portal",className:"bg-white border border-slate-200 rounded-xl shadow-2xl overflow-hidden",style:{position:"fixed",top:p.bottom+6,left:p.left,width:p.width,maxHeight:260,zIndex:10080,overflowY:"auto"},children:[b.length>0&&(0,c.tZ)("div",{className:"px-4 py-2 text-[10px] font-bold text-slate-400 uppercase tracking-widest border-b border-slate-100 sticky top-0 bg-white",children:"Agents"}),n&&(0,c.tZ)("div",{className:"flex justify-center py-6",children:(0,c.tZ)(we.Z,{size:16,className:"animate-spin text-slate-400"})}),!n&&0===b.length&&(0,c.tZ)("div",{className:"px-4 py-8 text-sm text-slate-400 text-center",children:"No results found"}),!n&&b.map((function(e){var t,n=r.some((function(t){return t._id===e._id}));return(0,c.BX)("button",{onMouseDown:function(e){return e.preventDefault()},onClick:function(){var t;i(e),o(""),null===(t=v.current)||void 0===t||t.focus()},className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-gray-50 text-left transition-colors",children:[(0,c.tZ)("div",{className:"flex items-center justify-center w-5 h-5 rounded border-2 shrink-0 transition-all\n                  ".concat(n?"bg-black border-black":"border-gray-300 bg-white"),children:n&&(0,c.tZ)(Ne.Z,{size:12,className:"text-white",strokeWidth:3})}),(0,c.tZ)("div",{className:"w-9 h-9 rounded-full flex items-center justify-center text-white text-sm font-bold shrink-0",style:{backgroundColor:Xe(e.name)},children:(t=e.name,t.split(" ").map((function(e){return e[0]})).join("").slice(0,2).toUpperCase())}),(0,c.BX)("div",{className:"flex-1 min-w-0",children:[(0,c.tZ)("p",{className:"text-sm font-medium text-gray-900 truncate",children:e.name}),e.email&&(0,c.tZ)("p",{className:"text-xs text-gray-500 mt-0.5 truncate",children:e.email})]})]},e._id)}))]}),document.body):null;return(0,c.BX)(c.HY,{children:[(0,c.tZ)("div",{ref:g,children:(0,c.BX)("div",{onClick:x,className:"min-h-[42px] flex flex-wrap items-center gap-1.5 px-3 py-2\n            bg-white border rounded-xl cursor-text transition-all\n            ".concat(u?"border-[#202938] ring-1 ring-[#202938]":"border-slate-200 hover:border-slate-300"),children:[r.map((function(e){return(0,c.tZ)(_e,{agent:e,onRemove:function(){return function(e){return i(e)}(e)}},e._id)})),(0,c.BX)("div",{className:"flex items-center gap-1.5 flex-1 min-w-[120px]",children:[(0,c.tZ)(ke.Z,{size:12,className:"text-slate-400 shrink-0"}),(0,c.tZ)("input",{ref:v,value:l,onChange:function(e){o(e.target.value),x()},onFocus:x,placeholder:0===r.length?"Search agents\u2026":"",className:"flex-1 text-xs text-slate-700 placeholder-slate-400 outline-none bg-transparent"})]})]})}),y]})}var Ie=function(e){var t,n,r,i,a,o,d=e.agents,f=e.agentsLoading,p=(0,h.I0)(),m=(0,h.v9)((function(e){return e.wiseLens})),g=m.pinModal,v=m.pinning,b=m.pinError,x=(0,s.useRef)(null),y=g.open,Z=g.chat,w=g.label,N=g.viewBy,k=g.showTo;if((0,s.useEffect)((function(){y&&setTimeout((function(){var e;return null===(e=x.current)||void 0===e?void 0:e.focus()}),80)}),[y]),!y||!Z)return null;var C,S=null!==(o=null===(t=Z.echartsOption)||void 0===t||null===(n=t.title)||void 0===n?void 0:n.text)&&void 0!==o?o:"Chart",A=null!==(C=null===(r=Z.echartsOption)||void 0===r||null===(i=r.series)||void 0===i||null===(a=i[0])||void 0===a?void 0:a.type)&&void 0!==C?C:"chart",E=function(){w.trim()&&Z&&p((0,xe.n9)({chatId:Z.id,conversationId:Z.conversationId,label:w.trim(),viewBy:N,showTo:k.map((function(e){return e._id}))}))};return se.createPortal((0,c.BX)("div",{className:"fixed inset-0 flex items-center justify-center p-4",style:{zIndex:10050,background:"rgba(2,6,23,0.65)",backdropFilter:"blur(8px)"},onClick:function(){return p((0,xe.Yf)())},onKeyDown:function(e){"Escape"===e.key&&p((0,xe.Yf)()),"Enter"!==e.key||e.shiftKey||"OnlyMe"!==N||E()},children:[(0,c.BX)("div",{className:"relative w-full bg-white rounded-2xl shadow-2xl flex flex-col",style:{maxWidth:480,animation:"pinModalIn 0.22s cubic-bezier(0.34,1.56,0.64,1) both"},onClick:function(e){return e.stopPropagation()},children:[(0,c.BX)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-slate-100 rounded-t-2xl",children:[(0,c.BX)("div",{className:"flex items-center gap-2.5",children:[(0,c.tZ)("div",{className:"w-8 h-8 rounded-xl bg-[#202938] flex items-center justify-center shadow-md",children:(0,c.tZ)(Ce.Z,{size:14,className:"text-white"})}),(0,c.BX)("div",{children:[(0,c.tZ)("p",{className:"text-sm font-bold text-slate-800 leading-none",children:"Pin to Dashboard"}),(0,c.tZ)("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Configure how this chart appears"})]})]}),(0,c.tZ)("button",{onClick:function(){return p((0,xe.Yf)())},className:"p-1.5 rounded-xl text-slate-400 hover:text-slate-700 hover:bg-slate-100 transition-colors",children:(0,c.tZ)(ne.Z,{size:15})})]}),(0,c.BX)("div",{className:"mx-5 mt-4 px-3 py-2.5 rounded-xl bg-slate-50 border border-slate-200 flex items-center gap-2.5",children:[(0,c.tZ)("div",{className:"w-7 h-7 rounded-lg bg-blue-50 flex items-center justify-center shrink-0",children:(0,c.tZ)(Se.Z,{size:13,className:"text-blue-500"})}),(0,c.BX)("div",{className:"min-w-0",children:[(0,c.tZ)("p",{className:"text-xs font-semibold text-slate-700 truncate",children:S}),(0,c.BX)("p",{className:"text-[10px] text-slate-400 capitalize",children:[A," chart"]})]})]}),(0,c.BX)("div",{className:"px-5 py-4 space-y-5",children:[(0,c.BX)("div",{children:[(0,c.tZ)("label",{className:"block text-[11px] font-semibold text-slate-500 uppercase tracking-wide mb-1.5",children:"Dashboard Label"}),(0,c.tZ)("input",{ref:x,value:w,onChange:function(e){return p((0,xe.ST)(e.target.value))},placeholder:"e.g. Monthly Revenue by Region",className:"w-full text-sm text-slate-700 bg-white border border-slate-200 rounded-xl px-3 py-2.5 outline-none focus:border-[#202938] focus:ring-1 focus:ring-[#202938] placeholder-slate-300 transition-all"})]}),(0,c.BX)("div",{children:[(0,c.tZ)("label",{className:"block text-[11px] font-semibold text-slate-500 uppercase tracking-wide mb-2",children:"Visibility"}),(0,c.BX)("div",{className:"flex gap-2",children:[(0,c.BX)("button",{onClick:function(){return p((0,xe.Tv)("OnlyMe"))},className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-xs font-bold\n                  border transition-all duration-150\n                  ".concat("OnlyMe"===N?"bg-[#202938] text-white border-[#202938]":"bg-white text-[#202938] border-[#202938] hover:bg-slate-50"),children:[(0,c.tZ)(Ae.Z,{size:11}),"Only Me"]}),(0,c.BX)("button",{onClick:function(){return p((0,xe.Tv)("Others"))},className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-xs font-bold\n                  border transition-all duration-150\n                  ".concat("Others"===N?"bg-[#202938] text-white border-[#202938]":"bg-white text-[#202938] border-[#202938] hover:bg-slate-50"),children:[(0,c.tZ)(Ee.Z,{size:11}),"Team Members"]})]}),(0,c.tZ)("p",{className:"text-[10px] text-slate-400 mt-1.5 leading-relaxed",children:"OnlyMe"===N?"Only you will see this pin on the dashboard.":0===k.length?"Visible to all members of your organisation.":"Visible to ".concat(k.length," selected member").concat(k.length>
11?"s":"",".")})]}),"Others"===N&&(0,c.BX)("div",{style:{animation:"fadeSlideDown 0.18s ease both"},children:[(0,c.tZ)("label",{className:"block text-[11px] font-semibold text-slate-500 uppercase tracking-wide mb-1.5",children:"Specific Members"}),(0,c.tZ)(ze,{agents:d,loading:f,selected:k,onToggle:function(e){var t=k.some((function(t){return t._id===e._id}));p((0,xe.Yr)(t?k.filter((function(t){return t._id!==e._id})):(0,l.Z)(k).concat([e])))}})]}),b&&(0,c.BX)("div",{className:"flex items-center gap-2 bg-red-50 border border-red-200 rounded-xl px-3 py-2.5",children:[(0,c.tZ)(fe.Z,{size:13,className:"text-red-500 shrink-0"}),(0,c.tZ)("p",{className:"text-xs text-red-600 flex-1",children:b}),(0,c.tZ)("button",{onClick:function(){return p((0,xe.qs)())},className:"text-red-400 hover:text-red-600",children:(0,c.tZ)(ne.Z,{size:11})})]})]}),(0,c.BX)("div",{className:"px-5 pb-5 flex items-center justify-end gap-2.5",children:[(0,c.tZ)(u.Z,{variant:"outlined",onClick:function(){return p((0,xe.Yf)())},disabled:v,sx:{textTransform:"none",color:"#202938",fontWeight:800,borderColor:"#202938",borderWidth:"2px",fontSize:"12px","&:hover":{borderWidth:"2px",borderColor:"#202938",background:"#f8fafc"},"&:disabled":{borderWidth:"2px",opacity:.4}},children:"Cancel"}),(0,c.tZ)(u.Z,{variant:"contained",onClick:E,disabled:!w.trim()||v,startIcon:v?(0,c.tZ)(we.Z,{size:13,className:"animate-spin"}):(0,c.tZ)(Be.Z,{sx:{fontSize:14}}),disableElevation:!0,sx:{textTransform:"none",fontWeight:800,fontSize:"12px",background:"#202938",color:"#fff","&:hover":{background:"#111827"},"&:disabled":{opacity:.4,color:"#fff"}},children:v?"Pinning\u2026":"Pin to Dashboard"})]})]}),(0,c.tZ)("style",{children:"\n        @keyframes pinModalIn {\n          from { opacity: 0; transform: scale(0.94) translateY(12px); }\n          to   { opacity: 1; transform: scale(1) translateY(0); }\n        }\n        @keyframes fadeSlideDown {\n          from { opacity: 0; transform: translateY(-6px); }\n          to   { opacity: 1; transform: translateY(0); }\n        }\n      "})]}),document.body)},De=n(74193),Te=n(6338),Re=function(){return(0,c.tZ)("div",{className:"flex gap-2.5 items-end animate-slideIn",children:(0,c.tZ)("div",{className:"bg-[#55D2841F] border border-slate-200 rounded-2xl rounded-bl-sm px-4 py-3 shadow-sm",children:(0,c.tZ)("div",{className:"flex items-center gap-1.5",children:[0,1,2].map((function(e){return(0,c.tZ)("span",{className:"w-2 h-2 rounded-full bg-[#55D284] animate-typingBounce",style:{animationDelay:"".concat(.2*e,"s")}},e)}))})})})},Oe=function(e){var t,n=e.collectionId,i=e.collectionTitle,a=(e.agents,e.agentsLoading,(0,h.I0)()),l=(0,h.v9)((function(e){return e.wiseLens})),d=l.conversation,u=l.conversationLoading,f=l.chats,p=l.chatsLoading,m=l.hasMore,g=l.currentPage,v=l.sending,b=l.sendError,x=l.dashboard,y=(l.allCharts,(0,s.useState)("")),Z=y[0],w=y[1],N=(0,s.useState)(new Set),k=N[0],C=N[1],S=(0,s.useState)(!1),A=S[0],E=S[1],B=(0,s.useState)(!1),X=B[0],_=B[1],z=(0,s.useRef)(null),I=(0,s.useRef)(null),D=(0,s.useRef)(null),T=(0,s.useRef)(null),R=(0,s.useRef)(0),O=(0,s.useRef)(!1),j=new Set(null!==(t=null===x||void 0===x?void 0:x.pins.map((function(e){return e.chatId})))&&void 0!==t?t:[]);(0,s.useEffect)((function(){a((0,xe.T2)()),a((0,xe.kB)({collectionId:n})),a((0,xe.AK)({}))}),[n]),(0,s.useEffect)((function(){var e;0===R.current&&(null===(e=z.current)||void 0===e||e.scrollIntoView({behavior:"smooth"}))}),[f.length,v]),(0,s.useEffect)((function(){if(0!==R.current){var e=I.current;if(e){var t=e.scrollHeight-R.current;e.scrollTop=t,R.current=0,O.current=!1}}}));var L=(0,s.useCallback)((function(){if(d&&m&&!p&&!O.current){var e=g-1;if(!(e<1)){var t=I.current;t&&(R.current=t.scrollHeight),O.current=!0,a((0,xe.Hi)({conversationId:d.id,page:e}))}}}),[d,m,p,g,a]),F=(0,s.useCallback)((function(){var e=I.current;e&&e.scrollTop<80&&L()}),[L]),P=(0,s.useCallback)((function(){var e=window.SpeechRecognition||window.webkitSpeechRecognition;if(e){var t;if(A)return null===(t=T.current)||void 0===t||t.stop(),void E(!1);var n=new e;n.lang="en-US",n.continuous=!1,n.interimResults=!1,n.onresult=function(e){return w((function(t){return t+e.results[0][0].transcript}))},n.onend=function(){return E(!1)},T.current=n,n.start(),E(!0)}}),[A]),W=(0,s.useCallback)((0,r.Z)((function(){var e,t,r,i,l,c,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return!(e=Z.trim())||v?[2]:(w(""),t="opt_".concat(Date.now()),a((0,xe._L)({id:t,conversationId:null!==(r=null===d||void 0===d?void 0:d.id)&&void 0!==r?r:"",role:"user",prompt:e,createdAt:(new Date).toISOString()})),C((function(e){return new Set(e).add(t)})),[4,a((0,xe.bG)({collectionId:n,prompt:e}))]);case 1:return i=o.sent(),xe.bG.fulfilled.match(i)&&(l=i.payload,c=l.userChat,s=l.assistantChat,C((function(e){var t=new Set(e);return t.add(c.id),t.add(s.id),t}))),[2]}}))}
1)),[Z,v,n,d,a]),M=(0,s.useCallback)((function(e){a((0,xe.N0)(e))}),[a]),H=(0,s.useCallback)((function(e){a((0,xe.Sn)({chatId:e.id}))}),[a]),U=(0,c.BX)("div",{className:"flex flex-col h-full",children:[(0,c.BX)("div",{ref:I,onScroll:F,className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",style:{scrollbarWidth:"thin",scrollbarColor:"#e2e8f0 transparent"},children:[p&&(0,c.tZ)("div",{className:"flex justify-center py-2",children:(0,c.BX)("div",{className:"flex items-center gap-1.5 text-[11px] text-slate-400",children:[(0,c.tZ)(de.Z,{size:11,className:"animate-bounce"}),"Loading older messages\u2026"]})}),m&&!p&&(0,c.tZ)("div",{className:"flex justify-center",children:(0,c.tZ)("button",{onClick:L,className:"text-[10px] text-blue-500 hover:text-blue-700 underline underline-offset-2 py-1",children:"Load older messages"})}),u&&(0,c.tZ)("div",{className:"flex justify-center py-8",children:(0,c.tZ)("div",{className:"w-6 h-6 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"})}),!u&&0===f.length&&(0,c.BX)("div",{className:"flex flex-col items-center justify-center h-full gap-5 py-10",children:[(0,c.tZ)("div",{className:"w-14 h-14 rounded-2xl bg-blue-50 border border-blue-100 flex items-center justify-center",children:(0,c.tZ)(ue.Z,{size:26,className:"text-blue-500"})}),(0,c.BX)("div",{className:"text-center",children:[(0,c.tZ)("p",{className:"text-sm font-semibold text-slate-700",children:"Ask about your data"}),(0,c.tZ)("p",{className:"text-xs text-slate-400 mt-1 max-w-[220px]",children:"Get instant charts, tables, and insights"})]}),(0,c.tZ)("div",{className:"flex flex-col gap-2 w-full max-w-[260px]",children:["How many records do we have?","Show top 10 entries by count","Compare trends over time","Give me a breakdown summary"].map((function(e){return(0,c.tZ)("button",{onClick:function(){return w(e)},className:"text-left text-xs text-slate-600 bg-white border border-slate-200 rounded-xl px-3 py-2 hover:bg-blue-50 hover:border-blue-200 hover:text-blue-700 transition-all",children:e},e)}))})]}),!m&&!p&&f.length>0&&(0,c.BX)("div",{className:"flex items-center gap-2 py-1",children:[(0,c.tZ)("div",{className:"flex-1 h-px bg-slate-100"}),(0,c.tZ)("span",{className:"text-[9px] text-slate-400 font-medium tracking-wide uppercase",children:"Start of conversation"}),(0,c.tZ)("div",{className:"flex-1 h-px bg-slate-100"})]}),f.map((function(e){return(0,c.tZ)(ye.Z,{chat:e,isPinned:j.has(e.id),onPin:M,onUnpin:H,isNew:k.has(e.id)},e.id)})),v&&(0,c.tZ)(Re,{}),b&&(0,c.BX)("div",{className:"flex items-center gap-2 bg-red-50 border border-red-200 rounded-xl px-3 py-2.5",style:{animation:"slideIn 0.2s ease both"},children:[(0,c.tZ)(fe.Z,{size:13,className:"text-red-500 shrink-0"}),(0,c.tZ)("p",{className:"text-xs text-red-600 flex-1",children:b}),(0,c.tZ)("button",{onClick:function(){return a((0,xe.fw)())},className:"text-red-400 hover:text-red-600",children:(0,c.tZ)(ne.Z,{size:11})})]}),(0,c.tZ)("div",{ref:z})]}),(0,c.BX)("div",{className:"shrink-0 border-t border-slate-100 px-3 py-3 bg-white",children:[(0,c.BX)("div",{className:"flex items-end gap-2 bg-slate-50 rounded-2xl border border-slate-200 focus-within:border-blue-400 focus-within:ring-2 focus-within:ring-blue-100 transition-all px-2 py-1.5",children:[(0,c.tZ)("textarea",{ref:D,value:Z,onChange:function(e){return w(e.target.value)},onKeyDown:function(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),W())},placeholder:"Ask about your data\u2026",rows:1,disabled:v,className:"flex-1 bg-transparent resize-none text-sm text-slate-700 placeholder-slate-400 outline-none px-2 py-1.5 max-h-28 leading-relaxed",style:{minHeight:36},onInput:function(e){var t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,112)+"px"}}),(0,c.tZ)("button",{onClick:P,className:"p-2 rounded-xl transition-all ".concat(A?"bg-red-500 text-white animate-pulse":"text-slate-400 hover:text-slate-600 hover:bg-slate-200"),children:A?(0,c.tZ)(he.Z,{size:18}):(0,c.tZ)(pe.Z,{size:18})}),(0,c.tZ)("button",{onClick:W,disabled:!Z.trim()||v,className:"p-2 rounded-xl transition-all ".concat(Z.trim()&&!v?"bg-[#55D284] text-white shadow-md shadow-blue-200":"bg-slate-200 text-slate-400 cursor-not-allowed"),children:(0,c.tZ)(me.Z,{size:16})})]}),(0,c.tZ)("p",{className:"text-[9px] text-slate-400 text-center mt-1.5",children:"Enter to send \u2022 Shift+Enter for new line"})]})]});return X?se.createPortal((0,c.BX)("div",{className:"fixed inset-0 z-[10000] bg-white flex flex-col",style:{fontFamily:"'DM Sans', sans-serif"},children:[(0,c.BX)("div",{className:"shrink-0 flex items-center justify-between px-5 py-3 border-b border-slate-100",children:[(0,c.BX)("div",{className:"flex items-center gap-2",children:[(0,c.tZ)(ue.Z,{size:16,className:"text-blue-500"}),(0,c.BX)("span",{className:"text-sm font-semibold text-slate-700",children:["WiseLens",i?" \u2014 ".concat(i):""]})]}),(0,c.BX)("button",{onClick:function(){return _(!1)},className:"flex items-center gap-1.5 text-xs text-slate-500 hover:text-slate-800 px-3 py-1.5 rounded-lg hover:bg-slate-100 transition-colors",children:[(0,c.tZ)(ge.Z,{size:13})," Minimize"]})]}),(0,c.tZ)("div",{className:"flex-1 overflow-hidden",children:U})]}),document.body):(0,c.BX)("div",{className:"fixed top-0 right-0 h-full z-[9999] bg-white border-l border-slate-200 shadow-2xl flex flex-col",style:{width:"clamp(360px, 45vw, 680px)",fontFamily:"'DM Sans', sans-serif",animation:"slideInRight 0.3s cubic-bezier(0.34,1.56,0.64,1) both"},children:[(0,c.BX)("div",{className:"shrink-0 flex items-center justify-between px-4 py-3 border-b border-slate-100 bg-white",children:[(0,c.BX)("div",{className:"flex items-center gap-2",children:[(0,c.tZ)("div",{className:"w-8 h-8 rounded-lg bg-[#55D2841F] flex items-center justify-center",children:(0,c.tZ)(ve.Z,{size:15,className:"text-[#55D284]"})}),(0,c.tZ)("span",{className:"text-sm font-semibold text-slate-700 truncate max-w-[200px]",children:null!==i&&void 0!==i?i:"WiseLens AI"}),(0,c.BX)("span",{className:"flex items-center gap-1 text-[10px] text-emerald-500 font-medium",children:[(0,c.tZ)("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),"Live"]})]}),(0,c.BX)("div",{className:"flex items-center gap-1",children:[(0,c.tZ)("button",{onClick:function(){return _(!0)},className:"p-1.5 rounded-lg text-slate-400 hover:text-slate-700 hover:bg-slate-100 transition-colors",title:"Fullscreen",children:(0,c.tZ)(be.Z,{size:14})}),(0,c.tZ)("button",{onClick:function(){return a((0,xe.wt)())},className:"p-1.5 rounded-lg text-slate-400 hover:text-red-500 hover:bg-red-50 transition-colors",title:"Close",children:(0,c.tZ)(ne.Z,{size:14})})]})]}),(0,c.tZ)("div",{className:"flex-1 overflow-hidden",children:U})]})},je=function(e){var t,n,r=(0,h.v9)((function(e){return e.wiseLens.isOpen}
1)),i=(0,s.useState)((function(){var e=document.getElementById("wiselens-portal");return e||((e=document.createElement("div")).id="wiselens-portal",document.body.appendChild(e)),e}))[0],a=(0,h.I0)(),l=(0,h.v9)((function(e){var t;return null===e||void 0===e||null===(t=e.agent)||void 0===t?void 0:t.agentListData})),o=(0,h.v9)((function(e){var t;return null===e||void 0===e||null===(t=e.agent)||void 0===t?void 0:t.myAgentData}));return(0,s.useEffect)((function(){0==l.data.length&&a((0,De.Ku)({skip:0,limit:99999})),o||a((0,Te.ts)())}),[a,l]),r?(0,c.BX)(c.HY,{children:[se.createPortal((0,c.tZ)(Oe,(0,g.Z)({},e)),i),(0,c.tZ)(Ie,{agents:null!==(n=null===l||void 0===l||null===(t=l.data)||void 0===t?void 0:t.map((function(e){return{_id:null===e||void 0===e?void 0:e._id,name:null===e||void 0===e?void 0:e.name,email:null===e||void 0===e?void 0:e.email}})))&&void 0!==n?n:[]})]}):null},Le=function(e){var t=e.showFilter,n=void 0!==t&&t,m=(0,i.Z)(e,["showFilter"]),g=(0,h.v9)((function(e){return e.automations})).automationCount,v=(0,s.useState)(!1),x=v[0],y=v[1],Z=(0,s.useState)(!1),w=Z[0],N=Z[1],k=(0,s.use
1State)(!1),S=k[0],E=k[1],L=(0,s.useState)(m.collectionMeta),F=L[0],P=L[1],W=(0,s.useState)(!1),M=(W[0],W[1],(0,s.useState)(!1)),H=M[0],U=M[1],V=(0,Q.useRouter)(),q=(0,h.I0)();(0,s.useEffect)((function(){P(m.collectionMeta)}),[m.collectionMeta]);var Y,J=(0,s.useState)(null),ee=J[0],te=J[1],ne=Boolean(ee),re=function(){te(null)},se=(function(e){if(!e)return[];try{var t=e;Object.entries(t).filter((function(e){var t=(0,a.Z)(e,2),n=(t[0],t[1]);return Array.isArray(n.acceptedValues)&&n.acceptedValues.length>0})).map((function(e){var t=(0,a.Z)(e,2);return{field:t[0],acceptedValues:t[1].acceptedValues}}))}catch(n){return console.error("Invalid schema",n),[]}}(null===F||void 0===F?void 0:F.schema),function(){var e=(0,r.Z)((function(){var e,t,n,r,i,a,c,s,d,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:re(),o.label=1;case 1:if(o.trys.push([1,6,,7]),t=m.tableData||[],!m.onExportData)return[3,5];o.label=2;case 2:return o.trys.push([2,4,,5]),[4,m.onExportData()];case 3:return t=o.sent(),Array.isArray(t)?[3,5]:(console.error("Export data is not an array:",t),alert("Failed to export data. Invalid data format."),[2]);case 4:return n=o.sent(),console.error("Error fetching all data:",n),alert("Failed to fetch all data for export. Please try again."),[2];case 5:return 0===t.length?(alert("No data available to export. The table appears to be empty."),[2]):(r=t.map((function(e){var t={};return Object.keys(e).forEach((function(n){if("_id"!==n&&"__v"!==n&&"updatedAt"!==n&&"conversationId"!==n){var r=e[n];Array.isArray(r)?t[n]=r.length>0?JSON.stringify(r):"":t[n]="object"===typeof r&&null!==r?JSON.stringify(r):r}})),t})),i=b.utils.json_to_sheet(r),50,a=Object.keys(r[0]||{}).map((function(t){return{wch:Math.min((e=Math).max.apply(e,[t.length].concat((0,l.Z)(r.map((function(e){return String(e[t]||"").length}))))),50)}})),i["!cols"]=a,c=b.utils.book_new(),b.utils.book_append_sheet(c,i,"Data"),s=(new Date).toISOString().split("T")[0],d="".concat((null===F||void 0===F?void 0:F.name)||"collection","_").concat(s,".xlsx"),b.writeFile(c,d),[3,7]);case 6:return u=o.sent(),console.error("Error exporting data:",u),alert("Failed to export data. Please check console for details."),[3,7];case 7:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}()),de=function(){var e=(0,r.Z)((function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(E(!1),!V.query.id)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,q((0,p.m0)(V.query.id))];case 2:return"fulfilled"===(e=n.sent()).meta.requestStatus&&P(e.payload),m.fetchData(),[3,4];case 3:return t=n.sent(),console.error("Error fetching updated collection:",t),[3,4];case 4:return[2]}}))}));return function(){return e.apply(this,arguments)}}(),ue=function(){var e=(0,r.Z)((function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(!V.query.id)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,q((0,p.m0)(V.query.id))];case 2:return"fulfilled"===(e=n.sent()).meta.requestStatus&&P(e.payload),[3,4];case 3:return t=n.sent(),console.error(t),[3,4];case 4:return m.fetchData(),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,s.useEffect)((function(){V.query.id&&(q((0,G.Ys)({collectionId:V.query.id})),q((0,K.DJ)()))}),[]),(0,c.BX)(d.Z,{sx:{p:6,gap:4,display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between"},children:[(0,c.BX)("div",{className:"flex justify-between w-full",children:[(0,c.BX)("div",{children:[(0,c.tZ)(f.Z,{sx:{fontWeight:600,fontSize:"1.7rem",letterSpacing:"-0.04em",color:"#414141"},children:null!==(Y=null===F||void 0===F?void 0:F.name)&&void 0!==Y?Y:"Table Header"}),m.totalCount&&(0,c.BX)(f.Z,{sx:{fontWeight:400,fontSize:"0.8rem",letterSpacing:"-0.04em",color:"#909090"},children:[m.totalCount," Entries"]})]}),(0,c.BX)("div",{className:"flex gap-2",children:[(0,c.tZ)("div",{children:m.children}),m.showAskAI&&(0,c.tZ)("button",{style:{textTransform:"none",color:"#202938",fontWeight:800,borderColor:"#202938",borderWidth:"2px",padding:6,borderRadius:6,maxHeight:40},onClick:function(){var e;return null===(e=m.onAskAI)||void 0===e?void 0:e.call(m)},children:(0,c.tZ)(ce.Z,{})}),n&&(0,c.tZ)(u.Z,{variant:"outlined",onClick:function(){var e;return null===(e=m.onClearFilters)||void 0===e?void 0:e.call(m)},startIcon:(0,c.tZ)(X.G,{}),sx:{textTransform:"none",color:"#202938",fontWeight:800,borderColor:"#202938",maxHeight:40,borderWidth:"2px","&:hover":{borderWidth:"2px"}},children:"Clear Filters"}),(null===m||void 0===m?void 0:m.showAdvanceFilter)&&(0,c.tZ)(u.Z,{sx:{textTransform:"none",color:"white",backgroundColor:"#202938",fontWeight:800,borderColor:"#202938",borderWidth:"2px",maxHeight:40,"&:hover":{color:"#202938",backgroundColor:"white",borderWidth:"2px"}},variant:"outlined",onClick:function(){return"function"===typeof m.showAdvanceFilter&&m.showAdvanceFilter(!0)},startIcon:(0,c.tZ)(_.j,{}),children:"Advance Filter"}),!(null===m||void 0===m?void 0:m.showAdvanceFilter)&&(0,c.tZ)(u.Z,{sx:{textTransform:"none",color:"white",backgroundColor:"#202938",fontWeight:800,borderColor:"#202938",borderWidth:"2px",maxHeight:40,"&:hover":{color:"#202938",backgroundColor:"white",borderWidth:"2px"}},variant:"outlined",onClick:function(){return y(!0)},startIcon:(0,c.tZ)(z.M,{}),endIcon:(0,c.tZ)("div",{className:"bg-[#EFEFEF] rounded-full text-black w-5 h-5 flex items-center justify-center ",children:(0,c.tZ)("p",{className:"text-xs",children:g})}),children:"Automation"}),!(null===m||void 0===m?void 0:m.showAdvanceFilter)&&(0,c.tZ)(u.Z,{sx:{textTransform:"none",color:"#202938",fontWeight:800,borderColor:"#202938",maxHeight:40,borderWidth:"2px","&:hover":{borderWidth:"2px"}},variant:"outlined",onClick:function(e){te(e.currentTarget)},endIcon:(0,c.tZ)(I.p,{}),children:"Table Actions"}),(0,c.BX)(ae.Z,{anchorEl:ee,open:ne,onClose:re,PaperProps:{sx:{px:1}},children:[(0,c.BX)(C.Z,{onClick:function(){re(),m.onAddEntry()},sx:{borderRadius:"6px",padding:"8px 12px",marginY:"4px",fontWeight:500,fontSize:"16px",lineHeight:"100%",letterSpacing:"-0.04em","&:hover":{backgroundColor:"#202938",color:"white"}},children:[(0,c.tZ)(D.v,{size:18,weight:"bold",style:{marginRight:"8px"}}),"Add New Entry"]}),(0,c.BX)(C.Z,{onClick:function(){var e;re(),null===(e=m.onRowEdit)||void 0===e||e.call(m)},disabled:m.rowEditDisabled,style:m.rowEditDisabled?{color:"black"}:{},sx:{borderRadius:"6px",padding:"8px 12px",marginY:"4px",fontWeight:500,fontSize:"16px",lineHeight:"100%",letterSpacing:"-0.04em","&:hover":{backgroundColor:"#202938",color:"white"}},children:[(0,c.tZ)(T.k,{size:18,weight:"bold",style:{marginRight:"8px"}}),"Toggle Edit Mode"]}),(0,c.BX)(C.Z,{onClick:se,style:m.rowEditDisabled?{color:"black"}:{},sx:{borderRadius:"6px",padding:"8px 12px",marginY:"4px",fontWeight:500,fontSize:"16px",lineHeight:"100%",letterSpacing:"-0.04em","&:hover":{backgroundColor:"#202938",color:"white"}},children:[(0,c.tZ)(A.Q,{size:18,weight:"bold",style:{marginRight:"8px"}}),"Export Data to Excel"]}),(0,c.BX)(C.Z,{onClick:function(){re(),setTimeout((function(){U(!0)}),100)},sx:{borderRadius:"6px",padding:"8px 12px",marginY:"4px",fontWeight:500,fontSize:"16px",lineHeight:"100%",letterSpacing:"-0.04em","&:hover":{backgroundColor:"#202938",color:"white"}},children:[(0,c.tZ)(R.E,{size:18,weight:"bold",style:{marginRight:"8px"}}),"Upload CSV"]}),(0,c.tZ)("hr",{className:"my-2"}),(0,c.BX)(C.Z,{onClick:function(){re(),E(!0)},sx:{borderRadius:"6px",padding:"8px 12px",marginY:"4px",fontWeight:500,fontSize:"16px",lineHeight:"100%",letterSpacing:"-0.04em","&:hover":{backgroundColor:"#202938",color:"white"}},children:[(0,c.tZ)(O.R,{size:18,weight:"bold",style:{marginRight:"8px"}}),"Edit Collection"]}),(null===m||void 0===m?void 0:m.handleAllClear)&&(0,c.BX)(C.Z,{onClick:null===m||void 0===m?void 0:m.handleAllClear,sx:{borderRadius:"6px",padding:"8px 12px",marginY:"4px",fontWeight:500,fontSize:"16px",lineHeight:"100%",letterSpacing:"-0.04em",color:"red","&:hover":{backgroundColor:"#202938",color:"white"}},children:[(0,c.tZ)(oe.Z,{size:18,style:{marginRight:"8px"}}),"Clear All"]}),m.isAPIAccessable&&(0,c.BX)(C.Z,{onClick:function(){re(),N(!0)},sx:{borderRadius:"6px",padding:"8px 12px",marginY:"4px",fontWeight:500,fontSize:"16px",lineHeight:"100%",letterSpacing:"-0.04em","&:hover":{backgroundColor:"#202938",color:"white"}},children:[(0,c.tZ)(j.f,{size:18,weight:"bold",style:{marginRight:"8px"}}),"Show API specs"]})]}),(0,c.tZ)($,{open:x,onClose:function(){return y(!1)},collectionMeta:m.collectionMeta}),(0,c.tZ)(ie,{open:w,onClose:function(){return N(!1)},tableId:V.query.id||"",collectionData:m.collectionMeta}),(0,c.tZ)(le.Z,{open:S,onClose:de,collectionId:(null===F||void 0===F?void 0:F._id)||V.query.id,fetchFirstEntries:m.fetchData,onUpdateComplete:ue}),(0,c.tZ)(B,{collectionMeta:m.collectionMeta,fetchData:m.fetchData,triggerUpload:H,onUploadComplete:function(){return U(!1)}})]})]}),(0,c.tZ)(je,{collectionId:null===F||void 0===F?void 0:F._id,collectionTitle:null===F||void 0===F?void 0:F.name})]})}}}]);

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.