/** * 宿主 quote-result:按当前点选费率打 selected 标记。 * 与 embedded-quote-widget.notifyHostQuoteSelection 匹配规则一致。 */ export type HostQuoteMatchKey = { carrier: string; service_level: string; rate_option: string; final_total: number; }; export function isHostSelectedQuote( quote: HostQuoteMatchKey, selected: HostQuoteMatchKey, ): boolean { return ( quote.carrier === selected.carrier && quote.service_level === selected.service_level && quote.rate_option === selected.rate_option && quote.final_total === selected.final_total ); } export function mapQuotesWithSelectedFlag( quotes: T[], selected: HostQuoteMatchKey, ): Array { return quotes.map((q) => ({ ...q, selected: isHostSelectedQuote(q, selected), })); }