realtimex-crm 0.12.2 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{DealList-BvoXZ_PI.js → DealList-syAJzJpA.js} +2 -2
- package/dist/assets/{DealList-BvoXZ_PI.js.map → DealList-syAJzJpA.js.map} +1 -1
- package/dist/assets/{index-D-i5w9_j.js → index-fNN1dYom.js} +2 -2
- package/dist/assets/{index-D-i5w9_j.js.map → index-fNN1dYom.js.map} +1 -1
- package/dist/index.html +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
|
@@ -151,7 +151,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
151
151
|
L`+r+" "+r+`
|
|
152
152
|
L0 `+r+`
|
|
153
153
|
L`+r/2+` 0
|
|
154
|
-
`,fill:a,opacity:s,strokeWidth:f,stroke:c===void 0?"transparent":c,style:{pointerEvents:"none"}})})},"y");function cc(){return cc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},cc.apply(null,arguments)}i(cc,"b");var ki={translateX:0,translateY:0,padding:0,itemsSpacing:0,itemDirection:"left-to-right",justify:!1,symbolShape:"square",symbolSize:16,symbolSpacing:8},iqe={top:0,right:0,bottom:0,left:0},M3=i(function(e){var t,n=e.direction,r=e.itemsSpacing,a=e.padding,o=e.itemCount,s=e.itemWidth,l=e.itemHeight;if(typeof a!="number"&&(typeof(t=a)!="object"||Array.isArray(t)||t===null))throw new Error("Invalid property padding, must be one of: number, object");var f=typeof a=="number"?{top:a,right:a,bottom:a,left:a}:cc({},iqe,a),c=f.left+f.right,p=f.top+f.bottom,m=s+c,v=l+p,b=(o-1)*r;return n==="row"?m=s*o+b+c:n==="column"&&(v=l*o+b+p),{width:m,height:v,padding:f}},"A"),Qae=i(function(e){var t=e.anchor,n=e.translateX,r=e.translateY,a=e.containerWidth,o=e.containerHeight,s=e.width,l=e.height,f=n,c=r;switch(t){case"top":f+=(a-s)/2;break;case"top-right":f+=a-s;break;case"right":f+=a-s,c+=(o-l)/2;break;case"bottom-right":f+=a-s,c+=o-l;break;case"bottom":f+=(a-s)/2,c+=o-l;break;case"bottom-left":c+=o-l;break;case"left":c+=(o-l)/2;break;case"center":f+=(a-s)/2,c+=(o-l)/2}return{x:f,y:c}},"C"),Xae=i(function(e){var t,n,r,a,o,s,l=e.direction,f=e.justify,c=e.symbolSize,p=e.symbolSpacing,m=e.width,v=e.height;switch(l){case"left-to-right":t=0,n=(v-c)/2,a=v/2,s="central",f?(r=m,o="end"):(r=c+p,o="start");break;case"right-to-left":t=m-c,n=(v-c)/2,a=v/2,s="central",f?(r=0,o="start"):(r=m-c-p,o="end");break;case"top-to-bottom":t=(m-c)/2,n=0,r=m/2,o="middle",f?(a=v,s="alphabetic"):(a=c+p,s="text-before-edge");break;case"bottom-to-top":t=(m-c)/2,n=v-c,r=m/2,o="middle",f?(a=0,s="text-before-edge"):(a=v-c-p,s="alphabetic")}return{symbolX:t,symbolY:n,labelX:r,labelY:a,labelAnchor:o,labelAlignment:s}},"z"),oqe={circle:tqe,diamond:nqe,square:rqe,triangle:aqe},sqe=i(function(e){var t,n,r,a,o,s,l,f,c,p,m,v=e.x,b=e.y,w=e.width,S=e.height,_=e.data,j=e.direction,E=j===void 0?ki.itemDirection:j,O=e.justify,C=O===void 0?ki.justify:O,T=e.textColor,R=e.background,A=R===void 0?"transparent":R,N=e.opacity,D=N===void 0?1:N,M=e.symbolShape,I=M===void 0?ki.symbolShape:M,F=e.symbolSize,L=F===void 0?ki.symbolSize:F,q=e.symbolSpacing,U=q===void 0?ki.symbolSpacing:q,$=e.symbolBorderWidth,V=$===void 0?0:$,z=e.symbolBorderColor,W=z===void 0?"transparent":z,H=e.onClick,Q=e.onMouseEnter,Y=e.onMouseLeave,K=e.toggleSerie,ee=e.effects,te=y.useState({}),oe=te[0],ne=te[1],fe=Lr(),re=y.useCallback((function(X){if(ee){var se=ee.filter((function(me){return me.on==="hover"})).reduce((function(me,Te){return cc({},me,Te.style)}),{});ne(se)}Q?.(_,X)}),[Q,_,ee]),ce=y.useCallback((function(X){if(ee){var se=ee.filter((function(me){return me.on!=="hover"})).reduce((function(me,Te){return cc({},me,Te.style)}),{});ne(se)}Y?.(_,X)}),[Y,_,ee]),he=Xae({direction:E,justify:C,symbolSize:(t=oe.symbolSize)!=null?t:L,symbolSpacing:U,width:w,height:S}),J=he.symbolX,Me=he.symbolY,we=he.labelX,Ee=he.labelY,Re=he.labelAnchor,ke=he.labelAlignment,Ne=[H,Q,Y,K].some((function(X){return X!==void 0})),Ue=typeof I=="function"?I:oqe[I];return d.jsxs("g",{transform:"translate("+v+","+b+")",style:{opacity:(n=oe.itemOpacity)!=null?n:D},children:[d.jsx("rect",{width:w,height:S,fill:(r=oe.itemBackground)!=null?r:A,style:{cursor:Ne?"pointer":"auto"},onClick:i(function(X){H?.(_,X),K?.(_.id)},"onClick"),onMouseEnter:re,onMouseLeave:ce}),y.createElement(Ue,cc({id:_.id,x:J,y:Me,size:(a=oe.symbolSize)!=null?a:L,fill:(o=(s=_.fill)!=null?s:_.color)!=null?o:"black",borderWidth:(l=oe.symbolBorderWidth)!=null?l:V,borderColor:(f=oe.symbolBorderColor)!=null?f:W},_.hidden?fe.legends.hidden.symbol:void 0)),d.jsx(W_,{textAnchor:Re,style:cc({},fe.legends.text,{fill:(c=(p=(m=oe.itemTextColor)!=null?m:T)!=null?p:fe.legends.text.fill)!=null?c:"black",dominantBaseline:ke,pointerEvents:"none",userSelect:"none"},_.hidden?fe.legends.hidden.text:void 0),x:we,y:Ee,children:_.label})]})},"B"),lqe=i(function(e){var t=e.data,n=e.x,r=e.y,a=e.direction,o=e.padding,s=o===void 0?ki.padding:o,l=e.justify,f=e.effects,c=e.itemWidth,p=e.itemHeight,m=e.itemDirection,v=m===void 0?ki.itemDirection:m,b=e.itemsSpacing,w=b===void 0?ki.itemsSpacing:b,S=e.itemTextColor,_=e.itemBackground,j=_===void 0?"transparent":_,E=e.itemOpacity,O=E===void 0?1:E,C=e.symbolShape,T=e.symbolSize,R=e.symbolSpacing,A=e.symbolBorderWidth,N=e.symbolBorderColor,D=e.onClick,M=e.onMouseEnter,I=e.onMouseLeave,F=e.toggleSerie,L=M3({itemCount:t.length,itemWidth:c,itemHeight:p,itemsSpacing:w,direction:a,padding:s}).padding,q=a==="row"?c+w:0,U=a==="column"?p+w:0;return d.jsx("g",{transform:"translate("+n+","+r+")",children:t.map((function($,V){return d.jsx(sqe,{data:$,x:V*q+L.left,y:V*U+L.top,width:c,height:p,direction:v,justify:l,effects:f,textColor:S,background:j,opacity:O,symbolShape:C,symbolSize:T,symbolSpacing:R,symbolBorderWidth:A,symbolBorderColor:N,onClick:D,onMouseEnter:M,onMouseLeave:I,toggleSerie:F},V)}))})},"H"),cqe=i(function(e){var t=e.data,n=e.containerWidth,r=e.containerHeight,a=e.translateX,o=a===void 0?ki.translateX:a,s=e.translateY,l=s===void 0?ki.translateY:s,f=e.anchor,c=e.direction,p=e.padding,m=p===void 0?ki.padding:p,v=e.justify,b=e.itemsSpacing,w=b===void 0?ki.itemsSpacing:b,S=e.itemWidth,_=e.itemHeight,j=e.itemDirection,E=e.itemTextColor,O=e.itemBackground,C=e.itemOpacity,T=e.symbolShape,R=e.symbolSize,A=e.symbolSpacing,N=e.symbolBorderWidth,D=e.symbolBorderColor,M=e.onClick,I=e.onMouseEnter,F=e.onMouseLeave,L=e.toggleSerie,q=e.effects,U=M3({itemCount:t.length,itemsSpacing:w,itemWidth:S,itemHeight:_,direction:c,padding:m}),$=U.width,V=U.height,z=Qae({anchor:f,translateX:o,translateY:l,containerWidth:n,containerHeight:r,width:$,height:V}),W=z.x,H=z.y;return d.jsx(lqe,{data:t,x:W,y:H,direction:c,padding:m,justify:v,effects:q,itemsSpacing:w,itemWidth:S,itemHeight:_,itemDirection:j,itemTextColor:E,itemBackground:O,itemOpacity:C,symbolShape:T,symbolSize:R,symbolSpacing:A,symbolBorderWidth:N,symbolBorderColor:D,onClick:M,onMouseEnter:I,onMouseLeave:F,toggleSerie:typeof L=="boolean"?void 0:L})},"E"),uqe={start:"left",middle:"center",end:"right"},dqe=i(function(e,t){var n=t.data,r=t.containerWidth,a=t.containerHeight,o=t.translateX,s=o===void 0?0:o,l=t.translateY,f=l===void 0?0:l,c=t.anchor,p=t.direction,m=t.padding,v=m===void 0?0:m,b=t.justify,w=b!==void 0&&b,S=t.itemsSpacing,_=S===void 0?0:S,j=t.itemWidth,E=t.itemHeight,O=t.itemDirection,C=O===void 0?"left-to-right":O,T=t.itemTextColor,R=t.symbolSize,A=R===void 0?16:R,N=t.symbolSpacing,D=N===void 0?8:N,M=t.theme,I=M3({itemCount:n.length,itemWidth:j,itemHeight:E,itemsSpacing:_,direction:p,padding:v}),F=I.width,L=I.height,q=I.padding,U=Qae({anchor:c,translateX:s,translateY:f,containerWidth:r,containerHeight:a,width:F,height:L}),$=U.x,V=U.y,z=p==="row"?j+_:0,W=p==="column"?E+_:0;e.save(),e.translate($,V),$v(e,M.legends.text),n.forEach((function(H,Q){var Y,K=Q*z+q.left,ee=Q*W+q.top,te=Xae({direction:C,justify:w,symbolSize:A,symbolSpacing:D,width:j,height:E}),oe=te.symbolX,ne=te.symbolY,fe=te.labelX,re=te.labelY,ce=te.labelAnchor,he=te.labelAlignment;e.fillStyle=(Y=H.color)!=null?Y:"black",e.fillRect(K+oe,ee+ne,A,A),e.textAlign=uqe[ce],he==="central"&&(e.textBaseline="middle"),qv(e,cc({},M.legends.text,{fill:T??M.legends.text.fill}),String(H.label),K+fe,ee+re)})),e.restore()},"L"),fqe=i(function(e,t,n,r,a,o){o>0?(e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+a-o),e.quadraticCurveTo(t+r,n+a,t+r-o,n+a),e.lineTo(t+o,n+a),e.quadraticCurveTo(t,n+a,t,n+a-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()):e.rect(t,n,r,a)},"o");function gn(){return gn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gn.apply(null,arguments)}i(gn,"Q");function qc(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}i(qc,"U");var vW,hqe=i(function(e){var t=e.bars,n=e.annotations,r=Wae({data:t,annotations:n,getPosition:i(function(a){return{x:a.x+a.width/2,y:a.y+a.height/2}},"getPosition"),getDimensions:i(function(a){var o=a.height,s=a.width;return{width:s,height:o,size:Math.max(s,o)}},"getDimensions")});return d.jsx(d.Fragment,{children:r.map((function(a,o){return d.jsx(L9e,gn({},a),o)}))})},"$"),pqe=i(function(e){var t=e.width,n=e.height,r=e.legends,a=e.toggleSerie;return d.jsx(d.Fragment,{children:r.map((function(o,s){var l,f=o[0],c=o[1];return d.jsx(cqe,gn({},f,{containerWidth:t,containerHeight:n,data:(l=f.data)!=null?l:c,toggleSerie:f.toggleSerie&&f.dataFrom==="keys"?a:void 0}),s)}))})},"ee"),mqe=["data"],gqe=i(function(e){var t,n=e.bar,r=n.data,a=qc(n,mqe),o=e.style,s=o.borderColor,l=o.color,f=o.height,c=o.labelColor,p=o.labelOpacity,m=o.labelX,v=o.labelY,b=o.transform,w=o.width,S=o.textAnchor,_=e.borderRadius,j=e.borderWidth,E=e.label,O=e.shouldRenderLabel,C=e.isInteractive,T=e.onClick,R=e.onMouseEnter,A=e.onMouseLeave,N=e.tooltip,D=e.isFocusable,M=e.ariaLabel,I=e.ariaLabelledBy,F=e.ariaDescribedBy,L=e.ariaDisabled,q=e.ariaHidden,U=Lr(),$=Ere(),V=$.showTooltipFromEvent,z=$.showTooltipAt,W=$.hideTooltip,H=y.useMemo((function(){return function(){return y.createElement(N,gn({},a,r))}}),[N,a,r]),Q=y.useCallback((function(ne){T?.(gn({color:a.color},r),ne)}),[a,r,T]),Y=y.useCallback((function(ne){return V(H(),ne)}),[V,H]),K=y.useCallback((function(ne){R?.(r,ne),V(H(),ne)}),[r,R,V,H]),ee=y.useCallback((function(ne){A?.(r,ne),W()}),[r,W,A]),te=y.useCallback((function(){z(H(),[a.absX+a.width/2,a.absY])}),[z,H,a]),oe=y.useCallback((function(){W()}),[W]);return d.jsxs(mr.g,{transform:b,children:[d.jsx(mr.rect,{width:BP(w,(function(ne){return Math.max(ne,0)})),height:BP(f,(function(ne){return Math.max(ne,0)})),rx:_,ry:_,fill:(t=r.fill)!=null?t:l,strokeWidth:j,stroke:s,focusable:D,tabIndex:D?0:void 0,"aria-label":M?M(r):void 0,"aria-labelledby":I?I(r):void 0,"aria-describedby":F?F(r):void 0,"aria-disabled":L?L(r):void 0,"aria-hidden":q?q(r):void 0,onMouseEnter:C?K:void 0,onMouseMove:C?Y:void 0,onMouseLeave:C?ee:void 0,onClick:C?Q:void 0,onFocus:C&&D?te:void 0,onBlur:C&&D?oe:void 0,"data-testid":"bar.item."+r.id+"."+r.index}),O&&d.jsx(W_,{x:m,y:v,textAnchor:S,dominantBaseline:"central",fillOpacity:p,style:gn({},U.labels.text,{pointerEvents:"none",fill:c}),children:E})]})},"ae"),vqe=["color","label"],yqe=i(function(e){var t=e.color,n=e.label,r=qc(e,vqe);return d.jsx(L8e,{id:n,value:r.formattedValue,enableChip:!0,color:t})},"ne"),Fn={indexBy:"id",keys:["value"],groupMode:"stacked",layout:"vertical",valueScale:{type:"linear",nice:!0,round:!1},indexScale:{type:"band",round:!1},padding:.1,innerPadding:0,enableGridX:!1,enableGridY:!0,enableLabel:!0,label:"formattedValue",labelPosition:"middle",labelOffset:0,labelSkipWidth:0,labelSkipHeight:0,labelTextColor:{theme:"labels.text.fill"},colorBy:"id",colors:{scheme:"nivo"},borderRadius:0,borderWidth:0,borderColor:{from:"color"},isInteractive:!0,tooltip:yqe,tooltipLabel:i(function(e){return e.id+" - "+e.indexValue},"tooltipLabel"),legends:[],initialHiddenIds:[],annotations:[],enableTotals:!1,totalsOffset:10},In=gn({},Fn,{layers:["grid","axes","bars","totals","markers","legends","annotations"],axisTop:null,axisRight:null,axisBottom:{},axisLeft:{},barComponent:gqe,defs:[],fill:[],markers:[],animate:!0,animateOnMount:!1,motionConfig:"default",role:"img",isFocusable:!1}),yr=gn({},Fn,{layers:["grid","axes","bars","totals","legends","annotations"],axisTop:null,axisRight:null,axisBottom:{},axisLeft:{},renderBar:i(function(e,t){var n=t.bar,r=n.color,a=n.height,o=n.width,s=n.x,l=n.y,f=t.borderColor,c=t.borderRadius,p=t.borderWidth,m=t.label,v=t.shouldRenderLabel,b=t.labelStyle,w=t.labelX,S=t.labelY,_=t.textAnchor;e.fillStyle=r,p>0&&(e.strokeStyle=f,e.lineWidth=p),e.beginPath(),fqe(e,s,l,o,a,Math.min(c,a)),e.fill(),p>0&&e.stroke(),v&&(e.textBaseline="middle",e.textAlign=_==="middle"?"center":_,qv(e,b,m,s+w,l+S))},"renderBar"),pixelRatio:typeof window<"u"&&(vW=window.devicePixelRatio)!=null?vW:1}),Zae=i(function(e,t,n,r,a,o){return D3(r,{all:e.map(t),min:0,max:0},a,o).padding(n)},"de"),Jae=i(function(e,t){return e.map((function(n){return gn({},t.reduce((function(r,a){return r[a]=null,r}),{}),n)}))},"ue"),G_=i(function(e){return Object.keys(e).reduce((function(t,n){return e[n]&&(t[n]=e[n]),t}),{})},"se"),K_=i(function(e){return[e,Number(e)]},"ce");function eie(e,t,n,r){return e===void 0&&(e=Fn.layout),n===void 0&&(n=Fn.labelPosition),r===void 0&&(r=Fn.labelOffset),function(a,o){var s=r*(t?-1:1);if(e==="horizontal"){var l=a/2;return n==="start"?l=t?a:0:n==="end"&&(l=t?0:a),{labelX:l+s,labelY:o/2,textAnchor:n==="middle"?"middle":t?"end":"start"}}var f=o/2;return n==="start"?f=t?0:o:n==="end"&&(f=t?o:0),{labelX:a/2,labelY:f-s,textAnchor:"middle"}}}i(eie,"he");var bqe=["layout","width","height","padding","innerPadding","valueScale","indexScale","hiddenIds"],I3=i(function(e,t){return e>t},"be"),tie=i(function(e,t){return e<t},"ge"),nie=i(function(e,t){return Array.from(" ".repeat(t-e),(function(n,r){return e+r}))},"ve"),xqe=i(function(e){return I3(e,0)?0:e},"me"),wqe=i(function(e,t,n,r){var a=e.data,o=e.formatValue,s=e.getColor,l=e.getIndex,f=e.getTooltipLabel,c=e.innerPadding,p=c===void 0?0:c,m=e.keys,v=e.xScale,b=e.yScale,w=e.margin,S=n?tie:I3,_=a.map(G_),j=[];return m.forEach((function(E,O){return nie(0,v.domain().length).forEach((function(C){var T,R,A,N=K_(a[C][E]),D=N[0],M=N[1],I=l(a[C]),F=((T=v(I))!=null?T:0)+t*O+p*O,L=S(R=M,0)?(A=b(R))!=null?A:0:r,q=(function($,V){var z;return S($,0)?r-V:((z=b($))!=null?z:0)-r})(M,L),U={id:E,value:D===null?D:M,formattedValue:o(M),hidden:!1,index:C,indexValue:I,data:_[C]};j.push({key:E+"."+U.indexValue,index:j.length,data:U,x:F,y:L,absX:w.left+F,absY:w.top+L,width:t,height:q,color:s(U),label:f(U)})}))})),j},"pe"),_qe=i(function(e,t,n,r){var a=e.data,o=e.formatValue,s=e.getIndex,l=e.getColor,f=e.getTooltipLabel,c=e.keys,p=e.innerPadding,m=p===void 0?0:p,v=e.xScale,b=e.yScale,w=e.margin,S=n?tie:I3,_=a.map(G_),j=[];return c.forEach((function(E,O){return nie(0,b.domain().length).forEach((function(C){var T,R,A,N=K_(a[C][E]),D=N[0],M=N[1],I=s(a[C]),F=S(R=M,0)?r:(A=v(R))!=null?A:0,L=((T=b(I))!=null?T:0)+t*O+m*O,q=(function($,V){var z;return S($,0)?((z=v($))!=null?z:0)-r:r-V})(M,F),U={id:E,value:D===null?D:M,formattedValue:o(M),hidden:!1,index:C,indexValue:I,data:_[C]};j.push({key:E+"."+U.indexValue,index:j.length,data:U,x:F,y:L,absX:w.left+F,absY:w.top+L,width:q,height:t,color:l(U),label:f(U)})}))})),j},"ye"),Sqe=i(function(e){var t,n,r,a=e.layout,o=e.width,s=e.height,l=e.padding,f=l===void 0?0:l,c=e.innerPadding,p=c===void 0?0:c,m=e.valueScale,v=e.indexScale,b=e.hiddenIds,w=b===void 0?[]:b,S=qc(e,bqe),_=S.keys.filter((function(V){return!w.includes(V)})),j=Jae(S.data,_),E=a==="vertical"?["y","x",o]:["x","y",s],O=E[0],C=E[1],T=E[2],R=Zae(j,S.getIndex,f,v,T,C),A=m.min==="auto"?xqe:function(V){return V},N=j.reduce((function(V,z){return[].concat(V,_.map((function(W){return z[W]})))}),[]).filter(Boolean),D=A(Math.min.apply(Math,N)),M=(r=Math.max.apply(Math,N),isFinite(r)?r:0),I=D3(m,{all:N,min:D,max:M},O==="x"?o:s,O),F=a==="vertical"?[R,I]:[I,R],L=F[0],q=F[1],U=(R.bandwidth()-p*(_.length-1))/_.length,$=[gn({},S,{data:j,keys:_,innerPadding:p,xScale:L,yScale:q}),U,(t=m.reverse)!=null&&t,(n=I(0))!=null?n:0];return{xScale:L,yScale:q,bars:U>0?a==="vertical"?wqe.apply(void 0,$):_qe.apply(void 0,$):[]}},"xe"),jqe=["data","layout","width","height","padding","valueScale","indexScale","hiddenIds"],rie=i(function(e){var t;return e.some(Array.isArray)?rie((t=[]).concat.apply(t,e)):e},"ke"),Eqe=i(function(e,t,n){var r=e.formatValue,a=e.getColor,o=e.getIndex,s=e.getTooltipLabel,l=e.innerPadding,f=e.stackedData,c=e.xScale,p=e.yScale,m=e.margin,v=[];return f.forEach((function(b){return c.domain().forEach((function(w,S){var _,j,E=b[S],O=(_=c(o(E.data)))!=null?_:0,C=((j=(function(M){return p(M[n?0:1])})(E))!=null?j:0)+.5*l,T=(function(M,I){var F;return((F=p(M[n?1:0]))!=null?F:0)-I})(E,C)-l,R=K_(E.data[b.key]),A=R[0],N=R[1],D={id:b.key,value:A===null?A:N,formattedValue:r(N),hidden:!1,index:S,indexValue:w,data:G_(E.data)};v.push({key:b.key+"."+w,index:v.length,data:D,x:O,y:C,absX:m.left+O,absY:m.top+C,width:t,height:T,color:a(D),label:s(D)})}))})),v},"we"),Cqe=i(function(e,t,n){var r=e.formatValue,a=e.getColor,o=e.getIndex,s=e.getTooltipLabel,l=e.innerPadding,f=e.stackedData,c=e.xScale,p=e.yScale,m=e.margin,v=[];return f.forEach((function(b){return p.domain().forEach((function(w,S){var _,j,E=b[S],O=(_=p(o(E.data)))!=null?_:0,C=((j=(function(M){return c(M[n?1:0])})(E))!=null?j:0)+.5*l,T=(function(M,I){var F;return((F=c(M[n?0:1]))!=null?F:0)-I})(E,C)-l,R=K_(E.data[b.key]),A=R[0],N=R[1],D={id:b.key,value:A===null?A:N,formattedValue:r(N),hidden:!1,index:S,indexValue:w,data:G_(E.data)};v.push({key:b.key+"."+w,index:v.length,data:D,x:C,y:O,absX:m.left+C,absY:m.top+O,width:T,height:t,color:a(D),label:s(D)})}))})),v},"Le"),Oqe=i(function(e){var t,n,r=e.data,a=e.layout,o=e.width,s=e.height,l=e.padding,f=l===void 0?0:l,c=e.valueScale,p=e.indexScale,m=e.hiddenIds,v=m===void 0?[]:m,b=qc(e,jqe),w=b.keys.filter((function(U){return!v.includes(U)})),S=XIe().keys(w).offset(ZIe)(Jae(r,w)),_=a==="vertical"?["y","x",o]:["x","y",s],j=_[0],E=_[1],O=_[2],C=Zae(r,b.getIndex,f,p,O,E),T=(n=rie(S),c.type==="log"?n.filter((function(U){return U!==0})):n),R=Math.min.apply(Math,T),A=Math.max.apply(Math,T),N=D3(c,{all:T,min:R,max:A},j==="x"?o:s,j),D=a==="vertical"?[C,N]:[N,C],M=D[0],I=D[1],F=b.innerPadding>0?b.innerPadding:0,L=C.bandwidth(),q=[gn({},b,{innerPadding:F,stackedData:S,xScale:M,yScale:I}),L,(t=c.reverse)!=null&&t];return{xScale:M,yScale:I,bars:L>0?a==="vertical"?Eqe.apply(void 0,q):Cqe.apply(void 0,q):[]}},"Ce"),kqe=i(function(e){var t=e.bars,n=e.direction,r=e.from,a=e.groupMode,o=e.layout,s=e.legendLabel,l=e.reverse,f=Iae(s??(r==="indexes"?"indexValue":"id"));return r==="indexes"?(function(c,p,m){var v=VH(c.map((function(b){var w,S;return{id:(w=b.data.indexValue)!=null?w:"",label:m(b.data),hidden:b.data.hidden,color:(S=b.color)!=null?S:"#000"}})),(function(b){return b.id}));return p==="horizontal"&&v.reverse(),v})(t,o,f):(function(c,p,m,v,b,w){var S=VH(c.map((function(_){var j;return{id:_.data.id,label:w(_.data),hidden:_.data.hidden,color:(j=_.color)!=null?j:"#000"}})),(function(_){return _.id}));return(p==="vertical"&&v==="stacked"&&m==="column"&&b!==!0||p==="horizontal"&&v==="stacked"&&b===!0)&&S.reverse(),S})(t,o,n,a,l,f)},"We"),yW=i(function(e,t,n){var r=e.get(t)||0;e.set(t,r+n)},"Me"),Rqe=i(function(e,t,n){var r=e.get(t)||0;e.set(t,r+(n>0?n:0))},"Be"),Aqe=i(function(e,t,n){var r=e.get(t)||0;e.set(t,Math.max(r,Number(n)))},"Re"),Tqe=i(function(e,t){var n=e.get(t)||0;e.set(t,n+1)},"Oe"),aie=i(function(e){var t,n=e.indexBy,r=n===void 0?Fn.indexBy:n,a=e.keys,o=a===void 0?Fn.keys:a,s=e.label,l=s===void 0?Fn.label:s,f=e.tooltipLabel,c=f===void 0?Fn.tooltipLabel:f,p=e.valueFormat,m=e.colors,v=m===void 0?Fn.colors:m,b=e.colorBy,w=b===void 0?Fn.colorBy:b,S=e.borderColor,_=S===void 0?Fn.borderColor:S,j=e.labelTextColor,E=j===void 0?Fn.labelTextColor:j,O=e.groupMode,C=O===void 0?Fn.groupMode:O,T=e.layout,R=T===void 0?Fn.layout:T,A=e.data,N=e.margin,D=e.width,M=e.height,I=e.padding,F=I===void 0?Fn.padding:I,L=e.innerPadding,q=L===void 0?Fn.innerPadding:L,U=e.valueScale,$=U===void 0?Fn.valueScale:U,V=e.indexScale,z=V===void 0?Fn.indexScale:V,W=e.initialHiddenIds,H=W===void 0?Fn.initialHiddenIds:W,Q=e.enableLabel,Y=Q===void 0?Fn.enableLabel:Q,K=e.labelSkipWidth,ee=K===void 0?Fn.labelSkipWidth:K,te=e.labelSkipHeight,oe=te===void 0?Fn.labelSkipHeight:te,ne=e.legends,fe=ne===void 0?Fn.legends:ne,re=e.legendLabel,ce=e.totalsOffset,he=ce===void 0?Fn.totalsOffset:ce,J=y.useState(H??[]),Me=J[0],we=J[1],Ee=y.useCallback((function(Ke){we((function(pt){return pt.indexOf(Ke)>-1?pt.filter((function(ve){return ve!==Ke})):[].concat(pt,[Ke])}))}),[]),Re=BA(r),ke=BA(l),Ne=BA(c),Ue=P3(p),X=Lr(),se=eqe(v,w),me=gW(_,X),Te=gW(E,X),de=(C==="grouped"?Sqe:Oqe)({layout:R,data:A,getIndex:Re,keys:o,width:D,height:M,getColor:se,padding:F,innerPadding:q,valueScale:$,indexScale:z,hiddenIds:Me,formatValue:Ue,getTooltipLabel:Ne,margin:N}),ue=de.bars,Ae=de.xScale,Pe=de.yScale,Fe=y.useMemo((function(){return ue.filter((function(Ke){return Ke.data.value!==null})).map((function(Ke,pt){return gn({},Ke,{index:pt})}))}),[ue]),Je=y.useCallback((function(Ke){var pt=Ke.width,ve=Ke.height;return!!Y&&!(ee>0&&pt<ee)&&!(oe>0&&ve<oe)}),[Y,ee,oe]),Nt=y.useMemo((function(){return o.map((function(Ke){var pt=ue.find((function(ve){return ve.data.id===Ke}));return gn({},pt,{data:gn({id:Ke},pt?.data,{hidden:Me.includes(Ke)})})}))}),[Me,o,ue]),$t=(t=$.reverse)!=null&&t,Rt=y.useMemo((function(){return fe.map((function(Ke){return[Ke,kqe({bars:Ke.dataFrom==="keys"?Nt:ue,direction:Ke.direction,from:Ke.dataFrom,groupMode:C,layout:R,legendLabel:re,reverse:$t})]}))}),[fe,Nt,ue,C,R,re,$t]),qt=y.useMemo((function(){return(function(Ke,pt,ve,ye,ct,$e,Xe){ye===void 0&&(ye=Fn.layout),ct===void 0&&(ct=Fn.groupMode);var We=[];if(Ke.length===0)return We;var et=new Map,jt=Ke[0].width,Ye=Ke[0].height;if(ct==="stacked"){var mt=new Map;Ke.forEach((function(At){var _t=At.data,gt=_t.indexValue,Ct=_t.value;yW(et,gt,Number(Ct)),Rqe(mt,gt,Number(Ct))})),mt.forEach((function(At,_t){var gt,Ct,Z,pe=et.get(_t)||0;ye==="vertical"?(gt=pt(_t),Ct=ve(At),Z=ve(At/2)):(gt=pt(At),Ct=ve(_t),Z=pt(At/2)),gt+=ye==="vertical"?jt/2:$e,Ct+=ye==="vertical"?-$e:Ye/2,We.push({key:"total_"+_t,x:gt,y:Ct,value:pe,formattedValue:Xe(pe),animationOffset:Z})}))}else if(ct==="grouped"){var Ft=new Map,Pt=new Map;Ke.forEach((function(At){var _t=At.data,gt=_t.indexValue,Ct=_t.value;yW(et,gt,Number(Ct)),Aqe(Ft,gt,Number(Ct)),Tqe(Pt,gt)})),Ft.forEach((function(At,_t){var gt,Ct,Z,pe=et.get(_t)||0,_e=Pt.get(_t);ye==="vertical"?(gt=pt(_t),Ct=ve(At),Z=ve(At/2)):(gt=pt(At),Ct=ve(_t),Z=pt(At/2)),gt+=ye==="vertical"?_e*jt/2:$e,Ct+=ye==="vertical"?-$e:_e*Ye/2,We.push({key:"total_"+_t,x:gt,y:Ct,value:pe,formattedValue:Xe(pe),animationOffset:Z})}))}return We})(ue,Ae,Pe,R,C,he,Ue)}),[ue,Ae,Pe,R,C,he,Ue]);return{bars:ue,barsWithValue:Fe,xScale:Ae,yScale:Pe,getIndex:Re,getLabel:ke,getTooltipLabel:Ne,formatValue:Ue,getColor:se,getBorderColor:me,getLabelColor:Te,shouldRenderBarLabel:Je,hiddenIds:Me,toggleSerie:Ee,legendsWithData:Rt,barTotals:qt}},"Ie"),Nqe=i(function(e){var t=e.data,n=e.springConfig,r=e.animate,a=e.layout,o=a===void 0?In.layout:a,s=Lr();return l_(t,{keys:i(function(l){return l.key},"keys"),from:i(function(l){return{x:o==="vertical"?l.x:l.animationOffset,y:o==="vertical"?l.animationOffset:l.y,labelOpacity:0}},"from"),enter:i(function(l){return{x:l.x,y:l.y,labelOpacity:1}},"enter"),update:i(function(l){return{x:l.x,y:l.y,labelOpacity:1}},"update"),leave:i(function(l){return{x:o==="vertical"?l.x:l.animationOffset,y:o==="vertical"?l.animationOffset:l.y,labelOpacity:0}},"leave"),config:n,immediate:!r,initial:r?void 0:null})((function(l,f){return d.jsx(mr.text,{x:l.x,y:l.y,fillOpacity:l.labelOpacity,style:gn({},s.labels.text,{pointerEvents:"none"}),fontWeight:"bold",fontSize:s.labels.text.fontSize,fontFamily:s.labels.text.fontFamily,textAnchor:o==="vertical"?"middle":"start",alignmentBaseline:o==="vertical"?"alphabetic":"middle",children:f.formattedValue},f.key)}))},"Ve"),Pqe=["isInteractive","animate","motionConfig","theme","renderWrapper"],Dqe=i(function(e){var t,n=e.data,r=e.indexBy,a=e.keys,o=e.margin,s=e.width,l=e.height,f=e.groupMode,c=e.layout,p=e.valueScale,m=e.indexScale,v=e.padding,b=e.innerPadding,w=e.axisTop,S=e.axisRight,_=e.axisBottom,j=_===void 0?In.axisBottom:_,E=e.axisLeft,O=E===void 0?In.axisLeft:E,C=e.enableGridX,T=C===void 0?In.enableGridX:C,R=e.enableGridY,A=R===void 0?In.enableGridY:R,N=e.gridXValues,D=e.gridYValues,M=e.layers,I=M===void 0?In.layers:M,F=e.barComponent,L=F===void 0?In.barComponent:F,q=e.enableLabel,U=q===void 0?In.enableLabel:q,$=e.label,V=e.labelSkipWidth,z=V===void 0?In.labelSkipWidth:V,W=e.labelSkipHeight,H=W===void 0?In.labelSkipHeight:W,Q=e.labelTextColor,Y=e.labelPosition,K=Y===void 0?In.labelPosition:Y,ee=e.labelOffset,te=ee===void 0?In.labelOffset:ee,oe=e.markers,ne=oe===void 0?In.markers:oe,fe=e.colorBy,re=e.colors,ce=e.defs,he=ce===void 0?In.defs:ce,J=e.fill,Me=J===void 0?In.fill:J,we=e.borderRadius,Ee=we===void 0?In.borderRadius:we,Re=e.borderWidth,ke=Re===void 0?In.borderWidth:Re,Ne=e.borderColor,Ue=e.annotations,X=Ue===void 0?In.annotations:Ue,se=e.legendLabel,me=e.tooltipLabel,Te=e.valueFormat,de=e.isInteractive,ue=de===void 0?In.isInteractive:de,Ae=e.tooltip,Pe=Ae===void 0?In.tooltip:Ae,Fe=e.onClick,Je=e.onMouseEnter,Nt=e.onMouseLeave,$t=e.legends,Rt=e.role,qt=Rt===void 0?In.role:Rt,Ke=e.ariaLabel,pt=e.ariaLabelledBy,ve=e.ariaDescribedBy,ye=e.isFocusable,ct=ye===void 0?In.isFocusable:ye,$e=e.barAriaLabel,Xe=e.barAriaLabelledBy,We=e.barAriaDescribedBy,et=e.barAriaHidden,jt=e.barAriaDisabled,Ye=e.initialHiddenIds,mt=e.enableTotals,Ft=mt===void 0?In.enableTotals:mt,Pt=e.totalsOffset,At=Pt===void 0?In.totalsOffset:Pt,_t=e.forwardedRef,gt=go(),Ct=gt.animate,Z=gt.config,pe=Mae(s,l,o),_e=pe.outerWidth,qe=pe.outerHeight,Ve=pe.margin,rt=pe.innerWidth,nt=pe.innerHeight,Qe=aie({indexBy:r,label:$,tooltipLabel:me,valueFormat:Te,colors:re,colorBy:fe,borderColor:Ne,labelTextColor:Q,groupMode:f,layout:c,data:n,keys:a,margin:Ve,width:rt,height:nt,padding:v,innerPadding:b,valueScale:p,indexScale:m,enableLabel:U,labelSkipWidth:z,labelSkipHeight:H,legends:$t,legendLabel:se,initialHiddenIds:Ye,totalsOffset:At}),ot=Qe.bars,ut=Qe.barsWithValue,st=Qe.xScale,lt=Qe.yScale,vt=Qe.getLabel,at=Qe.getTooltipLabel,kt=Qe.getBorderColor,bt=Qe.getLabelColor,Lt=Qe.shouldRenderBarLabel,Mt=Qe.toggleSerie,qr=Qe.legendsWithData,ka=Qe.barTotals,ui=Qe.getColor,ur=eie(c,(t=p?.reverse)!=null&&t,K,te),vo=l_(ut,{keys:i(function(He){return He.key},"keys"),from:i(function(He){return gn({borderColor:kt(He),color:He.color,height:0,labelColor:bt(He),labelOpacity:0},ur(He.width,He.height),{transform:"translate("+He.x+", "+(He.y+He.height)+")",width:He.width},c==="vertical"?{}:{height:He.height,transform:"translate("+He.x+", "+He.y+")",width:0})},"from"),enter:i(function(He){return gn({borderColor:kt(He),color:He.color,height:He.height,labelColor:bt(He),labelOpacity:1},ur(He.width,He.height),{transform:"translate("+He.x+", "+He.y+")",width:He.width})},"enter"),update:i(function(He){return gn({borderColor:kt(He),color:He.color,height:He.height,labelColor:bt(He),labelOpacity:1},ur(He.width,He.height),{transform:"translate("+He.x+", "+He.y+")",width:He.width})},"update"),leave:i(function(He){return gn({borderColor:kt(He),color:He.color,height:0,labelColor:bt(He),labelOpacity:0},ur(He.width,He.height),{labelY:0,transform:"translate("+He.x+", "+(He.y+He.height)+")",width:He.width},c==="vertical"?{}:gn({},ur(He.width,He.height),{labelX:0,height:He.height,transform:"translate("+He.x+", "+He.y+")",width:0}))},"leave"),config:Z,immediate:!Ct,initial:Ct?void 0:null}),zr=y.useMemo((function(){return{borderRadius:Ee,borderWidth:ke,enableLabel:U,isInteractive:ue,labelSkipWidth:z,labelSkipHeight:H,onClick:Fe,onMouseEnter:Je,onMouseLeave:Nt,getTooltipLabel:at,tooltip:Pe,isFocusable:ct,ariaLabel:$e,ariaLabelledBy:Xe,ariaDescribedBy:We,ariaHidden:et,ariaDisabled:jt}}),[Ee,ke,U,at,ue,H,z,Fe,Je,Nt,Pe,ct,$e,Xe,We,et,jt]),Wa=T7e(he,ot,Me,{dataKey:"data",targetKey:"data.fill"}),Jr={annotations:null,axes:null,bars:null,grid:null,legends:null,markers:null,totals:null};I.includes("annotations")&&(Jr.annotations=d.jsx(hqe,{bars:ot,annotations:X},"annotations")),I.includes("axes")&&(Jr.axes=d.jsx(d9e,{xScale:st,yScale:lt,width:rt,height:nt,top:w,right:S,bottom:j,left:O},"axes")),I.includes("bars")&&(Jr.bars=d.jsx(y.Fragment,{children:vo((function(He,qn){return y.createElement(L,gn({},zr,{bar:qn,style:He,shouldRenderLabel:Lt(qn),label:vt(qn.data)}))}))},"bars")),I.includes("grid")&&(Jr.grid=d.jsx(h9e,{width:rt,height:nt,xScale:T?st:null,yScale:A?lt:null,xValues:N,yValues:D},"grid")),I.includes("legends")&&(Jr.legends=d.jsx(pqe,{width:rt,height:nt,legends:qr,toggleSerie:Mt},"legends")),I.includes("markers")&&(Jr.markers=d.jsx(w7e,{markers:ne,width:rt,height:nt,xScale:st,yScale:lt},"markers")),I.includes("totals")&&Ft&&(Jr.totals=d.jsx(Nqe,{data:ka,springConfig:Z,animate:Ct,layout:c},"totals"));var Ga=gn({},zr,{margin:Ve,width:s,height:l,innerWidth:rt,innerHeight:nt,bars:ot,legendData:qr,enableLabel:U,xScale:st,yScale:lt,tooltip:Pe,getTooltipLabel:at,onClick:Fe,onMouseEnter:Je,onMouseLeave:Nt,getColor:ui});return d.jsx(y7e,{width:_e,height:qe,margin:Ve,defs:Wa,role:qt,ariaLabel:Ke,ariaLabelledBy:pt,ariaDescribedBy:ve,isFocusable:ct,ref:_t,children:I.map((function(He,qn){var Ii;return typeof He=="function"?d.jsx(y.Fragment,{children:y.createElement(He,Ga)},qn):(Ii=Jr?.[He])!=null?Ii:null}))})},"He"),Mqe=y.forwardRef((function(e,t){var n=e.isInteractive,r=n===void 0?In.isInteractive:n,a=e.animate,o=a===void 0?In.animate:a,s=e.motionConfig,l=s===void 0?In.motionConfig:s,f=e.theme,c=e.renderWrapper,p=qc(e,Pqe);return d.jsx(Aae,{animate:o,isInteractive:r,motionConfig:l,renderWrapper:c,theme:f,children:d.jsx(Dqe,gn({},p,{isInteractive:r,forwardedRef:t}))})})),Iqe=["isInteractive","renderWrapper","theme"],hT=i(function(e,t,n,r){return e.find((function(a){return O7e(a.x+t.left,a.y+t.top,a.width,a.height,n,r)}))},"Fe"),Fqe=i(function(e){var t,n=e.data,r=e.indexBy,a=e.keys,o=e.margin,s=e.width,l=e.height,f=e.groupMode,c=e.layout,p=e.valueScale,m=e.indexScale,v=e.padding,b=e.innerPadding,w=e.axisTop,S=e.axisRight,_=e.axisBottom,j=_===void 0?yr.axisBottom:_,E=e.axisLeft,O=E===void 0?yr.axisLeft:E,C=e.enableGridX,T=C===void 0?yr.enableGridX:C,R=e.enableGridY,A=R===void 0?yr.enableGridY:R,N=e.gridXValues,D=e.gridYValues,M=e.labelPosition,I=M===void 0?yr.labelPosition:M,F=e.labelOffset,L=F===void 0?yr.labelOffset:F,q=e.layers,U=q===void 0?yr.layers:q,$=e.renderBar,V=$===void 0?yr.renderBar:$,z=e.enableLabel,W=z===void 0?yr.enableLabel:z,H=e.label,Q=e.labelSkipWidth,Y=Q===void 0?yr.labelSkipWidth:Q,K=e.labelSkipHeight,ee=K===void 0?yr.labelSkipHeight:K,te=e.labelTextColor,oe=e.colorBy,ne=e.colors,fe=e.borderRadius,re=fe===void 0?yr.borderRadius:fe,ce=e.borderWidth,he=ce===void 0?yr.borderWidth:ce,J=e.borderColor,Me=e.annotations,we=Me===void 0?yr.annotations:Me,Ee=e.legendLabel,Re=e.tooltipLabel,ke=e.valueFormat,Ne=e.isInteractive,Ue=Ne===void 0?yr.isInteractive:Ne,X=e.tooltip,se=X===void 0?yr.tooltip:X,me=e.onClick,Te=e.onMouseEnter,de=e.onMouseLeave,ue=e.legends,Ae=e.pixelRatio,Pe=Ae===void 0?yr.pixelRatio:Ae,Fe=e.role,Je=e.forwardedRef,Nt=e.enableTotals,$t=Nt===void 0?yr.enableTotals:Nt,Rt=e.totalsOffset,qt=Rt===void 0?yr.totalsOffset:Rt,Ke=y.useRef(null),pt=Lr(),ve=Mae(s,l,o),ye=ve.margin,ct=ve.innerWidth,$e=ve.innerHeight,Xe=ve.outerWidth,We=ve.outerHeight,et=aie({indexBy:r,label:H,tooltipLabel:Re,valueFormat:ke,colors:ne,colorBy:oe,borderColor:J,labelTextColor:te,groupMode:f,layout:c,data:n,keys:a,margin:ye,width:ct,height:$e,padding:v,innerPadding:b,valueScale:p,indexScale:m,enableLabel:W,labelSkipWidth:Y,labelSkipHeight:ee,legends:ue,legendLabel:Ee,totalsOffset:qt}),jt=et.bars,Ye=et.barsWithValue,mt=et.xScale,Ft=et.yScale,Pt=et.getLabel,At=et.getTooltipLabel,_t=et.getBorderColor,gt=et.getLabelColor,Ct=et.shouldRenderBarLabel,Z=et.legendsWithData,pe=et.barTotals,_e=et.getColor,qe=Ere(),Ve=qe.showTooltipFromEvent,rt=qe.hideTooltip,nt=N9e({annotations:Wae({data:jt,annotations:we,getPosition:i(function(at){return{x:at.x,y:at.y}},"getPosition"),getDimensions:i(function(at){var kt=at.width,bt=at.height;return{width:kt,height:bt,size:Math.max(kt,bt)}},"getDimensions")})}),Qe=y.useMemo((function(){return{borderRadius:re,borderWidth:he,isInteractive:Ue,isFocusable:!1,labelSkipWidth:Y,labelSkipHeight:ee,margin:ye,width:s,height:l,innerWidth:ct,innerHeight:$e,bars:jt,legendData:Z,enableLabel:W,xScale:mt,yScale:Ft,tooltip:se,getTooltipLabel:At,onClick:me,onMouseEnter:Te,onMouseLeave:de,getColor:_e}}),[re,he,Ue,Y,ee,ye,s,l,ct,$e,jt,Z,W,mt,Ft,se,At,me,Te,de,_e]),ot=P3(ke),ut=eie(c,(t=p?.reverse)!=null&&t,I,L);y.useEffect((function(){if(Ke.current){Ke.current.width=Xe*Pe,Ke.current.height=We*Pe;var at=Ke.current.getContext("2d");at.scale(Pe,Pe),at.fillStyle=pt.background,at.fillRect(0,0,Xe,We),at.translate(ye.left,ye.top),U.forEach((function(kt){kt==="grid"?typeof pt.grid.line.strokeWidth=="number"&&pt.grid.line.strokeWidth>0&&(at.lineWidth=pt.grid.line.strokeWidth,at.strokeStyle=pt.grid.line.stroke,T&&rW(at,{width:ct,height:$e,scale:mt,axis:"x",values:N}),A&&rW(at,{width:ct,height:$e,scale:Ft,axis:"y",values:D})):kt==="axes"?m9e(at,{xScale:mt,yScale:Ft,width:ct,height:$e,top:w,right:S,bottom:j,left:O,theme:pt}):kt==="bars"?($v(at,pt.text),Ye.forEach((function(bt){V(at,gn({bar:bt,borderColor:_t(bt),borderRadius:re,borderWidth:he,label:Pt(bt.data),shouldRenderLabel:Ct(bt),labelStyle:gn({},pt.labels.text,{fill:gt(bt)})},ut(bt.width,bt.height)))}))):kt==="legends"?Z.forEach((function(bt){var Lt=bt[0],Mt=bt[1];dqe(at,gn({},Lt,{data:Mt,containerWidth:ct,containerHeight:$e,theme:pt}))})):kt==="annotations"?$9e(at,{annotations:nt,theme:pt}):kt==="totals"&&$t?(function(bt,Lt,Mt,qr){qr===void 0&&(qr=yr.layout),$v(bt,Mt.labels.text),bt.textBaseline=qr==="vertical"?"alphabetic":"middle",bt.textAlign=qr==="vertical"?"center":"start",Lt.forEach((function(ka){qv(bt,Mt.labels.text,ka.formattedValue,ka.x,ka.y)}))})(at,pe,pt,c):typeof kt=="function"&&kt(at,Qe)})),at.save()}}),[j,O,S,w,Ye,re,he,nt,T,A,_t,Pt,gt,N,D,f,l,$e,ct,Qe,U,c,Z,ye.left,ye.top,We,Xe,Pe,V,mt,Ft,Ct,pt,s,pe,$t,ot,ut]);var st=y.useCallback((function(at){if(jt&&Ke.current){var kt=VA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=hT(jt,ye,bt,Lt);Mt!==void 0?(Ve(y.createElement(se,gn({},Mt.data,{color:Mt.color,label:Mt.label,value:Number(Mt.data.value)})),at),at.type==="mouseenter"&&Te?.(Mt.data,at)):rt()}}),[rt,ye,Te,jt,Ve,se]),lt=y.useCallback((function(at){if(jt&&Ke.current){rt();var kt=VA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=hT(jt,ye,bt,Lt);Mt&&de?.(Mt.data,at)}}),[rt,ye,de,jt]),vt=y.useCallback((function(at){if(jt&&Ke.current){var kt=VA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=hT(jt,ye,bt,Lt);Mt!==void 0&&me?.(gn({},Mt.data,{color:Mt.color}),at)}}),[ye,me,jt]);return d.jsx("canvas",{ref:N7e(Ke,Je),width:Xe*Pe,height:We*Pe,style:{width:Xe,height:We,cursor:Ue?"auto":"normal"},onMouseEnter:Ue?st:void 0,onMouseMove:Ue?st:void 0,onMouseLeave:Ue?lt:void 0,onClick:Ue?vt:void 0,role:Fe})},"ze"),Lqe=y.forwardRef((function(e,t){var n=e.isInteractive,r=e.renderWrapper,a=e.theme,o=qc(e,Iqe);return d.jsx(Aae,{isInteractive:n,renderWrapper:r,theme:a,animate:!1,children:d.jsx(Fqe,gn({},o,{isInteractive:n,forwardedRef:t}))})})),$qe=["defaultWidth","defaultHeight","onResize","debounceResize"],qqe=y.forwardRef((function(e,t){var n=e.defaultWidth,r=e.defaultHeight,a=e.onResize,o=e.debounceResize,s=qc(e,$qe);return d.jsx(Tae,{defaultWidth:n,defaultHeight:r,onResize:a,debounceResize:o,children:i(function(l){var f=l.width,c=l.height;return d.jsx(Mqe,gn({},s,{width:f,height:c,ref:t}))},"children")})})),zqe=["defaultWidth","defaultHeight","onResize","debounceResize"];y.forwardRef((function(e,t){var n=e.defaultWidth,r=e.defaultHeight,a=e.onResize,o=e.debounceResize,s=qc(e,zqe);return d.jsx(Tae,{defaultWidth:n,defaultHeight:r,onResize:a,debounceResize:o,children:i(function(l){var f=l.width,c=l.height;return d.jsx(Lqe,gn({},s,{width:f,height:c,ref:t}))},"children")})}));const Uqe={opportunity:.2,"proposal-sent":.5,"in-negociation":.8,delayed:.3},Bqe=new Date(new Date().setMonth(new Date().getMonth()-6)).toISOString(),bW="en-US",Vqe="USD",Hqe=y.memo(()=>{const e=navigator?navigator.languages||[navigator.language]:[bW],{data:t,isPending:n}=wa("deals",{pagination:{perPage:100,page:1},sort:{field:"created_at",order:"ASC"},filter:{"created_at@gte":Bqe}}),r=y.useMemo(()=>{if(!t)return[];const s=t.reduce((f,c)=>{const p=cN(c.created_at??new Date).toISOString();return f[p]||(f[p]=[]),f[p].push(c),f},{});return Object.keys(s).map(f=>({date:fc(f,"MMM"),won:s[f].filter(c=>c.stage==="won").reduce((c,p)=>{const m=p.amount??0;return isNaN(m)||(c+=m),c},0),pending:s[f].filter(c=>!["won","lost"].includes(c.stage)).reduce((c,p)=>{const m=p.amount??0,v=Uqe[p.stage]??0;return!isNaN(m)&&!isNaN(v)&&(c+=m*v),c},0),lost:s[f].filter(c=>c.stage==="lost").reduce((c,p)=>{const m=p.amount??0;return isNaN(m)||(c-=m),c},0)})).filter(f=>!isNaN(f.won)&&!isNaN(f.pending)&&!isNaN(f.lost))},[t]);if(n||r.length===0)return null;const a=r.reduce((s,l)=>(s.min=Math.min(s.min,l.lost),s.max=Math.max(s.max,l.won+l.pending),s),{min:0,max:0}),o={min:a.min===0&&a.max===0?-100:a.min*1.2,max:a.min===0&&a.max===0?100:a.max*1.2};return d.jsxs("div",{className:"flex flex-col",children:[d.jsxs("div",{className:"flex items-center mb-4",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(kQ,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"Upcoming Deal Revenue"})]}),d.jsx("div",{className:"h-[400px]",children:d.jsx(qqe,{data:r,indexBy:"date",keys:["won","pending","lost"],colors:["#61cdbb","#97e3d5","#e25c3b"],margin:{top:30,right:50,bottom:30,left:0},padding:.3,valueScale:{type:"linear",min:o.min,max:o.max},indexScale:{type:"band",round:!0},enableGridX:!0,enableGridY:!1,enableLabel:!1,tooltip:i(({value:s,indexValue:l})=>d.jsxs("div",{className:"p-2 bg-secondary rounded shadow inline-flex items-center gap-1 text-secondary-foreground",children:[d.jsxs("strong",{children:[l,": "]})," ",s>0?"+":"",s.toLocaleString(e.at(0)??bW,{style:"currency",currency:Vqe})]}),"tooltip"),axisTop:{tickSize:0,tickPadding:12,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},axisBottom:{legendPosition:"middle",legendOffset:50,tickSize:0,tickPadding:12,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},axisLeft:null,axisRight:{format:i(s=>`${Math.abs(s/1e3)}k`,"format"),tickValues:8,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},markers:[{axis:"y",value:0,lineStyle:{strokeOpacity:0},textStyle:{fill:"#2ebca6"},legend:"Won",legendPosition:"top-left",legendOrientation:"vertical"},{axis:"y",value:0,lineStyle:{stroke:"#f47560",strokeWidth:1},textStyle:{fill:"#e25c3b"},legend:"Lost",legendPosition:"bottom-left",legendOrientation:"vertical"}]})})]})}),Wqe=i(e=>{const t=xt(),n=Wt(e),{filterValues:r,setFilters:a}=Uw(e),o=hd();if(!n)throw new Error("<ListNoResults> must be used inside a <List> component");return d.jsx("div",{className:"p-6",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:r&&a&&Object.keys(r).length>0?d.jsxs(d.Fragment,{children:[t("ra.navigation.no_filtered_results",{resource:n,name:o(n,0),_:"No results found with the current filters."})," ",d.jsx(Le,{variant:"outline",size:"sm",onClick:i(()=>a({},[]),"onClick"),children:t("ra.navigation.clear_filters",{_:"Clear filters"})})]}):t("ra.navigation.no_results",{resource:n,name:o(n,0),_:"No results found."})})})},"ListNoResults"),Gqe=i(e=>{const{children:t,linkType:n,rowClick:r,style:a}=e,o=Wt(e),s=Vt(e),l=ja(),f=typeof n=="function"||typeof r=="function",c=eK({link:f?!1:n??r,resource:o}),p=rK(),m=Et(async()=>{if(!f||!s)return;const v=typeof n=="function"?n(s,s.id):typeof r=="function"?(w,S)=>r(w.id,S,w):!1,b=await p({record:s,resource:o,link:v});b===!1||b==null||l(b)});return s?f?d.jsx("li",{className:"w-full",children:d.jsx("button",{onClick:m,style:a,className:"w-full text-left hover:bg-muted focus: bg-muted focus:outline-none",children:t})}):c?d.jsx("li",{className:"w-full",children:d.jsx(fn,{to:c,style:a,className:"block w-full hover:bg-muted focus:bg-muted focus:outline-none",children:t})}):d.jsx("li",{className:"w-full",children:t}):null},"SimpleListItem"),pT=i(({className:e})=>d.jsx("span",{className:Se("bg-gray-300 flex",e),children:" "}),"ListPlaceholder"),Kqe=i(e=>{const{className:t,hasLeftAvatarOrIcon:n,hasRightAvatarOrIcon:r,hasSecondaryText:a,hasTertiaryText:o,nbFakeLines:s=5,...l}=e;return PK(1e3)?d.jsx("ul",{className:t,...l,children:Yqe(s,c=>d.jsxs("li",{className:"flex items-center space-x-3 p-3",children:[n&&d.jsx("div",{className:"w-10 h-10 bg-gray-300 rounded-full flex-shrink-0",children:" "}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"mb-1",children:[d.jsx(pT,{className:"w-1/3 inline-block mb-1"}),o&&d.jsx("span",{className:"float-right opacity-55 min-w-[10vw]",children:d.jsx(pT,{})})]}),a&&d.jsx(pT,{className:"w-1/4"})]}),r&&d.jsx("div",{className:"w-10 h-10 bg-gray-300 rounded-full flex-shrink-0",children:" "})]},c))}):null},"SimpleListLoading"),Yqe=i((e,t)=>Array.from({length:e},(n,r)=>t(r)),"times"),Qqe=i(e=>{const{className:t,empty:n=Zqe,leftAvatar:r,leftIcon:a,linkType:o,rowClick:s,primaryText:l,rightAvatar:f,rightIcon:c,secondaryText:p,tertiaryText:m,resource:v,...b}=e,{data:w,isPending:S,total:_}=Uw(e);return S===!0?d.jsx(Kqe,{className:t,hasLeftAvatarOrIcon:!!a||!!r,hasRightAvatarOrIcon:!!c||!!f,hasSecondaryText:!!p,hasTertiaryText:!!m}):w==null||w.length===0||_===0?n||null:d.jsx("ul",{className:t,...hme(b),children:d.jsx(xme,{data:w,total:_,render:i((j,E)=>d.jsx(Gqe,{rowIndex:E,linkType:o,rowClick:s,resource:v,children:d.jsx(Xqe,{leftAvatar:r,leftIcon:a,primaryText:l,rightAvatar:f,rightIcon:c,secondaryText:p,tertiaryText:m,rowIndex:E})},j.id),"render")})})},"SimpleList"),Xqe=i(e=>{const{leftAvatar:t,leftIcon:n,primaryText:r,rightAvatar:a,rightIcon:o,secondaryText:s,tertiaryText:l}=e,f=Wt(e),c=Vt(e),p=Oc(f),m=xt(),v=i((b,w)=>{const S=w(b,b.id);return typeof S=="string"&&(S.startsWith("http")||S.startsWith("data:"))?d.jsx("img",{src:S,alt:"",className:"w-10 h-10 rounded-full object-cover"}):d.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center text-sm",children:S})},"renderAvatar");return c?d.jsxs("div",{className:"flex items-center space-x-3 p-3",children:[n&&d.jsx("div",{className:"flex-shrink-0",children:n(c,c.id)}),t&&d.jsx("div",{className:"flex-shrink-0",children:v(c,t)}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"text-sm font-medium truncate",children:r?typeof r=="string"?m(r,{...c,_:r}):y.isValidElement(r)?r:r(c,c.id):p(c)}),!!l&&d.jsx("div",{className:"text-xs text-muted-foreground ml-2",children:typeof l=="string"?m(l,{...c,_:l}):y.isValidElement(l)?l:l(c,c.id)})]}),!!s&&d.jsx("div",{className:"text-sm text-muted-foreground truncate",children:typeof s=="string"?m(s,{...c,_:s}):y.isValidElement(s)?s:s(c,c.id)})]}),(a||o)&&d.jsxs("div",{className:"flex-shrink-0 flex items-center space-x-2",children:[a&&v(c,a),o&&o(c,c.id)]})]}):null},"SimpleListItemContent"),Zqe=d.jsx(Wqe,{}),Jqe=i(()=>{const{identity:e}=Jn(),{data:t,total:n,isPending:r}=wa("contacts",{pagination:{page:1,perPage:10},sort:{field:"last_seen",order:"DESC"},filter:{status:"hot",sales_id:e?.id}},{enabled:Number.isInteger(e?.id)});return d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(FM,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"Hot Contacts"}),d.jsx(Ni,{children:d.jsxs(io,{children:[d.jsx(oo,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",className:"ml-auto text-muted-foreground",asChild:!0,children:d.jsx(fn,{to:"/contacts/create",children:d.jsx(eo,{className:"w-4 h-4 text-primary"})})})}),d.jsx(so,{children:"Create contact"})]})})]}),d.jsx(pn,{className:"py-0",children:d.jsx(Qqe,{linkType:"show",data:t,total:n,isPending:r,resource:"contacts",className:"[&>li:first-child>a]:rounded-t-xl [&>li:last-child>a]:rounded-b-xl",primaryText:i(a=>`${a.first_name} ${a.last_name}`,"primaryText"),secondaryText:i(a=>d.jsxs(d.Fragment,{children:[a.title," at ",a.company_name]}),"secondaryText"),leftAvatar:i(a=>d.jsx(os,{record:a}),"leftAvatar"),empty:d.jsxs("div",{className:"p-4",children:[d.jsx("p",{className:"text-sm mb-4",children:'Contacts with a "hot" status will appear here.'}),d.jsx("p",{className:"text-sm",children:'Change the status of a contact by adding a note to that contact and clicking on "show options".'})]})})})]})},"HotContacts"),eze=i(()=>{const{identity:e}=Jn(),{total:t}=wa("tasks",{pagination:{page:1,perPage:1},filter:{sales_id:e?.id}},{enabled:!!e});return t?null:d.jsx("p",{className:"text-sm",children:"Tasks added to your contacts will appear here."})},"TasksListEmpty"),hg=i(({title:e,filter:t})=>{const{identity:n}=Jn(),{data:r,total:a,isPending:o}=wa("tasks",{pagination:{page:1,perPage:100},sort:{field:"due_date",order:"ASC"},filter:{...t,sales_id:n?.id}},{enabled:!!n}),s=Bw({data:r,isPending:o,resource:"tasks",perPage:5});return o||!r||!a?null:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground font-medium mb-2",children:e}),d.jsx(fd,{value:"tasks",children:d.jsx(iy,{value:s,children:d.jsx(Ane,{showContact:!0})})}),a>s.perPage&&d.jsx("div",{className:"flex justify-center",children:d.jsx("a",{href:"#",onClick:i(l=>{s.setPerPage(s.perPage+10),l.preventDefault()},"onClick"),className:"text-sm underline hover:no-underline",children:"Load more"})})]})},"TasksListFilter"),iie=new Date,tze=Z0e(iie),nze=tze<5,xW=ebe().toISOString(),wW=Xye().toISOString(),_W=Zye().toISOString(),SW=Qye(iie,{weekStartsOn:0}).toISOString(),pg={overdue:{"done_date@is":null,"due_date@lt":xW},today:{"done_date@is":null,"due_date@gte":xW,"due_date@lte":wW},tomorrow:{"done_date@is":null,"due_date@gt":wW,"due_date@lt":_W},thisWeek:{"done_date@is":null,"due_date@gte":_W,"due_date@lte":SW},later:{"done_date@is":null,"due_date@gt":SW}},rze=i(()=>d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(NQ,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground flex-1",children:"Upcoming Tasks"}),d.jsx(Rne,{display:"icon",selectContact:!0})]}),d.jsx(pn,{className:"p-4 mb-2",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx(eze,{}),d.jsx(hg,{title:"Overdue",filter:pg.overdue}),d.jsx(hg,{title:"Today",filter:pg.today}),d.jsx(hg,{title:"Tomorrow",filter:pg.tomorrow}),nze&&d.jsx(hg,{title:"This week",filter:pg.thisWeek}),d.jsx(hg,{title:"Later",filter:pg.later})]})})]}),"TasksList"),aze=i(()=>{const{data:e,total:t,isPending:n}=wa("contacts",{pagination:{page:1,perPage:1}}),{total:r,isPending:a}=wa("contactNotes",{pagination:{page:1,perPage:1}}),{total:o,isPending:s}=wa("deals",{pagination:{page:1,perPage:1}});return n||a||s?null:t?r?d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6 mt-1",children:[d.jsx("div",{className:"md:col-span-3",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[null,d.jsx(Jqe,{})]})}),d.jsx("div",{className:"md:col-span-6",children:d.jsxs("div",{className:"flex flex-col gap-6",children:[o?d.jsx(Hqe,{}):null,d.jsx(n6e,{})]})}),d.jsx("div",{className:"md:col-span-3",children:d.jsx(rze,{})})]}):d.jsx(SV,{step:2,contactId:e?.[0]?.id}):d.jsx(SV,{step:1})},"Dashboard"),ize=y.lazy(()=>$p(()=>import("./DealList-BvoXZ_PI.js"),[],import.meta.url)),oze={list:ize},sze=y.createContext(void 0),Y_=i(()=>y.useContext(sze),"useUserMenu"),lze=i(()=>{const{darkModeLogo:e,lightModeLogo:t,title:n}=Ha(),r=Fr(),o=[{path:"/",pattern:"/"},{path:"/contacts",pattern:"/contacts/*"},{path:"/companies",pattern:"/companies/*"},{path:"/deals",pattern:"/deals/*"}].find(s=>rp(s.pattern,r.pathname))?.path||!1;return d.jsx("header",{className:"bg-secondary fixed top-0 left-0 right-0 z-50 border-b border-border",children:d.jsx("div",{className:"px-4",children:d.jsxs("div",{className:"flex justify-between items-center flex-1",children:[d.jsx(cze,{darkLogo:e,lightLogo:t,title:n}),d.jsxs("nav",{className:"flex","aria-label":"Main navigation",children:[d.jsx(Ob,{label:"Dashboard",to:"/",isActive:o==="/"}),d.jsx(Ob,{label:"Contacts",to:"/contacts",isActive:o==="/contacts"}),d.jsx(Ob,{label:"Companies",to:"/companies",isActive:o==="/companies"}),d.jsx(Ob,{label:"Deals",to:"/deals",isActive:o==="/deals"})]}),d.jsxs("div",{className:"flex items-center",children:[d.jsx(qZ,{}),d.jsx(zZ,{}),d.jsxs(FZ,{children:[d.jsx(dze,{}),d.jsx(fze,{}),d.jsx(hze,{}),d.jsx(Ive,{resource:"sales",action:"list",children:d.jsx(uze,{})}),d.jsx(ov,{}),d.jsx(c4,{className:"font-normal",children:d.jsxs("div",{className:"text-xs text-muted-foreground",children:["Version ","0.12.2"]})})]})]})]})})})},"Header"),cze=i(({darkLogo:e,lightLogo:t,title:n})=>d.jsxs(fn,{to:"/",className:"flex items-center gap-2 text-secondary-foreground no-underline hover:opacity-80 transition-opacity",children:[d.jsx("img",{className:"[.light_&]:hidden h-6",src:e,alt:`${n} logo`}),d.jsx("img",{className:"[.dark_&]:hidden h-6",src:t,alt:`${n} logo`}),d.jsx("h1",{className:"text-xl font-semibold",children:n})]}),"Logo"),Ob=i(({label:e,to:t,isActive:n})=>d.jsx(fn,{to:t,className:`px-6 py-3 text-sm font-medium transition-colors border-b-2 ${n?"text-secondary-foreground border-secondary-foreground":"text-secondary-foreground/70 border-transparent hover:text-secondary-foreground/80"}`,children:e}),"NavigationTab"),uze=i(()=>{const{onClose:e}=Y_()??{};return d.jsx(lr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/sales",className:"flex items-center gap-2",children:[d.jsx(IQ,{className:"h-4 w-4"}),"Users"]})})},"UsersMenu"),dze=i(()=>{const{onClose:e}=Y_()??{};return d.jsx(lr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/settings",className:"flex items-center gap-2",children:[d.jsx(fN,{className:"h-4 w-4"}),"My info"]})})},"ConfigurationMenu"),fze=i(()=>{const{onClose:e}=Y_()??{};return d.jsx(lr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/database",className:"flex items-center gap-2",children:[d.jsx(ev,{className:"h-4 w-4"}),"Database"]})})},"DatabaseMenu"),hze=i(()=>{const{onClose:e}=Y_()??{};return d.jsx(lr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/integrations",className:"flex items-center gap-2",children:[d.jsx(f_e,{className:"h-4 w-4"}),"Integrations"]})})},"IntegrationsMenu"),pze=i(({children:e})=>d.jsxs(d.Fragment,{children:[d.jsx(lze,{}),d.jsx("main",{className:"max-w-screen-xl mx-auto pt-20 px-4",id:"main-content",children:d.jsx(mx,{FallbackComponent:UZ,children:d.jsx(y.Suspense,{fallback:d.jsx(sn,{className:"h-12 w-12 rounded-full"}),children:e})})}),d.jsx(N1,{})]}),"Layout"),oie=i(()=>d.jsx("div",{className:"max-w-screen-xl mx-auto h-screen pt-8",children:d.jsx("div",{className:"h-full",children:d.jsxs("div",{className:"max-w-sm mx-auto h-full flex flex-col justify-center gap-8",children:[d.jsx(sn,{className:"w-full h-[100px]"}),d.jsx(sn,{className:"w-4/5 h-[50px]"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-2/5 h-9"})]})})}),"LoginSkeleton"),iD=i(()=>{const e=Nn(),t=xn(),{darkModeLogo:n,title:r}=Ha(),{data:a,isPending:o}=Qr({queryKey:["init"],queryFn:i(async()=>t.isInitialized(),"queryFn")}),{isPending:s,mutate:l}=Mr({mutationKey:["signup"],mutationFn:i(async w=>t.signUp(w),"mutationFn"),onSuccess:i(w=>{f({email:w.email,password:w.password,redirectTo:"/contacts"}).then(()=>{c("Initial user successfully created"),e.invalidateQueries({queryKey:["auth","canAccess"]})})},"onSuccess"),onError:i(()=>{c("An error occurred. Please try again.")},"onError")}),f=jY(),c=Bt(),{register:p,handleSubmit:m,formState:{isValid:v}}=ly({mode:"onChange"});if(o)return d.jsx(oie,{});if(a)return d.jsx(bw,{to:"/login"});const b=i(async w=>{l(w)},"onSubmit");return d.jsxs("div",{className:"h-screen p-8",children:[d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx("img",{src:n,alt:r,width:24,className:"filter brightness-0 invert"}),d.jsx("h1",{className:"text-xl font-semibold",children:r})]}),d.jsx("div",{className:"h-full",children:d.jsxs("div",{className:"max-w-sm mx-auto h-full flex flex-col justify-center gap-4",children:[d.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Welcome to CRM"}),d.jsx("p",{className:"text-base mb-4",children:"Create the first user account to complete the setup."}),d.jsxs("form",{onSubmit:m(b),className:"space-y-4",children:[d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"first_name",children:"First name"}),d.jsx(Sr,{...p("first_name",{required:!0}),id:"first_name",type:"text",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"last_name",children:"Last name"}),d.jsx(Sr,{...p("last_name",{required:!0}),id:"last_name",type:"text",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"email",children:"Email"}),d.jsx(Sr,{...p("email",{required:!0}),id:"email",type:"email",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"password",children:"Password"}),d.jsx(Sr,{...p("password",{required:!0}),id:"password",type:"password",required:!0})]}),d.jsx("div",{className:"flex justify-between items-center mt-8",children:d.jsx(Le,{type:"submit",disabled:!v||s,className:"w-full",children:s?d.jsxs(d.Fragment,{children:[d.jsx(Rc,{className:"w-4 h-4 animate-spin mr-2"}),"Creating..."]}):"Create account"})})]})]})})]})},"SignupPage");iD.path="/sign-up";const mze=i((e,t)=>e==="admin"?!0:t.resource!=="sales","canAccess"),mT=rAe(Ln,{getIdentity:i(async()=>{const e=await sie();if(e==null)throw new Error;return{id:e.id,fullName:`${e.first_name} ${e.last_name}`,avatar:e.avatar?.src}},"getIdentity")});async function Gs(){if(Gs._is_initialized_cache==null){const{data:e}=await Ln.from("init_state").select("is_initialized");Gs._is_initialized_cache=e?.at(0)?.is_initialized>0}return Gs._is_initialized_cache}i(Gs,"getIsInitialized");(e=>{e._is_initialized_cache=null})(Gs||(Gs={}));const gze={...mT,login:i(async e=>{const t=await mT.login(e);return Ub=void 0,t},"login"),checkAuth:i(async e=>{if(window.location.pathname==="/set-password"||window.location.hash.includes("#/set-password")||window.location.pathname==="/forgot-password"||window.location.hash.includes("#/forgot-password")||window.location.pathname==="/change-password"||window.location.hash.includes("#/change-password")||window.location.pathname==="/otp-login"||window.location.hash.includes("#/otp-login")||window.location.pathname==="/sign-up"||window.location.hash.includes("#/sign-up"))return;if(!await Gs())throw await Ln.auth.signOut(),{redirectTo:"/sign-up",message:!1};return mT.checkAuth(e)},"checkAuth"),canAccess:i(async e=>{if(!await Gs())return!1;const n=await sie();if(n==null)return!1;const r=n.administrator?"admin":"user";return mze(r,e)},"canAccess")};let Ub;const sie=i(async()=>{if(Ub!=null)return Ub;const{data:e,error:t}=await Ln.auth.getSession();if(e?.session?.user==null||t)return;const{data:n,error:r}=await Ln.from("sales").select("id, first_name, last_name, avatar, administrator").match({user_id:e?.session?.user.id}).single();if(!(n==null||r))return Ub=n,n},"getSaleFromCache");async function vze(e,t,n){const r={};t&&(r.id=t);const a={};t&&(a.company_id=t);const[o,s,l,f]=await Promise.all([yze(e,r),bze(e,a),xze(e,a),wze(e,a)]);return[...o,...s,...l,...f].sort((c,p)=>c.date&&p.date?c.date.localeCompare(p.date)*-1:0).slice(0,250)}i(vze,"getActivityLog");const yze=i(async(e,t)=>{const{data:n}=await e.getList("companies",{filter:t,pagination:{page:1,perPage:250},sort:{field:"created_at",order:"DESC"}});return n.map(r=>({id:`company.${r.id}.created`,type:kte,company_id:r.id,company:r,sales_id:r.sales_id,date:r.created_at}))},"getNewCompanies");async function bze(e,t){const{data:n}=await e.getList("contacts",{filter:t,pagination:{page:1,perPage:250},sort:{field:"first_seen",order:"DESC"}}),r={};if(t.sales_id&&(r.sales_id=t.sales_id),t.company_id){const l=n.map(f=>f.id).join(",");r["contact_id@in"]=`(${l})`}const{data:a}=await e.getList("contactNotes",{filter:r,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}}),o=n.map(l=>({id:`contact.${l.id}.created`,type:Ate,company_id:l.company_id,sales_id:l.sales_id,contact:l,date:l.first_seen})),s=a.map(l=>({id:`contactNote.${l.id}.created`,type:Tte,sales_id:l.sales_id,contactNote:l,date:l.date}));return[...o,...s]}i(bze,"getNewContactsAndNotes");async function xze(e,t){const{data:n}=await e.getList("deals",{filter:t,pagination:{page:1,perPage:250},sort:{field:"created_at",order:"DESC"}}),r={};if(t.sales_id&&(r.sales_id=t.sales_id),t.company_id){const l=n.map(f=>f.id).join(",");r["deal_id@in"]=`(${l})`}const{data:a}=await e.getList("dealNotes",{filter:r,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}}),o=n.map(l=>({id:`deal.${l.id}.created`,type:Nte,company_id:l.company_id,sales_id:l.sales_id,deal:l,date:l.created_at})),s=a.map(l=>({id:`dealNote.${l.id}.created`,type:Pte,sales_id:l.sales_id,dealNote:l,date:l.date}));return[...o,...s]}i(xze,"getNewDealsAndNotes");async function wze(e,t){const n={};t.sales_id&&(n.sales_id=t.sales_id),t.company_id&&(n.company_id=t.company_id);const{data:r}=await e.getList("companyNotes",{filter:n,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}});return r.map(o=>({id:`companyNote.${o.id}.created`,type:Rte,sales_id:o.sales_id,companyNote:o,date:o.date}))}i(wze,"getNewCompanyNotes");async function _ze(e){return e.website?{src:`https://favicon.show/${e.website.replace(/^https?:\/\//,"").replace(/\/$/,"")}`,title:"Company favicon"}:null}i(_ze,"getCompanyAvatar");async function Sze(e,t={}){const{timeout:n=2e3}=t,r=new AbortController,a=setTimeout(()=>r.abort(),n),o=await fetch(e,{...t,signal:r.signal});return clearTimeout(a),o}i(Sze,"fetchWithTimeout");const jze=["gmail.com","yahoo.com","hotmail.com","aol.com","hotmail.co.uk","hotmail.fr","msn.com","yahoo.fr","wanadoo.fr","orange.fr","comcast.net","yahoo.co.uk","yahoo.com.br","yahoo.co.in","live.com","rediffmail.com","free.fr","gmx.de","web.de","yandex.ru","ymail.com","libero.it","outlook.com","uol.com.br","bol.com.br","mail.ru","cox.net","hotmail.it","sbcglobal.net","sfr.fr","live.fr","verizon.net","live.co.uk","googlemail.com","yahoo.es","ig.com.br","live.nl","bigpond.com","terra.com.br","yahoo.it","neuf.fr","yahoo.de","alice.it","rocketmail.com","att.net","laposte.net","facebook.com","bellsouth.net","yahoo.in","hotmail.es","charter.net","yahoo.ca","yahoo.com.au","rambler.ru","hotmail.de","tiscali.it","shaw.ca","yahoo.co.jp","sky.com","earthlink.net","optonline.net","freenet.de","t-online.de","aliceadsl.fr","virgilio.it","home.nl","qq.com","telenet.be","me.com","yahoo.com.ar","tiscali.co.uk","yahoo.com.mx","voila.fr","gmx.net","mail.com","planet.nl","tin.it","live.it","ntlworld.com","arcor.de","yahoo.co.id","frontiernet.net","hetnet.nl","live.com.au","yahoo.com.sg","zonnet.nl","club-internet.fr","juno.com","optusnet.com.au","blueyonder.co.uk","bluewin.ch","skynet.be","sympatico.ca","windstream.net","mac.com","centurytel.net","chello.nl","live.ca","aim.com","bigpond.net.au","online.de","apple.com"];async function Eze(e){const t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(o=>o.toString(16).padStart(2,"0")).join("")}i(Eze,"hash");async function Cze(e){return`https://www.gravatar.com/avatar/${await Eze(e)}?d=404`}i(Cze,"getGravatarUrl");async function Oze(e){if(jze.includes(e))return null;try{const t=`https://${e}/favicon.ico`;if((await Sze(t)).ok)return t}catch{return null}return null}i(Oze,"getFaviconUrl");async function kze(e){if(!e.email_jsonb||!e.email_jsonb.length)return null;for(const{email:t}of e.email_jsonb){const n=await Cze(t);try{if((await fetch(n)).ok)return n}catch{}const r=t.split("@")[1],a=await Oze(r);if(a)return a}return null}i(kze,"getContactAvatar");const jW=wd()||{url:"https://placeholder.supabase.co",anonKey:"placeholder-key"},Co=wAe({instanceUrl:jW.url,apiKey:jW.anonKey,supabaseClient:Ln,sortOrder:"asc,desc.nullslast"}),EW=i(async e=>{let t=e.data.logo;return typeof t!="object"||t===null||!t.src?t=await _ze(e.data):t.rawFile instanceof File&&await Bb(t),{...e,data:{...e.data,logo:t}}},"processCompanyLogo");async function CW(e){const{data:t}=e;if(t.avatar?.src||!t.email_jsonb||!t.email_jsonb.length)return e;const n=await kze(t),r={...t,avatar:{src:n||void 0}};return{...e,data:r}}i(CW,"processContactAvatar");const Rze={...Co,async getList(e,t){return e==="companies"?Co.getList("companies_summary",t):e==="contacts"?Co.getList("contacts_summary",t):Co.getList(e,t)},async getOne(e,t){return e==="companies"?Co.getOne("companies_summary",t):e==="contacts"?Co.getOne("contacts_summary",t):Co.getOne(e,t)},async signUp({email:e,password:t,first_name:n,last_name:r}){const{data:a,error:o}=await Ln.functions.invoke("setup",{method:"POST",body:{email:e,password:t,first_name:n,last_name:r}});if(!a||o)throw console.error("signUp.error",o),new Error("Failed to create account");return Gs._is_initialized_cache=!0,{id:a.data.id,email:e,password:t}},async salesCreate(e){const{data:t,error:n}=await Ln.functions.invoke("users",{method:"POST",body:e});if(!t||n)throw console.error("salesCreate.error",n),new Error("Failed to create account manager");return t},async salesUpdate(e,t){const{email:n,first_name:r,last_name:a,administrator:o,avatar:s,disabled:l}=t,{data:f,error:c}=await Ln.functions.invoke("users",{method:"PATCH",body:{sales_id:e,email:n,first_name:r,last_name:a,administrator:o,disabled:l,avatar:s}});if(!f||c)throw console.error("salesCreate.error",c),new Error("Failed to update account manager");return t},async resendInvite(e){const{data:t,error:n}=await Ln.functions.invoke("users",{method:"PUT",body:{sales_id:e,action:"invite"}});if(!t||n)throw console.error("resendInvite.error",n),new Error("Failed to resend invitation");return t},async resetPassword(e){const{data:t,error:n}=await Ln.functions.invoke("users",{method:"PUT",body:{sales_id:e,action:"reset"}});if(!t||n)throw console.error("resetPassword.error",n),new Error("Failed to send password reset");return t},async updatePassword(e){const{data:t,error:n}=await Ln.functions.invoke("updatePassword",{method:"PATCH",body:{sales_id:e}});if(!t||n)throw console.error("passwordUpdate.error",n),new Error("Failed to update password");return t},async unarchiveDeal(e){const{data:t}=await Co.getList("deals",{filter:{stage:e.stage},pagination:{page:1,perPage:1e3},sort:{field:"index",order:"ASC"}}),n=t.map((r,a)=>({...r,index:r.id===e.id?0:a+1,archived_at:r.id===e.id?null:r.archived_at}));return await Promise.all(n.map(r=>Co.update("deals",{id:r.id,data:r,previousData:t.find(a=>a.id===r.id)})))},async getActivityLog(e){return vze(Co,e)},async isInitialized(){return Gs()},async mergeContacts(e,t){const{data:n,error:r}=await Ln.functions.invoke("mergeContacts",{method:"POST",body:{loserId:e,winnerId:t}});if(r)throw console.error("mergeContacts.error",r),new Error("Failed to merge contacts");return n},async mergeCompanies(e,t){const{data:n,error:r}=await Ln.functions.invoke("mergeCompanies",{method:"POST",body:{loserId:e,winnerId:t}});if(r)throw console.error("mergeCompanies.error",r),new Error("Failed to merge companies");return n}},Aze=She(Rze,[{resource:"contactNotes",beforeSave:i(async(e,t,n)=>{if(e.attachments)for(const r of e.attachments)await Bb(r);return e},"beforeSave")},{resource:"dealNotes",beforeSave:i(async(e,t,n)=>{if(e.attachments)for(const r of e.attachments)await Bb(r);return e},"beforeSave")},{resource:"sales",beforeSave:i(async(e,t,n)=>(e.avatar&&await Bb(e.avatar),e),"beforeSave")},{resource:"contacts",beforeCreate:i(async e=>CW(e),"beforeCreate"),beforeUpdate:i(async e=>CW(e),"beforeUpdate"),beforeGetList:i(async e=>kb(["first_name","last_name","company_name","title","email","phone","background"])(e),"beforeGetList")},{resource:"companies",beforeGetList:i(async e=>kb(["name","phone_number","website","zipcode","city","stateAbbr"])(e),"beforeGetList"),beforeCreate:i(async e=>{const t=await EW(e);return{...t,data:{...t.data,created_at:new Date().toISOString()}}},"beforeCreate"),beforeUpdate:i(async e=>await EW(e),"beforeUpdate")},{resource:"contacts_summary",beforeGetList:i(async e=>kb(["first_name","last_name"])(e),"beforeGetList")},{resource:"deals",beforeGetList:i(async e=>kb(["name","type","description"])(e),"beforeGetList")}]),kb=i(e=>t=>{if(!t.filter?.q)return t;const{q:n,...r}=t.filter;return{...t,filter:{...r,"@or":e.reduce((a,o)=>o==="email"?{...a,"email_fts@ilike":n}:o==="phone"?{...a,"phone_fts@ilike":n}:{...a,[`${o}@ilike`]:n},{})}}},"applyFullTextSearch"),Bb=i(async e=>{if(!e.src.startsWith("blob:")&&!e.src.startsWith("data:")&&e.path){const{error:c}=await Ln.storage.from("attachments").createSignedUrl(e.path,60);if(!c)return}const t=e.src?await fetch(e.src).then(c=>c.blob()):e.rawFile,n=e.rawFile,r=n.name.split(".").pop(),o=`${`${Math.random()}.${r}`}`,{error:s}=await Ln.storage.from("attachments").upload(o,t);if(s)throw console.error("uploadError",s),new Error("Failed to upload attachment");const{data:l}=Ln.storage.from("attachments").getPublicUrl(o);e.path=o,e.src=l.publicUrl;const f=n.type;return e.type=f,e},"uploadToBucket");function lie(){const{identity:e}=Jn(),t=Vt();return d.jsxs("div",{className:"space-y-4 w-full",children:[d.jsx(ln,{source:"first_name",validate:Zn(),helperText:!1}),d.jsx(ln,{source:"last_name",validate:Zn(),helperText:!1}),d.jsx(ln,{source:"email",validate:[Zn(),rY()],helperText:!1}),d.jsx(OP,{source:"administrator",readOnly:t?.id===e?.id,helperText:!1}),d.jsx(OP,{source:"disabled",readOnly:t?.id===e?.id,helperText:!1})]})}i(lie,"SalesInputs");function Tze(){const e=xn(),t=Bt(),n=po(),{mutate:r}=Mr({mutationKey:["signup"],mutationFn:i(async o=>e.salesCreate(o),"mutationFn"),onSuccess:i(()=>{t("User created. They will soon receive an email to set their password."),n("/sales")},"onSuccess"),onError:i(()=>{t("An error occurred while creating the user.",{type:"error"})},"onError")}),a=i(async o=>{r(o)},"onSubmit");return d.jsx("div",{className:"max-w-lg w-full mx-auto mt-8",children:d.jsxs(pn,{children:[d.jsx(Xo,{children:d.jsx(Zo,{children:"Create a new user"})}),d.jsx(Wn,{children:d.jsx(bee,{onSubmit:a,children:d.jsx(lie,{})})})]})})}i(Tze,"SalesCreate");function Nze(){return d.jsxs("div",{className:"flex justify-end gap-4",children:[d.jsx(U1,{}),d.jsx(bd,{})]})}i(Nze,"EditToolbar");function Pze(){const{record:e}=RK(),t=xn(),n=Bt(),r=po(),{mutate:a}=Mr({mutationKey:["signup"],mutationFn:i(async s=>{if(!e)throw new Error("Record not found");return t.salesUpdate(e.id,s)},"mutationFn"),onSuccess:i(()=>{r("/sales"),n("User updated successfully")},"onSuccess"),onError:i(()=>{n("An error occurred. Please try again.")},"onError")}),o=i(async s=>{a(s)},"onSubmit");return d.jsx("div",{className:"max-w-lg w-full mx-auto mt-8",children:d.jsx(pn,{children:d.jsx(Wn,{children:d.jsxs(bee,{toolbar:d.jsx(Nze,{}),onSubmit:o,record:e,children:[d.jsx(Dze,{}),d.jsx(lie,{})]})})})})}i(Pze,"SalesEdit");const Dze=i(()=>{const e=Vt();return e?d.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Edit ",e?.first_name," ",e?.last_name]}):null},"SaleEditTitle"),Mze=i(()=>d.jsxs(S4,{children:[d.jsx(M1,{}),d.jsx(Dc,{label:"New user"})]}),"SalesListActions"),Ize=[d.jsx(j4,{source:"q",alwaysOn:!0})],Fze=i(e=>{const t=Vt();return t?d.jsxs("div",{className:"flex flex-row gap-1",children:[t.administrator&&d.jsx(Dr,{variant:"outline",className:"border-blue-300 dark:border-blue-700",children:"Admin"}),t.disabled&&d.jsx(Dr,{variant:"outline",className:"border-orange-300 dark:border-orange-700",children:"Disabled"})]}):null},"OptionsField"),Lze=i(()=>{const e=Vt(),t=xn(),n=Bt(),r=Mw(),[a,o]=y.useState(!1),[s,l]=y.useState(!1),{mutate:f,isPending:c}=Mr({mutationFn:i(async()=>t.resendInvite(e.id),"mutationFn"),onSuccess:i(()=>{n("Invitation email resent successfully"),o(!1),r()},"onSuccess"),onError:i(()=>{n("Failed to resend invitation email",{type:"error"}),o(!1)},"onError")}),{mutate:p,isPending:m}=Mr({mutationFn:i(async()=>t.resetPassword(e.id),"mutationFn"),onSuccess:i(()=>{n("Password reset email sent successfully"),l(!1),r()},"onSuccess"),onError:i(()=>{n("Failed to send password reset email",{type:"error"}),l(!1)},"onError")});if(!e)return null;const v=e.email_confirmed_at!==null,b=e.disabled===!0;return console.log("[RowActions] Record:",{email:e.email,email_confirmed_at:e.email_confirmed_at,isConfirmed:v,isDisabled:b,inviteDialogOpen:a,resetDialogOpen:s}),d.jsxs(d.Fragment,{children:[d.jsxs(Nc,{children:[d.jsx(Xs,{asChild:!0,children:d.jsxs(Le,{variant:"ghost",className:"h-8 w-8 p-0",children:[d.jsx("span",{className:"sr-only",children:"Open menu"}),d.jsx(PM,{className:"h-4 w-4"})]})}),d.jsxs(Pc,{align:"end",children:[d.jsx(c4,{children:"Email Actions"}),d.jsx(ov,{}),!v&&d.jsxs(lr,{onClick:i(w=>{w.preventDefault(),w.stopPropagation(),console.log("[Menu] Clicked Resend Invite"),o(!0)},"onClick"),children:[d.jsx(P1e,{className:"mr-2 h-4 w-4"}),"Resend Invite"]}),v&&!b&&d.jsxs(lr,{onClick:i(()=>l(!0),"onClick"),children:[d.jsx(e1e,{className:"mr-2 h-4 w-4"}),"Send Password Reset"]})]})]}),d.jsx(ua,{open:a,onOpenChange:o,children:d.jsxs(da,{onClick:i(w=>w.stopPropagation(),"onClick"),onPointerDown:i(w=>w.stopPropagation(),"onPointerDown"),children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Resend Invitation"}),d.jsxs(ii,{children:["Send a new invitation email to ",d.jsx("strong",{children:e.email}),"?",d.jsx("br",{}),d.jsx("br",{}),"This will send them a fresh invitation link to set up their account."]})]}),d.jsxs(lo,{children:[d.jsx(Le,{variant:"outline",onClick:i(w=>{w.stopPropagation(),o(!1)},"onClick"),disabled:c,children:"Cancel"}),d.jsx(Le,{onClick:i(w=>{w.stopPropagation(),f()},"onClick"),disabled:c,children:c?"Sending...":"Send Invitation"})]})]})}),d.jsx(ua,{open:s,onOpenChange:l,children:d.jsxs(da,{onClick:i(w=>w.stopPropagation(),"onClick"),onPointerDown:i(w=>w.stopPropagation(),"onPointerDown"),children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Send Password Reset"}),d.jsxs(ii,{children:["Send a password reset email to ",d.jsx("strong",{children:e.email}),"?",d.jsx("br",{}),d.jsx("br",{}),"This will send them a link to reset their password."]})]}),d.jsxs(lo,{children:[d.jsx(Le,{variant:"outline",onClick:i(w=>{w.stopPropagation(),l(!1)},"onClick"),disabled:m,children:"Cancel"}),d.jsx(Le,{onClick:i(w=>{w.stopPropagation(),p()},"onClick"),disabled:m,children:m?"Sending...":"Send Reset Link"})]})]})})]})},"RowActions");function $ze(){return d.jsx(x4,{filters:Ize,actions:d.jsx(Mze,{}),sort:{field:"first_name",order:"ASC"},children:d.jsx(qze,{})})}i($ze,"SalesList");const qze=i(()=>{const{data:e,isPending:t,filterValues:n}=Gn(),{identity:r}=Jn(),a=n&&Object.keys(n).length>0;return!r||t?d.jsx(pn,{className:"p-4",children:d.jsxs("div",{className:"space-y-3",children:[d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"})]})}):!e?.length&&!a?d.jsx(zze,{}):d.jsxs(Ls,{children:[d.jsx(Ls.Col,{source:"first_name"}),d.jsx(Ls.Col,{source:"last_name"}),d.jsx(Ls.Col,{source:"email"}),d.jsx(Ls.Col,{label:!1,children:d.jsx(Fze,{})}),d.jsx(Ls.Col,{label:!1,children:d.jsx(Lze,{})})]})},"SalesListLayout"),zze=i(()=>{const e=q1();return d.jsxs("div",{className:"flex flex-col justify-center items-center gap-3",style:{height:`calc(100dvh - ${e}px)`},children:[d.jsx("img",{src:"./img/empty.svg",alt:"No users found"}),d.jsxs("div",{className:"flex flex-col gap-0 items-center",children:[d.jsx("h6",{className:"text-lg font-bold",children:"No users found"}),d.jsx("p",{className:"text-sm text-muted-foreground text-center mb-4",children:"It seems your user list is empty."})]}),d.jsx("div",{className:"flex flex-row gap-2",children:d.jsx(Dc,{label:"New user"})})]})},"SalesEmpty"),Uze={list:$ze,create:Tze,edit:Pze,recordRepresentation:i(e=>`${e.first_name} ${e.last_name}`,"recordRepresentation")};function cie({open:e,onComplete:t,canClose:n=!1}){const[r,a]=y.useState("welcome"),[o,s]=y.useState(""),[l,f]=y.useState(""),[c,p]=y.useState(null),m=i(async()=>{p(null),a("validating");const b=await JRe(o,l);b.valid?(QRe({url:o,anonKey:l}),a("success"),setTimeout(()=>{window.location.href=window.location.origin},1500)):(p(b.error||"Connection failed"),a("credentials"))},"handleValidateAndSave"),v=i(()=>{n&&t()},"handleClose");return d.jsx(ua,{open:e,onOpenChange:n?v:void 0,children:d.jsxs(da,{className:"sm:max-w-md",onPointerDownOutside:i(b=>!n&&b.preventDefault(),"onPointerDownOutside"),onEscapeKeyDown:i(b=>!n&&b.preventDefault(),"onEscapeKeyDown"),children:[r==="welcome"&&d.jsxs(d.Fragment,{children:[d.jsxs(Nr,{children:[d.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[d.jsx(ev,{className:"h-6 w-6 text-primary"}),d.jsx(Pr,{children:"Welcome to CRM"})]}),d.jsx(ii,{children:"To get started, you'll need to connect to a Supabase database."})]}),d.jsxs("div",{className:"space-y-4 py-4",children:[d.jsx(Ua,{children:d.jsxs(oi,{children:[d.jsx("strong",{children:"Don't have a Supabase project?"}),d.jsx("br",{}),"Create one for free at"," ",d.jsx("a",{href:"https://supabase.com",target:"_blank",rel:"noopener noreferrer",className:"underline text-primary",children:"supabase.com"})]})}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"font-medium text-sm",children:"What you'll need:"}),d.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:[d.jsx("li",{children:"Your Supabase project URL"}),d.jsx("li",{children:"Your anonymous (anon) API key"})]})]}),d.jsx(Le,{onClick:i(()=>a("credentials"),"onClick"),className:"w-full",children:"Continue"})]})]}),r==="credentials"&&d.jsxs(d.Fragment,{children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Connect to Supabase"}),d.jsx(ii,{children:"Enter your Supabase project credentials"})]}),d.jsxs("div",{className:"space-y-4 py-4",children:[c&&d.jsxs(Ua,{variant:"destructive",children:[d.jsx(Np,{className:"h-4 w-4"}),d.jsx(oi,{children:c})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"supabase-url",children:"Supabase URL"}),d.jsx(Sr,{id:"supabase-url",placeholder:"https://xxxxx.supabase.co",value:o,onChange:i(b=>s(b.target.value),"onChange")}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Found in Project Settings → API"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"anon-key",children:"Anonymous Key"}),d.jsx(Sr,{id:"anon-key",type:"password",placeholder:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",value:l,onChange:i(b=>f(b.target.value),"onChange")}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Found in Project Settings → API → Project API keys"})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Le,{variant:"outline",onClick:i(()=>a("welcome"),"onClick"),className:"flex-1",children:"Back"}),d.jsx(Le,{onClick:m,disabled:!o||!l,className:"flex-1",children:"Connect"})]})]})]}),r==="validating"&&d.jsxs(d.Fragment,{children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Validating Connection"}),d.jsx(ii,{children:"Testing your Supabase credentials..."})]}),d.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[d.jsx(Rc,{className:"h-12 w-12 animate-spin text-primary mb-4"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Please wait..."})]})]}),r==="success"&&d.jsxs(d.Fragment,{children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Connection Successful!"}),d.jsx(ii,{children:"Your Supabase database is now connected"})]}),d.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[d.jsx($o,{className:"h-12 w-12 text-green-500 mb-4"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Reloading application..."})]})]})]})})}i(cie,"SupabaseSetupWizard");function Bze(){const[e,t]=y.useState(!1),n=wd(),r=eAe(),a=i(()=>{confirm("Are you sure you want to clear the database configuration? The app will need to be reconfigured on next launch.")&&(XRe(),window.location.reload())},"handleClearConfig");return d.jsxs(d.Fragment,{children:[d.jsxs(pn,{children:[d.jsxs(Xo,{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ev,{className:"h-5 w-5"}),d.jsx(Zo,{children:"Database Connection"})]}),d.jsx(_4,{children:"Manage your Supabase database connection settings"})]}),d.jsx(Wn,{className:"space-y-4",children:n?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start gap-3 p-4 border rounded-lg",children:[d.jsx($o,{className:"h-5 w-5 text-green-500 mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx("p",{className:"font-medium",children:"Connected"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:n.url}),n.configuredAt&&d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Configured on"," ",new Date(n.configuredAt).toLocaleDateString()]})]})]}),r==="env"&&d.jsxs(Ua,{children:[d.jsx(fN,{className:"h-4 w-4"}),d.jsx(oi,{children:"Using configuration from environment variables. You can override this by setting up a new connection via the UI."})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs(Le,{variant:"outline",onClick:i(()=>t(!0),"onClick"),className:"flex-1",children:[d.jsx(fN,{className:"h-4 w-4 mr-2"}),"Change Connection"]}),r==="ui"&&d.jsxs(Le,{variant:"destructive",onClick:a,className:"flex-1",children:[d.jsx(fy,{className:"h-4 w-4 mr-2"}),"Clear Configuration"]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Vze,{className:"text-sm font-medium",children:"Anonymous Key"}),d.jsxs("div",{className:"font-mono text-sm p-2 bg-muted rounded",children:[n.anonKey.substring(0,20),"...",n.anonKey.substring(n.anonKey.length-10)]})]})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start gap-3 p-4 border border-dashed rounded-lg",children:[d.jsx(as,{className:"h-5 w-5 text-destructive mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx("p",{className:"font-medium",children:"Not Connected"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"No Supabase database is configured"})]})]}),d.jsx(Ua,{children:d.jsxs(oi,{children:["Connect to a Supabase database to start using Atomic CRM. You can create a free project at"," ",d.jsx("a",{href:"https://supabase.com",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"supabase.com"})]})}),d.jsxs(Le,{onClick:i(()=>t(!0),"onClick"),className:"w-full",children:[d.jsx(ev,{className:"h-4 w-4 mr-2"}),"Connect to Supabase"]})]})})]}),d.jsx(cie,{open:e,onComplete:i(()=>t(!1),"onComplete"),canClose:!0})]})}i(Bze,"DatabaseSettings");function Vze({children:e,className:t}){return d.jsx("label",{className:t,children:e})}i(Vze,"Label");const oD=i(()=>d.jsx("div",{className:"max-w-lg mx-auto mt-8",children:d.jsx(Bze,{})}),"DatabasePage");oD.path="/database";const sD=i(()=>{const[e,t]=y.useState(!1),{identity:n,refetch:r}=Jn(),{data:a,refetch:o}=Iw("sales",{id:n?.id}),s=Bt(),l=xn(),{mutate:f}=Mr({mutationKey:["signup"],mutationFn:i(async p=>{if(!n)throw new Error("Record not found");return l.salesUpdate(n.id,p)},"mutationFn"),onSuccess:i(()=>{r(),o(),t(!1),s("Your profile has been updated")},"onSuccess"),onError:i(p=>{s("An error occurred. Please try again",{type:"error"})},"onError")});if(!n)return null;const c=i(async p=>{f(p)},"handleOnSubmit");return d.jsx("div",{className:"max-w-lg mx-auto mt-8",children:d.jsx(Xr,{onSubmit:c,record:a,children:d.jsx(Hze,{isEditMode:e,setEditMode:t})})})},"SettingsPage"),Hze=i(({isEditMode:e,setEditMode:t})=>{const n=Bt(),r=ja(),a=Vt(),{identity:o,refetch:s}=Jn(),{isDirty:l}=sy(),f=xn(),{mutate:c}=Mr({mutationKey:["signup"],mutationFn:i(async v=>{if(!a)throw new Error("Record not found");return f.salesUpdate(a.id,v)},"mutationFn"),onSuccess:i(()=>{s(),n("Your profile has been updated")},"onSuccess"),onError:i(()=>{n("An error occurred. Please try again.")},"onError")});if(!o)return null;const p=i(()=>{r("/change-password")},"handleClickOpenPasswordChange"),m=i(async v=>{c(v)},"handleAvatarUpdate");return d.jsxs("div",{className:"space-y-4",children:[d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx("div",{className:"mb-4 flex flex-row justify-between",children:d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"My info"})}),d.jsxs("div",{className:"space-y-4 mb-4",children:[d.jsx(dte,{source:"avatar",type:"avatar",onSave:m,linkPosition:"right"}),d.jsx(gT,{source:"first_name",isEditMode:e}),d.jsx(gT,{source:"last_name",isEditMode:e}),d.jsx(gT,{source:"email",isEditMode:e})]}),d.jsxs("div",{className:"flex flex-row justify-end gap-2",children:[!e&&d.jsx(d.Fragment,{children:d.jsx(Le,{variant:"outline",type:"button",onClick:p,children:"Change password"})}),d.jsxs(Le,{type:"button",variant:e?"ghost":"outline",onClick:i(()=>t(!e),"onClick"),className:"flex items-center",children:[e?d.jsx(as,{}):d.jsx(TQ,{}),e?"Cancel":"Edit"]}),e&&d.jsxs(Le,{type:"submit",disabled:!l,variant:"outline",children:[d.jsx(l1,{}),"Save"]})]})]})}),void 0]})},"SettingsForm"),gT=i(({source:e,isEditMode:t})=>t?d.jsx(ln,{source:e,helperText:!1}):d.jsx("div",{className:"m-2",children:d.jsx(y5e,{source:e})}),"TextRender");sD.path="/settings";function uie(){const e=new Uint8Array(16);return crypto.getRandomValues(e),`ak_live_${Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join("")}`}i(uie,"generateApiKey");async function Wze(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}i(Wze,"hashApiKey");const Gze=[{value:"contacts:read",label:"Contacts: Read"},{value:"contacts:write",label:"Contacts: Write"},{value:"companies:read",label:"Companies: Read"},{value:"companies:write",label:"Companies: Write"},{value:"deals:read",label:"Deals: Read"},{value:"deals:write",label:"Deals: Write"},{value:"activities:write",label:"Activities: Write"}],Kze=i(({open:e,onClose:t})=>{const[n,r]=y.useState(null),[a,o]=y.useState(!1),s=xn(),l=Bt(),f=Nn(),{identity:c}=Jn(),{register:p,handleSubmit:m,watch:v,setValue:b,reset:w}=ly({defaultValues:{name:"",scopes:[],expires_at:""}}),S=Mr({mutationFn:i(async O=>{const C=uie(),T=await Wze(C),R=C.substring(0,12),{data:A}=await s.create("api_keys",{data:{name:O.name,key_hash:T,key_prefix:R,scopes:O.scopes,is_active:!0,expires_at:O.expires_at||null,sales_id:c?.id,created_by_sales_id:c?.id}});return{data:A,apiKey:C}},"mutationFn"),onSuccess:i(({apiKey:O})=>{r(O),f.invalidateQueries({queryKey:["api_keys"]}),l("API key created successfully")},"onSuccess"),onError:i(()=>{l("Failed to create API key",{type:"error"})},"onError")}),_=i(()=>{r(null),o(!1),w(),t()},"handleClose"),j=i(()=>{n&&(navigator.clipboard.writeText(n),o(!0),setTimeout(()=>o(!1),2e3))},"copyApiKey"),E=i(O=>{const C=v("scopes");C.includes(O)?b("scopes",C.filter(T=>T!==O)):b("scopes",[...C,O])},"toggleScope");return d.jsx(ua,{open:e,onOpenChange:_,children:d.jsxs(da,{className:"sm:max-w-[500px]",children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:n?"API Key Created":"Create API Key"}),d.jsx(ii,{children:n?"Copy this key now - it won't be shown again!":"Create a new API key to access the CRM API"})]}),n?d.jsxs("div",{className:"space-y-4",children:[d.jsx(Ua,{children:d.jsx(oi,{children:"Make sure to copy your API key now. You won't be able to see it again!"})}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Your API Key"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Sr,{value:n,readOnly:!0,className:"font-mono text-sm"}),d.jsx(Le,{type:"button",variant:"outline",size:"icon",onClick:j,children:a?d.jsx($o,{className:"h-4 w-4 text-green-500"}):d.jsx(TM,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex justify-end",children:d.jsx(Le,{onClick:_,children:"Done"})})]}):d.jsx("form",{onSubmit:m(O=>S.mutate(O)),children:d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"name",children:"Name"}),d.jsx(Sr,{id:"name",placeholder:"e.g., Production API Key",...p("name",{required:!0})})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Scopes"}),d.jsx("div",{className:"space-y-2",children:Gze.map(O=>d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Hp,{id:O.value,checked:v("scopes").includes(O.value),onCheckedChange:i(()=>E(O.value),"onCheckedChange")}),d.jsx("label",{htmlFor:O.value,className:"text-sm cursor-pointer",children:O.label})]},O.value))})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"expires_at",children:"Expiration (optional)"}),d.jsx(Sr,{id:"expires_at",type:"date",...p("expires_at")})]}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(Le,{type:"button",variant:"outline",onClick:_,children:"Cancel"}),d.jsx(Le,{type:"submit",disabled:S.isPending,children:"Create"})]})]})})]})})},"CreateApiKeyDialog");var Yze=Symbol("radix.slottable");function Qze(e){const t=i(({children:n})=>d.jsx(d.Fragment,{children:n}),"Slottable2");return t.displayName=`${e}.Slottable`,t.__radixId=Yze,t}i(Qze,"createSlottable");var die="AlertDialog",[Xze,JUe]=ha(die,[XQ]),ll=XQ(),fie=i(e=>{const{__scopeAlertDialog:t,...n}=e,r=ll(t);return d.jsx(my,{...r,...n,modal:!0})},"AlertDialog$1");fie.displayName=die;var Zze="AlertDialogTrigger",Jze=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(hX,{...a,...r,ref:t})});Jze.displayName=Zze;var eUe="AlertDialogPortal",hie=i(e=>{const{__scopeAlertDialog:t,...n}=e,r=ll(t);return d.jsx(gy,{...r,...n})},"AlertDialogPortal$1");hie.displayName=eUe;var tUe="AlertDialogOverlay",pie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(vy,{...a,...r,ref:t})});pie.displayName=tUe;var fh="AlertDialogContent",[nUe,rUe]=Xze(fh),aUe=Qze("AlertDialogContent"),mie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...a}=e,o=ll(n),s=y.useRef(null),l=Zt(t,s),f=y.useRef(null);return d.jsx(QSe,{contentName:fh,titleName:gie,docsSlug:"alert-dialog",children:d.jsx(nUe,{scope:n,cancelRef:f,children:d.jsxs(yy,{role:"alertdialog",...o,...a,ref:l,onOpenAutoFocus:tt(a.onOpenAutoFocus,c=>{c.preventDefault(),f.current?.focus({preventScroll:!0})}),onPointerDownOutside:i(c=>c.preventDefault(),"onPointerDownOutside"),onInteractOutside:i(c=>c.preventDefault(),"onInteractOutside"),children:[d.jsx(aUe,{children:r}),d.jsx(oUe,{contentRef:s})]})})})});mie.displayName=fh;var gie="AlertDialogTitle",vie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(h1,{...a,...r,ref:t})});vie.displayName=gie;var yie="AlertDialogDescription",bie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(p1,{...a,...r,ref:t})});bie.displayName=yie;var iUe="AlertDialogAction",xie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(by,{...a,...r,ref:t})});xie.displayName=iUe;var wie="AlertDialogCancel",_ie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:a}=rUe(wie,n),o=ll(n),s=Zt(t,a);return d.jsx(by,{...o,...r,ref:s})});_ie.displayName=wie;var oUe=i(({contentRef:e})=>{const t=`\`${fh}\` requires a description for the component to be accessible for screen reader users.
|
|
154
|
+
`,fill:a,opacity:s,strokeWidth:f,stroke:c===void 0?"transparent":c,style:{pointerEvents:"none"}})})},"y");function cc(){return cc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},cc.apply(null,arguments)}i(cc,"b");var ki={translateX:0,translateY:0,padding:0,itemsSpacing:0,itemDirection:"left-to-right",justify:!1,symbolShape:"square",symbolSize:16,symbolSpacing:8},iqe={top:0,right:0,bottom:0,left:0},M3=i(function(e){var t,n=e.direction,r=e.itemsSpacing,a=e.padding,o=e.itemCount,s=e.itemWidth,l=e.itemHeight;if(typeof a!="number"&&(typeof(t=a)!="object"||Array.isArray(t)||t===null))throw new Error("Invalid property padding, must be one of: number, object");var f=typeof a=="number"?{top:a,right:a,bottom:a,left:a}:cc({},iqe,a),c=f.left+f.right,p=f.top+f.bottom,m=s+c,v=l+p,b=(o-1)*r;return n==="row"?m=s*o+b+c:n==="column"&&(v=l*o+b+p),{width:m,height:v,padding:f}},"A"),Qae=i(function(e){var t=e.anchor,n=e.translateX,r=e.translateY,a=e.containerWidth,o=e.containerHeight,s=e.width,l=e.height,f=n,c=r;switch(t){case"top":f+=(a-s)/2;break;case"top-right":f+=a-s;break;case"right":f+=a-s,c+=(o-l)/2;break;case"bottom-right":f+=a-s,c+=o-l;break;case"bottom":f+=(a-s)/2,c+=o-l;break;case"bottom-left":c+=o-l;break;case"left":c+=(o-l)/2;break;case"center":f+=(a-s)/2,c+=(o-l)/2}return{x:f,y:c}},"C"),Xae=i(function(e){var t,n,r,a,o,s,l=e.direction,f=e.justify,c=e.symbolSize,p=e.symbolSpacing,m=e.width,v=e.height;switch(l){case"left-to-right":t=0,n=(v-c)/2,a=v/2,s="central",f?(r=m,o="end"):(r=c+p,o="start");break;case"right-to-left":t=m-c,n=(v-c)/2,a=v/2,s="central",f?(r=0,o="start"):(r=m-c-p,o="end");break;case"top-to-bottom":t=(m-c)/2,n=0,r=m/2,o="middle",f?(a=v,s="alphabetic"):(a=c+p,s="text-before-edge");break;case"bottom-to-top":t=(m-c)/2,n=v-c,r=m/2,o="middle",f?(a=0,s="text-before-edge"):(a=v-c-p,s="alphabetic")}return{symbolX:t,symbolY:n,labelX:r,labelY:a,labelAnchor:o,labelAlignment:s}},"z"),oqe={circle:tqe,diamond:nqe,square:rqe,triangle:aqe},sqe=i(function(e){var t,n,r,a,o,s,l,f,c,p,m,v=e.x,b=e.y,w=e.width,S=e.height,_=e.data,j=e.direction,E=j===void 0?ki.itemDirection:j,O=e.justify,C=O===void 0?ki.justify:O,T=e.textColor,R=e.background,A=R===void 0?"transparent":R,N=e.opacity,D=N===void 0?1:N,M=e.symbolShape,I=M===void 0?ki.symbolShape:M,F=e.symbolSize,L=F===void 0?ki.symbolSize:F,q=e.symbolSpacing,U=q===void 0?ki.symbolSpacing:q,$=e.symbolBorderWidth,V=$===void 0?0:$,z=e.symbolBorderColor,W=z===void 0?"transparent":z,H=e.onClick,Q=e.onMouseEnter,Y=e.onMouseLeave,K=e.toggleSerie,ee=e.effects,te=y.useState({}),oe=te[0],ne=te[1],fe=Lr(),re=y.useCallback((function(X){if(ee){var se=ee.filter((function(me){return me.on==="hover"})).reduce((function(me,Te){return cc({},me,Te.style)}),{});ne(se)}Q?.(_,X)}),[Q,_,ee]),ce=y.useCallback((function(X){if(ee){var se=ee.filter((function(me){return me.on!=="hover"})).reduce((function(me,Te){return cc({},me,Te.style)}),{});ne(se)}Y?.(_,X)}),[Y,_,ee]),he=Xae({direction:E,justify:C,symbolSize:(t=oe.symbolSize)!=null?t:L,symbolSpacing:U,width:w,height:S}),J=he.symbolX,Me=he.symbolY,we=he.labelX,Ee=he.labelY,Re=he.labelAnchor,ke=he.labelAlignment,Ne=[H,Q,Y,K].some((function(X){return X!==void 0})),Ue=typeof I=="function"?I:oqe[I];return d.jsxs("g",{transform:"translate("+v+","+b+")",style:{opacity:(n=oe.itemOpacity)!=null?n:D},children:[d.jsx("rect",{width:w,height:S,fill:(r=oe.itemBackground)!=null?r:A,style:{cursor:Ne?"pointer":"auto"},onClick:i(function(X){H?.(_,X),K?.(_.id)},"onClick"),onMouseEnter:re,onMouseLeave:ce}),y.createElement(Ue,cc({id:_.id,x:J,y:Me,size:(a=oe.symbolSize)!=null?a:L,fill:(o=(s=_.fill)!=null?s:_.color)!=null?o:"black",borderWidth:(l=oe.symbolBorderWidth)!=null?l:V,borderColor:(f=oe.symbolBorderColor)!=null?f:W},_.hidden?fe.legends.hidden.symbol:void 0)),d.jsx(W_,{textAnchor:Re,style:cc({},fe.legends.text,{fill:(c=(p=(m=oe.itemTextColor)!=null?m:T)!=null?p:fe.legends.text.fill)!=null?c:"black",dominantBaseline:ke,pointerEvents:"none",userSelect:"none"},_.hidden?fe.legends.hidden.text:void 0),x:we,y:Ee,children:_.label})]})},"B"),lqe=i(function(e){var t=e.data,n=e.x,r=e.y,a=e.direction,o=e.padding,s=o===void 0?ki.padding:o,l=e.justify,f=e.effects,c=e.itemWidth,p=e.itemHeight,m=e.itemDirection,v=m===void 0?ki.itemDirection:m,b=e.itemsSpacing,w=b===void 0?ki.itemsSpacing:b,S=e.itemTextColor,_=e.itemBackground,j=_===void 0?"transparent":_,E=e.itemOpacity,O=E===void 0?1:E,C=e.symbolShape,T=e.symbolSize,R=e.symbolSpacing,A=e.symbolBorderWidth,N=e.symbolBorderColor,D=e.onClick,M=e.onMouseEnter,I=e.onMouseLeave,F=e.toggleSerie,L=M3({itemCount:t.length,itemWidth:c,itemHeight:p,itemsSpacing:w,direction:a,padding:s}).padding,q=a==="row"?c+w:0,U=a==="column"?p+w:0;return d.jsx("g",{transform:"translate("+n+","+r+")",children:t.map((function($,V){return d.jsx(sqe,{data:$,x:V*q+L.left,y:V*U+L.top,width:c,height:p,direction:v,justify:l,effects:f,textColor:S,background:j,opacity:O,symbolShape:C,symbolSize:T,symbolSpacing:R,symbolBorderWidth:A,symbolBorderColor:N,onClick:D,onMouseEnter:M,onMouseLeave:I,toggleSerie:F},V)}))})},"H"),cqe=i(function(e){var t=e.data,n=e.containerWidth,r=e.containerHeight,a=e.translateX,o=a===void 0?ki.translateX:a,s=e.translateY,l=s===void 0?ki.translateY:s,f=e.anchor,c=e.direction,p=e.padding,m=p===void 0?ki.padding:p,v=e.justify,b=e.itemsSpacing,w=b===void 0?ki.itemsSpacing:b,S=e.itemWidth,_=e.itemHeight,j=e.itemDirection,E=e.itemTextColor,O=e.itemBackground,C=e.itemOpacity,T=e.symbolShape,R=e.symbolSize,A=e.symbolSpacing,N=e.symbolBorderWidth,D=e.symbolBorderColor,M=e.onClick,I=e.onMouseEnter,F=e.onMouseLeave,L=e.toggleSerie,q=e.effects,U=M3({itemCount:t.length,itemsSpacing:w,itemWidth:S,itemHeight:_,direction:c,padding:m}),$=U.width,V=U.height,z=Qae({anchor:f,translateX:o,translateY:l,containerWidth:n,containerHeight:r,width:$,height:V}),W=z.x,H=z.y;return d.jsx(lqe,{data:t,x:W,y:H,direction:c,padding:m,justify:v,effects:q,itemsSpacing:w,itemWidth:S,itemHeight:_,itemDirection:j,itemTextColor:E,itemBackground:O,itemOpacity:C,symbolShape:T,symbolSize:R,symbolSpacing:A,symbolBorderWidth:N,symbolBorderColor:D,onClick:M,onMouseEnter:I,onMouseLeave:F,toggleSerie:typeof L=="boolean"?void 0:L})},"E"),uqe={start:"left",middle:"center",end:"right"},dqe=i(function(e,t){var n=t.data,r=t.containerWidth,a=t.containerHeight,o=t.translateX,s=o===void 0?0:o,l=t.translateY,f=l===void 0?0:l,c=t.anchor,p=t.direction,m=t.padding,v=m===void 0?0:m,b=t.justify,w=b!==void 0&&b,S=t.itemsSpacing,_=S===void 0?0:S,j=t.itemWidth,E=t.itemHeight,O=t.itemDirection,C=O===void 0?"left-to-right":O,T=t.itemTextColor,R=t.symbolSize,A=R===void 0?16:R,N=t.symbolSpacing,D=N===void 0?8:N,M=t.theme,I=M3({itemCount:n.length,itemWidth:j,itemHeight:E,itemsSpacing:_,direction:p,padding:v}),F=I.width,L=I.height,q=I.padding,U=Qae({anchor:c,translateX:s,translateY:f,containerWidth:r,containerHeight:a,width:F,height:L}),$=U.x,V=U.y,z=p==="row"?j+_:0,W=p==="column"?E+_:0;e.save(),e.translate($,V),$v(e,M.legends.text),n.forEach((function(H,Q){var Y,K=Q*z+q.left,ee=Q*W+q.top,te=Xae({direction:C,justify:w,symbolSize:A,symbolSpacing:D,width:j,height:E}),oe=te.symbolX,ne=te.symbolY,fe=te.labelX,re=te.labelY,ce=te.labelAnchor,he=te.labelAlignment;e.fillStyle=(Y=H.color)!=null?Y:"black",e.fillRect(K+oe,ee+ne,A,A),e.textAlign=uqe[ce],he==="central"&&(e.textBaseline="middle"),qv(e,cc({},M.legends.text,{fill:T??M.legends.text.fill}),String(H.label),K+fe,ee+re)})),e.restore()},"L"),fqe=i(function(e,t,n,r,a,o){o>0?(e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+a-o),e.quadraticCurveTo(t+r,n+a,t+r-o,n+a),e.lineTo(t+o,n+a),e.quadraticCurveTo(t,n+a,t,n+a-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()):e.rect(t,n,r,a)},"o");function gn(){return gn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},gn.apply(null,arguments)}i(gn,"Q");function qc(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}i(qc,"U");var vW,hqe=i(function(e){var t=e.bars,n=e.annotations,r=Wae({data:t,annotations:n,getPosition:i(function(a){return{x:a.x+a.width/2,y:a.y+a.height/2}},"getPosition"),getDimensions:i(function(a){var o=a.height,s=a.width;return{width:s,height:o,size:Math.max(s,o)}},"getDimensions")});return d.jsx(d.Fragment,{children:r.map((function(a,o){return d.jsx(L9e,gn({},a),o)}))})},"$"),pqe=i(function(e){var t=e.width,n=e.height,r=e.legends,a=e.toggleSerie;return d.jsx(d.Fragment,{children:r.map((function(o,s){var l,f=o[0],c=o[1];return d.jsx(cqe,gn({},f,{containerWidth:t,containerHeight:n,data:(l=f.data)!=null?l:c,toggleSerie:f.toggleSerie&&f.dataFrom==="keys"?a:void 0}),s)}))})},"ee"),mqe=["data"],gqe=i(function(e){var t,n=e.bar,r=n.data,a=qc(n,mqe),o=e.style,s=o.borderColor,l=o.color,f=o.height,c=o.labelColor,p=o.labelOpacity,m=o.labelX,v=o.labelY,b=o.transform,w=o.width,S=o.textAnchor,_=e.borderRadius,j=e.borderWidth,E=e.label,O=e.shouldRenderLabel,C=e.isInteractive,T=e.onClick,R=e.onMouseEnter,A=e.onMouseLeave,N=e.tooltip,D=e.isFocusable,M=e.ariaLabel,I=e.ariaLabelledBy,F=e.ariaDescribedBy,L=e.ariaDisabled,q=e.ariaHidden,U=Lr(),$=Ere(),V=$.showTooltipFromEvent,z=$.showTooltipAt,W=$.hideTooltip,H=y.useMemo((function(){return function(){return y.createElement(N,gn({},a,r))}}),[N,a,r]),Q=y.useCallback((function(ne){T?.(gn({color:a.color},r),ne)}),[a,r,T]),Y=y.useCallback((function(ne){return V(H(),ne)}),[V,H]),K=y.useCallback((function(ne){R?.(r,ne),V(H(),ne)}),[r,R,V,H]),ee=y.useCallback((function(ne){A?.(r,ne),W()}),[r,W,A]),te=y.useCallback((function(){z(H(),[a.absX+a.width/2,a.absY])}),[z,H,a]),oe=y.useCallback((function(){W()}),[W]);return d.jsxs(mr.g,{transform:b,children:[d.jsx(mr.rect,{width:BP(w,(function(ne){return Math.max(ne,0)})),height:BP(f,(function(ne){return Math.max(ne,0)})),rx:_,ry:_,fill:(t=r.fill)!=null?t:l,strokeWidth:j,stroke:s,focusable:D,tabIndex:D?0:void 0,"aria-label":M?M(r):void 0,"aria-labelledby":I?I(r):void 0,"aria-describedby":F?F(r):void 0,"aria-disabled":L?L(r):void 0,"aria-hidden":q?q(r):void 0,onMouseEnter:C?K:void 0,onMouseMove:C?Y:void 0,onMouseLeave:C?ee:void 0,onClick:C?Q:void 0,onFocus:C&&D?te:void 0,onBlur:C&&D?oe:void 0,"data-testid":"bar.item."+r.id+"."+r.index}),O&&d.jsx(W_,{x:m,y:v,textAnchor:S,dominantBaseline:"central",fillOpacity:p,style:gn({},U.labels.text,{pointerEvents:"none",fill:c}),children:E})]})},"ae"),vqe=["color","label"],yqe=i(function(e){var t=e.color,n=e.label,r=qc(e,vqe);return d.jsx(L8e,{id:n,value:r.formattedValue,enableChip:!0,color:t})},"ne"),Fn={indexBy:"id",keys:["value"],groupMode:"stacked",layout:"vertical",valueScale:{type:"linear",nice:!0,round:!1},indexScale:{type:"band",round:!1},padding:.1,innerPadding:0,enableGridX:!1,enableGridY:!0,enableLabel:!0,label:"formattedValue",labelPosition:"middle",labelOffset:0,labelSkipWidth:0,labelSkipHeight:0,labelTextColor:{theme:"labels.text.fill"},colorBy:"id",colors:{scheme:"nivo"},borderRadius:0,borderWidth:0,borderColor:{from:"color"},isInteractive:!0,tooltip:yqe,tooltipLabel:i(function(e){return e.id+" - "+e.indexValue},"tooltipLabel"),legends:[],initialHiddenIds:[],annotations:[],enableTotals:!1,totalsOffset:10},In=gn({},Fn,{layers:["grid","axes","bars","totals","markers","legends","annotations"],axisTop:null,axisRight:null,axisBottom:{},axisLeft:{},barComponent:gqe,defs:[],fill:[],markers:[],animate:!0,animateOnMount:!1,motionConfig:"default",role:"img",isFocusable:!1}),yr=gn({},Fn,{layers:["grid","axes","bars","totals","legends","annotations"],axisTop:null,axisRight:null,axisBottom:{},axisLeft:{},renderBar:i(function(e,t){var n=t.bar,r=n.color,a=n.height,o=n.width,s=n.x,l=n.y,f=t.borderColor,c=t.borderRadius,p=t.borderWidth,m=t.label,v=t.shouldRenderLabel,b=t.labelStyle,w=t.labelX,S=t.labelY,_=t.textAnchor;e.fillStyle=r,p>0&&(e.strokeStyle=f,e.lineWidth=p),e.beginPath(),fqe(e,s,l,o,a,Math.min(c,a)),e.fill(),p>0&&e.stroke(),v&&(e.textBaseline="middle",e.textAlign=_==="middle"?"center":_,qv(e,b,m,s+w,l+S))},"renderBar"),pixelRatio:typeof window<"u"&&(vW=window.devicePixelRatio)!=null?vW:1}),Zae=i(function(e,t,n,r,a,o){return D3(r,{all:e.map(t),min:0,max:0},a,o).padding(n)},"de"),Jae=i(function(e,t){return e.map((function(n){return gn({},t.reduce((function(r,a){return r[a]=null,r}),{}),n)}))},"ue"),G_=i(function(e){return Object.keys(e).reduce((function(t,n){return e[n]&&(t[n]=e[n]),t}),{})},"se"),K_=i(function(e){return[e,Number(e)]},"ce");function eie(e,t,n,r){return e===void 0&&(e=Fn.layout),n===void 0&&(n=Fn.labelPosition),r===void 0&&(r=Fn.labelOffset),function(a,o){var s=r*(t?-1:1);if(e==="horizontal"){var l=a/2;return n==="start"?l=t?a:0:n==="end"&&(l=t?0:a),{labelX:l+s,labelY:o/2,textAnchor:n==="middle"?"middle":t?"end":"start"}}var f=o/2;return n==="start"?f=t?0:o:n==="end"&&(f=t?o:0),{labelX:a/2,labelY:f-s,textAnchor:"middle"}}}i(eie,"he");var bqe=["layout","width","height","padding","innerPadding","valueScale","indexScale","hiddenIds"],I3=i(function(e,t){return e>t},"be"),tie=i(function(e,t){return e<t},"ge"),nie=i(function(e,t){return Array.from(" ".repeat(t-e),(function(n,r){return e+r}))},"ve"),xqe=i(function(e){return I3(e,0)?0:e},"me"),wqe=i(function(e,t,n,r){var a=e.data,o=e.formatValue,s=e.getColor,l=e.getIndex,f=e.getTooltipLabel,c=e.innerPadding,p=c===void 0?0:c,m=e.keys,v=e.xScale,b=e.yScale,w=e.margin,S=n?tie:I3,_=a.map(G_),j=[];return m.forEach((function(E,O){return nie(0,v.domain().length).forEach((function(C){var T,R,A,N=K_(a[C][E]),D=N[0],M=N[1],I=l(a[C]),F=((T=v(I))!=null?T:0)+t*O+p*O,L=S(R=M,0)?(A=b(R))!=null?A:0:r,q=(function($,V){var z;return S($,0)?r-V:((z=b($))!=null?z:0)-r})(M,L),U={id:E,value:D===null?D:M,formattedValue:o(M),hidden:!1,index:C,indexValue:I,data:_[C]};j.push({key:E+"."+U.indexValue,index:j.length,data:U,x:F,y:L,absX:w.left+F,absY:w.top+L,width:t,height:q,color:s(U),label:f(U)})}))})),j},"pe"),_qe=i(function(e,t,n,r){var a=e.data,o=e.formatValue,s=e.getIndex,l=e.getColor,f=e.getTooltipLabel,c=e.keys,p=e.innerPadding,m=p===void 0?0:p,v=e.xScale,b=e.yScale,w=e.margin,S=n?tie:I3,_=a.map(G_),j=[];return c.forEach((function(E,O){return nie(0,b.domain().length).forEach((function(C){var T,R,A,N=K_(a[C][E]),D=N[0],M=N[1],I=s(a[C]),F=S(R=M,0)?r:(A=v(R))!=null?A:0,L=((T=b(I))!=null?T:0)+t*O+m*O,q=(function($,V){var z;return S($,0)?((z=v($))!=null?z:0)-r:r-V})(M,F),U={id:E,value:D===null?D:M,formattedValue:o(M),hidden:!1,index:C,indexValue:I,data:_[C]};j.push({key:E+"."+U.indexValue,index:j.length,data:U,x:F,y:L,absX:w.left+F,absY:w.top+L,width:q,height:t,color:l(U),label:f(U)})}))})),j},"ye"),Sqe=i(function(e){var t,n,r,a=e.layout,o=e.width,s=e.height,l=e.padding,f=l===void 0?0:l,c=e.innerPadding,p=c===void 0?0:c,m=e.valueScale,v=e.indexScale,b=e.hiddenIds,w=b===void 0?[]:b,S=qc(e,bqe),_=S.keys.filter((function(V){return!w.includes(V)})),j=Jae(S.data,_),E=a==="vertical"?["y","x",o]:["x","y",s],O=E[0],C=E[1],T=E[2],R=Zae(j,S.getIndex,f,v,T,C),A=m.min==="auto"?xqe:function(V){return V},N=j.reduce((function(V,z){return[].concat(V,_.map((function(W){return z[W]})))}),[]).filter(Boolean),D=A(Math.min.apply(Math,N)),M=(r=Math.max.apply(Math,N),isFinite(r)?r:0),I=D3(m,{all:N,min:D,max:M},O==="x"?o:s,O),F=a==="vertical"?[R,I]:[I,R],L=F[0],q=F[1],U=(R.bandwidth()-p*(_.length-1))/_.length,$=[gn({},S,{data:j,keys:_,innerPadding:p,xScale:L,yScale:q}),U,(t=m.reverse)!=null&&t,(n=I(0))!=null?n:0];return{xScale:L,yScale:q,bars:U>0?a==="vertical"?wqe.apply(void 0,$):_qe.apply(void 0,$):[]}},"xe"),jqe=["data","layout","width","height","padding","valueScale","indexScale","hiddenIds"],rie=i(function(e){var t;return e.some(Array.isArray)?rie((t=[]).concat.apply(t,e)):e},"ke"),Eqe=i(function(e,t,n){var r=e.formatValue,a=e.getColor,o=e.getIndex,s=e.getTooltipLabel,l=e.innerPadding,f=e.stackedData,c=e.xScale,p=e.yScale,m=e.margin,v=[];return f.forEach((function(b){return c.domain().forEach((function(w,S){var _,j,E=b[S],O=(_=c(o(E.data)))!=null?_:0,C=((j=(function(M){return p(M[n?0:1])})(E))!=null?j:0)+.5*l,T=(function(M,I){var F;return((F=p(M[n?1:0]))!=null?F:0)-I})(E,C)-l,R=K_(E.data[b.key]),A=R[0],N=R[1],D={id:b.key,value:A===null?A:N,formattedValue:r(N),hidden:!1,index:S,indexValue:w,data:G_(E.data)};v.push({key:b.key+"."+w,index:v.length,data:D,x:O,y:C,absX:m.left+O,absY:m.top+C,width:t,height:T,color:a(D),label:s(D)})}))})),v},"we"),Cqe=i(function(e,t,n){var r=e.formatValue,a=e.getColor,o=e.getIndex,s=e.getTooltipLabel,l=e.innerPadding,f=e.stackedData,c=e.xScale,p=e.yScale,m=e.margin,v=[];return f.forEach((function(b){return p.domain().forEach((function(w,S){var _,j,E=b[S],O=(_=p(o(E.data)))!=null?_:0,C=((j=(function(M){return c(M[n?1:0])})(E))!=null?j:0)+.5*l,T=(function(M,I){var F;return((F=c(M[n?0:1]))!=null?F:0)-I})(E,C)-l,R=K_(E.data[b.key]),A=R[0],N=R[1],D={id:b.key,value:A===null?A:N,formattedValue:r(N),hidden:!1,index:S,indexValue:w,data:G_(E.data)};v.push({key:b.key+"."+w,index:v.length,data:D,x:C,y:O,absX:m.left+C,absY:m.top+O,width:T,height:t,color:a(D),label:s(D)})}))})),v},"Le"),Oqe=i(function(e){var t,n,r=e.data,a=e.layout,o=e.width,s=e.height,l=e.padding,f=l===void 0?0:l,c=e.valueScale,p=e.indexScale,m=e.hiddenIds,v=m===void 0?[]:m,b=qc(e,jqe),w=b.keys.filter((function(U){return!v.includes(U)})),S=XIe().keys(w).offset(ZIe)(Jae(r,w)),_=a==="vertical"?["y","x",o]:["x","y",s],j=_[0],E=_[1],O=_[2],C=Zae(r,b.getIndex,f,p,O,E),T=(n=rie(S),c.type==="log"?n.filter((function(U){return U!==0})):n),R=Math.min.apply(Math,T),A=Math.max.apply(Math,T),N=D3(c,{all:T,min:R,max:A},j==="x"?o:s,j),D=a==="vertical"?[C,N]:[N,C],M=D[0],I=D[1],F=b.innerPadding>0?b.innerPadding:0,L=C.bandwidth(),q=[gn({},b,{innerPadding:F,stackedData:S,xScale:M,yScale:I}),L,(t=c.reverse)!=null&&t];return{xScale:M,yScale:I,bars:L>0?a==="vertical"?Eqe.apply(void 0,q):Cqe.apply(void 0,q):[]}},"Ce"),kqe=i(function(e){var t=e.bars,n=e.direction,r=e.from,a=e.groupMode,o=e.layout,s=e.legendLabel,l=e.reverse,f=Iae(s??(r==="indexes"?"indexValue":"id"));return r==="indexes"?(function(c,p,m){var v=VH(c.map((function(b){var w,S;return{id:(w=b.data.indexValue)!=null?w:"",label:m(b.data),hidden:b.data.hidden,color:(S=b.color)!=null?S:"#000"}})),(function(b){return b.id}));return p==="horizontal"&&v.reverse(),v})(t,o,f):(function(c,p,m,v,b,w){var S=VH(c.map((function(_){var j;return{id:_.data.id,label:w(_.data),hidden:_.data.hidden,color:(j=_.color)!=null?j:"#000"}})),(function(_){return _.id}));return(p==="vertical"&&v==="stacked"&&m==="column"&&b!==!0||p==="horizontal"&&v==="stacked"&&b===!0)&&S.reverse(),S})(t,o,n,a,l,f)},"We"),yW=i(function(e,t,n){var r=e.get(t)||0;e.set(t,r+n)},"Me"),Rqe=i(function(e,t,n){var r=e.get(t)||0;e.set(t,r+(n>0?n:0))},"Be"),Aqe=i(function(e,t,n){var r=e.get(t)||0;e.set(t,Math.max(r,Number(n)))},"Re"),Tqe=i(function(e,t){var n=e.get(t)||0;e.set(t,n+1)},"Oe"),aie=i(function(e){var t,n=e.indexBy,r=n===void 0?Fn.indexBy:n,a=e.keys,o=a===void 0?Fn.keys:a,s=e.label,l=s===void 0?Fn.label:s,f=e.tooltipLabel,c=f===void 0?Fn.tooltipLabel:f,p=e.valueFormat,m=e.colors,v=m===void 0?Fn.colors:m,b=e.colorBy,w=b===void 0?Fn.colorBy:b,S=e.borderColor,_=S===void 0?Fn.borderColor:S,j=e.labelTextColor,E=j===void 0?Fn.labelTextColor:j,O=e.groupMode,C=O===void 0?Fn.groupMode:O,T=e.layout,R=T===void 0?Fn.layout:T,A=e.data,N=e.margin,D=e.width,M=e.height,I=e.padding,F=I===void 0?Fn.padding:I,L=e.innerPadding,q=L===void 0?Fn.innerPadding:L,U=e.valueScale,$=U===void 0?Fn.valueScale:U,V=e.indexScale,z=V===void 0?Fn.indexScale:V,W=e.initialHiddenIds,H=W===void 0?Fn.initialHiddenIds:W,Q=e.enableLabel,Y=Q===void 0?Fn.enableLabel:Q,K=e.labelSkipWidth,ee=K===void 0?Fn.labelSkipWidth:K,te=e.labelSkipHeight,oe=te===void 0?Fn.labelSkipHeight:te,ne=e.legends,fe=ne===void 0?Fn.legends:ne,re=e.legendLabel,ce=e.totalsOffset,he=ce===void 0?Fn.totalsOffset:ce,J=y.useState(H??[]),Me=J[0],we=J[1],Ee=y.useCallback((function(Ke){we((function(pt){return pt.indexOf(Ke)>-1?pt.filter((function(ve){return ve!==Ke})):[].concat(pt,[Ke])}))}),[]),Re=BA(r),ke=BA(l),Ne=BA(c),Ue=P3(p),X=Lr(),se=eqe(v,w),me=gW(_,X),Te=gW(E,X),de=(C==="grouped"?Sqe:Oqe)({layout:R,data:A,getIndex:Re,keys:o,width:D,height:M,getColor:se,padding:F,innerPadding:q,valueScale:$,indexScale:z,hiddenIds:Me,formatValue:Ue,getTooltipLabel:Ne,margin:N}),ue=de.bars,Ae=de.xScale,Pe=de.yScale,Fe=y.useMemo((function(){return ue.filter((function(Ke){return Ke.data.value!==null})).map((function(Ke,pt){return gn({},Ke,{index:pt})}))}),[ue]),Je=y.useCallback((function(Ke){var pt=Ke.width,ve=Ke.height;return!!Y&&!(ee>0&&pt<ee)&&!(oe>0&&ve<oe)}),[Y,ee,oe]),Nt=y.useMemo((function(){return o.map((function(Ke){var pt=ue.find((function(ve){return ve.data.id===Ke}));return gn({},pt,{data:gn({id:Ke},pt?.data,{hidden:Me.includes(Ke)})})}))}),[Me,o,ue]),$t=(t=$.reverse)!=null&&t,Rt=y.useMemo((function(){return fe.map((function(Ke){return[Ke,kqe({bars:Ke.dataFrom==="keys"?Nt:ue,direction:Ke.direction,from:Ke.dataFrom,groupMode:C,layout:R,legendLabel:re,reverse:$t})]}))}),[fe,Nt,ue,C,R,re,$t]),qt=y.useMemo((function(){return(function(Ke,pt,ve,ye,ct,$e,Xe){ye===void 0&&(ye=Fn.layout),ct===void 0&&(ct=Fn.groupMode);var We=[];if(Ke.length===0)return We;var et=new Map,jt=Ke[0].width,Ye=Ke[0].height;if(ct==="stacked"){var mt=new Map;Ke.forEach((function(At){var _t=At.data,gt=_t.indexValue,Ct=_t.value;yW(et,gt,Number(Ct)),Rqe(mt,gt,Number(Ct))})),mt.forEach((function(At,_t){var gt,Ct,Z,pe=et.get(_t)||0;ye==="vertical"?(gt=pt(_t),Ct=ve(At),Z=ve(At/2)):(gt=pt(At),Ct=ve(_t),Z=pt(At/2)),gt+=ye==="vertical"?jt/2:$e,Ct+=ye==="vertical"?-$e:Ye/2,We.push({key:"total_"+_t,x:gt,y:Ct,value:pe,formattedValue:Xe(pe),animationOffset:Z})}))}else if(ct==="grouped"){var Ft=new Map,Pt=new Map;Ke.forEach((function(At){var _t=At.data,gt=_t.indexValue,Ct=_t.value;yW(et,gt,Number(Ct)),Aqe(Ft,gt,Number(Ct)),Tqe(Pt,gt)})),Ft.forEach((function(At,_t){var gt,Ct,Z,pe=et.get(_t)||0,_e=Pt.get(_t);ye==="vertical"?(gt=pt(_t),Ct=ve(At),Z=ve(At/2)):(gt=pt(At),Ct=ve(_t),Z=pt(At/2)),gt+=ye==="vertical"?_e*jt/2:$e,Ct+=ye==="vertical"?-$e:_e*Ye/2,We.push({key:"total_"+_t,x:gt,y:Ct,value:pe,formattedValue:Xe(pe),animationOffset:Z})}))}return We})(ue,Ae,Pe,R,C,he,Ue)}),[ue,Ae,Pe,R,C,he,Ue]);return{bars:ue,barsWithValue:Fe,xScale:Ae,yScale:Pe,getIndex:Re,getLabel:ke,getTooltipLabel:Ne,formatValue:Ue,getColor:se,getBorderColor:me,getLabelColor:Te,shouldRenderBarLabel:Je,hiddenIds:Me,toggleSerie:Ee,legendsWithData:Rt,barTotals:qt}},"Ie"),Nqe=i(function(e){var t=e.data,n=e.springConfig,r=e.animate,a=e.layout,o=a===void 0?In.layout:a,s=Lr();return l_(t,{keys:i(function(l){return l.key},"keys"),from:i(function(l){return{x:o==="vertical"?l.x:l.animationOffset,y:o==="vertical"?l.animationOffset:l.y,labelOpacity:0}},"from"),enter:i(function(l){return{x:l.x,y:l.y,labelOpacity:1}},"enter"),update:i(function(l){return{x:l.x,y:l.y,labelOpacity:1}},"update"),leave:i(function(l){return{x:o==="vertical"?l.x:l.animationOffset,y:o==="vertical"?l.animationOffset:l.y,labelOpacity:0}},"leave"),config:n,immediate:!r,initial:r?void 0:null})((function(l,f){return d.jsx(mr.text,{x:l.x,y:l.y,fillOpacity:l.labelOpacity,style:gn({},s.labels.text,{pointerEvents:"none"}),fontWeight:"bold",fontSize:s.labels.text.fontSize,fontFamily:s.labels.text.fontFamily,textAnchor:o==="vertical"?"middle":"start",alignmentBaseline:o==="vertical"?"alphabetic":"middle",children:f.formattedValue},f.key)}))},"Ve"),Pqe=["isInteractive","animate","motionConfig","theme","renderWrapper"],Dqe=i(function(e){var t,n=e.data,r=e.indexBy,a=e.keys,o=e.margin,s=e.width,l=e.height,f=e.groupMode,c=e.layout,p=e.valueScale,m=e.indexScale,v=e.padding,b=e.innerPadding,w=e.axisTop,S=e.axisRight,_=e.axisBottom,j=_===void 0?In.axisBottom:_,E=e.axisLeft,O=E===void 0?In.axisLeft:E,C=e.enableGridX,T=C===void 0?In.enableGridX:C,R=e.enableGridY,A=R===void 0?In.enableGridY:R,N=e.gridXValues,D=e.gridYValues,M=e.layers,I=M===void 0?In.layers:M,F=e.barComponent,L=F===void 0?In.barComponent:F,q=e.enableLabel,U=q===void 0?In.enableLabel:q,$=e.label,V=e.labelSkipWidth,z=V===void 0?In.labelSkipWidth:V,W=e.labelSkipHeight,H=W===void 0?In.labelSkipHeight:W,Q=e.labelTextColor,Y=e.labelPosition,K=Y===void 0?In.labelPosition:Y,ee=e.labelOffset,te=ee===void 0?In.labelOffset:ee,oe=e.markers,ne=oe===void 0?In.markers:oe,fe=e.colorBy,re=e.colors,ce=e.defs,he=ce===void 0?In.defs:ce,J=e.fill,Me=J===void 0?In.fill:J,we=e.borderRadius,Ee=we===void 0?In.borderRadius:we,Re=e.borderWidth,ke=Re===void 0?In.borderWidth:Re,Ne=e.borderColor,Ue=e.annotations,X=Ue===void 0?In.annotations:Ue,se=e.legendLabel,me=e.tooltipLabel,Te=e.valueFormat,de=e.isInteractive,ue=de===void 0?In.isInteractive:de,Ae=e.tooltip,Pe=Ae===void 0?In.tooltip:Ae,Fe=e.onClick,Je=e.onMouseEnter,Nt=e.onMouseLeave,$t=e.legends,Rt=e.role,qt=Rt===void 0?In.role:Rt,Ke=e.ariaLabel,pt=e.ariaLabelledBy,ve=e.ariaDescribedBy,ye=e.isFocusable,ct=ye===void 0?In.isFocusable:ye,$e=e.barAriaLabel,Xe=e.barAriaLabelledBy,We=e.barAriaDescribedBy,et=e.barAriaHidden,jt=e.barAriaDisabled,Ye=e.initialHiddenIds,mt=e.enableTotals,Ft=mt===void 0?In.enableTotals:mt,Pt=e.totalsOffset,At=Pt===void 0?In.totalsOffset:Pt,_t=e.forwardedRef,gt=go(),Ct=gt.animate,Z=gt.config,pe=Mae(s,l,o),_e=pe.outerWidth,qe=pe.outerHeight,Ve=pe.margin,rt=pe.innerWidth,nt=pe.innerHeight,Qe=aie({indexBy:r,label:$,tooltipLabel:me,valueFormat:Te,colors:re,colorBy:fe,borderColor:Ne,labelTextColor:Q,groupMode:f,layout:c,data:n,keys:a,margin:Ve,width:rt,height:nt,padding:v,innerPadding:b,valueScale:p,indexScale:m,enableLabel:U,labelSkipWidth:z,labelSkipHeight:H,legends:$t,legendLabel:se,initialHiddenIds:Ye,totalsOffset:At}),ot=Qe.bars,ut=Qe.barsWithValue,st=Qe.xScale,lt=Qe.yScale,vt=Qe.getLabel,at=Qe.getTooltipLabel,kt=Qe.getBorderColor,bt=Qe.getLabelColor,Lt=Qe.shouldRenderBarLabel,Mt=Qe.toggleSerie,qr=Qe.legendsWithData,ka=Qe.barTotals,ui=Qe.getColor,ur=eie(c,(t=p?.reverse)!=null&&t,K,te),vo=l_(ut,{keys:i(function(He){return He.key},"keys"),from:i(function(He){return gn({borderColor:kt(He),color:He.color,height:0,labelColor:bt(He),labelOpacity:0},ur(He.width,He.height),{transform:"translate("+He.x+", "+(He.y+He.height)+")",width:He.width},c==="vertical"?{}:{height:He.height,transform:"translate("+He.x+", "+He.y+")",width:0})},"from"),enter:i(function(He){return gn({borderColor:kt(He),color:He.color,height:He.height,labelColor:bt(He),labelOpacity:1},ur(He.width,He.height),{transform:"translate("+He.x+", "+He.y+")",width:He.width})},"enter"),update:i(function(He){return gn({borderColor:kt(He),color:He.color,height:He.height,labelColor:bt(He),labelOpacity:1},ur(He.width,He.height),{transform:"translate("+He.x+", "+He.y+")",width:He.width})},"update"),leave:i(function(He){return gn({borderColor:kt(He),color:He.color,height:0,labelColor:bt(He),labelOpacity:0},ur(He.width,He.height),{labelY:0,transform:"translate("+He.x+", "+(He.y+He.height)+")",width:He.width},c==="vertical"?{}:gn({},ur(He.width,He.height),{labelX:0,height:He.height,transform:"translate("+He.x+", "+He.y+")",width:0}))},"leave"),config:Z,immediate:!Ct,initial:Ct?void 0:null}),zr=y.useMemo((function(){return{borderRadius:Ee,borderWidth:ke,enableLabel:U,isInteractive:ue,labelSkipWidth:z,labelSkipHeight:H,onClick:Fe,onMouseEnter:Je,onMouseLeave:Nt,getTooltipLabel:at,tooltip:Pe,isFocusable:ct,ariaLabel:$e,ariaLabelledBy:Xe,ariaDescribedBy:We,ariaHidden:et,ariaDisabled:jt}}),[Ee,ke,U,at,ue,H,z,Fe,Je,Nt,Pe,ct,$e,Xe,We,et,jt]),Wa=T7e(he,ot,Me,{dataKey:"data",targetKey:"data.fill"}),Jr={annotations:null,axes:null,bars:null,grid:null,legends:null,markers:null,totals:null};I.includes("annotations")&&(Jr.annotations=d.jsx(hqe,{bars:ot,annotations:X},"annotations")),I.includes("axes")&&(Jr.axes=d.jsx(d9e,{xScale:st,yScale:lt,width:rt,height:nt,top:w,right:S,bottom:j,left:O},"axes")),I.includes("bars")&&(Jr.bars=d.jsx(y.Fragment,{children:vo((function(He,qn){return y.createElement(L,gn({},zr,{bar:qn,style:He,shouldRenderLabel:Lt(qn),label:vt(qn.data)}))}))},"bars")),I.includes("grid")&&(Jr.grid=d.jsx(h9e,{width:rt,height:nt,xScale:T?st:null,yScale:A?lt:null,xValues:N,yValues:D},"grid")),I.includes("legends")&&(Jr.legends=d.jsx(pqe,{width:rt,height:nt,legends:qr,toggleSerie:Mt},"legends")),I.includes("markers")&&(Jr.markers=d.jsx(w7e,{markers:ne,width:rt,height:nt,xScale:st,yScale:lt},"markers")),I.includes("totals")&&Ft&&(Jr.totals=d.jsx(Nqe,{data:ka,springConfig:Z,animate:Ct,layout:c},"totals"));var Ga=gn({},zr,{margin:Ve,width:s,height:l,innerWidth:rt,innerHeight:nt,bars:ot,legendData:qr,enableLabel:U,xScale:st,yScale:lt,tooltip:Pe,getTooltipLabel:at,onClick:Fe,onMouseEnter:Je,onMouseLeave:Nt,getColor:ui});return d.jsx(y7e,{width:_e,height:qe,margin:Ve,defs:Wa,role:qt,ariaLabel:Ke,ariaLabelledBy:pt,ariaDescribedBy:ve,isFocusable:ct,ref:_t,children:I.map((function(He,qn){var Ii;return typeof He=="function"?d.jsx(y.Fragment,{children:y.createElement(He,Ga)},qn):(Ii=Jr?.[He])!=null?Ii:null}))})},"He"),Mqe=y.forwardRef((function(e,t){var n=e.isInteractive,r=n===void 0?In.isInteractive:n,a=e.animate,o=a===void 0?In.animate:a,s=e.motionConfig,l=s===void 0?In.motionConfig:s,f=e.theme,c=e.renderWrapper,p=qc(e,Pqe);return d.jsx(Aae,{animate:o,isInteractive:r,motionConfig:l,renderWrapper:c,theme:f,children:d.jsx(Dqe,gn({},p,{isInteractive:r,forwardedRef:t}))})})),Iqe=["isInteractive","renderWrapper","theme"],hT=i(function(e,t,n,r){return e.find((function(a){return O7e(a.x+t.left,a.y+t.top,a.width,a.height,n,r)}))},"Fe"),Fqe=i(function(e){var t,n=e.data,r=e.indexBy,a=e.keys,o=e.margin,s=e.width,l=e.height,f=e.groupMode,c=e.layout,p=e.valueScale,m=e.indexScale,v=e.padding,b=e.innerPadding,w=e.axisTop,S=e.axisRight,_=e.axisBottom,j=_===void 0?yr.axisBottom:_,E=e.axisLeft,O=E===void 0?yr.axisLeft:E,C=e.enableGridX,T=C===void 0?yr.enableGridX:C,R=e.enableGridY,A=R===void 0?yr.enableGridY:R,N=e.gridXValues,D=e.gridYValues,M=e.labelPosition,I=M===void 0?yr.labelPosition:M,F=e.labelOffset,L=F===void 0?yr.labelOffset:F,q=e.layers,U=q===void 0?yr.layers:q,$=e.renderBar,V=$===void 0?yr.renderBar:$,z=e.enableLabel,W=z===void 0?yr.enableLabel:z,H=e.label,Q=e.labelSkipWidth,Y=Q===void 0?yr.labelSkipWidth:Q,K=e.labelSkipHeight,ee=K===void 0?yr.labelSkipHeight:K,te=e.labelTextColor,oe=e.colorBy,ne=e.colors,fe=e.borderRadius,re=fe===void 0?yr.borderRadius:fe,ce=e.borderWidth,he=ce===void 0?yr.borderWidth:ce,J=e.borderColor,Me=e.annotations,we=Me===void 0?yr.annotations:Me,Ee=e.legendLabel,Re=e.tooltipLabel,ke=e.valueFormat,Ne=e.isInteractive,Ue=Ne===void 0?yr.isInteractive:Ne,X=e.tooltip,se=X===void 0?yr.tooltip:X,me=e.onClick,Te=e.onMouseEnter,de=e.onMouseLeave,ue=e.legends,Ae=e.pixelRatio,Pe=Ae===void 0?yr.pixelRatio:Ae,Fe=e.role,Je=e.forwardedRef,Nt=e.enableTotals,$t=Nt===void 0?yr.enableTotals:Nt,Rt=e.totalsOffset,qt=Rt===void 0?yr.totalsOffset:Rt,Ke=y.useRef(null),pt=Lr(),ve=Mae(s,l,o),ye=ve.margin,ct=ve.innerWidth,$e=ve.innerHeight,Xe=ve.outerWidth,We=ve.outerHeight,et=aie({indexBy:r,label:H,tooltipLabel:Re,valueFormat:ke,colors:ne,colorBy:oe,borderColor:J,labelTextColor:te,groupMode:f,layout:c,data:n,keys:a,margin:ye,width:ct,height:$e,padding:v,innerPadding:b,valueScale:p,indexScale:m,enableLabel:W,labelSkipWidth:Y,labelSkipHeight:ee,legends:ue,legendLabel:Ee,totalsOffset:qt}),jt=et.bars,Ye=et.barsWithValue,mt=et.xScale,Ft=et.yScale,Pt=et.getLabel,At=et.getTooltipLabel,_t=et.getBorderColor,gt=et.getLabelColor,Ct=et.shouldRenderBarLabel,Z=et.legendsWithData,pe=et.barTotals,_e=et.getColor,qe=Ere(),Ve=qe.showTooltipFromEvent,rt=qe.hideTooltip,nt=N9e({annotations:Wae({data:jt,annotations:we,getPosition:i(function(at){return{x:at.x,y:at.y}},"getPosition"),getDimensions:i(function(at){var kt=at.width,bt=at.height;return{width:kt,height:bt,size:Math.max(kt,bt)}},"getDimensions")})}),Qe=y.useMemo((function(){return{borderRadius:re,borderWidth:he,isInteractive:Ue,isFocusable:!1,labelSkipWidth:Y,labelSkipHeight:ee,margin:ye,width:s,height:l,innerWidth:ct,innerHeight:$e,bars:jt,legendData:Z,enableLabel:W,xScale:mt,yScale:Ft,tooltip:se,getTooltipLabel:At,onClick:me,onMouseEnter:Te,onMouseLeave:de,getColor:_e}}),[re,he,Ue,Y,ee,ye,s,l,ct,$e,jt,Z,W,mt,Ft,se,At,me,Te,de,_e]),ot=P3(ke),ut=eie(c,(t=p?.reverse)!=null&&t,I,L);y.useEffect((function(){if(Ke.current){Ke.current.width=Xe*Pe,Ke.current.height=We*Pe;var at=Ke.current.getContext("2d");at.scale(Pe,Pe),at.fillStyle=pt.background,at.fillRect(0,0,Xe,We),at.translate(ye.left,ye.top),U.forEach((function(kt){kt==="grid"?typeof pt.grid.line.strokeWidth=="number"&&pt.grid.line.strokeWidth>0&&(at.lineWidth=pt.grid.line.strokeWidth,at.strokeStyle=pt.grid.line.stroke,T&&rW(at,{width:ct,height:$e,scale:mt,axis:"x",values:N}),A&&rW(at,{width:ct,height:$e,scale:Ft,axis:"y",values:D})):kt==="axes"?m9e(at,{xScale:mt,yScale:Ft,width:ct,height:$e,top:w,right:S,bottom:j,left:O,theme:pt}):kt==="bars"?($v(at,pt.text),Ye.forEach((function(bt){V(at,gn({bar:bt,borderColor:_t(bt),borderRadius:re,borderWidth:he,label:Pt(bt.data),shouldRenderLabel:Ct(bt),labelStyle:gn({},pt.labels.text,{fill:gt(bt)})},ut(bt.width,bt.height)))}))):kt==="legends"?Z.forEach((function(bt){var Lt=bt[0],Mt=bt[1];dqe(at,gn({},Lt,{data:Mt,containerWidth:ct,containerHeight:$e,theme:pt}))})):kt==="annotations"?$9e(at,{annotations:nt,theme:pt}):kt==="totals"&&$t?(function(bt,Lt,Mt,qr){qr===void 0&&(qr=yr.layout),$v(bt,Mt.labels.text),bt.textBaseline=qr==="vertical"?"alphabetic":"middle",bt.textAlign=qr==="vertical"?"center":"start",Lt.forEach((function(ka){qv(bt,Mt.labels.text,ka.formattedValue,ka.x,ka.y)}))})(at,pe,pt,c):typeof kt=="function"&&kt(at,Qe)})),at.save()}}),[j,O,S,w,Ye,re,he,nt,T,A,_t,Pt,gt,N,D,f,l,$e,ct,Qe,U,c,Z,ye.left,ye.top,We,Xe,Pe,V,mt,Ft,Ct,pt,s,pe,$t,ot,ut]);var st=y.useCallback((function(at){if(jt&&Ke.current){var kt=VA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=hT(jt,ye,bt,Lt);Mt!==void 0?(Ve(y.createElement(se,gn({},Mt.data,{color:Mt.color,label:Mt.label,value:Number(Mt.data.value)})),at),at.type==="mouseenter"&&Te?.(Mt.data,at)):rt()}}),[rt,ye,Te,jt,Ve,se]),lt=y.useCallback((function(at){if(jt&&Ke.current){rt();var kt=VA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=hT(jt,ye,bt,Lt);Mt&&de?.(Mt.data,at)}}),[rt,ye,de,jt]),vt=y.useCallback((function(at){if(jt&&Ke.current){var kt=VA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=hT(jt,ye,bt,Lt);Mt!==void 0&&me?.(gn({},Mt.data,{color:Mt.color}),at)}}),[ye,me,jt]);return d.jsx("canvas",{ref:N7e(Ke,Je),width:Xe*Pe,height:We*Pe,style:{width:Xe,height:We,cursor:Ue?"auto":"normal"},onMouseEnter:Ue?st:void 0,onMouseMove:Ue?st:void 0,onMouseLeave:Ue?lt:void 0,onClick:Ue?vt:void 0,role:Fe})},"ze"),Lqe=y.forwardRef((function(e,t){var n=e.isInteractive,r=e.renderWrapper,a=e.theme,o=qc(e,Iqe);return d.jsx(Aae,{isInteractive:n,renderWrapper:r,theme:a,animate:!1,children:d.jsx(Fqe,gn({},o,{isInteractive:n,forwardedRef:t}))})})),$qe=["defaultWidth","defaultHeight","onResize","debounceResize"],qqe=y.forwardRef((function(e,t){var n=e.defaultWidth,r=e.defaultHeight,a=e.onResize,o=e.debounceResize,s=qc(e,$qe);return d.jsx(Tae,{defaultWidth:n,defaultHeight:r,onResize:a,debounceResize:o,children:i(function(l){var f=l.width,c=l.height;return d.jsx(Mqe,gn({},s,{width:f,height:c,ref:t}))},"children")})})),zqe=["defaultWidth","defaultHeight","onResize","debounceResize"];y.forwardRef((function(e,t){var n=e.defaultWidth,r=e.defaultHeight,a=e.onResize,o=e.debounceResize,s=qc(e,zqe);return d.jsx(Tae,{defaultWidth:n,defaultHeight:r,onResize:a,debounceResize:o,children:i(function(l){var f=l.width,c=l.height;return d.jsx(Lqe,gn({},s,{width:f,height:c,ref:t}))},"children")})}));const Uqe={opportunity:.2,"proposal-sent":.5,"in-negociation":.8,delayed:.3},Bqe=new Date(new Date().setMonth(new Date().getMonth()-6)).toISOString(),bW="en-US",Vqe="USD",Hqe=y.memo(()=>{const e=navigator?navigator.languages||[navigator.language]:[bW],{data:t,isPending:n}=wa("deals",{pagination:{perPage:100,page:1},sort:{field:"created_at",order:"ASC"},filter:{"created_at@gte":Bqe}}),r=y.useMemo(()=>{if(!t)return[];const s=t.reduce((f,c)=>{const p=cN(c.created_at??new Date).toISOString();return f[p]||(f[p]=[]),f[p].push(c),f},{});return Object.keys(s).map(f=>({date:fc(f,"MMM"),won:s[f].filter(c=>c.stage==="won").reduce((c,p)=>{const m=p.amount??0;return isNaN(m)||(c+=m),c},0),pending:s[f].filter(c=>!["won","lost"].includes(c.stage)).reduce((c,p)=>{const m=p.amount??0,v=Uqe[p.stage]??0;return!isNaN(m)&&!isNaN(v)&&(c+=m*v),c},0),lost:s[f].filter(c=>c.stage==="lost").reduce((c,p)=>{const m=p.amount??0;return isNaN(m)||(c-=m),c},0)})).filter(f=>!isNaN(f.won)&&!isNaN(f.pending)&&!isNaN(f.lost))},[t]);if(n||r.length===0)return null;const a=r.reduce((s,l)=>(s.min=Math.min(s.min,l.lost),s.max=Math.max(s.max,l.won+l.pending),s),{min:0,max:0}),o={min:a.min===0&&a.max===0?-100:a.min*1.2,max:a.min===0&&a.max===0?100:a.max*1.2};return d.jsxs("div",{className:"flex flex-col",children:[d.jsxs("div",{className:"flex items-center mb-4",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(kQ,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"Upcoming Deal Revenue"})]}),d.jsx("div",{className:"h-[400px]",children:d.jsx(qqe,{data:r,indexBy:"date",keys:["won","pending","lost"],colors:["#61cdbb","#97e3d5","#e25c3b"],margin:{top:30,right:50,bottom:30,left:0},padding:.3,valueScale:{type:"linear",min:o.min,max:o.max},indexScale:{type:"band",round:!0},enableGridX:!0,enableGridY:!1,enableLabel:!1,tooltip:i(({value:s,indexValue:l})=>d.jsxs("div",{className:"p-2 bg-secondary rounded shadow inline-flex items-center gap-1 text-secondary-foreground",children:[d.jsxs("strong",{children:[l,": "]})," ",s>0?"+":"",s.toLocaleString(e.at(0)??bW,{style:"currency",currency:Vqe})]}),"tooltip"),axisTop:{tickSize:0,tickPadding:12,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},axisBottom:{legendPosition:"middle",legendOffset:50,tickSize:0,tickPadding:12,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},axisLeft:null,axisRight:{format:i(s=>`${Math.abs(s/1e3)}k`,"format"),tickValues:8,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},markers:[{axis:"y",value:0,lineStyle:{strokeOpacity:0},textStyle:{fill:"#2ebca6"},legend:"Won",legendPosition:"top-left",legendOrientation:"vertical"},{axis:"y",value:0,lineStyle:{stroke:"#f47560",strokeWidth:1},textStyle:{fill:"#e25c3b"},legend:"Lost",legendPosition:"bottom-left",legendOrientation:"vertical"}]})})]})}),Wqe=i(e=>{const t=xt(),n=Wt(e),{filterValues:r,setFilters:a}=Uw(e),o=hd();if(!n)throw new Error("<ListNoResults> must be used inside a <List> component");return d.jsx("div",{className:"p-6",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:r&&a&&Object.keys(r).length>0?d.jsxs(d.Fragment,{children:[t("ra.navigation.no_filtered_results",{resource:n,name:o(n,0),_:"No results found with the current filters."})," ",d.jsx(Le,{variant:"outline",size:"sm",onClick:i(()=>a({},[]),"onClick"),children:t("ra.navigation.clear_filters",{_:"Clear filters"})})]}):t("ra.navigation.no_results",{resource:n,name:o(n,0),_:"No results found."})})})},"ListNoResults"),Gqe=i(e=>{const{children:t,linkType:n,rowClick:r,style:a}=e,o=Wt(e),s=Vt(e),l=ja(),f=typeof n=="function"||typeof r=="function",c=eK({link:f?!1:n??r,resource:o}),p=rK(),m=Et(async()=>{if(!f||!s)return;const v=typeof n=="function"?n(s,s.id):typeof r=="function"?(w,S)=>r(w.id,S,w):!1,b=await p({record:s,resource:o,link:v});b===!1||b==null||l(b)});return s?f?d.jsx("li",{className:"w-full",children:d.jsx("button",{onClick:m,style:a,className:"w-full text-left hover:bg-muted focus: bg-muted focus:outline-none",children:t})}):c?d.jsx("li",{className:"w-full",children:d.jsx(fn,{to:c,style:a,className:"block w-full hover:bg-muted focus:bg-muted focus:outline-none",children:t})}):d.jsx("li",{className:"w-full",children:t}):null},"SimpleListItem"),pT=i(({className:e})=>d.jsx("span",{className:Se("bg-gray-300 flex",e),children:" "}),"ListPlaceholder"),Kqe=i(e=>{const{className:t,hasLeftAvatarOrIcon:n,hasRightAvatarOrIcon:r,hasSecondaryText:a,hasTertiaryText:o,nbFakeLines:s=5,...l}=e;return PK(1e3)?d.jsx("ul",{className:t,...l,children:Yqe(s,c=>d.jsxs("li",{className:"flex items-center space-x-3 p-3",children:[n&&d.jsx("div",{className:"w-10 h-10 bg-gray-300 rounded-full flex-shrink-0",children:" "}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"mb-1",children:[d.jsx(pT,{className:"w-1/3 inline-block mb-1"}),o&&d.jsx("span",{className:"float-right opacity-55 min-w-[10vw]",children:d.jsx(pT,{})})]}),a&&d.jsx(pT,{className:"w-1/4"})]}),r&&d.jsx("div",{className:"w-10 h-10 bg-gray-300 rounded-full flex-shrink-0",children:" "})]},c))}):null},"SimpleListLoading"),Yqe=i((e,t)=>Array.from({length:e},(n,r)=>t(r)),"times"),Qqe=i(e=>{const{className:t,empty:n=Zqe,leftAvatar:r,leftIcon:a,linkType:o,rowClick:s,primaryText:l,rightAvatar:f,rightIcon:c,secondaryText:p,tertiaryText:m,resource:v,...b}=e,{data:w,isPending:S,total:_}=Uw(e);return S===!0?d.jsx(Kqe,{className:t,hasLeftAvatarOrIcon:!!a||!!r,hasRightAvatarOrIcon:!!c||!!f,hasSecondaryText:!!p,hasTertiaryText:!!m}):w==null||w.length===0||_===0?n||null:d.jsx("ul",{className:t,...hme(b),children:d.jsx(xme,{data:w,total:_,render:i((j,E)=>d.jsx(Gqe,{rowIndex:E,linkType:o,rowClick:s,resource:v,children:d.jsx(Xqe,{leftAvatar:r,leftIcon:a,primaryText:l,rightAvatar:f,rightIcon:c,secondaryText:p,tertiaryText:m,rowIndex:E})},j.id),"render")})})},"SimpleList"),Xqe=i(e=>{const{leftAvatar:t,leftIcon:n,primaryText:r,rightAvatar:a,rightIcon:o,secondaryText:s,tertiaryText:l}=e,f=Wt(e),c=Vt(e),p=Oc(f),m=xt(),v=i((b,w)=>{const S=w(b,b.id);return typeof S=="string"&&(S.startsWith("http")||S.startsWith("data:"))?d.jsx("img",{src:S,alt:"",className:"w-10 h-10 rounded-full object-cover"}):d.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center text-sm",children:S})},"renderAvatar");return c?d.jsxs("div",{className:"flex items-center space-x-3 p-3",children:[n&&d.jsx("div",{className:"flex-shrink-0",children:n(c,c.id)}),t&&d.jsx("div",{className:"flex-shrink-0",children:v(c,t)}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"text-sm font-medium truncate",children:r?typeof r=="string"?m(r,{...c,_:r}):y.isValidElement(r)?r:r(c,c.id):p(c)}),!!l&&d.jsx("div",{className:"text-xs text-muted-foreground ml-2",children:typeof l=="string"?m(l,{...c,_:l}):y.isValidElement(l)?l:l(c,c.id)})]}),!!s&&d.jsx("div",{className:"text-sm text-muted-foreground truncate",children:typeof s=="string"?m(s,{...c,_:s}):y.isValidElement(s)?s:s(c,c.id)})]}),(a||o)&&d.jsxs("div",{className:"flex-shrink-0 flex items-center space-x-2",children:[a&&v(c,a),o&&o(c,c.id)]})]}):null},"SimpleListItemContent"),Zqe=d.jsx(Wqe,{}),Jqe=i(()=>{const{identity:e}=Jn(),{data:t,total:n,isPending:r}=wa("contacts",{pagination:{page:1,perPage:10},sort:{field:"last_seen",order:"DESC"},filter:{status:"hot",sales_id:e?.id}},{enabled:Number.isInteger(e?.id)});return d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(FM,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"Hot Contacts"}),d.jsx(Ni,{children:d.jsxs(io,{children:[d.jsx(oo,{asChild:!0,children:d.jsx(Le,{variant:"ghost",size:"sm",className:"ml-auto text-muted-foreground",asChild:!0,children:d.jsx(fn,{to:"/contacts/create",children:d.jsx(eo,{className:"w-4 h-4 text-primary"})})})}),d.jsx(so,{children:"Create contact"})]})})]}),d.jsx(pn,{className:"py-0",children:d.jsx(Qqe,{linkType:"show",data:t,total:n,isPending:r,resource:"contacts",className:"[&>li:first-child>a]:rounded-t-xl [&>li:last-child>a]:rounded-b-xl",primaryText:i(a=>`${a.first_name} ${a.last_name}`,"primaryText"),secondaryText:i(a=>d.jsxs(d.Fragment,{children:[a.title," at ",a.company_name]}),"secondaryText"),leftAvatar:i(a=>d.jsx(os,{record:a}),"leftAvatar"),empty:d.jsxs("div",{className:"p-4",children:[d.jsx("p",{className:"text-sm mb-4",children:'Contacts with a "hot" status will appear here.'}),d.jsx("p",{className:"text-sm",children:'Change the status of a contact by adding a note to that contact and clicking on "show options".'})]})})})]})},"HotContacts"),eze=i(()=>{const{identity:e}=Jn(),{total:t}=wa("tasks",{pagination:{page:1,perPage:1},filter:{sales_id:e?.id}},{enabled:!!e});return t?null:d.jsx("p",{className:"text-sm",children:"Tasks added to your contacts will appear here."})},"TasksListEmpty"),hg=i(({title:e,filter:t})=>{const{identity:n}=Jn(),{data:r,total:a,isPending:o}=wa("tasks",{pagination:{page:1,perPage:100},sort:{field:"due_date",order:"ASC"},filter:{...t,sales_id:n?.id}},{enabled:!!n}),s=Bw({data:r,isPending:o,resource:"tasks",perPage:5});return o||!r||!a?null:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground font-medium mb-2",children:e}),d.jsx(fd,{value:"tasks",children:d.jsx(iy,{value:s,children:d.jsx(Ane,{showContact:!0})})}),a>s.perPage&&d.jsx("div",{className:"flex justify-center",children:d.jsx("a",{href:"#",onClick:i(l=>{s.setPerPage(s.perPage+10),l.preventDefault()},"onClick"),className:"text-sm underline hover:no-underline",children:"Load more"})})]})},"TasksListFilter"),iie=new Date,tze=Z0e(iie),nze=tze<5,xW=ebe().toISOString(),wW=Xye().toISOString(),_W=Zye().toISOString(),SW=Qye(iie,{weekStartsOn:0}).toISOString(),pg={overdue:{"done_date@is":null,"due_date@lt":xW},today:{"done_date@is":null,"due_date@gte":xW,"due_date@lte":wW},tomorrow:{"done_date@is":null,"due_date@gt":wW,"due_date@lt":_W},thisWeek:{"done_date@is":null,"due_date@gte":_W,"due_date@lte":SW},later:{"done_date@is":null,"due_date@gt":SW}},rze=i(()=>d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(NQ,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground flex-1",children:"Upcoming Tasks"}),d.jsx(Rne,{display:"icon",selectContact:!0})]}),d.jsx(pn,{className:"p-4 mb-2",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx(eze,{}),d.jsx(hg,{title:"Overdue",filter:pg.overdue}),d.jsx(hg,{title:"Today",filter:pg.today}),d.jsx(hg,{title:"Tomorrow",filter:pg.tomorrow}),nze&&d.jsx(hg,{title:"This week",filter:pg.thisWeek}),d.jsx(hg,{title:"Later",filter:pg.later})]})})]}),"TasksList"),aze=i(()=>{const{data:e,total:t,isPending:n}=wa("contacts",{pagination:{page:1,perPage:1}}),{total:r,isPending:a}=wa("contactNotes",{pagination:{page:1,perPage:1}}),{total:o,isPending:s}=wa("deals",{pagination:{page:1,perPage:1}});return n||a||s?null:t?r?d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6 mt-1",children:[d.jsx("div",{className:"md:col-span-3",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[null,d.jsx(Jqe,{})]})}),d.jsx("div",{className:"md:col-span-6",children:d.jsxs("div",{className:"flex flex-col gap-6",children:[o?d.jsx(Hqe,{}):null,d.jsx(n6e,{})]})}),d.jsx("div",{className:"md:col-span-3",children:d.jsx(rze,{})})]}):d.jsx(SV,{step:2,contactId:e?.[0]?.id}):d.jsx(SV,{step:1})},"Dashboard"),ize=y.lazy(()=>$p(()=>import("./DealList-syAJzJpA.js"),[],import.meta.url)),oze={list:ize},sze=y.createContext(void 0),Y_=i(()=>y.useContext(sze),"useUserMenu"),lze=i(()=>{const{darkModeLogo:e,lightModeLogo:t,title:n}=Ha(),r=Fr(),o=[{path:"/",pattern:"/"},{path:"/contacts",pattern:"/contacts/*"},{path:"/companies",pattern:"/companies/*"},{path:"/deals",pattern:"/deals/*"}].find(s=>rp(s.pattern,r.pathname))?.path||!1;return d.jsx("header",{className:"bg-secondary fixed top-0 left-0 right-0 z-50 border-b border-border",children:d.jsx("div",{className:"px-4",children:d.jsxs("div",{className:"flex justify-between items-center flex-1",children:[d.jsx(cze,{darkLogo:e,lightLogo:t,title:n}),d.jsxs("nav",{className:"flex","aria-label":"Main navigation",children:[d.jsx(Ob,{label:"Dashboard",to:"/",isActive:o==="/"}),d.jsx(Ob,{label:"Contacts",to:"/contacts",isActive:o==="/contacts"}),d.jsx(Ob,{label:"Companies",to:"/companies",isActive:o==="/companies"}),d.jsx(Ob,{label:"Deals",to:"/deals",isActive:o==="/deals"})]}),d.jsxs("div",{className:"flex items-center",children:[d.jsx(qZ,{}),d.jsx(zZ,{}),d.jsxs(FZ,{children:[d.jsx(dze,{}),d.jsx(fze,{}),d.jsx(hze,{}),d.jsx(Ive,{resource:"sales",action:"list",children:d.jsx(uze,{})}),d.jsx(ov,{}),d.jsx(c4,{className:"font-normal",children:d.jsxs("div",{className:"text-xs text-muted-foreground",children:["Version ","0.12.3"]})})]})]})]})})})},"Header"),cze=i(({darkLogo:e,lightLogo:t,title:n})=>d.jsxs(fn,{to:"/",className:"flex items-center gap-2 text-secondary-foreground no-underline hover:opacity-80 transition-opacity",children:[d.jsx("img",{className:"[.light_&]:hidden h-6",src:e,alt:`${n} logo`}),d.jsx("img",{className:"[.dark_&]:hidden h-6",src:t,alt:`${n} logo`}),d.jsx("h1",{className:"text-xl font-semibold",children:n})]}),"Logo"),Ob=i(({label:e,to:t,isActive:n})=>d.jsx(fn,{to:t,className:`px-6 py-3 text-sm font-medium transition-colors border-b-2 ${n?"text-secondary-foreground border-secondary-foreground":"text-secondary-foreground/70 border-transparent hover:text-secondary-foreground/80"}`,children:e}),"NavigationTab"),uze=i(()=>{const{onClose:e}=Y_()??{};return d.jsx(lr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/sales",className:"flex items-center gap-2",children:[d.jsx(IQ,{className:"h-4 w-4"}),"Users"]})})},"UsersMenu"),dze=i(()=>{const{onClose:e}=Y_()??{};return d.jsx(lr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/settings",className:"flex items-center gap-2",children:[d.jsx(fN,{className:"h-4 w-4"}),"My info"]})})},"ConfigurationMenu"),fze=i(()=>{const{onClose:e}=Y_()??{};return d.jsx(lr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/database",className:"flex items-center gap-2",children:[d.jsx(ev,{className:"h-4 w-4"}),"Database"]})})},"DatabaseMenu"),hze=i(()=>{const{onClose:e}=Y_()??{};return d.jsx(lr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/integrations",className:"flex items-center gap-2",children:[d.jsx(f_e,{className:"h-4 w-4"}),"Integrations"]})})},"IntegrationsMenu"),pze=i(({children:e})=>d.jsxs(d.Fragment,{children:[d.jsx(lze,{}),d.jsx("main",{className:"max-w-screen-xl mx-auto pt-20 px-4",id:"main-content",children:d.jsx(mx,{FallbackComponent:UZ,children:d.jsx(y.Suspense,{fallback:d.jsx(sn,{className:"h-12 w-12 rounded-full"}),children:e})})}),d.jsx(N1,{})]}),"Layout"),oie=i(()=>d.jsx("div",{className:"max-w-screen-xl mx-auto h-screen pt-8",children:d.jsx("div",{className:"h-full",children:d.jsxs("div",{className:"max-w-sm mx-auto h-full flex flex-col justify-center gap-8",children:[d.jsx(sn,{className:"w-full h-[100px]"}),d.jsx(sn,{className:"w-4/5 h-[50px]"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-2/5 h-9"})]})})}),"LoginSkeleton"),iD=i(()=>{const e=Nn(),t=xn(),{darkModeLogo:n,title:r}=Ha(),{data:a,isPending:o}=Qr({queryKey:["init"],queryFn:i(async()=>t.isInitialized(),"queryFn")}),{isPending:s,mutate:l}=Mr({mutationKey:["signup"],mutationFn:i(async w=>t.signUp(w),"mutationFn"),onSuccess:i(w=>{f({email:w.email,password:w.password,redirectTo:"/contacts"}).then(()=>{c("Initial user successfully created"),e.invalidateQueries({queryKey:["auth","canAccess"]})})},"onSuccess"),onError:i(()=>{c("An error occurred. Please try again.")},"onError")}),f=jY(),c=Bt(),{register:p,handleSubmit:m,formState:{isValid:v}}=ly({mode:"onChange"});if(o)return d.jsx(oie,{});if(a)return d.jsx(bw,{to:"/login"});const b=i(async w=>{l(w)},"onSubmit");return d.jsxs("div",{className:"h-screen p-8",children:[d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx("img",{src:n,alt:r,width:24,className:"filter brightness-0 invert"}),d.jsx("h1",{className:"text-xl font-semibold",children:r})]}),d.jsx("div",{className:"h-full",children:d.jsxs("div",{className:"max-w-sm mx-auto h-full flex flex-col justify-center gap-4",children:[d.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Welcome to CRM"}),d.jsx("p",{className:"text-base mb-4",children:"Create the first user account to complete the setup."}),d.jsxs("form",{onSubmit:m(b),className:"space-y-4",children:[d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"first_name",children:"First name"}),d.jsx(Sr,{...p("first_name",{required:!0}),id:"first_name",type:"text",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"last_name",children:"Last name"}),d.jsx(Sr,{...p("last_name",{required:!0}),id:"last_name",type:"text",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"email",children:"Email"}),d.jsx(Sr,{...p("email",{required:!0}),id:"email",type:"email",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"password",children:"Password"}),d.jsx(Sr,{...p("password",{required:!0}),id:"password",type:"password",required:!0})]}),d.jsx("div",{className:"flex justify-between items-center mt-8",children:d.jsx(Le,{type:"submit",disabled:!v||s,className:"w-full",children:s?d.jsxs(d.Fragment,{children:[d.jsx(Rc,{className:"w-4 h-4 animate-spin mr-2"}),"Creating..."]}):"Create account"})})]})]})})]})},"SignupPage");iD.path="/sign-up";const mze=i((e,t)=>e==="admin"?!0:t.resource!=="sales","canAccess"),mT=rAe(Ln,{getIdentity:i(async()=>{const e=await sie();if(e==null)throw new Error;return{id:e.id,fullName:`${e.first_name} ${e.last_name}`,avatar:e.avatar?.src}},"getIdentity")});async function Gs(){if(Gs._is_initialized_cache==null){const{data:e}=await Ln.from("init_state").select("is_initialized");Gs._is_initialized_cache=e?.at(0)?.is_initialized>0}return Gs._is_initialized_cache}i(Gs,"getIsInitialized");(e=>{e._is_initialized_cache=null})(Gs||(Gs={}));const gze={...mT,login:i(async e=>{const t=await mT.login(e);return Ub=void 0,t},"login"),checkAuth:i(async e=>{if(window.location.pathname==="/set-password"||window.location.hash.includes("#/set-password")||window.location.pathname==="/forgot-password"||window.location.hash.includes("#/forgot-password")||window.location.pathname==="/change-password"||window.location.hash.includes("#/change-password")||window.location.pathname==="/otp-login"||window.location.hash.includes("#/otp-login")||window.location.pathname==="/sign-up"||window.location.hash.includes("#/sign-up"))return;if(!await Gs())throw await Ln.auth.signOut(),{redirectTo:"/sign-up",message:!1};return mT.checkAuth(e)},"checkAuth"),canAccess:i(async e=>{if(!await Gs())return!1;const n=await sie();if(n==null)return!1;const r=n.administrator?"admin":"user";return mze(r,e)},"canAccess")};let Ub;const sie=i(async()=>{if(Ub!=null)return Ub;const{data:e,error:t}=await Ln.auth.getSession();if(e?.session?.user==null||t)return;const{data:n,error:r}=await Ln.from("sales").select("id, first_name, last_name, avatar, administrator").match({user_id:e?.session?.user.id}).single();if(!(n==null||r))return Ub=n,n},"getSaleFromCache");async function vze(e,t,n){const r={};t&&(r.id=t);const a={};t&&(a.company_id=t);const[o,s,l,f]=await Promise.all([yze(e,r),bze(e,a),xze(e,a),wze(e,a)]);return[...o,...s,...l,...f].sort((c,p)=>c.date&&p.date?c.date.localeCompare(p.date)*-1:0).slice(0,250)}i(vze,"getActivityLog");const yze=i(async(e,t)=>{const{data:n}=await e.getList("companies",{filter:t,pagination:{page:1,perPage:250},sort:{field:"created_at",order:"DESC"}});return n.map(r=>({id:`company.${r.id}.created`,type:kte,company_id:r.id,company:r,sales_id:r.sales_id,date:r.created_at}))},"getNewCompanies");async function bze(e,t){const{data:n}=await e.getList("contacts",{filter:t,pagination:{page:1,perPage:250},sort:{field:"first_seen",order:"DESC"}}),r={};if(t.sales_id&&(r.sales_id=t.sales_id),t.company_id){const l=n.map(f=>f.id).join(",");r["contact_id@in"]=`(${l})`}const{data:a}=await e.getList("contactNotes",{filter:r,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}}),o=n.map(l=>({id:`contact.${l.id}.created`,type:Ate,company_id:l.company_id,sales_id:l.sales_id,contact:l,date:l.first_seen})),s=a.map(l=>({id:`contactNote.${l.id}.created`,type:Tte,sales_id:l.sales_id,contactNote:l,date:l.date}));return[...o,...s]}i(bze,"getNewContactsAndNotes");async function xze(e,t){const{data:n}=await e.getList("deals",{filter:t,pagination:{page:1,perPage:250},sort:{field:"created_at",order:"DESC"}}),r={};if(t.sales_id&&(r.sales_id=t.sales_id),t.company_id){const l=n.map(f=>f.id).join(",");r["deal_id@in"]=`(${l})`}const{data:a}=await e.getList("dealNotes",{filter:r,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}}),o=n.map(l=>({id:`deal.${l.id}.created`,type:Nte,company_id:l.company_id,sales_id:l.sales_id,deal:l,date:l.created_at})),s=a.map(l=>({id:`dealNote.${l.id}.created`,type:Pte,sales_id:l.sales_id,dealNote:l,date:l.date}));return[...o,...s]}i(xze,"getNewDealsAndNotes");async function wze(e,t){const n={};t.sales_id&&(n.sales_id=t.sales_id),t.company_id&&(n.company_id=t.company_id);const{data:r}=await e.getList("companyNotes",{filter:n,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}});return r.map(o=>({id:`companyNote.${o.id}.created`,type:Rte,sales_id:o.sales_id,companyNote:o,date:o.date}))}i(wze,"getNewCompanyNotes");async function _ze(e){return e.website?{src:`https://favicon.show/${e.website.replace(/^https?:\/\//,"").replace(/\/$/,"")}`,title:"Company favicon"}:null}i(_ze,"getCompanyAvatar");async function Sze(e,t={}){const{timeout:n=2e3}=t,r=new AbortController,a=setTimeout(()=>r.abort(),n),o=await fetch(e,{...t,signal:r.signal});return clearTimeout(a),o}i(Sze,"fetchWithTimeout");const jze=["gmail.com","yahoo.com","hotmail.com","aol.com","hotmail.co.uk","hotmail.fr","msn.com","yahoo.fr","wanadoo.fr","orange.fr","comcast.net","yahoo.co.uk","yahoo.com.br","yahoo.co.in","live.com","rediffmail.com","free.fr","gmx.de","web.de","yandex.ru","ymail.com","libero.it","outlook.com","uol.com.br","bol.com.br","mail.ru","cox.net","hotmail.it","sbcglobal.net","sfr.fr","live.fr","verizon.net","live.co.uk","googlemail.com","yahoo.es","ig.com.br","live.nl","bigpond.com","terra.com.br","yahoo.it","neuf.fr","yahoo.de","alice.it","rocketmail.com","att.net","laposte.net","facebook.com","bellsouth.net","yahoo.in","hotmail.es","charter.net","yahoo.ca","yahoo.com.au","rambler.ru","hotmail.de","tiscali.it","shaw.ca","yahoo.co.jp","sky.com","earthlink.net","optonline.net","freenet.de","t-online.de","aliceadsl.fr","virgilio.it","home.nl","qq.com","telenet.be","me.com","yahoo.com.ar","tiscali.co.uk","yahoo.com.mx","voila.fr","gmx.net","mail.com","planet.nl","tin.it","live.it","ntlworld.com","arcor.de","yahoo.co.id","frontiernet.net","hetnet.nl","live.com.au","yahoo.com.sg","zonnet.nl","club-internet.fr","juno.com","optusnet.com.au","blueyonder.co.uk","bluewin.ch","skynet.be","sympatico.ca","windstream.net","mac.com","centurytel.net","chello.nl","live.ca","aim.com","bigpond.net.au","online.de","apple.com"];async function Eze(e){const t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(o=>o.toString(16).padStart(2,"0")).join("")}i(Eze,"hash");async function Cze(e){return`https://www.gravatar.com/avatar/${await Eze(e)}?d=404`}i(Cze,"getGravatarUrl");async function Oze(e){if(jze.includes(e))return null;try{const t=`https://${e}/favicon.ico`;if((await Sze(t)).ok)return t}catch{return null}return null}i(Oze,"getFaviconUrl");async function kze(e){if(!e.email_jsonb||!e.email_jsonb.length)return null;for(const{email:t}of e.email_jsonb){const n=await Cze(t);try{if((await fetch(n)).ok)return n}catch{}const r=t.split("@")[1],a=await Oze(r);if(a)return a}return null}i(kze,"getContactAvatar");const jW=wd()||{url:"https://placeholder.supabase.co",anonKey:"placeholder-key"},Co=wAe({instanceUrl:jW.url,apiKey:jW.anonKey,supabaseClient:Ln,sortOrder:"asc,desc.nullslast"}),EW=i(async e=>{let t=e.data.logo;return typeof t!="object"||t===null||!t.src?t=await _ze(e.data):t.rawFile instanceof File&&await Bb(t),{...e,data:{...e.data,logo:t}}},"processCompanyLogo");async function CW(e){const{data:t}=e;if(t.avatar?.src||!t.email_jsonb||!t.email_jsonb.length)return e;const n=await kze(t),r={...t,avatar:{src:n||void 0}};return{...e,data:r}}i(CW,"processContactAvatar");const Rze={...Co,async getList(e,t){return e==="companies"?Co.getList("companies_summary",t):e==="contacts"?Co.getList("contacts_summary",t):Co.getList(e,t)},async getOne(e,t){return e==="companies"?Co.getOne("companies_summary",t):e==="contacts"?Co.getOne("contacts_summary",t):Co.getOne(e,t)},async signUp({email:e,password:t,first_name:n,last_name:r}){const{data:a,error:o}=await Ln.functions.invoke("setup",{method:"POST",body:{email:e,password:t,first_name:n,last_name:r}});if(!a||o)throw console.error("signUp.error",o),new Error("Failed to create account");return Gs._is_initialized_cache=!0,{id:a.data.id,email:e,password:t}},async salesCreate(e){const{data:t,error:n}=await Ln.functions.invoke("users",{method:"POST",body:e});if(!t||n)throw console.error("salesCreate.error",n),new Error("Failed to create account manager");return t},async salesUpdate(e,t){const{email:n,first_name:r,last_name:a,administrator:o,avatar:s,disabled:l}=t,{data:f,error:c}=await Ln.functions.invoke("users",{method:"PATCH",body:{sales_id:e,email:n,first_name:r,last_name:a,administrator:o,disabled:l,avatar:s}});if(!f||c)throw console.error("salesCreate.error",c),new Error("Failed to update account manager");return t},async resendInvite(e){const{data:t,error:n}=await Ln.functions.invoke("users",{method:"PUT",body:{sales_id:e,action:"invite"}});if(!t||n)throw console.error("resendInvite.error",n),new Error("Failed to resend invitation");return t},async resetPassword(e){const{data:t,error:n}=await Ln.functions.invoke("users",{method:"PUT",body:{sales_id:e,action:"reset"}});if(!t||n)throw console.error("resetPassword.error",n),new Error("Failed to send password reset");return t},async updatePassword(e){const{data:t,error:n}=await Ln.functions.invoke("updatePassword",{method:"PATCH",body:{sales_id:e}});if(!t||n)throw console.error("passwordUpdate.error",n),new Error("Failed to update password");return t},async unarchiveDeal(e){const{data:t}=await Co.getList("deals",{filter:{stage:e.stage},pagination:{page:1,perPage:1e3},sort:{field:"index",order:"ASC"}}),n=t.map((r,a)=>({...r,index:r.id===e.id?0:a+1,archived_at:r.id===e.id?null:r.archived_at}));return await Promise.all(n.map(r=>Co.update("deals",{id:r.id,data:r,previousData:t.find(a=>a.id===r.id)})))},async getActivityLog(e){return vze(Co,e)},async isInitialized(){return Gs()},async mergeContacts(e,t){const{data:n,error:r}=await Ln.functions.invoke("mergeContacts",{method:"POST",body:{loserId:e,winnerId:t}});if(r)throw console.error("mergeContacts.error",r),new Error("Failed to merge contacts");return n},async mergeCompanies(e,t){const{data:n,error:r}=await Ln.functions.invoke("mergeCompanies",{method:"POST",body:{loserId:e,winnerId:t}});if(r)throw console.error("mergeCompanies.error",r),new Error("Failed to merge companies");return n}},Aze=She(Rze,[{resource:"contactNotes",beforeSave:i(async(e,t,n)=>{if(e.attachments)for(const r of e.attachments)await Bb(r);return e},"beforeSave")},{resource:"dealNotes",beforeSave:i(async(e,t,n)=>{if(e.attachments)for(const r of e.attachments)await Bb(r);return e},"beforeSave")},{resource:"sales",beforeSave:i(async(e,t,n)=>(e.avatar&&await Bb(e.avatar),e),"beforeSave")},{resource:"contacts",beforeCreate:i(async e=>CW(e),"beforeCreate"),beforeUpdate:i(async e=>CW(e),"beforeUpdate"),beforeGetList:i(async e=>kb(["first_name","last_name","company_name","title","email","phone","background"])(e),"beforeGetList")},{resource:"companies",beforeGetList:i(async e=>kb(["name","phone_number","website","zipcode","city","stateAbbr"])(e),"beforeGetList"),beforeCreate:i(async e=>{const t=await EW(e);return{...t,data:{...t.data,created_at:new Date().toISOString()}}},"beforeCreate"),beforeUpdate:i(async e=>await EW(e),"beforeUpdate")},{resource:"contacts_summary",beforeGetList:i(async e=>kb(["first_name","last_name"])(e),"beforeGetList")},{resource:"deals",beforeGetList:i(async e=>kb(["name","type","description"])(e),"beforeGetList")}]),kb=i(e=>t=>{if(!t.filter?.q)return t;const{q:n,...r}=t.filter;return{...t,filter:{...r,"@or":e.reduce((a,o)=>o==="email"?{...a,"email_fts@ilike":n}:o==="phone"?{...a,"phone_fts@ilike":n}:{...a,[`${o}@ilike`]:n},{})}}},"applyFullTextSearch"),Bb=i(async e=>{if(!e.src.startsWith("blob:")&&!e.src.startsWith("data:")&&e.path){const{error:c}=await Ln.storage.from("attachments").createSignedUrl(e.path,60);if(!c)return}const t=e.src?await fetch(e.src).then(c=>c.blob()):e.rawFile,n=e.rawFile,r=n.name.split(".").pop(),o=`${`${Math.random()}.${r}`}`,{error:s}=await Ln.storage.from("attachments").upload(o,t);if(s)throw console.error("uploadError",s),new Error("Failed to upload attachment");const{data:l}=Ln.storage.from("attachments").getPublicUrl(o);e.path=o,e.src=l.publicUrl;const f=n.type;return e.type=f,e},"uploadToBucket");function lie(){const{identity:e}=Jn(),t=Vt();return d.jsxs("div",{className:"space-y-4 w-full",children:[d.jsx(ln,{source:"first_name",validate:Zn(),helperText:!1}),d.jsx(ln,{source:"last_name",validate:Zn(),helperText:!1}),d.jsx(ln,{source:"email",validate:[Zn(),rY()],helperText:!1}),d.jsx(OP,{source:"administrator",readOnly:t?.id===e?.id,helperText:!1}),d.jsx(OP,{source:"disabled",readOnly:t?.id===e?.id,helperText:!1})]})}i(lie,"SalesInputs");function Tze(){const e=xn(),t=Bt(),n=po(),{mutate:r}=Mr({mutationKey:["signup"],mutationFn:i(async o=>e.salesCreate(o),"mutationFn"),onSuccess:i(()=>{t("User created. They will soon receive an email to set their password."),n("/sales")},"onSuccess"),onError:i(()=>{t("An error occurred while creating the user.",{type:"error"})},"onError")}),a=i(async o=>{r(o)},"onSubmit");return d.jsx("div",{className:"max-w-lg w-full mx-auto mt-8",children:d.jsxs(pn,{children:[d.jsx(Xo,{children:d.jsx(Zo,{children:"Create a new user"})}),d.jsx(Wn,{children:d.jsx(bee,{onSubmit:a,children:d.jsx(lie,{})})})]})})}i(Tze,"SalesCreate");function Nze(){return d.jsxs("div",{className:"flex justify-end gap-4",children:[d.jsx(U1,{}),d.jsx(bd,{})]})}i(Nze,"EditToolbar");function Pze(){const{record:e}=RK(),t=xn(),n=Bt(),r=po(),{mutate:a}=Mr({mutationKey:["signup"],mutationFn:i(async s=>{if(!e)throw new Error("Record not found");return t.salesUpdate(e.id,s)},"mutationFn"),onSuccess:i(()=>{r("/sales"),n("User updated successfully")},"onSuccess"),onError:i(()=>{n("An error occurred. Please try again.")},"onError")}),o=i(async s=>{a(s)},"onSubmit");return d.jsx("div",{className:"max-w-lg w-full mx-auto mt-8",children:d.jsx(pn,{children:d.jsx(Wn,{children:d.jsxs(bee,{toolbar:d.jsx(Nze,{}),onSubmit:o,record:e,children:[d.jsx(Dze,{}),d.jsx(lie,{})]})})})})}i(Pze,"SalesEdit");const Dze=i(()=>{const e=Vt();return e?d.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Edit ",e?.first_name," ",e?.last_name]}):null},"SaleEditTitle"),Mze=i(()=>d.jsxs(S4,{children:[d.jsx(M1,{}),d.jsx(Dc,{label:"New user"})]}),"SalesListActions"),Ize=[d.jsx(j4,{source:"q",alwaysOn:!0})],Fze=i(e=>{const t=Vt();return t?d.jsxs("div",{className:"flex flex-row gap-1",children:[t.administrator&&d.jsx(Dr,{variant:"outline",className:"border-blue-300 dark:border-blue-700",children:"Admin"}),t.disabled&&d.jsx(Dr,{variant:"outline",className:"border-orange-300 dark:border-orange-700",children:"Disabled"})]}):null},"OptionsField"),Lze=i(()=>{const e=Vt(),t=xn(),n=Bt(),r=Mw(),[a,o]=y.useState(!1),[s,l]=y.useState(!1),{mutate:f,isPending:c}=Mr({mutationFn:i(async()=>t.resendInvite(e.id),"mutationFn"),onSuccess:i(()=>{n("Invitation email resent successfully"),o(!1),r()},"onSuccess"),onError:i(()=>{n("Failed to resend invitation email",{type:"error"}),o(!1)},"onError")}),{mutate:p,isPending:m}=Mr({mutationFn:i(async()=>t.resetPassword(e.id),"mutationFn"),onSuccess:i(()=>{n("Password reset email sent successfully"),l(!1),r()},"onSuccess"),onError:i(()=>{n("Failed to send password reset email",{type:"error"}),l(!1)},"onError")});if(!e)return null;const v=e.email_confirmed_at!==null,b=e.disabled===!0;return console.log("[RowActions] Record:",{email:e.email,email_confirmed_at:e.email_confirmed_at,isConfirmed:v,isDisabled:b,inviteDialogOpen:a,resetDialogOpen:s}),d.jsxs(d.Fragment,{children:[d.jsxs(Nc,{children:[d.jsx(Xs,{asChild:!0,children:d.jsxs(Le,{variant:"ghost",className:"h-8 w-8 p-0",children:[d.jsx("span",{className:"sr-only",children:"Open menu"}),d.jsx(PM,{className:"h-4 w-4"})]})}),d.jsxs(Pc,{align:"end",children:[d.jsx(c4,{children:"Email Actions"}),d.jsx(ov,{}),!v&&d.jsxs(lr,{onClick:i(w=>{w.preventDefault(),w.stopPropagation(),console.log("[Menu] Clicked Resend Invite"),o(!0)},"onClick"),children:[d.jsx(P1e,{className:"mr-2 h-4 w-4"}),"Resend Invite"]}),v&&!b&&d.jsxs(lr,{onClick:i(()=>l(!0),"onClick"),children:[d.jsx(e1e,{className:"mr-2 h-4 w-4"}),"Send Password Reset"]})]})]}),d.jsx(ua,{open:a,onOpenChange:o,children:d.jsxs(da,{onClick:i(w=>w.stopPropagation(),"onClick"),onPointerDown:i(w=>w.stopPropagation(),"onPointerDown"),children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Resend Invitation"}),d.jsxs(ii,{children:["Send a new invitation email to ",d.jsx("strong",{children:e.email}),"?",d.jsx("br",{}),d.jsx("br",{}),"This will send them a fresh invitation link to set up their account."]})]}),d.jsxs(lo,{children:[d.jsx(Le,{variant:"outline",onClick:i(w=>{w.stopPropagation(),o(!1)},"onClick"),disabled:c,children:"Cancel"}),d.jsx(Le,{onClick:i(w=>{w.stopPropagation(),f()},"onClick"),disabled:c,children:c?"Sending...":"Send Invitation"})]})]})}),d.jsx(ua,{open:s,onOpenChange:l,children:d.jsxs(da,{onClick:i(w=>w.stopPropagation(),"onClick"),onPointerDown:i(w=>w.stopPropagation(),"onPointerDown"),children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Send Password Reset"}),d.jsxs(ii,{children:["Send a password reset email to ",d.jsx("strong",{children:e.email}),"?",d.jsx("br",{}),d.jsx("br",{}),"This will send them a link to reset their password."]})]}),d.jsxs(lo,{children:[d.jsx(Le,{variant:"outline",onClick:i(w=>{w.stopPropagation(),l(!1)},"onClick"),disabled:m,children:"Cancel"}),d.jsx(Le,{onClick:i(w=>{w.stopPropagation(),p()},"onClick"),disabled:m,children:m?"Sending...":"Send Reset Link"})]})]})})]})},"RowActions");function $ze(){return d.jsx(x4,{filters:Ize,actions:d.jsx(Mze,{}),sort:{field:"first_name",order:"ASC"},children:d.jsx(qze,{})})}i($ze,"SalesList");const qze=i(()=>{const{data:e,isPending:t,filterValues:n}=Gn(),{identity:r}=Jn(),a=n&&Object.keys(n).length>0;return!r||t?d.jsx(pn,{className:"p-4",children:d.jsxs("div",{className:"space-y-3",children:[d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"})]})}):!e?.length&&!a?d.jsx(zze,{}):d.jsxs(Ls,{children:[d.jsx(Ls.Col,{source:"first_name"}),d.jsx(Ls.Col,{source:"last_name"}),d.jsx(Ls.Col,{source:"email"}),d.jsx(Ls.Col,{label:!1,children:d.jsx(Fze,{})}),d.jsx(Ls.Col,{label:!1,children:d.jsx(Lze,{})})]})},"SalesListLayout"),zze=i(()=>{const e=q1();return d.jsxs("div",{className:"flex flex-col justify-center items-center gap-3",style:{height:`calc(100dvh - ${e}px)`},children:[d.jsx("img",{src:"./img/empty.svg",alt:"No users found"}),d.jsxs("div",{className:"flex flex-col gap-0 items-center",children:[d.jsx("h6",{className:"text-lg font-bold",children:"No users found"}),d.jsx("p",{className:"text-sm text-muted-foreground text-center mb-4",children:"It seems your user list is empty."})]}),d.jsx("div",{className:"flex flex-row gap-2",children:d.jsx(Dc,{label:"New user"})})]})},"SalesEmpty"),Uze={list:$ze,create:Tze,edit:Pze,recordRepresentation:i(e=>`${e.first_name} ${e.last_name}`,"recordRepresentation")};function cie({open:e,onComplete:t,canClose:n=!1}){const[r,a]=y.useState("welcome"),[o,s]=y.useState(""),[l,f]=y.useState(""),[c,p]=y.useState(null),m=i(async()=>{p(null),a("validating");const b=await JRe(o,l);b.valid?(QRe({url:o,anonKey:l}),a("success"),setTimeout(()=>{window.location.href=window.location.origin},1500)):(p(b.error||"Connection failed"),a("credentials"))},"handleValidateAndSave"),v=i(()=>{n&&t()},"handleClose");return d.jsx(ua,{open:e,onOpenChange:n?v:void 0,children:d.jsxs(da,{className:"sm:max-w-md",onPointerDownOutside:i(b=>!n&&b.preventDefault(),"onPointerDownOutside"),onEscapeKeyDown:i(b=>!n&&b.preventDefault(),"onEscapeKeyDown"),children:[r==="welcome"&&d.jsxs(d.Fragment,{children:[d.jsxs(Nr,{children:[d.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[d.jsx(ev,{className:"h-6 w-6 text-primary"}),d.jsx(Pr,{children:"Welcome to CRM"})]}),d.jsx(ii,{children:"To get started, you'll need to connect to a Supabase database."})]}),d.jsxs("div",{className:"space-y-4 py-4",children:[d.jsx(Ua,{children:d.jsxs(oi,{children:[d.jsx("strong",{children:"Don't have a Supabase project?"}),d.jsx("br",{}),"Create one for free at"," ",d.jsx("a",{href:"https://supabase.com",target:"_blank",rel:"noopener noreferrer",className:"underline text-primary",children:"supabase.com"})]})}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"font-medium text-sm",children:"What you'll need:"}),d.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:[d.jsx("li",{children:"Your Supabase project URL"}),d.jsx("li",{children:"Your anonymous (anon) API key"})]})]}),d.jsx(Le,{onClick:i(()=>a("credentials"),"onClick"),className:"w-full",children:"Continue"})]})]}),r==="credentials"&&d.jsxs(d.Fragment,{children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Connect to Supabase"}),d.jsx(ii,{children:"Enter your Supabase project credentials"})]}),d.jsxs("div",{className:"space-y-4 py-4",children:[c&&d.jsxs(Ua,{variant:"destructive",children:[d.jsx(Np,{className:"h-4 w-4"}),d.jsx(oi,{children:c})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"supabase-url",children:"Supabase URL"}),d.jsx(Sr,{id:"supabase-url",placeholder:"https://xxxxx.supabase.co",value:o,onChange:i(b=>s(b.target.value),"onChange")}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Found in Project Settings → API"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"anon-key",children:"Anonymous Key"}),d.jsx(Sr,{id:"anon-key",type:"password",placeholder:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",value:l,onChange:i(b=>f(b.target.value),"onChange")}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Found in Project Settings → API → Project API keys"})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Le,{variant:"outline",onClick:i(()=>a("welcome"),"onClick"),className:"flex-1",children:"Back"}),d.jsx(Le,{onClick:m,disabled:!o||!l,className:"flex-1",children:"Connect"})]})]})]}),r==="validating"&&d.jsxs(d.Fragment,{children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Validating Connection"}),d.jsx(ii,{children:"Testing your Supabase credentials..."})]}),d.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[d.jsx(Rc,{className:"h-12 w-12 animate-spin text-primary mb-4"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Please wait..."})]})]}),r==="success"&&d.jsxs(d.Fragment,{children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:"Connection Successful!"}),d.jsx(ii,{children:"Your Supabase database is now connected"})]}),d.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[d.jsx($o,{className:"h-12 w-12 text-green-500 mb-4"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Reloading application..."})]})]})]})})}i(cie,"SupabaseSetupWizard");function Bze(){const[e,t]=y.useState(!1),n=wd(),r=eAe(),a=i(()=>{confirm("Are you sure you want to clear the database configuration? The app will need to be reconfigured on next launch.")&&(XRe(),window.location.reload())},"handleClearConfig");return d.jsxs(d.Fragment,{children:[d.jsxs(pn,{children:[d.jsxs(Xo,{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ev,{className:"h-5 w-5"}),d.jsx(Zo,{children:"Database Connection"})]}),d.jsx(_4,{children:"Manage your Supabase database connection settings"})]}),d.jsx(Wn,{className:"space-y-4",children:n?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start gap-3 p-4 border rounded-lg",children:[d.jsx($o,{className:"h-5 w-5 text-green-500 mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx("p",{className:"font-medium",children:"Connected"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:n.url}),n.configuredAt&&d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Configured on"," ",new Date(n.configuredAt).toLocaleDateString()]})]})]}),r==="env"&&d.jsxs(Ua,{children:[d.jsx(fN,{className:"h-4 w-4"}),d.jsx(oi,{children:"Using configuration from environment variables. You can override this by setting up a new connection via the UI."})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs(Le,{variant:"outline",onClick:i(()=>t(!0),"onClick"),className:"flex-1",children:[d.jsx(fN,{className:"h-4 w-4 mr-2"}),"Change Connection"]}),r==="ui"&&d.jsxs(Le,{variant:"destructive",onClick:a,className:"flex-1",children:[d.jsx(fy,{className:"h-4 w-4 mr-2"}),"Clear Configuration"]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Vze,{className:"text-sm font-medium",children:"Anonymous Key"}),d.jsxs("div",{className:"font-mono text-sm p-2 bg-muted rounded",children:[n.anonKey.substring(0,20),"...",n.anonKey.substring(n.anonKey.length-10)]})]})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start gap-3 p-4 border border-dashed rounded-lg",children:[d.jsx(as,{className:"h-5 w-5 text-destructive mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx("p",{className:"font-medium",children:"Not Connected"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"No Supabase database is configured"})]})]}),d.jsx(Ua,{children:d.jsxs(oi,{children:["Connect to a Supabase database to start using Atomic CRM. You can create a free project at"," ",d.jsx("a",{href:"https://supabase.com",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"supabase.com"})]})}),d.jsxs(Le,{onClick:i(()=>t(!0),"onClick"),className:"w-full",children:[d.jsx(ev,{className:"h-4 w-4 mr-2"}),"Connect to Supabase"]})]})})]}),d.jsx(cie,{open:e,onComplete:i(()=>t(!1),"onComplete"),canClose:!0})]})}i(Bze,"DatabaseSettings");function Vze({children:e,className:t}){return d.jsx("label",{className:t,children:e})}i(Vze,"Label");const oD=i(()=>d.jsx("div",{className:"max-w-lg mx-auto mt-8",children:d.jsx(Bze,{})}),"DatabasePage");oD.path="/database";const sD=i(()=>{const[e,t]=y.useState(!1),{identity:n,refetch:r}=Jn(),{data:a,refetch:o}=Iw("sales",{id:n?.id}),s=Bt(),l=xn(),{mutate:f}=Mr({mutationKey:["signup"],mutationFn:i(async p=>{if(!n)throw new Error("Record not found");return l.salesUpdate(n.id,p)},"mutationFn"),onSuccess:i(()=>{r(),o(),t(!1),s("Your profile has been updated")},"onSuccess"),onError:i(p=>{s("An error occurred. Please try again",{type:"error"})},"onError")});if(!n)return null;const c=i(async p=>{f(p)},"handleOnSubmit");return d.jsx("div",{className:"max-w-lg mx-auto mt-8",children:d.jsx(Xr,{onSubmit:c,record:a,children:d.jsx(Hze,{isEditMode:e,setEditMode:t})})})},"SettingsPage"),Hze=i(({isEditMode:e,setEditMode:t})=>{const n=Bt(),r=ja(),a=Vt(),{identity:o,refetch:s}=Jn(),{isDirty:l}=sy(),f=xn(),{mutate:c}=Mr({mutationKey:["signup"],mutationFn:i(async v=>{if(!a)throw new Error("Record not found");return f.salesUpdate(a.id,v)},"mutationFn"),onSuccess:i(()=>{s(),n("Your profile has been updated")},"onSuccess"),onError:i(()=>{n("An error occurred. Please try again.")},"onError")});if(!o)return null;const p=i(()=>{r("/change-password")},"handleClickOpenPasswordChange"),m=i(async v=>{c(v)},"handleAvatarUpdate");return d.jsxs("div",{className:"space-y-4",children:[d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx("div",{className:"mb-4 flex flex-row justify-between",children:d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"My info"})}),d.jsxs("div",{className:"space-y-4 mb-4",children:[d.jsx(dte,{source:"avatar",type:"avatar",onSave:m,linkPosition:"right"}),d.jsx(gT,{source:"first_name",isEditMode:e}),d.jsx(gT,{source:"last_name",isEditMode:e}),d.jsx(gT,{source:"email",isEditMode:e})]}),d.jsxs("div",{className:"flex flex-row justify-end gap-2",children:[!e&&d.jsx(d.Fragment,{children:d.jsx(Le,{variant:"outline",type:"button",onClick:p,children:"Change password"})}),d.jsxs(Le,{type:"button",variant:e?"ghost":"outline",onClick:i(()=>t(!e),"onClick"),className:"flex items-center",children:[e?d.jsx(as,{}):d.jsx(TQ,{}),e?"Cancel":"Edit"]}),e&&d.jsxs(Le,{type:"submit",disabled:!l,variant:"outline",children:[d.jsx(l1,{}),"Save"]})]})]})}),void 0]})},"SettingsForm"),gT=i(({source:e,isEditMode:t})=>t?d.jsx(ln,{source:e,helperText:!1}):d.jsx("div",{className:"m-2",children:d.jsx(y5e,{source:e})}),"TextRender");sD.path="/settings";function uie(){const e=new Uint8Array(16);return crypto.getRandomValues(e),`ak_live_${Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join("")}`}i(uie,"generateApiKey");async function Wze(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}i(Wze,"hashApiKey");const Gze=[{value:"contacts:read",label:"Contacts: Read"},{value:"contacts:write",label:"Contacts: Write"},{value:"companies:read",label:"Companies: Read"},{value:"companies:write",label:"Companies: Write"},{value:"deals:read",label:"Deals: Read"},{value:"deals:write",label:"Deals: Write"},{value:"activities:write",label:"Activities: Write"}],Kze=i(({open:e,onClose:t})=>{const[n,r]=y.useState(null),[a,o]=y.useState(!1),s=xn(),l=Bt(),f=Nn(),{identity:c}=Jn(),{register:p,handleSubmit:m,watch:v,setValue:b,reset:w}=ly({defaultValues:{name:"",scopes:[],expires_at:""}}),S=Mr({mutationFn:i(async O=>{const C=uie(),T=await Wze(C),R=C.substring(0,12),{data:A}=await s.create("api_keys",{data:{name:O.name,key_hash:T,key_prefix:R,scopes:O.scopes,is_active:!0,expires_at:O.expires_at||null,sales_id:c?.id,created_by_sales_id:c?.id}});return{data:A,apiKey:C}},"mutationFn"),onSuccess:i(({apiKey:O})=>{r(O),f.invalidateQueries({queryKey:["api_keys"]}),l("API key created successfully")},"onSuccess"),onError:i(()=>{l("Failed to create API key",{type:"error"})},"onError")}),_=i(()=>{r(null),o(!1),w(),t()},"handleClose"),j=i(()=>{n&&(navigator.clipboard.writeText(n),o(!0),setTimeout(()=>o(!1),2e3))},"copyApiKey"),E=i(O=>{const C=v("scopes");C.includes(O)?b("scopes",C.filter(T=>T!==O)):b("scopes",[...C,O])},"toggleScope");return d.jsx(ua,{open:e,onOpenChange:_,children:d.jsxs(da,{className:"sm:max-w-[500px]",children:[d.jsxs(Nr,{children:[d.jsx(Pr,{children:n?"API Key Created":"Create API Key"}),d.jsx(ii,{children:n?"Copy this key now - it won't be shown again!":"Create a new API key to access the CRM API"})]}),n?d.jsxs("div",{className:"space-y-4",children:[d.jsx(Ua,{children:d.jsx(oi,{children:"Make sure to copy your API key now. You won't be able to see it again!"})}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Your API Key"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(Sr,{value:n,readOnly:!0,className:"font-mono text-sm"}),d.jsx(Le,{type:"button",variant:"outline",size:"icon",onClick:j,children:a?d.jsx($o,{className:"h-4 w-4 text-green-500"}):d.jsx(TM,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex justify-end",children:d.jsx(Le,{onClick:_,children:"Done"})})]}):d.jsx("form",{onSubmit:m(O=>S.mutate(O)),children:d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"name",children:"Name"}),d.jsx(Sr,{id:"name",placeholder:"e.g., Production API Key",...p("name",{required:!0})})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Scopes"}),d.jsx("div",{className:"space-y-2",children:Gze.map(O=>d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Hp,{id:O.value,checked:v("scopes").includes(O.value),onCheckedChange:i(()=>E(O.value),"onCheckedChange")}),d.jsx("label",{htmlFor:O.value,className:"text-sm cursor-pointer",children:O.label})]},O.value))})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"expires_at",children:"Expiration (optional)"}),d.jsx(Sr,{id:"expires_at",type:"date",...p("expires_at")})]}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(Le,{type:"button",variant:"outline",onClick:_,children:"Cancel"}),d.jsx(Le,{type:"submit",disabled:S.isPending,children:"Create"})]})]})})]})})},"CreateApiKeyDialog");var Yze=Symbol("radix.slottable");function Qze(e){const t=i(({children:n})=>d.jsx(d.Fragment,{children:n}),"Slottable2");return t.displayName=`${e}.Slottable`,t.__radixId=Yze,t}i(Qze,"createSlottable");var die="AlertDialog",[Xze,JUe]=ha(die,[XQ]),ll=XQ(),fie=i(e=>{const{__scopeAlertDialog:t,...n}=e,r=ll(t);return d.jsx(my,{...r,...n,modal:!0})},"AlertDialog$1");fie.displayName=die;var Zze="AlertDialogTrigger",Jze=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(hX,{...a,...r,ref:t})});Jze.displayName=Zze;var eUe="AlertDialogPortal",hie=i(e=>{const{__scopeAlertDialog:t,...n}=e,r=ll(t);return d.jsx(gy,{...r,...n})},"AlertDialogPortal$1");hie.displayName=eUe;var tUe="AlertDialogOverlay",pie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(vy,{...a,...r,ref:t})});pie.displayName=tUe;var fh="AlertDialogContent",[nUe,rUe]=Xze(fh),aUe=Qze("AlertDialogContent"),mie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...a}=e,o=ll(n),s=y.useRef(null),l=Zt(t,s),f=y.useRef(null);return d.jsx(QSe,{contentName:fh,titleName:gie,docsSlug:"alert-dialog",children:d.jsx(nUe,{scope:n,cancelRef:f,children:d.jsxs(yy,{role:"alertdialog",...o,...a,ref:l,onOpenAutoFocus:tt(a.onOpenAutoFocus,c=>{c.preventDefault(),f.current?.focus({preventScroll:!0})}),onPointerDownOutside:i(c=>c.preventDefault(),"onPointerDownOutside"),onInteractOutside:i(c=>c.preventDefault(),"onInteractOutside"),children:[d.jsx(aUe,{children:r}),d.jsx(oUe,{contentRef:s})]})})})});mie.displayName=fh;var gie="AlertDialogTitle",vie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(h1,{...a,...r,ref:t})});vie.displayName=gie;var yie="AlertDialogDescription",bie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(p1,{...a,...r,ref:t})});bie.displayName=yie;var iUe="AlertDialogAction",xie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=ll(n);return d.jsx(by,{...a,...r,ref:t})});xie.displayName=iUe;var wie="AlertDialogCancel",_ie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:a}=rUe(wie,n),o=ll(n),s=Zt(t,a);return d.jsx(by,{...o,...r,ref:s})});_ie.displayName=wie;var oUe=i(({contentRef:e})=>{const t=`\`${fh}\` requires a description for the component to be accessible for screen reader users.
|
|
155
155
|
|
|
156
156
|
You can add a description to the \`${fh}\` by passing a \`${yie}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
157
157
|
|
|
@@ -163,4 +163,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
163
163
|
${v?"border-green-500 bg-green-50 scale-[1.02] shadow-lg":"border-gray-300 hover:border-primary/50 hover:bg-gray-50"}
|
|
164
164
|
`,children:[d.jsx("input",{...m()}),d.jsx(MQ,{className:"w-12 h-12 mx-auto mb-4 text-gray-400"}),v?d.jsx("p",{className:"text-lg font-medium",children:"Drop files here..."}):d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"text-lg font-medium mb-2",children:"Drag & drop files here, or click to select"}),d.jsx("p",{className:"text-sm text-gray-500",children:"Supports all file types (executables blocked for security)"})]})]}),e.length>0&&d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("h3",{className:"font-medium",children:["Files (",e.length,")"]}),d.jsxs("div",{className:"space-x-2",children:[d.jsx(Le,{size:"sm",onClick:w,disabled:!e.some(j=>j.status==="pending"),children:"Upload All"}),d.jsx(Le,{size:"sm",variant:"outline",onClick:S,disabled:!e.some(j=>j.status==="success"),children:"Clear Completed"})]})]}),d.jsx("div",{className:"space-y-2",children:e.map((j,E)=>d.jsxs("div",{className:"border rounded-lg p-4 space-y-2",children:[d.jsxs("div",{className:"flex items-start justify-between gap-4",children:[d.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[d.jsx(qwe,{className:"w-5 h-5 mt-0.5 flex-shrink-0 text-gray-400"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"font-medium truncate",children:j.file.name}),d.jsxs("p",{className:"text-sm text-gray-500",children:[_(j.file.size),j.activityId&&d.jsxs("span",{className:"ml-2 text-xs",children:["ID: ",j.activityId.substring(0,8),"..."]})]})]})]}),d.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[j.status==="pending"&&d.jsx(Le,{size:"sm",onClick:i(()=>b(E),"onClick"),children:"Upload"}),j.status==="uploading"&&d.jsx(Rc,{className:"w-5 h-5 animate-spin text-primary"}),j.status==="success"&&d.jsx($o,{className:"w-5 h-5 text-green-500"}),j.status==="error"&&d.jsx(as,{className:"w-5 h-5 text-red-500"})]})]}),j.status==="uploading"&&d.jsx(Lne,{value:j.progress,className:"h-1"}),j.status==="error"&&j.error&&d.jsxs("p",{className:"text-sm text-red-500",children:["Error: ",j.error]})]},E))})]})]})]}),d.jsxs(pn,{children:[d.jsx(Xo,{children:d.jsx(Zo,{className:"text-base",children:"How it works"})}),d.jsxs(Wn,{className:"text-sm text-gray-600 space-y-2",children:[d.jsx("p",{children:"• Files are uploaded directly to secure storage (no database bloat)"}),d.jsx("p",{children:"• Each file creates an activity record for tracking and search"}),d.jsx("p",{children:"• Large files are handled automatically (no size limits)"}),d.jsx("p",{children:"• Files are linked to your selected ingestion channel"}),d.jsx("p",{children:"• Activities appear in the Activity Feed immediately"})]})]})]})},"FileUpload"),lD=i(()=>d.jsxs("div",{className:"max-w-6xl mx-auto mt-8 px-4",children:[d.jsxs("div",{className:"mb-6",children:[d.jsx("h1",{className:"text-3xl font-bold",children:"Integrations"}),d.jsx("p",{className:"text-muted-foreground mt-2",children:"Manage API keys, webhooks, and ingestion channels to integrate Atomic CRM with external systems."})]}),d.jsxs(Ete,{defaultValue:"ingestion",children:[d.jsxs(Cte,{className:"mb-4",children:[d.jsx(ac,{value:"ingestion",children:"Ingestion Channels"}),d.jsx(ac,{value:"file-upload",children:"File Upload"}),d.jsx(ac,{value:"api-keys",children:"API Keys"}),d.jsx(ac,{value:"webhooks",children:"Webhooks (Outbound)"})]}),d.jsx(ic,{value:"ingestion",children:d.jsx(jUe,{})}),d.jsx(ic,{value:"file-upload",children:d.jsx(CUe,{})}),d.jsx(ic,{value:"api-keys",children:d.jsx(vUe,{})}),d.jsx(ic,{value:"webhooks",children:d.jsx(xUe,{})})]})]}),"IntegrationsPage");lD.path="/integrations";var OUe={"ra-supabase":{auth:{email:"Email",confirm_password:"Confirm password",sign_in_with:"Sign in with %{provider}",forgot_password:"Forgot password?",reset_password:"Reset password",password_reset:"Your password has been reset. You will receive an email containing a link to log in.",missing_tokens:"Access and refresh tokens are missing",back_to_login:"Back to login"},reset_password:{forgot_password:"Forgot password?",forgot_password_details:"Enter your email for instructions."},set_password:{new_password:"Choose your password"},validation:{password_mismatch:"Passwords do not match"}}};const kUe={"ra-supabase":{auth:{password_reset:"Check your emails for a Reset Password message."}}},RUe=uQ(()=>lfe(XY,OUe,kUe),"en",[{locale:"en",name:"English"}],{allowMissing:!0}),AUe=i(()=>{const e=xn(),{data:t,error:n,isPending:r}=Qr({queryKey:["init"],queryFn:i(async()=>e.isInitialized(),"queryFn")});return r?d.jsx(oie,{}):n?d.jsx(jx,{}):t?d.jsx(jx,{}):d.jsx(bw,{to:"/sign-up"})},"StartPage");async function TUe(e){const t=["contacts","companies","deals","contactNotes","dealNotes","tasks","sales","tags"],n=[];try{for(const r of t)try{await e.getList(r,{pagination:{page:1,perPage:1},sort:{field:"id",order:"ASC"},filter:{}})}catch(a){(a?.message?.includes("Could not find the table")||a?.message?.includes("relation")||a?.message?.includes("does not exist"))&&n.push(r)}return{isHealthy:n.length===0,missingTables:n}}catch(r){return{isHealthy:!1,missingTables:t,error:r?.message||"Unknown error"}}}i(TUe,"checkDatabaseHealth");function NUe({missingTables:e,supabaseUrl:t}){const n=t.match(/https:\/\/([^.]+)\.supabase\.co/)?.[1];return d.jsxs("div",{className:"max-w-2xl mx-auto mt-8 space-y-4",children:[d.jsxs(Ua,{variant:"destructive",children:[d.jsx(Np,{className:"h-4 w-4"}),d.jsx(M4,{children:"Database Schema Not Configured"}),d.jsx(oi,{children:"Your Supabase database is connected, but the CRM schema hasn't been set up yet."})]}),d.jsxs(pn,{children:[d.jsxs(Xo,{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ev,{className:"h-5 w-5"}),d.jsx(Zo,{children:"Setup Instructions"})]}),d.jsx(_4,{children:"Follow these steps to set up your database schema"})]}),d.jsxs(Wn,{className:"space-y-6",children:[d.jsxs("div",{children:[d.jsx("h3",{className:"font-semibold mb-2",children:"Missing Tables:"}),d.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(r=>d.jsx("span",{className:"px-2 py-1 bg-destructive/10 text-destructive text-sm rounded",children:r},r))})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-primary text-primary-foreground text-sm font-bold",children:"1"}),d.jsx("h3",{className:"font-semibold",children:"Using Supabase CLI (Recommended)"})]}),d.jsxs("div",{className:"ml-8 space-y-3",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Install Supabase CLI:"}),d.jsx("pre",{className:"bg-muted p-3 rounded text-sm overflow-x-auto",children:"npm install -g supabase"})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Clone the RealTimeX CRM repository to get migrations:"}),d.jsxs("pre",{className:"bg-muted p-3 rounded text-sm overflow-x-auto",children:["git clone https://github.com/therealtimex/realtimex-crm.git",`
|
|
165
165
|
`,"cd realtimex-crm"]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Link to your Supabase project:"}),d.jsxs("pre",{className:"bg-muted p-3 rounded text-sm overflow-x-auto",children:["supabase link --project-ref ",n||"YOUR_PROJECT_REF"]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Push the migrations:"}),d.jsx("pre",{className:"bg-muted p-3 rounded text-sm overflow-x-auto",children:"supabase db push"})]}),d.jsx("div",{children:d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Reload this page after migrations are complete."})})]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-primary text-primary-foreground text-sm font-bold",children:"2"}),d.jsx("h3",{className:"font-semibold",children:"Using Supabase SQL Editor"})]}),d.jsxs("div",{className:"ml-8 space-y-3",children:[d.jsx("p",{className:"text-sm text-muted-foreground",children:"Manually run the SQL migrations in your Supabase SQL Editor:"}),d.jsxs("ol",{className:"list-decimal list-inside space-y-2 text-sm text-muted-foreground",children:[d.jsxs("li",{children:["Download migrations from"," ",d.jsxs("a",{href:"https://github.com/therealtimex/realtimex-crm/tree/main/supabase/migrations",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["GitHub",d.jsx(ff,{className:"h-3 w-3"})]})]}),d.jsxs("li",{children:["Open your"," ",d.jsxs("a",{href:`https://supabase.com/dashboard/project/${n}/sql/new`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["Supabase SQL Editor",d.jsx(ff,{className:"h-3 w-3"})]})]}),d.jsx("li",{children:"Run each migration file in order (by date in filename)"}),d.jsx("li",{children:"Reload this page after all migrations are complete"})]}),n&&d.jsx(Le,{asChild:!0,variant:"outline",className:"w-full",children:d.jsxs("a",{href:`https://supabase.com/dashboard/project/${n}/sql/new`,target:"_blank",rel:"noopener noreferrer",children:[d.jsx(ff,{className:"h-4 w-4 mr-2"}),"Open SQL Editor"]})})]})]}),d.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[d.jsx("h3",{className:"font-semibold",children:"After Setup"}),d.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx($o,{className:"h-4 w-4 mt-0.5 text-green-500"}),d.jsx("span",{children:"All tables will be created with proper schemas and relationships"})]}),d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx($o,{className:"h-4 w-4 mt-0.5 text-green-500"}),d.jsx("span",{children:"Row Level Security (RLS) policies will be configured"})]}),d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx($o,{className:"h-4 w-4 mt-0.5 text-green-500"}),d.jsx("span",{children:"Database triggers and functions will be set up"})]})]}),d.jsx(Le,{onClick:i(()=>window.location.reload(),"onClick"),className:"w-full mt-4",children:"Reload Page"})]})]})]}),d.jsxs(pn,{children:[d.jsx(Xo,{children:d.jsx(Zo,{className:"text-base",children:"Need Help?"})}),d.jsxs(Wn,{className:"space-y-2 text-sm",children:[d.jsxs("a",{href:"https://github.com/therealtimex/realtimex-crm#installation",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[d.jsx(ff,{className:"h-4 w-4"}),"View Full Setup Guide"]}),d.jsxs("a",{href:"https://github.com/therealtimex/realtimex-crm/issues",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[d.jsx(ff,{className:"h-4 w-4"}),"Report an Issue"]}),d.jsxs("a",{href:"https://supabase.com/docs/guides/cli",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[d.jsx(ff,{className:"h-4 w-4"}),"Supabase CLI Documentation"]})]})]})]})}i(NUe,"DatabaseSetupGuide");function PUe({children:e,dataProvider:t}){const[n,r]=y.useState(null),[a,o]=y.useState(!0);if(y.useEffect(()=>{let s=!1;async function l(){try{const f=await TUe(t);s||(r(f),o(!1))}catch(f){console.error("[DatabaseHealthCheck] Failed to check database health:",f),s||o(!1)}}return i(l,"checkHealth"),l(),()=>{s=!0}},[t]),a)return d.jsx("div",{className:"flex items-center justify-center min-h-screen",children:d.jsxs("div",{className:"text-center space-y-4",children:[d.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"}),d.jsx("p",{className:"text-muted-foreground",children:"Checking database connection..."})]})});if(n&&!n.isHealthy){const s=wd();if(s)return d.jsx(NUe,{missingTables:n.missingTables,supabaseUrl:s.url})}return d.jsx(d.Fragment,{children:e})}i(PUe,"DatabaseHealthCheck");const DUe=i(({contactGender:e=nJ,companySectors:t=QZ,dealCategories:n=JZ,dealPipelineStatuses:r=ZZ,dealStages:a=XZ,darkModeLogo:o=GZ,lightModeLogo:s=KZ,noteStatuses:l=eJ,taskTypes:f=tJ,title:c=YZ,dataProvider:p=Aze,authProvider:m=gze,disableTelemetry:v,...b})=>(y.useEffect(()=>{if(v||typeof window>"u"||typeof window.location>"u"||typeof Image>"u")return;const w=new Image;w.src=`https://atomic-crm-telemetry.marmelab.com/atomic-crm-telemetry?domain=${window.location.hostname}`},[v]),d.jsx(rke,{contactGender:e,companySectors:t,dealCategories:n,dealPipelineStatuses:r,dealStages:a,darkModeLogo:o,lightModeLogo:s,noteStatuses:l,taskTypes:f,title:c,children:d.jsx(PUe,{dataProvider:p,children:d.jsxs(lke,{dataProvider:p,authProvider:m,store:yG(void 0,"CRM"),layout:pze,loginPage:AUe,i18nProvider:RUe,dashboard:aze,requireAuth:!0,disableTelemetry:!0,...b,children:[d.jsxs(tN,{noLayout:!0,children:[d.jsx(Qn,{path:iD.path,element:d.jsx(iD,{})}),d.jsx(Qn,{path:ZN.path,element:d.jsx(ZN,{})}),d.jsx(Qn,{path:YN.path,element:d.jsx(YN,{})}),d.jsx(Qn,{path:JN.path,element:d.jsx(JN,{})}),d.jsx(Qn,{path:eP.path,element:d.jsx(eP,{})})]}),d.jsxs(tN,{children:[d.jsx(Qn,{path:sD.path,element:d.jsx(sD,{})}),d.jsx(Qn,{path:oD.path,element:d.jsx(oD,{})}),d.jsx(Qn,{path:lD.path,element:d.jsx(lD,{})})]}),d.jsx(Ui,{name:"deals",...oze}),d.jsx(Ui,{name:"contacts",...t6e}),d.jsx(Ui,{name:"companies",...l3e}),d.jsx(Ui,{name:"companyNotes"}),d.jsx(Ui,{name:"contactNotes"}),d.jsx(Ui,{name:"dealNotes"}),d.jsx(Ui,{name:"tasks"}),d.jsx(Ui,{name:"sales",...Uze}),d.jsx(Ui,{name:"tags"})]})})})),"CRM"),MUe=i(()=>{const[e,t]=y.useState(()=>!ZRe());return e?d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:d.jsx(cie,{open:!0,onComplete:i(()=>{t(!1)},"onComplete"),canClose:!1})}):d.jsx(DUe,{})},"App");Fse.createRoot(document.getElementById("root")).render(d.jsx(y.StrictMode,{children:d.jsx(MUe,{})}));export{Jn as $,al as A,Dr as B,kK as C,bY as D,g4 as E,Ko as F,p4 as G,fn as H,Yo as I,kJ as J,Se as K,DK as L,rge as M,Sr as N,hw as O,ie as P,vG as Q,fd as R,nl as S,cr as T,po as U,pn as V,Wn as W,Pp as X,sr as Y,_d as Z,Up as _,cy as a,Le as a0,ua as a1,da as a2,Pr as a3,pd as a4,md as a5,ln as a6,Zn as a7,Bp as a8,A3e as a9,zye as aA,O4e as aB,ih as aC,qte as aD,F4 as aE,Mw as aF,Mr as aG,dd as aH,Jte as aI,Hn as aJ,j4 as aK,Ny as aL,x4 as aM,sn as aN,S4 as aO,mNe as aP,M1 as aQ,RP as aa,Ha as ab,Js as ac,One as ad,xn as ae,Gn as af,Nn as ag,Xr as ah,B1 as ai,bd as aj,Bt as ak,iM as al,Gte as am,Vt as an,L4 as ao,Fr as ap,rp as aq,q1 as ar,Lne as as,Dc as at,N4e as au,Ji as av,os as aw,fY as ax,zte as ay,fc as az,dM as b,hK as c,Yme as d,wa as e,Ge as f,bM as g,kc as h,xt as i,Oc as j,t1 as k,Et as l,d as m,Zs as n,ca as o,Oy as p,bPe as q,y as r,wPe as s,SPe as t,fa as u,jPe as v,ol as w,qw as x,Wt as y,hd as z};
|
|
166
|
-
//# sourceMappingURL=index-
|
|
166
|
+
//# sourceMappingURL=index-fNN1dYom.js.map
|