import fs from 'node:fs'
const read=p=>fs.readFileSync(p,'utf8');const failures=[]
const fast=read('apps/web/src/modules/erp/item-prices/ItemPriceFastEntryPage.vue')
for(const t of ['KbxFastEntryPage','KbxDataGrid','KbxLookupDialog','allowRowAdd:true','allowRowDuplicate:true','fillDown:true','paste:true','errorNavigation:true'])if(!fast.includes(t))failures.push(`ERP-PRICE-001 missing ${t}`)
const priceDef=read('apps/web/src/modules/erp/item-prices/item-price.definition.ts');for(const t of ["type: 'fast-entry'","id: 'ERP-PRICE-001'","shortcut: 'F8'"])if(!priceDef.includes(t))failures.push(`price screen definition missing ${t}`)
const priceApi=read('backend/Modules/ERP/ItemPrices/BulkSave/Endpoint.cs');for(const t of ['Idempotency-Key','erp.item_prices','ITEM_PRICE_SAVED','ErpItemPriceChanged','command_receipts','DUPLICATE_ITEM_DATE'])if(!priceApi.includes(t))failures.push(`price backend missing ${t}`)
const master=read('packages/kbx-ui/src/components/KbxMasterDetailPage.vue');for(const t of ['masterSize','master-header','detail-header','bottom-header','contextText'])if(!master.includes(t))failures.push(`MasterDetail template missing ${t}`)
const grid=read('packages/kbx-ui/src/components/KbxDataGrid.vue');for(const t of ['activeRowKey','syncActiveRow','ensureNodeVisible'])if(!grid.includes(t))failures.push(`DataGrid active-row contract missing ${t}`)
const inv=read('apps/web/src/modules/erp/inventory/InventoryPage.vue');for(const t of ['historyQuery','active-row-key','drill-down-requested','KbxDrawer','previous=selectedItemId.value'])if(!inv.includes(t))failures.push(`ERP-INV-001 context/history missing ${t}`)
const history=read('backend/Modules/ERP/Inventory/Search/HistoryEndpoint.cs');for(const t of ['erp_inventory_ledger_projection','occurred_at desc','erp.inventory.read'])if(!history.includes(t))failures.push(`inventory history endpoint missing ${t}`)
const routes=read('apps/web/src/router/appRoutes.ts');if(!routes.includes("screenId:'ERP-PRICE-001'"))failures.push('ERP-PRICE-001 route missing')
const nav=read('apps/web/src/shell/navigationCatalog.ts');if(!nav.includes("screenId:'ERP-PRICE-001'"))failures.push('ERP-PRICE-001 navigation missing')
if(failures.length){console.error('KBX v26 Golden Screen validation failed:\n- '+failures.join('\n- '));process.exit(1)}
console.log('Golden T04/T05 PASS: independent Fast Entry, server-safe bulk save, Master/Detail context, history and drill-down.')
