@sveltia/cms 0.9.6 → 0.9.7

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.
@@ -220,7 +220,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
220
220
  `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
221
221
  `,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){const i="end"in n.value?n.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){const s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const i=!this.onKeyLine&&this.indent===e.indent&&n.sep;let s=[];if(i&&n.sep&&!n.value){const l=[];for(let r=0;r<n.sep.length;++r){const o=n.sep[r];switch(o.type){case"newline":l.push(r);break;case"space":break;case"comment":o.indent>e.indent&&(l.length=0);break;default:l.length=0}}l.length>=2&&(s=n.sep.splice(l[1]))}switch(this.type){case"anchor":case"tag":i||n.value?(s.push(this.sourceToken),e.items.push({start:s}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!di(n.start,"explicit-key-ind")?n.start.push(this.sourceToken):i||n.value?(s.push(this.sourceToken),e.items.push({start:s})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]}),this.onKeyLine=!0;return;case"map-value-ind":if(di(n.start,"explicit-key-ind"))if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(di(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(zw(n.key)&&!di(n.sep,"newline")){const l=Nl(n.start),r=n.key,o=n.sep;o.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,key:r,sep:o}]})}else s.length>0?n.sep=n.sep.concat(s,this.sourceToken):n.sep.push(this.sourceToken);else if(di(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{const l=Nl(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:l,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||i?e.items.push({start:s,key:null,sep:[this.sourceToken]}):di(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const l=this.flowScalar(this.type);i||n.value?(e.items.push({start:s,key:l,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(l):(Object.assign(n,{key:l,sep:[]}),this.onKeyLine=!0);return}default:{const l=this.startBlockValue(e);if(l){i&&l.type!=="block-seq"&&di(n.start,"explicit-key-ind")&&e.items.push({start:s}),this.stack.push(l);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){const i="end"in n.value?n.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){const s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||di(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){const i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){const n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i&&i.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const s=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:s,sep:[]}):n.sep?this.stack.push(s):Object.assign(n,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}const i=this.startBlockValue(e);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{const i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){const s=ca(i),l=Nl(s);og(e);const r=e.end.splice(1,e.end.length);r.push(this.sourceToken);const o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:l,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
222
222
  `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
223
- `,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const n=ca(e),i=Nl(n);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i}]}}case"map-value-ind":{this.onKeyLine=!0;const n=ca(e),i=Nl(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function jw(t){const e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Rw||null,prettyErrors:e}}function xA(t,e={}){const{lineCounter:n,prettyErrors:i}=jw(e),s=new ih(n?.addNewLine),l=new nh(e),r=Array.from(l.compose(s.parse(t)));if(i&&n)for(const o of r)o.errors.forEach(Ha(t,n)),o.warnings.forEach(Ha(t,n));return r.length>0?r:Object.assign([],{empty:!0},l.streamInfo())}function Fw(t,e={}){const{lineCounter:n,prettyErrors:i}=jw(e),s=new ih(n?.addNewLine),l=new nh(e);let r=null;for(const o of l.compose(s.parse(t),!0,t.length))if(!r)r=o;else if(r.options.logLevel!=="silent"){r.errors.push(new Ks(o.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(r.errors.forEach(Ha(t,n)),r.warnings.forEach(Ha(t,n))),r}function eL(t,e,n){let i;typeof e=="function"?i=e:n===void 0&&e&&typeof e=="object"&&(n=e);const s=Fw(t,n);if(!s)return null;if(s.warnings.forEach(l=>rw(s.options.logLevel,l)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:i},n))}function tL(t,e,n){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){const s=Math.round(n);n=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){const{keepUndefined:s}=n??e??{};if(!s)return}return new Nr(t,i,n).toString(n)}const fr=Object.freeze(Object.defineProperty({__proto__:null,Alias:Dc,CST:XA,Composer:nh,Document:Nr,Lexer:Mw,LineCounter:Rw,Pair:dn,Parser:ih,Scalar:xe,Schema:Vc,YAMLError:eh,YAMLMap:Rn,YAMLParseError:Ks,YAMLSeq:Ps,YAMLWarning:Ew,isAlias:dl,isCollection:Ft,isDocument:Er,isMap:Tr,isNode:qt,isPair:Dt,isScalar:At,isSeq:Ar,parse:eL,parseAllDocuments:xA,parseDocument:Fw,stringify:tL,visit:$s,visitAsync:Cc},Symbol.toStringTag,{value:"Module"}));function Bw(t){return t&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Uw(t){return t}function ls(t,e){e=e||{};const n=e.delimiter||".",i=e.maxDepth,s=e.transformKey||Uw,l={};function r(o,a,c){c=c||1,Object.keys(o).forEach(function(u){const f=o[u],d=e.safe&&Array.isArray(f),h=Object.prototype.toString.call(f),m=Bw(f),b=h==="[object Object]"||h==="[object Array]",g=a?a+n+s(u):s(u);if(!d&&!m&&b&&Object.keys(f).length&&(!e.maxDepth||c<i))return r(f,g,c+1);l[g]=f})}return r(t),l}function al(t,e){e=e||{};const n=e.delimiter||".",i=e.overwrite||!1,s=e.transformKey||Uw,l={};if(Bw(t)||Object.prototype.toString.call(t)!=="[object Object]")return t;function o(u){const f=Number(u);return isNaN(f)||u.indexOf(".")!==-1||e.object?u:f}function a(u,f,d){return Object.keys(d).reduce(function(h,m){return h[u+n+m]=d[m],h},f)}function c(u){const f=Object.prototype.toString.call(u),d=f==="[object Array]",h=f==="[object Object]";if(u){if(d)return!u.length;if(h)return!Object.keys(u).length}else return!0}return t=Object.keys(t).reduce(function(u,f){const d=Object.prototype.toString.call(t[f]);return!(d==="[object Object]"||d==="[object Array]")||c(t[f])?(u[f]=t[f],u):a(f,u,ls(t[f],e))},{}),Object.keys(t).forEach(function(u){const f=u.split(n).map(s);let d=o(f.shift()),h=o(f[0]),m=l;for(;h!==void 0;){if(d==="__proto__")return;const b=Object.prototype.toString.call(m[d]),g=b==="[object Object]"||b==="[object Array]";if(!i&&!g&&typeof m[d]<"u")return;(i&&!g||!i&&m[d]==null)&&(m[d]=typeof h=="number"&&!e.object?[]:{}),m=m[d],f.length>0&&(d=o(f.shift()),h=o(f[0]))}m[d]=al(t[u],e)}),l}const Ya=(t,e,{ellipsis:n="…"}={})=>{const i=[...t];return`${i.slice(0,e).join("").trim()}${i.length>e?n:""}`},Ht=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Es=t=>t.replace(/^\/+/,"").replace(/\/+$/,""),Zs=()=>window.crypto.randomUUID(),ag=t=>t.match(/{{.+?}}/)?t:`{{${t}}}`,sh=(t,e,n)=>{const i=e.value_field,s=e.display_fields,l=ag(i),r=(s??[i]).map(ag).join(" ");return n.map(o=>{const{content:a}=o?.locales[t]??{};if(!a)return;const c=ls(a),u=Object.fromEntries([...new Set([...[...r.matchAll(/{{(.+?)}}/g)].map(m=>m[1]),...[...l.matchAll(/{{(.+?)}}/g)].map(m=>m[1])].map(m=>m.includes(".")?m.replace(/^([^.]+)+\.\*\.[^.]+$/,"$1.*"):m))].map(m=>{if(m.endsWith(".*")){const w=new RegExp(`^${Ht(m).replace("\\.\\*","\\.\\d+\\.[^.]+")}$`),k=al(Object.fromEntries(Object.entries(c).filter(([E])=>!!E.match(w))));return[m,k[Object.keys(k)[0]]??""]}if(m==="slug")return[m,o.slug];const b=Wn({collectionName:e.collection,keyPath:m}),g=m.replace(/^fields\./,""),v=c[g];return b?.widget==="relation"?[m,lh({fieldConfig:b,valueMap:c,keyPath:g,locale:t})??""]:[m,v??""]})),f=Math.max(...Object.values(u).map(m=>Array.isArray(m)?m.length:1));let d=new Array(f).fill(r),h=new Array(f).fill(l);return Object.entries(u).forEach(([m,b])=>{Array.isArray(b)?b.forEach((g,v)=>{Object.entries(g).forEach(([w,k])=>{d.forEach((E,N)=>{v%N===0&&(d[v]=d[v].replaceAll(`{{${m}.${w}}}`,k),h[v]=h[v].replaceAll(`{{${m}.${w}}}`,k))})})}):(d=d.map(g=>g.replaceAll(`{{${m}}}`,b)),h=h.map(g=>g.replaceAll(`{{${m}}}`,b)))}),d.map((m,b)=>({label:m,value:h[b]}))}).flat(1).filter(Boolean).sort((o,a)=>o.label.localeCompare(a.label))},lh=({fieldConfig:t,valueMap:e,keyPath:n,locale:i})=>{const{multiple:s,collection:l}=t,r=qo(l),o=sh(i,t,r),a=c=>o.find(u=>u.value===c)?.label||c;return s?Object.entries(e).filter(([u])=>u.match(`^${Ht(n)}\\.\\d+$`)).map(([,u])=>u).map(a):a(e[n])},pi=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),qw=t=>Array.isArray(t)&&t.every(e=>pi(e)),Hw=(t=1e3)=>new Promise(e=>{window.setTimeout(()=>{e()},t)}),nL=({fieldConfig:t,valueMap:e,keyPath:n})=>{const{multiple:i,options:s}=t,l=qw(s),r=a=>s.find(c=>c.value===a)?.label||a;if(i){const a=Object.entries(e).filter(([c])=>c.match(`^${Ht(n)}\\.\\d+$`)).map(([,c])=>c);return l?a.map(r):a}const o=e[n];return l?r(o):o},Wn=({collectionName:t,fileName:e=void 0,valueMap:n={},keyPath:i})=>{const s=yi(t),l=e?s._fileMap[e]:void 0,{fields:r}=l??s,o=i.split(".");let a;return o.forEach((c,u)=>{if(u===0)a=r.find(({name:f})=>f===c);else if(a){const f=c.match(/^\d+$/),{field:d,fields:h,types:m,typeKey:b="type"}=a;d?a=d:h&&!f?a=h.find(({name:g})=>g===c):m&&f&&(a=m.find(({name:g})=>g===n[`${o.slice(0,u).join(".")}.${c}.${b}`]))}}),a},rh=({collectionName:t,fileName:e,valueMap:n,keyPath:i,locale:s})=>{const l=Wn({collectionName:t,fileName:e,valueMap:n,keyPath:i});let r=n[i];return l?.widget==="relation"&&(r=lh({fieldConfig:l,valueMap:n,keyPath:i,locale:s})),l?.widget==="select"&&(r=nL({fieldConfig:l,valueMap:n,keyPath:i})),r??""},dr=(t,e,n,{resolveRef:i=!0}={})=>{const{slug:s,locales:l,commitAuthor:{name:r,login:o,email:a}={},commitDate:c}=t;if(n==="slug")return s;if(n==="commit_author")return r||o||a;if(n==="commit_date")return c;const u=l[e]?.content;if(u===void 0)return;const f=n.includes(".")?ls(u):u;if(i){const d=Wn({collectionName:t.collectionName,keyPath:n});if(d?.widget==="relation")return lh({fieldConfig:d,valueMap:f,keyPath:n,locale:e})}return f[n]},Vw=(t,{relative:e=!1}={})=>{const{collectionName:n,locales:i}=t;return Object.values(i).map(({content:s})=>Object.entries(s).map(([l,r])=>{if((!e||!r.match(/^[/@]/))&&["image","file"].includes(Wn({collectionName:n,keyPath:l})?.widget)){const o=Gw(r,t);if(o?.collectionName===n)return o}})).flat(1).filter((s,l,r)=>!!s&&r.indexOf(s)===l)},zs={i18nEnabled:!1,saveAllLocales:!0,locales:["_default"],defaultLocale:"_default",structure:"single_file"},cg=(t,e)=>{const n=re(vt);let i;pi(n?.i18n)&&(i=n.i18n,t?.i18n?(pi(t.i18n)&&Object.assign(i,t.i18n),e&&(e.i18n?pi(e.i18n)&&Object.assign(i,e.i18n):i=void 0)):i=void 0);const{structure:s="single_file",locales:l=[],default_locale:r=void 0,save_all_locales:o=!0}=i??{},a=!!l.length;return{i18nEnabled:a,saveAllLocales:o,locales:a?l:["_default"],defaultLocale:a?r&&l.includes(r)?r:l[0]:"_default",structure:e?"single_file":s}},js=t=>{let e;if(t!=="_default")try{[e]=Intl.getCanonicalLocales(t)}catch{}return e},qn=t=>{const e=js(t);try{return new Intl.DisplayNames(re(Jt),{type:"language"}).of(e)}catch{return t}},vo=Ye(!1),oh=Ye([]),si=Ye([]),Mt=Ye(),Ts=Ye([]),yi=t=>{const e=re(vt).collections.find(n=>n.name===t);if(e)return{...e,_fileMap:e.files?.length?Object.fromEntries(e.files.map(n=>[n.name,{...n,_i18n:cg(e,n)}])):void 0,_i18n:cg(e),_assetFolder:re(Hn).find(({collectionName:n})=>n===t)}},ah=(t,e)=>re(si).find(n=>n.collectionName===t&&n.fileName===e),qo=t=>{const e=yi(t);if(!e)return[];const{filter:n,_i18n:{defaultLocale:i}}=e;return re(si).filter(s=>s.collectionName===t&&(!n||dr(s,i,n.field)===n.value))},iL=async t=>{const e=t.replace(re(vt).site_url,""),n=re(si),i=await Promise.all(n.map(async s=>{const{locales:l,collectionName:r,fileName:o}=s;return(await Promise.all(Object.values(l).map(async({content:c})=>{const u=ls(c);return(await Promise.all(Object.entries(u).map(async([d,h])=>{const m=Wn({collectionName:r,fileName:o,valueMap:u,keyPath:d});return!m||!["image","file"].includes(m.widget)?!1:await Ho(h,s)===e}))).includes(!0)}))).includes(!0)}));return n.filter((s,l)=>i[l])};var sL=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var i,s,l;if(Array.isArray(e)){if(i=e.length,i!=n.length)return!1;for(s=i;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(l=Object.keys(e),i=l.length,i!==Object.keys(n).length)return!1;for(s=i;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,l[s]))return!1;for(s=i;s--!==0;){var r=l[s];if(!t(e[r],n[r]))return!1}return!0}return e!==e&&n!==n};const Cn=Nd(sL);class tn{static async set(e,n){window.localStorage.setItem(e,JSON.stringify(n))}static async get(e){return JSON.parse(window.localStorage.getItem(e))}static async delete(e){window.localStorage.removeItem(e)}static async clear(){window.localStorage.clear()}static async keys(){return Object.keys(window.localStorage)}static async values(){return Object.values(window.localStorage).map(e=>JSON.parse(e))}static async entries(){return Object.entries(window.localStorage).map(([e,n])=>[e,JSON.parse(n)])}}const Ff="sveltia-cms.prefs",bt=Ye({},t=>{(async()=>{try{const e=await tn.get(Ff)??{};e.apiKeys??={},t(e)}catch{t({error:"permission_denied"})}})()});bt.subscribe(async t=>{if(!t||t.error||!Object.keys(t).length)return;try{Cn(t,await tn.get(Ff))||await tn.set(Ff,t)}catch{}const{locale:e,theme:n,devModeEnabled:i=!1}=t;e&&re(kv).includes(e)&&Jt.set(e);const s=!n||n==="auto",l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";Object.assign(document.documentElement.dataset,{theme:s?l:n,autoTheming:s,env:i?"dev":"prod"})});var lL={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const vt=Ye(),{DEV:rL,VITE_SITE_URL:oL}=lL,aL=t=>{if(!pi(t))throw new Error(re(me)("config.error.parse_failed"));if(!t.collections?.length)throw new Error(re(me)("config.error.no_collection"));if(!t.backend?.name)throw new Error(re(me)("config.error.no_backend"));if(!(t.backend.name in uy))throw new Error(re(me)("config.error.unsupported_backend",{values:{name:t.backend.name}}));if(!t.media_folder)throw new Error(re(me)("config.error.no_media_folder"))},cL=async()=>{const{href:t="./config.yml"}=document.querySelector('link[type="text/yaml"][rel="cms-config-url"]')??{};let e,n;try{try{e=await fetch(t)}catch{throw new Error(re(me)("config.error.fetch_failed"))}if(!e.ok)throw new Error(re(me)("config.error.fetch_failed"));try{n=fr.parse(await e.text())}catch{throw new Error(re(me)("config.error.parse_failed"))}aL(n),rL&&!n.site_url&&(n.site_url=oL||"http://localhost:5174"),vt.set(n)}catch(i){vt.set({error:i.name==="Error"?i.message:re(me)("config.error.unexpected")}),console.error(i)}};vt.subscribe(t=>{if(re(bt).devModeEnabled&&console.info("siteConfig",t),!t||t.error)return;const{media_folder:e,public_folder:n,collections:i}=t;Mt.set(yi(i[0].name));const s=[...i.filter(({folder:u})=>!!u).map(({name:u,folder:f,extension:d,format:h,frontmatter_delimiter:m,yaml_quote:b})=>({collectionName:u,folderPath:f,extension:d,format:h,frontmatterDelimiter:m,yamlQuote:b})).sort((u,f)=>u.folderPath.localeCompare(f.folderPath)),...i.filter(({files:u})=>!!u).map(({name:u,files:f,extension:d,format:h,frontmatter_delimiter:m,yaml_quote:b})=>f.map(({name:g,file:v})=>({collectionName:u,fileName:g,filePath:v,extension:d,format:h,frontmatterDelimiter:m,yamlQuote:b}))).flat(1).sort((u,f)=>u.filePath.localeCompare(f.filePath))],l=Es(e),r=n?`/${Es(n)}`.replace(/^\/@/,"@"):`/${l}`,o={collectionName:null,internalPath:l,publicPath:r,entryRelative:!1},a=i.map(u=>{const{name:f,folder:d,path:h,public_folder:m}=u;let{media_folder:b}=u;if(b===void 0){if(h===void 0)return null;b=""}b=b.replace("{{media_folder}}",l);const g=!b.startsWith("/");return{collectionName:f,internalPath:Es(g?d:b),publicPath:(m??b).replace("{{public_folder}}",r),entryRelative:g}}),c=[o,...a.filter(Boolean).sort((u,f)=>u.internalPath.localeCompare(f.internalPath))];oh.set(s),Hn.set(c),re(bt).devModeEnabled&&(console.info("allEntryFolders",s),console.info("allAssetFolders",c))});const uL=async({items:t},{accept:e}={})=>{const n=e?e.trim().split(/,\s*/g):[],i=s=>new Promise(l=>{s.name.startsWith(".")?l(null):s.isFile?s.file(r=>{const o=!n.length||n.some(a=>{const[c,u]=a.split("/");return u==="*"?r.type.split("/")[0]===c:r.type===a});l(o?r:null)},()=>{l(null)}):s.createReader().readEntries(r=>{l(Promise.all(r.map(i)))})});return(await Promise.all([...t].map(s=>i(s.webkitGetAsEntry())))).flat(1e5).filter(Boolean).sort((s,l)=>s.name.localeCompare(l.name))},fL=async t=>{const e=new FileReader;return new Promise(n=>{e.onload=()=>{n(e.result.replace(/\r\n/g,`
223
+ `,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const n=ca(e),i=Nl(n);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i}]}}case"map-value-ind":{this.onKeyLine=!0;const n=ca(e),i=Nl(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function jw(t){const e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Rw||null,prettyErrors:e}}function xA(t,e={}){const{lineCounter:n,prettyErrors:i}=jw(e),s=new ih(n?.addNewLine),l=new nh(e),r=Array.from(l.compose(s.parse(t)));if(i&&n)for(const o of r)o.errors.forEach(Ha(t,n)),o.warnings.forEach(Ha(t,n));return r.length>0?r:Object.assign([],{empty:!0},l.streamInfo())}function Fw(t,e={}){const{lineCounter:n,prettyErrors:i}=jw(e),s=new ih(n?.addNewLine),l=new nh(e);let r=null;for(const o of l.compose(s.parse(t),!0,t.length))if(!r)r=o;else if(r.options.logLevel!=="silent"){r.errors.push(new Ks(o.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(r.errors.forEach(Ha(t,n)),r.warnings.forEach(Ha(t,n))),r}function eL(t,e,n){let i;typeof e=="function"?i=e:n===void 0&&e&&typeof e=="object"&&(n=e);const s=Fw(t,n);if(!s)return null;if(s.warnings.forEach(l=>rw(s.options.logLevel,l)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:i},n))}function tL(t,e,n){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){const s=Math.round(n);n=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){const{keepUndefined:s}=n??e??{};if(!s)return}return new Nr(t,i,n).toString(n)}const fr=Object.freeze(Object.defineProperty({__proto__:null,Alias:Dc,CST:XA,Composer:nh,Document:Nr,Lexer:Mw,LineCounter:Rw,Pair:dn,Parser:ih,Scalar:xe,Schema:Vc,YAMLError:eh,YAMLMap:Rn,YAMLParseError:Ks,YAMLSeq:Ps,YAMLWarning:Ew,isAlias:dl,isCollection:Ft,isDocument:Er,isMap:Tr,isNode:qt,isPair:Dt,isScalar:At,isSeq:Ar,parse:eL,parseAllDocuments:xA,parseDocument:Fw,stringify:tL,visit:$s,visitAsync:Cc},Symbol.toStringTag,{value:"Module"}));function Bw(t){return t&&t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Uw(t){return t}function ls(t,e){e=e||{};const n=e.delimiter||".",i=e.maxDepth,s=e.transformKey||Uw,l={};function r(o,a,c){c=c||1,Object.keys(o).forEach(function(u){const f=o[u],d=e.safe&&Array.isArray(f),h=Object.prototype.toString.call(f),m=Bw(f),b=h==="[object Object]"||h==="[object Array]",g=a?a+n+s(u):s(u);if(!d&&!m&&b&&Object.keys(f).length&&(!e.maxDepth||c<i))return r(f,g,c+1);l[g]=f})}return r(t),l}function al(t,e){e=e||{};const n=e.delimiter||".",i=e.overwrite||!1,s=e.transformKey||Uw,l={};if(Bw(t)||Object.prototype.toString.call(t)!=="[object Object]")return t;function o(u){const f=Number(u);return isNaN(f)||u.indexOf(".")!==-1||e.object?u:f}function a(u,f,d){return Object.keys(d).reduce(function(h,m){return h[u+n+m]=d[m],h},f)}function c(u){const f=Object.prototype.toString.call(u),d=f==="[object Array]",h=f==="[object Object]";if(u){if(d)return!u.length;if(h)return!Object.keys(u).length}else return!0}return t=Object.keys(t).reduce(function(u,f){const d=Object.prototype.toString.call(t[f]);return!(d==="[object Object]"||d==="[object Array]")||c(t[f])?(u[f]=t[f],u):a(f,u,ls(t[f],e))},{}),Object.keys(t).forEach(function(u){const f=u.split(n).map(s);let d=o(f.shift()),h=o(f[0]),m=l;for(;h!==void 0;){if(d==="__proto__")return;const b=Object.prototype.toString.call(m[d]),g=b==="[object Object]"||b==="[object Array]";if(!i&&!g&&typeof m[d]<"u")return;(i&&!g||!i&&m[d]==null)&&(m[d]=typeof h=="number"&&!e.object?[]:{}),m=m[d],f.length>0&&(d=o(f.shift()),h=o(f[0]))}m[d]=al(t[u],e)}),l}const Ya=(t,e,{ellipsis:n="…"}={})=>{const i=[...t];return`${i.slice(0,e).join("").trim()}${i.length>e?n:""}`},Ht=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Es=t=>t.replace(/^\/+/,"").replace(/\/+$/,""),Zs=()=>window.crypto.randomUUID(),ag=t=>t.match(/{{.+?}}/)?t:`{{${t}}}`,sh=(t,e,n)=>{const i=e.value_field,s=e.display_fields,l=ag(i),r=(s??[i]).map(ag).join(" ");return n.map(o=>{const{content:a}=o?.locales[t]??{};if(!a)return;const c=ls(a),u=Object.fromEntries([...new Set([...[...r.matchAll(/{{(.+?)}}/g)].map(m=>m[1]),...[...l.matchAll(/{{(.+?)}}/g)].map(m=>m[1])].map(m=>m.includes(".")?m.replace(/^([^.]+)+\.\*\.[^.]+$/,"$1.*"):m))].map(m=>{if(m.endsWith(".*")){const w=new RegExp(`^${Ht(m).replace("\\.\\*","\\.\\d+\\.[^.]+")}$`),k=al(Object.fromEntries(Object.entries(c).filter(([E])=>!!E.match(w))));return[m,k[Object.keys(k)[0]]??""]}if(m==="slug")return[m,o.slug];const b=Wn({collectionName:e.collection,keyPath:m}),g=m.replace(/^fields\./,""),v=c[g];return b?.widget==="relation"?[m,lh({fieldConfig:b,valueMap:c,keyPath:g,locale:t})??""]:[m,v??""]})),f=Math.max(...Object.values(u).map(m=>Array.isArray(m)?m.length:1));let d=new Array(f).fill(r),h=new Array(f).fill(l);return Object.entries(u).forEach(([m,b])=>{Array.isArray(b)?b.forEach((g,v)=>{Object.entries(g).forEach(([w,k])=>{d.forEach((E,N)=>{v%N===0&&(d[v]=d[v].replaceAll(`{{${m}.${w}}}`,k),h[v]=h[v].replaceAll(`{{${m}.${w}}}`,k))})})}):(d=d.map(g=>g.replaceAll(`{{${m}}}`,b)),h=h.map(g=>g.replaceAll(`{{${m}}}`,b)))}),d.map((m,b)=>({label:m,value:h[b]}))}).flat(1).filter(Boolean).sort((o,a)=>o.label.localeCompare(a.label))},lh=({fieldConfig:t,valueMap:e,keyPath:n,locale:i})=>{const{multiple:s,collection:l}=t,r=qo(l),o=sh(i,t,r),a=c=>o.find(u=>u.value===c)?.label||c;return s?Object.entries(e).filter(([u])=>u.match(`^${Ht(n)}\\.\\d+$`)).map(([,u])=>u).map(a):a(e[n])},pi=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),qw=t=>Array.isArray(t)&&t.every(e=>pi(e)),Hw=(t=1e3)=>new Promise(e=>{window.setTimeout(()=>{e()},t)}),nL=({fieldConfig:t,valueMap:e,keyPath:n})=>{const{multiple:i,options:s}=t,l=qw(s),r=a=>s.find(c=>c.value===a)?.label||a;if(i){const a=Object.entries(e).filter(([c])=>c.match(`^${Ht(n)}\\.\\d+$`)).map(([,c])=>c);return l?a.map(r):a}const o=e[n];return l?r(o):o},Wn=({collectionName:t,fileName:e=void 0,valueMap:n={},keyPath:i})=>{const s=yi(t),l=e?s._fileMap[e]:void 0,{fields:r}=l??s,o=i.split(".");let a;return o.forEach((c,u)=>{if(u===0)a=r.find(({name:f})=>f===c);else if(a){const f=c.match(/^\d+$/),{field:d,fields:h,types:m,typeKey:b="type"}=a;d?a=d:h&&!f?a=h.find(({name:g})=>g===c):m&&f&&(a=m.find(({name:g})=>g===n[`${o.slice(0,u).join(".")}.${c}.${b}`]))}}),a},rh=({collectionName:t,fileName:e,valueMap:n,keyPath:i,locale:s})=>{const l=Wn({collectionName:t,fileName:e,valueMap:n,keyPath:i});let r=n[i];return l?.widget==="relation"&&(r=lh({fieldConfig:l,valueMap:n,keyPath:i,locale:s})),l?.widget==="select"&&(r=nL({fieldConfig:l,valueMap:n,keyPath:i})),r??""},dr=(t,e,n,{resolveRef:i=!0}={})=>{const{slug:s,locales:l,commitAuthor:{name:r,login:o,email:a}={},commitDate:c}=t;if(n==="slug")return s;if(n==="commit_author")return r||o||a;if(n==="commit_date")return c;const u=l[e]?.content;if(u===void 0)return;const f=n.includes(".")?ls(u):u;if(i){const d=Wn({collectionName:t.collectionName,keyPath:n});if(d?.widget==="relation")return lh({fieldConfig:d,valueMap:f,keyPath:n,locale:e})}return f[n]},Vw=(t,{relative:e=!1}={})=>{const{collectionName:n,locales:i}=t;return Object.values(i).map(({content:s})=>Object.entries(s).map(([l,r])=>{if(typeof r=="string"&&(!e||!r.match(/^[/@]/))&&["image","file"].includes(Wn({collectionName:n,keyPath:l})?.widget)){const o=Gw(r,t);if(o?.collectionName===n)return o}})).flat(1).filter((s,l,r)=>!!s&&r.indexOf(s)===l)},zs={i18nEnabled:!1,saveAllLocales:!0,locales:["_default"],defaultLocale:"_default",structure:"single_file"},cg=(t,e)=>{const n=re(vt);let i;pi(n?.i18n)&&(i=n.i18n,t?.i18n?(pi(t.i18n)&&Object.assign(i,t.i18n),e&&(e.i18n?pi(e.i18n)&&Object.assign(i,e.i18n):i=void 0)):i=void 0);const{structure:s="single_file",locales:l=[],default_locale:r=void 0,save_all_locales:o=!0}=i??{},a=!!l.length;return{i18nEnabled:a,saveAllLocales:o,locales:a?l:["_default"],defaultLocale:a?r&&l.includes(r)?r:l[0]:"_default",structure:e?"single_file":s}},js=t=>{let e;if(t!=="_default")try{[e]=Intl.getCanonicalLocales(t)}catch{}return e},qn=t=>{const e=js(t);try{return new Intl.DisplayNames(re(Jt),{type:"language"}).of(e)}catch{return t}},vo=Ye(!1),oh=Ye([]),si=Ye([]),Mt=Ye(),Ts=Ye([]),yi=t=>{const e=re(vt).collections.find(n=>n.name===t);if(e)return{...e,_fileMap:e.files?.length?Object.fromEntries(e.files.map(n=>[n.name,{...n,_i18n:cg(e,n)}])):void 0,_i18n:cg(e),_assetFolder:re(Hn).find(({collectionName:n})=>n===t)}},ah=(t,e)=>re(si).find(n=>n.collectionName===t&&n.fileName===e),qo=t=>{const e=yi(t);if(!e)return[];const{filter:n,_i18n:{defaultLocale:i}}=e;return re(si).filter(s=>s.collectionName===t&&(!n||dr(s,i,n.field)===n.value))},iL=async t=>{const e=t.replace(re(vt).site_url,""),n=re(si),i=await Promise.all(n.map(async s=>{const{locales:l,collectionName:r,fileName:o}=s;return(await Promise.all(Object.values(l).map(async({content:c})=>{const u=ls(c);return(await Promise.all(Object.entries(u).map(async([d,h])=>{const m=Wn({collectionName:r,fileName:o,valueMap:u,keyPath:d});return!m||!["image","file"].includes(m.widget)?!1:await Ho(h,s)===e}))).includes(!0)}))).includes(!0)}));return n.filter((s,l)=>i[l])};var sL=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var i,s,l;if(Array.isArray(e)){if(i=e.length,i!=n.length)return!1;for(s=i;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(l=Object.keys(e),i=l.length,i!==Object.keys(n).length)return!1;for(s=i;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,l[s]))return!1;for(s=i;s--!==0;){var r=l[s];if(!t(e[r],n[r]))return!1}return!0}return e!==e&&n!==n};const Cn=Nd(sL);class tn{static async set(e,n){window.localStorage.setItem(e,JSON.stringify(n))}static async get(e){return JSON.parse(window.localStorage.getItem(e))}static async delete(e){window.localStorage.removeItem(e)}static async clear(){window.localStorage.clear()}static async keys(){return Object.keys(window.localStorage)}static async values(){return Object.values(window.localStorage).map(e=>JSON.parse(e))}static async entries(){return Object.entries(window.localStorage).map(([e,n])=>[e,JSON.parse(n)])}}const Ff="sveltia-cms.prefs",bt=Ye({},t=>{(async()=>{try{const e=await tn.get(Ff)??{};e.apiKeys??={},t(e)}catch{t({error:"permission_denied"})}})()});bt.subscribe(async t=>{if(!t||t.error||!Object.keys(t).length)return;try{Cn(t,await tn.get(Ff))||await tn.set(Ff,t)}catch{}const{locale:e,theme:n,devModeEnabled:i=!1}=t;e&&re(kv).includes(e)&&Jt.set(e);const s=!n||n==="auto",l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";Object.assign(document.documentElement.dataset,{theme:s?l:n,autoTheming:s,env:i?"dev":"prod"})});var lL={BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const vt=Ye(),{DEV:rL,VITE_SITE_URL:oL}=lL,aL=t=>{if(!pi(t))throw new Error(re(me)("config.error.parse_failed"));if(!t.collections?.length)throw new Error(re(me)("config.error.no_collection"));if(!t.backend?.name)throw new Error(re(me)("config.error.no_backend"));if(!(t.backend.name in uy))throw new Error(re(me)("config.error.unsupported_backend",{values:{name:t.backend.name}}));if(!t.media_folder)throw new Error(re(me)("config.error.no_media_folder"))},cL=async()=>{const{href:t="./config.yml"}=document.querySelector('link[type="text/yaml"][rel="cms-config-url"]')??{};let e,n;try{try{e=await fetch(t)}catch{throw new Error(re(me)("config.error.fetch_failed"))}if(!e.ok)throw new Error(re(me)("config.error.fetch_failed"));try{n=fr.parse(await e.text())}catch{throw new Error(re(me)("config.error.parse_failed"))}aL(n),rL&&!n.site_url&&(n.site_url=oL||"http://localhost:5174"),vt.set(n)}catch(i){vt.set({error:i.name==="Error"?i.message:re(me)("config.error.unexpected")}),console.error(i)}};vt.subscribe(t=>{if(re(bt).devModeEnabled&&console.info("siteConfig",t),!t||t.error)return;const{media_folder:e,public_folder:n,collections:i}=t;Mt.set(yi(i[0].name));const s=[...i.filter(({folder:u})=>!!u).map(({name:u,folder:f,extension:d,format:h,frontmatter_delimiter:m,yaml_quote:b})=>({collectionName:u,folderPath:f,extension:d,format:h,frontmatterDelimiter:m,yamlQuote:b})).sort((u,f)=>u.folderPath.localeCompare(f.folderPath)),...i.filter(({files:u})=>!!u).map(({name:u,files:f,extension:d,format:h,frontmatter_delimiter:m,yaml_quote:b})=>f.map(({name:g,file:v})=>({collectionName:u,fileName:g,filePath:v,extension:d,format:h,frontmatterDelimiter:m,yamlQuote:b}))).flat(1).sort((u,f)=>u.filePath.localeCompare(f.filePath))],l=Es(e),r=n?`/${Es(n)}`.replace(/^\/@/,"@"):`/${l}`,o={collectionName:null,internalPath:l,publicPath:r,entryRelative:!1},a=i.map(u=>{const{name:f,folder:d,path:h,public_folder:m}=u;let{media_folder:b}=u;if(b===void 0){if(h===void 0)return null;b=""}b=b.replace("{{media_folder}}",l);const g=!b.startsWith("/");return{collectionName:f,internalPath:Es(g?d:b),publicPath:(m??b).replace("{{public_folder}}",r),entryRelative:g}}),c=[o,...a.filter(Boolean).sort((u,f)=>u.internalPath.localeCompare(f.internalPath))];oh.set(s),Hn.set(c),re(bt).devModeEnabled&&(console.info("allEntryFolders",s),console.info("allAssetFolders",c))});const uL=async({items:t},{accept:e}={})=>{const n=e?e.trim().split(/,\s*/g):[],i=s=>new Promise(l=>{s.name.startsWith(".")?l(null):s.isFile?s.file(r=>{const o=!n.length||n.some(a=>{const[c,u]=a.split("/");return u==="*"?r.type.split("/")[0]===c:r.type===a});l(o?r:null)},()=>{l(null)}):s.createReader().readEntries(r=>{l(Promise.all(r.map(i)))})});return(await Promise.all([...t].map(s=>i(s.webkitGetAsEntry())))).flat(1e5).filter(Boolean).sort((s,l)=>s.name.localeCompare(l.name))},fL=async t=>{const e=new FileReader;return new Promise(n=>{e.onload=()=>{n(e.result.replace(/\r\n/g,`
224
224
  `))},e.readAsText(t)})},dL=async t=>{const e=new FileReader;return new Promise(n=>{e.onload=()=>{n(e.result)},e.readAsArrayBuffer(t)})},Ga=async t=>{const e=await window.crypto.subtle.digest("SHA-1",await dL(t));return Array.from(new Uint8Array(e)).map(n=>n.toString(16).padStart(2,"0")).join("")},Yw=async t=>{const e=typeof t=="string"?new Blob([t],{type:"text/plain"}):t,n=new FileReader;return new Promise(i=>{n.onload=()=>{i(n.result)},n.readAsDataURL(e)})},hL=async t=>(await Yw(t)).split(",")[1],hr=t=>{const e=new Intl.NumberFormat(re(Jt)),n=1e3,i=n*1e3,s=i*1e3,l=s*1e3;return t<n?`${e.format(t)} bytes`:t<i?`${e.format(Number((t/n).toFixed(1)))} KB`:t<s?`${e.format(Number((t/i).toFixed(1)))} MB`:t<l?`${e.format(Number((t/s).toFixed(1)))} GB`:`${e.format(Number((t/l).toFixed(1)))} TB`},ch=(t,e)=>{if(!e.length)return t;const[,n,i]=t.match(/(.+?)(?:\.([a-zA-Z0-9]+?))?$/),s=new RegExp(`^${Ht(n)}(?:-(\\d+?))?${i?`\\.${i}`:""}$`),l=e.sort((r,o)=>r.split(".")[0].localeCompare(o.split(".")[0])).findLast(r=>r.match(s));return l?`${n}-${Number(l.match(s)[1]??0)+1}${i?`.${i}`:""}`:t},Bf=t=>t.filter(Boolean).join("/"),Uf=t=>{const e=t.split("/");let n=!1;return e.forEach((i,s)=>{if(i==="."||i===".."){if(n&&(e[s]=null,i==="..")){const l=e.findLastIndex((r,o)=>!!r&&o<s);l>-1&&(e[l]=null)}}else n=!0}),Bf(e)},pL=(t,e)=>{const n=e==="image",i=n?new Image:document.createElement(e);return new Promise(s=>{const l=()=>{s({dimensions:e==="audio"?void 0:{width:n?i.naturalWidth:i.videoWidth,height:n?i.naturalHeight:i.videoHeight},duration:n?void 0:i.duration})};i.addEventListener(n?"load":"loadedmetadata",l,{once:!0}),i.src=t})},ug=t=>new Date(t*1e3).toISOString().substr(11,8),fg=["image","video","audio","document","other"],qf={image:/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|tiff?|webp)$/i,video:/\.(?:avi|mp4|mpeg|ogv|ts|webm|3gp|3g2)$/i,audio:/\.(?:aac|midi?|mp3|opus|wav|weba)$/i,document:/\.(?:csv|docx?|odp|ods|odt|pdf|pptx?|rtf|xslx?)$/i},an=Ye([]),Hn=Ye([]),ni=Ye(),xs=Ye([]),Wa=Ye(),el=Ye(),zn=Ye({folder:void 0,files:[]}),mL=mn([zn],([t],e)=>{e(!!t.files?.length)}),uh=t=>Object.entries(qf).find(([,e])=>t.match(e))?.[0]??"other",Gw=(t,e)=>{if(!t.match(/^[/@]/)){if(!e)return;const{collectionName:l,fileName:r,locales:o}=e,a=yi(l),c=r?a._fileMap[r]:void 0,{defaultLocale:u}=(c??a)._i18n,f=u in o?u:Object.keys(o)[0],{path:d,content:h}=o[f];if(!d||!h)return;const[,m]=d.match(/(.+?)(?:\/[^/]+)?$/),b=Uf(`${m}/${t}`);return re(an).find(g=>g.path===b)}const[,n,i]=t.match(/(.+?)\/([^/]+)$/)??[];if(!n)return;const{internalPath:s}=re(Hn).findLast(l=>l.publicPath===n)??{};if(s)return re(an).find(l=>l.path===`${s}/${i}`)},wo=async(t,{pathOnly:e=!1}={})=>{if(!t)return;const n=t.url?.startsWith("blob:");if(n&&!e)return t.url;if(!t.url&&(t.file||t.fetchURL)&&!e){const o=URL.createObjectURL(t.file||await re(ri).fetchBlob(t));return an.update(a=>[...a.filter(({sha:c,path:u})=>!(c===t.sha&&u===t.path)),{...t,url:o}]),o}const{publicPath:i,entryRelative:s}=re(Hn).find(({collectionName:o})=>o===t.collectionName)||re(Hn).find(({collectionName:o})=>o===null);if(s)return n?t.url:void 0;const l=e?"":re(vt).site_url??"",r=t.path.replace(t.folder,i);return`${l}${r}`},Ho=async(t,e)=>{if(t)return t.match(/^(?:https?|data):/)?t:wo(Gw(t,e))},gL=async t=>{const{kind:e}=t,n=await wo(t);let i,s;return["image","video","audio"].includes(e)&&n&&({dimensions:i,duration:s}=await pL(n,e)),{displayURL:n,dimensions:i,duration:s,usedEntries:await iL(n)}};ni.subscribe(()=>{Wa.set(void 0)});const _L=async t=>{const{site_domain:e=document.domain,base_url:n="https://api.netlify.com",auth_endpoint:i="auth"}=re(vt).backend,s=600,l=800,{availHeight:r,availWidth:o}=window.screen,a=r/2-l/2,c=o/2-s/2,u=window.open(`${n}/${i}?provider=${t}&site_id=${e}&scope=repo`,"auth",`width=${s},height=${l},top=${a},left=${c}`);return new Promise(f=>{const d=({origin:h,data:m})=>{if(h!==n||typeof m!="string")return;if(m===`authorizing:${t}`){u.postMessage(m,h);return}const[,b,g]=m.match(`^authorization:${t}:(success|error):(.+)`)??[];let v;try{v=g?JSON.parse(g):void 0}catch{}f(b==="success"&&pi(v)&&typeof v.token=="string"?v.token:null),window.removeEventListener("message",d),u.close()};window.addEventListener("message",d)})},bL={create:"Create {{collection}} “{{slug}}”",update:"Update {{collection}} “{{slug}}”",delete:"Delete {{collection}} “{{slug}}”",uploadMedia:"Upload “{{path}}”",deleteMedia:"Delete “{{path}}”",openAuthoring:"{{message}}"},vL=(t,{commitType:e="update",collection:n,skipCI:i=void 0})=>{const{backend:{commit_messages:s={},automatic_deployments:l}}=re(vt),{login:r="",name:o=""}=re(Mi),[a=""]=t.map(h=>h.slug).filter(Boolean),[c,...u]=t.map(({path:h})=>h),f=n?.label_singular||n?.label||n?.name||"";let d=s[e]||bL[e]||"";return["create","update","delete"].includes(e)&&(d=d.replaceAll("{{slug}}",a).replaceAll("{{collection}}",f).replaceAll("{{path}}",c).replaceAll("{{author-login}}",r).replaceAll("{{author-name}}",o)),["uploadMedia","deleteMedia"].includes(e)&&(d=d.replaceAll("{{path}}",c).replaceAll("{{author-login}}",r).replaceAll("{{author-name}}",o),u.length&&(d+=` +${u.length}`)),["openAuthoring"].includes(e)&&(d=d.replaceAll("{{message}}",e).replaceAll("{{author-login}}",r).replaceAll("{{author-name}}",o)),!["delete","deleteMedia"].includes(e)&&(i===void 0?l===!1:i===!0)&&(d=`[skip ci] ${d}`),d},wL="1.38.0",ze=SyntaxError,Xt=RangeError,Je=TypeError,rn=Error,kn=void 0,rs=typeof BigInt>"u"?kn:BigInt,fh=RegExp,dh=WeakMap,Ww=WeakMap.prototype.get,Kw=WeakMap.prototype.set,Bn=Object.create,Vl=Number.isSafeInteger,Yi=Object.getOwnPropertyNames,Vn=Object.freeze,Zw=Object.prototype.isPrototypeOf,Pn=Object.seal?Object.preventExtensions(Object.create(null)):null,pr=Function.prototype.bind,dg=RegExp.prototype.test,hg=RegExp.prototype.exec,hh=Reflect.apply,Hf=Proxy,pg=typeof Symbol>"u"?kn:Symbol.toStringTag,Xw=Object.defineProperty,As=Object.assign,ph=Object,kL=Math.floor,tl=Array.isArray,mr=1/0,mh=String.fromCharCode,Ka=Array,ua=Object.prototype.hasOwnProperty,mg=Object.prototype.propertyIsEnumerable,Is=Function.prototype.apply;var Jw=mg.call.bind(mg),ps=ph.hasOwn||function(){return ua.bind?ua.call.bind(ua):function(e,n){return ua.call(e,n)}}(),Qw=ph.create;function gg(t){var e=Qw(Pn);return ps(t,"value")&&(e.value=t.value),ps(t,"writable")&&(e.writable=t.writable),ps(t,"get")&&(e.get=t.get),ps(t,"set")&&(e.set=t.set),ps(t,"enumerable")&&(e.enumerable=t.enumerable),ps(t,"configurable")&&(e.configurable=t.configurable),e}const yL=function(e,n){if(!n&&typeof e!="function"&&(n=e,e=Bn(Pn)),As)As(e,n);else for(var i in n)ps(n,i)&&(e[i]=n[i]);if(e.default=e,typeof e=="function")e.prototype&&Vn(e.prototype);else if(pg){var s=Bn(Pn);s.value="Module",Xw(e,pg,s)}return Vn(e)};/*!@preserve@license
225
225
  * 模块名称:j-regexp
226
226
  * 模块功能:可读性更好的正则表达式创建方式。从属于“简计划”。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltia/cms",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {