"use strict";var _utils=require("../../../utils/utils"),_constant=require("../../../utils/constant"),_theme=require("../../../utils/theme");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 n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,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 n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}Component({options:{styleIsolation:"shared"},properties:{sdkInstance:{type:Object,value:null}},data:{visible:!1,data:null,useDarkTheme:!1},lifetimes:{detached:function(){"function"==typeof this.unsub&&this.unsub(),this.unsub=null}},observers:{sdkInstance:function(e){var t=this;e&&(this.sdkInstance=e,this.store=e.store,"function"==typeof this.unsub&&this.unsub(),this.unsub=null,this.unsub=this.store.get({AnnouncementInfo:function(e){var n,o=e||{},r=o.visible,i=o.currentId;r&&i&&t.openAnnouncement(i),!r&&t.data.visible&&(null===(n=t.selectComponent("#announcement-drawer"))||void 0===n||n.hideFrame({silent:!0})),(0,_utils.setDataIfChanged)(t,{visible:!!r})},liveInfo:function(e){(0,_utils.setDataIfChanged)(t,{useDarkTheme:(0,_theme.isUseDarkTheme)(null==e?void 0:e.Basic)})}}))}},methods:{findAnnouncement:function(e){for(var t,n=(null===(t=this.store)||void 0===t?void 0:t.get("imageTextInfo.imageText"))||[],o=0;o<n.length;o+=1)for(var r,i=(null===(r=n[o])||void 0===r?void 0:r.Context)||[],u=0;u<i.length;u+=1){var s,l=i[u];if((null==l?void 0:l.ImageTextType)===_constant.ImageTextTypes.ANNOUNCEMENT&&String(null==l||null===(s=l.AnnouncementContext)||void 0===s?void 0:s.AnnouncementId)===String(e))return l.AnnouncementContext}return null},openAnnouncement:function(e){var t,n=this.findAnnouncement(e);n?(this.setData({data:_objectSpread(_objectSpread({},n),{},{Title:(0,_utils.getBySplit)(n.Title||n.AnnouncementTitle||"公告"),ContentHtml:n.Content||"",ContentLinkPayload:{announcementId:n.AnnouncementId}})}),null===(t=this.selectComponent("#announcement-drawer"))||void 0===t||t.showFrame()):this.closeAnnouncementDrawer()},closeAnnouncementDrawer:function(){var e;null===(e=this.selectComponent("#announcement-drawer"))||void 0===e||e.hideFrame()},onAnnouncementDrawerCancel:function(){var e;null===(e=this.store)||void 0===e||e.set("AnnouncementInfo",_objectSpread(_objectSpread({},this.store.get("AnnouncementInfo")||{}),{},{visible:!1,currentId:null}))}}});