"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InputController = exports.INPUTS = void 0; const schema_js_1 = require("../schema.js"); const types_js_1 = require("../types.js"); /** alexa-inputcontroller.html, "Input property values". */ exports.INPUTS = [ "AUX 1", "AUX 2", "AUX 3", "AUX 4", "AUX 5", "AUX 6", "AUX 7", "BLURAY", "CABLE", "CD", "COAX 1", "COAX 2", "COMPOSITE 1", "DVD", "GAME", "HD RADIO", "HDMI 1", "HDMI 2", "HDMI 3", "HDMI 4", "HDMI 5", "HDMI 6", "HDMI 7", "HDMI 8", "HDMI 9", "HDMI 10", "HDMI ARC", "INPUT 1", "INPUT 2", "INPUT 3", "INPUT 4", "INPUT 5", "INPUT 6", "INPUT 7", "INPUT 8", "INPUT 9", "INPUT 10", "IPOD", "LINE 1", "LINE 2", "LINE 3", "LINE 4", "LINE 5", "LINE 6", "LINE 7", "MEDIA PLAYER", "OPTICAL 1", "OPTICAL 2", "PHONO", "PLAYSTATION", "PLAYSTATION 3", "PLAYSTATION 4", "SATELLITE", "SMARTCAST", "TUNER", "TV", "USB DAC", "VIDEO 1", "VIDEO 2", "VIDEO 3", "XBOX", ]; const input = schema_js_1.s.oneOf(exports.INPUTS, "an input like HDMI 1"); /** * The input a TV or a receiver shows. The inputs of the device are on the capability itself, as the discovery * example of the page has them; its table calls them a configuration object. */ exports.InputController = (0, types_js_1.defineInterface)({ namespace: "Alexa.InputController", version: "3", doc: "https://developer.amazon.com/docs/alexaplus/device-apis/alexa-inputcontroller.html", kind: "controller", tier: 2, instanced: false, properties: { input: { name: "input", value: input }, }, directives: { SelectInput: { name: "SelectInput", payload: schema_js_1.s.object({ input }) }, }, options: schema_js_1.s.object({ /** friendlyNames: what the user calls the input, "Cable" for HDMI 2. */ inputs: schema_js_1.s.array(schema_js_1.s.object({ name: input, friendlyNames: schema_js_1.s.optional(schema_js_1.s.array(schema_js_1.s.string({ min: 1 }))) }, { unknownKeys: "reject" }), { min: 1 }), }, { unknownKeys: "reject" }), // A capability declared the 1.x way has no inputs; check() says so discovery: ({ options: { inputs } }) => (inputs ? { topLevel: { inputs } } : {}), validate(capability) { const names = capability.options.inputs.map(({ name }) => name); const called = capability.options.inputs.flatMap(({ friendlyNames = [] }) => friendlyNames); const lists = [names, called]; for (const list of lists) { const twice = list.find((entry, i) => list.indexOf(entry) !== i); if (twice) throw new types_js_1.DeclarationError(capability, `${twice} is listed twice, a name stands for one input`); } }, });