g.right&&w.left+i>y.width?(p=i-y.width,l.push(Hc.X.LEFT),c.push(Hc.X.RIGHT)):(p=i,l.push(Hc.X.RIGHT),c.push(Hc.X.LEFT)),_>g.bottom&&w.top+o>y.height?(f=o-y.height,l.push(Hc.Y.TOP),c.push(Hc.Y.BOTTOM)):(f=o,l.push(Hc.Y.BOTTOM),c.push(Hc.Y.TOP)),this.props.renderToBody&&(f+=w.top,p+=w.left),this.ref.style.top="".concat(f,"px"),this.ref.style.left="".concat(p,"px"),(r=this.ref.classList).remove.apply(r,c),(a=this.ref.classList).add.apply(a,l)}},{key:"render",value:function(){var r=this,a=this.props,o=a.style,i=a.className,l=a.innerRef,c=a.children,f=a.renderToBody,p=document.body,g=ne.createElement("div",{ref:function(w){r.ref=w,l(w)},className:"rta__autocomplete ".concat(i||""),style:o},c);return f&&p!==null?z2.createPortal(g,p):g}}]),t}(ne.Component),p6=function(e){bb(t,e);function t(n){var r;Ov(this,t),r=wb(this,vp(t).call(this,n)),r.state={top:null,left:null,currentTrigger:null,actualToken:"",data:null,value:"",dataLoading:!1,selectionEnd:0,component:null,textToReplace:null},r.escListenerInit=function(){r.escListener||(r.escListener=lf.add(Ci.ESC,r._closeAutocomplete))},r.escListenerDestroy=function(){r.escListener&&(lf.remove(r.escListener),r.escListener=null)},r.getSelectionPosition=function(){return r.textareaRef?{selectionStart:r.textareaRef.selectionStart,selectionEnd:r.textareaRef.selectionEnd}:null},r.getSelectedText=function(){if(!r.textareaRef)return null;var c=r.textareaRef,f=c.selectionStart,p=c.selectionEnd;return f===p?null:r.state.value.substr(f,p-f)},r.setCaretPosition=function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;r.textareaRef&&(r.textareaRef.focus(),r.textareaRef.setSelectionRange(c,c))},r.getCaretPosition=function(){if(!r.textareaRef)return 0;var c=r.textareaRef.selectionEnd;return c},r._handleCaretChange=function(c){var f=function(){var y=r.getCaretPosition()-1;r.lastTrigger=r.lastTrigger?y:0};if(c.type==="keydown"){var p=c.keyCode||c.which;switch(p){case Ci.UP:case Ci.DOWN:r._isAutocompleteOpen()||f();break;case Ci.LEFT:case Ci.RIGHT:f();break}return}f()},r._onSelect=function(c){var f=r.state,p=f.selectionEnd,g=f.currentTrigger,y=f.value,w=r.props.onItemSelected;if(g){var T=r._getTextToReplace(g);if(!T){r._closeAutocomplete();return}var S=T(c);if(!S){r._closeAutocomplete();return}w&&w({currentTrigger:g,item:c});var I=function($,X,Q){switch($){case"start":return Q;case"next":case"end":return Q+X.length;default:if(!Number.isInteger($))throw new Error('RTA: caretPosition should be "start", "next", "end" or number.');return $}},M=y.slice(0,p),N=b0(g),_=M.length-M.lastIndexOf(g),k=M.search(new RegExp("(?!".concat(N,")$")))-_,R=S.caretPosition==="next"?"".concat(S.text," "):S.text,L=I(S.caretPosition,R,k),H=M.substring(0,k)+R,U=y.replace(M,H);r.setState({value:U,dataLoading:!1},function(){var z=r.tokenRegExpEnding.exec(R),$=z?z[0].length:1;r.lastTrigger=L&&L-$,r.textareaRef.value=U,r.textareaRef.selectionEnd=L,r._changeHandler();var X=r.textareaRef.scrollTop;r.setCaretPosition(L),window.chrome&&(r.textareaRef.scrollTop=X)})}},r._getTextToReplace=function(c){var f=r.props.trigger[c];if(!c||!f)return null;var p=f.output;return function(g){if(typeof g=="object"&&(!p||typeof p!="function"))throw new Error('Output functor is not defined! If you are using items as object you have to define "output" function. https://github.com/webscopeio/react-textarea-autocomplete#trigger-type');if(p){var y=p(g,c);if(y===void 0||typeof y=="number")throw new Error(`Output functor should return string or object in shape {text: string, caretPosition: string | number}.
+Check the documentation or create issue if you think it's bug. https://github.com/webscopeio/react-textarea-autocomplete/issues`))},MY=[".","^","$","*","+","-","?","(",")","[","]","{","}","\\","|"],I0=function(t){return TY(t).map(function(n){return MY.includes(n)?"\\".concat(n):n}).join("")},kY=function(e){Tb(t,e);function t(){return Lv(this,t),Db(this,yp(t).apply(this,arguments))}return Sb(t,[{key:"componentDidMount",value:function(){var r=this.props.boundariesElement;if(typeof r=="string"){var a=document.querySelector(r);if(!a)throw new Error("RTA: Invalid prop boundariesElement: it has to be string or HTMLElement.");this.containerElem=a}else if(r instanceof HTMLElement)this.containerElem=r;else throw new Error("RTA: Invalid prop boundariesElement: it has to be string or HTMLElement.");if(!this.containerElem||!this.containerElem.contains(this.ref))throw new Error("RTA: Invalid prop boundariesElement: it has to be one of the parents of the RTA.")}},{key:"componentDidUpdate",value:function(){var r,a,o=this.props.top||0,i=this.props.left||0,l=[],c=[],f=0,h=0,g=this.containerElem.getBoundingClientRect(),y=this.ref.getBoundingClientRect(),w=this.props.textareaRef.getBoundingClientRect(),S=window.getComputedStyle(this.ref),D=parseInt(S.getPropertyValue("margin-top"),10),I=parseInt(S.getPropertyValue("margin-bottom"),10),M=parseInt(S.getPropertyValue("margin-left"),10),N=parseInt(S.getPropertyValue("margin-right"),10),R=D+I+w.top+o+y.height,k=M+N+w.left+i+y.width;k>g.right&&w.left+i>y.width?(h=i-y.width,l.push(Yc.X.LEFT),c.push(Yc.X.RIGHT)):(h=i,l.push(Yc.X.RIGHT),c.push(Yc.X.LEFT)),R>g.bottom&&w.top+o>y.height?(f=o-y.height,l.push(Yc.Y.TOP),c.push(Yc.Y.BOTTOM)):(f=o,l.push(Yc.Y.BOTTOM),c.push(Yc.Y.TOP)),this.props.renderToBody&&(f+=w.top,h+=w.left),this.ref.style.top="".concat(f,"px"),this.ref.style.left="".concat(h,"px"),(r=this.ref.classList).remove.apply(r,c),(a=this.ref.classList).add.apply(a,l)}},{key:"render",value:function(){var r=this,a=this.props,o=a.style,i=a.className,l=a.innerRef,c=a.children,f=a.renderToBody,h=document.body,g=ne.createElement("div",{ref:function(w){r.ref=w,l(w)},className:"rta__autocomplete ".concat(i||""),style:o},c);return f&&h!==null?q2.createPortal(g,h):g}}]),t}(ne.Component),T6=function(e){Tb(t,e);function t(n){var r;Lv(this,t),r=Db(this,yp(t).call(this,n)),r.state={top:null,left:null,currentTrigger:null,actualToken:"",data:null,value:"",dataLoading:!1,selectionEnd:0,component:null,textToReplace:null},r.escListenerInit=function(){r.escListener||(r.escListener=uf.add(xi.ESC,r._closeAutocomplete))},r.escListenerDestroy=function(){r.escListener&&(uf.remove(r.escListener),r.escListener=null)},r.getSelectionPosition=function(){return r.textareaRef?{selectionStart:r.textareaRef.selectionStart,selectionEnd:r.textareaRef.selectionEnd}:null},r.getSelectedText=function(){if(!r.textareaRef)return null;var c=r.textareaRef,f=c.selectionStart,h=c.selectionEnd;return f===h?null:r.state.value.substr(f,h-f)},r.setCaretPosition=function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;r.textareaRef&&(r.textareaRef.focus(),r.textareaRef.setSelectionRange(c,c))},r.getCaretPosition=function(){if(!r.textareaRef)return 0;var c=r.textareaRef.selectionEnd;return c},r._handleCaretChange=function(c){var f=function(){var y=r.getCaretPosition()-1;r.lastTrigger=r.lastTrigger?y:0};if(c.type==="keydown"){var h=c.keyCode||c.which;switch(h){case xi.UP:case xi.DOWN:r._isAutocompleteOpen()||f();break;case xi.LEFT:case xi.RIGHT:f();break}return}f()},r._onSelect=function(c){var f=r.state,h=f.selectionEnd,g=f.currentTrigger,y=f.value,w=r.props.onItemSelected;if(g){var S=r._getTextToReplace(g);if(!S){r._closeAutocomplete();return}var D=S(c);if(!D){r._closeAutocomplete();return}w&&w({currentTrigger:g,item:c});var I=function(Z,Q,K){switch(Z){case"start":return K;case"next":case"end":return K+Q.length;default:if(!Number.isInteger(Z))throw new Error('RTA: caretPosition should be "start", "next", "end" or number.');return Z}},M=y.slice(0,h),N=I0(g),R=M.length-M.lastIndexOf(g),k=M.search(new RegExp("(?!".concat(N,")$")))-R,B=D.caretPosition==="next"?"".concat(D.text," "):D.text,L=I(D.caretPosition,B,k),_=M.substring(0,k)+B,V=y.replace(M,_);r.setState({value:V,dataLoading:!1},function(){var Y=r.tokenRegExpEnding.exec(B),Z=Y?Y[0].length:1;r.lastTrigger=L&&L-Z,r.textareaRef.value=V,r.textareaRef.selectionEnd=L,r._changeHandler();var Q=r.textareaRef.scrollTop;r.setCaretPosition(L),window.chrome&&(r.textareaRef.scrollTop=Q)})}},r._getTextToReplace=function(c){var f=r.props.trigger[c];if(!c||!f)return null;var h=f.output;return function(g){if(typeof g=="object"&&(!h||typeof h!="function"))throw new Error('Output functor is not defined! If you are using items as object you have to define "output" function. https://github.com/webscopeio/react-textarea-autocomplete#trigger-type');if(h){var y=h(g,c);if(y===void 0||typeof y=="number")throw new Error(`Output functor should return string or object in shape {text: string, caretPosition: string | number}.
Got "`.concat(String(y),'". Check the implementation for trigger "').concat(c,`"
See https://github.com/webscopeio/react-textarea-autocomplete#trigger-type for more information.
-`));if(y===null)return null;if(typeof y=="string")return{text:y,caretPosition:pC};if(!y.text&&typeof y.text!="string")throw new Error('Output "text" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger "'.concat(c,`"
+`));if(y===null)return null;if(typeof y=="string")return{text:y,caretPosition:bx};if(!y.text&&typeof y.text!="string")throw new Error('Output "text" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger "'.concat(c,`"
`));if(!y.caretPosition)throw new Error('Output "caretPosition" is not defined! Object should has shape {text: string, caretPosition: string | number}. Check the implementation for trigger "'.concat(c,`"
`));return y}if(typeof g!="string")throw new Error(`Output item should be string
-`);return{text:"".concat(c).concat(g).concat(c),caretPosition:pC}}},r._getCurrentTriggerSettings=function(){var c=r.state.currentTrigger;return c?r.props.trigger[c]:null},r._getValuesFromProvider=function(){var c=r.state,f=c.currentTrigger,p=c.actualToken,g=r._getCurrentTriggerSettings();if(!(!f||!g)){var y=g.dataProvider,w=g.component;if(typeof y!="function")throw new Error("Trigger provider has to be a function!");r.setState({dataLoading:!0});var T=y(p);T instanceof Promise||(T=Promise.resolve(T)),T.then(function(S){if(!Array.isArray(S))throw new Error("Trigger provider has to provide an array!");if(typeof w!="function")throw new Error("Component should be defined!");if(f===r.state.currentTrigger){if(!S.length){r._closeAutocomplete();return}r.setState({dataLoading:!1,data:S,component:w})}}).catch(function(S){return mC(S.message)})}},r._getSuggestions=function(){var c=r.state,f=c.currentTrigger,p=c.data;return!f||!p||p&&!p.length?null:p},r._createRegExp=function(){var c=r.props.trigger;r.tokenRegExp=new RegExp("(".concat(Object.keys(c).sort(function(f,p){return fp?-1:0}).map(function(f){return b0(f)}).join("|"),")((?:(?!\\1)[^\\s])*$)")),r.tokenRegExpEnding=new RegExp("(".concat(Object.keys(c).sort(function(f,p){return f
p?-1:0}).map(function(f){return b0(f)}).join("|"),")$"))},r._closeAutocomplete=function(){var c=r.state.currentTrigger;r.escListenerDestroy(),r.setState({data:null,dataLoading:!1,currentTrigger:null},function(){c&&r._onItemHighlightedHandler(null)})},r._cleanUpProps=function(){var c=sY({},r.props),f=["loadingComponent","boundariesElement","containerStyle","minChar","scrollToItem","ref","innerRef","onChange","onCaretPositionChange","className","value","trigger","listStyle","itemStyle","containerStyle","loaderStyle","className","containerClassName","listClassName","itemClassName","loaderClassName","dropdownStyle","dropdownClassName","movePopupAsYouType","textAreaComponent","renderToBody","onItemSelected","onItemHighlighted"];for(var p in c)f.includes(p)&&delete c[p];return c},r._changeHandler=function(c){var f=r.props,p=f.trigger,g=f.onChange,y=f.minChar,w=f.onCaretPositionChange,T=f.movePopupAsYouType,S=r.state,I=S.top,M=S.left,N=c;N||(N=new oY("change",{bubbles:!0}),r.textareaRef.dispatchEvent(N));var _=N.target||r.textareaRef,k=_.selectionEnd,R=_.value;if(r.lastValueBubbledEvent=R,g&&N&&(N.persist&&N.persist(),g(new Proxy(N,{get:function(K,ae,Se){return ae==="target"?_:Reflect.get(K,ae,Se)}}))),w){var L=r.getCaretPosition();w(L)}r.setState({value:R});var H=function(){var K=nY(_,k),ae=K.top,Se=K.left;r.setState({top:ae-r.textareaRef.scrollTop||0,left:Se})},U=function(K){r.lastTrigger=k-K,r._closeAutocomplete(),H()};if(k<=r.lastTrigger){var z=R.slice(0,k),$=r.tokenRegExp.exec(z);U($?$[0].length:0)}var X=R.slice(r.lastTrigger,k),Q=r.tokenRegExp.exec(X),se=Q&&Q[0],ue=Q&&Q[1]||null,fe=ue?ue.length-1:0,Z=r.tokenRegExpEnding.exec(X);if(Z?U(Z[0].length):r._isAutocompleteOpen()||r._closeAutocomplete(),(!se||se.length<=y+fe)&&(r.state.currentTrigger&&!p[r.state.currentTrigger].allowWhitespace||!r.state.currentTrigger)){r._closeAutocomplete();return}if(ue&&p[ue].afterWhitespace&&!/\s/.test(R[k-se.length-1])&&R[k-se.length-1]!==void 0){r._closeAutocomplete();return}if(r.state.currentTrigger&&p[r.state.currentTrigger].allowWhitespace){if(Q=new RegExp("".concat(b0(r.state.currentTrigger),".*$")).exec(R.slice(0,k)),se=Q&&Q[0],!se){r._closeAutocomplete();return}ue=Object.keys(p).find(function(de){return de.slice(0,fe+1)===se.slice(0,fe+1)})||null}var pe=se.slice(1);if(ue){(T||I===null&&M===null||r.state.currentTrigger!==ue)&&H(),r.escListenerInit();var ie=r._getTextToReplace(ue);r.setState({selectionEnd:k,currentTrigger:ue,textToReplace:ie,actualToken:pe},function(){try{r._getValuesFromProvider()}catch(de){mC(de.message)}})}},r._selectHandler=function(c){var f=r.props,p=f.onCaretPositionChange,g=f.onSelect;if(p){var y=r.getCaretPosition();p(y)}g&&(c.persist(),g(c))},r._shouldStayOpen=function(c){var f=c.relatedTarget;return f===null&&(f=document.activeElement),!!(r.dropdownRef&&f instanceof Node&&r.dropdownRef.contains(f))},r._onClick=function(c){var f=r.props.onClick;f&&(c.persist(),f(c)),!r._shouldStayOpen(c)&&r._closeAutocomplete()},r._onBlur=function(c){var f=r.props.onBlur;f&&(c.persist(),f(c)),!r._shouldStayOpen(c)&&r._closeAutocomplete()},r._onScrollHandler=function(){r._closeAutocomplete()},r._onItemHighlightedHandler=function(c){var f=r.props.onItemHighlighted,p=r.state.currentTrigger;if(f)if(typeof f=="function")f({currentTrigger:p,item:c});else throw new Error("`onItemHighlighted` has to be a function")},r._dropdownScroll=function(c){var f=r.props.scrollToItem;if(f){if(f===!0){gY(r.dropdownRef,c);return}if(typeof f!="function"||f.length!==2)throw new Error("`scrollToItem` has to be boolean (true for default implementation) or function with two parameters: container, item.");f(r.dropdownRef,c)}},r._isAutocompleteOpen=function(){var c=r.state,f=c.dataLoading,p=c.currentTrigger,g=r._getSuggestions();return!!((f||g)&&p)},r._textareaRef=function(c){r.props.innerRef&&r.props.innerRef(c),r.textareaRef=c},r.lastTrigger=0,r.escListener=null;var a=r.props,o=a.loadingComponent,i=a.trigger,l=a.value;if(l&&(r.state.value=l),r._createRegExp(),!o)throw new Error("RTA: loadingComponent is not defined");if(!i)throw new Error("RTA: trigger is not defined");return r}return yb(t,[{key:"componentDidMount",value:function(){lf.startListen(this.textareaRef),this.textareaRef&&this.textareaRef.addEventListener("focus",this._handleCaretChange),this.textareaRef&&this.textareaRef.addEventListener("click",this._handleCaretChange),this.textareaRef&&this.textareaRef.addEventListener("keydown",this._handleCaretChange)}},{key:"componentDidUpdate",value:function(r){var a=r.trigger,o=r.value,i=this.props,l=i.trigger,c=i.value;Object.keys(l).join("")!==Object.keys(a).join("")&&this._createRegExp(),o!==c&&this.lastValueBubbledEvent!==c&&(this.lastTrigger=0,this._changeHandler())}},{key:"componentWillUnmount",value:function(){this.escListenerDestroy(),lf.stopListen(this.textareaRef),this.textareaRef&&this.textareaRef.removeEventListener("focus",this._handleCaretChange),this.textareaRef&&this.textareaRef.removeEventListener("click",this._handleCaretChange),this.textareaRef&&this.textareaRef.removeEventListener("keydown",this._handleCaretChange)}},{key:"render",value:function(){var r=this,a=this.props,o=a.loadingComponent,i=a.style,l=a.className,c=a.listStyle,f=a.itemStyle,p=a.boundariesElement,g=a.movePopupAsYouType,y=a.listClassName,w=a.itemClassName,T=a.dropdownClassName,S=a.dropdownStyle,I=a.containerStyle,M=a.containerClassName,N=a.loaderStyle,_=a.loaderClassName,k=a.textAreaComponent,R=a.renderToBody,L=this.state,H=L.left,U=L.top,z=L.dataLoading,$=L.component,X=L.value,Q=L.textToReplace,se=this._isAutocompleteOpen(),ue=this._getSuggestions(),fe={},Z;return k.component?(Z=k.component,fe[k.ref]=this._textareaRef):(Z=k,fe.ref=this._textareaRef),ne.createElement("div",{className:"rta ".concat(z===!0?"rta--loading":""," ").concat(M||""),style:I},ne.createElement(Z,Object.assign({},this._cleanUpProps(),{className:"rta__textarea ".concat(l||""),onChange:this._changeHandler,onSelect:this._selectHandler,onScroll:this._onScrollHandler,onClick:this._onClick,onBlur:this._onBlur,value:X,style:i},fe)),se&&ne.createElement(yY,{innerRef:function(ie){r.dropdownRef=ie},top:U,left:H,style:S,className:T,movePopupAsYouType:g,boundariesElement:p,textareaRef:this.textareaRef,renderToBody:R},ue&&$&&Q&&ne.createElement(mY,{values:ue,component:$,style:c,className:y,itemClassName:w,itemStyle:f,getTextToReplace:Q,onItemHighlighted:this._onItemHighlightedHandler,onSelect:this._onSelect,dropdownScroll:this._dropdownScroll}),z&&ne.createElement("div",{className:"rta__loader ".concat(ue!==null?"rta__loader--suggestion-data":"rta__loader--empty-suggestion-data"," ").concat(_||""),style:N},ne.createElement(o,{data:ue}))))}}],[{key:"getDerivedStateFromProps",value:function(r){var a=r.value;return a==null?null:{value:a}}}]),t}(ne.Component);p6.defaultProps={movePopupAsYouType:!1,value:null,minChar:1,boundariesElement:"body",scrollToItem:!0,textAreaComponent:"textarea",renderToBody:!1};const wY=()=>{const{app:e}=ft.getState(),t=e.metadataCache.getTags();return[...Object.keys(t)].map(n=>n.split("#").pop())},bY=e=>{let t=[];const n=ft.getState().settings;if(n&&(n!=null&&n.UseVaultTags))t=wY();else{const{tags:o}=be.getState();t=o}const r=e.toLowerCase(),a=[];return t.forEach(o=>{o&&o.toLowerCase().contains(r)&&a.push({name:o,char:o})}),a},SY=e=>{const{app:t}=ft.getState(),n=t.vault.getAllLoadedFiles(),r=[];let a;return n.forEach(o=>{e==="["?a="":e.contains("[")&&(a=e.slice(1));const i=a.toLowerCase();o instanceof C.TFile&&["md","png","jpg","canvas","jpeg","gif"].contains(o.extension)&&o.path.toLowerCase().contains(i)&&r.push({name:o.basename,char:o.name,file:o})}),r};var MS=P,DY=function(e){return typeof e=="function"},TY=function(e){var t=MS.useState(e),n=t[0],r=t[1],a=MS.useRef(n),o=MS.useCallback(function(i){a.current=DY(i)?i(a.current):i,r(a.current)},[]);return[n,o,a]},IY=TY;const Co=qt(IY);function EY(e){return e.containerEl.matches(".memos-list-view")}function kS(){}function xY(e){return{app:e.app,showSearch:kS,toggleMode:kS,onMarkdownScroll:kS,getMode:()=>"source",getViewType:()=>"thino_view",id:e.leaf.id,scroll:0,editMode:null,get file(){return e.file},get path(){return e.file.path}}}const CY=(e,t)=>{const{dailyNotesState:{app:n,plugin:r,editor:a,view:o,dailyNotes:i}}=P.useContext(Lt),[l,c]=P.useState(null),[f,p]=P.useState(!1),[g,y]=P.useState(""),[w,T]=P.useState(null),S=P.useRef(C.debounce((U,z,$)=>{kY(U,z,$)},100)),I=P.useRef();P.useEffect(()=>{var U;if(!w){if(!i&&!(n&&window.app)){const z=(U=n||window.app)==null?void 0:U.vault.getMarkdownFiles();T(z[0]);return}for(const z in i)if(i[z]instanceof C.TFile){T(i[z]);break}}},[i]),P.useEffect(()=>{if(!o.plugin.MarkdownEditor||typeof o.plugin.MarkdownEditor!="function"||!e)return;class U extends o.plugin.MarkdownEditor{updateBottomPadding(){}onUpdate(ue,fe){super.onUpdate(ue,fe),N&&N(o,this.get())}}const z=xY(o),$=o.plugin.addChild(new U(n,e,z));$&&!t&&dt.setInstance(`${o.leaf.id}`,$),z.editMode=$,$.owner.editor=$.editor;const X=MY(n,t?"modal":"view");$.set&&$.set(X||"",!0),n.workspace.trigger("thino-editor-created",e,$.editor);const Q=$.cm;return I.current=Q,p(!0),c($),()=>{p(!1),l==null||l.destroy(),o.plugin.removeChild($),I.current=null}},[e]),P.useEffect(()=>{!l||!n||S.current(g,n,t?"modal":"view")},[g,n]);const M=()=>{l&&l.toggleSource()},N=C.debounce((U,z)=>_(U,z),500,!0),_=(U,z)=>{U&&y(z)};return{instance:l,value:g,set:U=>{try{l&&((l==null?void 0:l.editor).replaceSelection(U),y(U))}catch(z){console.error(z)}},get:()=>l?l.get():"",append:(U,z)=>{if(!l||z&&z!==l.owner.id)return;const X=(l.get()||"")+U;(l==null?void 0:l.editor).replaceSelection(U),y(X)},clear:()=>{l&&(l.clear(),y(""))},toggleSource:M}};function m6(e,t){return`thinoEditorContentCache:${e}:${t||"view"}`}function MY(e,t){try{const n=m6(e==null?void 0:e.appId,t);return la.get([n])[n]||""}catch(n){return console.error(n),""}}function kY(e,t,n){try{const r=m6(t==null?void 0:t.appId,n);la.set({[r]:e})}catch(r){console.error(r)}}function NY(e,t){return{line:e.line,ch:e.ch+t}}const gC=({entity:{name:e,char:t,file:n}})=>v.jsx("div",{children:`${t}`}),AY=({data:e})=>v.jsx("div",{children:"Loading"});let Nl;const FY=P.forwardRef((e,t)=>{var Re;const{globalState:{useTinyUndoHistoryCache:n,globalEditorShown:r,memoListView:a},dailyNotesState:{settings:o,app:i}}=P.useContext(Lt),{SaveMemoButtonLabel:l,SaveMemoButtonIcon:c}=o,{className:f,inputerType:p,initialContent:g,placeholder:y,showConfirmBtn:w,showCancelBtn:T,onConfirmBtnClick:S,onCancelBtnClick:I,onContentChange:M}=e,N=P.useRef(null),_=P.useRef(null),k=P.useRef(null),R=eY(),{instance:L,value:H,set:U,get:z,append:$,clear:X,toggleSource:Q}=CY(_.current,e.modal),[,se,ue]=Co(0),[fe,Z]=Co(!1);P.useEffect(()=>{var Fe,Be;if(o&&o.FocusOnEditor)switch(p){case"minimal":case"memos":(Fe=N.current)==null||Fe.focus();break;case"obsidian":L&&((Be=L.editor)==null||Be.focus())}},[o,L]),P.useEffect(()=>{if(!i)return;const Fe=i.workspace.getLeavesOfType(lo);let Be,Qe;Fe.length>0?(Qe=Fe[0].view.containerEl,Be=Qe.offsetHeight):(Qe=document,Be=window.outerHeight),se(Be)},[i]),P.useEffect(()=>{!N.current||p==="obsidian"||g&&(N.current.value=g,R())},[]),P.useEffect(()=>{var Fe;if(p!=="obsidian")if(n){if(!N.current)return;const{tinyUndoActionsCache:Be,tinyUndoIndexCache:Qe}=la.get(["tinyUndoActionsCache","tinyUndoIndexCache"]);return k.current=new XH(N.current,{interval:5e3,initialActions:Be,initialIndex:Qe}),k.current.subscribe((Ze,st)=>{la.set({tinyUndoActionsCache:Ze,tinyUndoIndexCache:st})}),()=>{var Ze;(Ze=k.current)==null||Ze.destroy()}}else(Fe=k.current)==null||Fe.destroy(),k.current=null,la.remove(["tinyUndoActionsCache","tinyUndoIndexCache"])},[n]),P.useEffect(()=>{N.current&&(N.current.style.height="auto",N.current.style.height=(N.current.scrollHeight??0)+"px")},[(Re=N.current)==null?void 0:Re.value]),P.useImperativeHandle(t,()=>({element:N.current,blur:()=>{var Fe,Be;switch(p){case"minimal":case"memos":(Fe=N.current)==null||Fe.blur();break;case"obsidian":L&&((Be=L.editor)==null||Be.blur())}},focus:Fe=>{var Be,Qe,Ze,st,xt;switch(p){case"minimal":case"memos":(Be=N.current)==null||Be.focus();break;case"obsidian":if(L){if(Fe&&Fe!==((st=(Ze=(Qe=L==null?void 0:L.owner)==null?void 0:Qe.view)==null?void 0:Ze.leaf)==null?void 0:st.id))return;(xt=L.editor)==null||xt.focus()}}},insertTag:Fe=>{var Be,Qe,Ze;switch(p){case"minimal":case"memos":{if(!N.current)return;const st=N.current.value;N.current.value=st.slice(0,N.current.selectionStart)+"# "+st.slice(N.current.selectionStart),M(N.current.value),R();break}case"obsidian":if(Fe&&Fe!==((Ze=(Qe=(Be=L==null?void 0:L.owner)==null?void 0:Be.view)==null?void 0:Qe.leaf)==null?void 0:Ze.id))return;if(L){const st=L.editor,xt=st.getCursor("from");st.replaceRange("#",xt),st.setSelection(NY(xt,1))}break}},insertText:(Fe,Be)=>{switch(p){case"minimal":case"memos":{if(!N.current)return;const Qe=N.current.value;N.current.value=Qe.slice(0,N.current.selectionStart)+Fe+Qe.slice(N.current.selectionStart),M(N.current.value),R()}break;case"obsidian":L&&$(Fe,Be);break}},setContent:Fe=>{switch(p){case"minimal":case"memos":N.current&&(N.current.value=Fe,M(N.current.value),R());break;case"obsidian":L&&U(Fe);break}},getContent:()=>{switch(p){case"minimal":case"memos":return N.current?N.current.value:"";case"obsidian":return z()}},toggleSource:()=>{switch(p){case"minimal":case"memos":break;case"obsidian":Q();break}},clear:()=>{switch(p){case"minimal":case"memos":N.current&&(N.current.value="",M(N.current.value),R());break;case"obsidian":X();break}}}),[L,p]);const pe=Fe=>{if(!N.current)return;const{fileManager:Be}=Le.getState().dailyNotesState.app;if(Fe.currentTrigger==="#"){const Qe=N.current.value;let Ze;Nl!=null?Ze=Nl.length:Ze=0;let st=N.current.selectionStart;for(let xt=0;xt{var Fe;M(((Fe=N.current)==null?void 0:Fe.value)||""),R()},[]),de=()=>{var Fe;switch(p){case"minimal":case"memos":if(!N.current)return;N.current.value=ae(),S(N.current.value),N.current.value="",R(),(Fe=k.current)==null||Fe.resetState();break;case"obsidian":S(z()),X(),R();break}},K=P.useCallback(()=>{switch(p){case"minimal":case"memos":N.current&&(N.current.value="",M(N.current.value),R());break;case"obsidian":X();break}I()},[p,L,N]),ae=()=>la.get(["thinoEditorContentCache"]).thinoEditorContentCache||"",Se=()=>{if(N.current)return N.current.value=ae(),N.current.value},je=Fe=>{switch(Fe){case"memos":return v.jsx(p6,{className:`common-editor-inputer scroll ${fe?" editing":""}`,loadingComponent:AY,placeholder:y,movePopupAsYouType:!0,value:Se(),innerRef:Be=>{N.current=Be},onFocus:()=>{Z(!0)},onBlur:()=>{Z(!1)},onInput:ie,style:{maxHeight:`${ue.current>400?ue.current-400:100}px`},dropdownStyle:{minWidth:180,maxHeight:250,overflowY:"auto"},minChar:0,onItemSelected:pe,scrollToItem:!0,trigger:{"#":{dataProvider:Be=>(Nl=Be,bY(Be).map(({name:Qe,char:Ze})=>({name:Qe,char:Ze}))),component:gC,afterWhitespace:!0,output:Be=>Be.char},"[[":{dataProvider:Be=>(Nl=Be,SY(Be).slice(0,10).map(({name:Qe,char:Ze,file:st})=>({name:Qe,char:Ze,file:st}))),component:gC,afterWhitespace:!0,output:Be=>Be.char}}});case"minimal":return v.jsx("textarea",{style:{minHeight:48},className:"common-editor-inputer scroll",rows:1,placeholder:y,ref:N,onInput:ie});case"obsidian":return v.jsx("div",{className:"common-editor-inputer common-editor-mod-cm6",onClick:()=>{var Be;(Be=L==null?void 0:L.editor)==null||Be.focus()},ref:_});default:return v.jsx("div",{className:"common-editor-inputer common-editor-mod-cm6",ref:_})}};return v.jsxs("div",{className:"common-editor-wrapper "+f,children:[je(p),v.jsxs("div",{className:"common-tools-wrapper",children:[v.jsx("div",{className:"common-tools-container",children:v.jsx(ts,{when:e.tools!==void 0,children:e.tools})}),v.jsxs("div",{className:"btns-container",children:[v.jsx(ts,{when:T,children:v.jsx("button",{className:"action-btn cancel-btn",onClick:()=>{o&&o.DefaultEditorLocation==="Top"&&!r&&K()},onPointerDown:()=>{(o&&o.DefaultEditorLocation==="Bottom"||r)&&K()},children:ot.getState().pathname==="/"&&a==="chat"&&((o==null?void 0:o.chatViewStyle)==="fluent"||(o==null?void 0:o.chatViewStyle)==="inline")?"":E("CANCEL EDIT")})}),v.jsx(ts,{when:w,children:v.jsxs("button",{title:"Ctrl/Cmd + Enter to save thino",className:"action-btn confirm-btn",onClick:()=>{o&&o.DefaultEditorLocation==="Top"&&!r&&de()},onPointerDown:()=>{(o&&o.DefaultEditorLocation==="Bottom"||r)&&de()},children:[a==="chat"&&((o==null?void 0:o.chatViewStyle)==="fluent"||(o==null?void 0:o.chatViewStyle)==="inline")?"":l,v.jsx("span",{className:"icon-text",children:null})]})})]})]})]})}),OY=typeof window<"u"?P.useLayoutEffect:P.useEffect;function PY(e,t,n,r){const a=P.useRef(t);OY(()=>{a.current=t},[t]),P.useEffect(()=>{const o=(n==null?void 0:n.current)||window;if(!(o&&o.addEventListener))return;const i=l=>{a.current(l)};return o.addEventListener(e,i,r),()=>{o.removeEventListener(e,i,r)}},[e,n,r])}function Pv(e,t,n="mousedown"){PY(n,r=>{const a=r.target;if(!a||!a.isConnected||a.closest(".suggestion-container")||a.closest(".menu"))return;(Array.isArray(e)?e.every(i=>i.current&&!i.current.contains(a)):e.current&&!e.current.contains(a))&&t(r)})}const g6=e=>{const{year:t,handleYearChange:n}=e,[r,a]=P.useState([]),[o,i]=P.useState(t),l=P.useRef(null),c=P.useRef(null),[f,p]=ne.useState(!1),g=ne.useRef(null);Pv(g,()=>{p(!1)}),P.useEffect(()=>{l.current&&C.setIcon(l.current,"chevron-left"),c.current&&C.setIcon(c.current,"chevron-right")},[l,c,f]),P.useEffect(()=>{w(o)},[t]);const w=T=>{const S=parseInt(T),I=S-S%10,M=[];for(let N=0;N<10;N++)M.push(`${I+N}`);a(M)};return v.jsxs(v.Fragment,{children:[v.jsxs("span",{className:"btn year-btn",onClick:()=>{p(!f)},children:[v.jsx("span",{children:t}),v.jsx("span",{children:E("year")})]}),f&&v.jsxs("div",{ref:g,className:"year-picker-wrapper",children:[v.jsxs("div",{className:"year-picker-header",children:[v.jsxs("div",{className:"year-picker-header-title",children:[o," "+(E("year")||"")]}),v.jsxs("div",{className:"year-picker-header-btns",children:[v.jsx("span",{className:"btn",ref:l,onClick:()=>{const T=parseInt(o)-10;i(T.toString()),w(T.toString())}}),v.jsx("span",{className:"btn",ref:c,onClick:()=>{const T=parseInt(o)+10;i(T.toString()),w(T.toString())}})]})]}),v.jsx("div",{className:"year-picker-body",children:v.jsx("div",{className:"year-picker-body-list",children:r.map(T=>v.jsx("div",{className:`year-picker-body-item ${T===o?"selected":""}`,onClick:()=>{i(T),n(T),p(!1)},children:T},T))})})]})]})},v6=e=>{const{month:t,handleMonthChange:n}=e,[r,a]=P.useState([]),[o,i]=P.useState((parseInt(t)+1).toString()),[l,c]=ne.useState(!1),f=ne.useRef(null);Pv(f,()=>{c(!1)}),P.useEffect(()=>{g()},[t]);const g=()=>{const y=[];for(let w=1;w<=12;w++)y.push(`${w}`);a(y)};return v.jsxs(v.Fragment,{children:[v.jsxs("span",{className:"btn month-btn",onClick:()=>{c(!l)},children:[v.jsxs("span",{children:[E("monthsShort")[parseInt(t)]||parseInt(t)+1," "]}),v.jsx("span",{children:E("month")||""})]}),l&&v.jsxs("div",{ref:f,className:"month-picker-wrapper",children:[v.jsxs("div",{className:"month-picker-header",children:[v.jsxs("div",{className:"month-picker-header-title",children:[o," "+(E("month")||"")]}),v.jsx("div",{className:"month-picker-header-btns"})]}),v.jsx("div",{className:"month-picker-body",children:v.jsx("div",{className:"month-picker-body-list",children:r.map(y=>v.jsx("div",{className:`month-picker-body-item ${y===o?"selected":""}`,onClick:()=>{i(y),n(y),c(!1)},children:y},y))})})]})]})},Sb=e=>{const{className:t,datestamp:n,handleDateStampChange:r}=e,[a,o]=P.useState(vg(n)),[i,l]=P.useState(n);P.useEffect(()=>{o(vg(n))},[n]);const c=new Date(a),f=c.getDay(),p=[];for(let T=0;T{r(S,T.nativeEvent),l(S)},w=T=>{const S=c.getFullYear(),I=c.getMonth()+1;let M=0;I===1&&T===-1?M=new Date(`${S-1}/12/1`).getTime():I===12&&T===1?M=new Date(`${S+1}/1/1`).getTime():M=new Date(`${S}/${I+T}/1`).getTime(),o(vg(M))};return v.jsxs("div",{className:`date-picker-wrapper ${t}`,children:[v.jsxs("div",{className:"date-picker-header",children:[v.jsx("span",{ref:T=>{T&&C.setIcon(T,"chevron-left")},className:"btn btn-text",onClick:()=>w(-1)}),v.jsxs("span",{className:"normal-text",children:[v.jsx(g6,{year:c.getFullYear().toString(),handleYearChange:T=>{o(vg(new Date(`${T}/${c.getMonth()+1}/1`).getTime()))}}),v.jsx(v6,{month:c.getMonth().toString(),handleMonthChange:T=>{o(vg(new Date(`${c.getFullYear()}/${parseInt(T)}/1`).getTime()))}})]}),v.jsx("span",{ref:T=>{T&&C.setIcon(T,"chevron-right")},className:"btn btn-text",onClick:()=>w(1)})]}),v.jsxs("div",{className:"date-picker-day-container",children:[v.jsx("div",{className:"date-picker-day-header",children:E("weekDaysShort").map(T=>v.jsx("span",{className:"day-item",children:T},T))}),v.jsx("div",{className:"date-picker-day-content",children:p.map(T=>T.date===0?v.jsx("span",{className:"day-item null",children:""},T.datestamp):v.jsx("span",{className:`day-item ${T.datestamp===n?"current":""} ${T.datestamp===i?"selected":""}`,onClick:S=>y(S,T.datestamp),children:v.jsx("span",{className:"day-item-text",children:T.date})},T.datestamp))})]})]})};function jY(e){const t=new Date(e),n=new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`);return((n.getMonth()===11?new Date(`${n.getFullYear()+1}/1/1`):new Date(`${n.getFullYear()}/${n.getMonth()+2}/1`)).getTime()-n.getTime())/ei}function vg(e){const t=new Date(e);return new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`).getTime()}var vC=function(t){return t.reduce(function(n,r){var a=r[0],o=r[1];return n[a]=o,n},{})},yC=typeof window<"u"&&window.document&&window.document.createElement?P.useLayoutEffect:P.useEffect,ti="top",as="bottom",os="right",ni="left",W2="auto",jv=[ti,as,os,ni],yp="start",Gg="end",LY="clippingParents",y6="viewport",yg="popper",RY="reference",wC=jv.reduce(function(e,t){return e.concat([t+"-"+yp,t+"-"+Gg])},[]),$2=[].concat(jv,[W2]).reduce(function(e,t){return e.concat([t,t+"-"+yp,t+"-"+Gg])},[]),_Y="beforeRead",BY="read",HY="afterRead",YY="beforeMain",UY="main",zY="afterMain",VY="beforeWrite",WY="write",$Y="afterWrite",ZY=[_Y,BY,HY,YY,UY,zY,VY,WY,$Y];function Kl(e){return e?(e.nodeName||"").toLowerCase():null}function Ni(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function vf(e){var t=Ni(e).Element;return e instanceof t||e instanceof Element}function ns(e){var t=Ni(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function Z2(e){if(typeof ShadowRoot>"u")return!1;var t=Ni(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function qY(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var r=t.styles[n]||{},a=t.attributes[n]||{},o=t.elements[n];!ns(o)||!Kl(o)||(Object.assign(o.style,r),Object.keys(a).forEach(function(i){var l=a[i];l===!1?o.removeAttribute(i):o.setAttribute(i,l===!0?"":l)}))})}function GY(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(r){var a=t.elements[r],o=t.attributes[r]||{},i=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:n[r]),l=i.reduce(function(c,f){return c[f]="",c},{});!ns(a)||!Kl(a)||(Object.assign(a.style,l),Object.keys(o).forEach(function(c){a.removeAttribute(c)}))})}}const JY={name:"applyStyles",enabled:!0,phase:"write",fn:qY,effect:GY,requires:["computeStyles"]};function Zl(e){return e.split("-")[0]}var df=Math.max,Mw=Math.min,wp=Math.round;function wT(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function w6(){return!/^((?!chrome|android).)*safari/i.test(wT())}function bp(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),a=1,o=1;t&&ns(e)&&(a=e.offsetWidth>0&&wp(r.width)/e.offsetWidth||1,o=e.offsetHeight>0&&wp(r.height)/e.offsetHeight||1);var i=vf(e)?Ni(e):window,l=i.visualViewport,c=!w6()&&n,f=(r.left+(c&&l?l.offsetLeft:0))/a,p=(r.top+(c&&l?l.offsetTop:0))/o,g=r.width/a,y=r.height/o;return{width:g,height:y,top:p,right:f+g,bottom:p+y,left:f,x:f,y:p}}function q2(e){var t=bp(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function b6(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Z2(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Yu(e){return Ni(e).getComputedStyle(e)}function KY(e){return["table","td","th"].indexOf(Kl(e))>=0}function rd(e){return((vf(e)?e.ownerDocument:e.document)||window.document).documentElement}function Db(e){return Kl(e)==="html"?e:e.assignedSlot||e.parentNode||(Z2(e)?e.host:null)||rd(e)}function bC(e){return!ns(e)||Yu(e).position==="fixed"?null:e.offsetParent}function QY(e){var t=/firefox/i.test(wT()),n=/Trident/i.test(wT());if(n&&ns(e)){var r=Yu(e);if(r.position==="fixed")return null}var a=Db(e);for(Z2(a)&&(a=a.host);ns(a)&&["html","body"].indexOf(Kl(a))<0;){var o=Yu(a);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return a;a=a.parentNode}return null}function Lv(e){for(var t=Ni(e),n=bC(e);n&&KY(n)&&Yu(n).position==="static";)n=bC(n);return n&&(Kl(n)==="html"||Kl(n)==="body"&&Yu(n).position==="static")?t:n||QY(e)||t}function G2(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function _g(e,t,n){return df(e,Mw(t,n))}function XY(e,t,n){var r=_g(e,t,n);return r>n?n:r}function S6(){return{top:0,right:0,bottom:0,left:0}}function D6(e){return Object.assign({},S6(),e)}function T6(e,t){return t.reduce(function(n,r){return n[r]=e,n},{})}var eU=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,D6(typeof t!="number"?t:T6(t,jv))};function tU(e){var t,n=e.state,r=e.name,a=e.options,o=n.elements.arrow,i=n.modifiersData.popperOffsets,l=Zl(n.placement),c=G2(l),f=[ni,os].indexOf(l)>=0,p=f?"height":"width";if(!(!o||!i)){var g=eU(a.padding,n),y=q2(o),w=c==="y"?ti:ni,T=c==="y"?as:os,S=n.rects.reference[p]+n.rects.reference[c]-i[c]-n.rects.popper[p],I=i[c]-n.rects.reference[c],M=Lv(o),N=M?c==="y"?M.clientHeight||0:M.clientWidth||0:0,_=S/2-I/2,k=g[w],R=N-y[p]-g[T],L=N/2-y[p]/2+_,H=_g(k,L,R),U=c;n.modifiersData[r]=(t={},t[U]=H,t.centerOffset=H-L,t)}}function nU(e){var t=e.state,n=e.options,r=n.element,a=r===void 0?"[data-popper-arrow]":r;a!=null&&(typeof a=="string"&&(a=t.elements.popper.querySelector(a),!a)||b6(t.elements.popper,a)&&(t.elements.arrow=a))}const I6={name:"arrow",enabled:!0,phase:"main",fn:tU,effect:nU,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Sp(e){return e.split("-")[1]}var rU={top:"auto",right:"auto",bottom:"auto",left:"auto"};function aU(e,t){var n=e.x,r=e.y,a=t.devicePixelRatio||1;return{x:wp(n*a)/a||0,y:wp(r*a)/a||0}}function SC(e){var t,n=e.popper,r=e.popperRect,a=e.placement,o=e.variation,i=e.offsets,l=e.position,c=e.gpuAcceleration,f=e.adaptive,p=e.roundOffsets,g=e.isFixed,y=i.x,w=y===void 0?0:y,T=i.y,S=T===void 0?0:T,I=typeof p=="function"?p({x:w,y:S}):{x:w,y:S};w=I.x,S=I.y;var M=i.hasOwnProperty("x"),N=i.hasOwnProperty("y"),_=ni,k=ti,R=window;if(f){var L=Lv(n),H="clientHeight",U="clientWidth";if(L===Ni(n)&&(L=rd(n),Yu(L).position!=="static"&&l==="absolute"&&(H="scrollHeight",U="scrollWidth")),a===ti||(a===ni||a===os)&&o===Gg){k=as;var z=g&&L===R&&R.visualViewport?R.visualViewport.height:L[H];S-=z-r.height,S*=c?1:-1}if(a===ni||(a===ti||a===as)&&o===Gg){_=os;var $=g&&L===R&&R.visualViewport?R.visualViewport.width:L[U];w-=$-r.width,w*=c?1:-1}}var X=Object.assign({position:l},f&&rU),Q=p===!0?aU({x:w,y:S},Ni(n)):{x:w,y:S};if(w=Q.x,S=Q.y,c){var se;return Object.assign({},X,(se={},se[k]=N?"0":"",se[_]=M?"0":"",se.transform=(R.devicePixelRatio||1)<=1?"translate("+w+"px, "+S+"px)":"translate3d("+w+"px, "+S+"px, 0)",se))}return Object.assign({},X,(t={},t[k]=N?S+"px":"",t[_]=M?w+"px":"",t.transform="",t))}function oU(e){var t=e.state,n=e.options,r=n.gpuAcceleration,a=r===void 0?!0:r,o=n.adaptive,i=o===void 0?!0:o,l=n.roundOffsets,c=l===void 0?!0:l,f={placement:Zl(t.placement),variation:Sp(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:a,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,SC(Object.assign({},f,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:i,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,SC(Object.assign({},f,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const E6={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:oU,data:{}};var S0={passive:!0};function iU(e){var t=e.state,n=e.instance,r=e.options,a=r.scroll,o=a===void 0?!0:a,i=r.resize,l=i===void 0?!0:i,c=Ni(t.elements.popper),f=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&f.forEach(function(p){p.addEventListener("scroll",n.update,S0)}),l&&c.addEventListener("resize",n.update,S0),function(){o&&f.forEach(function(p){p.removeEventListener("scroll",n.update,S0)}),l&&c.removeEventListener("resize",n.update,S0)}}const x6={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:iU,data:{}};var sU={left:"right",right:"left",bottom:"top",top:"bottom"};function tw(e){return e.replace(/left|right|bottom|top/g,function(t){return sU[t]})}var lU={start:"end",end:"start"};function DC(e){return e.replace(/start|end/g,function(t){return lU[t]})}function J2(e){var t=Ni(e),n=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:n,scrollTop:r}}function K2(e){return bp(rd(e)).left+J2(e).scrollLeft}function uU(e,t){var n=Ni(e),r=rd(e),a=n.visualViewport,o=r.clientWidth,i=r.clientHeight,l=0,c=0;if(a){o=a.width,i=a.height;var f=w6();(f||!f&&t==="fixed")&&(l=a.offsetLeft,c=a.offsetTop)}return{width:o,height:i,x:l+K2(e),y:c}}function cU(e){var t,n=rd(e),r=J2(e),a=(t=e.ownerDocument)==null?void 0:t.body,o=df(n.scrollWidth,n.clientWidth,a?a.scrollWidth:0,a?a.clientWidth:0),i=df(n.scrollHeight,n.clientHeight,a?a.scrollHeight:0,a?a.clientHeight:0),l=-r.scrollLeft+K2(e),c=-r.scrollTop;return Yu(a||n).direction==="rtl"&&(l+=df(n.clientWidth,a?a.clientWidth:0)-o),{width:o,height:i,x:l,y:c}}function Q2(e){var t=Yu(e),n=t.overflow,r=t.overflowX,a=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+a+r)}function C6(e){return["html","body","#document"].indexOf(Kl(e))>=0?e.ownerDocument.body:ns(e)&&Q2(e)?e:C6(Db(e))}function Bg(e,t){var n;t===void 0&&(t=[]);var r=C6(e),a=r===((n=e.ownerDocument)==null?void 0:n.body),o=Ni(r),i=a?[o].concat(o.visualViewport||[],Q2(r)?r:[]):r,l=t.concat(i);return a?l:l.concat(Bg(Db(i)))}function bT(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function dU(e,t){var n=bp(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function TC(e,t,n){return t===y6?bT(uU(e,n)):vf(t)?dU(t,n):bT(cU(rd(e)))}function fU(e){var t=Bg(Db(e)),n=["absolute","fixed"].indexOf(Yu(e).position)>=0,r=n&&ns(e)?Lv(e):e;return vf(r)?t.filter(function(a){return vf(a)&&b6(a,r)&&Kl(a)!=="body"}):[]}function hU(e,t,n,r){var a=t==="clippingParents"?fU(e):[].concat(t),o=[].concat(a,[n]),i=o[0],l=o.reduce(function(c,f){var p=TC(e,f,r);return c.top=df(p.top,c.top),c.right=Mw(p.right,c.right),c.bottom=Mw(p.bottom,c.bottom),c.left=df(p.left,c.left),c},TC(e,i,r));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function M6(e){var t=e.reference,n=e.element,r=e.placement,a=r?Zl(r):null,o=r?Sp(r):null,i=t.x+t.width/2-n.width/2,l=t.y+t.height/2-n.height/2,c;switch(a){case ti:c={x:i,y:t.y-n.height};break;case as:c={x:i,y:t.y+t.height};break;case os:c={x:t.x+t.width,y:l};break;case ni:c={x:t.x-n.width,y:l};break;default:c={x:t.x,y:t.y}}var f=a?G2(a):null;if(f!=null){var p=f==="y"?"height":"width";switch(o){case yp:c[f]=c[f]-(t[p]/2-n[p]/2);break;case Gg:c[f]=c[f]+(t[p]/2-n[p]/2);break}}return c}function Jg(e,t){t===void 0&&(t={});var n=t,r=n.placement,a=r===void 0?e.placement:r,o=n.strategy,i=o===void 0?e.strategy:o,l=n.boundary,c=l===void 0?LY:l,f=n.rootBoundary,p=f===void 0?y6:f,g=n.elementContext,y=g===void 0?yg:g,w=n.altBoundary,T=w===void 0?!1:w,S=n.padding,I=S===void 0?0:S,M=D6(typeof I!="number"?I:T6(I,jv)),N=y===yg?RY:yg,_=e.rects.popper,k=e.elements[T?N:y],R=hU(vf(k)?k:k.contextElement||rd(e.elements.popper),c,p,i),L=bp(e.elements.reference),H=M6({reference:L,element:_,strategy:"absolute",placement:a}),U=bT(Object.assign({},_,H)),z=y===yg?U:L,$={top:R.top-z.top+M.top,bottom:z.bottom-R.bottom+M.bottom,left:R.left-z.left+M.left,right:z.right-R.right+M.right},X=e.modifiersData.offset;if(y===yg&&X){var Q=X[a];Object.keys($).forEach(function(se){var ue=[os,as].indexOf(se)>=0?1:-1,fe=[ti,as].indexOf(se)>=0?"y":"x";$[se]+=Q[fe]*ue})}return $}function pU(e,t){t===void 0&&(t={});var n=t,r=n.placement,a=n.boundary,o=n.rootBoundary,i=n.padding,l=n.flipVariations,c=n.allowedAutoPlacements,f=c===void 0?$2:c,p=Sp(r),g=p?l?wC:wC.filter(function(T){return Sp(T)===p}):jv,y=g.filter(function(T){return f.indexOf(T)>=0});y.length===0&&(y=g);var w=y.reduce(function(T,S){return T[S]=Jg(e,{placement:S,boundary:a,rootBoundary:o,padding:i})[Zl(S)],T},{});return Object.keys(w).sort(function(T,S){return w[T]-w[S]})}function mU(e){if(Zl(e)===W2)return[];var t=tw(e);return[DC(e),t,DC(t)]}function gU(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var a=n.mainAxis,o=a===void 0?!0:a,i=n.altAxis,l=i===void 0?!0:i,c=n.fallbackPlacements,f=n.padding,p=n.boundary,g=n.rootBoundary,y=n.altBoundary,w=n.flipVariations,T=w===void 0?!0:w,S=n.allowedAutoPlacements,I=t.options.placement,M=Zl(I),N=M===I,_=c||(N||!T?[tw(I)]:mU(I)),k=[I].concat(_).reduce(function(Re,Fe){return Re.concat(Zl(Fe)===W2?pU(t,{placement:Fe,boundary:p,rootBoundary:g,padding:f,flipVariations:T,allowedAutoPlacements:S}):Fe)},[]),R=t.rects.reference,L=t.rects.popper,H=new Map,U=!0,z=k[0],$=0;$=0,fe=ue?"width":"height",Z=Jg(t,{placement:X,boundary:p,rootBoundary:g,altBoundary:y,padding:f}),pe=ue?se?os:ni:se?as:ti;R[fe]>L[fe]&&(pe=tw(pe));var ie=tw(pe),de=[];if(o&&de.push(Z[Q]<=0),l&&de.push(Z[pe]<=0,Z[ie]<=0),de.every(function(Re){return Re})){z=X,U=!1;break}H.set(X,de)}if(U)for(var K=T?3:1,ae=function(Fe){var Be=k.find(function(Qe){var Ze=H.get(Qe);if(Ze)return Ze.slice(0,Fe).every(function(st){return st})});if(Be)return z=Be,"break"},Se=K;Se>0;Se--){var je=ae(Se);if(je==="break")break}t.placement!==z&&(t.modifiersData[r]._skip=!0,t.placement=z,t.reset=!0)}}const k6={name:"flip",enabled:!0,phase:"main",fn:gU,requiresIfExists:["offset"],data:{_skip:!1}};function IC(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function EC(e){return[ti,os,as,ni].some(function(t){return e[t]>=0})}function vU(e){var t=e.state,n=e.name,r=t.rects.reference,a=t.rects.popper,o=t.modifiersData.preventOverflow,i=Jg(t,{elementContext:"reference"}),l=Jg(t,{altBoundary:!0}),c=IC(i,r),f=IC(l,a,o),p=EC(c),g=EC(f);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:f,isReferenceHidden:p,hasPopperEscaped:g},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":g})}const N6={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:vU};function yU(e,t,n){var r=Zl(e),a=[ni,ti].indexOf(r)>=0?-1:1,o=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,i=o[0],l=o[1];return i=i||0,l=(l||0)*a,[ni,os].indexOf(r)>=0?{x:l,y:i}:{x:i,y:l}}function wU(e){var t=e.state,n=e.options,r=e.name,a=n.offset,o=a===void 0?[0,0]:a,i=$2.reduce(function(p,g){return p[g]=yU(g,t.rects,o),p},{}),l=i[t.placement],c=l.x,f=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=f),t.modifiersData[r]=i}const A6={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:wU};function bU(e){var t=e.state,n=e.name;t.modifiersData[n]=M6({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const F6={name:"popperOffsets",enabled:!0,phase:"read",fn:bU,data:{}};function SU(e){return e==="x"?"y":"x"}function DU(e){var t=e.state,n=e.options,r=e.name,a=n.mainAxis,o=a===void 0?!0:a,i=n.altAxis,l=i===void 0?!1:i,c=n.boundary,f=n.rootBoundary,p=n.altBoundary,g=n.padding,y=n.tether,w=y===void 0?!0:y,T=n.tetherOffset,S=T===void 0?0:T,I=Jg(t,{boundary:c,rootBoundary:f,padding:g,altBoundary:p}),M=Zl(t.placement),N=Sp(t.placement),_=!N,k=G2(M),R=SU(k),L=t.modifiersData.popperOffsets,H=t.rects.reference,U=t.rects.popper,z=typeof S=="function"?S(Object.assign({},t.rects,{placement:t.placement})):S,$=typeof z=="number"?{mainAxis:z,altAxis:z}:Object.assign({mainAxis:0,altAxis:0},z),X=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,Q={x:0,y:0};if(L){if(o){var se,ue=k==="y"?ti:ni,fe=k==="y"?as:os,Z=k==="y"?"height":"width",pe=L[k],ie=pe+I[ue],de=pe-I[fe],K=w?-U[Z]/2:0,ae=N===yp?H[Z]:U[Z],Se=N===yp?-U[Z]:-H[Z],je=t.elements.arrow,Re=w&&je?q2(je):{width:0,height:0},Fe=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:S6(),Be=Fe[ue],Qe=Fe[fe],Ze=_g(0,H[Z],Re[Z]),st=_?H[Z]/2-K-Ze-Be-$.mainAxis:ae-Ze-Be-$.mainAxis,xt=_?-H[Z]/2+K+Ze+Qe+$.mainAxis:Se+Ze+Qe+$.mainAxis,tn=t.elements.arrow&&Lv(t.elements.arrow),_e=tn?k==="y"?tn.clientTop||0:tn.clientLeft||0:0,Xe=(se=X==null?void 0:X[k])!=null?se:0,tt=pe+st-Xe-_e,ht=pe+xt-Xe,St=_g(w?Mw(ie,tt):ie,pe,w?df(de,ht):de);L[k]=St,Q[k]=St-pe}if(l){var Tt,Gt=k==="x"?ti:ni,_t=k==="x"?as:os,Vt=L[R],Xt=R==="y"?"height":"width",dn=Vt+I[Gt],en=Vt-I[_t],Zn=[ti,ni].indexOf(M)!==-1,kn=(Tt=X==null?void 0:X[R])!=null?Tt:0,Er=Zn?dn:Vt-H[Xt]-U[Xt]-kn+$.altAxis,pt=Zn?Vt+H[Xt]+U[Xt]-kn-$.altAxis:en,Mt=w&&Zn?XY(Er,Vt,pt):_g(w?Er:dn,Vt,w?pt:en);L[R]=Mt,Q[R]=Mt-Vt}t.modifiersData[r]=Q}}const O6={name:"preventOverflow",enabled:!0,phase:"main",fn:DU,requiresIfExists:["offset"]};function TU(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function IU(e){return e===Ni(e)||!ns(e)?J2(e):TU(e)}function EU(e){var t=e.getBoundingClientRect(),n=wp(t.width)/e.offsetWidth||1,r=wp(t.height)/e.offsetHeight||1;return n!==1||r!==1}function xU(e,t,n){n===void 0&&(n=!1);var r=ns(t),a=ns(t)&&EU(t),o=rd(t),i=bp(e,a,n),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((Kl(t)!=="body"||Q2(o))&&(l=IU(t)),ns(t)?(c=bp(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):o&&(c.x=K2(o))),{x:i.left+l.scrollLeft-c.x,y:i.top+l.scrollTop-c.y,width:i.width,height:i.height}}function CU(e){var t=new Map,n=new Set,r=[];e.forEach(function(o){t.set(o.name,o)});function a(o){n.add(o.name);var i=[].concat(o.requires||[],o.requiresIfExists||[]);i.forEach(function(l){if(!n.has(l)){var c=t.get(l);c&&a(c)}}),r.push(o)}return e.forEach(function(o){n.has(o.name)||a(o)}),r}function MU(e){var t=CU(e);return ZY.reduce(function(n,r){return n.concat(t.filter(function(a){return a.phase===r}))},[])}function kU(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function NU(e){var t=e.reduce(function(n,r){var a=n[r.name];return n[r.name]=a?Object.assign({},a,r,{options:Object.assign({},a.options,r.options),data:Object.assign({},a.data,r.data)}):r,n},{});return Object.keys(t).map(function(n){return t[n]})}var xC={placement:"bottom",modifiers:[],strategy:"absolute"};function CC(){for(var e=arguments.length,t=new Array(e),n=0;n({placement:e,modifiers:[{name:"flip",options:{allowedAutoPlacements:t,rootBoundary:"document"}},{name:"preventOverflow",options:{rootBoundary:"document"}}]}),zU=e=>{const n=P.useRef(null),[r,a]=P.useState(null),[o,i]=P.useState(0);let l,c;const f=()=>{if(C.Platform.isMobile){l="right-end",c=["bottom"];return}const g=window.innerWidth-o>280*1.2,y=window.innerWidth-o<280,w=window.innerWidth>280*1.5;if(e.DefaultEditorLocation!=="Bottom"){g?(l="right-end",c=["left-end"]):y&&w?(l="left-end",c=["right-end"]):(l="bottom",c=["bottom"]);return}g?(l="top-end",c=["top-start"]):y&&o>280?(l="top-start",c=["top-end"]):(l="top",c=["top"])};P.useEffect(()=>{e&&f()},[o,e==null?void 0:e.DefaultEditorLocation]);const p=Tb(n.current,r,UU(l,c));return{setPosX:i,popperRef:n,setPopperElement:a,popper:p}},VU=()=>{const e=new Set,t=ot.getState().query.filter,n=ot.getState().query.tag,r=sn.getQueryById(t||"");if(r&&r.querystring){const a=JSON.parse(r.querystring);if(Array.isArray(a))for(const o of a)o.type==="TAG"&&o.value&&o.value.operator==="CONTAIN"&&e.add(o.value.value)}return n&&e.add(n),Array.from(e)},WU=e=>{const{offsetLeft:t,offsetTop:n,offsetHeight:r,offsetWidth:a,selectionEnd:o}=e,i=document.createElement("div"),l=window.getComputedStyle(e);for(const S of l)i.style.setProperty(S,l.getPropertyValue(S));i.style.position="fixed",i.style.visibility="hidden",i.style.whiteSpace="pre-wrap";const f=e.tagName==="INPUT"?e.value.replace(/ /g,"."):e.value;i.textContent=f.substring(0,o||0),e.tagName==="TEXTAREA"&&(i.style.height="auto");const p=document.createElement("span");p.textContent=f.substring(o||0)||".",i.appendChild(p),document.body.appendChild(i);const{offsetLeft:g,offsetTop:y,offsetHeight:w,offsetWidth:T}=p;return document.body.removeChild(i),{x:t+g,y:n+y,h:r+w,w:a+T}},ff=({className:e,editorType:t,destroy:n,modal:r})=>{const{globalState:a,dailyNotesState:{app:o,settings:i,view:l,verifyState:c}}=P.useContext(Lt),[f,p]=Jl(!0),g=P.useRef(f),[y,w]=Co(!0),T=P.useRef(null),S=P.useRef(null),I=P.useRef(a),[M,N]=Co(!1),[_,k]=Co(!1),{setPosX:R,popperRef:L,setPopperElement:H,popper:U}=zU(i),[z]=Co(parseInt(C.moment().format("x"))),$=P.useRef(null),[X,Q]=Co((i==null?void 0:i.EnabledLocationList.length)===1?i==null?void 0:i.EnabledLocationList[0].value:(i==null?void 0:i.MemoSaveLocation)||"DAILY"),se=P.useRef(i.MemoSaveLocation||"DAILY");P.useEffect(()=>{g.current=f},[f]),P.useEffect(()=>{!S.current||!o||!l||(l.registerEvent(o.workspace.on("focus-on-textarea",_e=>{var Xe;(Xe=S.current)==null||Xe.focus(_e==null?void 0:_e.id)})),l.registerEvent(o.workspace.on("blur-on-memos",()=>{var _e;(_e=S.current)==null||_e.blur()})),l.registerEvent(o.workspace.on("send-to-thino",async(_e,Xe)=>{var tt,ht;if(typeof _e=="string")(tt=S.current)==null||tt.insertText(_e+`
-`,Xe.id);else{const St=_e.toPNG(),Tt=new Blob([St],{type:"image/png"}),Gt=new File([Tt],"image.png",{type:"image/png",lastModified:Date.now()});if(!Gt)return;const _t=await de(Gt);_t&&((ht=S.current)==null||ht.insertText(_t+`
-`,Xe.id))}})))},[S,l,o]),P.useEffect(()=>{i&&p(i.DefaultPrefix==="List")},[i==null?void 0:i.DefaultPrefix]),P.useEffect(()=>{if(i){if(i.EnabledLocationList.length===1){Q(i.EnabledLocationList[0].value);return}Q(i.MemoSaveLocation||"DAILY")}},[i==null?void 0:i.MemoSaveLocation,i==null?void 0:i.EnabledLocationList]),P.useEffect(()=>{var tt;if(!i||!$.current)return;const _e=(tt=$g.find(ht=>ht.title===X))==null?void 0:tt.icon;C.setIcon($.current,_e),C.requireApiVersion("1.4.4")&&C.setTooltip($.current,E("Thino Save To: ")+X),se.current=X;const Xe=a.manifest;if(Xe){const ht=o==null?void 0:o.plugins.getPlugin(Xe.id);if(ht){if(ht.settings.MemoSaveLocation===X)return;ht.settings.MemoSaveLocation=X,ht.saveSettings()}}},[X,y]),P.useEffect(()=>{S.current&&i.MemoSaveLocation&&Q(i.MemoSaveLocation)},[$,i]),P.useEffect(()=>{if(!S.current||!i||C.Platform.isDesktop||a.globalEditorShown)return;const _e=i.UseButtonToShowEditor&&i.DefaultEditorLocation==="Bottom";if(C.Platform.isDesktop){w(!0);return}if(t&&t==="inline"){w(!0);return}if(w(C.Platform.isMobile&&!_e),!_e||a.memoListView==="chat")return;const Xe=document.body.find(".memolist-scrollview");Xe&&(Xe.onscroll=()=>{if(a.globalEditorShown)return;if(!a.memoListView&&dt.getState().memoListView==="chat"){Xe.onscroll=null;return}const tt=S.current.getContent();C.Platform.isMobile&&_e&&!tt&&w(!1)})},[a.globalEditorShown,t,S]);const ue=()=>{k(!1)};P.useEffect(()=>{var _e,Xe,tt,ht,St,Tt,Gt,_t,Vt;if(o&&(a.markMemoId||(_e=a.editMemoId)!=null&&_e.trim()&&a.editMemoId!==I.current.editMemoId)){const Xt=o.workspace.getLeavesOfType("thino_view");Xt.length>0&&o.workspace.revealLeaf(Xt[0])}if(a.markMemoId){const Xt=`${E("MARK")}: [@THINO](${a.markMemoId})`;(Xe=S.current)==null||Xe.insertText(Xt),(tt=S.current)==null||tt.focus(),dt.setMarkMemoId("");return}if((ht=a.editMemoId)!=null&&ht.trim()&&a.editMemoId!==I.current.editMemoId){const Xt=be.getMemoById(a.editMemoId);if(Xt)switch(p(Xt.thinoType==="JOURNAL"),i.EditorType){case"memos":(St=S.current)==null||St.setContent(Xt.content.replace(/ \^\S{6}$/,"")||""),(Tt=S.current)==null||Tt.focus();break;case"obsidian":(Gt=S.current)==null||Gt.clear(),(_t=S.current)==null||_t.setContent(Xt.content.replace(/ \^\S{6}$/,"")||""),(Vt=S.current)==null||Vt.focus();break}}I.current=a},[a.markMemoId,a.editMemoId]),P.useEffect(()=>{var _e,Xe,tt;!S.current||M||i.EditorType==="memos"&&((_e=S.current)==null||_e.element.addEventListener("paste",fe),(Xe=S.current)==null||Xe.element.addEventListener("drop",Z),(tt=S.current)==null||tt.element.addEventListener("click",pe),N(!0))},[S.current]);const fe=async _e=>{var Xe;if(_e.clipboardData&&_e.clipboardData.files.length>0){_e.preventDefault();const tt=_e.clipboardData.files;for(const ht of tt){const St=await de(ht);St&&((Xe=S.current)==null||Xe.insertText(St))}}},Z=async _e=>{var Xe;if(_e.dataTransfer&&_e.dataTransfer.files.length>0){_e.preventDefault();const tt=_e.dataTransfer.files;for(const ht of tt){const St=await de(ht);St&&((Xe=S.current)==null||Xe.insertText(St))}}},pe=()=>{var _e;Se(((_e=S.current)==null?void 0:_e.element.value)||"")},ie=async(_e,Xe)=>{var St,Tt,Gt;const tt=_e.ctrlKey||_e.metaKey,ht=_e.altKey;if(_e.key==="Escape"&&a.globalEditorShown&&(dt.setGlobalEditorShown(!1),_e.preventDefault()),tt&&_e.key==="Enter"){_e.preventDefault(),_e.stopPropagation(),Xe?(await K((Tt=S.current)==null?void 0:Tt.getContent()),(Gt=S.current)==null||Gt.clear()):await K((St=S.current)==null?void 0:St.element.value);return}if(ht)for(let _t=0;_t{var _t;Xe||Se(((_t=S.current)==null?void 0:_t.element.value)||"")})},de=P.useCallback(async _e=>{const{type:Xe}=_e;if(Xe.startsWith("image"))try{return`${await Y2.upload(_e)}`}catch(tt){new C.Notice(tt)}},[]),K=async _e=>{if(!_e||_e.trim()===""){new C.Notice(E("Content cannot be empty"));return}const Xe=ft.getState().settings,tt=Xe==null?void 0:Xe.addTagAutomatically,ht=Xe==null?void 0:Xe.addTagWithNewline,St=Xe==null?void 0:Xe.addTagPosition,Gt=(VU()||[]).filter(dn=>!_e.includes(`#${dn}`)),_t=async(dn,en)=>{en=en.replaceAll(" "," "),D0("");try{if(!dn){let kn;switch(se.current){case"CANVAS":kn=await be.createMemoCanvas({text:en,isList:g.current});break;case"MULTI":kn=await be.createMemoMultiFile({content:en,isList:g.current});break;case"DAILY":kn=await be.createMemoDaily(en,g.current);break;case"FILE":kn=await be.createMemoSingleFile({content:en,isList:g.current});break}if(!kn)return;be.pushMemo(kn),(!tt||Gt.length===0)&&ot.clearQuery();const Er=o||ft.getState().app,pt=Er==null?void 0:Er.loadLocalStorage("tokenForSync");kn&&pt&&i.startSync&&setTimeout(async()=>{try{if(se.current!=="DAILY"){const Mt=await T2({content:en,thinoType:"FILE"});await be.updateMemoById(kn.id,Mt,!0)}}catch(Mt){console.error(Mt)}},200);return}const Zn=be.getMemoById(dn);if(Zn&&(Zn.content!==en||Zn.thinoType!==(g.current?"JOURNAL":"TASK-TODO"))){const kn=await be.updateMemo(Zn.id,en,g.current?"JOURNAL":Zn.thinoType.startsWith("TASK")?Zn.thinoType:"TASK-TODO");kn.updatedAt=ut.getDateTimeString(Date.now()),be.editMemo(kn)}dt.setEditMemoId("")}catch(Zn){new C.Notice(Zn.message)}};n&&n();const{editMemoId:Vt}=dt.getState(),Xt=Gt&&Gt.length>0&&tt&&!Vt?St==="Beginning"?`${Gt.map(dn=>`#${dn}`).join(" ")} ${ht?`
+`);return{text:"".concat(c).concat(g).concat(c),caretPosition:bx}}},r._getCurrentTriggerSettings=function(){var c=r.state.currentTrigger;return c?r.props.trigger[c]:null},r._getValuesFromProvider=function(){var c=r.state,f=c.currentTrigger,h=c.actualToken,g=r._getCurrentTriggerSettings();if(!(!f||!g)){var y=g.dataProvider,w=g.component;if(typeof y!="function")throw new Error("Trigger provider has to be a function!");r.setState({dataLoading:!0});var S=y(h);S instanceof Promise||(S=Promise.resolve(S)),S.then(function(D){if(!Array.isArray(D))throw new Error("Trigger provider has to provide an array!");if(typeof w!="function")throw new Error("Component should be defined!");if(f===r.state.currentTrigger){if(!D.length){r._closeAutocomplete();return}r.setState({dataLoading:!1,data:D,component:w})}}).catch(function(D){return Sx(D.message)})}},r._getSuggestions=function(){var c=r.state,f=c.currentTrigger,h=c.data;return!f||!h||h&&!h.length?null:h},r._createRegExp=function(){var c=r.props.trigger;r.tokenRegExp=new RegExp("(".concat(Object.keys(c).sort(function(f,h){return fh?-1:0}).map(function(f){return I0(f)}).join("|"),")((?:(?!\\1)[^\\s])*$)")),r.tokenRegExpEnding=new RegExp("(".concat(Object.keys(c).sort(function(f,h){return fh?-1:0}).map(function(f){return I0(f)}).join("|"),")$"))},r._closeAutocomplete=function(){var c=r.state.currentTrigger;r.escListenerDestroy(),r.setState({data:null,dataLoading:!1,currentTrigger:null},function(){c&&r._onItemHighlightedHandler(null)})},r._cleanUpProps=function(){var c=yY({},r.props),f=["loadingComponent","boundariesElement","containerStyle","minChar","scrollToItem","ref","innerRef","onChange","onCaretPositionChange","className","value","trigger","listStyle","itemStyle","containerStyle","loaderStyle","className","containerClassName","listClassName","itemClassName","loaderClassName","dropdownStyle","dropdownClassName","movePopupAsYouType","textAreaComponent","renderToBody","onItemSelected","onItemHighlighted"];for(var h in c)f.includes(h)&&delete c[h];return c},r._changeHandler=function(c){var f=r.props,h=f.trigger,g=f.onChange,y=f.minChar,w=f.onCaretPositionChange,S=f.movePopupAsYouType,D=r.state,I=D.top,M=D.left,N=c;N||(N=new gY("change",{bubbles:!0}),r.textareaRef.dispatchEvent(N));var R=N.target||r.textareaRef,k=R.selectionEnd,B=R.value;if(r.lastValueBubbledEvent=B,g&&N&&(N.persist&&N.persist(),g(new Proxy(N,{get:function(X,ae,De){return ae==="target"?R:Reflect.get(X,ae,De)}}))),w){var L=r.getCaretPosition();w(L)}r.setState({value:B});var _=function(){var X=hY(R,k),ae=X.top,De=X.left;r.setState({top:ae-r.textareaRef.scrollTop||0,left:De})},V=function(X){r.lastTrigger=k-X,r._closeAutocomplete(),_()};if(k<=r.lastTrigger){var Y=B.slice(0,k),Z=r.tokenRegExp.exec(Y);V(Z?Z[0].length:0)}var Q=B.slice(r.lastTrigger,k),K=r.tokenRegExp.exec(Q),se=K&&K[0],le=K&&K[1]||null,fe=le?le.length-1:0,$=r.tokenRegExpEnding.exec(Q);if($?V($[0].length):r._isAutocompleteOpen()||r._closeAutocomplete(),(!se||se.length<=y+fe)&&(r.state.currentTrigger&&!h[r.state.currentTrigger].allowWhitespace||!r.state.currentTrigger)){r._closeAutocomplete();return}if(le&&h[le].afterWhitespace&&!/\s/.test(B[k-se.length-1])&&B[k-se.length-1]!==void 0){r._closeAutocomplete();return}if(r.state.currentTrigger&&h[r.state.currentTrigger].allowWhitespace){if(K=new RegExp("".concat(I0(r.state.currentTrigger),".*$")).exec(B.slice(0,k)),se=K&&K[0],!se){r._closeAutocomplete();return}le=Object.keys(h).find(function(ce){return ce.slice(0,fe+1)===se.slice(0,fe+1)})||null}var he=se.slice(1);if(le){(S||I===null&&M===null||r.state.currentTrigger!==le)&&_(),r.escListenerInit();var ie=r._getTextToReplace(le);r.setState({selectionEnd:k,currentTrigger:le,textToReplace:ie,actualToken:he},function(){try{r._getValuesFromProvider()}catch(ce){Sx(ce.message)}})}},r._selectHandler=function(c){var f=r.props,h=f.onCaretPositionChange,g=f.onSelect;if(h){var y=r.getCaretPosition();h(y)}g&&(c.persist(),g(c))},r._shouldStayOpen=function(c){var f=c.relatedTarget;return f===null&&(f=document.activeElement),!!(r.dropdownRef&&f instanceof Node&&r.dropdownRef.contains(f))},r._onClick=function(c){var f=r.props.onClick;f&&(c.persist(),f(c)),!r._shouldStayOpen(c)&&r._closeAutocomplete()},r._onBlur=function(c){var f=r.props.onBlur;f&&(c.persist(),f(c)),!r._shouldStayOpen(c)&&r._closeAutocomplete()},r._onScrollHandler=function(){r._closeAutocomplete()},r._onItemHighlightedHandler=function(c){var f=r.props.onItemHighlighted,h=r.state.currentTrigger;if(f)if(typeof f=="function")f({currentTrigger:h,item:c});else throw new Error("`onItemHighlighted` has to be a function")},r._dropdownScroll=function(c){var f=r.props.scrollToItem;if(f){if(f===!0){xY(r.dropdownRef,c);return}if(typeof f!="function"||f.length!==2)throw new Error("`scrollToItem` has to be boolean (true for default implementation) or function with two parameters: container, item.");f(r.dropdownRef,c)}},r._isAutocompleteOpen=function(){var c=r.state,f=c.dataLoading,h=c.currentTrigger,g=r._getSuggestions();return!!((f||g)&&h)},r._textareaRef=function(c){r.props.innerRef&&r.props.innerRef(c),r.textareaRef=c},r.lastTrigger=0,r.escListener=null;var a=r.props,o=a.loadingComponent,i=a.trigger,l=a.value;if(l&&(r.state.value=l),r._createRegExp(),!o)throw new Error("RTA: loadingComponent is not defined");if(!i)throw new Error("RTA: trigger is not defined");return r}return Sb(t,[{key:"componentDidMount",value:function(){uf.startListen(this.textareaRef),this.textareaRef&&this.textareaRef.addEventListener("focus",this._handleCaretChange),this.textareaRef&&this.textareaRef.addEventListener("click",this._handleCaretChange),this.textareaRef&&this.textareaRef.addEventListener("keydown",this._handleCaretChange)}},{key:"componentDidUpdate",value:function(r){var a=r.trigger,o=r.value,i=this.props,l=i.trigger,c=i.value;Object.keys(l).join("")!==Object.keys(a).join("")&&this._createRegExp(),o!==c&&this.lastValueBubbledEvent!==c&&(this.lastTrigger=0,this._changeHandler())}},{key:"componentWillUnmount",value:function(){this.escListenerDestroy(),uf.stopListen(this.textareaRef),this.textareaRef&&this.textareaRef.removeEventListener("focus",this._handleCaretChange),this.textareaRef&&this.textareaRef.removeEventListener("click",this._handleCaretChange),this.textareaRef&&this.textareaRef.removeEventListener("keydown",this._handleCaretChange)}},{key:"render",value:function(){var r=this,a=this.props,o=a.loadingComponent,i=a.style,l=a.className,c=a.listStyle,f=a.itemStyle,h=a.boundariesElement,g=a.movePopupAsYouType,y=a.listClassName,w=a.itemClassName,S=a.dropdownClassName,D=a.dropdownStyle,I=a.containerStyle,M=a.containerClassName,N=a.loaderStyle,R=a.loaderClassName,k=a.textAreaComponent,B=a.renderToBody,L=this.state,_=L.left,V=L.top,Y=L.dataLoading,Z=L.component,Q=L.value,K=L.textToReplace,se=this._isAutocompleteOpen(),le=this._getSuggestions(),fe={},$;return k.component?($=k.component,fe[k.ref]=this._textareaRef):($=k,fe.ref=this._textareaRef),ne.createElement("div",{className:"rta ".concat(Y===!0?"rta--loading":""," ").concat(M||""),style:I},ne.createElement($,Object.assign({},this._cleanUpProps(),{className:"rta__textarea ".concat(l||""),onChange:this._changeHandler,onSelect:this._selectHandler,onScroll:this._onScrollHandler,onClick:this._onClick,onBlur:this._onBlur,value:Q,style:i},fe)),se&&ne.createElement(kY,{innerRef:function(ie){r.dropdownRef=ie},top:V,left:_,style:D,className:S,movePopupAsYouType:g,boundariesElement:h,textareaRef:this.textareaRef,renderToBody:B},le&&Z&&K&&ne.createElement(CY,{values:le,component:Z,style:c,className:y,itemClassName:w,itemStyle:f,getTextToReplace:K,onItemHighlighted:this._onItemHighlightedHandler,onSelect:this._onSelect,dropdownScroll:this._dropdownScroll}),Y&&ne.createElement("div",{className:"rta__loader ".concat(le!==null?"rta__loader--suggestion-data":"rta__loader--empty-suggestion-data"," ").concat(R||""),style:N},ne.createElement(o,{data:le}))))}}],[{key:"getDerivedStateFromProps",value:function(r){var a=r.value;return a==null?null:{value:a}}}]),t}(ne.Component);T6.defaultProps={movePopupAsYouType:!1,value:null,minChar:1,boundariesElement:"body",scrollToItem:!0,textAreaComponent:"textarea",renderToBody:!1};const NY=()=>{const{app:e}=ft.getState(),t=e.metadataCache.getTags();return[...Object.keys(t)].map(n=>n.split("#").pop())},AY=e=>{let t=[];const n=ft.getState().settings;if(n&&(n!=null&&n.UseVaultTags))t=NY();else{const{tags:o}=be.getState();t=o}const r=e.toLowerCase(),a=[];return t.forEach(o=>{o&&o.toLowerCase().contains(r)&&a.push({name:o,char:o})}),a},FY=e=>{const{app:t}=ft.getState(),n=t.vault.getAllLoadedFiles(),r=[];let a;return n.forEach(o=>{e==="["?a="":e.contains("[")&&(a=e.slice(1));const i=a.toLowerCase();o instanceof x.TFile&&["md","png","jpg","canvas","jpeg","gif"].contains(o.extension)&&o.path.toLowerCase().contains(i)&&r.push({name:o.basename,char:o.name,file:o})}),r};var FS=P,OY=function(e){return typeof e=="function"},PY=function(e){var t=FS.useState(e),n=t[0],r=t[1],a=FS.useRef(n),o=FS.useCallback(function(i){a.current=OY(i)?i(a.current):i,r(a.current)},[]);return[n,o,a]},jY=PY;const xo=qt(jY);function LY(e){return e.containerEl.matches(".memos-list-view")}function OS(){}function RY(e){const n=e.app.workspace.getLeavesOfType("thino_view")[0];return{app:e.app,showSearch:OS,toggleMode:OS,onMarkdownScroll:OS,getMode:()=>"source",getViewType:()=>"thino_view",id:(n==null?void 0:n.id)||ut.randomId(6),scroll:0,editMode:null,get file(){var r;return((r=n==null?void 0:n.view)==null?void 0:r.file)||null},get path(){var r,a;return((a=(r=n==null?void 0:n.view)==null?void 0:r.file)==null?void 0:a.path)||""}}}const _Y=(e,t)=>{const{dailyNotesState:{app:n,plugin:r,view:a,dailyNotes:o}}=P.useContext(Lt),[i,l]=P.useState(null),[c,f]=P.useState(!1),[h,g]=P.useState(""),[y,w]=P.useState(null),S=P.useRef(x.debounce((_,V,Y)=>{HY(_,V,Y)},100)),D=P.useRef();P.useEffect(()=>{var _;if(!y){if(!o&&!(n&&window.app)){const V=(_=n||window.app)==null?void 0:_.vault.getMarkdownFiles();w(V[0]);return}for(const V in o)if(o[V]instanceof x.TFile){w(o[V]);break}}},[o]),P.useEffect(()=>{var K;if(!(r!=null&&r.MarkdownEditor)||!e)return;class _ extends r.MarkdownEditor{updateBottomPadding(){}onUpdate(le,fe){super.onUpdate(le,fe),M&&M(this.get())}}const V=RY(r),Y=r.addChild(new _(n,e,V));Y&&!t&&a&&dt.setInstance(`${(K=a.leaf)==null?void 0:K.id}`,Y),V.editMode=Y,Y.owner.editor=Y.editor;const Z=BY(n,t?"modal":"view");Y.set&&Y.set(Z||"",!0),n.workspace.trigger("thino-editor-created",e,Y.editor);const Q=Y.cm;return D.current=Q,f(!0),l(Y),()=>{f(!1),i==null||i.destroy(),r.removeChild(Y),D.current=null}},[e,r]),P.useEffect(()=>{!i||!n||S.current(h,n,t?"modal":"view")},[h,n]);const I=()=>{i&&i.toggleSource()},M=x.debounce(_=>N(_),500,!0),N=_=>{g(_)};return{instance:i,value:h,set:_=>{try{i&&((i==null?void 0:i.editor).replaceSelection(_),g(_))}catch(V){console.error(V)}},get:()=>i?i.get():"",append:(_,V)=>{if(!i||V&&V!==i.owner.id)return;const Z=(i.get()||"")+_;(i==null?void 0:i.editor).replaceSelection(_),g(Z)},clear:()=>{i&&(i.clear(),g(""))},toggleSource:I}};function I6(e,t){return`thinoEditorContentCache:${e}:${t||"view"}`}function BY(e,t){try{const n=I6(e==null?void 0:e.appId,t);return la.get([n])[n]||""}catch(n){return console.error(n),""}}function HY(e,t,n){try{const r=I6(t==null?void 0:t.appId,n);la.set({[r]:e})}catch(r){console.error(r)}}function YY(e,t){return{line:e.line,ch:e.ch+t}}const Dx=({entity:{name:e,char:t,file:n}})=>v.jsx("div",{children:`${t}`}),UY=({data:e})=>v.jsx("div",{children:"Loading"});let Al;const zY=P.forwardRef((e,t)=>{var Re;const{globalState:{useTinyUndoHistoryCache:n,globalEditorShown:r,memoListView:a},dailyNotesState:{settings:o,app:i}}=P.useContext(Lt),{SaveMemoButtonLabel:l,SaveMemoButtonIcon:c}=o,{className:f,inputerType:h,initialContent:g,placeholder:y,showConfirmBtn:w,showCancelBtn:S,onConfirmBtnClick:D,onCancelBtnClick:I,onContentChange:M}=e,N=P.useRef(null),R=P.useRef(null),k=P.useRef(null),B=dY(),{instance:L,value:_,set:V,get:Y,append:Z,clear:Q,toggleSource:K}=_Y(R.current,e.modal),[,se,le]=xo(0),[fe,$]=xo(!1);P.useEffect(()=>{var Fe,Be;if(o&&o.FocusOnEditor)switch(h){case"minimal":case"memos":(Fe=N.current)==null||Fe.focus();break;case"obsidian":L&&((Be=L.editor)==null||Be.focus())}},[o,L]),P.useEffect(()=>{if(!i)return;const Fe=i.workspace.getLeavesOfType(lo);let Be,Xe;Fe.length>0?(Xe=Fe[0].view.containerEl,Be=Xe.offsetHeight):(Xe=document,Be=window.outerHeight),se(Be)},[i]),P.useEffect(()=>{!N.current||h==="obsidian"||g&&(N.current.value=g,B())},[]),P.useEffect(()=>{var Fe;if(h!=="obsidian")if(n){if(!N.current)return;const{tinyUndoActionsCache:Be,tinyUndoIndexCache:Xe}=la.get(["tinyUndoActionsCache","tinyUndoIndexCache"]);return k.current=new cY(N.current,{interval:5e3,initialActions:Be,initialIndex:Xe}),k.current.subscribe((Ze,st)=>{la.set({tinyUndoActionsCache:Ze,tinyUndoIndexCache:st})}),()=>{var Ze;(Ze=k.current)==null||Ze.destroy()}}else(Fe=k.current)==null||Fe.destroy(),k.current=null,la.remove(["tinyUndoActionsCache","tinyUndoIndexCache"])},[n]),P.useEffect(()=>{N.current&&(N.current.style.height="auto",N.current.style.height=(N.current.scrollHeight??0)+"px")},[(Re=N.current)==null?void 0:Re.value]),P.useImperativeHandle(t,()=>({element:N.current,blur:()=>{var Fe,Be;switch(h){case"minimal":case"memos":(Fe=N.current)==null||Fe.blur();break;case"obsidian":L&&((Be=L.editor)==null||Be.blur())}},focus:Fe=>{var Be,Xe,Ze,st,Ct;switch(h){case"minimal":case"memos":(Be=N.current)==null||Be.focus();break;case"obsidian":if(L){if(Fe&&Fe!==((st=(Ze=(Xe=L==null?void 0:L.owner)==null?void 0:Xe.view)==null?void 0:Ze.leaf)==null?void 0:st.id))return;(Ct=L.editor)==null||Ct.focus()}}},insertTag:Fe=>{var Be,Xe,Ze;switch(h){case"minimal":case"memos":{if(!N.current)return;const st=N.current.value;N.current.value=st.slice(0,N.current.selectionStart)+"# "+st.slice(N.current.selectionStart),M(N.current.value),B();break}case"obsidian":if(Fe&&Fe!==((Ze=(Xe=(Be=L==null?void 0:L.owner)==null?void 0:Be.view)==null?void 0:Xe.leaf)==null?void 0:Ze.id))return;if(L){const st=L.editor,Ct=st.getCursor("from");st.replaceRange("#",Ct),st.setSelection(YY(Ct,1))}break}},insertText:(Fe,Be)=>{switch(h){case"minimal":case"memos":{if(!N.current)return;const Xe=N.current.value;N.current.value=Xe.slice(0,N.current.selectionStart)+Fe+Xe.slice(N.current.selectionStart),M(N.current.value),B()}break;case"obsidian":L&&Z(Fe,Be);break}},setContent:Fe=>{switch(h){case"minimal":case"memos":N.current&&(N.current.value=Fe,M(N.current.value),B());break;case"obsidian":L&&V(Fe);break}},getContent:()=>{switch(h){case"minimal":case"memos":return N.current?N.current.value:"";case"obsidian":return Y()}},toggleSource:()=>{switch(h){case"minimal":case"memos":break;case"obsidian":K();break}},clear:()=>{switch(h){case"minimal":case"memos":N.current&&(N.current.value="",M(N.current.value),B());break;case"obsidian":Q();break}}}),[L,h]);const he=Fe=>{if(!N.current)return;const{fileManager:Be}=Le.getState().dailyNotesState.app;if(Fe.currentTrigger==="#"){const Xe=N.current.value;let Ze;Al!=null?Ze=Al.length:Ze=0;let st=N.current.selectionStart;for(let Ct=0;Ct{var Fe;M(((Fe=N.current)==null?void 0:Fe.value)||""),B()},[]),ce=()=>{var Fe;switch(h){case"minimal":case"memos":if(!N.current)return;N.current.value=ae(),D(N.current.value),N.current.value="",B(),(Fe=k.current)==null||Fe.resetState();break;case"obsidian":D(Y()),Q(),B();break}},X=P.useCallback(()=>{switch(h){case"minimal":case"memos":N.current&&(N.current.value="",M(N.current.value),B());break;case"obsidian":Q();break}I()},[h,L,N]),ae=()=>la.get(["thinoEditorContentCache"]).thinoEditorContentCache||"",De=()=>{if(N.current)return N.current.value=ae(),N.current.value},je=Fe=>{switch(Fe){case"memos":return v.jsx(T6,{className:`common-editor-inputer scroll ${fe?" editing":""}`,loadingComponent:UY,placeholder:y,movePopupAsYouType:!0,value:De(),innerRef:Be=>{N.current=Be},onFocus:()=>{$(!0)},onBlur:()=>{$(!1)},onInput:ie,style:{maxHeight:`${le.current>400?le.current-400:100}px`},dropdownStyle:{minWidth:180,maxHeight:250,overflowY:"auto"},minChar:0,onItemSelected:he,scrollToItem:!0,trigger:{"#":{dataProvider:Be=>(Al=Be,AY(Be).map(({name:Xe,char:Ze})=>({name:Xe,char:Ze}))),component:Dx,afterWhitespace:!0,output:Be=>Be.char},"[[":{dataProvider:Be=>(Al=Be,FY(Be).slice(0,10).map(({name:Xe,char:Ze,file:st})=>({name:Xe,char:Ze,file:st}))),component:Dx,afterWhitespace:!0,output:Be=>Be.char}}});case"minimal":return v.jsx("textarea",{style:{minHeight:48},className:"common-editor-inputer scroll",rows:1,placeholder:y,ref:N,onInput:ie});case"obsidian":return v.jsx("div",{className:"common-editor-inputer common-editor-mod-cm6",onClick:()=>{var Be;(Be=L==null?void 0:L.editor)==null||Be.focus()},ref:R});default:return v.jsx("div",{className:"common-editor-inputer common-editor-mod-cm6",ref:R})}};return v.jsxs("div",{className:"common-editor-wrapper "+f,children:[je(h),v.jsxs("div",{className:"common-tools-wrapper",children:[v.jsx("div",{className:"common-tools-container",children:v.jsx(ts,{when:e.tools!==void 0,children:e.tools})}),v.jsxs("div",{className:"btns-container",children:[v.jsx(ts,{when:S,children:v.jsx("button",{className:"action-btn cancel-btn",onClick:()=>{o&&o.DefaultEditorLocation==="Top"&&!r&&X()},onPointerDown:()=>{(o&&o.DefaultEditorLocation==="Bottom"||r)&&X()},children:at.getState().pathname==="/"&&a==="chat"&&((o==null?void 0:o.chatViewStyle)==="fluent"||(o==null?void 0:o.chatViewStyle)==="inline")?"":E("CANCEL EDIT")})}),v.jsx(ts,{when:w,children:v.jsxs("button",{title:"Ctrl/Cmd + Enter to save thino",className:"action-btn confirm-btn",onClick:()=>{o&&o.DefaultEditorLocation==="Top"&&!r&&ce()},onPointerDown:()=>{(o&&o.DefaultEditorLocation==="Bottom"||r)&&ce()},children:[a==="chat"&&((o==null?void 0:o.chatViewStyle)==="fluent"||(o==null?void 0:o.chatViewStyle)==="inline")?"":l,v.jsx("span",{className:"icon-text",children:null})]})})]})]})]})}),VY=typeof window<"u"?P.useLayoutEffect:P.useEffect;function WY(e,t,n,r){const a=P.useRef(t);VY(()=>{a.current=t},[t]),P.useEffect(()=>{const o=(n==null?void 0:n.current)||window;if(!(o&&o.addEventListener))return;const i=l=>{a.current(l)};return o.addEventListener(e,i,r),()=>{o.removeEventListener(e,i,r)}},[e,n,r])}function Rv(e,t,n="mousedown"){WY(n,r=>{const a=r.target;if(!a||!a.isConnected||a.closest(".suggestion-container")||a.closest(".menu"))return;(Array.isArray(e)?e.every(i=>i.current&&!i.current.contains(a)):e.current&&!e.current.contains(a))&&t(r)})}const E6=e=>{const{year:t,handleYearChange:n}=e,[r,a]=P.useState([]),[o,i]=P.useState(t),l=P.useRef(null),c=P.useRef(null),[f,h]=ne.useState(!1),g=ne.useRef(null);Rv(g,()=>{h(!1)}),P.useEffect(()=>{l.current&&x.setIcon(l.current,"chevron-left"),c.current&&x.setIcon(c.current,"chevron-right")},[l,c,f]),P.useEffect(()=>{w(o)},[t]);const w=S=>{const D=parseInt(S),I=D-D%10,M=[];for(let N=0;N<10;N++)M.push(`${I+N}`);a(M)};return v.jsxs(v.Fragment,{children:[v.jsxs("span",{className:"btn year-btn",onClick:()=>{h(!f)},children:[v.jsx("span",{children:t}),v.jsx("span",{children:E("year")})]}),f&&v.jsxs("div",{ref:g,className:"year-picker-wrapper",children:[v.jsxs("div",{className:"year-picker-header",children:[v.jsxs("div",{className:"year-picker-header-title",children:[o," "+(E("year")||"")]}),v.jsxs("div",{className:"year-picker-header-btns",children:[v.jsx("span",{className:"btn",ref:l,onClick:()=>{const S=parseInt(o)-10;i(S.toString()),w(S.toString())}}),v.jsx("span",{className:"btn",ref:c,onClick:()=>{const S=parseInt(o)+10;i(S.toString()),w(S.toString())}})]})]}),v.jsx("div",{className:"year-picker-body",children:v.jsx("div",{className:"year-picker-body-list",children:r.map(S=>v.jsx("div",{className:`year-picker-body-item ${S===o?"selected":""}`,onClick:()=>{i(S),n(S),h(!1)},children:S},S))})})]})]})},C6=e=>{const{month:t,handleMonthChange:n}=e,[r,a]=P.useState([]),[o,i]=P.useState((parseInt(t)+1).toString()),[l,c]=ne.useState(!1),f=ne.useRef(null);Rv(f,()=>{c(!1)}),P.useEffect(()=>{g()},[t]);const g=()=>{const y=[];for(let w=1;w<=12;w++)y.push(`${w}`);a(y)};return v.jsxs(v.Fragment,{children:[v.jsxs("span",{className:"btn month-btn",onClick:()=>{c(!l)},children:[v.jsxs("span",{children:[E("monthsShort")[parseInt(t)]||parseInt(t)+1," "]}),v.jsx("span",{children:E("month")||""})]}),l&&v.jsxs("div",{ref:f,className:"month-picker-wrapper",children:[v.jsxs("div",{className:"month-picker-header",children:[v.jsxs("div",{className:"month-picker-header-title",children:[o," "+(E("month")||"")]}),v.jsx("div",{className:"month-picker-header-btns"})]}),v.jsx("div",{className:"month-picker-body",children:v.jsx("div",{className:"month-picker-body-list",children:r.map(y=>v.jsx("div",{className:`month-picker-body-item ${y===o?"selected":""}`,onClick:()=>{i(y),n(y),c(!1)},children:y},y))})})]})]})},Ib=e=>{const{className:t,datestamp:n,handleDateStampChange:r}=e,[a,o]=P.useState(wg(n)),[i,l]=P.useState(n);P.useEffect(()=>{o(wg(n))},[n]);const c=new Date(a),f=c.getDay(),h=[];for(let S=0;S{r(D,S.nativeEvent),l(D)},w=S=>{const D=c.getFullYear(),I=c.getMonth()+1;let M=0;I===1&&S===-1?M=new Date(`${D-1}/12/1`).getTime():I===12&&S===1?M=new Date(`${D+1}/1/1`).getTime():M=new Date(`${D}/${I+S}/1`).getTime(),o(wg(M))};return v.jsxs("div",{className:`date-picker-wrapper ${t}`,children:[v.jsxs("div",{className:"date-picker-header",children:[v.jsx("span",{ref:S=>{S&&x.setIcon(S,"chevron-left")},className:"btn btn-text",onClick:()=>w(-1)}),v.jsxs("span",{className:"normal-text",children:[v.jsx(E6,{year:c.getFullYear().toString(),handleYearChange:S=>{o(wg(new Date(`${S}/${c.getMonth()+1}/1`).getTime()))}}),v.jsx(C6,{month:c.getMonth().toString(),handleMonthChange:S=>{o(wg(new Date(`${c.getFullYear()}/${parseInt(S)}/1`).getTime()))}})]}),v.jsx("span",{ref:S=>{S&&x.setIcon(S,"chevron-right")},className:"btn btn-text",onClick:()=>w(1)})]}),v.jsxs("div",{className:"date-picker-day-container",children:[v.jsx("div",{className:"date-picker-day-header",children:E("weekDaysShort").map(S=>v.jsx("span",{className:"day-item",children:S},S))}),v.jsx("div",{className:"date-picker-day-content",children:h.map(S=>S.date===0?v.jsx("span",{className:"day-item null",children:""},S.datestamp):v.jsx("span",{className:`day-item ${S.datestamp===n?"current":""} ${S.datestamp===i?"selected":""}`,onClick:D=>y(D,S.datestamp),children:v.jsx("span",{className:"day-item-text",children:S.date})},S.datestamp))})]})]})};function $Y(e){const t=new Date(e),n=new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`);return((n.getMonth()===11?new Date(`${n.getFullYear()+1}/1/1`):new Date(`${n.getFullYear()}/${n.getMonth()+2}/1`)).getTime()-n.getTime())/ei}function wg(e){const t=new Date(e);return new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`).getTime()}var Tx=function(t){return t.reduce(function(n,r){var a=r[0],o=r[1];return n[a]=o,n},{})},Ix=typeof window<"u"&&window.document&&window.document.createElement?P.useLayoutEffect:P.useEffect,ti="top",as="bottom",os="right",ni="left",J2="auto",_v=[ti,as,os,ni],wp="start",Qg="end",ZY="clippingParents",x6="viewport",bg="popper",qY="reference",Ex=_v.reduce(function(e,t){return e.concat([t+"-"+wp,t+"-"+Qg])},[]),K2=[].concat(_v,[J2]).reduce(function(e,t){return e.concat([t,t+"-"+wp,t+"-"+Qg])},[]),GY="beforeRead",JY="read",KY="afterRead",QY="beforeMain",XY="main",eU="afterMain",tU="beforeWrite",nU="write",rU="afterWrite",aU=[GY,JY,KY,QY,XY,eU,tU,nU,rU];function Ql(e){return e?(e.nodeName||"").toLowerCase():null}function Ni(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function yf(e){var t=Ni(e).Element;return e instanceof t||e instanceof Element}function ns(e){var t=Ni(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function Q2(e){if(typeof ShadowRoot>"u")return!1;var t=Ni(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function oU(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var r=t.styles[n]||{},a=t.attributes[n]||{},o=t.elements[n];!ns(o)||!Ql(o)||(Object.assign(o.style,r),Object.keys(a).forEach(function(i){var l=a[i];l===!1?o.removeAttribute(i):o.setAttribute(i,l===!0?"":l)}))})}function iU(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(r){var a=t.elements[r],o=t.attributes[r]||{},i=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:n[r]),l=i.reduce(function(c,f){return c[f]="",c},{});!ns(a)||!Ql(a)||(Object.assign(a.style,l),Object.keys(o).forEach(function(c){a.removeAttribute(c)}))})}}const sU={name:"applyStyles",enabled:!0,phase:"write",fn:oU,effect:iU,requires:["computeStyles"]};function ql(e){return e.split("-")[0]}var ff=Math.max,Aw=Math.min,bp=Math.round;function TT(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function M6(){return!/^((?!chrome|android).)*safari/i.test(TT())}function Sp(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),a=1,o=1;t&&ns(e)&&(a=e.offsetWidth>0&&bp(r.width)/e.offsetWidth||1,o=e.offsetHeight>0&&bp(r.height)/e.offsetHeight||1);var i=yf(e)?Ni(e):window,l=i.visualViewport,c=!M6()&&n,f=(r.left+(c&&l?l.offsetLeft:0))/a,h=(r.top+(c&&l?l.offsetTop:0))/o,g=r.width/a,y=r.height/o;return{width:g,height:y,top:h,right:f+g,bottom:h+y,left:f,x:f,y:h}}function X2(e){var t=Sp(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function k6(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Q2(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Uu(e){return Ni(e).getComputedStyle(e)}function lU(e){return["table","td","th"].indexOf(Ql(e))>=0}function ad(e){return((yf(e)?e.ownerDocument:e.document)||window.document).documentElement}function Eb(e){return Ql(e)==="html"?e:e.assignedSlot||e.parentNode||(Q2(e)?e.host:null)||ad(e)}function Cx(e){return!ns(e)||Uu(e).position==="fixed"?null:e.offsetParent}function uU(e){var t=/firefox/i.test(TT()),n=/Trident/i.test(TT());if(n&&ns(e)){var r=Uu(e);if(r.position==="fixed")return null}var a=Eb(e);for(Q2(a)&&(a=a.host);ns(a)&&["html","body"].indexOf(Ql(a))<0;){var o=Uu(a);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return a;a=a.parentNode}return null}function Bv(e){for(var t=Ni(e),n=Cx(e);n&&lU(n)&&Uu(n).position==="static";)n=Cx(n);return n&&(Ql(n)==="html"||Ql(n)==="body"&&Uu(n).position==="static")?t:n||uU(e)||t}function eI(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function Yg(e,t,n){return ff(e,Aw(t,n))}function cU(e,t,n){var r=Yg(e,t,n);return r>n?n:r}function N6(){return{top:0,right:0,bottom:0,left:0}}function A6(e){return Object.assign({},N6(),e)}function F6(e,t){return t.reduce(function(n,r){return n[r]=e,n},{})}var dU=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,A6(typeof t!="number"?t:F6(t,_v))};function fU(e){var t,n=e.state,r=e.name,a=e.options,o=n.elements.arrow,i=n.modifiersData.popperOffsets,l=ql(n.placement),c=eI(l),f=[ni,os].indexOf(l)>=0,h=f?"height":"width";if(!(!o||!i)){var g=dU(a.padding,n),y=X2(o),w=c==="y"?ti:ni,S=c==="y"?as:os,D=n.rects.reference[h]+n.rects.reference[c]-i[c]-n.rects.popper[h],I=i[c]-n.rects.reference[c],M=Bv(o),N=M?c==="y"?M.clientHeight||0:M.clientWidth||0:0,R=D/2-I/2,k=g[w],B=N-y[h]-g[S],L=N/2-y[h]/2+R,_=Yg(k,L,B),V=c;n.modifiersData[r]=(t={},t[V]=_,t.centerOffset=_-L,t)}}function hU(e){var t=e.state,n=e.options,r=n.element,a=r===void 0?"[data-popper-arrow]":r;a!=null&&(typeof a=="string"&&(a=t.elements.popper.querySelector(a),!a)||k6(t.elements.popper,a)&&(t.elements.arrow=a))}const O6={name:"arrow",enabled:!0,phase:"main",fn:fU,effect:hU,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Dp(e){return e.split("-")[1]}var pU={top:"auto",right:"auto",bottom:"auto",left:"auto"};function mU(e,t){var n=e.x,r=e.y,a=t.devicePixelRatio||1;return{x:bp(n*a)/a||0,y:bp(r*a)/a||0}}function xx(e){var t,n=e.popper,r=e.popperRect,a=e.placement,o=e.variation,i=e.offsets,l=e.position,c=e.gpuAcceleration,f=e.adaptive,h=e.roundOffsets,g=e.isFixed,y=i.x,w=y===void 0?0:y,S=i.y,D=S===void 0?0:S,I=typeof h=="function"?h({x:w,y:D}):{x:w,y:D};w=I.x,D=I.y;var M=i.hasOwnProperty("x"),N=i.hasOwnProperty("y"),R=ni,k=ti,B=window;if(f){var L=Bv(n),_="clientHeight",V="clientWidth";if(L===Ni(n)&&(L=ad(n),Uu(L).position!=="static"&&l==="absolute"&&(_="scrollHeight",V="scrollWidth")),a===ti||(a===ni||a===os)&&o===Qg){k=as;var Y=g&&L===B&&B.visualViewport?B.visualViewport.height:L[_];D-=Y-r.height,D*=c?1:-1}if(a===ni||(a===ti||a===as)&&o===Qg){R=os;var Z=g&&L===B&&B.visualViewport?B.visualViewport.width:L[V];w-=Z-r.width,w*=c?1:-1}}var Q=Object.assign({position:l},f&&pU),K=h===!0?mU({x:w,y:D},Ni(n)):{x:w,y:D};if(w=K.x,D=K.y,c){var se;return Object.assign({},Q,(se={},se[k]=N?"0":"",se[R]=M?"0":"",se.transform=(B.devicePixelRatio||1)<=1?"translate("+w+"px, "+D+"px)":"translate3d("+w+"px, "+D+"px, 0)",se))}return Object.assign({},Q,(t={},t[k]=N?D+"px":"",t[R]=M?w+"px":"",t.transform="",t))}function gU(e){var t=e.state,n=e.options,r=n.gpuAcceleration,a=r===void 0?!0:r,o=n.adaptive,i=o===void 0?!0:o,l=n.roundOffsets,c=l===void 0?!0:l,f={placement:ql(t.placement),variation:Dp(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:a,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,xx(Object.assign({},f,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:i,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,xx(Object.assign({},f,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const P6={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:gU,data:{}};var E0={passive:!0};function vU(e){var t=e.state,n=e.instance,r=e.options,a=r.scroll,o=a===void 0?!0:a,i=r.resize,l=i===void 0?!0:i,c=Ni(t.elements.popper),f=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&f.forEach(function(h){h.addEventListener("scroll",n.update,E0)}),l&&c.addEventListener("resize",n.update,E0),function(){o&&f.forEach(function(h){h.removeEventListener("scroll",n.update,E0)}),l&&c.removeEventListener("resize",n.update,E0)}}const j6={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:vU,data:{}};var yU={left:"right",right:"left",bottom:"top",top:"bottom"};function aw(e){return e.replace(/left|right|bottom|top/g,function(t){return yU[t]})}var wU={start:"end",end:"start"};function Mx(e){return e.replace(/start|end/g,function(t){return wU[t]})}function tI(e){var t=Ni(e),n=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:n,scrollTop:r}}function nI(e){return Sp(ad(e)).left+tI(e).scrollLeft}function bU(e,t){var n=Ni(e),r=ad(e),a=n.visualViewport,o=r.clientWidth,i=r.clientHeight,l=0,c=0;if(a){o=a.width,i=a.height;var f=M6();(f||!f&&t==="fixed")&&(l=a.offsetLeft,c=a.offsetTop)}return{width:o,height:i,x:l+nI(e),y:c}}function SU(e){var t,n=ad(e),r=tI(e),a=(t=e.ownerDocument)==null?void 0:t.body,o=ff(n.scrollWidth,n.clientWidth,a?a.scrollWidth:0,a?a.clientWidth:0),i=ff(n.scrollHeight,n.clientHeight,a?a.scrollHeight:0,a?a.clientHeight:0),l=-r.scrollLeft+nI(e),c=-r.scrollTop;return Uu(a||n).direction==="rtl"&&(l+=ff(n.clientWidth,a?a.clientWidth:0)-o),{width:o,height:i,x:l,y:c}}function rI(e){var t=Uu(e),n=t.overflow,r=t.overflowX,a=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+a+r)}function L6(e){return["html","body","#document"].indexOf(Ql(e))>=0?e.ownerDocument.body:ns(e)&&rI(e)?e:L6(Eb(e))}function Ug(e,t){var n;t===void 0&&(t=[]);var r=L6(e),a=r===((n=e.ownerDocument)==null?void 0:n.body),o=Ni(r),i=a?[o].concat(o.visualViewport||[],rI(r)?r:[]):r,l=t.concat(i);return a?l:l.concat(Ug(Eb(i)))}function IT(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function DU(e,t){var n=Sp(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function kx(e,t,n){return t===x6?IT(bU(e,n)):yf(t)?DU(t,n):IT(SU(ad(e)))}function TU(e){var t=Ug(Eb(e)),n=["absolute","fixed"].indexOf(Uu(e).position)>=0,r=n&&ns(e)?Bv(e):e;return yf(r)?t.filter(function(a){return yf(a)&&k6(a,r)&&Ql(a)!=="body"}):[]}function IU(e,t,n,r){var a=t==="clippingParents"?TU(e):[].concat(t),o=[].concat(a,[n]),i=o[0],l=o.reduce(function(c,f){var h=kx(e,f,r);return c.top=ff(h.top,c.top),c.right=Aw(h.right,c.right),c.bottom=Aw(h.bottom,c.bottom),c.left=ff(h.left,c.left),c},kx(e,i,r));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function R6(e){var t=e.reference,n=e.element,r=e.placement,a=r?ql(r):null,o=r?Dp(r):null,i=t.x+t.width/2-n.width/2,l=t.y+t.height/2-n.height/2,c;switch(a){case ti:c={x:i,y:t.y-n.height};break;case as:c={x:i,y:t.y+t.height};break;case os:c={x:t.x+t.width,y:l};break;case ni:c={x:t.x-n.width,y:l};break;default:c={x:t.x,y:t.y}}var f=a?eI(a):null;if(f!=null){var h=f==="y"?"height":"width";switch(o){case wp:c[f]=c[f]-(t[h]/2-n[h]/2);break;case Qg:c[f]=c[f]+(t[h]/2-n[h]/2);break}}return c}function Xg(e,t){t===void 0&&(t={});var n=t,r=n.placement,a=r===void 0?e.placement:r,o=n.strategy,i=o===void 0?e.strategy:o,l=n.boundary,c=l===void 0?ZY:l,f=n.rootBoundary,h=f===void 0?x6:f,g=n.elementContext,y=g===void 0?bg:g,w=n.altBoundary,S=w===void 0?!1:w,D=n.padding,I=D===void 0?0:D,M=A6(typeof I!="number"?I:F6(I,_v)),N=y===bg?qY:bg,R=e.rects.popper,k=e.elements[S?N:y],B=IU(yf(k)?k:k.contextElement||ad(e.elements.popper),c,h,i),L=Sp(e.elements.reference),_=R6({reference:L,element:R,strategy:"absolute",placement:a}),V=IT(Object.assign({},R,_)),Y=y===bg?V:L,Z={top:B.top-Y.top+M.top,bottom:Y.bottom-B.bottom+M.bottom,left:B.left-Y.left+M.left,right:Y.right-B.right+M.right},Q=e.modifiersData.offset;if(y===bg&&Q){var K=Q[a];Object.keys(Z).forEach(function(se){var le=[os,as].indexOf(se)>=0?1:-1,fe=[ti,as].indexOf(se)>=0?"y":"x";Z[se]+=K[fe]*le})}return Z}function EU(e,t){t===void 0&&(t={});var n=t,r=n.placement,a=n.boundary,o=n.rootBoundary,i=n.padding,l=n.flipVariations,c=n.allowedAutoPlacements,f=c===void 0?K2:c,h=Dp(r),g=h?l?Ex:Ex.filter(function(S){return Dp(S)===h}):_v,y=g.filter(function(S){return f.indexOf(S)>=0});y.length===0&&(y=g);var w=y.reduce(function(S,D){return S[D]=Xg(e,{placement:D,boundary:a,rootBoundary:o,padding:i})[ql(D)],S},{});return Object.keys(w).sort(function(S,D){return w[S]-w[D]})}function CU(e){if(ql(e)===J2)return[];var t=aw(e);return[Mx(e),t,Mx(t)]}function xU(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var a=n.mainAxis,o=a===void 0?!0:a,i=n.altAxis,l=i===void 0?!0:i,c=n.fallbackPlacements,f=n.padding,h=n.boundary,g=n.rootBoundary,y=n.altBoundary,w=n.flipVariations,S=w===void 0?!0:w,D=n.allowedAutoPlacements,I=t.options.placement,M=ql(I),N=M===I,R=c||(N||!S?[aw(I)]:CU(I)),k=[I].concat(R).reduce(function(Re,Fe){return Re.concat(ql(Fe)===J2?EU(t,{placement:Fe,boundary:h,rootBoundary:g,padding:f,flipVariations:S,allowedAutoPlacements:D}):Fe)},[]),B=t.rects.reference,L=t.rects.popper,_=new Map,V=!0,Y=k[0],Z=0;Z=0,fe=le?"width":"height",$=Xg(t,{placement:Q,boundary:h,rootBoundary:g,altBoundary:y,padding:f}),he=le?se?os:ni:se?as:ti;B[fe]>L[fe]&&(he=aw(he));var ie=aw(he),ce=[];if(o&&ce.push($[K]<=0),l&&ce.push($[he]<=0,$[ie]<=0),ce.every(function(Re){return Re})){Y=Q,V=!1;break}_.set(Q,ce)}if(V)for(var X=S?3:1,ae=function(Fe){var Be=k.find(function(Xe){var Ze=_.get(Xe);if(Ze)return Ze.slice(0,Fe).every(function(st){return st})});if(Be)return Y=Be,"break"},De=X;De>0;De--){var je=ae(De);if(je==="break")break}t.placement!==Y&&(t.modifiersData[r]._skip=!0,t.placement=Y,t.reset=!0)}}const _6={name:"flip",enabled:!0,phase:"main",fn:xU,requiresIfExists:["offset"],data:{_skip:!1}};function Nx(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Ax(e){return[ti,os,as,ni].some(function(t){return e[t]>=0})}function MU(e){var t=e.state,n=e.name,r=t.rects.reference,a=t.rects.popper,o=t.modifiersData.preventOverflow,i=Xg(t,{elementContext:"reference"}),l=Xg(t,{altBoundary:!0}),c=Nx(i,r),f=Nx(l,a,o),h=Ax(c),g=Ax(f);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:f,isReferenceHidden:h,hasPopperEscaped:g},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":h,"data-popper-escaped":g})}const B6={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:MU};function kU(e,t,n){var r=ql(e),a=[ni,ti].indexOf(r)>=0?-1:1,o=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,i=o[0],l=o[1];return i=i||0,l=(l||0)*a,[ni,os].indexOf(r)>=0?{x:l,y:i}:{x:i,y:l}}function NU(e){var t=e.state,n=e.options,r=e.name,a=n.offset,o=a===void 0?[0,0]:a,i=K2.reduce(function(h,g){return h[g]=kU(g,t.rects,o),h},{}),l=i[t.placement],c=l.x,f=l.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=f),t.modifiersData[r]=i}const H6={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:NU};function AU(e){var t=e.state,n=e.name;t.modifiersData[n]=R6({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const Y6={name:"popperOffsets",enabled:!0,phase:"read",fn:AU,data:{}};function FU(e){return e==="x"?"y":"x"}function OU(e){var t=e.state,n=e.options,r=e.name,a=n.mainAxis,o=a===void 0?!0:a,i=n.altAxis,l=i===void 0?!1:i,c=n.boundary,f=n.rootBoundary,h=n.altBoundary,g=n.padding,y=n.tether,w=y===void 0?!0:y,S=n.tetherOffset,D=S===void 0?0:S,I=Xg(t,{boundary:c,rootBoundary:f,padding:g,altBoundary:h}),M=ql(t.placement),N=Dp(t.placement),R=!N,k=eI(M),B=FU(k),L=t.modifiersData.popperOffsets,_=t.rects.reference,V=t.rects.popper,Y=typeof D=="function"?D(Object.assign({},t.rects,{placement:t.placement})):D,Z=typeof Y=="number"?{mainAxis:Y,altAxis:Y}:Object.assign({mainAxis:0,altAxis:0},Y),Q=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,K={x:0,y:0};if(L){if(o){var se,le=k==="y"?ti:ni,fe=k==="y"?as:os,$=k==="y"?"height":"width",he=L[k],ie=he+I[le],ce=he-I[fe],X=w?-V[$]/2:0,ae=N===wp?_[$]:V[$],De=N===wp?-V[$]:-_[$],je=t.elements.arrow,Re=w&&je?X2(je):{width:0,height:0},Fe=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:N6(),Be=Fe[le],Xe=Fe[fe],Ze=Yg(0,_[$],Re[$]),st=R?_[$]/2-X-Ze-Be-Z.mainAxis:ae-Ze-Be-Z.mainAxis,Ct=R?-_[$]/2+X+Ze+Xe+Z.mainAxis:De+Ze+Xe+Z.mainAxis,tn=t.elements.arrow&&Bv(t.elements.arrow),_e=tn?k==="y"?tn.clientTop||0:tn.clientLeft||0:0,et=(se=Q==null?void 0:Q[k])!=null?se:0,nt=he+st-et-_e,ht=he+Ct-et,St=Yg(w?Aw(ie,nt):ie,he,w?ff(ce,ht):ce);L[k]=St,K[k]=St-he}if(l){var Tt,Gt=k==="x"?ti:ni,_t=k==="x"?as:os,Vt=L[B],Xt=B==="y"?"height":"width",dn=Vt+I[Gt],en=Vt-I[_t],Zn=[ti,ni].indexOf(M)!==-1,kn=(Tt=Q==null?void 0:Q[B])!=null?Tt:0,Er=Zn?dn:Vt-_[Xt]-V[Xt]-kn+Z.altAxis,pt=Zn?Vt+_[Xt]+V[Xt]-kn-Z.altAxis:en,Mt=w&&Zn?cU(Er,Vt,pt):Yg(w?Er:dn,Vt,w?pt:en);L[B]=Mt,K[B]=Mt-Vt}t.modifiersData[r]=K}}const U6={name:"preventOverflow",enabled:!0,phase:"main",fn:OU,requiresIfExists:["offset"]};function PU(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function jU(e){return e===Ni(e)||!ns(e)?tI(e):PU(e)}function LU(e){var t=e.getBoundingClientRect(),n=bp(t.width)/e.offsetWidth||1,r=bp(t.height)/e.offsetHeight||1;return n!==1||r!==1}function RU(e,t,n){n===void 0&&(n=!1);var r=ns(t),a=ns(t)&&LU(t),o=ad(t),i=Sp(e,a,n),l={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((Ql(t)!=="body"||rI(o))&&(l=jU(t)),ns(t)?(c=Sp(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):o&&(c.x=nI(o))),{x:i.left+l.scrollLeft-c.x,y:i.top+l.scrollTop-c.y,width:i.width,height:i.height}}function _U(e){var t=new Map,n=new Set,r=[];e.forEach(function(o){t.set(o.name,o)});function a(o){n.add(o.name);var i=[].concat(o.requires||[],o.requiresIfExists||[]);i.forEach(function(l){if(!n.has(l)){var c=t.get(l);c&&a(c)}}),r.push(o)}return e.forEach(function(o){n.has(o.name)||a(o)}),r}function BU(e){var t=_U(e);return aU.reduce(function(n,r){return n.concat(t.filter(function(a){return a.phase===r}))},[])}function HU(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function YU(e){var t=e.reduce(function(n,r){var a=n[r.name];return n[r.name]=a?Object.assign({},a,r,{options:Object.assign({},a.options,r.options),data:Object.assign({},a.data,r.data)}):r,n},{});return Object.keys(t).map(function(n){return t[n]})}var Fx={placement:"bottom",modifiers:[],strategy:"absolute"};function Ox(){for(var e=arguments.length,t=new Array(e),n=0;n({placement:e,modifiers:[{name:"flip",options:{allowedAutoPlacements:t,rootBoundary:"document"}},{name:"preventOverflow",options:{rootBoundary:"document"}}]}),ez=e=>{const n=P.useRef(null),[r,a]=P.useState(null),[o,i]=P.useState(0);let l,c;const f=()=>{if(x.Platform.isMobile){l="right-end",c=["bottom"];return}const g=window.innerWidth-o>280*1.2,y=window.innerWidth-o<280,w=window.innerWidth>280*1.5;if(e.DefaultEditorLocation!=="Bottom"){g?(l="right-end",c=["left-end"]):y&&w?(l="left-end",c=["right-end"]):(l="bottom",c=["bottom"]);return}g?(l="top-end",c=["top-start"]):y&&o>280?(l="top-start",c=["top-end"]):(l="top",c=["top"])};P.useEffect(()=>{e&&f()},[o,e==null?void 0:e.DefaultEditorLocation]);const h=Cb(n.current,r,XU(l,c));return{setPosX:i,popperRef:n,setPopperElement:a,popper:h}},tz=()=>{const e=new Set,t=at.getState().query.filter,n=at.getState().query.tag,r=on.getQueryById(t||"");if(r&&r.querystring){const a=JSON.parse(r.querystring);if(Array.isArray(a))for(const o of a)o.type==="TAG"&&o.value&&o.value.operator==="CONTAIN"&&e.add(o.value.value)}return n&&e.add(n),Array.from(e)},nz=e=>{const{offsetLeft:t,offsetTop:n,offsetHeight:r,offsetWidth:a,selectionEnd:o}=e,i=document.createElement("div"),l=window.getComputedStyle(e);for(const D of l)i.style.setProperty(D,l.getPropertyValue(D));i.style.position="fixed",i.style.visibility="hidden",i.style.whiteSpace="pre-wrap";const f=e.tagName==="INPUT"?e.value.replace(/ /g,"."):e.value;i.textContent=f.substring(0,o||0),e.tagName==="TEXTAREA"&&(i.style.height="auto");const h=document.createElement("span");h.textContent=f.substring(o||0)||".",i.appendChild(h),document.body.appendChild(i);const{offsetLeft:g,offsetTop:y,offsetHeight:w,offsetWidth:S}=h;return document.body.removeChild(i),{x:t+g,y:n+y,h:r+w,w:a+S}},hf=({className:e,editorType:t,destroy:n,modal:r})=>{const{globalState:a,dailyNotesState:{app:o,settings:i,view:l,verifyState:c}}=P.useContext(Lt),[f,h]=Kl(!0),g=P.useRef(f),[y,w]=xo(!0),S=P.useRef(null),D=P.useRef(null),I=P.useRef(a),[M,N]=xo(!1),[R,k]=xo(!1),{setPosX:B,popperRef:L,setPopperElement:_,popper:V}=ez(i),[Y]=xo(parseInt(x.moment().format("x"))),Z=P.useRef(null),[Q,K]=xo((i==null?void 0:i.EnabledLocationList.length)===1?i==null?void 0:i.EnabledLocationList[0].value:(i==null?void 0:i.MemoSaveLocation)||"DAILY"),se=P.useRef(i.MemoSaveLocation||"DAILY");P.useEffect(()=>{g.current=f},[f]),P.useEffect(()=>{!D.current||!o||!l||(l.registerEvent(o.workspace.on("focus-on-textarea",_e=>{var et;(et=D.current)==null||et.focus(_e==null?void 0:_e.id)})),l.registerEvent(o.workspace.on("blur-on-memos",()=>{var _e;(_e=D.current)==null||_e.blur()})),l.registerEvent(o.workspace.on("send-to-thino",async(_e,et)=>{var nt,ht;if(typeof _e=="string")(nt=D.current)==null||nt.insertText(_e+`
+`,et.id);else{const St=_e.toPNG(),Tt=new Blob([St],{type:"image/png"}),Gt=new File([Tt],"image.png",{type:"image/png",lastModified:Date.now()});if(!Gt)return;const _t=await ce(Gt);_t&&((ht=D.current)==null||ht.insertText(_t+`
+`,et.id))}})))},[D,l,o]),P.useEffect(()=>{i&&h(i.DefaultPrefix==="List")},[i==null?void 0:i.DefaultPrefix]),P.useEffect(()=>{if(i){if(i.EnabledLocationList.length===1){K(i.EnabledLocationList[0].value);return}K(i.MemoSaveLocation||"DAILY")}},[i==null?void 0:i.MemoSaveLocation,i==null?void 0:i.EnabledLocationList]),P.useEffect(()=>{var nt;if(!i||!Z.current)return;const _e=(nt=Gg.find(ht=>ht.title===Q))==null?void 0:nt.icon;x.setIcon(Z.current,_e),x.requireApiVersion("1.4.4")&&x.setTooltip(Z.current,E("Thino Save To: ")+Q),se.current=Q;const et=a.manifest;if(et){const ht=o==null?void 0:o.plugins.getPlugin(et.id);if(ht){if(ht.settings.MemoSaveLocation===Q)return;ht.settings.MemoSaveLocation=Q,ht.saveSettings()}}},[Q,y]),P.useEffect(()=>{D.current&&i.MemoSaveLocation&&K(i.MemoSaveLocation)},[Z,i]),P.useEffect(()=>{if(!D.current||!i||x.Platform.isDesktop||a.globalEditorShown)return;const _e=i.UseButtonToShowEditor&&i.DefaultEditorLocation==="Bottom";if(x.Platform.isDesktop){w(!0);return}if(t&&t==="inline"){w(!0);return}if(w(x.Platform.isMobile&&!_e),!_e||a.memoListView==="chat")return;const et=document.body.find(".memolist-scrollview");et&&(et.onscroll=()=>{if(a.globalEditorShown)return;if(!a.memoListView&&dt.getState().memoListView==="chat"){et.onscroll=null;return}const nt=D.current.getContent();x.Platform.isMobile&&_e&&!nt&&w(!1)})},[a.globalEditorShown,t,D]);const le=()=>{k(!1)};P.useEffect(()=>{var _e,et,nt,ht,St,Tt,Gt,_t,Vt;if(o&&(a.markMemoId||(_e=a.editMemoId)!=null&&_e.trim()&&a.editMemoId!==I.current.editMemoId)){const Xt=o.workspace.getLeavesOfType("thino_view");Xt.length>0&&o.workspace.revealLeaf(Xt[0])}if(a.markMemoId){const Xt=`${E("MARK")}: [@THINO](${a.markMemoId})`;(et=D.current)==null||et.insertText(Xt),(nt=D.current)==null||nt.focus(),dt.setMarkMemoId("");return}if((ht=a.editMemoId)!=null&&ht.trim()&&a.editMemoId!==I.current.editMemoId){const Xt=be.getMemoById(a.editMemoId);if(Xt)switch(h(Xt.thinoType==="JOURNAL"),i.EditorType){case"memos":(St=D.current)==null||St.setContent(Xt.content.replace(/ \^\S{6}$/,"")||""),(Tt=D.current)==null||Tt.focus();break;case"obsidian":(Gt=D.current)==null||Gt.clear(),(_t=D.current)==null||_t.setContent(Xt.content.replace(/ \^\S{6}$/,"")||""),(Vt=D.current)==null||Vt.focus();break}}I.current=a},[a.markMemoId,a.editMemoId]),P.useEffect(()=>{var _e,et,nt;!D.current||M||i.EditorType==="memos"&&((_e=D.current)==null||_e.element.addEventListener("paste",fe),(et=D.current)==null||et.element.addEventListener("drop",$),(nt=D.current)==null||nt.element.addEventListener("click",he),N(!0))},[D.current]);const fe=async _e=>{var et;if(_e.clipboardData&&_e.clipboardData.files.length>0){_e.preventDefault();const nt=_e.clipboardData.files;for(const ht of nt){const St=await ce(ht);St&&((et=D.current)==null||et.insertText(St))}}},$=async _e=>{var et;if(_e.dataTransfer&&_e.dataTransfer.files.length>0){_e.preventDefault();const nt=_e.dataTransfer.files;for(const ht of nt){const St=await ce(ht);St&&((et=D.current)==null||et.insertText(St))}}},he=()=>{var _e;De(((_e=D.current)==null?void 0:_e.element.value)||"")},ie=async(_e,et)=>{var St,Tt,Gt;const nt=_e.ctrlKey||_e.metaKey,ht=_e.altKey;if(_e.key==="Escape"&&a.globalEditorShown&&(dt.setGlobalEditorShown(!1),_e.preventDefault()),nt&&_e.key==="Enter"){_e.preventDefault(),_e.stopPropagation(),et?(await X((Tt=D.current)==null?void 0:Tt.getContent()),(Gt=D.current)==null||Gt.clear()):await X((St=D.current)==null?void 0:St.element.value);return}if(ht)for(let _t=0;_t{var _t;et||De(((_t=D.current)==null?void 0:_t.element.value)||"")})},ce=P.useCallback(async _e=>{const{type:et}=_e;if(et.startsWith("image"))try{return`${await $2.upload(_e)}`}catch(nt){new x.Notice(nt)}},[]),X=async _e=>{if(!_e||_e.trim()===""){new x.Notice(E("Content cannot be empty"));return}const et=ft.getState().settings,nt=et==null?void 0:et.addTagAutomatically,ht=et==null?void 0:et.addTagWithNewline,St=et==null?void 0:et.addTagPosition,Gt=(tz()||[]).filter(dn=>!_e.includes(`#${dn}`)),_t=async(dn,en)=>{en=en.replaceAll(" "," "),C0("");try{if(!dn){let kn;switch(se.current){case"CANVAS":kn=await be.createMemoCanvas({text:en,isList:g.current});break;case"MULTI":kn=await be.createMemoMultiFile({content:en,isList:g.current});break;case"DAILY":kn=await be.createMemoDaily(en,g.current);break;case"FILE":kn=await be.createMemoSingleFile({content:en,isList:g.current});break}if(!kn)return;be.pushMemo(kn),(!nt||Gt.length===0)&&at.clearQuery();const Er=o||ft.getState().app,pt=Er==null?void 0:Er.loadLocalStorage("tokenForSync");kn&&pt&&i.startSync&&setTimeout(async()=>{try{if(se.current!=="DAILY"){const Mt=await M2({content:en,thinoType:"FILE"});await be.updateMemoById(kn.id,Mt,!0)}}catch(Mt){console.error(Mt)}},200);return}const Zn=be.getMemoById(dn);if(Zn&&(Zn.content!==en||Zn.thinoType!==(g.current?"JOURNAL":"TASK-TODO"))){const kn=await be.updateMemo(Zn.id,en,g.current?"JOURNAL":Zn.thinoType.startsWith("TASK")?Zn.thinoType:"TASK-TODO");kn.updatedAt=ut.getDateTimeString(Date.now()),be.editMemo(kn)}dt.setEditMemoId("")}catch(Zn){new x.Notice(Zn.message)}};n&&n();const{editMemoId:Vt}=dt.getState(),Xt=Gt&&Gt.length>0&&nt&&!Vt?St==="Beginning"?`${Gt.map(dn=>`#${dn}`).join(" ")} ${ht?`
`:""}${_e}`:`${_e} ${ht?`
-`:""}${Gt.map(dn=>`#${dn}`).join(" ")}`:_e;await _t(Vt,Xt),D0("")},ae=P.useCallback(()=>{var _e;dt.setEditMemoId(""),(_e=S.current)==null||_e.setContent(""),D0("")},[]),Se=P.useCallback(_e=>{if(D0(_e??""),!S.current)return;const Xe=S.current.getContent(),tt=S.current.element.selectionStart,ht=Xe.slice(0,tt),St=Xe.slice(tt);(ht.endsWith("@")||ht.endsWith("📆"))&&St.startsWith(" ")||(ht.endsWith("@")||ht.endsWith("📆"))&&St===""?(Ze(),k(!0)):k(!1),setTimeout(()=>{var Tt;(Tt=S.current)==null||Tt.focus()})},[i.EditorType]),je=_e=>{if(!S.current||!i)return;_e&&(ue(),p(!1));const Xe=S.current.getContent(),tt=S.current.element.selectionStart,ht=Xe.slice(0,tt),St=Xe.slice(tt),Tt=C.moment(_e);if(ht.endsWith("@"))switch(i.InsertDateFormat){case"Dataview":S.current.element.value=Xe.slice(0,S.current.element.selectionStart-1)+"[due:: "+Tt.format("YYYY-MM-DD")+"]"+St,S.current.element.setSelectionRange(tt+17,tt+17),S.current.focus(),Se(S.current.element.value);break;case"Tasks":S.current.element.value=Xe.slice(0,S.current.element.selectionStart-1)+"📅 "+Tt.format("YYYY-MM-DD")+St,S.current.element.setSelectionRange(tt+11,tt+11),S.current.focus(),Se(S.current.element.value)}else{S.current.element.value=ht+Tt.format("YYYY-MM-DD")+St,S.current.element.setSelectionRange(tt+10,tt+10),S.current.focus(),Se(S.current.element.value);return}},Re=()=>{S.current&&p()},Fe=async()=>{var tt;const _e=!C.Platform.isDesktop&&await((tt=window.Capacitor)==null?void 0:tt.Plugins.Device.getId()),Xe=C.Platform.isDesktop?await cr():_e.identifier||_e.uuid;return!c||(c==null?void 0:c.appId)!==Xe?(Sn(),!1):!0},Be=async _e=>{if(!await Fe())return;const Xe=new C.Menu;i.EnabledLocationList.forEach(Tt=>{Xe.addItem(Gt=>{var _t;Gt.setTitle(E(Tt.value)).setIcon(((_t=$g.find(Vt=>Vt.title===Tt.value))==null?void 0:_t.icon)??"file").setChecked(X===Tt.value).onClick(()=>{Q(Tt.value)})})});let tt=_e.target,ht=null;for(;!tt.hasClass("location-wrapper")&&(ht=tt.parentElement,ht);)tt=ht;const St=tt.getBoundingClientRect();setTimeout(()=>{Xe.showAtPosition({x:St.x,y:St.bottom,width:St.width,left:!1,overlap:!0})},200)},Qe=P.useCallback(()=>{var _e,Xe;if(!(!S.current&&i.EditorType==="memos"))switch(i.EditorType){case"obsidian":(_e=S.current)==null||_e.focus(),(Xe=S.current)==null||Xe.insertTag();break;case"memos":{const tt=S.current.getContent(),ht=S.current.element.selectionStart,St=tt.slice(0,ht),Tt=tt.slice(ht);let Gt=St+"# "+Tt,_t=St.length+1;St.endsWith("#")&&Tt.startsWith(" ")&&(Gt=St.slice(0,St.length-1)+Tt.slice(1),_t=St.length-1),S.current.element.value=Gt,S.current.element.setSelectionRange(_t,_t),S.current.focus();const Vt=new Event("input",{bubbles:!0,cancelable:!0});S.current.element.dispatchEvent(Vt),Se(S.current.element.value)}}},[o]),Ze=P.useCallback(()=>{if(!S.current||!L.current||!i||!o)return;const tt=o.workspace.getLeavesOfType(lo)[0].view.containerEl,ht=280,St=tt.clientWidth,{x:Tt,y:Gt}=WU(S.current.element);let _t,Vt;C.Platform.isMobile?(window.innerWidth-Tt>ht?_t=(Tt+ht+16>St,Tt+18):window.innerWidth-TtSt,Tt+34):_t=S.current.element.clientWidth/2,i.DefaultEditorLocation==="Bottom"&&window.innerWidth>875?Vt=Gt+4:i.DefaultEditorLocation==="Bottom"&&window.innerWidth<=875?Vt=Gt+19:i.DefaultEditorLocation==="Top"&&window.innerWidth<=875&&(Vt=Gt+36)):(_t=(Tt+ht+16>St,Tt+18),Vt=Gt+34),R(Tt),L.current.style.left=`${_t}px`,L.current.style.top=`${Vt}px`},[i,o]),st=P.useCallback(()=>{const _e=document.createElement("input");document.body.appendChild(_e),_e.type="file",_e.multiple=!1,_e.accept="image/png, image/gif, image/jpeg",_e.onchange=async()=>{var ht;if(!_e.files||_e.files.length===0)return;const Xe=_e.files[0],tt=await de(Xe);tt&&((ht=S.current)==null||ht.insertText(tt)),document.body.removeChild(_e)},_e.click()},[]),xt=!!a.editMemoId,tn=P.useMemo(()=>({className:"memo-editor",inputerType:i.EditorType||"obsidian",modal:r,initialContent:$U(),placeholder:E("What do you think now..."),showConfirmBtn:!0,showCancelBtn:xt,showTools:!0,onConfirmBtnClick:K,onCancelBtnClick:ae,onContentChange:Se}),[xt,i.EditorType]);return v.jsxs(v.Fragment,{children:[!a.globalEditorShown&&t==="block"&&v.jsx("div",{ref:_e=>{T.current=_e,_e&&C.setIcon&&C.setIcon(_e,"plus-circle")},className:`memo-show-editor-button ${y?"hidden":""}`,onClick:()=>{var _e;(_e=T.current.firstElementChild)==null||_e.toggleClass("rotate-hidden",!0),setTimeout(()=>{w(!0),T.current.firstElementChild.toggleClass("rotate-hidden",!1)},500),setTimeout(()=>{var Xe;(Xe=S.current)==null||Xe.focus()},600)}}),v.jsxs("div",{className:`memo-editor-wrapper ${e||""} ${xt?"edit-ing":""} ${a.globalEditorShown?"fullscreen-editor":""} ${y?"":"hidden"}`,onKeyDownCapture:_e=>ie(_e,!0),children:[v.jsx("span",{className:`tip-text ${xt?"":"hidden"}`,children:"Modifying..."}),v.jsx(FY,{ref:S,...tn,tools:v.jsxs(v.Fragment,{children:[v.jsx("span",{ref:_e=>{_e&&C.setIcon(_e,"hash")},className:"btn action-btn add-tag",onClick:()=>{i&&i.DefaultEditorLocation==="Top"&&!a.globalEditorShown&&Qe()},onPointerDown:()=>{(i&&i.DefaultEditorLocation==="Bottom"||a.globalEditorShown)&&Qe()}}),v.jsx("span",{ref:_e=>{_e&&C.setIcon(_e,"paperclip")},className:"btn action-btn file-upload",onClick:()=>{i&&i.DefaultEditorLocation==="Top"&&!a.globalEditorShown&&st()},onPointerDown:()=>{(i&&i.DefaultEditorLocation==="Bottom"||a.globalEditorShown)&&st()}}),v.jsx("span",{ref:_e=>{_e&&C.setIcon(_e,f?"layout-list":"check-square")},className:ar("btn action-btn list-or-task",f?"list":"task"),onClick:()=>{i&&i.DefaultEditorLocation==="Top"&&!a.globalEditorShown&&Re()},onPointerDown:()=>{(i&&i.DefaultEditorLocation==="Bottom"||a.globalEditorShown)&&Re()}}),v.jsx("div",{ref:_e=>{_e&&(C.setIcon&&C.setIcon(_e,a.globalEditorShown?"shrink":"expand"),C.setTooltip&&C.setTooltip(_e,a.globalEditorShown?E("Exit fullscreen mode"):E("Enter fullscreen mode")))},className:"action-btn show-editor pro",onPointerDown:async()=>{await Fe()&&(w(!0),dt.setGlobalEditorShown(!a.globalEditorShown))}}),v.jsx("div",{className:"action-btn split-line pro"}),v.jsx("div",{className:"action-btn location-wrapper pro",onClick:async _e=>{i&&i.DefaultEditorLocation==="Top"&&!a.globalEditorShown&&await Be(_e)},onPointerDown:async _e=>{(i&&i.DefaultEditorLocation==="Bottom"||a.globalEditorShown)&&await Be(_e)},children:v.jsx("div",{ref:$,className:"action-btn file-location-btn"})})]})}),v.jsx("div",{ref:L,className:"date-picker",children:_&&v.jsx("div",{tabIndex:-1,style:U.styles.popper,...U.attributes.popper,ref:H,role:"dialog",children:v.jsx(Sb,{className:`editor-date-picker ${_?"":"hidden"}`,datestamp:z,handleDateStampChange:je})})})]})]})};function $U(){return la.get(["thinoEditorContentCache"]).thinoEditorContentCache??""}function D0(e){la.set({thinoEditorContentCache:e})}const ZU=e=>{const t=[];return e.map(n=>{t.length==0?t.push({date:C.moment(n.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"),have:[n]}):t.some(a=>{if(a.date==C.moment(n.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"))return a.have.push(n),!0})||t.push({date:C.moment(n.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"),have:[n]})}),t},qU=e=>be.getState().commentMemos.filter(t=>t.linkId===e.hasId).sort((t,n)=>ut.getTimeStampByDate(t.createdAt)-ut.getTimeStampByDate(n.createdAt)).map(t=>({...t,createdAtStr:ut.getDateTimeString(t.createdAt),dateStr:ut.getDateString(t.createdAt)})),GU=e=>{const t=ft.getState().settings,n=QL(),r=t!=null&&t.ShowDate?" ":"",a="YYYY/MM/DD HH:mm:ss",o=/comment:(.*)$/g,i=/^\d{14}/g,l=(g,y,w)=>{const T=C.moment(g.createdAt,a).format("HH:mm");return w?w.replace(/{TIME}/g,T).replace(/{CONTENT}/g,y):`${T} ${y}`},c=g=>{const y=g.match(/TASK-(.*)?/g);return y?y[1]:""},f=g=>g==="TASK-TODO"?"- [ ] ":g==="TASK-DONE"?"- [x] ":g.match(/TASK-(.*)?/g)?`- [${c(g)}] `:"- ",p=g=>g.reduce((y,w)=>{const T=w.sourceType!=="MULTI"?`${w.content}`:`[[${w.path}]]`,S=t!=null&&t.ShowTime?l(w,T,t==null?void 0:t.DefaultMemoComposition):T,I=`${f(w.thinoType)}${S}`;let M="";return t.CommentOnMemos&&w.hasId!==void 0&&w.hasId!==""&&(M=qU(w).reduce((_,k)=>{const R=f(k.thinoType),L=k.content.replace(o,"").replace(i,""),H=t!=null&&t.ShowDate?`${R}[[${C.moment(k.createdAt).format(n)}]] ${C.moment(k.createdAt).format("HH:mm")} ${L}`:`${R}${L}`;return _+r+" "+H+`
+`:""}${Gt.map(dn=>`#${dn}`).join(" ")}`:_e;await _t(Vt,Xt),C0("")},ae=P.useCallback(()=>{var _e;dt.setEditMemoId(""),(_e=D.current)==null||_e.setContent(""),C0("")},[]),De=P.useCallback(_e=>{if(C0(_e??""),!D.current)return;const et=D.current.getContent(),nt=D.current.element.selectionStart,ht=et.slice(0,nt),St=et.slice(nt);(ht.endsWith("@")||ht.endsWith("📆"))&&St.startsWith(" ")||(ht.endsWith("@")||ht.endsWith("📆"))&&St===""?(Ze(),k(!0)):k(!1),setTimeout(()=>{var Tt;(Tt=D.current)==null||Tt.focus()})},[i.EditorType]),je=_e=>{if(!D.current||!i)return;_e&&(le(),h(!1));const et=D.current.getContent(),nt=D.current.element.selectionStart,ht=et.slice(0,nt),St=et.slice(nt),Tt=x.moment(_e);if(ht.endsWith("@"))switch(i.InsertDateFormat){case"Dataview":D.current.element.value=et.slice(0,D.current.element.selectionStart-1)+"[due:: "+Tt.format("YYYY-MM-DD")+"]"+St,D.current.element.setSelectionRange(nt+17,nt+17),D.current.focus(),De(D.current.element.value);break;case"Tasks":D.current.element.value=et.slice(0,D.current.element.selectionStart-1)+"📅 "+Tt.format("YYYY-MM-DD")+St,D.current.element.setSelectionRange(nt+11,nt+11),D.current.focus(),De(D.current.element.value)}else{D.current.element.value=ht+Tt.format("YYYY-MM-DD")+St,D.current.element.setSelectionRange(nt+10,nt+10),D.current.focus(),De(D.current.element.value);return}},Re=()=>{D.current&&h()},Fe=async()=>{var nt;const _e=!x.Platform.isDesktop&&await((nt=window.Capacitor)==null?void 0:nt.Plugins.Device.getId()),et=x.Platform.isDesktop?await cr():_e.identifier||_e.uuid;return!c||(c==null?void 0:c.appId)!==et?(fn(),!1):!0},Be=async _e=>{if(!await Fe())return;const et=new x.Menu;i.EnabledLocationList.forEach(Tt=>{et.addItem(Gt=>{var _t;Gt.setTitle(E(Tt.value)).setIcon(((_t=Gg.find(Vt=>Vt.title===Tt.value))==null?void 0:_t.icon)??"file").setChecked(Q===Tt.value).onClick(()=>{K(Tt.value)})})});let nt=_e.target,ht=null;for(;!nt.hasClass("location-wrapper")&&(ht=nt.parentElement,ht);)nt=ht;const St=nt.getBoundingClientRect();setTimeout(()=>{et.showAtPosition({x:St.x,y:St.bottom,width:St.width,left:!1,overlap:!0})},200)},Xe=P.useCallback(()=>{var _e,et;if(!(!D.current&&i.EditorType==="memos"))switch(i.EditorType){case"obsidian":(_e=D.current)==null||_e.focus(),(et=D.current)==null||et.insertTag();break;case"memos":{const nt=D.current.getContent(),ht=D.current.element.selectionStart,St=nt.slice(0,ht),Tt=nt.slice(ht);let Gt=St+"# "+Tt,_t=St.length+1;St.endsWith("#")&&Tt.startsWith(" ")&&(Gt=St.slice(0,St.length-1)+Tt.slice(1),_t=St.length-1),D.current.element.value=Gt,D.current.element.setSelectionRange(_t,_t),D.current.focus();const Vt=new Event("input",{bubbles:!0,cancelable:!0});D.current.element.dispatchEvent(Vt),De(D.current.element.value)}}},[o]),Ze=P.useCallback(()=>{if(!D.current||!L.current||!i||!o)return;const nt=o.workspace.getLeavesOfType(lo)[0].view.containerEl,ht=280,St=nt.clientWidth,{x:Tt,y:Gt}=nz(D.current.element);let _t,Vt;x.Platform.isMobile?(window.innerWidth-Tt>ht?_t=(Tt+ht+16>St,Tt+18):window.innerWidth-TtSt,Tt+34):_t=D.current.element.clientWidth/2,i.DefaultEditorLocation==="Bottom"&&window.innerWidth>875?Vt=Gt+4:i.DefaultEditorLocation==="Bottom"&&window.innerWidth<=875?Vt=Gt+19:i.DefaultEditorLocation==="Top"&&window.innerWidth<=875&&(Vt=Gt+36)):(_t=(Tt+ht+16>St,Tt+18),Vt=Gt+34),B(Tt),L.current.style.left=`${_t}px`,L.current.style.top=`${Vt}px`},[i,o]),st=P.useCallback(()=>{const _e=document.createElement("input");document.body.appendChild(_e),_e.type="file",_e.multiple=!1,_e.accept="image/png, image/gif, image/jpeg",_e.onchange=async()=>{var ht;if(!_e.files||_e.files.length===0)return;const et=_e.files[0],nt=await ce(et);nt&&((ht=D.current)==null||ht.insertText(nt)),document.body.removeChild(_e)},_e.click()},[]),Ct=!!a.editMemoId,tn=P.useMemo(()=>({className:"memo-editor",inputerType:i.EditorType||"obsidian",modal:r,initialContent:rz(),placeholder:E("What do you think now..."),showConfirmBtn:!0,showCancelBtn:Ct,showTools:!0,onConfirmBtnClick:X,onCancelBtnClick:ae,onContentChange:De}),[Ct,i.EditorType]);return v.jsxs(v.Fragment,{children:[!a.globalEditorShown&&t==="block"&&v.jsx("div",{ref:_e=>{S.current=_e,_e&&x.setIcon&&x.setIcon(_e,"plus-circle")},className:`memo-show-editor-button ${y?"hidden":""}`,onClick:()=>{var _e;(_e=S.current.firstElementChild)==null||_e.toggleClass("rotate-hidden",!0),setTimeout(()=>{w(!0),S.current.firstElementChild.toggleClass("rotate-hidden",!1)},500),setTimeout(()=>{var et;(et=D.current)==null||et.focus()},600)}}),v.jsxs("div",{className:`memo-editor-wrapper ${e||""} ${Ct?"edit-ing":""} ${a.globalEditorShown?"fullscreen-editor":""} ${y?"":"hidden"}`,onKeyDownCapture:_e=>ie(_e,!0),children:[v.jsx("span",{className:`tip-text ${Ct?"":"hidden"}`,children:"Modifying..."}),v.jsx(zY,{ref:D,...tn,tools:v.jsxs(v.Fragment,{children:[v.jsx("span",{ref:_e=>{_e&&x.setIcon(_e,"hash")},className:"btn action-btn add-tag",onClick:()=>{i&&i.DefaultEditorLocation==="Top"&&!a.globalEditorShown&&Xe()},onPointerDown:()=>{(i&&i.DefaultEditorLocation==="Bottom"||a.globalEditorShown)&&Xe()}}),v.jsx("span",{ref:_e=>{_e&&x.setIcon(_e,"paperclip")},className:"btn action-btn file-upload",onClick:()=>{i&&i.DefaultEditorLocation==="Top"&&!a.globalEditorShown&&st()},onPointerDown:()=>{(i&&i.DefaultEditorLocation==="Bottom"||a.globalEditorShown)&&st()}}),v.jsx("span",{ref:_e=>{_e&&x.setIcon(_e,f?"layout-list":"check-square")},className:ar("btn action-btn list-or-task",f?"list":"task"),onClick:()=>{i&&i.DefaultEditorLocation==="Top"&&!a.globalEditorShown&&Re()},onPointerDown:()=>{(i&&i.DefaultEditorLocation==="Bottom"||a.globalEditorShown)&&Re()}}),v.jsx("div",{ref:_e=>{_e&&(x.setIcon&&x.setIcon(_e,a.globalEditorShown?"shrink":"expand"),x.setTooltip&&x.setTooltip(_e,a.globalEditorShown?E("Exit fullscreen mode"):E("Enter fullscreen mode")))},className:"action-btn show-editor pro",onPointerDown:async()=>{await Fe()&&(w(!0),dt.setGlobalEditorShown(!a.globalEditorShown))}}),v.jsx("div",{className:"action-btn split-line pro"}),v.jsx("div",{className:"action-btn location-wrapper pro",onClick:async _e=>{i&&i.DefaultEditorLocation==="Top"&&!a.globalEditorShown&&await Be(_e)},onPointerDown:async _e=>{(i&&i.DefaultEditorLocation==="Bottom"||a.globalEditorShown)&&await Be(_e)},children:v.jsx("div",{ref:Z,className:"action-btn file-location-btn"})})]})}),v.jsx("div",{ref:L,className:"date-picker",children:R&&v.jsx("div",{tabIndex:-1,style:V.styles.popper,...V.attributes.popper,ref:_,role:"dialog",children:v.jsx(Ib,{className:`editor-date-picker ${R?"":"hidden"}`,datestamp:Y,handleDateStampChange:je})})})]})]})};function rz(){return la.get(["thinoEditorContentCache"]).thinoEditorContentCache??""}function C0(e){la.set({thinoEditorContentCache:e})}const az=e=>{const t=[];return e.map(n=>{t.length==0?t.push({date:x.moment(n.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"),have:[n]}):t.some(a=>{if(a.date==x.moment(n.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"))return a.have.push(n),!0})||t.push({date:x.moment(n.createdAt,"YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD"),have:[n]})}),t},oz=e=>be.getState().commentMemos.filter(t=>t.linkId===e.hasId).sort((t,n)=>ut.getTimeStampByDate(t.createdAt)-ut.getTimeStampByDate(n.createdAt)).map(t=>({...t,createdAtStr:ut.getDateTimeString(t.createdAt),dateStr:ut.getDateString(t.createdAt)})),iz=e=>{const t=ft.getState().settings,n=uR(),r=t!=null&&t.ShowDate?" ":"",a="YYYY/MM/DD HH:mm:ss",o=/comment:(.*)$/g,i=/^\d{14}/g,l=(g,y,w)=>{const S=x.moment(g.createdAt,a).format("HH:mm");return w?w.replace(/{TIME}/g,S).replace(/{CONTENT}/g,y):`${S} ${y}`},c=g=>{const y=g.match(/TASK-(.*)?/g);return y?y[1]:""},f=g=>g==="TASK-TODO"?"- [ ] ":g==="TASK-DONE"?"- [x] ":g.match(/TASK-(.*)?/g)?`- [${c(g)}] `:"- ",h=g=>g.reduce((y,w)=>{const S=w.sourceType!=="MULTI"?`${w.content}`:`[[${w.path}]]`,D=t!=null&&t.ShowTime?l(w,S,t==null?void 0:t.DefaultMemoComposition):S,I=`${f(w.thinoType)}${D}`;let M="";return t.CommentOnMemos&&w.hasId!==void 0&&w.hasId!==""&&(M=oz(w).reduce((R,k)=>{const B=f(k.thinoType),L=k.content.replace(o,"").replace(i,""),_=t!=null&&t.ShowDate?`${B}[[${x.moment(k.createdAt).format(n)}]] ${x.moment(k.createdAt).format("HH:mm")} ${L}`:`${B}${L}`;return R+r+" "+_+`
`},"")),y+r+I.replace(/ \^\S{6}/g,"")+`
-`+M},"");return e.reduce((g,y)=>{const w=t!=null&&t.ShowDate?`- [[${C.moment(y.date,"YYYY-MM-DD").format(n)}]]
-`:"",T=p(y.have),S=t!=null&&t.ShowDate&&(t!=null&&t.AddBlankLineWhenDate)&&!(t!=null&&t.CommentOnMemos)?`
-`:"";return g+w+T+S},"").replace(/ /g,`
- `)},JU=[{label:E("Today"),value:C.moment().format("YYYY-MM-DD")},{label:E("Yesterday"),value:C.moment().subtract(1,"days").format("YYYY-MM-DD")},{label:E("Last 7 days"),value:C.moment().subtract(7,"days").format("YYYY-MM-DD")},{label:E("Last 30 days"),value:C.moment().subtract(30,"days").format("YYYY-MM-DD")},{label:E("Last 90 days"),value:C.moment().subtract(90,"days").format("YYYY-MM-DD")},{label:E("Last 180 days"),value:C.moment().subtract(180,"days").format("YYYY-MM-DD")},{label:E("Last 365 days"),value:C.moment().subtract(365,"days").format("YYYY-MM-DD")}],L6=e=>{const{handleValueChange:t,setShownStatus:n}=e;return v.jsxs(v.Fragment,{children:[e.type==="icon"&&v.jsx("div",{className:"quick-date-btn-group",children:JU.map((r,a)=>v.jsx("div",{className:"btn action-btn quick-date-btn",onClick:()=>{t(r.value),n&&n(!1)},children:r.label},a))}),v.jsx(Sb,{className:"calendar-date-picker",datestamp:(e==null?void 0:e.defaultValue)||C.moment().startOf("day").valueOf(),handleDateStampChange:(r,a)=>{t(e.type==="icon"?C.moment(r).format("YYYY-MM-DD"):r.toString()),n&&n(!1)}})]})},kw=e=>{const{handleValueChange:t}=e,[n,r]=ne.useState(!1),a=ne.useRef(null),o=ne.useRef(null),i=Tb(o.current,a.current,{placement:"bottom-start"});return Pv(a,()=>{r(!1)}),v.jsxs(v.Fragment,{children:[v.jsx("span",{ref:c=>{o.current=c,c&&e.type==="icon"&&C.setIcon(c,"calendar")},className:`btn calendar-btn ${e.type==="icon"?"icon-btn":"text-btn"}`,onClick:()=>{!C.Platform.isMobile&&r(!n),!C.Platform.isMobile&&(i!=null&&i.update)&&(i==null||i.update()),C.Platform.isMobile&&new R6(ft.getState().app,e.type,t).open()},children:e.type==="text"&&e.defaultValue?e.defaultText?e.defaultText:C.moment(e.defaultValue,"x").subtract(e.startOrEnd==="end"?1:0,"days").format("YYYY/MM/DD"):""}),v.jsx("div",{className:`menu-btns-popup ${n?"":"hidden"}`,ref:a,style:i.styles.popper,children:v.jsx(L6,{type:e.defaultText?"icon":e.type,handleValueChange:t,setShownStatus:r})})]})};class R6 extends C.Modal{constructor(n,r,a){super(n);De(this,"root");De(this,"type");De(this,"handleValueChange");this.type=r,this.handleValueChange=a}onOpen(){const{contentEl:n}=this;this.root=Av(n),this.root.render(v.jsx(L6,{type:this.type,handleValueChange:this.handleValueChange.bind(this),setShownStatus:r=>{!r&&this.close()}}))}onClose(){var n;(n=this.root)==null||n.unmount()}}const KU=(e,t)=>(e%t+t)%t;class QU{constructor(t,n,r){De(this,"owner");De(this,"values");De(this,"suggestions");De(this,"selectedItem");De(this,"containerEl");this.owner=t,this.containerEl=n,n.on("click",".suggestion-item",this.onSuggestionClick.bind(this)),n.on("mousemove",".suggestion-item",this.onSuggestionMouseover.bind(this)),r.register([],"ArrowUp",a=>{if(!a.isComposing)return this.setSelectedItem(this.selectedItem-1,!0),!1}),r.register([],"ArrowDown",a=>{if(!a.isComposing)return this.setSelectedItem(this.selectedItem+1,!0),!1}),r.register([],"Enter",a=>{if(!a.isComposing)return this.useSelectedItem(a),!1})}onSuggestionClick(t,n){t.preventDefault();const r=this.suggestions.indexOf(n);this.setSelectedItem(r,!1),this.useSelectedItem(t)}onSuggestionMouseover(t,n){const r=this.suggestions.indexOf(n);this.setSelectedItem(r,!1)}setSuggestions(t){this.containerEl.empty();const n=[];t.forEach(r=>{const a=this.containerEl.createDiv("suggestion-item");this.owner.renderSuggestion(r,a),n.push(a)}),this.values=t,this.suggestions=n,this.setSelectedItem(0,!1)}useSelectedItem(t){const n=this.values[this.selectedItem];n&&this.owner.selectSuggestion(n,t)}setSelectedItem(t,n){const r=KU(t,this.suggestions.length),a=this.suggestions[this.selectedItem],o=this.suggestions[r];a==null||a.removeClass("is-selected"),o==null||o.addClass("is-selected"),this.selectedItem=r,n&&o.scrollIntoView(!1)}}class _6{constructor(t,n){De(this,"inputEl");De(this,"popper");De(this,"scope");De(this,"suggestEl");De(this,"suggest");De(this,"cb");this.inputEl=t,this.scope=new C.Scope,this.cb=n,this.suggestEl=createDiv("suggestion-container");const r=this.suggestEl.createDiv("suggestion");this.suggest=new QU(this,r,this.scope),this.scope.register([],"Escape",this.close.bind(this)),this.inputEl.addEventListener("input",this.onInputChanged.bind(this)),this.inputEl.addEventListener("focus",this.onInputChanged.bind(this)),this.inputEl.addEventListener("click",this.onInputChanged.bind(this)),this.inputEl.addEventListener("blur",this.close.bind(this)),this.suggestEl.on("mousedown",".suggestion-container",a=>{a.preventDefault()})}clearInput(){this.inputEl.value="",this.inputEl.trigger("blur"),this.inputEl.trigger("focus"),this.inputEl.trigger("input"),this.onInputChanged()}onInputChanged(){const t=this.inputEl.value,n=this.getSuggestions(t);if(!n){this.close();return}n.length>0?(this.suggest.setSuggestions(n),this.open(app.dom.appContainerEl,this.inputEl)):this.close()}open(t,n){app.keymap.pushScope(this.scope),t.appendChild(this.suggestEl),this.popper=j6(n,this.suggestEl,{placement:"bottom-start",modifiers:[{name:"sameWidth",enabled:!0,fn:({state:r,instance:a})=>{const o=`${r.rects.reference.width}px`;r.styles.popper.width!==o&&(r.styles.popper.width=o,a.update())},phase:"beforeWrite",requires:["computeStyles"]}]})}close(){app.keymap.popScope(this.scope),this.suggest.setSuggestions([]),this.popper&&this.popper.destroy(),this.suggestEl.detach()}destroy(){this.inputEl.removeEventListener("input",this.onInputChanged.bind(this)),this.inputEl.removeEventListener("focus",this.onInputChanged.bind(this)),this.inputEl.removeEventListener("blur",this.close.bind(this)),this.close()}updateCb(t){this.cb=t}}const XU=e=>{const t=e.metadataCache.getTags();return[...Object.keys(t)].map(n=>n.split("#").pop())};let Kg=class extends _6{fuzzySearchItemsOptimized(t,n){const r=C.prepareFuzzySearch(t);return n.map(a=>{const o=r(a);return o?{item:a,match:o,score:o.score}:null}).sort((a,o)=>(o==null?void 0:o.score)-(a==null?void 0:a.score)).filter(Boolean)}getSuggestions(t){const{settings:n,app:r}=ft.getState(),a=t.toLocaleLowerCase(),o=n.UseVaultTags?XU(r):be.getState().tags;return this.fuzzySearchItemsOptimized(a,o).map(i=>i.item)}renderSuggestion(t,n){n.toggleClass("thino-image-suggest-item",!0),n.createSpan({cls:"suggestion-name",text:t})}selectSuggestion(t){this.inputEl.value=t,this.cb&&this.cb(t),this.inputEl.dispatchEvent(new Event("change")),this.inputEl.trigger("change"),this.close()}};const ez=e=>{const t=new Set;return e.forEach(n=>{const r=new RegExp($r).exec(n.content),a=new RegExp(ua).exec(n.content);if(r)for(let o=1;o{const[t,n]=ne.useState([]),r=ne.useRef(null),a=ne.useRef(null);P.useEffect(()=>{if(a.current){if(r.current){r.current.updateCb(o);return}r.current=new Kg(a.current,o)}},[a.current,t]);const o=l=>{if(!l)return;const c=new Set(t);c.add(l),n(Array.from(c)),r.current.clearInput()},i=()=>{e(t)};return v.jsxs("div",{className:"thino-tag-operation",children:[v.jsx("div",{className:"tag-operation-title",children:E("Tag Bulk Select")}),v.jsxs("div",{className:"tag-operation-content",children:[v.jsxs("div",{className:"tag-operation-content-title selected-tags",children:[v.jsx("div",{className:"name",children:E("Selected Tags")}),v.jsx("div",{className:"desc",children:E("Click to remove selected tag")})]}),v.jsx("div",{className:"tag-operation-content-tags selected-tags",children:t.map(l=>v.jsx("div",{className:"tag-operation-content-tag",onClick:()=>{n(t.filter(c=>c!==l))},children:l},l))}),v.jsx("div",{className:"tag-operation-content-inputer",children:v.jsx("input",{placeholder:E("Input to select exist tag"),ref:a,onKeyDown:l=>{l.key==="Enter"&&o(a.current.value)}})}),v.jsxs("div",{className:"tag-operation-content-btn-group",children:[v.jsx("button",{className:"cancel-btn",onClick:()=>{e([])},children:E("Cancel")}),v.jsx("button",{className:"save-btn",onClick:i,children:E("Save")})]})]})]})},rz=({app:e,thinos:t,closeDialog:n})=>{const[r,a]=ne.useState([]),[o,i]=ne.useState([]),[l,c]=ne.useState([]),f=ne.useRef(null),p=ne.useRef(null),g=ne.useRef(null),y=ne.useRef("End"),w=ne.useRef(!1),T=ne.useRef(null);P.useEffect(()=>{t&&t.length&&a(ez(t))},[t]),P.useEffect(()=>{!g.current||!p.current||(new C.Setting(p.current).setName(E("Add tag position")).addDropdown(N=>{N.addOption("End",E("End")),N.addOption("Beginning",E("Beginning")),N.setValue("End").onChange(async _=>{y.current=_})}),new C.Setting(g.current).setName(E("Add tag with new line")).addToggle(N=>{N.setValue(!1).onChange(async _=>{w.current=_})}))},[]);const S=N=>{if(!N)return;const _=new Set(o);_.add(N),i(Array.from(_)),f.current.clearInput()};P.useEffect(()=>{if(T.current){if(f.current){f.current.updateCb(S);return}f.current=new Kg(T.current,S)}},[T.current,o]);const I=()=>{n(),M({remove:l,add:o,targetThinos:t})},M=async({remove:N,add:_,targetThinos:k})=>{const R=w.current||!1,L=[];for(const H of k){let U=H.content;for(const z of N)U=U.replace(new RegExp(`#${z}`,"g"),"");if(U=U.trim(),_.length>0&&(U=y.current==="Beginning"?`${_.map(z=>`#${z}`).join(" ")} ${R?`
-`:""}${U}`:`${U} ${R?`
-`:""}${_.map(z=>`#${z}`).join(" ")}`),H&&H.content!==U){const z=await be.updateMemo(H.id,U==null?void 0:U.trim());L.push(z)}}L.length>0&&be.editMemoBulk(L),L.length>0&&ot.clearQuery()};return v.jsxs("div",{className:"thino-tag-operation",children:[v.jsx("div",{className:"tag-operation-title",children:E("Tag Bulk Edit")}),v.jsxs("div",{className:"tag-operation-content",children:[r.length>0&&v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"tag-operation-content-title exist-tags",children:[v.jsx("div",{className:"name",children:E("Exist Tags")}),v.jsx("div",{className:"desc",children:E("Click to remove exist tag")})]}),v.jsx("div",{className:"tag-operation-content-tags exist-tags",children:r.map(N=>v.jsx("div",{className:ar("tag-operation-content-tag",l.includes(N)&&"tag-operation-content-tag-removed"),onClick:()=>{l.includes(N)||c([...l,N]),l.includes(N)&&c(l.filter(_=>_!==N)),o.includes(N)&&i(o.filter(_=>_!==N))},children:N},N))})]}),v.jsxs("div",{className:"tag-operation-content-title selected-tags",children:[v.jsx("div",{className:"name",children:E("Selected Tags")}),v.jsx("div",{className:"desc",children:E("Click to remove selected tag")})]}),v.jsx("div",{className:"tag-operation-content-tags selected-tags",children:o.map(N=>v.jsx("div",{className:"tag-operation-content-tag",onClick:()=>{i(o.filter(_=>_!==N))},children:N},N))}),v.jsx("div",{className:"tag-operation-content-inputer",children:v.jsx("input",{placeholder:E("Input to select exist tag"),ref:T,onKeyDown:N=>{N.key==="Enter"&&S(T.current.value)}})}),v.jsxs("div",{className:"tag-operation-settings",children:[v.jsx("div",{ref:p}),v.jsx("div",{ref:g})]}),v.jsxs("div",{className:"tag-operation-content-btn-group",children:[v.jsx("button",{className:"cancel-btn",onClick:n,children:E("Cancel")}),v.jsx("button",{className:"save-btn",onClick:I,children:E("Save")})]})]})]})},ST=new Map,yf=async(e,t=!0)=>{const{vault:n,metadataCache:r}=ft.getState().app;if(t&&ST.has(e))return Promise.resolve(ST.get(e));if(e.contains("data:image"))return e;let a;const o=await n.adapter.exists(C.normalizePath(e));let i="";try{if(!o&&!/(http|https)/g.test(e)&&!e.includes("data:image")){let l;if(e.startsWith("app://")){const c=C.normalizePath(decodeURIComponent(e).replace(C.Platform.resourcePathPrefix,"").replace(/\?(.*)$/,"").replace(C.normalizePath(app==null?void 0:app.vault.adapter.basePath),""));i=C.normalizePath(decodeURIComponent(c))}else{if(l=r.getFirstLinkpathDest(e,""),!l){new C.Notice(E("File not exist"));return}i=l.path}}else i=e}catch(l){console.error(l)}if(i){if(/(http|https)/g.test(i))if(i.startsWith("http://localhost")){let l=i;l=l.replace("http://localhost/_capacitor_file_",""),l=decodeURIComponent(l).replace(/\?(.*)$/,"").replace(app==null?void 0:app.vault.adapter.basePath,""),l=C.normalizePath(decodeURIComponent(l));const c=await n.adapter.readBinary(l),f=new Uint8Array(c);a=new Blob([f],{type:"image/png"})}else try{const l=await C.requestUrl(e),c=new Uint8Array(l.arrayBuffer);a=new Blob([c],{type:"image/png"})}catch{}else if(i){const l=await n.adapter.readBinary(i),c=new Uint8Array(l);a=new Blob([c],{type:"image/png"})}return a?await az(a,e):""}},az=(e,t)=>new Promise(n=>{const r=new FileReader;r.onloadend=()=>{const a=r.result;ST.set(t,a),n(a)},r.readAsDataURL(e)}),Fg=async e=>{if(!e.style.backgroundImage.includes("url(")&&!e.style.backgroundImage.includes("http"))return;let t=e.style.backgroundImage.includes("url(")?e.style.backgroundImage.slice(5,-2):e.style.backgroundImage;return t?(t.startsWith("http://localhost")&&(t=t.replace("http://localhost/_capacitor_file_",""),t=decodeURIComponent(t).replace(/\?(.*)$/,"").replace(app==null?void 0:app.vault.adapter.basePath,""),t=C.normalizePath(decodeURIComponent(t))),await yf(t)):void 0},oz=async e=>{var n;return e.getAttribute("src")?(n=e==null?void 0:e.src)!=null&&n.startsWith("http://localhost")?await yf(e.getAttribute("path")||C.normalizePath(e==null?void 0:e.parentElement.getAttribute("src"))):await yf(e.getAttribute("src")):void 0},Zt=mz(),Nw=gz(),B6=vz(),H6=yz(),Qd={copyDefaultStyles:!0,imagePlaceholder:void 0,cacheBust:!1,useCredentials:!1,httpTimeout:3e4,styleCaching:"strict",corsImg:void 0},yn={toSvg:Y6,toPng:lz,toJpeg:uz,toBlob:cz,toPixelData:sz,toCanvas:dz,impl:{fontFaces:B6,images:H6,util:Zt,inliner:Nw,urlCache:[],options:{}}},X2=(typeof Node<"u"?Node.ELEMENT_NODE:void 0)||1,rw=(typeof global<"u"?global.getComputedStyle:void 0)||(typeof window<"u"?window.getComputedStyle:void 0)||globalThis.getComputedStyle,iz=(typeof global<"u"?global.atob:void 0)||(typeof window<"u"?window.atob:void 0)||globalThis.atob;function Y6(e,t){yn.impl.util.getWindow(e),t=t||{},fz(t);let n=[];return Promise.resolve(e).then(r).then(function(c){return U6(c,t,null)}).then(hz).then(pz).then(i).then(l).then(a).then(o);function r(c){if(c.nodeType===X2)return c;const f=c,p=c.parentNode,g=document.createElement("span");return p.replaceChild(g,f),g.append(c),n.push({parent:p,child:f,wrapper:g}),g}function a(c){for(;n.length>0;){const f=n.pop();f.parent.replaceChild(f.child,f.wrapper)}return c}function o(c){return yn.impl.urlCache=[],Iz(),c}function i(c){t.bgcolor&&(c.style.backgroundColor=t.bgcolor),t.width&&(c.style.width=`${t.width}px`),t.height&&(c.style.height=`${t.height}px`),t.style&&Object.keys(t.style).forEach(function(p){c.style[p]=t.style[p]});let f=null;return typeof t.onclone=="function"&&(f=t.onclone(c)),Promise.resolve(f).then(function(){return c})}function l(c){let f=t.width||Zt.width(c),p=t.height||Zt.height(c);return Promise.resolve(c).then(function(g){return g.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),new XMLSerializer().serializeToString(g)}).then(Zt.escapeXhtml).then(function(g){const y=(Zt.isDimensionMissing(f)?' width="100%"':` width="${f}"`)+(Zt.isDimensionMissing(p)?' height="100%"':` height="${p}"`);return`${g} `}).then(function(g){return`data:image/svg+xml;charset=utf-8,${g}`})}}function sz(e,t){return Rv(e,t).then(function(n){return n.getContext("2d").getImageData(0,0,Zt.width(e),Zt.height(e)).data})}function lz(e,t){return Rv(e,t).then(function(n){return n.toDataURL()})}function uz(e,t){return Rv(e,t).then(function(n){return n.toDataURL("image/jpeg",(t?t.quality:void 0)||1)})}function cz(e,t){return Rv(e,t).then(Zt.canvasToBlob)}function dz(e,t){return Rv(e,t)}function fz(e){typeof e.copyDefaultStyles>"u"?yn.impl.options.copyDefaultStyles=Qd.copyDefaultStyles:yn.impl.options.copyDefaultStyles=e.copyDefaultStyles,typeof e.imagePlaceholder>"u"?yn.impl.options.imagePlaceholder=Qd.imagePlaceholder:yn.impl.options.imagePlaceholder=e.imagePlaceholder,typeof e.cacheBust>"u"?yn.impl.options.cacheBust=Qd.cacheBust:yn.impl.options.cacheBust=e.cacheBust,typeof e.corsImg>"u"?yn.impl.options.corsImg=Qd.corsImg:yn.impl.options.corsImg=e.corsImg,typeof e.useCredentials>"u"?yn.impl.options.useCredentials=Qd.useCredentials:yn.impl.options.useCredentials=e.useCredentials,typeof e.httpTimeout>"u"?yn.impl.options.httpTimeout=Qd.httpTimeout:yn.impl.options.httpTimeout=e.httpTimeout,typeof e.styleCaching>"u"?yn.impl.options.styleCaching=Qd.styleCaching:yn.impl.options.styleCaching=e.styleCaching,yn.impl.options.requestUrl=e.requestUrl,yn.impl.options.type=e.type||"image/png"}function Rv(e,t){return t=t||{},Y6(e,t).then(Zt.makeImage).then(function(r){const a=typeof t.scale!="number"?1:t.scale,o=n(e,a),i=o.getContext("2d");return i.msImageSmoothingEnabled=!1,i.imageSmoothingEnabled=!1,r&&(i.scale(a,a),i.drawImage(r,0,0)),o});function n(r,a){let o=t.width||Zt.width(r),i=t.height||Zt.height(r);Zt.isDimensionMissing(o)&&(o=Zt.isDimensionMissing(i)?300:i*2),Zt.isDimensionMissing(i)&&(i=o/2);const l=document.createElement("canvas");if(l.width=o*a,l.height=i*a,t.bgcolor){const c=l.getContext("2d");c.fillStyle=t.bgcolor,c.fillRect(0,0,l.width,l.height)}return l}}let xi=null;function U6(e,t,n,r){const a=t.filter;if(e===xi||Zt.isHTMLScriptElement(e)||Zt.isHTMLStyleElement(e)||Zt.isHTMLLinkElement(e)||n!==null&&a&&!a(e))return Promise.resolve();return Promise.resolve(e).then(o).then(function(f){return l(f,i(e))}).then(function(f){return c(f,e)});function o(f){return Zt.isHTMLCanvasElement(f)?Zt.makeImage(f.toDataURL()):f.cloneNode(!1)}function i(f){return Zt.isElementHostForOpenShadowRoot(f)?f.shadowRoot:f}function l(f,p){const g=T(p);let y=Promise.resolve();if(g.length!==0){const S=rw(w(p));Zt.asArray(g).forEach(function(I){y=y.then(function(){return U6(I,t,S).then(function(M){M&&f.appendChild(M)})})})}return y.then(function(){return f});function w(S){return Zt.isShadowRoot(S)?S.host:S}function T(S){return Zt.isShadowSlotElement(S)?S.assignedNodes():S.childNodes}}function c(f,p){if(!Zt.isElement(f)||Zt.isShadowSlotElement(p))return Promise.resolve(f);return Promise.resolve().then(g).then(y).then(w).then(T).then(function(){return f});function g(){I(p,f);function S(M,N){N.font=M.font,N.fontFamily=M.fontFamily,N.fontFeatureSettings=M.fontFeatureSettings,N.fontKerning=M.fontKerning,N.fontSize=M.fontSize,N.fontStretch=M.fontStretch,N.fontStyle=M.fontStyle,N.fontVariant=M.fontVariant,N.fontVariantCaps=M.fontVariantCaps,N.fontVariantEastAsian=M.fontVariantEastAsian,N.fontVariantLigatures=M.fontVariantLigatures,N.fontVariantNumeric=M.fontVariantNumeric,N.fontVariationSettings=M.fontVariationSettings,N.fontWeight=M.fontWeight}function I(M,N){const _=rw(M);_.cssText?(N.style.cssText=_.cssText,S(_,N.style)):(bz(t,M,_,n,N),n===null&&(["inset-block","inset-block-start","inset-block-end"].forEach(k=>N.style.removeProperty(k)),["left","right","top","bottom"].forEach(k=>{N.style.getPropertyValue(k)&&N.style.setProperty(k,"0px")})))}}function y(){const S=Zt.uid();[":before",":after"].forEach(function(M){I(M)});function I(M){const N=rw(p,M),_=N.getPropertyValue("content");if(_===""||_==="none")return;const k=f.getAttribute("class")||"";f.setAttribute("class",`${k} ${S}`);const R=document.createElement("style");R.appendChild(L()),f.appendChild(R);function L(){const H=`.${S}:${M}`,U=N.cssText?z():$();return document.createTextNode(`${H}{${U}}`);function z(){return`${N.cssText} content: ${_};`}function $(){return`${Zt.asArray(N).map(Q).join("; ")};`;function Q(se){const ue=N.getPropertyValue(se),fe=N.getPropertyPriority(se)?" !important":"";return`${se}: ${ue}${fe}`}}}}}function w(){Zt.isHTMLTextAreaElement(p)&&(f.innerHTML=p.value),Zt.isHTMLInputElement(p)&&f.setAttribute("value",p.value)}function T(){Zt.isSVGElement(f)&&(f.setAttribute("xmlns","http://www.w3.org/2000/svg"),Zt.isSVGRectElement(f)&&["width","height"].forEach(function(S){const I=f.getAttribute(S);I&&f.style.setProperty(S,I)}))}}}function hz(e){return B6.resolveAll().then(function(t){if(t!==""){const n=document.createElement("style");e.appendChild(n),n.appendChild(document.createTextNode(t))}return e})}function pz(e){return H6.inlineAll(e).then(function(){return e})}function mz(){let e=0;return{escape:z,isDataUrl:M,canvasToBlob:k,resolveUrl:R,getAndEncode:U,uid:L,delay:$,asArray:X,escapeXhtml:Q,makeImage:H,width:se,height:ue,getWindow:t,isElement:o,isElementHostForOpenShadowRoot:n,isShadowRoot:r,isInShadowRoot:a,isHTMLElement:l,isHTMLCanvasElement:i,isHTMLInputElement:f,isHTMLImageElement:c,isHTMLLinkElement:p,isHTMLScriptElement:g,isHTMLStyleElement:y,isHTMLTextAreaElement:w,isShadowSlotElement:T,isSVGElement:S,isSVGRectElement:I,isDimensionMissing:N};function t(Z){const pe=Z?Z.ownerDocument:void 0;return(pe?pe.defaultView:void 0)||global||window}function n(Z){return o(Z)&&Z.shadowRoot!==null}function r(Z){return Z instanceof t(Z).ShadowRoot}function a(Z){return Z!==null&&Object.prototype.hasOwnProperty.call(Z,"getRootNode")&&r(Z.getRootNode())}function o(Z){return Z instanceof t(Z).Element}function i(Z){return Z instanceof t(Z).HTMLCanvasElement}function l(Z){return Z instanceof t(Z).HTMLElement}function c(Z){return Z instanceof t(Z).HTMLImageElement}function f(Z){return Z instanceof t(Z).HTMLInputElement}function p(Z){return Z instanceof t(Z).HTMLLinkElement}function g(Z){return Z instanceof t(Z).HTMLScriptElement}function y(Z){return Z instanceof t(Z).HTMLStyleElement}function w(Z){return Z instanceof t(Z).HTMLTextAreaElement}function T(Z){return a(Z)&&Z instanceof t(Z).HTMLSlotElement}function S(Z){return Z instanceof t(Z).SVGElement}function I(Z){return Z instanceof t(Z).SVGRectElement}function M(Z){return Z.search(/^(data:)/)!==-1}function N(Z){return isNaN(Z)||Z<=0}function _(Z){return new Promise(function(pe){const ie=iz(Z.toDataURL().split(",")[1]),de=ie.length,K=new Uint8Array(de);for(let ae=0;aenew Promise(de=>{const K=new FileReader;K.onload=function(ae){de(ae.target.result)},K.readAsDataURL(new Blob([ie.arrayBuffer],{type:ie.headers["content-type"]}))})).catch(ie=>(console.error("cannot fetch resource: "+Z+", error: "+ie),"")):pe.promise=new Promise(function(ie){const de=yn.impl.options.httpTimeout,K=new XMLHttpRequest;if(K.onreadystatechange=Se,K.ontimeout=je,K.responseType="blob",K.timeout=de,yn.impl.options.useCredentials&&(K.withCredentials=!0),yn.impl.options.corsImg&&Z.indexOf("http")===0&&Z.indexOf(window.location.origin)===-1){const Be=(yn.impl.options.corsImg.method||"GET").toUpperCase()==="POST"?"POST":"GET";K.open(Be,(yn.impl.options.corsImg.url||"").replace("#{cors}",Z),!0);let Qe=!1;const Ze=yn.impl.options.corsImg.headers||{};Object.keys(Ze).forEach(function(xt){Ze[xt].indexOf("application/json")!==-1&&(Qe=!0),K.setRequestHeader(xt,Ze[xt])});const st=Re(yn.impl.options.corsImg.data||"");Object.keys(st).forEach(function(xt){typeof st[xt]=="string"&&(st[xt]=st[xt].replace("#{cors}",Z))}),K.send(Qe?JSON.stringify(st):st)}else K.open("GET",Z,!0),K.send();let ae;if(yn.impl.options.imagePlaceholder){const Be=yn.impl.options.imagePlaceholder.split(/,/);Be&&Be[1]&&(ae=Be[1])}function Se(){if(K.readyState!==4)return;if(K.status>=300){ae?ie(ae):Fe(`cannot fetch resource: ${Z}, status: ${K.status}`);return}const Be=new FileReader;Be.onloadend=function(){ie(Be.result)},Be.readAsDataURL(K.response)}function je(){ae?ie(ae):Fe(`timeout of ${de}ms occured while fetching resource: ${Z}`)}function Re(Be){try{return JSON.parse(JSON.stringify(Be))}catch{Fe("corsImg.data is missing or invalid");return}}function Fe(Be){console.error(Be),ie("")}})),pe.promise}function z(Z){return Z.replace(/([.*+?^${}()|[]\/\\])/g,"\\$1")}function $(Z){return function(pe){return new Promise(function(ie){setTimeout(function(){ie(pe)},Z)})}}function X(Z){const pe=[],ie=Z.length;for(let de=0;de=0;r?(e.setProperty(t,n,r),a&&e.setProperty(`-webkit-${t}`,n,r)):(e.setProperty(t,n),a&&e.setProperty(`-webkit-${t}`,n))}function bz(e,t,n,r,a){const o=yn.impl.options.copyDefaultStyles?Dz(e,t):{},i=a.style;Zt.asArray(n).forEach(function(l){const c=n.getPropertyValue(l),f=o[l],p=r?r.getPropertyValue(l):void 0;if(c!==f||r&&c!==p){const g=n.getPropertyPriority(l);wz(i,l,c,g)}})}let T0=null,aw={};const Sz=["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIALOG","DD","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SVG","TABLE","UL","math","svg","BODY","HEAD","HTML"];function Dz(e,t){const n=l(t),r=c(n);if(aw[r])return aw[r];const a=Tz(),o=f(a.document,n),i=p(a,o);return g(o),aw[r]=i,i;function l(y){const w=[];do{if(y.nodeType===X2){const T=y.tagName;if(w.push(T),Sz.includes(T))break}y=y.parentNode}while(y);return w}function c(y){return e.styleCaching==="relaxed"?y.filter((w,T,S)=>T===0||T===S.length-1).join(">"):y.join(">")}function f(y,w){let T=y.body;do{const S=w.pop(),I=y.createElement(S);T.appendChild(I),T=I}while(w.length>0);return T.textContent="",T}function p(y,w){const T={},S=y.getComputedStyle(w);return Zt.asArray(S).forEach(function(I){T[I]=I==="width"||I==="height"?"auto":S.getPropertyValue(I)}),T}function g(y){do{const w=y.parentElement;w!==null&&w.removeChild(y),y=w}while(y&&y.tagName!=="BODY")}}function Tz(){if(xi)return xi.contentWindow;const e=document.characterSet||"UTF-8",t=document.doctype,n=t?`":"";return xi=document.createElement("iframe"),xi.id="domtoimage-sandbox-"+Zt.uid(),xi.className="domtoimage-thino",xi.style.visibility="hidden",xi.style.position="fixed",document.body.appendChild(xi),a(xi,n,e,"domtoimage-sandbox");function r(o){if(o){const i=document.createElement("div");return i.innerText=o,i.innerHTML}else return""}function a(o,i,l,c){try{return o.contentWindow.document.write(`${i}${c} `),o.contentWindow}catch{}const f=document.createElement("meta");f.setAttribute("charset",l);try{const p=document.implementation.createHTMLDocument(c);p.head.appendChild(f);const g=i+p.documentElement.outerHTML;return o.setAttribute("srcdoc",g),o.contentWindow}catch{}return o.contentDocument.head.appendChild(f),o.contentDocument.title=c,o.contentWindow}}function Iz(){xi&&(document.body.removeChild(xi),xi=null),T0&&clearTimeout(T0),T0=setTimeout(()=>{T0=null,aw={}},20*1e3)}async function Ez(e,t,n){return await yn.toCanvas(e,{width:e.clientWidth,height:e.clientHeight,quality:1,scale:t?2:1,requestUrl:C.requestUrl,type:n})}const Ib=async(e,t)=>(await Ez(e,!0,"image/jpeg")).toDataURL(),MC=async e=>{e.startsWith("http")&&(e=await yf(e));const t=e.split("base64,")[1],n=db(t,"image/png");await z6(n),new C.Notice(E("Send to clipboard successfully"))},xz=async(e,t)=>{const n=await e.vault.adapter.exists(t);let r="";if(n)r=t;else{const l=e.metadataCache.getFirstLinkpathDest(t,"");if(!l){new C.Notice(E("File not exist"));return}r=l.path}const a=await e.vault.adapter.readBinary(r),o=new Uint8Array(a),i=new Blob([o],{type:"image/png"});await z6(i)},z6=async e=>{const t=new ClipboardItem({"image/png":e});await window.navigator.clipboard.write([t])},kC=1.1,NC=300,AC=20,Cz=({destroy:e,imgUrl:t,filepath:n,otherIMGEls:r,currentIndex:a})=>{const o=P.useRef(null),[i,l]=P.useState(-1),c=Le.getState().dailyNotesState.app,[f,p]=P.useState(a),[g,y]=P.useState(t),w={close:P.useRef(null),previous:P.useRef(null),next:P.useRef(null),decrease:P.useRef(null),increase:P.useRef(null),zoom:P.useRef(null),copy:P.useRef(null)};P.useEffect(()=>{!n&&!t||(C.setIcon(w.close.current,"x"),w.previous.current&&C.setIcon(w.previous.current,"arrow-left"),w.next.current&&C.setIcon(w.next.current,"arrow-right"),C.setIcon(w.decrease.current,"zoom-out"),C.setIcon(w.increase.current,"zoom-in"),C.setIcon(w.zoom.current,"circle"),C.setIcon(w.copy.current,"clipboard"))},[w]),P.useEffect(()=>{ut.getImageSize(g).then(({width:L})=>{l(L!==0?40:0)})},[g]);const T=()=>{let L=f-1;L<0&&(L=r.length-1),p(L),y(r[L].src)},S=()=>{let L=f+1;L>=r.length&&(L=0),p(L),y(r[L].src)},I=()=>{e()},M=()=>{i>30&&l(i-10)},N=()=>{l(i+10)},_=L=>{L.target!==o.current&&L.target===o.current.parentElement&&I()},k=L=>{if(L.ctrlKey){L.preventDefault();const H=o.current,U=L.nativeEvent.offsetX,z=L.nativeEvent.offsetY,$=U/H.clientWidth,X=z/H.clientHeight;let Q;L.deltaY>0?Q=i/kC:Q=i*kC,Q>NC?Q=NC:Q{if(g&&!n)await MC(t);else if(n){const H=r[f].parentElement.getAttribute("src");if(!H){await MC(g);return}await xz(c,H)}};return v.jsxs(v.Fragment,{children:[v.jsx("button",{ref:w.close,className:"btn close-btn",onClick:I}),v.jsxs("div",{className:"img-container internal-embed image-embed is-loaded",onClick:_,onWheel:k,children:[v.jsx("img",{className:i<=0?"hidden":"",ref:o,height:i+"%",src:g}),v.jsx("span",{className:"loading-text "+(i===-1?"":"hidden"),children:E("Image is loading...")}),v.jsx("span",{className:"loading-text "+(i===0?"":"hidden"),children:E("😟 Cannot load image, image link maybe broken")})]}),v.jsxs("div",{className:"action-btns-container",children:[r&&(r==null?void 0:r.length)>1&&v.jsxs(v.Fragment,{children:[v.jsx("button",{ref:w.previous,className:"btn",onClick:T}),v.jsx("button",{ref:w.next,className:"btn",onClick:S})]}),v.jsx("button",{ref:w.decrease,className:"btn",onClick:M}),v.jsx("button",{ref:w.increase,className:"btn",onClick:N}),v.jsx("button",{ref:w.zoom,className:"btn",onClick:()=>l(80)}),v.jsx("button",{ref:w.copy,className:"btn",onClick:R})]})]})};function Eb({imgUrl:e,filepath:t,otherIMGEls:n,currentIndex:r}){vb({className:"preview-image-dialog"},Cz,{...{imgUrl:e,otherIMGEls:n,currentIndex:r},filepath:t})}var Mz=class extends Error{constructor(e){super(`react-collapsed: ${e}`)}},Aw=(...e)=>(e[0],`${e[1]}`,void 0);function V6(e){const t=P.useRef(e);return P.useEffect(()=>{t.current=e}),P.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function kz(e,t,n){const[r,a]=P.useState(t),o=P.useRef(typeof e<"u"),i=o.current?e:r,l=V6(n),c=P.useCallback(f=>{const g=typeof f=="function"?f(i):f;o.current||a(g),l==null||l(g)},[l,i]);return P.useEffect(()=>{Aw(!(o.current&&e==null),"`isExpanded` state is changing from controlled to uncontrolled. useCollapse should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled collapse for the lifetime of the component. Check the `isExpanded` prop."),Aw(!(!o.current&&e!=null),"`isExpanded` state is changing from uncontrolled to controlled. useCollapse should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled collapse for the lifetime of the component. Check the `isExpanded` prop.")},[e]),[i,c]}var Nz="(prefers-reduced-motion: reduce)";function Az(){const[e,t]=P.useState(!1);return P.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia(Nz);t(n.matches);const r=a=>{t(a.matches)};if(n.addEventListener)return n.addEventListener("change",r),()=>{n.removeEventListener("change",r)};if(n.addListener)return n.addListener(r),()=>{n.removeListener(r)}},[]),e}var Fz=P7.useId||(()=>{});function Oz(){return Fz()??""}var Pz=typeof window<"u"?P.useLayoutEffect:P.useEffect,NS=!1,jz=0,FC=()=>++jz;function Lz(e){const t=e||(NS?FC():null),[n,r]=P.useState(t);return Pz(()=>{n===null&&r(FC())},[]),P.useEffect(()=>{NS===!1&&(NS=!0)},[]),n!=null?String(n):void 0}function Rz(e){const t=Oz(),n=Lz(e);return typeof e=="string"?e:typeof t=="string"?t:n}function _z(e,t){const n=performance.now(),r={};function a(){r.id=requestAnimationFrame(o=>{o-n>t?e():a()})}return a(),r}function OC(e){e.id&&cancelAnimationFrame(e.id)}function PC(e){return e!=null&&e.current?e.current.scrollHeight:(Aw(!0,"Was not able to find a ref to the collapse element via `getCollapseProps`. Ensure that the element exposes its `ref` prop. If it exposes the ref prop under a different name (like `innerRef`), use the `refKey` property to change it. Example:\n\nconst collapseProps = getCollapseProps({refKey: 'innerRef'})"),0)}function Bz(e){if(!e||typeof e=="string")return 0;const t=e/36;return Math.round((4+15*t**.25+t/5)*10)}function Hz(e,t){if(e!=null)if(typeof e=="function")e(t);else try{e.current=t}catch{throw new Mz(`Cannot assign value "${t}" to ref "${e}"`)}}function jC(...e){return e.every(t=>t==null)?null:t=>{e.forEach(n=>{Hz(n,t)})}}function Yz(e){let t=n=>{};t=n=>{if(!(n!=null&&n.current))return;const{paddingTop:r,paddingBottom:a}=window.getComputedStyle(n.current);Aw(!(r&&r!=="0px"||a&&a!=="0px"),`Padding applied to the collapse element will cause the animation to break and not perform as expected. To fix, apply equivalent padding to the direct descendent of the collapse element. Example:
+`+M},"");return e.reduce((g,y)=>{const w=t!=null&&t.ShowDate?`- [[${x.moment(y.date,"YYYY-MM-DD").format(n)}]]
+`:"",S=h(y.have),D=t!=null&&t.ShowDate&&(t!=null&&t.AddBlankLineWhenDate)&&!(t!=null&&t.CommentOnMemos)?`
+`:"";return g+w+S+D},"").replace(/ /g,`
+ `)},sz=[{label:E("Today"),value:x.moment().format("YYYY-MM-DD")},{label:E("Yesterday"),value:x.moment().subtract(1,"days").format("YYYY-MM-DD")},{label:E("Last 7 days"),value:x.moment().subtract(7,"days").format("YYYY-MM-DD")},{label:E("Last 30 days"),value:x.moment().subtract(30,"days").format("YYYY-MM-DD")},{label:E("Last 90 days"),value:x.moment().subtract(90,"days").format("YYYY-MM-DD")},{label:E("Last 180 days"),value:x.moment().subtract(180,"days").format("YYYY-MM-DD")},{label:E("Last 365 days"),value:x.moment().subtract(365,"days").format("YYYY-MM-DD")}],W6=e=>{const{handleValueChange:t,setShownStatus:n}=e;return v.jsxs(v.Fragment,{children:[e.type==="icon"&&v.jsx("div",{className:"quick-date-btn-group",children:sz.map((r,a)=>v.jsx("div",{className:"btn action-btn quick-date-btn",onClick:()=>{t(r.value),n&&n(!1)},children:r.label},a))}),v.jsx(Ib,{className:"calendar-date-picker",datestamp:(e==null?void 0:e.defaultValue)||x.moment().startOf("day").valueOf(),handleDateStampChange:(r,a)=>{t(e.type==="icon"?x.moment(r).format("YYYY-MM-DD"):r.toString()),n&&n(!1)}})]})},Fw=e=>{const{handleValueChange:t}=e,[n,r]=ne.useState(!1),a=ne.useRef(null),o=ne.useRef(null),i=Cb(o.current,a.current,{placement:"bottom-start"});return Rv(a,()=>{r(!1)}),v.jsxs(v.Fragment,{children:[v.jsx("span",{ref:c=>{o.current=c,c&&e.type==="icon"&&x.setIcon(c,"calendar")},className:`btn calendar-btn ${e.type==="icon"?"icon-btn":"text-btn"}`,onClick:()=>{!x.Platform.isMobile&&r(!n),!x.Platform.isMobile&&(i!=null&&i.update)&&(i==null||i.update()),x.Platform.isMobile&&new $6(ft.getState().app,e.type,t).open()},children:e.type==="text"&&e.defaultValue?e.defaultText?e.defaultText:x.moment(e.defaultValue,"x").subtract(e.startOrEnd==="end"?1:0,"days").format("YYYY/MM/DD"):""}),v.jsx("div",{className:`menu-btns-popup ${n?"":"hidden"}`,ref:a,style:i.styles.popper,children:v.jsx(W6,{type:e.defaultText?"icon":e.type,handleValueChange:t,setShownStatus:r})})]})};class $6 extends x.Modal{constructor(n,r,a){super(n);Se(this,"root");Se(this,"type");Se(this,"handleValueChange");this.type=r,this.handleValueChange=a}onOpen(){const{contentEl:n}=this;this.root=Pv(n),this.root.render(v.jsx(W6,{type:this.type,handleValueChange:this.handleValueChange.bind(this),setShownStatus:r=>{!r&&this.close()}}))}onClose(){var n;(n=this.root)==null||n.unmount()}}const lz=(e,t)=>(e%t+t)%t;class uz{constructor(t,n,r){Se(this,"owner");Se(this,"values");Se(this,"suggestions");Se(this,"selectedItem");Se(this,"containerEl");this.owner=t,this.containerEl=n,n.on("click",".suggestion-item",this.onSuggestionClick.bind(this)),n.on("mousemove",".suggestion-item",this.onSuggestionMouseover.bind(this)),r.register([],"ArrowUp",a=>{if(!a.isComposing)return this.setSelectedItem(this.selectedItem-1,!0),!1}),r.register([],"ArrowDown",a=>{if(!a.isComposing)return this.setSelectedItem(this.selectedItem+1,!0),!1}),r.register([],"Enter",a=>{if(!a.isComposing)return this.useSelectedItem(a),!1})}onSuggestionClick(t,n){t.preventDefault();const r=this.suggestions.indexOf(n);this.setSelectedItem(r,!1),this.useSelectedItem(t)}onSuggestionMouseover(t,n){const r=this.suggestions.indexOf(n);this.setSelectedItem(r,!1)}setSuggestions(t){this.containerEl.empty();const n=[];t.forEach(r=>{const a=this.containerEl.createDiv("suggestion-item");this.owner.renderSuggestion(r,a),n.push(a)}),this.values=t,this.suggestions=n,this.setSelectedItem(0,!1)}useSelectedItem(t){const n=this.values[this.selectedItem];n&&this.owner.selectSuggestion(n,t)}setSelectedItem(t,n){const r=lz(t,this.suggestions.length),a=this.suggestions[this.selectedItem],o=this.suggestions[r];a==null||a.removeClass("is-selected"),o==null||o.addClass("is-selected"),this.selectedItem=r,n&&o.scrollIntoView(!1)}}class Z6{constructor(t,n){Se(this,"inputEl");Se(this,"popper");Se(this,"scope");Se(this,"suggestEl");Se(this,"suggest");Se(this,"cb");this.inputEl=t,this.scope=new x.Scope,this.cb=n,this.suggestEl=createDiv("suggestion-container");const r=this.suggestEl.createDiv("suggestion");this.suggest=new uz(this,r,this.scope),this.scope.register([],"Escape",this.close.bind(this)),this.inputEl.addEventListener("input",this.onInputChanged.bind(this)),this.inputEl.addEventListener("focus",this.onInputChanged.bind(this)),this.inputEl.addEventListener("click",this.onInputChanged.bind(this)),this.inputEl.addEventListener("blur",this.close.bind(this)),this.suggestEl.on("mousedown",".suggestion-container",a=>{a.preventDefault()})}clearInput(){this.inputEl.value="",this.inputEl.trigger("blur"),this.inputEl.trigger("focus"),this.inputEl.trigger("input"),this.onInputChanged()}onInputChanged(){const t=this.inputEl.value,n=this.getSuggestions(t);if(!n){this.close();return}n.length>0?(this.suggest.setSuggestions(n),this.open(app.dom.appContainerEl,this.inputEl)):this.close()}open(t,n){app.keymap.pushScope(this.scope),t.appendChild(this.suggestEl),this.popper=V6(n,this.suggestEl,{placement:"bottom-start",modifiers:[{name:"sameWidth",enabled:!0,fn:({state:r,instance:a})=>{const o=`${r.rects.reference.width}px`;r.styles.popper.width!==o&&(r.styles.popper.width=o,a.update())},phase:"beforeWrite",requires:["computeStyles"]}]})}close(){app.keymap.popScope(this.scope),this.suggest.setSuggestions([]),this.popper&&this.popper.destroy(),this.suggestEl.detach()}destroy(){this.inputEl.removeEventListener("input",this.onInputChanged.bind(this)),this.inputEl.removeEventListener("focus",this.onInputChanged.bind(this)),this.inputEl.removeEventListener("blur",this.close.bind(this)),this.close()}updateCb(t){this.cb=t}}const cz=e=>{const t=e.metadataCache.getTags();return[...Object.keys(t)].map(n=>n.split("#").pop())};let ev=class extends Z6{fuzzySearchItemsOptimized(t,n){const r=x.prepareFuzzySearch(t);return n.map(a=>{const o=r(a);return o?{item:a,match:o,score:o.score}:null}).sort((a,o)=>(o==null?void 0:o.score)-(a==null?void 0:a.score)).filter(Boolean)}getSuggestions(t){const{settings:n,app:r}=ft.getState(),a=t.toLocaleLowerCase(),o=n.UseVaultTags?cz(r):be.getState().tags;return this.fuzzySearchItemsOptimized(a,o).map(i=>i.item)}renderSuggestion(t,n){n.toggleClass("thino-image-suggest-item",!0),n.createSpan({cls:"suggestion-name",text:t})}selectSuggestion(t){this.inputEl.value=t,this.cb&&this.cb(t),this.inputEl.dispatchEvent(new Event("change")),this.inputEl.trigger("change"),this.close()}};const dz=e=>{const t=new Set;return e.forEach(n=>{const r=new RegExp($r).exec(n.content),a=new RegExp(ua).exec(n.content);if(r)for(let o=1;o{const[t,n]=ne.useState([]),r=ne.useRef(null),a=ne.useRef(null);P.useEffect(()=>{if(a.current){if(r.current){r.current.updateCb(o);return}r.current=new ev(a.current,o)}},[a.current,t]);const o=l=>{if(!l)return;const c=new Set(t);c.add(l),n(Array.from(c)),r.current.clearInput()},i=()=>{e(t)};return v.jsxs("div",{className:"thino-tag-operation",children:[v.jsx("div",{className:"tag-operation-title",children:E("Tag Bulk Select")}),v.jsxs("div",{className:"tag-operation-content",children:[v.jsxs("div",{className:"tag-operation-content-title selected-tags",children:[v.jsx("div",{className:"name",children:E("Selected Tags")}),v.jsx("div",{className:"desc",children:E("Click to remove selected tag")})]}),v.jsx("div",{className:"tag-operation-content-tags selected-tags",children:t.map(l=>v.jsx("div",{className:"tag-operation-content-tag",onClick:()=>{n(t.filter(c=>c!==l))},children:l},l))}),v.jsx("div",{className:"tag-operation-content-inputer",children:v.jsx("input",{placeholder:E("Input to select exist tag"),ref:a,onKeyDown:l=>{l.key==="Enter"&&o(a.current.value)}})}),v.jsxs("div",{className:"tag-operation-content-btn-group",children:[v.jsx("button",{className:"cancel-btn",onClick:()=>{e([])},children:E("Cancel")}),v.jsx("button",{className:"save-btn",onClick:i,children:E("Save")})]})]})]})},pz=({app:e,thinos:t,closeDialog:n})=>{const[r,a]=ne.useState([]),[o,i]=ne.useState([]),[l,c]=ne.useState([]),f=ne.useRef(null),h=ne.useRef(null),g=ne.useRef(null),y=ne.useRef("End"),w=ne.useRef(!1),S=ne.useRef(null);P.useEffect(()=>{t&&t.length&&a(dz(t))},[t]),P.useEffect(()=>{!g.current||!h.current||(new x.Setting(h.current).setName(E("Add tag position")).addDropdown(N=>{N.addOption("End",E("End")),N.addOption("Beginning",E("Beginning")),N.setValue("End").onChange(async R=>{y.current=R})}),new x.Setting(g.current).setName(E("Add tag with new line")).addToggle(N=>{N.setValue(!1).onChange(async R=>{w.current=R})}))},[]);const D=N=>{if(!N)return;const R=new Set(o);R.add(N),i(Array.from(R)),f.current.clearInput()};P.useEffect(()=>{if(S.current){if(f.current){f.current.updateCb(D);return}f.current=new ev(S.current,D)}},[S.current,o]);const I=()=>{n(),M({remove:l,add:o,targetThinos:t})},M=async({remove:N,add:R,targetThinos:k})=>{const B=w.current||!1,L=[];for(const _ of k){let V=_.content;for(const Y of N)V=V.replace(new RegExp(`#${Y}`,"g"),"");if(V=V.trim(),R.length>0&&(V=y.current==="Beginning"?`${R.map(Y=>`#${Y}`).join(" ")} ${B?`
+`:""}${V}`:`${V} ${B?`
+`:""}${R.map(Y=>`#${Y}`).join(" ")}`),_&&_.content!==V){const Y=await be.updateMemo(_.id,V==null?void 0:V.trim());L.push(Y)}}L.length>0&&be.editMemoBulk(L),L.length>0&&at.clearQuery()};return v.jsxs("div",{className:"thino-tag-operation",children:[v.jsx("div",{className:"tag-operation-title",children:E("Tag Bulk Edit")}),v.jsxs("div",{className:"tag-operation-content",children:[r.length>0&&v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"tag-operation-content-title exist-tags",children:[v.jsx("div",{className:"name",children:E("Exist Tags")}),v.jsx("div",{className:"desc",children:E("Click to remove exist tag")})]}),v.jsx("div",{className:"tag-operation-content-tags exist-tags",children:r.map(N=>v.jsx("div",{className:ar("tag-operation-content-tag",l.includes(N)&&"tag-operation-content-tag-removed"),onClick:()=>{l.includes(N)||c([...l,N]),l.includes(N)&&c(l.filter(R=>R!==N)),o.includes(N)&&i(o.filter(R=>R!==N))},children:N},N))})]}),v.jsxs("div",{className:"tag-operation-content-title selected-tags",children:[v.jsx("div",{className:"name",children:E("Selected Tags")}),v.jsx("div",{className:"desc",children:E("Click to remove selected tag")})]}),v.jsx("div",{className:"tag-operation-content-tags selected-tags",children:o.map(N=>v.jsx("div",{className:"tag-operation-content-tag",onClick:()=>{i(o.filter(R=>R!==N))},children:N},N))}),v.jsx("div",{className:"tag-operation-content-inputer",children:v.jsx("input",{placeholder:E("Input to select exist tag"),ref:S,onKeyDown:N=>{N.key==="Enter"&&D(S.current.value)}})}),v.jsxs("div",{className:"tag-operation-settings",children:[v.jsx("div",{ref:h}),v.jsx("div",{ref:g})]}),v.jsxs("div",{className:"tag-operation-content-btn-group",children:[v.jsx("button",{className:"cancel-btn",onClick:n,children:E("Cancel")}),v.jsx("button",{className:"save-btn",onClick:I,children:E("Save")})]})]})]})},ET=new Map,wf=async(e,t=!0)=>{const{vault:n,metadataCache:r}=ft.getState().app;if(t&&ET.has(e))return Promise.resolve(ET.get(e));if(e.contains("data:image"))return e;let a;const o=await n.adapter.exists(x.normalizePath(e));let i="";try{if(!o&&!/(http|https)/g.test(e)&&!e.includes("data:image")){let l;if(e.startsWith("app://")){const c=x.normalizePath(decodeURIComponent(e).replace(x.Platform.resourcePathPrefix,"").replace(/\?(.*)$/,"").replace(x.normalizePath(app==null?void 0:app.vault.adapter.basePath),""));i=x.normalizePath(decodeURIComponent(c))}else{if(l=r.getFirstLinkpathDest(e,""),!l){new x.Notice(E("File not exist"));return}i=l.path}}else i=e}catch(l){console.error(l)}if(i){if(/(http|https)/g.test(i))if(i.startsWith("http://localhost")){let l=i;l=l.replace("http://localhost/_capacitor_file_",""),l=decodeURIComponent(l).replace(/\?(.*)$/,"").replace(app==null?void 0:app.vault.adapter.basePath,""),l=x.normalizePath(decodeURIComponent(l));const c=await n.adapter.readBinary(l),f=new Uint8Array(c);a=new Blob([f],{type:"image/png"})}else try{const l=await x.requestUrl(e),c=new Uint8Array(l.arrayBuffer);a=new Blob([c],{type:"image/png"})}catch{}else if(i){const l=await n.adapter.readBinary(i),c=new Uint8Array(l);a=new Blob([c],{type:"image/png"})}return a?await mz(a,e):""}},mz=(e,t)=>new Promise(n=>{const r=new FileReader;r.onloadend=()=>{const a=r.result;ET.set(t,a),n(a)},r.readAsDataURL(e)}),jg=async e=>{if(!e.style.backgroundImage.includes("url(")&&!e.style.backgroundImage.includes("http"))return;let t=e.style.backgroundImage.includes("url(")?e.style.backgroundImage.slice(5,-2):e.style.backgroundImage;return t?(t.startsWith("http://localhost")&&(t=t.replace("http://localhost/_capacitor_file_",""),t=decodeURIComponent(t).replace(/\?(.*)$/,"").replace(app==null?void 0:app.vault.adapter.basePath,""),t=x.normalizePath(decodeURIComponent(t))),await wf(t)):void 0},gz=async e=>{var n;return e.getAttribute("src")?(n=e==null?void 0:e.src)!=null&&n.startsWith("http://localhost")?await wf(e.getAttribute("path")||x.normalizePath(e==null?void 0:e.parentElement.getAttribute("src"))):await wf(e.getAttribute("src")):void 0},Zt=Cz(),Ow=xz(),q6=Mz(),G6=kz(),Xd={copyDefaultStyles:!0,imagePlaceholder:void 0,cacheBust:!1,useCredentials:!1,httpTimeout:3e4,styleCaching:"strict",corsImg:void 0},wn={toSvg:J6,toPng:wz,toJpeg:bz,toBlob:Sz,toPixelData:yz,toCanvas:Dz,impl:{fontFaces:q6,images:G6,util:Zt,inliner:Ow,urlCache:[],options:{}}},aI=(typeof Node<"u"?Node.ELEMENT_NODE:void 0)||1,iw=(typeof global<"u"?global.getComputedStyle:void 0)||(typeof window<"u"?window.getComputedStyle:void 0)||globalThis.getComputedStyle,vz=(typeof global<"u"?global.atob:void 0)||(typeof window<"u"?window.atob:void 0)||globalThis.atob;function J6(e,t){wn.impl.util.getWindow(e),t=t||{},Tz(t);let n=[];return Promise.resolve(e).then(r).then(function(c){return K6(c,t,null)}).then(Iz).then(Ez).then(i).then(l).then(a).then(o);function r(c){if(c.nodeType===aI)return c;const f=c,h=c.parentNode,g=document.createElement("span");return h.replaceChild(g,f),g.append(c),n.push({parent:h,child:f,wrapper:g}),g}function a(c){for(;n.length>0;){const f=n.pop();f.parent.replaceChild(f.child,f.wrapper)}return c}function o(c){return wn.impl.urlCache=[],jz(),c}function i(c){t.bgcolor&&(c.style.backgroundColor=t.bgcolor),t.width&&(c.style.width=`${t.width}px`),t.height&&(c.style.height=`${t.height}px`),t.style&&Object.keys(t.style).forEach(function(h){c.style[h]=t.style[h]});let f=null;return typeof t.onclone=="function"&&(f=t.onclone(c)),Promise.resolve(f).then(function(){return c})}function l(c){let f=t.width||Zt.width(c),h=t.height||Zt.height(c);return Promise.resolve(c).then(function(g){return g.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),new XMLSerializer().serializeToString(g)}).then(Zt.escapeXhtml).then(function(g){const y=(Zt.isDimensionMissing(f)?' width="100%"':` width="${f}"`)+(Zt.isDimensionMissing(h)?' height="100%"':` height="${h}"`);return`${g} `}).then(function(g){return`data:image/svg+xml;charset=utf-8,${g}`})}}function yz(e,t){return Hv(e,t).then(function(n){return n.getContext("2d").getImageData(0,0,Zt.width(e),Zt.height(e)).data})}function wz(e,t){return Hv(e,t).then(function(n){return n.toDataURL()})}function bz(e,t){return Hv(e,t).then(function(n){return n.toDataURL("image/jpeg",(t?t.quality:void 0)||1)})}function Sz(e,t){return Hv(e,t).then(Zt.canvasToBlob)}function Dz(e,t){return Hv(e,t)}function Tz(e){typeof e.copyDefaultStyles>"u"?wn.impl.options.copyDefaultStyles=Xd.copyDefaultStyles:wn.impl.options.copyDefaultStyles=e.copyDefaultStyles,typeof e.imagePlaceholder>"u"?wn.impl.options.imagePlaceholder=Xd.imagePlaceholder:wn.impl.options.imagePlaceholder=e.imagePlaceholder,typeof e.cacheBust>"u"?wn.impl.options.cacheBust=Xd.cacheBust:wn.impl.options.cacheBust=e.cacheBust,typeof e.corsImg>"u"?wn.impl.options.corsImg=Xd.corsImg:wn.impl.options.corsImg=e.corsImg,typeof e.useCredentials>"u"?wn.impl.options.useCredentials=Xd.useCredentials:wn.impl.options.useCredentials=e.useCredentials,typeof e.httpTimeout>"u"?wn.impl.options.httpTimeout=Xd.httpTimeout:wn.impl.options.httpTimeout=e.httpTimeout,typeof e.styleCaching>"u"?wn.impl.options.styleCaching=Xd.styleCaching:wn.impl.options.styleCaching=e.styleCaching,wn.impl.options.requestUrl=e.requestUrl,wn.impl.options.type=e.type||"image/png"}function Hv(e,t){return t=t||{},J6(e,t).then(Zt.makeImage).then(function(r){const a=typeof t.scale!="number"?1:t.scale,o=n(e,a),i=o.getContext("2d");return i.msImageSmoothingEnabled=!1,i.imageSmoothingEnabled=!1,r&&(i.scale(a,a),i.drawImage(r,0,0)),o});function n(r,a){let o=t.width||Zt.width(r),i=t.height||Zt.height(r);Zt.isDimensionMissing(o)&&(o=Zt.isDimensionMissing(i)?300:i*2),Zt.isDimensionMissing(i)&&(i=o/2);const l=document.createElement("canvas");if(l.width=o*a,l.height=i*a,t.bgcolor){const c=l.getContext("2d");c.fillStyle=t.bgcolor,c.fillRect(0,0,l.width,l.height)}return l}}let Ci=null;function K6(e,t,n,r){const a=t.filter;if(e===Ci||Zt.isHTMLScriptElement(e)||Zt.isHTMLStyleElement(e)||Zt.isHTMLLinkElement(e)||n!==null&&a&&!a(e))return Promise.resolve();return Promise.resolve(e).then(o).then(function(f){return l(f,i(e))}).then(function(f){return c(f,e)});function o(f){return Zt.isHTMLCanvasElement(f)?Zt.makeImage(f.toDataURL()):f.cloneNode(!1)}function i(f){return Zt.isElementHostForOpenShadowRoot(f)?f.shadowRoot:f}function l(f,h){const g=S(h);let y=Promise.resolve();if(g.length!==0){const D=iw(w(h));Zt.asArray(g).forEach(function(I){y=y.then(function(){return K6(I,t,D).then(function(M){M&&f.appendChild(M)})})})}return y.then(function(){return f});function w(D){return Zt.isShadowRoot(D)?D.host:D}function S(D){return Zt.isShadowSlotElement(D)?D.assignedNodes():D.childNodes}}function c(f,h){if(!Zt.isElement(f)||Zt.isShadowSlotElement(h))return Promise.resolve(f);return Promise.resolve().then(g).then(y).then(w).then(S).then(function(){return f});function g(){I(h,f);function D(M,N){N.font=M.font,N.fontFamily=M.fontFamily,N.fontFeatureSettings=M.fontFeatureSettings,N.fontKerning=M.fontKerning,N.fontSize=M.fontSize,N.fontStretch=M.fontStretch,N.fontStyle=M.fontStyle,N.fontVariant=M.fontVariant,N.fontVariantCaps=M.fontVariantCaps,N.fontVariantEastAsian=M.fontVariantEastAsian,N.fontVariantLigatures=M.fontVariantLigatures,N.fontVariantNumeric=M.fontVariantNumeric,N.fontVariationSettings=M.fontVariationSettings,N.fontWeight=M.fontWeight}function I(M,N){const R=iw(M);R.cssText?(N.style.cssText=R.cssText,D(R,N.style)):(Az(t,M,R,n,N),n===null&&(["inset-block","inset-block-start","inset-block-end"].forEach(k=>N.style.removeProperty(k)),["left","right","top","bottom"].forEach(k=>{N.style.getPropertyValue(k)&&N.style.setProperty(k,"0px")})))}}function y(){const D=Zt.uid();[":before",":after"].forEach(function(M){I(M)});function I(M){const N=iw(h,M),R=N.getPropertyValue("content");if(R===""||R==="none")return;const k=f.getAttribute("class")||"";f.setAttribute("class",`${k} ${D}`);const B=document.createElement("style");B.appendChild(L()),f.appendChild(B);function L(){const _=`.${D}:${M}`,V=N.cssText?Y():Z();return document.createTextNode(`${_}{${V}}`);function Y(){return`${N.cssText} content: ${R};`}function Z(){return`${Zt.asArray(N).map(K).join("; ")};`;function K(se){const le=N.getPropertyValue(se),fe=N.getPropertyPriority(se)?" !important":"";return`${se}: ${le}${fe}`}}}}}function w(){Zt.isHTMLTextAreaElement(h)&&(f.innerHTML=h.value),Zt.isHTMLInputElement(h)&&f.setAttribute("value",h.value)}function S(){Zt.isSVGElement(f)&&(f.setAttribute("xmlns","http://www.w3.org/2000/svg"),Zt.isSVGRectElement(f)&&["width","height"].forEach(function(D){const I=f.getAttribute(D);I&&f.style.setProperty(D,I)}))}}}function Iz(e){return q6.resolveAll().then(function(t){if(t!==""){const n=document.createElement("style");e.appendChild(n),n.appendChild(document.createTextNode(t))}return e})}function Ez(e){return G6.inlineAll(e).then(function(){return e})}function Cz(){let e=0;return{escape:Y,isDataUrl:M,canvasToBlob:k,resolveUrl:B,getAndEncode:V,uid:L,delay:Z,asArray:Q,escapeXhtml:K,makeImage:_,width:se,height:le,getWindow:t,isElement:o,isElementHostForOpenShadowRoot:n,isShadowRoot:r,isInShadowRoot:a,isHTMLElement:l,isHTMLCanvasElement:i,isHTMLInputElement:f,isHTMLImageElement:c,isHTMLLinkElement:h,isHTMLScriptElement:g,isHTMLStyleElement:y,isHTMLTextAreaElement:w,isShadowSlotElement:S,isSVGElement:D,isSVGRectElement:I,isDimensionMissing:N};function t($){const he=$?$.ownerDocument:void 0;return(he?he.defaultView:void 0)||global||window}function n($){return o($)&&$.shadowRoot!==null}function r($){return $ instanceof t($).ShadowRoot}function a($){return $!==null&&Object.prototype.hasOwnProperty.call($,"getRootNode")&&r($.getRootNode())}function o($){return $ instanceof t($).Element}function i($){return $ instanceof t($).HTMLCanvasElement}function l($){return $ instanceof t($).HTMLElement}function c($){return $ instanceof t($).HTMLImageElement}function f($){return $ instanceof t($).HTMLInputElement}function h($){return $ instanceof t($).HTMLLinkElement}function g($){return $ instanceof t($).HTMLScriptElement}function y($){return $ instanceof t($).HTMLStyleElement}function w($){return $ instanceof t($).HTMLTextAreaElement}function S($){return a($)&&$ instanceof t($).HTMLSlotElement}function D($){return $ instanceof t($).SVGElement}function I($){return $ instanceof t($).SVGRectElement}function M($){return $.search(/^(data:)/)!==-1}function N($){return isNaN($)||$<=0}function R($){return new Promise(function(he){const ie=vz($.toDataURL().split(",")[1]),ce=ie.length,X=new Uint8Array(ce);for(let ae=0;aenew Promise(ce=>{const X=new FileReader;X.onload=function(ae){ce(ae.target.result)},X.readAsDataURL(new Blob([ie.arrayBuffer],{type:ie.headers["content-type"]}))})).catch(ie=>(console.error("cannot fetch resource: "+$+", error: "+ie),"")):he.promise=new Promise(function(ie){const ce=wn.impl.options.httpTimeout,X=new XMLHttpRequest;if(X.onreadystatechange=De,X.ontimeout=je,X.responseType="blob",X.timeout=ce,wn.impl.options.useCredentials&&(X.withCredentials=!0),wn.impl.options.corsImg&&$.indexOf("http")===0&&$.indexOf(window.location.origin)===-1){const Be=(wn.impl.options.corsImg.method||"GET").toUpperCase()==="POST"?"POST":"GET";X.open(Be,(wn.impl.options.corsImg.url||"").replace("#{cors}",$),!0);let Xe=!1;const Ze=wn.impl.options.corsImg.headers||{};Object.keys(Ze).forEach(function(Ct){Ze[Ct].indexOf("application/json")!==-1&&(Xe=!0),X.setRequestHeader(Ct,Ze[Ct])});const st=Re(wn.impl.options.corsImg.data||"");Object.keys(st).forEach(function(Ct){typeof st[Ct]=="string"&&(st[Ct]=st[Ct].replace("#{cors}",$))}),X.send(Xe?JSON.stringify(st):st)}else X.open("GET",$,!0),X.send();let ae;if(wn.impl.options.imagePlaceholder){const Be=wn.impl.options.imagePlaceholder.split(/,/);Be&&Be[1]&&(ae=Be[1])}function De(){if(X.readyState!==4)return;if(X.status>=300){ae?ie(ae):Fe(`cannot fetch resource: ${$}, status: ${X.status}`);return}const Be=new FileReader;Be.onloadend=function(){ie(Be.result)},Be.readAsDataURL(X.response)}function je(){ae?ie(ae):Fe(`timeout of ${ce}ms occured while fetching resource: ${$}`)}function Re(Be){try{return JSON.parse(JSON.stringify(Be))}catch{Fe("corsImg.data is missing or invalid");return}}function Fe(Be){console.error(Be),ie("")}})),he.promise}function Y($){return $.replace(/([.*+?^${}()|[]\/\\])/g,"\\$1")}function Z($){return function(he){return new Promise(function(ie){setTimeout(function(){ie(he)},$)})}}function Q($){const he=[],ie=$.length;for(let ce=0;ce=0;r?(e.setProperty(t,n,r),a&&e.setProperty(`-webkit-${t}`,n,r)):(e.setProperty(t,n),a&&e.setProperty(`-webkit-${t}`,n))}function Az(e,t,n,r,a){const o=wn.impl.options.copyDefaultStyles?Oz(e,t):{},i=a.style;Zt.asArray(n).forEach(function(l){const c=n.getPropertyValue(l),f=o[l],h=r?r.getPropertyValue(l):void 0;if(c!==f||r&&c!==h){const g=n.getPropertyPriority(l);Nz(i,l,c,g)}})}let x0=null,sw={};const Fz=["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIALOG","DD","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SVG","TABLE","UL","math","svg","BODY","HEAD","HTML"];function Oz(e,t){const n=l(t),r=c(n);if(sw[r])return sw[r];const a=Pz(),o=f(a.document,n),i=h(a,o);return g(o),sw[r]=i,i;function l(y){const w=[];do{if(y.nodeType===aI){const S=y.tagName;if(w.push(S),Fz.includes(S))break}y=y.parentNode}while(y);return w}function c(y){return e.styleCaching==="relaxed"?y.filter((w,S,D)=>S===0||S===D.length-1).join(">"):y.join(">")}function f(y,w){let S=y.body;do{const D=w.pop(),I=y.createElement(D);S.appendChild(I),S=I}while(w.length>0);return S.textContent="",S}function h(y,w){const S={},D=y.getComputedStyle(w);return Zt.asArray(D).forEach(function(I){S[I]=I==="width"||I==="height"?"auto":D.getPropertyValue(I)}),S}function g(y){do{const w=y.parentElement;w!==null&&w.removeChild(y),y=w}while(y&&y.tagName!=="BODY")}}function Pz(){if(Ci)return Ci.contentWindow;const e=document.characterSet||"UTF-8",t=document.doctype,n=t?`":"";return Ci=document.createElement("iframe"),Ci.id="domtoimage-sandbox-"+Zt.uid(),Ci.className="domtoimage-thino",Ci.style.visibility="hidden",Ci.style.position="fixed",document.body.appendChild(Ci),a(Ci,n,e,"domtoimage-sandbox");function r(o){if(o){const i=document.createElement("div");return i.innerText=o,i.innerHTML}else return""}function a(o,i,l,c){try{return o.contentWindow.document.write(`${i}${c} `),o.contentWindow}catch{}const f=document.createElement("meta");f.setAttribute("charset",l);try{const h=document.implementation.createHTMLDocument(c);h.head.appendChild(f);const g=i+h.documentElement.outerHTML;return o.setAttribute("srcdoc",g),o.contentWindow}catch{}return o.contentDocument.head.appendChild(f),o.contentDocument.title=c,o.contentWindow}}function jz(){Ci&&(document.body.removeChild(Ci),Ci=null),x0&&clearTimeout(x0),x0=setTimeout(()=>{x0=null,sw={}},20*1e3)}async function Lz(e,t,n){return await wn.toCanvas(e,{width:e.clientWidth,height:e.clientHeight,quality:1,scale:t?2:1,requestUrl:x.requestUrl,type:n})}const xb=async(e,t)=>(await Lz(e,!0,"image/jpeg")).toDataURL(),Px=async e=>{e.startsWith("http")&&(e=await wf(e));const t=e.split("base64,")[1],n=pb(t,"image/png");await Q6(n),new x.Notice(E("Send to clipboard successfully"))},Rz=async(e,t)=>{const n=await e.vault.adapter.exists(t);let r="";if(n)r=t;else{const l=e.metadataCache.getFirstLinkpathDest(t,"");if(!l){new x.Notice(E("File not exist"));return}r=l.path}const a=await e.vault.adapter.readBinary(r),o=new Uint8Array(a),i=new Blob([o],{type:"image/png"});await Q6(i)},Q6=async e=>{const t=new ClipboardItem({"image/png":e});await window.navigator.clipboard.write([t])},jx=1.1,Lx=300,Rx=20,_z=({destroy:e,imgUrl:t,filepath:n,otherIMGEls:r,currentIndex:a})=>{const o=P.useRef(null),[i,l]=P.useState(-1),c=Le.getState().dailyNotesState.app,[f,h]=P.useState(a),[g,y]=P.useState(t),w={close:P.useRef(null),previous:P.useRef(null),next:P.useRef(null),decrease:P.useRef(null),increase:P.useRef(null),zoom:P.useRef(null),copy:P.useRef(null)};P.useEffect(()=>{!n&&!t||(x.setIcon(w.close.current,"x"),w.previous.current&&x.setIcon(w.previous.current,"arrow-left"),w.next.current&&x.setIcon(w.next.current,"arrow-right"),x.setIcon(w.decrease.current,"zoom-out"),x.setIcon(w.increase.current,"zoom-in"),x.setIcon(w.zoom.current,"circle"),x.setIcon(w.copy.current,"clipboard"))},[w]),P.useEffect(()=>{ut.getImageSize(g).then(({width:L})=>{l(L!==0?40:0)})},[g]);const S=()=>{let L=f-1;L<0&&(L=r.length-1),h(L),y(r[L].src)},D=()=>{let L=f+1;L>=r.length&&(L=0),h(L),y(r[L].src)},I=()=>{e()},M=()=>{i>30&&l(i-10)},N=()=>{l(i+10)},R=L=>{L.target!==o.current&&L.target===o.current.parentElement&&I()},k=L=>{if(L.ctrlKey){L.preventDefault();const _=o.current,V=L.nativeEvent.offsetX,Y=L.nativeEvent.offsetY,Z=V/_.clientWidth,Q=Y/_.clientHeight;let K;L.deltaY>0?K=i/jx:K=i*jx,K>Lx?K=Lx:K{if(g&&!n)await Px(t);else if(n){const _=r[f].parentElement.getAttribute("src");if(!_){await Px(g);return}await Rz(c,_)}};return v.jsxs(v.Fragment,{children:[v.jsx("button",{ref:w.close,className:"btn close-btn",onClick:I}),v.jsxs("div",{className:"img-container internal-embed image-embed is-loaded",onClick:R,onWheel:k,children:[v.jsx("img",{className:i<=0?"hidden":"",ref:o,height:i+"%",src:g}),v.jsx("span",{className:"loading-text "+(i===-1?"":"hidden"),children:E("Image is loading...")}),v.jsx("span",{className:"loading-text "+(i===0?"":"hidden"),children:E("😟 Cannot load image, image link maybe broken")})]}),v.jsxs("div",{className:"action-btns-container",children:[r&&(r==null?void 0:r.length)>1&&v.jsxs(v.Fragment,{children:[v.jsx("button",{ref:w.previous,className:"btn",onClick:S}),v.jsx("button",{ref:w.next,className:"btn",onClick:D})]}),v.jsx("button",{ref:w.decrease,className:"btn",onClick:M}),v.jsx("button",{ref:w.increase,className:"btn",onClick:N}),v.jsx("button",{ref:w.zoom,className:"btn",onClick:()=>l(80)}),v.jsx("button",{ref:w.copy,className:"btn",onClick:B})]})]})};function Mb({imgUrl:e,filepath:t,otherIMGEls:n,currentIndex:r}){bb({className:"preview-image-dialog"},_z,{...{imgUrl:e,otherIMGEls:n,currentIndex:r},filepath:t})}var Bz=class extends Error{constructor(e){super(`react-collapsed: ${e}`)}},Pw=(...e)=>(e[0],`${e[1]}`,void 0);function X6(e){const t=P.useRef(e);return P.useEffect(()=>{t.current=e}),P.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function Hz(e,t,n){const[r,a]=P.useState(t),o=P.useRef(typeof e<"u"),i=o.current?e:r,l=X6(n),c=P.useCallback(f=>{const g=typeof f=="function"?f(i):f;o.current||a(g),l==null||l(g)},[l,i]);return P.useEffect(()=>{Pw(!(o.current&&e==null),"`isExpanded` state is changing from controlled to uncontrolled. useCollapse should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled collapse for the lifetime of the component. Check the `isExpanded` prop."),Pw(!(!o.current&&e!=null),"`isExpanded` state is changing from uncontrolled to controlled. useCollapse should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled collapse for the lifetime of the component. Check the `isExpanded` prop.")},[e]),[i,c]}var Yz="(prefers-reduced-motion: reduce)";function Uz(){const[e,t]=P.useState(!1);return P.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia(Yz);t(n.matches);const r=a=>{t(a.matches)};if(n.addEventListener)return n.addEventListener("change",r),()=>{n.removeEventListener("change",r)};if(n.addListener)return n.addListener(r),()=>{n.removeListener(r)}},[]),e}var zz=WL.useId||(()=>{});function Vz(){return zz()??""}var Wz=typeof window<"u"?P.useLayoutEffect:P.useEffect,PS=!1,$z=0,_x=()=>++$z;function Zz(e){const t=e||(PS?_x():null),[n,r]=P.useState(t);return Wz(()=>{n===null&&r(_x())},[]),P.useEffect(()=>{PS===!1&&(PS=!0)},[]),n!=null?String(n):void 0}function qz(e){const t=Vz(),n=Zz(e);return typeof e=="string"?e:typeof t=="string"?t:n}function Gz(e,t){const n=performance.now(),r={};function a(){r.id=requestAnimationFrame(o=>{o-n>t?e():a()})}return a(),r}function Bx(e){e.id&&cancelAnimationFrame(e.id)}function Hx(e){return e!=null&&e.current?e.current.scrollHeight:(Pw(!0,"Was not able to find a ref to the collapse element via `getCollapseProps`. Ensure that the element exposes its `ref` prop. If it exposes the ref prop under a different name (like `innerRef`), use the `refKey` property to change it. Example:\n\nconst collapseProps = getCollapseProps({refKey: 'innerRef'})"),0)}function Jz(e){if(!e||typeof e=="string")return 0;const t=e/36;return Math.round((4+15*t**.25+t/5)*10)}function Kz(e,t){if(e!=null)if(typeof e=="function")e(t);else try{e.current=t}catch{throw new Bz(`Cannot assign value "${t}" to ref "${e}"`)}}function Yx(...e){return e.every(t=>t==null)?null:t=>{e.forEach(n=>{Kz(n,t)})}}function Qz(e){let t=n=>{};t=n=>{if(!(n!=null&&n.current))return;const{paddingTop:r,paddingBottom:a}=window.getComputedStyle(n.current);Pw(!(r&&r!=="0px"||a&&a!=="0px"),`Padding applied to the collapse element will cause the animation to break and not perform as expected. To fix, apply equivalent padding to the direct descendent of the collapse element. Example:
Before: {children}
@@ -199,15 +199,15 @@ After: `)},P.useEffect(()=>{t(e)},[e])}var Uz=typeof window>"u"?P.useEffect:P.useLayoutEffect;function zz({duration:e,easing:t="cubic-bezier(0.4, 0, 0.2, 1)",onTransitionStateChange:n=()=>{},isExpanded:r,defaultExpanded:a=!1,hasDisabledAnimation:o,id:i,...l}={}){const c=V6(n),f=Rz(i?`${i}`:void 0),[p,g]=kz(r,a),y=P.useRef(p),[w,T]=P.useState(!1),S=Az(),I=o??S,M=P.useRef(),N=P.useRef(),_=P.useRef(null),[k,R]=P.useState(null);Yz(_);const L=`${l.collapsedHeight||0}px`;function H(U){if(!_.current)return;const z=_.current;for(const $ in U){const X=U[$];X?z.style[$]=X:z.style.removeProperty($)}}return Uz(()=>{if(!_.current||p===y.current)return;y.current=p;function z(Q){return I?0:e??Bz(Q)}const $=Q=>`height ${z(Q)}ms ${t}`,X=Q=>{function se(){p?(H({height:"",overflow:"",transition:"",display:""}),c("expandEnd")):(H({transition:""}),c("collapseEnd")),T(!1)}N.current&&OC(N.current),N.current=_z(se,Q)};return T(!0),p?M.current=requestAnimationFrame(()=>{c("expandStart"),H({display:"block",overflow:"hidden",height:L}),M.current=requestAnimationFrame(()=>{c("expanding");const Q=PC(_);X(z(Q)),_.current&&(_.current.style.transition=$(Q),_.current.style.height=`${Q}px`)})}):M.current=requestAnimationFrame(()=>{c("collapseStart");const Q=PC(_);X(z(Q)),H({transition:$(Q),height:`${Q}px`}),M.current=requestAnimationFrame(()=>{c("collapsing"),H({height:L,overflow:"hidden"})})}),()=>{M.current&&cancelAnimationFrame(M.current),N.current&&OC(N.current)}},[p,L,I,e,t,c]),{isExpanded:p,setExpanded:g,getToggleProps(U){const{disabled:z,onClick:$,refKey:X,...Q}={refKey:"ref",onClick(){},disabled:!1,...U},se=k?k.tagName==="BUTTON":void 0,ue=U==null?void 0:U[X||"ref"],fe={id:`react-collapsed-toggle-${f}`,"aria-controls":`react-collapsed-panel-${f}`,"aria-expanded":p,onClick(ie){z||($==null||$(ie),g(de=>!de))},[X||"ref"]:jC(ue,R)},Z={type:"button",disabled:z?!0:void 0},pe={"aria-disabled":z?!0:void 0,role:"button",tabIndex:z?-1:0};return se===!1?{...fe,...pe,...Q}:se===!0?{...fe,...Z,...Q}:{...fe,...Z,...pe,...Q}},getCollapseProps(U){const{style:z,refKey:$}={refKey:"ref",style:{},...U},X=U==null?void 0:U[$||"ref"];return{id:`react-collapsed-panel-${f}`,"aria-hidden":!p,"aria-labelledby":`react-collapsed-toggle-${f}`,role:"region",...U,[$||"ref"]:jC(_,X),style:{boxSizing:"border-box",...!w&&!p?{display:L==="0px"?"none":"block",height:L,overflow:"hidden"}:{},...z}}}}}const Vz=e=>{const{dailyNotesState:{app:t,view:n,settings:r},globalState:{memoListView:a}}=P.useContext(Lt),{getCollapseProps:o,getToggleProps:i,isExpanded:l,setExpanded:c}=zz({defaultExpanded:!0,collapsedHeight:(r==null?void 0:r.ThinoCollapsedHeight)??100}),{memo:f,handleMemoContentClick:p,handleMemoDoubleClick:g}=e,y=ne.useRef(null),[w,T]=ne.useState(""),S=ne.useRef(w),I=ne.useRef(0),[M,N]=ne.useState(!1),[_,k]=ne.useState(!1),R=C.debounce((H,U,z)=>{for(const $ of H){const{height:X}=$.contentRect,Q=(U==null?void 0:U.ThinoMaxHeight)||340,se=X>Q;N(se),c(!se),z.disconnect()}},500);P.useEffect(()=>{var H;if(f.content!==S.current){if(r!=null&&r.OptimizeForCallout&&f.content.split("> [!").length>3&&f.content.split(`
-`).length>10&&!_){const U=y.current.createEl("button");U.setText(E("Render content")),U.onclick=async()=>{k(!0),await L()};const z=y.current.createEl("textarea");z.setText(f.content),z.disabled=!0,(H=y.current)==null||H.toggleClass(["raw-content"],!0),c(!0),N(!1);return}L()}},[f.content]),P.useEffect(()=>{_&&I.current!==(r==null?void 0:r.ThinoMaxHeight)&&(y!=null&&y.current.hasChildNodes()&&k(!1),L())},[r==null?void 0:r.ThinoMaxHeight]),P.useEffect(()=>{if(!_)return;const H=y.current;if(!H)return;if(!(r!=null&&r.ThinoMaxHeight)){c(!0),N(!1);return}const U=new ResizeObserver(z=>{R(z,r,U)});return U.observe(H),()=>U.disconnect()},[_]);const L=async()=>{var H,U;y.current&&n&&t&&f.content!==S.current&&(y.current.empty(),await C.MarkdownRenderer.render(t,f.content,y.current,f.path,n),S.current=f.content,(H=y.current)==null||H.toggleClass(["markdown-rendered"],!0),(U=y.current)==null||U.toggleClass(["raw-content"],!1),k&&k(!0),I.current=(r==null?void 0:r.ThinoMaxHeight)||340)};return v.jsxs(v.Fragment,{children:[M&&a==="moments"&&v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"thino-collapse-button",...i({style:{display:"block",marginTop:2}}),children:E(l?"Collapse":"Expand")}),!l&&(r==null?void 0:r.ThinoCollapsedHeight)!==0&&v.jsx("div",{className:"thino-collapse-shadowOverlay",onDoubleClick:g})]}),v.jsx("div",{...o({style:{margin:0}}),ref:y,className:"memo-content-text",onClick:H=>p(H,f),onDoubleClick:g,onContextMenu:H=>{H.preventDefault()}}),M&&a!=="moments"&&v.jsxs(v.Fragment,{children:[!l&&(r==null?void 0:r.ThinoCollapsedHeight)!==0&&v.jsx("div",{className:"thino-collapse-shadowOverlay",onDoubleClick:g}),v.jsx("button",{className:"thino-collapse-button",...i({style:{display:"block",marginTop:2}}),children:E(l?"Collapse":"Expand")})]})]})},W6=P.memo(Vz,(e,t)=>e.memo.content===t.memo.content),Wz=e=>{const[t,n]=P.useState({...e.memo,createdAtStr:ut.getDateTimeString(e.memo.createdAt)}),[r,a]=P.useState([]),[o,i]=P.useState([]);P.useEffect(()=>{(async()=>{try{const g=[],y=[...t.content.matchAll(nd)];for(const T of y)if(T&&T.length===3){const S=T[2],I=be.getMemoById(S);I&&g.push({...I,createdAtStr:ut.getDateTimeString(I.createdAt),dateStr:ut.getDateString(I.createdAt)})}a([...g]);const w=await be.getLinkedMemos(t.id);i(w.sort((T,S)=>ut.getTimeStampByDate(S.createdAt)-ut.getTimeStampByDate(T.createdAt)).map(T=>({...T,createdAtStr:ut.getDateTimeString(T.createdAt),dateStr:ut.getDateString(T.createdAt)})))}catch(g){console.error(g)}})()},[t.id]);const l=P.useCallback(async p=>{var y;const g=p.target;if(g.className==="memo-link-text"){const w=(y=g.dataset)==null?void 0:y.value,T=be.getMemoById(w??"");if(T){const S={...T,createdAtStr:ut.getDateTimeString(T.createdAt)};a([]),i([]),n(S)}else new C.Notice(E("Thino not found")),g.classList.remove("memo-link-text")}},[]),c=P.useCallback(p=>{a([]),i([]),n({...p,createdAtStr:ut.getDateTimeString(p.createdAt)})},[t.id]),f=P.useCallback(()=>{e.destroy(),dt.setEditMemoId(t.id)},[t.id]);return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"memo-card-container",children:[v.jsxs("div",{className:"header-container",children:[v.jsx("span",{className:"time-text",children:t.createdAtStr}),v.jsxs("div",{className:"btns-container",children:[v.jsx("button",{ref:p=>{p&&C.setIcon(p,"edit")},className:"btn edit-btn",onClick:f}),v.jsx("button",{ref:p=>{p&&C.setIcon(p,"x")},className:"btn close-btn",onClick:e.destroy})]})]}),v.jsx("div",{className:"memo-container",children:v.jsx("div",{className:"memo-content-text",children:v.jsx(W6,{memo:t,handleMemoContentClick:l,handleMemoDoubleClick:()=>{}})})}),v.jsx("div",{className:"layer-container"})]}),r.length>0?v.jsxs("div",{className:"linked-memos-wrapper",children:[v.jsxs("span",{className:"normal-text",children:[E("LINKED")," ",r.length," THINO"," "]}),r.map(p=>{const g=Tx(oT(p.content)).replaceAll(`
-`," ");return v.jsxs("div",{className:"linked-memo-container",onClick:()=>c(p),children:[v.jsxs("span",{className:"time-text",children:[p.dateStr," "]}),g]},p.id)})]}):null,o.length>0?v.jsxs("div",{className:"linked-memos-wrapper",children:[v.jsxs("span",{className:"normal-text",children:[o.length," THINO ",E("LINK TO THE")," THINO"]}),o.map(p=>{const g=Tx(oT(p.content)).replaceAll(`
-`," ");return v.jsxs("div",{className:"linked-memo-container",onClick:()=>c(p),children:[v.jsxs("span",{className:"time-text",children:[p.dateStr," "]}),g]},p.id)})]}):null]})};function Hp(e){vb({className:"memo-card-dialog"},Wz,{memo:e})}function $z({mouseEnterDelayMS:e=0,mouseLeaveDelayMS:t=0}={}){const[n,r]=P.useState(!1);let a,o;return[n,{onMouseEnter:()=>{clearTimeout(o),a=window.setTimeout(()=>r(!0),e)},onMouseLeave:()=>{clearTimeout(a),o=window.setTimeout(()=>r(!1),t)}}]}const Zz=e=>{const{memo:t,handlePinMemoClick:n,handleFixMemoClick:r,handleSourceMemoClick:a,handleShowMemoStoryDialog:o,handleCopyMemoClick:i,handleEditMemoClick:l,handleGenMemoImageBtnClick:c,handleMarkMemoClick:f,handleArchiveMemo:p,handleDeleteMemoClick:g,handleSplitMemoClick:y}=e,w=Le.getState().dailyNotesState.settings,T=w.EnabledLocationList.find(z=>z.value==="MULTI"),[S,I]=Jl(!1),M=P.useRef(null),N={pinRef:P.useRef(null),fixRef:P.useRef(null),typeRef:P.useRef(null),moreRef:P.useRef(null)},[_,k]=$z({mouseEnterDelayMS:500}),R=P.useRef();P.useEffect(()=>{if(!N.typeRef)return;const z=$g.find($=>$.title===t.sourceType);C.setIcon(N.typeRef.current,z.icon),C.requireApiVersion("1.4.4")&&C.setTooltip(N.typeRef.current,t.path),N.fixRef&&(C.setIcon(N.fixRef.current,"shield-alert"),C.requireApiVersion("1.4.4")&&C.setTooltip(N.fixRef.current,"Update Thino property"))},[N.typeRef]),P.useEffect(()=>{N.pinRef&&(t.pinned?(C.setIcon(N.pinRef.current,"pin-off"),C.requireApiVersion("1.4.4")&&C.setTooltip(N.pinRef.current,E("UNPIN"))):(C.setIcon(N.pinRef.current,"pin"),C.requireApiVersion("1.4.4")&&C.setTooltip(N.pinRef.current,E("PIN"))))},[N.pinRef,t.pinned]);const L=C.debounce(()=>{var z;if(_&&N.moreRef.current){if(R.current&&R.current._loaded||(z=R.current)!=null&&z.useNativeMenu||document.body.find(".more-action-btns-wrapper"))return;const $=H(),X=N.moreRef.current.getBoundingClientRect();$.showAtPosition({x:X.left,y:X.bottom})}},200);P.useEffect(()=>{L()},[_]);const H=()=>{var $;const z=new C.Menu;return z.dom.toggleClass(["more-action-btns-wrapper"],!0),z.useNativeMenu?(z.setNoIcon(),z.addItem(X=>{X.setTitle(E("COPY")).onClick(i)}),z.addItem(X=>{X.setTitle(E("EDIT")).onClick(l)}),z.addItem(X=>{X.setTitle(E("SHARE")).onClick(c)})):z.addItem(X=>{const Q=X.dom;X.dom.empty(),X.dom.toggleClass(["more-action-btn-group","more-action-menu-item"],!0);const se=Q.createEl("span");new C.ExtraButtonComponent(se).setIcon("copy"),se.toggleClass(["menu-item-icon","more-action-item-icon"],!0),se.onclick=Z=>{Z.stopPropagation(),Z.preventDefault(),i(),z.close()};const ue=Q.createEl("span");ue.toggleClass(["menu-item-icon","more-action-item-icon"],!0),ue.onclick=Z=>{Z.stopPropagation(),Z.preventDefault(),l(),z.close()},new C.ExtraButtonComponent(ue).setIcon("pencil");const fe=Q.createEl("span");fe.toggleClass(["menu-item-icon","more-action-item-icon"],!0),fe.onclick=Z=>{Z.stopPropagation(),Z.preventDefault(),c(),z.close()},new C.ExtraButtonComponent(fe).setIcon("share-2")}),z.addSeparator(),z.addItem(X=>{X.setIcon("book-open").setTitle(E("READ")).onClick(o)}),z.addItem(X=>{X.setIcon("bookmark").setTitle(E("MARK")).onClick(f)}),(($=/(^|\n)#{1,6}\s/g.exec(t.content))==null?void 0:$.length)>1&&T&&z.addItem(X=>{X.setIcon("separator-horizontal").setTitle(E("SPLIT")).onClick(y)}),z.addItem(X=>{X.setIcon("home").setTitle(E("SOURCE")).onClick(()=>a(t))}),z.addSeparator(),z.addItem(X=>{X.setWarning(!0).setIcon("archive").setTitle(E("ARCHIVE").toUpperCase()).onClick(()=>p(t))}),z.addItem(X=>{X.setWarning(!0).setIcon("trash").setTitle(w.DeleteThinoDirectly?E("DELETE"):E("TRASH BOX").toUpperCase().toUpperCase()).onClick(Q=>{if(z.useNativeMenu)g(Q),z.close();else if(Q.stopPropagation(),Q.preventDefault(),!S){I(!0),X.setTitle(E("CONFIRM!")).onClick(se=>{g(se),z.close()});return}})}),z.addSeparator(),z.addItem(X=>{X.setDisabled(!0).setTitle(ut.getWordCount(t.content.replace(/```[^\S\r\n]*[a-z]*\n.*?\n```/g,""))+` ${E("words")}`)}),z.onHide(()=>{I(!1)}),R.current=z,z},U=z=>{H().showAtMouseEvent(z.nativeEvent)};return v.jsx("div",{ref:M,className:"memo-top-right-wrapper",children:v.jsxs("div",{className:"btns-container",children:[v.jsx("span",{ref:N.fixRef,className:`btn ${t.sourceType!=="MULTI"||t.id!==""?"hidden":""} fix-memo-btn`,onClick:()=>r(t)}),v.jsx("span",{ref:N.typeRef,className:`btn ${t.sourceType==="DAILY"?"hidden":""} source-type-btn`,onClick:()=>a(t)}),v.jsx("span",{ref:N.pinRef,className:`btn ${e.memo.pinned?"pinned-btn":"unpinned-btn"} pro`,onClick:n}),v.jsx("span",{...k,ref:z=>{N.moreRef.current=z,z&&C.setIcon(z,"more-horizontal")},onClick:U,className:"btn more-action-btn"})]})})},qz=e=>{var o;const{memo:t,handleMemoTypeToggle:n,handleShowMemoStoryDialog:r,settings:a}=e;return v.jsxs("div",{className:"memo-top-left-wrapper",children:[e.children,v.jsx("span",{title:t.createdAt,className:"time-text",onClick:r,children:t.createdAt}),v.jsx("div",{className:`btn memo-type-img ${a!=null&&a.ShowTaskLabel?"":"hidden"}`,onClick:n,children:t.thinoType!=="JOURNAL"&&v.jsx("input",{className:"task-list-item-checkbox",type:"checkbox",checked:t.thinoType!=="TASK-TODO","data-task":t.thinoType==="TASK-TODO"?"":t.thinoType==="TASK-DONE"?"x":(o=t.thinoType)==null?void 0:o.slice(5)})})]})};class Gz extends C.SuggestModal{constructor(t,n){super(t),this.thino=n}sanitisedFileName(t){const n=JL;return t.replace(n,"").trim().slice(0,255)}ensureUniqueFileNames(t){const n=[];return t.map(a=>{const o=this.sanitisedFileName(a[0]),i=n.filter(l=>l==o);return n.push(o),i.length>=1?`${o}${i.length+1}`:o})}contentSplitByHeading(t,n){const r=t.split(`
-`),a=new Array(n).join("#")+" ",o=new Array(n+1).join("#")+" ",i=[];let l=[];return r.forEach((c,f)=>{c.startsWith(o)?(l.length>0&&(i.push(l),l=[]),l.push(c)):l.length>0&&!c.startsWith(a)?l.push(c):l.length>0&&(i.push(l),l=[]),f===r.length-1&&l.length>0&&i.push(l)}),i}onChooseSuggestion(t,n){this.selectSuggestion(t,n)}renderSuggestion(t,n){n.setText(t.title)}getSuggestions(){return[{id:"splitByHeading1",title:E("Split by Heading 1")},{id:"splitByHeading2",title:E("Split by Heading 2")},{id:"splitByHeading3",title:E("Split by Heading 3")}]}async selectSuggestion(t,n){let r=[];if(t.id==="splitByHeading1"?r=this.contentSplitByHeading(this.thino.content,1):t.id==="splitByHeading2"?r=this.contentSplitByHeading(this.thino.content,2):t.id==="splitByHeading3"&&(r=this.contentSplitByHeading(this.thino.content,3)),r.length===0){new C.Notice("No headings found"),this.close();return}const a=this.ensureUniqueFileNames(r);for(const l of r){const c=r.indexOf(l),f=await be.createThino({content:l.join(`
+ `)},P.useEffect(()=>{t(e)},[e])}var Xz=typeof window>"u"?P.useEffect:P.useLayoutEffect;function eV({duration:e,easing:t="cubic-bezier(0.4, 0, 0.2, 1)",onTransitionStateChange:n=()=>{},isExpanded:r,defaultExpanded:a=!1,hasDisabledAnimation:o,id:i,...l}={}){const c=X6(n),f=qz(i?`${i}`:void 0),[h,g]=Hz(r,a),y=P.useRef(h),[w,S]=P.useState(!1),D=Uz(),I=o??D,M=P.useRef(),N=P.useRef(),R=P.useRef(null),[k,B]=P.useState(null);Qz(R);const L=`${l.collapsedHeight||0}px`;function _(V){if(!R.current)return;const Y=R.current;for(const Z in V){const Q=V[Z];Q?Y.style[Z]=Q:Y.style.removeProperty(Z)}}return Xz(()=>{if(!R.current||h===y.current)return;y.current=h;function Y(K){return I?0:e??Jz(K)}const Z=K=>`height ${Y(K)}ms ${t}`,Q=K=>{function se(){h?(_({height:"",overflow:"",transition:"",display:""}),c("expandEnd")):(_({transition:""}),c("collapseEnd")),S(!1)}N.current&&Bx(N.current),N.current=Gz(se,K)};return S(!0),h?M.current=requestAnimationFrame(()=>{c("expandStart"),_({display:"block",overflow:"hidden",height:L}),M.current=requestAnimationFrame(()=>{c("expanding");const K=Hx(R);Q(Y(K)),R.current&&(R.current.style.transition=Z(K),R.current.style.height=`${K}px`)})}):M.current=requestAnimationFrame(()=>{c("collapseStart");const K=Hx(R);Q(Y(K)),_({transition:Z(K),height:`${K}px`}),M.current=requestAnimationFrame(()=>{c("collapsing"),_({height:L,overflow:"hidden"})})}),()=>{M.current&&cancelAnimationFrame(M.current),N.current&&Bx(N.current)}},[h,L,I,e,t,c]),{isExpanded:h,setExpanded:g,getToggleProps(V){const{disabled:Y,onClick:Z,refKey:Q,...K}={refKey:"ref",onClick(){},disabled:!1,...V},se=k?k.tagName==="BUTTON":void 0,le=V==null?void 0:V[Q||"ref"],fe={id:`react-collapsed-toggle-${f}`,"aria-controls":`react-collapsed-panel-${f}`,"aria-expanded":h,onClick(ie){Y||(Z==null||Z(ie),g(ce=>!ce))},[Q||"ref"]:Yx(le,B)},$={type:"button",disabled:Y?!0:void 0},he={"aria-disabled":Y?!0:void 0,role:"button",tabIndex:Y?-1:0};return se===!1?{...fe,...he,...K}:se===!0?{...fe,...$,...K}:{...fe,...$,...he,...K}},getCollapseProps(V){const{style:Y,refKey:Z}={refKey:"ref",style:{},...V},Q=V==null?void 0:V[Z||"ref"];return{id:`react-collapsed-panel-${f}`,"aria-hidden":!h,"aria-labelledby":`react-collapsed-toggle-${f}`,role:"region",...V,[Z||"ref"]:Yx(R,Q),style:{boxSizing:"border-box",...!w&&!h?{display:L==="0px"?"none":"block",height:L,overflow:"hidden"}:{},...Y}}}}}const tV=e=>{const{dailyNotesState:{app:t,view:n,settings:r},globalState:{memoListView:a}}=P.useContext(Lt),{getCollapseProps:o,getToggleProps:i,isExpanded:l,setExpanded:c}=eV({defaultExpanded:!0,collapsedHeight:(r==null?void 0:r.ThinoCollapsedHeight)??100}),{memo:f,handleMemoContentClick:h,handleMemoDoubleClick:g}=e,y=ne.useRef(null),[w,S]=ne.useState(""),D=ne.useRef(w),I=ne.useRef(0),[M,N]=ne.useState(!1),[R,k]=ne.useState(!1),B=x.debounce((_,V,Y)=>{for(const Z of _){const{height:Q}=Z.contentRect,K=(V==null?void 0:V.ThinoMaxHeight)||340,se=Q>K;N(se),c(!se),Y.disconnect()}},500);P.useEffect(()=>{var _;if(f.content!==D.current){if(r!=null&&r.OptimizeForCallout&&f.content.split("> [!").length>3&&f.content.split(`
+`).length>10&&!R){const V=y.current.createEl("button");V.setText(E("Render content")),V.onclick=async()=>{k(!0),await L()};const Y=y.current.createEl("textarea");Y.setText(f.content),Y.disabled=!0,(_=y.current)==null||_.toggleClass(["raw-content"],!0),c(!0),N(!1);return}L()}},[f.content]),P.useEffect(()=>{R&&I.current!==(r==null?void 0:r.ThinoMaxHeight)&&(y!=null&&y.current.hasChildNodes()&&k(!1),L())},[r==null?void 0:r.ThinoMaxHeight]),P.useEffect(()=>{if(!R)return;const _=y.current;if(!_)return;if(!(r!=null&&r.ThinoMaxHeight)){c(!0),N(!1);return}const V=new ResizeObserver(Y=>{B(Y,r,V)});return V.observe(_),()=>V.disconnect()},[R]);const L=async()=>{var _,V;y.current&&n&&t&&f.content!==D.current&&(y.current.empty(),await x.MarkdownRenderer.render(t,f.content,y.current,f.path,n),D.current=f.content,(_=y.current)==null||_.toggleClass(["markdown-rendered"],!0),(V=y.current)==null||V.toggleClass(["raw-content"],!1),k&&k(!0),I.current=(r==null?void 0:r.ThinoMaxHeight)||340)};return v.jsxs(v.Fragment,{children:[M&&a==="moments"&&v.jsxs(v.Fragment,{children:[v.jsx("button",{className:"thino-collapse-button",...i({style:{display:"block",marginTop:2}}),children:E(l?"Collapse":"Expand")}),!l&&(r==null?void 0:r.ThinoCollapsedHeight)!==0&&v.jsx("div",{className:"thino-collapse-shadowOverlay",onDoubleClick:g})]}),v.jsx("div",{...o({style:{margin:0}}),ref:y,className:"memo-content-text",onClick:_=>h(_,f),onDoubleClick:g,onContextMenu:_=>{_.preventDefault()}}),M&&a!=="moments"&&v.jsxs(v.Fragment,{children:[!l&&(r==null?void 0:r.ThinoCollapsedHeight)!==0&&v.jsx("div",{className:"thino-collapse-shadowOverlay",onDoubleClick:g}),v.jsx("button",{className:"thino-collapse-button",...i({style:{display:"block",marginTop:2}}),children:E(l?"Collapse":"Expand")})]})]})},e8=P.memo(tV,(e,t)=>e.memo.content===t.memo.content),nV=e=>{const[t,n]=P.useState({...e.memo,createdAtStr:ut.getDateTimeString(e.memo.createdAt)}),[r,a]=P.useState([]),[o,i]=P.useState([]);P.useEffect(()=>{(async()=>{try{const g=[],y=[...t.content.matchAll(rd)];for(const S of y)if(S&&S.length===3){const D=S[2],I=be.getMemoById(D);I&&g.push({...I,createdAtStr:ut.getDateTimeString(I.createdAt),dateStr:ut.getDateString(I.createdAt)})}a([...g]);const w=await be.getLinkedMemos(t.id);i(w.sort((S,D)=>ut.getTimeStampByDate(D.createdAt)-ut.getTimeStampByDate(S.createdAt)).map(S=>({...S,createdAtStr:ut.getDateTimeString(S.createdAt),dateStr:ut.getDateString(S.createdAt)})))}catch(g){console.error(g)}})()},[t.id]);const l=P.useCallback(async h=>{var y;const g=h.target;if(g.className==="memo-link-text"){const w=(y=g.dataset)==null?void 0:y.value,S=be.getMemoById(w??"");if(S){const D={...S,createdAtStr:ut.getDateTimeString(S.createdAt)};a([]),i([]),n(D)}else new x.Notice(E("Thino not found")),g.classList.remove("memo-link-text")}},[]),c=P.useCallback(h=>{a([]),i([]),n({...h,createdAtStr:ut.getDateTimeString(h.createdAt)})},[t.id]),f=P.useCallback(()=>{e.destroy(),dt.setEditMemoId(t.id)},[t.id]);return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"memo-card-container",children:[v.jsxs("div",{className:"header-container",children:[v.jsx("span",{className:"time-text",children:t.createdAtStr}),v.jsxs("div",{className:"btns-container",children:[v.jsx("button",{ref:h=>{h&&x.setIcon(h,"edit")},className:"btn edit-btn",onClick:f}),v.jsx("button",{ref:h=>{h&&x.setIcon(h,"x")},className:"btn close-btn",onClick:e.destroy})]})]}),v.jsx("div",{className:"memo-container",children:v.jsx("div",{className:"memo-content-text",children:v.jsx(e8,{memo:t,handleMemoContentClick:l,handleMemoDoubleClick:()=>{}})})}),v.jsx("div",{className:"layer-container"})]}),r.length>0?v.jsxs("div",{className:"linked-memos-wrapper",children:[v.jsxs("span",{className:"normal-text",children:[E("LINKED")," ",r.length," THINO"," "]}),r.map(h=>{const g=kC(uT(h.content)).replaceAll(`
+`," ");return v.jsxs("div",{className:"linked-memo-container",onClick:()=>c(h),children:[v.jsxs("span",{className:"time-text",children:[h.dateStr," "]}),g]},h.id)})]}):null,o.length>0?v.jsxs("div",{className:"linked-memos-wrapper",children:[v.jsxs("span",{className:"normal-text",children:[o.length," THINO ",E("LINK TO THE")," THINO"]}),o.map(h=>{const g=kC(uT(h.content)).replaceAll(`
+`," ");return v.jsxs("div",{className:"linked-memo-container",onClick:()=>c(h),children:[v.jsxs("span",{className:"time-text",children:[h.dateStr," "]}),g]},h.id)})]}):null]})};function Up(e){bb({className:"memo-card-dialog"},nV,{memo:e})}function rV({mouseEnterDelayMS:e=0,mouseLeaveDelayMS:t=0}={}){const[n,r]=P.useState(!1);let a,o;return[n,{onMouseEnter:()=>{clearTimeout(o),a=window.setTimeout(()=>r(!0),e)},onMouseLeave:()=>{clearTimeout(a),o=window.setTimeout(()=>r(!1),t)}}]}const aV=e=>{const{memo:t,handlePinMemoClick:n,handleFixMemoClick:r,handleSourceMemoClick:a,handleShowMemoStoryDialog:o,handleCopyMemoClick:i,handleEditMemoClick:l,handleGenMemoImageBtnClick:c,handleMarkMemoClick:f,handleArchiveMemo:h,handleDeleteMemoClick:g,handleSplitMemoClick:y}=e,w=Le.getState().dailyNotesState.settings,S=w.EnabledLocationList.find(Y=>Y.value==="MULTI"),[D,I]=Kl(!1),M=P.useRef(null),N={pinRef:P.useRef(null),fixRef:P.useRef(null),typeRef:P.useRef(null),moreRef:P.useRef(null)},[R,k]=rV({mouseEnterDelayMS:500}),B=P.useRef();P.useEffect(()=>{if(!N.typeRef)return;const Y=Gg.find(Z=>Z.title===t.sourceType);x.setIcon(N.typeRef.current,Y.icon),x.requireApiVersion("1.4.4")&&x.setTooltip(N.typeRef.current,t.path),N.fixRef&&(x.setIcon(N.fixRef.current,"shield-alert"),x.requireApiVersion("1.4.4")&&x.setTooltip(N.fixRef.current,"Update Thino property"))},[N.typeRef]),P.useEffect(()=>{N.pinRef&&(t.pinned?(x.setIcon(N.pinRef.current,"pin-off"),x.requireApiVersion("1.4.4")&&x.setTooltip(N.pinRef.current,E("UNPIN"))):(x.setIcon(N.pinRef.current,"pin"),x.requireApiVersion("1.4.4")&&x.setTooltip(N.pinRef.current,E("PIN"))))},[N.pinRef,t.pinned]);const L=x.debounce(()=>{var Y;if(R&&N.moreRef.current){if(B.current&&B.current._loaded||(Y=B.current)!=null&&Y.useNativeMenu||document.body.find(".more-action-btns-wrapper"))return;const Z=_(),Q=N.moreRef.current.getBoundingClientRect();Z.showAtPosition({x:Q.left,y:Q.bottom})}},200);P.useEffect(()=>{L()},[R]);const _=()=>{var Z;const Y=new x.Menu;return Y.dom.toggleClass(["more-action-btns-wrapper"],!0),Y.useNativeMenu?(Y.setNoIcon(),Y.addItem(Q=>{Q.setTitle(E("COPY")).onClick(i)}),Y.addItem(Q=>{Q.setTitle(E("EDIT")).onClick(l)}),Y.addItem(Q=>{Q.setTitle(E("SHARE")).onClick(c)})):Y.addItem(Q=>{const K=Q.dom;Q.dom.empty(),Q.dom.toggleClass(["more-action-btn-group","more-action-menu-item"],!0);const se=K.createEl("span");new x.ExtraButtonComponent(se).setIcon("copy"),se.toggleClass(["menu-item-icon","more-action-item-icon"],!0),se.onclick=$=>{$.stopPropagation(),$.preventDefault(),i(),Y.close()};const le=K.createEl("span");le.toggleClass(["menu-item-icon","more-action-item-icon"],!0),le.onclick=$=>{$.stopPropagation(),$.preventDefault(),l(),Y.close()},new x.ExtraButtonComponent(le).setIcon("pencil");const fe=K.createEl("span");fe.toggleClass(["menu-item-icon","more-action-item-icon"],!0),fe.onclick=$=>{$.stopPropagation(),$.preventDefault(),c(),Y.close()},new x.ExtraButtonComponent(fe).setIcon("share-2")}),Y.addSeparator(),Y.addItem(Q=>{Q.setIcon("book-open").setTitle(E("READ")).onClick(o)}),Y.addItem(Q=>{Q.setIcon("bookmark").setTitle(E("MARK")).onClick(f)}),((Z=/(^|\n)#{1,6}\s/g.exec(t.content))==null?void 0:Z.length)>1&&S&&Y.addItem(Q=>{Q.setIcon("separator-horizontal").setTitle(E("SPLIT")).onClick(y)}),Y.addItem(Q=>{Q.setIcon("home").setTitle(E("SOURCE")).onClick(()=>a(t))}),Y.addSeparator(),Y.addItem(Q=>{Q.setWarning(!0).setIcon("archive").setTitle(E("ARCHIVE").toUpperCase()).onClick(()=>h(t))}),Y.addItem(Q=>{Q.setWarning(!0).setIcon("trash").setTitle(w.DeleteThinoDirectly?E("DELETE"):E("TRASH BOX").toUpperCase().toUpperCase()).onClick(K=>{if(Y.useNativeMenu)g(K),Y.close();else if(K.stopPropagation(),K.preventDefault(),!D){I(!0),Q.setTitle(E("CONFIRM!")).onClick(se=>{g(se),Y.close()});return}})}),Y.addSeparator(),Y.addItem(Q=>{Q.setDisabled(!0).setTitle(ut.getWordCount(t.content.replace(/```[^\S\r\n]*[a-z]*\n.*?\n```/g,""))+` ${E("words")}`)}),Y.onHide(()=>{I(!1)}),B.current=Y,Y},V=Y=>{_().showAtMouseEvent(Y.nativeEvent)};return v.jsx("div",{ref:M,className:"memo-top-right-wrapper",children:v.jsxs("div",{className:"btns-container",children:[v.jsx("span",{ref:N.fixRef,className:`btn ${t.sourceType!=="MULTI"||t.id!==""?"hidden":""} fix-memo-btn`,onClick:()=>r(t)}),v.jsx("span",{ref:N.typeRef,className:`btn ${t.sourceType==="DAILY"?"hidden":""} source-type-btn`,onClick:()=>a(t)}),v.jsx("span",{ref:N.pinRef,className:`btn ${e.memo.pinned?"pinned-btn":"unpinned-btn"} pro`,onClick:n}),v.jsx("span",{...k,ref:Y=>{N.moreRef.current=Y,Y&&x.setIcon(Y,"more-horizontal")},onClick:V,className:"btn more-action-btn"})]})})},oV=e=>{var i,l,c;const{memo:t,handleMemoTypeToggle:n,handleShowMemoStoryDialog:r,settings:a}=e,o=((l=(i=t.fileInfo)==null?void 0:i.frontmatter)==null?void 0:l.title)||t.path.split("/").pop().split(".").shift();return v.jsxs("div",{className:"memo-top-left-wrapper",children:[e.children,v.jsx("span",{title:t.createdAt,className:"time-text",onClick:r,children:t.createdAt}),v.jsx("div",{className:`btn memo-type-img ${a!=null&&a.ShowTaskLabel?"":"hidden"}`,onClick:n,children:t.thinoType!=="JOURNAL"&&v.jsx("input",{className:"task-list-item-checkbox",type:"checkbox",checked:t.thinoType!=="TASK-TODO","data-task":t.thinoType==="TASK-TODO"?"":t.thinoType==="TASK-DONE"?"x":(c=t.thinoType)==null?void 0:c.slice(5)})}),(a==null?void 0:a.ShowSourcePath)&&t.sourceType==="FILE"&&v.jsx("span",{className:"time-text source-path","aria-label":o,onClick:()=>{at.setPathQuery(o)},children:o})]})};class iV extends x.SuggestModal{constructor(t,n){super(t),this.thino=n}sanitisedFileName(t){const n=sR;return t.replace(n,"").trim().slice(0,255)}ensureUniqueFileNames(t){const n=[];return t.map(a=>{const o=this.sanitisedFileName(a[0]),i=n.filter(l=>l==o);return n.push(o),i.length>=1?`${o}${i.length+1}`:o})}contentSplitByHeading(t,n){const r=t.split(`
+`),a=new Array(n).join("#")+" ",o=new Array(n+1).join("#")+" ",i=[];let l=[];return r.forEach((c,f)=>{c.startsWith(o)?(l.length>0&&(i.push(l),l=[]),l.push(c)):l.length>0&&!c.startsWith(a)?l.push(c):l.length>0&&(i.push(l),l=[]),f===r.length-1&&l.length>0&&i.push(l)}),i}onChooseSuggestion(t,n){this.selectSuggestion(t,n)}renderSuggestion(t,n){n.setText(t.title)}getSuggestions(){return[{id:"splitByHeading1",title:E("Split by Heading 1")},{id:"splitByHeading2",title:E("Split by Heading 2")},{id:"splitByHeading3",title:E("Split by Heading 3")}]}async selectSuggestion(t,n){let r=[];if(t.id==="splitByHeading1"?r=this.contentSplitByHeading(this.thino.content,1):t.id==="splitByHeading2"?r=this.contentSplitByHeading(this.thino.content,2):t.id==="splitByHeading3"&&(r=this.contentSplitByHeading(this.thino.content,3)),r.length===0){new x.Notice("No headings found"),this.close();return}const a=this.ensureUniqueFileNames(r);for(const l of r){const c=r.indexOf(l),f=await be.createThino({content:l.join(`
`),name:a[c],type:"MULTI",isList:!0});be.pushMemo(f)}let o=this.thino.content;r.forEach((l,c)=>{o=o.replace(l.join(`
-`),`[[${a[c]}]]`)});const i=await be.updateMemo(this.thino.id,o);i&&be.editMemo(i),this.close()}}const Jz=async(e,t,n)=>{const r=n.getAttribute("href"),a=n.className;if(a.contains("tag"))Kz(n.innerText.slice(1));else if(a.contains("internal-link")){const o=n.getAttribute("data-href"),i=be.getMemoById(o??"");i?Hp(i):await e.workspace.openLinkText(o,o,!C.Platform.isMobile&&t.navigation!==!0)}else r&&window.open(r,"_blank")},Kz=e=>{const t=ot.getState().query.tag;ot.setTagQuery(t.contains(",")?t.split(",").includes(e)?t.split(",").filter(n=>n!==e).join(","):t+","+e:t===e?"":e)},Qz=(e,t)=>{const n=t==null?void 0:t.getAttribute("src"),r=t==null?void 0:t.parentElement.getAttribute("src"),a=[...(e==null?void 0:e.querySelectorAll("img"))||[]],o=a.indexOf(t);Eb({imgUrl:n,filepath:n.startsWith("app")?r:void 0,otherIMGEls:a,currentIndex:o})},Xz=e=>{var r;const t=(r=e.dataset)==null?void 0:r.value,n=be.getMemoById(t??"");n?Hp(n):(new C.Notice("Thino Not Found"),e.classList.remove("memo-link-text"))},eV=async(e,t,n,r)=>{var l;const a=e!=null&&e.AppendDateWhenTaskDone?" ✅ "+C.moment().format("YYYY-MM-DD"):"",o=((l=r.parentElement.dataset)==null?void 0:l.task)==="x"?"DONE":"TODO",i=[...(n==null?void 0:n.querySelectorAll("li.task-list-item"))||[]];for(const c of i)if(c===r||c===r.closest("li.task-list-item")){const f=i.indexOf(c),p=t.content.split(/\n/),g=[];for(let M=0;M{const{globalState:{editMemoId:t},dailyNotesState:{app:n,view:r,settings:a,verifyState:o},locationState:{pathname:i}}=P.useContext(Lt),{memo:l,type:c="inline"}=e,f=P.useRef(null),p=P.useRef(null),[g,y]=P.useState(!1);P.useEffect(()=>{g&&setTimeout(()=>{dt.setEditMemoId(l.id)},100)},[g]),P.useEffect(()=>{(i==="/review"||i==="/daily")&&t!==l.id&&g&&y(!1)},[t]);const w=Z=>{if(Z.ctrlKey||Z.metaKey){const pe=C.moment(l.createdAt,"YYYY/MM/DD HH:mm:ss");ot.setFromAndToQuery(pe.startOf("day").valueOf(),pe.endOf("day").valueOf());return}Hp(l)},T=()=>{if(a!=null&&a.UseButtonToShowEditor&&(a==null?void 0:a.DefaultEditorLocation)==="Bottom"){const Z=document.querySelector("div[data-type='thino_view'] .view-content .memo-show-editor-button:not(.hidden)");Z&&Z.trigger("click")}dt.setMarkMemoId(l.id)},S=async()=>{var ie;const Z=!C.Platform.isDesktop&&await((ie=window.Capacitor)==null?void 0:ie.Plugins.Device.getId()),pe=C.Platform.isDesktop?await cr():Z.identifier||Z.uuid;if(!o||(o==null?void 0:o.appId)!==pe){Sn();return}l.pinned?await be.unpinMemoById(l.id):await be.pinMemoById(l.id)},I=()=>{if(a!=null&&a.UseButtonToShowEditor&&(a==null?void 0:a.DefaultEditorLocation)==="Bottom"&&C.Platform.isMobile){const Z=document.querySelector("div[data-type='thino_view'] .view-content .memo-show-editor-button:not(.hidden)");Z&&Z.trigger("click")}(i==="/review"||i==="/daily")&&y(!0),i!=="/review"&&i!=="/daily"&&dt.setEditMemoId(l.id)},M=async Z=>{Z.sourceType==="MULTI"&&Z.id.trim()===""&&await be.updateMemoProperty(Z)},N=async Z=>{await be.openThinoByID(Z.id)},_=async Z=>{try{const pe=await be.archiveMemo(Z);pe&&be.editMemo(pe)}catch(pe){console.error(pe),new C.Notice(pe.message)}},k=async()=>{try{if(a.DeleteThinoDirectly)await be.deleteMemoById(l.id);else{const Z=await be.hideMemoById(l.id);Z&&be.editMemo(Z)}}catch(Z){new C.Notice(Z.message)}dt.getState().editMemoId===l.id&&dt.setEditMemoId("")},R=()=>{if(p.current&&!p.current.confirmStatus){p.current&&p.current.toggleConfirm(!1);return}},L=()=>{of(l)},H=async()=>{const Z=await be.updateMemo(l.id,l.content,l.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");Z&&be.editMemo(Z)},U=async()=>{navigator.clipboard.writeText(l.content).then(()=>{new C.Notice(E("COPY SUCCEED"))}).catch(()=>{new C.Notice(E("COPY FAILED"))})},z=async()=>{new Gz(n,l).open()},$=Z=>{Z&&Z.target.tagName!=="INPUT"&&I()},X=async(Z,pe)=>{Z.preventDefault(),Z.stopPropagation();const ie=Z.target;if(Z.ctrlKey||Z.metaKey){await N(pe);return}if(ie.tagName==="A"){await Jz(n,r,ie);return}if(ie.tagName==="IMG"){Qz(f.current,ie);return}if(ie.tagName==="A"&&ie.getAttribute("href")){const de=ie.getAttribute("href");window.open(de,"_blank");return}if(ie.className==="memo-link-text"){Xz(ie);return}if(ie.tagName==="INPUT"&&ie.hasClass("task-list-item-checkbox")){await eV(a,pe,f.current,ie);return}},Q=Z=>{const pe=new C.Menu;pe.dom.toggleClass("memo-context-menu",!0);const ie=window.getSelection();(ie==null?void 0:ie.toString().length)>0&&pe.addItem(de=>{de.setIcon("copy").setTitle(E("Copy selected text")).onClick(()=>{navigator.clipboard.writeText(ie.toString()).then(()=>{new C.Notice(E("COPY SUCCEED"))}).catch(()=>{new C.Notice(E("COPY FAILED"))})})}).addSeparator(),pe.addItem(de=>{de.setIcon("copy").setTitle(E("Copy thino").toLocaleUpperCase()).onClick(async()=>{await U(),pe.close()})}).addItem(de=>{de.setIcon("book-open").setTitle(E("READ")).onClick(w)}).addItem(de=>{de.setIcon(l.pinned?"pin-off":"pin").setTitle(l.pinned?E("UNPIN"):E("PIN")).onClick(S)}).addItem(de=>{de.setIcon("bookmark").setTitle(E("MARK")).onClick(T)}).addItem(de=>{de.setIcon("share-2").setTitle(E("SHARE")).onClick(L)}).addItem(de=>{de.setIcon("pencil").setTitle(E("EDIT")).onClick(I)}).addItem(de=>{de.setIcon("home").setTitle(E("SOURCE")).onClick(()=>N(l))}).addSeparator().addItem(de=>{de.setIcon("archive").setTitle(E("ARCHIVE").toLocaleUpperCase()).onClick(()=>_(l))}).addItem(de=>{de.setIcon("trash").setTitle(E("DELETE")).onClick(async()=>{await k()})}),pe.showAtMouseEvent(Z.nativeEvent)},se=P.useMemo(()=>({memo:l,handlePinMemoClick:S,handleFixMemoClick:M,handleSourceMemoClick:N,handleArchiveMemo:_,handleDeleteMemoClick:k,handleGenMemoImageBtnClick:L,handleMarkMemoClick:T,handleEditMemoClick:I,handleCopyMemoClick:U,handleShowMemoStoryDialog:w,handleSplitMemoClick:z}),[l]),ue=P.useMemo(()=>({memo:l,handleMemoTypeToggle:H,handleShowMemoStoryDialog:w,settings:a}),[l,a]),fe=P.useMemo(()=>v.jsxs("div",{ref:f,className:`memo-wrapper ${l.pinned?"pinned":""}`,"data-source-type":l.sourceType,"data-thino-type":l.thinoType,"data-thino-id":l.id,onMouseLeave:R,onMouseOver:Z=>{Z.shiftKey&&(Z.stopPropagation(),n.workspace.trigger("hover-link",{event:Z,source:"thino",hoverParent:r.containerEl,targetEl:f.current,linktext:l.path,sourcePath:l.path,state:{scroll:l.sourceType==="DAILY"?parseInt(l.id.slice(14)):0}}))},onContextMenu:Q,children:[g&&v.jsx(ff,{editorType:"inline"}),!g&&v.jsxs(v.Fragment,{children:[c==="inline"&&v.jsxs("div",{className:"memo-top-wrapper",draggable:!0,onDragStart:Z=>{Z.target.classList.add("dragging"),Z.dataTransfer.setDragImage(f.current,0,0),Z.dataTransfer.setData("text/plain",l.content)},onDragEnd:Z=>{Z.target.classList.remove("dragging")},children:[v.jsx(qz,{...ue}),v.jsx(Zz,{...se})]}),v.jsx(W6,{memo:l,handleMemoContentClick:X,handleMemoDoubleClick:$})]})]}),[l,g]);return v.jsx(v.Fragment,{children:fe})},ai=P.memo(tV,(e,t)=>Sw.isEqual(e.memo,t.memo));class rt extends C.Setting{constructor(n,r){super(n);De(this,"settingTab");De(this,"name","");De(this,"desc","");this.settingTab=r}setName(n){return super.setName(n),this.name=n,this}setDesc(n){return super.setDesc(n),this.desc=n,this}setTab(n){const r=typeof this.name=="string"?this.name:this.name.textContent||"",a=typeof this.desc=="string"?this.desc:this.desc.textContent||"";return this.settingTab.addSettingToMasterSettingsList(n,this.settingEl,r,a),this}}class nV extends C.Modal{constructor(n,r,a,o,i){super(n);De(this,"plugin");De(this,"settingTab");De(this,"target",5);De(this,"cb");this.app=n,this.settingTab=r,this.plugin=a,this.target=o,this.cb=i}onOpen(){var l;const{contentEl:n}=this;(l=n.parentElement)==null||l.classList.add("memo-save-location-modal"),n.createEl("h3",{text:E("Thino Daily Target")});const r=n.createDiv("modal-setting");new rt(r,this.settingTab).setName(E("Target Thino Count")).addSlider(c=>{c.setDynamicTooltip().setValue(this.target).setLimits(1,30,1).onChange(async f=>{this.target=f})});const a=n.createDiv("button-group"),o=a.createEl("button",{text:E("Cancel")}),i=a.createEl("button",{text:E("Save")});i.onclick=async()=>{this.plugin.settings.MemoDailyTarget=this.target,this.settingTab.applySettingsUpdate(),this.cb(this.target),this.close()},o.onclick=async()=>{this.close()}}onClose(){const{contentEl:n}=this;n.empty()}}const rV=({allStat:e,todayTimeStamp:t,calendarType:n,handleCalendarTypeChange:r})=>{const{dailyNotesState:{app:a,settings:o},globalState:{manifest:i}}=P.useContext(Lt),[l,c]=P.useState(),[f,p]=P.useState(5),[g,y]=P.useState(0),[w,T]=P.useState(0),[S,I]=P.useState(o.HeatmapColorScheme||"default"),M=P.useRef(null),N=P.useRef(null);P.useEffect(()=>{o.HeatmapColorScheme&&I(o.HeatmapColorScheme)},[o.HeatmapColorScheme]),P.useEffect(()=>{let k,R=5;i&&a&&(k=a==null?void 0:a.plugins.getPlugin(i.id),R=k==null?void 0:k.settings.MemoDailyTarget,c(k)),p(R)},[i,a]),P.useEffect(()=>{const k=e.find(H=>H.timestamp===t),R=k?k.count:0;T(R);const L=Math.min(100,R/f*100);y(L)},[e,f]),P.useEffect(()=>{C.requireApiVersion("1.4.4")&&(C.setTooltip(N.current,g.toFixed(2)+"%"),C.setTooltip(M.current,E("Set daily target")+` (${w}/${f})`))},[g,w]),P.useEffect(()=>{M.current&&(M.current.hasChildNodes()||C.setIcon(M.current,"crosshair"),C.requireApiVersion("1.4.4")&&C.setTooltip(N.current,g+"%"))},[M,f]);const _=P.useCallback(()=>{if(!l)return;new nV(a,l==null?void 0:l.settingTab,l,f,R=>{p(R)}).open()},[l,f]);return v.jsx(v.Fragment,{children:v.jsxs("div",{className:`usage-daily-progress-wrapper heatmap-${S}`,children:[v.jsx("div",{ref:N,className:"daily-progress-bar",children:v.jsx("div",{className:"daily-progress-bar-inner",style:{width:`${g}%`}})}),v.jsx("div",{ref:M,className:"daily-progress-target",onClick:_}),v.jsx("div",{ref:k=>{k&&C.setIcon(k,n==="basic"?"layout-grid":"calendar"),k&&C.setTooltip&&C.setTooltip(k,E("Switch calendar type"))},className:"switch-calendar-type-btn",onClick:()=>r&&r(n==="basic"?"heatmap":"basic")})]})})},aV=(e,t)=>{const n=[],r=Math.floor((e-t)/ei);for(let a=0;a<=r;a++)n.push({timestamp:t+ei*a,count:0,list:0});return n},oV=e=>{const{className:t,view:n,datestamp:r,handleDateStampChange:a,handleDateItemClick:o,handleMonthChange:i,dailyStat:l}=e,c=C.moment().startOf("day").valueOf(),[f,p]=P.useState(Qh(r)),[g,y]=P.useState(null),[w,T]=P.useState(e.dailyStat);P.useEffect(()=>{p(Qh(r));const k=aV(sV(r),Qh(r)),R=e.thinos.filter(L=>!L.deletedAt&&L.rowStatus!=="ARCHIVED");for(const L of R){const U=C.moment(L.createdAt,"YYYY/MM/DD HH:mm:ss").startOf("day").diff(C.moment(f).startOf("day"),"days");U>=0&&U{const R=S.getFullYear(),L=S.getMonth()+1;let H=0;L===1&&k===-1?H=new Date(`${R-1}/12/1`).getTime():L===12&&k===1?H=new Date(`${R+1}/1/1`).getTime():H=new Date(`${R}/${L+k}/1`).getTime(),p(Qh(H)),i&&i(H)};return v.jsxs("div",{className:`heatmap-date-picker-wrapper ${t}`,children:[v.jsxs("div",{className:"date-picker-header",children:[v.jsx("span",{ref:k=>{k&&C.setIcon(k,"chevron-left")},className:"btn btn-text",onClick:()=>_(-1)}),v.jsxs("span",{className:"normal-text",children:[v.jsx(g6,{year:S.getFullYear().toString(),handleYearChange:k=>{p(Qh(new Date(`${k}/${S.getMonth()+1}/1`).getTime()))}}),v.jsx(v6,{month:S.getMonth().toString(),handleMonthChange:k=>{p(Qh(new Date(`${S.getFullYear()}/${parseInt(k)}/1`).getTime()))}})]}),v.jsx("span",{ref:k=>{k&&C.setIcon(k,"chevron-right")},className:"btn btn-text",onClick:()=>_(1)})]}),v.jsxs("div",{className:"date-picker-day-container",children:[v.jsx("div",{className:"date-picker-day-header",children:E("weekDaysShort").map(k=>v.jsx("span",{className:"day-item",children:k},k))}),v.jsx("div",{className:"date-picker-day-content",children:M.map(k=>{if(k.date===0)return v.jsx("span",{className:"day-item null",children:""},k.datestamp);const R=w.find(U=>U.timestamp===k.datestamp)||{count:0,timestamp:k.datestamp,list:0},L=R.count-R.list,H=R.list;return v.jsxs("span",{className:`day-item ${k.datestamp===c?"current":""} ${k.datestamp===g?"selected":""} ${AS(R.count)}`,onClick:U=>{a(r,U.nativeEvent),y(k.datestamp===g?null:k.datestamp),o&&o(U,R)},onMouseOver:U=>{if(!R||!R.count)return;const z=new C.HoverPopover(n,U.currentTarget,100);$6(z,{d:k,list:H,task:L})},children:[v.jsx("span",{className:"day-item-text",children:k.date}),v.jsx(v.Fragment,{children:R&&R.count!==0&&v.jsxs("span",{className:"day-item-dots",children:[L>0&&v.jsx("div",{className:`day-item-dot thino-task-dot ${AS(L)}`}),H>0&&v.jsx("div",{className:`day-item-dot thino-list-dot ${AS(H)}`})]})})]},k.datestamp)})})]})]})};function $6(e,{d:t,list:n,task:r}){e.hoverEl.toggleClass("thino-hover-popover",!0);const a=e.hoverEl.createDiv({cls:"thino-hover-popover-content"});a.createDiv({cls:"thino-date-item",text:`${C.moment(t.datestamp).format("YYYY-MM-DD")}`});const o=a.createDiv({cls:"thino-task-item"});o.createSpan({cls:"thino-task-item-title-text",text:`${E("Task")}: `}),o.createSpan({cls:"thino-task-item-title-count",text:`${r}`});const i=a.createDiv({cls:"thino-list-item"});i.createSpan({cls:"thino-list-item-title-text",text:`${E("List")}: `}),i.createSpan({cls:"thino-list-item-title-count",text:`${n}`})}function iV(e){const t=new Date(e),n=new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`);return((n.getMonth()===11?new Date(`${n.getFullYear()+1}/1/1`):new Date(`${n.getFullYear()}/${n.getMonth()+2}/1`)).getTime()-n.getTime())/ei}function Qh(e){const t=new Date(e);return new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`).getTime()}function sV(e){const t=new Date(e),n=new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`);return(n.getMonth()===11?new Date(`${n.getFullYear()+1}/1/1`):new Date(`${n.getFullYear()}/${n.getMonth()+2}/1`)).getTime()-ei}function AS(e){return e<=0?"":e<=1?"stat-day-L1-bg":e<=2?"stat-day-L2-bg":e<=4?"stat-day-L3-bg":"stat-day-L4-bg"}const LC={width:12,height:7},RC=(e,t)=>{const n=[];for(let r=0;r<=e;r++)n.push({timestamp:t+ei*r,count:0,list:0});return n},Qg=({initThinos:e,basicType:t})=>{const n=parseInt(C.moment().endOf("day").format("x"));new Date(n).getDay();const r=parseInt(C.moment().startOf("day").format("x")),a=new Array(6-new Date(n).getDay()).fill(0),o=LC.width*LC.height,i=parseInt(C.moment().startOf("day").subtract(o,"days").format("x")),l=C.moment().startOf("day").subtract(o,"days"),{memoState:{memos:c},dailyNotesState:{view:f,app:p,settings:g,verifyState:y}}=P.useContext(Lt),[w,T]=Co(t||uV(p||window.app)||"heatmap"),[S,I]=Co(C.moment().startOf("day").valueOf()),[M,N]=Co(g.HeatmapColorScheme||"default"),[_,k]=Co(RC(o,i)),[R,L]=Co(null),[H,U,z]=Co(""),$=P.useRef(null);P.useEffect(()=>{const fe=RC(o,i),Z=(e||c).filter(pe=>!pe.deletedAt&&pe.rowStatus!=="ARCHIVED");for(const pe of Z){const de=C.moment(pe.createdAt.replaceAll("/","-"),"YYYY-MM-DD HH:mm:ss").startOf("day").diff(l,"days");de>=0&&de{g.HeatmapColorScheme&&N(g.HeatmapColorScheme)},[g.HeatmapColorScheme]);const X=P.useCallback((fe,Z)=>{if(!Z||!Z.count)return;const pe=Z.count-Z.list,ie=Z.list,de={date:Z.timestamp,datestamp:Z.timestamp},K=new C.HoverPopover(f,fe.currentTarget,100);$6(K,{d:de,list:ie,task:pe})},[]),Q=()=>{T(w==="heatmap"?"basic":"heatmap"),lV(p,w==="heatmap"?"basic":"heatmap"),I(C.moment().startOf("day").valueOf())},se=P.useCallback(async(fe,Z)=>{if(Z.count===0)return;const pe=ot.getState().query.duration,ie=pe==null?void 0:pe.from,de=pe==null?void 0:pe.to,K=C.moment(ie).diff(de,"day")==0;if(ie===Z.timestamp&&K)ot.setFromAndToQuery(0,0),L(null),U(null);else if(ie!==Z.timestamp&&ie>0&&fe.shiftKey){const ae=C.moment(Z.timestamp).endOf("day").diff(de,"day");ie===0&&fe.shiftKey?U("from"):ae<0&&K&&U("to"),C.moment(ie).isBefore(Z.timestamp)?z.current==="to"?ae<0?ot.setFromAndToQuery(Z.timestamp,de):(ot.setFromAndToQuery(parseInt(C.moment(de).startOf("day").format("x")),parseInt(C.moment(Z.timestamp).endOf("day").format("x"))),U("from")):z.current==="from"&&(ae<0,ot.setFromAndToQuery(ie,parseInt(C.moment(Z.timestamp).endOf("day").format("x")))):z.current==="to"?ot.setFromAndToQuery(Z.timestamp,de):z.current==="from"&&(ot.setFromAndToQuery(Z.timestamp,parseInt(C.moment(ie).endOf("day").format("x"))),U("to"))}else if(ie===0&&fe.shiftKey)ot.setFromAndToQuery(Z.timestamp,parseInt(C.moment().endOf("day").format("x")));else if(Z.count>0&&(fe.ctrlKey||fe.metaKey)){const{app:ae,dailyNotes:Se}=ft.getState(),je=ub(C.moment(Z.timestamp),Se);if(!C.Platform.isMobile)await ae.workspace.getLeaf(!0).openFile(je);else{let Re=ae.workspace.activeLeaf;Re===null&&(Re=ae.workspace.getLeaf(!0)),Re.openFile(je)}}else Z.count>0&&!fe.shiftKey&&!fe.ctrlKey&&!fe.metaKey&&(["/","/recycle"].includes(ot.getState().pathname)||ot.setPathname("/"),ot.setFromAndToQuery(Z.timestamp,ut.getTimeStampByDate(C.moment(Z.timestamp+ei).subtract(1,"days").endOf("day").format("YYYY-MM-DD HH:mm:ss"))),L(Z))},[]),ue=P.useMemo(()=>v.jsx(oV,{className:`heatmap-${M}`,view:f,datestamp:S,dailyStat:_,thinos:e||c,handleMonthChange:fe=>{I(fe)},handleDateStampChange:fe=>{},handleDateItemClick:(fe,Z)=>se(fe,Z)}),[JSON.stringify(_),e,c,f,S,M]);return v.jsxs(v.Fragment,{children:[w==="basic"&&ue,w==="heatmap"&&v.jsxs("div",{className:`usage-heat-map-wrapper heatmap-${M}`,ref:$,children:[v.jsxs("div",{className:"day-tip-text-container",children:[v.jsx("span",{className:"tip-text",children:E("weekDaysShort")[0]}),v.jsx("span",{className:"tip-text"}),v.jsx("span",{className:"tip-text",children:E("weekDaysShort")[2]}),v.jsx("span",{className:"tip-text"}),v.jsx("span",{className:"tip-text",children:E("weekDaysShort")[4]}),v.jsx("span",{className:"tip-text"}),v.jsx("span",{className:"tip-text",children:E("weekDaysShort")[6]})]}),v.jsxs("div",{className:"usage-heat-map",children:[_.slice(_.length-84+a.length,_.length).map((fe,Z)=>{const pe=fe.count,ie=pe<=0?"":pe<=1?"stat-day-L1-bg":pe<=2?"stat-day-L2-bg":pe<=4?"stat-day-L3-bg":"stat-day-L4-bg";return v.jsx("span",{"data-timestamp":fe.timestamp,"data-count":fe.count,"data-list-count":fe.list,"data-task-count":fe.count-fe.list,className:`stat-container ${ie} ${R===fe?"current":""} ${r===fe.timestamp?"today":""}`,onMouseOver:de=>X(de,fe),onClick:de=>se(de,fe)},Z)}),a.map((fe,Z)=>v.jsx("span",{className:"stat-container null"},Z))]})]}),!t&&v.jsx(rV,{allStat:_,todayTimeStamp:r,calendarType:w,handleCalendarTypeChange:Q})]})};function lV(e,t){try{e==null||e.saveLocalStorage("calendarType",t)}catch(n){console.error(n)}}function uV(e){try{return(e==null?void 0:e.loadLocalStorage("calendarType"))||"heatmap"}catch(t){return console.error(t),"heatmap"}}const Z6=({type:e,timestamp:t})=>{const{memoState:{memos:n}}=P.useContext(Lt),[r,a]=P.useState([]),o=ne.useRef(null);return P.useEffect(()=>{if(e==="daily"){if(t){const l=n.filter(c=>C.moment(c.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(C.moment(t,"YYYY/MM/DD HH:mm:ss"),"day"));a(l);return}const i=n.filter(l=>C.moment(l.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(C.moment(),"day"));a(i)}else if(e==="latest"){const i=n.filter(f=>!f.deletedAt&&f.rowStatus!=="ARCHIVED"),l=i.filter(f=>f.pinned),c=i.filter(f=>!f.pinned).slice(0,5);a([...l,...c])}},[n]),P.useEffect(()=>{o.current&&(o.current.scrollTop=0)},[n]),r.length>0?v.jsx("div",{ref:o,className:"thino-list-container",children:r.map(i=>v.jsx(ai,{memo:i}))}):v.jsx("div",{className:"tip-text-container",children:v.jsx("span",{className:"tip-text",children:E("Here is No Memos.")})})},cV=(e,t)=>{rs.createRoot(e).render(v.jsx(ne.StrictMode,{children:v.jsx(is,{store:Le,context:Lt,children:v.jsx(dV,{plugin:t})})}))},dV=({plugin:e})=>v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"thino-error-code-block",children:E("Please open thino first")}),v.jsx("button",{className:"thino-open-view",onClick:()=>e.openMemos("center"),children:E("Open thino in center window")})]}),fV=(e,t)=>{rs.createRoot(e).render(v.jsx(ne.StrictMode,{children:v.jsx(is,{store:Le,context:Lt,children:v.jsx(hV,{yaml:t})})}))},hV=({yaml:e})=>{const t=Object.keys(e).filter(a=>e[a]),n=e.daily?e.daily:"",r=a=>{switch(a){case"editor":return _C;case"heatmap":return mV;case"calendar":return gV;case"daily":return yV;case"list":return wV;case"status":return vV;default:return _C}};return v.jsx(v.Fragment,{children:t.map(a=>v.jsx("div",{"data-embed-type":a,className:ar("thino-embed-container",a==="editor"?"thino-editor-modal":""),children:a==="daily"?r(a)(n):r(a)()}))})};function _C(){return v.jsx(ff,{editorType:"inline",modal:!0})}function pV(e,t,n){try{const r=rs.createRoot(e);return r.render(v.jsx(ne.StrictMode,{children:v.jsx(is,{store:Le,context:Lt,children:v.jsx(ff,{editorType:"inline",destroy:t,modal:n})})})),r}catch(r){console.error(r)}}function mV(){return v.jsx(Qg,{basicType:"heatmap"})}function gV(){return v.jsx(Qg,{basicType:"basic"})}function vV(){return v.jsx(V2,{statusType:"banner"})}function yV(e){return v.jsx(Z6,{type:"daily",timestamp:e})}function wV(){return v.jsx(Z6,{type:"latest"})}class q6 extends C.Modal{constructor(n){super(n);De(this,"root")}getViewType(){return"thino_view"}onOpen(){const{contentEl:n,modalEl:r}=this;try{this.root=pV(n,this.close.bind(this),this),r.toggleClass("thino-editor-modal",!0),setTimeout(()=>{var a;(a=n.querySelector("textarea"))==null||a.focus(),this.app.workspace.trigger("focus-on-textarea")},10)}catch(a){console.error(a)}}onClose(){this.root.unmount(),this.containerEl&&this.containerEl.empty()}}function bV(e,t){if(e==null)return{};var n=SV(e,t),r,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function SV(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o=0)&&(n[a]=e[a]);return n}function Fw(){return Fw=Object.assign||function(e){for(var t=1;t{this.reCalculateColumnCount()})}reCalculateColumnCount(){const t=window&&window.innerWidth||1/0;let n=this.props.breakpointCols;typeof n!="object"&&(n={default:parseInt(n)||FS});let r=1/0,a=n.default||FS;for(let o in n){const i=parseInt(o);i>0&&t<=i&&i"u"&&(i="my-masonry-grid_column"));const l=wg(wg(wg({},t),n),{},{style:wg(wg({},n.style),{},{width:o}),className:i});return a.map((c,f)=>ne.createElement("div",Fw({},l,{key:f}),c))}logDeprecated(t){console.error("[Masonry]",t)}render(){const t=this.props,{children:n,breakpointCols:r,columnClassName:a,columnAttrs:o,column:i,className:l}=t,c=bV(t,["children","breakpointCols","columnClassName","columnAttrs","column","className"]);let f=l;return typeof l!="string"&&(this.logDeprecated('The property "className" requires a string'),typeof l>"u"&&(f="my-masonry-grid")),ne.createElement("div",Fw({},c,{className:f}),this.renderColumns())}}Ow.defaultProps=TV;const DT=e=>{P.useContext(Lt);const t=Le.getState().dailyNotesState.settings,{thinos:n,dayMark:r,dayMarkRange:a="day",thinoWrapper:o}=e,[i,l]=ne.useState(!(t!=null&&t.hidePinnedGroup&&r==="PINNED")),c=ne.useRef(null);P.useEffect(()=>{c&&C.setTooltip&&C.setTooltip(c.current,E("Click to expand or fold, Cmd+Click to show all thinos of the day"))},[c]);const f=p=>{if(C.Keymap.isModifier(p.nativeEvent,"Mod")){const g={day:"YYYY-MM-DD",week:"YYYY-[W]WW",month:"YYYY-MM",quarter:"YYYY-[Q]Q",year:"YYYY"},y=C.moment(r,g[a]);ot.setFromAndToQuery(y.startOf(a).valueOf(),y.endOf(a).valueOf());return}l(!i)};return v.jsx(v.Fragment,{children:e.type==="list"?v.jsxs(v.Fragment,{children:[v.jsx("div",{ref:c,className:`day-mark ${i?"":"folded"} PINNED`,onClick:f,children:v.jsxs("span",{className:"day-mark-text",children:[i?"▼ ":"▶ ",r==="PINNED"?r+" 📌":r]})},r),i&&n.map((p,g)=>o?v.jsx("div",{children:o({thino:p})},`${p.id}-${C.moment(p.createdAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${g}`):v.jsx(ai,{memo:p},`${p.id}-${C.moment(p.createdAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${g}`))]}):v.jsxs(v.Fragment,{children:[v.jsx("div",{ref:c,className:`day-mark ${i?"":"folded"}`,onClick:f,children:v.jsxs("span",{className:"day-mark-text",children:[i?"▼ ":"▶ ",r==="PINNED"?r+" 📌":r]})},r),v.jsx(Ow,{breakpointCols:e.type==="waterfall"?3:1,className:`${e.type}-view masonry-memolist`,columnClassName:"masonry-memolist-grid_column",children:i&&n.map((p,g)=>o?v.jsx("div",{children:o({thino:p})},`${p.id}-${C.moment(p.updatedAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${g}`):v.jsx(ai,{memo:p},`${p.id}-${C.moment(p.updatedAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${g}`))})]})})};function Uu(e){"@babel/helpers - typeof";return Uu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Uu(e)}function IV(e,t){if(Uu(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(Uu(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function G6(e){var t=IV(e,"string");return Uu(t)=="symbol"?t:String(t)}function af(e,t,n){return t=G6(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function HC(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function tr(e){for(var t=1;t=0)&&(n[a]=e[a]);return n}function Ql(e,t){if(e==null)return{};var n=xb(e,t),r,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Ma(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function YC(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n{const r=n.getAttribute("href"),a=n.className;if(a.contains("tag"))lV(n.innerText.slice(1));else if(a.contains("internal-link")){const o=n.getAttribute("data-href"),i=be.getMemoById(o??"");i?Up(i):await e.workspace.openLinkText(o,o,!x.Platform.isMobile&&t.navigation!==!0)}else r&&window.open(r,"_blank")},lV=e=>{const t=at.getState().query.tag;at.setTagQuery(t.contains(",")?t.split(",").includes(e)?t.split(",").filter(n=>n!==e).join(","):t+","+e:t===e?"":e)},uV=(e,t)=>{const n=t==null?void 0:t.getAttribute("src"),r=t==null?void 0:t.parentElement.getAttribute("src"),a=[...(e==null?void 0:e.querySelectorAll("img"))||[]],o=a.indexOf(t);Mb({imgUrl:n,filepath:n.startsWith("app")?r:void 0,otherIMGEls:a,currentIndex:o})},cV=e=>{var r;const t=(r=e.dataset)==null?void 0:r.value,n=be.getMemoById(t??"");n?Up(n):(new x.Notice("Thino Not Found"),e.classList.remove("memo-link-text"))},dV=async(e,t,n,r)=>{var l;const a=e!=null&&e.AppendDateWhenTaskDone?" ✅ "+x.moment().format("YYYY-MM-DD"):"",o=((l=r.parentElement.dataset)==null?void 0:l.task)==="x"?"DONE":"TODO",i=[...(n==null?void 0:n.querySelectorAll("li.task-list-item"))||[]];for(const c of i)if(c===r||c===r.closest("li.task-list-item")){const f=i.indexOf(c),h=t.content.split(/\n/),g=[];for(let M=0;M{const{globalState:{editMemoId:t},dailyNotesState:{app:n,view:r,settings:a,verifyState:o},locationState:{pathname:i}}=P.useContext(Lt),{memo:l,type:c="inline"}=e,f=P.useRef(null),h=P.useRef(null),[g,y]=P.useState(!1);P.useEffect(()=>{g&&setTimeout(()=>{dt.setEditMemoId(l.id)},100)},[g]),P.useEffect(()=>{(i==="/review"||i==="/daily")&&t!==l.id&&g&&y(!1)},[t]);const w=$=>{if($.ctrlKey||$.metaKey){const he=x.moment(l.createdAt,"YYYY/MM/DD HH:mm:ss");at.setFromAndToQuery(he.startOf("day").valueOf(),he.endOf("day").valueOf());return}Up(l)},S=()=>{if(a!=null&&a.UseButtonToShowEditor&&(a==null?void 0:a.DefaultEditorLocation)==="Bottom"){const $=document.querySelector("div[data-type='thino_view'] .view-content .memo-show-editor-button:not(.hidden)");$&&$.trigger("click")}dt.setMarkMemoId(l.id)},D=async()=>{var ie;const $=!x.Platform.isDesktop&&await((ie=window.Capacitor)==null?void 0:ie.Plugins.Device.getId()),he=x.Platform.isDesktop?await cr():$.identifier||$.uuid;if(!o||(o==null?void 0:o.appId)!==he){fn();return}l.pinned?await be.unpinMemoById(l.id):await be.pinMemoById(l.id)},I=()=>{if(a!=null&&a.UseButtonToShowEditor&&(a==null?void 0:a.DefaultEditorLocation)==="Bottom"&&x.Platform.isMobile){const $=document.querySelector("div[data-type='thino_view'] .view-content .memo-show-editor-button:not(.hidden)");$&&$.trigger("click")}(i==="/review"||i==="/daily")&&y(!0),i!=="/review"&&i!=="/daily"&&dt.setEditMemoId(l.id)},M=async $=>{$.sourceType==="MULTI"&&$.id.trim()===""&&await be.updateMemoProperty($)},N=async $=>{await be.openThinoByID($.id)},R=async $=>{try{const he=await be.archiveMemo($);he&&be.editMemo(he)}catch(he){console.error(he),new x.Notice(he.message)}},k=async()=>{try{if(a.DeleteThinoDirectly)await be.deleteMemoById(l.id);else{const $=await be.hideMemoById(l.id);$&&be.editMemo($)}}catch($){new x.Notice($.message)}dt.getState().editMemoId===l.id&&dt.setEditMemoId("")},B=()=>{if(h.current&&!h.current.confirmStatus){h.current&&h.current.toggleConfirm(!1);return}},L=()=>{sf(l)},_=async()=>{const $=await be.updateMemo(l.id,l.content,l.thinoType==="TASK-TODO"?"TASK-DONE":"TASK-TODO");$&&be.editMemo($)},V=async()=>{navigator.clipboard.writeText(l.content).then(()=>{new x.Notice(E("COPY SUCCEED"))}).catch(()=>{new x.Notice(E("COPY FAILED"))})},Y=async()=>{new iV(n,l).open()},Z=$=>{$&&$.target.tagName!=="INPUT"&&I()},Q=async($,he)=>{$.preventDefault(),$.stopPropagation();const ie=$.target;if($.ctrlKey||$.metaKey){await N(he);return}if(ie.tagName==="A"){await sV(n,r,ie);return}if(ie.tagName==="IMG"){uV(f.current,ie);return}if(ie.tagName==="A"&&ie.getAttribute("href")){const ce=ie.getAttribute("href");window.open(ce,"_blank");return}if(ie.className==="memo-link-text"){cV(ie);return}if(ie.tagName==="INPUT"&&ie.hasClass("task-list-item-checkbox")){await dV(a,he,f.current,ie);return}},K=$=>{const he=new x.Menu;he.dom.toggleClass("memo-context-menu",!0);const ie=window.getSelection();(ie==null?void 0:ie.toString().length)>0&&he.addItem(ce=>{ce.setIcon("copy").setTitle(E("Copy selected text")).onClick(()=>{navigator.clipboard.writeText(ie.toString()).then(()=>{new x.Notice(E("COPY SUCCEED"))}).catch(()=>{new x.Notice(E("COPY FAILED"))})})}).addSeparator(),he.addItem(ce=>{ce.setIcon("copy").setTitle(E("Copy thino").toLocaleUpperCase()).onClick(async()=>{await V(),he.close()})}).addItem(ce=>{ce.setIcon("book-open").setTitle(E("READ")).onClick(w)}).addItem(ce=>{ce.setIcon(l.pinned?"pin-off":"pin").setTitle(l.pinned?E("UNPIN"):E("PIN")).onClick(D)}).addItem(ce=>{ce.setIcon("bookmark").setTitle(E("MARK")).onClick(S)}).addItem(ce=>{ce.setIcon("share-2").setTitle(E("SHARE")).onClick(L)}).addItem(ce=>{ce.setIcon("pencil").setTitle(E("EDIT")).onClick(I)}).addItem(ce=>{ce.setIcon("home").setTitle(E("SOURCE")).onClick(()=>N(l))}).addSeparator().addItem(ce=>{ce.setIcon("archive").setTitle(E("ARCHIVE").toLocaleUpperCase()).onClick(()=>R(l))}).addItem(ce=>{ce.setIcon("trash").setTitle(E("DELETE")).onClick(async()=>{await k()})}),he.showAtMouseEvent($.nativeEvent)},se=P.useMemo(()=>({memo:l,handlePinMemoClick:D,handleFixMemoClick:M,handleSourceMemoClick:N,handleArchiveMemo:R,handleDeleteMemoClick:k,handleGenMemoImageBtnClick:L,handleMarkMemoClick:S,handleEditMemoClick:I,handleCopyMemoClick:V,handleShowMemoStoryDialog:w,handleSplitMemoClick:Y}),[l]),le=P.useMemo(()=>({memo:l,handleMemoTypeToggle:_,handleShowMemoStoryDialog:w,settings:a}),[l,a]),fe=P.useMemo(()=>v.jsxs("div",{ref:f,className:`memo-wrapper ${l.pinned?"pinned":""}`,"data-source-type":l.sourceType,"data-thino-type":l.thinoType,"data-thino-id":l.id,onMouseLeave:B,onMouseOver:$=>{$.shiftKey&&($.stopPropagation(),n.workspace.trigger("hover-link",{event:$,source:"thino",hoverParent:r.containerEl,targetEl:f.current,linktext:l.path,sourcePath:l.path,state:{scroll:l.sourceType==="DAILY"?parseInt(l.id.slice(14)):0}}))},onContextMenu:K,children:[g&&v.jsx(hf,{editorType:"inline"}),!g&&v.jsxs(v.Fragment,{children:[c==="inline"&&v.jsxs("div",{className:"memo-top-wrapper",draggable:!0,onDragStart:$=>{$.target.classList.add("dragging"),$.dataTransfer.setDragImage(f.current,0,0),$.dataTransfer.setData("text/plain",l.content)},onDragEnd:$=>{$.target.classList.remove("dragging")},children:[v.jsx(oV,{...le}),v.jsx(aV,{...se})]}),v.jsx(e8,{memo:l,handleMemoContentClick:Q,handleMemoDoubleClick:Z})]})]}),[l,g]);return v.jsx(v.Fragment,{children:fe})},ai=P.memo(fV,(e,t)=>Iw.isEqual(e.memo,t.memo));class Ke extends x.Setting{constructor(n,r){super(n);Se(this,"settingTab");Se(this,"name","");Se(this,"desc","");this.settingTab=r}setName(n){return super.setName(n),this.name=n,this}setDesc(n){return super.setDesc(n),this.desc=n,this}setTab(n){const r=typeof this.name=="string"?this.name:this.name.textContent||"",a=typeof this.desc=="string"?this.desc:this.desc.textContent||"";return this.settingTab.addSettingToMasterSettingsList(n,this.settingEl,r,a),this}}class hV extends x.Modal{constructor(n,r,a,o,i){super(n);Se(this,"plugin");Se(this,"settingTab");Se(this,"target",5);Se(this,"cb");this.app=n,this.settingTab=r,this.plugin=a,this.target=o,this.cb=i}onOpen(){var l;const{contentEl:n}=this;(l=n.parentElement)==null||l.classList.add("memo-save-location-modal"),n.createEl("h3",{text:E("Thino Daily Target")});const r=n.createDiv("modal-setting");new Ke(r,this.settingTab).setName(E("Target Thino Count")).addSlider(c=>{c.setDynamicTooltip().setValue(this.target).setLimits(1,30,1).onChange(async f=>{this.target=f})});const a=n.createDiv("button-group"),o=a.createEl("button",{text:E("Cancel")}),i=a.createEl("button",{text:E("Save")});i.onclick=async()=>{this.plugin.settings.MemoDailyTarget=this.target,this.settingTab.applySettingsUpdate(),this.cb(this.target),this.close()},o.onclick=async()=>{this.close()}}onClose(){const{contentEl:n}=this;n.empty()}}const pV=({allStat:e,todayTimeStamp:t,calendarType:n,handleCalendarTypeChange:r})=>{const{dailyNotesState:{app:a,settings:o},globalState:{manifest:i}}=P.useContext(Lt),[l,c]=P.useState(),[f,h]=P.useState(5),[g,y]=P.useState(0),[w,S]=P.useState(0),[D,I]=P.useState(o.HeatmapColorScheme||"default"),M=P.useRef(null),N=P.useRef(null);P.useEffect(()=>{o.HeatmapColorScheme&&I(o.HeatmapColorScheme)},[o.HeatmapColorScheme]),P.useEffect(()=>{let k,B=5;i&&a&&(k=a==null?void 0:a.plugins.getPlugin(i.id),B=k==null?void 0:k.settings.MemoDailyTarget,c(k)),h(B)},[i,a]),P.useEffect(()=>{const k=e.find(_=>_.timestamp===t),B=k?k.count:0;S(B);const L=Math.min(100,B/f*100);y(L)},[e,f]),P.useEffect(()=>{x.requireApiVersion("1.4.4")&&(x.setTooltip(N.current,g.toFixed(2)+"%"),x.setTooltip(M.current,E("Set daily target")+` (${w}/${f})`))},[g,w]),P.useEffect(()=>{M.current&&(M.current.hasChildNodes()||x.setIcon(M.current,"crosshair"),x.requireApiVersion("1.4.4")&&x.setTooltip(N.current,g+"%"))},[M,f]);const R=P.useCallback(()=>{if(!l)return;new hV(a,l==null?void 0:l.settingTab,l,f,B=>{h(B)}).open()},[l,f]);return v.jsx(v.Fragment,{children:v.jsxs("div",{className:`usage-daily-progress-wrapper heatmap-${D}`,children:[v.jsx("div",{ref:N,className:"daily-progress-bar",children:v.jsx("div",{className:"daily-progress-bar-inner",style:{width:`${g}%`}})}),v.jsx("div",{ref:M,className:"daily-progress-target",onClick:R}),v.jsx("div",{ref:k=>{k&&x.setIcon(k,n==="basic"?"layout-grid":"calendar"),k&&x.setTooltip&&x.setTooltip(k,E("Switch calendar type"))},className:"switch-calendar-type-btn",onClick:()=>r&&r(n==="basic"?"heatmap":"basic")})]})})},mV=(e,t)=>{const n=[],r=Math.floor((e-t)/ei);for(let a=0;a<=r;a++)n.push({timestamp:t+ei*a,count:0,list:0});return n},gV=e=>{const{className:t,view:n,datestamp:r,handleDateStampChange:a,handleDateItemClick:o,handleMonthChange:i,dailyStat:l}=e,c=x.moment().startOf("day").valueOf(),[f,h]=P.useState(Xh(r)),[g,y]=P.useState(null),[w,S]=P.useState(e.dailyStat);P.useEffect(()=>{h(Xh(r));const k=mV(yV(r),Xh(r)),B=e.thinos.filter(L=>!L.deletedAt&&L.rowStatus!=="ARCHIVED");for(const L of B){const V=x.moment(L.createdAt,"YYYY/MM/DD HH:mm:ss").startOf("day").diff(x.moment(f).startOf("day"),"days");V>=0&&V{const B=D.getFullYear(),L=D.getMonth()+1;let _=0;L===1&&k===-1?_=new Date(`${B-1}/12/1`).getTime():L===12&&k===1?_=new Date(`${B+1}/1/1`).getTime():_=new Date(`${B}/${L+k}/1`).getTime(),h(Xh(_)),i&&i(_)};return v.jsxs("div",{className:`heatmap-date-picker-wrapper ${t}`,children:[v.jsxs("div",{className:"date-picker-header",children:[v.jsx("span",{ref:k=>{k&&x.setIcon(k,"chevron-left")},className:"btn btn-text",onClick:()=>R(-1)}),v.jsxs("span",{className:"normal-text",children:[v.jsx(E6,{year:D.getFullYear().toString(),handleYearChange:k=>{h(Xh(new Date(`${k}/${D.getMonth()+1}/1`).getTime()))}}),v.jsx(C6,{month:D.getMonth().toString(),handleMonthChange:k=>{h(Xh(new Date(`${D.getFullYear()}/${parseInt(k)}/1`).getTime()))}})]}),v.jsx("span",{ref:k=>{k&&x.setIcon(k,"chevron-right")},className:"btn btn-text",onClick:()=>R(1)})]}),v.jsxs("div",{className:"date-picker-day-container",children:[v.jsx("div",{className:"date-picker-day-header",children:E("weekDaysShort").map(k=>v.jsx("span",{className:"day-item",children:k},k))}),v.jsx("div",{className:"date-picker-day-content",children:M.map(k=>{if(k.date===0)return v.jsx("span",{className:"day-item null",children:""},k.datestamp);const B=w.find(V=>V.timestamp===k.datestamp)||{count:0,timestamp:k.datestamp,list:0},L=B.count-B.list,_=B.list;return v.jsxs("span",{className:`day-item ${k.datestamp===c?"current":""} ${k.datestamp===g?"selected":""} ${jS(B.count)}`,onClick:V=>{a(r,V.nativeEvent),y(k.datestamp===g?null:k.datestamp),o&&o(V,B)},onMouseOver:V=>{if(!B||!B.count)return;const Y=new x.HoverPopover(n,V.currentTarget,100);t8(Y,{d:k,list:_,task:L})},children:[v.jsx("span",{className:"day-item-text",children:k.date}),v.jsx(v.Fragment,{children:B&&B.count!==0&&v.jsxs("span",{className:"day-item-dots",children:[L>0&&v.jsx("div",{className:`day-item-dot thino-task-dot ${jS(L)}`}),_>0&&v.jsx("div",{className:`day-item-dot thino-list-dot ${jS(_)}`})]})})]},k.datestamp)})})]})]})};function t8(e,{d:t,list:n,task:r}){e.hoverEl.toggleClass("thino-hover-popover",!0);const a=e.hoverEl.createDiv({cls:"thino-hover-popover-content"});a.createDiv({cls:"thino-date-item",text:`${x.moment(t.datestamp).format("YYYY-MM-DD")}`});const o=a.createDiv({cls:"thino-task-item"});o.createSpan({cls:"thino-task-item-title-text",text:`${E("Task")}: `}),o.createSpan({cls:"thino-task-item-title-count",text:`${r}`});const i=a.createDiv({cls:"thino-list-item"});i.createSpan({cls:"thino-list-item-title-text",text:`${E("List")}: `}),i.createSpan({cls:"thino-list-item-title-count",text:`${n}`})}function vV(e){const t=new Date(e),n=new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`);return((n.getMonth()===11?new Date(`${n.getFullYear()+1}/1/1`):new Date(`${n.getFullYear()}/${n.getMonth()+2}/1`)).getTime()-n.getTime())/ei}function Xh(e){const t=new Date(e);return new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`).getTime()}function yV(e){const t=new Date(e),n=new Date(`${t.getFullYear()}/${t.getMonth()+1}/1`);return(n.getMonth()===11?new Date(`${n.getFullYear()+1}/1/1`):new Date(`${n.getFullYear()}/${n.getMonth()+2}/1`)).getTime()-ei}function jS(e){return e<=0?"":e<=1?"stat-day-L1-bg":e<=2?"stat-day-L2-bg":e<=4?"stat-day-L3-bg":"stat-day-L4-bg"}const Ux={width:12,height:7},zx=(e,t)=>{const n=[];for(let r=0;r<=e;r++)n.push({timestamp:t+ei*r,count:0,list:0});return n},tv=({initThinos:e,basicType:t})=>{const n=parseInt(x.moment().endOf("day").format("x"));new Date(n).getDay();const r=parseInt(x.moment().startOf("day").format("x")),a=new Array(6-new Date(n).getDay()).fill(0),o=Ux.width*Ux.height,i=parseInt(x.moment().startOf("day").subtract(o,"days").format("x")),l=x.moment().startOf("day").subtract(o,"days"),{memoState:{memos:c},dailyNotesState:{view:f,app:h,settings:g,verifyState:y}}=P.useContext(Lt),[w,S]=xo(t||bV(h||window.app)||"heatmap"),[D,I]=xo(x.moment().startOf("day").valueOf()),[M,N]=xo(g.HeatmapColorScheme||"default"),[R,k]=xo(zx(o,i)),[B,L]=xo(null),[_,V,Y]=xo(""),Z=P.useRef(null);P.useEffect(()=>{const fe=zx(o,i),$=(e||c).filter(he=>!he.deletedAt&&he.rowStatus!=="ARCHIVED");for(const he of $){const ce=x.moment(he.createdAt.replaceAll("/","-"),"YYYY-MM-DD HH:mm:ss").startOf("day").diff(l,"days");ce>=0&&ce{g.HeatmapColorScheme&&N(g.HeatmapColorScheme)},[g.HeatmapColorScheme]);const Q=P.useCallback((fe,$)=>{if(!$||!$.count)return;const he=$.count-$.list,ie=$.list,ce={date:$.timestamp,datestamp:$.timestamp},X=new x.HoverPopover(f,fe.currentTarget,100);t8(X,{d:ce,list:ie,task:he})},[]),K=()=>{S(w==="heatmap"?"basic":"heatmap"),wV(h,w==="heatmap"?"basic":"heatmap"),I(x.moment().startOf("day").valueOf())},se=P.useCallback(async(fe,$)=>{if($.count===0)return;const he=at.getState().query.duration,ie=he==null?void 0:he.from,ce=he==null?void 0:he.to,X=x.moment(ie).diff(ce,"day")==0;if(ie===$.timestamp&&X)at.setFromAndToQuery(0,0),L(null),V(null);else if(ie!==$.timestamp&&ie>0&&fe.shiftKey){const ae=x.moment($.timestamp).endOf("day").diff(ce,"day");ie===0&&fe.shiftKey?V("from"):ae<0&&X&&V("to"),x.moment(ie).isBefore($.timestamp)?Y.current==="to"?ae<0?at.setFromAndToQuery($.timestamp,ce):(at.setFromAndToQuery(parseInt(x.moment(ce).startOf("day").format("x")),parseInt(x.moment($.timestamp).endOf("day").format("x"))),V("from")):Y.current==="from"&&(ae<0,at.setFromAndToQuery(ie,parseInt(x.moment($.timestamp).endOf("day").format("x")))):Y.current==="to"?at.setFromAndToQuery($.timestamp,ce):Y.current==="from"&&(at.setFromAndToQuery($.timestamp,parseInt(x.moment(ie).endOf("day").format("x"))),V("to"))}else if(ie===0&&fe.shiftKey)at.setFromAndToQuery($.timestamp,parseInt(x.moment().endOf("day").format("x")));else if($.count>0&&(fe.ctrlKey||fe.metaKey)){const{app:ae,dailyNotes:De}=ft.getState(),je=fb(x.moment($.timestamp),De);if(!x.Platform.isMobile)await ae.workspace.getLeaf(!0).openFile(je);else{let Re=ae.workspace.activeLeaf;Re===null&&(Re=ae.workspace.getLeaf(!0)),Re.openFile(je)}}else $.count>0&&!fe.shiftKey&&!fe.ctrlKey&&!fe.metaKey&&(["/","/recycle"].includes(at.getState().pathname)||at.setPathname("/"),at.setFromAndToQuery($.timestamp,ut.getTimeStampByDate(x.moment($.timestamp+ei).subtract(1,"days").endOf("day").format("YYYY-MM-DD HH:mm:ss"))),L($))},[]),le=P.useMemo(()=>v.jsx(gV,{className:`heatmap-${M}`,view:f,datestamp:D,dailyStat:R,thinos:e||c,handleMonthChange:fe=>{I(fe)},handleDateStampChange:fe=>{},handleDateItemClick:(fe,$)=>se(fe,$)}),[JSON.stringify(R),e,c,f,D,M]);return v.jsxs(v.Fragment,{children:[w==="basic"&&le,w==="heatmap"&&v.jsxs("div",{className:`usage-heat-map-wrapper heatmap-${M}`,ref:Z,children:[v.jsxs("div",{className:"day-tip-text-container",children:[v.jsx("span",{className:"tip-text",children:E("weekDaysShort")[0]}),v.jsx("span",{className:"tip-text"}),v.jsx("span",{className:"tip-text",children:E("weekDaysShort")[2]}),v.jsx("span",{className:"tip-text"}),v.jsx("span",{className:"tip-text",children:E("weekDaysShort")[4]}),v.jsx("span",{className:"tip-text"}),v.jsx("span",{className:"tip-text",children:E("weekDaysShort")[6]})]}),v.jsxs("div",{className:"usage-heat-map",children:[R.slice(R.length-84+a.length,R.length).map((fe,$)=>{const he=fe.count,ie=he<=0?"":he<=1?"stat-day-L1-bg":he<=2?"stat-day-L2-bg":he<=4?"stat-day-L3-bg":"stat-day-L4-bg";return v.jsx("span",{"data-timestamp":fe.timestamp,"data-count":fe.count,"data-list-count":fe.list,"data-task-count":fe.count-fe.list,className:`stat-container ${ie} ${B===fe?"current":""} ${r===fe.timestamp?"today":""}`,onMouseOver:ce=>Q(ce,fe),onClick:ce=>se(ce,fe)},$)}),a.map((fe,$)=>v.jsx("span",{className:"stat-container null"},$))]})]}),!t&&v.jsx(pV,{allStat:R,todayTimeStamp:r,calendarType:w,handleCalendarTypeChange:K})]})};function wV(e,t){try{e==null||e.saveLocalStorage("calendarType",t)}catch(n){console.error(n)}}function bV(e){try{return(e==null?void 0:e.loadLocalStorage("calendarType"))||"heatmap"}catch(t){return console.error(t),"heatmap"}}const n8=({type:e,timestamp:t})=>{const{memoState:{memos:n}}=P.useContext(Lt),[r,a]=P.useState([]),o=ne.useRef(null);return P.useEffect(()=>{if(e==="daily"){if(t){const l=n.filter(c=>x.moment(c.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(x.moment(t,"YYYY/MM/DD HH:mm:ss"),"day"));a(l);return}const i=n.filter(l=>x.moment(l.createdAt,"YYYY/MM/DD HH:mm:ss").isSame(x.moment(),"day"));a(i)}else if(e==="latest"){const i=n.filter(f=>!f.deletedAt&&f.rowStatus!=="ARCHIVED"),l=i.filter(f=>f.pinned),c=i.filter(f=>!f.pinned).slice(0,5);a([...l,...c])}},[n]),P.useEffect(()=>{o.current&&(o.current.scrollTop=0)},[n]),r.length>0?v.jsx("div",{ref:o,className:"thino-list-container",children:r.map(i=>v.jsx(ai,{memo:i}))}):v.jsx("div",{className:"tip-text-container",children:v.jsx("span",{className:"tip-text",children:E("Here is No Memos.")})})},SV=(e,t)=>{rs.createRoot(e).render(v.jsx(ne.StrictMode,{children:v.jsx(is,{store:Le,context:Lt,children:v.jsx(DV,{plugin:t})})}))},DV=({plugin:e})=>v.jsxs(v.Fragment,{children:[v.jsx("div",{className:"thino-error-code-block",children:E("Please open thino first")}),v.jsx("button",{className:"thino-open-view",onClick:()=>e.openMemos("center"),children:E("Open thino in center window")})]}),TV=(e,t)=>{rs.createRoot(e).render(v.jsx(ne.StrictMode,{children:v.jsx(is,{store:Le,context:Lt,children:v.jsx(IV,{yaml:t})})}))},IV=({yaml:e})=>{const t=Object.keys(e).filter(a=>e[a]),n=e.daily?e.daily:"",r=a=>{switch(a){case"editor":return Vx;case"heatmap":return CV;case"calendar":return xV;case"daily":return kV;case"list":return NV;case"status":return MV;default:return Vx}};return v.jsx(v.Fragment,{children:t.map(a=>v.jsx("div",{"data-embed-type":a,className:ar("thino-embed-container",a==="editor"?"thino-editor-modal":""),children:a==="daily"?r(a)(n):r(a)()}))})};function Vx(){return v.jsx(hf,{editorType:"inline",modal:!0})}function EV(e,t,n){try{const r=rs.createRoot(e);return r.render(v.jsx(ne.StrictMode,{children:v.jsx(is,{store:Le,context:Lt,children:v.jsx(hf,{editorType:"inline",destroy:t,modal:n})})})),r}catch(r){console.error(r)}}function CV(){return v.jsx(tv,{basicType:"heatmap"})}function xV(){return v.jsx(tv,{basicType:"basic"})}function MV(){return v.jsx(G2,{statusType:"banner"})}function kV(e){return v.jsx(n8,{type:"daily",timestamp:e})}function NV(){return v.jsx(n8,{type:"latest"})}class CT extends x.Modal{constructor(n){super(n);Se(this,"root")}getViewType(){return"thino_view"}onOpen(){const{contentEl:n,modalEl:r}=this;try{this.root=EV(n,this.close.bind(this),this),r.toggleClass("thino-editor-modal",!0),setTimeout(()=>{var a;(a=n.querySelector("textarea"))==null||a.focus(),this.app.workspace.trigger("focus-on-textarea")},10)}catch(a){console.error(a)}}onClose(){this.root.unmount(),this.containerEl&&this.containerEl.empty()}}function AV(e,t){if(e==null)return{};var n=FV(e,t),r,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function FV(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o=0)&&(n[a]=e[a]);return n}function jw(){return jw=Object.assign||function(e){for(var t=1;t{this.reCalculateColumnCount()})}reCalculateColumnCount(){const t=window&&window.innerWidth||1/0;let n=this.props.breakpointCols;typeof n!="object"&&(n={default:parseInt(n)||LS});let r=1/0,a=n.default||LS;for(let o in n){const i=parseInt(o);i>0&&t<=i&&i"u"&&(i="my-masonry-grid_column"));const l=Sg(Sg(Sg({},t),n),{},{style:Sg(Sg({},n.style),{},{width:o}),className:i});return a.map((c,f)=>ne.createElement("div",jw({},l,{key:f}),c))}logDeprecated(t){console.error("[Masonry]",t)}render(){const t=this.props,{children:n,breakpointCols:r,columnClassName:a,columnAttrs:o,column:i,className:l}=t,c=AV(t,["children","breakpointCols","columnClassName","columnAttrs","column","className"]);let f=l;return typeof l!="string"&&(this.logDeprecated('The property "className" requires a string'),typeof l>"u"&&(f="my-masonry-grid")),ne.createElement("div",jw({},c,{className:f}),this.renderColumns())}}Lw.defaultProps=PV;const xT=e=>{P.useContext(Lt);const t=Le.getState().dailyNotesState.settings,{thinos:n,dayMark:r,dayMarkRange:a="day",thinoWrapper:o}=e,[i,l]=ne.useState(!(t!=null&&t.hidePinnedGroup&&r==="PINNED")),c=ne.useRef(null);P.useEffect(()=>{c&&x.setTooltip&&x.setTooltip(c.current,E("Click to expand or fold, Cmd+Click to show all thinos of the day"))},[c]);const f=h=>{if(x.Keymap.isModifier(h.nativeEvent,"Mod")){const g={day:"YYYY-MM-DD",week:"YYYY-[W]WW",month:"YYYY-MM",quarter:"YYYY-[Q]Q",year:"YYYY"},y=x.moment(r,g[a]);at.setFromAndToQuery(y.startOf(a).valueOf(),y.endOf(a).valueOf());return}l(!i)};return v.jsx(v.Fragment,{children:e.type==="list"?v.jsxs(v.Fragment,{children:[v.jsx("div",{ref:c,className:`day-mark ${i?"":"folded"} PINNED`,onClick:f,children:v.jsxs("span",{className:"day-mark-text",children:[i?"▼ ":"▶ ",r==="PINNED"?r+" 📌":r]})},r),i&&n.map((h,g)=>o?v.jsx("div",{children:o({thino:h})},`${h.id}-${x.moment(h.createdAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${g}`):v.jsx(ai,{memo:h},`${h.id}-${x.moment(h.createdAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${g}`))]}):v.jsxs(v.Fragment,{children:[v.jsx("div",{ref:c,className:`day-mark ${i?"":"folded"}`,onClick:f,children:v.jsxs("span",{className:"day-mark-text",children:[i?"▼ ":"▶ ",r==="PINNED"?r+" 📌":r]})},r),v.jsx(Lw,{breakpointCols:e.type==="waterfall"?3:1,className:`${e.type}-view masonry-memolist`,columnClassName:"masonry-memolist-grid_column",children:i&&n.map((h,g)=>o?v.jsx("div",{children:o({thino:h})},`${h.id}-${x.moment(h.updatedAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${g}`):v.jsx(ai,{memo:h},`${h.id}-${x.moment(h.updatedAt,"YYYY/MM/DD HH:mm:ss").format("x")}-${g}`))})]})})};function zu(e){"@babel/helpers - typeof";return zu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zu(e)}function jV(e,t){if(zu(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(zu(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function r8(e){var t=jV(e,"string");return zu(t)=="symbol"?t:String(t)}function of(e,t,n){return t=r8(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $x(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function tr(e){for(var t=1;t=0)&&(n[a]=e[a]);return n}function Xl(e,t){if(e==null)return{};var n=kb(e,t),r,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Ma(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Zx(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n1?H-1:0),z=1;zt}),Bv=Up(function(e,t){return e>=t}),nI=Up(function(e,t){return e=t&&a.getHours()-n.getHours()a?0:a+t),n=n>a?a:n,n<0&&(n+=a),a=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(a);++r-1&&e%1==0&&e<=IW}var aI=EW,xW=rI,CW=aI;function MW(e){return e!=null&&CW(e.length)&&!xW(e)}var Yv=MW,kW=9007199254740991,NW=/^(?:0|[1-9]\d*)$/;function AW(e,t){var n=typeof e;return t=t??kW,!!t&&(n=="number"||n!="symbol"&&NW.test(e))&&e>-1&&e%1==0&&e{t.current=e},[e]),t}function tM(e){const t=O$(e);return P.useCallback(function(...n){return t.current&&t.current(...n)},[t])}function nM(){return P.useState(null)}function P$(){const e=P.useRef(!0),t=P.useRef(()=>e.current);return P.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function j$(e){const t=P$();return[e[0],P.useCallback(n=>{if(t())return e[1](n)},[t,e[1]])]}var L$=P6({defaultModifiers:[N6,F6,E6,x6,A6,k6,O6,I6]}),rM=function(t){return{position:t,top:"0",left:"0",opacity:"0",pointerEvents:"none"}},R$={name:"applyStyles",enabled:!1},_$={name:"ariaDescribedBy",enabled:!0,phase:"afterWrite",effect:function(t){var n=t.state;return function(){var r=n.elements,a=r.reference,o=r.popper;if("removeAttribute"in a){var i=(a.getAttribute("aria-describedby")||"").split(",").filter(function(l){return l.trim()!==o.id});i.length?a.setAttribute("aria-describedby",i.join(",")):a.removeAttribute("aria-describedby")}}},fn:function(t){var n,r=t.state,a=r.elements,o=a.popper,i=a.reference,l=(n=o.getAttribute("role"))==null?void 0:n.toLowerCase();if(o.id&&l==="tooltip"&&"setAttribute"in i){var c=i.getAttribute("aria-describedby");if(c&&c.split(",").indexOf(o.id)!==-1)return;i.setAttribute("aria-describedby",c?c+","+o.id:o.id)}}},B$=[];function H$(e,t,n){var r=n===void 0?{}:n,a=r.enabled,o=a===void 0?!0:a,i=r.placement,l=i===void 0?"bottom":i,c=r.strategy,f=c===void 0?"absolute":c,p=r.modifiers,g=p===void 0?B$:p,y=xb(r,["enabled","placement","strategy","modifiers"]),w=P.useRef(),T=P.useCallback(function(){var k;(k=w.current)==null||k.update()},[]),S=P.useCallback(function(){var k;(k=w.current)==null||k.forceUpdate()},[]),I=j$(P.useState({placement:l,update:T,forceUpdate:S,attributes:{},styles:{popper:rM(f),arrow:{}}})),M=I[0],N=I[1],_=P.useMemo(function(){return{name:"updateStateModifier",enabled:!0,phase:"write",requires:["computeStyles"],fn:function(R){var L=R.state,H={},U={};Object.keys(L.elements).forEach(function(z){H[z]=L.styles[z],U[z]=L.attributes[z]}),N({state:L,styles:H,attributes:U,update:T,forceUpdate:S,placement:L.placement})}}},[T,S,N]);return P.useEffect(function(){!w.current||!o||w.current.setOptions({placement:l,strategy:f,modifiers:[].concat(g,[_,R$])})},[f,l,_,o]),P.useEffect(function(){if(!(!o||e==null||t==null))return w.current=L$(e,t,Pr({},y,{placement:l,strategy:f,modifiers:[].concat(g,[_$,_])})),function(){w.current!=null&&(w.current.destroy(),w.current=void 0,N(function(k){return Pr({},k,{attributes:{},styles:{popper:rM(f)}})}))}},[o,e,t]),M}function Y$(e,t,n,r){var a=r&&typeof r!="boolean"?r.capture:r;e.removeEventListener(t,n,a),n.__once&&e.removeEventListener(t,n.__once,a)}function Og(e,t,n,r){return F$(e,t,n,r),function(){Y$(e,t,n,r)}}function U$(e){return e&&"setState"in e?z2.findDOMNode(e):e??null}const z$=function(e){return zv(U$(e))};var V$=27,aM=function(){};function W$(e){return e.button===0}function $$(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var oM=function(t){return t&&("current"in t?t.current:t)};function Z$(e,t,n){var r=n===void 0?{}:n,a=r.disabled,o=r.clickTrigger,i=o===void 0?"click":o,l=P.useRef(!1),c=t||aM,f=P.useCallback(function(y){var w,T=oM(e);YU(!!T,"RootClose captured a close event but does not have a ref to compare it to. useRootClose(), should be passed a ref that resolves to a DOM node"),l.current=!T||$$(y)||!W$(y)||!!lv(T,(w=y.composedPath==null?void 0:y.composedPath()[0])!=null?w:y.target)},[e]),p=tM(function(y){l.current||c(y)}),g=tM(function(y){y.keyCode===V$&&c(y)});P.useEffect(function(){if(!(a||e==null)){var y=window.event,w=z$(oM(e)),T=Og(w,i,f,!0),S=Og(w,i,function(N){if(N===y){y=void 0;return}p(N)}),I=Og(w,"keyup",function(N){if(N===y){y=void 0;return}g(N)}),M=[];return"ontouchstart"in w.documentElement&&(M=[].slice.call(w.body.children).map(function(N){return Og(N,"mousemove",aM)})),function(){T(),S(),I(),M.forEach(function(N){return N()})}}},[e,a,i,f,p,g])}function q$(e){var t={};return Array.isArray(e)?(e==null||e.forEach(function(n){t[n.name]=n}),t):e||t}function G$(e){return e===void 0&&(e={}),Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t].name=t,e[t]})}function J$(e){var t,n,r,a,o=e.enabled,i=e.enableEvents,l=e.placement,c=e.flip,f=e.offset,p=e.fixed,g=e.containerPadding,y=e.arrowElement,w=e.popperConfig,T=w===void 0?{}:w,S=q$(T.modifiers);return Pr({},T,{placement:l,enabled:o,strategy:p?"fixed":T.strategy,modifiers:G$(Pr({},S,{eventListeners:{enabled:i},preventOverflow:Pr({},S.preventOverflow,{options:g?Pr({padding:g},(t=S.preventOverflow)==null?void 0:t.options):(n=S.preventOverflow)==null?void 0:n.options}),offset:{options:Pr({offset:f},(r=S.offset)==null?void 0:r.options)},arrow:Pr({},S.arrow,{enabled:!!y,options:Pr({},(a=S.arrow)==null?void 0:a.options,{element:y})}),flip:Pr({enabled:!!c},S.flip)}))})}function K$(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function Q$(e,t){e.classList?e.classList.add(t):K$(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function iM(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function X$(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=iM(e.className,t):e.setAttribute("class",iM(e.className&&e.className.baseVal||"",t))}var E0;function I8(e){if((!E0&&E0!==0||e)&&sI){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),E0=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return E0}var RS=function(t){var n;return typeof document>"u"?null:t==null?zv().body:(typeof t=="function"&&(t=t()),t&&"current"in t&&(t=t.current),(n=t)!=null&&n.nodeType&&t||null)};function sM(e,t){var n=P.useState(function(){return RS(e)}),r=n[0],a=n[1];if(!r){var o=RS(e);o&&a(o)}return P.useEffect(function(){t&&r&&t(r)},[t,r]),P.useEffect(function(){var i=RS(e);i!==r&&a(i)},[e,r]),r}const lM=e=>!e||typeof e=="function"?e:t=>{e.current=t};function eZ(e,t){const n=lM(e),r=lM(t);return a=>{n&&n(a),r&&r(a)}}function tZ(e,t){return P.useMemo(()=>eZ(e,t),[e,t])}var lI=ne.forwardRef(function(e,t){var n=e.flip,r=e.offset,a=e.placement,o=e.containerPadding,i=o===void 0?5:o,l=e.popperConfig,c=l===void 0?{}:l,f=e.transition,p=nM(),g=p[0],y=p[1],w=nM(),T=w[0],S=w[1],I=tZ(y,t),M=sM(e.container),N=sM(e.target),_=P.useState(!e.show),k=_[0],R=_[1],L=H$(N,g,J$({placement:a,enableEvents:!!e.show,containerPadding:i||5,flip:n,offset:r,arrowElement:T,popperConfig:c})),H=L.styles,U=L.attributes,z=xb(L,["styles","attributes"]);e.show?k&&R(!1):!e.transition&&!k&&R(!0);var $=function(){R(!0),e.onExited&&e.onExited.apply(e,arguments)},X=e.show||f&&!k;if(Z$(g,e.onHide,{disabled:!e.rootClose||e.rootCloseDisabled,clickTrigger:e.rootCloseEvent}),!X)return null;var Q=e.children(Pr({},z,{show:!!e.show,props:Pr({},U.popper,{style:H.popper,ref:I}),arrowProps:Pr({},U.arrow,{style:H.arrow,ref:S})}));if(f){var se=e.onExit,ue=e.onExiting,fe=e.onEnter,Z=e.onEntering,pe=e.onEntered;Q=ne.createElement(f,{in:e.show,appear:!0,onExit:se,onExiting:ue,onExited:$,onEnter:fe,onEntering:Z,onEntered:pe},Q)}return M?z2.createPortal(Q,M):null});lI.displayName="Overlay";lI.propTypes={show:ke.bool,placement:ke.oneOf($2),target:ke.any,container:ke.any,flip:ke.bool,children:ke.func.isRequired,containerPadding:ke.number,popperConfig:ke.object,rootClose:ke.bool,rootCloseEvent:ke.oneOf(["click","mousedown"]),rootCloseDisabled:ke.bool,onHide:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a-1}var vZ=gZ,yZ=kb;function wZ(e,t){var n=this.__data__,r=yZ(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var bZ=wZ,SZ=aZ,DZ=dZ,TZ=pZ,IZ=vZ,EZ=bZ;function Wp(e){var t=-1,n=e==null?0:e.length;for(this.clear();++tl))return!1;var f=o.get(e),p=o.get(t);if(f&&p)return f==t&&p==e;var g=-1,y=!0,w=n&RG?new OG:void 0;for(o.set(e,t),o.set(t,e);++g0&&n(l)?t>1?U8(l,t-1,n,r,a):Gee(a,l):r||(a[a.length]=l)}return a}var z8=U8;function Kee(e){return function(t,n,r){for(var a=-1,o=Object(t),i=r(t),l=i.length;l--;){var c=i[e?l:++a];if(n(o[c],c,o)===!1)break}return t}}var Qee=Kee,Xee=Qee,ete=Xee(),tte=ete,nte=tte,rte=Vv;function ate(e,t){return e&&nte(e,t,rte)}var DI=ate,ote=Yv;function ite(e,t){return function(n,r){if(n==null)return n;if(!ote(n))return e(n,r);for(var a=n.length,o=t?a:-1,i=Object(n);(t?o--:++ot||o&&i&&c&&!l&&!f||r&&i&&c||!n&&c||!a)return 1;if(!r&&!o&&!f&&e=l)return c;var f=n[r];return c*(f=="desc"?-1:1)}}return e.index-t.index}var Dte=Ste,zS=SI,Tte=Rb,Ite=Bb,Ete=mte,xte=vte,Cte=Pb,Mte=Dte,kte=_b,Nte=ss;function Ate(e,t,n){t.length?t=zS(t,function(o){return Nte(o)?function(i){return Tte(i,o.length===1?o[0]:o)}:o}):t=[kte];var r=-1;t=zS(t,Cte(Ite));var a=Ete(e,function(o,i,l){var c=zS(t,function(f){return f(o)});return{criteria:c,index:++r,value:o}});return xte(a,function(o,i){return Mte(o,i,n)})}var Fte=Ate;function Ote(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}var Pte=Ote,jte=Pte,BM=Math.max;function Lte(e,t,n){return t=BM(t===void 0?e.length-1:t,0),function(){for(var r=arguments,a=-1,o=BM(r.length-t,0),i=Array(o);++a0){if(++t>=Wte)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Gte=qte,Jte=Vte,Kte=Gte,Qte=Kte(Jte),$8=Qte,Xte=_b,ene=V8,tne=$8;function nne(e,t){return tne(ene(e,t,Xte),e+"")}var Z8=nne,rne=z8,ane=Fte,one=Z8,YM=Mb,ine=one(function(e,t){if(e==null)return[];var n=t.length;return n>1&&YM(e,t[0],t[1])?t=[]:n>2&&YM(t[0],t[1],t[2])&&(t=[t[0]]),ane(e,rne(t,1),[])}),sne=ine;const lne=qt(sne);function OT(e,t){var n=iI(e);return n?n.innerWidth:t?e.clientWidth:hf(e).width}function q8(e){return Q6(e)||h8(e)||eI(e)||X6()}function une(e,t){for(var n=-1,r=e==null?0:e.length;++n1),o}),eie(e,rie(e),n),r&&(n=Koe(n,aie|oie|iie,tie));for(var a=t.length;a--;)Qoe(n,t[a]);return n}),lie=sie;const uie=qt(lie);var cie=Z8,die=Hv,fie=Mb,hie=Hb,a9=Object.prototype,pie=a9.hasOwnProperty,mie=cie(function(e,t){e=Object(e);var n=-1,r=t.length,a=r>2?t[2]:void 0;for(a&&fie(t[0],t[1],a)&&(r=1);++n0&&(l=l[0]),c=(l=l.filter(function(p){return p}))[0];for(var f=1;f2?r-2:0),o=2;o2&&arguments[2]!==void 0?arguments[2]:"day",r=e,a=[];Yp(r,t,n);)a.push(r),r=zs(r,1,n);return a}function Zie(e,t){return t==null&&e==null?null:(t==null&&(t=new Date),e==null&&(e=new Date),e=$a(e,"day"),e=sv(e,sv(t)),e=Tp(e,Tp(t)),e=iv(e,iv(t)),ov(e,ov(t)))}function e3(e){return sv(e)===0&&Tp(e)===0&&iv(e)===0&&ov(e)===0}function qie(e,t,n,r){return n==="day"&&(n="date"),Math.abs(WC[n](e,void 0,r)-WC[n](t,void 0,r))}function EI(e,t,n){return!n||n==="milliseconds"?Math.abs(+e-+t):Math.round(Math.abs(+$a(e,n)/XM[n]-+$a(t,n)/XM[n]))}var Gie=ke.oneOfType([ke.string,ke.func]);function Jie(e,t,n,r,a){var o=typeof r=="function"?r(n,a,e):t.call(e,n,r,a);return Xg(o==null||typeof o=="string","`localizer format(..)` must return a string, null, or undefined"),o}function Kie(e,t,n){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,t+n,0,0)}function xI(e,t){return e.getTimezoneOffset()-t.getTimezoneOffset()}function Qie(e,t){return EI(e,t,"minutes")+xI(e,t)}function Xie(e){var t=$a(e,"day");return EI(t,e,"minutes")+xI(t,e)}function ese(e,t){return nI(e,t,"day")}function tse(e,t,n){var r=_v(e,t,"minutes");return r?Bv(t,n,"minutes"):Cb(t,n,"minutes")}function PT(e,t){return qie(e,t,"day")}function nse(e){var t=e.evtA,n=t.start,r=t.end,a=t.allDay,o=e.evtB,i=o.start,l=o.end,c=o.allDay,f=+$a(n,"day")-+$a(i,"day"),p=PT(n,r),g=PT(i,l);return f||g-p||!!c-!!a||+n-+i||+r-+l}function rse(e){var t=e.event,n=t.start,r=t.end,a=e.range,o=a.start,i=a.end,l=$a(n,"day"),c=Yp(l,i,"day"),f=tI(l,r,"minutes"),p=f?Cb(r,o,"minutes"):Bv(r,o,"minutes");return c&&p}function ase(e,t){return _v(e,t,"day")}function ose(e,t){return e3(e)&&e3(t)}var ise=ka(function e(t){var n=this;Ma(this,e),Xg(typeof t.format=="function","date localizer `format(..)` must be a function"),Xg(typeof t.firstOfWeek=="function","date localizer `firstOfWeek(..)` must be a function"),this.propType=t.propType||Gie,this.formats=t.formats,this.format=function(){for(var r=arguments.length,a=new Array(r),o=0;o1,ue=I.eventProp(i,X,$,l),fe=ne.createElement("div",{className:"rbc-event-content",title:z||void 0},_?ne.createElement(_,{event:i,continuesPrior:w,continuesAfter:T,title:U,isAllDay:Q,localizer:y,slotStart:R,slotEnd:L}):U);return ne.createElement(k,Object.assign({},this.props,{type:"date"}),ne.createElement("div",Object.assign({},H,{style:tr(tr({},ue.style),a),className:ca("rbc-event",o,ue.className,{"rbc-selected":l,"rbc-event-allday":se,"rbc-event-continues-prior":w,"rbc-event-continues-after":T}),onClick:function(pe){return f&&f(i,pe)},onDoubleClick:function(pe){return p&&p(i,pe)},onKeyDown:function(pe){return g&&g(i,pe)}}),typeof M=="function"?M(fe):fe))}}]),t}(ne.Component);function Ub(e,t){return!e||t==null?!1:kQ(e,t)}function l9(e,t){var n=e.right-e.left,r=n/t;return r}function u9(e,t,n,r){var a=l9(e,r);return n?r-1-Math.floor((t-e.left)/a):Math.floor((t-e.left)/a)}function fse(e,t){var n=t.x,r=t.y;return r>=e.top&&r<=e.bottom&&n>=e.left&&n<=e.right}function hse(e,t,n,r,a){var o=-1,i=-1,l=r-1,c=l9(t,r),f=u9(t,n.x,a,r),p=t.topn.y,g=t.tope.y,y=e.y>t.bottom,w=t.top>e.y,T=n.top