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ACC,GAAS,YAAc,EAAW,OAAS,GAC/C,IAEA,GAAS,IAAM,KAAK,QAAQ,GAAQ,aACpC,KAAK,UAAU,KAAK,GACb,IAEX,EA4CA,OAAO,UAAU,IAAM,SAAU,EAAO,GAOpC,OANA,KAAK,SAAS,EAAO,8DACrB,KAAK,UAAU,EAAO,kDACtB,KAAK,SAAS,EAAM,6DACpB,KAAK,UAAU,EAAM,iDAErB,KAAK,UAAU,KAAK,eAAiB,EAAQ,KAAO,KAAK,QAAQ,GAAQ,UAClE,IACX,EAQA,OAAO,UAAU,YAAc,SAAU,GAGrC,OAFA,KAAK,SAAS,EAAQ,wEACtB,KAAK,UAAU,KAAK,GACb,IACX,EAOA,OAAO,UAAU,gBAAkB,SAAU,GACzC,IAAI,EAAS,KAAK,QAAQ,iBAAiB,GAE3C,OADA,KAAK,UAAU,KAAK,KAAK,QAAQ,IAC1B,IACX,EAeA,OAAO,QAAU","file":"/npm/ssml-builder@0.4.3/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ssml-builder@0.4.3/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nvar Helper = require('./helper');\n    \n/**\n * This class helps simplify using SSML (Speech Synthesis Markup Language).\n * This only supports a subset of SSML tags which the Alexa device supports.\n * An example of how to use this class.\n * <code>\n *  var speech = new Speech();\n *  speech.say(\"Let's begin your lesson\");\n *  speech.pause(\"1s\");\n *\n * </code>\n * Implement a method for <phoneme/>, <w/>, <say-as> All done\n * interpret-as=\"cardinal|ordinal|digits|fraction|unit|date|time|telephone|address\" + format=\"mdy|dmy|ymd|md|dm|ym|my|d|m|y\" All done\n * @constructor\n */\nfunction Speech() {\n    this._elements = [];\n    this._helper = new Helper();\n}\n\n/**\n * This appends raw text into the <speak/> tag.\n * @param saying The raw text to insert into the speak tag.\n * @returns {Speech}\n */\nSpeech.prototype.say = function (saying) {\n    this._present(saying, \"The saying provided to Speech#saying(..) was null or undefined.\");\n    this._elements.push(this._escape(saying));\n    return this;\n};\n\n/**\n * Creates and inserts a paragraph tag.\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#p\n * @param paragraph The paragraph of text to insert.\n * @returns {Speech}\n */\nSpeech.prototype.paragraph = function (paragraph) {\n    this._present(paragraph, \"The paragraph provided to Speech#paragraph(..) was null or undefined.\");\n    this._elements.push(\"<p>\" + this._escape(paragraph) + \"</p>\");\n    return this;\n};\n\n/**\n * Creates and inserts a sentence tag.\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#s\n * @param saying The sentence to insert.\n * @returns {Speech}\n */\nSpeech.prototype.sentence = function (saying) {\n    this._present(saying, \"The sentence provided to Speech#sentence(..) was null or undefined.\");\n    this._elements.push(\"<s>\" + this._escape(saying) + \"</s>\");\n    return this;\n};\n\n/**\n * Creates and inserts a break tag. This method will also validate the break time conforms to the restrictions to Amazon Alexa.\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#break\n * @param duration the duration represented by a number + either 's' for second or 'ms' for milliseconds.\n * @returns {Speech}\n */\nSpeech.prototype.pause = function (duration) {\n    this._present(duration, \"The duration provided to Speech#pause(..) was null or undefined.\");\n    this._validateDuration(duration);\n    this._elements.push(\"<break time='\" + duration + \"'/>\");\n    return this;\n};\n\n/**\n * Creates a break tag that will pause the audio based upon the strength provided.\n * For more information, please see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#break\n * @param strength such as none, x-weak, weak, medium, strong, x-strong\n * @returns {Speech}\n */\nSpeech.prototype.pauseByStrength = function (strength) {\n    this._present(strength, \"The strength provided to Speech#pauseByStrength(..) was null or undefined\");\n    strength = strength.toLowerCase().trim();\n    var strengths = ['none', 'x-weak', 'weak', 'medium', 'strong', 'x-strong'];\n    isInList(strength, strengths, \"The strength provided to Speech#pauseByStrength(..) was not valid. Received strength: \" + strength);\n\n    this._elements.push(\"<break strength='\" + strength + \"'/>\");\n    return this;\n};\n\n/**\n * Creates and inserts an audio tag.\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#audio\n * @param url a link to an audio file to play.\n * @param callback - an optional callback which is called to build the nested SSML\n *                   for the audio tag. The callback takes a single parameter of type\n *                   Speech.\n * @returns {Speech}\n */\nSpeech.prototype.audio = function (url, callback) {\n    this._present(url, \"The url provided to Speech#audio(..) was null or undefined.\");\n    if (callback) {\n        this._isFunction(callback, \"callback\");\n        var audioBuilder = new Speech();\n        callback(audioBuilder);\n        this._elements.push(\"<audio src='\" + url + \"'>\" + audioBuilder.ssml(true) + \"</audio>\");\n    } else {\n        this._elements.push(\"<audio src='\" + url + \"'/>\");\n    }\n    return this;\n};\n\n\n/**\n * Creates and inserts a say-as tag.\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#say-as\n * @param word word or text to insert\n * @returns {Speech}\n */\nSpeech.prototype.spell = function (word) {\n    this._present(word, \"The word provided to Speech#spell(..) was null or undefined.\");\n    this._elements.push(\"<say-as interpret-as='spell-out'>\" + this._escape(word) + \"</say-as>\");\n    return this;\n};\n\n/**\n * Creates and inserts a say-as tag.\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#say-as\n * @param word word or text to insert , delay the delay represented by a number + either 's' for second or 'ms' for milliseconds.\n * @returns {Speech}\n */\nSpeech.prototype.spellSlowly = function (word, delay) {\n    this._present(word, \"The word provided to Speech#spellSlowly(..) was null or undefined.\");\n    for (var i = 0; i < word.length; i++) {\n        this._elements.push(\"<say-as interpret-as='spell-out'>\" + this._escape(word.charAt(i)) + \"</say-as>\");\n        this.pause(delay);\n    }\n    return this;\n};\n\n/**\n * This constructs an object that the AlexaSkill.js accepts to send to the user.\n * @returns {{type: string, speech}}\n */\nSpeech.prototype.toObject = function () {\n    return {\n        type: 'SSML',\n        speech: this.ssml()\n    }\n};\n\n/**\n * This method will construct an SSML xml string.\n * @param excludeSpeakTag when true, no root tag <speak/> is provided; otherwise,\n *        the content is surrounded by the <speak/>, default is false\n * @returns {string} An XML string.\n */\nSpeech.prototype.ssml = function (excludeSpeakTag) {\n    if (excludeSpeakTag) {\n        return this._elements.join(\" \");\n    }\n    return \"<speak>\" + this._elements.join(\" \") + \"</speak>\";\n};\n\n/**\n * Validates that the provided value is not null or undefined. It will throw an exception if it's either.\n * @param value The value to check.\n * @param msg The error message stating that exception.\n * @private\n */\nSpeech.prototype._present = function (value, msg) {\n    if (value === null || value === undefined) {\n        throw msg;\n    }\n};\n\n/**\n * This validates that a duration is in the correct format and doesn't exceed the\n * maximum duration of 10 seconds or 10000 milliseconds.\n *\n * The expected format is a positive number followed by 's' for second or 'ms' for milliseconds.\n *\n * @param duration The duration of a pause.\n * @throws an exception when the duration doesn't conform to the proper format or duration length.\n * @private\n */\nSpeech.prototype._validateDuration = function (duration) {\n    var re = /^(\\d*\\.?\\d+)(s|ms)$/;\n    if (duration.match(re)) {\n        var parts = re.exec(duration);\n        var pauseDuration = parts[1];\n        var pauseType = parts[2];\n        if (pauseType.toLowerCase() === 's' && pauseDuration > 10) {\n            throw \"The pause duration exceeds the allowed 10 second duration. Duration provided: \" + duration;\n        } else if (pauseDuration > 10000) {\n            throw \"The pause duration exceeds the allowed 10,000 milliseconds duration. Duration provided: \" + duration;\n        }\n    } else {\n        throw \"The duration must be a number followed by either 's' for second or 'ms' for milliseconds. e.g., 10s or 100ms. Max duration is 10 seconds (10000 milliseconds).\"\n    }\n};\n\n/**\n * Creates and inserts a say-as tag that has multiple attributes such as interpret-as and format\n * interpret-as=\"characters|spell-out|cardinal|number|ordinal|digits|fraction|unit|date|time|telephone|address|interjection|expletive\" + format=\"mdy|dmy|ymd|md|dm|ym|my|d|m|y\"\n *\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#say-as\n * @param options an object that has three properties: word, interpret and format\n * word being the text to insert, interpret represents the attribute interpret-as and format represents the attribute format\n * @returns {Speech}\n */\nSpeech.prototype.sayAs = function (options) {\n    this._present(options, \"The object provided to Speech#sayAs(..) was invalid.\");\n    this._present(options.word, \"The word provided to Speech#sayAs(..) was null or undefined.\");\n    if (options.interpret) {\n        var listOfInterpret = ['characters', 'spell-out', 'cardinal', 'number', 'ordinal', 'digits', 'fraction', 'unit', 'date', 'time', 'telephone', 'address', 'interjection', 'expletive'];\n        isInList(options.interpret, listOfInterpret, \"The interpret is invalid. Received this: \" + options.interpret);\n        if (options.format) {\n            this._elements.push(\"<say-as interpret-as=\\'\" + options.interpret + \"\\'\" + \" format=\\'\" + options.format + \"'>\" + options.word + \"</say-as>\");\n            return this;\n        }\n        this._elements.push(\"<say-as interpret-as=\\'\" + options.interpret + \"'>\" + options.word + \"</say-as>\");\n        return this;\n    } else {\n        this._elements.push(options.word);\n        return this;\n    }\n};\n\n/**\n * Creates and inserts a w tag that customizes the pronunciation of words by specifying the word’s part of speech\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#w\n * @param options an object that has two properties: word and role\n * word being the text to insert and role represents the part of speech\n * @returns {Speech}\n */\nSpeech.prototype.partOfSpeech = function (options) {\n    this._present(options, \"The object provided to Speech#partOfSpeech(..) was invalid.\");\n    this._present(options.word, \"The word provided to Speech#partOfSpeech(..) was null or undefined.\");\n    var word = this._escape(options.word);\n    if (options.role) {\n        this._elements.push(\"<w role=\\'\" + options.role + \"'>\" + word + \"</w>\")\n    }\n    return this;\n};\n\n/**\n * Creates and inserts a phoneme tag.\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#phoneme\n * @param alphabet, ph, word\n * alphabet i.e \"ipa\"\n * ph i.e \"pɪˈkɑːn\"\n * word being the text to insert\n * @returns {Speech}\n */\nSpeech.prototype.phoneme = function (alphabet, ph, word) {\n    this._present(alphabet, \"The alphabet provided to Speech#phoneme(..) was null or undefined.\");\n    this._present(ph, \"The ph provided to Speech#phoneme(..) was null or undefined.\");\n    this._present(word, \"The word provided to Speech#phoneme(..) was null or undefined.\");\n    var escapedWord = this._escape(word);\n    if (ph.indexOf(\"'\") !== -1) {\n        ph = ph.replace(/'/g, '&apos;')\n    }\n    this._elements.push(\"<phoneme alphabet=\\'\" + alphabet + \"\\'\" + \" ph=\\'\" + ph + \"'>\" + escapedWord + \"</phoneme>\");\n    return this;\n};\n\n/**\n * This method escapes any special characters that will cause SSML to be invalid.\n * @param word being the text to insert\n * @returns {*}\n * @private\n */\nSpeech.prototype._escape = function (word) {\n    if (typeof(word) === \"string\") {\n        word = word.replace(/&/g, '&amp;');\n        word = word.replace(/</g, '&lt;');\n        word = word.replace(/>/g, '&gt;');\n        word = word.replace(/\"/g, '&quot;');\n        word = word.replace(/'/g, '&apos;');\n        return word;\n    }\n    if (typeof(word) === \"number\") {\n        return word;\n    }\n    if (typeof(word) === \"boolean\") {\n        return word;\n    }\n    throw new Error('received invalid type ' + typeof(word));\n};\n\n/**\n * This method ensures the input passing in is not null, undefined or empty string. In the case that it is, an exception is thrown with the message provided.\n * @param word\n * @param msg\n * @private\n */\nSpeech.prototype._notEmpty = function (word, msg) {\n    this._present(word, msg);\n    if (word.length === 0) {\n        throw msg;\n    }\n};\n\n/**\n * Ensures 'fnc' is a function.\n * @param fnc the variable to check if it's a function.\n * @param name the name of the parameter used in the error message.\n */\nSpeech.prototype._isFunction = function (fnc, name) {\n    var fncType = typeof(fnc);\n    if (fncType !== \"function\") {\n        throw new Error(name + \" was not a function. received: \" + fncType);\n    }\n};\n\n/**\n * Creates and inserts a emphasis tag.\n * see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference#emphasis\n * @param level includes strong, moderate and reduced\n * @param word word or text to insert\n * @returns {Speech}\n */\nSpeech.prototype.emphasis = function (level, word) {\n    this._present(level, \"The level provided to Speech#emphasis(..) was null or undefined\");\n    this._present(word, \"The word provided to Speech#emphasis(..) was null or undefined\");\n    var levels = ['strong', 'moderate', 'reduced'];\n    if (levels.indexOf(level) < 0) {\n        throw new Error(\"The level provided to Speech#emphasis(..) was not valid. Received level: \" + level);\n    }\n\n    this._notEmpty(word, \"The word provided to Speech#emphasis(..) was empty\");\n    this._elements.push(\"<emphasis level='\" + level + \"'>\" + this._escape(word) + \"</emphasis>\");\n    return this;\n};\n\n/**\n * √ TODO: Handle rate minimum 20%\n * @param attributes\n * @param word\n * @returns {Speech}\n */\nSpeech.prototype.prosody = function (attributes, word) {\n    this._present(attributes, \"The attributes provided to Speech#prosody(..) was null or undefined\");\n    this._present(word, \"The word provided to Speech#prosody(..) was null or undefined\");\n    this._notEmpty(word, \"The word provided to Speech#prosody(..) was empty\");\n\n    var validRates = ['x-slow', 'slow', 'medium', 'fast', 'x-fast'];\n    var validPitches = ['x-low', 'low', 'medium', 'high', 'x-high'];\n    var validVolumes = ['silent', 'x-soft', 'soft', 'medium', 'loud', 'x-loud'];\n\n    var final = \"<prosody\";\n\n    validateAttribute(attributes, 'rate', validRates, function () {\n        if (!/\\d+%/.test(attributes.rate)) {\n            throw new Error(\"attributes.rate is not a valid rate\");\n        }\n        checkRateRange(attributes.rate);\n    }, function () {\n        final += \" rate='\" + attributes.rate + \"'\";\n    });\n\n    validateAttribute(attributes, 'pitch', validPitches, function () {\n        if (!/(\\+|-)\\d+(\\.\\d+)?%/.test(attributes.pitch)) {\n            throw new Error(\"attributes.pitch is not a valid pitch\");\n        }\n    }, function () {\n        final += \" pitch='\" + attributes.pitch + \"'\";\n    });\n\n    validateAttribute(attributes, 'volume', validVolumes, function () {\n        if (!/(\\+|-)\\d+(\\.\\d+)?db/.test(attributes.volume)) {\n            throw new Error(\"attributes.volume is not a valid volume\");\n        }\n        var length = attributes.volume.length;\n        var firstHalf = attributes.volume.substring(0, length - 2);\n        firstHalf += \"dB\";\n        attributes.volume = firstHalf;\n    }, function () {\n        final += \" volume='\" + attributes.volume + \"'\";\n    });\n\n    final += \">\" + this._escape(word) + \"</prosody>\";\n    this._elements.push(final);\n    return this;\n\n};\n\n/**\n * This helper function consolidates the validation checks for rate,pitch and volume. It will first\n * check to see if the attribute is present and whether it's one of the following conditions:\n *  a) the value of the attribute is a valid value or\n *  b) the value does not exist in the list, but passes the onCheck function. A hook for additional checks.\n *\n *  Upon passing the above checks, the onSuccessful function is called allowing the caller to do any additional work.\n *\n * @param obj The object that owns the attribute.\n * @param attribute The attribute name to check. e.g., rate, pitch or volume.\n * @param validList The list of value values that the attribute can be.\n * @param onCheck A hook for additional checks if the value does not exist in the list.\n * @param onSuccessful A hook to call when all validation checks succeed.\n */\nfunction validateAttribute(obj, attribute, validList, onCheck, onSuccessful) {\n    if (obj.hasOwnProperty(attribute)) {\n        obj[attribute] = obj[attribute].toLowerCase().trim();\n        if (validList.indexOf(obj[attribute]) == -1) {\n            onCheck();\n        }\n        onSuccessful();\n    }\n}\n\n/**\n * This method ensures that the value of the rate must be equal or great than 20%\n * @param num is the value of rate\n */\nfunction checkRateRange(num) {\n    var numString = num.substring(0, num.length - 1);\n    var parseNum = parseInt(numString);\n    if (parseNum < 20) {\n        throw new Error(\"The minimum rate is twenty percentage. Received: \" + parseNum);\n    }\n}\n\n/**\n * This method lets the user provide an alias and pronounce the specified word or pharse as a different word or phrase\n * @param alias is the word that you want to pronounce instead of the original word\n * @param word\n * @returns {Speech}\n */\nSpeech.prototype.sub = function (alias, word) {\n    this._present(alias, \"The alias provided to Speech#sub(..) was null or undefined\");\n    this._notEmpty(alias, \"The alias provided to Speech#sub(..) was empty\");\n    this._present(word, \"The word provided to Speech#sub(..) was null or undefined\");\n    this._notEmpty(word, \"The word provided to Speech#sub(..) was empty\");\n\n    this._elements.push(\"<sub alias='\" + alias + \"'>\" + this._escape(word) + \"</sub>\");\n    return this;\n};\n\n/**\n * This method lets the user add raw SSML into the speech object without escaping the special characters.\n * For example, if you passed in \"<speak>Hi</speak>\", it won't escape the less than or greater than tags.\n * @param saying raw string to be appended\n * @returns {Speech}\n */\nSpeech.prototype.sayWithSSML = function (saying) {\n    this._present(saying, \"The saying provided to Speech#sayWithSSML(..) was null or undefined.\");\n    this._elements.push(saying);\n    return this;\n};\n\n/**\n * This method will select a random word or phrase from the choices provided and then say it to the user\n * @param choices - an array of phrases or words\n * @returns {Speech}\n */\nSpeech.prototype.sayRandomChoice = function (choices) {\n    var choice = this._helper.chooseRandomWord(choices);\n    this._elements.push(this._escape(choice));\n    return this;\n};\n\n/**\n * This method validates if the value exists in the list of values\n * @param value\n * @param listOfValues\n * @param msg is the error message that will be thrown when the value is not in the list\n */\nfunction isInList(value, listOfValues, msg) {\n    value = value.toLowerCase().trim();\n    if (listOfValues.indexOf(value) === -1) {\n        throw new Error(msg);\n    }\n}\n\nmodule.exports = Speech;\n"]}