import { ChildBid , ParentBid } from '../../../../src/types' ; const { customElement , property } = Polymer . decorators ; @ customElement ( 'dash-host-bid' ) export default class DashHostBidElement extends Polymer . MutableData ( Polymer . Element ) { @ property ( { type : String , reflectToAttribute : true , computed : '_computeType(bid)' } ) type : string ; @ property ( { type : Object } ) bid : ParentBid ; @ property ( { type : Boolean , computed : 'computeFailed(closed, bid)' , reflectToAttribute : true } ) failed : boolean ; @ property ( { type : Boolean , computed : 'computeClosed(bid)' , reflectToAttribute : true } ) closed : boolean ; computeFailed ( closed , bid ) { return closed && bid . rawTotal < bid . rawGoal ; } computeClosed ( bid ) { return bid . state . toLowerCase ( ) === 'closed' ; } bidIsChallenge ( bid ) { return bid . type === 'challenge' ; } limitOptions ( options ) { if ( ! options ) { return [ ] ; } return options . slice ( 0 , 3 ) ; } bidHasMoreThanThreeOptions ( bid ) { if ( ! bid . options ) { return false ; } return bid . options . length > 3 ; } calcNumAdditionalOptions ( bid ) { if ( ! bid . options ) { return 0 ; } return bid . options . length - 3 ; } calcBidName ( description ) { return description . replace ( /\\n/g , ' ' ) ; } _computeType ( bid ) { return bid ? bid . type : '' ; } }