UNPKG

@microsoft/office-js

Version:
48 lines (36 loc) • 229 kB
/* Office JavaScript API library - Custom Functions */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* This file incorporates the "whatwg-fetch" implementation, version 2.0.3, licensed under MIT with the following licensing notice: (See github.com/github/fetch/blob/master/LICENSE) Copyright (c) 2014-2016 GitHub, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* Your use of this file is governed by the Microsoft Services Agreement http://go.microsoft.com/fwlink/?LinkId=266419. This file also contains the following Promise implementation (with a few small modifications): * @overview es6-promise - a tiny implementation of Promises/A+. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @license Licensed under MIT license * See https://raw.githubusercontent.com/jakearchibald/es6-promise/master/LICENSE * @version 2.3.0 */ var OSF=OSF||{};OSF.ConstantNames={FileVersion:"0.0.0.0",OfficeJS:"custom-functions-runtime.js",OfficeDebugJS:"custom-functions-runtime.debug.js",HostFileScriptSuffix:"core",IsCustomFunctionsRuntime:true};var OSF=OSF||{};OSF.HostSpecificFileVersionDefault="16.00";OSF.HostSpecificFileVersionMap={access:{web:"16.00"},agavito:{winrt:"16.00"},excel:{ios:"16.00",mac:"16.00",web:"16.00",win32:"16.01",winrt:"16.00"},onenote:{android:"16.00",web:"16.00",win32:"16.00",winrt:"16.00"},outlook:{ios:"16.00",mac:"16.00",web:"16.01",win32:"16.02"},powerpoint:{ios:"16.00",mac:"16.00",web:"16.00",win32:"16.01",winrt:"16.00"},project:{win32:"16.00"},sway:{web:"16.00"},word:{ios:"16.00",mac:"16.00",web:"16.00",win32:"16.01",winrt:"16.00"},visio:{web:"16.00",win32:"16.00"}};OSF.SupportedLocales={"ar-sa":true,"bg-bg":true,"bn-in":true,"ca-es":true,"cs-cz":true,"da-dk":true,"de-de":true,"el-gr":true,"en-us":true,"es-es":true,"et-ee":true,"eu-es":true,"fa-ir":true,"fi-fi":true,"fr-fr":true,"gl-es":true,"he-il":true,"hi-in":true,"hr-hr":true,"hu-hu":true,"id-id":true,"it-it":true,"ja-jp":true,"kk-kz":true,"ko-kr":true,"lo-la":true,"lt-lt":true,"lv-lv":true,"ms-my":true,"nb-no":true,"nl-nl":true,"nn-no":true,"pl-pl":true,"pt-br":true,"pt-pt":true,"ro-ro":true,"ru-ru":true,"sk-sk":true,"sl-si":true,"sr-cyrl-cs":true,"sr-cyrl-rs":true,"sr-latn-cs":true,"sr-latn-rs":true,"sv-se":true,"th-th":true,"tr-tr":true,"uk-ua":true,"ur-pk":true,"vi-vn":true,"zh-cn":true,"zh-tw":true};OSF.AssociatedLocales={ar:"ar-sa",bg:"bg-bg",bn:"bn-in",ca:"ca-es",cs:"cs-cz",da:"da-dk",de:"de-de",el:"el-gr",en:"en-us",es:"es-es",et:"et-ee",eu:"eu-es",fa:"fa-ir",fi:"fi-fi",fr:"fr-fr",gl:"gl-es",he:"he-il",hi:"hi-in",hr:"hr-hr",hu:"hu-hu",id:"id-id",it:"it-it",ja:"ja-jp",kk:"kk-kz",ko:"ko-kr",lo:"lo-la",lt:"lt-lt",lv:"lv-lv",ms:"ms-my",nb:"nb-no",nl:"nl-nl",nn:"nn-no",pl:"pl-pl",pt:"pt-br",ro:"ro-ro",ru:"ru-ru",sk:"sk-sk",sl:"sl-si",sr:"sr-cyrl-cs",sv:"sv-se",th:"th-th",tr:"tr-tr",uk:"uk-ua",ur:"ur-pk",vi:"vi-vn",zh:"zh-cn"};OSF.getSupportedLocale=function(a,c){if(c===void 0)c="en-us";if(!a)return c;var b;a=a.toLowerCase();if(a in OSF.SupportedLocales)b=a;else{var d=a.split("-",1);if(d&&d.length>0)b=OSF.AssociatedLocales[d[0]]}if(!b)b=c;return b};var ScriptLoading;(function(e){var a=false,b=function(){function b(g,e,d,f,c){var b=this;b.url=g;b.isReady=e;b.hasStarted=d;b.timer=f;b.hasError=a;b.pendingCallbacks=[];b.pendingCallbacks.push(c)}return b}(),d=function(){function a(c,b,a){this.scriptId=c;this.startTime=b;this.msResponseTime=a}return a}(),c=function(){var e=true,c=null;function f(b){var a=this;if(b===void 0)b={OfficeJS:"office.js",OfficeDebugJS:"office.debug.js"};a.constantNames=b;a.defaultScriptLoadingTimeout=1e4;a.loadedScriptByIds={};a.scriptTelemetryBuffer=[];a.osfControlAppCorrelationId="";a.basePath=c;a.getUseAssociatedActionsOnly=c}f.prototype.isScriptLoading=function(a){return !!(this.loadedScriptByIds[a]&&this.loadedScriptByIds[a].hasStarted)};f.prototype.getOfficeJsBasePath=function(){var b=this;if(b.basePath)return b.basePath;else{var h=function(b,c){var d,a,e;e=b.toLowerCase();a=e.indexOf(c);if(a>=0&&a===b.length-c.length&&(a===0||b.charAt(a-1)==="/"||b.charAt(a-1)==="\\"))d=b.substring(0,a);else if(a>=0&&a<b.length-c.length&&b.charAt(a+c.length)==="?"&&(a===0||b.charAt(a-1)==="/"||b.charAt(a-1)==="\\"))d=b.substring(0,a);return d},d=document.getElementsByTagName("script"),i=d.length,f=[b.constantNames.OfficeJS,b.constantNames.OfficeDebugJS],g=f.length;b.getUseAssociatedActionsOnly=a;for(var e,c=0;!b.basePath&&c<i;c++)if(d[c].src)for(e=0;!b.basePath&&e<g;e++){b.basePath=h(d[c].src,f[e]);if(b.basePath)try{var j=d[c].getAttribute("data-use-associated-actions-only");b.getUseAssociatedActionsOnly=j==="1"}catch(k){}}return b.basePath}};f.prototype.getUseAssociatedActionsOnlyDefined=function(){this.getOfficeJsBasePath();return this.getUseAssociatedActionsOnly};f.prototype.loadScript=function(e,d,c,a,b){this.loadScriptInternal(e,d,c,a,b)};f.prototype.loadScriptParallel=function(e,d,b){this.loadScriptInternal(e,d,c,a,b)};f.prototype.waitForFunction=function(g,d,h,i){var b=h,f,c=function(){b--;if(g()){d(e);return}else if(b>0){f=window.setTimeout(c,i);b--}else{window.clearTimeout(f);d(a)}};c()};f.prototype.waitForScripts=function(b,e){var f=this;if(this.invokeCallbackIfScriptsReady(b,e)==a)for(var c=0;c<b.length;c++){var g=b[c],d=this.loadedScriptByIds[g];d&&d.pendingCallbacks.push(function(){f.invokeCallbackIfScriptsReady(b,e)})}};f.prototype.logScriptLoading=function(c,a,b){a=Math.floor(a);if(OSF.AppTelemetry&&OSF.AppTelemetry.onScriptDone)if(OSF.AppTelemetry.onScriptDone.length==3)OSF.AppTelemetry.onScriptDone(c,a,b);else OSF.AppTelemetry.onScriptDone(c,a,b,this.osfControlAppCorrelationId);else{var e=new d(c,a,b);this.scriptTelemetryBuffer.push(e)}};f.prototype.setAppCorrelationId=function(a){this.osfControlAppCorrelationId=a};f.prototype.invokeCallbackIfScriptsReady=function(h,j){for(var g=a,f=0;f<h.length;f++){var i=h[f],d=this.loadedScriptByIds[i];if(!d){d=new b("",a,a,c,c);this.loadedScriptByIds[i]=d}if(d.isReady==a)return a;else if(d.hasError)g=e}j(!g);return e};f.prototype.getScriptEntryByUrl=function(d){for(var b in this.loadedScriptByIds){var a=this.loadedScriptByIds[b];if(this.loadedScriptByIds.hasOwnProperty(b)&&a.url===d)return a}return c};f.prototype.loadScriptInternal=function(h,g,i,n,k){var j=this;if(h){var q=j,r=window.document,d=g&&j.loadedScriptByIds[g]?j.loadedScriptByIds[g]:j.getScriptEntryByUrl(h);if(!d||d.hasError||d.url.toLowerCase()!=h.toLowerCase()){var f=r.createElement("script");f.type="text/javascript";if(g)f.id=g;if(!d){d=new b(h,a,a,c,c);j.loadedScriptByIds[g?g:h]=d}else{d.url=h;d.hasError=a;d.isReady=a}if(i)if(n)d.pendingCallbacks.unshift(i);else d.pendingCallbacks.push(i);var l=-1;if(window.performance&&window.performance.now)l=window.performance.now();var s=(new Date).getTime(),o=function(b){if(g){var a=(new Date).getTime()-s;if(!b)a=-a;q.logScriptLoading(g,l,a)}q.flushTelemetryBuffer()},m=function(){if(!OSF._OfficeAppFactory.getLoggingAllowed()&&typeof OSF.AppTelemetry!=="undefined")OSF.AppTelemetry.enableTelemetry=a;o(e);d.isReady=e;if(d.timer!=c){clearTimeout(d.timer);delete d.timer}for(var g=d.pendingCallbacks.length,f=0;f<g;f++){var b=d.pendingCallbacks.shift();if(b){var h=b(e);if(h===a)break}}},p=function(){o(a);d.hasError=e;d.isReady=e;if(d.timer!=c){clearTimeout(d.timer);delete d.timer}for(var g=d.pendingCallbacks.length,f=0;f<g;f++){var b=d.pendingCallbacks.shift();if(b){var h=b(a);if(h===a)break}}};if(f.readyState)f.onreadystatechange=function(){if(f.readyState=="loaded"||f.readyState=="complete"){f.onreadystatechange=c;m()}};else f.onload=m;f.onerror=p;k=k||j.defaultScriptLoadingTimeout;d.timer=setTimeout(p,k);d.hasStarted=e;f.setAttribute("crossOrigin","anonymous");f.src=h;r.getElementsByTagName("head")[0].appendChild(f)}else if(d.isReady)i(e);else if(n)d.pendingCallbacks.unshift(i);else d.pendingCallbacks.push(i)}};f.prototype.flushTelemetryBuffer=function(){var b=this;if(OSF.AppTelemetry&&OSF.AppTelemetry.onScriptDone){for(var c=0;c<b.scriptTelemetryBuffer.length;c++){var a=b.scriptTelemetryBuffer[c];if(OSF.AppTelemetry.onScriptDone.length==3)OSF.AppTelemetry.onScriptDone(a.scriptId,a.startTime,a.msResponseTime);else OSF.AppTelemetry.onScriptDone(a.scriptId,a.startTime,a.msResponseTime,b.osfControlAppCorrelationId)}b.scriptTelemetryBuffer=[]}};return f}();e.LoadScriptHelper=c})(ScriptLoading||(ScriptLoading={}));var OfficeExt;(function(a){var b;(function(a){var b=function(){function a(){var a=this;a.getDiagnostics=function(b){var a={host:this.getHost(),version:b||this.getDefaultVersion(),platform:this.getPlatform()};return a};a.platformRemappings={web:Microsoft.Office.WebExtension.PlatformType.OfficeOnline,winrt:Microsoft.Office.WebExtension.PlatformType.Universal,win32:Microsoft.Office.WebExtension.PlatformType.PC,mac:Microsoft.Office.WebExtension.PlatformType.Mac,ios:Microsoft.Office.WebExtension.PlatformType.iOS,android:Microsoft.Office.WebExtension.PlatformType.Android};a.camelCaseMappings={powerpoint:Microsoft.Office.WebExtension.HostType.PowerPoint,onenote:Microsoft.Office.WebExtension.HostType.OneNote};a.hostInfo=OSF._OfficeAppFactory.getHostInfo();a.getHost=a.getHost.bind(a);a.getPlatform=a.getPlatform.bind(a);a.getDiagnostics=a.getDiagnostics.bind(a)}a.prototype.capitalizeFirstLetter=function(a){if(a)return a[0].toUpperCase()+a.slice(1).toLowerCase();return a};a.getInstance=function(){if(a.hostObj===undefined)a.hostObj=new a;return a.hostObj};a.prototype.getPlatform=function(){var a=this;if(a.hostInfo.hostPlatform){var b=a.hostInfo.hostPlatform.toLowerCase();if(a.platformRemappings[b])return a.platformRemappings[b]}return null};a.prototype.getHost=function(){var a=this;if(a.hostInfo.hostType){var b=a.hostInfo.hostType.toLowerCase();if(a.camelCaseMappings[b])return a.camelCaseMappings[b];b=a.capitalizeFirstLetter(a.hostInfo.hostType);if(Microsoft.Office.WebExtension.HostType[b])return Microsoft.Office.WebExtension.HostType[b]}return null};a.prototype.getDefaultVersion=function(){if(this.getHost())return "16.0.0000.0000";return null};return a}();a.Host=b})(b=a.HostName||(a.HostName={}))})(OfficeExt||(OfficeExt={}));var Office;(function(d){var a=true,b="undefined",c="function",e;(function(d){var e;(function(d){function e(){return function(){var d=null,e="object";"use strict";function Q(a){return typeof a===c||typeof a===e&&a!==d}function y(a){return typeof a===c}function T(a){return typeof a===e&&a!==d}var z;if(!Array.isArray)z=function(a){return Object.prototype.toString.call(a)==="[object Array]"};else z=Array.isArray;var D=z,r=0,pb={}.toString,jb,w,l=function(a,b){q[r]=a;q[r+1]=b;r+=2;if(r===2)if(w)w(p);else u()};function cb(a){w=a}function lb(a){l=a}var X=typeof window!==b?window:undefined,C=X||{},G=C.MutationObserver||C.WebKitMutationObserver,mb=typeof process!==b&&{}.toString.call(process)==="[object process]",kb=typeof Uint8ClampedArray!==b&&typeof importScripts!==b&&typeof MessageChannel!==b;function eb(){var b=process.nextTick,a=process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);if(Array.isArray(a)&&a[1]==="0"&&a[2]==="10")b=setImmediate;return function(){b(p)}}function O(){var a=new MessageChannel;a.port1.onmessage=p;return function(){a.port2.postMessage(0)}}function Y(){return function(){setTimeout(p,1)}}var q=new Array(1e3);function p(){for(var a=0;a<r;a+=2){var b=q[a],c=q[a+1];b(c);q[a]=undefined;q[a+1]=undefined}r=0}var u;if(mb)u=eb();else if(kb)u=O();else u=Y();function o(){}var k=void 0,m=1,j=2,s=new B;function K(){return new TypeError("You cannot resolve a promise with itself")}function L(){return new TypeError("A promises callback cannot return that same promise.")}function ab(b){try{return b.then}catch(a){s.error=a;return s}}function bb(e,d,b,c){try{e.call(d,b,c)}catch(a){return a}}function E(c,b,d){l(function(e){var c=false,g=bb(d,b,function(d){if(c)return;c=a;if(b!==d)n(e,d);else h(e,d)},function(b){if(c)return;c=a;f(e,b)},"Settle: "+(e._label||" unknown promise"));if(!c&&g){c=a;f(e,g)}},c)}function H(b,a){if(a._state===m)h(b,a._result);else if(a._state===j)f(b,a._result);else t(a,undefined,function(a){n(b,a)},function(a){f(b,a)})}function F(b,a){if(a.constructor===b.constructor)H(b,a);else{var c=ab(a);if(c===s)f(b,s.error);else if(c===undefined)h(b,a);else if(y(c))E(b,a,c);else h(b,a)}}function n(a,b){if(a===b)f(a,K());else if(Q(b))F(a,b);else h(a,b)}function J(a){a._onerror&&a._onerror(a._result);x(a)}function h(a,b){if(a._state!==k)return;a._result=b;a._state=m;a._subscribers.length!==0&&l(x,a)}function f(a,b){if(a._state!==k)return;a._state=j;a._result=b;l(J,a)}function t(c,g,e,f){var a=c._subscribers,b=a.length;c._onerror=d;a[b]=g;a[b+m]=e;a[b+j]=f;b===0&&c._state&&l(x,c)}function x(b){var a=b._subscribers,f=b._state;if(a.length===0)return;for(var e,d,g=b._result,c=0;c<a.length;c+=3){e=a[c];d=a[c+f];if(e)A(f,e,d,g);else d(g)}b._subscribers.length=0}function B(){this.error=d}var v=new B;function W(b,c){try{return b(c)}catch(a){v.error=a;return v}}function A(l,c,i,o){var g=y(i),b,q,e,p;if(g){b=W(i,o);if(b===v){p=a;q=b.error;b=d}else e=a;if(c===b){f(c,L());return}}else{b=o;e=a}if(c._state===k)if(g&&e)n(c,b);else if(p)f(c,q);else if(l===m)h(c,b);else l===j&&f(c,b)}function I(a,c){try{c(function(b){n(a,b)},function(b){f(a,b)})}catch(b){f(a,b)}}function i(c,b){var a=this;a._instanceConstructor=c;a.promise=new c(o);if(a._validateInput(b)){a._input=b;a.length=b.length;a._remaining=b.length;a._init();if(a.length===0)h(a.promise,a._result);else{a.length=a.length||0;a._enumerate();a._remaining===0&&h(a.promise,a._result)}}else f(a.promise,a._validationError())}i.prototype._validateInput=function(a){return D(a)};i.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")};i.prototype._init=function(){this._result=new Array(this.length)};var Z=i;i.prototype._enumerate=function(){for(var a=this,d=a.length,c=a.promise,e=a._input,b=0;c._state===k&&b<d;b++)a._eachEntry(e[b],b)};i.prototype._eachEntry=function(a,c){var b=this,e=b._instanceConstructor;if(T(a))if(a.constructor===e&&a._state!==k){a._onerror=d;b._settledAt(a._state,c,a._result)}else b._willSettleAt(e.resolve(a),c);else{b._remaining--;b._result[c]=a}};i.prototype._settledAt=function(d,e,c){var a=this,b=a.promise;if(b._state===k){a._remaining--;if(d===j)f(b,c);else a._result[e]=c}a._remaining===0&&h(b,a._result)};i.prototype._willSettleAt=function(c,b){var a=this;t(c,undefined,function(c){a._settledAt(m,b,c)},function(c){a._settledAt(j,b,c)})};function ib(a){return (new Z(this,a)).promise}var V=ib;function db(b){var d=this,a=new d(o);if(!D(b)){f(a,new TypeError("You must pass an array to race."));return a}var h=b.length;function e(b){n(a,b)}function g(b){f(a,b)}for(var c=0;a._state===k&&c<h;c++)t(d.resolve(b[c]),undefined,e,g);return a}var U=db;function N(a){var b=this;if(a&&typeof a===e&&a.constructor===b)return a;var c=new b(o);n(c,a);return c}var M=N;function S(c){var b=this,a=new b(o);f(a,c);return a}var P=S,gb=0;function R(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function fb(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}var hb=g;function g(b){var a=this;a._id=gb++;a._state=undefined;a._result=undefined;a._subscribers=[];if(o!==b){!y(b)&&R();!(a instanceof g)&&fb();I(a,b)}}g.all=V;g.race=U;g.resolve=M;g.reject=P;g._setScheduler=cb;g._setAsap=lb;g._asap=l;g.prototype={constructor:g,then:function(d,e){var b=this,a=b._state;if(a===m&&!d||a===j&&!e)return this;var c=new this.constructor(o),g=b._result;if(a){var f=arguments[a-1];l(function(){A(a,c,f,g)})}else t(b,c,d,e);return c},"catch":function(a){return this.then(d,a)}};return hb}.call(this)}d.Init=e})(e=d.PromiseImpl||(d.PromiseImpl={}))})(e=d._Internal||(d._Internal={}));(function(d){function f(){var b=window.navigator.userAgent,c=b.indexOf("Edge/");if(c>=0){b=b.substring(c+5,b.length);if(b<"14.14393")return a;else return false}return false}function e(){if(typeof window===b&&typeof Promise===c)return Promise;if(typeof window!==b&&window.Promise)if(f())return d.PromiseImpl.Init();else return window.Promise;else return d.PromiseImpl.Init()}d.OfficePromise=e()})(e=d._Internal||(d._Internal={}));var f=e.OfficePromise;d.Promise=f})(Office||(Office={}));var OTel;(function(c){var a="telemetry/oteljs_agave.js",b=function(){var c="undefined";function b(){}b.loaded=function(){return !(b.logger===undefined||b.sink===undefined)};b.getOtelSinkCDNLocation=function(){return OSF._OfficeAppFactory.getLoadScriptHelper().getOfficeJsBasePath()+a};b.getMapName=function(b,a){if(a!==undefined&&b.hasOwnProperty(a))return b[a];return a};b.getHost=function(){var c=OSF._OfficeAppFactory.getHostInfo()["hostType"],d={excel:"Excel",onenote:"OneNote",outlook:"Outlook",powerpoint:"PowerPoint",project:"Project",visio:"Visio",word:"Word"},a=b.getMapName(d,c);return a};b.getFlavor=function(){var c=OSF._OfficeAppFactory.getHostInfo()["hostPlatform"],d={android:"Android",ios:"iOS",mac:"Mac",universal:"Universal",web:"Web",win32:"Win32"},a=b.getMapName(d,c);return a};b.ensureValue=function(a,b){if(!a)return b;return a};b.create=function(a){var i={id:a.appId,marketplaceType:a.marketplaceType,assetId:a.assetId,officeJsVersion:a.officeJSVersion,hostJsVersion:a.hostJSVersion,browserToken:a.clientId,instanceId:a.appInstanceId,sessionId:a.sessionId},k=oteljs.Contracts.Office.System.SDX.getFields("SDX",i),l=b.getHost(),e=b.getFlavor(),j=e==="Web"&&a.hostVersion.slice(0,2)==="0."?"16.0.0.0":a.hostVersion,d={"App.Name":l,"App.Platform":e,"App.Version":j,"Session.Id":b.ensureValue(a.correlationId,"00000000-0000-0000-0000-000000000000")},h="Office.Extensibility.OfficeJs",g="db334b301e7b474db5e0f02f07c51a47-a1b5bc36-1bbe-482f-a64a-c2d9cb606706-7439",f=1755,c=new oteljs.SimpleTelemetryLogger(undefined,k);c.setTenantToken(h,g,f);if(oteljs.AgaveSink)b.sink=oteljs.AgaveSink.createInstance(d);if(b.sink===undefined)b.attachLegacyAgaveSink(d);else c.addSink(b.sink);return c};b.attachLegacyAgaveSink=function(e){var d=function(){if(typeof oteljs_agave!==c)b.sink=oteljs_agave.AgaveSink.createInstance(e);if(b.sink===undefined||b.logger===undefined){b.Enabled=false;b.promises=[];b.logger=undefined;b.sink=undefined;return}b.logger.addSink(b.sink);b.promises.forEach(function(a){a()})},a=5e3;OSF.OUtil.loadScript(b.getOtelSinkCDNLocation(),d,a)};b.initialize=function(d){if(!b.Enabled){b.promises=[];return}var a=function(){if(typeof oteljs===c)return;if(!b.loaded())b.logger=b.create(d);b.loaded()&&b.promises.forEach(function(a){a()})};Microsoft.Office.WebExtension.onReadyInternal().then(function(){return a()})};b.sendTelemetryEvent=function(a){b.onTelemetryLoaded(function(){try{b.logger.sendTelemetryEvent(a)}catch(c){}})};b.sendCustomerContent=function(a){b.onTelemetryLoaded(function(){try{b.logger.sendCustomerContent(a)}catch(c){}})};b.onTelemetryLoaded=function(a){if(!b.Enabled)return;if(b.loaded())a();else b.promises.push(a)};b.promises=[];b.Enabled=true;return b}();c.OTelLogger=b})(OTel||(OTel={}));(function(b){var a=function(){function a(){this.m_mappings={};this.m_onchangeHandlers=[]}a.prototype.associate=function(){var a="[InvalidArg] Function=associate",b=this;function c(a){typeof console!=="undefined"&&console.warn&&console.warn(a)}if(arguments.length==1&&typeof arguments[0]==="object"&&arguments[0]){var g=arguments[0];for(var i in g)b.associate(i,g[i])}else if(arguments.length==2){var d=arguments[0],h=arguments[1];if(typeof d!=="string"){c(a);return}if(typeof h!=="function"){c(a);return}var f=d.toUpperCase();b.m_mappings[f]&&c("[DuplicatedName] Function="+d);b.m_mappings[f]=h;for(var e=0;e<b.m_onchangeHandlers.length;e++)b.m_onchangeHandlers[e]()}else c(a)};a.prototype.onchange=function(a){a&&this.m_onchangeHandlers.push(a)};Object.defineProperty(a.prototype,"mappings",{"get":function(){return this.m_mappings},enumerable:true,configurable:true});return a}();b.Association=a})(OfficeExt||(OfficeExt={}));var CustomFunctionMappings=window.CustomFunctionMappings||{},CustomFunctions;(function(a){var b="__delay__";function c(){CustomFunctionMappings[b]=true}a.delayInitialization=c;a._association=new OfficeExt.Association;function d(){a._association.associate.apply(a._association,arguments);delete CustomFunctionMappings[b]}a.associate=d})(CustomFunctions||(CustomFunctions={}));(function(a){var b;(function(a){a._association=new OfficeExt.Association;function b(){a._association.associate.apply(a._association,arguments)}a.associate=b})(b=a.actions||(a.actions={}))})(Office||(Office={}));var g_isExpEnabled=g_isExpEnabled||false,g_isOfflineLibrary=g_isOfflineLibrary||false;(function(){var a=OSF.ConstantNames||{};OSF.ConstantNames={FileVersion:"0.0.0.0",OfficeJS:"office.js",OfficeDebugJS:"office.debug.js",DefaultLocale:"en-us",LocaleStringLoadingTimeout:5e3,MicrosoftAjaxId:"MSAJAX",OfficeStringsId:"OFFICESTRINGS",OfficeJsId:"OFFICEJS",HostFileId:"HOST",O15MappingId:"O15Mapping",OfficeStringJS:"office_strings.js",O15InitHelper:"o15apptofilemappingtable.js",SupportedLocales:OSF.SupportedLocales,AssociatedLocales:OSF.AssociatedLocales,ExperimentScriptSuffix:"experiment"};for(var b in a)OSF.ConstantNames[b]=a[b]})();OSF.InitializationHelper=function(d,b,f,e,c){var a=this;a._hostInfo=d;a._webAppState=b;a._context=f;a._settings=e;a._hostFacade=c};OSF.InitializationHelper.prototype.saveAndSetDialogInfo=function(){};OSF.InitializationHelper.prototype.getAppContext=function(){};OSF.InitializationHelper.prototype.setAgaveHostCommunication=function(){};OSF.InitializationHelper.prototype.prepareRightBeforeWebExtensionInitialize=function(){};OSF.InitializationHelper.prototype.loadAppSpecificScriptAndCreateOM=function(){};OSF.InitializationHelper.prototype.prepareRightAfterWebExtensionInitialize=function(){};OSF.HostInfoFlags={SharedApp:1,CustomFunction:2,ProtectedDocDisable:4,ExperimentJsEnabled:8,PublicAddin:16};OSF._OfficeAppFactory=function(){var m="_host_Info",g="function",a="undefined",f="",d=true,e=false,b=null,o=function(b,a){if(a&&b&&!a[b])a[b]={}};o("Office",window);o("Microsoft",window);o("Office",Microsoft);o("WebExtension",Microsoft.Office);if(typeof window.Office==="object")for(var s in window.Office)if(window.Office.hasOwnProperty(s))Microsoft.Office.WebExtension[s]=window.Office[s];window.Office=Microsoft.Office.WebExtension;var y={0:"Unknown",1:"Hidden",2:"Taskpane",3:"Dialog"};Microsoft.Office.WebExtension.PlatformType={PC:"PC",OfficeOnline:"OfficeOnline",Mac:"Mac",iOS:"iOS",Android:"Android",Universal:"Universal"};Microsoft.Office.WebExtension.HostType={Word:"Word",Excel:"Excel",PowerPoint:"PowerPoint",Outlook:"Outlook",OneNote:"OneNote",Project:"Project",Access:"Access",Visio:"Visio"};var r={},H={},q={},j={id:b,webAppUrl:b,conversationID:b,clientEndPoint:b,wnd:window.parent,focused:e},c={isO15:d,isRichClient:d,hostType:f,hostPlatform:f,hostSpecificFileVersion:f,hostLocale:f,osfControlAppCorrelationId:f,isDialog:e,disableLogging:e,flags:0},l=d,i={},w=b,v=e,n=[],u=e,k={host:b,platform:b,addin:b},h=new ScriptLoading.LoadScriptHelper({OfficeJS:OSF.ConstantNames.OfficeJS,OfficeDebugJS:OSF.ConstantNames.OfficeDebugJS});window.performance&&window.performance.now&&h.logScriptLoading(OSF.ConstantNames.OfficeJsId,-1,window.performance.now());var C=window.location.hash,B=window.location.search,x=window.name,t=function(b){var f=b.host,c=b.platform,e=b.addin;v=d;if(typeof OSFPerformance!==a)OSFPerformance.officeOnReady=OSFPerformance.now();k={host:f,platform:c,addin:e};while(n.length>0)n.shift()(k)};Microsoft.Office.WebExtension.FeatureGates={};Microsoft.Office.WebExtension.sendTelemetryEvent=function(a){OTel.OTelLogger.sendTelemetryEvent(a)};Microsoft.Office.WebExtension.telemetrySink=OTel.OTelLogger;Microsoft.Office.WebExtension.onReadyInternal=function(a){if(v){var e=k.host,c=k.platform,d=k.addin;if(a){var b=a({host:e,platform:c,addin:d});if(b&&b.then&&typeof b.then===g)return b.then(function(){return Office.Promise.resolve({host:e,platform:c,addin:d})})}return Office.Promise.resolve({host:e,platform:c,addin:d})}if(a)return new Office.Promise(function(b){n.push(function(d){var c=a(d);if(c&&c.then&&typeof c.then===g)return c.then(function(){return b(d)});b(d)})});return new Office.Promise(function(a){n.push(a)})};Microsoft.Office.WebExtension.onReady=function(a){u=d;return Microsoft.Office.WebExtension.onReadyInternal(a)};var p=function(g){var c,d=window.location.search;if(d){var b=d.split(g+"=");if(b.length>1){var e=b[1],f=new RegExp("[&#]","g"),a=e.split(f);if(a.length>0)c=a[0]}}return c},F=function(f,g){var b=f.split("."),c=g.split("."),a;for(a in b)if(parseInt(b[a])<parseInt(c[a]))return e;else if(parseInt(b[a])>parseInt(c[a]))return d;return e},z=function(){try{var b="15.30.1128.0",a=window.external.GetContext().GetHostFullVersion()}catch(c){return e}return !!F(b,a)},A=function(){l=d;try{if(c.disableLogging){l=e;return}window.external=window.external||{};if(typeof window.external.GetLoggingAllowed===a)l=d;else l=window.external.GetLoggingAllowed()}catch(b){}},E=function(){var i="hostInfoValue",l="isDialog",o=m,h=b;try{window.external=window.external||{};if(typeof agaveHost!==a&&agaveHost.GetHostInfo)window.external.GetHostInfo=function(){return agaveHost.GetHostInfo()};var k=window.external.GetHostInfo();if(k==l){c.isO15=d;c.isDialog=d}else if(k.toLowerCase().indexOf("mac")!==-1&&k.toLowerCase().indexOf("outlook")!==-1&&z())c.isO15=d;else{var q=k.split(o+"=");if(q.length>1)h=q[1];else h=k}}catch(s){}if(!h){h=p(o);if(!h)try{var r=JSON.parse(x);h=r?r["hostInfo"]:b}catch(s){}}var u=function(){var a=b;try{if(window.sessionStorage)a=window.sessionStorage}catch(c){}return a},j=u();if(!h&&j&&j.getItem(i))h=j.getItem(i);if(h){h=decodeURIComponent(h);c.isO15=e;var g=h.split("$");if(typeof g[2]==a)g=h.split("|");c.hostType=typeof g[0]==a?f:g[0].toLowerCase();c.hostPlatform=typeof g[1]==a?f:g[1].toLowerCase();c.hostSpecificFileVersion=typeof g[2]==a?f:g[2].toLowerCase();c.hostLocale=typeof g[3]==a?f:g[3].toLowerCase();c.osfControlAppCorrelationId=typeof g[4]==a?f:g[4];if(c.osfControlAppCorrelationId=="telemetry")c.osfControlAppCorrelationId=f;c.isDialog=typeof g[5]!=a&&g[5]==l?d:e;c.disableLogging=typeof g[6]!=a&&g[6]=="disableLogging"?d:e;c.flags=typeof g[7]==="string"&&g[7].length>0?parseInt(g[7]):0;if(g_isOfflineLibrary)g_isExpEnabled=e;else g_isExpEnabled=g_isExpEnabled||!!(c.flags&OSF.HostInfoFlags.ExperimentJsEnabled);var t=parseFloat(c.hostSpecificFileVersion),n=OSF.HostSpecificFileVersionDefault;if(OSF.HostSpecificFileVersionMap[c.hostType]&&OSF.HostSpecificFileVersionMap[c.hostType][c.hostPlatform])n=OSF.HostSpecificFileVersionMap[c.hostType][c.hostPlatform];if(t>parseFloat(n))c.hostSpecificFileVersion=n;if(j)try{j.setItem(i,h)}catch(v){}}else{c.isO15=d;c.hostLocale=p("locale")}},D=function(b,a){OSF.AppTelemetry&&OSF.AppTelemetry.logAppCommonMessage&&OSF.AppTelemetry.logAppCommonMessage("getAppContextAsync starts");i.getAppContext(b,a)},G=function(){E();A();if(c.hostPlatform=="web"&&c.isDialog&&window==window.top&&window.opener==b){window.open(f,"_self",f);window.close()}if((c.flags&(OSF.HostInfoFlags.SharedApp|OSF.HostInfoFlags.CustomFunction))!==0)if(typeof window.Promise===a)window.Promise=window.Office.Promise;h.setAppCorrelationId(c.osfControlAppCorrelationId);var k=h.getOfficeJsBasePath(),B=e;if(!k)throw"Office Web Extension script library file name should be "+OSF.ConstantNames.OfficeJS+" or "+OSF.ConstantNames.OfficeDebugJS+".";var n=function(){if(typeof Sys!==a&&typeof Type!==a&&Sys.StringBuilder&&typeof Sys.StringBuilder===g&&Type.registerNamespace&&typeof Type.registerNamespace===g&&Type.registerClass&&typeof Type.registerClass===g||typeof OfficeExt!==a&&OfficeExt.MsAjaxError)return d;else return e},o=b,v=function(f){var b=e,c=function(){if(typeof Strings==a||typeof Strings.OfficeOM==a)if(!b){b=d;var g=k+OSF.ConstantNames.DefaultLocale+"/"+OSF.ConstantNames.OfficeStringJS;h.loadScript(g,OSF.ConstantNames.OfficeStringsId,c,d,OSF.ConstantNames.LocaleStringLoadingTimeout);return e}else throw"Neither the locale, "+f.toLowerCase()+", provided by the host app nor the fallback locale "+OSF.ConstantNames.DefaultLocale+" are supported.";else{b=e;o=Strings.OfficeOM}};if(!n()){window.Type=Function;Type.registerNamespace=function(a){window[a]=window[a]||{}};Type.prototype.registerClass=function(a){a={}}}var g=k+OSF.getSupportedLocale(f,OSF.ConstantNames.DefaultLocale)+"/"+OSF.ConstantNames.OfficeStringJS;h.loadScript(g,OSF.ConstantNames.OfficeStringsId,c,d,OSF.ConstantNames.LocaleStringLoadingTimeout)},s=function(s){if(s){i=new OSF.InitializationHelper(c,j,r,H,q);c.hostPlatform=="web"&&i.saveAndSetDialogInfo&&i.saveAndSetDialogInfo(p(m));i.setAgaveHostCommunication();if(typeof OSFPerformance!==a)OSFPerformance.getAppContextStart=OSFPerformance.now();D(j.wnd,function(d){if(typeof OSFPerformance!==a)OSFPerformance.getAppContextEnd=OSFPerformance.now();OSF.AppTelemetry&&OSF.AppTelemetry.logAppCommonMessage&&OSF.AppTelemetry.logAppCommonMessage("getAppContextAsync callback start");w=d._appInstanceId;if(d.get_featureGates){var e=d.get_featureGates();if(e)Microsoft.Office.WebExtension.FeatureGates=e}var f=function(){var a=c.hostSpecificFileVersion.split(".");if(d.get_appMinorVersion){var b=c.hostPlatform=="ios";if(!b)if(isNaN(d.get_appMinorVersion()))d._appMinorVersion=parseInt(a[1]);else if(a.length>1&&!isNaN(Number(a[1])))d._appMinorVersion=parseInt(a[1])}if(c.isDialog)d._isDialog=c.isDialog};f();var j=function(){i.prepareApiSurface&&i.prepareApiSurface(d);h.waitForFunction(function(){return Microsoft.Office.WebExtension.initialize!=undefined||u},function(f){if(f){if(i.prepareApiSurface)Microsoft.Office.WebExtension.initialize&&Microsoft.Office.WebExtension.initialize(i.getInitializationReason(d));else{if(!Microsoft.Office.WebExtension.initialize)Microsoft.Office.WebExtension.initialize=function(){};i.prepareRightBeforeWebExtensionInitialize(d)}i.prepareRightAfterWebExtensionInitialize&&i.prepareRightAfterWebExtensionInitialize(d);var e=d.get_appName(),a=b;if((c.flags&OSF.HostInfoFlags.SharedApp)!==0)a={visibilityMode:y[d.get_initialDisplayMode&&typeof d.get_initialDisplayMode===g?d.get_initialDisplayMode():0]};t({host:OfficeExt.HostName.Host.getInstance().getHost(e),platform:OfficeExt.HostName.Host.getInstance().getPlatform(e),addin:a})}else throw new Error('Office.js has not fully loaded. Your app must call "Office.onReady()" as part of it\'s loading sequence (or set the "Office.initialize" function). If your app has this functionality, try reloading this page.')},400,50)};!h.isScriptLoading(OSF.ConstantNames.OfficeStringsId)&&v(d.get_appUILocale());h.waitForScripts([OSF.ConstantNames.OfficeStringsId],function(){if(o&&!Strings.OfficeOM)Strings.OfficeOM=o;i.loadAppSpecificScriptAndCreateOM(d,j,k);if(typeof OSFPerformance!==a)OSFPerformance.createOMEnd=OSFPerformance.now()})});if(c.isO15){var n=OSF.OUtil.parseXdmInfo()==b;if(n){var f=d;if(window.external&&typeof window.external.GetContext!==a)try{window.external.GetContext();f=e}catch(x){}if(typeof OsfOptOut===a&&f&&window.top!==window.self){window.console&&window.console.log&&window.console.log("The add-in is not hosted in plain browser top window.");window.location.href="about:blank"}f&&t({host:b,platform:b,addin:b})}}}else{var l="MicrosoftAjax.js is not loaded successfully.";OSF.AppTelemetry&&OSF.AppTelemetry.logAppException&&OSF.AppTelemetry.logAppException(l);throw l}},x=function(){OSF.AppTelemetry&&OSF.AppTelemetry.setOsfControlAppCorrelationId&&OSF.AppTelemetry.setOsfControlAppCorrelationId(c.osfControlAppCorrelationId);if(h.isScriptLoading(OSF.ConstantNames.MicrosoftAjaxId))h.waitForScripts([OSF.ConstantNames.MicrosoftAjaxId],s);else h.waitForFunction(n,s,500,100)};if(c.isO15)h.loadScript(k+OSF.ConstantNames.O15InitHelper,OSF.ConstantNames.O15MappingId,x);else{var l;l=[c.hostType,c.hostPlatform,c.hostSpecificFileVersion,OSF.ConstantNames.HostFileScriptSuffix||b].filter(function(a){return a!=b}).join("-")+".js";h.loadScript(k+l.toLowerCase(),OSF.ConstantNames.HostFileId,x);if(typeof OSFPerformance!==a)OSFPerformance.hostSpecificFileName=l.toLowerCase()}c.hostLocale&&v(c.hostLocale);if(B&&!n()){var C=(window.location.protocol.toLowerCase()==="https:"?"https:":"http:")+"//ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js";h.loadScriptParallel(C,OSF.ConstantNames.MicrosoftAjaxId)}window.confirm=function(){throw new Error("Function window.confirm is not supported.")};window.alert=function(){throw new Error("Function window.alert is not supported.")};window.prompt=function(){throw new Error("Function window.prompt is not supported.")};var z=c.hostType=="outlook"&&c.hostPlatform=="android";if(!z){window.history.replaceState=b;window.history.pushState=b}};G();window.addEventListener&&window.addEventListener("DOMContentLoaded",function(){Microsoft.Office.WebExtension.onReadyInternal(function(){typeof OSFPerfUtil!==a&&OSFPerfUtil.sendPerformanceTelemetry()})});return {getId:function(){return j.id},getClientEndPoint:function(){return j.clientEndPoint},getContext:function(){return r},setContext:function(a){r=a},getHostInfo:function(){return c},getLoggingAllowed:function(){return l},getHostFacade:function(){return q},setHostFacade:function(a){q=a},getInitializationHelper:function(){return i},getCachedSessionSettingsKey:function(){return (j.conversationID!=b?j.conversationID:w)+"CachedSessionSettings"},getWebAppState:function(){return j},getWindowLocationHash:function(){return C},getWindowLocationSearch:function(){return B},getLoadScriptHelper:function(){return h},getWindowName:function(){return x}}}() !function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0}),t.TestUtility=t.CoreUtility=t.RichApiMessageUtility=t.CoreConstants=t.CoreResourceStrings=t.CoreErrorCodes=t.Provider=t.Attribution=t.WebImage=t.Entity=t.FormattedNumber=t.Error=t._Internal=t.HostBridge=t.HttpUtility=t.SessionBase=void 0;var i=function(){function e(){}return e.prototype._resolveRequestUrlAndHeaderInfo=function(){return f._createPromiseFromResult(null)},e.prototype._createRequestExecutorOrNull=function(){return null},Object.defineProperty(e.prototype,"eventRegistration",{get:function(){return null},enumerable:!1,configurable:!0}),e}();t.SessionBase=i;var s=function(){function e(){}return e.setCustomSendRequestFunc=function(t){e.s_customSendRequestFunc=t},e.xhrSendRequestFunc=function(e){return f.createPromise((function(t,n){var r=new XMLHttpRequest;if(r.open(e.method,e.url),r.onload=function(){var e={statusCode:r.status,headers:f._parseHttpResponseHeaders(r.getAllResponseHeaders()),body:r.responseText};t(e)},r.onerror=function(){n(new a.RuntimeError({code:c.connectionFailure,httpStatusCode:r.status,message:f._getResourceString(l.connectionFailureWithStatus,r.statusText)}))},e.headers)for(var o in e.headers)r.setRequestHeader(o,e.headers[o]);r.send(f._getRequestBodyText(e))}))},e.fetchSendRequestFunc=function(e){var t=f._getRequestBodyText(e);return""===t&&(t=void 0),fetch(e.url,{method:e.method,headers:e.headers,body:t}).then((function(e){return e.text().then((function(t){var n=e.status,r={};return e.headers.forEach((function(e,t){r[t]=e})),{statusCode:n,headers:r,body:t}}))}))},e.sendRequest=function(t){e.validateAndNormalizeRequest(t);var n=e.s_customSendRequestFunc;return n||(n="undefined"!=typeof fetch?e.fetchSendRequestFunc:e.xhrSendRequestFunc),n(t)},e.setCustomSendLocalDocumentRequestFunc=function(t){e.s_customSendLocalDocumentRequestFunc=t},e.sendLocalDocumentRequest=function(t){return e.validateAndNormalizeRequest(t),(e.s_customSendLocalDocumentRequestFunc||e.officeJsSendLocalDocumentRequestFunc)(t)},e.officeJsSendLocalDocumentRequestFunc=function(e){e=f._validateLocalDocumentRequest(e);var t=f._buildRequestMessageSafeArray(e);return f.createPromise((function(e,n){OSF.DDA.RichApi.executeRichApiRequestAsync(t,(function(t){var n;n="succeeded"==t.status?{statusCode:p.getResponseStatusCode(t),headers:p.getResponseHeaders(t),body:p.getResponseBody(t)}:p.buildHttpResponseFromOfficeJsError(t.error.code,t.error.message),f.log("Response:"),f.log(JSON.stringify(n)),e(n)}))}))},e.validateAndNormalizeRequest=function(e){if(f.isNullOrUndefined(e))throw a.RuntimeError._createInvalidArgError({argumentName:"request"});f.isNullOrEmptyString(e.method)&&(e.method="GET"),e.method=e.method.toUpperCase()},e.logRequest=function(t){if(f._logEnabled){if(f.log("---HTTP Request---"),f.log(t.method+" "+t.url),t.headers)for(var n in t.headers)f.log(n+": "+t.headers[n]);e._logBodyEnabled&&f.log(f._getRequestBodyText(t))}},e.logResponse=function(t){if(f._logEnabled){if(f.log("---HTTP Response---"),f.log(""+t.statusCode),t.headers)for(var n in t.headers)f.log(n+": "+t.headers[n]);e._logBodyEnabled&&f.log(t.body)}},e._logBodyEnabled=!1,e}();t.HttpUtility=s;var a,u=function(){function e(e){var t=this;this.m_bridge=e,this.m_promiseResolver={},this.m_handlers=[],this.m_bridge.onMessageFromHost=function(e){var n=JSON.parse(e);if(3==n.type){var r=n.message;if(r&&r.entries)for(var o=0;o<r.entries.length;o++){var i=r.entries[o];if(Array.isArray(i)){var s={messageCategory:i[0],messageType:i[1],targetId:i[2],message:i[3],id:i[4]};r.entries[o]=s}}}t.dispatchMessage(n)}}return e.init=function(t){if("object"==typeof t&&t){var n=new e(t);e.s_instance=n,s.setCustomSendLocalDocumentRequestFunc((function(t){t=f._validateLocalDocumentRequest(t);var r=0;f.isReadonlyRestRequest(t.method)||(r=1);var o=t.url.indexOf("?");if(o>=0){var i=t.url.substr(o+1),s=f._parseRequestFlagsAndCustomDataFromQueryStringIfAny(i);s.flags>=0&&(r=s.flags)}var a={id:e.nextId(),type:1,flags:r,message:t};return n.sendMessageToHostAndExpectResponse(a).then((function(e){return e.message}))}));for(var r=0;r<e.s_onInitedHandlers.length;r++)e.s_onInitedHandlers[r](n)}},Object.defineProperty(e,"instance",{get:function(){return e.s_instance},enumerable:!1,configurable:!0}),e.prototype.sendMessageToHost=function(e){this.m_bridge.sendMessageToHost(JSON.stringify(e))},e.prototype.sendMessageToHostAndExpectResponse=function(e){var t=this,n=f.createPromise((function(n,r){t.m_promiseResolver[e.id]=n}));return this.m_bridge.sendMessageToHost(JSON.stringify(e)),n},e.prototype.addHostMessageHandler=function(e){this.m_handlers.push(e)},e.prototype.removeHostMessageHandler=function(e){var t=this.m_handlers.indexOf(e);t>=0&&this.m_handlers.splice(t,1)},e.onInited=function(t){e.s_onInitedHandlers.push(t),e.s_instance&&t(e.s_instance)},e.prototype.dispatchMessage=function(e){if("number"==typeof e.id){var t=this.m_promiseResolver[e.id];if(t)return t(e),void delete this.m_promiseResolver[e.id]}for(var n=0;n<this.m_handlers.length;n++)this.m_handlers[n](e)},e.nextId=function(){return e.s_nextId++},e.s_onInitedHandlers=[],e.s_nextId=1,e}();t.HostBridge=u,"object"==typeof _richApiNativeBridge&&_richApiNativeBridge&&u.init(_richApiNativeBridge),function(e){var t=function(t){function n(e){var r=t.call(this,"string"==typeof e?e:e.message)||this;if(Object.setPrototypeOf(r,n.prototype),r.name="RichApi.Error","string"==typeof e?r.message=e:(r.code=e.code,r.message=e.message,r.traceMessages=e.traceMessages||[],r.innerError=e.innerError||null,r.debugInfo=r._createDebugInfo(e.debugInfo||{}),r.httpStatusCode=e.httpStatusCode,r.data=e.data),f.isNullOrUndefined(r.httpStatusCode)||200===r.httpStatusCode){var o={};o[c.accessDenied]=401,o[c.connectionFailure]=500,o[c.generalException]=500,o[c.invalidArgument]=400,o[c.invalidObjectPath]=400,o[c.invalidOrTimedOutSession]=408,o[c.invalidRequestContext]=400,o[c.timeout]=408,o[c.valueNotLoaded]=400,r.httpStatusCode=o[r.code]}return f.isNullOrUndefined(r.httpStatusCode)&&(r.httpStatusCode=500),r}return o(n,t),n.prototype.toString=function(){return this.code+": "+this.message},n.prototype._createDebugInfo=function(t){var n={code:this.code,message:this.message,toString:function(){return JSON.stringify(this)}};for(var r in t)n[r]=t[r];return this.innerError&&(this.innerError instanceof e.RuntimeError?n.innerError=this.innerError.debugInfo:n.innerError=this.innerError),n},n._createInvalidArgError=function(t){return new e.RuntimeError({code:c.invalidArgument,httpStatusCode:400,message:f.isNullOrEmptyString(t.argumentName)?f._getResourceString(l.invalidArgumentGeneric):f._getResourceString(l.invalidArgument,t.argumentName),debugInfo:t.errorLocation?{errorLocation:t.errorLocation}:{},innerError:t.innerError})},n}(Error);e.RuntimeError=t}(a=t._Internal||(t._Internal={})),t.Error=a.RuntimeError,t.FormattedNumber=a.FormattedNumber,t.Entity=a.Entity,t.WebImage=a.WebImage,t.Attribution=a.Attribution,t.Provider=a.Provider;var c=function(){function e(){}return e.apiNotFound="ApiNotFound",e.accessDenied="AccessDenied",e.generalException="GeneralException",e.activityLimitReached="ActivityLimitReached",e.invalidArgument="InvalidArgument",e.connectionFailure="ConnectionFailure",e.timeout="Timeout",e.invalidOrTimedOutSession="InvalidOrTimedOutSession",e.invalidObjectPath="InvalidObjectPath",e.invalidRequestContext="InvalidRequestContext",e.valueNotLoaded="ValueNotLoaded",e.requestPayloadSizeLimitExceeded="RequestPayloadSizeLimitExceeded",e}();t.CoreErrorCodes=c;var l=function(){function e(){}return e.apiNotFoundDetails="ApiNotFoundDetails",e.connectionFailureWithStatus="ConnectionFailureWithStatus",e.connectionFailureWithDetails="ConnectionFailureWithDetails",e.invalidArgument="InvalidArgument",e.invalidArgumentGeneric="InvalidArgumentGeneric",e.timeout="Timeout",e.invalidOrTimedOutSessionMessage="InvalidOrTimedOutSessionMessage",e.invalidObjectPath="InvalidObjectPath",e.invalidRequestContext="InvalidRequestContext",e.valueNotLoaded="ValueNotLoaded",e}();t.CoreResourceStrings=l;var d=function(){function e(){}return e.flags="flags",e.sourceLibHeader="SdkVersion",e.processQuery="ProcessQuery",e.localDocument="http://document.localhost/",e.localDocumentApiPrefix="http://document.localhost/_api/",e.customData="customdata",e}();t.CoreConstants=d;var p=function(){function e(){}return e.buildMessageArrayForIRequestExecutor=function(t,n,r,o){var i=JSON.stringify(r.Body);f.log("Request:"),f.log(i);var s={};return f._copyHeaders(r.Headers,s),s[d.sourceLibHeader]=o,e.buildRequestMessageSafeArray(t,n,"POST",d.processQuery,s,i)},e.buildResponseOnSuccess=function(e,t){var n={HttpStatusCode:200,ErrorCode:"",ErrorMessage:"",Headers:null,Body:null};return n.Body=JSON.parse(e),n.Headers=t,n},e.buildResponseOnError=function(t,n){var r={HttpStatusCode:500,ErrorCode:"",ErrorMessage:"",Headers:null,Body:null};return r.ErrorCode=c.generalException,r.ErrorMessage=n,t==e.OfficeJsErrorCode_ooeNoCapability?(r.ErrorCode=c.accessDenied,r.HttpStatusCode=401):t==e.OfficeJsErrorCode_ooeActivityLimitReached?(r.ErrorCode=c.activityLimitReached,r.HttpStatusCode=429):t==e.OfficeJsErrorCode_ooeInvalidOrTimedOutSession?(r.ErrorCode=c.invalidOrTimedOutSession,r.HttpStatusCode=408,r.ErrorMessage=f._getResourceString(l.invalidOrTimedOutSessionMessage)):t==e.OfficeJsErrorCode_ooeRequestPayloadSizeLimitExceeded&&(r.ErrorCode=c.requestPayloadSizeLimitExceeded,r.HttpStatusCode=400),r},e.buildHttpResponseFromOfficeJsError=function(t,n){var r=500,o={error:{}};return o.error.code=c.generalException,o.error.message=n,t===e.OfficeJsErrorCode_ooeNoCapability?(r=403,o.error.code=c.accessDenied):t===e.OfficeJsErrorCode_ooeActivityLimitReached&&(r=429,o.error.code=c.activityLimitReached),{statusCode:r,headers:{},body:JSON.stringify(o)}},e.buildRequestMessageSafeArray=function(e,t,n,r,o,i){var s=[];if(o)for(var a in o)s.push(a),s.push(o[a]);return[e,n,r,s,i,0,t,"","",""]},e.getResponseBody=function(t){return e.getResponseBodyFromSafeArray(t.value.data)},e.getResponseHeaders=function(t){return e.getResponseHeadersFromSafeArray(t.value.data)},e.getResponseBodyFromSafeArray=function(e){var t=e[2];return"string"==typeof t?t:t.join("")},e.getResponseHeadersFromSafeArray=function(e){var t=e[1];if(!t)return null;for(var n={},r=0;r<t.length-1;r+=2)n[t[r]]=t[r+1];return n},e.getResponseStatusCode=function(t){return e.getResponseStatusCodeFromSafeArray(t.value.data)},e.getResponseStatusCodeFromSafeArray=function(e){return e[0]},e.OfficeJsErrorCode_ooeInvalidOrTimedOutSession=5012,e.OfficeJsErrorCode_ooeActivityLimitReached=5102,e.OfficeJsErrorCode_ooeNoCapability=7e3,e.OfficeJsErrorCode_ooeRequestPayloadSizeLimitExceeded=5103,e}();t.RichApiMessageUtility=p,function(e){e.getPromiseType=function(){if("undefined"!=typeof Promise)return Promise;if("undefined"!=typeof Office&&Office.Promise)return Office.Promise;if("undefined"!=typeof OfficeExtension&&OfficeExtension.Promise)return OfficeExtension.Promise;throw new e.Error("No Promise implementation found")}}(a=t._Internal||(t._Internal={}));var f=function(){function e(){}return e.log=function(t){e._logEnabled&&"undefined"!=typeof console&&console.log&&console.log(t)},e.checkArgumentNull=function(t,n){if(e.isNullOrUndefined(t))throw a.RuntimeError._createInvalidArgError({argumentName:n})},e.isNullOrUndefined=function(e){return null==e},e.isUndefined=function(e){return void 0===e},e.isNullOrEmptyString=function(e){return null==e||0==e.length},e.isPlainJsonObject=function(t){if(e.isNullOrUndefined(t))return!1;if("object"!=typeof t)return!1;if("[object Object]"!==Object.prototype.toString.apply(t))return!1;if(t.constructor&&!Object.prototype.hasOwnProperty.call(t,"constructor")&&!Object.prototype.hasOwnProperty.call(t.constructor.prototype,"hasOwnProperty"))return!1;for(var n in t)if(!Object.prototype.hasOwnProperty.call(t,n))return!1;return!0},e.trim=function(e){return e.replace(new RegExp("^\\s+|\\s+$","g"),"")},e.caseInsensitiveCompareString=function(t,n){return e.isNullOrUndefined(t)?e.isNullOrUndefined(n):!e.isNullOrUndefined(n)&&t.toUpperCase()==n.toUpperCase()},e.isReadonlyRestRequest=function(t){return e.caseInsensitiveCompareString(t,"GET")},e._getResourceString=function(t,n){var r;if("undefined"!=typeof window&&window.Strings&&window.Strings.OfficeOM){var o="L_"+t,i=window.Strings.OfficeOM[o];i&&(r=i)}if(r||(r=e.s_resourceStringValues[t]),r||(r=t),!e.isNullOrUndefined(n))if(Array.isArray(n)){var s=n;r=e._formatString(r,s)}else r=r.replace("{0}",n);return r},e._formatString=function(e,t){return e.replace(/\{\d\}/g,(function(e){var n=parseInt(e.substr(1,e.length-2));if(n<t.length)return t[n];throw a.RuntimeError._createInvalidArgError({argumentName:"format"})}))},Object.defineProperty(e,"Promise",{get:function(){return a.getPromiseType()},enumerable:!1,configurable:!0}),e.createPromise=function(t){return new e.Promise(t)},e._createPromiseFromResult=function(t){return e.createPromise((function(e,n){e(t)}))},e._createPromiseFromException=function(t){return e.createPromise((function(e,n){n(t)}))},e._createTimeoutPromise=function(t){return e.createPromise((function(e,n){setTimeout((function(){e(null)}),t)}))},e._createInvalidArgError=function(e){return a.RuntimeError._createInvalidArgError(e)},e._isLocalDocumentUrl=function(t){return e._getLocalDocumentUrlPrefixLength(t)>0},e._getLocalDocumentUrlPrefixLength=function(e){for(var t=["http://document.localhost","https://document.localhost","//document.localhost"],n=e.toLowerCase().trim(),r=0;r<t.length;r++){if(n===t[r])return t[r].length;if(n.substr(0,t[r].length+1)===t[r]+"/")return t[r].length+1}return 0},e._validateLocalDocumentRequest=function(t){var n=e._getLocalDocumentUrlPrefixLength(t.url);if(n<=0)throw a.RuntimeError._createInvalidArgError({argumentName:"request"});var r=t.url.substr(n),o=r.toLowerCase();return"_api"===o?r="":"_api/"===o.substr(0,"_api/".length)&&(r=r.substr("_a