@michengai/dsh-automation 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -1,6 +1,6 @@
1
1
  window.__ModuleLoader__.load({ id: "@michengai/dsh-automation", factory: (require) => {
2
2
  var module = { exports: {} }; var exports = module.exports;
3
- "use strict";var Jo=Object.create;var sn=Object.defineProperty;var Yo=Object.getOwnPropertyDescriptor;var Qo=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty;var tr=(e,n)=>{for(var t in n)sn(e,t,{get:n[t],enumerable:!0})},bt=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Qo(n))!nr.call(e,r)&&r!==t&&sn(e,r,{get:()=>n[r],enumerable:!(s=Yo(n,r))||s.enumerable});return e};var on=(e,n,t)=>(t=e!=null?Jo(er(e)):{},bt(n||!e||!e.__esModule?sn(t,"default",{value:e,enumerable:!0}):t,e)),sr=e=>bt(sn({},"__esModule",{value:!0}),e);var yi={};tr(yi,{apply:()=>fi,inject:()=>ai,name:()=>ii});module.exports=sr(yi);var Fe=require("react");var Y=require("react");function wt(e,n){return n(`run.trigger.${e}`)}var de=class extends Error{constructor(t){super(t);this.key=t}},or=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function dn(e){return`/${or.test(e.name)?e.name:e.id}`}function rr(e,n,t){let s=n.startsWith("/")?n:`/${n}`,r=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(^|\\s)${r}(?=\\s|$)`).test(e))return{text:e,caret:Math.min(Math.max(t,0),e.length)};let i=Math.min(Math.max(t,0),e.length),o=e.slice(0,i),a=e.slice(i),c=`${o.length>0&&!/\s$/.test(o)?" ":""}${s} `;return{text:o+c+a,caret:o.length+c.length}}function Un(e,n){let t=Math.min(Math.max(n,0),e.length),s=/(?:^|\s)\/([^\s/]*)$/.exec(e.slice(0,t));if(s===null)return;let r=s[1]??"";return{start:t-r.length-1,query:r}}function St(e,n){let t=n.trim().toLowerCase();return t===""?[...e]:e.filter(s=>s.id.toLowerCase().includes(t)||s.name.toLowerCase().includes(t))}function kt(e,n,t){let s=Un(e,n),r=t.startsWith("/")?t:`/${t}`;return s===void 0?rr(e,r,n):{text:`${e.slice(0,s.start)}${r} ${e.slice(n)}`,caret:s.start+r.length+1}}function xt(e,n){let t=new Set(n.map(o=>dn(o).slice(1))),s=[],r=/(^|\s)(\/[a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/gi,i=0;for(let o of e.matchAll(r)){let a=o[1]??"",l=o[2]??"",c=(o.index??0)+a.length;t.has(l.slice(1))&&(c>i&&s.push({kind:"text",text:e.slice(i,c)}),s.push({kind:"skill",text:l}),i=c+l.length)}return(i<e.length||s.length===0)&&s.push({kind:"text",text:e.slice(i)}),s}function At(e=new Date){let n=new Date(e.getTime()+36e5);n.setMinutes(0,0,0);let t=n.getTimezoneOffset()*6e4;return new Date(n.getTime()-t).toISOString().slice(0,16)}function Bn(e=new Date,n=[],t,s=""){return{name:"",prompt:"",scheduleKind:"daily",onceAt:At(e),everyMinutes:"60",maxConcurrentRuns:"1",intervalAnchor:"",time:"09:00",weekdays:[1,2,3,4,5],hourlyMinute:"00",monthDay:"1",customDays:"2",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone||"Asia/Shanghai",permission:s,workspaceId:n[0]?.id??"",modelKey:t==null?"default":`${t.provider}::${t.model}`,reasoningEffort:t?.reasoning?.defaultEffort??"none",skills:[]}}function Tt(e,n,t,s=new Date,r={}){let i=Number(e.maxConcurrentRuns);if(!Number.isSafeInteger(i)||i<1)throw new de("form.error.maxConcurrentRuns");let o=e.name.trim(),a=e.prompt.trim();if(o==="")throw new de("form.error.name");if(a==="")throw new de("form.error.prompt");let l=n.find(m=>m.id===e.workspaceId);if(l===void 0)throw new de("form.error.workspace");let c;switch(e.scheduleKind){case"once":{let m=new Date(e.onceAt);if(!Number.isFinite(m.getTime())||r.allowPastOnce!==!0&&m.getTime()<=s.getTime())throw new de("form.error.once");c={kind:"once",at:m.toISOString(),timeZone:e.timeZone};break}case"interval":{let m=Number(e.everyMinutes);if(!Number.isInteger(m)||m<1||m>43200)throw new de("form.error.interval");c={kind:"interval",everyMinutes:m,anchor:e.intervalAnchor.trim()||s.toISOString(),timeZone:e.timeZone};break}case"daily":c={kind:"daily",time:e.time,timeZone:e.timeZone};break;case"weekly":if(e.weekdays.length===0)throw new de("form.error.weekdays");c={kind:"weekly",time:e.time,weekdays:[...e.weekdays].sort((m,x)=>m-x),timeZone:e.timeZone};break;case"hourly":{let m=Number(e.hourlyMinute);if(!Number.isInteger(m)||m<0||m>59)throw new de("form.error.interval");c={kind:"hourly",minute:m,timeZone:e.timeZone};break}case"monthly":{let m=Number(e.monthDay);if(!Number.isInteger(m)||m<1||m>31)throw new de("form.error.interval");c={kind:"monthly",day:m,time:e.time,timeZone:e.timeZone};break}case"custom":{let m=Number(e.customDays);if(!Number.isInteger(m)||m<1)throw new de("form.error.interval");c={kind:"custom",everyDays:m,time:e.time,timeZone:e.timeZone};break}}let g=t.find(m=>`${m.provider}::${m.model}`===e.modelKey);return{name:o,prompt:a,schedule:c,timeZone:e.timeZone,permission:e.permission,maxConcurrentRuns:i,workspaceId:l.id,cwd:l.path,...g===void 0?{provider:null,model:null}:{provider:g.provider,model:g.model},reasoningEffort:e.reasoningEffort==="none"?null:e.reasoningEffort}}function It(e,n,t){let s=Date.parse(e);if(!Number.isFinite(s))return e;let r=Math.round((s-n.getTime())/6e4),i=Math.abs(r);if(i<1)return t("time.now");let o=r>0;if(i<60)return t(o?"time.inMinute":"time.minuteAgo",{count:i});let a=Math.round(i/60);if(a<24)return t(o?"time.inHour":"time.hourAgo",{count:a});let l=Math.round(a/24);return t(o?"time.inDay":"time.dayAgo",{count:l})}function ln(e,n){switch(e.kind){case"once":return n("schedule.onceAt",{time:new Date(e.at).toLocaleString()});case"interval":return n("schedule.everyMinutes",{count:e.everyMinutes});case"daily":return n("schedule.dailyAt",{time:e.time});case"weekly":{let t=e.weekdays.map(s=>n(`day.${s}`)).join("\u3001");return n("schedule.weeklyAt",{days:t,time:e.time})}case"hourly":return n("schedule.hourlyAt",{minute:String(e.minute).padStart(2,"0")});case"monthly":return n("schedule.monthlyAt",{day:e.day,time:e.time});case"custom":return n("schedule.customAt",{count:e.everyDays,time:e.time})}}function cn(e,n,t){let s=Date.parse(e)-n.getTime();if(!Number.isFinite(s)||s<=0)return t("time.now");let r=Math.max(1,Math.ceil(s/6e4));if(r<60)return t("time.withinMinute",{count:r});let i=Math.ceil(r/60);return i<24?t("time.withinHour",{count:i}):t("time.withinDay",{count:Math.ceil(i/24)})}function Ct(e,n){if(e===void 0||n===void 0)return;let t=(Date.parse(n)-Date.parse(e))/1e3;if(!(!Number.isFinite(t)||t<0))return`${t.toFixed(1)}s`}function Nt(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}var Rt=["succeeded","failed","interrupted","running","queued","skipped","cancelled"];function rn(e){let n=Date.parse(e);return Number.isFinite(n)?n:0}function un(e,n,t){let s=t==="asc"?1:-1;return e.slice().sort((r,i)=>{if(n==="planned"){let a=r.nextRunAt,l=i.nextRunAt;if(a===void 0||l===void 0)return a===void 0&&l===void 0?r.name.localeCompare(i.name)||r.id.localeCompare(i.id):a===void 0?1:-1;let c=rn(a)-rn(l);return c!==0?c*s:r.name.localeCompare(i.name)||r.id.localeCompare(i.id)}let o=rn(r.createdAt)-rn(i.createdAt);return o!==0?o*s:r.id.localeCompare(i.id)})}var pn="dsh-automation.sort-default.settings",mn="dsh-automation.sort-default.overview";function Ce(e,n){if(e!==void 0)try{let t=e.getItem(n);if(t===null)return;let s=JSON.parse(t);return s.key!=="created"&&s.key!=="planned"||s.direction!=="asc"&&s.direction!=="desc"?void 0:{key:s.key,direction:s.direction}}catch{return}}function Et(e,n,t,s){e.setItem(n,JSON.stringify({key:t,direction:s}))}function Mt(e,n,t,s){let r=new Map;for(let i of e){let o=new Date(i.finishedAt??i.startedAt??i.scheduledFor);if(Number.isNaN(o.getTime()))continue;let a;if(n==="month")a=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}`;else if(n==="week"){let c=ir(o);a=an(c)}else a=an(o);let l=r.get(a)??[];l.push(i),r.set(a,l)}return[...r.entries()].map(([i,o])=>({key:i,label:o[0]===void 0?i:n==="month"?s("history.month",{month:i.replace("-","/")}):n==="week"?s("history.week",{date:i.slice(5).replace("-","/")}):i===an(t)?s("history.today"):i===an(new Date(t.getTime()-864e5))?s("history.yesterday"):s("history.date",{date:i.slice(5).replace("-","/")}),items:o}))}function an(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function ir(e){let n=new Date(e),t=n.getDay(),s=t===0?6:t-1;return n.setHours(0,0,0,0),n.setDate(n.getDate()-s),n}function Lt(e,n=[],t,s=e.permission){let r=Bn(new Date,n,t,s),i=e.schedule,o=e.provider&&e.model?`${e.provider}::${e.model}`:"default",a={...r,name:e.name,prompt:e.prompt,permission:e.permission,maxConcurrentRuns:String(e.maxConcurrentRuns??1),workspaceId:e.workspaceId??r.workspaceId,modelKey:o,reasoningEffort:e.reasoningEffort??"none",timeZone:e.timeZone||i.timeZone||r.timeZone};switch(i.kind){case"once":return{...a,scheduleKind:"once",onceAt:ar(i.at)};case"interval":return{...a,scheduleKind:"interval",everyMinutes:String(i.everyMinutes),intervalAnchor:i.anchor??""};case"hourly":return{...a,scheduleKind:"hourly",hourlyMinute:String(i.minute).padStart(2,"0")};case"daily":return{...a,scheduleKind:"daily",time:i.time};case"weekly":return{...a,scheduleKind:"weekly",time:i.time,weekdays:[...i.weekdays]};case"monthly":return{...a,scheduleKind:"monthly",time:i.time,monthDay:String(i.day)};case"custom":return{...a,scheduleKind:"custom",time:i.time,customDays:String(i.everyDays)}}}function ar(e){let n=new Date(e);if(Number.isNaN(n.getTime()))return At();let t=n.getTimezoneOffset()*6e4;return new Date(n.getTime()-t).toISOString().slice(0,16)}var Ke=class extends Error{code="workspace/picker-unavailable";constructor(){super("workspace picker unavailable"),this.name="WorkspacePickerUnavailableError"}};function Le(e,n){if(!(e===null||typeof e!="object"&&typeof e!="function"))return Reflect.get(e,n)}function fn(e,n){if(e===null||typeof e!="object")return;let t;try{t=Reflect.get(e,"reflect")}catch{t=void 0}let s=Le(t,"get");if(typeof s=="function")try{let i=s.call(t,n);if(i!==void 0)return i}catch{}let r=Le(e,"get");if(typeof r=="function")try{let i=r.call(e,n);if(i!==void 0)return i}catch{return}if(typeof s!="function")try{return Le(e,n)}catch{return}}function Ot(e){if(typeof e=="string"&&e.trim()!=="")return e;if(e===null||typeof e!="object"||Reflect.get(e,"canceled")===!0)return;let n=Reflect.get(e,"path");if(typeof n=="string"&&n.trim()!=="")return n;let t=Reflect.get(e,"filePaths"),s=Array.isArray(t)?t[0]:void 0;return typeof s=="string"&&s.trim()!==""?s:void 0}async function Pt(e){let n=Le(e,"pickDirectory");if(typeof n=="function")return{picked:Ot(await n.call(e))}}async function $n(e,n){let t=fn(e,"workspaces"),s=Le(t,"create");if(typeof s!="function")return!1;try{return await s.call(t,{path:n}),!0}catch{return!1}}async function Vn(e){let n;try{n=Reflect.get(globalThis,"__DSH_DIRECTORY_PICKER__")}catch{n=void 0}let t=Le(n,"pick");if(typeof t=="function")return Ot(await t.call(n));for(let s of["uiWorkspace","dialog","workspaces"]){let r=await Pt(fn(e,s));if(r!==void 0)return r.picked}try{let s=await Pt(Le(e,"workspaces"));if(s!==void 0)return s.picked}catch{}throw new Ke}var dr={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"},Dt=new Map;function lr(e){let n=Dt.get(e);if(n!==void 0)return n;let t=new Intl.DateTimeFormat("en-CA",{...dr,timeZone:e});return Dt.set(e,t),t}function qe(e,n){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;if(n===void 0){let s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,r=`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`;return`${s} ${r}`}try{let s=lr(n).formatToParts(t),r=g=>s.find(m=>m.type===g)?.value,[i,o,a,l,c]=["year","month","day","hour","minute"].map(g=>r(g));return[i,o,a,l,c].some(g=>g===void 0)?e:`${i}-${o}-${a} ${l}:${c}`}catch{return e}}var We="dsh-automation-session-",qn="dsh-automation.sidebar-tab";function hn(e,n){let t=new Map,s=new Map;for(let o of e)t.set(o.id,o.name),o.timeZone!==void 0&&s.set(o.id,o.timeZone);for(let o of n){let a=(o.automationName||"").trim();a!==""&&a!==o.automationId&&!t.has(o.automationId)&&t.set(o.automationId,a)}let r=[],i=new Set;for(let o of e)i.has(o.id)||(r.push(o.id),i.add(o.id));for(let o of n)o.sessionId===void 0||o.sessionId===""||i.has(o.automationId)||(r.push(o.automationId),i.add(o.automationId));return r.map(o=>{let a=t.get(o)??o;return{id:o,name:a,sessions:n.filter(l=>l.automationId===o&&l.sessionId!==void 0&&l.sessionId!=="").slice().sort((l,c)=>Date.parse(c.startedAt??c.scheduledFor)-Date.parse(l.startedAt??l.scheduledFor)).map(l=>({id:l.sessionId,running:l.status==="running"||l.status==="queued",label:qe(l.startedAt??l.scheduledFor,s.get(o))+" - "+a}))}}).filter(o=>o.sessions.length>0)}function gn(e){return e==="active"?"pause":"resume"}function Ut(e){return e.map(n=>({id:n.id,name:n.name,status:n.status,...n.nextRunAt===void 0?{}:{nextRunAt:n.nextRunAt}}))}function Bt(e,n,t){if(e===void 0||e==="")return!1;let s=n.has(e);return t==="only"?s:t==="show"?!0:!s}function yn(e,n){return e==null||e===""||!e.startsWith(We)?!1:!(n??[]).some(t=>t.sessionId===e)}function $t(e){let n=new Set;for(let t of e??[]){let s=t.sessionId;typeof s=="string"&&s!==""&&n.add(s)}return n}var cr=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/;function jn(e,n,t=new Set){if(e.startsWith(We)||t.has(e))return!0;let s=String(n?.title??n?.displayTitle??"");return cr.test(s)}function Ft(e,n=new Set){if(e===void 0||e.blank===!0||e.origin==="im"||e.origin==="subagent")return!1;let t=e.id??"";return!(t.startsWith("im:")||jn(t,e,n))}function Vt(e,n,t,s=new Set){let r=e.byId??{},i=new Set(n?.archivedSessionIds??[]),o=new Set,a=[];for(let c of n?.items??[]){let g=(c.sessionIds??[]).map(m=>r[m]).filter(m=>m!==void 0&&m.id!==void 0&&Ft(m,s)&&!i.has(m.id));for(let m of g)m.id!==void 0&&o.add(m.id);g.length>0&&a.push({id:c.workspaceId??c.id??c.path??c.title??"workspace",label:c.title||c.path||t,sessions:g})}let l=(e.ids??[]).map(c=>r[c]).filter(c=>c!==void 0&&c.id!==void 0&&!o.has(c.id)&&Ft(c,s)&&!i.has(c.id));return l.length>0&&a.push({id:"",label:t,sessions:l}),a}function Kt(e){return e==="channels"||e==="schedule"||e==="tasks"?e:"tasks"}function qt(e,n){let t=e??"",s=n??"";return s!==""&&t!==s}function jt(e){let n=["tasks"];for(let t of e.extraTabIds)t===""||t==="tasks"||t==="schedule"||n.includes(t)||n.push(t);return e.channelsReady&&!n.includes("channels")&&n.push("channels"),n.push("schedule"),n}function Zt(e){return e.extraTabIds.includes(e.tab)?e.tab:e.tab==="channels"&&!e.channelsReady?"tasks":e.tab}function Xt(e,n){if(!(e==null||e===""))return(n!==void 0?n.has(e):e.startsWith(We))?"schedule":e.startsWith("im:")?"channels":"tasks"}function ur(e){return/dsh-codex-ui|michengai-codex-ui|michengai\.codexUi|codex-ui/i.test(String(e??""))}function pr(e){let n=e;return String(n?.options?.locale??n?.options?.id??n?.options?.name??n?.options?.registrant??n?.component?.displayName??n?.component?.name??n?.id??n?.name??"")}function Jt(e){return(e??[]).some(n=>ur(pr(n)))}var Ht=new WeakMap,Wt=new WeakMap;function Yt(e){return e.size===0?"":[...e].sort().join("\0")}function Qt(e,n=new Set){let t=e??{ids:[],byId:{}},s=Yt(n);if(typeof t=="object"&&t!==null){let a=Ht.get(t);if(a!==void 0&&a.key===s)return a.result}let r=(t.ids??[]).filter(a=>{let l=String(a);return!l.startsWith("im:")&&!jn(l,t.byId?.[l],n)}),o=r.length===(t.ids??[]).length?t:{...t,ids:r,byId:Object.fromEntries(r.map(a=>[a,t.byId?.[a]]).filter(a=>a[1]!==void 0))};return typeof t=="object"&&t!==null&&Ht.set(t,{key:s,result:o}),o}function je(e){let n=e?.byId??{};for(let[t,s]of Object.entries(n))if((s?.retainedBy?.mainView??0)>0){let r=s.id?.trim();return r!==void 0&&r!==""?r:t}return null}function mr(e){if(e===null||typeof e!="object")return;let n=e.openSession;if(typeof n=="function")return{openSession:t=>{n.call(e,t)}}}function es(e){let n=mr(fn(e,"uiWorkspace"));return{...n===void 0?{}:{uiWorkspace:n}}}function ns(e){return typeof e.uiWorkspace?.openSession=="function"}function ts(e,n){if(typeof e.uiWorkspace?.openSession=="function"){e.uiWorkspace.openSession(n);return}throw new Error("no client session opener")}function _t(e,n,t){if(e==="")return!1;let s=e.startsWith(We)||e.startsWith("im:")?[n,t]:[t,n];for(let r of s)if(typeof r=="function")try{return r(e),!0}catch{}return!1}async function ss(e){let n=e.id.trim();return n===""?!1:(await e.adopt?.(n).catch(()=>{}),!(e.listed?.(n)===!0)&&e.refresh!==void 0&&await e.refresh().catch(()=>{}),_t(n,e.openRuntime,e.openHost)?!0:(e.refresh!==void 0&&await e.refresh().catch(()=>{}),_t(n,e.openRuntime,e.openHost)))}function fr(e,n=new Set){return e.startsWith("im:")||jn(e,void 0,n)}function os(e,n=new Set){let t=e??{items:[],archivedSessionIds:[]},s=Yt(n);if(typeof t=="object"&&t!==null){let a=Wt.get(t);if(a!==void 0&&a.key===s)return a.result}let r=!1,i=(t.items??[]).map(a=>{let l=(a.sessionIds??[]).filter(c=>!fr(String(c),n));return l.length!==(a.sessionIds??[]).length?(r=!0,{...a,sessionIds:l}):a}),o=r?{...t,items:i}:t;return typeof t=="object"&&t!==null&&Wt.set(t,{key:s,result:o}),o}function rs(e){return e==null||typeof e!="function"&&typeof e!="object"?{}:e}function hr(e){return rs(e).__dshAutomationWrapped===!0}function is(e){let n=new Set,t=e;for(;t!=null&&!n.has(t);){n.add(t);let s=rs(t),r=s.__dshAutomationOriginal??s.__imConnectOriginal;if(r!==void 0&&r!==t){t=r;continue}return s.__dshAutomationWrapped===!0||s.__imConnectWrapped===!0?void 0:t}}function gr(e){let n=e,t=String(n?.options?.id??""),s=String(n?.component?.displayName??n?.component?.name??"");return t==="dsh-automation-native-switcher"||t==="dsh-automation-wrap-bump"||s==="AutomationNativeWorkspaceShell"||s==="AutomationWrapBump"||hr(n?.component)}function as(e){for(let n of e)if(n?.component!==void 0&&!gr(n))return n}function He(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function zt(e,n){let t=He(e),s,r=-1;for(let i of n){let o=He(i);o.length>r&&t!==o&&t.startsWith(`${o}/`)&&(s=i,r=o.length)}return s}function ds(e,n,t){let s=new Map;for(let u of n)for(let y of u.sessionIds??[])s.set(y,u);let r=new Map,i=[];for(let u of e){let y=u.id===void 0?void 0:s.get(u.id),h=y?.workspaceId??y?.id??y?.path;if(y===void 0||h===void 0||h===""){i.push(u);continue}let S=r.get(h)??[];S.push(u),r.set(h,S)}let o=new Map;for(let u of n)u.path!==void 0&&u.path!==""&&o.set(He(u.path),u);let a=new Map;for(let u of n){let y=u.workspaceId??u.id??u.path;if(y===void 0||y===""||!r.has(y))continue;a.set(y,u);let h=u.path,S=new Set;for(;h!==void 0&&h!==""&&!S.has(h);){S.add(h);let N=zt(h,[...o.keys()]);if(N===void 0)break;let M=o.get(He(N)),_=M?.workspaceId??M?.id??M?.path;if(M===void 0||_===void 0||_==="")break;a.set(_,M),h=M.path}}let l=[...a.values()],c=l.map(u=>u.path).filter(u=>u!==void 0&&u!==""),g=u=>u.workspaceId??u.id??u.path??"",m=new Map,x=[];for(let u of l){let y=u.path===void 0?void 0:zt(u.path,c),h=y===void 0?void 0:l.find(N=>N.path!==void 0&&He(N.path)===He(y)),S=h===void 0?void 0:g(h);if(h===void 0||S===void 0||S==="")x.push(u);else{let N=m.get(S)??[];N.push(u),m.set(S,N)}}let A=(u,y)=>(u.title||u.path||"").localeCompare(y.title||y.path||""),f=[],p=(u,y)=>{let h=g(u),S=r.get(h)??[];f.push({id:h,name:u.title||u.path||t,depth:y,keep:S.length===0,sessions:S});for(let N of(m.get(h)??[]).sort(A))p(N,y+1)};for(let u of x.sort(A))p(u,0);return i.length>0&&f.push({id:"",name:t,depth:0,sessions:i}),f}function ls(e,n,t,s="workspace"){let r=n.trim().toLocaleLowerCase(),i=e.map(o=>{if(r===""||o.name.toLocaleLowerCase().includes(r))return o;let a=o.sessions.filter(l=>`${l.title??""} ${l.label??""}`.toLocaleLowerCase().includes(r));return{...o,sessions:a}}).filter(o=>o.sessions.length>0||r===""&&o.keep===!0||r!==""&&o.name.toLocaleLowerCase().includes(r));if(s==="list"){let o=i.flatMap(a=>[...a.sessions]);return t==="time"&&o.sort((a,l)=>Kn(l)-Kn(a)),o.length===0?[]:[{...i[0],name:"",sessions:o}]}return s==="workspace-tree"||t==="manual"?i:[...i].sort((o,a)=>Gt(a)-Gt(o))}function Kn(e){let n=Date.parse(e.updatedAt??"");return Number.isFinite(n)?n:0}function Gt(e){let n=0;for(let t of e.sessions){let s=Kn(t);s>n&&(n=s)}return n}var te=require("react/jsx-runtime");function Ze({children:e,...n}){return(0,te.jsx)("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n,children:e})}function vn(e){return(0,te.jsx)(Ze,{...e,children:(0,te.jsx)("path",{d:"M12 5v14M5 12h14"})})}function cs(e){return(0,te.jsxs)(Ze,{...e,children:[(0,te.jsx)("path",{d:"M19 7v5h-5"}),(0,te.jsx)("path",{d:"M18.1 15.5A7.5 7.5 0 1 1 19 12"})]})}function us(e){return(0,te.jsxs)(Ze,{...e,children:[(0,te.jsx)("rect",{x:"4",y:"5.5",width:"16",height:"14",rx:"2"}),(0,te.jsx)("path",{d:"M8 3.8v3.4M16 3.8v3.4M4 9.5h16"})]})}function ps(e){return(0,te.jsxs)(Ze,{...e,children:[(0,te.jsx)("circle",{cx:"12",cy:"12",r:"8.25"}),(0,te.jsx)("path",{d:"M12 10.4V16"}),(0,te.jsx)("path",{d:"M12 7.6h.01"})]})}function ms(e){return(0,te.jsx)(Ze,{...e,children:(0,te.jsx)("path",{d:"M5.5 6.5h13v9.2H9.2L5.5 18.8V6.5Z"})})}function fs(e){return(0,te.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,"aria-hidden":"true",focusable:"false",...e,children:(0,te.jsx)("path",{fill:"currentColor",d:"M8 0a8 8 0 0 0-2.53 15.59c.4.074.547-.173.547-.385 0-.19-.007-.693-.01-1.36-2.226.484-2.695-1.073-2.695-1.073-.364-.924-.89-1.17-.89-1.17-.726-.496.055-.486.055-.486.803.056 1.225.824 1.225.824.714 1.223 1.872.87 2.328.665.072-.517.28-.87.508-1.07-1.777-.202-3.645-.888-3.645-3.956 0-.874.31-1.588.823-2.148-.083-.202-.357-1.017.078-2.12 0 0 .672-.215 2.2.82A7.65 7.65 0 0 1 8 4.8c.68.003 1.365.092 2.004.27 1.527-1.035 2.197-.82 2.197-.82.437 1.103.162 1.918.08 2.12.513.56.822 1.274.822 2.148 0 3.076-1.872 3.752-3.654 3.95.288.248.544.735.544 1.482 0 1.07-.01 1.932-.01 2.195 0 .214.144.463.55.384A8.001 8.001 0 0 0 8 0Z"})})}function hs(e){return(0,te.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...e,children:(0,te.jsx)("path",{d:"M9.5 2.5 13.5 6.5 6 14H2v-4z"})})}var Pe=require("react"),yr=on(require("@deepseek-ai/dsh-client-ui-primitives"),1);function bn(e,n){return function(s){return e(s)??n(s)}}function X(e,...n){for(let t of n){let s=e[t];if(typeof s=="function")return s}return function(){return null}}var J=yr;function vr(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 3h4v3H3V3Zm6 1h4M3 10h4v3H3v-3Zm6 1.5h4M7 4.5h2M7 11.5h2",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"}))}function br(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"}))}function wr(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 6.5h10v6H3v-6Zm1.2-2.5h7.6L13 6.5H3L4.2 4Zm2.3 5.2 1.3 1.3 2.6-2.6",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"}))}var Xe=X(J,"IconEllipsisOutlineRegular"),gs=X(J,"IconSettingsOutlineRegular"),_e=X(J,"IconArchiveOutlineRegular"),ys=X(J,"IconBranchOutlineRegular"),vs=X(J,"IconEditOutlineRegular"),Zn=X(J,"IconTrashOutlineRegular"),Ri=X(J,"IconCheckOutlineRegular"),Ei=X(J,"IconChevronDownOutlineRegular"),Mi=X(J,"IconListPenOutlineRegular"),bs=X(J,"IconSearchOutlineRegular"),ws=X(J,"IconCloseFillRegular"),wn=X(J,"IconSlidersTwoOutlineRegular"),Sn=X(J,"IconFolderCloseRegular"),Ss=X(J,"IconFolderOpenRegular"),ks=X(J,"IconTriangleRightFillRegular"),Xn=X(J,"IconUnarchiveOutlineRegular"),kn=bn(X(J,"IconWorkspaceTreeOutlineRegular"),vr),ze=bn(X(J,"IconFlatListOutlineRegular"),br),Li=X(J,"IconChevronsUpDownOutlineRegular"),Ne=X(J,"IconClockOutlineRegular"),xs=X(J,"IconCopyOutlineRegular"),As=X(J,"IconArchiveOffOutlineRegular"),Ts=bn(X(J,"IconArchiveCheckOutlineRegular"),wr);var ie=require("@deepseek-ai/dsh-client-ui-primitives");var Jn=on(require("react"),1),Is=require("@deepseek-ai/dsh-client-ui-primitives"),Yn={width:22,minWidth:22,height:22,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"var(--dsw-radius-sm, 8px)"},Cs=Jn.default.forwardRef(function(n,t){let{className:s,rows:r,...i}=n;return Jn.default.createElement("textarea",{...i,ref:t,className:["dsh-st-textarea",s].filter(Boolean).join(" "),rows:r||4})}),Ge=Is.Input;function xn(e,n){let t=e.target;if(!(t instanceof Element)||t.getAttribute("aria-hidden")!=="true")return;let s=t.parentElement?.querySelector('[role="dialog"]');!(s instanceof HTMLElement)||!s.classList.contains(n)||e.stopPropagation()}var le=on(require("react"),1),An=require("@deepseek-ai/dsh-client-ui-primitives");function Qn(e){return{id:e.value,label:e.label,...e.disabled!==void 0?{disabled:e.disabled}:{},...e.danger!==void 0?{danger:e.danger}:{}}}function fe(e){let[n,t]=le.useState(!1),s=le.useRef(null),r=e.options??[];le.useEffect(()=>{if(!n)return;let c=s.current?.getBoundingClientRect().width??0;return c>0&&document.documentElement.style.setProperty("--dsh-st-menu-width",`${Math.round(c)}px`),()=>{document.documentElement.style.removeProperty("--dsh-st-menu-width")}},[n]),le.useEffect(()=>{if(!n||typeof window>"u")return;let c=g=>{g.key==="Escape"&&(g.stopPropagation(),t(!1))};return window.addEventListener("keydown",c,!0),()=>{window.removeEventListener("keydown",c,!0)}},[n]);let i=le.useMemo(()=>e.groups!==void 0&&e.groups.length>0?e.groups.flatMap(c=>[{type:"label",id:`label-${c.id}`,text:c.label},...c.options.map(Qn)]):r.map(Qn),[r,e.groups]),o=e.footer?.map(Qn),a=r.find(c=>c.value===e.value)??e.groups?.flatMap(c=>[...c.options]).find(c=>c.value===e.value),l=a?a.label:e.placeholder??e.label??"";return le.createElement("div",{ref:s,className:["dsh-st-menu-select-wrap",e.compact===!0?"is-compact":"",e.className].filter(Boolean).join(" ")},le.createElement(An.Menu,{open:n,onClose:()=>{t(!1)},onSelect:c=>{if(e.footer?.some(g=>g.value===c)===!0){e.onFooter?.(c),t(!1);return}e.onChange(c),t(!1)},selectedId:e.value,align:"start",portal:!0,dense:!0,listClassName:["dsh-st-form-menu",e.listClassName].filter(Boolean).join(" "),...o!==void 0?{footer:o}:{},anchor:le.createElement(An.Button,{variant:"outline",...e.compact===!0?{size:"sm"}:{},role:"combobox","aria-label":e.label??(typeof l=="string"?l:a?.text)??e.placeholder??"","aria-expanded":n,disabled:e.disabled,className:["dsh-st-menu-select-trigger",n?"is-open":""].filter(Boolean).join(" "),onClick:()=>{e.disabled||t(c=>!c)}},le.createElement("span",{className:"dsh-st-menu-select-label"},l),le.createElement("svg",{className:"dsh-st-menu-select-arrow",viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:4,transition:"transform 150ms ease",transform:n?"rotate(180deg)":"none"}},le.createElement("path",{d:"m4 6 4 4 4-4"}))),items:i}))}var pe=require("react");var Sr=new Map([["read-only",["permission.readOnly","Read Only"]],["workspace-write",["permission.workspaceWrite","Workspace Write"]],["danger-full-access",["permission.fullAccess","Full access"]]]);function Ns(e,n){let t=Sr.get(e.value);return t!==void 0&&(e.name===e.value||e.name===t[1])?n(t[0]):e.name||e.value}function Rs(e,n){return e!==n&&n==="danger-full-access"}var be=require("@deepseek-ai/dsh-client-ui-primitives");var b=require("react/jsx-runtime");function kr(e,n,t,s){if(e==="deepseek-account"){let r=t("provider.account");return r&&r!=="provider.account"?r:s("form.providerAccount")}return n}function xr(e,n){return(e==="deepseek-account"?0:e==="deepseek-official"?1:2)-(n==="deepseek-account"?0:n==="deepseek-official"?1:2)}function Ar(e){return(e.provider==="deepseek-account"||e.provider==="deepseek-official")&&e.model==="deepseek-flash"?(0,b.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,b.jsx)("span",{children:e.label}),(0,b.jsx)(be.Tag,{tone:"info",children:"1017"})]}):e.label}var Tr=[1,2,3,4,5,6,7],Ir=["once","interval","hourly","daily","weekly","monthly","custom"],Cr=Array.from({length:24},(e,n)=>String(n).padStart(2,"0")),Ls=Array.from({length:60},(e,n)=>String(n).padStart(2,"0"));function Ps({t:e,permissionT:n,modelT:t,busy:s,workspaces:r,models:i,modelFailures:o,defaultModel:a,skills:l,permissions:c,defaultPermission:g,draft:m,editing:x,onClose:A,onSubmit:f,onAddWorkspace:p}){let[u,y]=(0,pe.useState)(()=>({...Bn(new Date,r,a,g),...m})),[h,S]=(0,pe.useState)(),[N,M]=(0,pe.useState)(),[_,se]=(0,pe.useState)(!1),[re,z]=(0,pe.useState)(!1),[Q,V]=(0,pe.useState)(0),[F,G]=(0,pe.useState)(0),[W,ee]=(0,pe.useState)(),ce=(0,pe.useRef)(null),I=(0,pe.useRef)(0);(0,pe.useEffect)(()=>{let d=B=>{if(B.key==="Escape"&&document.querySelector('[role="menu"]')===null){if(B.preventDefault(),B.stopPropagation(),B.stopImmediatePropagation(),N!==void 0){se(!1),M(void 0);return}A()}},T=B=>{xn(B,"dsh-st-create-dialog")};return window.addEventListener("keydown",d,!0),document.addEventListener("click",T,!0),()=>{window.removeEventListener("keydown",d,!0),document.removeEventListener("click",T,!0)}},[N,A]);let R=d=>{y(T=>({...T,...d})),S(void 0)},H=r.some(d=>d.id===u.workspaceId),L=async()=>{if(!(p===void 0||re)){z(!0),S(void 0),document.activeElement instanceof HTMLElement&&document.activeElement.blur();try{let d=await p();d!==void 0&&R({workspaceId:d})}catch(d){d instanceof Ke?S(e("form.workspaceUnavailable")):d instanceof Error&&d.message!==""?S(d.message):S(e("form.addWorkspaceFailed"))}finally{z(!1)}}},ue=d=>{if(Rs(u.permission,d)){se(!1),M(d);return}R({permission:d})},he=async d=>{d?.preventDefault();try{await f(u)}catch(T){if(T instanceof de){S(e(T.key));return}S(T instanceof Error?T.message:e("error.action"))}},ae=u.onceAt.slice(0,10),oe=u.onceAt.slice(11,16)||"09:00",me=Nr(new Date),ge=i.find(d=>`${d.provider}::${d.model}`===u.modelKey)?.reasoning,Z=Un(u.prompt,Q),ne=Z===void 0||W===Z.query?[]:St(l,Z.query),ye=Math.min(F,Math.max(ne.length-1,0)),we=d=>{I.current=d,V(d)};(0,pe.useEffect)(()=>{let d=document.querySelector('.dsh-st-skill-menu [aria-selected="true"]');d instanceof HTMLElement&&d.scrollIntoView({block:"nearest"})},[ye,Z?.query]);let k=d=>{let T=kt(u.prompt,I.current,dn(d));R({prompt:T.text}),ee(void 0),queueMicrotask(()=>{let B=ce.current;B!=null&&(B.focus(),B.setSelectionRange(T.caret,T.caret),we(T.caret))})};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(be.Modal,{open:!0,className:"dsh-st-create-dialog",title:e(x===!0?"modal.edit":"modal.title"),closeLabel:e("form.cancel"),onClose:A,footer:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(be.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:s,onClick:A,children:e("form.cancel")}),(0,b.jsx)(be.Button,{variant:"primary",className:"dsh-st-modal-action",type:"submit",form:"dsh-st-create-form",disabled:s||re||!H,children:e("modal.save")})]}),children:(0,b.jsxs)("form",{id:"dsh-st-create-form",className:"dsh-st-form",onSubmit:d=>{he(d)},children:[(0,b.jsx)("p",{children:e("form.subtitle")}),(0,b.jsxs)("label",{className:"dsh-st-field",children:[e("form.name"),(0,b.jsx)(Ge,{value:u.name,placeholder:e("form.namePlaceholder"),onChange:d=>R({name:d.target.value})})]}),(0,b.jsxs)("div",{className:"dsh-st-plan-row",children:[(0,b.jsxs)("div",{className:"dsh-st-field",children:[e("form.planTime"),(0,b.jsxs)("div",{className:"dsh-st-inline",children:[(0,b.jsx)(fe,{value:u.scheduleKind,options:Ir.map(d=>({value:d,label:e(`form.${d}`)})),onChange:d=>R({scheduleKind:d})}),u.scheduleKind==="once"&&(0,b.jsx)(Ge,{type:"date",min:me,value:ae,onChange:d=>R({onceAt:Ms(`${d.target.value}T${oe}`)})}),(u.scheduleKind==="once"||u.scheduleKind==="daily"||u.scheduleKind==="weekly"||u.scheduleKind==="monthly")&&(0,b.jsx)(Es,{value:u.scheduleKind==="once"?oe:u.time,onChange:d=>{u.scheduleKind==="once"?R({onceAt:Ms(`${ae}T${d}`)}):R({time:d})}}),u.scheduleKind==="interval"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.every")}),(0,b.jsxs)("span",{className:"dsh-st-amount",children:[(0,b.jsx)(Ge,{type:"number",min:1,value:u.everyMinutes,onChange:d=>R({everyMinutes:d.target.value})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.minutes")})]})]}),u.scheduleKind==="hourly"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(fe,{value:u.hourlyMinute,options:Ls.map(d=>({value:d,label:d})),onChange:d=>R({hourlyMinute:d})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.minutesShort")})]}),u.scheduleKind==="monthly"&&(0,b.jsx)(fe,{value:u.monthDay,options:Array.from({length:31},(d,T)=>{let B=String(T+1);return{value:B,label:e("form.monthDay",{day:B})}}),onChange:d=>R({monthDay:d})}),u.scheduleKind==="custom"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.every")}),(0,b.jsxs)("span",{className:"dsh-st-amount",children:[(0,b.jsx)(Ge,{type:"number",min:1,value:u.customDays,onChange:d=>R({customDays:d.target.value})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.daysShort")})]}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.atTime")}),(0,b.jsx)(Es,{value:u.time,onChange:d=>R({time:d})})]})]}),u.scheduleKind==="interval"&&(0,b.jsx)("span",{className:"dsh-st-plan-hint",children:e("form.intervalHint")}),u.scheduleKind==="custom"&&(0,b.jsx)("span",{className:"dsh-st-plan-hint",children:e("form.customHint")})]}),(0,b.jsxs)("label",{className:"dsh-st-field dsh-st-concurrency",title:e("form.maxConcurrentRunsHint"),children:[e("form.maxConcurrentRuns"),(0,b.jsx)(Ge,{type:"number",min:1,step:1,value:u.maxConcurrentRuns,onChange:d=>R({maxConcurrentRuns:d.target.value})})]})]}),u.scheduleKind==="weekly"&&(0,b.jsx)("div",{className:"dsh-st-weekdays",children:Tr.map(d=>(0,b.jsx)(be.Checkbox,{checked:u.weekdays.includes(d),label:e(`day.${d}`),onChange:T=>R({weekdays:T?[...u.weekdays,d]:u.weekdays.filter(B=>B!==d)})},d))}),(0,b.jsxs)("div",{className:"dsh-st-settings",children:[(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldWorkspace")}),r.length===0?(0,b.jsxs)("div",{className:"dsh-st-workspace-empty",children:[(0,b.jsx)(be.Button,{variant:"primary",icon:(0,b.jsx)(vn,{width:14,height:14}),disabled:re,onClick:()=>{L()},children:e("form.addWorkspace")}),(0,b.jsx)("span",{className:"dsh-st-workspace-note",children:e("form.workspaceRequired")})]}):(0,b.jsx)(fe,{value:u.workspaceId,label:e("form.fieldWorkspace"),placeholder:e("form.workspace"),options:r.map(d=>({value:d.id,label:d.title})),footer:[{value:"add-workspace",label:e("form.addWorkspace"),disabled:re}],onFooter:()=>{L()},onChange:d=>R({workspaceId:d})})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldModel")}),(0,b.jsx)(fe,{value:u.modelKey,label:e("form.fieldModel"),groups:Array.from(i.reduce((d,T)=>{let B=kr(T.provider,T.providerLabel,t,e),Ie=d.get(T.provider)??{label:B,options:[]};return Ie.options.push({value:`${T.provider}::${T.model}`,label:Ar(T),text:T.label}),d.set(T.provider,Ie),d},new Map)).sort(([d],[T])=>xr(d,T)).map(([d,T])=>({id:d,label:T.label,options:T.options})),onChange:d=>{let T=i.find(B=>`${B.provider}::${B.model}`===d);R({modelKey:d,reasoningEffort:T?.reasoning?.defaultEffort??"none"})}})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldEffort")}),(0,b.jsx)(fe,{disabled:ge===void 0,value:ge===void 0?"":u.reasoningEffort,label:e("form.fieldEffort"),placeholder:t("effort.providerDefault"),options:ge===void 0?[]:[...ge.defaultEffort===void 0?[{value:"none",label:t("effort.providerDefault")}]:[],...ge.efforts.map(d=>({value:d.id,label:d.name}))],onChange:d=>R({reasoningEffort:d})})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldPermission")}),(0,b.jsx)(fe,{value:u.permission,options:c.map(d=>({value:d.value,label:Ns(d,e)})),onChange:d=>ue(d)})]})]}),(0,b.jsxs)("div",{className:"dsh-st-field",children:[(0,b.jsxs)("span",{className:"dsh-st-prompt-label",children:[e("form.prompt"),(0,b.jsx)("em",{children:e("form.slashHint")})]}),(0,b.jsxs)("div",{className:"dsh-st-prompt-anchor",children:[Z!==void 0&&W!==Z.query&&(0,b.jsx)("div",{className:"dsh-st-skill-menu",role:"listbox",children:ne.length===0?(0,b.jsx)("p",{children:e("form.slashEmpty")}):ne.map((d,T)=>(0,b.jsxs)("button",{type:"button",role:"option","aria-selected":T===ye,onMouseDown:B=>B.preventDefault(),onClick:()=>k(d),children:[(0,b.jsx)("span",{children:d.name}),(0,b.jsx)("code",{children:dn(d)})]},d.id))}),(0,b.jsxs)("div",{className:"dsh-st-prompt-card",children:[(0,b.jsx)("div",{className:"dsh-st-prompt-backdrop","aria-hidden":"true",children:xt(u.prompt,l).map((d,T)=>d.kind==="skill"?(0,b.jsx)("span",{className:"dsh-st-skill-token",children:d.text},T):(0,b.jsx)("span",{children:d.text},T))}),(0,b.jsx)(Cs,{ref:ce,spellCheck:!1,className:"dsh-st-prompt-input",value:u.prompt,placeholder:e("form.promptPlaceholder"),rows:4,onChange:d=>{we(d.target.selectionStart),R({prompt:d.target.value}),ee(void 0)},onSelect:d=>we(d.currentTarget.selectionStart),onScroll:d=>{let T=d.currentTarget.closest(".dsh-st-prompt-card")?.querySelector(".dsh-st-prompt-backdrop");T instanceof HTMLElement&&(T.scrollTop=d.currentTarget.scrollTop)},onKeyDown:d=>{if(Z!==void 0){if(d.key==="Escape"){d.preventDefault(),ee(Z.query);return}if(ne.length!==0){if(d.key==="ArrowDown")d.preventDefault(),G(T=>(Math.min(T,ne.length-1)+1)%ne.length);else if(d.key==="ArrowUp")d.preventDefault(),G(T=>(Math.min(T,ne.length-1)+ne.length-1)%ne.length);else if(d.key==="Enter"||d.key==="Tab"){d.preventDefault();let T=ne[ye];T!==void 0&&k(T)}}}}})]})]})]}),o.map(d=>(0,b.jsx)("p",{className:"dsh-st-error",children:t("warning.groupLoad",{name:d.providerLabel,message:d.message})},d.provider)),h!==void 0&&(0,b.jsx)("p",{className:"dsh-st-error",children:h})]})}),(0,b.jsx)(be.RiskConfirmation,{open:N!==void 0,title:n("confirm.title"),description:n("confirm.description"),acknowledgeLabel:n("confirm.acknowledge"),cancelLabel:n("confirm.cancel"),closeLabel:n("confirm.cancel"),confirmLabel:n("confirm.enable"),acknowledged:_,onAcknowledgedChange:se,onCancel:()=>{se(!1),M(void 0)},onConfirm:()=>{!_||N===void 0||(R({permission:N}),se(!1),M(void 0))}})]})}function Es({value:e,onChange:n}){let[t,s]=e.split(":");return(0,b.jsxs)("span",{className:"dsh-st-time",children:[(0,b.jsx)(fe,{value:t,options:Cr.map(r=>({value:r,label:r})),onChange:r=>n(`${r}:${s}`)}),(0,b.jsx)("span",{className:"dsh-st-time-sep",children:":"}),(0,b.jsx)(fe,{value:s,options:Ls.map(r=>({value:r,label:r})),onChange:r=>n(`${t}:${r}`)})]})}function Nr(e){let n=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-n).toISOString().slice(0,10)}function Ms(e){let n=new Date(e),t=new Date;if(!Number.isFinite(n.getTime())||n.getTime()>t.getTime())return e;let s=new Date(t.getTime()+6e4);s.setSeconds(0,0);let r=s.getTimezoneOffset()*6e4;return new Date(s.getTime()-r).toISOString().slice(0,16)}var Os=require("react"),Je=require("@deepseek-ai/dsh-client-ui-primitives");var Re=require("react/jsx-runtime");function Ds({target:e,t:n,busy:t,onCancel:s,onConfirm:r}){return(0,Os.useEffect)(()=>{if(e===void 0)return;let i=a=>{a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation(),s())},o=a=>{xn(a,"dsh-st-delete-dialog")};return window.addEventListener("keydown",i,!0),document.addEventListener("click",o,!0),()=>{window.removeEventListener("keydown",i,!0),document.removeEventListener("click",o,!0)}},[s,e]),(0,Re.jsx)(Je.Modal,{open:e!==void 0,className:"dsh-st-delete-dialog",title:n("card.confirmDelete"),...e===void 0?{}:{description:`${e.name} ${n("card.confirmDeleteHint")}`},closeLabel:n("card.cancel"),onClose:s,footer:(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)(Je.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:t,onClick:s,children:n("card.cancel")}),(0,Re.jsx)(Je.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:t,onClick:r,children:n("card.confirm")})]})})}var Ye=null,et=new Set;function Fs(e){Ye=e;for(let n of[...et])n(Ye)}function nt(){let e=Ye;return Ye=null,e}function Hs(){return Ye}function Ws(e){return et.add(e),()=>{et.delete(e)}}function _s(e){let n=document.querySelector("[data-composer-seat] textarea");return n instanceof HTMLTextAreaElement?(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set?.call(n,e),n.dispatchEvent(new InputEvent("input",{bubbles:!0})),n.focus(),!0):!1}function Qe(e){if(typeof e!="object"||e===null||!("ok"in e))throw new Error("\u81EA\u52A8\u5316\u4E3B\u673A\u8FD4\u56DE\u4E86\u65E0\u6548\u54CD\u5E94\u3002");let n=e;if(n.ok===!0&&"value"in n)return n.value;if(n.ok===!1&&"error"in n){let t=n.error;throw new Error(t?.message??"\u81EA\u52A8\u5316\u8BF7\u6C42\u5931\u8D25\u3002")}throw new Error("\u81EA\u52A8\u5316\u4E3B\u673A\u8FD4\u56DE\u4E86\u65E0\u6548\u54CD\u5E94\u3002")}var en="/dsh-automation",Gs=15e3,Rr=2e3,Us=[1,2,4],zs=Us.length+1,Er=5*60*1e3,Mr=24*60*60*1e3;function Lr(e){return(e??[]).some(n=>n.status==="running"||n.status==="queued")?Rr:Gs}function tt(e,n){return n>0?Lr(e):Gs}function st(e){let n=e instanceof Error?e.message:String(e);return/failed to fetch|networkerror|load failed|network request failed/i.test(n)}function Pr(e,n){let t=Date.parse(n),r=(Number.isFinite(t)?t:Date.now())-Mr;return[...new Set(e.filter(i=>{if(i.status==="queued"||i.status==="running")return!0;let o=Date.parse(i.finishedAt??i.startedAt??i.scheduledFor);return Number.isFinite(o)&&o>=r}).map(i=>i.sessionId).filter(i=>i!==void 0&&i!==""))].sort()}function Bs(e,n,t={}){let s=!1,r=0,i=e.source.getSnapshot().phase==="loading",o,a,l=0,c=0,g=0,m,x,A=!1,f=h=>{a=h,l=0,c=r,g=0,m=void 0},p=h=>{let S=e.source.getSnapshot().snapshot,N=h?.list?.getSnapshot();if(S===void 0||N===void 0||h?.refresh===void 0)return;let M=new Set([...N.ids??[],...Object.keys(N.byId??{})]);return Pr(S.runs,S.serverNow).filter(_=>!M.has(_)).join("\0")},u=()=>{if(s)return;let h=n();h!==o&&(o=h,f());let S=p(h);if(S===void 0)return;if(S===""){f();return}if(S!==a&&f(S),l>=zs){if((t.now??Date.now)()<g)return;f(S)}if(r<c)return;if(x!==void 0){A=!0;return}let N=l;l+=1;let M=Us[N];c=M===void 0?Number.POSITIVE_INFINITY:r+M,l>=zs&&(g=(t.now??Date.now)()+Er),x=Promise.resolve().then(async()=>{await h.refresh()}).catch(_=>{!s&&m!==S&&(m=S,console.warn("[dsh-automation] \u5237\u65B0 Host \u4F1A\u8BDD\u5217\u8868\u5931\u8D25",_))}).finally(()=>{x=void 0,!(s||!A)&&(A=!1,u())})},y=e.source.subscribe(()=>{e.source.getSnapshot().phase==="loading"?i=!0:i&&(i=!1,r+=1),u()},{background:!0});return u(),()=>{s=!0,A=!1,y()}}function $s(e){let n={phase:"idle"},t,s,r=()=>{},i=new Set,o=new Set,a=()=>{if(s!==void 0&&clearInterval(s),i.size===0){s=void 0;return}s=setInterval(()=>{m().catch(()=>{})},tt(n.snapshot?.runs,o.size))},l=()=>{if(r(),o.size===0)return;let f=()=>{m().catch(()=>{})},p=()=>{document.visibilityState==="visible"&&f()};typeof window<"u"&&window.addEventListener("focus",f),typeof document<"u"&&document.addEventListener("visibilitychange",p),r=()=>{typeof window<"u"&&window.removeEventListener("focus",f),typeof document<"u"&&document.removeEventListener("visibilitychange",p),r=()=>{}}},c=f=>{let p=tt(n.snapshot?.runs,o.size);n=f,i.size>0&&p!==tt(n.snapshot?.runs,o.size)&&a();for(let u of[...i])u()},g={getSnapshot:()=>n,subscribe:(f,p={})=>{let u=i.size>0,y=o.size>0;return i.add(f),p.background!==!0&&o.add(f),(!u||p.background!==!0&&!y)&&queueMicrotask(()=>{i.size>0&&m().catch(()=>{})}),a(),o.size>0&&!y&&l(),()=>{i.delete(f),o.delete(f),i.size===0&&s!==void 0?(clearInterval(s),s=void 0):i.size>0&&a(),o.size===0&&r()}}},m=async()=>{if(t!==void 0)return t;let f=n.snapshot;return c(f===void 0?{phase:"loading"}:{phase:"loading",snapshot:f,...n.refreshedAt===void 0?{}:{refreshedAt:n.refreshedAt}}),t=(async()=>{try{let p=await e.call(en,"snapshot",{sessionId:"settings"}),u=Qe(p);c({phase:"ready",snapshot:u,refreshedAt:Date.now()})}catch(p){let u=p instanceof Error?p.message:String(p);throw c(f===void 0?{phase:"error",error:u}:{phase:"error",snapshot:f,error:u,...n.refreshedAt===void 0?{}:{refreshedAt:n.refreshedAt}}),p}finally{t=void 0}})(),t},x=async(f,p)=>{try{return await e.call(en,f,p)}catch(u){if(!st(u))throw u;return await e.call(en,f,p)}},A=async(f,p,u)=>{Qe(await x(f,p));let y=()=>{u!==void 0&&n.snapshot!==void 0&&c({phase:"ready",snapshot:u(n.snapshot),refreshedAt:Date.now()})},h=t;y(),h!==void 0&&(await h.catch(()=>{}),y());try{await m()}catch{}};return{source:g,refresh:m,async createAutomation(f){await A("create",{sessionId:"settings",input:f})},async mutateAutomation(f,p){await A("mutate",{sessionId:"settings",automationId:f,mutation:p},p==="delete"?y=>({...y,automations:y.automations.filter(h=>h.id!==f)}):y=>({...y,automations:y.automations.map(h=>h.id===f?{...h,status:p==="pause"?"paused":"active"}:h)}))},async updateAutomation(f,p){await A("update",{sessionId:"settings",automationId:f,input:p})},async runNow(f){await A("run-now",{sessionId:"settings",automationId:f})},async markRunRead(f){await A("mark-read",{sessionId:"settings",runId:f})},async registerWorkspace(f){let p=Qe(await e.call(en,"register-workspace",{path:f}));return await m(),p},async adoptSession(f){Qe(await e.call(en,"adopt-session",{sessionId:f}))},async forgetSession(f){await A("forget-session",{sessionId:f},p=>({...p,runs:p.runs.map(u=>{if(u.sessionId!==f)return u;let{sessionId:y,...h}=u;return h})}))},async forgetAutomationSessions(f){await A("forget-automation-sessions",{automationId:f},p=>({...p,runs:p.runs.map(u=>{if(u.automationId!==f)return u;let{sessionId:y,...h}=u;return h})}))}}}var ot=require("react"),Ue=require("@deepseek-ai/dsh-client-ui-primitives");var Se=require("react/jsx-runtime"),Or=[["created","desc"],["created","asc"],["planned","asc"],["planned","desc"]];function Tn({t:e,storage:n,storageKey:t,sortKey:s,sortDirection:r,onSelect:i,iconOnly:o=!1,className:a}){let[l,c]=(0,ot.useState)(!1),[g,m]=(0,ot.useState)(()=>Ce(n,t)),x=e(s==="planned"?`sort.planned.${r}`:`sort.created.${r}`),A=g?.key===s&&g.direction===r,f=()=>{n===void 0||A||(Et(n,t,s,r),m({key:s,direction:r}))},p=[...Or.map(([y,h])=>({id:`${y}-${h}`,label:e(y==="planned"?`sort.planned.${h}`:`sort.created.${h}`)})),...n===void 0?[]:[{type:"separator",id:"sort-default-sep"},{id:"save-default",label:e(A?"sort.default.saved":"sort.default.save")}]],u=o?(0,Se.jsx)(Ue.Tooltip,{label:x,side:"bottom",delayMs:500,disabled:l,portal:!0,children:(0,Se.jsx)("button",{type:"button",className:l?"dsh-st-n-head-btn is-on":"dsh-st-n-head-btn","aria-label":x,"aria-expanded":l,onClick:()=>c(y=>!y),children:(0,Se.jsx)(wn,{size:16})})}):(0,Se.jsxs)(Ue.Button,{variant:"outline",size:"sm",role:"combobox","aria-label":x,"aria-expanded":l,className:["dsh-st-menu-select-trigger",l?"is-open":""].filter(Boolean).join(" "),onClick:()=>c(y=>!y),children:[(0,Se.jsx)("span",{className:"dsh-st-menu-select-label",children:x}),(0,Se.jsx)("svg",{className:"dsh-st-menu-select-arrow",viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:4,transition:"transform 150ms ease",transform:l?"rotate(180deg)":"none"},children:(0,Se.jsx)("path",{d:"m4 6 4 4 4-4"})})]});return(0,Se.jsx)("div",{className:["dsh-st-menu-select-wrap",a].filter(Boolean).join(" "),style:{display:"inline-flex",verticalAlign:"middle"},children:(0,Se.jsx)(Ue.Menu,{open:l,onClose:()=>c(!1),selectedId:`${s}-${r}`,align:o?"end":"start",portal:!0,dense:!0,anchor:u,items:p,onSelect:y=>{if(y==="save-default"){f(),c(!1);return}let[h,S]=y.split("-");i(h,S),c(!1)}})})}var In="dsh-automation:open-task-settings",rt="dsh-automation:pending-task-settings";function it(e){if(typeof e!="object"||e===null)return;let n=e;if(!(typeof n.name!="string"||n.name.trim()===""||!Array.isArray(n.sessionIds)||n.sessionIds.some(t=>typeof t!="string"))&&!(n.automationId!==void 0&&(typeof n.automationId!="string"||n.automationId.trim()==="")))return{...typeof n.automationId=="string"?{automationId:n.automationId}:{},name:n.name,sessionIds:[...n.sessionIds]}}function Dr(e,n){try{e?.setItem(rt,JSON.stringify(n))}catch{}}function at(e){typeof window>"u"||(Dr(window.sessionStorage,e),window.dispatchEvent(new CustomEvent(In,{detail:e})))}function Vs(e){if(e!==void 0)try{let n=e.getItem(rt);return n===null?void 0:it(JSON.parse(n))}catch{return}}function Ks(e){try{e?.removeItem(rt)}catch{}}function qs(e,n,t){if(e.automationId!==void 0){let a=n.find(l=>l.id===e.automationId);if(a!==void 0)return a}let s=new Set(e.sessionIds),r=t.find(a=>a.sessionId!==void 0&&s.has(a.sessionId))?.automationId,i=n.find(a=>a.id===r);if(i!==void 0)return i;let o=n.filter(a=>a.name===e.name);return o.length===1?o[0]:void 0}var w=require("react/jsx-runtime");var Cn=typeof window>"u"?void 0:window.localStorage,js=typeof window>"u"?void 0:window.sessionStorage,Fr=[{name:"\u6BCF\u65E5\u56DE\u5F52\u68C0\u67E5",scheduleKind:"daily",time:"09:00",weekdays:[1,2,3,4,5]},{name:"\u6BCF\u5468\u4F9D\u8D56\u5DE1\u68C0",scheduleKind:"weekly",time:"10:00",weekdays:[1]},{name:"\u5DE5\u4F5C\u65E5\u65E9\u62A5",scheduleKind:"weekly",time:"08:00",weekdays:[1,2,3,4,5]}];function Zs({t:e,permissionT:n,modelT:t,runtime:s,closeSettings:r,addWorkspace:i}){let o=(0,Y.useSyncExternalStore)(s.source.subscribe,s.source.getSnapshot,s.source.getSnapshot),[a,l]=(0,Y.useState)("mine"),[c,g]=(0,Y.useState)(""),[m,x]=(0,Y.useState)(!1),[A,f]=(0,Y.useState)(),[p,u]=(0,Y.useState)(),[y,h]=(0,Y.useState)(),[S,N]=(0,Y.useState)(!1),[M,_]=(0,Y.useState)(),[se,re]=(0,Y.useState)("day"),[z,Q]=(0,Y.useState)("all"),[V,F]=(0,Y.useState)("all"),[G,W]=(0,Y.useState)(()=>Ce(Cn,pn)?.key??"created"),[ee,ce]=(0,Y.useState)(()=>Ce(Cn,pn)?.direction??"desc"),[I,R]=(0,Y.useState)(()=>Vs(js)),H=(0,Y.useMemo)(()=>new Date(o.snapshot?.serverNow??Date.now()),[o.snapshot?.serverNow,o.refreshedAt]),L=o.snapshot,ue=L?.workspaces??[],he=L?.models??[],ae=L?.permissions??[],oe=L?.defaultPermission??"",me=un((L?.automations??[]).filter(k=>c.trim()===""||`${k.name} ${k.prompt}`.toLowerCase().includes(c.trim().toLowerCase())),G,ee),ke=(L?.runs??[]).filter(k=>!(z!=="all"&&k.automationId!==z||V!=="all"&&k.status!==V)),ge=Mt(ke,se,H,e),Z=async k=>{N(!0),_(void 0);try{await k()}catch(d){_(d instanceof de?e(d.key):st(d)?e("error.offline"):d instanceof Error?d.message:e("error.action"))}finally{N(!1)}},ne=()=>{x(!1),h(void 0),f(void 0)},ye=k=>{oe===""||ae.length===0||(f(void 0),h(k),x(!0))},we=k=>{f(k.id),h(Lt(k,ue,L?.defaultModel??null,L?.defaultPermission??k.permission)),x(!0)};return(0,Y.useEffect)(()=>{if(typeof window>"u")return;let k=d=>{let T=it(d.detail);T!==void 0&&R(T)};return window.addEventListener(In,k),()=>{window.removeEventListener(In,k)}},[]),(0,Y.useEffect)(()=>{if(I===void 0||L===void 0)return;let k=qs(I,L.automations,L.runs);if(Ks(js),R(void 0),l("mine"),g(""),k===void 0){_(e("error.taskMissing"));return}we(k)},[L,I,e]),(0,w.jsxs)("div",{className:"dsh-st-shell",children:[(0,w.jsxs)("header",{className:"dsh-st-top",children:[(0,w.jsxs)("div",{className:"dsh-st-heading",children:[(0,w.jsxs)("div",{className:"dsh-st-heading-row",children:[(0,w.jsx)("h1",{children:e("tab")}),(0,w.jsxs)("div",{className:"dsh-st-heading-links",children:[(0,w.jsx)(ie.Button,{variant:"outline",size:"sm","aria-label":e("header.githubProject"),icon:(0,w.jsx)(fs,{}),onClick:()=>{window.open("https://github.com/MichengAI/dsh-automation","_blank","noreferrer")},children:e("header.githubProject")}),(0,w.jsx)(ie.Button,{variant:"outline",size:"sm","aria-label":e("header.githubFeedback"),icon:(0,w.jsx)(hs,{}),onClick:()=>{window.open("https://github.com/MichengAI/dsh-automation/issues","_blank","noreferrer")},children:e("header.githubFeedback")})]})]}),(0,w.jsx)("p",{children:e("header.lead")})]}),(0,w.jsxs)("div",{className:"dsh-st-toolbar",children:[(0,w.jsx)(ie.Input,{className:"dsh-st-search",value:c,placeholder:e("search.placeholder"),onChange:k=>g(k.target.value)}),(0,w.jsx)(ie.Button,{variant:"outline",icon:(0,w.jsx)(ms,{}),onClick:()=>{Fs(e("chat.prompt")),r?.()},children:e("action.chatCreate")}),(0,w.jsx)(ie.Button,{variant:"primary",icon:(0,w.jsx)(vn,{}),disabled:oe===""||ae.length===0,onClick:()=>ye(),children:e("action.create")}),(0,w.jsx)(ie.Button,{className:"dsh-st-row-icon",variant:"outline",size:"sm",icon:(0,w.jsx)(cs,{}),"aria-label":e("section.refresh"),style:Yn,onClick:()=>{s.refresh()}})]})]}),(0,w.jsx)("div",{className:"dsh-st-banner",role:"note",children:(0,w.jsxs)("span",{children:[(0,w.jsx)(ps,{}),e("banner.wake")]})}),(0,w.jsxs)("section",{className:"dsh-st-examples",children:[(0,w.jsx)("div",{className:"dsh-st-examples-head",children:(0,w.jsx)("h2",{children:e("examples.title")})}),(0,w.jsx)("div",{className:"dsh-st-example-row",children:Fr.map((k,d)=>(0,w.jsxs)("button",{type:"button",className:"dsh-st-example",disabled:oe===""||ae.length===0,onClick:()=>ye({name:e(`examples.${d+1}.title`),prompt:e(`examples.${d+1}.body`),scheduleKind:k.scheduleKind,time:k.time,weekdays:k.weekdays}),children:[(0,w.jsx)("strong",{children:e(`examples.${d+1}.title`)}),(0,w.jsx)("p",{children:e(`examples.${d+1}.body`)}),(0,w.jsxs)("span",{className:"dsh-st-chip",children:[(0,w.jsx)(Ne,{size:14}),e(`examples.${d+1}.chip`)]})]},k.name))})]}),M!==void 0&&(0,w.jsx)("p",{className:"dsh-st-error",children:M}),(o.phase==="idle"||o.phase==="loading"&&L===void 0)&&(0,w.jsx)("p",{className:"dsh-st-muted",children:e("loading")}),o.phase==="error"&&L===void 0&&(0,w.jsxs)("div",{className:"dsh-st-empty",children:[(0,w.jsx)("h3",{children:e("error.title")}),(0,w.jsx)("p",{children:o.error}),(0,w.jsx)(ie.Button,{variant:"primary",onClick:()=>{s.refresh()},children:e("error.retry")})]}),(0,w.jsxs)("div",{className:"dsh-st-tabs",children:[(0,w.jsx)(ie.SegmentedTabs,{className:"dsh-st-settings-tabs",label:e("tab"),value:a,items:[{value:"mine",id:"dsh-st-tab-mine",panelId:"dsh-st-panel-mine",label:(0,w.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,w.jsx)(Ne,{}),(0,w.jsx)("span",{children:e("tabs.mine")})]})},{value:"runs",id:"dsh-st-tab-runs",panelId:"dsh-st-panel-runs",label:(0,w.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,w.jsx)(ze,{}),(0,w.jsx)("span",{children:e("tabs.runs")})]})}],onChange:l}),a==="mine"&&(0,w.jsx)("div",{className:"dsh-st-sort-wrap",children:(0,w.jsx)(Tn,{t:e,...Cn===void 0?{}:{storage:Cn},storageKey:pn,sortKey:G,sortDirection:ee,onSelect:(k,d)=>{W(k),ce(d)}})}),a==="runs"&&(0,w.jsxs)("div",{className:"dsh-st-filters",children:[(0,w.jsx)(fe,{compact:!0,className:"dsh-st-filter-range",value:se,options:["day","week","month"].map(k=>({value:k,label:e(`history.range.${k}`)})),onChange:k=>re(k)}),(0,w.jsx)(fe,{compact:!0,className:"dsh-st-filter-task",value:z,options:[{value:"all",label:e("history.allTasks")},...(L?.automations??[]).map(k=>({value:k.id,label:k.name}))],onChange:Q}),(0,w.jsx)(fe,{compact:!0,className:"dsh-st-filter-status",value:V,options:[{value:"all",label:e("history.allStatus")},...Rt.map(k=>({value:k,label:e(`status.${k}`)}))],onChange:k=>F(k)})]})]}),a==="mine"&&(me.length===0?(0,w.jsxs)("div",{id:"dsh-st-panel-mine",role:"tabpanel","aria-labelledby":"dsh-st-tab-mine",className:"dsh-st-empty",children:[(0,w.jsx)("h3",{children:e("empty.title")}),(0,w.jsx)("p",{children:e("empty.body")})]}):(0,w.jsx)("div",{id:"dsh-st-panel-mine",role:"tabpanel","aria-labelledby":"dsh-st-tab-mine",className:"dsh-st-grid",children:me.map(k=>(0,w.jsx)(Hr,{item:k,t:e,now:H,busy:S,onEdit:()=>we(k),onToggle:()=>{Z(()=>s.mutateAutomation(k.id,gn(k.status)))},onRun:()=>{Z(()=>s.runNow(k.id))},onDelete:()=>u(k)},k.id))})),a==="runs"&&(ge.length===0?(0,w.jsx)("div",{id:"dsh-st-panel-runs",role:"tabpanel","aria-labelledby":"dsh-st-tab-runs",className:"dsh-st-empty",children:e("runs.empty")}):(0,w.jsx)("div",{id:"dsh-st-panel-runs",role:"tabpanel","aria-labelledby":"dsh-st-tab-runs",className:"dsh-st-timeline",children:ge.map(k=>(0,w.jsxs)("section",{className:"dsh-st-group",children:[(0,w.jsx)("h3",{children:k.label}),k.items.map(d=>(0,w.jsx)(Wr,{run:d,t:e},d.id))]},k.key))})),m&&(0,w.jsx)(Ps,{t:e,permissionT:n,modelT:t,busy:S,workspaces:ue,models:he,modelFailures:L?.modelFailures??[],defaultModel:L?.defaultModel??null,skills:L?.skills??[],permissions:ae,defaultPermission:oe,editing:A!==void 0,...y===void 0?{}:{draft:y},onClose:ne,...i===void 0?{}:{onAddWorkspace:i},onSubmit:async k=>{let d=Tt(k,ue,he,new Date,{allowPastOnce:A!==void 0});await Z(async()=>{A===void 0?await s.createAutomation(d):await s.updateAutomation(A,d),ne()})}},A??"create"),(0,w.jsx)(Ds,{target:p,t:e,busy:S,onCancel:()=>u(void 0),onConfirm:()=>{let k=p;k!==void 0&&Z(async()=>{await s.mutateAutomation(k.id,"delete"),u(void 0)})}})]})}function Hr({item:e,t:n,now:t,busy:s,onEdit:r,onToggle:i,onRun:o,onDelete:a}){let[l,c]=(0,Y.useState)(!1);return(0,w.jsxs)("article",{className:"dsh-st-card",onClick:r,children:[(0,w.jsxs)("div",{className:"dsh-st-card-head",children:[(0,w.jsx)("span",{onClick:g=>g.stopPropagation(),children:(0,w.jsx)(ie.Switch,{checked:e.status==="active",disabled:s,label:e.status==="active"?n("card.pause"):n("card.resume"),onChange:()=>i()})}),(0,w.jsx)("span",{onClick:g=>g.stopPropagation(),children:(0,w.jsx)(ie.Menu,{open:l,onClose:()=>c(!1),align:"end",portal:!0,dense:!0,anchor:(0,w.jsx)(ie.Tooltip,{label:n("card.more"),side:"bottom",delayMs:500,portal:!0,children:(0,w.jsx)("button",{type:"button",className:"dsh-st-row-icon","aria-label":n("card.more"),style:{...Yn,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,border:"1px solid var(--dsw-alias-border-l2, rgba(255,255,255,.15))",borderRadius:"var(--dsw-radius-sm, 6px)",background:"transparent",color:"var(--dsw-alias-label-secondary)",cursor:"pointer"},onClick:()=>c(g=>!g),children:(0,w.jsx)(Xe,{size:16})})}),items:[{id:"run",label:n("menu.run"),disabled:s},{id:"edit",label:n("menu.edit"),disabled:s},{id:"delete",label:n("menu.delete"),danger:!0,disabled:s}],onSelect:g=>{c(!1),g==="run"&&o(),g==="edit"&&r(),g==="delete"&&a()}})})]}),(0,w.jsx)("h3",{children:e.name}),(0,w.jsx)("p",{children:e.prompt}),(0,w.jsxs)("div",{className:"dsh-st-card-foot",children:[(0,w.jsxs)("span",{className:"dsh-st-chip",children:[(0,w.jsx)(Ne,{size:14}),ln(e.schedule,n)]}),(0,w.jsx)("span",{children:e.nextRunAt===void 0?n("stats.noneScheduled"):n("history.nextApprox",{when:cn(e.nextRunAt,t,n)})})]})]})}function Wr({run:e,t:n}){let t=Ct(e.startedAt,e.finishedAt);return(0,w.jsxs)("article",{className:`dsh-st-run is-${e.status}`,children:[(0,w.jsx)("strong",{children:e.automationName}),(0,w.jsxs)("p",{children:[(0,w.jsx)("span",{children:Nt(e.startedAt??e.scheduledFor)}),t!==void 0&&(0,w.jsx)("span",{children:t}),(0,w.jsx)("span",{children:wt(e.trigger,n)})]})]})}var Be="dsh-automation",Xs={tab:"Scheduled tasks","sidebar.tab":"Scheduled","sidebar.tabs":"Workspace views","sidebar.tasksTab":"Tasks","sidebar.channelsTab":"Channels","sidebar.views":"Scheduled views","sidebar.viewOverview":"Task overview","sidebar.empty":"No scheduled runs yet.","sidebar.tasksEmpty":"No web tasks yet.","sidebar.ungrouped":"Ungrouped","sidebar.section":"Scheduled","sidebar.workspaces":"Workspaces","sidebar.search":"Search","sidebar.sessions":"Sessions","sidebar.searchSessions":"Search session names","sidebar.clearSearch":"Clear search","sidebar.filter":"View options","sidebar.groupBy":"Group by","sidebar.groupWorkspace":"WorkSpace","sidebar.groupWorkspaceTree":"Workspace Tree","sidebar.groupList":"In one list","sidebar.sortBy":"Order by","sidebar.sortManual":"Manual","sidebar.sortTime":"Last updated","sidebar.filterBy":"Filter sessions","sidebar.hideArchived":"Hide archived","sidebar.showArchived":"All conversations (show archived)","sidebar.onlyArchived":"Archived only","header.lead":"Plan automatic tasks, or trigger them by hand. Describe the recurring work in any chat to create it quickly.","header.githubProject":"GitHub","header.githubFeedback":"Issues","examples.title":"Recommended examples","examples.1.title":"Daily regression check","examples.1.body":"Create a scheduled task that runs every day and inspects new test failures.","examples.1.chip":"Every day 09:00","examples.2.title":"Weekly dependency review","examples.2.body":"Create a scheduled task that runs every Monday and reports outdated or risky dependencies.","examples.2.chip":"Monday 10:00","examples.3.title":"Weekday morning briefing","examples.3.body":"Create a scheduled task that runs on weekdays and summarizes overnight changes.","examples.3.chip":"Weekdays 08:00","chat.hint":"In any conversation, describe the recurring work and ask the Agent to call automation_create.","chat.prompt":"I want to create a scheduled task that runs every [interval] and does [the actual task]","menu.run":"Run task","menu.edit":"Edit task","menu.delete":"Delete task","session.rename":"Rename","session.fork":"Fork session","session.archive":"Archive session","session.unarchive":"Restore","session.copySessionId":"Copy Session ID","session.moreActions":"More actions for {title}","session.groupActions":"Actions for {name}","session.taskSettings":"Task settings","session.archiveGroup":"Archive all conversations","session.archiveGroupConfirm":"Archive all","session.archiveGroupDescription":"Archive all {count} conversations for \u201C{name}\u201D. Choose Filter \u2192 Show archived to restore them.","session.archiveGroupPending":"Archiving conversations\u2026","session.archiveGroupFailed":"Some conversations could not be archived: {message}","session.archiveGroupClose":"Close","session.archiveGroupCancel":"Cancel","session.unarchiveGroup":"Restore all conversations","session.unarchiveGroupConfirm":"Restore all","session.unarchiveGroupDescription":"Restore all {count} conversations for \u201C{name}\u201D.","session.unarchiveGroupPending":"Restoring conversations\u2026","session.unarchiveGroupFailed":"Some conversations could not be restored: {message}","session.unarchiveGroupClose":"Close","session.unarchiveGroupCancel":"Cancel","session.deleteSession":"Delete session","session.deleteSessionConfirm":"Delete session","session.deleteSessionDescription":"This permanently deletes session \u201C{name}\u201D, its child agents (including any that are still running), and all of its records (conversation, stats, cache). This cannot be undone.","session.deleteSessionPending":"Deleting session\u2026","session.deleteSessionFailed":"Could not delete the session: {message}","session.deleteSessionClose":"Close","session.deleteSessionCancel":"Cancel","session.idle":"Idle","session.runningStatus":"Running","session.completed":"Completed","session.waitingApproval":"Waiting for approval","session.planReview":"Plan to review","session.waitingAnswer":"Waiting for an answer","session.subagentsRunning":"{count} subagents running","session.archived":"Archived","session.delete":"Remove from Scheduled","session.deleteFolder":"Remove folder","session.confirmDeleteFolder":"Remove this folder from Scheduled?","session.confirmDeleteFolderHint":'This only unlists {count} session(s) in "{name}" from Scheduled. Host sessions are not deleted and they stay hidden from Tasks.',"session.confirmDeleteFolderAction":"Remove from Scheduled","history.range.day":"By day","history.range.week":"By week","history.range.month":"By month","history.allTasks":"All tasks","history.allStatus":"All statuses","history.today":"Today","history.yesterday":"Yesterday","history.date":"{date}","history.week":"Week of {date}","history.month":"{month}","history.nextApprox":"Next run in about {when}","time.withinMinute":"about {count} minutes","time.withinHour":"about {count} hours","time.withinDay":"about {count} days","search.placeholder":"Search scheduled tasks...","action.chatCreate":"Create in chat","action.create":"New scheduled task","banner.wake":"Scheduled tasks run only while this computer stays awake.","tabs.mine":"My tasks","tabs.runs":"Run history","sort.by":"Sort","sort.created.asc":"Created time ascending","sort.created.desc":"Created time descending","sort.planned.asc":"Planned time ascending","sort.planned.desc":"Planned time descending","sort.default.save":"Set as default","sort.default.saved":"Default","form.workspace":"Workspace","form.fieldWorkspace":"Workspace","form.fieldModel":"Model","form.providerAccount":"DeepSeek account","form.fieldEffort":"Reasoning","form.fieldPermission":"Permission","form.slashHint":"Type / to insert a skill","form.slashEmpty":"No matching skills","form.addWorkspace":"Add workspace","form.workspaceRequired":"Add a registered workspace before saving.","form.workspaceUnavailable":"This Host cannot create workspaces.","form.addWorkspaceFailed":"Could not add the workspace.","form.workspacePath":"Folder path","form.workspacePathPlaceholder":"D:\\work\\project","form.model":"Model","form.modelSelect":"Select model","form.effort":"Reasoning","form.effort.none":"Default","form.effort.low":"Low","form.effort.medium":"Medium","form.effort.high":"High","form.error.workspace":"Select a workspace.","modal.title":"New scheduled task","modal.edit":"Edit scheduled task","modal.save":"Save","header.eyebrow":"Unattended coding work","header.title":"Automations","header.subtitle":"Schedule standalone, auditable Agent runs for this workspace.","header.create":"New automation","header.closeCreate":"Hide form","scope.workspace":"Workspace","scope.folder":"Working directory","stats.total":"All","stats.active":"Active","stats.next":"Next run","stats.attention":"Needs attention","stats.noneScheduled":"None scheduled","stats.noAttention":"All clear","section.automations":"Workspace automations","section.automationsHint":"Each trigger starts a fresh DSH Session and keeps its own audit record.","section.runs":"Recent runs","section.runsHint":"Latest outcomes for this workspace.","section.refresh":"Refresh","empty.title":"Let recurring coding work run itself","empty.body":"Save a self-contained task, a schedule, and a permission boundary. Every run starts in a new Session.","empty.action":"Create the first automation","runs.empty":"No runs yet. Run one now, or wait for the next scheduled occurrence.","overview.empty":"No scheduled tasks yet. Create one in Settings.","form.title":"Create automation","form.subtitle":"Write a complete, standalone task. Scheduled runs do not inherit this conversation.","form.name":"Name","form.namePlaceholder":"Daily regression triage","form.prompt":"Task prompt","form.promptPlaceholder":"Inspect new test failures, locate the regression, and propose a verified minimal fix\u2026","form.schedule":"Schedule","form.planTime":"Schedule","form.hourly":"Hourly","form.monthly":"Monthly","form.custom":"Every few days","form.intervalHint":"Runs every this many minutes, starting now.","form.customHint":"Runs every this many days at the selected time.","form.atTime":"at","form.minutesShort":"min","form.daysShort":"days","form.monthDay":"Day {day} of month","form.skills":"Skills","form.skillsEmpty":"No skills available","schedule.hourlyAt":"Every hour at :{minute}","schedule.monthlyAt":"Monthly on day {day} \xB7 {time}","schedule.customAt":"Every {count} days \xB7 {time}","form.once":"Does not repeat","form.interval":"Interval","form.daily":"Daily","form.weekly":"Weekly","form.runAt":"Run at","form.every":"Every","form.minutes":"minutes","form.time":"Time","form.days":"Weekdays","form.timeZone":"Time zone","form.maxConcurrentRuns":"Concurrency","form.maxConcurrentRunsHint":"Queued and running executions share this limit. Defaults to 1; when full, scheduled triggers are skipped and manual runs are rejected.","form.error.maxConcurrentRuns":"Enter a positive whole number for concurrent runs.","form.permission":"Permission boundary","permission.readOnly":"Read Only","permission.workspaceWrite":"Workspace Write","permission.fullAccess":"Full access","form.cancel":"Cancel","form.submit":"Create automation","form.submitting":"Creating\u2026","form.error.name":"Enter a name.","form.error.prompt":"Enter a complete, standalone task prompt.","form.error.once":"Choose a valid future date and time.","form.error.interval":"The interval must be between 1 and 43,200 minutes.","form.error.weekdays":"Select at least one weekday.","day.1":"Mon","day.2":"Tue","day.3":"Wed","day.4":"Thu","day.5":"Fri","day.6":"Sat","day.7":"Sun","status.active":"Active","status.paused":"Paused","status.queued":"Queued","status.running":"Running","status.succeeded":"Succeeded","status.failed":"Failed","status.skipped":"Skipped","status.cancelled":"Cancelled","status.interrupted":"Interrupted","card.nextRun":"Next","card.lastRun":"Last","card.never":"Not yet run","schedule.onceAt":"Once \xB7 {time}","schedule.everyMinutes":"Every {count} minutes","schedule.dailyAt":"Daily \xB7 {time}","schedule.weeklyAt":"{days} \xB7 {time}","card.pause":"Pause","card.resume":"Resume","card.runNow":"Run now","card.more":"More actions","card.delete":"Delete","card.confirmDelete":"Delete this automation?","card.confirmDeleteHint":"Run history is kept for audit.","card.confirm":"Delete","card.cancel":"Cancel","run.trigger.schedule":"Scheduled","run.trigger.manual":"Manual","run.openSession":"Session {id}","run.markRead":"Mark reviewed",loading:"Loading automations\u2026","error.title":"Automations could not be loaded","error.retry":"Try again","error.action":"The action failed. Please try again.","error.taskMissing":"This scheduled task no longer exists.","error.offline":"Could not reach the local automation service. Check that DSH is still running and try again.","time.minutes":"{count}m","time.hours":"{count}h","time.days":"{count}d","time.months":"{count}mo","time.years":"{count}y","time.ago":"{text} ago","time.now":"now","session.copy":"Copy","session.copied":"Copied","session.compactApproval":"Approval","session.compactPlan":"Plan review","session.compactAnswer":"Answer","time.minuteAgo":"{count}m ago","time.hourAgo":"{count}h ago","time.dayAgo":"{count}d ago","time.inMinute":"in {count}m","time.inHour":"in {count}h","time.inDay":"in {count}d"},Js={tab:"\u5B9A\u65F6\u4EFB\u52A1","sidebar.tab":"\u5B9A\u65F6","sidebar.tabs":"\u5DE5\u4F5C\u533A\u5206\u7C7B","sidebar.tasksTab":"\u4EFB\u52A1","sidebar.channelsTab":"\u9891\u9053","sidebar.views":"\u5B9A\u65F6\u9875\u89C6\u56FE","sidebar.viewOverview":"\u4EFB\u52A1\u603B\u89C8","sidebar.empty":"\u8FD8\u6CA1\u6709\u5B9A\u65F6\u4EFB\u52A1\u6267\u884C\u8BB0\u5F55\u3002","sidebar.tasksEmpty":"\u6682\u65E0\u7F51\u9875\u4EFB\u52A1","sidebar.ungrouped":"\u672A\u5206\u7EC4","sidebar.section":"\u5B9A\u65F6\u4EFB\u52A1","sidebar.workspaces":"\u5DE5\u4F5C\u533A","sidebar.search":"\u641C\u7D22","sidebar.sessions":"\u4F1A\u8BDD","sidebar.searchSessions":"\u641C\u7D22\u4F1A\u8BDD\u540D\u79F0","sidebar.clearSearch":"\u6E05\u9664\u641C\u7D22","sidebar.filter":"\u89C6\u56FE\u9009\u9879","sidebar.groupBy":"\u5206\u7EC4\u65B9\u5F0F","sidebar.groupWorkspace":"\u6309\u5DE5\u4F5C\u533A","sidebar.groupWorkspaceTree":"\u6309\u5DE5\u4F5C\u533A\u6811","sidebar.groupList":"\u5355\u5217\u8868","sidebar.sortBy":"\u6392\u5E8F\u65B9\u5F0F","sidebar.sortManual":"\u624B\u52A8\u6392\u5E8F","sidebar.sortTime":"\u6700\u8FD1\u66F4\u65B0","sidebar.filterBy":"\u7B5B\u9009\u4F1A\u8BDD","sidebar.hideArchived":"\u9690\u85CF\u5DF2\u5F52\u6863","sidebar.showArchived":"\u5168\u90E8\u5BF9\u8BDD\uFF08\u663E\u793A\u5DF2\u5F52\u6863\uFF09","sidebar.onlyArchived":"\u4EC5\u663E\u793A\u5DF2\u5F52\u6863","header.lead":"\u6309\u8BA1\u5212\u81EA\u52A8\u6267\u884C\u4EFB\u52A1\uFF0C\u4E5F\u53EF\u968F\u65F6\u624B\u52A8\u89E6\u53D1\u3002\u5728\u4EFB\u610F\u5BF9\u8BDD\u4E2D\u63CF\u8FF0\u4F60\u60F3\u5B9A\u671F\u505A\u7684\u4E8B\uFF0C\u5373\u53EF\u5FEB\u901F\u521B\u5EFA","header.githubProject":"GitHub","header.githubFeedback":"\u95EE\u9898\u53CD\u9988","examples.title":"\u63A8\u8350\u6848\u4F8B","examples.1.title":"\u6BCF\u65E5\u56DE\u5F52\u68C0\u67E5","examples.1.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5929\u3011\u6267\u884C\u3010\u68C0\u67E5\u65B0\u589E\u6D4B\u8BD5\u5931\u8D25\u5E76\u7ED9\u51FA\u6700\u5C0F\u4FEE\u590D\u3011\u3002","examples.1.chip":"\u6BCF\u5929 09:00","examples.2.title":"\u6BCF\u5468\u4F9D\u8D56\u5DE1\u68C0","examples.2.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5468\u4E00\u3011\u6267\u884C\u3010\u68C0\u67E5\u8FC7\u671F\u6216\u6709\u98CE\u9669\u7684\u4F9D\u8D56\u5E76\u7ED9\u51FA\u5904\u7406\u5EFA\u8BAE\u3011\u3002","examples.2.chip":"\u6BCF\u5468\u4E00 10:00","examples.3.title":"\u5DE5\u4F5C\u65E5\u65E9\u62A5","examples.3.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5DE5\u4F5C\u65E5\u3011\u6267\u884C\u3010\u6C47\u603B\u6628\u591C\u4ED3\u5E93\u53D8\u66F4\u5E76\u7ED9\u51FA\u4ECA\u65E5\u5173\u6CE8\u70B9\u3011\u3002","examples.3.chip":"\u5DE5\u4F5C\u65E5 08:00","chat.hint":"\u5728\u4EFB\u610F\u5BF9\u8BDD\u4E2D\u63CF\u8FF0\u4F60\u60F3\u5B9A\u671F\u505A\u7684\u4E8B\uFF0C\u5E76\u8BA9 Agent \u8C03\u7528 automation_create\u3002","chat.prompt":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u65F6\u95F4\u95F4\u9694\u3011\u6267\u884C\u3010\u5177\u4F53\u4EFB\u52A1\u3011","menu.run":"\u6267\u884C\u4EFB\u52A1","menu.edit":"\u7F16\u8F91\u4EFB\u52A1","menu.delete":"\u5220\u9664\u4EFB\u52A1","session.rename":"\u91CD\u547D\u540D","session.fork":"\u5206\u53C9\u4F1A\u8BDD","session.archive":"\u5F52\u6863\u4F1A\u8BDD","session.unarchive":"\u6062\u590D","session.copySessionId":"\u590D\u5236 Session ID","session.moreActions":"\u201C{title}\u201D\u7684\u66F4\u591A\u64CD\u4F5C","session.groupActions":"\u201C{name}\u201D\u7684\u4EFB\u52A1\u64CD\u4F5C","session.taskSettings":"\u4EFB\u52A1\u8BBE\u7F6E","session.archiveGroup":"\u5F52\u6863\u6574\u7EC4\u4F1A\u8BDD","session.archiveGroupConfirm":"\u786E\u8BA4\u5F52\u6863","session.archiveGroupDescription":"\u5C06\u5F52\u6863\u201C{name}\u201D\u4E0B\u7684 {count} \u4E2A\u4F1A\u8BDD\u3002\u53EF\u5728\u7B5B\u9009\u4E2D\u9009\u62E9\u201C\u663E\u793A\u5DF2\u5F52\u6863\u201D\u540E\u6062\u590D\u3002","session.archiveGroupPending":"\u6B63\u5728\u5F52\u6863\u6574\u7EC4\u4F1A\u8BDD\u2026","session.archiveGroupFailed":"\u90E8\u5206\u4F1A\u8BDD\u5F52\u6863\u5931\u8D25\uFF1A{message}","session.archiveGroupClose":"\u5173\u95ED","session.archiveGroupCancel":"\u53D6\u6D88","session.unarchiveGroup":"\u6062\u590D\u6574\u7EC4\u4F1A\u8BDD","session.unarchiveGroupConfirm":"\u786E\u8BA4\u6062\u590D","session.unarchiveGroupDescription":"\u5C06\u6062\u590D\u201C{name}\u201D\u4E0B\u7684 {count} \u4E2A\u4F1A\u8BDD\u3002","session.unarchiveGroupPending":"\u6B63\u5728\u6062\u590D\u6574\u7EC4\u4F1A\u8BDD\u2026","session.unarchiveGroupFailed":"\u90E8\u5206\u4F1A\u8BDD\u6062\u590D\u5931\u8D25\uFF1A{message}","session.unarchiveGroupClose":"\u5173\u95ED","session.unarchiveGroupCancel":"\u53D6\u6D88","session.deleteSession":"\u5220\u9664\u4F1A\u8BDD","session.deleteSessionConfirm":"\u5220\u9664\u4F1A\u8BDD","session.deleteSessionDescription":"\u5C06\u6C38\u4E45\u5220\u9664\u4F1A\u8BDD\u201C{name}\u201D\u53CA\u5176\u5B50\u4EE3\u7406\uFF08\u542B\u6B63\u5728\u8FD0\u884C\u7684\uFF09\u548C\u5168\u90E8\u8BB0\u5F55\uFF08\u5BF9\u8BDD\u5185\u5BB9\u3001\u7EDF\u8BA1\u3001\u7F13\u5B58\uFF09\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002","session.deleteSessionPending":"\u6B63\u5728\u5220\u9664\u4F1A\u8BDD\u2026","session.deleteSessionFailed":"\u5220\u9664\u4F1A\u8BDD\u5931\u8D25\uFF1A{message}","session.deleteSessionClose":"\u5173\u95ED","session.deleteSessionCancel":"\u53D6\u6D88","session.idle":"\u7A7A\u95F2","session.runningStatus":"\u8FDB\u884C\u4E2D","session.completed":"\u5DF2\u5B8C\u6210","session.waitingApproval":"\u7B49\u5F85\u5BA1\u6279","session.planReview":"\u8BA1\u5212\u5F85\u5BA1","session.waitingAnswer":"\u7B49\u5F85\u56DE\u7B54","session.subagentsRunning":"{count} \u4E2A\u5B50\u4EE3\u7406\u8FD0\u884C\u4E2D","session.archived":"\u5DF2\u5F52\u6863","session.delete":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664","session.deleteFolder":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664\u6587\u4EF6\u5939","session.confirmDeleteFolder":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664\u8FD9\u4E2A\u6587\u4EF6\u5939\uFF1F","session.confirmDeleteFolderHint":"\u53EA\u4F1A\u628A\u300C{name}\u300D\u4E0B\u7684 {count} \u6761\u4F1A\u8BDD\u4ECE\u5B9A\u65F6\u9875\u6458\u6389\uFF0C\u4E0D\u4F1A\u5220\u9664\u5BBF\u4E3B Session\u3002\u4EFB\u52A1\u9875\u672C\u6765\u4E5F\u4E0D\u5C55\u793A\u8FD9\u4E9B\u81EA\u52A8\u5316\u4F1A\u8BDD\u3002","session.confirmDeleteFolderAction":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664","history.range.day":"\u6309\u5929","history.range.week":"\u6309\u5468","history.range.month":"\u6309\u6708","history.allTasks":"\u5168\u90E8\u4EFB\u52A1","history.allStatus":"\u5168\u90E8\u72B6\u6001","history.today":"\u4ECA\u5929","history.yesterday":"\u6628\u5929","history.date":"{date}","history.week":"{date} \u5F53\u5468","history.month":"{month}","history.nextApprox":"\u4E0B\u6B21\u6267\u884C \u5927\u7EA6 {when}","time.withinMinute":"{count} \u5206\u949F\u5185","time.withinHour":"{count} \u5C0F\u65F6\u5185","time.withinDay":"{count} \u5929\u5185","search.placeholder":"\u641C\u7D22\u5B9A\u65F6\u4EFB\u52A1...","action.chatCreate":"\u901A\u8FC7\u5BF9\u8BDD\u521B\u5EFA","action.create":"\u65B0\u5EFA\u5B9A\u65F6\u4EFB\u52A1","banner.wake":"\u5B9A\u65F6\u4EFB\u52A1\u4EC5\u5728\u7535\u8111\u4FDD\u6301\u5524\u9192\u65F6\u8FD0\u884C","tabs.mine":"\u6211\u7684\u5B9A\u65F6\u4EFB\u52A1","tabs.runs":"\u6267\u884C\u8BB0\u5F55","sort.by":"\u6392\u5E8F","sort.created.asc":"\u6309\u521B\u5EFA\u65F6\u95F4\u5347\u5E8F","sort.created.desc":"\u6309\u521B\u5EFA\u65F6\u95F4\u5012\u5E8F","sort.planned.asc":"\u6309\u8BA1\u5212\u65F6\u95F4\u5347\u5E8F","sort.planned.desc":"\u6309\u8BA1\u5212\u65F6\u95F4\u5012\u5E8F","sort.default.save":"\u8BBE\u4E3A\u9ED8\u8BA4","sort.default.saved":"\u9ED8\u8BA4","form.workspace":"\u5DE5\u4F5C\u76EE\u5F55","form.fieldWorkspace":"\u5DE5\u4F5C\u533A","form.fieldModel":"\u6A21\u578B","form.providerAccount":"DeepSeek \u8D26\u53F7","form.fieldEffort":"\u63A8\u7406\u7B49\u7EA7","form.fieldPermission":"\u6743\u9650","form.slashHint":"\u8F93\u5165 / \u53EC\u56DE\u6280\u80FD","form.slashEmpty":"\u6CA1\u6709\u5339\u914D\u7684\u6280\u80FD","form.addWorkspace":"\u6DFB\u52A0\u5DE5\u4F5C\u533A","form.workspaceRequired":"\u8BF7\u5148\u6DFB\u52A0\u5DF2\u767B\u8BB0\u7684\u5DE5\u4F5C\u533A\uFF0C\u5426\u5219\u65E0\u6CD5\u4FDD\u5B58\u3002","form.workspaceUnavailable":"\u5F53\u524D\u5BBF\u4E3B\u4E0D\u80FD\u65B0\u5EFA\u5DE5\u4F5C\u533A\u3002","form.addWorkspaceFailed":"\u6DFB\u52A0\u5DE5\u4F5C\u533A\u5931\u8D25\u3002","form.workspacePath":"\u76EE\u5F55\u8DEF\u5F84","form.workspacePathPlaceholder":"D:\\work\\project","form.model":"\u6A21\u578B","form.modelSelect":"\u9009\u62E9\u6A21\u578B","form.effort":"\u63A8\u7406\u7B49\u7EA7","form.effort.none":"\u9ED8\u8BA4","form.effort.low":"Low","form.effort.medium":"Medium","form.effort.high":"High","form.error.workspace":"\u8BF7\u9009\u62E9\u5DE5\u4F5C\u533A\u3002","modal.title":"\u65B0\u5EFA\u5B9A\u65F6\u4EFB\u52A1","modal.edit":"\u7F16\u8F91\u5B9A\u65F6\u4EFB\u52A1","modal.save":"\u4FDD\u5B58","header.eyebrow":"\u81EA\u4E3B\u7F16\u7801\u4EFB\u52A1","header.title":"\u81EA\u52A8\u5316","header.subtitle":"\u4E3A\u5F53\u524D\u5DE5\u4F5C\u533A\u5B89\u6392\u72EC\u7ACB\u3001\u53EF\u5BA1\u8BA1\u7684 Agent \u8FD0\u884C\u3002","header.create":"\u65B0\u5EFA\u81EA\u52A8\u5316","header.closeCreate":"\u6536\u8D77\u8868\u5355","scope.workspace":"\u5DE5\u4F5C\u533A","scope.folder":"\u5DE5\u4F5C\u76EE\u5F55","stats.total":"\u5168\u90E8","stats.active":"\u5DF2\u542F\u7528","stats.next":"\u4E0B\u6B21\u8FD0\u884C","stats.attention":"\u9700\u8981\u5173\u6CE8","stats.noneScheduled":"\u6682\u65E0\u8BA1\u5212","stats.noAttention":"\u4E00\u5207\u6B63\u5E38","section.automations":"\u5DE5\u4F5C\u533A\u81EA\u52A8\u5316","section.automationsHint":"\u6BCF\u6B21\u89E6\u53D1\u90FD\u4F1A\u521B\u5EFA\u4E00\u4E2A\u5168\u65B0\u7684 DSH Session\uFF0C\u5E76\u4FDD\u7559\u72EC\u7ACB\u5BA1\u8BA1\u8BB0\u5F55\u3002","section.runs":"\u6700\u8FD1\u8FD0\u884C","section.runsHint":"\u5F53\u524D\u5DE5\u4F5C\u533A\u6700\u8FD1\u7684\u6267\u884C\u72B6\u6001\u3002","section.refresh":"\u5237\u65B0","empty.title":"\u8BA9\u91CD\u590D\u7684\u7F16\u7801\u5DE5\u4F5C\u81EA\u52A8\u8FD0\u884C","empty.body":"\u8BBE\u7F6E\u4E00\u4E2A\u76EE\u6807\u660E\u786E\u7684\u4EFB\u52A1\u3001\u8FD0\u884C\u65F6\u95F4\u548C\u6743\u9650\u8FB9\u754C\u3002\u6BCF\u6B21\u8FD0\u884C\u90FD\u4ECE\u5168\u65B0 Session \u5F00\u59CB\u3002","empty.action":"\u521B\u5EFA\u7B2C\u4E00\u4E2A\u81EA\u52A8\u5316","runs.empty":"\u8FD8\u6CA1\u6709\u8FD0\u884C\u8BB0\u5F55\u3002\u4F60\u53EF\u4EE5\u7ACB\u5373\u8FD0\u884C\u4E00\u6B21\uFF0C\u6216\u7B49\u5F85\u8BA1\u5212\u89E6\u53D1\u3002","overview.empty":"\u6682\u65E0\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u53EF\u5230\u8BBE\u7F6E\u9875\u521B\u5EFA\u3002","form.title":"\u521B\u5EFA\u81EA\u52A8\u5316","form.subtitle":"\u8BF7\u5199\u5B8C\u6574\u3001\u72EC\u7ACB\u7684\u4EFB\u52A1\u8BF4\u660E\uFF1A\u5B9A\u65F6\u8FD0\u884C\u4E0D\u4F1A\u7EE7\u627F\u5F53\u524D\u5BF9\u8BDD\u3002","form.name":"\u540D\u79F0","form.namePlaceholder":"\u6BCF\u65E5\u56DE\u5F52\u6D4B\u8BD5\u5206\u8BCA","form.prompt":"\u4EFB\u52A1\u6307\u4EE4","form.promptPlaceholder":"\u68C0\u67E5\u65B0\u589E\u6D4B\u8BD5\u5931\u8D25\uFF0C\u5B9A\u4F4D\u56DE\u5F52\u539F\u56E0\uFF0C\u5E76\u7ED9\u51FA\u7ECF\u8FC7\u9A8C\u8BC1\u7684\u6700\u5C0F\u4FEE\u590D\u65B9\u6848\u2026\u2026","form.schedule":"\u8FD0\u884C\u8BA1\u5212","form.planTime":"\u8BA1\u5212\u65F6\u95F4","form.hourly":"\u6BCF\u5C0F\u65F6","form.monthly":"\u6BCF\u6708","form.custom":"\u6BCF\u9694\u51E0\u5929","form.intervalHint":"\u4ECE\u73B0\u5728\u8D77\uFF0C\u6BCF\u9694\u8FD9\u4E48\u591A\u5206\u949F\u8FD0\u884C\u4E00\u6B21\u3002","form.customHint":"\u6BCF\u9694\u8FD9\u4E48\u591A\u5929\uFF0C\u5728\u6240\u9009\u65F6\u95F4\u8FD0\u884C\u4E00\u6B21\u3002","form.atTime":"\u4E8E","form.minutesShort":"\u5206","form.daysShort":"\u5929","form.monthDay":"\u6BCF\u6708\u7B2C {day} \u5929","form.skills":"\u6280\u80FD","form.skillsEmpty":"\u6682\u65E0\u53EF\u7528\u6280\u80FD","schedule.hourlyAt":"\u6BCF\u5C0F\u65F6 :{minute}","schedule.monthlyAt":"\u6BCF\u6708 {day} \u65E5 \xB7 {time}","schedule.customAt":"\u6BCF {count} \u5929 \xB7 {time}","form.once":"\u4E0D\u91CD\u590D","form.interval":"\u95F4\u9694","form.daily":"\u6BCF\u5929","form.weekly":"\u6BCF\u5468","form.runAt":"\u8FD0\u884C\u65F6\u95F4","form.every":"\u6BCF\u9694","form.minutes":"\u5206\u949F","form.time":"\u65F6\u95F4","form.days":"\u661F\u671F","form.timeZone":"\u65F6\u533A","form.maxConcurrentRuns":"\u5E76\u53D1\u6570\u91CF","form.maxConcurrentRunsHint":"\u540C\u4E00\u4EFB\u52A1\u7684\u6392\u961F\u53CA\u8FD0\u884C\u6B21\u6570\u5171\u7528\u6B64\u4E0A\u9650\uFF0C\u9ED8\u8BA4 1\uFF1B\u6EE1\u989D\u65F6\u8DF3\u8FC7\u5F53\u6B21\u5B9A\u65F6\u89E6\u53D1\uFF0C\u624B\u52A8\u8FD0\u884C\u5C06\u88AB\u62D2\u7EDD\u3002","form.error.maxConcurrentRuns":"\u5E76\u53D1\u6570\u91CF\u5FC5\u987B\u4E3A\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\u3002","form.permission":"\u6743\u9650\u8FB9\u754C","permission.readOnly":"\u53EA\u8BFB","permission.workspaceWrite":"\u5DE5\u4F5C\u533A\u5199\u5165","permission.fullAccess":"\u5B8C\u5168\u8BBF\u95EE","form.cancel":"\u53D6\u6D88","form.submit":"\u521B\u5EFA\u81EA\u52A8\u5316","form.submitting":"\u521B\u5EFA\u4E2D\u2026","form.error.name":"\u8BF7\u8F93\u5165\u540D\u79F0\u3002","form.error.prompt":"\u8BF7\u8F93\u5165\u5B8C\u6574\u3001\u72EC\u7ACB\u7684\u4EFB\u52A1\u6307\u4EE4\u3002","form.error.once":"\u8BF7\u9009\u62E9\u6709\u6548\u7684\u672A\u6765\u65E5\u671F\u548C\u65F6\u95F4\u3002","form.error.interval":"\u8FD0\u884C\u95F4\u9694\u5FC5\u987B\u5728 1 \u5230 43,200 \u5206\u949F\u4E4B\u95F4\u3002","form.error.weekdays":"\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u5929\u3002","day.1":"\u5468\u4E00","day.2":"\u5468\u4E8C","day.3":"\u5468\u4E09","day.4":"\u5468\u56DB","day.5":"\u5468\u4E94","day.6":"\u5468\u516D","day.7":"\u5468\u65E5","status.active":"\u5DF2\u542F\u7528","status.paused":"\u5DF2\u6682\u505C","status.queued":"\u6392\u961F\u4E2D","status.running":"\u8FD0\u884C\u4E2D","status.succeeded":"\u5DF2\u5B8C\u6210","status.failed":"\u5931\u8D25","status.skipped":"\u5DF2\u8DF3\u8FC7","status.cancelled":"\u5DF2\u53D6\u6D88","status.interrupted":"\u5DF2\u4E2D\u65AD","card.nextRun":"\u4E0B\u6B21","card.lastRun":"\u6700\u8FD1","card.never":"\u5C1A\u672A\u8FD0\u884C","schedule.onceAt":"\u5355\u6B21 \xB7 {time}","schedule.everyMinutes":"\u6BCF {count} \u5206\u949F","schedule.dailyAt":"\u6BCF\u5929 \xB7 {time}","schedule.weeklyAt":"{days} \xB7 {time}","card.pause":"\u6682\u505C","card.resume":"\u6062\u590D","card.runNow":"\u7ACB\u5373\u8FD0\u884C","card.more":"\u66F4\u591A\u64CD\u4F5C","card.delete":"\u5220\u9664","card.confirmDelete":"\u786E\u8BA4\u5220\u9664\u8FD9\u4E2A\u81EA\u52A8\u5316\uFF1F","card.confirmDeleteHint":"\u8FD0\u884C\u5386\u53F2\u4F1A\u4FDD\u7559\u7528\u4E8E\u5BA1\u8BA1\u3002","card.confirm":"\u786E\u8BA4\u5220\u9664","card.cancel":"\u53D6\u6D88","run.trigger.schedule":"\u5B9A\u65F6\u89E6\u53D1","run.trigger.manual":"\u624B\u52A8\u89E6\u53D1","run.openSession":"Session {id}","run.markRead":"\u6807\u8BB0\u5DF2\u5904\u7406",loading:"\u6B63\u5728\u52A0\u8F7D\u81EA\u52A8\u5316\u2026","error.title":"\u65E0\u6CD5\u52A0\u8F7D\u81EA\u52A8\u5316","error.retry":"\u91CD\u8BD5","error.action":"\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002","error.taskMissing":"\u8BE5\u5B9A\u65F6\u4EFB\u52A1\u5DF2\u4E0D\u5B58\u5728\u3002","error.offline":"\u65E0\u6CD5\u8FDE\u63A5\u672C\u673A\u81EA\u52A8\u5316\u670D\u52A1\uFF0C\u8BF7\u786E\u8BA4 DSH \u4ECD\u5728\u8FD0\u884C\u540E\u91CD\u8BD5\u3002","time.minutes":"{count}\u5206\u949F","time.hours":"{count}\u5C0F\u65F6","time.days":"{count}\u5929","time.months":"{count}\u4E2A\u6708","time.years":"{count}\u5E74","time.ago":"{text}\u524D","time.now":"\u521A\u521A","session.copy":"\u590D\u5236","session.copied":"\u5DF2\u590D\u5236","session.compactApproval":"\u5F85\u5BA1\u6279","session.compactPlan":"\u8BA1\u5212\u5F85\u5BA1","session.compactAnswer":"\u5F85\u56DE\u7B54","time.minuteAgo":"{count} \u5206\u949F\u524D","time.hourAgo":"{count} \u5C0F\u65F6\u524D","time.dayAgo":"{count} \u5929\u524D","time.inMinute":"{count} \u5206\u949F\u540E","time.inHour":"{count} \u5C0F\u65F6\u540E","time.inDay":"{count} \u5929\u540E"};var Ys="__dshNativeTabs";function Qs(e){let n=new Map,t=[],s=new Set,r=[],i=()=>{r=[...n.values()].sort((a,l)=>(a.order??0)-(l.order??0))},o=()=>{for(let a of s)a()};return{version:1,officialTree:e,sessionFilters:t,getTabs(){return r},subscribe(a){return s.add(a),()=>{s.delete(a)}},insert(a){if(a.id==="")return()=>{};let l=n.get(a.id);return n.set(a.id,a),l!==a&&(i(),o()),()=>{n.get(a.id)===a&&(n.delete(a.id),i(),o())}},addSessionFilter(a){return t.push(a),o(),()=>{let l=t.indexOf(a);l>=0&&t.splice(l,1),o()}}}}function dt(e){if(e==null||typeof e!="object"&&typeof e!="function")return;let n=e[Ys];if(!(n==null||typeof n!="object"))return typeof n.insert=="function"?n:void 0}function lt(e,n){try{e[Ys]=n}catch{}return n}function eo(e){let n=e;return dt(e)??dt(n?.component)}function no(e){if(e==null)return!1;let n=e;return n.__dshNativeTabHost===!0||n.__imConnectWrapped===!0?!0:dt(e)!==void 0}var _r="@michengai/dsh-archive-manager";function ct(e){return e?.querySelector(`[data-plugin="${_r}"]`)!=null}function $e(e){return typeof e=="function"?e:void 0}function Nn(e){let n=e??{},t=$e(n.renameSession),s=$e(n.archiveSession),r=$e(n.unarchiveSession),i=$e(n.deleteSession),o=$e(n.forkSession),a=$e(n.notifyArchivedNotOpenable);return{...t===void 0?{}:{renameSession:t},...s===void 0?{}:{archiveSession:s},...r===void 0?{}:{unarchiveSession:r},...i===void 0?{}:{deleteSession:i},...o===void 0?{}:{forkSession:o},...a===void 0?{}:{notifyArchivedNotOpenable:a}}}function to(e,n){return e&&n!==void 0}function so(e){let n=["rename","fork"];return e.archived?e.canUnarchive&&n.push("unarchive"):n.push("archive"),e.canDelete&&n.push("delete-session"),n}function oo(e,n){return n!==null&&e.includes(n)}function ro(e,n){return e&&!n}async function io(e,n){for(let t of e)await n(t)}async function ao(e,n){for(let t of e)await n(t)}var P=require("react"),ko=require("react-dom"),K=require("@deepseek-ai/dsh-client-ui-primitives");function co(e,n,t,s){if(e===void 0)return null;try{return e(n,t,s)??null}catch(r){if(!zr(r))throw r;return null}}function zr(e){return typeof e!="object"||e===null?!1:"name"in e&&e.name==="SlotOwnershipError"?!0:(e instanceof Error?e.message:"").includes("not declared by this entry")}function uo(e,n,t){let r=e.right+8,i=e.top+n.height>t.height-8?Math.max(8,t.height-n.height-8):Math.max(8,e.top);return{position:"fixed",zIndex:4100,left:`${Math.round(r)}px`,top:`${Math.round(i)}px`}}function po(e,n){let t=e.runningSubagentCount??0,s=t===0?void 0:{state:"ongoing",label:n("session.subagentsRunning",{count:t})},r;e.pendingKind==="approval"?r={state:"warning",label:n("session.waitingApproval"),trailing:n("session.compactApproval")}:e.pendingKind==="plan-review"?r={state:"warning",label:n("session.planReview"),trailing:n("session.compactPlan")}:e.pendingKind==="question"&&(r={state:"warning",label:n("session.waitingAnswer"),trailing:n("session.compactAnswer")});let i;r!==void 0?i=s===void 0?[r]:[r,s]:e.running?i=s===void 0?[{state:"ongoing",label:n("session.runningStatus")}]:[{state:"ongoing",label:n("session.runningStatus")},s]:s!==void 0?i=[s]:e.completed===!0?i=[{state:"done",label:n("session.completed")}]:i=[{state:"idle",label:n("session.idle")}];let o=i.filter(a=>!(e.archived&&(a.state==="done"||a.state==="idle")));return e.archived&&o.push({state:"archived",label:n("session.archived")}),o}function mo(e,n){let t=Date.parse(e||"");if(!Number.isFinite(t))return;let s=6e4,r=36e5,i=864e5,o=Math.max(0,n-t);return o<s?{unit:"now",count:0}:o<r?{unit:"minutes",count:Math.floor(o/s)}:o<i?{unit:"hours",count:Math.floor(o/r)}:o<30*i?{unit:"days",count:Math.floor(o/i)}:o<365*i?{unit:"months",count:Math.floor(o/(30*i))}:{unit:"years",count:Math.floor(o/(365*i))}}function fo(e,n){return e.unit==="now"?n("time.now"):e.unit==="minutes"?n("time.minutes",{count:e.count}):e.unit==="hours"?n("time.hours",{count:e.count}):e.unit==="days"?n("time.days",{count:e.count}):e.unit==="months"?n("time.months",{count:e.count}):n("time.years",{count:e.count})}function lo(e,n,t){e.scrollLeft=n,n>0?e.dataset.scrolled="":delete e.dataset.scrolled,n<t?e.dataset.clipped="":delete e.dataset.clipped}function Gr(e){e.scrollLeft=0,delete e.dataset.scrolled,delete e.dataset.clipped}function ho(e,n){if(e===null)return;let t=e.scrollWidth-e.clientWidth;if(t<=8)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){lo(e,t,t);return}cancelAnimationFrame(n.id);let s,r=0,i=o=>{r+=s===void 0?0:(o-s)*.03,s=o,lo(e,Math.min(r,t),t),r<t&&(n.id=requestAnimationFrame(i))};n.id=requestAnimationFrame(i)}function ut(e,n){cancelAnimationFrame(n.id),e!==null&&Gr(e)}function go(e,n,t=Date.now()){let s=mo(e,t);return s===void 0?"":fo(s,n)}function yo(e,n,t=Date.now()){let s=mo(e,t);return s===void 0?"":s.unit==="now"?n("time.now"):n("time.ago",{text:fo(s,n)})}var Ee=require("react");var En=require("@deepseek-ai/dsh-client-ui-primitives");var $=require("react/jsx-runtime"),Rn=typeof window>"u"?void 0:window.localStorage;function Mn({t:e,view:n,onChange:t}){return(0,$.jsx)(En.SegmentedTabs,{className:"dsh-st-rail-views",label:e("sidebar.views"),value:n,items:[{value:"runs",id:"dsh-st-rail-view-runs",panelId:"dsh-st-rail-panel-runs",label:(0,$.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,$.jsx)(ze,{}),(0,$.jsx)("span",{children:e("tabs.runs")})]})},{value:"overview",id:"dsh-st-rail-view-overview",panelId:"dsh-st-rail-panel-overview",label:(0,$.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,$.jsx)(kn,{}),(0,$.jsx)("span",{children:e("sidebar.viewOverview")})]})}],onChange:t})}function Ln({t:e,automations:n,serverNow:t,openTaskSettings:s,onToggleAutomation:r}){let[i,o]=(0,Ee.useState)(()=>Ce(Rn,mn)?.key??"planned"),[a,l]=(0,Ee.useState)(()=>Ce(Rn,mn)?.direction??"asc"),[c,g]=(0,Ee.useState)(()=>new Set),m=(0,Ee.useMemo)(()=>new Date(t??Date.now()),[t]),x=(0,Ee.useMemo)(()=>{let p=un(n,i,a);return Ut(p)},[n,a,i]),A=(0,Ee.useMemo)(()=>new Map(n.map(p=>[p.id,ln(p.schedule,e)])),[n,e]),f=(p,u)=>{r===void 0||c.has(p)||(g(y=>new Set(y).add(p)),Promise.resolve(r(p,u)).catch(y=>{console.warn("[dsh-automation] \u5207\u6362\u4EFB\u52A1\u72B6\u6001\u5931\u8D25",y)}).finally(()=>{g(y=>{let h=new Set(y);return h.delete(p),h})}))};return(0,$.jsxs)("div",{className:"dsh-st-overview",children:[(0,$.jsxs)("div",{className:"dsh-st-overview-head",children:[(0,$.jsxs)("div",{className:"dsh-st-overview-title",children:[(0,$.jsx)("strong",{children:e("sidebar.viewOverview")}),(0,$.jsx)("span",{"aria-label":`${x.length}`,children:x.length})]}),(0,$.jsx)(Tn,{t:e,iconOnly:!0,className:"dsh-st-overview-sort",...Rn===void 0?{}:{storage:Rn},storageKey:mn,sortKey:i,sortDirection:a,onSelect:(p,u)=>{o(p),l(u)}})]}),x.length===0?(0,$.jsx)("div",{className:"dsh-st-rail-empty",children:e("overview.empty")}):x.map(p=>(0,$.jsx)(Ur,{t:e,row:p,now:m,scheduleSummary:A.get(p.id)??"",toggleDisabled:r===void 0||c.has(p.id),onToggleAutomation:f,...s===void 0?{}:{openTaskSettings:s}},p.id))]})}function Ur({t:e,row:n,now:t,scheduleSummary:s,openTaskSettings:r,toggleDisabled:i,onToggleAutomation:o}){let a=n.status!=="active",l=n.nextRunAt===void 0?e("stats.noneScheduled"):cn(n.nextRunAt,t,e),c=n.nextRunAt===void 0?e("stats.noneScheduled"):It(n.nextRunAt,t,e),g=`${e("stats.next")}: ${l}`,m=e(a?"card.resume":"card.pause");return(0,$.jsxs)("div",{className:`dsh-st-overview-row${a?" is-paused":""}`,children:[(0,$.jsxs)("button",{type:"button",className:"dsh-st-overview-open",disabled:r===void 0,onClick:()=>{r?.({automationId:n.id,name:n.name,sessionIds:[]})},children:[(0,$.jsxs)("span",{className:"dsh-st-overview-copy",children:[(0,$.jsx)("span",{className:"dsh-st-overview-name",children:n.name}),s!==""&&(0,$.jsxs)("span",{className:"dsh-st-overview-schedule",children:[(0,$.jsx)(us,{width:14,height:14}),(0,$.jsx)("span",{children:s})]})]}),(0,$.jsx)("span",{className:"dsh-st-overview-next",title:g,"aria-label":g,children:(0,$.jsx)("strong",{children:c})})]}),(0,$.jsx)("span",{className:"dsh-st-overview-toggle",title:m,children:(0,$.jsx)(En.Switch,{checked:!a,disabled:i,label:m,onChange:()=>{o?.(n.id,gn(n.status))}})})]})}var Oe=require("react"),Ve=require("@deepseek-ai/dsh-client-ui-primitives");function vo(e){return e?11:14}var j=require("react/jsx-runtime");function bo({t:e,query:n,sort:t,groupMode:s,archivedFilter:r="default",onQueryChange:i,onSortChange:o,onGroupModeChange:a,onArchivedFilterChange:l}){let[c,g]=(0,Oe.useState)(n.trim()!==""),[m,x]=(0,Oe.useState)(!1),A=(0,Oe.useRef)(null),f=vo(c);(0,Oe.useEffect)(()=>{c&&A.current?.focus()},[c]);let p=()=>{x(!1),g(!0)},u=()=>{i(""),g(!1)},y=[{type:"label",id:"group-by",text:e("sidebar.groupBy")},{id:"workspace",label:e("sidebar.groupWorkspace"),icon:(0,j.jsx)(Sn,{})},{id:"workspace-tree",label:e("sidebar.groupWorkspaceTree"),icon:(0,j.jsx)(kn,{})},{id:"flat",label:e("sidebar.groupList"),icon:(0,j.jsx)(ze,{})},{type:"separator",id:"order-by-separator"},{type:"label",id:"order-by",text:e("sidebar.sortBy")},{id:"updated",label:e("sidebar.sortTime"),icon:(0,j.jsx)(Ne,{})},...l!==void 0?[{type:"separator",id:"archived-filter-separator"},{type:"label",id:"filter-by",text:e("sidebar.filterBy")},{id:"hide-archived",label:e("sidebar.hideArchived"),icon:(0,j.jsx)(As,{})},{id:"show-archived",label:e("sidebar.showArchived"),icon:(0,j.jsx)(_e,{})},{id:"only-archived",label:e("sidebar.onlyArchived"),icon:(0,j.jsx)(Ts,{})}]:[]],h=[s==="list"?"flat":s,"updated",r==="show"?"show-archived":r==="only"?"only-archived":"hide-archived"];return(0,j.jsxs)("div",{className:c?"dsh-st-n-toolbar is-search":"dsh-st-n-toolbar",children:[(0,j.jsx)("span",{className:"dsh-st-n-head-label",children:e(s==="list"?"sidebar.sessions":"sidebar.workspaces")}),(0,j.jsx)("div",{className:"dsh-st-n-search-slot",children:(0,j.jsxs)("div",{className:"dsh-st-n-search",onClick:p,children:[(0,j.jsx)(Ve.Tooltip,{label:e("sidebar.search"),side:"bottom",delayMs:500,disabled:c,children:(0,j.jsx)("button",{type:"button",className:"dsh-st-n-search-btn","aria-label":e("sidebar.search"),"aria-expanded":c,onClick:p,children:(0,j.jsx)(bs,{size:f})})}),(0,j.jsx)("input",{ref:A,className:"dsh-st-n-search-input",value:n,placeholder:e("sidebar.searchSessions"),"aria-label":e("sidebar.searchSessions"),tabIndex:c?0:-1,"aria-hidden":!c,onChange:S=>i(S.target.value),onKeyDown:S=>{S.key==="Escape"&&u()}}),c&&(0,j.jsx)(Ve.Tooltip,{label:e("sidebar.clearSearch"),side:"bottom",delayMs:500,children:(0,j.jsx)("button",{type:"button",className:"dsh-st-n-search-clear","aria-label":e("sidebar.clearSearch"),onClick:S=>{S.stopPropagation(),u()},children:(0,j.jsx)(ws,{size:14})})})]})}),(0,j.jsx)("div",{className:"dsh-st-n-head-acts",children:(0,j.jsx)(Ve.Menu,{open:m,onClose:()=>{x(!1)},items:y,selectedIds:h,align:"end",dense:!0,portal:!0,onSelect:S=>{(S==="workspace"||S==="workspace-tree")&&a(S),S==="flat"&&a("list"),S==="updated"&&o("time"),S==="hide-archived"&&l?.("default"),S==="show-archived"&&l?.("show"),S==="only-archived"&&l?.("only"),x(!1)},anchor:(0,j.jsx)(Ve.Tooltip,{label:e("sidebar.filter"),side:"bottom",delayMs:500,disabled:m,children:(0,j.jsx)("button",{type:"button",className:m?"dsh-st-n-head-btn is-on":"dsh-st-n-head-btn","aria-label":e("sidebar.filter"),"aria-expanded":m,onClick:()=>x(S=>!S),children:(0,j.jsx)(wn,{size:16})})})})})]})}var v=require("react/jsx-runtime"),wo={},So=[];function Pn(e){let{t:n,runtime:t,openSession:s,useSessions:r,useWorkspaces:i,renameSession:o,archiveSession:a,unarchiveSession:l,deleteSession:c,forkSession:g,notifyArchivedNotOpenable:m,openTaskSettings:x,renderSlot:A,useSessionStatus:f}=e,p=(0,P.useSyncExternalStore)(t.source.subscribe,t.source.getSnapshot,t.source.getSnapshot),u=r?r(C=>je(C)):null,y=r?r(C=>C.byId??wo):wo,h=i?i(C=>C.archivedSessionIds??[]):[],S=i?i(C=>C.items??So):So,N=f?f(C=>C):void 0,M=r?r(C=>C.projectionsBySession):void 0,[_,se]=(0,P.useState)({}),[re,z]=(0,P.useState)(),[Q,V]=(0,P.useState)(),[F,G]=(0,P.useState)(),[W,ee]=(0,P.useState)(!1),[ce,I]=(0,P.useState)(),[R,H]=(0,P.useState)(),[L,ue]=(0,P.useState)(!1),[he,ae]=(0,P.useState)(),[oe,me]=(0,P.useState)(),[ke,ge]=(0,P.useState)(!1),[Z,ne]=(0,P.useState)(),[ye,we]=(0,P.useState)(()=>typeof document<"u"&&ct(document)),[k,d]=(0,P.useState)("default"),[T,B]=(0,P.useState)(""),[Ie,zo]=(0,P.useState)("time"),[xe,Go]=(0,P.useState)("workspace"),[ht,Uo]=(0,P.useState)("runs"),Wn=(0,P.useRef)(null),Me=(0,P.useMemo)(()=>new Set(h),[h]),_n=(0,P.useMemo)(()=>{let C=p.snapshot;if(C===void 0)return[];let q=new Map(C.automations.map(ve=>[ve.id,ve.timeZone]));return hn(C.automations,C.runs).map(ve=>({...ve,sessions:ve.sessions.filter(Ae=>Bt(Ae.id,Me,k)).map(Ae=>{let Te=C.runs.find(nn=>nn.sessionId===Ae.id);return{...Ae,title:qe(Te&&(Te.startedAt||Te.scheduledFor)||"",q.get(ve.id)),updatedAt:Te&&(Te.startedAt||Te.scheduledFor)||"",running:Ae.running||y[Ae.id]?.running===!0}})})).filter(ve=>ve.sessions.length>0)},[Me,k,y,p.snapshot]);(0,P.useEffect)(()=>{if(!yn(u,p.snapshot?.runs)){Wn.current=null;return}Wn.current!==u&&(Wn.current=u,t.refresh().catch(()=>{}))},[t,u,p.snapshot?.runs]);let zn=(0,P.useMemo)(()=>{let C=xe==="workspace-tree"?ds(_n.flatMap(q=>q.sessions.map(ve=>({...ve,automationId:q.id}))),S,n("sidebar.ungrouped")):_n;return ls(C.map(q=>({...q,name:q.name})),T,Ie,xe)},[xe,_n,T,Ie,n,S]);(0,P.useEffect)(()=>{if(typeof document>"u"||typeof MutationObserver>"u")return;let C=()=>{we(ct(document))};C();let q=new MutationObserver(C);return q.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{q.disconnect()}},[]);let Bo=ye&&a!==void 0,$o=to(ye,c),gt=l!==void 0,Vo=()=>{if(F===void 0||a===void 0||W)return;let C=F;ee(!0),I(void 0),io(C.sessionIds,a).then(()=>{G(void 0)}).catch(q=>{I(q instanceof Error?q.message:n("error.action"))}).finally(()=>{ee(!1)})},Ko=()=>{if(R===void 0||l===void 0||L)return;let C=R;ue(!0),ae(void 0),ao(C.sessionIds,l).then(()=>{H(void 0)}).catch(q=>{ae(q instanceof Error?q.message:n("error.action"))}).finally(()=>{ue(!1)})},qo=()=>{if(oe===void 0||c===void 0||ke)return;let C=oe;ge(!0),ne(void 0),Promise.resolve(c(C.id)).then(()=>{me(void 0)}).catch(q=>{ne(q instanceof Error?q.message:n("error.action"))}).finally(()=>{ge(!1)})};return(0,v.jsxs)("div",{className:"dsh-st-n",children:[(0,v.jsx)(Mn,{t:n,view:ht,onChange:Uo}),ht==="overview"?p.snapshot===void 0?(0,v.jsx)("div",{className:"dsh-st-n-empty",children:p.phase==="loading"?n("loading"):n("overview.empty")}):(0,v.jsx)(Ln,{t:n,automations:p.snapshot.automations,onToggleAutomation:(C,q)=>t.mutateAutomation(C,q),...x===void 0?{}:{openTaskSettings:x},...p.snapshot.serverNow===void 0?{}:{serverNow:p.snapshot.serverNow}}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(bo,{t:n,query:T,sort:Ie,groupMode:xe,archivedFilter:k,onQueryChange:B,onSortChange:zo,onGroupModeChange:Go,onArchivedFilterChange:d}),(0,v.jsx)("div",{className:"dsh-st-n-list-area",children:(0,v.jsxs)("div",{className:"dsh-st-n-tree",role:"tree",children:[p.phase==="loading"&&zn.length===0&&(0,v.jsx)("div",{className:"dsh-st-n-empty",children:n("loading")}),zn.length===0&&p.phase!=="loading"&&(0,v.jsx)("div",{className:"dsh-st-n-empty",children:n("sidebar.empty")}),zn.map(C=>{let q=_[C.id]!==!0,ve=oo(C.sessions.map(E=>E.id),u),Ae="depth"in C?C.depth:0,Te=[...new Set(C.sessions.flatMap(E=>"automationId"in E&&typeof E.automationId=="string"?[E.automationId]:[]))],nn=xe==="workspace-tree"&&Te.length===1?p.snapshot?.automations.find(E=>E.id===Te[0]):void 0,Gn=xe==="workspace-tree"?nn?.id:C.id,jo=xe==="workspace-tree"?nn?.name:C.name,yt=C.sessions.filter(E=>!Me.has(E.id)).map(E=>E.id),vt=C.sessions.filter(E=>Me.has(E.id)).map(E=>E.id),Zo=Bo&&yt.length>0,Xo=gt&&vt.length>0;return(0,v.jsxs)("div",{className:"dsh-st-n-group",style:Ae>0?{"--dsh-workspace-indent":`${Ae*12}px`}:void 0,children:[xe!=="list"&&(0,v.jsx)(Br,{t:n,id:C.id,name:C.name,sessionIds:C.sessions.map(E=>E.id),expanded:q,hasCurrentSession:ve,menuOpen:Q===C.id,canArchiveGroup:Zo,canUnarchiveGroup:Xo,showTaskSettings:Gn!==void 0,onToggle:()=>se(E=>({...E,[C.id]:q})),onMenuChange:E=>{z(void 0),V(E?C.id:void 0)},onTaskSettings:()=>{Gn!==void 0&&x?.({automationId:Gn,name:jo??C.name,sessionIds:C.sessions.map(E=>E.id)})},onArchiveGroup:()=>{I(void 0),G({id:C.id,name:C.name,sessionIds:yt})},onUnarchiveGroup:()=>{ae(void 0),H({id:C.id,name:C.name,sessionIds:vt})}}),(xe==="list"||q)&&C.sessions.map(E=>(0,v.jsx)($r,{t:n,flat:xe==="list",id:E.id,title:E.title,hoverTitle:String(y[E.id]?.displayTitle??y[E.id]?.title??C.name),updatedAt:E.updatedAt,running:E.running,archived:Me.has(E.id),selected:u===E.id,menuOpen:re===E.id,canDelete:$o,canUnarchive:gt,hoverStatuses:po({running:E.running||N?.get(E.id)?.running===!0,archived:Me.has(E.id),completed:N?.get(E.id)?.completionUnread===!0,...N?.get(E.id)?.pendingInteraction?.kind===void 0?{}:{pendingKind:N.get(E.id)?.pendingInteraction?.kind??""},runningSubagentCount:(M?.[E.id]?.values?.subagentCatalog??[]).filter(tn=>tn.id!==void 0&&N?.get(tn.id)?.running===!0).length},n),...A===void 0?{}:{renderSlot:A},onMenuChange:tn=>{V(void 0),z(tn?E.id:void 0)},onOpen:()=>{if(z(void 0),Me.has(E.id)){m?.();return}s?.(E.id)},onDeleteSession:()=>{ne(void 0),me({id:E.id,title:String(y[E.id]?.displayTitle??y[E.id]?.title??E.title)})},...o===void 0?{}:{renameSession:o},...a===void 0?{}:{archiveSession:a},...l===void 0?{}:{unarchiveSession:l},...g===void 0?{}:{forkSession:g}},E.id))]},C.id===""?"ungrouped":C.id)})]})})]}),(0,v.jsx)(K.Modal,{open:F!==void 0,onClose:()=>{W||(G(void 0),I(void 0))},closeLabel:n("session.archiveGroupClose"),title:n("session.archiveGroup"),...F===void 0?{}:{description:n("session.archiveGroupDescription",{name:F.name,count:F.sessionIds.length})},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:W,onClick:()=>{G(void 0),I(void 0)},children:n("session.archiveGroupCancel")}),(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:W,onClick:Vo,children:n("session.archiveGroupConfirm")})]}),children:W||ce!==void 0?(0,v.jsxs)(v.Fragment,{children:[W&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.archiveGroupPending")}),ce!==void 0&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.archiveGroupFailed",{message:ce})})]}):void 0}),(0,v.jsx)(K.Modal,{open:R!==void 0,onClose:()=>{L||(H(void 0),ae(void 0))},closeLabel:n("session.unarchiveGroupClose"),title:n("session.unarchiveGroup"),...R===void 0?{}:{description:n("session.unarchiveGroupDescription",{name:R.name,count:R.sessionIds.length})},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:L,onClick:()=>{H(void 0),ae(void 0)},children:n("session.unarchiveGroupCancel")}),(0,v.jsx)(K.Button,{variant:"primary",className:"dsh-st-modal-action",disabled:L,onClick:Ko,children:n("session.unarchiveGroupConfirm")})]}),children:L||he!==void 0?(0,v.jsxs)(v.Fragment,{children:[L&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.unarchiveGroupPending")}),he!==void 0&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.unarchiveGroupFailed",{message:he})})]}):void 0}),(0,v.jsx)(K.Modal,{open:oe!==void 0,onClose:()=>{ke||(me(void 0),ne(void 0))},closeLabel:n("session.deleteSessionClose"),title:n("session.deleteSession"),...oe===void 0?{}:{description:n("session.deleteSessionDescription",{name:oe.title})},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:ke,onClick:()=>{me(void 0),ne(void 0)},children:n("session.deleteSessionCancel")}),(0,v.jsx)(K.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:ke,onClick:qo,children:n("session.deleteSessionConfirm")})]}),children:ke||Z!==void 0?(0,v.jsxs)(v.Fragment,{children:[ke&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.deleteSessionPending")}),Z!==void 0&&(0,v.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.deleteSessionFailed",{message:Z})})]}):void 0})]})}function Br(e){let{t:n,id:t,name:s,expanded:r,hasCurrentSession:i,menuOpen:o,canArchiveGroup:a,canUnarchiveGroup:l,showTaskSettings:c,onToggle:g,onMenuChange:m,onTaskSettings:x,onArchiveGroup:A,onUnarchiveGroup:f}=e,p=[...c?[{id:"task-settings",label:n("session.taskSettings"),icon:(0,v.jsx)(gs,{size:16})}]:[],...a?[...c?[{type:"separator",id:"archive-separator"}]:[],{id:"archive-group",label:n("session.archiveGroup"),icon:(0,v.jsx)(_e,{size:16}),danger:!0}]:[],...l?[...c&&!a?[{type:"separator",id:"unarchive-separator"}]:[],{id:"unarchive-group",label:n("session.unarchiveGroup"),icon:(0,v.jsx)(Xn,{size:16})}]:[]],u="dsh-st-n-row"+(i?" has-current-session":"")+(o?" is-menu":"");return(0,v.jsxs)("div",{className:u,role:"treeitem","aria-expanded":r,"data-n-group":t,onClick:g,children:[(0,v.jsx)("span",{className:"dsh-st-n-slot dsh-st-n-folder",children:r?(0,v.jsx)(Ss,{size:16}):(0,v.jsx)(Sn,{size:16})}),(0,v.jsx)("span",{className:"dsh-st-n-slot dsh-st-n-chevron",children:(0,v.jsx)(ks,{size:14,className:"dsh-st-n-arrow"+(r?" is-open":"")})}),(0,v.jsx)("span",{className:"dsh-st-n-project-text",children:(0,v.jsx)("span",{className:"dsh-st-n-title",children:s})}),(0,v.jsx)("span",{className:"dsh-st-n-acts",children:(0,v.jsx)(K.Menu,{open:o,onClose:()=>{m(!1)},items:p,onSelect:y=>{m(!1),y==="task-settings"&&x(),y==="archive-group"&&A(),y==="unarchive-group"&&f?.()},portal:!0,closeOnPointerLeave:!0,anchor:(0,v.jsx)(K.Tooltip,{label:n("session.groupActions",{name:s}),side:"bottom",delayMs:500,portal:!0,children:(0,v.jsx)("button",{type:"button",className:"dsh-st-n-ico","aria-label":n("session.groupActions",{name:s}),onMouseDown:y=>{y.stopPropagation()},onClick:y=>{y.stopPropagation(),m(!o)},children:(0,v.jsx)(Xe,{size:16})})})})})]})}function $r(e){let{t:n,flat:t,id:s,title:r,hoverTitle:i,updatedAt:o,running:a,archived:l,selected:c,menuOpen:g,canDelete:m,canUnarchive:x,hoverStatuses:A,renderSlot:f,onMenuChange:p,onOpen:u,onDeleteSession:y,renameSession:h,archiveSession:S,unarchiveSession:N,forkSession:M}=e,_=ro(t,a),se=(0,P.useRef)(null),re=(0,P.useRef)(null),[z,Q]=(0,P.useState)(!1),[V,F]=(0,P.useState)({}),G=(0,P.useRef)(void 0),W=(0,P.useRef)(null),ee=(0,P.useRef)({id:0});(0,P.useEffect)(()=>()=>{ut(W.current,ee.current)},[]);let[ce,I]=(0,P.useState)(!1),[R,H]=(0,P.useState)(r);(0,P.useEffect)(()=>{H(r)},[r]),(0,P.useEffect)(()=>{if(typeof K.HoverCard=="function"||!z||g)return;let d=()=>{let T=se.current?.getBoundingClientRect(),B=re.current;if(T===void 0)return;let Ie=B===null?{width:220,height:96}:{width:B.offsetWidth,height:B.offsetHeight};F(uo({right:T.right,top:T.top},Ie,{width:window.innerWidth,height:window.innerHeight}))};return d(),window.addEventListener("resize",d),document.addEventListener("scroll",d,!0),()=>{window.removeEventListener("resize",d),document.removeEventListener("scroll",d,!0)}},[z,g,r,o,a]),(0,P.useEffect)(()=>()=>{G.current!==void 0&&window.clearTimeout(G.current)},[]);let L=d=>{Promise.resolve(d()).catch(()=>{})},ue=()=>{typeof K.HoverCard=="function"||g||(G.current!==void 0&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>Q(!0),500))},he=()=>{G.current!==void 0&&window.clearTimeout(G.current),Q(!1)},ae="dsh-st-n-sess"+(c?" is-on":"")+(g?" is-menu":"")+(_?" is-flat-idle":"")+(l?" is-archived":"");if(ce)return(0,v.jsx)("div",{className:ae,ref:se,children:(0,v.jsx)("input",{className:"dsh-st-n-rename",value:R,autoFocus:!0,"aria-label":n("session.rename"),onChange:d=>H(d.target.value),onClick:d=>d.stopPropagation(),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),I(!1),R.trim()!==""&&R.trim()!==r&&L(()=>h?.(s,R.trim()))),d.key==="Escape"&&(d.preventDefault(),I(!1),H(r))},onBlur:()=>{I(!1),R.trim()!==""&&R.trim()!==r&&L(()=>h?.(s,R.trim()))}})});let oe=(i??r).trim()||r,me=f!==void 0?["pin","rename","fork","archive","session-id","archive-manager.delete-session"].map(d=>f("sidebar.workspaces.session.menu.item",{sessionId:s,displayTitle:oe},{hookContext:[g,T=>p(T)],only:d})).filter(Boolean):void 0,ge=me!==void 0&&me.some(Boolean)?l&&m?[{id:"delete-session",label:n("session.deleteSession"),icon:(0,v.jsx)(Zn,{}),danger:!0}]:[]:[...so({canDelete:m,archived:l,canUnarchive:x}).map(d=>d==="rename"?{id:d,label:n("session.rename"),icon:(0,v.jsx)(vs,{})}:d==="fork"?{id:d,label:n("session.fork"),icon:(0,v.jsx)(ys,{})}:d==="archive"?{id:d,label:n("session.archive"),icon:(0,v.jsx)(_e,{size:16})}:d==="unarchive"?{id:d,label:n("session.unarchive"),icon:(0,v.jsx)(Xn,{size:16})}:{id:d,label:n("session.deleteSession"),icon:(0,v.jsx)(Zn,{}),danger:!0}),{id:"session-id",label:n("session.copySessionId"),icon:(0,v.jsx)(xs,{size:16})}],Z=A.find(d=>d.state!=="archived"),ne=!l&&Z!==void 0&&Z.state!=="idle",ye=Z?.trailing,we=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("div",{className:"dsh-st-n-hover-title",children:oe}),(0,v.jsx)("div",{className:"dsh-st-n-hover-time",children:yo(o,n)}),A.map(d=>(0,v.jsxs)("div",{className:"dsh-st-n-hover-state",children:[d.state==="archived"?(0,v.jsx)(_e,{size:14}):(0,v.jsx)(K.StateDot,{state:d.state==="ongoing"?"ongoing":d.state==="warning"?"warning":d.state==="done"?"done":"idle",size:10}),d.label]},d.label))]}),k=(0,v.jsxs)("div",{className:ae,ref:se,role:"treeitem",tabIndex:0,"aria-selected":c,"data-n-menu-root":s,onClick:u,onMouseEnter:()=>{ho(W.current,ee.current),ue()},onMouseLeave:()=>{ut(W.current,ee.current),he()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),u())},onContextMenu:d=>{d.preventDefault(),d.stopPropagation(),he(),p(!0)},children:[!_&&(0,v.jsx)("span",{className:"dsh-st-n-slot",children:ne&&Z!==void 0?(0,v.jsx)(K.StateDot,{state:Z.state==="ongoing"?"ongoing":Z.state==="warning"?"warning":"done",size:10}):a?(0,v.jsx)(K.StateDot,{state:"ongoing",size:10}):null}),(0,v.jsx)("span",{ref:W,className:"dsh-st-n-title",onDoubleClick:d=>{h!==void 0&&(d.stopPropagation(),I(!0))},children:r}),(0,v.jsx)("span",{className:"dsh-st-n-time","aria-hidden":ye===void 0?void 0:!0,children:ye??go(o,n)}),(0,v.jsxs)("span",{className:"dsh-st-n-acts",children:[me===void 0&&l&&x&&(0,v.jsx)("button",{type:"button",className:"dsh-st-n-restore",onMouseDown:d=>{d.stopPropagation()},onClick:d=>{d.stopPropagation(),L(()=>N?.(s))},children:n("session.unarchive")}),(0,v.jsx)(K.Menu,{open:g,onClose:()=>{p(!1)},items:ge,onSelect:d=>{p(!1),d==="rename"&&I(!0),d==="fork"&&L(()=>M?.(s)),d==="archive"&&L(()=>S?.(s)),d==="unarchive"&&L(()=>N?.(s)),d==="session-id"&&navigator.clipboard?.writeText(s),d==="delete-session"&&y?.()},portal:!0,closeOnPointerLeave:!0,anchor:(0,v.jsx)(K.Tooltip,{label:n("session.moreActions",{title:r}),side:"bottom",delayMs:500,portal:!0,children:(0,v.jsx)("button",{type:"button",className:"dsh-st-n-ico","aria-label":n("session.moreActions",{title:r}),onMouseDown:d=>{d.stopPropagation()},onClick:d=>{d.stopPropagation(),he(),p(!g)},children:(0,v.jsx)(Xe,{size:16})})}),children:me}),co(f,"sidebar.workspaces.session.row.action",{sessionId:s,displayTitle:oe},{only:"archive"})]}),typeof K.HoverCard!="function"&&z&&!g&&typeof document<"u"&&(0,ko.createPortal)((0,v.jsx)("div",{ref:re,className:"dsh-st-n-hover",style:V,onMouseEnter:ue,onMouseLeave:he,children:we}),document.body)]});return typeof K.HoverCard!="function"?k:(0,v.jsx)(K.HoverCard,{anchor:k,content:we,openDelayMs:800,disabled:g,copyText:oe,copyLabel:n("session.copy"),copiedLabel:n("session.copied")})}var U=require("react"),To=require("@deepseek-ai/dsh-client-ui-primitives");var O=require("react/jsx-runtime"),xo=[],Ao=e=>()=>{},pt=class extends U.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(n){console.warn("[dsh-automation] official workspace tree crashed",n)}render(){return this.state.failed?this.props.fallback:this.props.children}};function Io({t:e,runtime:n,openSession:t,openTaskSettings:s,view:r,showViewSwitch:i=!0}){let o=(0,U.useSyncExternalStore)(n.source.subscribe,n.source.getSnapshot,n.source.getSnapshot),[a,l]=(0,U.useState)({}),[c,g]=(0,U.useState)("runs"),m=r??c,x=o.snapshot,A=(0,U.useMemo)(()=>x===void 0?[]:hn(x.automations,x.runs),[x]);return(0,O.jsxs)("div",{className:"dsh-st-rail",children:[i&&(0,O.jsx)(Mn,{t:e,view:m,onChange:g}),m==="overview"?x===void 0?(0,O.jsx)("div",{className:"dsh-st-rail-empty",children:o.phase==="loading"?e("loading"):e("overview.empty")}):(0,O.jsx)(Ln,{t:e,automations:x.automations,onToggleAutomation:(f,p)=>n.mutateAutomation(f,p),...s===void 0?{}:{openTaskSettings:s},...x.serverNow===void 0?{}:{serverNow:x.serverNow}}):(0,O.jsxs)(O.Fragment,{children:[o.phase==="loading"&&A.length===0&&(0,O.jsx)("div",{className:"dsh-st-rail-empty",children:e("loading")}),A.length===0&&o.phase!=="loading"&&(0,O.jsx)("div",{className:"dsh-st-rail-empty",children:e("sidebar.empty")}),A.map(f=>(0,O.jsxs)("section",{className:"dsh-st-rail-group",children:[(0,O.jsxs)("button",{type:"button",className:"dsh-st-rail-head",onClick:()=>l(p=>({...p,[f.id]:!p[f.id]})),children:[(0,O.jsx)("span",{className:"dsh-st-rail-folder",children:(0,O.jsx)(Ne,{size:16})}),(0,O.jsx)("span",{className:"dsh-st-rail-title",children:f.name})]}),a[f.id]!==!0&&f.sessions.map(p=>(0,O.jsxs)("button",{type:"button",className:"dsh-st-rail-session",onClick:()=>t?.(p.id),children:[(0,O.jsx)("span",{children:p.label}),p.running&&(0,O.jsx)(To.StateDot,{state:"ongoing",size:10})]},p.id))]},f.id))]})]})}function Co({t:e,runtime:n,officialTree:t,hostProps:s,openSession:r,openTaskSettings:i,useSessions:o,useWorkspaces:a,renderSlot:l,hasChannels:c,subscribeChannels:g,tabRegistry:m,wide:x}){let A=t,[f,p]=(0,U.useState)(()=>{try{return Kt(window.localStorage.getItem(qn))}catch{return"tasks"}}),u=(0,U.useSyncExternalStore)(m?.subscribe??Ao,()=>m?.getTabs()??xo,()=>xo),y=(0,U.useSyncExternalStore)(g??Ao,()=>{try{return c?.()===!0}catch{return!1}},()=>!1),h=o?.(I=>je(I)),S=(0,U.useSyncExternalStore)(n.source.subscribe,n.source.getSnapshot,n.source.getSnapshot),N=(0,U.useMemo)(()=>$t(S.snapshot?.runs),[S.snapshot]),M=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!yn(h,S.snapshot?.runs)){M.current=null;return}M.current!==h&&(M.current=h??null,n.refresh().catch(()=>{}))},[S.snapshot?.runs,h,n]);let _=(0,U.useCallback)((I,R)=>o===void 0?I({ids:[],byId:{}}):o(H=>I(Qt(H,N)),R),[o,N]),se=(0,U.useCallback)((I,R)=>a===void 0?I({items:[],archivedSessionIds:[]}):a(H=>I(os(H,N)),R),[a,N]);(0,U.useEffect)(()=>{try{window.localStorage.setItem(qn,f)}catch{}},[f]),(0,U.useEffect)(()=>{let I=R=>{let H=R.target instanceof Element?R.target.closest("button"):null;if(H===null)return;let L=`${H.textContent??""} ${H.getAttribute("aria-label")??""}`;/新会话|新建任务|New chat|New session/i.test(L)&&p("tasks")};return document.addEventListener("click",I,!0),()=>document.removeEventListener("click",I,!0)},[]);let re=(0,U.useRef)(h),z=(0,U.useRef)(!1);(0,U.useEffect)(()=>{let I=Xt(h??void 0,N);if(!z.current){z.current=!0,re.current=h,I==="tasks"&&p("tasks");return}let R=re.current;if(re.current=h,!qt(R,h))return;let H=u.map(ue=>ue.id);I==="tasks"&&p("tasks"),I==="channels"&&(y||H.includes("channels"))&&p("channels");let L=u.find(ue=>h!=null&&ue.matchSession?.(String(h))===!0);L!==void 0&&L.id!=="schedule"&&p(L.id)},[h,y,u,N]);let Q={...s??{},...x===void 0?{}:{wide:x}},V={...Q,...o===void 0?{}:{useSessions:_},...a===void 0?{}:{useWorkspaces:se}},F=I=>A===void 0?(0,O.jsx)(Vr,{t:e,...r===void 0?{}:{openSession:r},...o===void 0?{}:{useSessions:_},...a===void 0?{}:{useWorkspaces:a}}):(0,O.jsx)(pt,{fallback:(0,U.createElement)(A,Q),children:(0,U.createElement)(A,I)});if(x===!1)return(0,O.jsx)(O.Fragment,{children:F(V)});let G=u.filter(I=>I.id!=="schedule"),W=Zt({tab:f,channelsReady:y,extraTabIds:jt({extraTabIds:G.map(I=>I.id),channelsReady:y})}),ee=u.find(I=>I.id==="schedule"),ce=ee===void 0?(0,O.jsx)(Pn,{t:e,runtime:n,...r===void 0?{}:{openSession:r},...i===void 0?{}:{openTaskSettings:i},...o===void 0?{}:{useSessions:o},...a===void 0?{}:{useWorkspaces:a},...l===void 0?{}:{renderSlot:l},...Nn(s),...typeof s?.useSessionStatus=="function"?{useSessionStatus:s.useSessionStatus}:{}}):ee.render({...s??{},openSession:r,open:r,useSessions:o,wide:!0});return(0,O.jsxs)("div",{className:"dsh-st-shell-rail",children:[(0,O.jsxs)("div",{className:"dsh-st-shell-tabs",role:"tablist","aria-label":e("sidebar.tabs"),children:[(0,O.jsx)("button",{type:"button",role:"tab","aria-selected":W==="tasks",className:W==="tasks"?"is-on":void 0,onClick:()=>p("tasks"),children:e("sidebar.tasksTab")}),G.map(I=>(0,O.jsx)("button",{type:"button",role:"tab","aria-selected":W===I.id,className:W===I.id?"is-on":void 0,onClick:()=>p(I.id),children:I.label},I.id)),y&&G.every(I=>I.id!=="channels")&&(0,O.jsx)("button",{type:"button",role:"tab","aria-selected":W==="channels",className:W==="channels"?"is-on":void 0,onClick:()=>p("channels"),children:e("sidebar.channelsTab")}),(0,O.jsx)("button",{type:"button",role:"tab","aria-selected":W==="schedule",className:W==="schedule"?"is-on":void 0,onClick:()=>p("schedule"),children:e("sidebar.tab")})]}),W==="schedule"?(0,O.jsx)("div",{className:"dsh-st-shell-body",children:ce}):G.find(I=>I.id===W)!==void 0?(0,O.jsx)("div",{className:"dsh-st-shell-body",children:G.find(I=>I.id===W)?.render({...s??{},openSession:r,open:r,useSessions:o,wide:!0})}):W==="channels"?(0,O.jsx)("div",{className:"dsh-st-shell-body",children:l?.("sidebar.channels",{...s??{},openSession:r,open:r,useSessions:o,wide:!0,skin:"native"})}):(0,O.jsx)("div",{className:"dsh-st-official-tree",children:F(V)})]})}function Vr({t:e,openSession:n,useSessions:t,useWorkspaces:s}){let r=t===void 0?{ids:[],byId:{}}:t(l=>l??{ids:[],byId:{}}),i=s===void 0?void 0:s(l=>l??{items:[],archivedSessionIds:[]}),o=Vt(r,i,e("sidebar.ungrouped")),a=je(r);return o.length===0?(0,O.jsx)("div",{className:"dsh-st-rail-empty",children:e("sidebar.tasksEmpty")}):(0,O.jsx)("div",{className:"dsh-st-rail",children:o.map(l=>(0,O.jsxs)("section",{className:"dsh-st-rail-group",children:[(0,O.jsx)("div",{className:"dsh-st-rail-head is-static",children:(0,O.jsx)("span",{className:"dsh-st-rail-title",children:l.label})}),l.sessions.map(c=>(0,O.jsx)("button",{type:"button",className:`dsh-st-rail-session${a===c.id?" is-on":""}`,onClick:()=>{c.id!==void 0&&n?.(c.id)},children:(0,O.jsx)("span",{children:c.title||c.id})},c.id))]},l.id||"ungrouped"))})}var No="dsh-automation-styles",On="@michengai/dsh-automation",Ro=`
3
+ "use strict";var Yo=Object.create;var rn=Object.defineProperty;var Qo=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var nr=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var sr=(e,n)=>{for(var t in n)rn(e,t,{get:n[t],enumerable:!0})},St=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of er(n))!tr.call(e,r)&&r!==t&&rn(e,r,{get:()=>n[r],enumerable:!(s=Qo(n,r))||s.enumerable});return e};var an=(e,n,t)=>(t=e!=null?Yo(nr(e)):{},St(n||!e||!e.__esModule?rn(t,"default",{value:e,enumerable:!0}):t,e)),or=e=>St(rn({},"__esModule",{value:!0}),e);var vi={};sr(vi,{apply:()=>gi,inject:()=>li,name:()=>di});module.exports=or(vi);var He=require("react");var Q=require("react");function xt(e,n){return n(`run.trigger.${e}`)}var ue=class extends Error{constructor(t){super(t);this.key=t}},rr=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;function cn(e){return`/${rr.test(e.name)?e.name:e.id}`}function ir(e,n,t){let s=n.startsWith("/")?n:`/${n}`,r=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(^|\\s)${r}(?=\\s|$)`).test(e))return{text:e,caret:Math.min(Math.max(t,0),e.length)};let i=Math.min(Math.max(t,0),e.length),o=e.slice(0,i),a=e.slice(i),l=`${o.length>0&&!/\s$/.test(o)?" ":""}${s} `;return{text:o+l+a,caret:o.length+l.length}}function Bn(e,n){let t=Math.min(Math.max(n,0),e.length),s=/(?:^|\s)\/([^\s/]*)$/.exec(e.slice(0,t));if(s===null)return;let r=s[1]??"";return{start:t-r.length-1,query:r}}function kt(e,n){let t=n.trim().toLowerCase();return t===""?[...e]:e.filter(s=>s.id.toLowerCase().includes(t)||s.name.toLowerCase().includes(t))}function Tt(e,n,t){let s=Bn(e,n),r=t.startsWith("/")?t:`/${t}`;return s===void 0?ir(e,r,n):{text:`${e.slice(0,s.start)}${r} ${e.slice(n)}`,caret:s.start+r.length+1}}function At(e,n){let t=new Set(n.map(o=>cn(o).slice(1))),s=[],r=/(^|\s)(\/[a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/gi,i=0;for(let o of e.matchAll(r)){let a=o[1]??"",c=o[2]??"",l=(o.index??0)+a.length;t.has(c.slice(1))&&(l>i&&s.push({kind:"text",text:e.slice(i,l)}),s.push({kind:"skill",text:c}),i=l+c.length)}return(i<e.length||s.length===0)&&s.push({kind:"text",text:e.slice(i)}),s}function It(e=new Date){let n=new Date(e.getTime()+36e5);n.setMinutes(0,0,0);let t=n.getTimezoneOffset()*6e4;return new Date(n.getTime()-t).toISOString().slice(0,16)}function $n(e=new Date,n=[],t,s=""){return{name:"",prompt:"",scheduleKind:"daily",onceAt:It(e),everyMinutes:"60",maxConcurrentRuns:"1",intervalAnchor:"",time:"09:00",weekdays:[1,2,3,4,5],hourlyMinute:"00",monthDay:"1",customDays:"2",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone||"Asia/Shanghai",permission:s,workspaceId:n[0]?.id??"",modelKey:t==null?"default":`${t.provider}::${t.model}`,reasoningEffort:t?.reasoning?.defaultEffort??"none",skills:[]}}function Ct(e,n,t,s=new Date,r={}){let i=Number(e.maxConcurrentRuns);if(!Number.isSafeInteger(i)||i<1)throw new ue("form.error.maxConcurrentRuns");let o=e.name.trim(),a=e.prompt.trim();if(o==="")throw new ue("form.error.name");if(a==="")throw new ue("form.error.prompt");let c=n.find(m=>m.id===e.workspaceId);if(c===void 0)throw new ue("form.error.workspace");let l;switch(e.scheduleKind){case"once":{let m=new Date(e.onceAt);if(!Number.isFinite(m.getTime())||r.allowPastOnce!==!0&&m.getTime()<=s.getTime())throw new ue("form.error.once");l={kind:"once",at:m.toISOString(),timeZone:e.timeZone};break}case"interval":{let m=Number(e.everyMinutes);if(!Number.isInteger(m)||m<1||m>43200)throw new ue("form.error.interval");l={kind:"interval",everyMinutes:m,anchor:e.intervalAnchor.trim()||s.toISOString(),timeZone:e.timeZone};break}case"daily":l={kind:"daily",time:e.time,timeZone:e.timeZone};break;case"weekly":if(e.weekdays.length===0)throw new ue("form.error.weekdays");l={kind:"weekly",time:e.time,weekdays:[...e.weekdays].sort((m,k)=>m-k),timeZone:e.timeZone};break;case"hourly":{let m=Number(e.hourlyMinute);if(!Number.isInteger(m)||m<0||m>59)throw new ue("form.error.interval");l={kind:"hourly",minute:m,timeZone:e.timeZone};break}case"monthly":{let m=Number(e.monthDay);if(!Number.isInteger(m)||m<1||m>31)throw new ue("form.error.interval");l={kind:"monthly",day:m,time:e.time,timeZone:e.timeZone};break}case"custom":{let m=Number(e.customDays);if(!Number.isInteger(m)||m<1)throw new ue("form.error.interval");l={kind:"custom",everyDays:m,time:e.time,timeZone:e.timeZone};break}}let h=t.find(m=>`${m.provider}::${m.model}`===e.modelKey);return{name:o,prompt:a,schedule:l,timeZone:e.timeZone,permission:e.permission,maxConcurrentRuns:i,workspaceId:c.id,cwd:c.path,...h===void 0?{provider:null,model:null}:{provider:h.provider,model:h.model},reasoningEffort:e.reasoningEffort==="none"?null:e.reasoningEffort}}function Nt(e,n,t){let s=Date.parse(e);if(!Number.isFinite(s))return e;let r=Math.round((s-n.getTime())/6e4),i=Math.abs(r);if(i<1)return t("time.now");let o=r>0;if(i<60)return t(o?"time.inMinute":"time.minuteAgo",{count:i});let a=Math.round(i/60);if(a<24)return t(o?"time.inHour":"time.hourAgo",{count:a});let c=Math.round(a/24);return t(o?"time.inDay":"time.dayAgo",{count:c})}function un(e,n){switch(e.kind){case"once":return n("schedule.onceAt",{time:new Date(e.at).toLocaleString()});case"interval":return n("schedule.everyMinutes",{count:e.everyMinutes});case"daily":return n("schedule.dailyAt",{time:e.time});case"weekly":{let t=e.weekdays.map(s=>n(`day.${s}`)).join("\u3001");return n("schedule.weeklyAt",{days:t,time:e.time})}case"hourly":return n("schedule.hourlyAt",{minute:String(e.minute).padStart(2,"0")});case"monthly":return n("schedule.monthlyAt",{day:e.day,time:e.time});case"custom":return n("schedule.customAt",{count:e.everyDays,time:e.time})}}function pn(e,n,t){let s=Date.parse(e)-n.getTime();if(!Number.isFinite(s)||s<=0)return t("time.now");let r=Math.max(1,Math.ceil(s/6e4));if(r<60)return t("time.withinMinute",{count:r});let i=Math.ceil(r/60);return i<24?t("time.withinHour",{count:i}):t("time.withinDay",{count:Math.ceil(i/24)})}function Rt(e,n){if(e===void 0||n===void 0)return;let t=(Date.parse(n)-Date.parse(e))/1e3;if(!(!Number.isFinite(t)||t<0))return`${t.toFixed(1)}s`}function Et(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}var Mt=["succeeded","failed","interrupted","running","queued","skipped","cancelled"];function dn(e){let n=Date.parse(e);return Number.isFinite(n)?n:0}function mn(e,n,t){let s=t==="asc"?1:-1;return e.slice().sort((r,i)=>{if(n==="planned"){let a=r.nextRunAt,c=i.nextRunAt;if(a===void 0||c===void 0)return a===void 0&&c===void 0?r.name.localeCompare(i.name)||r.id.localeCompare(i.id):a===void 0?1:-1;let l=dn(a)-dn(c);return l!==0?l*s:r.name.localeCompare(i.name)||r.id.localeCompare(i.id)}let o=dn(r.createdAt)-dn(i.createdAt);return o!==0?o*s:r.id.localeCompare(i.id)})}var fn="dsh-automation.sort-default.settings",hn="dsh-automation.sort-default.overview";function Ne(e,n){if(e!==void 0)try{let t=e.getItem(n);if(t===null)return;let s=JSON.parse(t);return s.key!=="created"&&s.key!=="planned"||s.direction!=="asc"&&s.direction!=="desc"?void 0:{key:s.key,direction:s.direction}}catch{return}}function Lt(e,n,t,s){e.setItem(n,JSON.stringify({key:t,direction:s}))}function Pt(e,n,t,s){let r=new Map;for(let i of e){let o=new Date(i.finishedAt??i.startedAt??i.scheduledFor);if(Number.isNaN(o.getTime()))continue;let a;if(n==="month")a=`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}`;else if(n==="week"){let l=ar(o);a=ln(l)}else a=ln(o);let c=r.get(a)??[];c.push(i),r.set(a,c)}return[...r.entries()].map(([i,o])=>({key:i,label:o[0]===void 0?i:n==="month"?s("history.month",{month:i.replace("-","/")}):n==="week"?s("history.week",{date:i.slice(5).replace("-","/")}):i===ln(t)?s("history.today"):i===ln(new Date(t.getTime()-864e5))?s("history.yesterday"):s("history.date",{date:i.slice(5).replace("-","/")}),items:o}))}function ln(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function ar(e){let n=new Date(e),t=n.getDay(),s=t===0?6:t-1;return n.setHours(0,0,0,0),n.setDate(n.getDate()-s),n}function Dt(e,n=[],t,s=e.permission){let r=$n(new Date,n,t,s),i=e.schedule,o=e.provider&&e.model?`${e.provider}::${e.model}`:"default",a={...r,name:e.name,prompt:e.prompt,permission:e.permission,maxConcurrentRuns:String(e.maxConcurrentRuns??1),workspaceId:e.workspaceId??r.workspaceId,modelKey:o,reasoningEffort:e.reasoningEffort??"none",timeZone:e.timeZone||i.timeZone||r.timeZone};switch(i.kind){case"once":return{...a,scheduleKind:"once",onceAt:dr(i.at)};case"interval":return{...a,scheduleKind:"interval",everyMinutes:String(i.everyMinutes),intervalAnchor:i.anchor??""};case"hourly":return{...a,scheduleKind:"hourly",hourlyMinute:String(i.minute).padStart(2,"0")};case"daily":return{...a,scheduleKind:"daily",time:i.time};case"weekly":return{...a,scheduleKind:"weekly",time:i.time,weekdays:[...i.weekdays]};case"monthly":return{...a,scheduleKind:"monthly",time:i.time,monthDay:String(i.day)};case"custom":return{...a,scheduleKind:"custom",time:i.time,customDays:String(i.everyDays)}}}function dr(e){let n=new Date(e);if(Number.isNaN(n.getTime()))return It();let t=n.getTimezoneOffset()*6e4;return new Date(n.getTime()-t).toISOString().slice(0,16)}var qe=class extends Error{code="workspace/picker-unavailable";constructor(){super("workspace picker unavailable"),this.name="WorkspacePickerUnavailableError"}};function Le(e,n){if(!(e===null||typeof e!="object"&&typeof e!="function"))return Reflect.get(e,n)}function gn(e,n){if(e===null||typeof e!="object")return;let t;try{t=Reflect.get(e,"reflect")}catch{t=void 0}let s=Le(t,"get");if(typeof s=="function")try{let i=s.call(t,n);if(i!==void 0)return i}catch{}let r=Le(e,"get");if(typeof r=="function")try{let i=r.call(e,n);if(i!==void 0)return i}catch{return}if(typeof s!="function")try{return Le(e,n)}catch{return}}function Ht(e){if(typeof e=="string"&&e.trim()!=="")return e;if(e===null||typeof e!="object"||Reflect.get(e,"canceled")===!0)return;let n=Reflect.get(e,"path");if(typeof n=="string"&&n.trim()!=="")return n;let t=Reflect.get(e,"filePaths"),s=Array.isArray(t)?t[0]:void 0;return typeof s=="string"&&s.trim()!==""?s:void 0}async function Ot(e){let n=Le(e,"pickDirectory");if(typeof n=="function")return{picked:Ht(await n.call(e))}}async function Kn(e,n){let t=gn(e,"workspaces"),s=Le(t,"create");if(typeof s!="function")return!1;try{return await s.call(t,{path:n}),!0}catch{return!1}}async function jn(e){let n;try{n=Reflect.get(globalThis,"__DSH_DIRECTORY_PICKER__")}catch{n=void 0}let t=Le(n,"pick");if(typeof t=="function")return Ht(await t.call(n));for(let s of["uiWorkspace","dialog","workspaces"]){let r=await Ot(gn(e,s));if(r!==void 0)return r.picked}try{let s=await Ot(Le(e,"workspaces"));if(s!==void 0)return s.picked}catch{}throw new qe}var lr={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"},Ft=new Map;function cr(e){let n=Ft.get(e);if(n!==void 0)return n;let t=new Intl.DateTimeFormat("en-CA",{...lr,timeZone:e});return Ft.set(e,t),t}function Ze(e,n){let t=new Date(e);if(Number.isNaN(t.getTime()))return e;if(n===void 0){let s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`,r=`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`;return`${s} ${r}`}try{let s=cr(n).formatToParts(t),r=h=>s.find(m=>m.type===h)?.value,[i,o,a,c,l]=["year","month","day","hour","minute"].map(h=>r(h));return[i,o,a,c,l].some(h=>h===void 0)?e:`${i}-${o}-${a} ${c}:${l}`}catch{return e}}var We="dsh-automation-session-",Zn="dsh-automation.sidebar-tab";function yn(e,n){let t=new Map,s=new Map;for(let o of e)t.set(o.id,o.name),o.timeZone!==void 0&&s.set(o.id,o.timeZone);for(let o of n){let a=(o.automationName||"").trim();a!==""&&a!==o.automationId&&!t.has(o.automationId)&&t.set(o.automationId,a)}let r=[],i=new Set;for(let o of e)i.has(o.id)||(r.push(o.id),i.add(o.id));for(let o of n)o.sessionId===void 0||o.sessionId===""||i.has(o.automationId)||(r.push(o.automationId),i.add(o.automationId));return r.map(o=>{let a=t.get(o)??o;return{id:o,name:a,sessions:n.filter(c=>c.automationId===o&&c.sessionId!==void 0&&c.sessionId!=="").slice().sort((c,l)=>Date.parse(l.startedAt??l.scheduledFor)-Date.parse(c.startedAt??c.scheduledFor)).map(c=>({id:c.sessionId,running:c.status==="running"||c.status==="queued",label:Ze(c.startedAt??c.scheduledFor,s.get(o))+" - "+a}))}}).filter(o=>o.sessions.length>0)}function vn(e){return e==="active"?"pause":"resume"}function Bt(e){return e.map(n=>({id:n.id,name:n.name,status:n.status,...n.nextRunAt===void 0?{}:{nextRunAt:n.nextRunAt}}))}function $t(e,n,t){if(e===void 0||e==="")return!1;let s=n.has(e);return t==="only"?s:t==="show"?!0:!s}function bn(e,n){return e==null||e===""||!e.startsWith(We)?!1:!(n??[]).some(t=>t.sessionId===e)}function Kt(e){let n=new Set;for(let t of e??[]){let s=t.sessionId;typeof s=="string"&&s!==""&&n.add(s)}return n}var ur=/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/;function Xn(e,n,t=new Set){if(e.startsWith(We)||t.has(e))return!0;let s=String(n?.title??n?.displayTitle??"");return ur.test(s)}function Wt(e,n=new Set){if(e===void 0||e.blank===!0||e.origin==="im"||e.origin==="subagent")return!1;let t=e.id??"";return!(t.startsWith("im:")||Xn(t,e,n))}function jt(e,n,t,s=new Set){let r=e.byId??{},i=new Set(n?.archivedSessionIds??[]),o=new Set,a=[];for(let l of n?.items??[]){let h=(l.sessionIds??[]).map(m=>r[m]).filter(m=>m!==void 0&&m.id!==void 0&&Wt(m,s)&&!i.has(m.id));for(let m of h)m.id!==void 0&&o.add(m.id);h.length>0&&a.push({id:l.workspaceId??l.id??l.path??l.title??"workspace",label:l.title||l.path||t,sessions:h})}let c=(e.ids??[]).map(l=>r[l]).filter(l=>l!==void 0&&l.id!==void 0&&!o.has(l.id)&&Wt(l,s)&&!i.has(l.id));return c.length>0&&a.push({id:"",label:t,sessions:c}),a}function qt(e){return e==="channels"||e==="schedule"||e==="tasks"?e:"tasks"}function Zt(e,n){let t=e??"",s=n??"";return s!==""&&t!==s}function Xt(e){let n=["tasks"];for(let t of e.extraTabIds)t===""||t==="tasks"||t==="schedule"||n.includes(t)||n.push(t);return e.channelsReady&&!n.includes("channels")&&n.push("channels"),n.push("schedule"),n}function Jt(e){return e.extraTabIds.includes(e.tab)?e.tab:e.tab==="channels"&&e.channelsReady?"channels":"tasks"}function Yt(e,n){if(!(e==null||e===""))return(n!==void 0?n.has(e):e.startsWith(We))?"schedule":e.startsWith("im:")?"channels":"tasks"}function pr(e){return/dsh-codex-ui|michengai-codex-ui|michengai\.codexUi|codex-ui/i.test(String(e??""))}function mr(e){let n=e;return String(n?.options?.locale??n?.options?.id??n?.options?.name??n?.options?.registrant??n?.component?.displayName??n?.component?.name??n?.id??n?.name??"")}function Qt(e){return(e??[]).some(n=>pr(mr(n)))}var _t=new WeakMap,zt=new WeakMap;function es(e){return e.size===0?"":[...e].sort().join("\0")}function ns(e,n=new Set){let t=e??{ids:[],byId:{}},s=es(n);if(typeof t=="object"&&t!==null){let a=_t.get(t);if(a!==void 0&&a.key===s)return a.result}let r=(t.ids??[]).filter(a=>{let c=String(a);return!c.startsWith("im:")&&!Xn(c,t.byId?.[c],n)}),o=r.length===(t.ids??[]).length?t:{...t,ids:r,byId:Object.fromEntries(r.map(a=>[a,t.byId?.[a]]).filter(a=>a[1]!==void 0))};return typeof t=="object"&&t!==null&&_t.set(t,{key:s,result:o}),o}function Xe(e){let n=e?.byId??{};for(let[t,s]of Object.entries(n))if((s?.retainedBy?.mainView??0)>0){let r=s.id?.trim();return r!==void 0&&r!==""?r:t}return null}function fr(e){if(e===null||typeof e!="object")return;let n=e.openSession;if(typeof n=="function")return{openSession:t=>{n.call(e,t)}}}function ts(e){let n=fr(gn(e,"uiWorkspace"));return{...n===void 0?{}:{uiWorkspace:n}}}function ss(e){return typeof e.uiWorkspace?.openSession=="function"}function os(e,n){if(typeof e.uiWorkspace?.openSession=="function"){e.uiWorkspace.openSession(n);return}throw new Error("no client session opener")}function Gt(e,n,t){if(e==="")return!1;let s=e.startsWith(We)||e.startsWith("im:")?[n,t]:[t,n];for(let r of s)if(typeof r=="function")try{return r(e),!0}catch{}return!1}async function rs(e){let n=e.id.trim();return n===""?!1:(await e.adopt?.(n).catch(()=>{}),!(e.listed?.(n)===!0)&&e.refresh!==void 0&&await e.refresh().catch(()=>{}),Gt(n,e.openRuntime,e.openHost)?!0:(e.refresh!==void 0&&await e.refresh().catch(()=>{}),Gt(n,e.openRuntime,e.openHost)))}function hr(e,n=new Set){return e.startsWith("im:")||Xn(e,void 0,n)}function is(e,n=new Set){let t=e??{items:[],archivedSessionIds:[]},s=es(n);if(typeof t=="object"&&t!==null){let a=zt.get(t);if(a!==void 0&&a.key===s)return a.result}let r=!1,i=(t.items??[]).map(a=>{let c=(a.sessionIds??[]).filter(l=>!hr(String(l),n));return c.length!==(a.sessionIds??[]).length?(r=!0,{...a,sessionIds:c}):a}),o=r?{...t,items:i}:t;return typeof t=="object"&&t!==null&&zt.set(t,{key:s,result:o}),o}function as(e){return e==null||typeof e!="function"&&typeof e!="object"?{}:e}function gr(e){return as(e).__dshAutomationWrapped===!0}function ds(e){let n=new Set,t=e;for(;t!=null&&!n.has(t);){n.add(t);let s=as(t),r=s.__dshAutomationOriginal??s.__imConnectOriginal;if(r!==void 0&&r!==t){t=r;continue}return s.__dshAutomationWrapped===!0||s.__imConnectWrapped===!0?void 0:t}}function yr(e){let n=e,t=String(n?.options?.id??""),s=String(n?.component?.displayName??n?.component?.name??"");return t==="dsh-automation-native-switcher"||t==="dsh-automation-wrap-bump"||s==="AutomationNativeWorkspaceShell"||s==="AutomationWrapBump"||gr(n?.component)}function ls(e){for(let n of e)if(n?.component!==void 0&&!yr(n))return n}function Fe(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function Ut(e,n){let t=Fe(e),s,r=-1;for(let i of n){let o=Fe(i);o.length>r&&t!==o&&t.startsWith(`${o}/`)&&(s=i,r=o.length)}return s}function cs(e,n,t){let s=new Map;for(let u of n)for(let g of u.sessionIds??[])s.set(g,u);let r=new Map,i=[];for(let u of e){let g=u.id===void 0?void 0:s.get(u.id),v=g?.workspaceId??g?.id??g?.path;if(g===void 0||v===void 0||v===""){i.push(u);continue}let x=r.get(v)??[];x.push(u),r.set(v,x)}let o=new Map;for(let u of n)u.path!==void 0&&u.path!==""&&o.set(Fe(u.path),u);let a=new Map;for(let u of n){let g=u.workspaceId??u.id??u.path;if(g===void 0||g===""||!r.has(g))continue;a.set(g,u);let v=u.path,x=new Set;for(;v!==void 0&&v!==""&&!x.has(v);){x.add(v);let N=Ut(v,[...o.keys()]);if(N===void 0)break;let P=o.get(Fe(N)),W=P?.workspaceId??P?.id??P?.path;if(P===void 0||W===void 0||W==="")break;a.set(W,P),v=P.path}}let c=[...a.values()],l=c.map(u=>u.path).filter(u=>u!==void 0&&u!==""),h=u=>u.workspaceId??u.id??u.path??"",m=new Map,k=[];for(let u of c){let g=u.path===void 0?void 0:Ut(u.path,l),v=g===void 0?void 0:c.find(N=>N.path!==void 0&&Fe(N.path)===Fe(g)),x=v===void 0?void 0:h(v);if(v===void 0||x===void 0||x==="")k.push(u);else{let N=m.get(x)??[];N.push(u),m.set(x,N)}}let A=(u,g)=>(u.title||u.path||"").localeCompare(g.title||g.path||""),f=[],p=(u,g)=>{let v=h(u),x=r.get(v)??[];f.push({id:v,name:u.title||u.path||t,depth:g,keep:x.length===0,sessions:x});for(let N of(m.get(v)??[]).sort(A))p(N,g+1)};for(let u of k.sort(A))p(u,0);return i.length>0&&f.push({id:"",name:t,depth:0,sessions:i}),f}function us(e,n,t,s="workspace"){let r=n.trim().toLocaleLowerCase(),i=e.map(o=>{if(r===""||o.name.toLocaleLowerCase().includes(r))return o;let a=o.sessions.filter(c=>`${c.title??""} ${c.label??""}`.toLocaleLowerCase().includes(r));return{...o,sessions:a}}).filter(o=>o.sessions.length>0||r===""&&o.keep===!0||r!==""&&o.name.toLocaleLowerCase().includes(r));if(s==="list"){let o=i.flatMap(a=>[...a.sessions]);return t==="time"&&o.sort((a,c)=>qn(c)-qn(a)),o.length===0?[]:[{...i[0],name:"",sessions:o}]}return s==="workspace-tree"||t==="manual"?i:[...i].sort((o,a)=>Vt(a)-Vt(o))}function qn(e){let n=Date.parse(e.updatedAt??"");return Number.isFinite(n)?n:0}function Vt(e){let n=0;for(let t of e.sessions){let s=qn(t);s>n&&(n=s)}return n}var se=require("react/jsx-runtime");function Je({children:e,...n}){return(0,se.jsx)("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n,children:e})}function wn(e){return(0,se.jsx)(Je,{...e,children:(0,se.jsx)("path",{d:"M12 5v14M5 12h14"})})}function ps(e){return(0,se.jsxs)(Je,{...e,children:[(0,se.jsx)("path",{d:"M19 7v5h-5"}),(0,se.jsx)("path",{d:"M18.1 15.5A7.5 7.5 0 1 1 19 12"})]})}function ms(e){return(0,se.jsxs)(Je,{...e,children:[(0,se.jsx)("rect",{x:"4",y:"5.5",width:"16",height:"14",rx:"2"}),(0,se.jsx)("path",{d:"M8 3.8v3.4M16 3.8v3.4M4 9.5h16"})]})}function fs(e){return(0,se.jsxs)(Je,{...e,children:[(0,se.jsx)("circle",{cx:"12",cy:"12",r:"8.25"}),(0,se.jsx)("path",{d:"M12 10.4V16"}),(0,se.jsx)("path",{d:"M12 7.6h.01"})]})}function hs(e){return(0,se.jsx)(Je,{...e,children:(0,se.jsx)("path",{d:"M5.5 6.5h13v9.2H9.2L5.5 18.8V6.5Z"})})}function gs(e){return(0,se.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,"aria-hidden":"true",focusable:"false",...e,children:(0,se.jsx)("path",{fill:"currentColor",d:"M8 0a8 8 0 0 0-2.53 15.59c.4.074.547-.173.547-.385 0-.19-.007-.693-.01-1.36-2.226.484-2.695-1.073-2.695-1.073-.364-.924-.89-1.17-.89-1.17-.726-.496.055-.486.055-.486.803.056 1.225.824 1.225.824.714 1.223 1.872.87 2.328.665.072-.517.28-.87.508-1.07-1.777-.202-3.645-.888-3.645-3.956 0-.874.31-1.588.823-2.148-.083-.202-.357-1.017.078-2.12 0 0 .672-.215 2.2.82A7.65 7.65 0 0 1 8 4.8c.68.003 1.365.092 2.004.27 1.527-1.035 2.197-.82 2.197-.82.437 1.103.162 1.918.08 2.12.513.56.822 1.274.822 2.148 0 3.076-1.872 3.752-3.654 3.95.288.248.544.735.544 1.482 0 1.07-.01 1.932-.01 2.195 0 .214.144.463.55.384A8.001 8.001 0 0 0 8 0Z"})})}function ys(e){return(0,se.jsx)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...e,children:(0,se.jsx)("path",{d:"M9.5 2.5 13.5 6.5 6 14H2v-4z"})})}var Pe=require("react"),vr=an(require("@deepseek-ai/dsh-client-ui-primitives"),1);function Sn(e,n){return function(s){return e(s)??n(s)}}function X(e,...n){for(let t of n){let s=e[t];if(typeof s=="function")return s}return function(){return null}}var Y=vr;function br(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 3h4v3H3V3Zm6 1h4M3 10h4v3H3v-3Zm6 1.5h4M7 4.5h2M7 11.5h2",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"}))}function wr(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round"}))}function Sr(){return(0,Pe.createElement)("svg",{viewBox:"0 0 16 16",width:16,height:16,fill:"none","aria-hidden":!0},(0,Pe.createElement)("path",{d:"M3 6.5h10v6H3v-6Zm1.2-2.5h7.6L13 6.5H3L4.2 4Zm2.3 5.2 1.3 1.3 2.6-2.6",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"}))}var Ye=X(Y,"IconEllipsisOutlineRegular"),vs=X(Y,"IconSettingsOutlineRegular"),_e=X(Y,"IconArchiveOutlineRegular"),bs=X(Y,"IconBranchOutlineRegular"),ws=X(Y,"IconEditOutlineRegular"),Jn=X(Y,"IconTrashOutlineRegular"),Ei=X(Y,"IconCheckOutlineRegular"),Mi=X(Y,"IconChevronDownOutlineRegular"),Li=X(Y,"IconListPenOutlineRegular"),Ss=X(Y,"IconSearchOutlineRegular"),xs=X(Y,"IconCloseFillRegular"),xn=X(Y,"IconSlidersTwoOutlineRegular"),ze=X(Y,"IconFolderCloseRegular"),ks=X(Y,"IconFolderOpenRegular"),Ts=X(Y,"IconTriangleRightFillRegular"),Yn=X(Y,"IconUnarchiveOutlineRegular"),kn=Sn(X(Y,"IconWorkspaceTreeOutlineRegular"),br),Ge=Sn(X(Y,"IconFlatListOutlineRegular"),wr),Pi=X(Y,"IconChevronsUpDownOutlineRegular"),Ie=X(Y,"IconClockOutlineRegular"),As=X(Y,"IconCopyOutlineRegular"),Is=X(Y,"IconArchiveOffOutlineRegular"),Cs=Sn(X(Y,"IconArchiveCheckOutlineRegular"),Sr);var le=require("@deepseek-ai/dsh-client-ui-primitives");var Qn=an(require("react"),1),Ns=require("@deepseek-ai/dsh-client-ui-primitives"),et={width:22,minWidth:22,height:22,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"var(--dsw-radius-sm, 8px)"},Rs=Qn.default.forwardRef(function(n,t){let{className:s,rows:r,...i}=n;return Qn.default.createElement("textarea",{...i,ref:t,className:["dsh-st-textarea",s].filter(Boolean).join(" "),rows:r||4})}),Ue=Ns.Input;function Tn(e,n){let t=e.target;if(!(t instanceof Element)||t.getAttribute("aria-hidden")!=="true")return;let s=t.parentElement?.querySelector('[role="dialog"]');!(s instanceof HTMLElement)||!s.classList.contains(n)||e.stopPropagation()}var pe=an(require("react"),1),An=require("@deepseek-ai/dsh-client-ui-primitives");function nt(e){return{id:e.value,label:e.label,...e.disabled!==void 0?{disabled:e.disabled}:{},...e.danger!==void 0?{danger:e.danger}:{}}}function he(e){let[n,t]=pe.useState(!1),s=pe.useRef(null),r=e.options??[];pe.useEffect(()=>{if(!n)return;let l=s.current?.getBoundingClientRect().width??0;return l>0&&document.documentElement.style.setProperty("--dsh-st-menu-width",`${Math.round(l)}px`),()=>{document.documentElement.style.removeProperty("--dsh-st-menu-width")}},[n]),pe.useEffect(()=>{if(!n||typeof window>"u")return;let l=h=>{h.key==="Escape"&&(h.stopPropagation(),t(!1))};return window.addEventListener("keydown",l,!0),()=>{window.removeEventListener("keydown",l,!0)}},[n]);let i=pe.useMemo(()=>e.groups!==void 0&&e.groups.length>0?e.groups.flatMap(l=>[{type:"label",id:`label-${l.id}`,text:l.label},...l.options.map(nt)]):r.map(nt),[r,e.groups]),o=e.footer?.map(nt),a=r.find(l=>l.value===e.value)??e.groups?.flatMap(l=>[...l.options]).find(l=>l.value===e.value),c=a?a.label:e.placeholder??e.label??"";return pe.createElement("div",{ref:s,className:["dsh-st-menu-select-wrap",e.compact===!0?"is-compact":"",e.className].filter(Boolean).join(" ")},pe.createElement(An.Menu,{open:n,onClose:()=>{t(!1)},onSelect:l=>{if(e.footer?.some(h=>h.value===l)===!0){e.onFooter?.(l),t(!1);return}e.onChange(l),t(!1)},selectedId:e.value,align:"start",portal:!0,dense:!0,listClassName:["dsh-st-form-menu",e.listClassName].filter(Boolean).join(" "),...o!==void 0?{footer:o}:{},anchor:pe.createElement(An.Button,{variant:"outline",...e.compact===!0?{size:"sm"}:{},role:"combobox","aria-label":e.label??(typeof c=="string"?c:a?.text)??e.placeholder??"","aria-expanded":n,disabled:e.disabled,className:["dsh-st-menu-select-trigger",n?"is-open":""].filter(Boolean).join(" "),onClick:()=>{e.disabled||t(l=>!l)}},pe.createElement("span",{className:"dsh-st-menu-select-label"},c),pe.createElement("svg",{className:"dsh-st-menu-select-arrow",viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:4,transition:"transform 150ms ease",transform:n?"rotate(180deg)":"none"}},pe.createElement("path",{d:"m4 6 4 4 4-4"}))),items:i}))}var me=require("react");var xr=new Map([["read-only",["permission.readOnly","Read Only"]],["workspace-write",["permission.workspaceWrite","Workspace Write"]],["danger-full-access",["permission.fullAccess","Full access"]]]);function Es(e,n){let t=xr.get(e.value);return t!==void 0&&(e.name===e.value||e.name===t[1])?n(t[0]):e.name||e.value}function Ms(e,n){return e!==n&&n==="danger-full-access"}var be=require("@deepseek-ai/dsh-client-ui-primitives");var b=require("react/jsx-runtime");function kr(e,n,t,s){if(e==="deepseek-account"){let r=t("provider.account");return r&&r!=="provider.account"?r:s("form.providerAccount")}return n}function Tr(e,n){return(e==="deepseek-account"?0:e==="deepseek-official"?1:2)-(n==="deepseek-account"?0:n==="deepseek-official"?1:2)}function Ar(e){return(e.provider==="deepseek-account"||e.provider==="deepseek-official")&&e.model==="deepseek-flash"?(0,b.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,b.jsx)("span",{children:e.label}),(0,b.jsx)(be.Tag,{tone:"info",children:"1017"})]}):e.label}var Ir=[1,2,3,4,5,6,7],Cr=["once","interval","hourly","daily","weekly","monthly","custom"],Nr=Array.from({length:24},(e,n)=>String(n).padStart(2,"0")),Ds=Array.from({length:60},(e,n)=>String(n).padStart(2,"0"));function Os({t:e,permissionT:n,modelT:t,busy:s,workspaces:r,models:i,modelFailures:o,defaultModel:a,skills:c,permissions:l,defaultPermission:h,draft:m,editing:k,onClose:A,onSubmit:f,onAddWorkspace:p}){let[u,g]=(0,me.useState)(()=>({...$n(new Date,r,a,h),...m})),[v,x]=(0,me.useState)(),[N,P]=(0,me.useState)(),[W,oe]=(0,me.useState)(!1),[B,G]=(0,me.useState)(!1),[$,O]=(0,me.useState)(0),[K,V]=(0,me.useState)(0),[J,re]=(0,me.useState)(),ee=(0,me.useRef)(null),ne=(0,me.useRef)(0);(0,me.useEffect)(()=>{let d=_=>{if(_.key==="Escape"&&document.querySelector('[role="menu"]')===null){if(_.preventDefault(),_.stopPropagation(),_.stopImmediatePropagation(),N!==void 0){oe(!1),P(void 0);return}A()}},I=_=>{Tn(_,"dsh-st-create-dialog")};return window.addEventListener("keydown",d,!0),document.addEventListener("click",I,!0),()=>{window.removeEventListener("keydown",d,!0),document.removeEventListener("click",I,!0)}},[N,A]);let S=d=>{g(I=>({...I,...d})),x(void 0)},H=r.some(d=>d.id===u.workspaceId),E=async()=>{if(!(p===void 0||B)){G(!0),x(void 0),document.activeElement instanceof HTMLElement&&document.activeElement.blur();try{let d=await p();d!==void 0&&S({workspaceId:d})}catch(d){d instanceof qe?x(e("form.workspaceUnavailable")):d instanceof Error&&d.message!==""?x(d.message):x(e("form.addWorkspaceFailed"))}finally{G(!1)}}},ae=d=>{if(Ms(u.permission,d)){oe(!1),P(d);return}S({permission:d})},de=async d=>{d?.preventDefault();try{await f(u)}catch(I){if(I instanceof ue){x(e(I.key));return}x(I instanceof Error?I.message:e("error.action"))}},ce=u.onceAt.slice(0,10),ie=u.onceAt.slice(11,16)||"09:00",fe=Rr(new Date),ge=i.find(d=>`${d.provider}::${d.model}`===u.modelKey)?.reasoning,Z=Bn(u.prompt,$),te=Z===void 0||J===Z.query?[]:kt(c,Z.query),ye=Math.min(K,Math.max(te.length-1,0)),we=d=>{ne.current=d,O(d)};(0,me.useEffect)(()=>{let d=document.querySelector('.dsh-st-skill-menu [aria-selected="true"]');d instanceof HTMLElement&&d.scrollIntoView({block:"nearest"})},[ye,Z?.query]);let T=d=>{let I=Tt(u.prompt,ne.current,cn(d));S({prompt:I.text}),re(void 0),queueMicrotask(()=>{let _=ee.current;_!=null&&(_.focus(),_.setSelectionRange(I.caret,I.caret),we(I.caret))})};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(be.Modal,{open:!0,className:"dsh-st-create-dialog",title:e(k===!0?"modal.edit":"modal.title"),closeLabel:e("form.cancel"),onClose:A,footer:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(be.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:s,onClick:A,children:e("form.cancel")}),(0,b.jsx)(be.Button,{variant:"primary",className:"dsh-st-modal-action",type:"submit",form:"dsh-st-create-form",disabled:s||B||!H,children:e("modal.save")})]}),children:(0,b.jsxs)("form",{id:"dsh-st-create-form",className:"dsh-st-form",onSubmit:d=>{de(d)},children:[(0,b.jsx)("p",{children:e("form.subtitle")}),(0,b.jsxs)("label",{className:"dsh-st-field",children:[e("form.name"),(0,b.jsx)(Ue,{value:u.name,placeholder:e("form.namePlaceholder"),onChange:d=>S({name:d.target.value})})]}),(0,b.jsxs)("div",{className:"dsh-st-plan-row",children:[(0,b.jsxs)("div",{className:"dsh-st-field",children:[e("form.planTime"),(0,b.jsxs)("div",{className:"dsh-st-inline",children:[(0,b.jsx)(he,{value:u.scheduleKind,options:Cr.map(d=>({value:d,label:e(`form.${d}`)})),onChange:d=>S({scheduleKind:d})}),u.scheduleKind==="once"&&(0,b.jsx)(Ue,{type:"date",min:fe,value:ce,onChange:d=>S({onceAt:Ps(`${d.target.value}T${ie}`)})}),(u.scheduleKind==="once"||u.scheduleKind==="daily"||u.scheduleKind==="weekly"||u.scheduleKind==="monthly")&&(0,b.jsx)(Ls,{value:u.scheduleKind==="once"?ie:u.time,onChange:d=>{u.scheduleKind==="once"?S({onceAt:Ps(`${ce}T${d}`)}):S({time:d})}}),u.scheduleKind==="interval"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.every")}),(0,b.jsxs)("span",{className:"dsh-st-amount",children:[(0,b.jsx)(Ue,{type:"number",min:1,value:u.everyMinutes,onChange:d=>S({everyMinutes:d.target.value})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.minutes")})]})]}),u.scheduleKind==="hourly"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(he,{value:u.hourlyMinute,options:Ds.map(d=>({value:d,label:d})),onChange:d=>S({hourlyMinute:d})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.minutesShort")})]}),u.scheduleKind==="monthly"&&(0,b.jsx)(he,{value:u.monthDay,options:Array.from({length:31},(d,I)=>{let _=String(I+1);return{value:_,label:e("form.monthDay",{day:_})}}),onChange:d=>S({monthDay:d})}),u.scheduleKind==="custom"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.every")}),(0,b.jsxs)("span",{className:"dsh-st-amount",children:[(0,b.jsx)(Ue,{type:"number",min:1,value:u.customDays,onChange:d=>S({customDays:d.target.value})}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.daysShort")})]}),(0,b.jsx)("span",{className:"dsh-st-suffix",children:e("form.atTime")}),(0,b.jsx)(Ls,{value:u.time,onChange:d=>S({time:d})})]})]}),u.scheduleKind==="interval"&&(0,b.jsx)("span",{className:"dsh-st-plan-hint",children:e("form.intervalHint")}),u.scheduleKind==="custom"&&(0,b.jsx)("span",{className:"dsh-st-plan-hint",children:e("form.customHint")})]}),(0,b.jsxs)("label",{className:"dsh-st-field dsh-st-concurrency",title:e("form.maxConcurrentRunsHint"),children:[e("form.maxConcurrentRuns"),(0,b.jsx)(Ue,{type:"number",min:1,step:1,value:u.maxConcurrentRuns,onChange:d=>S({maxConcurrentRuns:d.target.value})})]})]}),u.scheduleKind==="weekly"&&(0,b.jsx)("div",{className:"dsh-st-weekdays",children:Ir.map(d=>(0,b.jsx)(be.Checkbox,{checked:u.weekdays.includes(d),label:e(`day.${d}`),onChange:I=>S({weekdays:I?[...u.weekdays,d]:u.weekdays.filter(_=>_!==d)})},d))}),(0,b.jsxs)("div",{className:"dsh-st-settings",children:[(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldWorkspace")}),r.length===0?(0,b.jsxs)("div",{className:"dsh-st-workspace-empty",children:[(0,b.jsx)(be.Button,{variant:"primary",icon:(0,b.jsx)(wn,{width:14,height:14}),disabled:B,onClick:()=>{E()},children:e("form.addWorkspace")}),(0,b.jsx)("span",{className:"dsh-st-workspace-note",children:e("form.workspaceRequired")})]}):(0,b.jsx)(he,{value:u.workspaceId,label:e("form.fieldWorkspace"),placeholder:e("form.workspace"),options:r.map(d=>({value:d.id,label:d.title})),footer:[{value:"add-workspace",label:e("form.addWorkspace"),disabled:B}],onFooter:()=>{E()},onChange:d=>S({workspaceId:d})})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldModel")}),(0,b.jsx)(he,{value:u.modelKey,label:e("form.fieldModel"),groups:Array.from(i.reduce((d,I)=>{let _=kr(I.provider,I.providerLabel,t,e),Ce=d.get(I.provider)??{label:_,options:[]};return Ce.options.push({value:`${I.provider}::${I.model}`,label:Ar(I),text:I.label}),d.set(I.provider,Ce),d},new Map)).sort(([d],[I])=>Tr(d,I)).map(([d,I])=>({id:d,label:I.label,options:I.options})),onChange:d=>{let I=i.find(_=>`${_.provider}::${_.model}`===d);S({modelKey:d,reasoningEffort:I?.reasoning?.defaultEffort??"none"})}})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldEffort")}),(0,b.jsx)(he,{disabled:ge===void 0,value:ge===void 0?"":u.reasoningEffort,label:e("form.fieldEffort"),placeholder:t("effort.providerDefault"),options:ge===void 0?[]:[...ge.defaultEffort===void 0?[{value:"none",label:t("effort.providerDefault")}]:[],...ge.efforts.map(d=>({value:d.id,label:d.name}))],onChange:d=>S({reasoningEffort:d})})]}),(0,b.jsxs)("label",{className:"dsh-st-picker-field",children:[(0,b.jsx)("span",{children:e("form.fieldPermission")}),(0,b.jsx)(he,{value:u.permission,options:l.map(d=>({value:d.value,label:Es(d,e)})),onChange:d=>ae(d)})]})]}),(0,b.jsxs)("div",{className:"dsh-st-field",children:[(0,b.jsxs)("span",{className:"dsh-st-prompt-label",children:[e("form.prompt"),(0,b.jsx)("em",{children:e("form.slashHint")})]}),(0,b.jsxs)("div",{className:"dsh-st-prompt-anchor",children:[Z!==void 0&&J!==Z.query&&(0,b.jsx)("div",{className:"dsh-st-skill-menu",role:"listbox",children:te.length===0?(0,b.jsx)("p",{children:e("form.slashEmpty")}):te.map((d,I)=>(0,b.jsxs)("button",{type:"button",role:"option","aria-selected":I===ye,onMouseDown:_=>_.preventDefault(),onClick:()=>T(d),children:[(0,b.jsx)("span",{children:d.name}),(0,b.jsx)("code",{children:cn(d)})]},d.id))}),(0,b.jsxs)("div",{className:"dsh-st-prompt-card",children:[(0,b.jsx)("div",{className:"dsh-st-prompt-backdrop","aria-hidden":"true",children:At(u.prompt,c).map((d,I)=>d.kind==="skill"?(0,b.jsx)("span",{className:"dsh-st-skill-token",children:d.text},I):(0,b.jsx)("span",{children:d.text},I))}),(0,b.jsx)(Rs,{ref:ee,spellCheck:!1,className:"dsh-st-prompt-input",value:u.prompt,placeholder:e("form.promptPlaceholder"),rows:4,onChange:d=>{we(d.target.selectionStart),S({prompt:d.target.value}),re(void 0)},onSelect:d=>we(d.currentTarget.selectionStart),onScroll:d=>{let I=d.currentTarget.closest(".dsh-st-prompt-card")?.querySelector(".dsh-st-prompt-backdrop");I instanceof HTMLElement&&(I.scrollTop=d.currentTarget.scrollTop)},onKeyDown:d=>{if(Z!==void 0){if(d.key==="Escape"){d.preventDefault(),re(Z.query);return}if(te.length!==0){if(d.key==="ArrowDown")d.preventDefault(),V(I=>(Math.min(I,te.length-1)+1)%te.length);else if(d.key==="ArrowUp")d.preventDefault(),V(I=>(Math.min(I,te.length-1)+te.length-1)%te.length);else if(d.key==="Enter"||d.key==="Tab"){d.preventDefault();let I=te[ye];I!==void 0&&T(I)}}}}})]})]})]}),o.map(d=>(0,b.jsx)("p",{className:"dsh-st-error",children:t("warning.groupLoad",{name:d.providerLabel,message:d.message})},d.provider)),v!==void 0&&(0,b.jsx)("p",{className:"dsh-st-error",children:v})]})}),(0,b.jsx)(be.RiskConfirmation,{open:N!==void 0,title:n("confirm.title"),description:n("confirm.description"),acknowledgeLabel:n("confirm.acknowledge"),cancelLabel:n("confirm.cancel"),closeLabel:n("confirm.cancel"),confirmLabel:n("confirm.enable"),acknowledged:W,onAcknowledgedChange:oe,onCancel:()=>{oe(!1),P(void 0)},onConfirm:()=>{!W||N===void 0||(S({permission:N}),oe(!1),P(void 0))}})]})}function Ls({value:e,onChange:n}){let[t,s]=e.split(":");return(0,b.jsxs)("span",{className:"dsh-st-time",children:[(0,b.jsx)(he,{value:t,options:Nr.map(r=>({value:r,label:r})),onChange:r=>n(`${r}:${s}`)}),(0,b.jsx)("span",{className:"dsh-st-time-sep",children:":"}),(0,b.jsx)(he,{value:s,options:Ds.map(r=>({value:r,label:r})),onChange:r=>n(`${t}:${r}`)})]})}function Rr(e){let n=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-n).toISOString().slice(0,10)}function Ps(e){let n=new Date(e),t=new Date;if(!Number.isFinite(n.getTime())||n.getTime()>t.getTime())return e;let s=new Date(t.getTime()+6e4);s.setSeconds(0,0);let r=s.getTimezoneOffset()*6e4;return new Date(s.getTime()-r).toISOString().slice(0,16)}var Hs=require("react"),Qe=require("@deepseek-ai/dsh-client-ui-primitives");var Re=require("react/jsx-runtime");function Fs({target:e,t:n,busy:t,onCancel:s,onConfirm:r}){return(0,Hs.useEffect)(()=>{if(e===void 0)return;let i=a=>{a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation(),s())},o=a=>{Tn(a,"dsh-st-delete-dialog")};return window.addEventListener("keydown",i,!0),document.addEventListener("click",o,!0),()=>{window.removeEventListener("keydown",i,!0),document.removeEventListener("click",o,!0)}},[s,e]),(0,Re.jsx)(Qe.Modal,{open:e!==void 0,className:"dsh-st-delete-dialog",title:n("card.confirmDelete"),...e===void 0?{}:{description:`${e.name} ${n("card.confirmDeleteHint")}`},closeLabel:n("card.cancel"),onClose:s,footer:(0,Re.jsxs)(Re.Fragment,{children:[(0,Re.jsx)(Qe.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:t,onClick:s,children:n("card.cancel")}),(0,Re.jsx)(Qe.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:t,onClick:r,children:n("card.confirm")})]})})}var en=null,tt=new Set;function Ws(e){en=e;for(let n of[...tt])n(en)}function st(){let e=en;return en=null,e}function _s(){return en}function zs(e){return tt.add(e),()=>{tt.delete(e)}}function Gs(e){let n=document.querySelector("[data-composer-seat] textarea");return n instanceof HTMLTextAreaElement?(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,"value")?.set?.call(n,e),n.dispatchEvent(new InputEvent("input",{bubbles:!0})),n.focus(),!0):!1}function nn(e){if(typeof e!="object"||e===null||!("ok"in e))throw new Error("\u81EA\u52A8\u5316\u4E3B\u673A\u8FD4\u56DE\u4E86\u65E0\u6548\u54CD\u5E94\u3002");let n=e;if(n.ok===!0&&"value"in n)return n.value;if(n.ok===!1&&"error"in n){let t=n.error;throw new Error(t?.message??"\u81EA\u52A8\u5316\u8BF7\u6C42\u5931\u8D25\u3002")}throw new Error("\u81EA\u52A8\u5316\u4E3B\u673A\u8FD4\u56DE\u4E86\u65E0\u6548\u54CD\u5E94\u3002")}var tn="/dsh-automation",Vs=15e3,Er=2e3,Bs=[1,2,4],Us=Bs.length+1,Mr=5*60*1e3,Lr=24*60*60*1e3;function Pr(e){return(e??[]).some(n=>n.status==="running"||n.status==="queued")?Er:Vs}function ot(e,n){return n>0?Pr(e):Vs}function rt(e){let n=e instanceof Error?e.message:String(e);return/failed to fetch|networkerror|load failed|network request failed/i.test(n)}function Dr(e,n){let t=Date.parse(n),r=(Number.isFinite(t)?t:Date.now())-Lr;return[...new Set(e.filter(i=>{if(i.status==="queued"||i.status==="running")return!0;let o=Date.parse(i.finishedAt??i.startedAt??i.scheduledFor);return Number.isFinite(o)&&o>=r}).map(i=>i.sessionId).filter(i=>i!==void 0&&i!==""))].sort()}function $s(e,n,t={}){let s=!1,r=0,i=e.source.getSnapshot().phase==="loading",o,a,c=0,l=0,h=0,m,k,A=!1,f=v=>{a=v,c=0,l=r,h=0,m=void 0},p=v=>{let x=e.source.getSnapshot().snapshot,N=v?.list?.getSnapshot();if(x===void 0||N===void 0||v?.refresh===void 0)return;let P=new Set([...N.ids??[],...Object.keys(N.byId??{})]);return Dr(x.runs,x.serverNow).filter(W=>!P.has(W)).join("\0")},u=()=>{if(s)return;let v=n();v!==o&&(o=v,f());let x=p(v);if(x===void 0)return;if(x===""){f();return}if(x!==a&&f(x),c>=Us){if((t.now??Date.now)()<h)return;f(x)}if(r<l)return;if(k!==void 0){A=!0;return}let N=c;c+=1;let P=Bs[N];l=P===void 0?Number.POSITIVE_INFINITY:r+P,c>=Us&&(h=(t.now??Date.now)()+Mr),k=Promise.resolve().then(async()=>{await v.refresh()}).catch(W=>{!s&&m!==x&&(m=x,console.warn("[dsh-automation] \u5237\u65B0 Host \u4F1A\u8BDD\u5217\u8868\u5931\u8D25",W))}).finally(()=>{k=void 0,!(s||!A)&&(A=!1,u())})},g=e.source.subscribe(()=>{e.source.getSnapshot().phase==="loading"?i=!0:i&&(i=!1,r+=1),u()},{background:!0});return u(),()=>{s=!0,A=!1,g()}}function Ks(e){let n={phase:"idle"},t,s,r=()=>{},i=new Set,o=new Set,a=()=>{if(s!==void 0&&clearInterval(s),i.size===0){s=void 0;return}s=setInterval(()=>{m().catch(()=>{})},ot(n.snapshot?.runs,o.size))},c=()=>{if(r(),o.size===0)return;let f=()=>{m().catch(()=>{})},p=()=>{document.visibilityState==="visible"&&f()};typeof window<"u"&&window.addEventListener("focus",f),typeof document<"u"&&document.addEventListener("visibilitychange",p),r=()=>{typeof window<"u"&&window.removeEventListener("focus",f),typeof document<"u"&&document.removeEventListener("visibilitychange",p),r=()=>{}}},l=f=>{let p=ot(n.snapshot?.runs,o.size);n=f,i.size>0&&p!==ot(n.snapshot?.runs,o.size)&&a();for(let u of[...i])u()},h={getSnapshot:()=>n,subscribe:(f,p={})=>{let u=i.size>0,g=o.size>0;return i.add(f),p.background!==!0&&o.add(f),(!u||p.background!==!0&&!g)&&queueMicrotask(()=>{i.size>0&&m().catch(()=>{})}),a(),o.size>0&&!g&&c(),()=>{i.delete(f),o.delete(f),i.size===0&&s!==void 0?(clearInterval(s),s=void 0):i.size>0&&a(),o.size===0&&r()}}},m=async()=>{if(t!==void 0)return t;let f=n.snapshot;return l(f===void 0?{phase:"loading"}:{phase:"loading",snapshot:f,...n.refreshedAt===void 0?{}:{refreshedAt:n.refreshedAt}}),t=(async()=>{try{let p=await e.call(tn,"snapshot",{sessionId:"settings"}),u=nn(p);l({phase:"ready",snapshot:u,refreshedAt:Date.now()})}catch(p){let u=p instanceof Error?p.message:String(p);throw l(f===void 0?{phase:"error",error:u}:{phase:"error",snapshot:f,error:u,...n.refreshedAt===void 0?{}:{refreshedAt:n.refreshedAt}}),p}finally{t=void 0}})(),t},k=async(f,p)=>{try{return await e.call(tn,f,p)}catch(u){if(!rt(u))throw u;return await e.call(tn,f,p)}},A=async(f,p,u)=>{nn(await k(f,p));let g=()=>{u!==void 0&&n.snapshot!==void 0&&l({phase:"ready",snapshot:u(n.snapshot),refreshedAt:Date.now()})},v=t;g(),v!==void 0&&(await v.catch(()=>{}),g());try{await m()}catch{}};return{source:h,refresh:m,async createAutomation(f){await A("create",{sessionId:"settings",input:f})},async mutateAutomation(f,p){await A("mutate",{sessionId:"settings",automationId:f,mutation:p},p==="delete"?g=>({...g,automations:g.automations.filter(v=>v.id!==f)}):g=>({...g,automations:g.automations.map(v=>v.id===f?{...v,status:p==="pause"?"paused":"active"}:v)}))},async updateAutomation(f,p){await A("update",{sessionId:"settings",automationId:f,input:p})},async runNow(f){await A("run-now",{sessionId:"settings",automationId:f})},async markRunRead(f){await A("mark-read",{sessionId:"settings",runId:f})},async registerWorkspace(f){let p=nn(await e.call(tn,"register-workspace",{path:f}));return await m(),p},async adoptSession(f){nn(await e.call(tn,"adopt-session",{sessionId:f}))},async forgetSession(f){await A("forget-session",{sessionId:f},p=>({...p,runs:p.runs.map(u=>{if(u.sessionId!==f)return u;let{sessionId:g,...v}=u;return v})}))},async forgetAutomationSessions(f){await A("forget-automation-sessions",{automationId:f},p=>({...p,runs:p.runs.map(u=>{if(u.automationId!==f)return u;let{sessionId:g,...v}=u;return v})}))}}}var it=require("react"),Ve=require("@deepseek-ai/dsh-client-ui-primitives");var Se=require("react/jsx-runtime"),Or=[["created","desc"],["created","asc"],["planned","asc"],["planned","desc"]];function In({t:e,storage:n,storageKey:t,sortKey:s,sortDirection:r,onSelect:i,iconOnly:o=!1,className:a}){let[c,l]=(0,it.useState)(!1),[h,m]=(0,it.useState)(()=>Ne(n,t)),k=e(s==="planned"?`sort.planned.${r}`:`sort.created.${r}`),A=h?.key===s&&h.direction===r,f=()=>{n===void 0||A||(Lt(n,t,s,r),m({key:s,direction:r}))},p=[...Or.map(([g,v])=>({id:`${g}-${v}`,label:e(g==="planned"?`sort.planned.${v}`:`sort.created.${v}`)})),...n===void 0?[]:[{type:"separator",id:"sort-default-sep"},{id:"save-default",label:e(A?"sort.default.saved":"sort.default.save")}]],u=o?(0,Se.jsx)(Ve.Tooltip,{label:k,side:"bottom",delayMs:500,disabled:c,portal:!0,children:(0,Se.jsx)("button",{type:"button",className:c?"dsh-st-n-head-btn is-on":"dsh-st-n-head-btn","aria-label":k,"aria-expanded":c,onClick:()=>l(g=>!g),children:(0,Se.jsx)(xn,{size:16})})}):(0,Se.jsxs)(Ve.Button,{variant:"outline",size:"sm",role:"combobox","aria-label":k,"aria-expanded":c,className:["dsh-st-menu-select-trigger",c?"is-open":""].filter(Boolean).join(" "),onClick:()=>l(g=>!g),children:[(0,Se.jsx)("span",{className:"dsh-st-menu-select-label",children:k}),(0,Se.jsx)("svg",{className:"dsh-st-menu-select-arrow",viewBox:"0 0 16 16",width:12,height:12,fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:{marginLeft:4,transition:"transform 150ms ease",transform:c?"rotate(180deg)":"none"},children:(0,Se.jsx)("path",{d:"m4 6 4 4 4-4"})})]});return(0,Se.jsx)("div",{className:["dsh-st-menu-select-wrap",a].filter(Boolean).join(" "),style:{display:"inline-flex",verticalAlign:"middle"},children:(0,Se.jsx)(Ve.Menu,{open:c,onClose:()=>l(!1),selectedId:`${s}-${r}`,align:o?"end":"start",portal:!0,dense:!0,anchor:u,items:p,onSelect:g=>{if(g==="save-default"){f(),l(!1);return}let[v,x]=g.split("-");i(v,x),l(!1)}})})}var Cn="dsh-automation:open-task-settings",at="dsh-automation:pending-task-settings";function dt(e){if(typeof e!="object"||e===null)return;let n=e;if(!(typeof n.name!="string"||n.name.trim()===""||!Array.isArray(n.sessionIds)||n.sessionIds.some(t=>typeof t!="string"))&&!(n.automationId!==void 0&&(typeof n.automationId!="string"||n.automationId.trim()==="")))return{...typeof n.automationId=="string"?{automationId:n.automationId}:{},name:n.name,sessionIds:[...n.sessionIds]}}function Hr(e,n){try{e?.setItem(at,JSON.stringify(n))}catch{}}function lt(e){typeof window>"u"||(Hr(window.sessionStorage,e),window.dispatchEvent(new CustomEvent(Cn,{detail:e})))}function js(e){if(e!==void 0)try{let n=e.getItem(at);return n===null?void 0:dt(JSON.parse(n))}catch{return}}function qs(e){try{e?.removeItem(at)}catch{}}function Zs(e,n,t){if(e.automationId!==void 0){let a=n.find(c=>c.id===e.automationId);if(a!==void 0)return a}let s=new Set(e.sessionIds),r=t.find(a=>a.sessionId!==void 0&&s.has(a.sessionId))?.automationId,i=n.find(a=>a.id===r);if(i!==void 0)return i;let o=n.filter(a=>a.name===e.name);return o.length===1?o[0]:void 0}var w=require("react/jsx-runtime");var Nn=typeof window>"u"?void 0:window.localStorage,Xs=typeof window>"u"?void 0:window.sessionStorage,Fr=[{name:"\u6BCF\u65E5\u56DE\u5F52\u68C0\u67E5",scheduleKind:"daily",time:"09:00",weekdays:[1,2,3,4,5]},{name:"\u6BCF\u5468\u4F9D\u8D56\u5DE1\u68C0",scheduleKind:"weekly",time:"10:00",weekdays:[1]},{name:"\u5DE5\u4F5C\u65E5\u65E9\u62A5",scheduleKind:"weekly",time:"08:00",weekdays:[1,2,3,4,5]}];function Js({t:e,permissionT:n,modelT:t,runtime:s,closeSettings:r,addWorkspace:i}){let o=(0,Q.useSyncExternalStore)(s.source.subscribe,s.source.getSnapshot,s.source.getSnapshot),[a,c]=(0,Q.useState)("mine"),[l,h]=(0,Q.useState)(""),[m,k]=(0,Q.useState)(!1),[A,f]=(0,Q.useState)(),[p,u]=(0,Q.useState)(),[g,v]=(0,Q.useState)(),[x,N]=(0,Q.useState)(!1),[P,W]=(0,Q.useState)(),[oe,B]=(0,Q.useState)("day"),[G,$]=(0,Q.useState)("all"),[O,K]=(0,Q.useState)("all"),[V,J]=(0,Q.useState)(()=>Ne(Nn,fn)?.key??"created"),[re,ee]=(0,Q.useState)(()=>Ne(Nn,fn)?.direction??"desc"),[ne,S]=(0,Q.useState)(()=>js(Xs)),H=(0,Q.useMemo)(()=>new Date(o.snapshot?.serverNow??Date.now()),[o.snapshot?.serverNow,o.refreshedAt]),E=o.snapshot,ae=E?.workspaces??[],de=E?.models??[],ce=E?.permissions??[],ie=E?.defaultPermission??"",fe=mn((E?.automations??[]).filter(T=>l.trim()===""||`${T.name} ${T.prompt}`.toLowerCase().includes(l.trim().toLowerCase())),V,re),xe=(E?.runs??[]).filter(T=>!(G!=="all"&&T.automationId!==G||O!=="all"&&T.status!==O)),ge=Pt(xe,oe,H,e),Z=async T=>{N(!0),W(void 0);try{await T()}catch(d){W(d instanceof ue?e(d.key):rt(d)?e("error.offline"):d instanceof Error?d.message:e("error.action"))}finally{N(!1)}},te=()=>{k(!1),v(void 0),f(void 0)},ye=T=>{ie===""||ce.length===0||(f(void 0),v(T),k(!0))},we=T=>{f(T.id),v(Dt(T,ae,E?.defaultModel??null,E?.defaultPermission??T.permission)),k(!0)};return(0,Q.useEffect)(()=>{if(typeof window>"u")return;let T=d=>{let I=dt(d.detail);I!==void 0&&S(I)};return window.addEventListener(Cn,T),()=>{window.removeEventListener(Cn,T)}},[]),(0,Q.useEffect)(()=>{if(ne===void 0||E===void 0)return;let T=Zs(ne,E.automations,E.runs);if(qs(Xs),S(void 0),c("mine"),h(""),T===void 0){W(e("error.taskMissing"));return}we(T)},[E,ne,e]),(0,w.jsxs)("div",{className:"dsh-st-shell",children:[(0,w.jsxs)("header",{className:"dsh-st-top",children:[(0,w.jsxs)("div",{className:"dsh-st-heading",children:[(0,w.jsxs)("div",{className:"dsh-st-heading-row",children:[(0,w.jsx)("h1",{children:e("tab")}),(0,w.jsxs)("div",{className:"dsh-st-heading-links",children:[(0,w.jsx)(le.Button,{variant:"outline",size:"sm","aria-label":e("header.githubProject"),icon:(0,w.jsx)(gs,{}),onClick:()=>{window.open("https://github.com/MichengAI/dsh-automation","_blank","noreferrer")},children:e("header.githubProject")}),(0,w.jsx)(le.Button,{variant:"outline",size:"sm","aria-label":e("header.githubFeedback"),icon:(0,w.jsx)(ys,{}),onClick:()=>{window.open("https://github.com/MichengAI/dsh-automation/issues","_blank","noreferrer")},children:e("header.githubFeedback")})]})]}),(0,w.jsx)("p",{children:e("header.lead")})]}),(0,w.jsxs)("div",{className:"dsh-st-toolbar",children:[(0,w.jsx)(le.Input,{className:"dsh-st-search",value:l,placeholder:e("search.placeholder"),onChange:T=>h(T.target.value)}),(0,w.jsx)(le.Button,{variant:"outline",icon:(0,w.jsx)(hs,{}),onClick:()=>{Ws(e("chat.prompt")),r?.()},children:e("action.chatCreate")}),(0,w.jsx)(le.Button,{variant:"primary",icon:(0,w.jsx)(wn,{}),disabled:ie===""||ce.length===0,onClick:()=>ye(),children:e("action.create")}),(0,w.jsx)(le.Button,{className:"dsh-st-row-icon",variant:"outline",size:"sm",icon:(0,w.jsx)(ps,{}),"aria-label":e("section.refresh"),style:et,onClick:()=>{s.refresh()}})]})]}),(0,w.jsx)("div",{className:"dsh-st-banner",role:"note",children:(0,w.jsxs)("span",{children:[(0,w.jsx)(fs,{}),e("banner.wake")]})}),(0,w.jsxs)("section",{className:"dsh-st-examples",children:[(0,w.jsx)("div",{className:"dsh-st-examples-head",children:(0,w.jsx)("h2",{children:e("examples.title")})}),(0,w.jsx)("div",{className:"dsh-st-example-row",children:Fr.map((T,d)=>(0,w.jsxs)("button",{type:"button",className:"dsh-st-example",disabled:ie===""||ce.length===0,onClick:()=>ye({name:e(`examples.${d+1}.title`),prompt:e(`examples.${d+1}.body`),scheduleKind:T.scheduleKind,time:T.time,weekdays:T.weekdays}),children:[(0,w.jsx)("strong",{children:e(`examples.${d+1}.title`)}),(0,w.jsx)("p",{children:e(`examples.${d+1}.body`)}),(0,w.jsxs)("span",{className:"dsh-st-chip",children:[(0,w.jsx)(Ie,{size:14}),e(`examples.${d+1}.chip`)]})]},T.name))})]}),P!==void 0&&(0,w.jsx)("p",{className:"dsh-st-error",children:P}),(o.phase==="idle"||o.phase==="loading"&&E===void 0)&&(0,w.jsx)("p",{className:"dsh-st-muted",children:e("loading")}),o.phase==="error"&&E===void 0&&(0,w.jsxs)("div",{className:"dsh-st-empty",children:[(0,w.jsx)("h3",{children:e("error.title")}),(0,w.jsx)("p",{children:o.error}),(0,w.jsx)(le.Button,{variant:"primary",onClick:()=>{s.refresh()},children:e("error.retry")})]}),(0,w.jsxs)("div",{className:"dsh-st-tabs",children:[(0,w.jsx)(le.SegmentedTabs,{className:"dsh-st-settings-tabs",label:e("tab"),value:a,items:[{value:"mine",id:"dsh-st-tab-mine",panelId:"dsh-st-panel-mine",label:(0,w.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,w.jsx)(Ie,{}),(0,w.jsx)("span",{children:e("tabs.mine")})]})},{value:"runs",id:"dsh-st-tab-runs",panelId:"dsh-st-panel-runs",label:(0,w.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[(0,w.jsx)(Ge,{}),(0,w.jsx)("span",{children:e("tabs.runs")})]})}],onChange:c}),a==="mine"&&(0,w.jsx)("div",{className:"dsh-st-sort-wrap",children:(0,w.jsx)(In,{t:e,...Nn===void 0?{}:{storage:Nn},storageKey:fn,sortKey:V,sortDirection:re,onSelect:(T,d)=>{J(T),ee(d)}})}),a==="runs"&&(0,w.jsxs)("div",{className:"dsh-st-filters",children:[(0,w.jsx)(he,{compact:!0,className:"dsh-st-filter-range",value:oe,options:["day","week","month"].map(T=>({value:T,label:e(`history.range.${T}`)})),onChange:T=>B(T)}),(0,w.jsx)(he,{compact:!0,className:"dsh-st-filter-task",value:G,options:[{value:"all",label:e("history.allTasks")},...(E?.automations??[]).map(T=>({value:T.id,label:T.name}))],onChange:$}),(0,w.jsx)(he,{compact:!0,className:"dsh-st-filter-status",value:O,options:[{value:"all",label:e("history.allStatus")},...Mt.map(T=>({value:T,label:e(`status.${T}`)}))],onChange:T=>K(T)})]})]}),a==="mine"&&(fe.length===0?(0,w.jsxs)("div",{id:"dsh-st-panel-mine",role:"tabpanel","aria-labelledby":"dsh-st-tab-mine",className:"dsh-st-empty",children:[(0,w.jsx)("h3",{children:e("empty.title")}),(0,w.jsx)("p",{children:e("empty.body")})]}):(0,w.jsx)("div",{id:"dsh-st-panel-mine",role:"tabpanel","aria-labelledby":"dsh-st-tab-mine",className:"dsh-st-grid",children:fe.map(T=>(0,w.jsx)(Wr,{item:T,t:e,now:H,busy:x,onEdit:()=>we(T),onToggle:()=>{Z(()=>s.mutateAutomation(T.id,vn(T.status)))},onRun:()=>{Z(()=>s.runNow(T.id))},onDelete:()=>u(T)},T.id))})),a==="runs"&&(ge.length===0?(0,w.jsx)("div",{id:"dsh-st-panel-runs",role:"tabpanel","aria-labelledby":"dsh-st-tab-runs",className:"dsh-st-empty",children:e("runs.empty")}):(0,w.jsx)("div",{id:"dsh-st-panel-runs",role:"tabpanel","aria-labelledby":"dsh-st-tab-runs",className:"dsh-st-timeline",children:ge.map(T=>(0,w.jsxs)("section",{className:"dsh-st-group",children:[(0,w.jsx)("h3",{children:T.label}),T.items.map(d=>(0,w.jsx)(_r,{run:d,t:e},d.id))]},T.key))})),m&&(0,w.jsx)(Os,{t:e,permissionT:n,modelT:t,busy:x,workspaces:ae,models:de,modelFailures:E?.modelFailures??[],defaultModel:E?.defaultModel??null,skills:E?.skills??[],permissions:ce,defaultPermission:ie,editing:A!==void 0,...g===void 0?{}:{draft:g},onClose:te,...i===void 0?{}:{onAddWorkspace:i},onSubmit:async T=>{let d=Ct(T,ae,de,new Date,{allowPastOnce:A!==void 0});await Z(async()=>{A===void 0?await s.createAutomation(d):await s.updateAutomation(A,d),te()})}},A??"create"),(0,w.jsx)(Fs,{target:p,t:e,busy:x,onCancel:()=>u(void 0),onConfirm:()=>{let T=p;T!==void 0&&Z(async()=>{await s.mutateAutomation(T.id,"delete"),u(void 0)})}})]})}function Wr({item:e,t:n,now:t,busy:s,onEdit:r,onToggle:i,onRun:o,onDelete:a}){let[c,l]=(0,Q.useState)(!1);return(0,w.jsxs)("article",{className:"dsh-st-card",onClick:r,children:[(0,w.jsxs)("div",{className:"dsh-st-card-head",children:[(0,w.jsx)("span",{onClick:h=>h.stopPropagation(),children:(0,w.jsx)(le.Switch,{checked:e.status==="active",disabled:s,label:e.status==="active"?n("card.pause"):n("card.resume"),onChange:()=>i()})}),(0,w.jsx)("span",{onClick:h=>h.stopPropagation(),children:(0,w.jsx)(le.Menu,{open:c,onClose:()=>l(!1),align:"end",portal:!0,dense:!0,anchor:(0,w.jsx)(le.Tooltip,{label:n("card.more"),side:"bottom",delayMs:500,portal:!0,children:(0,w.jsx)("button",{type:"button",className:"dsh-st-row-icon","aria-label":n("card.more"),style:{...et,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,border:"1px solid var(--dsw-alias-border-l2, rgba(255,255,255,.15))",borderRadius:"var(--dsw-radius-sm, 6px)",background:"transparent",color:"var(--dsw-alias-label-secondary)",cursor:"pointer"},onClick:()=>l(h=>!h),children:(0,w.jsx)(Ye,{size:16})})}),items:[{id:"run",label:n("menu.run"),disabled:s},{id:"edit",label:n("menu.edit"),disabled:s},{id:"delete",label:n("menu.delete"),danger:!0,disabled:s}],onSelect:h=>{l(!1),h==="run"&&o(),h==="edit"&&r(),h==="delete"&&a()}})})]}),(0,w.jsx)("h3",{children:e.name}),(0,w.jsx)("p",{children:e.prompt}),(0,w.jsxs)("div",{className:"dsh-st-card-foot",children:[(0,w.jsxs)("span",{className:"dsh-st-chip",children:[(0,w.jsx)(Ie,{size:14}),un(e.schedule,n)]}),(0,w.jsx)("span",{children:e.nextRunAt===void 0?n("stats.noneScheduled"):n("history.nextApprox",{when:pn(e.nextRunAt,t,n)})})]})]})}function _r({run:e,t:n}){let t=Rt(e.startedAt,e.finishedAt);return(0,w.jsxs)("article",{className:`dsh-st-run is-${e.status}`,children:[(0,w.jsx)("strong",{children:e.automationName}),(0,w.jsxs)("p",{children:[(0,w.jsx)("span",{children:Et(e.startedAt??e.scheduledFor)}),t!==void 0&&(0,w.jsx)("span",{children:t}),(0,w.jsx)("span",{children:xt(e.trigger,n)})]})]})}var Be="dsh-automation",Ys={tab:"Scheduled tasks","sidebar.tab":"Scheduled","sidebar.tabs":"Workspace views","sidebar.tasksTab":"Tasks","sidebar.channelsTab":"Channels","sidebar.views":"Scheduled views","sidebar.viewOverview":"Task overview","sidebar.runsTab":"Records","sidebar.overviewTab":"Tasks","sidebar.empty":"No scheduled runs yet.","sidebar.tasksEmpty":"No web tasks yet.","sidebar.ungrouped":"Ungrouped","sidebar.section":"Scheduled","sidebar.workspaces":"Workspaces","sidebar.search":"Search","sidebar.sessions":"Sessions","sidebar.searchSessions":"Search session names","sidebar.clearSearch":"Clear search","sidebar.filter":"View options","sidebar.groupBy":"Group by","sidebar.groupWorkspace":"WorkSpace","sidebar.groupWorkspaceTree":"Workspace Tree","sidebar.groupList":"In one list","sidebar.sortBy":"Order by","sidebar.sortManual":"Manual","sidebar.sortTime":"Last updated","sidebar.filterBy":"Filter sessions","sidebar.hideArchived":"Hide archived","sidebar.showArchived":"All conversations (show archived)","sidebar.onlyArchived":"Archived only","header.lead":"Plan automatic tasks, or trigger them by hand. Describe the recurring work in any chat to create it quickly.","header.githubProject":"GitHub","header.githubFeedback":"Issues","examples.title":"Recommended examples","examples.1.title":"Daily regression check","examples.1.body":"Create a scheduled task that runs every day and inspects new test failures.","examples.1.chip":"Every day 09:00","examples.2.title":"Weekly dependency review","examples.2.body":"Create a scheduled task that runs every Monday and reports outdated or risky dependencies.","examples.2.chip":"Monday 10:00","examples.3.title":"Weekday morning briefing","examples.3.body":"Create a scheduled task that runs on weekdays and summarizes overnight changes.","examples.3.chip":"Weekdays 08:00","chat.hint":"In any conversation, describe the recurring work and ask the Agent to call automation_create.","chat.prompt":"I want to create a scheduled task that runs every [interval] and does [the actual task]","menu.run":"Run task","menu.edit":"Edit task","menu.delete":"Delete task","session.rename":"Rename","session.fork":"Fork session","session.archive":"Archive session","session.unarchive":"Restore","session.copySessionId":"Copy Session ID","session.moreActions":"More actions for {title}","session.groupActions":"Actions for {name}","session.taskSettings":"Task settings","session.archiveGroup":"Archive all conversations","session.archiveGroupConfirm":"Archive all","session.archiveGroupDescription":"Archive all {count} conversations for \u201C{name}\u201D. Choose Filter \u2192 Show archived to restore them.","session.archiveGroupPending":"Archiving conversations\u2026","session.archiveGroupFailed":"Some conversations could not be archived: {message}","session.archiveGroupClose":"Close","session.archiveGroupCancel":"Cancel","session.unarchiveGroup":"Restore all conversations","session.unarchiveGroupConfirm":"Restore all","session.unarchiveGroupDescription":"Restore all {count} conversations for \u201C{name}\u201D.","session.unarchiveGroupPending":"Restoring conversations\u2026","session.unarchiveGroupFailed":"Some conversations could not be restored: {message}","session.unarchiveGroupClose":"Close","session.unarchiveGroupCancel":"Cancel","session.deleteSession":"Delete session","session.deleteSessionConfirm":"Delete session","session.deleteSessionDescription":"This permanently deletes session \u201C{name}\u201D, its child agents (including any that are still running), and all of its records (conversation, stats, cache). This cannot be undone.","session.deleteSessionPending":"Deleting session\u2026","session.deleteSessionFailed":"Could not delete the session: {message}","session.deleteSessionClose":"Close","session.deleteSessionCancel":"Cancel","session.idle":"Idle","session.runningStatus":"Running","session.completed":"Completed","session.waitingApproval":"Waiting for approval","session.planReview":"Plan to review","session.waitingAnswer":"Waiting for an answer","session.subagentsRunning":"{count} subagents running","session.archived":"Archived","session.delete":"Remove from Scheduled","session.deleteFolder":"Remove folder","session.confirmDeleteFolder":"Remove this folder from Scheduled?","session.confirmDeleteFolderHint":'This only unlists {count} session(s) in "{name}" from Scheduled. Host sessions are not deleted and they stay hidden from Tasks.',"session.confirmDeleteFolderAction":"Remove from Scheduled","history.range.day":"By day","history.range.week":"By week","history.range.month":"By month","history.allTasks":"All tasks","history.allStatus":"All statuses","history.today":"Today","history.yesterday":"Yesterday","history.date":"{date}","history.week":"Week of {date}","history.month":"{month}","history.nextApprox":"Next run in about {when}","time.withinMinute":"about {count} minutes","time.withinHour":"about {count} hours","time.withinDay":"about {count} days","search.placeholder":"Search scheduled tasks...","action.chatCreate":"Create in chat","action.create":"New scheduled task","banner.wake":"Scheduled tasks run only while this computer stays awake.","tabs.mine":"My tasks","tabs.runs":"Run history","sort.by":"Sort","sort.created.asc":"Created time ascending","sort.created.desc":"Created time descending","sort.planned.asc":"Planned time ascending","sort.planned.desc":"Planned time descending","sort.default.save":"Set as default","sort.default.saved":"Default","form.workspace":"Workspace","form.fieldWorkspace":"Workspace","form.fieldModel":"Model","form.providerAccount":"DeepSeek account","form.fieldEffort":"Reasoning","form.fieldPermission":"Permission","form.slashHint":"Type / to insert a skill","form.slashEmpty":"No matching skills","form.addWorkspace":"Add workspace","form.workspaceRequired":"Add a registered workspace before saving.","form.workspaceUnavailable":"This Host cannot create workspaces.","form.addWorkspaceFailed":"Could not add the workspace.","form.workspacePath":"Folder path","form.workspacePathPlaceholder":"D:\\work\\project","form.model":"Model","form.modelSelect":"Select model","form.effort":"Reasoning","form.effort.none":"Default","form.effort.low":"Low","form.effort.medium":"Medium","form.effort.high":"High","form.error.workspace":"Select a workspace.","modal.title":"New scheduled task","modal.edit":"Edit scheduled task","modal.save":"Save","header.eyebrow":"Unattended coding work","header.title":"Automations","header.subtitle":"Schedule standalone, auditable Agent runs for this workspace.","header.create":"New automation","header.closeCreate":"Hide form","scope.workspace":"Workspace","scope.folder":"Working directory","stats.total":"All","stats.active":"Active","stats.next":"Next run","stats.attention":"Needs attention","stats.noneScheduled":"None scheduled","stats.noAttention":"All clear","section.automations":"Workspace automations","section.automationsHint":"Each trigger starts a fresh DSH Session and keeps its own audit record.","section.runs":"Recent runs","section.runsHint":"Latest outcomes for this workspace.","section.refresh":"Refresh","empty.title":"Let recurring coding work run itself","empty.body":"Save a self-contained task, a schedule, and a permission boundary. Every run starts in a new Session.","empty.action":"Create the first automation","runs.empty":"No runs yet. Run one now, or wait for the next scheduled occurrence.","overview.empty":"No scheduled tasks yet. Create one in Settings.","form.title":"Create automation","form.subtitle":"Write a complete, standalone task. Scheduled runs do not inherit this conversation.","form.name":"Name","form.namePlaceholder":"Daily regression triage","form.prompt":"Task prompt","form.promptPlaceholder":"Inspect new test failures, locate the regression, and propose a verified minimal fix\u2026","form.schedule":"Schedule","form.planTime":"Schedule","form.hourly":"Hourly","form.monthly":"Monthly","form.custom":"Every few days","form.intervalHint":"Runs every this many minutes, starting now.","form.customHint":"Runs every this many days at the selected time.","form.atTime":"at","form.minutesShort":"min","form.daysShort":"days","form.monthDay":"Day {day} of month","form.skills":"Skills","form.skillsEmpty":"No skills available","schedule.hourlyAt":"Every hour at :{minute}","schedule.monthlyAt":"Monthly on day {day} \xB7 {time}","schedule.customAt":"Every {count} days \xB7 {time}","form.once":"Does not repeat","form.interval":"Interval","form.daily":"Daily","form.weekly":"Weekly","form.runAt":"Run at","form.every":"Every","form.minutes":"minutes","form.time":"Time","form.days":"Weekdays","form.timeZone":"Time zone","form.maxConcurrentRuns":"Concurrency","form.maxConcurrentRunsHint":"Queued and running executions share this limit. Defaults to 1; when full, scheduled triggers are skipped and manual runs are rejected.","form.error.maxConcurrentRuns":"Enter a positive whole number for concurrent runs.","form.permission":"Permission boundary","permission.readOnly":"Read Only","permission.workspaceWrite":"Workspace Write","permission.fullAccess":"Full access","form.cancel":"Cancel","form.submit":"Create automation","form.submitting":"Creating\u2026","form.error.name":"Enter a name.","form.error.prompt":"Enter a complete, standalone task prompt.","form.error.once":"Choose a valid future date and time.","form.error.interval":"The interval must be between 1 and 43,200 minutes.","form.error.weekdays":"Select at least one weekday.","day.1":"Mon","day.2":"Tue","day.3":"Wed","day.4":"Thu","day.5":"Fri","day.6":"Sat","day.7":"Sun","status.active":"Active","status.paused":"Paused","status.queued":"Queued","status.running":"Running","status.succeeded":"Succeeded","status.failed":"Failed","status.skipped":"Skipped","status.cancelled":"Cancelled","status.interrupted":"Interrupted","card.nextRun":"Next","card.lastRun":"Last","card.never":"Not yet run","schedule.onceAt":"Once \xB7 {time}","schedule.everyMinutes":"Every {count} minutes","schedule.dailyAt":"Daily \xB7 {time}","schedule.weeklyAt":"{days} \xB7 {time}","card.pause":"Pause","card.resume":"Resume","card.runNow":"Run now","card.more":"More actions","card.delete":"Delete","card.confirmDelete":"Delete this automation?","card.confirmDeleteHint":"Run history is kept for audit.","card.confirm":"Delete","card.cancel":"Cancel","run.trigger.schedule":"Scheduled","run.trigger.manual":"Manual","run.openSession":"Session {id}","run.markRead":"Mark reviewed",loading:"Loading automations\u2026","error.title":"Automations could not be loaded","error.retry":"Try again","error.action":"The action failed. Please try again.","error.taskMissing":"This scheduled task no longer exists.","error.offline":"Could not reach the local automation service. Check that DSH is still running and try again.","time.minutes":"{count}m","time.hours":"{count}h","time.days":"{count}d","time.months":"{count}mo","time.years":"{count}y","time.ago":"{text} ago","time.now":"now","session.copy":"Copy","session.copied":"Copied","session.compactApproval":"Approval","session.compactPlan":"Plan review","session.compactAnswer":"Answer","time.minuteAgo":"{count}m ago","time.hourAgo":"{count}h ago","time.dayAgo":"{count}d ago","time.inMinute":"in {count}m","time.inHour":"in {count}h","time.inDay":"in {count}d"},Qs={tab:"\u5B9A\u65F6\u4EFB\u52A1","sidebar.tab":"\u5B9A\u65F6","sidebar.tabs":"\u5DE5\u4F5C\u533A\u5206\u7C7B","sidebar.tasksTab":"\u4EFB\u52A1","sidebar.channelsTab":"\u9891\u9053","sidebar.views":"\u5B9A\u65F6\u9875\u89C6\u56FE","sidebar.viewOverview":"\u4EFB\u52A1\u603B\u89C8","sidebar.runsTab":"\u8BB0\u5F55","sidebar.overviewTab":"\u4EFB\u52A1","sidebar.empty":"\u8FD8\u6CA1\u6709\u5B9A\u65F6\u4EFB\u52A1\u6267\u884C\u8BB0\u5F55\u3002","sidebar.tasksEmpty":"\u6682\u65E0\u7F51\u9875\u4EFB\u52A1","sidebar.ungrouped":"\u672A\u5206\u7EC4","sidebar.section":"\u5B9A\u65F6\u4EFB\u52A1","sidebar.workspaces":"\u5DE5\u4F5C\u533A","sidebar.search":"\u641C\u7D22","sidebar.sessions":"\u4F1A\u8BDD","sidebar.searchSessions":"\u641C\u7D22\u4F1A\u8BDD\u540D\u79F0","sidebar.clearSearch":"\u6E05\u9664\u641C\u7D22","sidebar.filter":"\u89C6\u56FE\u9009\u9879","sidebar.groupBy":"\u5206\u7EC4\u65B9\u5F0F","sidebar.groupWorkspace":"\u6309\u5DE5\u4F5C\u533A","sidebar.groupWorkspaceTree":"\u6309\u5DE5\u4F5C\u533A\u6811","sidebar.groupList":"\u5355\u5217\u8868","sidebar.sortBy":"\u6392\u5E8F\u65B9\u5F0F","sidebar.sortManual":"\u624B\u52A8\u6392\u5E8F","sidebar.sortTime":"\u6700\u8FD1\u66F4\u65B0","sidebar.filterBy":"\u7B5B\u9009\u4F1A\u8BDD","sidebar.hideArchived":"\u9690\u85CF\u5DF2\u5F52\u6863","sidebar.showArchived":"\u5168\u90E8\u5BF9\u8BDD\uFF08\u663E\u793A\u5DF2\u5F52\u6863\uFF09","sidebar.onlyArchived":"\u4EC5\u663E\u793A\u5DF2\u5F52\u6863","header.lead":"\u6309\u8BA1\u5212\u81EA\u52A8\u6267\u884C\u4EFB\u52A1\uFF0C\u4E5F\u53EF\u968F\u65F6\u624B\u52A8\u89E6\u53D1\u3002\u5728\u4EFB\u610F\u5BF9\u8BDD\u4E2D\u63CF\u8FF0\u4F60\u60F3\u5B9A\u671F\u505A\u7684\u4E8B\uFF0C\u5373\u53EF\u5FEB\u901F\u521B\u5EFA","header.githubProject":"GitHub","header.githubFeedback":"\u95EE\u9898\u53CD\u9988","examples.title":"\u63A8\u8350\u6848\u4F8B","examples.1.title":"\u6BCF\u65E5\u56DE\u5F52\u68C0\u67E5","examples.1.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5929\u3011\u6267\u884C\u3010\u68C0\u67E5\u65B0\u589E\u6D4B\u8BD5\u5931\u8D25\u5E76\u7ED9\u51FA\u6700\u5C0F\u4FEE\u590D\u3011\u3002","examples.1.chip":"\u6BCF\u5929 09:00","examples.2.title":"\u6BCF\u5468\u4F9D\u8D56\u5DE1\u68C0","examples.2.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5468\u4E00\u3011\u6267\u884C\u3010\u68C0\u67E5\u8FC7\u671F\u6216\u6709\u98CE\u9669\u7684\u4F9D\u8D56\u5E76\u7ED9\u51FA\u5904\u7406\u5EFA\u8BAE\u3011\u3002","examples.2.chip":"\u6BCF\u5468\u4E00 10:00","examples.3.title":"\u5DE5\u4F5C\u65E5\u65E9\u62A5","examples.3.body":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u5DE5\u4F5C\u65E5\u3011\u6267\u884C\u3010\u6C47\u603B\u6628\u591C\u4ED3\u5E93\u53D8\u66F4\u5E76\u7ED9\u51FA\u4ECA\u65E5\u5173\u6CE8\u70B9\u3011\u3002","examples.3.chip":"\u5DE5\u4F5C\u65E5 08:00","chat.hint":"\u5728\u4EFB\u610F\u5BF9\u8BDD\u4E2D\u63CF\u8FF0\u4F60\u60F3\u5B9A\u671F\u505A\u7684\u4E8B\uFF0C\u5E76\u8BA9 Agent \u8C03\u7528 automation_create\u3002","chat.prompt":"\u6211\u8981\u521B\u5EFA\u4E00\u4E2A\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u6BCF\u3010\u65F6\u95F4\u95F4\u9694\u3011\u6267\u884C\u3010\u5177\u4F53\u4EFB\u52A1\u3011","menu.run":"\u6267\u884C\u4EFB\u52A1","menu.edit":"\u7F16\u8F91\u4EFB\u52A1","menu.delete":"\u5220\u9664\u4EFB\u52A1","session.rename":"\u91CD\u547D\u540D","session.fork":"\u5206\u53C9\u4F1A\u8BDD","session.archive":"\u5F52\u6863\u4F1A\u8BDD","session.unarchive":"\u6062\u590D","session.copySessionId":"\u590D\u5236 Session ID","session.moreActions":"\u201C{title}\u201D\u7684\u66F4\u591A\u64CD\u4F5C","session.groupActions":"\u201C{name}\u201D\u7684\u4EFB\u52A1\u64CD\u4F5C","session.taskSettings":"\u4EFB\u52A1\u8BBE\u7F6E","session.archiveGroup":"\u5F52\u6863\u6574\u7EC4\u4F1A\u8BDD","session.archiveGroupConfirm":"\u786E\u8BA4\u5F52\u6863","session.archiveGroupDescription":"\u5C06\u5F52\u6863\u201C{name}\u201D\u4E0B\u7684 {count} \u4E2A\u4F1A\u8BDD\u3002\u53EF\u5728\u7B5B\u9009\u4E2D\u9009\u62E9\u201C\u663E\u793A\u5DF2\u5F52\u6863\u201D\u540E\u6062\u590D\u3002","session.archiveGroupPending":"\u6B63\u5728\u5F52\u6863\u6574\u7EC4\u4F1A\u8BDD\u2026","session.archiveGroupFailed":"\u90E8\u5206\u4F1A\u8BDD\u5F52\u6863\u5931\u8D25\uFF1A{message}","session.archiveGroupClose":"\u5173\u95ED","session.archiveGroupCancel":"\u53D6\u6D88","session.unarchiveGroup":"\u6062\u590D\u6574\u7EC4\u4F1A\u8BDD","session.unarchiveGroupConfirm":"\u786E\u8BA4\u6062\u590D","session.unarchiveGroupDescription":"\u5C06\u6062\u590D\u201C{name}\u201D\u4E0B\u7684 {count} \u4E2A\u4F1A\u8BDD\u3002","session.unarchiveGroupPending":"\u6B63\u5728\u6062\u590D\u6574\u7EC4\u4F1A\u8BDD\u2026","session.unarchiveGroupFailed":"\u90E8\u5206\u4F1A\u8BDD\u6062\u590D\u5931\u8D25\uFF1A{message}","session.unarchiveGroupClose":"\u5173\u95ED","session.unarchiveGroupCancel":"\u53D6\u6D88","session.deleteSession":"\u5220\u9664\u4F1A\u8BDD","session.deleteSessionConfirm":"\u5220\u9664\u4F1A\u8BDD","session.deleteSessionDescription":"\u5C06\u6C38\u4E45\u5220\u9664\u4F1A\u8BDD\u201C{name}\u201D\u53CA\u5176\u5B50\u4EE3\u7406\uFF08\u542B\u6B63\u5728\u8FD0\u884C\u7684\uFF09\u548C\u5168\u90E8\u8BB0\u5F55\uFF08\u5BF9\u8BDD\u5185\u5BB9\u3001\u7EDF\u8BA1\u3001\u7F13\u5B58\uFF09\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002","session.deleteSessionPending":"\u6B63\u5728\u5220\u9664\u4F1A\u8BDD\u2026","session.deleteSessionFailed":"\u5220\u9664\u4F1A\u8BDD\u5931\u8D25\uFF1A{message}","session.deleteSessionClose":"\u5173\u95ED","session.deleteSessionCancel":"\u53D6\u6D88","session.idle":"\u7A7A\u95F2","session.runningStatus":"\u8FDB\u884C\u4E2D","session.completed":"\u5DF2\u5B8C\u6210","session.waitingApproval":"\u7B49\u5F85\u5BA1\u6279","session.planReview":"\u8BA1\u5212\u5F85\u5BA1","session.waitingAnswer":"\u7B49\u5F85\u56DE\u7B54","session.subagentsRunning":"{count} \u4E2A\u5B50\u4EE3\u7406\u8FD0\u884C\u4E2D","session.archived":"\u5DF2\u5F52\u6863","session.delete":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664","session.deleteFolder":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664\u6587\u4EF6\u5939","session.confirmDeleteFolder":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664\u8FD9\u4E2A\u6587\u4EF6\u5939\uFF1F","session.confirmDeleteFolderHint":"\u53EA\u4F1A\u628A\u300C{name}\u300D\u4E0B\u7684 {count} \u6761\u4F1A\u8BDD\u4ECE\u5B9A\u65F6\u9875\u6458\u6389\uFF0C\u4E0D\u4F1A\u5220\u9664\u5BBF\u4E3B Session\u3002\u4EFB\u52A1\u9875\u672C\u6765\u4E5F\u4E0D\u5C55\u793A\u8FD9\u4E9B\u81EA\u52A8\u5316\u4F1A\u8BDD\u3002","session.confirmDeleteFolderAction":"\u4ECE\u5B9A\u65F6\u9875\u79FB\u9664","history.range.day":"\u6309\u5929","history.range.week":"\u6309\u5468","history.range.month":"\u6309\u6708","history.allTasks":"\u5168\u90E8\u4EFB\u52A1","history.allStatus":"\u5168\u90E8\u72B6\u6001","history.today":"\u4ECA\u5929","history.yesterday":"\u6628\u5929","history.date":"{date}","history.week":"{date} \u5F53\u5468","history.month":"{month}","history.nextApprox":"\u4E0B\u6B21\u6267\u884C \u5927\u7EA6 {when}","time.withinMinute":"{count} \u5206\u949F\u5185","time.withinHour":"{count} \u5C0F\u65F6\u5185","time.withinDay":"{count} \u5929\u5185","search.placeholder":"\u641C\u7D22\u5B9A\u65F6\u4EFB\u52A1...","action.chatCreate":"\u901A\u8FC7\u5BF9\u8BDD\u521B\u5EFA","action.create":"\u65B0\u5EFA\u5B9A\u65F6\u4EFB\u52A1","banner.wake":"\u5B9A\u65F6\u4EFB\u52A1\u4EC5\u5728\u7535\u8111\u4FDD\u6301\u5524\u9192\u65F6\u8FD0\u884C","tabs.mine":"\u6211\u7684\u5B9A\u65F6\u4EFB\u52A1","tabs.runs":"\u6267\u884C\u8BB0\u5F55","sort.by":"\u6392\u5E8F","sort.created.asc":"\u6309\u521B\u5EFA\u65F6\u95F4\u5347\u5E8F","sort.created.desc":"\u6309\u521B\u5EFA\u65F6\u95F4\u5012\u5E8F","sort.planned.asc":"\u6309\u8BA1\u5212\u65F6\u95F4\u5347\u5E8F","sort.planned.desc":"\u6309\u8BA1\u5212\u65F6\u95F4\u5012\u5E8F","sort.default.save":"\u8BBE\u4E3A\u9ED8\u8BA4","sort.default.saved":"\u9ED8\u8BA4","form.workspace":"\u5DE5\u4F5C\u76EE\u5F55","form.fieldWorkspace":"\u5DE5\u4F5C\u533A","form.fieldModel":"\u6A21\u578B","form.providerAccount":"DeepSeek \u8D26\u53F7","form.fieldEffort":"\u63A8\u7406\u7B49\u7EA7","form.fieldPermission":"\u6743\u9650","form.slashHint":"\u8F93\u5165 / \u53EC\u56DE\u6280\u80FD","form.slashEmpty":"\u6CA1\u6709\u5339\u914D\u7684\u6280\u80FD","form.addWorkspace":"\u6DFB\u52A0\u5DE5\u4F5C\u533A","form.workspaceRequired":"\u8BF7\u5148\u6DFB\u52A0\u5DF2\u767B\u8BB0\u7684\u5DE5\u4F5C\u533A\uFF0C\u5426\u5219\u65E0\u6CD5\u4FDD\u5B58\u3002","form.workspaceUnavailable":"\u5F53\u524D\u5BBF\u4E3B\u4E0D\u80FD\u65B0\u5EFA\u5DE5\u4F5C\u533A\u3002","form.addWorkspaceFailed":"\u6DFB\u52A0\u5DE5\u4F5C\u533A\u5931\u8D25\u3002","form.workspacePath":"\u76EE\u5F55\u8DEF\u5F84","form.workspacePathPlaceholder":"D:\\work\\project","form.model":"\u6A21\u578B","form.modelSelect":"\u9009\u62E9\u6A21\u578B","form.effort":"\u63A8\u7406\u7B49\u7EA7","form.effort.none":"\u9ED8\u8BA4","form.effort.low":"Low","form.effort.medium":"Medium","form.effort.high":"High","form.error.workspace":"\u8BF7\u9009\u62E9\u5DE5\u4F5C\u533A\u3002","modal.title":"\u65B0\u5EFA\u5B9A\u65F6\u4EFB\u52A1","modal.edit":"\u7F16\u8F91\u5B9A\u65F6\u4EFB\u52A1","modal.save":"\u4FDD\u5B58","header.eyebrow":"\u81EA\u4E3B\u7F16\u7801\u4EFB\u52A1","header.title":"\u81EA\u52A8\u5316","header.subtitle":"\u4E3A\u5F53\u524D\u5DE5\u4F5C\u533A\u5B89\u6392\u72EC\u7ACB\u3001\u53EF\u5BA1\u8BA1\u7684 Agent \u8FD0\u884C\u3002","header.create":"\u65B0\u5EFA\u81EA\u52A8\u5316","header.closeCreate":"\u6536\u8D77\u8868\u5355","scope.workspace":"\u5DE5\u4F5C\u533A","scope.folder":"\u5DE5\u4F5C\u76EE\u5F55","stats.total":"\u5168\u90E8","stats.active":"\u5DF2\u542F\u7528","stats.next":"\u4E0B\u6B21\u8FD0\u884C","stats.attention":"\u9700\u8981\u5173\u6CE8","stats.noneScheduled":"\u6682\u65E0\u8BA1\u5212","stats.noAttention":"\u4E00\u5207\u6B63\u5E38","section.automations":"\u5DE5\u4F5C\u533A\u81EA\u52A8\u5316","section.automationsHint":"\u6BCF\u6B21\u89E6\u53D1\u90FD\u4F1A\u521B\u5EFA\u4E00\u4E2A\u5168\u65B0\u7684 DSH Session\uFF0C\u5E76\u4FDD\u7559\u72EC\u7ACB\u5BA1\u8BA1\u8BB0\u5F55\u3002","section.runs":"\u6700\u8FD1\u8FD0\u884C","section.runsHint":"\u5F53\u524D\u5DE5\u4F5C\u533A\u6700\u8FD1\u7684\u6267\u884C\u72B6\u6001\u3002","section.refresh":"\u5237\u65B0","empty.title":"\u8BA9\u91CD\u590D\u7684\u7F16\u7801\u5DE5\u4F5C\u81EA\u52A8\u8FD0\u884C","empty.body":"\u8BBE\u7F6E\u4E00\u4E2A\u76EE\u6807\u660E\u786E\u7684\u4EFB\u52A1\u3001\u8FD0\u884C\u65F6\u95F4\u548C\u6743\u9650\u8FB9\u754C\u3002\u6BCF\u6B21\u8FD0\u884C\u90FD\u4ECE\u5168\u65B0 Session \u5F00\u59CB\u3002","empty.action":"\u521B\u5EFA\u7B2C\u4E00\u4E2A\u81EA\u52A8\u5316","runs.empty":"\u8FD8\u6CA1\u6709\u8FD0\u884C\u8BB0\u5F55\u3002\u4F60\u53EF\u4EE5\u7ACB\u5373\u8FD0\u884C\u4E00\u6B21\uFF0C\u6216\u7B49\u5F85\u8BA1\u5212\u89E6\u53D1\u3002","overview.empty":"\u6682\u65E0\u5B9A\u65F6\u4EFB\u52A1\uFF0C\u53EF\u5230\u8BBE\u7F6E\u9875\u521B\u5EFA\u3002","form.title":"\u521B\u5EFA\u81EA\u52A8\u5316","form.subtitle":"\u8BF7\u5199\u5B8C\u6574\u3001\u72EC\u7ACB\u7684\u4EFB\u52A1\u8BF4\u660E\uFF1A\u5B9A\u65F6\u8FD0\u884C\u4E0D\u4F1A\u7EE7\u627F\u5F53\u524D\u5BF9\u8BDD\u3002","form.name":"\u540D\u79F0","form.namePlaceholder":"\u6BCF\u65E5\u56DE\u5F52\u6D4B\u8BD5\u5206\u8BCA","form.prompt":"\u4EFB\u52A1\u6307\u4EE4","form.promptPlaceholder":"\u68C0\u67E5\u65B0\u589E\u6D4B\u8BD5\u5931\u8D25\uFF0C\u5B9A\u4F4D\u56DE\u5F52\u539F\u56E0\uFF0C\u5E76\u7ED9\u51FA\u7ECF\u8FC7\u9A8C\u8BC1\u7684\u6700\u5C0F\u4FEE\u590D\u65B9\u6848\u2026\u2026","form.schedule":"\u8FD0\u884C\u8BA1\u5212","form.planTime":"\u8BA1\u5212\u65F6\u95F4","form.hourly":"\u6BCF\u5C0F\u65F6","form.monthly":"\u6BCF\u6708","form.custom":"\u6BCF\u9694\u51E0\u5929","form.intervalHint":"\u4ECE\u73B0\u5728\u8D77\uFF0C\u6BCF\u9694\u8FD9\u4E48\u591A\u5206\u949F\u8FD0\u884C\u4E00\u6B21\u3002","form.customHint":"\u6BCF\u9694\u8FD9\u4E48\u591A\u5929\uFF0C\u5728\u6240\u9009\u65F6\u95F4\u8FD0\u884C\u4E00\u6B21\u3002","form.atTime":"\u4E8E","form.minutesShort":"\u5206","form.daysShort":"\u5929","form.monthDay":"\u6BCF\u6708\u7B2C {day} \u5929","form.skills":"\u6280\u80FD","form.skillsEmpty":"\u6682\u65E0\u53EF\u7528\u6280\u80FD","schedule.hourlyAt":"\u6BCF\u5C0F\u65F6 :{minute}","schedule.monthlyAt":"\u6BCF\u6708 {day} \u65E5 \xB7 {time}","schedule.customAt":"\u6BCF {count} \u5929 \xB7 {time}","form.once":"\u4E0D\u91CD\u590D","form.interval":"\u95F4\u9694","form.daily":"\u6BCF\u5929","form.weekly":"\u6BCF\u5468","form.runAt":"\u8FD0\u884C\u65F6\u95F4","form.every":"\u6BCF\u9694","form.minutes":"\u5206\u949F","form.time":"\u65F6\u95F4","form.days":"\u661F\u671F","form.timeZone":"\u65F6\u533A","form.maxConcurrentRuns":"\u5E76\u53D1\u6570\u91CF","form.maxConcurrentRunsHint":"\u540C\u4E00\u4EFB\u52A1\u7684\u6392\u961F\u53CA\u8FD0\u884C\u6B21\u6570\u5171\u7528\u6B64\u4E0A\u9650\uFF0C\u9ED8\u8BA4 1\uFF1B\u6EE1\u989D\u65F6\u8DF3\u8FC7\u5F53\u6B21\u5B9A\u65F6\u89E6\u53D1\uFF0C\u624B\u52A8\u8FD0\u884C\u5C06\u88AB\u62D2\u7EDD\u3002","form.error.maxConcurrentRuns":"\u5E76\u53D1\u6570\u91CF\u5FC5\u987B\u4E3A\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\u3002","form.permission":"\u6743\u9650\u8FB9\u754C","permission.readOnly":"\u53EA\u8BFB","permission.workspaceWrite":"\u5DE5\u4F5C\u533A\u5199\u5165","permission.fullAccess":"\u5B8C\u5168\u8BBF\u95EE","form.cancel":"\u53D6\u6D88","form.submit":"\u521B\u5EFA\u81EA\u52A8\u5316","form.submitting":"\u521B\u5EFA\u4E2D\u2026","form.error.name":"\u8BF7\u8F93\u5165\u540D\u79F0\u3002","form.error.prompt":"\u8BF7\u8F93\u5165\u5B8C\u6574\u3001\u72EC\u7ACB\u7684\u4EFB\u52A1\u6307\u4EE4\u3002","form.error.once":"\u8BF7\u9009\u62E9\u6709\u6548\u7684\u672A\u6765\u65E5\u671F\u548C\u65F6\u95F4\u3002","form.error.interval":"\u8FD0\u884C\u95F4\u9694\u5FC5\u987B\u5728 1 \u5230 43,200 \u5206\u949F\u4E4B\u95F4\u3002","form.error.weekdays":"\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u5929\u3002","day.1":"\u5468\u4E00","day.2":"\u5468\u4E8C","day.3":"\u5468\u4E09","day.4":"\u5468\u56DB","day.5":"\u5468\u4E94","day.6":"\u5468\u516D","day.7":"\u5468\u65E5","status.active":"\u5DF2\u542F\u7528","status.paused":"\u5DF2\u6682\u505C","status.queued":"\u6392\u961F\u4E2D","status.running":"\u8FD0\u884C\u4E2D","status.succeeded":"\u5DF2\u5B8C\u6210","status.failed":"\u5931\u8D25","status.skipped":"\u5DF2\u8DF3\u8FC7","status.cancelled":"\u5DF2\u53D6\u6D88","status.interrupted":"\u5DF2\u4E2D\u65AD","card.nextRun":"\u4E0B\u6B21","card.lastRun":"\u6700\u8FD1","card.never":"\u5C1A\u672A\u8FD0\u884C","schedule.onceAt":"\u5355\u6B21 \xB7 {time}","schedule.everyMinutes":"\u6BCF {count} \u5206\u949F","schedule.dailyAt":"\u6BCF\u5929 \xB7 {time}","schedule.weeklyAt":"{days} \xB7 {time}","card.pause":"\u6682\u505C","card.resume":"\u6062\u590D","card.runNow":"\u7ACB\u5373\u8FD0\u884C","card.more":"\u66F4\u591A\u64CD\u4F5C","card.delete":"\u5220\u9664","card.confirmDelete":"\u786E\u8BA4\u5220\u9664\u8FD9\u4E2A\u81EA\u52A8\u5316\uFF1F","card.confirmDeleteHint":"\u8FD0\u884C\u5386\u53F2\u4F1A\u4FDD\u7559\u7528\u4E8E\u5BA1\u8BA1\u3002","card.confirm":"\u786E\u8BA4\u5220\u9664","card.cancel":"\u53D6\u6D88","run.trigger.schedule":"\u5B9A\u65F6\u89E6\u53D1","run.trigger.manual":"\u624B\u52A8\u89E6\u53D1","run.openSession":"Session {id}","run.markRead":"\u6807\u8BB0\u5DF2\u5904\u7406",loading:"\u6B63\u5728\u52A0\u8F7D\u81EA\u52A8\u5316\u2026","error.title":"\u65E0\u6CD5\u52A0\u8F7D\u81EA\u52A8\u5316","error.retry":"\u91CD\u8BD5","error.action":"\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002","error.taskMissing":"\u8BE5\u5B9A\u65F6\u4EFB\u52A1\u5DF2\u4E0D\u5B58\u5728\u3002","error.offline":"\u65E0\u6CD5\u8FDE\u63A5\u672C\u673A\u81EA\u52A8\u5316\u670D\u52A1\uFF0C\u8BF7\u786E\u8BA4 DSH \u4ECD\u5728\u8FD0\u884C\u540E\u91CD\u8BD5\u3002","time.minutes":"{count}\u5206\u949F","time.hours":"{count}\u5C0F\u65F6","time.days":"{count}\u5929","time.months":"{count}\u4E2A\u6708","time.years":"{count}\u5E74","time.ago":"{text}\u524D","time.now":"\u521A\u521A","session.copy":"\u590D\u5236","session.copied":"\u5DF2\u590D\u5236","session.compactApproval":"\u5F85\u5BA1\u6279","session.compactPlan":"\u8BA1\u5212\u5F85\u5BA1","session.compactAnswer":"\u5F85\u56DE\u7B54","time.minuteAgo":"{count} \u5206\u949F\u524D","time.hourAgo":"{count} \u5C0F\u65F6\u524D","time.dayAgo":"{count} \u5929\u524D","time.inMinute":"{count} \u5206\u949F\u540E","time.inHour":"{count} \u5C0F\u65F6\u540E","time.inDay":"{count} \u5929\u540E"};var eo="__dshNativeTabs";function no(e){let n=new Map,t=[],s=new Set,r=[],i=()=>{r=[...n.values()].sort((a,c)=>(a.order??0)-(c.order??0))},o=()=>{for(let a of s)a()};return{version:1,officialTree:e,sessionFilters:t,getTabs(){return r},subscribe(a){return s.add(a),()=>{s.delete(a)}},insert(a){if(a.id==="")return()=>{};let c=n.get(a.id);return n.set(a.id,a),c!==a&&(i(),o()),()=>{n.get(a.id)===a&&(n.delete(a.id),i(),o())}},addSessionFilter(a){return t.push(a),o(),()=>{let c=t.indexOf(a);c>=0&&t.splice(c,1),o()}}}}function to(e){if(e==null||typeof e!="object"&&typeof e!="function")return;let n=e[eo];if(n==null||typeof n!="object")return;let t=n;return t.version===1&&typeof t.getTabs=="function"&&typeof t.subscribe=="function"&&typeof t.insert=="function"?n:void 0}function ct(e,n){try{e[eo]=n}catch{}return n}function so(e){if(!(e==null||typeof e!="object"&&typeof e!="function"))return to("component"in e?e.component:e)}function oo(e){if(e==null)return!1;let n=e;return n.__dshNativeTabHost===!0||n.__imConnectWrapped===!0?!0:to(e)!==void 0}var zr="@michengai/dsh-archive-manager";function ut(e){return e?.querySelector(`[data-plugin="${zr}"]`)!=null}function $e(e){return typeof e=="function"?e:void 0}function Rn(e){let n=e??{},t=$e(n.renameSession),s=$e(n.archiveSession),r=$e(n.unarchiveSession),i=$e(n.deleteSession),o=$e(n.forkSession),a=$e(n.notifyArchivedNotOpenable);return{...t===void 0?{}:{renameSession:t},...s===void 0?{}:{archiveSession:s},...r===void 0?{}:{unarchiveSession:r},...i===void 0?{}:{deleteSession:i},...o===void 0?{}:{forkSession:o},...a===void 0?{}:{notifyArchivedNotOpenable:a}}}function ro(e,n){return e&&n!==void 0}function io(e){let n=["rename","fork"];return e.archived?e.canUnarchive&&n.push("unarchive"):n.push("archive"),e.canDelete&&n.push("delete-session"),n}function ao(e,n){return n!==null&&e.includes(n)}function lo(e,n){return e&&!n}async function co(e,n){for(let t of e)await n(t)}async function uo(e,n){for(let t of e)await n(t)}var L=require("react"),Ao=require("react-dom"),U=require("@deepseek-ai/dsh-client-ui-primitives");function mo(e,n,t,s){if(e===void 0)return null;try{return e(n,t,s)??null}catch(r){if(!Gr(r))throw r;return null}}function Gr(e){return typeof e!="object"||e===null?!1:"name"in e&&e.name==="SlotOwnershipError"?!0:(e instanceof Error?e.message:"").includes("not declared by this entry")}function fo(e,n,t){let r=e.right+8,i=e.top+n.height>t.height-8?Math.max(8,t.height-n.height-8):Math.max(8,e.top);return{position:"fixed",zIndex:4100,left:`${Math.round(r)}px`,top:`${Math.round(i)}px`}}function ho(e,n){let t=e.runningSubagentCount??0,s=t===0?void 0:{state:"ongoing",label:n("session.subagentsRunning",{count:t})},r;e.pendingKind==="approval"?r={state:"warning",label:n("session.waitingApproval"),trailing:n("session.compactApproval")}:e.pendingKind==="plan-review"?r={state:"warning",label:n("session.planReview"),trailing:n("session.compactPlan")}:e.pendingKind==="question"&&(r={state:"warning",label:n("session.waitingAnswer"),trailing:n("session.compactAnswer")});let i;r!==void 0?i=s===void 0?[r]:[r,s]:e.running?i=s===void 0?[{state:"ongoing",label:n("session.runningStatus")}]:[{state:"ongoing",label:n("session.runningStatus")},s]:s!==void 0?i=[s]:e.completed===!0?i=[{state:"done",label:n("session.completed")}]:i=[{state:"idle",label:n("session.idle")}];let o=i.filter(a=>!(e.archived&&(a.state==="done"||a.state==="idle")));return e.archived&&o.push({state:"archived",label:n("session.archived")}),o}function go(e,n){let t=Date.parse(e||"");if(!Number.isFinite(t))return;let s=6e4,r=36e5,i=864e5,o=Math.max(0,n-t);return o<s?{unit:"now",count:0}:o<r?{unit:"minutes",count:Math.floor(o/s)}:o<i?{unit:"hours",count:Math.floor(o/r)}:o<30*i?{unit:"days",count:Math.floor(o/i)}:o<365*i?{unit:"months",count:Math.floor(o/(30*i))}:{unit:"years",count:Math.floor(o/(365*i))}}function yo(e,n){return e.unit==="now"?n("time.now"):e.unit==="minutes"?n("time.minutes",{count:e.count}):e.unit==="hours"?n("time.hours",{count:e.count}):e.unit==="days"?n("time.days",{count:e.count}):e.unit==="months"?n("time.months",{count:e.count}):n("time.years",{count:e.count})}function po(e,n,t){e.scrollLeft=n,n>0?e.dataset.scrolled="":delete e.dataset.scrolled,n<t?e.dataset.clipped="":delete e.dataset.clipped}function Ur(e){e.scrollLeft=0,delete e.dataset.scrolled,delete e.dataset.clipped}function vo(e,n){if(e===null)return;let t=e.scrollWidth-e.clientWidth;if(t<=8)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){po(e,t,t);return}cancelAnimationFrame(n.id);let s,r=0,i=o=>{r+=s===void 0?0:(o-s)*.03,s=o,po(e,Math.min(r,t),t),r<t&&(n.id=requestAnimationFrame(i))};n.id=requestAnimationFrame(i)}function pt(e,n){cancelAnimationFrame(n.id),e!==null&&Ur(e)}function bo(e,n,t=Date.now()){let s=go(e,t);return s===void 0?"":yo(s,n)}function wo(e,n,t=Date.now()){let s=go(e,t);return s===void 0?"":s.unit==="now"?n("time.now"):n("time.ago",{text:yo(s,n)})}var Ee=require("react");var Mn=require("@deepseek-ai/dsh-client-ui-primitives");var z=require("react/jsx-runtime"),Ke="dsh-st-rail-panel",En=typeof window>"u"?void 0:window.localStorage;function Ln({t:e,view:n,onChange:t}){return(0,z.jsx)(Mn.SegmentedTabs,{className:"dsh-st-rail-views",label:e("sidebar.views"),value:n,items:[{value:"runs",id:"dsh-st-rail-view-runs",panelId:Ke,label:(0,z.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:5},children:[(0,z.jsx)(Ge,{size:14}),(0,z.jsx)("span",{children:e("sidebar.runsTab")})]})},{value:"overview",id:"dsh-st-rail-view-overview",panelId:Ke,label:(0,z.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:5},children:[(0,z.jsx)(kn,{size:14}),(0,z.jsx)("span",{children:e("sidebar.overviewTab")})]})}],onChange:t})}function Pn({t:e,automations:n,serverNow:t,openTaskSettings:s,onToggleAutomation:r}){let[i,o]=(0,Ee.useState)(()=>Ne(En,hn)?.key??"planned"),[a,c]=(0,Ee.useState)(()=>Ne(En,hn)?.direction??"asc"),[l,h]=(0,Ee.useState)(()=>new Set),m=(0,Ee.useMemo)(()=>new Date(t??Date.now()),[t]),k=(0,Ee.useMemo)(()=>{let p=mn(n,i,a);return Bt(p)},[n,a,i]),A=(0,Ee.useMemo)(()=>new Map(n.map(p=>[p.id,un(p.schedule,e)])),[n,e]),f=(p,u)=>{r===void 0||l.has(p)||(h(g=>new Set(g).add(p)),Promise.resolve(r(p,u)).catch(g=>{console.warn("[dsh-automation] \u5207\u6362\u4EFB\u52A1\u72B6\u6001\u5931\u8D25",g)}).finally(()=>{h(g=>{let v=new Set(g);return v.delete(p),v})}))};return(0,z.jsxs)("div",{className:"dsh-st-overview",children:[(0,z.jsxs)("div",{className:"dsh-st-overview-head",children:[(0,z.jsxs)("div",{className:"dsh-st-overview-title",children:[(0,z.jsx)("strong",{children:e("sidebar.viewOverview")}),(0,z.jsx)("span",{"aria-label":`${k.length}`,children:k.length})]}),(0,z.jsx)(In,{t:e,iconOnly:!0,className:"dsh-st-overview-sort",...En===void 0?{}:{storage:En},storageKey:hn,sortKey:i,sortDirection:a,onSelect:(p,u)=>{o(p),c(u)}})]}),k.length===0?(0,z.jsx)("div",{className:"dsh-st-rail-empty",children:e("overview.empty")}):k.map(p=>(0,z.jsx)(Vr,{t:e,row:p,now:m,scheduleSummary:A.get(p.id)??"",toggleDisabled:r===void 0||l.has(p.id),onToggleAutomation:f,...s===void 0?{}:{openTaskSettings:s}},p.id))]})}function Vr({t:e,row:n,now:t,scheduleSummary:s,openTaskSettings:r,toggleDisabled:i,onToggleAutomation:o}){let a=n.status!=="active",c=n.nextRunAt===void 0?e("stats.noneScheduled"):pn(n.nextRunAt,t,e),l=n.nextRunAt===void 0?e("stats.noneScheduled"):Nt(n.nextRunAt,t,e),h=`${e("stats.next")}: ${c}`,m=e(a?"card.resume":"card.pause");return(0,z.jsxs)("div",{className:`dsh-st-overview-row${a?" is-paused":""}`,children:[(0,z.jsxs)("button",{type:"button",className:"dsh-st-overview-open",disabled:r===void 0,onClick:()=>{r?.({automationId:n.id,name:n.name,sessionIds:[]})},children:[(0,z.jsxs)("span",{className:"dsh-st-overview-copy",children:[(0,z.jsx)("span",{className:"dsh-st-overview-name",children:n.name}),s!==""&&(0,z.jsxs)("span",{className:"dsh-st-overview-schedule",children:[(0,z.jsx)(ms,{width:14,height:14}),(0,z.jsx)("span",{children:s})]})]}),(0,z.jsx)("span",{className:"dsh-st-overview-next",title:h,"aria-label":h,children:(0,z.jsx)("strong",{children:l})})]}),(0,z.jsx)("span",{className:"dsh-st-overview-toggle",title:m,children:(0,z.jsx)(Mn.Switch,{checked:!a,disabled:i,label:m,onChange:()=>{o?.(n.id,vn(n.status))}})})]})}var De=require("react"),je=require("@deepseek-ai/dsh-client-ui-primitives");function So(e){return e?11:14}var q=require("react/jsx-runtime");function xo({t:e,query:n,sort:t,groupMode:s,archivedFilter:r="default",onQueryChange:i,onSortChange:o,onGroupModeChange:a,onArchivedFilterChange:c}){let[l,h]=(0,De.useState)(n.trim()!==""),[m,k]=(0,De.useState)(!1),A=(0,De.useRef)(null),f=So(l);(0,De.useEffect)(()=>{l&&A.current?.focus()},[l]);let p=()=>{k(!1),h(!0)},u=()=>{i(""),h(!1)},g=[{type:"label",id:"group-by",text:e("sidebar.groupBy")},{id:"workspace",label:e("sidebar.groupWorkspace"),icon:(0,q.jsx)(ze,{})},{id:"workspace-tree",label:e("sidebar.groupWorkspaceTree"),icon:(0,q.jsx)(kn,{})},{id:"flat",label:e("sidebar.groupList"),icon:(0,q.jsx)(Ge,{})},{type:"separator",id:"order-by-separator"},{type:"label",id:"order-by",text:e("sidebar.sortBy")},{id:"updated",label:e("sidebar.sortTime"),icon:(0,q.jsx)(Ie,{})},...c!==void 0?[{type:"separator",id:"archived-filter-separator"},{type:"label",id:"filter-by",text:e("sidebar.filterBy")},{id:"hide-archived",label:e("sidebar.hideArchived"),icon:(0,q.jsx)(Is,{})},{id:"show-archived",label:e("sidebar.showArchived"),icon:(0,q.jsx)(_e,{})},{id:"only-archived",label:e("sidebar.onlyArchived"),icon:(0,q.jsx)(Cs,{})}]:[]],v=[s==="list"?"flat":s,"updated",r==="show"?"show-archived":r==="only"?"only-archived":"hide-archived"];return(0,q.jsxs)("div",{className:l?"dsh-st-n-toolbar is-search":"dsh-st-n-toolbar",children:[(0,q.jsx)("span",{className:"dsh-st-n-head-label",children:e(s==="list"?"sidebar.sessions":"sidebar.workspaces")}),(0,q.jsx)("div",{className:"dsh-st-n-search-slot",children:(0,q.jsxs)("div",{className:"dsh-st-n-search",onClick:p,children:[(0,q.jsx)(je.Tooltip,{label:e("sidebar.search"),side:"bottom",delayMs:500,disabled:l,children:(0,q.jsx)("button",{type:"button",className:"dsh-st-n-search-btn","aria-label":e("sidebar.search"),"aria-expanded":l,onClick:p,children:(0,q.jsx)(Ss,{size:f})})}),(0,q.jsx)("input",{ref:A,className:"dsh-st-n-search-input",value:n,placeholder:e("sidebar.searchSessions"),"aria-label":e("sidebar.searchSessions"),tabIndex:l?0:-1,"aria-hidden":!l,onChange:x=>i(x.target.value),onKeyDown:x=>{x.key==="Escape"&&u()}}),l&&(0,q.jsx)(je.Tooltip,{label:e("sidebar.clearSearch"),side:"bottom",delayMs:500,children:(0,q.jsx)("button",{type:"button",className:"dsh-st-n-search-clear","aria-label":e("sidebar.clearSearch"),onClick:x=>{x.stopPropagation(),u()},children:(0,q.jsx)(xs,{size:14})})})]})}),(0,q.jsx)("div",{className:"dsh-st-n-head-acts",children:(0,q.jsx)(je.Menu,{open:m,onClose:()=>{k(!1)},items:g,selectedIds:v,align:"end",dense:!0,portal:!0,onSelect:x=>{(x==="workspace"||x==="workspace-tree")&&a(x),x==="flat"&&a("list"),x==="updated"&&o("time"),x==="hide-archived"&&c?.("default"),x==="show-archived"&&c?.("show"),x==="only-archived"&&c?.("only"),k(!1)},anchor:(0,q.jsx)(je.Tooltip,{label:e("sidebar.filter"),side:"bottom",delayMs:500,disabled:m,children:(0,q.jsx)("button",{type:"button",className:m?"dsh-st-n-head-btn is-on":"dsh-st-n-head-btn","aria-label":e("sidebar.filter"),"aria-expanded":m,onClick:()=>k(x=>!x),children:(0,q.jsx)(xn,{size:16})})})})})]})}var y=require("react/jsx-runtime"),ko={},To=[];function Dn(e){let{t:n,runtime:t,openSession:s,useSessions:r,useWorkspaces:i,renameSession:o,archiveSession:a,unarchiveSession:c,deleteSession:l,forkSession:h,notifyArchivedNotOpenable:m,openTaskSettings:k,renderSlot:A,useSessionStatus:f}=e,p=(0,L.useSyncExternalStore)(t.source.subscribe,t.source.getSnapshot,t.source.getSnapshot),u=r?r(C=>Xe(C)):null,g=r?r(C=>C.byId??ko):ko,v=i?i(C=>C.archivedSessionIds??[]):[],x=i?i(C=>C.items??To):To,N=f?f(C=>C):void 0,P=r?r(C=>C.projectionsBySession):void 0,[W,oe]=(0,L.useState)({}),[B,G]=(0,L.useState)(),[$,O]=(0,L.useState)(),[K,V]=(0,L.useState)(),[J,re]=(0,L.useState)(!1),[ee,ne]=(0,L.useState)(),[S,H]=(0,L.useState)(),[E,ae]=(0,L.useState)(!1),[de,ce]=(0,L.useState)(),[ie,fe]=(0,L.useState)(),[xe,ge]=(0,L.useState)(!1),[Z,te]=(0,L.useState)(),[ye,we]=(0,L.useState)(()=>typeof document<"u"&&ut(document)),[T,d]=(0,L.useState)("default"),[I,_]=(0,L.useState)(""),[Ce,Go]=(0,L.useState)("time"),[ke,Uo]=(0,L.useState)("workspace"),[yt,Vo]=(0,L.useState)("runs"),zn=(0,L.useRef)(null),Me=(0,L.useMemo)(()=>new Set(v),[v]),Gn=(0,L.useMemo)(()=>{let C=p.snapshot;if(C===void 0)return[];let j=new Map(C.automations.map(ve=>[ve.id,ve.timeZone]));return yn(C.automations,C.runs).map(ve=>({...ve,sessions:ve.sessions.filter(Te=>$t(Te.id,Me,T)).map(Te=>{let Ae=C.runs.find(sn=>sn.sessionId===Te.id);return{...Te,title:Ze(Ae&&(Ae.startedAt||Ae.scheduledFor)||"",j.get(ve.id)),updatedAt:Ae&&(Ae.startedAt||Ae.scheduledFor)||"",running:Te.running||g[Te.id]?.running===!0}})})).filter(ve=>ve.sessions.length>0)},[Me,T,g,p.snapshot]);(0,L.useEffect)(()=>{if(!bn(u,p.snapshot?.runs)){zn.current=null;return}zn.current!==u&&(zn.current=u,t.refresh().catch(()=>{}))},[t,u,p.snapshot?.runs]);let Un=(0,L.useMemo)(()=>{let C=ke==="workspace-tree"?cs(Gn.flatMap(j=>j.sessions.map(ve=>({...ve,automationId:j.id}))),x,n("sidebar.ungrouped")):Gn;return us(C.map(j=>({...j,name:j.name})),I,Ce,ke)},[ke,Gn,I,Ce,n,x]);(0,L.useEffect)(()=>{if(typeof document>"u"||typeof MutationObserver>"u")return;let C=()=>{we(ut(document))};C();let j=new MutationObserver(C);return j.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{j.disconnect()}},[]);let Bo=ye&&a!==void 0,$o=ro(ye,l),vt=c!==void 0,Ko=()=>{if(K===void 0||a===void 0||J)return;let C=K;re(!0),ne(void 0),co(C.sessionIds,a).then(()=>{V(void 0)}).catch(j=>{ne(j instanceof Error?j.message:n("error.action"))}).finally(()=>{re(!1)})},jo=()=>{if(S===void 0||c===void 0||E)return;let C=S;ae(!0),ce(void 0),uo(C.sessionIds,c).then(()=>{H(void 0)}).catch(j=>{ce(j instanceof Error?j.message:n("error.action"))}).finally(()=>{ae(!1)})},qo=()=>{if(ie===void 0||l===void 0||xe)return;let C=ie;ge(!0),te(void 0),Promise.resolve(l(C.id)).then(()=>{fe(void 0)}).catch(j=>{te(j instanceof Error?j.message:n("error.action"))}).finally(()=>{ge(!1)})};return(0,y.jsxs)("div",{className:"dsh-st-n",children:[(0,y.jsx)("div",{className:"dsh-st-n-views-wrap",children:(0,y.jsx)(Ln,{t:n,view:yt,onChange:Vo})}),(0,y.jsx)("div",{id:Ke,role:"tabpanel",className:"dsh-st-n-view-body",children:yt==="overview"?p.snapshot===void 0?(0,y.jsx)("div",{className:"dsh-st-n-empty",children:p.phase==="loading"?n("loading"):n("overview.empty")}):(0,y.jsx)(Pn,{t:n,automations:p.snapshot.automations,onToggleAutomation:(C,j)=>t.mutateAutomation(C,j),...k===void 0?{}:{openTaskSettings:k},...p.snapshot.serverNow===void 0?{}:{serverNow:p.snapshot.serverNow}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(xo,{t:n,query:I,sort:Ce,groupMode:ke,archivedFilter:T,onQueryChange:_,onSortChange:Go,onGroupModeChange:Uo,onArchivedFilterChange:d}),(0,y.jsx)("div",{className:"dsh-st-n-list-area",children:(0,y.jsxs)("div",{className:"dsh-st-n-tree",role:"tree",children:[p.phase==="loading"&&Un.length===0&&(0,y.jsx)("div",{className:"dsh-st-n-empty",children:n("loading")}),Un.length===0&&p.phase!=="loading"&&(0,y.jsx)("div",{className:"dsh-st-n-empty",children:n("sidebar.empty")}),Un.map(C=>{let j=W[C.id]!==!0,ve=ao(C.sessions.map(R=>R.id),u),Te="depth"in C?C.depth:0,Ae=[...new Set(C.sessions.flatMap(R=>"automationId"in R&&typeof R.automationId=="string"?[R.automationId]:[]))],sn=ke==="workspace-tree"&&Ae.length===1?p.snapshot?.automations.find(R=>R.id===Ae[0]):void 0,Vn=ke==="workspace-tree"?sn?.id:C.id,Zo=ke==="workspace-tree"?sn?.name:C.name,bt=C.sessions.filter(R=>!Me.has(R.id)).map(R=>R.id),wt=C.sessions.filter(R=>Me.has(R.id)).map(R=>R.id),Xo=Bo&&bt.length>0,Jo=vt&&wt.length>0;return(0,y.jsxs)("div",{className:"dsh-st-n-group",style:Te>0?{"--dsh-workspace-indent":`${Te*12}px`}:void 0,children:[ke!=="list"&&(0,y.jsx)(Br,{t:n,id:C.id,name:C.name,sessionIds:C.sessions.map(R=>R.id),expanded:j,hasCurrentSession:ve,menuOpen:$===C.id,canArchiveGroup:Xo,canUnarchiveGroup:Jo,showTaskSettings:Vn!==void 0,onToggle:()=>oe(R=>({...R,[C.id]:j})),onMenuChange:R=>{G(void 0),O(R?C.id:void 0)},onTaskSettings:()=>{Vn!==void 0&&k?.({automationId:Vn,name:Zo??C.name,sessionIds:C.sessions.map(R=>R.id)})},onArchiveGroup:()=>{ne(void 0),V({id:C.id,name:C.name,sessionIds:bt})},onUnarchiveGroup:()=>{ce(void 0),H({id:C.id,name:C.name,sessionIds:wt})}}),(ke==="list"||j)&&C.sessions.map(R=>(0,y.jsx)($r,{t:n,flat:ke==="list",id:R.id,title:R.title,hoverTitle:String(g[R.id]?.displayTitle??g[R.id]?.title??C.name),updatedAt:R.updatedAt,running:R.running,archived:Me.has(R.id),selected:u===R.id,menuOpen:B===R.id,canDelete:$o,canUnarchive:vt,hoverStatuses:ho({running:R.running||N?.get(R.id)?.running===!0,archived:Me.has(R.id),completed:N?.get(R.id)?.completionUnread===!0,...N?.get(R.id)?.pendingInteraction?.kind===void 0?{}:{pendingKind:N.get(R.id)?.pendingInteraction?.kind??""},runningSubagentCount:(P?.[R.id]?.values?.subagentCatalog??[]).filter(on=>on.id!==void 0&&N?.get(on.id)?.running===!0).length},n),...A===void 0?{}:{renderSlot:A},onMenuChange:on=>{O(void 0),G(on?R.id:void 0)},onOpen:()=>{if(G(void 0),Me.has(R.id)){m?.();return}s?.(R.id)},onDeleteSession:()=>{te(void 0),fe({id:R.id,title:String(g[R.id]?.displayTitle??g[R.id]?.title??R.title)})},...o===void 0?{}:{renameSession:o},...a===void 0?{}:{archiveSession:a},...c===void 0?{}:{unarchiveSession:c},...h===void 0?{}:{forkSession:h}},R.id))]},C.id===""?"ungrouped":C.id)})]})})]})}),(0,y.jsx)(U.Modal,{open:K!==void 0,onClose:()=>{J||(V(void 0),ne(void 0))},closeLabel:n("session.archiveGroupClose"),title:n("session.archiveGroup"),...K===void 0?{}:{description:n("session.archiveGroupDescription",{name:K.name,count:K.sessionIds.length})},footer:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(U.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:J,onClick:()=>{V(void 0),ne(void 0)},children:n("session.archiveGroupCancel")}),(0,y.jsx)(U.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:J,onClick:Ko,children:n("session.archiveGroupConfirm")})]}),children:J||ee!==void 0?(0,y.jsxs)(y.Fragment,{children:[J&&(0,y.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.archiveGroupPending")}),ee!==void 0&&(0,y.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.archiveGroupFailed",{message:ee})})]}):void 0}),(0,y.jsx)(U.Modal,{open:S!==void 0,onClose:()=>{E||(H(void 0),ce(void 0))},closeLabel:n("session.unarchiveGroupClose"),title:n("session.unarchiveGroup"),...S===void 0?{}:{description:n("session.unarchiveGroupDescription",{name:S.name,count:S.sessionIds.length})},footer:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(U.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:E,onClick:()=>{H(void 0),ce(void 0)},children:n("session.unarchiveGroupCancel")}),(0,y.jsx)(U.Button,{variant:"primary",className:"dsh-st-modal-action",disabled:E,onClick:jo,children:n("session.unarchiveGroupConfirm")})]}),children:E||de!==void 0?(0,y.jsxs)(y.Fragment,{children:[E&&(0,y.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.unarchiveGroupPending")}),de!==void 0&&(0,y.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.unarchiveGroupFailed",{message:de})})]}):void 0}),(0,y.jsx)(U.Modal,{open:ie!==void 0,onClose:()=>{xe||(fe(void 0),te(void 0))},closeLabel:n("session.deleteSessionClose"),title:n("session.deleteSession"),...ie===void 0?{}:{description:n("session.deleteSessionDescription",{name:ie.title})},footer:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(U.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:xe,onClick:()=>{fe(void 0),te(void 0)},children:n("session.deleteSessionCancel")}),(0,y.jsx)(U.Button,{variant:"outline",className:"dsh-st-modal-action dsh-st-btn-danger",disabled:xe,onClick:qo,children:n("session.deleteSessionConfirm")})]}),children:xe||Z!==void 0?(0,y.jsxs)(y.Fragment,{children:[xe&&(0,y.jsx)("div",{className:"dsh-st-n-dialog-status",role:"status",children:n("session.deleteSessionPending")}),Z!==void 0&&(0,y.jsx)("div",{className:"dsh-st-n-dialog-error",role:"alert",children:n("session.deleteSessionFailed",{message:Z})})]}):void 0})]})}function Br(e){let{t:n,id:t,name:s,expanded:r,hasCurrentSession:i,menuOpen:o,canArchiveGroup:a,canUnarchiveGroup:c,showTaskSettings:l,onToggle:h,onMenuChange:m,onTaskSettings:k,onArchiveGroup:A,onUnarchiveGroup:f}=e,p=[...l?[{id:"task-settings",label:n("session.taskSettings"),icon:(0,y.jsx)(vs,{size:16})}]:[],...a?[...l?[{type:"separator",id:"archive-separator"}]:[],{id:"archive-group",label:n("session.archiveGroup"),icon:(0,y.jsx)(_e,{size:16}),danger:!0}]:[],...c?[...l&&!a?[{type:"separator",id:"unarchive-separator"}]:[],{id:"unarchive-group",label:n("session.unarchiveGroup"),icon:(0,y.jsx)(Yn,{size:16})}]:[]],u="dsh-st-n-row"+(i?" has-current-session":"")+(o?" is-menu":"");return(0,y.jsxs)("div",{className:u,role:"treeitem","aria-expanded":r,"data-n-group":t,onClick:h,children:[(0,y.jsx)("span",{className:"dsh-st-n-slot dsh-st-n-folder",children:r?(0,y.jsx)(ks,{size:16}):(0,y.jsx)(ze,{size:16})}),(0,y.jsx)("span",{className:"dsh-st-n-slot dsh-st-n-chevron",children:(0,y.jsx)(Ts,{size:14,className:"dsh-st-n-arrow"+(r?" is-open":"")})}),(0,y.jsx)("span",{className:"dsh-st-n-project-text",children:(0,y.jsx)("span",{className:"dsh-st-n-title",children:s})}),(0,y.jsx)("span",{className:"dsh-st-n-acts",children:(0,y.jsx)(U.Menu,{open:o,onClose:()=>{m(!1)},items:p,onSelect:g=>{m(!1),g==="task-settings"&&k(),g==="archive-group"&&A(),g==="unarchive-group"&&f?.()},portal:!0,closeOnPointerLeave:!0,anchor:(0,y.jsx)(U.Tooltip,{label:n("session.groupActions",{name:s}),side:"bottom",delayMs:500,portal:!0,children:(0,y.jsx)("button",{type:"button",className:"dsh-st-n-ico","aria-label":n("session.groupActions",{name:s}),onMouseDown:g=>{g.stopPropagation()},onClick:g=>{g.stopPropagation(),m(!o)},children:(0,y.jsx)(Ye,{size:16})})})})})]})}function $r(e){let{t:n,flat:t,id:s,title:r,hoverTitle:i,updatedAt:o,running:a,archived:c,selected:l,menuOpen:h,canDelete:m,canUnarchive:k,hoverStatuses:A,renderSlot:f,onMenuChange:p,onOpen:u,onDeleteSession:g,renameSession:v,archiveSession:x,unarchiveSession:N,forkSession:P}=e,W=lo(t,a),oe=(0,L.useRef)(null),B=(0,L.useRef)(null),[G,$]=(0,L.useState)(!1),[O,K]=(0,L.useState)({}),V=(0,L.useRef)(void 0),J=(0,L.useRef)(null),re=(0,L.useRef)({id:0});(0,L.useEffect)(()=>()=>{pt(J.current,re.current)},[]);let[ee,ne]=(0,L.useState)(!1),[S,H]=(0,L.useState)(r);(0,L.useEffect)(()=>{H(r)},[r]),(0,L.useEffect)(()=>{if(typeof U.HoverCard=="function"||!G||h)return;let d=()=>{let I=oe.current?.getBoundingClientRect(),_=B.current;if(I===void 0)return;let Ce=_===null?{width:220,height:96}:{width:_.offsetWidth,height:_.offsetHeight};K(fo({right:I.right,top:I.top},Ce,{width:window.innerWidth,height:window.innerHeight}))};return d(),window.addEventListener("resize",d),document.addEventListener("scroll",d,!0),()=>{window.removeEventListener("resize",d),document.removeEventListener("scroll",d,!0)}},[G,h,r,o,a]),(0,L.useEffect)(()=>()=>{V.current!==void 0&&window.clearTimeout(V.current)},[]);let E=d=>{Promise.resolve(d()).catch(()=>{})},ae=()=>{typeof U.HoverCard=="function"||h||(V.current!==void 0&&window.clearTimeout(V.current),V.current=window.setTimeout(()=>$(!0),500))},de=()=>{V.current!==void 0&&window.clearTimeout(V.current),$(!1)},ce="dsh-st-n-sess"+(l?" is-on":"")+(h?" is-menu":"")+(W?" is-flat-idle":"")+(c?" is-archived":"");if(ee)return(0,y.jsx)("div",{className:ce,ref:oe,children:(0,y.jsx)("input",{className:"dsh-st-n-rename",value:S,autoFocus:!0,"aria-label":n("session.rename"),onChange:d=>H(d.target.value),onClick:d=>d.stopPropagation(),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),ne(!1),S.trim()!==""&&S.trim()!==r&&E(()=>v?.(s,S.trim()))),d.key==="Escape"&&(d.preventDefault(),ne(!1),H(r))},onBlur:()=>{ne(!1),S.trim()!==""&&S.trim()!==r&&E(()=>v?.(s,S.trim()))}})});let ie=(i??r).trim()||r,fe=f!==void 0?["pin","rename","fork","archive","session-id","archive-manager.delete-session"].map(d=>f("sidebar.workspaces.session.menu.item",{sessionId:s,displayTitle:ie},{hookContext:[h,I=>p(I)],only:d})).filter(Boolean):void 0,ge=fe!==void 0&&fe.some(Boolean)?c&&m?[{id:"delete-session",label:n("session.deleteSession"),icon:(0,y.jsx)(Jn,{}),danger:!0}]:[]:[...io({canDelete:m,archived:c,canUnarchive:k}).map(d=>d==="rename"?{id:d,label:n("session.rename"),icon:(0,y.jsx)(ws,{})}:d==="fork"?{id:d,label:n("session.fork"),icon:(0,y.jsx)(bs,{})}:d==="archive"?{id:d,label:n("session.archive"),icon:(0,y.jsx)(_e,{size:16})}:d==="unarchive"?{id:d,label:n("session.unarchive"),icon:(0,y.jsx)(Yn,{size:16})}:{id:d,label:n("session.deleteSession"),icon:(0,y.jsx)(Jn,{}),danger:!0}),{id:"session-id",label:n("session.copySessionId"),icon:(0,y.jsx)(As,{size:16})}],Z=A.find(d=>d.state!=="archived"),te=!c&&Z!==void 0&&Z.state!=="idle",ye=Z?.trailing,we=(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{className:"dsh-st-n-hover-title",children:ie}),(0,y.jsx)("div",{className:"dsh-st-n-hover-time",children:wo(o,n)}),A.map(d=>(0,y.jsxs)("div",{className:"dsh-st-n-hover-state",children:[d.state==="archived"?(0,y.jsx)(_e,{size:14}):(0,y.jsx)(U.StateDot,{state:d.state==="ongoing"?"ongoing":d.state==="warning"?"warning":d.state==="done"?"done":"idle",size:10}),d.label]},d.label))]}),T=(0,y.jsxs)("div",{className:ce,ref:oe,role:"treeitem",tabIndex:0,"aria-selected":l,"data-n-menu-root":s,onClick:u,onMouseEnter:()=>{vo(J.current,re.current),ae()},onMouseLeave:()=>{pt(J.current,re.current),de()},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),u())},onContextMenu:d=>{d.preventDefault(),d.stopPropagation(),de(),p(!0)},children:[!W&&(0,y.jsx)("span",{className:"dsh-st-n-slot",children:te&&Z!==void 0?(0,y.jsx)(U.StateDot,{state:Z.state==="ongoing"?"ongoing":Z.state==="warning"?"warning":"done",size:10}):a?(0,y.jsx)(U.StateDot,{state:"ongoing",size:10}):null}),(0,y.jsx)("span",{ref:J,className:"dsh-st-n-title",onDoubleClick:d=>{v!==void 0&&(d.stopPropagation(),ne(!0))},children:r}),(0,y.jsx)("span",{className:"dsh-st-n-time","aria-hidden":ye===void 0?void 0:!0,children:ye??bo(o,n)}),(0,y.jsxs)("span",{className:"dsh-st-n-acts",children:[fe===void 0&&c&&k&&(0,y.jsx)("button",{type:"button",className:"dsh-st-n-restore",onMouseDown:d=>{d.stopPropagation()},onClick:d=>{d.stopPropagation(),E(()=>N?.(s))},children:n("session.unarchive")}),(0,y.jsx)(U.Menu,{open:h,onClose:()=>{p(!1)},items:ge,onSelect:d=>{p(!1),d==="rename"&&ne(!0),d==="fork"&&E(()=>P?.(s)),d==="archive"&&E(()=>x?.(s)),d==="unarchive"&&E(()=>N?.(s)),d==="session-id"&&navigator.clipboard?.writeText(s),d==="delete-session"&&g?.()},portal:!0,closeOnPointerLeave:!0,anchor:(0,y.jsx)(U.Tooltip,{label:n("session.moreActions",{title:r}),side:"bottom",delayMs:500,portal:!0,children:(0,y.jsx)("button",{type:"button",className:"dsh-st-n-ico","aria-label":n("session.moreActions",{title:r}),onMouseDown:d=>{d.stopPropagation()},onClick:d=>{d.stopPropagation(),de(),p(!h)},children:(0,y.jsx)(Ye,{size:16})})}),children:fe}),mo(f,"sidebar.workspaces.session.row.action",{sessionId:s,displayTitle:ie},{only:"archive"})]}),typeof U.HoverCard!="function"&&G&&!h&&typeof document<"u"&&(0,Ao.createPortal)((0,y.jsx)("div",{ref:B,className:"dsh-st-n-hover",style:O,onMouseEnter:ae,onMouseLeave:de,children:we}),document.body)]});return typeof U.HoverCard!="function"?T:(0,y.jsx)(U.HoverCard,{anchor:T,content:we,openDelayMs:800,disabled:h,copyText:ie,copyLabel:n("session.copy"),copiedLabel:n("session.copied")})}var F=require("react"),Hn=require("@deepseek-ai/dsh-client-ui-primitives");var M=require("react/jsx-runtime"),Io=[],Kr=e=>()=>{},On="dsh-st-shell-panel",mt=class extends F.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(n){console.warn("[dsh-automation] official workspace tree crashed",n)}render(){return this.state.failed?this.props.fallback:this.props.children}};function Co({t:e,runtime:n,openSession:t,openTaskSettings:s,view:r,showViewSwitch:i=!0}){let o=(0,F.useSyncExternalStore)(n.source.subscribe,n.source.getSnapshot,n.source.getSnapshot),[a,c]=(0,F.useState)({}),[l,h]=(0,F.useState)("runs"),m=r??l,k=o.snapshot,A=(0,F.useMemo)(()=>k===void 0?[]:yn(k.automations,k.runs),[k]);return(0,M.jsxs)("div",{className:"dsh-st-rail",children:[i&&(0,M.jsx)("div",{className:"dsh-st-n-views-wrap",children:(0,M.jsx)(Ln,{t:e,view:m,onChange:h})}),(0,M.jsx)("div",{id:Ke,role:"tabpanel",className:"dsh-st-rail-panel",children:m==="overview"?k===void 0?(0,M.jsx)("div",{className:"dsh-st-rail-empty",children:o.phase==="loading"?e("loading"):e("overview.empty")}):(0,M.jsx)(Pn,{t:e,automations:k.automations,onToggleAutomation:(f,p)=>n.mutateAutomation(f,p),...s===void 0?{}:{openTaskSettings:s},...k.serverNow===void 0?{}:{serverNow:k.serverNow}}):(0,M.jsxs)(M.Fragment,{children:[o.phase==="loading"&&A.length===0&&(0,M.jsx)("div",{className:"dsh-st-rail-empty",children:e("loading")}),A.length===0&&o.phase!=="loading"&&(0,M.jsx)("div",{className:"dsh-st-rail-empty",children:e("sidebar.empty")}),A.map(f=>(0,M.jsxs)("section",{className:"dsh-st-rail-group",children:[(0,M.jsxs)("button",{type:"button",className:"dsh-st-rail-head",onClick:()=>c(p=>({...p,[f.id]:!p[f.id]})),children:[(0,M.jsx)("span",{className:"dsh-st-rail-folder",children:(0,M.jsx)(Ie,{size:16})}),(0,M.jsx)("span",{className:"dsh-st-rail-title",children:f.name})]}),a[f.id]!==!0&&f.sessions.map(p=>(0,M.jsxs)("button",{type:"button",className:"dsh-st-rail-session",onClick:()=>t?.(p.id),children:[(0,M.jsx)("span",{children:p.label}),p.running&&(0,M.jsx)(Hn.StateDot,{state:"ongoing",size:10})]},p.id))]},f.id))]})})]})}function No({t:e,runtime:n,officialTree:t,hostProps:s,openSession:r,openTaskSettings:i,useSessions:o,useWorkspaces:a,renderSlot:c,tabRegistry:l,wide:h}){let m=t,[k,A]=(0,F.useState)(()=>{try{return qt(window.localStorage.getItem(Zn))}catch{return"tasks"}}),f=(0,F.useSyncExternalStore)(l?.subscribe??Kr,()=>l?.getTabs()??Io,()=>Io),p=f.some(S=>S.id==="channels"),u=o?.(S=>Xe(S)),g=(0,F.useSyncExternalStore)(n.source.subscribe,n.source.getSnapshot,n.source.getSnapshot),v=(0,F.useMemo)(()=>Kt(g.snapshot?.runs),[g.snapshot]),x=(0,F.useRef)(null);(0,F.useEffect)(()=>{if(!bn(u,g.snapshot?.runs)){x.current=null;return}x.current!==u&&(x.current=u??null,n.refresh().catch(()=>{}))},[g.snapshot?.runs,u,n]);let N=(0,F.useCallback)((S,H)=>o===void 0?S({ids:[],byId:{}}):o(E=>S(ns(E,v)),H),[o,v]),P=(0,F.useCallback)((S,H)=>a===void 0?S({items:[],archivedSessionIds:[]}):a(E=>S(is(E,v)),H),[a,v]);(0,F.useEffect)(()=>{try{window.localStorage.setItem(Zn,k)}catch{}},[k]),(0,F.useEffect)(()=>{let S=H=>{let E=H.target instanceof Element?H.target.closest("button"):null;if(E===null)return;let ae=`${E.textContent??""} ${E.getAttribute("aria-label")??""}`;/新会话|新建任务|New chat|New session/i.test(ae)&&A("tasks")};return document.addEventListener("click",S,!0),()=>document.removeEventListener("click",S,!0)},[]);let W=(0,F.useRef)(u),oe=(0,F.useRef)(!1);(0,F.useEffect)(()=>{let S=Yt(u??void 0,v);if(!oe.current){oe.current=!0,W.current=u,S==="tasks"&&A("tasks");return}let H=W.current;if(W.current=u,!Zt(H,u))return;let E=f.map(de=>de.id);S==="tasks"&&A("tasks"),S==="channels"&&(p||E.includes("channels"))&&A("channels");let ae=f.find(de=>u!=null&&de.matchSession?.(String(u))===!0);ae!==void 0&&ae.id!=="schedule"&&A(ae.id)},[u,p,f,v]);let B={...s??{},...h===void 0?{}:{wide:h}},G={...B,...o===void 0?{}:{useSessions:N},...a===void 0?{}:{useWorkspaces:P}},$=S=>m===void 0?(0,M.jsx)(jr,{t:e,...r===void 0?{}:{openSession:r},...o===void 0?{}:{useSessions:N},...a===void 0?{}:{useWorkspaces:a}}):(0,M.jsx)(mt,{fallback:(0,F.createElement)(m,B),children:(0,F.createElement)(m,S)});if(h===!1)return(0,M.jsx)(M.Fragment,{children:$(G)});let O=(0,F.useMemo)(()=>f.filter(S=>S.id!=="schedule"),[f]),K=Jt({tab:k,channelsReady:p,extraTabIds:Xt({extraTabIds:O.map(S=>S.id),channelsReady:p})}),V=f.find(S=>S.id==="schedule"),J=V===void 0?(0,M.jsx)(Dn,{t:e,runtime:n,...r===void 0?{}:{openSession:r},...i===void 0?{}:{openTaskSettings:i},...o===void 0?{}:{useSessions:o},...a===void 0?{}:{useWorkspaces:a},...c===void 0?{}:{renderSlot:c},...Rn(s),...typeof s?.useSessionStatus=="function"?{useSessionStatus:s.useSessionStatus}:{}}):V.render({...s??{},openSession:r,open:r,useSessions:o,wide:!0}),re=(0,F.useMemo)(()=>{let S=[{value:"tasks",id:"dsh-st-tab-tasks",panelId:On,label:(0,M.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,M.jsx)(ze,{size:14}),(0,M.jsx)("span",{children:e("sidebar.tasksTab")})]})}];for(let H of O){if(H.id==="tasks")continue;let E=H.id==="channels"?(0,M.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,M.jsx)("svg",{viewBox:"0 0 16 16",width:14,height:14,fill:"none","aria-hidden":"true",children:(0,M.jsx)("path",{fill:"currentColor",d:"M2.15 2.9h11.7v8.2H6.42L2.15 13.85V2.9Zm1.4 1.4v6.62l1.78-1.12h7.12V4.3H3.55Z"})}),(0,M.jsx)("span",{children:H.label})]}):H.label;S.push({value:H.id,id:"dsh-st-tab-"+H.id,panelId:On,label:E})}return S.push({value:"schedule",id:"dsh-st-tab-schedule",panelId:On,label:(0,M.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[(0,M.jsx)(Ie,{size:14}),(0,M.jsx)("span",{children:e("sidebar.tab")})]})}),S},[p,O,e]),ee=K==="schedule"||K==="tasks"?void 0:O.find(S=>S.id===K),ne=ee!==void 0||K==="schedule"||K==="channels"?"dsh-st-shell-body":"dsh-st-official-tree";return(0,M.jsxs)("div",{className:"dsh-st-shell-rail",children:[(0,M.jsx)("div",{className:"dsh-st-shell-tabs-wrap",children:(0,M.jsx)(Hn.SegmentedTabs,{className:"dsh-st-shell-segmented-tabs",label:e("sidebar.tabs"),value:K,onChange:S=>A(S),items:re})}),(0,M.jsx)("div",{id:On,role:"tabpanel",className:ne,children:K==="schedule"?J:ee!==void 0?ee.render({...s??{},openSession:r,open:r,useSessions:o,wide:!0}):$(G)})]})}function jr({t:e,openSession:n,useSessions:t,useWorkspaces:s}){let r=t===void 0?{ids:[],byId:{}}:t(c=>c??{ids:[],byId:{}}),i=s===void 0?void 0:s(c=>c??{items:[],archivedSessionIds:[]}),o=jt(r,i,e("sidebar.ungrouped")),a=Xe(r);return o.length===0?(0,M.jsx)("div",{className:"dsh-st-rail-empty",children:e("sidebar.tasksEmpty")}):(0,M.jsx)("div",{className:"dsh-st-rail",children:o.map(c=>(0,M.jsxs)("section",{className:"dsh-st-rail-group",children:[(0,M.jsx)("div",{className:"dsh-st-rail-head is-static",children:(0,M.jsx)("span",{className:"dsh-st-rail-title",children:c.label})}),c.sessions.map(l=>(0,M.jsx)("button",{type:"button",className:`dsh-st-rail-session${a===l.id?" is-on":""}`,onClick:()=>{l.id!==void 0&&n?.(l.id)},children:(0,M.jsx)("span",{children:l.title||l.id})},l.id))]},c.id||"ungrouped"))})}var Ro="dsh-automation-styles",Fn="@michengai/dsh-automation",Eo=`
4
4
  .dsh-st-shell{container-type:inline-size;min-width:0;box-sizing:border-box;max-width:1080px;width:100%;margin:0 auto;padding:0 0 32px;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family,system-ui)}
5
5
  .dsh-st-top{display:flex;flex-direction:column;align-items:stretch;gap:12px;margin-bottom:12px}
6
6
  .dsh-st-heading h1,.dsh-st-top h1{margin:0;font-size:24px;line-height:32px;font-weight:600;letter-spacing:-.4px;white-space:nowrap}
@@ -94,8 +94,19 @@ var module = { exports: {} }; var exports = module.exports;
94
94
  .dsh-st-composer-left,.dsh-st-composer-right{display:flex;align-items:center;gap:2px;min-width:0}
95
95
  .dsh-st-composer-left{flex:1}.dsh-st-composer-right{flex:none}
96
96
  @media(max-width:860px){.dsh-st-toolbar{flex-wrap:wrap}.dsh-st-search{flex-basis:100%;max-width:none}.dsh-st-grid,.dsh-st-example-row{grid-template-columns:1fr}.dsh-st-filters{width:100%;margin:8px 0}}
97
- .dsh-st-rail-views{margin:16px 8px 10px}
98
- .dsh-st-overview{display:flex;flex-direction:column;flex:1;min-height:0;overflow-y:auto;padding:2px 8px 14px}
97
+ .dsh-st-n-views-wrap{display:flex;flex:none;margin:2px 0 8px;padding:0;width:100%}
98
+ .dsh-st-n-views-wrap .dsh-st-rail-views{margin:0!important;width:100%!important}
99
+ .dsh-st-n-view-body{display:flex;flex:1;min-width:0;min-height:0;flex-direction:column}
100
+ /* \u4EE5\u4E0B\u4E24\u6BB5\u8986\u76D6\u5BBF\u4E3B SegmentedTabs \u7684\u80F6\u56CA\u5916\u89C2\u3002\u9009\u62E9\u5668\u4F9D\u8D56\u539F\u8BED\u6E32\u67D3\u51FA\u7684\u7ED3\u6784\uFF1A
101
+ \u5BB9\u5668 [role=tablist] \u7684\u9996\u4E2A\u5B50\u5143\u7D20\u662F aria-hidden \u7684\u6ED1\u52A8\u6307\u793A\u5668\uFF0C\u5176\u540E\u624D\u662F\u5404 [role=tab]\u3002
102
+ \u5347\u7EA7 @deepseek-ai/dsh-client-ui-primitives \u65F6\u5FC5\u987B\u590D\u6838\u8BE5\u7ED3\u6784\uFF0C\u5426\u5219\u8FD9\u4E9B\u89C4\u5219\u4F1A\u9759\u9ED8\u5931\u6548\u3002 */
103
+ .dsh-st-rail-views{display:grid!important;width:100%;margin:0!important;padding:2px!important;background:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 3%,transparent)!important;border-radius:8px!important;border:0.5px solid var(--dsw-alias-border-l1,rgba(255,255,255,.05))!important;box-sizing:border-box}
104
+ .dsh-st-rail-views>span[aria-hidden="true"]{inset:2px auto 2px 2px!important;border-radius:6px!important;border:0.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.08))!important;background:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 8%,transparent)!important;border-color:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 12%,transparent)!important;box-shadow:none!important}
105
+ .dsh-st-rail-views [role=tab]{display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:5px!important;width:100%!important;height:26px!important;padding:0 6px!important;font-size:13px!important;line-height:18px!important;border-radius:6px!important;color:var(--dsw-alias-label-secondary,#8b8f98);font-weight:500;text-align:center!important}
106
+ .dsh-st-rail-views [role=tab]>*{display:inline-flex!important;align-items:center!important;justify-content:center!important}
107
+ .dsh-st-rail-views [role=tab]:hover{color:var(--dsw-alias-label-primary,inherit)}
108
+ .dsh-st-rail-views [role=tab][aria-selected=true]{color:var(--dsw-alias-label-primary,inherit)!important;font-weight:600}
109
+ .dsh-st-overview{display:flex;flex-direction:column;flex:1;min-height:0;overflow-y:auto;padding:2px 0 14px}
99
110
  .dsh-st-overview-head{display:flex;flex:none;align-items:center;justify-content:space-between;gap:8px;height:36px;min-height:36px;margin-bottom:4px;padding:6px 0}
100
111
  .dsh-st-overview-title{display:flex;align-items:baseline;min-width:0;gap:6px;color:var(--dsw-alias-label-tertiary,#81858C)}
101
112
  .dsh-st-overview-title strong{font-size:14px;font-weight:400;line-height:20px}
@@ -127,10 +138,13 @@ var module = { exports: {} }; var exports = module.exports;
127
138
  .dsh-st-rail-session span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
128
139
  .dsh-st-run-dot{flex:none;color:var(--dsw-static-deepseek-450,#4c8dff)}.dsh-st-run-dot-cell{fill:currentColor;opacity:.15;animation:dsh-st-run-chase 1s infinite}@keyframes dsh-st-run-chase{0%,12.4%{opacity:1}12.5%,24.9%{opacity:.6}25%,37.4%{opacity:.35}37.5%,100%{opacity:.15}}
129
140
  .dsh-st-shell-rail{display:flex;flex-direction:column;min-height:0;flex:1;height:100%;overflow:hidden}
130
- .dsh-st-shell-tabs{display:flex;flex:none;gap:18px;padding:6px 12px 0;border-bottom:1px solid var(--dsw-alias-border-l2,rgba(255,255,255,.08))}
131
- .dsh-st-shell-tabs button{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-secondary,#8b8f98);padding:8px 0 9px;font-size:13px;font-weight:500;cursor:pointer;transition:color .15s ease}
132
- .dsh-st-shell-tabs button:hover{color:var(--dsw-alias-label-primary,inherit)}
133
- .dsh-st-shell-tabs button.is-on{color:var(--dsw-alias-label-primary,inherit);font-weight:600;box-shadow:inset 0 -2px 0 var(--dsw-alias-state-business-primary,currentColor)}
141
+ .dsh-st-shell-tabs-wrap{display:flex;margin:2px var(--dsh-sidebar-inline-padding,12px) 8px 0;padding:0;width:auto}
142
+ .dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs{width:100%;background:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 3%,transparent)!important;border-radius:8px!important;border:0.5px solid var(--dsw-alias-border-l1,rgba(255,255,255,.05))!important;box-sizing:border-box;padding:2px!important}
143
+ .dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs>span[aria-hidden="true"]{inset:2px auto 2px 2px!important;border-radius:6px!important;border:0.5px solid var(--dsw-alias-border-l2,rgba(255,255,255,.08))!important;background:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 8%,transparent)!important;border-color:color-mix(in srgb,var(--dsw-alias-label-primary,currentColor) 12%,transparent)!important;box-shadow:none!important}
144
+ .dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs [role=tab]{display:inline-flex!important;align-items:center!important;justify-content:center!important;gap:5px!important;width:100%!important;height:26px!important;padding:0 6px!important;font-size:13px!important;line-height:18px!important;border-radius:6px!important;color:var(--dsw-alias-label-secondary,#8b8f98);text-align:center!important}
145
+ .dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs [role=tab]>*{display:inline-flex!important;align-items:center!important;justify-content:center!important}
146
+ .dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs [role=tab]:hover{color:var(--dsw-alias-label-primary,inherit)}
147
+ .dsh-st-shell-tabs-wrap .dsh-st-shell-segmented-tabs [role=tab][aria-selected=true]{color:var(--dsw-alias-label-primary,inherit)!important;font-weight:600}
134
148
  .dsh-st-shell-body{display:flex;min-height:0;flex:1;overflow:hidden}
135
149
  .dsh-st-shell-body>*{min-width:0;flex:1}.dsh-st-official-tree{display:flex;min-height:0;flex:1;overflow:hidden}.dsh-st-official-tree>*{min-width:0;flex:1}
136
150
  .dsh-st-rail-head.is-static{cursor:default;font-weight:600}
@@ -160,7 +174,7 @@ var module = { exports: {} }; var exports = module.exports;
160
174
  .dsh-st-n-sess .dsh-st-n-title[data-clipped]{mask-image:linear-gradient(270deg,#0000,#000 12px)}
161
175
  .dsh-st-n-sess .dsh-st-n-title[data-scrolled][data-clipped]{mask-image:linear-gradient(90deg,#0000,#000 12px calc(100% - 12px),#0000)}
162
176
  .dsh-st-create-dialog{width:min(720px,100%) !important;max-height:100%}
163
- `;function Mo(){let e=document.getElementById(No);if(e instanceof HTMLStyleElement)return e.textContent=Ro,e.setAttribute("data-plugin",On),()=>{};let n=document.createElement("style");return n.id=No,n.textContent=Ro,n.setAttribute("data-plugin",On),document.head.append(n),()=>{n.remove()}}var Eo="michengai-plugin-update-ui";function Lo(e){let n=document.getElementById(Eo);if(n instanceof HTMLStyleElement){n.getAttribute("data-plugin")===null&&n.setAttribute("data-plugin",On);return}let t=document.createElement("style");t.id=Eo,t.textContent=e,t.setAttribute("data-plugin",On),(document.head??document.documentElement).append(t)}function Kr(e,n){for(let t of n){let s=t.trim();if(s==="")continue;let r=e.find(i=>i.textContent?.replace(/\s+/g," ").trim()===s);if(r!==void 0)return r}}function qr(e){return e.find(t=>{let s=`${t.textContent??""} ${t.getAttribute("aria-label")??""}`.trim();return/(^|\s)(设置|settings)(\s|$)/i.test(s)})??(e.length===1?e[0]:void 0)}var Dn,Oo="[data-dcu-settings-trigger]",Po="[data-dcu-settings-page]",jr="dcu-settings-open-section";function Zr(e){let n=document.querySelector(Oo);if(n===null)return!1;let t=new CustomEvent(jr,{detail:{labels:[...e]},cancelable:!0});return!n.dispatchEvent(t)}function Do(e,n,t){if(typeof document>"u"||typeof window>"u"){t?.();return}if(Zr(e)){n?.();return}let s=[...document.querySelectorAll('button[aria-haspopup="dialog"]')],r=qr(s),i=document.querySelector(Oo),o=document.querySelector('[role="dialog"]')!==null,a=document.querySelector(Po)!==null;if(!o&&!a&&r===void 0&&i===null){t?.();return}Dn?.(),!o&&!a&&(i??r)?.click();let l,c=!1,g=new MutationObserver(()=>{A()}),m=()=>{c||(c=!0,g.disconnect(),window.clearTimeout(f),l!==void 0&&window.cancelAnimationFrame(l),Dn===m&&(Dn=void 0))},x=()=>{let p=[...document.querySelectorAll('[role="dialog"] nav button'),...document.querySelectorAll(`${Po} nav button`)],u=Kr(p,e);return u===void 0?!1:(m(),u.click(),n?.(),!0)},A=()=>{c||l!==void 0||(l=window.requestAnimationFrame(()=>{l=void 0,x()}))},f=window.setTimeout(()=>{x()||(m(),t?.())},1500);g.observe(document.body,{childList:!0,subtree:!0}),Dn=m,A()}var D=on(require("react"),1),mt=require("react-dom/client"),De=require("@deepseek-ai/dsh-client-ui-primitives");function Fo(e,n,t){return`dsh plugin${e.trim()===""?"":` --profile ${e.trim()}`} add ${n}@${t} --registry=https://registry.npmjs.org/`}function Ho(e,n){return e.key!=="Escape"?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),n(),!0)}var Xr="x-michengai-plugin-update",Jr=`
177
+ `;function Lo(){let e=document.getElementById(Ro);if(e instanceof HTMLStyleElement)return e.textContent=Eo,e.setAttribute("data-plugin",Fn),()=>{};let n=document.createElement("style");return n.id=Ro,n.textContent=Eo,n.setAttribute("data-plugin",Fn),document.head.append(n),()=>{n.remove()}}var Mo="michengai-plugin-update-ui";function Po(e){let n=document.getElementById(Mo);if(n instanceof HTMLStyleElement){n.getAttribute("data-plugin")===null&&n.setAttribute("data-plugin",Fn);return}let t=document.createElement("style");t.id=Mo,t.textContent=e,t.setAttribute("data-plugin",Fn),(document.head??document.documentElement).append(t)}function qr(e,n){for(let t of n){let s=t.trim();if(s==="")continue;let r=e.find(i=>i.textContent?.replace(/\s+/g," ").trim()===s);if(r!==void 0)return r}}function Zr(e){return e.find(t=>{let s=`${t.textContent??""} ${t.getAttribute("aria-label")??""}`.trim();return/(^|\s)(设置|settings)(\s|$)/i.test(s)})??(e.length===1?e[0]:void 0)}var Wn,Oo="[data-dcu-settings-trigger]",Do="[data-dcu-settings-page]",Xr="dcu-settings-open-section";function Jr(e){let n=document.querySelector(Oo);if(n===null)return!1;let t=new CustomEvent(Xr,{detail:{labels:[...e]},cancelable:!0});return!n.dispatchEvent(t)}function Ho(e,n,t){if(typeof document>"u"||typeof window>"u"){t?.();return}if(Jr(e)){n?.();return}let s=[...document.querySelectorAll('button[aria-haspopup="dialog"]')],r=Zr(s),i=document.querySelector(Oo),o=document.querySelector('[role="dialog"]')!==null,a=document.querySelector(Do)!==null;if(!o&&!a&&r===void 0&&i===null){t?.();return}Wn?.(),!o&&!a&&(i??r)?.click();let c,l=!1,h=new MutationObserver(()=>{A()}),m=()=>{l||(l=!0,h.disconnect(),window.clearTimeout(f),c!==void 0&&window.cancelAnimationFrame(c),Wn===m&&(Wn=void 0))},k=()=>{let p=[...document.querySelectorAll('[role="dialog"] nav button'),...document.querySelectorAll(`${Do} nav button`)],u=qr(p,e);return u===void 0?!1:(m(),u.click(),n?.(),!0)},A=()=>{l||c!==void 0||(c=window.requestAnimationFrame(()=>{c=void 0,k()}))},f=window.setTimeout(()=>{k()||(m(),t?.())},1500);h.observe(document.body,{childList:!0,subtree:!0}),Wn=m,A()}var D=an(require("react"),1),ft=require("react-dom/client"),Oe=require("@deepseek-ai/dsh-client-ui-primitives");function Fo(e,n,t){return`dsh plugin${e.trim()===""?"":` --profile ${e.trim()}`} add ${n}@${t} --registry=https://registry.npmjs.org/`}function Wo(e,n){return e.key!=="Escape"?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),n(),!0)}var Yr="x-michengai-plugin-update",Qr=`
164
178
  .mpi-version{margin-left:8px;color:var(--dsw-alias-label-tertiary,#a0a0a0);font-family:inherit;font-size:12px;font-weight:500;line-height:18px;letter-spacing:0;white-space:nowrap;vertical-align:baseline}.mpi-check-host{display:inline-flex;align-items:center}.mpi-icon{display:inline-flex;flex:0 0 auto;width:16px;height:16px;align-items:center;justify-content:center;pointer-events:none}.mpi-icon svg{display:block;width:16px;height:16px}
165
179
  .dsh-st-modal-action{min-width:72px}
166
180
  .mpi-intro{margin:0 0 16px;color:var(--dsw-alias-label-secondary,#b9b9b9);font-size:13px;line-height:20px}.mpi-meta{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:8px 18px;margin:0 0 16px;font-size:12px;line-height:18px}.mpi-meta dt{color:var(--dsw-alias-label-secondary,#b9b9b9)}.mpi-meta dd{margin:0}.mpi-mono{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.mpi-latest{display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 10px}.mpi-status{font-size:13px;font-weight:600;line-height:18px}.mpi-status[data-kind=error]{color:var(--dsw-alias-state-error-primary,#ef7272)}.mpi-status[data-kind=success]{color:var(--dsw-alias-state-success-primary,#51b976)}.mpi-status[data-kind=update]{color:#e8b15a !important}.mpi-manual{border-top:0.5px solid var(--dsw-alias-border-l2,#494949);padding-top:16px}.mpi-manual h3{margin:0 0 6px;font-size:14px;line-height:20px}.mpi-manual p{margin:0 0 10px;color:var(--dsw-alias-label-secondary,#b9b9b9);font-size:12px;line-height:18px}.mpi-command{display:flex;align-items:flex-start;gap:8px;border:0.5px solid var(--dsw-alias-border-l2,#494949);border-radius:var(--dsw-radius-lg,16px);padding:10px;background:var(--dsw-alias-bg-layer-1,var(--dsw-alias-interactive-bg-hover,transparent))}.mpi-command code{min-width:0;flex:1;overflow:visible;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px;line-height:18px;white-space:pre-wrap;overflow-wrap:anywhere}
@@ -169,6 +183,6 @@ var module = { exports: {} }; var exports = module.exports;
169
183
  @keyframes dsh-st-progress-slide{0%{transform:translateX(-100%)}100%{transform:translateX(300%)}}
170
184
  @media (prefers-reduced-motion:reduce){.dsh-st-update-progress-bar{animation:none;width:100%;opacity:.6}}
171
185
  @media(max-width:560px){.mpi-meta{grid-template-columns:1fr;gap:2px}.mpi-meta dd{margin-bottom:6px}}
172
- `,Yr={check:"\u68C0\u67E5\u66F4\u65B0",update:"\u66F4\u65B0",close:"\u5173\u95ED",recheck:"\u91CD\u65B0\u68C0\u67E5",auto:"\u81EA\u52A8\u66F4\u65B0",updating:"\u6B63\u5728\u66F4\u65B0\u2026",copy:"\u590D\u5236\u547D\u4EE4",copied:"\u5DF2\u590D\u5236",copyFailed:"\u590D\u5236\u5931\u8D25",checking:"\u6B63\u5728\u68C0\u67E5\u66F4\u65B0\u2026",latest:"\u5DF2\u662F\u6700\u65B0\u7248\u672C",found:"\u53D1\u73B0\u65B0\u7248\u672C",failed:"\u68C0\u67E5\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",current:"\u8FD0\u884C\u7248\u672C",latestLabel:"\u6700\u65B0\u7248\u672C",profile:"\u76EE\u6807 profile",unknown:"\u672A\u77E5",manual:"\u624B\u5DE5\u66F4\u65B0",manualHint:"\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u65F6\uFF0C\u53EF\u5728\u5F53\u524D DSH \u7EC8\u7AEF\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\uFF0C\u5B8C\u6210\u540E\u91CD\u542F DSH Web\u3002",manualHintDesktop:"\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u65F6\uFF0C\u8BF7\u5148\u5B8C\u5168\u9000\u51FA DSH Desktop\uFF0C\u518D\u7528 Desktop \u81EA\u5E26\u7684 dsh \u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u3002\u666E\u901A dsh \u4F1A\u62D2\u7EDD desktop profile\u3002",intro:"\u4EC5\u68C0\u67E5\u5E76\u66F4\u65B0\u5F53\u524D\u63D2\u4EF6\uFF0C\u4E0D\u4F1A\u8054\u52A8\u5B89\u88C5\u5176\u4ED6\u63D2\u4EF6\u3002",restart:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u8BF7\u91CD\u542F DSH Web\u3002",restartDesktop:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u8BF7\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u65B0\u6253\u5F00 DSH Desktop\u3002",restarting:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u6B63\u5728\u91CD\u542F DSH Desktop\u2026",unavailable:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u81EA\u52A8\u66F4\u65B0\uFF0C\u8BF7\u4F7F\u7528\u624B\u5DE5\u66F4\u65B0\u547D\u4EE4\u3002"},Qr={check:"Check for updates",update:"Update",close:"Close",recheck:"Check again",auto:"Update automatically",updating:"Updating\u2026",copy:"Copy command",copied:"Copied",copyFailed:"Copy failed",checking:"Checking for updates\u2026",latest:"You are up to date",found:"New version available",failed:"Could not check for updates. Try again later.",current:"Running version",latestLabel:"Latest version",profile:"Target profile",unknown:"Unknown",manual:"Manual update",manualHint:"If automatic update fails, run this command in the current DSH terminal, then restart DSH Web.",manualHintDesktop:"If automatic update fails, fully quit DSH Desktop, then run this command with Desktop's own dsh. A regular dsh rejects the desktop profile.",intro:"Only this plugin is checked and updated. Other plugins are not changed.",restart:"Update complete. Restart DSH Web.",restartDesktop:"Update complete. Fully quit and reopen DSH Desktop.",restarting:"Update complete. Restarting DSH Desktop\u2026",unavailable:"Automatic update is unavailable. Use the manual command."};function Fn(e){return e.toLowerCase().startsWith("en")?Qr:Yr}function ei(e,n,t,s){let r=Fn(e),o=n?.profileName==="desktop"?{...r,manualHint:r.manualHintDesktop,restart:r.restartDesktop}:r,a=t!=="idle",l=o.checking,c="";return t==="checking"?l=o.checking:t==="updating"?l=o.updating:s.type==="error"?(l=s.message||o.failed,c="error"):s.type==="restart"?(l=o.restart,c="success"):s.type==="restarting"?(l=o.restarting,c="success"):n===void 0?l=o.checking:n.latestCheckFailed?(l=o.failed,c="error"):!n.canAutoUpdate&&n.updateAvailable?(l=o.unavailable,c="update"):n.updateAvailable?(l=`${o.found}: v${n.latestVersion??o.unknown}`,c="update"):(l=o.latest,c="success"),{copy:o,busy:a,message:l,kind:c,loading:t==="updating",updateLabel:t==="updating"?o.updating:o.auto,disabled:a||n?.canAutoUpdate!==!0||n.updateAvailable!==!0,currentVersion:n===void 0?o.unknown:`v${n.currentVersion}`,latestVersion:n?.latestVersion===void 0?o.unknown:`v${n.latestVersion}`,profileName:n?.profileName??o.unknown,profileRaw:n?.profileName??"",latestRaw:n?.latestVersion??"latest"}}function ni(e,n,t){let s="idle",r=n,i={type:"status"},o=new Set,a=()=>{for(let c of o)c()},l=c=>{r=c,t?.(c)};return{subscribe(c){return o.add(c),()=>{o.delete(c)}},view(c){return ei(c,r,s,i)},async check(){if(s==="idle"){s="checking",i={type:"status"},a();try{l(await e("GET")),i={type:"status"}}catch(c){i={type:"error",message:c instanceof Error?c.message:""}}finally{s="idle",a()}}},async update(){if(s==="idle"){s="updating",i={type:"status"},a();try{let c=await e("POST");l(c),i={type:c.autoReload===!0?"restarting":"restart"}}catch(c){i={type:"error",message:c instanceof Error?c.message:""}}finally{s="idle",a()}}}}}function ti(){Lo(Jr)}function si(e){if(e===null||typeof e!="object")return!1;let n=e;return typeof n.packageName=="string"&&typeof n.currentVersion=="string"&&typeof n.updateAvailable=="boolean"&&typeof n.profileName=="string"&&typeof n.canAutoUpdate=="boolean"&&typeof n.latestCheckFailed=="boolean"&&(n.latestVersion===void 0||typeof n.latestVersion=="string")}async function Wo(e,n,t){let s=t===void 0?{}:{signal:t},r=await fetch(e,n==="GET"?{cache:"no-store",...s}:{method:"POST",headers:{"content-type":"application/json",[Xr]:"1"},body:"{}",...s}),i=await r.json();if(!r.ok||!si(i))throw new Error(i!==null&&typeof i=="object"&&"error"in i&&typeof i.error=="string"?i.error:Fn(document.documentElement.lang).failed);return i}function oi(e){let n=D.default.useRef(null);return D.default.useLayoutEffect(()=>{n.current?.replaceChildren(e.node)},[e.node]),D.default.createElement("span",{ref:n,className:"mpi-icon","aria-hidden":!0})}function ri(e){let n=D.default.useRef(null),[,t]=D.default.useState(0),[s,r]=D.default.useState("idle");D.default.useEffect(()=>e.flow.subscribe(()=>t(g=>g+1)),[e.flow]),D.default.useEffect(()=>{let g=document.documentElement,m=new MutationObserver(()=>t(x=>x+1));return m.observe(g,{attributes:!0,attributeFilter:["lang"]}),()=>m.disconnect()},[]),D.default.useEffect(()=>{e.flow.check()},[e.flow]),D.default.useEffect(()=>{let g=m=>{Ho(m,e.onClose)};return document.addEventListener("keydown",g,!0),()=>document.removeEventListener("keydown",g,!0)},[e.onClose]);let i=document.documentElement.lang,o=e.flow.view(i),a=i.toLowerCase().startsWith("en")?e.enName:e.zhName,l=Fo(o.profileRaw,e.packageName,o.latestRaw),c=s==="copied"?o.copy.copied:s==="failed"?o.copy.copyFailed:o.copy.copy;return D.default.createElement(De.Modal,{open:!0,className:"dsh-st-update-dialog",title:`${a} ${o.copy.update}`,closeLabel:o.copy.close,onClose:e.onClose,footer:D.default.createElement(D.default.Fragment,null,D.default.createElement(De.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:o.busy,onClick:()=>{e.flow.check()}},o.copy.recheck),D.default.createElement(De.Button,{variant:"primary",className:"dsh-st-modal-action",disabled:o.disabled,onClick:()=>{e.flow.update()}},o.updateLabel))},D.default.createElement("div",{ref:n},D.default.createElement("p",{className:"mpi-intro"},o.copy.intro),D.default.createElement("dl",{className:"mpi-meta"},D.default.createElement("dt",null,o.copy.current),D.default.createElement("dd",null,D.default.createElement("span",{className:"mpi-mono"},o.currentVersion)),D.default.createElement("dt",null,o.copy.latestLabel),D.default.createElement("dd",{className:"mpi-latest"},D.default.createElement("span",{className:"mpi-mono"},o.latestVersion),D.default.createElement("span",{className:"mpi-status",role:"status","data-kind":o.kind,...o.kind==="update"?{style:{color:"#e8b15a"}}:{}},o.message)),D.default.createElement("dt",null,o.copy.profile),D.default.createElement("dd",null,D.default.createElement("span",{className:"mpi-mono"},o.profileName))),o.busy?D.default.createElement("div",{className:"dsh-st-update-progress",role:"progressbar","aria-busy":"true"},D.default.createElement("div",{className:"dsh-st-update-progress-bar"})):null,D.default.createElement("section",{className:"mpi-manual"},D.default.createElement("h3",null,o.copy.manual),D.default.createElement("p",null,o.copy.manualHint),D.default.createElement("div",{className:"mpi-command"},D.default.createElement("code",null,l),D.default.createElement(De.Button,{variant:"outline",size:"sm",disabled:o.busy,onClick:()=>{let g=navigator.clipboard?.writeText(l);if(g===void 0){r("failed");return}g.then(()=>{r("copied"),window.setTimeout(()=>r("idle"),1400)}).catch(()=>r("failed"))}},c)))))}function _o(e){if(typeof document>"u"||document.body===null)return()=>{};ti();let n=new AbortController,t,s,r,i,o,a,l,c=()=>{r?.unmount(),r=void 0,s=void 0,i=void 0},g=()=>{if(r===void 0)return;i===void 0&&(i=e.createIcon("refresh"));let u=i;r.render(D.default.createElement(De.Button,{variant:"outline",size:"sm",onClick:x,icon:D.default.createElement(oi,{node:u})},D.default.createElement("span",{"data-mpi-label":""},Fn(document.documentElement.lang).check)))},m=()=>{a?.unmount(),a=void 0,o?.remove(),o=void 0};function x(){m();let u=document.createElement("div");u.className="mpi-dialog-root",document.body.append(u),o=u;let y=(0,mt.createRoot)(u);a=y,y.render(D.default.createElement(ri,{flow:ni(h=>Wo(e.endpoint,h,n.signal),t,h=>{t=h,A()}),packageName:e.packageName,zhName:e.zhName,enName:e.enName,onClose:m}))}let A=()=>{let u=document.querySelector(e.titleRowSelector);if(u===null)return;let y=u.querySelector("h1,h2");if(y!==null&&t!==void 0){let M=y.querySelector(`.mpi-version[data-package="${e.packageName}"]`);M===null&&(M=document.createElement("span"),M.className="mpi-version",M.dataset.package=e.packageName,y.append(M));let _=`v${t.currentVersion}`;M.textContent!==_&&(M.textContent=_)}s!==void 0&&!s.isConnected&&c();let h=u.querySelector(e.linksSelector);if(h===null)return;let S=h.querySelector(`[data-mpi-check="${e.packageName}"]`);if(S!==null){let M=S.querySelector("[data-mpi-label]");(M===null||M.textContent!==Fn(document.documentElement.lang).check)&&g();return}let N=document.createElement("span");N.dataset.mpiCheck=e.packageName,N.className="mpi-check-host",h.append(N),s=N,r=(0,mt.createRoot)(N),g()},f=async()=>(t=await Wo(e.endpoint,"GET",n.signal),A(),t),p=new MutationObserver(()=>{l===void 0&&(l=window.requestAnimationFrame(()=>{l=void 0,A()}))});return p.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["lang"]}),A(),f().catch(()=>{}),()=>{n.abort(),p.disconnect(),m(),c(),l!==void 0&&window.cancelAnimationFrame(l),document.querySelectorAll(`[data-mpi-check="${e.packageName}"],.mpi-version[data-package="${e.packageName}"]`).forEach(u=>u.remove())}}var ii="dsh-automation-client",ai=["slots","locale","connection","sessions"],di={refresh:["M13.5 5.5V2.5m0 0h-3m3 0-2.1 2.1A5.5 5.5 0 1 0 13.2 12"],download:["M8 2v8m0 0 3-3m-3 3-3-3M3 13v2h10v-2"],copy:["M5 5h8v8H5z","M3 3h8"],close:["m4 4 8 8M12 4 4 12"]};function li(e){let n=document.createElement("span"),t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 16 16"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.5"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");for(let s of di[e]){let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",s),t.append(r)}return n.append(t),n}var ci='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-dsh-schedule-icon="1"><path d="M8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14Z"/><path d="M8 4.667V8l2.333 2.333"/></svg>';function ui(e){return typeof e=="function"}function pi(e){return typeof e=="function"}function mi(e){let n=new Set(e().map(i=>i.trim()).filter(i=>i!=="")),t=i=>{let o=(i.textContent??"").replace(/\s+/g," ").trim();if(!n.has(o))return;let a=i.querySelector("svg");a===null||a.getAttribute("data-dsh-schedule-icon")==="1"||(a.outerHTML=ci)},s=i=>{i instanceof HTMLButtonElement&&t(i);for(let o of i.querySelectorAll?.("button")??[])t(o)};s(document);let r=new MutationObserver(i=>{for(let o of i){let l=(o.target instanceof Element?o.target:o.target.parentElement)?.closest("button");l instanceof HTMLButtonElement&&t(l);for(let c of o.addedNodes)c instanceof Element&&s(c)}});return r.observe(document.documentElement,{childList:!0,characterData:!0,subtree:!0}),()=>{r.disconnect()}}function fi(e){e.effect(()=>Mo(),"dsh-automation: styles"),e.effect(()=>e.locale.register(Be,{zh:Js,en:Xs}),"dsh-automation: locale"),e.effect(()=>_o({endpoint:"/api/michengai/dsh-automation/update",packageName:"@michengai/dsh-automation",titleRowSelector:".dsh-st-heading-row",linksSelector:".dsh-st-heading-links",zhName:"\u5B9A\u65F6\u4EFB\u52A1",enName:"Scheduled tasks",createIcon:li}),"dsh-automation: plugin update ui");let n=e.locale.bind(Be),t=e.locale.bind("permission.access"),s=e.locale.bind("model"),r=$s(e.connection.rpc),i=async()=>{let a=await Vn(e);return a===void 0?void 0:(await $n(e,a),(await r.registerWorkspace(a)).id)},o=a=>{at(a),Do([n("tab"),"Scheduled tasks","\u5B9A\u65F6\u4EFB\u52A1"],()=>{at(a)})};e.effect(()=>Bs(r,()=>e.sessions),"dsh-automation: session sync"),e.effect(()=>mi(()=>[n("tab"),"Scheduled tasks","\u5B9A\u65F6\u4EFB\u52A1"]),"dsh-automation: settings icon"),e.slots.inject("settings.section",()=>e.slots.register({name:"settings.section",id:"scheduled-tasks",order:35,locale:Be,label:()=>n("tab"),icon:"schedule",inject:()=>({createWorkspace:a=>$n(e,a.path),pickDirectory:()=>Vn(e),permissionT:t,modelT:s})},function(l){return(0,Fe.createElement)(Zs,{t:n,permissionT:t,modelT:s,runtime:r,...l.close===void 0?{}:{closeSettings:l.close},addWorkspace:i})})),e.slots.inject("sidebar.schedule",()=>e.slots.register({name:"sidebar.schedule",id:"dsh-automation-schedule",order:10,locale:Be,label:()=>n("sidebar.tab")},function(l){return(0,Fe.createElement)(Io,{t:n,runtime:r,openSession:ft(e,r,l.openSession),openTaskSettings:o,...l.view===void 0?{}:{view:l.view},...l.showViewSwitch===void 0?{}:{showViewSwitch:l.showViewSwitch}})})),e.slots.inject("sidebar.workspaces",()=>{let a,l,c,g,m,x=()=>{},A=!1,f,p=()=>{queueMicrotask(()=>window.dispatchEvent(new Event("dsh-native-sidebar-change")))},u=z=>e.slots.subscribe?.("sidebar.channels",z)??(()=>{}),y=()=>{f!==void 0&&(window.clearInterval(f),f=void 0)},h=()=>{if(y(),x(),x=()=>{},m=void 0,a!==void 0){l!==void 0&&a.component===c&&(a.component=l);let z=a;z.__dshNativeTabs===g&&delete z.__dshNativeTabs,p()}a=void 0,l=void 0,c=void 0,g=void 0},S=(z,Q)=>{let V=eo(z);return V===void 0?!1:(m!==V&&(x(),x=()=>{},m=V),V.getTabs().some(F=>F.id==="schedule")||(x=V.insert({id:"schedule",label:n("sidebar.tab"),order:30,matchSession:F=>F.startsWith(We),render:F=>{let G=typeof F.openSession=="function"?F.openSession:typeof F.open=="function"?F.open:Q,W=ft(e,r,G);return(0,Fe.createElement)(Pn,{t:n,runtime:r,openSession:W,...ui(F.useSessions)?{useSessions:F.useSessions}:{},...pi(F.useWorkspaces)?{useWorkspaces:F.useWorkspaces}:{},...typeof F.renderSlot=="function"?{renderSlot:F.renderSlot}:{},...typeof F.useSessionStatus=="function"?{useSessionStatus:F.useSessionStatus}:{},...Nn(F),openTaskSettings:o})}})),!0)},N=()=>{let z=Hn(e,"sidebar.workspaces");for(let Q of z){let V=Q;if(S(Q)||S(V.component))return!0}return!1},M=()=>{if(N()){y();return}if(f!==void 0)return;let z=0;f=window.setInterval(()=>{z+=1,(N()||z>=20)&&y()},250)},_=()=>{if(!A){A=!0;try{let ce=function(H){let L=ft(e,r,H.openSession??H.open);return(0,Fe.createElement)(Co,{t:n,runtime:r,hostProps:H,openSession:L,openTaskSettings:o,tabRegistry:ee,...H.wide===void 0?{}:{wide:H.wide},hasChannels:()=>gi(e,"sidebar.channels"),subscribeChannels:u,...H.useSessions===void 0?{}:{useSessions:H.useSessions},...H.useWorkspaces===void 0?{}:{useWorkspaces:H.useWorkspaces},...H.renderSlot===void 0?{}:{renderSlot:H.renderSlot},officialTree:R})};var z=ce;if(Jt(Hn(e,"sidebar"))){h();return}let Q=Hn(e,"sidebar.workspaces"),V=Q.find(H=>H?.component!==void 0);if(a!==void 0&&(V!==a||V.component!==c)&&h(),V===a&&V?.component===c&&c!==void 0){M();return}if(V===void 0){h();return}let F=as(Q),G=F?.component;if(G!==void 0&&no(G)){M();return}if(F?.component===void 0)return;let W=is(F.component);if(W===void 0)return;l=W;let ee=Qs(l);g=ee,lt(F,ee);let I=ce;I.displayName="AutomationNativeWorkspaceShell",I.__dshNativeTabHost=!0,I.__dshAutomationWrapped=!0,I.__dshAutomationOriginal=l;let R=l;lt(I,ee),F.component=I,c=I,a=F,M(),p()}catch(Q){console.warn("[dsh-automation] \u5305\u88F9\u5B98\u65B9\u4EFB\u52A1\u6811\u5931\u8D25",Q)}finally{A=!1}}};_();let se=typeof e.slots.subscribe=="function"?e.slots.subscribe("sidebar.workspaces",_):()=>{},re=e.slots.subscribe?.("sidebar",_)??(()=>{});return window.addEventListener("dsh-native-sidebar-change",_),M(),()=>{se(),re(),window.removeEventListener("dsh-native-sidebar-change",_),h()}}),e.slots.inject("conversation.input.left",()=>e.slots.register({name:"conversation.input.left",id:"dsh-automation-prefill",order:80,locale:Be},hi))}function ft(e,n,t){return s=>{let r=es(e);ss({id:s,adopt:i=>n.adoptSession(i),listed:i=>{let o=e.sessions?.list?.getSnapshot();return(o?.ids??[]).includes(i)||o?.byId?.[i]!==void 0},...e.sessions?.refresh===void 0?{}:{refresh:()=>e.sessions.refresh()},...ns(r)?{openRuntime:i=>{ts(r,i)}}:{},...t===void 0?{}:{openHost:t}})}}function hi(e){return(0,Fe.useEffect)(()=>{let n=t=>{if(!(t===null||t==="")){if(e.inputActions!==void 0){e.inputActions.setDraft(t),nt();return}_s(t)&&nt()}};return n(Hs()),Ws(n)},[e.inputActions]),null}function Hn(e,n){try{return(e.slots.entriesOfSlot??e.slots.entries)?.call(e.slots,n)??[]}catch{return[]}}function gi(e,n){return Hn(e,n).length>0}
186
+ `,ei={check:"\u68C0\u67E5\u66F4\u65B0",update:"\u66F4\u65B0",close:"\u5173\u95ED",recheck:"\u91CD\u65B0\u68C0\u67E5",auto:"\u81EA\u52A8\u66F4\u65B0",updating:"\u6B63\u5728\u66F4\u65B0\u2026",copy:"\u590D\u5236\u547D\u4EE4",copied:"\u5DF2\u590D\u5236",copyFailed:"\u590D\u5236\u5931\u8D25",checking:"\u6B63\u5728\u68C0\u67E5\u66F4\u65B0\u2026",latest:"\u5DF2\u662F\u6700\u65B0\u7248\u672C",found:"\u53D1\u73B0\u65B0\u7248\u672C",failed:"\u68C0\u67E5\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",current:"\u8FD0\u884C\u7248\u672C",latestLabel:"\u6700\u65B0\u7248\u672C",profile:"\u76EE\u6807 profile",unknown:"\u672A\u77E5",manual:"\u624B\u5DE5\u66F4\u65B0",manualHint:"\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u65F6\uFF0C\u53EF\u5728\u5F53\u524D DSH \u7EC8\u7AEF\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\uFF0C\u5B8C\u6210\u540E\u91CD\u542F DSH Web\u3002",manualHintDesktop:"\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u65F6\uFF0C\u8BF7\u5148\u5B8C\u5168\u9000\u51FA DSH Desktop\uFF0C\u518D\u7528 Desktop \u81EA\u5E26\u7684 dsh \u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u3002\u666E\u901A dsh \u4F1A\u62D2\u7EDD desktop profile\u3002",intro:"\u4EC5\u68C0\u67E5\u5E76\u66F4\u65B0\u5F53\u524D\u63D2\u4EF6\uFF0C\u4E0D\u4F1A\u8054\u52A8\u5B89\u88C5\u5176\u4ED6\u63D2\u4EF6\u3002",restart:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u8BF7\u91CD\u542F DSH Web\u3002",restartDesktop:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u8BF7\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u65B0\u6253\u5F00 DSH Desktop\u3002",restarting:"\u66F4\u65B0\u5B8C\u6210\uFF0C\u6B63\u5728\u91CD\u542F DSH Desktop\u2026",unavailable:"\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u81EA\u52A8\u66F4\u65B0\uFF0C\u8BF7\u4F7F\u7528\u624B\u5DE5\u66F4\u65B0\u547D\u4EE4\u3002"},ni={check:"Check for updates",update:"Update",close:"Close",recheck:"Check again",auto:"Update automatically",updating:"Updating\u2026",copy:"Copy command",copied:"Copied",copyFailed:"Copy failed",checking:"Checking for updates\u2026",latest:"You are up to date",found:"New version available",failed:"Could not check for updates. Try again later.",current:"Running version",latestLabel:"Latest version",profile:"Target profile",unknown:"Unknown",manual:"Manual update",manualHint:"If automatic update fails, run this command in the current DSH terminal, then restart DSH Web.",manualHintDesktop:"If automatic update fails, fully quit DSH Desktop, then run this command with Desktop's own dsh. A regular dsh rejects the desktop profile.",intro:"Only this plugin is checked and updated. Other plugins are not changed.",restart:"Update complete. Restart DSH Web.",restartDesktop:"Update complete. Fully quit and reopen DSH Desktop.",restarting:"Update complete. Restarting DSH Desktop\u2026",unavailable:"Automatic update is unavailable. Use the manual command."};function _n(e){return e.toLowerCase().startsWith("en")?ni:ei}function ti(e,n,t,s){let r=_n(e),o=n?.profileName==="desktop"?{...r,manualHint:r.manualHintDesktop,restart:r.restartDesktop}:r,a=t!=="idle",c=o.checking,l="";return t==="checking"?c=o.checking:t==="updating"?c=o.updating:s.type==="error"?(c=s.message||o.failed,l="error"):s.type==="restart"?(c=o.restart,l="success"):s.type==="restarting"?(c=o.restarting,l="success"):n===void 0?c=o.checking:n.latestCheckFailed?(c=o.failed,l="error"):!n.canAutoUpdate&&n.updateAvailable?(c=o.unavailable,l="update"):n.updateAvailable?(c=`${o.found}: v${n.latestVersion??o.unknown}`,l="update"):(c=o.latest,l="success"),{copy:o,busy:a,message:c,kind:l,loading:t==="updating",updateLabel:t==="updating"?o.updating:o.auto,disabled:a||n?.canAutoUpdate!==!0||n.updateAvailable!==!0,currentVersion:n===void 0?o.unknown:`v${n.currentVersion}`,latestVersion:n?.latestVersion===void 0?o.unknown:`v${n.latestVersion}`,profileName:n?.profileName??o.unknown,profileRaw:n?.profileName??"",latestRaw:n?.latestVersion??"latest"}}function si(e,n,t){let s="idle",r=n,i={type:"status"},o=new Set,a=()=>{for(let l of o)l()},c=l=>{r=l,t?.(l)};return{subscribe(l){return o.add(l),()=>{o.delete(l)}},view(l){return ti(l,r,s,i)},async check(){if(s==="idle"){s="checking",i={type:"status"},a();try{c(await e("GET")),i={type:"status"}}catch(l){i={type:"error",message:l instanceof Error?l.message:""}}finally{s="idle",a()}}},async update(){if(s==="idle"){s="updating",i={type:"status"},a();try{let l=await e("POST");c(l),i={type:l.autoReload===!0?"restarting":"restart"}}catch(l){i={type:"error",message:l instanceof Error?l.message:""}}finally{s="idle",a()}}}}}function oi(){Po(Qr)}function ri(e){if(e===null||typeof e!="object")return!1;let n=e;return typeof n.packageName=="string"&&typeof n.currentVersion=="string"&&typeof n.updateAvailable=="boolean"&&typeof n.profileName=="string"&&typeof n.canAutoUpdate=="boolean"&&typeof n.latestCheckFailed=="boolean"&&(n.latestVersion===void 0||typeof n.latestVersion=="string")}async function _o(e,n,t){let s=t===void 0?{}:{signal:t},r=await fetch(e,n==="GET"?{cache:"no-store",...s}:{method:"POST",headers:{"content-type":"application/json",[Yr]:"1"},body:"{}",...s}),i=await r.json();if(!r.ok||!ri(i))throw new Error(i!==null&&typeof i=="object"&&"error"in i&&typeof i.error=="string"?i.error:_n(document.documentElement.lang).failed);return i}function ii(e){let n=D.default.useRef(null);return D.default.useLayoutEffect(()=>{n.current?.replaceChildren(e.node)},[e.node]),D.default.createElement("span",{ref:n,className:"mpi-icon","aria-hidden":!0})}function ai(e){let n=D.default.useRef(null),[,t]=D.default.useState(0),[s,r]=D.default.useState("idle");D.default.useEffect(()=>e.flow.subscribe(()=>t(h=>h+1)),[e.flow]),D.default.useEffect(()=>{let h=document.documentElement,m=new MutationObserver(()=>t(k=>k+1));return m.observe(h,{attributes:!0,attributeFilter:["lang"]}),()=>m.disconnect()},[]),D.default.useEffect(()=>{e.flow.check()},[e.flow]),D.default.useEffect(()=>{let h=m=>{Wo(m,e.onClose)};return document.addEventListener("keydown",h,!0),()=>document.removeEventListener("keydown",h,!0)},[e.onClose]);let i=document.documentElement.lang,o=e.flow.view(i),a=i.toLowerCase().startsWith("en")?e.enName:e.zhName,c=Fo(o.profileRaw,e.packageName,o.latestRaw),l=s==="copied"?o.copy.copied:s==="failed"?o.copy.copyFailed:o.copy.copy;return D.default.createElement(Oe.Modal,{open:!0,className:"dsh-st-update-dialog",title:`${a} ${o.copy.update}`,closeLabel:o.copy.close,onClose:e.onClose,footer:D.default.createElement(D.default.Fragment,null,D.default.createElement(Oe.Button,{variant:"outline",className:"dsh-st-modal-action",disabled:o.busy,onClick:()=>{e.flow.check()}},o.copy.recheck),D.default.createElement(Oe.Button,{variant:"primary",className:"dsh-st-modal-action",disabled:o.disabled,onClick:()=>{e.flow.update()}},o.updateLabel))},D.default.createElement("div",{ref:n},D.default.createElement("p",{className:"mpi-intro"},o.copy.intro),D.default.createElement("dl",{className:"mpi-meta"},D.default.createElement("dt",null,o.copy.current),D.default.createElement("dd",null,D.default.createElement("span",{className:"mpi-mono"},o.currentVersion)),D.default.createElement("dt",null,o.copy.latestLabel),D.default.createElement("dd",{className:"mpi-latest"},D.default.createElement("span",{className:"mpi-mono"},o.latestVersion),D.default.createElement("span",{className:"mpi-status",role:"status","data-kind":o.kind,...o.kind==="update"?{style:{color:"#e8b15a"}}:{}},o.message)),D.default.createElement("dt",null,o.copy.profile),D.default.createElement("dd",null,D.default.createElement("span",{className:"mpi-mono"},o.profileName))),o.busy?D.default.createElement("div",{className:"dsh-st-update-progress",role:"progressbar","aria-busy":"true"},D.default.createElement("div",{className:"dsh-st-update-progress-bar"})):null,D.default.createElement("section",{className:"mpi-manual"},D.default.createElement("h3",null,o.copy.manual),D.default.createElement("p",null,o.copy.manualHint),D.default.createElement("div",{className:"mpi-command"},D.default.createElement("code",null,c),D.default.createElement(Oe.Button,{variant:"outline",size:"sm",disabled:o.busy,onClick:()=>{let h=navigator.clipboard?.writeText(c);if(h===void 0){r("failed");return}h.then(()=>{r("copied"),window.setTimeout(()=>r("idle"),1400)}).catch(()=>r("failed"))}},l)))))}function zo(e){if(typeof document>"u"||document.body===null)return()=>{};oi();let n=new AbortController,t,s,r,i,o,a,c,l=()=>{r?.unmount(),r=void 0,s=void 0,i=void 0},h=()=>{if(r===void 0)return;i===void 0&&(i=e.createIcon("refresh"));let u=i;r.render(D.default.createElement(Oe.Button,{variant:"outline",size:"sm",onClick:k,icon:D.default.createElement(ii,{node:u})},D.default.createElement("span",{"data-mpi-label":""},_n(document.documentElement.lang).check)))},m=()=>{a?.unmount(),a=void 0,o?.remove(),o=void 0};function k(){m();let u=document.createElement("div");u.className="mpi-dialog-root",document.body.append(u),o=u;let g=(0,ft.createRoot)(u);a=g,g.render(D.default.createElement(ai,{flow:si(v=>_o(e.endpoint,v,n.signal),t,v=>{t=v,A()}),packageName:e.packageName,zhName:e.zhName,enName:e.enName,onClose:m}))}let A=()=>{let u=document.querySelector(e.titleRowSelector);if(u===null)return;let g=u.querySelector("h1,h2");if(g!==null&&t!==void 0){let P=g.querySelector(`.mpi-version[data-package="${e.packageName}"]`);P===null&&(P=document.createElement("span"),P.className="mpi-version",P.dataset.package=e.packageName,g.append(P));let W=`v${t.currentVersion}`;P.textContent!==W&&(P.textContent=W)}s!==void 0&&!s.isConnected&&l();let v=u.querySelector(e.linksSelector);if(v===null)return;let x=v.querySelector(`[data-mpi-check="${e.packageName}"]`);if(x!==null){let P=x.querySelector("[data-mpi-label]");(P===null||P.textContent!==_n(document.documentElement.lang).check)&&h();return}let N=document.createElement("span");N.dataset.mpiCheck=e.packageName,N.className="mpi-check-host",v.append(N),s=N,r=(0,ft.createRoot)(N),h()},f=async()=>(t=await _o(e.endpoint,"GET",n.signal),A(),t),p=new MutationObserver(()=>{c===void 0&&(c=window.requestAnimationFrame(()=>{c=void 0,A()}))});return p.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["lang"]}),A(),f().catch(()=>{}),()=>{n.abort(),p.disconnect(),m(),l(),c!==void 0&&window.cancelAnimationFrame(c),document.querySelectorAll(`[data-mpi-check="${e.packageName}"],.mpi-version[data-package="${e.packageName}"]`).forEach(u=>u.remove())}}var di="dsh-automation-client",li=["slots","locale","connection","sessions"],ci={refresh:["M13.5 5.5V2.5m0 0h-3m3 0-2.1 2.1A5.5 5.5 0 1 0 13.2 12"],download:["M8 2v8m0 0 3-3m-3 3-3-3M3 13v2h10v-2"],copy:["M5 5h8v8H5z","M3 3h8"],close:["m4 4 8 8M12 4 4 12"]};function ui(e){let n=document.createElement("span"),t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("viewBox","0 0 16 16"),t.setAttribute("width","16"),t.setAttribute("height","16"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.5"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true");for(let s of ci[e]){let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",s),t.append(r)}return n.append(t),n}var pi='<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-dsh-schedule-icon="1"><path d="M8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14Z"/><path d="M8 4.667V8l2.333 2.333"/></svg>';function mi(e){return typeof e=="function"}function fi(e){return typeof e=="function"}function hi(e){let n=new Set(e().map(i=>i.trim()).filter(i=>i!=="")),t=i=>{let o=(i.textContent??"").replace(/\s+/g," ").trim();if(!n.has(o))return;let a=i.querySelector("svg");a===null||a.getAttribute("data-dsh-schedule-icon")==="1"||(a.outerHTML=pi)},s=i=>{i instanceof HTMLButtonElement&&t(i);for(let o of i.querySelectorAll?.("button")??[])t(o)};s(document);let r=new MutationObserver(i=>{for(let o of i){let c=(o.target instanceof Element?o.target:o.target.parentElement)?.closest("button");c instanceof HTMLButtonElement&&t(c);for(let l of o.addedNodes)l instanceof Element&&s(l)}});return r.observe(document.documentElement,{childList:!0,characterData:!0,subtree:!0}),()=>{r.disconnect()}}function gi(e){e.effect(()=>Lo(),"dsh-automation: styles"),e.effect(()=>e.locale.register(Be,{zh:Qs,en:Ys}),"dsh-automation: locale"),e.effect(()=>zo({endpoint:"/api/michengai/dsh-automation/update",packageName:"@michengai/dsh-automation",titleRowSelector:".dsh-st-heading-row",linksSelector:".dsh-st-heading-links",zhName:"\u5B9A\u65F6\u4EFB\u52A1",enName:"Scheduled tasks",createIcon:ui}),"dsh-automation: plugin update ui");let n=e.locale.bind(Be),t=e.locale.bind("permission.access"),s=e.locale.bind("model"),r=Ks(e.connection.rpc),i=async()=>{let a=await jn(e);return a===void 0?void 0:(await Kn(e,a),(await r.registerWorkspace(a)).id)},o=a=>{lt(a),Ho([n("tab"),"Scheduled tasks","\u5B9A\u65F6\u4EFB\u52A1"],()=>{lt(a)})};e.effect(()=>$s(r,()=>e.sessions),"dsh-automation: session sync"),e.effect(()=>hi(()=>[n("tab"),"Scheduled tasks","\u5B9A\u65F6\u4EFB\u52A1"]),"dsh-automation: settings icon"),e.slots.inject("settings.section",()=>e.slots.register({name:"settings.section",id:"scheduled-tasks",order:35,locale:Be,label:()=>n("tab"),icon:"schedule",inject:()=>({createWorkspace:a=>Kn(e,a.path),pickDirectory:()=>jn(e),permissionT:t,modelT:s})},function(c){return(0,He.createElement)(Js,{t:n,permissionT:t,modelT:s,runtime:r,...c.close===void 0?{}:{closeSettings:c.close},addWorkspace:i})})),e.slots.inject("sidebar.schedule",()=>e.slots.register({name:"sidebar.schedule",id:"dsh-automation-schedule",order:10,locale:Be,label:()=>n("sidebar.tab")},function(c){return(0,He.createElement)(Co,{t:n,runtime:r,openSession:ht(e,r,c.openSession),openTaskSettings:o,...c.view===void 0?{}:{view:c.view},...c.showViewSwitch===void 0?{}:{showViewSwitch:c.showViewSwitch}})})),e.slots.inject("sidebar.workspaces",()=>{let a,c,l,h,m,k=()=>{},A=!1,f,p=()=>{queueMicrotask(()=>window.dispatchEvent(new Event("dsh-native-sidebar-change")))},u=()=>{f!==void 0&&(window.clearInterval(f),f=void 0)},g=()=>{if(u(),k(),k=()=>{},m=void 0,a!==void 0){c!==void 0&&a.component===l&&(a.component=c);let B=a;B.__dshNativeTabs===h&&delete B.__dshNativeTabs,p()}a=void 0,c=void 0,l=void 0,h=void 0},v=(B,G)=>{let $=so(B);return $===void 0?!1:(m!==$&&(k(),k=()=>{},m=$),$.getTabs().some(O=>O.id==="schedule")||(k=$.insert({id:"schedule",label:n("sidebar.tab"),order:30,matchSession:O=>O.startsWith(We),render:O=>{let K=typeof O.openSession=="function"?O.openSession:typeof O.open=="function"?O.open:G,V=ht(e,r,K);return(0,He.createElement)(Dn,{t:n,runtime:r,openSession:V,...mi(O.useSessions)?{useSessions:O.useSessions}:{},...fi(O.useWorkspaces)?{useWorkspaces:O.useWorkspaces}:{},...typeof O.renderSlot=="function"?{renderSlot:O.renderSlot}:{},...typeof O.useSessionStatus=="function"?{useSessionStatus:O.useSessionStatus}:{},...Rn(O),openTaskSettings:o})}})),!0)},x=()=>{let B=gt(e,"sidebar.workspaces");for(let G of B){let $=G;if(v(G)||v($.component))return!0}return k(),k=()=>{},m=void 0,!1},N=()=>{if(x()){u();return}if(f!==void 0)return;let B=0;f=window.setInterval(()=>{B+=1,(x()||B>=20)&&u()},250)},P=()=>{if(!A){A=!0;try{let re=function(S){let H=ht(e,r,S.openSession??S.open);return(0,He.createElement)(No,{t:n,runtime:r,hostProps:S,openSession:H,openTaskSettings:o,tabRegistry:J,...S.wide===void 0?{}:{wide:S.wide},...S.useSessions===void 0?{}:{useSessions:S.useSessions},...S.useWorkspaces===void 0?{}:{useWorkspaces:S.useWorkspaces},...S.renderSlot===void 0?{}:{renderSlot:S.renderSlot},officialTree:ne})};var B=re;if(Qt(gt(e,"sidebar"))){g();return}let G=gt(e,"sidebar.workspaces"),$=G.find(S=>S?.component!==void 0);if(a!==void 0&&($!==a||$.component!==l)&&g(),$===a&&$?.component===l&&l!==void 0){N();return}if($===void 0){g();return}let O=ls(G),K=O?.component;if(K!==void 0&&oo(K)){N();return}if(O?.component===void 0)return;let V=ds(O.component);if(V===void 0)return;c=V;let J=no(c);h=J,ct(O,J);let ee=re;ee.displayName="AutomationNativeWorkspaceShell",ee.__dshNativeTabHost=!0,ee.__dshAutomationWrapped=!0,ee.__dshAutomationOriginal=c;let ne=c;ct(ee,J),O.component=ee,l=ee,a=O,N(),p()}catch(G){console.warn("[dsh-automation] \u5305\u88F9\u5B98\u65B9\u4EFB\u52A1\u6811\u5931\u8D25",G)}finally{A=!1}}};P();let W=typeof e.slots.subscribe=="function"?e.slots.subscribe("sidebar.workspaces",P):()=>{},oe=e.slots.subscribe?.("sidebar",P)??(()=>{});return window.addEventListener("dsh-native-sidebar-change",P),N(),()=>{W(),oe(),window.removeEventListener("dsh-native-sidebar-change",P),g()}}),e.slots.inject("conversation.input.left",()=>e.slots.register({name:"conversation.input.left",id:"dsh-automation-prefill",order:80,locale:Be},yi))}function ht(e,n,t){return s=>{let r=ts(e);rs({id:s,adopt:i=>n.adoptSession(i),listed:i=>{let o=e.sessions?.list?.getSnapshot();return(o?.ids??[]).includes(i)||o?.byId?.[i]!==void 0},...e.sessions?.refresh===void 0?{}:{refresh:()=>e.sessions.refresh()},...ss(r)?{openRuntime:i=>{os(r,i)}}:{},...t===void 0?{}:{openHost:t}})}}function yi(e){return(0,He.useEffect)(()=>{let n=t=>{if(!(t===null||t==="")){if(e.inputActions!==void 0){e.inputActions.setDraft(t),st();return}Gs(t)&&st()}};return n(_s()),zs(n)},[e.inputActions]),null}function gt(e,n){try{return(e.slots.entriesOfSlot??e.slots.entries)?.call(e.slots,n)??[]}catch{return[]}}
173
187
  return module.exports; } });
174
188
  //# sourceMappingURL=client.js.map