PageSourceSearch

https://adpilot-489907.web.app/assets/index-D2MP03J3.js

js adpilot-489907.web.app collected 2026-10-03 12:15:46 UTC 60,241 bytes, 1 lines download raw bytes

1import{r as i,a as E,j as e}from"./index-tNhE6V5Q.js";import{C as vt}from"./ConversationPanel-YII99_0H.js";import{j as I,a1 as se,a2 as yt,a3 as ft,a4 as H,a5 as jt,a6 as _t,a7 as He,a8 as Nt,a9 as wt,F as G,aa as Pt,ab as At,ac as Ot,ad as Rt,k as Ze,ae as St,af as Ct,ag as kt,ah as Et,ai as Je,aj as It,ak as Dt,al as Tt,x as Xe,am as $t,t as ve,s as Ye,R as Lt,an as Ft,D as Qe,ao as et,u as ae,ap as Bt,c as ye,L as X,Z as tt,aq as fe,y as Mt,I as Kt,J as Wt,ar as Gt,K as De,i as Te,as as oe,at as Vt,e as zt,au as Ut,av as qt,aw as Ht,ax as Zt,ay as Jt,az as Xt,aA as Yt,aB as Qt,P as ea,M as ta,aC as aa,aD as re,aE as he,h as $e,aF as ra,aG as sa,aH as na,aI as la,aJ as ia,aK as oa,aL as ca,aM as da,aN as ma,aO as xa,aP as ua,aQ as pa,T as ga,U as Le,W as Fe,$ as ha,V as ba,X as va,Y as ya,a0 as Be,_ as fa}from"./BarChart-BOjaE1wW.js";var at=t=>t.graphicalItems.polarItems,ja=I([se,yt],ft),ce=I([at,H,ja],jt),_a=I([ce],_t),de=I([_a,He],Nt),Na=I([de,H,ce],wt);I([de,H,ce],(t,r,s)=>s.length>0?t.flatMap(n=>s.flatMap(l=>{var o,c=G(n,(o=r.dataKey)!==null&&o!==void 0?o:l.dataKey);return{value:c,errorDomain:[]}})).filter(Boolean):r?.dataKey!=null?t.map(n=>({value:G(n,r.dataKey),errorDomain:[]})):t.map(n=>({value:n,errorDomain:[]})));var Me=()=>{},wa=I([de,H,ce,Pt,se],At),Pa=I([H,Ot,Rt,Me,wa,Me,Ze,se],St),rt=I([H,Ze,de,Na,Ct,se,Pa],kt),Aa=I([rt,Et,Je],It),Oa=I([H,rt,Aa,se],Dt);I([Je,Oa],Tt);function Ke(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,n)}return s}function We(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Ke(Object(s),!0).forEach(function(n){Ra(t,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Ke(Object(s)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(s,n))})}return t}function Ra(t,r,s){return(r=Sa(r))in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Sa(t){var r=Ca(t,"string");return typeof r=="symbol"?r:r+""}function Ca(t,r){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var n=s.call(t,r);
1if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var ka=(t,r)=>r,je=I([at,ka],(t,r)=>t.filter(s=>s.type==="pie").find(s=>s.id===r)),Ea=[],_e=(t,r,s)=>s?.length===0?Ea:s,st=I([He,je,_e],(t,r,s)=>{var{chartData:n}=t;if(r!=null){var l;if(r?.data!=null&&r.data.length>0?l=r.data:l=n,(!l||!l.length)&&s!=null&&(l=s.map(o=>We(We({},r.presentationProps),o.props))),l!=null)return l}}),Ia=I([st,je,_e],(t,r,s)=>{if(!(t==null||r==null))return t.map((n,l)=>{var o,c=G(n,r.nameKey,r.name),p;return s!=null&&(o=s[l])!==null&&o!==void 0&&(o=o.props)!==null&&o!==void 0&&o.fill?p=s[l].props.fill:typeof n=="object"&&n!=null&&"fill"in n?p=n.fill:p=r.fill,{value:Xe(c,r.dataKey),color:p,payload:n,type:r.legendType}})}),Da=I([st,je,_e,$t],(t,r,s,n)=>{if(!(r==null||t==null))return tr({offset:n,pieSettings:r,displayedData:t,cells:s})}),Ta=["key"],$a=["onMouseEnter","onClick","onMouseLeave"],La=["id"],Fa=["id"];function V(){return V=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var n in s)({}).hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t},V.apply(null,arguments)}function me(t,r){if(t==null)return{};var s,n,l=Ba(t,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)s=o[n],r.indexOf(s)===-1&&{}.propertyIsEnumerable.call(t,s)&&(l[s]=t[s])}return l}function Ba(t,r){if(t==null)return{};var s={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(r.indexOf(n)!==-1)continue;s[n]=t[n]}return s}function Ge(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,n)}return s}function b(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Ge(Object(s),!0).forEach(function(n){Ma(t,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Ge(Object(s)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(s,n))})}return t}function Ma(t,r,s){return(r=Ka(r))in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Ka(t){var r=Wa(t,"string");return typeof r=="symbol"?r:r+""}function Wa(t,r){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var n=s.call(t,r);
1if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function Ga(t){var r=i.useMemo(()=>et(t.children,fe),[t.children]),s=ae(n=>Ia(n,t.id,r));return s==null?null:i.createElement(Bt,{legendPayload:s})}function Va(t){if(!(t==null||typeof t=="boolean"||typeof t=="function")){if(i.isValidElement(t)){var r,s=(r=t.props)===null||r===void 0?void 0:r.fill;return typeof s=="string"?s:void 0}var{fill:n}=t;return typeof n=="string"?n:void 0}}var za=i.memo(t=>{var{dataKey:r,nameKey:s,sectors:n,stroke:l,strokeWidth:o,fill:c,name:p,hide:_,tooltipType:v,id:y,activeShape:S}=t,u=Va(S),w=n.map(P=>{var f=P.tooltipPayload;return u==null||f==null?f:f.map(g=>b(b({},g),{},{color:u,fill:u}))}),N={dataDefinedOnItem:w,getPosition:P=>{var f;return(f=n[Number(P)])===null||f===void 0?void 0:f.tooltipPosition},settings:{stroke:l,strokeWidth:o,fill:c,dataKey:r,nameKey:s,name:Xe(p,r),hide:_,type:v,color:c,unit:"",graphicalItemId:y}};return i.createElement(Mt,{tooltipEntrySettings:N})}),Ua=(t,r)=>t>r?"start":t<r?"end":"middle",qa=(t,r,s)=>typeof r=="function"?re(r(t),s,s*.8):re(r,s,s*.8),Ha=(t,r,s)=>{var{top:n,left:l,width:o,height:c}=r,p=aa(o,c),_=l+re(t.cx,o,o/2),v=n+re(t.cy,c,c/2),y=re(t.innerRadius,p,0),S=qa(s,t.outerRadius,p),u=t.maxRadius||Math.sqrt(o*o+c*c)/2;return{cx:_,cy:v,innerRadius:y,outerRadius:S,maxRadius:u}},Za=(t,r)=>{var s=oe(r-t),n=Math.min(Math.abs(r-t),360);return s*n},Ja=(t,r)=>{if(i.isValidElement(t))return i.cloneElement(t,r);if(typeof t=="function")return t(r);var s=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:n}=r,l=me(r,Ta);return i.createElement(ra,V({},l,{type:"linear",className:s}))},Xa=(t,r,s)=>{if(i.isValidElement(t))return i.cloneElement(t,r);var n=s;if(typeof t=="function"&&(n=t(r),i.isValidElement(n)))return n;var l=ye("recharts-pie-label-text",sa(t));return i.createElement(na,V({},r,{alignmentBaseline:"middle",className:l}),n)};function Ya(t){var{sectors:r,props:s,showLabels:n}=t,{label:l,labelLine:o,dataKey:c}=s;if(!n||!l||!r)return null;var p=Ye(s),_=$e(l),v=$e(o),y=typeof l=="object"&&"offsetRadius"in l&&typeof l.offsetRadius=="number"&&l.offsetRadius||20,S=r.map((u,w)=>{var N=(u.startAngle+u.endAngle)/2,P=he(u.cx,u.cy,u.outerRadius+y,N),f=b(b(b(b({},p),u),{},{stroke:"none"},_),{},{index:w,textAnchor:Ua(P.x,u.cx)},P),g=b(b(b(b({},p),u),{},{fill:"none",stroke:u.fill},v),{},{index:w,points:[he(u.cx,u.cy,u.outerRadius,N),P],key:"line"});return i.createElement(tt,{zIndex:Qe.label,key:"label-".concat(u.startAngle,"-").concat(u.endAngle,"-").concat(u.midAngle,"-").concat(w)},i.createElement(X,null,o&&Ja(o,g),Xa(l,f,G(u,c))))});return i.createElement(X,{className:"recharts-pie-labels"},S)}function Qa(t){var{sectors:r,props:s,showLabels:n}=t,{label:l}=s;return typeof l=="object"&&l!=null&&"position"in l?i.createElement(ta,{label:l}):i.createElement(Ya,{sectors:r,props:s,showLabels:n})}function er(t){var{sectors:r,activeShape:s,inactiveShape:n,allOtherPieProps:l,shape:o,id:c}=t,p=ae(zt),_=ae(Ut),v=ae(qt),{onMouseEnter:y,onClick:S,onMouseLeave:u}=l,w=me(l,$a),N=Ht(y,l.dataKey,c),P=Zt(u),f=Jt(S,l.dataKey,c);return r==null||r.length===0?null:i.createElement(i.Fragment,null,r.map((g,k)=>{if(g?.startAngle===0&&g?.endAngle===0&&r.length!==1)return null;var K=v==null||v===c,T=String(k)===p&&(_==null||l.dataKey===_)&&K,L=p?n:null,A=s&&T?s:L,C=b(b({},g),{},{stroke:g.stroke,tabIndex:-1,[Yt]:k,[Xt]:c});return i.createElement(X,V({key:"sector-".concat(g?.startAngle,"-").concat(g?.endAngle,"-").concat(g.midAngle,"-").concat(k),tabIndex:-1,className:"recharts-pie-sector"},Qt(w,g,k),{onMouseEnter:N(g,k),onMouseLeave:P(g,k),onClick:f(g,k)}),i.createElement(ea,V({option:o??A,index:k,shapeType:"sector",isActive:T},C)))}))}function tr(t){var r,{pieSettings:s,displayedData:n,cells:l,offset:o}=t,{cornerRadius:c,startAngle:p,endAngle:_,dataKey:v,nameKey:y,tooltipType:S}=s,u=Math.abs(s.minAngle),w=Za(p,_),N=Math.abs(w),P=n.length<=1?0:(r=s.paddingAngle)!==null&&r!==void 0?r:0,f=n.filter(A=>G(A,v,0)!==0).length,g=(N>=360?f:f-1)*P,k=N-f*u-g,K=n.reduce((A,C)=>{var d=G(C,v,0);return A+(Te(d)?d:0)},0),T;if(K>0){var L;T=n.map((A,C)=>{var d=G(A,v,0),W=G(A,y,C),$=Ha(s,o,A),M=(Te(d)?d:0)/K,O,F=b(b({},A),l&&l[C]&&l[C].props),D=F!=null&&"fill"in F&&typeof F.fill=="string"?F.fill:s.fill;C?O=L.endAngle+oe(w)*P*(d!==0?1:0):O=p;var Z=O+oe(w)*((d!==0?u:0)+M*k),B=(O+Z)/2,z=($.innerRadius+$.outerRadius)/2,xe=[{name:W,value:d,payload:F,dataKey:v,type:S,color:D,fill:D,graphicalItemId:s.id}],ne=he($.cx,$.cy,z,B);return L=b(b(b(b({},s.presentationProps),{},{percent:M,cornerRadius:typeof c=="string"?parseFloat(c):c,name:W,tooltipPayload:xe,midAngle:B,middleRadius:z,tooltipPosition:ne},F),$),{},{value:d,dataKey:v,startAngle:O,endAngle:Z,payload:F,paddingAngle:oe(w)*P}),L})}return T}function ar(t){var{showLabels:r,sectors:s,children:n}=t,l=i.useMemo(()=>!r||!s?[]:s.map(o=>({value:o.value,payload:o.payload,clockWise:!1,parentViewBox:void 0,viewB
1ox:{cx:o.cx,cy:o.cy,innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,clockWise:!1},fill:o.fill})),[s,r]);return i.createElement(Vt,{value:r?l:void 0},n)}function rr(t){var{props:r,previousSectorsRef:s,id:n}=t,{sectors:l,isAnimationActive:o,animationBegin:c,animationDuration:p,animationEasing:_,activeShape:v,inactiveShape:y,onAnimationStart:S,onAnimationEnd:u}=r,w=Kt(r,"recharts-pie-"),N=s.current,[P,f]=i.useState(!1),g=i.useCallback(()=>{typeof u=="function"&&u(),f(!1)},[u]),k=i.useCallback(()=>{typeof S=="function"&&S(),f(!0)},[S]);return i.createElement(ar,{showLabels:!P,sectors:l},i.createElement(Wt,{animationId:w,begin:c,duration:p,isActive:o,easing:_,onAnimationStart:k,onAnimationEnd:g,key:w},K=>{var T,L=[],A=l&&l[0],C=(T=A?.startAngle)!==null&&T!==void 0?T:0;return l?.forEach((d,W)=>{var $=N&&N[W],M=W>0?Gt(d,"paddingAngle",0):0;if($){var O=De($.endAngle-$.startAngle,d.endAngle-d.startAngle,K),F=b(b({},d),{},{startAngle:C+M,endAngle:C+O+M});L.push(F),C=F.endAngle}else{var{endAngle:D,startAngle:Z}=d,B=De(0,D-Z,K),z=b(b({},d),{},{startAngle:C+M,endAngle:C+B+M});L.push(z),C=z.endAngle}}),s.current=L,i.createElement(X,null,i.createElement(er,{sectors:L,activeShape:v,inactiveShape:y,allOtherPieProps:r,shape:r.shape,id:n}))}),i.createElement(Qa,{showLabels:!P,sectors:l,props:r}),r.children)}var sr={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:Qe.area};function nr(t){var{id:r}=t,s=me(t,La),{hide:n,className:l,rootTabIndex:o}=t,c=i.useMemo(()=>et(t.children,fe),[t.children]),p=ae(y=>Da(y,r,c)),_=i.useRef(null),v=ye("recharts-pie",l);return n||p==null?(_.current=null,i.createElement(X,{tabIndex:o,className:v})):i.createElement(tt,{zIndex:t.zIndex},i.createElement(za,{dataKey:t.dataKey,nameKey:t.nameKey,sectors:p,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,tooltipType:t.tooltipType,id:r,activeShape:t.activeShape}),i.createElement(X,{tabIndex:o,className:v},i.createElement(rr,{props:b(b({},s),{},{sectors:p}),previousSectorsRef:_,id:r})))}function lr(t){var r=ve(t,sr),{id:s}=r,n=me(r,Fa),l=Ye(n);return i.createElement(Lt,{id:s,type:"pie"},o=>i.createElement(i.Fragment,null,i.createElement(Ft,{type:"pie",id:o,data:n.data,dataKey:n.dataKey,hide:n.hide,angleAxisId:0,radiusAxisId:0,name:n.name,nameKey:n.nameKey,tooltipType:n.tooltipType,legendType:n.legendType,fill:n.fill,cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,paddingAngle:n.paddingAngle,minAngle:n.minAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,cornerRadius:n.cornerRadius,presentationProps:l,maxRadius:r.maxRadius}),i.createElement(Ga,V({},n,{id:o})),i.createElement(nr,V({},n,{id:o}))))}var nt=lr;nt.displayName="Pie";function ir(t){var r=la();return i.useEffect(()=>{r(ia(t))},[r,t]),null}var or=["layout"];function be(){return be=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var s=arguments[r];for(var n in s)({}).hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t},be.apply(null,arguments)}function cr(t,r){if(t==null)return{};var s,n,l=dr(t,r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)s=o[n],r.indexOf(s)===-1&&{}.propertyIsEnumerable.call(t,s)&&(l[s]=t[s])}return l}function dr(t,r){if(t==null)return{};var s={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(r.indexOf(n)!==-1)continue;s[n]=t[n]}return s}function Ve(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,n)}return s}function mr(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Ve(Object(s),!0).forEach(function(n){xr(t,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Ve(Object(s)).forEac
1h(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(s,n))})}return t}function xr(t,r,s){return(r=ur(r))in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function ur(t){var r=pr(t,"string");return typeof r=="symbol"?r:r+""}function pr(t,r){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var n=s.call(t,r);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var gr={top:5,right:5,bottom:5,left:5},lt=mr({accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:gr,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},pa),hr=i.forwardRef(function(r,s){var n,l=ve(r.categoricalChartProps,lt),{layout:o}=l,c=cr(l,or),{chartName:p,defaultTooltipEventType:_,validateTooltipEventTypes:v,tooltipPayloadSearcher:y}=r,S={chartName:p,defaultTooltipEventType:_,validateTooltipEventTypes:v,tooltipPayloadSearcher:y,eventEmitter:void 0};return i.createElement(oa,{preloadedState:{options:S},reduxStoreName:(n=l.id)!==null&&n!==void 0?n:p},i.createElement(ca,{chartData:l.data}),i.createElement(da,{layout:o,margin:l.margin}),i.createElement(ma,{throttleDelay:l.throttleDelay,throttledEvents:l.throttledEvents}),i.createElement(xa,{baseValue:void 0,accessibilityLayer:l.accessibilityLayer,barCategoryGap:l.barCategoryGap,maxBarSize:l.maxBarSize,stackOffset:l.stackOffset,barGap:l.barGap,barSize:l.barSize,syncId:l.syncId,syncMethod:l.syncMethod,className:l.className,reverseStackOrder:l.reverseStackOrder}),i.createElement(ir,{cx:l.cx,cy:l.cy,startAngle:l.startAngle,endAngle:l.endAngle,innerRadius:l.innerRadius,outerRadius:l.outerRadius}),i.createElement(ua,be({},c,{ref:s})))});function ze(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),s.push.apply(s,n)}return s}function Ue(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?ze(Object(s),!0).forEach(function(n){br(t,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):ze(Object(s)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(s,n))})}return t}function br(t,r,s){return(r=vr(r))in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function vr(t){var r=yr(t,"string");return typeof r=="symbol"?r:r+""}function yr(t,r){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var n=s.call(t,r);
1if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}var fr=["item"],jr=Ue(Ue({},lt),{},{layout:"centric",startAngle:0,endAngle:360}),_r=i.forwardRef((t,r)=>{var s=ve(t,jr);return i.createElement(hr,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:fr,tooltipPayloadSearcher:ga,categoricalChartProps:s,ref:r})});const Nr=t=>t>=1e5?`${(t/1e5).toFixed(1)}L`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toFixed(0),x=t=>`₹${Nr(t)}`;function R({label:t,value:r,sub:s,color:n}){return e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-4",children:[e.jsx("p",{className:"text-xs text-gray-500 uppercase tracking-wide",children:t}),e.jsx("p",{className:`text-2xl font-bold mt-1 ${n}`,children:r}),s&&e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:s})]})}function qe({platform:t}){const r={google:"bg-blue-50 text-blue-700",meta:"bg-indigo-50 text-indigo-700",google_ads:"bg-blue-50 text-blue-700",meta_ads:"bg-indigo-50 text-indigo-700"};return e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${r[t]||"bg-gray-100 text-gray-600"}`,children:t})}function wr({bucket:t}){const r={retargeting:"bg-green-50 text-green-700",exploration:"bg-amber-50 text-amber-700",performance:"bg-blue-50 text-blue-700"};return e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${r[t]||"bg-gray-100 text-gray-600"}`,children:t})}function Pr({cls:t}){const r={A:"bg-green-50 text-green-700",B:"bg-blue-50 text-blue-700",C:"bg-amber-50 text-amber-700",D:"bg-red-50 text-red-700"},s={A:"Auto",B:"Auto+Log",C:"Approval",D:"Human Only"};return e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${r[t]||"bg-gray-100 text-gray-600"}`,children:s[t]||t})}function Ar({severity:t}){const r={high:"bg-red-50 text-red-700",medium:"bg-amber-50 text-amber-700",info:"bg-blue-50 text-blue-700"};return e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${r[t]||"bg-gray-100 text-gray-600"}`,children:t})}function Or({type:t}){const r={scale_up:"bg-green-50 text-green-700",reduce:"bg-red-50 text-red-700",pause:"bg-gray-100 text-gray-700",rebalance:"bg-blue-50 text-blue-700",explore:"bg-purple-50 text-purple-700",info:"bg-amber-50 text-amber-700"};return e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${r[t]||"bg-gray-100 text-gray-600"}`,children:t.replace(/_/g," ")})}function te({ok:t,label:r}){return e.jsxs("div",{className:`flex items-center gap-1.5 text-xs ${t?"text-green-600":"text-red-600"}`,children:[e.jsx("span",{children:t?"✓":"✗"}),e.jsx("span",{children:r})]})}const Rr=["#10b981","#f59e0b","#8b5cf6","#3b82f6"];function Er(){const[t,r]=i.useState("allocation"),[s,n]=i.useState(!0),[l,o]=i.useState(""),[c,p]=i.useState(null),[_,v]=i.useState([]),[y,S]=i.useState([]),[u,w]=i.useState(!1),[N,P]=i.useState("budget_to_outcome"),[f,g]=i.useState(""),[k,K]=i.useState(""),[T,L]=i.useState(""),[A,C]=i.useState(7),[d,W]=i.useState(null),[$,M]=i.useState(!1),[O,F]=i.useState([]),[D,Z]=i.useState(null),[B,z]=i.useState(null),[xe,ne]=i.useState(!1),[Y,it]=i.useState(""),[le,ot]=i.useState(""),[h,ct]=i.useState(null),[Ne,we]=i.useState(!1),[U,dt]=i.useState(null),[ue,mt]=i.useState([]),[Pe,xt]=i.useState([]),[Ae,Oe]=i.useState(!1),[Re,Se]=i.useState(!1),Ce=i.useCallback(async()=>{try{n(!0),o("");const[a,m]=await Promise.all([E.get("/v1/budget/overview"),E.get("/v1/budget/allocation")]);p(a),v(m.allocation||[])}catch(a){o(a.message||"Failed to load budget data")}finally{n(!1)}},[]),ke=i.useCallback(async()=>{try{w(!0);const a=await E.get("/v1/budget/recommendations");S(a.recommendations||[])}catch(a){o(a.message||"Failed to load recommendations")}finally{w(!1)}},[]),ut=i.useCallback(async()=>{try{M(!0),o("");const a={mode:N,timeframe_days:A};N==="budget_to_outcome"?a.budget_amount=parseFloat(f)||0:N==="target_to_budget"&&(a.target_orders=parseFloat(k)||0,a.target_revenue=parseFloat(T)||0);const m=await E.post("/v1/budget/forecast",a);W(m)}catch(a){o(a.message||"Forecast failed")}finally{M(!1)}},[N,f,k,T,A]),Q=i.useCallback(async()=>{try{ne(!0);const[a,m,j]=await Promise.all([E.get("/v1/promotions?limit=30"),E.get("/v1/promotions/budget-status"),E.get("/v1/promotions/summary")]);F(a.promotions||[]),Z(m),z(j)}catch(a){o(a.message||"Failed to load promotions")}finally{ne(!1)}},[]),pt=i.useCallback(async()=>
1{if(Y)try{we(!0);const a={product_ids:[Y]};le&&(a.campaign_id=le);const m=await E.post("/v1/promotions/recommend",a);ct(m)}catch(a){o(a.message||"Recommendation failed")}finally{we(!1)}},[Y,le]);i.useEffect(()=>{Ce()},[Ce]),i.useEffect(()=>{t==="recommendations"&&y.length===0&&ke()},[t,ke,y.length]),i.useEffect(()=>{t==="promotions"&&O.length===0&&Q()},[t,Q,O.length]);const ie=i.useCallback(async()=>{Oe(!0);try{const[a,m,j]=await Promise.all([E.get("/v1/inventory-throttle/status"),E.get("/v1/inventory-throttle/rules?limit=50"),E.get("/v1/inventory-throttle/log?limit=20")]);dt(a),mt(m.rules||[]),xt(j.log||[])}catch{}finally{Oe(!1)}},[]),gt=async()=>{Se(!0);try{await E.post("/v1/inventory-throttle/refresh",{}),await ie()}catch{}finally{Se(!1)}};i.useEffect(()=>{t==="inventory"&&ie()},[t,ie]);const pe=c?.waterfall_pools?[{name:"Retargeting",value:c.waterfall_pools.retargeting},{name:"Exploration",value:c.waterfall_pools.exploration},{name:"Trend Reserve",value:c.waterfall_pools.trend_reserve},{name:"Performance",value:c.waterfall_pools.performance}]:[],Ee=c?.by_platform?Object.entries(c.by_platform).map(([a,m])=>({platform:a,current:m.current_total,recommended:m.recommended_total})):[];return s?e.jsxs("div",{className:"p-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-1",children:"Budget Center"}),e.jsx("div",{className:"mt-8 text-center text-gray-400",children:"Loading budget data..."})]}):e.jsxs("div",{className:"p-6 max-w-[1400px] mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Budget Center"}),e.jsx("p",{className:"text-gray-500 text-sm",children:"Allocation waterfall, AI recommendations, and budget forecaster — read-only analysis mode"})]}),l&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 text-red-700 rounded-lg text-sm",children:l}),c&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-3 mb-6",children:[e.jsx(R,{label:"Total Budget",value:x(c.total_budget),color:"text-gray-900",sub:"daily cap"}),e.jsx(R,{label:"Total Spend",value:x(c.current_spend),color:"text-blue-600",sub:"all campaigns"}),e.jsx(R,{label:"Campaigns",value:c.campaign_count,color:"text-indigo-600"}),e.jsx(R,{label:"cROAS",value:`${(c.summary?.overall_croas||0).toFixed(2)}x`,color:"text-emerald-600",sub:"Contribution ROAS"}),e.jsx(R,{label:"Orders",value:c.summary?.total_orders||0,color:"text-purple-600",sub:"attributed"}),e.jsx(R,{label:"Exposure",value:c.exposure_check?.all_clear?"Clear":"Warning",color:c.exposure_check?.all_clear?"text-green-600":"text-red-600",sub:"limit checks"})]}),e.jsx("div",{className:"flex gap-1 bg-gray-100 rounded-lg p-1 mb-6 w-fit",children:[["allocation","Current Allocation"],["recommendations","Recommendations"],["forecaster","Forecaster"],["promotions","Promotions"],["inventory","Inventory"]].map(([a,m])=>e.jsx("button",{onClick:()=>r(a),className:`px-4 py-2 text-sm rounded-md transition ${t===a?"bg-white shadow-sm font-medium text-gray-900":"text-gray-500 hover:text-gray-700"}`,children:m},a))}),t==="allocation"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-3",children:"Allocation Waterfall"}),pe.length>0&&e.jsx(Le,{width:"100%",height:240,children:e.jsxs(_r,{children:[e.jsx(nt,{data:pe,cx:"50%",cy:"50%",innerRadius:55,outerRadius:90,paddingAngle:3,dataKey:"value",label:({name:a,value:m})=>`${a}: ${x(m)}`,children:pe.map((a,m)=>e.jsx(fe,{fill:Rr[m]},m))}),e.jsx(Fe,{formatter:a=>x(a)})]})}),c?.waterfall&&e.jsxs("div",{className:"flex gap-4 mt-2 text-xs text-gray-500 justify-center flex-wrap",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500"})," Retargeting ",c.waterfall.retargeting_pct,"%"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500"})," Exploration ",c.waterfall.exploration_pct,"%"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-violet-500"})," Trend ",c.waterfall.trend_reserve_pct,"%"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500"})," Performance ",c.waterfall.performance_pool_pct,"%"]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-3",children:"Exposure Limits"}),c?.exposure_check&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(te,{ok:c.exposure_check.max_increase_respected,label:"Max +30% increase per decision"}),e.jsx(te,{ok:c.exposure_check.experimental_within_limit,label:`Experimental spend: ${c.exposure_check.experimental_pct}% (max 20%)`}),e.jsx(te,{ok:c.exposure_check.experiments_within_limit,label:`Concurrent experiments: ${c.exposure_check.concurrent_experiments} (max 5)`}),e.jsx(te,{ok:c.exposure_check.variable_changes_ok,label:"Variable changes: <=2 per 48h"}),e.jsx(te,{ok:c.exposure_check.cooldown_clear,label:"Cooldown period: clear"}),e.jsx("div",{className:`mt-4 p-3 rounded-lg text-sm font-medium ${c.exposure_check.all_clear?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:c.exposure_check.all_clear?"✓ All exposure limits satisfied":"✗ Exposure limit violations detected"})]}),Ee.length>0&&e.jsxs("div",{className:"mt-6",children:[e.jsx("h4",{className:"text-xs font-semibold text-gray-600 mb-2 uppercase",children:"By Platform"}),e.jsx(Le,{width:"100%",height:140,children:e.jsxs(ha,{data:Ee,layout:"vertical",children:[e.jsx(ba,{strokeDasharray:"3 3"}),e.jsx(va,{type:"number",tickFormatter:a=>x(a)}),e.jsx(ya,{type:"category",dataKey:"platform",width:60}),e.jsx(Fe,{formatter:a=>x(a)}),e.jsx(Be,{dataKey:"current",fill:"#94a3b8",name:"Current"}),e.jsx(Be,{dataKey:"recommended",fill:"#3b82f6",name:"Recommended"}),e.jsx(fa,{})]})})]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-100",children:e.jsxs("h3",{className:"text-sm font-semibold text-gray-700",children:["Campaign Budget Allocation (",_.length,")"]})}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500 text-xs uppercase",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Campaign"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Platform"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Bucket"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Current"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Recommended"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Change"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"cROAS"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Conf."}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Class"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Reason"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:_.map((a,m)=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-2 font-medium text-gray-900 max-w-[200px] truncate",children:a.campaign_name}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(qe,{platform:a.platform})}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(wr,{bucket:a.bucket})}),e.jsx("td",{className:"px-3 py-2 text-right text-gray-600",children:x(a.current_budget)}),e.jsx("td",{className:"px-3 py-2 text-right font-medium text-gray-900",children:x(a.recommended_budget)}),e.jsxs("td",{className:`px-3 py-2 text-right font-medium ${a.change_pct>0?"text-green-600":a.change_pct<0?"text-red-600":"text-gray-500"}`,children:[a.change_pct>0?"+":"",a.change_pct.toFixed(1),"%"]}),e.jsxs("td",{className:"px-3 py-2 text-right",children:[a.croas.toFixed(2),"x"]}),e.jsxs("td",{className:"px-3 py-2 text-right",children:[(a.confidence*100).toFixed(0),"%"]}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(Pr,{cls:a.action_class})}),e.jsx("td",{className:"px-3 py-2 text-gray-500 max-w-[240px] truncate",children:a.reason})]},m))})]})})]})]}),t==="recommendations"&&e.jsx("div",{className:"space-y-4",children:u?e.jsx("div",{className:"text-center py-12 text-gray-400",children:"Generating AI recommendations..."}):y.length===0?e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-8 text-center text-gray-400",children:"No recommendations available. Click Recommendations tab to generate."}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-gray-500",children:[y.length," budget recommendations"]}),y.some(a=>a.attribution_warning)&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-3 text-xs text-amber-800",children:[e.jsx("strong",{children:"Attribution Gap:"})," Some campaigns show cROAS = 0.00x because per-campaign attribution hasn't flowed yet. Platform-reported ROAS is used as a fallback. Campaigns with good platform ROAS will NOT be recommended for pausing."]}),y.map((a,m)=>e.jsx("div",{className:`bg-white rounded-lg shadow-sm border p-4 ${a.attribution_warning?"border-amber-200":"border-gray-100"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(Ar,{severity:a.severity}),e.jsx(Or,{type:a.type}),a.attribution_warning&&e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded bg-amber-100 text-amber-700 font-medium",children:"Platform ROAS fallback"}),a.campaign_name&&e.jsx("span",{className:"text-xs text-gray-500",children:a.campaign_name})]}),e.jsx("p",{className:"text-sm text-gray-800",children:a.message}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Action: ",a.action]}),a.current_value>0&&e.jsxs("p",{className:"text-xs text-gray-400 mt-0.5",children:[x(a.current_value)," → ",x(a.recommended_value),a.expected_impact&&` — ${a.expected_impact}`]})]}),e.jsx("button",{disabled:!0,className:"px-3 py-1.5 text-xs rounded-md bg-gray-100 text-gray-400 cursor-not-allowed",title:"Execute mode disabled in Phase A - apply manually",children:"Approve"}),e.jsx(vt,{agentId:"budget_controller",contextType:"budget_recommendation",contextId:a.campaign_id||`rec-${m}`,agentLabel:"Budget Controller"})]})},m))]})}),t==="forecaster"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-5",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-4",children:"Budget Forecast Calculator"}),e.jsx("div",{className:"flex gap-2 mb-4",children:[["budget_to_outcome","Budget → Outcome"],["target_to_budget","Target → Budget"],["scenario_compare","Compare Scenarios"]].map(([a,m])=>e.jsx("button",{onClick:()=>{P(a),W(null)},className:`px-3 py-1.5 text-xs rounded-md transition ${N===a?"bg-indigo-600 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:m},a))}),e.jsxs("div",{className:"flex gap-4 items-end flex-wrap",children:[N==="budget_to_outcome"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Daily Budget (INR)"}),e.jsx("input",{type:"number",value:f,onChange:a=>g(a.target.value),placeholder:"e.g. 10000",className:"border border-gray-300 rounded-md px-3 py-2 text-sm w-40"})]}),N==="target_to_budget"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Target Orders/Day"}),e.jsx("input",{type:"number",value:k,onChange:a=>K(a.target.value),placeholder:"e.g. 30",className:"border border-gray-300 rounded-md px-3 py-2 text-sm w-36"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Target Revenue/Day (INR)"}),e.jsx("input",{type:"number",value:T,onChange:a=>L(a.target.value),placeholder:"e.g. 50000",className:"border border-gray-300 rounded-md px-3 py-2 text-sm w-40"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Timeframe"}),e.jsxs("select",{value:A,onChange:a=>C(parseInt(a.target.value)),className:"border border-gray-300 rounded-md px-3 py-2 text-sm",children:[e.jsx("option",{value:7,children:"7 days"}),e.jsx("option",{value:14,children:"14 days"}),e.jsx("option",{value:30,children:"30 days"})]})]}),e.jsx("button",{onClick:ut,disabled:$,className:"px-4 py-2 bg-indigo-600 text-white rounded-md text-sm hover:bg-indigo-700 disabled:opacity-50",children:$?"Forecasting...":"Run Forec
1ast"})]})]}),d&&!d.error&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(R,{label:"Confidence",value:`${d.confidence_pct}%`,color:d.confidence_pct>=70?"text-green-600":d.confidence_pct>=50?"text-amber-600":"text-red-600",sub:`${d.data_quality?.data_days||0} days of data`}),e.jsx(R,{label:"Avg Daily Spend",value:x(d.base_metrics?.avg_daily_spend||0),color:"text-gray-900",sub:"recency-weighted"}),e.jsx(R,{label:"Avg cROAS",value:`${(d.base_metrics?.avg_croas||0).toFixed(2)}x`,color:"text-emerald-600",sub:"current performance"}),e.jsx(R,{label:"Avg CPC",value:x(d.base_metrics?.avg_cpc||0),color:"text-blue-600",sub:"recency-weighted"})]}),d.predictions&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-semibold text-gray-700 mb-3",children:["Forecast: ₹",(d.budget_amount||0).toLocaleString(),"/day over ",d.timeframe_days," days"]}),d.adjustments&&d.adjustments.budget_multiplier>1&&e.jsxs("div",{className:"mb-3 p-2 bg-amber-50 text-amber-700 rounded text-xs",children:["Diminishing returns: CPC +",d.adjustments.cpc_adjustment_pct,"%, Conversions ",d.adjustments.conversion_adjustment_pct,"% (at ",d.adjustments.budget_multiplier,"x current spend)"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:["conservative","expected","optimistic"].map(a=>{const m=d.predictions[a],j={conservative:"border-amber-200 bg-amber-50/50",expected:"border-blue-200 bg-blue-50/50",optimistic:"border-green-200 bg-green-50/50"};return e.jsxs("div",{className:`rounded-lg border-2 p-4 ${j[a]}`,children:[e.jsx("h5",{className:"text-xs font-semibold uppercase text-gray-500 mb-3",children:a}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Total Spend"}),e.jsx("span",{className:"font-medium",children:x(m.total_spend)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Conversions"}),e.jsx("span",{className:"font-medium",children:m.total_conversions.toFixed(1)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Revenue"}),e.jsx("span",{className:"font-medium",children:x(m.total_revenue)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"cROAS"}),e.jsxs("span",{className:"font-bold text-emerald-600",children:[m.croas,"x"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-500",children:"Daily Clicks"}),e.jsx("span",{className:"font-medium",children:m.daily_clicks})]})]})]},a)})})]}),d.recommended_budget!==void 0&&d.recommended_budget>0&&e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 mb-3",children:"Required Budget"}),e.jsxs("div",{className:"text-3xl font-bold text-indigo-600",children:[x(d.recommended_budget),"/day"]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[d.budget_increase_factor,"x current spend"]}),d.feasibility_warning&&e.jsx("div",{className:"mt-2 p-2 bg-amber-50 text-amber-700 rounded text-xs",children:"Warning: Requires >2x current spend — significant diminishing returns expected"})]}),d.scenarios&&d.scenarios.length>0&&e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-100",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700",children:"Scenario Comparison"}),d.recommended&&e.jsxs("p",{className:"text-xs text-emerald-600 mt-0.5",children:["Recommended: ",d.recommended," — ",d.recommendation_reason]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500 text-xs uppercase",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Scenario"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Daily Budget"}),e.jsxs("th",{className:"px-3 py-2 text-right",children:["Total (",d.timeframe_days,"d)"]}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Conv/Day"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Rev/Day"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Total Rev"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"cROAS"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"CPC Adj."}),e.jsx("th",{className:"px-3 py-2 text-center",children:"Dim. Returns"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:d.scenarios.map((a,m)=>e.jsxs("tr",{className:`hover:bg-gray-50 ${a.name===d.recommended?"bg-emerald-50/50":""}`,children:[e.jsxs("td",{className:"px-4 py-2 font-medium text-gray-900",children:[a.name,a.name===d.recommended&&e.jsx("span",{className:"ml-1 text-xs text-emerald-600",children:"★"})]}),e.jsx("td",{className:"px-3 py-2 text-right",children:x(a.daily_budget)}),e.jsx("td",{className:"px-3 py-2 text-right",children:x(a.total_budget)}),e.jsx("td",{className:"px-3 py-2 text-right",children:a.expected_daily_conversions.toFixed(1)}),e.jsx("td",{className:"px-3 py-2 text-right",children:x(a.expected_daily_revenue)}),e.jsx("td",{className:"px-3 py-2 text-right font-medium",children:x(a.expected_total_revenue)}),e.jsxs("td",{className:"px-3 py-2 text-right text-emerald-600 font-medium",children:[a.expected_croas,"x"]}),e.jsx("td",{className:"px-3 py-2 text-right text-amber-600",children:a.cpc_adjustment>0?`+${a.cpc_adjustment}%`:"-"}),e.jsx("td",{className:"px-3 py-2 text-center",children:a.diminishing_returns?e.jsx("span",{className:"text-amber-600",children:"⚠"}):e.jsx("span",{className:"text-green-600",children:"-"})})]},m))})]})})]})]}),d?.error&&e.jsx("div",{className:"bg-red-50 text-red-700 p-4 rounded-lg text-sm",children:d.error}),!d&&!$&&e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-8 text-center text-gray-400",children:"Select a forecast mode, enter parameters, and click “Run Forec
1ast” to see predictions."})]}),t==="promotions"&&e.jsx("div",{className:"space-y-6",children:xe?e.jsx("div",{className:"text-center py-12 text-gray-400",children:"Loading promotions..."}):e.jsxs(e.Fragment,{children:[D&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-3 uppercase tracking-wide",children:"Promo Budget Status"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(R,{label:"Monthly Ad Spend",value:x(D.monthly_ad_spend||0),color:"text-gray-900",sub:"this month"}),e.jsx(R,{label:"Promo Budget Cap",value:x(D.promo_budget_cap||0),color:"text-blue-600",sub:"10% of ad spend"}),e.jsx(R,{label:"Promo Spent",value:x(D.promo_spent||0),color:"text-amber-600",sub:"discount cost"}),e.jsx(R,{label:"Remaining",value:x(D.remaining||0),color:"text-green-600",sub:`${(D.utilization_pct||0).toFixed(0)}% utilized`})]}),e.jsx("div",{className:"mt-2 bg-gray-200 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:`h-2 rounded-full transition-all ${(D.utilization_pct||0)>80?"bg-red-500":(D.utilization_pct||0)>50?"bg-amber-500":"bg-green-500"}`,style:{width:`${Math.min(D.utilization_pct||0,100)}%`}})})]}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-700 mb-3 uppercase tracking-wide",children:["Active Promotions (",O.filter(a=>a.status==="active").length,")"]}),O.filter(a=>a.status==="active").length===0?e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-6 text-center text-gray-400 text-sm",children:"No active promotions. Create one or approve a draft."}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:O.filter(a=>a.status==="active").map(a=>e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-green-200 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ge,{type:a.promo_type}),e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full bg-green-50 text-green-700",children:"Active"}),a.platform&&a.platform!=="all"&&e.jsx(qe,{platform:a.platform})]}),e.jsx("h4",{className:"font-semibold text-gray-900 text-sm",children:a.name}),a.discount_value&&e.jsx("p",{className:"text-lg font-bold text-indigo-600 mt-1",children:a.discount_unit==="percent"?`${a.discount_value}% off`:`₹${a.discount_value} off`}),(a.applicable_categories?.length>0||a.applicable_product_ids?.length>0)&&e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[a.applicable_categories?.length>0&&`Categories: ${a.applicable_categories.join(", ")}`,a.applicable_product_ids?.length>0&&`${a.applicable_categories?.length>0?" | ":""}Products: ${a.applicable_product_ids.length}`]}),a.start_date&&a.end_date&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex justify-between text-xs text-gray-400",children:[e.jsx("span",{children:new Date(a.start_date).toLocaleDateString()}),e.jsx("span",{children:new Date(a.end_date).toLocaleDateString()})]}),e.jsx("div",{className:"bg-gray-200 rounded-full h-1.5 mt-0.5",children:e.jsx("div",{className:"h-1.5 rounded-full bg-green-500",style:{width:`${Math.min(100,Math.max(5,(Date.now()-new Date(a.start_date).getTime())/(new Date(a.end_date).getTime()-new Date(a.start_date).getTime())*100))}%`}})})]}),e.jsxs("div",{className:"flex gap-4 mt-2 text-xs text-gray-500",children:[e.jsxs("span",{children:["Redemptions: ",a.total_redemptions||0]}),e.jsxs("span",{children:["Revenue: ",x(a.total_revenue_with_promo||0)]})]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx("button",{onClick:async()=>{await E.patch(`/v1/promotions/${a.id}`,{status:"paused"}),Q()},className:"px-3 py-1 text-xs rounded-md bg-amber-50 text-amber-700 hover:bg-amber-100",children:"Pause"}),e.jsx("button",{onClick:async()=>{try{await E.post(`/v1/promotions/${a.id}/evaluate`,{}),Q()}catch(m){console.error("Failed to evaluate promotion:",m)}},className:"px-3 py-1 text-xs rounded-md bg-blue-50 text-blue-700 hover:bg-blue-100",children:"Evaluate"})]})]},a.id))})]}),O.filter(a=>["draft","pending_review","approved"].includes(a.status)).length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-700 mb-3 uppercase tracking-wide",children:["Pending Promotions (",O.filter(a=>["draft","pending_review","approved"].includes(a.status)).length,")"]}),e.jsx("div",{className:"space-y-2",children:O.filter(a=>["draft","pending_review","approved"].includes(a.status)).map(a=>e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ge,{type:a.promo_type}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-gray-900",children:a.name}),a.discount_value&&e.jsx("span",{className:"ml-2 text-sm text-indigo-600 font-medium",children:a.discount_unit==="percent"?`${a.discount_value}%`:`₹${a.discount_value}`})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${a.status==="approved"?"bg-green-50 text-green-700":a.status==="pending_review"?"bg-amber-50 text-amber-700":"bg-gray-100 text-gray-600"}`,children:a.status}),a.status==="draft"&&e.jsx("button",{onClick:async()=>{try{await E.post(`/v1/promotions/${a.id}/approve`,{}),Q()}catch(m){console.error("Failed to approve promotion:",m)}},className:"px-3 py-1 text-xs rounded-md bg-green-600 text-white hover:bg-green-700",children:"Approve"})]})]},a.id))})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-3 uppercase tracking-wide",children:"Offer vs Media Recommendation"}),e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-4",children:[e.jsxs("div",{className:"flex gap-3 items-end flex-wrap",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Product ID"}),e.jsx("input",{type:"text",value:Y,onChange:a=>it(a.target.value),placeholder:"prod_...",className:"border border-gray-300 rounded-md px-3 py-2 text-sm w-56"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Campaign ID (optional)"}),e.jsx("input",{type:"text",value:le,onChange:a=>ot(a.target.value),placeholder:"campaign_id",className:"border border-gray-300 rounded-md px-3 py-2 text-sm w-56"})]}),e.jsx("button",{onClick:pt,disabled:Ne||!Y,className:"px-4 py-2 bg-indigo-600 text-white rounded-md text-sm hover:bg-indigo-700 disabled:opacity-50",children:Ne?"Analyzing...":"Get Recommendation"})]}),h&&e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:`p-4 rounded-lg border-2 ${h.verdict==="offer"?"border-green-300 bg-green-50":h.verdict==="media"?"border-blue-300 bg-blue-50":"border-purple-300 bg-purple-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-2xl font-bold ${h.verdict==="offer"?"text-green-700":h.verdict==="media"?"text-blue-700":"text-purple-700"}`,children:h.verdict==="offer"?"Run a Promotion":h.verdict==="media"?"Increase Ad Spend":"Combined Strategy"}),h.confidence&&e.jsxs("span",{className:"text-sm text-gray-500",children:["(",(h.confidence*100).toFixed(0),"% confidence)"]})]}),e.jsx("p",{className:"text-sm text-gray-700 mt-1",children:h.reasoning})]}),h.deterministic_signals?.length>0&&e.jsxs("div",{className:"text-xs text-gray-500",children:["Signals: ",h.deterministic_signals.join(" | ")]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[h.if_offer&&e.jsxs("div",{className:"border border-green-200 rounded-lg p-3 bg-green-50/50",children:[e.jsx("h5",{className:"text-xs font-semibold text-green-700 uppercase mb-2",children:"If Offer"}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"Type:"}
1)," ",h.if_offer.promo_type?.replace(/_/g," ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"Discount:"})," ",h.if_offer.discount_value,h.if_offer.discount_unit==="percent"?"%":" INR"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"Est. Orders:"})," +",h.if_offer.estimated_incremental_orders]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"Margin Impact:"})," ",x(Math.abs(h.if_offer.estimated_margin_impact_inr||0))]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"ROI:"})," ",h.if_offer.estimated_roi,"x"]})]})]}),h.if_media&&e.jsxs("div",{className:"border border-blue-200 rounded-lg p-3 bg-blue-50/50",children:[e.jsx("h5",{className:"text-xs font-semibold text-blue-700 uppercase mb-2",children:"If Media"}),e.jsxs("div",{className:"space-y-1 text-sm",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"Additional Budget:"})," ",x(h.if_media.additional_budget_inr||0)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"Est. Orders:"})," +",h.if_media.estimated_incremental_orders]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"Est. CPA:"})," ",x(h.if_media.estimated_cpa_inr||0)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-gray-500",children:"Platform:"})," ",h.if_media.recommended_platform]})]})]})]})]})]})]}),O.filter(a=>["completed","expired","cancelled"].includes(a.status)).length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-3 uppercase tracking-wide",children:"Promotion History"}),e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-500 text-xs uppercase",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Name"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Type"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Duration"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Redemptions"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Revenue"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"Discount Cost"}),e.jsx("th",{className:"px-3 py-2 text-right",children:"ROI"}),e.jsx("th",{className:"px-3 py-2 text-left",children:"Verdict"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:O.filter(a=>["completed","expired","cancelled"].includes(a.status)).map(a=>{const m=a.actual_cost_inr||0,j=a.incremental_revenue||0,Ie=m>0?(j/m).toFixed(2):"-";return e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-2 font-medium text-gray-900 max-w-[180px] truncate",children:a.name}),e.jsx("td",{className:"px-3 py-2",children:e.jsx(ge,{type:a.promo_type})}),e.jsxs("td",{className:"px-3 py-2 text-gray-500 text-xs",children:[a.start_date&&new Date(a.start_date).toLocaleDateString()," - ",a.end_date&&new Date(a.end_date).toLocaleDateString()]}),e.jsx("td",{className:"px-3 py-2 text-right",children:a.total_redemptions||0}),e.jsx("td",{className:"px-3 py-2 text-right",children:x(a.total_revenue_with_promo||0)}),e.jsx("td",{className:"px-3 py-2 text-right text-red-600",children:x(m)}),e.jsxs("td",{className:"px-3 py-2 text-right font-medium",children:[Ie,"x"]}),e.jsx("td",{className:"px-3 py-2",children:a.promo_vs_media_verdict&&e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full ${a.promo_vs_media_verdict==="promo"?"bg-green-50 text-green-700":a.promo_vs_media_verdict==="media"?"bg-blue-50 text-blue-700":"bg-gray-100 text-gray-600"}`,children:a.promo_vs_media_verdict})})]},a.id)})})]})})})]}),B&&B.total_promos>0&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(R,{label:"Total Promos",value:B.total_promos,color:"text-gray-900",sub:`last ${B.period_days} days`}),e.jsx(R,{label:"Total Redemptions",value:B.total_redemptions,color:"text-blue-600"}),e.jsx(R,{label:"Discount Cost",value:x(B.total_discount_cost||0),color:"text-red-600"}),e.jsx(R,{label:"Average ROI",value:`${(B.average_roi||0).toFixed(1)}x`,color:"text-green-600"})]})]})}),t==="inventory"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-bold text-gray-700",children:"Inventory-Aware Ad Management"}),e.jsx("button",{onClick:gt,disabled:Re,className:"px-3 py-1.5 text-xs bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 disabled:opacity-50 font-medium",children:Re?"Refreshing...":"Refresh Inventory"})]}),Ae?e.jsx("p",{className:"text-center text-gray-400 py-8 text-sm",children:"Loading inventory data..."}):e.jsxs(e.Fragment,{children:[U&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-white rounded-lg border border-gray-100 p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-gray-700",children:U.products_monitored}),e.jsx("p",{className:"text-[10px] text-gray-400 uppercase",children:"Monitored"})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-gray-100 p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-red-600",children:U.currently_paused}),e.jsx("p",{className:"text-[10px] text-gray-400 uppercase",children:"Paused"})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-gray-100 p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:U.budget_reduced}
1),e.jsx("p",{className:"text-[10px] text-gray-400 uppercase",children:"Reduced"})]}),e.jsxs("div",{className:"bg-white rounded-lg border border-gray-100 p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-bold text-green-600",children:x(U.estimated_daily_savings_inr||0)}),e.jsx("p",{className:"text-[10px] text-gray-400 uppercase",children:"Daily Savings"})]})]}),U?.top_risks?.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-red-600 uppercase mb-2",children:"Action Required"}),e.jsx("div",{className:"space-y-2",children:U.top_risks.map((a,m)=>{const j=a.stock_status==="out_of_stock"?"🔴":a.stock_status==="critical_low"?"🟡":"🟠";return e.jsxs("div",{className:"bg-white rounded-lg border border-red-200 p-3 text-xs flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"mr-1",children:j}),e.jsx("span",{className:"font-semibold text-gray-800",children:a.product_name?.slice(0,50)}),e.jsxs("span",{className:"text-gray-400 ml-2",children:[a.stock," units | ",a.stock_status?.replace(/_/g," ")," | Spend: ",x(a.daily_spend||0),"/day"]})]}),e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium ${a.current_action==="paused"?"bg-red-100 text-red-700":a.current_action==="budget_reduced"?"bg-yellow-100 text-yellow-700":"bg-orange-100 text-orange-700"}`,children:a.current_action==="none"?"Needs action":a.current_action.replace(/_/g," ")})]},m)})})]}),ue.length>0&&e.jsx("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-gray-50 border-b",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-3 py-2",children:"Product"}),e.jsx("th",{className:"text-right px-3 py-2",children:"Stock"}),e.jsx("th",{className:"text-right px-3 py-2",children:"Daily Sales"}),e.jsx("th",{className:"text-right px-3 py-2",children:"Days Supply"}),e.jsx("th",{className:"text-center px-3 py-2",children:"Status"}),e.jsx("th",{className:"text-center px-3 py-2",children:"Action"}),e.jsx("th",{className:"text-right px-3 py-2",children:"Budget"})]})}),e.jsx("tbody",{children:ue.slice(0,30).map(a=>{const m={out_of_stock:"bg-red-100 text-red-700",critical_low:"bg-red-50 text-red-600",low:"bg-yellow-100 text-yellow-700",healthy:"bg-green-50 text-green-700",overstocked:"bg-blue-50 text-blue-700",severely_overstocked:"bg-purple-50 text-purple-700"};return e.jsxs("tr",{className:"border-b border-gray-50 hover:bg-gray-25",children:[e.jsx("td",{className:"px-3 py-2 font-medium text-gray-800 max-w-[200px] truncate",children:a.product_name}),e.jsx("td",{className:"px-3 py-2 text-right font-mono",children:a.current_stock}),e.jsx("td",{className:"px-3 py-2 text-right font-mono",children:(a.avg_daily_sales||0).toFixed(1)}),e.jsx("td",{className:"px-3 py-2 text-right font-mono",children:a.days_of_supply!=null?`${a.days_of_supply}d`:"--"}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded-full text-[10px] font-medium ${m[a.stock_status]||"bg-gray-100"}`,children:(a.stock_status||"").replace(/_/g," ")})}),e.jsx("td",{className:"px-3 py-2 text-center",children:(()=>{const j=a.throttle_action||"none",q=(a.execution_status||"pending_approval")==="approved",ht=j!=="none"&&j!=="budget_normal"&&!q;let J="",ee="text-gray-400";return j==="paused"?(J=q?"Paused (approved)":"Rec: Pause",ee=q?"text-red-700 bg-red-50":"text-red-600"):j==="budget_reduced"?(J=q?"Reduced (approved)":"Rec: Reduce",ee=q?"text-yellow-700 bg-yellow-50":"text-yellow-600"):j==="budget_boosted"||j==="surge"?(J=q?"Boosted (approved)":"Rec: Boost",ee=q?"text-blue-700 bg-blue-50":"text-blue-600"):j==="budget_normal"?(J="Normal",ee="text-green-600"):J="No action",e.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-0.5 rounded ${ee}`,children:J}),ht&&e.jsx("button",{onClick:async()=>{const bt=j==="paused"||j==="budget_reduced"?"pause":j==="budget_boosted"?"boost":j==="surge"?"surge":"resume";try{await E.post(`/v1/inventory-throttle/override/${a.product_id}`,{action:bt,reason:`Approved by user: ${a.last_action_reason||j}`}),await ie()}catch{}},className:"text-[9px] px-1.5 py-0.5 bg-indigo-600 text-white rounded hover:bg-indigo-700 font-medium",children:"Approve"})]})})()}),e.jsx("td",{className:"px-3 py-2 text-right font-mono",children:a.current_daily_budget!=null?x(a.current_daily_budget):"--"})]},a.product_id)})})]})}),Pe.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold text-gray-600 uppercase mb-2",children:"Recent Actions"}),e.jsx("div",{className:"space-y-2",children:Pe.map(a=>e.jsxs("div",{className:"text-xs bg-gray-50 rounded p-2 flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:a.product_name?.slice(0,40)}),e.jsxs("span",{className:`ml-2 px-1.5 py-0.5 rounded text-[10px] font-medium ${a.action==="paused"?"bg-red-100 text-red-700":a.action==="budget_reduced"?"bg-yellow-100 text-yellow-700":a.action==="budget_normal"?"bg-green-100 text-green-700":"bg-gray-100"}`,children:[a.triggered_by==="manual"?"":"Rec: ",a.action?.replace(/_/g," ")
1]}),e.jsx("p",{className:"text-gray-500 mt-0.5",children:a.reason?.slice(0,100)})]}),e.jsxs("div",{className:"text-right flex-shrink-0 ml-3",children:[e.jsx("p",{className:"text-gray-400",children:new Date(a.created_at).toLocaleDateString()}),a.estimated_daily_savings_inr>0&&e.jsxs("p",{className:"text-green-600 font-medium",children:[x(a.estimated_daily_savings_inr),"/day saved"]})]})]},a.id))})]}),ue.length===0&&!Ae&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-gray-400 text-sm",children:"No inventory rules yet."}),e.jsx("p",{className:"text-gray-400 text-xs mt-1",children:'Click "Refresh Inventory" to scan products and create throttle rules.'})]})]})]})]})}function ge({type:t}){const r={percentage_discount:"bg-green-50 text-green-700",flat_discount:"bg-emerald-50 text-emerald-700",free_shipping:"bg-blue-50 text-blue-700",bundle_deal:"bg-purple-50 text-purple-700",flash_sale:"bg-red-50 text-red-700",first_order:"bg-amber-50 text-amber-700",loyalty_reward:"bg-indigo-50 text-indigo-700",cart_threshold:"bg-cyan-50 text-cyan-700",bogo:"bg-pink-50 text-pink-700"};return e.jsx("span",{className:`px-2 py-0.5 text-xs rounded-full whitespace-nowrap ${r[t]||"bg-gray-100 text-gray-600"}`,children:t.replace(/_/g," ")})}export{Er as default};

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