"use strict";var _jump=require("../../utils/jump"),_richTextParser=require("../../utils/rich-text-parser");function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var getParsedSegments=function(e,t){return e?(0,_richTextParser.parseRichTextSegments)(e):Array.isArray(t)?t:[]};Component({data:{lineBreak:"\n",parsedSegments:[]},properties:{sdkInstance:{type:Object,value:null},html:{type:String,value:"",observer:function(e){this.setData({parsedSegments:getParsedSegments(e,this.data.segments)})}},segments:{type:Array,value:[],observer:function(e){this.data.html||this.setData({parsedSegments:getParsedSegments(this.data.html,e)})}},eventName:{type:String,value:""},jumpFeature:{type:String,value:""},linkPayload:{type:Object,value:{}},textColor:{type:String,value:""},dark:{type:Boolean,value:!1}},lifetimes:{attached:function(){this.setData({parsedSegments:getParsedSegments(this.data.html,this.data.segments)})}},methods:{onLinkClick:function(e){var t,r=(null==e||null===(t=e.currentTarget)||void 0===t?void 0:t.dataset)||{},n=r.url,a=r.text;if(n){var i,o,s=_objectSpread({url:n,text:a||n},this.data.linkPayload||{});this.data.eventName&&(null===(i=this.data.sdkInstance)||void 0===i||null===(o=i.emitEvent)||void 0===o||o.call(i,this.data.eventName,s)),(0,_jump.navigateToConfiguredWebview)(this.data.sdkInstance,this.data.jumpFeature,n)}}}});