@cocalc/static
Version:
CoCalc's static frontend Webpack-based build system and framework
1 lines • 23.3 kB
JavaScript
"use strict";(self.webpackChunk_cocalc_static=self.webpackChunk_cocalc_static||[]).push([[7463],{57463:(t,e,s)=>{s.r(e),s.d(e,{TaskActions:()=>S});var n=s(85460),i=s(20812),r=s(95788),o=s(24620),a=s(22292);function l(t,e,s,i,r){var l=function(t,e){var s=_[e];return null!=s?s:(!c&&t.get("deleted")||!u&&t.get("done")?_[e]=!1:_[e]=!0,_[e])},c=!!s.get("show_deleted"),u=!!s.get("show_done"),_=(new Date,{}),d={};t.forEach((function(t,e){if(l(t,e)){var s,n=null!==(s=t.get("desc"))&&void 0!==s?s:"",i=!0,r=!1,a=void 0;try{for(var c,u=(0,o.parse_hashtags)(n)[Symbol.iterator]();!(i=(c=u.next()).done);i=!0){var _=c.value,h=n.slice(_[0]+1,_[1]).toLowerCase();d[h]=!0}}catch(t){r=!0,a=t}finally{try{i||null==u.return||u.return()}finally{if(r)throw a}}}}));var h,f=function(t,e){var s,n,i="";return null===(s=t.get("selected_hashtags"))||void 0===s||s.forEach((function(t,s){e[s]&&(1===t?i+=" #"+s+" ":-1===t&&(i+=" -#"+s+" "))})),i+" "+(null!==(n=t.get("search"))&&void 0!==n?n:"")}(s,d),v=(0,o.search_split)(f.toLowerCase()),g={done:0,deleted:0},y=!1,p=null!==(h=s.getIn(["sort","column"]))&&void 0!==h?h:"Changed";null==a.Hm[p]&&(a.Hm[p]=a.Hm[a.fb[0]]);var k,b=a.Hm[p],w=b.key,m=null!==(k=s.getIn(["sort","dir"]))&&void 0!==k?k:a.qM[0];b.reverse&&(m="asc"===m?"desc":"asc");var S="desc"===m?-1e15:1e15,x=(0,n.Set)(),j=[];t.forEach((function(t,s){t.get("done")&&(g.done+=1),t.get("deleted")&&(g.deleted+=1);var n=e.getIn([s,"editing_desc"]);if(n||l(t,s)){var i,a,c,u=null!==(i=t.get("desc"))&&void 0!==i?i:"";(0,o.search_match)(u,v)||n?(a=!0,s===r&&(y=!0),j.push([null!==(c=t.get(w))&&void 0!==c?c:S,s])):a=!1;var _=!0,d=!1,h=void 0;try{for(var f,p=(0,o.parse_hashtags)(u)[Symbol.iterator]();!(_=(f=p.next()).done);_=!0){var k=f.value,b=u.slice(k[0]+1,k[1]).toLowerCase();a&&(x=x.add(b))}}catch(t){d=!0,h=t}finally{try{_||null==p.return||p.return()}finally{if(d)throw h}}}})),"desc"===m?j.sort((function(t,e){return-(0,o.cmp)(t[0],e[0])})):j.sort((function(t,e){return(0,o.cmp)(t[0],e[0])}));var I=[],O=!0,A=!1,z=void 0;try{for(var E,J=j[Symbol.iterator]();!(O=(E=J.next()).done);O=!0){var C=E.value;I.push(C[1])}}catch(t){A=!0,z=t}finally{try{O||null==J.return||J.return()}finally{if(A)throw z}}var M=(0,n.fromJS)(I);(null==r||!y)&&M.size>0?r=M.get(0):y||0!==M.size||(r=void 0),i.get("done")!==g.done&&(i=i.set("done",g.done)),i.get("deleted")!==g.deleted&&(i=i.set("deleted",g.deleted));var P=[],D=!0,H=!1,T=void 0;try{for(var B,L=v[Symbol.iterator]();!(D=(B=L.next()).done);D=!0){var R=B.value;"#"!==R[0]&&"-"!==R[0]&&P.push("".concat(R))}}catch(t){H=!0,T=t}finally{try{D||null==L.return||L.return()}finally{if(H)throw T}}var q=(0,n.Set)(P),K=[],N=!0,U=!1,V=void 0;try{for(var X,$=v[Symbol.iterator]();!(N=(X=$.next()).done);N=!0){var G=X.value;"#"!==G[0]&&K.push("".concat(G))}}catch(t){U=!0,V=t}finally{try{N||null==$.return||$.return()}finally{if(U)throw V}}var F=(0,n.List)(K);return{visible:M,current_task_id:r,counts:i,hashtags:(0,n.fromJS)(x),search_desc:v.join(" "),search_terms:q,nonhash_search:F}}function c(t){return(0,a.pV)(t.store.getIn(["local_view_state","sort","column"]))}var u=s(74858),_=s(32295),d=s(97636),h=s(431);function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,n=new Array(e);s<e;s++)n[s]=t[s];return n}function v(t,e,s,n,i,r,o){try{var a=t[r](o),l=a.value}catch(t){return void s(t)}a.done?e(l):Promise.resolve(l).then(n,i)}function g(t){return function(){var e=this,s=arguments;return new Promise((function(n,i){var r=t.apply(e,s);function o(t){v(r,n,i,o,a,"next",t)}function a(t){v(r,n,i,o,a,"throw",t)}o(void 0)}))}}function y(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function p(t){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},p(t)}function k(t,e){return!e||"object"!==w(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function b(t,e){return b=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},b(t,e)}var w=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};var m=function(t,e){var s,n,i,r,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(r){return function(a){return function(r){if(s)throw new TypeError("Generator is already executing.");for(;o;)try{if(s=1,n&&(i=2&r[0]?n.return:r[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,r[1])).done)return i;switch(n=0,i&&(r=[2&r[0],i.value]),r[0]){case 0:case 1:i=r;break;case 4:return o.label++,{value:r[1],done:!1};case 5:o.label++,n=r[1],r=[0];continue;case 7:r=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==r[0]&&2!==r[0])){o=0;continue}if(3===r[0]&&(!i||r[1]>i[0]&&r[1]<i[3])){o.label=r[1];break}if(6===r[0]&&o.label<i[1]){o.label=i[1],i=r;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(r);break}i[2]&&o.ops.pop(),o.trys.pop();continue}r=e.call(t,o)}catch(t){r=[6,t],n=0}finally{s=i=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,a])}}},S=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&b(t,e)}(v,t);var e,s,_=(e=v,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,n=p(e);if(s){var i=p(this).constructor;t=Reflect.construct(n,arguments,i)}else t=n.apply(this,arguments);return k(this,t)});function v(){var t;return y(this,v),(t=_.apply(this,arguments)).is_closed=!1,t}var w=v.prototype;return w._init=function(t,e,s,r){var o=this;this._save_local_view_state=(0,i.debounce)(this.__save_local_view_state,1500),this._update_visible=(0,i.throttle)(this.__update_visible,500),this.project_id=t,this.path=e,this.syncdb=s,this.store=r,this.setState({local_task_state:(0,n.Map)(),local_view_state:this._load_local_view_state(),counts:(0,n.fromJS)({done:0,deleted:0})}),this._init_has_unsaved_changes(),this.syncdb.on("change",this._syncdb_change),this.syncdb.once("change",this._ensure_positions_are_unique),this.syncdb.once("ready",this._syncdb_metadata),this.syncdb.on("metadata-change",this._syncdb_metadata),this.syncdb.once("load-time-estimate",(function(t){return o.setState({load_time_estimate:t})}))},w.close=function(){this.is_closed||(this.is_closed=!0,this.__save_local_view_state(),this.syncdb.close(),null!=this.key_handler&&this.redux.getActions("page").erase_active_key_handler(this.key_handler),(0,o.close)(this),this.is_closed=!0)},w.enable_key_handler=function(){var t;this.is_closed||(null==this.key_handler&&(this.key_handler=(t=this,function(e){var s=!!t.store.get("read_only"),n=e.ctrlKey||e.metaKey||e.altKey||e.shiftKey;return 70===e.keyCode?(t.focus_find_box(),!1):40===e.which||74===e.which?(n?c(t)&&t.move_task_delta(1):t.set_current_task_delta(1),!1):38===e.which||75===e.which?(n?c(t)&&t.move_task_delta(-1):t.set_current_task_delta(-1),!1):s?void 0:83===e.keyCode?(t.save(),!1):78===e.keyCode?(t.new_task(),!1):n&&32===e.which?(t.toggleHideBody(),!1):n||13!==e.which&&73!==e.which?void 0:(t.edit_desc(),!1)})),this.redux.getActions("page").set_active_key_handler(this.key_handler,this.project_id,this.path))},w.disable_key_handler=function(){null!=this.key_handler&&(this.redux.getActions("page").erase_active_key_handler(this.key_handler),delete this.key_handler)},w.__save_local_view_state=function(){if(!this.is_closed){var t=this.store.get("local_view_state");null!=t&&null!==localStorage&&(0,h.nL)(this.name,JSON.stringify(t.toJS()))}},w._load_local_view_state=function(){var t,e,s=(0,h.sK)(this.name);if(null==s)return(0,n.fromJS)({});try{t=(0,n.fromJS)("string"==typeof s?JSON.parse(s):null!=s?s:{})}catch(e){t=(0,n.fromJS)({})}if(t.has("show_deleted")||(t=t.set("show_deleted",!1)),t.has("show_done")||(t=t.set("show_done",!1)),t.has("show_max")||(t=t.set("show_max",50)),t.has("font_size")||(t=t.set("font_size",null!==(e=this.redux.getStore("account").get("font_size"))&&void 0!==e?e:14)),!t.has("sort")){var i=(0,n.fromJS)({column:a.fb[0],dir:a.qM[0]});t=t.set("sort",i)}return t},w._init_has_unsaved_changes=function(){var t,e=this,s=function(){var t,s;e.is_closed||e.setState({has_unsaved_changes:null===(t=e.syncdb)||void 0===t?void 0:t.has_unsaved_changes(),has_uncommitted_changes:null===(s=e.syncdb)||void 0===s?void 0:s.has_uncommitted_changes()})},n=(t=g((function(){return m(this,(function(t){switch(t.label){case 0:return s(),[4,(0,r.delay)(3e3)];case 1:return t.sent(),s(),[2]}}))})),function(){return t.apply(this,arguments)});this.set_save_status=(0,i.debounce)(n,500),this.syncdb.on("metadata-change",this.set_save_status),this.syncdb.on("connected",this.set_save_status)},w._syncdb_metadata=function(){if(null!=this.syncdb&&null!=this.store){var t=this.syncdb.is_read_only();t!==this.store.get("read_only")&&this.setState({read_only:t})}},w._syncdb_change=function(t){var e,s=this;if(null!=this.syncdb&&null!=this.store){var i,r=null!==(i=this.store.get("tasks"))&&void 0!==i?i:(0,n.Map)();t.forEach((function(t){var e=t.get("task_id"),n=s.syncdb.get_one(t);r=null==n?r.delete(e):r.set(e,n)})),this.setState({tasks:r}),this._update_visible(),null===(e=this.set_save_status)||void 0===e||e.call(this)}},w.__update_visible=function(){var t;if(null!=this.store){var e=this.store.get("tasks");if(null!=e){var s=this.store.get("local_view_state"),n=this.store.get("local_task_state"),i=this.store.get("current_task_id"),r=this.store.get("counts"),a=l(e,n,s,r,i);0==a.visible.size&&0==(null===(t=s.get("search"))||void 0===t?void 0:t.trim().length)&&(this.clear_all_hashtags(),a=l(e,n,s,r,i)),a=(0,o.copy_with)(a,["visible","current_task_id","counts","hashtags","search_desc","search_terms"]),this.setState(a)}}},w._ensure_positions_are_unique=function(){var t=this.store.get("tasks");if(null!=t){var e={},s=!0;if(t.forEach((function(n,i){if(null!=t){var r=n.get("position");if(null==r&&(r=0,t=t.set(i,n.set("position",0))),e[r])return s=!1,!1;e[r]=!0}})),!s){var n=[];t.forEach((function(t,e){var s;n.push([null!==(s=t.get("position"))&&void 0!==s?s:0,e])})),n.sort((function(t,e){return(0,o.cmp)(t[0],e[0])}));var i=0,r=!0,a=!1,l=void 0;try{for(var c,u=n[Symbol.iterator]();!(r=(c=u.next()).done);r=!0){var _=c.value;this.set_task(_[1],{position:i}),i+=1}}catch(t){a=!0,l=t}finally{try{r||null==u.return||u.return()}finally{if(a)throw l}}}}},w.set_local_task_state=function(t,e){if(!this.is_closed&&(null==t&&(t=this.store.get("current_task_id")),null!=t)){var s=this.store.get("local_task_state");e.task_id=t;var i=s.get(e.task_id);if(null==i)i=(0,n.fromJS)(e);else for(var r in e){var o=e[r];i=i.set(r,(0,n.fromJS)(o))}this.setState({local_task_state:s.set(e.task_id,i)})}},w.set_local_view_state=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.is_closed){var s=this.store.get("local_view_state");for(var i in t){var r=t[i];if("show_deleted"!=i&&"show_done"!=i&&"show_max"!=i&&"font_size"!=i&&"sort"!=i&&"selected_hashtags"!=i&&"search"!=i&&"scrollState"!=i)throw Error('bug setting local_view_state -- invalid field "'.concat(i,'"'));s=s.set(i,(0,n.fromJS)(r))}this.setState({local_view_state:s}),e&&this._update_visible(),this._save_local_view_state()}},w.save=function(){var t=this;return g((function(){var e,s,n;return m(this,(function(i){switch(i.label){case 0:if(t.is_closed)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,t.syncdb.save_to_disk()];case 2:return i.sent(),[3,4];case 3:return n=i.sent(),t.is_closed?[2]:(console.warn("Tasks save to disk failed ",n),[3,4]);case 4:return null===(s=(e=t).set_save_status)||void 0===s||s.call(e),[2]}}))}))()},w.new_task=function(){var t,e=this.store.getIn(["tasks",null!==(t=this.store.get("current_task_id"))&&void 0!==t?t:"","position"]),s=this.store.get_positions(),n=void 0;if(null!=e&&s.length>0){for(var i=1,r=s.length,a=1<=r;a?i<r:i>r;a?i++:i--)if(e===s[i]){n=(s[i-1]+s[i])/2;break}null==n&&(n=s[0]-1)}else n=s.length>0?s[0]-1:0;var l=this.store.get("search_desc"),c=(0,o.search_split)(l).filter((function(t){return"-"!==t[0]})).join(" "),u=(0,o.uuid)();this.set_task(u,{desc:c,position:n}),this.set_current_task(u),this.edit_desc(u)},w.set_task=function(t,e){var s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(null!=e&&!this.is_closed&&(null==t&&(t=this.store.get("current_task_id")),null!=t)){var r=this.store.getIn(["tasks",t]);if(null==r||null!=e.desc&&e.desc!==r.get("desc")||null!=e.due_date&&e.due_date!==r.get("due_date")||null!=e.done&&e.done!==r.get("done")){var o,a=null!==(o=this.store.getIn(["tasks",t,"last_edited"]))&&void 0!==o?o:0,l=(new Date).valueOf();l-a>=3e4&&(e.last_edited=l)}if(e.task_id=t,this.syncdb.set(e),i&&this.commit(),s){var c,u,_=null!==(c=this.store.get("tasks"))&&void 0!==c?c:(0,n.fromJS)({});if(null==(r=null!==(u=_.get(t))&&void 0!==u?u:(0,n.fromJS)({task_id:t})))throw Error("bug");for(var d in e){var h=e[d];if("desc"!=d&&"done"!=d&&"deleted"!=d&&"task_id"!=d&&"position"!=d&&"due_date"!=d&&"last_edited"!=d)throw Error('bug setting task -- invalid field "'.concat(d,'"'));r=r.set(d,(0,n.fromJS)(h))}_=_.set(t,r),this.setState({tasks:_})}}},w.delete_task=function(t){this.set_task(t,{deleted:!0})},w.undelete_task=function(t){this.set_task(t,{deleted:!1})},w.delete_current_task=function(){var t=this.store.get("current_task_id");null!=t&&this.delete_task(t)},w.undelete_current_task=function(){var t=this.store.get("current_task_id");null!=t&&this.undelete_task(t)},w.move_task_to_top=function(){var t=this.store.get("current_task_id");null!=t&&this.set_task(t,{position:this.store.get_positions()[0]-1})},w.move_task_to_bottom=function(){var t=this.store.get("current_task_id");null!=t&&this.set_task(t,{position:this.store.get_positions().slice(-1)[0]+1})},w.move_task_delta=function(t){if(1===t||-1===t){var e=this.store.get("current_task_id");if(null!=e){var s=this.store.get("visible");if(null!=s){var n=s.indexOf(e);if(-1!==n){var i=n+t;if(!(i<0||i>=s.size)){var r=this.store.get("tasks");if(null!=r){var o=r.getIn([e,"position"]),a=r.getIn([s.get(i),"position"]);this.set_task(e,{position:a},!0),this.set_task(s.get(i),{position:o},!0),this.scroll_into_view()}}}}}}},w.time_travel=function(){this.redux.getProjectActions(this.project_id).open_file({path:(0,o.history_path)(this.path),foreground:!0})},w.help=function(){var t;null===(t=window.open("https://doc.cocalc.com/tasks.html","_blank"))||void 0===t||t.focus()},w.set_current_task=function(t){this.store.get("current_task_id")!=t&&(this.setState({current_task_id:t}),this.scroll_into_view())},w.set_current_task_delta=function(t){var e=this.store.get("current_task_id");if(null!=e){var s=this.store.get("visible");if(null!=s){var n=s.indexOf(e);if(-1!==n){(n+=t)<0?n=0:n>=s.size&&(n=s.size-1);var i=s.get(n);null!=i&&this.set_current_task(i)}}}},w.undo=function(){null!=this.syncdb&&(this.syncdb.undo(),this.commit())},w.redo=function(){null!=this.syncdb&&(this.syncdb.redo(),this.commit())},w.commit=function(){this.syncdb.commit()},w.set_task_not_done=function(t){null==t&&(t=this.store.get("current_task_id")),this.set_task(t,{done:!1})},w.set_task_done=function(t){null==t&&(t=this.store.get("current_task_id")),this.set_task(t,{done:!0})},w.toggle_task_done=function(t){null==t&&(t=this.store.get("current_task_id")),null!=t&&this.set_task(t,{done:!this.store.getIn(["tasks",t,"done"])},!0)},w.stop_editing_due_date=function(t){this.set_local_task_state(t,{editing_due_date:!1})},w.edit_due_date=function(t){this.set_local_task_state(t,{editing_due_date:!0})},w.stop_editing_desc=function(t){this.set_local_task_state(t,{editing_desc:!1})},w.edit_desc=function(t){var e,s,n=this.store.get("local_task_state"),i=!0,r=!1,o=void 0;try{for(var a,l=n[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){var c=(e=a.value,s=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var s=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=s){var n,i,r=[],o=!0,a=!1;try{for(s=s.call(t);!(o=(n=s.next()).done)&&(r.push(n.value),!e||r.length!==e);o=!0);}catch(t){a=!0,i=t}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}return r}}(e,s)||function(t,e){if(t){if("string"==typeof t)return f(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(s):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?f(t,e):void 0}}(e,s)||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.")}()),u=c[0];c[1].get("editing_desc")&&this.stop_editing_desc(u)}}catch(t){r=!0,o=t}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}this.set_local_task_state(t,{editing_desc:!0})},w.set_due_date=function(t,e){this.set_task(t,{due_date:e})},w.set_desc=function(t,e){var s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.set_task(t,{desc:e},!1,s)},w.set_color=function(t,e){var s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.set_task(t,{color:e},!1,s)},w.toggleHideBody=function(t){if(null==t&&(t=this.store.get("current_task_id")),null!=t){var e=!this.store.getIn(["tasks",t,"hideBody"]);this.set_task(t,{hideBody:e})}},w.show_deleted=function(){this.set_local_view_state({show_deleted:!0})},w.stop_showing_deleted=function(){this.set_local_view_state({show_deleted:!1})},w.show_done=function(){this.set_local_view_state({show_done:!0})},w.stop_showing_done=function(){this.set_local_view_state({show_done:!1})},w.set_font_size=function(t){this.set_local_view_state({font_size:t})},w.increase_font_size=function(){var t,e=null!==(t=this.store.getIn(["local_view_state","font_size"]))&&void 0!==t?t:14;this.set_font_size(e+1)},w.decrease_font_size=function(){var t,e=null!==(t=this.store.getIn(["local_view_state","font_size"]))&&void 0!==t?t:14;this.set_font_size(e-1)},w.empty_trash=function(){var t,e=this;null===(t=this.store.get("tasks"))||void 0===t||t.forEach((function(t,s){t.get("deleted")&&e.syncdb.delete({task_id:s})}))},w.set_hashtag_state=function(t,e){var s,i=null!==(s=this.store.getIn(["local_view_state","selected_hashtags"]))&&void 0!==s?s:(0,n.Map)();i=null==e?i.delete(t):i.set(t,e),this.set_local_view_state({selected_hashtags:i})},w.clear_all_hashtags=function(){this.set_local_view_state({selected_hashtags:(0,n.Map)()})},w.set_sort_column=function(t,e){var s,i=this.store.get("local_view_state"),r=null!==(s=i.get("sort"))&&void 0!==s?s:(0,n.fromJS)({});r=(r=r.set("column",t)).set("dir",e),i=i.set("sort",r),this.setState({local_view_state:i}),this._update_visible(),this.__save_local_view_state()},w.reorder_tasks=function(t,e){if(t!==e){var s=this.store.get("visible"),n=s.get(t),i=s.get(e);if(null!=i){var r=this.store.getIn(["tasks",i,"position"]);if(null!=r){var o;if(0===e)o=r-1;else if(e<t){var a,l=s.get(e-1);o=(r+(null!==(a=this.store.getIn(["tasks",null!=l?l:"","position"]))&&void 0!==a?a:r-1))/2}else if(e>t){var c,u=s.get(e+1);o=(r+(null!==(c=this.store.getIn(["tasks",null!=u?u:"","position"]))&&void 0!==c?c:r+1))/2}this.set_task(n,{position:o},!0),this.__update_visible()}}}},w.focus_find_box=function(){this.disable_key_handler(),this.setState({focus_find_box:!0})},w.blur_find_box=function(){this.enable_key_handler(),this.setState({focus_find_box:!1})},w.scroll_into_view=function(){var t=this;return g((function(){return m(this,(function(e){switch(e.label){case 0:return[4,(0,r.delay)(50)];case 1:return e.sent(),t.setState({scroll_into_view:!0}),[2]}}))}))()},w.scroll_into_view_done=function(){this.setState({scroll_into_view:!1})},w.set_show_max=function(t){this.set_local_view_state({show_max:t},!1)},w.toggle_desc_checkbox=function(t,e,s){var n=this.store.getIn(["tasks",t,"desc"]);null!=n&&(n=(0,u.X0)(n,e,s),this.set_desc(t,n))},w.hide=function(){this.disable_key_handler()},w.show=function(){var t=this;return g((function(){return m(this,(function(e){switch(e.label){case 0:return[4,(0,r.delay)(1)];case 1:return e.sent(),t.enable_key_handler(),[2]}}))}))()},w.export_to_markdown=function(){var t=this;return g((function(){var e,s,n,i,r;return m(this,(function(o){switch(o.label){case 0:return null==(e=t.store.get("visible"))||null==(s=t.store.get("tasks"))?[2]:(n=[],e.forEach((function(t){var e=s.get(t);if(null!=e){var i="";e.get("deleted")&&(i+="**Deleted**\n\n"),e.get("done")&&(i+="**Done**\n\n");var r,o=e.get("due_date");o&&(i+="Due: ".concat(new Date(o).toLocaleString(),"\n\n")),i+=null!==(r=e.get("desc"))&&void 0!==r?r:"",n.push(i)}})),i=n.join("\n\n---\n\n"),r=t.path+".md",[4,d.webapp_client.project_client.write_text_file({project_id:t.project_id,path:r,content:i})]);case 1:return o.sent(),t.redux.getProjectActions(t.project_id).open_file({path:r,foreground:!0}),[2]}}))}))()},v}(_.Actions)},74858:(t,e,s)=>{s.d(e,{Er:()=>o,X0:()=>r});var n=s(24620),i=s(22871);function r(t,e,s){var r,o;return s?(r="[x]",o="[ ]"):(r="[ ]",o="[x]"),(0,i.v)(t,(function(t){return(0,n.replace_all_function)(t,r,(function(t){return t===e?o:r}))}))}function o(t){for(var e=t.trim().split("\n"),s=0,n=e.length,i=0<=n;i?s<n:s>n;i?s++:s--)if(""===e[s].trim())return s===e.length-1?t:e.slice(0,s).join("\n");return t}},22292:(t,e,s)=>{s.d(e,{Hm:()=>r,fb:()=>n,pV:()=>o,qM:()=>i});var n=["Custom Order","Due","Changed"],i=["asc","desc"],r={"Custom Order":{key:"position",reverse:!1},Due:{key:"due_date",reverse:!1},Changed:{key:"last_edited",reverse:!0}};function o(t){return t==n[0]}},22871:(t,e,s)=>{function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,n=new Array(e);s<e;s++)n[s]=t[s];return n}e.v=void 0;var i=s(83841),r=s(24620);e.v=function(t,e){var s,o,a,l;(0,r.is_array)(e)||(e=[e]),t=(a=(0,i.remove_math)(t),l=2,o=function(t){if(Array.isArray(t))return t}(a)||function(t,e){var s=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=s){var n,i,r=[],o=!0,a=!1;try{for(s=s.call(t);!(o=(n=s.next()).done)&&(r.push(n.value),!e||r.length!==e);o=!0);}catch(t){a=!0,i=t}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}return r}}(a,l)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(s):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?n(t,e):void 0}}(a,l)||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.")}())[0],s=o[1];var c=!0,u=!1,_=void 0;try{for(var d,h=e[Symbol.iterator]();!(c=(d=h.next()).done);c=!0)t=(0,d.value)(t)}catch(t){u=!0,_=t}finally{try{c||null==h.return||h.return()}finally{if(u)throw _}}return(0,i.replace_math)(t,s)}}}]);