1import{Y as Pi,j as e,ab as ci,Z as Oi}from"./vendor-ui-BfO2VaBV.js";import{R as Wi,bG as Si,pd as Mi,px as Ni,py as qi,e as $i,j9 as E,t as l,g as ie,mi as ge,C as Qi,Y as Vi,B as x,Z as zi,lR as Ki,n as Y,i_ as di,a2 as f,bm as v,J as mi,br as g,c as Yi,iI as Ji,s as Z,pz as Ui,pA as Hi,l4 as Zi,pB as Xi}from"./index-DNro_9Uk.js";import{a as te}from"./vendor-redux-DAFPkm2K.js";import{c as et,d as pi,T as it,e as tt}from"./SectionWithPanel-Dwg2WWrC.js";import{B as rt}from"./bg_noncardmarket-ydURrlIY.js";import"./vendor-blockchain-B33N8Jyr.js";import"./three-DYsWAOM3.js";import"./maps-BKggpbsI.js";import"./react-number-format.es-4hMs4u0_.js";const st=(o,D=0)=>{const m=o==null?void 0:o.getBoundingClientRect();return m?m.top<(window.innerHeight||document.documentElement.clientHeight)-D&&m.bottom>0&&m.left<(window.innerWidth||document.documentElement.clientWidth)&&m.right>0:!1},nt=Z(x,{backgroundSize:"cover",backgroundImage:"url(".concat(rt,")"),backgroundRepeat:"no-repeat",backgroundAttachment:"fixed",minHeight:"100vh",paddingBottom:"20px"}),C=Z(tt,{textAlign:"left",margin:0,textTransform:"none"}),j=Z(it,{color:"$paleYellow"}),I=Z(Y,{flexDirection:"column",gap:10}),at=Z(x,{variants:{rarity:{4:{color:"#c67303"},3:{color:"#923fb1"},2:{color:"#298fa2"},1:{color:"#727272"}}}});function ot(){const o=Yi.c(2),{search:D}=Ji();let m;return o[0]!==D?(m=new URLSearchParams(D),o[0]=D,o[1]=m):m=o[1],m}const ft=()=>{var be,ke,Te,Ce,we,ve,_e,Ae,Ee,Be,Ge,Re,De,Le,Fe,Pe,Oe,We,Se,Me,Ne,qe,$e,Qe,Ve,ze,Ke,Ye,Je,Ue,He,Ze;const o=ot(),D=Wi(),{data:m,isLoading:ui,isError:hi}=Si(null),{data:re,isLoading:gi,isError:xi}=Mi(null),yi=te.useMemo(()=>Array.isArray(re)?re:[],[re]),[fi]=Ni(),[ji]=qi(),Ii=ui||gi,xe=hi||xi,[ye,bi]=te.useState([]),ki=$i().shape({edition:E().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")),packType:ie().nullable(),quantity:E().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")).test("Is positive?","The number must be greater than 0!",i=>i>0),potionOne:E().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")).test("Is positive?","The number must be 0 or greater!",i=>i>=0),potionTwo:E().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")).test("Is positive?","The number must be 0 or greater!",i=>i>=0),potionThree:E().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")).test("Is positive?","The number must be 0 or greater!",i=>i>=0),transactionId:ie().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")),blockNumber:E().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")).test("Is positive?","The number must be greater than 0!",i=>i>0),blockId:ie().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")),previousBlockId:ie().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")),blockTime:E().typeError(l("dec.err_invalid")).required(l("dec.err_invalid")).test("Is positive?","The number must be greater than 0!",i=>i>0),standard:E().typeError(l("dec.err_invalid")).nullable(),alchemy:E().nullable().default(0).transform(i=>Number.isNaN(i)?0:i).typeError(l("dec.err_invalid")),legendary:E().nullable().default(0).transform(i=>Number.isNaN(i)?0:i).typeError(l("dec.err_invalid"))}),fe="14",Ti={resolver:Oi(ki),defaultValues:{quantity:+o.get("quantity"),edition:+((be=o.get("edition"))!=null?be:fe),packType:o.get("packType"),potionOne:+o.get("potionOne"),potionTwo:+o.get("potionTwo"),potionThree:+o.get("potionThree"),standard:+((ke=o.get("standard"))!=null?ke:"0"),alchemy:+((Te=o.get("alchemy"))!=null?Te:"0"),legendary:+((Ce=o.get("legendary"))!=null?Ce:"0"),transactionId:o.get("transactionId"),blockNumber:+o.get("blockNumber"),blockId:o.get("blockId"),previousBlockId:o.get("previousBlockId"),blockTime:+o.get("blockTime")}},{control:je,register:k,handleSubmit:Ci,watch:wi,formState:{errors:t}}=Pi(Ti),q=wi("edition"),vi=te.useMemo(()=>ge.filter(i=>!i.packType||i.isPrimary).map(i=>({name:i.editionName||i.fullName||i.name,value:i.edition})),[]),se=te.useMemo(()=>ge.filter(i=>i.edition===+q&&!!i.packType).map(i=>({name:i.packType.toUpperCase(),value:i.packType})),[q]);if(Ii)return e.jsx(Qi,{});const Ie=(i,p,r,O,L,W,ne,$)=>{const d=$!=null?$:[.248,.048,.008,0],ae=ne.slice().sort((n,Q)=>n.id-Q.id),T=r();console.log("Rarity RNG: ",T);let y=Xi.Common;const c=d.slice();if(L)if(O===v.CONCLAVE_ARCANA.ID){const n=+(L/100).toFixed(3);c[0]+=c[1]*n,c[1]+=c[1]*n,c[2]+=c[2]*n}else{const n=+(c[2]*(L/100)).toFixed(3);c[0]+=n,c[1]+=n,c[2]+=n}for(let n=0;n<c.length&&(y=n+1,!(T>c[n]));n+=1);y<i&&(y=i),y>p&&(y=p);let B=ae.filter(n=>n.rarity===y&&!n.is_promo&&(!n.print_start_date||W>=n.print_start_date_as_date)&&n.editions.split(",").map(Q=>parseInt(Q,10)).includes(O));if(O===v.PROMO.ID&&(B=B.filter(n=>n.id>=118&&n.id<=129)),B.length===0)return-1;const J=r();return console.log("Card Index: ".concat(J,", Cards: ").concat(B.length,", Legendary Boost: ").concat(L)),B[Math.floor(J*B.length)].id},_i=async(i,p,r,O,L,W,ne,$,d,ae,T)=>{var ei,ii,ti,ri;if(isNaN(r)||![0,1,2,4,5,6,7,8,9,12,14,20,21].includes(r))return{error:"Invalid or unspecified pack edition."};console.log("----------------------"),console.log("Seed: ",p);let y=[];const c=Hi(p);let B=parseInt(L,10)||0,J=parseInt(W,10)||0,n=parseInt(ne,10)||0;const Q=new Date(+$),X=[...ae],Xe=m.map(u=>({...u,print_start_date_as_date:new Date(u.print_start_date)})),oe={},Bi=11e6;for(let u=0;u<i;u+=1){let b=d.cards_per_pack;const S=[];let _;
1if([v.CONCLAVE_ARCANA.ID,v.ESCALATION.ID].includes(r)&&d.arcane_multiplier>0){const s=c(),F=c(),G=(i-u)*d.arcane_multiplier,M=(r===v.CONCLAVE_ARCANA.ID?Bi:(ei=ge.find(h=>h.edition===r))==null?void 0:ei.totalMinted)-((ii=T==null?void 0:T.standard)!=null?ii:0)-((ti=T==null?void 0:T.alchemy)!=null?ti:0)-((ri=T==null?void 0:T.legendary)!=null?ri:0)+G;let A=Math.floor(s*M);A<X.length*d.arcane_multiplier&&(d.arcane_multiplier>1&&(A=Math.floor(F*X.length)),_=X[A],X.splice(A,1),b-=1,S.push(_))}const le=(d.guarantees||[]).map(s=>s.rarity).filter(s=>!!s),ce=(d.guarantees||[]).map(s=>s.foil).filter(s=>!!s),V=(d.minimum_guarantees||[]).map(s=>s.rarity).filter(s=>!!s),z=(d.minimum_guarantees||[]).map(s=>s.foil).filter(s=>!!s);if(_){const s=m.find(h=>h.id===_.card_detail_id),{rarity:F}=s,G=le.findIndex(h=>F>=h);G>-1&&le.splice(G,1);const P=ce.findIndex(h=>_.foil>=h);P>-1&&ce.splice(P,1);const M=V.findIndex(h=>F>=h);M>-1&&V.splice(M,1);const A=z.findIndex(h=>_.foil>=h);A>-1&&z.splice(A,1)}for(let s=0;s<b;s+=1){let F=0,G=0,P=0;const M=le[s],A=typeof M=="number",h=ce[s],de=typeof h=="number";B>0&&!A&&(B-=1,F=100),J>0&&!de&&(J-=1,G=100),n>0&&(n-=1,P=100);const{max_rarity:si}=d;let ee;if(A)ee=M;else{const a=V[0],U=s===b-V.length;ee=!!a&&U?a:d.min_rarity}let R=Ie(ee,si,c,r,F,Q,Xe,d.rarity_pcts);if(R===-1)return{error:"Could not generate cards for the given parameters (block number may be too low for the edition you selected)."};if(r!==v.PROMO.ID)for(;S.find(a=>a.card_detail_id===R);)R=Ie(ee,si,c,r,F,Q,Xe,d.rarity_pcts);const Gi=Math.floor(c()*15+5);for(let a=0;a<Gi;a+=1)c();const ni=.02;let w=g.Regular;if(d.max_foil_allowed>g.Regular){const a=c();console.log("Foil RNG: ",a,", .Gold Boost: ",G," .Black Boost: ",P),d.max_foil_allowed>g.Gold?w=a<d.black_foil_chance*(1+P/100)?g.Black:a<ni*(1+G/100)+d.black_foil_chance*(1+P/100)?g.Gold:g.Regular:w=a<ni*(1+G/100)?g.Gold:g.Regular,de&&w<h&&(w=h)}const me=z[0],Ri=s===b-z.length;!!me&&Ri&&w<me&&!de&&(w=me);const ai=z.findIndex(a=>w>=a);ai>-1&&z.splice(ai,1);let pe=m.find(a=>a.id===R),{rarity:K}=pe,oi;if(w===g.Black){if(!oe[K]){const{data:U}=await ji({edition:r,pack_open_date:$,rarity:K},!0),H=U.map(ue=>({...ue}));oe[K]=H}const a=oe[K];if((a==null?void 0:a.length)>0){const U=Math.min(...a.map(N=>N.mint)),H=a.filter(N=>N.mint===U),ue=H.length,Li=Math.floor(c()*ue),he=H[Li];R=he.id,pe=m.find(N=>
1N.id===R),K=pe.rarity,oi=(he.mint+1).toString();const Fi=a.findIndex(N=>N.id===he.id);a[Fi].mint+=1}}const li=V.findIndex(a=>K>=a);li>-1&&V.splice(li,1),console.log("Card Detail ID: ",R);const Di="".concat(w===g.Black?"B":w===g.Gold?"G":"C").concat(r,"-").concat(R,"-");S.push({uid:Di+Zi(10,c),card_detail_id:R,foil:w,mint:oi})}S.forEach(s=>y.push(s))}return console.log("----------------------"),y=y.map(u=>{var b,S;return{...u,name:(b=m.find(_=>_.id===u.card_detail_id))==null?void 0:b.name,rarity:(S=m.find(_=>_.id===u.card_detail_id))==null?void 0:S.rarity}}),y=y.sort((u,b)=>b.foil!==u.foil?b.foil-u.foil:b.rarity!==u.rarity?b.rarity-u.rarity:b.card_detail_id-u.card_detail_id),console.log("cardList",y),bi(y),null},Ai=async i=>{const p=se.length>0?i.packType:void 0,r=yi.find(W=>W.pack_type===(p!=null?p:"original"));let O=[];if(r.arcane_multiplier>0){const{data:W}=await fi({edition:i.edition.toString(),pack_open_date:i.blockTime.toString()},!0);O=W}const L={standard:+i.standard*1,alchemy:+i.alchemy*3,legendary:+i.legendary*6};await _i(i.quantity,Ui("".concat(i.transactionId).concat(i.blockId).concat(i.previousBlockId)),i.edition,i.blockNumber,i.potionOne,i.potionTwo,i.potionThree,i.blockTime.toString(),r,O,L),Ei()},Ei=()=>{const i=document.getElementById("card-list-section");if(!st(i,60)&&i){const p=i.getBoundingClientRect().top+window.scrollY-500;window.scroll({top:p,behavior:"smooth"})}};return e.jsxs(nt,{children:[e.jsx(Vi,{onGoBackTitle:"BACK",onGoBack:()=>{D("/mana-well")},headerTitle:"PACK VERIFY",sticky:!0}),e.jsxs(et,{sectionTitle:"PACK VERIFY",children:[xe&&e.jsx(x,{css:{width:"100%",pt:"100px",pb:"100px"},children:e.jsx(zi,{message:"An error occurred loading pack information, please refresh the page to try again.",withLines:!1})}),!xe&&e.jsxs(Ki,{onSubmit:Ci(Ai),css:{width:"100%",maxWidth:"800px"},children:[e.jsxs(Y,{css:{marginTop:20,gap:"20px 40px",flexWrap:"wrap"},children:[e.jsxs(I,{css:{gap:5,maxWidth:"100%"},children:[e.jsx(j,{children:"Edition:"}),e.jsx(ci,{render:({field:{onChange:i,value:p}})=>e.jsx(pi,{css:{width:380,maxWidth:"100%"},name:"edition",value:p,onChange:r=>{i(r.target.value)},children:vi.map(r=>e.jsx(di,{value:r.value,children:r.name},r.value))}),control:je,defaultValue:+fe,name:"edition"}),((we=t.edition)==null?void 0:we.message)&&e.jsx(f,{css:{marginTop:10},children:(ve=t.edition)==null?void 0:ve.message})]}),se.length>0&&e.jsxs(I,{css:{gap:5,maxWidth:"100%"},children:[e.jsx(j,{children:"Pack Type:"}),e.jsx(ci,{render:({field:{onChange:i,value:p}})=>e.jsx(pi,{css:{width:380,maxWidth:"100%"},name:"packType",value:p,onChange:r=>{i(r.target.value)},children:se.map(r=>e.jsx(di,{value:r.value,children:r.name},r.value))}),control:je,defaultValue:"original",name:"packType"}),((_e=t.packType)==null?void 0:_e.message)&&e.jsx(f,{css:{marginTop:10},children:(Ae=t.packType)==null?void 0:Ae.message})]})]}),e.jsxs(Y,{css:{marginTop:15,gap:"20px 40px",flexWrap:"wrap"},children:[e.jsxs(I,{css:{width:380,maxWidth:"100%",gap:5},children:[e.jsx(j,{children:q===v.GLADIUS.ID?"Blood Stone Quantity:":"Legendary Potion Quantity:"}),e.jsx(C,{type:"number",...k("potionOne"),css:{width:380,maxWidth:"100%"}}),((Ee=t.potionOne)==null?void 0:Ee.message)&&e.jsx(f,{children:(Be=t.potionOne)==null?void 0:Be.message})]}),e.jsxs(I,{css:{width:380,maxWidth:"100%",gap:5},children:[e.jsx(j,{children:q===v.GLADIUS.ID?"Power Stone Quantity:":"Alchemy Potion Quantity:"}),e.jsx(C,{type:"number",...k("potionTwo"),css:{width:380,maxWidth:"100%"}}),((Ge=t.potionTwo)==null?void 0:Ge.message)&&e.jsx(f,{children:(Re=t.potionTwo)==null?void 0:Re.message})]}),[v.CONCLAVE_ARCANA.ID,v.ESCALATION.ID].includes(+q)&&e.jsxs(e.Fragment,{children:[e.jsxs(I,{css:{width:380,maxWidth:"100%",gap:5},children:[e.jsx(j,{children:"Midnight Potion Quantity"}),e.jsx(C,{type:"number",...k("potionThree"),css:{width:380,maxWidth:"100%"}}),((De=t.potionThree)==null?void 0:De.message)&&e.jsx(f,{children:(Le=t.potionThree)==null?void 0:Le.message})]}),e.jsxs(I,{css:{width:380,maxWidth:"100%",gap:5},children:[e.jsx(j,{children:"Standard Packs Burned or Opened"}),e.jsx(C,{type:"number",...k("standard"),css:{width:380,maxWidth:"100%"}}),((Fe=t.standard)==null?void 0:Fe.message)&&e.jsx(f,{children:(Pe=t.standard)==null?void 0:Pe.message})]})]}),+q===v.CONCLAVE_ARCANA.ID&&e.jsxs(e.Fragment,{children:[e.jsxs(I,{css:{width:380,maxWidth:"100%",gap:5},children:[e.jsx(j,{children:"Alchemy Packs Burned or Opened"}),e.jsx(C,{type:"number",...k("alchemy"),css:{width:380,maxWidth:"100%"}}),((Oe=t.alchemy)==null?void 0:Oe.message)&&e.jsx(f,{children:(We=t.alchemy)==null?void 0:We.message})]}),e.jsxs(I,{css:{width:380,maxWidth:"100%",gap:5},children:[e.jsx(j,{children:"Legendary Packs Burned or Opened"}),e.jsx(C,{type:"number",...k("legendary"),css:{width:380,maxWidth:"100%"}}),((Se=t.legendary)==null?void 0:Se.message)&&e.jsx(f,{children:(Me=t.legendary)==null?void 0:Me.message})]})]})]}),e.jsx(x,{css:{marginTop:15},children:e.jsxs(I,{css:{gap:5},children:[e.jsx(j,{children:"Pack Quantity:"}),e.jsx(C,{type:"number",...k("quantity"),css:{width:380,maxWidth:"100%"}}),((Ne=t.quantity)==null?void 0:Ne.message)&&e.jsx(f,{children:(qe=t.quantity)==null?void 0:qe.message})]})}),e.jsx(x,{css:{marginTop:15},children:e.jsxs(I,{css:{gap:5},children:[e.jsx(j,{children:"Transaction ID:"}),e.jsx(C,{type:"input",...k("transactionId"),css:{width:800,maxWidth:"100%"}}),(($e=t.transactionId)==null?void 0:$e.message)&&e.jsx(f,{children:(Qe=t.transactionId)==null?void 0:Qe.message})]})}),e.jsx(x,{css:{marginTop:15},children:e.jsxs(I,{css:{gap:5},children:[e.jsx(j,{children:"Block Number:"}),e.jsx(C,{type:"number",...k("blockNumber"),css:{width:800,maxWidth:"100%"}}),((Ve=t.blockNumber)==null?void 0:Ve.message)&&e.jsx(f,{children:(ze=t.blockNumber)==null?void 0:ze.message})]})}),e.jsx(x,{css:{marginTop:15},children:e.jsxs(I,{css:{gap:5},children:[e.jsx(j,{children:"Block ID:"}),e.jsx(C,{type:"input",...k("blockId"),css:{width:800,maxWidth:"100%"}}),((Ke=t.blockId)==null?void 0:Ke.message)&&e.jsx(f,{children:(Ye=t.blockId)==null?void 0:Ye.message})]})}),e.jsx(x,{css:{marginTop:15},children:e.jsxs(I,{css:{gap:5},children:[e.jsx(j,{children:"Previous Block ID:"}),e.jsx(C,{type:"input",...k("previousBlockId"),css:{width:800,maxWidth:"100%"}}),((Je=t.previousBlockId)==null?void 0:Je.message)&&e.jsx(f,{children:(Ue=t.previousBlockId)==null?void 0:Ue.message})]})}),e.jsx(x,{css:{marginTop:15},children:e.jsxs(I,{css:{gap:5},children:[e.jsx(j,{children:"Block Time:"}),e.jsx(C,{type:"number",...k("blockTime"),css:{width:800,maxWidth:"100%"}}),((He=t.blockTime)==null?void 0:He.message)&&e.jsx(f,{children:(Ze=t.blockTime)==null?void 0:Ze.message})]})}),e.jsxs(Y,{css:{justifyContent:"center",width:"100%",marginTop:40,gap:"20px"},children:[e.jsx(mi,{type:"button",color:"red",onClick:()=>D("/mana-well"),css:{width:"120px",fontWeight:"normal"},children:"BACK"}),e.jsx(mi,{color:"darkBlue",css:{width:"120px",fontWeight:"normal"},children:"Generate Packs"})]})]})]}),e.jsx(Y,{id:"card-list-section",css:{margin:"auto",flexDirection:"column",gap:5,maxWidth:"380px",background:ye.length>0?"rgba(0, 0, 0, 0.6)":"transparent",padding:"10px",br:"4px"},children:ye.map((i,p)=>e.jsxs(Y,{css:{gap:8},children:[e.jsx(x,{css:{color:"$paleYellow"},children:i.uid}),e.jsx(at,{rarity:i.rarity,children:i.name}),i.foil===g.Gold&&e.jsx(x,{css:{color:"#E68E16"},children:"(GOLD)"}),i.foil===g.GoldArcane&&e.jsx(x,{css:{color:"#E68E16"},children:"(GOLD ARCANE)"}),i.foil===g.BlackArcane&&e.jsx(x,{css:{color:"blueviolet"},children:"(BLACK ARCANE)"}),i.foil===g.Black&&e.jsx(x,{css:{color:"blueviolet"},children:"(BLACK)"}),typeof i.mint=="string"&&i.mint!==""&&e.jsxs(x,{css:{color:"#FFF"},children:["Mint: ",i.mint]})]},p))})]})};export{ft as PackVerify,ft 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.