"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveInventoryAddressIntent = resolveInventoryAddressIntent; const inventoryLifecycleCueHelpers_1 = require("./inventoryLifecycleCueHelpers"); function hasInventoryAccount41Anchor(text) { return /(?:СЃС‡[её]С‚(?:Р°|Рµ|Сѓ)?|счет(?:Р°|Рµ|Сѓ)?)\D{0,12}41(?:[.,]0?1)?/iu.test(text) || /41(?:[.,]0?1)?\D{0,12}(?:СЃС‡[её]С‚(?:Р°|Рµ|Сѓ)?|счет(?:Р°|Рµ|Сѓ)?)/iu.test(text); } function hasInventoryAsOfCue(text) { return /(?:сейчас|текущ|РЅР°\s+дату|РїРѕ\s+состоянию|срез|РЅР°\s+конец|date|as\s+of|current|now|today)/iu.test(text); } function hasPlainRussianInventoryOnHandSignal(text) { const normalized = String(text ?? "").toLowerCase().replace(/ё/g, "е"); if (!normalized) { return false; } const hasStockCue = /(?:остатк|склад|товар(?:ы|ов)?|номенклатур|позици|на\s+складе|по\s+складу)/iu.test(normalized); if (!hasStockCue) { return false; } const hasRequestCue = /(?:какие|какой|какая|что|покажи|показать|получить|дай|выведи|чекни|посмотри|есть\s+ли)/iu.test(normalized); const hasSnapshotCue = /(?:на\s+(?:дату|сегодня|сейчас|март|апрел|май|мая|июн|июл|август|сентябр|октябр|ноябр|декабр|январ|феврал)|\b(?:19|20)\d{2}\b)/iu.test(normalized); return hasRequestCue && (hasSnapshotCue || /остатк/iu.test(normalized)); } function hasInventoryOnHandSignal(text) { const hasColloquialStockSnapshotCue = /(?:что|С‡[еёо])\s+(?:Сѓ\s+нас\s+)?РЅР°\s+склад(?:Рµ|Сѓ|РѕРј|ах)(?=$|[\s,.;:!?])/iu.test(text); const hasStockStateCue = /(?:(?:что|С‡[еёо])\s+там\s+РЅР°\s+склад(?:Рµ|Сѓ|РѕРј|ах)|(?:что|С‡[еёо]).*РїСЂРѕРёСЃС…РѕРґ(?:РёС‚|ило|ящее).*(?:РЅР°\s+)?склад(?:Рµ|Сѓ|РѕРј|ах)|РїСЂРѕРёСЃС…РѕРґ(?:РёС‚|ило|ящее)\s+РЅР°\s+склад(?:Рµ|Сѓ|РѕРј|ах)|ситуац(?:РёСЏ|РёРё)\s+РЅР°\s+склад(?:Рµ|Сѓ|РѕРј|ах)|обстановк(?:Р°|Рё)\s+РЅР°\s+склад(?:Рµ|Сѓ|РѕРј|ах)|what(?:'s| is)?\s+(?:there\s+)?(?:on|in)\s+(?:the\s+)?(?:warehouse|stock)|what(?:'s| is)?\s+happening\s+(?:on|in)\s+(?:the\s+)?(?:warehouse|stock))/iu.test(text); const hasAccount41Anchor = hasInventoryAccount41Anchor(text); const hasStockLexeme = /(?:склад(?:Рµ|Сѓ|РѕРј|С‹|РѕРІ)?|warehouse|stock(?:room)?|inventory|on[\s-]?hand)/iu.test(text); const hasPlainRussianRootCue = hasPlainRussianInventoryOnHandSignal(text); if (!hasStockLexeme && !hasAccount41Anchor && !hasPlainRussianRootCue) { return false; } if (hasInventoryProvenanceSignalV2(text) || hasInventoryPurchaseDocumentsSignalV2(text) || hasInventorySaleTraceSignalV2(text) || hasInventoryAgingSignal(text) || hasInventoryPurchaseToSaleChainSignal(text)) { return false; } const hasGoodsLexeme = /(?:товар(?:С‹|РѕРІ|РѕРј|Р°|ные)?|номенклатур|материал(?:С‹|РѕРІ|Р°|ам)?|item(?:s)?|sku|product(?:s)?)/iu.test(text); const hasBalanceLexeme = /(?:леж(?:РёС‚|ат)|есть|числ(?:РёС‚(?:СЃСЏ|СЃСЊ)|ятся)|остат(?:РѕРє|РєРё)|срез|РЅР°\s+дат|РїРѕ\s+состоянию|РЅР°\s+конец|РїСЂРѕРёСЃС…РѕРґ(?:РёС‚|ило|ящее)|ситуац(?:РёСЏ|РёРё)|обстановк(?:Р°|Рё)|today|now|current|as\s+of)/iu.test(text); const hasRequestCue = /(?:покажи|показать|выведи|дай|какие|что|С‡[еёо]|какой|сколько|проверь|проверить|чекни|check|show|list|which|what)/iu.test(text); if (hasAccount41Anchor && (hasGoodsLexeme || hasBalanceLexeme || hasRequestCue || hasInventoryAsOfCue(text))) { return true; } if (hasPlainRussianRootCue) { return true; } return (hasGoodsLexeme || hasBalanceLexeme || hasColloquialStockSnapshotCue || hasStockStateCue) && (hasRequestCue || hasBalanceLexeme || hasColloquialStockSnapshotCue || hasStockStateCue); } function hasSelectedObjectInventoryCue(text) { const value = String(text ?? ""); if (/(?:по\s+выбранному\s+объекту|по\s+выбранной\s+позиции|по\s+этой\s+позиции|по\s+этому\s+товару|по\s+нему|по\s+ней|по\s+ним|по\s+нему\s+же|по\s+ней\s+же|selected\s+object)/iu.test(value)) { return true; } return /(?:РїРѕ\s+выбранному\s+объекту|РїРѕ\s+выбранной\s+позиции|РїРѕ\s+этой\s+позиции|РїРѕ\s+этому\s+товару|РїРѕ\s+нему|РїРѕ\s+ней|РїРѕ\s+РЅРёРј|РїРѕ\s+нему\s+Р¶Рµ|РїРѕ\s+ней\s+Р¶Рµ|selected\s+object)/iu.test(String(text ?? "")); } function hasSelectedObjectInventoryProvenanceSignal(text) { return hasSelectedObjectInventoryCue(text) && (0, inventoryLifecycleCueHelpers_1.hasInventorySupplierCue)(text); } function hasSelectedObjectInventoryPurchaseDocumentsSignal(text) { const value = String(text ?? ""); if (hasSelectedObjectInventoryCue(value) && /(?:по\s+каким\s+документам\s+(?:это|его|этот\s+товар|эту\s+позицию)?\s*купили|по\s+каким\s+документам\s+(?:был\s+)?куплен|какими\s+документами\s+(?:это|его|этот\s+товар|эту\s+позицию)?\s*купили|какими\s+документами\s+(?:был\s+)?куплен|покажи\s+документы\s+по\s+(?:этой\s+позиции|этому\s+товару|ней|нему)|документы\s+по\s+(?:этой\s+позиции|этому\s+товару|ней|нему)|purchase\s+documents|documents\s+of\s+purchase|through\s+which\s+documents)/iu.test(value)) { return true; } const hasPurchaseDocumentsCue = /(?:РїРѕ\s+каким\s+документам\s+(?:это|его|этот\s+товар|эту\s+позицию)\s+купили|РїРѕ\s+каким\s+документам\s+(?:был\s+)?куплен|какими\s+документами\s+(?:это|его|этот\s+товар|эту\s+позицию)\s+купили|какими\s+документами\s+(?:был\s+)?куплен|purchase\s+documents|documents\s+of\s+purchase|through\s+which\s+documents)/iu.test(text) || /(?:(?:РїРѕ\s+каким|какими)\s+РґРѕРє[Р°-СЏС‘]*[\s\S]{0,80}(?:РєСѓРїРёР»|куплен)|РґРѕРє(?:Рё|умент[Р°-СЏС‘]*)[\s\S]{0,80}(?:РїРѕ\s+(?:РЅРёРј|ней|нему|этой\s+позиции|этому\s+товару)|операци)|(?:РїРѕ\s+(?:РЅРёРј|ней|нему|этой\s+позиции|этому\s+товару))[\s\S]{0,80}РґРѕРє(?:Рё|умент[Р°-СЏС‘]*))/iu.test(text); return hasSelectedObjectInventoryCue(text) && hasPurchaseDocumentsCue; } function hasSelectedObjectInventorySaleTraceSignal(text) { return hasSelectedObjectInventoryCue(text) && (0, inventoryLifecycleCueHelpers_1.hasInventorySaleCue)(text); } function hasSelectedObjectInventoryProfitabilitySignal(text) { return hasSelectedObjectInventoryCue(text) && (0, inventoryLifecycleCueHelpers_1.hasInventoryProfitabilityCue)(text); } function hasInventoryProvenanceSignalV2(text) { const value = String(text ?? ""); const hasPlainItemCue = /(?:товар|номенклатур|sku|item|product|остат|склад)/iu.test(value); const hasPlainSupplierCue = (0, inventoryLifecycleCueHelpers_1.hasInventorySupplierCue)(value) || /(?:кем\s+поставлен|кто\s+(?:это|его|этот\s+товар|эту\s+позицию)?\s*поставил)/iu.test(value); const hasPlainPurchaseCue = /(?:куплен(?:ы|а|о)?|закупк|происхожд|откуда|где\s+(?:мы\s+)?купили|поставлен(?:ы|а)?|purchase\s+provenance|purchase\s+date)/iu.test(value) || (0, inventoryLifecycleCueHelpers_1.hasInventoryPurchaseStem)(value); if (hasPlainItemCue && hasPlainSupplierCue && hasPlainPurchaseCue) { return true; } const hasItemCue = /(?:товар|номенклатур|sku|item|product|остат(?:РѕРє|РєРё)|склад)/iu.test(text); const hasSupplierCue = (0, inventoryLifecycleCueHelpers_1.hasInventorySupplierCue)(text) || /кем\s+поставлен/iu.test(text); const hasPurchaseCue = /(?:куплен(?:С‹|Р°|Рѕ)?|закупк|происхождени|откуда|РіРґРµ\s+(?:РјС‹\s+)?купили(?:\s+(?:это|его|товар|позицию))?|РіРґРµ\s+куплено|РєРѕРіРґР°\s+был\s+куплен|РєРѕРіРґР°\s+куплен|дата\s+закупк|кто\s+(?:нам\s+)?поставил|кем\s+поставлен|поставлен(?:С‹|Р°)?|purchase\s+provenance|purchase\s+date)/iu.test(text) || (0, inventoryLifecycleCueHelpers_1.hasInventoryPurchaseStem)(text); return hasItemCue && hasSupplierCue && hasPurchaseCue; } function hasInventoryPurchaseDateSignal(text) { const value = String(text ?? ""); const hasItemCue = /(?:\u0442\u043e\u0432\u0430\u0440|\u043f\u043e\u0437\u0438\u0446|\u043d\u043e\u043c\u0435\u043d\u043a\u043b\u0430\u0442\u0443\u0440|sku|item|product)/iu.test(value) || /(?:товар|номенклатур|sku|item|product)/iu.test(value) || hasSelectedObjectInventoryCue(value); const hasPurchaseDateCue = /(?:\u043a\u043e\u0433\u0434\u0430\s+(?:\u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e\s+)?(?:\u043c\u044b\s+)?\u043a\u0443\u043f\u0438\u043b\u0438|\u043a\u043e\u0433\u0434\u0430\s+\u0431\u044b\u043b(?:\u0430|\u0438|\u043e)?\s+\u043a\u0443\u043f\u043b\u0435\u043d|\u043a\u043e\u0433\u0434\u0430\s+\u043a\u0443\u043f\u043b\u0435\u043d|\u0434\u0430\u0442\u0430\s+\u0437\u0430\u043a\u0443\u043f\u043a|purchase\s+date)/iu.test(value) || /(?:РєРѕРіРґР°\s+(?:примерно\s+)?(?:РјС‹\s+)?купили|РєРѕРіРґР°\s+был\s+куплен|РєРѕРіРґР°\s+куплен|дата\s+закупк|purchase\s+date)/iu.test(value) || /(?:РєРѕРіРґР°\s+был(?:Р°|Рё|Рѕ)?\s+закупк\w*|РєРѕРіРґР°\s+закупк\w*)/iu.test(value); return hasItemCue && hasPurchaseDateCue; } function hasInventoryPurchaseDocumentsSignalV2(text) { const value = String(text ?? ""); const hasPlainItemCue = /(?:товар|номенклатур|sku|item|product)/iu.test(value); const hasPlainPurchaseDocCue = /(?:по\s+каким\s+документам\s+(?:был\s+)?куплен|по\s+каким\s+документам\s+(?:это|его|этот\s+товар|эту\s+позицию)?\s*купили|какими\s+документами\s+(?:был\s+)?куплен|какими\s+документами\s+(?:это|его|этот\s+товар|эту\s+позицию)?\s*купили|документ[а-яё]*\s+закупк|purchase\s+documents|documents\s+of\s+purchase|through\s+which\s+documents)/iu.test(value); if (hasPlainItemCue && hasPlainPurchaseDocCue) { return true; } const hasItemCue = /(?:товар|номенклатур|sku|item|product)/iu.test(text); const hasPurchaseDocCue = /(?:РїРѕ\s+каким\s+документам\s+был\s+куплен|РїРѕ\s+каким\s+документам\s+куплен|какими\s+документами\s+был\s+куплен|документ(?:ам|С‹)\s+закупк|purchase\s+documents|documents\s+of\s+purchase|through\s+which\s+documents)/iu.test(text); return hasItemCue && hasPurchaseDocCue; } function hasInventorySaleTraceSignalV2(text) { const value = String(text ?? ""); const hasPlainItemCue = /(?:товар|номенклатур|позици|продукци|sku|item|product)/iu.test(value); const hasPlainTraceCue = /(?:кому\s+(?:в\s+итоге\s+)?(?:мы\s+)?(?:продали|реализовали|впарили)|кому\s+(?:был[аио]?|были)?\s*(?:продан|реализован)|кто\s+купил|покупател|buyer|sale\s+trace|trace\s+of\s+sale)/iu.test(value); if (hasPlainItemCue && hasPlainTraceCue) { return true; } const hasItemCue = /(?:товар|номенклатур|sku|item|product|позици(?:СЏ|СЋ|Рё)|продукци(?:СЏ|СЋ|Рё))/iu.test(text); const hasTraceCue = /(?:РєРѕРјСѓ\s+(?:РІ\s+итоге\s+)?(?:РјС‹\s+)?продали|РєРѕРјСѓ\s+был\s+продан|РєСѓРґР°\s+(?:РІ\s+итоге\s+)?(?:РјС‹\s+)?продали(?:\s+(?:это|его|товар|позицию))?|РєСѓРґР°\s+(?:была\s+)?реализована\s+(?:позиция|номенклатура|продукция)|кто\s+РєСѓРїРёР»|buyer|sale\s+trace|trace\s+of\s+sale|через\s+какие\s+документы\s+РїСЂРѕС€[её]Р»\s+путь\s+товара|закупк.*склад.*продаж|purchase[\s-]?to[\s-]?sale|purchase\s*->\s*warehouse\s*->\s*sale|purchase\s*->\s*stock\s*->\s*sale)/iu.test(text); return hasItemCue && hasTraceCue; } function hasInventorySupplierStockOverlapSignal(text) { const value = String(text ?? ""); const hasPlainDirectSingleItemSupplierQuestion = /(?:от\s+(?:какого|кого)\s+поставщик[а-яё]*\s+куплен\s+(?:товар|номенклатур|позици)|от\s+кого\s+куплен\s+(?:товар|номенклатур|позици))/iu.test(value); if (hasPlainDirectSingleItemSupplierQuestion) { return false; } const hasPlainSupplierCue = /(?:поставщик|supplier|vendor)/iu.test(value); const hasPlainStockCue = /(?:склад|остат|леж[аи][т]?|висят|сейчас\s+еще|сейчас\s+ещё|на\s+дату|current\s+stock|stock\s+overlap)/iu.test(value); const hasPlainUnresolvedSupplierLink = /(?:без\s+понятн[а-яё]*\s+привязк[а-яё]*\s+к\s+поставщик|без\s+привязк[а-яё]*\s+к\s+поставщик|unresolved\s+supplier\s+link)/iu.test(value); if ((hasPlainSupplierCue && hasPlainStockCue) || (hasPlainUnresolvedSupplierLink && hasPlainStockCue)) { return true; } const hasDirectSingleItemSupplierQuestion = /(?:РѕС‚\s+какого\s+поставщика\s+куплен\s+(?:товар|номенклатур(?:Р°|Сѓ|С‹)|позици(?:СЏ|СЋ|Рё))|РѕС‚\s+РєРѕРіРѕ\s+куплен\s+(?:товар|номенклатур(?:Р°|Сѓ|С‹)|позици(?:СЏ|СЋ|Рё)))/iu.test(text); if (hasDirectSingleItemSupplierQuestion) { return false; } const hasSupplierCue = /(?:поставщик|supplier|vendor|РѕС‚\s+поставщика|Сѓ\s+поставщика)/iu.test(text); const hasStockCue = /(?:склад|остат(?:РѕРє|РєРµ|РєРѕРІ)|лежат|лежит|сейчас\s+еще|сейчас\s+ещ[её]|РЅР°\s+дату|РїРѕ\s+состоянию\s+РЅР°\s+дату|current\s+stock|stock\s+overlap|что\s+сейчас\s+лежит)/iu.test(text); return hasSupplierCue && hasStockCue; } function hasInventoryAgingSignal(text) { const value = String(text ?? ""); const hasPlainResidueCue = /(?:остат|склад|stock\s+residue|stock\s+balance)/iu.test(value); const hasPlainAgingCue = /(?:стар(?:ые|ым|ых)\s+закупк|очень\s+давно|давно\s+(?:куплен|приобретен|приобретён)|закуплен[а-яё]*\s+задолго\s+до|задолго\s+до(?:\s+\d{4}-\d{2}-\d{2})?|возраст\s+(?:остатк|закупк)|aging\s+by\s+purchase\s+date|old\s+purchase|old\s+purchases|old\s+stock|very\s+old\s+stock|very\s+old\s+purchase)/iu.test(value); if (hasPlainAgingCue || (hasPlainResidueCue && /(?:давно|задолго\s+до|стар(?:ые|ым|ых)\s+закупк)/iu.test(value))) { return true; } const hasResidueCue = /(?:остат(?:РѕРє|РєРё)|РІ\s+остатке|среди\s+текущих\s+остатков|РЅР°\s+складе|stock\s+residue|stock\s+balance)/iu.test(text); const hasAgingCue = /(?:стар(?:ые|ым|ых)\s+закупк|стары(?:Рј|С…)\s+закупк(?:ам|Рё|ах)|относит(?:СЃСЏ|СЃСЏ\s+ли)?\s+.*\s+Рє\s+старым\s+закупк|закупал(?:РёСЃСЊ|СЃСЏ)\s+очень\s+давно|очень\s+давно|давно\s+куплен|давно\s+приобретен|куплен\s+задолго\s+РґРѕ(?:\s+даты)?|закуплен(?:С‹|Р°)?\s+давно|приобретен\s+давно|задолго\s+РґРѕ(?:\s+даты)?|возраст\s+остатк|возраст\s+закупк|aged?\s+stock|old\s+purchase|old\s+purchases|old\s+stock|bought\s+long\s+ago|purchased\s+long\s+ago|aging\s+by\s+purchase\s+date|very\s+old\s+stock|very\s+old\s+purchase|old\s+procurement|older\s+purchases|aged\s+items|old\s+goods)/iu.test(text); return hasAgingCue || (hasResidueCue && /(?:давно\s+куплен|давно\s+приобретен|задолго\s+РґРѕ)/iu.test(text)); } function hasInventoryPurchaseToSaleChainSignal(text) { const value = String(text ?? ""); const hasPlainItemCue = /(?:товар|номенклатур|позици|sku|item|product)/iu.test(value); const hasPlainChainCue = /(?:закупк[а-яё]*\s*->\s*склад\s*->\s*продаж|через\s+какие\s+документы\s+прош[её]л\s+путь|цепочк[а-яё]*\s+движен|документально\s+подтвержденн[а-яё]*\s+цепочк|supplier\s*->\s*item\s*->\s*(?:buyer|customer)|supplier\s+to\s+buyer|supplier\s+to\s+item\s+to\s+buyer|purchase[\s-]?to[\s-]?sale|purchase\s*->\s*(?:warehouse|stock)\s*->\s*sale)/iu.test(value) || value.includes("->"); if (hasPlainItemCue && hasPlainChainCue) { return true; } const hasItemCue = /(?:товар|номенклатур|sku|item|product)/iu.test(text); const hasChainCue = /(?:закупк.*склад.*продаж|purchase[\s-]?to[\s-]?sale|purchase\s*->\s*(?:warehouse|stock)\s*->\s*sale|закупка\s*->\s*склад\s*->\s*продажа|цепочк[аи]\s+движен|документально\s+подтвержденн\w+\s+цепочк|supplier\s*->\s*item\s*->\s*(?:buyer|customer)|supplier\s+to\s+buyer|supplier\s+to\s+item\s+to\s+buyer)/iu.test(text) || text.includes("->"); return hasItemCue && hasChainCue; } function hasInventorySupplierToBuyerChainSignal(text) { const value = String(text ?? ""); const hasPlainSupplierCue = /(?:поставщик|supplier|vendor)/iu.test(value); const hasPlainBuyerCue = /(?:покупател|buyer|customer|client)/iu.test(value); const hasPlainItemCue = /(?:товар|номенклатур|sku|item|product)/iu.test(value); const hasPlainChainCue = /(?:документально\s+подтвержденн[а-яё]*\s+цепочк|поставщик\s*->\s*товар\s*->\s*покупател|supplier\s*->\s*item\s*->\s*(?:buyer|customer)|supplier\s*->\s*buyer|supplier\s+to\s+buyer|supplier\s+to\s+item\s+to\s+buyer)/iu.test(value) || value.includes("->"); if (hasPlainSupplierCue && hasPlainBuyerCue && hasPlainItemCue && hasPlainChainCue) { return true; } const hasSupplierCue = /(?:поставщик|supplier|vendor)/iu.test(text); const hasBuyerCue = /(?:покупател|buyer|customer|client)/iu.test(text); const hasItemCue = /(?:товар|номенклатур|sku|item|product)/iu.test(text); const hasChainCue = /(?:документально\s+подтвержденн\w+\s+цепочк|supplier\s*->\s*item\s*->\s*buyer|supplier\s*->\s*item\s*->\s*customer|supplier\s*->\s*buyer|supplier\s+to\s+buyer|supplier\s+to\s+buyer\s+chain|supplier\s+to\s+item\s+to\s+buyer|поставщик\s*->\s*товар\s*->\s*покупател|поставщик\s*->\s*товар\s*->\s*клиент|поставщик\s*->\s*товар\s*->\s*покупатель|поставщик\s+Рє\s+покупател|поставщик\s+Рє\s+клиент|поставщик\s+Рє\s+товару\s+Рё\s+покупателю)/iu.test(text) || text.includes("->"); return hasSupplierCue && hasBuyerCue && hasItemCue && hasChainCue; } function resolveInventoryAddressIntent(text) { if (/(?:старым\s+закупк(?:ам|Рё|ах)|относится\s+ли\s+.*\s+Рє\s+старым\s+закупк(?:ам|Рё|ах)|очень\s+давно|давно\s+куплен|давно\s+приобретен|old\s+stock|old\s+purchase|aging\s+by\s+purchase\s+date)/iu.test(text)) { return { intent: "inventory_aging_by_purchase_date", confidence: "high", reasons: ["inventory_aging_signal_detected_strong"] }; } if (hasInventoryAccount41Anchor(text) && hasInventoryAsOfCue(text)) { return { intent: "inventory_on_hand_as_of_date", confidence: "high", reasons: ["inventory_account_41_as_of_date_signal_detected"] }; } if (/(?:без\s+понятн(?:РѕР№|РѕРіРѕ)\s+РїСЂРёРІСЏР·Рє(?:Рё|Р°)\s+Рє\s+поставщик|без\s+РїСЂРёРІСЏР·Рє(?:Рё|Р°)\s+Рє\s+поставщик|unresolved\s+supplier\s+link)/iu.test(text)) { return { intent: "inventory_supplier_stock_overlap_as_of_date", confidence: "medium", reasons: ["inventory_unresolved_provenance_signal_detected"] }; } if (hasInventorySupplierStockOverlapSignal(text)) { return { intent: "inventory_supplier_stock_overlap_as_of_date", confidence: "medium", reasons: ["inventory_supplier_stock_overlap_signal_detected"] }; } if (/(?:supplier\s*->\s*buyer|supplier\s+to\s+buyer|supplier\s+to\s+buyer\s+chain|поставщик\s+Рє\s+покупателю|поставщик\s*->\s*товар\s*->\s*покупател|документально\s+подтвержденн\w+\s+цепочк)/iu.test(text) && /(?:поставщик|supplier|vendor)/iu.test(text) && /(?:покупател|buyer|customer|client)/iu.test(text) && /(?:товар|номенклатур|sku|item|product)/iu.test(text)) { return { intent: "inventory_purchase_to_sale_chain", confidence: "high", reasons: ["inventory_supplier_to_buyer_chain_signal_detected_strong"] }; } if (hasInventoryPurchaseToSaleChainSignal(text)) { return { intent: "inventory_purchase_to_sale_chain", confidence: "medium", reasons: ["inventory_purchase_to_sale_chain_signal_detected"] }; } if (hasInventoryAgingSignal(text)) { return { intent: "inventory_aging_by_purchase_date", confidence: "medium", reasons: ["inventory_aging_signal_detected"] }; } if (hasSelectedObjectInventoryProvenanceSignal(text)) { return { intent: "inventory_purchase_provenance_for_item", confidence: "medium", reasons: ["inventory_selected_object_provenance_signal_detected"] }; } if (hasInventoryProvenanceSignalV2(text)) { return { intent: "inventory_purchase_provenance_for_item", confidence: "medium", reasons: ["inventory_provenance_signal_detected"] }; } if (hasInventoryPurchaseDateSignal(text)) { return { intent: "inventory_purchase_provenance_for_item", confidence: "medium", reasons: ["inventory_purchase_date_signal_detected"] }; } if ((text.includes("по этой позиции") || text.includes("по этому товару")) && (text.includes("когда была закупка") || text.includes("когда купили"))) { return { intent: "inventory_purchase_provenance_for_item", confidence: "medium", reasons: ["inventory_purchase_date_signal_detected"] }; } if (hasSelectedObjectInventoryPurchaseDocumentsSignal(text)) { return { intent: "inventory_purchase_documents_for_item", confidence: "medium", reasons: ["inventory_selected_object_purchase_documents_signal_detected"] }; } if (hasInventoryPurchaseDocumentsSignalV2(text)) { return { intent: "inventory_purchase_documents_for_item", confidence: "medium", reasons: ["inventory_purchase_documents_signal_detected"] }; } if (hasSelectedObjectInventoryProfitabilitySignal(text)) { return { intent: "inventory_profitability_for_item", confidence: "medium", reasons: ["inventory_selected_object_profitability_signal_detected"] }; } if (hasSelectedObjectInventorySaleTraceSignal(text)) { return { intent: "inventory_sale_trace_for_item", confidence: "medium", reasons: ["inventory_selected_object_sale_trace_signal_detected"] }; } if (/(?:РєРѕРјСѓ\s+(?:РјС‹\s+)?впарили(?:\s+(?:это|его|товар|позицию))?|РєРѕРјСѓ\s+РІ\s+итоге\s+РјС‹\s+впарили)/iu.test(text) && /(?:товар|номенклатур|sku|item|product|позици(?:СЏ|СЋ|Рё)|продукци(?:СЏ|СЋ|Рё))/iu.test(text)) { return { intent: "inventory_sale_trace_for_item", confidence: "medium", reasons: ["inventory_sale_trace_signal_detected"] }; } if (hasInventorySaleTraceSignalV2(text)) { return { intent: "inventory_sale_trace_for_item", confidence: "medium", reasons: ["inventory_sale_trace_signal_detected"] }; } if (hasInventorySupplierToBuyerChainSignal(text)) { return { intent: "inventory_purchase_to_sale_chain", confidence: "medium", reasons: ["inventory_supplier_to_buyer_chain_signal_detected"] }; } if (hasInventoryOnHandSignal(text)) { return { intent: "inventory_on_hand_as_of_date", confidence: "high", reasons: ["inventory_on_hand_signal_detected"] }; } return null; }