1import{c as Ot,a as c,j as e,d as Vt,M as _t,f as Et,n as Ht,z as Wt,y as Bt,h as Yt,k as Zt,av as Gt,s as he,w as B,aw as rt,B as bt,L as re,X as Kt,ax as qt,a1 as Re,ay as Qt}from"./index-CRPZpX17.js";import{A as Xt,I as Jt}from"./invite-code-page-xhVh6mvp.js";import{d as es,c as ts,k as Q,l as X,m as J,n as L,F as ss,o as as,R as ns,P as rs,O as ls,C as cs,T as is,a as os}from"./popover-5zndvtb5.js";import{P as lt,A as ct,a as it,b as ot,c as dt,d as ut,e as mt,f as ds,g as xt,D as us}from"./alert-dialog-De_x8LSL.js";import{T as pe}from"./switcher-LFj8n8JV.js";import{T as ms}from"./search-BenPg9xh.js";import{u as xs,F as hs}from"./mobile-pending-C6irSst_.js";import{F as ps}from"./noPackages-DM38xhD5.js";import{n as fs}from"./sb-loading-BS93ZLM4.js";import{T as ht}from"./trash-2-3MeFaQb8.js";import{C as ge}from"./chevron-down-C7lCUKQy.js";import"./dapposLogo-T2t9YBIw.js";import"./incognito-BoJbb9iM.js";/** 2 * @license lucide-react v0.372.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 */const pt=Ot("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),gs=(s,a)=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"none",width:16,height:16,ref:a,...s,children:[e.jsx("path",{d:"M9.99992 3.99935V1.33268C9.99992 0.964492 10.2984 0.666016 10.6666 0.666016C11.0348 0.666016 11.3333 0.964492 11.3333 1.33268V3.99935C11.3333 4.36754 11.0348 4.66602 10.6666 4.66602C10.2984 4.66602 9.99992 4.36754 9.99992 3.99935Z",fill:"currentColor"}),e.jsx("path",{d:"M13.3333 8.66602V3.99935C13.3333 3.82254 13.263 3.65302 13.1379 3.52799C13.0285 3.41857 12.885 3.35106 12.7323 3.33594L12.6666 3.33268H3.33325C3.15644 3.33268 2.98692 3.40297 2.8619 3.52799C2.73687 3.65302 2.66659 3.82254 2.66659 3.99935V13.3327C2.66659 13.5095 2.73687 13.679 2.8619 13.804C2.98692 13.9291 3.15644 13.9993 3.33325 13.9993H6.99992C7.36811 13.9993 7.66659 14.2978 7.66659 14.666C7.66659 15.0342 7.36811 15.3327 6.99992 15.3327H3.33325C2.80282 15.3327 2.29426 15.1218 1.91919 14.7467C1.54412 14.3717 1.33325 13.8631 1.33325 13.3327V3.99935C1.33325 3.46892 1.54412 2.96036 1.91919 2.58529C2.29426 2.21021 2.80282 1.99935 3.33325 1.99935H12.6666C13.197 1.99935 13.7056 2.21021 14.0806 2.58529C14.4557 2.96036 14.6666 3.46892 14.6666 3.99935V8.66602C14.6666 9.03421 14.3681 9.33268 13.9999 9.33268C13.6317 9.33268 13.3333 9.03421 13.3333 8.66602Z",fill:"currentColor"}),e.jsx("path",{d:"M13.9999 5.99935C14.3681 5.99935 14.6666 6.29783 14.6666 6.66602C14.6666 7.03421 14.3681 7.33268 13.9999 7.33268H1.99992C1.63173 7.33268 1.33325 7.03421 1.33325 6.66602C1.33325 6.29783 1.63173 5.99935 1.99992 5.99935H13.9999Z",fill:"currentColor"}),e.jsx("path",{d:"M4.66659 3.99935V1.33268C4.66659 0.964492 4.96506 0.666016 5.33325 0.666016C5.70144 0.666016 5.99992 0.964492 5.99992 1.33268V3.99935C5.99992 4.36754 5.70144 4.66602 5.33325 4.66602C4.96506 4.66602 4.66659 4.36754 4.66659 3.99935Z",fill:"currentColor"}),e.jsx("path",{d:"M13.7999 12.6654L10.4685 10.6673L10.4666 10.666V14.666L10.4685 14.6647L13.7999 12.6667L13.8012 12.666L13.7999 12.6654ZM15.1346 12.666C15.1346 12.8969 15.0748 13.1241 14.9607 13.3249C14.8469 13.5252 14.6825 13.6917 14.4848 13.8099L14.4855 13.8105L11.1541 15.8086L11.1534 15.8079C10.9513 15.9295 10.7207 15.9961 10.4848 15.9993C10.2482 16.0026 10.0149 15.9429 9.80903 15.8262C9.60309 15.7094 9.4317 15.5394 9.31294 15.3346C9.19432 15.13 9.13232 14.8974 9.13325 14.6608V10.668C9.13291 10.4321 9.19508 10.2001 9.31359 9.99609C9.43245 9.79153 9.60381 9.62244 9.80968 9.50586C10.0156 9.38928 10.2489 9.32936 10.4855 9.33268C10.7212 9.33602 10.9514 9.40259 11.1534 9.52409L11.1541 9.52344L14.4842 11.5208L14.5564 11.5671C14.7224 11.6811 14.8609 11.8314 14.9607 12.0072C15.0748 12.2079 15.1346 12.4351 15.1346 12.666Z",fill:"currentColor"})]}),ft=c.forwardRef(gs),gt=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],yt=c.forwardRef(({value:s,onClick:a,className:r},d)=>e.jsx("button",{ref:d,type:"button",className:B(r,"text-left"),onClick:a,children:s}));yt.displayName="MobileDatePickerInput";const js=s=>{const a=s%100;if(a>=11&&a<=13)return`${s}th`;switch(s%10){case 1:return`${s}st`;case 2:return`${s}nd`;case 3:return`${s}rd`;default:return`${s}th`}},Ie=(s,a,r)=>{if(!r)return String(s);const h=a.toLowerCase().startsWith("en")?js(s).replace(/^\d+/,""):"";return r.replace("{number}",String(s)).replace("{suffix}",h)},ke=(s,a)=>new Intl.DateTimeFormat(a,{hour:"numeric",minute:"2-digit",hour12:!1}).format(s),bs=(s,a)=>
6{if(a.startsWith("zh")){const r=s.getFullYear(),d=s.getMonth()+1,h=s.getDate();return`${r}å¹´${d}æ${h}æ¥`}return new Intl.DateTimeFormat(a,{month:"short",day:"2-digit",year:"numeric"}).format(s)},ys=(s,a)=>{const r=new Date,d=new Date(Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),0,0,0)),h=ke(d,s);return s.startsWith("zh")||s.startsWith("ja")?`${a.daily} ${h}`:a.at?`${a.daily} ${a.at} ${h}`:`${a.daily} ${h}`},Ns=(s,a)=>{const r=new Date(2026,0,5),d=new Date(r);return d.setDate(r.getDate()+(a-1)),new Intl.DateTimeFormat(s,{weekday:"short"}).format(d)},jt=(s,a,r)=>{const d=s.scheduleTime??"";if(!d)return"";if(s.repeatType===0){const p=new Date(d),N=bs(p,a),g=ke(p,a);return r.at?`${N} ${r.at} ${g}`:`${N} ${g}`}const h=new Date(d);if(Number.isNaN(h.getTime()))return"";const x=ke(h,a);if(s.repeatType===1)return r.at?`${r.daily} ${r.at} ${x}`:`${r.daily} ${x}`;if(s.repeatType===2){const p=s.repeatValue??1,N=h.getUTCDay()===0?7:h.getUTCDay(),g=p-N,j=new Date(h);j.setUTCDate(j.getUTCDate()+g);const w=j.getDay()===0?7:j.getDay(),o=Ns(a,w);return a.startsWith("zh")||a.startsWith("ja")?`${r.weekly}${o} ${x}`:r.at?`${r.weekly} ${o} ${r.at} ${x}`:`${r.weekly} ${o} ${x}`}const z=s.repeatValue??1,v=new Date(h);v.setUTCDate(z);const b=v.getDate();if(a.startsWith("zh")||a.startsWith("ja"))return r.at?`${r.monthly}${b}æ¥ ${r.at} ${x}`:`${r.monthly}${b}æ¥ ${x}`;const S=Ie(b,a,r.ordinal);return r.at?`${r.monthly} ${S} ${r.at} ${x}`:`${r.monthly} ${S} ${x}`},ws=s=>{const a=new Date(s);if(Number.isNaN(a.getTime()))return{hour:"09",minute:"00",localDay:1,localMonthDay:1};const r=String(a.getHours()).padStart(2,"0"),d=String(a.getMinutes()).padStart(2,"0");return{hour:r,minute:d}},Cs=(s,a)=>
6{if(!a)return 1;const r=new Date(s);if(Number.isNaN(r.getTime()))return a;const d=r.getUTCDay()===0?7:r.getUTCDay(),h=a-d,x=new Date(r);return x.setUTCDate(x.getUTCDate()+h),x.getDay()===0?7:x.getDay()},vs=(s,a)=>{if(!a)return 1;const r=new Date(s);if(Number.isNaN(r.getTime()))return a;const d=new Date(r);return d.setUTCDate(a),d.getDate()},Ds=(s,a,r)=>{const d=new Date(s,a+1,0).getDate();return Math.min(Math.max(r,1),d)},Ts=s=>{const{repeatType:a,repeatValue:r,localDate:d,localTime:h}=s,[x="00",z="00"]=h.split(":"),v=Number(x),b=Number(z);if(a===0)return{scheduleTime:new Date(d.getFullYear(),d.getMonth(),d.getDate(),v,b,0).toISOString(),repeatValue:0};if(a===1){const u=new Date(d.getFullYear(),d.getMonth(),d.getDate(),v,b,0),$=String(u.getUTCHours()).padStart(2,"0"),Y=String(u.getUTCMinutes()).padStart(2,"0");return{scheduleTime:`${$}:${Y}`,repeatValue:0}}if(a===2){const u=new Date(d),$=u.getDay()===0?7:u.getDay(),Y=r-$;u.setDate(u.getDate()+Y),u.setHours(v,b,0,0);const le=String(u.getUTCHours()).padStart(2,"0"),je=String(u.getUTCMinutes()).padStart(2,"0"),be=u.getUTCDay()===0?7:u.getUTCDay();return{scheduleTime:`${le}:${je}`,repeatValue:be}}const S=d.getFullYear(),p=d.getMonth(),N=Ds(S,p,r),g=new Date(S,p,N,v,b,0),j=String(g.getUTCHours()).padStart(2,"0"),w=String(g.getUTCMinutes()).padStart(2,"0"),o=g.getUTCDate();return{scheduleTime:`${j}:${w}`,repeatValue:o}};function fe({value:s,hour:a,minute:r,hourOptions:d,minuteOptions:h,onHourChange:x,onMinuteChange:z,onConfirm:v,onOpenChange:b,menuProps:S}){const[p,N]=c.useState(!1),[g,j]=c.useState(a),[w,o]=c.useState(r);return c.useEffect(()=>{p&&(j(a),o(r))},[p,a,r]),e.jsxs(Q,{...S,open:p,onOpenChange:u=>{N(u),b==null||b(u)},children:[e.jsx(X,{asChild:!0,children:e.jsxs("button",{type:"button",className:"h-10 w-full rounded-[8px] border border-input bg-transparent px-3 text-sm text-left flex items-center justify-between",children:[e.jsx("span",{children:s||"Time"}),e.jsx(ge,{className:"h-4 w-4 text-[#858481]"})]})}),e.jsxs(J,{align:"start",className:"min-w-0 p-2 z-[80] rounded-[8px]",children:[e.jsxs("div",{className:"grid grid-cols-[48px_1px_48px] items-stretch border-b border-[#00000014]",children:[e.jsx("div",{className:"max-h-[180px] overflow-y-auto overscroll-contain touch-pan-y px-1",style:{WebkitOverflowScrolling:"touch"},onTouchMoveCapture:u=>u.stopPropagation(),children:d.map(u=>e.jsx("button",{type:"button",className:`w-full px-2 py-2 text-center text-sm transition-colors rounded-[6px] ${g===u?"bg-[#2aae67] text-white":"hover:bg-[#00000008]"}`,onWheel:$=>$.stopPropagation(),onClick:()=>j(u),children:u},u))}),e.jsx("div",{className:"w-px bg-[#00000014]"}),e.jsx("div",{className:"max-h-[180px] overflow-y-auto overscroll-contain touch-pan-y px-1",style:{WebkitOverflowScrolling:"touch"},onTouchMoveCapture:u=>u.stopPropagation(),children:h.map(u=>e.jsx("button",{type:"button",className:`w-full px-2 py-2 text-center text-sm transition-colors rounded-[6px] ${w===u?"bg-[#2aae67] text-white":"hover:bg-[#00000008]"}`,onWheel:$=>$.stopPropagation(),onClick:()=>o(u),children:u},u))})]}),e.jsx("div",{className:"mt-3 flex justify-end",children:e.jsx(bt,{type:"button",className:"h-8 px-4 bg-[#2aae67] hover:bg-[#1b9658]",onClick:()=>{x(g),z(w),v(g,w),N(!1)},children:"OK"})})]})]})}function Ss(){var nt;const s=fs("schedule"),{agentApi:a,packageApi:r,goldInfo:d,isNeedPurchase:h,isAppleGreenMode:x}=Vt(),z=_t(),v=h||z,{createThread:b,openThread:S}=es(),p=Et(),N=Ht(),g=N.lang||"en",j=c.useMemo(()=>({daily:s("daily"),weekly:s("weekly"),monthly:s("monthly"),at:s("at"),ordinal:s("ordinal",{number:"{number}",suffix:"{suffix}"})}),[s]),{data:w=[]}=xs(),{session:o}=Wt(),{can:u}=Bt(),$=u({action:"view",subject:"checkout"}),Y=u({action:"view",subject:"chat"}),{enhancedPush:le}=ts(),je=w.some(t=>t.status===0||t.status===3)&&o&&$,be=()=>{le("/")},Nt=async()=>{if(!(w!=null&&w.length))return;const t=w.find(n=>n.status===0||n.status===3);t&&le("/checkout",{id:t.id})},[C,Oe]=c.useState("scheduled"),[M,I]=c.useState([]),[ee,Ve]=c.useState([]),[wt,k]=c.useState(!1),[ye,_e]=c.useState(null),[te,Ne]=c.useState(""),[se,we]=c.useState(""),[f,Ce]=c.useState(0),[P,F]=c.useState(0),[ce,ae]=c.useState(new Date),[O,y]=c.useState("09:00"),[U,D]=c.useState("09"),[R,T]=c.useState("00"),[V,Ee]=c.useState(!1),[Ct,_]=c.useState(!1),He=t=>{t&&ae(t),_(!1)},[E,We]=c.useState({page:1,size:20,total:0}),[H,Be]=c.useState({page:1,size:20,total:0}),[ve,Ye]=c.useState(!1),[De,Ze]=c.useState(!1),[Te,Ge]=c.useState(!1),[Se,Ke]=c.useState(!1),[vt,$e]=c.useState(!1),[qe,Qe]=c.useState(null),[Dt,ne]=c.useState(!1),{data:ie,isLoading:Z,refetch:Tt}=Yt({queryKey:["gold-credit-auto-exchange",o==null?void 0:o.address],queryFn:async()=>o!=null&&o.address?r.getGoldCreditAutoExchange({eoaAddress:o.address}):null,enabled:!!(o!=null&&o.address)&&!x,retry:1}),Xe=c.useRef(null),Je=c.useRef(null),St=!!ye,oe=c.useMemo(()=>Array.from({length:24},(t,n)=>String(n).padStart(2,"0")),[]),de=c.useMemo(()=>Array.from({length:12},(t,n)=>String(n*5).padStart(2,"0")),[]),$t=s(f===0?"noRepeat":f===1?"daily":f===2?"weekly":"monthly"),Mt=gt[Math.max(0,P-1)]??"Mon",Pt=Ie(P||1,g,j.ordinal),Me=c.useMemo(()=>M.filter(t=>t.status===0).length,[M]),G=(ie==null?void 0:ie.exists)===!0&&((nt=ie.record)==null?void 0:nt.isPau
6sed)===0,Pe=Number((d==null?void 0:d.goldBalance)??0)>0,Fe=Pe||G,Ae=c.useMemo(()=>ys(g,j),[g,j]),Ft=()=>{if(!V){if(v){N.setNeedPurchaseDialogIsOpen(!0);return}_e(null),Ne(""),we(""),Ce(0),F(0),ae(new Date),y("09:00"),D("09"),T("00"),k(!0)}},ue=t=>{if(V)return;if(_e(t),Ne(t.title),we(t.prompt??""),Ce(t.repeatType??0),t.repeatType===0){const l=new Date(t.scheduleTime);Number.isNaN(l.getTime())?ae(new Date):ae(l);const i=String(l.getHours()).padStart(2,"0"),m=String(l.getMinutes()).padStart(2,"0");y(`${i}:${m}`),D(i),T(m),F(0),k(!0);return}const n=ws(t.scheduleTime);y(`${n.hour}:${n.minute}`),D(n.hour),T(n.minute),t.repeatType===2?F(Cs(t.scheduleTime,t.repeatValue??1)):t.repeatType===3?F(vs(t.scheduleTime,t.repeatValue??1)):F(0),ae(new Date),k(!0)},At=async()=>{if(!te.trim()||!se.trim()||f===0&&(!ce||!O)||f===2&&!P||f===3&&!P)return;Ee(!0);const t=Ts({repeatType:f,repeatValue:P,localDate:ce,localTime:O}),n=t.scheduleTime;try{ye?await a.updateScheduleTask({id:ye.id,body:{title:te.trim(),prompt:se.trim(),language:N.lang,scheduleTime:n,repeatType:f,repeatValue:f===2||f===3?t.repeatValue:0}}):await a.createScheduleTask({title:te.trim(),prompt:se.trim(),language:N.lang,scheduleTime:n,repeatType:f,repeatValue:f===2||f===3?t.repeatValue:0}),await q(1,!0),k(!1),Me>=3&&ne(!0)}catch{k(!1)}finally{Ee(!1)}},et=t=>{Qe(t),$e(!0)},Lt=async()=>{if(!qe)return;const t=qe;$e(!1),Qe(null),I(n=>n.filter(l=>l.id!==t));try{await a.deleteScheduleTask({id:t})}catch{await q(1,!0)}},Le=c.useCallback(async t=>{var l,i;if(!Y)return;const n=((l=t.prompt)==null?void 0:l.trim())||((i=t.title)==null?void 0:i.trim());n&&(typeof window<"u"&&(sessionStorage.setItem("pending_schedule_run_prompt",n),sessionStorage.setItem("pending_schedule_run_id",String(t.id)),sessionStorage.setItem("pending_schedule_run_title",t.title)),await b.mutateAsync())},[b]),tt=async t=>{Y&&await S.mutateAsync(t.path)},K=Zt({mutationFn:async t=>o!=null&&o.address?r.updateGoldCreditAutoExchangePause({eoaAddress:o.address,isPaused:t?0:1}):null,onSuccess:async()=>{await Tt()},onError:t=>{if(Gt(t)){he(t.eMsg);return}he("Update auto redeem failed")}}),ze=c.useCallback(t=>{!(o!=null&&o.address)||K.isPending||Z||!Pe&&(!G||t)||K.mutate(t)},[Z,K,Pe,G,o==null?void 0:o.address]),q=c.useCallback(async(t,n=!1)=>{var l,i,m;if(a)try{n?Ye(!0):Ge(!0);const A=await a.getScheduleTasks({page:t,size:E.size}),W=A.items??[];I(Ue=>n?W:[...Ue,...W]),We({page:((l=A.pager)==null?void 0:l.page)??t,size:((i=A.pager)==null?void 0:i.size)??E.size,total:((m=A.pager)==null?void 0:m.total)??W.length})}catch{n&&(I([]),We({page:1,size:E.size,total:0}))}finally{Ye(!1),Ge(!1)}},[a,E.size]),me=c.useCallback(async(t,n=!1)=>{var l,i,m;if(a)try{n?Ze(!0):Ke(!0);const A=await a.getScheduleExecutedConversations({page:t,size:H.size}),W=A.items??[];Ve(Ue=>n?W:[...Ue,...W]),Be({page:((l=A.pager)==null?void 0:l.page)??t,size:((i=A.pager)==null?void 0:i.size)??H.size,total:((m=A.pager)==null?void 0:m.total)??W.length})}catch{n&&(Ve([]),Be({page:1,size:H.size,total:0}))}finally{Ze(!1),Ke(!1)}},[a,H.size]),st=M.length<E.total,at=ee.length<H.total;c.useEffect(()=>{C==="scheduled"?q(1,!0):me(1,!0)},[C,q,me]),c.useEffect(()=>{if(C!=="scheduled")return;const t=Xe.current;if(!t)return;const n=new IntersectionObserver(l=>{const i=l[0];i!=null&&i.isIntersecting&&(!st||ve||Te||q(E.page+1,!1))},{root:null,rootMargin:"120px"});return n.observe(t),()=>n.disconnect()},[C,st,ve,Te,E.page,q]),c.useEffect(()=>{if(C!=="completed")return;const t=Je.current;if(!t)return;const n=new IntersectionObserver(l=>{const i=l[0];i!=null&&i.isIntersecting&&(!at||De||Se||me(H.page+1,!1))},{root:null,rootMargin:"120px"});return n.observe(t),()=>n.disconnect()},[C,at,De,Se,H.page,me]);const xe=M.length>0,zt=ee.length>0,Ut=!x&&Z||ve,Rt=c.useMemo(()=>x?null:p?e.jsxs("div",{className:B("p-3",xe?"border-b border-[#0000000F]":""),children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsx("div",{className:"min-w-0 text-[14px] font-medium text-[#1d1c1b]",children:s("autoRedeemTitle")})}),e.jsxs("div",{className:"pt-2 flex items-center justify-between text-[13px] text-[#646362]",children:[e.jsx("span",{children:s("scheduleAt")}),e.jsx("span",{className:"text-[#1d1c1b]",children:Ae})]}),e.jsxs("div",{className:"pt-2 flex items-center justify-between text-[13px] text-[#646362]",children:[e.jsx("span",{children:s("status")}),e.jsx(pe,{checked:G,onChange:ze,disabled:!(o!=null&&o.address)||Z||K.isPending||!Fe})]})]}):e.jsxs("div",{className:B("grid grid-cols-[1.2fr_0.9fr_0.6fr_48px] items-center gap-4 p-3",xe?"border-b border-[#0000000F]":""),children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"text-[14px] font-medium text-[#1d1c1b] truncate",children:s("autoRedeemTitle")})}),e.jsx("div",{className:"text-[13px] text-[#646362]",children:Ae}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(pe,{className:"w-[26px] h-[16px] p-[1px]",spanClassName:"w-3.5 h-3.5",checked:G,onChange:ze,disabled:!(o!=null&&o.address)||Z||K.isPending||!Fe})}),e.jsx("div",{})]}),[Z,K.isPending,Ae,Fe,ze,xe,x,G,p,o==null?void 0:o.address,s]),It=c.useMemo(()=>M.map((t,n)=>p?e.jsxs("div",{className:B("p-3",n===M.length-1?"":"border-b border-[#0000000F]"),onClick:()=>ue(t),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-[14px] font-medium text-[#1d1c1b] truncate",children:t.title}),e.jsxs(Q,{children:[e.jsx(X,{asChild:!0,children:e.jsx("button",{className:"w-8 h-8 rounded-full hover:bg-[#0505050a] flex items-center justify-center",onClick:l=>l.stopPropagation(),children:e.jsx(pt,{className:"w-4 h-4 text-[#646362]"})})}),e.jsxs(J,{align:"end",className:"rounded-[12px] z-[80]",onClick:l=>l.stopPropagation(),children:[e.jsx(L,{onClick:()=>Le(t),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"h-4 w-4"}),s("runNow")]})}),e.jsx(L,{onClick:()=>ue(t),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(lt,{className:"h-4 w-4"}),s("edit")]})}),e.jsx(L,{onClick:()=>
6et(t.id),className:"text-[#f25a5a] focus:text-[#f25a5a]",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ht,{className:"h-4 w-4"}),s("delete")]})})]})]})]}),e.jsxs("div",{className:"pt-2 flex items-center justify-between text-[13px] text-[#646362]",children:[e.jsx("span",{children:s("scheduleAt")}),e.jsx("span",{className:"text-[#1d1c1b]",children:jt(t,g,j)})]}),e.jsxs("div",{className:"pt-2 flex items-center justify-between text-[13px] text-[#646362]",children:[e.jsx("span",{children:s("status")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(pe,{checked:t.status===0,onChange:async l=>{if(t.status!==0&&l&&Me>=3){ne(!0);return}if(t.status!==0&&l&&t.repeatType===0){const i=new Date(t.scheduleTime);if(!Number.isNaN(i.getTime())&&i.getTime()<=Date.now()){he(s("startTimeFuture"));return}}I(i=>i.map(m=>m.id===t.id?{...m,status:l?0:1}:m));try{await a.updateScheduleTask({id:t.id,body:{status:l?0:1}})}catch{I(i=>i.map(m=>m.id===t.id?{...m,status:t.status}:m))}}})})]})]},t.id):e.jsxs("div",{className:B("grid grid-cols-[1.2fr_0.9fr_0.6fr_48px] items-center gap-4 p-3 cursor-pointer",n===M.length-1?"":"border-b border-[#0000000F]"),onClick:()=>ue(t),children:[e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"text-[14px] font-medium text-[#1d1c1b] truncate",children:t.title})}),e.jsx("div",{className:"text-[13px] text-[#646362]",children:jt(t,g,j)}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(pe,{className:"w-[26px] h-[16px] p-[1px]",spanClassName:"w-3.5 h-3.5",checked:t.status===0,onChange:async l=>{if(t.status!==0&&l&&Me>=3){ne(!0);return}if(t.status!==0&&l&&t.repeatType===0){const i=new Date(t.scheduleTime);if(!Number.isNaN(i.getTime())&&i.getTime()<=Date.now()){he(s("startTimeFuture"));return}}I(i=>i.map(m=>m.id===t.id?{...m,status:l?0:1}:m));try{await a.updateScheduleTask({id:t.id,body:{status:l?0:1}})}catch{I(i=>i.map(m=>m.id===t.id?{...m,status:t.status}:m))}}})}),e.jsxs(Q,{children:[e.jsx(X,{asChild:!0,children:e.jsx("button",{className:"ml-auto w-10 h-10 -mr-3 rounded-full flex items-center justify-center",onClick:l=>l.stopPropagation(),children:e.jsx(pt,{className:"w-4 h-4 text-[#646362]"})})}),e.jsxs(J,{align:"end",className:"rounded-[12px]",onClick:l=>l.stopPropagation(),children:[e.jsx(L,{className:"cursor-pointer",onClick:()=>Le(t),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"h-4 w-4"}),s("runNow")]})}),e.jsx(L,{className:"cursor-pointer",onClick:()=>ue(t),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(lt,{className:"h-4 w-4"}),s("edit")]})}),e.jsx(L,{onClick:()=>et(t.id),className:"text-[#f25a5a] focus:text-[#f25a5a] cursor-pointer",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ht,{className:"h-4 w-4"}),s("delete")]})})]})]})]},t.id)),[M,p,s,Le,a]),kt=c.useMemo(()=>ee.map((t,n)=>p?e.jsxs("div",{className:B("p-3",n===ee.length-1?"":"border-b border-[#0000000F]"),onClick:()=>tt(t),children:[e.jsxs("div",{className:"flex items-center justify-between text-[13px] text-[#646362]",children:[e.jsx("span",{children:s("completedName")}),e.jsx("div",{className:"text-[14px] font-medium text-[#1d1c1b] truncate",children:t.title})]}),e.jsxs("div",{className:"pt-2 flex items-center justify-between text-[13px] text-[#646362]",children:[e.jsx("span",{children:s("completedTime")}),e.jsx("span",{className:"text-[#1d1c1b]",children:rt(t.time,!0)})]})]},t.id):e.jsxs("div",{className:B("flex justify-between items-center gap-4 p-3",n===M.length-1?"":"border-b border-[#0000000F]"),onClick:()=>tt(t),children:[e.jsx("div",{className:"text-[14px] font-medium text-[#1d1c1b] truncate",children:t.title}),e.jsx("div",{className:"text-[13px] text-[#646362]",children:rt(t.time,!0)})]},t.id)),[ee,p,s]);return e.jsxs("div",{className:"mx-auto max-w-[800px] px-6 pb-10",children:[e.jsxs("div",{className:"sticky top-0 z-10 bg-[#f8f8f7] pt-6",children:[p?e.jsxs("div",{className:"grid grid-cols-[auto_1fr_auto] items-center",children:[e.jsx("div",{className:"flex items-center gap-1",onClick:be,children:e.jsx(ss,{className:"w-6 h-6 text-[#858481] cursor-pointer"})}),e.jsx("div",{className:"text-center font-medium text-[16px]",children:s("title")}),e.jsx("div",{className:"flex justify-end",children:je&&e.jsx("div",{className:"flex items-center rounded-full bg-[#00c9a7] p-2",onClick:Nt,children:e.jsx(hs,{className:"w-5 h-5"})})})]}):e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h1",{className:"text-[20px] font-semibold text-[#1d1c1b]",children:s("title")})}),e.jsxs("div",{className:"relative mt-6 flex items-end justify-between",children:[e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[1px] bg-[#0000000F]"}),e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex gap-2 md:gap-8",children:[e.jsxs("button",{onClick:()=>Oe("scheduled"),className:`relative px-2 pb-2 text-sm md:text-[16
6px] font-medium transition-colors ${C==="scheduled"?"text-[#34322d]":"text-[#858481]"}`,children:[s("scheduled"),C==="scheduled"&&e.jsx("span",{className:"absolute left-0 right-0 bottom-0 h-[2px] bg-[#34322d] rounded-full"})]}),e.jsxs("button",{onClick:()=>Oe("completed"),className:`relative px-2 pb-2 text-sm md:text-[16px] font-medium transition-colors ${C==="completed"?"text-[#34322d]":"text-[#858481]"}`,children:[s("completed"),C==="completed"&&e.jsx("span",{className:"absolute left-0 right-0 bottom-0 h-[2px] bg-[#34322d] rounded-full"})]})]})}),e.jsxs(bt,{className:"h-7 mb-1 shrink-0 flex items-center gap-1 px-2 rounded-full text-[13px] font-medium",onClick:Ft,children:[e.jsx(as,{className:"w-4 h-4"}),e.jsx("span",{className:"",children:s("new")})]})]}),!p&&e.jsx("div",{className:"mt-4 rounded-[14px] rounded-b-none border border-[#0000000F] border-b-0",children:C==="scheduled"?e.jsxs("div",{className:"grid grid-cols-[1.2fr_0.9fr_0.6fr_48px] items-center gap-4 px-3 py-3 text-xs font-medium text-[#858481] border-b border-[#0000000F]",children:[e.jsx("div",{children:s("scheduleTitle")}),e.jsx("div",{children:s("scheduleAt")}),e.jsx("div",{children:s("status")}),e.jsx("div",{className:"text-right"})]}):e.jsxs("div",{className:"flex justify-between items-center gap-4 px-3 py-3 text-xs text-[#858481] border-b border-[#0000000F]",children:[e.jsx("div",{children:s("completedName")}),e.jsx("div",{children:s("completedTime")})]})})]}),e.jsx("div",{className:p?"mt-4 rounded-[14px] border border-[#0000000F]":"-mt-[1px] rounded-[14px] border border-[#0000000F] border-t-0 rounded-t-none",children:C==="scheduled"?e.jsx(e.Fragment,{children:Ut?e.jsx("div",{className:"py-20 flex items-center justify-center",children:e.jsx(re,{className:"w-6 h-6 animate-spin text-[#858481]"})}):e.jsxs("div",{children:[Rt,xe&&e.jsxs(e.Fragment,{children:[It,e.jsx("div",{ref:Xe}),Te&&e.jsx("div",{className:"py-6 flex items-center justify-center",children:e.jsx(re,{className:"w-5 h-5 animate-spin text-[#858481]"})})]})]})}):e.jsx(e.Fragment,{children:De?e.jsx("div",{className:"py-20 flex items-center justify-center",children:e.jsx(re,{className:"w-6 h-6 animate-spin text-[#858481]"})}):zt?e.jsxs("div",{children:[kt,e.jsx("div",{ref:Je}),Se&&e.jsx("div",{className:"py-6 flex items-center justify-center",children:e.jsx(re,{className:"w-5 h-5 animate-spin text-[#858481]"})})]}):e.jsxs("div",{className:"h-full min-h-[100px] flex flex-col items-center justify-center gap-2 text-[12px] text-[#858481]",children:[e.jsx(ps,{className:"w-6 h-6"}),s("emptyRuns")]})})}),e.jsx(ct,{open:vt,onOpenChange:$e,children:e.jsxs(it,{className:"rounded-[16px] gap-6 z-[80]",overlayClassName:"z-[80]",children:[e.jsxs(ot,{className:"space-y-4",children:[e.jsx(dt,{children:s("confirmDeleteTitle")}),e.jsx(ut,{children:s("confirmDeleteBody")})]}),e.jsxs(mt,{children:[e.jsx(ds,{className:"rounded-full",children:s("cancel")}),e.jsx(xt,{className:"bg-[#f25a5a] hover:bg-[#e24b4b] text-white rounded-full",onClick:Lt,children:s("delete")})]})]})}),e.jsx(ct,{open:Dt,onOpenChange:ne,children:e.jsxs(it,{className:"rounded-[16px] gap-6 z-[80]",overlayClassName:"z-[80]",children:[e.jsxs(ot,{className:"space-y-4",children:[e.jsx(dt,{children:s("concurrencyTitle")}),e.jsx(ut,{children:s("concurrencyBody")})]}),e.jsx(mt,{children:e.jsx(xt,{className:"bg-[#2aae67] hover:bg-[#1b9658] text-white rounded-full",onClick:()=>ne(!1),children:s("close")})})]})}),e.jsx(ns,{open:wt,onOpenChange:k,children:e.jsxs(rs,{children:[e.jsx(ls,{className:"fixed inset-0 bg-[#05050533] ",style:{zIndex:70}}),e.jsx(cs,{className:"fixed top-1/2 left-1/2 py-2 -translate-x-1/2 -translate-y-1/2 w-[calc(100vw-32px)] md:w-[678px] bg-[#F8F7F6] rounded-[16px] ",style:{zIndex:71},onInteractOutside:t=>t.preventDefault(),onEscapeKeyDown:t=>t.preventDefault(),children:e.jsxs("div",{className:"py-[10px] px-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(is,{className:"text-[18px] leading-[28px] text-[#1d1c1b] font-medium",children:s(St?"dialogEdit":"dialogNew")}),e.jsx(os,{asChild:!0,children:e.jsx("button",{type:"button",className:"h-6 w-6 rounded-full hover:bg-[#0000000A] flex items-center justify-center disabled:opacity-50 disabled:cursor-not-allowed","aria-label":"Close",disabled:V,children:e.jsx(Kt,{className:"h-4 w-4 text-[#646362]"})})})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-[#34322d]",children:s("fieldTitle")}),e.jsx(qt,{value:te,onChange:t=>Ne(t.target.value),placeholder:s("filedInputPlaceholder"),className:"rounded-[10px] bg-transparent placeholder:text-[#b9b9b7]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-[#34322d]",children:s("filedPrompt")}),e.jsx(ms,{value:se,onChange:t=>we(t.target.value),placeholder:s("filedTextPlaceholder"),className:" h-[120px] bg-transparent border border-input rounded-[10px] px-4 py-2 placeholder-[#b9b9b7]",style:{minHeight:"120px"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-[#34322d]",children:s("fieldRepeat")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-3",children:[e.jsx("div",{className:"col-span-1",children:e.jsxs(Q,{modal:!1,onOpenChange:t=>t&&_(!1),children:[e.jsx(X,{asChild:!0,children:e.jsxs("button",{className:"h-10 w-full rounded-[8px] border border-input bg-transparent px-3 text-sm text-left flex items-center justify-between",children:[e.jsx("span",{children:$t}),e.jsx(ge,{className:"h-4 w-4 text-[#858481]"})]})}),e.jsx(J,{className:"w-[200px] z-[80] rounded-[8px]",children:[1,2,3,0].map(t=>{const n=s(t===0?"noRepeat":t===1?"daily":t===2?"weekly":"monthly"),l=f===t;return e.jsxs(L,{className:"flex items-center justify-between",onSelect:()=>{const i=t;_(!1),Ce(i),F(i===2||i===3?1:0)},children:[e.jsx("span",{children:n}),l?e.jsx(Re,{className:"h-4 w-4 text-[#2aae67]"}):e.jsx("span",{className:"w-4"})]},t)})})]})}),f===0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"col-span-1 h-10 border bg-transparent roun
6ded-[8px] px-2 flex items-center",children:e.jsx(us,{selected:ce,popperPlacement:"bottom-start",onChange:He,onSelect:He,dateFormat:"yyyy-MM-dd",className:"w-full bg-transparent text-sm",customInput:p?e.jsx(yt,{}):void 0,popperClassName:"custom-datepicker-popper",open:Ct,onInputClick:()=>_(!0),onClickOutside:()=>_(!1),onCalendarClose:()=>_(!1)})}),e.jsx("div",{className:"col-span-2 col-start-1 md:col-span-1 md:col-start-auto",children:e.jsx(fe,{value:O,hour:U,minute:R,onHourChange:t=>{D(t),y(`${t}:${R}`)},onMinuteChange:t=>{T(t),y(`${U}:${t}`)},onConfirm:(t,n)=>{D(t),T(n),y(`${t}:${n}`)},hourOptions:oe,minuteOptions:de,onOpenChange:t=>{t&&_(!1)}})})]}):f===1?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"col-span-1",children:e.jsx(fe,{value:O,hour:U,minute:R,onHourChange:t=>{D(t),y(`${t}:${R}`)},onMinuteChange:t=>{T(t),y(`${U}:${t}`)},onConfirm:(t,n)=>{D(t),T(n),y(`${t}:${n}`)},hourOptions:oe,minuteOptions:de,menuProps:{modal:!1}})}),e.jsx("div",{className:"hidden md:block"})]}):f===2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"col-span-1",children:e.jsxs(Q,{modal:!1,children:[e.jsx(X,{asChild:!0,children:e.jsxs("button",{className:"h-10 w-full rounded-[8px] border border-input bg-transparent px-3 text-sm text-left flex items-center justify-between",children:[e.jsx("span",{children:Mt}),e.jsx(ge,{className:"h-4 w-4 text-[#858481]"})]})}),e.jsx(J,{className:"w-[200px] z-[80] rounded-[8px]",children:gt.map((t,n)=>{const l=n+1,i=P===l;return e.jsxs(L,{className:"flex items-center justify-between",onSelect:()=>{F(l)},children:[e.jsx("span",{children:t}),i?e.jsx(Re,{className:"h-4 w-4 text-[#2aae67]"}):e.jsx("span",{className:"w-4"})]},t)})})]})}),e.jsx("div",{className:"col-span-2 col-start-1 md:col-span-1 md:col-start-auto",children:e.jsx(fe,{value:O,hour:U,minute:R,onHourChange:t=>{D(t),y(`${t}:${R}`)},onMinuteChange:t=>{T(t),y(`${U}:${t}`)},onConfirm:(t,n)=>{D(t),T(n),y(`${t}:${n}`)},hourOptions:oe,minuteOptions:de,menuProps:{modal:!1}})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"col-span-1",children:e.jsxs(Q,{modal:!1,children:[e.jsx(X,{asChild:!0,children:e.jsxs("button",{className:"h-10 w-full rounded-[8px] border border-input bg-transparent px-3 text-sm text-left flex items-center justify-between",children:[e.jsx("span",{children:Pt}),e.jsx(ge,{className:"h-4 w-4 text-[#858481]"})]})}),e.jsx(J,{className:"w-[200px] z-[80] max-h-[240px] overflow-y-auto overscroll-contain touch-pan-y rounded-[8px]",style:{WebkitOverflowScrolling:"touch"},onTouchMoveCapture:t=>t.stopPropagation(),onWheelCapture:t=>t.stopPropagation(),children:Array.from({length:31},(t,n)=>{const l=n+1,i=P===l,m=Ie(l,g,j.ordinal);return e.jsxs(L,{className:"flex items-center justify-between",onSelect:()=>{F(l)},children:[e.jsx("span",{children:m}),i?e.jsx(Re,{className:"h-4 w-4 text-[#2aae67]"}):e.jsx("span",{className:"w-4"})]},l)})})]})}),e.jsx("div",{className:"col-span-2 col-start-1 md:col-span-1 md:col-start-auto",children:e.jsx(fe,{value:O,hour:U,minute:R,onHourChange:t=>{D(t),y(`${t}:${R}`)},onMinuteChange:t=>{T(t),y(`${U}:${t}`)},onConfirm:(t,n)=>{D(t),T(n),y(`${t}:${n}`)},hourOptions:oe,minuteOptions:de,menuProps:{modal:!1}})})]})]})]})]}),e.jsx("div",{className:"mt-4 text-right",children:e.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[e.jsx("button",{className:"px-4 py-2 border border-[#0A0A0A1A] bg-[#F8F7F6] hover:bg-[#f3f3f1] text-[#1d1c1b] rounded-[16px] text-[14px] font-medium leading-[20px]",onClick:()=>!V&&k(!1),disabled:V,children:s("cancel")}),e.jsx("button",{className:"px-4 py-2 bg-[#2aae67] text-white rounded-[16px] text-[14px] font-medium leading-[20px] disabled:bg-[#1a1a19]/50",onClick:At,disabled:V||!te.trim()||!se.trim()||f===0&&(!ce||!O)||f===2&&!P||f===3&&!P,children:V?e.jsx(re,{className:"w-4 h-4 animate-spin"}):s("save")})]})})]})})]})})]})}const _s=function(){const a=Qt.useSearch();return e.jsx(Xt,{fallback:e.jsx(Jt,{referral:a.referral}),children:e.jsx(Ss,{})})};export{_s as component};
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.