(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{6545:(e,t,r)=>{Promise.resolve().then(r.bind(r,9160))},9160:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>S});var s=r(2432),a=r(364),n=r(4328),l=r(6992),o=r(2126),c=r(8441);function i(e,t,r,s){let a="".concat(e,"/download?xtlink=").concat(encodeURIComponent(t),"&file_id=").concat(encodeURIComponent(r));return s&&(a+="&password=".concat(encodeURIComponent(s))),a}function d(){for(var e=arguments.length,t=Array(e),r=0;r{let{className:r,variant:a,size:l,asChild:o=!1,...c}=e,i=o?n.DX:"button";return(0,s.jsx)(i,{className:d(u({variant:a,size:l,className:r})),ref:t,...c})});m.displayName="Button";let x=a.forwardRef((e,t)=>{let{className:r,type:a,...n}=e;return(0,s.jsx)("input",{type:a,className:d("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:t,...n})});x.displayName="Input";var f=r(7378);let h=(0,l.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),p=a.forwardRef((e,t)=>{let{className:r,...a}=e;return(0,s.jsx)(f.b,{ref:t,className:d(h(),r),...a})});p.displayName=f.b.displayName;let g=(0,l.F)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),b=a.forwardRef((e,t)=>{let{className:r,variant:a,...n}=e;return(0,s.jsx)("div",{ref:t,role:"alert",className:d(g({variant:a}),r),...n})});b.displayName="Alert",a.forwardRef((e,t)=>{let{className:r,...a}=e;return(0,s.jsx)("h5",{ref:t,className:d("mb-1 font-medium leading-none tracking-tight",r),...a})}).displayName="AlertTitle";let v=a.forwardRef((e,t)=>{let{className:r,...a}=e;return(0,s.jsx)("div",{ref:t,className:d("text-sm [&_p]:leading-relaxed",r),...a})});v.displayName="AlertDescription";let y="https://aqwmvepklmfy.ap-northeast-1.clawcloudrun.com";async function w(){try{let e=await fetch("".concat(y,"/login"),{method:"GET",cache:"no-store"});if(!e.ok)throw Error("API 请求失败: ".concat(e.status));return await e.json()}catch(e){return console.error("检查登录状态时出错:",e),!1}}async function j(e){try{let t=await fetch("".concat(y,"/login?password=").concat(encodeURIComponent(e)),{method:"GET",cache:"no-store"});if(!t.ok)throw Error("API 请求失败: ".concat(t.status));return await t.json()}catch(e){return console.error("验证密码时出错:",e),!1}}async function N(e,t){try{let r="".concat(y,"/download_info?xtlink=").concat(encodeURIComponent(e));t&&(r+="&password=".concat(encodeURIComponent(t)));let s=await fetch(r,{method:"GET",cache:"no-store"});if(!s.ok)throw Error("API 请求失败: ".concat(s.status));return await s.json()}catch(e){return console.error("获取文件列表时出错:",e),[]}}function k(e){let{onLoginSuccess:t}=e,[r,n]=(0,a.useState)(""),[l,o]=(0,a.useState)(null),[c,i]=(0,a.useState)(!1),d=async e=>{if(e.preventDefault(),!r.trim()){o("请输入密码");return}try{i(!0),o(null),await j(r)?t(r):o("密码错误,请重试")}catch(e){o("验证过程中出现错误,请重试"),console.error("验证密码时出错:",e)}finally{i(!1)}};return(0,s.jsxs)("div",{className:"mx-auto w-full max-w-md rounded-lg border p-6 shadow-md",children:[(0,s.jsx)("h2",{className:"mb-4 text-xl font-bold",children:"登录"}),(0,s.jsx)("p",{className:"mb-6 text-sm text-gray-500",children:"请输入密码以继续访问城通网盘解析工具"}),l&&(0,s.jsx)(b,{variant:"destructive",className:"mb-4",children:(0,s.jsx)(v,{children:l})}),(0,s.jsxs)("form",{onSubmit:d,className:"space-y-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(p,{htmlFor:"password",children:"密码"}),(0,s.jsx)(x,{id:"password",type:"password",value:r,onChange:e=>n(e.target.value),placeholder:"请输入密码",disabled:c})]}),(0,s.jsx)(m,{type:"submit",className:"w-full",disabled:c,children:c?"验证中...":"登录"})]})]})}function _(e){let{onSubmit:t,password:r}=e,[n,l]=(0,a.useState)(""),[o,c]=(0,a.useState)(null),[i,d]=(0,a.useState)(!1),u=async e=>{if(e.preventDefault(),!n.trim()){c("请输入城通网盘链接");return}let s=n.trim();s.startsWith("ctfile://")&&(s=s.substring(9));try{d(!0),c(null);let e=await N(s,r);e&&e.length>0?t(s,e):c("未找到文件或链接无效")}catch(e){c("获取文件列表失败,请检查链接是否正确"),console.error("获取文件列表时出错:",e)}finally{d(!1)}};return(0,s.jsxs)("div",{className:"rounded-lg border p-4 shadow-sm",children:[(0,s.jsx)("h2",{className:"mb-4 text-lg font-medium",children:"输入城通网盘链接"}),o&&(0,s.jsx)(b,{variant:"destructive",className:"mb-4",children:(0,s.jsx)(v,{children:o})}),(0,s.jsxs)("form",{onSubmit:u,className:"space-y-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(p,{htmlFor:"link",children:"链接"}),(0,s.jsx)(x,{id:"link",value:n,onChange:e=>l(e.target.value),placeholder:"请输入城通网盘链接,例如: ctfile://xxxxxx",disabled:i}),(0,s.jsx)("p",{className:"text-xs text-gray-500",children:"支持格式: ctfile://xxxxxx 或直接输入 xxxxxx"})]}),(0,s.jsx)(m,{type:"submit",className:"w-full",disabled:i,children:i?"解析中...":"解析链接"})]})]})}var C=r(3491),A=r(9392);function E(e){let{files:t,xtlink:r,password:n}=e,[l,o]=(0,a.useState)(null),[c,d]=(0,a.useState)(null),[u,m]=(0,a.useState)(!1),x=async e=>{if(navigator.clipboard&&window.isSecureContext)try{return await navigator.clipboard.writeText(e),!0}catch(e){console.warn("Clipboard API 失败,尝试降级方案",e)}try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",document.body.appendChild(t),t.focus(),t.select();let r=document.execCommand("copy");return document.body.removeChild(t),r}catch(e){return console.error("所有复制方法都失败了",e),!1}},f=async e=>{try{d(null);let t="https://aqwmvepklmfy.ap-northeast-1.clawcloudrun.com";if(!t)throw Error("API URL 未配置,请检查环境变量");let s=i(t,r,e.key,n);if(!await x(s))throw Error("复制失败");o(e.key),setTimeout(()=>{o(null)},3e3)}catch(e){d("复制链接失败,请手动复制"),console.error("复制链接时出错:",e)}},h=async()=>{try{d(null),m(!0);let e="https://aqwmvepklmfy.ap-northeast-1.clawcloudrun.com";if(!e)throw Error("API URL 未配置,请检查环境变量");let s=t.map(t=>({name:t.name,url:i(e,r,t.key,n)})).map(e=>"".concat(e.name,": ").concat(e.url)).join("\n\n");if(!await x(s))throw Error("复制失败");o("all"),setTimeout(()=>{o(null),m(!1)},3e3)}catch(e){d("批量复制链接失败"),console.error("批量复制链接时出错:",e),m(!1)}};return(0,s.jsxs)("div",{className:"rounded-lg border p-4 shadow-sm",children:[(0,s.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,s.jsx)("h2",{className:"text-lg font-medium",children:"文件列表"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"点击文件名复制下载链接"}),(0,s.jsx)("button",{onClick:e=>{e.stopPropagation(),h()},className:"flex items-center rounded-md px-2 py-1 text-xs ".concat("all"===l?"bg-green-100 text-green-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),disabled:u||0===t.length,children:"all"===l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(C.A,{className:"mr-1 h-3 w-3"}),"已复制全部"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(A.A,{className:"mr-1 h-3 w-3"}),"复制全部"]})})]})]}),c&&(0,s.jsx)(b,{variant:"destructive",className:"mb-4",children:(0,s.jsx)(v,{children:c})}),(0,s.jsx)("div",{className:"mb-4 max-h-80 overflow-y-auto rounded border",children:t.length>0?(0,s.jsx)("ul",{className:"divide-y",children:t.map(e=>(0,s.jsxs)("li",{className:"flex items-center justify-between p-3 hover:bg-gray-50 cursor-pointer",onClick:()=>f(e),children:[(0,s.jsx)("span",{className:"flex-1 truncate",children:e.name}),(0,s.jsx)("span",{className:"ml-2 flex items-center text-sm",children:l===e.key?(0,s.jsxs)("span",{className:"flex items-center text-green-600",children:[(0,s.jsx)(C.A,{className:"h-4 w-4 mr-1"}),"已复制"]}):(0,s.jsxs)("span",{className:"flex items-center text-gray-500",children:[(0,s.jsx)(A.A,{className:"h-4 w-4 mr-1"}),"复制链接"]})})]},e.key))}):(0,s.jsx)("div",{className:"p-4 text-center text-gray-500",children:"没有找到文件"})})]})}function R(e){return(0,s.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),(0,s.jsx)("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}function S(){let[e,t]=(0,a.useState)(!1),[r,n]=(0,a.useState)(!0),[l,o]=(0,a.useState)(""),[c,i]=(0,a.useState)([]),[d,u]=(0,a.useState)("");return((0,a.useEffect)(()=>{(async()=>{try{n(!0);let e=await w();t(e),e&&o("")}catch(e){console.error("登录验证失败:",e)}finally{n(!1)}})()},[]),r)?(0,s.jsx)("div",{className:"flex min-h-screen flex-col items-center justify-center p-4",children:(0,s.jsx)("div",{className:"w-full max-w-md space-y-4 rounded-lg border p-6 shadow-md",children:(0,s.jsxs)("div",{className:"flex items-center justify-center space-x-2",children:[(0,s.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-b-2 border-t-2 border-gray-900"}),(0,s.jsx)("span",{children:"正在加载..."})]})})}):(0,s.jsxs)("div",{className:"flex min-h-screen flex-col items-center p-4",children:[(0,s.jsxs)("header",{className:"mb-8 flex w-full max-w-4xl items-center justify-between",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold",children:"城通网盘解析工具"}),(0,s.jsxs)("a",{href:"https://github.com/Nekohy/ctfile-downloader",target:"_blank",rel:"noopener noreferrer",className:"flex items-center space-x-2 rounded-md bg-gray-100 px-3 py-2 text-sm hover:bg-gray-200",children:[(0,s.jsx)(R,{className:"h-5 w-5"}),(0,s.jsx)("span",{children:"GitHub"})]})]}),(0,s.jsx)("main",{className:"w-full max-w-4xl space-y-6",children:e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_,{onSubmit:(e,t)=>{u(e),i(t)},password:l}),c.length>0&&(0,s.jsx)(E,{files:c,xtlink:d,password:l})]}):(0,s.jsx)(k,{onLoginSuccess:e=>{t(!0),o(e)}})})]})}}},e=>{var t=t=>e(e.s=t);e.O(0,[388,22,575,358],()=>t(6545)),_N_E=e.O()}]);