@desktalk/miniapp-note 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/frontend.js +26 -23
- package/dist/frontend.js.map +4 -4
- package/package.json +3 -3
package/dist/frontend.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var h=window.React,
|
|
1
|
+
var h=window.React,Be=h.Children,qe=h.Component,je=h.Fragment,Ue=h.Profiler,Ge=h.PureComponent,Ye=h.StrictMode,Xe=h.Suspense,Ke=h.cloneElement,Je=h.createContext,Qe=h.createElement,Ze=h.createRef,ft=h.forwardRef,tr=h.isValidElement,er=h.lazy,rr=h.memo,ir=h.startTransition,x=h.useCallback,nr=h.useContext,or=h.useDebugValue,sr=h.useDeferredValue,B=h.useEffect,ar=h.useId,_t=h.useImperativeHandle,dr=h.useInsertionEffect,lr=h.useLayoutEffect,cr=h.useMemo,hr=h.useReducer,H=h.useRef,I=h.useState,ur=h.useSyncExternalStore,pr=h.useTransition,mr=h.version,st=window.ReactDOM,xt=st.createRoot,gr=st.hydrateRoot;import{useCommand as q,MiniAppIdProvider as wt,WindowIdProvider as yt}from"@desktalk/sdk";var v={root:"NoteApp_root",rootCompact:"NoteApp_rootCompact",listPanel:"NoteApp_listPanel",listHeader:"NoteApp_listHeader",searchInput:"NoteApp_searchInput",newNoteBtn:"NoteApp_newNoteBtn",noteList:"NoteApp_noteList",noteItem:"NoteApp_noteItem",noteItemActive:"NoteApp_noteItem NoteApp_noteItemActive",emptyState:"NoteApp_emptyState",noteTitle:"NoteApp_noteTitle",notePreview:"NoteApp_notePreview",noteDate:"NoteApp_noteDate",editorPanel:"NoteApp_editorPanel",editorHeader:"NoteApp_editorHeader",editorTitle:"NoteApp_editorTitle",editorTags:"NoteApp_editorTags",editorTag:"NoteApp_editorTag",editorBody:"NoteApp_editorBody",editorPlaceholder:"NoteApp_editorPlaceholder",saveStatus:"NoteApp_saveStatus",saveStatusSaving:"NoteApp_saveStatus NoteApp_saveStatusSaving"},X=window.__desktalk_jsx_runtime,p=X.jsx,T=X.jsxs,vr=X.jsxDEV,fr=X.Fragment;function kt(t){try{const e=new Date(t),i=new Date().getTime()-e.getTime(),n=Math.floor(i/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const o=Math.floor(n/60);if(o<24)return`${o}h ago`;const s=Math.floor(o/24);return s<7?`${s}d ago`:e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}catch{return""}}function Ct({notes:t,selectedId:e,onSelect:r,onCreate:i,searchQuery:n,onSearchChange:o}){const s=H(null);return T("div",{className:v.listPanel,children:[T("div",{className:v.listHeader,children:[p("input",{ref:s,type:"text",className:v.searchInput,placeholder:"Search notes...",value:n,onChange:a=>o(a.target.value)}),p("button",{className:v.newNoteBtn,onClick:i,title:"New note",children:"+"})]}),p("div",{className:v.noteList,children:t.length===0?p("div",{className:v.emptyState,children:n?"No notes match your search":"No notes yet"}):t.map(a=>T("div",{className:a.id===e?v.noteItemActive:v.noteItem,onClick:()=>r(a.id),children:[p("div",{className:v.noteTitle,children:a.title}),p("div",{className:v.notePreview,children:a.preview}),p("div",{className:v.noteDate,children:kt(a.updatedAt)})]},a.id))})]})}var Et=`.dt-tooltip-popup {
|
|
2
2
|
position: fixed;
|
|
3
3
|
z-index: 2147483647;
|
|
4
4
|
padding: 6px 10px;
|
|
@@ -41,13 +41,13 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
41
41
|
|
|
42
42
|
/* Arrow styling - tech/minimal */
|
|
43
43
|
.dt-tooltip-popup[data-actual-placement='top'] {
|
|
44
|
-
transform:
|
|
44
|
+
transform: none;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
.dt-tooltip-popup[data-actual-placement='top']::before {
|
|
48
48
|
top: auto;
|
|
49
49
|
bottom: -4px;
|
|
50
|
-
left: 50
|
|
50
|
+
left: var(--dt-tooltip-arrow-left, 50%);
|
|
51
51
|
transform: translateX(-50%);
|
|
52
52
|
width: 0;
|
|
53
53
|
height: 0;
|
|
@@ -58,13 +58,13 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
.dt-tooltip-popup[data-actual-placement='bottom'] {
|
|
61
|
-
transform:
|
|
61
|
+
transform: none;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
.dt-tooltip-popup[data-actual-placement='bottom']::before {
|
|
65
65
|
bottom: auto;
|
|
66
66
|
top: -4px;
|
|
67
|
-
left: 50
|
|
67
|
+
left: var(--dt-tooltip-arrow-left, 50%);
|
|
68
68
|
transform: translateX(-50%);
|
|
69
69
|
width: 0;
|
|
70
70
|
height: 0;
|
|
@@ -75,12 +75,12 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
.dt-tooltip-popup[data-actual-placement='left'] {
|
|
78
|
-
transform:
|
|
78
|
+
transform: none;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
.dt-tooltip-popup[data-actual-placement='left']::before {
|
|
82
82
|
left: auto;
|
|
83
|
-
top: 50
|
|
83
|
+
top: var(--dt-tooltip-arrow-top, 50%);
|
|
84
84
|
right: -4px;
|
|
85
85
|
transform: translateY(-50%);
|
|
86
86
|
width: 0;
|
|
@@ -92,12 +92,12 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
.dt-tooltip-popup[data-actual-placement='right'] {
|
|
95
|
-
transform:
|
|
95
|
+
transform: none;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
.dt-tooltip-popup[data-actual-placement='right']::before {
|
|
99
99
|
right: auto;
|
|
100
|
-
top: 50
|
|
100
|
+
top: var(--dt-tooltip-arrow-top, 50%);
|
|
101
101
|
left: -4px;
|
|
102
102
|
transform: translateY(-50%);
|
|
103
103
|
width: 0;
|
|
@@ -107,7 +107,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
107
107
|
border-top: none;
|
|
108
108
|
border-bottom: none;
|
|
109
109
|
}
|
|
110
|
-
`,At="dt-tooltip-popup",L=8,at=!1;function St(){if(at)return;let t=document.createElement("style");t.setAttribute("data-dt-tooltip",""),t.textContent=Et,document.head.appendChild(t),at=!0}var zt=class extends HTMLElement{_popup=null;_showTimeout=null;_tooltipId="";_visible=!1;static get observedAttributes(){return["content","placement","delay","disabled"]}get content(){return this.getAttribute("content")??""}set content(t){this.setAttribute("content",t)}get placement(){let t=this.getAttribute("placement");return t==="bottom"||t==="left"||t==="right"?t:"top"}set placement(t){this.setAttribute("placement",t)}get delay(){let t=Number(this.getAttribute("delay"));return Number.isFinite(t)&&t>0?t:0}set delay(t){this.setAttribute("delay",String(t))}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}constructor(){super();let t=this.attachShadow({mode:"open"});t.innerHTML="<slot></slot>",this._tooltipId=`dt-tip-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){St(),this.addEventListener("mouseenter",this._onEnter),this.addEventListener("mouseleave",this._onLeave),this.addEventListener("focusin",this._onEnter),this.addEventListener("focusout",this._onLeave)}disconnectedCallback(){this.removeEventListener("mouseenter",this._onEnter),this.removeEventListener("mouseleave",this._onLeave),this.removeEventListener("focusin",this._onEnter),this.removeEventListener("focusout",this._onLeave),this._hide()}attributeChangedCallback(t,e,r){t==="disabled"&&this.disabled&&this._hide(),t==="content"&&this._popup&&(this._popup.textContent=this.content)}_onEnter=()=>{if(this.disabled||!this.content)return;this._showTimeout!==null&&clearTimeout(this._showTimeout);let t=()=>{this._createPopup(),this._position(),this._visible=!0};this.delay>0?this._showTimeout=setTimeout(t,this.delay):t()};_onLeave=()=>{this._hide()};_createPopup(){if(this._popup)return;let t=document.createElement("div");t.className=At,t.id=this._tooltipId,t.setAttribute("role","tooltip"),t.textContent=this.content,document.body.appendChild(t),this._popup=t;let e=this._getTrigger();e&&e.setAttribute("aria-describedby",this._tooltipId)}_hide(){if(this._showTimeout!==null&&(clearTimeout(this._showTimeout),this._showTimeout=null),this._popup){let t=this._getTrigger();t&&t.removeAttribute("aria-describedby"),this._popup.remove(),this._popup=null,this._visible=!1}}_getTrigger(){let t=this.shadowRoot?.querySelector("slot")?.assignedElements();return t&&t.length>0?t[0]:null}_position(){let t=this._popup;if(!t)return;let e=this.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight,s=this.placement;s==="top"&&e.top-r.height-L<0?s="bottom":s==="bottom"&&e.bottom+r.height+L>n?s="top":s==="left"&&e.left-r.width-L<0?s="right":s==="right"&&e.right+r.width+L>i&&(s="left"),t.setAttribute("data-actual-placement",s);let
|
|
110
|
+
`,At="dt-tooltip-popup",L=8,at=!1;function St(){if(at)return;let t=document.createElement("style");t.setAttribute("data-dt-tooltip",""),t.textContent=Et,document.head.appendChild(t),at=!0}var zt=class extends HTMLElement{_popup=null;_showTimeout=null;_tooltipId="";_visible=!1;static get observedAttributes(){return["content","placement","align","delay","disabled"]}get content(){return this.getAttribute("content")??""}set content(t){this.setAttribute("content",t)}get placement(){let t=this.getAttribute("placement");return t==="bottom"||t==="left"||t==="right"?t:"top"}set placement(t){this.setAttribute("placement",t)}get align(){let t=this.getAttribute("align");return t==="left"||t==="right"?t:"center"}set align(t){this.setAttribute("align",t)}get delay(){let t=Number(this.getAttribute("delay"));return Number.isFinite(t)&&t>0?t:0}set delay(t){this.setAttribute("delay",String(t))}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}constructor(){super();let t=this.attachShadow({mode:"open"});t.innerHTML="<slot></slot>",this._tooltipId=`dt-tip-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){St(),this.addEventListener("mouseenter",this._onEnter),this.addEventListener("mouseleave",this._onLeave),this.addEventListener("focusin",this._onEnter),this.addEventListener("focusout",this._onLeave)}disconnectedCallback(){this.removeEventListener("mouseenter",this._onEnter),this.removeEventListener("mouseleave",this._onLeave),this.removeEventListener("focusin",this._onEnter),this.removeEventListener("focusout",this._onLeave),this._hide()}attributeChangedCallback(t,e,r){t==="disabled"&&this.disabled&&this._hide(),t==="content"&&this._popup&&(this._popup.textContent=this.content)}_onEnter=()=>{if(this.disabled||!this.content)return;this._showTimeout!==null&&clearTimeout(this._showTimeout);let t=()=>{this._createPopup(),this._position(),this._visible=!0};this.delay>0?this._showTimeout=setTimeout(t,this.delay):t()};_onLeave=()=>{this._hide()};_createPopup(){if(this._popup)return;let t=document.createElement("div");t.className=At,t.id=this._tooltipId,t.setAttribute("role","tooltip"),t.textContent=this.content,document.body.appendChild(t),this._popup=t;let e=this._getTrigger();e&&e.setAttribute("aria-describedby",this._tooltipId)}_hide(){if(this._showTimeout!==null&&(clearTimeout(this._showTimeout),this._showTimeout=null),this._popup){let t=this._getTrigger();t&&t.removeAttribute("aria-describedby"),this._popup.remove(),this._popup=null,this._visible=!1}}_getTrigger(){let t=this.shadowRoot?.querySelector("slot")?.assignedElements();return t&&t.length>0?t[0]:null}_position(){let t=this._popup;if(!t)return;let e=this.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth,n=window.innerHeight,o=8,s=this.placement;s==="top"&&e.top-r.height-L<0?s="bottom":s==="bottom"&&e.bottom+r.height+L>n?s="top":s==="left"&&e.left-r.width-L<0?s="right":s==="right"&&e.right+r.width+L>i&&(s="left"),t.setAttribute("data-actual-placement",s);let a,d,l=e.left+e.width/2,u=e.top+e.height/2;switch(s){case"top":l=this.align==="left"?e.left:this.align==="right"?e.right:e.left+e.width/2,d=this.align==="left"?e.left:this.align==="right"?e.right-r.width:e.left+e.width/2-r.width/2,a=e.top-r.height-L;break;case"bottom":l=this.align==="left"?e.left:this.align==="right"?e.right:e.left+e.width/2,d=this.align==="left"?e.left:this.align==="right"?e.right-r.width:e.left+e.width/2-r.width/2,a=e.bottom+L;break;case"left":d=e.left-r.width-L,a=e.top+e.height/2-r.height/2,u=e.top+e.height/2;break;case"right":d=e.right+L,a=e.top+e.height/2-r.height/2,u=e.top+e.height/2;break}s==="top"||s==="bottom"?(d=Math.max(o,Math.min(d,i-r.width-o)),t.style.setProperty("--dt-tooltip-arrow-left",`${Math.max(8,Math.min(l-d,r.width-8))}px`),t.style.removeProperty("--dt-tooltip-arrow-top")):(a=Math.max(o,Math.min(a,n-r.height-o)),t.style.setProperty("--dt-tooltip-arrow-top",`${Math.max(8,Math.min(u-a,r.height-8))}px`),t.style.removeProperty("--dt-tooltip-arrow-left")),t.style.left=`${d}px`,t.style.top=`${a}px`}},Mt=`:host {
|
|
111
111
|
display: block;
|
|
112
112
|
margin-bottom: 12px;
|
|
113
113
|
}
|
|
@@ -356,7 +356,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
356
356
|
.dt-select-trigger[aria-expanded='true'] .dt-select-chevron {
|
|
357
357
|
transform: rotate(180deg);
|
|
358
358
|
}
|
|
359
|
-
`,It="dt-select-trigger",dt="dt-select-label",Rt="dt-select-chevron",Ft="dt-select-menu",$t="dt-select-option",Pt="dt-select-option--active",lt=!1;function Dt(){if(lt)return;let t=document.createElement("style");t.setAttribute("data-dt-select",""),t.textContent=Lt,document.head.appendChild(t),lt=!0}var Vt=class extends HTMLElement{_menu=null;_trigger=null;_options=[];_open=!1;_menuId="";static get observedAttributes(){return["value","placeholder","disabled","align"]}get value(){return this.getAttribute("value")??""}set value(t){this.setAttribute("value",t)}get placeholder(){return this.getAttribute("placeholder")??"Select\u2026"}set placeholder(t){this.setAttribute("placeholder",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get align(){return this.getAttribute("align")==="right"?"right":"left"}set align(t){this.setAttribute("align",t)}get options(){return this._options}set options(t){this._options=t,this._updateLabel(),this._open&&this._renderMenuItems()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ht,t.appendChild(e);let r=document.createElement("button");r.type="button",r.className=It,r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false");let i=document.createElement("span");i.className=dt,r.appendChild(i);let n=document.createElement("span");n.className=Rt,n.setAttribute("aria-hidden","true"),n.textContent="\u25BE",r.appendChild(n),t.appendChild(r),this._trigger=r,this._menuId=`dt-sel-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){Dt(),this._trigger.addEventListener("click",this._onTriggerClick),this._updateLabel()}disconnectedCallback(){this._trigger.removeEventListener("click",this._onTriggerClick),this._close()}attributeChangedCallback(t){t==="value"&&(this._updateLabel(),this._open&&this._renderMenuItems()),t==="placeholder"&&!this.value&&this._updateLabel(),t==="disabled"&&this.disabled&&this._close()}_updateLabel(){let t=this._trigger.querySelector(`.${dt}`),e=this._options.find(r=>r.value===this.value);t.textContent=e?.label??this.placeholder}_onTriggerClick=()=>{this.disabled||(this._open?this._close():this._openMenu())};_openMenu(){if(this._open)return;let t=document.createElement("div");t.className=Ft,t.id=this._menuId,t.setAttribute("role","listbox"),document.body.appendChild(t),this._menu=t,this._renderMenuItems(),this._position(),requestAnimationFrame(()=>{t.setAttribute("data-open","")}),this._open=!0,this._trigger.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>{document.addEventListener("mousedown",this._onOutsideClick),document.addEventListener("keydown",this._onKeyDown)})}_close(){if(this._open){if(document.removeEventListener("mousedown",this._onOutsideClick),document.removeEventListener("keydown",this._onKeyDown),this._menu){this._menu.removeAttribute("data-open");let t=this._menu;setTimeout(()=>t.remove(),140),this._menu=null}this._open=!1,this._trigger.setAttribute("aria-expanded","false")}}_onOutsideClick=t=>{let e=t.target;this._menu?.contains(e)||this.contains(e)||this._close()};_onKeyDown=t=>{t.key==="Escape"&&(this._close(),this._trigger.focus())};_renderMenuItems(){let t=this._menu;if(t){t.innerHTML="";for(let e of this._options){let r=document.createElement("button");r.type="button",r.className=$t,r.setAttribute("role","option"),r.setAttribute("aria-selected",String(e.value===this.value)),e.value===this.value&&r.classList.add(Pt);let i=document.createElement("span");i.textContent=e.label,r.appendChild(i),r.addEventListener("click",()=>{this._selectValue(e.value)}),t.appendChild(r)}}}_selectValue(t){let e=this.value;this.value=t,this._updateLabel(),this._close(),t!==e&&this.dispatchEvent(new CustomEvent("dt-change",{detail:{value:t},bubbles:!0,composed:!0}))}_position(){let t=this._menu;if(!t)return;let e=this.getBoundingClientRect(),r=10,i=Math.max(e.width,240),n=e.bottom+r,
|
|
359
|
+
`,It="dt-select-trigger",dt="dt-select-label",Rt="dt-select-chevron",Ft="dt-select-menu",$t="dt-select-option",Pt="dt-select-option--active",lt=!1;function Dt(){if(lt)return;let t=document.createElement("style");t.setAttribute("data-dt-select",""),t.textContent=Lt,document.head.appendChild(t),lt=!0}var Vt=class extends HTMLElement{_menu=null;_trigger=null;_options=[];_open=!1;_menuId="";static get observedAttributes(){return["value","placeholder","disabled","align"]}get value(){return this.getAttribute("value")??""}set value(t){this.setAttribute("value",t)}get placeholder(){return this.getAttribute("placeholder")??"Select\u2026"}set placeholder(t){this.setAttribute("placeholder",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){t?this.setAttribute("disabled",""):this.removeAttribute("disabled")}get align(){return this.getAttribute("align")==="right"?"right":"left"}set align(t){this.setAttribute("align",t)}get options(){return this._options}set options(t){this._options=t,this._updateLabel(),this._open&&this._renderMenuItems()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ht,t.appendChild(e);let r=document.createElement("button");r.type="button",r.className=It,r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false");let i=document.createElement("span");i.className=dt,r.appendChild(i);let n=document.createElement("span");n.className=Rt,n.setAttribute("aria-hidden","true"),n.textContent="\u25BE",r.appendChild(n),t.appendChild(r),this._trigger=r,this._menuId=`dt-sel-${Math.random().toString(36).slice(2,9)}`}connectedCallback(){Dt(),this._trigger.addEventListener("click",this._onTriggerClick),this._updateLabel()}disconnectedCallback(){this._trigger.removeEventListener("click",this._onTriggerClick),this._close()}attributeChangedCallback(t){t==="value"&&(this._updateLabel(),this._open&&this._renderMenuItems()),t==="placeholder"&&!this.value&&this._updateLabel(),t==="disabled"&&this.disabled&&this._close()}_updateLabel(){let t=this._trigger.querySelector(`.${dt}`),e=this._options.find(r=>r.value===this.value);t.textContent=e?.label??this.placeholder}_onTriggerClick=()=>{this.disabled||(this._open?this._close():this._openMenu())};_openMenu(){if(this._open)return;let t=document.createElement("div");t.className=Ft,t.id=this._menuId,t.setAttribute("role","listbox"),document.body.appendChild(t),this._menu=t,this._renderMenuItems(),this._position(),requestAnimationFrame(()=>{t.setAttribute("data-open","")}),this._open=!0,this._trigger.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>{document.addEventListener("mousedown",this._onOutsideClick),document.addEventListener("keydown",this._onKeyDown),window.addEventListener("blur",this._onWindowBlur)})}_close(){if(this._open){if(document.removeEventListener("mousedown",this._onOutsideClick),document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("blur",this._onWindowBlur),this._menu){this._menu.removeAttribute("data-open");let t=this._menu;setTimeout(()=>t.remove(),140),this._menu=null}this._open=!1,this._trigger.setAttribute("aria-expanded","false")}}_onOutsideClick=t=>{let e=t.target;this._menu?.contains(e)||this.contains(e)||this._close()};_onWindowBlur=()=>{requestAnimationFrame(()=>{document.activeElement?.tagName==="IFRAME"&&this._close()})};_onKeyDown=t=>{t.key==="Escape"&&(this._close(),this._trigger.focus())};_renderMenuItems(){let t=this._menu;if(t){t.innerHTML="";for(let e of this._options){let r=document.createElement("button");r.type="button",r.className=$t,r.setAttribute("role","option"),r.setAttribute("aria-selected",String(e.value===this.value)),e.value===this.value&&r.classList.add(Pt);let i=document.createElement("span");i.textContent=e.label,r.appendChild(i),r.addEventListener("click",()=>{this._selectValue(e.value)}),t.appendChild(r)}}}_selectValue(t){let e=this.value;this.value=t,this._updateLabel(),this._close(),t!==e&&this.dispatchEvent(new CustomEvent("dt-change",{detail:{value:t},bubbles:!0,composed:!0}))}_position(){let t=this._menu;if(!t)return;let e=this.getBoundingClientRect(),r=10,i=Math.max(e.width,240),n=e.bottom+r,o=t.scrollHeight||260,s=window.innerHeight;if(n+o>s&&e.top-o-r>0&&(n=e.top-o-r),t.style.minWidth=`${i}px`,this.align==="right"){let a=window.innerWidth;t.style.right=`${a-e.right}px`,t.style.left="auto"}else t.style.left=`${e.left}px`,t.style.right="auto";t.style.top=`${n}px`}},Ot=`:host {
|
|
360
360
|
display: block;
|
|
361
361
|
margin-bottom: 12px;
|
|
362
362
|
}
|
|
@@ -448,7 +448,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
448
448
|
::slotted(*) {
|
|
449
449
|
min-width: 0;
|
|
450
450
|
}
|
|
451
|
-
`,
|
|
451
|
+
`,Wt="dt-grid-inner",Bt=class extends HTMLElement{static get observedAttributes(){return["cols","gap","min-width"]}get cols(){let t=this.getAttribute("cols");return t==="1"||t==="2"||t==="3"||t==="4"||t==="5"||t==="6"?t:null}set cols(t){t===null?this.removeAttribute("cols"):this.setAttribute("cols",t)}get gap(){let t=this.getAttribute("gap");return t==="0"||t==="4"||t==="8"||t==="12"||t==="20"||t==="24"||t==="32"?t:"16"}set gap(t){this.setAttribute("gap",t)}get minWidth(){let t=this.getAttribute("min-width");return t==="150"||t==="180"||t==="200"||t==="260"||t==="300"?t:"220"}set minWidth(t){this.setAttribute("min-width",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Ot,t.appendChild(e);let r=document.createElement("div");r.className=Wt,r.innerHTML="<slot></slot>",t.appendChild(r)}},qt=`:host {
|
|
452
452
|
display: block;
|
|
453
453
|
margin-bottom: 12px;
|
|
454
454
|
}
|
|
@@ -514,7 +514,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
514
514
|
::slotted(*) {
|
|
515
515
|
min-width: 0;
|
|
516
516
|
}
|
|
517
|
-
`,jt="dt-stack-inner";function Q(t){return t==="row"||t==="horizontal"?"row":"column"}var Ut=class extends HTMLElement{static get observedAttributes(){return["direction","gap","align"]}get direction(){return Q(this.getAttribute("direction"))}set direction(t){this.setAttribute("direction",Q(t))}get gap(){let t=this.getAttribute("gap");return t==="0"||t==="4"||t==="8"||t==="12"||t==="20"||t==="24"||t==="32"?t:"16"}set gap(t){this.setAttribute("gap",t)}get align(){let t=this.getAttribute("align");return t==="start"||t==="center"||t==="end"?t:"stretch"}set align(t){this.setAttribute("align",t)}connectedCallback(){this.#t()}attributeChangedCallback(t){t==="direction"&&this.#t()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=
|
|
517
|
+
`,jt="dt-stack-inner";function Q(t){return t==="row"||t==="horizontal"?"row":"column"}var Ut=class extends HTMLElement{static get observedAttributes(){return["direction","gap","align"]}get direction(){return Q(this.getAttribute("direction"))}set direction(t){this.setAttribute("direction",Q(t))}get gap(){let t=this.getAttribute("gap");return t==="0"||t==="4"||t==="8"||t==="12"||t==="20"||t==="24"||t==="32"?t:"16"}set gap(t){this.setAttribute("gap",t)}get align(){let t=this.getAttribute("align");return t==="start"||t==="center"||t==="end"?t:"stretch"}set align(t){this.setAttribute("align",t)}connectedCallback(){this.#t()}attributeChangedCallback(t){t==="direction"&&this.#t()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=qt,t.appendChild(e);let r=document.createElement("div");r.className=jt,r.innerHTML="<slot></slot>",t.appendChild(r)}#t(){let t=this.getAttribute("direction"),e=Q(t);t!==null&&t!==e&&this.setAttribute("direction",e)}},Gt=`:host {
|
|
518
518
|
display: block;
|
|
519
519
|
}
|
|
520
520
|
|
|
@@ -619,7 +619,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
619
619
|
.dt-stat-inner .trend.neutral {
|
|
620
620
|
color: var(--dt-text-muted);
|
|
621
621
|
}
|
|
622
|
-
`,
|
|
622
|
+
`,Yt="dt-stat-inner",Xt=class extends HTMLElement{static get observedAttributes(){return["label","value","description","size","variant","trend","trend-value"]}_container;_labelEl;_valueEl;_descEl;_trendEl;get label(){return this.getAttribute("label")}set label(t){t===null?this.removeAttribute("label"):this.setAttribute("label",t)}get value(){return this.getAttribute("value")}set value(t){t===null?this.removeAttribute("value"):this.setAttribute("value",t)}get description(){return this.getAttribute("description")}set description(t){t===null?this.removeAttribute("description"):this.setAttribute("description",t)}get size(){let t=this.getAttribute("size");return t==="sm"||t==="lg"?t:"md"}set size(t){this.setAttribute("size",t)}get variant(){let t=this.getAttribute("variant");return t==="outlined"||t==="filled"?t:"default"}set variant(t){this.setAttribute("variant",t)}get trend(){let t=this.getAttribute("trend");return t==="up"||t==="down"||t==="neutral"?t:null}set trend(t){t===null?this.removeAttribute("trend"):this.setAttribute("trend",t)}get trendValue(){return this.getAttribute("trend-value")}set trendValue(t){t===null?this.removeAttribute("trend-value"):this.setAttribute("trend-value",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=Gt,t.appendChild(e),this._container=document.createElement("div"),this._container.className=Yt,this._labelEl=document.createElement("div"),this._labelEl.className="label",this._container.appendChild(this._labelEl),this._valueEl=document.createElement("div"),this._valueEl.className="value",this._container.appendChild(this._valueEl),this._descEl=document.createElement("div"),this._descEl.className="description",this._container.appendChild(this._descEl),this._trendEl=document.createElement("div"),this._trendEl.className="trend",this._container.appendChild(this._trendEl),t.appendChild(this._container),this._render()}attributeChangedCallback(t,e,r){(t==="label"||t==="value"||t==="description"||t==="size"||t==="variant"||t==="trend"||t==="trend-value")&&this._render()}_render(){this._labelEl.textContent=this.label??"",this._labelEl.style.display=this.label?"block":"none",this._valueEl.textContent=this.value??"",this._valueEl.style.display=this.value?"block":"none",this._descEl.textContent=this.description??"",this._descEl.style.display=this.description?"block":"none";let t=this.trend,e=this.trendValue;if(t&&e){this._trendEl.style.display="inline-flex",this._trendEl.className=`trend ${t==="up"?"positive":t==="down"?"negative":"neutral"}`;let r="";t==="up"?r="\u2191":t==="down"?r="\u2193":r="\u2192",this._trendEl.textContent=`${r} ${e}`}else this._trendEl.style.display="none"}},Kt=`:host {
|
|
623
623
|
display: inline-flex;
|
|
624
624
|
vertical-align: middle;
|
|
625
625
|
}
|
|
@@ -718,6 +718,9 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
718
718
|
font-weight: 600;
|
|
719
719
|
font-family: var(--font-ui, 'Work Sans', system-ui, sans-serif);
|
|
720
720
|
line-height: 1.2;
|
|
721
|
+
white-space: nowrap;
|
|
722
|
+
overflow: hidden;
|
|
723
|
+
text-overflow: ellipsis;
|
|
721
724
|
cursor: pointer;
|
|
722
725
|
transition: all 0.1s ease;
|
|
723
726
|
background: var(--dt-surface);
|
|
@@ -925,7 +928,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
925
928
|
:host([direction='vertical'][spacing='lg']) .dt-divider-inner {
|
|
926
929
|
margin: 0 18px;
|
|
927
930
|
}
|
|
928
|
-
`,ie="dt-divider-inner",ne=class extends HTMLElement{static get observedAttributes(){return["direction","style-variant","spacing"]}get direction(){return this.getAttribute("direction")==="vertical"?"vertical":"horizontal"}set direction(t){this.setAttribute("direction",t)}get styleVariant(){let t=this.getAttribute("style-variant");return t==="subtle"||t==="strong"?t:"default"}set styleVariant(t){this.setAttribute("style-variant",t)}get spacing(){let t=this.getAttribute("spacing");return t==="sm"||t==="md"||t==="lg"?t:null}set spacing(t){t===null?this.removeAttribute("spacing"):this.setAttribute("spacing",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=re,t.appendChild(e);let r=document.createElement("hr");r.className=ie,t.appendChild(r)}},
|
|
931
|
+
`,ie="dt-divider-inner",ne=class extends HTMLElement{static get observedAttributes(){return["direction","style-variant","spacing"]}get direction(){return this.getAttribute("direction")==="vertical"?"vertical":"horizontal"}set direction(t){this.setAttribute("direction",t)}get styleVariant(){let t=this.getAttribute("style-variant");return t==="subtle"||t==="strong"?t:"default"}set styleVariant(t){this.setAttribute("style-variant",t)}get spacing(){let t=this.getAttribute("spacing");return t==="sm"||t==="md"||t==="lg"?t:null}set spacing(t){t===null?this.removeAttribute("spacing"):this.setAttribute("spacing",t)}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=re,t.appendChild(e);let r=document.createElement("hr");r.className=ie,t.appendChild(r)}},oe=`:host {
|
|
929
932
|
display: block;
|
|
930
933
|
min-height: 180px;
|
|
931
934
|
color: var(--dt-text);
|
|
@@ -1093,7 +1096,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
1093
1096
|
letter-spacing: 0.08em;
|
|
1094
1097
|
font-size: 0.75rem;
|
|
1095
1098
|
}
|
|
1096
|
-
`;function
|
|
1099
|
+
`;function se(t){return t==null||t===!1?null:t===!0?"":String(t)}function ae(t,e){let r=t.querySelectorAll("*");for(let i of r){let n=i.getAttribute("data-field");if(n){let o=e[n];i.textContent=o==null?"":String(o)}for(let o of i.getAttributeNames()){if(o==="data-field"||!o.startsWith("data-field-"))continue;let s=o.slice(11);if(!s)continue;let a=i.getAttribute(o);if(!a)continue;let d=se(e[a]);d===null?i.removeAttribute(s):i.setAttribute(s,d)}}}function ct(t,e){let r=t.content.cloneNode(!0);return ae(r,e),r}var ht=class{_count=0;_estimateSize=56;_overscan=5;_fixedSize=null;_viewportHeight=0;_scrollTop=0;_sizes=new Map;constructor(t={}){this._count=t.count??0,this._estimateSize=t.estimateSize??56,this._overscan=t.overscan??5,this._fixedSize=t.fixedSize??null}setCount(t){this._count=Math.max(0,t);for(let e of this._sizes.keys())e>=this._count&&this._sizes.delete(e)}setViewportHeight(t){this._viewportHeight=Math.max(0,t)}setScrollTop(t){this._scrollTop=Math.max(0,t)}setEstimateSize(t){this._estimateSize=Math.max(1,t)}setFixedSize(t){this._fixedSize=t&&t>0?t:null}resetMeasurements(){this._sizes.clear()}measure(t,e){if(this._fixedSize!==null||t<0||t>=this._count)return 0;let r=Math.max(1,Math.round(e)),i=this._sizes.get(t);return i===r?0:(this._sizes.set(t,r),this.getOffset(t+1)<=this._scrollTop?r-(i??this._estimateSize):0)}getOffset(t){if(t<=0)return 0;let e=Math.min(t,this._count);if(this._fixedSize!==null)return e*this._fixedSize;let r=0;for(let i=0;i<e;i+=1)r+=this._sizes.get(i)??this._estimateSize;return r}getTotalHeight(){return this.getOffset(this._count)}getRange(){if(this._count===0)return{start:0,end:0,paddingTop:0,paddingBottom:0,totalHeight:0};if(this._fixedSize!==null){let a=Math.max(1,Math.ceil(this._viewportHeight/this._fixedSize)),d=Math.max(0,Math.floor(this._scrollTop/this._fixedSize)-this._overscan),l=Math.min(this._count,d+a+this._overscan*2),u=d*this._fixedSize,_=this._count*this._fixedSize,b=Math.max(0,_-u-(l-d)*this._fixedSize);return{start:d,end:l,paddingTop:u,paddingBottom:b,totalHeight:_}}let t=0,e=0;for(;t<this._count;){let a=this._sizes.get(t)??this._estimateSize;if(e+a>this._scrollTop)break;e+=a,t+=1}t=Math.max(0,t-this._overscan);let r=this.getOffset(t),i=t,n=0;for(;i<this._count&&n<this._viewportHeight;)n+=this._sizes.get(i)??this._estimateSize,i+=1;i=Math.min(this._count,i+this._overscan);let o=this.getTotalHeight(),s=Math.max(0,o-this.getOffset(i));return{start:t,end:i,paddingTop:r,paddingBottom:s,totalHeight:o}}};function de(t){return t&&typeof t=="object"?t:{value:t}}function le(t){return t==="center"||t==="right"?t:"left"}var ut=class extends HTMLElement{static get observedAttributes(){return["field","header","width","min-width","align"]}get field(){return this.getAttribute("field")??""}get header(){return this.getAttribute("header")??this.field}get width(){return this.getAttribute("width")??"auto"}get minWidth(){return this.getAttribute("min-width")??"0"}get align(){return le(this.getAttribute("align"))}connectedCallback(){this.hidden=!0}attributeChangedCallback(){this.dispatchEvent(new CustomEvent("dt-column-change",{bubbles:!0,composed:!0}))}},ce=class extends HTMLElement{_rows=[];_columns=[];_virtualizer=new ht({estimateSize:40,overscan:5,fixedSize:40});_root;_scroll;_header;_body;_canvas;_emptyState;_resizeObserver=null;_mutationObserver=null;_sortField=null;_sortDirection="asc";static get observedAttributes(){return["row-height","sortable","striped","bordered","empty-text"]}get rows(){return this._rows}set rows(t){this._rows=Array.isArray(t)?t:[],this._virtualizer.setCount(this._rows.length),this._render()}get rowHeight(){let t=Number(this.getAttribute("row-height")??"40");return Number.isFinite(t)&&t>0?t:40}set rowHeight(t){this.setAttribute("row-height",String(t))}get sortable(){return this.hasAttribute("sortable")}get emptyText(){return this.getAttribute("empty-text")??"No data"}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=oe,t.appendChild(e),this._root=document.createElement("div"),this._root.className="dt-table-view",this._scroll=document.createElement("div"),this._scroll.className="dt-table-scroll",this._scroll.addEventListener("scroll",this._onScroll,{passive:!0}),this._header=document.createElement("div"),this._header.className="dt-table-header",this._body=document.createElement("div"),this._body.className="dt-table-body",this._canvas=document.createElement("div"),this._canvas.className="dt-table-canvas",this._emptyState=document.createElement("div"),this._emptyState.className="dt-table-empty",this._body.append(this._canvas,this._emptyState),this._scroll.append(this._header,this._body),this._root.appendChild(this._scroll),t.appendChild(this._root)}connectedCallback(){this._virtualizer.setFixedSize(this.rowHeight),this._virtualizer.setEstimateSize(this.rowHeight),this._syncColumns(),this._resizeObserver=new ResizeObserver(t=>{for(let e of t)if(e.target===this._scroll){let r=this._header.offsetHeight;this._virtualizer.setViewportHeight(Math.max(0,e.contentRect.height-r)),this._render()}}),this._resizeObserver.observe(this._scroll),this._mutationObserver=new MutationObserver(()=>{this._syncColumns(),this._render()}),this._mutationObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["field","header","width","min-width","align"]}),this._virtualizer.setCount(this._rows.length),this._virtualizer.setViewportHeight(Math.max(0,this._scroll.clientHeight-this._header.offsetHeight)),this._render()}disconnectedCallback(){this._scroll.removeEventListener("scroll",this._onScroll),this._resizeObserver?.disconnect(),this._mutationObserver?.disconnect(),this._resizeObserver=null,this._mutationObserver=null}attributeChangedCallback(t){t==="row-height"&&(this._virtualizer.setFixedSize(this.rowHeight),this._virtualizer.setEstimateSize(this.rowHeight)),this._render()}_onScroll=()=>{this._virtualizer.setScrollTop(Math.max(0,this._scroll.scrollTop-this._header.offsetHeight)),this._renderBody()};_syncColumns(){this._columns=Array.from(this.children).filter(t=>t instanceof ut).map(t=>({field:t.field,header:t.header,width:t.width,minWidth:t.minWidth,align:t.align,template:Array.from(t.children).find(e=>e instanceof HTMLTemplateElement)??null})).filter(t=>t.field)}_render(){if(!this.isConnected)return;this._emptyState.textContent=this.emptyText;let t=this._columns.length>0?this._columns.map(e=>this._toGridColumn(e)).join(" "):"minmax(0, 1fr)";this._header.style.setProperty("--dt-table-columns",t),this._canvas.style.setProperty("--dt-table-columns",t),this._renderHeader(),this._renderBody()}_renderHeader(){let t=document.createDocumentFragment();for(let e of this._columns){let r=document.createElement("div");r.className="dt-table-header-cell",r.dataset.align=e.align,this.sortable&&(r.classList.add("dt-table-header-cell--sortable"),r.tabIndex=0,r.setAttribute("role","button"),r.setAttribute("aria-label",`Sort by ${e.header}`),r.addEventListener("click",()=>this._requestSort(e.field)),r.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),this._requestSort(e.field))}));let i=document.createElement("span");if(i.className="dt-table-header-label",i.textContent=e.header,this.sortable){let n=document.createElement("span");n.className="dt-table-sort-indicator",this._sortField===e.field?n.textContent=this._sortDirection==="asc"?"\u25B2":"\u25BC":n.textContent="\u2195",i.appendChild(n)}r.appendChild(i),t.appendChild(r)}this._header.replaceChildren(t)}_renderBody(){if(this._rows.length===0||this._columns.length===0){this._emptyState.hidden=!1,this._canvas.replaceChildren(),this._body.style.height="140px",this._canvas.style.height="0px";return}this._emptyState.hidden=!0,this._virtualizer.setCount(this._rows.length),this._virtualizer.setScrollTop(Math.max(0,this._scroll.scrollTop-this._header.offsetHeight)),this._virtualizer.setViewportHeight(Math.max(0,this._scroll.clientHeight-this._header.offsetHeight));let t=this._virtualizer.getRange();this._body.style.height=`${Math.max(t.totalHeight,this._scroll.clientHeight-this._header.offsetHeight)}px`,this._canvas.style.height=`${t.totalHeight}px`;let e=document.createDocumentFragment();for(let r=t.start;r<t.end;r+=1)e.appendChild(this._renderRow(r));this._canvas.replaceChildren(e)}_renderRow(t){let e=this._rows[t],r=document.createElement("div");r.className="dt-table-row dt-table-row--clickable",r.style.top=`${this._virtualizer.getOffset(t)}px`,r.style.height=`${this.rowHeight}px`,r.style.setProperty("--dt-table-columns",this._header.style.getPropertyValue("--dt-table-columns")),r.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("dt-row-click",{detail:{row:e,index:t},bubbles:!0,composed:!0}))});let i=de(e);for(let n of this._columns){let o=document.createElement("div");if(o.className="dt-table-cell",o.dataset.align=n.align,n.template)o.appendChild(ct(n.template,i));else{let s=i[n.field];o.textContent=s==null?"":String(s)}r.appendChild(o)}return r}_requestSort(t){this._sortField===t?this._sortDirection=this._sortDirection==="asc"?"desc":"asc":(this._sortField=t,this._sortDirection="asc"),this._renderHeader(),this.dispatchEvent(new CustomEvent("dt-sort",{detail:{field:t,direction:this._sortDirection},bubbles:!0,composed:!0}))}_toGridColumn(t){let e=/^\d+$/.test(t.minWidth)?`${t.minWidth}px`:t.minWidth;if(t.width==="auto")return`minmax(${e}, 1fr)`;let r=/^\d+$/.test(t.width)?`${t.width}px`:t.width;return`minmax(${e}, ${r})`}},he=`:host {
|
|
1097
1100
|
display: block;
|
|
1098
1101
|
min-height: 120px;
|
|
1099
1102
|
color: var(--dt-text);
|
|
@@ -1279,7 +1282,7 @@ var h=window.React,We=h.Children,Be=h.Component,je=h.Fragment,Ue=h.Profiler,Ye=h
|
|
|
1279
1282
|
.dt-chart__status[hidden] {
|
|
1280
1283
|
display: none;
|
|
1281
1284
|
}
|
|
1282
|
-
`,Z=null;function ge(){return window.__DtChart?Promise.resolve(window.__DtChart):Z||(Z=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/chart.umd.js",r.async=!0,r.dataset.dtChart="true",r.onload=()=>{if(window.__DtChart){t(window.__DtChart);return}e(new Error("Chart runtime loaded without a __DtChart export."))},r.onerror=()=>e(new Error("Failed to load the Chart.js runtime bundle.")),document.head.appendChild(r)}),Z)}function j(t,e,r){return Math.min(r,Math.max(e,t))}function be(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function tt(t){let e=t.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(e){let n=e[1],
|
|
1285
|
+
`,Z=null;function ge(){return window.__DtChart?Promise.resolve(window.__DtChart):Z||(Z=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/chart.umd.js",r.async=!0,r.dataset.dtChart="true",r.onload=()=>{if(window.__DtChart){t(window.__DtChart);return}e(new Error("Chart runtime loaded without a __DtChart export."))},r.onerror=()=>e(new Error("Failed to load the Chart.js runtime bundle.")),document.head.appendChild(r)}),Z)}function j(t,e,r){return Math.min(r,Math.max(e,t))}function be(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function tt(t){let e=t.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(e){let n=e[1],o=n.length===3?n.split("").map(l=>`${l}${l}`).join(""):n,s=parseInt(o.slice(0,2),16)/255,a=parseInt(o.slice(2,4),16)/255,d=parseInt(o.slice(4,6),16)/255;return mt(s,a,d)}let r=t.trim().match(/^rgba?\((\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)(?:[,/\s]+[\d.]+)?\)$/i);if(r)return mt(Number(r[1])/255,Number(r[2])/255,Number(r[3])/255);let i=t.trim().match(/^hsla?\(([-\d.]+)(?:deg)?[,\s]+([\d.]+)%[,\s]+([\d.]+)%(?:[,/\s]+[\d.]+)?\)$/i);return i?{h:(Number(i[1])%360+360)%360,s:j(Number(i[2]),0,100),l:j(Number(i[3]),0,100)}:null}function mt(t,e,r){let i=Math.max(t,e,r),n=Math.min(t,e,r),o=i-n,s=0,a=(i+n)/2,d=o===0?0:o/(1-Math.abs(2*a-1));if(o!==0)switch(i){case t:s=60*((e-r)/o%6);break;case e:s=60*((r-t)/o+2);break;default:s=60*((t-e)/o+4);break}return{h:(s+360)%360,s:Math.round(d*100),l:Math.round(a*100)}}function D(t,e=1){return`hsla(${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}% / ${e})`}function ve(t){let e=tt(t)??{h:185,s:88,l:56};return[0,32,68,118,164,212,258,304].map((r,i)=>({h:(e.h+r)%360,s:j(e.s-i*2,55,90),l:j(e.l+(i%2===0?0:6)-i,38,66)}))}function K(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function gt(t,e){if(!K(t)||!K(e))return e??t;let r={...t};for(let[i,n]of Object.entries(e)){let o=r[i];r[i]=K(o)&&K(n)?gt(o,n):n}return r}function fe(t){return t==="top"||t==="bottom"||t==="left"||t==="right"?t:"none"}function _e(t){return t==="bar"||t==="line"||t==="area"||t==="pie"||t==="doughnut"||t==="radar"||t==="scatter"||t==="bubble"?t:"bar"}function xe(t){return t==="bar"||t==="line"||t==="area"||t==="scatter"||t==="bubble"}function we(t){return t.map(e=>e.trim()).filter(Boolean)}var ye=class extends HTMLElement{_canvas;_status;_runtime=null;_loadPromise=null;_chart=null;_renderedType=null;_dataInput=null;_optionsOverride=null;_syncFrame=0;static get observedAttributes(){return["type","legend","stacked","labels"]}get type(){return _e(this.getAttribute("type"))}set type(t){this.setAttribute("type",t)}get legend(){return fe(this.getAttribute("legend"))}set legend(t){this.setAttribute("legend",t)}get stacked(){return this.hasAttribute("stacked")}set stacked(t){this.toggleAttribute("stacked",t)}get labels(){return we(be(this.getAttribute("labels")))}set labels(t){this.setAttribute("labels",t.join(","))}get data(){return this._dataInput}set data(t){this._dataInput=t?structuredClone(t):null,this._scheduleSync()}get options(){return this._optionsOverride}set options(t){this._optionsOverride=t?structuredClone(t):null,this._renderChart()}constructor(){super();let t=this.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=me,t.appendChild(e);let r=document.createElement("div");r.className="dt-chart",this._canvas=document.createElement("canvas"),this._canvas.className="dt-chart__canvas",this._status=document.createElement("div"),this._status.className="dt-chart__status",this._status.textContent="Loading chart",r.append(this._canvas,this._status),t.appendChild(r)}connectedCallback(){this._canvas.addEventListener("click",this._handleCanvasClick),this._ensureRuntime().then(()=>this._renderChart()),this._scheduleSync()}disconnectedCallback(){this._canvas.removeEventListener("click",this._handleCanvasClick),this._syncFrame!==0&&(cancelAnimationFrame(this._syncFrame),this._syncFrame=0),this._chart?.destroy(),this._chart=null,this._renderedType=null}attributeChangedCallback(){this._scheduleSync()}_handleCanvasClick=t=>{if(!this._chart)return;let e=this._chart.getElementsAtEventForMode(t,"nearest",{intersect:!0},!0)[0];if(!e)return;let r=Array.isArray(this._chart.data.labels)?this._chart.data.labels[e.index]??null:null,i=this._chart.data.datasets[e.datasetIndex],n=Array.isArray(i?.data)?i.data[e.index]:void 0;this.dispatchEvent(new CustomEvent("dt-chart-click",{bubbles:!0,composed:!0,detail:{label:r,datasetIndex:e.datasetIndex,index:e.index,value:n}}))};_scheduleSync(){this._syncFrame===0&&(this._syncFrame=requestAnimationFrame(()=>{this._syncFrame=0,this._syncFromCurrentSource()}))}_syncFromCurrentSource(){this._renderChart()}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=ge().then(t=>(this._runtime=t,t))),this._loadPromise)}async _renderChart(){let t=this._dataInput;if(!t){this._setStatus("Waiting for data");return}let e=await this._ensureRuntime(),r=this._buildConfig(e,t),i=r.type;!this._chart||this._renderedType!==i?(this._chart?.destroy(),this._chart=new e.Chart(this._canvas,r),this._renderedType=i):(this._chart.data=r.data,this._chart.options=r.options,this._chart.update()),this._setStatus(t.datasets.length>0?null:"Waiting for data")}_buildConfig(t,e){let r=getComputedStyle(this),i=r.getPropertyValue("--dt-accent").trim()||"#42d4ff",n=r.getPropertyValue("--dt-text").trim()||"#d6ebff",o=r.getPropertyValue("--dt-text-muted").trim()||"#7b93a6",s=r.getPropertyValue("--dt-border").trim()||"rgba(123, 147, 166, 0.3)",a=r.getPropertyValue("--font-mono").trim()||"'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace",d=ve(i),l=this.type==="area"?"line":this.type,u={labels:e.labels??this.labels,datasets:e.datasets.map((b,w)=>{let C=d[w%d.length],g=b.color??D(C,1),M={label:b.label??"",data:b.data,backgroundColor:l==="line"||l==="radar"||l==="scatter"?D(C,l==="scatter"?.95:.24):g,borderColor:g,pointBackgroundColor:g,pointBorderColor:g,pointHoverBackgroundColor:g,pointRadius:this.type==="line"||this.type==="area"?3:4,pointHoverRadius:this.type==="line"||this.type==="area"?5:6,borderWidth:2,tension:l==="line"||this.type==="area"?.32:void 0,fill:this.type==="area"};return l==="pie"||l==="doughnut"?{...M,backgroundColor:Array.isArray(b.data)?b.data.map((F,E)=>D(d[E%d.length],.86)):g,borderColor:Array.isArray(b.data)?b.data.map((F,E)=>D(d[E%d.length],1)):g,borderWidth:1}:l==="scatter"||l==="bubble"?{...M,showLine:!1,backgroundColor:D(C,.78)}:M})},_={responsive:!0,maintainAspectRatio:!1,animation:{duration:320},interaction:{mode:"nearest",intersect:!0},plugins:{legend:{display:this.legend!=="none",position:this.legend==="none"?"top":this.legend,labels:{color:n,boxWidth:12,boxHeight:12,padding:14,font:{family:a,size:11}}},tooltip:{backgroundColor:"rgba(10, 18, 24, 0.92)",borderColor:ke(s,i,.35),borderWidth:1,titleColor:n,bodyColor:n,footerColor:o,titleFont:{family:a,size:11},bodyFont:{family:a,size:11},padding:10}},scales:xe(this.type)?{x:{stacked:this.stacked,grid:{display:!1,color:s},border:{color:s},ticks:{color:o,font:{family:a,size:11}}},y:{stacked:this.stacked,beginAtZero:!0,grid:{display:!1,color:s},border:{color:s},ticks:{color:o,font:{family:a,size:11}}}}:l==="radar"?{r:{angleLines:{color:s},grid:{color:s},pointLabels:{color:o,font:{family:a,size:11}},ticks:{color:o,backdropColor:"transparent",font:{family:a,size:10}}}}:void 0};return{type:l,data:u,options:gt(_,this._optionsOverride??{})}}_setStatus(t){if(!t){this._status.hidden=!0;return}this._status.hidden=!1,this._status.textContent=t}};function ke(t,e,r){let i=tt(t),n=tt(e);if(!i||!n)return t;let o=j(r,0,1),s=((n.h-i.h)%360+540)%360-180;return D({h:(i.h+s*o+360)%360,s:i.s+(n.s-i.s)*o,l:i.l+(n.l-i.l)*o})}var Ce=`:host {
|
|
1283
1286
|
display: block;
|
|
1284
1287
|
color: var(--dt-text);
|
|
1285
1288
|
font-family: var(--font-sans, 'Inter', sans-serif);
|
|
@@ -1729,15 +1732,15 @@ ${r}`}var ze=class extends HTMLElement{_body;_caret;_contentOverride=null;_runti
|
|
|
1729
1732
|
.milkdown .editor td {
|
|
1730
1733
|
border: 1px solid var(--dt-border);
|
|
1731
1734
|
}
|
|
1732
|
-
`,rt=null;function Ne(){return window.__DtMilkdown?Promise.resolve(window.__DtMilkdown):rt||(rt=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/milkdown.umd.js",r.async=!0,r.dataset.dtMilkdown="true",r.onload=()=>{if(window.__DtMilkdown){t(window.__DtMilkdown);return}e(new Error("Milkdown runtime loaded without a __DtMilkdown export."))},r.onerror=()=>e(new Error("Failed to load the Milkdown runtime bundle.")),document.head.appendChild(r)}),rt)}var Te=class extends HTMLElement{_shadow;_runtimeStyleAnchor;_surface;_content;_status;_runtime=null;_loadPromise=null;_editor=null;_pendingValue="";_changeTimer=null;_setupToken=0;_suppressNextChange=!1;static get observedAttributes(){return["placeholder","readonly"]}get placeholder(){return this.getAttribute("placeholder")??""}set placeholder(t){this.setAttribute("placeholder",t)}get readonly(){return this.hasAttribute("readonly")}set readonly(t){this.toggleAttribute("readonly",t)}get value(){return this._editor&&(this._pendingValue=this._editor.getMarkdown()),this._pendingValue}set value(t){let e=String(t??"");this._pendingValue=e,this._editor&&this._runtime&&this._editor.getMarkdown()!==e&&(this._suppressNextChange=!0,this._editor.editor.action(this._runtime.replaceAll(e)))}constructor(){super();let t=this.attachShadow({mode:"open"});this._shadow=t;let e=document.createElement("style");e.textContent=Me,t.appendChild(e),this._runtimeStyleAnchor=document.createComment("runtime-styles"),t.appendChild(this._runtimeStyleAnchor),this._surface=document.createElement("div"),this._surface.className="dt-markdown-editor",this._content=document.createElement("div"),this._content.className="dt-markdown-editor__surface";let r=document.createElement("div");r.className="dt-markdown-editor__content",this._content.appendChild(r),this._status=document.createElement("div"),this._status.className="dt-markdown-editor__status",this._status.textContent="Loading editor",this._surface.append(this._content,this._status),t.appendChild(this._surface)}connectedCallback(){this._initializeEditor()}disconnectedCallback(){this._setupToken+=1,this._clearChangeTimer(),this._destroyEditor()}attributeChangedCallback(t){if(t==="readonly"){this._editor?.setReadonly(this.readonly);return}t==="placeholder"&&this.isConnected&&this._initializeEditor(!0)}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=Ne().then(t=>{this._runtime=t;let e=this._runtimeStyleAnchor;for(let r of t.cssEntries){let i=document.createElement("style");i.dataset.css=r.name,i.textContent=r.css,e.parentNode.insertBefore(i,e.nextSibling)}return t})),this._loadPromise)}async _initializeEditor(t=!1){let e=++this._setupToken;if(this._setStatus("Loading editor"),t)await this._destroyEditor();else if(this._editor){this._setStatus(null);return}try{let r=await this._ensureRuntime();if(!this.isConnected||e!==this._setupToken)return;this._content.replaceChildren();let i=document.createElement("div");i.className="dt-markdown-editor__content",this._content.appendChild(i);let n=new r.Crepe({root:i,defaultValue:this._pendingValue,features:{[r.Crepe.Feature.CodeMirror]:!1,[r.Crepe.Feature.ImageBlock]:!1,[r.Crepe.Feature.Latex]:!1},featureConfigs:{[r.Crepe.Feature.Placeholder]:{text:this.placeholder,mode:"doc"}}});if(n.on(
|
|
1733
|
-
`)){const l=d.trim();if(l.startsWith("title:"))n=l.slice(6).trim().replace(/^["']|["']$/g,""),a=!1;else if(l.startsWith("created:"))
|
|
1734
|
-
`)}function Pe(t,e,r,i,n){const
|
|
1735
|
+
`,rt=null;function Ne(){return window.__DtMilkdown?Promise.resolve(window.__DtMilkdown):rt||(rt=new Promise((t,e)=>{let r=document.createElement("script");r.src="/api/ui/milkdown.umd.js",r.async=!0,r.dataset.dtMilkdown="true",r.onload=()=>{if(window.__DtMilkdown){t(window.__DtMilkdown);return}e(new Error("Milkdown runtime loaded without a __DtMilkdown export."))},r.onerror=()=>e(new Error("Failed to load the Milkdown runtime bundle.")),document.head.appendChild(r)}),rt)}var Te=class extends HTMLElement{_shadow;_runtimeStyleAnchor;_surface;_content;_status;_runtime=null;_loadPromise=null;_editor=null;_pendingValue="";_changeTimer=null;_setupToken=0;_suppressNextChange=!1;static get observedAttributes(){return["placeholder","readonly"]}get placeholder(){return this.getAttribute("placeholder")??""}set placeholder(t){this.setAttribute("placeholder",t)}get readonly(){return this.hasAttribute("readonly")}set readonly(t){this.toggleAttribute("readonly",t)}get value(){return this._editor&&(this._pendingValue=this._editor.getMarkdown()),this._pendingValue}set value(t){let e=String(t??"");this._pendingValue=e,this._editor&&this._runtime&&this._editor.getMarkdown()!==e&&(this._suppressNextChange=!0,this._editor.editor.action(this._runtime.replaceAll(e)))}constructor(){super();let t=this.attachShadow({mode:"open"});this._shadow=t;let e=document.createElement("style");e.textContent=Me,t.appendChild(e),this._runtimeStyleAnchor=document.createComment("runtime-styles"),t.appendChild(this._runtimeStyleAnchor),this._surface=document.createElement("div"),this._surface.className="dt-markdown-editor",this._content=document.createElement("div"),this._content.className="dt-markdown-editor__surface";let r=document.createElement("div");r.className="dt-markdown-editor__content",this._content.appendChild(r),this._status=document.createElement("div"),this._status.className="dt-markdown-editor__status",this._status.textContent="Loading editor",this._surface.append(this._content,this._status),t.appendChild(this._surface)}connectedCallback(){this._initializeEditor()}disconnectedCallback(){this._setupToken+=1,this._clearChangeTimer(),this._destroyEditor()}attributeChangedCallback(t){if(t==="readonly"){this._editor?.setReadonly(this.readonly);return}t==="placeholder"&&this.isConnected&&this._initializeEditor(!0)}async _ensureRuntime(){return this._runtime?this._runtime:(this._loadPromise||(this._loadPromise=Ne().then(t=>{this._runtime=t;let e=this._runtimeStyleAnchor;for(let r of t.cssEntries){let i=document.createElement("style");i.dataset.css=r.name,i.textContent=r.css,e.parentNode.insertBefore(i,e.nextSibling)}return t})),this._loadPromise)}async _initializeEditor(t=!1){let e=++this._setupToken;if(this._setStatus("Loading editor"),t)await this._destroyEditor();else if(this._editor){this._setStatus(null);return}try{let r=await this._ensureRuntime();if(!this.isConnected||e!==this._setupToken)return;this._content.replaceChildren();let i=document.createElement("div");i.className="dt-markdown-editor__content",this._content.appendChild(i);let n=new r.Crepe({root:i,defaultValue:this._pendingValue,features:{[r.Crepe.Feature.CodeMirror]:!1,[r.Crepe.Feature.ImageBlock]:!1,[r.Crepe.Feature.Latex]:!1},featureConfigs:{[r.Crepe.Feature.Placeholder]:{text:this.placeholder,mode:"doc"}}});if(n.on(o=>{o.markdownUpdated((s,a)=>{if(this._pendingValue=a,this._suppressNextChange){this._suppressNextChange=!1;return}this._queueChange(a)}),o.focus(()=>{this.dispatchEvent(new CustomEvent("dt-focus",{bubbles:!0,composed:!0}))}),o.blur(()=>{this.dispatchEvent(new CustomEvent("dt-blur",{bubbles:!0,composed:!0}))})}),await n.create(),!this.isConnected||e!==this._setupToken){await n.destroy();return}this._editor=n,this._editor.setReadonly(this.readonly),this._pendingValue=this._editor.getMarkdown(),this._setStatus(null)}catch{e===this._setupToken&&this._setStatus("Failed to load editor")}}async _destroyEditor(){let t=this._editor;if(this._editor=null,!!t)try{await t.destroy()}catch{}}_queueChange(t){this._clearChangeTimer(),this._changeTimer=setTimeout(()=>{this._changeTimer=null,this.dispatchEvent(new CustomEvent("dt-change",{bubbles:!0,composed:!0,detail:{value:t}}))},300)}_clearChangeTimer(){this._changeTimer&&(clearTimeout(this._changeTimer),this._changeTimer=null)}_setStatus(t){if(t){this._status.hidden=!1,this._status.textContent=t;return}this._status.hidden=!0}};customElements.get("dt-tooltip")||customElements.define("dt-tooltip",zt),customElements.get("dt-card")||customElements.define("dt-card",Tt),customElements.get("dt-select")||customElements.define("dt-select",Vt),customElements.get("dt-grid")||customElements.define("dt-grid",Bt),customElements.get("dt-stack")||customElements.define("dt-stack",Ut),customElements.get("dt-stat")||customElements.define("dt-stat",Xt),customElements.get("dt-badge")||customElements.define("dt-badge",Qt),customElements.get("dt-button")||customElements.define("dt-button",ee),customElements.get("dt-divider")||customElements.define("dt-divider",ne),customElements.get("dt-list-view")||customElements.define("dt-list-view",pe),customElements.get("dt-table-view")||customElements.define("dt-table-view",ce),customElements.get("dt-column")||customElements.define("dt-column",ut),customElements.get("dt-chart")||customElements.define("dt-chart",ye),customElements.get("dt-markdown")||customElements.define("dt-markdown",ze),customElements.get("dt-markdown-editor")||customElements.define("dt-markdown-editor",Te);function Le(t){const e=t.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?([\s\S]*)$/);return e?e[1]:t}var He=ft(function({note:e,loading:r,onSave:i},n){const o=H(null),[s,a]=I("idle"),d=H(null),l=H(i);return l.current=i,B(()=>{if(o.current&&e){const u=Le(e.content);o.current.value=u}},[e?.id]),B(()=>{const u=o.current;if(!u)return;const _=b=>{const w=b.detail;w&&(d.current&&clearTimeout(d.current),a("saving"),d.current=setTimeout(()=>{l.current(w.value),a("saved")},500))};return u.addEventListener("dt-change",_),()=>u.removeEventListener("dt-change",_)},[]),B(()=>()=>{d.current&&clearTimeout(d.current)},[]),_t(n,()=>({getMarkdown(){return o.current?.value??null},setMarkdown(u){o.current&&(o.current.value=u)},getCursorLine(){return 1},getSelectedText(){return""}}),[]),e?T("div",{className:v.editorPanel,children:[T("div",{className:v.editorHeader,children:[T("div",{children:[p("div",{className:v.editorTitle,children:e.title}),e.tags.length>0&&p("div",{className:v.editorTags,children:e.tags.map(u=>p("span",{className:v.editorTag,children:u},u))})]}),p("span",{className:s==="saving"?v.saveStatusSaving:v.saveStatus,children:s==="saving"?"Saving...":s==="saved"?"Saved":""})]}),p("div",{className:v.editorBody,children:p("dt-markdown-editor",{ref:o,placeholder:"Start writing...",style:{height:"100%"}})})]}):p("div",{className:v.editorPanel,children:p("div",{className:v.editorPlaceholder,children:r?"Loading...":"Select a note or create a new one"})})});import{ActionsProvider as Ie,Action as R,useCommand as J}from"@desktalk/sdk";var Re=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;function Fe(t){const e=t.match(Re);if(!e){const d=t.match(/^#\s+(.+)$/m);return{title:d?d[1].trim():"Untitled",tags:[],created:null,body:t}}const r=e[1],i=e[2];let n="Untitled",o=[],s=null,a=!1;for(const d of r.split(`
|
|
1736
|
+
`)){const l=d.trim();if(l.startsWith("title:"))n=l.slice(6).trim().replace(/^["']|["']$/g,""),a=!1;else if(l.startsWith("created:"))s=l.slice(8).trim(),a=!1;else if(l.startsWith("tags:")){a=!0;const u=l.slice(5).trim();u.startsWith("[")&&u.endsWith("]")&&(o=u.slice(1,-1).split(",").map(_=>_.trim().replace(/^["']|["']$/g,"")).filter(Boolean),a=!1)}else a&&l.startsWith("- ")?o.push(l.slice(2).trim().replace(/^["']|["']$/g,"")):a=!1}return{title:n,tags:o,created:s,body:i}}function $e(t,e,r,i){const n=["---",`title: "${t.replace(/"/g,'\\"')}"`];if(e.length>0){n.push("tags:");for(const o of e)n.push(` - ${o}`)}return n.push(`created: ${r}`,"---","",i),n.join(`
|
|
1737
|
+
`)}function Pe(t,e,r,i,n){const s=t.substring(0,n).split(`
|
|
1735
1738
|
`).length,a=r.split(`
|
|
1736
1739
|
`),d=i.split(`
|
|
1737
|
-
`),l=Math.max(0,
|
|
1740
|
+
`),l=Math.max(0,s-4),u=t.split(`
|
|
1738
1741
|
`),_=e.split(`
|
|
1739
|
-
`),b=[];b.push(`@@ -${
|
|
1740
|
-
`),firstChangedLine:
|
|
1742
|
+
`),b=[];b.push(`@@ -${s},${a.length} +${s},${d.length} @@`);for(let g=l;g<s-1;g++)b.push(` ${u[g]}`);for(const g of a)b.push(`-${g}`);for(const g of d)b.push(`+${g}`);const w=s-1+a.length,C=Math.min(_.length,w+3);for(let g=w;g<C;g++)_[g]!==void 0&&b.push(` ${_[g]}`);return{diff:b.join(`
|
|
1743
|
+
`),firstChangedLine:s}}function De({children:t,selectedNoteId:e,selectedNote:r,notes:i,editorRef:n,onNoteCreated:o,onNoteDeleted:s,onSearch:a,onNoteUpdated:d,onSelectNote:l,onRefresh:u}){const _=J("notes.create"),b=J("notes.delete"),w=J("notes.search"),C=J("notes.update"),g=x(async f=>{const m=await _({title:f?.title||void 0,content:f?.content||void 0,tags:f?.tags||void 0,path:f?.path||void 0});return o(m),m},[_,o]),M=x(async()=>{e&&(await b({id:e}),s(e))},[b,e,s]),F=x(async f=>{const m=f?.query||"";return a(m),await w({query:m})},[w,a]),E=x(()=>{if(!r)return null;const f=n.current;if(!f)return null;const m=f.getMarkdown();return m===null?null:$e(r.title,r.tags,r.createdAt,m)},[r,n]),$=x(async()=>({notes:i.slice(0,20).map(m=>({id:m.id,title:m.title,updatedAt:m.updatedAt,selected:m.id===e}))}),[i,e]),A=x(async f=>{const m=f?.id;return m?i.find(N=>N.id===m)?(await l(m),{success:!0}):{success:!1,error:`Note not found: ${m}`}:{success:!1,error:"id parameter is required"}},[i,l]),U=x(async()=>{if(!e||!r)return{error:"No note is currently open"};const f=n.current;if(!f)return{error:"Editor is not ready"};const m=E();return m===null?{error:"Editor is not ready"}:{id:r.id,title:r.title,content:m,cursorLine:f.getCursorLine(),selectedText:f.getSelectedText()}},[e,r,n,E]),V=x(async f=>{if(!e||!r)return{success:!1,error:"No note is currently open"};const m=n.current;if(!m)return{success:!1,error:"Editor is not ready"};const y=f?.old_text,N=f?.new_text;if(y===void 0||N===void 0)return{success:!1,error:"Both old_text and new_text are required"};const S=E();if(S===null)return{success:!1,error:"Editor is not ready"};let P,O;if(y==="")P=N+S,O=0;else{const z=S.indexOf(y);if(z===-1)return{success:!1,error:"Text not found in note"};const Y=S.indexOf(y,z+1);if(Y!==-1){let it=2,nt=Y+1;for(;;){const ot=S.indexOf(y,nt);if(ot===-1)break;it++,nt=ot+1}return{success:!1,error:`Text appears ${it} times; provide more surrounding context to make it unique`}}P=S.substring(0,z)+N+S.substring(z+y.length),O=z}const c=Fe(P);m.setMarkdown(c.body);const k=c.tags.length!==r.tags.length||c.tags.some((z,Y)=>z!==r.tags[Y]),W=c.title!==r.title;if(k||W){const z=await C({id:e,tags:c.tags,content:c.body});d(z)}const{diff:G,firstChangedLine:vt}=Pe(S,P,y,N,O);return{success:!0,diff:G,firstChangedLine:vt}},[e,r,n,E,C,d]);return T(Ie,{children:[p(R,{name:"Create Note",description:"Create a new note with optional title, content, and path",params:{title:{type:"string",description:"Note title",required:!1},content:{type:"string",description:"Note content in Markdown",required:!1},tags:{type:"string",description:"Comma-separated tags",required:!1},path:{type:"string",description:'Relative path for the note (e.g. "work/meeting-notes"). Becomes the note ID. Auto-generated if omitted.',required:!1}},handler:g}),p(R,{name:"Delete Note",description:"Delete the currently selected note",handler:M}),p(R,{name:"Search Notes",description:"Search notes by keyword",params:{query:{type:"string",description:"Search query",required:!0}},handler:F}),p(R,{name:"List Notes",description:"Return the 20 most recent notes with selection status",handler:$}),p(R,{name:"Select Note",description:"Select a note by ID and open it in the editor",params:{id:{type:"string",description:"Note ID (relative path without .md)",required:!0}},handler:A}),p(R,{name:"Get Editing Context",description:"Return the current editor state for the selected note including content, cursor position, and selected text",handler:U}),p(R,{name:"Edit Note",description:"Apply a text replacement to the current note content including front matter. Use old_text to find exact text and new_text to replace it. To edit tags or title, modify the YAML front matter directly.",params:{old_text:{type:"string",description:"Exact text to find in the note content (must appear exactly once). Searches the full content including YAML front matter. Use empty string to insert at beginning.",required:!0},new_text:{type:"string",description:"Replacement text",required:!0}},handler:V}),t]})}var Ve=720;function Oe(){const[t,e]=I([]),[r,i]=I(null),[n,o]=I(null),[s,a]=I(""),[d,l]=I(!1),[u,_]=I(!1),b=H(null),w=H(null),C=q("notes.list"),g=q("notes.get"),M=q("notes.update"),F=q("notes.search"),E=q("notes.create"),$=x(async()=>{try{let c;s?c=await F({query:s}):c=await C(),e(c)}catch(c){console.error("Failed to fetch notes:",c)}},[C,F,s]),A=x(()=>{$()},[$]);B(()=>{A()},[A]),B(()=>{if(!w.current)return;const c=W=>{_(W<=Ve)};c(w.current.clientWidth);const k=new ResizeObserver(W=>{const G=W[0];G&&c(G.contentRect.width)});return k.observe(w.current),()=>k.disconnect()},[]);const U=x(async c=>{i(c),l(!0);try{const k=await g({id:c});o(k)}catch(k){console.error("Failed to load note:",k),o(null)}finally{l(!1)}},[g]),V=H(null),f=x(c=>{a(c),V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{},300)},[]),m=x(async c=>{if(!(!r||!n))try{const k=await M({id:r,content:c});o(k),$()}catch(k){console.error("Failed to save note:",k)}},[r,n,M,$]),y=x(c=>{A(),i(c.id),o(c)},[A]),N=x(c=>{r===c&&(i(null),o(null)),A()},[r,A]),S=x(c=>{r===c.id&&o(c),A()},[r,A]),P=x(c=>{a(c)},[]),O=x(async()=>{try{const c=await E({});y(c)}catch(c){console.error("Failed to create note:",c)}},[E,y]);return p(De,{selectedNoteId:r,selectedNote:n,notes:t,editorRef:b,onNoteCreated:y,onNoteDeleted:N,onSearch:P,onNoteUpdated:S,onSelectNote:U,onRefresh:A,children:T("div",{ref:w,className:`${v.root}${u?` ${v.rootCompact}`:""}`,children:[p(Ct,{notes:t,selectedId:r,onSelect:U,onCreate:O,searchQuery:s,onSearchChange:f}),p(He,{ref:b,note:n,loading:d,onSave:m})]})})}function We(t){const e=xt(t.root);return e.render(p(yt,{windowId:t.windowId,children:p(wt,{miniAppId:t.miniAppId,children:p(Oe,{})})})),{deactivate(){e.unmount()}}}export{We as activate};
|
|
1741
1744
|
(() => {
|
|
1742
1745
|
if (typeof document === 'undefined') return;
|
|
1743
1746
|
const styleId = "desktalk-style-desktalk-miniapp-note-emi3yz";
|