| Commitments and Contingencies (Tables)
 | 6 Months Ended | 
| Jun. 30, 2018 | 
|---|
| Commitments and Contingencies Disclosure [Abstract] |  | 
| Future Minimum Payments Under Operating Leases | 
As of June 30, 2018, future minimum rental income under non-cancelable subleases is as follows:
 
|  |  
|  |  |  |  |  
|   | Amount |  
|   | (in thousands) |  
| 2018 (6 months) | $ | 1,456 | 
 |  
| 2019 | 3,604 | 
 |  
| 2020 | 4,088 | 
 |  
| 2021 | 4,152 | 
 |  
| 2022 | 879 | 
 |  
| Thereafter | 352 | 
 |  
| Total minimum rental income | $ | 14,531 | 
 |  
As of June 30, 2018, future minimum payments under non-cancelable operating leases, inventory purchase and other obligations are as follows:
 
|  |  
|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  
|   | Operating Leases |   | Inventory Purchase Obligations |   | Other Obligations |   | Total |  
|   | (in thousands) |  
| 2018 (6 months) | $ | 4,532 | 
 |   | $ | 45,140 | 
 |   | $ | 3,776 | 
 |   | $ | 53,448 | 
 |  
| 2019 | 9,188 | 
 |   | — | 
 |   | 7,761 | 
 |   | 16,949 | 
 |  
| 2020 | 9,366 | 
 |   | — | 
 |   | 3,781 | 
 |   | 13,147 | 
 |  
| 2021 | 9,169 | 
 |   | — | 
 |   | 30 | 
 |   | 9,199 | 
 |  
| 2022 | 5,037 | 
 |   | — | 
 |   | — | 
 |   | 5,037 | 
 |  
| Thereafter | 786 | 
 |   | — | 
 |   | — | 
 |   | 786 | 
 |  
| Total minimum payments | $ | 38,078 | 
 |   | $ | 45,140 | 
 |   | $ | 15,348 | 
 |   | $ | 98,566 | 
 |  | 
| Future Minimum Payments Under Other Obligations | 
As of June 30, 2018, future minimum payments under non-cancelable operating leases, inventory purchase and other obligations are as follows:
 
|  |  
|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  
|   | Operating Leases |   | Inventory Purchase Obligations |   | Other Obligations |   | Total |  
|   | (in thousands) |  
| 2018 (6 months) | $ | 4,532 | 
 |   | $ | 45,140 | 
 |   | $ | 3,776 | 
 |   | $ | 53,448 | 
 |  
| 2019 | 9,188 | 
 |   | — | 
 |   | 7,761 | 
 |   | 16,949 | 
 |  
| 2020 | 9,366 | 
 |   | — | 
 |   | 3,781 | 
 |   | 13,147 | 
 |  
| 2021 | 9,169 | 
 |   | — | 
 |   | 30 | 
 |   | 9,199 | 
 |  
| 2022 | 5,037 | 
 |   | — | 
 |   | — | 
 |   | 5,037 | 
 |  
| Thereafter | 786 | 
 |   | — | 
 |   | — | 
 |   | 786 | 
 |  
| Total minimum payments | $ | 38,078 | 
 |   | $ | 45,140 | 
 |   | $ | 15,348 | 
 |   | $ | 98,566 | 
 |  | 
| Future Minimum Payments Under Inventory Purchase Obligations | 
As of June 30, 2018, future minimum payments under non-cancelable operating leases, inventory purchase and other obligations are as follows:
 
|  |  
|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  
|   | Operating Leases |   | Inventory Purchase Obligations |   | Other Obligations |   | Total |  
|   | (in thousands) |  
| 2018 (6 months) | $ | 4,532 | 
 |   | $ | 45,140 | 
 |   | $ | 3,776 | 
 |   | $ | 53,448 | 
 |  
| 2019 | 9,188 | 
 |   | — | 
 |   | 7,761 | 
 |   | 16,949 | 
 |  
| 2020 | 9,366 | 
 |   | — | 
 |   | 3,781 | 
 |   | 13,147 | 
 |  
| 2021 | 9,169 | 
 |   | — | 
 |   | 30 | 
 |   | 9,199 | 
 |  
| 2022 | 5,037 | 
 |   | — | 
 |   | — | 
 |   | 5,037 | 
 |  
| Thereafter | 786 | 
 |   | — | 
 |   | — | 
 |   | 786 | 
 |  
| Total minimum payments | $ | 38,078 | 
 |   | $ | 45,140 | 
 |   | $ | 15,348 | 
 |   | $ | 98,566 | 
 |  |