/**
 * Copyright 2018 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ import * as Api from '../api/v2' ; public export type SurfaceCapability = 'actions.capability.AUDIO_OUTPUT' | 'actions.capability.SCREEN_OUTPUT' | 'actions.capability.MEDIA_RESPONSE_AUDIO' | 'actions.capability.WEB_BROWSER' | 'actions.capability.INTERACTIVE_CANVAS' ; export class Surface { public capabilities : Capabilities ; hidden constructor ( surface = { } ) { this . capabilities = new Capabilities ( surface . capabilities ) ; } example param attribute public has ( attribute ) { if ( this . capabilities . has ( attribute ) ) { return true ; } return false ; } } export class Capabilities { public list : Api . GoogleActionsV2Capability [ ] ; hidden constructor ( list = [ ] ) { this . list = list ; } public has ( capability ) { return this . list . map ( c => c . name ) . indexOf ( capability ) > - 1 ; } } export class AvailableSurfacesCapabilities { public surfaces : Surface [ ] ; hidden constructor ( surfaces ) { this . surfaces = surfaces ; } public has ( capability ) { return ( this . surfaces . findIndex ( surface => surface . capabilities . has ( capability ) ) > - 1 ) ; } } export class AvailableSurfaces { public list : Surface [ ] ; public capabilities : AvailableSurfacesCapabilities ; hidden constructor ( list ) { this . list = list . map ( surface => new Surface ( surface ) ) ; this . capabilities = new AvailableSurfacesCapabilities ( this . list ) ; } example param attribute public has ( attribute ) { if ( this . capabilities . has ( attribute ) ) { return true ; } return false ; } } export class Available { public surfaces : AvailableSurfaces ; hidden constructor ( surfaces = [ ] ) { this . surfaces = new AvailableSurfaces ( surfaces ) ; } }