"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[7162],{27162:function(e,u,t){t.d(u,{DI:function(){return w},GO:function(){return x},JB:function(){return d},JU:function(){return M},oz:function(){return B},rC:function(){return A}});var r=t(1413),n=t(93433),i=330,a=function(e){return Boolean(e&&String(e.orderid||"").trim())},o=function(e){return Array.isArray(e)?e.filter(a):[]},s=function(e){if(null===e||void 0===e)return null;var u=/(\d{1,2}):(\d{2})(?::(\d{2}))?/.exec(String(e));if(!u)return null;var t=Number(u[1]),r=Number(u[2]);return t>23||r>59?null:60*t+r+Number(u[3]||0)/60},c=function(e){var u=s(e);return null===u?null:Math.round(60*u)},d=function(e){if(null===e||void 0===e||Number.isNaN(e))return"\u2014";var u=Math.round(e),t=Math.floor(u/60)%24,r=u%60;return"".concat(String(t).padStart(2,"0"),":").concat(String(r).padStart(2,"0"))},l=function(e){var u=e.filter((function(e){return"number"===typeof e&&!Number.isNaN(e)})).sort((function(e,u){return e-u}));if(!u.length)return null;var t=Math.floor(u.length/2);return u.length%2?u[t]:(u[t-1]+u[t])/2},D=function(e){for(var u=e;u>720;)u-=1440;for(;u<=-720;)u+=1440;return u},F=["assigntime","starttime","arrivaltime","pickuptime","deliverytime"],f={assigntime:"assign",starttime:"start",arrivaltime:"arrival",pickuptime:"pickup",deliverytime:"delivery"},m=function(e){return null!==e&&void 0!==e&&""!==String(e).trim()},h={rider:["ridername","rider"],charge:["deliverycharges","deliverycharge"],distance:["kms","actualkms"],zone:["deliverysuburb","locationsuburb"],locality:["deliverylocation","deliverysuburb"]},g=function(e,u){for(var t=h[u]||[u],r=0;r1&&void 0!==arguments[1]?arguments[1]:{},t=u.toleranceMin,r=void 0===t?45:t,n=u.minOrders,a=void 0===n?5:n,c=[];o(e).forEach((function(e){var u=s(e.deliverydate),t=s(e.assigntime);null!==u&&null!==t&&c.push(D(t-u))}));var d=l(c);if(null===d||c.length1&&void 0!==arguments[1]?arguments[1]:{},t=u.maxGapSeconds,r=void 0===t?25:t,n=u.minClusterSize,i=void 0===n?4:n,a=o(e).map((function(e){return{orderid:String(e.orderid),seconds:c(e.deliverytime),raw:e.deliverytime}})).filter((function(e){return null!==e.seconds})).sort((function(e,u){return e.seconds-u.seconds})),s=[],d=[],D=function(){if(d.length>=i){var e=d.slice(1).map((function(e,u){return e.seconds-d[u].seconds})),u=d.map((function(e){return e.orderid})),t=u.every((function(e,t){return 0===t||u[t-1]>=e})),r=u.every((function(e,t){return 0===t||u[t-1]<=e}));s.push({count:d.length,orderIds:u,firstStamp:d[0].raw,lastStamp:d[d.length-1].raw,spanSeconds:d[d.length-1].seconds-d[0].seconds,medianGapSeconds:l(e),monotonicByOrderId:t||r})}d=[]};return a.forEach((function(e,u){0===u||e.seconds-a[u-1].seconds<=r?d.push(e):(D(),d=[e])})),D(),s},v=function(e){var u=o(e),t={};F.forEach((function(e){t[e]=u.filter((function(u){return m(u[e])})).length}));var r=F.reduce((function(e,u){return e+t[u]}),0),n=u.length*F.length;return{stages:t,captured:r,expected:n,ratio:n?r/n:0,orderCount:u.length}},E=function(e){var u=[];return o(e).forEach((function(e){for(var t=F.map((function(u){return{stage:u,seconds:m(e[u])?c(e[u]):null}})).filter((function(e){return null!==e.seconds})),r=1;r1&&void 0!==arguments[1]?arguments[1]:0,t=s(e&&e.deliverydate);return null===t?null:(t+u+1440)%1440}(e,t.suggestedShiftMin),r=s(e.assigntime);return null===u||null===r?null:D(r-u)})).filter((function(e){return null!==e}));return{orderCount:u.length,trustworthyDeliveryTimes:d.filter((function(e){return!c.has(String(e.orderid))})).length,deliveryStampCount:d.length,lifecycleRatio:i.ratio,lifecycleCaptured:i.captured,lifecycleExpected:i.expected,medianAssignDelayMin:F.length?Math.round(l(F)):null,totalKm:u.reduce((function(e,u){return e+b(g(u,"distance"))}),0),totalCharge:u.reduce((function(e,u){return e+b(g(u,"charge"))}),0),riders:(0,n.Z)(new Set(u.map((function(e){return String(g(e,"rider")).trim()})).filter(Boolean))),skew:t}},k={blocking:0,high:1,medium:2,low:3},M=function(e){var u=o(e),t=[];if(!u.length)return t;var r=Array.isArray(e)?e.length:0;C(e).forEach((function(e,u){t.push({id:"bulk-close-".concat(u),severity:"blocking",title:"Delivery timestamps were written in bulk, not observed",detail:"".concat(e.count," orders were stamped delivered inside ").concat(e.spanSeconds," seconds")+(null!==e.medianGapSeconds?", a median of ".concat(Math.round(e.medianGapSeconds),"s apart"):"")+(e.monotonicByOrderId?", running in order-ID sequence":"")+". That is a list being cleared, not deliveries happening. No SLA, ETA accuracy or rider productivity figure can be derived from this column.",evidence:["".concat(e.firstStamp," \u2192 ").concat(e.lastStamp),"".concat(e.count," orders, span ").concat(e.spanSeconds,"s")],orderIds:e.orderIds,fix:"Stamp delivery server-side from the rider action, and rate-limit closes per rider per minute."})}));var a=p(e);a.suspected&&t.push({id:"offset-skew",severity:"blocking",title:"Promised slots read exactly one IST offset early",detail:"Across ".concat(a.sampleSize," orders the median gap from promised slot to assignment is ").concat(a.medianDeltaMin," minutes ")+"(spread \xb1".concat(a.spreadMin,"), which is the +05:30 offset itself. The likeliest cause is a UTC clock serialised with an ")+"IST label, so every slot in the console reads five and a half hours early. Confirm against the API before trusting either reading.",evidence:["median assign \u2212 slot = ".concat(a.medianDeltaMin," min"),"IST offset = ".concat(i," min"),"spread \xb1".concat(a.spreadMin," min")],orderIds:u.map((function(e){return String(e.orderid)})),fix:"Serialise as true UTC with Z, or true IST with +05:30 \u2014 and normalise on ingest, before anything reads it."});var s=v(e);if(s.ratio<.9){var c=F.filter((function(e){return s.stages[e]u.length&&t.push({id:"export-artifact",severity:"medium",title:"The row set contains non-order rows",detail:"".concat(r-u.length," row(s) carry no orderid \u2014 the TOTAL row the CSV export appends. Any pipeline reading the file as ")+"records gains phantom orders, with the column sums as their values.",evidence:["".concat(r," rows in, ").concat(u.length," actual orders")],orderIds:[],fix:"Move totals to a footer sheet, or drop rows with no orderid on ingest."});var l=function(e){var u=o(e).map((function(e){return String(g(e,"locality")).trim()})).filter(Boolean),t={};return u.forEach((function(e){var u=e.toLowerCase();t[u]=t[u]||new Set,t[u].add(e)})),{nonLatin:(0,n.Z)(new Set(u.filter(y))),unbalanced:(0,n.Z)(new Set(u.filter(S))),caseVariants:Object.values(t).filter((function(e){return e.size>1})).map((function(e){return(0,n.Z)(e)})),distinct:Object.keys(t).length,total:u.length}}(e),D=[].concat((0,n.Z)(l.nonLatin),(0,n.Z)(l.unbalanced),(0,n.Z)(l.caseVariants.map((function(e){return e.join(" / ")}))));return D.length&&t.push({id:"locality-hygiene",severity:"medium",title:"Locality is free text and does not normalise",detail:"".concat(l.distinct," distinct spellings across ").concat(l.total," orders. Mixed scripts, unbalanced brackets and case variants all appear. ")+"Dispatch buckets zones on this family of fields, so the noise reaches the plan.",evidence:D.slice(0,5),orderIds:o(e).filter((function(e){return D.some((function(u){return u.includes(String(g(e,"locality")).trim())}))})).map((function(e){return String(e.orderid)})),fix:"Resolve localities against a gazetteer at order creation; keep the typed string as a display alias."}),t.sort((function(e,u){return k[e.severity]-k[u.severity]}))},x=function(e){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=B(e);return{meta:(0,r.Z)({generatedAt:(new Date).toISOString()},u),summary:{orders:t.orderCount,riders:t.riders,trustworthyDeliveryTimes:t.trustworthyDeliveryTimes,lifecycleCaptureRatio:Number(t.lifecycleRatio.toFixed(3)),medianAssignDelayMin:t.medianAssignDelayMin,totalKm:t.totalKm,totalCharge:t.totalCharge,timestampsTrustworthy:!t.skew.suspected&&t.trustworthyDeliveryTimes===t.deliveryStampCount},zones:w(e),findings:M(e).map((function(e){return{id:e.id,severity:e.severity,title:e.title,detail:e.detail,evidence:e.evidence,orderCount:e.orderIds.length}})),caveats:["Delivery timestamps flagged by a bulk-close finding must not be used for duration or SLA claims.","Where an offset-skew finding is present, promised slots are ambiguous; state the assumption used.","Rollups over a single day and a single tenant are descriptive, not evidence of a trend."]}}}}]);