waterplane 0.1.16 → 0.1.17
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/CHANGELOG.md +6 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/packages/web/dist/assets/{index-EYc28CfH.js → index-BYRdfW3T.js} +1 -1
- package/packages/web/dist/assets/index-DcZrEQNl.css +1 -0
- package/packages/web/dist/assets/{sheets-ByWNPa9p.js → sheets-BGN7Cs73.js} +1 -1
- package/packages/web/dist/build-id.txt +1 -1
- package/packages/web/dist/buildstamp.json +1 -1
- package/packages/web/dist/index.html +3 -3
- package/packages/web/dist/sw.js +2 -2
- package/release.json +3 -3
- package/packages/web/dist/assets/index-CpdyS6Xe.css +0 -1
|
@@ -202,7 +202,7 @@ Finish with one line: the button you wrote, its command, and what it will ask fo
|
|
|
202
202
|
|
|
203
203
|
`)||null}function RH(e,t){return e.trigger.kind===`at`&&zte({rule:e.trigger.rule,nextAt:e.nextAt,lastOccurrence:e.lastOccurrence},t)}function zH(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return!!e&&!!t&&/\bsession\b/i.test(e)&&RegExp(`(^|[^\\w-])${n}($|[^\\w-])`,`i`).test(e)}function BH(e,t,n,r){if(e.blockDetail)return e.blockDetail;if(e.blockReason)return dr(e.blockReason);if(t===`fanout`&&r){let e=r.targets.filter(e=>e.status===`done`).length,t=r.targets.filter(e=>e.status===`failed`).length,n=r.targets.length;return r.finishedAt?t?`${t} of ${n} repos failed${e?`, ${e} finished`:``}`:`all ${n} repos finished`:`${e} of ${n} repos done${t?`, ${t} failed`:``} — still going`}switch(e.state){case`running`:return t===`build`?`running the command now`:t===`capture`?`taking the picture now`:`running in the session now`;case`starting`:return`starting it now`;case`canceled`:return`stopped`;case`failed`:return PH(e.result?.detail,e.settledAt??e.createdAt,n,`it ran and did not finish`);case`done`:if(t===`build`){let t=e.result?.artifacts??[];return t.length&&t.every(e=>e.stale)?`finished — nothing was rebuilt, so these are the newest matching files, not this run's output`:t.length?`finished — ${t.length} ${t.length===1?`file`:`files`} written`:`finished — it wrote no build output`}return t===`schedule`&&RH(e,n)?e.result?.detail??`that instant has passed and this was a one-off — post it again if you still want it`:e.result?.detail??`finished`;default:return e.state===`blocked`?`the desktop is holding this one and did not say why`:t===`schedule`?`armed — it will fire on its own`:`next in line for this repo`}}function VH(e){let t=gr(e),n=LH(e),r=e.payload.kind===`build`?e.payload:null,i=e.payload.kind===`capture`?e.payload:null;return(t===`schedule`?e.label||Ar(e.title,n??``)||n||e.id:t===`schedule`||t===`build`||t===`assess`||t===`capture`?e.label||e.title||r?.name||i?.name||r?.cmd||n||e.id:e.headline||n||e.label||e.title||e.id).trim()}var HH=e=>!Ia(e.rule)&&e.action.kind===`backlog`,UH=e=>e.state===`done`||e.state===`failed`||e.state===`canceled`;function WH(e,t){return e.archived||e.trigger.kind!==`at`||UH(e)?!1:Si({rule:e.trigger.rule,nextAt:e.nextAt,lastOccurrence:e.lastOccurrence},t)}function GH(e){return e.archived||e.trigger.kind!==`at`?!1:e.state!==`starting`&&e.state!==`running`&&e.state!==`done`&&e.state!==`canceled`}function KH(e){let{focus:t,focusIds:n,now:r}=e,i=(e.text??``).trim().toLowerCase(),a=e.intents.filter(e=>ga(e)&&!e.archived),o=a.filter(e=>WH(e,r)).sort((e,t)=>(e.nextAt??1/0)-(t.nextAt??1/0)),s=new Set(o.map(e=>e.id)),c=a.filter(e=>!s.has(e.id)&&!e.dismissedAt),l=n?a.filter(e=>n.ids.includes(e.id)):t?o.filter(e=>at(e.nextAt,r)===t):o,u=i?l.filter(e=>JH(e,i)):l,d=[];for(let e of c){let t=d.find(([t])=>t===e.cwd);t?t[1].push(e):d.push([e.cwd,[e]])}let f=t=>e.intents.some(e=>e.id===t.entry.id),p=e.pending.filter(e=>HH(e.entry)&&!f(e)),m=e.pending.filter(e=>!HH(e.entry)),h=new Set(m.map(e=>e.entry.id)),g=[...m.map(e=>e.entry),...(e.entries??[]).filter(e=>!h.has(e.id))].sort((e,t)=>(e.nextAt??1/0)-(t.nextAt??1/0)),_=g.filter(e=>Si(e,r)),v=g.filter(e=>!Si(e,r)),y=n?g.filter(e=>n.ids.includes(e.id)):t?_.filter(e=>at(e.nextAt,r)===t):_,b=i?y.filter(e=>YH(e,i)):y,x=i?p.filter(e=>YH(e.entry,i)):p,S={soon:0,day:0,twoDay:0,week:0,later:0,unarmed:0,total:0};for(let e of[..._.map(e=>e.nextAt),...o.map(e=>e.nextAt),...p.map(e=>e.entry.nextAt)])S.total++,S[at(e,r)]++;return{cards:_,spentCards:v,shownCards:b,pendingCards:m,live:o,gone:c,shown:u,pending:p,shownPending:x,goneByRepo:d,horizon:S,kinds:{rules:_.length,timed:o.length+p.length},standingTotal:S.total,cutTotal:y.length+l.length+p.length,shownTotal:b.length+u.length+x.length}}var qH=e=>e.split(`/`).filter(Boolean).pop()??``;function JH(e,t){return`${VH(e)}\n${LH(e)??``}\n${qH(e.cwd)}`.toLowerCase().includes(t)}function YH(e,t){let n=Ka(e.action);return`${Ar(e.name,n)??``}\n${n}\n${XH(e).map(qH).join(` `)}`.toLowerCase().includes(t)}var XH=e=>e.action.kind===`fanout`?e.action.dirs:[e.action.repoDir];function ZH(e){let{cuts:t,repoOf:n,now:r}=e,i=new Map,a=(e,t,a)=>{let o=new Set;for(let t of e){let e=t?n(t):null;e&&o.add(e)}for(let e of o){let n=i.get(e);n||(n={ids:[],horizon:{soon:0,day:0,twoDay:0,week:0,later:0,unarmed:0,total:0}},i.set(e,n)),n.ids.push(t),n.horizon.total++,n.horizon[at(a??null,r)]++}};for(let e of t.cards)a(XH(e),e.id,e.nextAt);for(let e of t.live)a([e.cwd],e.id,e.nextAt);for(let e of t.pending)a(XH(e.entry),e.entry.id,e.entry.nextAt);return i}function QH(e,t){return`the ${t} on a clock in ${e}`}function $H(e){return e?`schedule deleted — and ${e===1?`the queue row that named it`:`${e} queue rows that named it`}`:`schedule deleted`}function eU(e){return e.filter(e=>e.mode===`op`&&e.op?.t===`schedule.save`).map(e=>({entry:e.op.entry,failed:e.status===`failed`}))}function tU(e){return`the ${e} one-off${e===1?` that has`:`s that have`} been and gone`}var nU=G(IE().v),rU=G(IE().at),iU=G(null),aU=G(null);function oU(){return K(nU)}function sU(e,t,n){let r=K(nU),i=(0,H.useMemo)(()=>eU(t),[t]);return(0,H.useMemo)(()=>KH({intents:e,entries:r,pending:i,focus:null,focusIds:null,now:Date.now()}),[e,r,i,n])}function cU(e){if(e.source!==`queue`)return`this one lives on the desktop — run it again from its own row`;if(e.bucket!==`failed`&&e.blockReason!==`sessionGone`)return`this one has not failed — it is still on its way`;if(!e.cwd)return`nothing recorded which repo these words were for`;let t=e.actions.find(e=>e.id===`retry`)??e.actions.find(e=>e.id===`sendNow`);return t?t.disabledReason??null:`this row is not a message that can be sent again`}function lU(e){return e.dismissedAt==null?e.state===`running`||e.state===`starting`?`this one is running — stopping it is “cancel”`:null:`already filed`}function uU(e,t){let n=[],r=[];for(let i of e){let e=t(i);e?r.push({row:i,why:e}):n.push(i)}return{go:n,skip:r}}var dU=3,fU=70;function pU(e,t){let n=[],r=e.length,i=r===1?`row`:`rows`;t.verb===`dismiss`?(n.push(`${r} ${i} filed away as dealt with.`),n.push(`Nothing is deleted: the words, the verdict and the buttons stay on the row, under the “dismissed” chip, and “bring back” undoes this.`)):t.verb===`restore`?n.push(`${r} ${i} back in the list.`):(n.push(`${r} ${r===1?`message goes`:`messages go`} out again as backlog items, each in the repo it was written for.`),n.push(`They run one at a time per repo, each in a new session. Nothing is re-typed and nothing is asked.`));let a=new Map,o=0;for(let t of e)t.cwd?a.set(t.cwd,(a.get(t.cwd)??0)+1):o+=1;let s=[...a.entries()].sort((e,t)=>t[1]-e[1]).map(([e,n])=>`${t.repoName(e)} ${n}`);o&&s.push(`no repo recorded ${o}`),s.length&&n.push(s.join(` · `));for(let t of e.slice(0,dU)){let e=(t.title||``).replace(/\s+/g,` `).trim();n.push(`“${e.length>fU?`${e.slice(0,fU)}…`:e}”`)}return r>dU&&n.push(`…and ${r-dU} more`),t.skipped&&n.push(`${t.skipped} of the selected ${t.skipped===1?`row is`:`rows are`} left alone — each says why on its own row.`),n}function mU(e,t){return e===`failed`?`failed`:e===`done`||e===`canceled`?`done`:e===`running`||e===`starting`?`running`:t===`sessionGone`||t===`gate`||t===`awaitingAnswer`||t===`auth`?`needsYou`:t===`notYet`?`scheduled`:`waiting`}function hU(e,t,n){let{online:r,now:i,deps:a}=t,o=gr(e),s=FH[o],c=e.blockReason??null,l=LH(e),u=o===`schedule`&&RH(e,i),d=wH(VH(e)),f=t.sessions?.find(t=>t.id===e.sessionId),p=u?qr:null,m=e.state===`done`||e.state===`failed`||e.state===`canceled`,h=e.state===`running`||e.state===`starting`,g=e.target.kind===`repo`,_=Kr(e)?{note:L_e}:g||e.target.kind===`session`?{note:g&&wM(e.cwd,t.intents??[],e.id,t.sessions)?`${SM(g)} — ${CM}`:SM(g)}:{},v=Mi(e)?sa:``,y=ga(e)&&e.trigger.kind===`at`?va(e.trigger.rule):``,b=a.repoName(e.cwd),x=e.target.kind===`repo`&&zH(e.result?.detail,b),S=[e.target.kind===`repos`?`${e.target.dirs.length} ${e.target.dirs.length===1?`repo`:`repos`}`:e.target.kind===`sessions`?`${e.target.sessionIds.length} sessions`:f?.title??(e.target.kind===`repo`?e.resume?`${x?``:`${b} · `}picking up the last conversation`:x?``:`${b} · in a new session`:e.target.kind===`session`?`in ${t.sessions?.find(t=>t.id===e.target.sessionId)?.title??b}`:b),v,y].filter(Boolean).join(` · `),C=e.trigger.kind===`files`?e.trigger.needs:null,w=n?.followUps,T=w?.length?w[w.length-1]:null,E=e.result?.artifacts??[],D=[];if(o===`launch`)D.push(AH(`runNow`,`open it without the files`,{primary:e.state===`blocked`,disabledReason:e.state===`blocked`?jH(r,`opening it`):`it is not waiting any more`}),AH(`cancel`,`call it off`,{danger:!0,disabledReason:m?`it is not waiting any more`:jH(r,`calling it off`)}));else if(o===`schedule`)D.push(AH(`runNow`,`run it now`,{primary:!0,disabledReason:h?`it is firing`:jH(r,`running it`),..._}),AH(`toggle`,e.nextAt==null?`switch it on`:`switch it off`,{disabledReason:p??jH(r,`the switch`)}),AH(`edit`,`edit the schedule`,{disabledReason:jH(r,`an edit`)}),AH(`cancel`,`delete it`,{danger:!0,disabledReason:jH(r,`deleting it`)}));else if(o===`fanout`){let e=n?.targets.find(e=>e.sessionId);D.push(AH(`open`,`open a session from it`,{primary:!0,disabledReason:e?void 0:`no session was opened by this sweep`}),AH(`sendNow`,`send a follow-up to these sessions`,{disabledReason:e?jH(r,`a follow-up`):`no session is left to drive`}))}else o===`build`||o===`capture`?D.push(AH(`download`,E.length===1?`download what it made`:`download (${E.length})`,{primary:E.length>0,disabledReason:E.length?void 0:`it produced no file to fetch`}),AH(`cancel`,`stop it`,{danger:!0,disabledReason:h?jH(r,`stopping it`):`it is not running`}),AH(`runNow`,`run it again`,{disabledReason:jH(r,`a run`)})):D.push(AH(`sendNow`,`run it now`,{primary:e.state===`queued`||e.state===`blocked`,disabledReason:h?`it is running`:e.state===`done`?`it already ran`:jH(r,`running it`),..._}),AH(`check`,`check whether it is already done`,{primary:e.state===`failed`,disabledReason:jH(r,`a check`)}),AH(`edit`,`rewrite it`,{disabledReason:h?`it is running — rewriting it now would change work already in flight`:jH(r,`an edit`)}),AH(`retarget`,`aim it at another session`,{disabledReason:h?`it is running`:jH(r,`a re-aim`)}),AH(`toggle`,e.pinned?`stop firing it on its own`:`fire it on its own`,{disabledReason:m?`it has already run`:jH(r,`the switch`)}),AH(`discard`,`remove it`,{danger:!0,alwaysShown:!0,disabledReason:jH(r,`removing it`)}));e.sessionId&&D.push(AH(`open`,`open the session`,{alwaysShown:!0,disabledReason:f?void 0:`that session is not open any more`}));let O=BH(e,o,i,n),k=!!e.result?.detail&&O.includes(e.result.detail);return{key:EH(e.id),id:e.id,source:s,kind:IH[o],state:e.state,bucket:mU(e.state,c),blockReason:c,verdict:O,...d,fullText:l,attachText:o===`build`?null:l,where:S,cwd:e.cwd||null,sessionId:e.sessionId??null,delivery:null,at:e.settledAt??e.startedAt??e.createdAt,createdAt:e.createdAt,dueAt:e.trigger.kind===`at`?e.nextAt??null:e.trigger.kind===`files`&&e.state===`blocked`?e.trigger.deadlineAt:null,asOf:r?null:t.hostSeenAt,progress:C?.length?{done:C.length-(e.missing?.length??0),total:C.length,label:`files`}:n?{done:n.targets.filter(e=>e.status===`done`).length,total:n.targets.length,label:`repos`}:null,targets:n?n.targets.map(e=>({label:e.title||MH(e.dir),sessionId:e.sessionId,state:gU[e.status]??`queued`,detail:e.error})):[],lastRun:T?{at:T.at,ok:!0,detail:`follow-up sent to ${T.dirs.length} of them`}:e.result&&!(k&&m&&!e.result.late)?{at:e.result.at,ok:e.result.ok,detail:k?``:e.result.detail,late:e.result.late}:null,attempts:e.attempts??0,actions:D,subject:{source:`intent`,intent:e,run:n},...o===`build`?_U(e,t.intents??[]):{}}}var gU={pending:`queued`,starting:`starting`,running:`running`,done:`done`,failed:`failed`};function _U(e,t){let n=rR(e,t);return n?{fromSchedule:n}:{}}function vU(e,t){let n=e.state===`downloading`?`running`:e.state===`done`?`done`:e.state===`failed`?`failed`:e.state===`paused`?`blocked`:`queued`,r=e.item.size?Math.floor(e.received/e.item.size*100):0,i=e.rate?`${yU(Math.round(e.rate))}/s`:null,a=`downloaded${e.item.size?` · ${yU(e.item.size)}`:``}`,o=n===`running`?`${r}% — ${i??`waiting for bytes`}`:n===`failed`?e.error||`the transfer stopped and nothing said why`:n===`blocked`?`paused — it resumes from where it stopped`:n===`done`?e.savedTo?`${a} · ${e.saveVia===`browser`?`handed to`:`saved to`} ${e.savedTo}`:e.evicted?`${a} — the bytes were cleared to make room; fetching again is one tap`:`${a} · on this phone`:r>0?`queued — ${r}% already here from an earlier attempt`:`queued`;return{key:`pull:${e.item.id}`,id:e.item.id,source:`pull`,kind:`download`,state:n,bucket:mU(n,null),blockReason:null,verdict:o,title:e.item.name,clipped:!1,fullText:null,attachText:null,where:e.item.repoName||t.deps.repoName(e.item.repoDir),cwd:e.item.repoDir,sessionId:null,delivery:null,at:e.updatedAt,createdAt:e.item.ts,dueAt:e.nextRetryAt??null,asOf:null,progress:n===`running`||n===`blocked`?{done:e.received,total:e.item.size,label:`bytes`}:null,targets:[],lastRun:null,attempts:e.attempts,actions:[AH(`save`,`save to phone`,{primary:n===`done`&&!e.evicted,disabledReason:n===`done`&&!e.evicted?void 0:`there is nothing downloaded to save yet`}),AH(`retry`,n===`failed`?`try again`:`fetch it now`,{primary:n!==`done`,disabledReason:n===`running`?`it is downloading`:n===`done`&&!e.evicted?`it is already on this phone — save it out instead`:void 0}),AH(`discard`,`drop it`,{danger:!0,alwaysShown:!0})],subject:{source:`pull`,record:e}}}var yU=e=>e>=1e9?`${(e/1e9).toFixed(1)} GB`:e>=1e6?`${(e/1e6).toFixed(1)} MB`:e>=1e3?`${Math.round(e/1e3)} kB`:`${e} B`,bU=15e4,xU=new Set([`unconfirmed`]);function SU(e,t){return e.status!==`failed`||e.hostSettled||!e.failState||!xU.has(e.failState)?!1:t-(e.failedAt??e.sentAt??e.ts)<bU}function CU(e){return e===1?`1 message typed — confirming it ran; types it again itself if not`:`${e} messages typed — confirming they ran; types one again itself if not`}var wU=`the desktop is still confirming this one — it may be running, and it re-sends it itself if it never landed`;function TU(e){return e.status===`failed`&&(!e.failState||e.failState===`other`)}function EU(e){return e.status===`failed`&&(e.failState===`unconfirmed`||e.failState===`unsubmitted`)}function DU(e,t){return e.status===`pending`?`sending`:e.status===`queued`?e.retryAt!=null&&e.retryAt>t?`retrying`:`waiting`:SU(e,t)?`confirming`:TU(e)?`failed-retryable`:EU(e)?`failed-unknown`:`failed-final`}function OU(e){return e===`failed-retryable`||e===`failed-unknown`||e===`failed-final`}var kU={waiting:`waiting`,retrying:`retrying`,sending:`sending`,confirming:`confirming it ran`,"failed-retryable":`not delivered`,"failed-unknown":`may be in that session`,"failed-final":`refused`},AU={waiting:``,retrying:``,sending:`already on its way`,confirming:`the desktop is still confirming this one — it may be running`,"failed-retryable":`it didn't go through — try it again first`,"failed-unknown":`it may already be in that session — open it and look, or rewrite it`,"failed-final":`the desktop refused it — rewrite it to send it as a new one`};function jU(e,t,n){return e===`unconfirmed`?`Typed — the desktop is confirming it ran. It re-sends it itself if it never landed.`:e===`unsubmitted`?`Typed, but it is still sitting in that session's box — open it and press Return. The desktop won't send it again.`:n?`Not sent — ${t}. Your words are kept; the row is below.`:`Not sent — ${t}. Your words are kept below — restore or re-aim them.`}function MU(e,t){let n=null;for(let r of e){if(!SU(r,t))continue;let e=(r.failedAt??r.sentAt??r.ts)+bU-t;(n==null||e<n)&&(n=e)}return n}function NU(e,t,n){let r=[];return e>0&&r.push(e>1?`${e} were typed and the desktop is still confirming that they ran — it types them again itself if not.`:`1 was typed and the desktop is still confirming that it ran — it types it again itself if not.`),t>0&&r.push(t>1?`${t} may already be in their sessions — open each and look, or rewrite them to send fresh copies.`:`1 may already be in its session — open it and look, or rewrite it to send a fresh copy.`),n>0&&r.push(n>1?`The desktop refused ${n} — rewrite them to send as new ones.`:`The desktop refused 1 — rewrite it to send as a new one.`),r}function PU(e){return e.status===`failed`&&e.failState===`unconfirmed`}function FU(e,t){let n=e.prompt?.kind===`trust`?fle(t??null,e.backend):void 0;return{turnActive:e.turnActive,limitBlocked:e.limit?.blocked,promptKind:e.prompt?.kind,awaitingInput:e.awaitingInput,block:fte(e),...n===!1?{trustAutoAccepted:!1}:{}}}var IU=(e,t)=>e.map(e=>({id:e.id,cwd:e.cwd,running:e.running,turnStartedAt:e.turnStartedAt,...FU(e,t),name:Yn(e)}));function LU(e,t,n){return ne(e?de(IU(t,n),[]).get(e):void 0)}var RU={gate:`gate`,budget:`budget`,sessionBudget:`sessionBudget`,sessionGone:`sessionGone`,serial:`serial`,held:`sessionBusy`,lane:`sessionBusy`,inflight:`sessionBusy`,pendingCreate:`sessionBusy`,backoff:null},zU={held:`held until the agent finishes this turn`,lane:`another message for that session is going out first`,inflight:`a delivery for that session is already in flight`,pendingCreate:`waiting for its session to open`},BU={unconfirmed:`unconfirmed`,unsubmitted:`unsubmitted`,stale:`refused`,refused:`refused`,other:`unknown`},VU=e=>e?BU[e]:`unknown`,HU={unconfirmed:`it was typed into the session and the desktop could not read the screen back — it may have run. Sending it again could run it twice: open the session and look, or rewrite it to send a fresh copy.`,unsubmitted:`the words are already sitting in that session's composer — open it and press Return. Sending again would leave two copies.`,stale:`the desktop refused this one because the question it answers is gone, and it remembers refusing it — a re-send is answered with the same no. Answer the question that is up now.`,refused:`the desktop answered no and remembers it, so this exact message can only be refused again — rewrite it to send it as a new one.`,other:void 0};function UU(e,t){return e.answer?`answer`:e.mode===`upload`?`upload`:e.mode===`op`?t.isCreateOp(e)?`prompt`:`action`:`prompt`}function WU(e,t){let{deps:n,now:r,online:i}=t,a=UU(e,n),o=t.queueBlocked?.get(e.ackId),s=(e.mode??`input`)===`input`&&!!t.goneLanes?.has(e.sessionId),c=DU(e,r),l=c===`sending`?`starting`:OU(c)?`failed`:`queued`,u=null,d,f=c===`confirming`;if(f&&(l=`running`,d=`the desktop is confirming whether it ran — it types it again itself if it never did`),e.status===`queued`){if(!i)u=`offline`;else if(s)u=`sessionGone`;else if(o){if(u=RU[o],d=zU[o],o===`serial`&&t.sessions&&(d=LU(e.serial,t.sessions)),o===`backoff`){let t=e.retryAt&&e.retryAt>r?e.retryAt-r:null,n=t==null?null:t<6e4?`${Math.max(1,Math.round(t/1e3))}s`:`${Math.round(t/6e4)} min`,i=e.waitReason??`a send just failed`;d=n?`${i} — trying again in ${n}`:`${i} — trying again in a moment`}if(o===`held`){let n=t.sessions?.find(t=>t.id===e.sessionId),r=n?jt({...FU(n),turnActive:void 0}):null;r===`limit`||r===`auth`||r===`net`?(u=r,d=void 0):(n?.awaitingInput||n?.prompt&&n.prompt.kind!==`trust`)&&(u=`awaitingAnswer`,d=n.prompt?`the session is waiting on a question — “${(n.prompt.ask||n.prompt.question).slice(0,80)}”`:`the session is showing a dialog it wants an answer to`)}}(u||d)&&(l=`blocked`)}let p=e.failedAt??e.sentAt??e.ts,m=l===`failed`?PH(e.reason,p,r,`it never went — nothing here says why, so treat it as unrun only if the session shows nothing`):l===`starting`?`on its way to the desktop`:u?dr(u,d):d??`next in line`,h=n.isEditableEntry(e)||e.status===`failed`&&a===`prompt`,g=e.mode===`upload`||e.mode===`op`||!!e.answer,_=e.status===`pending`,v=kH(e),y=a===`upload`?e.upload?.relPath??null:a===`answer`?null:v||null,b=u===`awaitingAnswer`,x=e.status===`failed`?f?wU:e.failState?HU[e.failState]:void 0:void 0,S=[...b?[AH(`answer`,`answer the question`,{primary:!0})]:[],AH(`sendNow`,e.status===`failed`?`try again`:`send now`,{primary:!b,disabledReason:_?`already on its way`:x??(!i&&e.status!==`failed`?`no connection yet — it goes out when the link is back`:void 0)}),AH(`hold`,e.holdUntilIdle?`send without waiting`:`wait for the agent`,{disabledReason:_?`already on its way`:g?`this one is an action or a file, not text — there is no turn to wait for`:void 0}),AH(`retarget`,`aim it elsewhere`,{disabledReason:_?`already on its way`:e.answer?`an answer names one question box in one session — it cannot go anywhere else`:e.mode===`upload`?`a file goes to the repo inbox its path names`:e.mode===`op`?`this one is an action — its payload already names its own subject`:void 0}),AH(`edit`,`rewrite it`,{primary:!!x,disabledReason:h?void 0:_?`already on its way`:e.answer?`an answer is the option you tapped, not text`:e.mode===`upload`?`a file has no words to rewrite`:`this one is an action, not text`}),AH(`fix`,`fix its files & send`,{disabledReason:e.answer||e.mode===`upload`?`there are no words on this row to rewrite`:void 0}),...PU(e)?[AH(`confirmDone`,`save as done`,{disabledReason:f?wU:_?`already on its way`:void 0})]:[],AH(`discard`,`discard`,{danger:!0,alwaysShown:!0,disabledReason:_?`already on its way`:void 0})];e.sessionId&&!e.sessionId.startsWith(`create:`)&&S.push(AH(`open`,`open the session`,{alwaysShown:!0,disabledReason:s?`that session is gone`:void 0}));let C=wH(a===`answer`&&e.answer?`${e.answer.label} — ${e.answer.question}`:v);return{key:TH(e.ackId),id:e.ackId,source:`queue`,kind:a,state:l,bucket:mU(l,u),blockReason:u,verdict:m,...C,fullText:a===`upload`||a===`answer`?null:v,attachText:y,where:n.laneLabel(e),cwd:e.cwd||null,sessionId:e.sessionId.startsWith(`create:`)?null:e.sessionId,delivery:e.status===`failed`?VU(e.failState):null,at:p,createdAt:e.ts,dueAt:null,asOf:null,progress:null,targets:[],lastRun:null,attempts:e.attempts??0,actions:S,subject:{source:`queue`,entry:e}}}var GU={needsYou:0,failed:1,running:2,waiting:3,scheduled:4,done:5},KU=new Map(Xee.map((e,t)=>[e,t]));function qU(e,t){let n=GU[e.bucket]-GU[t.bucket];if(n)return n;if(e.bucket===`scheduled`){let n=e.dueAt??2**53-1,r=t.dueAt??2**53-1;if(n!==r)return n-r}if(e.bucket===`waiting`||e.bucket===`needsYou`){let n=e.blockReason?KU.get(e.blockReason)??99:99,r=t.blockReason?KU.get(t.blockReason)??99:99;if(n!==r)return n-r}return t.at-e.at}function JU(e){let t=[];for(let n of e.outbox??[])t.push(WU(n,e));let n=e.intents??[],r=new Map;for(let e of Fr(n))r.set(e.id,e);let i=new Set((e.outbox??[]).map(e=>e.ackId));for(let a of n){if(a.archived||a.groupId!=null&&a.groupId!==a.id)continue;let n=a.groupId?r.get(a.groupId)??null:null;if(i.has(a.id)&&(a.state===`queued`||a.state===`blocked`||a.state===`starting`)){let e=t.findIndex(e=>e.subject.source===`queue`&&e.id===a.id);e>=0&&t.splice(e,1)}t.push(hU(a,e,n))}for(let n of e.pulls??[])t.push(vU(n,e));let a=e.dismissed;if(a?.size)for(let e of t){let t=a.get(e.key);t!=null&&(e.dismissedAt=t)}let o=e.confirmedDone;if(o?.size)for(let e of t){let t=o.get(e.key);t!=null&&(e.confirmedDoneAt=t,e.bucket=`done`,e.state=`done`,e.blockReason=null,e.verdict=`you marked this done ${new Date(t).toLocaleString()} — the desktop's own check never confirmed it`)}for(let e of t)e.actions.push(AH(`dismiss`,`save for later`,{disabledReason:lU(e)??void 0}));return t.sort(qU)}var YU=new Set([`needsYou`,`failed`,`running`,`waiting`]),XU=[{id:`open`,label:`open`},{id:`all`,label:`all`},{id:`needsYou`,label:`needs you`},{id:`failed`,label:`failed`},{id:`running`,label:`running`},{id:`waiting`,label:`waiting`},{id:`scheduled`,label:`scheduled`},{id:`done`,label:`done`},{id:`dismissed`,label:`dismissed`}];function ZU(e,t){return t===`dismissed`?e.dismissedAt!=null:e.dismissedAt==null?t===`open`?YU.has(e.bucket):t===`all`||e.bucket===t:!1}function QU(e){let t={open:0,all:0,needsYou:0,failed:0,running:0,waiting:0,scheduled:0,done:0,dismissed:0};for(let n of e)n.dismissedAt==null?(t.all+=1,t[n.bucket]+=1,YU.has(n.bucket)&&(t.open+=1)):t.dismissed+=1;return t}function $U(e,t){let n=e.filter(e=>e.dismissedAt==null);if(!t){let e=n.filter(e=>e.blockReason===`offline`).length;if(e)return{text:`${e} ${e===1?`thing is`:`things are`} still on this phone — nothing expires while the link is down`,cut:null}}let r=n.filter(e=>e.bucket===`needsYou`).length;if(r)return{text:`${r} ${r===1?`row needs`:`rows need`} a decision from you`,cut:`needsYou`};let i=n.filter(e=>e.bucket===`failed`).length;return i?{text:`${i} ${i===1?`thing`:`things`} never ran`,cut:`failed`}:null}function eW(e){if(e.kind===`upload`||e.kind===`download`||e.kind===`build`)return null;let t=(e.fullText??e.title).trim();if(!t)return null;let n=t.toLowerCase().replace(/\s+/g,` `).trim();return n.replace(/[.!?…]+$/u,``).trim()||n}var tW=new Set(`continue.continue please.please continue.go on.carry on.keep going.done.finished.did it work.any progress.progress.status.update.try again.again.retry.redo.rerun.run it again.ok.okay.k.yes.yep.yeah.sure.no.nope.n.y.thanks.thank you.ty.hi.hello.test.ping.hmm.next.next step.proceed.go.go ahead.stop.wait.fix.fix it.fix this.do it.continue working.and`.split(`.`));function nW(e){let t=eW(e);return!t||e.clipped||/[\n`/.]/.test(t.slice(1))?!1:tW.has(t)||/^\/[a-z][\w-]*$/.test(t)?!0:t.split(` `).length===1&&t.length<=3}function rW(e,t){return t===`ranked`?[...e]:[...e].sort((e,t)=>e.at-t.at)}function iW(e,t,n){let r=new Map;for(let e of t){let t=eW(e);if(!t)continue;let n=r.get(t);n?n.push(e):r.set(t,[e])}let i=[],a=new Map;for(let t of e){let e=eW(t),r=n.group&&e?`t:${e}`:t.key,o=a.get(r);if(o){o.rows.push(t),o.oldestAt=Math.min(o.oldestAt,t.at),o.newestAt=Math.max(o.newestAt,t.at),t.cwd&&!o.cwds.includes(t.cwd)&&o.cwds.push(t.cwd);continue}let s={key:r,rows:[t],elsewhere:{done:0,other:0},cwds:t.cwd?[t.cwd]:[],oldestAt:t.at,newestAt:t.at};a.set(r,s),i.push(s)}for(let e of i){let t=eW(e.rows[0]);if(!t)continue;let n=new Set(e.rows.map(e=>e.key));for(let i of r.get(t)??[])n.has(i.key)||(i.dismissedAt??(i.bucket===`done`?e.elsewhere.done+=1:e.elsewhere.other+=1))}return i}var aW=e=>e.status===`failed`&&!e.calledOff,oW=e=>e.calledOff?`done`:e.status,sW=e=>e.calledOff===`agent`?`withdrawn`:e.calledOff?`called off`:e.status,cW=e=>e.calledOff?`calledoff`:e.status,lW=e=>e.status===`done`||e.status===`failed`&&e.calledOff!==`agent`,uW=36e5,dW=[`hour`,`day`,`week`,`older`],fW={hour:`past hour`,day:`past 24h`,week:`past week`,older:`older`},pW=[`running`,`queued`,`failed`,`done`];function mW(e,t){let n=Math.max(0,t-e);return n<=uW?`hour`:n<=24*uW?`day`:n<=168*uW?`week`:`older`}function hW(e,t,n){let r=mW(e,n);if(t===`older`)return r===`older`;let i={hour:0,day:1,week:2,older:3};return i[r]<=i[t]}var gW=[...Xa,`none`];function _W(e){return e.category??`none`}var vW={bug:Me(`bug`),feature:Me(`feature`),enhancement:Me(`enhancement`),chore:Me(`chore`),none:S};function yW(e,t){return t?`show every kind again`:e===`none`?`show only the items nothing has said a kind for — the rows a naming pass is for`:`show only the ${e===`bug`?`bugs`:`${e}s`}`}var bW=`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`,xW=`no connection — the desktop is holding this one. It stays held; try again when the link is back.`,SW={status:null,age:null,category:null,ids:null,clock:null},CW=e=>!!(e.status||e.age||e.category||e.ids||e.clock);function wW(e,t,n){return!(t.ids&&!t.ids.includes(e.id)||t.status&&oW(e)!==t.status||t.age&&!hW(e.createdAt,t.age,n)||t.category&&_W(e)!==t.category||t.clock&&!e.at)}function TW(e,t){let n=[];if(e.status&&n.push(e.status),e.category&&n.push(e.category===`none`?`with no kind`:`${e.category===`bug`?`bug`:e.category}s`),e.clock&&n.push(`on a clock`),e.age&&n.push(e.age===`older`?`added over a week ago`:`added in the ${fW[e.age]}`),e.ids){let e=t?.trim()||`made from these`;return n.length?`${e} · ${n.join(` · `)}`:e}return n.length?`showing ${n.join(` · `)}`:`showing everything`}function EW(e){return!!e.archived&&e.status!==`running`}var DW={newest:`newest first`,run:`run order`},OW=`the number is each row's place in the run order — switch to run order to move rows`,kW=`the on-a-clock cut is always in run order`;function AW(e,t){return t?`run`:e}function jW(e,t){return t===`run`?e:[...e].sort((e,t)=>t.createdAt-e.createdAt)}function MW(e){return new Map(e.map((e,t)=>[e.id,t+1]))}function NW(e,t,n){let r={running:0,queued:0,failed:0,done:0},i={hour:0,day:0,week:0,older:0},a={bug:0,feature:0,enhancement:0,chore:0,none:0},o=0,s={status:0,age:0,category:0,clock:0};for(let c of e){if(t.ids&&!t.ids.includes(c.id))continue;let e=oW(c),l=!t.status||e===t.status,u=!t.age||hW(c.createdAt,t.age,n),d=!t.category||_W(c)===t.category,f=!t.clock||!!c.at;if(u&&d&&f&&(r[e]=(r[e]??0)+1,s.status++),l&&d&&f){s.age++;for(let e of dW)hW(c.createdAt,e,n)&&i[e]++}l&&u&&f&&(a[_W(c)]++,s.category++),l&&u&&d&&(s.clock++,c.at&&o++)}return{status:r,age:i,category:a,clock:o,pool:s}}function PW(e,t){let n=(e,t,n,r=!1)=>n||e>0&&(r||e<t);return{status:pW.filter(r=>n(e.status[r],e.pool.status,t.status===r,r===`failed`||r===`done`)),age:dW.filter(r=>n(e.age[r],e.pool.age,t.age===r)),category:gW.filter(r=>n(e.category[r],e.pool.category,t.category===r)),clock:n(e.clock,e.pool.clock,!!t.clock,!0)}}function FW(e,t){let n=e.fresh+e.aimed;if(n<=0)return null;let r=e.held+e.other,i=r?` The other ${r} here ${r===1?`is`:`are`} not going to start — each row says why.`:``;if(!t)return`auto is off on this desktop, so ${n===1?`this one does not start on its own`:`none of these ${n} start on their own`}. Turn auto back on, or ${n===1?`tap fire on the row to start it now`:`tap fire on a row to start that one now`}.${i}`;let a=n===1?` fire on the row starts it now.`:` fire on a row starts that one now.`,o=e.aimed===0&&n>1?`, in the order you see`:``,s;if(e.aimed===0)s=e.fresh===1?`this one starts when the repo is free, in a session of its own`:`these ${e.fresh} start one at a time in this repo, each in a session of its own${o}`;else if(e.fresh===0)s=e.aimed===1?`this one starts in the session it is aimed at, as soon as that session is free`:`these ${e.aimed} start in their sessions, each as soon as its session is free`;else{let t=e.aimed===1?`1 in the session it is aimed at`:`${e.aimed} in their sessions`;s=`of these ${n}, ${e.fresh} start in a session of their own and ${t}, each as soon as what it waits for is free`}return`auto is on: ${s}.${a}${i}`}function IW(e,t,n){return`${e} of ${t}${n.ids?`, archived included`:``}`}function LW(e){return`archive ${e===1?`this one`:`these ${e}`}`}function RW(e,t){return`${e===t?`every one of the ${t} rows here is finished`:`${e===1?`one row`:`${e} rows`} of the ${t} shown ${e===1?`is`:`are`} finished and not yet archived — the rest are already archived and are left alone`}. Archiving is not deleting: the words stay, the archived count keeps them, and any one of them can be brought back from its own row.`}function zW(e){return e===1?`archived — its words stay, and show archived still lists it`:`${e} archived — their words stay, and show archived still lists them`}function BW(e){return`assess ${e===1?`this one`:`these ${e}`}`}function VW(e,t){return`${e===t?`every one of the ${t} rows here is still open`:`${e===1?`one row`:`${e} rows`} of the ${t} shown ${e===1?`is`:`are`} still open — the rest are finished or running and cannot be judged`}. It still reads the whole repo as evidence — what narrows is which rows it may return a verdict on.`}var HW=`assess: nothing in this cut is still open — an assessment judges work that is waiting or failed, and these rows are finished or running`;function UW(e){return e.filter(e=>!e.archived&&(e.status===`queued`||aW(e))).map(e=>e.id)}function WW(e,t,n){let r=va(e.rule);return e.nextAt!=null&&n===`queued`?`${r} · next ${Dn(e.nextAt,t)}`:e.rule.kind===`window`&&n===`queued`?`${r} · waiting for a usage reading`:r}var GW=e=>e.at?tte(e.at.rule,e.at.graceMin,e.holdForHost):null;function KW(e){let t=[],n=new Map;for(let r of e){let e=r.calledOff?null:GW(r);if(!e)continue;let i=n.get(e);i||(i={key:e,at:r.at?.nextAt??null,hold:!!r.holdForHost,items:[]},n.set(e,i),t.push(i)),i.items.push(r)}return t}function qW(e,t){for(let n of e){let e=n.items.findIndex(e=>e.id===t);if(!(e<0))return n.items.length>1?{idx:e,of:n.items.length}:null}return null}var JW=[`1st`,`2nd`,`3rd`,`4th`,`5th`,`6th`,`7th`,`8th`,`9th`,`10th`],YW=e=>JW[e-1]??`${e}th`;function XW(e){return`${YW(e.idx+1)} of ${e.of} on this clock`}function ZW(e,t){let n=e.items.length,r=e.at==null?`waiting for a usage reading`:`${Dn(e.at,t)} · ${new Date(e.at).toLocaleString()}`,i=va(e.items[0].at.rule);return`${n} item${n===1?``:`s`} on one clock — ${i} · ${r}${e.hold?` · held until the desktop is free`:``}`}var QW=`moves it among the items waiting on this same clock — the instant does not change, and it never crosses an item on a different clock`;function $W(e){return`on a clock in ${e}`}function eG(e){return`been and gone on a clock in ${e}`}var tG=`holds until the desktop is free`;function nG(e){return e?`${tG} · survives a dropped clock`:tG}var rG=`let past the budget`;function iG(e){return e?`${rG} · undo`:rG}var aG=`held for the budget again`;function oG(e){return e===`failed`?`its instant has passed and a one-off cannot be re-armed — drop the clock and it waits its turn, where auto takes it from there`:`drop the clock and it runs in turn instead of at its time — the words and their place in the list stay`}var sG=`clock dropped — it waits its turn like any other item`;function cG(e){return e===1?sG:`clocks dropped on ${e} — they wait their turn like any other item`}function lG(e){return`drop the clocks on ${e===1?`this one`:`these ${e}`}`}function uG(e,t){return`${e===t?`every one of the ${t} rows here carries a clock`:`${e===1?`one row`:`${e} rows`} of the ${t} shown carr${e===1?`ies`:`y`} a clock — the rest have none and are left alone`}. Dropping a clock leaves the words where they are: they wait their turn, auto takes it from there, and any that hold until the desktop is free keep doing so.`}function dG(e){let t=`it failed, so nothing will pick it up again — put it back in the queue and it runs again `,n=` The failure it had stays on the row. “re-fire” beside it runs it this second instead.`;return e.targetSessionId?`${t}in the session it is aimed at, as soon as that session is free — auto takes it from there. It does not open a session of its own.${n}`:`${t}in a new session of its own when its turn comes, where auto takes it from there.${n}`}function fG(){return`it failed, and it is aimed at a session that has closed — nothing re-aims it, so putting it back in the queue would only make it wait for ever instead of stopping. Edit it to pick another session, or take the aim off so it opens a session of its own, and “run it again” comes back.`}var pG=`put back in the queue — it runs again when its turn comes`;function mG(e){return e===1?pG:`${e} put back in the queue — they run again as their turns come`}function hG(e,t){return e.status!==`failed`||e.calledOff||e.at||e.archived?`none`:e.targetSessionId&&!t.has(e.targetSessionId)?`held-closed`:`offered`}function gG(e,t){return hG(e,t)===`offered`}function _G(e,t){return e.filter(e=>gG(e,t)).map(e=>e.id)}function vG(e,t){return e.filter(e=>gG(e,t)&&!!e.targetSessionId).length}function yG(e){return`run ${e===1?`this one`:`these ${e}`} again`}function bG(e,t,n=0){return`${e===t?`every one of the ${t} rows here can go back in the queue`:`${e===1?`one row`:`${e} rows`} of the ${t} shown can go back in the queue — the rest carry a clock (they wear “drop the clock”), are aimed at a session that closed, or are set aside, and are left alone`}. ${n===0?`They run again one at a time in this repo, each in a session of its own, as their turns come — auto takes it from there`:n===e?`They run again in the session${e===1?``:`s`} they are aimed at, as ${e===1?`it comes`:`those come`} free — auto takes ${e===1?`it`:`them`} from there`:`${e-n} run again in a session of its own, one at a time in this repo, and ${n} in the session${n===1?``:`s`} ${n===1?`it names`:`they name`}, as those come free — auto takes them from there`}, and the failure each one had stays on its row.`}function xG(e,t,n){let r=SG(n-e.at),i=e.by===`run`?`started again ${r}`:`put back in the queue ${e.by===`assess`?`by the assessment`:`from the phone`} ${r}`,a=e.n!=null&&e.n>1?` (${CG(e.n)} time)`:``,o=e.error?` · failed before: “${e.error}”`:``;return t===`failed`?`failed again — it was ${i}${a}${o}`:t===`done`?`ran after being ${i}${a}${o}`:`${i}${a}${o}`}function SG(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s ago`;let n=Math.round(t/60);if(n<60)return`${n}m ago`;let r=Math.round(n/60);if(r<24)return`${r}h ago`;let i=Math.round(r/24);return i<60?`${i}d ago`:`${Math.round(i/30)}mo ago`}function CG(e){let t=e%100;return t>=11&&t<=13?`${e}th`:`${e}${[`th`,`st`,`nd`,`rd`][e%10]??`th`}`}var wG={hand:`you typed this title`,assess:`titled by the assessment`,name:`titled by the naming pass`};function TG(e){return e===`hand`?`this title is yours — the assessment and the naming pass will not change it. Clear the field to let them suggest one again.`:`saving makes it yours — the assessment and the naming pass will not change it again. Clear the field to let them suggest one again.`}function EG(e){return`name ${e===1?`this one`:`these ${e}`}`}function DG(e){return e.filter(e=>!e.archived&&(e.status===`queued`||e.status===`failed`&&!e.calledOff)&&(zn(e)===null||!e.category)).map(e=>e.id)}function OG(e,t){return`${e===t?`all ${t} rows here need a title or a kind`:`${e} of the ${t} shown need a title or a kind — the rest have both, or are running, finished or set aside`}. Nothing you typed is replaced.`}function kG(e){return`asked the desktop to ${e} — the titles land on the rows as the pass answers, and anything you typed yourself is left alone`}function AG(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function jG(e){return Ar(e.label,e.text,40)}var MG=`A new session (default)`,NG=`→ the session it was aimed at (closed)`;function PG(e,t){let n=[{value:``,label:MG}];for(let t of e)n.push({value:t.id,label:`→ ${Li(t)}`});return t&&!e.some(e=>e.id===t)&&n.push({value:t,label:NG}),n}function FG(e,t,n=[]){let r=e.status===`queued`&&e.holderSessionId?t.find(t=>t.id===e.holderSessionId&&t.running):void 0;if(!r)return null;let i=n.find(e=>e.sessionId===r.id&&ur({state:e.status,sessionId:e.sessionId},[r]));if(i)return{sessionId:r.id,itemId:i.id,cut:`the stalled item this row waits behind`,label:`show the stalled item`,title:`this row waits behind an item stalled on the API — it starts once that one gets a reply or you settle it`};let a=Yn(r)??`the session`,o=a.length>32?`${a.slice(0,31)}…`:a;return r.awaitingInput||r.asking||r.prompt&&r.prompt.kind!==`trust`?{sessionId:r.id,label:`answer in '${o}'`,title:`this row waits until that question is answered — open the session to answer it`}:{sessionId:r.id,label:`open '${o}'`,title:`the automatic session this row waits behind — it starts when that one is idle`}}function IG(e){return e.archived||e.status===`running`||e.status===`done`?!1:e.status!==`failed`||!!e.at&&!e.calledOff}function LG(e,t,n){let r=`${e} of ${t} picked`,i=n-t;return`${r}${i>0?` · ${i} ${i===1?`has`:`have`} no box: running, finished, archived, or failed with no clock to move`:``}. A new when replaces each one's — the words, where it goes and the place in the list stay.`}var RG=`tick the rows to move — the button appears with the count`;function zG(e,t){return e===1?`re-timed — the same row, now ${t}`:`re-timed ${e} — the same rows, now ${t}`}function BG(e,t,n,r){let i=e===1?`re-timed — now ${t}`:`re-timed ${e} — now ${t}`,a=n.length===1?` on ${n[0]}`:n.length>1?` on each repo's row`:``;return`${i}${`. Off the clock list: ${e===1?`it waits`:`they wait`} in the queue, ⌛${a}`}${r?` — held by the budget until ${r}`:``}.`}function VG(e){return e===1?`No clock: it leaves the ${fM.automation} clock list and waits in its repo's queue — the ⌛ chip on the repo's row.`:`No clock: these leave the ${fM.automation} clock list and wait in their repo's queue — the ⌛ chip on the repo's row.`}function HG(e,t){return t<=0?``:t>=e?` · budget`:` · ${t} budget`}function UG(e,t){let n=new Set(t.map(e=>e.id)),r=[];for(let t of e){let e=t.items.filter(e=>n.has(e.id)).map(e=>e.id);e.length<2||!t.items[0].at||r.push({key:t.key,rule:va(t.items[0].at.rule),ids:e})}return r}function dve(e){return`re-time the ${e.ids.length} on “${e.rule}”`}function fve(e){let t={waiting:[],failed:[]};for(let n of e)EW(n)||(n.status===`queued`||n.status===`running`?t.waiting.push(n.id):aW(n)&&t.failed.push(n.id));return t}function pve(e){return e.failed.length?e.waiting.length?`waiting, running or failed`:`failed`:`waiting or running`}function mve(e){let t=[];return e.waiting.length&&t.push(`${e.waiting.length} waiting or running`),e.failed.length&&t.push(`${e.failed.length} failed`),t.length?t.join(`, `):`nothing waiting`}function WG({picked:e,eligible:t,shown:n,onAll:r,onNone:i,onDone:a,onChoose:o,where:s}){return(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Z,{children:[LG(e,t,n),(0,J.jsxs)(`div`,{className:`annot-tools wrap`,style:{marginTop:6},children:[e>0?(0,J.jsxs)(Y,{title:`choose the new when — a time, a usage window, a condition, a repeat — for the ticked rows`,onClick:()=>{q(`action:${s}.retime.choose`),o()},children:[(0,J.jsx)(Ss,{size:14}),` `,e===1?`new when for it…`:`new when for these ${e}…`]}):(0,J.jsx)(`span`,{children:RG}),e<t&&(0,J.jsxs)(Y,{title:`tick every row on screen that can be re-timed`,onClick:r,children:[(0,J.jsx)(Do,{size:14}),` all `,t]}),e>0&&(0,J.jsxs)(Y,{title:`untick every row`,onClick:i,children:[(0,J.jsx)(Rc,{size:14}),` none`]}),(0,J.jsxs)(Y,{title:`close the pick list — nothing is changed`,onClick:a,children:[(0,J.jsx)(V,{size:14}),` done`]})]})]})})}function GG({children:e}){return(0,J.jsx)(`div`,{className:`retime-layer`,children:e})}function KG({on:e,onToggle:t}){return(0,J.jsx)(`button`,{className:`bl-pick`,"aria-pressed":e,"aria-label":e?`untick this row`:`tick this row to re-time it`,onClick:e=>{e.stopPropagation(),t()},children:e?(0,J.jsx)(Do,{size:18}):(0,J.jsx)(Rc,{size:18})})}function qG(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function hve({i:e,repoName:t,onOpen:n,pick:r}){let i=e.trigger.kind===`at`?e.trigger.rule:null,a=i&&e.nextAt&&!Da(i,e.nextAt)?fr(i,e.nextAt):null,o=t(e.cwd),s=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`sched-clock-name`,children:VH(e)}),(0,J.jsxs)(`span`,{className:`sched-clock-when`,children:[i?va(i):`on a clock`,e.nextAt?(0,J.jsxs)(J.Fragment,{children:[` · next `,Pe(e.nextAt)]}):null,a?(0,J.jsxs)(J.Fragment,{children:[` · held until `,Pe(a),`, when its hours open`]}):null,e.holdForHost?(0,J.jsx)(J.Fragment,{children:` · waits until free`}):null]}),(0,J.jsx)(`span`,{className:`sched-clock-state`,children:gve(e)}),e.state===`blocked`&&e.blockReason&&e.blockReason!==`notYet`&&e.blockDetail?(0,J.jsx)(`span`,{className:`sched-clock-why`,children:e.blockDetail}):null]});return r===void 0?n?(0,J.jsxs)(`button`,{className:`sched-clock`,title:`open it in ${o}'s backlog — it is waiting work that happens to carry a clock, and every verb it has is on its row there`,onClick:()=>{q(`action:schedule.clockrow`),n(e.cwd,[e.id],$W(o))},children:[s,(0,J.jsx)(Vl,{size:13,className:`sched-clock-go`})]}):(0,J.jsx)(`div`,{className:`sched-clock`,children:s}):r?(0,J.jsxs)(`div`,{className:`sched-clock sched-clock-pick`,role:`button`,onClick:r.toggle,children:[(0,J.jsx)(KG,{on:r.on,onToggle:r.toggle}),(0,J.jsx)(`div`,{className:`sched-clock sched-clock-inner`,children:s})]}):(0,J.jsx)(`div`,{className:`sched-clock`,children:s})}function gve(e){return e.state===`starting`||e.state===`running`?`running`:e.state===`blocked`?`waiting`:e.state}function _ve({p:e,repoName:t,online:n}){let r=e.entry,i=r.action.kind===`backlog`?t(r.action.repoDir):``;return(0,J.jsxs)(`div`,{className:`sched-clock`,children:[(0,J.jsx)(`span`,{className:`sched-clock-name`,children:Ar(r.name,Ka(r.action))??Ka(r.action)}),(0,J.jsxs)(`span`,{className:`sched-clock-when`,children:[va(r.rule),r.nextAt&&!e.failed?(0,J.jsxs)(J.Fragment,{children:[` · next `,Pe(r.nextAt)]}):null,i?(0,J.jsxs)(J.Fragment,{children:[` · `,i]}):null]}),(0,J.jsx)(`span`,{className:`sched-clock-state`,children:(0,J.jsx)(YR,{phase:yd({queued:!0,failed:!!e.failed,onHost:!1,online:n}),thing:`this one`})})]})}function vve({rows:e,pending:t,repoName:n,online:r,onOpen:i,renderRetime:a,counted:o=!0}){let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(()=>new Set),[d,f]=(0,H.useState)(!1);if(!e.length&&!t.length)return null;let p=r&&!!a,m=e.filter(GH),h=m.filter(e=>l.has(e.id)).map(e=>e.id),g=s&&p,_=()=>{c(!1),u(new Set)},v=[];for(let t of e){let e=v.find(([e])=>e===t.cwd);e?e[1].push(t):v.push([t.cwd,[t]])}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`sched-head`,children:[(0,J.jsx)(Ss,{size:13}),` On a clock`,o?(0,J.jsxs)(J.Fragment,{children:[` · `,e.length+t.length]}):null,(0,J.jsx)(`span`,{className:`sched-head-note`,children:`waiting in their backlogs — the row is there, this is the door`})]}),p&&!g&&m.length>0&&(0,J.jsx)(`div`,{className:`bl-bulk`,children:(0,J.jsxs)(`button`,{className:`link-btn`,title:`tick the lines you want — in any repo — and move them all to one new time`,onClick:()=>{q(`action:schedule.retime.pick`),c(!0)},children:[(0,J.jsx)(Cs,{size:14}),` `,`pick to re-time`]})}),g&&(0,J.jsx)(WG,{picked:h.length,eligible:m.length,shown:e.length,where:`schedule`,onAll:()=>u(new Set(m.map(e=>e.id))),onNone:()=>u(new Set),onDone:_,onChoose:()=>f(!0)}),d&&a&&h.length>0&&(0,J.jsx)(GG,{children:a(h,{onSent:()=>{f(!1),_()},onCancel:()=>f(!1)})}),t.length>0&&(0,J.jsx)(`div`,{className:`sched-clocks`,children:t.map(e=>(0,J.jsx)(_ve,{p:e,repoName:n,online:r},e.entry.id))}),v.map(([e,t])=>(0,J.jsxs)(`div`,{className:`sched-clocks`,children:[(0,J.jsxs)(`div`,{className:`sched-clocks-repo`,children:[n(e),` · `,t.length]}),t.map(e=>(0,J.jsx)(hve,{i:e,repoName:n,onOpen:i,pick:g?GH(e)?{on:l.has(e.id),toggle:()=>u(t=>qG(t,e.id))}:null:void 0},e.id))]},e))]})}function yve({goneByRepo:e,repoName:t,onOpen:n}){return!e.length||!n?null:(0,J.jsxs)(Z,{className:`sched-spent`,children:[(0,J.jsx)(kc,{size:13,style:{verticalAlign:`-2px`}}),` `,`On a clock, and been and gone — run or missed, the row says which:`,(0,J.jsx)(`div`,{className:`annot-tools`,style:{marginTop:6},children:e.map(([e,r])=>(0,J.jsxs)(Y,{title:`show the ${r.length} timed one-off${r.length===1?``:`s`} of ${t(e)} that have been and gone — they are rows in that backlog, with re-fire and “drop the clock” on them`,onClick:()=>{q(`action:schedule.clockspent`),n(e,r.map(e=>e.id),eG(t(e)))},children:[r.length,` in `,t(e)]},e))})]})}function bve({act:e,child:t,childSession:n,typed:r,repoName:i,onOpenSession:a,onOpenBacklog:o,onOpenBuildRun:s}){if(n&&a)return(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`schedule.session`,title:`Open the session this item ran in`,onClick:()=>{q(`action:schedule.session`),a(n)},children:[(0,J.jsx)(xo,{size:13}),` session`]});if(e.kind===`build`){if(!t||!s)return null;let n=iR(t),r=t.settledAt??t.startedAt;return(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`schedule.buildrun`,title:`Open the run this rule last started, in ${i(e.repoDir)}'s builds`,onClick:()=>{q(`action:schedule.buildrun`),s(e.repoDir,t.id)},children:[(0,J.jsx)(No,{size:13}),` last run · `,n,r&&n!==`running`&&n!==`waiting`?` ${Gp(r)}`:``]})}return e.kind!==`backlog`||!o?null:t?(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`schedule.backlogitems`,title:`Show the item this rule wrote, in ${i(e.repoDir)}'s backlog`,onClick:()=>{q(`action:schedule.backlog`),o(e.repoDir,[t.id],JL(r||e.text.slice(0,40)))},children:[(0,J.jsx)(Vl,{size:13}),` backlog · 1 item`]}):(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`schedule.backlogitems`,title:`Show ${i(e.repoDir)}'s backlog — this is the list each run of this rule writes into`,onClick:()=>{q(`action:schedule.backlog`),o(e.repoDir)},children:[(0,J.jsx)(Vl,{size:13}),` backlog`]})}function xve({query:e,setQuery:t,cutTotal:n,shownTotal:r}){let i=e.trim()!==``;return n<=1&&!i?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section quick-filter`,children:[(0,J.jsx)(Lc,{size:14,className:`quick-filter-icon`}),(0,J.jsx)(`input`,{type:`search`,value:e,placeholder:`search these schedules`,"aria-label":`search the schedules by their words or repo`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))}}),i&&(0,J.jsxs)(`span`,{className:`quick-filter-n`,children:[r,` of `,n]}),i&&(0,J.jsx)(`button`,{className:`head-act`,"aria-label":`clear the search`,title:`clear the search — every row of the cut again`,onClick:()=>t(``),children:(0,J.jsx)(V,{size:16})})]}),i&&r===0&&(0,J.jsxs)($,{children:[`Nothing here matches “`,e.trim(),`”.`]})]})}var JG=`no connection — it is armed on the desktop and can only be changed there`,YG=`no connection — it lives on the desktop and can only be deleted there`,XG=new Set([JG,YG]);function Sve(e){return e.state===`starting`||e.state===`running`?`running`:e.state===`blocked`?`waiting`:e.state===`queued`?`queued`:e.state}function Cve({repos:e,entries:t,onRemove:n,onSetEnabled:r,onRunNow:i,onSkipNext:a,onEdit:o,onClose:s,intents:c=[],sessions:l=[],onOpenSession:u,onOpenBacklog:d,onOpenBuildRun:f,renderRetime:p,online:m=!0,pending:h=[],listAt:g=0,focus:_=null,focusIds:v=null,onClearFocus:y,onOpenSpent:b,usage:x=null,foot:S}){let C=t=>{let n=e.find(e=>e.worktreePath===t);return n?Wn(n):t.split(`/`).pop()??t},[w,T]=(0,H.useState)(null),[E,D]=(0,H.useState)(``),O=E.trim()!==``,k=Date.now(),A=(0,H.useMemo)(()=>KH({intents:c,entries:t,pending:h,focus:_,focusIds:v,text:E,now:k}),[c,t,h,_,v,E,k]),j=(0,H.useMemo)(()=>new Map(A.pendingCards.map(e=>[e.entry.id,!!e.failed])),[A.pendingCards]),M=(0,H.useMemo)(()=>new Set(t.map(e=>e.id)),[t]),N=A.cards,P=A.spentCards,F=A.shownCards,I=(0,H.useMemo)(()=>F.filter(e=>Ia(e.rule)),[F]),ee=(0,H.useMemo)(()=>F.filter(e=>!Ia(e.rule)),[F]),te=A.shownTotal,ne=A.standingTotal,re=[I.length,ee.length,A.shown.length+A.shownPending.length].filter(e=>e>0).length===1,ie=e=>yd({queued:j.has(e.id),failed:j.get(e.id)===!0,onHost:M.has(e.id),online:m}),ae=[...F.map(ie),...A.shown.map(()=>`synced`),...A.shownPending.map(e=>yd({queued:!0,failed:!!e.failed,onHost:!1,online:m}))],oe=e=>{let t=e.action,s=j.has(e.id),p=j.get(e.id)===!0,h=ie(e),g=!Si(e,k),_=Ia(e.rule),v=_&&!e.enabled,y=v?ri(e.rule,k):null,b=Ar(e.name,Ka(t)),x=e.lastResult?.childId?c.find(t=>t.id===e.lastResult.childId):void 0,S=c.find(t=>t.id===e.id),E=S?.state===`blocked`&&S.blockReason&&S.blockReason!==`notYet`?S.blockDetail:void 0,D=x?.sessionId&&l.some(e=>e.id===x.sessionId&&e.running!==!1)?x.sessionId:null,O=e.nextAt&&!Da(e.rule,e.nextAt)?fr(e.rule,e.nextAt):null,A=t.kind===`backlog`&&t.steps&&t.steps.length>1?` · ${t.steps.length} turns`:``,M=t.kind===`fanout`?`fan-out · ${t.dirs.length} repo${t.dirs.length===1?``:`s`}`:t.kind===`build`?`build ${t.buildId} in ${C(t.repoDir)}`:t.autoFire===!1?`${C(t.repoDir)} · added to the backlog, not run${A}`:`a new session in ${C(t.repoDir)}${A}`,N=s||e.nextAt&&!e.running?null:e.running?(0,J.jsxs)(yE,{children:[(0,J.jsx)(Ml,{size:12,className:`spin`}),` running`]}):g?(0,J.jsx)(yE,{children:`been and gone`}):(0,J.jsx)(yE,{children:e.enabled?De.unarmed:v?`paused`:`off`}),P=xd(h,!0)!=null;return(0,J.jsxs)(`div`,{className:`q-card${e.running?` resuming`:``}`,children:[b&&(0,J.jsx)(`div`,{className:`sched-title`,children:b}),(P||N)&&(0,J.jsxs)(`div`,{className:`q-head`,children:[(0,J.jsx)(YR,{phase:h,thing:`this schedule`,saidAbove:!0}),N]}),(0,J.jsxs)(`div`,{className:`approve-hint`,children:[va(e.rule),` · `,M,e.waitUntilFree?(0,J.jsx)(J.Fragment,{children:` · waits until free`}):null,e.nextAt&&!p?(0,J.jsxs)(J.Fragment,{children:[` · next `,Pe(e.nextAt)]}):null,O&&!p?(0,J.jsxs)(J.Fragment,{children:[` · held until `,Pe(O),`, when its hours open`]}):null,y?(0,J.jsxs)(J.Fragment,{children:[` · would next run `,Pe(y),` once resumed`]}):null]}),g&&!s&&(0,J.jsx)(`div`,{className:`approve-hint`,children:`that instant has passed and a one-off cannot be re-armed — run it now, edit it, or post it again`}),!s&&E&&(0,J.jsx)(`div`,{className:`approve-hint`,children:E}),s&&(0,J.jsx)(`div`,{className:`approve-hint`,children:p?(0,J.jsx)(J.Fragment,{children:`the send gave up — this rule is on this phone and nowhere else, and it will not arm itself. Its words are kept; re-send it from the queue, or edit it here to replace the copy that failed.`}):(0,J.jsx)(J.Fragment,{children:`waiting for the link — it is armed on the desktop as soon as the queue drains, and the time above holds (the rule is a wall clock, not a countdown from when it is saved).`})}),(0,J.jsx)(`button`,{className:`bl-text bl-text-btn ${w===e.id?`open`:``}`,title:w===e.id?`collapse`:`expand — the whole prompt this fires`,onClick:()=>T(t=>t===e.id?null:e.id),children:Ka(t)}),e.lastResult&&(0,J.jsxs)(`div`,{className:`approve-hint`,children:[e.lastResult.ok?(0,J.jsx)(Dl,{size:12,style:{verticalAlign:`-2px`}}):(0,J.jsx)(Cc,{size:12,style:{verticalAlign:`-2px`}}),` `,Gp(e.lastResult.at),` · `,e.lastResult.detail,e.lastResult.occurrence?(0,J.jsxs)(J.Fragment,{children:[` · due `,Pe(e.lastResult.occurrence)]}):null,e.lastResult.late?` · ran late (the host had been asleep)`:``,x?(0,J.jsxs)(J.Fragment,{children:[` · the item is `,(0,J.jsx)(`b`,{children:Sve(x)})]}):null]}),(()=>{let c={run:p?`the send gave up — the desktop never got it, so there is nothing there to run`:s?`it is still in the send queue — the desktop does not have it yet`:null,toggle:p?`the send gave up — the desktop never got it, so there is nothing there to switch`:s?`it is still in the send queue — the desktop does not have it yet`:m?null:JG,remove:p?`the send gave up — nothing was stored, so there is nothing to delete`:s?`it is still in the send queue — cancel it there instead`:m?null:YG},l=[[`now`,c.run],[_?`pause/resume`:`on/off`,c.toggle&&XG.has(c.toggle)?null:c.toggle],[`delete`,c.remove&&XG.has(c.remove)?null:c.remove]];return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`approve-opts`,children:[c.run?null:(0,J.jsxs)(`button`,{className:`approve-btn`,"data-hint":`schedule.runnow`,title:`Run it now. This does not use up the next scheduled run.`,onClick:()=>{q(`action:schedule.runnow`),i(e.id)},children:[(0,J.jsx)(Hc,{size:14}),` now`]}),(0,J.jsxs)(`button`,{className:`approve-btn`,"data-hint":`schedule.edit`,onClick:()=>{q(`action:schedule.edit`),o(e)},children:[(0,J.jsx)(us,{size:14}),` edit`]})]}),(0,J.jsxs)(`div`,{className:`sched-acts`,children:[(0,J.jsx)(bve,{act:t,child:x,childSession:D,typed:b,repoName:C,onOpenSession:u,onOpenBacklog:d,onOpenBuildRun:f}),_&&e.nextAt&&a&&!s&&m&&(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`schedule.skipnext`,title:`Let this one run go by, then carry on as scheduled`,onClick:()=>{q(`action:schedule.skipnext`),a(e.id)},children:[(0,J.jsx)(Gne,{size:13}),` skip next`]}),c.toggle?null:(0,J.jsx)(`button`,{className:`link-btn`,"data-hint":`schedule.toggle`,title:_?e.enabled?`Pause it — nothing runs until you resume, and then it carries on at its own times`:`Resume it — the next run is its own next occurrence from now, never the ones it slept through`:e.enabled?`Stop it running`:`Arm it again — the next run is computed from now, not from what was missed`,onClick:()=>{q(`action:schedule.toggle`),r(e.id,!e.enabled)},children:_?e.enabled?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ho,{size:13}),` pause`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Hc,{size:13}),` resume`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Eo,{size:13}),` `,e.enabled?`off`:`on`]})}),c.remove?null:(0,J.jsx)(`span`,{className:`sched-acts-hint`,"data-hint":`schedule.remove`,children:(0,J.jsxs)(uT,{className:`link-btn danger`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ic,{size:13}),` delete it?`]}),title:`Delete this schedule — the next tap asks once more`,confirmTitle:`Tap again to delete it for good`,onConfirm:()=>{q(`action:schedule.remove`),n(e.id)},children:[(0,J.jsx)(ic,{size:13}),` delete`]})})]}),(0,J.jsx)(CE,{cants:l.flatMap(([e,t])=>t?[{label:e,reason:t}]:[])})]})})()]},e.id)};return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(gE,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ss,{size:16}),` `,fM.automation]}),onClose:s,children:[ne>0&&!_&&!v&&!O&&(0,J.jsx)(`span`,{className:`muted`,children:ne}),(0,J.jsx)(XR,{phases:ae})]}),(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(_||v)&&(0,J.jsxs)(`div`,{className:`section filter-bar`,children:[(0,J.jsxs)(`span`,{className:`filter-bar-txt`,children:[v?v.label:_?`showing the ${De[_]===`not armed`?`not armed`:`ones ${De[_]}`}`:``,` · `,A.cutTotal,` of `,ne,A.cutTotal===0&&(v?v.ids.length===1?` — that rule is not on this desktop any more`:` — none of those are on this desktop any more`:` — nothing is in that window any more`)]}),y&&(0,J.jsxs)(`button`,{className:`filter-bar-clear`,title:`clear the filter — show every schedule again`,onClick:()=>{q(`action:schedule.focus.clear`),y()},children:[(0,J.jsx)(V,{size:13}),` clear`]})]}),(0,J.jsx)(xve,{query:E,setQuery:D,cutTotal:A.cutTotal,shownTotal:te}),!m&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(Hs,{size:13,style:{verticalAlign:`-2px`}}),` offline — a new or edited schedule is queued and saved when the link is back, so `,(0,J.jsx)(`b`,{children:`edit`}),` still works on every row below (the save replaces the copy it edits rather than arming a second one). What the cards do not show while the link is down is`,` `,(0,J.jsx)(`b`,{children:`pause/resume`}),`, `,(0,J.jsx)(`b`,{children:`on/off`}),`, `,(0,J.jsx)(`b`,{children:`skip next`}),`, `,(0,J.jsx)(`b`,{children:`delete`}),` and the `,(0,J.jsx)(`b`,{children:`session`}),` button: the first four are decisions about a run that may be minutes away and only the host can make them, and the last one needs a desktop to open a session on.`,t.length>0&&(g?` The armed rows are this device's copy, last confirmed ${Gp(g)} ago.`:` The armed rows are this device's copy.`),` `,`Items waiting on a clock are not listed below while the link is down — this device caches the rules, not the rows. Each of them is in its repo's `,(0,J.jsx)(`b`,{children:`backlog`}),`, which does keep a copy.`]}),ne===0&&!m&&(0,J.jsx)($,{children:`No copy of the schedule list on this device — whatever is armed on the desktop is still armed.`}),ne===0&&m&&(0,J.jsxs)($,{children:[`Nothing is scheduled.`,` `,(0,J.jsx)(TE,{of:`a schedule`,label:`what is one?`,children:`A schedule fires a prompt on its own, at a time you pick — once tonight, or every week two hours before your usage window rolls over.`})]}),N.length===0&&ne>0&&!O&&(0,J.jsxs)(Z,{className:`sched-nothing-repeats`,children:[(0,J.jsx)(Pl,{size:13,style:{verticalAlign:`-2px`}}),` Nothing repeats — there is no standing rule on this desktop. `,ne,` one-off`,ne===1?``:`s`,` wait`,ne===1?`s`:``,` on a clock in `,ne===1?`its repo's backlog`:`their repos' backlogs`,`, where every verb they have lives. A rule that repeats would be a card here; `,(0,J.jsx)(`b`,{children:`new schedule`}),` writes one.`]}),!_&&!O&&S,ne>0&&(0,J.jsx)(NL,{entries:F,usage:x,now:k,title:e=>Ar(e.name,Ka(e.action))??Ka(e.action).split(`
|
|
204
204
|
`)[0]}),I.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`sched-head`,children:[(0,J.jsx)(Pl,{size:13}),` Repeating`,re?null:(0,J.jsxs)(J.Fragment,{children:[` · `,I.length]})]}),(0,J.jsx)(`div`,{className:`list`,children:I.map(oe)})]}),ee.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`sched-head`,children:[(0,J.jsx)(Ss,{size:13}),` One-off`,re?null:(0,J.jsxs)(J.Fragment,{children:[` · `,ee.length]})]}),(0,J.jsx)(`div`,{className:`list`,children:ee.map(oe)})]}),(0,J.jsx)(vve,{rows:A.shown,pending:A.shownPending,repoName:C,online:m,onOpen:d,renderRetime:p,counted:!re}),P.length>0&&!_&&!v&&!O&&(0,J.jsxs)(Z,{className:`sched-spent`,children:[(0,J.jsx)(kc,{size:13,style:{verticalAlign:`-2px`}}),` `,P.length,` one-off sweep`,P.length===1?` has`:`s have`,` been and gone — run or missed,`,` `,`Activity's row says which — and a one-off cannot be re-armed, so`,` `,P.length===1?`it is not a row here`:`they are not rows here`,` any more.`,b&&(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsxs)(Y,{"data-hint":`schedule.spent`,onClick:()=>{q(`action:schedule.spent`),b(P.map(e=>e.id))},children:[`see `,P.length===1?`it`:`them`,` in `,fM.activity]})]})]}),!_&&!v&&!O&&(0,J.jsx)(yve,{goneByRepo:A.goneByRepo,repoName:C,onOpen:d})]}),(0,J.jsx)(`div`,{className:`sheet-actions`,children:(0,J.jsxs)(`button`,{className:`send`,onClick:()=>{q(`action:schedule.new`),o(null)},children:[(0,J.jsx)(os,{size:16}),` new schedule`]})})]})}var wve={backlog:Vl,pull:rs,weekburn:Tc,peer:To};function Tve({lines:e,onDoor:t}){return e.length?(0,J.jsxs)(`div`,{className:`auto-foot`,children:[(0,J.jsx)(`div`,{className:`sched-head`,children:`Runs on its own, no clock`}),e.map(e=>{let n=wve[e.icon];return(0,J.jsxs)(xE,{kind:`wrap`,children:[(0,J.jsxs)(Q,{children:[(0,J.jsx)(n,{size:13,style:{verticalAlign:`-2px`}}),` `,e.text]}),(0,J.jsx)(Y,{onClick:()=>{q(`action:automation.${e.icon}`),t(e.door)},children:e.verb})]},e.key)})]}):null}var ZG=`__closed`;function QG(e,t){return e.targetSessionId?t.has(e.targetSessionId)?e.targetSessionId:e.reopensConv?``:ZG:``}function $G(e,t){return!!e.manual||!!e.at&&(e.at.nextAt==null||e.at.nextAt>t)}function eK(e,t,n,r){let i=new Set;if(!n)return i;let a=new Set;for(let n of e){let e=QG(n,t);e===`__closed`||a.has(e)||n.status===`queued`&&!$G(n,r)&&(a.add(e),i.add(n.id))}return i}var tK=e=>`${e} row${e===1?``:`s`}`;function nK(e){return[...new Set(e.map(e=>e.repoDir))]}function Eve(e,t){return e.filter(e=>e.repoDir===t&&!EW(e))}function Dve(e,t){let n=new Set(e.sessions.filter(e=>e.running&&e.cwd===t).map(e=>e.id));return[...eK(Eve(e.items,t),n,e.auto,e.now)]}function Ove(e){let t=e=>({kind:`backlog`,repoDir:e});if(!e.auto)return[{key:`backlog`,icon:`backlog`,verb:`open the backlog`,door:t(e.repoDir),text:`Backlog auto is off: no backlog row starts by itself.`}];let n=(e.repoDir?[e.repoDir]:nK(e.items)).map(t=>({dir:t,ids:Dve(e,t)})).filter(e=>e.ids.length>0);return n.length?n.map(({dir:t,ids:n},r)=>{let i=n.length,a=e.repoName(t),o=`${tK(i)} in ${a} will start when free`;return{key:`backlog:${t}`,icon:`backlog`,verb:i===1?`see it`:`see those ${i}`,door:{kind:`backlog`,repoDir:t,ids:n,label:`the ${tK(i)} auto starts next in ${a}`},text:r===0?`Backlog auto is on: ${o}.`:`${o[0].toUpperCase()}${o.slice(1)}.`}}):[{key:`backlog`,icon:`backlog`,verb:`open the backlog`,door:t(e.repoDir),text:e.repoDir?`Backlog auto is on; nothing in ${e.repoName(e.repoDir)} is waiting to start.`:`Backlog auto is on; no backlog row is waiting to start.`}]}function kve(e){if(!e.repoDir||!e.pull)return null;let t=e.repoName(e.repoDir),n=e.pull.scope===`repo`?`anywhere in the repo`:`in its outbox`;return{key:`pull`,icon:`pull`,verb:`download rules`,door:{kind:`pull`,repoDir:e.repoDir},text:e.pull.enabled?`Auto-download is on for ${t}: new files ${n}${e.pull.builds?` and build artifacts`:``} come to this phone by themselves.`:`Auto-download is off for ${t}.`}}function rK(e){let t=e.weekburn;if(!t||!t.available)return null;let n=e=>({key:`weekburn`,icon:`weekburn`,verb:`open the burn`,door:{kind:`weekburn`},text:e}),r=t.pickedThisWeek?t.prefs.repos:[],i=t.plan?`, from ${e.when(t.plan.startAt)}`:``;if(e.repoDir){let a=e.repoName(e.repoDir);return t.running.some(t=>t.repoDir===e.repoDir)?n(`The week-end burn is posting small one-commit items in ${a} now.`):r.includes(e.repoDir)?n(`The week-end burn picked ${a} this week: small one-commit items post there by themselves${i}.`):null}return t.running.length?n(`The week-end burn is posting small one-commit items in ${t.running.length===1?e.repoName(t.running[0].repoDir):`${t.running.length} repos`} now.`):r.length?n(`The week-end burn picked ${r.length===1?e.repoName(r[0]):`${r.length} repos`} this week${i}.`):n(`No repo is picked for this week's week-end burn.`)}function Ave(e){let t=e.items.filter(t=>Fee(t)&&t.status===`queued`&&!EW(t)&&(!e.repoDir||t.repoDir===e.repoDir));return nK(t).map(n=>{let r=t.filter(e=>e.repoDir===n).map(e=>e.id),i=[...new Set(t.filter(e=>e.repoDir===n).map(e=>Or(e.origin)))],a=r.length,o=e.repoName(n),s=i.length===1?`peer ${i[0]}`:`${i.length} peer desktops`;return{key:`peer:${n}`,icon:`peer`,verb:a===1?`see it`:`see those ${a}`,door:{kind:`backlog`,repoDir:n,ids:r,label:`the ${a} from a peer desktop in ${o}`},text:`${a===1?`1 job`:`${a} jobs`} from ${s} ${a===1?`waits`:`wait`} in ${o}'s backlog.`}})}function jve(e){let t=Ove(e),n=kve(e);n&&t.push(n);let r=rK(e);return r&&t.push(r),t.push(...Ave(e)),t}function Mve(e){nU.set(e),lue(e),rU.set(Date.now())}function Nve(e){iU.set(e),W().nav.open(`schedule`)}function Pve(e,t,n){iU.set(null),aU.set(n?{ids:e,label:t,repoDir:n}:{ids:e,label:t}),W().nav.open(`schedule`)}function iK(){iU.set(null),aU.set(null)}function Fve(e){let t=W(),{queueOp:n}=t.queue,r=nU.get().find(t=>t.id===e),i=n({t:`schedule.run`,id:e},`fanout`,r?.name||`scheduled run`);t.say.toast(i?`queued — it runs when the link is back`:`running it now`)}function Ive(e){let t=W(),n=t.queue.verbs.scheduleQueueRows(e);t.conn.liveSend({t:`schedule.remove`,id:e},$H(n.length),`no connection — this one lives on the desktop and can only be deleted there`)&&t.queue.verbs.dropScheduleQueue(n)}function Lve(){let e=_h(),{liveSend:t}=e.conn,{sessions:n,visibleRepos:r,active:i,intents:a}=e.world,o=t=>{let n=t.action.kind===`build`?e.world.repoForCwd(t.action.repoDir):null;n?e.nav.openBuild(n,{schedule:t}):e.say.toast(`that build's repo is not on this desktop's list — the rule cannot be edited from here`)},s=K(nU),c=K(rU),l=K(iU),u=K(aU),d=vh(),f=(0,H.useMemo)(()=>eU(d),[d]),p=u?u.repoDir??null:null,m=!u||!!u.repoDir,h=UV(),g=!p||!!h?.configs.has(p),_=h?.ask;(0,H.useEffect)(()=>{p&&_&&!g&&_(p)},[p,_,g]);let v=fh(`weekburn`,()=>U.getWeekBurn()),y=m?jve({repoDir:p,items:e.world.backlog,auto:e.world.backlogAuto,sessions:n,now:Date.now(),repoName:t=>{let n=e.world.repoForCwd(t);return n?Wn(n):t.split(/[/\\]/).filter(Boolean).pop()||t},pull:p?h?.configs.get(p):void 0,weekburn:v.state===`fresh`?v.data:null,when:Pe}):[];return(0,J.jsx)(Cve,{foot:(0,J.jsx)(Tve,{lines:y,onDoor:t=>{t.kind===`pull`?h?.open(t.repoDir):t.kind===`weekburn`?e.nav.open(`weekburn`):t.repoDir?e.nav.openBacklogCut(t.repoDir,t.ids,t.label):e.nav.open(`backlog`)}}),repos:r,entries:s,pending:f,listAt:c,focus:l,focusIds:u,onClearFocus:iK,onOpenSpent:t=>e.nav.openActivity({keys:t.map(EH),label:tU(t.length)}),online:e.conn.status===`open`,usage:e.world.usage,intents:a,sessions:n,onSkipNext:e=>{t({t:`schedule.skipNext`,id:e},`skipping the next run…`,`no connection — a skip has to reach the desktop before the run does`)},onOpenSession:t=>{let r=n.find(e=>e.id===t);r?(e.nav.close(`schedule`),e.nav.attach(r)):e.say.toast(`that session is no longer open`)},onOpenBacklog:(t,n,r)=>e.nav.openBacklogCut(t,n,r),onOpenBuildRun:(t,n)=>{let r=e.world.repoForCwd(t);r?e.nav.openBuild(r,{run:n}):e.say.toast(`that build's repo is not on this desktop's list`)},renderRetime:e.send.renderRetime,onEdit:t=>t?.action.kind===`build`?o(t):e.nav.openSend(t?e.send.seedFromSchedule(t):{when:tM(36e5),target:{kind:`repo`,cwd:i?.cwd??r.find(e=>e.isPrimary)?.worktreePath??``},cwdHint:i?.cwd??null,origin:`New schedule`}),onRunNow:Fve,onSetEnabled:(e,n)=>t({t:`schedule.setEnabled`,id:e,enabled:n},n?`armed`:`switched off`,`no connection — this one is armed on the desktop and can only be changed there`),onRemove:Ive,onClose:()=>e.nav.close(`schedule`)})}var Rve={id:`schedule`,sheets:[{id:`schedule`,persisted:!1,render:()=>(0,H.createElement)(Lve),onLeave:iK,keep:mh(iU,aU)}],messages:{"schedule.list":e=>Mve(e.entries)}},zve=[`done`,`obsolete`,`superseded`,`merged`];function aK(e){return zve.includes(e)}function Bve(e){return`the words for “${e}” are not on this phone`}var Vve=`this run's own record of what it judged is what both ends apply from, and this id is not in it — so there is nothing here to agree with, and a tick would do nothing`,Hve=`a pad note the run still wants — it is offered below, in its own words, as a backlog item; the pad itself is never edited by this app`;function Uve(e,t,n=!1){return n?Vve:t===`note`?e===`wanted`?Hve:`a pad note — this app never edits the pad, so there is nothing to apply here. If you agree it is done, delete it on the pad.`:e===`unclear`?`nothing to accept — the run did not decide about this one, so it stays exactly as it is`:e===`merged`?`a merge is one decision about all of its items — approve it on the merge itself, below`:null}function Wve(e){return e.verdict===`wanted`?e.rank==null?e.failed?`put back in the queue`:null:e.failed?`put back in the queue, position ${e.rank}`:`position ${e.rank} in the order`:null}var Gve=`retire this item: its words are kept with the reason on the row, and nothing is built`,oK=`tap to change your mind`;function sK(e){return`${e?``:`each `}where it was already aimed — a session of its own, or the session it names`}function cK(e,t,n=!1){return e===`wanted`?n?{label:`put it back`,title:`put this failed item back in the queue at the position the run proposes — it runs again ${sK(!0)} when its turn comes, and the failure it had stays on the row`,effect:`ticking keeps the item and gives it the position the run proposes; one that failed goes back in the queue and runs again when its turn comes — nothing is started now`,picked:`will be put back in the queue`,pickedTitle:oK}:{label:`keep it`,title:`keep this item and give it the position the run proposes — it does not run it`,effect:`ticking keeps the item and gives it the position the run proposes — nothing is started`,picked:`will be kept`,pickedTitle:oK}:e===`merged`?{label:`accept`,title:`a merge is approved on the merge card itself`,effect:`one decision about all of its items — approved on the card`,picked:`will be retired`,pickedTitle:oK}:e===`unclear`?{label:`accept`,title:`nothing was decided about this one`,effect:`nothing was decided here — these rows are yours to read`,picked:`stays as it is`,pickedTitle:oK}:{label:`retire it`,title:Gve,effect:`ticking a row here marks it to be retired when you Apply — its words are kept, with the reason on the row, and nothing is implemented`,picked:`will be retired`,pickedTitle:oK}}var lK={label:`leave it`,picked:`left alone`,title:`leave this one exactly as it is`,pickedTitle:`un-mark it`};function Kve(e,t){let n=new Map;for(let e of t)e&&typeof e.id==`string`&&e.id&&n.set(e.id,e);let r=e=>{let t=n.get(e.id),r=t?.source??`intent`,i=e.supersededBy?n.get(e.supersededBy):void 0;return{id:e.id,verdict:e.verdict,source:r,text:t?.text??``,missing:!t,failed:t?.state===`failed`,label:t?.label,headline:e.headline,category:e.category,verdictLabel:ve(e.verdict),sentence:kt(e),downgraded:e.downgraded,rank:e.rank,supersededBy:e.supersededBy,supersededByText:i?.text,gid:e.gid,acceptBlocked:Uve(e.verdict,r,!t),row:e}},i=e.rows.map(r),a=e.merges.map(e=>qve(e,i,n,r)),o=[];for(let e of cn){let t=i.filter(t=>t.verdict===e),n=e===`merged`?a:[];if(!t.length&&!n.length)continue;e===`wanted`&&t.sort((e,t)=>(e.rank??2**53-1)-(t.rank??2**53-1));let r=e===`merged`?[]:t,s=new Set;for(let e of n)for(let t of e.originals)s.add(t.id);o.push({verdict:e,label:ve(e),rows:r,merges:n,count:e===`merged`?s.size:t.length,acceptable:r.filter(e=>!e.acceptBlocked).length,failed:e===`wanted`?r.filter(e=>!e.acceptBlocked&&e.failed).length:0,retires:aK(e),defaultOpen:aK(e),fixedOpen:e===`merged`})}return o}function qve(e,t,n,r){let i=[],a=[];for(let o of e.ids){let s=t.find(e=>e.id===o);s?(i.push(s),s.missing&&a.push(o)):n.has(o)?i.push(r({id:o,verdict:`merged`,evidence:e.rationale,gid:e.gid})):a.push(o)}return{gid:e.gid,prompt:e.prompt,rank:e.rank,rationale:e.rationale,ids:[...e.ids],originals:i,missingIds:a,headline:e.headline,category:e.category}}function uK(e){let t=Ar(e.label,e.text,40),n={kind:e.source===`note`?`pad note`:`backlog item`,suggested:!t&&!!e.headline};t&&(n.name=t);let r=t??(e.headline?.trim()||void 0);return r&&(n.headline=r),e.category&&(n.category=e.category),e.missing&&(n.id=e.id),n}var dK=90;function Jve(e){let t=new Map;for(let n of e)n.downgraded&&t.set(n.downgraded,(t.get(n.downgraded)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e,t])=>({down:e,text:Ve(e),n:t}))}var fK=e=>{let t=(e||``).replace(/\s+/g,` `).trim();return t?`“${t.length>dK?`${t.slice(0,dK)}…`:t}”`:`“” (the words for this one are not on this phone)`};function Yve(e,t){let n=e.length,r=e.filter(e=>e.failed).length,i=[`${n} ${n===1?`item`:`items`} in ${t.repoName} — ${ve(t.verdict)}.`];i.push(aK(t.verdict)?`Nothing is deleted: each row keeps its words and the evidence it was retired on, dimmed rather than hidden, and one tap brings it back.`:r?`${r} of them failed: ${r===1?`it goes`:`they go`} back in the queue and run${r===1?`s`:``} again when ${r===1?`its turn comes`:`their turn comes`}, one at a time in this repo, ${sK(r===1)}. The failure ${r===1?`it`:`they`} had stays on the row. Nothing is retired and nothing is started now.`:`This only sets the order they run in. Nothing is sent and nothing is retired.`);for(let t of e.slice(0,3))i.push(fK(t.text));return n>3&&i.push(`…and ${n-3} more`),i}var Xve=e=>e.retires?`retire`:`keep`,pK=e=>e.slice(0,1).toUpperCase()+e.slice(1);function Zve(e,t,n){if(e.verdict===`merged`||e.verdict===`unclear`||!e.acceptable)return null;if(t>=e.acceptable)return{label:`un-tick ${t}`,title:`take the marks off this strip — nothing has been applied yet, so nothing is undone`,confirm:!1};let r=Xve(e),i=e.acceptable;if(e.retires)return{label:`${r} all ${i}`,title:`mark all ${i} to be retired when you Apply — their words are kept with the reason on each row, and nothing is implemented. You are shown the repo and 3 of the items first.`,confirm:!0,ask:{title:`${pK(r)} ${i} “${e.label}” in ${n.repoName}?`,confirmLabel:`${pK(r)} ${i}`}};let a=e.failed;return a?{label:`${r} all ${i}`,title:`keep all ${i} and give them the order the run proposes — ${a} of them failed and ${a===1?`is`:`are`} put back in the queue to run again when ${a===1?`its turn comes`:`their turn comes`}, one at a time in this repo, ${sK(a===1)}; nothing is started now and nothing is retired`,confirm:!0,ask:{title:`${pK(r)} ${i} in ${n.repoName} — put ${a} back in the queue?`,confirmLabel:`${pK(r)} ${i}`}}:{label:`${r} all ${i}`,title:`keep all ${i} and give them the order the run proposes — nothing is started and nothing is retired`,confirm:!1}}function Qve(e,t){let n=e.originals.length||e.ids.length,r=[`One new prompt replaces ${n} ${n===1?`item`:`items`} in ${t.repoName}.`,`The prompt below was written by the assessment, not by you. The items it replaces are retired with a reason and keep their words.`,fK(e.prompt)];for(let t of e.originals.slice(0,3))r.push(`replaces ${fK(t.text)}`);return e.originals.length>3&&r.push(`…and ${e.originals.length-3} more`),e.missingIds.length&&r.push(`${e.missingIds.length} of the items it names ${e.missingIds.length===1?`is`:`are`} not on this phone, so ${e.missingIds.length===1?`its words are`:`their words are`} not shown above.`),r}function $ve(e){let t=e.judged,n=[`The run read ${e.repoName} and is saying what it thinks of ${t} ${t===1?`item`:`items`} you wrote — it is a proposal, not a to-do list.`,`retire it / keep it on a row means you agree with that verdict. Nothing happens yet.`,`retire all on a strip agrees with every row on it in one go — you are shown the repo and 3 of the items first.`,`Apply, at the bottom, is the only thing that changes anything: retired items keep their words and go dim in the backlog (one tap brings one back); kept items stay where they are and each still runs in its own session when it fires — a kept item that had failed is put back in the queue and runs again when its turn comes, with its old failure kept on the row; new items are posted to the backlog the same way. Anything you left alone is untouched.`];return e.named&&n.push(`The run also suggested a title and a kind for each item — the switch at the bottom decides whether they are written on the rows. A title you typed yourself is never replaced.`),e.planPath&&n.push(`read the plan opens ${e.planPath}, the run's write-up. It is for reading, not something to run — the work is the items below.`),{lead:`A proposal. Nothing here builds, runs or sends anything.`,lines:n}}function eye(e){return e.rows.size+e.merges.size+e.news.size+(e.splits?.size??0)}function tye(e){return`${e} ticked`}var mK=e=>Array.isArray(e)?new Set(e):e;function nye(e,t,n){let r=mK(t.rows),i=mK(t.merges),a=mK(t.news),o=new Map;for(let e of n)e&&typeof e.id==`string`&&e.id&&o.set(e.id,e);let s=e=>{let t=o.get(e);return!!t&&!t.context&&t.source===`intent`},c=new Set,l=0;for(let t of e.merges)if(i.has(t.gid)){l++;for(let e of t.ids)s(e)&&c.add(e)}let u=0,d=0;for(let t of e.rows)if(r.has(t.id)){if(t.verdict===`wanted`){if(!s(t.id))continue;o.get(t.id)?.state===`failed`?d++:t.rank!=null&&u++}else t.verdict!==`merged`&&t.verdict!==`unclear`&&s(t.id)&&c.add(t.id)}e.news.forEach((e,t)=>{a.has(t)&&l++});let f=0;for(let t of e.rows)(t.headline||t.category)&&s(t.id)&&f++;return{retire:c.size,keep:u,requeue:d,post:l,name:f}}function rye(e,t,n={}){let r=[];return e.retire&&r.push(`retire ${e.retire}`),e.keep&&r.push(`keep ${e.keep} in order`),e.requeue&&r.push(`put ${e.requeue} back in the queue`),e.post&&r.push(`post ${e.post} new`),n.splits&&r.push(`split ${n.splits} in two`),n.ranked&&r.push(`order ${n.pinRanks===!1?`free`:`pinned`}`),n.writeNames&&e.name&&r.push(`title ${e.name}`),r.length?`Apply in ${t} — ${r.join(` · `)}`:`Apply in ${t}`}function iye(e){let t=`Retired items keep their words and can be brought back.`;if(!e)return`${t} Nothing is built or sent by this.`;let n=e===1;return`${t} Nothing is started now: the ${n?`one put back runs`:`${e} put back run`} again when ${n?`its turn comes`:`their turn comes`}, one at a time per repo, ${sK(n)}.`}var aye=new Set([`queued`,`blocked`]);function oye(e,t){if(!e?.applied)return{ids:[],n:0};let n=[];for(let e of t)e&&typeof e.id==`string`&&e.id&&(e.archived||aye.has(e.status??``)&&n.push(e.id));return{ids:n,n:n.length}}function sye(e,t){return e>0?`open the backlog — ${e} waiting in ${t}`:`open the backlog in ${t}`}function hK(e){return e>0?`Opens exactly those ${e} — everything waiting in this repo, filtered, with the clear button on the bar. Nothing else is applied by this — the apply above already happened.`:`Nothing is waiting in this repo, so the list opens unfiltered. Nothing else is applied by this.`}function cye(e){return`everything waiting in ${e}, from the assessment`}function lye(e){let t=[`${e.dismissed} retired`,`${e.ranked} ranked`];return e.requeued&&t.push(`${e.requeued} put back`),e.named&&t.push(`${e.named} titled`),t.push(`${e.posted} posted`),`applied: ${t.join(` · `)}`}var uye={label:`post it`,picked:`will be posted`,title:`add this to the backlog when you Apply — it is not started by this`,pickedTitle:`tap to change your mind`};function dye(e){return`becomes a backlog item in ${e}, in its own session when it fires`}var fye={label:`file it`,picked:`will be filed`,title:`file your own words as a backlog item when you Apply, and take the note off the pad — nothing is started by this`,pickedTitle:oK};function pye(e){return`your note, word for word, becomes a backlog item in ${e} — and comes off the pad once the desktop has it`}function mye(e){return e===1?`your note is on the backlog and off the pad`:`${e} notes are on the backlog and off the pad`}function hye(e,t){if(!Array.isArray(t))return{clear:[],stay:[...e],told:!1};let n=new Set(t),r=[],i=[];for(let t of e)(n.has(t)?r:i).push(t);return{clear:r,stay:i,told:!0}}function gye(e){let t=e.clear.length,n=e.stay.length;return!t&&!n?null:e.told?n?t?`${t===1?`1 note is on the backlog and off the pad`:`${t} notes are on the backlog and off the pad`}; ${n===1?`1 is still on your pad — the desktop did not file it`:`${n} are still on your pad — the desktop did not file them`}`:n===1?`nothing was filed — your note is still on the pad`:`nothing was filed — your ${n} notes are still on the pad`:mye(t):n===1?`your note is left on the pad — the desktop could not say whether it filed it`:`your ${n} notes are left on the pad — the desktop could not say which it filed`}function _ye(e){let t=e.run;if(!t)return`no assessment has been run for this repo yet`;if(t.status===`running`)return`the assessment is still running — its verdicts are not final until it finishes`;if(t.status===`failed`)return`the run did not produce a proposal${t.detail?` — ${t.detail}`:``}`;let n=t.proposal;return!n||!(n.rows.length+n.merges.length+n.news.length+(n.splits?.length??0)+(n.conflicts?.length??0))?`this run came back with nothing to decide`:t.status===`applied`?`this proposal has already been applied — run a new assessment to judge what is left now`:e.busy?`the decisions have been sent — waiting for the desktop`:e.picked?e.online?null:`no connection — applying starts work on the desktop, so it cannot be queued from here`:`nothing is ticked yet — tap retire it or keep it on the rows you agree with, or retire all on a strip`}function gK(e){return e.run?.status===`running`?`an assessment is already running for this repo — two of them would propose different verdicts on one list`:e.busy?`the run has been asked for — waiting for the desktop`:e.budgetNote?e.budgetNote:e.online?null:`no connection — the run happens on the desktop`}function _K(e,t){let n=Math.max(e||0,t||0),r=`step${n===1?``:`s`}`,i=t>0&&n>t;return{line:i?`${n} ${r} · last ${t} shown`:`${n} ${r}`,button:i?`last ${t} of ${n} ${r}`:`${n} ${r}`}}function vK(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return t%60?`${n}m ${t%60}s`:`${n}m`;let r=Math.floor(n/60);return n%60?`${r}h ${n%60}m`:`${r}h`}function vye(e){let t=e.detail;switch(e.kind){case`read`:return t?`reading ${t}`:`reading`;case`search`:return t?`searching for ${t}`:`searching`;case`edit`:return t?`writing ${t}`:`writing`;case`run`:return t?`running ${t}`:`running a command`;case`task`:return t?`running an agent: ${t}`:`running an agent`;case`web`:return t?`fetching ${t}`:`fetching`;case`say`:return`thinking it over`;default:return t?`${e.label}: ${t}`:e.label}}function yye(e,t){if(!e||e.status!==`running`)return null;let n=vK(t-e.startedAt),r=e.progress,i=r?.tail.length?r.tail[r.tail.length-1]:null,a=!r||!i?`starting up`:r.wroteOut?`writing its answer`:vye(i),o=r?r.tail.length:0;return{doing:a,elapsed:n,counts:r&&r.steps?_K(r.steps,o).line:void 0,quiet:r&&t-r.at>=9e4?`nothing new for ${vK(t-r.at)}`:void 0,say:r?.say}}var yK=[`inherit`,`keep`,`close`];function bK(e){return e===!0?`close`:e===!1?`keep`:`inherit`}function bye(e){return e===`close`||e!==`keep`&&null}function xye(e){return e===`close`||e!==`keep`&&void 0}var Sye=e=>e?`close when done`:`keep open`;function xK(e,t){return e===`close`?`close when done`:e===`keep`?`keep open`:`as set globally (currently: ${Sye(t)})`}function SK(e,t){let n=bK(e);return`${(n===`inherit`?t:n===`close`)?`Its session closes itself once the work is done (it stays under Recently closed, reopenable)`:`Its session stays open once the work is done, until you close it`} — ${n===`inherit`?`as set globally`:`this item's own choice`}.`}function Cye(e,t){return e===`inherit`?`follows the global setting — ${t?`closes when done`:`stays open`}`:e===`close`?`its session will close when done`:`its session will stay open`}function CK(e){let t=bK(e);return t===`close`?`closes when done`:t===`keep`?`stays open`:null}var wK=e=>!e.targetSessionId,TK=e=>wK(e)&&e.status===`queued`;function EK(e,t){return!e||!t?!1:$r(t).length>=t.max&&/free slot/i.test(e)}function wye(e,t){if(!e)return[];let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of $r(e)){let e=n.get(t.id);e&&e.running&&r.push({s:e,closeWhenDone:t.closeWhenDone})}return r}function Tye(e){return`close one to make room — ${e} working`}function Eye(e,t){let n=e.turnActive?`working`:`idle`;return t?`${n} · closes itself when done`:`${n} · stays open until closed`}function DK(e,t){let n=[];for(let r of e){if(r.repoDir!==t)continue;let e=Zte(r);e&&n.push(e)}return n}function OK(e,t){return{repoDir:e,ids:[...t.ids],scope:{kind:`slot`,key:t.key},kind:t.kind,at:t.at,period:t.period}}function Dye(e,t,n,r){if(r)return null;let i=DK(e,t),a=Hee(i,n);if(!a.length)return null;let o=yee(i,n);return o?{id:n,others:a.length,check:OK(t,o)}:null}function Oye(e){return`${wa(e.others,e.check.kind)} — check them together?`}var kye=`check`,Aye=`not now`,jye=`don't ask in this repo`,Mye=`ask after a timed send`;function Nye(e){return`won't ask in ${e} again — “${Mye}” in its backlog brings it back`}function Pye(e){return`will ask again in ${e} when a timed send lands beside others`}function kK(e){return e?.at?JSON.stringify([e.at.rule,e.at.nextAt]):null}function Fye(e,t,n,r){if(r||n-e.since>6e5)return{kind:`drop`};let i=t.find(t=>t.id===e.id);if(!i||kK(i)===e.was)return{kind:`wait`};let a=Dye(t,e.repoDir,e.id,r);return a?{kind:`ask`,ask:a}:{kind:`drop`}}function Iye(e,t){return Oee(DK(e,t)).filter(e=>e.ids.length>=2).map(e=>OK(t,e))}function AK(e){return e.kind===`reset`?`at the ${e.period??`usage`} reset, ${Pe(e.at)}`:`at ${Pe(e.at)}`}function Lye(e,t){return`check these ${e.ids.length} · ${Dn(e.at,t)}`}function jK(e){return`the ${e.ids.length} rows that run together ${AK(e)} — one assessment reads them as a group (rows that contradict each other, a row that is two jobs, their order). Nothing changes until you approve it.`}function Rye(e,t,n){if(!e||e.kind!==`slot`)return null;let r=Jee(e.key),i=t?t===2?`these two`:`these ${t}`:`these rows`;return r?`A slot check: ${i} run together ${AK(r)} (${Dn(r.at,n)}). It looks for rows that contradict each other, a row that is two jobs, and the order they should go in.`:`A slot check: ${i} run together.`}function MK(e,t){return`${t?`check again`:`check`} ${e===2?`these two`:`these ${e}`} together`}var NK=(e,t)=>({id:t,text:e.get(t)?.text??null}),PK=e=>{let t=new Map;for(let n of e)n?.id&&t.set(n.id,n);return t};function zye(e,t){let n=PK(t);return(e?.conflicts??[]).map(e=>({cid:e.cid,sentence:le(e),rows:e.ids.map(e=>NK(n,e))}))}var Bye=`words only — nothing here is applied. Edit one, drop one, or leave them as they are.`,Vye=`drop this one`,Hye=`archive it?`,Uye=`archive this row — its words are kept and the backlog's archived cut brings it back`,Wye=`leave them`;function Gye(e,t){let n=PK(t);return(e?.splits??[]).map(e=>({sid:e.sid,id:e.id,sentence:Gt(e),original:NK(n,e.id),texts:[...e.texts]}))}function Kye(e,t){if(!e||e.status===`applied`||e.status===`failed`)return`run`;if(e.status===`running`)return`busy`;let n=e.scopedIds??[];return e.scope?.kind===`slot`&&e.scope.key===t.scope.key&&n.length===t.ids.length&&t.ids.every(e=>n.includes(e))?`same`:`waiting`}function qye(e,t){return e===`busy`?`an assessment is already running here — when it ends, the sheet's check button runs this one`:e===`waiting`?`another proposal is waiting here — decide it, or tap “${MK(t,!0)}” to replace it`:null}function Jye(e){let t=[...e.splits];return{rows:[...e.rows],merges:[...e.merges],news:[...e.news],...t.length?{splits:t}:{},pinRanks:e.pinRanks,writeNames:e.writeNames}}function Yye(e,t){return[`In ${t}, this row is archived (its words kept):`,e.original.text??`${e.id} — its words are not on this phone`,`and two rows are posted on the same clock:`,`1. ${e.texts[0]??``}`,`2. ${e.texts[1]??``}`]}var FK=[],IK=[],LK=null,RK=null,zK=new Set,BK=()=>{for(let e of zK)e()};function VK(){let e=oo(B.slotAskOff,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function HK(e){return VK().includes(e)}function UK(e,t){let n=VK().filter(t=>t!==e);$a(B.slotAskOff,t?[...n,e]:n),t&&(IK=IK.filter(t=>t.repoDir!==e),LK?.check.repoDir===e&&(LK=null)),BK()}function Xye(e,t){if(!e||!t||HK(t))return;let n=kK(FK.find(t=>t.id===e));IK=[...IK.filter(t=>t.id!==e),{id:e,repoDir:t,was:n,since:Date.now()}]}function Zye(e){if(FK=e,!IK.length)return;let t=Date.now(),n=[],r=null;for(let i of IK){let a=Fye(i,e,t,HK(i.repoDir));a.kind===`wait`?n.push(i):a.kind===`ask`&&(r=a.ask)}IK=n,r&&(LK=r,BK())}function Qye(){return LK}function WK(e){return zK.add(e),()=>{zK.delete(e)}}function GK(){LK&&(LK=null,BK())}function KK(e){RK=e}function $ye(e){return RK?(RK(e),!0):!1}var qK=e=>e.status===`queued`||aW(e),ebe={checking:`checking…`,done:`implemented`,partial:`partial`,questions:`open questions`,not_done:`not done`,error:`check failed`,limited:`not checked — usage limit`,signedOut:`not checked — signed out`},tbe={checking:Ml,done:ys,partial:Jc,questions:gl,not_done:V,error:Js,limited:Kl,signedOut:ns},nbe={validating:`validating…`,achieved:`outcome achieved`,likely:`likely achieved`,unlikely:`likely not achieved`,unclear:`unclear`,error:`validate failed`,limited:`not validated — usage limit`,signedOut:`not validated — signed out`},rbe={validating:Ml,achieved:ys,likely:Jc,unlikely:V,unclear:gl,error:Js,limited:Kl,signedOut:ns},JK=e=>({label:bn(ebe,e,`a check result this app version cannot name`),Icon:bn(tbe,e,gl)}),YK=e=>({label:bn(nbe,e,`a validate result this app version cannot name`),Icon:bn(rbe,e,gl)}),XK={bug:wo,feature:Co,enhancement:Al,chore:$s};function ibe(e,t,{text:n,repoDir:r,filter:i,showArchived:a,sort:o},s){let c=(0,H.useMemo)(()=>wye(e.autoSlots,e.sessions),[e.autoSlots,e.sessions]),l=r?e.cutVerbs.assessBlocked?.(r)??null:null,u=e.sessions.filter(e=>e.running&&e.cwd===r),d=(0,H.useMemo)(()=>new Set(e.sessions.filter(e=>e.running).map(e=>e.id)),[e.sessions]),f=e=>gG(e,d),p=t=>!t.targetSessionId&&wM(t.repoDir,e.intents,t.id,e.sessions),m=e=>hG(e,d)===`held-closed`,h=e=>!!e.targetSessionId&&!d.has(e.targetSessionId)&&!e.reopensConv,g=e=>!!e.targetSessionId&&!d.has(e.targetSessionId)&&!!e.reopensConv,_=e=>!!e.targetSessionId&&d.has(e.targetSessionId),v=e.activeSession&&e.sessions.some(t=>t.running&&t.id===e.activeSession.id)?e.activeSession:null,y=v&&v.cwd===r?v:null,b=e=>!!v&&e.targetSessionId===v.id&&!!e.autoFire,x=t=>{let n=e.repos.find(e=>e.worktreePath===t);return n?Te(n):t.split(/[/\\]/).filter(Boolean).pop()||t},S=e.items.filter(e=>e.repoDir===r),C=i.ids||a?S:S.filter(e=>!EW(e)),w=NW(C,i,t),T=(0,H.useMemo)(()=>Iye(S,r),[S,r]),E=(0,H.useSyncExternalStore)(WK,()=>HK(r)),D=CW(i),O=D?C.filter(e=>wW(e,i,t)):C,k=n.trim().toLowerCase(),A=k?O.filter(e=>`${zn(e)??``} ${e.label??``} ${e.text}`.toLowerCase().includes(k)):O,j=S.filter(e=>e.archived).length,M=new Map(e.items.map(e=>[e.id,e])),N=e=>jG(e)??(e.text.length>40?`${e.text.slice(0,40)}…`:e.text),P=(0,H.useMemo)(()=>new Set(e.naming??[]),[e.naming]),F=new Set(u.map(e=>e.id)),I=e=>QG(e,F),ee=AW(o,!!i.clock),te=[],ne=(e,t,n,r)=>({key:e,title:t,running:n,items:jW(r,ee),seats:MW(r)}),re=A.filter(e=>I(e)===``);re.length&&te.push(ne(``,`Each in a new session`,!0,re));let ie=A.filter(e=>I(e)===ZG);ie.length&&te.push(ne(ZG,`Aimed at a session that closed`,!1,ie));for(let e of u){let t=A.filter(t=>I(t)===e.id);t.length&&te.push(ne(e.id,`In ${Li(e)}`,!0,t))}let ae=te.flatMap(e=>e.items),oe=ae.filter(IG),se=oe.filter(e=>s.has(e.id)).map(e=>e.id),ce=(0,H.useMemo)(()=>KW(C),[C]),le=UG(ce,oe),ue=e=>$G(e,t),de=eK(ae,F,e.auto,t),fe={fresh:0,aimed:0,held:0,other:0};for(let e of O){let t=I(e);e.archived?fe.other++:e.status===`queued`&&!ue(e)?t===``?fe.fresh++:t===`__closed`?fe.held++:fe.aimed++:e.status===`queued`&&(ue(e)||t===`__closed`)?fe.held++:fe.other++}return{slotSessions:c,assessWhyNot:l,repoSessions:u,liveSessionIds:d,runAgainOffered:f,fireIntoBusy:p,runAgainHeld:m,targetClosed:h,targetReopens:g,targetLive:_,here:v,hereInRepo:y,queuedHere:b,repoLabel:x,inRepo:S,base:C,counts:w,filtering:D,cut:O,q:k,visible:A,archivedCount:j,byId:M,nameOf:N,namingIds:P,groupKeyOf:I,drawSort:ee,groups:te,displayOrder:ae,retimeable:oe,retimeIds:se,clockCuts:ce,retimeClocks:le,nextFireIds:de,clockAhead:ue,focusBreakdown:fe,focusWords:i.ids?FW(fe,e.auto):null,bulkClockIds:i.status===`failed`?O.filter(e=>!!e.at).map(e=>e.id):[],bulkRunAgainIds:i.status===`failed`?_G(O,d):[],bulkRunAgainAimed:i.status===`failed`?vG(O,d):0,bulkDoneIds:i.status===`done`?O.filter(e=>!e.archived).map(e=>e.id):[],assessIds:UW(O),nameIds:DG(O),namingHere:S.some(e=>P.has(e.id)),slotCheckList:T,slotAskOff:E}}var ZK=B.backlogDraft;function abe(){let[e,t]=(0,H.useState)(()=>(z(ZK)??``).trim());return{strandedDraft:e,dropStrandedDraft:()=>{so(ZK),t(``)}}}function obe(e,{displayOrder:t,groupKeyOf:n,drawSort:r}){let[i,a]=(0,H.useState)(null),o=e.online&&r===`run`,s=(0,H.useRef)({displayOrder:t,groupKeyOf:n,verbs:e.cutVerbs});return s.current={displayOrder:t,groupKeyOf:n,verbs:e.cutVerbs},(0,H.useEffect)(()=>{if(!i)return;let e=e=>{let t=(document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-blid]`))?.getAttribute(`data-blid`);if(!t||t===i)return;let{displayOrder:n,groupKeyOf:r}=s.current,a=n.find(e=>e.id===i),o=n.find(e=>e.id===t);if(!a||!o||r(a)!==r(o))return;let c=n.map(e=>e.id),l=c.indexOf(i),u=c.indexOf(t);l!==-1&&u!==-1&&(c.splice(l,1),c.splice(u,0,i),s.current.verbs.onReorder(c))},t=()=>a(null);return window.addEventListener(`pointermove`,e,{passive:!1}),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[i]),{dragId:i,setDragId:a,canDrag:o}}function sbe(e){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(``),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(``),[p,m]=(0,H.useState)(``);function h(e){n(e.id),i(e.text),o(e.label??``),c(e.repoDir),u(e.targetSessionId??``),f(e.headline??``),m(e.category??``)}function g(t){let i=r.trim();if(!i)return;let o={};i!==t.text&&(o.text=i),(a||void 0)!==t.label&&(o.label=a);let c=d.trim();c!==(t.headline??``)&&(o.headline=c),p!==(t.category??``)&&(o.category=p),t.status!==`running`&&(s&&s!==t.repoDir&&(o.repoDir=s),(l||``)!==(t.targetSessionId??``)&&(o.targetSessionId=l)),Object.keys(o).length>0&&e.verbs.onUpdate(t.id,o),n(null)}return{editingId:t,setEditingId:n,editText:r,setEditText:i,editLabel:a,setEditLabel:o,editRepo:s,setEditRepo:c,editTarget:l,setEditTarget:u,editHeadline:d,setEditHeadline:f,editCategory:p,setEditCategory:m,beginEdit:h,saveEdit:g}}function cbe(e){let t=t=>!!t&&e.repos.some(e=>e.worktreePath===t);if(t(e.cutRepo))return{repoDir:e.cutRepo,derived:!1};if(t(e.sessionRepo))return{repoDir:e.sessionRepo,derived:!1};if(t(e.saved))return{repoDir:e.saved,derived:!1};let n=e.items.find(e=>!e.archived&&t(e.repoDir))?.repoDir;return n?{repoDir:n,derived:!0}:{repoDir:e.repos[0]?.worktreePath??``,derived:!1}}var QK=B.backlogShowArchived,$K=B.backlogRepo;function lbe(e){let{cut:t,setCut:n}=e,{text:r,filter:i,idsLabel:a}=t,o=e=>n(t=>({...t,text:e})),{repoDir:s,derived:c}=cbe({repos:e.repos,items:e.items,cutRepo:t.repoDir,sessionRepo:e.defaultRepoDir,saved:z($K)});(0,H.useEffect)(()=>{c&&n(e=>e.repoDir===s?e:{...e,repoDir:s})},[c,s,n]);let[l,u]=(0,H.useState)(()=>z(QK)===`1`),d=(e,t)=>n(n=>({...n,idsLabel:t,filter:{...n.filter,ids:e}})),f=()=>n(e=>({...e,idsLabel:void 0,filter:SW}));function p(e){e&&Za($K,e),n(t=>({...t,repoDir:e,filter:t.filter.ids?{...t.filter,ids:null}:t.filter,idsLabel:void 0}))}let m=e=>n(t=>({...t,filter:e(t.filter)})),h=e=>m(t=>({...t,status:t.status===e?null:e})),g=e=>m(t=>({...t,age:t.age===e?null:e})),_=e=>m(t=>({...t,category:t.category===e?null:e})),v=()=>m(e=>({...e,clock:!e.clock||null}));function y(){let e=!l;u(e),e?Za(QK,`1`):so(QK)}return{text:r,setText:o,repoDir:s,showArchived:l,filter:i,idsLabel:a,showIds:d,clearFilter:f,selectRepo:p,pickStatus:h,pickAge:g,pickCategory:_,pickClock:v,toggleArchived:y}}var eq=B.backlogSortRun;function ube(){let[e,t]=(0,H.useState)(()=>z(eq)===`1`?`run`:`newest`);return{sort:e,setSort:e=>{t(e),e===`run`?Za(eq,`1`):so(eq)}}}function dbe(){let[e,t]=(0,H.useState)(!1),[n,r]=(0,H.useState)(()=>new Set),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(new Set),c=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[l,u]=(0,H.useState)(new Set),d=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[f,p]=(0,H.useState)(new Set),[m,h]=(0,H.useState)(new Set),[g,_]=(0,H.useState)(new Set);return{picking:e,setPicking:t,picked:n,setPicked:r,choosing:i,setChoosing:a,openDetail:o,toggleDetail:c,openValidate:l,toggleValidate:d,openText:f,toggleText:e=>p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),slotOpen:m,setSlotOpen:h,budgetOpen:g,toggleBudget:e=>_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}}function fbe({m:e,repoDir:t}){let{p:n}=e,r=n.items.filter(e=>e.repoDir===t&&Ri(e.origin)).map(e=>e.id),i=n.nav.weekBurnText?.(t)??null;return(0,J.jsxs)(`div`,{className:`form bl-repobar`,children:[i&&(0,J.jsxs)(Z,{as:`span`,children:[(0,J.jsx)(Tc,{size:13,style:{verticalAlign:`-2px`}}),` `,i]}),r.length>0&&n.nav.onOpenCut&&(0,J.jsx)(Y,{onClick:()=>{q(`action:backlog.weekburnrows`),n.nav.onOpenCut(t,r,pr(r.length))},children:pr(r.length)}),(0,J.jsxs)(Y,{onClick:()=>{q(`action:backlog.weekburn`),n.nav.onOpenWeekBurn()},children:[!i&&(0,J.jsx)(Tc,{size:14}),` week-end burn…`]})]})}function pbe({m:e}){let{p:t,repoDir:n}=e;return(0,J.jsxs)(gE,{title:`Backlog`,onClose:t.nav.onClose,children:[n&&(0,J.jsxs)(`button`,{className:`rc`,title:`write something for this repo — the send sheet, with the repo already chosen`,onClick:()=>{q(`action:backlog.send`),t.nav.onOpenSend(n)},children:[(0,J.jsx)(_l,{size:14}),` send…`]}),(0,J.jsx)(`button`,{className:`rc ${t.auto?`on`:`off`}`,onClick:()=>t.cutVerbs.onSetAuto(!t.auto),children:t.auto?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(yl,{size:14}),` auto`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(vc,{size:14}),` auto off`]})})]})}function mbe({m:e}){let{assessIds:t,assessWhyNot:n,cut:r,filtering:i,p:a,repoDir:o,selectRepo:s}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`form bl-repobar`,children:[(0,J.jsx)(ZO,{repos:a.repos,value:o,onChange:s,"aria-label":`repo`}),a.cutVerbs.onAssess&&o?n?(0,J.jsxs)(Z,{as:`span`,children:[`assess: `,n]}):i&&!t.length?(0,J.jsx)(Z,{as:`span`,children:HW}):(0,J.jsxs)(Y,{title:i?`judge exactly the open rows in this cut — it still reads the whole repo as evidence, and nothing applies itself`:`read this repo and judge what is left in it — with evidence, and nothing applies itself`,onClick:()=>{q(`action:backlog.assess`),a.cutVerbs.onAssess?.(o,i?t:void 0)},children:[(0,J.jsx)(uo,{size:14}),` `,i?BW(t.length):`assess`]}):null,a.cutVerbs.onAssess&&o&&!n&&i&&t.length>0&&(0,J.jsx)(Z,{as:`span`,children:VW(t.length,r.length)})]}),o&&a.nav.onOpenWeekBurn&&(0,J.jsx)(fbe,{m:e,repoDir:o})]})}function hbe({m:e}){let{focusWords:t,p:n}=e;return(0,J.jsx)(J.Fragment,{children:!n.auto&&!t&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsx)(Z,{children:(0,J.jsxs)(TE,{of:`auto off`,label:`what does auto off stop?`,children:[(0,J.jsx)(`b`,{children:`auto`}),` is off on this desktop: nothing queued anywhere runs until you turn it back on or fire an item by hand.`]})})})})}function gbe({m:e}){let{dropStrandedDraft:t,p:n,repoDir:r,strandedDraft:i}=e;return(0,J.jsx)(J.Fragment,{children:i&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Z,{children:[(0,J.jsx)(`b`,{children:`Kept from before`}),` — this was the old add/search field, so it may be a search you typed:`,` `,`“`,i.length>160?`${i.slice(0,160)}…`:i,`”`,(0,J.jsxs)(`div`,{className:`annot-tools`,style:{marginTop:6},children:[(0,J.jsxs)(Y,{onClick:()=>{let e=i;t(),n.nav.onOpenSend(r,e)},children:[(0,J.jsx)(_l,{size:14}),` send it`]}),(0,J.jsxs)(uT,{confirm:`discard it?`,title:`throw these words away`,onConfirm:t,children:[(0,J.jsx)(V,{size:14}),` discard`]})]})]})})})}function _be({m:e}){let{here:t,hereInRepo:n,p:r}=e;return(0,J.jsxs)(J.Fragment,{children:[r.online&&!n&&(t?(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Z,{children:[`No wait verb on these items: the session you came from (`,(0,J.jsx)(`b`,{children:t.title}),`) is in another repo, and an item can only run in a session opened on its own checkout.`]})}):r.activeSession?(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsx)(Z,{children:`No wait verb on these items: the session you came from is no longer running, so there is nothing to hand one to.`})}):null),!r.online&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Z,{children:[`Offline — showing the last synced backlog. Every mutation (fire, edit, done, check, validate, continue, reorder, archive, remove) is disabled until the connection is back; `,(0,J.jsx)(`b`,{children:`send…`}),` still queues normally.`]})})]})}var vbe=[`newest`,`run`];function ybe({m:e}){let{base:t,drawSort:n,setSort:r,sort:i}=e;return t.length<2?null:(0,J.jsxs)(`div`,{className:`ts-filter bl-sort`,role:`group`,"aria-label":`sort`,children:[(0,J.jsx)(`span`,{className:`ctx-stackpick-lab`,children:`sort`}),vbe.map(e=>(0,J.jsx)(pE,{on:i===e,clears:!1,onClick:()=>{q(e===`run`?`action:backlog.sort.run`:`action:backlog.sort.newest`),r(e)},children:DW[e]},e)),(0,J.jsxs)(TE,{of:`the sort`,children:[(0,J.jsx)(`p`,{children:`Newest first draws the rows most recently added at the top. Run order is the order they will start in.`}),(0,J.jsxs)(`p`,{children:[`Either way, `,OW,`.`]}),n===i?null:(0,J.jsxs)(`p`,{children:[`Right now `,kW,`.`]})]})]})}function bbe({m:e}){let{archivedCount:t,base:n,counts:r,filter:i,filtering:a,pickAge:o,pickCategory:s,pickClock:c,pickStatus:l,setText:u,showArchived:d,text:f,toggleArchived:p}=e,m=PW(r,i),h=m.status.length>0||m.clock||m.age.length>0||m.category.length>0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`form bl-searchrow`,children:[(0,J.jsxs)(`div`,{className:`bl-search`,children:[(0,J.jsx)(Lc,{size:16,className:`bl-search-icon`}),(0,J.jsx)(`textarea`,{className:`search bl-combo`,rows:1,placeholder:`Search this repo…`,value:f,onChange:e=>u(e.target.value)}),f&&(0,J.jsx)(`button`,{className:`bl-search-clear`,onClick:()=>u(``),title:`clear`,children:(0,J.jsx)(V,{size:16})})]}),t>0&&(0,J.jsxs)(pE,{on:d,onClick:p,title:d?`hide archived items again`:`show this repo's archived items too`,children:[(0,J.jsx)(lo,{size:13,"aria-hidden":!0}),uE(`archived`,{count:t})]})]}),(0,J.jsx)(ybe,{m:e}),n.length>0&&h&&(0,J.jsxs)(`div`,{className:`bl-fchips`,children:[(m.status.length>0||m.clock)&&(0,J.jsxs)(`div`,{className:`fchips wrap`,children:[m.status.map(e=>(0,J.jsx)(pE,{on:i.status===e,title:`show only ${e} items${i.age?` from the ${fW[i.age]}`:``}`,onClick:()=>{q(`action:backlog.filter.status`),l(e)},children:uE(e,{count:r.status[e]})},e)),m.status.length>0&&m.clock&&(0,J.jsx)(`span`,{className:`fchips-gap`,"aria-hidden":!0}),m.clock&&(0,J.jsxs)(pE,{on:!!i.clock,title:i.clock?`show the items with no clock again`:`show only the ${r.clock} item${r.clock===1?``:`s`} waiting for an instant${i.status?` · ${i.status}`:``} — grouped by the clock they share, in the order they will run`,onClick:()=>{q(`action:backlog.filter.clock`),c()},children:[(0,J.jsx)(Ss,{size:12,"aria-hidden":!0}),uE(`on a clock`,{count:r.clock})]})]}),m.age.length>0&&(0,J.jsx)(`div`,{className:`fchips wrap`,children:m.age.map(e=>(0,J.jsx)(pE,{on:i.age===e,title:`show only ${i.status?`${i.status} `:``}items added ${e===`older`?`over a week ago`:`in the ${fW[e]}`}`,onClick:()=>{q(`action:backlog.filter.age`),o(e)},children:uE(fW[e],{count:r.age[e]})},e))}),m.category.length>0&&(0,J.jsx)(`div`,{className:`fchips wrap`,children:m.category.map(e=>{let t=e===`none`?null:XK[e];return(0,J.jsxs)(pE,{on:i.category===e,title:yW(e,i.category===e),onClick:()=>{q(`action:backlog.filter.category`),s(e)},children:[t&&(0,J.jsx)(t,{size:12,"aria-hidden":!0}),uE(vW[e],{count:r.category[e]})]},e)})})]}),a&&!i.ids&&(0,J.jsx)(tq,{m:e})]})}function tq({m:e}){let{base:t,clearFilter:n,cut:r,filter:i,idsLabel:a}=e;return(0,J.jsxs)(`div`,{className:`section filter-bar`,children:[(0,J.jsxs)(`span`,{className:`filter-bar-txt`,children:[TW(i,a),` · `,IW(r.length,t.length,i),r.length===0&&` — nothing here is in that cut`]}),(0,J.jsxs)(`button`,{className:`filter-bar-clear`,title:`clear the filter — show every item in this repo again`,onClick:()=>{q(`action:backlog.filter.clear`),n()},children:[(0,J.jsx)(V,{size:13}),` clear`]})]})}function nq({note:e,children:t}){return(0,J.jsxs)(`div`,{className:`bl-bulk-bar`,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsx)(`div`,{className:`bl-bulk`,children:t})]})}function xbe({m:e}){let{bulkClockIds:t,bulkDoneIds:n,bulkRunAgainAimed:r,bulkRunAgainIds:i,cut:a,focusWords:o,p:s,runAgainOffered:c}=e;return(0,J.jsxs)(J.Fragment,{children:[o&&s.auto&&(0,J.jsx)(`div`,{className:`bl-bulk-bar`,children:(0,J.jsx)(Z,{children:(0,J.jsx)(TE,{of:`when these run`,label:`when do these run?`,children:o})})}),o&&!s.auto&&(0,J.jsx)(nq,{note:o,children:(0,J.jsxs)(`button`,{className:`link-btn`,title:`turn the desktop's auto switch back on — the same switch as the chip in this sheet's head`,onClick:()=>{q(`action:backlog.auto.focus`),s.cutVerbs.onSetAuto(!0)},children:[(0,J.jsx)(yl,{size:14}),` `,`turn auto on`]})}),t.length>1&&s.online&&(0,J.jsx)(nq,{note:uG(t.length,a.length),children:(0,J.jsxs)(uT,{className:`link-btn`,confirm:`drop all ${t.length}?`,title:oG(`failed`),onConfirm:()=>{q(`action:backlog.dropclock.all`),s.cutVerbs.onDropClocks(t)},children:[(0,J.jsx)(tl,{size:14}),` `,lG(t.length)]})}),i.length>1&&(0,J.jsx)(nq,{note:bG(i.length,a.length,r),children:(0,J.jsxs)(uT,{className:`link-btn`,confirm:`run all ${i.length} again?`,title:bG(i.length,a.length,r),onConfirm:()=>{q(`action:backlog.runagain.all`),s.cutVerbs.onRunAgainMany(a.filter(e=>c(e)).map(e=>({id:e.id,failedAt:e.finishedAt})))},children:[(0,J.jsx)(Nc,{size:14}),` `,yG(i.length)]})}),n.length>1&&s.online&&(0,J.jsx)(nq,{note:RW(n.length,a.length),children:(0,J.jsxs)(uT,{className:`link-btn`,confirm:`archive all ${n.length}?`,title:`they keep their words and stay in show archived — any one of them comes back from its own row`,onConfirm:()=>{q(`action:backlog.archive.done`),s.cutVerbs.onArchiveMany(n)},children:[(0,J.jsx)(lo,{size:14}),` `,LW(n.length)]})})]})}function Sbe({m:e}){let{choosing:t,cut:n,displayOrder:r,nameIds:i,namingHere:a,p:o,picking:s,repoDir:c,retimeable:l,retimeClocks:u,retimeIds:d,setChoosing:f,setPicked:p,setPicking:m,slotCheckList:h,slotAskOff:g,now:_}=e,v=o.online&&!s&&!!o.cutVerbs.onSlotCheck&&h.length>0,y=o.online&&g,b=o.online&&!s&&l.length>1,x=e=>{q(`action:backlog.retime.clock`),p(new Set(e)),m(!0)},S=i.length>0&&o.online;return(0,J.jsxs)(J.Fragment,{children:[(b||S||v||y)&&(0,J.jsxs)(`div`,{className:`bl-bulk`,children:[b&&(0,J.jsxs)(`button`,{className:`link-btn`,title:`tick several rows and move them all to one new time`,onClick:()=>{q(`action:backlog.retime.pick`),m(!0)},children:[(0,J.jsx)(Cs,{size:14}),` `,`pick to re-time`]}),b&&u.map(e=>(0,J.jsxs)(`button`,{className:`link-btn`,title:`tick every row on this clock — then choose their new when`,onClick:()=>x(e.ids),children:[(0,J.jsx)(Ss,{size:14}),` `,dve(e)]},e.key)),v&&h.map(e=>(0,J.jsxs)(`button`,{className:`link-btn`,title:jK(e),onClick:()=>{q(`action:backlog.slotcheck`),o.cutVerbs.onSlotCheck?.(e)},children:[(0,J.jsx)(uo,{size:14}),` `,Lye(e,_)]},e.scope.key)),y&&(0,J.jsxs)(`button`,{className:`link-btn`,title:`after you post a timed row here that runs together with others, offer to check them as a group`,onClick:()=>{q(`action:backlog.slotask.on`),UK(c,!1),Dg(Pye(Rp(c)))},children:[(0,J.jsx)(Oo,{size:14}),` `,`ask after a timed send`]}),S&&(a?(0,J.jsx)(CE,{cants:[{label:EG(i.length),reason:`a naming pass is already running for this repo`}]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`backlog.name`,title:OG(i.length,n.length),onClick:()=>{q(`action:backlog.name`),o.cutVerbs.onName(c,i)},children:[(0,J.jsx)(Gl,{size:14}),` `,EG(i.length)]}),(0,J.jsxs)(TE,{of:`naming`,children:[OG(i.length,n.length),(0,J.jsx)(`div`,{className:`bl-cost`,children:`one short toolless call on the cheap model — reads the items' own words and nothing else`})]})]}))]}),o.online&&s&&(0,J.jsx)(`div`,{className:`bl-pick-bar`,children:(0,J.jsx)(WG,{picked:d.length,eligible:l.length,shown:r.length,where:`backlog`,onAll:()=>p(new Set(l.map(e=>e.id))),onNone:()=>p(new Set),onDone:()=>{m(!1),p(new Set)},onChoose:()=>f(!0)})}),t&&d.length>0&&(0,J.jsx)(GG,{children:o.nav.renderRetime(d,{onSent:()=>{f(!1),m(!1),p(new Set)},onCancel:()=>f(!1)})})]})}function Cbe({m:e,row:t}){let{beginEdit:n,fireIntoBusy:r,here:i,p:a,queuedHere:o,runAgainOffered:s}=e,{it:c}=t,l=r(c)?`${SM(!c.targetSessionId)} — ${CM}`:SM(!c.targetSessionId),u=FG(c,a.sessions,a.items);return(0,J.jsxs)(`div`,{className:`bl-actions`,children:[a.online&&(0,J.jsx)(Y,{title:`edit`,onClick:()=>n(c),children:(0,J.jsx)(us,{size:14})}),c.status===`queued`&&i&&i.cwd===c.repoDir&&a.online&&(o(c)?(0,J.jsxs)(Y,{className:`on`,"data-hint":`backlog.queuehere`,title:`waiting for ${i.title} — it goes in when that session is next free, whether or not the global auto switch is on. Tap to take it back off`,onClick:()=>{q(`action:backlog.unqueuehere`),a.verbs.onQueueHere(c.id,``)},children:[(0,J.jsx)(Kl,{size:14}),` waits for `,i.title]}):(0,J.jsxs)(Y,{"data-hint":`backlog.queuehere`,title:`hand it to ${i.title} — it goes to the bottom of that session's queue and runs when the session is next free, whether or not the global auto switch is on`,onClick:()=>{q(`action:backlog.queuehere`),a.verbs.onQueueHere(c.id,i.id)},children:[(0,J.jsx)(Kl,{size:14}),` when `,i.title,` is free`]})),c.at&&qK(c)&&a.online&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{title:`change its time — the send sheet, with this row already in it`,onClick:()=>{q(`action:backlog.editwhen`),a.verbs.onEditWhen(c.id)},children:[(0,J.jsx)(Ss,{size:14}),` when`]}),(0,J.jsxs)(uT,{confirm:`drop it?`,title:oG(c.status),onConfirm:()=>{q(`action:backlog.dropclock`),a.verbs.onDropClock(c.id,c.status)},children:[(0,J.jsx)(tl,{size:14}),` drop the clock`]})]}),u&&(0,J.jsxs)(Y,{"data-hint":`backlog.openholder`,title:u.title,onClick:()=>{q(`action:backlog.openholder`),u.itemId?(e.clearFilter(),e.showIds([u.itemId],u.cut??``)):a.nav.onOpenSession(u.sessionId)},children:[(0,J.jsx)(Go,{size:14}),` `,u.label]}),c.status===`queued`&&a.online&&(0,J.jsx)(Y,{className:c.manual?`primary`:void 0,"data-hint":`backlog.fire`,title:l,onClick:()=>{q(`action:backlog.fire`),a.verbs.onFire(c.id)},children:`fire`}),s(c)&&(0,J.jsxs)(Y,{"data-hint":`backlog.runagain`,title:dG(c),onClick:()=>{q(`action:backlog.runagain`),a.verbs.onRunAgain(c.id,c.finishedAt)},children:[(0,J.jsx)(Nc,{size:14}),` `,`run it again`]}),lW(c)&&a.online&&(0,J.jsx)(Y,{"data-hint":`backlog.refire`,title:l,onClick:()=>{q(`action:backlog.refire`),a.verbs.onFire(c.id)},children:`re-fire`}),c.sessionId&&(0,J.jsxs)(Y,{title:`go to the session it ran in`,onClick:()=>a.nav.onOpenSession(c.sessionId),children:[(0,J.jsx)(Go,{size:14}),` open`]}),(c.status===`done`||aW(c)||c.status===`running`)&&a.online&&(c.checkStatus===`checking`?(0,J.jsxs)(`span`,{className:`bl-waiting`,children:[(0,J.jsx)(Bl,{size:14}),` checking…`]}):(0,J.jsxs)(Y,{title:`check if implemented`,onClick:()=>a.verbs.onCheck(c.id),children:[(0,J.jsx)(Bl,{size:14}),` check`]})),(c.status===`done`||aW(c)||c.status===`running`)&&a.online&&(c.validateStatus===`validating`?(0,J.jsxs)(`span`,{className:`bl-waiting`,children:[(0,J.jsx)(Gl,{size:14}),` validating…`]}):(0,J.jsxs)(Y,{title:`validate the expected outcome & get next steps`,onClick:()=>a.verbs.onValidate(c.id),children:[(0,J.jsx)(Gl,{size:14}),` validate`]})),c.status===`running`&&a.online&&(0,J.jsx)(Y,{"data-hint":`backlog.done`,onClick:()=>{q(`action:backlog.done`),a.verbs.onDone(c.id)},children:`done`}),c.status!==`running`&&a.online&&(c.archived?(0,J.jsx)(Y,{title:`unarchive`,onClick:()=>a.verbs.onArchive(c.id,!1),children:(0,J.jsx)(_c,{size:14})}):(0,J.jsx)(Y,{title:`archive`,onClick:()=>a.verbs.onArchive(c.id,!0),children:(0,J.jsx)(lo,{size:14})})),a.online&&(0,J.jsx)(Y,{variant:`danger`,onClick:()=>{q(`action:backlog.remove`),a.verbs.onRemove(c.id)},children:(0,J.jsx)(V,{size:16})})]})}function wbe({m:e,row:t}){let{clockCuts:n,namingIds:r,nextFireIds:i,now:a,p:o,targetClosed:s,targetReopens:c}=e,{it:l}=t;return(0,J.jsxs)(`span`,{className:`bl-meta`,children:[(0,J.jsx)(`span`,{className:`tag-${cW(l)}`,children:sW(l)}),l.category&&(()=>{let e=XK[l.category];return(0,J.jsxs)(`span`,{className:`bl-chip bl-cat`,children:[(0,J.jsx)(e,{size:11,style:{verticalAlign:`-1px`}}),` `,l.category]})})(),r.has(l.id)&&(0,J.jsxs)(`span`,{className:`bl-chip bl-naming`,title:`a naming pass is reading this row's words right now`,children:[(0,J.jsx)(Gl,{size:11,style:{verticalAlign:`-1px`}}),` naming…`]}),(0,J.jsxs)(`span`,{className:`bl-age`,title:`added ${new Date(l.createdAt).toLocaleString()} (${fW[mW(l.createdAt,a)]})`,children:[`added `,Gp(l.createdAt)]}),l.status===`running`&&l.startedAt!=null&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`started ${new Date(l.startedAt).toLocaleString()}`,children:[`running `,AG(a-l.startedAt)]}),l.status!==`running`&&l.finishedAt!=null&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`finished ${new Date(l.finishedAt).toLocaleString()}`,children:[l.status===`failed`?sW(l):`finished`,` `,Gp(l.finishedAt),l.startedAt!=null&&l.finishedAt>=l.startedAt?` · took ${AG(l.finishedAt-l.startedAt)}`:``]}),l.checkedAt!=null&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`checked ${new Date(l.checkedAt).toLocaleString()}`,children:[`checked `,Gp(l.checkedAt)]}),l.validatedAt!=null&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`validated ${new Date(l.validatedAt).toLocaleString()}`,children:[`validated `,Gp(l.validatedAt)]}),(l.steps??1)>1&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`delivered one turn at a time, in one session`,children:[l.steps,` turns`]}),l.resume&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`it reopens this repo's last conversation instead of starting clean`,children:[(0,J.jsx)(kc,{size:11,style:{verticalAlign:`-1px`}}),` continued`]}),wK(l)&&CK(l.closeWhenDone)&&(0,J.jsxs)(`span`,{className:`bl-age`,children:[l.closeWhenDone?(0,J.jsx)(Ao,{size:11,style:{verticalAlign:`-1px`}}):(0,J.jsx)(ls,{size:11,style:{verticalAlign:`-1px`}}),` `,CK(l.closeWhenDone)]}),wK(l)&&l.flagWhenDone&&(0,J.jsxs)(`span`,{className:`bl-age fu-launch`,title:`its session gets the follow-up flag once it is done`,children:[(0,J.jsx)(dl,{size:11,style:{verticalAlign:`-1px`}}),` flag when done`]}),wK(l)&&l.status===`queued`&&UT(l.launch)&&(0,J.jsxs)(`span`,{className:`bl-age`,children:[`opens on `,HT(l.launch)]}),wK(l)&&l.budget&&(TK(l)&&o.online?(0,J.jsxs)(`button`,{className:`bl-age${e.budgetOpen.has(l.id)?` active`:``}`,"aria-pressed":e.budgetOpen.has(l.id),onClick:()=>e.toggleBudget(l.id),children:[(0,J.jsx)(El,{size:11,style:{verticalAlign:`-1px`}}),` `,sE(l.budget)]}):(0,J.jsxs)(`span`,{className:`bl-age`,children:[(0,J.jsx)(El,{size:11,style:{verticalAlign:`-1px`}}),` `,sE(l.budget)]})),l.at&&(0,J.jsxs)(`span`,{className:`bl-chip bl-clock`,title:`this one waits for an instant rather than for its turn — tap “when” to change it, or “drop the clock” to put it back in the queue`,children:[(0,J.jsx)(Ss,{size:11,style:{verticalAlign:`-1px`}}),` `,WW(l.at,a,l.status)]}),(()=>{let e=l.at?qW(n,l.id):null;if(!e)return null;let t=n.find(e=>e.items.some(e=>e.id===l.id)),r=t.items[e.idx-1]?.id,i=t.items[e.idx+1]?.id;return(0,J.jsxs)(`span`,{className:`bl-chip bl-clock-seat`,title:QW,children:[XW(e),o.online&&r&&(0,J.jsx)(`button`,{className:`bl-seat-move`,"aria-label":`run earlier on this clock`,title:`run it earlier on this clock — moves it among the items waiting on this same clock — the instant does not change, and it never crosses an item on a different clock`,onClick:()=>{q(`action:backlog.clock.up`),o.verbs.onSwap(l.id,r)},children:(0,J.jsx)(Ts,{size:11})}),o.online&&i&&(0,J.jsx)(`button`,{className:`bl-seat-move`,"aria-label":`run later on this clock`,title:`run it later on this clock — moves it among the items waiting on this same clock — the instant does not change, and it never crosses an item on a different clock`,onClick:()=>{q(`action:backlog.clock.down`),o.verbs.onSwap(l.id,i)},children:(0,J.jsx)(Bs,{size:11})})]})})(),l.holdForHost&&(0,J.jsxs)(`span`,{className:`bl-chip bl-hold`,title:`it waits for nothing else to be starting or running anywhere on this desktop — not just in this repo. This is the schedule vocabulary's “wait until free”, and dropping the clock does not drop it`,children:[(0,J.jsx)(Kl,{size:11,style:{verticalAlign:`-1px`}}),` `,nG(!!l.at&&qK(l)&&o.online)]}),xi(l,a)&&(o.online&&l.status===`queued`?(0,J.jsxs)(`button`,{className:`bl-chip bl-hold`,title:`you let this past the usage budget — it still waits its turn; tap to hold it for the budget again`,onClick:()=>{q(`action:backlog.holdforbudget`),o.verbs.onHoldForBudget(l.id)},children:[(0,J.jsx)(wl,{size:11,style:{verticalAlign:`-1px`}}),` `,iG(!0)]}):(0,J.jsxs)(`span`,{className:`bl-chip bl-hold`,title:`you let this past the usage budget — it still waits its turn; tap to hold it for the budget again`,children:[(0,J.jsx)(wl,{size:11,style:{verticalAlign:`-1px`}}),` `,iG(!1)]})),i.has(l.id)&&(0,J.jsxs)(`span`,{className:`bl-next`,title:`auto will run this one next`,children:[(0,J.jsx)(Hc,{size:10,style:{verticalAlign:`-1px`}}),` next`]}),s(l)&&(0,J.jsx)(`span`,{className:`bl-next`,title:`the session it was aimed at has exited — nothing re-aims it; edit it to pick another session, take the aim off, or remove it`,children:`target closed — held`}),c(l)&&(0,J.jsx)(`span`,{className:`bl-next`,title:`the session it was aimed at has exited, but this row remembers the conversation — at its time it reopens that conversation in a session of its own and sends the words there`,children:`session closed — reopens its conversation`}),(()=>{let e=o.nav.scheduleFor?.(l);return e?o.nav.onOpenSchedule?(0,J.jsxs)(`button`,{className:`bl-chip bl-merged`,title:`open the schedule “${e.name}” — the rule that wrote this row`,onClick:()=>{q(`action:backlog.fromschedule`),o.nav.onOpenSchedule(e.id,e.name)},children:[(0,J.jsx)(Ss,{size:11,style:{verticalAlign:`-1px`}}),` `,KL(e.name)]}):(0,J.jsxs)(`span`,{className:`bl-chip bl-merged`,children:[(0,J.jsx)(Ss,{size:11,style:{verticalAlign:`-1px`}}),` `,KL(e.name)]}):null})(),Ri(l.origin)&&(o.nav.onOpenWeekBurn?(0,J.jsxs)(`button`,{className:`bl-chip bl-merged`,title:`open the week-end burn — what picked this repo and wrote this row`,onClick:()=>{q(`action:backlog.fromweekburn`),o.nav.onOpenWeekBurn()},children:[(0,J.jsx)(Tc,{size:11,style:{verticalAlign:`-1px`}}),` `,`from the week-end burn`]}):(0,J.jsxs)(`span`,{className:`bl-chip bl-merged`,children:[(0,J.jsx)(Tc,{size:11,style:{verticalAlign:`-1px`}}),` `,`from the week-end burn`]})),l.handOrdered&&(0,J.jsxs)(`span`,{className:`bl-chip bl-hand`,title:`its position was decided by you — a drag, or an assessment ranking you approved`,children:[(0,J.jsx)(Ns,{size:11,style:{verticalAlign:`-1px`}}),` you placed this`]})]})}function Tbe({m:e,it:t}){let{editCategory:n,editHeadline:r,editLabel:i,editRepo:a,editTarget:o,editText:s,p:c,repoLabel:l,saveEdit:u,setEditCategory:d,setEditHeadline:f,setEditingId:p,setEditLabel:m,setEditRepo:h,setEditTarget:g,setEditText:_}=e,v=t.status===`running`;return(0,J.jsx)(`div`,{className:`bl-row bl-${t.status} bl-edit`,children:(0,J.jsxs)(`div`,{className:`form`,style:{width:`100%`},children:[(0,J.jsx)(uD,{inline:!0,rows:3,prompts:[s],onChange:e=>_(e[0]??``),placeholder:`Instruction…`}),(0,J.jsx)(`input`,{className:`search`,value:i,onChange:e=>m(e.target.value),placeholder:`Label (optional)`}),(0,J.jsx)(`input`,{className:`search`,value:r,maxLength:80,onChange:e=>f(e.target.value),placeholder:`Suggested title (optional)`}),(0,J.jsx)(Z,{children:TG(t.headlineBy)}),(0,J.jsxs)(`select`,{className:`search`,value:n,"aria-label":`kind`,onChange:e=>d(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`— none —`}),Xa.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))]}),v?(0,J.jsx)(Z,{as:`span`,children:l(a)}):(0,J.jsx)(ZO,{repos:c.repos,value:a,keepValue:!0,"aria-label":`repo`,onChange:e=>{h(e),g(``)}}),(()=>{let e=PG(c.sessions.filter(e=>e.running&&e.cwd===a),o);return e.length<2||v?null:(0,J.jsx)(`select`,{className:`search`,value:o,"aria-label":`session`,onChange:e=>g(e.target.value),children:e.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))})})(),(0,J.jsxs)(`div`,{className:`annot-tools`,children:[s.trim()&&c.online&&(0,J.jsx)(`button`,{className:`send`,onClick:()=>u(t),children:`Save`}),(0,J.jsx)(Y,{onClick:()=>p(null),children:`Cancel`})]}),!s.trim()&&(0,J.jsx)(Z,{children:`Nothing to save — type the task text.`}),v&&(0,J.jsx)(Z,{children:`Repo & session can't change while running.`}),!c.online&&(0,J.jsx)(Z,{children:`Offline — edits can't be saved until the connection is back.`})]})},t.id)}function Ebe({on:e,onSet:t}){return(0,J.jsx)(`div`,{className:`bl-close-chips`,children:(0,J.jsxs)(Y,{className:e?`active`:void 0,"aria-pressed":e,"data-hint":`session.followup`,onClick:()=>t(!e),children:[(0,J.jsx)(dl,{size:13,fill:e?`currentColor`:`none`}),` Flag for follow up when done`]})})}var Dbe=`A percent is converted from dollars at the window's measured rate once the session is running — until there is a fresh usage reading, nothing is held.`;function Obe({current:e,online:t,onSet:n,windowsOff:r}){let[i,a]=(0,H.useState)(e??null);if(!t)return(0,J.jsx)(`span`,{className:`bl-waiting`,children:`Changing the budget needs the desktop — the link is down.`});let o=!!i&&!!e&&i.unit===e.unit&&i.max===e.max&&i.interrupt===e.interrupt;return(0,J.jsxs)(`div`,{className:`bl-budget-edit`,children:[(0,J.jsx)($D,{initial:e??null,onChange:a,calFor:Dbe,windowsOff:r}),(0,J.jsxs)(`div`,{className:`bl-close-chips`,children:[i&&!o&&(0,J.jsxs)(Y,{className:`active`,onClick:()=>n(i),children:[(0,J.jsx)(El,{size:13}),` `,e?`change budget`:`set budget`]}),e&&(0,J.jsxs)(Y,{onClick:()=>n(null),children:[(0,J.jsx)(El,{size:13}),` clear budget`]})]})]})}function kbe({m:e,row:t}){let{fireIntoBusy:n,now:r,openDetail:i,openText:a,openValidate:o,p:s,runAgainHeld:c,runAgainOffered:l,setSlotOpen:u,slotOpen:d,slotSessions:f,targetLive:p,toggleDetail:m,toggleValidate:h}=e,{it:g,agentPosted:_}=t;return(0,J.jsxs)(J.Fragment,{children:[_&&a.has(g.id)&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:`posted by an agent — edit or delete it like any other`}),g.manual&&g.status===`queued`&&(0,J.jsx)(`span`,{className:`bl-hold`,children:`waits for your tap — nothing starts it by itself`}),g.at&&qK(g)&&s.online&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:oG(g.status)}),l(g)&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:dG(g)}),s.online&&g.status!==`running`&&(n(g)||g.status===`done`&&!l(g))&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:SM(!g.targetSessionId)}),c(g)&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:fG()}),g.requeued&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:xG(g.requeued,g.status,r)}),a.has(g.id)&&g.headline&&g.headlineBy&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:wG[g.headlineBy]}),g.status===`failed`&&g.error&&(0,J.jsx)(`span`,{className:g.calledOff?`bl-smart-note`:`bl-error`,children:g.error}),s.online&&g.status===`queued`&&s.waiting?.[g.id]&&!(EK(s.waiting[g.id],s.autoSlots)&&f.length>0)&&(p(g)&&/that session/i.test(s.waiting[g.id])?(0,J.jsx)(`button`,{className:`bl-waiting bl-waiting-act`,onClick:()=>s.nav.onOpenSession(g.targetSessionId),title:`go to the session this one is aimed at`,children:s.waiting[g.id]}):(0,J.jsx)(`span`,{className:`bl-waiting`,children:s.waiting[g.id]})),s.online&&g.status===`queued`&&EK(s.waiting?.[g.id],s.autoSlots)&&f.length>0&&(0,J.jsxs)(`div`,{className:`bl-slots`,children:[(0,J.jsxs)(Y,{className:`bl-step${d.has(g.id)?` active`:``}`,onClick:()=>u(e=>qG(e,g.id)),children:[(0,J.jsx)(Ao,{size:14}),` `,Tye(f.length)]}),d.has(g.id)&&(0,J.jsx)(`ul`,{className:`bl-slot-list`,children:f.map(({s:e,closeWhenDone:t})=>(0,J.jsxs)(`li`,{className:`bl-slot`,children:[(0,J.jsxs)(`button`,{className:`bl-slot-open`,onClick:()=>s.nav.onOpenSession(e.id),children:[(0,J.jsx)(`span`,{className:`bl-slot-title`,children:e.title}),(0,J.jsxs)(`span`,{className:`bl-slot-sub`,children:[`opened `,Gp(e.createdAt),` · `,Eye(e,t)]})]}),(0,J.jsxs)(Y,{variant:`danger`,onClick:()=>{q(`action:backlog.slotClose`),s.nav.onCloseSession(e)},children:[(0,J.jsx)(V,{size:14}),` close`]})]},e.id))})]}),a.has(g.id)&&wK(g)&&(0,J.jsxs)(`div`,{className:`bl-close-choice`,children:[(0,J.jsx)(`span`,{className:`bl-smart-note`,children:SK(g.closeWhenDone,s.closeWhenDoneGlobal)}),s.online?(0,J.jsx)(Bw,{label:`when this item is done`,options:yK.map(e=>({key:e,label:xK(e,s.closeWhenDoneGlobal)})),value:bK(g.closeWhenDone),onChange:e=>s.verbs.onSetCloseWhenDone(g.id,e)}):(0,J.jsx)(`span`,{className:`bl-waiting`,children:`Changing it needs the desktop — the link is down.`}),s.online&&(0,J.jsx)(Ebe,{on:!!g.flagWhenDone,onSet:e=>s.verbs.onSetFlagWhenDone(g.id,e)}),s.online&&TK(g)&&!g.budget&&(0,J.jsx)(`div`,{className:`bl-close-chips`,children:(0,J.jsxs)(Y,{className:e.budgetOpen.has(g.id)?`active`:void 0,"aria-pressed":e.budgetOpen.has(g.id),onClick:()=>e.toggleBudget(g.id),children:[(0,J.jsx)(El,{size:13}),` budget…`]})})]}),TK(g)&&e.budgetOpen.has(g.id)&&(0,J.jsx)(Obe,{current:g.budget,online:s.online,windowsOff:WT(s.backends??null,g.launch?.backend),onSet:t=>{s.verbs.onSetBudget(g.id,t),e.toggleBudget(g.id)}},`${g.id}:${g.budget?`${g.budget.unit}${g.budget.max}${g.budget.interrupt}`:`none`}`),a.has(g.id)&&(0,J.jsx)(`div`,{className:`bl-check-detail`,children:(0,J.jsx)(`div`,{className:`bl-steps`,children:s.online&&(0,J.jsxs)(Y,{className:`bl-step`,title:`open/resume a session seeded with this task as context`,onClick:()=>s.verbs.onContinue(g.id),children:[(0,J.jsx)(Go,{size:14}),` Continue in a session`]})})}),g.checkStatus&&(()=>{let e=g.checkStatus!==`checking`&&!!g.checkDetail,t=i.has(g.id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(e?`button`:`span`,{className:`bl-check bl-check-${g.checkStatus}`,title:e?`tap for full check details`:g.checkNote||``,onClick:e?()=>m(g.id):void 0,children:[(()=>{let e=JK(g.checkStatus).Icon;return(0,J.jsx)(e,{size:12,style:{verticalAlign:`-2px`}})})(),` `,JK(g.checkStatus).label,g.checkNote?` · ${g.checkNote}`:``,e?t?(0,J.jsx)(ac,{size:12,style:{verticalAlign:`-2px`}}):(0,J.jsx)(jl,{size:12,style:{verticalAlign:`-2px`}}):null]}),e&&t&&(0,J.jsxs)(`div`,{className:`bl-check-detail`,children:[(0,J.jsx)(`pre`,{children:g.checkDetail}),(0,J.jsx)(`div`,{className:`bl-steps`,children:s.online&&(0,J.jsxs)(Y,{className:`bl-step`,title:`open/resume a session with this task + verdict as context`,onClick:()=>s.verbs.onContinue(g.id),children:[(0,J.jsx)(Go,{size:14}),` Continue in a session`]})}),g.checkedAt&&(0,J.jsxs)(`span`,{className:`bl-check-when`,children:[`checked `,new Date(g.checkedAt).toLocaleString()]})]})]})})(),g.validateStatus&&(()=>{let e=g.validateStatus!==`validating`&&(!!g.validateDetail||!!g.validateSteps?.length),t=o.has(g.id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(e?`button`:`span`,{className:`bl-check bl-validate-${g.validateStatus}`,title:e?`tap for validation details & next steps`:g.validateNote||``,onClick:e?()=>h(g.id):void 0,children:[(()=>{let e=YK(g.validateStatus).Icon;return(0,J.jsx)(e,{size:12,style:{verticalAlign:`-2px`}})})(),` `,YK(g.validateStatus).label,g.validateNote?` · ${g.validateNote}`:``,e?t?(0,J.jsx)(ac,{size:12,style:{verticalAlign:`-2px`}}):(0,J.jsx)(jl,{size:12,style:{verticalAlign:`-2px`}}):null]}),e&&t&&(0,J.jsxs)(`div`,{className:`bl-check-detail`,children:[g.validateDetail&&(0,J.jsx)(`pre`,{children:g.validateDetail}),!!g.validateSteps?.length&&(0,J.jsxs)(`div`,{className:`bl-steps`,children:[(0,J.jsx)(`span`,{className:`bl-steps-head`,children:`Next steps — tap to run in the CLI:`}),g.validateSteps.map((e,t)=>s.online&&(0,J.jsxs)(Y,{className:`bl-step`,title:e.prompt,onClick:()=>s.verbs.onNextStep(g.id,t),children:[(0,J.jsx)(Go,{size:14}),` `,e.label]},t))]}),(0,J.jsx)(`div`,{className:`bl-steps`,children:s.online&&(0,J.jsxs)(Y,{className:`bl-step`,title:`open/resume a session with this task + verdict as context`,onClick:()=>s.verbs.onContinue(g.id),children:[(0,J.jsx)(Go,{size:14}),` Continue in a session`]})}),g.validatedAt&&(0,J.jsxs)(`span`,{className:`bl-check-when`,children:[`validated `,new Date(g.validatedAt).toLocaleString()]})]})]})})()]})}var rq=G(null);function Abe(){return K(rq)}function jbe(e,t=!1){W().conn.liveSend({t:`netretry.set`,enabled:e},Gr(e,t))}function iq(e,t){W().conn.liveSend({t:`session.netRetryCancel`,id:e},t?`hidden — stalled work keeps its note`:`retry cancelled — nothing more is typed`)}function aq(e){W().conn.liveSend({t:`session.netRetryNow`,id:e},vte)}function Mbe(){W().conn.liveSend({t:`netretry.set`,enabled:!1},`${Gr(!1)} — Settings › Sessions turns it back on`)}function oq({id:e,label:t,note:n,more:r}){let i=Abe();return i?(0,J.jsx)(eT,{id:e,label:t,icon:vl,on:i.envOff?i.enabled:ha(i),state:i.envOff?i.enabled?`saved on`:`saved off`:void 0,onChange:()=>jbe(!i.enabled,!!i.envOff),note:n,more:r,children:i.envOff&&(0,J.jsx)($w,{tone:`plain`,icon:Js,children:Dr()})}):null}function Nbe(e,t){if(e.state!==`running`||!e.sessionId)return null;let n=t.find(t=>t.id===e.sessionId),r=n?Cr(n):null;return!r||r.kind!==`auth`?null:r.phase===`needsYou`?Yee:r.detail??`stopped: the CLI is signed out — sign in, then continue`}function sq({state:e,sessionId:t,sessions:n}){let r=ur({state:e,sessionId:t},n);if(r&&t)return(0,J.jsx)(Pbe,{n:r,sessionId:t});let i=Nbe({state:e,sessionId:t},n);return i?(0,J.jsx)(`div`,{className:`net-stalled`,role:`status`,children:(0,J.jsxs)(`span`,{className:`netretry-line`,children:[(0,J.jsx)(ns,{size:14,"aria-hidden":`true`}),` `,i]})}):null}function Pbe({n:e,sessionId:t}){let n=_E(3e4);return(0,J.jsxs)(`div`,{className:`net-stalled`,role:`status`,children:[(0,J.jsxs)(`span`,{className:`netretry-line`,children:[(0,J.jsx)(vl,{size:14,"aria-hidden":`true`}),` `,Ta(e,n)]}),(0,J.jsx)(Z,{children:e.error}),(0,J.jsx)(`div`,{className:`net-stalled-verbs`,children:(0,J.jsxs)(Y,{title:Lte,onClick:()=>aq(t),children:[(0,J.jsx)(Kc,{size:14,"aria-hidden":`true`}),` retry now`]})}),(0,J.jsx)(oq,{label:`auto-retry`,note:`The desktop's own switch (Settings › Sessions): on, it retries the next give-up by itself and tries this stalled one again on a slow clock (the note says when); off, this row waits for retry now or your typing.`})]})}function Fbe({m:e,g:t,it:n,idx:r}){let{canDrag:i,clockCuts:a,dragId:o,editingId:s,filter:c,now:l,openText:u,p:d,picked:f,picking:p,setDragId:m,setPicked:h,drawSort:g,toggleText:_}=e,v=g===`run`?t.items[r-1]?.id:void 0,y=g===`run`?t.items[r+1]?.id:void 0,b={it:n,idx:r,g:t,up:v,down:y,agentPosted:Mi(n)};if(s===n.id)return(0,J.jsx)(Tbe,{m:e,it:n});let x=(()=>{if(!c.clock||!n.at)return null;let e=GW(n),r=a.find(t=>t.key===e);return!r||t.items.find(t=>GW(t)===e)?.id!==n.id?null:(0,J.jsxs)(`div`,{className:`bl-group-head bl-clock-head`,children:[(0,J.jsxs)(`span`,{className:`bl-group-title`,children:[(0,J.jsx)(Ss,{size:13}),` `,ZW(r,l)]}),(0,J.jsx)(`span`,{className:`bl-group-meta`,children:`in this order`})]})})();return(0,J.jsxs)(H.Fragment,{children:[x,(0,J.jsxs)(`div`,{"data-blid":n.id,className:`bl-row bl-${cW(n)} ${o===n.id?`dragging`:``}`,children:[(0,J.jsxs)(`div`,{className:`bl-head`,children:[p&&IG(n)&&(0,J.jsx)(KG,{on:f.has(n.id),onToggle:()=>h(e=>qG(e,n.id))}),(0,J.jsx)(`span`,{className:`bl-num`,children:t.seats.get(n.id)??r+1}),(0,J.jsxs)(`div`,{className:`bl-main`,children:[(()=>{let e=jG(n);if(e)return(0,J.jsx)(`span`,{className:`bl-label`,children:e});let t=zn(n);if(!t)return null;let r=n.headlineBy!==`hand`;return(0,J.jsxs)(`span`,{className:`bl-label${r?` bl-headline`:``}`,children:[r?(0,J.jsx)(Gl,{size:11}):null,r?` `:``,t]})})(),(0,J.jsx)(`button`,{className:`bl-text bl-text-btn ${u.has(n.id)?`open`:``}`,title:u.has(n.id)?`collapse`:`expand — full task & continue in a session`,onClick:()=>_(n.id),children:n.text}),(()=>{let e=pt(n.text).filter(e=>!/[<>*{}]/.test(e));return e.length?(0,J.jsx)(`div`,{className:`bl-thumbs`,children:e.map(e=>{let t=d.nav.imageSrc(n.repoDir,e);return t?(0,J.jsx)(`button`,{className:`bl-thumb`,title:`view & mark ${e}`,onClick:()=>d.verbs.onEditImage(n,e),children:(0,J.jsx)(`img`,{src:t,alt:``,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.hidden=!0}})},e):null})}):null})(),(0,J.jsx)(wbe,{m:e,row:b}),(0,J.jsx)(kbe,{m:e,row:b}),(0,J.jsx)(sq,{state:n.status,sessionId:n.sessionId,sessions:d.sessions})]}),(0,J.jsxs)(`div`,{className:`bl-order`,children:[i&&(0,J.jsx)(Y,{className:`drag-handle`,title:`drag to reorder`,style:{touchAction:`none`,cursor:`grab`},onPointerDown:e=>{e.preventDefault(),m(n.id)},children:(0,J.jsx)(Ko,{size:14})}),v&&d.online&&(0,J.jsx)(Y,{onClick:()=>d.verbs.onSwap(n.id,v),title:`move up`,children:(0,J.jsx)(Ts,{size:14})}),y&&d.online&&(0,J.jsx)(Y,{onClick:()=>d.verbs.onSwap(n.id,y),title:`move down`,children:(0,J.jsx)(Bs,{size:14})})]})]}),(0,J.jsx)(Cbe,{m:e,row:b})]})]},n.id)}function Ibe({m:e}){let{base:t,displayOrder:n,dragId:r,groups:i,hereInRepo:a,q:o}=e;return(0,J.jsxs)(`div`,{className:`list`,style:{touchAction:r?`none`:void 0},children:[n.length===0&&(0,J.jsx)($,{children:t.length===0?`Nothing waiting for this repo — “send…” above writes one.`:o?`No match in this repo.`:`Nothing here matches that filter — ${t.length} item${t.length===1?``:`s`} are hidden by it.`}),i.map(t=>(0,J.jsxs)(`div`,{className:`bl-group`,children:[(0,J.jsxs)(`div`,{className:`bl-group-head`,children:[(0,J.jsxs)(`span`,{className:`bl-group-title`,children:[t.key===`__closed`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ec,{size:13}),` `,t.title]}):t.key?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Go,{size:13}),` `,t.title]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(yl,{size:13}),` `,t.title]}),a&&t.key===a.id&&(0,J.jsx)(yE,{className:`bl-here`,children:`on screen`})]}),(0,J.jsx)(`span`,{className:`bl-group-meta`,children:`${t.items.length} item${t.items.length===1?``:`s`}`})]}),t.key===`__closed`&&(0,J.jsx)(`div`,{className:`empty bl-group-empty`,children:`The session each of these was aimed at has exited. Nothing re-aims them: edit one to pick another session or a new one, take the aim off, or remove it.`}),t.items.map((n,r)=>(0,J.jsx)(Fbe,{m:e,g:t,it:n,idx:r},n.id))]},t.key||`__default`))]})}function Lbe({m:e}){let{filter:t}=e;return(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[t.ids&&(0,J.jsx)(tq,{m:e}),(0,J.jsx)(mbe,{m:e}),(0,J.jsx)(hbe,{m:e}),(0,J.jsx)(gbe,{m:e}),(0,J.jsx)(_be,{m:e}),(0,J.jsx)(bbe,{m:e}),(0,J.jsx)(Sbe,{m:e}),(0,J.jsx)(xbe,{m:e}),(0,J.jsx)(Ibe,{m:e})]},t.ids?t.ids.join(`,`):``)}function Rbe(e){let t=abe(),n=lbe(e),r=ube(),i=dbe(),a=_E(3e4),o=sbe(e),s=ibe(e,a,{...n,...r},i.picked),c=obe(e,s),l={p:e,now:a,...t,...n,...r,...i,...o,...s,...c};return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(pbe,{m:l}),(0,J.jsx)(Lbe,{m:l})]})}function zbe(e){return e===`idle`?`When free`:`Send`}function Bbe(e){return e===`idle`?`Hand it to the desktop and let it go in when this session is free — turn ended, no question open, no usage-limit block`:`Send to this session`}function cq(e,t){return e===`now`?null:t.holder===`phone`?t.phoneHold===`opens-a-view`?t.online?`held on this phone — it opens a view rather than starting a turn, so it goes in when this turn ends. Leave the app open`:`held on this phone — it goes in when the link is back and this turn has ended. Leave the app open`:t.online?`queued — it runs in this session when it opens`:`queued — the session opens and runs this when the link is back`:t.online?`queued on the desktop — it goes in when this session is free`:`queued — it reaches the desktop when the link is back, and goes in when this session is free`}var Vbe=`kept on the pad — nothing runs it; open the pad to send it or file it onto a backlog`,Hbe=`nothing in the box to keep — the pad holds words, and there are none yet`;function Ube(){return[{key:`now`,label:`now`,icon:`send`,mode:`now`,title:`type it into this session straight away`},{key:`idle`,label:`when it's free`,icon:`hourglass`,mode:`idle`,title:`the desktop holds it and types it in when this session can take it — turn ended, no question open, no usage-limit block`},{key:`pad`,label:`keep it on the pad`,icon:`pad`,mode:null,title:`park the words on the pad — nothing runs them, no backlog, no trigger; you decide later whether they go anywhere`},{key:`elsewhere`,label:`elsewhere or later…`,icon:`elsewhere`,mode:null,title:`a different session, a new one, several repos — or at a time`}]}var Wbe=`Runs in`;function lq(){return[{key:`this`,label:`this session`,title:`the conversation on screen — it already knows what you have said in it, and every turn pays for that whole window again`},{key:`new`,label:`a new session`,title:`open a fresh session in this repo and run it there — none of this conversation comes with it, which is what makes it cheaper`},{key:`other`,label:`another open session`,title:`one of the other sessions running right now — pick which one below`}]}function Gbe(e){return lq().find(t=>t.key===e)?.label??`this session`}function Kbe(e,t){if(e===`this`)return null;if(e===`new`)return`Send opens a NEW session in ${t.repoName||`this repo`} — not the conversation on screen.`;let n=(t.sessionName??``).trim();return n?`Send goes to ${n} — not the conversation on screen.`:`Send is aimed at another session and none is picked — choose one under the chevron, or aim it back here.`}var qbe=`aim it here`,Jbe=`no session picked — choose one under the chevron, or aim it back at this session`;function Ybe(e){let t=(e??``).trim();return`${t?`“${t}”`:`that session`} has closed — nothing was sent, and the aim is back on this session`}function Xbe(e,t,n){if(t===`this`)return Bbe(e);if(t===`new`)return e===`idle`?`Open a fresh session in this repo and run it there when this repo is free — not the conversation on screen`:`Open a fresh session in this repo and run it there — not the conversation on screen`;let r=(n??``).trim()||`another open session`;return e===`idle`?`Hand it to the desktop and let it go in when ${r} is free — not the conversation on screen`:`Send it to ${r} — not the conversation on screen`}function Zbe(e){return e.how!==`now`||e.explicit||!e.aimedHere||!e.turnActive||e.pending||e.localCmd?e.how:e.pref===``?`ask`:e.pref}var uq={title:`This session is still working`,lines:[`Send now: claude queues the words and takes them at its next pause — after the command it is running, which can be minutes.`,`When it's free: the desktop holds them and sends them once this turn ends.`,`Tap outside to keep the words in the box.`],confirmLabel:`Send now`,cancelLabel:`When it's free`,rememberLabel:`don't ask again`},Qbe=`When it's free, past the budget`;function $be(e){if(!e)return{...uq,lines:[...uq.lines]};let[t,n,r]=uq.lines;return{...uq,lines:[t,`${n} The usage budget holds it after that: ${e}.`,`When it's free, past the budget: the same, but this prompt does not wait for the budget.`,r],altLabel:Qbe}}function exe(e){return e?`queued past the budget — the desktop sends it once this turn ends`:`queued past the budget — it reaches the desktop when the link is back, then goes in once this session is free`}function txe(e){return e===`idle`?`won't ask again — Send on a working session now waits until it is free; Settings › Writing & reading › Send while it works changes it`:`won't ask again — Send on a working session now goes straight in; Settings › Writing & reading › Send while it works changes it`}function nxe(e){return Ar(e.name,Ka(e.action))??(e.name.length>40?`${e.name.slice(0,40)}…`:e.name)}function rxe(e){let t=new Map,n=new Map;for(let r of e){let e={id:r.id,name:nxe(r)};t.set(r.id,e);let i=r.lastResult?.childId;i&&n.set(i,e)}return{byId:t,byChild:n}}function ixe(e,t){let n=new Map,r=new Map;for(let i of e){if(!ga(i))continue;let e=t(i),a={id:i.id,name:e.length>40?`${e.slice(0,40)}…`:e};n.set(i.id,a);let o=i.result?.childId;o&&r.set(o,a)}return{byId:n,byChild:r}}function axe(e){return e?`reading the repo to judge ${e.length===1?`this one`:`these ${e.length}`} — this takes a while; the proposal lands here`:`reading the repo — this takes a while; the proposal lands here`}function oxe(e){return`queued — ${e===1?`it goes`:`all ${e} go`} back in the queue when the link is back`}var dq={repoDir:null,text:``,filter:SW,idsLabel:void 0};function fq(e,t){return{...e,repoDir:t,filter:e.filter.ids?{...e.filter,ids:null}:e.filter,idsLabel:void 0}}function sxe(e,t){return!t||t===e.repoDir?e:fq(e,t)}function cxe(e,t,n,r){return n?.length?{...e,repoDir:t,filter:{...SW,ids:n},idsLabel:r??`made from these`}:{...e,repoDir:t,filter:SW,idsLabel:void 0}}function lxe(e){return{...dq,repoDir:e.repoDir}}function uxe(){let e=EE(B.snapBacklog,{});return{items:e.items??[],auto:e.auto??!1,waiting:{},naming:[],autoSlots:null,snapAt:e.at??null}}var pq=G(uxe()),mq=G(dq),hq=G(new Map),gq=G(null),_q=G(null),vq=G(null),yq=G(new Map);function dxe(){return K(pq)}function fxe(e){let t=Date.now();pq.set({items:e.items,auto:e.auto,waiting:e.waiting??{},naming:e.naming??[],autoSlots:e.autoSlots??null,snapAt:t}),DE(B.snapBacklog,{items:e.items,auto:e.auto,idleMs:e.idleMs,at:t}),Zye(e.items)}function pxe(e,t){let n=W().nav.overlay;hq.set(r=>{let i=r.get(e);return t&&i&&n!==`assess`&&i.runId===t.runId&&i.status===`running`&&t.status===`running`?r:t?yh(r,e,t):bh(r,e)})}function mxe(){W().conn.send({t:`assess.state`})}function bq(e,t){yq.set(yh(yq.get(),e,t))}function hxe(e,t,n,r){let i=yq.get().get(e);if(i===void 0||(yq.set(bh(yq.get(),e)),!t||!i.length))return;let a=hye(i,n);a.clear.length&&r(a.clear);let o=gye(a);o&&W().say.toast(o)}function gxe(e){mq.set(t=>fq(t,e.worktreePath)),W().nav.open(`backlog`)}function _xe(e){mq.set(t=>sxe(t,e)),W().nav.open(`backlog`)}function xq(e,t,n){mq.set(r=>cxe(r,e,t,n)),W().nav.open(`backlog`)}function vxe(e){mq.set(e)}function yxe(){mq.set(lxe)}function Sq(e,t){let n=W(),r=e.worktreePath;gq.set(e),_q.set(t?.length?t:null),vq.set(null),n.conn.liveAsk({t:`assess.state`,repoDir:r}),n.nav.open(`assess`),!hq.get().get(r)&&Cq(r,t)}function Cq(e,t,n){let r=W();r.say.track(`action:assess.run`);let i=r.queue.mintAckId(),a=t?.length?t:void 0,o=a&&n?{scope:n}:{};r.conn.liveSend({t:`assess.run`,repoDir:e,ids:a,...o,ackId:i,firstSentAt:Date.now()},axe(a),`no connection — the assessment runs on the desktop`)&&bq(i,[])}function bxe(e,t){let n=W();n.say.track(`action:assess.apply`);let r=n.queue.mintAckId(),i=t.news??[],a=(e.proposal?.news??[]).filter((e,t)=>i.includes(t)&&e.fromNote).map(e=>e.fromNote);n.conn.liveSend({t:`assess.apply`,runId:e.runId,choices:t,ackId:r,firstSentAt:Date.now()},`applying your decisions…`,`no connection — applying starts work on the desktop and can't be queued from here`)&&bq(r,a)}function wq(e){let t=W(),n=t.world.repos.find(t=>t.worktreePath===e.repoDir)??t.world.repoForCwd(e.repoDir);if(!n){t.say.toast(`that repo is not on this desktop's list any more`);return}let r=n.worktreePath;gq.set(n),_q.set([...e.ids]),vq.set(e.scope),t.conn.liveAsk({t:`assess.state`,repoDir:r}),t.nav.open(`assess`);let i=Kye(hq.get().get(r),e);if(i===`run`){Cq(r,e.ids,e.scope);return}let a=qye(i,e.ids.length);a&&t.say.toast(a)}function xxe(){gq.set(null),_q.set(null),vq.set(null),W().nav.close(`assess`)}function Sxe(e,t){let n=W(),r=Tq(n,e,t,n.world.intents.find(t=>t.id===e));n.say.toast(r?`queued — it goes back in the queue when the link is back`:pG)}function Cxe(e){let t=W(),n=!1;for(let{id:r,failedAt:i}of e)n=Tq(t,r,i,t.world.intents.find(e=>e.id===r))||n;t.say.toast(n?oxe(e.length):mG(e.length))}function Tq(e,t,n,r){return e.queue.queueOp({t:`intent.requeue`,id:t,failedAt:n},`intent:${t}`,r?.label||r?.title||`run it again`,{cwd:r?.cwd})}function wxe(){let e=_h(),{liveSend:t,liveSendAll:n}=e.conn,{queueOp:r}=e.queue,{intents:i,sessions:a,visibleRepos:o,active:s,pending:c,budget:l,schedules:u}=e.world,d=e.conn.status===`open`,f=K(pq),p=K(mq),m=K(hq),h=K(yq),g=oy(`closeWhenDone`),{cwdVisible:_}=e.world,v=(0,H.useMemo)(()=>f.items.filter(e=>_(e.repoDir)),[f.items,_]),y=(0,H.useMemo)(()=>rxe(u),[u]),b=fh(`weekburn`,()=>U.getWeekBurn()),x=(0,H.useMemo)(()=>ixe(i,VH),[i]),S=t=>e.world.repos.find(e=>e.worktreePath===t)?.id;return(0,J.jsx)(Rbe,{items:v,auto:f.auto,repos:o,backends:e.world.backends,waiting:f.waiting,autoSlots:d?f.autoSlots:null,closeWhenDoneGlobal:g,intents:i,naming:d?f.naming:[],snapAt:f.snapAt,online:d,cut:p,setCut:vxe,activeSession:s&&!c?{id:s.id,cwd:s.cwd,title:s.title||`this session`}:null,sessions:a,defaultRepoDir:s?.cwd,verbs:{onSetCloseWhenDone:(e,n)=>t({t:`backlog.update`,id:e,closeWhenDone:bye(n)},Cye(n,g),bW),onSetFlagWhenDone:(e,n)=>t({t:`backlog.update`,id:e,flagWhenDone:n?!0:null},n?`its session gets the follow-up flag once it is done`:`no follow-up flag when it is done`,bW),onSetBudget:(e,n)=>t({t:`backlog.update`,id:e,budget:n},n?`its session will start with that budget`:`no budget on its session`,bW),onDropClock:e=>t({t:`intent.update`,id:e,patch:{trigger:{kind:`idle`}}},sG,bW),onHoldForBudget:e=>t({t:`intent.waive`,id:e,rung:`budget`,on:!1},aG,bW),onRunAgain:Sxe,onEditWhen:t=>{let n=i.find(e=>e.id===t);n?e.nav.openSend(e.send.seedFromIntent(n)):e.say.toast(`that row is gone`)},onRemove:e=>t({t:`backlog.remove`,id:e},`removed`,bW),onUpdate:(e,n)=>t({t:`backlog.update`,id:e,...n},`saved`,bW),onQueueHere:(e,n)=>t({t:`backlog.update`,id:e,targetSessionId:n,autoFire:!!n},n?cq(`idle`,{online:d,holder:`desktop`}):`taken off this session's queue`,bW),onSwap:(e,n)=>t({t:`backlog.swap`,id:e,otherId:n},`reordered`,bW),onFire:n=>{t({t:`backlog.fire`,id:n},`running it now…`,`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`)&&e.nav.followFire(n)},onDone:e=>t({t:`backlog.done`,id:e},`marked done`,bW),onArchive:(e,n)=>t({t:`backlog.archive`,id:e,archived:n},n?`archived`:`unarchived`,bW),onCheck:e=>t({t:`backlog.check`,id:e},`checking…`,bW),onValidate:e=>t({t:`backlog.validate`,id:e},`validating…`,bW),onNextStep:(n,r)=>{t({t:`backlog.nextStep`,id:n,step:r},`firing the next step…`,`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`)&&e.nav.followFire(n)},onContinue:n=>{t({t:`backlog.continue`,id:n},`continuing…`,`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`)&&e.nav.followFire(n)},onEditImage:e.files.editBacklogImage},cutVerbs:{onDropClocks:e=>n(e.map(e=>({t:`intent.update`,id:e,patch:{trigger:{kind:`idle`}}})),cG(e.length),bW),onRunAgainMany:Cxe,onName:(t,n)=>{let i=r({t:`backlog.name`,repoDir:t,ids:n},`name:${t}`,EG(n.length),{cwd:t});e.say.toast(i?`Queued · ${kG(EG(n.length))}`:kG(EG(n.length)))},onReorder:e=>t({t:`backlog.reorder`,ids:e},`order saved`,bW),onSetAuto:e=>t({t:`backlog.setAuto`,enabled:e},`auto ${e?`on`:`off`}`,bW),onArchiveMany:e=>n(e.map(e=>({t:`backlog.archive`,id:e,archived:!0})),zW(e.length),bW),onAssess:(e,t)=>{let n=o.find(t=>t.worktreePath===e);n&&Sq(n,t)},onSlotCheck:e=>wq(e),assessBlocked:e=>m.get(e)??null?null:gK({run:null,online:d,busy:h.size>0,budgetNote:l?.verdict.blocked?Gi(l.verdict):null})},nav:{onCloseSession:e.nav.closeSession,scheduleFor:e=>{let t=Pi(e.origin);return(t?y.byId.get(t):void 0)??y.byChild.get(e.id)??(t?x.byId.get(t):void 0)??x.byChild.get(e.id)??null},onOpenSchedule:(t,n)=>{if(y.byId.has(t)){e.nav.openScheduleCut([t],qL(n));return}let r=i.find(e=>e.id===t);r?xq(r.cwd,[t],YL(n)):e.say.toast(`that schedule is no longer on the desktop`)},onOpenWeekBurn:()=>e.nav.open(`weekburn`),onOpenCut:(e,t,n)=>xq(e,t,n),weekBurnText:e=>rK({repoDir:e,weekburn:b.state===`fresh`?b.data:null,when:Pe,repoName:e=>{let t=o.find(t=>t.worktreePath===e);return t?Wn(t):e.split(/[/\\]/).filter(Boolean).pop()||e}})?.text??null,renderRetime:e.send.renderRetime,onClose:()=>e.nav.close(`backlog`),onOpenSend:(t,n)=>{let r=o.find(e=>e.worktreePath===t);e.nav.openSend({prompts:n?[n]:void 0,target:{kind:`repo`,cwd:t},when:{kind:`idle`},cwdHint:t,repoId:r?.id??null,origin:n?`Kept from the backlog's old add field`:`From the backlog`})},onOpenSession:t=>{let n=a.find(e=>e.id===t);n&&e.nav.attach(n)},imageSrc:(e,t)=>{let n=S(e);return n?(bj(n,t),sg(U.artifactUrl(n,t),ag(72),gj(n,t))):null}}})}var Eq=new Map,Dq=e=>({rows:[...e.rows],merges:[...e.merges],news:[...e.news],rejected:[...e.rejected],pinRanks:e.pinRanks===!0,writeNames:e.writeNames===!0,...e.splits?{splits:[...e.splits]}:{}});function Oq(e){if(!e)return null;let t=Eq.get(e);return t?Dq(t):null}function Txe(e,t){e&&Eq.set(e,Dq(t))}function kq(e){Eq.delete(e)}function Exe(e){let t=e.run,n=t?.proposal??null,r=(0,H.useMemo)(()=>t?.input?.items??[],[t]),i=t?.runId,[a,o]=(0,H.useState)(()=>new Set(Oq(i??``)?.rows??[])),[s,c]=(0,H.useState)(()=>new Set(Oq(i??``)?.merges??[])),[l,u]=(0,H.useState)(()=>new Set(Oq(i??``)?.news??[])),[d,f]=(0,H.useState)(()=>new Set(Oq(i??``)?.rejected??[])),[p,m]=(0,H.useState)(()=>new Set(Oq(i??``)?.splits??[])),[h,g]=(0,H.useState)(()=>new Set),_=(0,H.useRef)(i);(0,H.useEffect)(()=>{if(_.current===i)return;let e=_.current;_.current=i,e&&kq(e),o(new Set),c(new Set),u(new Set),f(new Set),m(new Set),g(new Set)},[i]);let v=(0,H.useMemo)(()=>n?Kve(n,r):[],[n,r]),y=(0,H.useMemo)(()=>n?ee(n):null,[n]),b=(0,H.useMemo)(()=>zye(n,r),[n,r]),x=(0,H.useMemo)(()=>Gye(n,r),[n,r]),S=(0,H.useMemo)(()=>{let e=new Map;for(let t of r)t?.id&&e.set(t.id,t);return e},[r]),C=_E(t?.status===`running`?1e3:6e4),w=yye(t,C),[T,E]=(0,H.useState)(!1),D=t&&t.status!==`running`?t.progress:void 0,O=eye({rows:a,merges:s,news:l,splits:p}),[k,A]=(0,H.useState)(!1),j=_ye({run:t,picked:O,online:e.online,busy:e.busy}),M=gK({run:t,online:e.online,busy:e.busy,budgetNote:e.budgetNote}),N=e.scope?.length??0,P=(0,H.useMemo)(()=>n?n.rows.filter(e=>e.verdict===`wanted`&&e.rank!=null&&a.has(e.id)).length+s.size+l.size:0,[n,a,s,l]),[F,I]=(0,H.useState)(()=>Oq(i??``)?.pinRanks??!0),te=(0,H.useMemo)(()=>n?Lt(n):0,[n]),[ne,re]=(0,H.useState)(()=>Oq(i??``)?.writeNames??!0);(0,H.useEffect)(()=>{i&&Txe(i,{rows:[...a],merges:[...s],news:[...l],rejected:[...d],pinRanks:F,writeNames:ne,...p.size?{splits:[...p]}:{}})},[i,a,s,l,d,F,ne,p]);let ie=e=>{o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),f(t=>{let n=new Set(t);return n.delete(`row:${e}`),n})},ae=e=>{c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),f(t=>{let n=new Set(t);return n.delete(`merge:${e}`),n})},oe=e=>{u(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),f(t=>{let n=new Set(t);return n.delete(`new:${e}`),n})},se=(e,t)=>{f(n=>{let r=new Set(n);return r.delete(e)||(r.add(e),t()),r})},ce=(t,n)=>{let r=t.rows.filter(e=>!e.acceptBlocked);if(!r.length)return;if(r.every(e=>a.has(e.id))){q(`action:assess.untick.${t.verdict}`),o(e=>{let n=new Set(e);for(let e of t.rows)n.delete(e.id);return n});return}q(`action:assess.bulk.${t.verdict}`);let i=()=>{o(e=>{let t=new Set(e);for(let e of r)t.add(e.id);return t}),f(e=>{let t=new Set(e);for(let e of r)t.delete(`row:${e.id}`);return t})},s=n.ask;!n.confirm||!s?i():(async()=>{await mT({title:s.title,lines:Yve(r,{repoName:e.repoName,verdict:t.verdict}),confirmLabel:s.confirmLabel})&&i()})()},le=t=>{q(`action:assess.merge`),s.has(t.gid)?ae(t.gid):(async()=>{await mT({title:`Replace ${t.originals.length||t.ids.length} items with one prompt?`,lines:Qve(t,{repoName:e.repoName}),confirmLabel:`Approve the merge`})&&ae(t.gid)})()},ue=e=>{m(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),f(t=>{let n=new Set(t);return n.delete(`split:${e}`),n})},de=t=>{q(`action:assess.split`),p.has(t.sid)?ue(t.sid):(async()=>{await mT({title:`Split this item in two?`,lines:Yye(t,e.repoName),confirmLabel:`Approve the split`})&&ue(t.sid)})()},fe=()=>{q(`action:assess.apply`),e.onApply(Jye({rows:a,merges:s,news:l,splits:p,pinRanks:P>0?F:void 0,writeNames:te>0?ne:void 0})),i&&kq(i)},pe=e.res??{state:e.online?t?`fresh`:`loading`:`offline`},me=!n||!(n.rows.length+n.merges.length+n.news.length+x.length+b.length),he=t?.finishedAt??t?.startedAt,ge=t?.planPath,_e=n?nye(n,{rows:[...a],merges:[...s],news:[...l]},r):null,ve=_e?rye(_e,e.repoName,{writeNames:te>0&&ne,ranked:P,pinRanks:F,splits:p.size}):``,ye=(0,H.useMemo)(()=>t?.applied&&e.onOpenBacklog?oye(t,e.backlog??[]):null,[t,e.backlog,e.onOpenBacklog]),be=N&&e.slot?MK(N,!!t):N?`${t?`run again on`:`assess`} ${N===1?`this one`:`these ${N}`}`:t?`run again`:`assess`;return{conflicts:b,splits:x,pickedSplits:p,setPickedSplits:m,acceptSplit:de,slotIntro:Rye(t?.scope,t?.scopedIds?.length,C),p:e,run:t,proposal:n,items:r,runId:i,pickedRows:a,setPickedRows:o,pickedMerges:s,setPickedMerges:c,pickedNews:l,setPickedNews:u,rejected:d,setRejected:f,flipped:h,setFlipped:g,seeded:_,groups:v,counts:y,itemsById:S,now:C,watch:w,logOpen:T,setLogOpen:E,pastSteps:D,picked:O,guideOpen:k,setGuideOpen:A,applyBlocked:j,runBlocked:M,scopeN:N,rankedN:P,pinRanks:F,setPinRanks:I,nameCount:te,writeNames:ne,setWriteNames:re,toggleRow:ie,toggleMerge:ae,toggleNew:oe,toggleReject:se,bulkGroup:ce,acceptMerge:le,apply:fe,res:pe,nothing:me,finishedAt:he,planPath:ge,applySummary:_e,applyLabel:ve,ready:ye,runLabel:be,guide:$ve({repoName:e.repoName,judged:t?.assessableCount??n?.rows.length??0,planPath:ge||void 0,named:te})}}var Aq=G(null);function Dxe(){return K(Aq)}function jq(e){let t=W();Aq.set(Kce(e)?e:null),t.say.track(`action:settings.door`),t.nav.open(`settings`)}var Mq={done:`tag-done`,obsolete:`tag-done`,superseded:`tag-done`,merged:`tag-running`,wanted:`tag-queued`,unclear:`queued`},Oxe={running:`tag-running`,done:`tag-queued`,failed:`tag-failed`,applied:`tag-done`},kxe={read:Qo,search:Lc,edit:us,run:xo,task:Uc,web:Vs,say:rl,tool:$s};function Axe({m:e}){let{p:t,run:n,proposal:r,runBlocked:i,scopeN:a,planPath:o,runLabel:s}=e;return(0,J.jsxs)(J.Fragment,{children:[o&&t.onOpenPlan?(0,J.jsxs)(Y,{title:`open ${o}, the write-up the run left for you — for reading; it does not run anything, and your ticks are kept`,onClick:()=>{q(`action:assess.plan`),t.onOpenPlan?.(o)},children:[(0,J.jsx)(Nl,{size:16}),` read the plan`]}):null,r&&t.onDiscard?(0,J.jsxs)(uT,{className:`key`,title:`throw this proposal away without applying any of it`,confirm:`discard it?`,confirmTitle:`nothing is applied, and the items keep their words`,onConfirm:()=>{q(`action:assess.discard`),t.onDiscard?.()},children:[(0,J.jsx)(ic,{size:16}),` discard`]}):null,i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(CE,{cants:[{label:s,reason:i}]}),t.budgetNote&&i===t.budgetNote&&(0,J.jsxs)(Y,{onClick:()=>jq(`budget`),children:[(0,J.jsx)(co,{size:16}),` change the usage budget`]})]}):(0,J.jsxs)(Y,{title:a?`judge ${a===1?`the one row`:`the ${a} rows`} you came here with — it still reads ${t.repoName} as evidence`:n?`read ${t.repoName} again and judge what is left now`:`read ${t.repoName} and judge what is left`,onClick:()=>{q(`action:assess.run`),t.onRun()},children:[(0,J.jsx)(Hc,{size:16}),` `,s]})]})}function jxe({m:e}){let{p:t,setPickedRows:n,setPickedMerges:r,setPickedNews:i,picked:a,applyBlocked:o,apply:s,applySummary:c,applyLabel:l,ready:u}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`act-bulk`,children:[(0,J.jsx)(`span`,{className:`act-bulk-n`,children:tye(a)}),a?(0,J.jsxs)(Y,{title:`un-tick everything — nothing has happened yet, so nothing is undone`,onClick:()=>{q(`action:assess.clear`),n(new Set),r(new Set),i(new Set)},children:[(0,J.jsx)(V,{size:14}),` clear`]}):null,o?(0,J.jsx)(CE,{cants:[{label:`apply`,reason:o}]}):(0,J.jsxs)(Y,{variant:`primary`,title:l,onClick:s,children:[(0,J.jsx)(Bl,{size:14}),` `,l]}),u?(0,J.jsxs)(Y,{variant:`primary`,className:`asr-route`,title:hK(u.n),onClick:()=>{q(`action:assess.backlog`),t.onOpenBacklog?.(u.ids,cye(t.repoName))},children:[(0,J.jsx)(Vl,{size:14}),` `,sye(u.n,t.repoName)]}):null]}),(0,J.jsx)(Z,{children:iye(c?.requeue??0)}),u?(0,J.jsx)(Z,{children:hK(u.n)}):null]})}function Mxe({m:e}){let{run:t,finishedAt:n}=e;return t?(0,J.jsxs)(`div`,{className:`act-triage`,children:[(0,J.jsx)(yE,{className:Oxe[t.status],children:t.status}),n?(0,J.jsx)(`span`,{className:`act-count`,children:Gp(n)}):null,t.assessableCount==null?null:(0,J.jsxs)(`span`,{className:`act-count`,children:[t.assessableCount,` judged`,t.itemCount!=null&&t.itemCount>t.assessableCount?` · ${t.itemCount-t.assessableCount} read as context`:``]}),t.scopedIds?.length?(0,J.jsxs)(`span`,{className:`act-count`,title:`this run was asked about a cut of the backlog, not the whole repo — it still read the repo as evidence`,children:[t.scope?.kind===`slot`?`slot check ·`:`scoped to`,` `,t.scopedIds.length===1?`1 row`:`${t.scopedIds.length} rows`]}):null,t.applied?(0,J.jsx)(`span`,{className:`act-count`,children:lye(t.applied)}):null]}):null}var Nq=`keep:`,Pq=e=>e.startsWith(Nq)?e.slice(5):null,Fq=12;async function Nxe(e,t){await Xb(`uploads`,Nq+e,{relPath:e,blob:t,ts:Date.now()}),await Ixe()}async function Iq(e){return(await Yb(`uploads`,Nq+e))?.blob??null}async function Pxe(){return(await $b(`uploads`)).map(Pq).filter(e=>!!e)}async function Fxe(e){await Zb(`uploads`,Nq+e)}async function Ixe(){let e=(await $b(`uploads`)).filter(e=>Pq(e));if(e.length<=Fq)return;let t=await Promise.all(e.map(async e=>({k:e,ts:(await Yb(`uploads`,e))?.ts??0})));t.sort((e,t)=>e.ts-t.ts);for(let{k:e}of t.slice(0,t.length-Fq))await Zb(`uploads`,e)}async function Lxe(e,t,n,r,i){let a=rj(e);if(!a.length)return{refs:a,states:[]};let o={onHost:null,sending:hn(n),kept:await Pxe(),dead:Zie()};if(t&&r){let e=a.some(e=>e.relPath.startsWith(`.claude/inbox/`)),n=a.some(e=>!e.relPath.startsWith(`.claude/inbox/`)),[r,s]=await Promise.all([e?U.inbox(t,i).catch(()=>null):Promise.resolve([]),n?U.artifacts(t,`outbox`,void 0,{signal:i}).then(e=>e.files).catch(()=>null):Promise.resolve([])]);o.onHost=r&&s?[...r,...s].map(e=>e.relPath):null}return{refs:a,states:kee(a.map(e=>e.relPath),o)}}async function Lq(e,t,n){if(t===`sending`){let t=n.find(t=>t.mode===`upload`&&t.upload?.relPath===e),r=t?await Yb(`uploads`,t.ackId):null;if(r)return URL.createObjectURL(r)}if(t===`sending`||t===`kept`||t===`dead`||t===`missing`||t===`unknown`){let t=await Iq(e);if(t)return URL.createObjectURL(t)}return null}var Rq=`app:open-attachment`;function Rxe(e){try{window.dispatchEvent(new CustomEvent(Rq,{detail:e}))}catch{}}function zxe(e){switch(e.state){case`host`:return`in the repo`;case`sending`:return`uploads before this message`;case`kept`:return`not uploaded — the file is still on this phone`;case`dead`:return e.why?`not uploaded — ${e.why}`:`not uploaded`;case`missing`:return`not in the repo, and not on this phone`;case`unknown`:return`can't check without a connection`}}var zq=e=>e.startsWith(Nq);async function Bxe(){return nx(`uploads`,zq)}var Vxe=96,Hxe={host:Xo,sending:Uo,kept:$c,dead:Js,missing:_s,unknown:gl};function Uxe({fref:e,state:t,repoId:n,localSrc:r}){let[i,a]=(0,H.useState)(!1),o=t.state===`host`?n:null,s=xj(o,e.relPath),c=!r&&e.image&&!i&&o?sg(U.artifactUrl(o,e.relPath),ag(Vxe),s):null,{src:l,live:u}=jj(c),d=r??l,f=!!d||!!o&&!e.image,p=d?(0,J.jsx)(`img`,{src:d,alt:e.name,loading:`lazy`,onLoad:()=>{c&&u&&s&&Oj(c)},onError:()=>a(!0)}):(0,J.jsx)(`span`,{className:`attach-noimg`,children:(0,J.jsx)(Nl,{size:16})});return f?(0,J.jsx)(`button`,{type:`button`,className:`attach-thumb tap`,title:`${e.relPath} — tap to open`,onClick:()=>Rxe({relPath:e.relPath,repoId:n,state:t.state}),children:p}):(0,J.jsx)(`div`,{className:`attach-thumb`,children:p})}function Bq({text:e,repoId:t,outbox:n,online:r,nonce:i,onStates:a,onReattach:o,onReplace:s,onForget:c,onRemove:l,compact:u,debounceMs:d=0}){let[f,p]=(0,H.useState)(e);(0,H.useEffect)(()=>{if(!d){p(e);return}let t=window.setTimeout(()=>p(e),d);return()=>window.clearTimeout(t)},[e,d]);let[m,h]=(0,H.useState)([]),g=(0,H.useRef)([]),[_,v]=(0,H.useState)({}),y=k(n);return(0,H.useEffect)(()=>{let e=new AbortController;return(async()=>{let{refs:i,states:o}=await Lxe(f,t,n,r,e.signal);if(e.signal.aborted)return;h(i.map((e,t)=>({ref:e,state:o[t]}))),a?.(o);let s={},c=[];for(let e=0;e<i.length;e++){if(!i[e].image)continue;let t=await Lq(i[e].relPath,o[e].state,n);t&&(s[i[e].relPath]=t,c.push(t))}e.signal.aborted?c.forEach(e=>URL.revokeObjectURL(e)):(g.current.forEach(e=>URL.revokeObjectURL(e)),g.current=c,v(s))})(),()=>e.abort()},[f,t,r,i,y]),(0,H.useEffect)(()=>()=>{g.current.forEach(e=>URL.revokeObjectURL(e))},[]),m.length?(0,J.jsx)(`div`,{className:`attach-strip ${u?`compact`:``}`,children:m.map(({ref:e,state:n})=>{let r=Hxe[n.state],i=_[e.relPath],a=n.state!==`host`&&n.state!==`sending`,d=l?()=>{h(t=>t.filter(t=>t.ref.relPath!==e.relPath)),l(e.relPath)}:null;return(0,J.jsxs)(`div`,{className:`attach-item ${n.state}`,children:[(0,J.jsx)(Uxe,{fref:e,state:n,repoId:t,localSrc:i}),(0,J.jsxs)(`div`,{className:`attach-body`,children:[(0,J.jsx)(`span`,{className:`attach-name`,title:e.relPath,children:e.name}),(0,J.jsxs)(`span`,{className:`attach-state`,children:[(0,J.jsx)(r,{size:11}),` `,zxe(n)]}),!u&&a&&(0,J.jsxs)(`div`,{className:`attach-acts`,children:[n.state===`kept`&&o&&(0,J.jsxs)(Y,{title:`put this phone's copy back in the send queue, under the same path — the message needs no change`,onClick:()=>o(e.relPath),children:[(0,J.jsx)($c,{size:14}),` re-attach`]}),s&&(0,J.jsxs)(Y,{title:`pick a different file for this mention — the path in the message is rewritten to the new one`,onClick:()=>s(e.relPath),children:[(0,J.jsx)(Xo,{size:14}),` pick a file`]}),c&&(0,J.jsxs)(Y,{variant:`danger`,title:`take this mention out of the message and send the words without it`,onClick:()=>c(e.relPath),children:[(0,J.jsx)(ic,{size:14}),` drop mention`]})]})]}),d&&(0,J.jsx)(`button`,{type:`button`,className:`attach-x`,"aria-label":`remove ${e.name} from the prompt`,onPointerDown:e=>e.preventDefault(),onClick:d,children:(0,J.jsx)(V,{size:16})})]},e.relPath)})}):null}function Vq(e){let[t,n]=(0,H.useState)(!1),r=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!e||t)return;let i=r.current;if(!i||typeof IntersectionObserver>`u`){n(!0);return}let a=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(n(!0),a.disconnect())},{rootMargin:`300px`});return a.observe(i),()=>a.disconnect()},[e,t]),[t,r]}function Hq({steps:e}){return e.length?(0,J.jsx)(`div`,{className:`assess-log`,children:e.map((e,t)=>{let n=kxe[e.kind]??$s;return(0,J.jsxs)(`div`,{className:`assess-step${e.kind===`say`?` assess-step-say`:``}`,children:[(0,J.jsx)(n,{size:12}),(0,J.jsx)(`span`,{className:`assess-step-label`,children:e.label}),e.detail?(0,J.jsx)(`span`,{className:`assess-step-detail`,children:e.detail}):null]},`${e.at}:${t}`)})}):null}function Uq({headline:e,suggested:t,category:n}){if(!e&&!n)return null;let r=n?XK[n]:null;return(0,J.jsxs)(J.Fragment,{children:[n&&r?(0,J.jsxs)(`span`,{className:`bl-chip bl-cat`,children:[(0,J.jsx)(r,{size:11}),` `,n]}):null,e?(0,J.jsxs)(`span`,{className:`act-where asr-headline`,children:[t?(0,J.jsx)(Gl,{size:11}):null,e]}):null]})}function Wq({text:e,repoId:t,outbox:n,online:r}){let i=(0,H.useMemo)(()=>!!e&&rj(e).length>0,[e]),[a,o]=Vq(i);return i?(0,J.jsx)(`div`,{ref:o,children:a?(0,J.jsx)(Bq,{compact:!0,text:e,repoId:t,outbox:n,online:r}):null}):null}function Wxe({m:e}){let{p:t,proposal:n,pickedNews:r,setPickedNews:i,rejected:a,toggleNew:o,toggleReject:s}=e;return(0,J.jsx)(J.Fragment,{children:n&&n.news.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:n.news.some(e=>e.fromNote)?`what it proposes to add`:`missing pieces it proposes`}),(0,J.jsx)(`span`,{className:`section-hint`,children:n.news.some(e=>e.fromNote)?`new items the run wrote, and pad notes of yours it says are still worth doing — offered in your own words`:`prose and a position, and nothing else — these are new items, not verdicts on yours`})]}),n.news.some(e=>!e.fromNote)?(0,J.jsx)(`div`,{className:`act-verdict assess-effect`,children:dye(t.repoName)}):null,n.news.map((e,n)=>{let c=!!e.fromNote,l=c?fye:uye;return(0,J.jsxs)(`div`,{className:`q-card${c?` asr-offer`:``}${a.has(`new:${n}`)?` act-filed`:``}`,children:[(0,J.jsxs)(`div`,{className:`q-head`,children:[c?(0,J.jsx)(Po,{size:14}):(0,J.jsx)(os,{size:14}),(0,J.jsx)(`span`,{className:`bl-group-title`,children:c?`from your pad`:`a new item`}),e.rank==null?null:(0,J.jsxs)(`span`,{className:`act-count`,children:[`position `,e.rank]})]}),e.headline||e.category?(0,J.jsx)(`div`,{className:`act-head asr-namehead`,children:(0,J.jsx)(Uq,{headline:e.headline,suggested:!!e.headline,category:e.category})}):null,c?(0,J.jsx)(`div`,{className:`act-verdict assess-effect`,children:pye(t.repoName)}):null,(0,J.jsx)(`div`,{className:`act-text act-text-full`,children:e.prompt}),(0,J.jsx)(Wq,{text:e.prompt,repoId:t.repoId,outbox:t.outbox,online:t.online}),(0,J.jsxs)(`div`,{className:`act-acts`,children:[(0,J.jsxs)(Y,{className:r.has(n)?`primary`:void 0,title:r.has(n)?l.pickedTitle:l.title,onClick:()=>{q(c?`action:assess.accept.note`:`action:assess.accept.new`),o(n)},children:[(0,J.jsx)(ys,{size:16}),` `,r.has(n)?l.picked:l.label]}),(0,J.jsxs)(Y,{className:a.has(`new:${n}`)?`active`:void 0,title:a.has(`new:${n}`)?lK.pickedTitle:c?`leave the note on the pad — nothing is filed and nothing is removed`:`do not add this`,onClick:()=>{q(`action:assess.leave`),s(`new:${n}`,()=>i(e=>{let t=new Set(e);return t.delete(n),t}))},children:[(0,J.jsx)(V,{size:16}),` `,a.has(`new:${n}`)?lK.picked:lK.label]})]})]},n)})]}):null})}function Gq({row:e,m:t}){let{p:n}=t;return e.text==null?(0,J.jsxs)(`span`,{className:`act-stale`,children:[(0,J.jsx)(Js,{size:11}),` `,e.id,` — its words are not on this phone`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`act-text act-text-full`,children:e.text}),(0,J.jsx)(Wq,{text:e.text,repoId:n.repoId,outbox:n.outbox,online:n.online})]})}function Gxe({m:e}){let{p:t,conflicts:n,splits:r,pickedSplits:i,setPickedSplits:a,rejected:o,setRejected:s,acceptSplit:c,itemsById:l}=e;if(!n.length&&!r.length)return null;let u=e=>s(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,J.jsxs)(J.Fragment,{children:[n.length?(0,J.jsxs)(`div`,{className:`act-group`,children:[(0,J.jsxs)(`div`,{className:`act-group-head`,children:[(0,J.jsx)(yE,{className:`tag-failed`,children:`contradict`}),(0,J.jsx)(`span`,{className:`act-group-n`,children:n.length})]}),(0,J.jsx)(`div`,{className:`act-verdict assess-effect`,children:Bye}),n.map(n=>{let r=o.has(`conflict:${n.cid}`);return(0,J.jsxs)(`div`,{className:`q-card${r?` act-filed`:``}`,children:[(0,J.jsxs)(`div`,{className:`q-head`,children:[(0,J.jsx)(gc,{size:14}),(0,J.jsx)(`span`,{className:`bl-group-title`,children:n.sentence})]}),n.rows.map(n=>{let r=l.get(n.id);return(0,J.jsx)(`div`,{className:`act-row`,children:(0,J.jsxs)(`div`,{className:`act-body`,children:[(0,J.jsx)(`span`,{className:`act-head`,children:(0,J.jsx)(`span`,{className:`act-when mono`,children:n.id})}),(0,J.jsx)(Gq,{row:n,m:e}),t.online||r&&t.onOpenItem?(0,J.jsxs)(`div`,{className:`act-acts`,children:[r&&t.onOpenItem?(0,J.jsxs)(Y,{title:`show it where its words live`,onClick:()=>{q(`action:assess.conflict.open`),t.onOpenItem?.(r)},children:[(0,J.jsx)(mo,{size:16}),` open`]}):null,t.online&&t.onEditItem?(0,J.jsxs)(Y,{title:`change its words or its time — the send sheet, with this row in it`,onClick:()=>{q(`action:assess.conflict.edit`),t.onEditItem?.(n.id)},children:[(0,J.jsx)(us,{size:16}),` edit`]}):null,t.online&&t.onDropItem?(0,J.jsxs)(uT,{confirm:Hye,title:Uye,onConfirm:()=>{q(`action:assess.conflict.drop`),t.onDropItem?.(n.id)},children:[(0,J.jsx)(V,{size:16}),` `,Vye]}):null]}):null]})},n.id)}),t.online?null:(0,J.jsx)(Z,{children:`No connection — edit and drop wait for the link.`}),(0,J.jsx)(`div`,{className:`act-acts`,children:(0,J.jsxs)(Y,{className:r?`active`:void 0,title:r?`un-mark it`:`leave every row here as it is — nothing is sent either way`,onClick:()=>{q(`action:assess.conflict.ignore`),u(`conflict:${n.cid}`)},children:[(0,J.jsx)(ys,{size:16}),` `,r?`left as they are`:Wye]})})]},n.cid)})]}):null,r.length?(0,J.jsxs)(`div`,{className:`act-group`,children:[(0,J.jsxs)(`div`,{className:`act-group-head`,children:[(0,J.jsx)(yE,{className:`tag-running`,children:`split`}),(0,J.jsx)(`span`,{className:`act-group-n`,children:r.length})]}),r.map(n=>{let r=i.has(n.sid),s=o.has(`split:${n.sid}`);return(0,J.jsxs)(`div`,{className:`q-card${s?` act-filed`:``}`,children:[(0,J.jsxs)(`div`,{className:`q-head`,children:[(0,J.jsx)(ps,{size:14}),(0,J.jsx)(`span`,{className:`bl-group-title`,children:n.sentence})]}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`the item as written`}),(0,J.jsx)(`span`,{className:`section-hint mono`,children:n.id})]}),(0,J.jsx)(`div`,{className:`act-row`,children:(0,J.jsx)(`div`,{className:`act-body`,children:(0,J.jsx)(Gq,{row:n.original,m:e})})}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`the two it would become`}),(0,J.jsx)(`span`,{className:`section-hint`,children:`written by the assessment, not by you`})]}),n.texts.map((e,n)=>(0,J.jsx)(`div`,{className:`act-row`,children:(0,J.jsxs)(`div`,{className:`act-body`,children:[(0,J.jsx)(`span`,{className:`act-text act-text-full`,children:e}),(0,J.jsx)(Wq,{text:e,repoId:t.repoId,outbox:t.outbox,online:t.online})]})},n)),(0,J.jsxs)(`div`,{className:`act-acts`,children:[(0,J.jsxs)(Y,{className:r?`primary`:void 0,title:r?`approved — tap to un-approve`:`approve: the original is archived (words kept) and these two are posted on its clock`,onClick:()=>c(n),children:[(0,J.jsx)(ys,{size:16}),` `,r?`approved`:`approve the split`]}),(0,J.jsxs)(Y,{className:s?`active`:void 0,title:s?`un-mark it`:`keep it as one item`,onClick:()=>{q(`action:assess.split.leave`),u(`split:${n.sid}`),a(e=>{let t=new Set(e);return t.delete(n.sid),t})},children:[(0,J.jsx)(V,{size:16}),` keep it as one`]})]})]},n.sid)})]}):null]})}function Kxe({r:e,accepted:t,rejected:n,onAccept:r,onReject:i,onOpen:a,repoId:o,outbox:s,online:c}){let l=cK(e.verdict,e.source,e.failed),u=uK(e),d=e.acceptBlocked;return(0,J.jsxs)(`div`,{className:`act-row${n?` act-filed`:``}${t?` act-running`:``}`,children:[(0,J.jsxs)(`div`,{className:`act-body`,children:[(0,J.jsxs)(`span`,{className:`act-head`,children:[u.headline?null:(0,J.jsx)(`span`,{className:`act-when`,children:u.kind}),(0,J.jsx)(Uq,{headline:u.headline,suggested:u.suggested,category:u.category}),u.id?(0,J.jsx)(`span`,{className:`act-when mono`,children:u.id}):null]}),e.missing?(0,J.jsxs)(`span`,{className:`act-stale`,children:[(0,J.jsx)(Js,{size:11}),` `,Bve(e.id)]}):(0,J.jsx)(`span`,{className:`act-text act-text-full`,children:e.text}),(0,J.jsx)(Wq,{text:e.text,repoId:o,outbox:s,online:c}),(0,J.jsxs)(`span`,{className:`act-verdict${e.downgraded?` act-last-bad`:``}`,children:[e.downgraded?(0,J.jsx)(Js,{size:11}):null,e.sentence]}),(()=>{let t=Wve(e);return t?(0,J.jsx)(`span`,{className:`act-verdict`,children:t}):null})(),e.supersededByText?(0,J.jsxs)(`span`,{className:`act-verdict`,children:[`the item said to cover it: “`,e.supersededByText,`”`]}):null,d?(0,J.jsx)(wE,{children:d}):null,n?(0,J.jsx)(`span`,{className:`act-filed-note`,children:`left exactly as it is — nothing will happen to it`}):null]}),(0,J.jsxs)(`div`,{className:`act-acts`,children:[d?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{className:t?`primary`:void 0,title:t?l.pickedTitle:l.title,onClick:r,children:[(0,J.jsx)(ys,{size:16}),` `,t?l.picked:l.label]}),(0,J.jsxs)(Y,{className:n?`active`:void 0,title:n?lK.pickedTitle:lK.title,onClick:i,children:[(0,J.jsx)(V,{size:16}),` `,n?lK.picked:lK.label]})]}),a?(0,J.jsxs)(Y,{title:`show this item where it lives`,onClick:a,children:[(0,J.jsx)(Nl,{size:16}),` open`]}):null]})]})}function qxe({card:e,accepted:t,rejected:n,onAccept:r,onReject:i,repoId:a,outbox:o,online:s}){let c=e.originals.length||e.ids.length;return(0,J.jsxs)(`div`,{className:`q-card${n?` act-filed`:``}`,children:[(0,J.jsxs)(`div`,{className:`q-head`,children:[(0,J.jsx)(dc,{size:14}),(0,J.jsxs)(`span`,{className:`bl-group-title`,children:[`one prompt in place of `,c]}),e.rank==null?null:(0,J.jsxs)(`span`,{className:`act-count`,children:[`position `,e.rank]})]}),(0,J.jsx)(`div`,{className:`act-verdict`,children:e.rationale||`no rationale was given — the prompt and the originals below are all there is to judge it on`}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`the prompt it would run`}),(0,J.jsx)(`span`,{className:`section-hint`,children:`written by the assessment, not by you`})]}),e.headline||e.category?(0,J.jsx)(`div`,{className:`act-head asr-namehead`,children:(0,J.jsx)(Uq,{headline:e.headline,suggested:!!e.headline,category:e.category})}):null,(0,J.jsx)(`div`,{className:`act-text act-text-full`,children:e.prompt}),(0,J.jsx)(Wq,{text:e.prompt,repoId:a,outbox:o,online:s}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsxs)(`span`,{children:[`it replaces these `,c,`, in full`]}),(0,J.jsx)(`span`,{className:`section-hint mono`,children:e.ids.join(` · `)})]}),e.originals.map(e=>{let t=uK(e);return(0,J.jsx)(`div`,{className:`act-row`,children:(0,J.jsxs)(`div`,{className:`act-body`,children:[(0,J.jsxs)(`span`,{className:`act-head`,children:[t.headline?null:(0,J.jsx)(`span`,{className:`act-when`,children:t.kind}),(0,J.jsx)(Uq,{headline:t.headline,suggested:t.suggested,category:t.category}),t.id?(0,J.jsx)(`span`,{className:`act-when mono`,children:t.id}):null]}),e.missing?(0,J.jsxs)(`span`,{className:`act-stale`,children:[(0,J.jsx)(Js,{size:11}),` not on this phone`]}):(0,J.jsx)(`span`,{className:`act-text act-text-full`,children:e.text}),(0,J.jsx)(Wq,{text:e.text,repoId:a,outbox:o,online:s})]})},e.id)}),e.missingIds.length?(0,J.jsxs)(`div`,{className:`act-stale`,children:[(0,J.jsx)(Js,{size:11}),` `,e.missingIds.length,` of the items this merge names`,e.missingIds.length===1?` is`:` are`,` not on this phone, so`,e.missingIds.length===1?` its words are`:` their words are`,` not shown above.`]}):null,(0,J.jsxs)(`div`,{className:`act-acts`,children:[(0,J.jsxs)(Y,{className:t?`primary`:void 0,title:t?`approved — tap to un-approve`:`approve this merge: one new item, and all ${c} retired with a reason`,onClick:r,children:[(0,J.jsx)(ys,{size:16}),` `,t?`approved`:`approve the merge`]}),(0,J.jsxs)(Y,{className:n?`active`:void 0,title:n?`un-mark it`:`leave all of them exactly as they are`,onClick:i,children:[(0,J.jsx)(V,{size:16}),` leave all `,c]})]})]})}function Jxe({m:e}){let{p:t,pickedRows:n,setPickedRows:r,pickedMerges:i,setPickedMerges:a,rejected:o,flipped:s,setFlipped:c,groups:l,itemsById:u,toggleRow:d,toggleReject:f,bulkGroup:p,acceptMerge:m}=e;return(0,J.jsx)(J.Fragment,{children:l.map(e=>{let l=e.fixedOpen||(s.has(e.verdict)?!e.defaultOpen:e.defaultOpen),h=e.verdict===`unclear`?Jve(e.rows):[],g=e.rows.filter(e=>!e.acceptBlocked&&n.has(e.id)).length,_=Zve(e,g,{repoName:t.repoName});return(0,J.jsxs)(`div`,{className:`act-group`,children:[(0,J.jsxs)(`div`,{className:`act-group-head`,children:[(0,J.jsx)(yE,{className:Mq[e.verdict],children:e.label}),(0,J.jsx)(`span`,{className:`act-group-n`,children:e.count}),_?(0,J.jsxs)(Y,{title:_.title,onClick:()=>p(e,_),children:[(0,J.jsx)(Bl,{size:14}),` `,_.label]}):null,e.fixedOpen?null:(0,J.jsx)(Y,{className:`act-group-more`,title:l?`collapse this`:`show these`,onClick:()=>{q(`action:assess.strip.${e.verdict}`),c(t=>{let n=new Set(t);return n.delete(e.verdict)||n.add(e.verdict),n})},children:l?(0,J.jsx)(Ys,{size:14}):(0,J.jsx)(ac,{size:14})})]}),l&&e.verdict!==`merged`?(0,J.jsx)(`div`,{className:`act-verdict assess-effect`,children:cK(e.verdict,void 0,e.failed>0).effect}):null,l&&h.length?(0,J.jsx)(`div`,{className:`act-group-head`,children:h.map(e=>(0,J.jsxs)(`span`,{className:`act-count`,children:[e.n,` × `,e.text]},e.down))}):null,l?e.merges.map(e=>(0,J.jsx)(qxe,{card:e,accepted:i.has(e.gid),rejected:o.has(`merge:${e.gid}`),repoId:t.repoId,outbox:t.outbox,online:t.online,onAccept:()=>m(e),onReject:()=>f(`merge:${e.gid}`,()=>a(t=>{let n=new Set(t);return n.delete(e.gid),n}))},e.gid)):null,l?e.rows.map(e=>{let i=u.get(e.id);return(0,J.jsx)(Kxe,{r:e,accepted:n.has(e.id),rejected:o.has(`row:${e.id}`),repoId:t.repoId,outbox:t.outbox,online:t.online,onAccept:()=>{q(`action:assess.accept.${e.verdict}`),d(e.id)},onReject:()=>{q(`action:assess.leave`),f(`row:${e.id}`,()=>r(t=>{let n=new Set(t);return n.delete(e.id),n}))},onOpen:i&&t.onOpenItem?()=>{q(`action:assess.open`),t.onOpenItem?.(i)}:void 0},e.id)}):null]},e.verdict)})})}function Yxe({m:e}){let{rankedN:t,pinRanks:n,setPinRanks:r,nameCount:i,writeNames:a,setWriteNames:o}=e;return t>0||i>0?(0,J.jsxs)(`div`,{className:`asr-asks`,children:[t>0&&(0,J.jsxs)(Z,{className:`asr-pin`,children:[xt(t),(0,J.jsx)(`div`,{className:`asr-answer`,children:(0,J.jsx)(Bw,{label:`the order of the rows`,value:n?`keep`:`free`,options:[{key:`keep`,label:`keep this order`},{key:`free`,label:`leave it unmarked`}],onChange:e=>{e===`keep`?(q(`action:assess.pin`),r(!0)):(q(`action:assess.pin.free`),r(!1))}})}),(0,J.jsx)(`div`,{children:ite(n)})]}),i>0&&(0,J.jsxs)(Z,{className:`asr-pin`,children:[g(i),(0,J.jsx)(`div`,{className:`asr-answer`,children:(0,J.jsx)(Bw,{label:`the run's titles`,value:a?`write`:`skip`,options:[{key:`write`,label:`write them`},{key:`skip`,label:`leave the rows as they are`}],onChange:e=>{e===`write`?(q(`action:assess.name`),o(!0)):(q(`action:assess.name.skip`),o(!1))}})}),(0,J.jsx)(`div`,{children:cte(a)})]})]}):null}function Xxe({m:e}){let{logOpen:t,setLogOpen:n,pastSteps:r}=e;return(0,J.jsxs)(J.Fragment,{children:[r&&r.tail.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`what it looked at`}),(0,J.jsxs)(Y,{title:t?`collapse this`:`show these`,onClick:()=>{q(`action:assess.log`),n(e=>!e)},children:[t?(0,J.jsx)(Ys,{size:14}):(0,J.jsx)(ac,{size:14}),` `,_K(r.steps,r.tail.length).button]})]}),t?(0,J.jsx)(Hq,{steps:r.tail}):null]}):null,(0,J.jsx)(Yxe,{m:e})]})}function Zxe({m:e}){let{p:t,run:n,proposal:r,counts:i,watch:a,guideOpen:o,setGuideOpen:s,res:c,nothing:l,guide:u}=e;return(0,J.jsxs)(J.Fragment,{children:[i?(0,J.jsx)(`div`,{className:`act-filters`,children:cn.map(e=>(0,J.jsxs)(yE,{className:Mq[e],children:[ve(e),` `,(0,J.jsx)(`span`,{className:`act-count`,children:i[e]})]},e))}):null,n?(0,J.jsxs)(`div`,{className:`assess-intro`,children:[e.slotIntro?(0,J.jsx)(`div`,{className:`assess-guide-lead`,children:e.slotIntro}):null,(0,J.jsx)(`div`,{className:`assess-guide-lead`,children:u.lead}),(0,J.jsx)(`div`,{className:`act-group-head`,children:(0,J.jsxs)(Y,{title:o?`hide this`:`what accepting and applying on this screen actually do`,onClick:()=>{q(`action:assess.guide`),s(e=>!e)},children:[o?(0,J.jsx)(Ys,{size:14}):(0,J.jsx)(ac,{size:14}),` how this works`]})}),o?(0,J.jsx)(`ul`,{className:`assess-guide`,children:u.lines.map((e,t)=>(0,J.jsx)(`li`,{children:e},t))}):null]}):null,n?.detail?(0,J.jsx)(Z,{tone:n.status===`failed`?`warn`:void 0,children:n.detail}):null,n?.status===`failed`&&n.envelope?(0,J.jsx)(`div`,{className:`hist-out mono`,children:n.envelope}):null,a?(0,J.jsxs)(`div`,{className:`assess-watch`,children:[(0,J.jsxs)(`div`,{className:`assess-doing`,children:[(0,J.jsx)(Ml,{size:16,className:`spin`}),(0,J.jsx)(`span`,{children:a.doing})]}),(0,J.jsxs)(`div`,{className:`act-triage`,children:[(0,J.jsx)(`span`,{className:`act-count`,children:a.elapsed}),a.counts?(0,J.jsx)(`span`,{className:`act-count`,children:a.counts}):null,n?.progress?.model?(0,J.jsx)(`span`,{className:`act-count`,children:n.progress.model}):null,a.quiet?(0,J.jsx)(`span`,{className:`act-count warn`,children:a.quiet}):null]}),a.say?(0,J.jsx)(Z,{className:`assess-say`,children:a.say}):null,(0,J.jsx)(Hq,{steps:n?.progress?.tail??[]})]}):null,t.online?null:(0,J.jsx)(Z,{tone:`warn`,children:`No connection — this is the last proposal this phone was told about. Applying starts work on the desktop, so it waits for the link; nothing here expires while it is down.`}),(0,J.jsx)($,{res:c,empty:l,thing:`the assessment`,noun:`proposal`,children:n==null?`Nothing has been assessed in ${t.repoName} yet. An assessment reads the repo and says, of everything still open here, what is already done, what no longer applies, what is covered elsewhere and what is still worth doing — with evidence, and nothing is applied until you approve it.`:n.status===`running`?`The assessment is reading the repo — what it is doing is above. It leaves a proposal here when it finishes; you can close this and come back.`:n.status===`failed`?`The run did not produce a proposal, so nothing was decided and nothing was touched.`:`The run came back with nothing to decide — there was nothing still open in this repo.`}),r&&r.notes.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`what the app refused`}),(0,J.jsx)(`span`,{className:`section-hint`,children:`shown, not swallowed — a dropped group and a group nobody proposed look identical otherwise`})]}),(0,J.jsx)(`div`,{className:`list`,children:r.notes.map((e,t)=>(0,J.jsxs)(`div`,{className:`act-verdict`,children:[(0,J.jsx)(Js,{size:11}),` `,e]},t))})]}):null]})}function Qxe(e){let t=Exe(e),{run:n,proposal:r}=t;return(0,J.jsx)(hE,{className:`assess-sheet`,title:(0,J.jsx)(`span`,{title:e.repoDir,children:e.repoName}),icon:(0,J.jsx)(uo,{size:18}),onClose:e.onClose,footer:r?(0,J.jsx)(jxe,{m:t}):null,actions:(0,J.jsx)(Axe,{m:t}),head:n?(0,J.jsx)(Mxe,{m:t}):null,children:(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsx)(Zxe,{m:t}),(0,J.jsxs)(`div`,{className:`list act-list`,children:[(0,J.jsx)(Gxe,{m:t}),(0,J.jsx)(Jxe,{m:t}),(0,J.jsx)(Wxe,{m:t}),(0,J.jsx)(Xxe,{m:t})]})]})})}function $xe({repo:e}){let t=_h(),{liveSend:n}=t.conn,{budget:r}=t.world,i=e.worktreePath,a=K(hq).get(i)??null,o=K(yq),s=K(_q),c=K(vq),l=K(pq).items,u=vh();return(0,J.jsx)(Qxe,{repoDir:i,repoName:e.repoName,repoId:e.id,outbox:u,run:a,online:t.conn.status===`open`,busy:o.size>0,budgetNote:r?.verdict.blocked?Gi(r.verdict):null,scope:s,slot:c,onRun:()=>Cq(i,s??void 0,c),onEditItem:e=>{let n=t.world.intents.find(t=>t.id===e);n?t.nav.openSend(t.send.seedFromIntent(n)):t.say.toast(`that row is gone`)},onDropItem:e=>n({t:`backlog.archive`,id:e,archived:!0},`archived — its words are kept; the backlog's archived cut brings it back`,`no connection — archiving waits for the link`),onApply:e=>{a&&bxe(a,e)},onDiscard:()=>n({t:`assess.discard`,runId:a?.runId??``},`proposal discarded — nothing was applied`,`no connection — the proposal lives on the desktop`),onOpenPlan:n=>t.files.openFileFrom({repoId:e.id,relPath:n,mtime:a?.planMtime},`assess`),onOpenItem:e=>{e.source===`note`?t.nav.openPadAt(e.id):t.nav.openActivity()},backlog:l.filter(e=>e.repoDir===i),onOpenBacklog:(e,t)=>xq(i,e,t),onClose:xxe})}var eSe={id:`backlog`,boot:()=>(KK(wq),()=>KK(null)),sheets:[{id:`backlog`,persisted:!0,render:()=>(0,H.createElement)(wxe),onLeave:yxe,keep:mh(mq)},{id:`assess`,persisted:!1,render:()=>{let e=gq.get();return e?(0,H.createElement)($xe,{repo:e}):null}}],messages:{welcome:()=>mxe(),"backlog.list":e=>fxe(e),"assess.state":e=>pxe(e.repoDir,e.run)}};function tSe({m:e,p:t}){let{selecting:n,pickedRows:r,shown:i,selectVisible:a,clearSelection:o,refire:s,file:c,restorable:l,filter:u}=e;if(!n)return null;let d=u===`dismissed`,f=r.length?[...s.go.length?[]:[{label:`send again`,reason:`none of the selected rows can be sent again — each says why on its own row`}],...d||c.go.length?[]:[{label:`file away`,reason:`the selected rows are running — stopping one is “cancel”`}]]:[];return(0,J.jsxs)(`div`,{className:`act-bulk`,children:[(0,J.jsx)(`span`,{className:`act-bulk-n`,children:r.length?`${r.length} selected`:`none selected — tick rows to act on them`}),i.length?(0,J.jsxs)(Y,{title:`select all ${i.length} rows on screen`,onClick:a,children:[(0,J.jsx)(Do,{size:14}),` all `,i.length]}):null,r.length?(0,J.jsxs)(Y,{title:`clear the selection`,onClick:o,children:[(0,J.jsx)(Rc,{size:14}),` none`]}):null,s.go.length?(0,J.jsxs)(Y,{variant:`primary`,"data-hint":`activity.bulkRefire`,title:`send ${s.go.length} again as backlog items, each in the repo it was written for${s.skip.length?` — ${s.skip.length} left alone`:``}`,onClick:()=>{q(`action:activity.bulk.refire`),t.onBulk(`refire`,s.go)},children:[(0,J.jsx)(_l,{size:14}),` send `,s.go.length,` again`]}):null,d?l.length?(0,J.jsxs)(Y,{title:`put ${l.length} back in the list`,onClick:()=>{q(`action:activity.bulk.restore`),t.onBulk(`restore`,l)},children:[(0,J.jsx)(_c,{size:14}),` bring `,l.length,` back`]}):null:c.go.length?(0,J.jsxs)(Y,{"data-hint":`activity.bulkDismiss`,title:`file ${c.go.length} away as dealt with — nothing is deleted, and “dismissed” brings them back`,onClick:()=>{q(`action:activity.bulk.dismiss`),t.onBulk(`dismiss`,c.go)},children:[(0,J.jsx)(ko,{size:14}),` file `,c.go.length,` away`]}):null,(0,J.jsx)(CE,{cants:f})]})}function nSe(e,t,n){if(e.all+e.dismissed===0)return{chips:[],none:null};let r=[],i=[],a=null;for(let o of XU){let s=!n&&t===o.id;if(o.id===`open`){(s||e.open>0&&e.open<e.all)&&r.push({id:o.id,text:uE(o.label,{count:e.open}),on:s});continue}let c=o.id!==`all`&&o.id!==`dismissed`&&e[o.id]===e.all;o.id===`all`||s||e[o.id]>0&&!c?r.push({id:o.id,text:uE(o.label,{count:e[o.id]}),on:s}):e[o.id]>0?a=o.id===`needsYou`?`all need you`:`all ${o.label}`:i.push(o.label)}return{chips:r,none:[a,i.length?`nothing ${rSe(i)}`:null].filter(Boolean).join(` · `)||null}}function rSe(e){return e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)} or ${e[e.length-1]}`}function iSe({m:e}){let{filter:t,focus:n,setFocus:r,setFilter:i,counts:a,selecting:o,setSelecting:s,setSelected:c,grouped:l,setGrouped:u,sort:d,setSort:f,debrisCount:p,hideDebris:m,setHideDebris:h}=e,{chips:g,none:_}=nSe(a,t,!!n);return(0,J.jsxs)(J.Fragment,{children:[g.length?(0,J.jsx)(`div`,{className:`fchips wrap act-fchips`,children:g.map(e=>(0,J.jsx)(pE,{on:e.on,clears:!1,onClick:()=>{q(`action:activity.filter.${e.id}`),r(null),i(e.id)},children:e.text},e.id))}):null,_?(0,J.jsx)(`div`,{className:`act-none`,children:_}):null,(0,J.jsxs)(`div`,{className:`fchips wrap act-toggles`,children:[(0,J.jsx)(pE,{on:o,title:o?`leave selection mode`:`select rows — deal with many at once`,onClick:()=>{q(`action:activity.select`),s(e=>!e),o&&c(new Set)},children:`select`}),(0,J.jsx)(`span`,{className:`act-hint`,"data-hint":`activity.group`,title:l?`show every copy separately`:`collapse rows that say the same thing`,children:(0,J.jsx)(pE,{on:l,onClick:()=>{q(`action:activity.group`),u(e=>!e)},children:`grouped`})}),(0,J.jsx)(pE,{on:d===`oldest`,title:d===`oldest`?`back to attention order — what needs you first`:`oldest first — the ones that have been waiting longest`,onClick:()=>{q(`action:activity.sort`),f(e=>e===`oldest`?`ranked`:`oldest`)},children:`oldest first`}),p>0||m?(0,J.jsx)(`span`,{className:`act-hint`,"data-hint":`activity.debris`,title:`hide one-word replies — “continue please”, “done?”, a bare /cost. Nothing is deleted.`,children:(0,J.jsx)(pE,{on:m,onClick:()=>{q(`action:activity.debris`),h(e=>!e)},children:p?uE(`hide chatter`,{count:p}):`hide chatter`})}):null]})]})}function Kq({s:e}){let t=rt(e);return t?(0,J.jsxs)(`span`,{className:`row-name`,title:`what the desktop called this conversation`,children:[(0,J.jsx)(Gl,{size:11,"aria-hidden":`true`}),` `,t]}):null}var aSe={sendNow:_l,hold:Kl,retarget:jo,edit:us,fix:Zs,retry:_l,answer:bl,check:rc,open:xo,runNow:Hc,cancel:V,toggle:Do,download:rs,save:Ec,discard:ic,dismiss:Ks,confirmDone:Bl,openSchedule:Ss},oSe={prompt:bl,answer:Do,upload:Zs,action:Hc,sweep:ds,build:No,download:rs},sSe={queued:Hs,blocked:Kl,starting:Ml,running:Ml,done:Bl,failed:Js,canceled:V},cSe={landed:`it reached the session`,unconfirmed:`it was written into the session, and nothing confirmed it submitted — do not retype it`,unsubmitted:`it is sitting in the composer, unsent — do not retype it`,refused:`the desktop answered and refused it, so nothing was written`,unreachable:`the desktop never answered — it may have run`,unknown:`nobody recorded whether it ran`};function lSe(e,t){let n=Math.round((e-t)/1e3);if(n<=0)return`now`;let r=Math.floor(n/60);if(r<60)return`in ${r||1}m`;let i=Math.floor(r/60);return i<24?r%60?`in ${i}h ${r%60}m`:`in ${i}h`:`in ${Math.floor(i/24)}d`}function qq({a:e,onPress:t}){let n=aSe[e.id];return(0,J.jsxs)(Y,{className:e.danger?`danger`:void 0,title:e.label,"data-hint":`activity.${e.id}`,onClick:t,children:[(0,J.jsx)(n,{size:16}),` `,e.label]})}function Jq({row:e,now:t,sessions:n,repos:r,pick:i,outbox:a,online:o,review:s,repoIdForCwd:c,onAction:l,onRetarget:u,onOpenSession:d}){let[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(!1),b=s??null,x=b?.checkStatus&&b.checkStatus!==`checking`?b.checkDetail:void 0,S=(0,H.useMemo)(()=>!!e.attachText&&rj(e.attachText).length>0,[e.attachText]),[C,w]=Vq(S),T=oSe[e.kind],E=sSe[e.state],D=e.actions.filter(e=>!e.disabledReason),O=e.actions.filter(e=>e.disabledReason),k=D.find(e=>e.primary)??D[0]??null,A=D.filter(e=>e!==k&&e.alwaysShown),j=D.filter(e=>e!==k&&!e.alwaysShown),M=e.state===`running`||e.state===`starting`,N=t=>{q(`action:activity.${t.id}`),t.id===`retarget`?(_(e=>!e),p(!1)):l(t.id,e)};return(0,J.jsxs)(`div`,{ref:w,className:`act-row act-${e.bucket}${g?` act-aiming`:``}${i?` act-picking`:``}${e.dismissedAt==null?``:` act-filed`}`,children:[i?(0,J.jsx)(`button`,{className:`act-pick${i.checked?` on`:``}`,"aria-label":i.checked?`deselect`:`select`,title:i.checked?`deselect this row`:`select this row`,onClick:i.onToggle,children:i.checked?(0,J.jsx)(Do,{size:18}):(0,J.jsx)(Rc,{size:18})}):null,(0,J.jsxs)(`div`,{className:`act-rowmain`,children:[(0,J.jsxs)(`button`,{className:`act-body`,onClick:()=>h(e=>!e),title:e.clipped||e.fullText?`tap for the whole thing`:e.title,children:[(0,J.jsxs)(`span`,{className:`act-head`,children:[(0,J.jsx)(T,{size:12}),(0,J.jsx)(`span`,{className:`act-where`,children:e.where}),(0,J.jsx)(`span`,{className:`act-when`,children:Gp(e.at)})]}),(0,J.jsx)(`span`,{className:`act-text${m?` act-text-full`:``}`,children:m&&e.fullText?e.fullText:e.title}),(0,J.jsxs)(`span`,{className:`act-verdict`,children:[(0,J.jsx)(E,{size:12,className:M?`spin`:void 0}),e.verdict]}),e.delivery?(0,J.jsxs)(`span`,{className:`act-delivery`,children:[(0,J.jsx)(gl,{size:11}),` `,cSe[e.delivery]]}):null,e.asOf==null?null:(0,J.jsxs)(`span`,{className:`act-stale`,children:[`last known `,Gp(e.asOf),` — the desktop is not reachable`]}),e.dismissedAt==null?null:(0,J.jsxs)(`span`,{className:`act-filed-note`,children:[(0,J.jsx)(ko,{size:11}),` filed `,Gp(e.dismissedAt),` — the words are still here`]}),e.dueAt!=null&&e.dueAt>t?(0,J.jsxs)(`span`,{className:`act-due`,children:[(0,J.jsx)(Ss,{size:11}),` `,lSe(e.dueAt,t),` · `,new Date(e.dueAt).toLocaleString()]}):null,e.progress&&e.progress.total>0?(0,J.jsxs)(`span`,{className:`act-prog`,children:[(0,J.jsx)(`span`,{className:`act-bar`,children:(0,J.jsx)(`i`,{style:{width:`${Math.min(100,Math.round(e.progress.done/e.progress.total*100))}%`}})}),(0,J.jsx)(`span`,{className:`act-prog-n`,children:e.progress.label===`bytes`?`${yU(e.progress.done)} of ${yU(e.progress.total)}`:`${e.progress.done} of ${e.progress.total} ${e.progress.label??``}`})]}):null,e.lastRun?(0,J.jsxs)(`span`,{className:`act-last${e.lastRun.ok?``:` act-last-bad`}`,children:[`last run `,Gp(e.lastRun.at),e.lastRun.late?` (late)`:``,e.lastRun.detail?` — ${e.lastRun.detail}`:``]}):null,e.attempts>1?(0,J.jsxs)(`span`,{className:`act-tries`,children:[e.attempts,` attempts`]}):null]}),e.fromSchedule?(0,J.jsxs)(`button`,{className:`linkish act-from-sched`,title:`open the schedule “${e.fromSchedule.name}” — the rule that ran this`,onClick:()=>l(`openSchedule`,e),children:[(0,J.jsx)(Ss,{size:11}),` `,KL(e.fromSchedule.name)]}):null,(0,J.jsx)(sq,{state:e.state,sessionId:e.sessionId,sessions:n}),S&&C?(0,J.jsx)(Bq,{compact:!0,text:e.attachText,repoId:e.cwd?c(e.cwd):null,outbox:a,online:o}):null,b?.checkStatus?(0,J.jsxs)(`div`,{className:`act-check`,children:[(0,J.jsxs)(`button`,{className:`bl-check bl-check-${b.checkStatus}`,disabled:!x,title:x?`tap for the whole check`:b.checkNote||``,onClick:()=>y(e=>!e),children:[(()=>{let e=JK(b.checkStatus).Icon;return(0,J.jsx)(e,{size:11,style:{verticalAlign:`-1px`}})})(),` `,JK(b.checkStatus).label,b.checkNote?` · ${b.checkNote}`:``,x?v?(0,J.jsx)(Ys,{size:11}):(0,J.jsx)(ac,{size:11}):null]}),x&&v?(0,J.jsxs)(`div`,{className:`bl-check-detail`,children:[(0,J.jsx)(`pre`,{children:x}),b.checkedAt?(0,J.jsxs)(`span`,{className:`bl-check-when`,children:[`checked `,new Date(b.checkedAt).toLocaleString()]}):null]}):null]}):null,e.targets.length?(0,J.jsx)(`div`,{className:`act-targets`,children:e.targets.map(e=>(0,J.jsxs)(`div`,{className:`act-target act-t-${e.state}`,children:[(0,J.jsx)(`span`,{className:`act-target-name`,children:e.label}),(0,J.jsx)(`span`,{className:`act-target-state`,children:e.detail??e.state}),e.sessionId?(0,J.jsx)(Y,{title:`open this repo's session`,onClick:()=>d(e.sessionId),children:(0,J.jsx)(xo,{size:14})}):(0,J.jsx)(wE,{children:`no session`})]},e.label))}):null,(0,J.jsxs)(`div`,{className:`act-acts`,children:[(0,J.jsxs)(`span`,{className:`act-acts-verbs`,children:[k?(0,J.jsx)(qq,{a:k,onPress:()=>N(k)}):null,A.map(e=>(0,J.jsx)(qq,{a:e,onPress:()=>N(e)},e.id))]}),j.length||O.length&&k?(0,J.jsxs)(Y,{className:`act-more`,title:f?`fewer options`:`more options`,onClick:()=>p(e=>!e),children:[f?(0,J.jsx)(Ys,{size:16}):(0,J.jsx)(ac,{size:16}),` more`]}):null]}),f&&j.length?(0,J.jsx)(`div`,{className:`act-acts act-acts-more`,children:j.map(e=>(0,J.jsx)(qq,{a:e,onPress:()=>N(e)},e.id))}):null,[k,...A,...f?j:[]].filter(e=>!!e?.note).map(e=>(0,J.jsx)(Z,{children:e.note},`note-${e.id}`)),O.length>0&&(f||!k)?(0,J.jsx)(CE,{cants:O.map(e=>({label:e.label,reason:e.disabledReason}))}):null,g?(0,J.jsxs)(`div`,{className:`act-aim`,children:[(0,J.jsx)(Z,{children:`Keep the words, change where they go.`}),n.filter(t=>t.running&&t.id!==e.sessionId).map(t=>(0,J.jsxs)(`button`,{className:`row`,onClick:()=>{_(!1),u(e,{sessionId:t.id,cwd:t.cwd,mode:`input`})},children:[(0,J.jsxs)(SE,{children:[(0,J.jsx)(_l,{size:12}),` `,t.title]}),(0,J.jsx)(Kq,{s:t}),(0,J.jsx)(Q,{children:t.turnActive?`working`:`idle`})]},t.id)),(0,J.jsx)(XO,{repos:r,listClass:``,home:e.cwd,subLead:`backlog item`,icon:(0,J.jsx)(Bl,{size:12}),onPick:t=>{_(!1),u(e,{sessionId:t.worktreePath,cwd:t.worktreePath,mode:`backlog`})}})]}):null]})]})}function uSe({g:e,now:t,sessions:n,repos:r,outbox:i,online:a,reviews:o,repoIdForCwd:s,selecting:c,selected:l,onToggleRow:u,onToggleGroup:d,onAction:f,onRetarget:p,onOpenSession:m}){let[h,g]=(0,H.useState)(!1),_=e.rows.length,v=e.elsewhere.done,y=e=>c?{checked:l.has(e.key),onToggle:()=>u(e.key)}:void 0;if(_===1&&v===0&&e.elsewhere.other===0)return(0,J.jsx)(Jq,{row:e.rows[0],now:t,sessions:n,repos:r,pick:y(e.rows[0]),outbox:i,online:a,review:o?.[e.rows[0].id],repoIdForCwd:s,onAction:f,onRetarget:p,onOpenSession:m});let b=e.rows.every(e=>l.has(e.key));return(0,J.jsxs)(`div`,{className:`act-group`,children:[(0,J.jsxs)(`div`,{className:`act-group-head`,children:[c?(0,J.jsx)(`button`,{className:`act-pick${b?` on`:``}`,"aria-label":b?`deselect these`:`select these`,title:b?`deselect all ${_}`:`select all ${_}`,onClick:()=>d(e),children:b?(0,J.jsx)(Do,{size:18}):(0,J.jsx)(Rc,{size:18})}):null,_>1?(0,J.jsxs)(`span`,{className:`act-group-n`,children:[(0,J.jsx)(Ds,{size:11}),` ×`,_]}):null,_>1?(0,J.jsxs)(`span`,{className:`act-group-span`,children:[Gp(e.oldestAt),` → `,Gp(e.newestAt)]}):null,v>0?(0,J.jsxs)(`span`,{className:`act-group-ran`,children:[(0,J.jsx)(Bl,{size:11}),` `,v===1?`one of these already ran`:`${v} of these already ran`]}):null,e.elsewhere.other>0?(0,J.jsxs)(`span`,{className:`act-group-else`,children:[e.elsewhere.other,` more elsewhere in the list`]}):null,_>1?(0,J.jsx)(Y,{className:`act-group-more`,title:h?`collapse these`:`show all ${_} copies`,onClick:()=>{q(`action:activity.expand`),g(e=>!e)},children:h?(0,J.jsx)(Ys,{size:14}):(0,J.jsx)(ac,{size:14})}):null]}),(h?e.rows:e.rows.slice(0,1)).map(e=>(0,J.jsx)(Jq,{row:e,now:t,sessions:n,repos:r,pick:y(e),outbox:i,online:a,review:o?.[e.id],repoIdForCwd:s,onAction:f,onRetarget:p,onOpenSession:m},e.key))]})}function dSe({m:e,p:t}){let{shown:n,focus:r,rows:i,filter:a,counts:o,groups:s,now:c,selecting:l,selected:u,toggleRow:d,toggleGroup:f}=e;return(0,J.jsx)(`div`,{className:`list act-list`,children:n.length===0?(0,J.jsx)(Z,{children:r?`Nothing left of ${r.label} — every one of them has moved on. They are under “all”.`:i.length===0?`Nothing has been posted yet. Everything you send, queue, schedule, build or download shows up here and stays here until it is finished.`:a===`dismissed`?`Nothing filed away yet. Rows you have read and dealt with land here — they keep their words and their buttons, and “bring back” returns them to the list.`:`Nothing under “${XU.find(e=>e.id===a)?.label}”. ${o.all} ${o.all===1?`row`:`rows`} under “all”${o.dismissed?`, ${o.dismissed} filed away`:``}.`}):s.map(e=>(0,J.jsx)(uSe,{g:e,now:c,sessions:t.sessions,repos:t.repos,outbox:t.outbox,online:t.online,reviews:t.reviews,repoIdForCwd:t.repoIdForCwd,selecting:l,selected:u,onToggleRow:d,onToggleGroup:f,onAction:t.onAction,onRetarget:t.onRetarget,onOpenSession:t.onOpenSession},e.key))})}function fSe({m:e,online:t}){let{focus:n,setFocus:r,focusMissing:i,headline:a,headlineCut:o,setFilter:s,hideDebris:c,debrisCount:l}=e;return(0,J.jsxs)(J.Fragment,{children:[n?(0,J.jsxs)(Z,{className:`act-focus`,children:[(0,J.jsx)(Ic,{size:12}),` showing `,n.label,i>0?` — ${i} of them ${i===1?`has`:`have`} moved on since and ${i===1?`is`:`are`} under “all”`:``,`.`,(0,J.jsxs)(Y,{onClick:()=>{q(`action:activity.focus.clear`),r(null)},children:[(0,J.jsx)(V,{size:14}),` show everything`]})]}):null,a?(0,J.jsxs)(Z,{tone:t?void 0:`warn`,children:[a,o?(0,J.jsxs)(`button`,{className:`link-btn`,onClick:()=>{q(`action:activity.headline.${o}`),s(o)},children:[`show `,a.startsWith(`1 `)?`it`:`them`]}):null]}):null,t?null:(0,J.jsxs)(Z,{tone:`warn`,children:[(0,J.jsx)(Hs,{size:12}),` no connection — rows the desktop owns are last known, and each one says when. Nothing here expires while the link is down.`]}),c&&l>0?(0,J.jsxs)(Z,{children:[l,` one-word `,l===1?`reply is`:`replies are`,` hidden — nothing was deleted, tap “hide chatter” again to see them.`]}):null]})}var Yq=G(null);function Xq(e){Yq.set(e?{Sheet:e}:null)}function pSe(){return K(Yq)?.Sheet??null}var Zq=G(null);function Qq(e){Zq.set(e?{Section:e}:null)}function mSe(){return K(Zq)?.Section??null}function hSe(e){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(()=>e.focus&&e.focus.keys.length?{keys:new Set(e.focus.keys),label:e.focus.label}:null),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(()=>new Set),[l,u]=(0,H.useState)(!0),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(`ranked`),h=_E(1e4),g=(0,H.useMemo)(()=>JU({now:h,online:e.online,hostSeenAt:e.hostSeenAt,deps:{isEditableEntry:rh,isCreateOp:ih,laneLabel:e.laneLabel,repoName:e.repoName},outbox:e.outbox,queueBlocked:e.queueBlocked,goneLanes:new Set(e.goneLanes),intents:e.intents,pulls:e.pulls,sessions:e.sessions,dismissed:e.dismissed,confirmedDone:e.confirmedDone}),[h,e.online,e.hostSeenAt,e.laneLabel,e.repoName,e.outbox,e.queueBlocked,e.goneLanes,e.intents,e.pulls,e.sessions,e.dismissed,e.confirmedDone]),_=(0,H.useMemo)(()=>QU(g),[g]),v=(0,H.useRef)(null);v.current==null&&_.all>0&&(v.current=_.open>0?`open`:`all`);let y=t??v.current??`all`,b=(0,H.useMemo)(()=>rW(g.filter(e=>r?r.keys.has(e.key):ZU(e,y)),p),[g,y,p,r]),x=r?r.keys.size-b.length:0,S=(0,H.useMemo)(()=>b.filter(nW).length,[b]),C=(0,H.useMemo)(()=>d?b.filter(e=>!nW(e)):b,[b,d]),w=(0,H.useMemo)(()=>iW(C,g,{group:l}),[C,g,l]),T=$U(r?b:g,e.online),E=T?.text??null,D=T&&!r&&T.cut!==y?T.cut:null,O=mSe(),k=(0,H.useMemo)(()=>C.filter(e=>s.has(e.key)),[C,s]);return{filter:y,setFilter:n,focus:r,setFocus:i,selecting:a,setSelecting:o,selected:s,setSelected:c,grouped:l,setGrouped:u,hideDebris:d,setHideDebris:f,sort:p,setSort:m,now:h,rows:g,counts:_,shown:C,groups:w,headline:E,headlineCut:D,PeerJobs:O,debrisCount:S,focusMissing:x,pickedRows:k,toggleRow:e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),toggleGroup:e=>c(t=>{let n=new Set(t),r=e.rows.every(e=>n.has(e.key));for(let t of e.rows)r?n.delete(t.key):n.add(t.key);return n}),selectVisible:()=>{q(`action:activity.selectall`),c(new Set(C.map(e=>e.key)))},clearSelection:()=>{q(`action:activity.selectnone`),c(new Set)},refire:uU(k,cU),file:uU(k,lU),restorable:k.filter(e=>e.dismissedAt!=null)}}function gSe(e){let t=hSe(e),{PeerJobs:n}=t;return(0,J.jsxs)(hE,{title:fM.activity,icon:(0,J.jsx)(Kl,{size:18}),onClose:e.onClose,footer:t.selecting?(0,J.jsx)(tSe,{m:t,p:e}):null,head:(0,J.jsx)(iSe,{m:t}),children:[(0,J.jsx)(fSe,{m:t,online:e.online}),(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsx)(dSe,{m:t,p:e}),n&&!t.focus&&(t.filter===`all`||t.filter===`open`)&&(0,J.jsx)(n,{sessions:e.sessions,onOpenSession:e.onOpenSession})]})]})}var $q=1e3;function eJ(){let e=oo(B.activityDismissed,{});if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`number`&&Number.isFinite(r)&&(t[n]=r);return t}function tJ(e){let t=Object.keys(e);if(t.length<=$q){$a(B.activityDismissed,e);return}let n={};for(let r of t.sort((t,n)=>e[n]-e[t]).slice(0,$q))n[r]=e[r];$a(B.activityDismissed,n)}function _Se(){return new Map(Object.entries(eJ()))}function nJ(e,t=Date.now()){let n=eJ();for(let r of e)n[r]??(n[r]=t);return tJ(n),new Map(Object.entries(n))}function vSe(e){let t=eJ();for(let n of e)delete t[n];return tJ(t),new Map(Object.entries(t))}var rJ=1e3;function iJ(){let e=oo(B.activityConfirmedDone,{});if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`number`&&Number.isFinite(r)&&(t[n]=r);return t}function ySe(e){let t=Object.keys(e);if(t.length<=rJ){$a(B.activityConfirmedDone,e);return}let n={};for(let r of t.sort((t,n)=>e[n]-e[t]).slice(0,rJ))n[r]=e[r];$a(B.activityConfirmedDone,n)}function bSe(){return new Map(Object.entries(iJ()))}function xSe(e,t=Date.now()){let n=iJ();for(let r of e)n[r]??(n[r]=t);return ySe(n),new Map(Object.entries(n))}var aJ=G(_Se()),oJ=G(bSe()),sJ=G(null),cJ=G([]);function SSe(){return K(aJ)}function CSe(){return K(oJ)}function wSe(e,t){return e===`build`?`build:${t.cwd}`:e===`capture`?`capture:${t.cwd}`:e===`schedule`?`fanout`:`intent:${t.id}`}function TSe(e,t){return t?`queued — it runs when the link is back`:e===`launch`?`opening it now, without the files it was waiting for`:e===`build`?`starting the build…`:e===`capture`?`taking the capture…`:`firing it into the session…`}function ESe(e,t,n){let r=t-e;return`${e} ${e===1?`message`:`messages`} back as backlog items${n?` — added when the link is back`:``}${r?` · ${r} could not go`:``} · their rows are filed under “dismissed”`}var lJ=(e,t)=>{let n=e.world.repoForCwd(t);return n?Wn(n):Rp(t)};function uJ(e){sJ.set(e?`keys`in e?{keys:e.keys,label:e.label}:{keys:e.entries.map(e=>TH(e.ackId)),label:e.label}:null),W().nav.open(`activity`)}function DSe(e,t){uJ({entries:e,label:t})}function OSe(){sJ.set(null),W().nav.close(`activity`)}function kSe(){return gS.subscribe(e=>cJ.set(e))}function ASe(e,t){let n=W();n.say.track(`action:activity.retarget`),e.subject.source===`queue`?n.queue.verbs.retargetQueued(e.id,t)&&t.mode===`backlog`&&n.nav.openBacklogCut(t.cwd):e.subject.source===`intent`?(n.conn.liveSend({t:`intent.retarget`,id:e.id,cwd:t.cwd,target:t.mode===`input`?{kind:`session`,sessionId:t.sessionId}:{kind:`repo`}},`aimed at ${lJ(n,t.cwd)}`,bW),t.mode!==`input`&&n.nav.openBacklogCut(t.cwd)):n.say.toast(`that row cannot be re-aimed`)}function jSe(e,t){let n=W(),{liveSend:r}=n.conn,{queueOp:i}=n.queue,{sessionId:a}=t;n.say.track(`action:activity.${e}`);let o=t.subject,s=()=>{let e=a?n.world.sessions.find(e=>e.id===a):null;e?n.nav.attach(e):n.say.toast(`that session is no longer open`)};if(e===`dismiss`)aJ.set(nJ([t.key])),dJ([t]),n.say.toast(`filed away for later — it's under “dismissed”, nothing was deleted`);else if(e===`confirmDone`)oJ.set(xSe([t.key])),n.say.toast(`marked done — the desktop's own check never confirmed it, this is your call`);else if(e===`openSchedule`)t.fromSchedule&&n.nav.openScheduleCut([t.fromSchedule.id],qL(t.fromSchedule.name));else switch(o.source){case`queue`:{let t=o.entry,r=n.queue.verbs;if(e===`answer`){n.nav.open(`questions`),n.say.toast(`answer it here — the queued reply is bound to this question`);return}if(e===`sendNow`){r.sendQueuedNow(t.ackId);return}if(e===`hold`){r.toggleHoldQueued(t.ackId);return}if(e===`discard`){r.removeQueued(t.ackId),n.say.toast(`discarded`);return}if(e===`open`){s();return}n.nav.openSend({prompts:[t.op?.t===`session.create`&&t.op.prompt||t.text],target:n.send.targetFor(t.sessionId,t.cwd),cwdHint:t.cwd,repoId:n.queue.repoIdOf(t),ackId:t.ackId,repair:e===`fix`,origin:t.status===`failed`?`This one never went`:`Queued, not sent yet`,openAfter:!0});return}case`intent`:{let t=o.intent,a=gr(t);if(e===`open`){s();return}if(e===`runNow`||e===`sendNow`){if(a===`fanout`){n.nav.open(`fanout`),n.say.toast(`follow up from the run below — it picks which of its sessions get it`);return}let e=i({t:`intent.run`,id:t.id},wSe(a,t),t.label||t.title||`run it now`,{cwd:t.cwd});n.say.toast(TSe(a,e)),!e&&a===`work`&&n.nav.followFire(t.id);return}if(e===`cancel`||e===`discard`){if(a===`build`&&(t.state===`running`||t.state===`starting`)){r({t:`build.cancel`,runId:t.id},`cancelling the build…`,`no connection — the build is running on the desktop and can't be stopped from here`);return}if(a===`capture`&&(t.state===`running`||t.state===`starting`)){r({t:`capture.cancel`,runId:t.id},`stopping the capture…`,`no connection — the capture is running on the desktop and can't be stopped from here`);return}if(a===`schedule`){let e=n.queue.verbs.scheduleQueueRows(t.id);r({t:`schedule.remove`,id:t.id},$H(e.length),`no connection — this one lives on the desktop and can only be deleted there`)&&n.queue.verbs.dropScheduleQueue(e);return}r({t:`intent.cancel`,id:t.id},a===`launch`?`called off — that session will not open`:`removed`,xW);return}if(e===`toggle`){if(a===`schedule`){r({t:`schedule.setEnabled`,id:t.id,enabled:t.nextAt==null},t.nextAt==null?`armed`:`switched off`,`no connection — this one is armed on the desktop and can only be changed there`);return}n.nav.open(`backlog`),n.say.toast(`this one is a per-item switch — it is on the row, in the backlog`);return}if(e===`check`){r({t:`backlog.check`,id:t.id},`checking whether this is already done…`,bW);return}if(e===`download`){let e=t.result?.artifacts??[];if(!e.length){n.say.toast(`that run left no files`);return}let r=e.map(e=>({...e,repoDir:t.cwd,repoName:n.world.repoForCwd(t.cwd)?.repoName}));if(r.length===1){NO(r[0]);return}for(let e of r)NO(e,{silent:!0});n.say.toast(`downloading ${r.length} files — see Downloads`);return}if(a===`schedule`&&t.payload.kind===`build`){let e=n.world.schedules.find(e=>e.id===t.id),r=n.world.repoForCwd(t.cwd);if(e&&r){n.nav.openBuild(r,{schedule:e});return}n.say.toast(e?`that rule's repo is not listed on this phone — edit it from its card in ${fM.automation}`:`that rule is not in the list yet — try again in a moment`);return}if(a===`schedule`||ga(t)){n.nav.openSend(n.send.seedFromIntent(t));return}n.nav.open(`backlog`),n.say.toast(`rewrite it on its row, in the backlog`);return}case`pull`:if(e===`save`){PO(o.record.item.id);return}if(e===`retry`){gS.retry(o.record.item.id),n.say.toast(`fetching it now`);return}if(o.record.local){gS.remove(o.record.item.id),n.say.toast(`removed from Downloads`);return}gS.remove(o.record.item.id),r({t:`pull.dismiss`,id:o.record.item.id},`dropped from Downloads`,`removed here — the desktop's own queue still lists it until the link is back`);return}}function MSe(e,t,n){if(t.subject.source!==`queue`)return`nothing`;let r=t.subject.entry,i=r.cwd?e.world.repoForCwd(r.cwd):null;if(!i)return`norepo`;let a=kH(r).trim();if(!a)return`nothing`;let o=e.queue.queueBacklog({text:a,repoDir:i.worktreePath,label:a.slice(0,40)});return o===null?`nothing`:(e.queue.drop(r.ackId),n.add(i.worktreePath),o?`queued`:`sent`)}function dJ(e){let t=W();if(t.conn.status===`open`)for(let n of e)n.source!==`queue`&&n.source!==`pull`&&t.conn.send({t:`intent.dismiss`,id:n.id})}function NSe(e,t){let n=W();if(n.say.track(`action:activity.bulk.${e}`),!t.length){n.say.toast(`nothing selected`);return}let r=e=>lJ(n,e);(async()=>{if(e===`restore`){aJ.set(vSe(t.map(e=>e.key))),n.say.toast(`${t.length} back in the list`);return}if(!await n.say.confirm({title:e===`dismiss`?`File ${t.length} away?`:`Send ${t.length} again?`,lines:pU(t,{verb:e,repoName:r}),confirmLabel:e===`dismiss`?`File them away`:`Send them again`})){n.say.toast(`left alone`);return}if(e===`dismiss`){aJ.set(nJ(t.map(e=>e.key))),dJ(t),n.say.toast(`${t.length} filed away — nothing was deleted, they are under “dismissed”`);return}let i=0,a=!1,o=[],s=new Set;for(let e of t){let t=MSe(n,e,s);(t===`sent`||t===`queued`)&&(i++,o.push(e.key),t===`queued`&&(a=!0))}i?(aJ.set(nJ(o)),dJ(t.filter(e=>o.includes(e.key))),n.say.toast(ESe(i,t.length,a)),s.size===1&&n.nav.openBacklogCut([...s][0])):n.say.toast(`nothing left to send from those rows`)})()}function PSe(){let e=_h(),{sessions:t,visibleRepos:n,intents:r,backlog:i}=e.world,a=vh(),o=K(cJ),s=K(aJ),c=K(oJ),l=K(sJ),u=(0,H.useMemo)(()=>Object.fromEntries(i.map(e=>[e.id,e])),[i]);return(0,J.jsx)(gSe,{outbox:a,queueBlocked:e.queue.blocked,goneLanes:e.queue.goneLanes(),intents:r,reviews:u,pulls:o,sessions:t,repos:n,online:e.conn.status===`open`,hostSeenAt:gm().lastSeenAt,laneLabel:e.queue.laneLabel,repoName:t=>{let n=e.world.repoForCwd(t);return n?Wn(n):Rp(t)},repoIdForCwd:t=>e.world.repoForCwd(t)?.id??null,onAction:jSe,onRetarget:ASe,dismissed:s,confirmedDone:c,onBulk:NSe,focus:l,onOpenSession:n=>{let r=t.find(e=>e.id===n);r?e.nav.attach(r):e.say.toast(`that session is no longer open`)},onClose:OSe})}var FSe={id:`activity`,sheets:[{id:`activity`,persisted:!0,render:()=>(0,H.createElement)(PSe)}],boot:()=>kSe()},fJ=`pad.editor`;function ISe({repos:e,onDispatch:t,onFile:n,outbox:r,online:i,repoIdForCwd:a,focusId:o,onAttach:s,onAnnotate:c,onClose:l}){let[u,d]=(0,H.useState)(eh),f=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=f.current;if(!o||!e)return;e.scrollIntoView({block:`center`}),e.classList.add(`nh-flash`);let t=window.setTimeout(()=>e.classList.remove(`nh-flash`),1400);return()=>window.clearTimeout(t)},[o]),(0,H.useEffect)(()=>Gm(()=>d(eh()),[B.pad]),[]);let p=lh(fJ),[m,h]=(0,H.useState)(p?lh(`${fJ}.id`)||`new`:null),[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)(()=>p.split(`\f`)),b=(0,H.useRef)(v),x=(0,H.useRef)(0);function S(e){b.current=e,y(e),dh(fJ,e.join(`\f`))}let C=v[0]??``,[w,T]=(0,H.useState)(()=>lh(`${fJ}.cwd`)),E=e.find(e=>e.worktreePath===w)??null,D=(0,H.useRef)([]),[O,k]=(0,H.useState)(!1),[A,j]=(0,H.useState)(!1),[M,N]=(0,H.useState)([]);(0,H.useEffect)(()=>{if(m===null)return;let e=v.join(`\f`);dh(fJ,e),dh(`${fJ}.id`,e.trim()?m:``),dh(`${fJ}.cwd`,e.trim()?w:``)},[m,v,w]);function P(){dh(fJ,``),dh(`${fJ}.id`,``),dh(`${fJ}.cwd`,``),h(null),_(null),S([``]),T(``),N([]),k(!1),D.current=[]}function F(e,t=E){if(!e.length)return;if(!t){D.current=e,k(!0);return}T(t.worktreePath),dh(`${fJ}.cwd`,t.worktreePath);let n=e.filter(cg),r=e.filter(e=>!cg(e));r.length&&I(r,t),n.length&&c(n,t)}async function I(e,t){j(!0);try{let n=await s(e,t);if(!n.length)return;N(e=>[...e,...n]);let r=b.current.length?b.current.slice():[``],i=r[0]??``;r[0]=i?`${i}${/\s$/.test(i)?``:` `}${n.join(` `)}`:n.join(` `),S(r)}finally{j(!1)}}function ee(){q(`action:pad.new`),h(`new`),_(null),S([``]),T(``),N([])}function te(e){h(e.id),_(null),S([e.text,...e.steps??[]]),T(e.cwd??``),N([])}function ne(){let e=m,t=b.current.map(e=>e.trim()).filter(Boolean),n=w;if(!e){P();return}if(!t.length){e!==`new`&&nh([e]),P(),d(eh());return}q(`action:pad.save`);let[r,...i]=t,a=e===`new`,o=a?void 0:eh().find(t=>t.id===e),s={id:a?`p_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`:e,text:r,ts:Date.now()};i.length&&(s.steps=i);let c=n||o?.cwd;c&&(s.cwd=c);let l=a?th(s):iae(s);l?_(l):(P(),d(eh()))}function re(e){q(`action:pad.remove`),nh([e]),d(eh())}return m===null?(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(gE,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Po,{size:16}),` Prompt pad`]}),onClose:l,children:(0,J.jsxs)(Y,{onClick:ee,children:[(0,J.jsx)(os,{size:16}),` new`]})}),(0,J.jsx)(JR,{keys:[B.pad],thing:`your notes`}),(0,J.jsx)(Z,{children:Rn}),(0,J.jsxs)(`div`,{className:`list`,children:[u.length===0&&(0,J.jsx)($,{children:`Nothing on the pad. Tap “new” to park a thought.`}),u.map(s=>{let c=s.cwd?e.find(e=>e.worktreePath===s.cwd):void 0;return(0,J.jsxs)(`div`,{className:`pad-item`,ref:s.id===o?f:void 0,children:[(0,J.jsxs)(`div`,{className:`queue-row`,children:[(0,J.jsxs)(`button`,{className:`queue-text`,onClick:()=>te(s),title:`tap to edit`,children:[(0,J.jsx)(`span`,{className:`queue-text-body`,children:s.text}),(0,J.jsxs)(`span`,{className:`queue-meta`,children:[(s.steps?.length??0)>0&&(0,J.jsxs)(J.Fragment,{children:[`+`,s.steps.length,` step`,s.steps.length>1?`s`:``,` · `]}),c?(0,J.jsxs)(J.Fragment,{children:[c.isPrimary?c.repoName:`${c.repoName} · ${c.branch}`,` · `]}):null,new Date(s.ts).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})]})]}),(0,J.jsxs)(`div`,{className:`queue-row-acts`,children:[c&&(0,J.jsxs)(Y,{title:je.title(c.repoName),onClick:()=>{q(`action:pad.file`),n(s,c)},children:[(0,J.jsx)(bs,{size:16}),` `,je.label]}),(0,J.jsxs)(Y,{title:`send it — pick where and when in one sheet`,onClick:()=>{q(`action:pad.dispatch`),t(s)},children:[(0,J.jsx)(_l,{size:16}),` send…`]}),(0,J.jsx)(uT,{className:`key danger`,title:`discard`,confirmTitle:`tap again and this note is gone`,confirm:`discard?`,onConfirm:()=>re(s.id),children:(0,J.jsx)(ic,{size:16})})]})]}),(0,J.jsx)(Bq,{compact:!0,text:s.text,repoId:s.cwd?a(s.cwd):null,outbox:r,online:i})]},s.id)})]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:l,children:[(0,J.jsx)(Hl,{size:16}),` back`]}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsxs)(X,{as:`span`,style:{padding:0},children:[u.length,` note`,u.length===1?``:`s`]})]})]}):(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(gE,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Po,{size:16}),` `,m===`new`?`New note`:`Edit note`]}),onClose:P}),(0,J.jsxs)(Z,{children:[`Just the text. You pick where it goes when you get there.`,E&&(0,J.jsxs)(J.Fragment,{children:[` Files go to `,(0,J.jsx)(`strong`,{children:E.repoName}),`'s inbox — that much the note has decided.`]})]}),g&&(0,J.jsx)(Z,{tone:`warn`,children:g}),(0,J.jsxs)(uD,{prompts:v,onChange:S,placeholder:`What should someone do about this?`,chain:!0,stepHint:`then, once that step's turn finishes:`,trackAdd:`action:pad.addprompt`,focusRef:x,autoFocus:!0,children:[M.length>0&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(Oc,{size:12}),` `,M.length,` file`,M.length>1?`s`:``,` queued for `,E?.repoName??`that repo`,`'s inbox — the paths are in the note above.`]}),(0,J.jsx)(Bq,{compact:!0,debounceMs:700,text:C,repoId:E?.id??null,outbox:r,online:i,onRemove:e=>S(b.current.map(t=>ij(t,e)))})]}),O&&(0,J.jsxs)(`div`,{className:`queue-aim attach-aim`,children:[(0,J.jsx)(Z,{children:`Whose inbox do these files go to?`}),(0,J.jsx)(XO,{repos:e,listClass:``,onPick:e=>{let t=D.current;D.current=[],k(!1),F(t,e)}})]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:P,children:[(0,J.jsx)(V,{size:16}),` cancel`]}),(0,J.jsx)(dD,{prompts:b,onPrompts:S,focusRef:x,busy:A,onFiles:e=>F(e),unavailable:e.length?void 0:`no repos under the host root to upload into`,trackImage:`action:pad.attach`,trackFile:`action:pad.attachfile`}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(`button`,{className:`send`,onClick:ne,children:`Save`})]})]})}var pJ=G(null);function LSe(e){pJ.set(e),W().nav.open(`pad`)}function RSe(){pJ.set(null),W().nav.close(`pad`)}function zSe(e){let t=W();t.say.track(`action:pad.dispatch`),t.nav.openSend({prompts:[e.text,...e.steps??[]],target:t.send.targetFor(void 0,e.cwd),cwdHint:e.cwd??null,repoId:e.cwd?t.world.repoForCwd(e.cwd)?.id??null:null,padId:e.id,repair:rj(e.text).length>0,origin:`From the pad`})}function BSe(e,t){if(!e.cwd)return;let n=W(),r=n.queue.queueBacklog({text:e.text,repoDir:e.cwd,steps:e.steps?.length?[e.text,...e.steps]:void 0});r!==null&&(n.compose.removePadNotes([e.id]),n.say.toast(Je(t.repoName,r)),n.nav.openBacklogCut(e.cwd))}function VSe(){let e=_h(),t=vh(),n=K(pJ);return(0,J.jsx)(ISe,{repos:e.world.visibleRepos,outbox:t,online:e.conn.status===`open`,focusId:n,repoIdForCwd:t=>e.world.repoForCwd(t)?.id??null,onClose:RSe,onAttach:(t,n)=>e.files.attachForInbox(n,t),onAnnotate:(t,n)=>e.files.annotate(n,t,`pad`),onDispatch:zSe,onFile:BSe})}var HSe={id:`pad`,sheets:[{id:`pad`,persisted:!1,render:()=>(0,H.createElement)(VSe)}]},mJ=G(null),hJ=G(0);function USe(){return K(hJ)}var gJ=G(null),_J=G(null),vJ=G(null),yJ=G(null),bJ=G(null),xJ=G(null),SJ=G(new Map(Object.entries(oo(B.newImages,{})))),CJ=G(new Set),wJ={ret:`session`,pickRepo:null,sendRepo:null,padRepo:null,backlogEdit:null};function TJ(e){return K(SJ).get(e)??WSe}var WSe=[];function GSe(e){return K(CJ).has(e)}function EJ(e,t){return{repoId:e.repoId,scope:`outbox`,allTime:!0,returnTo:t,openFile:{...e,name:e.name||e.relPath.split(`/`).pop()||e.relPath}}}var DJ=/\.(mp4|webm|mov|m4v|ogv|mkv)$/i,KSe=/\.(png|jpe?g|gif|webp|bmp|avif|heic|svg)$/i;function OJ(e){return DJ.test(e)}function kJ(e){return/\.(md|markdown|mdx)$/i.test(e)}function AJ(e){return DJ.test(e)||KSe.test(e)}function jJ(e){return e.filter(e=>AJ(e.relPath))}function qSe(e){let t=e.filter(e=>kJ(e.relPath)),n=t.filter(e=>e.changed).length,r=e.length-t.length,i=[];return r&&i.push(`${r} new image${r>1?`s`:``}`),t.length-n&&i.push(`${t.length-n} new markdown`),n&&i.push(`${n} markdown edited`),i.join(` · `)}function MJ(e,t,n){let r=n=>jJ(e.get(n)??[]).findIndex(e=>e.repoId===t.repoId&&e.relPath===t.relPath);if(n&&r(n)>=0)return{sessionId:n,i:r(n)};for(let t of e.keys()){let e=r(t);if(e>=0)return{sessionId:t,i:e}}return null}function JSe(e,t,n,r){let i=new Map(e),a=[...i.get(t)??[]];for(let e of r){let t=a.findIndex(t=>t.relPath===e.relPath);if(t<0){a.push({...e,repoId:n});continue}if(!kJ(e.relPath)||e.mtime<=a[t].mtime)continue;let[r]=a.splice(t,1),{changed:i,...o}=e;a.push(r.changed?{...e,repoId:n}:{...o,repoId:n})}return i.set(t,a),i}function YSe(e,t){if(!e.has(t))return e;let n=new Map(e);return n.delete(t),n}function XSe(e){let t={};for(let[n,r]of e)r.length&&(t[n]=r.slice(-60));return t}function NJ(e,t,n){let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=RegExp(`${r}(?:\\s*\\(marked:(?:[^()]|\\([^()]*\\))*\\))?`);return i.test(e)?e.replace(i,n):`${e} ${n}`}function ZSe(e){let t=e.trim(),n=Math.max(2,...[...t.matchAll(/`+/g)].map(e=>e[0].length)),r="`".repeat(n+1);return`Text read off a photo (on-device OCR, the photo itself not sent — glyphs may be misread):\n${r}\n${t}\n${r}\n`}function QSe(e,t){return t?`${e} (marked: ${t})`:e}function PJ(e,t){return e===`backlog-item`?`backlog`:e===`send`?t?`send`:null:e===`pad`?`pad`:null}function $Se(e,t,n,r,i){return e===`session`?n??t:e===`send`?`create:${r??t}`:e===`pad`?`create:${i??t}`:t}function eCe(e){return e?.outboxSeenAt!=null&&e.outboxCount>0?{since:e.outboxSeenAt,count:e.outboxCount}:void 0}function tCe(e,t){let n=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]);return e.length>0&&e.every(e=>t.some(t=>n(e,t)))}function nCe(e){return e.handled||!e.files||!e.repoId||e.editable&&!e.inCompose?`ignore`:e.annotating?`ask`:e.sheet&&!e.inCompose?`ignore`:`route`}function FJ(e){let t=W().nav,n=Yae(e,t.overlay);n===`close`&&t.overlay?t.close(t.overlay):n===`open`&&e&&t.open(e)}function IJ(e){W().compose.insert(e),gp(e),W().say.toast(`path copied: ${e}`)}function LJ(e,t){let n=U.artifactUrl(e,t),r=OJ(t);bj(e,t);let i=gj(e,t);return{name:t.split(`/`).pop()||t,relPath:t,url:r?n:sg(n,og(),i),fullUrl:n,video:r,repoId:e}}var RJ=!1;function rCe(e,t){if(!RJ){if(RJ=!0,e.image){let t=MJ(SJ.get(),e.image);_J.set(t??{items:[LJ(e.image.repoId,e.image.relPath)],repoId:e.image.repoId,i:0})}e.file&&t&&vJ.set(EJ(e.file))}}function zJ(e){let t=_J.get()?.revoke;_J.set(e);let n=_J.get()?.revoke;t&&t!==n&&URL.revokeObjectURL(t)}function iCe(e,t){let n=MJ(SJ.get(),e,t);mJ.set(null),zJ(n??{items:[LJ(e.repoId,e.relPath)],repoId:e.repoId,i:0}),W().nav.open(`swipe`)}function BJ(e){W().say.track(`action:newimg.open`),zJ({sessionId:e,i:0}),W().nav.open(`swipe`)}function aCe(e,t){W().say.track(`action:newimg.open`);let n=jJ(SJ.get().get(e)??[]);zJ({sessionId:e,i:Math.max(0,n.findIndex(e=>e.relPath===t.relPath))}),W().nav.open(`swipe`)}function VJ(e,t,n){W().say.track(`action:read.fileref`),AJ(t)?(zJ({items:[LJ(e,t)],repoId:e,i:0,back:n}),W().nav.open(`swipe`)):(vJ.set(EJ({repoId:e,relPath:t},n)),W().nav.open(`gallery`))}function oCe(e){let t=W().nav.overlay;e.state===`host`&&e.repoId?VJ(e.repoId,e.relPath,t):Lq(e.relPath,e.state,[...W().queue.entries]).then(n=>{n?(W().say.track(`action:attach.openlocal`),zJ({items:[{name:e.relPath.split(`/`).pop()||e.relPath,relPath:e.relPath,url:n,repoId:e.repoId??void 0}],repoId:e.repoId??void 0,i:0,back:t,revoke:n}),W().nav.open(`swipe`)):W().say.toast(`no copy of this file on this phone`)})}function HJ(){FJ(_J.get()?.back??null),zJ(null)}function sCe(e,t,n){SJ.set(r=>JSe(r,e,t,n)),WJ(e),W().say.toast(qSe(n))}function UJ(e){W().say.track(`action:newimg.ref`),IJ(e.relPath)}function cCe(e){SJ.set(t=>YSe(t,e)),WJ(e)}function lCe(e){CJ.set(t=>t.has(e)?t:new Set(t).add(e))}function WJ(e){CJ.set(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})}function GJ(e,t,n,r){vJ.set({repoId:e,scope:t,allTime:n,newCut:r}),W().nav.open(`gallery`)}function KJ(e){GJ(e,`outbox`,!0,eCe(W().world.repos.find(t=>t.id===e)))}function uCe(e){vJ.set({repoId:e.id,scope:`outbox`,allTime:!0,returnTo:`send`,insertInto:`send`}),W().nav.open(`gallery`)}function dCe(e,t){t===void 0&&W().say.track(`notif:open-file`);let n=t??(W().nav.overlay===`notifications`?`notifications`:void 0);vJ.set(EJ(e,n)),W().nav.open(`gallery`)}function fCe(e){NO(e)}function pCe(){let e=vJ.get()?.returnTo??null;vJ.set(null),FJ(e),W().world.refreshRepos()}function qJ(e){vJ.get()?.insertInto===`send`?(W().compose.appendSheetDraft(Xj,e),W().say.toast(`added to the prompt`)):IJ(e)}function mCe(e){let t=W(),n=t.world.repos.find(t=>t.id===e);if(!n)return[];let r=t.world.active?.id;return t.world.sessions.filter(e=>e.cwd===n.worktreePath&&e.running).sort((e,t)=>Number(t.id===r)-Number(e.id===r)).map(e=>({id:e.id,label:v_(e,n.repoName),onScreen:e.id===r}))}function hCe(e,t,n){let r=W(),i=r.world.repos.find(e=>e.id===t);if(!i){r.say.toast(`unknown repo`);return}let a=n?r.world.sessions.find(e=>e.id===n&&e.running):void 0;if(n&&!a)r.say.toast(`that session has ended — pick another, or start a new one`);else if(vJ.set(null),FJ(null),gp(e),a)r.nav.attach(a),r.compose.seedDraft(a.id,e),r.say.toast(`opened session · ${e}`);else{let t=r.launch.openCwd(i.worktreePath,Te(i));t?r.compose.seedDraft(t,e):r.compose.insert(e),r.say.toast(`new session · ${e}`)}}function gCe(e,t){let n=W(),r=n.world.repos.find(t=>t.id===e);if(!r)return n.say.toast(`unknown repo — the remarks are kept on the file`),!1;bJ.set(null),xJ.set(null),FJ(null),gp(t);let i=[n.world.active,...n.world.sessions].find(e=>e&&e.cwd===r.worktreePath&&e.running);if(i)return i.id!==n.world.active?.id&&n.nav.attach(i),n.compose.seedDraft(i.id,t),n.say.toast(`remarks are in the prompt — read them over, then send`),!0;let a=n.launch.openCwd(r.worktreePath,Te(r),!0);return a?n.compose.seedDraft(a,t):n.compose.insert(t),n.say.toast(`new session · remarks are in the prompt`),!0}function JJ(e,t,n){W().say.track(`overlay:sweep`),yJ.set({repoId:e,scope:t,back:n}),W().nav.open(`sweep`)}function _Ce(e){let t=vJ.get()?.repoId??W().world.activeRepo?.id;t&&JJ(t,e,`gallery`)}function vCe(e){yJ.set(t=>t&&{...t,scope:e})}function yCe(){let e=yJ.get()?.back??null;yJ.set(null),FJ(e)}function bCe(){W().world.refreshRepos()}function xCe(e,t=null){bJ.set(e),t&&xJ.set({file:``,back:t}),W().nav.open(`browse`)}function YJ(e,t,n){bJ.set(e),xJ.set({file:t,back:n}),W().nav.open(`browse`)}function SCe(){W().nav.open(`gallery`)}function XJ(e){return t=>{let n=t.world.activeRepo?.id;n?e(n):t.say.toast(`not a known repo`)}}function CCe(){bJ.set(null),W().nav.open(`browse`)}function ZJ(){let e=xJ.get()?.back??null;bJ.set(null),xJ.set(null),FJ(e)}var QJ=null,$J=null;function eY(e){wJ.ret=`session`,wJ.pickRepo=e,QJ?.click()}function tY(e){wJ.ret=`session`,wJ.pickRepo=e,$J?.click()}function nY(e){let t=Array.from(e.files??[]);e.value=``;let n=wJ.pickRepo;return wJ.pickRepo=null,t.length&&n?{files:t,repoId:n}:null}function wCe(e){let t=nY(e);t&&(W().say.track(`action:attach.file`),rY(t.files,t.repoId))}function rY(e,t,n){if(wJ.ret=`session`,n?.annotate===!1){cY(e,t);return}let r=e.filter(cg),i=e.filter(e=>!cg(e));i.length&&cY(i,t),r.length&&(r.length===1?iY({source:r[0],repoId:t}):oY(r,t,e=>{wJ.ret===`session`?aY(e,t):cY(e,t)}))}function TCe(e){let t=nY(e);if(!t)return;let{files:n,repoId:r}=t;n.length===1?iY({source:n[0],repoId:r}):oY(n,r,e=>{wJ.ret===`session`?aY(e,r):cY(e,r)})}function ECe(){let e=(e,t)=>{let n=document.createElement(`input`);return n.type=`file`,n.multiple=!0,n.hidden=!0,e&&(n.accept=e),n.addEventListener(`change`,()=>t(n)),document.body.appendChild(n),n};return QJ=e(`image/*`,TCe),$J=e(null,wCe),()=>{QJ?.remove(),$J?.remove(),QJ=$J=null}}function iY(e){mJ.set(e),W().nav.open(`image`)}function aY(e,t){mJ.set({source:e[0],repoId:t,rest:e.slice(1),total:e.length,index:1}),W().nav.open(`image`)}function oY(e,t,n){gJ.set({files:e,repoId:t,separate:n}),W().nav.open(`collage`)}function sY(){let e=mJ.get();if(e?.rest&&e.rest.length){let[t,...n]=e.rest;mJ.set({source:t,repoId:e.repoId,rest:n,total:e.total,index:(e.index??1)+1})}else FJ(null),mJ.set(null)}function DCe(e,t){let n=gJ.get();n&&(gJ.set(null),iY({source:e,repoId:n.repoId,facts:t}))}function OCe(e){let t=gJ.get();t&&(gJ.set(null),t.separate(e))}function kCe(){let e=PJ(wJ.ret,W().nav.sendSeeded());wJ.ret=`session`,gJ.set(null),FJ(e)}async function cY(e,t){wJ.ret=`session`;let n=W(),r=[],i=n.world.repos.find(e=>e.id===t)?.worktreePath??t,a=n.world.active?.id??i,o=``;for(let s of e)try{let{width:e}=cH(),c=await fH(s,s.name,e),l=await n.queue.queueImageUpload(t,c.blob,c.name,a,i);l?r.push(l.relPath):o||=`this browser can't hold files offline — reconnect and re-attach`}catch{o||=`couldn't read that file`}let s=W().say;r.length?(r.forEach(e=>W().compose.insert(e)),await gp(r.join(` `)),FJ(null),mJ.set(null),s.toast(W().conn.status===`open`?`Sent ${r.length} · paths copied`:`${r.length} queued · they upload when the link is back`)):s.toast(o||`Upload failed`)}function ACe(){let e=hJ.get();return e?(hJ.set(0),Date.now()-e<jCe&&W().nav.overlay==null):!1}var jCe=3e3;async function MCe(e,t){let n=mJ.get();if(!n)return null;let r=W(),i=r.world.repos.find(e=>e.id===n.repoId)?.worktreePath??n.repoId,a=$Se(wJ.ret,i,r.world.active?.id??null,wJ.sendRepo?.worktreePath,wJ.padRepo?.worktreePath);return(await r.queue.queueImageUpload(n.repoId,e,t,a,i))?.relPath??null}function NCe(e,t){let n=mJ.get();if(!n)return;let r=W().queue.uploads,i=r.ensureUploadBuf(n.repoId);t===`run`&&(i.submit=!0),t===`queue`&&(i.queue=!0),r.queueUpload(i,e.blob,e.name,e.note,e.size),n.rest&&n.rest.length?(sY(),W().say.toast(`Sent ${n.index}/${n.total} · next…`)):(i.closed=!0,mJ.set(null),FJ(null),r.settleUploads(i))}function PCe(){let e=mJ.get();if(e?.rest&&e.rest.length){sY(),W().say.toast(`Skipped ${e.index}/${e.total}`);return}let t=W().queue.uploads,n=t.current();n&&(n.closed=!0,t.settleUploads(n));let r=PJ(wJ.ret,W().nav.sendSeeded());wJ.ret=`session`,mJ.set(null),FJ(r)}function FCe(e,t){let n=mJ.get();if(!n)return;let{repoId:r,rest:i=[]}=n,a=W().queue.uploads,o=a.ensureUploadBuf(r);t===`run`&&(o.submit=!0),t===`queue`&&(o.queue=!0),a.queueUpload(o,e.blob,e.name,e.note,e.size);for(let e of i){let t=e instanceof File?e:fetch(e.url).then(e=>e.blob());a.queueUpload(o,t,e.name)}o.closed=!0,mJ.set(null),FJ(null),a.settleUploads(o)}function lY(){let e=PJ(wJ.ret,W().nav.sendSeeded()),t=W().queue.uploads,n=t.current();wJ.ret===`session`&&n&&(n.closed=!0,t.settleUploads(n)),wJ.ret=`session`,wJ.backlogEdit=null,mJ.set(null),FJ(e)}async function ICe(e,t){let n=QSe(e,t),r=W().say;if(wJ.ret===`backlog-item`&&wJ.backlogEdit){let{id:t,oldPath:i,text:a}=wJ.backlogEdit;wJ.backlogEdit=null,wJ.ret=`session`;let o=NJ(a,i,n);mJ.set(null),FJ(`backlog`),o===a?r.toast(`updated image: ${e}`):W().conn.liveSend({t:`backlog.update`,id:t,text:o},`updated image: ${e}`,`no connection — the marked image will still upload (${e}), but the backlog row lives on the desktop and still names the old one`);return}if(wJ.ret===`send`){WCe(n);return}if(wJ.ret===`pad`){GCe(n);return}W().world.active&&W().compose.insert(n),await gp(n);let i=mJ.get();i?.rest&&i.rest.length?(sY(),r.toast(`Sent ${i.index}/${i.total} · next…`)):(FJ(null),mJ.set(null),r.toast(`Sent · path copied: ${e}`))}function LCe(e){let t=ZSe(e),n=W();if(wJ.ret===`backlog-item`&&wJ.backlogEdit){let{id:e,oldPath:r,text:i}=wJ.backlogEdit;wJ.backlogEdit=null,wJ.ret=`session`,mJ.set(null),FJ(`backlog`),n.conn.liveSend({t:`backlog.update`,id:e,text:NJ(i,r,t)},`the image is now its text`,`no connection — the backlog row lives on the desktop and still names the image`);return}wJ.ret===`send`?n.compose.appendSheetDraft(Xj,t):wJ.ret===`pad`?(n.compose.appendSheetDraft(`pad.editor`,t),n.compose.loadSheetDraft(`pad.editor.id`)||n.compose.seedSheetDraft(`pad.editor.id`,`new`)):n.world.active?n.compose.insert(t):gp(t);let r=mJ.get();r?.rest&&r.rest.length?(sY(),n.say.toast(`Text added ${r.index}/${r.total} · next…`)):(n.say.toast(wJ.ret===`session`&&!n.world.active?`text copied — no session open to put it in`:`text added — the photo was not sent`),lY())}function uY(e,t,n){iY({source:{url:e,name:t},repoId:n})}function dY(e,t,n){wJ.ret=`session`,uY(e,t,n)}function RCe(e){dY(U.artifactUrl(e.repoId,e.relPath),e.name,e.repoId)}function zCe(){return W().nav.overlay===`image`&&mJ.get()!=null}async function BCe(e){let t=mJ.get();if(!t||!e.length)return!1;let n=[t.source,...t.rest??[]].filter(e=>e instanceof File),r=new Set(n.map(e=>e.size));if(!e.every(e=>r.has(e.size)))return!1;let i=e=>e.arrayBuffer().then(e=>new Uint8Array(e));try{let[t,r]=await Promise.all([Promise.all(e.map(i)),Promise.all(n.filter(t=>e.some(e=>e.size===t.size)).map(i))]);return tCe(t,r)}catch{return!1}}function VCe(e){let t=mJ.get();if(!t)return;let n=e.filter(cg);e.length>n.length&&cY(e.filter(e=>!cg(e)),t.repoId),n.length&&mJ.set({...t,rest:[...t.rest??[],...n],total:(t.total??1)+n.length,index:t.index??1})}async function HCe(e,t,n=`create:${e.worktreePath}`){let r=[];for(let i of t){let t=i,a=i.name;try{let{width:e}=cH(),n=await fH(i,i.name,e);t=n.blob,a=n.name}catch{}let o=await W().queue.queueImageUpload(e.id,t,a,n,e.worktreePath);o?r.push(o.relPath):W().say.toast(`this browser can't hold files offline — reconnect and attach again`)}return r}function UCe(e,t,n){t.length&&(wJ.ret=n,n===`send`?wJ.sendRepo=e:wJ.padRepo=e,t.length===1?iY({source:t[0],repoId:e.id}):oY(t,e.id,t=>aY(t,e.id)))}function WCe(e){let t=W();t.compose.appendSheetDraft(Xj,e);let n=mJ.get();if(n?.rest&&n.rest.length){sY(),t.say.toast(`Attached ${n.index}/${n.total} · next…`);return}wJ.ret=`session`,mJ.set(null);let r=t.nav.sendSeeded();FJ(r?`send`:null),gp(e),t.say.toast(r?`attached · the path is in the prompt`:`path copied: ${e}`)}function GCe(e){let t=W();t.compose.appendSheetDraft(`pad.editor`,e),t.compose.loadSheetDraft(`pad.editor.id`)||t.compose.seedSheetDraft(`pad.editor.id`,`new`);let n=mJ.get();n?.rest&&n.rest.length?(sY(),t.say.toast(`Attached ${n.index}/${n.total} · next…`)):(wJ.ret=`session`,mJ.set(null),t.nav.open(`pad`),gp(e),t.say.toast(`attached · the path is in the note`))}function KCe(e,t){let n=W().world.repos.find(t=>t.worktreePath===e.repoDir)?.id;n?(wJ.ret=`backlog-item`,wJ.backlogEdit={id:n,oldPath:t,text:e.text},uY(U.artifactUrl(n,t),t.split(`/`).pop()||`image`,n)):W().say.toast(`unknown repo`)}function qCe(e,t){let n=t.find(t=>t.relPath===e.relPath),r=_J.get()?.back??null;zJ(null),n?RCe(n):e.repoId?dY(e.fullUrl??e.url,e.name,e.repoId):FJ(r)}function JCe(e,t){let n=t.find(t=>t.relPath===e.relPath);n?UJ(n):IJ(e.relPath),HJ()}function YCe(){let e=ECe(),t=e=>{let t=e.detail;t&&oCe(t)};window.addEventListener(Rq,t);let n=SJ.subscribe(()=>$a(B.newImages,XSe(SJ.get()))),r=!1,i=mJ.subscribe(()=>{mJ.get()==null?(r&&hJ.set(Date.now()),r=!1):r=wJ.ret===`session`});return()=>{e(),n(),i(),window.removeEventListener(Rq,t);let r=_J.get()?.revoke;r&&URL.revokeObjectURL(r)}}var XCe=`#0d1013`,ZCe=`#000000`,QCe=`#ffffff`,$Ce=`rgba(0,0,0,0.75)`;async function ewe(e){let t=[],n=[];for(let r of e){let e=await mH(vH(r),null),i=e?e.width:0,a=e?e.height:0;e&&i>0&&a>0?t.push({name:r.name,file:r,img:e,w:i,h:a}):n.push(r.name)}return{items:t,failed:n}}function fY(e){for(let t of e)typeof ImageBitmap<`u`&&t.img instanceof ImageBitmap&&t.img.close()}var pY=e=>e.map(e=>({w:e.w,h:e.h}));function mY(e,t){if(t===`none`)return 0;let n=Ui(pY(e));return t===`wide`?n*3:n}function twe(e,t){return wee(pY(e),mY(e,t))}function nwe(e){return Array.from({length:e},(e,t)=>t+1)}function rwe(e,t={}){return si(pY(e),{cols:t.cols,gap:mY(e,t.gap??`thin`),...t.maxWidth?{maxWidth:t.maxWidth}:{}})}var hY=[2600,1800,1200,800];async function gY(e,t={}){if(!e.length)return null;let n=t.maxSide?[t.maxSide,...hY.filter(e=>e<t.maxSide)]:[void 0,...hY];for(let r=0;r<n.length;r++){let i=n[r],a=si(pY(e),{cols:t.cols,gap:mY(e,t.gap??`thin`),...t.maxWidth?{maxWidth:t.maxWidth}:{},...i?{maxSide:i,maxPixels:i*i}:{}}),o=await iwe(e,a,t.labels!==!1&&e.length>1);if(o)return{blob:o,layout:a,label:oa(e.length,a.cols),reduced:r>0}}return null}async function iwe(e,t,n){let r=document.createElement(`canvas`);try{if(r.width=t.width,r.height=t.height,r.width!==t.width||r.height!==t.height)return null;let i=r.getContext(`2d`);if(!i)return null;i.fillStyle=XCe,i.fillRect(0,0,r.width,r.height),i.imageSmoothingQuality=`high`;for(let r of t.cells){let t=e[r.i];if(t){try{i.drawImage(t.img,r.x,r.y,r.w,r.h)}catch{}n&&awe(i,r.x,r.y,r.w,r.h,r.i+1)}}return await gH(r,`image/jpeg`,.9)}catch{return null}finally{r.width=0,r.height=0}}function awe(e,t,n,r,i,a){let o=Math.max(22,Math.round(Math.min(r,i)*.095)),s=Math.round(o*.5),c=String(a);e.font=`800 ${o}px system-ui, -apple-system, sans-serif`,e.textBaseline=`middle`,e.textAlign=`center`;let l=o+s,u=Math.max(l,e.measureText(c).width+s*2),d=Math.max(2,Math.round(o*.11)),f=t+Math.round(o*.35)+d,p=n+Math.round(o*.35)+d;owe(e,f,p,u,l,Math.round(o*.32)),e.fillStyle=ZCe,e.fill(),e.lineJoin=`round`,e.lineWidth=d*2.4,e.strokeStyle=$Ce,e.stroke(),e.lineWidth=d,e.strokeStyle=QCe,e.stroke(),e.fillStyle=`#ffffff`,e.fillText(c,f+u/2,p+l/2)}function owe(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+r,n,t+r,n+i,a),e.arcTo(t+r,n+i,t,n+i,a),e.arcTo(t,n+i,t,n,a),e.arcTo(t,n,t+r,n,a),e.closePath()}var _Y=B.collageGap,vY=B.collageLabels,swe=1200,cwe=()=>{let e=z(_Y);return e===`none`||e===`wide`?e:`thin`},lwe=()=>z(vY)!==`0`;function uwe({files:e,onCombine:t,onSeparate:n,onClose:r}){let[i,a]=(0,H.useState)(null),[o,s]=(0,H.useState)([]),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(cwe),[f,p]=(0,H.useState)(lwe),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(!0),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(null),[S,C]=(0,H.useState)(!1),w=(0,H.useRef)(null),T=(0,H.useRef)(new Map),E=cH();(0,H.useEffect)(()=>{let t=!0,n=[];return ewe(e).then(({items:r,failed:i})=>{n=r,t?(a(r),s(e.filter(e=>i.includes(e.name))),r.length<2&&x(r.length?`Only one of these could be read as an image on this device.`:`None of these could be read as an image on this device.`)):fY(r)}),()=>{t=!1,fY(n),w.current&&URL.revokeObjectURL(w.current);for(let e of T.current.values())URL.revokeObjectURL(e);T.current.clear()}},[]),(0,H.useEffect)(()=>{if(!i||i.length<2){_(!1);return}let e=!0;return _(!0),gY(i,{cols:c??void 0,gap:u,labels:f,maxSide:swe}).then(t=>{e&&(_(!1),t?(x(null),w.current&&URL.revokeObjectURL(w.current),w.current=URL.createObjectURL(t.blob),h({url:w.current,bytes:t.blob.size})):x(`This device couldn't draw the combined image.`))}),()=>{e=!1}},[i,c,u,f]);let D=i?.length??e.length,O=i&&i.length>1?twe(i,u):1,k=c??O,A=i&&i.length>1?rwe(i,{cols:k,gap:u,...E.width?{maxWidth:E.width*k}:{}}):null;function j(e){let t=T.current.get(e);return t||(t=URL.createObjectURL(e.file),T.current.set(e,t)),t}function M(e,t){a(n=>{if(!n)return n;let r=e+t;if(r<0||r>=n.length)return n;let i=n.slice();return[i[e],i[r]]=[i[r],i[e]],i}),q(`action:collage.reorder`)}function N(e){q(`action:collage.layout`),l(e)}function P(e){d(e),Za(_Y,e)}function F(){let e=!f;p(e),Za(vY,e?`1`:`0`)}async function I(){if(!i||i.length<2)return;q(`action:collage.combine`),y(!0),x(null);let e=await gY(i,{cols:k,gap:u,labels:f,...E.width?{maxWidth:E.width*k}:{}});e?(C(e.reduced),t(new File([e.blob],JV(i.length,e.layout.cols),{type:`image/jpeg`}),Cte(i.length,e.layout.cols,f))):(y(!1),x(`This device couldn't draw the combined image at any size — send them separately instead.`))}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(gE,{title:(0,J.jsxs)(J.Fragment,{children:[D,` images`]}),onClose:r,children:(0,J.jsx)(`span`,{className:`upscale-note`,children:A?`${A.width} × ${A.height}`:``})}),(0,J.jsx)(Z,{children:`Put them on one canvas so a circle or an arrow can span them — that is the only way to point at something that crosses screens. Or keep them apart and mark each in turn.`}),i&&i.length>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`collage-strip`,children:i.map((e,t)=>(0,J.jsxs)(`div`,{className:`collage-chip`,children:[(0,J.jsx)(`img`,{src:j(e),alt:e.name}),(0,J.jsx)(`span`,{className:`collage-chip-n`,children:t+1}),(0,J.jsxs)(`div`,{className:`collage-chip-acts`,children:[(0,J.jsx)(Y,{disabled:t===0,title:`earlier`,onClick:()=>M(t,-1),children:(0,J.jsx)(Hl,{size:14})}),(0,J.jsx)(Y,{disabled:t===i.length-1,title:`later`,onClick:()=>M(t,1),children:(0,J.jsx)(jl,{size:14})})]})]},`${e.name}-${t}`))}),(0,J.jsxs)(`div`,{className:`upscale`,children:[(0,J.jsxs)(`span`,{className:`upscale-head`,children:[(0,J.jsx)(zne,{size:12}),` arrangement`]}),(0,J.jsxs)(Y,{className:c===null?`active`:``,title:`chosen from the shapes of these images`,onClick:()=>N(null),children:[(0,J.jsx)(Gl,{size:13}),` auto`]}),nwe(i.length).map(e=>(0,J.jsx)(Y,{className:c===e?`active`:``,onClick:()=>N(e),children:oa(i.length,e)},e)),(0,J.jsx)(`span`,{className:`upscale-note`,children:c===null?`auto → ${oa(i.length,O)}`:``})]}),(0,J.jsxs)(`div`,{className:`upscale`,children:[(0,J.jsxs)(`span`,{className:`upscale-head`,children:[(0,J.jsx)(Lne,{size:12}),` seam`]}),[`none`,`thin`,`wide`].map(e=>(0,J.jsx)(Y,{className:u===e?`active`:``,onClick:()=>P(e),children:e},e)),(0,J.jsxs)(Y,{className:f?`active`:``,title:`number each panel, so the prompt can say which screen it means`,onClick:F,children:[(0,J.jsx)(kne,{size:13}),` numbers`]})]})]}),(0,J.jsx)(`div`,{className:`collage-prev`,children:m?(0,J.jsx)(`img`,{src:m.url,alt:`combined preview`,className:g?`dim`:``}):(0,J.jsx)(`span`,{className:`upscale-note`,children:b?``:`preparing…`})}),(b||o.length>0)&&(0,J.jsxs)(Z,{tone:`warn`,children:[b,o.length>0&&` ${o.length} file${o.length===1?``:`s`} couldn't be decoded on this device and ${o.length===1?`is`:`are`} not in the picture: ${o.map(e=>e.name).join(`, `)}.`]}),m&&!b&&(0,J.jsxs)(Z,{children:[`One image, `,oa(D,k),f?`, panels numbered`:``,` · goes to the annotator next, and uploads at `,lH(E.width),E.width?` per panel`:``,E.auto?` (auto)`:``,`.`,S?` This device couldn't draw it at full size, so it was drawn smaller.`:``,` Preview is ${zp(m.bytes)}.`]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{disabled:v,title:`mark each image on its own, one after another`,onClick:()=>{q(`action:collage.separate`),n(i?[...i.map(e=>e.file),...o]:e)},children:[(0,J.jsx)(Vo,{size:16}),` keep separate`]}),(0,J.jsxs)(`button`,{className:`send`,disabled:v||!i||i.length<2,onClick:()=>void I(),children:[(0,J.jsx)(ys,{size:16}),` `,v?`combining…`:`combine & mark`]})]})]})}var yY=e=>e===`arrow`||e===`line`||e===`marker`,dwe=e=>e===`arrow`||e===`line`;function bY(e){return e===`text`?[`move`,`turn`]:e===`marker`?[`move`,`size`]:dwe(e)?[`move`,`tail`,`head`]:[`move`,`size`,`turn`]}function fwe(e,t,n,r,i){let a=18/n,o=26/n,s=t.x+t.w/2,c=t.y+t.h/2,l=yY(e.tool)?0:e.angle??0,u=(e,t)=>SY({x:e,y:t},{x:s,y:c},l),d=[];for(let n of bY(e.tool))if(n===`move`){let e=Math.abs(t.w/2*Math.sin(l))+Math.abs(t.h/2*Math.cos(l)),r=c+e,u=c-e,f=r+o+a;d.push(f+a<=i?{knob:n,ax:s,ay:r,x:s,y:f}:{knob:n,ax:s,ay:u,x:s,y:u-o-a})}else if(n===`head`||n===`tail`){let t=xY(e.x1-e.x0,e.y1-e.y0),r=n===`head`?1:-1,i=n===`head`?e.x1:e.x0,s=n===`head`?e.y1:e.y0;d.push({knob:n,ax:i,ay:s,x:i+r*t.x*(o+a),y:s+r*t.y*(o+a)})}else if(n===`size`){if(yY(e.tool)){let t=xY(e.x1-e.x0,e.y1-e.y0);d.push({knob:n,ax:e.x1,ay:e.y1,x:e.x1+t.x*(o+a),y:e.y1+t.y*(o+a)})}else{let e=(o+a)*Math.SQRT1_2,r=u(t.x+t.w,t.y+t.h),i=u(t.x+t.w+e,t.y+t.h+e);d.push({knob:n,ax:r.x,ay:r.y,x:i.x,y:i.y})}}else if(yY(e.tool)){let t=xY(e.x1-e.x0,e.y1-e.y0),r=-t.y,i=t.x;(i>0||i===0&&r>0)&&(r=-r,i=-i);let s=(e.x0+e.x1)/2,c=(e.y0+e.y1)/2;d.push({knob:n,ax:s,ay:c,x:s+r*(o+a),y:c+i*(o+a)})}else{let e=u(s,t.y),r=u(s,t.y-o-a);d.push({knob:n,ax:e.x,ay:e.y,x:r.x,y:r.y})}let f=e=>({x:Math.min(Math.max(e.x,a),Math.max(a,r-a)),y:Math.min(Math.max(e.y,a),Math.max(a,i-a))}),p=[];for(let e of d){let t=e=>p.every(t=>Math.hypot(t.x-e.x,t.y-e.y)>=a*2.2),n=f(e);if(!t(n))search:for(let r=1;r<=12;r++)for(let i of[1,-1]){let a=f(SY(e,{x:s,y:c},i*r*20*Math.PI/180));if(t(a)){n=a;break search}}p.push({...e,x:n.x,y:n.y})}return p}function pwe(e,t,n,r){let i=24/r,a=null,o=1/0;for(let r of e){let e=Math.hypot(r.x-t,r.y-n);e<=i&&e<o&&(a=r,o=e)}return a?.knob??null}function mwe(e,t,n,r,i,a){let o=r.x-n.x,s=r.y-n.y,c=16/i;if(e===`move`)return{...t,x0:t.x0+o,y0:t.y0+s,x1:t.x1+o,y1:t.y1+s};if(e===`head`||e===`tail`){let n=e===`head`,r=n?t.x0:t.x1,i=n?t.y0:t.y1,a=(n?t.x1:t.x0)+o,l=(n?t.y1:t.y0)+s;if(Math.hypot(a-r,l-i)<c){let e=xY(a-r||(n?t.x1-t.x0:t.x0-t.x1),l-i||(n?t.y1-t.y0:t.y0-t.y1));a=r+e.x*c,l=i+e.y*c}return n?{...t,x1:a,y1:l}:{...t,x0:a,y0:l}}let l=a?.x??(t.x0+t.x1)/2,u=a?.y??(t.y0+t.y1)/2;if(e===`turn`){if(Math.hypot(n.x-l,n.y-u)<c||Math.hypot(r.x-l,r.y-u)<c)return t;let e=Math.atan2(r.y-u,r.x-l)-Math.atan2(n.y-u,n.x-l);if(!yY(t.tool))return{...t,angle:hwe((t.angle??0)+e)};let i=SY({x:t.x0,y:t.y0},{x:l,y:u},e),a=SY({x:t.x1,y:t.y1},{x:l,y:u},e);return{...t,x0:i.x,y0:i.y,x1:a.x,y1:a.y}}if(yY(t.tool)){let e=xY(t.x1-t.x0,t.y1-t.y0),n=Math.max(c/2,Math.hypot(t.x1-t.x0,t.y1-t.y0)/2+o*e.x+s*e.y);return{...t,x0:l-e.x*n,y0:u-e.y*n,x1:l+e.x*n,y1:u+e.y*n}}let d=t.angle??0,f=SY({x:o,y:s},{x:0,y:0},-d),p=Math.abs(t.x1-t.x0),m=Math.abs(t.y1-t.y0),h=Math.max(c,p+f.x),g=Math.max(c,m+f.y),_=SY({x:l-p/2,y:u-m/2},{x:l,y:u},d),v=SY({x:h/2,y:g/2},{x:0,y:0},d),y={x:_.x+v.x,y:_.y+v.y};return{...t,x0:y.x-h/2,y0:y.y-g/2,x1:y.x+h/2,y1:y.y+g/2}}function hwe(e){let t=e%(Math.PI*2);return t>Math.PI?t-Math.PI*2:t<=-Math.PI?t+Math.PI*2:t}function xY(e,t){let n=Math.hypot(e,t);return n>1e-6?{x:e/n,y:t/n}:{x:1,y:0}}function SY(e,t,n){let r=Math.cos(n),i=Math.sin(n),a=e.x-t.x,o=e.y-t.y;return{x:t.x+a*r-o*i,y:t.y+a*i+o*r}}var gwe={move:`#2f80ed`,size:`#f2994a`,turn:`#27ae60`,tail:`#f2994a`,head:`#f2994a`};function _we(e){let t={move:`blue moves`,size:yY(e)?`orange sets the length`:`orange sizes`,turn:`green turns`,tail:`orange drags that end`,head:`orange drags that end`},n=[...new Set(bY(e).map(e=>t[e]))];return n[0][0].toUpperCase()+n.join(` · `).slice(1)}function vwe(e,t,n,r,i,a){e.save(),e.strokeStyle=`#fff`,e.lineWidth=a,e.lineCap=`round`,e.lineJoin=`round`;let o=i*.35;if(e.beginPath(),t===`move`){e.moveTo(n-i,r),e.lineTo(n+i,r),e.moveTo(n,r-i),e.lineTo(n,r+i);for(let[t,a]of[[1,0],[-1,0],[0,1],[0,-1]]){let s=n+t*i,c=r+a*i;e.moveTo(s-t*o+a*o,c-a*o+t*o),e.lineTo(s,c),e.lineTo(s-t*o-a*o,c-a*o-t*o)}}else if(t===`head`||t===`tail`)e.arc(n,r,i*.55,0,Math.PI*2);else if(t===`size`){let t=i*.75;e.moveTo(n-t,r-t),e.lineTo(n+t,r+t),e.moveTo(n-t+o*1.4,r-t),e.lineTo(n-t,r-t),e.lineTo(n-t,r-t+o*1.4),e.moveTo(n+t-o*1.4,r+t),e.lineTo(n+t,r+t),e.lineTo(n+t,r+t-o*1.4)}else{let t=-Math.PI*.25;e.arc(n,r,i*.8,t,Math.PI*1.45);let a=n+Math.cos(t)*i*.8,s=r+Math.sin(t)*i*.8;e.moveTo(a-o*1.2,s-o*.2),e.lineTo(a,s),e.lineTo(a+o*.1,s-o*1.2)}e.stroke(),e.restore()}function ywe({m:e}){let{tool:t,shapes:n,moveMode:r,selected:i,target:a,setTarget:o,moveNote:s,knobs:c,err:l,cropMode:u,pendingCrop:d,pendingText:f,textDraft:p,setTextDraft:m,textInputRef:h,editRead:g,setEditRead:_,readDraft:v,setReadDraft:y,readInputRef:b,lastBand:x,applyCrop:S,toggleCrop:C,commitText:w,cancelText:T,startEditRead:E,commitRead:D,dropRead:O,hintHidden:k,hideHint:A}=e;return(0,J.jsxs)(J.Fragment,{children:[u?(0,J.jsxs)(`div`,{className:`annot-crop-bar`,children:[(0,J.jsx)(`span`,{className:`annot-hint`,children:d?`crop to ${Math.round(d.w)}×${Math.round(d.h)}`:`drag a box to crop`}),(0,J.jsx)(`button`,{className:`send`,disabled:!d,onClick:S,children:`Apply crop`}),(0,J.jsx)(Y,{onClick:C,children:`cancel`})]}):g==null?f?(0,J.jsxs)(`div`,{className:`annot-crop-bar`,children:[(0,J.jsx)(`input`,{className:`search annot-text-in`,ref:h,value:p,placeholder:`label text`,"aria-label":`label text`,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w())}}),(0,J.jsx)(`button`,{className:`send`,disabled:!p.trim(),onClick:w,children:`Place`}),(0,J.jsx)(Y,{onClick:T,children:`cancel`})]}):r&&i!=null&&n[i]&&c?(0,J.jsx)(`div`,{className:`annot-hint`,children:s??_we(n[i].tool)}):r&&i!=null&&n[i]?n[i].tool===`text`?(0,J.jsx)(`div`,{className:`annot-hint`,children:`Drag anywhere to move the label — from beside the picture too.`}):(0,J.jsxs)(`div`,{className:`annot-crop-bar`,children:[(0,J.jsx)(Y,{className:a===null?`active`:``,onClick:()=>o(null),"aria-pressed":a===null,children:`whole`}),(0,J.jsx)(Y,{className:a===0?`active`:``,onClick:()=>o(0),"aria-pressed":a===0,children:n[i].tool===`arrow`?`tail`:`A`}),(0,J.jsx)(Y,{className:a===1?`active`:``,onClick:()=>o(1),"aria-pressed":a===1,children:n[i].tool===`arrow`?`head`:`B`}),(0,J.jsx)(`span`,{className:`annot-hint`,children:s??`Drag anywhere — the finger needn't be on the mark · pinch to zoom for finer steps`})]}):k?null:(0,J.jsxs)(`div`,{className:`annot-hint annot-hint-x`,children:[(0,J.jsx)(`span`,{children:r?`Tap a mark to select it`:t===`text`?`Tap where the label goes, then type it · two fingers pinch-zoom & pan`:t===`marker`?`Swipe along a line of text to point at it · Claude reads the words off the picture`:`One finger draws, from beside the picture too · two fingers pinch-zoom & pan · crop trims the image`}),(0,J.jsx)(Y,{onClick:A,"aria-label":`hide this hint for good`,children:(0,J.jsx)(V,{size:14,"aria-hidden":!0})})]}):(0,J.jsxs)(`div`,{className:`annot-crop-bar`,children:[(0,J.jsx)(`input`,{className:`search annot-text-in`,ref:b,value:v,placeholder:`the highlighted words`,"aria-label":`the highlighted words`,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())}}),(0,J.jsx)(`button`,{className:`send`,onClick:D,children:`Use`}),(0,J.jsx)(Y,{onClick:()=>{_(null),y(``)},children:`cancel`})]}),x&&!u&&f==null&&g==null&&(0,J.jsx)(`div`,{className:`annot-read`,children:x.read?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`annot-hint annot-read-text`,children:[`reads: “`,x.read,`”`]}),(0,J.jsx)(Y,{onClick:()=>E(x),children:`edit`}),(0,J.jsx)(Y,{onClick:()=>O(x),children:`drop`})]}):x.reading?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`annot-hint`,children:`reading…`}),(0,J.jsx)(Y,{onClick:()=>E(x),children:`type its words`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`annot-hint`,children:x.readErr??`the mark says where to look · its words are optional`}),(0,J.jsx)(Y,{onClick:()=>E(x),children:`type its words`})]})}),l&&(0,J.jsx)(`div`,{className:`err`,children:l})]})}var bwe=`(min-width: 1280px)`,CY=G(!1),wY=G(!1);function TY(){return K(wY)}function EY(){return K(CY)}if(typeof window<`u`)try{let e=window.matchMedia?.(bwe);if(e){let t=()=>CY.set(e.matches);t(),e.addEventListener?.(`change`,t)}}catch{}var DY=null;function xwe(e){return DY=e,()=>{DY===e&&(DY=null)}}function Swe(){return DY}function Cwe({m:e}){let{view:t,fitRef:n,zoomed:r,resetZoom:i,configOpen:a,setConfigOpen:o}=e,s=EY(),c=TY(),l=s&&!!e.props.onDispatch,{send:u}=e;return(0,H.useEffect)(()=>l?xwe(e=>void u(e)):void 0,[l,u]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{className:r?`active`:``,onClick:i,title:`reset zoom`,"aria-label":`reset zoom`,children:[(0,J.jsx)(el,{size:16}),` `,(t.k/(n.current.k||1)).toFixed(1),`×`]}),(0,J.jsx)(Y,{className:a?`active`:``,onClick:()=>o(e=>!e),"aria-pressed":a,title:`customize the toolbar`,"aria-label":`customize the toolbar`,children:(0,J.jsx)(Os,{size:16})}),l&&(0,J.jsx)(Y,{className:c?`active`:``,onClick:()=>wY.set(!c),"aria-pressed":c,title:c?`back beside the session (Esc)`:`full screen — the session stays where it is`,"aria-label":c?`exit annotator full screen`:`annotator full screen`,children:c?(0,J.jsx)(yc,{size:16}):(0,J.jsx)(wc,{size:16})})]})}function wwe({prompt:e}){let[t,n]=(0,H.useState)(()=>io(B.annPrompt,!1)),r=()=>n(e=>(Za(B.annPrompt,e?`0`:`1`),!e)),i=e.value.trim().split(`
|
|
205
|
-
`)[0];return(0,J.jsxs)(`div`,{className:`ann-prompt`,children:[(0,J.jsxs)(`button`,{className:`ann-prompt-fold`,onClick:r,"aria-expanded":t,title:t?`fold the message box away`:`show the session's message box — typed here, sent with the picture on Send & run`,children:[t?(0,J.jsx)(ac,{size:14}):(0,J.jsx)(jl,{size:14}),(0,J.jsx)(Qne,{size:14}),(0,J.jsx)(`span`,{className:`ann-prompt-gist`,children:t?`message for the session`:i||`message for the session — empty`})]}),t&&(0,J.jsx)(uD,{inline:!0,rows:2,prompts:[e.value],onChange:t=>e.onChange(t[0]??``),placeholder:`Message for the session — Send & run sends it with the picture`})]})}function Twe({m:e}){let{busy:t,send:n,sendAll:r,readAll:i}=e,{index:a,total:o,onSkip:s,onSendAll:c,onDispatch:l,onText:u}=e.props;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(yH,{compact:!0}),(0,J.jsxs)(`div`,{className:`sheet-actions annot-send-bar`,"data-primary-key":``,children:[s&&(0,J.jsx)(Y,{onClick:s,disabled:t,children:`skip`}),c&&o&&o>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:()=>r(`none`),disabled:t,title:`send this + every remaining image as-is`,children:`Send all`}),(0,J.jsx)(Y,{onClick:()=>r(`run`),disabled:t,title:`send all, then submit once uploads finish`,children:`Send all + submit`}),(0,J.jsxs)(Y,{onClick:()=>r(`queue`),disabled:t,title:`send all, then hand the prompt to the desktop — it goes in when this session is free`,children:[(0,J.jsx)(Kl,{size:14}),` Send all, then when it's free`]})]}),l&&(!o||o<=1)&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:()=>n(`run`),disabled:t,title:`attach the image and run the prompt (uploads in the background)`,children:`Send & run`}),(0,J.jsxs)(Y,{onClick:()=>n(`queue`),disabled:t,title:`attach the image and hand the prompt to the desktop — it goes in when this session is free`,children:[(0,J.jsx)(Kl,{size:14}),` Send & when it's free`]})]}),u&&(0,J.jsxs)(Y,{onClick:()=>void i(),disabled:t,title:`read every word on the desktop and send only the text, not the photo`,children:[(0,J.jsx)(fc,{size:14}),` text only`]}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>n(`none`),disabled:t,children:t?`Sending…`:o&&o>1&&(a??1)<o?`Send & next`:`Send to repo`})]})]})}var OY=[{id:`undo`,label:`undo`},{id:`circle`,label:`circle`},{id:`rect`,label:`rectangle`},{id:`arrow`,label:`arrow`},{id:`line`,label:`line`},{id:`text`,label:`text label`},{id:`marker`,label:`highlight text`},{id:`blur`,label:`blur / redact`},{id:`crop`,label:`crop`},{id:`move`,label:`move a mark`},{id:`style`,label:`colour & stroke`},{id:`clear`,label:`clear all marks`}],kY=OY.map(e=>e.id),Ewe=[`auto`,`left`,`top`],AY={order:kY.slice(),hidden:[],place:`auto`},jY=e=>typeof e==`string`&&kY.includes(e);function Dwe(e){if(!e||typeof e!=`object`)return{...AY,order:kY.slice()};let t=e,n=new Set,r=[];for(let e of Array.isArray(t.order)?t.order:[])jY(e)&&!n.has(e)&&(n.add(e),r.push(e));return kY.forEach((e,t)=>{if(n.has(e))return;let i=0;for(let e=t-1;e>=0;e--){let t=r.indexOf(kY[e]);if(t>=0){i=t+1;break}}r.splice(i,0,e),n.add(e)}),{order:r,hidden:(Array.isArray(t.hidden)?t.hidden:[]).filter(jY).filter((e,t,n)=>n.indexOf(e)===t),place:Ewe.includes(t.place)?t.place:`auto`}}function Owe(e){return e.order.filter(t=>!e.hidden.includes(t))}function kwe(e,t){let n=e.hidden.includes(t)?e.hidden.filter(e=>e!==t):[...e.hidden,t];return{...e,hidden:n}}function MY(e,t,n){let r=e.order.indexOf(t),i=r+n;if(r<0||i<0||i>=e.order.length)return e;let a=e.order.slice();return[a[r],a[i]]=[a[i],a[r]],{...e,order:a}}function Awe(e){return e.place===`auto`&&!e.hidden.length&&e.order.every((e,t)=>e===kY[t])}function jwe(e,t){if(!e||!t||e.w<1||e.h<1||t.w<1||t.h<1)return null;let n=(e,n)=>Math.min(Math.max(e,0)/t.w,Math.max(n,0)/t.h),r=n(e.w-57,e.h);return n(e.w,e.h-61)>r?`top`:`left`}var Mwe=[{v:`auto`,label:`auto`},{v:`left`,label:`left`},{v:`top`,label:`top`}];function Nwe({m:e}){let{layout:t,setLayout:n,setConfigOpen:r}=e,i=e=>OY.find(t=>t.id===e)?.label??e,a=t.order.length-1;return(0,J.jsxs)(`div`,{className:`annot-config`,role:`dialog`,"aria-label":`customize the toolbar`,children:[(0,J.jsxs)(`div`,{className:`annot-config-head`,children:[(0,J.jsx)(`span`,{children:`Toolbar`}),(0,J.jsxs)(Y,{onClick:()=>r(!1),"aria-label":`close the toolbar settings`,children:[(0,J.jsx)(V,{size:16}),` done`]})]}),(0,J.jsxs)(`div`,{className:`annot-config-row`,children:[(0,J.jsx)(`span`,{className:`annot-config-label`,children:`position`}),Mwe.map(e=>(0,J.jsx)(Y,{className:t.place===e.v?`active`:``,"aria-pressed":t.place===e.v,onClick:()=>n({...t,place:e.v}),children:e.label},e.v))]}),(0,J.jsx)(`div`,{className:`annot-config-hint`,children:t.place===`auto`?`auto: whichever side leaves this picture larger — a row on top for a wide one, a rail on the left for a tall one`:`always on the ${t.place}`}),(0,J.jsx)(`div`,{className:`annot-config-list`,children:t.order.map((e,r)=>{let o=!t.hidden.includes(e);return(0,J.jsxs)(`div`,{className:`annot-config-row ${o?``:`off`}`,children:[(0,J.jsx)(Y,{className:`annot-config-toggle${o?` active`:``}`,"aria-pressed":o,onClick:()=>n(kwe(t,e)),children:o?`shown`:`hidden`}),(0,J.jsx)(`span`,{className:`annot-config-label`,children:i(e)}),r>0?(0,J.jsx)(Y,{onClick:()=>n(MY(t,e,-1)),"aria-label":`move ${i(e)} up`,children:(0,J.jsx)(Ys,{size:16})}):(0,J.jsx)(`span`,{className:`annot-config-gap`}),r<a?(0,J.jsx)(Y,{onClick:()=>n(MY(t,e,1)),"aria-label":`move ${i(e)} down`,children:(0,J.jsx)(ac,{size:16})}):(0,J.jsx)(`span`,{className:`annot-config-gap`})]},e)})}),!Awe(t)&&(0,J.jsx)(`div`,{className:`annot-config-row`,children:(0,J.jsx)(Y,{onClick:()=>n({...AY,order:AY.order.slice()}),children:`reset to default`})})]})}var NY=[`#ff2d2d`,`#ffd400`,`#3fb950`,`#4c9aff`,`#ffffff`],Pwe=`#ffd400`,PY=[{label:`S`,factor:.6},{label:`M`,factor:1},{label:`L`,factor:1.8}];function Fwe(e){return e instanceof File,e.name}var Iwe={circle:{tool:`circle`,icon:(0,J.jsx)(vc,{size:16}),label:`circle`},rect:{tool:`rect`,icon:(0,J.jsx)(Rc,{size:16}),label:`rectangle`},arrow:{tool:`arrow`,icon:(0,J.jsx)(qne,{size:16}),label:`arrow`},line:{tool:`line`,icon:(0,J.jsx)(hs,{size:16}),label:`line`},text:{tool:`text`,icon:(0,J.jsx)(Dc,{size:16}),label:`text`},marker:{tool:`marker`,icon:(0,J.jsx)(bne,{size:16}),label:`highlight text`},blur:{tool:`blur`,icon:(0,J.jsx)(Gc,{size:16}),label:`blur or redact`}};function Lwe({m:e}){let{tool:t,color:n,setColor:r,factor:i,setFactor:a,shapes:o,setShapes:s,moveMode:c,selected:l,setSelected:u,setTarget:d,setMoveNote:f,knobs:p,cropMode:m,paletteOpen:h,setPaletteOpen:g,moveRef:_,toggleCrop:v,pickTool:y,undoShape:b,toggleMove:x,toggleKnobs:S,deleteSelected:C,layout:w}=e,T=PY.find(e=>e.factor===i)?.label??`M`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`annot-tools annot-bar`,children:Owe(w).map(e=>{let r=Iwe[e];if(r)return(0,J.jsx)(Y,{className:t===r.tool?`active`:``,onClick:()=>y(r.tool),title:r.label,"aria-label":r.label,"aria-pressed":t===r.tool,children:r.icon},e);switch(e){case`undo`:return(0,J.jsx)(Y,{onClick:b,disabled:!o.length,title:`undo`,"aria-label":`undo the last mark`,children:(0,J.jsx)(Ac,{size:16})},e);case`crop`:return(0,J.jsx)(Y,{className:m?`active`:``,onClick:v,title:`crop`,"aria-label":`crop`,"aria-pressed":m,children:(0,J.jsx)(Fne,{size:16})},e);case`move`:return[(0,J.jsx)(Y,{className:c?`active`:``,onClick:x,disabled:!o.length,title:`move/reshape a mark`,"aria-label":`move a mark`,"aria-pressed":c,children:(0,J.jsx)(Pne,{size:16})},e),c&&(0,J.jsx)(Y,{onClick:C,disabled:l==null,title:`delete the selected mark`,"aria-label":`delete the selected mark`,children:(0,J.jsx)(ic,{size:16})},`del`),c&&(0,J.jsx)(Y,{className:p?`active`:``,onClick:S,"aria-pressed":p,title:`knobs: move, size and turn a mark (or drag an arrow's ends) by knobs on strings, instead of dragging from anywhere`,"aria-label":`knobs on the selected mark`,children:`knobs`},`knobs`)];case`style`:return(0,J.jsx)(`button`,{className:`swatch dot annot-style ${h?`on`:``}`,style:{background:n},onClick:()=>g(e=>!e),title:`mark colour and stroke`,"aria-label":`mark colour ${n}, stroke ${T} — tap to change`,"aria-expanded":h,children:T},e);case`clear`:return(0,J.jsx)(Y,{onClick:()=>{_.current=null,u(null),d(null),f(null),s([])},disabled:!o.length,title:`clear all marks`,"aria-label":`clear all marks`,children:(0,J.jsx)(Vc,{size:16})},e)}return null})}),h&&(0,J.jsxs)(`div`,{className:`annot-tools annot-palette`,children:[NY.map(e=>(0,J.jsx)(`button`,{className:`swatch ${n===e?`on`:``}`,style:{background:e},onClick:()=>{r(e),g(!1)},title:`colour ${e}`,"aria-label":`colour ${e}`,"aria-pressed":n===e},e)),PY.map(e=>(0,J.jsx)(Y,{className:i===e.factor?`active`:``,onClick:()=>{a(e.factor),g(!1)},title:`stroke ${e.label}`,"aria-label":`stroke ${e.label}`,"aria-pressed":i===e.factor,children:e.label},e.label))]})]})}function Rwe({m:e}){let{canvasRef:t,wrapRef:n,bodyRef:r,view:i,onDown:a,onMove:o,onUp:s,place:c,configOpen:l}=e;return(0,J.jsxs)(`div`,{className:`annot-body place-${c}`,ref:r,children:[(0,J.jsx)(Lwe,{m:e}),(0,J.jsx)(`div`,{className:`annot-canvas-wrap`,ref:n,onPointerDown:a,onPointerMove:o,onPointerUp:s,onPointerCancel:s,children:(0,J.jsx)(`canvas`,{ref:t,className:`annot-canvas`,style:{transform:`translate(${i.tx}px, ${i.ty}px) scale(${i.k})`,transformOrigin:`0 0`}})}),l&&(0,J.jsx)(Nwe,{m:e})]})}function zwe({m:e}){let{ocr:t,ocrDraft:n,setOcrDraft:r,readAll:i,closeOcr:a,sendText:o}=e;if(!t)return null;let s=!n.trim();return(0,J.jsxs)(`div`,{className:`annot-ocr`,children:[t.phase===`reading`&&(0,J.jsx)(`div`,{className:`annot-hint`,children:`Reading every word on your desktop… The photo goes no further than that machine.`}),t.phase===`error`&&(0,J.jsx)(`div`,{className:`annot-hint`,children:t.error}),t.phase===`ready`&&(0,J.jsxs)(`div`,{className:`annot-hint`,children:[`Read on your desktop (`,t.engine,`, `,(t.ms/1e3).toFixed(1),` s). Fix anything misread — only this text is sent, never the photo.`]}),(t.phase===`ready`||!s)&&(0,J.jsx)(`textarea`,{className:`annot-ocr-text`,value:n,onChange:e=>r(e.target.value),spellCheck:!1,autoCapitalize:`off`,"aria-label":`text read off the picture`}),t.phase===`ready`&&s&&(0,J.jsx)(`div`,{className:`annot-hint`,children:`Nothing left to send — read again, or go back to the picture.`}),(0,J.jsxs)(`div`,{className:`sheet-actions annot-send-bar`,"data-primary-key":``,children:[(0,J.jsxs)(Y,{onClick:a,children:[(0,J.jsx)(pl,{size:14}),` picture`]}),t.phase!==`reading`&&(0,J.jsxs)(Y,{onClick:()=>void i(),children:[(0,J.jsx)($c,{size:14}),` read again`]}),t.phase!==`reading`&&!s&&(0,J.jsxs)(`button`,{className:`send`,onClick:()=>o(n),children:[(0,J.jsx)(fc,{size:14}),` Send text only`]})]})]})}var Bwe={"#ff2d2d":`red`,"#ffd400":`yellow`,"#3fb950":`green`,"#4c9aff":`blue`,"#ffffff":`white`};function Vwe(e,t,n,r){let i=t/r,a=e/n,o=i<.34?`top`:i>.66?`bottom`:`middle`,s=a<.34?`left`:a>.66?`right`:`center`;return o===`middle`&&s===`center`?`center`:o===`middle`?s:s===`center`?o:`${o}-${s}`}function FY(e){return`${Math.round(Math.max(0,Math.min(1,e))*100)}%`}function IY(e,t,n,r){return`${Vwe(e,t,n,r)} (x ${FY(e/n)}, y ${FY(t/r)})`}function LY(e,t,n){let r=Math.min(e.x0,e.x1),i=Math.max(e.x0,e.x1),a=Math.min(e.y0,e.y1),o=Math.max(e.y0,e.y1);return`(x ${FY(r/t)}-${FY(i/t)}, y ${FY(a/n)}-${FY(o/n)})`}function RY(e){return`"${e.replace(/\s+/g,` `).trim().replace(/"/g,`''`)}"`}var Hwe=e=>Bwe[e.toLowerCase()]||e;function Uwe(e,t,n){return[e.tool,e.color.toLowerCase(),FY(Math.min(e.x0,e.x1)/t),FY(Math.min(e.y0,e.y1)/n),FY(Math.max(e.x0,e.x1)/t),FY(Math.max(e.y0,e.y1)/n),(e.text??``).trim(),(e.read??``).trim()].join(`|`)}function zY(e,t,n){if(t<=0||n<=0)return[];let r=new Set,i=[];for(let a of e){let e=Uwe(a,t,n);r.has(e)||(r.add(e),i.push(a))}return i}function Wwe(e,t,n){switch(e.tool){case`blur`:return`blurred/redacted region ${LY(e,t,n)}`;case`text`:return`text ${RY(e.text||``)} at ${IY(e.x0,e.y0,t,n)}`;case`marker`:return e.read?`highlight over ${RY(e.read)} ${LY(e,t,n)}`:`highlight ${LY(e,t,n)}`;case`arrow`:return`arrow pointing to ${IY(e.x1,e.y1,t,n)}`;case`line`:return`line from ${IY(e.x0,e.y0,t,n)} to ${IY(e.x1,e.y1,t,n)}`;case`rect`:return e.read?`box around ${RY(e.read)} ${LY(e,t,n)}`:`box ${LY(e,t,n)}`;default:return e.read?`circle around ${RY(e.read)} ${LY(e,t,n)}`:`circle ${LY(e,t,n)}`}}function Gwe(e,t,n,r){let i=zY(e,t,n),a=[];r&&a.push(r);let o=i.length>1,s=new Set(i.map(e=>e.color.toLowerCase())).size<=1;return i.forEach((e,r)=>{let i=o?`#${r+1} `:``,c=s||e.tool===`blur`?``:`${Hwe(e.color)} `;a.push(`${i}${c}${Wwe(e,t,n)}`)}),a.join(`; `)}function BY(e,t){return!e||!t||!(t.w>0)||!(t.h>0)?e:`${e}; image ${Math.round(t.w)}x${Math.round(t.h)}`}var Kwe=new Set([`rect`,`blur`,`marker`]),VY=(e,t)=>tm(e,0,t);function HY(e,t,n){return Math.max(e.x0,e.x1)>0&&Math.min(e.x0,e.x1)<t&&Math.max(e.y0,e.y1)>0&&Math.min(e.y0,e.y1)<n}function UY(e,t){let n=(e.x0+e.x1)/2,r=(e.y0+e.y1)/2,i=Math.abs(e.x1-e.x0)/2,a=Math.abs(e.y1-e.y0)/2,o=Math.abs(i*Math.cos(t))+Math.abs(a*Math.sin(t)),s=Math.abs(i*Math.sin(t))+Math.abs(a*Math.cos(t));return{x0:n-o,y0:r-s,x1:n+o,y1:r+s}}function qwe(e,t,n){let r=e.x1-e.x0,i=e.y1-e.y0,a=0,o=1,s=[[-r,e.x0-0],[r,t-e.x0],[-i,e.y0-0],[i,n-e.y0]];for(let[e,t]of s){if(e===0){if(t<0)return null;continue}let n=t/e;if(e<0){if(n>o)return null;n>a&&(a=n)}else{if(n<a)return null;n<o&&(o=n)}}return{x0:e.x0+a*r,y0:e.y0+a*i,x1:e.x0+o*r,y1:e.y0+o*i}}function WY(e,t,n){if(!(t>0&&n>0))return e;if(e.tool===`text`){let r=VY(e.x0,t),i=VY(e.y0,n);return{...e,x0:r,y0:i,x1:r,y1:i}}if(e.tool===`line`||e.tool===`arrow`){let r=qwe(e,t,n);return r?{...e,...r}:null}return e.angle?HY(UY(e,e.angle),t,n)?e:null:HY(e,t,n)?Kwe.has(e.tool)?{...e,x0:VY(e.x0,t),y0:VY(e.y0,n),x1:VY(e.x1,t),y1:VY(e.y1,n)}:e:null}function GY(e,t){return e.tool!==`text`&&Math.hypot(e.x1-e.x0,e.y1-e.y0)*t<48}function Jwe(e){let{sel:t,small:n,handleHit:r,pickHit:i,target:a}=e;return t!=null&&!n&&r!=null?{kind:`handle`,i:t,h:r}:i==null?t==null?{kind:`none`}:{kind:`relative`,i:t,h:a}:{kind:`pick`,i}}function Ywe(e,t,n,r){let i=WY(e,n,r);return i?{mark:i,refused:!1}:{mark:t,refused:!0}}function KY(e){return Math.max(4,Math.round(e.width/220))}function qY(e){return{x:Math.min(e.x0,e.x1),y:Math.min(e.y0,e.y1),w:Math.abs(e.x1-e.x0),h:Math.abs(e.y1-e.y0)}}function JY(e,t){if(!e)return t;let n=t=>Math.max(0,Math.min(t,e.width)),r=t=>Math.max(0,Math.min(t,e.height)),i=n(t.x),a=r(t.y);return{x:i,y:a,w:n(t.x+t.w)-i,h:r(t.y+t.h)-a}}function Xwe(e){let t=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!t)return`#fff`;let n=parseInt(t[1],16);return(.299*(n>>16&255)+.587*(n>>8&255)+.114*(n&255))/255>.6?`#111`:`#fff`}function Zwe(e){if(e.tool===`text`||e.tool===`arrow`||e.tool===`line`)return{x:e.x0,y:e.y0};let t=qY(e);if(!e.angle)return{x:t.x,y:t.y};let n=t.x+t.w/2,r=t.y+t.h/2,i=Math.cos(e.angle),a=Math.sin(e.angle);return{x:n+-t.w/2*i- -t.h/2*a,y:r+-t.w/2*a+-t.h/2*i}}function YY(e,t,n){if(n.tool===`text`){let r=Math.max(16,Math.round(t.width/26))*n.factor;e.save(),e.font=`bold ${r}px ui-sans-serif, system-ui, sans-serif`;let i=e.measureText(n.text||``).width;return e.restore(),{x:n.x0,y:n.y0,w:i,h:r*1.2}}return qY(n)}function Qwe(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0;return Math.hypot(e-(n+l*o),t-(r+l*s))}function $we(e,t,n,r,i){if(!e)return!1;if(t.tool===`arrow`||t.tool===`line`)return Qwe(n,r,t.x0,t.y0,t.x1,t.y1)<=i;let a=YY(e.getContext(`2d`),e,t);if(t.angle){let e=a.x+a.w/2,i=a.y+a.h/2,o=Math.cos(-t.angle),s=Math.sin(-t.angle),c=e+(n-e)*o-(r-i)*s,l=i+(n-e)*s+(r-i)*o;n=c,r=l}return n>=a.x-i&&n<=a.x+a.w+i&&r>=a.y-i&&r<=a.y+a.h+i}function eTe(e,t,n){if(!n)return;let r=KY(t);e.save(),e.fillStyle=`rgba(0,0,0,.55)`,e.beginPath(),e.rect(0,0,t.width,t.height),e.rect(n.x,n.y,n.w,n.h),e.fill(`evenodd`),e.strokeStyle=`#fff`,e.lineWidth=r,e.setLineDash([r*2.5,r*2.5]),e.strokeRect(n.x,n.y,n.w,n.h),e.restore()}function XY(e,t,n,r){if(!n)return;if(r.angle){let i=qY(r),a=i.x+i.w/2,o=i.y+i.h/2;e.save(),e.beginPath(),e.translate(a,o),e.rotate(r.angle),e.rect(-i.w/2,-i.h/2,i.w,i.h),e.setTransform(1,0,0,1,0,0),e.clip(),XY(e,t,n,{...r,angle:0,...UY(r,r.angle)}),e.restore();return}let{x:i,y:a,w:o,h:s}=JY(t,qY(r));if(o<1||s<1)return;let c=Math.max(8,Math.round(t.width/48)),l=Math.max(1,Math.round(o/c)),u=Math.max(1,Math.round(s/c)),d=document.createElement(`canvas`);d.width=l,d.height=u,d.getContext(`2d`).drawImage(n,i,a,o,s,0,0,l,u),e.save(),e.imageSmoothingEnabled=!1,e.drawImage(d,0,0,l,u,i,a,o,s),e.restore()}function tTe(e,t,n){let r=qY(n),i=KY(t)*5*n.factor,a=Math.max(r.h,i),o=r.h>=i?r.y:r.y-(i-r.h)/2;e.save(),e.globalAlpha=.38,e.globalCompositeOperation=`multiply`,e.fillStyle=n.color,e.fillRect(r.x,o,Math.max(r.w,i),a),e.restore()}function nTe(e,t,n){if(n.length<2)return;let r=Math.max(10,KY(t)*3.2);n.forEach((n,i)=>{let a=Zwe(n),o=Math.max(r+2,Math.min(t.width-r-2,a.x-r*.2)),s=Math.max(r+2,Math.min(t.height-r-2,a.y-r*.2));e.save(),e.beginPath(),e.arc(o,s,r,0,Math.PI*2),e.fillStyle=n.tool===`blur`?`#111`:n.color,e.fill(),e.lineWidth=Math.max(1,r*.14),e.strokeStyle=`rgba(0,0,0,.55)`,e.stroke(),e.fillStyle=n.tool===`blur`?`#fff`:Xwe(n.color),e.font=`bold ${Math.round(r*1.25)}px ui-sans-serif, system-ui, sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(String(i+1),o,s),e.restore()}),e.textAlign=`start`}function ZY(e,t,n,r){if(!r.angle||r.tool===`blur`||r.tool===`arrow`||r.tool===`line`){QY(e,t,n,r);return}let i=YY(e,t,r),a=i.x+i.w/2,o=i.y+i.h/2;e.save(),e.translate(a,o),e.rotate(r.angle),e.translate(-a,-o),QY(e,t,n,r),e.restore()}function QY(e,t,n,r){if(r.tool===`blur`){XY(e,t,n,r);return}if(r.tool===`marker`){tTe(e,t,r);return}let i=KY(t)*r.factor;if(e.strokeStyle=r.color,e.fillStyle=r.color,e.lineWidth=i,e.lineCap=`round`,e.lineJoin=`round`,r.tool===`rect`)e.strokeRect(r.x0,r.y0,r.x1-r.x0,r.y1-r.y0);else if(r.tool===`circle`)e.beginPath(),e.ellipse((r.x0+r.x1)/2,(r.y0+r.y1)/2,Math.abs(r.x1-r.x0)/2,Math.abs(r.y1-r.y0)/2,0,0,Math.PI*2),e.stroke();else if(r.tool===`arrow`||r.tool===`line`){let t=Math.atan2(r.y1-r.y0,r.x1-r.x0),n=i*4;if(e.beginPath(),e.moveTo(r.x0,r.y0),e.lineTo(r.x1,r.y1),e.stroke(),r.tool===`line`)return;e.beginPath(),e.moveTo(r.x1,r.y1),e.lineTo(r.x1-n*Math.cos(t-Math.PI/6),r.y1-n*Math.sin(t-Math.PI/6)),e.lineTo(r.x1-n*Math.cos(t+Math.PI/6),r.y1-n*Math.sin(t+Math.PI/6)),e.closePath(),e.fill()}else if(r.tool===`text`&&r.text){let n=Math.max(16,Math.round(t.width/26))*r.factor;e.font=`bold ${n}px ui-sans-serif, system-ui, sans-serif`,e.textBaseline=`top`,e.lineWidth=Math.max(2,n/8),e.strokeStyle=`rgba(0,0,0,.65)`,e.strokeText(r.text,r.x0,r.y0),e.fillText(r.text,r.x0,r.y0)}}function rTe(e,t,n,r,i,a){let o=YY(e,t,n),s=Math.max(1,KY(t)*.6),c=GY(n,r),l=c?Math.max(s*3,48/r/2):s*3;if(e.save(),n.angle&&n.tool!==`arrow`&&n.tool!==`line`){let t=o.x+o.w/2,r=o.y+o.h/2;e.translate(t,r),e.rotate(n.angle),e.translate(-t,-r)}if(e.strokeStyle=`#4c9aff`,e.lineWidth=s,e.setLineDash([s*3,s*3]),e.strokeRect(o.x-l,o.y-l,o.w+l*2,o.h+l*2),e.setLineDash([]),i)e.restore(),iTe(e,t,n,r);else if(n.angle)e.restore();else{if(n.tool!==`text`&&!c){let r=KY(t)*1.8;[[0,n.x0,n.y0],[1,n.x1,n.y1]].forEach(([t,n,i])=>{e.beginPath(),e.arc(n,i,r,0,Math.PI*2),e.fillStyle=a===t?`#4c9aff`:`#fff`,e.fill(),e.stroke()})}e.restore()}}function $Y(e,t,n){return fwe(t,YY(e.getContext(`2d`),e,t),n,e.width,e.height)}function iTe(e,t,n,r){let i=18/r,a=$Y(t,n,r);e.save(),e.lineCap=`round`;for(let t of a)e.beginPath(),e.moveTo(t.ax,t.ay),e.lineTo(t.x,t.y),e.strokeStyle=`rgba(255,255,255,0.85)`,e.lineWidth=4/r,e.stroke(),e.strokeStyle=`#4c9aff`,e.lineWidth=2/r,e.stroke();for(let t of a)e.beginPath(),e.arc(t.x,t.y,i,0,Math.PI*2),e.fillStyle=gwe[t.knob],e.fill(),e.lineWidth=2/r,e.strokeStyle=`#fff`,e.stroke(),vwe(e,t.knob,t.x,t.y,i*.5,2/r);e.restore()}function aTe(e){let{canvasRef:t,wrapRef:n,imgRef:r,setTool:i,color:a,setColor:o,factor:s,setShapes:c,setMoveMode:l,setSelected:u,selectedRef:d,setTarget:f,targetRef:p,setMoveNote:m,setKnobs:h,moveRef:g,setCropMode:_,pendingCrop:v,setPendingCrop:y,cropDrag:b,pendingText:x,setPendingText:S,textDraft:C,setTextDraft:w,textInputRef:T,idRef:E,setPaletteOpen:D,setView:O,viewRef:k,fitRef:A,redraw:j,clampToImage:M}=e;async function N(){let e=r.current,i=t.current;if(!e||!i||!v)return;let{x:a,y:o,w:s,h:l}=M(v);if(s<1||l<1){y(null);return}let u=document.createElement(`canvas`);u.width=Math.round(s),u.height=Math.round(l),u.getContext(`2d`).drawImage(e,a,o,s,l,0,0,u.width,u.height);try{r.current=await createImageBitmap(u)}catch{r.current=u}i.width=u.width,i.height=u.height,c(e=>e.map(e=>({...e,x0:e.x0-a,y0:e.y0-o,x1:e.x1-a,y1:e.y1-o})).map(e=>WY(e,u.width,u.height)).filter(e=>e!=null));let d=n.current?.getBoundingClientRect();if(d){let e=Math.min(d.width/u.width,d.height/u.height),t={k:e,tx:(d.width-u.width*e)/2,ty:(d.height-u.height*e)/2};A.current=t,O(t)}y(null),_(!1),j()}function P(){b.current=null,y(null),l(!1),u(null),f(null),m(null),g.current=null,ie(),_(e=>!e)}function F(e){e!==`text`&&ie(),D(!1),e===`marker`&&a.toLowerCase()===`#ffffff`&&o(Pwe),i(e)}function I(){g.current=null,u(null),f(null),m(null),c(e=>e.slice(0,-1))}function ee(){g.current=null,f(null),m(null),l(e=>(e?u(null):(b.current=null,y(null),_(!1)),!e))}function te(){g.current=null,f(null),p.current=null,m(null),h(e=>(ao(B.annKnobs,!e),!e))}function ne(){let e=d.current;e!=null&&(g.current=null,u(null),f(null),m(null),c(t=>t.filter((t,n)=>n!==e)))}function re(){let e=x,n=C.trim();if(S(null),w(``),T.current?.blur(),!e||!n)return;let r=t.current,i={tool:`text`,x0:e.x,y0:e.y,x1:e.x,y1:e.y,color:a,factor:s,text:n,id:E.current++};c(e=>[...e,r?WY(i,r.width,r.height):i])}function ie(){S(null),w(``),T.current?.blur()}function ae(){k.current=A.current,j(),O(A.current)}return{applyCrop:N,toggleCrop:P,pickTool:F,undoShape:I,toggleMove:ee,toggleKnobs:te,deleteSelected:ne,commitText:re,cancelText:ie,resetZoom:ae}}function oTe(e){let{canvasRef:t,wrapRef:n,tool:r,color:i,factor:a,setShapes:o,shapesRef:s,dragRef:c,moveMode:l,setSelected:u,selectedRef:d,setTarget:f,targetRef:p,setMoveNote:m,knobsRef:h,moveRef:g,cropMode:_,setPendingCrop:v,cropDrag:y,setPendingText:b,setTextDraft:x,textInputRef:S,idRef:C,setView:w,viewRef:T,fitRef:E,pointers:D,gesture:O,redraw:k,clampToImage:A}=e,j=(e,n,r,i)=>$we(t.current,e,n,r,i),M=(e,t)=>$Y(e,t,T.current.k||1);function N(){let e=t.current,n=T.current.k||1;return Math.max(6,24/n,e?e.width/90:0)}function P(e){let n=t.current,r=n.getBoundingClientRect();return{x:(e.clientX-r.left)/r.width*n.width,y:(e.clientY-r.top)/r.height*n.height}}function F(e){let t=n.current.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function I(e,t,n){let r=s.current;for(let i=r.length-1;i>=0;i--)if(j(r[i],e,t,n))return i;return null}function ee(e){if(e.preventDefault(),D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),e.currentTarget.setPointerCapture(e.pointerId),D.current.size===2){c.current=null,g.current=null;let e=[...D.current.values()],t=Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},r=F({clientX:n.x,clientY:n.y}),i=T.current;O.current={startDist:t,startK:i.k,cx:(r.x-i.tx)/i.k,cy:(r.y-i.ty)/i.k},y.current=null,k();return}if(_){let{x:t,y:n}=P(e);y.current={x0:t,y0:n,x1:t,y1:n},v(null);return}if(l){m(null);let{x:n,y:r}=P(e),i=N(),a=T.current.k||1,o=s.current,c=d.current,l=c!=null&&o[c]?c:null,_=l==null?void 0:o[l],v=_?GY(_,a)||!!_.angle:!1;if(h.current){let s=t.current,c=_?pwe(M(s,_),n,r,a):null;if(c){g.current={i:l,base:_,live:_,gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!1,knob:c};return}let f=I(n,r,i);if(f!=null){d.current=f,u(f),g.current={i:f,base:o[f],live:o[f],gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!1,knob:`move`},k();return}l!=null&&(g.current={i:l,base:_,live:_,gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!0,idle:!0});return}let y=null;if(_&&_.tool!==`text`&&!v){let e=1/0;for(let t of[0,1]){let a=t===0?_.x0:_.x1,o=t===0?_.y0:_.y1,s=Math.hypot(n-a,r-o);s<=i*1.4&&s<e&&(e=s,y=t)}}let b=I(n,r,i),x=Jwe({sel:l,small:v,handleHit:y,pickHit:b,target:p.current});if(x.kind===`handle`){g.current={i:x.i,base:_,live:_,gx:n,gy:r,handle:x.h,sx:e.clientX,sy:e.clientY,fromEmpty:!1};return}if(x.kind===`pick`){x.i!==l&&(f(null),p.current=null),d.current=x.i,u(x.i),g.current={i:x.i,base:o[x.i],live:o[x.i],gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!1},k();return}if(x.kind===`relative`){g.current={i:l,base:_,live:_,gx:n,gy:r,handle:x.h,sx:e.clientX,sy:e.clientY,fromEmpty:!0};return}return}if(r===`text`)return;let{x:n,y:o}=P(e);c.current={tool:r,x0:n,y0:o,x1:n,y1:o,color:i,factor:a,id:C.current++}}function te(e){if(D.current.has(e.pointerId)&&D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),O.current&&D.current.size>=2){let e=[...D.current.values()],t=Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},r=F({clientX:n.x,clientY:n.y}),i=O.current,a=E.current.k,o=Math.min(a*8,Math.max(a,i.startK*(t/i.startDist)));w({k:o,tx:r.x-i.cx*o,ty:r.y-i.cy*o});return}if(_&&y.current){let{x:t,y:n}=P(e);y.current={...y.current,x1:t,y1:n},k();return}if(l){let n=g.current;if(!n||n.idle)return;let{x:r,y:i}=P(e);if(n.knob){let e=t.current,a=YY(e.getContext(`2d`),e,n.base);n.live=mwe(n.knob,n.base,{x:n.gx,y:n.gy},{x:r,y:i},T.current.k||1,{x:a.x+a.w/2,y:a.y+a.h/2}),k();return}let a=r-n.gx,o=i-n.gy;n.live=n.handle===0?{...n.base,x0:n.base.x0+a,y0:n.base.y0+o}:n.handle===1?{...n.base,x1:n.base.x1+a,y1:n.base.y1+o}:{...n.base,x0:n.base.x0+a,y0:n.base.y0+o,x1:n.base.x1+a,y1:n.base.y1+o},k();return}if(!c.current)return;let{x:n,y:r}=P(e);c.current={...c.current,x1:n,y1:r},k()}function ne(e){if(D.current.delete(e.pointerId),D.current.size<2&&(O.current=null),!(D.current.size>0)){if(_){if(y.current){let e=A(qY(y.current));y.current=null,v(e.w>12&&e.h>12?e:null),k()}}else if(l){let n=g.current;if(g.current=null,n){if(n.fromEmpty&&Math.hypot(e.clientX-n.sx,e.clientY-n.sy)<8){d.current=null,p.current=null,u(null),f(null),k();return}if(n.idle){k();return}let r=t.current,{mark:i,refused:a}=r?Ywe(n.live,n.base,r.width,r.height):{mark:n.live,refused:!1};a?k():o(e=>e.map((e,t)=>t===n.i?{...e,x0:i.x0,y0:i.y0,x1:i.x1,y1:i.y1,angle:i.angle}:e)),m(a?`That would take it off the picture — left where it was.`:null)}else k()}else if(r===`text`){let{x:t,y:n}=P(e);b({x:t,y:n}),x(``),requestAnimationFrame(()=>S.current?.focus())}else if(c.current){let e=c.current;c.current=null;let n=t.current,r=n?WY(e,n.width,n.height):e;r&&(Math.abs(r.x1-r.x0)>6||Math.abs(r.y1-r.y0)>6)?o(e=>[...e,r]):k()}}}return{onDown:ee,onMove:te,onUp:ne}}function sTe(e){let{setShapes:t,readTextRef:n,editRead:r,setEditRead:i,readDraft:a,setReadDraft:o,readInputRef:s}=e;function c(e,n){t(t=>t.map(t=>t.id===e?{...t,...n}:t))}function l(e){i(e.id),o(e.read??``),requestAnimationFrame(()=>s.current?.focus())}function u(){let e=r,t=a.trim();i(null),o(``),s.current?.blur(),e!=null&&(t?n.current.set(e,t):n.current.delete(e),c(e,{read:t||void 0,readErr:t?void 0:`no words on this mark`,readBy:`hand`,reading:!1}))}function d(e){n.current.delete(e.id),c(e.id,{read:void 0,readErr:`words dropped`,readBy:`hand`,reading:!1})}return{patchShape:c,startEditRead:l,commitRead:u,dropRead:d}}var cTe=new Set([`marker`,`rect`,`circle`]),eX=1e4,lTe=2e3;function tX(e){let t=e=>Math.round(e);return[e.tool,t(e.x0),t(e.y0),t(e.x1),t(e.y1),Math.round((e.angle??0)*1e3)].join(`|`)}function uTe(e,t,n){let r=new Map(e.map(e=>[e.id,e])),i=[];for(let e of t.keys()){let t=r.get(e);(!n||!t||t.readBy===`hand`)&&i.push(e)}return n?{start:e.filter(e=>cTe.has(e.tool)&&e.readBy!==`hand`&&t.get(e.id)!==tX(e)),abort:i}:{start:[],abort:i}}function dTe(e,t,n,r){let i={x0:Math.min(e.x0,e.x1),y0:Math.min(e.y0,e.y1),x1:Math.max(e.x0,e.x1),y1:Math.max(e.y0,e.y1)};if(e.tool===`marker`&&i.y1-i.y0<r){let e=(i.y0+i.y1)/2;i={...i,y0:e-r/2,y1:e+r/2}}e.angle&&e.tool!==`marker`&&(i=UY(i,e.angle));let a=Math.max(4,Math.round(Math.min(i.x1-i.x0,i.y1-i.y0)*.08)),o=Math.max(0,Math.floor(i.x0-a)),s=Math.max(0,Math.floor(i.y0-a)),c=Math.min(t,Math.ceil(i.x1+a)),l=Math.min(n,Math.ceil(i.y1+a));return c-o<2||l-s<2?null:{x:o,y:s,w:c-o,h:l-s}}function fTe(e,t){return Math.min(4,lTe/Math.max(e,t,1))}function pTe(e){return(e??``).replace(/\s+/g,` `).trim()||null}function mTe(e){let{canvasRef:t,imgRef:n,setShapes:r,genRef:i,readsRef:a}=e,o=(e,t)=>r(n=>n.map(n=>n.id===e?t(n):n));function s(e){a.current.get(e)?.ctl?.abort(),a.current.delete(e)}function c(){for(let e of[...a.current.keys()])s(e)}function l(e,t){let{start:n,abort:r}=uTe(e,new Map([...a.current].map(([e,t])=>[e,t.key])),!!t);for(let e of r){let t=!!a.current.get(e)?.ctl;s(e),t&&o(e,e=>e.reading?{...e,reading:!1}:e)}if(t)for(let r of n)u(r,e,t)}async function u(e,t,n){s(e.id);let r=new AbortController,c={key:tX(e),ctl:r};a.current.set(e.id,c);let l=i.current;o(e.id,e=>({...e,reading:!0,readErr:void 0,...e.readBy===`phone`?{read:void 0,readBy:void 0}:{}}));let u=setTimeout(()=>r.abort(),eX),f=null,p=`no words found in this mark`;try{let i=await d(e,t);i?f=pTe(await hTe(n.read(i,{signal:r.signal}),r.signal)):p=`this mark is too small to read`}catch{p=r.signal.aborted?`not read within ${eX/1e3} s`:`this phone could not read it`}finally{clearTimeout(u)}a.current.get(e.id)===c&&i.current===l&&(c.ctl=void 0,o(e.id,e=>e.readBy===`hand`?{...e,reading:!1}:f?{...e,reading:!1,read:f,readBy:`phone`,readErr:void 0}:{...e,reading:!1,read:void 0,readBy:void 0,readErr:p}))}async function d(e,r){let i=t.current,a=n.current;if(!i||!a)return null;let o=r.find(t=>t.id===e.id),s=dTe(e,i.width,i.height,KY(i)*5*(o?.factor??1));if(!s)return null;let c=a,l=r.filter(e=>e.tool===`blur`);if(l.length){let e=document.createElement(`canvas`);e.width=i.width,e.height=i.height;let t=e.getContext(`2d`);if(!t)return null;t.drawImage(a,0,0);for(let n of l)ZY(t,e,a,n);c=e}let u=fTe(s.w,s.h),d=document.createElement(`canvas`);d.width=Math.max(1,Math.round(s.w*u)),d.height=Math.max(1,Math.round(s.h*u));let f=d.getContext(`2d`);return f?(f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`,f.drawImage(c,s.x,s.y,s.w,s.h,0,0,d.width,d.height),gH(d,`image/png`)):null}return{sync:l,abortAll:c}}function hTe(e,t){return t.aborted?Promise.reject(Error(`aborted`)):new Promise((n,r)=>{let i=()=>r(Error(`aborted`));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}function gTe(e){let{source:t,repoId:n,facts:r,onUploaded:i,onDispatch:a,onPark:o,onSendAll:s,canvasRef:c,shapes:l,shapesRef:u,busy:d,setBusy:f,setErr:p,readTextRef:m,redraw:h}=e;function g(){let e=c.current;h(!0);let n=l.length>0,r=gH(e,`image/png`).then(e=>{if(!e)throw Error(`this device could not encode the marked-up image`);return e}),i=Fwe(t).replace(/\.[^.]+$/,``).replace(/[/\\]/g,`_`)||`image`;return{blob:r,name:n?`${i}-marked.png`:`${i}.png`,note:_(e.width,e.height),size:{w:e.width,h:e.height}}}function _(e,t){return Gwe(u.current.map(e=>({...e})).map(e=>({...e,read:m.current.get(e.id)??e.read})),e,t,r)||void 0}async function v(){let e=g();return{...e,blob:await e.blob}}async function y(e=`none`){if(c.current&&!d){if(q(e===`queue`?`action:image.queue`:`action:image.send`),p(null),a)f(!0),a(g(),e);else{f(!0);try{let{blob:e,name:t,note:r,size:a}=await v(),s=async()=>{let e=await Promise.resolve(r);return e?BY(e,a??null):void 0};if(o){let n=await o(e,t);if(n){i(n,await s());return}}try{let r=await U.uploadInbox(n,e,t);r.saved?.[0]&&_j(n,r.saved[0].relPath,r.saved[0].mtime),r.saved?.[0]?i(r.saved[0].relPath,await s()):p(r.skipped?.[0]?.error||`upload failed`)}catch(n){let r=o?await o(e,t):null;r?i(r,await s()):p(String(n))}}catch(e){p(String(e))}finally{f(!1)}}}}function b(e){c.current&&s&&!d&&(q(e===`queue`?`action:image.queue`:`action:image.send`),f(!0),p(null),s(g(),e))}return{send:y,sendAll:b}}function _Te(e){let{canvasRef:t,genRef:n,redraw:r,setOcr:i,setOcrDraft:a,onText:o}=e;async function s(){let e=t.current;if(!e)return;q(`action:image.ocr`);let o=n.current;i({phase:`reading`}),r(!0);let s=await gH(e,`image/jpeg`,.92);if(o!==n.current)return;if(!s){i({phase:`error`,error:`this device could not encode the picture`});return}let c=await U.ocrImage(s);o===n.current&&(`error`in c?i({phase:`error`,error:c.error}):(a(c.text),i({phase:`ready`,engine:c.engine,ms:c.ms})))}function c(){i(null)}function l(e){let t=e.trim();t&&o&&(q(`action:image.ocr.send`),o(t))}return{readAll:s,closeOcr:c,sendText:l}}function vTe(e){let t=(0,H.useRef)(null),[n,r]=(0,H.useState)(null);return(0,H.useEffect)(()=>{let n=t.current,i=e.current;if(!n||!i||typeof ResizeObserver>`u`)return;let a=new ResizeObserver(()=>{let e=n.getBoundingClientRect();r(jwe({w:e.width,h:e.height},i.width?{w:i.width,h:i.height}:null))});return a.observe(n),a.observe(i),()=>a.disconnect()},[e]),{bodyRef:t,side:n}}function yTe({source:e,repoId:t,index:n,total:r,facts:i,onUploaded:a,onDispatch:o,onPark:s,onSkip:c,onSendAll:l,onText:u,onClose:d}){let f=(0,H.useRef)(null),p=(0,H.useRef)(null),m=(0,H.useRef)(null),[h,g]=(0,H.useState)(`circle`),[_,v]=(0,H.useState)(NY[0]),[y,b]=(0,H.useState)(1),[x,S]=(0,H.useState)([]),C=(0,H.useRef)(x);C.current=x;let w=(0,H.useRef)(null),[T,E]=(0,H.useState)(!1),[D,O]=(0,H.useState)(null),k=(0,H.useRef)(D);k.current=D;let[A,j]=(0,H.useState)(null),M=(0,H.useRef)(A);M.current=A;let[N,P]=(0,H.useState)(null),[F,I]=(0,H.useState)(()=>io(B.annKnobs)),[ee,te]=(0,H.useState)(()=>io(B.annHintHidden)),ne=()=>{ao(B.annHintHidden,!0),te(!0)},re=(0,H.useRef)(F);re.current=F;let ie=(0,H.useRef)(null),[ae,oe]=(0,H.useState)(!1),[se,ce]=(0,H.useState)(null),[le,ue]=(0,H.useState)(!1),[de,fe]=(0,H.useState)(null),pe=(0,H.useRef)(null),[me,he]=(0,H.useState)(null),[ge,_e]=(0,H.useState)(``),ve=(0,H.useRef)(null),ye=(0,H.useRef)(1),be=(0,H.useRef)(new Map),xe=(0,H.useRef)(0),[Se,Ce]=(0,H.useState)(null),[we,Te]=(0,H.useState)(``),Ee=(0,H.useRef)(null),De=Ty(),Oe=(0,H.useRef)(new Map),[ke,Ae]=(0,H.useState)(!1),[je,Me]=(0,H.useState)(null),[Ne,Pe]=(0,H.useState)(``),[Fe,Ie]=(0,H.useState)(()=>Dwe(oo(B.annTools,null))),Le=e=>{Ie(e),$a(B.annTools,e)},[Re,ze]=(0,H.useState)(!1),{bodyRef:Be,side:Ve}=vTe(f),He=Fe.place===`auto`?Ve??`auto`:Fe.place,[Ue,We]=(0,H.useState)({k:1,tx:0,ty:0}),Ge=(0,H.useRef)(Ue);Ge.current=Ue;let Ke=(0,H.useRef)({k:1,tx:0,ty:0}),qe=(0,H.useRef)(new Map),Je=(0,H.useRef)(null);(0,H.useEffect)(()=>{let t=null,n=!1;S([]),Me(null),Pe(``),xe.current++,Ce(null),O(null),j(null),P(null),ie.current=null,ce(null),oe(!1);let r=(e,t)=>{let n=f.current;n.width=e,n.height=t;let r=p.current?.getBoundingClientRect();if(r){let n=Math.min(r.width/e,r.height/t),i={k:n,tx:(r.width-e*n)/2,ty:(r.height-t*n)/2};Ke.current=i,We(i)}Ye()},i=async e=>{try{let t=await createImageBitmap(e);return n?void 0:(m.current=t,r(t.width,t.height),!0)}catch{return!1}};return(async()=>{if(e instanceof File){if(await i(e))return;let a=new Image;t=URL.createObjectURL(e),a.onload=()=>{n||(m.current=a,r(a.naturalWidth,a.naturalHeight))},a.onerror=()=>!n&&ce(`Can't decode this image format on this device.`),a.src=t}else try{let t=await fetch(e.url).then(e=>e.blob());await i(t)||ce(`Can't load this image.`)}catch{ce(`Can't load this image.`)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,H.useEffect)(()=>{document.activeElement?.blur()},[]),(0,H.useEffect)(()=>{let e=p.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=f.current,n=e.getBoundingClientRect();if(!t||!t.width||!t.height||n.width<1||n.height<1)return;let r=Math.min(n.width/t.width,n.height/t.height),i={k:r,tx:(n.width-t.width*r)/2,ty:(n.height-t.height*r)/2},a=Math.abs(Ge.current.k-Ke.current.k)<=Ke.current.k*.02;Ke.current=i,a&&(Ge.current=i,Ye(),We(i))});return t.observe(e),()=>t.disconnect()},[]),(0,H.useEffect)(Ye,[x,le,de,D,T,A,F]),(0,H.useEffect)(()=>{!x.length&&T&&(E(!1),O(null),j(null))},[x.length,T]);function Ye(e=!1){let t=f.current,n=m.current;if(!t||!n)return;let r=t.getContext(`2d`);r.drawImage(n,0,0);let i=ie.current,a=i?C.current.map((e,t)=>t===i.i?i.live:e):C.current,o=w.current?[...a,w.current]:a;for(let e of o)ZY(r,t,n,e);nTe(r,t,zY(a,t.width,t.height)),le&&eTe(r,t,pe.current?qY(pe.current):de);let s=k.current;!e&&!le&&s!=null&&a[s]&&rTe(r,t,a[s],Ge.current.k||1,re.current,M.current)}function Xe(e){return JY(f.current,e)}let Ze={source:e,repoId:t,facts:i,onUploaded:a,onDispatch:o,onPark:s,onSendAll:l,canvasRef:f,wrapRef:p,imgRef:m,tool:h,setTool:g,color:_,setColor:v,factor:y,shapes:x,setShapes:S,shapesRef:C,dragRef:w,moveMode:T,setMoveMode:E,selected:D,setSelected:O,selectedRef:k,target:A,setTarget:j,targetRef:M,setMoveNote:P,setKnobs:I,knobsRef:re,moveRef:ie,busy:ae,setBusy:oe,setErr:ce,cropMode:le,setCropMode:ue,pendingCrop:de,setPendingCrop:fe,cropDrag:pe,pendingText:me,setPendingText:he,textDraft:ge,setTextDraft:_e,textInputRef:ve,idRef:ye,readTextRef:be,genRef:xe,editRead:Se,setEditRead:Ce,readDraft:we,setReadDraft:Te,readInputRef:Ee,setPaletteOpen:Ae,setView:We,viewRef:Ge,fitRef:Ke,pointers:qe,gesture:Je,redraw:Ye,clampToImage:Xe},Qe=aTe(Ze),$e=sTe(Ze),et=oTe(Ze),{send:tt,sendAll:nt}=gTe(Ze),rt=_Te({canvasRef:f,genRef:xe,redraw:Ye,setOcr:Me,setOcrDraft:Pe,onText:u}),it=mTe({canvasRef:f,imgRef:m,setShapes:S,genRef:xe,readsRef:Oe});(0,H.useEffect)(()=>it.sync(x,De),[x,De]),(0,H.useEffect)(()=>()=>it.abortAll(),[]);let at=Ue.k>Ke.current.k*1.02,ot=[...x].reverse().find(e=>e.tool===`marker`||!!De&&(e.tool===`rect`||e.tool===`circle`));return{props:{index:n,total:r,onSkip:c,onSendAll:l,onDispatch:o,onText:u,onClose:d},canvasRef:f,wrapRef:p,tool:h,color:_,setColor:v,factor:y,setFactor:b,shapes:x,setShapes:S,moveMode:T,selected:D,setSelected:O,target:A,setTarget:j,moveNote:N,setMoveNote:P,knobs:F,busy:ae,err:se,cropMode:le,pendingCrop:de,pendingText:me,textDraft:ge,setTextDraft:_e,textInputRef:ve,editRead:Se,setEditRead:Ce,readDraft:we,setReadDraft:Te,readInputRef:Ee,paletteOpen:ke,setPaletteOpen:Ae,view:Ue,fitRef:Ke,layout:Fe,setLayout:Le,configOpen:Re,setConfigOpen:ze,bodyRef:Be,place:He,moveRef:ie,zoomed:at,lastBand:ot,hintHidden:ee,hideHint:ne,...Qe,...$e,...et,send:tt,sendAll:nt,ocr:je,ocrDraft:Ne,setOcrDraft:Pe,...rt}}function bTe(e){let t=yTe(e);Ih(t.ocr!==null,t.closeOcr);let{index:n,total:r,onClose:i}=e;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(gE,{onClose:i,title:r&&r>1?`Mark & send · ${n??1}/${r}`:`Mark & send image`,children:(0,J.jsx)(Cwe,{m:t})}),e.prompt&&(0,J.jsx)(wwe,{prompt:e.prompt}),(0,J.jsx)(Rwe,{m:t}),t.ocr?(0,J.jsx)(zwe,{m:t}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ywe,{m:t}),(0,J.jsx)(Twe,{m:t})]})]})}var nX=6,rX=0;function xTe(){if(rX)return rX;rX=4096;try{let e=document.createElement(`canvas`).getContext(`webgl`),t=e?.getParameter(e.MAX_TEXTURE_SIZE);typeof t==`number`&&t>0&&(rX=t)}catch{}return rX}function STe(e,t){let n=Math.max(e,t)*(window.devicePixelRatio||1);return n?tm(xTe()/n,2,nX):nX}function iX({src:e,alt:t,onNav:n,onError:r}){let i=(0,H.useRef)(null),a=(0,H.useRef)(null),[o,s]=(0,H.useState)({s:1,x:0,y:0}),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)(o);u.current=o;let d=(0,H.useRef)(new Map),f=(0,H.useRef)(null),p=(0,H.useRef)(null),m=(0,H.useRef)(0),[h,g]=(0,H.useState)(null);(0,H.useEffect)(()=>{s({s:1,x:0,y:0})},[e]);function _(e,t=!1){let n=a.current,r=i.current,o=Number.isFinite(e.s)?tm(e.s,1,nX):1;n&&n.offsetWidth&&(o=Math.min(o,STe(n.offsetWidth,n.offsetHeight)));let s=Number.isFinite(e.x)?e.x:0,c=Number.isFinite(e.y)?e.y:0;if(n&&r){let e=Math.max(0,(n.offsetWidth*o-r.clientWidth)/2),i=Math.max(0,(n.offsetHeight*o-r.clientHeight)/2);t||(s=tm(s,-e,e)),c=tm(c,-i,i)}return{s:o,x:s,y:c}}let v=()=>{let e=[...d.current.values()];return e.length>=2?e:null};function y(){let e=v();if(!e)return;let t=Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),n=i.current?.getBoundingClientRect(),r=n?n.left+n.width/2:0,a=n?n.top+n.height/2:0;f.current={dist:t||1,mx:(e[0].x+e[1].x)/2-r,my:(e[0].y+e[1].y)/2-a,s:u.current.s,x:u.current.x,y:u.current.y},p.current=null}function b(e){if(e.target.setPointerCapture?.(e.pointerId),d.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),l(!0),d.current.size>=2)y();else{let t=e.timeStamp;t-m.current<300?(s(e=>_(e.s>1?{s:1,x:0,y:0}:{s:2.5,x:0,y:0})),m.current=0):m.current=t,p.current={x:e.clientX,y:e.clientY,tx:u.current.x,ty:u.current.y}}}function x(e){let t=d.current.get(e.pointerId);if(!t)return;t.x=e.clientX,t.y=e.clientY;let r=v();if(r&&f.current){e.stopPropagation();let t=f.current,n=Math.hypot(r[0].x-r[1].x,r[0].y-r[1].y),a=i.current?.getBoundingClientRect(),o=(r[0].x+r[1].x)/2-(a?a.left+a.width/2:0),c=(r[0].y+r[1].y)/2-(a?a.top+a.height/2:0),l=tm(t.s*n/t.dist,1,nX);s(_({s:l,x:o-(t.mx-t.x)*(l/t.s),y:c-(t.my-t.y)*(l/t.s)}))}else if(p.current&&u.current.s>1){e.stopPropagation();let t=p.current;s(n=>_({s:n.s,x:t.tx+(e.clientX-t.x),y:t.ty+(e.clientY-t.y)}))}else if(p.current&&n){let t=p.current;s(n=>({...n,x:t.tx+(e.clientX-t.x)}))}}function S(e){if(d.current.delete(e.pointerId),d.current.size<2&&(f.current=null),d.current.size===1){let[e]=[...d.current.values()];p.current={x:e.x,y:e.y,tx:u.current.x,ty:u.current.y}}if(d.current.size===0){if(l(!1),p.current&&u.current.s<=1&&n&&e.type!==`pointercancel`){let t=e.clientX-p.current.x,r=e.clientY-p.current.y;Math.abs(t)>60&&Math.abs(t)>Math.abs(r)*1.5&&n(t<0?1:-1)}s(e=>e.s<=1?{s:1,x:0,y:0}:_(e)),p.current=null}}let C=o.s>1.01;return(0,J.jsxs)(`div`,{ref:i,className:`zoom-stage`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:S,children:[h===e?(0,J.jsxs)(`div`,{className:`img-missing`,children:[(0,J.jsx)(_s,{size:22}),(0,J.jsx)(`span`,{className:`img-missing-name`,children:t}),(0,J.jsx)(`span`,{children:`couldn’t load this image — the host may be unreachable`})]}):(0,J.jsx)(`img`,{ref:a,src:e,alt:t,draggable:!1,onLoad:()=>s(e=>_(e)),onError:()=>{g(e),r?.()},style:{transform:`translate(${o.x}px, ${o.y}px) scale(${o.s})`,willChange:c?`transform`:`auto`}}),C&&(0,J.jsxs)(`button`,{className:`zoom-reset`,"aria-label":`reset zoom`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),s({s:1,x:0,y:0})},children:[(0,J.jsx)(yc,{size:16}),` `,o.s.toFixed(1),`×`]})]})}function CTe({items:e,index:t,onIndex:n,onAnnotate:r,onReference:i,onClose:a}){let o=e[t],[s,c]=(0,H.useState)(!1);(0,H.useEffect)(()=>{c(!1)},[t]);let l=r=>{let i=t+r;i>=0&&i<e.length&&n(i)};return(0,H.useEffect)(()=>{let e=e=>{e.key===`ArrowRight`?l(1):e.key===`ArrowLeft`?l(-1):e.key===`Escape`&&(e.preventDefault(),a())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,H.useEffect)(()=>{o||a()},[o,a]),o?(0,J.jsxs)(`div`,{className:`viewer`,onClick:a,children:[(0,J.jsx)(`button`,{className:`viewer-close`,onClick:a,"aria-label":`close`,children:(0,J.jsx)(V,{size:22})}),(0,J.jsxs)(`div`,{className:`viewer-body`,onClick:e=>e.stopPropagation(),children:[o.video?(0,J.jsx)(`video`,{className:`viewer-video`,src:o.url,controls:!0,autoPlay:!0,playsInline:!0},o.relPath):(0,J.jsx)(iX,{src:s&&o.fullUrl?o.fullUrl:o.url,alt:o.name,onNav:e.length>1?l:void 0},`${o.relPath}:${s?`full`:`fit`}`),(0,J.jsx)(`div`,{className:`viewer-path mono`,children:o.relPath}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[e.length>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:()=>l(-1),disabled:t===0,"aria-label":`previous`,children:(0,J.jsx)(Hl,{size:16})}),(0,J.jsxs)(`span`,{className:`viewer-count`,children:[t+1,` / `,e.length]}),(0,J.jsx)(Y,{onClick:()=>l(1),disabled:t===e.length-1,"aria-label":`next`,children:(0,J.jsx)(jl,{size:16})})]}),!o.video&&o.fullUrl&&o.fullUrl!==o.url&&!s&&(0,J.jsx)(Y,{title:`load the original file instead of the screen-sized copy`,onClick:()=>c(!0),children:`full res`}),!o.video&&r&&(0,J.jsxs)(Y,{onClick:()=>r(o),children:[(0,J.jsx)(us,{size:16}),` mark`]}),o.repoId&&(0,J.jsx)(FO,{target:{repoId:o.repoId,relPath:o.relPath,name:o.name},trackId:`action:swipe.download`}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>i(o),children:`ref path`})]})]})]}):null}function wTe(){let e=K(gJ);return e?(0,J.jsx)(uwe,{files:e.files,onCombine:DCe,onSeparate:OCe,onClose:kCe}):null}function aX(){let e=K(mJ);return EY()&&!!e&&wJ.ret===`session`&&!!W().world.active}function TTe(){let e=K(mJ),t=aX();if(!e)return null;let n=wJ.ret===`session`,r=!!e.total&&e.total>1,i=W(),a=n&&!t&&i.world.active?{value:i.compose.draft,onChange:e=>{W().compose.typeOn(W().compose.draft,e)||W().say.toast(`The message box changed meanwhile — that key was not applied`)}}:void 0;return(0,J.jsx)(bTe,{prompt:a,source:e.source,repoId:e.repoId,index:e.index,total:e.total,facts:e.facts,onUploaded:ICe,onDispatch:n?NCe:void 0,onPark:MCe,onSkip:r?PCe:void 0,onSendAll:r&&n?FCe:void 0,onText:LCe,onClose:lY})}function ETe(){let e=K(_J),t=K(SJ);if(!e)return null;let n=e.sessionId?jJ(t.get(e.sessionId)??[]):[],r=e.items??n.map(e=>({name:e.name,relPath:e.relPath,url:OJ(e.relPath)?U.artifactUrl(e.repoId,e.relPath):sg(U.artifactUrl(e.repoId,e.relPath),og(),e.mtime),fullUrl:U.artifactUrl(e.repoId,e.relPath),video:OJ(e.relPath)}));return(0,J.jsx)(CTe,{items:r,index:Math.min(e.i,Math.max(0,r.length-1)),onIndex:e=>zJ(t=>t&&{...t,i:e}),onAnnotate:e.revoke?void 0:e=>qCe(e,n),onReference:e=>JCe(e,n),onClose:HJ})}var oX=[{label:`10m`,long:`10 minutes`,secs:600},{label:`4h`,long:`4 hours`,secs:14400},{label:`24h`,long:`24 hours`,secs:86400}];function sX(e){return e===`outbox`?14400:void 0}var DTe=[{label:`images`,value:`image`},{label:`docs`,value:`doc`}],cX=4e5,OTe={new:`new — not opened on this device yet`,opened:`opened in ${L.name} on this device`,downloaded:`downloaded to this phone`};function lX(e){if(!e)return``;let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function uX(e){return e?new Date(e).toLocaleString():``}var dX=(e,t)=>t.repoId??e,fX=(e,t,n)=>e===`inbox`?U.inboxUrl(dX(t,n),n.name):U.artifactUrl(dX(t,n),n.relPath),pX=(e,t,n)=>sg(fX(e,t,n),ag(140),n.mtime),kTe=(e,t,n,r)=>n?fX(e,t,r):sg(fX(e,t,r),og(),r.mtime),ATe=e=>nO(e.relPath)&&(e.size??0)>=49152;function jTe({openFile:e,onClose:t}){let[n,r]=(0,H.useState)(e?{...e,size:e.size??0,mtime:e.mtime??0,ctime:e.mtime??0}:null),i=(0,H.useRef)(!!e),a=e=>{i.current=!1,r(e)};return Ih(n!==null&&!i.current,()=>a(null)),{open:n,showFile:a,closeDoc:()=>{i.current?(i.current=!1,t()):a(null)}}}function MTe({repoId:e,repos:t,initialScope:n,initialAllTime:r,initialNew:i}){let a=!!e,o=n??(a?`outbox`:`all`),[s,c]=(0,H.useState)(o),l=i?Math.max(1,Math.ceil((Date.now()-i.since)/1e3)):void 0,[u,d]=(0,H.useState)(l??(r?void 0:sX(o))),[f,p]=(0,H.useState)(!!l),m=e=>{c(e),d(sX(e)),P(60),p(!1)},[h,g]=(0,H.useState)(`all`),[_,v]=(0,H.useState)(``),[y,b]=(0,H.useState)([]),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)(!0),[T,E]=(0,H.useState)(null),[D,O]=(0,H.useState)(null),[k,A]=(0,H.useState)(null),[j,M]=(0,H.useState)(0),[N,P]=(0,H.useState)(60),F=(t??[]).map(e=>e.id).join(`,`),I={kind:h,since:s===`inbox`?void 0:u},ee=lte(s,e,F);return(0,H.useEffect)(()=>{let t=!1,n=new AbortController,r=!1;w(!0),E(null),A(null);let i=(n,i,a)=>{if(!t&&(r=!0,b(n),S(i),w(!1),E(null),O(null),vj(n,e),!_.trim())){let e=a??{rows:n,cov:I,truncated:i};SC(ee,e.cov,e.rows,e.truncated)}},a=async n=>{let i=await CC(ee,I);if(t||r)return!1;if(!i)return n&&w(!1),!1;let a=Yi(i.rows,{...I,query:_},iO,Date.now());return vj(a,e),b(a.slice(0,N)),S(a.length>N||i.exact&&i.truncated),O(i.savedAt),n&&w(!1),!0};a(!1);let o=e=>{t||a(!0).then(n=>{if(t)return;w(!1);let r=Ba(e)?`the host didn't answer`:String(e?.message||e||`request failed`);A(n?r:null),E(n?null:r)})};return s===`all`?U.search({query:_,kind:h,scope:`repo`,sinceSeconds:u,repoIds:F?F.split(`,`):void 0,limit:N,signal:n.signal}).then(e=>i(e.hits,e.truncated)).catch(o):s===`inbox`?(U.markInboxSeen(e),U.inbox(e,n.signal).then(e=>{let t=Yi(e,{kind:h,query:_},iO,Date.now());i(t.slice(0,N),t.length>N,{rows:e,cov:{kind:`all`},truncated:!1})}).catch(o)):(s===`outbox`&&U.markOutboxSeen(e),U.artifacts(e,s,u,{query:_,kind:h,limit:N,signal:n.signal}).then(e=>i(e.files,e.truncated)).catch(o)),()=>{t=!0,n.abort()}},[e,F,s,u,h,_,j,N]),(0,H.useEffect)(()=>{D!=null||T||_ge(y.filter(e=>nO(e.relPath)||rO(e.relPath)).slice(0,24).map(t=>pX(s,e,t)))},[y,D,T]),(0,H.useEffect)(()=>{P(60)},[u,h,_,e]),{singleRepo:a,scope:s,changeScope:m,since:u,setSince:d,newSecs:l,onNewCut:f,setOnNewCut:p,kind:h,setKind:g,query:_,setQuery:v,files:y,truncated:x,loading:C,loadErr:T,cachedAt:D,staleWhy:k,setReload:M,setLimit:P}}function NTe({open:e,scope:t,repoId:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(0);return(0,H.useEffect)(()=>{i(!1)},[e?.relPath,e?.repoId]),(0,H.useEffect)(()=>{e&&t!==`inbox`&&(Qde(dX(n,e),e.relPath,e.mtime),m(e=>e+1))},[e?.relPath,e?.repoId,t]),(0,H.useEffect)(()=>{if(c(null),f(!1),u(null),!e||!uO(e.relPath)){o(null);return}let r=new AbortController,i=!1,a=e.relPath,s=dX(n,e),l=e.mtime,d=l>0,p=async()=>{let e=d?await FC(s,a,l):null;return r.signal.aborted||i||!e?!1:(o({path:a,text:e.text,truncated:e.truncated}),u(e.savedAt),!0)};return p(),fp(fX(t,n,e),{signal:r.signal}).then(e=>e.ok?e.text():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>{if(r.signal.aborted)return;i=!0;let t={path:a,text:e.slice(0,cX),truncated:e.length>cX};o(t),u(null),d&&PC(s,a,l,t.text,t.truncated)}).catch(e=>{r.signal.aborted||p().then(t=>{r.signal.aborted||t||(o(null),c(Ba(e)?`the host didn't answer, and this device has no saved copy`:String(e?.message||e)))})}),()=>r.abort()},[e?.relPath,e?.repoId,t]),{fullRes:r,setFullRes:i,doc:a,docErr:s,docCachedAt:l,docRaw:d,setDocRaw:f,markTick:p,setMarkTick:m}}function PTe(e,t,n){let r=n(t);return e.some(e=>n(e)===r)?e.filter(e=>n(e)!==r):[...e,t]}function FTe(e){return e===0?`Tap the pictures to combine, in the order you want them numbered.`:e===1?`1 picked — tap one more: a combined picture needs at least two.`:`${e} picked, numbered in the order you tapped them.`}function ITe(e){let[t,n]=(0,H.useState)(null),r=t=>`${e.repoOf(t)}:${t.relPath}`;return{picked:t,pickIndex:e=>t?t.findIndex(t=>r(t)===r(e)):-1,canPick:!!e.onCombine&&e.singleRepo&&e.files.filter(e=>nO(e.relPath)).length>=2,startPick:()=>{q(`action:gallery.pick`),n([])},cancelPick:()=>n(null),togglePicked:e=>{nO(e.relPath)&&n(t=>PTe(t??[],e,r))},combinePicked:()=>{if(!t||t.length<2||!e.onCombine)return;q(`action:gallery.combine`);let r=t.map(t=>({url:e.urlFor(t),name:t.name,repoId:e.repoOf(t)}));n(null),e.onCombine(r)}}}function LTe(e){let{repoId:t,openFile:n,onClose:r}=e,{open:i,showFile:a,closeDoc:o}=jTe({openFile:n,onClose:r}),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),d=e=>{u(e),window.setTimeout(()=>u(t=>t===e?null:t),4e3)},[f,p]=(0,H.useState)(new Set),m=e=>p(t=>t.has(e)?t:new Set(t).add(e)),[h,g]=(0,H.useState)([]);(0,H.useEffect)(()=>gS.subscribe(g),[]);let _=MTe(e),{scope:v,files:y,loading:b,setReload:x}=_,S=NTe({open:i,scope:v,repoId:t}),{fullRes:C,docRaw:w,markTick:T}=S,E=e=>e&&b?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsx)(Ul,{size:12,className:`spin`})]}):null,D=e=>dX(t,e),O=e=>fX(v,t,e),k=e=>pX(v,t,e),A=e=>kTe(v,t,C,e),j=e=>v===`inbox`||e.relPath.startsWith(`.claude/inbox/`),M=e=>{if(v===`inbox`)return null;let t=OO(D(e),e.relPath,e.mtime);return t===`new`&&v!==`outbox`?null:t},N=e=>{let t=D(e);return h.find(n=>n.item.repoId===t&&n.item.relPath===e.relPath&&Math.round(n.item.mtime)===Math.round(e.mtime))},P=e=>({repoId:D(e),relPath:e.relPath,name:e.name,size:e.size,mtime:e.mtime,repoName:e.repoName}),F=e=>{let t=ix(e);return t.phase===`have`||t.phase===`saved`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(go,{size:11}),` on phone`]}):t.phase===`downloading`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ul,{size:11,className:`spin`}),` `,t.pct,`%`]}):t.phase===`failed`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Js,{size:11}),` stopped`]}):t.phase===`idle`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rs,{size:11}),` was here`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Rs,{size:11}),` queued`]})},I=i?N(i):void 0,ee=I?.state===`done`?I.item.id:null,[te,ne]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(ne(null),!ee)return;let e=null,t=!1;return gS.objectUrl(ee).then(n=>{n&&(t?URL.revokeObjectURL(n):(e=n,ne(n)))}),()=>{t=!0,e&&URL.revokeObjectURL(e)}},[ee]);let re=e=>te??A(e),ie=e=>te??O(e),ae=!!i&&sO(i.relPath)&&!w,oe=y.filter(e=>nO(e.relPath)),se=i?oe.findIndex(e=>e.relPath===i.relPath&&e.repoId===i.repoId):-1;function ce(e){let t=se>=0?oe[se+e]:void 0;t&&a(t)}(0,H.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`ArrowRight`?ce(1):e.key===`ArrowLeft`?ce(-1):e.key===`Escape`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});async function le(e){try{return await U.deleteInbox(D(e),e.name),x(e=>e+1),!0}catch(t){return d(Ba(t)?`Could not delete ${e.name} — the host didn't answer. The file is still on the desktop.`:`Could not delete ${e.name} — ${String(t?.message||t)}`),!1}}async function ue(e){q(`action:gallery.delete`),await le(e)&&a(null)}let de=ITe({onCombine:e.onCombine,singleRepo:_.singleRepo,files:y,repoOf:D,urlFor:O});async function fe(e){let t=await gp(e);c(t?e:null),setTimeout(()=>c(null),1500)}return{props:e,..._,...S,open:i,showFile:a,closeDoc:o,copied:s,note:l,badSrc:f,markBad:m,busyMark:E,repoOf:D,urlFor:O,thumbFor:k,canFullRes:ATe,isInboxFile:j,markOf:M,pullOf:N,dlTarget:P,pullBadge:F,localUrl:te,mediaSrc:re,fileSrc:ie,htmlLive:ae,imgs:oe,openIdx:se,nav:ce,removeInbox:le,del:ue,copy:fe,...de}}function RTe(e,t,n,r){let i=`${e} new since you last looked`;return n||t===e?i:r?`${i} · newest ${t} shown`:`${i} · ${t} still here`}function zTe(e){let t=oX.find(t=>t.secs===e);return t?`Nothing from the last ${t.long}.`:null}function BTe({m:e}){let{scope:t,loading:n,singleRepo:r,changeScope:i,kind:a,setKind:o,since:s,setSince:c,newSecs:l,onNewCut:u,setOnNewCut:d}=e,{initialNew:f}=e.props,p=(e,r)=>(0,J.jsxs)(`button`,{className:`seg${t===e?` on`:``}${t===e&&n?` busy`:``}`,"aria-pressed":t===e,onClick:()=>i(e),children:[r,t===e&&n?(0,J.jsx)(Ul,{size:13,className:`spin`}):null]}),m=(e,t,r,i)=>(0,J.jsx)(pE,{on:e,busy:e&&n,title:i,onClick:r,children:t}),h=()=>{c(void 0),d(!1)};return(0,J.jsxs)(J.Fragment,{children:[r&&(0,J.jsxs)(`div`,{className:`segmented gallery-scope`,children:[p(`inbox`,`inbox`),p(`outbox`,`outbox`),p(`repo`,`this repo`),p(`all`,`all repos`)]}),(0,J.jsxs)(`div`,{className:`fchips gallery-filters`,children:[DTe.map(e=>(0,J.jsx)(H.Fragment,{children:m(a===e.value,e.label,()=>o(a===e.value?`all`:e.value))},e.value)),t!==`inbox`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`fchips-gap`,"aria-hidden":!0}),l!==void 0&&m(u,`${f.count} new`,()=>{u?h():(c(l),d(!0))},`the ${f.count} file${f.count>1?`s`:``} added since you last opened this outbox — the badge you tapped`),oX.map(e=>(0,J.jsx)(H.Fragment,{children:m(!u&&s===e.secs,e.label,()=>{!u&&s===e.secs?h():(c(e.secs),d(!1))},`only files from the last ${e.long}`)},e.label))]})]})]})}function VTe({m:e}){let{scope:t,loading:n,files:r,truncated:i,query:a,setQuery:o,singleRepo:s,setSince:c,onNewCut:l,setOnNewCut:u,loadErr:d,setReload:f,cachedAt:p,staleWhy:m,note:h,open:g}=e,{onClose:_,onSweep:v,onSurvey:y,initialNew:b}=e.props,x=r.length;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(gE,{title:`Images & documents`,onClose:_,children:[(x>0||n)&&(0,J.jsx)(`span`,{className:`gallery-meta`,title:no()?void 0:`build cc85ddc9`,children:n&&!x?(0,J.jsx)(Ul,{size:12,className:`spin`}):`${x}${i?`+`:``} file${x===1&&!i?``:`s`}`}),v&&s&&(t===`inbox`||t===`outbox`)&&(0,J.jsx)(Y,{className:`gallery-head-btn`,title:`clear out old ${t} files`,"aria-label":`clear out old ${t} files`,onClick:()=>v(t),children:(0,J.jsx)(ic,{size:17})}),y&&t===`all`&&(0,J.jsx)(Y,{className:`gallery-head-btn`,title:`what is taking space, repo by repo`,"aria-label":`what is taking space`,onClick:y,children:(0,J.jsx)(Es,{size:17})})]}),(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(`div`,{className:`search-row`,children:[(0,J.jsx)(Lc,{size:16}),(0,J.jsx)(`input`,{className:`search`,placeholder:t===`all`?`Search every repo by name`:`Search by name`,value:a,onChange:e=>o(e.target.value)}),a&&(0,J.jsx)(Y,{"aria-label":`clear the search`,onClick:()=>o(``),children:(0,J.jsx)(V,{size:14})})]})}),(0,J.jsx)(BTe,{m:e}),l&&(0,J.jsx)(cE,{onClear:()=>{c(void 0),u(!1)},clearLabel:`show all`,children:RTe(b.count,x,n,i)}),d&&(0,J.jsxs)(`div`,{className:`gallery-note err`,children:[(0,J.jsx)(Js,{size:14}),(0,J.jsxs)(`span`,{children:[`Could not load the list (`,d,`)`,x?` — showing what was already loaded`:``,`.`]}),(0,J.jsxs)(Y,{onClick:()=>f(e=>e+1),children:[(0,J.jsx)($c,{size:14}),` retry`]})]}),p!=null&&(0,J.jsxs)(`div`,{className:`gallery-note`,children:[(0,J.jsx)(Hs,{size:14}),(0,J.jsx)(`span`,{children:m?`Showing the list this phone last saw, ${lX(p)} — ${m}.`:`Showing the list this phone last saw, ${lX(p)} — refreshing…`}),m&&(0,J.jsxs)(Y,{onClick:()=>f(e=>e+1),children:[(0,J.jsx)($c,{size:14}),` retry`]})]}),h&&!g&&(0,J.jsx)(`div`,{className:`gallery-note`,children:h})]})}var HTe=[[/^(md|markdown|txt|log|rst|pdf)$/,Nl],[/^(html?|json|ya?ml|toml|xml|js|mjs|ts|tsx|css|sh|py|diff|patch)$/,ire],[/^(csv|tsv|xlsx?|ods)$/,cre],[/^(zip|tar|gz|tgz|7z|rar)$/,Dne],[/^(apk|aab|ipa)$/,ql],[/^(mp3|m4a|wav|ogg|opus|flac|aac)$/,Hne]];function UTe({name:e}){let t=e.lastIndexOf(`.`),n=t>0?e.slice(t+1).toLowerCase():``,r=HTe.find(([e])=>e.test(n))?.[1]??Mc;return(0,J.jsxs)(`span`,{className:`doc`,"aria-hidden":!0,children:[(0,J.jsx)(r,{size:30,strokeWidth:1.5}),n&&(0,J.jsx)(`span`,{className:`doc-ext`,children:n})]})}function WTe({url:e,name:t,missing:n,onMissing:r}){let{src:i,live:a}=jj(e);return n?(0,J.jsxs)(`span`,{className:`img-missing`,children:[(0,J.jsx)(_s,{size:18}),(0,J.jsx)(`span`,{className:`img-missing-name`,children:t})]}):i?(0,J.jsx)(`img`,{src:i,alt:t,loading:`lazy`,decoding:`async`,onLoad:()=>{a&&Oj(e)},onError:r}):(0,J.jsx)(`span`,{className:`thumb-blank`})}function GTe({src:e,poster:t,name:n}){let{src:r,live:i}=jj(t);return(0,H.useEffect)(()=>{i&&Oj(t)},[i,t]),(0,J.jsx)(`video`,{src:e,poster:r??void 0,title:n,muted:!0,playsInline:!0,preload:`none`})}function KTe({m:e}){let{picked:t,canPick:n,startPick:r,cancelPick:i,combinePicked:a}=e;return t?(0,J.jsxs)(`div`,{className:`annot-tools gallery-pick on`,children:[(0,J.jsx)(`span`,{className:`viewer-doc-note`,children:FTe(t.length)}),(0,J.jsxs)(Y,{onClick:i,children:[(0,J.jsx)(V,{size:14}),` cancel`]}),t.length>=2&&(0,J.jsxs)(`button`,{className:`send`,onClick:a,children:[(0,J.jsx)(Wc,{size:14}),` combine `,t.length]})]}):n?(0,J.jsx)(`div`,{className:`annot-tools gallery-pick`,children:(0,J.jsxs)(Y,{"aria-label":`pick pictures to combine`,onClick:r,children:[(0,J.jsx)(Wc,{size:14}),` combine pictures…`]})}):null}function qTe({m:e}){let{files:t,loading:n,loadErr:r,query:i,kind:a,scope:o,truncated:s,showFile:c,badSrc:l,markBad:u,urlFor:d,thumbFor:f,markOf:p,pullOf:m,pullBadge:h,isInboxFile:g,removeInbox:_,setLimit:v,onNewCut:y,since:b,setSince:x,setOnNewCut:S}=e,C=e=>y&&p(e)===`new`?null:p(e),w=o!==`inbox`&&!y?zTe(b):null,{picked:T,pickIndex:E,togglePicked:D}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(KTe,{m:e}),(0,J.jsxs)(`div`,{className:`grid${n&&t.length?` stale`:``}`,children:[t.map(e=>(0,J.jsxs)(`div`,{className:`thumb-wrap${E(e)>=0?` picked`:``}`,children:[T&&E(e)>=0&&(0,J.jsx)(`span`,{className:`thumb-pick`,"aria-hidden":`true`,children:E(e)+1}),(0,J.jsxs)(`button`,{className:`thumb`,"aria-pressed":T&&nO(e.relPath)?E(e)>=0:void 0,onClick:()=>T?D(e):c(e),children:[nO(e.relPath)?(0,J.jsx)(WTe,{url:f(e),name:e.name,missing:l.has(f(e)),onMissing:()=>u(f(e))}):rO(e.relPath)?(0,J.jsx)(GTe,{src:d(e),poster:f(e),name:e.name}):(0,J.jsx)(UTe,{name:e.name}),(0,J.jsx)(`span`,{className:`thumb-name`,children:e.name}),(0,J.jsxs)(`span`,{className:`thumb-date`,title:uX(e.ctime??e.mtime),children:[lX(e.ctime??e.mtime),e.size?(0,J.jsxs)(`span`,{className:`thumb-size`,children:[` · `,zp(e.size)]}):null]}),e.repoName&&(0,J.jsx)(`span`,{className:`thumb-repo`,children:e.repoName}),(0,J.jsxs)(`span`,{className:`thumb-badges`,children:[C(e)&&!m(e)&&(0,J.jsx)(`span`,{className:`thumb-mark ${C(e)}`,title:OTe[C(e)],children:C(e)===`new`?(0,J.jsx)(`span`,{className:`sr-only`,children:`new`}):C(e)===`downloaded`?(0,J.jsx)(rs,{size:11}):(0,J.jsx)(as,{size:11})}),m(e)&&(0,J.jsx)(`span`,{className:`thumb-pull ${m(e).state}`,title:ix(m(e)).detail,children:h(m(e))})]})]}),g(e)&&(0,J.jsx)(uT,{className:`thumb-del`,title:`delete ${e.name}`,confirmTitle:`tap again to delete ${e.name}`,confirm:(0,J.jsx)(Js,{size:14}),onConfirm:()=>{_(e)},children:(0,J.jsx)(ic,{size:14})})]},`${e.repoId??``}:${e.relPath}`)),t.length===0&&n&&Array.from({length:8},(e,t)=>(0,J.jsx)(`div`,{className:`thumb-wrap`,children:(0,J.jsx)(`div`,{className:`thumb skel-thumb`})},`skel-${t}`)),t.length===0&&!n&&!r&&(0,J.jsx)($,{children:i||a!==`all`?`No matches.`:w?(0,J.jsxs)(J.Fragment,{children:[w,` `,(0,J.jsx)(`button`,{className:`link-btn`,onClick:()=>{x(void 0),S(!1)},children:`show older files`})]}):o===`outbox`?`The outbox is empty. Claude puts screenshots and files meant for your phone in .claude/outbox. To see images anywhere in the repo, switch to this repo.`:`Nothing here yet.`})]}),s&&(0,J.jsxs)(`div`,{className:`annot-tools`,children:[(0,J.jsxs)(Y,{onClick:()=>{q(`action:gallery.more`),v(e=>e+60)},children:[`load `,60,` more`]}),(0,J.jsxs)(`span`,{className:`viewer-doc-note`,children:[`showing the newest `,t.length]})]})]})}function mX(e){let{onContinueInSession:t,sessionsIn:n}=e.props;return t&&n?n(e.repoId):[]}function hX(e,t){q(t?`action:gallery.toSession`:`action:gallery.toNewSession`),e.setPicking(!1),e.props.onContinueInSession?.(e.relPath,e.repoId,t)}function JTe(e){if(!e.props.onContinueInSession)return null;let t=mX(e);return(0,J.jsxs)(J.Fragment,{children:[t.length===1&&(0,J.jsxs)(Y,{title:`put this file's path in that session's prompt`,onClick:()=>hX(e,t[0].id),children:[(0,J.jsx)(Go,{size:16}),` `,t[0].label]}),t.length>1&&(0,J.jsxs)(Y,{title:`pick which live session gets this file's path`,onClick:()=>e.setPicking(!e.picking),children:[(0,J.jsx)(Go,{size:16}),` session · `,t.length]}),(0,J.jsxs)(Y,{title:`start a new session in this repo with this file's path in its prompt`,onClick:()=>hX(e,null),children:[(0,J.jsx)(os,{size:16}),` new session`]})]})}function YTe(e){let t=mX(e);return!e.picking||t.length<2?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`viewer-doc-note`,children:[t.length,` live sessions in `,e.repoName||`this repo`,` — the path goes into the prompt of the one you pick`]}),(0,J.jsx)(`div`,{className:`list`,children:t.map(t=>(0,J.jsxs)(xE,{as:`button`,onClick:()=>hX(e,t.id),children:[(0,J.jsxs)(SE,{children:[(0,J.jsx)(xo,{size:14}),` `,t.label]}),t.onScreen&&(0,J.jsx)(Q,{children:`on screen behind the gallery`})]},t.id))})]})}function XTe({m:e}){let{open:t,closeDoc:n,repoOf:r,localUrl:i,fullRes:a,mediaSrc:o,fileSrc:s,imgs:c,nav:l,setDocRaw:u,docRaw:d,doc:f,docErr:p,docCachedAt:m,htmlLive:h,pullOf:g,dlTarget:_,files:v,showFile:y,openIdx:b,copied:x,copy:S,canFullRes:C,setFullRes:w,urlFor:T,setMarkTick:E,isInboxFile:D,del:O,note:k}=e,{onAnnotate:A,onInsertPath:j,onClose:M}=e.props,[N,P]=(0,H.useState)(null);if(!t)return null;let F={relPath:t.relPath,repoId:r(t),repoName:t.repoName,props:e.props,picking:N===t.relPath,setPicking:e=>P(e?t.relPath:null)};return(0,J.jsxs)(`div`,{className:`viewer`,onClick:()=>n(),children:[(0,J.jsx)(`button`,{className:`viewer-close`,onClick:()=>n(),"aria-label":`close`,children:(0,J.jsx)(V,{size:22})}),(0,J.jsxs)(`div`,{className:`viewer-body`,onClick:e=>e.stopPropagation(),children:[nO(t.relPath)?(0,J.jsx)(iX,{src:o(t),alt:t.name,onNav:c.length>1?l:void 0},`${r(t)}:${t.relPath}:${i?`local`:a?`full`:`fit`}`):rO(t.relPath)?(0,J.jsx)(`video`,{className:`viewer-video`,src:s(t),controls:!0,autoPlay:!0,playsInline:!0},`${r(t)}:${t.relPath}:${i?`local`:`net`}`):uO(t.relPath)?(0,J.jsxs)(`div`,{className:`viewer-doc`,children:[cO(t.relPath)&&(0,J.jsxs)(`div`,{className:`viewer-doc-bar`,children:[(0,J.jsx)(Y,{onClick:()=>u(e=>!e),children:d?`rendered`:`source`}),f?.truncated&&!h&&(0,J.jsxs)(`span`,{className:`viewer-doc-note`,children:[`showing the first `,400,` KB — download for the rest`]}),m!=null&&!h&&(0,J.jsxs)(`span`,{className:`viewer-doc-note`,children:[(0,J.jsx)(Hs,{size:12}),` saved copy from `,lX(m)]})]}),h?(0,J.jsx)(`iframe`,{className:`viewer-html`,src:s(t),title:t.name,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`},`${r(t)}:${t.relPath}:${i?`local`:`net`}`):p?(0,J.jsxs)($,{children:[`Could not load this file (`,p,`). `,(0,J.jsx)(FO,{rec:g(t),target:_(t)})]}):!f||f.path!==t.relPath?(0,J.jsx)($,{children:`Loading…`}):lO(t.relPath)&&!d?(0,J.jsx)(`div`,{className:`viewer-doc-body`,children:(0,J.jsx)(Rj,{src:f.text,q:``,onCopy:e=>gp(e),files:{repoId:r(t),url:(e,n,i)=>{let a=U.artifactUrl(r(t),e);return n?sg(a,n,i):a},open:e=>{let n=v.find(t=>t.relPath===e);n?y(n):NO({repoId:r(t),relPath:e})},known:v.filter(e=>r(e)===r(t)).map(e=>e.relPath),docPath:t.relPath}})}):(0,J.jsxs)(`pre`,{className:`viewer-doc-pre`,children:[f.text,f.truncated?`
|
|
205
|
+
`)[0];return(0,J.jsxs)(`div`,{className:`ann-prompt`,children:[(0,J.jsxs)(`button`,{className:`ann-prompt-fold`,onClick:r,"aria-expanded":t,title:t?`fold the message box away`:`show the session's message box — typed here, sent with the picture on Send & run`,children:[t?(0,J.jsx)(ac,{size:14}):(0,J.jsx)(jl,{size:14}),(0,J.jsx)(Qne,{size:14}),(0,J.jsx)(`span`,{className:`ann-prompt-gist`,children:t?`message for the session`:i||`message for the session — empty`})]}),t&&(0,J.jsx)(uD,{inline:!0,rows:2,prompts:[e.value],onChange:t=>e.onChange(t[0]??``),placeholder:`Message for the session — Send & run sends it with the picture`})]})}function Twe({m:e}){let{busy:t,send:n,sendAll:r,readAll:i}=e,{index:a,total:o,onSkip:s,onSendAll:c,onDispatch:l,onText:u}=e.props;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(yH,{compact:!0}),(0,J.jsxs)(`div`,{className:`sheet-actions annot-send-bar`,"data-primary-key":``,children:[s&&(0,J.jsx)(Y,{onClick:s,disabled:t,children:`skip`}),c&&o&&o>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:()=>r(`none`),disabled:t,title:`send this + every remaining image as-is`,children:`Send all`}),(0,J.jsx)(Y,{onClick:()=>r(`run`),disabled:t,title:`send all, then submit once uploads finish`,children:`Send all + submit`}),(0,J.jsxs)(Y,{onClick:()=>r(`queue`),disabled:t,title:`send all, then hand the prompt to the desktop — it goes in when this session is free`,children:[(0,J.jsx)(Kl,{size:14}),` Send all, then when it's free`]})]}),l&&(!o||o<=1)&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:()=>n(`run`),disabled:t,title:`attach the image and run the prompt (uploads in the background)`,children:`Send & run`}),(0,J.jsxs)(Y,{onClick:()=>n(`queue`),disabled:t,title:`attach the image and hand the prompt to the desktop — it goes in when this session is free`,children:[(0,J.jsx)(Kl,{size:14}),` Send & when it's free`]})]}),u&&(0,J.jsxs)(Y,{onClick:()=>void i(),disabled:t,title:`read every word on the desktop and send only the text, not the photo`,children:[(0,J.jsx)(fc,{size:14}),` text only`]}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>n(`none`),disabled:t,children:t?`Sending…`:o&&o>1&&(a??1)<o?`Send & next`:`Send to repo`})]})]})}var OY=[{id:`undo`,label:`undo`},{id:`circle`,label:`circle`},{id:`rect`,label:`rectangle`},{id:`arrow`,label:`arrow`},{id:`line`,label:`line`},{id:`text`,label:`text label`},{id:`marker`,label:`highlight text`},{id:`blur`,label:`blur / redact`},{id:`crop`,label:`crop`},{id:`move`,label:`move a mark`},{id:`style`,label:`colour & stroke`},{id:`clear`,label:`clear all marks`}],kY=OY.map(e=>e.id),Ewe=[`auto`,`left`,`top`],AY={order:kY.slice(),hidden:[],place:`auto`},jY=e=>typeof e==`string`&&kY.includes(e);function Dwe(e){if(!e||typeof e!=`object`)return{...AY,order:kY.slice()};let t=e,n=new Set,r=[];for(let e of Array.isArray(t.order)?t.order:[])jY(e)&&!n.has(e)&&(n.add(e),r.push(e));return kY.forEach((e,t)=>{if(n.has(e))return;let i=0;for(let e=t-1;e>=0;e--){let t=r.indexOf(kY[e]);if(t>=0){i=t+1;break}}r.splice(i,0,e),n.add(e)}),{order:r,hidden:(Array.isArray(t.hidden)?t.hidden:[]).filter(jY).filter((e,t,n)=>n.indexOf(e)===t),place:Ewe.includes(t.place)?t.place:`auto`}}function Owe(e){return e.order.filter(t=>!e.hidden.includes(t))}function kwe(e,t){let n=e.hidden.includes(t)?e.hidden.filter(e=>e!==t):[...e.hidden,t];return{...e,hidden:n}}function MY(e,t,n){let r=e.order.indexOf(t),i=r+n;if(r<0||i<0||i>=e.order.length)return e;let a=e.order.slice();return[a[r],a[i]]=[a[i],a[r]],{...e,order:a}}function Awe(e){return e.place===`auto`&&!e.hidden.length&&e.order.every((e,t)=>e===kY[t])}function jwe(e,t){if(!e||!t||e.w<1||e.h<1||t.w<1||t.h<1)return null;let n=(e,n)=>Math.min(Math.max(e,0)/t.w,Math.max(n,0)/t.h),r=n(e.w-57,e.h);return n(e.w,e.h-61)>r?`top`:`left`}var Mwe=[{v:`auto`,label:`auto`},{v:`left`,label:`left`},{v:`top`,label:`top`}];function Nwe({m:e}){let{layout:t,setLayout:n,setConfigOpen:r}=e,i=e=>OY.find(t=>t.id===e)?.label??e,a=t.order.length-1;return(0,J.jsxs)(`div`,{className:`annot-config`,role:`dialog`,"aria-label":`customize the toolbar`,children:[(0,J.jsxs)(`div`,{className:`annot-config-head`,children:[(0,J.jsx)(`span`,{children:`Toolbar`}),(0,J.jsxs)(Y,{onClick:()=>r(!1),"aria-label":`close the toolbar settings`,children:[(0,J.jsx)(V,{size:16}),` done`]})]}),(0,J.jsxs)(`div`,{className:`annot-config-row`,children:[(0,J.jsx)(`span`,{className:`annot-config-label`,children:`position`}),Mwe.map(e=>(0,J.jsx)(Y,{className:t.place===e.v?`active`:``,"aria-pressed":t.place===e.v,onClick:()=>n({...t,place:e.v}),children:e.label},e.v))]}),(0,J.jsx)(`div`,{className:`annot-config-hint`,children:t.place===`auto`?`auto: whichever side leaves this picture larger — a row on top for a wide one, a rail on the left for a tall one`:`always on the ${t.place}`}),(0,J.jsx)(`div`,{className:`annot-config-list`,children:t.order.map((e,r)=>{let o=!t.hidden.includes(e);return(0,J.jsxs)(`div`,{className:`annot-config-row ${o?``:`off`}`,children:[(0,J.jsx)(Y,{className:`annot-config-toggle${o?` active`:``}`,"aria-pressed":o,onClick:()=>n(kwe(t,e)),children:o?`shown`:`hidden`}),(0,J.jsx)(`span`,{className:`annot-config-label`,children:i(e)}),r>0?(0,J.jsx)(Y,{onClick:()=>n(MY(t,e,-1)),"aria-label":`move ${i(e)} up`,children:(0,J.jsx)(Ys,{size:16})}):(0,J.jsx)(`span`,{className:`annot-config-gap`}),r<a?(0,J.jsx)(Y,{onClick:()=>n(MY(t,e,1)),"aria-label":`move ${i(e)} down`,children:(0,J.jsx)(ac,{size:16})}):(0,J.jsx)(`span`,{className:`annot-config-gap`})]},e)})}),!Awe(t)&&(0,J.jsx)(`div`,{className:`annot-config-row`,children:(0,J.jsx)(Y,{onClick:()=>n({...AY,order:AY.order.slice()}),children:`reset to default`})})]})}var NY=[`#ff2d2d`,`#ffd400`,`#3fb950`,`#4c9aff`,`#ffffff`],Pwe=`#ffd400`,PY=[{label:`S`,factor:.6},{label:`M`,factor:1},{label:`L`,factor:1.8}];function Fwe(e){return e instanceof File,e.name}var Iwe={circle:{tool:`circle`,icon:(0,J.jsx)(vc,{size:16}),label:`circle`},rect:{tool:`rect`,icon:(0,J.jsx)(Rc,{size:16}),label:`rectangle`},arrow:{tool:`arrow`,icon:(0,J.jsx)(qne,{size:16}),label:`arrow`},line:{tool:`line`,icon:(0,J.jsx)(hs,{size:16}),label:`line`},text:{tool:`text`,icon:(0,J.jsx)(Dc,{size:16}),label:`text`},marker:{tool:`marker`,icon:(0,J.jsx)(bne,{size:16}),label:`highlight text`},blur:{tool:`blur`,icon:(0,J.jsx)(Gc,{size:16}),label:`blur or redact`}};function Lwe({m:e}){let{tool:t,color:n,setColor:r,factor:i,setFactor:a,shapes:o,setShapes:s,moveMode:c,selected:l,setSelected:u,setTarget:d,setMoveNote:f,knobs:p,cropMode:m,paletteOpen:h,setPaletteOpen:g,moveRef:_,toggleCrop:v,pickTool:y,undoShape:b,toggleMove:x,toggleKnobs:S,deleteSelected:C,layout:w}=e,T=PY.find(e=>e.factor===i)?.label??`M`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`annot-tools annot-bar`,children:Owe(w).map(e=>{let r=Iwe[e];if(r)return(0,J.jsx)(Y,{className:t===r.tool?`active`:``,onClick:()=>y(r.tool),title:r.label,"aria-label":r.label,"aria-pressed":t===r.tool,children:r.icon},e);switch(e){case`undo`:return(0,J.jsx)(Y,{onClick:b,disabled:!o.length,title:`undo`,"aria-label":`undo the last mark`,children:(0,J.jsx)(Ac,{size:16})},e);case`crop`:return(0,J.jsx)(Y,{className:m?`active`:``,onClick:v,title:`crop`,"aria-label":`crop`,"aria-pressed":m,children:(0,J.jsx)(Fne,{size:16})},e);case`move`:return[(0,J.jsx)(Y,{className:c?`active`:``,onClick:x,disabled:!o.length,title:`move/reshape a mark`,"aria-label":`move a mark`,"aria-pressed":c,children:(0,J.jsx)(Pne,{size:16})},e),c&&(0,J.jsx)(Y,{onClick:C,disabled:l==null,title:`delete the selected mark`,"aria-label":`delete the selected mark`,children:(0,J.jsx)(ic,{size:16})},`del`),c&&(0,J.jsx)(Y,{className:p?`active`:``,onClick:S,"aria-pressed":p,title:`knobs: move, size and turn a mark (or drag an arrow's ends) by knobs on strings, instead of dragging from anywhere`,"aria-label":`knobs on the selected mark`,children:`knobs`},`knobs`)];case`style`:return(0,J.jsx)(`button`,{className:`swatch dot annot-style ${h?`on`:``}`,style:{background:n},onClick:()=>g(e=>!e),title:`mark colour and stroke`,"aria-label":`mark colour ${n}, stroke ${T} — tap to change`,"aria-expanded":h,children:T},e);case`clear`:return(0,J.jsx)(Y,{onClick:()=>{_.current=null,u(null),d(null),f(null),s([])},disabled:!o.length,title:`clear all marks`,"aria-label":`clear all marks`,children:(0,J.jsx)(Vc,{size:16})},e)}return null})}),h&&(0,J.jsxs)(`div`,{className:`annot-tools annot-palette`,children:[NY.map(e=>(0,J.jsx)(`button`,{className:`swatch ${n===e?`on`:``}`,style:{background:e},onClick:()=>{r(e),g(!1)},title:`colour ${e}`,"aria-label":`colour ${e}`,"aria-pressed":n===e},e)),PY.map(e=>(0,J.jsx)(Y,{className:i===e.factor?`active`:``,onClick:()=>{a(e.factor),g(!1)},title:`stroke ${e.label}`,"aria-label":`stroke ${e.label}`,"aria-pressed":i===e.factor,children:e.label},e.label))]})]})}function Rwe({m:e}){let{canvasRef:t,wrapRef:n,bodyRef:r,view:i,onDown:a,onMove:o,onUp:s,place:c,configOpen:l}=e;return(0,J.jsxs)(`div`,{className:`annot-body place-${c}`,ref:r,children:[(0,J.jsx)(Lwe,{m:e}),(0,J.jsx)(`div`,{className:`annot-canvas-wrap`,ref:n,onPointerDown:a,onPointerMove:o,onPointerUp:s,onPointerCancel:s,children:(0,J.jsx)(`canvas`,{ref:t,className:`annot-canvas`,style:{transform:`translate(${i.tx}px, ${i.ty}px) scale(${i.k})`,transformOrigin:`0 0`}})}),l&&(0,J.jsx)(Nwe,{m:e})]})}function zwe({m:e}){let{ocr:t,ocrDraft:n,setOcrDraft:r,readAll:i,closeOcr:a,sendText:o}=e;if(!t)return null;let s=!n.trim();return(0,J.jsxs)(`div`,{className:`annot-ocr`,children:[t.phase===`reading`&&(0,J.jsx)(`div`,{className:`annot-hint`,children:`Reading every word on your desktop… The photo goes no further than that machine.`}),t.phase===`error`&&(0,J.jsx)(`div`,{className:`annot-hint`,children:t.error}),t.phase===`ready`&&(0,J.jsxs)(`div`,{className:`annot-hint`,children:[`Read on your desktop (`,t.engine,`, `,(t.ms/1e3).toFixed(1),` s). Fix anything misread — only this text is sent, never the photo.`]}),(t.phase===`ready`||!s)&&(0,J.jsx)(`textarea`,{className:`annot-ocr-text`,value:n,onChange:e=>r(e.target.value),spellCheck:!1,autoCapitalize:`off`,"aria-label":`text read off the picture`}),t.phase===`ready`&&s&&(0,J.jsx)(`div`,{className:`annot-hint`,children:`Nothing left to send — read again, or go back to the picture.`}),(0,J.jsxs)(`div`,{className:`sheet-actions annot-send-bar`,"data-primary-key":``,children:[(0,J.jsxs)(Y,{onClick:a,children:[(0,J.jsx)(pl,{size:14}),` picture`]}),t.phase!==`reading`&&(0,J.jsxs)(Y,{onClick:()=>void i(),children:[(0,J.jsx)($c,{size:14}),` read again`]}),t.phase!==`reading`&&!s&&(0,J.jsxs)(`button`,{className:`send`,onClick:()=>o(n),children:[(0,J.jsx)(fc,{size:14}),` Send text only`]})]})]})}var Bwe={"#ff2d2d":`red`,"#ffd400":`yellow`,"#3fb950":`green`,"#4c9aff":`blue`,"#ffffff":`white`};function Vwe(e,t,n,r){let i=t/r,a=e/n,o=i<.34?`top`:i>.66?`bottom`:`middle`,s=a<.34?`left`:a>.66?`right`:`center`;return o===`middle`&&s===`center`?`center`:o===`middle`?s:s===`center`?o:`${o}-${s}`}function FY(e){return`${Math.round(Math.max(0,Math.min(1,e))*100)}%`}function IY(e,t,n,r){return`${Vwe(e,t,n,r)} (x ${FY(e/n)}, y ${FY(t/r)})`}function LY(e,t,n){let r=Math.min(e.x0,e.x1),i=Math.max(e.x0,e.x1),a=Math.min(e.y0,e.y1),o=Math.max(e.y0,e.y1);return`(x ${FY(r/t)}-${FY(i/t)}, y ${FY(a/n)}-${FY(o/n)})`}function RY(e){return`"${e.replace(/\s+/g,` `).trim().replace(/"/g,`''`)}"`}var Hwe=e=>Bwe[e.toLowerCase()]||e;function Uwe(e,t,n){return[e.tool,e.color.toLowerCase(),FY(Math.min(e.x0,e.x1)/t),FY(Math.min(e.y0,e.y1)/n),FY(Math.max(e.x0,e.x1)/t),FY(Math.max(e.y0,e.y1)/n),(e.text??``).trim(),(e.read??``).trim()].join(`|`)}function zY(e,t,n){if(t<=0||n<=0)return[];let r=new Set,i=[];for(let a of e){let e=Uwe(a,t,n);r.has(e)||(r.add(e),i.push(a))}return i}function Wwe(e,t,n){switch(e.tool){case`blur`:return`blurred/redacted region ${LY(e,t,n)}`;case`text`:return`text ${RY(e.text||``)} at ${IY(e.x0,e.y0,t,n)}`;case`marker`:return e.read?`highlight over ${RY(e.read)} ${LY(e,t,n)}`:`highlight ${LY(e,t,n)}`;case`arrow`:return`arrow pointing to ${IY(e.x1,e.y1,t,n)}`;case`line`:return`line from ${IY(e.x0,e.y0,t,n)} to ${IY(e.x1,e.y1,t,n)}`;case`rect`:return e.read?`box around ${RY(e.read)} ${LY(e,t,n)}`:`box ${LY(e,t,n)}`;default:return e.read?`circle around ${RY(e.read)} ${LY(e,t,n)}`:`circle ${LY(e,t,n)}`}}function Gwe(e,t,n,r){let i=zY(e,t,n),a=[];r&&a.push(r);let o=i.length>1,s=new Set(i.map(e=>e.color.toLowerCase())).size<=1;return i.forEach((e,r)=>{let i=o?`#${r+1} `:``,c=s||e.tool===`blur`?``:`${Hwe(e.color)} `;a.push(`${i}${c}${Wwe(e,t,n)}`)}),a.join(`; `)}function BY(e,t){return!e||!t||!(t.w>0)||!(t.h>0)?e:`${e}; image ${Math.round(t.w)}x${Math.round(t.h)}`}var Kwe=new Set([`rect`,`blur`,`marker`]),VY=(e,t)=>tm(e,0,t);function HY(e,t,n){return Math.max(e.x0,e.x1)>0&&Math.min(e.x0,e.x1)<t&&Math.max(e.y0,e.y1)>0&&Math.min(e.y0,e.y1)<n}function UY(e,t){let n=(e.x0+e.x1)/2,r=(e.y0+e.y1)/2,i=Math.abs(e.x1-e.x0)/2,a=Math.abs(e.y1-e.y0)/2,o=Math.abs(i*Math.cos(t))+Math.abs(a*Math.sin(t)),s=Math.abs(i*Math.sin(t))+Math.abs(a*Math.cos(t));return{x0:n-o,y0:r-s,x1:n+o,y1:r+s}}function qwe(e,t,n){let r=e.x1-e.x0,i=e.y1-e.y0,a=0,o=1,s=[[-r,e.x0-0],[r,t-e.x0],[-i,e.y0-0],[i,n-e.y0]];for(let[e,t]of s){if(e===0){if(t<0)return null;continue}let n=t/e;if(e<0){if(n>o)return null;n>a&&(a=n)}else{if(n<a)return null;n<o&&(o=n)}}return{x0:e.x0+a*r,y0:e.y0+a*i,x1:e.x0+o*r,y1:e.y0+o*i}}function WY(e,t,n){if(!(t>0&&n>0))return e;if(e.tool===`text`){let r=VY(e.x0,t),i=VY(e.y0,n);return{...e,x0:r,y0:i,x1:r,y1:i}}if(e.tool===`line`||e.tool===`arrow`){let r=qwe(e,t,n);return r?{...e,...r}:null}return e.angle?HY(UY(e,e.angle),t,n)?e:null:HY(e,t,n)?Kwe.has(e.tool)?{...e,x0:VY(e.x0,t),y0:VY(e.y0,n),x1:VY(e.x1,t),y1:VY(e.y1,n)}:e:null}function GY(e,t){return e.tool!==`text`&&Math.hypot(e.x1-e.x0,e.y1-e.y0)*t<48}function Jwe(e){let{sel:t,small:n,handleHit:r,pickHit:i,target:a}=e;return t!=null&&!n&&r!=null?{kind:`handle`,i:t,h:r}:i==null?t==null?{kind:`none`}:{kind:`relative`,i:t,h:a}:{kind:`pick`,i}}function Ywe(e,t,n,r){let i=WY(e,n,r);return i?{mark:i,refused:!1}:{mark:t,refused:!0}}function KY(e){return Math.max(4,Math.round(e.width/220))}function qY(e){return{x:Math.min(e.x0,e.x1),y:Math.min(e.y0,e.y1),w:Math.abs(e.x1-e.x0),h:Math.abs(e.y1-e.y0)}}function JY(e,t){if(!e)return t;let n=t=>Math.max(0,Math.min(t,e.width)),r=t=>Math.max(0,Math.min(t,e.height)),i=n(t.x),a=r(t.y);return{x:i,y:a,w:n(t.x+t.w)-i,h:r(t.y+t.h)-a}}function Xwe(e){let t=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!t)return`#fff`;let n=parseInt(t[1],16);return(.299*(n>>16&255)+.587*(n>>8&255)+.114*(n&255))/255>.6?`#111`:`#fff`}function Zwe(e){if(e.tool===`text`||e.tool===`arrow`||e.tool===`line`)return{x:e.x0,y:e.y0};let t=qY(e);if(!e.angle)return{x:t.x,y:t.y};let n=t.x+t.w/2,r=t.y+t.h/2,i=Math.cos(e.angle),a=Math.sin(e.angle);return{x:n+-t.w/2*i- -t.h/2*a,y:r+-t.w/2*a+-t.h/2*i}}function YY(e,t,n){if(n.tool===`text`){let r=Math.max(16,Math.round(t.width/26))*n.factor;e.save(),e.font=`bold ${r}px ui-sans-serif, system-ui, sans-serif`;let i=e.measureText(n.text||``).width;return e.restore(),{x:n.x0,y:n.y0,w:i,h:r*1.2}}return qY(n)}function Qwe(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0;return Math.hypot(e-(n+l*o),t-(r+l*s))}function $we(e,t,n,r,i){if(!e)return!1;if(t.tool===`arrow`||t.tool===`line`)return Qwe(n,r,t.x0,t.y0,t.x1,t.y1)<=i;let a=YY(e.getContext(`2d`),e,t);if(t.angle){let e=a.x+a.w/2,i=a.y+a.h/2,o=Math.cos(-t.angle),s=Math.sin(-t.angle),c=e+(n-e)*o-(r-i)*s,l=i+(n-e)*s+(r-i)*o;n=c,r=l}return n>=a.x-i&&n<=a.x+a.w+i&&r>=a.y-i&&r<=a.y+a.h+i}function eTe(e,t,n){if(!n)return;let r=KY(t);e.save(),e.fillStyle=`rgba(0,0,0,.55)`,e.beginPath(),e.rect(0,0,t.width,t.height),e.rect(n.x,n.y,n.w,n.h),e.fill(`evenodd`),e.strokeStyle=`#fff`,e.lineWidth=r,e.setLineDash([r*2.5,r*2.5]),e.strokeRect(n.x,n.y,n.w,n.h),e.restore()}function XY(e,t,n,r){if(!n)return;if(r.angle){let i=qY(r),a=i.x+i.w/2,o=i.y+i.h/2;e.save(),e.beginPath(),e.translate(a,o),e.rotate(r.angle),e.rect(-i.w/2,-i.h/2,i.w,i.h),e.setTransform(1,0,0,1,0,0),e.clip(),XY(e,t,n,{...r,angle:0,...UY(r,r.angle)}),e.restore();return}let{x:i,y:a,w:o,h:s}=JY(t,qY(r));if(o<1||s<1)return;let c=Math.max(8,Math.round(t.width/48)),l=Math.max(1,Math.round(o/c)),u=Math.max(1,Math.round(s/c)),d=document.createElement(`canvas`);d.width=l,d.height=u,d.getContext(`2d`).drawImage(n,i,a,o,s,0,0,l,u),e.save(),e.imageSmoothingEnabled=!1,e.drawImage(d,0,0,l,u,i,a,o,s),e.restore()}function tTe(e,t,n){let r=qY(n),i=KY(t)*5*n.factor,a=Math.max(r.h,i),o=r.h>=i?r.y:r.y-(i-r.h)/2;e.save(),e.globalAlpha=.38,e.globalCompositeOperation=`multiply`,e.fillStyle=n.color,e.fillRect(r.x,o,Math.max(r.w,i),a),e.restore()}function nTe(e,t,n){if(n.length<2)return;let r=Math.max(10,KY(t)*3.2);n.forEach((n,i)=>{let a=Zwe(n),o=Math.max(r+2,Math.min(t.width-r-2,a.x-r*.2)),s=Math.max(r+2,Math.min(t.height-r-2,a.y-r*.2));e.save(),e.beginPath(),e.arc(o,s,r,0,Math.PI*2),e.fillStyle=n.tool===`blur`?`#111`:n.color,e.fill(),e.lineWidth=Math.max(1,r*.14),e.strokeStyle=`rgba(0,0,0,.55)`,e.stroke(),e.fillStyle=n.tool===`blur`?`#fff`:Xwe(n.color),e.font=`bold ${Math.round(r*1.25)}px ui-sans-serif, system-ui, sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(String(i+1),o,s),e.restore()}),e.textAlign=`start`}function ZY(e,t,n,r){if(!r.angle||r.tool===`blur`||r.tool===`arrow`||r.tool===`line`){QY(e,t,n,r);return}let i=YY(e,t,r),a=i.x+i.w/2,o=i.y+i.h/2;e.save(),e.translate(a,o),e.rotate(r.angle),e.translate(-a,-o),QY(e,t,n,r),e.restore()}function QY(e,t,n,r){if(r.tool===`blur`){XY(e,t,n,r);return}if(r.tool===`marker`){tTe(e,t,r);return}let i=KY(t)*r.factor;if(e.strokeStyle=r.color,e.fillStyle=r.color,e.lineWidth=i,e.lineCap=`round`,e.lineJoin=`round`,r.tool===`rect`)e.strokeRect(r.x0,r.y0,r.x1-r.x0,r.y1-r.y0);else if(r.tool===`circle`)e.beginPath(),e.ellipse((r.x0+r.x1)/2,(r.y0+r.y1)/2,Math.abs(r.x1-r.x0)/2,Math.abs(r.y1-r.y0)/2,0,0,Math.PI*2),e.stroke();else if(r.tool===`arrow`||r.tool===`line`){let t=Math.atan2(r.y1-r.y0,r.x1-r.x0),n=i*4;if(e.beginPath(),e.moveTo(r.x0,r.y0),e.lineTo(r.x1,r.y1),e.stroke(),r.tool===`line`)return;e.beginPath(),e.moveTo(r.x1,r.y1),e.lineTo(r.x1-n*Math.cos(t-Math.PI/6),r.y1-n*Math.sin(t-Math.PI/6)),e.lineTo(r.x1-n*Math.cos(t+Math.PI/6),r.y1-n*Math.sin(t+Math.PI/6)),e.closePath(),e.fill()}else if(r.tool===`text`&&r.text){let n=Math.max(16,Math.round(t.width/26))*r.factor;e.font=`bold ${n}px ui-sans-serif, system-ui, sans-serif`,e.textBaseline=`top`,e.lineWidth=Math.max(2,n/8),e.strokeStyle=`rgba(0,0,0,.65)`,e.strokeText(r.text,r.x0,r.y0),e.fillText(r.text,r.x0,r.y0)}}function rTe(e,t,n,r,i,a){let o=YY(e,t,n),s=Math.max(1,KY(t)*.6),c=GY(n,r),l=c?Math.max(s*3,48/r/2):s*3;if(e.save(),n.angle&&n.tool!==`arrow`&&n.tool!==`line`){let t=o.x+o.w/2,r=o.y+o.h/2;e.translate(t,r),e.rotate(n.angle),e.translate(-t,-r)}if(e.strokeStyle=`#4c9aff`,e.lineWidth=s,e.setLineDash([s*3,s*3]),e.strokeRect(o.x-l,o.y-l,o.w+l*2,o.h+l*2),e.setLineDash([]),i)e.restore(),iTe(e,t,n,r);else if(n.angle)e.restore();else{if(n.tool!==`text`&&!c){let r=KY(t)*1.8;[[0,n.x0,n.y0],[1,n.x1,n.y1]].forEach(([t,n,i])=>{e.beginPath(),e.arc(n,i,r,0,Math.PI*2),e.fillStyle=a===t?`#4c9aff`:`#fff`,e.fill(),e.stroke()})}e.restore()}}function $Y(e,t,n){return fwe(t,YY(e.getContext(`2d`),e,t),n,e.width,e.height)}function iTe(e,t,n,r){let i=18/r,a=$Y(t,n,r);e.save(),e.lineCap=`round`;for(let t of a)e.beginPath(),e.moveTo(t.ax,t.ay),e.lineTo(t.x,t.y),e.strokeStyle=`rgba(255,255,255,0.85)`,e.lineWidth=4/r,e.stroke(),e.strokeStyle=`#4c9aff`,e.lineWidth=2/r,e.stroke();for(let t of a)e.beginPath(),e.arc(t.x,t.y,i,0,Math.PI*2),e.fillStyle=gwe[t.knob],e.fill(),e.lineWidth=2/r,e.strokeStyle=`#fff`,e.stroke(),vwe(e,t.knob,t.x,t.y,i*.5,2/r);e.restore()}function aTe(e){let{canvasRef:t,wrapRef:n,imgRef:r,setTool:i,color:a,setColor:o,factor:s,setShapes:c,setMoveMode:l,setSelected:u,selectedRef:d,setTarget:f,targetRef:p,setMoveNote:m,setKnobs:h,moveRef:g,setCropMode:_,pendingCrop:v,setPendingCrop:y,cropDrag:b,pendingText:x,setPendingText:S,textDraft:C,setTextDraft:w,textInputRef:T,idRef:E,setPaletteOpen:D,setView:O,viewRef:k,fitRef:A,redraw:j,clampToImage:M}=e;async function N(){let e=r.current,i=t.current;if(!e||!i||!v)return;let{x:a,y:o,w:s,h:l}=M(v);if(s<1||l<1){y(null);return}let u=document.createElement(`canvas`);u.width=Math.round(s),u.height=Math.round(l),u.getContext(`2d`).drawImage(e,a,o,s,l,0,0,u.width,u.height);try{r.current=await createImageBitmap(u)}catch{r.current=u}i.width=u.width,i.height=u.height,c(e=>e.map(e=>({...e,x0:e.x0-a,y0:e.y0-o,x1:e.x1-a,y1:e.y1-o})).map(e=>WY(e,u.width,u.height)).filter(e=>e!=null));let d=n.current?.getBoundingClientRect();if(d){let e=Math.min(d.width/u.width,d.height/u.height),t={k:e,tx:(d.width-u.width*e)/2,ty:(d.height-u.height*e)/2};A.current=t,O(t)}y(null),_(!1),j()}function P(){b.current=null,y(null),l(!1),u(null),f(null),m(null),g.current=null,ie(),_(e=>!e)}function F(e){e!==`text`&&ie(),D(!1),e===`marker`&&a.toLowerCase()===`#ffffff`&&o(Pwe),i(e)}function I(){g.current=null,u(null),f(null),m(null),c(e=>e.slice(0,-1))}function ee(){g.current=null,f(null),m(null),l(e=>(e?u(null):(b.current=null,y(null),_(!1)),!e))}function te(){g.current=null,f(null),p.current=null,m(null),h(e=>(ao(B.annKnobs,!e),!e))}function ne(){let e=d.current;e!=null&&(g.current=null,u(null),f(null),m(null),c(t=>t.filter((t,n)=>n!==e)))}function re(){let e=x,n=C.trim();if(S(null),w(``),T.current?.blur(),!e||!n)return;let r=t.current,i={tool:`text`,x0:e.x,y0:e.y,x1:e.x,y1:e.y,color:a,factor:s,text:n,id:E.current++};c(e=>[...e,r?WY(i,r.width,r.height):i])}function ie(){S(null),w(``),T.current?.blur()}function ae(){k.current=A.current,j(),O(A.current)}return{applyCrop:N,toggleCrop:P,pickTool:F,undoShape:I,toggleMove:ee,toggleKnobs:te,deleteSelected:ne,commitText:re,cancelText:ie,resetZoom:ae}}function oTe(e){let{canvasRef:t,wrapRef:n,tool:r,color:i,factor:a,setShapes:o,shapesRef:s,dragRef:c,moveMode:l,setSelected:u,selectedRef:d,setTarget:f,targetRef:p,setMoveNote:m,knobsRef:h,moveRef:g,cropMode:_,setPendingCrop:v,cropDrag:y,setPendingText:b,setTextDraft:x,textInputRef:S,idRef:C,setView:w,viewRef:T,fitRef:E,pointers:D,gesture:O,redraw:k,clampToImage:A}=e,j=(e,n,r,i)=>$we(t.current,e,n,r,i),M=(e,t)=>$Y(e,t,T.current.k||1);function N(){let e=t.current,n=T.current.k||1;return Math.max(6,24/n,e?e.width/90:0)}function P(e){let n=t.current,r=n.getBoundingClientRect();return{x:(e.clientX-r.left)/r.width*n.width,y:(e.clientY-r.top)/r.height*n.height}}function F(e){let t=n.current.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function I(e,t,n){let r=s.current;for(let i=r.length-1;i>=0;i--)if(j(r[i],e,t,n))return i;return null}function ee(e){if(e.preventDefault(),D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),e.currentTarget.setPointerCapture(e.pointerId),D.current.size===2){c.current=null,g.current=null;let e=[...D.current.values()],t=Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},r=F({clientX:n.x,clientY:n.y}),i=T.current;O.current={startDist:t,startK:i.k,cx:(r.x-i.tx)/i.k,cy:(r.y-i.ty)/i.k},y.current=null,k();return}if(_){let{x:t,y:n}=P(e);y.current={x0:t,y0:n,x1:t,y1:n},v(null);return}if(l){m(null);let{x:n,y:r}=P(e),i=N(),a=T.current.k||1,o=s.current,c=d.current,l=c!=null&&o[c]?c:null,_=l==null?void 0:o[l],v=_?GY(_,a)||!!_.angle:!1;if(h.current){let s=t.current,c=_?pwe(M(s,_),n,r,a):null;if(c){g.current={i:l,base:_,live:_,gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!1,knob:c};return}let f=I(n,r,i);if(f!=null){d.current=f,u(f),g.current={i:f,base:o[f],live:o[f],gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!1,knob:`move`},k();return}l!=null&&(g.current={i:l,base:_,live:_,gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!0,idle:!0});return}let y=null;if(_&&_.tool!==`text`&&!v){let e=1/0;for(let t of[0,1]){let a=t===0?_.x0:_.x1,o=t===0?_.y0:_.y1,s=Math.hypot(n-a,r-o);s<=i*1.4&&s<e&&(e=s,y=t)}}let b=I(n,r,i),x=Jwe({sel:l,small:v,handleHit:y,pickHit:b,target:p.current});if(x.kind===`handle`){g.current={i:x.i,base:_,live:_,gx:n,gy:r,handle:x.h,sx:e.clientX,sy:e.clientY,fromEmpty:!1};return}if(x.kind===`pick`){x.i!==l&&(f(null),p.current=null),d.current=x.i,u(x.i),g.current={i:x.i,base:o[x.i],live:o[x.i],gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!1},k();return}if(x.kind===`relative`){g.current={i:l,base:_,live:_,gx:n,gy:r,handle:x.h,sx:e.clientX,sy:e.clientY,fromEmpty:!0};return}return}if(r===`text`)return;let{x:n,y:o}=P(e);c.current={tool:r,x0:n,y0:o,x1:n,y1:o,color:i,factor:a,id:C.current++}}function te(e){if(D.current.has(e.pointerId)&&D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),O.current&&D.current.size>=2){let e=[...D.current.values()],t=Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},r=F({clientX:n.x,clientY:n.y}),i=O.current,a=E.current.k,o=Math.min(a*8,Math.max(a,i.startK*(t/i.startDist)));w({k:o,tx:r.x-i.cx*o,ty:r.y-i.cy*o});return}if(_&&y.current){let{x:t,y:n}=P(e);y.current={...y.current,x1:t,y1:n},k();return}if(l){let n=g.current;if(!n||n.idle)return;let{x:r,y:i}=P(e);if(n.knob){let e=t.current,a=YY(e.getContext(`2d`),e,n.base);n.live=mwe(n.knob,n.base,{x:n.gx,y:n.gy},{x:r,y:i},T.current.k||1,{x:a.x+a.w/2,y:a.y+a.h/2}),k();return}let a=r-n.gx,o=i-n.gy;n.live=n.handle===0?{...n.base,x0:n.base.x0+a,y0:n.base.y0+o}:n.handle===1?{...n.base,x1:n.base.x1+a,y1:n.base.y1+o}:{...n.base,x0:n.base.x0+a,y0:n.base.y0+o,x1:n.base.x1+a,y1:n.base.y1+o},k();return}if(!c.current)return;let{x:n,y:r}=P(e);c.current={...c.current,x1:n,y1:r},k()}function ne(e){if(D.current.delete(e.pointerId),D.current.size<2&&(O.current=null),!(D.current.size>0)){if(_){if(y.current){let e=A(qY(y.current));y.current=null,v(e.w>12&&e.h>12?e:null),k()}}else if(l){let n=g.current;if(g.current=null,n){if(n.fromEmpty&&Math.hypot(e.clientX-n.sx,e.clientY-n.sy)<8){d.current=null,p.current=null,u(null),f(null),k();return}if(n.idle){k();return}let r=t.current,{mark:i,refused:a}=r?Ywe(n.live,n.base,r.width,r.height):{mark:n.live,refused:!1};a?k():o(e=>e.map((e,t)=>t===n.i?{...e,x0:i.x0,y0:i.y0,x1:i.x1,y1:i.y1,angle:i.angle}:e)),m(a?`That would take it off the picture — left where it was.`:null)}else k()}else if(r===`text`){let{x:t,y:n}=P(e);b({x:t,y:n}),x(``),requestAnimationFrame(()=>S.current?.focus())}else if(c.current){let e=c.current;c.current=null;let n=t.current,r=n?WY(e,n.width,n.height):e;r&&(Math.abs(r.x1-r.x0)>6||Math.abs(r.y1-r.y0)>6)?o(e=>[...e,r]):k()}}}return{onDown:ee,onMove:te,onUp:ne}}function sTe(e){let{setShapes:t,readTextRef:n,editRead:r,setEditRead:i,readDraft:a,setReadDraft:o,readInputRef:s}=e;function c(e,n){t(t=>t.map(t=>t.id===e?{...t,...n}:t))}function l(e){i(e.id),o(e.read??``),requestAnimationFrame(()=>s.current?.focus())}function u(){let e=r,t=a.trim();i(null),o(``),s.current?.blur(),e!=null&&(t?n.current.set(e,t):n.current.delete(e),c(e,{read:t||void 0,readErr:t?void 0:`no words on this mark`,readBy:`hand`,reading:!1}))}function d(e){n.current.delete(e.id),c(e.id,{read:void 0,readErr:`words dropped`,readBy:`hand`,reading:!1})}return{patchShape:c,startEditRead:l,commitRead:u,dropRead:d}}var cTe=new Set([`marker`,`rect`,`circle`]),eX=1e4,lTe=2e3;function tX(e){let t=e=>Math.round(e);return[e.tool,t(e.x0),t(e.y0),t(e.x1),t(e.y1),Math.round((e.angle??0)*1e3)].join(`|`)}function uTe(e,t,n){let r=new Map(e.map(e=>[e.id,e])),i=[];for(let e of t.keys()){let t=r.get(e);(!n||!t||t.readBy===`hand`)&&i.push(e)}return n?{start:e.filter(e=>cTe.has(e.tool)&&e.readBy!==`hand`&&t.get(e.id)!==tX(e)),abort:i}:{start:[],abort:i}}function dTe(e,t,n,r){let i={x0:Math.min(e.x0,e.x1),y0:Math.min(e.y0,e.y1),x1:Math.max(e.x0,e.x1),y1:Math.max(e.y0,e.y1)};if(e.tool===`marker`&&i.y1-i.y0<r){let e=(i.y0+i.y1)/2;i={...i,y0:e-r/2,y1:e+r/2}}e.angle&&e.tool!==`marker`&&(i=UY(i,e.angle));let a=Math.max(4,Math.round(Math.min(i.x1-i.x0,i.y1-i.y0)*.08)),o=Math.max(0,Math.floor(i.x0-a)),s=Math.max(0,Math.floor(i.y0-a)),c=Math.min(t,Math.ceil(i.x1+a)),l=Math.min(n,Math.ceil(i.y1+a));return c-o<2||l-s<2?null:{x:o,y:s,w:c-o,h:l-s}}function fTe(e,t){return Math.min(4,lTe/Math.max(e,t,1))}function pTe(e){return(e??``).replace(/\s+/g,` `).trim()||null}function mTe(e){let{canvasRef:t,imgRef:n,setShapes:r,genRef:i,readsRef:a}=e,o=(e,t)=>r(n=>n.map(n=>n.id===e?t(n):n));function s(e){a.current.get(e)?.ctl?.abort(),a.current.delete(e)}function c(){for(let e of[...a.current.keys()])s(e)}function l(e,t){let{start:n,abort:r}=uTe(e,new Map([...a.current].map(([e,t])=>[e,t.key])),!!t);for(let e of r){let t=!!a.current.get(e)?.ctl;s(e),t&&o(e,e=>e.reading?{...e,reading:!1}:e)}if(t)for(let r of n)u(r,e,t)}async function u(e,t,n){s(e.id);let r=new AbortController,c={key:tX(e),ctl:r};a.current.set(e.id,c);let l=i.current;o(e.id,e=>({...e,reading:!0,readErr:void 0,...e.readBy===`phone`?{read:void 0,readBy:void 0}:{}}));let u=setTimeout(()=>r.abort(),eX),f=null,p=`no words found in this mark`;try{let i=await d(e,t);i?f=pTe(await hTe(n.read(i,{signal:r.signal}),r.signal)):p=`this mark is too small to read`}catch{p=r.signal.aborted?`not read within ${eX/1e3} s`:`this phone could not read it`}finally{clearTimeout(u)}a.current.get(e.id)===c&&i.current===l&&(c.ctl=void 0,o(e.id,e=>e.readBy===`hand`?{...e,reading:!1}:f?{...e,reading:!1,read:f,readBy:`phone`,readErr:void 0}:{...e,reading:!1,read:void 0,readBy:void 0,readErr:p}))}async function d(e,r){let i=t.current,a=n.current;if(!i||!a)return null;let o=r.find(t=>t.id===e.id),s=dTe(e,i.width,i.height,KY(i)*5*(o?.factor??1));if(!s)return null;let c=a,l=r.filter(e=>e.tool===`blur`);if(l.length){let e=document.createElement(`canvas`);e.width=i.width,e.height=i.height;let t=e.getContext(`2d`);if(!t)return null;t.drawImage(a,0,0);for(let n of l)ZY(t,e,a,n);c=e}let u=fTe(s.w,s.h),d=document.createElement(`canvas`);d.width=Math.max(1,Math.round(s.w*u)),d.height=Math.max(1,Math.round(s.h*u));let f=d.getContext(`2d`);return f?(f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`,f.drawImage(c,s.x,s.y,s.w,s.h,0,0,d.width,d.height),gH(d,`image/png`)):null}return{sync:l,abortAll:c}}function hTe(e,t){return t.aborted?Promise.reject(Error(`aborted`)):new Promise((n,r)=>{let i=()=>r(Error(`aborted`));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}function gTe(e){let{source:t,repoId:n,facts:r,onUploaded:i,onDispatch:a,onPark:o,onSendAll:s,canvasRef:c,shapes:l,shapesRef:u,busy:d,setBusy:f,setErr:p,readTextRef:m,redraw:h}=e;function g(){let e=c.current;h(!0);let n=l.length>0,r=gH(e,`image/png`).then(e=>{if(!e)throw Error(`this device could not encode the marked-up image`);return e}),i=Fwe(t).replace(/\.[^.]+$/,``).replace(/[/\\]/g,`_`)||`image`;return{blob:r,name:n?`${i}-marked.png`:`${i}.png`,note:_(e.width,e.height),size:{w:e.width,h:e.height}}}function _(e,t){return Gwe(u.current.map(e=>({...e})).map(e=>({...e,read:m.current.get(e.id)??e.read})),e,t,r)||void 0}async function v(){let e=g();return{...e,blob:await e.blob}}async function y(e=`none`){if(c.current&&!d){if(q(e===`queue`?`action:image.queue`:`action:image.send`),p(null),a)f(!0),a(g(),e);else{f(!0);try{let{blob:e,name:t,note:r,size:a}=await v(),s=async()=>{let e=await Promise.resolve(r);return e?BY(e,a??null):void 0};if(o){let n=await o(e,t);if(n){i(n,await s());return}}try{let r=await U.uploadInbox(n,e,t);r.saved?.[0]&&_j(n,r.saved[0].relPath,r.saved[0].mtime),r.saved?.[0]?i(r.saved[0].relPath,await s()):p(r.skipped?.[0]?.error||`upload failed`)}catch(n){let r=o?await o(e,t):null;r?i(r,await s()):p(String(n))}}catch(e){p(String(e))}finally{f(!1)}}}}function b(e){c.current&&s&&!d&&(q(e===`queue`?`action:image.queue`:`action:image.send`),f(!0),p(null),s(g(),e))}return{send:y,sendAll:b}}function _Te(e){let{canvasRef:t,genRef:n,redraw:r,setOcr:i,setOcrDraft:a,onText:o}=e;async function s(){let e=t.current;if(!e)return;q(`action:image.ocr`);let o=n.current;i({phase:`reading`}),r(!0);let s=await gH(e,`image/jpeg`,.92);if(o!==n.current)return;if(!s){i({phase:`error`,error:`this device could not encode the picture`});return}let c=await U.ocrImage(s);o===n.current&&(`error`in c?i({phase:`error`,error:c.error}):(a(c.text),i({phase:`ready`,engine:c.engine,ms:c.ms})))}function c(){i(null)}function l(e){let t=e.trim();t&&o&&(q(`action:image.ocr.send`),o(t))}return{readAll:s,closeOcr:c,sendText:l}}function vTe(e){let t=(0,H.useRef)(null),[n,r]=(0,H.useState)(null);return(0,H.useEffect)(()=>{let n=t.current,i=e.current;if(!n||!i||typeof ResizeObserver>`u`)return;let a=new ResizeObserver(()=>{let e=n.getBoundingClientRect();r(jwe({w:e.width,h:e.height},i.width?{w:i.width,h:i.height}:null))});return a.observe(n),a.observe(i),()=>a.disconnect()},[e]),{bodyRef:t,side:n}}function yTe({source:e,repoId:t,index:n,total:r,facts:i,onUploaded:a,onDispatch:o,onPark:s,onSkip:c,onSendAll:l,onText:u,onClose:d}){let f=(0,H.useRef)(null),p=(0,H.useRef)(null),m=(0,H.useRef)(null),[h,g]=(0,H.useState)(`circle`),[_,v]=(0,H.useState)(NY[0]),[y,b]=(0,H.useState)(1),[x,S]=(0,H.useState)([]),C=(0,H.useRef)(x);C.current=x;let w=(0,H.useRef)(null),[T,E]=(0,H.useState)(!1),[D,O]=(0,H.useState)(null),k=(0,H.useRef)(D);k.current=D;let[A,j]=(0,H.useState)(null),M=(0,H.useRef)(A);M.current=A;let[N,P]=(0,H.useState)(null),[F,I]=(0,H.useState)(()=>io(B.annKnobs)),[ee,te]=(0,H.useState)(()=>io(B.annHintHidden)),ne=()=>{ao(B.annHintHidden,!0),te(!0)},re=(0,H.useRef)(F);re.current=F;let ie=(0,H.useRef)(null),[ae,oe]=(0,H.useState)(!1),[se,ce]=(0,H.useState)(null),[le,ue]=(0,H.useState)(!1),[de,fe]=(0,H.useState)(null),pe=(0,H.useRef)(null),[me,he]=(0,H.useState)(null),[ge,_e]=(0,H.useState)(``),ve=(0,H.useRef)(null),ye=(0,H.useRef)(1),be=(0,H.useRef)(new Map),xe=(0,H.useRef)(0),[Se,Ce]=(0,H.useState)(null),[we,Te]=(0,H.useState)(``),Ee=(0,H.useRef)(null),De=Ty(),Oe=(0,H.useRef)(new Map),[ke,Ae]=(0,H.useState)(!1),[je,Me]=(0,H.useState)(null),[Ne,Pe]=(0,H.useState)(``),[Fe,Ie]=(0,H.useState)(()=>Dwe(oo(B.annTools,null))),Le=e=>{Ie(e),$a(B.annTools,e)},[Re,ze]=(0,H.useState)(!1),{bodyRef:Be,side:Ve}=vTe(f),He=Fe.place===`auto`?Ve??`auto`:Fe.place,[Ue,We]=(0,H.useState)({k:1,tx:0,ty:0}),Ge=(0,H.useRef)(Ue);Ge.current=Ue;let Ke=(0,H.useRef)({k:1,tx:0,ty:0}),qe=(0,H.useRef)(new Map),Je=(0,H.useRef)(null);(0,H.useEffect)(()=>{let t=null,n=!1;S([]),Me(null),Pe(``),xe.current++,Ce(null),O(null),j(null),P(null),ie.current=null,ce(null),oe(!1);let r=(e,t)=>{let n=f.current;n.width=e,n.height=t;let r=p.current?.getBoundingClientRect();if(r){let n=Math.min(r.width/e,r.height/t),i={k:n,tx:(r.width-e*n)/2,ty:(r.height-t*n)/2};Ke.current=i,We(i)}Ye()},i=async e=>{try{let t=await createImageBitmap(e);return n?void 0:(m.current=t,r(t.width,t.height),!0)}catch{return!1}};return(async()=>{if(e instanceof File){if(await i(e))return;let a=new Image;t=URL.createObjectURL(e),a.onload=()=>{n||(m.current=a,r(a.naturalWidth,a.naturalHeight))},a.onerror=()=>!n&&ce(`Can't decode this image format on this device.`),a.src=t}else try{let t=await fetch(e.url).then(e=>e.blob());await i(t)||ce(`Can't load this image.`)}catch{ce(`Can't load this image.`)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,H.useEffect)(()=>{document.activeElement?.blur()},[]),(0,H.useEffect)(()=>{let e=p.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=f.current,n=e.getBoundingClientRect();if(!t||!t.width||!t.height||n.width<1||n.height<1)return;let r=Math.min(n.width/t.width,n.height/t.height),i={k:r,tx:(n.width-t.width*r)/2,ty:(n.height-t.height*r)/2},a=Math.abs(Ge.current.k-Ke.current.k)<=Ke.current.k*.02;Ke.current=i,a&&(Ge.current=i,Ye(),We(i))});return t.observe(e),()=>t.disconnect()},[]),(0,H.useEffect)(Ye,[x,le,de,D,T,A,F]),(0,H.useEffect)(()=>{!x.length&&T&&(E(!1),O(null),j(null))},[x.length,T]);function Ye(e=!1){let t=f.current,n=m.current;if(!t||!n)return;let r=t.getContext(`2d`);r.drawImage(n,0,0);let i=ie.current,a=i?C.current.map((e,t)=>t===i.i?i.live:e):C.current,o=w.current?[...a,w.current]:a;for(let e of o)ZY(r,t,n,e);nTe(r,t,zY(a,t.width,t.height)),le&&eTe(r,t,pe.current?qY(pe.current):de);let s=k.current;!e&&!le&&s!=null&&a[s]&&rTe(r,t,a[s],Ge.current.k||1,re.current,M.current)}function Xe(e){return JY(f.current,e)}let Ze={source:e,repoId:t,facts:i,onUploaded:a,onDispatch:o,onPark:s,onSendAll:l,canvasRef:f,wrapRef:p,imgRef:m,tool:h,setTool:g,color:_,setColor:v,factor:y,shapes:x,setShapes:S,shapesRef:C,dragRef:w,moveMode:T,setMoveMode:E,selected:D,setSelected:O,selectedRef:k,target:A,setTarget:j,targetRef:M,setMoveNote:P,setKnobs:I,knobsRef:re,moveRef:ie,busy:ae,setBusy:oe,setErr:ce,cropMode:le,setCropMode:ue,pendingCrop:de,setPendingCrop:fe,cropDrag:pe,pendingText:me,setPendingText:he,textDraft:ge,setTextDraft:_e,textInputRef:ve,idRef:ye,readTextRef:be,genRef:xe,editRead:Se,setEditRead:Ce,readDraft:we,setReadDraft:Te,readInputRef:Ee,setPaletteOpen:Ae,setView:We,viewRef:Ge,fitRef:Ke,pointers:qe,gesture:Je,redraw:Ye,clampToImage:Xe},Qe=aTe(Ze),$e=sTe(Ze),et=oTe(Ze),{send:tt,sendAll:nt}=gTe(Ze),rt=_Te({canvasRef:f,genRef:xe,redraw:Ye,setOcr:Me,setOcrDraft:Pe,onText:u}),it=mTe({canvasRef:f,imgRef:m,setShapes:S,genRef:xe,readsRef:Oe});(0,H.useEffect)(()=>it.sync(x,De),[x,De]),(0,H.useEffect)(()=>()=>it.abortAll(),[]);let at=Ue.k>Ke.current.k*1.02,ot=[...x].reverse().find(e=>e.tool===`marker`||!!De&&(e.tool===`rect`||e.tool===`circle`));return{props:{index:n,total:r,onSkip:c,onSendAll:l,onDispatch:o,onText:u,onClose:d},canvasRef:f,wrapRef:p,tool:h,color:_,setColor:v,factor:y,setFactor:b,shapes:x,setShapes:S,moveMode:T,selected:D,setSelected:O,target:A,setTarget:j,moveNote:N,setMoveNote:P,knobs:F,busy:ae,err:se,cropMode:le,pendingCrop:de,pendingText:me,textDraft:ge,setTextDraft:_e,textInputRef:ve,editRead:Se,setEditRead:Ce,readDraft:we,setReadDraft:Te,readInputRef:Ee,paletteOpen:ke,setPaletteOpen:Ae,view:Ue,fitRef:Ke,layout:Fe,setLayout:Le,configOpen:Re,setConfigOpen:ze,bodyRef:Be,place:He,moveRef:ie,zoomed:at,lastBand:ot,hintHidden:ee,hideHint:ne,...Qe,...$e,...et,send:tt,sendAll:nt,ocr:je,ocrDraft:Ne,setOcrDraft:Pe,...rt}}function bTe(e){let t=yTe(e);Ih(t.ocr!==null,t.closeOcr);let{index:n,total:r,onClose:i}=e;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(gE,{onClose:i,title:r&&r>1?`Mark & send · ${n??1}/${r}`:`Mark & send image`,children:(0,J.jsx)(Cwe,{m:t})}),e.prompt&&(0,J.jsx)(wwe,{prompt:e.prompt}),(0,J.jsx)(Rwe,{m:t}),t.ocr?(0,J.jsx)(zwe,{m:t}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ywe,{m:t}),(0,J.jsx)(Twe,{m:t})]})]})}var nX=6,rX=0;function xTe(){if(rX)return rX;rX=4096;try{let e=document.createElement(`canvas`).getContext(`webgl`),t=e?.getParameter(e.MAX_TEXTURE_SIZE);typeof t==`number`&&t>0&&(rX=t)}catch{}return rX}function STe(e,t){let n=Math.max(e,t)*(window.devicePixelRatio||1);return n?tm(xTe()/n,2,nX):nX}function iX({src:e,alt:t,onNav:n,onError:r}){let i=(0,H.useRef)(null),a=(0,H.useRef)(null),[o,s]=(0,H.useState)({s:1,x:0,y:0}),[c,l]=(0,H.useState)(!1),u=(0,H.useRef)(o);u.current=o;let d=(0,H.useRef)(new Map),f=(0,H.useRef)(null),p=(0,H.useRef)(null),m=(0,H.useRef)(0),[h,g]=(0,H.useState)(null);(0,H.useEffect)(()=>{s({s:1,x:0,y:0})},[e]);function _(e,t=!1){let n=a.current,r=i.current,o=Number.isFinite(e.s)?tm(e.s,1,nX):1;n&&n.offsetWidth&&(o=Math.min(o,STe(n.offsetWidth,n.offsetHeight)));let s=Number.isFinite(e.x)?e.x:0,c=Number.isFinite(e.y)?e.y:0;if(n&&r){let e=Math.max(0,(n.offsetWidth*o-r.clientWidth)/2),i=Math.max(0,(n.offsetHeight*o-r.clientHeight)/2);t||(s=tm(s,-e,e)),c=tm(c,-i,i)}return{s:o,x:s,y:c}}let v=()=>{let e=[...d.current.values()];return e.length>=2?e:null};function y(){let e=v();if(!e)return;let t=Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),n=i.current?.getBoundingClientRect(),r=n?n.left+n.width/2:0,a=n?n.top+n.height/2:0;f.current={dist:t||1,mx:(e[0].x+e[1].x)/2-r,my:(e[0].y+e[1].y)/2-a,s:u.current.s,x:u.current.x,y:u.current.y},p.current=null}function b(e){if(e.target.setPointerCapture?.(e.pointerId),d.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),l(!0),d.current.size>=2)y();else{let t=e.timeStamp;t-m.current<300?(s(e=>_(e.s>1?{s:1,x:0,y:0}:{s:2.5,x:0,y:0})),m.current=0):m.current=t,p.current={x:e.clientX,y:e.clientY,tx:u.current.x,ty:u.current.y}}}function x(e){let t=d.current.get(e.pointerId);if(!t)return;t.x=e.clientX,t.y=e.clientY;let r=v();if(r&&f.current){e.stopPropagation();let t=f.current,n=Math.hypot(r[0].x-r[1].x,r[0].y-r[1].y),a=i.current?.getBoundingClientRect(),o=(r[0].x+r[1].x)/2-(a?a.left+a.width/2:0),c=(r[0].y+r[1].y)/2-(a?a.top+a.height/2:0),l=tm(t.s*n/t.dist,1,nX);s(_({s:l,x:o-(t.mx-t.x)*(l/t.s),y:c-(t.my-t.y)*(l/t.s)}))}else if(p.current&&u.current.s>1){e.stopPropagation();let t=p.current;s(n=>_({s:n.s,x:t.tx+(e.clientX-t.x),y:t.ty+(e.clientY-t.y)}))}else if(p.current&&n){let t=p.current;s(n=>({...n,x:t.tx+(e.clientX-t.x)}))}}function S(e){if(d.current.delete(e.pointerId),d.current.size<2&&(f.current=null),d.current.size===1){let[e]=[...d.current.values()];p.current={x:e.x,y:e.y,tx:u.current.x,ty:u.current.y}}if(d.current.size===0){if(l(!1),p.current&&u.current.s<=1&&n&&e.type!==`pointercancel`){let t=e.clientX-p.current.x,r=e.clientY-p.current.y;Math.abs(t)>60&&Math.abs(t)>Math.abs(r)*1.5&&n(t<0?1:-1)}s(e=>e.s<=1?{s:1,x:0,y:0}:_(e)),p.current=null}}let C=o.s>1.01;return(0,J.jsxs)(`div`,{ref:i,className:`zoom-stage`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:S,children:[h===e?(0,J.jsxs)(`div`,{className:`img-missing`,children:[(0,J.jsx)(_s,{size:22}),(0,J.jsx)(`span`,{className:`img-missing-name`,children:t}),(0,J.jsx)(`span`,{children:`couldn’t load this image — the host may be unreachable`})]}):(0,J.jsx)(`img`,{ref:a,src:e,alt:t,draggable:!1,onLoad:()=>s(e=>_(e)),onError:()=>{g(e),r?.()},style:{transform:`translate(${o.x}px, ${o.y}px) scale(${o.s})`,willChange:c?`transform`:`auto`}}),C&&(0,J.jsxs)(`button`,{className:`zoom-reset`,"aria-label":`reset zoom`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),s({s:1,x:0,y:0})},children:[(0,J.jsx)(yc,{size:16}),` `,o.s.toFixed(1),`×`]})]})}function CTe({items:e,index:t,onIndex:n,onAnnotate:r,onReference:i,onClose:a}){let o=e[t],[s,c]=(0,H.useState)(!1);(0,H.useEffect)(()=>{c(!1)},[t]);let l=r=>{let i=t+r;i>=0&&i<e.length&&n(i)};return(0,H.useEffect)(()=>{let e=e=>{e.key===`ArrowRight`?l(1):e.key===`ArrowLeft`?l(-1):e.key===`Escape`&&(e.preventDefault(),a())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,H.useEffect)(()=>{o||a()},[o,a]),o?(0,J.jsxs)(`div`,{className:`viewer`,onClick:a,children:[(0,J.jsx)(`button`,{className:`viewer-close`,onClick:a,"aria-label":`close`,children:(0,J.jsx)(V,{size:22})}),(0,J.jsxs)(`div`,{className:`viewer-body`,onClick:e=>e.stopPropagation(),children:[o.video?(0,J.jsx)(`video`,{className:`viewer-video`,src:o.url,controls:!0,autoPlay:!0,playsInline:!0},o.relPath):(0,J.jsx)(iX,{src:s&&o.fullUrl?o.fullUrl:o.url,alt:o.name,onNav:e.length>1?l:void 0},`${o.relPath}:${s?`full`:`fit`}`),(0,J.jsx)(`div`,{className:`viewer-path mono`,children:o.relPath}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[e.length>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:()=>l(-1),disabled:t===0,"aria-label":`previous`,children:(0,J.jsx)(Hl,{size:16})}),(0,J.jsxs)(`span`,{className:`viewer-count`,children:[t+1,` / `,e.length]}),(0,J.jsx)(Y,{onClick:()=>l(1),disabled:t===e.length-1,"aria-label":`next`,children:(0,J.jsx)(jl,{size:16})})]}),!o.video&&o.fullUrl&&o.fullUrl!==o.url&&!s&&(0,J.jsx)(Y,{title:`load the original file instead of the screen-sized copy`,onClick:()=>c(!0),children:`full res`}),!o.video&&r&&(0,J.jsxs)(Y,{onClick:()=>r(o),children:[(0,J.jsx)(us,{size:16}),` mark`]}),o.repoId&&(0,J.jsx)(FO,{target:{repoId:o.repoId,relPath:o.relPath,name:o.name},trackId:`action:swipe.download`}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>i(o),children:`ref path`})]})]})]}):null}function wTe(){let e=K(gJ);return e?(0,J.jsx)(uwe,{files:e.files,onCombine:DCe,onSeparate:OCe,onClose:kCe}):null}function aX(){let e=K(mJ);return EY()&&!!e&&wJ.ret===`session`&&!!W().world.active}function TTe(){let e=K(mJ),t=aX();if(!e)return null;let n=wJ.ret===`session`,r=!!e.total&&e.total>1,i=W(),a=n&&!t&&i.world.active?{value:i.compose.draft,onChange:e=>{W().compose.typeOn(W().compose.draft,e)||W().say.toast(`The message box changed meanwhile — that key was not applied`)}}:void 0;return(0,J.jsx)(bTe,{prompt:a,source:e.source,repoId:e.repoId,index:e.index,total:e.total,facts:e.facts,onUploaded:ICe,onDispatch:n?NCe:void 0,onPark:MCe,onSkip:r?PCe:void 0,onSendAll:r&&n?FCe:void 0,onText:LCe,onClose:lY})}function ETe(){let e=K(_J),t=K(SJ);if(!e)return null;let n=e.sessionId?jJ(t.get(e.sessionId)??[]):[],r=e.items??n.map(e=>({name:e.name,relPath:e.relPath,url:OJ(e.relPath)?U.artifactUrl(e.repoId,e.relPath):sg(U.artifactUrl(e.repoId,e.relPath),og(),e.mtime),fullUrl:U.artifactUrl(e.repoId,e.relPath),video:OJ(e.relPath)}));return(0,J.jsx)(CTe,{items:r,index:Math.min(e.i,Math.max(0,r.length-1)),onIndex:e=>zJ(t=>t&&{...t,i:e}),onAnnotate:e.revoke?void 0:e=>qCe(e,n),onReference:e=>JCe(e,n),onClose:HJ})}var oX=[{label:`10m`,long:`10 minutes`,secs:600},{label:`4h`,long:`4 hours`,secs:14400},{label:`24h`,long:`24 hours`,secs:86400}];function sX(e){return e===`outbox`?14400:void 0}var DTe=[{label:`images`,value:`image`},{label:`docs`,value:`doc`}],cX=4e5,OTe={new:`new — not opened on this device yet`,opened:`opened in ${L.name} on this device`,downloaded:`downloaded to this phone`};function lX(e){if(!e)return``;let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function uX(e){return e?new Date(e).toLocaleString():``}var dX=(e,t)=>t.repoId??e,fX=(e,t,n)=>e===`inbox`?U.inboxUrl(dX(t,n),n.name):U.artifactUrl(dX(t,n),n.relPath),pX=(e,t,n)=>sg(fX(e,t,n),ag(140),n.mtime),kTe=(e,t,n,r)=>n?fX(e,t,r):sg(fX(e,t,r),og(),r.mtime),ATe=e=>nO(e.relPath)&&(e.size??0)>=49152;function jTe({openFile:e,onClose:t}){let[n,r]=(0,H.useState)(e?{...e,size:e.size??0,mtime:e.mtime??0,ctime:e.mtime??0}:null),i=(0,H.useRef)(!!e),a=e=>{i.current=!1,r(e)};return Ih(n!==null&&!i.current,()=>a(null)),{open:n,showFile:a,closeDoc:()=>{i.current?(i.current=!1,t()):a(null)}}}function MTe({repoId:e,repos:t,initialScope:n,initialAllTime:r,initialNew:i}){let a=!!e,o=n??(a?`outbox`:`all`),[s,c]=(0,H.useState)(o),l=i?Math.max(1,Math.ceil((Date.now()-i.since)/1e3)):void 0,[u,d]=(0,H.useState)(l??(r?void 0:sX(o))),[f,p]=(0,H.useState)(!!l),m=e=>{c(e),d(sX(e)),P(60),p(!1)},[h,g]=(0,H.useState)(`all`),[_,v]=(0,H.useState)(``),[y,b]=(0,H.useState)([]),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)(!0),[T,E]=(0,H.useState)(null),[D,O]=(0,H.useState)(null),[k,A]=(0,H.useState)(null),[j,M]=(0,H.useState)(0),[N,P]=(0,H.useState)(60),F=(t??[]).map(e=>e.id).join(`,`),I={kind:h,since:s===`inbox`?void 0:u},ee=lte(s,e,F);return(0,H.useEffect)(()=>{let t=!1,n=new AbortController,r=!1;w(!0),E(null),A(null);let i=(n,i,a)=>{if(!t&&(r=!0,b(n),S(i),w(!1),E(null),O(null),vj(n,e),!_.trim())){let e=a??{rows:n,cov:I,truncated:i};SC(ee,e.cov,e.rows,e.truncated)}},a=async n=>{let i=await CC(ee,I);if(t||r)return!1;if(!i)return n&&w(!1),!1;let a=Yi(i.rows,{...I,query:_},iO,Date.now());return vj(a,e),b(a.slice(0,N)),S(a.length>N||i.exact&&i.truncated),O(i.savedAt),n&&w(!1),!0};a(!1);let o=e=>{t||a(!0).then(n=>{if(t)return;w(!1);let r=Ba(e)?`the host didn't answer`:String(e?.message||e||`request failed`);A(n?r:null),E(n?null:r)})};return s===`all`?U.search({query:_,kind:h,scope:`repo`,sinceSeconds:u,repoIds:F?F.split(`,`):void 0,limit:N,signal:n.signal}).then(e=>i(e.hits,e.truncated)).catch(o):s===`inbox`?(U.markInboxSeen(e),U.inbox(e,n.signal).then(e=>{let t=Yi(e,{kind:h,query:_},iO,Date.now());i(t.slice(0,N),t.length>N,{rows:e,cov:{kind:`all`},truncated:!1})}).catch(o)):(s===`outbox`&&U.markOutboxSeen(e),U.artifacts(e,s,u,{query:_,kind:h,limit:N,signal:n.signal}).then(e=>i(e.files,e.truncated)).catch(o)),()=>{t=!0,n.abort()}},[e,F,s,u,h,_,j,N]),(0,H.useEffect)(()=>{D!=null||T||_ge(y.filter(e=>nO(e.relPath)||rO(e.relPath)).slice(0,24).map(t=>pX(s,e,t)))},[y,D,T]),(0,H.useEffect)(()=>{P(60)},[u,h,_,e]),{singleRepo:a,scope:s,changeScope:m,since:u,setSince:d,newSecs:l,onNewCut:f,setOnNewCut:p,kind:h,setKind:g,query:_,setQuery:v,files:y,truncated:x,loading:C,loadErr:T,cachedAt:D,staleWhy:k,setReload:M,setLimit:P}}function NTe({open:e,scope:t,repoId:n}){let[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(0);return(0,H.useEffect)(()=>{i(!1)},[e?.relPath,e?.repoId]),(0,H.useEffect)(()=>{e&&t!==`inbox`&&(Qde(dX(n,e),e.relPath,e.mtime),m(e=>e+1))},[e?.relPath,e?.repoId,t]),(0,H.useEffect)(()=>{if(c(null),f(!1),u(null),!e||!uO(e.relPath)){o(null);return}let r=new AbortController,i=!1,a=e.relPath,s=dX(n,e),l=e.mtime,d=l>0,p=async()=>{let e=d?await FC(s,a,l):null;return r.signal.aborted||i||!e?!1:(o({path:a,text:e.text,truncated:e.truncated}),u(e.savedAt),!0)};return p(),fp(fX(t,n,e),{signal:r.signal}).then(e=>e.ok?e.text():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>{if(r.signal.aborted)return;i=!0;let t={path:a,text:e.slice(0,cX),truncated:e.length>cX};o(t),u(null),d&&PC(s,a,l,t.text,t.truncated)}).catch(e=>{r.signal.aborted||p().then(t=>{r.signal.aborted||t||(o(null),c(Ba(e)?`the host didn't answer, and this device has no saved copy`:String(e?.message||e)))})}),()=>r.abort()},[e?.relPath,e?.repoId,t]),{fullRes:r,setFullRes:i,doc:a,docErr:s,docCachedAt:l,docRaw:d,setDocRaw:f,markTick:p,setMarkTick:m}}function PTe(e,t,n){let r=n(t);return e.some(e=>n(e)===r)?e.filter(e=>n(e)!==r):[...e,t]}function FTe(e){return e===0?`Tap the pictures to combine, in the order you want them numbered.`:e===1?`1 picked — tap one more: a combined picture needs at least two.`:`${e} picked, numbered in the order you tapped them.`}function ITe(e){let[t,n]=(0,H.useState)(null),r=t=>`${e.repoOf(t)}:${t.relPath}`;return{picked:t,pickIndex:e=>t?t.findIndex(t=>r(t)===r(e)):-1,canPick:!!e.onCombine&&e.singleRepo&&e.files.filter(e=>nO(e.relPath)).length>=2,startPick:()=>{q(`action:gallery.pick`),n([])},cancelPick:()=>n(null),togglePicked:e=>{nO(e.relPath)&&n(t=>PTe(t??[],e,r))},combinePicked:()=>{if(!t||t.length<2||!e.onCombine)return;q(`action:gallery.combine`);let r=t.map(t=>({url:e.urlFor(t),name:t.name,repoId:e.repoOf(t)}));n(null),e.onCombine(r)}}}function LTe(e){let{repoId:t,openFile:n,onClose:r}=e,{open:i,showFile:a,closeDoc:o}=jTe({openFile:n,onClose:r}),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),d=e=>{u(e),window.setTimeout(()=>u(t=>t===e?null:t),4e3)},[f,p]=(0,H.useState)(new Set),m=e=>p(t=>t.has(e)?t:new Set(t).add(e)),[h,g]=(0,H.useState)([]);(0,H.useEffect)(()=>gS.subscribe(g),[]);let _=MTe(e),{scope:v,files:y,loading:b,setReload:x}=_,S=NTe({open:i,scope:v,repoId:t}),{fullRes:C,docRaw:w,markTick:T}=S,E=e=>e&&b?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsx)(Ul,{size:12,className:`spin`})]}):null,D=e=>dX(t,e),O=e=>fX(v,t,e),k=e=>pX(v,t,e),A=e=>kTe(v,t,C,e),j=e=>v===`inbox`||e.relPath.startsWith(`.claude/inbox/`),M=e=>{if(v===`inbox`)return null;let t=OO(D(e),e.relPath,e.mtime);return t===`new`&&v!==`outbox`?null:t},N=e=>{let t=D(e);return h.find(n=>n.item.repoId===t&&n.item.relPath===e.relPath&&Math.round(n.item.mtime)===Math.round(e.mtime))},P=e=>({repoId:D(e),relPath:e.relPath,name:e.name,size:e.size,mtime:e.mtime,repoName:e.repoName}),F=e=>{let t=ix(e);return t.phase===`have`||t.phase===`saved`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(go,{size:11}),` on phone`]}):t.phase===`downloading`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ul,{size:11,className:`spin`}),` `,t.pct,`%`]}):t.phase===`failed`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Js,{size:11}),` stopped`]}):t.phase===`idle`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rs,{size:11}),` was here`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Rs,{size:11}),` queued`]})},I=i?N(i):void 0,ee=I?.state===`done`?I.item.id:null,[te,ne]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(ne(null),!ee)return;let e=null,t=!1;return gS.objectUrl(ee).then(n=>{n&&(t?URL.revokeObjectURL(n):(e=n,ne(n)))}),()=>{t=!0,e&&URL.revokeObjectURL(e)}},[ee]);let re=e=>te??A(e),ie=e=>te??O(e),ae=!!i&&sO(i.relPath)&&!w,oe=y.filter(e=>nO(e.relPath)),se=i?oe.findIndex(e=>e.relPath===i.relPath&&e.repoId===i.repoId):-1;function ce(e){let t=se>=0?oe[se+e]:void 0;t&&a(t)}(0,H.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`ArrowRight`?ce(1):e.key===`ArrowLeft`?ce(-1):e.key===`Escape`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});async function le(e){try{return await U.deleteInbox(D(e),e.name),x(e=>e+1),!0}catch(t){return d(Ba(t)?`Could not delete ${e.name} — the host didn't answer. The file is still on the desktop.`:`Could not delete ${e.name} — ${String(t?.message||t)}`),!1}}async function ue(e){q(`action:gallery.delete`),await le(e)&&a(null)}let de=ITe({onCombine:e.onCombine,singleRepo:_.singleRepo,files:y,repoOf:D,urlFor:O});async function fe(e){let t=await gp(e);c(t?e:null),setTimeout(()=>c(null),1500)}return{props:e,..._,...S,open:i,showFile:a,closeDoc:o,copied:s,note:l,badSrc:f,markBad:m,busyMark:E,repoOf:D,urlFor:O,thumbFor:k,canFullRes:ATe,isInboxFile:j,markOf:M,pullOf:N,dlTarget:P,pullBadge:F,localUrl:te,mediaSrc:re,fileSrc:ie,htmlLive:ae,imgs:oe,openIdx:se,nav:ce,removeInbox:le,del:ue,copy:fe,...de}}function RTe(e,t,n,r){let i=`${e} new since you last looked`;return n||t===e?i:r?`${i} · newest ${t} shown`:`${i} · ${t} still here`}function zTe(e){let t=oX.find(t=>t.secs===e);return t?`Nothing from the last ${t.long}.`:null}function BTe({m:e}){let{scope:t,loading:n,singleRepo:r,changeScope:i,kind:a,setKind:o,since:s,setSince:c,newSecs:l,onNewCut:u,setOnNewCut:d}=e,{initialNew:f}=e.props,p=(e,r)=>(0,J.jsxs)(`button`,{className:`seg${t===e?` on`:``}${t===e&&n?` busy`:``}`,"aria-pressed":t===e,onClick:()=>i(e),children:[r,t===e&&n?(0,J.jsx)(Ul,{size:13,className:`spin`}):null]}),m=(e,t,r,i)=>(0,J.jsx)(pE,{on:e,busy:e&&n,title:i,onClick:r,children:t}),h=()=>{c(void 0),d(!1)};return(0,J.jsxs)(J.Fragment,{children:[r&&(0,J.jsxs)(`div`,{className:`segmented gallery-scope`,children:[p(`inbox`,`inbox`),p(`outbox`,`outbox`),p(`repo`,`this repo`),p(`all`,`all repos`)]}),(0,J.jsxs)(`div`,{className:`fchips gallery-filters`,children:[DTe.map(e=>(0,J.jsx)(H.Fragment,{children:m(a===e.value,e.label,()=>o(a===e.value?`all`:e.value))},e.value)),t!==`inbox`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`fchips-gap`,"aria-hidden":!0}),l!==void 0&&m(u,`${f.count} new`,()=>{u?h():(c(l),d(!0))},`the ${f.count} file${f.count>1?`s`:``} added since you last opened this outbox — the badge you tapped`),oX.map(e=>(0,J.jsx)(H.Fragment,{children:m(!u&&s===e.secs,e.label,()=>{!u&&s===e.secs?h():(c(e.secs),d(!1))},`only files from the last ${e.long}`)},e.label))]})]})]})}function VTe({m:e}){let{scope:t,loading:n,files:r,truncated:i,query:a,setQuery:o,singleRepo:s,setSince:c,onNewCut:l,setOnNewCut:u,loadErr:d,setReload:f,cachedAt:p,staleWhy:m,note:h,open:g}=e,{onClose:_,onSweep:v,onSurvey:y,initialNew:b}=e.props,x=r.length;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(gE,{title:`Images & documents`,onClose:_,children:[(x>0||n)&&(0,J.jsx)(`span`,{className:`gallery-meta`,title:no()?void 0:`build 4da059cd`,children:n&&!x?(0,J.jsx)(Ul,{size:12,className:`spin`}):`${x}${i?`+`:``} file${x===1&&!i?``:`s`}`}),v&&s&&(t===`inbox`||t===`outbox`)&&(0,J.jsx)(Y,{className:`gallery-head-btn`,title:`clear out old ${t} files`,"aria-label":`clear out old ${t} files`,onClick:()=>v(t),children:(0,J.jsx)(ic,{size:17})}),y&&t===`all`&&(0,J.jsx)(Y,{className:`gallery-head-btn`,title:`what is taking space, repo by repo`,"aria-label":`what is taking space`,onClick:y,children:(0,J.jsx)(Es,{size:17})})]}),(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(`div`,{className:`search-row`,children:[(0,J.jsx)(Lc,{size:16}),(0,J.jsx)(`input`,{className:`search`,placeholder:t===`all`?`Search every repo by name`:`Search by name`,value:a,onChange:e=>o(e.target.value)}),a&&(0,J.jsx)(Y,{"aria-label":`clear the search`,onClick:()=>o(``),children:(0,J.jsx)(V,{size:14})})]})}),(0,J.jsx)(BTe,{m:e}),l&&(0,J.jsx)(cE,{onClear:()=>{c(void 0),u(!1)},clearLabel:`show all`,children:RTe(b.count,x,n,i)}),d&&(0,J.jsxs)(`div`,{className:`gallery-note err`,children:[(0,J.jsx)(Js,{size:14}),(0,J.jsxs)(`span`,{children:[`Could not load the list (`,d,`)`,x?` — showing what was already loaded`:``,`.`]}),(0,J.jsxs)(Y,{onClick:()=>f(e=>e+1),children:[(0,J.jsx)($c,{size:14}),` retry`]})]}),p!=null&&(0,J.jsxs)(`div`,{className:`gallery-note`,children:[(0,J.jsx)(Hs,{size:14}),(0,J.jsx)(`span`,{children:m?`Showing the list this phone last saw, ${lX(p)} — ${m}.`:`Showing the list this phone last saw, ${lX(p)} — refreshing…`}),m&&(0,J.jsxs)(Y,{onClick:()=>f(e=>e+1),children:[(0,J.jsx)($c,{size:14}),` retry`]})]}),h&&!g&&(0,J.jsx)(`div`,{className:`gallery-note`,children:h})]})}var HTe=[[/^(md|markdown|txt|log|rst|pdf)$/,Nl],[/^(html?|json|ya?ml|toml|xml|js|mjs|ts|tsx|css|sh|py|diff|patch)$/,ire],[/^(csv|tsv|xlsx?|ods)$/,cre],[/^(zip|tar|gz|tgz|7z|rar)$/,Dne],[/^(apk|aab|ipa)$/,ql],[/^(mp3|m4a|wav|ogg|opus|flac|aac)$/,Hne]];function UTe({name:e}){let t=e.lastIndexOf(`.`),n=t>0?e.slice(t+1).toLowerCase():``,r=HTe.find(([e])=>e.test(n))?.[1]??Mc;return(0,J.jsxs)(`span`,{className:`doc`,"aria-hidden":!0,children:[(0,J.jsx)(r,{size:30,strokeWidth:1.5}),n&&(0,J.jsx)(`span`,{className:`doc-ext`,children:n})]})}function WTe({url:e,name:t,missing:n,onMissing:r}){let{src:i,live:a}=jj(e);return n?(0,J.jsxs)(`span`,{className:`img-missing`,children:[(0,J.jsx)(_s,{size:18}),(0,J.jsx)(`span`,{className:`img-missing-name`,children:t})]}):i?(0,J.jsx)(`img`,{src:i,alt:t,loading:`lazy`,decoding:`async`,onLoad:()=>{a&&Oj(e)},onError:r}):(0,J.jsx)(`span`,{className:`thumb-blank`})}function GTe({src:e,poster:t,name:n}){let{src:r,live:i}=jj(t);return(0,H.useEffect)(()=>{i&&Oj(t)},[i,t]),(0,J.jsx)(`video`,{src:e,poster:r??void 0,title:n,muted:!0,playsInline:!0,preload:`none`})}function KTe({m:e}){let{picked:t,canPick:n,startPick:r,cancelPick:i,combinePicked:a}=e;return t?(0,J.jsxs)(`div`,{className:`annot-tools gallery-pick on`,children:[(0,J.jsx)(`span`,{className:`viewer-doc-note`,children:FTe(t.length)}),(0,J.jsxs)(Y,{onClick:i,children:[(0,J.jsx)(V,{size:14}),` cancel`]}),t.length>=2&&(0,J.jsxs)(`button`,{className:`send`,onClick:a,children:[(0,J.jsx)(Wc,{size:14}),` combine `,t.length]})]}):n?(0,J.jsx)(`div`,{className:`annot-tools gallery-pick`,children:(0,J.jsxs)(Y,{"aria-label":`pick pictures to combine`,onClick:r,children:[(0,J.jsx)(Wc,{size:14}),` combine pictures…`]})}):null}function qTe({m:e}){let{files:t,loading:n,loadErr:r,query:i,kind:a,scope:o,truncated:s,showFile:c,badSrc:l,markBad:u,urlFor:d,thumbFor:f,markOf:p,pullOf:m,pullBadge:h,isInboxFile:g,removeInbox:_,setLimit:v,onNewCut:y,since:b,setSince:x,setOnNewCut:S}=e,C=e=>y&&p(e)===`new`?null:p(e),w=o!==`inbox`&&!y?zTe(b):null,{picked:T,pickIndex:E,togglePicked:D}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(KTe,{m:e}),(0,J.jsxs)(`div`,{className:`grid${n&&t.length?` stale`:``}`,children:[t.map(e=>(0,J.jsxs)(`div`,{className:`thumb-wrap${E(e)>=0?` picked`:``}`,children:[T&&E(e)>=0&&(0,J.jsx)(`span`,{className:`thumb-pick`,"aria-hidden":`true`,children:E(e)+1}),(0,J.jsxs)(`button`,{className:`thumb`,"aria-pressed":T&&nO(e.relPath)?E(e)>=0:void 0,onClick:()=>T?D(e):c(e),children:[nO(e.relPath)?(0,J.jsx)(WTe,{url:f(e),name:e.name,missing:l.has(f(e)),onMissing:()=>u(f(e))}):rO(e.relPath)?(0,J.jsx)(GTe,{src:d(e),poster:f(e),name:e.name}):(0,J.jsx)(UTe,{name:e.name}),(0,J.jsx)(`span`,{className:`thumb-name`,children:e.name}),(0,J.jsxs)(`span`,{className:`thumb-date`,title:uX(e.ctime??e.mtime),children:[lX(e.ctime??e.mtime),e.size?(0,J.jsxs)(`span`,{className:`thumb-size`,children:[` · `,zp(e.size)]}):null]}),e.repoName&&(0,J.jsx)(`span`,{className:`thumb-repo`,children:e.repoName}),(0,J.jsxs)(`span`,{className:`thumb-badges`,children:[C(e)&&!m(e)&&(0,J.jsx)(`span`,{className:`thumb-mark ${C(e)}`,title:OTe[C(e)],children:C(e)===`new`?(0,J.jsx)(`span`,{className:`sr-only`,children:`new`}):C(e)===`downloaded`?(0,J.jsx)(rs,{size:11}):(0,J.jsx)(as,{size:11})}),m(e)&&(0,J.jsx)(`span`,{className:`thumb-pull ${m(e).state}`,title:ix(m(e)).detail,children:h(m(e))})]})]}),g(e)&&(0,J.jsx)(uT,{className:`thumb-del`,title:`delete ${e.name}`,confirmTitle:`tap again to delete ${e.name}`,confirm:(0,J.jsx)(Js,{size:14}),onConfirm:()=>{_(e)},children:(0,J.jsx)(ic,{size:14})})]},`${e.repoId??``}:${e.relPath}`)),t.length===0&&n&&Array.from({length:8},(e,t)=>(0,J.jsx)(`div`,{className:`thumb-wrap`,children:(0,J.jsx)(`div`,{className:`thumb skel-thumb`})},`skel-${t}`)),t.length===0&&!n&&!r&&(0,J.jsx)($,{children:i||a!==`all`?`No matches.`:w?(0,J.jsxs)(J.Fragment,{children:[w,` `,(0,J.jsx)(`button`,{className:`link-btn`,onClick:()=>{x(void 0),S(!1)},children:`show older files`})]}):o===`outbox`?`The outbox is empty. Claude puts screenshots and files meant for your phone in .claude/outbox. To see images anywhere in the repo, switch to this repo.`:`Nothing here yet.`})]}),s&&(0,J.jsxs)(`div`,{className:`annot-tools`,children:[(0,J.jsxs)(Y,{onClick:()=>{q(`action:gallery.more`),v(e=>e+60)},children:[`load `,60,` more`]}),(0,J.jsxs)(`span`,{className:`viewer-doc-note`,children:[`showing the newest `,t.length]})]})]})}function mX(e){let{onContinueInSession:t,sessionsIn:n}=e.props;return t&&n?n(e.repoId):[]}function hX(e,t){q(t?`action:gallery.toSession`:`action:gallery.toNewSession`),e.setPicking(!1),e.props.onContinueInSession?.(e.relPath,e.repoId,t)}function JTe(e){if(!e.props.onContinueInSession)return null;let t=mX(e);return(0,J.jsxs)(J.Fragment,{children:[t.length===1&&(0,J.jsxs)(Y,{title:`put this file's path in that session's prompt`,onClick:()=>hX(e,t[0].id),children:[(0,J.jsx)(Go,{size:16}),` `,t[0].label]}),t.length>1&&(0,J.jsxs)(Y,{title:`pick which live session gets this file's path`,onClick:()=>e.setPicking(!e.picking),children:[(0,J.jsx)(Go,{size:16}),` session · `,t.length]}),(0,J.jsxs)(Y,{title:`start a new session in this repo with this file's path in its prompt`,onClick:()=>hX(e,null),children:[(0,J.jsx)(os,{size:16}),` new session`]})]})}function YTe(e){let t=mX(e);return!e.picking||t.length<2?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`viewer-doc-note`,children:[t.length,` live sessions in `,e.repoName||`this repo`,` — the path goes into the prompt of the one you pick`]}),(0,J.jsx)(`div`,{className:`list`,children:t.map(t=>(0,J.jsxs)(xE,{as:`button`,onClick:()=>hX(e,t.id),children:[(0,J.jsxs)(SE,{children:[(0,J.jsx)(xo,{size:14}),` `,t.label]}),t.onScreen&&(0,J.jsx)(Q,{children:`on screen behind the gallery`})]},t.id))})]})}function XTe({m:e}){let{open:t,closeDoc:n,repoOf:r,localUrl:i,fullRes:a,mediaSrc:o,fileSrc:s,imgs:c,nav:l,setDocRaw:u,docRaw:d,doc:f,docErr:p,docCachedAt:m,htmlLive:h,pullOf:g,dlTarget:_,files:v,showFile:y,openIdx:b,copied:x,copy:S,canFullRes:C,setFullRes:w,urlFor:T,setMarkTick:E,isInboxFile:D,del:O,note:k}=e,{onAnnotate:A,onInsertPath:j,onClose:M}=e.props,[N,P]=(0,H.useState)(null);if(!t)return null;let F={relPath:t.relPath,repoId:r(t),repoName:t.repoName,props:e.props,picking:N===t.relPath,setPicking:e=>P(e?t.relPath:null)};return(0,J.jsxs)(`div`,{className:`viewer`,onClick:()=>n(),children:[(0,J.jsx)(`button`,{className:`viewer-close`,onClick:()=>n(),"aria-label":`close`,children:(0,J.jsx)(V,{size:22})}),(0,J.jsxs)(`div`,{className:`viewer-body`,onClick:e=>e.stopPropagation(),children:[nO(t.relPath)?(0,J.jsx)(iX,{src:o(t),alt:t.name,onNav:c.length>1?l:void 0},`${r(t)}:${t.relPath}:${i?`local`:a?`full`:`fit`}`):rO(t.relPath)?(0,J.jsx)(`video`,{className:`viewer-video`,src:s(t),controls:!0,autoPlay:!0,playsInline:!0},`${r(t)}:${t.relPath}:${i?`local`:`net`}`):uO(t.relPath)?(0,J.jsxs)(`div`,{className:`viewer-doc`,children:[cO(t.relPath)&&(0,J.jsxs)(`div`,{className:`viewer-doc-bar`,children:[(0,J.jsx)(Y,{onClick:()=>u(e=>!e),children:d?`rendered`:`source`}),f?.truncated&&!h&&(0,J.jsxs)(`span`,{className:`viewer-doc-note`,children:[`showing the first `,400,` KB — download for the rest`]}),m!=null&&!h&&(0,J.jsxs)(`span`,{className:`viewer-doc-note`,children:[(0,J.jsx)(Hs,{size:12}),` saved copy from `,lX(m)]})]}),h?(0,J.jsx)(`iframe`,{className:`viewer-html`,src:s(t),title:t.name,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`},`${r(t)}:${t.relPath}:${i?`local`:`net`}`):p?(0,J.jsxs)($,{children:[`Could not load this file (`,p,`). `,(0,J.jsx)(FO,{rec:g(t),target:_(t)})]}):!f||f.path!==t.relPath?(0,J.jsx)($,{children:`Loading…`}):lO(t.relPath)&&!d?(0,J.jsx)(`div`,{className:`viewer-doc-body`,children:(0,J.jsx)(Rj,{src:f.text,q:``,onCopy:e=>gp(e),files:{repoId:r(t),url:(e,n,i)=>{let a=U.artifactUrl(r(t),e);return n?sg(a,n,i):a},open:e=>{let n=v.find(t=>t.relPath===e);n?y(n):NO({repoId:r(t),relPath:e})},known:v.filter(e=>r(e)===r(t)).map(e=>e.relPath),docPath:t.relPath}})}):(0,J.jsxs)(`pre`,{className:`viewer-doc-pre`,children:[f.text,f.truncated?`
|
|
206
206
|
… (truncated — download for the rest)`:``]})]}):aO(t.relPath)?(0,J.jsx)(`audio`,{className:`viewer-audio`,src:s(t),controls:!0,preload:`metadata`},`${r(t)}:${t.relPath}:${i?`local`:`net`}`):oO(t.relPath)?(0,J.jsxs)(`div`,{className:`viewer-doc`,children:[(0,J.jsx)(`iframe`,{className:`viewer-pdf`,src:s(t),title:t.name}),(0,J.jsxs)(`div`,{className:`viewer-doc-note`,children:[(0,J.jsx)(FO,{rec:g(t),target:_(t)}),` if the preview stays blank`]})]}):(0,J.jsxs)(`div`,{className:`viewer-none`,children:[(0,J.jsx)(sc,{size:28}),(0,J.jsx)(`span`,{children:`no preview for this kind of file — the actions below download it or copy its path`})]}),(0,J.jsxs)(`div`,{className:`viewer-path mono`,children:[t.repoName?`${t.repoName} · `:``,t.relPath]}),(0,J.jsxs)(`div`,{className:`viewer-path`,children:[`created `,uX(t.ctime??t.mtime),b>=0&&c.length>1?` · ${b+1} / ${c.length}`:``]}),i&&(0,J.jsxs)(`div`,{className:`viewer-doc-note`,children:[(0,J.jsx)(go,{size:12}),` shown from the copy already on this phone — no host needed`]}),m!=null&&!cO(t.relPath)&&(0,J.jsxs)(`div`,{className:`viewer-doc-note`,children:[(0,J.jsx)(Hs,{size:12}),` saved copy from `,lX(m)]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:()=>n(),children:[(0,J.jsx)(Hl,{size:16}),` back`]}),(0,J.jsx)(Y,{onClick:()=>S(t.relPath),children:x===t.relPath?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ys,{size:16}),` copied`]}):`copy path`}),C(t)&&!a&&!i&&(0,J.jsxs)(Y,{"data-hint":`gallery.fullres`,title:`load the original file instead of the screen-sized copy`,onClick:()=>{q(`action:gallery.fullres`),w(!0)},children:[`full res`,t.size?` (${Math.round(t.size/1024)} KB)`:``]}),nO(t.relPath)&&(0,J.jsxs)(Y,{onClick:()=>{q(`action:gallery.annotate`),A(T(t),t.name,r(t))},children:[(0,J.jsx)(us,{size:16}),` annotate`]}),(0,J.jsx)(FO,{rec:g(t),target:_(t),trackId:`action:gallery.download`,onStart:()=>E(e=>e+1)}),D(t)&&(0,J.jsx)(Y,{variant:`danger`,onClick:()=>O(t),children:`delete`}),(0,J.jsx)(JTe,{...F}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>{j(t.relPath),M()},children:`insert path`})]}),(0,J.jsx)(YTe,{...F}),k&&(0,J.jsx)(`div`,{className:`viewer-doc-note`,children:k})]})]})}function ZTe(e){let t=LTe(e);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(VTe,{m:t}),(0,J.jsx)(qTe,{m:t}),(0,J.jsx)(XTe,{m:t})]})}function QTe(e,t,n=t){let r=Math.min(t,n),i=Math.max(t,n);return!e||!e.open?{from:r,to:i,open:!0}:e.from===r&&e.to===i?null:{from:Math.min(e.from,r),to:Math.max(e.to,i),open:!1}}function $Te(e,t){return e===t?`${e}`:`${e}-${t}`}function gX(e,t){return e===t?`line ${e}`:`lines ${e}–${t}`}function _X(e){return e.slice().sort((e,t)=>e.from-t.from||e.to-t.to)}function vX(e,t,n=t){let r=[];return e.forEach((e,i)=>{e.from<=n&&e.to>=t&&r.push(i+1)}),r}function eEe(e,t,n){return e.slice(Math.max(0,t-1),Math.max(0,n))}function yX(e,t,n){if(t<1||t-1+n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(e[t-1+r]!==n[r])return!1;return!0}function bX(e,t){return e.map(e=>{if(!e.quote.length)return e;if(yX(t,e.from,e.quote))return e.moved?{...e,moved:!1}:e;let n=-1;for(let r=1;r+e.quote.length-1<=t.length;r++)t[r-1]===e.quote[0]&&yX(t,r,e.quote)&&(n<0||Math.abs(r-e.from)<Math.abs(n-e.from))&&(n=r);return n<0?e.moved?e:{...e,moved:!0}:{...e,from:n,to:n+e.quote.length-1,moved:!1}})}function xX(e){return e.length>160?`${e.slice(0,159)}…`:e}function tEe(e){return(e.length>4?[...e.slice(0,3).map(xX),`… ${e.length-4} more lines …`,xX(e[e.length-1])]:e.map(xX)).map(e=>e.trim()?`> ${e}`:`>`)}function nEe(e,t){let n=_X(t).filter(e=>e.text.trim());if(!n.length)return null;let r=n.map((t,n)=>[`${n+1}. ${e}:${$Te(t.from,t.to)}${t.moved?` (these lines have changed since — quoted as they read then)`:``}`,...tEe(t.quote),t.text.trim()].join(`
|
|
207
207
|
`));return`Remarks on ${e} (${n.length}):\n\n${r.join(`
|
|
208
208
|
|