PageSourceSearch

https://blockautomation.ai/assets/ScopedAnalytics-BHVPTjRy.js

js blockautomation.ai collected 2026-10-05 13:09:40 UTC 44,217 bytes, 1 lines download raw bytes

vendor: 7,992 bytes, line 1
1import{R as N,r as b,j as e,W as Ne,K as Re,aQ as $e,X as Be,aB as ze,a_ as Le,a$ as Me,b as We,b0 as Ue,V as Ve,a1 as qe,ao as Ge,h as He,ai as Ze,al as Xe,u as Se,F as Je,x as Ye,B as Qe}from"./main-9st80poY.js";import{P as Ae,a as Ie,u as et}from"./ScopedAnalytics-BHm_8ve-.js";import{e as tt,b as at}from"./api-BzhAchE7.js";import{b as H,a as st}from"./blockDisplayName-D7An2h7d.js";import{g as xe,h as nt,i as de,j as M,k as it,A as rt,l as te,m as ot,n as Pe,E as lt,o as ne,p as ct,q as dt,r as ut,s as ht,t as R,u as pt,v as mt,G as ft,b as z,w as be,x as yt,X as _,Y as P,y as xt,z as _e,R as A,B as X,C as D,T as I,e as V,a as J,L as oe,d as Z,D as bt,F as vt,S as T,c as jt}from"./analyticsUi-BzZTfBZ7.js";import{M as gt}from"./MoneyTriplet-BaQpE5_q.js";import{l as Oe,f as F,a as O,C,c as kt,M as De}from"./analyticsFormat-C7Cmtqyg.js";import"./checkoutApi-B8Quyt35.js";function $(a){"@babel/helpers - typeof";return $=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$(a)}function wt(a,t){if(!(a instanceof t))throw new TypeError("Cannot call a class as a function")}function Nt(a,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(a,Fe(n.key),n)}}function St(a,t,s){return t&&Nt(a.prototype,t),Object.defineProperty(a,"prototype",{writable:!1}),a}function At(a,t,s){return t=ie(t),It(a,Ce()?Reflect.construct(t,s||[],ie(a).constructor):t.apply(a,s))}function It(a,t){if(t&&($(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Pt(a)}function Pt(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function Ce(){try{var a=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ce=function(){return!!a})()}function ie(a){return ie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},ie(a)}function _t(a,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(t&&t.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),t&&he(a,t)}function he(a,t){return he=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},he(a,t)}function Ee(a,t,s){return t=Fe(t),t in a?Object.defineProperty(a,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[t]=s,a}function Fe(a){var t=Ot(a,"string");return $(t)=="symbol"?t:t+""}function Ot(a,t){if($(a)!="object"||!a)return a;var s=a[Symbol.toPrimitive];if(s!==void 0){var n=s.call(a,t);if($(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(a)}var Y=(function(a){function t(){return wt(this,t),At(this,t,arguments)}return _t(t,a),St(t,[{key:"render",value:function(){return null}}])})(N.Component);Ee(Y,"displayName","ZAxis");Ee(Y,"defaultProps",{zAxisId:0,range:[64,64],scale:"auto",type:"number"});var Dt=["option","isActive"];function q(){return q=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(a[n]=s[n])}return a},q.apply(this,arguments)}function Ct(a,t){if(a==null)return{};var s=Et(a,t),n,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(a);for(i=0;i<o.length;i++)n=o[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(a,n)&&(s[n]=a[n])}return s}function Et(a,t){if(a==null)return{};var s={};for(var n in a)if(Object.prototype.hasOwnProperty.call(a,n)){if(t.indexOf(n)>=0)continue;s[n]=a[n]}return s}function Ft(a){var t=a.option,s=a.isActive,n=Ct(a,Dt);return typeof t=="string"?N.createElement(xe,q({option:N.createElement(nt,q({type:t},n)),isActive:s,shapeType:"symbols"},n)):N.createElement(xe,q({option:t,isActive:s,shapeType:"symbols"},n))}function B(a){"@babel/helpers - typeof";return B=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(a)}function G(){return G=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(a[n]=s[n])}return a},G.apply(this,arguments)}function ve(a,t){var s=Object.keys(a);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(a);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(a,i).enumerable})),s.push.apply(s,n)}return s}function S(a){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?ve(Object(s),!0).forEach(function(n){E(a,n,s[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):ve(Object(s)).forEach(function(n){Object.defineProperty(a,n,Object.getOwnPropertyDescriptor(s,n))})}return a}function Tt(a,t){if(!(a instanceof t))throw new TypeError("Cannot call a class as a function")}function je(a,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(a,Ke(n.key),n)}}function Kt(a,t,s){return t&&je(a.prototype,t),s&&je(a,s),Object.defineProperty(a,"prototype",{writable:!1}),a}function Rt(a,t,s){return t=re(t),$t(a,Te()?Reflect.construct(t,s||[],re(a).constructor):t.apply(a,s))}function $t(a,t){if(t&&(B(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Bt(a)}function Bt(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function Te(){try{var a=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Te=function(){return!!a})()}function re(a){return re=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},re(a)}function zt(a,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(t&&t.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),t&&pe(a,t)}function pe(a,t){return pe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},pe(a,t)}function E(a,t,s){return t=Ke(t),t in a?Object.defineProperty(a,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[t]=s,a}function Ke(a){var t=Lt(a,"string");return B(t)=="symbol"?t:t+""}function Lt(a,t){if(B(a)!="object"||!a)return a;var s=a[Symbol.toPrimitive];if(s!==void 0){var n=s.call(a,t);if(B(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(a)}var Q=(function(a){function t(){var s;Tt(this,t);for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return s=Rt(this,t,[].concat(i)),E(s,"state",{isAnimationFinished:!1}),E(s,"handleAnimationEnd",function(){s.setState({isAnimationFinished:!0})}),E(s,"handleAnimationStart",function(){s.setState({isAnimationFinished:!1})}),E(s,"id",mt("recharts-scatter-")),s}return zt(t,a),Kt(t,[{key:"renderSymbolsStatically",value:function(n){var i=this,o=this.props,l=o.shape,r=o.activeShape,m=o.activeIndex,c=de(this.props,!1);return n.map(function(d,p){var f=m===p,y=f?r:l,j=S(S({},c),d);return N.createElement(M,G({className:"recharts-scatter-symbol",key:"symbol-".concat(d==null?void 0:d.cx,"-").concat(d==null?void 0:d.cy,"-").concat(d==null?void 0:d.size,"-").concat(p)},it(i.props,d,p),{role:"img"}),N.createElement(Ft,G({option:y,isActive:f,key:"symbol-".concat(p)}
1,j)))})}},{key:"renderSymbolsWithAnimation",value:function(){var n=this,i=this.props,o=i.points,l=i.isAnimationActive,r=i.animationBegin,m=i.animationDuration,c=i.animationEasing,d=i.animationId,p=this.state.prevPoints;return N.createElement(rt,{begin:r,duration:m,isActive:l,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(d),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(f){var y=f.t,j=o.map(function(k,u){var v=p&&p[u];if(v){var g=te(v.cx,k.cx),w=te(v.cy,k.cy),h=te(v.size,k.size);return S(S({},k),{},{cx:g(y),cy:w(y),size:h(y)})}var x=te(0,k.size);return S(S({},k),{},{size:x(y)})});return N.createElement(M,null,n.renderSymbolsStatically(j))})}},{key:"renderSymbols",value:function(){var n=this.props,i=n.points,o=n.isAnimationActive,l=this.state.prevPoints;return o&&i&&i.length&&(!l||!ot(l,i))?this.renderSymbolsWithAnimation():this.renderSymbolsStatically(i)}},{key:"renderErrorBar",value:function(){var n=this.props.isAnimationActive;if(n&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.points,l=i.xAxis,r=i.yAxis,m=i.children,c=Pe(m,lt);return c?c.map(function(d,p){var f=d.props,y=f.direction,j=f.dataKey;return N.cloneElement(d,{key:"".concat(y,"-").concat(j,"-").concat(o[p]),data:o,xAxis:l,yAxis:r,layout:y==="x"?"vertical":"horizontal",dataPointFormatter:function(u,v){return{x:u.cx,y:u.cy,value:y==="x"?+u.node.x:+u.node.y,errorVal:ne(u,v)}}})}):null}},{key:"renderLine",value:function(){var n=this.props,i=n.points,o=n.line,l=n.lineType,r=n.lineJointType,m=de(this.props,!1),c=de(o,!1),d,p;if(l==="joint")d=i.map(function(w){return{x:w.cx,y:w.cy}});else if(l==="fitting"){var f=ct(i),y=f.xmin,j=f.xmax,k=f.a,u=f.b,v=function(h){return k*h+u};d=[{x:y,y:v(y)},{x:j,y:v(j)}]}var g=S(S(S({},m),{},{fill:"none",stroke:m&&m.fill},c),{},{points:d});return N.isValidElement(o)?p=N.cloneElement(o,g):dt(o)?p=o(g):p=N.createElement(ut,G({},g,{type:r})),N.createElement(M,{className:"recharts-scatter-line",key:"recharts-scatter-line"},p)}},{key:"render",value:function(){var n=this.props,i=n.hide,o=n.points,l=n.line,r=n.className,m=n.xAxis,c=n.yAxis,d=n.left,p=n.top,f=n.width,y=n.height,j=n.id,k=n.isAnimationActive;if(i||!o||!o.length)return null;var u=this.state.isAnimationFinished,v=ht("recharts-scatter",r),g=m&&m.allowDataOverflow,w=c&&c.allowDataOverflow,h=g||w,x=R(j)?this.id:j;return N.createElement(M,{className:v,clipPath:h?"url(#clipPath-".concat(x,")"):null},g||w?N.createElement("defs",null,N.createElement("clipPath",{id:"clipPath-".concat(x)},N.createElement("rect",{x:g?d:d-f/2,y:w?p:p-y/2,width:g?f:f*2,height:w?y:y*2}))):null,l&&this.renderLine(),this.renderErrorBar(),N.createElement(M,{key:"recharts-scatter-symbols"},this.renderSymbols()),(!k||u)&&pt.renderCallByParent(this.props,o))}}],[{key:"getDerivedStateFromProps",value:function(n,i){return n.animationId!==i.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:i.curPoints}:n.points!==i.curPoints?{curPoints:n.points}:null}}])})(b.PureComponent);E(Q,"displayName","Scatter");E(Q,"defaultProps",{xAxisId:0,yAxisId:0,zAxisId:0,legendType:"circle",lineType:"joint",lineJointType:"linear",data:[],shape:"circle",hide:!1,isAnimationActive:!ft.isSsr,animationBegin:0,animationDuration:400,animationEasing:"linear"});E(Q,"getComposedData",function(a){var t=a.xAxis,s=a.yAxis,n=a.zAxis,i=a.item,o=a.displayedData,l=a.xAxisTicks,r=a.yAxisTicks,m=a.offset,c=i.props.tooltipType,d=Pe(i.props.children,z),p=R(t.dataKey)?i.props.dataKey:t.dataKey,f=R(s.dataKey)?i.props.dataKey:s.dataKey,y=n&&n.dataKey,j=n?n.range:Y.defaultProps.range,k=j&&j[0],u=t.scale.bandwidth?t.scale.bandwidth():0,v=s.scale.bandwidth?s.scale.bandwidth():0,g=o.map(function(w,h){var x=ne(w,p),me=ne(w,f),L=!R(y)&&ne(w,y)||"-",fe=[{name:R(t.dataKey)?i.props.name:t.name||t.dataKey,unit:t.unit||"",value:x,payload:w,dataKey:p,type:c},{name:R(s.dataKey)?i.props.name:s.name||s.dataKey,unit:s.unit||"",value:me,payload:w,dataKey:f,type:c}];L!=="-"&&fe.push({name:n.name||n.dataKey,unit:n.unit||"",value:L,payload:w,dataKey:y,type:c});var le=be({axis:t,ticks:l,bandSize:u,entry:w,index:h,dataKey:p}),ce=be({axis:s,ticks:r,bandSize:v,entry:w,index:h,dataKey:f}),ye=L!=="-"?n.scale(L):k,ee=Math.sqrt(Math.max(ye,0)/Math.PI);return S(S({},w),{},{cx:le,cy:ce,x:le-ee,y:ce-ee,xAxis:t,yAxis:s,zAxis:n,width:2*ee,height:2*ee,size:ye,node:{x,y:me,z:L},tooltipPayload:fe,tooltipPosition:{x:le,y:ce},payload:w},d&&d[h]&&d[h].props)});return S({points:g},m)});var Mt=yt({chartName:"ScatterChart",GraphicalChild:Q,defaultTooltipEventType:"item",validateTooltipEventTypes:["item"],axisComponents:[{axisType:"xAxis",AxisComp:_},{axisType:"yAxis",AxisComp:P},{axisType:"zAxis",AxisComp:Y}],formatAxisMap:xt});const Wt={beach:Xe,pool:Ze,resort:He,gym:Ge,school:qe,theme_park:Ve,water_park:Ue,trailhead:We,golf_course:Me,marina:Le,campground:ze,sports_complex:Be,park:$e,event_venue:Re,other:Ne};function Ut({type:a}){const t=Wt[a]||Ne;return e.jsx(t,{size:13,"aria-hidden":"true"})}function U({active:a,onClick:t,children:s,testId:n}){return e.jsx("button",{"data-testid":n,className:`fc-pill${a?" fc-pill--active":""}`,onClick:t,type:"button",children:s})}function ae({active:a,onClick:t,label:s}){return e.jsxs(U,{active:a,onClick:t,children:["All ",s]})}function Vt({filterTree:a,scope:t,onScopeChange:s,userRole:n="administrator"}){const i=(a==null?void 0:a.franchises)??[],o=n==="administrator",l=b.useMemo(()=>o?i.find(h=>h.id===t.franchiseId)??null:null,[i,t.franchiseId,o]),r=b.useMemo(()=>o?(l==null?void 0:l.partners)??[]:i.flatMap(h=>h.partners??[]),[i,l,o]),m=b.useMemo(()=>r.find(h=>h.id===t.partnerId)??null,[r,t.partnerId]),c=b.useMemo(()=>m?m.locations??[]:[],[m]),d=b.useMemo(()=>c.find(h=>h.id===t.locationId)??null,[c,t.locationId]),p=b.useMemo(()=>d?d.blocks??[]:[],[d]),f=b.useMemo(()=>p.find(h=>h.serial===t.serial)??null,[p,t.serial]),y=h=>{h===t.franchiseId?s({}):s({franchiseId:h})},j=h=>{if(h===t.partnerId){const x={};o&&t.franchiseId&&(x.franchiseId=t.franchiseId),s(x)}else{const x=o&&t.franchiseId?{franchiseId:t.franchiseId}:{};s({...x,partnerId:h})}},k=h=>{if(h===t.locationId){const x={};t.franchiseId&&(x.franchiseId=t.franchiseId),t.partnerId&&(x.partnerId=t.partnerId),s(x)}else{const x={};t.franchiseId&&(x.franchiseId=t.franchiseId),t.partnerId&&(x.partnerId=t.partnerId),s({...x,locationId:h})}},u=h=>{if(h===t.serial){const x={};t.franchiseId&&(x.franchiseId=t.franchiseId),t.partnerId&&(x.partnerId=t.partnerId),t.locationId&&(x.locationId=t.locationId),s(x)}else{const x={};t.franchiseId&&(x.franchiseId=t.franchiseId),t.partnerId&&(x.partnerId=t.partnerId),t.locationId&&(x.locationId=t.locationId),s({...x,serial:h})}},v=()=>s({});if(!a)return null;const g=[];
1l&&g.push(l.name),m&&g.push(m.name),d&&g.push(d.name),f&&g.push(H(f));const w=`Viewing: ${g.length>0?g.join(" › "):"All"}`;return e.jsxs("div",{className:"fc-root","data-testid":"filter-cascade",children:[e.jsxs("div",{className:"fc-breadcrumb",children:[e.jsx("span",{className:"fc-breadcrumb-label","data-testid":"fc-viewing-label",children:w}),g.length>0&&e.jsx("button",{className:"fc-reset",onClick:v,type:"button",children:"Reset"})]}),o&&i.length>0&&e.jsxs("div",{className:"fc-row","data-testid":"fc-franchise-row",children:[e.jsx("span",{className:"fc-row-label",children:"Franchise"}),e.jsxs("div",{className:"fc-pills",children:[e.jsx(ae,{active:!t.franchiseId,onClick:v,label:"Franchises"}),i.map(h=>e.jsx(U,{active:t.franchiseId===h.id,onClick:()=>y(h.id),testId:`fc-franchise-${h.id}`,children:h.name},h.id))]})]}),r.length>0&&e.jsxs("div",{className:"fc-row","data-testid":"fc-partner-row",children:[e.jsx("span",{className:"fc-row-label",children:"Partner"}),e.jsxs("div",{className:"fc-pills",children:[e.jsx(ae,{active:!t.partnerId,onClick:()=>{const h=o&&t.franchiseId?{franchiseId:t.franchiseId}:{};s(h)},label:"Partners"}),r.map(h=>e.jsx(U,{active:t.partnerId===h.id,onClick:()=>j(h.id),testId:`fc-partner-${h.id}`,children:h.name},h.id))]})]}),c.length>0&&e.jsxs("div",{className:"fc-row","data-testid":"fc-location-row",children:[e.jsx("span",{className:"fc-row-label",children:"Location"}),e.jsxs("div",{className:"fc-pills",children:[e.jsx(ae,{active:!t.locationId,onClick:()=>{const h={};t.franchiseId&&(h.franchiseId=t.franchiseId),t.partnerId&&(h.partnerId=t.partnerId),s(h)},label:"Locations"}),c.map(h=>e.jsxs(U,{active:t.locationId===h.id,onClick:()=>k(h.id),testId:`fc-location-${h.id}`,children:[e.jsx("span",{className:"fc-loc-icon",children:e.jsx(Ut,{type:h.type})}),h.name]},h.id))]})]}),p.length>0&&e.jsxs("div",{className:"fc-row","data-testid":"fc-block-row",children:[e.jsx("span",{className:"fc-row-label",children:"Block"}),e.jsxs("div",{className:"fc-pills",children:[e.jsx(ae,{active:!t.serial,onClick:()=>{const h={};t.franchiseId&&(h.franchiseId=t.franchiseId),t.partnerId&&(h.partnerId=t.partnerId),t.locationId&&(h.locationId=t.locationId),s(h)},label:"Blocks"}),p.map(h=>e.jsx(U,{active:t.serial===h.serial,onClick:()=>u(h.serial),testId:`fc-block-${h.serial}`,children:H(h)},h.serial))]})]}),d&&p.length===0&&e.jsxs("div",{className:"fc-row fc-row--no-blocks","data-testid":"fc-no-blocks-hint",children:[e.jsx("span",{className:"fc-row-label",children:"Block"}),e.jsx("span",{className:"fc-no-blocks-text",children:"No blocks deployed at this location yet"})]})]})}const W=Oe,ue=(a,t)=>a.color||C[t%C.length],qt=(a,t,s)=>a.color||kt(a[t],s);function Gt(a="",t){if(t==null||Number.isNaN(Number(t)))return"—";if(/cents/i.test(a))return F(t);const s=Number(t);return Number.isInteger(s)?O(s):s.toLocaleString("en-US",{maximumFractionDigits:2})}function Ht(a=""){const t=String(a).replace(/_cents$/i,"").replace(/_/g," ").trim();return t?t.replace(/\b\w/g,s=>s.toUpperCase()):String(a)}const se=(a,t)=>typeof a=="number"?[O(a),t]:[a,t];function Zt({spec:a,data:t}){var o;const{chartType:s,xKey:n}=a,i=Array.isArray(a.series)&&a.series.length>0?a.series:[{key:"value",label:"Value"}];if(s==="kpi")return e.jsx("div",{"data-testid":"dynamic-kpi",className:"dynamic-kpi-row",children:i.map(l=>{var r;return e.jsxs("div",{className:"dynamic-kpi",children:[e.jsx("span",{className:"dynamic-kpi-value",children:Gt(l.key,(r=t[0])==null?void 0:r[l.key])}),e.jsx("span",{className:"dynamic-kpi-label",children:l.label||Ht(l.key)})]},l.key)})});if(s==="bar")return e.jsx(A,{width:"100%",height:340,children:e.jsxs(X,{data:t,margin:{top:8,right:16,left:0,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3",vertical:!1}),e.jsx(_,{dataKey:n,tick:{fontSize:12},tickFormatter:W}),e.jsx(P,{allowDecimals:!1}),e.jsx(I,{formatter:se,labelFormatter:W,cursor:{fill:"rgba(59,130,246,0.06)"}}),i.length>1&&e.jsx(V,{}),i.map((l,r)=>e.jsx(J,{dataKey:l.key,name:l.label||l.key,fill:ue(l,r),radius:[4,4,0,0],maxBarSize:64},l.key))]})});if(s==="line")return e.jsx(A,{width:"100%",height:340,children:e.jsxs(oe,{data:t,margin:{top:8,right:16,left:0,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3",vertical:!1}),e.jsx(_,{dataKey:n,tick:{fontSize:11}
1,tickFormatter:W}),e.jsx(P,{allowDecimals:!1}),e.jsx(I,{formatter:se,labelFormatter:W}),i.length>1&&e.jsx(V,{}),i.map((l,r)=>e.jsx(Z,{type:"monotone",dataKey:l.key,name:l.label||l.key,stroke:ue(l,r),strokeWidth:2,dot:!1},l.key))]})});if(s==="pie"){const l=i[0].key,r=t.map((m,c)=>({...m,__label:W(m[n]),__fill:qt(m,n,c)}));return e.jsx(A,{width:"100%",height:320,children:e.jsxs(Ae,{children:[e.jsx(Ie,{data:r,cx:"50%",cy:"50%",innerRadius:70,outerRadius:110,paddingAngle:3,dataKey:l,nameKey:"__label",children:r.map((m,c)=>e.jsx(z,{fill:m.__fill},c))}),e.jsx(I,{formatter:se}),e.jsx(V,{})]})})}if(s==="scatter"){const l=i[0].key,r=(o=i[1])==null?void 0:o.key;return e.jsx(A,{width:"100%",height:340,children:e.jsxs(Mt,{margin:{top:8,right:16,left:0,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3"}),e.jsx(_,{dataKey:n,name:n,type:"number"}),e.jsx(P,{dataKey:l,name:i[0].label||l}),r&&e.jsx(Y,{dataKey:r,range:[40,400],name:i[1].label||r}),e.jsx(I,{cursor:{strokeDasharray:"3 3"},formatter:se}),e.jsx(Q,{data:t,fill:ue(i[0],0),opacity:.7})]})})}return e.jsx(_e,{message:"This question can’t be charted yet."})}function Xt({spec:a,data:t}){const s=b.useMemo(()=>Array.isArray(t)?t:[],[t]);if(!a)return null;const n=a.chartType==="kpi",i=s.length===0;return e.jsxs("div",{className:"dynamic-chart","data-testid":"dynamic-chart",children:[e.jsxs("div",{className:"dynamic-chart-head",children:[e.jsx("h3",{className:"dynamic-chart-title",children:a.title}),a.note&&e.jsx("p",{className:"dynamic-chart-note",children:a.note})]}),i&&!n?e.jsx(_e,{message:"No data for that question."}):e.jsx(Zt,{spec:a,data:s})]})}const ge=["Dispenses by location type, last 30 days","Revenue by location, last 90 days","Purchases by block","Free vs paid dispenses"];function Jt(){const{isAdmin:a}=Se(),[t,s]=b.useState(""),[n,i]=b.useState("idle"),[o,l]=b.useState(null),[r,m]=b.useState(""),c=b.useRef(""),d=b.useRef(!0);b.useEffect(()=>()=>{d.current=!1},[]);const p=b.useCallback(async u=>{const v=(u??"").trim();if(v){s(v),c.current=v,i("loading"),m(""),l(null);try{const g=await tt.ask(v);if(!d.current)return;l(g||{}),i("done")}catch(g){if(!d.current)return;console.error("Ask failed:",g),m("Couldn’t get an answer. Please try again."),i("error")}}},[]),f=u=>{u.preventDefault(),p(t)},y=o==null?void 0:o.answerable,j=o!=null&&o.suggestions&&o.suggestions.length>0?o.suggestions:ge,k=o!=null&&o.error&&a&&a()?o.error:"";
1return e.jsxs("div",{className:"ask-panel","data-testid":"ask-panel",children:[e.jsxs("form",{className:"ask-bar",onSubmit:f,children:[e.jsx(Je,{className:"ask-bar-icon","aria-hidden":"true"}),e.jsx("input",{className:"ask-input",type:"text",value:t,onChange:u=>s(u.target.value),placeholder:"Ask anything — e.g. dispenses by location type, last 30 days","aria-label":"Ask a question about your analytics"}),e.jsx("button",{type:"submit",className:"ask-submit",disabled:!t.trim()||n==="loading",children:"Ask"})]}),n==="idle"&&e.jsxs("div",{className:"ask-examples",children:[e.jsx("span",{className:"ask-examples-label",children:"Try:"}),ge.map(u=>e.jsx("button",{type:"button","data-testid":"ask-example",className:"ask-chip",onClick:()=>p(u),children:u},u))]}),n!=="idle"&&e.jsxs("div",{className:"ask-result",children:[n==="loading"&&e.jsx(bt,{variant:"chart"}),n==="error"&&e.jsx(vt,{message:r,onRetry:()=>p(c.current)}),n==="done"&&y&&e.jsx(Xt,{spec:o.chartSpec,data:o.data}),n==="done"&&!y&&e.jsxs("div",{className:"ask-unanswerable","data-testid":"ask-suggestions",children:[k&&e.jsxs("div",{className:"ask-admin-error","data-testid":"ask-admin-error",role:"status",children:[e.jsx(Ye,{className:"ask-admin-error-icon","aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Ask is degraded (admin):"})," ",k]})]}),e.jsx("p",{className:"ask-unanswerable-msg",children:"I couldn’t chart that one. Here’s what I can show you:"}),e.jsx("div",{className:"ask-suggestion-chips",children:j.map(u=>e.jsx("button",{type:"button",className:"ask-chip ask-chip--suggest",onClick:()=>p(u),children:u},u))})]})]})]})}const ke=["#3b82f6","#10b981","#f59e0b","#ec4899","#8b5cf6","#6b7280","#0ea5e9","#f97316"];function Yt(a){if(!Array.isArray(a)||a.length===0)return[];const t=new Set;a.forEach(i=>{(i.points??[]).forEach(o=>t.add(o.weekStart))});const s=Array.from(t).sort(),n=new Map;return a.forEach(i=>{const o=new Map;(i.points??[]).forEach(l=>o.set(l.weekStart,l)),n.set(i.serial,o)}),s.map(i=>{const o={weekStart:i};return a.forEach(l=>{var m;const r=(m=n.get(l.serial))==null?void 0:m.get(i);o[l.serial]=(r==null?void 0:r.uptimePct)??null,o[`__meta__${l.serial}`]={upWindows:(r==null?void 0:r.upWindows)??0,eligibleWindows:(r==null?void 0:r.eligibleWindows)??0}}),o})}function Qt({active:a,label:t,payload:s,blockNames:n}){return!a||!(s!=null&&s.length)?null:e.jsxs("div",{className:"uptime-tooltip",children:[e.jsxs("p",{className:"uptime-tooltip-week",children:["Week of ",t]}),s.map(i=>{const o=i.dataKey,l=n[o]??o,r=i.payload[`__meta__${o}`],m=i.value;return e.jsxs("div",{className:"uptime-tooltip-row",children:[e.jsx("span",{className:"uptime-tooltip-dot",style:{background:i.color}}),e.jsx("span",{className:"uptime-tooltip-name",children:l}),m!=null?e.jsxs("span",{className:"uptime-tooltip-value",children:[m.toFixed(1),"%",r&&r.eligibleWindows>0&&e.jsxs("span",{className:"uptime-tooltip-windows",children:[" ","(",Math.round(r.upWindows),"/",r.eligibleWindows," windows)"]})]}):e.jsx("span",{className:"uptime-tooltip-gap",children:"not deployed"})]},o)})]})}function ea({payload:a}){return a!=null&&a.length?e.jsx("div",{className:"uptime-legend",children:a.map(t=>e.jsxs("span",{className:"uptime-legend-item",children:[e.jsx("span",{className:"uptime-legend-dot",style:{background:t.color}}),t.value]},t.value))}):null}function ta({seriesData:a,loading:t,error:s,onRetry:n}){const i=Array.isArray(a)?a:[],[o,l]=b.useState(!1),r=b.useMemo(()=>Yt(i),[i]),m=b.useMemo(()=>Object.fromEntries(i.map(p=>[p.serial,H(p)])),[i]),c=i.length===0||r.length===0,d=b.useMemo(()=>i.length>0&&i.every(p=>(p.points??[]).every(f=>f.uptimePct==null)),[i]);return e.jsxs("div",{className:"sa-panel","data-testid":"sa-uptime-series-panel",children:[e.jsx("h2",{className:"sa-panel-title",children:"Uptime"}),e.jsx("p",{className:"sa-panel-sub",children:"Share of each block's operating hours it was online and error-free — ready to dispense, per calendar week."}),e.jsx("p",{className:"sa-panel-def","data-testid":"uptime-series-definition",children:"Each week, we count the quarter-hours the block was open for business and deployed, and show the share of them where it checked in with no errors — weeks it was in storage or not yet deployed are left blank rather than scored."}),e.jsxs("button",{type:"button",className:"uptime-how-toggle","aria-expanded":o,onClick:()=>l(p=>!p),children:["How uptime is calculated",e.jsx("span",{className:"uptime-how-chevron","aria-hidden":"true",children:o?" ▲":" ▼"})]}),o&&e.jsx("div",{className:"uptime-how-panel","data-testid":"uptime-how-panel",children:e.jsxs("ul",{children:[e.jsx("li",{children:"Each week is split into 15-minute windows, and only the windows inside the block's operating hours count."}),e.jsxs("li",{children:["A window is ",e.jsx("strong",{children:"up"})," when the block checked in (its regular heartbeat) during it and no error was happening at the time."]}),e.jsxs("li",{children:["Only errors that stop a block dispensing count. ",e.jsx("strong",{children:"Warnings don't count"})," — a warning means it kept working."]}),e.jsxs("li",{children:["An error only counts ",e.jsx("strong",{children:"while it was happening"}),": from when the block reported it until the block reported it fixed. If the block never reported it fixed we stop counting it after 24 hours rather than guessing, so an old fault still sitting open on the Health tab can't drag down this week."]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Uptime = up windows ÷ eligible windows"})," for that week."]}),e.jsxs("li",{children:["Weeks a block was in storage, archived, or not yet deployed have no eligible windows — they show as a ",e.jsx("strong",{children:"gap"}),", never a 0%. A deployed block that simply went silent is a real 0%."]})]})}),e.jsxs(T,{loading:t,error:s,onRetry:n,empty:c,skeleton:"chart",emptyMessage:"No uptime data available for the selected period.",children:[d&&e.jsx("p",{className:"uptime-allgap-note","data-testid":"uptime-all-gap-note",children:"No uptime to plot for this period — none of these blocks were deployed and open during it (in storage, or not yet placed), so there is nothing to score."}),e.jsx("div",{"data-testid":"recharts-uptime-chart","data-chart-rows":JSON.stringify(r),children:e.jsx(A,{width:"100%",height:320,children:e.jsxs(oe,{data:r,margin:{top:8,right:16,left:0,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3",vertical:!1}),e.jsx(_,{dataKey:"weekStart",tick:{fontSize:11},minTickGap:32}),e.jsx(P,{domain:[0,100],tickFormatter:p=>`${p}%`,tick:{fontSize:11}}),e.jsx(I,{content:p=>e.jsx(Qt,{...p,blockNames:m})}),e.jsx(V,{content:ea}),i.map((p,f)=>e.jsx(Z,{type:"monotone",dataKey:p.serial,name:H(p),stroke:ke[f%ke.length],strokeWidth:2,dot:{r:3},activeDot:{r:5},connectNulls:!1},p.serial))]})})}),e.jsx("p",{"data-testid":"uptime-gap-footnote",className:"uptime-gap-footnote",children:"A gap in a line means the block was not deployed / in storage that week and has no uptime data."})]})]})}const we=[{key:"location",label:"Location"},{key:"block",label:"Block"},{key:"slot",label:"Slot"},{key:"operating_model",label:"Model"}];function aa(a){const[t,s]=String(a??"").split("-").map(Number);return!t||!s?a??"":new Date(Date.UTC(t,s-1,1)).toLocaleDateString("en-US",{month:"long",year:"numeric",timeZone:"UTC"})}function sa({isAdmin:a}){const[t,s]=b.useState(null);return b.useEffect(()=>{if(!a)return;let n=!1;return at.getFeedbackSummary().then(i=>{n||s(i)}).catch(()=>{}),()=>{n=!0}},[a]),!a||!t||t.up===0&&t.down===0?null:e.jsxs("div",{className:"sa-kpi sa-kpi--feedback","data-testid":"sa-feedback-tile",children:[e.jsx("span",{className:"sa-kpi-label",children:"Feedback (7 d)"}),e.jsx("span",{className:"sa-kpi-value",children:`👍 ${t.up} · 👎 ${t.down}`}),t.topDownTag&&e.jsx("span",{className:"sa-kpi-sub",children:`Top: ${t.topDownTag}`})]})}function K({label:a,value:t,sub:s,tone:n}){return e.jsxs("div",{className:`sa-kpi${n?` sa-kpi--${n}`:""}`,children:[e.jsx("span",{className:"sa-kpi-label",children:a}),e.jsx("span",{className:"sa-kpi-value",children:t}),s&&e.jsx("span",{className:"sa-kpi-sub",children:s})]})}function na({rows:a,loading:t,error:s,reload:n}){return e.jsxs("div",{className:"sa-panel","data-testid":"sa-tax-panel",children:[e.jsxs("div",{className:"sa-panel-header",children:[e.jsx("h2",{className:"sa-panel-title",children:"Sales tax collected"}),e.jsx("span",{className:"sa-panel-note",children:"By month — held for the state, not revenue"})]}),e.jsx(T,{loading:t,error:s,onRetry:n,empty:a.length===0,emptyMessage:"No sales tax collected in this period.",skeleton:"table",children:e.jsxs("table",{className:"sa-tax-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Month"}),e.jsx("th",{scope:"col",className:"num",children:"Collected"}),e.jsx("th",{scope:"col",className:"num",children:"Sales tax"}),e.jsx("th",{scope:"col",className:"num",children:"Net revenue"}),e.jsx("th",{scope:"col",className:"num",children:"Sales"})]})}),e.jsx("tbody",{children:a.map(i=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:aa(i.month)}),e.jsx("td",{className:"num",children:F(i.collected_cents)}),e.jsx("td",{className:"num sa-tax-amount",children:F(i.tax_cents)}),e.jsx("td",{className:"num",children:F(i.net_cents)}),e.jsx("td",{className:"num",children:O(i.payments_count)})]},i.month))})]})})]})}function ia({revenue:a,salesDay:t,loading:s,errors:n,reload:i,emptyAction:o}){const l=t.map(r=>({date:r.label??r.key,revenue:(r.revenueCents??0)/100,dispenses:r.dispenses??0}));return e.jsxs("div",{className:"sa-panel","data-testid":"sa-revenue-panel",children:[e.jsx("h2",{className:"sa-panel-title",children:"Revenue"}),a&&e.jsxs("div",{className:"sa-kpi-row",children:[e.jsx(K,{label:"Net Revenue",value:F(a.grossCents),sub:e.jsx(gt,{collectedCents:a.collectedCents,taxCents:a.taxCents})}),e.jsx(K,{label:"Paid Dispenses",value:O(a.paidDispenses)}),e.jsx(K,{label:"Free Dispenses",value:O(a.freeDispenses),tone:"neutral"}),e.jsx(K,{label:"Payout Base",value:F(a.payoutBaseCents),tone:"muted"})]}),e.jsx(T,{loading:s.salesDay||s.revenue,error:n.salesDay||n.revenue,onRetry:()=>
1{i.salesDay(),i.revenue()},empty:l.length===0,emptyAction:o,skeleton:"chart",children:e.jsx(A,{width:"100%",height:260,children:e.jsxs(oe,{data:l,margin:{top:8,right:16,left:0,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3",vertical:!1}),e.jsx(_,{dataKey:"date",tick:{fontSize:11},minTickGap:20}),e.jsx(P,{yAxisId:"rev",orientation:"left",tickFormatter:r=>`$${r}`}),e.jsx(P,{yAxisId:"cnt",orientation:"right",allowDecimals:!1}),e.jsx(I,{formatter:(r,m)=>m==="revenue"?[`$${r.toFixed(2)}`,"Revenue"]:[O(r),"Dispenses"]}),e.jsx(V,{}),e.jsx(Z,{yAxisId:"rev",type:"monotone",dataKey:"revenue",stroke:C[0],strokeWidth:2,dot:!1}),e.jsx(Z,{yAxisId:"cnt",type:"monotone",dataKey:"dispenses",stroke:C[1],strokeWidth:1.5,dot:!1,strokeDasharray:"4 2"})]})})})]})}function ra({data:a,dimension:t,onDimension:s,loading:n,errors:i,reload:o,emptyAction:l}){var c;const r=((c=we.find(d=>d.key===t))==null?void 0:c.label)??t,m=a.map((d,p)=>({name:d.label,revenue:(d.revenueCents??0)/100,dispenses:d.dispenses??0,fill:De[d.key]??C[p%C.length]}));return e.jsxs("div",{className:"sa-panel","data-testid":"sa-sales-panel",children:[e.jsxs("div",{className:"sa-panel-header",children:[e.jsxs("h2",{className:"sa-panel-title",children:["Sales by ",r]}),e.jsx("div",{className:"sa-dim-tabs",children:we.map(({key:d,label:p})=>e.jsx("button",{type:"button",className:`sa-dim-tab${t===d?" active":""}`,onClick:()=>s(d),children:p},d))})]}),e.jsxs(T,{loading:n.salesByDim,error:i.salesByDim,onRetry:o.salesByDim,empty:m.length===0,emptyAction:l,skeleton:"chart",children:[e.jsx("div",{className:"sa-sales-table",children:m.map(d=>e.jsxs("div",{className:"sa-sales-row",children:[e.jsx("span",{className:"sa-sales-name",children:d.name}),e.jsx("span",{className:"sa-sales-revenue","data-testid":"sa-sales-revenue-value",children:F(d.revenue*100)}),e.jsx("span",{className:"sa-sales-dispenses","data-testid":"sa-sales-dispenses-value",children:O(d.dispenses)})]},d.name))}),e.jsx(A,{width:"100%",height:260,children:e.jsxs(X,{data:m,margin:{top:8,right:16,left:40,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3",vertical:!1}),e.jsx(_,{dataKey:"name",tick:{fontSize:11},angle:m.length>5?-20:0,textAnchor:m.length>5?"end":"middle",height:m.length>5?56:30}),e.jsx(P,{tickFormatter:d=>`$${d}`}),e.jsx(I,{formatter:d=>[F(d*100),"Revenue"]}),e.jsx(J,{dataKey:"revenue",radius:[4,4,0,0],maxBarSize:56,children:m.map((d,p)=>e.jsx(z,{fill:d.fill},p))})]})})]})]})}function oa({data:a,loading:t,errors:s,reload:n,emptyAction:i}){const o=a.reduce((r,m)=>r+(m.dispenses??0),0),l=a.map(r=>({name:Oe(r.model),value:r.dispenses??0,fill:De[r.model]??C[0]}));return e.jsxs("div",{className:"sa-panel","data-testid":"sa-freepaid-panel",children:[e.jsx("h2",{className:"sa-panel-title",children:"Free vs Paid"}),e.jsx(T,{loading:t.freePaid,error:s.freePaid,onRetry:n.freePaid,empty:l.length===0,emptyAction:i,skeleton:"pie",children:e.jsxs("div",{className:"sa-pie-layout",children:[e.jsx("div",{className:"sa-pie-chart-wrap",children:e.jsx(A,{width:"100%",height:240,children:e.jsxs(Ae,{children:[e.jsx(Ie,{data:l,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:3,dataKey:"value",children:l.map((r,m)=>e.jsx(z,{fill:r.fill},m))}),e.jsx(I,{formatter:r=>[O(r),"Dispenses"]})]})})}),e.jsx("div",{className:"sa-pie-legend",children:l.map(r=>e.jsxs("div",{className:"sa-pie-legend-item",children:[e.jsx("span",{className:"sa-pie-dot",style:{background:r.fill}}),e.jsx("span",{className:"sa-pie-name",children:r.name}),e.jsx("span",{className:"sa-pie-count",children:O(r.value)}),e.jsxs("span",{className:"sa-pie-pct",children:["(",o>0?(r.value/o*100).toFixed(1):0,"%)"]})]},r.name))})]})})]})}function la({inventory:a,loading:t,errors:s,reload:n,emptyAction:i}){const o=a.filter(r=>r.days_remaining!=null&&r.days_remaining<=5).length,l=a.map(r=>({name:st(r),days:r.days_remaining??0,fill:(r.days_remaining??0)<=5?"#dc2626":(r.days_remaining??0)<=14?"#f59e0b":"#10b981"}));return e.jsxs("div",{className:"sa-panel","data-testid":"sa-inventory-panel",children:[e.jsx("h2",{className:"sa-panel-title",children:"Inventory Forecast"}),o>0&&e.jsxs("div",{className:"sa-alert","data-testid":"sa-low-inventory-alert",children:[o," slot",o!==1?"s":""," running low (≤5 days remaining)"]}),e.jsx(T,{loading:t.inventory,error:s.inventory,onRetry:n.inventory,empty:l.length===0,emptyAction:i,skeleton:"chart",children:e.jsx(A,{width:"100%",height:Math.max(200,l.length*36),children:e.jsxs(X,{data:l,layout:"vertical",margin:{top:8,right:24,left:48,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3",horizontal:!1}),e.jsx(_,{type:"number",label:{value:"Days remaining",position:"insideBottom",offset:-2}}),e.jsx(P,{type:"category",dataKey:"name",tick:{fontSize:11},width:130}),e.jsx(I,{formatter:r=>[`${r} days`,"Est. remaining"]}),e.jsx(J,{dataKey:"days",radius:[0,4,4,0],children:l.map((r,m)=>e.jsx(z,{fill:r.fill},m))})]})})})]})}function ca({weather:a,loading:t,errors:s,reload:n,emptyAction:i}){const o=a.find(r=>r.uv_bucket==="unknown"),l=a.filter(r=>r.uv_bucket!=="unknown").map(r=>
1({uv:r.uv_bucket,dispenses:r.dispenses??0}));return e.jsxs("div",{className:"sa-panel","data-testid":"sa-weather-panel",children:[e.jsx("h2",{className:"sa-panel-title",children:"UV vs Dispenses"}),o&&e.jsxs("p",{className:"sa-weather-notice","data-testid":"sa-weather-unknown-notice",children:["UV: collecting data — ",O(o.dispenses)," dispense",o.dispenses!==1?"s":""," occurred before UV readings were available and are excluded from this chart."]}),e.jsx(T,{loading:t.weather,error:s.weather,onRetry:n.weather,empty:l.length===0,emptyAction:i,skeleton:"chart",children:e.jsx(A,{width:"100%",height:240,children:e.jsxs(X,{data:l,margin:{top:8,right:16,left:0,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3",vertical:!1}),e.jsx(_,{dataKey:"uv",tick:{fontSize:11}}),e.jsx(P,{allowDecimals:!1,label:{value:"Dispenses",angle:-90,position:"insideLeft",offset:10}}),e.jsx(I,{formatter:r=>[O(r),"Dispenses"]}),e.jsx(J,{dataKey:"dispenses",fill:C[2],radius:[4,4,0,0],maxBarSize:48})]})})})]})}const da="Uptime is the share of a block's own operating hours it was online, error-free, and ready to take a payment. Time before a block is deployed, while it sits in storage, or outside its operating hours doesn't count against it — it just shows as a gap, not a 0%. A block needs a working check-in roughly every 15 minutes; too many missed check-ins during open hours brings the score down for that period. Only errors that stop a block dispensing count against it — warnings don't count at all, and an error only counts while it was happening, so an old fault left open on the Health tab no longer drags down today's number.";function ga({uptime:a,loading:t,errors:s,reload:n}){const i=(a==null?void 0:a.perBlock)??[],o=(a==null?void 0:a.trend)??[],l=(a==null?void 0:a.summary)??{},r=u=>u==null?"muted":u>=99?"ok":u>=90?"warn":"error",m=u=>u<90?"#dc2626":u<99?"#f59e0b":"#10b981",c=u=>u.has_data??u.uptime_pct!=null,d=i.filter(c),p=i.length-d.length,f=d.map(u=>({name:H(u),uptime:Number(u.uptime_pct),fill:m(Number(u.uptime_pct))})),y=o.map(u=>({day:u.day,uptime:Number(u.avg_uptime)})),[j,k]=b.useState(!1);return e.jsxs("div",{className:"sa-panel","data-testid":"sa-uptime-panel",children:[e.jsx("h2",{className:"sa-panel-title",children:"Uptime"}),e.jsx("p",{className:"sa-panel-sub",children:"Share of each block's operating hours it was online and error-free (could have taken a payment)."}),e.jsxs("button",{type:"button",className:"sa-uptime-def-toggle","aria-expanded":j,onClick:()=>k(u=>!u),children:["How is this calculated?",e.jsx("span",{className:"sa-uptime-def-chevron","aria-hidden":"true",children:j?" ▲":" ▼"})]}),j&&e.jsx("p",{className:"sa-uptime-def-text","data-testid":"sa-uptime-def-text",children:da}),l.avg_uptime!=null&&e.jsxs("div",{className:"sa-kpi-row",children:[e.jsx(K,{label:"Avg Uptime",value:`${l.avg_uptime}%`,tone:r(l.avg_uptime)}),e.jsx(K,{label:"Blocks < 90%",value:l.blocks_below_90??0,tone:(l.blocks_below_90??0)>0?"error":"ok"}),e.jsx(K,{label:"Blocks Tracked",value:l.blocks_with_data??0,tone:"muted"})]}),e.jsxs(T,{loading:t.uptime,error:s.uptime,onRetry:n.uptime,empty:i.length===0,skeleton:"chart",children:[f.length>0&&e.jsx(A,{width:"100%",height:Math.max(200,f.length*36),children:e.jsxs(X,{data:f,layout:"vertical",margin:{top:8,right:24,left:48,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3",horizontal:!1}),e.jsx(_,{type:"number",domain:[0,100],tickFormatter:u=>`${u}%`}),e.jsx(P,{type:"category",dataKey:"name",tick:{fontSize:11},width:90}),e.jsx(I,{formatter:u=>[`${u}%`,"Uptime"]}),e.jsx(J,{dataKey:"uptime",radius:[0,4,4,0],children:f.map((u,v)=>e.jsx(z,{fill:u.fill},v))})]})}),p>0&&e.jsxs("p",{className:"sa-uptime-nodata","data-testid":"sa-uptime-nodata",children:[p===1?"1 block has":`${p} blocks have`," no uptime data yet"," ","(in storage, unassigned, or outside operating hours this period)."]}),y.length>0&&e.jsx(A,{width:"100%",height:220,children:e.jsxs(oe,{data:y,margin:{top:8,right:16,left:0,bottom:8},children:[e.jsx(D,{strokeDasharray:"3 3",vertical:!1}),e.jsx(_,{dataKey:"day",tick:{fontSize:11},minTickGap:20}),e.jsx(P,{domain:[0,100],tickFormatter:u=>`${u}%`}),e.jsx(I,{formatter:u=>[`${u}%`,"Avg uptime"]}),e.jsx(Z,{type:"monotone",dataKey:"uptime",stroke:C[1],strokeWidth:2,dot:!1})]})})]})]})}function ua(a){const t={};return a.get("franchise")&&(t.franchiseId=a.get("franchise")),a.get("partner")&&(t.partnerId=a.get("partner")),a.get("location")&&(t.locationId=a.get("location")),a.get("block")&&(t.serial=a.get("block")),t}function ha(a,t){const s=new URLSearchParams(t);return a.franchiseId?s.set("franchise",a.franchiseId):s.delete("franchise"),a.partnerId?s.set("partner",a.partnerId):s.delete("partner"),a.locationId?s.set("location",a.locationId):s.delete("location"),a.seri
1al?s.set("block",a.serial):s.delete("block"),s}function ka({initialScope:a,initialRange:t}){var k;const{userRole:s}=Se(),[n,i]=b.useState("revenue"),[o,l]=Qe(),r=ua(o),m=Object.keys(r).length>0?r:a??{},c=et({initialScope:m,initialRange:t??{preset:"30d"},skipFilterTree:!1,activeSection:n}),d=b.useCallback(u=>{c.setScope(u),l(ha(u,o),{replace:!0})},[c.setScope,o,l]),p=Object.keys(c.scope??{}).length>0||((k=c.range)==null?void 0:k.preset)!=="30d",f=b.useCallback(()=>{d({}),c.setPreset("30d")},[d,c.setPreset]),y=p?{label:"Reset filters",onClick:f}:void 0,j=[{key:"revenue",label:"Revenue"},{key:"sales",label:"Sales"},{key:"free-paid",label:"Free vs Paid"},{key:"uptime",label:"Uptime"},{key:"inventory",label:"Inventory"},{key:"weather",label:"Weather"},{key:"ask",label:"Ask"}];return e.jsxs("div",{className:"sa-page","data-testid":"scoped-analytics-page",children:[e.jsxs("div",{className:"sa-header",children:[e.jsxs("div",{className:"sa-header-top",children:[e.jsxs("div",{className:"sa-header-text",children:[e.jsx("h1",{className:"sa-title",children:"Analytics"}),e.jsx("p",{className:"sa-subtitle",children:"Sales, uptime, inventory, and weather — scoped to what you manage."})]}),e.jsx(jt,{range:c.range,onPreset:c.setPreset,customRange:c.customRange,onCustomChange:c.setCustomRange,showCustom:c.showCustom,onToggleCustom:()=>c.setShowCustom(u=>!u),onApplyCustom:c.applyCustomRange})]}),e.jsx(Vt,{filterTree:c.filterTree,scope:c.scope,onScopeChange:d,userRole:s??"operator"})]}),e.jsx("div",{className:"sa-tabs",role:"tablist",children:j.map(({key:u,label:v})=>e.jsx("button",{role:"tab",type:"button","aria-selected":n===u,className:`sa-tab${n===u?" active":""}`,onClick:()=>i(u),children:v},u))}),e.jsxs("div",{className:"sa-content",children:[n==="revenue"&&e.jsx(ia,{revenue:c.revenue,salesDay:c.salesDay,loading:c.loading,errors:c.errors,reload:c.reload,emptyAction:y}),n==="revenue"&&e.jsx(sa,{isAdmin:s==="administrator"}),n==="revenue"&&e.jsx(na,{rows:c.taxSummary,loading:c.loading.taxSummary,error:c.errors.taxSummary,reload:c.reload.taxSummary}),n==="sales"&&e.jsx(ra,{data:c.salesByDim,dimension:c.salesDimension,onDimension:c.changeSalesDimension,loading:c.loading,errors:c.errors,reload:c.reload,emptyAction:y}),n==="free-paid"&&e.jsx(oa,{data:c.freePaid,loading:c.loading,errors:c.errors,reload:c.reload,emptyAction:y}),n==="uptime"&&e.jsx(ta,{seriesData:c.uptimeSeries,loading:c.loading.uptimeSeries,error:c.errors.uptimeSeries,onRetry:c.reload.uptimeSeries}),n==="inventory"&&e.jsx(la,{inventory:c.inventory,loading:c.loading,errors:c.errors,reload:c.reload,emptyAction:y}),n==="weather"&&e.jsx(ca,{weather:c.weather,loading:c.loading,errors:c.errors,reload:c.reload,emptyAction:y}),n==="ask"&&e.jsx(Jt,{})]})]})}export{na as TaxSummaryPanel,ga as UptimePanel,ka 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.