15 lines
44 KiB
JavaScript
15 lines
44 KiB
JavaScript
(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[273],{86782:(e,t,r)=>{e.exports=r.p+"alarm_clock.48d3df0afe4d4981523b8a12e4e25f92.mp3"},47740:(e,t,r)=>{"use strict";r.d(t,{AlertConditionEditor:()=>c});var i=r(28353),a=r(2495),n=r(37387),o=r.n(n),s=r(98125),l=r(9423),d=r(50993);const u=(0,s.getLogger)("Alerts.Price.ConditionEditor");class c{constructor(e){this._dialogCreator=e,this._alert=e.alert,this._extra=this._alert&&this._alert.get("extra")||null,this._operatorsData=o().defaults(),this._secondOperandIdsForAlert={},this._valueBands={}}hasCondition(){return!!this._extra}getMainSeriesPlotIndexOptions(){const e=this._extra.alertSeries();if(!e)return[];const t=this._extra.conditionData();return["pine_script","pine_alertcondition_plot","alerts"].includes(t.type)?[]:this._getPlotIndexOptions(e)}getMainSeriesSelectOptions(){const e=this._extra.alertSeries().id,t=this._extra.drawing(),r={selectedValue:e,shortTitle:!0};return t&&(r.excluded=[{id:t.id}],r.excludeAlertConditionsOnly=!0),this._dialogCreator.getSeriesSelectOptions(r)}updateMainSeriesIdForAlert(e,t){return this._extra.alertSeries().id!==e&&(this._dialogCreator.update({alertSeries:this._dialogCreator.prepareBandForExtra(e,void 0,t)}),!0)}updateMainSeriesPlotIndex(e){if("number"!=typeof e&&(e=+e),isFinite(e)){const t=this._extra.alertSeries();"number"==typeof t.plotIndex&&e!==t.plotIndex&&(t.plotIndex=e,this._dialogCreator.update({alertSeries:t}))}}getOperatorOptionGroups(){const e=this._extra.state().condition,t=o().ordered(this._extra,{isGrouped:!0}),r=[];for(const i of t){const t=[];for(const r of i)t.push({value:r.id,caption:r.title||null,selected:Boolean(e&&r.id===e.id)});r.push(t)}return r}updateOperator(e){const t=this._extra.state().condition,r=t&&this._operatorsData[t.id],i=this._operatorsData[e];return t.id!==e&&this._dialogCreator.update({conditionId:e}),this._getSecondOperandType(r)!==this._getSecondOperandType(i)}getSecondOperandInputs(){const e=this._extra.state().condition;if(!(e&&this._operatorsData[e.id])){const e=this._extra.conditionData();return["pine_script","pine_alertcondition_plot","alerts","strategy","strategy_and_alerts"].includes(e.type)?[]:void u.logError("Unable to get condition operator data")}const t=[],r=o().getData(e.id,this._extra);if("comparison"===r.type)if(r.isChannel)if(this._alert.isDrawing()){const e=this._extra.drawing();t.push({name:"fake-drawing-band-main",isDrawing:!0,options:[{value:e.id,caption:e.title}]})}else t.push({label:(0,i.t)("Upper Bound"),name:"upper-band-main",valueName:"upper-band-additional",options:this._getSecondOperandSeriesOptions(this._extra.getUpperBand(),"upper-band-main")}),t.push({label:(0,i.t)("Lower Bound"),name:"lower-band-main",valueName:"lower-band-additional",options:this._getSecondOperandSeriesOptions(this._extra.getLowerBand(),"lower-band-main")});else t.push({name:"band-main",valueName:"band-additional",options:this._getSecondOperandSeriesOptions(this._extra.getBand(),"band-main")});else if("moving"===r.type){const e=this._extra.value();let i=1,a=null
|
|
;r.percents?(i=.01,a={format:e=>Number(e).toFixed(2),parse:e=>parseFloat(e)}):(a=this._getFormatter(),i=this._getPriceStep(e,a)),t.push({isMoving:!0,unit:r.percents?"%":"",value:{name:"moving-value",value:e,min:i,max:1/0,step:i,formatter:a},period:{name:"moving-period",value:this._extra.period(),min:Math.max(1,this._dialogCreator.minMovingPeriod(this._extra.alertSeries())),max:this._dialogCreator.maxMovingPeriod(),step:1}})}return t}updateMovingValue(e){this._dialogCreator.update({value:e})}updateMovingPeriod(e){this._dialogCreator.update({period:e})}updateSecondOperandSeriesIdForAlert(e,t){const r=this._getBandNameByInputName(t.name);this._secondOperandIdsForAlert[r]=e}updateSecondOperandValue(e,t){const r=this._getBandNameByInputName(t.name),i=this._getBandByBandName(r);if("Value"===i.type)i.value=e,this._updateValueBand(r,e);else{const t=+e;isFinite(t)&&t!==i.plotIndex&&Array.isArray(i.plots)&&void 0!==i.plots[t]&&(i.plotIndex=t)}const a={};a[r]=i,this._dialogCreator.update(a)}getSecondOperandSeriesValueType(e){if(e.isDrawing)return"drawing";const t=this._getBandNameByInputName(e.name),r=this._getBandByBandName(t);if(r){if("band"===t){const e=this._extra.drawing();if(e&&e.id===r.id)return"drawing"}return"Value"===r.type?"value":"plotIndex"}u.logError("Unable to get band for second operand")}getSecondOperandSeriesValueOptions(e){const t=this._getBandNameByInputName(e.name),r=this._getValueBand(t),i=parseFloat(r.value);"Value"!==r.type&&u.logError(`Band "${t}" is not of "Value" type`);const a=this._getFormatter();return{value:i,formatter:a,step:this._getPriceStep(i,a),min:-1/0,max:1/0}}isStrategy(){if(!this._extra)return!1;const e=this._extra.conditionData();return"strategy"===e.type||"strategy_and_alerts"===e.type}isOnlyAlertFunctionCondition(){if(!this._extra)return!1;return"alerts"===this._extra.conditionData().type}isSeriesWithAlertFunction(){return!!this._extra&&this._extra.hasAlertFunction()}_getFormatter(){let e=this._alert.getFormatter();if(!e){const t=this._extra.alertSeries(),r=this._dialogCreator.getStateForAlertById(t.id);r&&r.formatter&&(e=r.formatter())}return e}_getPriceStep(e,t){let r=this._getPriceStepByFormatter(t);return r||(r=this._calculatePriceStep(e,t)),r}getSecondOperandPlotIndexOptions(e,t){const r=this._getBandByInputName(t.name),i=this._getSecondOperandPlotsToExclude(e,t.name);return this._getPlotIndexOptions(r,i)}getSecondOperandPlots(e){const t=this._getBandNameByInputName(e.name),r=this._getBandByBandName(t);return r&&Array.isArray(r.plots)?r.plots:[]}_getSecondOperandPlotsToExclude(e,t){const r=this,i=[],a=this._extra.alertSeries();if(a&&a.id===e&&n(a),"lower-band-main"===t){const t=this._getBandByInputName("upper-band-main");t&&t.id===e&&n(t)}function n(e){const t=r._getPlotIndexOptions(e);for(let e=0;e<t.length;e++)if(t[e].selected){i.push(t[e].value);break}}return i}_getPlotIndexOptions(e,t){if(this.isStrategy())return[];const r=a.alertBandFactory.create(e),i=r&&r.getPlots(),n=e&&"number"==typeof e.plotIndex&&e.plotIndex;if(Array.isArray(i)&&i.length){const e=[];let a=!1
|
|
;for(let o=0;o<i.length;++o){if(t&&-1!==t.indexOf(o)||(0,d.isAlertConditionPlot)(i[o]))continue;const s={value:o,caption:r.getPlotTitle(i[o])};n===o&&(s.selected=!0,a=!0),e.push(s)}return!a&&e.length&&(e[0].selected=!0),e}return[]}getDescription(){return this._alert.defaultDescription()}getName(){return this._alert.defaultName()}isDescriptionSetByUser(){return this._checkIsExistingAlertType()&&this._alert.get("description")!==this._alert.defaultDescription()}isNameSetByUser(){return this._checkIsExistingAlertType()&&(this._alert.get("name")||"")!==this._alert.defaultName()}getFireRateOptions(){return this._dialogCreator.getFireRateOptions()}_getPriceStepByFormatter(e){if(!e)return;const t="function"==typeof e.state&&e.state()||{};return t.priceScale&&t.minMove?t.minMove/t.priceScale:void 0}_calculatePriceStep(e,t){var r=1;if(!t)return r;if(void 0!==e)e="string"==typeof e?parseFloat(e):e;else if(void 0!==this._options.value)e=this._options.value;else{if(!this.alert||!this.alert.isPrice())return r;e=this.alert.get("extra").price().upperBand||this.alert.get("extra").price()}if(-1!==(e=(e=t.format(e)).replace(/^-/,"")).indexOf(".")){var i=e.replace(/^\d+\./,"").length;r=Math.pow(10,-1*i)}return r}_getSecondOperandType(e){let t=e&&(e.isChannel?"channel":e.type)||null;return"moving"!==t||"moving_up_percents"!==e.id&&"moving_down_percents"!==e.id||(t="moving_percent"),t}_getSecondOperandSeriesOptions(e,t){const r=this._getSecondOperandExcluded(t),a=[{value:"Value",caption:(0,i.t)("Value")}],n=this._extra.drawing();n&&a.push({value:n.id,caption:(0,i.t)(n.title),removeOnChange:!0});const o=e.id();return this._dialogCreator.getSeriesSelectOptions({prepend:a,excluded:r,excludeTypes:["MainSeries","StudyStrategy"],selectedValue:o,shortTitle:!0,excludeAlertConditionsOnly:!0})}_getSecondOperandExcluded(e){const t=e=>e.plots.length-e.plots.filter(d.isAlertConditionPlot).length,r=[];if("upper-band-main"===e){const e=this._getBandByInputName("lower-band-main");Array.isArray(e.plots)&&t(e)<=1&&r.push({id:e.id})}if("lower-band-main"===e){const e=this._getBandByInputName("upper-band-main");Array.isArray(e.plots)&&t(e)<=1&&r.push({id:e.id})}const i=this._extra.alertSeries();if(i&&"MainSeries"!==i.type)if(Array.isArray(i.plots)){const a=t(i);if(a<=1&&r.push({id:i.id}),2===a){if("upper-band-main"===e){const e=this._getIdForAlertByInputName("lower-band-main");i.id===e&&r.push({id:e})}if("lower-band-main"===e){const e=this._getIdForAlertByInputName("upper-band-main");i.id===e&&r.push({id:e})}}}else r.push({id:i.id});return r}_getBandNameByInputName(e){return"band-main"===e?"band":"upper-band-main"===e?"upperBand":"lower-band-main"===e?"lowerBand":null}_getBandByInputName(e){return this._getBandByBandName(this._getBandNameByInputName(e))}_getIdForAlertByInputName(e){return this._secondOperandIdsForAlert[this._getBandNameByInputName(e)]}_getBandByBandName(e){const t="function"==typeof this._extra[e]&&this._extra[e]()||null;if(null!=this._secondOperandIdsForAlert[e]){const r=this._secondOperandIdsForAlert[e],i=void 0
|
|
;return this._dialogCreator.prepareBandForExtra(r,t?t.plotIndex:void 0,i)}return t}_getValueBand(e){if(this._valueBands[e])return this._valueBands[e];let t=this._extra[e]();if("Value"!==t.type){var r=(0,l.randomHashN)(6);t={id:r,uniqueId:r,type:"Value",value:0}}return this._valueBands[e]=t,t}_updateValueBand(e,t){this._getValueBand(e).value=t}_checkIsExistingAlertType(){return"edit_alert"===this._dialogCreator.getType()||"show_alert"===this._dialogCreator.getType()}}},79540:(e,t,r)=>{"use strict";var i=r(23127),a=r(28353).t,n=r(25531).Alert,o=r(7298).AlertExtra,s=r(37387),l=r(2495),d=l.alertBandFactory,u=l.AlertBandValue,c=l.AlertBandStudy,p=r(62591).isStudyStateForAlertType,h=r(47740).AlertConditionEditor,g=r(16256).DEFAULT_SOUNDS,_=r(82992).linking,m=r(38874).loadTVScript,f=r(76861);const{trackGoProFeature:y}=r(87463);var S=r(2872),v=r(66712),b=r(99486).getAlertDialogType,A=r(33550).enabled,w=r(62867).ProductFeatures,x=r(84015).isOnMobileAppPage,B=r(9423),P=r(98125).getLogger("Alerts.Price.AlertEditor"),D=r(94738).AlertCategory,I=r(72154).createAlertDataSourceBridge,T=r(58352).canSubmitAlert,O=r(58352).AlertSubmitFailReason,E=r(22822).canPlaceAlertOnResolution,C=r(24993).AlertEditorAbortReason,F=r(26978).validateWebhookUrl,V=r(26978).WebhookValidationResult,M=new Map([[V.EmptyUrl,a("A Webhook url is required")],[V.BadUrl,a("This url is invalid")],[V.BadScheme,a("A http(s) protocol is required")],[V.BadHTTPPort,a("Only port 80 is allowed for HTTP")],[V.BadHTTPSPort,a("Only port 443 is allowed for HTTPS")],[V.BadHost,a("This host is not allowed")]]);function k(e,t){f.isLocal()&&(window._exposed_alertEditor=this),this._options=t||{},this._prepareOptions();var r=this._options.abortSignal;if(r){var i=this._abort.bind(this,C.ManualAbort);if(r.value())return void i();r.subscribe(i),this._releaseAbortSignal=function(){r.unsubscribe(i)}}this._priceAlertsDispatcher=e,this._dataSourceHub=this._options.dataSourceHub,this.dialogOpened=new S,this._options.onDialogOpened&&this.dialogOpened.subscribe(null,this._options.onDialogOpened,!0),this._options.silent=this._options.silent||!1,this._type=b(this._options),this._saveAlertFunc=this._options.saveAlertFunc,this._deleteAlertFunc=this._options.deleteAlertFunc,this._cache={},this._createAlertEditor(this._dataSourceHub)}function N(e,t,r,i,a){r&&(!t||t.id()!==r.id())&&r.detachAlert(),t?t.setAlert(e.id).then(()=>{e.get("extra").mainSeries().id===t.model().mainSeries().stateForAlert().id&&t.synchronizeAlert(!0),i()}).catch(a):i()}k.prototype._prepareOptions=function(){this._options.series&&!this._options.series.alertCreationAvailable()&&delete this._options.series,this._options.drawing&&!this._options.drawing.alertCreationAvailable()&&delete this._options.drawing},k.prototype._createAlertEditor=function(e){var t=e?e.mainSeries():null,r=t?t.symbolInfo():null;if(!e||r)this._init();else{var i=this;!function(){e.mainSeries().dataEvents().symbolResolved().subscribe(null,r);var t=setTimeout((function(){e.mainSeries().dataEvents().symbolResolved().unsubscribe(null,r),
|
|
i._abort(C.SymbolInfoTimeout)}),2e4);function r(a){clearTimeout(t),a?(e.mainSeries().dataEvents().symbolResolved().unsubscribe(null,r),i._init()):i._abort(C.SymbolIsInvalid)}}()}m()},k.prototype._init=function(){var e;this._dataSourceHub?(e=this.mainSeries(),this._symbol=e.actualSymbol(),this._symbolInternal=e.getSymbolString(),this._resolution=e.interval()):(this._symbol=_.symbol.value(),this._resolution=_.interval.value()||"1"),I(this._dataSourceHub).then(function(e){this._dataSourceBridge=e,this._initCurrentAlert(),this._options.alert&&this._options.alert.saveState(),this._options.silent?T(this.alert,this._dataSourceBridge).then(function(e){e.canSubmit?this._placeAlert(this.alert):this._abort(e.reason===O.DangerousSource?C.SourceIsDangerous:C.MisleadingPriceScale)}.bind(this)):this._createDialog(),window.lineToolPropertiesToolbar&&window.lineToolPropertiesToolbar.hide()}.bind(this))},k.prototype._hide=function(){this.dialog&&this.dialog.hide()},k.prototype._show=function(){this.dialog&&this.dialog.show()},k.prototype.destroy=function(e){!0!==e&&this.dialog?this.dialog.close():this._onDestroyAsync()},k.prototype._onDestroyAsync=function(){if(this._generationPromise){var e=this;this._generationPromise.then((function(t){"cancelled: new alert already generating"!==t&&e._onDestroy()}))}else this._onDestroy()},k.prototype._onDestroy=function(){if("edit_alert"===this._type){if(this.alert&&this._onOkSucceed&&this.alert.saveState(),this._onOkSucceed&&"function"==typeof this._options.onEditSuccess&&this._options.onEditSuccess(),this.alert&&!this._onOkSucceed){const e=this.alert.state(),t=this._originalState,r=["active","fireTime","fire_bar_time","startTime","stopTime","stopReason"];for(const i of r)e.hasOwnProperty(i)&&(t[i]=e[i]);this.alert.restoreState(t)}this._onOkSucceed||"function"!=typeof this._options.onEditCancel||this._options.onEditCancel(),"function"==typeof this._options.onEditComplete&&this._options.onEditComplete()}this.alert&&(this.alert.off("destroy",this.destroy,this),this.alert.isNew()&&this._priceAlertsDispatcher.deleteAlert(this.alert)),"function"==typeof this._options.onDestroy&&this._options.onDestroy(),this._releaseAbortSignal&&this._releaseAbortSignal(),window.lineToolPropertiesToolbar&&window.lineToolPropertiesToolbar.refresh()},k._createValueDataSource=function(e){var t=B.randomHashN(6);return{id:t,uniqueId:t,type:"Value",value:e}},k.prototype._initCurrentAlert=function(){var e=this._options.alert,t=!1;if(e instanceof n)t=this._defaultDescriptionBySavedState(e)!==e.get("description"),this._originalState=e.getSavedState()||e.state(),e.saveState(),this.alert=e;else{if(!this._dataSourceHub)return void P.logError("Can't create alert without chart widget");var r=this.defaults({type:"alert"});e=this._priceAlertsDispatcher.createLocalAlert(r,!0),this.alert=e;var a=this.defaults({type:"extra"}),s=new o(a);e.set("extra",s);var l=s.getDependencies();if(e.set("scriptDeps",l),s.conditionId(this.defaults({name:"conditionId"})),this._options.drawing){var d=this._options.drawing.stateForAlert(),u=d.plots||[]
|
|
;d=i.extend(!0,{},d),1===u.length?s.band(i.extend(!0,{plotIndex:0},d)):1<u.length&&(s.upperBand(i.extend(!0,{plotIndex:0},d)),s.lowerBand(i.extend(!0,{plotIndex:1},d)))}else this._options.value&&s.band(k._createValueDataSource(this._options.value));s.setValidConditionId(),e.frequencyController.switchFrequencies()}var c=e.get("extra");"create_alert"!==this._type&&t||e.setDefaultDescription(),"create_alert"===this._type&&e.set("name",e.defaultName()),this._options.value&&e.isPrice()&&c.band()&&c.price(this._options.value),this.alert.on("destroy",this.destroy,this)},k.prototype._defaultDescriptionBySavedState=function(e){var t=e.defaultDescription(),r=e.getSavedState();if(r){var i=e.state();e.restoreState(r,!0),t=e.defaultDescription(),e.restoreState(i,!0)}return t},k.prototype._placeAlert=function(e){const t=this._getAlertDrawingDataSource(),r=e=>{e&&P.logError(String(e)),this._onDestroyAsync()},i={success:e=>N(e,t,null,()=>{},r),error:r,actionSource:this._options.actionSource};this._generationPromise="create_alert"===this._type?this._priceAlertsDispatcher.createAlert(e,i):this._priceAlertsDispatcher.restartAlert(e,i)},k.prototype.update=function(e){var t=this.alert;e=e||{};var r=this._dataSourceBridge.getMainSeriesState();if(t){var i=t.get("extra");if(i){var a=i.conditionId(),n=t.frequencyController.getAvailable();if(this._cachedConditionOptions||(this._cachedConditionOptions={}),e.alertSeries){var o=i.alertSeries().id;i.alertSeries(e.alertSeries);var l=i.alertSeries().id;const a=i.hasAlertCondition(),n=i.hasAlertFunction();o===l||!a&&!n||e.conditionId||(e.conditionId=s.ordered(i)[0].id),this._updateAlertSymbol(),r&&(this._bandIsInAlertState(e.alertSeries)?this._restoreMainSeriesAndResolution():i.mainSeries(r)),t.trigger("change:alertSeries",t)}for(var d=["upperBand","lowerBand","band","value","period"],u=d.length-1;u>=0;u--){var c=d[u];i[c]()&&(this._cachedConditionOptions[c]=i[c]())}e.conditionId&&i.conditionId(e.conditionId,!0);var p=i.conditionData(),h=void 0!==e.conditionId||a!==i.conditionId()||void 0!==e.upperBand||void 0!==e.lowerBand||void 0!==e.band||void 0!==e.value||void 0!==e.period;if(h){switch(i.clearOptionalConditions(!0),p.type){case"comparison":p.isChannel?(i.upperBand(e.upperBand||this._cachedConditionOptions.upperBand||this.defaults({name:"upperBand"}),!0),i.lowerBand(e.lowerBand||this._cachedConditionOptions.lowerBand||this.defaults({name:"lowerBand"}))):i.band(e.band||this._cachedConditionOptions.band||this.defaults({name:"band"}));break;case"moving":var g=e.value;void 0===g&&(g=this._cachedConditionOptions.value),void 0===g&&(g=this.defaults({name:"value"}));var _=e.period;void 0===_&&(_=this._cachedConditionOptions.period),void 0===_&&(_=this.defaults({name:"period"})),i.value(g),i.period(_);break;case"pine_alertcondition_plot":case"pine_script":case"alerts":case"strategy":case"strategy_and_alerts":break;default:P.logError("Unknown condition type")}var m=t.get("crossInterval"),f=t.getSavedState()&&t.getSavedState().crossInterval;if(r&&!m&&f){var y=i.alertSeries()
|
|
;"MainSeries"===y.type&&y.actualSymbol===r.actualSymbol&&(i.mainSeries(r),i.alertSeries(r),this._updateAlertSymbol())}}var S=i.getDependencies();t.set("scriptDeps",S);var v=t.frequencyController.getAvailable();i.getAvailableBands().forEach((function(r){e[r]&&JSON.stringify(n)!==JSON.stringify(v)&&t.frequencyController.switchFrequencies()})),(e.alertSeries||h)&&t.syncAlertType()}var b,A,w,x,B=["expired","showPopup","description","playSound","soundFile","soundDuration","sendSms","sendEmail","sendPush","noExpiration","webhookUrl","name"];for(u=0;u<B.length;u++)void 0!==(A=e[b=B[u]])&&("soundDuration"===b&&(A=parseInt(A)),w=b,x=A,t.set(w,x));var D={};["autoDeactivation","frequency"].forEach((function(t){void 0!==e[t]&&(D[t]=e[t])})),Object.keys(D).length>0&&t.set(D)}},k.prototype._updateAlertSymbol=function(){var e=this.alert.get("extra"),t=e&&e.getAlertSeries();t&&("MainSeries"===t.type()?this.alert.set({symbol:t.getActualSymbol(),symbolInternal:t.getSymbolString(),resolution:this.alert.get("crossInterval")?"1":t.getInterval()}):this.alert.set({symbol:this._symbol,symbolInternal:this._symbolInternal,resolution:this.alert.get("crossInterval")?"1":this._resolution}))},k.prototype._bandIsInAlertState=function(e){if(this.alert&&this.alert.getSavedState())for(var t=this.alert.getSavedState().extra.bandsArray("object"),r=0;r<t.length;r++)if(t[r].id===e.id)return!0;return!1},k.prototype._isBandWithUnsupportedResolution=function(e){return!E("MainSeries"===e.type()?e.getInterval():this._resolution)},k.prototype._restoreMainSeriesAndResolution=function(){var e=this.alert.getSavedState();if(e&&e.extra){var t=e.extra.mainSeries();this.alert.get("extra").mainSeries(t),this.alert.set("resolution",e.resolution)}},k.prototype.getFireRateOptions=function(){var e=this.alert.get("crossInterval");return this.alert.frequencyController.getAvailable().map((function(t){var r=t.autoDeactivation,i=t.frequency,n=function(e,t,r){var i,n;if(t)i=a("Only Once"),n=a("The alert will only trigger once and will not be repeated");else switch(r){case"on_first_fire":i=a(e?"Every Time":"Once Per Bar"),n=a(e?"The alert will trigger every time the condition is met, but not more than 1 time per minute":"The alert will trigger every time the condition is met, but not more than 1 time per bar");break;case"on_bar_close":i=a("Once Per Bar Close"),n=a("The alert will trigger every time the condition is met at bar close");break;case"60":i=a("Once Per Minute"),n=a("The alert will trigger every time the condition is met, but not more than 1 time per minute");break;default:P.logError("Unknown autoDeactivation and frequency combination: "+[t,r].join("; ")),n=r.toString(),i="Auto deactivation: "+t+"; frequency: "+r}return{title:n,caption:i}}(e,r,i);return{value:{autoDeactivation:r,frequency:i},caption:n.caption,title:n.title}}))},k.prototype.defaults=function(e){var t=this;e=e||{};var r={conditionId:["extra",function(){return t._options.conditionId?t._options.conditionId:s.ordered(t.alert&&t.alert.get("extra"))[0].id}],alertSeries:["extra",function(){
|
|
if(t._options.series){var e=p(t._options.series);return d("alertSeries")||u("alertSeries",e||null)}return t._options.drawing&&(e=p(t._options.drawing.ownerSource()))||c("mainSeries")}],mainSeries:["extra",function(){return d("mainSeries")||u("mainSeries",t._dataSourceBridge.getMainSeriesState())}],fireInfo:["extra",{frequency:"once"}],value:["extra",1],period:["extra",function(){return t.minMovingPeriod()}],band:["extra",function(){return d("band")||u("band",k._createValueDataSource(t._options.value||t._dataSourceBridge.getMainSeriesLastPrice()))}],upperBand:["extra",function(){return d("upperBand")||u("upperBand",k._createValueDataSource(t._options.value||t._dataSourceBridge.getMainSeriesLastPrice()))}],lowerBand:["extra",function(){return d("lowerBand")||u("lowerBand",k._createValueDataSource(t._options.value||t._dataSourceBridge.getMainSeriesLastPrice()))}],symbol:["alert",t._symbol],symbolInternal:["alert",t._symbolInternal],resolution:["alert",t._resolution],soundFile:["alert",TVSettings.getValue("alerts.creating.sound_file",g.alert)],soundDuration:["alert",TVSettings.getValue("alerts.creating.sound_duration",0)],autoDeactivation:["alert",!0],description:["alert",""],expired:["alert",function(){var e=new Date,t=new Date;return e.setMonth(t.getMonth()+1),e.getTime()/1e3}],script:["alert",""],maxExpired:["dialog",function(){return new Date(Date.now()+5184e6)}],noExpiration:["alert",TVSettings.getBool("alerts.creating.no_expiration",!1)&&A(w.ALERTS_NO_EXPIRATION)],webhookUrl:["alert",A(w.ALERTS_WEBHOOK)&&TVSettings.getValue("alerts.creating.webhook_url")||null],name:["alert",null]},i=x("any"),a={showPopup:TVSettings.getBool("alerts.creating.show_popup",!i),playSound:TVSettings.getBool("alerts.creating.play_sound",!i),sendEmail:TVSettings.getBool("alerts.creating.send_email",!1)&&window.user.has_active_email,sendSms:TVSettings.getBool("alerts.creating.send_sms",!1)&&!!window.user.sms_email,sendPush:TVSettings.getBool("alerts.creating.send_push",i)};for(var n in a){var o=a[n];a[n]=["alert",o]}Object.assign(r,a);var l=Object.keys(r);function d(e){return t._cache[e]}function u(e,r){return t._cache.defaults||(t._cache.defaults={}),r}function c(e){return r[e]?"function"==typeof r[e][1]?r[e][1]():r[e][1]:null}function p(e){var r=e.idForAlert(),i="function"==typeof e.actualSymbol&&e.actualSymbol();return t.prepareBandForExtra(r,void 0,i)}return e.name?c(e.name):e.type?function(e){for(var t,i={},a=0;a<l.length;a++)t=l[a],r[t][0]===e&&(i[t]=c(t));return i}(e.type):void 0},k.prototype.mainSeries=function(){return this._dataSourceHub?this._dataSourceHub.mainSeries():null},k.prototype.getDataSourceById=function(e){return this._dataSourceBridge.getDataSourceById(e)},k.prototype.getStateForAlertById=function(e){return this._dataSourceBridge.getStateById(e)},k.prototype.prepareBandForExtra=function(e,t,r){var a,n,o,s=null;if(!e)return null;if("Value"===e)return k._createValueDataSource(0);if(this.alert&&this.alert.get("extra")){a=this.alert.getSavedState(),o=this.alert.get("extra").bandsArray(),
|
|
a&&(o=o.concat(a.extra.bandsArray()||[])),n=this.alert.get("crossInterval");for(var l=0;l<o.length;l++){var u=o[l].id===e;if(!u&&n&&"MainSeries"===o[l].type&&(u=o[l].actualSymbol===r),u){s=i.extend(!0,{},o[l]);break}}}if(s||(s=this.getStateForAlertById(e)),s){if(p(s.type,!1)){var c=d.create(s).getPlots();if(c.length>0){var h=void 0!==t&&t<c.length;s.plotIndex=h?t:0,s.plotOffset=c[s.plotIndex].offset}}return s}P.logError("Can't find state for datasource id "+e)},k.prototype.minMovingPeriod=function(e){return e||(e=this.alert&&this.alert.get("extra")&&this.alert.get("extra").alertSeries&&this.alert.get("extra").alertSeries()),e&&"MainSeries"===e.type?1:2},k.prototype.maxMovingPeriod=function(){return 300},k.prototype.getType=function(){return this._type},k.prototype._createDialog=function(){var e={conditionEditor:new h(this),alertState:this._getAlertState(),title:this._generateDialogTitle(),maxExpire:this.defaults({name:"maxExpired"}),readonly:"show_alert"===this._type,alertCategory:D.Price,hasInfiniteExpiration:!0};switch(this.alert.set("isBeingEdited",!0),this._type){case"create_alert":e.submitCaption=a("Create",{context:"alert"}),e.enableDeleteButton=!1;break;case"edit_alert":e.submitCaption=a("Save"),e.enableDeleteButton=!0,e.deleteCaption=a("Delete")}var t=this;v.createAlertDialog(e).then((function(e){t.dialog=e,t.dialog.stateChange.subscribe(null,(function(e){t._updateByDialogState(e,t.dialog.getAlertState()),t.dialog.setAlertState(t._getAlertState())})),t.dialog.on("action:submit",(function(e){e.isLoading()||setTimeout(()=>{t._validate(e)?T(t.alert,t._dataSourceBridge).then((function(r){r.canSubmit?t._onSubmit(e):e.restoreButtons()})):e.restoreButtons()},300)})).on("action:delete",(function(e){if(!e.isLoading()){var r={success:function(){t.destroy(),t._options.onDeleteSuccess&&t._options.onDeleteSuccess()},error:function(){e.error(a("Alert deleting failed. Please, try again"))}};t._deleteAlertFunc?t._deleteAlertFunc(t.alert,r):(r.showConfirm=!0,r.cancel=function(){e.restoreButtons()},t._priceAlertsDispatcher.deleteAlert(t.alert,r))}})).on("afterOpen",(function(e){t._validate(e),t.dialogOpened.fire()})).on("beforeClose",(function(){t.alert.set("isBeingEdited",!1),t.destroy(!0)})),t.dialog.open()}))},k.prototype._validate=function(e){if(!this.alert)return!1;if(!this.alert.get("noExpiration")){var t=this.alert.get("expired");if(t<=Date.now())return e.error(a("Expiration date must be in the future"),"expirationDate"),!1;var r=this.defaults({name:"maxExpired"});if(r&&t>r)return e.error(a("Maximum expiration time is {days} days",{replace:{days:Math.round((r-Date.now())/864e5)}}),"expirationDate"),!1}var i=this.alert.get("webhookUrl");if("string"==typeof i){var n=F(i);if(n!==V.Ok)return e.error(M.get(n),"webhook-url"),!1}var o=this.alert.get("extra"),s=o&&o.conditionData();if(s&&s.isChannel){var l=o.upperBand(),d=o.lowerBand();if("Value"===l.type&&"Value"===d.type){var u=+l.value;if(!isFinite(u))return e.error(a("Please enter correct upper bound value"),"upper-band-additional"),!1;var c=+d.value
|
|
;if(!isFinite(c))return e.error(a("Please enter correct lower bound value"),"lower-band-additional"),!1;if(u<=c){var p=a("Upper bound value must be greater than lower bound value");return e.error(p,"upper-band-additional"),e.error(p,"lower-band-additional"),!1}}}if("moving"===s.type){if(o.value()<=0)return e.error(a("Moving value should be a positive number"),"moving-value"),!1;var h=o.period(),g=this.minMovingPeriod(),_=this.maxMovingPeriod();if(h<g||h>_)return e.error(a("Moving period must be in range from {min} to {max}",{replace:{min:g,max:_}}),"moving-period"),!1}return!0},k.prototype._onSubmit=function(e){const t=this,r=this.alert,i=this._getAlertPreviousDrawingDataSource(),n=this._getAlertDrawingDataSource(),o={success:e=>N(e,n,i,s,l),error:l,complete:function(){d()},actionSource:this._options.actionSource};function s(){d(),t._onOkSucceed=!0,t.destroy()}function l(r,i){r&&P.logError(String(r)),t._show(),!0!==i&&e&&e.error(a("Alert saving failed. Please, try again"))}function d(){e&&e.restoreButtons()}y("alerts",this._options.trackEvent),TVSettings.setValue("alerts.creating.send_email",!!r.get("sendEmail")),TVSettings.setValue("alerts.creating.send_sms",!!r.get("sendSms")),TVSettings.setValue("alerts.creating.send_push",!!r.get("sendPush")),TVSettings.setValue("alerts.creating.show_popup",!!r.get("showPopup")),TVSettings.setValue("alerts.creating.play_sound",!!r.get("playSound")),TVSettings.setValue("alerts.creating.sound_file",r.get("soundFile")),TVSettings.setValue("alerts.creating.sound_duration",r.get("soundDuration")),TVSettings.setValue("alerts.creating.webhook_url",r.get("webhookUrl")||""),TVSettings.setValue("alerts.creating.no_expiration",!!r.get("noExpiration")),t._hide(),t._saveAlertFunc?t._saveAlertFunc(r,o):"create_alert"===t._type?t._generationPromise=this._priceAlertsDispatcher.createAlert(r,o):(r.isDrawing()&&this._updateDrawing(),t._generationPromise=this._priceAlertsDispatcher.restartAlert(r,o))},k.prototype._updateDrawing=function(){var e=this.alert.get("extra"),t=e.drawing(),r=t&&this.getDataSourceById(t.id);if(r){var i=e.alertSeries(),a=r.model().mainSeries();"MainSeries"===i.type&&i.id===a.idForAlert()&&e.drawing(r)}},k.prototype.getSeriesSelectOptions=function(e){var t=e.prepend?Array.isArray(e.prepend)?e.prepend:[e.prepend]:[];e=e||{};var r=this.alert;function a(e,t){var i=e.id();if(t&&Array.isArray(t)&&i){if(-1!==t.map((function(e){return e.id})).indexOf(i))return!0;if(r.get("crossInterval")&&"MainSeries"===e.type()){var a=g(e),n=t.map((function(e){return e.band&&"MainSeries"===e.band.type()&&g(e.band)}));return a&&-1!==n.indexOf(a)}return!1}return!1}function n(e){return a(e,i.map(t,(function(e){return{id:e.value,band:e.band}})))}function o(t){return t.id()!==e.selectedValue&&(t.getStyleInputs&&t.getStyleInputs()&&"ATR"===t.getStyleInputs().style)}function s(t){if(t.id()===e.selectedValue)return!1;return(t.getActualSymbol()||"").startsWith("ECONOMICS:")}function l(t){return a(t,e.excluded)||e.excludeTypes&&e.excludeTypes.includes(v.type())}var p=!1;function h(r){
|
|
void 0!==e.selectedValue&&r.value===e.selectedValue&&(r.selected=!0,p=!0),t.push(r)}function g(e){var t={actualSymbol:e.getActualSymbol(),sessionId:e.sessionId(),style:e.getStyle(),styleInputs:e.getStyleInputs()||{},dividendsAdjustment:e.getDividendsAdjustment(),backAdjustment:e.getBackAdjustment(),settlementAsClose:e.getSettlementAsClose()};return JSON.stringify(t,(function(e,t){return null!==t?t:void 0}))}function _(e){return e instanceof c&&e.isTVLibrary()}var m=this._dataSourceBridge.getMainSeriesState();if(r&&r.getSavedState())for(var f=r.getSavedState().extra.bandsArray("model"),y=0;y<f.length;y++){(v=f[y])instanceof u||n(v)||l(v)||s(v)||o(v)||e.excludeAlertConditionsOnly&&!v.hasUsualPlots()||_(v)||h({value:v.id(),band:v,caption:v.title({short:!0===e.shortTitle,withInterval:"MainSeries"===v.type()&&m&&m.id!==v.id()&&!r.get("crossInterval"),sessionDescription:"MainSeries"===v.type()&&v.sessionDescription()})})}if(!(m&&m.styleInputs&&"ATR"===m.styleInputs.style)){var S=this._dataSourceBridge.getStatesForAlert();for(y=0;y<S.length;y++){var v;n(v=d.create(S[y]))||l(v)||this._options.mainSeriesOnly&&"MainSeries"!==v.type()||s(v)||o(v)||e.excludeAlertConditionsOnly&&!v.hasUsualPlots()||this._isBandWithUnsupportedResolution(v)||_(v)||h({value:v.id(),band:v,caption:v.title({short:!0===e.shortTitle,withInterval:"MainSeries"===v.type()&&"create_alert"!==this._type&&r&&!r.get("crossInterval"),sessionDescription:"MainSeries"===v.type()&&v.sessionDescription()})})}}if(!p&&void 0!==e.selectedValue)for(y=0;y<t.length;++y)t[y].value===e.selectedValue&&(t[y].selected=!0);return t},k.prototype._generateDialogTitle=function(){var e,t=this.alert.title();return"create_alert"===this._type?e=a("Create Alert on {title}",{replace:{title:t}}):"edit_alert"===this._type?e=a("Edit Alert on {title}",{replace:{title:t}}):"show_alert"===this._type&&(e=a("Alert on {title}",{replace:{title:t}})),e},k.prototype._getAlertState=function(){var e=this.alert;if(e){var t=e.get("extra")&&e.get("extra").state(),r=t&&t.condition&&t.condition.fireInfo.frequency;r||(r=this.defaults({type:"extra"}).fireInfo.frequency);var i=e.get("webhookUrl");return{expirationDate:e.get("expired"),frequency:r,autoDeactivation:e.get("autoDeactivation"),message:e.get("description"),noExpiration:!!e.get("noExpiration"),webhookUrl:"string"==typeof i?i:null,notifyWith:{email:!!e.get("sendEmail"),popup:!!e.get("showPopup"),sms:!!e.get("sendSms"),sound:!!e.get("playSound"),push:!!e.get("sendPush")},soundParams:{duration:e.get("soundDuration")||0,name:e.get("soundFile")},name:e.get("name")}}P.logError("Unable to get alert state because alert is missing")},k.prototype._updateByDialogState=function(e,t){var r=this._buildEditorPropsByDialogStateProps({dialogAlertState:t,dialogChangedProps:e,editorPropNames:this._dialogChangedPropsToEditorPropNames(e)});this.update(r)},k.prototype._buildEditorPropsByDialogStateProps=function(e){var t={},r=e.dialogAlertState,i=e.dialogChangedProps||{};return e.editorPropNames.forEach((function(e,a){if(null!==e){
|
|
var n=i[a].name,o=Array.isArray(n)?r[n[0]][n[1]]:r[n];t[e]=o}})),t},k.prototype._dialogChangedPropsToEditorPropNames=function(e){return e.map((function(e){if(Array.isArray(e.name))switch(e.name[0]){case"notifyWith":switch(e.name[1]){case"popup":return"showPopup";case"sound":return"playSound";case"email":return"sendEmail";case"sms":return"sendSms";case"push":return"sendPush"}break;case"soundParams":switch(e.name[1]){case"name":return"soundFile";case"duration":return"soundDuration"}}else switch(e.name){case"frequency":return"frequency";case"autoDeactivation":return"autoDeactivation";case"expirationDate":return"expired";case"message":return"description";case"noExpiration":return"noExpiration";case"webhookUrl":return"webhookUrl";case"name":return"name"}return null}))},k.prototype._abort=function(e){this._options.onAborted&&this._options.onAborted(e),e!==C.ManualAbort&&P.logWarn("Aborted: "+e),this.destroy()},k.prototype._getAlertDrawingDataSource=function(){const e=this.alert.get("extra"),t=e&&e.drawing();return t&&this.getDataSourceById(t.id)||null},k.prototype._getAlertPreviousDrawingDataSource=function(){const e=this.alert.getSavedState(),t=e&&e.extra.drawing();return t&&this.getDataSourceById(t.id)||null},e.exports.AlertEditor=k},38874:(e,t,r)=>{"use strict";var i=r(23127);var a,n=(a=null,function(){return a||(a=i.Deferred(),r.e(3646).then(r.t.bind(r,16087,23)).then(()=>{a.resolve()})),a.promise()});TradingView.loadTVScript=n,t.loadTVScript=n},72154:(e,t,r)=>{"use strict";r.d(t,{createAlertDataSourceBridge:()=>o});var i=r(86811),a=r(14291);class n{constructor(e=null){this._idToState=new Map,this._dataSourceHub=e;const t=e&&e.mainSeries();this._mainSeriesId=t&&t.idForAlert();const r=t?t.lastValueData(4,!0,!0).price:void 0;this._mainSeriesLastPrice=void 0!==r?r:0}init(){return this._getChartDataSourcesForOptions().then(e=>{e.forEach(e=>{const t=e.stateForAlert&&e.stateForAlert();t&&this._idToState.set(t.id,t)})})}getStateById(e){return this._idToState.get(e)||null}getDataSourceById(e){return this._getChartDataSources().find(t=>t.alertCreationAvailable()&&t.idForAlert()===e)||null}getStatesForAlert(){return Array.from(this._idToState.values())}getMainSeriesState(){return this._mainSeriesId&&this._idToState.get(this._mainSeriesId)||null}getMainSeriesLastPrice(){return this._mainSeriesLastPrice}isSetOnLogarithmicScale(e){var t,r;return Boolean(null===(r=null===(t=this.getDataSourceById(e))||void 0===t?void 0:t.priceScale())||void 0===r?void 0:r.isLog())}_getChartDataSources(){return this._dataSourceHub?this._dataSourceHub.orderedDataSources():[]}_getChartDataSourcesForOptions(){if(!this._dataSourceHub)return Promise.resolve([]);const e=this._dataSourceHub.orderedDataSources(!0),t=this._dataSourceHub.mainSeries(),r=e.filter(e=>!(0,a.isLineTool)(e)&&e.alertCreationAvailable());return(0,i.filterAccessibleDataSources)(r).then(e=>(e.splice(e.indexOf(t),1),e.unshift(t),e))}}function o(e){return new Promise(t=>{const r=new n(e);r.init().then(()=>t(r))})}},58352:(e,t,r)=>{"use strict";r.d(t,{AlertSubmitFailReason:()=>n,
|
|
canSubmitAlert:()=>s});var i=r(56840);async function a(e){const t="alerts.no_warning."+e;if(i.getBool(t,!1))return!0;const{canContinue:a,doNotShow:n}=await(await Promise.all([r.e(5514),r.e(9129),r.e(2888),r.e(4956),r.e(8463),r.e(7427),r.e(5998),r.e(7552),r.e(279),r.e(5618),r.e(1e3),r.e(4364),r.e(7136)]).then(r.bind(r,71270))).showAlertsTriggerWarningDialogImpl(e);return n&&i.setValue(t,!0),a}var n,o=r(88537);async function s(e,t){return await async function(e){const t=(0,o.ensureDefined)(e.get("extra"));for(const e of t.bandsArray()){const t=e.dangerReason;if(t)return a(t)}return!0}(e)?await async function(e,t){const r=(0,o.ensureDefined)(e.get("extra")).alertSeries();if(r&&t.isSetOnLogarithmicScale(r.id))return a("logarithmic-scale");return!0}(e,t)?{canSubmit:!0}:{canSubmit:!1,reason:n.LogarithmicScale}:{canSubmit:!1,reason:n.DangerousSource}}!function(e){e[e.DangerousSource=0]="DangerousSource",e[e.LogarithmicScale=1]="LogarithmicScale"}(n||(n={}))},94738:(e,t,r)=>{"use strict";var i;r.d(t,{AlertCategory:()=>i}),function(e){e.Price="price",e.Screener="screener"}(i||(i={}))},26978:(e,t,r)=>{"use strict";r.d(t,{WebhookValidationResult:()=>i,validateWebhookUrl:()=>u});var i,a=r(75072);!function(e){e[e.Ok=0]="Ok",e[e.EmptyUrl=1]="EmptyUrl",e[e.BadUrl=2]="BadUrl",e[e.BadScheme=3]="BadScheme",e[e.BadHTTPPort=4]="BadHTTPPort",e[e.BadHTTPSPort=5]="BadHTTPSPort",e[e.BadHost=6]="BadHost"}(i||(i={}));const n={http:"80",https:"443"},o=Object.keys(n).map(e=>e+":"),s=new Set(["localhost","[::1]"]),l=function(){const e="(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])";return["0\\.0\\.0\\.0",`10\\.${e}\\.${e}\\.${e}`,`172\\.(?:1[6-9]|2[0-9]|3[0-1])\\.${e}\\.${e}`,`192\\.168\\.${e}\\.${e}`,`127\\.${e}\\.${e}\\.${e}`].map(e=>new RegExp(`^${e}$`))}(),d=new RegExp("^([a-z]+):\\/\\/(\\[[:.0-9A-Fa-f]+\\]|[^\\s/:#?@]+?)(?::(\\d+))?(\\/[^\\s#]*)?$");function u(e){if(""===e)return i.EmptyUrl;if(!o.some(t=>e.startsWith(t)))return i.BadScheme;const t=d.exec(e);if(null===t)return i.BadUrl;const r=t[1],u=t[2].toLowerCase(),c=t[3];return c&&n[r]!==c?"http"===r?i.BadHTTPPort:i.BadHTTPSPort:s.has(u)||(0,a.isInternalHost)(u,"tradingview.com")||(0,a.isInternalHost)(u,window.location.hostname)||l.some(e=>e.test(u))?i.BadHost:i.Ok}},66712:(e,t,r)=>{"use strict";r.r(t),r.d(t,{createAlertDialog:()=>a});const i={title:(0,r(28353).t)("Create Alert"),width:450,destroyOnClose:!0,focusFirstControl:!1,closeOnOutsideClick:!1,closeOnClickAtOtherDialogs:!1,contentWrapTemplate:'<div class="tv-dialog__section tv-dialog__section--no-border"><div class="tv-text"><p></p></div></div>',actionsWrapTemplate:'<div class="tv-dialog__section tv-dialog__section--actions tv-dialog__section--no-border tv-alert-dialog tv-alert-dialog__actions">'};function a(e){return Promise.all([r.e(5514),r.e(9289),r.e(509),r.e(3118),r.e(1729),r.e(3713),r.e(6708),r.e(5708),r.e(9593),r.e(2006),r.e(2288),r.e(9255),r.e(1536),r.e(7678),r.e(7404),r.e(6055),r.e(2465)]).then(r.bind(r,91426)).then(t=>{const r=t.AlertDialog;return Promise.resolve(new r({...i,...e}))})}},75072:(e,t,r)=>{"use strict"
|
|
;function i(e){const t=new URL(e,document.baseURI);return o(t)&&n(t)&&a(t)}r.d(t,{isInternalUrl:()=>i,isInternalHost:()=>s});const a=e=>!e.username,n=e=>"http:"===e.protocol||"https:"===e.protocol,o=e=>e.hostname===location.hostname||!/^\d+\.\d+\.\d+\.\d+$/.test(e.hostname)&&s(e.hostname);function s(e,t=window.location.hostname){const r="."===t.slice(-1)?3:2,i=t.toLowerCase().split(".").slice(-r),a=e.toLowerCase().split(".").slice(-i.length);return i.join(".")===a.join(".")}},16256:(e,t,r)=>{"use strict";r.d(t,{DEFAULT_SOUNDS:()=>u,availableSounds:()=>c,play:()=>h,stop:()=>g,onStopped:()=>_,isPlaying:()=>m});var i=r(28353),a=r(84015),n=r(98125),o=r(52714),s=r.n(o),l=r(86782);const d=(0,n.getLogger)("Lib.Sound",{color:"#dea433"}),u={sound:"notification/notification",alert:"alert/fired"},c=[{title:(0,i.t)("Alarm Clock"),path:"alert/alarm_clock",soundForAlerts:!0,filePath:l}];const p={};function h(e=u.sound,t){if((0,a.isOnMobileAppPage)("any"))return Promise.resolve();d.logNormal(`Sound play attempt for "${e}" duration-${t}s;`);return y(e).play(t)}function g(e){if((0,a.isOnMobileAppPage)("any"))return;let t=[];e?t.push(y(e)):t=Object.values(p),t.forEach(e=>{e.stop()})}function _(e,t){(0,a.isOnMobileAppPage)("any")||y(e).playing.subscribe(e=>{e||t()},{once:!0})}function m(e){return!(0,a.isOnMobileAppPage)("any")&&y(e).playing.value()}function f(e){if((0,a.isOnMobileAppPage)("any"))return;if(!e)return;if(!/iPhone|iPad|iPod|Android|BlackBerry|BB10|Silk|Mobi/i.test(window.navigator.userAgent))return;if(Array.isArray(e)||(e=[e]),0===(e=e.filter(e=>{const t=y(e);return!(!t||!t.el.load||t._mobilePreloadActive)&&(t._mobilePreloadActive=!0,!0)})).length)return void d.logNormal("enableForMobile no sounds passed");const t=()=>{const i=[];Array.isArray(e)&&e.forEach(e=>{const t=y(e);t.el.load();const r=t.play().catch(e=>{if("AbortError"!==e.name)throw d.logError(`enableForMobile for "${t.el.src}" preload error: - ${e.message}`),e});t.el.pause(),i.push(r)}),Promise.all(i).then(()=>{d.logNormal("enableForMobile sounds initialized")}),r.forEach(e=>{document.removeEventListener(e,t,!0)})},r=["click","touchend","keydown"];r.forEach(e=>{document.addEventListener(e,t,!0)})}const y=e=>{if(e in p)return p[e];d.logNormal(`requested sound ${e} not cached, building a new audio element`);const t=c.find(t=>t.path===e);if(void 0===t)throw new Error(`Cannot find sound "${e}"`);const r=new Audio(t.filePath),i={el:r,playing:new(s())(!1),play:(t=0)=>i.playing.value()?(d.logNormal("sound already playing"),Promise.reject("already playing")):(i.playing.setValue(!0),new Promise((r,a)=>{let n=t>0;const o=()=>{(function(e){try{d.logNormal(`"${e.el.src}" triggering html5 play method, readyState - ${e.el.readyState}; muted - ${e.el.muted}; volume - ${e.el.volume}; currentTime - ${e.el.currentTime}`);let t=e.el.play();return t||(t=Promise.resolve()),t}catch(t){return d.logError(`play method for "${e.el.src}" catch error - ${t.message}`),Promise.reject(t)}})(i).catch(t=>{d.logNormal(`stop counting sound "${e}"; as playing due to an error: ${t.message}`),
|
|
i.stop(),a(t)})};i._onEnded=()=>{n?o():(i.stop(),r())},i.el.addEventListener("ended",i._onEnded),n&&setTimeout(()=>{d.logNormal(`"${e}" repeat timeout - ${t}s off`),n=!1},1e3*t),o()})),stop:()=>{i.el.pause(),i.playing.setValue(!1),i._onEnded&&i.el.removeEventListener("ended",i._onEnded)}};p[e]=i;return["canplaythrough","error"].forEach(t=>{r.addEventListener(t,()=>{d.logNormal(`for sound "${e}", event - ${t} is fired`)},!1)}),d.logNormal("canPlayType - "+r.canPlayType("audio/mp3")),p[e]};f(c.filter(e=>!!e.common).map(e=>e.path))},95695:(e,t,r)=>{"use strict";r.d(t,{default:()=>n});var i=r(51768);const a={filterNamesMap:{script_type:"Indicators and Strategies","script_type-indicators":"Indicators","script_type-strategies":"Strategies",stream:"All Markets","stream-stocks":"Stocks","stream-indices":"Indices","stream-commodities":"Commodities","stream-currencies":"Currencies","stream-bitcoin":"Bitcoin","interval-all":"All Intervals","interval-m":"Short Term","interval-h":"Medium Term","interval-dwm":"Long Term","sort-unmoderated":"Unmoderated","sort-trending":"Trending","sort-discussed":"Most Discussed","sort-viewed":"Most Viewed","sort-agreed":"Most Agreed","sort-suggested":"Suggested","sort-recent":"All Ideas","time-day":"Today","time-week":"This Week","time-month":"This Month","time-all":"All Time","by-everyone":"Everyone","by-following":"Following","by-me":"My Ideas"},goProFeaturesMap:{customIntervals:"Add Custom Interval",intradaySpread:"Inraday Spread",kagiRenko:"Japanese Intraday Chart",alerts:{prefix:"New Alerts Limit",widget:"Widget",chart:"Chart Header"},multipleCharts:"Multiple Charts Layout",savedChartsLimit:"Save Chart Limit",studyLimit:"Studies Limit",multipleWatchLists:{prefix:"Watchlists",new:"Create New List",rename:"Rename List",saveAs:"Save List As"},importWatchlist:"Watchlists Import Watchlist",exportWatchlist:"Watchlists Export Watchlist",BATSExchangePopup:"BATS Exchange Popup",DataQualityPopup:"Data Quality Popup",FreeDelayPopup:"Free Delay Popup",proRTProduct:"Volume Profile",studyOnStudy:"Unlimited Study on Study"},trackFeature:{savedChartsLimit:!0,BATSExchangePopup:!0,FreeDelayPopup:!0,DataQualityPopup:!0,intradaySpread:!0,studyOnStudy:!0},trackGoPro:function(e,t,r){r&&!t&&(t=r,r=null);var n=a.goProFeaturesMap[t];if(n){if(r){if("string"==typeof n)return;n="{0} {1}".format(n.prefix,n[r])}(0,i.trackEvent)(e,n)}}},n=a},87463:(e,t,r)=>{"use strict";r.r(t),r.d(t,{trackGoProFeature:()=>a});var i=r(95695);function a(e,t){i.default.trackGoPro("Gopro Features",e,t)}}}]); |