1import{n as e}from"./pinia-YL0TXNFu.js";import{t}from"./axios-CenCkXay.js";import{T as n,rt as r}from"./maintenance-service-B-yNArdO.js";function i(){function e(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}return e}var a=i();function o(e){return e.webkitGetAsEntry?.()??e.getAsEntry?.()??null}function s(e){for(let t=0;t<e.length;t++)if(o(e[t])?.isDirectory)return!0;return!1}function c(e){let t=e.createReader(),n=[];function r(){return new Promise((e,i)=>{t.readEntries(t=>{if(t.length===0){e(n);return}n.push(...t),r().then(e).catch(i)},i)})}return r()}function l(e){return new Promise((t,n)=>e.file(t,n))}function u(e,t,r){let i=r.find(t=>t.title.toLowerCase()===e.toLowerCase());return i===void 0?n.createAlbum({title:e,parent_id:t}).then(e=>({id:e.data,existed:!1})):Promise.resolve({id:i.id,existed:!0})}async function d(e){let t=[],r=1,i;do{let a=await n.getAlbums(e,r);t.push(...a.data.data.map(e=>({id:e.id,title:e.title}))),i=a.data.last_page,r++}while(r<=i);return t}function f(e,t,n,r,i,o,s){return o>0&&i>o?Promise.resolve(!1):u(e.name,t,n).then(({id:t,existed:n})=>{let u=n?d(t):Promise.resolve([]);return Promise.all([c(e),u]).then(([n,c])=>{let u=n.filter(e=>e.isFile),d=n.filter(e=>e.isDirectory),p=u.map(n=>l(n).then(n=>{r.value.push({uid:a(),file:n,album_id:t,albumTitle:e.name,status:`waiting`})})),m=d.map(e=>f(e,t,c,r,i+1,o,s));return Promise.allSettled([...p,...m]).then(e=>(e.forEach(e=>{e.status===`rejected`&&s(String(e.reason))}),u.length>0||d.length>0))})}).catch(t=>(s(`Failed to create album "${e.name}": ${String(t)}`),!1))}function p(e,t,n,r,i,s){let c=[],u=[];for(let t=0;t<e.length;t++){let n=o(e[t]);n!==null&&(n.isDirectory?c.push(n):n.isFile&&u.push(n))}let d=u.map(e=>l(e).then(e=>{r.value.push({uid:a(),file:e,status:`waiting`})})),p=c.map(e=>f(e,t,n,r,1,i,s));return Promise.allSettled([...d,...p]).then(e=>(e.forEach(e=>{e.status===`rejected`&&s(String(e.reason))}),r.value.length>0))}var m={getOptions(){return t.get(`${r.getApiUrl()}Import`,{data:{}})},importFromServer(e){return t.post(`${r.getApiUrl()}Import`,e)},browse(e){return t.get(`${r.getApiUrl()}Import::browse`,{params:{directory:e},data:{}})}},h=e(`import-store`,{state:()=>({options:void 0,directory:``}),actions:{refresh(){return this.reset(),this.load()},reset(){this.options=void 0,this.directory=``},load(){return this.options===void 0?m.getOptions().then(e=>{this.options=e.data,this.directory=e.data.directory}):Promise.resolve()}}});
1export{i as a,s as i,m as n,p as r,h as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.