File Manager
Viewing File: price-alerts-dispatcher.js
(window.webpackJsonp=window.webpackJsonp||[]).push([["price-alerts-dispatcher"],{"15Qe":function(e,t,r){"use strict";r.r(t),r.d(t,"getNotificationFromPriceEvent",(function(){return a})),r.d(t,"getNotificationFromAlertStopped",(function(){return l}));r("YFKU"),r("HbRj");var n=r("JZcM"),o=r("IWHC"),i=r("hp/T"),s=r("zNIe");function a(e){var t=e.shortSymbol(),r=e.get("symbol");return{id:"fired:price:"+e.id,fired:new Date(e.get("fireTime")),type:n.a.Fired,desktopNotificationTitle:window.t("Alert on {shortSymbol}").format({shortSymbol:t}),dialogTitle:window.t("Alert on {shortSymbol}").format({shortSymbol:'<a data-symbol="'+r+'" class="js-symbol" href="'+Object(s.a)(r)+'" target="_blank">'+t+"</span>"}),description:e.get("name")||e.get("description"),title:t,alertId:Number(e.get("alertId")),alertCategory:o.AlertCategory.Price,eventId:e.get("id"),notifyWith:{email:!!e.get("sendEmail"),popup:!!e.get("showPopup"),sms:!!e.get("sendSms"),sound:!!e.get("playSound")},soundParams:{duration:e.get("soundDuration")||0,name:e.get("soundFile")||i.DEFAULT_SOUNDS.alert}}}function l(e){if("fire_control"===e.reason){var t=new Date(6e4*Math.round(Date.now()/6e4));return{id:"fire_control:price:"+e.alertId+":"+t.getTime()/1e3,fired:t,type:n.a.FireControl,desktopNotificationTitle:e.shortSymbol+window.t("The alert is triggered too often"),description:e.description,title:e.shortSymbol,alertId:e.alertId,alertCategory:o.AlertCategory.Price,notifyWith:{popup:!0}}}return null}},"2qdo":function(e,t,r){"use strict";function n(){return Promise.all([r.e("dialogs-core"),r.e(12),r.e(21),r.e(37),r.e(349),r.e(0),r.e(6),r.e(13),r.e(15),r.e(35),r.e(57),r.e(178),r.e("alert-notifier")]).then(r.bind(null,"Z59a")).then((function(e){return e.createAlertNotifier()}))}r.r(t),r.d(t,"createAlertNotifier",(function(){return n}))},"3DsO":function(e,t,r){"use strict";r.r(t),r.d(t,"showGoProInfExpDialog",(function(){return o}));var n=r("oOPW");function o(){Object(n.createGoProDialog)({feature:"alertsNoExpiration"})}},"3Tqy":function(e,t,r){"use strict";(function(n){Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var r=[],n=!0,o=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(l){o=!0,i=l}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}return r}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")};t.prepareAlertsModels=Z;var s,a=r("+GxX"),l=r("brCa"),c=r("ZF9k"),u=r("0dm4"),d=r("15Qe"),f=r("IWHC"),p=r("jA5l"),h=r("aIyQ"),_=(s=h)&&s.__esModule?s:{default:s},v=r("PfBM"),m=r("uOo4"),y=r("8I+7"),g=r("K81e")
;var b=r("ijto").allSettled,S=r("2O5g").invokeAlertEditor,A=r("1UCy").AlertEditorAbortReason,x=r("sg6D"),w=r("Evi4").AlertVersioning,P=r("4pku").Alert,E=r("nmnj"),I=r("dfhE"),D=r("TxTq"),C=r("JWMC").trackEvent,O=r("NP3r").enabled,T=r("bKsZ").ProductFeatures,N=r("oNDq").createConfirmDialog,k=r("txPx").getLogger("Alerts.Price.Dispatcher"),q=r("hWRP").sendRequest,F=r("2qdo").createAlertNotifier,j=r("4BMm").server2clientParams,R=r("4BMm").client2serverParams,M=r("xlbu").telemetry,W=r("Zdjc").showGoProAlertsTrueSmsDialog,L=r("gdgp").showGoProMaxAlertsDialog,B=r("3DsO").showGoProInfExpDialog,U=r("zL88").showWarningAlertsMaxTotalCountExceeded,J="cancelled: new alert already generating",H=r("flg1").showAlertsMaintenanceDialog,V=r("8woN");function G(){var e=this;this._loading={},this._alertVersioning=new w,this._lastGenIds={},this._notifierPromise=null,this._onPushStreamMessage=new _.default,this._onPushStreamStatusChanged=function(t){t===v.ConnectionStatus.Open&&e._onPushStreamMessage.fire({source:"host",data:{m:"pushstream_ready"}})},this.alerts=new(n.Collection.extend({model:P})),this.events=new(n.Collection.extend({comparator:function(e,t){var r=e.get("fireTime"),n=t.get("fireTime");return r&&n?n-r:r?n?void 0:1:-1},model:x})),this._attachHandlers()}function z(e){e.forEach((function(e){return e.set("selected",!1)}))}function Y(e,t){e.forEach((function(e){e!==t&&e.set("selected",!1)}))}function X(e){var t=new Date;e.get("expired")<t&&(t.setMonth(t.getMonth()+1),e.set("expired",t))}function Z(e,t){return new Promise((function(r,n){var o=e.map(j).map((function(e){var r=t(e);return r.catch((function(t){return k.logError("Migration failed. Alert ID: "+e.id+". Error: "+t)})),r}));b(o).then((function(e){var t=e.filter((function(e){return"fulfilled"===e.status})).map((function(e){return new P(e.value)}));r(t)}))}))}function K(e,t){e.script=t.IL,t.inputs&&(e.inputs=t.inputs),t.genAlertData&&(0,a.isFeatureEnabled)("alerts-send-gen-alert-data")&&(e.gen_alert_data=t.genAlertData)}function Q(e){if("function"==typeof e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];e.apply(this,r)}}G.checkProPermissions=function(e){return e.get("sendTrueSms")&&!O(T.ALERTS_TRUE_SMS)?(W(),!1):e.get("noExpiration")&&!O(T.ALERTS_NO_EXPIRATION)?(B(),!1):"string"!=typeof e.get("webhookUrl")||O(T.ALERTS_WEBHOOK)?!!(0,u.canPlaceAlertOnResolution)(e.get("resolution"))||((0,c.showGoProAlertsOnSecondsDialog)(),!1):((0,p.showGoProAlertsWebhookDialog)(),!1)},G.getAnalyticsHeaders=function(e,t){return{"X-Analytics-Price-Alert-Condition":String(e),"X-Analytics-Price-Alert-Action-Source":String(t)}},G.prototype._onLoginStateChange=function(e){is_authenticated?(e||setTimeout(this.showOfflineEvents.bind(this),1),this._refreshPushStream()):(this.alerts.reset(),this.events.reset(),this._alertVersioning.cancelAllPossibleExtraUpdates()),this._offlineEventsRequestWasSent=!1,this._fullListWasRequested=!1},G.prototype._attachHandlers=function(){var e=this;function t(t){var r=e.chartWidget(),n=r?r.model():null;if(n){var o=n.hoveredSource()
;t.set("hovered",o&&o.hasAlert&&o.hasAlert.value()&&o.alertId()===t.id);var i=n.selection().dataSources().some((function(e){return e.hasAlert.value()&&e.alertId()===t.id}));t.set("selected",i)}}loginStateChange.subscribe(this,this._onLoginStateChange.bind(this)),this._onLoginStateChange(!0),e.alerts.on("add",(function(r){t(r),r.isDrawing()&&function(t){var r=e.chartWidget()&&e.chartWidget().model();if(r){var n=t.get("extra").drawing(),o=r.dataSourceForId(n.id);o&&!o.hasAlert.value()&&o.canHasAlert()&&o.setAlert(t.id)}}(r)})).on("change:selected",(function(t,r,n){if(r){var o=e.alerts;z(e.events),Y(o,t)}})).on("change:id",t).on("destroy",(function(t){t.isNew()||e.events.where({alertId:t.id}).forEach((function(e){e.destroy()}))})),e.events.on("change:selected",(function(t,r,n){var o=e.events.models;r&&(z(e.alerts),Y(o,t))})),e.alerts.on("change:id",(function(t){var r=!1,n=!0,o=!1,i=void 0;try{for(var s,a=e.alerts.models[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){s.value.id===t.id&&(r?k.logWarn("Two alerts share the same id "+t.id+", which may lead to undefined behaviour"):r=!0)}}catch(l){o=!0,i=l}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}}))},G.prototype.showOfflineEvents=function(){var e=this;if(!window.is_authenticated||this._offlineEventsRequestWasSent)return Promise.resolve();this._offlineEventsRequestWasSent=!0;return Promise.all([this.sendRequest({method:"get_offline_events",preventMaintenanceDialog:!0,params:{}}),this.getAlertNotifier()]).then((function(t){var r=i(t,2),n=r[0],s=n.fires,a=n.fire_controls,l=r[1],c=Object.keys(s);c.length>0&&e.sendRequest({method:"clear_shown_events",preventMaintenanceDialog:!0,params:{alerts_ids:c.map((function(e){return parseInt(e)}))}}).catch((function(e){k.logError("Could not mark offline events as shown: "+e)}));var u=c.map((function(e){return s[e].latest_event})).sort((function(e,t){return e.id-t.id})),f=!0,p=!1,h=void 0;try{for(var _,v=u[Symbol.iterator]();!(f=(_=v.next()).done);f=!0){var m=_.value,y=new x(j(m));e.events.add(y),y.trigger("fired",y);var g=e.alerts.get(y.get("alertId"));void 0!==g&&g.trigger("fired",g),l.addNotification(o({},(0,d.getNotificationFromPriceEvent)(y),{count:s[y.get("alertId")].events_count}))}}catch(I){p=!0,h=I}finally{try{!f&&v.return&&v.return()}finally{if(p)throw h}}u.length>0&&e.events.trigger("offline_events");var b=!0,S=!1,A=void 0;try{for(var w,P=Object.values(a)[Symbol.iterator]();!(b=(w=P.next()).done);b=!0){var E=w.value;l.addNotification((0,d.getNotificationFromAlertStopped)({alertId:E.id,description:E.name||E.desc,reason:"fire_control",shortSymbol:V.shortName(E.sym)}))}}catch(I){S=!0,A=I}finally{try{!b&&P.return&&P.return()}finally{if(S)throw A}}}),(function(e){k.logError("Failed to get offline events: "+e)}))},G.prototype._refreshPushStream=function(){D.off("alert"),D.offStatus(this._onPushStreamStatusChanged),is_authenticated&&(D.on("alert",this._onMessage.bind(this)),D.onPrivateStatus(this._onPushStreamStatusChanged))},G.prototype._onMessage=function(e){var t,r,n,i,s=this,a={};if(e)switch(k.logNormal(e),
t=JSON.parse(e),this._onPushStreamMessage.fire({source:"alert",data:t}),r=t.m,a="new_alerts"===r?t.p.alerts.map(j):j(t.p),r){case"alert_running":s._alertVersioning.cancelPossibleExtraUpdate(a.id),s._alertVersioning.migrate(a).then((function(e){(n=s.alerts.get(e.id))?n.set(e):s.alerts.add(e,{at:0})}));break;case"new_alerts":var l=!0,c=!1,u=void 0;try{for(var f,p=a[Symbol.iterator]();!(l=(f=p.next()).done);l=!0){var h=f.value;s.alerts.add(h)}}catch(v){c=!0,u=v}finally{try{!l&&p.return&&p.return()}finally{if(c)throw u}}break;case"alert_stopped":if(n=s.alerts.get(a.id)){var _={active:!1,stopReason:a.stopReason,error:a.error};n.set(_)}"fire_control"===a.stopReason&&s.getAlertNotifier().then((function(e){var t=(0,d.getNotificationFromAlertStopped)({alertId:a.id,description:a.name||a.description,reason:a.stopReason,shortSymbol:V.shortName(a.symbol)});t&&e.addNotification(t)}));break;case"alert_deleted":s._alertVersioning.cancelPossibleExtraUpdate(a.id),(n=s.alerts.get(a.id))&&n.destroy();break;case"event":this.getAlertNotifier().then(function(e){i=new x(o({},a)),s.events.add(i);var t=(0,d.getNotificationFromPriceEvent)(i);e.addNotification(t),i.trigger("fired",i),i.trigger("fired:online",i);var r=s.alerts.get(a.alertId);void 0!==r&&(r.set({fireTime:a.fireTime}),r.trigger("fired",r)),this.sendRequest({method:"clear_shown_events",preventMaintenanceDialog:!0,params:{alerts_ids:[a.alertId]}})}.bind(this))}},G.prototype.cloneAlert=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(0,m.isAlertCloneable)(e))return"function"==typeof t.error&&t.error("Cannot clone alert"),void("function"==typeof t.complete&&t.complete());var r=e.getLocalClone();X(r),this.alerts.add(r),this.createAlert(r,o({},t,{eventName:"clone"}))},G.prototype.createLocalAlert=function(e,t){var r;return t&&function(e){if(!e)throw new Error("Can't create alert. 'params' is required");for(var t=["symbol","resolution","expired","autoDeactivation","sendEmail","sendSms","sendTrueSms","showPopup","playSound","description","script"],r=[],n=t.length-1;n>=0;n--){var o=t[n];o in e||r.push(o)}r.length&&k.logError("[Alerts] Can't create alert. "+r.join(" ,")+(1===r.length?" is":" are")+" required")}(e),r=new P(e),this.alerts.add(r),r},G.prototype.createAlert=function(e,t){var r=this;t=t||{};function n(e,r){"function"==typeof t.complete&&t.complete(),"function"==typeof t.error&&t.error(e,r)}if(e instanceof P){if(G.checkProPermissions(e)){var o=Date.now(),i=e.prepareToSend();return r._generateScriptWithCancellation(e).then((function(n){return K(i,n),r.sendRequest({headers:G.getAnalyticsHeaders(e.get("extra").conditionId(),t.actionSource),method:"create_alert",params:i,success:function(n){n=j(n||{});var o=r.alerts.get(n.id);o?(r.alerts.remove(e),e=o):(n.active=!0,e.set(n)),r._gaTrackEvent(t.eventName||"create",e,t.eventLabel),"function"==typeof t.success&&t.success(e)},complete:function(){var r=Date.now()-o;M.sendReport("alerts","full_time_frame",{value:r}),"function"==typeof t.complete&&t.complete(e)},error:t.error})})).catch((function(e){
if(e===J)return k.logNormal("Alert generation is cancelled because next alert generation is started"),J;"function"==typeof t.error&&t.error("Can't generate source code: "+e),"function"==typeof t.complete&&t.complete()}))}n("cannot create alert with current pro plan",!0)}else n("'alert' should be instance of Alert")},G.prototype.stopAlert=function(e,t){var r,n,o=this;t=t||{};e instanceof P?n=(r=e).get("id"):(n=e,r=o.alerts.get(n)),n?o.sendRequest({method:"stop_alert",params:{id:n},success:function(){o._gaTrackEvent("stop"),r&&r.set("active",!1),"function"==typeof t.success&&t.success()},error:t.error,complete:t.complete}):k.logError("Alert id is required to stop alert")},G.prototype.stopAllAlerts=function(e){var t,r=this,n={cross_int:!0};(e=e||{}).symbol&&(n.symbol=e.symbol),e.resolution&&(n.resolution=e.resolution),e.showConfirm&&(t=e.symbol||e.resolution?$.t("Do you really want to stop filtered Alerts?"):$.t("Do you really want to stop all Alerts?")),r.sendRequest({method:"stop_all",params:n,success:function(){r._gaTrackEvent("stop_all"),r.alerts.each((function(e){n.symbol&&n.symbol!==e.get("symbol")||n.resolution&&n.resolution!==e.get("resolution")||e.set("active",!1)})),"function"==typeof e.success&&e.success()},confirmation:t,error:e.error,complete:e.complete})},G.prototype.deleteAlert=function(e,t){var r,n,o,i=this;t=t||{};if(e instanceof P?o=(n=e).get("id"):(o=e,n=i.alerts.get(o)),n&&n.isNew())return n.destroy(),void("function"==typeof t.complete&&t.complete());o?(t.showConfirm&&(r=$.t("Do you really want to delete Alert '{0}' ?").format(n?n.title():o)),i.sendRequest({method:"delete_alert",params:{id:o},success:function(){i._gaTrackEvent("delete"),"function"==typeof t.success&&t.success(),n&&n.destroy()},error:t.error,cancel:t.cancel,complete:t.complete,confirmation:r})):k.logError("Alert id is required to delete alert")},G.prototype.deleteAllAlerts=function(e){var t,r=this,n={crossInterval:!0};(e=e||{}).symbol&&(n.symbol=e.symbol),e.resolution&&(n.resolution=e.resolution),"boolean"==typeof e.active&&(n.active=e.active),e.showConfirm&&(t=!1!==n.active||n.symbol||n.resolution?n.symbol||n.resolution||n.active?$.t("Do you really want to delete filtered Alerts?"):$.t("Do you really want to delete all Alerts?"):$.t("Do you really want to delete all inactive Alerts?")),r.sendRequest({method:"delete_all",params:n,success:function(){var t,o={};for(r._gaTrackEvent("delete_all"),n.symbol&&(o.symbol=n.symbol),n.resolution&&(o.resolution=n.resolution),"boolean"==typeof n.active&&(o.active=n.active),t=r.alerts.findWhere(o);t;)t.destroy(),t=r.alerts.findWhere(o);"function"==typeof e.success&&e.success()},error:e.error,complete:e.complete,confirmation:t})},G.prototype.restartAlert=function(e,t){var r,n,o=this;t=t||{};if(e instanceof P?r=e:(n=e,r=o.alerts.get(n)),r){if(X(r),!G.checkProPermissions(r))return"function"==typeof t.complete&&t.complete(),void("function"==typeof t.error&&t.error("cannot restart alert with current pro plan",!0));var i=Date.now(),s=r.prepareToSend()
;return o._generateScriptWithCancellation(r).then((function(e){return K(s,e),o.sendRequest({headers:G.getAnalyticsHeaders(r.get("extra").conditionId(),t.actionSource),method:"restart_alert",params:s,success:function(){o._gaTrackEvent("restart",r),r.set("active",!0),"function"==typeof t.success&&t.success(r)},complete:function(){var e=Date.now()-i;M.sendReport("alerts","full_time_frame",{value:e}),"function"==typeof t.complete&&t.complete(r)},error:t.error})})).catch((function(e){if(e===J)return k.logNormal("Alert generation is cancelled because next alert generation is started"),J;"function"==typeof t.error&&t.error("Can't generate alert source code for alert #"+n)}))}o.requestAlert(n,{success:function(e){e?o.restartAlert(e,t):("function"==typeof t.error&&t.error("Can't find alert "+n),"function"==typeof t.complete&&t.complete())}})},G.prototype._generateScriptWithCancellation=function(e){var t=this;null==t._lastGenIds[e.cid]&&(t._lastGenIds[e.cid]=0),t._lastGenIds[e.cid]++;var r=t._lastGenIds[e.cid];return new Promise((function(t,r){var n=e.get("extra"),o=null,i="";if(n.isValid()?null===(o=n.toGenAlertJSON(e.get("description")))&&(i="Can't generate alert JSON"):i="Can't generate alert on invalid AlertExtra",i)return k.logError(i),void r(i);E.generateAlert(JSON.stringify(o)).then((function(e,r,n,o){t({IL:r,inputs:n,genAlertData:o})}),r)})).then((function(n){return t._lastGenIds[e.cid]!==r?Promise.reject(J):(e.set("script",n.IL),n)}))},G.prototype.restartAllAlerts=function(e){var t,r=this,n={crossInterval:!0};(e=e||{}).symbol&&(n.symbol=e.symbol),e.resolution&&(n.resolution=e.resolution),"boolean"==typeof e.active&&(n.active=e.active),e.showConfirm&&(t=e.symbol||e.resolution?$.t("Do you really want to restart filtered alerts?"):$.t("Do you really want to restart all inactive alerts?")),r.alerts.every(G.checkProPermissions)&&r.sendRequest({method:"restart_all",params:n,success:function(){r._gaTrackEvent("restart_all"),r.alerts.each((function(e){n.symbol&&n.symbol!==e.get("symbol")||n.resolution&&n.resolution!==e.get("resolution")||e.set("active",!0)})),"function"==typeof e.success&&e.success()},error:e.error,complete:e.complete,confirmation:t})},G.prototype.requestAlert=function(e,t){var r=this,n=(t=t||{},parseInt(e));function o(e){var o=r.alerts.get(n)||null;return(o||e)&&("function"==typeof t.success&&t.success(o),"function"==typeof t.complete&&t.complete()),!!o}function i(){r.sendRequest({method:"get_alert",preventMaintenanceDialog:!0,params:{id:n},success:function(e){var n,o=e.alert;o=j(o),r._alertVersioning.migrate(o).then((function(e){n=new P(e),r.alerts.add(n),"function"==typeof t.success&&t.success(n)})).catch((function(e){"function"==typeof t.error&&t.error(e)}))},complete:t.complete,error:function(r){"function"==typeof t.error?t.error(r):k.logError("Error in getting alert "+e+(r?": "+r:""))}})}!0===t.fromCache?o(!0):!1===t.fromCache?i():o()||i()},G.prototype.getAlertSync=function(e){return this.alerts.get(e)||null},G.prototype.ensureFullAlertsList=function(){
var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=function(e){"function"==typeof t.error&&t.error(e)},n=function(){"function"==typeof t.success&&t.success()},o=function(){"function"==typeof t.complete&&t.complete()};return window.is_authenticated||(this._fullListWasRequested=!0),this._fullListWasRequested?(n(),o(),Promise.resolve()):this.sendRequest({method:"list_alerts",preventMaintenanceDialog:!0,params:{limit:2e3},success:function(t){if(!t.alerts||!Array.isArray(t.alerts)){var o="Not valid params in alert list response";return k.logError(o),void r(o)}Z(t.alerts,(function(t){return e._alertVersioning.migrate(t)})).then((function(t){e.alerts.set(t),e._fullListWasRequested=!0,n()})).catch(r)},error:t.error,complete:o})},G.prototype.requestEventList=function(e){var t=this,r={sym:(e=e||{}).symbol,res:e.resolution&&e.resolution.toString?e.resolution.toString():void 0,limit:e.limit,before:e.before,inc_cross_int:void 0===e.includeCrossInterval||e.includeCrossInterval};e.aid&&(r.aid=e.aid),this.sendRequest({method:"list_events",preventMaintenanceDialog:!0,params:r,success:function(r){var n=r.events;n&&$.isArray(n)?(n=$.map(n,(function(e){var r=new x(j(e));return t.events.add(r),r})),"function"==typeof e.success&&e.success(n)):console.warn("[Alerts] Not valid params in event list response")},error:e.error,complete:e.complete})},G.prototype.deleteEvents=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.ids;if(r&&0===r.length)return n(),void o();function n(){"function"==typeof t.success&&t.success()}function o(){"function"==typeof t.complete&&t.complete()}this.sendRequest({method:"delete_events",params:r?{ids:r}:void 0,success:function(){r?e.events.remove(r):e.events.reset(),n()},error:t.error,complete:t.complete})},G.prototype.stopAlerts=function(e){var t=this,r=e.ids,n=e.success,o=e.error,i=e.complete;if(0===r.length)return Q(n),void Q(i);this.sendRequest({method:"stop_alerts",params:{ids:r},success:function(){t._gaTrackEvent("stop_alerts");var e=!0,o=!1,i=void 0;try{for(var s,a=r[Symbol.iterator]();!(e=(s=a.next()).done);e=!0){var l=s.value,c=t.alerts.get(l);c&&c.set("active",!1)}}catch(u){o=!0,i=u}finally{try{!e&&a.return&&a.return()}finally{if(o)throw i}}Q(n)},error:o,complete:i})},G.prototype.restartAlerts=function(e){var t=this,r=e.ids,n=e.success,o=e.error,i=e.complete;if(0===r.length)return Q(n),void Q(i);var s=[],a=!0,l=!1,c=void 0;try{for(var u,d=r[Symbol.iterator]();!(a=(u=d.next()).done);a=!0){var f=u.value,p=this.alerts.get(f);p&&s.push(p)}}catch(h){l=!0,c=h}finally{try{!a&&d.return&&d.return()}finally{if(l)throw c}}if(!s.every(G.checkProPermissions))return Q(o,"Cannot restart alerts with current pro plan"),void Q(i);this.sendRequest({method:"restart_alerts",params:{ids:r},success:function(){t._gaTrackEvent("restart_alerts");var e=!0,r=!1,o=void 0;try{for(var i,a=s[Symbol.iterator]();!(e=(i=a.next()).done);e=!0){i.value.set("active",!0)}}catch(h){r=!0,o=h}finally{try{!e&&a.return&&a.return()}finally{if(r)throw o}}Q(n)},error:function(e){
"max_alerts_count_exceeded"===e&&L(),Q(o)},complete:i})},G.prototype.cloneAlerts=function(e){var t=this,r=e.success,n=e.error,o=e.complete,i=e.ids.filter((function(e){var r=t.alerts.get(e);return Boolean(r&&(0,m.isAlertCloneable)(r))}));if(0===i.length)return Q(r),void Q(o);this.sendRequest({method:"clone_alerts",params:{ids:i},success:function(){t._gaTrackEvent("clone_alerts"),Q(r)},error:n,complete:o})},G.prototype.deleteAlerts=function(e){var t=this,r=e.ids,n=e.showConfirm,o=e.success,i=e.error,s=e.complete;if(0===r.length)return Q(o),void Q(s);var a=void 0;if(n)if(1===r.length){var l=r[0],c=this.alerts.get(l);a=window.t("Do you really want to delete Alert '{0}' ?").format(c?c.title():l)}else a=window.t("Do you really want to delete selected alerts?");this.sendRequest({method:"delete_alerts",params:{ids:r},success:function(){t._gaTrackEvent("delete_alerts");var e=!0,n=!1,i=void 0;try{for(var s,a=r[Symbol.iterator]();!(e=(s=a.next()).done);e=!0){var l=s.value,c=t.alerts.get(l);c&&c.destroy()}}catch(u){n=!0,i=u}finally{try{!e&&a.return&&a.return()}finally{if(n)throw i}}Q(o)},error:i,complete:s,confirmation:a})},G.prototype.sendRequest=function(e){var t=e.method,r=R(e.params);if(function(e,t){if(["create_alert","restart_alert"].includes(e)){var r=t.extra&&JSON.parse(t.extra),n=r&&r.condition;"strategy"===n.id&&(t.alert_type="strategy"),["strategy","alerts","strategy_and_alerts"].includes(n.id)&&(t.ns_only_fire=!0)}}(t,r),y.alertsMaintenanceTracker.sync(),y.alertsMaintenanceTracker.value())return s("maintenance"),a(),Promise.reject("maintenance");if(e.confirmation){var n=!0;return new Promise((function(t,r){N({content:e.confirmation,title:$.t("Alert"),type:"modal"}).then((function(e){e.actionLoader("yes"),e.on("action:yes",(function(e){e.actionLoader("yes","start");var r=o();r.then((function(t){return e.actionLoader("yes","stop"),e.close(),t})).catch((function(t){return e.actionLoader("yes","stop"),t})),t(r),n=!1})),e.on("action:no",(function(){l(),a(),n=!1})),e.on("afterClose",(function(){n&&(l(),a())})),e.open()}))}))}return o();function o(){var n=q({method:t,params:r,noCache:e.noCache,headers:e.headers});return n.then(i,s),n}function i(t){if("function"==typeof e.success){var r=j(t);e.success(r)}return a(),r}function s(t){var r=!1;return"max_alerts_count_exceeded"===t?(L(),r=!0):"max_total_alerts_count_exceeded"===t?(U(),r=!0):"pro_plan_expired"===t?(B(),r=!0):"maintenance"===t&&(e.preventMaintenanceDialog||(setTimeout(H,0),r=!0)),"function"==typeof e.error?e.error(t,r):"maintenance"===t?k.logNormal("Alerts maintenance"):t&&k.logError("Reason: "+t),a(),t}function a(){"function"==typeof e.complete&&e.complete()}function l(){"function"==typeof e.cancel&&e.cancel()}},G.prototype.setChartWidgetCollection=function(e){this._chartWidgetCollection=e},G.prototype.chartWidget=function(){var e=null;return this._chartWidgetCollection&&(e=this._chartWidgetCollection.activeChartWidget.value()||null),e},G.prototype._gaTrackEvent=function(e,t,r){var n;C("alert",e,r),"create"===e&&t instanceof P&&(n=t.get("extra"),
C("alert","create__style",function(e){var t=e&&e.getMainSeries(),r=t&&t.getStyle&&t.getStyle();return r&&I.STYLE_SHORT_NAMES.hasOwnProperty(r)?I.STYLE_SHORT_NAMES[r]:"unknown"}(n)),C("alert","create__condition",function(e){var t=e.conditionId();return e.prepareAlertConditions()[t]&&(t="pine_condition"),t||"unknown"}(n)),C("alert","create__frequency",t.get("frequency")||"unknown"),t.isPrice()?C("alert","create__on","price"):t.isDrawing()?C("alert","create__on","drawing"):t.isMoving()?C("alert","create__on","moving"):n.band()||n.upperBand()||n.lowerBand()?C("alert","create__on","study"):C("alert","create__on","unknown"))},G.prototype.getAlertDialogInvocations=function(){return g.alertEditorInvocationHandler.getDialogInvocations()},G.prototype.openCreateDialog=function(e){S(o({type:"create_alert"},e))},G.prototype.openEditDialog=function(e,t){var r,n,o=this,i=function(e){return t.onAborted&&t.onAborted(e)};!(t=t||{}).dataSourceHub&&o.chartWidget()&&(t.dataSourceHub=o.chartWidget().model().model()),e instanceof P?r=e:(n=e,r=o.alerts.get(n)),r?(t=$.extend(t,{alert:r,type:"edit_alert"}),S(t)):n?o.requestAlert(n,{success:function(e){o.openEditDialog(e,t)},error:function(e){"not_exists"===e&&(0,l.showNoticeDialog)({type:"modal",title:window.t("Alert"),content:window.t("Alert does not exist.")}),"function"==typeof t.error&&t.error(e),i(A.AlertIsInvalid)}}):(console.error("[Alerts] alert id is required to edit alert"),i(A.AlertIsInvalid))},G.prototype.subscribeToPushStream=function(e){this._onPushStreamMessage.subscribe(null,e)},G.prototype.unsubscribeFromPushStream=function(e){e?this._onPushStreamMessage.unsubscribe(null,e):this._onPushStreamMessage.unsubscribeAll(null)},G.prototype.getAlertNotifier=function(){if(null===this._notifierPromise){var e=this;this._notifierPromise=F().then((function(t){return t.onEditAlert.subscribe(null,(function(t,r,n){r===f.AlertCategory.Price&&e.openEditDialog(t,o({},n,{actionSource:"alert_notifier_edit"}))})),t.onRestartAlert.subscribe(null,(function(t,r,n){r===f.AlertCategory.Price&&e.restartAlert(t,o({},n,{actionSource:"alert_notifier_restart"}))})),t}))}return this._notifierPromise},e.exports.AlertsDispatcher=G}).call(this,r("q1z7"))},"4BMm":function(e,t){var r={active:"active",aid:"alertId",alerts:"alerts",bar_time:"barTime",create_t:"createTime",cross_int:"crossInterval",deact:"autoDeactivation",desc:"description",email:"sendEmail",error:"error",events:"events",exp:"expired",fire_time:"fireTime",inc_cross_int:"includeCrossInterval",inf_exp:"noExpiration",internal_sym:"symbolInternal",popup:"showPopup",reason:"reason",res:"resolution",script_deps:"scriptDeps",script:"script",sms:"sendSms",true_sms:"sendTrueSms",snd:"playSound",push:"sendPush",snd_duration:"soundDuration",snd_file:"soundFile",sort_by:"sortBy",sort_dir:"sortDirection",start_t:"startTime",stop_t:"stopTime",stop:"stopReason",sym:"symbol",web_hook:"webhookUrl",inst_id:"instanceId",name:"name"},n=function(){var e={};return Object.keys(r).forEach((function(t){e[r[t]]=t})),e}();function o(e,t){var r={}
;return e?(Object.keys(e).forEach((function(n){var o=t(n),i=e[n];r[o]=i})),r):e}t.server2clientParams=function(e){return o(e,(function(e){return r[e]||e}))},t.client2serverParams=function(e){return o(e,(function(e){return n[e]||e}))}},Evi4:function(e,t,r){"use strict";var n=r("C2JW").AlertExtra,o=r("0YCj"),i=r("K4L1"),s=r("cBZt").extractStudyId,a=r("TcSq").extractPineId,l=r("xD5v").prepareCallStudyArgs,c=r("e3/o"),u=r("txPx").getLogger("Alerts.Versioning"),d=r("nmnj"),f=r("nXyu"),p=r("YJLw"),h=r("dn9U"),_=r("n5al"),v=r("PjMa").DataSourceDangerReason,m=r("uXxt").AlertExtraUpdateScheduler,y=r("+GxX").isFeatureEnabled;function g(){this._extraUpdateScheduler=new m}g.version_10_tv_6611_1a_refactoring=10,g.version_11_tv_6611_1b_refactoring=11,g.version_12_tv_6888_fix_plot_index=12,g.version_13_tv_4164_source_code_protection=13,g.version_14_tv_4164_source_code_protection_fix=14,g.version_15_tv_8068_fix_main_series_resolution=15,g.version_16_jv_298_remove_callstudy=16,g.version_17_jv_646_fix_mixed_inputs=17,g.version_18_tv_10636_price_format=18,g.version_19_tv_11267_fix_frequency_options=19,g.version_20_tv_14463_extract_dividends_adjustment_from_symbol_string=20,g.version_21_tv_14886_add_alert_dangerous_source_check=21,g.prototype.migrate=function(e,t){var r;if(t=Object.assign({sendExtraUpdate:y("alerts-send-extra-update")},t),!e||!e.extra)return Promise.resolve(e);if((r=JSON.parse(e.extra))&&!Object.keys(r).length&&r.constructor===Object)return delete e.extra,Promise.resolve(e);var o=Promise.resolve(e),i=null==r.version||r.version<n.VERSION;return i&&(o=this._patchAlert(r,e)),o=o.then(function(e){var r=JSON.parse(e.extra);return r.version<n.VERSION?u.logError("Alert version is less than current"):r.version>n.VERSION?u.logNormal("Alert version is greater than current"):i&&t.sendExtraUpdate&&this._extraUpdateScheduler.scheduleUpdate({id:e.id,instanceId:e.instanceId,extra:e.extra}),e}.bind(this))},g.prototype._patchAlert=function(e,t){var r=this;e.version||(e.version=1);var n=e.version;n<g.version_10_tv_6611_1a_refactoring&&(e.condition.mainSeries=this._patchBand_to10(e.condition.mainSeries,t.symbol),e.condition.options.band&&(e.condition.options.band=this._patchBand_to10(e.condition.options.band,t.symbol)),e.condition.options.upperBand&&(e.condition.options.upperBand=this._patchBand_to10(e.condition.options.upperBand,t.symbol)),e.condition.options.lowerBand&&(e.condition.options.lowerBand=this._patchBand_to10(e.condition.options.lowerBand,t.symbol)),e.version=g.version_10_tv_6611_1a_refactoring),n<g.version_11_tv_6611_1b_refactoring&&(e=this._patchExtra_to11(e)),n<g.version_12_tv_6888_fix_plot_index&&(e=this._patchExtra_to12(e)),n<g.version_13_tv_4164_source_code_protection&&(e=this._patchExtra_to13(e,t)),n<g.version_14_tv_4164_source_code_protection_fix&&(e=this._patchExtra_to14(e,t)),n<g.version_15_tv_8068_fix_main_series_resolution&&(e=this._patchExtra_to15(e,t)),t.extra=JSON.stringify(e);var o=Promise.resolve(t);return n<g.version_16_jv_298_remove_callstudy&&(o=o.then((function(e){return r._patchAlert_to16(e)}))),
n<g.version_17_jv_646_fix_mixed_inputs&&(o=o.then((function(e){var t=JSON.parse(e.extra),n=r._patchExtra_to17(t);return e.extra=JSON.stringify(n),e}))),n<g.version_18_tv_10636_price_format&&(o=o.then((function(e){var t=JSON.parse(e.extra),n=r._patchExtra_to18(t);return e.extra=JSON.stringify(n),e}))),n<g.version_19_tv_11267_fix_frequency_options&&(o=o.then((function(e){return r._patchAlert_to19(e)}))),n<g.version_20_tv_14463_extract_dividends_adjustment_from_symbol_string&&(o=o.then((function(e){var t=JSON.parse(e.extra),n=r._patchExtra_to20(t);return e.extra=JSON.stringify(n),e}))),n<g.version_21_tv_14886_add_alert_dangerous_source_check&&(o=o.then((function(e){var t=JSON.parse(e.extra),n=r._patchExtra_to21(t);return e.extra=JSON.stringify(n),e}))),o},g.prototype.cancelPossibleExtraUpdate=function(e){this._extraUpdateScheduler.cancelUpdate(e)},g.prototype.cancelAllPossibleExtraUpdates=function(){this._extraUpdateScheduler.cancelAllUpdates()},g.prototype._patchBand_to10=function(e,t){return e=this._patchBand_to10_callStudyArgs(e),e=this._patchBand_to10_stateForAlert(e,t)},g.prototype._patchBand_to10_callStudyArgs=function(e){var t=e&&"Study"===e.type,r=t&&(e.alertsData||{}).callStudyArgs,n=t&&e.metaInfo&&e.state&&e.state.inputs;return t&&!r&&n?(e.alertsData||(e.alertsData={}),e.alertsData.callStudyArgs=l(e.state.inputs,e.metaInfo),e):e},g.prototype._patchBand_to10_stateForAlert=function(e,t){var r,n;if(!e)return e;if(n=!e.state,"MainSeries"!==(r=e.type)||n){if("Study"!==r&&!/^study_\w+/.test(r)||n)return e;var o=e.metaInfo.plots.map((function(t){var r={id:t.id,type:t.type,offset:e.data.completePlotOffsets[t.id]};return e.metaInfo.styles&&void 0!==e.metaInfo.styles[t.id]&&(r.title=e.metaInfo.styles[t.id].title||""),t.target&&e.metaInfo.ohlcPlots&&e.metaInfo.ohlcPlots[t.target]&&(r.ohlcTitle=e.metaInfo.ohlcPlots[t.target].title),r}));return{id:e.id,uniqueId:e.uniqueId,type:e.type,title:"",shortDescription:e.state.shortDescription||"Study",fullId:e.metaInfo.fullId,isTVScript:!!e.metaInfo.isTVScript,plots:o,inputs:e.state.inputs,alerts:e.metaInfo.alerts,callStudyArgs:e.alertsData.callStudyArgs,plotIndex:e.plotIndex,plotOffset:e.plotOffset}}return{id:e.id,uniqueId:e.uniqueId,type:e.type,proSymbol:e.state.symbol||t,actualSymbol:t,interval:e.state.interval,style:e.state.style,styleInputs:function(){var t={0:"bar",1:"candle",2:"line",3:"area",4:"renko",5:"kagi",6:"pnf",7:"pb",8:"ha",9:"hollowCandle"}[e.state.style];if(t){var r=e.state[t+"Style"];if(r)return r.inputs}}(),extendedHours:e.state.extendedHours,boxSize:e.boxSize,reversalAmount:e.reversalAmount}},g.prototype._patchExtra_to11=function(e){var t=function(e,t,r){r.id=r.id||c.randomHashN(6),e.condition[t]={id:r.id,plotIndex:r.plotIndex},e.statesForAlert[r.id]=r},r={version:g.version_11_tv_6611_1b_refactoring,condition:{id:e.condition.id,fireInfo:{frequency:e.frequency||"once"},movPeriod:e.condition.options.period,movValue:e.condition.options.value},statesForAlert:{}};t(r,"alertSeries",e.condition.mainSeries);return["band","upperBand","lowerBand"].filter((function(t){
return!!e.condition.options[t]})).forEach((function(n){t(r,n,e.condition.options[n])})),r},g.prototype._patchExtra_to12=function(e){return["alertSeries","band","upperBand","lowerBand"].filter((function(t){return!!e.condition[t]&&void 0!==e.condition[t].plotIndex})).map((function(t){var r=e.condition[t];return{state:e.statesForAlert[r.id],plotIndex:r.plotIndex}})).filter((function(e){return!!e.state.plots})).forEach((function(e){var t=e.state.plots[e.plotIndex];null==t||"object"!=typeof t&&"function"!=typeof t||void 0===t.pinePlotIndex&&(t.pinePlotIndex=e.plotIndex)})),e.version=g.version_12_tv_6888_fix_plot_index,e},g.prototype._patchExtra_to13=function(e,t){var r=e;if(!e.condition.mainSeries){if("MainSeries"===e.statesForAlert[e.condition.alertSeries.id].type)r.condition.mainSeries=r.condition.alertSeries;else{var n=c.randomHashN(6);r.condition.mainSeries={id:n},r.statesForAlert[n]={id:n}}r.statesForAlert[r.condition.mainSeries.id].symbolString=t.symbol}for(var i in e.statesForAlert){var s=e.statesForAlert[i];s.fullId&&(s.scriptIdPart=o.parseIdString(s.fullId).shortId.split("$")[1])}return r.version=g.version_13_tv_4164_source_code_protection,r},g.prototype._patchExtra_to14=function(e,t){var r=e;return e.condition.mainSeries||("MainSeries"===e.statesForAlert[e.condition.alertSeries.id].type?r.condition.mainSeries=r.condition.alertSeries:(r.condition.mainSeries={id:c.randomHashN(6)},r.statesForAlert[r.condition.mainSeries.id]={})),null==r.statesForAlert[r.condition.mainSeries.id].symbolString&&(r.statesForAlert[r.condition.mainSeries.id].symbolString=t.symbol),r.version=g.version_14_tv_4164_source_code_protection_fix,r},g.prototype._patchExtra_to15=function(e,t){var r=e;return null==r.statesForAlert[r.condition.mainSeries.id].interval&&(r.statesForAlert[r.condition.mainSeries.id].interval=t.resolution),r.version=g.version_15_tv_8068_fix_main_series_resolution,r},g.prototype._patchAlert_to16=function(e){var t=JSON.parse(e.extra);function r(e){return e.replace(/tv-scripting-1!?$/,"tv-scripting-88")}function n(t){return(n=t,i=o.cutDollarHash(n.fullId),a=g._recoverFullInputs(n.fullId,n.pineId,n.pineVersion,n.inputs).then((function(e){return{id:f.idForAlert(s(n.fullId),e),study:r(i),inputs:e}})),l=new Promise((function(e,t){var o=JSON.parse(n.callStudyDependencies||"[]").map((function(e){return g._recoverFullInputs(null,e.scriptIdPart,e.scriptVersion,e.inputs).then((function(t){return{id:e.id,study:r(e.study),inputs:t}}))}));Promise.all(o).then((function(t){e(t)}),t)})),a.then((function(e){return l.then((function(t){return[e].concat(t)}))}))).then((function(r){t.studyDependencies=r;var n=r[0];t.id=n.id,t.uniqueId=t.id,e.scriptDeps=e.scriptDeps.concat(r)}));var n,i,a,l}e.scriptDeps=[];var i=[];for(var a in t.statesForAlert)if(t.statesForAlert.hasOwnProperty(a)){var l=t.statesForAlert[a];if("MainSeries"===l.type)l.id=p(l.symbolString+l.interval).toString(),l.uniqueId=l.id;else if(/^LineTool.*/i.test(l.type))l.id=l.uniqueId;else if("Study"===l.type||/^study_\w+/.test(l.type)){var c=n(l);i.push(c)}}
return Promise.all(i).then((function(){return function(e){var t={},r={};Object.keys(e.statesForAlert).forEach((function(n){var o=e.statesForAlert[n].id;t[n]=o,r[o]=e.statesForAlert[n]})),Object.keys(e.condition).filter((function(r){return null!=e.condition[r].id&&null!=t[e.condition[r].id]})).forEach((function(r){e.condition[r].id=t[e.condition[r].id]})),e.statesForAlert=r}(t),t.version=g.version_16_jv_298_remove_callstudy,e.extra=JSON.stringify(t),e}))},g.prototype.patchAlert_to16_forTestsOnly=g.prototype._patchAlert_to16,g.prototype._patchExtra_to17=function(e){for(var t in e.statesForAlert)if(e.statesForAlert.hasOwnProperty(t)){var r=e.statesForAlert[t],n=r.inputs;if(null!=n&&(r.inputs=i.splitInputs(n).obj),null!=r.studyDependencies)for(var o=0;o<r.studyDependencies.length;o++){var s=r.studyDependencies[o];s.inputs=i.splitInputs(s.inputs).obj}}return e.version=g.version_17_jv_646_fix_mixed_inputs,e},g.prototype.patchExtra_to17_forTestsOnly=g.prototype._patchExtra_to17,g._recoverFullInputs=function(e,t,r,n){if(t=t||e&&a(e)||n.pineId,r=r||n.pineVersion||"-1",null==t)return Promise.resolve(n);var o=d.translateScriptAsync2(t,r);return new Promise((function(e,t){o.then(e,t)})).catch((function(e){if("-1"===r&&t.startsWith("USER")){var o=function(e){var t={};return Object.keys(e).forEach((function(r){var n,o=e[r];r.startsWith("in_")?(n=["open","high","low","close","hl2","hlc3","ohlc4"].indexOf(o)>0||/.*\$\d+/.test(o)?"source":"string"==typeof o?"string":"boolean"==typeof o?"bool":"float",t[r]={f:!0,v:o,t:n}):t[r]=o})),t}(n);return u.logNormal("A very rare case: alert on legacy script that was never resaved. Trying to guess input types \n\t"+JSON.stringify(n)+" -> "+JSON.stringify(o)),o}return u.logError("Alert migration failed, inputs cannot be migrated: "+JSON.stringify(e)),Promise.reject(e)})).then((function(e){return TVScript.patchInputs(e.inputs,n)}))},g.prototype._patchExtra_to18=function(e){var t,r={},n=h.getData(e.condition.id);if(n&&"comparison"===n.type)if(n.isChannel){var o=e.statesForAlert[e.condition.upperBand.id],i=e.statesForAlert[e.condition.lowerBand.id];"Value"===o.type?t=o.value:"Value"===i.type&&(t=i.value)}else{var s=e.statesForAlert[e.condition.band.id];"Value"===s.type&&(t=s.value)}if(t&&-1!==(t=t.toString().replace(/^-/,"")).indexOf(".")){var a=t.replace(/^\d+\./,"").length,l=Math.pow(10,a);r.priceScale=l}var c=e.condition.alertSeries.id;return e.statesForAlert[c].formatter={type:"price",state:r},e.version=g.version_18_tv_10636_price_format,e},g.prototype._patchAlert_to19=function(e){var t=JSON.parse(e.extra),r=e.autoDeactivation,n=t.condition.fireInfo.frequency,o=t.statesForAlert[t.condition.mainSeries.id],i=["band","lowerBand","upperBand"].map((function(e){var r=t.condition[e];return r&&t.statesForAlert[r.id]})).filter((function(e){return!!e})).filter((function(e){return"LineToolVertLine"===e.type})).length>0,s=_.hasProjection(o.style),a=e.crossInterval,l=[];function c(e){return-1!==l.indexOf(e)}return i?l.push("once"):(a||s||(l.push("once"),l.push("60"),l.push("on_bar_close")),
s?l.push("on_bar_close"):l.push("on_first_fire")),"once_per_bar"===n&&(n="on_first_fire"),"once"!==n||c("once")||(r=!0,n=l[0]),"once"!==n&&r&&(n=l[0]),"once"!==n&&i&&(r=!0,n="once"),"on_bar_close"===n&&!c("on_bar_close")&&c("on_first_fire")&&(n="on_first_fire"),e.autoDeactivation=r,t.condition.fireInfo.frequency=n,t.version=g.version_19_tv_11267_fix_frequency_options,e.extra=JSON.stringify(t),e},g.prototype._patchExtra_to20=function(e){var t=e.condition.mainSeries,r=e.statesForAlert,n=t&&r&&r[t.id];if(n){var o=n.symbolString;if(o&&0===o.indexOf("=")){var i=o.slice(1);"dividends"===(i=JSON.parse(i)).adjustment?n.dividendsAdjustment=!0:"splits"===i.adjustment&&(n.dividendsAdjustment=!1)}}return e.version=g.version_20_tv_14463_extract_dividends_adjustment_from_symbol_string,e},g.prototype.patchExtra_to20_forTestsOnly=g.prototype._patchExtra_to20,g.prototype._patchExtra_to21=function(e){var t=e.statesForAlert;for(var r in t)if(t.hasOwnProperty(r)){var n=t[r];n.isSpread&&(n.dangerReason=v.Spread)}return e.version=g.version_21_tv_14886_add_alert_dangerous_source_check,e},e.exports={AlertVersioning:g}},JZcM:function(e,t,r){"use strict";var n;r.d(t,"a",(function(){return n})),function(e){e.Fired="fired",e.FireControl="fire_control"}(n||(n={}))},Zdjc:function(e,t,r){"use strict";r.r(t),r.d(t,"createGoProAlertsTrueSmsDialog",(function(){return o})),r.d(t,"showGoProAlertsTrueSmsDialog",(function(){return i}));r("YFKU");var n=r("oOPW");function o(){return Object(n.createGoProDialog)({feature:"alertsTrueSms",goOnMarkets:!1,isTrialAvailable:!0,upgradeMessage:window.t("Upgrade now"),visitPaymentPage:{billing_cycle:"y",options:{productName:"pro_premium",newWindow:!0}}})}function i(){o()}},flg1:function(e,t,r){"use strict";r.r(t),r.d(t,"showAlertsMaintenanceDialog",(function(){return i}));var n=r("1UCy"),o=r("PlME");function i(){Object(o.showAbortExplainingDialog)(n.AlertEditorAbortReason.AlertsMaintenance)}},gdgp:function(e,t,r){"use strict";r.r(t),r.d(t,"showGoProMaxAlertsDialog",(function(){return o}));var n=r("oOPW");function o(){Object(n.createGoProDialog)({feature:"alerts"})}},ijto:function(e,t,r){"use strict";function n(e){return Promise.all(e.map((function(e){return e.then((function(e){return{status:"fulfilled",value:e}})).catch((function(e){return{status:"rejected",reason:e}}))})))}r.r(t),r.d(t,"allSettled",(function(){return n}))},jA5l:function(e,t,r){"use strict";r.r(t),r.d(t,"showGoProAlertsWebhookDialog",(function(){return o}));var n=r("oOPW");function o(){Object(n.createGoProDialog)({feature:"alertsWebhook"})}},oNDq:function(e,t,r){"use strict";r.r(t),r.d(t,"createConfirmDialog",(function(){return i}));var n=r("mrSG"),o=r("YFKU");function i(e){var t={actions:[{key:13,name:"yes",text:o.t("Yes"),type:"success"},{method:"close",name:"no",text:o.t("No"),type:"default"}],actionsWrapTemplate:'<div class="tv-dialog__section tv-dialog__section--actions tv-dialog__section--no-border">',content:o.t("Are you sure?"),
contentWrapTemplate:'<div class="tv-dialog__section tv-dialog__section--no-border"><div class="tv-text"><p></p></div></div>',destroyOnClose:!0,title:o.t("Confirmation"),width:400,dataset:{"dialog-type":"confirm-dialog"}};return new Promise((function(o){Promise.all([r.e("vendors_embed"),r.e("dialogs-core"),r.e(12),r.e(21),r.e(23),r.e(37),r.e(15),r.e(22),r.e(35),r.e(45),r.e(185),r.e("create-dialog")]).then(function(i){var s=r("YDhE").createDialog;o(s(Object(n.a)(Object(n.a)({},t),e)))}.bind(null,r)).catch(void 0)}))}},sg6D:function(e,t,r){"use strict";var n=r("/ELx").extend({_prepareToSet_fireTime:function(e){return new Date(1e3*e)},_prepareToSet_barTime:function(e){return new Date(1e3*e)},_prepareToSet_alertId:function(e){return parseInt(e)},fireTimeReadable:function(){return this._formatDate(this.get("fireTime"))},fireTimeUnix:function(){return Math.round(this.get("fireTime").getTime()/1e3)}});e.exports=n},"tc+8":function(e,t,r){"use strict";(function(t){var n=r("ogJP").isFunction;function o(e){if(this._listeners=new t,this._childs=[],this._muteChildChanges=!1,void 0!==e)if(this.isPrimitiveType(e))this._value=e;else for(var r in e)this.addProperty(r,e[r])}o.prototype.merge=function(e,t){var r=null;if(t)var n=(r=[]).length;if(void 0===e)return r;if(this.isPrimitiveType(e))return t&&this._value!==e&&r.push(this),this._value=e,r;if(Array.isArray(e))for(var o=0;o<e.length;o++)if(this[o]){var i=this[o].merge(e[o],t);t&&(r=r.concat(i))}else this.addProperty(o,e[o]),t&&r.push(this[o]);else for(var s in e)if(this[s]){i=this[s].merge(e[s],t);t&&void 0!==i&&(r=r.concat(i))}else this.addProperty(s,e[s]),t&&r.push(this[s]);return t&&r.length>n&&r.push(this),r},o.prototype.mergeAndFire=function(e){var t=this.merge(e,!0);this._muteChildChanges=!0,t.forEach((function(e){e._muteChildChanges=!0})),t.forEach((function(e){e._muteChildChanges=!1,e.listeners().fire(e)})),this._muteChildChanges=!1,t.length>0&&this.listeners().fire(this)},o.prototype.state=function(e){var t=n(this.value)?this.value():void 0;void 0===t&&(t={});for(var r=0;r<this._childs.length;r++){var o=this._childs[r];if(!e||-1===e.indexOf(o))if(e){for(var i=[],s=0;s<e.length;s++){var a=e[s];a.startsWith(o+".")&&i.push(a.substr(o.length+1))}t[o]=this[o].state(i)}else t[o]=this[o].state()}return t},o.prototype.clone=function(e){return new o(this.state())},o.prototype.isPrimitiveType=function(e){return null===e||(!!isNumber(e)||(!!new TradingView.TypeValidator(String).check(e)||TradingView.isBoolean(e)))},o.prototype.value=function(){return this._value},o.prototype.listeners=function(){return this._listeners},o.prototype.childCount=function(){return this._childs.length},o.prototype.childNames=function(){return this._childs},o.prototype.child=function(e){return this[e]},o.prototype.setValue=function(e,t){(this._value!==e||t)&&(this._value=e,this._listeners.fire(this))},o.prototype.setValueSilently=function(e){this._value=e},o.prototype.addProperty=function(e,t){var r=new o(t);this[e]=r,this._childs.push(e),r.subscribe(this,this.childChanged)},
o.prototype.removeProperty=function(e){this[e].unsubscribe(this,this.childChanged),delete this[e],this._childs=this._childs.filter((function(t){return t!==e}))},o.prototype.hasChild=function(e){return this._childs.indexOf(e)>=0},o.prototype.addChild=function(e,t){this[e]&&this[e].unsubscribe(this,this.childChanged),this[e]=t,-1===this._childs.indexOf(e)&&this._childs.push(e),t.subscribe(this,this.childChanged)},o.prototype.childChanged=function(e,t){this._muteChildChanges||this.listeners().fire(this)},o.prototype.subscribe=function(e,t){this.listeners().subscribe(e,t,!1)},o.prototype.unsubscribe=function(e,t){this.listeners().unsubscribe(e,t)},o.prototype.unsubscribeAll=function(e){this.listeners().unsubscribeAll(e)},o.prototype.childs=function(){return this},e.exports=o}).call(this,r("aIyQ"))},uOo4:function(e,t,r){"use strict";function n(e){return!e.isDrawing()}r.r(t),r.d(t,"isAlertCloneable",(function(){return n}))},uXxt:function(e,t,r){"use strict";r.r(t),r.d(t,"AlertExtraUpdateScheduler",(function(){return c}));var n=r("mrSG"),o=r("hWRP"),i=r("4BMm"),s=r("txPx"),a=Object(s.getLogger)("Alerts.ExtraUpdateScheduler"),l=clearTimeout,c=function(){function e(){this._queue=new Map,this._taskHandle=null}return e.prototype.scheduleUpdate=function(e){this._queue.set(e.id,e),this._maybeScheduleTask()},e.prototype.cancelUpdate=function(e){this._queue.delete(e),null!==this._taskHandle&&0===this._queue.size&&(l(this._taskHandle),this._taskHandle=null)},e.prototype.cancelAllUpdates=function(){this._queue.clear(),null!==this._taskHandle&&(l(this._taskHandle),this._taskHandle=null)},e.prototype._maybeScheduleTask=function(){var e=this;null===this._taskHandle&&0!==this._queue.size&&(this._taskHandle=setTimeout((function(){return Object(n.b)(e,void 0,void 0,(function(){var e;return Object(n.d)(this,(function(t){switch(t.label){case 0:return(e=this._queue.values().next().value)?(this._queue.delete(e.id),[4,u(e)]):[3,2];case 1:t.sent(),t.label=2;case 2:return this._taskHandle=null,this._maybeScheduleTask(),[2]}}))}))}),1e3))},e}();function u(e){return a.logDebug("Sending extra update request for alert "+e.id),Object(o.sendRequest)({method:"update_extra",params:Object(i.client2serverParams)(e)}).then((function(){return a.logDebug("Extra has been updated successfully for alert "+e.id)}),(function(t){return a.logWarn("Could not update extra for alert "+e.id+": "+t)}))}},zL88:function(e,t,r){"use strict";function n(){Promise.all([r.e("vendors_embed"),r.e(1),r.e(3),r.e(30),r.e(38),r.e(43),r.e(211),r.e(0),r.e(164),r.e("show-warning-alerts-max-total-count-exceeded")]).then(r.bind(null,"MR9f")).then((function(e){return e.showWarningAlertsMaxTotalCountExceededImpl()}))}r.r(t),r.d(t,"showWarningAlertsMaxTotalCountExceeded",(function(){return n}))},zNIe:function(e,t,r){"use strict";function n(e){var t=new URL("chart",window.location.origin);return t.searchParams.append("symbol",e),t.toString()}r.d(t,"a",(function(){return n}))}}]);