snow-cms 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ ${n.body}`,n}function jn(e){if(!/^---(\r?\n)/.test(e.trim()))return["date: 0001-
39
39
  `,`
40
40
  `),$=A.trim().replaceAll(`\r
41
41
  `,`
42
- `);break;case"hidden":switch(_.type){case"datetime-local":case"date":case"time":S=new Date(k).getTime(),$=A.getTime();break;default:S=k,$=A;break}break;default:S=k,$=A;break}if(S!==$)return!1}return!0}return je(()=>{c=document.querySelector("#entry-data")}),e.$$.update=()=>{e.$$.dirty&33&&(i||l)&&f()},[i,s,o,a,u,l]}class gs extends se{constructor(t){super(),ce(this,t,ms,ps,oe,{})}}function _s(e){let t,n,r,i,o,l,a,c;return{c(){t=E("label"),n=te(e[2]),r=V(),i=E("input"),o=V(),l=E("input"),h(i,"type","checkbox"),h(i,"role","switch"),h(i,"id",e[1]),h(i,"name",e[1]),h(i,"form","ignore"),i.required=e[3],h(l,"type","hidden"),h(l,"id",e[1]),h(l,"name",e[1]),l.value=e[0],l.required=e[3],h(t,"class","editorInput"),h(t,"for",e[1])},m(s,u){I(s,t,u),b(t,n),b(t,r),b(t,i),i.checked=e[0],b(t,o),b(t,l),a||(c=[Z(i,"change",e[5]),Z(i,"change",e[4])],a=!0)},p(s,[u]){u&4&&_e(n,s[2]),u&2&&h(i,"id",s[1]),u&2&&h(i,"name",s[1]),u&8&&(i.required=s[3]),u&1&&(i.checked=s[0]),u&2&&h(l,"id",s[1]),u&2&&h(l,"name",s[1]),u&1&&(l.value=s[0]),u&8&&(l.required=s[3]),u&2&&h(t,"for",s[1])},i:v,o:v,d(s){s&&F(t),a=!1,fe(c)}}}function ws(e,t,n){let r,i,o;z(e,De,p=>n(6,r=p)),z(e,we,p=>n(7,i=p)),z(e,$e,p=>n(8,o=p));let{name:l}=t,{label:a}=t,{checked:c=!1}=t,{required:s=!0}=t;function u(){const p={...i};c==null?p[l]=o==null?void 0:o.fields.find(m=>m.name===l).default:p[l]=c,he(we,i=p,i)}async function f(){r&&n(0,c=r.fields[l]),u()}je(()=>{f()});function d(){c=this.checked,n(0,c)}return e.$$set=p=>{"name"in p&&n(1,l=p.name),"label"in p&&n(2,a=p.label),"checked"in p&&n(0,c=p.checked),"required"in p&&n(3,s=p.required)},[c,l,a,s,u,d]}class bs extends se{constructor(t){super(),ce(this,t,ws,_s,oe,{name:1,label:2,checked:0,required:3})}}function vs(e){let t,n,r;return{c(){t=E("input"),h(t,"type","datetime-local"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[8]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function ys(e){let t,n,r;return{c(){t=E("input"),h(t,"type","date"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[7]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function ks(e){let t,n,r;return{c(){t=E("input"),h(t,"type","time"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[6]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function As(e){let t,n,r;function i(a,c){return a[3]==="time"?ks:a[3]==="date"?ys:vs}let o=i(e),l=o(e);return{c(){t=E("label"),n=te(e[2]),r=V(),l.c(),h(t,"class","editorInput"),h(t,"for",e[1])},m(a,c){I(a,t,c),b(t,n),b(t,r),l.m(t,null)},p(a,[c]){c&4&&_e(n,a[2]),o===(o=i(a))&&l?l.p(a,c):(l.d(1),l=o(a),l&&(l.c(),l.m(t,null))),c&2&&h(t,"for",a[1])},i:v,o:v,d(a){a&&F(t),l.d()}}}function Es(e,t,n){let r,i;z(e,De,g=>n(9,r=g)),z(e,we,g=>n(10,i=g));let{name:o}=t,{label:l}=t,{type:a="datetime-local"}=t,{value:c=zt(a,new Date)}=t,{required:s=!0}=t;function u(){const g={...i};g[o]=c,he(we,i=g,i)}async function f(){if(r){const g=r.fields;n(0,c=zt(a,new Date(g[o])))}u()}je(()=>{f()});function d(){c=this.value,n(0,c)}function p(){c=this.value,n(0,c)}function m(){c=this.value,n(0,c)}return e.$$set=g=>{"name"in g&&n(1,o=g.name),"label"in g&&n(2,l=g.label),"type"in g&&n(3,a=g.type),"value"in g&&n(0,c=g.value),"required"in g&&n(4,s=g.required)},[c,o,l,a,s,u,d,p,m]}class Cs extends se{constructor(t){super(),ce(this,t,Es,As,oe,{name:1,label:2,type:3,value:0,required:4})}}function Ss(e){let t,n,r;return{c(){t=E("textarea"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[7]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function xs(e){let t,n,r;return{c(){t=E("input"),h(t,"type","text"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[6]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&t.value!==i[0]&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function Ls(e){let t,n,r;function i(a,c){return a[3]?Ss:xs}let o=i(e),l=o(e);return{c(){t=E("label"),n=te(e[2]),r=V(),l.c(),h(t,"class","editorInput"),h(t,"for",e[1])},m(a,c){I(a,t,c),b(t,n),b(t,r),l.m(t,null)},p(a,[c]){c&4&&_e(n,a[2]),o===(o=i(a))&&l?l.p(a,c):(l.d(1),l=o(a),l&&(l.c(),l.m(t,null))),c&2&&h(t,"for",a[1])},i:v,o:v,d(a){a&&F(t),l.d()}}}function Ts(e,t,n){let r,i,o;z(e,De,g=>n(8,r=g)),z(e,we,g=>n(9,i=g)),z(e,$e,g=>n(10,o=g));let{name:l}=t,{label:a}=t,{multiline:c=!1}=t,{required:s=!0}=t,{value:u=""}=t;function f(){const g={...i};u?g[l]=u:g[l]=o==null?void 0:o.fields.find(_=>_.name===l).label,he(we,i=g,i)}async function d(){r&&n(0,u=l==="body"?r.body:r.fields[l]),f()}je(()=>{d()});function p(){u=this.value,n(0,u)}function m(){u=this.value,n(0,u)}return e.$$set=g=>{"name"in g&&n(1,l=g.name),"label"in g&&n(2,a=g.label),"multiline"in g&&n(3,c=g.multiline),"required"in g&&n(4,s=g.required),"value"in g&&n(0,u=g.value)},[u,l,a,c,s,f,p,m]}class wr extends se{constructor(t){super(),ce(this,t,Ts,Ls,oe,{name:1,label:2,multiline:3,required:4,value:0})}}function Ms(e){let t,n,r,i,o,l;return{c(){t=E("label"),n=te(e[2]),r=V(),i=E("input"),h(i,"type","number"),h(i,"id",e[1]),h(i,"name",e[1]),h(i,"step",e[3]),h(i,"min",e[4]),h(i,"max",e[5]),i.required=e[6],h(t,"class","editorInput"),h(t,"for",e[1])},m(a,c){I(a,t,c),b(t,n),b(t,r),b(t,i),ve(i,e[0]),o||(l=[Z(i,"input",e[8]),Z(i,"input",e[7])],o=!0)},p(a,[c]){c&4&&_e(n,a[2]),c&2&&h(i,"id",a[1]),c&2&&h(i,"name",a[1]),c&8&&h(i,"step",a[3]),c&16&&h(i,"min",a[4]),c&32&&h(i,"max",a[5]),c&64&&(i.required=a[6]),c&1&&Br(i.value)!==a[0]&&ve(i,a[0]),c&2&&h(t,"for",a[1])},i:v,o:v,d(a){a&&F(t),o=!1,fe(l)}}}function Os(e,t,n){let r,i;z(e,De,g=>n(9,r=g)),z(e,we,g=>n(10,i=g));let{name:o}=t,{label:l}=t,{value:a}=t,{step:c}=t,{min:s}=t,{max:u}=t,{required:f=!0}=t;function d(){const g={...i};g[o]=a,he(we,i=g,i)}async function p(){r&&n(0,a=r.fields[o]),d()}je(()=>{p()});function m(){a=Br(this.value),n(0,a)}return e.$$set=g=>{"name"in g&&n(1,o=g.name),"label"in g&&n(2,l=g.label),"value"in g&&n(0,a=g.value),"step"in g&&n(3,c=g.step),"min"in g&&n(4,s=g.min),"max"in g&&n(5,u=g.max),"required"in g&&n(6,f=g.required)},[a,o,l,c,s,u,f,d,m]}class Ds extends se{constructor(t){super(),ce(this,t,Os,Ms,oe,{name:1,label:2,value:0,step:3,min:4,max:5,required:6})}}const Fs=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),Hs=function(e,t){return new URL(e,t).href},br={},Xe=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const o=document.getElementsByTagName("link"),l=document.querySelector("meta[property=csp-nonce]"),a=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=Promise.allSettled(n.map(c=>{if(c=Hs(c,r),c in br)return;br[c]=!0;const s=c.endsWith(".css"),u=s?'[rel="stylesheet"]':"";if(!!r)for(let p=o.length-1;p>=0;p--){const m=o[p];if(m.href===c&&(!s||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${u}`))return;const d=document.createElement("link");if(d.rel=s?"stylesheet":Fs,s||(d.as="script"),d.crossOrigin="",d.href=c,a&&d.setAttribute("nonce",a),document.head.appendChild(d),s)return new Promise((p,m)=>{d.addEventListener("load",p),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}return i.then(o=>{for(const l of o||[]){if(l.status!=="rejected")continue;const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=l.reason,window.dispatchEvent(a),!a.defaultPrevented)throw l.reason}return t()})},Is='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-bold</title><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',Ns='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-italic</title><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',Rs='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-list-bulleted</title><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>',Ps='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-list-numbered</title><path d="M7,13V11H21V13H7M7,19V17H21V19H7M7,7V5H21V7H7M3,8V5H2V4H4V8H3M2,17V16H5V20H2V19H4V18.5H3V17.5H4V17H2M4.25,10A0.75,0.75 0 0,1 5,10.75C5,10.95 4.92,11.14 4.79,11.27L3.12,13H5V14H2V13.08L4,11H2V10H4.25Z" /></svg>',$s='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>horizontal-rule</title><path d="M19,13H5V11H19V13Z" /></svg>',js='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-quote-close</title><path d="M14,17H17L19,13V7H13V13H16M6,17H9L11,13V7H5V13H8L6,17Z" /></svg>',Vs='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>link</title><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',qs='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>image</title><path d="M8.5,13.5L11,16.5L14.5,12L19,18H5M21,19V5C21,3.89 20.1,3 19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19Z" /></svg>',{document:Ys}=Kt;function vr(e,t,n){const r=e.slice();return r[9]=t[n],r}function yr(e,t,n){const r=e.slice();return r[12]=t[n],r}function kr(e){let t,n=e[12].title+"",r;return{c(){t=E("option"),r=te(n),t.__value=e[12].value,ve(t,t.__value),h(t,"class","svelte-niyo7g")},m(i,o){I(i,t,o),b(t,r)},p:v,d(i){i&&F(t)}}}function Ar(e){let t,n,r=e[9].icon+"",i,o,l;return{c(){t=E("button"),n=new Ze(!1),i=V(),n.a=i,h(t,"class","secondary svelte-niyo7g"),h(t,"data-action",e[9].name)},m(a,c){I(a,t,c),n.m(r,t),b(t,i),o||(l=Z(t,"click",Ue(e[3])),o=!0)},p:v,d(a){a&&F(t),o=!1,l()}}}function Us(e){let t,n,r,i,o,l,a=Ee(e[1]),c=[];for(let f=0;f<a.length;f+=1)c[f]=kr(yr(e,a,f));let s=Ee(e[2]),u=[];for(let f=0;f<s.length;f+=1)u[f]=Ar(vr(e,s,f));return{c(){t=V(),n=E("div"),r=E("select");for(let f=0;f<c.length;f+=1)c[f].c();i=V();for(let f=0;f<u.length;f+=1)u[f].c();h(r,"name","text-type"),h(r,"form","ignore"),h(r,"class","svelte-niyo7g"),h(n,"class","editor-menu svelte-niyo7g")},m(f,d){I(f,t,d),I(f,n,d),b(n,r);for(let p=0;p<c.length;p+=1)c[p]&&c[p].m(r,null);e[6](r),b(n,i);for(let p=0;p<u.length;p+=1)u[p]&&u[p].m(n,null);o||(l=[Z(Ys,"selectionchange",e[5]),Z(r,"change",e[4])],o=!0)},p(f,[d]){if(d&2){a=Ee(f[1]);let p;for(p=0;p<a.length;p+=1){const m=yr(f,a,p);c[p]?c[p].p(m,d):(c[p]=kr(m),c[p].c(),c[p].m(r,null))}for(;p<c.length;p+=1)c[p].d(1);c.length=a.length}if(d&12){s=Ee(f[2]);let p;for(p=0;p<s.length;p+=1){const m=vr(f,s,p);u[p]?u[p].p(m,d):(u[p]=Ar(m),u[p].c(),u[p].m(n,null))}for(;p<u.length;p+=1)u[p].d(1);u.length=s.length}},i:v,o:v,d(f){f&&(F(t),F(n)),un(c,f),e[6](null),un(u,f),o=!1,fe(l)}}}function Bs(){const e=[];for(let t=0;t<=6;t++){let n;t===0?n={title:"Normal",value:"p"}:n={title:`Heading ${t}`,value:t},e.push(n)}return e}function Gs(e,t,n){const r=Qt();let i,o;const l=Bs(),a=[{name:"bold",icon:Is},{name:"italic",icon:Ns},{name:"listBulleted",icon:Rs},{name:"listNumbered",icon:Ps},{name:"quote",icon:js},{name:"horizontalRule",icon:$s},{name:"link",icon:Vs},{name:"image",icon:qs}];function c(d){const{action:p}=d.currentTarget.dataset;r("menuaction",p)}function s(d){const p=d.currentTarget.value;r("menutexttype",p)}function u(){var g;const p=(g=document.getSelection().focusNode)==null?void 0:g.parentElement;if(!o.contains(p))return;const{localName:m}=p;switch(m){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":n(0,i.value=parseInt(m.split("").at(-1)),i);break;default:n(0,i.value="p",i);break}}je(()=>{o=document.querySelector("#md-editor")});function f(d){at[d?"unshift":"push"](()=>{i=d,n(0,i),n(1,l)})}return[i,l,a,c,s,u,f]}class Ws extends se{constructor(t){super(),ce(this,t,Gs,Us,oe,{})}}const{document:zs}=Kt;function Zs(e){let t,n,r,i,o,l,a,c,s,u;return{c(){t=V(),n=E("div"),r=E("div"),i=E("div"),i.textContent="Enter link:",o=V(),l=E("input"),a=V(),c=E("button"),c.textContent="Save",h(i,"class","svelte-1vifg91"),h(l,"form","md-link-editor"),h(l,"type","url"),h(l,"name","url"),h(l,"placeholder","https://example.com"),l.required=!0,h(l,"class","svelte-1vifg91"),h(c,"class","secondary svelte-1vifg91"),h(c,"form","md-link-editor"),h(c,"type","submit"),h(r,"id","link-editor"),h(r,"class","svelte-1vifg91"),h(n,"id","link-editor-container"),h(n,"class","svelte-1vifg91"),Gn(n,"visibility",e[0]?"visible":"hidden")},m(f,d){I(f,t,d),I(f,n,d),b(n,r),b(r,i),b(r,o),b(r,l),e[5](l),b(r,a),b(r,c),e[6](r),s||(u=Z(zs,"selectionchange",e[3]),s=!0)},p(f,[d]){d&1&&Gn(n,"visibility",f[0]?"visible":"hidden")},i:v,o:v,d(f){f&&(F(t),F(n)),e[5](null),e[6](null),s=!1,u()}}}function Ks(e,t,n){const r=Qt();let i=!1,o,l;function a(){const d=document.getSelection();if(d.focusNode.parentElement.localName==="a"){r("saveurl",{});return}else if(i)n(0,i=!i),n(2,l.value="",l);else{const{startOffset:p,endOffset:m}=d.getRangeAt(0);n(0,i=p!==m)}}function c(d){d.preventDefault();const p=l.value;n(2,l.value="",l),n(0,i=!1),r("saveurl",{href:p})}function s(){if(!i)return;const p=document.getSelection().focusNode;o.contains(p)||(n(0,i=!1),n(2,l.value="",l),r("saveurl",null))}je(()=>{const d=document.querySelector("#md-link-editor");return d.addEventListener("submit",c),()=>{d.removeEventListener("submit",c)}}),_o(()=>{i&&l.focus()});function u(d){at[d?"unshift":"push"](()=>{l=d,n(2,l)})}function f(d){at[d?"unshift":"push"](()=>{o=d,n(1,o)})}return[i,o,l,s,a,u,f]}class Qs extends se{constructor(t){super(),ce(this,t,Ks,Zs,oe,{toggleEditor:4})}get toggleEditor(){return this.$$.ctx[4]}}function Er(e,t,n){const r=e.slice();return r[9]=t[n],r}function Cr(e,t){let n,r,i,o,l,a=t[9].name+"",c,s,u,f;function d(){return t[6](t[9])}return{key:e,first:null,c(){n=E("div"),r=E("img"),o=V(),l=E("small"),c=te(a),s=V(),Vt(r.src,i=t[9].url_preview)||h(r,"src",i),h(r,"alt",""),h(r,"loading","lazy"),h(r,"crossorigin","use-credentials"),h(r,"class","svelte-157z34i"),h(l,"class","svelte-157z34i"),h(n,"class","img-container svelte-157z34i"),qt(n,"selected",t[1]===t[9]),this.first=n},m(p,m){I(p,n,m),b(n,r),b(n,o),b(n,l),b(l,c),b(n,s),u||(f=Z(n,"click",d),u=!0)},p(p,m){t=p,m&1&&!Vt(r.src,i=t[9].url_preview)&&h(r,"src",i),m&1&&a!==(a=t[9].name+"")&&_e(c,a),m&3&&qt(n,"selected",t[1]===t[9])},d(p){p&&F(n),u=!1,f()}}}function Xs(e){let t,n,r,i,o,l=[],a=new Map,c,s,u,f,d,p,m,g,_,k=Ee(e[0]);const A=S=>S[9].name;for(let S=0;S<k.length;S+=1){let $=Er(e,k,S),M=A($);a.set(M,l[S]=Cr(M,$))}return{c(){t=E("dialog"),n=E("article"),r=E("header"),r.textContent="Select Image",i=V(),o=E("div");for(let S=0;S<l.length;S+=1)l[S].c();c=V(),s=E("footer"),u=E("button"),u.textContent="Cancel",f=V(),d=E("button"),p=te("Select"),h(o,"class","images svelte-157z34i"),h(u,"class","secondary svelte-157z34i"),d.disabled=m=!e[1],h(d,"class","svelte-157z34i"),h(s,"class","svelte-157z34i"),t.open=!0},m(S,$){I(S,t,$),b(t,n),b(n,r),b(n,i),b(n,o);for(let M=0;M<l.length;M+=1)l[M]&&l[M].m(o,null);b(n,c),b(n,s),b(s,u),b(s,f),b(s,d),b(d,p),g||(_=[Z(u,"click",Ue(e[4])),Z(d,"click",Ue(e[3])),Z(t,"click",e[4])],g=!0)},p(S,[$]){$&7&&(k=Ee(S[0]),l=Ft(l,$,A,1,S,k,a,o,Gr,Cr,null,Er)),$&2&&m!==(m=!S[1])&&(d.disabled=m)},i:v,o:v,d(S){S&&F(t);for(let $=0;$<l.length;$+=1)l[$].d();g=!1,fe(_)}}}function Js(e,t,n){let r;z(e,Ve,d=>n(5,r=d));const i=Qt();let o=[],l;async function a(){const d=await(r==null?void 0:r.getMediaFiles());n(0,o=d||[])}function c(d){n(1,l=d)}function s(){i("selectimg",{img:l})}function u(d){d.currentTarget===d.target&&i("selectimg",{})}je(()=>{const{body:d}=document;return d.classList.add("contain-scroll"),()=>{d.classList.remove("contain-scroll")}});const f=d=>c(d);return e.$$.update=()=>{e.$$.dirty&32&&r&&a()},[o,l,c,s,u,r,f]}class eu extends se{constructor(t){super(),ce(this,t,Js,Xs,oe,{})}}const{document:tu}=Kt;function nu(e){let t,n;return t=new Qe({props:{msg:"Unable to load",details:e[48].message}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p(r,i){const o={};i[0]&16&&(o.details=r[48].message),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function ru(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function iu(e){let t,n;return t=new en({props:{msg:"Loading"}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p:v,i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function Sr(e){let t,n;return t=new eu({}),t.$on("selectimg",e[7]),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p:v,i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function ou(e){let t,n,r,i,o,l,a,c,s,u,f,d,p,m,g,_,k,A,S;l=new Ws({}),l.$on("menutexttype",e[9]),l.$on("menuaction",e[10]);let $={};u=new Qs({props:$}),e[13](u),u.$on("saveurl",e[8]);let M={ctx:e,current:null,token:null,hasCatch:!0,pending:iu,then:ru,catch:nu,error:48,blocks:[,,,]};ue(m=e[4],M);let P=e[5]&&Sr(e);return{c(){t=V(),n=E("label"),r=te(e[2]),i=V(),o=E("div"),J(l.$$.fragment),a=V(),c=E("div"),s=V(),J(u.$$.fragment),f=V(),d=E("input"),p=V(),M.block.c(),g=V(),P&&P.c(),_=Oe(),h(o,"id","md-editor"),h(o,"class","svelte-1rfhu7q"),h(d,"type","hidden"),h(d,"id",e[1]),h(d,"name",e[1]),d.required=e[3],h(d,"class","svelte-1rfhu7q"),h(n,"class","editorInput"),h(n,"for",e[1])},m(N,C){I(N,t,C),I(N,n,C),b(n,r),b(n,i),b(n,o),Q(l,o,null),b(o,a),b(o,c),b(o,s),Q(u,o,null),b(n,f),b(n,d),ve(d,e[0]),I(N,p,C),M.block.m(N,M.anchor=C),M.mount=()=>g.parentNode,M.anchor=g,I(N,g,C),P&&P.m(N,C),I(N,_,C),k=!0,A||(S=[Z(tu,"selectionchange",e[11]),po(e[12].call(null,c)),Z(d,"input",e[14])],A=!0)},p(N,C){e=N,(!k||C[0]&4)&&_e(r,e[2]);const R={};u.$set(R),(!k||C[0]&2)&&h(d,"id",e[1]),(!k||C[0]&2)&&h(d,"name",e[1]),(!k||C[0]&8)&&(d.required=e[3]),C[0]&1&&ve(d,e[0]),(!k||C[0]&2)&&h(n,"for",e[1]),M.ctx=e,C[0]&16&&m!==(m=e[4])&&ue(m,M)||Pe(M,e,C),e[5]?P?(P.p(e,C),C[0]&32&&H(P,1)):(P=Sr(e),P.c(),H(P,1),P.m(_.parentNode,_)):P&&(ye(),j(P,1,1,()=>{P=null}),ke())},i(N){k||(H(l.$$.fragment,N),H(u.$$.fragment,N),H(M.block),H(P),k=!0)},o(N){j(l.$$.fragment,N),j(u.$$.fragment,N);for(let C=0;C<3;C+=1){const R=M.blocks[C];j(R)}j(P),k=!1},d(N){N&&(F(t),F(n),F(p),F(g),F(_)),X(l),e[13](null),X(u),M.block.d(N),M.token=null,M=null,P&&P.d(N),A=!1,fe(S)}}}function lu(e,t,n){let r,i,o,l;z(e,Ve,Y=>n(38,r=Y)),z(e,De,Y=>n(39,i=Y)),z(e,we,Y=>n(40,o=Y)),z(e,$e,Y=>n(41,l=Y));let{name:a}=t,{label:c}=t,{value:s=""}=t,{required:u=!0}=t,f,d,p,m,g,_,k,A,S,$,M,P,N,C,R,D,x,B,W,O,y,w=!1,L,T,q,G;async function K(){const Y=await Xe(()=>import("./index.es.js").then(It=>It.a5),[],import.meta.url),ee=await Xe(()=>import("./index.es2.js"),[],import.meta.url),ne=await Xe(()=>import("./index.es3.js"),[],import.meta.url),le=await Xe(()=>import("./index.es4.js"),[],import.meta.url),Re=await Xe(()=>import("./index.es5.js"),[],import.meta.url);f=Y.Editor,d=Y.rootCtx,p=Y.defaultValueCtx,m=Y.commandsCtx,g=ee.listener,_=ee.listenerCtx,k=ne.commonmark,A=ne.turnIntoTextCommand,S=ne.wrapInHeadingCommand,$=ne.toggleStrongCommand,M=ne.toggleEmphasisCommand,P=ne.wrapInBulletListCommand,N=ne.wrapInOrderedListCommand,C=ne.wrapInBlockquoteCommand,R=ne.insertHrCommand,D=ne.toggleLinkCommand,x=ne.insertImageCommand,B=le.nord,W=Re.getHTML,O=Re.replaceAll}function re(Y){const ee={...o};Y?q&&(ee[a]=W()(q.ctx).replaceAll("<img ",'<img crossorigin="use-credentials" ')):ee[a]=l==null?void 0:l.fields.find(ne=>ne.name===a).label,he(we,o=ee,o)}function ie(){if(!L)return;const Y=document.getSelection();Y.removeAllRanges();const ee=document.createRange(),{startOffset:ne,endOffset:le}=L.range;ee.setStart(L.node,ne),ee.setEnd(L.node,le),Y.addRange(ee)}function de(Y){n(5,w=!1),ie();const{img:ee}=Y.detail;ee&&q.action(ne=>{const le=ne.get(m),Re={alt:ee.name,src:ee.url_preview};le.call(x.key,Re)})}function Ae(Y){if(ie(),!Y.detail)return;const{href:ee}=Y.detail,ne=document.getSelection(),{textContent:le}=ne.focusNode,{startOffset:Re,endOffset:It}=ne.getRangeAt(0),io=le.substring(Re,It);q.action(oo=>{const lo=oo.get(m),ao={title:io,href:ee};lo.call(D.key,ao)})}function qe(Y){const ee=Y.detail;q.action(ne=>{const le=ne.get(m);ee==="p"?le.call(A.key):le.call(S.key,ee)})}function Ie(Y){const ee=Y.detail;q.action(ne=>{const le=ne.get(m);switch(ee){case"bold":le.call($.key);break;case"italic":le.call(M.key);break;case"listBulleted":le.call(P.key);break;case"listNumbered":le.call(N.key);break;case"quote":le.call(C.key);break;case"horizontalRule":le.call(R.key);break;case"link":T.toggleEditor();break;case"image":L&&n(5,w=!0);break}})}function We(){const Y=document.getSelection(),ee=Y.focusNode;G!=null&&G.contains(ee)&&(L={node:Y.focusNode,range:Y.getRangeAt(0)})}function Fe(Y){q=Y,G=document.querySelector(".milkdown .ProseMirror"),O(s)(q.ctx),re(s)}async function me(Y){await K(),f.make().config(ee=>{ee.set(d,Y),ee.set(p,s),ee.get(_).markdownUpdated((ne,le,Re)=>{n(0,s=le)})}).config(B).use(k).use(g).create().then(Fe)}function Le(Y){me(Y)}async function Ne(){if(i)try{const Y=a==="body"?i.body:i.fields[a];n(4,y=r.replacePublicLinks(Y)),n(0,s=await y),q&&O(s)(q.ctx)}catch{}}je(()=>{Ne()});function Ye(Y){at[Y?"unshift":"push"](()=>{T=Y,n(6,T)})}function ft(){s=this.value,n(0,s)}return e.$$set=Y=>{"name"in Y&&n(1,a=Y.name),"label"in Y&&n(2,c=Y.label),"value"in Y&&n(0,s=Y.value),"required"in Y&&n(3,u=Y.required)},e.$$.update=()=>{e.$$.dirty[0]&1&&re(s)},[s,a,c,u,y,w,T,de,Ae,qe,Ie,We,Le,Ye,ft]}class au extends se{constructor(t){super(),ce(this,t,lu,ou,oe,{name:1,label:2,value:0,required:3},null,[-1,-1])}}function cu(e){let t,n,r;return{c(){t=E("input"),h(t,"type","hidden"),h(t,"id",e[1]),h(t,"name",e[1])},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=Z(t,"input",e[3]),n=!0)},p(i,[o]){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&1&&ve(t,i[0])},i:v,o:v,d(i){i&&F(t),n=!1,r()}}}function su(e,t,n){let r,i;z(e,De,f=>n(4,r=f)),z(e,we,f=>n(5,i=f));let{name:o}=t,{type:l="text"}=t,{value:a}=t;function c(){const f={...i};f[o]=a,he(we,i=f,i)}async function s(){if(r!=null&&r.fields[o])switch(l){case"datetime-local":case"date":case"time":n(0,a=zt(l,new Date(r.fields[o])));break;default:n(0,a=r.fields[o]);break}else if(!a)switch(l){case"datetime-local":case"date":case"time":n(0,a=zt(l,new Date));break;case"boolean":n(0,a="false");break}c()}je(()=>{s()});function u(){a=this.value,n(0,a)}return e.$$set=f=>{"name"in f&&n(1,o=f.name),"type"in f&&n(2,l=f.type),"value"in f&&n(0,a=f.value)},[a,o,l,u]}class uu extends se{constructor(t){super(),ce(this,t,su,cu,oe,{name:1,type:2,value:0})}}function fu(e){let t,n,r;return{c(){t=E("iframe"),h(t,"title","Preview"),h(t,"sandbox","allow-same-origin"),h(t,"srcdoc",e[1]),h(t,"class","svelte-1sw5k8j")},m(i,o){I(i,t,o),e[9](t),n||(r=Z(t,"load",e[2]),n=!0)},p(i,[o]){o&2&&h(t,"srcdoc",i[1])},i:v,o:v,d(i){i&&F(t),e[9](null),n=!1,r()}}}function du(e,t,n){let r,i,o,l,a,c;z(e,we,m=>n(6,l=m)),z(e,$e,m=>n(7,a=m)),z(e,Ce,m=>n(8,c=m)),Te.extend(Yi);let s,u;function f(){d()}function d(){if(u!=null&&u.contentDocument)for(const m in l){const g=a==null?void 0:a.fields.find(A=>A.name===m);let _=l[m];if(g.name==="date")switch(g==null?void 0:g.type){case"time":_=Te(l[m],"hh:mm").format(g.time_format);break;case"date":_=Te(l[m],"YYYY-MM-DD").format(g.date_format);break;default:_=Te(l[m],"YYYY-MM-DDThh:mm").format(g.datetime_format)}u.contentDocument.querySelectorAll(`[data-tag="${m}"]`).forEach(A=>{A.innerHTML!==_&&(A.innerHTML=_)})}}function p(m){at[m?"unshift":"push"](()=>{u=m,n(0,u)})}return e.$$.update=()=>{e.$$.dirty&384&&n(5,r=(a==null?void 0:a.preview)||(c==null?void 0:c.previews.default)),e.$$.dirty&288&&n(4,i=rs(c,r)),e.$$.dirty&288&&(async()=>n(3,s=await is(c,r)))(),e.$$.dirty&24&&n(1,o=os(s,i)),e.$$.dirty&192&&(a||l)&&d()},[u,o,f,s,i,r,l,a,c,p]}class pu extends se{constructor(t){super(),ce(this,t,du,fu,oe,{})}}function xr(e,t,n){var l;const r=e.slice();r[11]=t[n];const i=r[5][r[11].widget];r[12]=i;const o=(l=r[11])==null?void 0:l.default;return r[13]=o,r}function Lr(e){let t=[],n=new Map,r,i,o=Ee(e[3].fields);const l=a=>a[11].name;for(let a=0;a<o.length;a+=1){let c=xr(e,o,a),s=l(c);n.set(s,t[a]=Tr(s,c))}return{c(){for(let a=0;a<t.length;a+=1)t[a].c();r=Oe()},m(a,c){for(let s=0;s<t.length;s+=1)t[s]&&t[s].m(a,c);I(a,r,c),i=!0},p(a,c){c&40&&(o=Ee(a[3].fields),ye(),t=Ft(t,c,l,1,a,o,n,r.parentNode,Tn,Tr,r,xr),ke())},i(a){if(!i){for(let c=0;c<o.length;c+=1)H(t[c]);i=!0}},o(a){for(let c=0;c<t.length;c+=1)j(t[c]);i=!1},d(a){a&&F(r);for(let c=0;c<t.length;c+=1)t[c].d(a)}}}function hu(e){let t,n,r;const i=[e[11],{value:e[13]}];var o=e[12];function l(a,c){let s={};for(let u=0;u<i.length;u+=1)s=lt(s,i[u]);return c!==void 0&&c&8&&(s=lt(s,ct(i,[st(a[11]),{value:a[13]}]))),{props:s}}return o&&(t=et(o,l(e))),{c(){t&&J(t.$$.fragment),n=Oe()},m(a,c){t&&Q(t,a,c),I(a,n,c),r=!0},p(a,c){if(c&8&&o!==(o=a[12])){if(t){ye();const s=t;j(s.$$.fragment,1,0,()=>{X(s,1)}),ke()}o?(t=et(o,l(a,c)),J(t.$$.fragment),H(t.$$.fragment,1),Q(t,n.parentNode,n)):t=null}else if(o){const s=c&8?ct(i,[st(a[11]),{value:a[13]}]):{};t.$set(s)}},i(a){r||(t&&H(t.$$.fragment,a),r=!0)},o(a){t&&j(t.$$.fragment,a),r=!1},d(a){a&&F(n),t&&X(t,a)}}}function mu(e){let t,n,r;const i=[e[11],{value:e[13]},{multiline:!0}];var o=e[12];function l(a,c){let s={};for(let u=0;u<i.length;u+=1)s=lt(s,i[u]);return c!==void 0&&c&8&&(s=lt(s,ct(i,[st(a[11]),{value:a[13]},i[2]]))),{props:s}}return o&&(t=et(o,l(e))),{c(){t&&J(t.$$.fragment),n=Oe()},m(a,c){t&&Q(t,a,c),I(a,n,c),r=!0},p(a,c){if(c&8&&o!==(o=a[12])){if(t){ye();const s=t;j(s.$$.fragment,1,0,()=>{X(s,1)}),ke()}o?(t=et(o,l(a,c)),J(t.$$.fragment),H(t.$$.fragment,1),Q(t,n.parentNode,n)):t=null}else if(o){const s=c&8?ct(i,[st(a[11]),{value:a[13]},i[2]]):{};t.$set(s)}},i(a){r||(t&&H(t.$$.fragment,a),r=!0)},o(a){t&&j(t.$$.fragment,a),r=!1},d(a){a&&F(n),t&&X(t,a)}}}function gu(e){let t,n,r;const i=[e[11],{checked:e[13]}];var o=e[12];function l(a,c){let s={};for(let u=0;u<i.length;u+=1)s=lt(s,i[u]);return c!==void 0&&c&8&&(s=lt(s,ct(i,[st(a[11]),{checked:a[13]}]))),{props:s}}return o&&(t=et(o,l(e))),{c(){t&&J(t.$$.fragment),n=Oe()},m(a,c){t&&Q(t,a,c),I(a,n,c),r=!0},p(a,c){if(c&8&&o!==(o=a[12])){if(t){ye();const s=t;j(s.$$.fragment,1,0,()=>{X(s,1)}),ke()}o?(t=et(o,l(a,c)),J(t.$$.fragment),H(t.$$.fragment,1),Q(t,n.parentNode,n)):t=null}else if(o){const s=c&8?ct(i,[st(a[11]),{checked:a[13]}]):{};t.$set(s)}},i(a){r||(t&&H(t.$$.fragment,a),r=!0)},o(a){t&&j(t.$$.fragment,a),r=!1},d(a){a&&F(n),t&&X(t,a)}}}function Tr(e,t){let n,r,i,o,l;const a=[gu,mu,hu],c=[];function s(u,f){return u[11].widget==="boolean"?0:u[11].widget==="text"?1:2}return r=s(t),i=c[r]=a[r](t),{key:e,first:null,c(){n=Oe(),i.c(),o=Oe(),this.first=n},m(u,f){I(u,n,f),c[r].m(u,f),I(u,o,f),l=!0},p(u,f){t=u;let d=r;r=s(t),r===d?c[r].p(t,f):(ye(),j(c[d],1,1,()=>{c[d]=null}),ke(),i=c[r],i?i.p(t,f):(i=c[r]=a[r](t),i.c()),H(i,1),i.m(o.parentNode,o))},i(u){l||(H(i),l=!0)},o(u){j(i),l=!1},d(u){u&&(F(n),F(o)),c[r].d(u)}}}function _u(e){let t,n;return t=new Qe({props:{msg:"Unable to save",details:e[10].message}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p(r,i){const o={};i&1&&(o.details=r[10].message),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function wu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function bu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function vu(e){let t,n;return t=new Qe({props:{msg:"Unable to save",details:e[10].message}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p(r,i){const o={};i&4&&(o.details=r[10].message),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function yu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function ku(e){let t,n;return t=new en({props:{msg:"Saving"}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p:v,i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function Au(e){let t,n;return t=new Qe({props:{msg:"'On save' event action failed",details:e[10].message}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p(r,i){const o={};i&2&&(o.details=r[10].message),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function Eu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function Cu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function Su(e){let t,n,r,i,o,l,a,c,s,u,f,d,p,m,g,_,k,A,S,$,M,P,N,C,R,D;t=new gs({});let x=e[3]&&Lr(e);_=new pu({});let B={ctx:e,current:null,token:null,hasCatch:!0,pending:bu,then:wu,catch:_u,error:10,blocks:[,,,]};ue(A=e[0],B);let W={ctx:e,current:null,token:null,hasCatch:!0,pending:ku,then:yu,catch:vu,error:10,blocks:[,,,]};ue($=e[2],W);let O={ctx:e,current:null,token:null,hasCatch:!0,pending:Cu,then:Eu,catch:Au,error:10,blocks:[,,,]};return ue(N=e[1],O),{c(){J(t.$$.fragment),n=V(),r=E("div"),i=E("section"),o=E("header"),o.textContent="Edit",l=V(),a=E("form"),x&&x.c(),c=V(),s=E("form"),u=V(),f=E("form"),d=V(),p=E("section"),m=E("header"),m.textContent="Preview",g=V(),J(_.$$.fragment),k=V(),B.block.c(),S=V(),W.block.c(),M=V(),P=Oe(),O.block.c(),h(o,"class","svelte-14qwct"),h(a,"id","entry-data"),h(a,"class","svelte-14qwct"),h(s,"id","md-link-editor"),h(s,"class","svelte-14qwct"),h(f,"id","ignore"),h(f,"class","svelte-14qwct"),h(i,"id","inputArea"),h(i,"class","svelte-14qwct"),h(m,"class","svelte-14qwct"),h(p,"id","previewArea"),h(p,"class","svelte-14qwct"),h(r,"class","page svelte-14qwct")},m(y,w){Q(t,y,w),I(y,n,w),I(y,r,w),b(r,i),b(i,o),b(i,l),b(i,a),x&&x.m(a,null),b(i,c),b(i,s),b(i,u),b(i,f),b(r,d),b(r,p),b(p,m),b(p,g),Q(_,p,null),I(y,k,w),B.block.m(y,B.anchor=w),B.mount=()=>S.parentNode,B.anchor=S,I(y,S,w),W.block.m(y,W.anchor=w),W.mount=()=>M.parentNode,W.anchor=M,I(y,M,w),I(y,P,w),O.block.m(y,O.anchor=w),O.mount=()=>P.parentNode,O.anchor=P,C=!0,R||(D=Z(a,"submit",Ue(e[6])),R=!0)},p(y,[w]){e=y,e[3]?x?(x.p(e,w),w&8&&H(x,1)):(x=Lr(e),x.c(),H(x,1),x.m(a,null)):x&&(ye(),j(x,1,1,()=>{x=null}),ke()),B.ctx=e,w&1&&A!==(A=e[0])&&ue(A,B)||Pe(B,e,w),W.ctx=e,w&4&&$!==($=e[2])&&ue($,W)||Pe(W,e,w),O.ctx=e,w&2&&N!==(N=e[1])&&ue(N,O)||Pe(O,e,w)},i(y){C||(H(t.$$.fragment,y),H(x),H(_.$$.fragment,y),H(B.block),H(W.block),H(O.block),C=!0)},o(y){j(t.$$.fragment,y),j(x),j(_.$$.fragment,y);for(let w=0;w<3;w+=1){const L=B.blocks[w];j(L)}for(let w=0;w<3;w+=1){const L=W.blocks[w];j(L)}for(let w=0;w<3;w+=1){const L=O.blocks[w];j(L)}C=!1},d(y){y&&(F(n),F(r),F(k),F(S),F(M),F(P)),X(t,y),x&&x.d(),X(_),B.block.d(y),B.token=null,B=null,W.block.d(y),W.token=null,W=null,O.block.d(y),O.token=null,O=null,R=!1,D()}}}function xu(e,t,n){let r,i,o,l,a;z(e,De,p=>n(7,r=p)),z(e,Nn,p=>n(8,i=p)),z(e,$e,p=>n(3,l=p)),z(e,Ve,p=>n(9,a=p));const c=nt();z(e,c,p=>n(2,o=p)),Sn("submitted",c);let s,u;const f={string:wr,text:wr,datetime:Cs,boolean:bs,number:Ds,markdown:au,hidden:uu};async function d(p){const m=r?{...r}:{fields:{}},g=new FormData(p.target);for(const[k,A]of g.entries()){const S=l.fields.find($=>$.name===k);try{n(0,s=Ui(S,A,a)),m.fields[k]=await s}catch($){console.error("Error parsing form entry.",$);return}}const _=as(l,m);he(c,o=a.saveFile(l,_),o);try{he(De,r=await o,r),i!=null&&i.onSave&&(n(1,u=i.onSave(r)),await u)}catch(k){console.warn("Issue saving post.",k)}}return[s,u,o,l,c,f,d]}class Lu extends se{constructor(t){super(),ce(this,t,xu,Su,oe,{})}}async function Tu(e,t){let n;try{n=await t.text()}catch(a){console.error("Error constructing doc",a);return}const[r,i]=jn(n),o=Jt.load(r);return{_id:t.webkitRelativePath,name:t.name,collection:e,date:o.date,raw:n,fields:o,body:i,handle:t.handle,directoryHandle:t.directoryHandle}}function Bi(e,t){const n=t.lastModifiedDate,r=`${e.public_folder}/${t.name}`;return{_id:t.webkitRelativePath,name:t.name,date:n,asset:t.type,url:r,url_preview:r,handle:t.handle,directoryHandle:t.directoryHandle}}let jt,Gi,Wi,ot,Ge,xt;async function Mu(){if(ot=He(Ce).repo_folder,!ot){console.error("Missing 'repo_folder' config");return}return await Ou(),jt.plugin(Gi),jt.plugin(Wi),Ge=new jt(`${ot}-local`,{adapter:"idb"}),[["name","collection"],["date","collection"],["asset"],["url"],["url_preview"]].map(t=>({index:{fields:t},ddoc:t.join("-")})).forEach(t=>Fu(t)),console.log("Using local CMS backend"),Vn}async function Ou(){jt=(await Xe(async()=>{const{default:e}=await import("./index.es6.js");return{default:e}},[],import.meta.url)).default,Gi=(await Xe(async()=>{const{default:e}=await import("./index.es7.js");return{default:e}},[],import.meta.url)).default,Wi=(await Xe(async()=>{const{default:e}=await import("./index-browser.es.js");return{default:e}},[],import.meta.url)).default}async function Du(){return{title:"Local Backend Enabled",message:"Select the local project directory to continue.",button:"Select Project Directory",action:Iu}}async function Fu(e){try{const t=await Ge.createIndex(e);console.log("Create index",e,t)}catch(t){console.error("Create index error",t)}}async function Hu(e){try{const t=await Ge.get(e._id);e._rev=t._rev}catch(t){console.warn("Existing doc error",t)}}async function Iu(){if(!ot)return;const e=[],t=He(Ce);t.collections.forEach(s=>{const d=`\\/?${s.folder.split("/").join("\\/")}\\/[^_][\\w-]+\\.\\w+`;e.push({name:s.name,regex:new RegExp(d,"i")})});const o=`\\/?${t.media_folder.split("/").join("\\/")}\\/[^_][\\w-]+\\.\\w+`,l=new RegExp(o,"i"),a=["node_modules"],c={recursive:!0,id:`snow-cms-${ot}`,skipDirectory:s=>s.name.startsWith(".")||a.includes(s.name)};try{const s=await Vc(c),u=[],f=[];s.forEach(g=>{var A;if(!xt&&((A=g.directoryHandle)==null?void 0:A.name)===ot&&(xt=g.directoryHandle),l.test(g.webkitRelativePath)){u.push(Bi(t,g));return}const k=e.find(({name:S,regex:$})=>$.test(g.webkitRelativePath));k&&f.push(Tu(k.name,g))});const d=await Promise.all(f);d.push(...u);const p=[];d.forEach(g=>p.push(Hu(g))),await Promise.all(p);const m=await Ge.bulkDocs(d);Ve.set(Vn)}catch(s){console.error("Open directory error",s)}}async function Nu(e){try{return(await Ge.find({selector:{collection:e,date:{$gte:null}},sort:[{date:"desc"}],limit:200})).docs}catch(t){throw console.error("Error finding docs",t),t}}async function Ru(e,t){const n=He(Ce).repo_folder;t._id||(t._id=[n,e.folder,t.name].join("/"));try{const r=`.${e.extension}`,i=`snow-cms-save-${n}-${e.folder.split(/[\/\\]/).at(-1)}`.substring(0,32),o={fileName:t.name,extensions:[r],id:i},l=new Blob([t.raw],{type:cs(r)});if(t.handle)await wn(l,o,t.handle,!0);else{let c=await wn(l,o);t.handle=c}const a=await Ge.put(t);return console.log(a),t._rev=a.rev,t}catch(r){throw console.error("Save file error",r),r}}async function Pu(e){try{e.forEach(r=>r._deleted=!0);const t=await Ge.bulkDocs(e);console.log(t);const n=[];e.forEach(r=>{r.handle&&n.push(r.handle.remove())}),await Promise.all(n)}catch(t){throw console.error("Delete files error",t),t}}async function $u(){try{return(await Ge.find({selector:{asset:{$gt:""}},limit:200})).docs}catch(e){return console.error("Error finding docs",e),null}}async function ju(){try{const t=await Pn({mimeTypes:["image/*"],description:"Image Files"}),n="."+t.name.split(".").at(-1),r={fileName:t.name,extensions:[n],id:`snow-cms-upload-${ot}`},i=await wn(t,r);if(!xt){console.warn("File not saved to db: No root dir handle found.");return}const o=await xt.resolve(i);o.unshift(xt.name);const l={name:i.name,lastModifiedDate:new Date,type:t.type,webkitRelativePath:o.join("/"),handle:i},a=Bi(He(Ce),l),c=await Ge.put(a);console.log(c)}catch(e){console.error("Upload file error",e)}}async function zi(e,t){const n=[];t.forEach(o=>{const l={limit:200};e==="public"?l.selector={url:o}:l.selector={url_preview:o};const a=Ge.find(l);n.push(a)});const r=await Promise.all(n),i=[];return r.forEach(o=>i.push(...o.docs)),i}async function Vu(e){let t=e;try{const n=Ht(t);return n.length===0?e:((await zi("public",n)).forEach(i=>{t=t.replaceAll(i.url,i.url_preview)}),t)}catch(n){throw console.error("Error processing public links",n),n}}async function qu(e){let t=e;try{const n=Ht(t);return n.length===0?e:((await zi("preview",n)).forEach(i=>{t=t.replaceAll(i.url_preview,i.url)}),t)}catch(n){throw console.error("Error processing preview links",n),n}}const Vn={init:Mu,getLoginConfig:Du,getFiles:Nu,saveFile:Ru,deleteFiles:Pu,getMediaFiles:$u,uploadMediaFile:ju,replacePublicLinks:Vu,replacePreviewLinks:qu};function tn(){return typeof navigator=="object"&&"userAgent"in navigator?navigator.userAgent:typeof process=="object"&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:"<environment undetectable>"}function qn(e,t,n,r){if(typeof n!="function")throw new Error("method for before hook must be a function");return r||(r={}),Array.isArray(t)?t.reverse().reduce((i,o)=>qn.bind(null,e,o,i,r),n)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((i,o)=>o.hook.bind(null,i,r),n)():n(r))}function Yu(e,t,n,r){const i=r;e.registry[n]||(e.registry[n]=[]),t==="before"&&(r=(o,l)=>Promise.resolve().then(i.bind(null,l)).then(o.bind(null,l))),t==="after"&&(r=(o,l)=>{let a;return Promise.resolve().then(o.bind(null,l)).then(c=>(a=c,i(a,l))).then(()=>a)}),t==="error"&&(r=(o,l)=>Promise.resolve().then(o.bind(null,l)).catch(a=>i(a,l))),e.registry[n].push({hook:r,orig:i})}function Uu(e,t,n){if(!e.registry[t])return;const r=e.registry[t].map(i=>i.orig).indexOf(n);r!==-1&&e.registry[t].splice(r,1)}const Mr=Function.bind,Or=Mr.bind(Mr);function Zi(e,t,n){const r=Or(Uu,null).apply(null,n?[t,n]:[t]);e.api={remove:r},e.remove=r,["before","error","after","wrap"].forEach(i=>{const o=n?[t,i,n]:[t,i];e[i]=e.api[i]=Or(Yu,null).apply(null,o)})}function Bu(){const e=Symbol("Singular"),t={registry:{}},n=qn.bind(null,t,e);return Zi(n,t,e),n}function Gu(){const e={registry:{}},t=qn.bind(null,e);return Zi(t,e),t}const Wu={Singular:Bu,Collection:Gu};var zu="0.0.0-development",Zu=`octokit-endpoint.js/${zu} ${tn()}`,Ku={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":Zu},mediaType:{format:""}};function Qu(e){return e?Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{}):{}}function Xu(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;const t=Object.getPrototypeOf(e);if(t===null)return!0;const n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Function.prototype.call(n)===Function.prototype.call(e)}function Ki(e,t){const n=Object.assign({},e);return Object.keys(t).forEach(r=>{Xu(t[r])?r in e?n[r]=Ki(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function Dr(e){for(const t in e)e[t]===void 0&&delete e[t];return e}function bn(e,t,n){var i;if(typeof t=="string"){let[o,l]=t.split(" ");n=Object.assign(l?{method:o,url:l}:{url:o},n)}else n=Object.assign({},t);n.headers=Qu(n.headers),Dr(n),Dr(n.headers);const r=Ki(e||{},n);return n.url==="/graphql"&&(e&&((i=e.mediaType.previews)!=null&&i.length)&&(r.mediaType.previews=e.mediaType.previews.filter(o=>!r.mediaType.previews.includes(o)).concat(r.mediaType.previews)),r.mediaType.previews=(r.mediaType.previews||[]).map(o=>o.replace(/-preview/,""))),r}function Ju(e,t){const n=/\?/.test(e)?"&":"?",r=Object.keys(t);return r.length===0?e:e+n+r.map(i=>i==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${i}=${encodeURIComponent(t[i])}`).join("&")}var ef=/\{[^}]+\}/g;function tf(e){return e.replace(/^\W+|\W+$/g,"").split(/,/)}function nf(e){const t=e.match(ef);return t?t.map(tf).reduce((n,r)=>n.concat(r),[]):[]}function Fr(e,t){const n={__proto__:null};for(const r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function Qi(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function vt(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function Ct(e,t,n){return t=e==="+"||e==="#"?Qi(t):vt(t),n?vt(n)+"="+t:t}function mt(e){return e!=null}function an(e){return e===";"||e==="&"||e==="?"}function rf(e,t,n,r){var i=e[n],o=[];if(mt(i)&&i!=="")if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")i=i.toString(),r&&r!=="*"&&(i=i.substring(0,parseInt(r,10))),o.push(Ct(t,i,an(t)?n:""));else if(r==="*")Array.isArray(i)?i.filter(mt).forEach(function(l){o.push(Ct(t,l,an(t)?n:""))}):Object.keys(i).forEach(function(l){mt(i[l])&&o.push(Ct(t,i[l],l))});else{const l=[];Array.isArray(i)?i.filter(mt).forEach(function(a){l.push(Ct(t,a))}):Object.keys(i).forEach(function(a){mt(i[a])&&(l.push(vt(a)),l.push(Ct(t,i[a].toString())))}),an(t)?o.push(vt(n)+"="+l.join(",")):l.length!==0&&o.push(l.join(","))}else t===";"?mt(i)&&o.push(vt(n)):i===""&&(t==="&"||t==="?")?o.push(vt(n)+"="):i===""&&o.push("");return o}function of(e){return{expand:lf.bind(null,e)}}function lf(e,t){var n=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(r,i,o){if(i){let a="";const c=[];if(n.indexOf(i.charAt(0))!==-1&&(a=i.charAt(0),i=i.substr(1)),i.split(/,/g).forEach(function(s){var u=/([^:\*]*)(?::(\d+)|(\*))?/.exec(s);c.push(rf(t,a,u[1],u[2]||u[3]))}),a&&a!=="+"){var l=",";return a==="?"?l="&":a!=="#"&&(l=a),(c.length!==0?a:"")+c.join(l)}else return c.join(",")}else return Qi(o)}),e==="/"?e:e.replace(/\/$/,"")}function Xi(e){var u;let t=e.method.toUpperCase(),n=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),r=Object.assign({},e.headers),i,o=Fr(e,["method","baseUrl","url","headers","request","mediaType"]);const l=nf(n);n=of(n).expand(o),/^http/.test(n)||(n=e.baseUrl+n);const a=Object.keys(e).filter(f=>l.includes(f)).concat("baseUrl"),c=Fr(o,a);if(!/application\/octet-stream/i.test(r.accept)&&(e.mediaType.format&&(r.accept=r.accept.split(/,/).map(f=>f.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),n.endsWith("/graphql")&&(u=e.mediaType.previews)!=null&&u.length)){const f=r.accept.match(/[\w-]+(?=-preview)/g)||[];r.accept=f.concat(e.mediaType.previews).map(d=>{const p=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${d}-preview${p}`}).join(",")}return["GET","HEAD"].includes(t)?n=Ju(n,c):"data"in c?i=c.data:Object.keys(c).length&&(i=c),!r["content-type"]&&typeof i<"u"&&(r["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof i>"u"&&(i=""),Object.assign({method:t,url:n,headers:r},typeof i<"u"?{body:i}:null,e.request?{request:e.request}:null)}function af(e,t,n){return Xi(bn(e,t,n))}function Ji(e,t){const n=bn(e,t),r=af.bind(null,n);return Object.assign(r,{DEFAULTS:n,defaults:Ji.bind(null,n),merge:bn.bind(null,n),parse:Xi})}var cf=Ji(null,Ku);class Rt extends Error{constructor(n,r,i){super(n);ae(this,"name");ae(this,"status");ae(this,"request");ae(this,"response");this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);const o=Object.assign({},i.request);i.request.headers.authorization&&(o.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/ .*$/," [REDACTED]")})),o.url=o.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=o}}var sf="0.0.0-development",uf={headers:{"user-agent":`octokit-request.js/${sf} ${tn()}`}};function ff(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;const t=Object.getPrototypeOf(e);if(t===null)return!0;const n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Function.prototype.call(n)===Function.prototype.call(e)}async function Hr(e){var f,d,p,m,g;const t=((f=e.request)==null?void 0:f.fetch)||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");const n=((d=e.request)==null?void 0:d.log)||console,r=((p=e.request)==null?void 0:p.parseSuccessResponseBody)!==!1,i=ff(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,o=Object.fromEntries(Object.entries(e.headers).map(([_,k])=>[_,String(k)]));let l;try{l=await t(e.url,{method:e.method,body:i,redirect:(m=e.request)==null?void 0:m.redirect,headers:o,signal:(g=e.request)==null?void 0:g.signal,...e.body&&{duplex:"half"}})}catch(_){let k="Unknown Error";if(_ instanceof Error){if(_.name==="AbortError")throw _.status=500,_;k=_.message,_.name==="TypeError"&&"cause"in _&&(_.cause instanceof Error?k=_.cause.message:typeof _.cause=="string"&&(k=_.cause))}const A=new Rt(k,500,{request:e});throw A.cause=_,A}const a=l.status,c=l.url,s={};for(const[_,k]of l.headers)s[_]=k;const u={url:c,status:a,headers:s,data:""};if("deprecation"in s){const _=s.link&&s.link.match(/<([^>]+)>; rel="deprecation"/),k=_&&_.pop();n.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${k?`. See ${k}`:""}`)}if(a===204||a===205)return u;if(e.method==="HEAD"){if(a<400)return u;throw new Rt(l.statusText,a,{response:u,request:e})}if(a===304)throw u.data=await cn(l),new Rt("Not modified",a,{response:u,request:e});if(a>=400)throw u.data=await cn(l),new Rt(df(u.data),a,{response:u,request:e});return u.data=r?await cn(l):l.body,u}async function cn(e){const t=e.headers.get("content-type");return/application\/json/.test(t)?e.json().catch(()=>e.text()).catch(()=>""):!t||/^text\/|charset=utf-8$/.test(t)?e.text():e.arrayBuffer()}function df(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){const t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(n=>JSON.stringify(n)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function vn(e,t){const n=e.defaults(t);return Object.assign(function(i,o){const l=n.merge(i,o);if(!l.request||!l.request.hook)return Hr(n.parse(l));const a=(c,s)=>Hr(n.parse(n.merge(c,s)));return Object.assign(a,{endpoint:n,defaults:vn.bind(null,n)}),l.request.hook(a,l)},{endpoint:n,defaults:vn.bind(null,n)})}var yn=vn(cf,uf),pf="0.0.0-development";function hf(e){return`Request failed due to following response errors:
42
+ `);break;case"hidden":switch(_.type){case"datetime-local":case"date":case"time":S=new Date(k).getTime(),$=A.getTime();break;default:S=k,$=A;break}break;default:S=k,$=A;break}if(S!==$)return!1}return!0}return je(()=>{c=document.querySelector("#entry-data")}),e.$$.update=()=>{e.$$.dirty&33&&(i||l)&&f()},[i,s,o,a,u,l]}class gs extends se{constructor(t){super(),ce(this,t,ms,ps,oe,{})}}function _s(e){let t,n,r,i,o,l,a,c;return{c(){t=E("label"),n=te(e[2]),r=V(),i=E("input"),o=V(),l=E("input"),h(i,"type","checkbox"),h(i,"role","switch"),h(i,"id",e[1]),h(i,"name",e[1]),h(i,"form","ignore"),i.required=e[3],h(l,"type","hidden"),h(l,"id",e[1]),h(l,"name",e[1]),l.value=e[0],l.required=e[3],h(t,"class","editorInput"),h(t,"for",e[1])},m(s,u){I(s,t,u),b(t,n),b(t,r),b(t,i),i.checked=e[0],b(t,o),b(t,l),a||(c=[Z(i,"change",e[5]),Z(i,"change",e[4])],a=!0)},p(s,[u]){u&4&&_e(n,s[2]),u&2&&h(i,"id",s[1]),u&2&&h(i,"name",s[1]),u&8&&(i.required=s[3]),u&1&&(i.checked=s[0]),u&2&&h(l,"id",s[1]),u&2&&h(l,"name",s[1]),u&1&&(l.value=s[0]),u&8&&(l.required=s[3]),u&2&&h(t,"for",s[1])},i:v,o:v,d(s){s&&F(t),a=!1,fe(c)}}}function ws(e,t,n){let r,i,o;z(e,De,p=>n(6,r=p)),z(e,we,p=>n(7,i=p)),z(e,$e,p=>n(8,o=p));let{name:l}=t,{label:a}=t,{checked:c=!1}=t,{required:s=!0}=t;function u(){const p={...i};c==null?p[l]=o==null?void 0:o.fields.find(m=>m.name===l).default:p[l]=c,he(we,i=p,i)}async function f(){r&&n(0,c=r.fields[l]),u()}je(()=>{f()});function d(){c=this.checked,n(0,c)}return e.$$set=p=>{"name"in p&&n(1,l=p.name),"label"in p&&n(2,a=p.label),"checked"in p&&n(0,c=p.checked),"required"in p&&n(3,s=p.required)},[c,l,a,s,u,d]}class bs extends se{constructor(t){super(),ce(this,t,ws,_s,oe,{name:1,label:2,checked:0,required:3})}}function vs(e){let t,n,r;return{c(){t=E("input"),h(t,"type","datetime-local"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[8]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function ys(e){let t,n,r;return{c(){t=E("input"),h(t,"type","date"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[7]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function ks(e){let t,n,r;return{c(){t=E("input"),h(t,"type","time"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[6]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function As(e){let t,n,r;function i(a,c){return a[3]==="time"?ks:a[3]==="date"?ys:vs}let o=i(e),l=o(e);return{c(){t=E("label"),n=te(e[2]),r=V(),l.c(),h(t,"class","editorInput"),h(t,"for",e[1])},m(a,c){I(a,t,c),b(t,n),b(t,r),l.m(t,null)},p(a,[c]){c&4&&_e(n,a[2]),o===(o=i(a))&&l?l.p(a,c):(l.d(1),l=o(a),l&&(l.c(),l.m(t,null))),c&2&&h(t,"for",a[1])},i:v,o:v,d(a){a&&F(t),l.d()}}}function Es(e,t,n){let r,i;z(e,De,g=>n(9,r=g)),z(e,we,g=>n(10,i=g));let{name:o}=t,{label:l}=t,{type:a="datetime-local"}=t,{value:c=zt(a,new Date)}=t,{required:s=!0}=t;function u(){const g={...i};g[o]=c,he(we,i=g,i)}async function f(){if(r){const g=r.fields;n(0,c=zt(a,new Date(g[o])))}u()}je(()=>{f()});function d(){c=this.value,n(0,c)}function p(){c=this.value,n(0,c)}function m(){c=this.value,n(0,c)}return e.$$set=g=>{"name"in g&&n(1,o=g.name),"label"in g&&n(2,l=g.label),"type"in g&&n(3,a=g.type),"value"in g&&n(0,c=g.value),"required"in g&&n(4,s=g.required)},[c,o,l,a,s,u,d,p,m]}class Cs extends se{constructor(t){super(),ce(this,t,Es,As,oe,{name:1,label:2,type:3,value:0,required:4})}}function Ss(e){let t,n,r;return{c(){t=E("textarea"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[7]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function xs(e){let t,n,r;return{c(){t=E("input"),h(t,"type","text"),h(t,"id",e[1]),h(t,"name",e[1]),t.required=e[4]},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=[Z(t,"input",e[6]),Z(t,"input",e[5])],n=!0)},p(i,o){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&16&&(t.required=i[4]),o&1&&t.value!==i[0]&&ve(t,i[0])},d(i){i&&F(t),n=!1,fe(r)}}}function Ls(e){let t,n,r;function i(a,c){return a[3]?Ss:xs}let o=i(e),l=o(e);return{c(){t=E("label"),n=te(e[2]),r=V(),l.c(),h(t,"class","editorInput"),h(t,"for",e[1])},m(a,c){I(a,t,c),b(t,n),b(t,r),l.m(t,null)},p(a,[c]){c&4&&_e(n,a[2]),o===(o=i(a))&&l?l.p(a,c):(l.d(1),l=o(a),l&&(l.c(),l.m(t,null))),c&2&&h(t,"for",a[1])},i:v,o:v,d(a){a&&F(t),l.d()}}}function Ts(e,t,n){let r,i,o;z(e,De,g=>n(8,r=g)),z(e,we,g=>n(9,i=g)),z(e,$e,g=>n(10,o=g));let{name:l}=t,{label:a}=t,{multiline:c=!1}=t,{required:s=!0}=t,{value:u=""}=t;function f(){const g={...i};u?g[l]=u:g[l]=o==null?void 0:o.fields.find(_=>_.name===l).label,he(we,i=g,i)}async function d(){r&&n(0,u=l==="body"?r.body:r.fields[l]),f()}je(()=>{d()});function p(){u=this.value,n(0,u)}function m(){u=this.value,n(0,u)}return e.$$set=g=>{"name"in g&&n(1,l=g.name),"label"in g&&n(2,a=g.label),"multiline"in g&&n(3,c=g.multiline),"required"in g&&n(4,s=g.required),"value"in g&&n(0,u=g.value)},[u,l,a,c,s,f,p,m]}class wr extends se{constructor(t){super(),ce(this,t,Ts,Ls,oe,{name:1,label:2,multiline:3,required:4,value:0})}}function Ms(e){let t,n,r,i,o,l;return{c(){t=E("label"),n=te(e[2]),r=V(),i=E("input"),h(i,"type","number"),h(i,"id",e[1]),h(i,"name",e[1]),h(i,"step",e[3]),h(i,"min",e[4]),h(i,"max",e[5]),i.required=e[6],h(t,"class","editorInput"),h(t,"for",e[1])},m(a,c){I(a,t,c),b(t,n),b(t,r),b(t,i),ve(i,e[0]),o||(l=[Z(i,"input",e[8]),Z(i,"input",e[7])],o=!0)},p(a,[c]){c&4&&_e(n,a[2]),c&2&&h(i,"id",a[1]),c&2&&h(i,"name",a[1]),c&8&&h(i,"step",a[3]),c&16&&h(i,"min",a[4]),c&32&&h(i,"max",a[5]),c&64&&(i.required=a[6]),c&1&&Br(i.value)!==a[0]&&ve(i,a[0]),c&2&&h(t,"for",a[1])},i:v,o:v,d(a){a&&F(t),o=!1,fe(l)}}}function Os(e,t,n){let r,i;z(e,De,g=>n(9,r=g)),z(e,we,g=>n(10,i=g));let{name:o}=t,{label:l}=t,{value:a}=t,{step:c}=t,{min:s}=t,{max:u}=t,{required:f=!0}=t;function d(){const g={...i};g[o]=a,he(we,i=g,i)}async function p(){r&&n(0,a=r.fields[o]),d()}je(()=>{p()});function m(){a=Br(this.value),n(0,a)}return e.$$set=g=>{"name"in g&&n(1,o=g.name),"label"in g&&n(2,l=g.label),"value"in g&&n(0,a=g.value),"step"in g&&n(3,c=g.step),"min"in g&&n(4,s=g.min),"max"in g&&n(5,u=g.max),"required"in g&&n(6,f=g.required)},[a,o,l,c,s,u,f,d,m]}class Ds extends se{constructor(t){super(),ce(this,t,Os,Ms,oe,{name:1,label:2,value:0,step:3,min:4,max:5,required:6})}}const Fs=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),Hs=function(e,t){return new URL(e,t).href},br={},Xe=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const l=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),c=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=Promise.allSettled(n.map(s=>{if(s=Hs(s,r),s in br)return;br[s]=!0;const u=s.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(!!r)for(let m=l.length-1;m>=0;m--){const g=l[m];if(g.href===s&&(!u||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${s}"]${f}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":Fs,u||(p.as="script"),p.crossOrigin="",p.href=s,c&&p.setAttribute("nonce",c),document.head.appendChild(p),u)return new Promise((m,g)=>{p.addEventListener("load",m),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${s}`)))})}))}function o(l){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=l,window.dispatchEvent(a),!a.defaultPrevented)throw l}return i.then(l=>{for(const a of l||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})},Is='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-bold</title><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',Ns='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-italic</title><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',Rs='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-list-bulleted</title><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>',Ps='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-list-numbered</title><path d="M7,13V11H21V13H7M7,19V17H21V19H7M7,7V5H21V7H7M3,8V5H2V4H4V8H3M2,17V16H5V20H2V19H4V18.5H3V17.5H4V17H2M4.25,10A0.75,0.75 0 0,1 5,10.75C5,10.95 4.92,11.14 4.79,11.27L3.12,13H5V14H2V13.08L4,11H2V10H4.25Z" /></svg>',$s='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>horizontal-rule</title><path d="M19,13H5V11H19V13Z" /></svg>',js='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>format-quote-close</title><path d="M14,17H17L19,13V7H13V13H16M6,17H9L11,13V7H5V13H8L6,17Z" /></svg>',Vs='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>link</title><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',qs='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>image</title><path d="M8.5,13.5L11,16.5L14.5,12L19,18H5M21,19V5C21,3.89 20.1,3 19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19Z" /></svg>',{document:Ys}=Kt;function vr(e,t,n){const r=e.slice();return r[9]=t[n],r}function yr(e,t,n){const r=e.slice();return r[12]=t[n],r}function kr(e){let t,n=e[12].title+"",r;return{c(){t=E("option"),r=te(n),t.__value=e[12].value,ve(t,t.__value),h(t,"class","svelte-niyo7g")},m(i,o){I(i,t,o),b(t,r)},p:v,d(i){i&&F(t)}}}function Ar(e){let t,n,r=e[9].icon+"",i,o,l;return{c(){t=E("button"),n=new Ze(!1),i=V(),n.a=i,h(t,"class","secondary svelte-niyo7g"),h(t,"data-action",e[9].name)},m(a,c){I(a,t,c),n.m(r,t),b(t,i),o||(l=Z(t,"click",Ue(e[3])),o=!0)},p:v,d(a){a&&F(t),o=!1,l()}}}function Us(e){let t,n,r,i,o,l,a=Ee(e[1]),c=[];for(let f=0;f<a.length;f+=1)c[f]=kr(yr(e,a,f));let s=Ee(e[2]),u=[];for(let f=0;f<s.length;f+=1)u[f]=Ar(vr(e,s,f));return{c(){t=V(),n=E("div"),r=E("select");for(let f=0;f<c.length;f+=1)c[f].c();i=V();for(let f=0;f<u.length;f+=1)u[f].c();h(r,"name","text-type"),h(r,"form","ignore"),h(r,"class","svelte-niyo7g"),h(n,"class","editor-menu svelte-niyo7g")},m(f,d){I(f,t,d),I(f,n,d),b(n,r);for(let p=0;p<c.length;p+=1)c[p]&&c[p].m(r,null);e[6](r),b(n,i);for(let p=0;p<u.length;p+=1)u[p]&&u[p].m(n,null);o||(l=[Z(Ys,"selectionchange",e[5]),Z(r,"change",e[4])],o=!0)},p(f,[d]){if(d&2){a=Ee(f[1]);let p;for(p=0;p<a.length;p+=1){const m=yr(f,a,p);c[p]?c[p].p(m,d):(c[p]=kr(m),c[p].c(),c[p].m(r,null))}for(;p<c.length;p+=1)c[p].d(1);c.length=a.length}if(d&12){s=Ee(f[2]);let p;for(p=0;p<s.length;p+=1){const m=vr(f,s,p);u[p]?u[p].p(m,d):(u[p]=Ar(m),u[p].c(),u[p].m(n,null))}for(;p<u.length;p+=1)u[p].d(1);u.length=s.length}},i:v,o:v,d(f){f&&(F(t),F(n)),un(c,f),e[6](null),un(u,f),o=!1,fe(l)}}}function Bs(){const e=[];for(let t=0;t<=6;t++){let n;t===0?n={title:"Normal",value:"p"}:n={title:`Heading ${t}`,value:t},e.push(n)}return e}function Gs(e,t,n){const r=Qt();let i,o;const l=Bs(),a=[{name:"bold",icon:Is},{name:"italic",icon:Ns},{name:"listBulleted",icon:Rs},{name:"listNumbered",icon:Ps},{name:"quote",icon:js},{name:"horizontalRule",icon:$s},{name:"link",icon:Vs},{name:"image",icon:qs}];function c(d){const{action:p}=d.currentTarget.dataset;r("menuaction",p)}function s(d){const p=d.currentTarget.value;r("menutexttype",p)}function u(){var g;const p=(g=document.getSelection().focusNode)==null?void 0:g.parentElement;if(!o.contains(p))return;const{localName:m}=p;switch(m){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":n(0,i.value=parseInt(m.split("").at(-1)),i);break;default:n(0,i.value="p",i);break}}je(()=>{o=document.querySelector("#md-editor")});function f(d){at[d?"unshift":"push"](()=>{i=d,n(0,i),n(1,l)})}return[i,l,a,c,s,u,f]}class Ws extends se{constructor(t){super(),ce(this,t,Gs,Us,oe,{})}}const{document:zs}=Kt;function Zs(e){let t,n,r,i,o,l,a,c,s,u;return{c(){t=V(),n=E("div"),r=E("div"),i=E("div"),i.textContent="Enter link:",o=V(),l=E("input"),a=V(),c=E("button"),c.textContent="Save",h(i,"class","svelte-1vifg91"),h(l,"form","md-link-editor"),h(l,"type","url"),h(l,"name","url"),h(l,"placeholder","https://example.com"),l.required=!0,h(l,"class","svelte-1vifg91"),h(c,"class","secondary svelte-1vifg91"),h(c,"form","md-link-editor"),h(c,"type","submit"),h(r,"id","link-editor"),h(r,"class","svelte-1vifg91"),h(n,"id","link-editor-container"),h(n,"class","svelte-1vifg91"),Gn(n,"visibility",e[0]?"visible":"hidden")},m(f,d){I(f,t,d),I(f,n,d),b(n,r),b(r,i),b(r,o),b(r,l),e[5](l),b(r,a),b(r,c),e[6](r),s||(u=Z(zs,"selectionchange",e[3]),s=!0)},p(f,[d]){d&1&&Gn(n,"visibility",f[0]?"visible":"hidden")},i:v,o:v,d(f){f&&(F(t),F(n)),e[5](null),e[6](null),s=!1,u()}}}function Ks(e,t,n){const r=Qt();let i=!1,o,l;function a(){const d=document.getSelection();if(d.focusNode.parentElement.localName==="a"){r("saveurl",{});return}else if(i)n(0,i=!i),n(2,l.value="",l);else{const{startOffset:p,endOffset:m}=d.getRangeAt(0);n(0,i=p!==m)}}function c(d){d.preventDefault();const p=l.value;n(2,l.value="",l),n(0,i=!1),r("saveurl",{href:p})}function s(){if(!i)return;const p=document.getSelection().focusNode;o.contains(p)||(n(0,i=!1),n(2,l.value="",l),r("saveurl",null))}je(()=>{const d=document.querySelector("#md-link-editor");return d.addEventListener("submit",c),()=>{d.removeEventListener("submit",c)}}),_o(()=>{i&&l.focus()});function u(d){at[d?"unshift":"push"](()=>{l=d,n(2,l)})}function f(d){at[d?"unshift":"push"](()=>{o=d,n(1,o)})}return[i,o,l,s,a,u,f]}class Qs extends se{constructor(t){super(),ce(this,t,Ks,Zs,oe,{toggleEditor:4})}get toggleEditor(){return this.$$.ctx[4]}}function Er(e,t,n){const r=e.slice();return r[9]=t[n],r}function Cr(e,t){let n,r,i,o,l,a=t[9].name+"",c,s,u,f;function d(){return t[6](t[9])}return{key:e,first:null,c(){n=E("div"),r=E("img"),o=V(),l=E("small"),c=te(a),s=V(),Vt(r.src,i=t[9].url_preview)||h(r,"src",i),h(r,"alt",""),h(r,"loading","lazy"),h(r,"crossorigin","use-credentials"),h(r,"class","svelte-157z34i"),h(l,"class","svelte-157z34i"),h(n,"class","img-container svelte-157z34i"),qt(n,"selected",t[1]===t[9]),this.first=n},m(p,m){I(p,n,m),b(n,r),b(n,o),b(n,l),b(l,c),b(n,s),u||(f=Z(n,"click",d),u=!0)},p(p,m){t=p,m&1&&!Vt(r.src,i=t[9].url_preview)&&h(r,"src",i),m&1&&a!==(a=t[9].name+"")&&_e(c,a),m&3&&qt(n,"selected",t[1]===t[9])},d(p){p&&F(n),u=!1,f()}}}function Xs(e){let t,n,r,i,o,l=[],a=new Map,c,s,u,f,d,p,m,g,_,k=Ee(e[0]);const A=S=>S[9].name;for(let S=0;S<k.length;S+=1){let $=Er(e,k,S),M=A($);a.set(M,l[S]=Cr(M,$))}return{c(){t=E("dialog"),n=E("article"),r=E("header"),r.textContent="Select Image",i=V(),o=E("div");for(let S=0;S<l.length;S+=1)l[S].c();c=V(),s=E("footer"),u=E("button"),u.textContent="Cancel",f=V(),d=E("button"),p=te("Select"),h(o,"class","images svelte-157z34i"),h(u,"class","secondary svelte-157z34i"),d.disabled=m=!e[1],h(d,"class","svelte-157z34i"),h(s,"class","svelte-157z34i"),t.open=!0},m(S,$){I(S,t,$),b(t,n),b(n,r),b(n,i),b(n,o);for(let M=0;M<l.length;M+=1)l[M]&&l[M].m(o,null);b(n,c),b(n,s),b(s,u),b(s,f),b(s,d),b(d,p),g||(_=[Z(u,"click",Ue(e[4])),Z(d,"click",Ue(e[3])),Z(t,"click",e[4])],g=!0)},p(S,[$]){$&7&&(k=Ee(S[0]),l=Ft(l,$,A,1,S,k,a,o,Gr,Cr,null,Er)),$&2&&m!==(m=!S[1])&&(d.disabled=m)},i:v,o:v,d(S){S&&F(t);for(let $=0;$<l.length;$+=1)l[$].d();g=!1,fe(_)}}}function Js(e,t,n){let r;z(e,Ve,d=>n(5,r=d));const i=Qt();let o=[],l;async function a(){const d=await(r==null?void 0:r.getMediaFiles());n(0,o=d||[])}function c(d){n(1,l=d)}function s(){i("selectimg",{img:l})}function u(d){d.currentTarget===d.target&&i("selectimg",{})}je(()=>{const{body:d}=document;return d.classList.add("contain-scroll"),()=>{d.classList.remove("contain-scroll")}});const f=d=>c(d);return e.$$.update=()=>{e.$$.dirty&32&&r&&a()},[o,l,c,s,u,r,f]}class eu extends se{constructor(t){super(),ce(this,t,Js,Xs,oe,{})}}const{document:tu}=Kt;function nu(e){let t,n;return t=new Qe({props:{msg:"Unable to load",details:e[48].message}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p(r,i){const o={};i[0]&16&&(o.details=r[48].message),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function ru(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function iu(e){let t,n;return t=new en({props:{msg:"Loading"}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p:v,i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function Sr(e){let t,n;return t=new eu({}),t.$on("selectimg",e[7]),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p:v,i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function ou(e){let t,n,r,i,o,l,a,c,s,u,f,d,p,m,g,_,k,A,S;l=new Ws({}),l.$on("menutexttype",e[9]),l.$on("menuaction",e[10]);let $={};u=new Qs({props:$}),e[13](u),u.$on("saveurl",e[8]);let M={ctx:e,current:null,token:null,hasCatch:!0,pending:iu,then:ru,catch:nu,error:48,blocks:[,,,]};ue(m=e[4],M);let P=e[5]&&Sr(e);return{c(){t=V(),n=E("label"),r=te(e[2]),i=V(),o=E("div"),J(l.$$.fragment),a=V(),c=E("div"),s=V(),J(u.$$.fragment),f=V(),d=E("input"),p=V(),M.block.c(),g=V(),P&&P.c(),_=Oe(),h(o,"id","md-editor"),h(o,"class","svelte-1rfhu7q"),h(d,"type","hidden"),h(d,"id",e[1]),h(d,"name",e[1]),d.required=e[3],h(d,"class","svelte-1rfhu7q"),h(n,"class","editorInput"),h(n,"for",e[1])},m(N,C){I(N,t,C),I(N,n,C),b(n,r),b(n,i),b(n,o),Q(l,o,null),b(o,a),b(o,c),b(o,s),Q(u,o,null),b(n,f),b(n,d),ve(d,e[0]),I(N,p,C),M.block.m(N,M.anchor=C),M.mount=()=>g.parentNode,M.anchor=g,I(N,g,C),P&&P.m(N,C),I(N,_,C),k=!0,A||(S=[Z(tu,"selectionchange",e[11]),po(e[12].call(null,c)),Z(d,"input",e[14])],A=!0)},p(N,C){e=N,(!k||C[0]&4)&&_e(r,e[2]);const R={};u.$set(R),(!k||C[0]&2)&&h(d,"id",e[1]),(!k||C[0]&2)&&h(d,"name",e[1]),(!k||C[0]&8)&&(d.required=e[3]),C[0]&1&&ve(d,e[0]),(!k||C[0]&2)&&h(n,"for",e[1]),M.ctx=e,C[0]&16&&m!==(m=e[4])&&ue(m,M)||Pe(M,e,C),e[5]?P?(P.p(e,C),C[0]&32&&H(P,1)):(P=Sr(e),P.c(),H(P,1),P.m(_.parentNode,_)):P&&(ye(),j(P,1,1,()=>{P=null}),ke())},i(N){k||(H(l.$$.fragment,N),H(u.$$.fragment,N),H(M.block),H(P),k=!0)},o(N){j(l.$$.fragment,N),j(u.$$.fragment,N);for(let C=0;C<3;C+=1){const R=M.blocks[C];j(R)}j(P),k=!1},d(N){N&&(F(t),F(n),F(p),F(g),F(_)),X(l),e[13](null),X(u),M.block.d(N),M.token=null,M=null,P&&P.d(N),A=!1,fe(S)}}}function lu(e,t,n){let r,i,o,l;z(e,Ve,Y=>n(38,r=Y)),z(e,De,Y=>n(39,i=Y)),z(e,we,Y=>n(40,o=Y)),z(e,$e,Y=>n(41,l=Y));let{name:a}=t,{label:c}=t,{value:s=""}=t,{required:u=!0}=t,f,d,p,m,g,_,k,A,S,$,M,P,N,C,R,D,x,B,W,O,y,w=!1,L,T,q,G;async function K(){const Y=await Xe(()=>import("./index.es.js").then(It=>It.a5),[],import.meta.url),ee=await Xe(()=>import("./index.es2.js"),[],import.meta.url),ne=await Xe(()=>import("./index.es3.js"),[],import.meta.url),le=await Xe(()=>import("./index.es4.js"),[],import.meta.url),Re=await Xe(()=>import("./index.es5.js"),[],import.meta.url);f=Y.Editor,d=Y.rootCtx,p=Y.defaultValueCtx,m=Y.commandsCtx,g=ee.listener,_=ee.listenerCtx,k=ne.commonmark,A=ne.turnIntoTextCommand,S=ne.wrapInHeadingCommand,$=ne.toggleStrongCommand,M=ne.toggleEmphasisCommand,P=ne.wrapInBulletListCommand,N=ne.wrapInOrderedListCommand,C=ne.wrapInBlockquoteCommand,R=ne.insertHrCommand,D=ne.toggleLinkCommand,x=ne.insertImageCommand,B=le.nord,W=Re.getHTML,O=Re.replaceAll}function re(Y){const ee={...o};Y?q&&(ee[a]=W()(q.ctx).replaceAll("<img ",'<img crossorigin="use-credentials" ')):ee[a]=l==null?void 0:l.fields.find(ne=>ne.name===a).label,he(we,o=ee,o)}function ie(){if(!L)return;const Y=document.getSelection();Y.removeAllRanges();const ee=document.createRange(),{startOffset:ne,endOffset:le}=L.range;ee.setStart(L.node,ne),ee.setEnd(L.node,le),Y.addRange(ee)}function de(Y){n(5,w=!1),ie();const{img:ee}=Y.detail;ee&&q.action(ne=>{const le=ne.get(m),Re={alt:ee.name,src:ee.url_preview};le.call(x.key,Re)})}function Ae(Y){if(ie(),!Y.detail)return;const{href:ee}=Y.detail,ne=document.getSelection(),{textContent:le}=ne.focusNode,{startOffset:Re,endOffset:It}=ne.getRangeAt(0),io=le.substring(Re,It);q.action(oo=>{const lo=oo.get(m),ao={title:io,href:ee};lo.call(D.key,ao)})}function qe(Y){const ee=Y.detail;q.action(ne=>{const le=ne.get(m);ee==="p"?le.call(A.key):le.call(S.key,ee)})}function Ie(Y){const ee=Y.detail;q.action(ne=>{const le=ne.get(m);switch(ee){case"bold":le.call($.key);break;case"italic":le.call(M.key);break;case"listBulleted":le.call(P.key);break;case"listNumbered":le.call(N.key);break;case"quote":le.call(C.key);break;case"horizontalRule":le.call(R.key);break;case"link":T.toggleEditor();break;case"image":L&&n(5,w=!0);break}})}function We(){const Y=document.getSelection(),ee=Y.focusNode;G!=null&&G.contains(ee)&&(L={node:Y.focusNode,range:Y.getRangeAt(0)})}function Fe(Y){q=Y,G=document.querySelector(".milkdown .ProseMirror"),O(s)(q.ctx),re(s)}async function me(Y){await K(),f.make().config(ee=>{ee.set(d,Y),ee.set(p,s),ee.get(_).markdownUpdated((ne,le,Re)=>{n(0,s=le)})}).config(B).use(k).use(g).create().then(Fe)}function Le(Y){me(Y)}async function Ne(){if(i)try{const Y=a==="body"?i.body:i.fields[a];n(4,y=r.replacePublicLinks(Y)),n(0,s=await y),q&&O(s)(q.ctx)}catch{}}je(()=>{Ne()});function Ye(Y){at[Y?"unshift":"push"](()=>{T=Y,n(6,T)})}function ft(){s=this.value,n(0,s)}return e.$$set=Y=>{"name"in Y&&n(1,a=Y.name),"label"in Y&&n(2,c=Y.label),"value"in Y&&n(0,s=Y.value),"required"in Y&&n(3,u=Y.required)},e.$$.update=()=>{e.$$.dirty[0]&1&&re(s)},[s,a,c,u,y,w,T,de,Ae,qe,Ie,We,Le,Ye,ft]}class au extends se{constructor(t){super(),ce(this,t,lu,ou,oe,{name:1,label:2,value:0,required:3},null,[-1,-1])}}function cu(e){let t,n,r;return{c(){t=E("input"),h(t,"type","hidden"),h(t,"id",e[1]),h(t,"name",e[1])},m(i,o){I(i,t,o),ve(t,e[0]),n||(r=Z(t,"input",e[3]),n=!0)},p(i,[o]){o&2&&h(t,"id",i[1]),o&2&&h(t,"name",i[1]),o&1&&ve(t,i[0])},i:v,o:v,d(i){i&&F(t),n=!1,r()}}}function su(e,t,n){let r,i;z(e,De,f=>n(4,r=f)),z(e,we,f=>n(5,i=f));let{name:o}=t,{type:l="text"}=t,{value:a}=t;function c(){const f={...i};f[o]=a,he(we,i=f,i)}async function s(){if(r!=null&&r.fields[o])switch(l){case"datetime-local":case"date":case"time":n(0,a=zt(l,new Date(r.fields[o])));break;default:n(0,a=r.fields[o]);break}else if(!a)switch(l){case"datetime-local":case"date":case"time":n(0,a=zt(l,new Date));break;case"boolean":n(0,a="false");break}c()}je(()=>{s()});function u(){a=this.value,n(0,a)}return e.$$set=f=>{"name"in f&&n(1,o=f.name),"type"in f&&n(2,l=f.type),"value"in f&&n(0,a=f.value)},[a,o,l,u]}class uu extends se{constructor(t){super(),ce(this,t,su,cu,oe,{name:1,type:2,value:0})}}function fu(e){let t,n,r;return{c(){t=E("iframe"),h(t,"title","Preview"),h(t,"sandbox","allow-same-origin"),h(t,"srcdoc",e[1]),h(t,"class","svelte-1sw5k8j")},m(i,o){I(i,t,o),e[9](t),n||(r=Z(t,"load",e[2]),n=!0)},p(i,[o]){o&2&&h(t,"srcdoc",i[1])},i:v,o:v,d(i){i&&F(t),e[9](null),n=!1,r()}}}function du(e,t,n){let r,i,o,l,a,c;z(e,we,m=>n(6,l=m)),z(e,$e,m=>n(7,a=m)),z(e,Ce,m=>n(8,c=m)),Te.extend(Yi);let s,u;function f(){d()}function d(){if(u!=null&&u.contentDocument)for(const m in l){const g=a==null?void 0:a.fields.find(A=>A.name===m);let _=l[m];if(g.name==="date")switch(g==null?void 0:g.type){case"time":_=Te(l[m],"hh:mm").format(g.time_format);break;case"date":_=Te(l[m],"YYYY-MM-DD").format(g.date_format);break;default:_=Te(l[m],"YYYY-MM-DDThh:mm").format(g.datetime_format)}u.contentDocument.querySelectorAll(`[data-tag="${m}"]`).forEach(A=>{A.innerHTML!==_&&(A.innerHTML=_)})}}function p(m){at[m?"unshift":"push"](()=>{u=m,n(0,u)})}return e.$$.update=()=>{e.$$.dirty&384&&n(5,r=(a==null?void 0:a.preview)||(c==null?void 0:c.previews.default)),e.$$.dirty&288&&n(4,i=rs(c,r)),e.$$.dirty&288&&(async()=>n(3,s=await is(c,r)))(),e.$$.dirty&24&&n(1,o=os(s,i)),e.$$.dirty&192&&(a||l)&&d()},[u,o,f,s,i,r,l,a,c,p]}class pu extends se{constructor(t){super(),ce(this,t,du,fu,oe,{})}}function xr(e,t,n){var l;const r=e.slice();r[11]=t[n];const i=r[5][r[11].widget];r[12]=i;const o=(l=r[11])==null?void 0:l.default;return r[13]=o,r}function Lr(e){let t=[],n=new Map,r,i,o=Ee(e[3].fields);const l=a=>a[11].name;for(let a=0;a<o.length;a+=1){let c=xr(e,o,a),s=l(c);n.set(s,t[a]=Tr(s,c))}return{c(){for(let a=0;a<t.length;a+=1)t[a].c();r=Oe()},m(a,c){for(let s=0;s<t.length;s+=1)t[s]&&t[s].m(a,c);I(a,r,c),i=!0},p(a,c){c&40&&(o=Ee(a[3].fields),ye(),t=Ft(t,c,l,1,a,o,n,r.parentNode,Tn,Tr,r,xr),ke())},i(a){if(!i){for(let c=0;c<o.length;c+=1)H(t[c]);i=!0}},o(a){for(let c=0;c<t.length;c+=1)j(t[c]);i=!1},d(a){a&&F(r);for(let c=0;c<t.length;c+=1)t[c].d(a)}}}function hu(e){let t,n,r;const i=[e[11],{value:e[13]}];var o=e[12];function l(a,c){let s={};for(let u=0;u<i.length;u+=1)s=lt(s,i[u]);return c!==void 0&&c&8&&(s=lt(s,ct(i,[st(a[11]),{value:a[13]}]))),{props:s}}return o&&(t=et(o,l(e))),{c(){t&&J(t.$$.fragment),n=Oe()},m(a,c){t&&Q(t,a,c),I(a,n,c),r=!0},p(a,c){if(c&8&&o!==(o=a[12])){if(t){ye();const s=t;j(s.$$.fragment,1,0,()=>{X(s,1)}),ke()}o?(t=et(o,l(a,c)),J(t.$$.fragment),H(t.$$.fragment,1),Q(t,n.parentNode,n)):t=null}else if(o){const s=c&8?ct(i,[st(a[11]),{value:a[13]}]):{};t.$set(s)}},i(a){r||(t&&H(t.$$.fragment,a),r=!0)},o(a){t&&j(t.$$.fragment,a),r=!1},d(a){a&&F(n),t&&X(t,a)}}}function mu(e){let t,n,r;const i=[e[11],{value:e[13]},{multiline:!0}];var o=e[12];function l(a,c){let s={};for(let u=0;u<i.length;u+=1)s=lt(s,i[u]);return c!==void 0&&c&8&&(s=lt(s,ct(i,[st(a[11]),{value:a[13]},i[2]]))),{props:s}}return o&&(t=et(o,l(e))),{c(){t&&J(t.$$.fragment),n=Oe()},m(a,c){t&&Q(t,a,c),I(a,n,c),r=!0},p(a,c){if(c&8&&o!==(o=a[12])){if(t){ye();const s=t;j(s.$$.fragment,1,0,()=>{X(s,1)}),ke()}o?(t=et(o,l(a,c)),J(t.$$.fragment),H(t.$$.fragment,1),Q(t,n.parentNode,n)):t=null}else if(o){const s=c&8?ct(i,[st(a[11]),{value:a[13]},i[2]]):{};t.$set(s)}},i(a){r||(t&&H(t.$$.fragment,a),r=!0)},o(a){t&&j(t.$$.fragment,a),r=!1},d(a){a&&F(n),t&&X(t,a)}}}function gu(e){let t,n,r;const i=[e[11],{checked:e[13]}];var o=e[12];function l(a,c){let s={};for(let u=0;u<i.length;u+=1)s=lt(s,i[u]);return c!==void 0&&c&8&&(s=lt(s,ct(i,[st(a[11]),{checked:a[13]}]))),{props:s}}return o&&(t=et(o,l(e))),{c(){t&&J(t.$$.fragment),n=Oe()},m(a,c){t&&Q(t,a,c),I(a,n,c),r=!0},p(a,c){if(c&8&&o!==(o=a[12])){if(t){ye();const s=t;j(s.$$.fragment,1,0,()=>{X(s,1)}),ke()}o?(t=et(o,l(a,c)),J(t.$$.fragment),H(t.$$.fragment,1),Q(t,n.parentNode,n)):t=null}else if(o){const s=c&8?ct(i,[st(a[11]),{checked:a[13]}]):{};t.$set(s)}},i(a){r||(t&&H(t.$$.fragment,a),r=!0)},o(a){t&&j(t.$$.fragment,a),r=!1},d(a){a&&F(n),t&&X(t,a)}}}function Tr(e,t){let n,r,i,o,l;const a=[gu,mu,hu],c=[];function s(u,f){return u[11].widget==="boolean"?0:u[11].widget==="text"?1:2}return r=s(t),i=c[r]=a[r](t),{key:e,first:null,c(){n=Oe(),i.c(),o=Oe(),this.first=n},m(u,f){I(u,n,f),c[r].m(u,f),I(u,o,f),l=!0},p(u,f){t=u;let d=r;r=s(t),r===d?c[r].p(t,f):(ye(),j(c[d],1,1,()=>{c[d]=null}),ke(),i=c[r],i?i.p(t,f):(i=c[r]=a[r](t),i.c()),H(i,1),i.m(o.parentNode,o))},i(u){l||(H(i),l=!0)},o(u){j(i),l=!1},d(u){u&&(F(n),F(o)),c[r].d(u)}}}function _u(e){let t,n;return t=new Qe({props:{msg:"Unable to save",details:e[10].message}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p(r,i){const o={};i&1&&(o.details=r[10].message),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function wu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function bu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function vu(e){let t,n;return t=new Qe({props:{msg:"Unable to save",details:e[10].message}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p(r,i){const o={};i&4&&(o.details=r[10].message),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function yu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function ku(e){let t,n;return t=new en({props:{msg:"Saving"}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p:v,i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function Au(e){let t,n;return t=new Qe({props:{msg:"'On save' event action failed",details:e[10].message}}),{c(){J(t.$$.fragment)},m(r,i){Q(t,r,i),n=!0},p(r,i){const o={};i&2&&(o.details=r[10].message),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){j(t.$$.fragment,r),n=!1},d(r){X(t,r)}}}function Eu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function Cu(e){return{c:v,m:v,p:v,i:v,o:v,d:v}}function Su(e){let t,n,r,i,o,l,a,c,s,u,f,d,p,m,g,_,k,A,S,$,M,P,N,C,R,D;t=new gs({});let x=e[3]&&Lr(e);_=new pu({});let B={ctx:e,current:null,token:null,hasCatch:!0,pending:bu,then:wu,catch:_u,error:10,blocks:[,,,]};ue(A=e[0],B);let W={ctx:e,current:null,token:null,hasCatch:!0,pending:ku,then:yu,catch:vu,error:10,blocks:[,,,]};ue($=e[2],W);let O={ctx:e,current:null,token:null,hasCatch:!0,pending:Cu,then:Eu,catch:Au,error:10,blocks:[,,,]};return ue(N=e[1],O),{c(){J(t.$$.fragment),n=V(),r=E("div"),i=E("section"),o=E("header"),o.textContent="Edit",l=V(),a=E("form"),x&&x.c(),c=V(),s=E("form"),u=V(),f=E("form"),d=V(),p=E("section"),m=E("header"),m.textContent="Preview",g=V(),J(_.$$.fragment),k=V(),B.block.c(),S=V(),W.block.c(),M=V(),P=Oe(),O.block.c(),h(o,"class","svelte-14qwct"),h(a,"id","entry-data"),h(a,"class","svelte-14qwct"),h(s,"id","md-link-editor"),h(s,"class","svelte-14qwct"),h(f,"id","ignore"),h(f,"class","svelte-14qwct"),h(i,"id","inputArea"),h(i,"class","svelte-14qwct"),h(m,"class","svelte-14qwct"),h(p,"id","previewArea"),h(p,"class","svelte-14qwct"),h(r,"class","page svelte-14qwct")},m(y,w){Q(t,y,w),I(y,n,w),I(y,r,w),b(r,i),b(i,o),b(i,l),b(i,a),x&&x.m(a,null),b(i,c),b(i,s),b(i,u),b(i,f),b(r,d),b(r,p),b(p,m),b(p,g),Q(_,p,null),I(y,k,w),B.block.m(y,B.anchor=w),B.mount=()=>S.parentNode,B.anchor=S,I(y,S,w),W.block.m(y,W.anchor=w),W.mount=()=>M.parentNode,W.anchor=M,I(y,M,w),I(y,P,w),O.block.m(y,O.anchor=w),O.mount=()=>P.parentNode,O.anchor=P,C=!0,R||(D=Z(a,"submit",Ue(e[6])),R=!0)},p(y,[w]){e=y,e[3]?x?(x.p(e,w),w&8&&H(x,1)):(x=Lr(e),x.c(),H(x,1),x.m(a,null)):x&&(ye(),j(x,1,1,()=>{x=null}),ke()),B.ctx=e,w&1&&A!==(A=e[0])&&ue(A,B)||Pe(B,e,w),W.ctx=e,w&4&&$!==($=e[2])&&ue($,W)||Pe(W,e,w),O.ctx=e,w&2&&N!==(N=e[1])&&ue(N,O)||Pe(O,e,w)},i(y){C||(H(t.$$.fragment,y),H(x),H(_.$$.fragment,y),H(B.block),H(W.block),H(O.block),C=!0)},o(y){j(t.$$.fragment,y),j(x),j(_.$$.fragment,y);for(let w=0;w<3;w+=1){const L=B.blocks[w];j(L)}for(let w=0;w<3;w+=1){const L=W.blocks[w];j(L)}for(let w=0;w<3;w+=1){const L=O.blocks[w];j(L)}C=!1},d(y){y&&(F(n),F(r),F(k),F(S),F(M),F(P)),X(t,y),x&&x.d(),X(_),B.block.d(y),B.token=null,B=null,W.block.d(y),W.token=null,W=null,O.block.d(y),O.token=null,O=null,R=!1,D()}}}function xu(e,t,n){let r,i,o,l,a;z(e,De,p=>n(7,r=p)),z(e,Nn,p=>n(8,i=p)),z(e,$e,p=>n(3,l=p)),z(e,Ve,p=>n(9,a=p));const c=nt();z(e,c,p=>n(2,o=p)),Sn("submitted",c);let s,u;const f={string:wr,text:wr,datetime:Cs,boolean:bs,number:Ds,markdown:au,hidden:uu};async function d(p){const m=r?{...r}:{fields:{}},g=new FormData(p.target);for(const[k,A]of g.entries()){const S=l.fields.find($=>$.name===k);try{n(0,s=Ui(S,A,a)),m.fields[k]=await s}catch($){console.error("Error parsing form entry.",$);return}}const _=as(l,m);he(c,o=a.saveFile(l,_),o);try{he(De,r=await o,r),i!=null&&i.onSave&&(n(1,u=i.onSave(r)),await u)}catch(k){console.warn("Issue saving post.",k)}}return[s,u,o,l,c,f,d]}class Lu extends se{constructor(t){super(),ce(this,t,xu,Su,oe,{})}}async function Tu(e,t){let n;try{n=await t.text()}catch(a){console.error("Error constructing doc",a);return}const[r,i]=jn(n),o=Jt.load(r);return{_id:t.webkitRelativePath,name:t.name,collection:e,date:o.date,raw:n,fields:o,body:i,handle:t.handle,directoryHandle:t.directoryHandle}}function Bi(e,t){const n=t.lastModifiedDate,r=`${e.public_folder}/${t.name}`;return{_id:t.webkitRelativePath,name:t.name,date:n,asset:t.type,url:r,url_preview:r,handle:t.handle,directoryHandle:t.directoryHandle}}let jt,Gi,Wi,ot,Ge,xt;async function Mu(){if(ot=He(Ce).repo_folder,!ot){console.error("Missing 'repo_folder' config");return}return await Ou(),jt.plugin(Gi),jt.plugin(Wi),Ge=new jt(`${ot}-local`,{adapter:"idb"}),[["name","collection"],["date","collection"],["asset"],["url"],["url_preview"]].map(t=>({index:{fields:t},ddoc:t.join("-")})).forEach(t=>Fu(t)),console.log("Using local CMS backend"),Vn}async function Ou(){jt=(await Xe(async()=>{const{default:e}=await import("./index.es6.js");return{default:e}},[],import.meta.url)).default,Gi=(await Xe(async()=>{const{default:e}=await import("./index.es7.js");return{default:e}},[],import.meta.url)).default,Wi=(await Xe(async()=>{const{default:e}=await import("./index-browser.es.js");return{default:e}},[],import.meta.url)).default}async function Du(){return{title:"Local Backend Enabled",message:"Select the local project directory to continue.",button:"Select Project Directory",action:Iu}}async function Fu(e){try{const t=await Ge.createIndex(e);console.log("Create index",e,t)}catch(t){console.error("Create index error",t)}}async function Hu(e){try{const t=await Ge.get(e._id);e._rev=t._rev}catch(t){console.warn("Existing doc error",t)}}async function Iu(){if(!ot)return;const e=[],t=He(Ce);t.collections.forEach(s=>{const d=`\\/?${s.folder.split("/").join("\\/")}\\/[^_][\\w-]+\\.\\w+`;e.push({name:s.name,regex:new RegExp(d,"i")})});const o=`\\/?${t.media_folder.split("/").join("\\/")}\\/[^_][\\w-]+\\.\\w+`,l=new RegExp(o,"i"),a=["node_modules"],c={recursive:!0,id:`snow-cms-${ot}`,skipDirectory:s=>s.name.startsWith(".")||a.includes(s.name)};try{const s=await Vc(c),u=[],f=[];s.forEach(g=>{var A;if(!xt&&((A=g.directoryHandle)==null?void 0:A.name)===ot&&(xt=g.directoryHandle),l.test(g.webkitRelativePath)){u.push(Bi(t,g));return}const k=e.find(({name:S,regex:$})=>$.test(g.webkitRelativePath));k&&f.push(Tu(k.name,g))});const d=await Promise.all(f);d.push(...u);const p=[];d.forEach(g=>p.push(Hu(g))),await Promise.all(p);const m=await Ge.bulkDocs(d);Ve.set(Vn)}catch(s){console.error("Open directory error",s)}}async function Nu(e){try{return(await Ge.find({selector:{collection:e,date:{$gte:null}},sort:[{date:"desc"}],limit:200})).docs}catch(t){throw console.error("Error finding docs",t),t}}async function Ru(e,t){const n=He(Ce).repo_folder;t._id||(t._id=[n,e.folder,t.name].join("/"));try{const r=`.${e.extension}`,i=`snow-cms-save-${n}-${e.folder.split(/[\/\\]/).at(-1)}`.substring(0,32),o={fileName:t.name,extensions:[r],id:i},l=new Blob([t.raw],{type:cs(r)});if(t.handle)await wn(l,o,t.handle,!0);else{let c=await wn(l,o);t.handle=c}const a=await Ge.put(t);return console.log(a),t._rev=a.rev,t}catch(r){throw console.error("Save file error",r),r}}async function Pu(e){try{e.forEach(r=>r._deleted=!0);const t=await Ge.bulkDocs(e);console.log(t);const n=[];e.forEach(r=>{r.handle&&n.push(r.handle.remove())}),await Promise.all(n)}catch(t){throw console.error("Delete files error",t),t}}async function $u(){try{return(await Ge.find({selector:{asset:{$gt:""}},limit:200})).docs}catch(e){return console.error("Error finding docs",e),null}}async function ju(){try{const t=await Pn({mimeTypes:["image/*"],description:"Image Files"}),n="."+t.name.split(".").at(-1),r={fileName:t.name,extensions:[n],id:`snow-cms-upload-${ot}`},i=await wn(t,r);if(!xt){console.warn("File not saved to db: No root dir handle found.");return}const o=await xt.resolve(i);o.unshift(xt.name);const l={name:i.name,lastModifiedDate:new Date,type:t.type,webkitRelativePath:o.join("/"),handle:i},a=Bi(He(Ce),l),c=await Ge.put(a);console.log(c)}catch(e){console.error("Upload file error",e)}}async function zi(e,t){const n=[];t.forEach(o=>{const l={limit:200};e==="public"?l.selector={url:o}:l.selector={url_preview:o};const a=Ge.find(l);n.push(a)});const r=await Promise.all(n),i=[];return r.forEach(o=>i.push(...o.docs)),i}async function Vu(e){let t=e;try{const n=Ht(t);return n.length===0?e:((await zi("public",n)).forEach(i=>{t=t.replaceAll(i.url,i.url_preview)}),t)}catch(n){throw console.error("Error processing public links",n),n}}async function qu(e){let t=e;try{const n=Ht(t);return n.length===0?e:((await zi("preview",n)).forEach(i=>{t=t.replaceAll(i.url_preview,i.url)}),t)}catch(n){throw console.error("Error processing preview links",n),n}}const Vn={init:Mu,getLoginConfig:Du,getFiles:Nu,saveFile:Ru,deleteFiles:Pu,getMediaFiles:$u,uploadMediaFile:ju,replacePublicLinks:Vu,replacePreviewLinks:qu};function tn(){return typeof navigator=="object"&&"userAgent"in navigator?navigator.userAgent:typeof process=="object"&&process.version!==void 0?`Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`:"<environment undetectable>"}function qn(e,t,n,r){if(typeof n!="function")throw new Error("method for before hook must be a function");return r||(r={}),Array.isArray(t)?t.reverse().reduce((i,o)=>qn.bind(null,e,o,i,r),n)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((i,o)=>o.hook.bind(null,i,r),n)():n(r))}function Yu(e,t,n,r){const i=r;e.registry[n]||(e.registry[n]=[]),t==="before"&&(r=(o,l)=>Promise.resolve().then(i.bind(null,l)).then(o.bind(null,l))),t==="after"&&(r=(o,l)=>{let a;return Promise.resolve().then(o.bind(null,l)).then(c=>(a=c,i(a,l))).then(()=>a)}),t==="error"&&(r=(o,l)=>Promise.resolve().then(o.bind(null,l)).catch(a=>i(a,l))),e.registry[n].push({hook:r,orig:i})}function Uu(e,t,n){if(!e.registry[t])return;const r=e.registry[t].map(i=>i.orig).indexOf(n);r!==-1&&e.registry[t].splice(r,1)}const Mr=Function.bind,Or=Mr.bind(Mr);function Zi(e,t,n){const r=Or(Uu,null).apply(null,n?[t,n]:[t]);e.api={remove:r},e.remove=r,["before","error","after","wrap"].forEach(i=>{const o=n?[t,i,n]:[t,i];e[i]=e.api[i]=Or(Yu,null).apply(null,o)})}function Bu(){const e=Symbol("Singular"),t={registry:{}},n=qn.bind(null,t,e);return Zi(n,t,e),n}function Gu(){const e={registry:{}},t=qn.bind(null,e);return Zi(t,e),t}const Wu={Singular:Bu,Collection:Gu};var zu="0.0.0-development",Zu=`octokit-endpoint.js/${zu} ${tn()}`,Ku={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":Zu},mediaType:{format:""}};function Qu(e){return e?Object.keys(e).reduce((t,n)=>(t[n.toLowerCase()]=e[n],t),{}):{}}function Xu(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;const t=Object.getPrototypeOf(e);if(t===null)return!0;const n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Function.prototype.call(n)===Function.prototype.call(e)}function Ki(e,t){const n=Object.assign({},e);return Object.keys(t).forEach(r=>{Xu(t[r])?r in e?n[r]=Ki(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function Dr(e){for(const t in e)e[t]===void 0&&delete e[t];return e}function bn(e,t,n){var i;if(typeof t=="string"){let[o,l]=t.split(" ");n=Object.assign(l?{method:o,url:l}:{url:o},n)}else n=Object.assign({},t);n.headers=Qu(n.headers),Dr(n),Dr(n.headers);const r=Ki(e||{},n);return n.url==="/graphql"&&(e&&((i=e.mediaType.previews)!=null&&i.length)&&(r.mediaType.previews=e.mediaType.previews.filter(o=>!r.mediaType.previews.includes(o)).concat(r.mediaType.previews)),r.mediaType.previews=(r.mediaType.previews||[]).map(o=>o.replace(/-preview/,""))),r}function Ju(e,t){const n=/\?/.test(e)?"&":"?",r=Object.keys(t);return r.length===0?e:e+n+r.map(i=>i==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${i}=${encodeURIComponent(t[i])}`).join("&")}var ef=/\{[^}]+\}/g;function tf(e){return e.replace(/^\W+|\W+$/g,"").split(/,/)}function nf(e){const t=e.match(ef);return t?t.map(tf).reduce((n,r)=>n.concat(r),[]):[]}function Fr(e,t){const n={__proto__:null};for(const r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function Qi(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function vt(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function Ct(e,t,n){return t=e==="+"||e==="#"?Qi(t):vt(t),n?vt(n)+"="+t:t}function mt(e){return e!=null}function an(e){return e===";"||e==="&"||e==="?"}function rf(e,t,n,r){var i=e[n],o=[];if(mt(i)&&i!=="")if(typeof i=="string"||typeof i=="number"||typeof i=="boolean")i=i.toString(),r&&r!=="*"&&(i=i.substring(0,parseInt(r,10))),o.push(Ct(t,i,an(t)?n:""));else if(r==="*")Array.isArray(i)?i.filter(mt).forEach(function(l){o.push(Ct(t,l,an(t)?n:""))}):Object.keys(i).forEach(function(l){mt(i[l])&&o.push(Ct(t,i[l],l))});else{const l=[];Array.isArray(i)?i.filter(mt).forEach(function(a){l.push(Ct(t,a))}):Object.keys(i).forEach(function(a){mt(i[a])&&(l.push(vt(a)),l.push(Ct(t,i[a].toString())))}),an(t)?o.push(vt(n)+"="+l.join(",")):l.length!==0&&o.push(l.join(","))}else t===";"?mt(i)&&o.push(vt(n)):i===""&&(t==="&"||t==="?")?o.push(vt(n)+"="):i===""&&o.push("");return o}function of(e){return{expand:lf.bind(null,e)}}function lf(e,t){var n=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(r,i,o){if(i){let a="";const c=[];if(n.indexOf(i.charAt(0))!==-1&&(a=i.charAt(0),i=i.substr(1)),i.split(/,/g).forEach(function(s){var u=/([^:\*]*)(?::(\d+)|(\*))?/.exec(s);c.push(rf(t,a,u[1],u[2]||u[3]))}),a&&a!=="+"){var l=",";return a==="?"?l="&":a!=="#"&&(l=a),(c.length!==0?a:"")+c.join(l)}else return c.join(",")}else return Qi(o)}),e==="/"?e:e.replace(/\/$/,"")}function Xi(e){var u;let t=e.method.toUpperCase(),n=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),r=Object.assign({},e.headers),i,o=Fr(e,["method","baseUrl","url","headers","request","mediaType"]);const l=nf(n);n=of(n).expand(o),/^http/.test(n)||(n=e.baseUrl+n);const a=Object.keys(e).filter(f=>l.includes(f)).concat("baseUrl"),c=Fr(o,a);if(!/application\/octet-stream/i.test(r.accept)&&(e.mediaType.format&&(r.accept=r.accept.split(/,/).map(f=>f.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),n.endsWith("/graphql")&&(u=e.mediaType.previews)!=null&&u.length)){const f=r.accept.match(/[\w-]+(?=-preview)/g)||[];r.accept=f.concat(e.mediaType.previews).map(d=>{const p=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${d}-preview${p}`}).join(",")}return["GET","HEAD"].includes(t)?n=Ju(n,c):"data"in c?i=c.data:Object.keys(c).length&&(i=c),!r["content-type"]&&typeof i<"u"&&(r["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof i>"u"&&(i=""),Object.assign({method:t,url:n,headers:r},typeof i<"u"?{body:i}:null,e.request?{request:e.request}:null)}function af(e,t,n){return Xi(bn(e,t,n))}function Ji(e,t){const n=bn(e,t),r=af.bind(null,n);return Object.assign(r,{DEFAULTS:n,defaults:Ji.bind(null,n),merge:bn.bind(null,n),parse:Xi})}var cf=Ji(null,Ku);class Rt extends Error{constructor(n,r,i){super(n);ae(this,"name");ae(this,"status");ae(this,"request");ae(this,"response");this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);const o=Object.assign({},i.request);i.request.headers.authorization&&(o.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/ .*$/," [REDACTED]")})),o.url=o.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=o}}var sf="0.0.0-development",uf={headers:{"user-agent":`octokit-request.js/${sf} ${tn()}`}};function ff(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;const t=Object.getPrototypeOf(e);if(t===null)return!0;const n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Function.prototype.call(n)===Function.prototype.call(e)}async function Hr(e){var f,d,p,m,g;const t=((f=e.request)==null?void 0:f.fetch)||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");const n=((d=e.request)==null?void 0:d.log)||console,r=((p=e.request)==null?void 0:p.parseSuccessResponseBody)!==!1,i=ff(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,o=Object.fromEntries(Object.entries(e.headers).map(([_,k])=>[_,String(k)]));let l;try{l=await t(e.url,{method:e.method,body:i,redirect:(m=e.request)==null?void 0:m.redirect,headers:o,signal:(g=e.request)==null?void 0:g.signal,...e.body&&{duplex:"half"}})}catch(_){let k="Unknown Error";if(_ instanceof Error){if(_.name==="AbortError")throw _.status=500,_;k=_.message,_.name==="TypeError"&&"cause"in _&&(_.cause instanceof Error?k=_.cause.message:typeof _.cause=="string"&&(k=_.cause))}const A=new Rt(k,500,{request:e});throw A.cause=_,A}const a=l.status,c=l.url,s={};for(const[_,k]of l.headers)s[_]=k;const u={url:c,status:a,headers:s,data:""};if("deprecation"in s){const _=s.link&&s.link.match(/<([^>]+)>; rel="deprecation"/),k=_&&_.pop();n.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${k?`. See ${k}`:""}`)}if(a===204||a===205)return u;if(e.method==="HEAD"){if(a<400)return u;throw new Rt(l.statusText,a,{response:u,request:e})}if(a===304)throw u.data=await cn(l),new Rt("Not modified",a,{response:u,request:e});if(a>=400)throw u.data=await cn(l),new Rt(df(u.data),a,{response:u,request:e});return u.data=r?await cn(l):l.body,u}async function cn(e){const t=e.headers.get("content-type");return/application\/json/.test(t)?e.json().catch(()=>e.text()).catch(()=>""):!t||/^text\/|charset=utf-8$/.test(t)?e.text():e.arrayBuffer()}function df(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){const t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(n=>JSON.stringify(n)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function vn(e,t){const n=e.defaults(t);return Object.assign(function(i,o){const l=n.merge(i,o);if(!l.request||!l.request.hook)return Hr(n.parse(l));const a=(c,s)=>Hr(n.parse(n.merge(c,s)));return Object.assign(a,{endpoint:n,defaults:vn.bind(null,n)}),l.request.hook(a,l)},{endpoint:n,defaults:vn.bind(null,n)})}var yn=vn(cf,uf),pf="0.0.0-development";function hf(e){return`Request failed due to following response errors:
43
43
  `+e.errors.map(t=>` - ${t.message}`).join(`
44
44
  `)}var mf=class extends Error{constructor(t,n,r){super(hf(r));ae(this,"name","GraphqlResponseError");ae(this,"errors");ae(this,"data");this.request=t,this.headers=n,this.response=r,this.errors=r.errors,this.data=r.data,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},gf=["method","baseUrl","url","headers","request","query","mediaType"],_f=["query","method","url"],Ir=/\/api\/v3\/?$/;function wf(e,t,n){if(n){if(typeof t=="string"&&"query"in n)return Promise.reject(new Error('[@octokit/graphql] "query" cannot be used as variable name'));for(const l in n)if(_f.includes(l))return Promise.reject(new Error(`[@octokit/graphql] "${l}" cannot be used as variable name`))}const r=typeof t=="string"?Object.assign({query:t},n):t,i=Object.keys(r).reduce((l,a)=>gf.includes(a)?(l[a]=r[a],l):(l.variables||(l.variables={}),l.variables[a]=r[a],l),{}),o=r.baseUrl||e.endpoint.DEFAULTS.baseUrl;return Ir.test(o)&&(i.url=o.replace(Ir,"/api/graphql")),e(i).then(l=>{if(l.data.errors){const a={};for(const c of Object.keys(l.headers))a[c]=l.headers[c];throw new mf(i,a,l.data)}return l.data.data})}function Yn(e,t){const n=e.defaults(t);return Object.assign((i,o)=>wf(n,i,o),{defaults:Yn.bind(null,n),endpoint:n.endpoint})}Yn(yn,{headers:{"user-agent":`octokit-graphql.js/${pf} ${tn()}`},method:"POST",url:"/graphql"});function bf(e){return Yn(e,{method:"POST",url:"/graphql"})}var vf=/^v1\./,yf=/^ghs_/,kf=/^ghu_/;async function Af(e){const t=e.split(/\./).length===3,n=vf.test(e)||yf.test(e),r=kf.test(e);return{type:"token",token:e,tokenType:t?"app":n?"installation":r?"user-to-server":"oauth"}}function Ef(e){return e.split(/\./).length===3?`bearer ${e}`:`token ${e}`}async function Cf(e,t,n,r){const i=t.endpoint.merge(n,r);return i.headers.authorization=Ef(e),t(i)}var Sf=function(t){if(!t)throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");if(typeof t!="string")throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string");return t=t.replace(/^(token|bearer) +/i,""),Object.assign(Af.bind(null,t),{hook:Cf.bind(null,t)})};const eo="6.1.2",Nr=()=>{},xf=console.warn.bind(console),Lf=console.error.bind(console),Rr=`octokit-core.js/${eo} ${tn()}`;class kn{constructor(t={}){ae(this,"request");ae(this,"graphql");ae(this,"log");ae(this,"hook");ae(this,"auth");const n=new Wu.Collection,r={baseUrl:yn.endpoint.DEFAULTS.baseUrl,headers:{},request:Object.assign({},t.request,{hook:n.bind(null,"request")}),mediaType:{previews:[],format:""}};if(r.headers["user-agent"]=t.userAgent?`${t.userAgent} ${Rr}`:Rr,t.baseUrl&&(r.baseUrl=t.baseUrl),t.previews&&(r.mediaType.previews=t.previews),t.timeZone&&(r.headers["time-zone"]=t.timeZone),this.request=yn.defaults(r),this.graphql=bf(this.request).defaults(r),this.log=Object.assign({debug:Nr,info:Nr,warn:xf,error:Lf},t.log),this.hook=n,t.authStrategy){const{authStrategy:o,...l}=t,a=o(Object.assign({request:this.request,log:this.log,octokit:this,octokitOptions:l},t.auth));n.wrap("request",a.hook),this.auth=a}else if(!t.auth)this.auth=async()=>({type:"unauthenticated"});else{const o=Sf(t.auth);n.wrap("request",o.hook),this.auth=o}const i=this.constructor;for(let o=0;o<i.plugins.length;++o)Object.assign(this,i.plugins[o](this,t))}static defaults(t){return class extends this{constructor(...r){const i=r[0]||{};if(typeof t=="function"){super(t(i));return}super(Object.assign({},t,i,i.userAgent&&t.userAgent?{userAgent:`${i.userAgent} ${t.userAgent}`}:null))}}}static plugin(...t){var i;const n=this.plugins;return i=class extends this{},ae(i,"plugins",n.concat(t.filter(o=>!n.includes(o)))),i}}ae(kn,"VERSION",eo),ae(kn,"plugins",[]);function to(e,t,n,r){return e.graphql(`
45
45
  query GetRepoPath($repoOwner: String!, $repoName: String!, $path: String!) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snow-cms",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "A configurable CMS built with Svelte.",
5
5
  "keywords": [],
6
6
  "author": "Sammy-T",
@@ -39,7 +39,7 @@
39
39
  "pouchdb-core": "^9.0.0",
40
40
  "pouchdb-find": "^9.0.0",
41
41
  "svelte": "^4.2.19",
42
- "vite": "^5.4.4"
42
+ "vite": "^5.4.7"
43
43
  },
44
44
  "scripts": {
45
45
  "dev": "run-p build:watch:cms serve:site",