1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8523],{21166:(e,s,l)=>{"use strict";l.r(s),l.d(s,{__N_SSP:()=>F,default:()=>I});var r=l(37876),i=l(14232),a=l(77328),n=l.n(a),t=l(19512),c=l(55006),o=l(86922),d=l(64184),h=l(48578),m=l(42428),x=l(58830),j=l(40670),u=l(44501),f=l(69241),g=l(4697),p=l(69844),b=l(83957),A=l(47951),v=l(45879);function w(e){return(0,v.Ay)("MuiFormGroup",e)}(0,A.A)("MuiFormGroup",["root","row","error"]);var _=l(50538),k=l(67788);let N=["className","row"],y=(0,p.Ay)("div",{name:"MuiFormGroup",slot:"Root",overridesResolver:(e,s)=>{let{ownerState:l}=e;return[s.root,l.row&&s.row]}})(({ownerState:e})=>(0,u.A)({display:"flex",flexDirection:"column",flexWrap:"wrap"},e.row&&{flexDirection:"row"})),S=i.forwardRef(function(e,s){let l=(0,b.b)({props:e,name:"MuiFormGroup"}),{className:i,row:a=!1}=l,n=(0,j.A)(l,N),t=(0,_.A)(),c=(0,k.A)({props:l,muiFormControl:t,states:["error"]}),o=(0,u.A)({},l,{row:a,error:c.error}),d=(e=>{let{classes:s,row:l,error:r}=e;return(0,g.A)({root:["root",l&&"row",r&&"error"]},w,s)})(o);return(0,r.jsx)(y,(0,u.A)({className:(0,f.A)(d.root,i),ownerState:o,ref:s},n))});var C=l(86115),T=l(84399),P=l(27910),E=l(87868),R=l(30338),$=l(61875),B=l(33115),O=l(99742);let q=["track","release","merch","discography"],z=()=>({track:!0,release:!0,merch:!0,discography:!0});var F=!0;function I(){let[e,s]=(0,i.useState)(""),[l,a]=(0,i.useState)([]),[j,u]=(0,i.useState)({}),[f,g]=(0,i.useState)(!1),[p,b]=(0,i.useState)(!1),[A,v]=(0,i.useState)(!1),[w,_]=(0,i.useState)(null),[k,N]=(0,i.useState)(null),[y,F]=(0,i.useState)(z),[I,G]=(0,i.useState)(null),M=O.env.NEXT_PUBLIC_ENV_WARNING||"production",D=(0,i.useCallback)(async e=>{g(!0),G(null);try{let s=new URLSearchParams;e?.trim()&&s.set("q",e.trim()),s.set("limit","100");let l=await fetch(`/api/admin/pricing/sellers?${s.toString()}`),r=await l.json();if(!l.ok)throw Error(r.error||`HTTP ${l.status}`);a(r.sellers??[]),u({})}catch(e){G(e instanceof Error?e.message:String(e))}finally{g(!1)}},[]);async function H(e){for(let s=0;s<120;s++){let s=await fetch(`/api/admin/jobs/status?jobId=${encodeURIComponent(e)}`),l=await s.json();if(!s.ok)throw Error(l.error||`HTTP ${s.status}`);if("completed"===l.state||"failed"===l.state)return l;await new Promise(e=>setTimeout(e,1e3))}throw Error("Job timed out waiting for completion")}async function Q(){b(!0),G(null),_(null),N(null);try{let e=await fetch("/api/admin/jobs/pricing-compare",{method:"POST"}),s=await e.json();if(!e.ok)throw Error(s.error||`HTTP ${e.status}`);_(`Compare job queued (${s.jobId}). Waitingâ¦`);let l=await H(s.jobId);if("failed"===l.state)throw Error(l.failedReason||"Compare job failed");N(l.result??null),F(z()),_("Compare completed.")}catch(e){G(e instanceof Error?e.message:String(e))}finally{b(!1)}}async function V(s){if(confirm("all"===s?`Backfill resolved prices for ALL sellers with products on ${M}?`:"mismatch"===s?`Backfill resolved prices for sellers with compare mismatches on ${M}?`:`Backfill resolved prices for ${"selected"===s?Object.values(j).filter(Boolean).length:"matching"} seller(s) on ${M}?`)){v(!0),G(null),_(null);try{let l={};"selected"===s?l.sellerIds=Object.entries(j).filter(([,e])=>e).map(([e])=>Number(e)):"all"===s?l.selectAll=!0:"mismatch"===s?l.mismatchOnly=!0:(l.query=e.trim(),l.selectAll=!0);let r=await fetch("/api/admin/jobs/pricing-backfill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),i=await r.json();if(!r.ok)throw Error(i.error||`HTTP ${r.status}`);_(`Queued ${i.sellerCount} backfill job(s). See Queues for progress.`)}catch(e){G(e instanceof Error?e.message:String(e))}finally{v(!1)}}}(0,i.useEffect)(()=>{D()},[D]);let W=k?.samples.filter(e=>y[e.type]??!0)??[];return(0,B.B)()?(0,r.jsxs)(E.A,{message:"unknown"!==M?`Environment: ${M}`:void 0,children:[(0,r.jsx)(n(),{children:(0,r.jsx)("title",{children:"Admin â Pricing"})}),(0,r.jsx)($.DZ,{children:"Resolved price tools"}),(0,r.jsxs)("p",{className:"text-sm text-neutral-500 mb-4",children:["Compare view prices vs stored ",(0,r.jsx)("code",{children:"product.resolved_price"}),", then backfill per seller."]}),I&&(0,r.jsx)("p",{className:"text-red-400 mb-2",children:I}),w&&(0,r.jsx)("p",{className:"text-green-400 mb-2",children:w}),(0,r.jsxs)("section",{className:"mb-8 flex flex-wrap gap-2 items-center",children:[(0,r.jsx)(t.A,{variant:"contained",disabled:p,onClick:()=>void Q(),children:p?(0,r.jsx)(c.A,{size:20}):"Compare prices (full catalog)"}),(0,r.jsx)(t.A,{variant:"contained",color:"warning",disabled:A,onClick:()=>void V("mismatch"),children:A?(0,r.jsx)(c.A,{size:20}):"Backfill discrepancies"})]}
1),k&&(0,r.jsxs)("section",{className:"mb-8",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Compare results"}),(0,r.jsxs)(o.A,{size:"small",children:[(0,r.jsx)(d.A,{children:(0,r.jsxs)(h.A,{children:[(0,r.jsx)(m.A,{children:"Type"}),(0,r.jsx)(m.A,{align:"right",children:"Total"}),(0,r.jsx)(m.A,{align:"right",children:"Mismatches"}),(0,r.jsx)(m.A,{align:"right",children:"Null resolved"})]})}),(0,r.jsxs)(x.A,{children:[Object.entries(k.byType).map(([e,s])=>(0,r.jsxs)(h.A,{children:[(0,r.jsx)(m.A,{children:e}),(0,r.jsx)(m.A,{align:"right",children:s.total}),(0,r.jsx)(m.A,{align:"right",children:s.mismatches}),(0,r.jsx)(m.A,{align:"right",children:s.nullResolved})]},e)),(0,r.jsxs)(h.A,{children:[(0,r.jsx)(m.A,{children:(0,r.jsx)("strong",{children:"Total"})}),(0,r.jsx)(m.A,{align:"right",children:k.totals.total}),(0,r.jsx)(m.A,{align:"right",children:k.totals.mismatches}),(0,r.jsx)(m.A,{align:"right",children:k.totals.nullResolved})]})]})]}),k.totals.mismatches>0&&(0,r.jsx)("div",{className:"mt-3",children:(0,r.jsxs)(t.A,{variant:"contained",color:"warning",disabled:A,onClick:()=>void V("mismatch"),children:["Backfill discrepancies (",k.totals.mismatches," product",1===k.totals.mismatches?"":"s",")"]})}),k.samples.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h3",{className:"text-md font-semibold mt-4 mb-2",children:"Sample mismatches"}),(0,r.jsx)(S,{row:!0,className:"mb-2",children:q.map(e=>(0,r.jsx)(C.A,{control:(0,r.jsx)(T.A,{size:"small",checked:y[e],onChange:s=>{var l;return l=s.target.checked,void F(s=>({...s,[e]:l}))}}),label:e},e))}),(0,r.jsxs)("p",{className:"text-sm text-neutral-500 mb-2",children:["Showing ",W.length," of ",k.samples.length," samples"]}),(0,r.jsxs)(o.A,{size:"small",children:[(0,r.jsx)(d.A,{children:(0,r.jsxs)(h.A,{children:[(0,r.jsx)(m.A,{children:"Product"}),(0,r.jsx)(m.A,{children:"Type"}),(0,r.jsx)(m.A,{align:"right",children:"View"}),(0,r.jsx)(m.A,{align:"right",children:"Resolved"}),(0,r.jsx)(m.A,{align:"right",children:"Diff"})]})}),(0,r.jsx)(x.A,{children:W.map(e=>(0,r.jsxs)(h.A,{children:[(0,r.jsx)(m.A,{children:e.productId}),(0,r.jsx)(m.A,{children:e.type}),(0,r.jsx)(m.A,{align:"right",children:e.viewPrice??"null"}),(0,r.jsx)(m.A,{align:"right",children:e.resolvedPrice??"null"}),(0,r.jsx)(m.A,{align:"right",children:e.diff.toFixed(2)})]},e.productId))})]})]})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2",children:"Backfill by seller"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2 mb-4 items-end",children:[(0,r.jsx)(P.A,{label:"Search name or slug",size:"small",value:e,onChange:e=>s(e.target.value)}),(0,r.jsx)(t.A,{variant:"outlined",disabled:f,onClick:()=>void D(e),children:"Search"}),(0,r.jsx)(t.A,{variant:"contained",color:"warning",disabled:A,onClick:()=>void V("selected"),children:"Backfill selected"}),(0,r.jsx)(t.A,{variant:"outlined",color:"warning",disabled:A||!e.trim(),onClick:()=>void V("query"),children:"Backfill all matching search"}),(0,r.jsx)(t.A,{variant:"outlined",color:"error",disabled:A,onClick:()=>void V("all"),children:"Backfill all (with products)"})]}),f?(0,r.jsx)(c.A,{size:24}):(0,r.jsxs)(o.A,{size:"small",children:[(0,r.jsx)(d.A,{children:(0,r.jsxs)(h.A,{children:[(0,r.jsx)(m.A,{padding:"checkbox",children:(0,r.jsx)(T.A,{indeterminate:l.some(e=>j[e.id])&&!l.every(e=>j[e.id]),checked:l.length>0&&l.every(e=>j[e.id]),onChange:e=>(function(e){let s={};for(let r of l)s[r.id]=e;u(s)})(e.target.checked)})}),(0,r.jsx)(m.A,{children:"ID"}),(0,r.jsx)(m.A,{children:"Name"}),(0,r.jsx)(m.A,{children:"Slug"}),(0,r.jsx)(m.A,{align:"right",children:"Products"})]})}),(0,r.jsx)(x.A,{children:l.map(e=>(0,r.jsxs)(h.A,{children:[(0,r.jsx)(m.A,{padding:"checkbox",children:(0,r.jsx)(T.A,{checked:!!j[e.id],onChange:s=>u(l=>({...l,[e.id]:s.target.checked}))})}),(0,r.jsx)(m.A,{children:e.id}),(0,r.jsx)(m.A,{children:e.name}),(0,r.jsx)(m.A,{children:e.slug}),(0,r.jsx)(m.A,{align:"right",children:e.productCount})]},e.id))})]})]})]}):(0,r.jsx)(R.G,{})}},28698:(e,s,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/_admin/pricing",function(){return l(21166)}])},30338:(e,s,l)=>{"use strict";l.d(s,{G:()=>a});var r=l(37876),i=l(67904);function a(){return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h1",{children:"Please sign in"}
1),(0,r.jsx)(i.bN,{})]})}l(14232)},87868:(e,s,l)=>{"use strict";l.d(s,{A:()=>x});var r=l(37876);l(14232);var i=l(48230),a=l.n(i),n=l(89099),t=l(10553),c=l(4186);let o=[{href:"/_admin/",label:"Admin",icon:(0,r.jsx)(c.g_8,{})},{href:"/_admin/stats",label:"Stats",icon:(0,r.jsx)(c.DX0,{})},{href:"/_admin/orders",label:"Orders",icon:(0,r.jsx)(c.q8i,{})},{href:"/_admin/sales",label:"Sales",icon:(0,r.jsx)(c.imn,{})},{href:"/_admin/carts",label:"Carts",icon:(0,r.jsx)(c.O7Q,{})},{href:"/_admin/payouts",label:"Payouts",icon:(0,r.jsx)(c.DwJ,{})},{href:"/_admin/revenues",label:"Revenues",icon:(0,r.jsx)(c.H4F,{})},{href:"/_admin/vat",label:"VAT",icon:(0,r.jsx)(c.q89,{})},{href:"/_admin/virtual_cash",label:"Virtual Cash",icon:(0,r.jsx)(c.ohY,{})},{href:"/_admin/pricing",label:"Pricing",icon:(0,r.jsx)(c.HdF,{})},{href:"/_admin/sellers",label:"Sellers",icon:(0,r.jsx)(c.nZo,{})},{href:"/_admin/beta_queue",label:"Beta Queue",icon:(0,r.jsx)(c.tX0,{})},{href:"/_admin/music",label:"Music",icon:(0,r.jsx)(c.qzP,{})},{href:"/_admin/tracks",label:"Tracks",icon:(0,r.jsx)(c.vC2,{})},{href:"/_admin/genre_change",label:"Genre Change",icon:(0,r.jsx)(c.M1j,{})},{href:"/_admin/send_email",label:"Send Email",icon:(0,r.jsx)(c.mm2,{})},{href:"/_admin/queues",label:"Queues",icon:(0,r.jsx)(c.fs5,{})},{href:"/_admin/release_jobs",label:"Release Jobs",icon:(0,r.jsx)(c.qzP,{})},{href:"/_admin/waf",label:"WAF",icon:(0,r.jsx)(c.Ueo,{})},{href:"/_admin/system",label:"System",icon:(0,r.jsx)(c.hgV,{})},{href:"/_admin/testing",label:"Testing",icon:(0,r.jsx)(c.mGp,{})}];function d(e){return["inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-sm font-medium transition-colors",e?"bg-brand text-white shadow-sm":"bg-neutral-800 text-neutral-200 hover:bg-neutral-600"].join(" ")}function h({href:e,label:s,icon:l}){var i;let t=(i=(0,n.useRouter)().pathname,"/_admin/"===e?"/_admin"===i||"/_admin/"===i:i===e||i.startsWith(`${e}/`));return(0,r.jsx)("li",{children:(0,r.jsxs)(a(),{href:e,className:d(t),children:[(0,r.jsx)("span",{className:"text-base shrink-0 opacity-90",children:l}),s]})})}function m({href:e,label:s,icon:l,onClick:i}){let n=d(!1);return i?(0,r.jsxs)("button",{type:"button",onClick:i,className:n,children:[(0,r.jsx)("span",{className:"text-base shrink-0 opacity-90",children:l}),s]}):(0,r.jsxs)(a(),{href:e,className:n,children:[(0,r.jsx)("span",{className:"text-base shrink-0 opacity-90",children:l}),s]})}function x(e){let s=e.children;return(0,r.jsxs)("div",{className:"min-h-screen bg-neutral-950 text-neutral-100",children:[e.message?(0,r.jsx)("div",{className:"border-b border-orange-400/30 bg-orange-300/20 px-4 py-1.5 text-sm text-orange-100",children:e.message}):null,(0,r.jsxs)("header",{className:"border-b border-neutral-800 bg-neutral-900",children:[(0,r.jsxs)("div",{className:"mx-auto flex max-w-7xl flex-wrap items-center justify-between gap-2 px-4 py-2",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-2 text-lg font-semibold text-white",children:[(0,r.jsx)(c.g_8,{className:"text-2xl text-brand"}),"Admin"]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(m,{href:"/",label:"Main Site",icon:(0,r.jsx)(c.Tsc,{})}),(0,r.jsx)(m,{label:"Sign Out",icon:(0,r.jsx)(c.EyH,{}),onClick:()=>(0,t.signOut)()})]})]}),(0,r.jsx)("nav",{className:"mx-auto max-w-7xl border-t border-neutral-800 px-4 py-2",children:(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5",children:o.map(e=>(0,r.jsx)(h,{...e},e.href))})})]}),(0,r.jsx)("div",{className:"mx-auto max-w-7xl p-4",children:s})]})}}},e=>{e.O(0,[1994,636,6593,8792],()=>e(e.s=28698)),_N_E=e.O()}]);
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.