define("discourse/plugins/discourse-local-dates/discourse/components/discourse-local-dates-create-form",["exports","discourse-common/utils/decorators","@ember/component","@ember/object","I18n","discourse-common/config/environment","rsvp","discourse/lib/text","discourse-common/lib/debounce","@ember/utils","discourse/lib/load-script","@ember/object/computed","discourse/lib/computed","@ember/runloop"],(function(e,t,n,a,o,r,i,s,l,c,u,m,d,f){"use strict";var p,h,v,y,z,g,_,b,T,w,k,D,P,L;function O(e,t,n,a,o){var r={};return Object.keys(a).forEach((function(e){r[e]=a[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=n.slice().reverse().reduce((function(n,a){return a(e,t,n)||n}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var E=n.default.extend((p=(0,t.observes)("markup"),h=(0,t.default)("date","toDate","toTime"),v=(0,t.default)("computedConfig","isRange"),y=(0,t.default)("date","time","isRange","options.{format,timezone}"),z=(0,t.default)("toDate","toTime","isRange","options.{timezone,format}"),g=(0,t.default)("recurring","timezones","timezone","format"),_=(0,t.default)("fromConfig.{date}","toConfig.{date}","options.{recurring,timezones,timezone,format}"),b=(0,t.default)("currentUserTimezone"),T=(0,t.default)("formats"),w=(0,t.default)("advancedMode"),k=(0,t.default)("computedConfig.{from,to,options}","options","isValid","isRange"),D=(0,t.default)("fromConfig.dateTime"),P=(0,t.default)("toConfig.dateTime","toSelected"),L={timeFormat:"HH:mm:ss",dateFormat:"YYYY-MM-DD",dateTimeFormat:"YYYY-MM-DD HH:mm:ss",date:null,toDate:null,time:null,toTime:null,format:null,formats:null,recurring:null,advancedMode:!1,timezone:null,fromSelected:null,fromFilled:(0,m.notEmpty)("date"),toSelected:null,toFilled:(0,m.notEmpty)("toDate"),init:function(){this._super.apply(this,arguments),this._picker=null,this.setProperties({timezones:[],formats:(this.siteSettings.discourse_local_dates_default_formats||"").split("|").filter((function(e){return e})),timezone:moment.tz.guess(),date:moment().format(this.dateFormat)})},didInsertElement:function(){var e=this;this._super.apply(this,arguments),this._setupPicker().then((function(t){e._picker=t,e.send("focusFrom")}))},_renderPreview:function(){(0,l.default)(this,(function(){var e=this,t=this.markup;t&&(0,s.cookAsync)(t).then((function(t){e.set("currentPreview",t),(0,f.schedule)("afterRender",(function(){return e.$(".preview .discourse-local-date").applyLocalDates()}))}))}),r.INPUT_DELAY)},isRange:function(e,t,n){return e&&(t||n)},isValid:function(e,t){var n=e.from;if(!e.from.dateTime||!e.from.dateTime.isValid())return!1;if(t){var a=e.to;if(!a.dateTime||!a.dateTime.isValid()||a.dateTime.diff(n.dateTime)<0)return!1}return!0},fromConfig:function(e,t,n){var o,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=!t;o=i?moment.tz(e,r.timezone):moment.tz("".concat(e," ").concat(t),r.timezone),i||(t=o.format(this.timeFormat));var s=r.format;return i&&this.formats.includes(s)&&(s="LL"),a.default.create({date:o.format(this.dateFormat),time:t,dateTime:o,format:s,range:!!n&&"start"})},toConfig:function(e,t,n){var o,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=!t;t&&!e&&(e=moment().format(this.dateFormat)),o=i?moment.tz(e,r.timezone).endOf("day"):moment.tz("".concat(e," ").concat(t),r.timezone),i||(t=o.format(this.timeFormat));var s=r.format;return i&&this.formats.includes(s)&&(s="LL"),a.default.create({date:o.format(this.dateFormat),time:t,dateTime:o,format:s,range:!!n&&"end"})},options:function(e,t,n,o){return a.default.create({recurring:e,timezones:t,timezone:n,format:o})},computedConfig:function(e,t,n){return a.default.create({from:e,to:t,options:n})},currentUserTimezone:function(){return moment.tz.guess()},allTimezones:function(){return moment.tz.names()},timezoneIsDifferentFromUserTimezone:(0,d.propertyNotEqual)("currentUserTimezone","options.timezone"),formatedCurrentUserTimezone:function(e){return e.replace("_"," ").replace("Etc/","").split("/")},previewedFormats:function(e){return e.map((function(e){return{format:e,preview:moment().format(e)}}))},recurringOptions:function(){var e="discourse_local_dates.create.form.recurring";return[{name:o.default.t("".concat(e,".every_day")),id:"1.days"},{name:o.default.t("".concat(e,".every_week")),id:"1.weeks"},{name:o.default.t("".concat(e,".every_two_weeks")),id:"2.weeks"},{name:o.default.t("".concat(e,".every_month")),id:"1.months"},{name:o.default.t("".concat(e,".every_two_months")),id:"2.months"},{name:o.default.t("".concat(e,".every_three_months")),id:"3.months"},{name:o.default.t("".concat(e,".every_six_months")),id:"6.months"},{name:o.default.t("".concat(e,".every_year")),id:"1.years"}]},_generateDateMarkup:function(e,t,n){var a="[date=".concat(e.date);return e.time&&(a+=" time=".concat(e.time)),e.format&&e.format.length&&(a+=' format="'.concat(e.format,'"')),t.timezone&&(a+=' timezone="'.concat(t.timezone,'"')),t.timezones&&t.timezones.length&&(a+=' timezones="'.concat(t.timezones.join("|"),'"')),t.recurring&&!n&&(a+=' recurring="'.concat(t.recurring,'"')),a+="]"},toggleModeBtnLabel:function(e){return e?"discourse_local_dates.create.form.simple_mode":"discourse_local_dates.create.form.advanced_mode"},markup:function(e,t,n,a){var o;return n&&e.from&&(o=this._generateDateMarkup(e.from,t,a),e.to&&e.to.range&&(o+=" → ",o+=this._generateDateMarkup(e.to,t,a))),o},formattedFrom:function(e){return e.format("LLLL")},formattedTo:function(e,t){var n=t?" ":o.default.t("discourse_local_dates.create.form.until");return e.isValid()?e.format("LLLL"):n},actions:{setTime:function(e){this._setTimeIfValid(e.target.value,"time")},setToTime:function(e){this._setTimeIfValid(e.target.value,"toTime")},eraseToDateTime:function(){this.setProperties({toDate:null,toTime:null}),this._setPickerDate(null)},focusFrom:function(){this.setProperties({fromSelected:!0,toSelected:!1}),this._setPickerDate(this.get("fromConfig.date")),this._setPickerMinDate(null)},focusTo:function(){this.setProperties({toSelected:!0,fromSelected:!1}),this._setPickerDate(this.get("toConfig.date")),this._setPickerMinDate(this.get("fromConfig.date"))},advancedMode:function(){this.toggleProperty("advancedMode")},save:function(){var e=this.markup;e&&(this._closeModal(),this.toolbarEvent.addText(e))},cancel:function(){this._closeModal()}},_setTimeIfValid:function(e,t){(0,c.isEmpty)(e)?this.set(t,null):/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/.test(e)&&this.set(t,e)},_setupPicker:function(){var e=this;return new i.Promise((function(t){(0,u.default)("/javascripts/pikaday.js").then((function(){var n={field:e.$(".fake-input")[0],container:e.$("#picker-container-".concat(e.elementId))[0],bound:!1,format:"YYYY-MM-DD",reposition:!1,firstDay:1,setDefaultDate:!0,keyboardInput:!1,i18n:{previousMonth:o.default.t("dates.previous_month"),nextMonth:o.default.t("dates.next_month"),months:moment.months(),weekdays:moment.weekdays(),weekdaysShort:moment.weekdaysMin()},onSelect:function(t){var n=moment(t).format("YYYY-MM-DD");e.fromSelected&&e.set("date",n),e.toSelected&&e.set("toDate",n)}};t(new Pikaday(n))}))}))},_setPickerMinDate:function(e){var t=this;e&&!moment(e,this.dateFormat).isValid()&&(e=null),(0,f.schedule)("afterRender",(function(){t._picker.setMinDate(moment(e,t.dateFormat).toDate())}))},_setPickerDate:function(e){var t=this;e&&!moment(e,this.dateFormat).isValid()&&(e=null),(0,f.schedule)("afterRender",(function(){t._picker.setDate(moment.utc(e),!0)}))},_closeModal:function(){Discourse.__container__.lookup("controller:composer").send("closeModal")}},O(L,"_renderPreview",[p],Object.getOwnPropertyDescriptor(L,"_renderPreview"),L),O(L,"isRange",[h],Object.getOwnPropertyDescriptor(L,"isRange"),L),O(L,"isValid",[v],Object.getOwnPropertyDescriptor(L,"isValid"),L),O(L,"fromConfig",[y],Object.getOwnPropertyDescriptor(L,"fromConfig"),L),O(L,"toConfig",[z],Object.getOwnPropertyDescriptor(L,"toConfig"),L),O(L,"options",[g],Object.getOwnPropertyDescriptor(L,"options"),L),O(L,"computedConfig",[_],Object.getOwnPropertyDescriptor(L,"computedConfig"),L),O(L,"currentUserTimezone",[t.default],Object.getOwnPropertyDescriptor(L,"currentUserTimezone"),L),O(L,"allTimezones",[t.default],Object.getOwnPropertyDescriptor(L,"allTimezones"),L),O(L,"formatedCurrentUserTimezone",[b],Object.getOwnPropertyDescriptor(L,"formatedCurrentUserTimezone"),L),O(L,"previewedFormats",[T],Object.getOwnPropertyDescriptor(L,"previewedFormats"),L),O(L,"recurringOptions",[t.default],Object.getOwnPropertyDescriptor(L,"recurringOptions"),L),O(L,"toggleModeBtnLabel",[w],Object.getOwnPropertyDescriptor(L,"toggleModeBtnLabel"),L),O(L,"markup",[k],Object.getOwnPropertyDescriptor(L,"markup"),L),O(L,"formattedFrom",[D],Object.getOwnPropertyDescriptor(L,"formattedFrom"),L),O(L,"formattedTo",[P],Object.getOwnPropertyDescriptor(L,"formattedTo"),L),L));e.default=E})),define("discourse/plugins/discourse-local-dates/discourse/controllers/discourse-local-dates-create-modal",["exports","@ember/controller","discourse/mixins/modal-functionality","@ember/runloop"],(function(e,t,n,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=t.default.extend(n.default,{onShow:function(){(0,a.schedule)("afterRender",(function(){var e=document.getElementById("from-date-time");e&&e.focus()}))},onClose:function(){(0,a.schedule)("afterRender",(function(){var e=document.querySelector(".d-editor-button-bar .local-dates.btn");e&&e.focus()}))}});e.default=o})),Ember.TEMPLATES["javascripts/components/discourse-local-dates-create-form"]=Ember.HTMLBars.template({id:null,block:'{"symbols":["previewedFormat"],"statements":[[4,"d-modal-body",null,[["title","class","style"],["discourse_local_dates.title","discourse-local-dates-create-modal","overflow: auto"]],{"statements":[[0,"\\n "],[7,"div",true],[10,"class","form"],[8],[0,"\\n"],[4,"if",[[24,["isValid"]]],null,{"statements":[[4,"if",[[24,["timezoneIsDifferentFromUserTimezone"]]],null,{"statements":[[0," "],[7,"div",true],[10,"class","preview alert alert-info"],[8],[0,"\\n "],[7,"b",true],[8],[1,[22,"formatedCurrentUserTimezone"],false],[0," "],[9],[1,[22,"currentPreview"],false],[0,"\\n "],[9],[0,"\\n"]],"parameters":[]},null]],"parameters":[]},{"statements":[[0," "],[7,"div",true],[10,"class","validation-error alert alert-error"],[8],[0,"\\n "],[1,[28,"i18n",["discourse_local_dates.create.form.invalid_date"],null],false],[0,"\\n "],[9],[0,"\\n"]],"parameters":[]}],[0,"\\n "],[1,[22,"computeDate"],false],[0,"\\n\\n "],[7,"div",true],[10,"class","date-time-configuration"],[8],[0,"\\n "],[7,"div",true],[10,"class","inputs-panel"],[8],[0,"\\n "],[7,"div",true],[11,"class",[29,["date-time-control from ",[28,"if",[[24,["fromSelected"]],"is-selected"],null]," ",[28,"if",[[24,["fromFilled"]],"is-filled"],null]]]],[8],[0,"\\n "],[1,[28,"d-icon",["calendar-alt"],null],false],[0,"\\n "],[1,[28,"d-button",null,[["id","action","translatedLabel","class"],["from-date-time",[28,"action",[[23,0,[]],"focusFrom"],null],[24,["formattedFrom"]],"date-time"]]],false],[0,"\\n "],[9],[0,"\\n\\n "],[7,"div",true],[11,"class",[29,["date-time-control to ",[28,"if",[[24,["toSelected"]],"is-selected"],null]," ",[28,"if",[[24,["toFilled"]],"is-filled"],null]]]],[8],[0,"\\n "],[1,[28,"d-icon",["calendar-alt"],null],false],[0,"\\n "],[1,[28,"d-button",null,[["action","translatedLabel","class"],[[28,"action",[[23,0,[]],"focusTo"],null],[24,["formattedTo"]],"date-time"]]],false],[0,"\\n"],[4,"if",[[24,["toFilled"]]],null,{"statements":[[0," "],[1,[28,"d-button",null,[["icon","action","class"],["times",[28,"action",[[23,0,[]],"eraseToDateTime"],null],"delete-to-date"]]],false],[0,"\\n"]],"parameters":[]},null],[0," "],[9],[0,"\\n\\n"],[4,"unless",[[24,["site","mobileView"]]],null,{"statements":[[0," "],[1,[28,"timezone-input",null,[["options","value","onChange"],[[28,"hash",null,[["icon"],["globe"]]],[24,["timezone"]],[28,"action",[[23,0,[]],[28,"mut",[[24,["timezone"]]],null]],null]]]],false],[0,"\\n"]],"parameters":[]},null],[0," "],[9],[0,"\\n\\n "],[7,"div",true],[10,"class","picker-panel"],[8],[0,"\\n "],[1,[28,"input",null,[["class"],["fake-input"]]],false],[0,"\\n "],[7,"div",true],[10,"class","date-picker"],[11,"id",[29,["picker-container-",[22,"elementId"]]]],[8],[9],[0,"\\n\\n"],[4,"if",[[24,["fromSelected"]]],null,{"statements":[[0," "],[7,"div",true],[10,"class","time-pickers"],[8],[0,"\\n "],[1,[28,"d-icon",["far-clock"],null],false],[0,"\\n "],[1,[28,"input",null,[["maxlength","placeholder","input","type","value","class"],[5,"hh:mm",[28,"action",[[23,0,[]],"setTime"],null],"time",[24,["time"]],"time-picker"]]],false],[0,"\\n "],[9],[0,"\\n"]],"parameters":[]},null],[0,"\\n"],[4,"if",[[24,["toSelected"]]],null,{"statements":[[4,"if",[[24,["toDate"]]],null,{"statements":[[0," "],[7,"div",true],[10,"class","time-pickers"],[8],[0,"\\n "],[1,[28,"d-icon",["far-clock"],null],false],[0,"\\n "],[1,[28,"input",null,[["maxlength","placeholder","input","type","value","class"],[5,"hh:mm",[28,"action",[[23,0,[]],"setToTime"],null],"time",[24,["toTime"]],"time-picker"]]],false],[0,"\\n "],[9],[0,"\\n"]],"parameters":[]},null]],"parameters":[]},null],[0," "],[9],[0,"\\n\\n"],[4,"if",[[24,["site","mobileView"]]],null,{"statements":[[0," "],[1,[28,"timezone-input",null,[["value","options","onChange"],[[24,["timezone"]],[28,"hash",null,[["icon"],["globe"]]],[28,"action",[[23,0,[]],[28,"mut",[[24,["timezone"]]],null]],null]]]],false],[0,"\\n"]],"parameters":[]},null],[0," "],[9],[0,"\\n\\n"],[4,"if",[[24,["advancedMode"]]],null,{"statements":[[0," "],[7,"div",true],[10,"class","advanced-options"],[8],[0,"\\n"],[4,"unless",[[24,["isRange"]]],null,{"statements":[[0," "],[7,"div",true],[10,"class","control-group recurrence"],[8],[0,"\\n "],[7,"label",true],[10,"class","control-label"],[8],[0,"\\n "],[1,[28,"i18n",["discourse_local_dates.create.form.recurring_title"],null],false],[0,"\\n "],[9],[0,"\\n "],[7,"p",true],[8],[1,[28,"html-safe",[[28,"i18n",["discourse_local_dates.create.form.recurring_description"],null]],null],false],[9],[0,"\\n "],[7,"div",true],[10,"class","controls"],[8],[0,"\\n "],[1,[28,"combo-box",null,[["content","class","value","onChange","none"],[[24,["recurringOptions"]],"recurrence-input",[24,["recurring"]],[28,"action",[[23,0,[]],[28,"mut",[[24,["recurring"]]],null]],null],"discourse_local_dates.create.form.recurring_none"]]],false],[0,"\\n "],[9],[0,"\\n "],[9],[0,"\\n"]],"parameters":[]},null],[0,"\\n "],[7,"div",true],[10,"class","control-group format"],[8],[0,"\\n "],[7,"label",true],[8],[1,[28,"i18n",["discourse_local_dates.create.form.format_title"],null],false],[9],[0,"\\n "],[7,"p",true],[8],[0,"\\n "],[1,[28,"i18n",["discourse_local_dates.create.form.format_description"],null],false],[0,"\\n "],[7,"a",true],[10,"target","_blank"],[10,"href","https://momentjs.com/docs/#/parsing/string-format/"],[10,"rel","noopener noreferrer"],[8],[0,"\\n "],[1,[28,"d-icon",["question-circle"],null],false],[0,"\\n "],[9],[0,"\\n "],[9],[0,"\\n "],[7,"div",true],[10,"class","controls"],[8],[0,"\\n "],[1,[28,"text-field",null,[["value","class"],[[24,["format"]],"format-input"]]],false],[0,"\\n "],[9],[0,"\\n "],[9],[0,"\\n "],[7,"div",true],[10,"class","control-group"],[8],[0,"\\n "],[7,"ul",true],[10,"class","formats"],[8],[0,"\\n"],[4,"each",[[24,["previewedFormats"]]],null,{"statements":[[0," "],[7,"li",true],[10,"class","format"],[8],[0,"\\n "],[7,"a",false],[12,"class","moment-format"],[12,"href",""],[3,"action",[[23,0,[]],[28,"mut",[[24,["format"]]],null],[23,1,["format"]]]],[8],[0,"\\n "],[1,[23,1,["format"]],false],[0,"\\n "],[9],[0,"\\n "],[7,"span",true],[10,"class","previewed-format"],[8],[0,"\\n "],[1,[23,1,["preview"]],false],[0,"\\n "],[9],[0,"\\n "],[9],[0,"\\n"]],"parameters":[1]},null],[0," "],[9],[0,"\\n "],[9],[0,"\\n\\n "],[7,"div",true],[10,"class","control-group timezones"],[8],[0,"\\n "],[7,"label",true],[8],[1,[28,"i18n",["discourse_local_dates.create.form.timezones_title"],null],false],[9],[0,"\\n "],[7,"p",true],[8],[1,[28,"i18n",["discourse_local_dates.create.form.timezones_description"],null],false],[9],[0,"\\n "],[7,"div",true],[10,"class","controls"],[8],[0,"\\n "],[1,[28,"multi-select",null,[["valueProperty","nameProperty","class","allowAny","maximum","content","value"],[null,null,"timezones-input",false,5,[24,["allTimezones"]],[24,["timezones"]]]]],false],[0,"\\n "],[9],[0,"\\n "],[9],[0,"\\n "],[9],[0,"\\n"]],"parameters":[]},null],[0," "],[9],[0,"\\n"]],"parameters":[]},null],[0,"\\n"],[7,"div",true],[10,"class","modal-footer discourse-local-dates-create-modal-footer"],[8],[0,"\\n"],[4,"if",[[24,["isValid"]]],null,{"statements":[[0," "],[1,[28,"d-button",null,[["class","action","label"],["btn-primary",[28,"action",[[23,0,[]],"save"],null],"discourse_local_dates.create.form.insert"]]],false],[0,"\\n"]],"parameters":[]},null],[0,"\\n "],[7,"a",false],[12,"class","cancel-action"],[12,"href",""],[3,"action",[[23,0,[]],"cancel"]],[8],[0,"\\n "],[1,[28,"i18n",["cancel"],null],false],[0,"\\n "],[9],[0,"\\n\\n "],[1,[28,"d-button",null,[["class","action","icon","label"],["btn-default advanced-mode-btn",[28,"action",[[23,0,[]],"advancedMode"],null],"cog",[24,["toggleModeBtnLabel"]]]]],false],[0,"\\n"],[9],[0,"\\n"]],"hasEval":false}',meta:{moduleName:"javascripts/discourse/templates/components/discourse-local-dates-create-form"}}),Ember.TEMPLATES["javascripts/modal/discourse-local-dates-create-modal"]=Ember.HTMLBars.template({id:null,block:'{"symbols":[],"statements":[[1,[28,"discourse-local-dates-create-form",null,[["config","toolbarEvent"],[[24,["config"]],[24,["toolbarEvent"]]]]],false],[0,"\\n"]],"hasEval":false}',meta:{moduleName:"javascripts/discourse/templates/modal/discourse-local-dates-create-modal"}}),define("discourse/plugins/discourse-local-dates/initializers/discourse-local-dates",["exports","../lib/local-date-builder","discourse/lib/show-modal","discourse/lib/plugin-api"],(function(e,t,n,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;function o(e){e.decorateCooked((function(e){return $(".discourse-local-date",e).applyLocalDates()}),{id:"discourse-local-date"}),e.onToolbarCreate((function(e){e.addButton({title:"discourse_local_dates.title",id:"local-dates",group:"extras",icon:"calendar-alt",sendAction:function(t){return e.context.send("insertDiscourseLocalDate",t)}})})),e.modifyClass("component:d-editor",{actions:{insertDiscourseLocalDate:function(e){(0,n.default)("discourse-local-dates-create-modal").setProperties({toolbarEvent:e})}}})}var r={name:"discourse-local-dates",initialize:function(e){var n=e.lookup("site-settings:main");n.discourse_local_dates_enabled&&($.fn.applyLocalDates=function(){return this.each((function(){var e={},a=this.dataset;e.time=a.time,e.date=a.date,e.recurring=a.recurring,e.timezones=(a.timezones||n.discourse_local_dates_default_timezones||"Etc/UTC").split("|").filter(Boolean),e.timezone=a.timezone,e.calendar="on"===(a.calendar||"on"),e.displayedTimezone=a.displayedTimezone,e.format=a.format||(e.time?"LLL":"LL"),e.countdown=a.countdown;var o=new t.default(e,moment.tz.guess()).build(),r=o.previews.map((function(e){var t=document.createElement("div");t.classList.add("preview"),e.current&&t.classList.add("current");var n=document.createElement("span");n.classList.add("timezone"),n.innerText=e.timezone,t.appendChild(n);var a=document.createElement("span");return a.classList.add("date-time"),a.innerText=e.formated,t.appendChild(a),t})),i=document.createElement("div");i.classList.add("locale-dates-previews"),r.forEach((function(e){return i.appendChild(e)})),this.innerHTML='\n \n \n \n \n \n \n',this.setAttribute("aria-label",o.textPreview),this.dataset.htmlTooltip=i.outerHTML,this.classList.add("cooked-date"),o.pastEvent&&this.classList.add("past"),this.querySelector(".relative-time").innerText=o.formated}))},(0,a.withPluginApi)("0.8.8",o))}};e.default=r})),define("discourse/plugins/discourse-local-dates/lib/discourse-markdown/discourse-local-dates",["exports","pretty-text/engines/discourse-markdown/bbcode-block"],(function(e,t){"use strict";function n(e,n,o){var r,i={date:null,time:null,timezone:null,format:null,timezones:null,displayedTimezone:null,countdown:null},s=n[1].replace(/‘|’|„|“|«|»|”/g,'"'),l=(0,t.parseBBCodeTag)("[date date"+s+"]",0,s.length+11);if(i.date=l.attrs.date,i.format=l.attrs.format,i.calendar=l.attrs.calendar,i.time=l.attrs.time,i.timezone=(l.attrs.timezone||"").trim(),i.recurring=l.attrs.recurring,i.timezones=l.attrs.timezones,i.displayedTimezone=l.attrs.displayedTimezone,i.countdown=l.attrs.countdown,(r=new o.Token("span_open","span",1)).attrs=[["data-date",o.md.utils.escapeHtml(i.date)]],i.date.match(/\d{4}-\d{2}-\d{2}/))if(!i.time||i.time.match(/\d{2}:\d{2}(?::\d{2})?/)){var c=i.date;if(i.time&&(r.attrs.push(["data-time",o.md.utils.escapeHtml(i.time)]),c="".concat(c," ").concat(i.time)),moment(c).isValid()){if(r.attrs.push(["class","discourse-local-date"]),i.format&&r.attrs.push(["data-format",o.md.utils.escapeHtml(i.format)]),i.countdown&&r.attrs.push(["data-countdown",o.md.utils.escapeHtml(i.countdown)]),i.calendar&&r.attrs.push(["data-calendar",o.md.utils.escapeHtml(i.calendar)]),i.displayedTimezone&&moment.tz.names().includes(i.displayedTimezone)&&r.attrs.push(["data-displayed-timezone",o.md.utils.escapeHtml(i.displayedTimezone)]),i.timezones){var u=i.timezones.split("|").filter((function(e){return moment.tz.names().includes(e)}));r.attrs.push(["data-timezones",o.md.utils.escapeHtml(u.join("|"))])}i.timezone&&moment.tz.names().includes(i.timezone)?(r.attrs.push(["data-timezone",o.md.utils.escapeHtml(i.timezone)]),c=moment.tz(c,i.timezone)):c=moment.utc(c),i.recurring&&r.attrs.push(["data-recurring",o.md.utils.escapeHtml(i.recurring)]),e.push(r);var m=c.tz("Etc/UTC").format(o.md.options.discourse.datesEmailFormat||moment.defaultFormat);r.attrs.push(["data-email-preview","".concat(m," UTC")]),a(e,o,c.utc().format(i.format))}else a(e,o,moment.invalid().format())}else a(e,o,moment.invalid().format());else a(e,o,moment.invalid().format())}function a(e,t,n){var a;(a=new t.Token("text","",0)).content=n,e.push(a),a=new t.Token("span_close","span",-1),e.push(a)}Object.defineProperty(e,"__esModule",{value:!0}),e.setup=function(e){e.allowList(["span.discourse-local-date","span[data-*]","span[aria-label]"]),e.registerOptions((function(e,t){e.datesEmailFormat=t.discourse_local_dates_email_format,e.features["discourse-local-dates"]=!!t.discourse_local_dates_enabled})),e.registerPlugin((function(e){var t={matcher:/\[date(=.+?)\]/,onMatch:n};e.core.textPostProcess.ruler.push("discourse-local-dates",t)}))}})),define("discourse/plugins/discourse-local-dates/lib/date-with-zone-helper",["exports"],(function(e){"use strict";function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],a=!0,o=!1,r=void 0;try{for(var i,s=e[Symbol.iterator]();!(a=(i=s.next()).done)&&(n.push(i.value),!t||n.length!==t);a=!0);}catch(e){o=!0,r=e}finally{try{a||null==s.return||s.return()}finally{if(o)throw r}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);"Object"===a&&e.constructor&&(a=e.constructor.name);if("Map"===a||"Set"===a)return Array.from(e);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return n(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:{};a(this,e),this.timezone=t.timezone||"UTC",this.localTimezone=t.localTimezone||moment.tz.guess(),this.datetime=moment.tz(r(t,["year","month","day","hour","minute","second"]),this.timezone)}var n,i,s;return n=e,s=[{key:"fromDatetime",value:function(t,n,a){return new e({year:t.year(),month:t.month(),day:t.date(),hour:t.hour(),minute:t.minute(),second:t.second(),timezone:n,localTimezone:a})}}],(i=[{key:"isDST",value:function(){return this.datetime.tz(this.localTimezone).isDST()}},{key:"unitRepetitionsBetweenDates",value:function(e,n){var a=t(e.split("."),2),o=a[0],r=a[1],i=Math.abs(this.datetime.diff(n,r,!0)),s=i/o%1;return Math.trunc(i/o)*parseInt(o,10)+(s>0?parseInt(o,10):0)}},{key:"add",value:function(e,t){return this._fromDatetime(this.datetime.clone().add(e,t),this.timezone,this.localTimezone)}},{key:"subtract",value:function(e,t){return this._fromDatetime(this.datetime.clone().subtract(e,t),this.timezone,this.localTimezone)}},{key:"datetimeWithZone",value:function(e){return this.datetime.clone().tz(e)}},{key:"format",value:function(e){return e?this.datetime.tz(this.localTimezone).format(e):this.datetime.tz(this.localTimezone).toISOString(!0)}},{key:"_fromDatetime",value:function(t,n,a){return e.fromDatetime(t,n,a)}}])&&o(n.prototype,i),s&&o(n,s),e}();e.default=i})),define("discourse/plugins/discourse-local-dates/lib/local-date-builder",["exports","./date-with-zone-helper","I18n"],(function(e,t,n){"use strict";function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],a=!0,o=!1,r=void 0;try{for(var i,s=e[Symbol.iterator]();!(a=(i=s.next()).done)&&(n.push(i.value),!t||n.length!==t);a=!0);}catch(e){o=!0,r=e}finally{try{a||null==s.return||s.return()}finally{if(o)throw r}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;r(this,e),this.time=t.time,this.date=t.date,this.recurring=t.recurring,this.timezones=Array.from(new Set((t.timezones||[]).filter(Boolean))),this.timezone=t.timezone||"UTC",this.calendar=void 0===t.calendar||t.calendar,this.displayedTimezone=t.displayedTimezone,this.format=t.format||(this.time?s:"LL"),this.countdown=t.countdown,this.localTimezone=n}var o,c,u;return o=e,(c=[{key:"build",value:function(){var e,n=a(this.date.split("-").map((function(e){return parseInt(e,10)})),3),o=n[0],r=n[1],i=n[2],s=a((this.time||"").split(":").map((function(e){return e?parseInt(e,10):void 0})),3),l=s[0],c=s[1],u=s[2];e=this.time?this.displayedTimezone||this.localTimezone:this.displayedTimezone||this.timezone||this.localTimezone;var m=new t.default({year:o,month:r?r-1:null,day:i,hour:l,minute:c,second:u,timezone:this.timezone,localTimezone:this.localTimezone});if(this.recurring&&moment().isAfter(m.datetime)){var d=this.recurring.split(".")[1],f=m.unitRepetitionsBetweenDates(this.recurring,moment.tz(this.localTimezone));m=m.add(f,d)}var p=this._generatePreviews(m,e);return{pastEvent:!this.recurring&&moment.tz(this.localTimezone).isAfter(m.datetime),formated:this._applyFormatting(m,e),previews:p,textPreview:this._generateTextPreviews(p)}}},{key:"_generateTextPreviews",value:function(e){var t=this;return e.map((function(e){var n=t._zoneWithoutPrefix(e.timezone);return"".concat(n," ").concat(e.formated)})).join(", ")}},{key:"_generatePreviews",value:function(e,n){var a=this,o=[],r=this.timezones.filter((function(e){return!a._isEqualZones(e,a.localTimezone)}));return o.push({timezone:this._zoneWithoutPrefix(this.localTimezone),current:!0,formated:this._createDateTimeRange(t.default.fromDatetime(e.datetime,e.timezone,this.localTimezone),this.time)}),!this.timezone||n!==this.localTimezone||this.timezone===n||this._isEqualZones(n,this.timezone)||this.timezones.any((function(e){return a._isEqualZones(e,a.timezone)}))||r.unshift(this.timezone),r.forEach((function(r){a._isEqualZones(r,n)||(a._isEqualZones(r,a.localTimezone)&&(r=a.localTimezone),o.push({timezone:a._zoneWithoutPrefix(r),formated:a._createDateTimeRange(t.default.fromDatetime(e.datetime,e.timezone,r),a.time)}))})),o.uniqBy("timezone")}},{key:"_isEqualZones",value:function(e,t){return!(!(!e&&!t||e&&t)||!e.includes(t)&&!t.includes(e)&&moment.tz(e).utcOffset()!==moment.tz(t).utcOffset())}},{key:"_createDateTimeRange",value:function(e,t){if(t)return e.format(s);var n=e.add(24,"hours");return[e.format("LLLL"),l,n.format("LLLL")].join(" ")}},{key:"_applyFormatting",value:function(e,t){if(this.countdown){var a=moment.tz(this.localTimezone).diff(e.datetime);return a<0?moment.duration(a).humanize():n.default.t("discourse_local_dates.relative_dates.countdown.passed")}var o=this._isEqualZones(t,this.localTimezone);if(this.calendar&&moment.tz(this.localTimezone).isBetween(e.subtract(2,"day").datetime,e.add(1,"day").datetime.endOf("day"))&&o){var r=e.datetimeWithZone(this.localTimezone);return 0===r.hours()&&0===r.minutes()?r.format("dddd"):r.calendar(moment.tz(e.timezone),this._calendarFormats(this.time?this.time:null))}return o?e.format(this.format):this._formatWithZone(e,t,this.format)}},{key:"_calendarFormats",value:function(e){return{sameDay:this._translateCalendarKey(e,"today"),nextDay:this._translateCalendarKey(e,"tomorrow"),lastDay:this._translateCalendarKey(e,"yesterday"),sameElse:"L"}}},{key:"_translateCalendarKey",value:function(e,t){var a=n.default.t("discourse_local_dates.relative_dates.".concat(t),{time:"LT"});return e?a.split("LT").map((function(e){return"[".concat(e,"]")})).join("LT"):"[".concat(a.replace(" LT",""),"]")}},{key:"_formatTimezone",value:function(e){return e.replace("_"," ").replace("Etc/","").split("/")}},{key:"_zoneWithoutPrefix",value:function(e){var t=a(this._formatTimezone(e),2),n=t[0];return t[1]||n}},{key:"_formatWithZone",value:function(e,t,n){var a=e.datetimeWithZone(t).format(n);return"".concat(a," (").concat(this._zoneWithoutPrefix(t),")")}}])&&i(o.prototype,c),u&&i(o,u),e}();e.default=c})); //# sourceMappingURL=/assets/plugins/discourse-local-dates-5edf452312b471fbb9ea9a9ad686e24becaf6d38d13456ac170b45902409d1cf.js.map