!function(e){"use strict";const r=new Set([4,10]);function t(e,r){if(!Array.isArray(r))return{id:Number(e),name:"",acronym:"",value:0,rap:0};let t=Number(r[2])||0,a=Number(r[3]),n=Number.isFinite(a)&&a>0?a:t>0?t:0;return{id:Number(e),name:String(r[0]||""),acronym:String(r[1]||""),value:n,rap:t}}function a(e){let t=Number(e);if(Number.isFinite(t)&&r.has(t))return!0;let a=String(e||"").trim().toLowerCase();return"any"===a||"adds"===a}function n(e){if(!e||"object"!=typeof e)return!1;let r=e.want;if(!r||"object"!=typeof r)return!1;if(1!==(Array.isArray(r.itemIds)?r.itemIds:[]).length)return!1;if(Number(r.robux)>0)return!1;let t=[...Array.isArray(r.tags)?r.tags:[],...Array.isArray(e?.tags)?e.tags:[]];if(t.length>0)for(let e of t)if(a(e))return!1;return!0}function u(e,r){let a=Array.isArray(e?.have?.itemIds)?e.have.itemIds:[],n=Array.isArray(e?.want?.itemIds)?e.want.itemIds:[],u=a.map(e=>t(e,r(Number(e)))),i=n.length?t(n[0],r(Number(n[0]))):null,s=u.reduce((e,r)=>e+(r.value||0),0),o=i&&i.value||0,l=Math.max(0,Number(e?.have?.robux)||0);return l>0&&(s+=l),{offer_items:u,wanted_item:i,have_total:s,want_total:o,have_robux:l}}function i(e,r){return r>0&&e>0&&(!(e<=1.025*r)&&(!(e>1.75*r)&&!(e-r<2e3)))}function s(e,r,t,a){if(!n(e))return null;if(null!=a&&String(e.userId)===String(a))return null;let s=Number(e.want.itemIds[0]);if(!Number.isFinite(s)||s<=0)return null;if(!r.has(String(s)))return null;let{offer_items:o,wanted_item:l,have_total:m,want_total:f,have_robux:_}=u(e,t);if(!l||f<=0)return null;if(!i(m,f))return null;let d=m-f,A=f>0?Math.round(d/f*100):0;return{adId:e.id,createdAt:e.createdAt,username:String(e.username||""),userId:e.userId,wantedItemId:s,wantedItem:l,offerItems:o,haveRobux:_,wantTags:Array.isArray(e?.want?.tags)?e.want.tags.slice():[],requestTags:Array.isArray(e?.tags)?e.tags.slice():[],haveTotal:m,wantTotal:f,overpayAmount:d,overpayPercent:A,matchedAt:Date.now()}}e.TradeAdNotificationsCore={WANT_BLOCKED_TAGS:r,is_blocked_want_tag:a,OVERPAY_MIN_RATIO:1.025,OVERPAY_MAX_RATIO:1.75,OVERPAY_MIN_DIFF:2e3,effective_value_from_row:function(e){if(!Array.isArray(e))return 0;let r=Number(e[2])||0,t=Number(e[3]),a=Number.isFinite(t)?t:0;return a>0?a:r},item_summary_from_row:t,passes_single_item_want_filter:n,summarize_ad_values:u,is_overpay_trade:i,build_match:s,scan_ads_for_matches:function(e,r,t,a){let n=[];if(!Array.isArray(e))return n;for(let u of e){let e=s(u,r,t,a);e&&n.push(e)}return n.sort((e,r)=>{let t=Number(e.createdAt)||0,a=Number(r.createdAt)||0;return a!==t?a-t:Number(r.overpayAmount)-Number(e.overpayAmount)}),n}}}("undefined"!=typeof globalThis?globalThis:self);