import{parseList,serializeItem,serializeList}from"./StructuredHeaders.js";export function parseBrandsList(e,r,i){const t=[],n=parseList(e);if(0===n.kind)return r;for(const s of n.items){if(4!==s.kind)return i;const e=s.value;if(7!==e.kind)return i;if(1!==s.parameters.items.length)return i;const r=s.parameters.items[0];if("v"!==r.name.value)return i;const n=r.value;if(7!==n.kind)return i;t.push({brand:e.value,version:n.value})}return t}export function serializeBrandsList(e){const r={kind:11,items:[]},i={kind:1,value:"v"};for(const n of e){const e={kind:4,value:{kind:7,value:n.brand},parameters:{kind:3,items:[{kind:2,name:i,value:{kind:7,value:n.version}}]}};r.items.push(e)}const t=serializeList(r);return 0===t.kind?"":t.value}export function validateAsStructuredHeadersString(e,r){return 0===serializeItem({kind:4,value:{kind:7,value:e},parameters:{kind:3,items:[]}}).kind?{valid:!1,errorMessage:r}:{valid:!0,errorMessage:void 0}}