PageSourceSearch

https://flipalert.co/_next/static/chunks/3986-9f2e01a6e75a78f9.js

js flipalert.co collected 2026-09-24 14:38:00 UTC 35,259 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3986],{9539:function(e,t,n){n.d(t,{X:function(){return r}});var a=n(80752),s=n(45262),i=n(45867);function r(e){let{options:t,labels:n,counts:r,value:l,onChange:u,label:o}=e,c=(0,s.useRef)(null),[d,m]=(0,s.useState)(null),f=(0,s.useCallback)(()=>{let e=c.current;if(!e)return;let t=e.querySelector('[data-option="'.concat(l,'"]'));if(!t||0===t.offsetWidth)return;let n={left:t.offsetLeft,width:t.offsetWidth};m(e=>(null==e?void 0:e.left)===n.left&&e.width===n.width?e:n)},[l]);return(0,s.useEffect)(()=>{f();let e=requestAnimationFrame(f);return()=>cancelAnimationFrame(e)},[f]),(0,s.useEffect)(()=>(window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)),[f]),(0,s.useEffect)(()=>{let e=c.current;if(!e||"undefined"==typeof ResizeObserver)return;let t=new ResizeObserver(f);return t.observe(e),e.querySelectorAll("button").forEach(e=>t.observe(e)),()=>t.disconnect()},[f]),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[o&&(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:o}),(0,a.jsxs)("div",{ref:c,className:"relative flex items-center rounded-full bg-muted/50 p-0.5",children:[d&&(0,a.jsx)("div",{className:"absolute rounded-full bg-primary transition-all duration-300 ease-out",style:{left:d.left,width:d.width,top:2,bottom:2}}),t.map(e=>{var t;return(0,a.jsxs)("button",{"data-option":e,type:"button","aria-pressed":l===e,onClick:()=>u(e),className:(0,i.cn)("relative z-10 flex h-6 shrink-0 items-center justify-center whitespace-nowrap rounded-full px-3 text-xs font-medium transition-colors",l===e?"text-primary-foreground":"text-muted-foreground hover:text-foreground"),children:[null!==(t=null==n?void 0:n[e])&&void 0!==t?t:e,(null==r?void 0:r[e])!=null&&(0,a.jsx)("span",{className:"tabular-nums ml-1 opacity-80",children:r[e]})]},e)})]})]})}},80511:function(e,t,n){n.d(t,{b:function(){return r}});var a=n(80752),s=n(71900),i=n(45867);function r(e){let{id:t,value:n,onChange:r,disabled:l=!1,placeholder:u="Select date",buttonClassName:o,align:c="start",modal:d=!1}=e;return(0,a.jsx)(s.b,{id:t,value:n,onChange:r,disabled:l,placeholder:u,buttonClassName:(0,i.cn)("h-7 px-1.5 text-sm",o),iconClassName:"mr-1.5 size-3.5",align:c,modal:d,variant:"ghost",clearable:!0,stopPropagation:!0})}},70032:function(e,t,n){n.d(t,{f:function(){return K}});var a=n(80752),s=n(45262),i=n(71997),r=n(12237),l=n(94141),u=n(87929),o=n(50850),c=n(58714),d=n(72418),m=n(35495),f=n(33689),p=n(27365),x=n(41190),h=n(64396),b=n(79357),g=n(99270),y=n(70488),v=n(82185),j=n(1531),N=n(49129),w=n(33887),_=n(16560),S=n(9539),k=n(28940),C=n(68303),z=n(53184),q=n(45867);function D(e){var t;let{open:n,onOpenChange:i,lot:r,busy:l=!1,onSubmit:u}=e,c=null!==(t=null==r?void 0:r.initial_quantity)&&void 0!==t?t:0,[d,f]=(0,s.useState)(["0"]);(0,s.useEffect)(()=>{n&&f(function(e){if(e<=1)return[String(Math.max(e,0))];let t=Math.floor(e/2);return[String(t),String(e-t)]}(c))},[n,c]);let p=d.map(e=>Number(e)),h=p.reduce((e,t)=>e+(Number.isFinite(t)?t:0),0),b=p.every(e=>Number.isInteger(e)&&e>=1),g=d.length>=2&&b&&h===c&&c>=2;async function y(e){e.preventDefault(),g&&await u(p)}return(0,a.jsx)(k.Vq,{open:n,onOpenChange:i,children:(0,a.jsx)(k.cZ,{className:"max-w-[480px]",children:(0,a.jsxs)("form",{onSubmit:y,className:"space-y-4",children:[(0,a.jsx)(k.fK,{children:(0,a.jsx)(k.$N,{children:"Split lot"})}),r&&(0,a.jsxs)("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,a.jsx)("div",{className:"font-medium",children:r.display_name||r.sku}),(0,a.jsxs)("div",{className:"text-muted-foreground",children:["Lot quantity:"," ",(0,a.jsx)("span",{className:"font-semibold tabular-nums text-foreground",children:c.toLocaleString("en-US")})," ","units"]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)(z._,{children:["Resulting lots (quantities must total ",c.toLocaleString("en-US"),")"]}),d.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(C.I,{type:"text",inputMode:"numeric",value:e,onChange:e=>(function(e,t){let n=t.replace(/[^\d]/g,"");f(t=>t.map((t,a)=>a===e?n:t))})(t,e.target.value),className:"h-9 w-32 tabular-nums","aria-label":"Lot ".concat(t+1," quantity")}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"units"}),(0,a.jsx)(x.z,{type:"button",variant:"ghost",size:"icon",className:"ml-auto h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{f(e=>
1e.length<=1?e:e.filter((e,n)=>n!==t))},disabled:d.length<=2,"aria-label":"Remove lot ".concat(t+1),children:(0,a.jsx)(m.Z,{className:"size-3.5"})})]},t)),(0,a.jsxs)(x.z,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:function(){f(e=>[...e,"0"])},children:[(0,a.jsx)(o.Z,{className:"size-3.5"})," Add lot"]})]}),(0,a.jsxs)("div",{className:(0,q.cn)("text-xs",h===c?"text-muted-foreground":"text-destructive"),children:["Total: ",h.toLocaleString("en-US")," / ",c.toLocaleString("en-US"),h!==c&&" \xb7 parts must total the lot quantity"]}),(0,a.jsxs)(k.cN,{children:[(0,a.jsx)(x.z,{type:"button",variant:"outline",onClick:()=>i(!1),disabled:l,children:"Cancel"}),(0,a.jsx)(x.z,{type:"submit",disabled:!g||l,children:l?"Splitting...":"Split lot"})]})]})})})}var E=n(80511),$=n(76531);function A(e){let t=e.trim();return t.length>0?t:null}function L(e){let{open:t,onOpenChange:n,mode:i,sku:r,asin:l,lot:u,busy:o=!1,onSubmit:c}=e,[d,m]=(0,s.useState)(""),[f,p]=(0,s.useState)(""),[h,b]=(0,s.useState)(""),[g,y]=(0,s.use
1State)("0");(0,s.useEffect)(()=>{var e,n;t&&(m((null==u?void 0:u.unit_cost)==null?"":String(u.unit_cost)),p(null!==(e=null==u?void 0:u.supplier)&&void 0!==e?e:""),b((n=null==u?void 0:u.purchase_date)?n.slice(0,10):""),y((null==u?void 0:u.initial_quantity)==null?"0":String(u.initial_quantity)))},[t,u]);let v=Number(g),j="edit"===i||Number.isInteger(v)&&v>=1;async function N(e){if(e.preventDefault(),!j)return;let t={unit_cost:function(e){if(""===e.trim())return null;let t=Number(e);return Number.isFinite(t)?t:null}(d),supplier:A(f),purchase_date:A(h)};if("create"===i){await c({...t,sku:r,asin:null!=l?l:null,initial_quantity:v,estimated_quantity:!1});return}await c(t)}return(0,a.jsx)(k.Vq,{open:t,onOpenChange:n,children:(0,a.jsx)(k.cZ,{className:"max-w-[560px]",children:(0,a.jsxs)("form",{onSubmit:N,className:"space-y-4",children:[(0,a.jsx)(k.fK,{children:(0,a.jsx)(k.$N,{children:"create"===i?"Add lot":"Edit lot"})}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(z._,{htmlFor:"replenishment-unit-cost",children:"Unit cost"}),(0,a.jsx)(C.I,{id:"replenishment-unit-cost",type:"number",inputMode:"decimal",min:"0",step:"0.01",value:d,onChange:e=>m(e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(z._,{htmlFor:"replenishment-supplier",children:"Supplier"}),(0,a.jsx)($.e,{id:"replenishment-supplier",value:f||null,onChange:e=>p(null!=e?e:""),placeholder:"Add supplier",modal:!0,disabled:o,showEditIcon:!0,missingTone:"neutral",triggerClassName:"h-10 w-full rounded-md border-input bg-background px-3 py-2 text-foreground hover:border-input"})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(z._,{htmlFor:"replenishment-purchase-date",children:"Purchase date"}),(0,a.jsx)(E.b,{id:"replenishment-purchase-date",value:h||null,onChange:e=>b(null!=e?e:""),modal:!0,buttonClassName:"h-10 w-full justify-start rounded-md border border-input bg-background px-3 text-left hover:bg-background"})]}),"create"===i&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(z._,{htmlFor:"replenishment-initial-quantity",children:"Initial quantity"}),(0,a.jsx)(C.I,{id:"replenishment-initial-quantity",type:"number",inputMode:"numeric",min:"1",step:"1",value:g,onChange:e=>y(e.target.value),required:!0})]})]}),(0,a.jsxs)(k.cN,{children:[(0,a.jsx)(x.z,{type:"button",variant:"outline",onClick:()=>n(!1),disabled:o,children:"Cancel"}),(0,a.jsx)(x.z,{type:"submit",disabled:!j||o,children:o?"Saving...":"Save"})]})]})})})}let Q={estimated_initial_quantity:"Estimated initial quantity",missing_unit_cost:"Missing unit cost",missing_replenishment:"Missing lot coverage",purchase_date_missing:"Purchase date missing"},F={missing_replenishment:"These units are not covered by the recorded lots. Add the missing purchase lots before setting their costs."};function M(e){return e.toLocaleString("en-US")}function P(e){let{lot:t,disabled:n,onSave:i}=e,[r,l]=(0,s.useState)(!1);async function u(e){var n,a;if(!r&&e!==(null!==(a=null===(n=t.purchase_date)||void 0===n?void 0:n.slice(0,10))&&void 0!==a?a:null)){l(!0);try{await i(t.id,{purchase_date:e})}finally{l(!1)}}}return(0,a.jsx)(E.b,{value:t.purchase_date,onChange:u,disabled:n||r,placeholder:"-",buttonClassName:"h-7 px-1 text-xs"})}function R(e){let{lot:t,disabled:n,onSave:s}=e;return(0,a.jsx)($.e,{value:t.supplier,disabled:n,placeholder:"Add supplier",missingTone:"neutral",triggerClassName:"h-7 max-w-[180px] px-1 text-xs",showEditIcon:!0,onChange:e=>s(t.id,{supplier:e})})}function K(e){var t,n,k,C,z;let{listingId:q,sku:E,asin:$=null,presentation:A="row",focusedLotIds:K=[],missingReplenishmentUnits:T=0}=e,I=null!==(k=null==q?void 0:q.trim())&&void 0!==k?k:"",O=E.trim(),Z=I||(O?"sku:".concat(O):""),U=(0,i.NL)(),{toast:Y}=(0,N.pm)(),[X,V]=(0,s.useState)(null),[B,J]=(0,s.useState)(null),[W,G]=(0,s.useState)(null),[H,ee]=(0,s.useState)(null),[et,en]=(0,s.useState)("all"),ea=Z.length>0,es=(0,r.a)({queryKey:(0,_.zy)(Z),queryFn:()=>(0,w.Ln)(I,O),enabled:ea}),ei=()=>{V(null),J(null)},er=(0,l.D)({mutationFn:e=>(0,w.BV)(I,e),onSuccess:()=>{ei(),(0,_.hS)(U,Z),Y({description:"Lot added"})},onError:()=>{Y({description:"Could not add lot. Refresh the page and try again.",variant:"destructive"})}}),el=(0,l.D)({mutationFn:e=>{let{lotId:t,body:n}=e;return(0,w.G2)(t,n)},onMutate:async e=>{let{lotId:t,body:n}=e,a=(0,_.zy)(Z);await U.cancelQueries({queryKey:a});let s=U.getQueryData(a);return U.setQueryData(a,e=>e?function(e,t,n,a){let s=e.lots.map(e=>{var a,s,i;return e.id!==t?e:{...e,...Object.prototype.hasOwnProperty.call(n,"unit_cost")?{unit_cost:null!==(a=n.unit_cost)&&void 0!==a?a:null}:{},...Object.prototype.hasOwnProperty.call(n,"supplier")?{supplier:null!==(s=n.supplier)&&void 0!==s?s:null}:{},...Object.prototype.hasOwnProperty.call(n,"purchase_date")?{purchase_date:null!==(i=n.purchase_date)&&void 0!==i?i:null}:{}}}),i=s.reduce((e,t)=>
1e+(null==t.unit_cost?Math.max(0,t.remaining_quantity):0),0),r=e.summary.alerts.filter(e=>"missing_unit_cost"!==e&&"missing_replenishment"!==e);return i>0&&r.push("missing_unit_cost"),a>0&&r.push("missing_replenishment"),{...e,lots:s,summary:{...e.summary,missing_unit_cost_units:i,missing_replenishment_units:a,alerts:r}}}(e,t,n,T):e),{previous:s}},onSuccess:()=>{ei(),Y({description:"Lot updated"})},onError:(e,t,n)=>{(null==n?void 0:n.previous)&&U.setQueryData((0,_.zy)(Z),n.previous),Y({description:"Could not update lot. Refresh the page and try again.",variant:"destructive"})},onSettled:()=>{(0,_.hS)(U,Z)}}),eu=(0,l.D)({mutationFn:e=>(0,w.SA)(e),onSuccess:()=>{G(null),(0,_.hS)(U,Z),Y({description:"Lot deleted"})},onError:()=>{Y({description:"Could not delete lot. Refresh the page and try again.",variant:"destructive"})}}),eo=(0,l.D)({mutationFn:e=>{let{lotId:t,parts:n}=e;return(0,w.IR)(t,n)},onSuccess:()=>{ee(null),(0,_.hS)(U,Z),Y({description:"Lot split"})},onError:()=>{Y({description:"Could not split lot. Refresh the page and try again.",variant:"destructive"})}}),ec=new Set(K),ed=[...null!==(C=null===(t=es.data)||void 0===t?void 0:t.lots)&&void 0!==C?C:[]].sort((e,t)=>{let n=ec.has(e.id);return n===ec.has(t.id)?0:n?-1:1}),em={all:ed.length,missing_cost:ed.filter(e=>null==e.unit_cost).length},ef=ed.filter(e=>"missing_cost"!==et||null==e.unit_cost),ep=new Set(null!==(z=null===(n=es.data)||void 0===n?void 0:n.summary.alerts)&&void 0!==z?z:[]);ep.delete("missing_unit_cost"),T>0&&ep.add("missing_replenishment");let ex=[...ep].map(e=>({status:e,label:Q[e]})).filter(e=>!!e.label),eh=er.isPending||el.isPending||eu.isPending||eo.isPending,eb=()=>{J(null),V("create")};return(0,a.jsxs)("div",{className:"row"===A?"border-y bg-muted/20 p-3":"pt-2",children:[(0,a.jsxs)("div",{className:"row"===A?"overflow-hidden rounded-md border bg-background shadow-sm":"overflow-hidden rounded-md border bg-background",children:[(0,a.jsxs)("div",{className:"flex min-h-11 flex-wrap items-center justify-between gap-2 border-b px-3 py-2",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-semibold",children:"Lots"}),(0,a.jsx)("span",{className:"text-xs tabular-nums text-muted-foreground",children:M(em.all)}),(es.isFetching||eh)&&(0,a.jsx)(y.Spinner,{className:"size-3.5 text-muted-foreground"}),(0,a.jsx)(j.pn,{delayDuration:150,children:ex.map(e=>{var t,n,s,i;let r="missing_replenishment"===e.status?Math.max(null!==(n=null===(t=es.data)||void 0===t?void 0:t.summary.missing_replenishment_units)&&void 0!==n?n:0,T):0,l="missing_replenishment"===e.status&&r>0?function(e){let t=1===e,n=M(e);return{label:"".concat(n," unallocated ").concat(t?"unit":"units"),explanation:"Amazon reports ".concat(n," active ").concat(t?"unit that is":"units that are"," not covered by your recorded purchase lots. Add a lot or increase ").concat(t?"its":"a lot's"," purchase quantity to allocate ").concat(t?"it":"them",".")}}(r):null,o=null!==(s=null==l?void 0:l.label)&&void 0!==s?s:e.label,c=null!==(i=null==l?void 0:l.explanation)&&void 0!==i?i:F[e.status];return(0,a.jsxs)(p.C,{variant:"outline",className:"inline-flex h-6 items-center gap-1 rounded-md border-amber-300 bg-amber-50 px-1.5 py-0 text-xs font-medium text-amber-900 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-200",children:[(0,a.jsx)("span",{children:o}),c?(0,a.jsxs)(j.u,{children:[(0,a.jsx)(j.aJ,{asChild:!0,children:(0,a.jsx)("button",{type:"button",className:"inline-flex size-4 items-center justify-center rounded-full focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-amber-500","aria-label":"".concat(e.label," details"),children:(0,a.jsx)(u.Z,{className:"size-3"})})}),(0,a.jsx)(j._v,{className:"max-w-72 text-xs font-normal leading-relaxed",children:c})]}):null]},e.status)})})]}),(0,a.jsxs)(x.z,{type:"button",size:"compact",onClick:eb,disabled:!ea||eh,children:[(0,a.jsx)(o.Z,{}),"Add lot"]})]}),ea&&!es.isError?(0,a.jsx)("div",{className:"flex items-center border-b px-3 py-2",children:(0,a.jsx)(S.X,{options:["all","missing_cost"],labels:{all:"All",missing_cost:"Need cost"},counts:em,value:et,onChange:en})}):null,ea?es.isError?(0,a.jsxs)("div",{className:"flex min-h-24 items-center justify-between gap-3 px-4",children:[(0,a.jsx)("span",{className:"text-sm text-destructive",children:"Lots unavailable"}),(0,a.jsx)(x.z,{type:"button",size:"compact",variant:"outline",onClick:()=>void es.refetch(),children:"Retry"})]}):(0,a.jsx)("div",{className:"max-h-[520px] overflow-auto",children:(0,a.jsx)(j.pn,{delayDuration:150,children:(0,a.jsxs)(v.iA,{className:"min-w-[1060px] w-full table-fixed",children:[(0,a.jsx)(b.Qt,{className:"sticky top-0 z-10 backdrop-blur-sm",children:(0,a.jsxs)(v.SC,{className:"hover:bg-transparent",children:[(0,a.jsx)(b.YT,{className:"w-[22%]",children:"Lot"}),(0,a.jsx)(b.YT,{className:"w-[13%] whitespace-nowrap",children:"Unit cost"}),(0,a.jsx)(b.YT,{className:"w-[17%]",children:"Supplier"}),(0,a.jsx)(b.YT,{className:"w-[15%] whitespace-nowrap",children:"Purchase date"}),(0,a.jsx)(b.YT,{className:"w-[9%] whitespace-nowrap text-right",children:"Initial"}),(0,a.jsx)(b.YT,{className:"w-[10%] whitespace-nowrap text-right",children:"Remaining"}),(0,a.jsx)(b.YT,{className:"w-[8%] whitespace-nowrap",children:"Estimated"}),(0,a.jsx)(b.YT,{className:"w-[112px]",children:(0,a.jsx)("span",{className:"sr-only",children:"Actions"})})]})}),(0,a.jsxs)(v.RM,{children:[es.isLoading?Array.from({length:5}).map((e,t)=>(0,a.jsx)(v.SC,{children:Array.from({length:8}).map((e,t)=>(0,a.jsx)(b.X4,{className:"h-12 py-2",children:(0,a.jsx)(g.O,{className:"h-4 w-full max-w-28"})},t))},"skeleton-".concat(t))):null,es.isLoading||0!==ed.length?null:(0,a.jsx)(v.SC,{children:(0,a.jsx)(b.X4,{colSpan:8,className:"h-24 text-center",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-2 text-sm text-muted-foreground",children:[(0,a.jsx)("span",{children:"No lots yet"}),(0,a.jsxs)(x.z,{type:"button",size:"compact",variant:"outline",onClick:eb,children:[(0,a.jsx)(o.Z,{}),"Add lot"]})]})})}),!es.isLoading&&ed.length>0&&0===ef.length?(0,a.jsx)(v.SC,{children:(0,a.jsx)(b.X4,{colSpan:8,className:"h-24 text-center",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-1.5 text-sm text-muted-foreground",children:[(0,a.jsx)("span",{children:"No lots match this filter"}),(0,a.jsx)(x.z,{type:"button",size:"compact",variant:"ghost",onClick:()=>en("all"),children:"Show all"})]})})}):null,es.isLoading?null:ef.map(e=>
1{let t=e.display_name||"Unnamed lot",n=eh||!1===e.can_split||e.initial_quantity<=1,s=e.remaining_quantity!==e.initial_quantity?"Partially used lots cannot be split":e.initial_quantity<=1?"This lot has only one unit":"Only unused manual lots can be split";return(0,a.jsxs)(v.SC,{className:"hover:bg-muted/30",children:[(0,a.jsxs)(b.X4,{className:"min-w-0 align-top",children:[(0,a.jsxs)(j.u,{children:[(0,a.jsx)(j.aJ,{asChild:!0,children:(0,a.jsx)("span",{className:"block truncate text-sm font-medium","aria-label":t,children:t})}),(0,a.jsx)(j._v,{children:t})]}),(0,a.jsx)("div",{className:"text-xs uppercase text-muted-foreground",children:e.lot_type}),ec.has(e.id)?(0,a.jsx)(p.C,{variant:"secondary",className:"mt-1 rounded-sm px-1.5 py-0 text-xs",children:"Allocated to this order"}):null]}),(0,a.jsx)(b.X4,{className:"tabular-nums",children:(0,a.jsx)(h._,{fnsku:e.id,currentCost:e.unit_cost,disabled:eh,allowClear:!0,unsetLabel:"Set cost",inputClassName:"h-7 w-24 px-2 text-xs tabular-nums",onSave:(e,t)=>{el.mutate({lotId:e,body:{unit_cost:t}})}})}),(0,a.jsx)(b.X4,{className:"min-w-0",children:(0,a.jsx)(R,{lot:e,disabled:eh,onSave:(e,t)=>el.mutate({lotId:e,body:t})})}),(0,a.jsx)(b.X4,{className:"tabular-nums",children:(0,a.jsx)(P,{lot:e,disabled:eh,onSave:(e,t)=>el.mutate({lotId:e,body:t})})}),(0,a.jsx)(b.X4,{className:"text-right tabular-nums",children:M(e.initial_quantity)}),(0,a.jsx)(b.X4,{className:"text-right tabular-nums",children:(0,a.jsx)("span",{className:e.remaining_quantity<0?"font-semibold text-amber-700 dark:text-amber-300":void 0,children:M(e.remaining_quantity)})}),(0,a.jsx)(b.X4,{children:e.estimated_quantity?(0,a.jsx)(p.C,{variant:"secondary",className:"rounded-sm px-1.5 py-0 text-xs",children:"Estimated"}):(0,a.jsx)("span",{className:"font-normal text-muted-foreground",children:"—"})}),(0,a.jsx)(b.X4,{className:"text-right",children:(0,a.jsxs)("div",{className:"flex items-center justify-end gap-0.5",children:[(0,a.jsx)(x.z,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",disabled:eh,onClick:()=>{J(e),V("edit")},"aria-label":"Edit lot ".concat(t),title:"Edit lot",children:(0,a.jsx)(c.Z,{className:"size-4"})}),(0,a.jsx)(x.z,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",disabled:n,onClick:()=>ee(e),"aria-label":"Split lot ".concat(t),title:n?s:"Split lot",children:(0,a.jsx)(d.Z,{className:"size-4"})}),(0,a.jsx)(x.z,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",disabled:eh||!1===e.can_delete,onClick:()=>G(e),"aria-label":"Delete lot ".concat(t),title:"Delete lot",children:(0,a.jsx)(m.Z,{className:"size-4"})})]})})]},e.id)})]})]})})}):(0,a.jsx)("div",{className:"flex min-h-24 items-center px-4 text-sm text-muted-foreground",children:"Listing information is unavailable."})]}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(L,{open:null!==X,onOpenChange:e=>{e||ei()},mode:null!=X?X:"create",sku:O,asin:$,lot:B,busy:er.isPending||el.isPending,onSubmit:async e=>{if("edit"===X&&B){await el.mutateAsync({lotId:B.id,body:e});return}await er.mutateAsync(e)}}),(0,a.jsx)(D,{open:null!==H,onOpenChange:e=>{e||ee(null)},lot:H,busy:eo.isPending,onSubmit:async e=>{H&&await eo.mutateAsync({lotId:H.id,parts:e})}}),(0,a.jsx)(f.aR,{open:null!==W,onOpenChange:e=>{e||G(null)},children:(0,a.jsxs)(f._T,{children:[(0,a.jsxs)(f.fY,{children:[(0,a.jsx)(f.f$,{children:"Delete lot?"}),(0,a.jsx)(f.yT,{children:"This lot will be removed from cost allocation."})]}),(0,a.jsxs)(f.xo,{children:[(0,a.jsx)(f.le,{disabled:eu.isPending,children:"Cancel"}),(0,a.jsx)(f.OL,{disabled:eu.isPending,onClick:e=>{e.preventDefault(),W&&eu.mutate(W.id)},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})]})}},16560:function(e,t,n){n.d(t,{hS:function(){return m},wA:function(){return f},zy:function(){return c}});var a=n(71997),s=n(94141),i=n(49129),r=n(81356),l=n(91630),u=n(33887);let o=["catalog-analytics","data"],c=e=>["inventory","lots",e];function d(e){return e.fnsku||e.msku}function m(e,t){e.invalidateQueries({queryKey:["catalog-analytics"]}
1),e.invalidateQueries({queryKey:["catalog-analytics-profitability-list"]}),e.invalidateQueries({queryKey:["catalog-analytics-pl"]}),e.invalidateQueries({queryKey:["catalog-analytics-profit-loss"]}),e.invalidateQueries({queryKey:["catalog-analytics-sales-log"]}),e.invalidateQueries({queryKey:["inventory-valuation"]}),e.invalidateQueries({queryKey:["catalog-suppliers-in-use"]}),t&&e.invalidateQueries({queryKey:c(t)})}function f(){let e=(0,a.NL)(),{toast:t}=(0,i.pm)();return{supplierMutation:(0,s.D)({mutationFn:async e=>(0,u.AZ)(e.sku,e.supplier),onMutate:async t=>{await e.cancelQueries({queryKey:o});let n=e.getQueriesData({queryKey:o});return e.setQueriesData({queryKey:o},e=>{if(!e)return e;let n=e.rows.map(e=>d(e)===t.rowId?{...e,supplier_user_input:t.supplier}:e);return{...e,rows:n,stats:p(n)}}),{snapshot:n}},onError:(n,a,s)=>{null==s||s.snapshot.forEach(t=>{let[n,a]=t;e.setQueryData(n,a)}),t({title:"Unable to update supplier",description:"Try again. If the problem persists, refresh the page.",variant:"destructive"})},onSuccess:()=>{t({description:"Supplier updated",duration:r.QE})},onSettled:()=>{m(e)}}),costMutation:(0,s.D)({mutationFn:async e=>{var t;return(0,l.B0)(e.sku,null!==(t=e.newCost)&&void 0!==t?t:0)},onMutate:async t=>{await e.cancelQueries({queryKey:o});let n=e.getQueriesData({queryKey:o});return e.setQueriesData({queryKey:o},e=>{if(!e)return e;let n=e.rows.map(e=>d(e)===t.rowId?{...e,unit_cost:t.newCost}:e);return{...e,rows:n,stats:p(n)}}),{snapshot:n}},onError:(n,a,s)=>{null==s||s.snapshot.forEach(t=>{let[n,a]=t;e.setQueryData(n,a)}),t({title:"Unable to update unit cost",description:"Try again. If the problem persists, refresh the page.",variant:"destructive"})},onSuccess:()=>{t({description:"Unit cost updated",duration:r.QE})},onSettled:()=>{m(e)}}),bulkSupplierMutation:(0,s.D)({mutationFn:async e=>(0,u.v4)(e.skus,e.supplier),onMutate:async t=>{await e.cancelQueries({queryKey:o});let n=e.getQueriesData({queryKey:o}),a=new Set(t.rowIds);return e.setQueriesData({queryKey:o},e=>{if(!e)return e;let n=e.rows.map(e=>a.has(d(e))?{...e,supplier_user_input:t.supplier}:e);return{...e,rows:n,stats:p(n)}}),{snapshot:n}},onError:(n,a,s)=>{null==s||s.snapshot.forEach(t=>{let[n,a]=t;e.setQueryData(n,a)}),t({title:"Bulk supplier update failed",description:"No SKU was updated. Try again.",variant:"destructive"})},onSuccess:e=>{t({description:"".concat(e.updated," SKUs updated"),duration:r.QE})},onSettled:()=>{m(e)}})}}function p(e){return{total:e.length,active:e.filter(e=>e.is_active).length,missing_supplier:e.filter(e=>!e.supplier_user_input).length,missing_cost:e.filter(e=>null==e.unit_cost).length}}},91630:function(e,t,n){n.d(t,{$P:function(){return d},B0:function(){return u},E_:function(){return s},Ec:function(){return v},Gy:function(){return C},Ik:function(){return k},K$:function(){return l},Nq:function(){return m},PP:function(){return p},WX:function(){return f},WY:function(){return b},ZP:function(){return c},_W:function(){return z},_v:function(){return g},au:function(){return i},eF:function(){return r},eM:function(){return _},g2:function(){return S},hj:function(){return j},j9:function(){return x},o7:function(){return y},pc:function(){return N},qe:function(){return o},xB:function(){return w},zN:function(){return h}}),n(74058);var a=n(86978),s=(0,a.$)("341b8693e0d4b65148b3c81687eeaf29c4494d80"),i=(0,a.$)("36e5a8ac523a00b52fa0b956fa40e374a5bfd25b");(0,a.$)("f0e4b6ac7927f4b0838322b9da41bf005631ba12");var r=(0,a.$)("f3f442e400c8d91d129e7327a19ddd1d72975e1f"),l=(0,a.$)("e235e0eeccee61f6a07f37c4f919218a41968d08"),u=(0,a.$)("8a647ce89d9897a6dba59fc44b93adb94b629e4e"),o=(0,a.$)("640899c926b5b0f15080e8f134c791dbd1ac22db"),c=(0,a.$)("49d41aa28163d838faf6853d7eade1d0ad590e84"),d=(0,a.$)("14cafd5bf74b4f78d629b7bc6a5b5f83e9d3bed0"),m=(0,a.$)("f40890d382e9b4949222e3453090a6bc5229fe6a"),f=(0,a.$)("f6cc402b4c6f833b1fa231d8ac78006fb57ff7ab"),p=(0,a.$)("7a720fd4cec0f8e982e20cd2098fba0de56b5026"),x=(0,a.$)("3e80ed8c7ac730df73b5970039d87f8ec043b75c");(0,a.$)("3efd145e426ad30bd0604821dffb7a9f34c2369b"),(0,a.$)("f67ef9f5cacb7a46d24d88cfc4db5df77143adff");var h=(0,a.$)("ba8d437512e01bedc1b07556f33674520a985695"),b=(0,a.$)("d434fad2e5026cd160a914d3066c58322937b55b"),g=(0,a.$)("4c98c7c7ee3d1eacecc9d4859df9e30f5f493ff1"),y=(0,a.$)("9ac7c48bd3c4b5b728c31d9c25ae59e4f85f8968"),v=(0,a.$)("81ac3a8da3853d6f88e489777c6e326e03d1a30a"),j=(0,a.$)("c0f1647560ac0fd2c939ecb417576209125bc76e"),N=(0,a.$)("36ffe0682aa0a80152a0787434dc25a80e7979dd"),w=(0,a.$)("11d973fa1b6821b18f6701ff0115062d7cd55924");(0,a.$)("6f6c0ccda350b1f375317a5ebb17c8d37404a7ee"),(0,a.$)("9882ada2ffad8dcb321c34cec1759470aed02444"),(0,a.$)("9cf3175cadb46206456a046e4e641b9658cb0e81");var _=(0,a.$)("d302ce1c3a9d44c70cb39d9378484e243ef97b9e"),S=(0,a.$)("dd35c47f5a8a813eede561f0f2d40cfb1bf396eb"),k=(0,a.$)("4cc33bbb3e7629e9deea0b876af3139028596a3c"),C=(0,a.$)("d1a096f5f2193c1b79b56e7ee8cd0936b3691446"),z=(0,a.$)("2124d57769f1ea1c26f319b202c7b1e1f1687cff")}
1,89663:function(e,t,n){n.d(t,{_:function(){return s},z:function(){return i}});let a=/^(\d{4})-(\d{2})-(\d{2})(?:$|T)/;function s(e){if(!e)return;let t=a.exec(e);if(!t)return;let n=Number(t[1]),s=Number(t[2])-1,i=Number(t[3]),r=new Date(n,s,i);return r.getFullYear()===n&&r.getMonth()===s&&r.getDate()===i?r:void 0}function i(e){if(Number.isNaN(e.getTime()))throw RangeError("Invalid calendar date");let t=String(e.getFullYear()).padStart(4,"0"),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(n,"-").concat(a)}},71900:function(e,t,n){n.d(t,{b:function(){return m}});var a=n(80752),s=n(45262),i=n(21272),r=n(2225),l=n(41190),u=n(17296),o=n(96123),c=n(45867),d=n(89663);function m(e){let{id:t,value:n,onChange:m,disabled:f=!1,placeholder:p="Select date",buttonClassName:x,iconClassName:h,align:b="start",modal:g=!1,variant:y="outline",clearable:v=!1,minDate:j,stopPropagation:N=!1}=e,[w,_]=(0,s.useState)(!1),S=(0,d._)(n),k=(0,d._)(j),C=e=>{N&&e.stopPropagation()};return(0,a.jsxs)(o.J2,{open:w,onOpenChange:_,modal:g,children:[(0,a.jsx)(o.xo,{asChild:!0,children:(0,a.jsxs)(l.z,{id:t,type:"button",variant:y,disabled:f,onClick:C,className:(0,c.cn)("justify-start text-left font-normal tabular-nums",!S&&"text-muted-foreground",x),children:[(0,a.jsx)(r.Z,{className:(0,c.cn)("mr-2 h-4 w-4 shrink-0",h)}),S?(0,i.WU)(S,"MMM d, yyyy"):p]})}),(0,a.jsxs)(o.yk,{align:b,className:"w-auto p-0",onClick:C,children:[(0,a.jsx)(u.f,{mode:"single",selected:S,defaultMonth:null!=S?S:k,disabled:k?{before:k}:void 0,onSelect:e=>{(e||v)&&(m(e?(0,d.z)(e):null),_(!1))},initialFocus:!0}),v&&S?(0,a.jsx)("div",{className:"border-t p-2",children:(0,a.jsx)(l.z,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-full justify-start text-sm",onClick:()=>{m(null),_(!1)},children:"Clear date"})}):null]})]})}},64396:function(e,t,n){n.d(t,{_:function(){return d}});var a=n(80752),s=n(68303),i=n(1531),r=n(45867),l=n(90851),u=n(58714),o=n(45262);function c(e){let{label:t}=e;return(0,a.jsx)(i.pn,{children:(0,a.jsxs)(i.u,{delayDuration:0,children:[(0,a.jsx)(i.aJ,{asChild:!0,children:(0,a.jsx)("span",{className:"inline-flex flex-shrink-0 items-center rounded bg-orange-100 px-1.5 py-0.5 text-xs font-medium text-orange-700 dark:bg-amber-900/60 dark:text-amber-300",children:(0,a.jsx)(l.Z,{"aria-hidden":"true",className:"h-2.5 w-2.5 shrink-0"})})}),(0,a.jsx)(i._v,{side:"top",children:t})]})})}function d(e){let{fnsku:t,currentCost:n,currency:l="USD",isAiSuggested:d,disabled:m=!1,allowClear:f=!1,inputClassName:p,valueClassName:x,unsetLabel:h="Set cost",aiLabel:b="Estimated cost generated by AI",onSave:g}=e,[y,v]=(0,o.useState)(!1),[j,N]=(0,o.useState)(null==n?"":n.toString()),[w,_]=(0,o.useState)(!1),S=(0,o.useRef)(null),k=(0,o.useRef)(!1);(0,o.useEffect)(()=>{y&&S.current&&(k.current=!1,S.current.focus(),S.current.select())},[y]),(0,o.useEffect)(()=>{y||N(null==n?"":n.toString())},[n,y]);let C=(0,o.useCallback)(async()=>{if(k.current)return;k.current=!0;let e=j.trim(),a=""===e&&f?null:parseFloat(e);if(null!==a&&(isNaN(a)||a<0)){k.current=!1;return}if((null==a?null:Number(a.toFixed(4)))===(null==n?null:Number(n.toFixed(4)))){N(null==n?"":n.toString()),v(!1),k.current=!1;return}_(!0);try{await g(t,a),v(!1)}catch(e){k.current=!1}finally{_(!1)}},[j,n,t,g,f]),z=()=>{k.current=!0,N(null==n?"":n.toString()),v(!1)};return y?(0,a.jsx)(s.I,{ref:S,type:"text",inputMode:"decimal",value:j,onChange:e=>{let t=e.target.value.replace(",",".");(""===t||/^\d*\.?\d*$/.test(t))&&N(t)},onKeyDown:e=>{e.stopPropagation(),"Enter"===e.key&&(e.preventDefault(),C()),"Escape"===e.key&&(e.preventDefault(),z())},onClick:e=>e.stopPropagation(),onBlur:C,className:(0,r.cn)("h-7 w-20 px-1.5 text-sm font-medium ring-2 ring-primary/50",p),disabled:m||w}):(0,a.jsxs)("button",{type:"button",disabled:m,className:"group inline-flex h-7 shrink-0 cursor-pointer items-center gap-1 whitespace-nowrap rounded px-1 text-sm tabular-nums transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60",onClick:e=>{e.stopPropagation(),v(!0)},children:[null==n&&(0,a.jsx)(c,{label:h}),(0,a.jsx)("span",{className:(0,r.cn)("text-sm font-semibold",x),children:null==n?h:(0,r.dJ)(n,l)}
1),(0,a.jsx)(u.Z,{className:"h-2.5 w-2.5 text-muted-foreground/30 group-hover:text-muted-foreground transition-colors flex-shrink-0"}),null!=n&&d?(0,a.jsx)(i.pn,{children:(0,a.jsxs)(i.u,{delayDuration:0,children:[(0,a.jsx)(i.aJ,{asChild:!0,children:(0,a.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-blue-100 text-blue-700 dark:bg-blue-900/60 dark:text-blue-300 flex-shrink-0",children:"AI"})}),(0,a.jsx)(i._v,{side:"top",children:b})]})}):null]})}},23694:function(e,t,n){n.d(t,{s:function(){return u}});var a=n(80752),s=n(45867),i=n(90851),r=n(25283),l=n(65168);function u(e){let{incomplete:t,value:n,expanded:u=!1,onClick:o,ariaLabel:c,title:d,incompleteLabel:m="Set cost",align:f="start",className:p,status:x}=e;return(0,a.jsxs)("button",{type:"button",onClick:o,"aria-expanded":u,"aria-label":c,title:d,className:(0,s.cn)("inline-flex h-7 shrink-0 items-center gap-1.5 whitespace-nowrap rounded px-1.5 text-sm font-normal tabular-nums transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","center"===f&&"mx-auto","end"===f&&"ml-auto",p),children:[t?(0,a.jsx)(i.Z,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-amber-600 dark:text-amber-400"}):null,(0,a.jsx)("span",{className:"whitespace-nowrap",children:t?m:n}),x,u?(0,a.jsx)(r.Z,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}):(0,a.jsx)(l.Z,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"})]})}},33689:function(e,t,n){n.d(t,{OL:function(){return h},_T:function(){return d},aR:function(){return u},f$:function(){return p},fY:function(){return m},le:function(){return b},xo:function(){return f},yT:function(){return x}});var a=n(80752),s=n(45262),i=n(31731),r=n(45867),l=n(41190);let u=i.fC;i.xz;let o=i.h_,c=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,a.jsx)(i.aV,{className:(0,r.cn)("fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...s,ref:t})});c.displayName=i.aV.displayName;let d=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,a.jsxs)(o,{children:[(0,a.jsx)(c,{}),(0,a.jsx)(i.VY,{ref:t,className:(0,r.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...s})]})});d.displayName=i.VY.displayName;let m=e=>{let{className:t,...n}=e;return(0,a.jsx)("div",{className:(0,r.cn)("flex flex-col space-y-2 text-center sm:text-left",t),...n})};m.displayName="AlertDialogHeader";let f=e=>{let{className:t,...n}=e;return(0,a.jsx)("div",{className:(0,r.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...n})};f.displayName="AlertDialogFooter";let p=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,a.jsx)(i.Dx,{ref:t,className:(0,r.cn)("text-lg font-semibold",n),...s})});p.displayName=i.Dx.displayName;let x=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,a.jsx)(i.dk,{ref:t,className:(0,r.cn)("text-sm text-muted-foreground",n),...s})});x.displayName=i.dk.displayName;let h=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,a.jsx)(i.aU,{ref:t,className:(0,r.cn)((0,l.d)(),n),...s})});h.displayName=i.aU.displayName;let b=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,a.jsx)(i.$j,{ref:t,className:(0,r.cn)((0,l.d)({variant:"outline"}),"mt-2 sm:mt-0",n),...s})});b.displayName=i.$j.displayName},27365:function(e,t,n){n.d(t,{C:function(){return l}});var a=n(80752);n(45262);var s=n(5389),i=n(45867);let r=(0,s.j)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function l(e){let{className:t,variant:n,...s}=e;return(0,a.jsx)("div",{className:(0,i.cn)(r({variant:n}),t),...s})}},53184:function(e,t,n){n.d(t,{_:function(){return o}});var a=n(80752),s=n(45262),i=n(41184),r=n(5389),l=n(45867);let u=(0,r.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),o=s.forwardRef((e,t)=>
1{let{className:n,...s}=e;return(0,a.jsx)(i.f,{ref:t,className:(0,l.cn)(u(),n),...s})});o.displayName=i.f.displayName}}]);

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.