import{g as K}from"./asset.js";import{r as v,u as S,b as c,d as G,o as D,k as j,w as n,f as a,g as b,t as d,h as q,e as z,i as p,J,z as Y,K as F,j as k,q as H,A as m,n as l}from"./index.js";import{U as Q,D as W}from"./constants.js";import{_ as X}from"./_plugin-vue_export-helper.js";const Z=["element-loading-text","element-loading-background"],ee={style:{display:"flex","align-items":"center"}},te=["src"],oe={style:{"margin-left":"10px"}},ne={__name:"ChooseDirModal",emits:["choose"],setup(ae,{expose:x,emit:O}){const _=v(!1),r=v(!0),{t:s}=S({useScope:"global"}),g=v("/");let i="/";const y=v([]),$=O;function h(e){r.value=!0,m.post("service_get_dir_list.html",`dir=${encodeURIComponent(e)}`).then(({data:{code:t,data:o,error:u}})=>{t==0&&(y.value=[],o.dirs.forEach(C=>{y.value.push({name:C})}),g.value=o.nowdir,i=o.nowdir),t==-1&&(l({message:u,grouping:!0,type:"error"}),m.logout())}).catch(t=>{l({message:t.message,grouping:!0,type:"error"})}).finally(()=>{r.value=!1})}function A(e){if(e){let t=i==="/"?e.name:i+"/"+e.name;h(t)}}function B(e,t){let o=e.name.toLowerCase(),u=t.name.toLowerCase();return o<u?-1:o>u?1:0}function U(){var e=i.substring(0,i.lastIndexOf("/"));e.lastIndexOf("/")===-1&&(e="/"),h(e)}function w(){h(i)}function V(){H.prompt(s("title_directory"),s("title_mkdir"),{confirmButtonText:s("button_submit"),cancelButtonText:s("button_cancel"),inputPattern:/^[^\\\/\<\>\:\?\"\|\*]+$/,inputErrorMessage:s("error_bad_filename")}).then(({value:e})=>{r.value=!0,m.post("service_make_dir.html","dir="+encodeURIComponent(e)).then(({data:{code:t,error:o}})=>{t==0?w():t==-1?(l({message:o,grouping:!0,type:"error"}),m.logout()):l({message:o,grouping:!0,type:"error"})}).catch(t=>{l({message:t.message,grouping:!0,type:"error"})}).finally(()=>{r.value=!1})})}function E(){r.value=!0,m.post("service_check_dir.html","dir="+encodeURIComponent(g.value)).then(({data:{code:e,error:t}})=>{e==0?($("choose",g.value),_.value=!1):e==-1?(l({message:t,grouping:!0,type:"error"}),m.logout()):l({message:s("error_invalid_dir"),grouping:!0,type:"error"})}).catch(e=>{l({message:e.message,grouping:!0,type:"error"})}).finally(()=>{r.value=!1})}function I(){_.value=!1}function R(){h()}function L(){_.value=!0}return x({show:L}),(e,t)=>{const o=c("el-button"),u=c("el-row"),C=c("el-table-column"),M=c("el-table"),N=c("el-input"),P=c("el-dialog"),T=G("loading");return D(),j(P,{title:e.$t("str_choosedir"),draggable:"","align-center":"","destroy-on-close":"",modelValue:_.value,"onUpdate:modelValue":t[1]||(t[1]=f=>_.value=f),class:"general_dialog","open-delay":p(W),onOpen:R},{footer:n(()=>[a(o,{type:"primary",class:"w-100px",onClick:E},{default:n(()=>[b(d(e.$t("button_submit")),1)]),_:1}),a(o,{type:"primary",class:"w-100px",onClick:I},{default:n(()=>[b(d(e.$t("button_cancel")),1)]),_:1})]),default:n(()=>[q((D(),z("div",{"element-loading-text":e.$t("title_updating"),"element-loading-background":p(Q)},[a(u,null,{default:n(()=>[a(o,{type:"button",class:"btn btn-primary mb-10",icon:p(J),onClick:U},{default:n(()=>[b(d(e.$t("title_goup")),1)]),_:1},8,["icon"]),a(o,{type:"button",class:"btn btn-primary",icon:p(Y),onClick:w},{default:n(()=>[b(d(e.$t("title_refresh")),1)]),_:1},8,["icon"]),a(o,{type:"button",class:"btn btn-primary",icon:p(F),onClick:V},{default:n(()=>[b(d(e.$t("title_mkdir")),1)]),_:1},8,["icon"])]),_:1}),a(M,{data:y.value,border:"","default-sort":{prop:"name",order:"ascending"},class:"dir_table mb-10","highlight-current-row":"",onRowClick:A},{default:n(()=>[a(C,{label:e.$t("title_name"),prop:"name",sortable:"","sort-orders":["ascending","descending"],"sort-method":B,min_width:100},{default:n(f=>[k("div",ee,[k("img",{src:p(K)("images/folder.png")},null,8,te),k("span",oe,d(f.row.name),1)])]),_:1},8,["label"])]),_:1},8,["data"]),a(N,{modelValue:g.value,"onUpdate:modelValue":t[0]||(t[0]=f=>g.value=f),type:"text",placeholder:""},null,8,["modelValue"])],8,Z)),[[T,r.value]])]),_:1},8,["title","modelValue","open-delay"])}}},ue=X(ne,[["__scopeId","data-v-0f34b914"]]);export{ue as C};
