webpackJsonp59d54cc69c644b50062d1819c9fbb72d([4],{3226:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(37),o=n(147),i=(n.n(o),n(583)),a=n(43),s=function(){function e(e,t){this.SPFxContext=e,this.webServerRelativeUrl=t,this.listService=new i.a}return e.prototype.Convert=function(e,t){var n=this;return new Promise(function(r,i){n.getListDataAsStream(e,t).then(function(e){if(n.isSupportedFileType(e)){var t=n.getConvertPDFUrl(e),a=o.SPHttpClient.configurations.v1;n.SPFxContext.spHttpClient.get(t,a,{cache:"no-cache",headers:{"Cache-Control":"no-cache"}}).then(function(e){if(e.ok){var t=e.blob();r(t)}else e.json().then(function(e){var t=e.error.innererror?e.error.innererror.code:e.error.message;i("Failed to convert file to PDF. "+t)})}).catch(function(e){return i(e)})}else{var s=e.ListData.Row[0][".fileType"];i("Provided file type "+s+" is not supported.")}}).catch(function(e){return i(e)})})},e.prototype.getConvertPDFUrl=function(e){var t=e.ListSchema[".pdfConversionUrl"];if(!t)throw new Error("Cannot get PDF conversion URL format");var n=t.match(/\{(.*?)\}/g);if(!n)throw new Error("Cannot get PDF conversion URL. Data is unavailable");return n.forEach(function(n){var r=n,o=n.slice(1,-1),i=e.ListSchema[o],a=e.ListData.Row[0][o],s=i||a;if(!s)throw new Error("Cannot build PDF conversion URL");t=t.replace(r,s)}),t},e.prototype.getListDataAsStream=function(e,t){var n=this;return new Promise(function(o,i){var s="\n        <View Scope='RecursiveAll'>\n            <Query>\n                <Where>\n                    <Eq>\n                      <FieldRef Name='ID' />\n                      <Value Type=\"Counter\">"+t+"</Value>\n                    </Eq>\n                </Where>\n            </Query>\n            <RowLimit>1</RowLimit>\n        </View>",c={RenderOptions:r.f.EnableMediaTAUrls|r.f.ContextInfo|r.f.ListData|r.f.ListSchema,ViewXml:s},l="";if(n.webServerRelativeUrl){var p=a.a.GetHostUrl(n.SPFxContext.pageContext.web.absoluteUrl);l=a.a.Combine(p,n.webServerRelativeUrl)}n.listService.renderListDataAsStream(e,c,l).then(function(e){e&&e.ListSchema&&e.ListData&&e.ListData.Row?o(e):i("Cannot load PDF conversion data")}).catch(function(e){i("Cannot load PDF conversion data. "+e)})})},e.prototype.isSupportedFileType=function(t){var n=t.ListData.Row[0][".fileType"];return-1!=e.supportedFileTypes.indexOf(n)},e.supportedFileTypes=["docx","docm","dotx","dotm","doc","xlsx","xlsm","xltx","xltm","xlsb","xlam","xls","pptx","pptm","potx","potm","ppam","ppsx","ppsm","sldx","sldm","thmx","ppt"],e}();t.default=s}});