"use strict";exports.id=1188,exports.ids=[1188],exports.modules={1188:(t,e,i)=>{function n(t,e={}){let{maxContextTokens:i=4e3,maxContextCharacters:n,maxChunksPerSource:r=3,maxSources:l=5,mergeStrategy:o="concatenate"}=e,a=new Map;for(let e of t){let t=`${e.entityType}:${e.entityId}`;a.has(t)||a.set(t,[]),a.get(t).push(e)}let s=[],u=0,c=0;for(let{key:t,chunks:e}of Array.from(a.entries()).map(([t,e])=>({key:t,chunks:e.sort((t,e)=>e.similarity-t.similarity),bestSimilarity:Math.max(...e.map(t=>t.similarity))})).sort((t,e)=>e.bestSimilarity-t.bestSimilarity).slice(0,l)){let t;if(s.length>=l)break;let a=e.slice(0,r),d=a[0],p=d.metadata,h=(t="concatenate"===o?a.map(t=>t.contentText.trim()).filter(t=>t.length>0).join("\n\n"):a.map(t=>t.contentText.trim()).filter(t=>t.length>0).join("\n\n")).length,m=Math.ceil(h/4);if(n&&u+h>n||c+m>i)break;let y={sourceType:d.entityType,sourceId:d.entityId,title:p.product_title||p.page_title||p.title||void 0,url:p.product_url||p.page_url||p.url||void 0,content:t,chunkIds:a.map(t=>t.id),chunkIndices:a.map(t=>t.chunkIndex),sourceUpdatedAt:p.source_updated_at||void 0,similarity:Math.max(...a.map(t=>t.similarity))};s.push(y),u+=h,c+=m}return s}function r(t){if(0===t.length)return"";let e=t.map((t,e)=>{let i=[];t.title&&i.push(`Product: ${t.title}`),t.url&&i.push(`Product URL: ${t.url}`),t.sourceUpdatedAt&&i.push(`Updated: ${new Date(t.sourceUpdatedAt).toLocaleDateString()}`);let n=i.length>0?`[Product ${e+1}] ${i.join(" | ")}`:`[Source ${e+1}]`;return`${n}
${t.content}`});if(t.length>1){let i=t.filter(t=>"product"===t.sourceType).length;return`EXACT PRODUCT COUNT: Found exactly ${i} product${1!==i?"s":""} matching the query (this is the precise number from the database):

`+e.join("\n\n---\n\n")}return e.join("\n\n---\n\n")}i.d(e,{buildContextBlocks:()=>n,formatContextBlocks:()=>r})}};