(function(){"use strict";BX.namespace("BX.Landing.MediaService");var e=BX.Landing.Utils.isArray;BX.Landing.MediaService.BaseMediaService=function(e,t){if(typeof e!=="string"){throw new TypeError("URL not a string")}this.url=encodeURI(e);this.settings=t||{};this.matcher=new RegExp("//");this.embedURL="";this.idPlace=0;this.type="iframe";this.params={}};BX.Landing.MediaService.BaseMediaService.prototype={getMediaId:function(){return this.url.match(this.matcher)[this.idPlace]},getUserSettings:function(){var t={};var i=this.getSettingsForm();if(i){t=i.fields.fetchValues();Object.keys(t).forEach((function(i){if(e(t[i])){t[i]=encodeURIComponent(t[i].join(", "))}}))}return t},getSettings:function(){return BX.util.objectMerge(BX.clone(this.params),BX.Landing.Utils.getQueryParams(this.url),BX.clone(this.settings))},getEmbedURL:function(){var e=this.embedURL;var t=this.url.match(this.matcher);if(typeof this.embedURL==="string"){[].slice.call(t).forEach((function(t,i){e=e.replace(new RegExp("\\$"+i,"g"),t)}));var i=BX.util.objectMerge(this.getSettings(),this.getUserSettings());e=BX.util.add_url_param(e,i)}if(typeof this.embedURL==="function"){e=this.embedURL(t)}return e},getEmbedPreview:function(){if(typeof this.previewURL==="string"){var e=this.previewURL;var t=this.url.match(this.matcher);[].slice.call(t).forEach((function(t,i){e=e.replace(new RegExp("\\$"+i,"g"),t)}));return e}else{return false}},getEmbedElement:function(){return BX.create("iframe",{attrs:{src:this.getEmbedURL(),frameborder:"0",gesture:"media",allow:"encrypted-media",allowfullscreen:true}})},getURLPreview:function(){return BX.Landing.Utils.getURLPreview(this.url)},getURLPreviewElement:function(){return this.getURLPreview().then(function(e){var t=e.DESCRIPTION;var i=e.TITLE;if(i.length+t.length>120){if(i.length>120){t="";i=i.slice(0,120)+"..."}else if(i.length+t.length>120){t=t.slice(0,t.length-(i.length+t.length-120))+"..."}}return BX.create("div",{props:{className:"landing-ui-mediaservice-url-preview"},children:[BX.create("div",{props:{className:"landing-ui-mediaservice-url-preview-image"},attrs:{style:'background-image: url("'+e.IMAGE+'")'}}),BX.create("div",{props:{className:"landing-ui-mediaservice-url-preview-text"},children:[BX.create("div",{props:{className:"landing-ui-mediaservice-url-preview-text-title"},text:i}),BX.create("div",{props:{className:"landing-ui-mediaservice-url-preview-text-description"},text:t})]})]})}.bind(this))},getSettingsForm:function(){return null}}})();
//# sourceMappingURL=base_mediaservice.map.js