PageSourceSearch

https://www.bloomengine.ai/_next/static/chunks/3268-06b707a0d0baa118.js

js bloomengine.ai collected 2026-10-05 15:28:20 UTC 12,846 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9ec12976-3193-446c-a28b-1f95cf31a0ab",e._sentryDebugIdIdentifier="sentry-dbid-9ec12976-3193-446c-a28b-1f95cf31a0ab")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3268],{23268:function(e,t,a){a.d(t,{keepaService:function(){return l}});let n=a(40257).env.KEEPA_API_KEY,r="https://api.keepa.com",l={async testConnection(){console.log("Checking token balance...");try{let e=await fetch("".concat(r,"/token?key=").concat(n)),t=await e.json();if(t.error)throw Error(t.error.message);return console.log("Available tokens:",t.tokensLeft),{success:!!t.tokensLeft&&t.tokensLeft>0,tokensLeft:t.tokensLeft||0,message:"Available tokens: ".concat(t.tokensLeft)}}catch(e){return console.error("Token check failed:",e),{success:!1,error:"Failed to verify Keepa API access"}}},async getCompetitorData(e){if(!(null==e?void 0:e.length))return console.error("No ASINs provided to Keepa service"),[];try{var t,a,l,i,o,s,c,u;console.log("Starting analysis for ".concat(e.length," ASINs (will use ").concat(e.length," tokens)"));let h=e.map(e=>e.replace(/[^A-Z0-9]/g,"")).filter(e=>10===e.length);if(!h.length)throw console.error("No valid ASINs after filtering:",e),Error("No valid ASINs provided");console.log("Requesting Keepa data for valid ASINs:",h);let d="".concat(r,"/product?key=").concat(n,"&domain=1&asin=").concat(h.join(","),"&stats=180"),g=await fetch(d);if(!g.ok){let e=await g.text();throw console.error("Keepa API error (".concat(g.status,"):"),e),Error("Keepa API error: ".concat(g.status))}let m=await g.json();if(console.log("Raw Keepa API response structure:",{hasProducts:!!m.products,productCount:null===(t=m.products)||void 0===t?void 0:t.length,firstProductKeys:(null===(a=m.products)||void 0===a?void 0:a[0])?Object.keys(m.products[0]):[],csvArrays:(null===(i=m.products)||void 0===i?void 0:null===(l=i[0])||void 0===l?void 0:l.csv)?Object.keys(m.products[0].csv):[]}),(null===(o=m.products)||void 0===o?void 0:o[0])&&console.log("First product CSV arrays:",{array3:null===(u=m.products[0].csv)||void 0===u?void 0:null===(c=u[3])||void 0===c?void 0:c.slice(0,10),csvKeys:Object.keys(m.products[0].csv||{})}),m.error)throw console.error("Keepa API returned an error:",m.error),Error(m.error.message||"Keepa API error");if(!(null===(s=m.products)||void 0===s?void 0:s.length))throw console.error("No product data received from Keepa"),Error("No product data received");return this.transformKeepaData(m.products)}catch(e){throw console.error("Keepa analysis error:",e),e}},transformKeepaData(e){return e.map(e=>{if(console.log("Processing product:",{asin:e.asin,hasCsvData:!!e.csv,csvArrays:e.csv?Object.keys(e.csv):[]}),e.csv){console.log("CSV array data exploration for "+e.asin+":");for(let t=0;t<5;t++)if(e.csv[t]){let a=e.csv[t].slice(0,10);console.log("  csv[".concat(t,"] (").concat(e.csv[t].length," values): "),a)}else console.log("  csv[".concat(t,"]: undefined or empty"))}if(!e.asin||!e.csv)return console.warn("Invalid product data:",{asin:e.asin}),{asin:e.asin||"unknown",status:"error",error:"Invalid product data",productData:{title:"Unknown Product",bsr:[],prices:[],salesEstimates:[]},analysis:{bsr:{trend:{direction:"stable",strength:0,confidence:0},stability:0,volatility:1,details:null},price:{trend:{direction:"stable",strength:0},stability:.65},competitivePosition:{score:0,factors:["Insufficient data"]}}};let t=this.normalizeTimeSeries(e.csv[3]||[]),a=this.normalizeTimeSeries(e.csv[0]||[]);console.log("PRICE DATA CHECK for "+e.asin+":",{rawPriceDataLength:e.csv[0]?e.csv[0].length:0,normalizedPriceDataPoints:a.length,firstFewPricePoints:a.slice(0,3)});let n=[];a.length<2&&(console.log("Trying alternative price data sources for "+e.asin),[1,2,16].forEach(t=>{if(e.csv[t]&&e.csv[t].length){let a=this.normalizeTimeSeries(e.csv[t]);a.length>n.length&&(n=a,console.log("Found better price data in csv[".concat(t,"]: ").concat(a.length," points")))}}));let r=n.length>a.length?n:a,l=this.normalizeTimeSeries(e.csv[11]||[]);console.log("Extracted time series:",{asin:e.asin,bsrPoints:t.length,pricePoints:r.length,salesPoints:l.length});let i=t.length>0?this.analyzeBSRTrend(t):{trend:{direction:"stable",strength:0,confidence:0},stability:0,volatility:1,details:null},o=r.length>0?this.analyzePriceTrend(r):{trend:{direction:"stable",strength:0},stability:.65},s=t.length>0?this.analyzeCompetitivePosition(e,t):{score:0,factors:["Insufficient BSR data"]};return console.log("Analysis results:",{asin:e.asin,hasBSRAnalysis:!!i,hasPriceAnalysis:!!o,hasCompetitivePosition:!!s}),{asin:e.asin,status:"complete",productData:{title:e.title||"Unknown Product",bsr:t,prices:r,salesEstimates:l},analysis:{bsr:i,price:o,competitivePosition:s}}})},normalizeTimeSeries(e){if(!(null==e?void 0:e.length))return[];let t=new Date("2011-01-01").getTime(),a=[];for(let n=0;n<e.length;n+=2){let r=e[n],l=e[n+1];if(r>=0&&l>=0){let e=t+6e4*r;a.push({timestamp:e,value:l})}}return a.sort((e,t)=>
1e.timestamp-t.timestamp),a},calculateVolatilityAndStability(e){if(e.length<2)return{stability:1,volatility:0,details:{consistencyScore:1,changeScore:0,outOfStockImpact:0}};let t=this.preprocessValues(e),a=this.calculateConsistencyScore(t),{changeScore:n,maxRelativeChange:r}=this.calculateChangeScore(t),l=this.calculateOutOfStockImpact(e),i=Math.max(0,Math.min(1,[.4*a,(1-n)*.3,(1-l)*.3].reduce((e,t)=>e+t,0))),o=1-i;return console.log("Volatility Analysis:",{inputValuesCount:e.length,cleanValuesCount:t.length,consistencyScore:a,changeScore:n,outOfStockImpact:l,finalStability:i,finalVolatility:o}),{stability:i,volatility:o,details:{consistencyScore:a,changeScore:n,outOfStockImpact:l}}},preprocessValues(e){if(e.length<5)return e;let t=[...e].sort((e,t)=>e-t),a=t[Math.floor(.25*t.length)],n=t[Math.floor(.75*t.length)],r=n-a,l=a-1.5*r,i=n+1.5*r;return e.filter(e=>e>=l&&e<=i)},calculateConsistencyScore(e){if(e.length<2)return 1;let t=e.reduce((e,t)=>e+t,0)/e.length;return Math.max(0,1-Math.sqrt(e.reduce((e,a)=>e+Math.pow(a-t,2),0)/e.length)/t*2)},calculateChangeScore(e){if(e.length<2)return{changeScore:0,maxRelativeChange:0};let t=[];for(let a=1;a<e.length;a++){let n=Math.abs((e[a]-e[a-1])/e[a-1]);t.push(n)}let a=Math.max(...t);return{changeScore:1-Math.exp(-a),maxRelativeChange:a}},calculateOutOfStockImpact(e){if(e.length<10)return 0;let t=[...e].sort((e,t)=>e-t),a=t[Math.floor(.25*t.length)];return Math.min(1,e.filter(e=>e<.5*a).length/e.length)},calculateBSRTimelineScore(e){let t;if(e.length<10)return{score:0,timeInRanges:{under10k:0,under25k:0,under50k:0,under100k:0,under250k:0,above250k:0},volatilityPenalty:0,finalScore:0};let a={under10k:0,under25k:0,under50k:0,under100k:0,under250k:0,above250k:0},n=0,r=[...e].sort((e,t)=>e.timestamp-t.timestamp);for(let e=1;e<r.length;e++){let t=Math.max(0,r[e].timestamp-r[e-1].timestamp);if(t>2592e6)continue;let l=(r[e].value+r[e-1].value)/2;l<1e4?a.under10k+=t:l<25e3?a.under25k+=t:l<5e4?a.under50k+=t:l<1e5?a.under100k+=t:l<25e4?a.under250k+=t:a.above250k+=t,n+=t}let l={under10k:a.under10k/n*100,under25k:a.under25k/n*100,under50k:a.under50k/n*100,under100k:a.under100k/n*100,under250k:a.under250k/n*100,above250k:a.above250k/n*100};t=0+.9*Math.min(l.under10k,100)+.75*Math.min(l.under25k,100)+.6*Math.min(l.under50k,
1100)-.2*l.under100k-.4*l.under250k-.6*l.above250k;let i=this.calculateVolatilityPenalty(r);return{score:Math.max(0,Math.min(100,t)),timeInRanges:l,volatilityPenalty:i,finalScore:Math.max(0,Math.min(100,t-i))}},calculateVolatilityPenalty(e){let t=0;for(let a=1;a<e.length;a++)Math.abs((e[a].value-e[a-1].value)/e[a-1].value)>.5&&t++;return Math.min(10,2*t)},getPerformanceSummary(e){let t=e.threeMonth.finalScore,a=e.sixMonth.finalScore,n=e.twelveMonth.finalScore;return t>=90&&a>=85&&n>=80?"Exceptional":t>=80&&a>=75&&n>=70?"Highly Consistent":t>=70&&a>=65&&n>=60?"Consistent":t>=60&&a>=55&&n>=50?"Moderately Consistent":t>=50&&a>=45&&n>=40?"Inconsistent":t<40||a<35||n<30?"Highly Volatile":t<n&&a<n?"Declining":"Extremely Volatile"},analyzeBSRTrend(e){if(e.length<2)return{trend:{direction:"stable",strength:0,confidence:0},stability:0,volatility:1,details:null};let t=e.map(e=>e.value),a=this.calculateTrend(t),n=this.calculateStability(t);return{trend:a,stability:n,volatility:1-n,details:null}},analyzePriceTrend(e){if(!e||!Array.isArray(e)||e.length<2)return console.log("Price stability defaulting to 65% due to insufficient price history data points:",e?e.length:0),{trend:{direction:"stable",strength:0},stability:.65};let t=e.filter(e=>e.value>0);if(t.length<2)return console.log("Price stability defaulting to 65% due to insufficient valid price points:",t.length),{trend:{direction:"stable",strength:0},stability:.65};let a=[...t.map(e=>({timestamp:e.timestamp,value:e.value/100}))].sort((e,t)=>e.timestamp-t.timestamp),n=a[0].timestamp,r=(a[a.length-1].timestamp-n)/864e5,l=a;if(r<365){let e=n+2592e6;(l=a.filter(t=>t.timestamp>=e)).length<5&&(l=a)}let i={};l.forEach(e=>{let t=Math.round(e.value);i[t]||(i[t]=[]),i[t].push(e)});let o=[];
1Object.keys(i).forEach(e=>{let t=i[e];if(t.length<2)o.push(t[0]);else{let e=[...t].sort((e,t)=>e.timestamp-t.timestamp),a=!1;for(let t=0;t<e.length-1;t++)if((e[t+1].timestamp-e[t].timestamp)/864e5>=3){a=!0;break}if(a)o.push(...t);else{let t=e[Math.floor(e.length/2)];o.push(t)}}});let s=o.length>=5?o:l,c=s.map(e=>e.value);console.log("Price analysis for product with data points:",{totalPoints:e.length,validPoints:t.length,afterGracePeriod:l.length,afterSustainedFilter:s.length,minPrice:Math.min(...c),maxPrice:Math.max(...c),avgPrice:c.reduce((e,t)=>e+t,0)/c.length,listingAgeInDays:r.toFixed(1)});let u=this.calculateTrend(c),h=c.reduce((e,t)=>e+t,0)/c.length,d=Math.min(...c),g=Math.max(...c),m=h>0?(g-d)/h:0;console.log("Price stability calculation:",{priceRangeRatio:m.toFixed(3),minPrice:d.toFixed(2),maxPrice:g.toFixed(2),meanPrice:h.toFixed(2)});let f=0;if(f=0===m?1:m<.01?.97:m<.03?.93:m<.05?.9:m<.1?.85:m<.15?.78:m<.2?.73:m<.25?.68:m<.3?.63:m<.4?.57:m<.5?.5:m<.75?.43:.35,r<90){let e=Math.max(0,.25-r/90*.25);f=Math.min(.95,f+e),console.log("Applied new listing boost of ".concat(e.toFixed(2)," for ").concat(r.toFixed(0)," day old listing"))}let p=f,y=0;return m>0&&(p=Math.max(.35,Math.min(.99,f+(y=.03*Math.random()-.015)))),console.log("Final Price stability calculation:",{baseScore:f.toFixed(2),randomFactor:y.toFixed(3),finalScore:p.toFixed(2),finalPercent:(100*p).toFixed(1)+"%",appliedGracePeriod:r<365,appliedSustainedFilter:o.length>=5}),{trend:{direction:u.direction,strength:u.strength},stability:p}},calculateTrend(e){let t=e.slice(0,Math.floor(e.length/2)),a=e.slice(Math.floor(e.length/2)),n=t.reduce((e,t)=>e+t,0)/t.length,r=(a.reduce((e,t)=>e+t,0)/a.length-n)/n;return{direction:r>.05?"up":r<-.05?"down":"stable",strength:Math.min(Math.abs(r),1),confidence:.8}},calculateStability(e){if(e.length<2)return 1;let t=e.reduce((e,t)=>e+t,0)/e.length,a=Math.sqrt(e.reduce((e,a)=>e+Math.pow(a-t,2),0)/e.length),n=e.filter(e=>e<5e4).length/e.length,r=e.filter(e=>e<1e5).length/e.length;if(0===n)return .1;let l=a/t,i=Math.max(0,1-l/3);i=n>.95?Math.min(1,(i=Math.max(i,.85))+.15):n>.9?Math.min(1,(i=Math.max(i,.75))+.1):n>.8?Math.min(1,(i=Math.max(i,.65))+.05):r>.9?Math.max(i,.6):n>.5?Math.max(i,.4):r>.5?Math.max(i,.3):Math.min(i,.2);let o=this.detectSeasonalImprovements(e);return i=Math.min(1,i+o),console.log("BSR Stability Calculation:",{mean:t,stdDev:a,cov:l,percentUnder50k:n,percentUnder100k:r,rawStabilityScore:Math.max(0,1-l/3),consistencyBonus:n>.95?.15:n>.9?.1:n>.8?.05:0,seasonalityAdjustment:o,finalScore:i}),i},detectSeasonalImprovements(e){if(e.length<60)return 0;let t=[...e].sort((e,t)=>e-t);return t[Math.floor(.25*e.length)]<.5*t[Math.floor(.5*e.length)]?.15:0},detectSeasonality:e=>!1,analyzeCompetitivePosition(e,t){let a=t.reduce((e,t)=>e+t.value,0)/t.length;return{score:Math.max(1,Math.min(10,10-Math.log10(a))),factors:["Average BSR: ".concat(Math.round(a).toLocaleString()),"Score based on BSR performance"]}},calculateVolatility(e){if(e.length<2)return 0;let t=e.reduce((e,t)=>e+t,0)/e.length;return Math.min(Math.sqrt(e.reduce((e,a)=>e+Math.pow(a-t,2),0)/e.length)/t/2,1)},getEmptyTimelineScore:()=>({score:0,finalScore:0,timeInRanges:{under10k:0,under25k:0,under50k:0,under100k:0,under250k:0,above250k:0},volatilityPenalty:0}),getStabilityDetails(e){let t=100*e;return t>=90?{category:"Exceptionally Stable",color:"text-emerald-500"}:t>=75?{category:"Very Stable",color:"text-green-500"}:t>=60?{category:"Moderately Stable",color:"text-yellow-500"}:t>=40?{category:"Somewhat Volatile",color:"text-orange-500"}:{category:"Highly Volatile",color:"text-red-500"}}}}}]);

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.