From 60ce1f479ee19b145e1ca9db71d24e8fa77e95da Mon Sep 17 00:00:00 2001 From: JP Cen Date: Sat, 14 Dec 2024 18:04:26 -0500 Subject: [PATCH] remove excess logging --- main.js | 2 +- .../SpaceView/Contexts/CalendarView/DayView/DayView.tsx | 2 -- .../SpaceView/Contexts/CalendarView/MonthView/MonthWeekRow.tsx | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/main.js b/main.js index 9dbf5db..ea64046 100644 --- a/main.js +++ b/main.js @@ -327,7 +327,7 @@ In case of a (multi dimensional) array or matrix, the prob order quantile of all ${t.code} }`:"",[t]),n=i=>{e.saveCommand({...t,code:i.split(` `).slice(1,-1).join(` -`),codeType:"script"})};return iE.default.createElement("div",null,iE.default.createElement(XC,{className:"mk-editor-code",value:r,height:"100%",theme:h6e,extensions:[p6e({jsx:!0})],onChange:n}),iE.default.createElement(o9,{type:"script",code:t.code,fields:t.fields,value:{},superstate:e.superstate,path:e.path}))};var j8=e=>{let[t,r]=(0,ea.useState)(null),n=(0,ea.useMemo)(()=>e.superstate.spaceManager.uriByString(e.action),[e.action]),i=p=>{if(r(p),n.authority=="$actions"){e.superstate.spaceManager.saveSystemCommand(n.path.split("/").pop(),p);return}e.superstate.spaceManager.saveCommand(n.path,p.schema.id,()=>p)};(0,ea.useEffect)(()=>{r(e.superstate.cli.commandForAction(e.action))},[e.action]),(0,ea.useEffect)(()=>{let p=h=>{h.path==n.basePath&&r(e.superstate.cli.commandForAction(e.action))};return e.superstate.eventsDispatcher.addListener("actionStateUpdated",p),()=>{e.superstate.eventsDispatcher.removeListener("actionStateUpdated",p)}});let a=(p,h)=>(i({...t,fields:[...t.fields,h]}),!0),o=p=>{i({...t,fields:t.fields.filter(h=>h.name!=p.name)})},s=(p,h)=>{i({...t,fields:t.fields.map(m=>m.name==h.name?p:m)})},u=p=>{let h=p.target.getBoundingClientRect();Pf(e.superstate,h,je(p.view.document),{spaces:[],fields:[],saveField:a,schemaId:t.schema.id,fileMetadata:!0,isSpace:!0})},l=[{name:"Actions",value:"actions"},{name:"Script",value:"script"},{name:"Formula",value:"formula"}],c=p=>{let h=Hr(p.value,p.type);if(h)return h?.default},f=(p,h)=>{let m=Hr(p.value,p.type)??{};m.default=h,s({...p,value:JSON.stringify(m)},p)},d=(0,ea.useMemo)(()=>t?.fields.reduce((p,h)=>({...p,[h.name]:c(h)}),{})??{},[t?.fields]);return ea.default.createElement("div",{className:"mk-editor-actions"},t&&ea.default.createElement(ea.default.Fragment,null,ea.default.createElement("div",{className:"mk-props-contexts"},ea.default.createElement("div",{className:"mk-path-context-row"},ea.default.createElement("div",{className:"mk-path-context-field"},"Type"),ea.default.createElement("div",{className:"mk-path-context-value"},ea.default.createElement(Q9,{superstate:e.superstate,options:l,value:t.schema.type,selectValue:p=>i({...t,schema:{...t.schema,type:p}})}))),ea.default.createElement("div",{className:"mk-path-context-row"},ea.default.createElement("div",{className:"mk-path-context-field"},"Properties")),ea.default.createElement("div",{className:"mk-cell-object"},t.fields.map(p=>ea.default.createElement(Ss,{key:p.name,superstate:e.superstate,initialValue:c(p),column:p,editMode:5,updateValue:h=>{f(p,h)},updateFieldValue:(h,m)=>{i({...t,fields:t.fields.map(g=>p.name==g.name?{...g,value:h}:g)})},propertyMenu:h=>{let m=h.target.getBoundingClientRect();yh({superstate:e.superstate,rect:m,win:je(h.view.document),editable:!0,options:[],field:p,fields:t.fields,contextPath:null,saveField:g=>s(g,p),deleteColumn:o})}}))),ea.default.createElement("button",{className:"mk-inline-button",onClick:p=>u(p)},ea.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")}}),z.labels.newProperty)),t.schema.type=="script"?ea.default.createElement(A6e,{superstate:e.superstate,command:t,saveCommand:i,values:d,path:n.path}):t.schema.type=="actions"?ea.default.createElement(tke,{superstate:e.superstate,formula:t.code,path:n.path,saveOutputType:p=>{i({...t,codeType:p})},saveFormula:p=>{i({...t,code:p})},fields:t.fields,value:d}):t.schema.type=="formula"?ea.default.createElement(mh,{superstate:e.superstate,formula:t.code,saveFormula:p=>{i({...t,code:p})},fields:t.fields,value:d,path:n.path}):ea.default.createElement("div",null)))};var rs=he(Me());var Q8=he(Me());var aE=e=>{let t=[];return e.class&&t.push(`${e.class}`),e.layout&&t.push(`mk-layout-${e.layout}`),e.layoutAlign&&t.push(`mk-layout-align-${e.layoutAlign}`),e.layoutWrap&&t.push(`mk-layout-wrap-${e.layoutWrap}`),e.iconSize&&t.push(`mk-icon-size-${e.iconSize}`),e.imageSize&&t.push(`mk-image-size-${e.imageSize}`),t.join(" ")};var ip=he(Me());var oE=he(Me()),M8=e=>{let t=e.state.props.value,r=(0,oE.useMemo)(()=>e.superstate.ui.getUIPath(t),[t]);return e.state?.props.value?.length>0?oE.default.createElement("audio",{controls:!0,preload:"none",src:r}):oE.default.createElement(oE.default.Fragment,null)};var CZ=he(Me()),N8=e=>CZ.default.createElement(CZ.default.Fragment,null,e.children);var sE=he(Me());function Ret(e){return e?.replace(/([^/])#([*^])/g,"$1/#$2")}var T8=e=>{let t=Ret(e.state?.props?.value),{updateNode:r}=(0,sE.useContext)(Oi),{id:n}=(0,sE.useContext)(vi),i=o=>{oo(o,je(o.view.document),e.superstate,s=>r(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(s+"/#^"+Fr)}}))},a=o=>{if(e.treeNode.node.props.value=="$contexts['$space']['space']"){r(e.treeNode.node,{props:{...e.treeNode.node.props,value:`$contexts['$space']['space']+"/#*${o}"`}});return}q5(e.superstate,e.superstate.spaceManager.resolvePath(t,e.source)).then(s=>{r(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(s?.space+"#*"+o)}})})};return e.state&&t?sE.default.createElement(Jv,{id:n,source:e.source,showTitle:!0,superstate:e.superstate,path:t,minMode:e.state?.styles?.["--mk-min-mode"],containerRef:e.containerRef,setFrameSchema:a}):sE.default.createElement("div",{className:"mk-frame-placeholder",onClick:o=>i(o)},z.labels.selectSpace)};var Eo=he(Me());var uo=he(Me()),g6e=he(Ws()),VD=(0,uo.forwardRef)((e,t)=>{let r=(0,uo.useRef)(null),[n,i]=(0,uo.useState)(0),[a,o]=(0,uo.useState)(!1),s=(0,uo.useRef)(null),[u,l]=(0,uo.useState)({x:0,y:0}),[c,f]=(0,uo.useState)(!1),[d,p]=(0,uo.useState)("");(0,uo.useEffect)(()=>{let g=new ResizeObserver(A=>{if(s.current){let b=s.current.getBoundingClientRect();o(!0),l(ZN(r.current.getBoundingClientRect(),b,{width:window.innerWidth,height:innerHeight},"bottom"))}});return s.current&&r.current&&(g.observe(s.current),g.observe(r.current)),()=>{g.disconnect()}},[s.current]);let h=g=>{if((g.key=="Delete"||g.key=="Backspace")&&r.current.innerText==""&&e.onDelete&&e.onDelete(),g.key=="Tab"&&e.sections&&e.onSelectSection&&(g.preventDefault(),g.stopPropagation(),p(A=>{let b=e.sections.findIndex(v=>v.value==A);return g.shiftKey?b==0?A:(e.onSelectSection(e.sections[b-1].value),e.sections[b-1].value):b==e.sections.length-1?A:(e.onSelectSection(e.sections[b+1].value),e.sections[b+1].value)})),g.key=="ArrowUp"){let A=e.suggestions.length-1,b=n<0?A:n-1;e.suggestions[b]?.disabled?i(b<0?A:b-1):i(b),g.preventDefault()}if(g.key=="ArrowDown"){let A=e.suggestions.length-1,b=n>=A?0:n+1;e.suggestions[b]?.disabled?i(b>=A?0:b+1):i(b),g.preventDefault()}g.key=="Enter"&&(e.onSelect(e.suggestions[n]),g.preventDefault())},m={root:"mk-menu-container",rootFocused:"mk-focused",selected:"mk-selected",selectedTagWrapper:"mk-menu-selected-tag-wrapper",selectedTag:"mk-menu-selected-tag",selectedTagName:"mk-menu-selected-tag-name",search:"mk-menu-search",searchWrapper:"mk-menu-search-container",searchInput:"mk-menu-search-input",suggestions:"mk-menu-suggestions",suggestionActive:"mk-active",suggestionDisabled:"mk-disabled"};return uo.default.createElement(uo.default.Fragment,null,uo.default.createElement("div",{ref:g=>{r.current=g,t&&(typeof t=="function"?t(g):t.current=g)},onFocus:()=>{e.onFocus&&e.onFocus(),f(!0)},onBlur:()=>{e.onBlur&&e.onBlur(),f(!1)},"data-placeholder":e.placeholder,onInput:g=>e.onChange(g.currentTarget.innerText),onKeyDown:g=>h(g),className:"mk-suggester",contentEditable:!0}),c&&(0,g6e.createPortal)(uo.default.createElement("div",{ref:s,className:`mk-menu mk-menu-suggester ${a?"mk-ready":""}`,style:{position:"absolute",top:u.y,left:u.x,zIndex:1e3,width:"300px","--mk-menu-max-height":"300px",visibility:c?"visible":"hidden"}},e.sections?uo.default.createElement("div",{className:"mk-menu-sections"},e.sections.map((g,A)=>uo.default.createElement("div",{key:A,onClick:()=>p(g.value),className:`${d==g.value?"is-active":""} mk-menu-section`},g.name==""?z.labels.all:g.name))):uo.default.createElement(uo.default.Fragment,null),uo.default.createElement(q9,{expanded:!1,addKeyword:"Add",options:e.suggestions,query:"",refs:null,hide:()=>null,selectOption:e.onSelect,id:"",onHide:()=>null,classNames:m,index:n,setIndex:i,allowNew:!1,ui:e.superstate.ui,isDisclosureMenu:!1})),document.body))});VD.displayName="Suggester";function $et(e){let t=/!\[!\[(.*?)\]\]/,r=/!!\[\[(.*?)\]\]/,n=e.match(t),i=e.match(r);return n?n[1]:i?i[1]:e}var F8=e=>{let{spaceState:t}=(0,Eo.useContext)(ar),r=(0,Eo.useMemo)(()=>{let m=e.state?.props?.value,g=m?e.superstate.spaceManager.resolvePath($et(m),e.source):null,A=e.superstate.spaceManager.uriByString(m);return A?.scheme=="https"||A?.scheme=="http"?{path:m,label:{sticker:A.scheme,name:A.path,color:""},hidden:!1,subtype:"md",type:"remote",readOnly:!0}:e.superstate.pathsIndex.get(g)},[e.state,e.source]),{updateNode:n,nodes:i}=(0,Eo.useContext)(Oi),{selectionMode:a}=(0,Eo.useContext)(ji),[o,s]=(0,Eo.useState)(e.state?.styles?.["--mk-expanded"]),u=m=>{if(m!=e.state.props?.value)if(e.treeNode.editorProps?.linkedNode){let g=i.find(A=>A.id==e.treeNode.editorProps.linkedNode.node);n(g,{props:{...g.props,[e.treeNode.editorProps.linkedNode.prop]:mr(m)}})}else n(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(m)}})},l=e.state?.styles?.["--mk-link"],{id:c}=(0,Eo.useContext)(vi),[f,d]=(0,Eo.useState)(""),p=(0,Eo.useMemo)(()=>{let m={keys:["name","value"]},g=[...e.superstate.pathsIndex.values()].filter(b=>!b.hidden&&b.subtype=="md"||b.subtype=="space").map(b=>({name:b.label.name,value:b.path,description:b.path,icon:b.label?.sticker})),A=new zc(g,m);return f?.length==0?g:A.search(f).map(b=>b.item)},[f]),h=()=>{s(m=>!m),a>0&&n(e.treeNode.node,{styles:{...e.treeNode.node.styles,"--mk-expanded":(!e.state?.styles?.["--mk-expanded"]).toString()}})};return Eo.default.createElement("div",{className:"mk-node-flow"},!e.state?.styles?.["--mk-min-mode"]&&Eo.default.createElement(Eo.default.Fragment,null,r?Eo.default.createElement("div",{className:"mk-node-link"},Eo.default.createElement(Pa,{superstate:e.superstate,path:r.path},!l&&Eo.default.createElement(Uc,{superstate:e.superstate,collapsed:!o,onToggle:h}))):a>0&&Eo.default.createElement("div",{className:"mk-node-text-placeholder"},Eo.default.createElement(VD,{placeholder:z.hintText.selectNote,onChange:m=>{d(m)},suggestions:p,superstate:e.superstate,onSelect:m=>{u(m.value)}}))),e.state&&o&&(e.state?.props?.value?.length>0?Eo.default.createElement(_8,{id:c,superstate:e.superstate,path:r?.path??e.state?.props?.value,containerRef:e.containerRef,styles:{},readOnly:!0}):Eo.default.createElement("div",{onClick:()=>Un(e.superstate,t,"md",null,!0).then(m=>u(m))},"New Note")))};var TZ=he(to());var zt=he(Me()),tCe=he(Ws());var rp=he(Me()),v6e=e=>{let{groupNodes:t,saveNodes:r,nodes:n}=(0,rp.useContext)(Oi),{selection:i,select:a}=(0,rp.useContext)(ji),o=i.map(s=>n.find(u=>u.id==s)).filter(s=>s);return rp.default.createElement("div",{className:"mk-editor-frame-node-selector",style:{pointerEvents:"auto"},onClick:s=>s.stopPropagation()},rp.default.createElement("div",{className:"mk-mark"},rp.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//copy-check")}}),z.labels.itemsSelected.replace("${1}",i.length.toString())),rp.default.createElement("div",{className:"mk-divider"}),rp.default.createElement("div",{"aria-label":z.editor.createVerticalSection,className:"mk-mark",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//rows")},onClick:()=>t(o,{layoutAlign:'"left"',gap:'"8px"'})}),rp.default.createElement("div",{"aria-label":z.editor.createHorizontalSection,className:"mk-mark",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//columns")},onClick:()=>t(o,{layout:'"row"',gap:'"8px"'})}),rp.default.createElement("div",{className:"mk-divider"}),rp.default.createElement("div",{className:"mk-mark","aria-label":z.menu.delete,onClick:()=>r([],o),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//trash")}}))};var or=he(Me());var qet=e=>{if(e=="table")return{view:"table",listView:"",listGroup:"",listItem:""};if(e=="flow")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*flowListItem"};if(e=="list")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*rowItem"};if(e=="details")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*detailItem"};if(e=="board")return{view:"list",listView:"spaces://$kit/#*columnView",listGroup:"spaces://$kit/#*columnGroup",listItem:"spaces://$kit/#*cardListItem"};if(e=="cards")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*gridGroup",listItem:"spaces://$kit/#*cardsListItem"};if(e=="catalog")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*rowGroup",listItem:"spaces://$kit/#*coverListItem"};if(e=="gallery")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*masonryGroup",listItem:"spaces://$kit/#*imageListItem"};if(e=="calendar")return{view:"list",listView:"spaces://$kit/#*calendarView",listGroup:"spaces://$kit/#*dateGroup",listItem:"spaces://$kit/#*eventItem"}},uE=async(e,t,r)=>{let n=r=="board"?"Board":"Table",i=await e.spaceManager.tablesForSpace(t);return i&&(n=Ri(n,i.map(o=>o.id))),await e.spaceManager.createTable(t,{id:n,name:n,type:"db"}).then(o=>e.spaceManager.addSpaceProperty(t,{...tw[0],schemaId:n})).then(async o=>{let s=await e.spaceManager.framesForSpace(t),u={id:Ri(n,s?.map(l=>l.id)??[]),name:n,type:"view",predicate:JSON.stringify({...kS,...r?qet(r):{view:"table"}}),def:JSON.stringify({db:n,icon:r=="board"?"ui//square-kanban":"ui//table"})};return await e.spaceManager.createFrame(t,u),u.id})};var P8=(e,t,r,n,i,a={searchable:!0})=>{let o=[{name:z.commands.newNote,value:{type:"preset",value:"note"},section:"default",icon:"ui//mk-make-flow"},{name:z.commands.table,value:{type:"preset",value:"table"},section:"default",icon:"ui//mk-make-table"}],s=[zi,xf,Yr,Wl,MS,ja,un,ale],u=[xh,TS,_S,FS,PS,IS,NS],l=[...o,...s.map(f=>({name:f.node.name,value:{type:"element",value:f},section:"element",icon:f.def?.icon})),...u.map(f=>({name:f.node.name,value:{type:"default",value:f},section:"element",icon:f.def?.icon}))],c=async f=>{if(f.type=="preset")if(f.value=="note"){let d=r.spacesIndex.get(n.path);if(d){let p=await Un(r,d,"md",null,!0);i({...zi.node,props:{value:mr(p)}})}}else if(f.value=="table"){let d=await uE(r,n.path);i({...xf.node,props:{value:mr(`${n.path}/#*${d}`)}})}else f.value=="link";else f.type=="default"?i({...f.value.node,type:"frame",ref:"spaces://$kit/#*"+f.value.def.id}):f.type=="element"&&i({...f.value.node})};r.ui.openMenu(e,{ui:r.ui,multi:!1,editable:!1,value:[],options:l,saveOptions:(f,d)=>c(d[0]),searchable:a.searchable,showAll:!0},t)};var y6e=he(Me());var I8=e=>{let t=(r,n)=>{let i=o=>{e.setValue(o)},a=r.target.getBoundingClientRect();Ql(e.superstate,a,je(r.view.document),e.value,i)};return y6e.default.createElement("div",{className:"mk-color",style:{background:e.value},onClick:r=>{t(r,"--text-normal")}})};var $o=he(Me());var b6e=he(xi()),lo=he(Me());function Let(e){if(Math.floor(e)===e)return 0;let t=e.toString();return t.split(".")[1].length||t.split(",")[1].length||0}function x6e({style:e={},modifiers:t={},onChange:r,onInput:n,...i}){let[a,o]=(0,lo.useState)(i.value),[s,u]=(0,lo.useState)(""),l=(0,lo.useRef)(0),c=(0,lo.useRef)(null),f=i.step?+i.step:1,d=(0,lo.useMemo)(()=>({shiftKey:.1,...t}),[t]),[,p]=(0,lo.useState)([0,0]),h={cursor:"ew-resize",...e},m=k=>{let M=k.target.value;isNaN(+M)||(o(+M),r?.(+M,c.current))},g=(0,b6e.debounce)(k=>{r?.(k,c.current)},200),A=(0,lo.useCallback)(k=>{requestAnimationFrame(()=>{n?.(k,c.current)}),g(k)},[g,n]),b=(0,lo.useCallback)(k=>{p(M=>{let{clientX:O,clientY:D}=k,[N,C]=M,_=N-O,I=C-D,L=1;s&&(L=d[s]||1);let $=f*L,T=Let($),W=Math.sqrt(_*_+I*I)*$;O{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",v)},[b]),x=(0,lo.useCallback)(k=>{let M=+a;isNaN(M)&&(M=+(i.defaultValue||i.min||0)),l.current=M,p([k.clientX,k.clientY]),document.addEventListener("mousemove",b),document.addEventListener("mouseup",v)},[b,v,a,i.min,i.defaultValue]),w=k=>{k.metaKey?u("metaKey"):k.ctrlKey?u("ctrlKey"):k.altKey?u("altKey"):k.shiftKey&&u("shiftKey")},S=()=>{u("")};return(0,lo.useEffect)(()=>{i.value!==a&&typeof i.value=="number"&&o(i.value)},[i.value]),(0,lo.useEffect)(()=>(document.addEventListener("keydown",w),document.addEventListener("keyup",S),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",v),document.removeEventListener("keydown",w),document.removeEventListener("keyup",S)}),[]),lo.default.createElement("input",{placeholder:"auto",type:"number",...i,value:a,style:h,onMouseDown:x,onChange:m,ref:c})}var ba=e=>{let t=e.value&&zl(e.value)?Ea(e.value).match(/^(\d+(?:\.\d+)?)\s?([a-zA-Z%]+)$/):null,r=t?parseInt(t[1]):0,n=t&&t[2]?t[2]:e.units[0],i=a=>{let o=[];e.units.forEach(u=>{o.push({name:u,onClick:()=>{if(u=="%"){e.setValue(mr(`${100}${u}`));return}e.setValue(mr(`${r}${u}`))}})});let s=a.target.getBoundingClientRect();e.superstate.ui.openMenu(s,Xt(e.superstate.ui,o),je(a.view.document))};return lo.default.createElement("div",{className:"mk-setter-step"},lo.default.createElement("span",null,e.name),lo.default.createElement(x6e,{min:e.min,max:e.max,value:r,onKeyDown:a=>{a.key=="Backspace"&&(a.currentTarget.value.length==1&&e.setValue(null),a.stopPropagation())},onChange:a=>{e.setValue(mr(`${a.toString()+n}`))}}),lo.default.createElement("span",{onClick:a=>i(a)},n))};var GD=he(Me()),w6e=e=>{let t=["nw","n","ne","w","m","e","sw","s","se"],[r,n]=(0,GD.useState)(e.state?.styles?.layoutAlign);return GD.default.createElement("div",{className:"mk-editor-alignment-menu"},t.map(i=>GD.default.createElement("div",{className:`mk-editor-alignment-selector ${r==i&&"mk-active"}`,key:"d",onClick:()=>{n(i),e.saveStyleValue("layoutAlign",mr(i))}})))};var S6e=e=>{let{spaceInfo:t}=(0,$o.useContext)(ar),{addNode:r}=(0,$o.useContext)(Oi),{select:n}=(0,$o.useContext)(ji),{selectedNode:i,saveStyleValue:a}=e;return $o.default.createElement($o.default.Fragment,null,$o.default.createElement("div",{className:"mk-editor-frame-node-button-primary",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:o=>{P8(o.target.getBoundingClientRect(),je(o.view.document),e.superstate,t,s=>r(s,e.selectedNode,!0).then(u=>n(u.id))),o.stopPropagation()}}),$o.default.createElement(Bo,{icon:"ui//arrow-right",superstate:e.superstate,name:z.editor.rows,value:i.styles?.layout,setValue:o=>a("layout",o),onValue:"'row'",defaultValue:"'row'"}),$o.default.createElement(Bo,{icon:"ui//arrow-down",superstate:e.superstate,name:z.editor.columns,value:i.styles?.layout,setValue:o=>a("layout",o),onValue:"'column'",defaultValue:"'column'"}),$o.default.createElement(Bo,{icon:"ui//layout-dashboard",superstate:e.superstate,name:z.editor.gallery,value:i.styles?.layout,setValue:o=>a("layout",o),onValue:"'masonry'",defaultValue:"'masonry'"}),$o.default.createElement("div",{className:"mk-divider"}),e.state.styles?.layout=="row"||e.state.styles?.layout=="column"?$o.default.createElement($o.default.Fragment,null,$o.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:o=>{e.superstate.ui.openCustomMenu(o.target.getBoundingClientRect(),$o.default.createElement(w6e,{...e}),{...e},je(o.view.document))},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//grid")}}),$o.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:o=>{o.preventDefault(),o.stopPropagation(),a("flexWrap",`${Ea(i.styles.flexWrap)=="wrap"?"":mr("wrap")}`)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//wrap-text")}}),$o.default.createElement(ba,{superstate:e.superstate,name:z.editor.gap,value:i.styles?.gap,setValue:o=>a("gap",o),units:["px"]})):$o.default.createElement($o.default.Fragment,null,$o.default.createElement(ba,{superstate:e.superstate,name:z.editor.columns,value:i.styles?.columnCount,min:0,setValue:o=>a("columnCount",o),units:[""]})))};var Sb=he(Me());var bb=he(Me());var E6e=e=>{let{selectedNode:t,saveStyleValue:r}=e;return bb.default.createElement(bb.default.Fragment,null,bb.default.createElement("div",{className:"mk-divider"}),bb.default.createElement(ba,{superstate:e.superstate,name:z.editor.width,min:0,value:t.styles?.width,setValue:n=>r("width",n),units:["px","%","em"]}),bb.default.createElement("div",{className:"mk-divider"}),bb.default.createElement(ba,{superstate:e.superstate,name:z.editor.height,min:0,value:t.styles?.height,setValue:n=>r("height",n),units:["px","%","em"]}))};var Cg=he(Me());var xb=he(Me());var k6e=e=>{let{selectedNode:t,saveStyleValue:r}=e;return xb.default.createElement(xb.default.Fragment,null,xb.default.createElement(ba,{superstate:e.superstate,name:z.editor.marginLeft,value:t.styles?.marginLeft,setValue:n=>r("marginLeft",n),units:["px","em"]}),xb.default.createElement(ba,{superstate:e.superstate,name:z.editor.marginTop,value:t.styles?.marginTop,setValue:n=>r("marginTop",n),units:["px","em"]}),xb.default.createElement(ba,{superstate:e.superstate,name:z.editor.marginRight,value:t.styles?.marginRight,setValue:n=>r("marginRight",n),units:["px","em"]}),xb.default.createElement(ba,{superstate:e.superstate,name:z.editor.marginBottom,value:t.styles?.marginBottom,setValue:n=>r("marginBottom",n),units:["px","em"]}))};var wb=he(Me());var C6e=e=>{let{selectedNode:t,saveStyleValue:r}=e;return wb.default.createElement(wb.default.Fragment,null,wb.default.createElement(ba,{superstate:e.superstate,name:z.editor.paddingLeft,value:t.styles?.paddingLeft,setValue:n=>r("paddingLeft",n),units:["px","em"]}),wb.default.createElement(ba,{superstate:e.superstate,name:z.editor.paddingTop,min:0,value:t.styles?.paddingTop,setValue:n=>r("paddingTop",n),units:["px","em"]}),wb.default.createElement(ba,{superstate:e.superstate,name:z.editor.paddingRight,min:0,value:t.styles?.paddingRight,setValue:n=>r("paddingRight",n),units:["px","em"]}),wb.default.createElement(ba,{superstate:e.superstate,name:z.editor.paddingBottom,min:0,value:t.styles?.paddingBottom,setValue:n=>r("paddingBottom",n),units:["px","em"]}))};var D6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=a=>{let o=a.target.getBoundingClientRect();return e.superstate.ui.openCustomMenu(o,Cg.default.createElement(C6e,{...e}),e,je(a.view.document))},i=a=>{let o=a.target.getBoundingClientRect();return e.superstate.ui.openCustomMenu(o,Cg.default.createElement(k6e,{...e}),e,je(a.view.document))};return Cg.default.createElement(Cg.default.Fragment,null,Cg.default.createElement(ba,{superstate:e.superstate,name:z.editor.margin,value:t.styles?.margin,setValue:a=>r("margin",a),units:["px","em"]}),Cg.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:a=>{i(a)}}),Cg.default.createElement(ba,{superstate:e.superstate,name:z.editor.padding,min:0,value:t.styles?.padding,setValue:a=>r("padding",a),units:["px","em"]}),Cg.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:a=>{n(a)}}))};var O6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=(i,a)=>{let o=a=="icon"?"iconSize":"imageSize",s=[];s.push({name:z.labels.styleSmall,icon:"type",onClick:()=>{r(o,"'s'")}}),s.push({name:z.labels.styleMedium,icon:"type",onClick:()=>{r(o,"'m'")}}),s.push({name:z.labels.styleLarge,icon:"type",onClick:()=>{r(o,"'l'")}});let u=i.target.getBoundingClientRect();e.superstate.ui.openMenu(u,Xt(e.superstate.ui,s),je(i.view.document))};return Sb.default.createElement(Sb.default.Fragment,null,Sb.default.createElement("div",{className:"mk-divider"}),Sb.default.createElement(D6e,{...e}),Sb.default.createElement(E6e,{...e}),Sb.default.createElement("div",{className:"mk-divider"}))};var B8=he(Me());var j6e=e=>{let{selectedNode:t,saveStyleValue:r}=e;return B8.default.createElement(B8.default.Fragment,null,B8.default.createElement(Bo,{superstate:e.superstate,name:z.editor.minimize,value:t.styles?.["--mk-min-mode"],defaultValue:"false",onValue:"true",icon:"ui//panel-top-close",setValue:n=>r("--mk-min-mode",n)}))};var M6e=he(to());var qo=he(Me());var N6e=e=>{let{selectedNode:t,pathState:r,savePropValue:n,frameProps:i,fields:a,frameProperties:o,instance:s}=e,u=(d,p)=>{d.preventDefault();let h=zl(i?.[p.name]),m=[];h||(m.push({name:z.editor.unlinkProperty,icon:"ui//unplug",onClick:()=>{n(p.name,mr(e.state.props?.[p.name]))}}),m.push(Wt));let g=[p.type];g.push("fileprop"),(p.type=="image"||p.type=="link"||p.type=="context")&&(g.push("file"),g.push("link"),g.push("image"),g.push("context"));let A=v=>v=="$space"?z.editor.currentSpace:v;Object.keys(s.state.$contexts).forEach(v=>{twe(e.superstate,v).forEach(x=>{v!=s.state.$contexts?.$context?._path&&x.primary=="true"||(g.includes(x.type)&&m.push({name:Yo(x,e.superstate),icon:qi(x),description:A(v),onClick:()=>{n(p.name,`$contexts['${v}']['${x.name}']`)}}),(x.type=="link"||x.type=="image"||x.type=="file")&&(p.type=="icon"&&m.push({name:`${Yo(x,e.superstate)} Sticker`,icon:qi(x),description:A(v),onClick:()=>{n(p.name,`$api.path.label($contexts['${v}']['${x.name}'])?.sticker`)}}),p.type=="text"&&m.push({name:z.editor.linkName.replace("${1}",Yo(x,e.superstate)),icon:qi(x),description:A(v),onClick:()=>{n(p.name,`$api.path.label($contexts['${v}']['${x.name}'])?.name`)}}),p.type=="image"&&m.push({name:z.editor.linkThumbnail.replace("${1}",Yo(x,e.superstate)),icon:qi(x),description:A(v),onClick:()=>{n(p.name,`$api.path.label($contexts['${v}']['${x.name}'])?.thumbnail`)}})))}),m.push(Wt)}),o.filter(v=>g.some(x=>x==v.type)).forEach(v=>{m.push({name:v.name,icon:qi(v),onClick:()=>{n(p.name,`${v.schemaId}.props['${v.name}']`)}})}),m.push(Wt),o.filter(v=>v.type!=p.type).forEach(v=>{(v.type=="link"||v.type=="image"||v.type=="file")&&(p.type=="icon"&&m.push({name:z.editor.linkSticker.replace("${1}",Yo(v,e.superstate)),icon:qi(v),onClick:()=>{n(p.name,`$api.path.label(${v.schemaId}.props['${v.name}'])?.sticker`)}}),p.type=="image"&&m.push({name:z.editor.linkThumbnail.replace("${1}",v.name),icon:qi(v),onClick:()=>{n(p.name,`$api.path.label(${v.schemaId}.props['${v.name}'])?.thumbnail`)}})),p.type=="text"&&(v.type=="link"||v.type=="file")&&m.push({name:z.editor.linkName.replace("${1}",Yo(v,e.superstate)),icon:qi(v),onClick:()=>{n(p.name,`$api.path.label(${v.schemaId}.props['${v.name}'])?.name`)}})});let b=d.target.getBoundingClientRect();e.superstate.ui.openMenu(b,Xt(e.superstate.ui,m),je(d.view.document),"bottom")},l=d=>o?.find(h=>h.name==eh(i?.[d])?.prop),c=(d,p)=>{if(!d||!p)return null;if(d.type.startsWith("object"))return HW(p);if(d.type=="option")return(Hr(d.value,d.type,e.superstate,r.path).options??[]).find(g=>g.value==Ea(p))?.name??null;if(d.type=="super"){let h=Hr(d.value,d.type,e.superstate);if(h.dynamic?Ea(i[h.field??""]):h.field)return p}return zl(p)?Ea(p):null},f=d=>d.type.startsWith("object")||d.type=="super";return qo.default.createElement("div",{className:"mk-editor-frame-properties"},qo.default.createElement("div",{className:"mk-editor-actions-name"},qo.default.createElement("div",{className:"mk-editor-actions-name-icon"},qo.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//list")}})),qo.default.createElement("div",{className:"mk-editor-actions-name-text"},z.buttons.editProperty),qo.default.createElement("span",null),qo.default.createElement("div",{className:"mk-icon-small mk-inline-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//close")},onClick:()=>e.hide()})),qo.default.createElement("div",{className:"mk-props-contexts"},a.map((d,p)=>{let h=d.type.startsWith("object")?DT(i?.[d.name],d.type):d.type=="super"||zl(i?.[d.name]),m=f(d);return qo.default.createElement(qo.default.Fragment,{key:p},h?qo.default.createElement(Ss,{initialValue:c(d,i?.[d.name]),column:d,compactMode:!1,superstate:e.superstate,editMode:3,row:e.state?.props,updateValue:g=>{Qx(d)?n(d.name,g):n(d.name,mr(g))},linkProp:g=>u(g,d),source:r.path,columns:o}):qo.default.createElement("div",{className:(0,M6e.default)("mk-path-context-row",m&&"mk-path-context-stacked")},d.type=="input"?qo.default.createElement(E9,{initialValue:i?.[d.name],superstate:e.superstate,compactMode:!0,property:d,editMode:3,saveValue:g=>n(d.name,mr(g)),columns:o}):qo.default.createElement(qo.default.Fragment,null,qo.default.createElement(iD,{path:r.path,superstate:e.superstate,property:d,draggable:!0}),qo.default.createElement("div",{className:"mk-active"},qo.default.createElement("div",{"aria-label":z.editor.linkedProperty},pC(i?.[d.name])))),qo.default.createElement("span",null),!m&&qo.default.createElement("div",{"aria-label":z.editor.linkProperty,className:"mk-icon-small mk-inline-button",onClick:g=>u(g,d),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plug")}})))})))};var lE=he(Me());var e1=he(Me());var T6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=a=>{let o=[];o.push({name:z.editor.strokeNone,icon:"ui//type",onClick:()=>{r("outlineStyle","'none'")}}),o.push({name:z.editor.strokeSolid,icon:"ui//type",onClick:()=>{r("outlineStyle","'solid'")}}),o.push({name:z.editor.strokeDashed,icon:"ui//type",onClick:()=>{r("outlineStyle","'dashed'")}}),o.push({name:z.editor.strokeDotted,icon:"ui//type",onClick:()=>{r("outlineStyle","'dotted'")}});let s=a.target.getBoundingClientRect();e.superstate.ui.openMenu(s,Xt(e.superstate.ui,o),je(a.view.document))},i=(a,o)=>{let s=l=>{r(o,`'${l}'`)},u=a.target.getBoundingClientRect();Ql(e.superstate,u,je(a.view.document),Ea(t.styles?.[o]),s)};return e1.default.createElement(e1.default.Fragment,null,e1.default.createElement("div",{className:"mk-divider"}),e1.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:a=>n(a)},e1.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//case-sensitive")}}),e.state.styles?.outlineStyle??z.labels.none),e1.default.createElement(ba,{superstate:e.superstate,name:z.editor.size,value:e.state.styles?.outlineWidth,setValue:a=>r("outlineWidth",a),units:["px","em"]}),e1.default.createElement("div",{onClick:a=>{i(a,"outlineColor")},className:"mk-color",style:{background:e.state.styles?.outlineColor}}))};var F6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=(i,a)=>{let o=u=>{r(a,`'${u}'`)},s=i.target.getBoundingClientRect();Ql(e.superstate,s,je(i.view.document),Ea(e.selectedNode.styles?.[a]),o)};return lE.default.createElement(lE.default.Fragment,null,lE.default.createElement("div",{className:"mk-color",onClick:i=>n(i,"background"),style:{background:Ea(e.selectedNode.styles?.background)}}),lE.default.createElement(T6e,{...e}),lE.default.createElement(ba,{superstate:e.superstate,name:z.editor.opacity,min:0,max:100,value:t.styles?.opacity,setValue:i=>r("opacity",i),units:["%"]}))};function _6e(){let{fonts:e}=document,t=e.entries(),r=[],n=!1;for(;!n;){let i=t.next();i.done?n=i.done:r.push(i.value[0].family)}return Array.from(new Set(r))}var iu=he(Me());var P6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=o=>{let s=_6e().map(u=>({name:u,value:u}));e.superstate.ui.openMenu(o.target.getBoundingClientRect(),{ui:e.superstate.ui,multi:!1,editable:!1,searchable:!0,saveOptions:(u,l)=>{r("--font-text",`'${l[0]}'`)},value:[t.styles?.["--font-text"]??""],options:s},je(o.view.document))},i=(o,s)=>{o.stopPropagation(),o.preventDefault(),r("textAlign",`'${s}'`)},a=(o,s)=>{let u=c=>{r(s,`'${c}'`)},l=o.target.getBoundingClientRect();Ql(e.superstate,l,je(o.view.document),Ea(e.selectedNode.styles?.[s]),u)};return iu.default.createElement(iu.default.Fragment,null,iu.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:o=>n(o)},iu.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//type")}}),t.styles?.["--font-text"]),iu.default.createElement("div",{className:"mk-divider"}),iu.default.createElement(ba,{superstate:e.superstate,name:z.editor.size,value:t.styles?.["--font-text-size"],setValue:o=>r("--font-text-size",o),units:["px","em"]}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.bold,value:t.styles?.["--font-text-weight"],defaultValue:"'normal'",onValue:"'bold'",icon:"ui//bold",setValue:o=>r("--font-text-weight",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.italic,value:t.styles?.["--font-text-style"],defaultValue:"'normal'",onValue:"'italic'",icon:"ui//italic",setValue:o=>r("--font-text-style",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.underline,value:t.styles?.["--font-text-decoration"],defaultValue:"'none'",onValue:"'underline'",icon:"ui//underline",setValue:o=>r("--font-text-decoration",o)}),iu.default.createElement(I8,{superstate:e.superstate,value:Ea(t.styles?.["--font-text-color"]),setValue:o=>r("--font-text-color",`'${o}'`)}),iu.default.createElement("div",{className:"mk-divider"}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.alignLeft,value:t.styles?.textAlign,defaultValue:"'left'",onValue:"'left'",icon:"ui//align-left",setValue:o=>r("textAlign",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.alignCenter,value:t.styles?.textAlign,defaultValue:"'center'",onValue:"'center'",icon:"ui//align-center",setValue:o=>r("textAlign",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.alignRight,value:t.styles?.textAlign,defaultValue:"'left'",onValue:"'right'",icon:"ui//align-right",setValue:o=>r("textAlign",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.alignJustify,value:t.styles?.textAlign,defaultValue:"'left'",onValue:"'justify'",icon:"ui//align-justify",setValue:o=>r("textAlign",o)}),iu.default.createElement("div",{className:"mk-divider"}),iu.default.createElement(ba,{superstate:e.superstate,name:z.editor.numberOfLines,value:t.styles?.["--line-count"],setValue:o=>r("--line-count",o),units:[""]}))};var I6e=e=>{let{pathState:t}=(0,or.useContext)(qr),{deleteFrame:r,duplicateFrame:n}=e,{spaceInfo:i}=(0,or.useContext)(ar),{addNode:a,ungroupNode:o,updateNode:s,saveNodes:u,frameProperties:l}=(0,or.useContext)(Oi),{selectionMode:c}=(0,or.useContext)(ji),{instance:f}=(0,or.useContext)(vi),d=(0,or.useCallback)((D,N)=>{s(N,{props:{...D}})},[s]),p=(D,N)=>{s(e.node,{styles:{[D]:N}})},[h,m]=(0,or.useState)(0),[g,A]=(0,or.useState)(e.node.props),b=(0,or.useMemo)(()=>Object.keys(e.node.types).map(D=>({type:e.node.types[D],name:D,attrs:e.node.propsAttrs?.[D],schemaId:e.node.schemaId,value:e.node.propsValue?.[D]})),[e.node]);(0,or.useEffect)(()=>{A(e.node.props)},[e.node]);let v=(0,or.useCallback)((D,N)=>{A(C=>({...C,[D]:N})),d({[D]:N},e.node)},[A,d,e.node]),x=[{type:"h1",name:z.commands.h1,icon:"ui//heading-1",class:"mk-t-h1"},{type:"h2",name:z.commands.h2,icon:"ui//heading-2",class:"mk-t-h2"},{type:"h3",name:z.commands.h3,icon:"ui//heading-3",class:"mk-t-h3"},{type:"h4",name:z.commands.h4,icon:"ui//heading-4",class:"mk-t-h4"},{type:"h5",name:z.commands.h5,icon:"ui//heading-5",class:"mk-t-h5"},{type:"h6",name:z.commands.h6,icon:"ui//heading-6",class:"mk-t-h6"},{type:"p",name:z.commands.paragraph,icon:"ui//type",class:"mk-t-p"}],w=D=>{let N=[];x.forEach(_=>{N.push({name:_.name,icon:_.icon,onClick:()=>{p("class",`'${_.class}'`)}})});let C=D.target.getBoundingClientRect();e.superstate.ui.openMenu(C,Xt(e.superstate.ui,N),je(D.view.document))},S=(0,or.useRef)(null),k={superstate:e.superstate,exitMenu:()=>m(0),saveStyleValue:p,savePropValue:v,frameProps:g,selectedNode:e.node,setHoverMenu:m,fields:b,state:e.state},M={...k,pathState:t,frameProperties:l,instance:f};(0,or.useEffect)(()=>{S.current&&S.current.update(M)},[f,b,e.state,e.node,g]);let O=(0,or.useRef)(null);return or.default.createElement("div",{className:"mk-editor-frame-node-selector",style:{pointerEvents:"auto"},ref:O,onClick:D=>{D.preventDefault()}},e.node.type=="new"&&or.default.createElement(or.default.Fragment,null,or.default.createElement("div",{className:"mk-editor-frame-node-button-primary",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:D=>{P8(D.target.getBoundingClientRect(),je(D.view.document),e.superstate,i,N=>u([{...N,id:e.node.id,parentId:e.node.parentId,schemaId:e.node.schemaId,rank:e.node.rank,props:{...N.props,value:e.node.props?.value}}])),D.stopPropagation()}}),or.default.createElement("div",{className:"mk-editor-frame-node-button-primary",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:D=>{let N=e.superstate.spacesIndex.get(i.path);N&&Un(e.superstate,N,"md",e.state?.props?.value,!0).then(C=>u([{...e.node,type:zi.node.type,props:{...e.node.props,value:mr(C)}}])),D.stopPropagation()}})),h==0?or.default.createElement(or.default.Fragment,null,e.node.type=="group"||e.node.type=="content"?or.default.createElement(S6e,{...k}):b.length>0&&or.default.createElement("div",{"aria-label":"Properties",className:"mk-editor-frame-node-button",onClick:D=>{if(S.current){S.current.hide(),S.current=null;return}D.preventDefault(),S.current=e.superstate.ui.openCustomMenu(O.current.getBoundingClientRect(),or.default.createElement(N6e,{...M}),M,je(D.view.document),"bottom")},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//list")}}),e.node.type=="text"&&or.default.createElement(or.default.Fragment,null,or.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:D=>w(D)},or.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(x.find(D=>D.class==Ea(e.node.styles?.class))?.icon??"ui//type")}}),x.find(D=>D.class==Ea(e.node.styles?.class))?.name??"Paragraph"),or.default.createElement("div",{className:"mk-divider"})),e.node.type=="icon"&&or.default.createElement(I8,{superstate:e.superstate,value:Ea(e.node.styles?.color),setValue:D=>p("color",`'${D}'`)}),or.default.createElement("div",{"aria-label":"Layout",className:"mk-editor-frame-node-button",onClick:D=>{D.preventDefault(),D.stopPropagation(),e.editLayout(!0),m(4)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//scaling")}}),or.default.createElement("div",{"aria-label":"Style",className:"mk-editor-frame-node-button",onClick:D=>{D.preventDefault(),D.stopPropagation(),m(5)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//paintbrush")}}),(e.node.type=="flow"||e.node.type=="space")&&or.default.createElement(j6e,{...k}),or.default.createElement("div",{"aria-label":"Text Style",className:"mk-editor-frame-node-button",onClick:D=>{D.preventDefault(),D.stopPropagation(),m(3)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//type")}}),c==1&&or.default.createElement(or.default.Fragment,null,or.default.createElement("div",{className:"mk-divider"}),or.default.createElement(Bo,{superstate:e.superstate,name:"Page Width",setValue:D=>{p("--max-width",D)},defaultValue:"",onValue:mr("100%"),value:e.node.styles?.["--max-width"],icon:"ui//full-width"})),or.default.createElement("div",{className:"mk-divider"}),e.node.type=="group"||e.node.type=="container"?or.default.createElement("div",{"aria-label":"Ungroup",className:"mk-editor-frame-node-button",onClick:()=>o(e.node),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//copy-x")}}):or.default.createElement(or.default.Fragment,null),or.default.createElement("div",{className:"mk-editor-frame-node-button","aria-label":"Delete",onClick:()=>r(),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//trash")}})):or.default.createElement(or.default.Fragment,null,or.default.createElement("div",{className:"mk-editor-frame-node-button",onMouseDown:D=>{D.stopPropagation(),e.editLayout(!1),m(0)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//close")}}),or.default.createElement("div",{className:"mk-editor-frame-node-divider"}),h==3?or.default.createElement(P6e,{...k}):h==4?or.default.createElement(O6e,{...k}):h==5?or.default.createElement(F6e,{...k}):or.default.createElement(or.default.Fragment,null)))};var $h=he(Me());var B6e=e=>{let{spaceInfo:t}=(0,$h.useContext)(ar),{addNode:r,moveUp:n,moveDown:i,setLastCreatedId:a}=(0,$h.useContext)(Oi),{select:o,selection:s}=(0,$h.useContext)(ji),u=s.includes(e.node.id);return $h.default.createElement($h.default.Fragment,null,$h.default.createElement("div",{className:"mk-editor-frame-hover-horizontal",style:{pointerEvents:"auto",opacity:e.visible?"1":"0"}},e.dragRef&&$h.default.createElement("div",{className:"mk-icon-small mk-editor-frame-hover-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//handle")},style:{cursor:"grab"},ref:e.dragRef,onClick:l=>{if(l.stopPropagation(),s.length==1&&u){o(null);return}l.shiftKey?o(e.node.id,!0):o(e.node.id)},...e.listeners??{},...e.attributes??{}}),!cr(e.superstate.ui)&&$h.default.createElement("div",{onClick:l=>{r(ile.node,e.node).then(c=>a(c.id)),l.stopPropagation()},className:"mk-icon-small mk-editor-frame-hover-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")}})))};var Dg=he(Me()),DZ=e=>{let t=(0,Dg.useRef)(null),[r,n]=(0,Dg.useState)(0),i=(s,u,l)=>{let c=s.x-e.containerRect.x,f=c+u.width-l.width,d=c;return f>0&&(s.x-e.containerRect.x-u.width>0?d=l.width-u.width:d=0),d},[a,o]=(0,Dg.useState)(!1);return(0,Dg.useEffect)(()=>{let s=new ResizeObserver(u=>{let l=u[0].target.getBoundingClientRect();o(!0),n(i(e.nodeRect,l,e.containerRect))});return t.current&&s.observe(t.current),()=>{s.disconnect()}},[t]),Dg.default.createElement("div",{className:"mk-editor-frame-node-container",ref:t,style:{visibility:a?"visible":"hidden",pointerEvents:"auto",left:r,bottom:`calc(100% - ${e.nodeRect.y-e.containerRect.y-10}px)`,maxWidth:e.containerRect.width},onClick:s=>{s.preventDefault(),s.stopPropagation()}},e.children)};var R6e=he(to()),Hc=he(Me());var tc=he(Me()),au=e=>{let[t,r]=(0,tc.useState)(null),n=(0,tc.useRef)(e.value),i=(0,tc.useRef)(e.value),[,a]=(0,tc.useState)([0,0]),o=e.step??1,s=(0,tc.useCallback)(d=>{a(p=>{let{clientX:h,clientY:m}=d,[g,A]=p,b=e.reverseX?g-h:h-g,v=e.reverseY?m-A:A-m,x=e.mod??1,w=o*x,S=Math.sqrt((b+v)/2*(b+v)/2)*w;b+v<0&&(S=-S),e.disableX&&(S=v*w),e.disableY&&(S=b*w);let k=n.current+S;return k=e.min!=null?Math.max(k,e.min):k,k=e.max!=null?Math.min(k,e.max):k,i.current=k,e.onDragMove(k,{ctrlKey:d.ctrlKey,metaKey:d.metaKey,altKey:d.altKey,shiftKey:d.shiftKey}),p}),d.stopPropagation()},[t,e.max,e.min,o,e.onDragMove,e.mod]),u=(0,tc.useCallback)(d=>{let p=h=>{h.stopPropagation(),window.removeEventListener("click",p,!0)};window.addEventListener("click",p,!0),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",u),e.onDragEnd(i.current,{ctrlKey:d.ctrlKey,metaKey:d.metaKey,altKey:d.altKey,shiftKey:d.shiftKey}),d.preventDefault(),d.stopPropagation()},[s,e.onDragEnd]),l=(0,tc.useCallback)(d=>{n.current=e.value,a([d.clientX,d.clientY]),document.addEventListener("mousemove",s),document.addEventListener("mouseup",u),d.stopPropagation()},[s,u,e.value]),c=d=>{d.metaKey?r("metaKey"):d.ctrlKey?r("ctrlKey"):d.altKey?r("altKey"):d.shiftKey&&r("shiftKey")},f=()=>{r(null)};return(0,tc.useEffect)(()=>(document.addEventListener("keydown",c),document.addEventListener("keyup",f),()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",u),document.removeEventListener("keydown",c),document.removeEventListener("keyup",f)}),[]),tc.default.createElement("div",{className:"mk-frame-draggable-handle",onMouseDown:l,"data-placeholder":i.current.toString(),style:{cursor:e.cursor,width:"100%",height:"100%",pointerEvents:"auto"}},tc.default.createElement("span",null))};var $6e=e=>{let t=e.styles.borderRadius?e.styles.borderRadius.match(/^(\d+(?:\.\d+)?)\s?([a-zA-Z%]+)$/):null,r=t?parseInt(t[1]):0,n=t&&t[2]?t[2]:"px",[i,a]=Hc.default.useState(Math.max(8,r));(0,Hc.useEffect)(()=>{a(r)},[r]);let o={min:0,max:Math.min(e.clientSize.height/2,e.clientSize.width/2),value:i,onDragMove:u=>{a(u)},onDragEnd:u=>{e.saveStyles({borderRadius:`"${u}${n}"`})}},s=Math.max(8,i);return Hc.default.createElement("div",{style:{position:"absolute",top:0,left:0,width:e.clientSize.width,height:e.clientSize.height,display:"flex",zIndex:200,borderRadius:i,border:"1px solid var(--mk-ui-border-accent)"}},Hc.default.createElement("div",{className:(0,R6e.default)("mk-frame-corners")},Hc.default.createElement("div",{className:"mk-frame-corner",style:{position:"absolute",transform:`translate(${s}px, ${s}px)`,zIndex:"var(--mk-layer-editor-overlay)"}},Hc.default.createElement(au,{...o,cursor:"nwse-resize",reverseY:!0})),Hc.default.createElement("div",{className:"mk-frame-corner",style:{position:"absolute",transform:`translate(${e.clientSize.width-s}px, ${s}px)`,zIndex:"var(--mk-layer-editor-overlay)"}},Hc.default.createElement(au,{...o,cursor:"nesw-resize",reverseX:!0,reverseY:!0})),Hc.default.createElement("div",{className:"mk-frame-corner",style:{position:"absolute",transform:`translate(${s}px, ${e.clientSize.height-s}px)`,zIndex:"var(--mk-layer-editor-overlay)"}},Hc.default.createElement(au,{...o,cursor:"nesw-resize"})),Hc.default.createElement("div",{className:"mk-frame-corner",style:{position:"absolute",transform:`translate(${e.clientSize.width-s}px, ${e.clientSize.height-s}px)`,zIndex:"var(--mk-layer-editor-overlay)"}},Hc.default.createElement(au,{...o,reverseX:!0,cursor:"nwse-resize"}))))};var q6e=he(to());var Og=he(Me());var zet=e=>{let{instance:t,id:r}=(0,Og.useContext)(vi),{spaceInfo:n}=(0,Og.useContext)(ar),{setNodeRef:i}=ql({id:e.id+e.direction,data:{id:e.id+e.direction,direction:e.direction,type:"node",parent:e.parentId,root:r,frame:e.schemaID,space:n.path,node:e.node}}),a=20,o=e.direction=="left"?-a:e.direction=="right"?e.width:0,s=e.direction=="bottom"?e.insertMode!=0?e.height:e.height/2:e.direction=="top"&&e.insertMode!=0?-a:0,u=e.direction=="left"||e.direction=="right"?a:e.width,l=e.direction=="top"||e.direction=="bottom"?e.insertMode!=0?a:e.height/2:e.height,c=e.insertMode!=0?e.direction=="top"?"bottom":e.direction=="bottom"?"top":e.direction:e.direction;return Og.default.createElement("div",{ref:i,className:(0,q6e.default)(e.active?`mk-indicator-${c}`:"","mk-frame-drop-zone"),style:{left:o,top:s,width:u,height:l}})},L6e=e=>{let{frameSchema:t}=(0,Og.useContext)(va),{hoverNode:r}=(0,Og.useContext)(vi),n=[...e.mode==1?["top","bottom","left","right"]:e.mode==2?["top","bottom"]:e.mode==3?["left","right"]:[],...e.insertMode==1?["inside"]:[]];return Og.default.createElement("div",{className:"mk-frame-drop-zone-container",style:{width:e.width,height:e.height}},n.map(i=>Og.default.createElement(zet,{...e,key:i,active:r?.node==e.node&&r?.direction==i,direction:i,mode:e.mode,schemaID:t.id})))};var xa=he(Me());var Uet=(e,t,r,n)=>{let i={},a=0,o=0,s=r?"width":"height",u=r?"height":"width";return e.forEach((l,c,f)=>{c==0?(i[a]={start:c,end:c,maxValue:l[u],items:[{...l,row:a}]},o=l[s]):f[c][s]+n>t[s]?(a++,i[a]={start:c,end:c,maxValue:l[u],items:[{...l,row:a}]}):f[c][s]+n+o>t[s]?(a++,i[a]={start:c,end:c,maxValue:l[u],items:[{...l,row:a}]},o=l[s]):i[a]?(i[a]={start:i[a].start,end:c,maxValue:Math.max(i[a].maxValue,l[u]),items:[...i[a].items,{...l,row:a}]},o+=l[s]+n):console.log("Warning: Flexbox found orphan row")}),i},z6e=e=>{let t=u=>{let l=u?u.match(/^(\d+(?:\.\d+)?)\s?([a-zA-Z%]+)$/):null;return l?parseInt(l[1]):0},[r,n]=xa.default.useState({row:t(e.styles.rowGap),column:t(e.styles.columnGap)});(0,xa.useEffect)(()=>{n({row:t(e.styles.rowGap),column:t(e.styles.columnGap)})},[e.styles]);let i={value:r[e.direction],onDragMove:u=>{n({...r,[e.direction=="column"?"row":"column"]:u})},onDragEnd:u=>{e.saveStyles(e.direction=="column"?{rowGap:`"${u}px"`}:{columnGap:`"${u}px"`})}},a={value:r[e.direction=="column"?"row":"column"],onDragMove:u=>{n({...r,[e.direction]:u})},onDragEnd:u=>{e.saveStyles(e.direction=="column"?{columnGap:`"${u}px"`}:{rowGap:`"${u}px"`})}},o=(0,xa.useMemo)(()=>Uet(e.childSizes,{width:e.clientSize.width-e.clientSize.paddingLeft-e.clientSize.paddingRight,height:e.clientSize.height-e.clientSize.paddingTop-e.clientSize.paddingBottom},e.direction=="row",r[e.direction=="column"?"row":"column"]),[e.childSizes,e.clientSize,e.direction,r]),s=(0,xa.useMemo)(()=>{let u=[];return Object.keys(o).forEach(l=>{u.push(...o[l].items)}),u},[o]);return xa.default.createElement("div",{className:`mk-frame-gaps ${aE(e.styles)}`,style:{position:"absolute",top:0,left:0,width:e.clientSize.width,height:e.clientSize.height,padding:e.clientSize.paddingTop,paddingLeft:e.clientSize.paddingLeft,paddingBottom:e.clientSize.paddingBottom,paddingRight:e.clientSize.paddingRight,flexWrap:e.styles.flexWrap}},e.direction==="row"?s.map((u,l,c)=>xa.default.createElement(xa.default.Fragment,null,xa.default.createElement("div",{style:{width:u.width,height:u.height}}),l==c.length-1?xa.default.createElement(xa.default.Fragment,null):o[u.row].end==l?xa.default.createElement("div",{key:l,className:"mk-frame-gap-handle-h",style:{width:"100%",height:Math.max(8,Math.abs(r.row)),zIndex:"var(--mk-layer-editor-overlay)"}},xa.default.createElement(au,{...a,cursor:"col-resize",disableX:!0,reverseY:!0})):xa.default.createElement("div",{key:l,className:"mk-frame-gap-handle-v",style:{width:Math.max(8,Math.abs(r.column)),height:o[u.row].maxValue,zIndex:"var(--mk-layer-editor-overlay)"}},xa.default.createElement(au,{...i,cursor:"col-resize",disableY:!0})))):s.map((u,l,c)=>xa.default.createElement(xa.default.Fragment,null,xa.default.createElement("div",{style:{width:u.width,height:u.height}}),l==c.length-1?xa.default.createElement(xa.default.Fragment,null):o[u.row].end==l?xa.default.createElement("div",{key:l,className:"mk-frame-gap-handle-v",style:{height:"100%",width:Math.max(8,Math.abs(r.column)),zIndex:"var(--mk-layer-editor-overlay)"}},xa.default.createElement(au,{...a,cursor:"col-resize",disableX:!0,reverseY:!0})):xa.default.createElement("div",{key:l,className:"mk-frame-gap-handle-h",style:{height:Math.max(8,Math.abs(r.row)),width:o[u.row].maxValue,zIndex:"var(--mk-layer-editor-overlay)"}},xa.default.createElement(au,{...i,cursor:"row-resize",disableX:!0,reverseY:!0})))))};var U6e=he(to()),vl=he(Me());var W6e=e=>{let t=["padding","paddingTop","paddingBottom","paddingLeft","paddingRight"],[r,n]=vl.default.useState({padding:0,paddingTop:null,paddingBottom:null,paddingLeft:null,paddingRight:null}),i="px";(0,vl.useEffect)(()=>{let f=d=>{if(!e.styles[d])return null;let p=e.styles[d]?e.styles[d].match(/^(\d+(?:\.\d+)?)\s?([a-zA-Z%]+)$/):null;return Math.max(p?parseInt(p[1]):0,8)};n(d=>t.reduce((p,h)=>({...p,[h]:f(h)}),d))},[e.styles]);let[a,o]=vl.default.useState(!1),s={min:0,mod:2},u=f=>Math.max(5,r[f]??r.padding),l=(f,d,p)=>{n(h=>p.shiftKey?{padding:d,paddingBottom:null,paddingTop:null,paddingLeft:null,paddingRight:null}:{...h,[f]:d})},c=(f,d,p)=>{e.saveStyles(p.shiftKey?{padding:`'${d}${i}'`,paddingBottom:"",paddingTop:"",paddingLeft:"",paddingRight:""}:{[f]:`'${d}${i}'`})};return(0,vl.useEffect)(()=>{let f=p=>{p.key==="Shift"&&o(!0)},d=p=>{p.key==="Shift"&&o(!1)};return window.addEventListener("keydown",f),window.addEventListener("keyup",d),()=>{window.removeEventListener("keydown",f),window.removeEventListener("keyup",d)}},[]),vl.default.createElement("div",{style:{position:"absolute",top:0,left:0,width:e.clientSize.width,height:e.clientSize.height,display:"flex",zIndex:200,border:"1px solid var(--mk-ui-color-border-accent)"}},vl.default.createElement("div",{className:(0,U6e.default)("mk-frame-paddings",a&&"mk-modifier-shift")},vl.default.createElement("div",{className:"mk-frame-padding-handle-h",style:{position:"absolute",transform:`translate(${0}px, ${0}px)`,height:u("paddingTop"),zIndex:"var(--mk-layer-editor-overlay)"}},vl.default.createElement(au,{...s,value:r.paddingTop??r.padding,cursor:"s-resize",max:e.clientSize.height,onDragMove:(f,d)=>{l("paddingTop",f,d)},onDragEnd:(f,d)=>{c("paddingTop",f,d)},reverseY:!0,disableX:!0})),vl.default.createElement("div",{className:"mk-frame-padding-handle-v",style:{position:"absolute",transform:`translate(${e.clientSize.width-u("paddingRight")}px, ${0}px)`,width:u("paddingRight"),zIndex:"var(--mk-layer-editor-overlay)"}},vl.default.createElement(au,{...s,value:r.paddingRight??r.padding,cursor:"w-resize",onDragMove:(f,d)=>{l("paddingRight",f,d)},max:e.clientSize.width,onDragEnd:(f,d)=>{c("paddingRight",f,d)},reverseX:!0,reverseY:!0,disableY:!0})),vl.default.createElement("div",{className:"mk-frame-padding-handle-v",style:{position:"absolute",transform:`translate(${0}px, ${0}px)`,width:u("paddingLeft"),zIndex:"var(--mk-layer-editor-overlay)"}},vl.default.createElement(au,{...s,value:r.paddingLeft??r.padding,cursor:"e-resize",max:e.clientSize.width,onDragMove:(f,d)=>{l("paddingLeft",f,d)},onDragEnd:(f,d)=>{c("paddingLeft",f,d)},disableY:!0})),vl.default.createElement("div",{className:"mk-frame-padding-handle-h",style:{position:"absolute",transform:`translate(${0}px, ${e.clientSize.height-u("paddingBottom")}px)`,height:u("paddingBottom"),zIndex:"var(--mk-layer-editor-overlay)"}},vl.default.createElement(au,{...s,value:r.paddingBottom??r.padding,cursor:"n-resize",max:e.clientSize.height,onDragMove:(f,d)=>{l("paddingBottom",f,d)},onDragEnd:(f,d)=>{c("paddingBottom",f,d)},reverseX:!0,disableX:!0}))))};var J6e=he(to());var Eb=he(Me()),X6e=he(Ws());var $8=he(Me()),Wet=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a])},e(t,r)};return function(t,r){e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),ts=function(){return ts=Object.assign||function(e){for(var t,r=1,n=arguments.length;r"u"?void 0:Number(n),maxHeight:typeof i>"u"?void 0:Number(i),minWidth:typeof a>"u"?void 0:Number(a),minHeight:typeof o>"u"?void 0:Number(o)}},Zet=["as","style","className","grid","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],Z6e="__resizable_base__",K6e=function(e){Vet(t,e);function t(r){var n=e.call(this,r)||this;return n.ratio=1,n.resizable=null,n.parentLeft=0,n.parentTop=0,n.resizableLeft=0,n.resizableRight=0,n.resizableTop=0,n.resizableBottom=0,n.targetLeft=0,n.targetTop=0,n.appendBase=function(){if(!n.resizable||!n.window)return null;var i=n.parentNode;if(!i)return null;var a=n.window.document.createElement("div");return a.style.width="100%",a.style.height="100%",a.style.position="absolute",a.style.transform="scale(0, 0)",a.style.left="0",a.style.flex="0 0 100%",a.classList?a.classList.add(Z6e):a.className+=Z6e,i.appendChild(a),a},n.removeBase=function(i){var a=n.parentNode;!a||a.removeChild(i)},n.ref=function(i){i&&(n.resizable=i)},n.state={isResizing:!1,width:typeof(n.propsSize&&n.propsSize.width)>"u"?"auto":n.propsSize&&n.propsSize.width,height:typeof(n.propsSize&&n.propsSize.height)>"u"?"auto":n.propsSize&&n.propsSize.height,direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},n.onResizeStart=n.onResizeStart.bind(n),n.onMouseMove=n.onMouseMove.bind(n),n.onMouseUp=n.onMouseUp.bind(n),n}return Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return!this.resizable||!this.resizable.ownerDocument?null:this.resizable.ownerDocument.defaultView},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||Get},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var r=0,n=0;if(this.resizable&&this.window){var i=this.resizable.offsetWidth,a=this.resizable.offsetHeight,o=this.resizable.style.position;o!=="relative"&&(this.resizable.style.position="relative"),r=this.resizable.style.width!=="auto"?this.resizable.offsetWidth:i,n=this.resizable.style.height!=="auto"?this.resizable.offsetHeight:a,this.resizable.style.position=o}return{width:r,height:n}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeStyle",{get:function(){var r=this,n=this.props.size,i=function(s){if(typeof r.state[s]>"u"||r.state[s]==="auto")return"auto";if(r.propsSize&&r.propsSize[s]&&r.propsSize[s].toString().endsWith("%")){if(r.state[s].toString().endsWith("%"))return r.state[s].toString();var u=r.getParentSize(),l=Number(r.state[s].toString().replace("px","")),c=l/u[s]*100;return c+"%"}return OZ(r.state[s])},a=n&&typeof n.width<"u"&&!this.state.isResizing?OZ(n.width):i("width"),o=n&&typeof n.height<"u"&&!this.state.isResizing?OZ(n.height):i("height");return{width:a,height:o}},enumerable:!1,configurable:!0}),t.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var r=this.appendBase();if(!r)return{width:0,height:0};var n=!1,i=this.parentNode.style.flexWrap;i!=="wrap"&&(n=!0,this.parentNode.style.flexWrap="wrap"),r.style.position="relative",r.style.minWidth="100%",r.style.minHeight="100%";var a={width:r.offsetWidth,height:r.offsetHeight};return n&&(this.parentNode.style.flexWrap=i),this.removeBase(r),a},t.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},t.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},t.prototype.componentDidMount=function(){if(!(!this.resizable||!this.window)){var r=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:r.flexBasis!=="auto"?r.flexBasis:void 0})}},t.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},t.prototype.createSizeForCssProperty=function(r,n){var i=this.propsSize&&this.propsSize[n];return this.state[n]==="auto"&&this.state.original[n]===r&&(typeof i>"u"||i==="auto")?"auto":r},t.prototype.calculateNewMaxFromBoundary=function(r,n){var i=this.props.boundsByDirection,a=this.state.direction,o=i&&cE("left",a),s=i&&cE("top",a),u,l;if(this.props.bounds==="parent"){var c=this.parentNode;c&&(u=o?this.resizableRight-this.parentLeft:c.offsetWidth+(this.parentLeft-this.resizableLeft),l=s?this.resizableBottom-this.parentTop:c.offsetHeight+(this.parentTop-this.resizableTop))}else this.props.bounds==="window"?this.window&&(u=o?this.resizableRight:this.window.innerWidth-this.resizableLeft,l=s?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(u=o?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),l=s?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return u&&Number.isFinite(u)&&(r=r&&r"u"?10:a.width,f=typeof i.width>"u"||i.width<0?r:i.width,d=typeof a.height>"u"?10:a.height,p=typeof i.height>"u"||i.height<0?n:i.height,h=u||0,m=l||0;if(s){var g=(d-h)*this.ratio+m,A=(p-h)*this.ratio+m,b=(c-m)/this.ratio+h,v=(f-m)/this.ratio+h,x=Math.max(c,g),w=Math.min(f,A),S=Math.max(d,b),k=Math.min(p,v);r=q8(r,x,w),n=q8(n,S,k)}else r=q8(r,c,f),n=q8(n,d,p);return{newWidth:r,newHeight:n}},t.prototype.setBoundingClientRect=function(){if(this.props.bounds==="parent"){var r=this.parentNode;if(r){var n=r.getBoundingClientRect();this.parentLeft=n.left,this.parentTop=n.top}}if(this.props.bounds&&typeof this.props.bounds!="string"){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left,this.targetTop=i.top}if(this.resizable){var a=this.resizable.getBoundingClientRect(),o=a.left,s=a.top,u=a.right,l=a.bottom;this.resizableLeft=o,this.resizableRight=u,this.resizableTop=s,this.resizableBottom=l}},t.prototype.onResizeStart=function(r,n){if(!(!this.resizable||!this.window)){var i=0,a=0;if(r.nativeEvent&&Qet(r.nativeEvent)?(i=r.nativeEvent.clientX,a=r.nativeEvent.clientY):r.nativeEvent&&L8(r.nativeEvent)&&(i=r.nativeEvent.touches[0].clientX,a=r.nativeEvent.touches[0].clientY),this.props.onResizeStart&&this.resizable){var o=this.props.onResizeStart(r,n,this.resizable);if(o===!1)return}this.props.size&&(typeof this.props.size.height<"u"&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),typeof this.props.size.width<"u"&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio=typeof this.props.lockAspectRatio=="number"?this.props.lockAspectRatio:this.size.width/this.size.height;var s,u=this.window.getComputedStyle(this.resizable);if(u.flexBasis!=="auto"){var l=this.parentNode;if(l){var c=this.window.getComputedStyle(l).flexDirection;this.flexDir=c.startsWith("row")?"row":"column",s=u.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var f={original:{x:i,y:a,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:qh(qh({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(r.target).cursor||"auto"}),direction:n,flexBasis:s};this.setState(f)}},t.prototype.onMouseMove=function(r){var n=this;if(!(!this.state.isResizing||!this.resizable||!this.window)){if(this.window.TouchEvent&&L8(r))try{r.preventDefault(),r.stopPropagation()}catch{}var i=this.props,a=i.maxWidth,o=i.maxHeight,s=i.minWidth,u=i.minHeight,l=L8(r)?r.touches[0].clientX:r.clientX,c=L8(r)?r.touches[0].clientY:r.clientY,f=this.state,d=f.direction,p=f.original,h=f.width,m=f.height,g=this.getParentSize(),A=Yet(g,this.window.innerWidth,this.window.innerHeight,a,o,s,u);a=A.maxWidth,o=A.maxHeight,s=A.minWidth,u=A.minHeight;var b=this.calculateNewSizeFromDirection(l,c),v=b.newHeight,x=b.newWidth,w=this.calculateNewMaxFromBoundary(a,o);this.props.snap&&this.props.snap.x&&(x=Y6e(x,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(v=Y6e(v,this.props.snap.y,this.props.snapGap));var S=this.calculateNewSizeFromAspectRatio(x,v,{width:w.maxWidth,height:w.maxHeight},{width:s,height:u});if(x=S.newWidth,v=S.newHeight,this.props.grid){var k=Q6e(x,this.props.grid[0]),M=Q6e(v,this.props.grid[1]),O=this.props.snapGap||0;x=O===0||Math.abs(k-x)<=O?k:x,v=O===0||Math.abs(M-v)<=O?M:v}var D={width:x-p.width,height:v-p.height};if(h&&typeof h=="string"){if(h.endsWith("%")){var N=x/g.width*100;x=N+"%"}else if(h.endsWith("vw")){var C=x/this.window.innerWidth*100;x=C+"vw"}else if(h.endsWith("vh")){var _=x/this.window.innerHeight*100;x=_+"vh"}}if(m&&typeof m=="string"){if(m.endsWith("%")){var N=v/g.height*100;v=N+"%"}else if(m.endsWith("vw")){var C=v/this.window.innerWidth*100;v=C+"vw"}else if(m.endsWith("vh")){var _=v/this.window.innerHeight*100;v=_+"vh"}}var I={width:this.createSizeForCssProperty(x,"width"),height:this.createSizeForCssProperty(v,"height")};this.flexDir==="row"?I.flexBasis=I.width:this.flexDir==="column"&&(I.flexBasis=I.height),(0,X6e.flushSync)(function(){n.setState(I)}),this.props.onResize&&this.props.onResize(r,d,this.resizable,D)}},t.prototype.onMouseUp=function(r){var n=this.state,i=n.isResizing,a=n.direction,o=n.original;if(!(!i||!this.resizable)){var s={width:this.size.width-o.width,height:this.size.height-o.height};this.props.onResizeStop&&this.props.onResizeStop(r,a,this.resizable,s),this.props.size&&this.setState(this.props.size),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:qh(qh({},this.state.backgroundStyle),{cursor:"auto"})})}},t.prototype.updateSize=function(r){this.setState({width:r.width,height:r.height})},t.prototype.renderResizer=function(){var r=this,n=this.props,i=n.enable,a=n.handleStyles,o=n.handleClasses,s=n.handleWrapperStyle,u=n.handleWrapperClass,l=n.handleComponent;if(!i)return null;var c=Object.keys(i).map(function(f){return i[f]!==!1?Eb.createElement(G6e,{key:f,direction:f,onResizeStart:r.onResizeStart,replaceStyles:a&&a[f],className:o&&o[f]},l&&l[f]?l[f]:null):null});return Eb.createElement("div",{className:u,style:s},c)},t.prototype.render=function(){var r=this,n=Object.keys(this.props).reduce(function(o,s){return Zet.indexOf(s)!==-1||(o[s]=r.props[s]),o},{}),i=qh(qh(qh({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(i.flexBasis=this.state.flexBasis);var a=this.props.as||"div";return Eb.createElement(a,qh({ref:this.ref,style:i,className:this.props.className},n),this.state.isResizing&&Eb.createElement("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer())},t.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},t}(Eb.PureComponent);var ou=he(Me());var jZ=e=>{let t=o=>o?o=="auto"?"Fit":o=="100%"?"Fill":o:null,[r,n]=ou.default.useState(null),[i,a]=ou.default.useState({width:e.resizeMode!=2?e.size.width:e.size.minWidth,height:e.size.height});return ou.default.useEffect(()=>{a({width:e.resizeMode!=2?e.size.width:e.size.minWidth,height:e.size.height})},[e.size,e.resizeMode]),(0,ou.useEffect)(()=>{let o=s=>{n({shiftKey:s.shiftKey})};return e.superstate.ui.inputManager.on("keydown",o),e.superstate.ui.inputManager.on("keyup",o),()=>{e.superstate.ui.inputManager.off("keydown",o),e.superstate.ui.inputManager.off("keyup",o)}},[n]),ou.default.createElement("div",{style:{position:"absolute",top:0,left:0,width:e.clientSize.width,height:e.clientSize.height}},ou.default.createElement(K6e,{lockAspectRatio:r?.shiftKey,className:(0,J6e.default)(e.resizeMode==2?"mk-frame-column":"mk-frame-bounds"),enable:e.resizeMode==2?{right:!0}:{right:!0,bottom:!0,bottomRight:!0},onResize:(o,s,u,l)=>{a({width:u.clientWidth,height:u.clientHeight})},onResizeStop:(o,s,u,l)=>{let c=f=>{f.stopPropagation(),window.removeEventListener("click",c,!0)};window.addEventListener("click",c,!0),e.resizeMode==2?e.resize({minWidth:`'${u.clientWidth}px'`}):s=="bottom"?e.resize({height:`'${u.clientHeight}px'`}):s=="right"?e.resize({width:`'${u.clientWidth}px'`}):e.resize({width:`'${u.clientWidth}px'`,height:`'${u.clientHeight}px'`}),o.stopPropagation()},onResizeStart:o=>{o.stopPropagation()},handleClasses:e.resizeMode==2?{right:"mk-frame-column-resize-handle"}:e.resizeMode==1?{bottomRight:"mk-frame-resize-handle"}:{},handleWrapperStyle:{pointerEvents:"auto"},size:{width:i.width&&i.width!="auto"?i.width:"100%",height:i.height&&i.height!="auto"?i.height:"100%"},...e.listeners}),e.clientSize?.width>50&&e.resizeMode==1&&ou.default.createElement("div",{className:"mk-frame-resize-label-width"},ou.default.createElement("div",null,ou.default.createElement("span",null,t(i.width)??z.editor.fit),i.width&&i.width!="auto"?ou.default.createElement("div",{onClick:o=>{e.resize({width:mr("auto")}),o.stopPropagation()},"aria-label":z.editor.scaleToFit,style:{display:"flex"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//fold-horizontal")}}):ou.default.createElement("div",{onClick:o=>{e.resize({width:mr("100%")}),o.stopPropagation()},"aria-label":z.editor.scaleToFill,style:{display:"flex"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//unfold-horizontal")}}))),e.clientSize?.height>50&&e.resizeMode==1&&ou.default.createElement("div",{className:"mk-frame-resize-label-height"},ou.default.createElement("div",null,ou.default.createElement("span",null,t(i.height)??z.editor.fit),i.height&&i.height!="auto"?ou.default.createElement("div",{onClick:o=>{e.resize({height:mr("auto")}),o.stopPropagation()},"aria-label":z.editor.scaleToFit,style:{display:"flex"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//fold-vertical")}}):ou.default.createElement("div",{onClick:o=>{e.resize({height:mr("100%")}),o.stopPropagation()},"aria-label":z.editor.scaleToFill,style:{display:"flex"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//unfold-vertical")}}))))};var np=he(Me());var U8=e=>{let{selectionMode:t,selected:r,selection:n}=(0,np.useContext)(ji),{updateNode:i,nodes:a}=(0,np.useContext)(Oi),o=d=>{if(d!=e.state.props?.value)if(e.treeNode.editorProps?.linkedNode){let p=a.find(h=>h.id==e.treeNode.editorProps.linkedNode.node);i(p,{props:{...p.props,[e.treeNode.editorProps.linkedNode.prop]:mr(d)}})}else i(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(d)}})},s=n?.includes(e.treeNode.node.id),u=(0,np.useMemo)(()=>t==0?!1:t==1||t==3&&s?!0:e.treeNode.isRef?!!(e.treeNode.editorProps.linkedNode&&r):!0,[e.treeNode,t,r,s]),l=d=>{e.superstate.ui.openPalette(np.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:p=>o(p)}),je(d.view.document))},[c,f]=e.state.props?.value?sg(e.state.props?.value):[null,null];return e.state&&(e.state.props?.value?.length>0?c=="image"?np.default.createElement("img",{className:"mk-frame-icon",src:e.superstate.ui.getUIPath(e.superstate.imagesCache.get(f))}):np.default.createElement("div",{className:"mk-frame-icon",style:{},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(e.state.props?.value)}}):u?np.default.createElement("div",{onClick:d=>l(d),"aria-label":"Select Sticker",className:"mk-node-icon-placeholder",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//smile")}}):np.default.createElement(np.default.Fragment,null))};var Lf=he(Me());var W8=e=>{let t=e.state.props.value,r=(0,Lf.useMemo)(()=>e.superstate.ui.getUIPath(t,!0),[t]),{nodes:n,updateNode:i}=(0,Lf.useContext)(Oi),{linkedProps:a}=(0,Lf.useContext)(vi),{selectionMode:o,selected:s,selection:u}=(0,Lf.useContext)(ji),l=u?.includes(e.treeNode.node.id),c=p=>{!zl(e.treeNode.node.props.value)&&!a.some(h=>e.treeNode.editorProps.linkedNode?.node==e.treeNode.node.schemaId&&e.treeNode.editorProps.linkedNode?.prop==h)||e.superstate.ui.openPalette(Lf.default.createElement(Xl,{superstate:e.superstate,selectedPath:h=>f(h)}),je(p.view.document))},f=p=>{if(p!=e.state.props?.value)if(e.treeNode.editorProps?.linkedNode){let h=n.find(m=>m.id==e.treeNode.editorProps.linkedNode.node);i(h,{props:{...h.props,[e.treeNode.editorProps.linkedNode.prop]:mr(p)}})}else i(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(p)}})},d=(0,Lf.useMemo)(()=>o==0?!1:o==1||o==3&&l?!0:e.treeNode.isRef?!!(e.treeNode.editorProps.linkedNode&&s):!0,[e.treeNode,o,s,l]);return e.state?.props.value?.length>0?Lf.default.createElement("img",{className:"mk-node-image",width:e.state?.styles.width,height:e.state?.styles.height,style:{borderRadius:e.state?.styles.borderRadius,maxHeight:e.state?.styles.maxHeight},src:r}):d?Lf.default.createElement("div",{className:"mk-node-image-placeholder",dangerouslySetInnerHTML:{__html:e.superstate.ui.getPlaceholderImage("image-select")},style:{borderRadius:e.state?.styles.borderRadius,maxHeight:e.state?.styles.maxHeight},onClick:p=>c(p)}):Lf.default.createElement(Lf.default.Fragment,null)};var jg=he(Me()),H8=e=>{let{selectionMode:t}=(0,jg.useContext)(ji),{saveState:r,instance:n}=(0,jg.useContext)(vi),[i,a]=(0,jg.useState)(""),o=e.state,s=e.state.styles?.as;return(0,jg.useEffect)(()=>{let u=eh(e.state?.props?.value);if(u){let l=u.node=="$root"?n.exec.id:u.node;a(n.state?.[l]?.props?.[u.prop])}},[e.state.props]),jg.default.createElement("input",{className:"mk-node-input",type:s,value:s=="checkbox"?null:i,checked:i=="true",onKeyDown:u=>{if(u.stopPropagation(),u.key=="Enter"){let l=s=="text"?u.currentTarget.value:s=="checkbox"?(!u.currentTarget.checked).toString():u.currentTarget.value;a(""),typeof o.actions?.onEnter=="function"&&o.actions?.onEnter(u,l,n.state,c=>r(c,n),e.superstate.api)}},onChange:u=>{let l=s=="text"?u.target.value:s=="checkbox"?(!u.target.checked).toString():u.target.value;a(l),typeof o.actions?.onChange=="function"&&o.actions?.onChange(u,l,n.state,c=>r(c,n),e.superstate.api)},placeholder:o.styles.placeholder,style:{...o?.styles}})};var yl=he(Me());var V8=e=>{let t=yl.default.createRef(),{spaceState:r}=(0,yl.useContext)(ar),{updateNode:n,nodes:i,deleteNode:a,addNode:o,saveNodes:s,lastCreatedId:u,setLastCreatedId:l}=(0,yl.useContext)(Oi),{selection:c,select:f}=(0,yl.useContext)(ji),[d,p]=(0,yl.useState)("label"),{instance:h}=(0,yl.useContext)(vi),m=[...e.superstate.allSpaces(!0)].filter(k=>k.type!="default").map(k=>({name:k.name,value:k.path,icon:e.superstate.pathsIndex.get(k.path)?.label?.sticker,description:k.type=="tag"?k.name:k.type=="folder"?k.path:k.name})),g=[...e.superstate.pathsIndex.values()].filter(k=>!k.hidden).filter(k=>k.type=="space"||k.subtype=="md").map(k=>({name:k.label.name,value:k.path,description:k.path,section:"flow",icon:k.label?.sticker})),A={minMatchCharLength:1,threshold:0,keys:["name","value"]},[b,v]=(0,yl.useState)(""),x=(0,yl.useMemo)(()=>{let k=[],M={name:z.frames.label.label,description:b,icon:"ui//baseline",section:"label",value:""};k.push(M);let O={name:z.frames.note.label,description:b,icon:"ui//file-text",value:"",section:"flow"};k.push(O);let D=[{name:z.frames.table.label,description:z.frames.table.description,icon:"ui//table",section:"list",value:""},...[xf,MS,ja,Wl,un].map(_=>({name:_.node.name,value:_,icon:_.def?.icon,section:"base",description:_.def?.description})),...[xh,TS,FS,_S,PS,IS,NS].map(_=>({name:_.node.name,value:_,icon:_.def?.icon,section:"kit",description:_.def?.description}))],N=new zc(D,A),C=b.length==0?D:N.search(b).map(_=>_.item).slice(0,10);if(C.length>0&&k.push(ZG("Kit")),k.push(...C),b.length>0){let _=new zc([...g],A),I=b.length==0?[]:_.search(b).map(L=>L.item).slice(0,10);I.length>0&&k.push(ZG("Paths")),k.push(...I)}return k},[b,d]),w=k=>{if(e.treeNode||S(),k.section=="kit"||k.section=="base")if(e.treeNode){let M=nl("$root",e.treeNode.node.schemaId,k.value.node,e.treeNode.node.schemaId);M=nl(M.id,e.treeNode.node.id,M,e.treeNode.node.schemaId),s([{...M,type:k.section=="base"?M.type:"frame",styles:k.value.node.styles,ref:k.section=="base"?"":"spaces://$kit/#*"+k.value.def.id,parentId:e.treeNode.node.parentId,schemaId:e.treeNode.node.schemaId,id:e.treeNode.node.id,rank:e.treeNode.node.rank}]).then(O=>f(e.treeNode.id))}else o(k.section=="base"?k.value.node:{...k.value.node,type:"frame",styles:k.value.node.styles,ref:"spaces://$kit/#*"+k.value.def.id},h.exec.node,!0).then(M=>f(M.id));else k.section=="label"?e.treeNode?s([{...e.treeNode.node,type:"text",name:Yr.node.name,props:{...e.treeNode.node.props,value:mr(b)},styles:Yr.node.styles}]).then(M=>f(e.treeNode.id)):o({...Yr.node,props:{value:mr(b)}},h.exec.node,!0).then(M=>f(M.id)):k.section=="flow"?k.value.length>0?e.treeNode?s([{...e.treeNode.node,type:"flow",name:zi.node.name,props:{...e.treeNode.node.props,value:mr(k.value)},styles:zi.node.styles}]):o({...zi.node,props:{value:mr(k.value)}},h.exec.node,!0):Un(e.superstate,r,"md",b,!0).then(M=>{e.treeNode?s([{...e.treeNode.node,name:zi.node.name,type:"flow",props:{value:mr(M)},styles:{...zi.node.styles}}]):o({...zi.node,props:{value:mr(M)}},h.exec.node,!0)}):k.section=="list"&&uE(e.superstate,r.path).then(M=>{e.treeNode?s([{...e.treeNode.node,name:xf.node.name,type:"space",props:{value:mr(`${r.path}/#*${M}`)},styles:{...xf.node.styles}}]):o({...Yr.node,name:xf.node.name,type:"space",props:{value:mr(`${r.path}/#^${M}`)}},h.exec.node,!0)})},S=()=>{v(""),t.current.blur(),t.current.innerHTML=""};return(0,yl.useEffect)(()=>{t.current&&u&&u==e.treeNode?.node.id&&(t.current.focus(),l(null))},[t,c,e.treeNode]),yl.default.createElement("div",{className:"mk-node-new"},yl.default.createElement(VD,{superstate:e.superstate,placeholder:z.hintText.newFrame,suggestions:x,onChange:k=>v(k),onSelect:k=>{w(k)},onFocus:()=>{f(null)},ref:t,onDelete:()=>e.treeNode?a(e.treeNode?.node):S(),onSelectSection:k=>p(k)}))};var zh=he(Me());var eCe=he(Me());function MZ(e){(0,eCe.useEffect)(e,[])}var QD=he(Me());function kb(e,t,r=window){let n=(0,QD.useRef)(t);(0,QD.useEffect)(()=>{n.current=t},[t]),(0,QD.useEffect)(()=>{if(r==null)return;let i=a=>n.current(a);return r.addEventListener(e,i),()=>r.removeEventListener(e,i)},[e,r])}var Lh=he(Me());function NZ(e,t){let r=(0,Lh.useRef)(e),n=(0,Lh.useRef)(null);(0,Lh.useEffect)(()=>{r.current=e},[e]);let i=(0,Lh.useCallback)(()=>{n.current=setTimeout(()=>r.current(),t)},[t]),a=(0,Lh.useCallback)(()=>{n.current&&clearTimeout(n.current)},[]);return(0,Lh.useEffect)(()=>(i(),a),[t,i,a]),{reset:(0,Lh.useCallback)(()=>{a(),i()},[a,i]),clear:a}}function YD(e,t,{delay:r=400}={}){let{reset:n,clear:i}=NZ(t,r);MZ(i),kb("mousedown",n,e.current),kb("touchstart",n,e.current),kb("mouseup",i,e.current),kb("mouseleave",i,e.current),kb("touchend",i,e.current)}var G8=e=>{let{selectionMode:t,selection:r,selectable:n,selected:i,select:a}=(0,zh.useContext)(ji),o=(0,zh.useRef)(null),{updateNode:s,nodes:u,deleteNode:l}=(0,zh.useContext)(Oi),c=w=>{if(w!=e.state.props?.value)if(e.treeNode.editorProps?.linkedNode){let S=u.find(k=>k.id==e.treeNode.editorProps.linkedNode.node);s(S,{props:{...S.props,[e.treeNode.editorProps.linkedNode.prop]:mr(w)}})}else s(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(w)}})},f=w=>{let S=w.target.innerHTML;c(S)},d=w=>{w.stopPropagation()},p=w=>{w.stopPropagation()},h=w=>{if(w.stopPropagation(),(w.key=="Delete"||w.key=="Backspace")&&w.target.innerHTML==""&&l(e.treeNode.node),w.key=="a"&&w.metaKey){w.preventDefault();let S=window.getSelection(),k=document.createRange();k.selectNodeContents(w.target),S.removeAllRanges(),S.addRange(k)}w.key=="Enter"&&(w.target.blur(),w.preventDefault()),w.key=="Escape"&&(w.target.blur(),w.preventDefault())},m=w=>{x&&w.stopPropagation()},g=w=>{x&&w.stopPropagation(),t==3&&!e.treeNode.isRef&&a(e.treeNode.id)};YD(o,()=>{if(x){a(e.treeNode.node.id,!1);return}});let b=r.includes(e.treeNode.id),{linkedProps:v}=(0,zh.useContext)(vi),x=(0,zh.useMemo)(()=>t==0?!1:e.treeNode.isRef?!!(e.treeNode.editorProps.linkedNode&&i):v.some(w=>e.treeNode.editorProps.linkedNode?.node==e.treeNode.node.schemaId&&e.treeNode.editorProps.linkedNode?.prop==w)?!0:zl(e.treeNode.node.props.value)?!!(t==1||t==3&&b):!1,[e.treeNode,t,i,b,v]);return e.state&&zh.default.createElement("div",{className:"mk-frame-text","data-placeholder":x||n?z.labels.textPlaceholder:"",dangerouslySetInnerHTML:{__html:e.state.props?.value},onClick:m,onMouseDown:g,onBlur:f,onDrop:w=>w.preventDefault(),onKeyDown:h,onKeyPress:d,onKeyUp:p,ref:o,contentEditable:x})};var FZ={position:"relative"},Xet=(0,zt.memo)(function(t){let r={superstate:t.superstate,treeNode:t.treeNode,state:t.state},{treeNode:n}=t,{pathState:i}=(0,zt.useContext)(qr),{instance:a}=(0,zt.useContext)(vi);return zt.default.createElement(zt.default.Fragment,null,n.node.type=="new"?zt.default.createElement(V8,{...r}):n.node.type=="input"?zt.default.createElement(H8,{...r}):n.node.type=="text"?zt.default.createElement(G8,{...r}):n.node.type=="icon"?zt.default.createElement(U8,{...r}):n.node.type=="audio"?zt.default.createElement(M8,{...r}):n.node.type=="image"?zt.default.createElement(W8,{...r}):n.node.type=="space"?zt.default.createElement(T8,{...r,containerRef:t.containerRef,source:i.path}):n.node.type=="flow"?zt.default.createElement(F8,{...r,source:i.path,containerRef:t.containerRef}):n.node.type=="content"?zt.default.createElement(N8,{editable:!t.treeNode.isRef},t.treeNode.children.map((o,s)=>o.node.type=="slides"?null:zt.default.createElement(ZD,{superstate:t.superstate,key:o.id,treeNode:o,instance:t.instance,containerRef:t.containerRef},t.children)),t.children):(n.node.type=="column"||n.node.type=="container")&&n.children.length==0?null:t.treeNode.id==t.instance.exec.id||n.node.type=="column"||n.node.type=="container"?t.treeNode.children.map((o,s)=>o.node.type=="slides"?null:zt.default.createElement(ZD,{superstate:t.superstate,key:o.id,treeNode:o,instance:t.instance,containerRef:t.containerRef},t.children)):zt.default.createElement(zt.default.Fragment,null,zt.default.createElement(Lv,{superstate:t.superstate,id:n.id,editMode:t.editMode},n.children.map((o,s)=>o.node.type=="slides"?null:zt.default.createElement(ZD,{superstate:t.superstate,key:o.id,treeNode:o,instance:t.instance,containerRef:t.containerRef},t.children)))))}),ZD=e=>{let{selectionMode:t,selectable:r,selected:n,isParentToSelection:i,select:a,selection:o}=(0,zt.useContext)(ji),{updateNode:s,addNode:u,deleteNode:l,nodes:c,selectedSlide:f}=(0,zt.useContext)(Oi),{setDragNode:d}=(0,zt.useContext)(vh),{saveState:p,selectableNodeBounds:h,id:m}=(0,zt.useContext)(vi),{dragActive:g}=(0,zt.useContext)(vh),A=e.treeNode.isRef?0:e.treeNode.id==e.instance.exec.id?t:3,b=o.some(X=>X==e.treeNode.id),v=r&&!e.treeNode.isRef&&!b,x=e.instance.state[e.treeNode.id],w=(0,zt.useMemo)(()=>f?c.find(X=>X.ref==e.treeNode.id&&f==X.parentId)??null:null,[c,e.treeNode,f]),S=(0,zt.useMemo)(()=>w?{...e.treeNode,node:{...e.treeNode.node,styles:{...e.treeNode.node.styles,...w.styles},props:{...e.treeNode.node.props,...w.props},actions:{...e.treeNode.node.actions,...w.actions}}}:e.treeNode,[w,e.treeNode]),{frameSchema:k}=(0,zt.useContext)(va),M=m+k.id+e.treeNode.id,[O,D]=(0,zt.useState)(!1),[N,C]=zt.default.useState(!1),[_,I]=zt.default.useState(!1),L=e.treeNode.editorProps.dragMode==1||(v&&!i||b)&&e.treeNode.editorProps.dragMode!=0,{attributes:$,listeners:T,setNodeRef:W,transform:P}=Vs({id:M,data:{id:M,root:m,type:"node",parent:e.treeNode.node.parentId,frame:k.id,node:e.treeNode.id},disabled:!L}),Y=(0,zt.useRef)(null),oe=()=>{if(v&&e.treeNode.id!=e.instance.exec.id){a(S.node.id);return}},re=e.instance.state[e.treeNode.id]?.styles?!!e.instance.state[e.treeNode.id]?.styles?.hidden:!1,Q={superstate:e.superstate,treeNode:S,state:x},de=X=>{s(S.node,{styles:{...X}})},Pe=X=>{if(v&&(t!=1||i&&e.treeNode.id!=e.instance.exec.id)){X.shiftKey?a(S.node.id,!0):a(S.node.id),X.stopPropagation();return}else e.treeNode.id==e.instance.exec.id&&a(null);if(b)X.stopPropagation();else{if((X.detail===2||cr(e.superstate.ui))&&typeof x.actions?.onDoubleClick=="function"){x.actions?.onDoubleClick(X,null,e.instance.state,te=>p(te,e.instance),e.superstate.api),X.stopPropagation();return}X.detail===1&&typeof x.actions?.onClick=="function"&&(x.actions?.onClick(X,null,e.instance.state,te=>p(te,e.instance),e.superstate.api),X.stopPropagation())}};(0,zt.useEffect)(()=>{o.some(X=>X!=e.treeNode.id)&&D(!1)},[o,e.treeNode]);let[xe,Ce]=(0,zt.useState)(!1);(0,zt.useEffect)(()=>{b&&cr(e.superstate.ui)&&(e.treeNode.node.type=="group"||e.treeNode.node.type=="image"||t>=3)?Ce(!0):b&&xe||Ce(!1)},[e.treeNode,t,b]);let Be=e.treeNode.editorProps.dropMode,Fe=Y.current&&getComputedStyle(Y.current),Se=Y.current&&Y.current.clientWidth,ge=Y.current&&Y.current.clientHeight,[q,ae]=(0,zt.useState)([]),le=(X,te)=>({left:X.x-te.x,top:X.y-te.y,width:X.width,height:X.height});(0,zt.useEffect)(()=>{if(!Y.current||!e.containerRef?.current)return()=>null;e.treeNode.node.parentId==e.instance.exec.id&&(h.current[e.treeNode.id]=le(Y.current.getBoundingClientRect(),e.containerRef.current.getBoundingClientRect())),ae(()=>Array.from(Y.current?.children??[]).map(ne=>({x:ne.offsetLeft,y:ne.offsetTop,width:ne.clientWidth,height:ne.clientHeight})));let X=new ResizeObserver(()=>{e.treeNode.node.parentId==e.instance.exec.id&&Y.current&&(h.current[e.treeNode.id]=le(Y.current.getBoundingClientRect(),e.containerRef.current.getBoundingClientRect())),ae(()=>Array.from(Y.current?.children??[]).map(ne=>({x:ne.offsetLeft,y:ne.offsetTop,width:ne.clientWidth,height:ne.clientHeight})))});return X.observe(Y.current),()=>X.disconnect()},[x]);let U=Y.current?.getBoundingClientRect(),B=e.containerRef?.current?.getBoundingClientRect(),K={...FZ,...e.treeNode.node.type!="flow"?x?.styles:{width:x?.styles?.width,height:x?.styles?.height,"--max-width":x?.styles?.["--max-width"]},"--translate-x":`${P?.x??0}px`,"--translate-y":`${P?.y??0}px`};return Da({onDragStart:X=>{X.active?.id==M&&d(zt.default.createElement("div",{style:{width:Y.current.clientWidth}},zt.default.createElement(fE,{superstate:e.superstate,treeNode:e.treeNode,instance:e.instance,saveState:null})))}}),zt.default.createElement(zt.default.Fragment,null,(!re||!e.treeNode.isRef)&&zt.default.createElement("div",{ref:X=>{Y.current=X,t>1&&L&&W(X)},onContextMenu:()=>cr(e.superstate.ui)&&oe(),className:(0,TZ.default)(`mk-frame-edit ${aE(x?.styles)}`,v&&t!=1&&"mk-f-editable",b&&t==1&&"mk-selected"),"data-path":S.id,"data-type":S.node.type,onMouseEnter:()=>{D(!0),C(!0)},onMouseLeave:()=>{_||D(!1),C(!1)},...{onClick:Pe},...t>1?{...T,...$}:{},style:K},zt.default.createElement(Xet,{...Q,containerRef:e.containerRef,editMode:A,instance:e.instance},e.children)),x&&e.treeNode.node.type!="new"&&e.containerRef?.current&&t>0&&Y.current&&(0,tCe.createPortal)(zt.default.createElement(zt.default.Fragment,null,zt.default.createElement("div",{style:{position:"absolute",top:U.top-B.top,left:U.left-B.left,width:Se,height:ge,pointerEvents:"none"},className:(0,TZ.default)(!g&&v&&t!=1&&"mk-f-editable",!g&&b&&(t!=1||e.treeNode.node.type=="group")&&"mk-f-edit",!g&&O&&t!=1&&"mk-f-edit-hover"),onClick:X=>{if(v&&t!=1){X.shiftKey?a(S.node.id,!0):a(S.node.id),X.stopPropagation();return}}},e.treeNode.editorProps.resizeMode==2&&zt.default.createElement(jZ,{size:x?.styles,superstate:e.superstate,resizeMode:e.treeNode.editorProps.resizeMode,resize:de,clientSize:{width:Se,height:ge}}),g&&(t==1||t==3)&&Be>0&&zt.default.createElement(L6e,{parentId:S.node.parentId,superstate:e.superstate,height:ge,width:Se,node:S.node.id,id:M,mode:Be,insertMode:S.node.type=="group"?1:S.node.type=="space"?-1:0}),xe&&zt.default.createElement(zt.default.Fragment,null,zt.default.createElement(jZ,{superstate:e.superstate,resizeMode:1,size:x?.styles,resize:de,clientSize:{width:Se,height:ge}}),zt.default.createElement($6e,{styles:x?.styles,saveStyles:de,clientSize:{width:Se,height:ge}}),(S.node.type=="group"||S.node.type=="content")&&(x.styles?.layout=="row"||x.styles?.layout=="column")&&zt.default.createElement(zt.default.Fragment,null,zt.default.createElement(z6e,{childSizes:q,clientSize:{width:Se,height:ge,paddingBottom:parseInt(Fe?.paddingBottom??"0"),paddingLeft:parseInt(Fe?.paddingLeft??"0"),paddingRight:parseInt(Fe?.paddingRight??"0"),paddingTop:parseInt(Fe?.paddingTop??"0")},styles:x?.styles,saveStyles:de,direction:x?.styles.layout=="column"?"column":"row"}),zt.default.createElement(W6e,{clientSize:{width:Se,height:ge},styles:x?.styles,saveStyles:de}))),S.editorProps.dragMode==1&&(!cr(e.superstate.ui)||b)?zt.default.createElement("div",{onMouseEnter:()=>{I(!0),D(!0)},onMouseLeave:()=>{N||D(!1),I(!1)},className:"mk-editor-frame-hover-menu-container",style:{zIndex:O?"calc(var(--layer-popover) + 1)":"var(--layer-popover)"}},zt.default.createElement(B6e,{superstate:e.superstate,node:S.node,mode:t==1?0:1,selected:b,visible:cr(e.superstate.ui)||O,dragRef:W,attributes:$,listeners:T})):zt.default.createElement(zt.default.Fragment,null)),o&&!g&&b&&o.length==1?zt.default.createElement(DZ,{nodeRect:U,containerRect:B},zt.default.createElement(I6e,{editLayout:X=>Ce(X),superstate:e.superstate,node:S.node,duplicateFrame:()=>{u(S.node,S.node)},state:x,deleteFrame:()=>l(S.node),fields:tle(S.node)})):o.length>1&&o[0]==S.id?zt.default.createElement(DZ,{nodeRect:U,containerRect:B},zt.default.createElement(v6e,{superstate:e.superstate})):null),e.containerRef.current))};var fE=e=>{let t={superstate:e.superstate,treeNode:e.treeNode,state:e.instance.state[e.treeNode.id]},r=e.treeNode.node.type=="input"?ip.default.createElement(H8,{...t}):e.treeNode.node.type=="text"?ip.default.createElement(G8,{...t}):e.treeNode.node.type=="icon"?ip.default.createElement(U8,{...t}):e.treeNode.node.type=="audio"?ip.default.createElement(M8,{...t}):e.treeNode.node.type=="image"?ip.default.createElement(W8,{...t}):e.treeNode.node.type=="space"?ip.default.createElement(T8,{...t,source:e.source}):e.treeNode.node.type=="content"?ip.default.createElement(N8,null,e.treeNode.children.filter(i=>i.node.type!="slides").map((i,a)=>ip.default.createElement(fE,{superstate:e.superstate,key:a,treeNode:i,instance:e.instance,saveState:e.saveState,source:e.source},e.children)),e.children):e.treeNode.node.type=="flow"?ip.default.createElement(F8,{...t,source:e.source}):e.treeNode.children.filter(i=>i.node.type!="slides").map((i,a)=>ip.default.createElement(fE,{superstate:e.superstate,key:a,treeNode:i,instance:e.instance,saveState:e.saveState,source:e.source},e.children)),n=e.instance.state[e.treeNode.id]?.styles?!!e.instance.state[e.treeNode.id]?.styles?.hidden:!1;return e.instance.state[e.treeNode.id]&&!n&&ip.default.createElement("div",{className:`mk-frame ${aE(e.instance.state[e.treeNode.id]?.styles)}`,"data-path":e.treeNode.id,"data-type":e.treeNode.node.type,onContextMenu:i=>{typeof e.instance.state[e.treeNode.id].actions?.onContextMenu=="function"&&(e.instance.state[e.treeNode.id].actions?.onContextMenu(i,null,e.instance.state,a=>e.saveState(a,e.instance),e.superstate.api),i.stopPropagation())},onClick:i=>{if((i.detail===2||cr(e.superstate.ui))&&typeof e.instance.state[e.treeNode.id].actions?.onDoubleClick=="function"){e.instance.state[e.treeNode.id].actions?.onDoubleClick(i,null,e.instance.state,a=>e.saveState(a,e.instance),e.superstate.api),i.stopPropagation();return}i.detail===1&&typeof e.instance.state[e.treeNode.id].actions?.onClick=="function"&&(e.instance.state[e.treeNode.id].actions?.onClick(i,null,e.instance.state,a=>e.saveState(a,e.instance),e.superstate.api),i.stopPropagation())},style:{...FZ,...e.instance.state[e.treeNode.id]?.styles}},r)};var Cb=e=>{let{saveState:t,instance:r}=(0,Q8.useContext)(vi);return r.exec&&Q8.default.createElement(fE,{superstate:e.superstate,treeNode:r.exec,instance:r,saveState:t,source:e.source},e.children)};var Jv=e=>{let t=(0,rs.useMemo)(()=>e.superstate.spaceManager.uriByString(e.path,e.source),[e.path,e.source]),[r,n]=(0,rs.useState)(null);return(0,rs.useEffect)(()=>{t.refType=="context"?n({type:"context",path:t.basePath,contextSchema:t.ref,frameSchema:t.query?.frameSchema}):t.refType=="frame"?e.superstate.spaceManager.readFrame(t.basePath,t.ref).then(i=>{let a=i?.schema;!a&&t.ref==Op.id&&(a=Op,n({type:"context",path:t.basePath,frameSchema:a.id})),a?.type=="view"?n({type:"context",path:t.basePath,frameSchema:t.ref}):n({type:"frame",path:t.basePath,frameSchema:t.ref})}):t.refType=="action"?n({type:"action",path:t.basePath,actionSchema:t.ref}):n({type:"context",path:t.basePath,frameSchema:A0})},[t]),rs.default.createElement(rs.default.Fragment,null,r?.path&&(r?.type=="context"?rs.default.createElement(Ks,{superstate:e.superstate,path:r.path,readMode:!1},rs.default.createElement(gh,{superstate:e.superstate},rs.default.createElement(Mv,{superstate:e.superstate,contextSchema:r.contextSchema,schema:r.frameSchema},rs.default.createElement(DS,{superstate:e.superstate},rs.default.createElement(dE,{showTitle:e.showTitle,superstate:e.superstate,minMode:e.minMode,containerRef:e.containerRef,setView:e.setFrameSchema}))))):r?.type=="frame"?rs.default.createElement(V9,{superstate:e.superstate,path:t,cols:[]},rs.default.createElement(vg,{id:e.id,superstate:e.superstate,props:{},editable:!1},rs.default.createElement(Cb,{superstate:e.superstate,source:e.source}))):r?.type=="action"?rs.default.createElement(j8,{superstate:e.superstate,action:e.path}):rs.default.createElement(rs.default.Fragment,null)))};var _8=e=>{let[t,r]=(0,Vc.useState)(e.superstate.pathsIndex.get(e.path)),n=(0,Vc.useRef)(null);return(0,Vc.useEffect)(()=>{let i=e.superstate.spaceManager.uriByString(e.path),a=e.superstate.pathsIndex.get(e.path);if(!a&&(i?.scheme=="https"||i?.scheme=="http")){r({path:e.path,label:{sticker:i.scheme,name:i.path,color:""},hidden:!1,readOnly:!0,subtype:"md",type:"remote"});return}r(a)},[e.path]),Vc.default.createElement("div",{className:"mk-path-view",style:{...e.styles??{}}},t?.type=="remote"?t.subtype=="note"?Vc.default.createElement(Zd,{superstate:e.superstate,path:e.path,load:!0,classname:"mk-flow-node"}):Vc.default.createElement("iframe",{src:e.path}):t?.type=="space"?Vc.default.createElement(Jv,{id:e.id,showTitle:!0,containerRef:n,superstate:e.superstate,path:e.path}):e.superstate.ui.availableViews().some(i=>i==e.path?.split(".").pop())?Vc.default.createElement(Zd,{superstate:e.superstate,path:e.path,load:!0,classname:"mk-flow-node"}):Vc.default.createElement(Vc.default.Fragment,null))};var iCe=e=>{let[t,r]=(0,Sr.useState)(null),[n,i]=(0,Sr.useState)(!1),[a,o]=(0,Sr.useState)(!1),[s,u]=(0,Sr.useState)(""),[l,c]=(0,Sr.useState)(0),f=N=>{u(N)},[d,p]=(0,Sr.useState)([]),h=(0,Sr.useMemo)(()=>s.length>0?[{type:"any",trueFalse:!0,filters:[{type:"file",fType:"text",field:"name",fn:"include",value:s}]},...d]:d,[s,d]),m=N=>({type:"path",value:N.path,cache:N,sticker:N.label.sticker,description:N.label.preview,label:N.name}),g=e.parentSpace?[{type:"section",label:"Items"},...[...e.superstate.spacesMap.getInverse(e.parentSpace)].map(N=>e.superstate.pathsIndex.get(N)).filter(N=>N&&!N.hidden).map(N=>m(N))]:[],A=[{type:"section",label:"Recent"},...e.superstate.ui.navigationHistory().map(N=>e.superstate.pathsIndex.get(N)).filter(N=>N&&!N.hidden).map(N=>m(N))],[b,v]=(0,Sr.useState)(e.parentSpace?g:A);(0,Sr.useEffect)(()=>{let N=(C,_)=>{if(C.length==0&&s.length==0){v(e.parentSpace?g:A);return}if(d.length==0){e.superstate.searcher.run({type:"fastSearch",path:C,payload:{query:s,count:10}}).then(I=>v([{type:"section",label:"Results"},...I.map(L=>m(L)),{type:"section",label:"Create New"},{type:"new-note",sticker:"ui//edit",value:s,label:"New Note"},{type:"new-space",sticker:"ui//folder-plus",value:s,label:"New Space"}]));return}if(!e.superstate.settings.searchWorker){let I=JEe({queries:_,count:10,pathsIndex:e.superstate.pathsIndex});v([{type:"section",label:"Results"},...I.map(L=>m(L)),{type:"new-note",sticker:"ui//plus",value:s,label:"New Note"},{type:"new-space",sticker:"ui//plus",value:s,label:"New Space"}]);return}e.superstate.searcher.run({type:"search",path:C,payload:{queries:_,count:10}}).then(I=>v(I.map(L=>m(L))))};(0,rCe.debounce)(()=>N(s,h),300)()},[s,h]),(0,Sr.useEffect)(()=>{if(!b[l]||b[l].type!="path")return;let N=b[l]?.cache?.path;!N||N==t||r(b[l]?.cache?.path)},[l,b]);let x=(N,C)=>{if(!!N&&N.type!="section"){if(N.type=="new-note"){if(e.parentSpace){let _=e.superstate.spacesIndex.get(e.parentSpace);if(_){Un(e.superstate,_,"md",s).then(I=>{e.mode==2&&e.onSelect(I),e.hide()});return}}dS(e.superstate,e.superstate.pathsIndex.get(e.superstate.ui.activePath)).then(_=>Un(e.superstate,_,"md",s).then(I=>{e.mode==2&&e.onSelect(I),e.hide()}));return}if(N.type=="new-space"){let _=e.superstate.pathsIndex.get(e.parentSpace)??e.superstate.pathsIndex.get("/"),I=s.replace(/\//g,""),L=_?.subtype=="folder"?_.path:_.parent?_.parent:"/",$=!L||L=="/"?I:L+"/"+I;if(I.length==0){e.superstate.ui.notify(z.notice.newSpaceName);return}if(e.superstate.spacesIndex.has($)){e.superstate.ui.notify(z.notice.duplicateSpaceName);return}Tf(e.superstate,$,{}).then(T=>{e.mode==2&&e.onSelect(T.path),e.hide()});return}if(N.cache){if(e.mode==2){e.onSelect(N.cache?.path),e.hide();return}if(!n||C){e.superstate.ui.openPath(N.cache?.path),e.hide();return}}c(b.findIndex(_=>_.cache?.path==N.cache?.path))}},w=[],S=N=>{if(N.key=="Tab"&&w&&(N.preventDefault(),N.stopPropagation()),N.key=="ArrowUp"){let _=l<=0?b.length-1:l-1;if(b.length==0)return;!b[_]||b[_].type=="section"?c(_<0?b.length-1:_-1):c(_),N.preventDefault()}if(N.key=="ArrowDown"){let C=b.length-1,_=l>=C?0:l+1;!b[_]||b[_].type=="section"?c(_>=C?0:_+1):c(_),c(_),N.preventDefault()}N.key=="Enter"&&(x(b[l],!0),N.preventDefault())},k=Sr.default.useRef(null);(0,Sr.useEffect)(()=>{k.current?.focus()},[k.current]);let M=T9(e.superstate),O=[];Object.keys(M).forEach(N=>{M[N].properties.forEach(C=>{O.push({...C})})});let D=Object.keys(M).map(N=>({name:M[N].name,value:N}));return Sr.default.createElement(Sr.default.Fragment,null,Sr.default.createElement("div",{className:"mk-blink-input-container"},Sr.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//search")}}),Sr.default.createElement("div",{"data-placeholder":z.labels.blinkPlaceholder,onInput:N=>f(N.currentTarget.innerText),onKeyDown:N=>S(N),ref:k,contentEditable:!0,className:"mk-blink-input"}),e.mode==1&&Sr.default.createElement(Sr.default.Fragment,null,Sr.default.createElement("button",{onClick:()=>i(N=>!N),className:"mk-toolbar-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//blink")}}),Sr.default.createElement("button",{className:"mk-toolbar-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//filter")},onClick:()=>o(!a)}))),a&&Sr.default.createElement("div",{className:"mk-blink-filters"},Sr.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//filter")}}),Sr.default.createElement(BS,{superstate:e.superstate,filters:d,setFilters:p,fields:O,sections:D})),Sr.default.createElement("div",{className:"mk-blink-suggester",style:{}},Sr.default.createElement("div",{className:"mk-blink-suggestions"},b.map((N,C)=>Sr.default.createElement("div",{key:C,className:(0,nCe.default)(N.type=="section"?"mk-blink-section":"mk-blink-suggestion",l==C&&"mk-active"),onClick:_=>x(N)},N.type=="section"?Sr.default.createElement("div",{className:"mk-blink-suggestion-title"},N.label):Sr.default.createElement(Sr.default.Fragment,null,Sr.default.createElement("div",{className:"mk-blink-suggestion-icon",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(N.sticker)}}),Sr.default.createElement("div",{className:"mk-blink-suggestion-text"},Sr.default.createElement("div",{className:"mk-blink-suggestion-title"},N.label),Sr.default.createElement("div",{className:"mk-blink-suggestion-description"},N.value),N.description&&Sr.default.createElement("div",{className:"mk-blink-suggestion-preview"},N.description)))))),e.mode==1&&n&&Sr.default.createElement(Ket,{superstate:e.superstate,path:t})))},Ket=e=>{let t=Sr.default.useRef(null),[r,n]=(0,Sr.useState)(!1);return Sr.default.createElement("div",{className:"mk-blink-preview",ref:t},Sr.default.createElement("div",{className:"mk-blink-preview-title"},Sr.default.createElement(Pa,{superstate:e.superstate,path:e.path}),Sr.default.createElement("span",null),Sr.default.createElement("button",{className:r?"is-active mk-icon-small":"mk-icon-small",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//list")},onClick:()=>n(!r)})),Sr.default.createElement(_8,{id:"blink",superstate:e.superstate,path:e.path,containerRef:t,styles:{},readOnly:!0}),r&&Sr.default.createElement("div",{className:"mk-blink-properties"},Sr.default.createElement("div",{className:"mk-blink-properties-header"},"Properties"),Sr.default.createElement(Ks,{path:e.path,superstate:e.superstate,readMode:!1})))};var zf=(e,t,r,n,i)=>{e.ui.openPalette(aCe.default.createElement(iCe,{superstate:e,mode:t,onSelect:n,parentSpace:i}),r,"mk-blink-modal")};var Bu=he(Me());var t1=he(Me()),mE=e=>{let t=_r(e.superstate,e.date,e.mode=="day"?"MMMM d":"MMMM");return t1.default.createElement("div",{className:"mk-calendar-header"},t1.default.createElement("div",{className:"mk-calendar-header-title"},t1.default.createElement("span",null,t),_r(e.superstate,e.date,"yyyy")),t1.default.createElement("span",null),t1.default.createElement("button",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//chevron-left")},onClick:()=>{if(e.mode=="day"){e.setDate(new Date(e.date.setDate(e.date.getDate()-1)));return}else if(e.mode=="week"){e.setDate(new Date(e.date.setDate(e.date.getDate()-7)));return}e.setDate(new Date(e.date.setMonth(e.date.getMonth()-1)))}}),t1.default.createElement("button",{onClick:()=>{e.setDate(new Date)}},"Today"),t1.default.createElement("button",{onClick:()=>{if(e.mode=="day"){e.setDate(new Date(e.date.setDate(e.date.getDate()+1)));return}if(e.mode=="week"){e.setDate(new Date(e.date.setDate(e.date.getDate()+7)));return}e.setDate(new Date(e.date.setMonth(e.date.getMonth()+1)))},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//chevron-right")}}))};var _Z=he(Me()),Y8=e=>{let{attributes:t,listeners:r,setNodeRef:n,transform:i}=Vs({id:"event-"+e.index,data:{type:"event",index:e.index}});return _Z.default.createElement("div",{className:"mk-week-event",ref:n,...t,...r,style:{...e.style,left:"2px",width:`calc(${(e.endDay-e.startDay+1)*100}% - 4px)`,top:`${e.topOffset*22+2}px`}},_Z.default.createElement(Pa,{superstate:e.superstate,path:e.data[gt]}))};var XD=he(Me()),Z8=e=>XD.default.createElement("div",{className:"mk-day-view-gutter"},e.allDay&&XD.default.createElement("div",{className:"mk-day-view-hour-title"},"all day"),Array.from({length:e.endHour-e.startHour+1}).map((t,r)=>{let n=r+e.startHour;return XD.default.createElement("div",{key:n,className:"mk-day-view-hour-title"},XD.default.createElement("span",null,n%12===0?12:n%12)," ",n<12?"AM":"PM")}));var ko=he(Me());var KD=e=>{let{event:t,hourHeight:r,startHour:n}=e,{spaceState:i}=(0,ko.useContext)(ar),{attributes:a,listeners:o,setNodeRef:s,transform:u}=Vs({id:`event-${t?.index??""}-${t?.start?.getTime().toString()??""}-${e.clone?"clone":""}`,data:{type:"event",index:t?.index}}),l="#0098FF",[c,f]=(0,ko.useState)(null),d=c||t,p=(0,ko.useMemo)(()=>{let h=t.start??xk(Gn(new Date),e.event.startOffset),m=t.end??xk(Gn(new Date),e.event.endOffset),g=_r(e.superstate,h,"a")===_r(e.superstate,m,"a"),A=`h${h.getMinutes()==0?"":":mm"} ${g?"":"a"}`,b=`h${m.getMinutes()==0?"":":mm"} a`;return e.event.startOffset>0?`${_r(e.superstate,h,A)} - ${_r(e.superstate,m,b)}`:null},[e.event]);return ko.default.createElement("div",{key:t.index,onMouseDown:h=>{h.stopPropagation()},onContextMenu:h=>{let m=h.currentTarget.getBoundingClientRect();Jp(e.superstate,e.item[gt],i.path,m,je(h.currentTarget.ownerDocument))},className:"mk-day-block",style:{zIndex:1,...e.style||{},...e.clone?{top:`${(d.startOffset/60-n)*r}px`,width:`calc(${t.widthPercentage}% - ${t.leftOffset*8}px)`,height:`${(d.endOffset-d.startOffset)*r/60}px`}:{top:`${(d.startOffset/60-n)*r}px`,height:`${(d.endOffset-d.startOffset)*r/60}px`,left:`calc(${d.column*d.widthPercentage}% + ${d.leftOffset*8}px)`,width:`calc(${d.widthPercentage}% - ${d.leftOffset*8}px)`}}},ko.default.createElement("div",{...a,...o,ref:s,className:"mk-day-block-inner",style:{"--block-color":l,"--block-bg-color":yg(40,l)}},ko.default.createElement("div",{className:"mk-day-block-inner-indicator"}),ko.default.createElement("div",{className:"mk-day-block-content"},e.item[gt]?ko.default.createElement(Pa,{superstate:e.superstate,path:e.item[gt],hideIcon:!0}):"New Event",p&&ko.default.createElement("div",{className:"mk-day-block-time"},ko.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//clock")}}),p)),ko.default.createElement("span",null),d.repeat&&ko.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//sync")}}),!d.allDay&&ko.default.createElement(ko.default.Fragment,null,ko.default.createElement("div",{className:"mk-day-handle-n"},ko.default.createElement(au,{value:d.startOffset,cursor:"s",reverseY:!0,disableX:!0,step:60/r,onDragMove:h=>{let m={...t,startOffset:Math.round(h/15)*15};f(m)},onDragEnd:h=>{e.updateStartEnd&&e.updateStartEnd(Math.round(h/15)*15,d.endOffset),f(null)}})),ko.default.createElement("div",{className:"mk-day-handle-s"},ko.default.createElement(au,{value:d.endOffset,cursor:"s",reverseY:!0,disableX:!0,step:60/r,onDragMove:h=>{let m={...t,endOffset:Math.round(h/15)*15};f(m)},onDragEnd:h=>{e.updateStartEnd&&e.updateStartEnd(d.startOffset,Math.round(h/15)*15),f(null)}})))))};var X8=e=>{let{hourHeight:t}=e,[r,n]=(0,Gc.useState)(e.date??Gn(new Date)),{source:i}=(0,Gc.useContext)(_a),[a,o]=(0,Gc.useState)(null),s=`day-view-${r.toDateString()}`,u=e.startHour??0,l=(N,C,_,I,L)=>{if(!N||!_||!I)return[];let $=[],T=[];N.forEach((W,P)=>{let Y=lr(W[L]),oe=[],re=da(W[_]);if(re>=C&&re<=Sa(C,{days:1})&&oe.push(W),Y&&Y.freq){let Q=da(W[I]).getTime()-re.getTime(),de={dtstart:re,freq:Y.freq&&hM(Y.freq),count:Y.count&&Math.min(parseInt(Y.count),100),interval:Y.interval&&parseInt(Y.interval),byweekday:Y.byweekday&&Y.byweekday.map(Ce=>uw(Ce)),until:Y.until&&new Date(Math.min((da(Y.until)??Sa(C,{days:1})).getTime(),Sa(C,{days:1}).getTime())),wkst:Y.wkst&&uw(Y.wkst)};console.log(Y),new Ht(Object.entries(de).filter(([Ce,Be])=>Be!==void 0).reduce((Ce,[Be,Fe])=>(Ce[Be]=Fe,Ce),{})).between(C,Sa(C,{days:1}),!0).forEach(Ce=>{Ce.getTime()!=re.getTime()&&oe.push({...W,[_]:_r(e.superstate,Ce,Ls),[I]:_r(e.superstate,ud(Ce,Q),Ls)})})}oe.forEach(Q=>{let de=Gn(r).getTime(),Pe=Sa(r,{days:1}).getTime(),xe=da(Q[_]),Ce=da(Q[I])??Gn(xe).getTime()==xe.getTime()?xe:Sa(xe,{hours:1}),Be=Math.max(u*60,(xe.getTime()-de)/6e4),Fe=Math.min(Ce.getTime()-de,Pe-de)/6e4;if(xe.getTime()==Gn(xe).getTime()){T.push({index:P,start:xe,end:Ce,startOffset:u*60,endOffset:60*24,leftOffset:0,widthPercentage:100,column:0,columnTotal:1,allDay:!0});return}let ge=!1;for(let q=0;q<$.length;q++){let ae=$[q],le=ae[0];if(Be>=le.startOffset-15&&Be<=le.startOffset+15){ae.push({index:P,start:xe,end:Ce,repeat:!!Y,startOffset:Be,endOffset:Fe}),ge=!0;break}}ge||$.push([{index:P,repeat:!!Y,start:xe,end:Ce,startOffset:Be,endOffset:Fe}])})}),$.forEach((W,P)=>{W.forEach((Y,oe)=>{T.push({...Y,leftOffset:0,widthPercentage:100/W.length,column:oe,columnTotal:W.length})})}),T.sort((W,P)=>W.startOffset-P.startOffset);for(let W=0;WT[P].startOffset&&T[W].startOffsetl(e.data,r,e.field,e.fieldEnd,e.fieldRepeat),[e.data,r,e.field,e.fieldEnd,e.fieldRepeat]),[d,p]=(0,Gc.useState)(null),[h,m]=(0,Gc.useState)(null),[g,A]=(0,Gc.useState)(null),[b,v]=(0,Gc.useState)(null),x=()=>{p(null),m(null),A(null),v(null)},w=N=>Math.round(N/15)*15;Da({onDragStart:N=>{N.active.data.current.type==="event"&&(p(N.active.data.current.index),o(null))},onDragOver:N=>{if(N.over?.id!=s||(p(N.active.data.current.index),N.active.data.current.type==="event"))return;let C=N.activatorEvent.clientY,_=N.over.rect.top;v(C-_),m(N.active?.data.current.path)},onDragMove:N=>{if(N.over?.id!=s)return;N.active.data.current.type!="event"&&m(N.active?.data.current.path);let C=N.over.rect,_=N.delta.y,I=2*Math.round(_/2);g!==I&&A(I)},onDragCancel:()=>{x()},onDragEnd:N=>{if(N.active.data.current.type==="event"&&N.over?.id==s){let{index:C}=N.active.data.current,_=f.find($=>$.index==C);if(!_){x();return}let I=Sa(r,{minutes:Math.round(w(_.startOffset+g/t*60))}),L=Sa(r,{minutes:Math.round(w(_.endOffset+g/t*60))});console.log(I,L),e.updateItem({...e.data[C],[e.field]:_r(e.superstate,I,Ls),[e.fieldEnd]:_r(e.superstate,L,Ls)})}else if(h){let C=Sa(r,{minutes:Math.round(g/t*60)}),_=Sa(r,{minutes:Math.round(g/t*60)+60});e.insertItem({[e.field]:_r(e.superstate,C,Ls),[e.fieldEnd]:_r(e.superstate,_,Ls),[gt]:h})}x()}});let{setNodeRef:S}=ql({id:s,data:{type:"day-view",date:r}}),k=new Date().toDateString()===r.toDateString(),[M,O]=(0,Gc.useState)(0),D=f.find(N=>N.index==d);return(0,Gc.useEffect)(()=>{let N;return k&&(O((new Date().getHours()-u)*60+new Date().getMinutes()),N=setInterval(()=>{O((new Date().getHours()-u)*60+new Date().getMinutes())},6e4)),()=>{N&&clearInterval(N)}},[]),Bu.default.createElement("div",{className:"mk-day-view-container",style:{"--hour-height":`${t}px`}},e.header&&Bu.default.createElement(mE,{superstate:e.superstate,date:r,mode:"day",setDate:n}),e.gutter&&Bu.default.createElement("div",{className:"mk-day-view-all-day"},Bu.default.createElement("div",{className:"mk-day-view-gutter"},Bu.default.createElement("div",{className:"mk-day-view-hour-title"},"all day")),Bu.default.createElement("div",{className:"mk-day-view-hour"},f.filter(N=>N.allDay).map((N,C)=>Bu.default.createElement(Y8,{superstate:e.superstate,key:C,index:N.index,startDay:0,endDay:0,topOffset:0,data:e.data[N.index],style:{position:"relative","--block-bg-color":yg(40,"#0098FF"),"--block-color":"#0098FF"}})))),Bu.default.createElement("div",{className:"mk-day-view"},e.gutter&&Bu.default.createElement(Z8,{hourHeight:t,startHour:u,endHour:c}),Bu.default.createElement("div",{className:"mk-day-view-content",ref:S,onMouseDown:N=>{if(N.button!=0)return;let C=N.currentTarget.scrollTop,_=N.clientY-N.currentTarget.getBoundingClientRect().top+C;o({index:-1,startOffset:w((_/t+u)*60),endOffset:w((_/t+u)*60),leftOffset:0,widthPercentage:100,column:0,columnTotal:1})},onMouseMove:N=>{if(a){let C=N.currentTarget.scrollTop,_=N.clientY-N.currentTarget.getBoundingClientRect().top+C,I=w((_/t+u)*60);I<=a.startOffset?o({...a,startOffset:I}):o({...a,endOffset:I}),N.preventDefault()}},onMouseUp:N=>{if(!a||a.startOffset==a.endOffset){o(null);return}let C=Sa(r,{minutes:a.startOffset}),_=Sa(r,{minutes:a.endOffset});N.preventDefault(),zf(e.superstate,2,window,I=>{!I||e.insertItem({[e.field]:_r(e.superstate,C,Ls),[e.fieldEnd]:_r(e.superstate,_,Ls),[gt]:I})},i),o(null)}},Array.from({length:c-u}).map((N,C)=>Bu.default.createElement("div",{key:C,className:"mk-day-view-hour"})),k&&Bu.default.createElement("div",{className:"mk-day-view-hour-current",style:{top:`${M*t/60}px`}}),f.filter(N=>!N.allDay).map((N,C)=>Bu.default.createElement(KD,{superstate:e.superstate,key:C,event:N,item:e.data[N.index],hourHeight:t,startHour:u,updateStartEnd:(_,I)=>{let L=Sa(r,{minutes:_}),$=Sa(r,{minutes:I});e.updateItem({...e.data[N.index],[e.field]:_r(e.superstate,L,Ls),[e.fieldEnd]:_r(e.superstate,$,Ls)})}})),a&&a.endOffset>a.startOffset&&Bu.default.createElement(KD,{superstate:e.superstate,event:a,item:{},hourHeight:t,startHour:u,clone:!0}),d!==null&&D?Bu.default.createElement(KD,{superstate:e.superstate,event:{...D,start:null,end:null,startOffset:Math.round(w(D.startOffset+g/t*60)),endOffset:Math.round(w(D.endOffset+g/t*60))},item:e.data[d],hourHeight:t,startHour:u,clone:!0}):h?Bu.default.createElement(KD,{superstate:e.superstate,event:{index:-1,startOffset:0,endOffset:60,leftOffset:0,widthPercentage:100,column:0,columnTotal:1},startHour:e.startHour,item:{[gt]:h},hourHeight:t,style:{transform:`translateY(${g+b}px)`},clone:!0}):null)))};var Ru=he(Me());var Uf=he(Me()),sCe=he(Ws());var PZ=he(Me()),oCe=e=>{let{attributes:t,listeners:r,setNodeRef:n,transform:i}=Vs({id:"day-"+e.date.getTime(),data:{type:"day",date:e.date.getTime()}}),{setNodeRef:a}=ql({id:"day-"+e.date.getTime(),data:{type:"day",weekStart:e.weekStart.getTime(),date:e.date.getTime()}}),o=e.date.toDateString()===new Date().toDateString(),s=m9(a,n);return PZ.default.createElement("div",{ref:s,...t,...r,className:`mk-month-day ${e.active?"mk-active":"mk-inactive"} ${o?"mk-today":""}`,onClick:u=>{u.detail==2&&e.insertItem()},style:{opacity:"1 !important"}},PZ.default.createElement("div",{className:"mk-month-day-number"},e.date.getDate()),e.children)};var Db=he(Me()),IZ=e=>{let{attributes:t,listeners:r,setNodeRef:n,transform:i}=Vs({id:"event-"+e.index,data:{type:"event",index:e.index}}),a=(0,Db.useMemo)(()=>{let o=new Date(e.startEvent),s=`h${o.getMinutes()==0?"":":mm"} a`;return e.allDay?null:`${_r(e.superstate,o,s)}`},[e.startEvent,e.endEvent,e.allDay]);return Db.default.createElement("div",{className:"mk-month-event",ref:n,style:e.style,...t,...r},!e.allDay&&Db.default.createElement("div",{className:"mk-day-block-inner-indicator"}),Db.default.createElement(Pa,{superstate:e.superstate,path:e.data[gt],hideIcon:!0}),Db.default.createElement("div",{className:"mk-day-block-time"},a))};var uCe=e=>{let t=go(e.date),r=bA(t),{source:n}=(0,Uf.useContext)(_a),i=(0,Uf.useMemo)(()=>{let l=[];return e.events.forEach((c,f)=>{let d=[],p=lr(c[e.fieldRepeat]),h=da(c[e.field]),m=da(c[e.fieldEnd])??h;if(h<=$x(r)&&m>=Gn(t)&&d.push(c),p&&p.freq){let g=da(c[e.fieldEnd]).getTime()-h.getTime(),A={dtstart:h,freq:p.freq&&hM(p.freq),count:p.count&&Math.min(p.count,100),interval:parseInt(p.interval),byweekday:p.byweekday&&p.byweekday.map(x=>uw(x)),until:da(p.until),wkst:p.wkst&&uw(p.wkst)},v=new Ht(Object.entries(A).filter(([x,w])=>w!==void 0).reduce((x,[w,S])=>(x[w]=S,x),{})).between(Gn(t),$x(r),!0);console.log(c[gt],p,v),v.forEach(x=>{x.getTime()!=h.getTime()&&d.push({...c,[e.field]:_r(e.superstate,x,Ls),[e.fieldEnd]:_r(e.superstate,ud(x,g),Ls)})})}d.forEach(g=>{let A=da(g[e.field]),b=da(g[e.fieldEnd])??Gn(A).getTime()==A.getTime()?Gn(A):Rx(A,1),v=A>t?A:t,x=bc.startDay==f.startDay?c.endDay==f.endDay?c.allDay?-1:1:f.endDay-c.endDay:c.startDay-f.startDay),l.map((c,f,d)=>{let p=d.slice(0,f).reduce((h,m)=>m.endDay>=c.startDay?h+1:h,0);return{...c,offset:p}})},[e.events,e.fieldRepeat,e.field,e.fieldEnd,t,r]),[a,o]=(0,Uf.useState)(null),[s,u]=(0,Uf.useState)(null);return Da({onDragStart:l=>{l.active.data.current.type=="day"&&u(new Date(l.active.data.current.date))},onDragOver:l=>{if(l.active?.data.current.type=="day"&&l.over?.data.current.type=="day"){let c=new Date(l.over?.data.current.date),f=c>s?s:c,d=c>s?c:s;if(f>=r||d<=t){o(null);return}let p=i.reduce((h,m)=>m.endDay>=r.getDay()?h+1:h,0);o({offset:p,index:-1,startDay:td?d.getDay():r.getDay(),allDay:!1,startTime:f.getTime(),endTime:d.getTime()})}},onDragEnd:l=>{if(a&&l.over?.data.current.weekStart==t.getTime()){let c=_r(e.superstate,s,"yyyy-MM-dd"),f=_r(e.superstate,new Date(l.over.data.current.date),"yyyy-MM-dd");zf(e.superstate,2,window,d=>{d&&e.insertItem({[gt]:d,[e.field]:c,[e.fieldEnd]:f}),o(null)},n)}else o(null);u(null)}}),Uf.default.createElement("div",{className:"mk-month-week"},Array.from({length:7}).map((l,c)=>{let f=Sa(t,{days:c}),d=f.getMonth()===e.date.getMonth();return Uf.default.createElement(oCe,{key:c,superstate:e.superstate,weekStart:t,active:d,date:f,insertItem:()=>{let p=i.reduce((A,b)=>{let v=da(e.events[b.index])?.getHours();return v>A?v:A},9),h=_r(e.superstate,Rx(Gn(f),p),Ls),m=_r(e.superstate,Rx(Gn(f),p+1),Ls),g=i.reduce((A,b)=>b.endDay>=c?A+1:A,0);o({offset:g,index:-1,startDay:c,endDay:c,startTime:Gn(f).getTime(),endTime:$x(f).getTime(),allDay:!1}),zf(e.superstate,2,window,A=>{A&&e.insertItem({[gt]:A,[e.field]:h,[e.fieldEnd]:m}),o(null)})}},a?.startDay==c&&Uf.default.createElement(IZ,{superstate:e.superstate,index:-1,style:{"--block-bg-color":yg(40,"#0098FF"),"--block-color":"#0098FF","--block-text-color":"var(--mk-ui-text-accent)",top:`${30}px`,width:`${(a.endDay-a.startDay+1)*100}%`},data:{[gt]:"New Event"},startEvent:a.startTime,endEvent:a.endTime,allDay:!1}),i.filter(p=>p.startDay==c).map((p,h)=>{let m=a?p.startDay<=a.endDay&&p.endDay>=a.startDay:!1;return Uf.default.createElement(IZ,{superstate:e.superstate,key:h,index:p.index,startEvent:p.startTime,endEvent:p.endTime,allDay:p.allDay,style:{"--block-bg-color":p.allDay?yg(40,"#0098FF"):"transparent","--block-color":"#0098FF","--block-text-color":p.allDay?"var(--mk-ui-text-accent)":"var(--mk-ui-text-primary)",top:`${p.offset*22+30+(m?22:0)}px`,width:`${(p.endDay-p.startDay+1)*100}%`},data:e.events[p.index]})}))}),s&&(0,sCe.createPortal)(Uf.default.createElement(Zm,{dropAnimation:zU}),document.body))};var lCe=e=>{let[t,r]=(0,Ru.useState)(e.date??new Date),n=(0,Ru.useMemo)(()=>{let o=Vo(t),s=d0(t),u=[],l=o;for(;l<=s;)u.push(l),l=c0(l,1);return u},[t]),[i,a]=(0,Ru.useState)(null);return Da({onDragStart:o=>{a(o.active.id)},onDragEnd:o=>{a(null)}}),Ru.default.createElement("div",{className:"mk-month-grid"},e.header&&Ru.default.createElement(mE,{superstate:e.superstate,date:t,setDate:r,mode:"month"}),Ru.default.createElement("div",{className:"mk-month-header"},Ru.default.createElement("div",null,"S"),Ru.default.createElement("div",null,"M"),Ru.default.createElement("div",null,"T"),Ru.default.createElement("div",null,"W"),Ru.default.createElement("div",null,"T"),Ru.default.createElement("div",null,"F"),Ru.default.createElement("div",null,"S")),n.map((o,s)=>Ru.default.createElement(uCe,{key:s,superstate:e.superstate,date:o,events:e.data,field:e.field,fieldEnd:e.fieldEnd,fieldRepeat:e.fieldRepeat,insertItem:e.insertItem,updateItem:e.updateItem})))};var Os=he(Me());var K8=he(Me());var cCe=e=>{let{source:t}=(0,K8.useContext)(_a),{setNodeRef:r}=ql({id:"allday-"+e.date.toISOString()});return K8.default.createElement("div",{className:"mk-week-view-all-day-cell",ref:r,onClick:i=>{i.stopPropagation(),i.detail===2&&zf(e.superstate,2,je(i.currentTarget.ownerDocument),a=>{e.insertItem(a)},t)},style:{"--block-bg-color":yg(40,"#0098FF"),"--block-color":"#0098FF","--block-text-color":"var(--mk-ui-text-accent)",height:`${e.height*24}px`}},e.children)};var fCe=e=>{let t=e.hourHeight,[r,n]=(0,Os.useState)(e.weekStart??go(new Date)),i=e.startHour??0,a=e.endHour??24,[o,s]=(0,Os.useState)(0),u=(0,Os.useMemo)(()=>{let l=[];e.data.forEach((f,d)=>{let p=da(f[e.field]),h=da(f[e.fieldEnd])??p;h>=r&&p<=Sa(r,{days:7})&&Gn(p).getTime()==p.getTime()&&Gn(h).getTime()==h.getTime()&&l.push({index:d,startDay:new Date(Math.max(r.getTime(),p.getTime())).getDay(),endDay:new Date(Math.min(Sa(r,{days:7}).getTime(),h.getTime())).getDay(),topOffset:0})});let c=0;return l.forEach((f,d)=>{for(let p=0;p=f.endDay&&l[p].topOffset==l[d].topOffset&&(l[d].topOffset+=1,c=Math.max(c,l[d].topOffset))}),s(c),l},[e.data,r,e.field,e.weekStart]);return Os.default.createElement("div",{className:"mk-week-view",style:{"--hour-height":`${t}px`}},e.header&&Os.default.createElement(mE,{superstate:e.superstate,date:r,mode:"week",setDate:n}),Os.default.createElement("div",{className:"mk-week-view-header"},Os.default.createElement("div",{className:"mk-day-view-gutter"}),Array.from({length:7}).map((l,c)=>Os.default.createElement("div",{key:c},_r(e.superstate,Sa(r,{days:c}),"EEE d")))),Os.default.createElement("div",{className:"mk-week-view-all-day"},Os.default.createElement("div",{className:"mk-day-view-gutter"},Os.default.createElement("div",{className:"mk-day-view-hour-title",style:{height:`${o*30}px`}},"all day")),Array.from({length:7}).map((l,c)=>Os.default.createElement(cCe,{key:c,height:o+1,superstate:e.superstate,date:ua(r,c),insertItem:f=>{e.insertItem({[e.field]:_r(e.superstate,ua(r,c),"yyyy-MM-dd"),[e.fieldEnd]:_r(e.superstate,ua(r,c),"yyyy-MM-dd"),[gt]:f})}},u.filter(f=>f.startDay==c).map((f,d)=>Os.default.createElement(Y8,{superstate:e.superstate,data:e.data[f.index],index:f.index,startDay:f.startDay,endDay:f.endDay,topOffset:f.topOffset,key:d}))))),Os.default.createElement("div",{className:"mk-week-view-content"},Os.default.createElement(Z8,{hourHeight:t,startHour:i,endHour:a}),Array.from({length:7}).map((l,c)=>Os.default.createElement(X8,{superstate:e.superstate,key:_r(e.superstate,Sa(r,{days:c})),field:e.field,fieldEnd:e.fieldEnd,fieldRepeat:e.fieldRepeat,date:Sa(r,{days:c}),data:e.data,hourHeight:t,startHour:i,endHour:a,insertItem:f=>{e.insertItem(f)},updateItem:f=>{e.updateItem(f)}}))))};var dCe=he(xi()),Lo=he(Me());var Jet=e=>e.node.type=="column"&&e.children.length==1,ett=e=>e.node.type=="container"&&e.children.length==1,ttt=e=>e.node.type=="container"&&e.children.length==2,JD=(e,t,r,n,i)=>{let a=e;if(a.schemaId!=r.id){a=nl("$root",r.id,a,r.id);let d=Ri(a.id,n.map(p=>p.id));a=nl(a.id,d,a,r.id),a.id=d,a.schemaId=r.id}let o=[],s=[];if(a.id==t.id)return[[],[]];let u=r.node.schemaId,l=Oc(r,t.id),c=Oc(r,a.id);if(!l)return[[],[]];let f=t.node.type=="column";if(i=="inside"){let d={...a,parentId:t.node.id};o.push(d)}else if(f||r.editorProps.editMode==1&&t.node.parentId==r.id&&(i=="left"||i=="right")){let d=t.node.parentId==r.id,p=t.node.type=="container",h=t.node.type=="column",m=!1;h&&l.node.parentId==r.id&&(m=!0);let g=d&&!p,A=d&&p||h&&m;if(g){let b={...Dy(ole,l.id,n,u),rank:t.node.rank},v={...Dy(FT,b.id,[...n,b],u),rank:i=="left"?1:0},x={...Dy(FT,b.id,[...n,b,v],u),rank:i=="left"?0:1},w=[b,v,x,{...t.node,rank:0,parentId:v.id}];o.push(...w,{...a,rank:0,parentId:x.id})}else if(A){let b=p?t.id:t.node.parentId,v={...Dy(FT,b,n,u),rank:i=="left"?p?0:t.node.rank:p?t.children.length:t.node.rank+1},x=[v,{...a,parentId:v.id}];o.push(...x)}}else{let d=n.filter(A=>A.parentId==l.id&&A.id!=a.id).sort((A,b)=>A.rank-b.rank).map((A,b)=>({...A,rank:b})),p=d.find(A=>A.id==t.id)?.rank??0,h=i=="bottom"||i=="right"?p+1:p,m={...a,parentId:t.node.parentId},g=Hx(d,h,m).map((A,b)=>({...A,rank:b}));o.push(...g)}if(c&&Jet(c)){let d=Oc(r,c.id);if(s.push(c.node),ett(d))s.push(d.node);else if(ttt(d)){let p=d.children.filter(m=>m.id!=c.id);s.push(...p.map(m=>m.node),d.node);let h=p.flatMap(m=>m.children.map(g=>({...g.node,parentId:r.id,rank:d.node.rank})));h.push(...o.filter(m=>p.some(g=>g.id==m.parentId))),o=[...o.map(m=>h.some(g=>g.id==m.id)?{...m,parentId:r.id}:m),...h.filter(m=>!o.some(g=>m.id==g.id))]}}return[o,s]};var $u=he(Me());var J8=e=>{let{spaceInfo:t}=(0,$u.useContext)(ar),{undoLastAction:r,redoAction:n,frameSchema:i}=(0,$u.useContext)(va),{nodes:a,addNode:o,saveNodes:s,setLastCreatedId:u}=(0,$u.useContext)(Oi),{hoverNode:l,setHoverNode:c,instance:f,id:d}=(0,$u.useContext)(vi),{selectionMode:p,selection:h,select:m}=(0,$u.useContext)(ji),g=()=>{c(null)};Da({onDragOver:({active:v,over:x})=>{let w=x?.data.current.node;x?.data.current.root==d?w&&c({id:x?.data.current.id,node:x?.data.current.node,direction:x?.data.current?.direction}):c(null)},onDragCancel:()=>{g()},onDragEnd:({active:v,over:x})=>{if(!v||!l){g();return}let w=l?.node;if(w==v.data.current.id||l?.id!=x.data.current.id){g();return}let k=Oc(f.exec,w)?.children.find(M=>M.id==w);if(v.data.current.type=="node"){let O=Oc(f.exec,v.data.current.node)?.children.find(D=>D.id==v.data.current.node);if(k&&O){let[D,N]=JD(O.node,k,f.exec,a,l.direction);s(D,N)}}else if(v.data.current.type=="property"){if(v.data.current.path==t.path&&k){let[M,O]=JD(A(v.data.current.property,v.data.current.context),k,f.exec,a,l.direction);s(M,O)}}else if(v.data.current.type=="listItem"){if(k){let[M,O]=JD({...zi.node,props:{value:`'${v.data.current.contexts?.$context?._keyValue}'`}},k,f.exec,a,l.direction);s(M,O)}}else if(v.data.current.type=="context"&&k){let M=e.superstate.spacesIndex.get(v.data.current.space);if(M){let[O,D]=JD({...xf.node,props:{value:mr(cb(M,v.data.current.schema))}},k,f.exec,a,l.direction);s(O,D)}}g()}});let A=(v,x)=>{let w=Yr.node;return v.type=="boolean"?w={...Ty.node,styles:{...Ty.node.styles,as:"'checkbox'"}}:v.type=="link"||v.type=="context"||v.type=="file"?w=zi.node:v.type=="image"&&(w=Wl.node),w.type=="input"?w={...w,props:{...w.props,value:mr(v.name)}}:x.length>0?w={...w,props:{...w.props,value:`$contexts['${x}']['${v.name}']`}}:w={...w,props:{...w.props,value:`${i.id}.props['${v.name}']`}},w},b=(0,$u.useCallback)(v=>{if(v.key=="ArrowUp"&&h.length>0){let x=a.find(w=>w.id==h[0]);if(x){let w=Oc(f.exec,x.id);if(w){let S=w.children.find(k=>k.id==x.id).node.rank;S>0&&m(w.children.find(k=>k.node.rank==S-1)?.id)}}}if(v.key=="ArrowDown"&&h.length>0){let x=a.find(w=>w.id==h[0]);if(x){let w=Oc(f.exec,x.id);if(w){let S=w.children.find(k=>k.id==x.id).node.rank;Sk.node.rank==S+1)?.id)}}}(v.key=="Delete"||v.key=="Backspace")&&h.length>0&&s([],h.map(x=>a.find(w=>w.id==x)).filter(x=>x)),v.key=="z"&&v.metaKey&&(v.shiftKey?n():r())},[h,a,r,n,s]);return(0,$u.useEffect)(()=>(e.superstate.ui.inputManager.on("keydown",b),()=>{e.superstate.ui.inputManager.off("keydown",b)}),[b]),$u.default.createElement($u.default.Fragment,null,f.exec&&$u.default.createElement("div",{className:"mk-f-root",style:{position:"relative"}},p>=3&&$u.default.createElement("div",{className:"mk-f-root-label",onClick:v=>{m(f.exec.id),v.stopPropagation()}},f.exec.node.name),$u.default.createElement(ZD,{key:t.path,superstate:e.superstate,treeNode:f.exec,instance:f,containerRef:e.containerRef},e.children),f.exec.children.length==0&&$u.default.createElement(V8,{superstate:e.superstate,treeNode:null,state:null})))};var eO=e=>{let[t,r]=(0,Lo.useState)(e.contexts);(0,Lo.useEffect)(()=>r(g=>dCe.default.isEqual(e.contexts,g)?g:e.contexts),[e.contexts]);let{spaceInfo:n}=(0,Lo.useContext)(ar),{dbSchema:i}=(0,Lo.useContext)(_a),{setDragNode:a}=(0,Lo.useContext)(vh),o=Lo.default.useRef(null),{attributes:s,listeners:u,active:l,setNodeRef:c,transform:f,isDragging:d,transition:p,isOver:h,over:m}=roe({id:e.id,data:{id:e.id,type:e.type,space:n?.path,schema:i?.id,props:e.props,contexts:t},disabled:e.type!="listItem"||e.editMode>0,animateLayoutChanges:WU});return Da({onDragStart:g=>{g.active.data.current.id==e.id&&a(Lo.default.createElement("div",{dangerouslySetInnerHTML:{__html:o.current.innerHTML}}))},onDragOver:g=>{},onDragEnd:({active:g,over:A})=>{let b=A&&A.data.current.space==n?.path&&A.data.current.schema==i?.id;rtt(b,A,e,g,n)}}),e.editMode>=1&&e.uri.authority!="$kit"?Lo.default.createElement(Lv,{superstate:e.superstate,id:e.id,editMode:e.editMode,selected:e.editMode==3},Lo.default.createElement(vg,{id:e.id,superstate:e.superstate,props:e.props,propSetters:e.propSetters,contexts:t,editable:!0},Lo.default.createElement(J8,{superstate:e.superstate,containerRef:e.containerRef},e.children))):Lo.default.createElement(Lo.default.Fragment,null,m?.id==e.id&&l.data.current.type==e.type&&!(l.data.current.space==n?.path&&l.data.current.schema==i?.id&&l.data.current.props?._groupValue==e.props?._groupValue)&&Lo.default.createElement(vg,{id:e.id,superstate:e.superstate,props:e.props,propSetters:e.propSetters,contexts:t,editable:!1},Lo.default.createElement(Cb,{superstate:e.superstate})),Lo.default.createElement("div",{ref:g=>{c(g),o.current=g},...s,...u,style:{transform:$l.Transform.toString(f),transition:p}},Lo.default.createElement(vg,{id:e.id,superstate:e.superstate,props:e.props,propSetters:e.propSetters,contexts:t,editable:!1},Lo.default.createElement(Cb,{superstate:e.superstate},e.children))))},rtt=async(e,t,r,n,i)=>{if(e&&t.id==r.id)if(n.data.current.schema==Fr){let a=n.data.current.contexts?.$context?._keyValue,o=t.data.current.contexts?.$context,s=r.props?._groupValue!=n.data.current.props?._groupValue;a&&o&&(s?mi(r.superstate,a,{[r.props?._groupField]:r.props?._groupValue}):cS(r.superstate,a,o._index,i.path))}else{let a=t.data.current.contexts?.$context;ewe(r.superstate.spaceManager,i,n.data.current.schema,n.data.current.contexts?.$context?._index,r.props?._groupField,r.props?._groupValue,a?._index)}};var Co=he(Me());var hE=he(Me()),pCe=e=>{let t=(0,hE.useRef)(null);return(0,hE.useEffect)(()=>{let r=new IntersectionObserver(n=>{n[0].isIntersecting&&e.onScroll()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t]),hE.default.createElement("div",{ref:t})};var AE=he(Me());var Ob=e=>{let{selected:t}=(0,AE.useContext)(ji);return e.editMode>=1&&e.uri.authority!="$kit"?AE.default.createElement(Mv,{superstate:e.superstate,schema:e.uri.ref},AE.default.createElement(KEe,{superstate:e.superstate,cols:e.cols,editMode:e.editMode},e.children)):AE.default.createElement(V9,{superstate:e.superstate,path:e.uri,cols:e.cols},e.children)};var mCe=e=>{let{editSection:t,selectedIndex:r,setSelectedIndex:n,groupURI:i,itemURI:a}=e,{readMode:o}=(0,Co.useContext)(qr),{spaceInfo:s}=(0,Co.useContext)(ar),{predicate:u,filteredData:l,editMode:c,sortedColumns:f,contextTable:d,cols:p,dbSchema:h,source:m}=(0,Co.useContext)(_a),[g,A]=(0,Co.useState)(1),b=25,{instance:v}=(0,Co.useContext)(vi),x=u?.groupBy?.length>0?p.find(C=>C.name+C.table==u.groupBy[0]):null,w=(0,Co.useMemo)(()=>{let C=v?.state[v?.root?.id].props?.groupOptions;return C?gu(C):x?Pr(["",...(Hr(x.value,x.type,e.superstate)?.options??[]).map(I=>I.value),...l.reduce((I,L)=>[...I,L[x.name+x.table]??""],[])]):[""]},[x,l,v]),S=(0,Co.useMemo)(()=>{let C=v?.state[v?.root?.id].props?.groupFilter;return Ui[C]??Ui.is},[v]),k=(0,Co.useMemo)(()=>w.reduce((C,_)=>{let[I,L]=C;if(!x)return[_==""?{...I,[_]:l.map((T,W)=>({...T,_pageId:L+W}))??[]}:{...I,[_]:[]},L+l.length];let $=l.filter(T=>S.fn(T[x.name+x.table],_));return[$.length>0?{...I,[_]:$.map((T,W)=>({...T,_pageId:L+W}))}:{...I,[_]:[]},L+$.length]},[{},0])[0],[l,w,S,x]),M=(0,Co.useMemo)(()=>p.find(C=>C.primary=="true")?.name,[p]),O=(0,Co.useMemo)(()=>f.filter(C=>!u?.colsHidden.includes(C.name)),[u,f]),D={_path:m,_schema:h?.id,_key:M,_properties:O},N=(0,Co.useMemo)(()=>h?h?.primary=="true"?l.reduce((C,_)=>({...C,[_._index]:{$context:{_index:_._index,_keyValue:_[M],_schema:h.id,_name:e.superstate.pathsIndex.get(_[M])?.name,...D},$properties:p,[s.path]:p.reduce((I,L)=>({...I,[L.name]:_[L.name]}),{}),...Object.keys(d).reduce((I,L)=>({...I,[L]:d[L].cols.reduce(($,T)=>({...$,[T.name]:_[T.name+L]}),{})}),{})}}),{}):l.reduce((C,_)=>({...C,[_._index]:{$context:{_index:_._index,_keyValue:_[M],_schema:h.id,_name:_[M],...D},$properties:p,[s.path]:p.reduce((I,L)=>({...I,[L.name]:_[L.name]}),{})}}),{}):{},[l,p,d]);return Co.default.createElement(Ob,{superstate:e.superstate,uri:i,editMode:t=="listGroup"?c:0,cols:[]},Co.default.createElement(UU,{items:Object.keys(k).map((C,_)=>s.path+"listGroup"+_),strategy:K6},Object.keys(k).map((C,_)=>Co.default.createElement(eO,{key:"listGroup"+_,id:s.path+"listGroup"+_,type:"listGroup",superstate:e.superstate,uri:i,props:{_selectedIndex:r,_groupValue:C,_groupField:x?.name,_groupType:x?.type,_readMode:o,...u.listGroupProps},propSetters:null,editMode:t=="listGroup"?c:0,cols:[],containerRef:e.containerRef,contexts:{$context:D}},Co.default.createElement(Ob,{uri:a,superstate:e.superstate,cols:[],editMode:t=="listItem"?c:0},Co.default.createElement(UU,{items:k[C].flatMap((I,L)=>s.path+"listGroup"+_+"_listItem"+L),strategy:K6},k[C].filter(I=>parseInt(I._pageId)<=g*b).map((I,L)=>parseInt(I._pageId)==g*b?Co.default.createElement(pCe,{key:L,onScroll:()=>A($=>$+1)}):Co.default.createElement(eO,{key:"listGroup"+_+"_listItem"+L,id:s.path+"listGroup"+_+"_listItem"+L,type:"listItem",uri:a,superstate:e.superstate,cols:[],props:{_selectedIndex:r,_groupValue:C,_groupField:x?.name,_readMode:o,...u.listItemProps},propSetters:{_selectedIndex:n},containerRef:e.containerRef,editMode:t=="listItem"?c:0,contexts:N[I._index]}))))))))};var dE=e=>{let{pathState:t}=(0,ta.useContext)(qr),{predicate:r,editMode:n,setEditMode:i,dbSchema:a,tableData:o,data:s,updateRow:u}=(0,ta.useContext)(_a),{frameSchema:l}=(0,ta.useContext)(va),[c,f]=(0,ta.useState)(null),[d,p]=(0,ta.useState)(null),[h,m]=(0,ta.useState)(r?{listView:e.superstate.spaceManager.uriByString(SA(r.listView,"spaces://$kit/#*listView"),t.path),listGroup:e.superstate.spaceManager.uriByString(SA(r.listGroup,"spaces://$kit/#*listGroup"),t.path),listItem:e.superstate.spaceManager.uriByString(SA(r.listItem,"spaces://$kit/#*rowItem"),t.path)}:null);(0,ta.useEffect)(()=>{if(!r)return;let A={listView:e.superstate.spaceManager.uriByString(SA(r.listView,"spaces://$kit/#*listView"),t.path),listGroup:e.superstate.spaceManager.uriByString(SA(r.listGroup,"spaces://$kit/#*listGroup"),t.path),listItem:e.superstate.spaceManager.uriByString(SA(r.listItem,"spaces://$kit/#*rowItem"),t.path)};m(b=>hCe.default.isEqual(A,b)?b:A)},[r,t]);let g=A=>{A.key=="Escape"&&p(null),A.key!="Enter"&&(A.key=="ArrowDown"&&(p(b=>b==null?"0":(parseInt(b)+1).toString()),A.preventDefault()),A.key=="ArrowUp"&&(p(b=>b==null||b=="0"?null:(parseInt(b)-1).toString()),A.preventDefault()),A.key=="ArrowLeft",A.key=="ArrowRight")};return o?ta.default.createElement("div",{className:"mk-context-container"},!e.minMode&&ta.default.createElement(H9,{showTitle:e.showTitle,superstate:e.superstate,setView:e.setView}),h?r.view=="table"||r.view=="db"||a?.primary!="true"&&!l?ta.default.createElement(_Se,{superstate:e.superstate}):r.view=="day"?ta.default.createElement(X8,{superstate:e.superstate,field:r.listViewProps?.start||"start",fieldEnd:r.listViewProps?.end||"end",fieldRepeat:r.listViewProps?.repeat,startHour:r.listViewProps?.startOfDay??0,endHour:r.listViewProps?.endOfDay??24,gutter:!0,header:r.listViewProps?.hideHeader!=!0,hourHeight:60,data:s,insertItem:A=>{u(A,-1)},updateItem:A=>{u(A,parseInt(A._index))}}):r.view=="week"?ta.default.createElement(fCe,{superstate:e.superstate,field:r.listViewProps?.start||"start",fieldEnd:r.listViewProps?.end||"end",fieldRepeat:r.listViewProps?.repeat,startHour:r.listViewProps?.startOfDay??0,endHour:r.listViewProps?.endOfDay??24,hourHeight:40,header:r.listViewProps?.hideHeader!=!0,data:s,insertItem:A=>{u(A,-1)},updateItem:A=>{u(A,parseInt(A._index))}}):r.view=="month"?ta.default.createElement(lCe,{superstate:e.superstate,data:s,field:r.listViewProps?.start||"start",fieldEnd:r.listViewProps?.end||"end",fieldRepeat:r.listViewProps?.repeat,header:!0,insertItem:A=>{u(A,-1)},updateItem:A=>{u(A,parseInt(A._index))}}):ta.default.createElement("div",{className:"mk-editor-context",onKeyDown:g},ta.default.createElement(Lv,{superstate:e.superstate,id:"list",editMode:c=="listView"?n:0},n>0&&ta.default.createElement(_2e,{editSection:c,superstate:e.superstate,setEditSection:f,setEditMode:i}),ta.default.createElement(Ob,{superstate:e.superstate,uri:h.listView,cols:[],editMode:c=="listView"?n:0},ta.default.createElement(eO,{superstate:e.superstate,id:"listView",type:"listView",uri:h.listView,props:{_selectedIndex:d,...r.listViewProps},propSetters:{_selectedIndex:p},containerRef:e.containerRef,editMode:c=="listView"?n:0,cols:[],contexts:null},ta.default.createElement(mCe,{superstate:e.superstate,containerRef:e.containerRef,editSection:c,selectedIndex:d,setSelectedIndex:p,groupURI:h.listGroup,itemURI:h.listItem}))))):ta.default.createElement(ta.default.Fragment,null)):ta.default.createElement(ta.default.Fragment,null)};var BZ=e=>gE.default.createElement(Ks,{superstate:e.superstate,path:e.space.path,readMode:!1},gE.default.createElement(gh,{superstate:e.superstate},gE.default.createElement(Mv,{superstate:e.superstate,schema:e.schema},gE.default.createElement(DS,{superstate:e.superstate},gE.default.createElement(dE,{showTitle:!1,superstate:e.superstate})))));var cm={frameSelected:"mkmd-active-frame",frameLayerSelected:"mkmd-frame-layer",refreshView:"mkmd-refresh-view",revealPath:"mkmd-reveal-file",collapseFolders:"mkmd-collapse-folders",toggleBacklinks:"mkmd-toggle-backlinks",metadataChange:"mkmd-tags-change",vaultChange:"mkmd-vault-change",mdbChange:"mkmd-mdb-change",spacesChange:"mkmd-spaces-change",frameChange:"mkmd-frame-change",updateSections:"mkmd-update-sections",settingsChanged:"mkmd-settings-changed"};var Ni=he(Me());var ntt=e=>{let[t,r]=(0,Ni.useState)(null),n=o=>{let s=e.superstate.pathsIndex.get(o),u=[...s.metadata.links??[],...s.metadata.embeds??[]].find(l=>e.source.includes(l.displayText));if(u){let l=s.metadata.sections.find(c=>c.position.start.offset<=u.position.start.offset&&c.position.end.offset>=u.position.end.offset);r([Math.max(1,l.position.start.line),Math.max(l.position.start.line+1,l.position.end.line+1)])}else r([null,null])};(0,Ni.useEffect)(()=>{n(e.path)},[]),(0,Ni.useEffect)(()=>{n(e.path)},[e.path]);let[i,a]=(0,Ni.useState)(!0);return Ni.default.createElement(Ni.default.Fragment,null,Ni.default.createElement("div",{className:"mk-path-backlink-title"},Ni.default.createElement(Pa,{superstate:e.superstate,path:e.path},Ni.default.createElement(Uc,{superstate:e.superstate,collapsed:i,onToggle:o=>a(o)}))),!i&&t?Ni.default.createElement("div",{className:"mk-path-context-backlink"},Ni.default.createElement(Zd,{load:!0,forceNote:!0,superstate:e.superstate,path:e.path,properties:{from:t[0],to:t[1]},classname:"mk-path-context-flow"})):Ni.default.createElement(Ni.default.Fragment,null))},fb=e=>{let[t,r]=(0,Ni.useState)(!e.superstate.settings.inlineBacklinksExpanded),[n,i]=(0,Ni.useState)([]);(0,Ni.useEffect)(()=>{!e.path||i(Pr([...e.superstate.linksMap.getInverse(e.path)]).map(o=>e.superstate.pathsIndex.get(o).path))},[e.path]),(0,Ni.useEffect)(()=>{e.superstate.settings.inlineBacklinksExpanded=!t,e.superstate.saveSettings()},[t]);let a=()=>{r(!t)};return(0,Ni.useEffect)(()=>(window.addEventListener(cm.toggleBacklinks,a),()=>{window.removeEventListener(cm.toggleBacklinks,a)}),[t]),n.length>0&&e.path?Ni.default.createElement("div",{className:"mk-path-context-component mk-note-footer"},Ni.default.createElement("div",{onClick:o=>{r(!t),o.stopPropagation()},className:"mk-path-context-title"},Ni.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//backlink")}}),z.labels.backlinks),Ni.default.createElement("div",{className:"mk-fold"},Ni.default.createElement(Uc,{superstate:e.superstate,collapsed:t,onToggle:o=>a()})),Ni.default.createElement("div",{className:"mk-path-backlinks"},!t&&n.map((o,s)=>Ni.default.createElement(ntt,{path:o,key:s,superstate:e.superstate,source:e.path})))):Ni.default.createElement(Ni.default.Fragment,null)};var Qc=he(Me());var ACe=he(to());var Zn=he(Me());var e7=e=>{let{pathState:t}=(0,Zn.useContext)(qr),{spaceState:r}=(0,Zn.useContext)(ar),n=t?.metadata.property?.aliases??[],[i,a]=(0,Zn.useState)(e.superstate.settings.spacesUseAlias&&n?.[0]?.length>0),o=(0,Zn.useMemo)(()=>t?i?n?.[0]:t.subtype=="tag"?bu(t?.name):t?.name:null,[t,i]);(0,Zn.useEffect)(()=>{e.superstate.settings.spacesUseAlias&&n?.[0]?.length>0?a(!0):a(!1)},[t]);let s=(0,Zn.useRef)(null),u=!e.readOnly&&r?.type!="default",l=A=>{let b=A.target.innerText;if(b!=o){if(t.path=="/"){e.superstate.settings.systemName=b,e.superstate.saveSettings(),e.superstate.reloadPath("/",!0);return}if(i)Xy(e.superstate,t.path,t.metadata?.property?.aliases,b);else{let v=xv(b);Kx(e.superstate,t.path,v).then(x=>{x&&v!=b&&Xy(e.superstate,x,t.metadata?.property?.aliases,b)})}}};(0,Zn.useEffect)(()=>{if(!!s?.current&&s.current.innerText.startsWith("Untitled")){s.current.focus();let A=window.getSelection(),b=document.createRange();b.selectNodeContents(s.current),A.removeAllRanges(),A.addRange(b)}},[]);let c=A=>{A.stopPropagation()},f=A=>{A.stopPropagation()},d=A=>{if(A.stopPropagation(),A.key=="a"&&A.metaKey){A.preventDefault();let b=window.getSelection(),v=document.createRange();v.selectNodeContents(A.target),b.removeAllRanges(),b.addRange(v)}A.key=="Enter"&&(A.target.blur(),A.preventDefault()),A.key=="Escape"&&(A.target.blur(),A.preventDefault())},p=t?.metadata.label?.[e.superstate.settings.fmKeySticker]?.length>0,h=t?.metadata.property?.[e.superstate.settings.fmKeyBanner],m=kc(e.superstate.ui),g=A=>{let b=A.target.getBoundingClientRect(),v=[];p?(v.push({name:z.buttons.changeIcon,icon:"ui//sticker",onClick:x=>e.superstate.ui.openPalette(Zn.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:w=>hS(e.superstate,t.path,w)}),je(x.view.document))}),v.push({name:z.buttons.removeIcon,icon:"ui//sticker",onClick:x=>{AS(e.superstate,t.path)}})):v.push({name:z.buttons.addIcon,icon:"ui//sticker",onClick:x=>e.superstate.ui.openPalette(Zn.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:w=>hS(e.superstate,t.path,w)}),je(x.view.document))}),v.push(Wt),h?(v.push({name:z.buttons.changeBanner,icon:"ui//mk-make-image",onClick:x=>e.superstate.ui.openPalette(Zn.default.createElement(Xl,{superstate:e.superstate,selectedPath:w=>ug(e.superstate,t.path,w)}),je(x.view.document))}),v.push({name:z.labels.reposition,icon:"ui//move",onClick:x=>e.setReposition(w=>!w)}),v.push({name:z.buttons.removeBanner,icon:"ui//file-minus",onClick:x=>{e.superstate.spacesIndex.has(t.path)&&e.superstate.spaceManager.deleteProperty(Mf(e.superstate,e.superstate.spacesIndex.get(t.path).space),e.superstate.settings.fmKeyBanner),e.superstate.spaceManager.deleteProperty(t.path,e.superstate.settings.fmKeyBanner)}})):v.push({name:z.buttons.addCover,icon:"ui//mk-make-image",onClick:x=>e.superstate.ui.openPalette(Zn.default.createElement(Xl,{superstate:e.superstate,selectedPath:w=>ug(e.superstate,t.path,w)}),je(x.view.document))}),v.push(Wt),i?v.push({name:"Edit File Name",icon:"ui//alias",onClick:()=>a(!1)}):v.push({name:"Edit Display Name",icon:"ui//alias",onClick:()=>a(!0)}),e.superstate.ui.openMenu(b,Xt(e.superstate.ui,v),je(A.view.document))};return t&&Zn.default.createElement(Zn.default.Fragment,null,!m&&Zn.default.createElement(itt,{superstate:e.superstate,pathState:t,hasBanner:h,hasSticker:p}),e.superstate.settings.spacesStickers&&p&&Zn.default.createElement("div",{className:"mk-header-icon",style:h?{"--label-color":"var(--mk-ui-background)"}:{}},Zn.default.createElement(g9,{superstate:e.superstate,path:t.path})),Zn.default.createElement("div",{className:"mk-title-container"},t?.subtype=="tag"?Zn.default.createElement("div",{className:"mk-title-prefix"},"#"):"",Zn.default.createElement("div",{ref:s,className:"mk-inline-title inline-title",contentEditable:u,onBlur:l,onDrop:A=>A.preventDefault(),onKeyDown:d,onKeyPress:c,onKeyUp:f,dangerouslySetInnerHTML:{__html:o},"data-ph":i?z.hintText.alias:z.hintText.fileName}),m?Zn.default.createElement("div",{className:"mk-toolbar-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//edit")},onClick:A=>g(A)}):Zn.default.createElement("button",{className:(0,ACe.default)("mk-title-alias",i&&"mk-active"),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//alias")},"aria-label":z.buttons.alias,onClick:()=>a(!i)})))},itt=e=>{let{pathState:t,hasBanner:r,hasSticker:n}=e;return Zn.default.createElement("div",{className:"mk-header-label-actions"},e.superstate.settings.spacesStickers&&!n&&Zn.default.createElement("button",{className:"mk-inline-button",onClick:i=>e.superstate.ui.openPalette(Zn.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:a=>hS(e.superstate,t.path,a)}),je(i.view.document))},Zn.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//smile")}}),z.buttons.addIcon),!r&&Zn.default.createElement("button",{className:"mk-inline-button",onClick:i=>e.superstate.ui.openPalette(Zn.default.createElement(Xl,{superstate:e.superstate,selectedPath:a=>ug(e.superstate,t.path,a)}),je(i.view.document))},Zn.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//mk-make-image")}}),z.buttons.addCover))};var Xn=he(Me());var vE=e=>{let[t,r]=(0,Xn.useState)(!1),{pathState:n}=(0,Xn.useContext)(qr),[i,a]=(0,Xn.useState)(e.superstate.spaceManager.uriByString(n?.metadata.property?.[e.superstate.settings.fmKeyBanner])),o=n.readOnly;(0,Xn.useEffect)(()=>{let k=e.superstate.spaceManager.uriByString(n?.metadata.property?.[e.superstate.settings.fmKeyBanner]),M=n?.metadata.property?.[e.superstate.settings.fmKeySticker]?.length>0;r(M),a(k||null)},[n]);let[s,u]=(0,Xn.useState)(n?.metadata.property?.[e.superstate.settings.fmKeyBannerOffset]?`${(parseFloat(n?.metadata.property?.[e.superstate.settings.fmKeyBannerOffset])*100).toString()}%`:"center"),l=k=>{e.superstate.ui.openPalette(Xn.default.createElement(Xl,{superstate:e.superstate,selectedPath:M=>ug(e.superstate,n.path,M)}),je(k.view.document))},c=k=>{k.preventDefault();let M=[{name:z.buttons.changeBanner,value:"change",icon:"ui//image",onClick:O=>{l(O)}},{name:z.buttons.removeBanner,value:"remove",icon:"ui//file-minus",onClick:O=>{e.superstate.spacesIndex.has(n.path)&&e.superstate.spaceManager.deleteProperty(Mf(e.superstate,e.superstate.spacesIndex.get(n.path).space),e.superstate.settings.fmKeyBanner),e.superstate.spaceManager.deleteProperty(n.path,e.superstate.settings.fmKeyBanner)}}];return e.superstate.ui.openMenu({x:k.clientX,y:k.clientY,width:0,height:0},Xt(e.superstate.ui,M),je(k.view.document)),!1},[f,d]=(0,Xn.useState)(null),p=(0,Xn.useRef)(s=="center"?50:parseFloat(s)),h=(0,Xn.useRef)(s=="center"?50:parseFloat(s)),m=k=>{u(k+"%"),mi(e.superstate,n.path,{[e.superstate.settings.fmKeyBannerOffset]:k.toString()})},[,g]=(0,Xn.useState)([0,0]),A=.5,b=(0,Xn.useCallback)(k=>{g(M=>{let{clientX:O,clientY:D}=k,[N,C]=M,_=O-N,I=C-D,$=A*1,T=Math.sqrt((_+I)/2*(_+I)/2)*$;_+I<0&&(T=-T),T=I*$;let W=p.current+T;return W=Math.max(W,0),W=Math.min(W,100),h.current=W,m(W),M}),k.stopPropagation()},[f,A]),v=(0,Xn.useCallback)(k=>{let M=O=>{O.stopPropagation(),window.removeEventListener("click",M,!0)};window.addEventListener("click",M,!0),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",v),m(h.current),k.preventDefault(),k.stopPropagation()},[b]),x=(0,Xn.useCallback)(k=>{!e.reposition||(p.current=s=="center"?50:parseFloat(s),g([k.clientX,k.clientY]),document.addEventListener("mousemove",b),document.addEventListener("mouseup",v),k.stopPropagation())},[b,v,s,e.reposition]),w=k=>{k.metaKey?d("metaKey"):k.ctrlKey?d("ctrlKey"):k.altKey?d("altKey"):k.shiftKey&&d("shiftKey")},S=()=>{d(null)};return(0,Xn.useEffect)(()=>(document.addEventListener("keydown",w),document.addEventListener("keyup",S),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",v),document.removeEventListener("keydown",w),document.removeEventListener("keyup",S)}),[]),i?Xn.default.createElement(Xn.default.Fragment,null,Xn.default.createElement("div",{className:"mk-space-banner",onContextMenu:!o&&c,style:{"--mk-banner-height":e.superstate.settings.bannerHeight+"px",backgroundImage:`url("${i.scheme=="vault"?e.superstate.ui.getUIPath(i.basePath):i.fullPath}")`,backgroundPositionY:s,cursor:e.reposition?"grab":"inherit"},onMouseDown:x}),e.setReposition&&Xn.default.createElement("div",{className:"mk-space-banner-buttons"},e.reposition?Xn.default.createElement("button",{className:"mk-hover-button",onClick:()=>e.setReposition(!1)},Xn.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//check")}}),z.labels.done):Xn.default.createElement("button",{className:"mk-hover-button",onClick:()=>e.setReposition(!0)},Xn.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//move")}}),z.labels.reposition),Xn.default.createElement("button",{className:"mk-hover-button",onClick:k=>l(k)},Xn.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//edit")}}),z.labels.changeCoverShort),Xn.default.createElement("button",{className:"mk-hover-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//options")},onClick:k=>c(k)})),Xn.default.createElement("div",{className:"mk-spacer",style:{"--mk-header-height":((cr(e.superstate.ui)?1:0)*26+(e.superstate.settings.bannerHeight-62)+(!e.superstate.settings.spacesStickers||e.superstate.settings.inlineContextNameLayout=="horizontal"?50:t?0:40)).toString()+"px"},onContextMenu:k=>k.preventDefault()})):Xn.default.createElement(Xn.default.Fragment,null)};var tO=e=>{let{pathState:t}=(0,Qc.useContext)(qr);(0,Qc.useLayoutEffect)(()=>{e.editorView?.requestMeasure()},[]);let[r,n]=Qc.default.useState(!1);return t&&Qc.default.createElement(Qc.default.Fragment,null,Qc.default.createElement("div",{className:"mk-path-context-component"},Qc.default.createElement("div",{className:`mk-path-context-label ${e.superstate.settings.inlineContextNameLayout=="horizontal"?"mk-path-context-file-horizontal":""}`},Qc.default.createElement(vE,{superstate:e.superstate,reposition:r,setReposition:n}),Qc.default.createElement(e7,{superstate:e.superstate,readOnly:!e.editable,setReposition:n})),e.editable&&e.superstate.settings.inlineContextProperties&&Qc.default.createElement(RS,{superstate:e.superstate,collapseSpaces:!0})))};var Uh=he(xi()),rc=he(Me()),su=(0,rc.createContext)({dragPaths:[],setDragPaths:Uh.default.noop,selectedPaths:[],setSelectedPaths:Uh.default.noop,activePath:null,setActivePath:Uh.default.noop,activeFocus:0,setActiveFocus:Uh.default.noop,activeViewSpaces:[],focuses:[],setFocuses:Uh.default.noop,saveActiveSpace:Uh.default.noop,closeActiveSpace:Uh.default.noop,modifier:null,setModifier:Uh.default.noop,editFocus:!1,setEditFocus:Uh.default.noop}),t7=e=>{let[t,r]=(0,rc.useState)(null),[n,i]=(0,rc.useState)([]),[a,o]=(0,rc.useState)([]),[s,u]=(0,rc.useState)(null),[l,c]=(0,rc.useState)(!1),[f,d]=(0,rc.useState)(e.superstate.focuses),[p,h]=(0,rc.useState)(e.superstate.settings.currentWaypoint),[m,g]=(0,rc.useState)((e.superstate.focuses[p]?.paths??[]).map(S=>e.superstate.pathsIndex.get(S)).filter(S=>S)),A=S=>{let k=e.superstate.focuses[p]??{sticker:"",name:"Waypoint",paths:[]};k.paths=[...k.paths.filter(O=>O!=S),S],p>e.superstate.focuses.length&&e.superstate.spaceManager.saveFocuses([...e.superstate.focuses,k]);let M=e.superstate.focuses.map((O,D)=>D==p?k:O);e.superstate.spaceManager.saveFocuses(M.filter(O=>O))},b=S=>{let k=e.superstate.focuses[p]??{sticker:"",name:"Waypoint",paths:[]};k.paths=[...k.paths.filter(O=>O!=S)],p>e.superstate.focuses.length&&e.superstate.spaceManager.saveFocuses([...e.superstate.focuses,k]);let M=e.superstate.focuses.map((O,D)=>D==p?k:O);e.superstate.spaceManager.saveFocuses(M.filter(O=>O))},v=S=>{e.superstate.spaceManager.saveFocuses(S.filter(k=>k))},x=S=>{e.superstate.focuses[e.superstate.settings.currentWaypoint]?.paths?.includes(S.path)&&g((e.superstate.focuses[e.superstate.settings.currentWaypoint]?.paths??[]).map(k=>e.superstate.pathsIndex.get(k)).filter(k=>k))},w=()=>{d(e.superstate.focuses);let S=e.superstate.settings.currentWaypoint;h(S),g((e.superstate.focuses[S]?.paths??[]).map(k=>e.superstate.pathsIndex.get(k)).filter(k=>k))};return(0,rc.useEffect)(()=>(e.superstate.eventsDispatcher.addListener("spaceStateUpdated",x),e.superstate.eventsDispatcher.addListener("settingsChanged",w),e.superstate.eventsDispatcher.addListener("focusesChanged",w),e.superstate.eventsDispatcher.addListener("superstateUpdated",w),()=>{e.superstate.eventsDispatcher.removeListener("spaceStateUpdated",x),e.superstate.eventsDispatcher.removeListener("settingsChanged",w),e.superstate.eventsDispatcher.removeListener("focusesChanged",w),e.superstate.eventsDispatcher.removeListener("superstateUpdated",w)}),[]),rc.default.createElement(su.Provider,{value:{dragPaths:n,setDragPaths:i,activeFocus:p,selectedPaths:a,setSelectedPaths:o,activePath:s,setActiveFocus:h,setActivePath:u,activeViewSpaces:m,focuses:f,setFocuses:v,saveActiveSpace:A,closeActiveSpace:b,modifier:t,setModifier:r,editFocus:l,setEditFocus:c}},e.children)};var l7=he(Me());var dDe=he(xi());function att(e,t){return e?e.item?.type=="space"&&!e.collapsed&&t?e.depth+1:e.depth:0}function ott(e){return e?Math.max(0,e.depth-1):0}function gCe(e,t){return Math.round(e/t)}var stt=(e,t,r,n)=>{let i=e[r];if(!i)return;let a=i.type=="file"?e.find(o=>o.id==i.parentId):i;return a&&a.type!="file"?{depth:i.depth,overId:i.id,parentId:a.id,sortable:!1,insert:a.collapsed,droppable:!0,copy:n=="link"||n=="copy",reorder:!1}:null};function vCe(e,t,r,n,i,a,o,s,u){if(r.length==0)return null;if(r.length>1)return stt(t,r,n,s);let l=t[n],c=t[n],f=t[n+1];if(!c)return;let d=c.type!="file",p=e.depth>0&&l.collapsed&&d&&(!l.sortable||o&&a<=13||!o&&a>=13),h=l.sortable||d&&!p&&f.sortable,m=i,g=e.depth==0?0:att(c,o),A=ott(c),b=m;m>=g?b=g:mS.id==v);return{depth:b,overId:c.id,parentId:v,sortable:h,insert:p,droppable:x?.type!="file",copy:s=="link"||s=="copy",reorder:p?e?.parentId==l?.id:e?.parentId==x?.id||e?.parentId==u};function w(){return b===0||!c?null:b===c.depth||b>c.depth&&c.item.type!="space"?c.parentId:b>c.depth?c.id:t.slice(0,n).reverse().find(k=>k.depth===b)?.parentId??null}}var yCe=()=>window.navigator.platform.startsWith("Mac")?"\u2325":"Alt";var tn=he(Me());var bCe=he(to());var ns=he(Me());var xCe=e=>{let{saveActiveSpace:t,editFocus:r,activeFocus:n,setFocuses:i,focuses:a,setEditFocus:o}=(0,ns.useContext)(su),[s,u]=(0,ns.useState)(e.focus);return(0,ns.useEffect)(()=>{u(e.focus)},[e.focus]),s&&e.focus?e.focus.name?.length==0||r?ns.default.createElement("div",{className:"mk-path-tree-focus"},ns.default.createElement("div",{className:(0,bCe.default)("mk-focuses-item"),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(s.sticker)},onClick:l=>e.superstate.ui.openPalette(ns.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:c=>{u({...s,sticker:c})}}),je(l.view.document))}),ns.default.createElement("input",{value:s.name,onChange:l=>u({...s,name:l.target.value})}),ns.default.createElement("div",{className:"mk-button-group"},ns.default.createElement("button",{onClick:()=>e.saveFocus(s)},z.buttons.save),ns.default.createElement("button",{onClick:()=>{e.focus.name.length==0?(i(a.filter((l,c)=>c!=n)),e.superstate.saveSettings()):o(!1)}},z.buttons.cancel))):ns.default.createElement("div",{className:"mk-path-tree-empty"},ns.default.createElement("div",{className:"mk-empty-state-title"},"Open a Space"),ns.default.createElement("div",{className:"mk-empty-state-description"},"Open an existing folders and tags as a space or create a new one"),ns.default.createElement("button",{onClick:l=>{zf(e.superstate,2,je(l.view.document),c=>{if(!e.superstate.pathsIndex.has(c)){Tf(e.superstate,c,{}).then(d=>{t(c),e.superstate.ui.openPath(c,!1)});return}t(c)})}},"Open a Space")):ns.default.createElement(ns.default.Fragment,null)};var i7=he(to());var Kn=he(Me());var hn=he(Me()),Yi=he(jCe());var ctt=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]);function yE(e,t){var r=ftt(e);if(typeof r.path!="string"){var n=e.webkitRelativePath;Object.defineProperty(r,"path",{value:typeof t=="string"?t:typeof n=="string"&&n.length>0?n:e.name,writable:!1,configurable:!1,enumerable:!0})}return r}function ftt(e){var t=e.name,r=t&&t.lastIndexOf(".")!==-1;if(r&&!e.type){var n=t.split(".").pop().toLowerCase(),i=ctt.get(n);i&&Object.defineProperty(e,"type",{value:i,writable:!1,configurable:!1,enumerable:!0})}return e}var dtt=[".DS_Store","Thumbs.db"];function $Z(e){return W1(this,void 0,void 0,function(){return H1(this,function(t){return r7(e)&&ptt(e.dataTransfer)?[2,gtt(e.dataTransfer,e.type)]:mtt(e)?[2,htt(e)]:Array.isArray(e)&&e.every(function(r){return"getFile"in r&&typeof r.getFile=="function"})?[2,Att(e)]:[2,[]]})})}function ptt(e){return r7(e)}function mtt(e){return r7(e)&&r7(e.target)}function r7(e){return typeof e=="object"&&e!==null}function htt(e){return RZ(e.target.files).map(function(t){return yE(t)})}function Att(e){return W1(this,void 0,void 0,function(){var t;return H1(this,function(r){switch(r.label){case 0:return[4,Promise.all(e.map(function(n){return n.getFile()}))];case 1:return t=r.sent(),[2,t.map(function(n){return yE(n)})]}})})}function gtt(e,t){return W1(this,void 0,void 0,function(){var r,n;return H1(this,function(i){switch(i.label){case 0:return e.items?(r=RZ(e.items).filter(function(a){return a.kind==="file"}),t!=="drop"?[2,r]:[4,Promise.all(r.map(vtt))]):[3,2];case 1:return n=i.sent(),[2,MCe(TCe(n))];case 2:return[2,MCe(RZ(e.files).map(function(a){return yE(a)}))]}})})}function MCe(e){return e.filter(function(t){return dtt.indexOf(t.name)===-1})}function RZ(e){if(e===null)return[];for(var t=[],r=0;r{let[t,r]=(0,ea.useState)(null),n=(0,ea.useMemo)(()=>e.superstate.spaceManager.uriByString(e.action),[e.action]),i=p=>{if(r(p),n.authority=="$actions"){e.superstate.spaceManager.saveSystemCommand(n.path.split("/").pop(),p);return}e.superstate.spaceManager.saveCommand(n.path,p.schema.id,()=>p)};(0,ea.useEffect)(()=>{r(e.superstate.cli.commandForAction(e.action))},[e.action]),(0,ea.useEffect)(()=>{let p=h=>{h.path==n.basePath&&r(e.superstate.cli.commandForAction(e.action))};return e.superstate.eventsDispatcher.addListener("actionStateUpdated",p),()=>{e.superstate.eventsDispatcher.removeListener("actionStateUpdated",p)}});let a=(p,h)=>(i({...t,fields:[...t.fields,h]}),!0),o=p=>{i({...t,fields:t.fields.filter(h=>h.name!=p.name)})},s=(p,h)=>{i({...t,fields:t.fields.map(m=>m.name==h.name?p:m)})},u=p=>{let h=p.target.getBoundingClientRect();Pf(e.superstate,h,je(p.view.document),{spaces:[],fields:[],saveField:a,schemaId:t.schema.id,fileMetadata:!0,isSpace:!0})},l=[{name:"Actions",value:"actions"},{name:"Script",value:"script"},{name:"Formula",value:"formula"}],c=p=>{let h=Hr(p.value,p.type);if(h)return h?.default},f=(p,h)=>{let m=Hr(p.value,p.type)??{};m.default=h,s({...p,value:JSON.stringify(m)},p)},d=(0,ea.useMemo)(()=>t?.fields.reduce((p,h)=>({...p,[h.name]:c(h)}),{})??{},[t?.fields]);return ea.default.createElement("div",{className:"mk-editor-actions"},t&&ea.default.createElement(ea.default.Fragment,null,ea.default.createElement("div",{className:"mk-props-contexts"},ea.default.createElement("div",{className:"mk-path-context-row"},ea.default.createElement("div",{className:"mk-path-context-field"},"Type"),ea.default.createElement("div",{className:"mk-path-context-value"},ea.default.createElement(Q9,{superstate:e.superstate,options:l,value:t.schema.type,selectValue:p=>i({...t,schema:{...t.schema,type:p}})}))),ea.default.createElement("div",{className:"mk-path-context-row"},ea.default.createElement("div",{className:"mk-path-context-field"},"Properties")),ea.default.createElement("div",{className:"mk-cell-object"},t.fields.map(p=>ea.default.createElement(Ss,{key:p.name,superstate:e.superstate,initialValue:c(p),column:p,editMode:5,updateValue:h=>{f(p,h)},updateFieldValue:(h,m)=>{i({...t,fields:t.fields.map(g=>p.name==g.name?{...g,value:h}:g)})},propertyMenu:h=>{let m=h.target.getBoundingClientRect();yh({superstate:e.superstate,rect:m,win:je(h.view.document),editable:!0,options:[],field:p,fields:t.fields,contextPath:null,saveField:g=>s(g,p),deleteColumn:o})}}))),ea.default.createElement("button",{className:"mk-inline-button",onClick:p=>u(p)},ea.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")}}),z.labels.newProperty)),t.schema.type=="script"?ea.default.createElement(A6e,{superstate:e.superstate,command:t,saveCommand:i,values:d,path:n.path}):t.schema.type=="actions"?ea.default.createElement(tke,{superstate:e.superstate,formula:t.code,path:n.path,saveOutputType:p=>{i({...t,codeType:p})},saveFormula:p=>{i({...t,code:p})},fields:t.fields,value:d}):t.schema.type=="formula"?ea.default.createElement(mh,{superstate:e.superstate,formula:t.code,saveFormula:p=>{i({...t,code:p})},fields:t.fields,value:d,path:n.path}):ea.default.createElement("div",null)))};var rs=he(Me());var Q8=he(Me());var aE=e=>{let t=[];return e.class&&t.push(`${e.class}`),e.layout&&t.push(`mk-layout-${e.layout}`),e.layoutAlign&&t.push(`mk-layout-align-${e.layoutAlign}`),e.layoutWrap&&t.push(`mk-layout-wrap-${e.layoutWrap}`),e.iconSize&&t.push(`mk-icon-size-${e.iconSize}`),e.imageSize&&t.push(`mk-image-size-${e.imageSize}`),t.join(" ")};var ip=he(Me());var oE=he(Me()),M8=e=>{let t=e.state.props.value,r=(0,oE.useMemo)(()=>e.superstate.ui.getUIPath(t),[t]);return e.state?.props.value?.length>0?oE.default.createElement("audio",{controls:!0,preload:"none",src:r}):oE.default.createElement(oE.default.Fragment,null)};var CZ=he(Me()),N8=e=>CZ.default.createElement(CZ.default.Fragment,null,e.children);var sE=he(Me());function Ret(e){return e?.replace(/([^/])#([*^])/g,"$1/#$2")}var T8=e=>{let t=Ret(e.state?.props?.value),{updateNode:r}=(0,sE.useContext)(Oi),{id:n}=(0,sE.useContext)(vi),i=o=>{oo(o,je(o.view.document),e.superstate,s=>r(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(s+"/#^"+Fr)}}))},a=o=>{if(e.treeNode.node.props.value=="$contexts['$space']['space']"){r(e.treeNode.node,{props:{...e.treeNode.node.props,value:`$contexts['$space']['space']+"/#*${o}"`}});return}q5(e.superstate,e.superstate.spaceManager.resolvePath(t,e.source)).then(s=>{r(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(s?.space+"#*"+o)}})})};return e.state&&t?sE.default.createElement(Jv,{id:n,source:e.source,showTitle:!0,superstate:e.superstate,path:t,minMode:e.state?.styles?.["--mk-min-mode"],containerRef:e.containerRef,setFrameSchema:a}):sE.default.createElement("div",{className:"mk-frame-placeholder",onClick:o=>i(o)},z.labels.selectSpace)};var Eo=he(Me());var uo=he(Me()),g6e=he(Ws()),VD=(0,uo.forwardRef)((e,t)=>{let r=(0,uo.useRef)(null),[n,i]=(0,uo.useState)(0),[a,o]=(0,uo.useState)(!1),s=(0,uo.useRef)(null),[u,l]=(0,uo.useState)({x:0,y:0}),[c,f]=(0,uo.useState)(!1),[d,p]=(0,uo.useState)("");(0,uo.useEffect)(()=>{let g=new ResizeObserver(A=>{if(s.current){let b=s.current.getBoundingClientRect();o(!0),l(ZN(r.current.getBoundingClientRect(),b,{width:window.innerWidth,height:innerHeight},"bottom"))}});return s.current&&r.current&&(g.observe(s.current),g.observe(r.current)),()=>{g.disconnect()}},[s.current]);let h=g=>{if((g.key=="Delete"||g.key=="Backspace")&&r.current.innerText==""&&e.onDelete&&e.onDelete(),g.key=="Tab"&&e.sections&&e.onSelectSection&&(g.preventDefault(),g.stopPropagation(),p(A=>{let b=e.sections.findIndex(v=>v.value==A);return g.shiftKey?b==0?A:(e.onSelectSection(e.sections[b-1].value),e.sections[b-1].value):b==e.sections.length-1?A:(e.onSelectSection(e.sections[b+1].value),e.sections[b+1].value)})),g.key=="ArrowUp"){let A=e.suggestions.length-1,b=n<0?A:n-1;e.suggestions[b]?.disabled?i(b<0?A:b-1):i(b),g.preventDefault()}if(g.key=="ArrowDown"){let A=e.suggestions.length-1,b=n>=A?0:n+1;e.suggestions[b]?.disabled?i(b>=A?0:b+1):i(b),g.preventDefault()}g.key=="Enter"&&(e.onSelect(e.suggestions[n]),g.preventDefault())},m={root:"mk-menu-container",rootFocused:"mk-focused",selected:"mk-selected",selectedTagWrapper:"mk-menu-selected-tag-wrapper",selectedTag:"mk-menu-selected-tag",selectedTagName:"mk-menu-selected-tag-name",search:"mk-menu-search",searchWrapper:"mk-menu-search-container",searchInput:"mk-menu-search-input",suggestions:"mk-menu-suggestions",suggestionActive:"mk-active",suggestionDisabled:"mk-disabled"};return uo.default.createElement(uo.default.Fragment,null,uo.default.createElement("div",{ref:g=>{r.current=g,t&&(typeof t=="function"?t(g):t.current=g)},onFocus:()=>{e.onFocus&&e.onFocus(),f(!0)},onBlur:()=>{e.onBlur&&e.onBlur(),f(!1)},"data-placeholder":e.placeholder,onInput:g=>e.onChange(g.currentTarget.innerText),onKeyDown:g=>h(g),className:"mk-suggester",contentEditable:!0}),c&&(0,g6e.createPortal)(uo.default.createElement("div",{ref:s,className:`mk-menu mk-menu-suggester ${a?"mk-ready":""}`,style:{position:"absolute",top:u.y,left:u.x,zIndex:1e3,width:"300px","--mk-menu-max-height":"300px",visibility:c?"visible":"hidden"}},e.sections?uo.default.createElement("div",{className:"mk-menu-sections"},e.sections.map((g,A)=>uo.default.createElement("div",{key:A,onClick:()=>p(g.value),className:`${d==g.value?"is-active":""} mk-menu-section`},g.name==""?z.labels.all:g.name))):uo.default.createElement(uo.default.Fragment,null),uo.default.createElement(q9,{expanded:!1,addKeyword:"Add",options:e.suggestions,query:"",refs:null,hide:()=>null,selectOption:e.onSelect,id:"",onHide:()=>null,classNames:m,index:n,setIndex:i,allowNew:!1,ui:e.superstate.ui,isDisclosureMenu:!1})),document.body))});VD.displayName="Suggester";function $et(e){let t=/!\[!\[(.*?)\]\]/,r=/!!\[\[(.*?)\]\]/,n=e.match(t),i=e.match(r);return n?n[1]:i?i[1]:e}var F8=e=>{let{spaceState:t}=(0,Eo.useContext)(ar),r=(0,Eo.useMemo)(()=>{let m=e.state?.props?.value,g=m?e.superstate.spaceManager.resolvePath($et(m),e.source):null,A=e.superstate.spaceManager.uriByString(m);return A?.scheme=="https"||A?.scheme=="http"?{path:m,label:{sticker:A.scheme,name:A.path,color:""},hidden:!1,subtype:"md",type:"remote",readOnly:!0}:e.superstate.pathsIndex.get(g)},[e.state,e.source]),{updateNode:n,nodes:i}=(0,Eo.useContext)(Oi),{selectionMode:a}=(0,Eo.useContext)(ji),[o,s]=(0,Eo.useState)(e.state?.styles?.["--mk-expanded"]),u=m=>{if(m!=e.state.props?.value)if(e.treeNode.editorProps?.linkedNode){let g=i.find(A=>A.id==e.treeNode.editorProps.linkedNode.node);n(g,{props:{...g.props,[e.treeNode.editorProps.linkedNode.prop]:mr(m)}})}else n(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(m)}})},l=e.state?.styles?.["--mk-link"],{id:c}=(0,Eo.useContext)(vi),[f,d]=(0,Eo.useState)(""),p=(0,Eo.useMemo)(()=>{let m={keys:["name","value"]},g=[...e.superstate.pathsIndex.values()].filter(b=>!b.hidden&&b.subtype=="md"||b.subtype=="space").map(b=>({name:b.label.name,value:b.path,description:b.path,icon:b.label?.sticker})),A=new zc(g,m);return f?.length==0?g:A.search(f).map(b=>b.item)},[f]),h=()=>{s(m=>!m),a>0&&n(e.treeNode.node,{styles:{...e.treeNode.node.styles,"--mk-expanded":(!e.state?.styles?.["--mk-expanded"]).toString()}})};return Eo.default.createElement("div",{className:"mk-node-flow"},!e.state?.styles?.["--mk-min-mode"]&&Eo.default.createElement(Eo.default.Fragment,null,r?Eo.default.createElement("div",{className:"mk-node-link"},Eo.default.createElement(Pa,{superstate:e.superstate,path:r.path},!l&&Eo.default.createElement(Uc,{superstate:e.superstate,collapsed:!o,onToggle:h}))):a>0&&Eo.default.createElement("div",{className:"mk-node-text-placeholder"},Eo.default.createElement(VD,{placeholder:z.hintText.selectNote,onChange:m=>{d(m)},suggestions:p,superstate:e.superstate,onSelect:m=>{u(m.value)}}))),e.state&&o&&(e.state?.props?.value?.length>0?Eo.default.createElement(_8,{id:c,superstate:e.superstate,path:r?.path??e.state?.props?.value,containerRef:e.containerRef,styles:{},readOnly:!0}):Eo.default.createElement("div",{onClick:()=>Un(e.superstate,t,"md",null,!0).then(m=>u(m))},"New Note")))};var TZ=he(to());var zt=he(Me()),tCe=he(Ws());var rp=he(Me()),v6e=e=>{let{groupNodes:t,saveNodes:r,nodes:n}=(0,rp.useContext)(Oi),{selection:i,select:a}=(0,rp.useContext)(ji),o=i.map(s=>n.find(u=>u.id==s)).filter(s=>s);return rp.default.createElement("div",{className:"mk-editor-frame-node-selector",style:{pointerEvents:"auto"},onClick:s=>s.stopPropagation()},rp.default.createElement("div",{className:"mk-mark"},rp.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//copy-check")}}),z.labels.itemsSelected.replace("${1}",i.length.toString())),rp.default.createElement("div",{className:"mk-divider"}),rp.default.createElement("div",{"aria-label":z.editor.createVerticalSection,className:"mk-mark",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//rows")},onClick:()=>t(o,{layoutAlign:'"left"',gap:'"8px"'})}),rp.default.createElement("div",{"aria-label":z.editor.createHorizontalSection,className:"mk-mark",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//columns")},onClick:()=>t(o,{layout:'"row"',gap:'"8px"'})}),rp.default.createElement("div",{className:"mk-divider"}),rp.default.createElement("div",{className:"mk-mark","aria-label":z.menu.delete,onClick:()=>r([],o),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//trash")}}))};var or=he(Me());var qet=e=>{if(e=="table")return{view:"table",listView:"",listGroup:"",listItem:""};if(e=="flow")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*flowListItem"};if(e=="list")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*rowItem"};if(e=="details")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*listGroup",listItem:"spaces://$kit/#*detailItem"};if(e=="board")return{view:"list",listView:"spaces://$kit/#*columnView",listGroup:"spaces://$kit/#*columnGroup",listItem:"spaces://$kit/#*cardListItem"};if(e=="cards")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*gridGroup",listItem:"spaces://$kit/#*cardsListItem"};if(e=="catalog")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*rowGroup",listItem:"spaces://$kit/#*coverListItem"};if(e=="gallery")return{view:"list",listView:"spaces://$kit/#*listView",listGroup:"spaces://$kit/#*masonryGroup",listItem:"spaces://$kit/#*imageListItem"};if(e=="calendar")return{view:"list",listView:"spaces://$kit/#*calendarView",listGroup:"spaces://$kit/#*dateGroup",listItem:"spaces://$kit/#*eventItem"}},uE=async(e,t,r)=>{let n=r=="board"?"Board":"Table",i=await e.spaceManager.tablesForSpace(t);return i&&(n=Ri(n,i.map(o=>o.id))),await e.spaceManager.createTable(t,{id:n,name:n,type:"db"}).then(o=>e.spaceManager.addSpaceProperty(t,{...tw[0],schemaId:n})).then(async o=>{let s=await e.spaceManager.framesForSpace(t),u={id:Ri(n,s?.map(l=>l.id)??[]),name:n,type:"view",predicate:JSON.stringify({...kS,...r?qet(r):{view:"table"}}),def:JSON.stringify({db:n,icon:r=="board"?"ui//square-kanban":"ui//table"})};return await e.spaceManager.createFrame(t,u),u.id})};var P8=(e,t,r,n,i,a={searchable:!0})=>{let o=[{name:z.commands.newNote,value:{type:"preset",value:"note"},section:"default",icon:"ui//mk-make-flow"},{name:z.commands.table,value:{type:"preset",value:"table"},section:"default",icon:"ui//mk-make-table"}],s=[zi,xf,Yr,Wl,MS,ja,un,ale],u=[xh,TS,_S,FS,PS,IS,NS],l=[...o,...s.map(f=>({name:f.node.name,value:{type:"element",value:f},section:"element",icon:f.def?.icon})),...u.map(f=>({name:f.node.name,value:{type:"default",value:f},section:"element",icon:f.def?.icon}))],c=async f=>{if(f.type=="preset")if(f.value=="note"){let d=r.spacesIndex.get(n.path);if(d){let p=await Un(r,d,"md",null,!0);i({...zi.node,props:{value:mr(p)}})}}else if(f.value=="table"){let d=await uE(r,n.path);i({...xf.node,props:{value:mr(`${n.path}/#*${d}`)}})}else f.value=="link";else f.type=="default"?i({...f.value.node,type:"frame",ref:"spaces://$kit/#*"+f.value.def.id}):f.type=="element"&&i({...f.value.node})};r.ui.openMenu(e,{ui:r.ui,multi:!1,editable:!1,value:[],options:l,saveOptions:(f,d)=>c(d[0]),searchable:a.searchable,showAll:!0},t)};var y6e=he(Me());var I8=e=>{let t=(r,n)=>{let i=o=>{e.setValue(o)},a=r.target.getBoundingClientRect();Ql(e.superstate,a,je(r.view.document),e.value,i)};return y6e.default.createElement("div",{className:"mk-color",style:{background:e.value},onClick:r=>{t(r,"--text-normal")}})};var $o=he(Me());var b6e=he(xi()),lo=he(Me());function Let(e){if(Math.floor(e)===e)return 0;let t=e.toString();return t.split(".")[1].length||t.split(",")[1].length||0}function x6e({style:e={},modifiers:t={},onChange:r,onInput:n,...i}){let[a,o]=(0,lo.useState)(i.value),[s,u]=(0,lo.useState)(""),l=(0,lo.useRef)(0),c=(0,lo.useRef)(null),f=i.step?+i.step:1,d=(0,lo.useMemo)(()=>({shiftKey:.1,...t}),[t]),[,p]=(0,lo.useState)([0,0]),h={cursor:"ew-resize",...e},m=k=>{let M=k.target.value;isNaN(+M)||(o(+M),r?.(+M,c.current))},g=(0,b6e.debounce)(k=>{r?.(k,c.current)},200),A=(0,lo.useCallback)(k=>{requestAnimationFrame(()=>{n?.(k,c.current)}),g(k)},[g,n]),b=(0,lo.useCallback)(k=>{p(M=>{let{clientX:O,clientY:D}=k,[N,C]=M,_=N-O,I=C-D,L=1;s&&(L=d[s]||1);let $=f*L,T=Let($),W=Math.sqrt(_*_+I*I)*$;O{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",v)},[b]),x=(0,lo.useCallback)(k=>{let M=+a;isNaN(M)&&(M=+(i.defaultValue||i.min||0)),l.current=M,p([k.clientX,k.clientY]),document.addEventListener("mousemove",b),document.addEventListener("mouseup",v)},[b,v,a,i.min,i.defaultValue]),w=k=>{k.metaKey?u("metaKey"):k.ctrlKey?u("ctrlKey"):k.altKey?u("altKey"):k.shiftKey&&u("shiftKey")},S=()=>{u("")};return(0,lo.useEffect)(()=>{i.value!==a&&typeof i.value=="number"&&o(i.value)},[i.value]),(0,lo.useEffect)(()=>(document.addEventListener("keydown",w),document.addEventListener("keyup",S),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",v),document.removeEventListener("keydown",w),document.removeEventListener("keyup",S)}),[]),lo.default.createElement("input",{placeholder:"auto",type:"number",...i,value:a,style:h,onMouseDown:x,onChange:m,ref:c})}var ba=e=>{let t=e.value&&zl(e.value)?Ea(e.value).match(/^(\d+(?:\.\d+)?)\s?([a-zA-Z%]+)$/):null,r=t?parseInt(t[1]):0,n=t&&t[2]?t[2]:e.units[0],i=a=>{let o=[];e.units.forEach(u=>{o.push({name:u,onClick:()=>{if(u=="%"){e.setValue(mr(`${100}${u}`));return}e.setValue(mr(`${r}${u}`))}})});let s=a.target.getBoundingClientRect();e.superstate.ui.openMenu(s,Xt(e.superstate.ui,o),je(a.view.document))};return lo.default.createElement("div",{className:"mk-setter-step"},lo.default.createElement("span",null,e.name),lo.default.createElement(x6e,{min:e.min,max:e.max,value:r,onKeyDown:a=>{a.key=="Backspace"&&(a.currentTarget.value.length==1&&e.setValue(null),a.stopPropagation())},onChange:a=>{e.setValue(mr(`${a.toString()+n}`))}}),lo.default.createElement("span",{onClick:a=>i(a)},n))};var GD=he(Me()),w6e=e=>{let t=["nw","n","ne","w","m","e","sw","s","se"],[r,n]=(0,GD.useState)(e.state?.styles?.layoutAlign);return GD.default.createElement("div",{className:"mk-editor-alignment-menu"},t.map(i=>GD.default.createElement("div",{className:`mk-editor-alignment-selector ${r==i&&"mk-active"}`,key:"d",onClick:()=>{n(i),e.saveStyleValue("layoutAlign",mr(i))}})))};var S6e=e=>{let{spaceInfo:t}=(0,$o.useContext)(ar),{addNode:r}=(0,$o.useContext)(Oi),{select:n}=(0,$o.useContext)(ji),{selectedNode:i,saveStyleValue:a}=e;return $o.default.createElement($o.default.Fragment,null,$o.default.createElement("div",{className:"mk-editor-frame-node-button-primary",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:o=>{P8(o.target.getBoundingClientRect(),je(o.view.document),e.superstate,t,s=>r(s,e.selectedNode,!0).then(u=>n(u.id))),o.stopPropagation()}}),$o.default.createElement(Bo,{icon:"ui//arrow-right",superstate:e.superstate,name:z.editor.rows,value:i.styles?.layout,setValue:o=>a("layout",o),onValue:"'row'",defaultValue:"'row'"}),$o.default.createElement(Bo,{icon:"ui//arrow-down",superstate:e.superstate,name:z.editor.columns,value:i.styles?.layout,setValue:o=>a("layout",o),onValue:"'column'",defaultValue:"'column'"}),$o.default.createElement(Bo,{icon:"ui//layout-dashboard",superstate:e.superstate,name:z.editor.gallery,value:i.styles?.layout,setValue:o=>a("layout",o),onValue:"'masonry'",defaultValue:"'masonry'"}),$o.default.createElement("div",{className:"mk-divider"}),e.state.styles?.layout=="row"||e.state.styles?.layout=="column"?$o.default.createElement($o.default.Fragment,null,$o.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:o=>{e.superstate.ui.openCustomMenu(o.target.getBoundingClientRect(),$o.default.createElement(w6e,{...e}),{...e},je(o.view.document))},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//grid")}}),$o.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:o=>{o.preventDefault(),o.stopPropagation(),a("flexWrap",`${Ea(i.styles.flexWrap)=="wrap"?"":mr("wrap")}`)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//wrap-text")}}),$o.default.createElement(ba,{superstate:e.superstate,name:z.editor.gap,value:i.styles?.gap,setValue:o=>a("gap",o),units:["px"]})):$o.default.createElement($o.default.Fragment,null,$o.default.createElement(ba,{superstate:e.superstate,name:z.editor.columns,value:i.styles?.columnCount,min:0,setValue:o=>a("columnCount",o),units:[""]})))};var Sb=he(Me());var bb=he(Me());var E6e=e=>{let{selectedNode:t,saveStyleValue:r}=e;return bb.default.createElement(bb.default.Fragment,null,bb.default.createElement("div",{className:"mk-divider"}),bb.default.createElement(ba,{superstate:e.superstate,name:z.editor.width,min:0,value:t.styles?.width,setValue:n=>r("width",n),units:["px","%","em"]}),bb.default.createElement("div",{className:"mk-divider"}),bb.default.createElement(ba,{superstate:e.superstate,name:z.editor.height,min:0,value:t.styles?.height,setValue:n=>r("height",n),units:["px","%","em"]}))};var Cg=he(Me());var xb=he(Me());var k6e=e=>{let{selectedNode:t,saveStyleValue:r}=e;return xb.default.createElement(xb.default.Fragment,null,xb.default.createElement(ba,{superstate:e.superstate,name:z.editor.marginLeft,value:t.styles?.marginLeft,setValue:n=>r("marginLeft",n),units:["px","em"]}),xb.default.createElement(ba,{superstate:e.superstate,name:z.editor.marginTop,value:t.styles?.marginTop,setValue:n=>r("marginTop",n),units:["px","em"]}),xb.default.createElement(ba,{superstate:e.superstate,name:z.editor.marginRight,value:t.styles?.marginRight,setValue:n=>r("marginRight",n),units:["px","em"]}),xb.default.createElement(ba,{superstate:e.superstate,name:z.editor.marginBottom,value:t.styles?.marginBottom,setValue:n=>r("marginBottom",n),units:["px","em"]}))};var wb=he(Me());var C6e=e=>{let{selectedNode:t,saveStyleValue:r}=e;return wb.default.createElement(wb.default.Fragment,null,wb.default.createElement(ba,{superstate:e.superstate,name:z.editor.paddingLeft,value:t.styles?.paddingLeft,setValue:n=>r("paddingLeft",n),units:["px","em"]}),wb.default.createElement(ba,{superstate:e.superstate,name:z.editor.paddingTop,min:0,value:t.styles?.paddingTop,setValue:n=>r("paddingTop",n),units:["px","em"]}),wb.default.createElement(ba,{superstate:e.superstate,name:z.editor.paddingRight,min:0,value:t.styles?.paddingRight,setValue:n=>r("paddingRight",n),units:["px","em"]}),wb.default.createElement(ba,{superstate:e.superstate,name:z.editor.paddingBottom,min:0,value:t.styles?.paddingBottom,setValue:n=>r("paddingBottom",n),units:["px","em"]}))};var D6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=a=>{let o=a.target.getBoundingClientRect();return e.superstate.ui.openCustomMenu(o,Cg.default.createElement(C6e,{...e}),e,je(a.view.document))},i=a=>{let o=a.target.getBoundingClientRect();return e.superstate.ui.openCustomMenu(o,Cg.default.createElement(k6e,{...e}),e,je(a.view.document))};return Cg.default.createElement(Cg.default.Fragment,null,Cg.default.createElement(ba,{superstate:e.superstate,name:z.editor.margin,value:t.styles?.margin,setValue:a=>r("margin",a),units:["px","em"]}),Cg.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:a=>{i(a)}}),Cg.default.createElement(ba,{superstate:e.superstate,name:z.editor.padding,min:0,value:t.styles?.padding,setValue:a=>r("padding",a),units:["px","em"]}),Cg.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:a=>{n(a)}}))};var O6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=(i,a)=>{let o=a=="icon"?"iconSize":"imageSize",s=[];s.push({name:z.labels.styleSmall,icon:"type",onClick:()=>{r(o,"'s'")}}),s.push({name:z.labels.styleMedium,icon:"type",onClick:()=>{r(o,"'m'")}}),s.push({name:z.labels.styleLarge,icon:"type",onClick:()=>{r(o,"'l'")}});let u=i.target.getBoundingClientRect();e.superstate.ui.openMenu(u,Xt(e.superstate.ui,s),je(i.view.document))};return Sb.default.createElement(Sb.default.Fragment,null,Sb.default.createElement("div",{className:"mk-divider"}),Sb.default.createElement(D6e,{...e}),Sb.default.createElement(E6e,{...e}),Sb.default.createElement("div",{className:"mk-divider"}))};var B8=he(Me());var j6e=e=>{let{selectedNode:t,saveStyleValue:r}=e;return B8.default.createElement(B8.default.Fragment,null,B8.default.createElement(Bo,{superstate:e.superstate,name:z.editor.minimize,value:t.styles?.["--mk-min-mode"],defaultValue:"false",onValue:"true",icon:"ui//panel-top-close",setValue:n=>r("--mk-min-mode",n)}))};var M6e=he(to());var qo=he(Me());var N6e=e=>{let{selectedNode:t,pathState:r,savePropValue:n,frameProps:i,fields:a,frameProperties:o,instance:s}=e,u=(d,p)=>{d.preventDefault();let h=zl(i?.[p.name]),m=[];h||(m.push({name:z.editor.unlinkProperty,icon:"ui//unplug",onClick:()=>{n(p.name,mr(e.state.props?.[p.name]))}}),m.push(Wt));let g=[p.type];g.push("fileprop"),(p.type=="image"||p.type=="link"||p.type=="context")&&(g.push("file"),g.push("link"),g.push("image"),g.push("context"));let A=v=>v=="$space"?z.editor.currentSpace:v;Object.keys(s.state.$contexts).forEach(v=>{twe(e.superstate,v).forEach(x=>{v!=s.state.$contexts?.$context?._path&&x.primary=="true"||(g.includes(x.type)&&m.push({name:Yo(x,e.superstate),icon:qi(x),description:A(v),onClick:()=>{n(p.name,`$contexts['${v}']['${x.name}']`)}}),(x.type=="link"||x.type=="image"||x.type=="file")&&(p.type=="icon"&&m.push({name:`${Yo(x,e.superstate)} Sticker`,icon:qi(x),description:A(v),onClick:()=>{n(p.name,`$api.path.label($contexts['${v}']['${x.name}'])?.sticker`)}}),p.type=="text"&&m.push({name:z.editor.linkName.replace("${1}",Yo(x,e.superstate)),icon:qi(x),description:A(v),onClick:()=>{n(p.name,`$api.path.label($contexts['${v}']['${x.name}'])?.name`)}}),p.type=="image"&&m.push({name:z.editor.linkThumbnail.replace("${1}",Yo(x,e.superstate)),icon:qi(x),description:A(v),onClick:()=>{n(p.name,`$api.path.label($contexts['${v}']['${x.name}'])?.thumbnail`)}})))}),m.push(Wt)}),o.filter(v=>g.some(x=>x==v.type)).forEach(v=>{m.push({name:v.name,icon:qi(v),onClick:()=>{n(p.name,`${v.schemaId}.props['${v.name}']`)}})}),m.push(Wt),o.filter(v=>v.type!=p.type).forEach(v=>{(v.type=="link"||v.type=="image"||v.type=="file")&&(p.type=="icon"&&m.push({name:z.editor.linkSticker.replace("${1}",Yo(v,e.superstate)),icon:qi(v),onClick:()=>{n(p.name,`$api.path.label(${v.schemaId}.props['${v.name}'])?.sticker`)}}),p.type=="image"&&m.push({name:z.editor.linkThumbnail.replace("${1}",v.name),icon:qi(v),onClick:()=>{n(p.name,`$api.path.label(${v.schemaId}.props['${v.name}'])?.thumbnail`)}})),p.type=="text"&&(v.type=="link"||v.type=="file")&&m.push({name:z.editor.linkName.replace("${1}",Yo(v,e.superstate)),icon:qi(v),onClick:()=>{n(p.name,`$api.path.label(${v.schemaId}.props['${v.name}'])?.name`)}})});let b=d.target.getBoundingClientRect();e.superstate.ui.openMenu(b,Xt(e.superstate.ui,m),je(d.view.document),"bottom")},l=d=>o?.find(h=>h.name==eh(i?.[d])?.prop),c=(d,p)=>{if(!d||!p)return null;if(d.type.startsWith("object"))return HW(p);if(d.type=="option")return(Hr(d.value,d.type,e.superstate,r.path).options??[]).find(g=>g.value==Ea(p))?.name??null;if(d.type=="super"){let h=Hr(d.value,d.type,e.superstate);if(h.dynamic?Ea(i[h.field??""]):h.field)return p}return zl(p)?Ea(p):null},f=d=>d.type.startsWith("object")||d.type=="super";return qo.default.createElement("div",{className:"mk-editor-frame-properties"},qo.default.createElement("div",{className:"mk-editor-actions-name"},qo.default.createElement("div",{className:"mk-editor-actions-name-icon"},qo.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//list")}})),qo.default.createElement("div",{className:"mk-editor-actions-name-text"},z.buttons.editProperty),qo.default.createElement("span",null),qo.default.createElement("div",{className:"mk-icon-small mk-inline-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//close")},onClick:()=>e.hide()})),qo.default.createElement("div",{className:"mk-props-contexts"},a.map((d,p)=>{let h=d.type.startsWith("object")?DT(i?.[d.name],d.type):d.type=="super"||zl(i?.[d.name]),m=f(d);return qo.default.createElement(qo.default.Fragment,{key:p},h?qo.default.createElement(Ss,{initialValue:c(d,i?.[d.name]),column:d,compactMode:!1,superstate:e.superstate,editMode:3,row:e.state?.props,updateValue:g=>{Qx(d)?n(d.name,g):n(d.name,mr(g))},linkProp:g=>u(g,d),source:r.path,columns:o}):qo.default.createElement("div",{className:(0,M6e.default)("mk-path-context-row",m&&"mk-path-context-stacked")},d.type=="input"?qo.default.createElement(E9,{initialValue:i?.[d.name],superstate:e.superstate,compactMode:!0,property:d,editMode:3,saveValue:g=>n(d.name,mr(g)),columns:o}):qo.default.createElement(qo.default.Fragment,null,qo.default.createElement(iD,{path:r.path,superstate:e.superstate,property:d,draggable:!0}),qo.default.createElement("div",{className:"mk-active"},qo.default.createElement("div",{"aria-label":z.editor.linkedProperty},pC(i?.[d.name])))),qo.default.createElement("span",null),!m&&qo.default.createElement("div",{"aria-label":z.editor.linkProperty,className:"mk-icon-small mk-inline-button",onClick:g=>u(g,d),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plug")}})))})))};var lE=he(Me());var e1=he(Me());var T6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=a=>{let o=[];o.push({name:z.editor.strokeNone,icon:"ui//type",onClick:()=>{r("outlineStyle","'none'")}}),o.push({name:z.editor.strokeSolid,icon:"ui//type",onClick:()=>{r("outlineStyle","'solid'")}}),o.push({name:z.editor.strokeDashed,icon:"ui//type",onClick:()=>{r("outlineStyle","'dashed'")}}),o.push({name:z.editor.strokeDotted,icon:"ui//type",onClick:()=>{r("outlineStyle","'dotted'")}});let s=a.target.getBoundingClientRect();e.superstate.ui.openMenu(s,Xt(e.superstate.ui,o),je(a.view.document))},i=(a,o)=>{let s=l=>{r(o,`'${l}'`)},u=a.target.getBoundingClientRect();Ql(e.superstate,u,je(a.view.document),Ea(t.styles?.[o]),s)};return e1.default.createElement(e1.default.Fragment,null,e1.default.createElement("div",{className:"mk-divider"}),e1.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:a=>n(a)},e1.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//case-sensitive")}}),e.state.styles?.outlineStyle??z.labels.none),e1.default.createElement(ba,{superstate:e.superstate,name:z.editor.size,value:e.state.styles?.outlineWidth,setValue:a=>r("outlineWidth",a),units:["px","em"]}),e1.default.createElement("div",{onClick:a=>{i(a,"outlineColor")},className:"mk-color",style:{background:e.state.styles?.outlineColor}}))};var F6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=(i,a)=>{let o=u=>{r(a,`'${u}'`)},s=i.target.getBoundingClientRect();Ql(e.superstate,s,je(i.view.document),Ea(e.selectedNode.styles?.[a]),o)};return lE.default.createElement(lE.default.Fragment,null,lE.default.createElement("div",{className:"mk-color",onClick:i=>n(i,"background"),style:{background:Ea(e.selectedNode.styles?.background)}}),lE.default.createElement(T6e,{...e}),lE.default.createElement(ba,{superstate:e.superstate,name:z.editor.opacity,min:0,max:100,value:t.styles?.opacity,setValue:i=>r("opacity",i),units:["%"]}))};function _6e(){let{fonts:e}=document,t=e.entries(),r=[],n=!1;for(;!n;){let i=t.next();i.done?n=i.done:r.push(i.value[0].family)}return Array.from(new Set(r))}var iu=he(Me());var P6e=e=>{let{selectedNode:t,saveStyleValue:r}=e,n=o=>{let s=_6e().map(u=>({name:u,value:u}));e.superstate.ui.openMenu(o.target.getBoundingClientRect(),{ui:e.superstate.ui,multi:!1,editable:!1,searchable:!0,saveOptions:(u,l)=>{r("--font-text",`'${l[0]}'`)},value:[t.styles?.["--font-text"]??""],options:s},je(o.view.document))},i=(o,s)=>{o.stopPropagation(),o.preventDefault(),r("textAlign",`'${s}'`)},a=(o,s)=>{let u=c=>{r(s,`'${c}'`)},l=o.target.getBoundingClientRect();Ql(e.superstate,l,je(o.view.document),Ea(e.selectedNode.styles?.[s]),u)};return iu.default.createElement(iu.default.Fragment,null,iu.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:o=>n(o)},iu.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//type")}}),t.styles?.["--font-text"]),iu.default.createElement("div",{className:"mk-divider"}),iu.default.createElement(ba,{superstate:e.superstate,name:z.editor.size,value:t.styles?.["--font-text-size"],setValue:o=>r("--font-text-size",o),units:["px","em"]}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.bold,value:t.styles?.["--font-text-weight"],defaultValue:"'normal'",onValue:"'bold'",icon:"ui//bold",setValue:o=>r("--font-text-weight",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.italic,value:t.styles?.["--font-text-style"],defaultValue:"'normal'",onValue:"'italic'",icon:"ui//italic",setValue:o=>r("--font-text-style",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.underline,value:t.styles?.["--font-text-decoration"],defaultValue:"'none'",onValue:"'underline'",icon:"ui//underline",setValue:o=>r("--font-text-decoration",o)}),iu.default.createElement(I8,{superstate:e.superstate,value:Ea(t.styles?.["--font-text-color"]),setValue:o=>r("--font-text-color",`'${o}'`)}),iu.default.createElement("div",{className:"mk-divider"}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.alignLeft,value:t.styles?.textAlign,defaultValue:"'left'",onValue:"'left'",icon:"ui//align-left",setValue:o=>r("textAlign",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.alignCenter,value:t.styles?.textAlign,defaultValue:"'center'",onValue:"'center'",icon:"ui//align-center",setValue:o=>r("textAlign",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.alignRight,value:t.styles?.textAlign,defaultValue:"'left'",onValue:"'right'",icon:"ui//align-right",setValue:o=>r("textAlign",o)}),iu.default.createElement(Bo,{superstate:e.superstate,name:z.editor.alignJustify,value:t.styles?.textAlign,defaultValue:"'left'",onValue:"'justify'",icon:"ui//align-justify",setValue:o=>r("textAlign",o)}),iu.default.createElement("div",{className:"mk-divider"}),iu.default.createElement(ba,{superstate:e.superstate,name:z.editor.numberOfLines,value:t.styles?.["--line-count"],setValue:o=>r("--line-count",o),units:[""]}))};var I6e=e=>{let{pathState:t}=(0,or.useContext)(qr),{deleteFrame:r,duplicateFrame:n}=e,{spaceInfo:i}=(0,or.useContext)(ar),{addNode:a,ungroupNode:o,updateNode:s,saveNodes:u,frameProperties:l}=(0,or.useContext)(Oi),{selectionMode:c}=(0,or.useContext)(ji),{instance:f}=(0,or.useContext)(vi),d=(0,or.useCallback)((D,N)=>{s(N,{props:{...D}})},[s]),p=(D,N)=>{s(e.node,{styles:{[D]:N}})},[h,m]=(0,or.useState)(0),[g,A]=(0,or.useState)(e.node.props),b=(0,or.useMemo)(()=>Object.keys(e.node.types).map(D=>({type:e.node.types[D],name:D,attrs:e.node.propsAttrs?.[D],schemaId:e.node.schemaId,value:e.node.propsValue?.[D]})),[e.node]);(0,or.useEffect)(()=>{A(e.node.props)},[e.node]);let v=(0,or.useCallback)((D,N)=>{A(C=>({...C,[D]:N})),d({[D]:N},e.node)},[A,d,e.node]),x=[{type:"h1",name:z.commands.h1,icon:"ui//heading-1",class:"mk-t-h1"},{type:"h2",name:z.commands.h2,icon:"ui//heading-2",class:"mk-t-h2"},{type:"h3",name:z.commands.h3,icon:"ui//heading-3",class:"mk-t-h3"},{type:"h4",name:z.commands.h4,icon:"ui//heading-4",class:"mk-t-h4"},{type:"h5",name:z.commands.h5,icon:"ui//heading-5",class:"mk-t-h5"},{type:"h6",name:z.commands.h6,icon:"ui//heading-6",class:"mk-t-h6"},{type:"p",name:z.commands.paragraph,icon:"ui//type",class:"mk-t-p"}],w=D=>{let N=[];x.forEach(_=>{N.push({name:_.name,icon:_.icon,onClick:()=>{p("class",`'${_.class}'`)}})});let C=D.target.getBoundingClientRect();e.superstate.ui.openMenu(C,Xt(e.superstate.ui,N),je(D.view.document))},S=(0,or.useRef)(null),k={superstate:e.superstate,exitMenu:()=>m(0),saveStyleValue:p,savePropValue:v,frameProps:g,selectedNode:e.node,setHoverMenu:m,fields:b,state:e.state},M={...k,pathState:t,frameProperties:l,instance:f};(0,or.useEffect)(()=>{S.current&&S.current.update(M)},[f,b,e.state,e.node,g]);let O=(0,or.useRef)(null);return or.default.createElement("div",{className:"mk-editor-frame-node-selector",style:{pointerEvents:"auto"},ref:O,onClick:D=>{D.preventDefault()}},e.node.type=="new"&&or.default.createElement(or.default.Fragment,null,or.default.createElement("div",{className:"mk-editor-frame-node-button-primary",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:D=>{P8(D.target.getBoundingClientRect(),je(D.view.document),e.superstate,i,N=>u([{...N,id:e.node.id,parentId:e.node.parentId,schemaId:e.node.schemaId,rank:e.node.rank,props:{...N.props,value:e.node.props?.value}}])),D.stopPropagation()}}),or.default.createElement("div",{className:"mk-editor-frame-node-button-primary",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")},onClick:D=>{let N=e.superstate.spacesIndex.get(i.path);N&&Un(e.superstate,N,"md",e.state?.props?.value,!0).then(C=>u([{...e.node,type:zi.node.type,props:{...e.node.props,value:mr(C)}}])),D.stopPropagation()}})),h==0?or.default.createElement(or.default.Fragment,null,e.node.type=="group"||e.node.type=="content"?or.default.createElement(S6e,{...k}):b.length>0&&or.default.createElement("div",{"aria-label":"Properties",className:"mk-editor-frame-node-button",onClick:D=>{if(S.current){S.current.hide(),S.current=null;return}D.preventDefault(),S.current=e.superstate.ui.openCustomMenu(O.current.getBoundingClientRect(),or.default.createElement(N6e,{...M}),M,je(D.view.document),"bottom")},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//list")}}),e.node.type=="text"&&or.default.createElement(or.default.Fragment,null,or.default.createElement("div",{className:"mk-editor-frame-node-button",onClick:D=>w(D)},or.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(x.find(D=>D.class==Ea(e.node.styles?.class))?.icon??"ui//type")}}),x.find(D=>D.class==Ea(e.node.styles?.class))?.name??"Paragraph"),or.default.createElement("div",{className:"mk-divider"})),e.node.type=="icon"&&or.default.createElement(I8,{superstate:e.superstate,value:Ea(e.node.styles?.color),setValue:D=>p("color",`'${D}'`)}),or.default.createElement("div",{"aria-label":"Layout",className:"mk-editor-frame-node-button",onClick:D=>{D.preventDefault(),D.stopPropagation(),e.editLayout(!0),m(4)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//scaling")}}),or.default.createElement("div",{"aria-label":"Style",className:"mk-editor-frame-node-button",onClick:D=>{D.preventDefault(),D.stopPropagation(),m(5)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//paintbrush")}}),(e.node.type=="flow"||e.node.type=="space")&&or.default.createElement(j6e,{...k}),or.default.createElement("div",{"aria-label":"Text Style",className:"mk-editor-frame-node-button",onClick:D=>{D.preventDefault(),D.stopPropagation(),m(3)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//type")}}),c==1&&or.default.createElement(or.default.Fragment,null,or.default.createElement("div",{className:"mk-divider"}),or.default.createElement(Bo,{superstate:e.superstate,name:"Page Width",setValue:D=>{p("--max-width",D)},defaultValue:"",onValue:mr("100%"),value:e.node.styles?.["--max-width"],icon:"ui//full-width"})),or.default.createElement("div",{className:"mk-divider"}),e.node.type=="group"||e.node.type=="container"?or.default.createElement("div",{"aria-label":"Ungroup",className:"mk-editor-frame-node-button",onClick:()=>o(e.node),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//copy-x")}}):or.default.createElement(or.default.Fragment,null),or.default.createElement("div",{className:"mk-editor-frame-node-button","aria-label":"Delete",onClick:()=>r(),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//trash")}})):or.default.createElement(or.default.Fragment,null,or.default.createElement("div",{className:"mk-editor-frame-node-button",onMouseDown:D=>{D.stopPropagation(),e.editLayout(!1),m(0)},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//close")}}),or.default.createElement("div",{className:"mk-editor-frame-node-divider"}),h==3?or.default.createElement(P6e,{...k}):h==4?or.default.createElement(O6e,{...k}):h==5?or.default.createElement(F6e,{...k}):or.default.createElement(or.default.Fragment,null)))};var $h=he(Me());var B6e=e=>{let{spaceInfo:t}=(0,$h.useContext)(ar),{addNode:r,moveUp:n,moveDown:i,setLastCreatedId:a}=(0,$h.useContext)(Oi),{select:o,selection:s}=(0,$h.useContext)(ji),u=s.includes(e.node.id);return $h.default.createElement($h.default.Fragment,null,$h.default.createElement("div",{className:"mk-editor-frame-hover-horizontal",style:{pointerEvents:"auto",opacity:e.visible?"1":"0"}},e.dragRef&&$h.default.createElement("div",{className:"mk-icon-small mk-editor-frame-hover-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//handle")},style:{cursor:"grab"},ref:e.dragRef,onClick:l=>{if(l.stopPropagation(),s.length==1&&u){o(null);return}l.shiftKey?o(e.node.id,!0):o(e.node.id)},...e.listeners??{},...e.attributes??{}}),!cr(e.superstate.ui)&&$h.default.createElement("div",{onClick:l=>{r(ile.node,e.node).then(c=>a(c.id)),l.stopPropagation()},className:"mk-icon-small mk-editor-frame-hover-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//plus")}})))};var Dg=he(Me()),DZ=e=>{let t=(0,Dg.useRef)(null),[r,n]=(0,Dg.useState)(0),i=(s,u,l)=>{let c=s.x-e.containerRect.x,f=c+u.width-l.width,d=c;return f>0&&(s.x-e.containerRect.x-u.width>0?d=l.width-u.width:d=0),d},[a,o]=(0,Dg.useState)(!1);return(0,Dg.useEffect)(()=>{let s=new ResizeObserver(u=>{let l=u[0].target.getBoundingClientRect();o(!0),n(i(e.nodeRect,l,e.containerRect))});return t.current&&s.observe(t.current),()=>{s.disconnect()}},[t]),Dg.default.createElement("div",{className:"mk-editor-frame-node-container",ref:t,style:{visibility:a?"visible":"hidden",pointerEvents:"auto",left:r,bottom:`calc(100% - ${e.nodeRect.y-e.containerRect.y-10}px)`,maxWidth:e.containerRect.width},onClick:s=>{s.preventDefault(),s.stopPropagation()}},e.children)};var R6e=he(to()),Hc=he(Me());var tc=he(Me()),au=e=>{let[t,r]=(0,tc.useState)(null),n=(0,tc.useRef)(e.value),i=(0,tc.useRef)(e.value),[,a]=(0,tc.useState)([0,0]),o=e.step??1,s=(0,tc.useCallback)(d=>{a(p=>{let{clientX:h,clientY:m}=d,[g,A]=p,b=e.reverseX?g-h:h-g,v=e.reverseY?m-A:A-m,x=e.mod??1,w=o*x,S=Math.sqrt((b+v)/2*(b+v)/2)*w;b+v<0&&(S=-S),e.disableX&&(S=v*w),e.disableY&&(S=b*w);let k=n.current+S;return k=e.min!=null?Math.max(k,e.min):k,k=e.max!=null?Math.min(k,e.max):k,i.current=k,e.onDragMove(k,{ctrlKey:d.ctrlKey,metaKey:d.metaKey,altKey:d.altKey,shiftKey:d.shiftKey}),p}),d.stopPropagation()},[t,e.max,e.min,o,e.onDragMove,e.mod]),u=(0,tc.useCallback)(d=>{let p=h=>{h.stopPropagation(),window.removeEventListener("click",p,!0)};window.addEventListener("click",p,!0),document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",u),e.onDragEnd(i.current,{ctrlKey:d.ctrlKey,metaKey:d.metaKey,altKey:d.altKey,shiftKey:d.shiftKey}),d.preventDefault(),d.stopPropagation()},[s,e.onDragEnd]),l=(0,tc.useCallback)(d=>{n.current=e.value,a([d.clientX,d.clientY]),document.addEventListener("mousemove",s),document.addEventListener("mouseup",u),d.stopPropagation()},[s,u,e.value]),c=d=>{d.metaKey?r("metaKey"):d.ctrlKey?r("ctrlKey"):d.altKey?r("altKey"):d.shiftKey&&r("shiftKey")},f=()=>{r(null)};return(0,tc.useEffect)(()=>(document.addEventListener("keydown",c),document.addEventListener("keyup",f),()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",u),document.removeEventListener("keydown",c),document.removeEventListener("keyup",f)}),[]),tc.default.createElement("div",{className:"mk-frame-draggable-handle",onMouseDown:l,"data-placeholder":i.current.toString(),style:{cursor:e.cursor,width:"100%",height:"100%",pointerEvents:"auto"}},tc.default.createElement("span",null))};var $6e=e=>{let t=e.styles.borderRadius?e.styles.borderRadius.match(/^(\d+(?:\.\d+)?)\s?([a-zA-Z%]+)$/):null,r=t?parseInt(t[1]):0,n=t&&t[2]?t[2]:"px",[i,a]=Hc.default.useState(Math.max(8,r));(0,Hc.useEffect)(()=>{a(r)},[r]);let o={min:0,max:Math.min(e.clientSize.height/2,e.clientSize.width/2),value:i,onDragMove:u=>{a(u)},onDragEnd:u=>{e.saveStyles({borderRadius:`"${u}${n}"`})}},s=Math.max(8,i);return Hc.default.createElement("div",{style:{position:"absolute",top:0,left:0,width:e.clientSize.width,height:e.clientSize.height,display:"flex",zIndex:200,borderRadius:i,border:"1px solid var(--mk-ui-border-accent)"}},Hc.default.createElement("div",{className:(0,R6e.default)("mk-frame-corners")},Hc.default.createElement("div",{className:"mk-frame-corner",style:{position:"absolute",transform:`translate(${s}px, ${s}px)`,zIndex:"var(--mk-layer-editor-overlay)"}},Hc.default.createElement(au,{...o,cursor:"nwse-resize",reverseY:!0})),Hc.default.createElement("div",{className:"mk-frame-corner",style:{position:"absolute",transform:`translate(${e.clientSize.width-s}px, ${s}px)`,zIndex:"var(--mk-layer-editor-overlay)"}},Hc.default.createElement(au,{...o,cursor:"nesw-resize",reverseX:!0,reverseY:!0})),Hc.default.createElement("div",{className:"mk-frame-corner",style:{position:"absolute",transform:`translate(${s}px, ${e.clientSize.height-s}px)`,zIndex:"var(--mk-layer-editor-overlay)"}},Hc.default.createElement(au,{...o,cursor:"nesw-resize"})),Hc.default.createElement("div",{className:"mk-frame-corner",style:{position:"absolute",transform:`translate(${e.clientSize.width-s}px, ${e.clientSize.height-s}px)`,zIndex:"var(--mk-layer-editor-overlay)"}},Hc.default.createElement(au,{...o,reverseX:!0,cursor:"nwse-resize"}))))};var q6e=he(to());var Og=he(Me());var zet=e=>{let{instance:t,id:r}=(0,Og.useContext)(vi),{spaceInfo:n}=(0,Og.useContext)(ar),{setNodeRef:i}=ql({id:e.id+e.direction,data:{id:e.id+e.direction,direction:e.direction,type:"node",parent:e.parentId,root:r,frame:e.schemaID,space:n.path,node:e.node}}),a=20,o=e.direction=="left"?-a:e.direction=="right"?e.width:0,s=e.direction=="bottom"?e.insertMode!=0?e.height:e.height/2:e.direction=="top"&&e.insertMode!=0?-a:0,u=e.direction=="left"||e.direction=="right"?a:e.width,l=e.direction=="top"||e.direction=="bottom"?e.insertMode!=0?a:e.height/2:e.height,c=e.insertMode!=0?e.direction=="top"?"bottom":e.direction=="bottom"?"top":e.direction:e.direction;return Og.default.createElement("div",{ref:i,className:(0,q6e.default)(e.active?`mk-indicator-${c}`:"","mk-frame-drop-zone"),style:{left:o,top:s,width:u,height:l}})},L6e=e=>{let{frameSchema:t}=(0,Og.useContext)(va),{hoverNode:r}=(0,Og.useContext)(vi),n=[...e.mode==1?["top","bottom","left","right"]:e.mode==2?["top","bottom"]:e.mode==3?["left","right"]:[],...e.insertMode==1?["inside"]:[]];return Og.default.createElement("div",{className:"mk-frame-drop-zone-container",style:{width:e.width,height:e.height}},n.map(i=>Og.default.createElement(zet,{...e,key:i,active:r?.node==e.node&&r?.direction==i,direction:i,mode:e.mode,schemaID:t.id})))};var xa=he(Me());var Uet=(e,t,r,n)=>{let i={},a=0,o=0,s=r?"width":"height",u=r?"height":"width";return e.forEach((l,c,f)=>{c==0?(i[a]={start:c,end:c,maxValue:l[u],items:[{...l,row:a}]},o=l[s]):f[c][s]+n>t[s]?(a++,i[a]={start:c,end:c,maxValue:l[u],items:[{...l,row:a}]}):f[c][s]+n+o>t[s]?(a++,i[a]={start:c,end:c,maxValue:l[u],items:[{...l,row:a}]},o=l[s]):i[a]?(i[a]={start:i[a].start,end:c,maxValue:Math.max(i[a].maxValue,l[u]),items:[...i[a].items,{...l,row:a}]},o+=l[s]+n):console.log("Warning: Flexbox found orphan row")}),i},z6e=e=>{let t=u=>{let l=u?u.match(/^(\d+(?:\.\d+)?)\s?([a-zA-Z%]+)$/):null;return l?parseInt(l[1]):0},[r,n]=xa.default.useState({row:t(e.styles.rowGap),column:t(e.styles.columnGap)});(0,xa.useEffect)(()=>{n({row:t(e.styles.rowGap),column:t(e.styles.columnGap)})},[e.styles]);let i={value:r[e.direction],onDragMove:u=>{n({...r,[e.direction=="column"?"row":"column"]:u})},onDragEnd:u=>{e.saveStyles(e.direction=="column"?{rowGap:`"${u}px"`}:{columnGap:`"${u}px"`})}},a={value:r[e.direction=="column"?"row":"column"],onDragMove:u=>{n({...r,[e.direction]:u})},onDragEnd:u=>{e.saveStyles(e.direction=="column"?{columnGap:`"${u}px"`}:{rowGap:`"${u}px"`})}},o=(0,xa.useMemo)(()=>Uet(e.childSizes,{width:e.clientSize.width-e.clientSize.paddingLeft-e.clientSize.paddingRight,height:e.clientSize.height-e.clientSize.paddingTop-e.clientSize.paddingBottom},e.direction=="row",r[e.direction=="column"?"row":"column"]),[e.childSizes,e.clientSize,e.direction,r]),s=(0,xa.useMemo)(()=>{let u=[];return Object.keys(o).forEach(l=>{u.push(...o[l].items)}),u},[o]);return xa.default.createElement("div",{className:`mk-frame-gaps ${aE(e.styles)}`,style:{position:"absolute",top:0,left:0,width:e.clientSize.width,height:e.clientSize.height,padding:e.clientSize.paddingTop,paddingLeft:e.clientSize.paddingLeft,paddingBottom:e.clientSize.paddingBottom,paddingRight:e.clientSize.paddingRight,flexWrap:e.styles.flexWrap}},e.direction==="row"?s.map((u,l,c)=>xa.default.createElement(xa.default.Fragment,null,xa.default.createElement("div",{style:{width:u.width,height:u.height}}),l==c.length-1?xa.default.createElement(xa.default.Fragment,null):o[u.row].end==l?xa.default.createElement("div",{key:l,className:"mk-frame-gap-handle-h",style:{width:"100%",height:Math.max(8,Math.abs(r.row)),zIndex:"var(--mk-layer-editor-overlay)"}},xa.default.createElement(au,{...a,cursor:"col-resize",disableX:!0,reverseY:!0})):xa.default.createElement("div",{key:l,className:"mk-frame-gap-handle-v",style:{width:Math.max(8,Math.abs(r.column)),height:o[u.row].maxValue,zIndex:"var(--mk-layer-editor-overlay)"}},xa.default.createElement(au,{...i,cursor:"col-resize",disableY:!0})))):s.map((u,l,c)=>xa.default.createElement(xa.default.Fragment,null,xa.default.createElement("div",{style:{width:u.width,height:u.height}}),l==c.length-1?xa.default.createElement(xa.default.Fragment,null):o[u.row].end==l?xa.default.createElement("div",{key:l,className:"mk-frame-gap-handle-v",style:{height:"100%",width:Math.max(8,Math.abs(r.column)),zIndex:"var(--mk-layer-editor-overlay)"}},xa.default.createElement(au,{...a,cursor:"col-resize",disableX:!0,reverseY:!0})):xa.default.createElement("div",{key:l,className:"mk-frame-gap-handle-h",style:{height:Math.max(8,Math.abs(r.row)),width:o[u.row].maxValue,zIndex:"var(--mk-layer-editor-overlay)"}},xa.default.createElement(au,{...i,cursor:"row-resize",disableX:!0,reverseY:!0})))))};var U6e=he(to()),vl=he(Me());var W6e=e=>{let t=["padding","paddingTop","paddingBottom","paddingLeft","paddingRight"],[r,n]=vl.default.useState({padding:0,paddingTop:null,paddingBottom:null,paddingLeft:null,paddingRight:null}),i="px";(0,vl.useEffect)(()=>{let f=d=>{if(!e.styles[d])return null;let p=e.styles[d]?e.styles[d].match(/^(\d+(?:\.\d+)?)\s?([a-zA-Z%]+)$/):null;return Math.max(p?parseInt(p[1]):0,8)};n(d=>t.reduce((p,h)=>({...p,[h]:f(h)}),d))},[e.styles]);let[a,o]=vl.default.useState(!1),s={min:0,mod:2},u=f=>Math.max(5,r[f]??r.padding),l=(f,d,p)=>{n(h=>p.shiftKey?{padding:d,paddingBottom:null,paddingTop:null,paddingLeft:null,paddingRight:null}:{...h,[f]:d})},c=(f,d,p)=>{e.saveStyles(p.shiftKey?{padding:`'${d}${i}'`,paddingBottom:"",paddingTop:"",paddingLeft:"",paddingRight:""}:{[f]:`'${d}${i}'`})};return(0,vl.useEffect)(()=>{let f=p=>{p.key==="Shift"&&o(!0)},d=p=>{p.key==="Shift"&&o(!1)};return window.addEventListener("keydown",f),window.addEventListener("keyup",d),()=>{window.removeEventListener("keydown",f),window.removeEventListener("keyup",d)}},[]),vl.default.createElement("div",{style:{position:"absolute",top:0,left:0,width:e.clientSize.width,height:e.clientSize.height,display:"flex",zIndex:200,border:"1px solid var(--mk-ui-color-border-accent)"}},vl.default.createElement("div",{className:(0,U6e.default)("mk-frame-paddings",a&&"mk-modifier-shift")},vl.default.createElement("div",{className:"mk-frame-padding-handle-h",style:{position:"absolute",transform:`translate(${0}px, ${0}px)`,height:u("paddingTop"),zIndex:"var(--mk-layer-editor-overlay)"}},vl.default.createElement(au,{...s,value:r.paddingTop??r.padding,cursor:"s-resize",max:e.clientSize.height,onDragMove:(f,d)=>{l("paddingTop",f,d)},onDragEnd:(f,d)=>{c("paddingTop",f,d)},reverseY:!0,disableX:!0})),vl.default.createElement("div",{className:"mk-frame-padding-handle-v",style:{position:"absolute",transform:`translate(${e.clientSize.width-u("paddingRight")}px, ${0}px)`,width:u("paddingRight"),zIndex:"var(--mk-layer-editor-overlay)"}},vl.default.createElement(au,{...s,value:r.paddingRight??r.padding,cursor:"w-resize",onDragMove:(f,d)=>{l("paddingRight",f,d)},max:e.clientSize.width,onDragEnd:(f,d)=>{c("paddingRight",f,d)},reverseX:!0,reverseY:!0,disableY:!0})),vl.default.createElement("div",{className:"mk-frame-padding-handle-v",style:{position:"absolute",transform:`translate(${0}px, ${0}px)`,width:u("paddingLeft"),zIndex:"var(--mk-layer-editor-overlay)"}},vl.default.createElement(au,{...s,value:r.paddingLeft??r.padding,cursor:"e-resize",max:e.clientSize.width,onDragMove:(f,d)=>{l("paddingLeft",f,d)},onDragEnd:(f,d)=>{c("paddingLeft",f,d)},disableY:!0})),vl.default.createElement("div",{className:"mk-frame-padding-handle-h",style:{position:"absolute",transform:`translate(${0}px, ${e.clientSize.height-u("paddingBottom")}px)`,height:u("paddingBottom"),zIndex:"var(--mk-layer-editor-overlay)"}},vl.default.createElement(au,{...s,value:r.paddingBottom??r.padding,cursor:"n-resize",max:e.clientSize.height,onDragMove:(f,d)=>{l("paddingBottom",f,d)},onDragEnd:(f,d)=>{c("paddingBottom",f,d)},reverseX:!0,disableX:!0}))))};var J6e=he(to());var Eb=he(Me()),X6e=he(Ws());var $8=he(Me()),Wet=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a])},e(t,r)};return function(t,r){e(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),ts=function(){return ts=Object.assign||function(e){for(var t,r=1,n=arguments.length;r"u"?void 0:Number(n),maxHeight:typeof i>"u"?void 0:Number(i),minWidth:typeof a>"u"?void 0:Number(a),minHeight:typeof o>"u"?void 0:Number(o)}},Zet=["as","style","className","grid","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],Z6e="__resizable_base__",K6e=function(e){Vet(t,e);function t(r){var n=e.call(this,r)||this;return n.ratio=1,n.resizable=null,n.parentLeft=0,n.parentTop=0,n.resizableLeft=0,n.resizableRight=0,n.resizableTop=0,n.resizableBottom=0,n.targetLeft=0,n.targetTop=0,n.appendBase=function(){if(!n.resizable||!n.window)return null;var i=n.parentNode;if(!i)return null;var a=n.window.document.createElement("div");return a.style.width="100%",a.style.height="100%",a.style.position="absolute",a.style.transform="scale(0, 0)",a.style.left="0",a.style.flex="0 0 100%",a.classList?a.classList.add(Z6e):a.className+=Z6e,i.appendChild(a),a},n.removeBase=function(i){var a=n.parentNode;!a||a.removeChild(i)},n.ref=function(i){i&&(n.resizable=i)},n.state={isResizing:!1,width:typeof(n.propsSize&&n.propsSize.width)>"u"?"auto":n.propsSize&&n.propsSize.width,height:typeof(n.propsSize&&n.propsSize.height)>"u"?"auto":n.propsSize&&n.propsSize.height,direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},n.onResizeStart=n.onResizeStart.bind(n),n.onMouseMove=n.onMouseMove.bind(n),n.onMouseUp=n.onMouseUp.bind(n),n}return Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return!this.resizable||!this.resizable.ownerDocument?null:this.resizable.ownerDocument.defaultView},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||Get},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){var r=0,n=0;if(this.resizable&&this.window){var i=this.resizable.offsetWidth,a=this.resizable.offsetHeight,o=this.resizable.style.position;o!=="relative"&&(this.resizable.style.position="relative"),r=this.resizable.style.width!=="auto"?this.resizable.offsetWidth:i,n=this.resizable.style.height!=="auto"?this.resizable.offsetHeight:a,this.resizable.style.position=o}return{width:r,height:n}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sizeStyle",{get:function(){var r=this,n=this.props.size,i=function(s){if(typeof r.state[s]>"u"||r.state[s]==="auto")return"auto";if(r.propsSize&&r.propsSize[s]&&r.propsSize[s].toString().endsWith("%")){if(r.state[s].toString().endsWith("%"))return r.state[s].toString();var u=r.getParentSize(),l=Number(r.state[s].toString().replace("px","")),c=l/u[s]*100;return c+"%"}return OZ(r.state[s])},a=n&&typeof n.width<"u"&&!this.state.isResizing?OZ(n.width):i("width"),o=n&&typeof n.height<"u"&&!this.state.isResizing?OZ(n.height):i("height");return{width:a,height:o}},enumerable:!1,configurable:!0}),t.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var r=this.appendBase();if(!r)return{width:0,height:0};var n=!1,i=this.parentNode.style.flexWrap;i!=="wrap"&&(n=!0,this.parentNode.style.flexWrap="wrap"),r.style.position="relative",r.style.minWidth="100%",r.style.minHeight="100%";var a={width:r.offsetWidth,height:r.offsetHeight};return n&&(this.parentNode.style.flexWrap=i),this.removeBase(r),a},t.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},t.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},t.prototype.componentDidMount=function(){if(!(!this.resizable||!this.window)){var r=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:r.flexBasis!=="auto"?r.flexBasis:void 0})}},t.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},t.prototype.createSizeForCssProperty=function(r,n){var i=this.propsSize&&this.propsSize[n];return this.state[n]==="auto"&&this.state.original[n]===r&&(typeof i>"u"||i==="auto")?"auto":r},t.prototype.calculateNewMaxFromBoundary=function(r,n){var i=this.props.boundsByDirection,a=this.state.direction,o=i&&cE("left",a),s=i&&cE("top",a),u,l;if(this.props.bounds==="parent"){var c=this.parentNode;c&&(u=o?this.resizableRight-this.parentLeft:c.offsetWidth+(this.parentLeft-this.resizableLeft),l=s?this.resizableBottom-this.parentTop:c.offsetHeight+(this.parentTop-this.resizableTop))}else this.props.bounds==="window"?this.window&&(u=o?this.resizableRight:this.window.innerWidth-this.resizableLeft,l=s?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(u=o?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),l=s?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return u&&Number.isFinite(u)&&(r=r&&r"u"?10:a.width,f=typeof i.width>"u"||i.width<0?r:i.width,d=typeof a.height>"u"?10:a.height,p=typeof i.height>"u"||i.height<0?n:i.height,h=u||0,m=l||0;if(s){var g=(d-h)*this.ratio+m,A=(p-h)*this.ratio+m,b=(c-m)/this.ratio+h,v=(f-m)/this.ratio+h,x=Math.max(c,g),w=Math.min(f,A),S=Math.max(d,b),k=Math.min(p,v);r=q8(r,x,w),n=q8(n,S,k)}else r=q8(r,c,f),n=q8(n,d,p);return{newWidth:r,newHeight:n}},t.prototype.setBoundingClientRect=function(){if(this.props.bounds==="parent"){var r=this.parentNode;if(r){var n=r.getBoundingClientRect();this.parentLeft=n.left,this.parentTop=n.top}}if(this.props.bounds&&typeof this.props.bounds!="string"){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left,this.targetTop=i.top}if(this.resizable){var a=this.resizable.getBoundingClientRect(),o=a.left,s=a.top,u=a.right,l=a.bottom;this.resizableLeft=o,this.resizableRight=u,this.resizableTop=s,this.resizableBottom=l}},t.prototype.onResizeStart=function(r,n){if(!(!this.resizable||!this.window)){var i=0,a=0;if(r.nativeEvent&&Qet(r.nativeEvent)?(i=r.nativeEvent.clientX,a=r.nativeEvent.clientY):r.nativeEvent&&L8(r.nativeEvent)&&(i=r.nativeEvent.touches[0].clientX,a=r.nativeEvent.touches[0].clientY),this.props.onResizeStart&&this.resizable){var o=this.props.onResizeStart(r,n,this.resizable);if(o===!1)return}this.props.size&&(typeof this.props.size.height<"u"&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),typeof this.props.size.width<"u"&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio=typeof this.props.lockAspectRatio=="number"?this.props.lockAspectRatio:this.size.width/this.size.height;var s,u=this.window.getComputedStyle(this.resizable);if(u.flexBasis!=="auto"){var l=this.parentNode;if(l){var c=this.window.getComputedStyle(l).flexDirection;this.flexDir=c.startsWith("row")?"row":"column",s=u.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var f={original:{x:i,y:a,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:qh(qh({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(r.target).cursor||"auto"}),direction:n,flexBasis:s};this.setState(f)}},t.prototype.onMouseMove=function(r){var n=this;if(!(!this.state.isResizing||!this.resizable||!this.window)){if(this.window.TouchEvent&&L8(r))try{r.preventDefault(),r.stopPropagation()}catch{}var i=this.props,a=i.maxWidth,o=i.maxHeight,s=i.minWidth,u=i.minHeight,l=L8(r)?r.touches[0].clientX:r.clientX,c=L8(r)?r.touches[0].clientY:r.clientY,f=this.state,d=f.direction,p=f.original,h=f.width,m=f.height,g=this.getParentSize(),A=Yet(g,this.window.innerWidth,this.window.innerHeight,a,o,s,u);a=A.maxWidth,o=A.maxHeight,s=A.minWidth,u=A.minHeight;var b=this.calculateNewSizeFromDirection(l,c),v=b.newHeight,x=b.newWidth,w=this.calculateNewMaxFromBoundary(a,o);this.props.snap&&this.props.snap.x&&(x=Y6e(x,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(v=Y6e(v,this.props.snap.y,this.props.snapGap));var S=this.calculateNewSizeFromAspectRatio(x,v,{width:w.maxWidth,height:w.maxHeight},{width:s,height:u});if(x=S.newWidth,v=S.newHeight,this.props.grid){var k=Q6e(x,this.props.grid[0]),M=Q6e(v,this.props.grid[1]),O=this.props.snapGap||0;x=O===0||Math.abs(k-x)<=O?k:x,v=O===0||Math.abs(M-v)<=O?M:v}var D={width:x-p.width,height:v-p.height};if(h&&typeof h=="string"){if(h.endsWith("%")){var N=x/g.width*100;x=N+"%"}else if(h.endsWith("vw")){var C=x/this.window.innerWidth*100;x=C+"vw"}else if(h.endsWith("vh")){var _=x/this.window.innerHeight*100;x=_+"vh"}}if(m&&typeof m=="string"){if(m.endsWith("%")){var N=v/g.height*100;v=N+"%"}else if(m.endsWith("vw")){var C=v/this.window.innerWidth*100;v=C+"vw"}else if(m.endsWith("vh")){var _=v/this.window.innerHeight*100;v=_+"vh"}}var I={width:this.createSizeForCssProperty(x,"width"),height:this.createSizeForCssProperty(v,"height")};this.flexDir==="row"?I.flexBasis=I.width:this.flexDir==="column"&&(I.flexBasis=I.height),(0,X6e.flushSync)(function(){n.setState(I)}),this.props.onResize&&this.props.onResize(r,d,this.resizable,D)}},t.prototype.onMouseUp=function(r){var n=this.state,i=n.isResizing,a=n.direction,o=n.original;if(!(!i||!this.resizable)){var s={width:this.size.width-o.width,height:this.size.height-o.height};this.props.onResizeStop&&this.props.onResizeStop(r,a,this.resizable,s),this.props.size&&this.setState(this.props.size),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:qh(qh({},this.state.backgroundStyle),{cursor:"auto"})})}},t.prototype.updateSize=function(r){this.setState({width:r.width,height:r.height})},t.prototype.renderResizer=function(){var r=this,n=this.props,i=n.enable,a=n.handleStyles,o=n.handleClasses,s=n.handleWrapperStyle,u=n.handleWrapperClass,l=n.handleComponent;if(!i)return null;var c=Object.keys(i).map(function(f){return i[f]!==!1?Eb.createElement(G6e,{key:f,direction:f,onResizeStart:r.onResizeStart,replaceStyles:a&&a[f],className:o&&o[f]},l&&l[f]?l[f]:null):null});return Eb.createElement("div",{className:u,style:s},c)},t.prototype.render=function(){var r=this,n=Object.keys(this.props).reduce(function(o,s){return Zet.indexOf(s)!==-1||(o[s]=r.props[s]),o},{}),i=qh(qh(qh({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(i.flexBasis=this.state.flexBasis);var a=this.props.as||"div";return Eb.createElement(a,qh({ref:this.ref,style:i,className:this.props.className},n),this.state.isResizing&&Eb.createElement("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer())},t.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},t}(Eb.PureComponent);var ou=he(Me());var jZ=e=>{let t=o=>o?o=="auto"?"Fit":o=="100%"?"Fill":o:null,[r,n]=ou.default.useState(null),[i,a]=ou.default.useState({width:e.resizeMode!=2?e.size.width:e.size.minWidth,height:e.size.height});return ou.default.useEffect(()=>{a({width:e.resizeMode!=2?e.size.width:e.size.minWidth,height:e.size.height})},[e.size,e.resizeMode]),(0,ou.useEffect)(()=>{let o=s=>{n({shiftKey:s.shiftKey})};return e.superstate.ui.inputManager.on("keydown",o),e.superstate.ui.inputManager.on("keyup",o),()=>{e.superstate.ui.inputManager.off("keydown",o),e.superstate.ui.inputManager.off("keyup",o)}},[n]),ou.default.createElement("div",{style:{position:"absolute",top:0,left:0,width:e.clientSize.width,height:e.clientSize.height}},ou.default.createElement(K6e,{lockAspectRatio:r?.shiftKey,className:(0,J6e.default)(e.resizeMode==2?"mk-frame-column":"mk-frame-bounds"),enable:e.resizeMode==2?{right:!0}:{right:!0,bottom:!0,bottomRight:!0},onResize:(o,s,u,l)=>{a({width:u.clientWidth,height:u.clientHeight})},onResizeStop:(o,s,u,l)=>{let c=f=>{f.stopPropagation(),window.removeEventListener("click",c,!0)};window.addEventListener("click",c,!0),e.resizeMode==2?e.resize({minWidth:`'${u.clientWidth}px'`}):s=="bottom"?e.resize({height:`'${u.clientHeight}px'`}):s=="right"?e.resize({width:`'${u.clientWidth}px'`}):e.resize({width:`'${u.clientWidth}px'`,height:`'${u.clientHeight}px'`}),o.stopPropagation()},onResizeStart:o=>{o.stopPropagation()},handleClasses:e.resizeMode==2?{right:"mk-frame-column-resize-handle"}:e.resizeMode==1?{bottomRight:"mk-frame-resize-handle"}:{},handleWrapperStyle:{pointerEvents:"auto"},size:{width:i.width&&i.width!="auto"?i.width:"100%",height:i.height&&i.height!="auto"?i.height:"100%"},...e.listeners}),e.clientSize?.width>50&&e.resizeMode==1&&ou.default.createElement("div",{className:"mk-frame-resize-label-width"},ou.default.createElement("div",null,ou.default.createElement("span",null,t(i.width)??z.editor.fit),i.width&&i.width!="auto"?ou.default.createElement("div",{onClick:o=>{e.resize({width:mr("auto")}),o.stopPropagation()},"aria-label":z.editor.scaleToFit,style:{display:"flex"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//fold-horizontal")}}):ou.default.createElement("div",{onClick:o=>{e.resize({width:mr("100%")}),o.stopPropagation()},"aria-label":z.editor.scaleToFill,style:{display:"flex"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//unfold-horizontal")}}))),e.clientSize?.height>50&&e.resizeMode==1&&ou.default.createElement("div",{className:"mk-frame-resize-label-height"},ou.default.createElement("div",null,ou.default.createElement("span",null,t(i.height)??z.editor.fit),i.height&&i.height!="auto"?ou.default.createElement("div",{onClick:o=>{e.resize({height:mr("auto")}),o.stopPropagation()},"aria-label":z.editor.scaleToFit,style:{display:"flex"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//fold-vertical")}}):ou.default.createElement("div",{onClick:o=>{e.resize({height:mr("100%")}),o.stopPropagation()},"aria-label":z.editor.scaleToFill,style:{display:"flex"},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//unfold-vertical")}}))))};var np=he(Me());var U8=e=>{let{selectionMode:t,selected:r,selection:n}=(0,np.useContext)(ji),{updateNode:i,nodes:a}=(0,np.useContext)(Oi),o=d=>{if(d!=e.state.props?.value)if(e.treeNode.editorProps?.linkedNode){let p=a.find(h=>h.id==e.treeNode.editorProps.linkedNode.node);i(p,{props:{...p.props,[e.treeNode.editorProps.linkedNode.prop]:mr(d)}})}else i(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(d)}})},s=n?.includes(e.treeNode.node.id),u=(0,np.useMemo)(()=>t==0?!1:t==1||t==3&&s?!0:e.treeNode.isRef?!!(e.treeNode.editorProps.linkedNode&&r):!0,[e.treeNode,t,r,s]),l=d=>{e.superstate.ui.openPalette(np.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:p=>o(p)}),je(d.view.document))},[c,f]=e.state.props?.value?sg(e.state.props?.value):[null,null];return e.state&&(e.state.props?.value?.length>0?c=="image"?np.default.createElement("img",{className:"mk-frame-icon",src:e.superstate.ui.getUIPath(e.superstate.imagesCache.get(f))}):np.default.createElement("div",{className:"mk-frame-icon",style:{},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(e.state.props?.value)}}):u?np.default.createElement("div",{onClick:d=>l(d),"aria-label":"Select Sticker",className:"mk-node-icon-placeholder",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//smile")}}):np.default.createElement(np.default.Fragment,null))};var Lf=he(Me());var W8=e=>{let t=e.state.props.value,r=(0,Lf.useMemo)(()=>e.superstate.ui.getUIPath(t,!0),[t]),{nodes:n,updateNode:i}=(0,Lf.useContext)(Oi),{linkedProps:a}=(0,Lf.useContext)(vi),{selectionMode:o,selected:s,selection:u}=(0,Lf.useContext)(ji),l=u?.includes(e.treeNode.node.id),c=p=>{!zl(e.treeNode.node.props.value)&&!a.some(h=>e.treeNode.editorProps.linkedNode?.node==e.treeNode.node.schemaId&&e.treeNode.editorProps.linkedNode?.prop==h)||e.superstate.ui.openPalette(Lf.default.createElement(Xl,{superstate:e.superstate,selectedPath:h=>f(h)}),je(p.view.document))},f=p=>{if(p!=e.state.props?.value)if(e.treeNode.editorProps?.linkedNode){let h=n.find(m=>m.id==e.treeNode.editorProps.linkedNode.node);i(h,{props:{...h.props,[e.treeNode.editorProps.linkedNode.prop]:mr(p)}})}else i(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(p)}})},d=(0,Lf.useMemo)(()=>o==0?!1:o==1||o==3&&l?!0:e.treeNode.isRef?!!(e.treeNode.editorProps.linkedNode&&s):!0,[e.treeNode,o,s,l]);return e.state?.props.value?.length>0?Lf.default.createElement("img",{className:"mk-node-image",width:e.state?.styles.width,height:e.state?.styles.height,style:{borderRadius:e.state?.styles.borderRadius,maxHeight:e.state?.styles.maxHeight},src:r}):d?Lf.default.createElement("div",{className:"mk-node-image-placeholder",dangerouslySetInnerHTML:{__html:e.superstate.ui.getPlaceholderImage("image-select")},style:{borderRadius:e.state?.styles.borderRadius,maxHeight:e.state?.styles.maxHeight},onClick:p=>c(p)}):Lf.default.createElement(Lf.default.Fragment,null)};var jg=he(Me()),H8=e=>{let{selectionMode:t}=(0,jg.useContext)(ji),{saveState:r,instance:n}=(0,jg.useContext)(vi),[i,a]=(0,jg.useState)(""),o=e.state,s=e.state.styles?.as;return(0,jg.useEffect)(()=>{let u=eh(e.state?.props?.value);if(u){let l=u.node=="$root"?n.exec.id:u.node;a(n.state?.[l]?.props?.[u.prop])}},[e.state.props]),jg.default.createElement("input",{className:"mk-node-input",type:s,value:s=="checkbox"?null:i,checked:i=="true",onKeyDown:u=>{if(u.stopPropagation(),u.key=="Enter"){let l=s=="text"?u.currentTarget.value:s=="checkbox"?(!u.currentTarget.checked).toString():u.currentTarget.value;a(""),typeof o.actions?.onEnter=="function"&&o.actions?.onEnter(u,l,n.state,c=>r(c,n),e.superstate.api)}},onChange:u=>{let l=s=="text"?u.target.value:s=="checkbox"?(!u.target.checked).toString():u.target.value;a(l),typeof o.actions?.onChange=="function"&&o.actions?.onChange(u,l,n.state,c=>r(c,n),e.superstate.api)},placeholder:o.styles.placeholder,style:{...o?.styles}})};var yl=he(Me());var V8=e=>{let t=yl.default.createRef(),{spaceState:r}=(0,yl.useContext)(ar),{updateNode:n,nodes:i,deleteNode:a,addNode:o,saveNodes:s,lastCreatedId:u,setLastCreatedId:l}=(0,yl.useContext)(Oi),{selection:c,select:f}=(0,yl.useContext)(ji),[d,p]=(0,yl.useState)("label"),{instance:h}=(0,yl.useContext)(vi),m=[...e.superstate.allSpaces(!0)].filter(k=>k.type!="default").map(k=>({name:k.name,value:k.path,icon:e.superstate.pathsIndex.get(k.path)?.label?.sticker,description:k.type=="tag"?k.name:k.type=="folder"?k.path:k.name})),g=[...e.superstate.pathsIndex.values()].filter(k=>!k.hidden).filter(k=>k.type=="space"||k.subtype=="md").map(k=>({name:k.label.name,value:k.path,description:k.path,section:"flow",icon:k.label?.sticker})),A={minMatchCharLength:1,threshold:0,keys:["name","value"]},[b,v]=(0,yl.useState)(""),x=(0,yl.useMemo)(()=>{let k=[],M={name:z.frames.label.label,description:b,icon:"ui//baseline",section:"label",value:""};k.push(M);let O={name:z.frames.note.label,description:b,icon:"ui//file-text",value:"",section:"flow"};k.push(O);let D=[{name:z.frames.table.label,description:z.frames.table.description,icon:"ui//table",section:"list",value:""},...[xf,MS,ja,Wl,un].map(_=>({name:_.node.name,value:_,icon:_.def?.icon,section:"base",description:_.def?.description})),...[xh,TS,FS,_S,PS,IS,NS].map(_=>({name:_.node.name,value:_,icon:_.def?.icon,section:"kit",description:_.def?.description}))],N=new zc(D,A),C=b.length==0?D:N.search(b).map(_=>_.item).slice(0,10);if(C.length>0&&k.push(ZG("Kit")),k.push(...C),b.length>0){let _=new zc([...g],A),I=b.length==0?[]:_.search(b).map(L=>L.item).slice(0,10);I.length>0&&k.push(ZG("Paths")),k.push(...I)}return k},[b,d]),w=k=>{if(e.treeNode||S(),k.section=="kit"||k.section=="base")if(e.treeNode){let M=nl("$root",e.treeNode.node.schemaId,k.value.node,e.treeNode.node.schemaId);M=nl(M.id,e.treeNode.node.id,M,e.treeNode.node.schemaId),s([{...M,type:k.section=="base"?M.type:"frame",styles:k.value.node.styles,ref:k.section=="base"?"":"spaces://$kit/#*"+k.value.def.id,parentId:e.treeNode.node.parentId,schemaId:e.treeNode.node.schemaId,id:e.treeNode.node.id,rank:e.treeNode.node.rank}]).then(O=>f(e.treeNode.id))}else o(k.section=="base"?k.value.node:{...k.value.node,type:"frame",styles:k.value.node.styles,ref:"spaces://$kit/#*"+k.value.def.id},h.exec.node,!0).then(M=>f(M.id));else k.section=="label"?e.treeNode?s([{...e.treeNode.node,type:"text",name:Yr.node.name,props:{...e.treeNode.node.props,value:mr(b)},styles:Yr.node.styles}]).then(M=>f(e.treeNode.id)):o({...Yr.node,props:{value:mr(b)}},h.exec.node,!0).then(M=>f(M.id)):k.section=="flow"?k.value.length>0?e.treeNode?s([{...e.treeNode.node,type:"flow",name:zi.node.name,props:{...e.treeNode.node.props,value:mr(k.value)},styles:zi.node.styles}]):o({...zi.node,props:{value:mr(k.value)}},h.exec.node,!0):Un(e.superstate,r,"md",b,!0).then(M=>{e.treeNode?s([{...e.treeNode.node,name:zi.node.name,type:"flow",props:{value:mr(M)},styles:{...zi.node.styles}}]):o({...zi.node,props:{value:mr(M)}},h.exec.node,!0)}):k.section=="list"&&uE(e.superstate,r.path).then(M=>{e.treeNode?s([{...e.treeNode.node,name:xf.node.name,type:"space",props:{value:mr(`${r.path}/#*${M}`)},styles:{...xf.node.styles}}]):o({...Yr.node,name:xf.node.name,type:"space",props:{value:mr(`${r.path}/#^${M}`)}},h.exec.node,!0)})},S=()=>{v(""),t.current.blur(),t.current.innerHTML=""};return(0,yl.useEffect)(()=>{t.current&&u&&u==e.treeNode?.node.id&&(t.current.focus(),l(null))},[t,c,e.treeNode]),yl.default.createElement("div",{className:"mk-node-new"},yl.default.createElement(VD,{superstate:e.superstate,placeholder:z.hintText.newFrame,suggestions:x,onChange:k=>v(k),onSelect:k=>{w(k)},onFocus:()=>{f(null)},ref:t,onDelete:()=>e.treeNode?a(e.treeNode?.node):S(),onSelectSection:k=>p(k)}))};var zh=he(Me());var eCe=he(Me());function MZ(e){(0,eCe.useEffect)(e,[])}var QD=he(Me());function kb(e,t,r=window){let n=(0,QD.useRef)(t);(0,QD.useEffect)(()=>{n.current=t},[t]),(0,QD.useEffect)(()=>{if(r==null)return;let i=a=>n.current(a);return r.addEventListener(e,i),()=>r.removeEventListener(e,i)},[e,r])}var Lh=he(Me());function NZ(e,t){let r=(0,Lh.useRef)(e),n=(0,Lh.useRef)(null);(0,Lh.useEffect)(()=>{r.current=e},[e]);let i=(0,Lh.useCallback)(()=>{n.current=setTimeout(()=>r.current(),t)},[t]),a=(0,Lh.useCallback)(()=>{n.current&&clearTimeout(n.current)},[]);return(0,Lh.useEffect)(()=>(i(),a),[t,i,a]),{reset:(0,Lh.useCallback)(()=>{a(),i()},[a,i]),clear:a}}function YD(e,t,{delay:r=400}={}){let{reset:n,clear:i}=NZ(t,r);MZ(i),kb("mousedown",n,e.current),kb("touchstart",n,e.current),kb("mouseup",i,e.current),kb("mouseleave",i,e.current),kb("touchend",i,e.current)}var G8=e=>{let{selectionMode:t,selection:r,selectable:n,selected:i,select:a}=(0,zh.useContext)(ji),o=(0,zh.useRef)(null),{updateNode:s,nodes:u,deleteNode:l}=(0,zh.useContext)(Oi),c=w=>{if(w!=e.state.props?.value)if(e.treeNode.editorProps?.linkedNode){let S=u.find(k=>k.id==e.treeNode.editorProps.linkedNode.node);s(S,{props:{...S.props,[e.treeNode.editorProps.linkedNode.prop]:mr(w)}})}else s(e.treeNode.node,{props:{...e.treeNode.node.props,value:mr(w)}})},f=w=>{let S=w.target.innerHTML;c(S)},d=w=>{w.stopPropagation()},p=w=>{w.stopPropagation()},h=w=>{if(w.stopPropagation(),(w.key=="Delete"||w.key=="Backspace")&&w.target.innerHTML==""&&l(e.treeNode.node),w.key=="a"&&w.metaKey){w.preventDefault();let S=window.getSelection(),k=document.createRange();k.selectNodeContents(w.target),S.removeAllRanges(),S.addRange(k)}w.key=="Enter"&&(w.target.blur(),w.preventDefault()),w.key=="Escape"&&(w.target.blur(),w.preventDefault())},m=w=>{x&&w.stopPropagation()},g=w=>{x&&w.stopPropagation(),t==3&&!e.treeNode.isRef&&a(e.treeNode.id)};YD(o,()=>{if(x){a(e.treeNode.node.id,!1);return}});let b=r.includes(e.treeNode.id),{linkedProps:v}=(0,zh.useContext)(vi),x=(0,zh.useMemo)(()=>t==0?!1:e.treeNode.isRef?!!(e.treeNode.editorProps.linkedNode&&i):v.some(w=>e.treeNode.editorProps.linkedNode?.node==e.treeNode.node.schemaId&&e.treeNode.editorProps.linkedNode?.prop==w)?!0:zl(e.treeNode.node.props.value)?!!(t==1||t==3&&b):!1,[e.treeNode,t,i,b,v]);return e.state&&zh.default.createElement("div",{className:"mk-frame-text","data-placeholder":x||n?z.labels.textPlaceholder:"",dangerouslySetInnerHTML:{__html:e.state.props?.value},onClick:m,onMouseDown:g,onBlur:f,onDrop:w=>w.preventDefault(),onKeyDown:h,onKeyPress:d,onKeyUp:p,ref:o,contentEditable:x})};var FZ={position:"relative"},Xet=(0,zt.memo)(function(t){let r={superstate:t.superstate,treeNode:t.treeNode,state:t.state},{treeNode:n}=t,{pathState:i}=(0,zt.useContext)(qr),{instance:a}=(0,zt.useContext)(vi);return zt.default.createElement(zt.default.Fragment,null,n.node.type=="new"?zt.default.createElement(V8,{...r}):n.node.type=="input"?zt.default.createElement(H8,{...r}):n.node.type=="text"?zt.default.createElement(G8,{...r}):n.node.type=="icon"?zt.default.createElement(U8,{...r}):n.node.type=="audio"?zt.default.createElement(M8,{...r}):n.node.type=="image"?zt.default.createElement(W8,{...r}):n.node.type=="space"?zt.default.createElement(T8,{...r,containerRef:t.containerRef,source:i.path}):n.node.type=="flow"?zt.default.createElement(F8,{...r,source:i.path,containerRef:t.containerRef}):n.node.type=="content"?zt.default.createElement(N8,{editable:!t.treeNode.isRef},t.treeNode.children.map((o,s)=>o.node.type=="slides"?null:zt.default.createElement(ZD,{superstate:t.superstate,key:o.id,treeNode:o,instance:t.instance,containerRef:t.containerRef},t.children)),t.children):(n.node.type=="column"||n.node.type=="container")&&n.children.length==0?null:t.treeNode.id==t.instance.exec.id||n.node.type=="column"||n.node.type=="container"?t.treeNode.children.map((o,s)=>o.node.type=="slides"?null:zt.default.createElement(ZD,{superstate:t.superstate,key:o.id,treeNode:o,instance:t.instance,containerRef:t.containerRef},t.children)):zt.default.createElement(zt.default.Fragment,null,zt.default.createElement(Lv,{superstate:t.superstate,id:n.id,editMode:t.editMode},n.children.map((o,s)=>o.node.type=="slides"?null:zt.default.createElement(ZD,{superstate:t.superstate,key:o.id,treeNode:o,instance:t.instance,containerRef:t.containerRef},t.children)))))}),ZD=e=>{let{selectionMode:t,selectable:r,selected:n,isParentToSelection:i,select:a,selection:o}=(0,zt.useContext)(ji),{updateNode:s,addNode:u,deleteNode:l,nodes:c,selectedSlide:f}=(0,zt.useContext)(Oi),{setDragNode:d}=(0,zt.useContext)(vh),{saveState:p,selectableNodeBounds:h,id:m}=(0,zt.useContext)(vi),{dragActive:g}=(0,zt.useContext)(vh),A=e.treeNode.isRef?0:e.treeNode.id==e.instance.exec.id?t:3,b=o.some(X=>X==e.treeNode.id),v=r&&!e.treeNode.isRef&&!b,x=e.instance.state[e.treeNode.id],w=(0,zt.useMemo)(()=>f?c.find(X=>X.ref==e.treeNode.id&&f==X.parentId)??null:null,[c,e.treeNode,f]),S=(0,zt.useMemo)(()=>w?{...e.treeNode,node:{...e.treeNode.node,styles:{...e.treeNode.node.styles,...w.styles},props:{...e.treeNode.node.props,...w.props},actions:{...e.treeNode.node.actions,...w.actions}}}:e.treeNode,[w,e.treeNode]),{frameSchema:k}=(0,zt.useContext)(va),M=m+k.id+e.treeNode.id,[O,D]=(0,zt.useState)(!1),[N,C]=zt.default.useState(!1),[_,I]=zt.default.useState(!1),L=e.treeNode.editorProps.dragMode==1||(v&&!i||b)&&e.treeNode.editorProps.dragMode!=0,{attributes:$,listeners:T,setNodeRef:W,transform:P}=Vs({id:M,data:{id:M,root:m,type:"node",parent:e.treeNode.node.parentId,frame:k.id,node:e.treeNode.id},disabled:!L}),Y=(0,zt.useRef)(null),oe=()=>{if(v&&e.treeNode.id!=e.instance.exec.id){a(S.node.id);return}},re=e.instance.state[e.treeNode.id]?.styles?!!e.instance.state[e.treeNode.id]?.styles?.hidden:!1,Q={superstate:e.superstate,treeNode:S,state:x},de=X=>{s(S.node,{styles:{...X}})},Pe=X=>{if(v&&(t!=1||i&&e.treeNode.id!=e.instance.exec.id)){X.shiftKey?a(S.node.id,!0):a(S.node.id),X.stopPropagation();return}else e.treeNode.id==e.instance.exec.id&&a(null);if(b)X.stopPropagation();else{if((X.detail===2||cr(e.superstate.ui))&&typeof x.actions?.onDoubleClick=="function"){x.actions?.onDoubleClick(X,null,e.instance.state,te=>p(te,e.instance),e.superstate.api),X.stopPropagation();return}X.detail===1&&typeof x.actions?.onClick=="function"&&(x.actions?.onClick(X,null,e.instance.state,te=>p(te,e.instance),e.superstate.api),X.stopPropagation())}};(0,zt.useEffect)(()=>{o.some(X=>X!=e.treeNode.id)&&D(!1)},[o,e.treeNode]);let[xe,Ce]=(0,zt.useState)(!1);(0,zt.useEffect)(()=>{b&&cr(e.superstate.ui)&&(e.treeNode.node.type=="group"||e.treeNode.node.type=="image"||t>=3)?Ce(!0):b&&xe||Ce(!1)},[e.treeNode,t,b]);let Be=e.treeNode.editorProps.dropMode,Fe=Y.current&&getComputedStyle(Y.current),Se=Y.current&&Y.current.clientWidth,ge=Y.current&&Y.current.clientHeight,[q,ae]=(0,zt.useState)([]),le=(X,te)=>({left:X.x-te.x,top:X.y-te.y,width:X.width,height:X.height});(0,zt.useEffect)(()=>{if(!Y.current||!e.containerRef?.current)return()=>null;e.treeNode.node.parentId==e.instance.exec.id&&(h.current[e.treeNode.id]=le(Y.current.getBoundingClientRect(),e.containerRef.current.getBoundingClientRect())),ae(()=>Array.from(Y.current?.children??[]).map(ne=>({x:ne.offsetLeft,y:ne.offsetTop,width:ne.clientWidth,height:ne.clientHeight})));let X=new ResizeObserver(()=>{e.treeNode.node.parentId==e.instance.exec.id&&Y.current&&(h.current[e.treeNode.id]=le(Y.current.getBoundingClientRect(),e.containerRef.current.getBoundingClientRect())),ae(()=>Array.from(Y.current?.children??[]).map(ne=>({x:ne.offsetLeft,y:ne.offsetTop,width:ne.clientWidth,height:ne.clientHeight})))});return X.observe(Y.current),()=>X.disconnect()},[x]);let U=Y.current?.getBoundingClientRect(),B=e.containerRef?.current?.getBoundingClientRect(),K={...FZ,...e.treeNode.node.type!="flow"?x?.styles:{width:x?.styles?.width,height:x?.styles?.height,"--max-width":x?.styles?.["--max-width"]},"--translate-x":`${P?.x??0}px`,"--translate-y":`${P?.y??0}px`};return Da({onDragStart:X=>{X.active?.id==M&&d(zt.default.createElement("div",{style:{width:Y.current.clientWidth}},zt.default.createElement(fE,{superstate:e.superstate,treeNode:e.treeNode,instance:e.instance,saveState:null})))}}),zt.default.createElement(zt.default.Fragment,null,(!re||!e.treeNode.isRef)&&zt.default.createElement("div",{ref:X=>{Y.current=X,t>1&&L&&W(X)},onContextMenu:()=>cr(e.superstate.ui)&&oe(),className:(0,TZ.default)(`mk-frame-edit ${aE(x?.styles)}`,v&&t!=1&&"mk-f-editable",b&&t==1&&"mk-selected"),"data-path":S.id,"data-type":S.node.type,onMouseEnter:()=>{D(!0),C(!0)},onMouseLeave:()=>{_||D(!1),C(!1)},...{onClick:Pe},...t>1?{...T,...$}:{},style:K},zt.default.createElement(Xet,{...Q,containerRef:e.containerRef,editMode:A,instance:e.instance},e.children)),x&&e.treeNode.node.type!="new"&&e.containerRef?.current&&t>0&&Y.current&&(0,tCe.createPortal)(zt.default.createElement(zt.default.Fragment,null,zt.default.createElement("div",{style:{position:"absolute",top:U.top-B.top,left:U.left-B.left,width:Se,height:ge,pointerEvents:"none"},className:(0,TZ.default)(!g&&v&&t!=1&&"mk-f-editable",!g&&b&&(t!=1||e.treeNode.node.type=="group")&&"mk-f-edit",!g&&O&&t!=1&&"mk-f-edit-hover"),onClick:X=>{if(v&&t!=1){X.shiftKey?a(S.node.id,!0):a(S.node.id),X.stopPropagation();return}}},e.treeNode.editorProps.resizeMode==2&&zt.default.createElement(jZ,{size:x?.styles,superstate:e.superstate,resizeMode:e.treeNode.editorProps.resizeMode,resize:de,clientSize:{width:Se,height:ge}}),g&&(t==1||t==3)&&Be>0&&zt.default.createElement(L6e,{parentId:S.node.parentId,superstate:e.superstate,height:ge,width:Se,node:S.node.id,id:M,mode:Be,insertMode:S.node.type=="group"?1:S.node.type=="space"?-1:0}),xe&&zt.default.createElement(zt.default.Fragment,null,zt.default.createElement(jZ,{superstate:e.superstate,resizeMode:1,size:x?.styles,resize:de,clientSize:{width:Se,height:ge}}),zt.default.createElement($6e,{styles:x?.styles,saveStyles:de,clientSize:{width:Se,height:ge}}),(S.node.type=="group"||S.node.type=="content")&&(x.styles?.layout=="row"||x.styles?.layout=="column")&&zt.default.createElement(zt.default.Fragment,null,zt.default.createElement(z6e,{childSizes:q,clientSize:{width:Se,height:ge,paddingBottom:parseInt(Fe?.paddingBottom??"0"),paddingLeft:parseInt(Fe?.paddingLeft??"0"),paddingRight:parseInt(Fe?.paddingRight??"0"),paddingTop:parseInt(Fe?.paddingTop??"0")},styles:x?.styles,saveStyles:de,direction:x?.styles.layout=="column"?"column":"row"}),zt.default.createElement(W6e,{clientSize:{width:Se,height:ge},styles:x?.styles,saveStyles:de}))),S.editorProps.dragMode==1&&(!cr(e.superstate.ui)||b)?zt.default.createElement("div",{onMouseEnter:()=>{I(!0),D(!0)},onMouseLeave:()=>{N||D(!1),I(!1)},className:"mk-editor-frame-hover-menu-container",style:{zIndex:O?"calc(var(--layer-popover) + 1)":"var(--layer-popover)"}},zt.default.createElement(B6e,{superstate:e.superstate,node:S.node,mode:t==1?0:1,selected:b,visible:cr(e.superstate.ui)||O,dragRef:W,attributes:$,listeners:T})):zt.default.createElement(zt.default.Fragment,null)),o&&!g&&b&&o.length==1?zt.default.createElement(DZ,{nodeRect:U,containerRect:B},zt.default.createElement(I6e,{editLayout:X=>Ce(X),superstate:e.superstate,node:S.node,duplicateFrame:()=>{u(S.node,S.node)},state:x,deleteFrame:()=>l(S.node),fields:tle(S.node)})):o.length>1&&o[0]==S.id?zt.default.createElement(DZ,{nodeRect:U,containerRect:B},zt.default.createElement(v6e,{superstate:e.superstate})):null),e.containerRef.current))};var fE=e=>{let t={superstate:e.superstate,treeNode:e.treeNode,state:e.instance.state[e.treeNode.id]},r=e.treeNode.node.type=="input"?ip.default.createElement(H8,{...t}):e.treeNode.node.type=="text"?ip.default.createElement(G8,{...t}):e.treeNode.node.type=="icon"?ip.default.createElement(U8,{...t}):e.treeNode.node.type=="audio"?ip.default.createElement(M8,{...t}):e.treeNode.node.type=="image"?ip.default.createElement(W8,{...t}):e.treeNode.node.type=="space"?ip.default.createElement(T8,{...t,source:e.source}):e.treeNode.node.type=="content"?ip.default.createElement(N8,null,e.treeNode.children.filter(i=>i.node.type!="slides").map((i,a)=>ip.default.createElement(fE,{superstate:e.superstate,key:a,treeNode:i,instance:e.instance,saveState:e.saveState,source:e.source},e.children)),e.children):e.treeNode.node.type=="flow"?ip.default.createElement(F8,{...t,source:e.source}):e.treeNode.children.filter(i=>i.node.type!="slides").map((i,a)=>ip.default.createElement(fE,{superstate:e.superstate,key:a,treeNode:i,instance:e.instance,saveState:e.saveState,source:e.source},e.children)),n=e.instance.state[e.treeNode.id]?.styles?!!e.instance.state[e.treeNode.id]?.styles?.hidden:!1;return e.instance.state[e.treeNode.id]&&!n&&ip.default.createElement("div",{className:`mk-frame ${aE(e.instance.state[e.treeNode.id]?.styles)}`,"data-path":e.treeNode.id,"data-type":e.treeNode.node.type,onContextMenu:i=>{typeof e.instance.state[e.treeNode.id].actions?.onContextMenu=="function"&&(e.instance.state[e.treeNode.id].actions?.onContextMenu(i,null,e.instance.state,a=>e.saveState(a,e.instance),e.superstate.api),i.stopPropagation())},onClick:i=>{if((i.detail===2||cr(e.superstate.ui))&&typeof e.instance.state[e.treeNode.id].actions?.onDoubleClick=="function"){e.instance.state[e.treeNode.id].actions?.onDoubleClick(i,null,e.instance.state,a=>e.saveState(a,e.instance),e.superstate.api),i.stopPropagation();return}i.detail===1&&typeof e.instance.state[e.treeNode.id].actions?.onClick=="function"&&(e.instance.state[e.treeNode.id].actions?.onClick(i,null,e.instance.state,a=>e.saveState(a,e.instance),e.superstate.api),i.stopPropagation())},style:{...FZ,...e.instance.state[e.treeNode.id]?.styles}},r)};var Cb=e=>{let{saveState:t,instance:r}=(0,Q8.useContext)(vi);return r.exec&&Q8.default.createElement(fE,{superstate:e.superstate,treeNode:r.exec,instance:r,saveState:t,source:e.source},e.children)};var Jv=e=>{let t=(0,rs.useMemo)(()=>e.superstate.spaceManager.uriByString(e.path,e.source),[e.path,e.source]),[r,n]=(0,rs.useState)(null);return(0,rs.useEffect)(()=>{t.refType=="context"?n({type:"context",path:t.basePath,contextSchema:t.ref,frameSchema:t.query?.frameSchema}):t.refType=="frame"?e.superstate.spaceManager.readFrame(t.basePath,t.ref).then(i=>{let a=i?.schema;!a&&t.ref==Op.id&&(a=Op,n({type:"context",path:t.basePath,frameSchema:a.id})),a?.type=="view"?n({type:"context",path:t.basePath,frameSchema:t.ref}):n({type:"frame",path:t.basePath,frameSchema:t.ref})}):t.refType=="action"?n({type:"action",path:t.basePath,actionSchema:t.ref}):n({type:"context",path:t.basePath,frameSchema:A0})},[t]),rs.default.createElement(rs.default.Fragment,null,r?.path&&(r?.type=="context"?rs.default.createElement(Ks,{superstate:e.superstate,path:r.path,readMode:!1},rs.default.createElement(gh,{superstate:e.superstate},rs.default.createElement(Mv,{superstate:e.superstate,contextSchema:r.contextSchema,schema:r.frameSchema},rs.default.createElement(DS,{superstate:e.superstate},rs.default.createElement(dE,{showTitle:e.showTitle,superstate:e.superstate,minMode:e.minMode,containerRef:e.containerRef,setView:e.setFrameSchema}))))):r?.type=="frame"?rs.default.createElement(V9,{superstate:e.superstate,path:t,cols:[]},rs.default.createElement(vg,{id:e.id,superstate:e.superstate,props:{},editable:!1},rs.default.createElement(Cb,{superstate:e.superstate,source:e.source}))):r?.type=="action"?rs.default.createElement(j8,{superstate:e.superstate,action:e.path}):rs.default.createElement(rs.default.Fragment,null)))};var _8=e=>{let[t,r]=(0,Vc.useState)(e.superstate.pathsIndex.get(e.path)),n=(0,Vc.useRef)(null);return(0,Vc.useEffect)(()=>{let i=e.superstate.spaceManager.uriByString(e.path),a=e.superstate.pathsIndex.get(e.path);if(!a&&(i?.scheme=="https"||i?.scheme=="http")){r({path:e.path,label:{sticker:i.scheme,name:i.path,color:""},hidden:!1,readOnly:!0,subtype:"md",type:"remote"});return}r(a)},[e.path]),Vc.default.createElement("div",{className:"mk-path-view",style:{...e.styles??{}}},t?.type=="remote"?t.subtype=="note"?Vc.default.createElement(Zd,{superstate:e.superstate,path:e.path,load:!0,classname:"mk-flow-node"}):Vc.default.createElement("iframe",{src:e.path}):t?.type=="space"?Vc.default.createElement(Jv,{id:e.id,showTitle:!0,containerRef:n,superstate:e.superstate,path:e.path}):e.superstate.ui.availableViews().some(i=>i==e.path?.split(".").pop())?Vc.default.createElement(Zd,{superstate:e.superstate,path:e.path,load:!0,classname:"mk-flow-node"}):Vc.default.createElement(Vc.default.Fragment,null))};var iCe=e=>{let[t,r]=(0,Sr.useState)(null),[n,i]=(0,Sr.useState)(!1),[a,o]=(0,Sr.useState)(!1),[s,u]=(0,Sr.useState)(""),[l,c]=(0,Sr.useState)(0),f=N=>{u(N)},[d,p]=(0,Sr.useState)([]),h=(0,Sr.useMemo)(()=>s.length>0?[{type:"any",trueFalse:!0,filters:[{type:"file",fType:"text",field:"name",fn:"include",value:s}]},...d]:d,[s,d]),m=N=>({type:"path",value:N.path,cache:N,sticker:N.label.sticker,description:N.label.preview,label:N.name}),g=e.parentSpace?[{type:"section",label:"Items"},...[...e.superstate.spacesMap.getInverse(e.parentSpace)].map(N=>e.superstate.pathsIndex.get(N)).filter(N=>N&&!N.hidden).map(N=>m(N))]:[],A=[{type:"section",label:"Recent"},...e.superstate.ui.navigationHistory().map(N=>e.superstate.pathsIndex.get(N)).filter(N=>N&&!N.hidden).map(N=>m(N))],[b,v]=(0,Sr.useState)(e.parentSpace?g:A);(0,Sr.useEffect)(()=>{let N=(C,_)=>{if(C.length==0&&s.length==0){v(e.parentSpace?g:A);return}if(d.length==0){e.superstate.searcher.run({type:"fastSearch",path:C,payload:{query:s,count:10}}).then(I=>v([{type:"section",label:"Results"},...I.map(L=>m(L)),{type:"section",label:"Create New"},{type:"new-note",sticker:"ui//edit",value:s,label:"New Note"},{type:"new-space",sticker:"ui//folder-plus",value:s,label:"New Space"}]));return}if(!e.superstate.settings.searchWorker){let I=JEe({queries:_,count:10,pathsIndex:e.superstate.pathsIndex});v([{type:"section",label:"Results"},...I.map(L=>m(L)),{type:"new-note",sticker:"ui//plus",value:s,label:"New Note"},{type:"new-space",sticker:"ui//plus",value:s,label:"New Space"}]);return}e.superstate.searcher.run({type:"search",path:C,payload:{queries:_,count:10}}).then(I=>v(I.map(L=>m(L))))};(0,rCe.debounce)(()=>N(s,h),300)()},[s,h]),(0,Sr.useEffect)(()=>{if(!b[l]||b[l].type!="path")return;let N=b[l]?.cache?.path;!N||N==t||r(b[l]?.cache?.path)},[l,b]);let x=(N,C)=>{if(!!N&&N.type!="section"){if(N.type=="new-note"){if(e.parentSpace){let _=e.superstate.spacesIndex.get(e.parentSpace);if(_){Un(e.superstate,_,"md",s).then(I=>{e.mode==2&&e.onSelect(I),e.hide()});return}}dS(e.superstate,e.superstate.pathsIndex.get(e.superstate.ui.activePath)).then(_=>Un(e.superstate,_,"md",s).then(I=>{e.mode==2&&e.onSelect(I),e.hide()}));return}if(N.type=="new-space"){let _=e.superstate.pathsIndex.get(e.parentSpace)??e.superstate.pathsIndex.get("/"),I=s.replace(/\//g,""),L=_?.subtype=="folder"?_.path:_.parent?_.parent:"/",$=!L||L=="/"?I:L+"/"+I;if(I.length==0){e.superstate.ui.notify(z.notice.newSpaceName);return}if(e.superstate.spacesIndex.has($)){e.superstate.ui.notify(z.notice.duplicateSpaceName);return}Tf(e.superstate,$,{}).then(T=>{e.mode==2&&e.onSelect(T.path),e.hide()});return}if(N.cache){if(e.mode==2){e.onSelect(N.cache?.path),e.hide();return}if(!n||C){e.superstate.ui.openPath(N.cache?.path),e.hide();return}}c(b.findIndex(_=>_.cache?.path==N.cache?.path))}},w=[],S=N=>{if(N.key=="Tab"&&w&&(N.preventDefault(),N.stopPropagation()),N.key=="ArrowUp"){let _=l<=0?b.length-1:l-1;if(b.length==0)return;!b[_]||b[_].type=="section"?c(_<0?b.length-1:_-1):c(_),N.preventDefault()}if(N.key=="ArrowDown"){let C=b.length-1,_=l>=C?0:l+1;!b[_]||b[_].type=="section"?c(_>=C?0:_+1):c(_),c(_),N.preventDefault()}N.key=="Enter"&&(x(b[l],!0),N.preventDefault())},k=Sr.default.useRef(null);(0,Sr.useEffect)(()=>{k.current?.focus()},[k.current]);let M=T9(e.superstate),O=[];Object.keys(M).forEach(N=>{M[N].properties.forEach(C=>{O.push({...C})})});let D=Object.keys(M).map(N=>({name:M[N].name,value:N}));return Sr.default.createElement(Sr.default.Fragment,null,Sr.default.createElement("div",{className:"mk-blink-input-container"},Sr.default.createElement("div",{className:"mk-icon-small",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//search")}}),Sr.default.createElement("div",{"data-placeholder":z.labels.blinkPlaceholder,onInput:N=>f(N.currentTarget.innerText),onKeyDown:N=>S(N),ref:k,contentEditable:!0,className:"mk-blink-input"}),e.mode==1&&Sr.default.createElement(Sr.default.Fragment,null,Sr.default.createElement("button",{onClick:()=>i(N=>!N),className:"mk-toolbar-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//blink")}}),Sr.default.createElement("button",{className:"mk-toolbar-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//filter")},onClick:()=>o(!a)}))),a&&Sr.default.createElement("div",{className:"mk-blink-filters"},Sr.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//filter")}}),Sr.default.createElement(BS,{superstate:e.superstate,filters:d,setFilters:p,fields:O,sections:D})),Sr.default.createElement("div",{className:"mk-blink-suggester",style:{}},Sr.default.createElement("div",{className:"mk-blink-suggestions"},b.map((N,C)=>Sr.default.createElement("div",{key:C,className:(0,nCe.default)(N.type=="section"?"mk-blink-section":"mk-blink-suggestion",l==C&&"mk-active"),onClick:_=>x(N)},N.type=="section"?Sr.default.createElement("div",{className:"mk-blink-suggestion-title"},N.label):Sr.default.createElement(Sr.default.Fragment,null,Sr.default.createElement("div",{className:"mk-blink-suggestion-icon",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(N.sticker)}}),Sr.default.createElement("div",{className:"mk-blink-suggestion-text"},Sr.default.createElement("div",{className:"mk-blink-suggestion-title"},N.label),Sr.default.createElement("div",{className:"mk-blink-suggestion-description"},N.value),N.description&&Sr.default.createElement("div",{className:"mk-blink-suggestion-preview"},N.description)))))),e.mode==1&&n&&Sr.default.createElement(Ket,{superstate:e.superstate,path:t})))},Ket=e=>{let t=Sr.default.useRef(null),[r,n]=(0,Sr.useState)(!1);return Sr.default.createElement("div",{className:"mk-blink-preview",ref:t},Sr.default.createElement("div",{className:"mk-blink-preview-title"},Sr.default.createElement(Pa,{superstate:e.superstate,path:e.path}),Sr.default.createElement("span",null),Sr.default.createElement("button",{className:r?"is-active mk-icon-small":"mk-icon-small",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//list")},onClick:()=>n(!r)})),Sr.default.createElement(_8,{id:"blink",superstate:e.superstate,path:e.path,containerRef:t,styles:{},readOnly:!0}),r&&Sr.default.createElement("div",{className:"mk-blink-properties"},Sr.default.createElement("div",{className:"mk-blink-properties-header"},"Properties"),Sr.default.createElement(Ks,{path:e.path,superstate:e.superstate,readMode:!1})))};var zf=(e,t,r,n,i)=>{e.ui.openPalette(aCe.default.createElement(iCe,{superstate:e,mode:t,onSelect:n,parentSpace:i}),r,"mk-blink-modal")};var Bu=he(Me());var t1=he(Me()),mE=e=>{let t=_r(e.superstate,e.date,e.mode=="day"?"MMMM d":"MMMM");return t1.default.createElement("div",{className:"mk-calendar-header"},t1.default.createElement("div",{className:"mk-calendar-header-title"},t1.default.createElement("span",null,t),_r(e.superstate,e.date,"yyyy")),t1.default.createElement("span",null),t1.default.createElement("button",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//chevron-left")},onClick:()=>{if(e.mode=="day"){e.setDate(new Date(e.date.setDate(e.date.getDate()-1)));return}else if(e.mode=="week"){e.setDate(new Date(e.date.setDate(e.date.getDate()-7)));return}e.setDate(new Date(e.date.setMonth(e.date.getMonth()-1)))}}),t1.default.createElement("button",{onClick:()=>{e.setDate(new Date)}},"Today"),t1.default.createElement("button",{onClick:()=>{if(e.mode=="day"){e.setDate(new Date(e.date.setDate(e.date.getDate()+1)));return}if(e.mode=="week"){e.setDate(new Date(e.date.setDate(e.date.getDate()+7)));return}e.setDate(new Date(e.date.setMonth(e.date.getMonth()+1)))},dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//chevron-right")}}))};var _Z=he(Me()),Y8=e=>{let{attributes:t,listeners:r,setNodeRef:n,transform:i}=Vs({id:"event-"+e.index,data:{type:"event",index:e.index}});return _Z.default.createElement("div",{className:"mk-week-event",ref:n,...t,...r,style:{...e.style,left:"2px",width:`calc(${(e.endDay-e.startDay+1)*100}% - 4px)`,top:`${e.topOffset*22+2}px`}},_Z.default.createElement(Pa,{superstate:e.superstate,path:e.data[gt]}))};var XD=he(Me()),Z8=e=>XD.default.createElement("div",{className:"mk-day-view-gutter"},e.allDay&&XD.default.createElement("div",{className:"mk-day-view-hour-title"},"all day"),Array.from({length:e.endHour-e.startHour+1}).map((t,r)=>{let n=r+e.startHour;return XD.default.createElement("div",{key:n,className:"mk-day-view-hour-title"},XD.default.createElement("span",null,n%12===0?12:n%12)," ",n<12?"AM":"PM")}));var ko=he(Me());var KD=e=>{let{event:t,hourHeight:r,startHour:n}=e,{spaceState:i}=(0,ko.useContext)(ar),{attributes:a,listeners:o,setNodeRef:s,transform:u}=Vs({id:`event-${t?.index??""}-${t?.start?.getTime().toString()??""}-${e.clone?"clone":""}`,data:{type:"event",index:t?.index}}),l="#0098FF",[c,f]=(0,ko.useState)(null),d=c||t,p=(0,ko.useMemo)(()=>{let h=t.start??xk(Gn(new Date),e.event.startOffset),m=t.end??xk(Gn(new Date),e.event.endOffset),g=_r(e.superstate,h,"a")===_r(e.superstate,m,"a"),A=`h${h.getMinutes()==0?"":":mm"} ${g?"":"a"}`,b=`h${m.getMinutes()==0?"":":mm"} a`;return e.event.startOffset>0?`${_r(e.superstate,h,A)} - ${_r(e.superstate,m,b)}`:null},[e.event]);return ko.default.createElement("div",{key:t.index,onMouseDown:h=>{h.stopPropagation()},onContextMenu:h=>{let m=h.currentTarget.getBoundingClientRect();Jp(e.superstate,e.item[gt],i.path,m,je(h.currentTarget.ownerDocument))},className:"mk-day-block",style:{zIndex:1,...e.style||{},...e.clone?{top:`${(d.startOffset/60-n)*r}px`,width:`calc(${t.widthPercentage}% - ${t.leftOffset*8}px)`,height:`${(d.endOffset-d.startOffset)*r/60}px`}:{top:`${(d.startOffset/60-n)*r}px`,height:`${(d.endOffset-d.startOffset)*r/60}px`,left:`calc(${d.column*d.widthPercentage}% + ${d.leftOffset*8}px)`,width:`calc(${d.widthPercentage}% - ${d.leftOffset*8}px)`}}},ko.default.createElement("div",{...a,...o,ref:s,className:"mk-day-block-inner",style:{"--block-color":l,"--block-bg-color":yg(40,l)}},ko.default.createElement("div",{className:"mk-day-block-inner-indicator"}),ko.default.createElement("div",{className:"mk-day-block-content"},e.item[gt]?ko.default.createElement(Pa,{superstate:e.superstate,path:e.item[gt],hideIcon:!0}):"New Event",p&&ko.default.createElement("div",{className:"mk-day-block-time"},ko.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//clock")}}),p)),ko.default.createElement("span",null),d.repeat&&ko.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//sync")}}),!d.allDay&&ko.default.createElement(ko.default.Fragment,null,ko.default.createElement("div",{className:"mk-day-handle-n"},ko.default.createElement(au,{value:d.startOffset,cursor:"s",reverseY:!0,disableX:!0,step:60/r,onDragMove:h=>{let m={...t,startOffset:Math.round(h/15)*15};f(m)},onDragEnd:h=>{e.updateStartEnd&&e.updateStartEnd(Math.round(h/15)*15,d.endOffset),f(null)}})),ko.default.createElement("div",{className:"mk-day-handle-s"},ko.default.createElement(au,{value:d.endOffset,cursor:"s",reverseY:!0,disableX:!0,step:60/r,onDragMove:h=>{let m={...t,endOffset:Math.round(h/15)*15};f(m)},onDragEnd:h=>{e.updateStartEnd&&e.updateStartEnd(d.startOffset,Math.round(h/15)*15),f(null)}})))))};var X8=e=>{let{hourHeight:t}=e,[r,n]=(0,Gc.useState)(e.date??Gn(new Date)),{source:i}=(0,Gc.useContext)(_a),[a,o]=(0,Gc.useState)(null),s=`day-view-${r.toDateString()}`,u=e.startHour??0,l=(N,C,_,I,L)=>{if(!N||!_||!I)return[];let $=[],T=[];N.forEach((W,P)=>{let Y=lr(W[L]),oe=[],re=da(W[_]);if(re>=C&&re<=Sa(C,{days:1})&&oe.push(W),Y&&Y.freq){let Q=da(W[I]).getTime()-re.getTime(),de={dtstart:re,freq:Y.freq&&hM(Y.freq),count:Y.count&&Math.min(parseInt(Y.count),100),interval:Y.interval&&parseInt(Y.interval),byweekday:Y.byweekday&&Y.byweekday.map(Ce=>uw(Ce)),until:Y.until&&new Date(Math.min((da(Y.until)??Sa(C,{days:1})).getTime(),Sa(C,{days:1}).getTime())),wkst:Y.wkst&&uw(Y.wkst)};new Ht(Object.entries(de).filter(([Ce,Be])=>Be!==void 0).reduce((Ce,[Be,Fe])=>(Ce[Be]=Fe,Ce),{})).between(C,Sa(C,{days:1}),!0).forEach(Ce=>{Ce.getTime()!=re.getTime()&&oe.push({...W,[_]:_r(e.superstate,Ce,Ls),[I]:_r(e.superstate,ud(Ce,Q),Ls)})})}oe.forEach(Q=>{let de=Gn(r).getTime(),Pe=Sa(r,{days:1}).getTime(),xe=da(Q[_]),Ce=da(Q[I])??Gn(xe).getTime()==xe.getTime()?xe:Sa(xe,{hours:1}),Be=Math.max(u*60,(xe.getTime()-de)/6e4),Fe=Math.min(Ce.getTime()-de,Pe-de)/6e4;if(xe.getTime()==Gn(xe).getTime()){T.push({index:P,start:xe,end:Ce,startOffset:u*60,endOffset:60*24,leftOffset:0,widthPercentage:100,column:0,columnTotal:1,allDay:!0});return}let ge=!1;for(let q=0;q<$.length;q++){let ae=$[q],le=ae[0];if(Be>=le.startOffset-15&&Be<=le.startOffset+15){ae.push({index:P,start:xe,end:Ce,repeat:!!Y,startOffset:Be,endOffset:Fe}),ge=!0;break}}ge||$.push([{index:P,repeat:!!Y,start:xe,end:Ce,startOffset:Be,endOffset:Fe}])})}),$.forEach((W,P)=>{W.forEach((Y,oe)=>{T.push({...Y,leftOffset:0,widthPercentage:100/W.length,column:oe,columnTotal:W.length})})}),T.sort((W,P)=>W.startOffset-P.startOffset);for(let W=0;WT[P].startOffset&&T[W].startOffsetl(e.data,r,e.field,e.fieldEnd,e.fieldRepeat),[e.data,r,e.field,e.fieldEnd,e.fieldRepeat]),[d,p]=(0,Gc.useState)(null),[h,m]=(0,Gc.useState)(null),[g,A]=(0,Gc.useState)(null),[b,v]=(0,Gc.useState)(null),x=()=>{p(null),m(null),A(null),v(null)},w=N=>Math.round(N/15)*15;Da({onDragStart:N=>{N.active.data.current.type==="event"&&(p(N.active.data.current.index),o(null))},onDragOver:N=>{if(N.over?.id!=s||(p(N.active.data.current.index),N.active.data.current.type==="event"))return;let C=N.activatorEvent.clientY,_=N.over.rect.top;v(C-_),m(N.active?.data.current.path)},onDragMove:N=>{if(N.over?.id!=s)return;N.active.data.current.type!="event"&&m(N.active?.data.current.path);let C=N.over.rect,_=N.delta.y,I=2*Math.round(_/2);g!==I&&A(I)},onDragCancel:()=>{x()},onDragEnd:N=>{if(N.active.data.current.type==="event"&&N.over?.id==s){let{index:C}=N.active.data.current,_=f.find($=>$.index==C);if(!_){x();return}let I=Sa(r,{minutes:Math.round(w(_.startOffset+g/t*60))}),L=Sa(r,{minutes:Math.round(w(_.endOffset+g/t*60))});e.updateItem({...e.data[C],[e.field]:_r(e.superstate,I,Ls),[e.fieldEnd]:_r(e.superstate,L,Ls)})}else if(h){let C=Sa(r,{minutes:Math.round(g/t*60)}),_=Sa(r,{minutes:Math.round(g/t*60)+60});e.insertItem({[e.field]:_r(e.superstate,C,Ls),[e.fieldEnd]:_r(e.superstate,_,Ls),[gt]:h})}x()}});let{setNodeRef:S}=ql({id:s,data:{type:"day-view",date:r}}),k=new Date().toDateString()===r.toDateString(),[M,O]=(0,Gc.useState)(0),D=f.find(N=>N.index==d);return(0,Gc.useEffect)(()=>{let N;return k&&(O((new Date().getHours()-u)*60+new Date().getMinutes()),N=setInterval(()=>{O((new Date().getHours()-u)*60+new Date().getMinutes())},6e4)),()=>{N&&clearInterval(N)}},[]),Bu.default.createElement("div",{className:"mk-day-view-container",style:{"--hour-height":`${t}px`}},e.header&&Bu.default.createElement(mE,{superstate:e.superstate,date:r,mode:"day",setDate:n}),e.gutter&&Bu.default.createElement("div",{className:"mk-day-view-all-day"},Bu.default.createElement("div",{className:"mk-day-view-gutter"},Bu.default.createElement("div",{className:"mk-day-view-hour-title"},"all day")),Bu.default.createElement("div",{className:"mk-day-view-hour"},f.filter(N=>N.allDay).map((N,C)=>Bu.default.createElement(Y8,{superstate:e.superstate,key:C,index:N.index,startDay:0,endDay:0,topOffset:0,data:e.data[N.index],style:{position:"relative","--block-bg-color":yg(40,"#0098FF"),"--block-color":"#0098FF"}})))),Bu.default.createElement("div",{className:"mk-day-view"},e.gutter&&Bu.default.createElement(Z8,{hourHeight:t,startHour:u,endHour:c}),Bu.default.createElement("div",{className:"mk-day-view-content",ref:S,onMouseDown:N=>{if(N.button!=0)return;let C=N.currentTarget.scrollTop,_=N.clientY-N.currentTarget.getBoundingClientRect().top+C;o({index:-1,startOffset:w((_/t+u)*60),endOffset:w((_/t+u)*60),leftOffset:0,widthPercentage:100,column:0,columnTotal:1})},onMouseMove:N=>{if(a){let C=N.currentTarget.scrollTop,_=N.clientY-N.currentTarget.getBoundingClientRect().top+C,I=w((_/t+u)*60);I<=a.startOffset?o({...a,startOffset:I}):o({...a,endOffset:I}),N.preventDefault()}},onMouseUp:N=>{if(!a||a.startOffset==a.endOffset){o(null);return}let C=Sa(r,{minutes:a.startOffset}),_=Sa(r,{minutes:a.endOffset});N.preventDefault(),zf(e.superstate,2,window,I=>{!I||e.insertItem({[e.field]:_r(e.superstate,C,Ls),[e.fieldEnd]:_r(e.superstate,_,Ls),[gt]:I})},i),o(null)}},Array.from({length:c-u}).map((N,C)=>Bu.default.createElement("div",{key:C,className:"mk-day-view-hour"})),k&&Bu.default.createElement("div",{className:"mk-day-view-hour-current",style:{top:`${M*t/60}px`}}),f.filter(N=>!N.allDay).map((N,C)=>Bu.default.createElement(KD,{superstate:e.superstate,key:C,event:N,item:e.data[N.index],hourHeight:t,startHour:u,updateStartEnd:(_,I)=>{let L=Sa(r,{minutes:_}),$=Sa(r,{minutes:I});e.updateItem({...e.data[N.index],[e.field]:_r(e.superstate,L,Ls),[e.fieldEnd]:_r(e.superstate,$,Ls)})}})),a&&a.endOffset>a.startOffset&&Bu.default.createElement(KD,{superstate:e.superstate,event:a,item:{},hourHeight:t,startHour:u,clone:!0}),d!==null&&D?Bu.default.createElement(KD,{superstate:e.superstate,event:{...D,start:null,end:null,startOffset:Math.round(w(D.startOffset+g/t*60)),endOffset:Math.round(w(D.endOffset+g/t*60))},item:e.data[d],hourHeight:t,startHour:u,clone:!0}):h?Bu.default.createElement(KD,{superstate:e.superstate,event:{index:-1,startOffset:0,endOffset:60,leftOffset:0,widthPercentage:100,column:0,columnTotal:1},startHour:e.startHour,item:{[gt]:h},hourHeight:t,style:{transform:`translateY(${g+b}px)`},clone:!0}):null)))};var Ru=he(Me());var Uf=he(Me()),sCe=he(Ws());var PZ=he(Me()),oCe=e=>{let{attributes:t,listeners:r,setNodeRef:n,transform:i}=Vs({id:"day-"+e.date.getTime(),data:{type:"day",date:e.date.getTime()}}),{setNodeRef:a}=ql({id:"day-"+e.date.getTime(),data:{type:"day",weekStart:e.weekStart.getTime(),date:e.date.getTime()}}),o=e.date.toDateString()===new Date().toDateString(),s=m9(a,n);return PZ.default.createElement("div",{ref:s,...t,...r,className:`mk-month-day ${e.active?"mk-active":"mk-inactive"} ${o?"mk-today":""}`,onClick:u=>{u.detail==2&&e.insertItem()},style:{opacity:"1 !important"}},PZ.default.createElement("div",{className:"mk-month-day-number"},e.date.getDate()),e.children)};var Db=he(Me()),IZ=e=>{let{attributes:t,listeners:r,setNodeRef:n,transform:i}=Vs({id:"event-"+e.index,data:{type:"event",index:e.index}}),a=(0,Db.useMemo)(()=>{let o=new Date(e.startEvent),s=`h${o.getMinutes()==0?"":":mm"} a`;return e.allDay?null:`${_r(e.superstate,o,s)}`},[e.startEvent,e.endEvent,e.allDay]);return Db.default.createElement("div",{className:"mk-month-event",ref:n,style:e.style,...t,...r},!e.allDay&&Db.default.createElement("div",{className:"mk-day-block-inner-indicator"}),Db.default.createElement(Pa,{superstate:e.superstate,path:e.data[gt],hideIcon:!0}),Db.default.createElement("div",{className:"mk-day-block-time"},a))};var uCe=e=>{let t=go(e.date),r=bA(t),{source:n}=(0,Uf.useContext)(_a),i=(0,Uf.useMemo)(()=>{let l=[];return e.events.forEach((c,f)=>{let d=[],p=lr(c[e.fieldRepeat]),h=da(c[e.field]),m=da(c[e.fieldEnd])??h;if(h<=$x(r)&&m>=Gn(t)&&d.push(c),p&&p.freq){let g=da(c[e.fieldEnd]).getTime()-h.getTime(),A={dtstart:h,freq:p.freq&&hM(p.freq),count:p.count&&Math.min(p.count,100),interval:parseInt(p.interval),byweekday:p.byweekday&&p.byweekday.map(x=>uw(x)),until:da(p.until),wkst:p.wkst&&uw(p.wkst)};new Ht(Object.entries(A).filter(([x,w])=>w!==void 0).reduce((x,[w,S])=>(x[w]=S,x),{})).between(Gn(t),$x(r),!0).forEach(x=>{x.getTime()!=h.getTime()&&d.push({...c,[e.field]:_r(e.superstate,x,Ls),[e.fieldEnd]:_r(e.superstate,ud(x,g),Ls)})})}d.forEach(g=>{let A=da(g[e.field]),b=da(g[e.fieldEnd])??Gn(A).getTime()==A.getTime()?Gn(A):Rx(A,1),v=A>t?A:t,x=bc.startDay==f.startDay?c.endDay==f.endDay?c.allDay?-1:1:f.endDay-c.endDay:c.startDay-f.startDay),l.map((c,f,d)=>{let p=d.slice(0,f).reduce((h,m)=>m.endDay>=c.startDay?h+1:h,0);return{...c,offset:p}})},[e.events,e.fieldRepeat,e.field,e.fieldEnd,t,r]),[a,o]=(0,Uf.useState)(null),[s,u]=(0,Uf.useState)(null);return Da({onDragStart:l=>{l.active.data.current.type=="day"&&u(new Date(l.active.data.current.date))},onDragOver:l=>{if(l.active?.data.current.type=="day"&&l.over?.data.current.type=="day"){let c=new Date(l.over?.data.current.date),f=c>s?s:c,d=c>s?c:s;if(f>=r||d<=t){o(null);return}let p=i.reduce((h,m)=>m.endDay>=r.getDay()?h+1:h,0);o({offset:p,index:-1,startDay:td?d.getDay():r.getDay(),allDay:!1,startTime:f.getTime(),endTime:d.getTime()})}},onDragEnd:l=>{if(a&&l.over?.data.current.weekStart==t.getTime()){let c=_r(e.superstate,s,"yyyy-MM-dd"),f=_r(e.superstate,new Date(l.over.data.current.date),"yyyy-MM-dd");zf(e.superstate,2,window,d=>{d&&e.insertItem({[gt]:d,[e.field]:c,[e.fieldEnd]:f}),o(null)},n)}else o(null);u(null)}}),Uf.default.createElement("div",{className:"mk-month-week"},Array.from({length:7}).map((l,c)=>{let f=Sa(t,{days:c}),d=f.getMonth()===e.date.getMonth();return Uf.default.createElement(oCe,{key:c,superstate:e.superstate,weekStart:t,active:d,date:f,insertItem:()=>{let p=i.reduce((A,b)=>{let v=da(e.events[b.index])?.getHours();return v>A?v:A},9),h=_r(e.superstate,Rx(Gn(f),p),Ls),m=_r(e.superstate,Rx(Gn(f),p+1),Ls),g=i.reduce((A,b)=>b.endDay>=c?A+1:A,0);o({offset:g,index:-1,startDay:c,endDay:c,startTime:Gn(f).getTime(),endTime:$x(f).getTime(),allDay:!1}),zf(e.superstate,2,window,A=>{A&&e.insertItem({[gt]:A,[e.field]:h,[e.fieldEnd]:m}),o(null)})}},a?.startDay==c&&Uf.default.createElement(IZ,{superstate:e.superstate,index:-1,style:{"--block-bg-color":yg(40,"#0098FF"),"--block-color":"#0098FF","--block-text-color":"var(--mk-ui-text-accent)",top:`${30}px`,width:`${(a.endDay-a.startDay+1)*100}%`},data:{[gt]:"New Event"},startEvent:a.startTime,endEvent:a.endTime,allDay:!1}),i.filter(p=>p.startDay==c).map((p,h)=>{let m=a?p.startDay<=a.endDay&&p.endDay>=a.startDay:!1;return Uf.default.createElement(IZ,{superstate:e.superstate,key:h,index:p.index,startEvent:p.startTime,endEvent:p.endTime,allDay:p.allDay,style:{"--block-bg-color":p.allDay?yg(40,"#0098FF"):"transparent","--block-color":"#0098FF","--block-text-color":p.allDay?"var(--mk-ui-text-accent)":"var(--mk-ui-text-primary)",top:`${p.offset*22+30+(m?22:0)}px`,width:`${(p.endDay-p.startDay+1)*100}%`},data:e.events[p.index]})}))}),s&&(0,sCe.createPortal)(Uf.default.createElement(Zm,{dropAnimation:zU}),document.body))};var lCe=e=>{let[t,r]=(0,Ru.useState)(e.date??new Date),n=(0,Ru.useMemo)(()=>{let o=Vo(t),s=d0(t),u=[],l=o;for(;l<=s;)u.push(l),l=c0(l,1);return u},[t]),[i,a]=(0,Ru.useState)(null);return Da({onDragStart:o=>{a(o.active.id)},onDragEnd:o=>{a(null)}}),Ru.default.createElement("div",{className:"mk-month-grid"},e.header&&Ru.default.createElement(mE,{superstate:e.superstate,date:t,setDate:r,mode:"month"}),Ru.default.createElement("div",{className:"mk-month-header"},Ru.default.createElement("div",null,"S"),Ru.default.createElement("div",null,"M"),Ru.default.createElement("div",null,"T"),Ru.default.createElement("div",null,"W"),Ru.default.createElement("div",null,"T"),Ru.default.createElement("div",null,"F"),Ru.default.createElement("div",null,"S")),n.map((o,s)=>Ru.default.createElement(uCe,{key:s,superstate:e.superstate,date:o,events:e.data,field:e.field,fieldEnd:e.fieldEnd,fieldRepeat:e.fieldRepeat,insertItem:e.insertItem,updateItem:e.updateItem})))};var Os=he(Me());var K8=he(Me());var cCe=e=>{let{source:t}=(0,K8.useContext)(_a),{setNodeRef:r}=ql({id:"allday-"+e.date.toISOString()});return K8.default.createElement("div",{className:"mk-week-view-all-day-cell",ref:r,onClick:i=>{i.stopPropagation(),i.detail===2&&zf(e.superstate,2,je(i.currentTarget.ownerDocument),a=>{e.insertItem(a)},t)},style:{"--block-bg-color":yg(40,"#0098FF"),"--block-color":"#0098FF","--block-text-color":"var(--mk-ui-text-accent)",height:`${e.height*24}px`}},e.children)};var fCe=e=>{let t=e.hourHeight,[r,n]=(0,Os.useState)(e.weekStart??go(new Date)),i=e.startHour??0,a=e.endHour??24,[o,s]=(0,Os.useState)(0),u=(0,Os.useMemo)(()=>{let l=[];e.data.forEach((f,d)=>{let p=da(f[e.field]),h=da(f[e.fieldEnd])??p;h>=r&&p<=Sa(r,{days:7})&&Gn(p).getTime()==p.getTime()&&Gn(h).getTime()==h.getTime()&&l.push({index:d,startDay:new Date(Math.max(r.getTime(),p.getTime())).getDay(),endDay:new Date(Math.min(Sa(r,{days:7}).getTime(),h.getTime())).getDay(),topOffset:0})});let c=0;return l.forEach((f,d)=>{for(let p=0;p=f.endDay&&l[p].topOffset==l[d].topOffset&&(l[d].topOffset+=1,c=Math.max(c,l[d].topOffset))}),s(c),l},[e.data,r,e.field,e.weekStart]);return Os.default.createElement("div",{className:"mk-week-view",style:{"--hour-height":`${t}px`}},e.header&&Os.default.createElement(mE,{superstate:e.superstate,date:r,mode:"week",setDate:n}),Os.default.createElement("div",{className:"mk-week-view-header"},Os.default.createElement("div",{className:"mk-day-view-gutter"}),Array.from({length:7}).map((l,c)=>Os.default.createElement("div",{key:c},_r(e.superstate,Sa(r,{days:c}),"EEE d")))),Os.default.createElement("div",{className:"mk-week-view-all-day"},Os.default.createElement("div",{className:"mk-day-view-gutter"},Os.default.createElement("div",{className:"mk-day-view-hour-title",style:{height:`${o*30}px`}},"all day")),Array.from({length:7}).map((l,c)=>Os.default.createElement(cCe,{key:c,height:o+1,superstate:e.superstate,date:ua(r,c),insertItem:f=>{e.insertItem({[e.field]:_r(e.superstate,ua(r,c),"yyyy-MM-dd"),[e.fieldEnd]:_r(e.superstate,ua(r,c),"yyyy-MM-dd"),[gt]:f})}},u.filter(f=>f.startDay==c).map((f,d)=>Os.default.createElement(Y8,{superstate:e.superstate,data:e.data[f.index],index:f.index,startDay:f.startDay,endDay:f.endDay,topOffset:f.topOffset,key:d}))))),Os.default.createElement("div",{className:"mk-week-view-content"},Os.default.createElement(Z8,{hourHeight:t,startHour:i,endHour:a}),Array.from({length:7}).map((l,c)=>Os.default.createElement(X8,{superstate:e.superstate,key:_r(e.superstate,Sa(r,{days:c})),field:e.field,fieldEnd:e.fieldEnd,fieldRepeat:e.fieldRepeat,date:Sa(r,{days:c}),data:e.data,hourHeight:t,startHour:i,endHour:a,insertItem:f=>{e.insertItem(f)},updateItem:f=>{e.updateItem(f)}}))))};var dCe=he(xi()),Lo=he(Me());var Jet=e=>e.node.type=="column"&&e.children.length==1,ett=e=>e.node.type=="container"&&e.children.length==1,ttt=e=>e.node.type=="container"&&e.children.length==2,JD=(e,t,r,n,i)=>{let a=e;if(a.schemaId!=r.id){a=nl("$root",r.id,a,r.id);let d=Ri(a.id,n.map(p=>p.id));a=nl(a.id,d,a,r.id),a.id=d,a.schemaId=r.id}let o=[],s=[];if(a.id==t.id)return[[],[]];let u=r.node.schemaId,l=Oc(r,t.id),c=Oc(r,a.id);if(!l)return[[],[]];let f=t.node.type=="column";if(i=="inside"){let d={...a,parentId:t.node.id};o.push(d)}else if(f||r.editorProps.editMode==1&&t.node.parentId==r.id&&(i=="left"||i=="right")){let d=t.node.parentId==r.id,p=t.node.type=="container",h=t.node.type=="column",m=!1;h&&l.node.parentId==r.id&&(m=!0);let g=d&&!p,A=d&&p||h&&m;if(g){let b={...Dy(ole,l.id,n,u),rank:t.node.rank},v={...Dy(FT,b.id,[...n,b],u),rank:i=="left"?1:0},x={...Dy(FT,b.id,[...n,b,v],u),rank:i=="left"?0:1},w=[b,v,x,{...t.node,rank:0,parentId:v.id}];o.push(...w,{...a,rank:0,parentId:x.id})}else if(A){let b=p?t.id:t.node.parentId,v={...Dy(FT,b,n,u),rank:i=="left"?p?0:t.node.rank:p?t.children.length:t.node.rank+1},x=[v,{...a,parentId:v.id}];o.push(...x)}}else{let d=n.filter(A=>A.parentId==l.id&&A.id!=a.id).sort((A,b)=>A.rank-b.rank).map((A,b)=>({...A,rank:b})),p=d.find(A=>A.id==t.id)?.rank??0,h=i=="bottom"||i=="right"?p+1:p,m={...a,parentId:t.node.parentId},g=Hx(d,h,m).map((A,b)=>({...A,rank:b}));o.push(...g)}if(c&&Jet(c)){let d=Oc(r,c.id);if(s.push(c.node),ett(d))s.push(d.node);else if(ttt(d)){let p=d.children.filter(m=>m.id!=c.id);s.push(...p.map(m=>m.node),d.node);let h=p.flatMap(m=>m.children.map(g=>({...g.node,parentId:r.id,rank:d.node.rank})));h.push(...o.filter(m=>p.some(g=>g.id==m.parentId))),o=[...o.map(m=>h.some(g=>g.id==m.id)?{...m,parentId:r.id}:m),...h.filter(m=>!o.some(g=>m.id==g.id))]}}return[o,s]};var $u=he(Me());var J8=e=>{let{spaceInfo:t}=(0,$u.useContext)(ar),{undoLastAction:r,redoAction:n,frameSchema:i}=(0,$u.useContext)(va),{nodes:a,addNode:o,saveNodes:s,setLastCreatedId:u}=(0,$u.useContext)(Oi),{hoverNode:l,setHoverNode:c,instance:f,id:d}=(0,$u.useContext)(vi),{selectionMode:p,selection:h,select:m}=(0,$u.useContext)(ji),g=()=>{c(null)};Da({onDragOver:({active:v,over:x})=>{let w=x?.data.current.node;x?.data.current.root==d?w&&c({id:x?.data.current.id,node:x?.data.current.node,direction:x?.data.current?.direction}):c(null)},onDragCancel:()=>{g()},onDragEnd:({active:v,over:x})=>{if(!v||!l){g();return}let w=l?.node;if(w==v.data.current.id||l?.id!=x.data.current.id){g();return}let k=Oc(f.exec,w)?.children.find(M=>M.id==w);if(v.data.current.type=="node"){let O=Oc(f.exec,v.data.current.node)?.children.find(D=>D.id==v.data.current.node);if(k&&O){let[D,N]=JD(O.node,k,f.exec,a,l.direction);s(D,N)}}else if(v.data.current.type=="property"){if(v.data.current.path==t.path&&k){let[M,O]=JD(A(v.data.current.property,v.data.current.context),k,f.exec,a,l.direction);s(M,O)}}else if(v.data.current.type=="listItem"){if(k){let[M,O]=JD({...zi.node,props:{value:`'${v.data.current.contexts?.$context?._keyValue}'`}},k,f.exec,a,l.direction);s(M,O)}}else if(v.data.current.type=="context"&&k){let M=e.superstate.spacesIndex.get(v.data.current.space);if(M){let[O,D]=JD({...xf.node,props:{value:mr(cb(M,v.data.current.schema))}},k,f.exec,a,l.direction);s(O,D)}}g()}});let A=(v,x)=>{let w=Yr.node;return v.type=="boolean"?w={...Ty.node,styles:{...Ty.node.styles,as:"'checkbox'"}}:v.type=="link"||v.type=="context"||v.type=="file"?w=zi.node:v.type=="image"&&(w=Wl.node),w.type=="input"?w={...w,props:{...w.props,value:mr(v.name)}}:x.length>0?w={...w,props:{...w.props,value:`$contexts['${x}']['${v.name}']`}}:w={...w,props:{...w.props,value:`${i.id}.props['${v.name}']`}},w},b=(0,$u.useCallback)(v=>{if(v.key=="ArrowUp"&&h.length>0){let x=a.find(w=>w.id==h[0]);if(x){let w=Oc(f.exec,x.id);if(w){let S=w.children.find(k=>k.id==x.id).node.rank;S>0&&m(w.children.find(k=>k.node.rank==S-1)?.id)}}}if(v.key=="ArrowDown"&&h.length>0){let x=a.find(w=>w.id==h[0]);if(x){let w=Oc(f.exec,x.id);if(w){let S=w.children.find(k=>k.id==x.id).node.rank;Sk.node.rank==S+1)?.id)}}}(v.key=="Delete"||v.key=="Backspace")&&h.length>0&&s([],h.map(x=>a.find(w=>w.id==x)).filter(x=>x)),v.key=="z"&&v.metaKey&&(v.shiftKey?n():r())},[h,a,r,n,s]);return(0,$u.useEffect)(()=>(e.superstate.ui.inputManager.on("keydown",b),()=>{e.superstate.ui.inputManager.off("keydown",b)}),[b]),$u.default.createElement($u.default.Fragment,null,f.exec&&$u.default.createElement("div",{className:"mk-f-root",style:{position:"relative"}},p>=3&&$u.default.createElement("div",{className:"mk-f-root-label",onClick:v=>{m(f.exec.id),v.stopPropagation()}},f.exec.node.name),$u.default.createElement(ZD,{key:t.path,superstate:e.superstate,treeNode:f.exec,instance:f,containerRef:e.containerRef},e.children),f.exec.children.length==0&&$u.default.createElement(V8,{superstate:e.superstate,treeNode:null,state:null})))};var eO=e=>{let[t,r]=(0,Lo.useState)(e.contexts);(0,Lo.useEffect)(()=>r(g=>dCe.default.isEqual(e.contexts,g)?g:e.contexts),[e.contexts]);let{spaceInfo:n}=(0,Lo.useContext)(ar),{dbSchema:i}=(0,Lo.useContext)(_a),{setDragNode:a}=(0,Lo.useContext)(vh),o=Lo.default.useRef(null),{attributes:s,listeners:u,active:l,setNodeRef:c,transform:f,isDragging:d,transition:p,isOver:h,over:m}=roe({id:e.id,data:{id:e.id,type:e.type,space:n?.path,schema:i?.id,props:e.props,contexts:t},disabled:e.type!="listItem"||e.editMode>0,animateLayoutChanges:WU});return Da({onDragStart:g=>{g.active.data.current.id==e.id&&a(Lo.default.createElement("div",{dangerouslySetInnerHTML:{__html:o.current.innerHTML}}))},onDragOver:g=>{},onDragEnd:({active:g,over:A})=>{let b=A&&A.data.current.space==n?.path&&A.data.current.schema==i?.id;rtt(b,A,e,g,n)}}),e.editMode>=1&&e.uri.authority!="$kit"?Lo.default.createElement(Lv,{superstate:e.superstate,id:e.id,editMode:e.editMode,selected:e.editMode==3},Lo.default.createElement(vg,{id:e.id,superstate:e.superstate,props:e.props,propSetters:e.propSetters,contexts:t,editable:!0},Lo.default.createElement(J8,{superstate:e.superstate,containerRef:e.containerRef},e.children))):Lo.default.createElement(Lo.default.Fragment,null,m?.id==e.id&&l.data.current.type==e.type&&!(l.data.current.space==n?.path&&l.data.current.schema==i?.id&&l.data.current.props?._groupValue==e.props?._groupValue)&&Lo.default.createElement(vg,{id:e.id,superstate:e.superstate,props:e.props,propSetters:e.propSetters,contexts:t,editable:!1},Lo.default.createElement(Cb,{superstate:e.superstate})),Lo.default.createElement("div",{ref:g=>{c(g),o.current=g},...s,...u,style:{transform:$l.Transform.toString(f),transition:p}},Lo.default.createElement(vg,{id:e.id,superstate:e.superstate,props:e.props,propSetters:e.propSetters,contexts:t,editable:!1},Lo.default.createElement(Cb,{superstate:e.superstate},e.children))))},rtt=async(e,t,r,n,i)=>{if(e&&t.id==r.id)if(n.data.current.schema==Fr){let a=n.data.current.contexts?.$context?._keyValue,o=t.data.current.contexts?.$context,s=r.props?._groupValue!=n.data.current.props?._groupValue;a&&o&&(s?mi(r.superstate,a,{[r.props?._groupField]:r.props?._groupValue}):cS(r.superstate,a,o._index,i.path))}else{let a=t.data.current.contexts?.$context;ewe(r.superstate.spaceManager,i,n.data.current.schema,n.data.current.contexts?.$context?._index,r.props?._groupField,r.props?._groupValue,a?._index)}};var Co=he(Me());var hE=he(Me()),pCe=e=>{let t=(0,hE.useRef)(null);return(0,hE.useEffect)(()=>{let r=new IntersectionObserver(n=>{n[0].isIntersecting&&e.onScroll()},{threshold:1});return t.current&&r.observe(t.current),()=>{t.current&&r.unobserve(t.current)}},[t]),hE.default.createElement("div",{ref:t})};var AE=he(Me());var Ob=e=>{let{selected:t}=(0,AE.useContext)(ji);return e.editMode>=1&&e.uri.authority!="$kit"?AE.default.createElement(Mv,{superstate:e.superstate,schema:e.uri.ref},AE.default.createElement(KEe,{superstate:e.superstate,cols:e.cols,editMode:e.editMode},e.children)):AE.default.createElement(V9,{superstate:e.superstate,path:e.uri,cols:e.cols},e.children)};var mCe=e=>{let{editSection:t,selectedIndex:r,setSelectedIndex:n,groupURI:i,itemURI:a}=e,{readMode:o}=(0,Co.useContext)(qr),{spaceInfo:s}=(0,Co.useContext)(ar),{predicate:u,filteredData:l,editMode:c,sortedColumns:f,contextTable:d,cols:p,dbSchema:h,source:m}=(0,Co.useContext)(_a),[g,A]=(0,Co.useState)(1),b=25,{instance:v}=(0,Co.useContext)(vi),x=u?.groupBy?.length>0?p.find(C=>C.name+C.table==u.groupBy[0]):null,w=(0,Co.useMemo)(()=>{let C=v?.state[v?.root?.id].props?.groupOptions;return C?gu(C):x?Pr(["",...(Hr(x.value,x.type,e.superstate)?.options??[]).map(I=>I.value),...l.reduce((I,L)=>[...I,L[x.name+x.table]??""],[])]):[""]},[x,l,v]),S=(0,Co.useMemo)(()=>{let C=v?.state[v?.root?.id].props?.groupFilter;return Ui[C]??Ui.is},[v]),k=(0,Co.useMemo)(()=>w.reduce((C,_)=>{let[I,L]=C;if(!x)return[_==""?{...I,[_]:l.map((T,W)=>({...T,_pageId:L+W}))??[]}:{...I,[_]:[]},L+l.length];let $=l.filter(T=>S.fn(T[x.name+x.table],_));return[$.length>0?{...I,[_]:$.map((T,W)=>({...T,_pageId:L+W}))}:{...I,[_]:[]},L+$.length]},[{},0])[0],[l,w,S,x]),M=(0,Co.useMemo)(()=>p.find(C=>C.primary=="true")?.name,[p]),O=(0,Co.useMemo)(()=>f.filter(C=>!u?.colsHidden.includes(C.name)),[u,f]),D={_path:m,_schema:h?.id,_key:M,_properties:O},N=(0,Co.useMemo)(()=>h?h?.primary=="true"?l.reduce((C,_)=>({...C,[_._index]:{$context:{_index:_._index,_keyValue:_[M],_schema:h.id,_name:e.superstate.pathsIndex.get(_[M])?.name,...D},$properties:p,[s.path]:p.reduce((I,L)=>({...I,[L.name]:_[L.name]}),{}),...Object.keys(d).reduce((I,L)=>({...I,[L]:d[L].cols.reduce(($,T)=>({...$,[T.name]:_[T.name+L]}),{})}),{})}}),{}):l.reduce((C,_)=>({...C,[_._index]:{$context:{_index:_._index,_keyValue:_[M],_schema:h.id,_name:_[M],...D},$properties:p,[s.path]:p.reduce((I,L)=>({...I,[L.name]:_[L.name]}),{})}}),{}):{},[l,p,d]);return Co.default.createElement(Ob,{superstate:e.superstate,uri:i,editMode:t=="listGroup"?c:0,cols:[]},Co.default.createElement(UU,{items:Object.keys(k).map((C,_)=>s.path+"listGroup"+_),strategy:K6},Object.keys(k).map((C,_)=>Co.default.createElement(eO,{key:"listGroup"+_,id:s.path+"listGroup"+_,type:"listGroup",superstate:e.superstate,uri:i,props:{_selectedIndex:r,_groupValue:C,_groupField:x?.name,_groupType:x?.type,_readMode:o,...u.listGroupProps},propSetters:null,editMode:t=="listGroup"?c:0,cols:[],containerRef:e.containerRef,contexts:{$context:D}},Co.default.createElement(Ob,{uri:a,superstate:e.superstate,cols:[],editMode:t=="listItem"?c:0},Co.default.createElement(UU,{items:k[C].flatMap((I,L)=>s.path+"listGroup"+_+"_listItem"+L),strategy:K6},k[C].filter(I=>parseInt(I._pageId)<=g*b).map((I,L)=>parseInt(I._pageId)==g*b?Co.default.createElement(pCe,{key:L,onScroll:()=>A($=>$+1)}):Co.default.createElement(eO,{key:"listGroup"+_+"_listItem"+L,id:s.path+"listGroup"+_+"_listItem"+L,type:"listItem",uri:a,superstate:e.superstate,cols:[],props:{_selectedIndex:r,_groupValue:C,_groupField:x?.name,_readMode:o,...u.listItemProps},propSetters:{_selectedIndex:n},containerRef:e.containerRef,editMode:t=="listItem"?c:0,contexts:N[I._index]}))))))))};var dE=e=>{let{pathState:t}=(0,ta.useContext)(qr),{predicate:r,editMode:n,setEditMode:i,dbSchema:a,tableData:o,data:s,updateRow:u}=(0,ta.useContext)(_a),{frameSchema:l}=(0,ta.useContext)(va),[c,f]=(0,ta.useState)(null),[d,p]=(0,ta.useState)(null),[h,m]=(0,ta.useState)(r?{listView:e.superstate.spaceManager.uriByString(SA(r.listView,"spaces://$kit/#*listView"),t.path),listGroup:e.superstate.spaceManager.uriByString(SA(r.listGroup,"spaces://$kit/#*listGroup"),t.path),listItem:e.superstate.spaceManager.uriByString(SA(r.listItem,"spaces://$kit/#*rowItem"),t.path)}:null);(0,ta.useEffect)(()=>{if(!r)return;let A={listView:e.superstate.spaceManager.uriByString(SA(r.listView,"spaces://$kit/#*listView"),t.path),listGroup:e.superstate.spaceManager.uriByString(SA(r.listGroup,"spaces://$kit/#*listGroup"),t.path),listItem:e.superstate.spaceManager.uriByString(SA(r.listItem,"spaces://$kit/#*rowItem"),t.path)};m(b=>hCe.default.isEqual(A,b)?b:A)},[r,t]);let g=A=>{A.key=="Escape"&&p(null),A.key!="Enter"&&(A.key=="ArrowDown"&&(p(b=>b==null?"0":(parseInt(b)+1).toString()),A.preventDefault()),A.key=="ArrowUp"&&(p(b=>b==null||b=="0"?null:(parseInt(b)-1).toString()),A.preventDefault()),A.key=="ArrowLeft",A.key=="ArrowRight")};return o?ta.default.createElement("div",{className:"mk-context-container"},!e.minMode&&ta.default.createElement(H9,{showTitle:e.showTitle,superstate:e.superstate,setView:e.setView}),h?r.view=="table"||r.view=="db"||a?.primary!="true"&&!l?ta.default.createElement(_Se,{superstate:e.superstate}):r.view=="day"?ta.default.createElement(X8,{superstate:e.superstate,field:r.listViewProps?.start||"start",fieldEnd:r.listViewProps?.end||"end",fieldRepeat:r.listViewProps?.repeat,startHour:r.listViewProps?.startOfDay??0,endHour:r.listViewProps?.endOfDay??24,gutter:!0,header:r.listViewProps?.hideHeader!=!0,hourHeight:60,data:s,insertItem:A=>{u(A,-1)},updateItem:A=>{u(A,parseInt(A._index))}}):r.view=="week"?ta.default.createElement(fCe,{superstate:e.superstate,field:r.listViewProps?.start||"start",fieldEnd:r.listViewProps?.end||"end",fieldRepeat:r.listViewProps?.repeat,startHour:r.listViewProps?.startOfDay??0,endHour:r.listViewProps?.endOfDay??24,hourHeight:40,header:r.listViewProps?.hideHeader!=!0,data:s,insertItem:A=>{u(A,-1)},updateItem:A=>{u(A,parseInt(A._index))}}):r.view=="month"?ta.default.createElement(lCe,{superstate:e.superstate,data:s,field:r.listViewProps?.start||"start",fieldEnd:r.listViewProps?.end||"end",fieldRepeat:r.listViewProps?.repeat,header:!0,insertItem:A=>{u(A,-1)},updateItem:A=>{u(A,parseInt(A._index))}}):ta.default.createElement("div",{className:"mk-editor-context",onKeyDown:g},ta.default.createElement(Lv,{superstate:e.superstate,id:"list",editMode:c=="listView"?n:0},n>0&&ta.default.createElement(_2e,{editSection:c,superstate:e.superstate,setEditSection:f,setEditMode:i}),ta.default.createElement(Ob,{superstate:e.superstate,uri:h.listView,cols:[],editMode:c=="listView"?n:0},ta.default.createElement(eO,{superstate:e.superstate,id:"listView",type:"listView",uri:h.listView,props:{_selectedIndex:d,...r.listViewProps},propSetters:{_selectedIndex:p},containerRef:e.containerRef,editMode:c=="listView"?n:0,cols:[],contexts:null},ta.default.createElement(mCe,{superstate:e.superstate,containerRef:e.containerRef,editSection:c,selectedIndex:d,setSelectedIndex:p,groupURI:h.listGroup,itemURI:h.listItem}))))):ta.default.createElement(ta.default.Fragment,null)):ta.default.createElement(ta.default.Fragment,null)};var BZ=e=>gE.default.createElement(Ks,{superstate:e.superstate,path:e.space.path,readMode:!1},gE.default.createElement(gh,{superstate:e.superstate},gE.default.createElement(Mv,{superstate:e.superstate,schema:e.schema},gE.default.createElement(DS,{superstate:e.superstate},gE.default.createElement(dE,{showTitle:!1,superstate:e.superstate})))));var cm={frameSelected:"mkmd-active-frame",frameLayerSelected:"mkmd-frame-layer",refreshView:"mkmd-refresh-view",revealPath:"mkmd-reveal-file",collapseFolders:"mkmd-collapse-folders",toggleBacklinks:"mkmd-toggle-backlinks",metadataChange:"mkmd-tags-change",vaultChange:"mkmd-vault-change",mdbChange:"mkmd-mdb-change",spacesChange:"mkmd-spaces-change",frameChange:"mkmd-frame-change",updateSections:"mkmd-update-sections",settingsChanged:"mkmd-settings-changed"};var Ni=he(Me());var ntt=e=>{let[t,r]=(0,Ni.useState)(null),n=o=>{let s=e.superstate.pathsIndex.get(o),u=[...s.metadata.links??[],...s.metadata.embeds??[]].find(l=>e.source.includes(l.displayText));if(u){let l=s.metadata.sections.find(c=>c.position.start.offset<=u.position.start.offset&&c.position.end.offset>=u.position.end.offset);r([Math.max(1,l.position.start.line),Math.max(l.position.start.line+1,l.position.end.line+1)])}else r([null,null])};(0,Ni.useEffect)(()=>{n(e.path)},[]),(0,Ni.useEffect)(()=>{n(e.path)},[e.path]);let[i,a]=(0,Ni.useState)(!0);return Ni.default.createElement(Ni.default.Fragment,null,Ni.default.createElement("div",{className:"mk-path-backlink-title"},Ni.default.createElement(Pa,{superstate:e.superstate,path:e.path},Ni.default.createElement(Uc,{superstate:e.superstate,collapsed:i,onToggle:o=>a(o)}))),!i&&t?Ni.default.createElement("div",{className:"mk-path-context-backlink"},Ni.default.createElement(Zd,{load:!0,forceNote:!0,superstate:e.superstate,path:e.path,properties:{from:t[0],to:t[1]},classname:"mk-path-context-flow"})):Ni.default.createElement(Ni.default.Fragment,null))},fb=e=>{let[t,r]=(0,Ni.useState)(!e.superstate.settings.inlineBacklinksExpanded),[n,i]=(0,Ni.useState)([]);(0,Ni.useEffect)(()=>{!e.path||i(Pr([...e.superstate.linksMap.getInverse(e.path)]).map(o=>e.superstate.pathsIndex.get(o).path))},[e.path]),(0,Ni.useEffect)(()=>{e.superstate.settings.inlineBacklinksExpanded=!t,e.superstate.saveSettings()},[t]);let a=()=>{r(!t)};return(0,Ni.useEffect)(()=>(window.addEventListener(cm.toggleBacklinks,a),()=>{window.removeEventListener(cm.toggleBacklinks,a)}),[t]),n.length>0&&e.path?Ni.default.createElement("div",{className:"mk-path-context-component mk-note-footer"},Ni.default.createElement("div",{onClick:o=>{r(!t),o.stopPropagation()},className:"mk-path-context-title"},Ni.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//backlink")}}),z.labels.backlinks),Ni.default.createElement("div",{className:"mk-fold"},Ni.default.createElement(Uc,{superstate:e.superstate,collapsed:t,onToggle:o=>a()})),Ni.default.createElement("div",{className:"mk-path-backlinks"},!t&&n.map((o,s)=>Ni.default.createElement(ntt,{path:o,key:s,superstate:e.superstate,source:e.path})))):Ni.default.createElement(Ni.default.Fragment,null)};var Qc=he(Me());var ACe=he(to());var Zn=he(Me());var e7=e=>{let{pathState:t}=(0,Zn.useContext)(qr),{spaceState:r}=(0,Zn.useContext)(ar),n=t?.metadata.property?.aliases??[],[i,a]=(0,Zn.useState)(e.superstate.settings.spacesUseAlias&&n?.[0]?.length>0),o=(0,Zn.useMemo)(()=>t?i?n?.[0]:t.subtype=="tag"?bu(t?.name):t?.name:null,[t,i]);(0,Zn.useEffect)(()=>{e.superstate.settings.spacesUseAlias&&n?.[0]?.length>0?a(!0):a(!1)},[t]);let s=(0,Zn.useRef)(null),u=!e.readOnly&&r?.type!="default",l=A=>{let b=A.target.innerText;if(b!=o){if(t.path=="/"){e.superstate.settings.systemName=b,e.superstate.saveSettings(),e.superstate.reloadPath("/",!0);return}if(i)Xy(e.superstate,t.path,t.metadata?.property?.aliases,b);else{let v=xv(b);Kx(e.superstate,t.path,v).then(x=>{x&&v!=b&&Xy(e.superstate,x,t.metadata?.property?.aliases,b)})}}};(0,Zn.useEffect)(()=>{if(!!s?.current&&s.current.innerText.startsWith("Untitled")){s.current.focus();let A=window.getSelection(),b=document.createRange();b.selectNodeContents(s.current),A.removeAllRanges(),A.addRange(b)}},[]);let c=A=>{A.stopPropagation()},f=A=>{A.stopPropagation()},d=A=>{if(A.stopPropagation(),A.key=="a"&&A.metaKey){A.preventDefault();let b=window.getSelection(),v=document.createRange();v.selectNodeContents(A.target),b.removeAllRanges(),b.addRange(v)}A.key=="Enter"&&(A.target.blur(),A.preventDefault()),A.key=="Escape"&&(A.target.blur(),A.preventDefault())},p=t?.metadata.label?.[e.superstate.settings.fmKeySticker]?.length>0,h=t?.metadata.property?.[e.superstate.settings.fmKeyBanner],m=kc(e.superstate.ui),g=A=>{let b=A.target.getBoundingClientRect(),v=[];p?(v.push({name:z.buttons.changeIcon,icon:"ui//sticker",onClick:x=>e.superstate.ui.openPalette(Zn.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:w=>hS(e.superstate,t.path,w)}),je(x.view.document))}),v.push({name:z.buttons.removeIcon,icon:"ui//sticker",onClick:x=>{AS(e.superstate,t.path)}})):v.push({name:z.buttons.addIcon,icon:"ui//sticker",onClick:x=>e.superstate.ui.openPalette(Zn.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:w=>hS(e.superstate,t.path,w)}),je(x.view.document))}),v.push(Wt),h?(v.push({name:z.buttons.changeBanner,icon:"ui//mk-make-image",onClick:x=>e.superstate.ui.openPalette(Zn.default.createElement(Xl,{superstate:e.superstate,selectedPath:w=>ug(e.superstate,t.path,w)}),je(x.view.document))}),v.push({name:z.labels.reposition,icon:"ui//move",onClick:x=>e.setReposition(w=>!w)}),v.push({name:z.buttons.removeBanner,icon:"ui//file-minus",onClick:x=>{e.superstate.spacesIndex.has(t.path)&&e.superstate.spaceManager.deleteProperty(Mf(e.superstate,e.superstate.spacesIndex.get(t.path).space),e.superstate.settings.fmKeyBanner),e.superstate.spaceManager.deleteProperty(t.path,e.superstate.settings.fmKeyBanner)}})):v.push({name:z.buttons.addCover,icon:"ui//mk-make-image",onClick:x=>e.superstate.ui.openPalette(Zn.default.createElement(Xl,{superstate:e.superstate,selectedPath:w=>ug(e.superstate,t.path,w)}),je(x.view.document))}),v.push(Wt),i?v.push({name:"Edit File Name",icon:"ui//alias",onClick:()=>a(!1)}):v.push({name:"Edit Display Name",icon:"ui//alias",onClick:()=>a(!0)}),e.superstate.ui.openMenu(b,Xt(e.superstate.ui,v),je(A.view.document))};return t&&Zn.default.createElement(Zn.default.Fragment,null,!m&&Zn.default.createElement(itt,{superstate:e.superstate,pathState:t,hasBanner:h,hasSticker:p}),e.superstate.settings.spacesStickers&&p&&Zn.default.createElement("div",{className:"mk-header-icon",style:h?{"--label-color":"var(--mk-ui-background)"}:{}},Zn.default.createElement(g9,{superstate:e.superstate,path:t.path})),Zn.default.createElement("div",{className:"mk-title-container"},t?.subtype=="tag"?Zn.default.createElement("div",{className:"mk-title-prefix"},"#"):"",Zn.default.createElement("div",{ref:s,className:"mk-inline-title inline-title",contentEditable:u,onBlur:l,onDrop:A=>A.preventDefault(),onKeyDown:d,onKeyPress:c,onKeyUp:f,dangerouslySetInnerHTML:{__html:o},"data-ph":i?z.hintText.alias:z.hintText.fileName}),m?Zn.default.createElement("div",{className:"mk-toolbar-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//edit")},onClick:A=>g(A)}):Zn.default.createElement("button",{className:(0,ACe.default)("mk-title-alias",i&&"mk-active"),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//alias")},"aria-label":z.buttons.alias,onClick:()=>a(!i)})))},itt=e=>{let{pathState:t,hasBanner:r,hasSticker:n}=e;return Zn.default.createElement("div",{className:"mk-header-label-actions"},e.superstate.settings.spacesStickers&&!n&&Zn.default.createElement("button",{className:"mk-inline-button",onClick:i=>e.superstate.ui.openPalette(Zn.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:a=>hS(e.superstate,t.path,a)}),je(i.view.document))},Zn.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//smile")}}),z.buttons.addIcon),!r&&Zn.default.createElement("button",{className:"mk-inline-button",onClick:i=>e.superstate.ui.openPalette(Zn.default.createElement(Xl,{superstate:e.superstate,selectedPath:a=>ug(e.superstate,t.path,a)}),je(i.view.document))},Zn.default.createElement("div",{className:"mk-icon-xsmall",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//mk-make-image")}}),z.buttons.addCover))};var Xn=he(Me());var vE=e=>{let[t,r]=(0,Xn.useState)(!1),{pathState:n}=(0,Xn.useContext)(qr),[i,a]=(0,Xn.useState)(e.superstate.spaceManager.uriByString(n?.metadata.property?.[e.superstate.settings.fmKeyBanner])),o=n.readOnly;(0,Xn.useEffect)(()=>{let k=e.superstate.spaceManager.uriByString(n?.metadata.property?.[e.superstate.settings.fmKeyBanner]),M=n?.metadata.property?.[e.superstate.settings.fmKeySticker]?.length>0;r(M),a(k||null)},[n]);let[s,u]=(0,Xn.useState)(n?.metadata.property?.[e.superstate.settings.fmKeyBannerOffset]?`${(parseFloat(n?.metadata.property?.[e.superstate.settings.fmKeyBannerOffset])*100).toString()}%`:"center"),l=k=>{e.superstate.ui.openPalette(Xn.default.createElement(Xl,{superstate:e.superstate,selectedPath:M=>ug(e.superstate,n.path,M)}),je(k.view.document))},c=k=>{k.preventDefault();let M=[{name:z.buttons.changeBanner,value:"change",icon:"ui//image",onClick:O=>{l(O)}},{name:z.buttons.removeBanner,value:"remove",icon:"ui//file-minus",onClick:O=>{e.superstate.spacesIndex.has(n.path)&&e.superstate.spaceManager.deleteProperty(Mf(e.superstate,e.superstate.spacesIndex.get(n.path).space),e.superstate.settings.fmKeyBanner),e.superstate.spaceManager.deleteProperty(n.path,e.superstate.settings.fmKeyBanner)}}];return e.superstate.ui.openMenu({x:k.clientX,y:k.clientY,width:0,height:0},Xt(e.superstate.ui,M),je(k.view.document)),!1},[f,d]=(0,Xn.useState)(null),p=(0,Xn.useRef)(s=="center"?50:parseFloat(s)),h=(0,Xn.useRef)(s=="center"?50:parseFloat(s)),m=k=>{u(k+"%"),mi(e.superstate,n.path,{[e.superstate.settings.fmKeyBannerOffset]:k.toString()})},[,g]=(0,Xn.useState)([0,0]),A=.5,b=(0,Xn.useCallback)(k=>{g(M=>{let{clientX:O,clientY:D}=k,[N,C]=M,_=O-N,I=C-D,$=A*1,T=Math.sqrt((_+I)/2*(_+I)/2)*$;_+I<0&&(T=-T),T=I*$;let W=p.current+T;return W=Math.max(W,0),W=Math.min(W,100),h.current=W,m(W),M}),k.stopPropagation()},[f,A]),v=(0,Xn.useCallback)(k=>{let M=O=>{O.stopPropagation(),window.removeEventListener("click",M,!0)};window.addEventListener("click",M,!0),document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",v),m(h.current),k.preventDefault(),k.stopPropagation()},[b]),x=(0,Xn.useCallback)(k=>{!e.reposition||(p.current=s=="center"?50:parseFloat(s),g([k.clientX,k.clientY]),document.addEventListener("mousemove",b),document.addEventListener("mouseup",v),k.stopPropagation())},[b,v,s,e.reposition]),w=k=>{k.metaKey?d("metaKey"):k.ctrlKey?d("ctrlKey"):k.altKey?d("altKey"):k.shiftKey&&d("shiftKey")},S=()=>{d(null)};return(0,Xn.useEffect)(()=>(document.addEventListener("keydown",w),document.addEventListener("keyup",S),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",v),document.removeEventListener("keydown",w),document.removeEventListener("keyup",S)}),[]),i?Xn.default.createElement(Xn.default.Fragment,null,Xn.default.createElement("div",{className:"mk-space-banner",onContextMenu:!o&&c,style:{"--mk-banner-height":e.superstate.settings.bannerHeight+"px",backgroundImage:`url("${i.scheme=="vault"?e.superstate.ui.getUIPath(i.basePath):i.fullPath}")`,backgroundPositionY:s,cursor:e.reposition?"grab":"inherit"},onMouseDown:x}),e.setReposition&&Xn.default.createElement("div",{className:"mk-space-banner-buttons"},e.reposition?Xn.default.createElement("button",{className:"mk-hover-button",onClick:()=>e.setReposition(!1)},Xn.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//check")}}),z.labels.done):Xn.default.createElement("button",{className:"mk-hover-button",onClick:()=>e.setReposition(!0)},Xn.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//move")}}),z.labels.reposition),Xn.default.createElement("button",{className:"mk-hover-button",onClick:k=>l(k)},Xn.default.createElement("div",{dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//edit")}}),z.labels.changeCoverShort),Xn.default.createElement("button",{className:"mk-hover-button",dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker("ui//options")},onClick:k=>c(k)})),Xn.default.createElement("div",{className:"mk-spacer",style:{"--mk-header-height":((cr(e.superstate.ui)?1:0)*26+(e.superstate.settings.bannerHeight-62)+(!e.superstate.settings.spacesStickers||e.superstate.settings.inlineContextNameLayout=="horizontal"?50:t?0:40)).toString()+"px"},onContextMenu:k=>k.preventDefault()})):Xn.default.createElement(Xn.default.Fragment,null)};var tO=e=>{let{pathState:t}=(0,Qc.useContext)(qr);(0,Qc.useLayoutEffect)(()=>{e.editorView?.requestMeasure()},[]);let[r,n]=Qc.default.useState(!1);return t&&Qc.default.createElement(Qc.default.Fragment,null,Qc.default.createElement("div",{className:"mk-path-context-component"},Qc.default.createElement("div",{className:`mk-path-context-label ${e.superstate.settings.inlineContextNameLayout=="horizontal"?"mk-path-context-file-horizontal":""}`},Qc.default.createElement(vE,{superstate:e.superstate,reposition:r,setReposition:n}),Qc.default.createElement(e7,{superstate:e.superstate,readOnly:!e.editable,setReposition:n})),e.editable&&e.superstate.settings.inlineContextProperties&&Qc.default.createElement(RS,{superstate:e.superstate,collapseSpaces:!0})))};var Uh=he(xi()),rc=he(Me()),su=(0,rc.createContext)({dragPaths:[],setDragPaths:Uh.default.noop,selectedPaths:[],setSelectedPaths:Uh.default.noop,activePath:null,setActivePath:Uh.default.noop,activeFocus:0,setActiveFocus:Uh.default.noop,activeViewSpaces:[],focuses:[],setFocuses:Uh.default.noop,saveActiveSpace:Uh.default.noop,closeActiveSpace:Uh.default.noop,modifier:null,setModifier:Uh.default.noop,editFocus:!1,setEditFocus:Uh.default.noop}),t7=e=>{let[t,r]=(0,rc.useState)(null),[n,i]=(0,rc.useState)([]),[a,o]=(0,rc.useState)([]),[s,u]=(0,rc.useState)(null),[l,c]=(0,rc.useState)(!1),[f,d]=(0,rc.useState)(e.superstate.focuses),[p,h]=(0,rc.useState)(e.superstate.settings.currentWaypoint),[m,g]=(0,rc.useState)((e.superstate.focuses[p]?.paths??[]).map(S=>e.superstate.pathsIndex.get(S)).filter(S=>S)),A=S=>{let k=e.superstate.focuses[p]??{sticker:"",name:"Waypoint",paths:[]};k.paths=[...k.paths.filter(O=>O!=S),S],p>e.superstate.focuses.length&&e.superstate.spaceManager.saveFocuses([...e.superstate.focuses,k]);let M=e.superstate.focuses.map((O,D)=>D==p?k:O);e.superstate.spaceManager.saveFocuses(M.filter(O=>O))},b=S=>{let k=e.superstate.focuses[p]??{sticker:"",name:"Waypoint",paths:[]};k.paths=[...k.paths.filter(O=>O!=S)],p>e.superstate.focuses.length&&e.superstate.spaceManager.saveFocuses([...e.superstate.focuses,k]);let M=e.superstate.focuses.map((O,D)=>D==p?k:O);e.superstate.spaceManager.saveFocuses(M.filter(O=>O))},v=S=>{e.superstate.spaceManager.saveFocuses(S.filter(k=>k))},x=S=>{e.superstate.focuses[e.superstate.settings.currentWaypoint]?.paths?.includes(S.path)&&g((e.superstate.focuses[e.superstate.settings.currentWaypoint]?.paths??[]).map(k=>e.superstate.pathsIndex.get(k)).filter(k=>k))},w=()=>{d(e.superstate.focuses);let S=e.superstate.settings.currentWaypoint;h(S),g((e.superstate.focuses[S]?.paths??[]).map(k=>e.superstate.pathsIndex.get(k)).filter(k=>k))};return(0,rc.useEffect)(()=>(e.superstate.eventsDispatcher.addListener("spaceStateUpdated",x),e.superstate.eventsDispatcher.addListener("settingsChanged",w),e.superstate.eventsDispatcher.addListener("focusesChanged",w),e.superstate.eventsDispatcher.addListener("superstateUpdated",w),()=>{e.superstate.eventsDispatcher.removeListener("spaceStateUpdated",x),e.superstate.eventsDispatcher.removeListener("settingsChanged",w),e.superstate.eventsDispatcher.removeListener("focusesChanged",w),e.superstate.eventsDispatcher.removeListener("superstateUpdated",w)}),[]),rc.default.createElement(su.Provider,{value:{dragPaths:n,setDragPaths:i,activeFocus:p,selectedPaths:a,setSelectedPaths:o,activePath:s,setActiveFocus:h,setActivePath:u,activeViewSpaces:m,focuses:f,setFocuses:v,saveActiveSpace:A,closeActiveSpace:b,modifier:t,setModifier:r,editFocus:l,setEditFocus:c}},e.children)};var l7=he(Me());var dDe=he(xi());function att(e,t){return e?e.item?.type=="space"&&!e.collapsed&&t?e.depth+1:e.depth:0}function ott(e){return e?Math.max(0,e.depth-1):0}function gCe(e,t){return Math.round(e/t)}var stt=(e,t,r,n)=>{let i=e[r];if(!i)return;let a=i.type=="file"?e.find(o=>o.id==i.parentId):i;return a&&a.type!="file"?{depth:i.depth,overId:i.id,parentId:a.id,sortable:!1,insert:a.collapsed,droppable:!0,copy:n=="link"||n=="copy",reorder:!1}:null};function vCe(e,t,r,n,i,a,o,s,u){if(r.length==0)return null;if(r.length>1)return stt(t,r,n,s);let l=t[n],c=t[n],f=t[n+1];if(!c)return;let d=c.type!="file",p=e.depth>0&&l.collapsed&&d&&(!l.sortable||o&&a<=13||!o&&a>=13),h=l.sortable||d&&!p&&f.sortable,m=i,g=e.depth==0?0:att(c,o),A=ott(c),b=m;m>=g?b=g:mS.id==v);return{depth:b,overId:c.id,parentId:v,sortable:h,insert:p,droppable:x?.type!="file",copy:s=="link"||s=="copy",reorder:p?e?.parentId==l?.id:e?.parentId==x?.id||e?.parentId==u};function w(){return b===0||!c?null:b===c.depth||b>c.depth&&c.item.type!="space"?c.parentId:b>c.depth?c.id:t.slice(0,n).reverse().find(k=>k.depth===b)?.parentId??null}}var yCe=()=>window.navigator.platform.startsWith("Mac")?"\u2325":"Alt";var tn=he(Me());var bCe=he(to());var ns=he(Me());var xCe=e=>{let{saveActiveSpace:t,editFocus:r,activeFocus:n,setFocuses:i,focuses:a,setEditFocus:o}=(0,ns.useContext)(su),[s,u]=(0,ns.useState)(e.focus);return(0,ns.useEffect)(()=>{u(e.focus)},[e.focus]),s&&e.focus?e.focus.name?.length==0||r?ns.default.createElement("div",{className:"mk-path-tree-focus"},ns.default.createElement("div",{className:(0,bCe.default)("mk-focuses-item"),dangerouslySetInnerHTML:{__html:e.superstate.ui.getSticker(s.sticker)},onClick:l=>e.superstate.ui.openPalette(ns.default.createElement(Fa,{ui:e.superstate.ui,selectedSticker:c=>{u({...s,sticker:c})}}),je(l.view.document))}),ns.default.createElement("input",{value:s.name,onChange:l=>u({...s,name:l.target.value})}),ns.default.createElement("div",{className:"mk-button-group"},ns.default.createElement("button",{onClick:()=>e.saveFocus(s)},z.buttons.save),ns.default.createElement("button",{onClick:()=>{e.focus.name.length==0?(i(a.filter((l,c)=>c!=n)),e.superstate.saveSettings()):o(!1)}},z.buttons.cancel))):ns.default.createElement("div",{className:"mk-path-tree-empty"},ns.default.createElement("div",{className:"mk-empty-state-title"},"Open a Space"),ns.default.createElement("div",{className:"mk-empty-state-description"},"Open an existing folders and tags as a space or create a new one"),ns.default.createElement("button",{onClick:l=>{zf(e.superstate,2,je(l.view.document),c=>{if(!e.superstate.pathsIndex.has(c)){Tf(e.superstate,c,{}).then(d=>{t(c),e.superstate.ui.openPath(c,!1)});return}t(c)})}},"Open a Space")):ns.default.createElement(ns.default.Fragment,null)};var i7=he(to());var Kn=he(Me());var hn=he(Me()),Yi=he(jCe());var ctt=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]);function yE(e,t){var r=ftt(e);if(typeof r.path!="string"){var n=e.webkitRelativePath;Object.defineProperty(r,"path",{value:typeof t=="string"?t:typeof n=="string"&&n.length>0?n:e.name,writable:!1,configurable:!1,enumerable:!0})}return r}function ftt(e){var t=e.name,r=t&&t.lastIndexOf(".")!==-1;if(r&&!e.type){var n=t.split(".").pop().toLowerCase(),i=ctt.get(n);i&&Object.defineProperty(e,"type",{value:i,writable:!1,configurable:!1,enumerable:!0})}return e}var dtt=[".DS_Store","Thumbs.db"];function $Z(e){return W1(this,void 0,void 0,function(){return H1(this,function(t){return r7(e)&&ptt(e.dataTransfer)?[2,gtt(e.dataTransfer,e.type)]:mtt(e)?[2,htt(e)]:Array.isArray(e)&&e.every(function(r){return"getFile"in r&&typeof r.getFile=="function"})?[2,Att(e)]:[2,[]]})})}function ptt(e){return r7(e)}function mtt(e){return r7(e)&&r7(e.target)}function r7(e){return typeof e=="object"&&e!==null}function htt(e){return RZ(e.target.files).map(function(t){return yE(t)})}function Att(e){return W1(this,void 0,void 0,function(){var t;return H1(this,function(r){switch(r.label){case 0:return[4,Promise.all(e.map(function(n){return n.getFile()}))];case 1:return t=r.sent(),[2,t.map(function(n){return yE(n)})]}})})}function gtt(e,t){return W1(this,void 0,void 0,function(){var r,n;return H1(this,function(i){switch(i.label){case 0:return e.items?(r=RZ(e.items).filter(function(a){return a.kind==="file"}),t!=="drop"?[2,r]:[4,Promise.all(r.map(vtt))]):[3,2];case 1:return n=i.sent(),[2,MCe(TCe(n))];case 2:return[2,MCe(RZ(e.files).map(function(a){return yE(a)}))]}})})}function MCe(e){return e.filter(function(t){return dtt.indexOf(t.name)===-1})}function RZ(e){if(e===null)return[];for(var t=[],r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);rr)return[!1,RCe(r)];if(e.sizer)return[!1,RCe(r)]}return[!0,null]}function jb(e){return e!=null}function WCe(e){var t=e.files,r=e.accept,n=e.minSize,i=e.maxSize,a=e.multiple,o=e.maxFiles,s=e.validator;return!a&&t.length>1||a&&o>=1&&t.length>o?!1:t.every(function(u){var l=zZ(u,r),c=rO(l,1),f=c[0],d=UZ(u,n,i),p=rO(d,1),h=p[0],m=s?s(u):null;return f&&h&&!m})}function nO(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function iO(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function WZ(e){e.preventDefault()}function Ttt(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function Ftt(e){return e.indexOf("Edge/")!==-1}function HCe(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Ttt(e)||Ftt(e)}function fm(){for(var e=arguments.length,t=new Array(e),r=0;r1?i-1:0),o=1;o value !== undefined) @@ -322,7 +321,6 @@ export const DayView = (props: { roundToQuarter(_event.endOffset + (offset / hourHeight) * 60) ), }); - console.log(newStart, newEnd); props.updateItem({ ...props.data[index], [props.field]: formatDate(props.superstate, newStart, isoDateFormat), diff --git a/src/core/react/components/SpaceView/Contexts/CalendarView/MonthView/MonthWeekRow.tsx b/src/core/react/components/SpaceView/Contexts/CalendarView/MonthView/MonthWeekRow.tsx index bc79d77..f9a3d83 100644 --- a/src/core/react/components/SpaceView/Contexts/CalendarView/MonthView/MonthWeekRow.tsx +++ b/src/core/react/components/SpaceView/Contexts/CalendarView/MonthView/MonthWeekRow.tsx @@ -95,7 +95,6 @@ export const MonthWeekRow = (props: { endOfDay(weekEnd), true ); - console.log(event[PathPropertyName], repeatDef, starts); starts.forEach((startDate) => { if (startDate.getTime() == rowDate.getTime()) return; instances.push({