import{F as b,g as p,b as M}from"./dav-D-0Zsvk_.chunk.mjs";import{g as F}from"./index-CxUc7fso.chunk.mjs";const d=Object.freeze({ReservedName:"reserved name",Character:"character",Extension:"extension"});class f extends Error{constructor(n){super(`Invalid ${n.reason} '${n.segment}' in filename '${n.filename}'`,{cause:n})}get filename(){return this.cause.filename}get reason(){return this.cause.reason}get segment(){return this.cause.segment}}function O(t){const n=F().files,s=n.forbidden_filename_characters??["/","\\"];for(const e of s)if(t.includes(e))throw new f({segment:e,reason:d.Character,filename:t});if(t=t.toLocaleLowerCase(),(n.forbidden_filenames??[".htaccess"]).includes(t))throw new f({filename:t,segment:t,reason:d.ReservedName});const r=t.indexOf(".",1),o=t.substring(0,r===-1?void 0:r);if((n.forbidden_filename_basenames??[]).includes(o))throw new f({filename:t,segment:o,reason:d.ReservedName});const a=n.forbidden_filename_extensions??[];for(const e of a)if(t.length>e.length&&t.endsWith(e))throw new f({segment:e,reason:d.Extension,filename:t})}const m=["B","KB","MB","GB","TB","PB"],l=["B","KiB","MiB","GiB","TiB","PiB"];function w(t,n=!1,s=!1,r=!1){s=s&&!r,typeof t=="string"&&(t=Number(t));let o=t>0?Math.floor(Math.log(t)/Math.log(r?1e3:1024)):0;o=Math.min((s?l.length:m.length)-1,o);const a=s?l[o]:m[o];let e=(t/Math.pow(r?1e3:1024,o)).toFixed(1);return n===!0&&o===0?(e!=="0.0"?"< 1 ":"0 ")+(s?l[1]:m[1]):(o<2?e=parseFloat(e).toFixed(0):e=parseFloat(e).toLocaleString(M()),e+" "+a)}function h(t){return t instanceof Date?t.toISOString():String(t)}function B(t,n,s){n=n??[a=>a],s=s??[];const r=n.map((a,e)=>(s[e]??"asc")==="asc"?1:-1),o=Intl.Collator([p(),M()],{numeric:!0,usage:"sort"});return[...t].sort((a,e)=>{for(const[i,g]of n.entries()){const u=o.compare(h(g(a)),h(g(e)));if(u!==0)return u*r[i]}return 0})}const c=Object.freeze({Name:"basename",Modified:"mtime",Size:"size"});function N(t,n={}){const s={sortingMode:c.Name,sortingOrder:"asc",...n};function r(e){const i=e.displayname||e.attributes?.displayname||e.basename||"";return e.type===b.Folder?i:i.lastIndexOf(".")>0?i.slice(0,i.lastIndexOf(".")):i}const o=[...s.sortFavoritesFirst?[e=>e.attributes?.favorite!==1]:[],...s.sortFoldersFirst?[e=>e.type!=="folder"]:[],...s.sortingMode!==c.Name?[e=>e[s.sortingMode]??e.attributes[s.sortingMode]]:[],e=>r(e),e=>e.basename],a=[...s.sortFavoritesFirst?["asc"]:[],...s.sortFoldersFirst?["asc"]:[],...s.sortingMode===c.Modified?[s.sortingOrder==="asc"?"desc":"asc"]:[],...s.sortingMode!==c.Modified&&s.sortingMode!==c.Name?[s.sortingOrder]:[],s.sortingOrder,s.sortingOrder];return B(t,o,a)}export{f as I,d as a,w as f,N as s,O as v};
//# sourceMappingURL=index-DxP0KQWI.chunk.mjs.map
