import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{$P as t,Jv as n,Uh as r}from"./lucide-C4oWPzu4.js";import{p as i}from"./utils-Bs-0X7qI.js";import{r as a}from"./bundle-mjs-C4g7ASB5.js";import"./react-dom-DA2kpOcl.js";import{n as o}from"./dist-Cw-z5Xb0.js";import"./useMutation-YNiikd7W.js";import{i as s}from"./shared-DtQmrU00.js";import"./label-D4DLXoEs.js";import{t as c}from"./button-B-NlEi4h.js";import"./textarea-BJ2TI6HZ.js";import{t as l}from"./input-DcxjhZaU.js";import"./status-codes.constant-BV2w9Io6.js";import{r as u,t as d}from"./card-BgiZuEPo.js";import{a as f,f as p,i as m,n as h,o as g,r as _,t as v}from"./form-CVrsvflM.js";import{C as y,T as b}from"./console-BA0IzvI-.js";import{t as x}from"./permission-guard-C-WT75tf.js";var S=i(),C=e(t(),1),w=a(),T=e=>{let t=(0,S.c)(36),{configId:i}=e,a=!!i,l;t[0]===a?l=t[1]:(l={enabled:a},t[0]=a,t[1]=l);let{data:f,isLoading:h,refetch:g}=y(i,l),_;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_={defaultValues:{localStorage:``,domain:``}},t[2]=_):_=t[2];let T=p(_),A,j;t[3]!==f||t[4]!==T?(A=()=>{f?.config&&T.reset({localStorage:f.config.localStorage??``,domain:f.config.domain??``})},j=[f,T],t[3]=f,t[4]=T,t[5]=A,t[6]=j):(A=t[5],j=t[6]),(0,C.useEffect)(A,j);let M;t[7]===g?M=t[8]:(M={onSuccess:()=>{s(),o.success(`已切换为本地存储`),g()},onError:E},t[7]=g,t[8]=M);let N=b(M),P=D,F;t[9]!==i||t[10]!==N?(F=()=>{if(!i){o.error(`未找到本地存储配置记录`);return}N.mutate({id:i,dto:{isActive:!0,storageType:`local`,config:null}})},t[9]=i,t[10]=N,t[11]=F):F=t[11];let I=F;if(!i||h){let e;return t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,w.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,w.jsx)(r,{className:`text-muted-foreground size-8 animate-spin`})}),t[12]=e):e=t[12],e}let L;t[13]===T?L=t[14]:(L=T.handleSubmit(P),t[13]=T,t[14]=L);let R;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,w.jsx)(`div`,{className:`bg-muted flex h-10 w-10 items-center justify-center rounded-full`,children:(0,w.jsx)(n,{className:`text-primary size-5`})}),t[15]=R):R=t[15];let z;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[R,(0,w.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,w.jsx)(`span`,{className:`text-sm font-medium`,children:`本地存储`})})]}),t[16]=z):z=t[16];let B=f?.isActive?`outline`:`default`,V=f?.isActive||N.isPending,H;t[17]===N.isPending?H=t[18]:(H=N.isPending&&(0,w.jsx)(r,{className:`mr-2 size-4 animate-spin`}),t[17]=N.isPending,t[18]=H);let U=f?.isActive?`已启用`:`启用`,W;t[19]!==I||t[20]!==B||t[21]!==V||t[22]!==H||t[23]!==U?(W=(0,w.jsx)(d,{children:(0,w.jsxs)(u,{className:`flex items-center justify-between gap-4`,children:[z,(0,w.jsx)(x,{permissions:`system-storage-config:set`,children:(0,w.jsxs)(c,{type:`button`,size:`sm`,variant:B,disabled:V,onClick:I,children:[H,U]})})]})}),t[19]=I,t[20]=B,t[21]=V,t[22]=H,t[23]=U,t[24]=W):W=t[24];let G,K;t[25]===T.control?(G=t[26],K=t[27]):(G=(0,w.jsx)(m,{control:T.control,name:`localStorage`,render:O}),K=(0,w.jsx)(m,{control:T.control,name:`domain`,render:k}),t[25]=T.control,t[26]=G,t[27]=K);let q;t[28]!==W||t[29]!==G||t[30]!==K||t[31]!==L?(q=(0,w.jsxs)(`form`,{onSubmit:L,className:`space-y-6`,children:[W,G,K]}),t[28]=W,t[29]=G,t[30]=K,t[31]=L,t[32]=q):q=t[32];let J;return t[33]!==T||t[34]!==q?(J=(0,w.jsx)(v,{...T,children:q}),t[33]=T,t[34]=q,t[35]=J):J=t[35],J};function E(e){console.log(`切换失败: ${e.message}`)}function D(e){}function O(e){let{field:t}=e;return(0,w.jsxs)(f,{children:[(0,w.jsx)(g,{children:`本地存储路径`}),(0,w.jsx)(h,{children:(0,w.jsx)(l,{...t,disabled:!0})}),(0,w.jsx)(_,{children:`系统文件存放的绝对路径或相对路径`})]})}function k(e){let{field:t}=e;return(0,w.jsxs)(f,{children:[(0,w.jsx)(g,{children:`访问域名（URL）`}),(0,w.jsx)(h,{children:(0,w.jsx)(l,{...t,disabled:!0})}),(0,w.jsx)(_,{children:`外部访问附件时使用的基础 URL`})]})}export{T as default};