var OSF; (function (OSF) { let XmlConstants; (function (XmlConstants) { XmlConstants[XmlConstants["MaxXmlSize"] = 1048576] = "MaxXmlSize"; XmlConstants[XmlConstants["MaxElementDepth"] = 64] = "MaxElementDepth"; })(XmlConstants = OSF.XmlConstants || (OSF.XmlConstants = {})); class Xpath3Provider { constructor(xml, xmlNamespaces) { this._xmldoc = new DOMParser().parseFromString(xml, "text/xml"); this._evaluator = new XPathEvaluator(); this._namespaceMapping = {}; this._defaultNamespace = null; var namespaces = xmlNamespaces.split(' '); var matches; for (var i = 0; i < namespaces.length; ++i) { matches = /xmlns="([^"]*)"/g.exec(namespaces[i]); if (matches) { this._defaultNamespace = matches[1]; continue; } matches = /xmlns:([^=]*)="([^"]*)"/g.exec(namespaces[i]); if (matches) { this._namespaceMapping[matches[1]] = matches[2]; continue; } } this._resolver = this; } lookupNamespaceURI(prefix) { var ns = this._namespaceMapping[prefix]; return ns || this._defaultNamespace; } addNamespaceMapping(namespacePrefix, namespaceUri) { var ns = this._namespaceMapping[namespacePrefix]; if (ns) { return false; } else { this._namespaceMapping[namespacePrefix] = namespaceUri; return true; } } getNamespaceMapping() { return this._namespaceMapping; } selectSingleNode(name, contextNode) { var xpath = (contextNode ? "./" : "/") + name; contextNode = contextNode || this.getDocumentElement(); var result = this._evaluator.evaluate(xpath, contextNode, this._resolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null); if (result) { return result.singleNodeValue; } else { return null; } } selectNodes(name, contextNode) { var xpath = (contextNode ? "./" : "/") + name; contextNode = contextNode || this.getDocumentElement(); var result = this._evaluator.evaluate(xpath, contextNode, this._resolver, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); var nodes = []; if (result) { var node = result.iterateNext(); while (node) { nodes.push(node); node = result.iterateNext(); } } return nodes; } selectNodesByXPath(xpath, contextNode) { var result = this._evaluator.evaluate(xpath, contextNode, this._resolver, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); var nodes = []; if (result) { var node = result.iterateNext(); while (node) { nodes.push(node); node = result.iterateNext(); } } return nodes; } getDocumentElement() { return this._xmldoc.documentElement; } } OSF.Xpath3Provider = Xpath3Provider; class IEXpathProvider { constructor(xml, xmlNamespaces) { var xmldoc = null; var msxmlVersions = ['MSXML2.DOMDocument.6.0']; for (var i = 0; i < msxmlVersions.length; i++) { try { xmldoc = new ActiveXObject(msxmlVersions[i]); xmldoc.setProperty('ResolveExternals', false); xmldoc.setProperty('ValidateOnParse', false); xmldoc.setProperty('ProhibitDTD', true); xmldoc.setProperty('MaxXMLSize', OSF.XmlConstants.MaxXmlSize); xmldoc.setProperty('MaxElementDepth', OSF.XmlConstants.MaxElementDepth); xmldoc.async = false; xmldoc.loadXML(xml); xmldoc.setProperty("SelectionLanguage", "XPath"); xmldoc.setProperty("SelectionNamespaces", xmlNamespaces); break; } catch (ex) { OsfMsAjaxFactory.msAjaxDebug.trace("xml doc creating error:" + ex); } } this._xmldoc = xmldoc; } selectSingleNode(name, contextNode) { var xpath = (contextNode ? "./" : "/") + name; contextNode = contextNode || this.getDocumentElement(); return contextNode.selectSingleNode(xpath); } addNamespaceMapping(namespacePrefix, namespaceUri) { var existingNamespaces = this._xmldoc.getProperty("SelectionNamespaces"); var newNamespacePrefix = "xmlns:" + namespacePrefix + "="; var newNamespaceMappingString = "xmlns:" + namespacePrefix + "=\"" + namespaceUri + "\""; if (existingNamespaces.indexOf(newNamespacePrefix) != -1) { return false; } existingNamespaces = existingNamespaces + " " + newNamespaceMappingString; this._xmldoc.setProperty("SelectionNamespaces", existingNamespaces); return true; } getNamespaceMapping() { return null; } selectNodes(name, contextNode) { var xpath = (contextNode ? "./" : "/") + name; contextNode = contextNode || this.getDocumentElement(); return contextNode.selectNodes(xpath); } selectNodesByXPath(xpath, contextNode) { return contextNode.selectNodes(xpath); } getDocumentElement() { return this._xmldoc.documentElement; } getActiveXObject() { return this._xmldoc; } } OSF.IEXpathProvider = IEXpathProvider; class DomParserProvider { constructor(xml, xmlNamespaces) { try { this._xmldoc = new DOMParser().parseFromString(xml, "text/xml"); } catch (ex) { Sys.Debug.trace("xml doc creating error:" + ex); } this._namespaceMapping = {}; this._defaultNamespace = null; var namespaces = xmlNamespaces.split(' '); var matches; for (var i = 0; i < namespaces.length; ++i) { matches = /xmlns="([^"]*)"/g.exec(namespaces[i]); if (matches) { this._defaultNamespace = matches[1]; continue; } matches = /xmlns:([^=]*)="([^"]*)"/g.exec(namespaces[i]); if (matches) { this._namespaceMapping[matches[1]] = matches[2]; continue; } } } addNamespaceMapping(namespacePrefix, namespaceUri) { var ns = this._namespaceMapping[namespacePrefix]; if (ns) { return false; } else { this._namespaceMapping[namespacePrefix] = namespaceUri; return true; } } getNamespaceMapping() { return this._namespaceMapping; } selectSingleNode(name, contextNode) { var selectedNode = contextNode || this._xmldoc; var nodes = this._selectNodes(name, selectedNode); if (nodes.length === 0) return null; return nodes[0]; } selectNodes(name, contextNode) { var selectedNode = contextNode || this._xmldoc; return this._selectNodes(name, selectedNode); } selectNodesByXPath(xpath, contextNode) { return null; } _selectNodes(name, contextNode) { var nodes = []; if (!name) return nodes; var nameInfo = name.split(":"); var ns, nodeName; if (nameInfo.length === 1) { ns = null; nodeName = nameInfo[0]; } else if (nameInfo.length === 2) { ns = this._namespaceMapping[nameInfo[0]]; nodeName = nameInfo[1]; } else { throw OsfMsAjaxFactory.msAjaxError.argument("name"); } if (!contextNode.hasChildNodes) return nodes; var childs = contextNode.childNodes; for (var i = 0; i < childs.length; i++) { if (nodeName === this._removeNodePrefix(childs[i].nodeName) && (ns === childs[i].namespaceURI)) { nodes.push(childs[i]); } } return nodes; } _removeNodePrefix(nodeName) { var nodeInfo = nodeName.split(':'); if (nodeInfo.length === 1) { return nodeName; } else { return nodeInfo[1]; } } getDocumentElement() { return this._xmldoc.documentElement; } } OSF.DomParserProvider = DomParserProvider; class XmlProcessor { constructor(xml, xmlNamespaces) { var e = Function._validateParams(arguments, [ { name: "xml", type: String, mayBeNull: false }, { name: "xmlNamespaces", type: String, mayBeNull: false } ]); if (e) throw e; if (document.implementation && document.implementation.hasFeature("XPath", "3.0")) { this._provider = new OSF.Xpath3Provider(xml, xmlNamespaces); } else { this._provider = new OSF.IEXpathProvider(xml, xmlNamespaces); if (!this._provider.getActiveXObject()) { this._provider = new OSF.DomParserProvider(xml, xmlNamespaces); } } } addNamespaceMapping(namespacePrefix, namespaceUri) { var e = Function._validateParams(arguments, [ { name: "namespacePrefix", type: String, mayBeNull: false }, { name: "namespaceUri", type: String, mayBeNull: false } ]); if (e) throw e; return this._provider.addNamespaceMapping(namespacePrefix, namespaceUri); } getNamespaceMapping() { var _a; return (_a = this._provider) === null || _a === void 0 ? void 0 : _a.getNamespaceMapping(); } selectSingleNode(name, contextNode) { var e = Function._validateParams(arguments, [ { name: "name", type: String, mayBeNull: false }, { name: "contextNode", mayBeNull: true, optional: true } ]); if (e) throw e; return this._provider.selectSingleNode(name, contextNode); } selectNodes(name, contextNode) { var e = Function._validateParams(arguments, [ { name: "name", type: String, mayBeNull: false }, { name: "contextNode", mayBeNull: true, optional: true } ]); if (e) throw e; return this._provider.selectNodes(name, contextNode); } selectNodesByXPath(xpath, contextNode) { var e = Function._validateParams(arguments, [ { name: "xpath", type: String, mayBeNull: false }, { name: "contextNode", mayBeNull: true, optional: true } ]); if (e) throw e; contextNode = contextNode || this._provider.getDocumentElement(); return this._provider.selectNodesByXPath(xpath, contextNode); } getDocumentElement() { return this._provider.getDocumentElement(); } getNodeValue(node) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false } ]); if (e) throw e; var nodeValue; if (node.text) { nodeValue = node.text; } else { nodeValue = node.textContent; } return nodeValue; } getNodeText(node) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false } ]); if (e) throw e; if (this.getNodeType(node) == 9) { return this.getNodeText(this.getDocumentElement()); } var nodeText; if (node.text) { nodeText = node.text; } else { nodeText = node.textContent; } return nodeText; } setNodeText(node, text) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false }, { name: "text", type: String, mayBeNull: false } ]); if (e) throw e; if (this.getNodeType(node) == 9) { return false; } try { if (node.text) { node.text = text; } else { node.textContent = text; } } catch (ex) { return false; } return true; } getNodeXml(node) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false } ]); if (e) throw e; var nodeXml; if (node.xml) { nodeXml = node.xml; } else { nodeXml = new XMLSerializer().serializeToString(node); if (this.getNodeType(node) == 2) { nodeXml = this.getNodeBaseName(node) + "=\"" + nodeXml + "\""; } } return nodeXml; } setNodeXml(node, xml) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false }, { name: "xml", type: String, mayBeNull: false } ]); if (e) throw e; var processor = new OSF.XmlProcessor(xml, ""); if (!processor.isValidXml()) { return null; } var newNode = processor.getDocumentElement(); try { node.parentNode.replaceChild(newNode, node); } catch (ex) { return null; } return newNode; } getNodeNamespaceURI(node) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false } ]); if (e) throw e; return node.namespaceURI; } getNodePrefix(node) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false } ]); if (e) throw e; return node.prefix; } getNodeBaseName(node) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false } ]); if (e) throw e; var nodeBaseName; if (node.nodeType && (node.nodeType == 1 || node.nodeType == 2)) { if (node.baseName) { nodeBaseName = node.baseName; } else { nodeBaseName = node.localName; } } else { nodeBaseName = node.nodeName; } return nodeBaseName; } getNodeType(node) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false } ]); if (e) throw e; return node.nodeType; } appendChild(node, childXml) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false }, { name: "childXml", type: String, mayBeNull: false } ]); if (e) throw e; var processor = new OSF.XmlProcessor(childXml, ""); if (!processor.isValidXml()) { return null; } var childNode = processor.getDocumentElement(); node.appendChild(childNode); return childNode; } _getAttributeLocalName(attribute) { var localName; if (attribute.localName) { localName = attribute.localName; } else { localName = attribute.baseName; } return localName; } readAttributes(node, attributesToRead, objectToFill) { var e = Function._validateParams(arguments, [ { name: "node", type: Object, mayBeNull: false }, { name: "attributesToRead", type: Object, mayBeNull: false }, { name: "objectToFill", type: Object, mayBeNull: false } ]); if (e) throw e; var attribute; var localName; for (var i = 0; i < node.attributes.length; i++) { attribute = node.attributes[i]; localName = this._getAttributeLocalName(attribute); for (var p in attributesToRead) { if (localName === p) { objectToFill[attributesToRead[p]] = attribute.value; } } } } isValidXml() { var documentElement = this.getDocumentElement(); if (documentElement == null) { return false; } else if (this._provider._xmldoc.getElementsByTagName("parsererror").length > 0) { var parser = new DOMParser(); var errorParse = parser.parseFromString('<', 'text/xml'); var parseErrorNS = errorParse.getElementsByTagName("parsererror")[0].namespaceURI; return this._provider._xmldoc.getElementsByTagNameNS(parseErrorNS, 'parsererror').length <= 0; } return true; } } OSF.XmlProcessor = XmlProcessor; })(OSF || (OSF = {})); var OSF; (function (OSF) { let AppName; (function (AppName) { AppName[AppName["Unsupported"] = 0] = "Unsupported"; AppName[AppName["Excel"] = 1] = "Excel"; AppName[AppName["Word"] = 2] = "Word"; AppName[AppName["PowerPoint"] = 4] = "PowerPoint"; AppName[AppName["Outlook"] = 8] = "Outlook"; AppName[AppName["ExcelWebApp"] = 16] = "ExcelWebApp"; AppName[AppName["WordWebApp"] = 32] = "WordWebApp"; AppName[AppName["OutlookWebApp"] = 64] = "OutlookWebApp"; AppName[AppName["Project"] = 128] = "Project"; AppName[AppName["AccessWebApp"] = 256] = "AccessWebApp"; AppName[AppName["PowerpointWebApp"] = 512] = "PowerpointWebApp"; AppName[AppName["ExcelIOS"] = 1024] = "ExcelIOS"; AppName[AppName["Sway"] = 2048] = "Sway"; AppName[AppName["WordIOS"] = 4096] = "WordIOS"; AppName[AppName["PowerPointIOS"] = 8192] = "PowerPointIOS"; AppName[AppName["Access"] = 16384] = "Access"; AppName[AppName["Lync"] = 32768] = "Lync"; AppName[AppName["OutlookIOS"] = 65536] = "OutlookIOS"; AppName[AppName["OneNoteWebApp"] = 131072] = "OneNoteWebApp"; AppName[AppName["OneNote"] = 262144] = "OneNote"; AppName[AppName["ExcelWinRT"] = 524288] = "ExcelWinRT"; AppName[AppName["WordWinRT"] = 1048576] = "WordWinRT"; AppName[AppName["PowerpointWinRT"] = 2097152] = "PowerpointWinRT"; AppName[AppName["OutlookAndroid"] = 4194304] = "OutlookAndroid"; AppName[AppName["OneNoteWinRT"] = 8388608] = "OneNoteWinRT"; AppName[AppName["ExcelAndroid"] = 8388609] = "ExcelAndroid"; AppName[AppName["VisioWebApp"] = 8388610] = "VisioWebApp"; AppName[AppName["OneNoteIOS"] = 8388611] = "OneNoteIOS"; AppName[AppName["WordAndroid"] = 8388613] = "WordAndroid"; AppName[AppName["PowerpointAndroid"] = 8388614] = "PowerpointAndroid"; AppName[AppName["Visio"] = 8388615] = "Visio"; AppName[AppName["OneNoteAndroid"] = 4194305] = "OneNoteAndroid"; })(AppName = OSF.AppName || (OSF.AppName = {})); })(OSF || (OSF = {})); var DEBUG = true; var OSF; (function (OSF) { let OsfNavigationMode; (function (OsfNavigationMode) { OsfNavigationMode[OsfNavigationMode["DefaultMode"] = 0] = "DefaultMode"; OsfNavigationMode[OsfNavigationMode["CategoryMode"] = 1] = "CategoryMode"; OsfNavigationMode[OsfNavigationMode["TrustPageMode"] = 2] = "TrustPageMode"; OsfNavigationMode[OsfNavigationMode["QueryResultMode"] = 3] = "QueryResultMode"; })(OsfNavigationMode = OSF.OsfNavigationMode || (OSF.OsfNavigationMode = {})); OSF.ManifestNamespaces = { "1.0": 'xmlns="http://schemas.microsoft.com/office/appforoffice/1.0" xmlns:o="http://schemas.microsoft.com/office/appforoffice/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"', "1.1": 'xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:o="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xmlns:c="http://schemas.microsoft.com/office/contentappversionoverrides" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides"' }; OSF.ManifestSchemaVersion = { "1.0": "1.0", "1.1": "1.1" }; class RequirementsChecker { constructor(supportedCapabilities, supportedHosts, supportedRequirements, supportedControlTargets, supportedOmexAppVersions) { this.defaultMinMaxVersion = "1.1"; this.setCapabilities(supportedCapabilities); this.setHosts(supportedHosts); this.setRequirements(supportedRequirements); this.setSupportedControlTargets(supportedControlTargets); this.setSupportedOmexAppVersions(supportedOmexAppVersions); this.setFilteringEnabled(false); } isManifestSupported(manifest) { if (!this.isFilteringEnabled()) { return true; } if (!manifest) { return false; } var manifestSchemaVersion = manifest.getManifestSchemaVersion() || OSF.ManifestSchemaVersion["1.0"]; switch (manifestSchemaVersion) { case OSF.ManifestSchemaVersion["1.0"]: return this._checkManifest1_0(manifest); case OSF.ManifestSchemaVersion["1.1"]: return this._checkManifest1_1(manifest); default: return false; } } isEntitlementFromOmexSupported(entitlement) { if (!this.isFilteringEnabled()) { return true; } if (!entitlement) { return false; } var targetType; switch (entitlement.appSubType) { case "1": targetType = OSF.OsfControlTarget.TaskPane; break; case "2": targetType = OSF.OsfControlTarget.InContent; break; case "3": targetType = OSF.OsfControlTarget.Contextual; break; case "4": targetType = OSF.OsfControlTarget.TaskPane; break; default: return false; } if (!this._checkControlTarget(targetType)) { return false; } if (!entitlement.requirements && !entitlement.hosts) { if (!entitlement.hasOwnProperty("appVersions") || entitlement.appVersions === undefined) { return true; } return this._checkOmexAppVersions(entitlement.appVersions); } var pseudoParser = new OSF.Manifest.Manifest(function () { }); var requirements, requirementsNode, hosts, hostsNode; if (entitlement.requirements) { pseudoParser._xmlProcessor = new OSF.XmlProcessor(entitlement.requirements, OSF.ManifestNamespaces["1.1"]); requirementsNode = pseudoParser._xmlProcessor.getDocumentElement(); } requirements = pseudoParser._parseRequirements(requirementsNode); if (entitlement.hosts) { pseudoParser._xmlProcessor = new OSF.XmlProcessor(entitlement.hosts, OSF.ManifestNamespaces["1.1"]); hostsNode = pseudoParser._xmlProcessor.getDocumentElement(); } hosts = pseudoParser._parseHosts(hostsNode); return this._checkHosts(hosts) && this._checkSets(requirements.sets) && this._checkMethods(requirements.methods); } isEntitlementFromCorpCatalogSupported(entitlement) { if (!this.isFilteringEnabled()) { return true; } if (!entitlement) { return false; } var targetType = OSF.OfficeAppType[entitlement.OEType]; if (!this._checkControlTarget(targetType)) { return false; } var pseudoParser = new OSF.Manifest.Manifest(function () { }); var hosts, sets, methods; if (entitlement.OfficeExtensionCapabilitiesXML) { pseudoParser._xmlProcessor = new OSF.XmlProcessor(entitlement.OfficeExtensionCapabilitiesXML, OSF.ManifestNamespaces["1.1"]); var xmlNode, requirements; xmlNode = pseudoParser._xmlProcessor.getDocumentElement(); requirements = pseudoParser._parseRequirements(xmlNode); sets = requirements.sets; methods = requirements.methods; hosts = pseudoParser._parseHosts(xmlNode); } return this._checkHosts(hosts) && this._checkSets(sets) && this._checkMethods(methods); } setCapabilities(capabilities) { this._supportedCapabilities = this._scalarArrayToObject(capabilities); } setHosts(hosts) { this._supportedHosts = this._scalarArrayToObject(hosts); } setRequirements(requirements) { this._supportedSets = requirements && this._arrayToSetsObject(requirements.sets) || {}; this._supportedMethods = requirements && this._scalarArrayToObject(requirements.methods) || {}; } setSupportedControlTargets(controlTargets) { this._supportedControlTargets = this._scalarArrayToObject(controlTargets); } setSupportedOmexAppVersions(appVersions) { this._supportedOmexAppVersions = appVersions && appVersions.slice ? appVersions.slice(0) : []; } setFilteringEnabled(filteringEnabled) { this._filteringEnabled = filteringEnabled ? true : false; } isFilteringEnabled() { return this._filteringEnabled; } _checkManifest1_0(manifest) { return this._checkCapabilities(manifest.getCapabilities()); } _checkCapabilities(askedCapabilities) { if (!askedCapabilities || askedCapabilities.length === 0) { return true; } for (var i = 0; i < askedCapabilities.length; i++) { if (this._supportedCapabilities[askedCapabilities[i]]) { return true; } } return false; } _checkManifest1_1(manifest) { var askedRequirements = manifest.getRequirements() || {}; return this._checkHosts(manifest.getHosts()) && this._checkSets(askedRequirements.sets) && this._checkMethods(askedRequirements.methods); } _checkHosts(askedHosts) { if (!askedHosts || askedHosts.length === 0) { return true; } for (var i = 0; i < askedHosts.length; i++) { if (this._supportedHosts[askedHosts[i]]) { return true; } } return false; } _checkSets(askedSets) { if (!askedSets || askedSets.length === 0) { return true; } for (var i = 0; i < askedSets.length; i++) { var askedSet = askedSets[i]; var supportedSet = this._supportedSets[askedSet.name.toLowerCase()]; if (!supportedSet) { return false; } if (askedSet.version) { if (this._compareVersionStrings(supportedSet.minVersion || this.defaultMinMaxVersion, askedSet.version) > 0 || this._compareVersionStrings(supportedSet.maxVersion || this.defaultMinMaxVersion, askedSet.version) < 0) { return false; } } } return true; } _checkMethods(askedMethods) { if (!askedMethods || askedMethods.length === 0) { return true; } for (var i = 0; i < askedMethods.length; i++) { if (!this._supportedMethods[askedMethods[i]]) { return false; } } return true; } _checkControlTarget(askedControlTarget) { return askedControlTarget != undefined && this._supportedControlTargets[askedControlTarget]; } _checkOmexAppVersions(askedAppVersions) { if (!askedAppVersions) { return false; } for (var i = 0; i < this._supportedOmexAppVersions.length; i++) { if (askedAppVersions.indexOf(this._supportedOmexAppVersions[i]) >= 0) { return true; } } return false; } _scalarArrayToObject(array) { var obj = {}; if (array && array.length) { for (var i = 0; i < array.length; i++) { if (array[i] != undefined) { obj[array[i]] = true; } } } return obj; } _arrayToSetsObject(array) { var obj = {}; if (array && array.length) { for (var i = 0; i < array.length; i++) { var set = array[i]; if (set && set.name != undefined) { obj[set.name.toLowerCase()] = set; } } } return obj; } _getSupportedSet() { var obj = {}; var supportSetNames = Object.getOwnPropertyNames(this._supportedSets); for (var i = 0; i < supportSetNames.length; i++) { var supportedSet = this._supportedSets[supportSetNames[i]]; obj[supportedSet.name.toLowerCase()] = supportedSet.maxVersion || this.defaultMinMaxVersion; } if (typeof (JSON) !== "undefined") { return JSON.stringify(obj); } return obj; } _getSupportedSetAsCapabilities() { return Object.getOwnPropertyNames(this._supportedSets).map(name => { const supportedSet = this._supportedSets[name]; return ({ Name: supportedSet.name.toLowerCase(), Version: supportedSet.maxVersion || this.defaultMinMaxVersion }); }); } _compareVersionStrings(leftVersion, rightVersion) { leftVersion = leftVersion.split('.'); rightVersion = rightVersion.split('.'); var maxComponentCount = Math.max(leftVersion.length, rightVersion.length); for (var i = 0; i < maxComponentCount; i++) { var leftInt = parseInt(leftVersion[i], 10) || 0, rightInt = parseInt(rightVersion[i], 10) || 0; if (leftInt === rightInt) { continue; } return leftInt - rightInt; } return 0; } } OSF.RequirementsChecker = RequirementsChecker; })(OSF || (OSF = {})); var Telemetry; (function (Telemetry) { "use strict"; let ULSTraceLevel; (function (ULSTraceLevel) { ULSTraceLevel[ULSTraceLevel["unexpected"] = 10] = "unexpected"; ULSTraceLevel[ULSTraceLevel["warning"] = 15] = "warning"; ULSTraceLevel[ULSTraceLevel["info"] = 50] = "info"; ULSTraceLevel[ULSTraceLevel["verbose"] = 100] = "verbose"; ULSTraceLevel[ULSTraceLevel["verboseEx"] = 200] = "verboseEx"; })(ULSTraceLevel = Telemetry.ULSTraceLevel || (Telemetry.ULSTraceLevel = {})); let ULSCat; (function (ULSCat) { ULSCat[ULSCat["msoulscat_Osf_Latency"] = 1401] = "msoulscat_Osf_Latency"; ULSCat[ULSCat["msoulscat_Osf_Notification"] = 1402] = "msoulscat_Osf_Notification"; ULSCat[ULSCat["msoulscat_Osf_Runtime"] = 1403] = "msoulscat_Osf_Runtime"; ULSCat[ULSCat["msoulscat_Osf_AppManagementMenu"] = 1404] = "msoulscat_Osf_AppManagementMenu"; ULSCat[ULSCat["msoulscat_Osf_InsertionDialogSession"] = 1405] = "msoulscat_Osf_InsertionDialogSession"; ULSCat[ULSCat["msoulscat_Osf_UploadFileDevCatelog"] = 1406] = "msoulscat_Osf_UploadFileDevCatelog"; ULSCat[ULSCat["msoulscat_Osf_UploadFileDevCatalogUsage"] = 1411] = "msoulscat_Osf_UploadFileDevCatalogUsage"; })(ULSCat = Telemetry.ULSCat || (Telemetry.ULSCat = {})); let AppManagementMenuFlags; (function (AppManagementMenuFlags) { AppManagementMenuFlags[AppManagementMenuFlags["ConfirmationDialogCancel"] = 256] = "ConfirmationDialogCancel"; AppManagementMenuFlags[AppManagementMenuFlags["InsertionDialogClosed"] = 512] = "InsertionDialogClosed"; AppManagementMenuFlags[AppManagementMenuFlags["IsAnonymous"] = 1024] = "IsAnonymous"; })(AppManagementMenuFlags || (AppManagementMenuFlags = {})); let InsertionDialogStateFlags; (function (InsertionDialogStateFlags) { InsertionDialogStateFlags[InsertionDialogStateFlags["Undefined"] = 0] = "Undefined"; InsertionDialogStateFlags[InsertionDialogStateFlags["Inserted"] = 1] = "Inserted"; InsertionDialogStateFlags[InsertionDialogStateFlags["Canceled"] = 2] = "Canceled"; InsertionDialogStateFlags[InsertionDialogStateFlags["Closed"] = 3] = "Closed"; InsertionDialogStateFlags[InsertionDialogStateFlags["TrustPageVisited"] = 8] = "TrustPageVisited"; })(InsertionDialogStateFlags || (InsertionDialogStateFlags = {})); class LatencyStopwatch { constructor() { this.timeValue = 0; } Start() { this.timeValue = -(new Date().getTime()); this.finishedMeasurement = false; } Stop() { if (this.timeValue < 0) { this.timeValue += (new Date().getTime()); this.finishedMeasurement = true; } } get Finished() { return this.finishedMeasurement; } get ElapsedTime() { var elapsedTime = this.timeValue; if (!this.Finished && elapsedTime < 0) { elapsedTime = Math.abs(elapsedTime) - (new Date().getTime()); } return elapsedTime; } } Telemetry.LatencyStopwatch = LatencyStopwatch; class Context { } Telemetry.Context = Context; class Logger { static SetExternalLogger(extLogger) { Logger.s_externalLogger = extLogger; } static SendULSTraceTag(category, level, data, tagId) { if (!Microsoft.Office.WebExtension.FULSSupported) { return; } if (window.Diag && Diag.UULS && Diag.UULS.trace) { Diag.UULS.trace(tagId, category, level, data); } else if (Logger.s_externalLogger && Logger.s_externalLogger.sendTraceTag) { Logger.s_externalLogger.sendTraceTag(tagId, category, level, data); } } } Logger.s_externalLogger = null; Telemetry.Logger = Logger; class NotificationLogger { constructor() { } static Instance() { if (!NotificationLogger.instance) { NotificationLogger.instance = new NotificationLogger(); } return NotificationLogger.instance; } LogData(data) { Logger.SendULSTraceTag(NotificationLogger.category, NotificationLogger.level, data.SerializeRow(), 0x005c815f); } } NotificationLogger.category = ULSCat.msoulscat_Osf_Notification; NotificationLogger.level = ULSTraceLevel.info; Telemetry.NotificationLogger = NotificationLogger; class AppManagementMenuLogger { constructor() { } static Instance() { if (!AppManagementMenuLogger.instance) { AppManagementMenuLogger.instance = new AppManagementMenuLogger(); } return AppManagementMenuLogger.instance; } LogData(data) { Logger.SendULSTraceTag(AppManagementMenuLogger.category, AppManagementMenuLogger.level, data.SerializeRow(), 0x1f31d7e1); } } AppManagementMenuLogger.category = ULSCat.msoulscat_Osf_AppManagementMenu; AppManagementMenuLogger.level = ULSTraceLevel.info; Telemetry.AppManagementMenuLogger = AppManagementMenuLogger; class UploadFileDevCatelogLogger { constructor() { } static Instance() { if (!UploadFileDevCatelogLogger.instance) { UploadFileDevCatelogLogger.instance = new UploadFileDevCatelogLogger(); } return UploadFileDevCatelogLogger.instance; } LogData(data) { Logger.SendULSTraceTag(UploadFileDevCatelogLogger.category, UploadFileDevCatelogLogger.level, data.SerializeRow(), 0x1f31d7e2); } } UploadFileDevCatelogLogger.category = ULSCat.msoulscat_Osf_UploadFileDevCatelog; UploadFileDevCatelogLogger.level = ULSTraceLevel.info; Telemetry.UploadFileDevCatelogLogger = UploadFileDevCatelogLogger; class UploadFileDevCatalogUsageLogger { constructor() { } static Instance() { if (!UploadFileDevCatalogUsageLogger.instance) { UploadFileDevCatalogUsageLogger.instance = new UploadFileDevCatalogUsageLogger(); } return UploadFileDevCatalogUsageLogger.instance; } LogData(data) { Logger.SendULSTraceTag(UploadFileDevCatalogUsageLogger.category, UploadFileDevCatalogUsageLogger.level, data.SerializeRow(), 0x1f31d7e3); } } UploadFileDevCatalogUsageLogger.category = ULSCat.msoulscat_Osf_UploadFileDevCatalogUsage; UploadFileDevCatalogUsageLogger.level = ULSTraceLevel.info; Telemetry.UploadFileDevCatalogUsageLogger = UploadFileDevCatalogUsageLogger; class LatencyLogger { constructor() { } static Instance() { if (!LatencyLogger.instance) { LatencyLogger.instance = new LatencyLogger(); } return LatencyLogger.instance; } LogData(data) { Logger.SendULSTraceTag(LatencyLogger.category, LatencyLogger.level, data.SerializeRow(), 0x00487317); } } LatencyLogger.category = ULSCat.msoulscat_Osf_Latency; LatencyLogger.level = ULSTraceLevel.info; Telemetry.LatencyLogger = LatencyLogger; class InsertionDialogSessionLogger { constructor() { } static Instance() { if (!InsertionDialogSessionLogger.instance) { InsertionDialogSessionLogger.instance = new InsertionDialogSessionLogger(); } return InsertionDialogSessionLogger.instance; } LogData(data) { Logger.SendULSTraceTag(InsertionDialogSessionLogger.category, InsertionDialogSessionLogger.level, data.SerializeRow(), 0x1f31d800); } } InsertionDialogSessionLogger.category = ULSCat.msoulscat_Osf_InsertionDialogSession; InsertionDialogSessionLogger.level = ULSTraceLevel.info; Telemetry.InsertionDialogSessionLogger = InsertionDialogSessionLogger; class AppNotificationHelper { static LogNotification(correlationId, errorResult, notificationClickInfo) { var notificationData = new OSFLog.AppNotificationUsageData(); notificationData.CorrelationId = correlationId; notificationData.ErrorResult = errorResult; notificationData.NotificationClickInfo = notificationClickInfo; NotificationLogger.Instance().LogData(notificationData); } } Telemetry.AppNotificationHelper = AppNotificationHelper; class AppManagementMenuHelper { static LogAppManagementMenuAction(assetId, operationMetadata, untrustedCount, isDialogClosed, isAnonymous, hrStatus) { var appManagementMenuData = new OSFLog.AppManagementMenuUsageData(); var assetIdNumber = assetId.toLowerCase().indexOf("wa") === 0 ? parseInt(assetId.substring(2), 10) : parseInt(assetId, 10); if (isDialogClosed) { operationMetadata |= AppManagementMenuFlags.InsertionDialogClosed; } if (isAnonymous) { operationMetadata |= AppManagementMenuFlags.IsAnonymous; } appManagementMenuData.AssetId = assetIdNumber; appManagementMenuData.OperationMetadata = operationMetadata; appManagementMenuData.ErrorResult = hrStatus; AppManagementMenuLogger.Instance().LogData(appManagementMenuData); } } Telemetry.AppManagementMenuHelper = AppManagementMenuHelper; class UploadFileDevCatelogHelper { static LogUploadFileDevCatelogAction(correlationId, operationMetadata, untrustedCount, isDialogClosed, isAnonymous, hrStatus) { var uploadFileDevCatelogData = new OSFLog.UploadFileDevCatelogUsageData(); uploadFileDevCatelogData.CorrelationId = correlationId; uploadFileDevCatelogData.OperationMetadata = operationMetadata; uploadFileDevCatelogData.ErrorResult = hrStatus; UploadFileDevCatelogLogger.Instance().LogData(uploadFileDevCatelogData); } } Telemetry.UploadFileDevCatelogHelper = UploadFileDevCatelogHelper; class UploadFileDevCatalogUsageHelper { static LogUploadFileDevCatalogUsageAction(correlationId, storeType, id, appVersion, appTargetType, isAppCommand, appSizeWidth, appSizeHeight) { var uploadFileDevCatalogUsageData = new OSFLog.UploadFileDevCatalogUsageUsageData(); uploadFileDevCatalogUsageData.CorrelationId = correlationId; uploadFileDevCatalogUsageData.StoreType = storeType; uploadFileDevCatalogUsageData.AppId = id; uploadFileDevCatalogUsageData.AppVersion = appVersion; uploadFileDevCatalogUsageData.AppTargetType = appTargetType; uploadFileDevCatalogUsageData.IsAppCommand = isAppCommand; uploadFileDevCatalogUsageData.AppSizeWidth = appSizeWidth; uploadFileDevCatalogUsageData.AppSizeHeight = appSizeHeight; UploadFileDevCatalogUsageLogger.Instance().LogData(uploadFileDevCatalogUsageData); } } Telemetry.UploadFileDevCatalogUsageHelper = UploadFileDevCatalogUsageHelper; class AppLoadTimeHelper { static GenerateActivationMessage(activationRuntimeType, correlationId) { var message = ""; if (activationRuntimeType != null) { message += "ActivationRuntimeType: " + activationRuntimeType.toString() + "|"; } if (correlationId != null) { message += "CorrelationId: " + correlationId; } return message; } static ActivationStart(context, appInfo, assetId, correlationId, instanceId, runtimeType) { AppLoadTimeHelper.activatingNumber++; context.LoadTime = new OSFLog.AppLoadTimeUsageData(); context.Timers = {}; context.LoadTime.CorrelationId = correlationId; context.LoadTime.AppInfo = appInfo; context.LoadTime.ActivationInfo = 0; context.LoadTime.InstanceId = instanceId; context.LoadTime.AssetId = assetId; context.LoadTime.Stage1Time = 0; context.Timers["Stage1Time"] = new LatencyStopwatch(); context.LoadTime.Stage2Time = 0; context.Timers["Stage2Time"] = new LatencyStopwatch(); context.LoadTime.Stage3Time = 0; context.LoadTime.Stage4Time = 0; context.Timers["Stage4Time"] = new LatencyStopwatch(); context.LoadTime.Stage5Time = 0; context.Timers["Stage5Time"] = new LatencyStopwatch(); context.LoadTime.Stage6Time = AppLoadTimeHelper.activatingNumber; context.LoadTime.Stage7Time = 0; context.Timers["Stage7Time"] = new LatencyStopwatch(); context.LoadTime.Stage8Time = 0; context.Timers["Stage8Time"] = new LatencyStopwatch(); context.LoadTime.Stage9Time = 0; context.Timers["Stage9Time"] = new LatencyStopwatch(); context.LoadTime.Stage10Time = 0; context.Timers["Stage10Time"] = new LatencyStopwatch(); context.LoadTime.Stage11Time = 0; context.Timers["Stage11Time"] = new LatencyStopwatch(); context.LoadTime.ErrorResult = 0; context.ActivationRuntimeType = runtimeType; AppLoadTimeHelper.StartStopwatch(context, "Stage1Time"); Logger.SendULSTraceTag(ULSCat.msoulscat_Osf_Runtime, ULSTraceLevel.info, AppLoadTimeHelper.GenerateActivationMessage(runtimeType, correlationId), 0x1f31d801); } static ActivationEnd(context) { AppLoadTimeHelper.ActivateEndInternal(context); } static PageStart(context) { AppLoadTimeHelper.StartStopwatch(context, "Stage2Time"); } static PageLoaded(context) { AppLoadTimeHelper.StopStopwatch(context, "Stage2Time"); } static ServerCallStart(context) { AppLoadTimeHelper.StartStopwatch(context, "Stage4Time"); } static ServerCallEnd(context) { AppLoadTimeHelper.StopStopwatch(context, "Stage4Time"); } static AuthenticationStart(context) { AppLoadTimeHelper.StartStopwatch(context, "Stage5Time"); } static AuthenticationEnd(context) { AppLoadTimeHelper.StopStopwatch(context, "Stage5Time"); } static EntitlementCheckStart(context) { AppLoadTimeHelper.StartStopwatch(context, "Stage7Time"); } static EntitlementCheckEnd(context) { AppLoadTimeHelper.StopStopwatch(context, "Stage7Time"); } static KilledAppsCheckStart(context) { AppLoadTimeHelper.StartStopwatch(context, "Stage8Time"); } static KilledAppsCheckEnd(context) { AppLoadTimeHelper.StopStopwatch(context, "Stage8Time"); } static AppStateCheckStart(context) { AppLoadTimeHelper.StartStopwatch(context, "Stage9Time"); } static AppStateCheckEnd(context) { AppLoadTimeHelper.StopStopwatch(context, "Stage9Time"); } static ManifestRequestStart(context) { AppLoadTimeHelper.StartStopwatch(context, "Stage10Time"); } static ManifestRequestEnd(context) { AppLoadTimeHelper.StopStopwatch(context, "Stage10Time"); } static OfficeJSStartToLoad(context) { AppLoadTimeHelper.StartStopwatch(context, "Stage11Time"); } static OfficeJSLoaded(context) { AppLoadTimeHelper.StopStopwatch(context, "Stage11Time"); } static SetAnonymousFlag(context, anonymousFlag) { AppLoadTimeHelper.SetActivationInfoField(context, AppLoadTimeHelper.ConvertFlagToBit(anonymousFlag), 2, 0); } static SetRetryCount(context, retryCount) { AppLoadTimeHelper.SetActivationInfoField(context, retryCount, 3, 2); } static SetManifestTrustCachedFlag(context, manifestTrustCachedFlag) { AppLoadTimeHelper.SetActivationInfoField(context, AppLoadTimeHelper.ConvertFlagToBit(manifestTrustCachedFlag), 2, 5); } static SetManifestDataCachedFlag(context, manifestDataCachedFlag) { AppLoadTimeHelper.SetActivationInfoField(context, AppLoadTimeHelper.ConvertFlagToBit(manifestDataCachedFlag), 2, 7); } static SetOmexHasEntitlementFlag(context, omexHasEntitlementFlag) { AppLoadTimeHelper.SetActivationInfoField(context, AppLoadTimeHelper.ConvertFlagToBit(omexHasEntitlementFlag), 2, 9); } static SetManifestDataInvalidFlag(context, manifestDataInvalidFlag) { AppLoadTimeHelper.SetActivationInfoField(context, AppLoadTimeHelper.ConvertFlagToBit(manifestDataInvalidFlag), 2, 11); } static SetAppStateDataCachedFlag(context, appStateDataCachedFlag) { AppLoadTimeHelper.SetActivationInfoField(context, AppLoadTimeHelper.ConvertFlagToBit(appStateDataCachedFlag), 2, 13); } static SetAppStateDataInvalidFlag(context, appStateDataInvalidFlag) { AppLoadTimeHelper.SetActivationInfoField(context, AppLoadTimeHelper.ConvertFlagToBit(appStateDataInvalidFlag), 2, 15); } static SetActivationRuntimeType(context, activationRuntimeType) { AppLoadTimeHelper.SetActivationInfoField(context, activationRuntimeType, 2, 17); } static SetErrorResult(context, result) { if (context.LoadTime) { context.LoadTime.ErrorResult = result; AppLoadTimeHelper.ActivateEndInternal(context); } } static SetBit(context, value, offset, length) { AppLoadTimeHelper.SetActivationInfoField(context, value, length || 2, offset); } static StartStopwatch(context, name) { if (context.LoadTime && context.Timers && context.Timers[name]) { context.Timers[name].Start(); AppLoadTimeHelper.UpdateActivatingNumber(context); } } static StopStopwatch(context, name) { if (context.LoadTime && context.Timers && context.Timers[name]) { context.Timers[name].Stop(); AppLoadTimeHelper.UpdateActivatingNumber(context); } } static ConvertFlagToBit(flag) { if (flag) { return 2; } else { return 1; } } static SetActivationInfoField(context, value, length, offset) { if (context.LoadTime) { AppLoadTimeHelper.UpdateActivatingNumber(context); context.LoadTime.ActivationInfo = AppLoadTimeHelper.SetBitField(context.LoadTime.ActivationInfo, value, length, offset); } } static SetBitField(field, value, length, offset) { var mask = (Math.pow(2, length) - 1) << offset; var cleanField = field & ~mask; return cleanField | (value << offset); } static UpdateActivatingNumber(context) { if (context.LoadTime) { context.LoadTime.Stage6Time = (context.LoadTime.Stage6Time > AppLoadTimeHelper.activatingNumber) ? context.LoadTime.Stage6Time : AppLoadTimeHelper.activatingNumber; } } static ActivateEndInternal(context) { if (context.LoadTime) { AppLoadTimeHelper.StopStopwatch(context, "Stage1Time"); if (context.Timers) { for (var key in context.Timers) { if (context.Timers[key].ElapsedTime != null) { context.LoadTime[key] = context.Timers[key].ElapsedTime; } } } Logger.SendULSTraceTag(ULSCat.msoulscat_Osf_Runtime, ULSTraceLevel.info, AppLoadTimeHelper.GenerateActivationMessage(context.ActivationRuntimeType, context.LoadTime.CorrelationId), 0x1f31d802); LatencyLogger.Instance().LogData(context.LoadTime); context.LoadTime = null; AppLoadTimeHelper.activatingNumber--; } } } AppLoadTimeHelper.activatingNumber = 0; Telemetry.AppLoadTimeHelper = AppLoadTimeHelper; class RuntimeTelemetryHelper { static LogProxyFailure(appCorrelationId, methodName, errorInfo) { var constructedMessage; if (appCorrelationId == null) { appCorrelationId = ""; } constructedMessage = OSF.OUtil.formatString("appCorrelationId:{0}, methodName:{1}", appCorrelationId, methodName); Object.keys(errorInfo).forEach(function (key) { var value = errorInfo[key]; if (value != null) { value = value.toString(); } constructedMessage += ", " + key + ":" + value; }); let logWarning = true; const statusCodePattern = new RegExp("statusCode:(\\d+)"); let match = constructedMessage.match(statusCodePattern); if (match) { switch (match[1]) { case "404": logWarning = false; Logger.SendULSTraceTag(RuntimeTelemetryHelper.category, ULSTraceLevel.info, constructedMessage, 0x1e420558); break; default: logWarning = true; break; } } if (logWarning) { Logger.SendULSTraceTag(RuntimeTelemetryHelper.category, ULSTraceLevel.warning, constructedMessage, 0x005c8160); } } static LogExceptionTag(message, exception, appCorrelationId, tagId) { var constructedMessage = message; if (exception) { if (exception.name) { constructedMessage += " Exception name:" + exception.name + "."; } if (exception.paramName) { constructedMessage += " Param name:" + exception.paramName + "."; } if (exception.message) { constructedMessage += " Message:" + exception.message + "."; } if (exception.stack) { constructedMessage += " [Stack:" + exception.stack + "]"; } } if (appCorrelationId != null) { constructedMessage += " AppCorrelationId:" + appCorrelationId + "."; } Logger.SendULSTraceTag(RuntimeTelemetryHelper.category, ULSTraceLevel.warning, constructedMessage, tagId); } static LogCommonMessageTag(message, appCorrelationId, tagId) { if (appCorrelationId != null) { message += " AppCorrelationId:" + appCorrelationId + "."; } Logger.SendULSTraceTag(RuntimeTelemetryHelper.category, ULSTraceLevel.info, message, tagId); } } RuntimeTelemetryHelper.category = ULSCat.msoulscat_Osf_Runtime; Telemetry.RuntimeTelemetryHelper = RuntimeTelemetryHelper; class InsertionDialogSessionHelper { static LogInsertionDialogSession(assetId, totalSessionTime, trustPageSessionTime, appInserted, lastActiveTab, lastActiveTabCount) { var insertionDialogSessionData = new OSFLog.InsertionDialogSessionUsageData(); var assetIdNumber = assetId.toLowerCase().indexOf("wa") === 0 ? parseInt(assetId.substring(2), 10) : parseInt(assetId, 10); var dialogState = InsertionDialogStateFlags.Undefined; if (appInserted) { dialogState |= InsertionDialogStateFlags.Inserted; } else { dialogState |= InsertionDialogStateFlags.Canceled; } if (trustPageSessionTime > 0) { dialogState |= InsertionDialogStateFlags.TrustPageVisited; } insertionDialogSessionData.AssetId = assetIdNumber; insertionDialogSessionData.TotalSessionTime = totalSessionTime; insertionDialogSessionData.TrustPageSessionTime = trustPageSessionTime; insertionDialogSessionData.DialogState = dialogState; insertionDialogSessionData.LastActiveTab = lastActiveTab; insertionDialogSessionData.LastActiveTabCount = lastActiveTabCount; InsertionDialogSessionLogger.Instance().LogData(insertionDialogSessionData); } } Telemetry.InsertionDialogSessionHelper = InsertionDialogSessionHelper; class PrivacyRules { static IsPrivateAddin(storeType, assetId, exchangeExtensionProviderName, exchangeExtensionType, storeId) { switch ((storeType || "").toLowerCase()) { case OSF.StoreType.OMEX: case OSF.StoreType.HardCodedPreinstall: case OSF.StoreType.FirstParty: case OSF.StoreType.Sdx: case OSF.StoreType.WopiCatalog: return false; case OSF.StoreType.SPCatalog: case OSF.StoreType.SPApp: case OSF.StoreType.FileSystem: case OSF.StoreType.Registry: case OSF.StoreType.UploadFileDevCatalog: return true; case OSF.StoreType.PrivateCatalog: { if (assetId && assetId.toLowerCase().indexOf("wa") === 0) { return false; } return true; } case OSF.StoreType.Exchange: { var extensionTypeLowerCase = exchangeExtensionType != null ? exchangeExtensionType.toLowerCase() : null; if (extensionTypeLowerCase && extensionTypeLowerCase === "default" || extensionTypeLowerCase === "marketplace" || extensionTypeLowerCase === "preinstalled" || extensionTypeLowerCase === "marketplaceprivatecatalog") { return false; } var providerNameLowercase = exchangeExtensionProviderName != null ? exchangeExtensionProviderName.toLowerCase() : null; if (providerNameLowercase && providerNameLowercase === "microsoft" || providerNameLowercase === "microsoft corp" || providerNameLowercase === "microsoft corp." || providerNameLowercase === "microsoft corporation") { return false; } return true; } case OSF.StoreType.InMemory: default: Logger.SendULSTraceTag(ULSCat.msoulscat_Osf_Notification, ULSTraceLevel.warning, "Unknown StoreType: " + storeType + " in function IsPrivateAddin.", 0x1f31d803); return true; } } static GetAssetId(storeType, storeId, assetId, exchangeExtensionProviderName, exchangeExtensionType) { Telemetry.RuntimeTelemetryHelper.LogExceptionTag("PrivacyRules GetAssetId is deprecated", null, null, 0x1e60e595); return (PrivacyRules.IsPrivateAddin(storeType, assetId, exchangeExtensionProviderName, exchangeExtensionType, storeId) ? PrivacyRules.privateCompliantId : assetId); } static GetPrivacyCompliantId(solutionId, storeType, assetId, exchangeExtensionProviderName, exchangeExtensionType, storeId) { return (PrivacyRules.IsPrivateAddin(storeType, assetId, exchangeExtensionProviderName, exchangeExtensionType, storeId) ? PrivacyRules.privateCompliantId : solutionId); } } PrivacyRules.privateCompliantId = "PRIVATE"; Telemetry.PrivacyRules = PrivacyRules; })(Telemetry || (Telemetry = {})); var OSFLog; (function (OSFLog) { class BaseUsageData { constructor(table) { this._table = table; this._fields = {}; } get Fields() { return this._fields; } get Table() { return this._table; } SerializeFields() { } SetSerializedField(key, value) { if (typeof (value) !== "undefined" && value !== null) { this._serializedFields[key] = value.toString(); } } SerializeRow() { this._serializedFields = {}; this.SetSerializedField("Table", this._table); this.SerializeFields(); return JSON.stringify(this._serializedFields); } } OSFLog.BaseUsageData = BaseUsageData; class AppLoadTimeUsageData extends BaseUsageData { constructor() { super("AppLoadTime"); } get CorrelationId() { return this.Fields["CorrelationId"]; } set CorrelationId(value) { this.Fields["CorrelationId"] = value; } get AppInfo() { return this.Fields["AppInfo"]; } set AppInfo(value) { this.Fields["AppInfo"] = value; } get ActivationInfo() { return this.Fields["ActivationInfo"]; } set ActivationInfo(value) { this.Fields["ActivationInfo"] = value; } get InstanceId() { return this.Fields["InstanceId"]; } set InstanceId(value) { this.Fields["InstanceId"] = value; } get AssetId() { return this.Fields["AssetId"]; } set AssetId(value) { this.Fields["AssetId"] = value; } get Stage1Time() { return this.Fields["Stage1Time"]; } set Stage1Time(value) { this.Fields["Stage1Time"] = value; } get Stage2Time() { return this.Fields["Stage2Time"]; } set Stage2Time(value) { this.Fields["Stage2Time"] = value; } get Stage3Time() { return this.Fields["Stage3Time"]; } set Stage3Time(value) { this.Fields["Stage3Time"] = value; } get Stage4Time() { return this.Fields["Stage4Time"]; } set Stage4Time(value) { this.Fields["Stage4Time"] = value; } get Stage5Time() { return this.Fields["Stage5Time"]; } set Stage5Time(value) { this.Fields["Stage5Time"] = value; } get Stage6Time() { return this.Fields["Stage6Time"]; } set Stage6Time(value) { this.Fields["Stage6Time"] = value; } get Stage7Time() { return this.Fields["Stage7Time"]; } set Stage7Time(value) { this.Fields["Stage7Time"] = value; } get Stage8Time() { return this.Fields["Stage8Time"]; } set Stage8Time(value) { this.Fields["Stage8Time"] = value; } get Stage9Time() { return this.Fields["Stage9Time"]; } set Stage9Time(value) { this.Fields["Stage9Time"] = value; } get Stage10Time() { return this.Fields["Stage10Time"]; } set Stage10Time(value) { this.Fields["Stage10Time"] = value; } get Stage11Time() { return this.Fields["Stage11Time"]; } set Stage11Time(value) { this.Fields["Stage11Time"] = value; } get ErrorResult() { return this.Fields["ErrorResult"]; } set ErrorResult(value) { this.Fields["ErrorResult"] = value; } SerializeFields() { this.SetSerializedField("CorrelationId", this.CorrelationId); this.SetSerializedField("AppInfo", this.AppInfo); this.SetSerializedField("ActivationInfo", this.ActivationInfo); this.SetSerializedField("InstanceId", this.InstanceId); this.SetSerializedField("AssetId", this.AssetId); this.SetSerializedField("Stage1Time", this.Stage1Time); this.SetSerializedField("Stage2Time", this.Stage2Time); this.SetSerializedField("Stage3Time", this.Stage3Time); this.SetSerializedField("Stage4Time", this.Stage4Time); this.SetSerializedField("Stage5Time", this.Stage5Time); this.SetSerializedField("Stage6Time", this.Stage6Time); this.SetSerializedField("Stage7Time", this.Stage7Time); this.SetSerializedField("Stage8Time", this.Stage8Time); this.SetSerializedField("Stage9Time", this.Stage9Time); this.SetSerializedField("Stage10Time", this.Stage10Time); this.SetSerializedField("Stage11Time", this.Stage11Time); this.SetSerializedField("ErrorResult", this.ErrorResult); } } OSFLog.AppLoadTimeUsageData = AppLoadTimeUsageData; class AppNotificationUsageData extends BaseUsageData { constructor() { super("AppNotification"); } get CorrelationId() { return this.Fields["CorrelationId"]; } set CorrelationId(value) { this.Fields["CorrelationId"] = value; } get ErrorResult() { return this.Fields["ErrorResult"]; } set ErrorResult(value) { this.Fields["ErrorResult"] = value; } get NotificationClickInfo() { return this.Fields["NotificationClickInfo"]; } set NotificationClickInfo(value) { this.Fields["NotificationClickInfo"] = value; } SerializeFields() { this.SetSerializedField("CorrelationId", this.CorrelationId); this.SetSerializedField("ErrorResult", this.ErrorResult); this.SetSerializedField("NotificationClickInfo", this.NotificationClickInfo); } } OSFLog.AppNotificationUsageData = AppNotificationUsageData; class AppManagementMenuUsageData extends BaseUsageData { constructor() { super("AppManagementMenu"); } get AssetId() { return this.Fields["AssetId"]; } set AssetId(value) { this.Fields["AssetId"] = value; } get OperationMetadata() { return this.Fields["OperationMetadata"]; } set OperationMetadata(value) { this.Fields["OperationMetadata"] = value; } get ErrorResult() { return this.Fields["ErrorResult"]; } set ErrorResult(value) { this.Fields["ErrorResult"] = value; } SerializeFields() { this.SetSerializedField("AssetId", this.AssetId); this.SetSerializedField("OperationMetadata", this.OperationMetadata); this.SetSerializedField("ErrorResult", this.ErrorResult); } } OSFLog.AppManagementMenuUsageData = AppManagementMenuUsageData; class InsertionDialogSessionUsageData extends BaseUsageData { constructor() { super("InsertionDialogSession"); } get AssetId() { return this.Fields["AssetId"]; } set AssetId(value) { this.Fields["AssetId"] = value; } get TotalSessionTime() { return this.Fields["TotalSessionTime"]; } set TotalSessionTime(value) { this.Fields["TotalSessionTime"] = value; } get TrustPageSessionTime() { return this.Fields["TrustPageSessionTime"]; } set TrustPageSessionTime(value) { this.Fields["TrustPageSessionTime"] = value; } get DialogState() { return this.Fields["DialogState"]; } set DialogState(value) { this.Fields["DialogState"] = value; } get LastActiveTab() { return this.Fields["LastActiveTab"]; } set LastActiveTab(value) { this.Fields["LastActiveTab"] = value; } get LastActiveTabCount() { return this.Fields["LastActiveTabCount"]; } set LastActiveTabCount(value) { this.Fields["LastActiveTabCount"] = value; } SerializeFields() { this.SetSerializedField("AssetId", this.AssetId); this.SetSerializedField("TotalSessionTime", this.TotalSessionTime); this.SetSerializedField("TrustPageSessionTime", this.TrustPageSessionTime); this.SetSerializedField("DialogState", this.DialogState); this.SetSerializedField("LastActiveTab", this.LastActiveTab); this.SetSerializedField("LastActiveTabCount", this.LastActiveTabCount); } } OSFLog.InsertionDialogSessionUsageData = InsertionDialogSessionUsageData; class UploadFileDevCatelogUsageData extends BaseUsageData { constructor() { super("UploadFileDevCatelog"); } get CorrelationId() { return this.Fields["CorrelationId"]; } set CorrelationId(value) { this.Fields["CorrelationId"] = value; } get OperationMetadata() { return this.Fields["OperationMetadata"]; } set OperationMetadata(value) { this.Fields["OperationMetadata"] = value; } get ErrorResult() { return this.Fields["ErrorResult"]; } set ErrorResult(value) { this.Fields["ErrorResult"] = value; } SerializeFields() { this.SetSerializedField("CorrelationId", this.CorrelationId); this.SetSerializedField("OperationMetadata", this.OperationMetadata); this.SetSerializedField("ErrorResult", this.ErrorResult); } } OSFLog.UploadFileDevCatelogUsageData = UploadFileDevCatelogUsageData; class UploadFileDevCatalogUsageUsageData extends BaseUsageData { constructor() { super("UploadFileDevCatalogUsage"); } get CorrelationId() { return this.Fields["CorrelationId"]; } set CorrelationId(value) { this.Fields["CorrelationId"] = value; } get StoreType() { return this.Fields["StoreType"]; } set StoreType(value) { this.Fields["StoreType"] = value; } get AppId() { return this.Fields["AppId"]; } set AppId(value) { this.Fields["AppId"] = value; } get AppVersion() { return this.Fields["AppVersion"]; } set AppVersion(value) { this.Fields["AppVersion"] = value; } get AppTargetType() { return this.Fields["AppTargetType"]; } set AppTargetType(value) { this.Fields["AppTargetType"] = value; } get IsAppCommand() { return this.Fields["IsAppCommand"]; } set IsAppCommand(value) { this.Fields["IsAppCommand"] = value; } get AppSizeWidth() { return this.Fields["AppSizeWidth"]; } set AppSizeWidth(value) { this.Fields["AppSizeWidth"] = value; } get AppSizeHeight() { return this.Fields["AppSizeHeight"]; } set AppSizeHeight(value) { this.Fields["AppSizeHeight"] = value; } SerializeFields() { this.SetSerializedField("CorrelationId", this.CorrelationId); this.SetSerializedField("StoreType", this.StoreType); this.SetSerializedField("AppId", this.AppId); this.SetSerializedField("AppVersion", this.AppVersion); this.SetSerializedField("AppTargetType", this.AppTargetType); this.SetSerializedField("IsAppCommand", this.IsAppCommand); this.SetSerializedField("AppSizeWidth", this.AppSizeWidth); this.SetSerializedField("AppSizeHeight", this.AppSizeHeight); } } OSFLog.UploadFileDevCatalogUsageUsageData = UploadFileDevCatalogUsageUsageData; })(OSFLog || (OSFLog = {})); var OfficeExt; (function (OfficeExt) { let DataServiceResultCode; (function (DataServiceResultCode) { DataServiceResultCode[DataServiceResultCode["Succeeded"] = 1] = "Succeeded"; DataServiceResultCode[DataServiceResultCode["Failed"] = 0] = "Failed"; DataServiceResultCode[DataServiceResultCode["ProxyNotReady"] = -1] = "ProxyNotReady"; DataServiceResultCode[DataServiceResultCode["PrxoyUrlEmpty"] = -2] = "PrxoyUrlEmpty"; DataServiceResultCode[DataServiceResultCode["ProxyUrlNotTrusted"] = -3] = "ProxyUrlNotTrusted"; DataServiceResultCode[DataServiceResultCode["UnknownUserType"] = 2] = "UnknownUserType"; DataServiceResultCode[DataServiceResultCode["Unauthenticated"] = 3] = "Unauthenticated"; DataServiceResultCode[DataServiceResultCode["UserResolutionNoMailbox"] = 4] = "UserResolutionNoMailbox"; DataServiceResultCode[DataServiceResultCode["ServerBusy"] = 5] = "ServerBusy"; })(DataServiceResultCode = OfficeExt.DataServiceResultCode || (OfficeExt.DataServiceResultCode = {})); })(OfficeExt || (OfficeExt = {})); var _omexXmlNamespaces = 'xmlns="urn:schemas-microsoft-com:office:office" xmlns:o="urn:schemas-microsoft-com:office:office"'; function _getAppSubType(officeExtentionTarget) { var appSubType; if (officeExtentionTarget === 0) { appSubType = OSF.AppSubType.Content; } else if (officeExtentionTarget === 1) { appSubType = OSF.AppSubType.Taskpane; } else { throw OsfMsAjaxFactory.msAjaxError.argument("officeExtentionTarget"); } return appSubType; } ; function _getAppVersion(applicationName) { var appVersion = OSF.AppVersion[applicationName.toLowerCase()]; if (typeof appVersion == "undefined") { throw OsfMsAjaxFactory.msAjaxError.argument("applicationName"); } return appVersion; } ; function _invokeCallbackTag(callback, status, result, errorMessage, executor, tagId) { var constructedMessage = errorMessage; if (callback) { try { var response = { "status": status, "result": result, "failureInfo": null }; var setFailureInfoProperty = function _invokeCallbackTag$setFailureInfoProperty(response, name, value) { if (response.failureInfo === null) { response.failureInfo = {}; } response.failureInfo[name] = value; }; if (executor) { var httpStatusCode = -1; if (executor.get_statusCode) { httpStatusCode = executor.get_statusCode(); } if (!constructedMessage) { if (executor.get_timedOut && executor.get_timedOut()) { constructedMessage = "Request timed out."; } else if (executor.get_aborted && executor.get_aborted()) { constructedMessage = "Request aborted."; } } if (httpStatusCode >= 400 || status === statusCode.Failed || constructedMessage) { setFailureInfoProperty(response, "statusCode", httpStatusCode); setFailureInfoProperty(response, "tagId", tagId); var webRequest = executor.get_webRequest(); if (webRequest) { if (webRequest.getResolvedUrl) { setFailureInfoProperty(response, "url", webRequest.getResolvedUrl()); } if (executor.getResponseHeader && webRequest.get_userContext && webRequest.get_userContext() && !webRequest.get_userContext().correlationId) { var correlationId = executor.getResponseHeader("X-CorrelationId"); setFailureInfoProperty(response, "correlationId", correlationId); } } } } if (constructedMessage) { setFailureInfoProperty(response, "message", constructedMessage); OsfMsAjaxFactory.msAjaxDebug.trace(constructedMessage); } } catch (ex) { OsfMsAjaxFactory.msAjaxDebug.trace("Encountered exception with logging: " + ex); } callback(response); } } ; var OSF; (function (OSF) { let AppSubType; (function (AppSubType) { AppSubType[AppSubType["Taskpane"] = 1] = "Taskpane"; AppSubType[AppSubType["Content"] = 2] = "Content"; AppSubType[AppSubType["Contextual"] = 3] = "Contextual"; AppSubType[AppSubType["Dictionary"] = 4] = "Dictionary"; })(AppSubType = OSF.AppSubType || (OSF.AppSubType = {})); let AppVersion; (function (AppVersion) { AppVersion["access"] = "ZAC150"; AppVersion["excel"] = "ZXL150"; AppVersion["excelwebapp"] = "WAE160"; AppVersion["outlook"] = "ZOL150"; AppVersion["outlookwebapp"] = "MOW150"; AppVersion["powerpoint"] = "ZPP151"; AppVersion["powerpointwebapp"] = "WAP160"; AppVersion["project"] = "ZPJ150"; AppVersion["word"] = "ZWD150"; AppVersion["wordwebapp"] = "WAW160"; AppVersion["onenotewebapp"] = "WAO160"; AppVersion["visio"] = "ZVO161"; AppVersion["visiowebapp"] = "WAV161"; })(AppVersion = OSF.AppVersion || (OSF.AppVersion = {})); })(OSF || (OSF = {})); var OfficeExt; (function (OfficeExt) { class MicrosoftAjaxFactory { isMsAjaxLoaded() { if (typeof (Sys) !== 'undefined' && typeof (Type) !== 'undefined' && Sys.StringBuilder && typeof (Sys.StringBuilder) === "function" && Type.registerNamespace && typeof (Type.registerNamespace) === "function" && Type.registerClass && typeof (Type.registerClass) === "function" && typeof (Function._validateParams) === "function" && Sys.Serialization && Sys.Serialization.JavaScriptSerializer && typeof (Sys.Serialization.JavaScriptSerializer.serialize) === "function") { return true; } else { return false; } } loadMsAjaxFull(callback) { var msAjaxCDNPath = (window.location.protocol.toLowerCase() === 'https:' ? 'https:' : 'http:') + '//ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js'; OSF.OUtil.loadScript(msAjaxCDNPath, callback); } get msAjaxError() { if (this._msAjaxError == null && this.isMsAjaxLoaded()) { this._msAjaxError = Error; } return this._msAjaxError; } set msAjaxError(errorClass) { this._msAjaxError = errorClass; } get msAjaxString() { if (this._msAjaxString == null && this.isMsAjaxLoaded()) { this._msAjaxString = String; } return this._msAjaxString; } set msAjaxString(stringClass) { this._msAjaxString = stringClass; } get msAjaxDebug() { if (this._msAjaxDebug == null && this.isMsAjaxLoaded()) { this._msAjaxDebug = Sys.Debug; } return this._msAjaxDebug; } set msAjaxDebug(debugClass) { this._msAjaxDebug = debugClass; } } OfficeExt.MicrosoftAjaxFactory = MicrosoftAjaxFactory; })(OfficeExt || (OfficeExt = {})); var OsfMsAjaxFactory = new OfficeExt.MicrosoftAjaxFactory(); var OfficeExt; (function (OfficeExt) { class MsAjaxTypeHelper { static isInstanceOfType(type, instance) { if (typeof (instance) === "undefined" || instance === null) return false; if (instance instanceof type) return true; var instanceType = instance.constructor; if (!instanceType || (typeof (instanceType) !== "function") || !instanceType.__typeName || instanceType.__typeName === 'Object') { instanceType = Object; } return !!(instanceType === type) || (instanceType.__typeName && type.__typeName && instanceType.__typeName === type.__typeName); } } OfficeExt.MsAjaxTypeHelper = MsAjaxTypeHelper; class MsAjaxError { static create(message, errorInfo) { var err = new Error(message); err.message = message; if (errorInfo) { for (var v in errorInfo) { err[v] = errorInfo[v]; } } err.popStackFrame(); return err; } static parameterCount(message) { var displayMessage = "Sys.ParameterCountException: " + (message ? message : "Parameter count mismatch."); var err = MsAjaxError.create(displayMessage, { name: 'Sys.ParameterCountException' }); err.popStackFrame(); return err; } static argument(paramName, message) { var displayMessage = "Sys.ArgumentException: " + (message ? message : "Value does not fall within the expected range."); if (paramName) { displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName); } var err = MsAjaxError.create(displayMessage, { name: "Sys.ArgumentException", paramName: paramName }); err.popStackFrame(); return err; } static argumentNull(paramName, message) { var displayMessage = "Sys.ArgumentNullException: " + (message ? message : "Value cannot be null."); if (paramName) { displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName); } var err = MsAjaxError.create(displayMessage, { name: "Sys.ArgumentNullException", paramName: paramName }); err.popStackFrame(); return err; } static argumentOutOfRange(paramName, actualValue, message) { var displayMessage = "Sys.ArgumentOutOfRangeException: " + (message ? message : "Specified argument was out of the range of valid values."); if (paramName) { displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName); } if (typeof (actualValue) !== "undefined" && actualValue !== null) { displayMessage += "\n" + MsAjaxString.format("Actual value was {0}.", actualValue); } var err = MsAjaxError.create(displayMessage, { name: "Sys.ArgumentOutOfRangeException", paramName: paramName, actualValue: actualValue }); err.popStackFrame(); return err; } static argumentType(paramName, actualType, expectedType, message) { var displayMessage = "Sys.ArgumentTypeException: "; if (message) { displayMessage += message; } else if (actualType && expectedType) { displayMessage += MsAjaxString.format("Object of type '{0}' cannot be converted to type '{1}'.", actualType.getName ? actualType.getName() : actualType, expectedType.getName ? expectedType.getName() : expectedType); } else { displayMessage += "Object cannot be converted to the required type."; } if (paramName) { displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName); } var err = MsAjaxError.create(displayMessage, { name: "Sys.ArgumentTypeException", paramName: paramName, actualType: actualType, expectedType: expectedType }); err.popStackFrame(); return err; } static argumentUndefined(paramName, message) { var displayMessage = "Sys.ArgumentUndefinedException: " + (message ? message : "Value cannot be undefined."); if (paramName) { displayMessage += "\n" + MsAjaxString.format("Parameter name: {0}", paramName); } var err = MsAjaxError.create(displayMessage, { name: "Sys.ArgumentUndefinedException", paramName: paramName }); err.popStackFrame(); return err; } static invalidOperation(message) { var displayMessage = "Sys.InvalidOperationException: " + (message ? message : "Operation is not valid due to the current state of the object."); var err = MsAjaxError.create(displayMessage, { name: 'Sys.InvalidOperationException' }); err.popStackFrame(); return err; } } OfficeExt.MsAjaxError = MsAjaxError; class MsAjaxString { static format(format, ...args) { var source = format; return source.replace(/{(\d+)}/gm, function (match, number) { var index = parseInt(number, 10); return args[index] === undefined ? '{' + number + '}' : args[index]; }); } static startsWith(str, prefix) { return (str.substr(0, prefix.length) === prefix); } } OfficeExt.MsAjaxString = MsAjaxString; class MsAjaxDebug { static trace(text) { if (DEBUG) { if (typeof Debug !== "undefined" && Debug.writeln) Debug.writeln(text); if (window.console && window.console.log) window.console.log(text); if (window.opera && window.opera.postError) window.opera.postError(text); if (window.debugService && window.debugService.trace) window.debugService.trace(text); var a = document.getElementById("TraceConsole"); if (a && a.tagName.toUpperCase() === "TEXTAREA") { a.appendChild(document.createTextNode(text + "\n")); } } } } OfficeExt.MsAjaxDebug = MsAjaxDebug; if (!OsfMsAjaxFactory.isMsAjaxLoaded()) { var registerTypeInternal = function registerTypeInternal(type, name, isClass) { if (type.__typeName === undefined || type.__typeName === null) { type.__typeName = name; } if (type.__class === undefined || type.__class === null) { type.__class = isClass; } }; registerTypeInternal(Function, "Function", true); registerTypeInternal(Error, "Error", true); registerTypeInternal(Object, "Object", true); registerTypeInternal(String, "String", true); registerTypeInternal(Boolean, "Boolean", true); registerTypeInternal(Date, "Date", true); registerTypeInternal(Number, "Number", true); registerTypeInternal(RegExp, "RegExp", true); registerTypeInternal(Array, "Array", true); if (!Function.createCallback) { Function.createCallback = function Function$createCallback(method, context) { var e = Function._validateParams(arguments, [ { name: "method", type: Function }, { name: "context", mayBeNull: true } ]); if (e) throw e; return function () { var l = arguments.length; if (l > 0) { var args = []; for (var i = 0; i < l; i++) { args[i] = arguments[i]; } args[l] = context; return method.apply(this, args); } return method.call(this, context); }; }; } if (!Function.createDelegate) { Function.createDelegate = function Function$createDelegate(instance, method) { var e = Function._validateParams(arguments, [ { name: "instance", mayBeNull: true }, { name: "method", type: Function } ]); if (e) throw e; return function () { return method.apply(instance, arguments); }; }; } if (!Function._validateParams) { Function._validateParams = function (params, expectedParams, validateParameterCount) { var e, expectedLength = expectedParams.length; validateParameterCount = validateParameterCount || (typeof (validateParameterCount) === "undefined"); e = Function._validateParameterCount(params, expectedParams, validateParameterCount); if (e) { e.popStackFrame(); return e; } for (var i = 0, l = params.length; i < l; i++) { var expectedParam = expectedParams[Math.min(i, expectedLength - 1)], paramName = expectedParam.name; if (expectedParam.parameterArray) { paramName += "[" + (i - expectedLength + 1) + "]"; } else if (!validateParameterCount && (i >= expectedLength)) { break; } e = Function._validateParameter(params[i], expectedParam, paramName); if (e) { e.popStackFrame(); return e; } } return null; }; } if (!Function._validateParameterCount) { Function._validateParameterCount = function (params, expectedParams, validateParameterCount) { var i, error, expectedLen = expectedParams.length, actualLen = params.length; if (actualLen < expectedLen) { var minParams = expectedLen; for (i = 0; i < expectedLen; i++) { var param = expectedParams[i]; if (param.optional || param.parameterArray) { minParams--; } } if (actualLen < minParams) { error = true; } } else if (validateParameterCount && (actualLen > expectedLen)) { error = true; for (i = 0; i < expectedLen; i++) { if (expectedParams[i].parameterArray) { error = false; break; } } } if (error) { var e = MsAjaxError.parameterCount(); e.popStackFrame(); return e; } return null; }; } if (!Function._validateParameter) { Function._validateParameter = function (param, expectedParam, paramName) { var e, expectedType = expectedParam.type, expectedInteger = !!expectedParam.integer, expectedDomElement = !!expectedParam.domElement, mayBeNull = !!expectedParam.mayBeNull; e = Function._validateParameterType(param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName); if (e) { e.popStackFrame(); return e; } var expectedElementType = expectedParam.elementType, elementMayBeNull = !!expectedParam.elementMayBeNull; if (expectedType === Array && typeof (param) !== "undefined" && param !== null && (expectedElementType || !elementMayBeNull)) { var expectedElementInteger = !!expectedParam.elementInteger, expectedElementDomElement = !!expectedParam.elementDomElement; for (var i = 0; i < param.length; i++) { var elem = param[i]; e = Function._validateParameterType(elem, expectedElementType, expectedElementInteger, expectedElementDomElement, elementMayBeNull, paramName + "[" + i + "]"); if (e) { e.popStackFrame(); return e; } } } return null; }; } if (!Function._validateParameterType) { Function._validateParameterType = function (param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName) { var e, i; if (typeof (param) === "undefined") { if (mayBeNull) { return null; } else { e = OfficeExt.MsAjaxError.argumentUndefined(paramName); e.popStackFrame(); return e; } } if (param === null) { if (mayBeNull) { return null; } else { e = OfficeExt.MsAjaxError.argumentNull(paramName); e.popStackFrame(); return e; } } if (expectedType && !OfficeExt.MsAjaxTypeHelper.isInstanceOfType(expectedType, param)) { e = OfficeExt.MsAjaxError.argumentType(paramName, typeof (param), expectedType); e.popStackFrame(); return e; } return null; }; } if (typeof (window) !== "undefined" && !window.Type) { window.Type = Function; } if (typeof (Type) !== "undefined" && !Type.registerNamespace) { Type.registerNamespace = function (ns) { var namespaceParts = ns.split('.'); var currentNamespace = window; for (var i = 0; i < namespaceParts.length; i++) { currentNamespace[namespaceParts[i]] = currentNamespace[namespaceParts[i]] || {}; currentNamespace = currentNamespace[namespaceParts[i]]; } }; } if (typeof (Type) !== "undefined" && !Type.prototype.registerClass) { Type.prototype.registerClass = function (cls) { cls = {}; }; } if (typeof (Sys) === "undefined" && typeof (Type) !== "undefined") { Type.registerNamespace('Sys'); } if (!Error.prototype.popStackFrame) { Error.prototype.popStackFrame = function () { if (arguments.length !== 0) throw MsAjaxError.parameterCount(); if (typeof (this.stack) === "undefined" || this.stack === null || typeof (this.fileName) === "undefined" || this.fileName === null || typeof (this.lineNumber) === "undefined" || this.lineNumber === null) { return; } var stackFrames = this.stack.split("\n"); var currentFrame = stackFrames[0]; var pattern = this.fileName + ":" + this.lineNumber; while (typeof (currentFrame) !== "undefined" && currentFrame !== null && currentFrame.indexOf(pattern) === -1) { stackFrames.shift(); currentFrame = stackFrames[0]; } var nextFrame = stackFrames[1]; if (typeof (nextFrame) === "undefined" || nextFrame === null) { return; } var nextFrameParts = nextFrame.match(/@(.*):(\d+)$/); if (typeof (nextFrameParts) === "undefined" || nextFrameParts === null) { return; } this.fileName = nextFrameParts[1]; this.lineNumber = parseInt(nextFrameParts[2]); stackFrames.shift(); this.stack = stackFrames.join("\n"); }; } OsfMsAjaxFactory.msAjaxError = MsAjaxError; OsfMsAjaxFactory.msAjaxString = MsAjaxString; OsfMsAjaxFactory.msAjaxDebug = MsAjaxDebug; } })(OfficeExt || (OfficeExt = {})); function XDM_DEBUG(x) { OsfMsAjaxFactory.msAjaxDebug.trace(x); } const URL_DELIM = "$"; var OfficeExt; (function (OfficeExt) { class SafeStorage { constructor(_internalStorage) { this._internalStorage = _internalStorage; } getItem(key) { try { return this._internalStorage && this._internalStorage.getItem(key); } catch (e) { return null; } } setItem(key, data) { try { this._internalStorage && this._internalStorage.setItem(key, data); } catch (e) { } } clear() { try { this._internalStorage && this._internalStorage.clear(); } catch (e) { } } removeItem(key) { try { this._internalStorage && this._internalStorage.removeItem(key); } catch (e) { } } getKeysWithPrefix(keyPrefix) { var keyList = []; try { var len = this._internalStorage && this._internalStorage.length || 0; for (var i = 0; i < len; i++) { var key = this._internalStorage.key(i); if (key.indexOf(keyPrefix) === 0) { keyList.push(key); } } } catch (e) { } return keyList; } isLocalStorageAvailable() { return (this._internalStorage != null); } } OfficeExt.SafeStorage = SafeStorage; })(OfficeExt || (OfficeExt = {})); try { (function () { OSF.Flights = OSF.OUtil.parseFlights(true); OSF.DisabledChangeGates = OSF.OUtil.parseDisabledChangeGates(true); })(); } catch (ex) { } var OSF; (function (OSF) { let WindowNameItemKeys; (function (WindowNameItemKeys) { WindowNameItemKeys["BaseFrameName"] = "baseFrameName"; WindowNameItemKeys["HostInfo"] = "hostInfo"; WindowNameItemKeys["XdmInfo"] = "xdmInfo"; WindowNameItemKeys["AppContext"] = "appContext"; WindowNameItemKeys["Flights"] = "flights"; WindowNameItemKeys["DisabledChangeGates"] = "disabledChangeGates"; WindowNameItemKeys["OfficeJsUrl"] = "officeJsUrl"; })(WindowNameItemKeys = OSF.WindowNameItemKeys || (OSF.WindowNameItemKeys = {})); let XdmFieldName; (function (XdmFieldName) { XdmFieldName["ConversationUrl"] = "ConversationUrl"; XdmFieldName["AppId"] = "AppId"; })(XdmFieldName = OSF.XdmFieldName || (OSF.XdmFieldName = {})); let Settings; (function (Settings) { })(Settings = OSF.Settings || (OSF.Settings = {})); let FlightNames; (function (FlightNames) { FlightNames[FlightNames["AddinEnforceHttps"] = 2] = "AddinEnforceHttps"; FlightNames[FlightNames["AddinRibbonIdAllowUnknown"] = 9] = "AddinRibbonIdAllowUnknown"; FlightNames[FlightNames["ManifestParserDevConsoleLog"] = 15] = "ManifestParserDevConsoleLog"; FlightNames[FlightNames["AddinActionDefinitionHybridMode"] = 18] = "AddinActionDefinitionHybridMode"; FlightNames[FlightNames["UseActionIdForUILessCommand"] = 20] = "UseActionIdForUILessCommand"; FlightNames[FlightNames["SetFocusToTaskpaneIsEnabled"] = 22] = "SetFocusToTaskpaneIsEnabled"; })(FlightNames = OSF.FlightNames || (OSF.FlightNames = {})); let FlightTreatmentNames; (function (FlightTreatmentNames) { FlightTreatmentNames["InsertionDialogFixesEnabled"] = "Microsoft.Office.SharedOnline.InsertionDialogFixesEnabled"; FlightTreatmentNames["EnsureStringsBeforeTrustErrorKill"] = "Microsoft.Office.SharedOnline.EnsureStringsBeforeTrustErrorKill"; FlightTreatmentNames["MosManifestEnabled"] = "Microsoft.Office.SharedOnline.OEP.MosManifest"; FlightTreatmentNames["MosForOmexEnabled"] = "Microsoft.Office.SharedOnline.MosForOmexEnabled"; FlightTreatmentNames["MosForPrivateCatalogEnabled"] = "Microsoft.Office.SharedOnline.MosForPrivateCatalogEnabled"; FlightTreatmentNames["ContextSlideShowEnvironmentEnabled"] = "Microsoft.Office.SharedOnline.ContextSlideShowEnvironmentEnabled"; FlightTreatmentNames["HostTrustDialog"] = "Microsoft.Office.SharedOnline.HostTrustDialog"; FlightTreatmentNames["BackstageEnabled"] = "Microsoft.Office.SharedOnline.NewBackstageEnabled"; FlightTreatmentNames["ProcessMultipleCommandsInDequeInvoker"] = "Microsoft.Office.SharedOnline.ProcessMultipleCommandsInDequeInvoker"; FlightTreatmentNames["EnablingWindowOpenUsageLogging"] = "Microsoft.Office.SharedOnline.EnablingWindowOpenUsageLogging"; FlightTreatmentNames["ExcelApiUndo25"] = "Microsoft.Office.SharedOnline.ExcelApiUndo25Bump"; FlightTreatmentNames["BrowserPermissionsEnabled"] = "Microsoft.Office.SharedOnline.BrowserPermissionsEnabled"; FlightTreatmentNames["SDXManifestTokenResolution"] = "Microsoft.Office.SharedOnline.SDXManifestTokenResolution"; FlightTreatmentNames["AgaveAuthContextApiEnabled"] = "Microsoft.Office.SharedOnline.AgaveAuthContextApiEnabled"; })(FlightTreatmentNames = OSF.FlightTreatmentNames || (OSF.FlightTreatmentNames = {})); OSF.Flights = []; OSF.DisabledChangeGates = []; class GuidClass { generateNewGuid() { var result = ""; var tick = new Date().getTime(); var index = 0; for (; index < 32 && tick > 0; index++) { if (index == 8 || index == 12 || index == 16 || index == 20) { result += "-"; } result += GuidClass.HEX_CODE[tick % 16]; tick = Math.floor(tick / 16); } for (; index < 32; index++) { if (index == 8 || index == 12 || index == 16 || index == 20) { result += "-"; } result += GuidClass.HEX_CODE[Math.floor(Math.random() * 16)]; } return result; } } GuidClass.HEX_CODE = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; class OUtilClass { constructor() { this._uniqueId = -1; this._xdmInfoKey = "&_xdm_Info="; this._flightsKey = "&_flights="; this._disabledChangeGatesKey = "&_disabledChangeGates="; this._xdmSessionKeyPrefix = "_xdm_"; this._flightsKeyPrefix = "_flights="; this._disabledChangeGatesKeyPrefix = "_disabledChangeGates="; this._fragmentSeparator = "#"; this._fragmentInfoDelimiter = "&"; this._classN = "class"; this._loadedScripts = {}; this._defaultScriptLoadingTimeout = 30000; this._safeSessionStorage = null; this._safeLocalStorage = null; this.Guid = new GuidClass(); } _getSessionStorage() { if (!this._safeSessionStorage) { try { var sessionStorage = window.sessionStorage; } catch (ex) { sessionStorage = null; } this._safeSessionStorage = new OfficeExt.SafeStorage(sessionStorage); } return this._safeSessionStorage; } _reOrderTabbableElements(elements) { var bucket0 = []; var bucketPositive = []; var i; var len = elements.length; var ele; for (i = 0; i < len; i++) { ele = elements[i]; if (ele.tabIndex) { if (ele.tabIndex > 0) { bucketPositive.push(ele); } else if (ele.tabIndex === 0) { bucket0.push(ele); } } else { bucket0.push(ele); } } bucketPositive = bucketPositive.sort(function (left, right) { var diff = left.tabIndex - right.tabIndex; if (diff === 0) { diff = bucketPositive.indexOf(left) - bucketPositive.indexOf(right); } return diff; }); return [].concat(bucketPositive, bucket0); } isChangeGateEnabled(name) { return OSF.DisabledChangeGates.indexOf(name) === -1; } serializeSettings(settingsCollection) { var ret = {}; for (var key in settingsCollection) { var value = settingsCollection[key]; try { if (JSON) { value = JSON.stringify(value, function dateReplacer(k, v) { return OSF.OUtil.isDate(this[k]) ? OSF.DDA.SettingsManager.DateJSONPrefix + this[k].getTime() + OSF.DDA.SettingsManager.DataJSONSuffix : v; }); } else { value = Sys.Serialization.JavaScriptSerializer.serialize(value); } ret[key] = value; } catch (ex) { } } return ret; } deserializeSettings(serializedSettings) { var ret = {}; serializedSettings = serializedSettings || {}; for (var key in serializedSettings) { var value = serializedSettings[key]; try { if (JSON) { value = JSON.parse(value, function dateReviver(k, v) { var d; if (typeof v === "string" && v && v.length > 6 && v.slice(0, 5) === OSF.DDA.SettingsManager.DateJSONPrefix && v.slice(-1) === OSF.DDA.SettingsManager.DataJSONSuffix) { d = new Date(parseInt(v.slice(5, -1))); if (d) { return d; } } return v; }); } else { value = Sys.Serialization.JavaScriptSerializer.deserialize(value, true); } ret[key] = value; } catch (ex) { } } return ret; } loadScript(url, callback, timeoutInMs) { if (url && callback) { var doc = window.document; var _loadedScriptEntry = this._loadedScripts[url]; if (!_loadedScriptEntry) { var script = doc.createElement("script"); script.type = "text/javascript"; _loadedScriptEntry = { loaded: false, pendingCallbacks: [callback], timer: null }; this._loadedScripts[url] = _loadedScriptEntry; var onLoadCallback = function OSF_OUtil_loadScript$onLoadCallback() { if (_loadedScriptEntry.timer != null) { clearTimeout(_loadedScriptEntry.timer); delete _loadedScriptEntry.timer; } _loadedScriptEntry.loaded = true; var pendingCallbackCount = _loadedScriptEntry.pendingCallbacks.length; for (var i = 0; i < pendingCallbackCount; i++) { var currentCallback = _loadedScriptEntry.pendingCallbacks.shift(); currentCallback(); } }; var onLoadTimeOut = function OSF_OUtil_loadScript$onLoadTimeOut(oUtil) { if (window.navigator.userAgent.indexOf("Trident") > 0) { onLoadError(oUtil, null); } else { onLoadError(oUtil, new Event("Script load timed out")); } }; var onLoadError = function OSF_OUtil_loadScript$onLoadError(oUtil, errorEvent) { delete oUtil._loadedScripts[url]; if (_loadedScriptEntry.timer != null) { clearTimeout(_loadedScriptEntry.timer); delete _loadedScriptEntry.timer; } var pendingCallbackCount = _loadedScriptEntry.pendingCallbacks.length; for (var i = 0; i < pendingCallbackCount; i++) { var currentCallback = _loadedScriptEntry.pendingCallbacks.shift(); currentCallback(); } }; if (script.readyState) { script.onreadystatechange = function () { if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; onLoadCallback(); } }; } else { script.onload = onLoadCallback; } script.onerror = () => { onLoadError(this, new Event("Script load timed out")); }; timeoutInMs = timeoutInMs || this._defaultScriptLoadingTimeout; _loadedScriptEntry.timer = setTimeout(() => { onLoadTimeOut(this); }, timeoutInMs); script.setAttribute("crossOrigin", "anonymous"); script.src = url; doc.head.appendChild(script); } else if (_loadedScriptEntry.loaded) { callback(); } else { _loadedScriptEntry.pendingCallbacks.push(callback); } } } loadCSS(url) { if (url) { var doc = window.document; var link = doc.createElement("link"); link.type = "text/css"; link.rel = "stylesheet"; link.href = url; doc.head.appendChild(link); } } parseEnum(str, enumObject) { var parsed = enumObject[str.trim()]; if (typeof parsed == "undefined") { OsfMsAjaxFactory.msAjaxDebug.trace("invalid enumeration string:" + str); throw OsfMsAjaxFactory.msAjaxError.argument("str"); } return parsed; } getUniqueId() { this._uniqueId = this._uniqueId + 1; return this._uniqueId.toString(); } formatString(...args) { var source = args[0]; return source.replace(/{(\d+)}/gm, function (match, number) { var index = parseInt(number, 10) + 1; return args[index] === undefined ? "{" + number + "}" : args[index]; }); } generateConversationId() { const randNums = crypto.getRandomValues(new Uint32Array([0, 0])); return [randNums[0].toString(16), randNums[1].toString(16), new Date().getTime().toString()].join("_"); } getFrameName(cacheKey) { return this._xdmSessionKeyPrefix + cacheKey + this.generateConversationId(); } addXdmInfoAsHash(url, xdmInfoValue) { return OSF.OUtil.addInfoAsHash(url, this._xdmInfoKey, xdmInfoValue, false); } addFlightsAsHash(url, flights) { return OSF.OUtil.addInfoAsHash(url, this._flightsKey, flights, true); } addDisabledChangeGatesAsHash(url, disabledChangeGates) { return OSF.OUtil.addInfoAsHash(url, this._disabledChangeGatesKey, disabledChangeGates, true); } addInfoAsHash(url, keyName, infoValue, encodeInfo) { url = url.trim() || ""; var urlParts = url.split(this._fragmentSeparator); var urlWithoutFragment = urlParts.shift(); var fragment = urlParts.join(this._fragmentSeparator); var newFragment; if (encodeInfo) { newFragment = [keyName, encodeURIComponent(infoValue), fragment].join(""); } else { newFragment = [fragment, keyName, infoValue].join(""); } return [urlWithoutFragment, this._fragmentSeparator, newFragment].join(""); } parseHostInfoFromWindowName(skipSessionStorage, windowName) { return OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.HostInfo); } parseXdmInfo(skipSessionStorage) { var xdmInfoValue = OSF.OUtil.parseXdmInfoWithGivenFragment(skipSessionStorage, window.location.hash); if (!xdmInfoValue) { xdmInfoValue = OSF.OUtil.parseXdmInfoFromWindowName(skipSessionStorage, window.name); } return xdmInfoValue; } parseXdmInfoFromWindowName(skipSessionStorage, windowName) { return OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.XdmInfo); } parseXdmInfoWithGivenFragment(skipSessionStorage, fragment) { return OSF.OUtil.parseInfoWithGivenFragment(this._xdmInfoKey, this._xdmSessionKeyPrefix, false, skipSessionStorage, fragment); } parseFlights(skipSessionStorage) { var flights = OSF.OUtil.parseFlightsWithGivenFragment(skipSessionStorage, window.location.hash); if (flights.length == 0) { flights = OSF.OUtil.parseFlightsFromWindowName(skipSessionStorage, window.name); } return flights; } parseDisabledChangeGates(skipSessionStorage) { var disabledChangeGates = OSF.OUtil.parseDisabledChangeGatesWithGivenFragment(skipSessionStorage, window.location.hash); if (disabledChangeGates.length == 0) { disabledChangeGates = OSF.OUtil.parseDisabledChangeGatesFromWindowName(skipSessionStorage, window.name); } return disabledChangeGates; } checkFlight(flight) { return OSF.Flights && OSF.Flights.indexOf(flight) >= 0; } pushFlight(flight) { if (OSF.Flights.indexOf(flight) < 0) { OSF.Flights.push(flight); return true; } return false; } getBooleanSetting(settingName) { return OSF.OUtil.getBooleanFromDictionary(OSF.Settings, settingName); } getBooleanFromDictionary(settings, settingName) { var result = settings && settingName && settings[settingName] !== undefined && settings[settingName] && ((typeof settings[settingName] === "string" && settings[settingName].toUpperCase() === "TRUE") || (typeof settings[settingName] === "boolean" && settings[settingName])); return result !== undefined ? result : false; } parseFlightsFromWindowName(skipSessionStorage, windowName) { return OSF.OUtil.parseArrayWithDefault(OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.Flights)); } parseFlightsWithGivenFragment(skipSessionStorage, fragment) { return OSF.OUtil.parseArrayWithDefault(OSF.OUtil.parseInfoWithGivenFragment(this._flightsKey, this._flightsKeyPrefix, true, skipSessionStorage, fragment)); } parseDisabledChangeGatesFromWindowName(skipSessionStorage, windowName) { return OSF.OUtil.parseArrayWithDefault(OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.DisabledChangeGates)); } parseDisabledChangeGatesWithGivenFragment(skipSessionStorage, fragment) { return OSF.OUtil.parseArrayWithDefault(OSF.OUtil.parseInfoWithGivenFragment(this._disabledChangeGatesKey, this._disabledChangeGatesKeyPrefix, true, skipSessionStorage, fragment)); } parseArrayWithDefault(jsonString) { var array = []; try { array = JSON.parse(jsonString); } catch (ex) { } if (!Array.isArray(array)) { array = []; } return array; } parseInfoFromWindowName(skipSessionStorage, windowName, infoKey) { try { var windowNameObj = JSON.parse(windowName); var infoValue = windowNameObj != null ? windowNameObj[infoKey] : null; var osfSessionStorage = this._getSessionStorage(); if (!skipSessionStorage && osfSessionStorage && windowNameObj != null) { var sessionKey = windowNameObj[OSF.WindowNameItemKeys.BaseFrameName] + infoKey; if (infoValue) { osfSessionStorage.setItem(sessionKey, infoValue); } else { infoValue = osfSessionStorage.getItem(sessionKey); } } return infoValue; } catch (Exception) { return null; } } parseInfoWithGivenFragment(infoKey, infoKeyPrefix, decodeInfo, skipSessionStorage, fragment) { var fragmentParts = fragment.split(infoKey); var infoValue = fragmentParts.length > 1 ? fragmentParts[fragmentParts.length - 1] : null; if (decodeInfo && infoValue != null) { if (infoValue.indexOf(this._fragmentInfoDelimiter) >= 0) { infoValue = infoValue.split(this._fragmentInfoDelimiter)[0]; } infoValue = decodeURIComponent(infoValue); } var osfSessionStorage = this._getSessionStorage(); if (!skipSessionStorage && osfSessionStorage) { var sessionKeyStart = window.name.indexOf(infoKeyPrefix); if (sessionKeyStart > -1) { var sessionKeyEnd = window.name.indexOf(";", sessionKeyStart); if (sessionKeyEnd == -1) { sessionKeyEnd = window.name.length; } var sessionKey = window.name.substring(sessionKeyStart, sessionKeyEnd); if (infoValue) { osfSessionStorage.setItem(sessionKey, infoValue); } else { infoValue = osfSessionStorage.getItem(sessionKey); } } } return infoValue; } getConversationId() { var searchString = window.location.search; var conversationId = null; if (searchString) { var index = searchString.indexOf("&"); conversationId = index > 0 ? searchString.substring(1, index) : searchString.substr(1); if (conversationId && conversationId.charAt(conversationId.length - 1) === "=") { conversationId = conversationId.substring(0, conversationId.length - 1); if (conversationId) { conversationId = decodeURIComponent(conversationId); } } } return conversationId; } getInfoItems(strInfo) { var items = strInfo.split(URL_DELIM); if (typeof items[1] == "undefined") { items = strInfo.split("|"); } if (typeof items[1] == "undefined") { items = strInfo.split("%7C"); } return items; } getXdmFieldValue(xdmFieldName, skipSessionStorage) { var fieldValue = ""; var xdmInfoValue = OSF.OUtil.parseXdmInfo(skipSessionStorage); if (xdmInfoValue) { var items = OSF.OUtil.getInfoItems(xdmInfoValue); if (items != undefined && items.length >= 3) { switch (xdmFieldName) { case OSF.XdmFieldName.ConversationUrl: fieldValue = items[2]; break; case OSF.XdmFieldName.AppId: fieldValue = items[1]; break; } } } return fieldValue; } validateParamObject(params, expectedProperties, callback) { var e = Function._validateParams(arguments, [ { name: "params", type: Object, mayBeNull: false }, { name: "expectedProperties", type: Object, mayBeNull: false }, { name: "callback", type: Function, mayBeNull: true }, ]); if (e) throw e; for (var p in expectedProperties) { e = Function._validateParameter(params[p], expectedProperties[p], p); if (e) throw e; } } finalizeProperties(obj, descriptor) { descriptor = descriptor || {}; var props = Object.getOwnPropertyNames(obj); var propsLength = props.length; for (var i = 0; i < propsLength; i++) { var prop = props[i]; var desc = Object.getOwnPropertyDescriptor(obj, prop); if (!desc.get && !desc.set) { desc.writable = descriptor.writable || false; } desc.configurable = descriptor.configurable || false; desc.enumerable = descriptor.enumerable || true; Object.defineProperty(obj, prop, desc); } return obj; } isDate(obj) { return Object.prototype.toString.apply(obj) === "[object Date]"; } xhrGet(url, onSuccess, onError) { var xmlhttp; try { xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { onSuccess(xmlhttp.responseText); } else { onError(xmlhttp.status); } } }; xmlhttp.open("GET", url, true); xmlhttp.send(); } catch (ex) { onError(ex); } } encodeBase64Utf16(input) { if (!input) return input; const stringCodeU16 = new Uint16Array(input.length).map((_, i) => input.charCodeAt(i)); const stringCodeU8 = new Uint8Array(stringCodeU16.buffer); const encodedString = String.fromCharCode.apply(null, stringCodeU8); return btoa(encodedString); } getLocalStorage() { if (!this._safeLocalStorage) { try { var localStorage = window.localStorage; } catch (ex) { localStorage = null; } this._safeLocalStorage = new OfficeExt.SafeStorage(localStorage); } return this._safeLocalStorage; } convertIntToCssHexColor(val) { var hex = "#" + (Number(val) + 0x1000000).toString(16).slice(-6); return hex; } attachClickHandler(element, handler) { element.onclick = function (e) { handler(); }; element.ontouchend = function (e) { handler(); e.preventDefault(); }; } getQueryStringParamValue(queryString, paramName) { var e = Function._validateParams(arguments, [ { name: "queryString", type: String, mayBeNull: false }, { name: "paramName", type: String, mayBeNull: false }, ]); if (e) { OsfMsAjaxFactory.msAjaxDebug.trace("OSF_Outil_getQueryStringParamValue: Parameters cannot be null."); return ""; } var queryExp = new RegExp("[\\?&]" + paramName + "=([^&#]*)", "i"); if (!queryExp.test(queryString)) { OsfMsAjaxFactory.msAjaxDebug.trace("OSF_Outil_getQueryStringParamValue: The parameter is not found."); return ""; } return queryExp.exec(queryString)[1]; } getHostnamePortionForLogging(hostname) { var e = Function._validateParams(arguments, [{ name: "hostname", type: String, mayBeNull: false }]); if (e) { return ""; } var hostnameSubstrings = hostname.split("."); var len = hostnameSubstrings.length; if (len >= 2) { return hostnameSubstrings[len - 2] + "." + hostnameSubstrings[len - 1]; } else if (len == 1) { return hostnameSubstrings[0]; } } isiOS() { return window.navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false; } doesUrlHaveSupportedProtocol(url) { var isValid = false; if (url) { try { var parsedUrl = OSF.OUtil.parseUrl(url, false); isValid = parsedUrl.protocol === 'https:' || parsedUrl.protocol === 'http:'; } catch (ex) { this.sendTelemetryEvent("Office.Extensibility.UrlParsingForProtocolCheck", [{ name: "errorMessage", string: "Fix for bug 7142881 exception hit in officeutils.ts function doesUrlHaveSupportedProtocol." }, { name: "tag", string: '0x1e88019a' } ]); var decodedUrl = decodeURIComponent(url); var matches = decodedUrl.match(/^https?:\/\/.+$/ig); isValid = (matches != null); } } return isValid; } containsPort(url, protocol, hostname, portNumber) { return (url.startsWith(protocol + "//" + hostname + ":" + portNumber) || url.startsWith(hostname + ":" + portNumber)); } getRedundandPortString(url, parser) { if (!url || !parser) return ""; if (parser.protocol == "https:" && this.containsPort(url, "https:", parser.hostname, "443")) return ":443"; else if (parser.protocol == "http:" && this.containsPort(url, "http:", parser.hostname, "80")) return ":80"; return ""; } removeChar(url, indexOfCharToRemove) { if (indexOfCharToRemove < url.length - 1) return url.substring(0, indexOfCharToRemove) + url.substring(indexOfCharToRemove + 1); else if (indexOfCharToRemove == url.length - 1) return url.substring(0, url.length - 1); else return url; } cleanUrlOfChar(url, charToClean) { let i; for (i = 0; i < url.length; i++) { if (url.charAt(i) === charToClean) { if (i + 1 >= url.length) { return this.removeChar(url, i); } else if (charToClean === "/") { if (url.charAt(i + 1) === "?" || url.charAt(i + 1) === "#") { return this.removeChar(url, i); } } else if (charToClean === "?") { if (url.charAt(i + 1) === "#") { return this.removeChar(url, i); } } } } return url; } cleanUrl(url) { url = this.cleanUrlOfChar(url, "/"); url = this.cleanUrlOfChar(url, "?"); url = this.cleanUrlOfChar(url, "#"); if (url.substr(0, 8) == "https://") { let portIndex = url.indexOf(":443"); if (portIndex != -1) { if (portIndex == url.length - 4 || url.charAt(portIndex + 4) == "/" || url.charAt(portIndex + 4) == "?" || url.charAt(portIndex + 4) == "#") { url = url.substring(0, portIndex) + url.substring(portIndex + 4); } } } else if (url.substr(0, 7) == "http://") { let portIndex = url.indexOf(":80"); if (portIndex != -1) { if (portIndex == url.length - 3 || url.charAt(portIndex + 3) == "/" || url.charAt(portIndex + 3) == "?" || url.charAt(portIndex + 3) == "#") { url = url.substring(0, portIndex) + url.substring(portIndex + 3); } } } return url; } isPortPartOfUrl(urlObj) { return urlObj.host.lastIndexOf(":" + urlObj.port) == urlObj.host.length - urlObj.port.length - 1; } parseUrl(url, enforceHttps = false) { if (!url) { return undefined; } const notHttpsErrorMessage = "NotHttps"; try { const urlObj = new URL(url); if (urlObj && urlObj.protocol && urlObj.host && urlObj.hostname) { if (OSF.OUtil.checkFlight(OSF.FlightNames.AddinEnforceHttps)) { if (enforceHttps && urlObj.protocol != "https:") throw new Error(notHttpsErrorMessage); } return urlObj; } } catch (err) { if (err.message === notHttpsErrorMessage) throw err; } return {}; } focusToFirstTabbable(all, backward) { var next; var focused = false; var candidate; var setFlag = function (e) { focused = true; }; var findNextPos = function (allLen, currPos, backward) { if (currPos < 0 || currPos > allLen) { return -1; } else if (currPos === 0 && backward) { return -1; } else if (currPos === allLen - 1 && !backward) { return -1; } if (backward) { return currPos - 1; } else { return currPos + 1; } }; all = this._reOrderTabbableElements(all); next = backward ? all.length - 1 : 0; if (all.length === 0) { return null; } while (!focused && next >= 0 && next < all.length) { candidate = all[next]; window.focus(); candidate.addEventListener("focus", setFlag); candidate.focus(); candidate.removeEventListener("focus", setFlag); next = findNextPos(all.length, next, backward); if (!focused && candidate === document.activeElement) { focused = true; } } if (focused) { return candidate; } else { return null; } } focusToNextTabbable(all, curr, shift) { var currPos; var next; var focused = false; var candidate; var setFlag = function (e) { focused = true; }; var findCurrPos = function (all, curr) { var i = 0; for (; i < all.length; i++) { if (all[i] === curr) { return i; } } return -1; }; var findNextPos = function (allLen, currPos, shift) { if (currPos < 0 || currPos > allLen) { return -1; } else if (currPos === 0 && shift) { return -1; } else if (currPos === allLen - 1 && !shift) { return -1; } if (shift) { return currPos - 1; } else { return currPos + 1; } }; all = this._reOrderTabbableElements(all); currPos = findCurrPos(all, curr); next = findNextPos(all.length, currPos, shift); if (next < 0) { return null; } while (!focused && next >= 0 && next < all.length) { candidate = all[next]; candidate.addEventListener("focus", setFlag); candidate.focus(); candidate.removeEventListener("focus", setFlag); next = findNextPos(all.length, next, shift); if (!focused && candidate === document.activeElement) { focused = true; } } if (focused) { return candidate; } else { return null; } } hashCode(str) { let hash = 0; if (str != null) { let i = 0; const len = str.length; while (i < len) { hash = ((hash << 5) - hash + str.charCodeAt(i++)) | 0; } } return hash; } getBOMCodepointLength(data) { if (data.charCodeAt(0) === 0xFEFF) { return 1; } else if (data.length >= 3 && (data.charCodeAt(0) === 0xEF && data.charCodeAt(1) === 0xBB && data.charCodeAt(2) === 0xBF)) { return 3; } return 0; } sendTelemetryEvent(eventName, dataFieldsValue) { if (typeof (otel) !== 'undefined' && typeof (otel.sendTelemetryEvent) !== 'undefined') { otel.sendTelemetryEvent({ name: eventName, dataFields: dataFieldsValue }); return true; } return false; } sendActivityEvent(eventName, eventDuration, eventSucceeded, dataFieldsValue) { if (typeof (otel) !== 'undefined' && typeof (otel.sendActivityEvent) !== 'undefined') { otel.sendActivityEvent({ name: eventName, durationMs: eventDuration, succeeded: eventSucceeded, dataFields: dataFieldsValue }); return true; } return false; } } OSF.OUtilClass = OUtilClass; OSF.OUtil = new OUtilClass(); })(OSF || (OSF = {})); var OfficeExt; (function (OfficeExt) { function appSpecificCheckOriginFunction(allowed_domains, eventObj, origin, checkOriginFunction) { return false; } ; OfficeExt.appSpecificCheckOrigin = appSpecificCheckOriginFunction; })(OfficeExt || (OfficeExt = {})); var Microsoft; (function (Microsoft) { let Office; (function (Office) { let Common; (function (Common) { class ResponseSender { constructor(requesterWindow, requesterUrl, actionName, conversationId, correlationId, responseType) { var e = Function._validateParams(arguments, [ { name: "requesterWindow", mayBeNull: false }, { name: "requesterUrl", type: String, mayBeNull: false }, { name: "actionName", type: String, mayBeNull: false }, { name: "conversationId", type: String, mayBeNull: false }, { name: "correlationId", mayBeNull: false }, { name: "responsetype", type: Number, maybeNull: false } ]); if (e) throw e; this._requesterWindow = requesterWindow; this._requesterUrl = requesterUrl; this._actionName = actionName; this._conversationId = conversationId; this._correlationId = correlationId; this._invokeResultCode = Microsoft.Office.Common.InvokeResultCode.noError; this._responseType = responseType; var me = this; this._send = function (result) { var validateTargetMatchesRequester = function (targetOrigin, requesterUrl) { var parsedTargetOrigin = OSF.OUtil.parseUrl(targetOrigin); var parsedRequesterUrl = OSF.OUtil.parseUrl(requesterUrl); if (!parsedTargetOrigin || !parsedTargetOrigin.hostname || !parsedRequesterUrl || !parsedRequesterUrl.hostname) { var errorMessage = "Failed to execute 'postMessage' on 'DOMWindow': The target origin provided or the recipient window's origin are undefined."; XDM_DEBUG(errorMessage); return false; } else if (!Microsoft.Office.Common.XdmCommunicationManager.urlCompare(parsedTargetOrigin, parsedRequesterUrl)) { var targetOriginToConsoleLog = parsedTargetOrigin ? (parsedTargetOrigin.protocol + "//" + parsedTargetOrigin.hostname + (parsedTargetOrigin.port ? (":" + parsedTargetOrigin.port) : "")) : 'undefined'; var requesterUrlToConsoleLog = parsedRequesterUrl ? (parsedRequesterUrl.protocol + "//" + parsedRequesterUrl.hostname + (parsedRequesterUrl.port ? (":" + parsedRequesterUrl.port) : "")) : 'undefined'; var errorMessage = "Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('" + targetOriginToConsoleLog + "') does not match the recipient window's origin ('" + requesterUrlToConsoleLog + "')."; XDM_DEBUG(errorMessage); return false; } return true; }; try { if (me._actionName === "dialogMessageReceived" && result.targetOrigin !== "*") { if (result.targetOrigin) { if (!validateTargetMatchesRequester(result.targetOrigin, me._requesterUrl)) { return; } } } else if (me._actionName === "dialogParentMessageReceived" && result.targetOrigin && result.targetOrigin !== "*") { if (!validateTargetMatchesRequester(result.targetOrigin, me._requesterUrl)) { return; } } var response = new Microsoft.Office.Common.Response(me._actionName, me._conversationId, me._correlationId, me._invokeResultCode, me._responseType, result); var envelopedResult = Microsoft.Office.Common.MessagePackager.envelope(response); me._requesterWindow.postMessage(envelopedResult, me._requesterUrl); } catch (ex) { OsfMsAjaxFactory.msAjaxDebug.trace("ResponseSender._send error:" + ex.message); } }; } getRequesterWindow() { return this._requesterWindow; } getRequesterUrl() { return this._requesterUrl; } getActionName() { return this._actionName; } getConversationId() { return this._conversationId; } getCorrelationId() { return this._correlationId; } getSend() { return this._send; } setResultCode(resultCode) { this._invokeResultCode = resultCode; } } Common.ResponseSender = ResponseSender; class InvokeCompleteCallback extends ResponseSender { constructor(requesterWindow, requesterUrl, actionName, conversationId, correlationId, postCallbackHandler) { super(requesterWindow, requesterUrl, actionName, conversationId, correlationId, Microsoft.Office.Common.ResponseType.forCalling); this._postCallbackHandler = postCallbackHandler; var me = this; this._send = function (result, responseCode) { if (responseCode != undefined) { me._invokeResultCode = responseCode; } try { var response = new Microsoft.Office.Common.Response(me._actionName, me._conversationId, me._correlationId, me._invokeResultCode, me._responseType, result); var envelopedResult = Microsoft.Office.Common.MessagePackager.envelope(response); me._requesterWindow.postMessage(envelopedResult, me._requesterUrl); me._postCallbackHandler(); } catch (ex) { OsfMsAjaxFactory.msAjaxDebug.trace("InvokeCompleteCallback._send error:" + ex.message); } }; } } Common.InvokeCompleteCallback = InvokeCompleteCallback; class MessagePackager { static envelope(messageObject) { return JSON.stringify(messageObject); } ; static unenvelope(messageObject) { return JSON.parse(messageObject); } } Common.MessagePackager = MessagePackager; let HostTrustStatus; (function (HostTrustStatus) { HostTrustStatus[HostTrustStatus["unknown"] = 0] = "unknown"; HostTrustStatus[HostTrustStatus["untrusted"] = 1] = "untrusted"; HostTrustStatus[HostTrustStatus["nothttps"] = 2] = "nothttps"; HostTrustStatus[HostTrustStatus["trusted"] = 3] = "trusted"; })(HostTrustStatus = Common.HostTrustStatus || (Common.HostTrustStatus = {})); let ResponseType; (function (ResponseType) { ResponseType[ResponseType["forCalling"] = 0] = "forCalling"; ResponseType[ResponseType["forEventing"] = 1] = "forEventing"; })(ResponseType = Common.ResponseType || (Common.ResponseType = {})); let ActionType; (function (ActionType) { ActionType[ActionType["invoke"] = 0] = "invoke"; ActionType[ActionType["registerEvent"] = 1] = "registerEvent"; ActionType[ActionType["unregisterEvent"] = 2] = "unregisterEvent"; })(ActionType = Common.ActionType || (Common.ActionType = {})); let MessageType; (function (MessageType) { MessageType[MessageType["request"] = 0] = "request"; MessageType[MessageType["response"] = 1] = "response"; })(MessageType = Common.MessageType || (Common.MessageType = {})); let InvokeResultCode; (function (InvokeResultCode) { InvokeResultCode[InvokeResultCode["noError"] = 0] = "noError"; InvokeResultCode[InvokeResultCode["errorInRequest"] = -1] = "errorInRequest"; InvokeResultCode[InvokeResultCode["errorHandlingRequest"] = -2] = "errorHandlingRequest"; InvokeResultCode[InvokeResultCode["errorInResponse"] = -3] = "errorInResponse"; InvokeResultCode[InvokeResultCode["errorHandlingResponse"] = -4] = "errorHandlingResponse"; InvokeResultCode[InvokeResultCode["errorHandlingRequestAccessDenied"] = -5] = "errorHandlingRequestAccessDenied"; InvokeResultCode[InvokeResultCode["errorHandlingMethodCallTimedout"] = -6] = "errorHandlingMethodCallTimedout"; })(InvokeResultCode = Common.InvokeResultCode || (Common.InvokeResultCode = {})); let InvokeType; (function (InvokeType) { InvokeType[InvokeType["async"] = 0] = "async"; InvokeType[InvokeType["sync"] = 1] = "sync"; InvokeType[InvokeType["asyncRegisterEvent"] = 2] = "asyncRegisterEvent"; InvokeType[InvokeType["asyncUnregisterEvent"] = 3] = "asyncUnregisterEvent"; InvokeType[InvokeType["syncRegisterEvent"] = 4] = "syncRegisterEvent"; InvokeType[InvokeType["syncUnregisterEvent"] = 5] = "syncUnregisterEvent"; })(InvokeType = Common.InvokeType || (Common.InvokeType = {})); Common.XdmCommunicationManager = (function () { var _invokerQueue = []; var _lastMessageProcessTime = null; var _messageProcessingTimer = null; var _processInterval = 10; var _blockingFlag = false; var _methodTimeoutTimer = null; var _methodTimeoutProcessInterval = 2000; var _methodTimeoutDefault = 65000; var _methodTimeout = _methodTimeoutDefault; var _serviceEndPoints = {}; var _clientEndPoints = {}; var _initialized = false; function _getControlIdFromMessageObject(messageObject) { if (!messageObject) return null; const actionName = messageObject._actionName; try { if (!actionName) throw new Error('actionName not found in messageObject'); let controlId; switch (actionName) { case 'executeMethod': controlId = messageObject._data.DdaMethod.ControlId; break; default: return null; } if (typeof controlId !== "string") { throw new Error('Failed to extract controlId from messageObject'); } return controlId; } catch (ex) { OsfMsAjaxFactory.msAjaxDebug.trace(`XdmCommunicationManager._getControlIdFromMessageObject (actionName: ${actionName}) error: ${ex.message}`); return null; } } function _lookupServiceEndPoint(conversationId) { for (var id in _serviceEndPoints) { if (_serviceEndPoints[id]._conversations[conversationId]) { return _serviceEndPoints[id]; } } OsfMsAjaxFactory.msAjaxDebug.trace("Unknown conversation Id."); throw OsfMsAjaxFactory.msAjaxError.argument("conversationId"); } ; function _lookupClientEndPoint(conversationId) { var clientEndPoint = _clientEndPoints[conversationId]; if (!clientEndPoint) { OsfMsAjaxFactory.msAjaxDebug.trace("Unknown conversation Id."); } return clientEndPoint; } ; function _lookupMethodObject(serviceEndPoint, messageObject) { var methodOrEventMethodObject = serviceEndPoint._methodObjectList[messageObject._actionName]; if (!methodOrEventMethodObject) { OsfMsAjaxFactory.msAjaxDebug.trace("The specified method is not registered on service endpoint:" + messageObject._actionName); throw OsfMsAjaxFactory.msAjaxError.argument("messageObject"); } var methodObject = null; if (messageObject._actionType === Microsoft.Office.Common.ActionType.invoke) { methodObject = methodOrEventMethodObject; } else if (messageObject._actionType === Microsoft.Office.Common.ActionType.registerEvent) { methodObject = methodOrEventMethodObject.getRegisterMethodObject(); } else { methodObject = methodOrEventMethodObject.getUnregisterMethodObject(); } return methodObject; } ; function _enqueInvoker(invoker) { _invokerQueue.push(invoker); } ; function _dequeInvoker() { if (_messageProcessingTimer !== null) { if (OSF.OUtil.checkFlight(OSF.FlightTreatmentNames.ProcessMultipleCommandsInDequeInvoker)) { while (!_blockingFlag && _invokerQueue.length > 0) { var invoker = _invokerQueue.shift(); _executeCommand(invoker); } if (_invokerQueue.length == 0) { clearInterval(_messageProcessingTimer); _messageProcessingTimer = null; } } else { if (!_blockingFlag) { if (_invokerQueue.length > 0) { var invoker = _invokerQueue.shift(); _executeCommand(invoker); } else { clearInterval(_messageProcessingTimer); _messageProcessingTimer = null; } } } } else { OsfMsAjaxFactory.msAjaxDebug.trace("channel is not ready."); } } ; function _executeCommand(invoker) { _blockingFlag = invoker.getInvokeBlockingFlag(); invoker.invoke(); _lastMessageProcessTime = (new Date()).getTime(); } ; function _checkMethodTimeout() { if (_methodTimeoutTimer) { var clientEndPoint; var methodCallsNotTimedout = 0; var now = new Date(); var timeoutValue; for (var conversationId in _clientEndPoints) { clientEndPoint = _clientEndPoints[conversationId]; for (var correlationId in clientEndPoint._callbackList) { var callbackEntry = clientEndPoint._callbackList[correlationId]; timeoutValue = callbackEntry.timeout ? callbackEntry.timeout : _methodTimeout; if (timeoutValue >= 0 && Math.abs(now.getTime() - callbackEntry.createdOn) >= timeoutValue) { try { if (callbackEntry.callback) { callbackEntry.callback(Microsoft.Office.Common.InvokeResultCode.errorHandlingMethodCallTimedout, null); } } finally { delete clientEndPoint._callbackList[correlationId]; } } else { methodCallsNotTimedout++; } ; } } if (methodCallsNotTimedout === 0) { clearInterval(_methodTimeoutTimer); _methodTimeoutTimer = null; } } else { OsfMsAjaxFactory.msAjaxDebug.trace("channel is not ready."); } } ; function _postCallbackHandler() { _blockingFlag = false; } ; function _registerListener(listener) { if (window.addEventListener) { window.addEventListener("message", listener); } else if ((navigator.userAgent.indexOf("MSIE") > -1) && window.attachEvent) { window.attachEvent("onmessage", listener); } else { OsfMsAjaxFactory.msAjaxDebug.trace("Browser doesn't support the required API."); throw OsfMsAjaxFactory.msAjaxError.argument("Browser"); } } ; function _checkOrigin(url, origin) { var res = false; if (!url || !origin || url === "null" || origin === "null" || !url.length || !origin.length) { return res; } const url_parser = OSF.OUtil.parseUrl(url, true); const org_parser = OSF.OUtil.parseUrl(origin, true); return _urlCompare(url_parser, org_parser); } function _checkOriginWithAppDomains(allowed_domains, origin) { var res = false; if (!origin || origin === "null" || !origin.length || !(allowed_domains) || !(allowed_domains instanceof Array) || !allowed_domains.length) { return res; } const org_parser = OSF.OUtil.parseUrl(origin); return allowed_domains.some(domain => domain.indexOf("://") !== -1 && _urlCompare(org_parser, OSF.OUtil.parseUrl(domain))); } function _isHostNameValidWacDomain(hostName) { if (!hostName || hostName === "null") { return false; } var regexHostNameStringArray = new Array("^office-int\\.com$", "^officeapps\\.live-int\\.com$", "^.*\\.dod\\.online\\.office365\\.us$", "^.*\\.gov\\.online\\.office365\\.us$", "^.*\\.officeapps\\.live\\.com$", "^.*\\.officeapps\\.live-int\\.com$", "^.*\\.officeapps-df\\.live\\.com$", "^.*\\.online\\.office\\.de$", "^.*\\.partner\\.officewebapps\\.cn$", "^.*\\.office\\.net$", "^" + document.domain.replace(new RegExp("\\.", "g"), "\\.") + "$"); var regexHostName = new RegExp(regexHostNameStringArray.join("|")); return regexHostName.test(hostName); } function _isTargetSubdomainOfSourceLocation(sourceLocation, messageOrigin) { if (!sourceLocation || !messageOrigin || sourceLocation === "null" || messageOrigin === "null") { return false; } const sourceLocationParser = OSF.OUtil.parseUrl(sourceLocation, true); const messageOriginParser = OSF.OUtil.parseUrl(messageOrigin, true); if (sourceLocationParser == null || messageOriginParser == null) { return false; } let isSameProtocol = sourceLocationParser.protocol === messageOriginParser.protocol; let isSamePort = sourceLocationParser.port === messageOriginParser.port; let originHostName = messageOriginParser.hostname; let sourceLocationHostName = sourceLocationParser.hostname; let isSameDomain = originHostName === sourceLocationHostName; let isSubDomain = false; if (!isSameDomain) { isSubDomain = sourceLocationHostName && originHostName.endsWith('.' + sourceLocationHostName); } let isSameDomainOrSubdomain = isSameDomain || isSubDomain; return isSamePort && isSameProtocol && isSameDomainOrSubdomain; } function _urlCompare(url_parser1, url_parser2) { if (!url_parser1 || !url_parser2 || !url_parser1.protocol || !url_parser2.protocol || !url_parser1.hostname || !url_parser2.hostname) { return false; } return ((url_parser1.hostname === url_parser2.hostname) && (url_parser1.protocol === url_parser2.protocol) && (url_parser1.port === url_parser2.port)); } function _receive(e) { if (!OSF) { return; } if (e.data != '') { var messageObject; var serializedMessage = e.data; try { messageObject = Microsoft.Office.Common.MessagePackager.unenvelope(serializedMessage); } catch (ex) { return; } if (messageObject._messageType === Microsoft.Office.Common.MessageType.request) { var requesterUrl = (e.origin == null || e.origin === "null") ? messageObject._origin : e.origin; try { var serviceEndPoint = _lookupServiceEndPoint(messageObject._conversationId); var conversation = serviceEndPoint._conversations[messageObject._conversationId]; var allowedDomains = [conversation.url].concat(serviceEndPoint._appDomains[messageObject._conversationId]); if (!_checkOriginWithAppDomains(allowedDomains, e.origin)) { if (!OfficeExt.appSpecificCheckOrigin(allowedDomains, e, messageObject._origin, _checkOriginWithAppDomains)) { let isOriginSubdomain = _isTargetSubdomainOfSourceLocation(conversation.url, e.origin); if (!isOriginSubdomain) { throw "Failed origin check"; } } } var dataWithOrigin = (messageObject._data != null) ? messageObject._data : {}; if (typeof dataWithOrigin == 'object') { dataWithOrigin.SecurityOrigin = e.origin; } var trustedParams = { controlId: conversation.controlId, securityOrigin: e.origin, }; var policyManager = serviceEndPoint.getPolicyManager(); if (policyManager && !policyManager.checkPermission(messageObject._conversationId, messageObject._actionName, dataWithOrigin)) { throw "Access Denied"; } var controlIdTrusted = conversation.controlId; if (controlIdTrusted) { var controlIdToVerify = _getControlIdFromMessageObject(messageObject); if (controlIdToVerify && controlIdToVerify !== controlIdTrusted) { throw "Access Denied"; } } var methodObject = _lookupMethodObject(serviceEndPoint, messageObject); var invokeCompleteCallback = new Microsoft.Office.Common.InvokeCompleteCallback(e.source, requesterUrl, messageObject._actionName, messageObject._conversationId, messageObject._correlationId, _postCallbackHandler); var invoker = new Microsoft.Office.Common.Invoker(methodObject, dataWithOrigin, invokeCompleteCallback, serviceEndPoint._eventHandlerProxyList, messageObject._conversationId, messageObject._actionName, trustedParams); var shouldEnque = true; if (_messageProcessingTimer == null) { if ((_lastMessageProcessTime == null || (new Date()).getTime() - _lastMessageProcessTime > _processInterval) && !_blockingFlag) { _executeCommand(invoker); shouldEnque = false; } else { _messageProcessingTimer = setInterval(_dequeInvoker, _processInterval); } } if (shouldEnque) { _enqueInvoker(invoker); } } catch (ex) { if (serviceEndPoint && serviceEndPoint._onHandleRequestError) { serviceEndPoint._onHandleRequestError(messageObject, ex); } var errorCode = Microsoft.Office.Common.InvokeResultCode.errorHandlingRequest; if (ex == "Access Denied") { errorCode = Microsoft.Office.Common.InvokeResultCode.errorHandlingRequestAccessDenied; } var callResponse = new Microsoft.Office.Common.Response(messageObject._actionName, messageObject._conversationId, messageObject._correlationId, errorCode, Microsoft.Office.Common.ResponseType.forCalling, ex); var envelopedResult = Microsoft.Office.Common.MessagePackager.envelope(callResponse); var canPostMessage = false; try { canPostMessage = !!(e.source && e.source.postMessage); } catch (ex) { } var isOriginValid = false; if (window.location.href && e.origin && e.origin !== "null" && _isTargetSubdomainOfSourceLocation(window.location.href, e.origin)) { isOriginValid = true; } else { if (e.origin && e.origin !== "null") { const hostname = OSF.OUtil.parseUrl(e.origin, true).hostname; isOriginValid = _isHostNameValidWacDomain(hostname); } } if (canPostMessage && isOriginValid) { e.source.postMessage(envelopedResult, requesterUrl); } } } else if (messageObject._messageType === Microsoft.Office.Common.MessageType.response) { var clientEndPoint = _lookupClientEndPoint(messageObject._conversationId); if (!clientEndPoint) { return; } if (!_checkOrigin(clientEndPoint._targetUrl, e.origin)) { throw "Failed orgin check"; } if (messageObject._responseType === Microsoft.Office.Common.ResponseType.forCalling) { var callbackEntry = clientEndPoint._callbackList[messageObject._correlationId]; if (callbackEntry) { try { if (callbackEntry.callback) callbackEntry.callback(messageObject._errorCode, messageObject._data); } finally { delete clientEndPoint._callbackList[messageObject._correlationId]; } } } else { var eventhandler = clientEndPoint._eventHandlerList[messageObject._actionName]; if (eventhandler !== undefined && eventhandler !== null) { eventhandler(messageObject._data); } } } else { return; } } } ; function _initialize() { if (!_initialized) { _registerListener(_receive); _initialized = true; } } ; return { connect: function Microsoft_Office_Common_XdmCommunicationManager$connect(conversationId, targetWindow, targetUrl) { var clientEndPoint = _clientEndPoints[conversationId]; if (!clientEndPoint) { _initialize(); clientEndPoint = new Microsoft.Office.Common.ClientEndPoint(conversationId, targetWindow, targetUrl); _clientEndPoints[conversationId] = clientEndPoint; } return clientEndPoint; }, getClientEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$getClientEndPoint(conversationId) { var e = Function._validateParams(arguments, [ { name: "conversationId", type: String, mayBeNull: false } ]); if (e) throw e; return _clientEndPoints[conversationId]; }, createServiceEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$createServiceEndPoint(serviceEndPointId) { _initialize(); var serviceEndPoint = new Microsoft.Office.Common.ServiceEndPoint(serviceEndPointId); _serviceEndPoints[serviceEndPointId] = serviceEndPoint; return serviceEndPoint; }, getServiceEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$getServiceEndPoint(serviceEndPointId) { var e = Function._validateParams(arguments, [ { name: "serviceEndPointId", type: String, mayBeNull: false } ]); if (e) throw e; return _serviceEndPoints[serviceEndPointId]; }, deleteClientEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$deleteClientEndPoint(conversationId) { var e = Function._validateParams(arguments, [ { name: "conversationId", type: String, mayBeNull: false } ]); if (e) throw e; delete _clientEndPoints[conversationId]; }, deleteServiceEndPoint: function Microsoft_Office_Common_XdmCommunicationManager$deleteServiceEndPoint(serviceEndPointId) { var e = Function._validateParams(arguments, [ { name: "serviceEndPointId", type: String, mayBeNull: false } ]); if (e) throw e; delete _serviceEndPoints[serviceEndPointId]; }, urlCompare: function Microsoft_Office_Common_XdmCommunicationManager$_urlCompare(url_parser1, url_parser2) { return _urlCompare(url_parser1, url_parser2); }, checkUrlWithAppDomains: function Microsoft_Office_Common_XdmCommunicationManager$_checkUrlWithAppDomains(appDomains, origin) { return _checkOriginWithAppDomains(appDomains, origin); }, isTargetSubdomainOfSourceLocation: function Microsoft_Office_Common_XdmCommunicationManager$_isTargetSubdomainOfSourceLocation(sourceLocation, messageOrigin) { return _isTargetSubdomainOfSourceLocation(sourceLocation, messageOrigin); }, _setMethodTimeout: function Microsoft_Office_Common_XdmCommunicationManager$_setMethodTimeout(methodTimeout) { var e = Function._validateParams(arguments, [ { name: "methodTimeout", type: Number, mayBeNull: false } ]); if (e) throw e; _methodTimeout = (methodTimeout <= 0) ? _methodTimeoutDefault : methodTimeout; }, _startMethodTimeoutTimer: function Microsoft_Office_Common_XdmCommunicationManager$_startMethodTimeoutTimer() { if (!_methodTimeoutTimer) { _methodTimeoutTimer = setInterval(_checkMethodTimeout, _methodTimeoutProcessInterval); } }, isHostNameValidWacDomain: function Microsoft_Office_Common_XdmCommunicationManager$_isHostNameValidWacDomain(hostName) { return _isHostNameValidWacDomain(hostName); }, _hasSamePort: function Microsoft_Office_Common_XdmCommunicationManager$_hasSamePort(url_parser1, url_parser2) { return url_parser1.port == url_parser2.port; }, receiveFromClient: function Microsoft_Office_Common_XdmCommunicationManager$_receiveFromClient(e) { _receive(e); } }; })(); class MethodObject { constructor(method, invokeType, blockingOthers) { this._method = method; this._invokeType = invokeType; this._blockingOthers = blockingOthers; } getMethod() { return this._method; } getInvokeType() { return this._invokeType; } getBlockingFlag() { return this._blockingOthers; } } Common.MethodObject = MethodObject; class EventMethodObject { constructor(registerMethodObject, unregisterMethodObject) { this._registerMethodObject = registerMethodObject; this._unregisterMethodObject = unregisterMethodObject; } getRegisterMethodObject() { return this._registerMethodObject; } getUnregisterMethodObject() { return this._unregisterMethodObject; } } Common.EventMethodObject = EventMethodObject; class ServiceEndPoint { constructor(serviceEndPointId) { var e = Function._validateParams(arguments, [ { name: "serviceEndPointId", type: String, mayBeNull: false } ]); if (e) throw e; this._methodObjectList = {}; this._eventHandlerProxyList = {}; this._Id = serviceEndPointId; this._conversations = {}; this._policyManager = null; this._appDomains = {}; this._onHandleRequestError = null; } registerMethod(methodName, method, invokeType, blockingOthers) { var e = Function._validateParams(arguments, [ { name: "methodName", type: String, mayBeNull: false }, { name: "method", type: Function, mayBeNull: false }, { name: "invokeType", type: Number, mayBeNull: false }, { name: "blockingOthers", type: Boolean, mayBeNull: false } ]); if (e) throw e; if (invokeType !== Microsoft.Office.Common.InvokeType.async && invokeType !== Microsoft.Office.Common.InvokeType.sync) { throw OsfMsAjaxFactory.msAjaxError.argument("invokeType"); } var methodObject = new Microsoft.Office.Common.MethodObject(method, invokeType, blockingOthers); this._methodObjectList[methodName] = methodObject; } unregisterMethod(methodName) { var e = Function._validateParams(arguments, [ { name: "methodName", type: String, mayBeNull: false } ]); if (e) throw e; delete this._methodObjectList[methodName]; } registerEvent(eventName, registerMethod, unregisterMethod) { var e = Function._validateParams(arguments, [ { name: "eventName", type: String, mayBeNull: false }, { name: "registerMethod", type: Function, mayBeNull: false }, { name: "unregisterMethod", type: Function, mayBeNull: false } ]); if (e) throw e; var methodObject = new Microsoft.Office.Common.EventMethodObject(new Microsoft.Office.Common.MethodObject(registerMethod, Microsoft.Office.Common.InvokeType.syncRegisterEvent, false), new Microsoft.Office.Common.MethodObject(unregisterMethod, Microsoft.Office.Common.InvokeType.syncUnregisterEvent, false)); this._methodObjectList[eventName] = methodObject; } registerEventEx(eventName, registerMethod, registerMethodInvokeType, unregisterMethod, unregisterMethodInvokeType) { var e = Function._validateParams(arguments, [ { name: "eventName", type: String, mayBeNull: false }, { name: "registerMethod", type: Function, mayBeNull: false }, { name: "registerMethodInvokeType", type: Number, mayBeNull: false }, { name: "unregisterMethod", type: Function, mayBeNull: false }, { name: "unregisterMethodInvokeType", type: Number, mayBeNull: false } ]); if (e) throw e; var methodObject = new Microsoft.Office.Common.EventMethodObject(new Microsoft.Office.Common.MethodObject(registerMethod, registerMethodInvokeType, false), new Microsoft.Office.Common.MethodObject(unregisterMethod, unregisterMethodInvokeType, false)); this._methodObjectList[eventName] = methodObject; } unregisterEvent(eventName) { var e = Function._validateParams(arguments, [ { name: "eventName", type: String, mayBeNull: false } ]); if (e) throw e; this.unregisterMethod(eventName); } registerConversation(conversationId, conversationUrl, appDomains, controlId) { var e = Function._validateParams(arguments, [ { name: "conversationId", type: String, mayBeNull: false }, { name: "conversationUrl", type: String, mayBeNull: false, optional: true }, { name: "appDomains", type: Object, mayBeNull: true, optional: true }, { name: "controlId", type: String, mayBeNull: true, optional: true }, ]); if (e) throw e; if (appDomains) { if (!(appDomains instanceof Array)) { throw OsfMsAjaxFactory.msAjaxError.argument("appDomains"); } this._appDomains[conversationId] = appDomains; } this._conversations[conversationId] = { url: conversationUrl, controlId: controlId }; } unregisterConversation(conversationId) { var e = Function._validateParams(arguments, [ { name: "conversationId", type: String, mayBeNull: false } ]); if (e) throw e; delete this._conversations[conversationId]; } setPolicyManager(policyManager) { var e = Function._validateParams(arguments, [ { name: "policyManager", type: Object, mayBeNull: false } ]); if (e) throw e; if (!policyManager.checkPermission) { throw OsfMsAjaxFactory.msAjaxError.argument("policyManager"); } this._policyManager = policyManager; } getPolicyManager() { return this._policyManager; } dispose() { this._methodObjectList = null; this._eventHandlerProxyList = null; this._Id = null; this._conversations = null; this._policyManager = null; this._appDomains = null; this._onHandleRequestError = null; } } Common.ServiceEndPoint = ServiceEndPoint; class ClientEndPoint { constructor(conversationId, targetWindow, targetUrl) { var e = Function._validateParams(arguments, [ { name: "conversationId", type: String, mayBeNull: false }, { name: "targetWindow", mayBeNull: false }, { name: "targetUrl", type: String, mayBeNull: false } ]); if (e) throw e; try { if (!targetWindow.postMessage) { throw OsfMsAjaxFactory.msAjaxError.argument("targetWindow"); } } catch (ex) { if (!Object.prototype.hasOwnProperty.call(targetWindow, "postMessage")) { throw OsfMsAjaxFactory.msAjaxError.argument("targetWindow"); } } this._conversationId = conversationId; this._targetWindow = targetWindow; this._targetUrl = targetUrl; this._callingIndex = 0; this._callbackList = {}; this._eventHandlerList = {}; this._checkReceiverOriginAndRun = null; this._hostTrustCheckStatus = Microsoft.Office.Common.HostTrustStatus.unknown; this._checkStatusLogged = false; } invoke(targetMethodName, callback, param, trustedParams = null) { var e = Function._validateParams(arguments, [ { name: "targetMethodName", type: String, mayBeNull: false }, { name: "callback", type: Function, mayBeNull: true }, { name: "param", mayBeNull: true }, { name: "trustedParams", mayBeNull: true, optional: true } ]); if (e) throw e; var me = this; var funcToRun = function () { var correlationId = me._callingIndex++; var now = new Date(); var callbackEntry = { "callback": callback, "createdOn": now.getTime() }; if (param && typeof param === "object" && typeof param.__timeout__ === "number") { callbackEntry.timeout = param.__timeout__; delete param.__timeout__; } me._callbackList[correlationId] = callbackEntry; try { if (me._hostTrustCheckStatus !== Microsoft.Office.Common.HostTrustStatus.trusted) { if (targetMethodName !== "ContextActivationManager_getAppContextAsync") { throw "Access Denied"; } } var callRequest = new Microsoft.Office.Common.Request(targetMethodName, Microsoft.Office.Common.ActionType.invoke, me._conversationId, correlationId, param); var msg = Microsoft.Office.Common.MessagePackager.envelope(callRequest); me._targetWindow.postMessage(msg, me._targetUrl); Microsoft.Office.Common.XdmCommunicationManager._startMethodTimeoutTimer(); } catch (ex) { try { if (callback !== null) callback(Microsoft.Office.Common.InvokeResultCode.errorInRequest, ex); } finally { delete me._callbackList[correlationId]; } } }; if (me._checkReceiverOriginAndRun) { me._checkReceiverOriginAndRun(funcToRun); } else { me._hostTrustCheckStatus = Microsoft.Office.Common.HostTrustStatus.trusted; funcToRun(); } } registerForEvent(targetEventName, eventHandler, callback, data) { var e = Function._validateParams(arguments, [ { name: "targetEventName", type: String, mayBeNull: false }, { name: "eventHandler", type: Function, mayBeNull: false }, { name: "callback", type: Function, mayBeNull: true }, { name: "data", mayBeNull: true, optional: true } ]); if (e) throw e; var correlationId = this._callingIndex++; var now = new Date(); this._callbackList[correlationId] = { "callback": callback, "createdOn": now.getTime() }; try { var callRequest = new Microsoft.Office.Common.Request(targetEventName, Microsoft.Office.Common.ActionType.registerEvent, this._conversationId, correlationId, data); var msg = Microsoft.Office.Common.MessagePackager.envelope(callRequest); this._targetWindow.postMessage(msg, this._targetUrl); Microsoft.Office.Common.XdmCommunicationManager._startMethodTimeoutTimer(); this._eventHandlerList[targetEventName] = eventHandler; } catch (ex) { try { if (callback !== null) { callback(Microsoft.Office.Common.InvokeResultCode.errorInRequest, ex); } } finally { delete this._callbackList[correlationId]; } } } unregisterForEvent(targetEventName, callback, data) { var e = Function._validateParams(arguments, [ { name: "targetEventName", type: String, mayBeNull: false }, { name: "callback", type: Function, mayBeNull: true }, { name: "data", mayBeNull: true, optional: true } ]); if (e) throw e; var correlationId = this._callingIndex++; var now = new Date(); this._callbackList[correlationId] = { "callback": callback, "createdOn": now.getTime() }; try { var callRequest = new Microsoft.Office.Common.Request(targetEventName, Microsoft.Office.Common.ActionType.unregisterEvent, this._conversationId, correlationId, data); var msg = Microsoft.Office.Common.MessagePackager.envelope(callRequest); this._targetWindow.postMessage(msg, this._targetUrl); Microsoft.Office.Common.XdmCommunicationManager._startMethodTimeoutTimer(); } catch (ex) { try { if (callback !== null) { callback(Microsoft.Office.Common.InvokeResultCode.errorInRequest, ex); } } finally { delete this._callbackList[correlationId]; } } finally { delete this._eventHandlerList[targetEventName]; } } } Common.ClientEndPoint = ClientEndPoint; class Message { constructor(messageType, actionName, conversationId, correlationId, data) { var e = Function._validateParams(arguments, [ { name: "messageType", type: Number, mayBeNull: false }, { name: "actionName", type: String, mayBeNull: false }, { name: "conversationId", type: String, mayBeNull: false }, { name: "correlationId", mayBeNull: false }, { name: "data", mayBeNull: true, optional: true } ]); if (e) throw e; this._messageType = messageType; this._actionName = actionName; this._conversationId = conversationId; this._correlationId = correlationId; this._origin = window.location.origin; if (typeof data == "undefined") { this._data = null; } else { this._data = data; } } getActionName() { return this._actionName; } getConversationId() { return this._conversationId; } getCorrelationId() { return this._correlationId; } getOrigin() { return this._origin; } getData() { return this._data; } getMessageType() { return this._messageType; } } Common.Message = Message; class Request extends Message { constructor(actionName, actionType, conversationId, correlationId, data) { super(Microsoft.Office.Common.MessageType.request, actionName, conversationId, correlationId, data); this._actionType = actionType; } getActionType() { return this._actionType; } } Common.Request = Request; class Response extends Message { constructor(actionName, conversationId, correlationId, errorCode, responseType, data) { super(Microsoft.Office.Common.MessageType.response, actionName, conversationId, correlationId, data); this._errorCode = errorCode; this._responseType = responseType; } getErrorCode() { return this._errorCode; } getResponseType() { return this._responseType; } } Common.Response = Response; class Invoker { constructor(methodObject, paramValue, invokeCompleteCallback, eventHandlerProxyList, conversationId, eventName, trustedParams = null) { var e = Function._validateParams(arguments, [ { name: "methodObject", mayBeNull: false }, { name: "paramValue", mayBeNull: true }, { name: "invokeCompleteCallback", mayBeNull: false }, { name: "eventHandlerProxyList", mayBeNull: true }, { name: "conversationId", type: String, mayBeNull: false }, { name: "eventName", type: String, mayBeNull: false }, { name: "trustedParams", type: Object, mayBeNull: true, optional: true } ]); if (e) throw e; this._methodObject = methodObject; this._param = paramValue; this._trustedParams = trustedParams; this._invokeCompleteCallback = invokeCompleteCallback; this._eventHandlerProxyList = eventHandlerProxyList; this._conversationId = conversationId; this._eventName = eventName; } invoke() { try { var result; switch (this._methodObject.getInvokeType()) { case Microsoft.Office.Common.InvokeType.async: this._methodObject.getMethod()(this._param, this._invokeCompleteCallback.getSend(), this._trustedParams); break; case Microsoft.Office.Common.InvokeType.sync: result = this._methodObject.getMethod()(this._param, this._trustedParams); this._invokeCompleteCallback.getSend()(result); break; case Microsoft.Office.Common.InvokeType.syncRegisterEvent: var eventHandlerProxy = this._createEventHandlerProxyObject(this._invokeCompleteCallback); result = this._methodObject.getMethod()(eventHandlerProxy.getSend(), this._param, this._trustedParams); this._eventHandlerProxyList[this._conversationId + this._eventName] = eventHandlerProxy.getSend(); this._invokeCompleteCallback.getSend()(result); break; case Microsoft.Office.Common.InvokeType.syncUnregisterEvent: var eventHandler = this._eventHandlerProxyList[this._conversationId + this._eventName]; result = this._methodObject.getMethod()(eventHandler, this._param, this._trustedParams); delete this._eventHandlerProxyList[this._conversationId + this._eventName]; this._invokeCompleteCallback.getSend()(result); break; case Microsoft.Office.Common.InvokeType.asyncRegisterEvent: var eventHandlerProxyAsync = this._createEventHandlerProxyObject(this._invokeCompleteCallback); this._methodObject.getMethod()(eventHandlerProxyAsync.getSend(), this._invokeCompleteCallback.getSend(), this._param, this._trustedParams); this._eventHandlerProxyList[this._callerId + this._eventName] = eventHandlerProxyAsync.getSend(); break; case Microsoft.Office.Common.InvokeType.asyncUnregisterEvent: var eventHandlerAsync = this._eventHandlerProxyList[this._callerId + this._eventName]; this._methodObject.getMethod()(eventHandlerAsync, this._invokeCompleteCallback.getSend(), this._param, this._trustedParams); delete this._eventHandlerProxyList[this._callerId + this._eventName]; break; default: break; } } catch (ex) { this._invokeCompleteCallback.setResultCode(Microsoft.Office.Common.InvokeResultCode.errorInResponse); this._invokeCompleteCallback.getSend()(ex); } } getInvokeBlockingFlag() { return this._methodObject.getBlockingFlag(); } _createEventHandlerProxyObject(invokeCompleteObject) { return new Microsoft.Office.Common.ResponseSender(invokeCompleteObject.getRequesterWindow(), invokeCompleteObject.getRequesterUrl(), invokeCompleteObject.getActionName(), invokeCompleteObject.getConversationId(), invokeCompleteObject.getCorrelationId(), Microsoft.Office.Common.ResponseType.forEventing); } } Common.Invoker = Invoker; })(Common = Office.Common || (Office.Common = {})); })(Office = Microsoft.Office || (Microsoft.Office = {})); })(Microsoft || (Microsoft = {})); var OfficeExt; (function (OfficeExt) { var WACUtils; (function (WACUtils) { var _trustedDomain = "^https:\/\/[a-z0-9-]+\.(officeapps\.live|officeapps-df\.live|partner\.officewebapps)\.com\/?$"; function parseAppContextFromWindowName(skipSessionStorage, windowName) { return OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.AppContext); } WACUtils.parseAppContextFromWindowName = parseAppContextFromWindowName; function serializeObjectToString(obj) { if (typeof (JSON) !== "undefined") { try { return JSON.stringify(obj); } catch (ex) { } } return ""; } WACUtils.serializeObjectToString = serializeObjectToString; function isHostTrusted() { const domain = getDomainForUrl(OSF.getClientEndPoint()._targetUrl.toLowerCase()); return (new RegExp(_trustedDomain)).test(domain); } WACUtils.isHostTrusted = isHostTrusted; function addHostInfoAsQueryParam(url, hostInfoValue) { if (!url) { return null; } url = url.trim() || ''; var questionMark = "?"; var hostInfo = "_host_Info="; var ampHostInfo = "&_host_Info="; var fragmentSeparator = "#"; var urlParts = url.split(fragmentSeparator); var urlWithoutFragment = urlParts.shift(); var fragment = urlParts.join(fragmentSeparator); var querySplits = urlWithoutFragment.split(questionMark); var urlWithoutFragmentWithHostInfo; if (querySplits.length > 1) { urlWithoutFragmentWithHostInfo = urlWithoutFragment + ampHostInfo + hostInfoValue; } else if (querySplits.length > 0) { urlWithoutFragmentWithHostInfo = urlWithoutFragment + questionMark + hostInfo + hostInfoValue; } if (fragment) { return [urlWithoutFragmentWithHostInfo, fragmentSeparator, fragment].join(''); } else { return urlWithoutFragmentWithHostInfo; } } WACUtils.addHostInfoAsQueryParam = addHostInfoAsQueryParam; function getDomainForUrl(url) { if (!url) { return null; } var url_parser = OSF.OUtil.parseUrl(url, true); return url_parser.protocol + "//" + url_parser.host; } WACUtils.getDomainForUrl = getDomainForUrl; function shouldUseLocalStorageToPassMessage() { try { var osList = [ "Windows NT 6.1", "Windows NT 6.2", "Windows NT 6.3", "Windows NT 10.0" ]; var userAgent = window.navigator.userAgent; for (var i = 0, len = osList.length; i < len; i++) { if (userAgent.indexOf(osList[i]) > -1) { return isInternetExplorer(); } } return false; } catch (e) { logExceptionToBrowserConsole("Error happens in shouldUseLocalStorageToPassMessage.", e); return false; } } WACUtils.shouldUseLocalStorageToPassMessage = shouldUseLocalStorageToPassMessage; function isInternetExplorer() { try { var userAgent = window.navigator.userAgent; return userAgent.indexOf("MSIE ") > -1 || userAgent.indexOf("Trident/") > -1 || userAgent.indexOf("Edge/") > -1; } catch (e) { logExceptionToBrowserConsole("Error happens in isInternetExplorer.", e); return false; } } WACUtils.isInternetExplorer = isInternetExplorer; function removeMatchesFromLocalStorage(regexPatterns) { var _localStorage = OSF.OUtil.getLocalStorage(); var keys = _localStorage.getKeysWithPrefix(""); for (var i = 0, len = keys.length; i < len; i++) { var key = keys[i]; for (var j = 0, lenRegex = regexPatterns.length; j < lenRegex; j++) { if (regexPatterns[j].test(key)) { _localStorage.removeItem(key); break; } } } } WACUtils.removeMatchesFromLocalStorage = removeMatchesFromLocalStorage; function logExceptionToBrowserConsole(message, exception) { OsfMsAjaxFactory.msAjaxDebug.trace(message + " Exception details: " + serializeObjectToString(exception)); } WACUtils.logExceptionToBrowserConsole = logExceptionToBrowserConsole; function isTeamsWebView() { const ua = navigator.userAgent; return /Teams\/((?:(\d+)\.)?(?:(\d+)\.)?(?:(\d+)\.\d+)).* Electron\/((?:(\d+)\.)?(?:(\d+)\.)?(?:(\d+)\.\d+))/.test(ua); } WACUtils.isTeamsWebView = isTeamsWebView; function getHostSecure(url) { if (typeof url === "undefined" || !url) { return undefined; } let host = undefined; const httpsProtocol = "https:"; try { let urlObj = new URL(url); if (urlObj) { host = urlObj.host; } if (!urlObj.protocol) { throw "fallback"; } else if (urlObj.protocol !== httpsProtocol) { return undefined; } } catch (ex) { try { let parser = document.createElement("a"); parser.href = url; if (parser.protocol !== httpsProtocol) { return undefined; } let match = url.match(new RegExp("^https://[^/?#]+", "i")); let naiveMatch = (match && match.length == 1) ? match[0].toLowerCase() : ""; let parsedUrlWithoutPort = (parser.protocol + "//" + parser.hostname).toLowerCase(); let parsedUrlWithPort = (parser.protocol + "//" + parser.host).toLowerCase(); if (parsedUrlWithPort === naiveMatch || parsedUrlWithoutPort == naiveMatch) { host = parser.port == "443" ? parser.hostname : parser.host; } } catch (ex) { return undefined; } } return host ? host.toLowerCase() : undefined; } WACUtils.getHostSecure = getHostSecure; class CacheConstants { } CacheConstants.GatedCacheKeyPrefix = "__OSF_GATED_OMEX."; CacheConstants.AnonymousCacheKeyPrefix = "__OSF_ANONYMOUS_OMEX."; CacheConstants.UngatedCacheKeyPrefix = "__OSF_OMEX."; CacheConstants.ActivatedCacheKeyPrefix = "__OSF_RUNTIME_.Activated."; CacheConstants.AppinstallAuthenticated = "appinstall_authenticated."; CacheConstants.Entitlement = "entitle."; CacheConstants.AppState = "appState."; CacheConstants.AppDetails = "appDetails."; CacheConstants.AppInstallInfo = "appInstallInfo."; CacheConstants.AuthenticatedAppInstallInfoCacheKey = CacheConstants.GatedCacheKeyPrefix + CacheConstants.AppinstallAuthenticated + "{0}.{1}.{2}.{3}"; CacheConstants.EntitlementsKey = CacheConstants.Entitlement + "{0}.{1}"; CacheConstants.AppStateCacheKey = "{0}" + CacheConstants.AppState + "{1}.{2}"; CacheConstants.AppDetailKey = "{0}" + CacheConstants.AppDetails + "{1}.{2}"; CacheConstants.AppInstallInfoKey = "{0}" + CacheConstants.AppInstallInfo + "{1}.{2}"; CacheConstants.ActivatedCacheKey = CacheConstants.ActivatedCacheKeyPrefix + "{0}.{1}.{2}"; WACUtils.CacheConstants = CacheConstants; })(WACUtils = OfficeExt.WACUtils || (OfficeExt.WACUtils = {})); })(OfficeExt || (OfficeExt = {})); var OSF; (function (OSF) { let OmexRemoveAddinResultCode; (function (OmexRemoveAddinResultCode) { OmexRemoveAddinResultCode[OmexRemoveAddinResultCode["Success"] = 0] = "Success"; OmexRemoveAddinResultCode[OmexRemoveAddinResultCode["ClientError"] = 400] = "ClientError"; OmexRemoveAddinResultCode[OmexRemoveAddinResultCode["ServerError"] = 500] = "ServerError"; OmexRemoveAddinResultCode[OmexRemoveAddinResultCode["UnknownError"] = 600] = "UnknownError"; })(OmexRemoveAddinResultCode = OSF.OmexRemoveAddinResultCode || (OSF.OmexRemoveAddinResultCode = {})); let OmexRemoveAddinMessageKeys; (function (OmexRemoveAddinMessageKeys) { OmexRemoveAddinMessageKeys["RemoveAddinResultCode"] = "resultCode"; OmexRemoveAddinMessageKeys["RemoveAddinResultValue"] = "resultValue"; })(OmexRemoveAddinMessageKeys = OSF.OmexRemoveAddinMessageKeys || (OSF.OmexRemoveAddinMessageKeys = {})); let OmexMessageKeys; (function (OmexMessageKeys) { OmexMessageKeys["MessageType"] = "messageType"; OmexMessageKeys["MessageValue"] = "messageValue"; })(OmexMessageKeys = OSF.OmexMessageKeys || (OSF.OmexMessageKeys = {})); let AuthType; (function (AuthType) { AuthType[AuthType["Anonymous"] = 0] = "Anonymous"; AuthType[AuthType["MSA"] = 1] = "MSA"; AuthType[AuthType["OrgId"] = 2] = "OrgId"; AuthType[AuthType["ADAL"] = 3] = "ADAL"; })(AuthType = OSF.AuthType || (OSF.AuthType = {})); let OmexPageParameterKeys; (function (OmexPageParameterKeys) { OmexPageParameterKeys["AppName"] = "client"; OmexPageParameterKeys["AppVersion"] = "cv"; OmexPageParameterKeys["AppUILocale"] = "ui"; OmexPageParameterKeys["AppDomain"] = "appDomain"; OmexPageParameterKeys["StoreLocator"] = "rs"; OmexPageParameterKeys["AssetId"] = "assetid"; OmexPageParameterKeys["NotificationType"] = "notificationType"; OmexPageParameterKeys["AppCorrelationId"] = "corr"; OmexPageParameterKeys["AuthType"] = "authType"; OmexPageParameterKeys["AppId"] = "appid"; OmexPageParameterKeys["Scopes"] = "scopes"; })(OmexPageParameterKeys = OSF.OmexPageParameterKeys || (OSF.OmexPageParameterKeys = {})); let HostThemeButtonStyleKeys; (function (HostThemeButtonStyleKeys) { HostThemeButtonStyleKeys["ButtonBorderColor"] = "buttonBorderColor"; HostThemeButtonStyleKeys["ButtonBackgroundColor"] = "buttonBackgroundColor"; })(HostThemeButtonStyleKeys = OSF.HostThemeButtonStyleKeys || (OSF.HostThemeButtonStyleKeys = {})); let ShowWindowDialogParameterKeys; (function (ShowWindowDialogParameterKeys) { ShowWindowDialogParameterKeys["Url"] = "url"; ShowWindowDialogParameterKeys["Width"] = "width"; ShowWindowDialogParameterKeys["Height"] = "height"; ShowWindowDialogParameterKeys["DisplayInIframe"] = "displayInIframe"; ShowWindowDialogParameterKeys["HideTitle"] = "hideTitle"; ShowWindowDialogParameterKeys["UseDeviceIndependentPixels"] = "useDeviceIndependentPixels"; ShowWindowDialogParameterKeys["PromptBeforeOpen"] = "promptBeforeOpen"; ShowWindowDialogParameterKeys["EnforceAppDomain"] = "enforceAppDomain"; ShowWindowDialogParameterKeys["UrlNoHostInfo"] = "urlNoHostInfo"; })(ShowWindowDialogParameterKeys = OSF.ShowWindowDialogParameterKeys || (OSF.ShowWindowDialogParameterKeys = {})); })(OSF || (OSF = {})); let stringResourceFileValue = 'osfruntime_strings.js'; if (DEBUG) { stringResourceFileValue = 'osfruntime_strings.debug.js'; } var OSF; (function (OSF) { OSF.Constants = { FileVersion: '0.0.0.0', ThreePartsFileVersion: '0.0.0', OmexAnonymousServiceName: "__omexExtensionAnonymousProxy", OmexAnonymousServiceExtension: "/anonymousserviceextension.aspx", OmexGatedServiceName: "__omexExtensionGatedProxy", OmexGatedServiceExtension: "/gatedserviceextension.aspx", OmexUnGatedServiceName: "__omexExtensionProxy", OmexUnGatedServiceExtension: "/ungatedserviceextension.aspx", OmexConsentNotificationPage: "/client/consentnotification.aspx", Http: "http", Https: "https", ProtocolSeparator: "://", SignInRedirectUrl: "/logontoliveforwac.aspx?returnurl=", ETokenParameterName: "et", ActivatedCacheKey: "__OSF_RUNTIME_.Activated.{0}.{1}.{2}", ConsentedCacheKey: "__OSF_RUNTIME_.Consented.{0}.{1}.{2}", AuthenticatedConnectMaxTries: 3, IgnoreSandBoxSupport: "Ignore_SandBox_Support", IEUpgradeUrl: "https://office.microsoft.com/redir/HA102789344.aspx", OmexForceAnonymousParamName: "SKAV", OmexForceAnonymousParamValue: "274AE4CD-E50B-4342-970E-1E7F36C70037", EndPointInternalSuffix: "_internal", SPCatalogTrustedLocationsCacheKey: "__OSF_RUNTIME_.SPCatalog_TrustedLocations", AddinPermissionsTable: "OSF.ADDINS.AddinPermissions", StringResourceFile: stringResourceFileValue }; })(OSF || (OSF = {})); var OSF; (function (OSF) { let ClientMode; (function (ClientMode) { ClientMode[ClientMode["ReadOnly"] = 0] = "ReadOnly"; ClientMode[ClientMode["ReadWrite"] = 1] = "ReadWrite"; })(ClientMode = OSF.ClientMode || (OSF.ClientMode = {})); let OsfControlType; (function (OsfControlType) { OsfControlType[OsfControlType["DocumentLevel"] = 0] = "DocumentLevel"; OsfControlType[OsfControlType["ContainerLevel"] = 1] = "ContainerLevel"; })(OsfControlType = OSF.OsfControlType || (OSF.OsfControlType = {})); OSF.OfficeAppContext = function OSF_OfficeAppContext(id, appName, appVersion, appUILocale, dataLocale, docUrl, clientMode, settings, reason, osfControlType, eToken, correlationId, appInstanceId, touchEnabled, commerceAllowed, appMinorVersion, requirementMatrix, hostCustomMessage, hostFullVersion, clientWindowHeight, clientWindowWidth, addinName, appDomains, dialogRequirementMatrix, featureGates, officeTheme, initialDisplayMode, hostSettings) { this._id = id; this._appName = appName; this._appVersion = appVersion; this._appUILocale = appUILocale; this._dataLocale = dataLocale; this._docUrl = docUrl; this._clientMode = clientMode; this._settings = settings; this._reason = reason; this._osfControlType = osfControlType; this._eToken = eToken; this._correlationId = correlationId; this._appInstanceId = appInstanceId; this._touchEnabled = touchEnabled; this._commerceAllowed = commerceAllowed; this._appMinorVersion = appMinorVersion; this._requirementMatrix = requirementMatrix; this._hostCustomMessage = hostCustomMessage; this._hostFullVersion = hostFullVersion; this._isDialog = false; this._clientWindowHeight = clientWindowHeight; this._clientWindowWidth = clientWindowWidth; this._addinName = addinName; this._appDomains = appDomains; this._dialogRequirementMatrix = dialogRequirementMatrix; this._featureGates = featureGates; this._officeTheme = officeTheme; this._initialDisplayMode = initialDisplayMode; this._hostSettings = hostSettings; this.get_id = function get_id() { return this._id; }; this.get_appName = function get_appName() { return this._appName; }; this.get_appVersion = function get_appVersion() { return this._appVersion; }; this.get_appUILocale = function get_appUILocale() { return this._appUILocale; }; this.get_dataLocale = function get_dataLocale() { return this._dataLocale; }; this.get_docUrl = function get_docUrl() { return this._docUrl; }; this.get_clientMode = function get_clientMode() { return this._clientMode; }; this.get_bindings = function get_bindings() { return this._bindings; }; this.get_settings = function get_settings() { return this._settings; }; this.get_reason = function get_reason() { return this._reason; }; this.get_osfControlType = function get_osfControlType() { return this._osfControlType; }; this.get_eToken = function get_eToken() { return this._eToken; }; this.get_correlationId = function get_correlationId() { return this._correlationId; }; this.get_appInstanceId = function get_appInstanceId() { return this._appInstanceId; }; this.get_touchEnabled = function get_touchEnabled() { return this._touchEnabled; }; this.get_commerceAllowed = function get_commerceAllowed() { return this._commerceAllowed; }; this.get_appMinorVersion = function get_appMinorVersion() { return this._appMinorVersion; }; this.get_requirementMatrix = function get_requirementMatrix() { return this._requirementMatrix; }; this.get_dialogRequirementMatrix = function get_dialogRequirementMatrix() { return this._dialogRequirementMatrix; }; this.get_hostCustomMessage = function get_hostCustomMessage() { return this._hostCustomMessage; }; this.get_hostFullVersion = function get_hostFullVersion() { return this._hostFullVersion; }; this.get_isDialog = function get_isDialog() { return this._isDialog; }; this.get_clientWindowHeight = function get_clientWindowHeight() { return this._clientWindowHeight; }; this.get_clientWindowWidth = function get_clientWindowWidth() { return this._clientWindowWidth; }; this.get_addinName = function get_addinName() { return this._addinName; }; this.get_appDomains = function get_appDomains() { return this._appDomains; }; this.get_featureGates = function get_featureGates() { return this._featureGates; }; this.get_officeTheme = function get_officeTheme() { return this._officeTheme; }; this.get_initialDisplayMode = function get_initialDisplayMode() { return this._initialDisplayMode ? this._initialDisplayMode : 0; }; this.get_hostSettings = function get_hostSettings() { return this._hostSettings; }; }; let DialogMessageType; (function (DialogMessageType) { DialogMessageType[DialogMessageType["DialogMessageReceived"] = 0] = "DialogMessageReceived"; DialogMessageType[DialogMessageType["DialogParentMessageReceived"] = 1] = "DialogParentMessageReceived"; DialogMessageType[DialogMessageType["DialogClosed"] = 12006] = "DialogClosed"; })(DialogMessageType = OSF.DialogMessageType || (OSF.DialogMessageType = {})); let SharedConstants; (function (SharedConstants) { SharedConstants["NotificationConversationIdSuffix"] = "_ntf"; })(SharedConstants = OSF.SharedConstants || (OSF.SharedConstants = {})); let AgaveHostAction; (function (AgaveHostAction) { AgaveHostAction[AgaveHostAction["Select"] = 0] = "Select"; AgaveHostAction[AgaveHostAction["UnSelect"] = 1] = "UnSelect"; AgaveHostAction[AgaveHostAction["CancelDialog"] = 2] = "CancelDialog"; AgaveHostAction[AgaveHostAction["InsertAgave"] = 3] = "InsertAgave"; AgaveHostAction[AgaveHostAction["CtrlF6In"] = 4] = "CtrlF6In"; AgaveHostAction[AgaveHostAction["CtrlF6Exit"] = 5] = "CtrlF6Exit"; AgaveHostAction[AgaveHostAction["CtrlF6ExitShift"] = 6] = "CtrlF6ExitShift"; AgaveHostAction[AgaveHostAction["SelectWithError"] = 7] = "SelectWithError"; AgaveHostAction[AgaveHostAction["NotifyHostError"] = 8] = "NotifyHostError"; AgaveHostAction[AgaveHostAction["RefreshAddinCommands"] = 9] = "RefreshAddinCommands"; AgaveHostAction[AgaveHostAction["PageIsReady"] = 10] = "PageIsReady"; AgaveHostAction[AgaveHostAction["TabIn"] = 11] = "TabIn"; AgaveHostAction[AgaveHostAction["TabInShift"] = 12] = "TabInShift"; AgaveHostAction[AgaveHostAction["TabExit"] = 13] = "TabExit"; AgaveHostAction[AgaveHostAction["TabExitShift"] = 14] = "TabExitShift"; AgaveHostAction[AgaveHostAction["EscExit"] = 15] = "EscExit"; AgaveHostAction[AgaveHostAction["F2Exit"] = 16] = "F2Exit"; AgaveHostAction[AgaveHostAction["ExitNoFocusable"] = 17] = "ExitNoFocusable"; AgaveHostAction[AgaveHostAction["ExitNoFocusableShift"] = 18] = "ExitNoFocusableShift"; AgaveHostAction[AgaveHostAction["MouseEnter"] = 19] = "MouseEnter"; AgaveHostAction[AgaveHostAction["MouseLeave"] = 20] = "MouseLeave"; AgaveHostAction[AgaveHostAction["UpdateTargetUrl"] = 21] = "UpdateTargetUrl"; AgaveHostAction[AgaveHostAction["InstallCustomFunctions"] = 22] = "InstallCustomFunctions"; AgaveHostAction[AgaveHostAction["SendTelemetryEvent"] = 23] = "SendTelemetryEvent"; AgaveHostAction[AgaveHostAction["UninstallCustomFunctions"] = 24] = "UninstallCustomFunctions"; AgaveHostAction[AgaveHostAction["SendMessage"] = 25] = "SendMessage"; AgaveHostAction[AgaveHostAction["LaunchExtensionComponent"] = 26] = "LaunchExtensionComponent"; AgaveHostAction[AgaveHostAction["StopExtensionComponent"] = 27] = "StopExtensionComponent"; AgaveHostAction[AgaveHostAction["RestartExtensionComponent"] = 28] = "RestartExtensionComponent"; AgaveHostAction[AgaveHostAction["EnableTaskPaneHeaderButton"] = 29] = "EnableTaskPaneHeaderButton"; AgaveHostAction[AgaveHostAction["DisableTaskPaneHeaderButton"] = 30] = "DisableTaskPaneHeaderButton"; AgaveHostAction[AgaveHostAction["TaskPaneHeaderButtonClicked"] = 31] = "TaskPaneHeaderButtonClicked"; AgaveHostAction[AgaveHostAction["RemoveAppCommandsAddin"] = 32] = "RemoveAppCommandsAddin"; AgaveHostAction[AgaveHostAction["RefreshRibbonGallery"] = 33] = "RefreshRibbonGallery"; AgaveHostAction[AgaveHostAction["GetOriginalControlId"] = 34] = "GetOriginalControlId"; AgaveHostAction[AgaveHostAction["OfficeJsReady"] = 35] = "OfficeJsReady"; AgaveHostAction[AgaveHostAction["InsertDevManifest"] = 36] = "InsertDevManifest"; AgaveHostAction[AgaveHostAction["InsertDevManifestError"] = 37] = "InsertDevManifestError"; AgaveHostAction[AgaveHostAction["SendCustomerContent"] = 38] = "SendCustomerContent"; AgaveHostAction[AgaveHostAction["KeyboardShortcuts"] = 39] = "KeyboardShortcuts"; AgaveHostAction[AgaveHostAction["OsfControlLoad"] = 40] = "OsfControlLoad"; AgaveHostAction[AgaveHostAction["ClickTrust"] = 41] = "ClickTrust"; AgaveHostAction[AgaveHostAction["CloseSDXDialog"] = 42] = "CloseSDXDialog"; AgaveHostAction[AgaveHostAction["ResizeSDXDialog"] = 43] = "ResizeSDXDialog"; AgaveHostAction[AgaveHostAction["SendNonStandardEvent"] = 44] = "SendNonStandardEvent"; })(AgaveHostAction = OSF.AgaveHostAction || (OSF.AgaveHostAction = {})); let HostCallPerfMarker; (function (HostCallPerfMarker) { HostCallPerfMarker["IssueCall"] = "Agave.HostCall.IssueCall"; HostCallPerfMarker["ReceiveResponse"] = "Agave.HostCall.ReceiveResponse"; HostCallPerfMarker["RuntimeExceptionRaised"] = "Agave.HostCall.RuntimeExecptionRaised"; })(HostCallPerfMarker = OSF.HostCallPerfMarker || (OSF.HostCallPerfMarker = {})); let InternalPerfMarker; (function (InternalPerfMarker) { InternalPerfMarker["DataCoercionBegin"] = "Agave.HostCall.CoerceDataStart"; InternalPerfMarker["DataCoercionEnd"] = "Agave.HostCall.CoerceDataEnd"; })(InternalPerfMarker = OSF.InternalPerfMarker || (OSF.InternalPerfMarker = {})); let NestedAppAuthBridgeType; (function (NestedAppAuthBridgeType) { NestedAppAuthBridgeType[NestedAppAuthBridgeType["None"] = 0] = "None"; NestedAppAuthBridgeType[NestedAppAuthBridgeType["ExecuteApi"] = 1] = "ExecuteApi"; NestedAppAuthBridgeType[NestedAppAuthBridgeType["PostMessage"] = 2] = "PostMessage"; })(NestedAppAuthBridgeType = OSF.NestedAppAuthBridgeType || (OSF.NestedAppAuthBridgeType = {})); let DDA; (function (DDA) { let EventDispId; (function (EventDispId) { EventDispId[EventDispId["dispidEventMin"] = 0] = "dispidEventMin"; EventDispId[EventDispId["dispidInitializeEvent"] = 0] = "dispidInitializeEvent"; EventDispId[EventDispId["dispidSettingsChangedEvent"] = 1] = "dispidSettingsChangedEvent"; EventDispId[EventDispId["dispidDocumentSelectionChangedEvent"] = 2] = "dispidDocumentSelectionChangedEvent"; EventDispId[EventDispId["dispidBindingSelectionChangedEvent"] = 3] = "dispidBindingSelectionChangedEvent"; EventDispId[EventDispId["dispidBindingDataChangedEvent"] = 4] = "dispidBindingDataChangedEvent"; EventDispId[EventDispId["dispidDocumentOpenEvent"] = 5] = "dispidDocumentOpenEvent"; EventDispId[EventDispId["dispidDocumentCloseEvent"] = 6] = "dispidDocumentCloseEvent"; EventDispId[EventDispId["dispidActiveViewChangedEvent"] = 7] = "dispidActiveViewChangedEvent"; EventDispId[EventDispId["dispidDocumentThemeChangedEvent"] = 8] = "dispidDocumentThemeChangedEvent"; EventDispId[EventDispId["dispidOfficeThemeChangedEvent"] = 9] = "dispidOfficeThemeChangedEvent"; EventDispId[EventDispId["dispidDialogMessageReceivedEvent"] = 10] = "dispidDialogMessageReceivedEvent"; EventDispId[EventDispId["dispidDialogNotificationShownInAddinEvent"] = 11] = "dispidDialogNotificationShownInAddinEvent"; EventDispId[EventDispId["dispidDialogParentMessageReceivedEvent"] = 12] = "dispidDialogParentMessageReceivedEvent"; EventDispId[EventDispId["dispidObjectDeletedEvent"] = 13] = "dispidObjectDeletedEvent"; EventDispId[EventDispId["dispidObjectSelectionChangedEvent"] = 14] = "dispidObjectSelectionChangedEvent"; EventDispId[EventDispId["dispidObjectDataChangedEvent"] = 15] = "dispidObjectDataChangedEvent"; EventDispId[EventDispId["dispidContentControlAddedEvent"] = 16] = "dispidContentControlAddedEvent"; EventDispId[EventDispId["dispidLiveShareStateChangedEvent"] = 17] = "dispidLiveShareStateChangedEvent"; EventDispId[EventDispId["dispidSuspend"] = 19] = "dispidSuspend"; EventDispId[EventDispId["dispidResume"] = 20] = "dispidResume"; EventDispId[EventDispId["dispidActivationStatusChangedEvent"] = 32] = "dispidActivationStatusChangedEvent"; EventDispId[EventDispId["dispidRichApiMessageEvent"] = 33] = "dispidRichApiMessageEvent"; EventDispId[EventDispId["dispidAppCommandInvokedEvent"] = 39] = "dispidAppCommandInvokedEvent"; EventDispId[EventDispId["dispidOlkItemSelectedChangedEvent"] = 46] = "dispidOlkItemSelectedChangedEvent"; EventDispId[EventDispId["dispidOlkRecipientsChangedEvent"] = 47] = "dispidOlkRecipientsChangedEvent"; EventDispId[EventDispId["dispidOlkAppointmentTimeChangedEvent"] = 48] = "dispidOlkAppointmentTimeChangedEvent"; EventDispId[EventDispId["dispidOlkRecurrenceChangedEvent"] = 49] = "dispidOlkRecurrenceChangedEvent"; EventDispId[EventDispId["dispidOlkAttachmentsChangedEvent"] = 50] = "dispidOlkAttachmentsChangedEvent"; EventDispId[EventDispId["dispidOlkEnhancedLocationsChangedEvent"] = 51] = "dispidOlkEnhancedLocationsChangedEvent"; EventDispId[EventDispId["dispidOlkInfobarClickedEvent"] = 52] = "dispidOlkInfobarClickedEvent"; EventDispId[EventDispId["dispidTaskSelectionChangedEvent"] = 56] = "dispidTaskSelectionChangedEvent"; EventDispId[EventDispId["dispidResourceSelectionChangedEvent"] = 57] = "dispidResourceSelectionChangedEvent"; EventDispId[EventDispId["dispidViewSelectionChangedEvent"] = 58] = "dispidViewSelectionChangedEvent"; EventDispId[EventDispId["dispidDataNodeAddedEvent"] = 60] = "dispidDataNodeAddedEvent"; EventDispId[EventDispId["dispidDataNodeReplacedEvent"] = 61] = "dispidDataNodeReplacedEvent"; EventDispId[EventDispId["dispidDataNodeDeletedEvent"] = 62] = "dispidDataNodeDeletedEvent"; EventDispId[EventDispId["dispidEventMax"] = 63] = "dispidEventMax"; })(EventDispId = DDA.EventDispId || (DDA.EventDispId = {})); let MethodDispId; (function (MethodDispId) { MethodDispId[MethodDispId["dispidMethodMin"] = 64] = "dispidMethodMin"; MethodDispId[MethodDispId["dispidGetSelectedDataMethod"] = 64] = "dispidGetSelectedDataMethod"; MethodDispId[MethodDispId["dispidSetSelectedDataMethod"] = 65] = "dispidSetSelectedDataMethod"; MethodDispId[MethodDispId["dispidAddBindingFromSelectionMethod"] = 66] = "dispidAddBindingFromSelectionMethod"; MethodDispId[MethodDispId["dispidAddBindingFromPromptMethod"] = 67] = "dispidAddBindingFromPromptMethod"; MethodDispId[MethodDispId["dispidGetBindingMethod"] = 68] = "dispidGetBindingMethod"; MethodDispId[MethodDispId["dispidReleaseBindingMethod"] = 69] = "dispidReleaseBindingMethod"; MethodDispId[MethodDispId["dispidGetBindingDataMethod"] = 70] = "dispidGetBindingDataMethod"; MethodDispId[MethodDispId["dispidSetBindingDataMethod"] = 71] = "dispidSetBindingDataMethod"; MethodDispId[MethodDispId["dispidAddRowsMethod"] = 72] = "dispidAddRowsMethod"; MethodDispId[MethodDispId["dispidClearAllRowsMethod"] = 73] = "dispidClearAllRowsMethod"; MethodDispId[MethodDispId["dispidGetAllBindingsMethod"] = 74] = "dispidGetAllBindingsMethod"; MethodDispId[MethodDispId["dispidLoadSettingsMethod"] = 75] = "dispidLoadSettingsMethod"; MethodDispId[MethodDispId["dispidSaveSettingsMethod"] = 76] = "dispidSaveSettingsMethod"; MethodDispId[MethodDispId["dispidGetDocumentCopyMethod"] = 77] = "dispidGetDocumentCopyMethod"; MethodDispId[MethodDispId["dispidAddBindingFromNamedItemMethod"] = 78] = "dispidAddBindingFromNamedItemMethod"; MethodDispId[MethodDispId["dispidAddColumnsMethod"] = 79] = "dispidAddColumnsMethod"; MethodDispId[MethodDispId["dispidGetDocumentCopyChunkMethod"] = 80] = "dispidGetDocumentCopyChunkMethod"; MethodDispId[MethodDispId["dispidReleaseDocumentCopyMethod"] = 81] = "dispidReleaseDocumentCopyMethod"; MethodDispId[MethodDispId["dispidNavigateToMethod"] = 82] = "dispidNavigateToMethod"; MethodDispId[MethodDispId["dispidGetActiveViewMethod"] = 83] = "dispidGetActiveViewMethod"; MethodDispId[MethodDispId["dispidGetDocumentThemeMethod"] = 84] = "dispidGetDocumentThemeMethod"; MethodDispId[MethodDispId["dispidGetOfficeThemeMethod"] = 85] = "dispidGetOfficeThemeMethod"; MethodDispId[MethodDispId["dispidGetFilePropertiesMethod"] = 86] = "dispidGetFilePropertiesMethod"; MethodDispId[MethodDispId["dispidClearFormatsMethod"] = 87] = "dispidClearFormatsMethod"; MethodDispId[MethodDispId["dispidSetTableOptionsMethod"] = 88] = "dispidSetTableOptionsMethod"; MethodDispId[MethodDispId["dispidSetFormatsMethod"] = 89] = "dispidSetFormatsMethod"; MethodDispId[MethodDispId["dispidGetUserIdentityInfoMethod"] = 92] = "dispidGetUserIdentityInfoMethod"; MethodDispId[MethodDispId["dispidExecuteRichApiRequestMethod"] = 93] = "dispidExecuteRichApiRequestMethod"; MethodDispId[MethodDispId["dispidAppCommandInvocationCompletedMethod"] = 94] = "dispidAppCommandInvocationCompletedMethod"; MethodDispId[MethodDispId["dispidCloseContainerMethod"] = 97] = "dispidCloseContainerMethod"; MethodDispId[MethodDispId["dispidGetAccessTokenMethod"] = 98] = "dispidGetAccessTokenMethod"; MethodDispId[MethodDispId["dispidGetAuthContextMethod"] = 99] = "dispidGetAuthContextMethod"; MethodDispId[MethodDispId["dispidGetLiveShareStateMethod"] = 100] = "dispidGetLiveShareStateMethod"; MethodDispId[MethodDispId["dispidSetLiveShareStateMethod"] = 101] = "dispidSetLiveShareStateMethod"; MethodDispId[MethodDispId["dispidOpenBrowserWindow"] = 102] = "dispidOpenBrowserWindow"; MethodDispId[MethodDispId["dispidCreateDocumentMethod"] = 105] = "dispidCreateDocumentMethod"; MethodDispId[MethodDispId["dispidInsertFormMethod"] = 106] = "dispidInsertFormMethod"; MethodDispId[MethodDispId["dispidDisplayRibbonCalloutAsyncMethod"] = 109] = "dispidDisplayRibbonCalloutAsyncMethod"; MethodDispId[MethodDispId["dispidGetSelectedTaskMethod"] = 110] = "dispidGetSelectedTaskMethod"; MethodDispId[MethodDispId["dispidGetSelectedResourceMethod"] = 111] = "dispidGetSelectedResourceMethod"; MethodDispId[MethodDispId["dispidGetTaskMethod"] = 112] = "dispidGetTaskMethod"; MethodDispId[MethodDispId["dispidGetResourceFieldMethod"] = 113] = "dispidGetResourceFieldMethod"; MethodDispId[MethodDispId["dispidGetWSSUrlMethod"] = 114] = "dispidGetWSSUrlMethod"; MethodDispId[MethodDispId["dispidGetTaskFieldMethod"] = 115] = "dispidGetTaskFieldMethod"; MethodDispId[MethodDispId["dispidGetProjectFieldMethod"] = 116] = "dispidGetProjectFieldMethod"; MethodDispId[MethodDispId["dispidGetSelectedViewMethod"] = 117] = "dispidGetSelectedViewMethod"; MethodDispId[MethodDispId["dispidGetTaskByIndexMethod"] = 118] = "dispidGetTaskByIndexMethod"; MethodDispId[MethodDispId["dispidGetResourceByIndexMethod"] = 119] = "dispidGetResourceByIndexMethod"; MethodDispId[MethodDispId["dispidSetTaskFieldMethod"] = 120] = "dispidSetTaskFieldMethod"; MethodDispId[MethodDispId["dispidSetResourceFieldMethod"] = 121] = "dispidSetResourceFieldMethod"; MethodDispId[MethodDispId["dispidGetMaxTaskIndexMethod"] = 122] = "dispidGetMaxTaskIndexMethod"; MethodDispId[MethodDispId["dispidGetMaxResourceIndexMethod"] = 123] = "dispidGetMaxResourceIndexMethod"; MethodDispId[MethodDispId["dispidCreateTaskMethod"] = 124] = "dispidCreateTaskMethod"; MethodDispId[MethodDispId["dispidAddDataPartMethod"] = 128] = "dispidAddDataPartMethod"; MethodDispId[MethodDispId["dispidGetDataPartByIdMethod"] = 129] = "dispidGetDataPartByIdMethod"; MethodDispId[MethodDispId["dispidGetDataPartsByNamespaceMethod"] = 130] = "dispidGetDataPartsByNamespaceMethod"; MethodDispId[MethodDispId["dispidGetDataPartXmlMethod"] = 131] = "dispidGetDataPartXmlMethod"; MethodDispId[MethodDispId["dispidGetDataPartNodesMethod"] = 132] = "dispidGetDataPartNodesMethod"; MethodDispId[MethodDispId["dispidDeleteDataPartMethod"] = 133] = "dispidDeleteDataPartMethod"; MethodDispId[MethodDispId["dispidGetDataNodeValueMethod"] = 134] = "dispidGetDataNodeValueMethod"; MethodDispId[MethodDispId["dispidGetDataNodeXmlMethod"] = 135] = "dispidGetDataNodeXmlMethod"; MethodDispId[MethodDispId["dispidGetDataNodesMethod"] = 136] = "dispidGetDataNodesMethod"; MethodDispId[MethodDispId["dispidSetDataNodeValueMethod"] = 137] = "dispidSetDataNodeValueMethod"; MethodDispId[MethodDispId["dispidSetDataNodeXmlMethod"] = 138] = "dispidSetDataNodeXmlMethod"; MethodDispId[MethodDispId["dispidAddDataNamespaceMethod"] = 139] = "dispidAddDataNamespaceMethod"; MethodDispId[MethodDispId["dispidGetDataUriByPrefixMethod"] = 140] = "dispidGetDataUriByPrefixMethod"; MethodDispId[MethodDispId["dispidGetDataPrefixByUriMethod"] = 141] = "dispidGetDataPrefixByUriMethod"; MethodDispId[MethodDispId["dispidGetDataNodeTextMethod"] = 142] = "dispidGetDataNodeTextMethod"; MethodDispId[MethodDispId["dispidSetDataNodeTextMethod"] = 143] = "dispidSetDataNodeTextMethod"; MethodDispId[MethodDispId["dispidMessageParentMethod"] = 144] = "dispidMessageParentMethod"; MethodDispId[MethodDispId["dispidSendMessageMethod"] = 145] = "dispidSendMessageMethod"; MethodDispId[MethodDispId["dispidExecuteFeature"] = 146] = "dispidExecuteFeature"; MethodDispId[MethodDispId["dispidQueryFeature"] = 147] = "dispidQueryFeature"; MethodDispId[MethodDispId["dispidMethodMax"] = 147] = "dispidMethodMax"; MethodDispId[MethodDispId["dispidGetNestedAppAuthContextMethod"] = 205] = "dispidGetNestedAppAuthContextMethod"; })(MethodDispId = DDA.MethodDispId || (DDA.MethodDispId = {})); DDA.getXdmEventName = function OSF_DDA$GetXdmEventName(id, eventType) { if (eventType == Microsoft.Office.WebExtension.EventType.BindingSelectionChanged || eventType == Microsoft.Office.WebExtension.EventType.BindingDataChanged || eventType == Microsoft.Office.WebExtension.EventType.DataNodeDeleted || eventType == Microsoft.Office.WebExtension.EventType.DataNodeInserted || eventType == Microsoft.Office.WebExtension.EventType.DataNodeReplaced) { return id + "_" + eventType; } else { return eventType; } }; let UI; (function (UI) { })(UI = DDA.UI || (DDA.UI = {})); let ListDescriptors; (function (ListDescriptors) { })(ListDescriptors = DDA.ListDescriptors || (DDA.ListDescriptors = {})); let EventDescriptors; (function (EventDescriptors) { })(EventDescriptors = DDA.EventDescriptors || (DDA.EventDescriptors = {})); let PropertyDescriptors; (function (PropertyDescriptors) { PropertyDescriptors["AsyncResultStatus"] = "AsyncResultStatus"; })(PropertyDescriptors = DDA.PropertyDescriptors || (DDA.PropertyDescriptors = {})); let DocumentMode; (function (DocumentMode) { DocumentMode[DocumentMode["ReadOnly"] = 1] = "ReadOnly"; DocumentMode[DocumentMode["ReadWrite"] = 0] = "ReadWrite"; })(DocumentMode = DDA.DocumentMode || (DDA.DocumentMode = {})); })(DDA = OSF.DDA || (OSF.DDA = {})); })(OSF || (OSF = {})); var Microsoft; (function (Microsoft) { let Office; (function (Office) { let WebExtension; (function (WebExtension) { let Parameters; (function (Parameters) { Parameters["BindingType"] = "bindingType"; Parameters["CoercionType"] = "coercionType"; Parameters["ValueFormat"] = "valueFormat"; Parameters["FilterType"] = "filterType"; Parameters["Columns"] = "columns"; Parameters["SampleData"] = "sampleData"; Parameters["GoToType"] = "goToType"; Parameters["SelectionMode"] = "selectionMode"; Parameters["Id"] = "id"; Parameters["PromptText"] = "promptText"; Parameters["ItemName"] = "itemName"; Parameters["FailOnCollision"] = "failOnCollision"; Parameters["StartRow"] = "startRow"; Parameters["StartColumn"] = "startColumn"; Parameters["RowCount"] = "rowCount"; Parameters["ColumnCount"] = "columnCount"; Parameters["Callback"] = "callback"; Parameters["AsyncContext"] = "asyncContext"; Parameters["Data"] = "data"; Parameters["Rows"] = "rows"; Parameters["OverwriteIfStale"] = "overwriteIfStale"; Parameters["FileType"] = "fileType"; Parameters["EventType"] = "eventType"; Parameters["Handler"] = "handler"; Parameters["SliceSize"] = "sliceSize"; Parameters["SliceIndex"] = "sliceIndex"; Parameters["ActiveView"] = "activeView"; Parameters["Status"] = "status"; Parameters["PlatformType"] = "platformType"; Parameters["HostType"] = "hostType"; Parameters["Email"] = "email"; Parameters["ForceConsent"] = "forceConsent"; Parameters["ForceAddAccount"] = "forceAddAccount"; Parameters["AuthChallenge"] = "authChallenge"; Parameters["AllowConsentPrompt"] = "allowConsentPrompt"; Parameters["ForMSGraphAccess"] = "forMSGraphAccess"; Parameters["AllowSignInPrompt"] = "allowSignInPrompt"; Parameters["JsonPayload"] = "jsonPayload"; Parameters["EnableNewHosts"] = "enableNewHosts"; Parameters["AccountTypeFilter"] = "accountTypeFilter"; Parameters["AddinTrustId"] = "addinTrustId"; Parameters["Reserved"] = "reserved"; Parameters["Tcid"] = "tcid"; Parameters["Xml"] = "xml"; Parameters["Namespace"] = "namespace"; Parameters["Prefix"] = "prefix"; Parameters["XPath"] = "xPath"; Parameters["Text"] = "text"; Parameters["ImageLeft"] = "imageLeft"; Parameters["ImageTop"] = "imageTop"; Parameters["ImageWidth"] = "imageWidth"; Parameters["ImageHeight"] = "imageHeight"; Parameters["TaskId"] = "taskId"; Parameters["FieldId"] = "fieldId"; Parameters["FieldValue"] = "fieldValue"; Parameters["ServerUrl"] = "serverUrl"; Parameters["ListName"] = "listName"; Parameters["ResourceId"] = "resourceId"; Parameters["ViewType"] = "viewType"; Parameters["ViewName"] = "viewName"; Parameters["GetRawValue"] = "getRawValue"; Parameters["CellFormat"] = "cellFormat"; Parameters["TableOptions"] = "tableOptions"; Parameters["TaskIndex"] = "taskIndex"; Parameters["ResourceIndex"] = "resourceIndex"; Parameters["CustomFieldId"] = "customFieldId"; Parameters["Url"] = "url"; Parameters["MessageHandler"] = "messageHandler"; Parameters["Width"] = "width"; Parameters["Height"] = "height"; Parameters["RequireHTTPs"] = "requireHTTPS"; Parameters["MessageToParent"] = "messageToParent"; Parameters["DisplayInIframe"] = "displayInIframe"; Parameters["MessageContent"] = "messageContent"; Parameters["TargetOrigin"] = "targetOrigin"; Parameters["HideTitle"] = "hideTitle"; Parameters["UseDeviceIndependentPixels"] = "useDeviceIndependentPixels"; Parameters["PromptBeforeOpen"] = "promptBeforeOpen"; Parameters["EnforceAppDomain"] = "enforceAppDomain"; Parameters["UrlNoHostInfo"] = "urlNoHostInfo"; Parameters["Targetorigin"] = "targetOrigin"; Parameters["AppCommandInvocationCompletedData"] = "appCommandInvocationCompletedData"; Parameters["Base64"] = "base64"; Parameters["FormId"] = "formId"; })(Parameters = WebExtension.Parameters || (WebExtension.Parameters = {})); let FilterType; (function (FilterType) { FilterType["All"] = "all"; })(FilterType = WebExtension.FilterType || (WebExtension.FilterType = {})); let ValueFormat; (function (ValueFormat) { ValueFormat["Unformatted"] = "unformatted"; ValueFormat["Formatted"] = "formatted"; })(ValueFormat = WebExtension.ValueFormat || (WebExtension.ValueFormat = {})); let InitializationReason; (function (InitializationReason) { InitializationReason["Inserted"] = "inserted"; InitializationReason["DocumentOpened"] = "documentOpened"; InitializationReason["ControlActivation"] = "controlActivation"; })(InitializationReason = WebExtension.InitializationReason || (WebExtension.InitializationReason = {})); })(WebExtension = Office.WebExtension || (Office.WebExtension = {})); })(Office = Microsoft.Office || (Microsoft.Office = {})); })(Microsoft || (Microsoft = {})); var _serviceEndPoint = null; var _defaultRefreshRate = 3; var _msPerDay = 86400000; var _defaultTimeout = 60000; var _officeVersionHeader = "X-Office-Version"; var _hourToDayConversionFactor = 24; var _buildParameter = "&build="; var _expectedVersionParameter = "&expver="; var _queryStringParameters = { clientName: "client", clientVersion: "cv" }; var statusCode = { Succeeded: 1, Failed: 0 }; var _spUpn = null; function _sendWebRequest(url, verb, headers, onCompleted, context, body) { context = context || {}; var webRequest = new Sys.Net.WebRequest(); for (var p in headers) { webRequest.get_headers()[p] = headers[p]; } if (context) { if (context.officeVersion) { webRequest.get_headers()[_officeVersionHeader] = context.officeVersion; } if (context.correlationId && url.indexOf('?') > -1) { url += "&corr=" + context.correlationId; } } if (body) { webRequest.set_body(body); } webRequest.set_url(url); webRequest.set_httpVerb(verb); webRequest.set_timeout(_defaultTimeout); webRequest.set_userContext(context); webRequest.add_completed(onCompleted); webRequest.invoke(); } ; function _onCompleted(executor, eventArgs) { var context = executor.get_webRequest().get_userContext(); var url = executor.get_webRequest().get_url(); if (executor.get_timedOut()) { OsfMsAjaxFactory.msAjaxDebug.trace("Request timed out: " + url); _invokeCallbackTag(context.callback, statusCode.Failed, null, null, executor, 0x0085a2c3); } else if (executor.get_aborted()) { OsfMsAjaxFactory.msAjaxDebug.trace("Request aborted: " + url); _invokeCallbackTag(context.callback, statusCode.Failed, null, null, executor, 0x0085a2c4); } else if (executor.get_responseAvailable()) { if (executor.get_statusCode() == 200) { try { context._onCompleteHandler(executor, eventArgs); } catch (ex) { OsfMsAjaxFactory.msAjaxDebug.trace("Request failed with exception " + ex + ": " + url); _invokeCallbackTag(context.callback, statusCode.Failed, ex, null, executor, 0x0085a2c5); } } else { var statusText = executor.get_statusText(); OsfMsAjaxFactory.msAjaxDebug.trace("Request failed with status code " + statusText + ": " + url); _invokeCallbackTag(context.callback, statusCode.Failed, statusText, null, executor, 0x0085a2c6); } } else { OsfMsAjaxFactory.msAjaxDebug.trace("Request failed: " + url); _invokeCallbackTag(context.callback, statusCode.Failed, statusText, null, executor, 0x0085a2c7); } } ; function _isProxyReady(params, callback) { if (callback) { callback({ "status": statusCode.Succeeded, "result": true }); } } ; function _createQueryStringFragment(paramDictionary) { var queryString = ""; for (var param in paramDictionary) { var value = paramDictionary[param]; if (value === null || value === undefined || value === "") { continue; } queryString += '&' + encodeURIComponent(param) + '=' + encodeURIComponent(value); } return queryString; } ; var Mos; (function (Mos) { class AcquisitionList { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.acquisitions = []; } } init(_data) { if (_data) { if (Array.isArray(_data["acquisitions"])) { this.acquisitions = []; for (let item of _data["acquisitions"]) this.acquisitions.push(Acquisition.fromJS(item)); } this.syncKey = _data["syncKey"]; this.nextInterval = _data["nextInterval"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new AcquisitionList(); result.init(data); return result; } push(data) { this.acquisitions.push(...data.acquisitions); this.syncKey = data.syncKey; this.nextInterval = data.nextInterval; } toJSON(data) { data = typeof data === 'object' ? data : {}; if (Array.isArray(this.acquisitions)) { data["acquisitions"] = []; for (let item of this.acquisitions) data["acquisitions"].push(item.toJSON()); } data["syncKey"] = this.syncKey; data["nextInterval"] = this.nextInterval; return data; } } Mos.AcquisitionList = AcquisitionList; class Acquisition { static getStoreType(acquisition) { var _a; if ((acquisition === null || acquisition === void 0 ? void 0 : acquisition.acquisitionContext) && ((_a = acquisition === null || acquisition === void 0 ? void 0 : acquisition.titleDefinition) === null || _a === void 0 ? void 0 : _a.scope)) { const scope = acquisition.titleDefinition.scope.toLowerCase(); const context = acquisition.acquisitionContext.toLowerCase(); if (context === "user" && scope === "public") { return OSF.StoreType.OMEX; } else if (context === "tenant") { return OSF.StoreType.PrivateCatalog; } else if (context === "user") { return OSF.StoreType.UploadFileDevCatalog; } } return undefined; } constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.titleDefinition = new TitleDefinition(); } } init(_data) { if (_data) { this.titleId = _data["titleId"]; this.assetId = _data["assetId"]; this.manifestId = _data["manifestId"]; this.titleDefinition = _data["titleDefinition"] ? TitleDefinition.fromJS(_data["titleDefinition"]) : new TitleDefinition(); this.acquisitionState = _data["acquisitionState"]; this.acquisitionContext = _data["acquisitionContext"]; this.canBeUnacquired = _data["canBeUnacquired"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Acquisition(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["titleId"] = this.titleId; data["assetId"] = this.assetId; data["manifestId"] = this.manifestId; data["titleDefinition"] = this.titleDefinition ? this.titleDefinition.toJSON() : undefined; data["acquisitionState"] = this.acquisitionState; data["acquisitionContext"] = this.acquisitionContext; data["canBeUnacquired"] = this.canBeUnacquired; return data; } } Mos.Acquisition = Acquisition; class TitleDefinition { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.iconSmall = new IconSmall(); this.elementDefinitions = new ElementDefinitions(); } } init(_data) { if (_data) { this.name = _data["name"]; this.iconSmall = _data["iconSmall"] ? IconSmall.fromJS(_data["iconSmall"]) : new IconSmall(); this.version = _data["version"]; this.elementDefinitions = _data["elementDefinitions"] ? ElementDefinitions.fromJS(_data["elementDefinitions"]) : new ElementDefinitions(); this.ingestionSource = _data["ingestionSource"]; this.scope = _data["scope"]; this.developerName = _data["developerName"]; this.shortDescription = _data["shortDescription"]; if (Array.isArray(_data["validDomains"])) { this.validDomains = []; for (let item of _data["validDomains"]) this.validDomains.push(item); } this.webApplicationInfo = _data["webApplicationInfo"] ? WebApplicationInfo.fromJS(_data["webApplicationInfo"]) : undefined; this.authorization = _data["authorization"] ? Authorization.fromJS(_data["authorization"]) : undefined; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new TitleDefinition(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["name"] = this.name; data["iconSmall"] = this.iconSmall ? this.iconSmall.toJSON() : undefined; data["version"] = this.version; data["elementDefinitions"] = this.elementDefinitions ? this.elementDefinitions.toJSON() : undefined; data["ingestionSource"] = this.ingestionSource; data["scope"] = this.scope; data["developerName"] = this.developerName; data["shortDescription"] = this.shortDescription; if (Array.isArray(this.validDomains)) { data["validDomains"] = []; for (let item of this.validDomains) data["validDomains"].push(item); } data["webApplicationInfo"] = this.webApplicationInfo ? this.webApplicationInfo.toJSON() : undefined; data["authorization"] = this.authorization ? this.authorization.toJSON() : undefined; return data; } } Mos.TitleDefinition = TitleDefinition; class IconSmall { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.uri = _data["uri"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new IconSmall(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["uri"] = this.uri; return data; } } Mos.IconSmall = IconSmall; class ElementDefinitions { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { if (Array.isArray(_data["officeAddIns"])) { this.officeAddIns = []; for (let item of _data["officeAddIns"]) this.officeAddIns.push(OfficeAddIn.fromJS(item)); } if (Array.isArray(_data["extensions"])) { this.extensions = []; for (let item of _data["extensions"]) this.extensions.push(Extension.fromJS(item)); } if (Array.isArray(_data["firstPartyPages"])) { this.firstPartyPages = []; for (let item of _data["firstPartyPages"]) this.firstPartyPages.push(FirstPartyPages.fromJS(item)); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new ElementDefinitions(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; if (Array.isArray(this.officeAddIns)) { data["officeAddIns"] = []; for (let item of this.officeAddIns) data["officeAddIns"].push(item.toJSON()); } if (Array.isArray(this.extensions)) { data["extensions"] = []; for (let item of this.extensions) data["extensions"].push(item.toJSON()); } if (Array.isArray(this.firstPartyPages)) { data["firstPartyPages"] = []; for (let item of this.firstPartyPages) data["firstPartyPages"].push(item.toJSON()); } return data; } } Mos.ElementDefinitions = ElementDefinitions; class WebApplicationInfo { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.id = _data["id"]; this.resource = _data["resource"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new WebApplicationInfo(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["id"] = this.id; data["resource"] = this.resource; return data; } } Mos.WebApplicationInfo = WebApplicationInfo; class Authorization { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.permissions = _data["permissions"] ? Permissions.fromJS(_data["permissions"]) : undefined; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Authorization(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["permissions"] = this.permissions ? this.permissions.toJSON() : undefined; return data; } } Mos.Authorization = Authorization; class OfficeAddIn { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.xmlDefinition = _data["xmlDefinition"]; this.name = _data["name"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new OfficeAddIn(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["xmlDefinition"] = this.xmlDefinition; data["name"] = this.name; return data; } } Mos.OfficeAddIn = OfficeAddIn; class Extension { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.getStartedMessages = []; this.runtimes = []; this.shortcuts = []; this.autoRunEvents = []; } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; if (Array.isArray(_data["getStartedMessages"])) { this.getStartedMessages = []; for (let item of _data["getStartedMessages"]) this.getStartedMessages.push(GetStartedMessages.fromJS(item)); } if (Array.isArray(_data["runtimes"])) { this.runtimes = []; for (let item of _data["runtimes"]) this.runtimes.push(Runtimes.fromJS(item)); } if (Array.isArray(_data["ribbons"])) { this.ribbons = []; for (let item of _data["ribbons"]) this.ribbons.push(Ribbons.fromJS(item)); } if (Array.isArray(_data["shortcuts"])) { this.shortcuts = []; for (let item of _data["shortcuts"]) this.shortcuts.push(Shortcuts.fromJS(item)); } if (Array.isArray(_data["autoRunEvents"])) { this.autoRunEvents = []; for (let item of _data["autoRunEvents"]) this.autoRunEvents.push(AutoRunEvents.fromJS(item)); } if (Array.isArray(_data["contextMenus"])) { this.contextMenus = []; for (let item of _data["contextMenus"]) this.contextMenus.push(ContextMenus.fromJS(item)); } if (Array.isArray(_data["alternatives"])) { this.alternatives = []; for (let item of _data["alternatives"]) this.alternatives.push(Alternatives.fromJS(item)); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Extension(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; if (Array.isArray(this.getStartedMessages)) { data["getStartedMessages"] = []; for (let item of this.getStartedMessages) data["getStartedMessages"].push(item.toJSON()); } if (Array.isArray(this.runtimes)) { data["runtimes"] = []; for (let item of this.runtimes) data["runtimes"].push(item.toJSON()); } if (Array.isArray(this.ribbons)) { data["ribbons"] = []; for (let item of this.ribbons) data["ribbons"].push(item.toJSON()); } if (Array.isArray(this.shortcuts)) { data["shortcuts"] = []; for (let item of this.shortcuts) data["shortcuts"].push(item.toJSON()); } if (Array.isArray(this.autoRunEvents)) { data["autoRunEvents"] = []; for (let item of this.autoRunEvents) data["autoRunEvents"].push(item.toJSON()); } if (Array.isArray(this.contextMenus)) { data["contextMenus"] = []; for (let item of this.contextMenus) data["contextMenus"].push(item.toJSON()); } if (Array.isArray(this.alternatives)) { data["alternatives"] = []; for (let item of this.alternatives) data["alternatives"].push(item.toJSON()); } return data; } } Mos.Extension = Extension; class FirstPartyPages { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.id = _data["Id"]; this.title = _data["Title"]; this.subtitle = _data["Subtitle"]; this.alternateNames = _data["AlternateNames"]; this.brandBarText = _data["BrandBarText"]; this.ariaLabel = _data["AriaLabel"]; this.publisher = _data["Publisher"]; this.iconAnonymousUrl = _data["IconAnonymousUrl"]; this.targetWindow = _data["TargetWindow"]; this.backgroundColor = _data["BackgroundColor"]; this.launchFullUrl = _data["LaunchFullUrl"]; this.name = _data["name"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new FirstPartyPages(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["Id"] = this.id; data["Title"] = this.title; data["Subtitle"] = this.subtitle; data["AlternateNames"] = this.alternateNames; data["BrandBarText"] = this.brandBarText; data["AriaLabel"] = this.ariaLabel; data["Publisher"] = this.publisher; data["IconAnonymousUrl"] = this.iconAnonymousUrl; data["TargetWindow"] = this.targetWindow; data["BackgroundColor"] = this.backgroundColor; data["LaunchFullUrl"] = this.launchFullUrl; data["name"] = this.name; return data; } } Mos.FirstPartyPages = FirstPartyPages; class Permissions { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { if (Array.isArray(_data["orgWide"])) { this.orgWide = []; for (let item of _data["orgWide"]) this.orgWide.push(OrgWide.fromJS(item)); } if (Array.isArray(_data["resourceSpecific"])) { this.resourceSpecific = []; for (let item of _data["resourceSpecific"]) this.resourceSpecific.push(ResourceSpecific.fromJS(item)); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Permissions(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; if (Array.isArray(this.orgWide)) { data["orgWide"] = []; for (let item of this.orgWide) data["orgWide"].push(item.toJSON()); } if (Array.isArray(this.resourceSpecific)) { data["resourceSpecific"] = []; for (let item of this.resourceSpecific) data["resourceSpecific"].push(item.toJSON()); } return data; } } Mos.Permissions = Permissions; class Requirements { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { if (Array.isArray(_data["scopes"])) { this.scopes = []; for (let item of _data["scopes"]) this.scopes.push(item); } if (Array.isArray(_data["capabilities"])) { this.capabilities = []; for (let item of _data["capabilities"]) this.capabilities.push(Capabilities.fromJS(item)); } if (Array.isArray(_data["platforms"])) { this.platforms = []; for (let item of _data["platforms"]) this.platforms.push(item); } if (Array.isArray(_data["formFactors"])) { this.formFactors = []; for (let item of _data["formFactors"]) this.formFactors.push(item); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Requirements(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; if (Array.isArray(this.scopes)) { data["scopes"] = []; for (let item of this.scopes) data["scopes"].push(item); } if (Array.isArray(this.capabilities)) { data["capabilities"] = []; for (let item of this.capabilities) data["capabilities"].push(item.toJSON()); } if (Array.isArray(this.platforms)) { data["platforms"] = []; for (let item of this.platforms) data["platforms"].push(item); } if (Array.isArray(this.formFactors)) { data["formFactors"] = []; for (let item of this.formFactors) data["formFactors"].push(item); } return data; } } Mos.Requirements = Requirements; class GetStartedMessages { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; this.title = _data["title"]; this.description = _data["description"]; this.learnMoreUrl = _data["learnMoreUrl"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new GetStartedMessages(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; data["title"] = this.title; data["description"] = this.description; data["learnMoreUrl"] = this.learnMoreUrl; return data; } } Mos.GetStartedMessages = GetStartedMessages; class Runtimes { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.code = new Code(); this.actions = []; this.functions = []; this.functionSettings = new FunctionSettings(); } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; this.id = _data["id"]; this.type = _data["type"]; this.code = _data["code"] ? Code.fromJS(_data["code"]) : new Code(); this.lifetime = _data["lifetime"]; if (Array.isArray(_data["actions"])) { this.actions = []; for (let action of _data["actions"]) this.actions.push(Actions.fromJS(action)); } if (Array.isArray(_data["functions"])) { this.functions = []; for (let item of _data["functions"]) this.functions.push(item); } this.functionSettings = _data["functionSettings"] ? FunctionSettings.fromJS(_data["functionSettings"]) : new FunctionSettings(); } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Runtimes(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; data["id"] = this.id; data["type"] = this.type; data["code"] = this.code ? this.code.toJSON() : undefined; data["lifetime"] = this.lifetime; if (Array.isArray(this.actions)) { data["actions"] = []; for (let action of this.actions) data["actions"].push(action.toJSON()); } if (Array.isArray(this.functions)) { data["functions"] = []; for (let item of this.functions) data["functions"].push(item.toJSON()); } data["functionSettings"] = this.functionSettings ? this.functionSettings.toJSON() : undefined; return data; } } Mos.Runtimes = Runtimes; class Ribbons { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.tabs = []; } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; if (Array.isArray(_data["contexts"])) { this.contexts = []; for (let item of _data["contexts"]) this.contexts.push(item); } if (Array.isArray(_data["tabs"])) { this.tabs = []; for (let item of _data["tabs"]) this.tabs.push(Tabs.fromJS(item)); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Ribbons(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; if (Array.isArray(this.contexts)) { data["contexts"] = []; for (let item of this.contexts) data["contexts"].push(item); } if (Array.isArray(this.tabs)) { data["tabs"] = []; for (let item of this.tabs) data["tabs"].push(item.toJSON()); } return data; } } Mos.Ribbons = Ribbons; class Shortcuts { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.keys = []; } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; if (Array.isArray(_data["keys"])) { this.keys = []; for (let item of _data["keys"]) this.keys.push(Keys.fromJS(item)); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Shortcuts(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; if (Array.isArray(this.keys)) { data["shortcuts"] = []; for (let item of this.keys) data["shortcuts"].push(item.toJSON()); } return data; } } Mos.Shortcuts = Shortcuts; class AutoRunEvents { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.events = []; } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; if (Array.isArray(_data["events"])) { this.events = []; for (let item of _data["events"]) this.events.push(Events.fromJS(item)); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new AutoRunEvents(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; if (Array.isArray(this.events)) { data["events"] = []; for (let item of this.events) data["events"].push(item.toJSON()); } return data; } } Mos.AutoRunEvents = AutoRunEvents; class ContextMenus { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.menus = []; } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; if (Array.isArray(_data["menus"])) { this.menus = []; for (let item of _data["menus"]) this.menus.push(Menus.fromJS(item)); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new ContextMenus(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; if (Array.isArray(this.menus)) { data["menus"] = []; for (let item of this.menus) data["menus"].push(item.toJSON()); } return data; } } Mos.ContextMenus = ContextMenus; class Alternatives { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; this.prefer = _data["prefer"]; this.hide = _data["hide"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Alternatives(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; data["prefer"] = this.prefer; data["hide"] = this.hide; return data; } } Mos.Alternatives = Alternatives; class Subtitle { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Subtitle(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; return data; } } Mos.Subtitle = Subtitle; class AlternateNames { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new AlternateNames(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; return data; } } Mos.AlternateNames = AlternateNames; class BrandBarText { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new BrandBarText(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; return data; } } Mos.BrandBarText = BrandBarText; class TargetWindow { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new TargetWindow(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; return data; } } Mos.TargetWindow = TargetWindow; class OrgWide { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.name = _data["name"]; this.type = _data["type"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new OrgWide(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["name"] = this.name; data["type"] = this.type; return data; } } Mos.OrgWide = OrgWide; class ResourceSpecific { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.name = _data["name"]; this.type = _data["type"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new ResourceSpecific(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["name"] = this.name; data["type"] = this.type; return data; } } Mos.ResourceSpecific = ResourceSpecific; let Scopes; (function (Scopes) { Scopes["Mail"] = "mail"; Scopes["Workbook"] = "workbook"; Scopes["Document"] = "document"; Scopes["Presentation"] = "presentation"; })(Scopes = Mos.Scopes || (Mos.Scopes = {})); class Capabilities { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.name = _data["name"]; this.minVersion = _data["minVersion"]; this.maxVersion = _data["maxVersion"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Capabilities(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["name"] = this.name; data["minVersion"] = this.minVersion; data["maxVersion"] = this.maxVersion; return data; } } Mos.Capabilities = Capabilities; let Platforms; (function (Platforms) { Platforms["Windows"] = "windows"; Platforms["Mac"] = "mac"; Platforms["Web"] = "web"; Platforms["Ios"] = "ios"; Platforms["Android"] = "android"; })(Platforms = Mos.Platforms || (Mos.Platforms = {})); let FormFactors; (function (FormFactors) { FormFactors["Desktop"] = "desktop"; FormFactors["Tablet"] = "tablet"; FormFactors["Phone"] = "phone"; })(FormFactors = Mos.FormFactors || (Mos.FormFactors = {})); class Code { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.page = _data["page"]; this.script = _data["script"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Code(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["page"] = this.page; data["script"] = this.script; return data; } } Mos.Code = Code; class Actions { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.id = _data["id"]; this.type = _data["type"]; this.displayName = _data["displayName"]; this.view = _data["view"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Actions(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["id"] = this.id; data["type"] = this.type; data["displayName"] = this.displayName; data["view"] = this.view; return data; } } Mos.Actions = Actions; class Functions { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.result = new Result(); this.parameters = []; } } init(_data) { if (_data) { this.id = _data["id"]; this.name = _data["name"]; this.description = _data["description"]; if (Array.isArray(_data["parameters"])) { this.parameters = []; for (let item of _data["parameters"]) this.parameters.push(Parameters.fromJS(item)); } this.result = _data["result"] ? Result.fromJS(_data["result"]) : new Result(); this.stream = _data["stream"]; this.volatile = _data["volatile"]; this.cancelable = _data["cancelable"]; this.requiresAddress = _data["requiresAddress"]; this.requiresParameterAddress = _data["requiresParameterAddress"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Functions(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["id"] = this.id; data["name"] = this.name; data["description"] = this.description; if (Array.isArray(this.parameters)) { data["parameters"] = []; for (let item of this.parameters) data["parameters"].push(item.toJSON()); } data["result"] = this.result ? this.result.toJSON() : undefined; data["stream"] = this.stream; data["volatile"] = this.volatile; data["cancelable"] = this.cancelable; data["requiresAddress"] = this.requiresAddress; data["requiresParameterAddress"] = this.requiresParameterAddress; return data; } } Mos.Functions = Functions; class FunctionSettings { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.namespace = new Namespace(); } } init(_data) { if (_data) { this.namespace = _data["namespace"] ? Namespace.fromJS(_data["namespace"]) : new Namespace(); this.allowErrorForDataTypeAny = _data["allowErrorForDataTypeAny"]; this.allowRichDataForDataTypeAny = _data["allowRichDataForDataTypeAny"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new FunctionSettings(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["namespace"] = this.namespace ? this.namespace.toJSON() : undefined; data["allowErrorForDataTypeAny"] = this.allowErrorForDataTypeAny; data["allowRichDataForDataTypeAny"] = this.allowRichDataForDataTypeAny; return data; } } Mos.FunctionSettings = FunctionSettings; let Contexts; (function (Contexts) { Contexts["Default"] = "default"; Contexts["ReadMail"] = "readMail"; Contexts["ComposeMail"] = "composeMail"; Contexts["AppointmentOrganizer"] = "appointmentOrganizer"; Contexts["AppointmentAttendee"] = "appointmentAttendee"; })(Contexts = Mos.Contexts || (Mos.Contexts = {})); class Tabs { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.groups = []; } } init(_data) { if (_data) { this.builtInTabId = _data["builtInTabId"]; this.id = _data["id"]; this.label = _data["label"]; this.position = _data["position"] ? Position.fromJS(_data["position"]) : undefined; if (Array.isArray(_data["groups"])) { this.groups = []; for (let item of _data["groups"]) this.groups.push(Groups.fromJS(item)); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Tabs(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["builtInTabId"] = this.builtInTabId; data["id"] = this.id; data["label"] = this.label; data["position"] = this.position ? this.position.toJSON() : undefined; if (Array.isArray(this.groups)) { data["groups"] = []; for (let item of this.groups) data["groups"].push(item.toJSON()); } return data; } } Mos.Tabs = Tabs; class Keys { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; this.key = _data["key"] ? Key.fromJS(_data["key"]) : undefined; this.actionId = _data["actionId"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Keys(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; data["key"] = this.key ? this.key.toJSON() : undefined; data["actionId"] = this.actionId; return data; } } Mos.Keys = Keys; class Key { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.defaultKey = _data["default"]; this.windows = _data["windows"]; this.mac = _data["mac"]; this.web = _data["web"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Key(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["default"] = this.defaultKey; data["windows"] = this.windows; data["mac"] = this.mac; data["web"] = this.web; return data; } } Mos.Key = Key; class Events { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.options = new Options(); } } init(_data) { if (_data) { this.requirements = _data["requirements"] ? Requirements.fromJS(_data["requirements"]) : undefined; this.id = _data["id"]; this.actionId = _data["actionId"]; this.options = _data["options"] ? Options.fromJS(_data["options"]) : new Options(); } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Events(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["requirements"] = this.requirements ? this.requirements.toJSON() : undefined; data["id"] = this.id; data["actionId"] = this.actionId; data["options"] = this.options ? this.options.toJSON() : undefined; return data; } } Mos.Events = Events; class Menus { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.controls = []; } } init(_data) { if (_data) { this.type = _data["type"]; if (Array.isArray(_data["controls"])) { this.controls = []; for (let item of _data["controls"]) this.controls.push(item); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Menus(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["type"] = this.type; if (Array.isArray(this.controls)) { data["controls"] = []; for (let item of this.controls) data["controls"].push(item); } return data; } } Mos.Menus = Menus; let OrgWideType; (function (OrgWideType) { OrgWideType["Application"] = "Application"; OrgWideType["Delegated"] = "Delegated"; })(OrgWideType = Mos.OrgWideType || (Mos.OrgWideType = {})); let ResourceSpecificType; (function (ResourceSpecificType) { ResourceSpecificType["Application"] = "Application"; ResourceSpecificType["Delegated"] = "Delegated"; })(ResourceSpecificType = Mos.ResourceSpecificType || (Mos.ResourceSpecificType = {})); class Namespace { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.id = _data["id"]; this.name = _data["name"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Namespace(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["id"] = this.id; data["name"] = this.name; return data; } } Mos.Namespace = Namespace; class Position { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.builtInTabId = _data["builtInTabId"]; this.align = _data["align"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Position(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["builtInTabId"] = this.builtInTabId; data["align"] = this.align; return data; } } Mos.Position = Position; class Groups { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.overriddenByRibbonApi = false; this.controls = []; } } init(_data) { if (_data) { this.overriddenByRibbonApi = _data["overriddenByRibbonApi"] !== undefined ? _data["overriddenByRibbonApi"] : false; this.builtInGroupId = _data["builtInGroupId"]; this.id = _data["id"]; this.label = _data["label"]; if (Array.isArray(_data["icons"])) { this.icons = []; for (let item of _data["icons"]) this.icons.push(Icons.fromJS(item)); } if (Array.isArray(_data["controls"])) { this.controls = []; for (let item of _data["controls"]) this.controls.push(Controls.fromJS(item)); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Groups(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["overriddenByRibbonApi"] = this.overriddenByRibbonApi; data["builtInGroupId"] = this.builtInGroupId; data["id"] = this.id; data["label"] = this.label; if (Array.isArray(this.icons)) { data["icons"] = []; for (let item of this.icons) data["icons"].push(item.toJSON()); } if (Array.isArray(this.controls)) { data["controls"] = []; for (let item of this.controls) data["controls"].push(item.toJSON()); } return data; } } Mos.Groups = Groups; class Options { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.sendMode = _data["sendMode"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Options(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["sendMode"] = this.sendMode; return data; } } Mos.Options = Options; let MenusType; (function (MenusType) { MenusType["Cell"] = "cell"; MenusType["Text"] = "text"; })(MenusType = Mos.MenusType || (Mos.MenusType = {})); class Parameters { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.name = _data["name"]; this.description = _data["description"]; this.type = _data["type"]; this.dimensionality = _data["dimensionality"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Parameters(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["name"] = this.name; data["description"] = this.description; data["type"] = this.type; data["dimensionality"] = this.dimensionality; return data; } } Mos.Parameters = Parameters; class Result { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.dimensionality = _data["dimensionality"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Result(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["dimensionality"] = this.dimensionality; return data; } } Mos.Result = Result; let PositionAlign; (function (PositionAlign) { PositionAlign["After"] = "after"; PositionAlign["Before"] = "before"; })(PositionAlign = Mos.PositionAlign || (Mos.PositionAlign = {})); class Icons { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.size = _data["size"]; this.file = _data["file"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Icons(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["size"] = this.size; data["file"] = this.file; return data; } } Mos.Icons = Icons; class Controls { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } if (!data) { this.overriddenByRibbonApi = false; this.enabled = true; this.icons = []; this.supertip = new Supertip(); } } init(_data) { if (_data) { this.overriddenByRibbonApi = _data["overriddenByRibbonApi"] !== undefined ? _data["overriddenByRibbonApi"] : false; this.builtInControlId = _data["builtInControlId"]; this.id = _data["id"]; this.type = _data["type"]; this.label = _data["label"]; this.enabled = _data["enabled"] !== undefined ? _data["enabled"] : true; if (Array.isArray(_data["icons"])) { this.icons = []; for (let item of _data["icons"]) this.icons.push(Icons.fromJS(item)); } this.supertip = _data["supertip"] ? Supertip.fromJS(_data["supertip"]) : new Supertip(); this.actionId = _data["actionId"]; if (Array.isArray(_data["items"])) { this.items = []; for (let item of _data["items"]) this.items.push(Controls.fromJS((item))); } } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Controls(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["overriddenByRibbonApi"] = this.overriddenByRibbonApi; data["builtInControlId"] = this.builtInControlId; data["id"] = this.id; data["type"] = this.type; data["label"] = this.label; data["enabled"] = this.enabled; if (Array.isArray(this.icons)) { data["icons"] = []; for (let item of this.icons) data["icons"].push(item.toJSON()); } data["supertip"] = this.supertip ? this.supertip.toJSON() : undefined; data["actionId"] = this.actionId; if (Array.isArray(this.items)) { data["items"] = []; for (let item of this.items) data["items"].push(item.toJSON()); } return data; } } Mos.Controls = Controls; let ControlsType; (function (ControlsType) { ControlsType["Button"] = "button"; ControlsType["Menu"] = "menu"; })(ControlsType = Mos.ControlsType || (Mos.ControlsType = {})); class Supertip { constructor(data) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) this[property] = data[property]; } } } init(_data) { if (_data) { this.title = _data["title"]; this.description = _data["description"]; } } static fromJS(data) { data = typeof data === 'object' ? data : {}; let result = new Supertip(); result.init(data); return result; } toJSON(data) { data = typeof data === 'object' ? data : {}; data["title"] = this.title; data["description"] = this.description; return data; } } Mos.Supertip = Supertip; })(Mos || (Mos = {})); var OSF; (function (OSF) { let ExtendedManifestSupportTokens; (function (ExtendedManifestSupportTokens) { ExtendedManifestSupportTokens["Requirements"] = "RequirementsToken"; ExtendedManifestSupportTokens["Locale"] = "LocaleToken"; ExtendedManifestSupportTokens["TokenReplaceRegex"] = "\\$\\{token\\.(\\w+)\\}"; ExtendedManifestSupportTokens["ResourceTokenRegEx"] = "^\\$\\{resource\\.([A-Za-z0-9_-]+)\\}$"; ExtendedManifestSupportTokens["ExtendedManifestLoggingPrefix"] = "Extended Manifest"; ExtendedManifestSupportTokens["ExtendedManifestResourcesLoggingPrefix"] = "Extended Manifest Resources"; ExtendedManifestSupportTokens[ExtendedManifestSupportTokens["ActionIdMaxLength"] = 32] = "ActionIdMaxLength"; ExtendedManifestSupportTokens[ExtendedManifestSupportTokens["ActionNameMaxLength"] = 125] = "ActionNameMaxLength"; })(ExtendedManifestSupportTokens = OSF.ExtendedManifestSupportTokens || (OSF.ExtendedManifestSupportTokens = {})); let SdxAssetIds; (function (SdxAssetIds) { SdxAssetIds["Ideas"] = "fa000000029"; SdxAssetIds["ExperimentationSdx"] = "fa000000059"; SdxAssetIds["CopilotChatExcel"] = "fa000000124"; SdxAssetIds["CopilotChatWord"] = "fa000000125"; SdxAssetIds["CopilotChatOneNote"] = "fa000000128"; SdxAssetIds["CopilotChatPpt"] = "fa000000129"; })(SdxAssetIds = OSF.SdxAssetIds || (OSF.SdxAssetIds = {})); OSF.DefaultAllowDisplayCaptureSdxIds = [ SdxAssetIds.CopilotChatExcel, SdxAssetIds.CopilotChatWord, SdxAssetIds.CopilotChatOneNote, SdxAssetIds.CopilotChatPpt, ].join(';'); let HostFeatureGateFlags; (function (HostFeatureGateFlags) { HostFeatureGateFlags[HostFeatureGateFlags["None"] = 0] = "None"; HostFeatureGateFlags[HostFeatureGateFlags["Enable3rdPartySetAppContextInIFrameName"] = 2] = "Enable3rdPartySetAppContextInIFrameName"; })(HostFeatureGateFlags = OSF.HostFeatureGateFlags || (OSF.HostFeatureGateFlags = {})); OSF.MaxAppContextLength = 10240; let HostInfoFlags; (function (HostInfoFlags) { HostInfoFlags[HostInfoFlags["None"] = 0] = "None"; HostInfoFlags[HostInfoFlags["SharedApp"] = 1] = "SharedApp"; HostInfoFlags[HostInfoFlags["CustomFunction"] = 2] = "CustomFunction"; HostInfoFlags[HostInfoFlags["ProtectedDocDisable"] = 4] = "ProtectedDocDisable"; HostInfoFlags[HostInfoFlags["ExperimentJsEnabled"] = 8] = "ExperimentJsEnabled"; HostInfoFlags[HostInfoFlags["PublicAddin"] = 16] = "PublicAddin"; HostInfoFlags[HostInfoFlags["IsMos"] = 64] = "IsMos"; HostInfoFlags[HostInfoFlags["IsMonarch"] = 128] = "IsMonarch"; })(HostInfoFlags = OSF.HostInfoFlags || (OSF.HostInfoFlags = {})); let ManifestRequestTypes; (function (ManifestRequestTypes) { ManifestRequestTypes[ManifestRequestTypes["Manifest"] = 1] = "Manifest"; ManifestRequestTypes[ManifestRequestTypes["Etoken"] = 2] = "Etoken"; ManifestRequestTypes[ManifestRequestTypes["Both"] = 3] = "Both"; })(ManifestRequestTypes = OSF.ManifestRequestTypes || (OSF.ManifestRequestTypes = {})); let ActivationTypes; (function (ActivationTypes) { ActivationTypes[ActivationTypes["V1Enabled"] = 0] = "V1Enabled"; ActivationTypes[ActivationTypes["V1S2SEnabled"] = 1] = "V1S2SEnabled"; ActivationTypes[ActivationTypes["V2Enabled"] = 2] = "V2Enabled"; ActivationTypes[ActivationTypes["V2S2SEnabled"] = 3] = "V2S2SEnabled"; })(ActivationTypes = OSF.ActivationTypes || (OSF.ActivationTypes = {})); let InvokeResultCode; (function (InvokeResultCode) { InvokeResultCode[InvokeResultCode["S_OK"] = 0] = "S_OK"; InvokeResultCode[InvokeResultCode["E_REQUEST_TIME_OUT"] = -2147471590] = "E_REQUEST_TIME_OUT"; InvokeResultCode[InvokeResultCode["E_USER_NOT_SIGNED_IN"] = -2147208619] = "E_USER_NOT_SIGNED_IN"; InvokeResultCode[InvokeResultCode["E_CATALOG_ACCESS_DENIED"] = -2147471591] = "E_CATALOG_ACCESS_DENIED"; InvokeResultCode[InvokeResultCode["E_CATALOG_REQUEST_FAILED"] = -2147471589] = "E_CATALOG_REQUEST_FAILED"; InvokeResultCode[InvokeResultCode["E_OEM_NO_NETWORK_CONNECTION"] = -2147208640] = "E_OEM_NO_NETWORK_CONNECTION"; InvokeResultCode[InvokeResultCode["E_PROVIDER_NOT_REGISTERED"] = -2147208617] = "E_PROVIDER_NOT_REGISTERED"; InvokeResultCode[InvokeResultCode["E_OEM_CACHE_SHUTDOWN"] = -2147208637] = "E_OEM_CACHE_SHUTDOWN"; InvokeResultCode[InvokeResultCode["E_OEM_REMOVED_FAILED"] = -2147209421] = "E_OEM_REMOVED_FAILED"; InvokeResultCode[InvokeResultCode["E_CATALOG_NO_APPS"] = -1] = "E_CATALOG_NO_APPS"; InvokeResultCode[InvokeResultCode["E_USER_NO_MAILBOX"] = -2] = "E_USER_NO_MAILBOX"; InvokeResultCode[InvokeResultCode["E_GENERIC_ERROR"] = -1000] = "E_GENERIC_ERROR"; InvokeResultCode[InvokeResultCode["S_HIDE_PROVIDER"] = 10] = "S_HIDE_PROVIDER"; })(InvokeResultCode = OSF.InvokeResultCode || (OSF.InvokeResultCode = {})); let ErrorStatusCodes; (function (ErrorStatusCodes) { ErrorStatusCodes[ErrorStatusCodes["E_OEM_EXTENSION_NOT_ENTITLED"] = 2147758662] = "E_OEM_EXTENSION_NOT_ENTITLED"; ErrorStatusCodes[ErrorStatusCodes["E_MANIFEST_SERVER_UNAVAILABLE"] = 2147758672] = "E_MANIFEST_SERVER_UNAVAILABLE"; ErrorStatusCodes[ErrorStatusCodes["E_USER_NOT_SIGNED_IN"] = 2147758677] = "E_USER_NOT_SIGNED_IN"; ErrorStatusCodes[ErrorStatusCodes["E_MANIFEST_DOES_NOT_EXIST"] = 2147758673] = "E_MANIFEST_DOES_NOT_EXIST"; ErrorStatusCodes[ErrorStatusCodes["E_OEM_EXTENSION_KILLED"] = 2147758660] = "E_OEM_EXTENSION_KILLED"; ErrorStatusCodes[ErrorStatusCodes["E_OEM_OMEX_EXTENSION_KILLED"] = 2147758686] = "E_OEM_OMEX_EXTENSION_KILLED"; ErrorStatusCodes[ErrorStatusCodes["E_MANIFEST_UPDATE_AVAILABLE"] = 2147758681] = "E_MANIFEST_UPDATE_AVAILABLE"; ErrorStatusCodes[ErrorStatusCodes["S_OEM_EXTENSION_TRIAL_MODE"] = 275013] = "S_OEM_EXTENSION_TRIAL_MODE"; ErrorStatusCodes[ErrorStatusCodes["E_OEM_EXTENSION_WITHDRAWN_FROM_SALE"] = 2147758690] = "E_OEM_EXTENSION_WITHDRAWN_FROM_SALE"; ErrorStatusCodes[ErrorStatusCodes["E_TOKEN_EXPIRED"] = 2147758675] = "E_TOKEN_EXPIRED"; ErrorStatusCodes[ErrorStatusCodes["E_TRUSTCENTER_CATALOG_UNTRUSTED_ADMIN_CONTROLLED"] = 2147757992] = "E_TRUSTCENTER_CATALOG_UNTRUSTED_ADMIN_CONTROLLED"; ErrorStatusCodes[ErrorStatusCodes["E_MANIFEST_REFERENCE_INVALID"] = 2147758678] = "E_MANIFEST_REFERENCE_INVALID"; ErrorStatusCodes[ErrorStatusCodes["S_USER_CLICKED_BUY"] = 274205] = "S_USER_CLICKED_BUY"; ErrorStatusCodes[ErrorStatusCodes["E_MANIFEST_INVALID_VALUE_FORMAT"] = 2147758654] = "E_MANIFEST_INVALID_VALUE_FORMAT"; ErrorStatusCodes[ErrorStatusCodes["E_TRUSTCENTER_MOE_UNACTIVATED"] = 2147757996] = "E_TRUSTCENTER_MOE_UNACTIVATED"; ErrorStatusCodes[ErrorStatusCodes["S_OEM_EXTENSION_FLAGGED"] = 275040] = "S_OEM_EXTENSION_FLAGGED"; ErrorStatusCodes[ErrorStatusCodes["S_OEM_EXTENSION_DEVELOPER_WITHDRAWN_FROM_SALE"] = 275041] = "S_OEM_EXTENSION_DEVELOPER_WITHDRAWN_FROM_SALE"; ErrorStatusCodes[ErrorStatusCodes["E_BROWSER_VERSION"] = 2147758194] = "E_BROWSER_VERSION"; ErrorStatusCodes[ErrorStatusCodes["E_TRUSTCENTER_APP_BLOCKED_FOR_MINOR"] = -2147209295] = "E_TRUSTCENTER_APP_BLOCKED_FOR_MINOR"; ErrorStatusCodes[ErrorStatusCodes["E_PRIVACY_SERVICE_DISABLED_ADMIN"] = 2147758792] = "E_PRIVACY_SERVICE_DISABLED_ADMIN"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveUnsupportedStoreType"] = 1041] = "WAC_AgaveUnsupportedStoreType"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveActivationError"] = 1042] = "WAC_AgaveActivationError"; ErrorStatusCodes[ErrorStatusCodes["WAC_ActivateAttempLoading"] = 1043] = "WAC_ActivateAttempLoading"; ErrorStatusCodes[ErrorStatusCodes["WAC_HTML5IframeSandboxNotSupport"] = 1044] = "WAC_HTML5IframeSandboxNotSupport"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveRequirementsErrorOmex"] = 1045] = "WAC_AgaveRequirementsErrorOmex"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveRequirementsError"] = 1046] = "WAC_AgaveRequirementsError"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveOriginCheckError"] = 1047] = "WAC_AgaveOriginCheckError"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgavePermissionCheckError"] = 1048] = "WAC_AgavePermissionCheckError"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveHostHandleRequestError"] = 1049] = "WAC_AgaveHostHandleRequestError"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveUnknownClientAppStatus"] = 1050] = "WAC_AgaveUnknownClientAppStatus"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveAnonymousProxyCreationError"] = 1051] = "WAC_AgaveAnonymousProxyCreationError"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveOsfControlActivationError"] = 1052] = "WAC_AgaveOsfControlActivationError"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveEntitlementRequestFailure"] = 1053] = "WAC_AgaveEntitlementRequestFailure"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveManifestRequestFailure"] = 1054] = "WAC_AgaveManifestRequestFailure"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveManifestAndEtokenRequestFailure"] = 1055] = "WAC_AgaveManifestAndEtokenRequestFailure"; ErrorStatusCodes[ErrorStatusCodes["WAC_FirstPartyAddInListRequestFailure"] = 1056] = "WAC_FirstPartyAddInListRequestFailure"; ErrorStatusCodes[ErrorStatusCodes["WAC_SDX_DMSRequestFailed"] = 1058] = "WAC_SDX_DMSRequestFailed"; ErrorStatusCodes[ErrorStatusCodes["WAC_SDX_AssetIdNotInDMSResponse"] = 1059] = "WAC_SDX_AssetIdNotInDMSResponse"; ErrorStatusCodes[ErrorStatusCodes["WAC_CustomFunctionsRegistrationError"] = 1060] = "WAC_CustomFunctionsRegistrationError"; ErrorStatusCodes[ErrorStatusCodes["WAC_WopiHostCheckStatusNotTrusted"] = 1061] = "WAC_WopiHostCheckStatusNotTrusted"; ErrorStatusCodes[ErrorStatusCodes["WAC_WopiHostCheckStatusNotReady"] = 1062] = "WAC_WopiHostCheckStatusNotReady"; ErrorStatusCodes[ErrorStatusCodes["WAC_AgaveIRMBlockError"] = 1063] = "WAC_AgaveIRMBlockError"; })(ErrorStatusCodes = OSF.ErrorStatusCodes || (OSF.ErrorStatusCodes = {})); let BWsaConfig; (function (BWsaConfig) { BWsaConfig[BWsaConfig["defaultMaxStreamRows"] = 1000] = "defaultMaxStreamRows"; })(BWsaConfig = OSF.BWsaConfig || (OSF.BWsaConfig = {})); let BWsaStreamTypes; (function (BWsaStreamTypes) { BWsaStreamTypes[BWsaStreamTypes["Static"] = 1] = "Static"; })(BWsaStreamTypes = OSF.BWsaStreamTypes || (OSF.BWsaStreamTypes = {})); let SQMDataPoints; (function (SQMDataPoints) { SQMDataPoints[SQMDataPoints["DATAID_APPSFOROFFICEUSAGE"] = 10595] = "DATAID_APPSFOROFFICEUSAGE"; SQMDataPoints[SQMDataPoints["DATAID_APPSFOROFFICENOTIFICATIONS"] = 10942] = "DATAID_APPSFOROFFICENOTIFICATIONS"; })(SQMDataPoints = OSF.SQMDataPoints || (OSF.SQMDataPoints = {})); let ClientAppInfoReturnType; (function (ClientAppInfoReturnType) { ClientAppInfoReturnType[ClientAppInfoReturnType["urlOnly"] = 0] = "urlOnly"; ClientAppInfoReturnType[ClientAppInfoReturnType["etokenOnly"] = 1] = "etokenOnly"; ClientAppInfoReturnType[ClientAppInfoReturnType["both"] = 2] = "both"; })(ClientAppInfoReturnType = OSF.ClientAppInfoReturnType || (OSF.ClientAppInfoReturnType = {})); let HostFrameTrustState; (function (HostFrameTrustState) { HostFrameTrustState[HostFrameTrustState["NotInitialized"] = 0] = "NotInitialized"; HostFrameTrustState[HostFrameTrustState["NotImplemented"] = 1] = "NotImplemented"; HostFrameTrustState[HostFrameTrustState["NotReady"] = 2] = "NotReady"; HostFrameTrustState[HostFrameTrustState["Exempted"] = 3] = "Exempted"; HostFrameTrustState[HostFrameTrustState["NotTrusted"] = 4] = "NotTrusted"; HostFrameTrustState[HostFrameTrustState["Trusted"] = 5] = "Trusted"; })(HostFrameTrustState = OSF.HostFrameTrustState || (OSF.HostFrameTrustState = {})); let UpnCheckCode; (function (UpnCheckCode) { UpnCheckCode[UpnCheckCode["NotSet"] = 0] = "NotSet"; UpnCheckCode[UpnCheckCode["Match"] = 1] = "Match"; UpnCheckCode[UpnCheckCode["NotMatch"] = 2] = "NotMatch"; })(UpnCheckCode = OSF.UpnCheckCode || (OSF.UpnCheckCode = {})); let ProxyCallStatusCode; (function (ProxyCallStatusCode) { ProxyCallStatusCode[ProxyCallStatusCode["Succeeded"] = 1] = "Succeeded"; ProxyCallStatusCode[ProxyCallStatusCode["Failed"] = 0] = "Failed"; ProxyCallStatusCode[ProxyCallStatusCode["ProxyNotReady"] = -1] = "ProxyNotReady"; })(ProxyCallStatusCode = OSF.ProxyCallStatusCode || (OSF.ProxyCallStatusCode = {})); let FormFactor; (function (FormFactor) { FormFactor["Default"] = "DefaultSettings"; FormFactor["Desktop"] = "DesktopSettings"; FormFactor["Tablet"] = "TabletSettings"; FormFactor["Phone"] = "PhoneSettings"; })(FormFactor = OSF.FormFactor || (OSF.FormFactor = {})); let OsfControlTarget; (function (OsfControlTarget) { OsfControlTarget[OsfControlTarget["Undefined"] = -1] = "Undefined"; OsfControlTarget[OsfControlTarget["InContent"] = 0] = "InContent"; OsfControlTarget[OsfControlTarget["TaskPane"] = 1] = "TaskPane"; OsfControlTarget[OsfControlTarget["Contextual"] = 2] = "Contextual"; OsfControlTarget[OsfControlTarget["SDXDialog"] = 3] = "SDXDialog"; })(OsfControlTarget = OSF.OsfControlTarget || (OSF.OsfControlTarget = {})); let OfficeAppType; (function (OfficeAppType) { OfficeAppType[OfficeAppType["ContentApp"] = 0] = "ContentApp"; OfficeAppType[OfficeAppType["TaskPaneApp"] = 1] = "TaskPaneApp"; OfficeAppType[OfficeAppType["MailApp"] = 2] = "MailApp"; OfficeAppType[OfficeAppType["SDXDialogApp"] = 3] = "SDXDialogApp"; })(OfficeAppType = OSF.OfficeAppType || (OSF.OfficeAppType = {})); let OmexRemoveAppStatus; (function (OmexRemoveAppStatus) { OmexRemoveAppStatus[OmexRemoveAppStatus["Failed"] = 0] = "Failed"; OmexRemoveAppStatus[OmexRemoveAppStatus["Success"] = 1] = "Success"; })(OmexRemoveAppStatus = OSF.OmexRemoveAppStatus || (OSF.OmexRemoveAppStatus = {})); let OmexAuthNStatus; (function (OmexAuthNStatus) { OmexAuthNStatus[OmexAuthNStatus["NotAttempted"] = -1] = "NotAttempted"; OmexAuthNStatus[OmexAuthNStatus["CheckFailed"] = 0] = "CheckFailed"; OmexAuthNStatus[OmexAuthNStatus["Authenticated"] = 1] = "Authenticated"; OmexAuthNStatus[OmexAuthNStatus["Anonymous"] = 2] = "Anonymous"; OmexAuthNStatus[OmexAuthNStatus["Unknown"] = 3] = "Unknown"; })(OmexAuthNStatus = OSF.OmexAuthNStatus || (OSF.OmexAuthNStatus = {})); let OmexEntitlementType; (function (OmexEntitlementType) { OmexEntitlementType["Free"] = "free"; OmexEntitlementType["Trial"] = "trial"; OmexEntitlementType["Paid"] = "paid"; })(OmexEntitlementType = OSF.OmexEntitlementType || (OSF.OmexEntitlementType = {})); let OmexTrialType; (function (OmexTrialType) { OmexTrialType[OmexTrialType["None"] = 0] = "None"; OmexTrialType[OmexTrialType["Office"] = 1] = "Office"; OmexTrialType[OmexTrialType["External"] = 2] = "External"; })(OmexTrialType = OSF.OmexTrialType || (OSF.OmexTrialType = {})); let OmexState; (function (OmexState) { OmexState[OmexState["Killed"] = 0] = "Killed"; OmexState[OmexState["OK"] = 1] = "OK"; OmexState[OmexState["Withdrawn"] = 2] = "Withdrawn"; OmexState[OmexState["Flagged"] = 3] = "Flagged"; OmexState[OmexState["DeveloperWithdrawn"] = 4] = "DeveloperWithdrawn"; })(OmexState = OSF.OmexState || (OSF.OmexState = {})); let OmexClientAppStatus; (function (OmexClientAppStatus) { OmexClientAppStatus[OmexClientAppStatus["OK"] = 1] = "OK"; OmexClientAppStatus[OmexClientAppStatus["UnknownAssetId"] = 2] = "UnknownAssetId"; OmexClientAppStatus[OmexClientAppStatus["KilledAsset"] = 3] = "KilledAsset"; OmexClientAppStatus[OmexClientAppStatus["NoEntitlement"] = 4] = "NoEntitlement"; OmexClientAppStatus[OmexClientAppStatus["DownloadsExceeded"] = 5] = "DownloadsExceeded"; OmexClientAppStatus[OmexClientAppStatus["Expired"] = 6] = "Expired"; OmexClientAppStatus[OmexClientAppStatus["Invalid"] = 7] = "Invalid"; OmexClientAppStatus[OmexClientAppStatus["Revoked"] = 8] = "Revoked"; OmexClientAppStatus[OmexClientAppStatus["ServerError"] = 9] = "ServerError"; OmexClientAppStatus[OmexClientAppStatus["BadRequest"] = 10] = "BadRequest"; OmexClientAppStatus[OmexClientAppStatus["LimitedTrial"] = 11] = "LimitedTrial"; OmexClientAppStatus[OmexClientAppStatus["TrialNotSupported"] = 12] = "TrialNotSupported"; OmexClientAppStatus[OmexClientAppStatus["EntitlementDeactivated"] = 13] = "EntitlementDeactivated"; OmexClientAppStatus[OmexClientAppStatus["VersionMismatch"] = 14] = "VersionMismatch"; OmexClientAppStatus[OmexClientAppStatus["VersionNotSupported"] = 15] = "VersionNotSupported"; OmexClientAppStatus[OmexClientAppStatus["UserIsMinor"] = 16] = "UserIsMinor"; })(OmexClientAppStatus = OSF.OmexClientAppStatus || (OSF.OmexClientAppStatus = {})); let ManifestIdIssuer; (function (ManifestIdIssuer) { ManifestIdIssuer["Microsoft"] = "Microsoft"; ManifestIdIssuer["Custom"] = "Custom"; })(ManifestIdIssuer = OSF.ManifestIdIssuer || (OSF.ManifestIdIssuer = {})); let StoreTypeEnum; (function (StoreTypeEnum) { StoreTypeEnum[StoreTypeEnum["MarketPlace"] = 0] = "MarketPlace"; StoreTypeEnum[StoreTypeEnum["Catalog"] = 1] = "Catalog"; StoreTypeEnum[StoreTypeEnum["SPApp"] = 2] = "SPApp"; StoreTypeEnum[StoreTypeEnum["Exchange"] = 3] = "Exchange"; StoreTypeEnum[StoreTypeEnum["FileSystem"] = 4] = "FileSystem"; StoreTypeEnum[StoreTypeEnum["Registry"] = 5] = "Registry"; StoreTypeEnum[StoreTypeEnum["PrivateCatalog"] = 10] = "PrivateCatalog"; StoreTypeEnum[StoreTypeEnum["HardCodedPreinstall"] = 11] = "HardCodedPreinstall"; StoreTypeEnum[StoreTypeEnum["FirstParty"] = 12] = "FirstParty"; StoreTypeEnum[StoreTypeEnum["Sdx"] = 14] = "Sdx"; StoreTypeEnum[StoreTypeEnum["UploadFileDevCatalog"] = 15] = "UploadFileDevCatalog"; StoreTypeEnum[StoreTypeEnum["WopiCatalog"] = 16] = "WopiCatalog"; })(StoreTypeEnum = OSF.StoreTypeEnum || (OSF.StoreTypeEnum = {})); let StoreType; (function (StoreType) { StoreType["OMEX"] = "omex"; StoreType["SPCatalog"] = "spcatalog"; StoreType["SPApp"] = "spapp"; StoreType["Exchange"] = "exchange"; StoreType["FileSystem"] = "filesystem"; StoreType["Registry"] = "registry"; StoreType["InMemory"] = "inmemory"; StoreType["PrivateCatalog"] = "excatalog"; StoreType["HardCodedPreinstall"] = "hardcodedpreinstall"; StoreType["FirstParty"] = "firstparty"; StoreType["UploadFileDevCatalog"] = "uploadfiledevcatalog"; StoreType["Sdx"] = "sdxcatalog"; StoreType["WopiCatalog"] = "wopicatalog"; })(StoreType = OSF.StoreType || (OSF.StoreType = {})); let OsfControlPageStatus; (function (OsfControlPageStatus) { OsfControlPageStatus[OsfControlPageStatus["NotStarted"] = 1] = "NotStarted"; OsfControlPageStatus[OsfControlPageStatus["Loading"] = 2] = "Loading"; OsfControlPageStatus[OsfControlPageStatus["Ready"] = 3] = "Ready"; OsfControlPageStatus[OsfControlPageStatus["FailedHandleRequest"] = 4] = "FailedHandleRequest"; OsfControlPageStatus[OsfControlPageStatus["FailedOriginCheck"] = 5] = "FailedOriginCheck"; OsfControlPageStatus[OsfControlPageStatus["FailedPermissionCheck"] = 6] = "FailedPermissionCheck"; })(OsfControlPageStatus = OSF.OsfControlPageStatus || (OSF.OsfControlPageStatus = {})); let OsfControlStatus; (function (OsfControlStatus) { OsfControlStatus[OsfControlStatus["NotActivated"] = 1] = "NotActivated"; OsfControlStatus[OsfControlStatus["Activated"] = 2] = "Activated"; OsfControlStatus[OsfControlStatus["AppStoreNotReachable"] = 3] = "AppStoreNotReachable"; OsfControlStatus[OsfControlStatus["InvalidOsfControl"] = 4] = "InvalidOsfControl"; OsfControlStatus[OsfControlStatus["UnsupportedStore"] = 5] = "UnsupportedStore"; OsfControlStatus[OsfControlStatus["UnknownStore"] = 6] = "UnknownStore"; OsfControlStatus[OsfControlStatus["ActivationFailed"] = 7] = "ActivationFailed"; OsfControlStatus[OsfControlStatus["NotSandBoxSupported"] = 8] = "NotSandBoxSupported"; })(OsfControlStatus = OSF.OsfControlStatus || (OSF.OsfControlStatus = {})); let OsfControlPermission; (function (OsfControlPermission) { OsfControlPermission[OsfControlPermission["Restricted"] = 1] = "Restricted"; OsfControlPermission[OsfControlPermission["ReadDocument"] = 2] = "ReadDocument"; OsfControlPermission[OsfControlPermission["WriteDocument"] = 4] = "WriteDocument"; OsfControlPermission[OsfControlPermission["ReadItem"] = 32] = "ReadItem"; OsfControlPermission[OsfControlPermission["ReadWriteMailbox"] = 64] = "ReadWriteMailbox"; OsfControlPermission[OsfControlPermission["ReadAllDocument"] = 131] = "ReadAllDocument"; OsfControlPermission[OsfControlPermission["ReadWriteDocument"] = 135] = "ReadWriteDocument"; OsfControlPermission[OsfControlPermission["ReadWriteItem"] = 256] = "ReadWriteItem"; })(OsfControlPermission = OSF.OsfControlPermission || (OSF.OsfControlPermission = {})); let Capability; (function (Capability) { Capability["Mailbox"] = "Mailbox"; Capability["Document"] = "Document"; Capability["Workbook"] = "Workbook"; Capability["Project"] = "Project"; Capability["Presentation"] = "Presentation"; Capability["Database"] = "Database"; Capability["Sway"] = "Sway"; Capability["Notebook"] = "Notebook"; Capability["Drawing"] = "Drawing"; })(Capability = OSF.Capability || (OSF.Capability = {})); let HostCapability; (function (HostCapability) { HostCapability["Excel"] = "Workbook"; HostCapability["Outlook"] = "Mailbox"; HostCapability["Access"] = "Database"; HostCapability["PowerPoint"] = "Presentation"; HostCapability["Word"] = "Document"; HostCapability["Sway"] = "Sway"; HostCapability["OneNote"] = "Notebook"; HostCapability["Visio"] = "Drawing"; })(HostCapability = OSF.HostCapability || (OSF.HostCapability = {})); OSF.getManifestHostType = function OSF$getManifestHostType(hostType) { var manifestHostType; switch (hostType) { case OSF.HostType.Excel: manifestHostType = OSF.ManifestHostType.Workbook; break; case OSF.HostType.Word: manifestHostType = OSF.ManifestHostType.Document; break; case OSF.HostType.PowerPoint: manifestHostType = OSF.ManifestHostType.Presentation; break; case OSF.HostType.OneNote: manifestHostType = OSF.ManifestHostType.Notebook; break; case OSF.HostType.Outlook: manifestHostType = OSF.ManifestHostType.Mailbox; break; case OSF.HostType.Visio: manifestHostType = OSF.ManifestHostType.Drawing; break; default: OsfMsAjaxFactory.msAjaxDebug.trace("Invalid host type."); throw "Invalid hostType."; } return manifestHostType; }; OSF.getManifestHostTypeFromAppName = function OSF$getModernAppVerCode(appName) { var manifestHostType; switch (appName) { case OSF.AppName.ExcelWebApp: manifestHostType = OSF.ManifestHostType.Workbook; break; case OSF.AppName.PowerpointWebApp: manifestHostType = OSF.ManifestHostType.Presentation; break; case OSF.AppName.WordWebApp: manifestHostType = OSF.ManifestHostType.Document; break; case OSF.AppName.OneNoteWebApp: manifestHostType = OSF.ManifestHostType.Notebook; break; case OSF.AppName.OutlookWebApp: manifestHostType = OSF.ManifestHostType.Mailbox; break; case OSF.AppName.VisioWebApp: manifestHostType = OSF.ManifestHostType.Drawing; break; default: OsfMsAjaxFactory.msAjaxDebug.trace("Invalid appName."); throw "Invalid appName."; } return manifestHostType; }; OSF.getModernAppVerCode = function OSF$getModernAppVerCode(appName) { var appModernVerCode; switch (appName) { case OSF.AppName.ExcelWebApp: appModernVerCode = "WAC_Excel"; break; case OSF.AppName.PowerpointWebApp: appModernVerCode = "WAC_PowerPoint"; break; case OSF.AppName.WordWebApp: appModernVerCode = "WAC_Word"; break; case OSF.AppName.OneNoteWebApp: appModernVerCode = "WAC_OneNote"; break; case OSF.AppName.OutlookWebApp: appModernVerCode = "WAC_Outlook"; break; case OSF.AppName.VisioWebApp: appModernVerCode = "WAC_Visio"; break; default: OsfMsAjaxFactory.msAjaxDebug.trace("Invalid appName."); throw "Invalid appName."; } return appModernVerCode; }; OSF.getAppVerCode = function OSF$getAppVerCode(appName) { var appVerCode; switch (appName) { case OSF.AppName.ExcelWebApp: appVerCode = "excel.exe"; break; case OSF.AppName.AccessWebApp: appVerCode = "ZAC"; break; case OSF.AppName.PowerpointWebApp: appVerCode = "WAP"; break; case OSF.AppName.WordWebApp: appVerCode = "WAW"; break; case OSF.AppName.OneNoteWebApp: appVerCode = "WAO"; break; case OSF.AppName.VisioWebApp: appVerCode = "WAV"; break; default: OsfMsAjaxFactory.msAjaxDebug.trace("Invalid appName."); throw "Invalid appName."; } return appVerCode; }; let HostPlatform; (function (HostPlatform) { HostPlatform["Web"] = "Web"; })(HostPlatform = OSF.HostPlatform || (OSF.HostPlatform = {})); let ManifestHostType; (function (ManifestHostType) { ManifestHostType["Workbook"] = "Workbook"; ManifestHostType["Document"] = "Document"; ManifestHostType["Presentation"] = "Presentation"; ManifestHostType["Notebook"] = "Notebook"; ManifestHostType["Mailbox"] = "Mailbox"; ManifestHostType["Drawing"] = "Drawing"; })(ManifestHostType = OSF.ManifestHostType || (OSF.ManifestHostType = {})); let HostType; (function (HostType) { HostType["Excel"] = "Excel"; HostType["Outlook"] = "Outlook"; HostType["Access"] = "Access"; HostType["PowerPoint"] = "PowerPoint"; HostType["Word"] = "Word"; HostType["Sway"] = "Sway"; HostType["OneNote"] = "OneNote"; HostType["Visio"] = "Visio"; })(HostType = OSF.HostType || (OSF.HostType = {})); OSF.OmexAppVersions = (function OSF_OmexAppVersions() { var nameMap = {}, appNameList = OSF.AppName; nameMap[appNameList.ExcelWebApp] = OSF.AppVersion.excelwebapp; nameMap[appNameList.WordWebApp] = OSF.AppVersion.wordwebapp; nameMap[appNameList.OutlookWebApp] = OSF.AppVersion.outlookwebapp; nameMap[appNameList.AccessWebApp] = OSF.AppVersion.access; nameMap[appNameList.PowerpointWebApp] = OSF.AppVersion.powerpointwebapp; nameMap[appNameList.OneNoteWebApp] = OSF.AppVersion.onenotewebapp; nameMap[appNameList.VisioWebApp] = OSF.AppVersion.visiowebapp; return nameMap; })(); OSF.OmexClientNames = (function OSF_OmexClientNames() { var nameMap = {}, appNameList = OSF.AppName; nameMap[appNameList.ExcelWebApp] = "WAC_Excel"; nameMap[appNameList.WordWebApp] = "WAC_Word"; nameMap[appNameList.OutlookWebApp] = "WAC_Outlook"; nameMap[appNameList.AccessWebApp] = "WAC_Access"; nameMap[appNameList.PowerpointWebApp] = "WAC_Powerpoint"; nameMap[appNameList.OneNoteWebApp] = "WAC_OneNote"; nameMap[appNameList.VisioWebApp] = "WAC_Visio"; return nameMap; })(); let HttpVerb; (function (HttpVerb) { HttpVerb["GET"] = "GET"; HttpVerb["POST"] = "POST"; HttpVerb["DELETE"] = "DELETE"; HttpVerb["PUT"] = "PUT"; })(HttpVerb = OSF.HttpVerb || (OSF.HttpVerb = {})); let PayloadType; (function (PayloadType) { PayloadType[PayloadType["OfficeAddin"] = 1] = "OfficeAddin"; PayloadType[PayloadType["MosAcquisition"] = 2] = "MosAcquisition"; })(PayloadType = OSF.PayloadType || (OSF.PayloadType = {})); let TitleScope; (function (TitleScope) { TitleScope["Public"] = "Public"; TitleScope["Tenant"] = "Tenant"; TitleScope["User"] = "User"; })(TitleScope = OSF.TitleScope || (OSF.TitleScope = {})); let AcquisitionAcquiredState; (function (AcquisitionAcquiredState) { AcquisitionAcquiredState["Acquired"] = "acquired"; AcquisitionAcquiredState["Unacquired"] = "unacquired"; AcquisitionAcquiredState["NeedsConsentForUpgrade"] = "needsconsentforupgrade"; })(AcquisitionAcquiredState = OSF.AcquisitionAcquiredState || (OSF.AcquisitionAcquiredState = {})); let VersionOverridesNumber; (function (VersionOverridesNumber) { VersionOverridesNumber[VersionOverridesNumber["V1_0"] = 100] = "V1_0"; VersionOverridesNumber[VersionOverridesNumber["V1_1"] = 101] = "V1_1"; VersionOverridesNumber[VersionOverridesNumber["Max"] = 102] = "Max"; })(VersionOverridesNumber = OSF.VersionOverridesNumber || (OSF.VersionOverridesNumber = {})); let VersionOverridesNamespace; (function (VersionOverridesNamespace) { VersionOverridesNamespace["V1_0"] = "http://schemas.microsoft.com/office/mailappversionoverrides"; VersionOverridesNamespace["V1_1"] = "http://schemas.microsoft.com/office/mailappversionoverrides/1.1"; })(VersionOverridesNamespace = OSF.VersionOverridesNamespace || (OSF.VersionOverridesNamespace = {})); let ParserStrings; (function (ParserStrings) { ParserStrings["DesktopFormFactor"] = "DesktopFormFactor"; ParserStrings["Form"] = "Form"; ParserStrings["FormSettings"] = "FormSettings"; ParserStrings["MobileFormFactor"] = "MobileFormFactor"; ParserStrings["OOfficeApp"] = "o:OfficeApp"; ParserStrings["RequestedHeight"] = "RequestedHeight"; ParserStrings["Resources"] = "Resources"; ParserStrings["SourceLocation"] = "SourceLocation"; ParserStrings["VersionOverrides"] = "VersionOverrides"; ParserStrings["Mailappor"] = "mailappor:"; })(ParserStrings = OSF.ParserStrings || (OSF.ParserStrings = {})); let PowerPointSlideShowRole; (function (PowerPointSlideShowRole) { PowerPointSlideShowRole[PowerPointSlideShowRole["Attendee"] = 0] = "Attendee"; PowerPointSlideShowRole[PowerPointSlideShowRole["Presenter"] = 1] = "Presenter"; PowerPointSlideShowRole[PowerPointSlideShowRole["PrivateViewing"] = 2] = "PrivateViewing"; })(PowerPointSlideShowRole = OSF.PowerPointSlideShowRole || (OSF.PowerPointSlideShowRole = {})); let PowerPointSlideShowUIHostType; (function (PowerPointSlideShowUIHostType) { PowerPointSlideShowUIHostType[PowerPointSlideShowUIHostType["UnifiedApp"] = 0] = "UnifiedApp"; PowerPointSlideShowUIHostType[PowerPointSlideShowUIHostType["MSTeams"] = 1] = "MSTeams"; PowerPointSlideShowUIHostType[PowerPointSlideShowUIHostType["TeamsiOS"] = 2] = "TeamsiOS"; PowerPointSlideShowUIHostType[PowerPointSlideShowUIHostType["TeamsAndroid"] = 3] = "TeamsAndroid"; PowerPointSlideShowUIHostType[PowerPointSlideShowUIHostType["Unknown"] = 4] = "Unknown"; })(PowerPointSlideShowUIHostType = OSF.PowerPointSlideShowUIHostType || (OSF.PowerPointSlideShowUIHostType = {})); })(OSF || (OSF = {})); var OfficeExt; (function (OfficeExt) { class ManifestUtil { static versionLessThan(version1, version2) { return OSF.OsfManifestManager.versionLessThan(version1, version2); } static ParseManifest(para, uiLocale, correlation) { try { return new OSF.Manifest.Manifest(para, uiLocale); } catch (ex) { Telemetry.RuntimeTelemetryHelper.LogExceptionTag("Invalid manifest:", ex, correlation, 0x1f01139f); return null; } } static constructAddInId(solutionId, version, storeTypeName, storeLocation) { const addinIdFormat = "{0}|{1}|{2}|{3}|{4}|||"; const addinIdFormatVersion = "2"; return OfficeExt.MsAjaxString.format(addinIdFormat, addinIdFormatVersion, solutionId, version, this.GetStoreTypeId(storeTypeName).toString(), storeLocation); } static GetStoreTypeId(storeTypeName) { if (storeTypeName == OSF.StoreType.OMEX) { return OSF.StoreTypeEnum.MarketPlace; } else if (storeTypeName == OSF.StoreType.SPCatalog) { return OSF.StoreTypeEnum.Catalog; } else if (storeTypeName == OSF.StoreType.SPApp) { return OSF.StoreTypeEnum.SPApp; } else if (storeTypeName == OSF.StoreType.Exchange) { return OSF.StoreTypeEnum.Exchange; } else if (storeTypeName == OSF.StoreType.FileSystem) { return OSF.StoreTypeEnum.FileSystem; } else if (storeTypeName == OSF.StoreType.Registry) { return OSF.StoreTypeEnum.Registry; } else if (storeTypeName == OSF.StoreType.PrivateCatalog) { return OSF.StoreTypeEnum.PrivateCatalog; } else if (storeTypeName == OSF.StoreType.HardCodedPreinstall) { return OSF.StoreTypeEnum.HardCodedPreinstall; } else if (storeTypeName == OSF.StoreType.FirstParty) { return OSF.StoreTypeEnum.FirstParty; } else if (storeTypeName == OSF.StoreType.UploadFileDevCatalog) { return OSF.StoreTypeEnum.UploadFileDevCatalog; } else if (storeTypeName == OSF.StoreType.WopiCatalog) { return OSF.StoreTypeEnum.WopiCatalog; } return -1; } static GetStoreTypeName(storeType) { var storeTypeId = parseInt(storeType); if (storeTypeId == OSF.StoreTypeEnum.MarketPlace) { return OSF.StoreType.OMEX; } else if (storeTypeId == OSF.StoreTypeEnum.Catalog) { return OSF.StoreType.SPCatalog; } else if (storeTypeId == OSF.StoreTypeEnum.SPApp) { return OSF.StoreType.SPApp; } else if (storeTypeId == OSF.StoreTypeEnum.Exchange) { return OSF.StoreType.Exchange; } else if (storeTypeId == OSF.StoreTypeEnum.FileSystem) { return OSF.StoreType.FileSystem; } else if (storeTypeId == OSF.StoreTypeEnum.Registry) { return OSF.StoreType.Registry; } else if (storeTypeId == OSF.StoreTypeEnum.PrivateCatalog) { return OSF.StoreType.PrivateCatalog; } else if (storeTypeId == OSF.StoreTypeEnum.HardCodedPreinstall) { return OSF.StoreType.HardCodedPreinstall; } else if (storeTypeId == OSF.StoreTypeEnum.FirstParty) { return OSF.StoreType.FirstParty; } else if (storeTypeId == OSF.StoreTypeEnum.UploadFileDevCatalog) { return OSF.StoreType.UploadFileDevCatalog; } else if (storeTypeId == OSF.StoreTypeEnum.WopiCatalog) { return OSF.StoreType.WopiCatalog; } return null; } } OfficeExt.ManifestUtil = ManifestUtil; class AsyncUtil { static failed(result, onComplete, value) { if (result.status != OfficeExt.DataServiceResultCode.Succeeded) { var r = { status: result.status, httpStatus: result.httpStatus }; if (value != null) { r.value = value; } onComplete(r); return true; } return false; } static retry(operation, options = {}) { const { retries = 3, factor = 2, minTimeout = 300, maxTimeout = Infinity } = options; return new Promise((resolve, reject) => { const attempt = (count) => { operation().then(resolve, err => { if (count >= retries) { reject(err); return; } setTimeout(() => attempt(count + 1), Math.min(minTimeout * Math.pow(factor, count), maxTimeout)); }); }; attempt(0); }); } static limitRate(func, wait) { const taskQueue = []; let lastRunTask = -Infinity; const runTaskQueue = () => { const args = taskQueue.shift(); if (taskQueue.length > 0) { setTimeout(runTaskQueue, wait); } lastRunTask = performance.now(); func(...args); }; return (...args) => { if (taskQueue.length === 0) { setTimeout(runTaskQueue, Math.max(0, wait - (performance.now() - lastRunTask))); } taskQueue.push(args); }; } static withCache(cacheKey, options, operation) { const { forceUpdateCache = false, maxAgeInSecs = 60 * 60 * 24 * 3, useStaleCache = false } = options; if (!forceUpdateCache && AsyncUtil.Cache.hasOwnProperty(cacheKey)) { return Promise.resolve({ cacheType: 'memory', value: AsyncUtil.Cache[cacheKey] }); } const cacheKeyWithPrefix = `__OSF_AsyncCache_${cacheKey}`; const cacheKeyWithPrefixStale = `__OSF_AsyncCache_${cacheKey}_stale`; const expiriesKey = `__OSF_AsyncCacheExpiry`; const now = Date.now(); if (OSF.OUtil.getLocalStorage().isLocalStorageAvailable()) { try { if (now >= AsyncUtil.NextCheckExpiry) { const expiries = JSON.parse(localStorage.getItem(expiriesKey)) || {}; let needUpdateExpiries = false; AsyncUtil.NextCheckExpiry = Infinity; for (const key in expiries) { if (now > expiries[key]) { localStorage.removeItem(`__OSF_AsyncCache_${key}`); delete expiries[key]; needUpdateExpiries = true; } else { AsyncUtil.NextCheckExpiry = Math.min(AsyncUtil.NextCheckExpiry, expiries[key]); } } if (needUpdateExpiries) { localStorage.setItem(expiriesKey, JSON.stringify(expiries)); } } if (!forceUpdateCache && localStorage.hasOwnProperty(cacheKeyWithPrefix)) { return Promise.resolve({ cacheType: 'localStorage', value: localStorage.getItem(cacheKeyWithPrefix) }); } } catch (e) { Telemetry.RuntimeTelemetryHelper.LogExceptionTag(`failed to get key ${cacheKeyWithPrefix}`, e, null, 0x1f01139e); } } return operation().then(result => { AsyncUtil.Cache[cacheKey] = result; try { const expiries = JSON.parse(localStorage.getItem(expiriesKey)) || {}; expiries[cacheKey] = now + maxAgeInSecs * 1000; AsyncUtil.NextCheckExpiry = Math.min(AsyncUtil.NextCheckExpiry, expiries[cacheKey]); localStorage.setItem(expiriesKey, JSON.stringify(expiries)); localStorage.setItem(cacheKeyWithPrefix, result); localStorage.setItem(cacheKeyWithPrefixStale, result); } catch (e) { } return { cacheType: 'none', value: result }; }, ex => { if (useStaleCache && OSF.OUtil.getLocalStorage().isLocalStorageAvailable()) { if (localStorage.hasOwnProperty(cacheKeyWithPrefixStale)) { Telemetry.RuntimeTelemetryHelper.LogCommonMessageTag(`stale cache used for ${cacheKeyWithPrefixStale}`, null, 0x1f01139d); return Promise.resolve({ cacheType: 'localStorage', value: localStorage.getItem(cacheKeyWithPrefixStale) }); } } throw ex; }); } } AsyncUtil.Cache = {}; AsyncUtil.NextCheckExpiry = 0; OfficeExt.AsyncUtil = AsyncUtil; class CatalogFactoryImp { static register(storeType, creator) { this._registry[storeType] = creator; } static resolve(storeType, hostInfo) { var catalog = this._resolved[storeType]; if (catalog != null) { return catalog; } hostInfo = hostInfo || this._hostInfo; if (hostInfo != null) { var creator = this._registry[storeType]; if (creator == null) { return null; } this._resolved[storeType] = catalog = creator(hostInfo); } return catalog; } static setHostContext(hostInfo) { this._hostInfo = hostInfo; } static getHostContext() { return this._hostInfo; } } CatalogFactoryImp._registry = {}; CatalogFactoryImp._resolved = {}; OfficeExt.CatalogFactory = CatalogFactoryImp; })(OfficeExt || (OfficeExt = {})); var OSF; (function (OSF) { OSF.RibbonControlIdMap = {}; OSF.RibbonGroupIdMap = {}; OSF.RibbonGroupIdMapMLR = {}; OSF.RibbonGroupIdMapCommonMLR = {}; OSF.RibbonGroupIdMapCommonSLR = {}; })(OSF || (OSF = {})); OSF.RibbonControlIdMap = {}; OSF.RibbonGroupIdMap = {}; OSF.RibbonGroupIdMapMLR = {}; OSF.RibbonGroupIdMapCommonMLR = {}; OSF.RibbonGroupIdMapCommonSLR = {}; var OSF; (function (OSF) { function SelectSingleNode(xmlProcessor, node, path, isStrictPath) { if (path == null) return node; let currentNode = node; for (let i = 0; i < path.length; i++) { currentNode = xmlProcessor.selectSingleNode(path[i], currentNode); if (currentNode == null) { if (isStrictPath) { return null; } break; } } return currentNode; } OSF.SelectSingleNode = SelectSingleNode; function SelectChildNodes(xmlProcessor, name, node, path, isStrictPath) { let currentNode = SelectSingleNode(xmlProcessor, node, path, isStrictPath); if (currentNode == null) { return []; } return xmlProcessor.selectNodes(name, currentNode); } OSF.SelectChildNodes = SelectChildNodes; function GetVersionOverridesString(versionOverridesNumber) { let versionString = ""; if (versionOverridesNumber >= OSF.VersionOverridesNumber.V1_0 && versionOverridesNumber < OSF.VersionOverridesNumber.Max) { versionString = "VersionOverridesV" + Math.floor(versionOverridesNumber / 100) + "_" + (versionOverridesNumber % 100); } return versionString; } OSF.GetVersionOverridesString = GetVersionOverridesString; function GetVersionOverridesPath(xmlProcessor, namespace, versionOverridesNumber) { let path = []; if (versionOverridesNumber >= OSF.VersionOverridesNumber.V1_0 && versionOverridesNumber < OSF.VersionOverridesNumber.Max) { for (const v in OSF.VersionOverridesNumber) { let versionNumber = Number(v); if (!isNaN(versionNumber) && versionNumber <= versionOverridesNumber) { let ns = namespace; if (versionNumber > OSF.VersionOverridesNumber.V1_0) { ns = GetVersionOverridesNamespace(ns, versionNumber); xmlProcessor.addNamespaceMapping(ns.slice(0, -1), OSF.VersionOverridesNamespace[OSF.VersionOverridesNumber[versionNumber]]); } path.push(ns + OSF.ParserStrings.VersionOverrides); } } } return path; } OSF.GetVersionOverridesPath = GetVersionOverridesPath; function GetVersionOverridesNamespace(namespace, versionOverridesNumber) { let ns = namespace; if (versionOverridesNumber != null && versionOverridesNumber > OSF.VersionOverridesNumber.V1_0 && ns === OSF.ParserStrings.Mailappor) { ns = OSF.ParserStrings.Mailappor.replace(":", OSF.VersionOverridesNumber[versionOverridesNumber] + ":"); } return ns; } OSF.GetVersionOverridesNamespace = GetVersionOverridesNamespace; function GetNamespaceOrDefault(namespace) { if (namespace && namespace.length > 0) { return namespace; } return "ov:"; } OSF.GetNamespaceOrDefault = GetNamespaceOrDefault; })(OSF || (OSF = {})); var OfficeExt; (function (OfficeExt) { let Parser; (function (Parser) { const OfficeControlNodeName = "OfficeControl"; class AddInManifestException { constructor(message) { this.name = 'AddinManifestError'; this.message = this.name + ": " + message; console.error(this.message); } } class AddInInternalException { constructor(message) { this.name = 'AddinInternalError'; this.message = message; } } function CheckValueNotNullNorUndefined(objectValue, errorMessage) { if (objectValue == null) { throw new AddInManifestException(errorMessage); } } function CheckValueNotContainsInvalidCharacters(stringValue, errorMessage) { const invalidChars = '\r\n\f\b\v\u0007\t'; for (let i = 0; i < invalidChars.length; ++i) { if (stringValue.indexOf(invalidChars[i]) >= 0) { throw new AddInManifestException(errorMessage); } } } function GetActionType(action) { const type = action.type; return type === "openPage" ? "ShowTaskpane" : (type === "executeFunction" ? "ExecuteFunction" : type); } let resIdCounter = 0; class ManifestResourceManager { constructor(context, namespace, versionOverridesNumber) { this.Images = {}; this.Urls = {}; this.LongStrings = {}; this.ShortStrings = {}; this.namespace = OSF.GetNamespaceOrDefault(namespace); if (context.manifest.getPayloadType() === OSF.PayloadType.OfficeAddin) { let xmlProcessor = context.manifest._xmlProcessor; var officeAppNode = xmlProcessor.selectSingleNode("o:OfficeApp"); var resourcesNode; if (context.manifest.isForOfficeAppManifest()) { this.AllLocaleImages = {}; this.AllLocaleUrls = {}; this.AllLocaleLongStrings = {}; this.AllLocaleShortStrings = {}; if (versionOverridesNumber == null) { versionOverridesNumber = OSF.VersionOverridesNumber.V1_0; } let resourcesNodePath = OSF.GetVersionOverridesPath(xmlProcessor, this.namespace, versionOverridesNumber); resourcesNodePath.push(OSF.GetVersionOverridesNamespace(this.namespace, versionOverridesNumber) + OSF.ParserStrings.Resources); resourcesNode = OSF.SelectSingleNode(xmlProcessor, officeAppNode, resourcesNodePath, true); this.parseCollection(context, OSF.SelectChildNodes(xmlProcessor, "bt:Image", resourcesNode, ["bt:Images"]), this.Images, this.AllLocaleImages); this.parseCollection(context, OSF.SelectChildNodes(xmlProcessor, "bt:Url", resourcesNode, ["bt:Urls"]), this.Urls, this.AllLocaleUrls); this.parseCollection(context, OSF.SelectChildNodes(xmlProcessor, "bt:String", resourcesNode, ["bt:LongStrings"]), this.LongStrings, this.AllLocaleLongStrings); this.parseCollection(context, OSF.SelectChildNodes(xmlProcessor, "bt:String", resourcesNode, ["bt:ShortStrings"]), this.ShortStrings, this.AllLocaleShortStrings); } else { resourcesNode = OSF.SelectSingleNode(xmlProcessor, officeAppNode, [this.namespace + "VersionOverrides", this.namespace + "Resources"]); this.parseCollection(context, OSF.SelectChildNodes(xmlProcessor, "bt:Image", resourcesNode, ["bt:Images"]), this.Images); this.parseCollection(context, OSF.SelectChildNodes(xmlProcessor, "bt:Url", resourcesNode, ["bt:Urls"]), this.Urls); this.parseCollection(context, OSF.SelectChildNodes(xmlProcessor, "bt:String", resourcesNode, ["bt:LongStrings"]), this.LongStrings); this.parseCollection(context, OSF.SelectChildNodes(xmlProcessor, "bt:String", resourcesNode, ["bt:ShortStrings"]), this.ShortStrings); } } } parseCollection(context, nodes, map, allLocaleMaps) { var len = nodes.length; for (var i = 0; i < len; i++) { var node = nodes[i]; var id = node.getAttribute("id"); if (allLocaleMaps != null) { allLocaleMaps[id] = {}; map[id] = context.parseLocaleAwareSettingsAndGetValue(node, allLocaleMaps[id]); } else { map[id] = context.parseLocaleAwareSettingsAndGetValue(node); } } } } Parser.ManifestResourceManager = ManifestResourceManager; class ParsingContext { constructor(hostType, formFactor, entitlement, manifest, namespace, versionOverridesNumber) { this.hostType = hostType; this.formFactor = formFactor; this.entitlement = entitlement; this.manifest = manifest; this.namespace = OSF.GetNamespaceOrDefault(namespace); this.resources = new ManifestResourceManager(this, this.namespace, versionOverridesNumber); this.officeGroupCount = 0; this.officeControlCount = 0; } shouldParseNode(node) { var overriddenByRibbonApi = this.manifest._xmlProcessor.selectSingleNode(this.namespace + "OverriddenByRibbonApi", node); if ((overriddenByRibbonApi != null && this.manifest._parseBooleanNode(overriddenByRibbonApi)) && !this.manifest.isForOfficeAppManifest()) { return false; } return true; } shouldParseNodeFromMos(node) { return !node.overriddenByRibbonApi; } parseIdRequired(node) { var id = node.getAttribute("id"); CheckValueNotNullNorUndefined(id, "Id required"); return id; } parseIdRequiredFromMos(node) { let id = node.id; CheckValueNotNullNorUndefined(id, "Id required"); return id; } parseLabel(node) { var child = this.manifest._xmlProcessor.selectSingleNode(this.namespace + "Label", node); if (child != null) { return this.getShortString(child); } return null; } parseLabelRequired(node) { var label = this.parseLabel(node); CheckValueNotNullNorUndefined(label, "Label required"); return label; } parseLabelRequiredFromMos(node) { let label = node.label; CheckValueNotNullNorUndefined(label, "Label required"); return label; } parseResId(node) { if (node != null) { return node.getAttribute("resid"); } return null; } parseType(node) { if (node != null) { return node.getAttribute("type"); } return null; } parseRequiredSuperTip(node) { var superTip = this.parseSuperTip(node); CheckValueNotNullNorUndefined(superTip, "SuperTip required"); return superTip; } parseRequiredSupertipFromMos(node) { const supertip = this.parseSupertipFromMos(node); CheckValueNotNullNorUndefined(supertip, "supertip required"); return supertip; } parseSuperTip(node) { var superTip = null; var child = this.manifest._xmlProcessor.selectSingleNode(this.namespace + "Supertip", node); if (child != null) { var tipNode = child; var title, description, titleResId, descriptionResId; child = this.manifest._xmlProcessor.selectSingleNode(this.namespace + "Title", tipNode); CheckValueNotNullNorUndefined(child, "Title is necessary for SuperTip."); title = this.getShortString(child); child = this.manifest._xmlProcessor.selectSingleNode(this.namespace + "Description", tipNode); CheckValueNotNullNorUndefined(child, "Description is necessary for SuperTip."); description = this.getLongString(child); superTip = { title: title, description: description }; if (this.manifest.isForOfficeAppManifest()) { child = this.manifest._xmlProcessor.selectSingleNode(this.namespace + "Title", tipNode); superTip.titleResId = this.parseResId(child); child = this.manifest._xmlProcessor.selectSingleNode(this.namespace + "Description", tipNode); superTip.descriptionResId = this.parseResId(child); } } return superTip; } parseSupertipFromMos(control) { let supertip = null; const child = control.supertip; if (child != null) { const title = child.title; CheckValueNotNullNorUndefined(title, "Title is necessary for Supertip."); CheckValueNotContainsInvalidCharacters(title, "Invalid characters in text value: " + title); const description = child.description; CheckValueNotNullNorUndefined(description, "Description is necessary for Supertip."); CheckValueNotContainsInvalidCharacters(description, "Invalid characters in text value: " + description); supertip = { title: title, description: description }; } return supertip; } parseRequiredIcon(node) { var icon = this.parseIcon(node); CheckValueNotNullNorUndefined(icon, "Icon required"); return icon; } parseRequiredIconFromMos(node) { let icon = this.parseIconFromMos(node); CheckValueNotNullNorUndefined(icon, "Icon required"); return icon; } parseOptionalIcon(node) { return this.parseIcon(node); } parseOptionalIconFromMos(node) { return this.parseIcon(node); } parseIcon(node) { var iconNodes = OSF.SelectChildNodes(this.manifest._xmlProcessor, "bt:Image", node, [this.namespace + "Icon"]); var len = iconNodes.length; if (len == 0) { return null; } var icon = {}; for (var i = 0; i < len; i++) { var iconNode = iconNodes[i]; var size = iconNode.getAttribute("size"); icon[size] = this.getImageResource(iconNode); } return icon; } parseIconFromMos(node) { const iconNodes = node.icons; const len = iconNodes === null || iconNodes === void 0 ? void 0 : iconNodes.length; if (!len || len == 0) { return null; } let icons = {}; for (const icon of iconNodes) { this.AddResourceMapAndGetIdHelper(icon.file, this.resources.Images); const size = icon.size; icons[size] = icon.file; } return icons; } parseIconResId(node) { var iconNodes = OSF.SelectChildNodes(this.manifest._xmlProcessor, "bt:Image", node, [this.namespace + "Icon"]); var len = iconNodes.length; if (len == 0) { return null; } var iconResId = {}; for (var i = 0; i < len; i++) { var iconNode = iconNodes[i]; var size = iconNode.getAttribute("size"); if (size != null) { iconResId[size] = iconNode.getAttribute("resid"); } } return iconResId; } AddResourceMapAndGetIdHelper(resourceValue, resourceMap) { CheckValueNotNullNorUndefined(resourceMap, "resourceMap is not found."); resIdCounter++; resourceMap[resIdCounter] = resourceValue; } checkRequiredGroupIcons(icons) { CheckValueNotNullNorUndefined(icons[16], "Icons are missing required size 16"); CheckValueNotNullNorUndefined(icons[32], "Icons are missing required size 32"); CheckValueNotNullNorUndefined(icons[80], "Icons are missing required size 80"); } parseMultipleChildControls(childNodeNames, node, parser) { var controls = []; for (var idx = 0; idx < node.childNodes.length; idx++) { if (childNodeNames.indexOf(node.childNodes[idx].nodeName) !== -1) { controls.push(node.childNodes[idx]); } } return this.parseControls(controls, parser); } parseMultipleChildControlsFromMos(childNodeNames, node, parseControlFromMos) { let controls = []; if (childNodeNames[0] == "Group") { for (const group of node.groups) { controls.push(group); } } else { for (const control of node.controls) { controls.push(control); } } return this.parseControlsFromMos(controls, parseControlFromMos); } parseChildControls(childNodeName, node, parser) { var controls = this.manifest._xmlProcessor.selectNodes(childNodeName, node); return this.parseControls(controls, parser); } parseChildControlsFromMos(childNodeName, contextMenu, parser) { let controls = contextMenu.menus; return this.parseControlsFromMos(controls, parser); } parseControls(nodes, parser) { var controls = []; var len = nodes.length; for (var i = 0; i < len; i++) { var e = nodes[i]; if (this.shouldParseNode(e)) { var control = parser(this, e); CheckValueNotNullNorUndefined(control, "parser must return a control."); controls.push(control); } } return controls; } parseControlsFromMos(nodes, parseControlFromMos) { let controls = []; for (const e of nodes) { if (this.shouldParseNodeFromMos(e)) { const control = parseControlFromMos(this, e); CheckValueNotNullNorUndefined(control, "parseControlFromMos must return a control."); controls.push(control); } } return controls; } parseGroupUnderTab(node) { let group; switch (node.nodeName) { case "OfficeGroup": group = new OfficeGroup(this.hostType); this.officeGroupCount++; break; default: group = new RibbonGroup(this.hostType); } group.parse(this, node); return group; } parseGroupUnderTabFromMos(group) { let newGroup; if (group.id == null) { newGroup = new OfficeGroup(this.hostType); this.officeGroupCount++; } else { newGroup = new RibbonGroup(this.hostType); } newGroup.parseFromMos(this, group); return newGroup; } parseControlInGroup(node) { var controlType = this.manifest.getNodeXsiType(node); var control; if (!controlType && node.nodeName === OfficeControlNodeName) { controlType = 'OfficeControl'; } switch (controlType) { case "Menu": control = new MenuControl(controlType, this.namespace); break; case "Button": control = new Button(controlType, this.namespace); break; case "OfficeControl": control = new OfficeControl(); this.officeControlCount++; break; default: throw new AddInManifestException("Unsupported control type."); } control.parse(this, node); return control; } parseControlInGroupFromMos(control) { let controlType = control.type; let newControl; if (controlType == null) { controlType = 'OfficeControl'; } switch (controlType) { case "menu": newControl = new MenuControl("Menu"); break; case "button": newControl = new Button("Button"); break; case "OfficeControl": newControl = new OfficeControl(); this.officeControlCount++; break; default: throw new AddInManifestException("Unsupported control type."); } newControl.parseFromMos(this, control); return newControl; } parseMenuItem(node) { var item = new MenuItem(this.namespace); item.parse(this, node); return item; } parseMenuItemFromMos(node) { let item = new MenuItem(); item.parseFromMos(this, node); return item; } parseLocaleAwareSettingsAndGetValue(node, allLocaleMap) { const forAllLocales = allLocaleMap != null; let values = forAllLocales ? allLocaleMap : {}; var defaultValue = node.getAttribute("DefaultValue"); values[this.manifest._defaultLocale] = defaultValue; values[this.manifest._defaultLocale.toLocaleLowerCase()] = defaultValue; var overrideNodes = this.manifest._xmlProcessor.selectNodes("bt:Override", node); if (overrideNodes) { var len = overrideNodes.length; for (var i = 0; i < len; i++) { var node = overrideNodes[i]; var locale = node.getAttribute("Locale"); var value = node.getAttribute("Value"); if (!forAllLocales) { values[locale] = value; } values[locale.toLocaleLowerCase()] = value; if (this.manifest.isForOfficeAppManifest()) { this.manifest.addLocaleSeen(locale); } } } return this.manifest._getDefaultValue(values); } selectSingleNode(node, path) { if (path == null) return node; for (var i = 0; i < path.length; i++) { node = this.manifest._xmlProcessor.selectSingleNode(path[i], node); if (node == null) { break; } } return node; } selectChildNodes(name, node, path) { node = this.selectSingleNode(node, path); if (node == null) { return []; } return this.manifest._xmlProcessor.selectNodes(name, node); } getSingleNodeValue(nodeName, parentNode) { let node = this.manifest._xmlProcessor.selectSingleNode(nodeName, parentNode); if (node) { return this.manifest._xmlProcessor.getNodeValue(node); } return ''; } getResourceByNode(resources, resourceNode) { var resid = resourceNode.getAttribute("resid"); var res = resources[resid]; if (this.manifest.isForOfficeAppManifest() && res == null) { if (this.manifest.converterLogging()) { console.error('\x1b[31m%s\x1b[0m', "WARNING: resid: " + resid + " is not defined."); } res = ""; } else { CheckValueNotNullNorUndefined(res, "resid: " + resid + " not found"); } return res; } getImageResource(resourceNode) { return this.getResourceByNode(this.resources.Images, resourceNode); } getUrlResource(resourceNode) { return this.getResourceByNode(this.resources.Urls, resourceNode); } getLongString(resourceNode) { const longString = this.getResourceByNode(this.resources.LongStrings, resourceNode); CheckValueNotContainsInvalidCharacters(longString, "Invalid characters in text value: " + longString); return longString; } getShortString(resourceNode) { const shortString = this.getResourceByNode(this.resources.ShortStrings, resourceNode); CheckValueNotContainsInvalidCharacters(shortString, "Invalid characters in text value: " + shortString); return shortString; } getContextMenuType(menu) { switch (menu === null || menu === void 0 ? void 0 : menu.type) { case "cell": return "ContextMenuCell"; case "text": return "ContextMenuText"; default: throw new AddInManifestException("Unsupported context menu type."); } } getLabelChildNode(node, namespace) { var labelNode = this.manifest._xmlProcessor.selectSingleNode(namespace + "Label", node); return labelNode; } } Parser.ParsingContext = ParsingContext; class BuildHelpers { static buildControls(context, controls) { var len = controls.length; for (var i = 0; i < len; i++) { var child = controls[i]; child.apply(context); } } } class AddinBuildingContext { constructor(functionFile, builder, multipleCustomTabsEnabled = false) { this.multipleCustomTabsEnabled = false; this.functionFile = functionFile; this.builder = builder; this.multipleCustomTabsEnabled = multipleCustomTabsEnabled; } } class GetStartedNode { constructor(namespace) { this.namespace = OSF.GetNamespaceOrDefault(namespace); } parse(context, node) { var xmlProcessor = context.manifest._xmlProcessor; var titleNode = xmlProcessor.selectSingleNode(this.namespace + "Title", node); CheckValueNotNullNorUndefined(titleNode, "Title is necessary for GetStarted."); this.title = context.getShortString(titleNode); var descriptionNode = xmlProcessor.selectSingleNode(this.namespace + "Description", node); CheckValueNotNullNorUndefined(descriptionNode, "Description is necessary for GetStarted."); this.description = context.getLongString(descriptionNode); var learnMoreNode = xmlProcessor.selectSingleNode(this.namespace + "LearnMoreUrl", node); this.learnMoreUrl = context.getUrlResource(learnMoreNode); } parseFromMos(context, getStartedMessage) { this.title = getStartedMessage.title; this.description = getStartedMessage.description; this.learnMoreUrl = getStartedMessage.learnMoreUrl; } } class ActionBase { constructor(type, namespace) { this.type = type; this.namespace = OSF.GetNamespaceOrDefault(namespace); } buildAction(context) { } parse(context, node) { } parseFromMos(context, node) { } } class ShowUIAction extends ActionBase { constructor() { super(...arguments); this.title = null; } parse(context, node) { var child = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "SourceLocation", node); CheckValueNotNullNorUndefined(child, "SourceLocation is necessary for ShowTaskpane action"); this.sourceLocation = context.getUrlResource(child); context.manifest.addManifestUrl(this.sourceLocation); } parseFromMos(context, node) { const runtime = context.manifest.getExtensionRuntimeByActionId(node.id); this.sourceLocation = runtime.code.page; context.manifest.addManifestUrl(this.sourceLocation); } } class ShowTaskPaneAction extends ShowUIAction { constructor() { super(...arguments); this.pinnable = false; } buildAction(context) { return context.actionBuilder.buildShowTaskpane(this.sourceLocation, this.title, this.taskpaneId, this.sourceLocationResid); } parse(context, node) { super.parse(context, node); var child = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "TaskpaneId", node); if (child != null) { this.taskpaneId = child.firstChild.nodeValue; } if (context.manifest.isForOfficeAppManifest()) { child = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "SourceLocation", node); } else { child = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "SourceLocation ", node); } if (child != null) { this.sourceLocationResid = child.getAttribute("resid"); } child = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "Title", node); if (child != null) { this.title = context.getShortString(child); } if (context.manifest.isForOfficeAppManifest()) { var supportsPinningNode = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "SupportsPinning", node); if (supportsPinningNode != null) { this.pinnable = context.manifest._parseBooleanNode(supportsPinningNode); } } } parseFromMos(context, node) { super.parseFromMos(context, node); const runtime = context.manifest.getExtensionRuntimeByActionId(node.id); if (runtime != null) { this.sourceLocationResid = runtime.id; this.taskpaneId = null; const action = context.manifest.getExtensionActionById(node.id); if (action != null && action.view != null) { this.taskpaneId = action.view; } if (action.displayName != null) { this.title = action.displayName; } } } } class ExecuteFunctionAction extends ActionBase { buildAction(context) { CheckValueNotNullNorUndefined(context.functionFile, "Valid FunctionFile source url is necessary for ExecuteFunctionAction."); return context.actionBuilder.buildCallFunction(context.functionFile, this.functionName, this.controlId); } parse(context, node) { var child = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "FunctionName", node); CheckValueNotNullNorUndefined(child, "FunctionName is necessary for ExecuteFunctionAction."); this.functionName = context.manifest._xmlProcessor.getNodeValue(child); } parseFromMos(conext, node) { const functionName = node.displayName; CheckValueNotNullNorUndefined(functionName, "Parsing from Mos: FunctionName is necessary for ExecuteFunctionAction."); this.functionName = functionName; } } class UIEntityBase { parse(context, node) { this.id = context.parseIdRequired(node); this.label = context.parseLabelRequired(node); } parseFromMos(context, node) { this.id = context.parseIdRequiredFromMos(node); this.label = context.parseLabelRequiredFromMos(node); } } class MenuControl extends UIEntityBase { constructor(controlType, namespace) { super(); this.controlType = controlType; this.namespace = OSF.GetNamespaceOrDefault(namespace); } apply(context) { context.controlBuilder.startBuildMenu(this); BuildHelpers.buildControls(context, this.children); context.controlBuilder.endBuildMenu(); } parse(context, node) { if (!context.shouldParseNode(node)) { return; } super.parse(context, node); this.icon = context.parseRequiredIcon(node); if (context.manifest.isForOfficeAppManifest()) { this.iconResId = context.parseIconResId(node); } this.superTip = context.parseRequiredSuperTip(node); var controls = OSF.SelectChildNodes(context.manifest._xmlProcessor, this.namespace + "Item", node, [this.namespace + "Items"]); if (context.manifest.isForOfficeAppManifest()) { let labelChild = null; labelChild = context.manifest._xmlProcessor.selectSingleNode(context.namespace + "Label", node); this.labelResId = context.parseResId(labelChild); } this.children = context.parseControls(controls, (context, node) => { return context.parseMenuItem(node); }); } parseFromMos(context, node) { if (!context.shouldParseNodeFromMos(node)) { return; } super.parseFromMos(context, node); this.icon = context.parseRequiredIconFromMos(node); this.superTip = context.parseRequiredSupertipFromMos(node); const controls = node.items; this.children = context.parseControlsFromMos(controls, (context, item) => { return context.parseMenuItemFromMos(item); }); } } Parser.MenuControl = MenuControl; class ItemControl extends UIEntityBase { constructor(controlType, namespace) { super(); this.enabled = true; this.controlType = controlType; this.namespace = OSF.GetNamespaceOrDefault(namespace); } apply(context) { var action = this.action.buildAction(context); var control = { id: this.id, label: this.label, icon: this.icon, superTip: this.superTip, actionType: this.actionType, action: action, enabled: this.enabled }; this.applyControl(context, control); } parse(context, node) { super.parse(context, node); this.icon = this.parseIcon(context, node); if (context.manifest.isForOfficeAppManifest()) { this.iconResId = context.parseIconResId(node); } this.superTip = context.parseRequiredSuperTip(node); var child = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "Action", node); CheckValueNotNullNorUndefined(child, "Action is necessary for itemControl."); var actionType = context.manifest.getNodeXsiType(child); var action; switch (actionType) { case "ShowTaskpane": action = new ShowTaskPaneAction(actionType, this.namespace); break; case "ExecuteFunction": var execAction = action = new ExecuteFunctionAction(actionType, this.namespace); execAction.controlId = this.id; break; default: throw new AddInManifestException("Unsupported action type."); } action.parse(context, child); this.actionType = actionType; this.action = action; var enabledNode = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "Enabled", node); if (enabledNode != null) { this.enabled = context.manifest._parseBooleanNode(enabledNode); } if (context.manifest.isForOfficeAppManifest()) { let labelChild = null; labelChild = context.manifest._xmlProcessor.selectSingleNode(context.namespace + "Label", node); this.labelResId = context.parseResId(labelChild); } } parseFromMos(context, control) { super.parseFromMos(context, control); this.icon = this.parseIconFromMos(context, control); this.superTip = context.parseRequiredSupertipFromMos(control); const child = context.manifest.getExtensionActionById(control.actionId); CheckValueNotNullNorUndefined(child, "Parsing from Mos: Action is necessary for itemControl."); const actionType = GetActionType(child); let action; switch (actionType) { case "ShowTaskpane": action = new ShowTaskPaneAction(actionType, this.namespace); break; case "ExecuteFunction": let execAction = action = new ExecuteFunctionAction(actionType, this.namespace); execAction.controlId = this.id; break; default: throw new AddInManifestException("Parsing from Mos: Unsupported action type."); } action.parseFromMos(context, child); this.actionType = actionType; this.action = action; this.enabled = control.enabled ? control.enabled : true; } applyControl(context, control) { throw new AddInInternalException("Not implemented method applyControl for ItemControl."); } parseIcon(context, node) { return context.parseIcon(node); } parseIconFromMos(context, node) { return context.parseIconFromMos(node); } } class Button extends ItemControl { applyControl(context, control) { context.controlBuilder.addButton(control); } parseIcon(context, node) { return context.parseRequiredIcon(node); } } class MenuItem extends ItemControl { constructor(namespace) { super("MenuItem", namespace); } applyControl(context, control) { context.controlBuilder.addMenuItem(control); } } class OfficeControl extends ItemControl { constructor() { super('OfficeControl'); this.label = null; this.icon = null; this.superTip = null; this.actionType = null; this.action = null; this.enabled = true; } apply(context) { var control = { id: this.id, label: this.label, icon: this.icon, superTip: this.superTip, actionType: this.actionType, action: this.action, enabled: this.enabled }; this.applyControl(context, control); } parse(context, node) { try { this.id = context.parseIdRequired(node); } catch (ex) { throw new AddInManifestException("Required id attribute missing for OfficeControl."); } if (OSF.RibbonControlIdMap && OSF.RibbonControlIdMap[this.id]) { this.id = OSF.RibbonControlIdMap[this.id]; } else if (!OSF.OUtil.checkFlight(OSF.FlightNames.AddinRibbonIdAllowUnknown)) { throw new AddInManifestException("Unsupported control id for OfficeControl."); } } parseFromMos(context, control) { this.id = control.builtInControlId; CheckValueNotNullNorUndefined(this.id, "Built in control id is required."); if (OSF.RibbonControlIdMap && OSF.RibbonControlIdMap[this.id]) { this.id = OSF.RibbonControlIdMap[this.id]; } else if (!OSF.OUtil.checkFlight(OSF.FlightNames.AddinRibbonIdAllowUnknown)) { throw new AddInManifestException("Unsupported control id for OfficeControl."); } } applyControl(context, control) { context.controlBuilder.addNativeControl(control); } } class RibbonTab { constructor(isOfficeTab, namespace) { this.label = null; this.isOfficeTab = false; this.visible = true; this.children = []; this.tabType = 'default'; this.insertBefore = ''; this.insertAfter = ''; this.autoFocus = false; this.isOfficeTab = isOfficeTab; this.namespace = OSF.GetNamespaceOrDefault(namespace); } apply(context) { context.builder.ribbonBuilder.startBuildTab(this); var len = this.children.length; for (var i = 0; i < len; i++) { var child = this.children[i]; child.apply(context); } context.builder.ribbonBuilder.endBuildTab(); } parse(context, node) { this.id = context.parseIdRequired(node); if (!this.isOfficeTab) { this.label = context.parseLabelRequired(node); if (OSF.Settings["IsReactRibbonEnabled"]) { this.insertBefore = context.getSingleNodeValue(this.namespace + "InsertBefore", node); this.insertAfter = context.getSingleNodeValue(this.namespace + "InsertAfter", node); if (this.insertBefore) { if (this.insertBefore === 'TabHome') { this.autoFocus = true; } context.insertBefore = this.insertBefore; } if (this.insertAfter) { context.insertAfter = this.insertAfter; } } } if (OSF.Settings["IsReactRibbonEnabled"]) { this.children = context.parseMultipleChildControls(["Group", "OfficeGroup"], node, (context, node) => { return context.parseGroupUnderTab(node); }); } else { this.children = context.parseMultipleChildControls(["Group"], node, (context, node) => { return context.parseGroupUnderTab(node); }); } } parseFromMos(context, tab) { if (!this.isOfficeTab) { this.id = context.parseIdRequiredFromMos(tab); this.label = context.parseLabelRequiredFromMos(tab); if (OSF.Settings["IsReactRibbonEnabled"]) { const insertPosition = tab.position.align; if (insertPosition === "before") { this.insertBefore = tab.position.builtInTabId; if (this.insertBefore != null) { if (this.insertBefore === 'TabHome') { this.autoFocus = true; } context.insertBefore = this.insertBefore; } } else if (insertPosition === "after") { this.insertAfter = tab.position.builtInTabId; if (this.insertAfter != null) { context.insertAfter = this.insertAfter; } } else { throw new AddInManifestException("Unsupported insert position"); } } } else { this.id = tab.builtInTabId; CheckValueNotNullNorUndefined(this.id, "Built in tab id is required."); } if (OSF.Settings["IsReactRibbonEnabled"]) { this.children = context.parseMultipleChildControlsFromMos(["Group", "OfficeGroup"], tab, (context, group) => { return context.parseGroupUnderTabFromMos(group); }); } else { this.children = context.parseMultipleChildControlsFromMos(["Group"], tab, (context, group) => { return context.parseGroupUnderTabFromMos(group); }); } } } class RibbonGroup extends UIEntityBase { constructor(hostType) { super(); this.groupType = 'Custom'; this.labelResId = null; this.hostType = hostType; } parse(context, node) { if (!context.shouldParseNode(node)) { return; } super.parse(context, node); if (context.manifest.isForOfficeAppManifest()) { let labelChild = null; labelChild = context.manifest._xmlProcessor.selectSingleNode(context.namespace + "Label", node); this.labelResId = context.parseResId(labelChild); } if (this.hostType === "MailHost") { this.icon = context.parseOptionalIcon(node); } else { this.icon = context.parseRequiredIcon(node); context.checkRequiredGroupIcons(this.icon); } if (context.manifest.isForOfficeAppManifest()) { this.iconResId = context.parseIconResId(node); } if (OSF.Settings["IsReactRibbonEnabled"]) { this.children = context.parseMultipleChildControls(["Control", "OfficeControl"], node, (context, node) => { return context.parseControlInGroup(node); }); } else { this.children = context.parseMultipleChildControls(["Control"], node, (context, node) => { return context.parseControlInGroup(node); }); } } parseFromMos(context, group) { if (!context.shouldParseNodeFromMos(group)) { return; } super.parseFromMos(context, group); if (this.hostType === "MailHost") { this.icon = context.parseOptionalIconFromMos(group); } else { this.icon = context.parseRequiredIconFromMos(group); context.checkRequiredGroupIcons(this.icon); } if (OSF.Settings["IsReactRibbonEnabled"]) { this.children = context.parseMultipleChildControlsFromMos(["Control", "OfficeControl"], group, (context, control) => { return context.parseControlInGroupFromMos(control); }); } else { this.children = context.parseMultipleChildControlsFromMos(["Control"], group, (context, control) => { return context.parseControlInGroupFromMos(control); }); } } apply(context) { context.builder.ribbonBuilder.startBuildGroup(this); BuildHelpers.buildControls({ functionFile: context.functionFile, actionBuilder: context.builder.actionBuilder, controlBuilder: context.builder.ribbonBuilder }, this.children); context.builder.ribbonBuilder.endBuildGroup(); } } class OfficeGroup extends RibbonGroup { constructor(hostType) { super(hostType); this.mlrId = ""; this.children = null; this.label = null; this.icon = null; this.groupType = 'OfficeGroup'; } parse(context, node) { try { this.id = context.parseIdRequired(node); } catch (ex) { throw new AddInManifestException("Required id attribute missing for OfficeGroup."); } if (OSF.RibbonGroupIdMap && OSF.RibbonGroupIdMap[this.id]) { if (OSF.RibbonGroupIdMapCommonMLR && OSF.RibbonGroupIdMapCommonMLR[this.id]) { this.mlrId = OSF.RibbonGroupIdMapCommonMLR[this.id]; } this.id = OSF.RibbonGroupIdMap[this.id]; } else if (!OSF.OUtil.checkFlight(OSF.FlightNames.AddinRibbonIdAllowUnknown)) { throw new AddInManifestException("Unsupported id for OfficeGroup."); } } parseFromMos(context, group) { this.id = group.builtInGroupId; CheckValueNotNullNorUndefined(this.id, "Built in group id is required."); if (OSF.RibbonGroupIdMap && OSF.RibbonGroupIdMap[this.id]) { if (OSF.RibbonGroupIdMapCommonMLR && OSF.RibbonGroupIdMapCommonMLR[this.id]) { this.mlrId = OSF.RibbonGroupIdMapCommonMLR[this.id]; } this.id = OSF.RibbonGroupIdMap[this.id]; } else if (!OSF.OUtil.checkFlight(OSF.FlightNames.AddinRibbonIdAllowUnknown)) { throw new AddInManifestException("Unsupported id for OfficeGroup."); } } apply(context) { context.builder.ribbonBuilder.addNativeGroup(this); } } class MobileExtensionPoint { constructor(type, namespace) { this.type = type; this.namespace = OSF.GetNamespaceOrDefault(namespace); } parse(context, node) { switch (this.type) { case "MobileMessageReadCommandSurface": let mobileGroupNode = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "Group", node); if (mobileGroupNode != null) { let mobileGroup = new MobileGroup(this.namespace); mobileGroup.parse(context, mobileGroupNode); this.group = mobileGroup; } break; case "MobileMessageComposeCommandSurface": case "MobileAppointmentOrganizerCommandSurface": case "MobileAppointmentAttendeeCommandSurface": break; case "MobileOnlineMeetingCommandSurface": case "MobileLogEventAppointmentAttendee": let mobileControlNode = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "Control", node); if (mobileControlNode != null) { let mobileControl = new MobileControl(this.namespace); mobileControl.parse(context, mobileControlNode); this.control = mobileControl; } break; default: throw new AddInManifestException("Unsupported Mobile extension type."); } } apply(context) { } parseFromMos(context) { } } class MobileGroup { constructor(namespace) { this.namespace = OSF.GetNamespaceOrDefault(namespace); } parse(context, node) { var labelNode = context.getLabelChildNode(node, this.namespace); if (labelNode) { this.labelResId = context.parseResId(labelNode); if (this.labelResId) { this.label = context.getShortString(labelNode); } } var controlNode = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "Control", node); if (controlNode) { this.control = new MobileControl(this.namespace); this.control.parse(context, controlNode); } } apply(context) { } parseFromMos(context) { } } class MobileControl { constructor(namespace) { this.namespace = OSF.GetNamespaceOrDefault(namespace); } parse(context, node) { var labelNode = context.getLabelChildNode(node, this.namespace); if (labelNode) { this.labelResId = context.parseResId(labelNode); if (this.labelResId) { this.label = context.getShortString(labelNode); } } var iconNode = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "Icon", node); if (iconNode) { this.icon = new MobileIcon(this.namespace); this.icon.parse(context, iconNode); } var child = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "Action", node); var actionType = context.manifest.getNodeXsiType(child); var action; switch (actionType) { case "ShowTaskpane": action = new ShowTaskPaneAction(actionType, this.namespace); break; case "ExecuteFunction": var execAction = action = new ExecuteFunctionAction(actionType, this.namespace); break; default: throw new AddInManifestException("Unsupported action type."); } if (action) { action.parse(context, child); this.actionType = actionType; this.action = action; } } apply(context) { } parseFromMos(context) { } } class MobileIcon { constructor(namespace) { this.namespace = OSF.GetNamespaceOrDefault(namespace); this.images = []; } parse(context, node) { let imageNodes = context.manifest._xmlProcessor.selectNodes("bt:Image", node); if (imageNodes) { let len = imageNodes.length; for (let i = 0; i < len; i++) { let imageNode = imageNodes[i]; if (imageNode != null) { let image = new MobileImage(this.namespace); image.parse(context, imageNode); this.images.push(image); } } } } apply(context) { } parseFromMos(context) { } } class MobileImage { constructor(namespace) { this.namespace = OSF.GetNamespaceOrDefault(namespace); } parse(context, node) { if (node) { this.size = node.getAttribute("size"); this.scale = node.getAttribute("scale"); this.resid = node.getAttribute("resid"); } } apply(context) { } parseFromMos(context) { } } class RibbonExtensionPoint { constructor(type, namespace) { this.type = type; this.tabs = []; this.namespace = OSF.GetNamespaceOrDefault(namespace); } apply(context) { if (this.type == context.builder.commandSurface) { var len = this.tabs.length; var officeTabCount = 0; var customTabCount = 0; for (var i = 0; i < len; i++) { var tab = this.tabs[i]; if (tab.isOfficeTab && officeTabCount < 1) { officeTabCount++; } else if (!tab.isOfficeTab && (customTabCount < 1 || context.multipleCustomTabsEnabled)) { customTabCount++; } else { break; } tab.apply(context); } } } parse(context, node) { let tabNode = context.manifest._xmlProcessor.selectSingleNode(this.namespace + "OfficeTab", node); if (tabNode != null) { let tab = new RibbonTab(true, this.namespace); tab.parse(context, tabNode); this.tabs.push(tab); } let tabNodes = context.manifest._xmlProcessor.selectNodes(this.namespace + "CustomTab", node); if (tabNodes) { let len = tabNodes.length; for (let i = 0; i < len; i++) { tabNode = tabNodes[i]; if (tabNode != null) { let tab = new RibbonTab(false, this.namespace); tab.parse(context, tabNode); this.tabs.push(tab); } } } if (typeof (otel) !== 'undefined' && typeof (otel.sendTelemetryEvent) !== 'undefined') { if (!OSF.OUtil.sendTelemetryEvent("Office.Online.Extensibility.Ribbon.OfficeGroupControlCount", [{ name: "OfficeControlCount", int64: context.officeControlCount }, { name: "OfficeGroupCount", int64: context.officeGroupCount }, { name: "InsertBefore", string: JSON.stringify(context.insertBefore) }, { name: "InsertAfter", string: JSON.stringify(context.insertAfter) }])) { otel.sendTelemetryEvent({ name: "Office.Online.Extensibility.Ribbon.OfficeGroupControlCount", dataFields: [ { name: "OfficeControlCount", int64: context.officeControlCount }, { name: "OfficeGroupCount", int64: context.officeGroupCount }, { name: "InsertBefore", string: JSON.stringify(context.insertBefore) }, { name: "InsertAfter", string: JSON.stringify(context.insertAfter) } ] }); } } } parseFromMos(context, tabs) { if (tabs != null) { for (const tab of tabs) { let newTab; if (tab.builtInTabId != null) { newTab = new RibbonTab(true); } else { newTab = new RibbonTab(false); } newTab.parseFromMos(context, tab); this.tabs.push(newTab); } } if (typeof (otel) !== 'undefined' && typeof (otel.sendTelemetryEvent) !== 'undefined') { if (!OSF.OUtil.sendTelemetryEvent("Office.Online.Extensibility.Ribbon.OfficeGroupControlCount", [{ name: "OfficeControlCount", int64: context.officeControlCount }, { name: "OfficeGroupCount", int64: context.officeGroupCount }, { name: "InsertBefore", string: JSON.stringify(context.insertBefore) }, { name: "InsertAfter", string: JSON.stringify(context.insertAfter) }])) { otel.sendTelemetryEvent({ name: "Office.Online.Extensibility.Ribbon.OfficeGroupControlCount", dataFields: [ { name: "OfficeControlCount", int64: context.officeControlCount }, { name: "OfficeGroupCount", int64: context.officeGroupCount }, { name: "InsertBefore", string: JSON.stringify(context.insertBefore) }, { name: "InsertAfter", string: JSON.stringify(context.insertAfter) } ] }); } } } } class OfficeMenuNode { constructor(namespace) { this.namespace = OSF.GetNamespaceOrDefault(namespace); } parse(context, node) { if (!context.shouldParseNode(node)) { return; } this.id = context.parseIdRequired(node); if (context.manifest.isForOfficeAppManifest()) { this.type = context.parseType(node); } this.children = context.parseChildControls(this.namespace + "Control", node, (context, node) => { return context.parseControlInGroup(node); }); } parseFromMos(context, menu) { if (!context.shouldParseNodeFromMos(menu)) { return; } this.id = context.getContextMenuType(menu); this.children = context.parseControlsFromMos(menu.controls, (context, control) => { return context.parseControlInGroupFromMos(control); }); } apply(context) { context.controlBuilder.startBuildMenu({ id: this.id, label: null, superTip: null }); BuildHelpers.buildControls(context, this.children); context.controlBuilder.endBuildMenu(); } } class ContextMenuExtensionPoint { constructor(type, namespace) { this.type = type; this.namespace = OSF.GetNamespaceOrDefault(namespace); } apply(context) { if (this.type == context.builder.commandSurface) { BuildHelpers.buildControls({ functionFile: context.functionFile, actionBuilder: context.builder.actionBuilder, controlBuilder: context.builder.contextMenuBuilder }, this.children); } } parse(context, node) { this.children = context.parseChildControls(this.namespace + "OfficeMenu", node, (context, node) => { var menu = new OfficeMenuNode(this.namespace); menu.parse(context, node); return menu; }); } parseFromMos(context, contextMenu) { this.children = context.parseChildControlsFromMos("OfficeMenu", contextMenu, (context, menu) => { let newMenu = new OfficeMenuNode(); newMenu.parseFromMos(context, menu); return newMenu; }); } } class CustomFunctionsExtensionPoint { constructor(type) { this.type = type; } apply(context) { } parse(context, node) { var namespaceNode = context.manifest._xmlProcessor.selectSingleNode("ov:Namespace", node); if (namespaceNode) { this.namespaceResId = namespaceNode.getAttribute("resid"); } var scriptNode = context.manifest._xmlProcessor.selectSingleNode("ov:Script", node); if (scriptNode) { this.scriptResId = this._parseSourceLocationResId(context, scriptNode); } if (!this.scriptResId) { throw new AddInManifestException("Missing required