1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1521],{26512:function(e,a,t){"use strict";var r=t(51072),s={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,a){var t,i,l,n,o,d,c,m,p=!1;a||(a={}),l=a.debug||!1;try{if(o=r(),d=document.createRange(),c=document.getSelection(),(m=document.createElement("span")).textContent=e,m.ariaHidden="true",m.style.all="unset",m.style.position="fixed",m.style.top=0,m.style.clip="rect(0, 0, 0, 0)",m.style.whiteSpace="pre",m.style.webkitUserSelect="text",m.style.MozUserSelect="text",m.style.msUserSelect="text",m.style.userSelect="text",m.addEventListener("copy",function(t){if(t.stopPropagation(),a.format){if(t.preventDefault(),void 0===t.clipboardData){l&&console.warn("unable to use e.clipboardData"),l&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var r=s[a.format]||s.default;window.clipboardData.setData(r,e)}else t.clipboardData.clearData(),t.clipboardData.setData(a.format,e)}a.onCopy&&(t.preventDefault(),a.onCopy(t.clipboardData))}),document.body.appendChild(m),d.selectNodeContents(m),c.addRange(d),!document.execCommand("copy"))throw Error("copy command was unsuccessful");p=!0}catch(r){l&&console.error("unable to copy using execCommand: ",r),l&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(a.format||"text",e),a.onCopy&&a.onCopy(window.clipboardData),p=!0}catch(r){l&&console.error("unable to copy using clipboardData: ",r),l&&console.error("falling back to prompt"),t="message"in a?a.message:"Copy to clipboard: #{key}, Enter",i=(/mac os x/i.test(navigator.userAgent)?"â":"Ctrl")+"+C",n=t.replace(/#{\s*key\s*}/g,i),window.prompt(n,e)}}finally{c&&("function"==typeof c.removeRange?c.removeRange(d):c.removeAllRanges()),m&&document.body.removeChild(m),o()}return p}},51072:function(e){e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var a=document.activeElement,t=[],r=0;r<e.rangeCount;r++)t.push(e.getRangeAt(r));switch(a.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":a.blur();break;default:a=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||t.forEach(function(a){e.addRange(a)}),a&&a.focus()}}},88321:function(e,a,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/api-key",function(){return t(62557)}])},85460:function(e,a,t){"use strict";var r=t(15311),s=t(20132),i=t(1631),l=t(12372),n=t(87609),o=t(74807),d=t(48078),c=t(30560),m=t(84927),p=t(85510),x=t(77755),h=t(41478),y=t(11205),u=t(48846),g=t(14218),f=t(34219),v=t(75927),j=t(5724),b=t(5762);let N=(0,u.Pi)(()=>{let{userStore:e}=(0,g.o)(),{t:a}=(0,j.Z)("dashboard"),t=(0,b.useRouter)(),[u,N]=(0,s.useState)({discord:!1,telegram:!1}),w=async e=>{N({...u,[e]:!0});try{let t=await (0,f.Z)({url:"/client/v1/user/getVipChannelUrl",method:"post",data:{vipChannelType:e,projectSource:"sunoapi.org"}});200===t.code&&t.data?window.location.href=t.data:(v.Am.error(t.msg||a("settings.vipChannel.errors.joinFailed")),N({...u,[e]:!1}))}catch(t){console.error("Error joining VIP channel:",t),v.Am.error(a("settings.vipChannel.errors.tryAgainLater")),N({...u,[e]:!1})}};return"/join-discord-vip"===t.pathname?null:(0,r.jsx)(c.R,{isOpen:e.openDiscordModel,onClose:()=>e.setOpenDiscordModel(!1),size:"lg",classNames:{base:"bg-content1",backdrop:"bg-black/80"},children:(0,r.jsx)(m.A,{children:t=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p.k,{className:"flex items-center justify-between border-b border-divider pb-4",children:(0,r.jsx)("h2",{className:"text-xl font-semibold text-foreground",children:a("settings.vipChannel.modal.title")})}),(0,r.jsx)(x.I,{className:"py-6",children:(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-sm text-foreground-600",children:a("settings.vipChannel.modal.getSupport")}),(0,r.jsx)("p",{className:"text-sm text-foreground",dangerouslySetInnerHTML:{__html:a("settings.vipChannel.description").replace("<strong>",'<span class="font-semibold">').replace("</strong>","</span>")}})]}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center",children:(0,r.jsx)(i.Z,{className:"h-5 w-5 text-yellow-500"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:a("settings.vipChannel.benefits.priorityAssistance")}),(0,r.jsxs)("span",{className:"text-foreground-600",children:[" ",a("settings.vipChannel.benefits.priorityAssistanceDesc")]})]})]}),(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center",children:(0,r.jsx)(l.Z,{className:"h-5 w-5 text-blue-500"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:a("settings.vipChannel.benefits.realTimeAlerts")}),(0,r.jsxs)("span",{className:"text-foreground-600",children:[" ",a("settings.vipChannel.benefits.realTimeAlertsDesc")]})]})]}),(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center",children:(0,r.jsx)(n.Z,{className:"h-5 w-5 text-orange-500"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:a("settings.vipChannel.benefits.lowCreditReminders")}),(0,r.jsxs)("span",{className:"text-foreground-600",children:[" ",a("settings.vipChannel.benefits.lowCreditRemindersDesc")]})]})]}),(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center",children:(0,r.jsx)(o.Z,{className:"h-5 w-5 text-green-500"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium text-foreground",children:a("settings.vipChannel.benefits.privateCommunication")}),(0,r.jsxs)("span",{className:"text-foreground-600",children:[" ",a("settings.vipChannel.benefits.privateCommunicationDesc")]})]})]})]})]})}),(0,r.jsxs)(h.R,{className:"flex flex-col gap-2 border-t border-divider pt-4",children:[(()=>{var t,s;let i=[{platform:"discord",title:a("settings.vipChannel.buttons.discord"),icon:"ic:baseline-discord",bgColor:"bg-[#5865F2]",hoverColor:"hover:bg-[#47
152C4]"},{platform:"telegram",title:a("settings.vipChannel.buttons.telegram"),icon:"ic:baseline-telegram",bgColor:"bg-[#0088cc]",hoverColor:"hover:bg-[#006699]"}],l=i;if((null===(t=e.user)||void 0===t?void 0:t.vipChannelStatus)===0){let a=null===(s=e.user)||void 0===s?void 0:s.vipChannelType;"discord"===a?l=i.filter(e=>"discord"===e.platform):"telegram"===a&&(l=i.filter(e=>"telegram"===e.platform))}return(0,r.jsx)("div",{className:"grid gap-2 ".concat(1===l.length?"grid-cols-1":"grid-cols-2"),children:l.map(e=>(0,r.jsx)(y.A,{color:"primary",size:"lg",className:"relative w-full ".concat(e.bgColor," font-semibold text-white ").concat(e.hoverColor," transition-colors"),onPress:()=>w(e.platform),isLoading:u[e.platform],children:(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)(d.JO,{icon:e.icon,className:"h-6 w-6"}),(0,r.jsx)("span",{children:u[e.platform]?a("settings.vipChannel.modal.authorizing"):e.title})]})},e.platform))})})(),(0,r.jsx)(y.A,{variant:"light",size:"lg",className:"w-full text-foreground-500",onPress:t,isDisabled:u.discord||u.telegram,children:a("settings.vipChannel.modal.maybeLater")})]})]})})})});a.Z=N},62557:function(e,a,t){"use strict";t.r(a),t.d(a,{__N_SSG:function(){return q},default:function(){return Y}});var r=t(15311),s=t(5724),i=t(20132),l=t(5762),n=t(66887),o=t(33326),d=t.n(o),c=t(77155),m=t(37341),p=t(79717),x=t(45538),h=t(11205),y=t(25379),u=t(15914),g=t(83032),f=t(71079),v=t(25072),j=t(53952),b=t(24839),N=t(60036),w=t(60384),k=t(2215),A=t(30560),K=t(84927),C=t(85510),S=t(77755),L=t(22066),I=t(41478),T=t(48078),F=t(75927),O=t(48239);let P=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch(e){return"UTC"}},R=e=>(null==e?void 0:e.timezone)||(null==e?void 0:e.timeZone)||P()||"UTC",D=function(e,a){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!e)return t;let r=new Date(e);if(Number.isNaN(r.getTime()))return t;try{let e=new Intl.DateTimeFormat("en-US",{timeZone:a||"UTC",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,hourCycle:"h23"}).formatToParts(r),t=a=>{var t;return(null===(t=e.find(e=>e.type===a))||void 0===t?void 0:t.value)||""};return"".concat(t("year"),"-").concat(t("month"),"-").concat(t("day")," ").concat(t("hour"),":").concat(t("minute"),":").concat(t("second"))}catch(e){return t}};var E=t(22619);/** 2 * @license lucide-react v0.461.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */let z=(0,E.Z)("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var W=t(17111);/** 7 * @license lucide-react v0.461.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */let Z=(0,E.Z)("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),M=(0,E.Z)("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);var U=e=>{let{isOpen:a,onClose:t,apiKeyId:l,onSave:n}=e,{t:o}=(0,s.Z)("dashboard"),[d,c]=(0,i.useState)(""),[m,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(""),[y,u]=(0,i.useState)(!1),[g,f]=(0,i.useState)(!1),[v,j]=(0,i.useState)(!1),[b,N]=(0,i.useState)(!1),[w,k]=(0,i.useState)(!1),A=async()=>
11{if(l){k(!0);try{let e=await O.BG.getSafeSpendLimits({apiKeyId:parseInt(l)});e.data&&(c(e.data.hourLimit>0?e.data.hourLimit.toString():""),p(e.data.dayLimit>0?e.data.dayLimit.toString():""),h(e.data.totalLimit>0?e.data.totalLimit.toString():""))}catch(e){console.error("Fetch safe-spend limits error:",e)}finally{k(!1)}}};(0,i.useEffect)(()=>{a&&l?A():a||(c(""),p(""),h(""))},[a,l]);let K=async()=>{if(!l){F.ZP.error(o("apiKey.apiKeyIdMissing"));return}let e=d.trim(),a=m.trim(),r=x.trim();if(!e&&!a&&!r){F.ZP.error(o("apiKey.enterAtLeastOneLimit"));return}if(e&&(isNaN(e)||0>Number(e))){F.ZP.error(o("apiKey.enterValidHourlyLimit"));return}if(a&&(isNaN(a)||0>Number(a))){F.ZP.error(o("apiKey.enterValidDailyLimit"));return}if(r&&(isNaN(r)||0>Number(r))){F.ZP.error(o("apiKey.enterValidTotalLimit"));return}N(!0);try{await O.BG.saveSafeSpendLimits({apiKeyId:parseInt(l),hourLimit:e?Number(e):0,dayLimit:a?Number(a):0,totalLimit:r?Number(r):0}),F.ZP.success(o("apiKey.limitsUpdatedSuccessfully")+"\n"+o("apiKey.changesEffectIn60Seconds")),setTimeout(()=>{c(""),p(""),h(""),t(),n&&n()},2e3)}catch(e){console.error("Save safe-spend limits error:",e),F.ZP.error(o("apiKey.safeSpendLimitsFailed"))}finally{N(!1)}},C=""!==d||""!==m||""!==x;return a?(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50 p-4",children:(0,r.jsxs)("div",{className:"relative max-h-[90vh] w-full max-w-lg overflow-y-auto overflow-x-hidden rounded-lg bg-white shadow-xl dark:bg-gray-800",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 p-6 dark:border-gray-700",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"bg-[var(--color-primary)]/10 flex h-8 w-8 items-center justify-center rounded-lg",children:(0,r.jsx)(z,{className:"h-4 w-4 text-[var(--color-primary)]"})}),(0,r.jsx)("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:o("apiKey.safeSpendLimits")})]}),(0,r.jsx)("button",{onClick:t,className:"flex h-8 w-8 items-center justify-center rounded-lg transition-colors hover:bg-gray-100 dark:hover:bg-gray-700",children:(0,r.jsx)(W.Z,{className:"h-5 w-5 text-gray-500 dark:text-gray-400"})})]}),(0,r.jsxs)("div",{className:"p-6",children:[(0,r.jsx)("p",{className:"mb-6 text-sm text-gray-600 dark:text-gray-300",children:o("apiKey.safeSpendLimitsTooltip")}),w&&(0,r.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-blue-500 border-t-transparent"}),(0,r.jsx)("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:o("apiKey.loadingLimits")})]})}),!w&&(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{htmlFor:"hourly-limit",className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:[o("apiKey.hourlyCreditLimit"),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(Z,{className:"h-4 w-4 cursor-help text-gray-400 dark:text-gray-500",onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1)}),y&&(0,r.jsxs)("div",{className:"absolute left-full top-1/2 z-[9999] ml-2 -translate-y-1/2 transform whitespace-normal rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-gray-700 shadow-md dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:shadow-lg",style:{fontSize:"13px",lineHeight:"20px",width:"320px",wordWrap:"break-word"},children:[o("apiKey.hourlyLimitTooltip"),(0,r.jsx)("div",{className:"absolute right-full top-1/2 h-0 w-0 -translate-y-1/2 transform",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:"6px solid rgb(249 250 251)"}}),(0,r.jsx)("div",{className:"absolute right-full top-1/2 hidden h-0 w-0 -translate-y-1/2 transform dark:block",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:"6px solid rgb(31 41 55)"}})]})]})]}),(0,r.jsx)("input",{type:"number",id:"hourly-limit",value:d,onChange:e=>c(e.target.value),placeholder:"1000",min:"0",className:"w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-sm text-gray-900 placeholder-gray-400 transition-colors focus:border-[var(--color-primary)] focus:ring-2 focus:ring-[var(--color-primary)] dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-500"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:o("apiKey.zeroMeansUnlimited")})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{htmlFor:"daily-limit",className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:[o("apiKey.dailyCreditLimit"),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(Z,{className:"h-4 w-4 cursor-help text-gray-400 dark:text-gray-500",onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1)}),g&&(0,r.jsxs)("div",{className:"absolute left-full top-1/2 z-[9999] ml-2 -translate-y-1/2 transform whitespace-normal rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-gray-700 shadow-md dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:shadow-lg",style:{fontSize:"13px",lineHeight:"20px",width:"320px",wordWrap:"break-word"},children:[o("apiKey.dailyLimitTooltip"),(0,r.jsx)("div",{className:"absolute right-full top-1/2 h-0 w-0 -translate-y-1/2 transform",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:"6px solid rgb(249 250 251)"}}),(0,r.jsx)("div",{className:"absolute right-full top-1/2 hidden h-0 w-0 -translate-y-1/2 transform dark:block",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:"6px solid rgb(31 41 55)"}})]})]})]}),(0,r.jsx)("input",{type:"number",id:"daily-limit",value:m,onChange:e=>p(e.target.value),placeholder:"5000",min:"0",className:"w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-sm text-gray-900 placeholder-gray-400 transition-colors focus:border-[var(--color-primary)] focus:ring-2 focus:ring-[var(--color-primary)] dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-500"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:o("apiKey.zeroMeansUnlimited")})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{htmlFor:"total-limit",className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300",children:[o("apiKey.totalCreditLimit"),(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(Z,{className:"h-4 w-4 cursor-help text-gray-400 dark:text-gray-500",onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1)}),v&&(0,r.jsxs)("div",{className:"absolute left-full top-1/2 z-[9999] ml-2 -translate-y-1/2 transform whitespace-normal rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-gray-700 shadow-md dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:shadow-lg",style:{fontSize:"13px",lineHeight:"20px",width:"320px",wordWrap:"break-word"},children:[o("apiKey.totalLimitTooltip"),(0,r.jsx)("div",{className:"absolute right-full top-1/2 h-0 w-0 -translate-y-1/2 transform",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:"6px solid rgb(249 250 251)"}}),(0,r.jsx)("div",{className:"absolute right-full top-1/2 hidden h-0 w-0 -translate-y-1/2 transform dark:block",style:{borderTop:"6px solid transparent",borderBottom:"6px solid transparent",borderRight:"6px solid rgb(31 41 55)"}})]})]})]}),(0,r.jsx)("input",{type:"number",id:"total-limit",value:x,onChange:e=>h(e.target.value),placeholder:"100000",min:"0",className:"w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-sm text-gray-900 placeholder-gray-400 transition-colors focus:border-[var(--color-primary)] focus:ring-2 focus:ring-[var(--color-primary)] dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-500"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:o("apiKey.zeroMeansUnlimited")})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-3 border-t border-gray-200 bg-gray-50 p-6 dark:border-gray-700 dark:bg-gray-800/50",children:[(0,r.jsx)("button",{onClick:t,className:"px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:text-gray-900 dark:text-gray-300 dark:hover:text-white",children:o("common.cancel")}),(0,r.jsx)("button",{onClick:K,disabled:!C||b,className:"flex items-center gap-2 rounded-lg bg-[var(--color-primary)] px-6 py-2 text-sm font-medium text-[var(--color-primary-contrast)] transition-all hover:bg-[var(--color-primary-dark)] focus:ring-2 focus:ring-[var(--color-primary)] focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-[var(--color-primary)] dark:focus:ring-offset-gray-800",children:b?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),o("apiKey.saving")]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(M,{className:"h-4 w-4"}),o("apiKey.saveLimits")]})})]})]})}):null},_=t(14218),B=t(26512),J=t.n(B),G=t(48846);let H="bg-[var(--color-primary)] text-[var(--color-primary-contrast)] hover:bg-[var(--color-primary-dark)]",V="border-[var(--color-primary)] text-[var(--color-primary)] data-[hover=true]:bg-[var(--color-primary)]/10";var X=(0,G.Pi)(function(){let{t:e}=(0,s.Z)("dashboard"),{userStore:a}=(0,_.o)(),t=R(a.user),[l,n]=(0,i.useState)(""),[o,d]=(0,i.useState)(""),[c,P]=(0,i.useState)(""),[E,z]=(0,i.useState)(""),[W,Z]=(0,i.useState)(null),[M,B]=(0,i.useState)([""]),[G,X]=(0,i.useState)({}),[q,Y]=(0,i.useState)(!1),[$,Q]=(0,i.useState)(!1),[ee,ea]=(0,i.useState)(!1),[et,er]=(0,i.useState)(""),[es,ei]=(0,i.useState)(!1),[el,en]=(0,i.useState)(""),{isOpen:eo,onOpen:ed,onClose:ec}=(0,m.q)(),{isOpen:em,onOpen:ep,onClose:ex}=(0,m.q)(),{isOpen:eh,onOpen:ey,onClose:eu}=(0,m.q)(),{isOpen:eg,onOpen:ef,onClose:ev}=(0,m.q)(),{isOpen:ej,onOpen:eb,onClose:eN}=(0,m.q)(),{isOpen:ew,onOpen:ek,onClose:eA}=(0,m.q)(),[eK,eC]=(0,i.useState)(null),[eS,eL]=(0,i.useState)([]);(0,i.useEffect)(()=>{a.user&&eD()},[a.user]);let eI=(e,a)=>{navigator.clipboard.writeText(a),n(e),setTimeout(()=>n(null),2e3)},eT=e=>"".concat(e.substring(0,8)).concat("â¢".repeat(32)),eF=a=>a.ipWhitelist&&a.ipWhitelist.length>0?(0,r.jsxs)("div",{className:"max-w-xs space-y-2",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:e("apiKey.whitelistTooltip")}),(0,r.jsxs)("div",{className:"text-xs text-default-500",children:[e("apiKey.currentWhitelist"),":"]}),(0,r.jsx)("div",{className:"space-y-1",children:a.ipWhitelist.map((e,a)=>(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded bg-default-100 px-2 py-1",children:[(0,r.jsx)(T.JO,{icon:"ph:check-circle-fill",className:"h-3 w-3 text-success"}),(0,r.jsx)("span",{className:"font-mono text-xs text-default-900",children:e})]},a))})]}):(0,r.jsxs)("div",{className:"max-w-xs space-y-2",children:[(0,r.jsx)("div",{className:"text-sm font-medium text-foreground",children:e("apiKey.whitelistTooltip")}),(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded bg-warning-50 px-2 py-1 dark:bg-warning-900/20",children:[(0,r.jsx)(T.JO,{icon:"ph:warning-circle-fill",className:"h-3 w-3 text-warning"}),(0,r.jsx)("span",{className:"text-xs text-warning-700 dark:text-warning-300",children:e("apiKey.noWhitelistAdded")})]})]}),eO=e=>{Z(e.id),B(e.ipWhitelist&&e.ipWhitelist.length>0?[...e.ipWhitelist]:[""]),X({}),ep()},eP=()=>{B([""]),X({}),Z(null),Y(!1),ex()},eR=e=>!!e&&"string"==typeof e&&((e=e.trim(),/^(\d{1,3}\.){3}\d{1,3}$/.test(e))?e.split(".").every(e=>{let a=parseInt(e,10);return!isNaN(a)&&a>=0&&a<=255&&e===a.toString()}):/^(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,5}(?::[0-9A-Fa-f]{1,4}){1,2}|(?:[0-9A-Fa-f]{1,4}:){1,4}(?::[0-9A-Fa-f]{1,4}){1,3}|(?:[0-9A-Fa-f]{1,4}:){1,3}(?::[0-9A-Fa-f]{1,4}){1,4}|(?:[0-9A-Fa-f]{1,4}:){1,2}(?::[0-9A-Fa-f]{1,4}){1,5}|[0-9A-Fa-f]{1,4}:(?:(?::[0-9A-Fa-f]{1,4}){1,6}
11)|:(?:(?::[0-9A-Fa-f]{1,4}){1,7}|:)|fe80:(?::[0-9A-Fa-f]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(?:ffff(?::0{1,4}){0,1}:){0,1}(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])|(?:[0-9A-Fa-f]{1,4}:){1,4}:(?:(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(?:25[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/.test(e)),eD=(0,i.useCallback)(async()=>{Q(!0);try{let e=await O.BG.getApiKeyList();if(e.data&&Array.isArray(e.data)){let a=e.data.map(e=>({id:e.id.toString(),name:e.keyName,key:e.apiKey,createdAt:D(e.createTime,t,"-"),fullApiKey:e.apiKey,ipWhitelist:e.ipWhitelist?JSON.parse(e.ipWhitelist):[]}));eL(a)}}catch(a){F.Am.error(e("apiKey.fetchFailed"))}finally{Q(!1)}},[e,t]),eE=async()=>{if(M.some(e=>!e||!e.trim())){F.Am.error(e("apiKey.fillAllIpAddresses"));let a={...G};M.forEach((t,r)=>{t&&t.trim()||(a[r]=e("apiKey.pleaseEnterIp"))}),X(a);return}let a=!1,t={...G};if(M.forEach((r,s)=>{eR(r.trim())||(a=!0,t[s]=e("apiKey.invalidIpFormat"))}),a){X(t),F.Am.error(e("apiKey.fixInvalidIps"));return}Y(!0);try{let a=M.map(e=>e.trim());await O.BG.saveWhitelist({id:parseInt(W),ipWhitelist:a}),eL(eS.map(e=>e.id===W?{...e,ipWhitelist:a}:e)),F.Am.success(e("apiKey.whitelistSaveSuccess")),eP()}catch(a){F.Am.error(e("apiKey.whitelistSaveFailed"))}finally{Y(!1),await eD()}},ez=e=>{B(M.filter((a,t)=>t!==e));let a={...G};delete a[e],X(a)},eW=(e,a)=>{let t=[...M];t[e]=a,B(t),eZ(e,a)},eZ=(a,t)=>{let r={...G};return t&&""!==t.trim()?eR(t.trim())?delete r[a]:r[a]=e("apiKey.invalidIpFormat"):r[a]=e("apiKey.pleaseEnterIp"),X(r),!r[a]},eM=e=>{eC(e),ey()},eU=async()=>{if(!o.trim()){F.Am.error(e("apiKey.pleaseEnterName"));return}ea(!0);try{let t=await O.BG.addApiKey({name:o});200===t.code&&(await eD(),ec(),F.Am.success(e("apiKey.createSuccess")),er(t.data),ef(),a.loadUserInfo())}catch(a){F.Am.error(e("apiKey.createFailed"))}finally{ea(!1)}},e_=a=>{let t=a.fullApiKey||a;J()(t)?F.Am.success(e("apiKey.copySuccess")):F.Am.error(e("apiKey.copyFailed"))},eB=e=>{en(e),eb()},eJ=async()=>{ei(!0);try{let t=await O.BG.deleteApiKey({id:parseInt(el)});200===t.code?(await eD(),F.Am.success(e("apiKey.deleteSuccess")),eN(),a.loadUserInfo()):F.Am.error(t.msg||e("apiKey.deleteFailed"))}catch(a){F.Am.error(e("apiKey.deleteFailed"))}finally{ei(!1)}},eG=(e,a)=>{P(e),z(a),ek()},eH=async()=>{if(!E.trim()){F.Am.error(e("apiKey.pleaseEnterName"));return}ea(!0);try{await O.BG.updateApiKeyName({id:parseInt(c),name:E}),eL(eS.map(e=>e.id===c?{...e,name:E}:e)),F.Am.success(e("apiKey.editSuccess")),eA()}catch(a){F.Am.error(e("apiKey.editFailed"))}finally{ea(!1)}};return(0,r.jsxs)("div",{className:"min-h-screen bg-background",children:[(0,r.jsx)("div",{className:"mx-auto px-8 py-12",children:(0,r.jsxs)(p.w,{children:[(0,r.jsxs)(x.u,{className:"flex-row items-center justify-between px-8 py-6",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:e("apiKey.apiKeys")}),(0,r.jsx)(h.A,{onPress:()=>{d(""),ed()},className:H,startContent:(0,r.jsx)(T.JO,{icon:"mdi:plus",width:16}),size:"sm",children:e("apiKey.createNewKey")})]}),(0,r.jsx)(y.j,{}),(0,r.jsx)(u.G,{className:"p-0",children:(0,r.jsxs)(g.b,{classNames:{wrapper:"shadow-none",th:"bg-default-100 text-default-600 text-base py-4",td:"py-4"},children:[(0,r.jsxs)(f.J,{children:[(0,r.jsx)(v.j,{className:"text-center",children:e("apiKey.name")}),(0,r.jsx)(v.j,{className:"text-center",children:e("apiKey.key")}),(0,r.jsx)(v.j,{className:"text-center",children:e("apiKey.createdAt")}),(0,r.jsx)(v.j,{className:"text-center",children:e("apiKey.addWhitelist")}),(0,r.jsx)(v.j,{className:"text-center",children:e("apiKey.safeSpendLimits")}),(0,r.jsx)(v.j,{className:"text-center",children:e("apiKey.actions")})]}),(0,r.jsx)(j.y,{isLoading:$,loadingContent:(0,r.jsx)(b.c,{}),children:eS.map(a=>(0,r.jsxs)(N.g,{children:[(0,r.jsx)(w.X,{className:"font-medium",children:a.name}),(0,r.jsx)(w.X,{children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("code",{className:"text-foreground-muted font-mono text-xs",children:eT(a.key)}),(0,r.jsx)(h.A,{isIconOnly:!0,size:"sm",variant:"light",onPress:()=>eI(a.id,a.key),children:l===a.id?(0,r.jsx)(T.JO,{icon:"mdi:check",className:"h-4 w-4 text-success"}):(0,r.jsx)(T.JO,{icon:"mdi:content-copy",className:"h-4 w-4"})})]})}),(0,r.jsx)(w.X,{className:"text-center",children:a.createdAt}),(0,r.jsx)(w.X,{className:"text-center",children:(0,r.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)(k.e,{content:eF(a),placement:"top",showArrow:!0,classNames:{content:"py-3 px-4"},children:(0,r.jsx)(T.JO,{icon:"ph:question-bold",className:"text-black-400 h-4 w-4 cursor-help"})}),(0,r.jsx)(h.A,{variant:"solid",className:H,size:"sm",onPress:()=>eO(a),children:e("apiKey.addWhitelistButton")})]})}),(0,r.jsx)(w.X,{className:"text-center",children:(0,r.jsx)(h.A,{variant:"bordered",className:V,size:"sm",onPress:()=>eM(a.id),children:e("apiKey.safeSpendLimits")})}),(0,r.jsx)(w.X,{children:(0,r.jsxs)("div",{className:"flex items-center justify-center gap-1",children:[(0,r.jsx)(h.A,{isIconOnly:!0,size:"sm",variant:"light",className:"text-[var(--color-primary)]",onPress:()=>eG(a.id,a.name),"aria-label":e("apiKey.editKeyAriaLabel"),children:(0,r.jsx)(T.JO,{icon:"mdi:pencil",className:"h-4 w-4"})}),1===eS.length?null:(0,r.jsx)(h.A,{isIconOnly:!0,size:"sm",variant:"light",color:"danger",onPress:()=>
11eB(a.id),"aria-label":e("apiKey.revokeKeyAriaLabel"),isDisabled:1===eS.length,children:(0,r.jsx)(T.JO,{icon:"mdi:delete",className:"h-4 w-4"})})]})})]},a.id))})]})})]})}),(0,r.jsx)(A.R,{isOpen:em,onClose:eP,children:(0,r.jsxs)(K.A,{children:[(0,r.jsx)(C.k,{className:"flex flex-col gap-1",children:e("apiKey.manageWhitelist")}),(0,r.jsx)(S.I,{children:(0,r.jsxs)("div",{className:"space-y-4",children:[M.map((a,t)=>(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(L.Y,{type:"text",placeholder:e("apiKey.enterIpPlaceholder"),value:a,onChange:e=>eW(t,e.target.value),isInvalid:!!G[t],variant:"bordered",color:G[t]?"danger":"default",errorMessage:G[t],classNames:{inputWrapper:G[t]?"border-2 border-danger":"",input:G[t]?"text-danger placeholder:text-danger":""}})}),(0,r.jsx)(h.A,{isIconOnly:!0,color:"danger",variant:"light",onPress:()=>ez(t),className:"mt-1",children:(0,r.jsx)(T.JO,{icon:"solar:trash-bin-trash-bold",className:"text-lg"})})]},t)),M.length<10&&(0,r.jsxs)(h.A,{onPress:()=>{if(M.length>=10){F.Am.error(e("apiKey.maxWhitelistLimit"));return}B([...M,""]),X({})},variant:"bordered",className:"mt-4 flex w-full items-center justify-center gap-2 ".concat(V),children:[(0,r.jsx)(T.JO,{icon:"solar:add-circle-bold",className:"text-xl"}),e("apiKey.addIpAddress")," (",M.length,"/10)"]})]})}),(0,r.jsxs)(I.R,{children:[(0,r.jsx)(h.A,{variant:"bordered",onPress:eP,children:e("common.cancel")}),(0,r.jsx)(h.A,{variant:"solid",className:H,isLoading:q,onPress:eE,children:e("common.save")})]})]})}),(0,r.jsx)(U,{isOpen:eh,onClose:()=>{eC(null),eu()},apiKeyId:eK,onSave:eD}),(0,r.jsx)(A.R,{isOpen:eo,onClose:ec,children:(0,r.jsxs)(K.A,{children:[(0,r.jsx)(C.k,{className:"flex flex-col gap-1",children:e("apiKey.createTitle")}),(0,r.jsx)(S.I,{children:(0,r.jsx)(L.Y,{label:e("apiKey.name"),placeholder:e("apiKey.namePlaceholder"),value:o,onChange:e=>d(e.target.value)})}),(0,r.jsxs)(I.R,{children:[(0,r.jsx)(h.A,{variant:"bordered",onPress:ec,children:e("common.cancel")}),(0,r.jsx)(h.A,{variant:"solid",className:H,isLoading:ee,onPress:eU,children:e("common.create")})]})]})}),(0,r.jsx)(A.R,{isDismissable:!1,isOpen:eg,onClose:ev,children:(0,r.jsxs)(K.A,{children:[(0,r.jsx)(C.k,{className:"flex flex-col gap-1",children:e("apiKey.createSuccessTitle")}),(0,r.jsxs)(S.I,{children:[(0,r.jsx)("p",{className:"mb-2 text-sm text-default-500",children:e("apiKey.saveKeyWarning")}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(L.Y,{className:"flex-1",value:et,readOnly:!0,type:"text",variant:"bordered"})})]}),(0,r.jsxs)(I.R,{children:[(0,r.jsx)(h.A,{variant:"bordered",onPress:ev,children:e("common.cancel")}),(0,r.jsx)(h.A,{variant:"bordered",className:V,onPress:()=>e_(et),children:e("apiKey.copy")})]})]})}),(0,r.jsx)(A.R,{isOpen:ej,onClose:eN,children:(0,r.jsxs)(K.A,{children:[(0,r.jsx)(C.k,{className:"flex flex-col gap-1",children:e("apiKey.deleteConfirmTitle")}),(0,r.jsx)(S.I,{children:(0,r.jsx)("p",{children:e("apiKey.deleteConfirmText")})}),(0,r.jsxs)(I.R,{children:[(0,r.jsx)(h.A,{variant:"bordered",onPress:eN,children:e("common.cancel")}),(0,r.jsx)(h.A,{isLoading:es,color:"danger",onPress:eJ,children:e("common.delete")})]})]})}),(0,r.jsx)(A.R,{isOpen:ew,onClose:eA,children:(0,r.jsxs)(K.A,{children:[(0,r.jsx)(C.k,{className:"flex flex-col gap-1",children:e("apiKey.editTitle")}),(0,r.jsx)(S.I,{children:(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("div",{className:"mb-1 text-sm",children:e("apiKey.name")}),(0,r.jsx)(L.Y,{placeholder:e("apiKey.namePlaceholder"),fullWidth:!0,value:E,onChange:e=>z(e.target.value),className:"bg-default-100"})]})}),(0,r.jsxs)(I.R,{children:[(0,r.jsx)(h.A,{variant:"bordered",onPress:eA,children:e("common.cancel")}),(0,r.jsx)(h.A,{isLoading:ee,variant:"solid",className:H,onPress:eH,children:e("common.save")})]})]})})]})}),q=!0,Y=function(e){let{}=e,a=(0,l.useRouter)(),{t}=(0,s.Z)("common");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(d(),{children:[(0,r.jsx)("title",{children:t("head.title")}),(0,r.jsx)("meta",{name:"description",content:t("head.description")}),(0,r.jsx)("meta",{name:"robots",content:"noindex"}),(0,n.t)(a,"/api-key")]}),(0,r.jsx)("div",{className:"relative w-full dark",children:(0,r.jsx)("main",{children:(0,r.jsx)(c.Z,{selectedKey:"api-key",children:(0,r.jsx)(X,{})})})})]})}},45538:function(e,a,t){"use strict";t.d(a,{u:function(){return d}});var r=t(66037),s=t(26223),i=t(61593),l=t(81437),n=t(15311),o=(0,s.Gp)((e,a)=>{var t;let{as:s,className:o,children:d,...c}=e,m=(0,i.gy)(a),{slots:p,classNames:x}
11=(0,r.R)(),h=(0,l.Wy)(null==x?void 0:x.header,o);return(0,n.jsx)(s||"div",{ref:m,className:null==(t=p.header)?void 0:t.call(p,{class:h}),...c,children:d})});o.displayName="HeroUI.CardHeader";var d=o},15914:function(e,a,t){"use strict";t.d(a,{G:function(){return d}});var r=t(66037),s=t(26223),i=t(61593),l=t(81437),n=t(15311),o=(0,s.Gp)((e,a)=>{var t;let{as:s,className:o,children:d,...c}=e,m=(0,i.gy)(a),{slots:p,classNames:x}=(0,r.R)(),h=(0,l.Wy)(null==x?void 0:x.body,o);return(0,n.jsx)(s||"div",{ref:m,className:null==(t=p.body)?void 0:t.call(p,{class:h}),...c,children:d})});o.displayName="HeroUI.CardBody";var d=o}},function(e){e.O(0,[3676,6169,7924,2066,9717,7359,3998,1778,2888,9774,179],function(){return e(e.s=88321)}),_N_E=e.O()}]);
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.