ryugi-artifacts 1.120.3 → 1.120.6

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.
Files changed (48) hide show
  1. package/dist/cli.cjs +197 -230
  2. package/dist/document-engine.cjs +1 -1
  3. package/dist/output-bootstrap.cjs +170 -56
  4. package/dist/runtime/ryugi-report.js +3 -3
  5. package/dist/runtime/ryugi-whiteboard-embed.js +1 -1
  6. package/dist/viewer/{DocumentLayout-B16AJ4m1.js → DocumentLayout-BxFYyKFq.js} +2 -2
  7. package/dist/viewer/{DocumentPage-dMWzmQVw.js → DocumentPage-CP8Qy9Ae.js} +2 -2
  8. package/dist/viewer/DocumentPage-l6f5vTWL.css +1 -0
  9. package/dist/viewer/{PreviewLayout-BnV4cPB4.js → PreviewLayout-eg8-py8p.js} +2 -2
  10. package/dist/viewer/{SnapshotDocument-B9mIj1Hu.js → SnapshotDocument-C7mV8NQn.js} +1 -1
  11. package/dist/viewer/{VerifyLayout-8IJyCQab.js → VerifyLayout-DtRz6K2y.js} +1 -1
  12. package/dist/viewer/{VirtualizedEditor-uWe43zaI-St9YpcWe.js → VirtualizedEditor-uWe43zaI-CgOwRELB.js} +1 -1
  13. package/dist/viewer/{VirtualizedRenderer-C_d95FXi-AQRKmbO2.js → VirtualizedRenderer-C_d95FXi-DiZVcTAc.js} +1 -1
  14. package/dist/viewer/{channel-Cuvtl_mH.js → channel-RZcAq9dq.js} +3 -3
  15. package/dist/viewer/{dist-Bk5XPCBt.js → dist-1y-5eBAw.js} +1 -1
  16. package/dist/viewer/{dist-uxyq6tMx.js → dist-3kOakO1C.js} +1 -1
  17. package/dist/viewer/{dist-IPNQW5G8.js → dist-BD6XPyPx.js} +1 -1
  18. package/dist/viewer/{dist-Dps6vTN-.js → dist-BI0qFRAy.js} +1 -1
  19. package/dist/viewer/{dist-BZtYe42f.js → dist-BKkO1Omj.js} +1 -1
  20. package/dist/viewer/{dist-CdLcI1iK.js → dist-BQ22B1dL.js} +1 -1
  21. package/dist/viewer/dist-BjB8i81Z.js +1 -0
  22. package/dist/viewer/{dist-ZiVOhU9h.js → dist-Bo1t4X-Z.js} +1 -1
  23. package/dist/viewer/{dist-CIFQVgHq.js → dist-Ci8SGeFw.js} +1 -1
  24. package/dist/viewer/{dist-BlsFMD-D.js → dist-CskHZfMU.js} +1 -1
  25. package/dist/viewer/{dist-7mb2bGpU.js → dist-CvSBK4r1.js} +1 -1
  26. package/dist/viewer/{dist-D3jbkNxp.js → dist-D0fC7ysz.js} +1 -1
  27. package/dist/viewer/{dist-B7uQYv5D.js → dist-D8T-VMuH.js} +1 -1
  28. package/dist/viewer/{dist-CPlSf_-n.js → dist-DQI2slI5.js} +1 -1
  29. package/dist/viewer/{dist-BQ-mw7EX.js → dist-DW1-cTNS.js} +1 -1
  30. package/dist/viewer/{dist-heibZsuo.js → dist-DknksWkX.js} +1 -1
  31. package/dist/viewer/{dist-J2ZdVVPe.js → dist-Do_0jRES.js} +1 -1
  32. package/dist/viewer/{dist-C1y9SfQg.js → dist-DqZiUlRF.js} +1 -1
  33. package/dist/viewer/{dist-ZG8pOFA0.js → dist-IhKVX0N7.js} +1 -1
  34. package/dist/viewer/{dist-D239Hbe5.js → dist-SwdVvEpO.js} +1 -1
  35. package/dist/viewer/{dist-lr1VXsEc.js → dist-V7e95zqk.js} +1 -1
  36. package/dist/viewer/{dist-48uAq37R.js → dist-f8YElrUw.js} +1 -1
  37. package/dist/viewer/{dist-CVLSwR1I.js → dist-h2T27ekx.js} +1 -1
  38. package/dist/viewer/{dist-yH5e-0q1.js → dist-i1Gf9O6b.js} +1 -1
  39. package/dist/viewer/{editor-B9cVjpUI.js → editor-CLF22MpT.js} +131 -131
  40. package/dist/viewer/index.js +2 -2
  41. package/dist/viewer/{plugin-_bGVeqI0--OtMqC7P.js → plugin-_bGVeqI0-D20LzbhT.js} +2 -2
  42. package/dist/viewer/preview.html +1 -1
  43. package/dist/viewer/preview.js +1 -1
  44. package/dist/viewer/{printDocument-DDB2RpO4.js → printDocument-DmnjWjBu.js} +1 -1
  45. package/dist/viewer/{viewport-CFJHn_Y6-DVNTdoOX.js → viewport-CFJHn_Y6-GTpeksto.js} +1 -1
  46. package/package.json +23 -23
  47. package/dist/viewer/DocumentPage-DGJI3MRN.css +0 -1
  48. package/dist/viewer/dist-D9hP37Je.js +0 -1
@@ -1,5 +1,5 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{C as t,R as n,S as r,c as i,l as a,n as o,o as s,s as c,t as l,u}from"./index.js";import{C as d,E as f,Er as p,T as m,Tr as h,fr as g,g as _,h as v,k as y,m as b,sr as x,w as S,wr as C,y as w}from"./url-BaZreTXB.js";import{i as T,n as E}from"./comments-DUAz1Q9X.js";import{Ha as D,Jr as O,ir as k,ni as A,pa as ee,xr as j,zr as te}from"./WhiteboardEditor-DrHOvXez-Bd1MyHmC.js";import{At as ne,Ct as M,D as re,Dt as ie,E as N,Et as ae,G as oe,J as P,N as se,Ot as ce,P as le,Pt as ue,S as de,St as fe,T as pe,W as me,_ as he,b as ge,d as F,f as _e,ft as ve,g as I,gt as L,h as R,ht as ye,i as be,j as z,k as xe,m as Se,n as Ce,o as we,p as Te,pt as Ee,rt as De,t as Oe,u as ke,w as Ae,wt as je}from"./editor-B9cVjpUI.js";import{t as Me}from"./react-DlmbjZJV.js";import{A as Ne,C as Pe,D as B,N as Fe,S as V,f as H,j as U,s as W,x as G}from"./route-BEA0O_Ry.js";import{t as Ie}from"./WarningsBadge-CyQbVl6h.js";import{n as Le,t as Re}from"./useRefBoard-Cj5dzC4F.js";import{n as ze,t as Be}from"./useMedia-CFebB4XU.js";import{A as Ve,C as He,D as Ue,E as We,O as Ge,S as Ke,T as qe,_ as Je,a as Ye,b as Xe,d as Ze,f as Qe,g as $e,h as et,i as tt,k as nt,l as rt,m as it,n as at,o as ot,p as st,r as ct,t as lt,u as ut,w as dt,x as ft,y as pt}from"./channel-Cuvtl_mH.js";import{t as mt}from"./useTypeFavicon-yXOsFZBx.js";import{n as ht,t as gt}from"./BottomSheet-SYC_8Y6k.js";import{P as _t}from"./Popover-HS6yjzxl.js";import{t as K}from"./jsx-runtime-LKYXHABd.js";import{a as vt,i as yt,t as bt}from"./motion-Cy65kd7X.js";import{n as xt}from"./artifact-list-CuXyveqX.js";import{t as St}from"./dist-D9hP37Je.js";import{t as Ct}from"./chevron-right-DBC0wrKu.js";import{n as wt}from"./read-marks-CVVWpIvf.js";/* empty css */import{t as Tt}from"./DropdownMenu-Dza6-jeN.js";import{t as Et}from"./Segmented-D5ApsVJJ.js";import{t as Dt}from"./arrow-up-right-CHwLq7Lo.js";import{n as Ot}from"./pen-tool-B7HWrrcR.js";import{Dt as kt}from"./MotionConfigContext-BqjwrGj9.js";import{P as At}from"./SelectScrollUpArrow-BFRXZrFq.js";import{t as jt}from"./DocumentExportMenu-DyhweUFo.js";import{t as Mt}from"./selection-BWCQd_Fn.js";import{t as Nt}from"./message-square-BQbestX7.js";import{r as Pt}from"./underline-AY5gu1iN.js";import{a as Ft,i as It,o as Lt}from"./ThreadView-DTGR5uqU.js";import{r as Rt}from"./agentLook-BPPrbQJ3.js";import{r as zt}from"./icons-CCSPm9SD.js";import{n as Bt,r as Vt}from"./useArtifactSocket-CZwBSmOD.js";import{a as Ht}from"./ref-DjRYiP25.js";import"./pages-DWkRbog-.js";import{t as Ut}from"./local-split-host-CeKHc_JX.js";var Wt={name:`panel-right-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]};Wt.node;var Gt=kt(Wt),Kt=`1.85.0`,qt=e=>/^(\d+)\.(\d+)\.(\d+)/.exec(e)?.slice(1).map(Number);function Jt(e){if(e===void 0)return!0;let t=e===null?void 0:qt(e);if(!t)return!1;let n=qt(Kt);for(let e=0;e<3;e++)if(t[e]!==n[e])return t[e]>n[e];return!0}var q=e(Me(),1),Yt=e(Ne(),1),J=K(),Xt=/^approve(-\d+)?$/,Zt=e=>e.choice===null&&e.text===null;function Qt(e){let t=e.filter(e=>e.state===`draft`),n=t.find(e=>Xt.test(e.id)&&Zt(e)&&e.options.some(e=>e.value===`approve`)&&e.options.some(e=>e.value===`revise`));return n&&t.every(e=>e===n||!Zt(e))?n:null}function $t(e,t){return t?e.some(e=>e.state===`draft`)?`draft`:e.some(e=>e.state===`submitted`)?`submitted`:null:null}function en({views:e,canWithdraw:t,listening:n,agent:r,onSubmit:o,onWithdraw:s,onJump:c,onDecide:l}){let{t:d}=Pe(),f=Qt(e);if(f)return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{"data-ask-revise":!0,variant:`quiet`,onClick:()=>l(f.id,`revise`),children:d(`asks.revise`)}),(0,J.jsx)(i,{"data-ask-approve":!0,variant:`primary`,onClick:()=>l(f.id,`approve`),children:d(`asks.approve`)})]});let p=e.filter(e=>e.state===`draft`);if(p.length){let e=p.filter(e=>e.changed).length,t=p.filter(e=>e.choice===null&&e.text===null);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(u,{children:d(`asks.questions`,{count:p.length})}),e>0&&(0,J.jsx)(u,{tone:`changed`,children:d(`asks.changedCount`,{count:e})}),t.length>0&&(0,J.jsxs)(i,{"data-ask-jump":!0,variant:`link`,onClick:()=>c(t[0].id),children:[d(`asks.pendingCount`,{count:t.length}),(0,J.jsx)(_t,{size:12})]}),(0,J.jsx)(a,{}),(0,J.jsx)(i,{"data-ask-submit":!0,variant:`primary`,onClick:o,children:d(`asks.submit`,{agent:r})})]})}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(u,{tone:`muted`,children:n?d(`asks.waiting`,{agent:r}):d(`asks.sayDone`)}),t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(a,{}),(0,J.jsx)(i,{"data-ask-withdraw":!0,variant:`quiet`,onClick:s,children:d(`asks.withdraw`)})]})]})}var tn=e=>e?ne(e.getEditorState().toJSON()):[],nn=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function rn(e){let[t,n]=(0,q.useState)(()=>tn(e));return(0,q.useEffect)(()=>{if(!e)return;let t=()=>n(t=>{let n=tn(e);return nn(t,n)?t:n});return t(),e.registerUpdateListener(t)},[e]),t}function an(e){return e.registerMutationListener(se,t=>{let n=[...t].filter(([,e])=>e===`created`).map(([e])=>e);n.length&&e.update(()=>{let t=new Map;for(let[r,i]of e.getEditorState()._nodeMap)i instanceof se&&!n.includes(r)&&t.set(i.__ask.askId,r);for(let e of n){let n=k(e);n instanceof se&&(t.has(n.__ask.askId)?n.remove():t.set(n.__ask.askId,e))}})})}var on=e=>({op:`create`,blockId:`*`,quote:``,submit:e,text:e?`Submitted the answers`:`Withdrew the submit`});async function sn(e,t,n){await e({op:`create`,blockId:`*`,quote:``,ask:t,choice:n,answer:null,text:n})&&await e(on(!0))}function cn(e){let t=document.querySelector(`[data-ask-tag="${CSS.escape(e)}"]`);t?.scrollIntoView({block:`center`,behavior:`smooth`}),t?.focus({preventScroll:!0})}function ln({editor:e,threads:t,send:n,canAct:r,listening:i,agent:a}){let o=rn(e);(0,q.useEffect)(()=>e&&r?an(e):void 0,[e,r]);let s=(0,q.useMemo)(()=>ie(o,t).filter(e=>e.state!==`orphan`),[o,t]),c=(0,q.useMemo)(()=>{try{return ce(t),!0}catch{return!1}},[t]);return $t(s,r)?(0,J.jsx)(en,{agent:a,canWithdraw:c,listening:i,views:s,onDecide:(e,t)=>void sn(n,e,t),onJump:cn,onSubmit:()=>void n(on(!0)),onWithdraw:()=>void n(on(!1))}):null}var un=`cubic-bezier(0.45, 0, 0.2, 1)`,dn=e=>vt()?`none`:e.map(e=>`${e} 400ms ${un}`).join(`, `);function fn(e){let[t,n]=(0,q.useState)(e);return e&&!t&&n(!0),(0,q.useEffect)(()=>{if(e||!t)return;let r=setTimeout(()=>n(!1),vt()?0:400);return()=>clearTimeout(r)},[e,t]),t}function Y({show:e,gap:t=12,lead:n=0,track:r=!1,children:i,...a}){let o=fn(e),s=(0,q.useRef)(i);e&&(s.current=i);let c=(0,q.useRef)(null),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(0),[f,p]=(0,q.useState)(!1);if((0,q.useLayoutEffect)(()=>{let t=c.current,n=l.current;if(!o||!t||!n)return;if(!e){t.style.width=`${t.getBoundingClientRect().width}px`,t.getBoundingClientRect(),d(0);return}t.getBoundingClientRect();let i=()=>d(n.getBoundingClientRect().width);if(i(),p(!0),r&&typeof ResizeObserver==`function`){let e=new ResizeObserver(i);return e.observe(n),()=>e.disconnect()}let a=setTimeout(()=>d(void 0),vt()?0:400);return()=>clearTimeout(a)},[o,e,r]),(0,q.useLayoutEffect)(()=>{let t=l.current;if(!r||!e||!t)return;let n=t.getBoundingClientRect().width;d(e=>e===n?e:n)},[i,e,r]),!o)return null;let m={display:`inline-flex`,alignItems:`center`,minWidth:0,flexShrink:1,overflow:`hidden`,width:u,opacity:e&&f?1:0,transition:dn([`width`,`opacity`])};return(0,J.jsx)(`span`,{...a,"data-shown":e?``:void 0,ref:c,style:m,children:(0,J.jsx)(`span`,{ref:l,style:{display:`inline-flex`,alignItems:`center`,gap:t,flexShrink:0,paddingInlineStart:n,whiteSpace:`nowrap`,transition:dn([`padding-inline-start`])},children:s.current})})}function pn({value:e,children:t}){let n=(0,q.useRef)({value:e,node:t}),[r,i]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{n.current.value!==e&&i({...n.current,at:Date.now()}),n.current={value:e,node:t}},[e,t]),(0,q.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(null),400);return()=>clearTimeout(e)},[r]),(0,J.jsx)(Y,{show:!0,track:!0,children:(0,J.jsxs)(`span`,{className:`bar-text`,children:[r?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`bar-text-out`,children:r.node},`out-${r.at}`):null,(0,J.jsx)(`span`,{className:r?`bar-text-in`:void 0,children:t},e)]})})}var mn=864e5,hn=e=>String(e).padStart(2,`0`),gn=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function _n(e,t=Date.now()){if(!(e>0))return G.t(`time.notRecorded`);let n=new Date(e*1e3),r=new Date(t),i=Math.round((gn(r)-gn(n))/mn);if(i===0)return G.t(`time.today`);if(i===1)return G.t(`time.yesterday`);let a=n.getFullYear()===r.getFullYear();return new Intl.DateTimeFormat(Fe[G.language],a?{month:`long`,day:`numeric`}:{year:`numeric`,month:`long`,day:`numeric`}).format(n)}function X(e,t=!1){if(!(e>0))return`--:--`;let n=new Date(e*1e3),r=`${hn(n.getHours())}:${hn(n.getMinutes())}`;return t?`${r}:${hn(n.getSeconds())}`:r}function vn(e){return e>0?`${_n(e)} ${X(e)}`:G.t(`time.notRecorded`)}var yn={display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:26,height:26,padding:0,border:0,borderRadius:999,background:`transparent`,color:`inherit`,cursor:`pointer`};function bn({agent:e,total:t,unread:n,position:r,since:o,compacted:s,compact:c=!1,merged:l,done:d,onPrev:f,onNext:m,onCompare:g,onMarkAll:_}){let{t:v}=Pe(),y=c||l,b=c&&l,x=!d&&!s&&n===t,S=s?{value:`compacted`,tone:`muted`,text:v(`sinceRead.compacted`)}:d?{value:`done`,tone:`success`,text:v(`sinceRead.done`,{count:t})}:x?{value:`changed:${y}:${b}:${t}`,tone:`agent`,text:b?String(t):y?v(`sinceRead.changedShort`,{count:t}):v(`sinceRead.changed`,{agent:e,count:t})}:{value:`left:${b}:${n}`,tone:`agent`,text:b?String(n):v(`sinceRead.left`,{count:n})};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(pn,{value:S.value,children:(0,J.jsx)(u,{tone:S.tone,children:d?(0,J.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,J.jsx)(p,{size:15}),S.text]}):S.text})}),(0,J.jsx)(Y,{lead:24,show:x&&!y,children:(0,J.jsx)(u,{tone:`muted`,children:v(`sinceRead.since`,{when:vn(o)})})}),(0,J.jsxs)(Y,{lead:24,show:!d&&!s&&!b,children:[(0,J.jsx)(a,{}),(0,J.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:2,fontVariantNumeric:`tabular-nums`},children:[(0,J.jsx)(`button`,{"data-since-prev":!0,"aria-label":v(`sinceRead.previous`),style:yn,type:`button`,onClick:f,children:(0,J.jsx)(C,{size:15})}),(0,J.jsx)(u,{tone:`muted`,children:`${r} / ${t}`}),(0,J.jsx)(`button`,{"data-since-next":!0,"aria-label":v(`sinceRead.next`),style:yn,type:`button`,onClick:m,children:(0,J.jsx)(h,{size:15})})]})]}),(0,J.jsx)(Y,{lead:16,show:!d&&!s&&b,children:(0,J.jsx)(`button`,{"data-since-next":!0,"aria-label":v(`sinceRead.next`),style:yn,type:`button`,onClick:m,children:(0,J.jsx)(h,{size:15})})}),(0,J.jsxs)(Y,{lead:24,show:!y&&!s,children:[(0,J.jsx)(a,{}),(0,J.jsx)(i,{"data-since-compare":!0,variant:`quiet`,onClick:g,children:v(`sinceRead.compare`)})]}),(0,J.jsx)(Y,{lead:y?12:24,show:!d&&!b,children:(0,J.jsx)(i,{"data-since-mark-all":!0,variant:y?`quiet`:`primary`,style:{transition:[dn([`padding`]),`background-color 300ms`,`color 80ms`].join(`, `)},onClick:_,children:v(`sinceRead.markAll`)})})]})}var Z={text:{kMv6JI:`xqfszdh`,kGuDYH:`x4z9k3i`,kLWn49:`x1dbl2gt`,kMwMTN:`xo2rkog`,$$css:!0},buttonBase:{kMv6JI:`xjb2p0i`,kLWn49:`x15bjb6t`,kMwMTN:`x1heor9g`,kkrTdU:`x1ypdohk`,kPJHz1:`x784prv`,k7shQP:`x9v5kkp`,kZs9gx:`x1vavhu1`,kiEn40:`x7s97pk`,kWCcOm:`x2wzlov`,kYPGJ8:`xtgyt42`,$$css:!0},icon:{k1xSpc:`xrvj5dj`,kgQiWS:`x1ku5rj1`,kUk6DE:`x1okw0bk`,kzqmXN:`x23j0i4`,kZKoxP:`xd7y6wv`,kmVPX3:`x1717udv`,kMzoRj:`xc342km`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w`,kMwMTN:`x1bo0w0s`,kGzVvX:`xj0l527`,kDPRdz:`xytdrwj`,$$css:!0},stripIcon:{koRygp:`xzy26m8`,kya2p2:`x1fkvin3`,$$css:!0},filter:{kMzoRj:`xmkeg23`,ksu8eU:`x1y0btm7`,kVAM5u:`x12xov25`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w`,k8WAf4:`xj8oexa`,kg3NbH:`xdqyycr`,kGuDYH:`x1j6dyjg`,khDVqt:`xuxw1ft`,$$css:!0},filterOn:{kWkggS:`xahzvm9`,kVAM5u:`xgcsv5v`,$$css:!0},count:{k7Eaqz:`x1aasl1c`,k9WMMc:`x1hr2gdg`,kMwMTN:`x1bo0w0s`,kGuDYH:`x1j6dyjg`,kcqcaj:`xss6m8b`,$$css:!0},update:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x167g77z`,k1K539:`xod5an3`,k8WAf4:`x1vvogim`,kg3NbH:`x1awh872`,kaIpWk:`x1kogg8i`,kWkggS:`xlssvyo`,kMwMTN:`x19ay2w6`,kGuDYH:`xfifm61`,$$css:!0},updateCompact:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x167g77z`,kqGvvJ:`x1jp4ehj`,k8WAf4:`x1vvogim`,kg3NbH:`x1awh872`,kaIpWk:`x1kogg8i`,kWkggS:`xlssvyo`,kMwMTN:`x19ay2w6`,kGuDYH:`xfifm61`,$$css:!0},updateText:{kUk6DE:`x98rzlu`,k7Eaqz:`xeuugli`,$$css:!0},updateButton:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1jnr06f`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,kmVPX3:`x1717udv`,kGuDYH:`x1qlqyl8`,k63SB2:`x1s688f`,khDVqt:`xuxw1ft`,kMwMTN:`x1heor9g`,$$css:!0},timeline:{kB88ic:`xe8uvvx`,keoZOQ:`x1gslohp`,k1K539:`xat24cr`,kmVPX3:`x1717udv`,$$css:!0},node:{kVAEAm:`x1n2onr6`,kEoFBp:`x1hmns74`,k75S9Q:`x5s50al`,kOlAkY:`x1vgi0k`,kgeoSG:`x1cpjm7i`,kLkRvE:`x1e5ukxm`,k96MEf:`x1y3wzot`,kgzTxl:`xdytif7`,kwXMNM:`x1j6awrg`,kH8cDV:`x105yrkx`,kkgrvl:`xv6d0c5`,k5JduY:`x1s928wv`,ks3ayO:`x1l9ipfb`,k3foIR:`xpptxpr`,k8Iv0R:`x1xrz1ek`,kyPpv6:`x1pyjh0w`,kvGrFk:`x12d1tmf`,k8OcCd:`x1oo1iut`,kMaslv:`xsrs1j1`,kemPvI:`x1tpg6y4`,k5pIzQ:`x1xg71k9`,$$css:!0},day:{kZKoxP:`x90ne7k`,kB7OPa:`x9f619`,kLKAdn:`xz9dl7a`,kZCmMZ:`x110972j`,kwRFfy:`xyri2b`,kGuDYH:`x1j6dyjg`,k63SB2:`x1s688f`,kMwMTN:`x1bo0w0s`,$$css:!0},row:{kVAEAm:`x1n2onr6`,$$css:!0},dot:{kVAEAm:`x10l6tqk`,kY2c9j:`x1vjfegm`,kbCHJM:`xbpoxm1`,k87sOh:`xjqd8mg`,kzqmXN:`x1xc55vz`,kZKoxP:`xdk7pt`,kB7OPa:`x9f619`,kaIpWk:`x16rqkct`,k3aq6I:`x11lhmoz`,kMzoRj:`xvndefy`,ksu8eU:`x1y0btm7`,kVAM5u:`xct3ywq`,kWkggS:`x1rozbrz`,kaxkhh:`xp7vd6g`,kBzXvT:`x1linyqi`,kdowMK:`x6wuh8v`,kP5Q0z:`x8e4dz`,kPAhU7:`x1355wyl`,kUDdqw:`x1nzxh0e`,kyEoYf:`xw49lei`,kr7ELp:`xzqh9vb`,kc8fFq:`x1nvy8h2`,k40vjo:`xwqtvyl`,k6RPIA:`xlsu8l`,kZDKfJ:`x1k3t2iv`,kGh7v6:`xtkdjl9`,$$css:!0},select:{k1xSpc:`x1lliihq`,kzqmXN:`xh8yej3`,kB7OPa:`x9f619`,k9WMMc:`xdpxx8g`,kMzoRj:`xc342km`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w`,k8WAf4:`x1vvogim`,kZCmMZ:`x110972j`,kwRFfy:`xp48ta0`,kGzVvX:`x9jwiqo`,kZDKfJ:`xd00ecs`,$$css:!0},line:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x167g77z`,k7Eaqz:`xeuugli`,$$css:!0},lineStrong:{kGuDYH:`xfifm61`,k63SB2:`x1s688f`,kcqcaj:`xss6m8b`,$$css:!0},lineText:{kMwMTN:`x1bo0w0s`,khDVqt:`xuxw1ft`,kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,$$css:!0},tag:{kUk6DE:`x1okw0bk`,kGuDYH:`x1k6wstc`,kLWn49:`x1d3mw78`,kg3NbH:`xm9j1uf`,kMzoRj:`xmkeg23`,ksu8eU:`x1y0btm7`,kVAM5u:`xgcsv5v`,kaIpWk:`x12oqio5`,kMwMTN:`x1bo0w0s`,$$css:!0},tagStart:{kVAM5u:`x9r1u3d`,kWkggS:`xjbqb8w`,kMwMTN:`xo2rkog`,$$css:!0},meta:{k1xSpc:`x1lliihq`,keoZOQ:`xr9ek0c`,kGuDYH:`x1j6dyjg`,kMwMTN:`x1bo0w0s`,kcqcaj:`xss6m8b`,$$css:!0},changed:{kMwMTN:`xo2rkog`,$$css:!0},expand:{kVAEAm:`x10l6tqk`,kCIrl2:`xclnmbr`,k87sOh:`x1nl0pjx`,kzqmXN:`xgd8bvy`,kZKoxP:`x1fgtraw`,$$css:!0},expandIcon:{k1ekBW:`x11xpdln`,kIyJzY:`xgdialr`,$$css:!0},expandIconOpen:{k3aq6I:`x1iffjtl`,$$css:!0},raw:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kLKAdn:`x1nn3v0j`,kGO01o:`xwib8y2`,kZCmMZ:`x110972j`,kwRFfy:`x1icxu4v`,$$css:!0},rawButton:{k1xSpc:`x78zum5`,kGNEyG:`x1pha0wt`,kOIVth:`x883omv`,kzqmXN:`xh8yej3`,kB7OPa:`x9f619`,k9WMMc:`xdpxx8g`,kMzoRj:`xc342km`,kaIpWk:`x12oqio5`,kWkggS:`xjbqb8w`,k8WAf4:`x12ulsxz`,kg3NbH:`x1xijbu4`,kGuDYH:`x1j6dyjg`,kGzVvX:`xj0l527`,k1dPUN:`x1mhs912`,$$css:!0},rawTime:{kUk6DE:`x1okw0bk`,kMwMTN:`x1bo0w0s`,kcqcaj:`xss6m8b`,$$css:!0},rawCode:{k7Eaqz:`xeuugli`,kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,kGuDYH:`x1k6wstc`,kMwMTN:`x1bo0w0s`,$$css:!0},more:{k1xSpc:`x1lliihq`,kzqmXN:`xh8yej3`,kqGvvJ:`x1twdi5u`,kmVPX3:`xe8ttls`,kMzoRj:`xmkeg23`,ksu8eU:`x1y0btm7`,kVAM5u:`x12xov25`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w`,kGuDYH:`xfifm61`,$$css:!0},end:{keoZOQ:`xhrpt6u`,k1K539:`xat24cr`,kLKAdn:`xz9dl7a`,kEafiO:`x178xt8z`,kPef9Z:`x13fuv20`,kLZC3w:`xxu5053`,kGuDYH:`x1j6dyjg`,kLWn49:`xa7kkou`,kMwMTN:`x1bo0w0s`,$$css:!0},strip:{kVAEAm:`x7wzq59`,k87sOh:`x13vifvy`,kY2c9j:`x1u8a7rm`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1jnr06f`,keoZOQ:`xf4ichi`,k1K539:`x1e56ztr`,kLKAdn:`x1aq4ukf`,kGO01o:`x10b6aqq`,kWkggS:`x1rozbrz`,kGVxlE:`xg7c00`,kz4h6p:`x1drl50h`,kGuDYH:`xfifm61`,$$css:!0},bar:{k87sOh:`x5v0ndm`,kY2c9j:`xk3oba8`,kB7OPa:`x9f619`,kZKoxP:`xrtz9ly`,keoZOQ:`xdj266r`,k1K539:`xat24cr`,kLKAdn:`xexx8yu`,kGO01o:`x18d9i69`,kg3NbH:`x4l9tsp`,kGVxlE:`x1gnnqk1`,kz4h6p:`x1gj8qfm`,kt9PQ7:`xso031l`,kfdmCh:`x1q0q8m5`,kL6WhQ:`xtrfj0v`,$$css:!0},pickRow:{kXwgrk:`x1q0g3np`,kGNEyG:`x1pha0wt`,kOIVth:`x167g77z`,$$css:!0},pick:{k1xSpc:`x78zum5`,kUk6DE:`x98rzlu`,k7Eaqz:`xeuugli`,kXwgrk:`xdt5ytf`,kGNEyG:`x1cy8zhl`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,k8WAf4:`xj8oexa`,kg3NbH:`xnjsko4`,k9WMMc:`xdpxx8g`,$$css:!0},pickSpan:{kGuDYH:`x1j6dyjg`,kMwMTN:`x1bo0w0s`,$$css:!0},pickStrong:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1jnr06f`,ks0D6T:`x193iq5w`,k63SB2:`x1s688f`,khDVqt:`xuxw1ft`,kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,kcqcaj:`xss6m8b`,$$css:!0},sheet:{kVAEAm:`xixxii4`,k87sOh:`x13vifvy`,kCIrl2:`x3m8u43`,krVfgx:`x1ey2m1c`,kbCHJM:`xu96u03`,kY2c9j:`x68pp3s`,$$css:!0},sheetHead:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`x1qughib`,kLKAdn:`x1yrsyyn`,kGO01o:`xwib8y2`,kZCmMZ:`x106a9eq`,kwRFfy:`xf159sx`,$$css:!0},sheetHeadText:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,$$css:!0},sheetTitle:{kGuDYH:`x1jvydc1`,k63SB2:`x1s688f`,$$css:!0},sheetSmall:{kGuDYH:`xfifm61`,kMwMTN:`x1bo0w0s`,$$css:!0},sheetButton:{kAzted:`x1gg8mnh`,kg3NbH:`xaope02`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,kGuDYH:`xif65rj`,$$css:!0},sheetBody:{kLKAdn:`xexx8yu`,kGO01o:`xwxc41k`,kg3NbH:`xaope02`,$$css:!0},sheetSelect:{kAzted:`xbktkl8`,$$css:!0}},xn={human:`history.sourceHuman`,agent:`history.sourceAgent`,session:`history.sourceSession`,unknown:`history.sourceUnknown`};function Sn(e){let{session:t,selected:n}=e;return t&&n?t.history.groups.find(e=>e.entries.includes(n)):void 0}function Cn(e){return e.session?.history.entries.at(-1)?.change.timestamp??0}function wn({model:e,strip:t}){let{count:n,changeIndex:r,loading:i}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{"aria-live":`polite`,role:`status`,...U(Z.count),children:[n?r+1:0,` / `,n]}),(0,J.jsx)(`button`,{"aria-label":V(`history.previousChange`),disabled:r===0||i,type:`button`,...U(Z.buttonBase,Z.icon,t&&Z.stripIcon),onClick:()=>e.navigate(-1),children:(0,J.jsx)(C,{"aria-hidden":`true`,size:14})}),(0,J.jsx)(`button`,{"aria-label":V(`history.nextChange`),disabled:r>=n-1||i,type:`button`,...U(Z.buttonBase,Z.icon,t&&Z.stripIcon),onClick:()=>e.navigate(1),children:(0,J.jsx)(h,{"aria-hidden":`true`,size:14})})]})}function Tn({model:e}){return(0,J.jsx)(`button`,{"aria-pressed":e.onlyChanges,type:`button`,...U(Z.buttonBase,Z.filter,e.onlyChanges&&Z.filterOn),onClick:e.toggleOnly,children:V(`history.onlyChanges`)})}function En({compact:e,model:t}){return t.pending?(0,J.jsxs)(`div`,{role:`status`,...U(e?Z.updateCompact:Z.update),children:[(0,J.jsx)(`span`,{...U(Z.updateText),children:t.streaming?V(`history.waitingEdits`):V(`history.newContent`,{time:X(Cn(t))})}),(0,J.jsxs)(`button`,{disabled:t.streaming||t.loading,type:`button`,...U(Z.buttonBase,Z.updateButton),onClick:t.refresh,children:[(0,J.jsx)(n,{"aria-hidden":`true`,size:12}),V(`history.refresh`)]})]}):null}function Dn({model:e,sheet:t}){let[n,r]=(0,q.useState)(50),[i,a]=(0,q.useState)(()=>new Set),{session:o,selected:s,blocks:c}=e;if(!o)return null;let{groups:l,entries:u,shallow:d}=o.history,f=l.findIndex(e=>s!==null&&e.entries.includes(s)),p=new Map;for(let e of c)e.group&&p.set(e.group,(p.get(e.group)??0)+1);let m=l.slice(0,n),h=e=>_n(e.entries.at(-1).change.timestamp),g=e=>a(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`ol`,{"aria-label":V(`history.timeline`),...U(Z.timeline),children:m.map((n,r)=>{let a=n.entries.at(-1),o=h(n),c=r===0||o!==h(m[r-1]),l=r===f?`selected`:r===0?`latest`:r<f?`range`:`outside`,u=i.has(n.id),d=r<f?p.get(n):void 0;return(0,J.jsxs)(`li`,{"data-day":c?``:void 0,"data-lower":r<f?`in`:`out`,"data-state":l,"data-upper":r<=f?`in`:`out`,...U(Z.node),children:[c?(0,J.jsx)(`div`,{...U(Z.day),children:o}):null,(0,J.jsxs)(`div`,{...U(Z.row),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,"data-state":l,...U(Z.dot)}),(0,J.jsxs)(`button`,{"aria-current":l===`selected`?`true`:void 0,"data-state":l,type:`button`,...U(Z.buttonBase,Z.select,t&&Z.sheetSelect),onClick:()=>e.select(a),children:[(0,J.jsxs)(`span`,{...U(Z.line),children:[(0,J.jsx)(`strong`,{...U(Z.lineStrong),children:X(a.change.timestamp)}),(0,J.jsx)(`span`,{...U(Z.lineText),children:n.author??V(xn[n.source])}),l===`latest`?(0,J.jsx)(`span`,{...U(Z.tag),children:V(`history.latest`)}):null,l===`selected`?(0,J.jsx)(`span`,{...U(Z.tag,Z.tagStart),children:V(`history.start`)}):null]}),(0,J.jsxs)(`span`,{...U(Z.meta),children:[V(`history.commits`,{count:n.entries.length}),d?(0,J.jsx)(`span`,{...U(Z.changed),children:V(`history.changedSuffix`,{count:d})}):null]})]}),(0,J.jsx)(`button`,{"aria-expanded":u,"aria-label":V(u?`history.collapseCommits`:`history.expandCommits`),type:`button`,...U(Z.buttonBase,Z.icon,Z.expand),onClick:()=>g(n.id),children:(0,J.jsx)(Ct,{"aria-hidden":`true`,size:14,...U(Z.expandIcon,u&&Z.expandIconOpen)})})]}),u?(0,J.jsx)(`div`,{...U(Z.raw),children:[...n.entries].reverse().map(t=>(0,J.jsxs)(`button`,{"aria-current":t===s?`true`:void 0,title:t.change.message?.split(`
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{C as t,R as n,S as r,c as i,l as a,n as o,o as s,s as c,t as l,u}from"./index.js";import{C as d,E as f,Er as p,T as m,Tr as h,fr as g,g as _,h as v,k as y,m as b,sr as x,w as S,wr as C,y as w}from"./url-BaZreTXB.js";import{i as T,n as E}from"./comments-DUAz1Q9X.js";import{Ha as D,Jr as O,ir as k,ni as A,pa as ee,xr as j,zr as te}from"./WhiteboardEditor-DrHOvXez-Bd1MyHmC.js";import{At as ne,Ct as M,D as re,Dt as ie,E as N,Et as ae,G as oe,J as P,N as se,Ot as ce,P as le,Pt as ue,S as de,St as fe,T as pe,W as me,_ as he,b as ge,d as F,f as _e,ft as ve,g as I,gt as L,h as R,ht as ye,i as be,j as z,k as xe,m as Se,n as Ce,o as we,p as Te,pt as Ee,rt as De,t as Oe,u as ke,w as Ae,wt as je}from"./editor-CLF22MpT.js";import{t as Me}from"./react-DlmbjZJV.js";import{A as Ne,C as Pe,D as B,N as Fe,S as V,f as H,j as U,s as W,x as G}from"./route-BEA0O_Ry.js";import{t as Ie}from"./WarningsBadge-CyQbVl6h.js";import{n as Le,t as Re}from"./useRefBoard-Cj5dzC4F.js";import{n as ze,t as Be}from"./useMedia-CFebB4XU.js";import{A as Ve,C as He,D as Ue,E as We,O as Ge,S as Ke,T as qe,_ as Je,a as Ye,b as Xe,d as Ze,f as Qe,g as $e,h as et,i as tt,k as nt,l as rt,m as it,n as at,o as ot,p as st,r as ct,t as lt,u as ut,w as dt,x as ft,y as pt}from"./channel-RZcAq9dq.js";import{t as mt}from"./useTypeFavicon-yXOsFZBx.js";import{n as ht,t as gt}from"./BottomSheet-SYC_8Y6k.js";import{P as _t}from"./Popover-HS6yjzxl.js";import{t as K}from"./jsx-runtime-LKYXHABd.js";import{a as vt,i as yt,t as bt}from"./motion-Cy65kd7X.js";import{n as xt}from"./artifact-list-CuXyveqX.js";import{t as St}from"./dist-BjB8i81Z.js";import{t as Ct}from"./chevron-right-DBC0wrKu.js";import{n as wt}from"./read-marks-CVVWpIvf.js";/* empty css */import{t as Tt}from"./DropdownMenu-Dza6-jeN.js";import{t as Et}from"./Segmented-D5ApsVJJ.js";import{t as Dt}from"./arrow-up-right-CHwLq7Lo.js";import{n as Ot}from"./pen-tool-B7HWrrcR.js";import{Dt as kt}from"./MotionConfigContext-BqjwrGj9.js";import{P as At}from"./SelectScrollUpArrow-BFRXZrFq.js";import{t as jt}from"./DocumentExportMenu-DyhweUFo.js";import{t as Mt}from"./selection-BWCQd_Fn.js";import{t as Nt}from"./message-square-BQbestX7.js";import{r as Pt}from"./underline-AY5gu1iN.js";import{a as Ft,i as It,o as Lt}from"./ThreadView-DTGR5uqU.js";import{r as Rt}from"./agentLook-BPPrbQJ3.js";import{r as zt}from"./icons-CCSPm9SD.js";import{n as Bt,r as Vt}from"./useArtifactSocket-CZwBSmOD.js";import{a as Ht}from"./ref-DjRYiP25.js";import"./pages-DWkRbog-.js";import{t as Ut}from"./local-split-host-CeKHc_JX.js";var Wt={name:`panel-right-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]};Wt.node;var Gt=kt(Wt),Kt=`1.85.0`,qt=e=>/^(\d+)\.(\d+)\.(\d+)/.exec(e)?.slice(1).map(Number);function Jt(e){if(e===void 0)return!0;let t=e===null?void 0:qt(e);if(!t)return!1;let n=qt(Kt);for(let e=0;e<3;e++)if(t[e]!==n[e])return t[e]>n[e];return!0}var q=e(Me(),1),Yt=e(Ne(),1),J=K(),Xt=/^approve(-\d+)?$/,Zt=e=>e.choice===null&&e.text===null;function Qt(e){let t=e.filter(e=>e.state===`draft`),n=t.find(e=>Xt.test(e.id)&&Zt(e)&&e.options.some(e=>e.value===`approve`)&&e.options.some(e=>e.value===`revise`));return n&&t.every(e=>e===n||!Zt(e))?n:null}function $t(e,t){return t?e.some(e=>e.state===`draft`)?`draft`:e.some(e=>e.state===`submitted`)?`submitted`:null:null}function en({views:e,canWithdraw:t,listening:n,agent:r,onSubmit:o,onWithdraw:s,onJump:c,onDecide:l}){let{t:d}=Pe(),f=Qt(e);if(f)return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{"data-ask-revise":!0,variant:`quiet`,onClick:()=>l(f.id,`revise`),children:d(`asks.revise`)}),(0,J.jsx)(i,{"data-ask-approve":!0,variant:`primary`,onClick:()=>l(f.id,`approve`),children:d(`asks.approve`)})]});let p=e.filter(e=>e.state===`draft`);if(p.length){let e=p.filter(e=>e.changed).length,t=p.filter(e=>e.choice===null&&e.text===null);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(u,{children:d(`asks.questions`,{count:p.length})}),e>0&&(0,J.jsx)(u,{tone:`changed`,children:d(`asks.changedCount`,{count:e})}),t.length>0&&(0,J.jsxs)(i,{"data-ask-jump":!0,variant:`link`,onClick:()=>c(t[0].id),children:[d(`asks.pendingCount`,{count:t.length}),(0,J.jsx)(_t,{size:12})]}),(0,J.jsx)(a,{}),(0,J.jsx)(i,{"data-ask-submit":!0,variant:`primary`,onClick:o,children:d(`asks.submit`,{agent:r})})]})}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(u,{tone:`muted`,children:n?d(`asks.waiting`,{agent:r}):d(`asks.sayDone`)}),t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(a,{}),(0,J.jsx)(i,{"data-ask-withdraw":!0,variant:`quiet`,onClick:s,children:d(`asks.withdraw`)})]})]})}var tn=e=>e?ne(e.getEditorState().toJSON()):[],nn=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function rn(e){let[t,n]=(0,q.useState)(()=>tn(e));return(0,q.useEffect)(()=>{if(!e)return;let t=()=>n(t=>{let n=tn(e);return nn(t,n)?t:n});return t(),e.registerUpdateListener(t)},[e]),t}function an(e){return e.registerMutationListener(se,t=>{let n=[...t].filter(([,e])=>e===`created`).map(([e])=>e);n.length&&e.update(()=>{let t=new Map;for(let[r,i]of e.getEditorState()._nodeMap)i instanceof se&&!n.includes(r)&&t.set(i.__ask.askId,r);for(let e of n){let n=k(e);n instanceof se&&(t.has(n.__ask.askId)?n.remove():t.set(n.__ask.askId,e))}})})}var on=e=>({op:`create`,blockId:`*`,quote:``,submit:e,text:e?`Submitted the answers`:`Withdrew the submit`});async function sn(e,t,n){await e({op:`create`,blockId:`*`,quote:``,ask:t,choice:n,answer:null,text:n})&&await e(on(!0))}function cn(e){let t=document.querySelector(`[data-ask-tag="${CSS.escape(e)}"]`);t?.scrollIntoView({block:`center`,behavior:`smooth`}),t?.focus({preventScroll:!0})}function ln({editor:e,threads:t,send:n,canAct:r,listening:i,agent:a}){let o=rn(e);(0,q.useEffect)(()=>e&&r?an(e):void 0,[e,r]);let s=(0,q.useMemo)(()=>ie(o,t).filter(e=>e.state!==`orphan`),[o,t]),c=(0,q.useMemo)(()=>{try{return ce(t),!0}catch{return!1}},[t]);return $t(s,r)?(0,J.jsx)(en,{agent:a,canWithdraw:c,listening:i,views:s,onDecide:(e,t)=>void sn(n,e,t),onJump:cn,onSubmit:()=>void n(on(!0)),onWithdraw:()=>void n(on(!1))}):null}var un=`cubic-bezier(0.45, 0, 0.2, 1)`,dn=e=>vt()?`none`:e.map(e=>`${e} 400ms ${un}`).join(`, `);function fn(e){let[t,n]=(0,q.useState)(e);return e&&!t&&n(!0),(0,q.useEffect)(()=>{if(e||!t)return;let r=setTimeout(()=>n(!1),vt()?0:400);return()=>clearTimeout(r)},[e,t]),t}function Y({show:e,gap:t=12,lead:n=0,track:r=!1,children:i,...a}){let o=fn(e),s=(0,q.useRef)(i);e&&(s.current=i);let c=(0,q.useRef)(null),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(0),[f,p]=(0,q.useState)(!1);if((0,q.useLayoutEffect)(()=>{let t=c.current,n=l.current;if(!o||!t||!n)return;if(!e){t.style.width=`${t.getBoundingClientRect().width}px`,t.getBoundingClientRect(),d(0);return}t.getBoundingClientRect();let i=()=>d(n.getBoundingClientRect().width);if(i(),p(!0),r&&typeof ResizeObserver==`function`){let e=new ResizeObserver(i);return e.observe(n),()=>e.disconnect()}let a=setTimeout(()=>d(void 0),vt()?0:400);return()=>clearTimeout(a)},[o,e,r]),(0,q.useLayoutEffect)(()=>{let t=l.current;if(!r||!e||!t)return;let n=t.getBoundingClientRect().width;d(e=>e===n?e:n)},[i,e,r]),!o)return null;let m={display:`inline-flex`,alignItems:`center`,minWidth:0,flexShrink:1,overflow:`hidden`,width:u,opacity:e&&f?1:0,transition:dn([`width`,`opacity`])};return(0,J.jsx)(`span`,{...a,"data-shown":e?``:void 0,ref:c,style:m,children:(0,J.jsx)(`span`,{ref:l,style:{display:`inline-flex`,alignItems:`center`,gap:t,flexShrink:0,paddingInlineStart:n,whiteSpace:`nowrap`,transition:dn([`padding-inline-start`])},children:s.current})})}function pn({value:e,children:t}){let n=(0,q.useRef)({value:e,node:t}),[r,i]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{n.current.value!==e&&i({...n.current,at:Date.now()}),n.current={value:e,node:t}},[e,t]),(0,q.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(null),400);return()=>clearTimeout(e)},[r]),(0,J.jsx)(Y,{show:!0,track:!0,children:(0,J.jsxs)(`span`,{className:`bar-text`,children:[r?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`bar-text-out`,children:r.node},`out-${r.at}`):null,(0,J.jsx)(`span`,{className:r?`bar-text-in`:void 0,children:t},e)]})})}var mn=864e5,hn=e=>String(e).padStart(2,`0`),gn=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime();function _n(e,t=Date.now()){if(!(e>0))return G.t(`time.notRecorded`);let n=new Date(e*1e3),r=new Date(t),i=Math.round((gn(r)-gn(n))/mn);if(i===0)return G.t(`time.today`);if(i===1)return G.t(`time.yesterday`);let a=n.getFullYear()===r.getFullYear();return new Intl.DateTimeFormat(Fe[G.language],a?{month:`long`,day:`numeric`}:{year:`numeric`,month:`long`,day:`numeric`}).format(n)}function X(e,t=!1){if(!(e>0))return`--:--`;let n=new Date(e*1e3),r=`${hn(n.getHours())}:${hn(n.getMinutes())}`;return t?`${r}:${hn(n.getSeconds())}`:r}function vn(e){return e>0?`${_n(e)} ${X(e)}`:G.t(`time.notRecorded`)}var yn={display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:26,height:26,padding:0,border:0,borderRadius:999,background:`transparent`,color:`inherit`,cursor:`pointer`};function bn({agent:e,total:t,unread:n,position:r,since:o,compacted:s,compact:c=!1,merged:l,done:d,onPrev:f,onNext:m,onCompare:g,onMarkAll:_}){let{t:v}=Pe(),y=c||l,b=c&&l,x=!d&&!s&&n===t,S=s?{value:`compacted`,tone:`muted`,text:v(`sinceRead.compacted`)}:d?{value:`done`,tone:`success`,text:v(`sinceRead.done`,{count:t})}:x?{value:`changed:${y}:${b}:${t}`,tone:`agent`,text:b?String(t):y?v(`sinceRead.changedShort`,{count:t}):v(`sinceRead.changed`,{agent:e,count:t})}:{value:`left:${b}:${n}`,tone:`agent`,text:b?String(n):v(`sinceRead.left`,{count:n})};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(pn,{value:S.value,children:(0,J.jsx)(u,{tone:S.tone,children:d?(0,J.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,J.jsx)(p,{size:15}),S.text]}):S.text})}),(0,J.jsx)(Y,{lead:24,show:x&&!y,children:(0,J.jsx)(u,{tone:`muted`,children:v(`sinceRead.since`,{when:vn(o)})})}),(0,J.jsxs)(Y,{lead:24,show:!d&&!s&&!b,children:[(0,J.jsx)(a,{}),(0,J.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`,gap:2,fontVariantNumeric:`tabular-nums`},children:[(0,J.jsx)(`button`,{"data-since-prev":!0,"aria-label":v(`sinceRead.previous`),style:yn,type:`button`,onClick:f,children:(0,J.jsx)(C,{size:15})}),(0,J.jsx)(u,{tone:`muted`,children:`${r} / ${t}`}),(0,J.jsx)(`button`,{"data-since-next":!0,"aria-label":v(`sinceRead.next`),style:yn,type:`button`,onClick:m,children:(0,J.jsx)(h,{size:15})})]})]}),(0,J.jsx)(Y,{lead:16,show:!d&&!s&&b,children:(0,J.jsx)(`button`,{"data-since-next":!0,"aria-label":v(`sinceRead.next`),style:yn,type:`button`,onClick:m,children:(0,J.jsx)(h,{size:15})})}),(0,J.jsxs)(Y,{lead:24,show:!y&&!s,children:[(0,J.jsx)(a,{}),(0,J.jsx)(i,{"data-since-compare":!0,variant:`quiet`,onClick:g,children:v(`sinceRead.compare`)})]}),(0,J.jsx)(Y,{lead:y?12:24,show:!d&&!b,children:(0,J.jsx)(i,{"data-since-mark-all":!0,variant:y?`quiet`:`primary`,style:{transition:[dn([`padding`]),`background-color 300ms`,`color 80ms`].join(`, `)},onClick:_,children:v(`sinceRead.markAll`)})})]})}var Z={text:{kMv6JI:`xqfszdh`,kGuDYH:`x4z9k3i`,kLWn49:`x1dbl2gt`,kMwMTN:`xo2rkog`,$$css:!0},buttonBase:{kMv6JI:`xjb2p0i`,kLWn49:`x15bjb6t`,kMwMTN:`x1heor9g`,kkrTdU:`x1ypdohk`,kPJHz1:`x784prv`,k7shQP:`x9v5kkp`,kZs9gx:`x1vavhu1`,kiEn40:`x7s97pk`,kWCcOm:`x2wzlov`,kYPGJ8:`xtgyt42`,$$css:!0},icon:{k1xSpc:`xrvj5dj`,kgQiWS:`x1ku5rj1`,kUk6DE:`x1okw0bk`,kzqmXN:`x23j0i4`,kZKoxP:`xd7y6wv`,kmVPX3:`x1717udv`,kMzoRj:`xc342km`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w`,kMwMTN:`x1bo0w0s`,kGzVvX:`xj0l527`,kDPRdz:`xytdrwj`,$$css:!0},stripIcon:{koRygp:`xzy26m8`,kya2p2:`x1fkvin3`,$$css:!0},filter:{kMzoRj:`xmkeg23`,ksu8eU:`x1y0btm7`,kVAM5u:`x12xov25`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w`,k8WAf4:`xj8oexa`,kg3NbH:`xdqyycr`,kGuDYH:`x1j6dyjg`,khDVqt:`xuxw1ft`,$$css:!0},filterOn:{kWkggS:`xahzvm9`,kVAM5u:`xgcsv5v`,$$css:!0},count:{k7Eaqz:`x1aasl1c`,k9WMMc:`x1hr2gdg`,kMwMTN:`x1bo0w0s`,kGuDYH:`x1j6dyjg`,kcqcaj:`xss6m8b`,$$css:!0},update:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x167g77z`,k1K539:`xod5an3`,k8WAf4:`x1vvogim`,kg3NbH:`x1awh872`,kaIpWk:`x1kogg8i`,kWkggS:`xlssvyo`,kMwMTN:`x19ay2w6`,kGuDYH:`xfifm61`,$$css:!0},updateCompact:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x167g77z`,kqGvvJ:`x1jp4ehj`,k8WAf4:`x1vvogim`,kg3NbH:`x1awh872`,kaIpWk:`x1kogg8i`,kWkggS:`xlssvyo`,kMwMTN:`x19ay2w6`,kGuDYH:`xfifm61`,$$css:!0},updateText:{kUk6DE:`x98rzlu`,k7Eaqz:`xeuugli`,$$css:!0},updateButton:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1jnr06f`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,kmVPX3:`x1717udv`,kGuDYH:`x1qlqyl8`,k63SB2:`x1s688f`,khDVqt:`xuxw1ft`,kMwMTN:`x1heor9g`,$$css:!0},timeline:{kB88ic:`xe8uvvx`,keoZOQ:`x1gslohp`,k1K539:`xat24cr`,kmVPX3:`x1717udv`,$$css:!0},node:{kVAEAm:`x1n2onr6`,kEoFBp:`x1hmns74`,k75S9Q:`x5s50al`,kOlAkY:`x1vgi0k`,kgeoSG:`x1cpjm7i`,kLkRvE:`x1e5ukxm`,k96MEf:`x1y3wzot`,kgzTxl:`xdytif7`,kwXMNM:`x1j6awrg`,kH8cDV:`x105yrkx`,kkgrvl:`xv6d0c5`,k5JduY:`x1s928wv`,ks3ayO:`x1l9ipfb`,k3foIR:`xpptxpr`,k8Iv0R:`x1xrz1ek`,kyPpv6:`x1pyjh0w`,kvGrFk:`x12d1tmf`,k8OcCd:`x1oo1iut`,kMaslv:`xsrs1j1`,kemPvI:`x1tpg6y4`,k5pIzQ:`x1xg71k9`,$$css:!0},day:{kZKoxP:`x90ne7k`,kB7OPa:`x9f619`,kLKAdn:`xz9dl7a`,kZCmMZ:`x110972j`,kwRFfy:`xyri2b`,kGuDYH:`x1j6dyjg`,k63SB2:`x1s688f`,kMwMTN:`x1bo0w0s`,$$css:!0},row:{kVAEAm:`x1n2onr6`,$$css:!0},dot:{kVAEAm:`x10l6tqk`,kY2c9j:`x1vjfegm`,kbCHJM:`xbpoxm1`,k87sOh:`xjqd8mg`,kzqmXN:`x1xc55vz`,kZKoxP:`xdk7pt`,kB7OPa:`x9f619`,kaIpWk:`x16rqkct`,k3aq6I:`x11lhmoz`,kMzoRj:`xvndefy`,ksu8eU:`x1y0btm7`,kVAM5u:`xct3ywq`,kWkggS:`x1rozbrz`,kaxkhh:`xp7vd6g`,kBzXvT:`x1linyqi`,kdowMK:`x6wuh8v`,kP5Q0z:`x8e4dz`,kPAhU7:`x1355wyl`,kUDdqw:`x1nzxh0e`,kyEoYf:`xw49lei`,kr7ELp:`xzqh9vb`,kc8fFq:`x1nvy8h2`,k40vjo:`xwqtvyl`,k6RPIA:`xlsu8l`,kZDKfJ:`x1k3t2iv`,kGh7v6:`xtkdjl9`,$$css:!0},select:{k1xSpc:`x1lliihq`,kzqmXN:`xh8yej3`,kB7OPa:`x9f619`,k9WMMc:`xdpxx8g`,kMzoRj:`xc342km`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w`,k8WAf4:`x1vvogim`,kZCmMZ:`x110972j`,kwRFfy:`xp48ta0`,kGzVvX:`x9jwiqo`,kZDKfJ:`xd00ecs`,$$css:!0},line:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x167g77z`,k7Eaqz:`xeuugli`,$$css:!0},lineStrong:{kGuDYH:`xfifm61`,k63SB2:`x1s688f`,kcqcaj:`xss6m8b`,$$css:!0},lineText:{kMwMTN:`x1bo0w0s`,khDVqt:`xuxw1ft`,kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,$$css:!0},tag:{kUk6DE:`x1okw0bk`,kGuDYH:`x1k6wstc`,kLWn49:`x1d3mw78`,kg3NbH:`xm9j1uf`,kMzoRj:`xmkeg23`,ksu8eU:`x1y0btm7`,kVAM5u:`xgcsv5v`,kaIpWk:`x12oqio5`,kMwMTN:`x1bo0w0s`,$$css:!0},tagStart:{kVAM5u:`x9r1u3d`,kWkggS:`xjbqb8w`,kMwMTN:`xo2rkog`,$$css:!0},meta:{k1xSpc:`x1lliihq`,keoZOQ:`xr9ek0c`,kGuDYH:`x1j6dyjg`,kMwMTN:`x1bo0w0s`,kcqcaj:`xss6m8b`,$$css:!0},changed:{kMwMTN:`xo2rkog`,$$css:!0},expand:{kVAEAm:`x10l6tqk`,kCIrl2:`xclnmbr`,k87sOh:`x1nl0pjx`,kzqmXN:`xgd8bvy`,kZKoxP:`x1fgtraw`,$$css:!0},expandIcon:{k1ekBW:`x11xpdln`,kIyJzY:`xgdialr`,$$css:!0},expandIconOpen:{k3aq6I:`x1iffjtl`,$$css:!0},raw:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,kLKAdn:`x1nn3v0j`,kGO01o:`xwib8y2`,kZCmMZ:`x110972j`,kwRFfy:`x1icxu4v`,$$css:!0},rawButton:{k1xSpc:`x78zum5`,kGNEyG:`x1pha0wt`,kOIVth:`x883omv`,kzqmXN:`xh8yej3`,kB7OPa:`x9f619`,k9WMMc:`xdpxx8g`,kMzoRj:`xc342km`,kaIpWk:`x12oqio5`,kWkggS:`xjbqb8w`,k8WAf4:`x12ulsxz`,kg3NbH:`x1xijbu4`,kGuDYH:`x1j6dyjg`,kGzVvX:`xj0l527`,k1dPUN:`x1mhs912`,$$css:!0},rawTime:{kUk6DE:`x1okw0bk`,kMwMTN:`x1bo0w0s`,kcqcaj:`xss6m8b`,$$css:!0},rawCode:{k7Eaqz:`xeuugli`,kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,khDVqt:`xuxw1ft`,kGuDYH:`x1k6wstc`,kMwMTN:`x1bo0w0s`,$$css:!0},more:{k1xSpc:`x1lliihq`,kzqmXN:`xh8yej3`,kqGvvJ:`x1twdi5u`,kmVPX3:`xe8ttls`,kMzoRj:`xmkeg23`,ksu8eU:`x1y0btm7`,kVAM5u:`x12xov25`,kaIpWk:`x1kogg8i`,kWkggS:`xjbqb8w`,kGuDYH:`xfifm61`,$$css:!0},end:{keoZOQ:`xhrpt6u`,k1K539:`xat24cr`,kLKAdn:`xz9dl7a`,kEafiO:`x178xt8z`,kPef9Z:`x13fuv20`,kLZC3w:`xxu5053`,kGuDYH:`x1j6dyjg`,kLWn49:`xa7kkou`,kMwMTN:`x1bo0w0s`,$$css:!0},strip:{kVAEAm:`x7wzq59`,k87sOh:`x13vifvy`,kY2c9j:`x1u8a7rm`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1jnr06f`,keoZOQ:`xf4ichi`,k1K539:`x1e56ztr`,kLKAdn:`x1aq4ukf`,kGO01o:`x10b6aqq`,kWkggS:`x1rozbrz`,kGVxlE:`xg7c00`,kz4h6p:`x1drl50h`,kGuDYH:`xfifm61`,$$css:!0},bar:{k87sOh:`x5v0ndm`,kY2c9j:`xk3oba8`,kB7OPa:`x9f619`,kZKoxP:`xrtz9ly`,keoZOQ:`xdj266r`,k1K539:`xat24cr`,kLKAdn:`xexx8yu`,kGO01o:`x18d9i69`,kg3NbH:`x4l9tsp`,kGVxlE:`x1gnnqk1`,kz4h6p:`x1gj8qfm`,kt9PQ7:`xso031l`,kfdmCh:`x1q0q8m5`,kL6WhQ:`xtrfj0v`,$$css:!0},pickRow:{kXwgrk:`x1q0g3np`,kGNEyG:`x1pha0wt`,kOIVth:`x167g77z`,$$css:!0},pick:{k1xSpc:`x78zum5`,kUk6DE:`x98rzlu`,k7Eaqz:`xeuugli`,kXwgrk:`xdt5ytf`,kGNEyG:`x1cy8zhl`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,k8WAf4:`xj8oexa`,kg3NbH:`xnjsko4`,k9WMMc:`xdpxx8g`,$$css:!0},pickSpan:{kGuDYH:`x1j6dyjg`,kMwMTN:`x1bo0w0s`,$$css:!0},pickStrong:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kOIVth:`x1jnr06f`,ks0D6T:`x193iq5w`,k63SB2:`x1s688f`,khDVqt:`xuxw1ft`,kVQacm:`xb3r6kr`,kg5iWk:`xlyipyv`,kcqcaj:`xss6m8b`,$$css:!0},sheet:{kVAEAm:`xixxii4`,k87sOh:`x13vifvy`,kCIrl2:`x3m8u43`,krVfgx:`x1ey2m1c`,kbCHJM:`xu96u03`,kY2c9j:`x68pp3s`,$$css:!0},sheetHead:{k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`x1qughib`,kLKAdn:`x1yrsyyn`,kGO01o:`xwib8y2`,kZCmMZ:`x106a9eq`,kwRFfy:`xf159sx`,$$css:!0},sheetHeadText:{k1xSpc:`x78zum5`,kXwgrk:`xdt5ytf`,$$css:!0},sheetTitle:{kGuDYH:`x1jvydc1`,k63SB2:`x1s688f`,$$css:!0},sheetSmall:{kGuDYH:`xfifm61`,kMwMTN:`x1bo0w0s`,$$css:!0},sheetButton:{kAzted:`x1gg8mnh`,kg3NbH:`xaope02`,kMzoRj:`xc342km`,kWkggS:`xjbqb8w`,kGuDYH:`xif65rj`,$$css:!0},sheetBody:{kLKAdn:`xexx8yu`,kGO01o:`xwxc41k`,kg3NbH:`xaope02`,$$css:!0},sheetSelect:{kAzted:`xbktkl8`,$$css:!0}},xn={human:`history.sourceHuman`,agent:`history.sourceAgent`,session:`history.sourceSession`,unknown:`history.sourceUnknown`};function Sn(e){let{session:t,selected:n}=e;return t&&n?t.history.groups.find(e=>e.entries.includes(n)):void 0}function Cn(e){return e.session?.history.entries.at(-1)?.change.timestamp??0}function wn({model:e,strip:t}){let{count:n,changeIndex:r,loading:i}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{"aria-live":`polite`,role:`status`,...U(Z.count),children:[n?r+1:0,` / `,n]}),(0,J.jsx)(`button`,{"aria-label":V(`history.previousChange`),disabled:r===0||i,type:`button`,...U(Z.buttonBase,Z.icon,t&&Z.stripIcon),onClick:()=>e.navigate(-1),children:(0,J.jsx)(C,{"aria-hidden":`true`,size:14})}),(0,J.jsx)(`button`,{"aria-label":V(`history.nextChange`),disabled:r>=n-1||i,type:`button`,...U(Z.buttonBase,Z.icon,t&&Z.stripIcon),onClick:()=>e.navigate(1),children:(0,J.jsx)(h,{"aria-hidden":`true`,size:14})})]})}function Tn({model:e}){return(0,J.jsx)(`button`,{"aria-pressed":e.onlyChanges,type:`button`,...U(Z.buttonBase,Z.filter,e.onlyChanges&&Z.filterOn),onClick:e.toggleOnly,children:V(`history.onlyChanges`)})}function En({compact:e,model:t}){return t.pending?(0,J.jsxs)(`div`,{role:`status`,...U(e?Z.updateCompact:Z.update),children:[(0,J.jsx)(`span`,{...U(Z.updateText),children:t.streaming?V(`history.waitingEdits`):V(`history.newContent`,{time:X(Cn(t))})}),(0,J.jsxs)(`button`,{disabled:t.streaming||t.loading,type:`button`,...U(Z.buttonBase,Z.updateButton),onClick:t.refresh,children:[(0,J.jsx)(n,{"aria-hidden":`true`,size:12}),V(`history.refresh`)]})]}):null}function Dn({model:e,sheet:t}){let[n,r]=(0,q.useState)(50),[i,a]=(0,q.useState)(()=>new Set),{session:o,selected:s,blocks:c}=e;if(!o)return null;let{groups:l,entries:u,shallow:d}=o.history,f=l.findIndex(e=>s!==null&&e.entries.includes(s)),p=new Map;for(let e of c)e.group&&p.set(e.group,(p.get(e.group)??0)+1);let m=l.slice(0,n),h=e=>_n(e.entries.at(-1).change.timestamp),g=e=>a(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`ol`,{"aria-label":V(`history.timeline`),...U(Z.timeline),children:m.map((n,r)=>{let a=n.entries.at(-1),o=h(n),c=r===0||o!==h(m[r-1]),l=r===f?`selected`:r===0?`latest`:r<f?`range`:`outside`,u=i.has(n.id),d=r<f?p.get(n):void 0;return(0,J.jsxs)(`li`,{"data-day":c?``:void 0,"data-lower":r<f?`in`:`out`,"data-state":l,"data-upper":r<=f?`in`:`out`,...U(Z.node),children:[c?(0,J.jsx)(`div`,{...U(Z.day),children:o}):null,(0,J.jsxs)(`div`,{...U(Z.row),children:[(0,J.jsx)(`span`,{"aria-hidden":`true`,"data-state":l,...U(Z.dot)}),(0,J.jsxs)(`button`,{"aria-current":l===`selected`?`true`:void 0,"data-state":l,type:`button`,...U(Z.buttonBase,Z.select,t&&Z.sheetSelect),onClick:()=>e.select(a),children:[(0,J.jsxs)(`span`,{...U(Z.line),children:[(0,J.jsx)(`strong`,{...U(Z.lineStrong),children:X(a.change.timestamp)}),(0,J.jsx)(`span`,{...U(Z.lineText),children:n.author??V(xn[n.source])}),l===`latest`?(0,J.jsx)(`span`,{...U(Z.tag),children:V(`history.latest`)}):null,l===`selected`?(0,J.jsx)(`span`,{...U(Z.tag,Z.tagStart),children:V(`history.start`)}):null]}),(0,J.jsxs)(`span`,{...U(Z.meta),children:[V(`history.commits`,{count:n.entries.length}),d?(0,J.jsx)(`span`,{...U(Z.changed),children:V(`history.changedSuffix`,{count:d})}):null]})]}),(0,J.jsx)(`button`,{"aria-expanded":u,"aria-label":V(u?`history.collapseCommits`:`history.expandCommits`),type:`button`,...U(Z.buttonBase,Z.icon,Z.expand),onClick:()=>g(n.id),children:(0,J.jsx)(Ct,{"aria-hidden":`true`,size:14,...U(Z.expandIcon,u&&Z.expandIconOpen)})})]}),u?(0,J.jsx)(`div`,{...U(Z.raw),children:[...n.entries].reverse().map(t=>(0,J.jsxs)(`button`,{"aria-current":t===s?`true`:void 0,title:t.change.message?.split(`
2
2
  `)[0],type:`button`,...U(Z.buttonBase,Z.rawButton),onClick:()=>e.select(t),children:[(0,J.jsx)(`span`,{...U(Z.rawTime),children:X(t.change.timestamp,!0)}),(0,J.jsx)(`code`,{...U(Z.rawCode),children:t.change.message?.split(`
3
- `)[0]||V(`history.sourceUnknown`)})]},t.id))}):null]},n.id)})}),n<l.length?(0,J.jsx)(`button`,{type:`button`,...U(Z.buttonBase,Z.more),onClick:()=>r(e=>e+50),children:V(`history.loadEarlier`)}):(0,J.jsxs)(`p`,{...U(Z.end),children:[V(d?`history.shallow`:`history.earliest`),` ·`,` `,V(`history.summary`,{edits:V(`history.edits`,{count:l.length}),commits:V(`history.commits`,{count:u.length})}),(0,J.jsx)(`br`,{}),V(`history.clockNote`)]})]})}function On({model:e,open:t,onDismiss:n,onExited:r}){let i=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!t)return;let e=document.activeElement,n=i.current,r=()=>[...n?.querySelectorAll(`button:not(:disabled), a[href], input:not(:disabled), [tabindex="0"]`)??[]];r()[0]?.focus();let a=e=>{if(e.key!==`Tab`)return;let t=r();e.shiftKey&&document.activeElement===t[0]?(e.preventDefault(),t.at(-1)?.focus()):!e.shiftKey&&document.activeElement===t.at(-1)&&(e.preventDefault(),t[0]?.focus())};return n?.addEventListener(`keydown`,a),()=>{n?.removeEventListener(`keydown`,a),e?.focus()}},[t]);let a=(0,J.jsxs)(`div`,{...U(Z.sheetHead),children:[(0,J.jsxs)(`span`,{...U(Z.sheetHeadText),children:[(0,J.jsx)(`strong`,{...U(Z.sheetTitle),children:V(`history.chooseStart`)}),(0,J.jsx)(`small`,{...U(Z.sheetSmall),children:V(`history.compareWithLatest`,{time:vn(Cn(e))})})]}),(0,J.jsx)(`button`,{type:`button`,...U(Z.buttonBase,Z.sheetButton),onClick:n,children:V(`common.done`)})]});return(0,J.jsx)(`div`,{"aria-label":V(`history.chooseStart`),"aria-modal":`true`,inert:!t,ref:i,role:`dialog`,...U(Z.text,Z.sheet),children:(0,J.jsx)(gt,{header:a,open:t,snap:.85,snaps:[0,.85],onExited:r,onScrim:n,onSnap:e=>{e===0&&n()},children:(0,J.jsx)(`div`,{...U(Z.sheetBody),children:(0,J.jsx)(Dn,{sheet:!0,model:e})})})})}var kn=[z,xe,...St,se,he],An={[ve]:re,[Ee]:Ae,[ye]:N,[L]:de},jn={insert:`history.kindInsert`,delete:`history.kindDelete`,modify:`history.kindModify`};function Mn(e){return q.Children.toArray(e).map(e=>(0,q.isValidElement)(e)?Mn(e.props.children):String(e)).join(``)}var Nn={table:(e,t,n,r)=>{let i=r();return(0,q.isValidElement)(i)?(0,q.cloneElement)(i,{tabIndex:0}):i},heading:(e,t,n,r)=>{let i=r();if(!(0,q.isValidElement)(i))return i;let a=Mn(i.props.children);return(0,q.cloneElement)(i,void 0,q.Children.map(i.props.children,e=>(0,q.isValidElement)(e)&&e.type===`a`?(0,q.cloneElement)(e,{"aria-label":a}):e))}},Pn=(0,q.memo)(function({value:e,theme:t}){return(0,J.jsx)(pe,{children:(0,J.jsx)(it,{builtinNodeOverrides:Nn,extraNodes:kn,rendererConfig:An,theme:t,value:e,variant:`article`})})},(e,t)=>e.theme===t.theme&&JSON.stringify(e.value)===JSON.stringify(t.value));function Fn({model:e,theme:t,title:n,narrow:r,bodyRef:i,onPick:a}){let{comparison:o,selected:s,count:c,changeIndex:l,loading:u,error:d,streaming:f,onlyChanges:p}=e,m=[U(Z.text).className,`history-view`].filter(Boolean).join(` `),g=-1,_=o?.blocks.flatMap(e=>e.kind===`equal`?e.value.root.children.map((t,n)=>({...e,newIndex:e.newIndex+n,value:{root:{...e.value.root,children:[t]}}})):[e])??[],v=(0,q.use)(fe)?.toolbarSlot,y=U(Z.strip,v&&Z.bar),b=r?(0,J.jsxs)(`div`,{...y,className:[y.className,v&&`history-bar`].filter(Boolean).join(` `),children:[(0,J.jsxs)(`button`,{type:`button`,...U(Z.buttonBase,Z.pick,v&&Z.pickRow),onClick:a,children:[(0,J.jsx)(`span`,{...U(Z.pickSpan),children:V(`history.compareFrom`)}),(0,J.jsxs)(`strong`,{...U(Z.pickStrong),children:[V(`history.toLatest`,{from:s?vn(s.change.timestamp):V(`history.pickPoint`)}),(0,J.jsx)(h,{"aria-hidden":`true`,size:12})]})]}),(0,J.jsx)(Tn,{model:e}),(0,J.jsx)(wn,{strip:!0,model:e})]}):null,x=_.filter(e=>e.kind===`equal`&&e.value.root.children[0]?.type!==`heading`).length;return(0,J.jsxs)(`div`,{className:m,children:[b&&v?(0,Yt.createPortal)(b,v):b,r?(0,J.jsx)(En,{compact:!0,model:e}):null,r&&(u||d)?(0,J.jsx)(`div`,{className:`history-inline-status`,role:d?`alert`:`status`,children:d?(0,J.jsxs)(J.Fragment,{children:[V(`history.readFailed`,{error:d}),` `,(0,J.jsx)(`button`,{disabled:f,type:`button`,onClick:e.refresh,children:V(`common.retry`)})]}):(0,J.jsx)(H,{label:V(f?`history.waitingEdits`:`history.computing`),size:14})}):null,o?(0,J.jsxs)(`div`,{"aria-busy":u,"aria-label":V(`history.diffBody`),className:`history-content`,ref:i,role:`region`,children:[o.latest.value.root.children.some(e=>e.type===`heading`&&e.tag===`h1`)?null:(0,J.jsx)(`h1`,{className:`history-content-title`,children:n}),_.map(e=>{let n=e.kind!==`equal`;n&&g++;let r=n?g:-1,i=e.kind!==`delete`,a=e.value.root.children[0],s=a?.type===`heading`?a.tag:void 0,c=(i?o.latest.value.root.children[e.newIndex]:null)?.$?.blockId,u=s&&i?{root:{...o.latest.value.root,children:[o.latest.value.root.children[e.newIndex]]}}:e.value,d=i?o.latest.ids[e.newIndex]??`current-`+e.newIndex:`deleted-`+e.oldIndex;return(0,J.jsxs)(`section`,{className:`history-block`,"data-current":n&&r===l?``:void 0,"data-folded":!n&&p&&!s?``:void 0,"data-heading":s,"data-history-block-id":c,"data-history-change":n?``:void 0,"data-history-index":i?e.newIndex:void 0,"data-kind":e.kind,children:[(0,J.jsx)(`div`,{className:`history-current`,children:i?(0,J.jsx)(Pn,{theme:t,value:u}):null}),(0,J.jsx)(`div`,{className:`history-before`,children:(0,J.jsx)(`div`,{className:`history-before-inner`,children:e.before||e.kind===`delete`?(0,J.jsxs)(`div`,{className:`history-old-content`,children:[(0,J.jsxs)(`div`,{className:`history-caption`,children:[(0,J.jsx)(`span`,{children:V(jn[e.kind])}),e.author?(0,J.jsxs)(`span`,{children:[vn(e.author.change.timestamp),e.group?` · `+(e.group.author??V(xn[e.group.source])):``]}):null]}),(0,J.jsx)(Pn,{theme:t,value:e.before??e.value})]}):null})})]},d)}),p&&x>0?(0,J.jsx)(`button`,{className:`history-expand`,type:`button`,onClick:e.showAll,children:V(`history.unchanged`,{count:x})}):null,c?null:(0,J.jsx)(`p`,{className:`history-no-diff`,role:`status`,children:V(`history.noDiff`)}),(0,J.jsx)(`p`,{...U(Z.end),children:V(`history.endOfDiff`)})]}):null]})}function In(e,t){return e.read(()=>{let n=j().getChildren(),r=new Map;for(let e of n){let t=A(e,ue);t&&r.set(t,e)}let i=new Map;for(let a of t){let t=a.blockId&&r.get(a.blockId)||n[a.index];i.set(a.key,t?e.getElementByKey(t.getKey()):null)}return i})}var Ln=28,Rn=12,zn=36,Bn=6,Vn={insert:`history.kindInsert`,delete:`history.kindDelete`,modify:`history.kindModify`};function Hn(e){let[t,n]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let t=()=>n(e=>e+1),r=e.getRootElement(),i=typeof ResizeObserver==`function`?new ResizeObserver(t):null;r&&i?.observe(r);let a=e.registerUpdateListener(t);return window.addEventListener(`resize`,t),()=>{a(),i?.disconnect(),window.removeEventListener(`resize`,t)}},[e]),t}function Un({editor:e,changes:t,seen:n,focused:r,leaving:i=!1,theme:a,onElements:o}){let{t:s}=Pe(),c=Hn(e),[l,u]=(0,q.useState)([]),[d,f]=(0,q.useState)(new Set),[p,m]=(0,q.useState)({}),h=(0,q.useRef)(new Map),g=(0,q.useRef)(new Map),_=e.getRootElement(),v=_?_.offsetParent??_.parentElement:null;if((0,q.useLayoutEffect)(()=>{if(!_||!v)return u([]);let n=In(e,t);g.current=n;let r=_.lastElementChild,i=[],a=e=>(p[e]??Ln)+24;for(let e of t){if(e.kind!==`delete`)continue;let t=n.get(e.key)??r;t&&(t.dataset.sinceDeleted=n.get(e.key)?`before`:`after`,t.style.setProperty(`--since-gap`,`${a(e.key)}px`),i.push(t))}let o=v.getBoundingClientRect(),s=_.getBoundingClientRect(),c=e=>e-o.top+v.scrollTop,l=e=>e-o.left+v.scrollLeft,d=e=>l(Math.max(e-zn,Bn)),f=[];for(let e of t){let t=n.get(e.key);if(e.kind!==`delete`){if(!t)continue;let n=t.getBoundingClientRect();f.push({key:e.key,bar:d(n.left),top:c(n.top),height:n.height,left:l(n.left),width:n.width});continue}let i=t??r;if(!i)continue;let o=i.getBoundingClientRect(),u=a(e.key);f.push({key:e.key,bar:d(s.left),top:t?c(o.top)-u+Rn:c(o.bottom)+Rn,height:u-24,left:l(s.left),width:s.width})}return u(f),()=>i.forEach(e=>{delete e.dataset.sinceDeleted,e.style.removeProperty(`--since-gap`)})},[e,_,v,t,c,p]),(0,q.useLayoutEffect)(()=>{let e={};for(let t of d){let n=h.current.get(t)?.querySelector(`[data-since-row-body]`);n&&(e[t]=Ln+n.offsetHeight)}Object.keys(e).length===Object.keys(p).length&&Object.entries(e).every(([e,t])=>p[e]===t)||m(e)},[d,l,p]),(0,q.useLayoutEffect)(()=>{if(!o)return;let e=new Map;for(let n of t){let t=n.kind===`delete`?h.current.get(n.key):g.current.get(n.key);t&&e.set(n.key,t)}o(e)},[l,t,o]),!v)return null;let y=new Map(t.map(e=>[e.key,e])),b=l.find(e=>e.key===r&&y.get(e.key)?.kind!==`delete`),x=e=>f(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,Yt.createPortal)((0,J.jsxs)(`div`,{className:`since-marks`,"data-leaving":i?``:void 0,"data-since-marks":``,children:[b?(0,J.jsx)(`div`,{className:`since-focus`,"data-since-focus":``,style:{top:b.top-4,left:b.left-12,width:b.width+24,height:b.height+8}}):null,l.map(e=>{let t=y.get(e.key);if(!t)return null;let i={"data-seen":n.has(e.key)?``:void 0,"data-focused":r===e.key?``:void 0};if(t.kind===`delete`){let n=d.has(e.key);return(0,J.jsxs)(`div`,{className:`since-row`,"data-since-deleted-row":e.key,style:{top:e.top,left:e.left,width:e.width,minHeight:Ln},ref:t=>{t?h.current.set(e.key,t):h.current.delete(e.key)},...i,children:[(0,J.jsx)(`span`,{className:`since-row-bar`,style:{left:e.bar-e.left}}),(0,J.jsxs)(`div`,{className:`since-row-head`,children:[(0,J.jsx)(`span`,{children:s(`sinceRead.deleted`,{count:t.count})}),(0,J.jsx)(`span`,{className:`since-row-rule`}),(0,J.jsx)(`button`,{"data-since-expand":``,type:`button`,onClick:()=>x(e.key),children:s(n?`sinceRead.collapse`:`sinceRead.expand`)})]}),n&&t.deleted?(0,J.jsx)(`div`,{className:`since-row-body`,"data-since-row-body":``,children:(0,J.jsx)(Pn,{theme:a,value:t.deleted})}):null]},e.key)}return(0,J.jsx)(`div`,{className:`since-mark`,"data-since-mark":e.key,style:{top:e.top,left:e.bar-4.5,height:e.height},...i,children:(0,J.jsxs)(`span`,{className:`since-tip`,children:[(0,J.jsx)(`b`,{children:t.author??`Agent`}),s(Vn[t.kind]),` · `,xt(t.at*1e3)]})},e.key)})]}),v)}function Wn(e,{properties:t,lineage:n}={}){let r=I(e.message);if(r)return r;if(R(e.message)!==`agent`||!t||t.lineage!==n||!t.baseline||e.peer===void 0||e.counter===void 0||!e.length)return;let i=t.baseline;for(let n of t.batches){if(e.counter>=(i[e.peer]??0)&&e.counter+e.length<=(n.through[e.peer]??0))return n.by;i=n.through}}function Gn(e,t){return e.map(e=>{let n=Wn(e,t);return n&&!I(e.message)?{...e,message:Se(e.message??``,n)}:e})}var Kn=5e4,qn=`background-color: color-mix(in srgb, var(--rc-alert-caution) 22%, transparent); text-decoration: line-through;`,Jn=`background-color: color-mix(in srgb, var(--rc-alert-tip) 22%, transparent);`;function Yn(e){let t=e;return t.type===`heading`?`heading:${t.tag}`:t.type===`list`?`list:${t.listType}`:t.type||`unknown`}function Xn(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Zn(e){let t=e;return t.type===`text`&&typeof t.text==`string`}function Qn(e){let t=e;return Array.isArray(t.children)?t.children:null}function $n(e,t){let n=typeof e==`string`?e.trim():``;return n?`${n}${n.endsWith(`;`)?``:`;`} ${t}`:t}function er(e,t,n){let{style:r}=e;return n===`delete`?r=$n(r,qn):n===`insert`&&(r=$n(r,Jn)),{...e,text:t,style:r}}function tr(e,t){return{...e,children:t}}function Q(e,t){if(Zn(e))return er(e,e.text,t);let n=Qn(e);return n?tr(e,n.map(e=>Q(e,t))):e}function nr(e){return Array.from(e).reverse().join(``)}function rr(e){let t=[];for(let n of e){if(!n.text)continue;let e=t.at(-1);e&&e.kind===n.kind?e.text+=n.text:t.push({...n})}return t}function ir(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return[{kind:`insert`,text:t.join(``)}];if(r===0)return[{kind:`delete`,text:e.join(``)}];if(n*r>Kn)return[{kind:`delete`,text:e.join(``)},{kind:`insert`,text:t.join(``)}];let i=Array.from({length:n+1},()=>Array.from({length:r+1}).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++)e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]+1:i[a][n]=Math.max(i[a-1][n],i[a][n-1]);let a=[],o=n,s=r;for(;o>0&&s>0;)if(e[o-1]===t[s-1]){let t=a.at(-1);t&&t.kind===`equal`?t.text+=e[o-1]:a.push({kind:`equal`,text:e[o-1]}),o--,s--}else if(i[o-1][s]>=i[o][s-1]){let t=a.at(-1);t&&t.kind===`delete`?t.text+=e[o-1]:a.push({kind:`delete`,text:e[o-1]}),o--}else{let e=a.at(-1);e&&e.kind===`insert`?e.text+=t[s-1]:a.push({kind:`insert`,text:t[s-1]}),s--}for(;o>0;){let t=a.at(-1);t&&t.kind===`delete`?t.text+=e[o-1]:a.push({kind:`delete`,text:e[o-1]}),o--}for(;s>0;){let e=a.at(-1);e&&e.kind===`insert`?e.text+=t[s-1]:a.push({kind:`insert`,text:t[s-1]}),s--}return rr(a.reverse().map(e=>({kind:e.kind,text:nr(e.text)})))}function ar(e,t){let n=Array.from(e),r=Array.from(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;let a=n.length-1,o=r.length-1;for(;a>=i&&o>=i&&n[a]===r[o];)a--,o--;let s=[];return i>0&&s.push({kind:`equal`,text:n.slice(0,i).join(``)}),s.push(...ir(n.slice(i,a+1),r.slice(i,o+1))),a<n.length-1&&s.push({kind:`equal`,text:n.slice(a+1).join(``)}),rr(s)}function or(e,t){let n=ar(e.text,t.text),r=[],i=[],a=!1;for(let o of n)o.text&&(o.kind===`equal`?(r.push(er(e,o.text)),i.push(er(t,o.text))):(a=!0,o.kind===`delete`?r.push(er(e,o.text,`delete`)):i.push(er(t,o.text,`insert`))));return{oldNodes:r.length>0?r:[e],newNodes:i.length>0?i:[t],changed:a}}function sr(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array.from({length:r+1}).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++){let r=Math.max(i[a-1][n],i[a][n-1]);if(Yn(e[a-1])===Yn(t[n-1])){let o=Xn(e[a-1],t[n-1])?2:1;i[a][n]=Math.max(r,i[a-1][n-1]+o)}else i[a][n]=r}let a=[],o=n,s=r;for(;o>0&&s>0;){if(Yn(e[o-1])===Yn(t[s-1])){let n=Xn(e[o-1],t[s-1]),r=n?2:1;if(i[o][s]===i[o-1][s-1]+r){a.push(n?{kind:`equal`,node:e[o-1]}:{kind:`modify`,oldNode:e[o-1],newNode:t[s-1]}),o--,s--;continue}}i[o-1][s]>=i[o][s-1]?(a.push({kind:`delete`,node:e[o-1]}),o--):(a.push({kind:`insert`,node:t[s-1]}),s--)}for(;o>0;)a.push({kind:`delete`,node:e[--o]});for(;s>0;)a.push({kind:`insert`,node:t[--s]});return a.reverse(),a}function cr(e,t){let n=sr(e,t),r=[],i=[],a=!1;for(let e of n)switch(e.kind){case`equal`:r.push(e.node),i.push(e.node);break;case`delete`:a=!0,r.push(Q(e.node,`delete`));break;case`insert`:a=!0,i.push(Q(e.node,`insert`));break;case`modify`:{if(a=!0,Zn(e.oldNode)&&Zn(e.newNode)){let t=or(e.oldNode,e.newNode);r.push(...t.oldNodes),i.push(...t.newNodes);break}let t=lr(e.oldNode,e.newNode);t?(r.push(t.oldNode),i.push(t.newNode)):(r.push(Q(e.oldNode,`delete`)),i.push(Q(e.newNode,`insert`)));break}}return{oldChildren:r,newChildren:i,changed:a}}function lr(e,t){if(Yn(e)!==Yn(t))return null;if(Xn(e,t))return{oldNode:e,newNode:t,changed:!1};let n=Qn(e),r=Qn(t);if(!n||!r)return null;let i=cr(n,r);return i.changed?{oldNode:tr(e,i.oldChildren),newNode:tr(t,i.newChildren),changed:!0}:{oldNode:e,newNode:t,changed:!1}}function ur(e,t){let n=lr(e,t);return n?{oldNode:n.oldNode,newNode:n.newNode}:{oldNode:Q(e,`delete`),newNode:Q(t,`insert`)}}function dr(e,t){let n=sr(e.root.children,t.root.children),r=[];for(let e of n)switch(e.kind){case`equal`:{let t=r.at(-1);t&&t.type===`equal`?t.nodes.push(e.node):r.push({type:`equal`,nodes:[e.node]});break}case`modify`:{let t=ur(e.oldNode,e.newNode);r.push({type:`delete`,nodes:[t.oldNode]},{type:`insert`,nodes:[t.newNode]})}break;case`delete`:r.push({type:`delete`,nodes:[Q(e.node,`delete`)]});break;case`insert`:r.push({type:`insert`,nodes:[Q(e.node,`insert`)]})}return r}function fr(e){let t={...e};if(t.$){let{blockId:e,...n}=t.$;Object.keys(n).length?t.$=n:delete t.$}return t.children&&=t.children.map(fr),t}function pr(e,t){let{children:n,text:r,...i}=e,{children:a,text:o,...s}=t;return JSON.stringify(i)!==JSON.stringify(s)||!!(n&&a&&_r(n,a).some(e=>e.kind===`modify`&&pr(e.old[0],e.current[0])))}function mr(e){let t=e;return t.type===`dynamic`||t.type===`pending`?{type:`paragraph`,version:1,direction:null,format:``,indent:0,children:[{type:`text`,version:1,text:t.type===`dynamic`?G.t(`history.dynamic`,{url:t.url,height:t.initialHeight??320,props:JSON.stringify(t.props??{})}):G.t(`history.pendingIntent`,{intent:t.intent??``}),format:0,detail:0,mode:`normal`,style:``}]}:t.children?{...t,children:t.children.map(mr)}:t}function hr(e){return gr(e.map(mr))}function gr(e){return{root:{type:`root`,version:1,direction:null,format:``,indent:0,children:e}}}function _r(e,t){let n=dr(gr(e),gr(t)),r=[],i=0,a=0;for(let o=0;o<n.length;o++){let s=n[o];if(s.type===`equal`){r.push({kind:`equal`,old:e.slice(i,i+s.nodes.length),current:t.slice(a,a+s.nodes.length),oldIndex:i,newIndex:a}),i+=s.nodes.length,a+=s.nodes.length;continue}let c=0,l=0;for(;o<n.length&&n[o].type!==`equal`;){let e=n[o++];e.type===`delete`?c+=e.nodes.length:l+=e.nodes.length}o--;for(let n=0;n<Math.max(c,l);n++){let o=n<c?[e[i+n]]:[],s=n<l?[t[a+n]]:[];r.push({kind:o.length&&s.length?`modify`:o.length?`delete`:`insert`,old:o,current:s,oldIndex:o.length?i+n:void 0,newIndex:s.length?a+n:void 0})}i+=c,a+=l}return r}function vr(e,t){return _r(e.root.children.map(fr),t.root.children.map(fr)).map(e=>{let t={oldIndex:e.oldIndex,newIndex:e.newIndex};if(e.kind===`modify`){let n=e.old[0],r=e.current[0],i=n.type===r.type&&!pr(n,r)?ur(n,r):null;return i?{kind:`modify`,before:hr([i.oldNode]),value:hr([i.newNode]),...t}:{kind:`modify`,before:hr(e.old),value:hr(e.current),...t}}let n=e.kind===`delete`?e.old:e.current;return{kind:e.kind,value:hr(e.kind===`equal`?n:n.map(t=>Q(t,e.kind))),...t}})}var yr=e=>`${e.counter}@${e.peer}`,br=(e,t)=>e.lamport-t.lamport||e.peer.localeCompare(t.peer)||e.counter-t.counter;async function xr(e,t){await new Promise(e=>setTimeout(e,0));let n=Gn([...e.getAllChanges().values()].flat(),{properties:t,lineage:e.getTree(F).roots()[0]?.id}).sort(br),r=e.shallowSinceFrontiers(),i=new Map(r.map(e=>[yr(e),e])),a=[],o=[];for(let e of n){for(let t of e.deps)i.delete(yr(t));i.delete(yr({peer:e.peer,counter:e.counter-1}));let t={peer:e.peer,counter:e.counter+e.length-1};i.set(yr(t),t);let n={id:`${e.counter}@${e.peer}`,change:e,frontiers:[...i.values()]};a.push(n);let r=R(e.message),s=Te(e.message),c=o.at(-1),l=c?.entries.at(-1)?.change;c&&l&&r!==`unknown`&&c.source===r&&c.author===s&&l.peer===e.peer&&l.timestamp>0&&e.timestamp>=l.timestamp&&e.timestamp-l.timestamp<=60?(c.entries.push(n),c.id=n.id):o.push({id:n.id,source:r,...s&&{author:s},entries:[n]}),a.length%200==0&&await new Promise(e=>setTimeout(e,0))}return{entries:a,groups:o.reverse(),shallow:r.length>0}}function Sr(e,t,n){if(!n.length)return null;for(let r=t.entries.length-1;r>=0;r--){let i=t.entries[r];try{let t=e.cmpFrontiers(i.frontiers,n);if(t===0||t===-1)return i}catch{return null}}return null}function Cr(e,t,n){let r=e.fork(),i;try{r.checkout(t);let e=r.getTree(F).roots();if(e.length!==1)throw Error(G.t(`history.contentUnavailable`));let a=ee({nodes:n,editable:!1,onError:e=>{throw e}});i=_e(a,r);let o=e[0].children()??[],s=new Map,c=(e,t)=>{s.set(e.id,t),e.children()?.forEach(e=>c(e,t))};return o.forEach(e=>c(e,e.id)),{value:a.getEditorState().toJSON(),ids:o.map(e=>e.id),owners:s}}finally{i?.dispose(),r.free()}}var wr=/^cid:(\d+@\d+):Map$/;function Tr(e,t,n){let r=new Map(n.flatMap(e=>[...e.owners])),i=e.getTree(F),a=new Map,o=new Map(t.map((e,t)=>[e,t])),s=(e,t)=>{let n=a.get(e);(!n||o.get(n)<o.get(t))&&a.set(e,t)};for(let n of t){let{peer:t,counter:i,length:a}=n.change;for(let o of e.getChangedContainersIn({peer:t,counter:i},a)){let t=e.getContainerById(o);for(;t;){let e=wr.exec(t.id)?.[1],i=e&&r.get(e);if(i){s(i,n);break}t=t.parent()}}}let c=e=>e&&t.find(({change:t})=>t.peer===e.peer&&t.counter<=e.counter&&e.counter<t.counter+t.length);for(let e of new Set(r.values())){if(!i.isNodeDeleted(e))continue;let t=c(i.getNodeByID(e)?.getLastMoveId());t&&s(e,t)}return a}var Er=e=>!!e&&(e.startsWith(`agent:`)||e.startsWith(`session `));function Dr(e,t){try{e.frontiersToVV(t).free()}catch{return!1}let n=e.shallowSinceFrontiers();if(!n.length)return!0;let r=e.cmpFrontiers(t,n);return r===0||r===1}async function Or(e,t,n,r,i){if(!Dr(e,t))return{kind:`compacted`};let a=t=>Wn(t,{properties:i,lineage:e.getTree(F).roots()[0]?.id})?.name,{forward:o}=e.findIdSpansBetween(t,e.frontiers());if(!o.length)return{kind:`changes`,changes:[]};let s=e.fork();try{await new Promise(e=>setTimeout(e,0));let e=[];for(let t of o){let n=t.counter;for(;n<t.counter+t.length;){let r=s.getChangeAt({peer:t.peer,counter:n});Er(r.message)&&e.push({change:r}),n=r.counter+r.length}}if(e.sort((e,t)=>br(e.change,t.change)),!e.length)return{kind:`changes`,changes:[]};let i=Cr(s,t,n),c=Cr(s,s.frontiers(),n),l=Tr(s,e,[i,c]),u=(e,{change:t})=>`${e}@${t.counter+t.length-1}@${t.peer}`,d=(...e)=>e.map(e=>e&&l.get(e)).find(e=>!!e),f=new Set(c.ids),p=new Set(i.ids),m=s.getTree(F),h=[...e].reverse().find(({change:e})=>s.getChangedContainersIn({peer:e.peer,counter:e.counter},e.length).includes(m.id)),g=e=>e&&p.has(e)?h:void 0,_=new Set,v=c.value.root.children,y=[],b=0,x=null,S=()=>{x&&=(x.change.deleted={root:{...c.value.root,children:x.nodes}},r.has(x.change.key)||y.push(x.change),null)};for(let e of vr(i.value,c.value)){if(e.kind===`delete`){let t=i.ids[e.oldIndex];if(t&&f.has(t))continue;let n=d(t);if(!n){S();continue}let r=a(n.change);x&&x.change.author!==r&&S(),x?(x.change.count++,x.nodes.push(...e.value.root.children),n.change.timestamp>x.change.at&&(x.change.at=n.change.timestamp)):x={change:{key:u(t,n),author:r,kind:`delete`,index:b,count:1,at:n.change.timestamp},nodes:[...e.value.root.children]};continue}if(S(),b=e.newIndex+1,e.kind===`equal`){b=e.newIndex+e.value.root.children.length;continue}let t=c.ids[e.newIndex],n=e.kind===`insert`&&!!t&&p.has(t),o=d(t,e.oldIndex===void 0?void 0:i.ids[e.oldIndex])??(n?g(t):void 0);if(!o)continue;let s=u(t,o);if(r.has(s)||_.has(s))continue;_.add(s);let l=v[e.newIndex]?.$?.blockId;y.push({key:s,author:a(o.change),kind:n?`modify`:e.kind,index:e.newIndex,count:1,at:o.change.timestamp,...typeof l==`string`?{blockId:l}:{}})}return S(),{kind:`changes`,changes:y}}finally{s.free()}}function kr({onSeen:e,dwellMs:t=1e3}){let n=new Map,r=!1,i=()=>!r&&document.visibilityState===`visible`,a=e=>{clearTimeout(e.timer),e.timer=void 0},o=(r,o)=>{if(!o.inView||!i())return a(o);o.timer===void 0&&(o.timer=setTimeout(()=>{c.unobserve(r),n.delete(r),e(o.key)},t))},s=()=>n.forEach((e,t)=>o(t,e)),c=new IntersectionObserver(e=>{for(let{target:t,intersectionRatio:r,intersectionRect:i}of e){let e=n.get(t);e&&(e.inView=r>=.5||i.height>=window.innerHeight/2,o(t,e))}},{threshold:[0,.25,.5,.75,1]});document.addEventListener(`visibilitychange`,s);let l=()=>{n.forEach((e,t)=>{a(e),c.unobserve(t)}),n.clear()},u=(e,t)=>{let r=n.get(t);r?.key!==e&&(r&&a(r),n.set(t,{key:e,inView:!1}),c.observe(t))};return{observe:u,track:e=>{let t=new Map([...e].map(([e,t])=>[t,e]));n.forEach((e,r)=>{t.get(r)!==e.key&&(a(e),c.unobserve(r),n.delete(r))}),e.forEach((e,t)=>u(t,e))},clear:l,setPaused:e=>{r=e,s()},dispose:()=>{l(),c.disconnect(),document.removeEventListener(`visibilitychange`,s)}}}var Ar=`ryugi:read-since`;function jr(){try{let e=JSON.parse(globalThis.localStorage?.getItem(Ar)??`null`);return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}catch{return{}}}var Mr=e=>!!e&&typeof e.peer==`string`&&typeof e.counter==`number`;function Nr(e){let t=e;return!!t&&typeof t.at==`string`&&Array.isArray(t.frontiers)&&t.frontiers.every(Mr)&&Array.isArray(t.seen)&&t.seen.every(e=>typeof e==`string`)}function Pr(e){let t=jr()[e];return Nr(t)?t:null}function Fr(e,t){let n=jr();delete n[e],n[e]=t;let r=Object.keys(n);for(let e of r.slice(0,Math.max(0,r.length-200)))delete n[e];try{globalThis.localStorage?.setItem(Ar,JSON.stringify(n))}catch{return}}var Ir=2e3,Lr=400,Rr=300,zr=()=>new Date().toISOString();function Br(e){let t=e.oplogVersion();try{return t.remove(e.peerIdStr),e.vvToFrontiers(t)}catch{return e.frontiers()}finally{t.free()}}function Vr({properties:e,id:t,doc:n,nodes:r,streaming:i,active:a}){let[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(new Set),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(0),v=(0,q.useRef)(new Map),y=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!n)return;let e=Pr(t),r=e??{frontiers:Br(n),seen:[],at:zr()};e||Fr(t,r),s({baseline:r.frontiers,earlier:r.seen,at:r.at}),l(null),d(new Set),p(!1),h(null)},[t,n]),(0,q.useEffect)(()=>{if(!n)return;let e,t=n.subscribe(t=>{t.by===`import`&&(clearTimeout(e),e=setTimeout(()=>_(e=>e+1),Lr))});return()=>{clearTimeout(e),t()}},[n]),(0,q.useEffect)(()=>{if(!n||!o||i)return;let t=!1,a=Br(n);return Or(n,o.baseline,r,new Set(o.earlier),e).then(e=>{t||l({frontiers:a,compacted:e.kind===`compacted`,changes:e.kind===`changes`?e.changes:[]})},()=>void 0),()=>{t=!0}},[n,o,r,i,g,e]);let b=(0,q.useMemo)(()=>c?.changes??[],[c]),x=b.filter(e=>!u.has(e.key)).length,S=b.length>0&&x===0;(0,q.useEffect)(()=>{o&&c&&!c.compacted&&(S?Fr(t,{frontiers:c.frontiers,seen:[],at:zr()}):u.size&&Fr(t,{frontiers:o.baseline,seen:[...o.earlier,...u],at:o.at}))},[t,o,c,u,S]),(0,q.useEffect)(()=>{x>0&&p(!1)},[x]),(0,q.useEffect)(()=>{if(!S||f)return;let e=setTimeout(()=>p(!0),Ir);return()=>clearTimeout(e)},[S,f]);let C=wt()===`clear`&&S&&f;(0,q.useEffect)(()=>{if(!C||!c)return;let e=setTimeout(()=>{v.current=new Map,y.current?.clear(),s({baseline:c.frontiers,earlier:[],at:zr()}),d(new Set),h(null)},vt()?0:Rr);return()=>clearTimeout(e)},[C,c]),(0,q.useEffect)(()=>{let e=kr({onSeen:e=>d(t=>new Set(t).add(e))});return y.current=e,()=>{e.dispose(),y.current=null}},[]),(0,q.useEffect)(()=>y.current?.setPaused(!a),[a]);let w=(0,q.useRef)(u);w.current=u;let T=(0,q.useCallback)(()=>{let e=new Map([...v.current].filter(([e])=>!w.current.has(e)));y.current?.track(e)},[]),E=(0,q.useCallback)(e=>{v.current=e,T()},[T]);(0,q.useEffect)(T,[u,T]);let D=e=>{if(!b.length)return;let t=m===null?e>0?0:b.length-1:(m+e+b.length)%b.length;h(t),v.current.get(b[t].key)?.scrollIntoView?.({block:`center`,behavior:`instant`})},O=()=>{if(c?.compacted&&n){let e=Br(n);Fr(t,{frontiers:e,seen:[],at:zr()}),l({frontiers:e,compacted:!1,changes:[]})}d(new Set(b.map(e=>e.key))),p(!0)},k=c?.compacted??!1;return{baseline:o?.baseline??null,changes:b,compacted:k,done:S,focused:m===null?null:b[m]?.key??null,leaving:C,markAll:O,next:()=>D(1),prev:()=>D(-1),onElements:E,position:(m??0)+1,seen:u,since:o?Date.parse(o.at)/1e3:0,unread:x,visible:a&&!f&&(k||b.length>0)}}function Hr({since:e,ask:t,bottom:n}){let r=e!==null||t!==null,i=fn(r),[o,s]=(0,q.useState)(!1),l=(0,q.useRef)(null);if((0,q.useLayoutEffect)(()=>{l.current?.getBoundingClientRect(),s(i)},[i]),!i)return null;let u=r&&o;return(0,J.jsxs)(c,{"data-chrome":`bottom-bar`,position:`fixed`,ref:l,style:{gap:0,...n===void 0?{}:{bottom:n},opacity:+!!u,transform:`translateX(-50%) translateY(${u?0:8}px)`,transition:vt()?`none`:`opacity 400ms ${bt}, transform 400ms ${bt}`},children:[(0,J.jsx)(Y,{"data-since-bar":``,gap:0,show:e!==null,children:e}),(0,J.jsxs)(Y,{lead:12,show:e!==null&&t!==null,children:[(0,J.jsx)(a,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(Y,{"data-ask-bar":``,show:t!==null,children:t})]})}function Ur({properties:e,id:t,doc:n,editor:r,nodes:i,streaming:a,active:o,asks:s,theme:c,phone:l,onCompare:u}){let d=ln(s),f=Vr({id:t,doc:n,nodes:i,streaming:a,active:o,properties:e}),p=[...new Set(f.changes.map(e=>e.author??`Agent`))].join(`, `)||`Agent`;return(0,J.jsxs)(J.Fragment,{children:[o&&r&&f.changes.length?(0,J.jsx)(Un,{changes:f.changes,editor:r,focused:f.focused,leaving:f.leaving,seen:f.seen,theme:c,onElements:f.onElements}):null,(0,J.jsx)(Hr,{ask:d,bottom:l?90:void 0,since:f.visible?(0,J.jsx)(bn,{agent:p,compact:l,compacted:f.compacted,done:f.done,merged:d!==null,position:f.position,since:f.since,total:f.changes.length,unread:f.unread,onCompare:()=>f.baseline&&u(f.baseline),onMarkAll:f.markAll,onNext:f.next,onPrev:f.prev}):null})]})}var Wr=60;function Gr(e,t={}){let n=new Map,r,i,a;return e.forEach(e=>{let{message:o,timestamp:s}=e,c=R(o),l=Wn(e,t);if(!l){n.size&&(c===`agent`||c===`human`||c===`session`)&&(r={kind:c===`session`?`unknown`:c,name:c===`agent`?`Agent`:c===`human`?`Human`:`Unknown`,at:s},c===`agent`&&(i={name:`Agent`,at:s}),c===`session`&&(i=void 0),a=void 0);return}if(c===`unknown`||c===`session`&&n.size>0)return;let u=c===`human`?`human`:`agent`,d=u+`\0`+l.name,f=n.get(d);f||(f={kind:u,name:l.name,models:[],edits:0,lastAt:s},n.set(d,f)),l.avatar&&(f.avatar=l.avatar),l.model&&(f.models=[l.model,...f.models.filter(e=>e!==l.model)]),(a?.key!==d||s-a.at>Wr)&&(f.edits+=1),f.lastAt=Math.max(f.lastAt,s),a={key:d,at:s},r={kind:u,name:l.name,at:s},u===`agent`&&(i={name:l.name,at:s})}),{contributors:[...n.values()].map(({avatar:e,...t})=>({kind:t.kind,name:t.name,...e&&{avatar:e},models:t.models,edits:t.edits,lastAt:t.lastAt})),...r&&{last:r},...i&&{lastAgent:i}}}var Kr=500,qr=(e,t)=>Gr([...e.getAllChanges().values()].flat().sort(br),{properties:t,lineage:e.getTree(F).roots()[0]?.id});function Jr(e,t){let[n,r]=(0,q.useState)(()=>e?qr(e,t):{contributors:[]});return(0,q.useEffect)(()=>{if(!e)return;let n;r(qr(e,t));let i=e.subscribe(()=>{clearTimeout(n),n=setTimeout(()=>r(qr(e,t)),Kr)});return()=>{clearTimeout(n),i()}},[e,t]),n}var Yr=280,Xr=`cubic-bezier(.2, .7, .2, 1)`,Zr={transform:`none`,filter:`none`,opacity:1},Qr={transform:`translateY(-10px) scale(.965)`,filter:`brightness(.9)`,opacity:1},$r={transform:`scale(1.045)`,filter:`none`,opacity:0};function ei(e,t,n){let r=(0,q.useRef)(null),i=(0,q.useRef)(null),a=(0,q.useRef)(n);return(0,q.useLayoutEffect)(()=>{a.current=n},[n]),(0,q.useLayoutEffect)(()=>{let e=r.current,t=a.current;if(r.current=null,!e||e.from===t||!e.paper.isConnected)return;i.current?.();let{leaf:n,paper:o}=e,s=t>e.from;n.style.zIndex=s?`3`:`1`,o.after(n),n.querySelector(`.history-space-scroll`).scrollTop=e.scrollTop;let c=s?[n.animate([Zr,$r],{duration:Yr,easing:`cubic-bezier(.4, 0, .6, 1)`,fill:`forwards`}),o.animate([Qr,Zr],{duration:Yr,easing:Xr})]:[o.animate([$r,Zr],{duration:Yr,easing:Xr}),n.animate([Zr,Qr],{duration:Yr,easing:Xr,fill:`forwards`})],l=()=>{i.current===l&&(i.current=null,c.forEach(e=>e.cancel()),n.remove())};i.current=l,Promise.all(c.map(e=>e.finished)).then(l,l)},[t]),t=>{if(vt())return;let n=e.current?.closest(`.history-space-shell`)?.querySelector(`.history-space-paper:not(.history-space-leaf)`),i=n?.querySelector(`.history-space-scroll`);if(!n||!i||typeof n.animate!=`function`)return;let a=document.createElement(`div`);a.className=`history-space-paper history-space-leaf`,a.setAttribute(`aria-hidden`,`true`),a.inert=!0;let o=i.cloneNode(!0);o.removeAttribute(`tabindex`),a.append(o),r.current={from:r.current?.from??t,leaf:a,paper:n,scrollTop:i.scrollTop}}}function ti({model:e,theme:t,title:n}){if(!e.comparison)return null;let r=e.comparison.snapshot.value;return(0,J.jsxs)(`section`,{"aria-busy":e.loading,"aria-label":V(`history.versionContent`),className:`history-space-snapshot`,hidden:e.mode!==`snapshot`,children:[r.root.children.some(e=>e.type===`heading`&&e.tag===`h1`)?null:(0,J.jsx)(`h1`,{className:`history-content-title`,children:n}),(0,J.jsx)(Pn,{theme:t,value:r})]})}function ni({model:e,title:t}){let{session:n,selected:r,comparison:i,loading:a,mode:o,error:s}=e,c=n?.history.groups??[],l=Sn(e),u=Math.max(0,l?c.indexOf(l):0),d=r?.id===n?.history.entries.at(-1)?.id,f=(0,q.useRef)(null),m=(0,q.useRef)(null),_=ei(f,i,u),v=t=>{t.id!==e.selected?.id&&(_(u),e.select(t))},y=(0,q.useRef)({choose:v,groups:c,at:u});(0,q.useLayoutEffect)(()=>{y.current={choose:v,groups:c,at:u}});let b=(0,q.useRef)(-1/0),S=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=e=>{let{choose:t,groups:n}=y.current,r=n[Math.max(0,Math.min(n.length-1,e))]?.entries.at(-1);r&&t(r)},t=t=>{if(f.current?.closest(`.history-space-shell`)&&!f.current.closest(`[data-open]`)||t.altKey||t.ctrlKey||t.metaKey||t.target?.closest?.(`input,textarea,select,[contenteditable="true"],[role="menu"]`))return;let n=t.key===`ArrowDown`?y.current.at+1:t.key===`ArrowUp`?y.current.at-1:t.key===`Home`?0:t.key===`End`?y.current.groups.length-1:null;n!==null&&(t.preventDefault(),e(n))},n=t=>{(!f.current?.closest(`.history-space-shell`)||f.current.closest(`[data-open]`))&&(t.preventDefault(),Math.abs(t.deltaY)<4||performance.now()-b.current<260||(b.current=performance.now(),e(y.current.at+Math.sign(t.deltaY))))};document.addEventListener(`keydown`,t);let r=f.current;return r?.addEventListener(`wheel`,n,{passive:!1}),()=>{document.removeEventListener(`keydown`,t),r?.removeEventListener(`wheel`,n)}},[]),(0,q.useEffect)(()=>{S.current?.scrollIntoView?.({block:`nearest`})},[r]);let w=e=>{let t=c[e]?.entries.at(-1);t&&v(t)},T=i?.from??r,E=Math.max(0,Math.min(u-20,c.length-50));return(0,J.jsxs)(B,{appearance:`dark`,className:`history-space-ui`,children:[(0,J.jsxs)(`header`,{className:`history-space-header`,ref:m,children:[(0,J.jsx)(g,{"aria-hidden":!0,size:16}),(0,J.jsx)(`strong`,{children:V(`history.title`)}),(0,J.jsx)(`span`,{className:`history-space-name`,children:t}),(0,J.jsxs)(`div`,{"aria-label":V(`history.selectedVersion`),className:`history-space-caption`,role:`group`,children:[r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`strong`,{className:`history-space-clock`,children:d?V(`history.now`):X(r.change.timestamp)}),(0,J.jsx)(`span`,{children:_n(r.change.timestamp)}),(0,J.jsxs)(`span`,{className:`history-space-source`,children:[(0,J.jsx)(D,{"aria-hidden":!0,size:12}),l?l.author??V(xn[l.source]):null]})]}):null,(0,J.jsx)(`div`,{"aria-live":`polite`,className:`history-space-description`,role:`status`,children:s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`strong`,{children:V(`history.failed`)}),(0,J.jsx)(`span`,{children:s}),(0,J.jsx)(`button`,{disabled:e.streaming,type:`button`,onClick:e.refresh,children:V(`common.retry`)})]}):a||!n?(0,J.jsx)(H,{label:e.streaming?V(`history.waitingEdits`):V(`history.loading`),size:14}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:d?V(`history.currentDocument`):o===`compare`?V(`history.changes`,{count:e.count}):V(`history.readingVersion`)}),o===`compare`&&!d?(0,J.jsx)(`span`,{children:V(`history.compareWithLatest`,{time:vn(n.history.entries.at(-1)?.change.timestamp??0)})}):null]})}),l&&l.entries.length>1?(0,J.jsx)(Tt,{placement:`bottomLeft`,portalProps:{container:m},items:[...l.entries].reverse().map(e=>({icon:e.id===r?.id?p:void 0,key:e.id,label:X(e.change.timestamp,!0),onClick:()=>v(e)})),children:(0,J.jsx)(x,{outdent:!0,className:`history-space-commits`,icon:(0,J.jsx)(h,{"aria-hidden":!0,size:14}),iconPosition:`end`,size:`small`,type:`text`,children:V(`history.commits`,{count:l.entries.length})})}):null]}),(0,J.jsx)(`span`,{"aria-live":`polite`,className:`history-space-updating`,children:a&&T?V(`history.loading`):``}),(0,J.jsxs)(`div`,{className:`history-space-actions`,children:[(0,J.jsx)(`div`,{"aria-label":V(`history.viewMode`),role:`group`,children:(0,J.jsx)(Et,{value:o,options:[{label:V(`history.versionContent`),value:`snapshot`},{disabled:!i||d,label:V(`history.compareNow`),value:`compare`}],onChange:e.setMode})}),(0,J.jsx)(x,{"data-history-exit":!0,icon:(0,J.jsx)(Dt,{"aria-hidden":!0,size:14}),iconPosition:`end`,onClick:e.close,children:V(`history.backToNow`)})]})]}),(0,J.jsx)(`div`,{"aria-label":V(`history.olderVersion`),className:`history-space-stack`,role:`group`,children:c.slice(u+1,u+3).map((e,t)=>(0,J.jsx)(`button`,{"aria-label":vn(e.entries.at(-1).change.timestamp),className:`history-space-sheet`,style:{"--depth":t+1},type:`button`,onClick:()=>w(u+t+1)},e.id))}),(0,J.jsxs)(`div`,{className:`history-space-side`,children:[(0,J.jsxs)(`nav`,{"aria-label":V(`history.chooseStart`),className:`history-space-steps`,children:[(0,J.jsx)(`button`,{"aria-label":V(`history.newerVersion`),disabled:!n||d,type:`button`,onClick:()=>w(Math.max(0,u-1)),children:(0,J.jsx)(C,{"aria-hidden":!0,size:17})}),n?(0,J.jsxs)(`span`,{children:[u+1,` / `,c.length]}):null,(0,J.jsx)(`button`,{"aria-label":V(`history.olderVersion`),disabled:!n||u>=c.length-1,type:`button`,onClick:()=>w(u+1),children:(0,J.jsx)(h,{"aria-hidden":!0,size:17})})]}),(0,J.jsxs)(`nav`,{"aria-label":V(`history.timeline`),className:`history-space-rail`,ref:f,children:[E>0?(0,J.jsx)(`button`,{className:`history-space-more`,type:`button`,onClick:()=>w(Math.max(0,E-25)),children:V(`history.newerVersion`)}):null,(0,J.jsx)(`ol`,{children:c.slice(E,E+50).map((e,t)=>{let n=E+t,r=e.entries.at(-1),i=_n(r.change.timestamp),a=t===0||i!==_n(c[n-1].entries.at(-1).change.timestamp);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{"aria-current":n===u?`true`:void 0,"aria-label":vn(r.change.timestamp),ref:n===u?S:void 0,type:`button`,onClick:()=>v(r),children:[(0,J.jsxs)(`span`,{children:[n===0?V(`history.now`):X(r.change.timestamp),a?(0,J.jsx)(`small`,{children:i}):null]}),(0,J.jsx)(`i`,{"aria-hidden":!0})]})},e.id)})}),E+50<c.length?(0,J.jsx)(`button`,{className:`history-space-more`,type:`button`,onClick:()=>w(E+50),children:V(`history.loadEarlier`)}):n?(0,J.jsx)(`p`,{children:V(n.history.shallow?`history.shallow`:`history.earliest`)}):null]}),(0,J.jsx)(`div`,{className:`history-space-notice`,children:(0,J.jsx)(En,{compact:!0,model:e})}),(0,J.jsx)(`span`,{className:`history-space-keyboard`,children:V(`history.keyboardHint`)})]})]})}var ri=e=>JSON.stringify(e.frontiers()),ii=(e,t)=>t===void 0?void 0:e[t];function ai({properties:e,doc:t,from:n,nodes:r,streaming:i,theme:a,title:o,open:s,onClose:c}){let[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null),p=(0,q.useRef)(null),m=(0,q.useRef)(null),h=(0,q.useRef)(null),g=(0,q.useRef)(0),[_,v]=(0,q.useState)(!0),[y,b]=(0,q.useState)(null),[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(!1),[D,O]=(0,q.useState)(0),[k,A]=(0,q.useState)(!1),[ee,j]=(0,q.useState)(`snapshot`),[te,ne]=le(k),M=ze(`(max-width: 1100px)`),re=(0,q.useRef)(null),ie=(0,q.useCallback)(async()=>{if(!t)return;let i=++g.current;v(!0),b(null);let a=t.fork();try{let o=await xr(a,e),s=Cr(a,a.frontiers(),r);if(g.current!==i){a.free();return}let c=h.current;h.current=a;let l=p.current&&o.entries.find(e=>e.id===p.current.id),d=!p.current&&n?Sr(a,o,n):null,_=d??(!M&&p.current?.id===m.current?o.entries.at(-1):l)??(M?o.groups[1]?.entries.at(-1):o.entries.at(-1))??o.entries[0]??null;d&&j(`compare`),p.current=_,m.current=o.entries.at(-1)?.id??null,f(_),u({doc:a,history:o,latest:s}),S(ri(t)!==ri(a)),c?.free()}catch(e){a.free(),g.current===i&&b(e.message)}finally{g.current===i&&v(!1)}},[t,r,M,n,e]),N=(0,q.useRef)(e);if((0,q.useEffect)(()=>{N.current!==e&&(N.current=e,s&&!i&&h.current&&ie())},[e,s,i,ie]),(0,q.useEffect)(()=>{if(s)return()=>{g.current++,h.current?.free(),h.current=null,p.current=null,m.current=null,u(null),f(null),w(null),S(!1),b(null),v(!0),A(!1),E(!1),j(`snapshot`)}},[s,t]),(0,q.useEffect)(()=>{s&&!i&&!h.current&&ie()},[s,ie,i]),(0,q.useEffect)(()=>{if(s&&t)return t.subscribe(()=>S(h.current!==null&&ri(t)!==ri(h.current)))},[t,s]),(0,q.useEffect)(()=>{if(!s)return;let e=e=>{e.key===`Escape`&&(k?A(!1):c())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s,c,k]),(0,q.useEffect)(()=>{if(!l||!d)return;let e=!1;v(!0);let t=setTimeout(()=>{try{let t=Cr(l.doc,d.frontiers,r),{entries:n,groups:i}=l.history,a=Tr(l.doc,n.slice(n.indexOf(d)+1),[t,l.latest]),o=new Map(i.flatMap(e=>e.entries.map(t=>[t,e]))),s=vr(t.value,l.latest.value).map(e=>{if(e.kind===`equal`)return e;let n=[ii(l.latest.ids,e.newIndex),ii(t.ids,e.oldIndex)].map(e=>e&&a.get(e)).find(Boolean);return n?{...e,author:n,group:o.get(n)}:e});e||(w({blocks:s,latest:l.latest,from:d,snapshot:t}),O(0),b(null))}catch(t){e||b(t.message)}finally{e||v(!1)}},0);return()=>{e=!0,clearTimeout(t)}},[l,d,r]),!s||!t)return null;let ae=C?.blocks??[],oe=ae.filter(e=>e.kind!==`equal`).length,P={session:l,selected:d,blocks:ae,count:oe,comparison:C,changeIndex:D,loading:_,mode:ee,setMode:j,error:y,pending:x,streaming:i,onlyChanges:T,select:e=>{e.id!==p.current?.id&&(v(!0),e.id===l?.history.entries.at(-1)?.id&&j(`snapshot`),p.current=e,f(e),A(!1))},navigate:e=>{let t=Math.max(0,Math.min(oe-1,D+e));O(t),(re.current?.querySelectorAll(`[data-history-change]`))?.[t]?.scrollIntoView?.({block:`center`,behavior:`instant`})},toggleOnly:()=>E(e=>!e),showAll:()=>E(!1),refresh:()=>void ie(),close:c};return{ready:C!==null,immersive:!M,space:M?null:(0,J.jsx)(ni,{model:P,title:o}),content:(0,J.jsxs)(J.Fragment,{children:[M?null:(0,J.jsx)(ti,{model:P,theme:a,title:o}),(0,J.jsx)(`div`,{hidden:!M&&ee!==`compare`,children:(0,J.jsx)(Fn,{bodyRef:re,model:P,narrow:M,theme:a,title:o,onPick:()=>A(!0)})}),M&&te?(0,J.jsx)(On,{model:P,open:k,onDismiss:()=>A(!1),onExited:ne}):null]}),panel:null}}var oi=[...De.filter(e=>!Ce.some(t=>t.getType()===(`getType`in e?e.getType():e.replace.getType()))),...Ce];function si(e){let t=new Map;for(let n of e){if(!n.artboard)continue;let e=t.get(n.artboard)??{artboard:n.artboard,count:0};e.count+=1,!e.to&&n.to&&(e.to=n.to),t.set(n.artboard,e)}return[...t.values()]}function ci({refs:e,onOpen:t}){let{t:n}=Pe(),[r,i]=(0,q.useState)(!1),a=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!r)return;let e=e=>{a.current?.contains(e.target)||i(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[r]);let o=si(e);return o.length?(0,J.jsxs)(`div`,{ref:a,className:`x1n2onr6`,children:[(0,J.jsxs)(`button`,{"data-linked-boards":!0,"aria-expanded":r,type:`button`,onClick:()=>i(e=>!e),className:`x3nfvp2 x6s0dn4 x17d4w8g x1fgtraw x1awh872 xmkeg23 x1y0btm7 x12xov25 xur7f20 xjbqb8w xo2rkog xjb2p0i xfifm61 x1ypdohk xj0l527`,children:[(0,J.jsx)(Ot,{size:14}),n(`refs.linked`),(0,J.jsx)(`span`,{className:`xddlp02 xss6m8b`,children:o.length}),(0,J.jsx)(h,{size:13})]}),r&&(0,J.jsxs)(`div`,{role:`menu`,className:`x10l6tqk xwwefxd x3m8u43 x1355qak xdzyupr x1ruevkc x1q4ynmn x12ilycc x1d5q07e`,children:[(0,J.jsx)(`div`,{className:`xtxj4hr x1qt5hsa xddlp02`,children:n(`refs.linkedHint`)}),o.map(({artboard:e,count:r,to:a})=>(0,J.jsxs)(`button`,{"data-linked-board":e,role:`menuitem`,type:`button`,onClick:()=>{i(!1),t(a?{artboard:e,to:a}:{artboard:e})},className:`x78zum5 x6s0dn4 x883omv xh8yej3 xe8ttls xc342km xu4hgxq xjbqb8w xo2rkog xjb2p0i x4z9k3i x1yc453h x1ypdohk xj0l527`,children:[(0,J.jsx)(Ot,{size:15}),(0,J.jsx)(`span`,{className:`x98rzlu xeuugli xb3r6kr xlyipyv`,children:e}),(0,J.jsx)(`span`,{className:`x1qt5hsa xddlp02`,children:n(`refs.count`,{count:r})}),(0,J.jsx)(Gt,{size:15})]},e))]})]}):null}function li({editing:e,pending:t,agentActiveAt:n,now:r}){return e?{kind:`editing`}:t===0?{kind:`idle`}:{kind:`working`,pending:t,idleMs:n===void 0?null:Math.max(0,r-n)}}function ui(e){return e<6e4?G.t(`time.seconds`,{count:Math.floor(e/1e3)}):e<36e5?G.t(`time.minutes`,{count:Math.floor(e/6e4)}):G.t(`time.hours`,{count:Math.floor(e/36e5)})}function di(e,t,n){switch(e.kind){case`editing`:return n?G.t(`activity.editingSection`,{agent:t,section:n}):G.t(`activity.editing`,{agent:t});case`idle`:return null;case`working`:{let n=G.t(`activity.pending`,{agent:t,count:e.pending});return e.idleMs===null?n:e.idleMs<1e4?G.t(`activity.updatedJustNow`,{left:n}):G.t(`activity.updatedAgo`,{left:n,duration:ui(e.idleMs)})}}}function fi(e,t,n){switch(e.kind){case`editing`:return{agent:t,detail:n?G.t(`activity.brief.editingSection`,{section:n}):G.t(`activity.brief.editing`),time:null};case`idle`:return null;case`working`:{let n=G.t(`activity.brief.left`,{count:e.pending});return e.idleMs===null?{agent:t,detail:n,time:null}:{agent:t,detail:n,time:e.idleMs<1e4?G.t(`activity.brief.justNow`):G.t(`activity.brief.ago`,{duration:ui(e.idleMs)})}}}}function pi({id:e,title:t,activity:n,agentSection:r,offline:i,openComments:a,cloud:o,compact:s=!1,onDone:c,actions:l,agent:u=`Agent`,history:d,exportState:p,onExport:m,toolbar:h=!1}){let g=o?di(n,u,r):null,v=o?fi(n,u,r):null,[y,b,x]=[v?.agent,v?.detail,v?.time??null],S=(0,q.useMemo)(()=>y===void 0||b===void 0?null:{agent:y,detail:b,time:x},[y,b,x]),C=f(e,o?{...t?{title:t}:{},online:o.online,comments:a,activity:g,activityParts:S,activityTone:n.kind===`working`?`quiet`:`live`,retrying:i,reason:o.reason,history:d?.available,historyOpen:d?.open,documentExport:p,toolbar:h&&!s}:null);return C&&!s?null:(0,J.jsxs)(`header`,{"data-doc-topbar":!0,...{0:{className:`x7wzq59 x13vifvy x1n327nk xdd8jsf x78zum5 x6s0dn4 x1v2ro7d x1hr3lfm x1rozbrz xqfszdh`},1:{className:`x7wzq59 x13vifvy x1n327nk xdd8jsf x78zum5 x6s0dn4 x1hr3lfm x1rozbrz xqfszdh x883omv`}}[!!s|0],children:[s?null:(0,J.jsxs)(`span`,{className:`x1bo0w0s xfifm61 xuxw1ft`,children:[V(`type.document`),` / `,(0,J.jsx)(`span`,{className:`xo2rkog x1s688f`,children:e})]}),g?(0,J.jsxs)(`span`,{...{0:{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla xlssvyo x19ay2w6 x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv`},1:{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xahzvm9 x1bo0w0s`}}[n.kind===`working`|0],children:[(0,J.jsx)(`i`,{className:`x1v4s8kt xols6we x16rqkct xtwfq29`}),g]}):null,i?(0,J.jsx)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xqdcvd7 x7zghnd`,children:V(`document.notSynced`)}):null,d?.open?(0,J.jsxs)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xahzvm9 x1bo0w0s`,children:[(0,J.jsx)(At,{"aria-hidden":`true`,size:11}),V(`document.readOnlyHistory`)]}):null,o?.reason&&!s?(0,J.jsx)(`span`,{className:`xb3r6kr xddlp02 xfifm61 xuxw1ft xlyipyv`,children:o.reason}):null,(0,J.jsx)(`span`,{className:`x98rzlu`}),o?(0,J.jsxs)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g x1bo0w0s xfifm61 xuxw1ft`,children:[(0,J.jsx)(`i`,{...{0:{className:`xci0xqf x1hagigm x16rqkct xxwmxtg`},1:{className:`xci0xqf x1hagigm x16rqkct xux1nz0`}}[!!o.online|0]}),o.online?V(`share.computerOnline`):V(`share.computerOffline`)]}):null,d?(0,J.jsx)(_,{available:d.available,comments:a,compact:s,open:d.open,onComments:d.close,onHistory:d.toggle}):null,C?null:(0,J.jsx)(jt,{state:p,onExport:m}),c?(0,J.jsx)(`button`,{type:`button`,onClick:c,className:`x12ulsxz xaope02 xc342km x1kogg8i x19ckca5 xs0jrwl xqfszdh x4z9k3i x1s688f x1ypdohk`,children:V(`common.done`)}):o||s?null:l]})}function mi(e,t,n){let[r,i]=t<=n?[t,n]:[n,t];return{blockIds:e.slice(r,i+1).flatMap(e=>e.id?[e.id]:[]).slice(0,Mt.blockIds),heading:e.slice(0,r+1).filter(e=>e.heading).pop()?.text??``}}var hi=crypto.randomUUID(),gi=300,_i={quote:``,blockIds:[],heading:``};function vi(e){let t=e.read(()=>{let e=te();if(!O(e))return null;let t=j().getChildren(),n=t.filter(t=>e.has(t.getKey()));if(!n.length)return null;let r=t.indexOf(n[0]),{heading:i}=mi(t.map(e=>({id:A(e,ue),heading:e.getType()===`heading`,text:e.getTextContent()})),r,r);return{heading:i.slice(0,Mt.heading),blockIds:n.map(e=>A(e,ue)).filter(Boolean).slice(0,Mt.blockIds),quote:n.map(e=>e.getTextContent()).join(`
3
+ `)[0]||V(`history.sourceUnknown`)})]},t.id))}):null]},n.id)})}),n<l.length?(0,J.jsx)(`button`,{type:`button`,...U(Z.buttonBase,Z.more),onClick:()=>r(e=>e+50),children:V(`history.loadEarlier`)}):(0,J.jsxs)(`p`,{...U(Z.end),children:[V(d?`history.shallow`:`history.earliest`),` ·`,` `,V(`history.summary`,{edits:V(`history.edits`,{count:l.length}),commits:V(`history.commits`,{count:u.length})}),(0,J.jsx)(`br`,{}),V(`history.clockNote`)]})]})}function On({model:e,open:t,onDismiss:n,onExited:r}){let i=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!t)return;let e=document.activeElement,n=i.current,r=()=>[...n?.querySelectorAll(`button:not(:disabled), a[href], input:not(:disabled), [tabindex="0"]`)??[]];r()[0]?.focus();let a=e=>{if(e.key!==`Tab`)return;let t=r();e.shiftKey&&document.activeElement===t[0]?(e.preventDefault(),t.at(-1)?.focus()):!e.shiftKey&&document.activeElement===t.at(-1)&&(e.preventDefault(),t[0]?.focus())};return n?.addEventListener(`keydown`,a),()=>{n?.removeEventListener(`keydown`,a),e?.focus()}},[t]);let a=(0,J.jsxs)(`div`,{...U(Z.sheetHead),children:[(0,J.jsxs)(`span`,{...U(Z.sheetHeadText),children:[(0,J.jsx)(`strong`,{...U(Z.sheetTitle),children:V(`history.chooseStart`)}),(0,J.jsx)(`small`,{...U(Z.sheetSmall),children:V(`history.compareWithLatest`,{time:vn(Cn(e))})})]}),(0,J.jsx)(`button`,{type:`button`,...U(Z.buttonBase,Z.sheetButton),onClick:n,children:V(`common.done`)})]});return(0,J.jsx)(`div`,{"aria-label":V(`history.chooseStart`),"aria-modal":`true`,inert:!t,ref:i,role:`dialog`,...U(Z.text,Z.sheet),children:(0,J.jsx)(gt,{header:a,open:t,snap:.85,snaps:[0,.85],onExited:r,onScrim:n,onSnap:e=>{e===0&&n()},children:(0,J.jsx)(`div`,{...U(Z.sheetBody),children:(0,J.jsx)(Dn,{sheet:!0,model:e})})})})}var kn=[z,xe,...St,se,he],An={[ve]:re,[Ee]:Ae,[ye]:N,[L]:de},jn={insert:`history.kindInsert`,delete:`history.kindDelete`,modify:`history.kindModify`};function Mn(e){return q.Children.toArray(e).map(e=>(0,q.isValidElement)(e)?Mn(e.props.children):String(e)).join(``)}var Nn={table:(e,t,n,r)=>{let i=r();return(0,q.isValidElement)(i)?(0,q.cloneElement)(i,{tabIndex:0}):i},heading:(e,t,n,r)=>{let i=r();if(!(0,q.isValidElement)(i))return i;let a=Mn(i.props.children);return(0,q.cloneElement)(i,void 0,q.Children.map(i.props.children,e=>(0,q.isValidElement)(e)&&e.type===`a`?(0,q.cloneElement)(e,{"aria-label":a}):e))}},Pn=(0,q.memo)(function({value:e,theme:t}){return(0,J.jsx)(pe,{children:(0,J.jsx)(it,{builtinNodeOverrides:Nn,extraNodes:kn,rendererConfig:An,theme:t,value:e,variant:`article`})})},(e,t)=>e.theme===t.theme&&JSON.stringify(e.value)===JSON.stringify(t.value));function Fn({model:e,theme:t,title:n,narrow:r,bodyRef:i,onPick:a}){let{comparison:o,selected:s,count:c,changeIndex:l,loading:u,error:d,streaming:f,onlyChanges:p}=e,m=[U(Z.text).className,`history-view`].filter(Boolean).join(` `),g=-1,_=o?.blocks.flatMap(e=>e.kind===`equal`?e.value.root.children.map((t,n)=>({...e,newIndex:e.newIndex+n,value:{root:{...e.value.root,children:[t]}}})):[e])??[],v=(0,q.use)(fe)?.toolbarSlot,y=U(Z.strip,v&&Z.bar),b=r?(0,J.jsxs)(`div`,{...y,className:[y.className,v&&`history-bar`].filter(Boolean).join(` `),children:[(0,J.jsxs)(`button`,{type:`button`,...U(Z.buttonBase,Z.pick,v&&Z.pickRow),onClick:a,children:[(0,J.jsx)(`span`,{...U(Z.pickSpan),children:V(`history.compareFrom`)}),(0,J.jsxs)(`strong`,{...U(Z.pickStrong),children:[V(`history.toLatest`,{from:s?vn(s.change.timestamp):V(`history.pickPoint`)}),(0,J.jsx)(h,{"aria-hidden":`true`,size:12})]})]}),(0,J.jsx)(Tn,{model:e}),(0,J.jsx)(wn,{strip:!0,model:e})]}):null,x=_.filter(e=>e.kind===`equal`&&e.value.root.children[0]?.type!==`heading`).length;return(0,J.jsxs)(`div`,{className:m,children:[b&&v?(0,Yt.createPortal)(b,v):b,r?(0,J.jsx)(En,{compact:!0,model:e}):null,r&&(u||d)?(0,J.jsx)(`div`,{className:`history-inline-status`,role:d?`alert`:`status`,children:d?(0,J.jsxs)(J.Fragment,{children:[V(`history.readFailed`,{error:d}),` `,(0,J.jsx)(`button`,{disabled:f,type:`button`,onClick:e.refresh,children:V(`common.retry`)})]}):(0,J.jsx)(H,{label:V(f?`history.waitingEdits`:`history.computing`),size:14})}):null,o?(0,J.jsxs)(`div`,{"aria-busy":u,"aria-label":V(`history.diffBody`),className:`history-content`,ref:i,role:`region`,children:[o.latest.value.root.children.some(e=>e.type===`heading`&&e.tag===`h1`)?null:(0,J.jsx)(`h1`,{className:`history-content-title`,children:n}),_.map(e=>{let n=e.kind!==`equal`;n&&g++;let r=n?g:-1,i=e.kind!==`delete`,a=e.value.root.children[0],s=a?.type===`heading`?a.tag:void 0,c=(i?o.latest.value.root.children[e.newIndex]:null)?.$?.blockId,u=s&&i?{root:{...o.latest.value.root,children:[o.latest.value.root.children[e.newIndex]]}}:e.value,d=i?o.latest.ids[e.newIndex]??`current-`+e.newIndex:`deleted-`+e.oldIndex;return(0,J.jsxs)(`section`,{className:`history-block`,"data-current":n&&r===l?``:void 0,"data-folded":!n&&p&&!s?``:void 0,"data-heading":s,"data-history-block-id":c,"data-history-change":n?``:void 0,"data-history-index":i?e.newIndex:void 0,"data-kind":e.kind,children:[(0,J.jsx)(`div`,{className:`history-current`,children:i?(0,J.jsx)(Pn,{theme:t,value:u}):null}),(0,J.jsx)(`div`,{className:`history-before`,children:(0,J.jsx)(`div`,{className:`history-before-inner`,children:e.before||e.kind===`delete`?(0,J.jsxs)(`div`,{className:`history-old-content`,children:[(0,J.jsxs)(`div`,{className:`history-caption`,children:[(0,J.jsx)(`span`,{children:V(jn[e.kind])}),e.author?(0,J.jsxs)(`span`,{children:[vn(e.author.change.timestamp),e.group?` · `+(e.group.author??V(xn[e.group.source])):``]}):null]}),(0,J.jsx)(Pn,{theme:t,value:e.before??e.value})]}):null})})]},d)}),p&&x>0?(0,J.jsx)(`button`,{className:`history-expand`,type:`button`,onClick:e.showAll,children:V(`history.unchanged`,{count:x})}):null,c?null:(0,J.jsx)(`p`,{className:`history-no-diff`,role:`status`,children:V(`history.noDiff`)}),(0,J.jsx)(`p`,{...U(Z.end),children:V(`history.endOfDiff`)})]}):null]})}function In(e,t){return e.read(()=>{let n=j().getChildren(),r=new Map;for(let e of n){let t=A(e,ue);t&&r.set(t,e)}let i=new Map;for(let a of t){let t=a.blockId&&r.get(a.blockId)||n[a.index];i.set(a.key,t?e.getElementByKey(t.getKey()):null)}return i})}var Ln=28,Rn=12,zn=36,Bn=6,Vn={insert:`history.kindInsert`,delete:`history.kindDelete`,modify:`history.kindModify`};function Hn(e){let[t,n]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let t=()=>n(e=>e+1),r=e.getRootElement(),i=typeof ResizeObserver==`function`?new ResizeObserver(t):null;r&&i?.observe(r);let a=e.registerUpdateListener(t);return window.addEventListener(`resize`,t),()=>{a(),i?.disconnect(),window.removeEventListener(`resize`,t)}},[e]),t}function Un({editor:e,changes:t,seen:n,focused:r,leaving:i=!1,theme:a,onElements:o}){let{t:s}=Pe(),c=Hn(e),[l,u]=(0,q.useState)([]),[d,f]=(0,q.useState)(new Set),[p,m]=(0,q.useState)({}),h=(0,q.useRef)(new Map),g=(0,q.useRef)(new Map),_=e.getRootElement(),v=_?_.offsetParent??_.parentElement:null;if((0,q.useLayoutEffect)(()=>{if(!_||!v)return u([]);let n=In(e,t);g.current=n;let r=_.lastElementChild,i=[],a=e=>(p[e]??Ln)+24;for(let e of t){if(e.kind!==`delete`)continue;let t=n.get(e.key)??r;t&&(t.dataset.sinceDeleted=n.get(e.key)?`before`:`after`,t.style.setProperty(`--since-gap`,`${a(e.key)}px`),i.push(t))}let o=v.getBoundingClientRect(),s=_.getBoundingClientRect(),c=e=>e-o.top+v.scrollTop,l=e=>e-o.left+v.scrollLeft,d=e=>l(Math.max(e-zn,Bn)),f=[];for(let e of t){let t=n.get(e.key);if(e.kind!==`delete`){if(!t)continue;let n=t.getBoundingClientRect();f.push({key:e.key,bar:d(n.left),top:c(n.top),height:n.height,left:l(n.left),width:n.width});continue}let i=t??r;if(!i)continue;let o=i.getBoundingClientRect(),u=a(e.key);f.push({key:e.key,bar:d(s.left),top:t?c(o.top)-u+Rn:c(o.bottom)+Rn,height:u-24,left:l(s.left),width:s.width})}return u(f),()=>i.forEach(e=>{delete e.dataset.sinceDeleted,e.style.removeProperty(`--since-gap`)})},[e,_,v,t,c,p]),(0,q.useLayoutEffect)(()=>{let e={};for(let t of d){let n=h.current.get(t)?.querySelector(`[data-since-row-body]`);n&&(e[t]=Ln+n.offsetHeight)}Object.keys(e).length===Object.keys(p).length&&Object.entries(e).every(([e,t])=>p[e]===t)||m(e)},[d,l,p]),(0,q.useLayoutEffect)(()=>{if(!o)return;let e=new Map;for(let n of t){let t=n.kind===`delete`?h.current.get(n.key):g.current.get(n.key);t&&e.set(n.key,t)}o(e)},[l,t,o]),!v)return null;let y=new Map(t.map(e=>[e.key,e])),b=l.find(e=>e.key===r&&y.get(e.key)?.kind!==`delete`),x=e=>f(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,Yt.createPortal)((0,J.jsxs)(`div`,{className:`since-marks`,"data-leaving":i?``:void 0,"data-since-marks":``,children:[b?(0,J.jsx)(`div`,{className:`since-focus`,"data-since-focus":``,style:{top:b.top-4,left:b.left-12,width:b.width+24,height:b.height+8}}):null,l.map(e=>{let t=y.get(e.key);if(!t)return null;let i={"data-seen":n.has(e.key)?``:void 0,"data-focused":r===e.key?``:void 0};if(t.kind===`delete`){let n=d.has(e.key);return(0,J.jsxs)(`div`,{className:`since-row`,"data-since-deleted-row":e.key,style:{top:e.top,left:e.left,width:e.width,minHeight:Ln},ref:t=>{t?h.current.set(e.key,t):h.current.delete(e.key)},...i,children:[(0,J.jsx)(`span`,{className:`since-row-bar`,style:{left:e.bar-e.left}}),(0,J.jsxs)(`div`,{className:`since-row-head`,children:[(0,J.jsx)(`span`,{children:s(`sinceRead.deleted`,{count:t.count})}),(0,J.jsx)(`span`,{className:`since-row-rule`}),(0,J.jsx)(`button`,{"data-since-expand":``,type:`button`,onClick:()=>x(e.key),children:s(n?`sinceRead.collapse`:`sinceRead.expand`)})]}),n&&t.deleted?(0,J.jsx)(`div`,{className:`since-row-body`,"data-since-row-body":``,children:(0,J.jsx)(Pn,{theme:a,value:t.deleted})}):null]},e.key)}return(0,J.jsx)(`div`,{className:`since-mark`,"data-since-mark":e.key,style:{top:e.top,left:e.bar-4.5,height:e.height},...i,children:(0,J.jsxs)(`span`,{className:`since-tip`,children:[(0,J.jsx)(`b`,{children:t.author??`Agent`}),s(Vn[t.kind]),` · `,xt(t.at*1e3)]})},e.key)})]}),v)}function Wn(e,{properties:t,lineage:n}={}){let r=I(e.message);if(r)return r;if(R(e.message)!==`agent`||!t||t.lineage!==n||!t.baseline||e.peer===void 0||e.counter===void 0||!e.length)return;let i=t.baseline;for(let n of t.batches){if(e.counter>=(i[e.peer]??0)&&e.counter+e.length<=(n.through[e.peer]??0))return n.by;i=n.through}}function Gn(e,t){return e.map(e=>{let n=Wn(e,t);return n&&!I(e.message)?{...e,message:Se(e.message??``,n)}:e})}var Kn=5e4,qn=`background-color: color-mix(in srgb, var(--rc-alert-caution) 22%, transparent); text-decoration: line-through;`,Jn=`background-color: color-mix(in srgb, var(--rc-alert-tip) 22%, transparent);`;function Yn(e){let t=e;return t.type===`heading`?`heading:${t.tag}`:t.type===`list`?`list:${t.listType}`:t.type||`unknown`}function Xn(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Zn(e){let t=e;return t.type===`text`&&typeof t.text==`string`}function Qn(e){let t=e;return Array.isArray(t.children)?t.children:null}function $n(e,t){let n=typeof e==`string`?e.trim():``;return n?`${n}${n.endsWith(`;`)?``:`;`} ${t}`:t}function er(e,t,n){let{style:r}=e;return n===`delete`?r=$n(r,qn):n===`insert`&&(r=$n(r,Jn)),{...e,text:t,style:r}}function tr(e,t){return{...e,children:t}}function Q(e,t){if(Zn(e))return er(e,e.text,t);let n=Qn(e);return n?tr(e,n.map(e=>Q(e,t))):e}function nr(e){return Array.from(e).reverse().join(``)}function rr(e){let t=[];for(let n of e){if(!n.text)continue;let e=t.at(-1);e&&e.kind===n.kind?e.text+=n.text:t.push({...n})}return t}function ir(e,t){let n=e.length,r=t.length;if(n===0&&r===0)return[];if(n===0)return[{kind:`insert`,text:t.join(``)}];if(r===0)return[{kind:`delete`,text:e.join(``)}];if(n*r>Kn)return[{kind:`delete`,text:e.join(``)},{kind:`insert`,text:t.join(``)}];let i=Array.from({length:n+1},()=>Array.from({length:r+1}).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++)e[a-1]===t[n-1]?i[a][n]=i[a-1][n-1]+1:i[a][n]=Math.max(i[a-1][n],i[a][n-1]);let a=[],o=n,s=r;for(;o>0&&s>0;)if(e[o-1]===t[s-1]){let t=a.at(-1);t&&t.kind===`equal`?t.text+=e[o-1]:a.push({kind:`equal`,text:e[o-1]}),o--,s--}else if(i[o-1][s]>=i[o][s-1]){let t=a.at(-1);t&&t.kind===`delete`?t.text+=e[o-1]:a.push({kind:`delete`,text:e[o-1]}),o--}else{let e=a.at(-1);e&&e.kind===`insert`?e.text+=t[s-1]:a.push({kind:`insert`,text:t[s-1]}),s--}for(;o>0;){let t=a.at(-1);t&&t.kind===`delete`?t.text+=e[o-1]:a.push({kind:`delete`,text:e[o-1]}),o--}for(;s>0;){let e=a.at(-1);e&&e.kind===`insert`?e.text+=t[s-1]:a.push({kind:`insert`,text:t[s-1]}),s--}return rr(a.reverse().map(e=>({kind:e.kind,text:nr(e.text)})))}function ar(e,t){let n=Array.from(e),r=Array.from(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;let a=n.length-1,o=r.length-1;for(;a>=i&&o>=i&&n[a]===r[o];)a--,o--;let s=[];return i>0&&s.push({kind:`equal`,text:n.slice(0,i).join(``)}),s.push(...ir(n.slice(i,a+1),r.slice(i,o+1))),a<n.length-1&&s.push({kind:`equal`,text:n.slice(a+1).join(``)}),rr(s)}function or(e,t){let n=ar(e.text,t.text),r=[],i=[],a=!1;for(let o of n)o.text&&(o.kind===`equal`?(r.push(er(e,o.text)),i.push(er(t,o.text))):(a=!0,o.kind===`delete`?r.push(er(e,o.text,`delete`)):i.push(er(t,o.text,`insert`))));return{oldNodes:r.length>0?r:[e],newNodes:i.length>0?i:[t],changed:a}}function sr(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array.from({length:r+1}).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++){let r=Math.max(i[a-1][n],i[a][n-1]);if(Yn(e[a-1])===Yn(t[n-1])){let o=Xn(e[a-1],t[n-1])?2:1;i[a][n]=Math.max(r,i[a-1][n-1]+o)}else i[a][n]=r}let a=[],o=n,s=r;for(;o>0&&s>0;){if(Yn(e[o-1])===Yn(t[s-1])){let n=Xn(e[o-1],t[s-1]),r=n?2:1;if(i[o][s]===i[o-1][s-1]+r){a.push(n?{kind:`equal`,node:e[o-1]}:{kind:`modify`,oldNode:e[o-1],newNode:t[s-1]}),o--,s--;continue}}i[o-1][s]>=i[o][s-1]?(a.push({kind:`delete`,node:e[o-1]}),o--):(a.push({kind:`insert`,node:t[s-1]}),s--)}for(;o>0;)a.push({kind:`delete`,node:e[--o]});for(;s>0;)a.push({kind:`insert`,node:t[--s]});return a.reverse(),a}function cr(e,t){let n=sr(e,t),r=[],i=[],a=!1;for(let e of n)switch(e.kind){case`equal`:r.push(e.node),i.push(e.node);break;case`delete`:a=!0,r.push(Q(e.node,`delete`));break;case`insert`:a=!0,i.push(Q(e.node,`insert`));break;case`modify`:{if(a=!0,Zn(e.oldNode)&&Zn(e.newNode)){let t=or(e.oldNode,e.newNode);r.push(...t.oldNodes),i.push(...t.newNodes);break}let t=lr(e.oldNode,e.newNode);t?(r.push(t.oldNode),i.push(t.newNode)):(r.push(Q(e.oldNode,`delete`)),i.push(Q(e.newNode,`insert`)));break}}return{oldChildren:r,newChildren:i,changed:a}}function lr(e,t){if(Yn(e)!==Yn(t))return null;if(Xn(e,t))return{oldNode:e,newNode:t,changed:!1};let n=Qn(e),r=Qn(t);if(!n||!r)return null;let i=cr(n,r);return i.changed?{oldNode:tr(e,i.oldChildren),newNode:tr(t,i.newChildren),changed:!0}:{oldNode:e,newNode:t,changed:!1}}function ur(e,t){let n=lr(e,t);return n?{oldNode:n.oldNode,newNode:n.newNode}:{oldNode:Q(e,`delete`),newNode:Q(t,`insert`)}}function dr(e,t){let n=sr(e.root.children,t.root.children),r=[];for(let e of n)switch(e.kind){case`equal`:{let t=r.at(-1);t&&t.type===`equal`?t.nodes.push(e.node):r.push({type:`equal`,nodes:[e.node]});break}case`modify`:{let t=ur(e.oldNode,e.newNode);r.push({type:`delete`,nodes:[t.oldNode]},{type:`insert`,nodes:[t.newNode]})}break;case`delete`:r.push({type:`delete`,nodes:[Q(e.node,`delete`)]});break;case`insert`:r.push({type:`insert`,nodes:[Q(e.node,`insert`)]})}return r}function fr(e){let t={...e};if(t.$){let{blockId:e,...n}=t.$;Object.keys(n).length?t.$=n:delete t.$}return t.children&&=t.children.map(fr),t}function pr(e,t){let{children:n,text:r,...i}=e,{children:a,text:o,...s}=t;return JSON.stringify(i)!==JSON.stringify(s)||!!(n&&a&&_r(n,a).some(e=>e.kind===`modify`&&pr(e.old[0],e.current[0])))}function mr(e){let t=e;return t.type===`dynamic`||t.type===`pending`?{type:`paragraph`,version:1,direction:null,format:``,indent:0,children:[{type:`text`,version:1,text:t.type===`dynamic`?G.t(`history.dynamic`,{url:t.url,height:t.initialHeight??320,props:JSON.stringify(t.props??{})}):G.t(`history.pendingIntent`,{intent:t.intent??``}),format:0,detail:0,mode:`normal`,style:``}]}:t.children?{...t,children:t.children.map(mr)}:t}function hr(e){return gr(e.map(mr))}function gr(e){return{root:{type:`root`,version:1,direction:null,format:``,indent:0,children:e}}}function _r(e,t){let n=dr(gr(e),gr(t)),r=[],i=0,a=0;for(let o=0;o<n.length;o++){let s=n[o];if(s.type===`equal`){r.push({kind:`equal`,old:e.slice(i,i+s.nodes.length),current:t.slice(a,a+s.nodes.length),oldIndex:i,newIndex:a}),i+=s.nodes.length,a+=s.nodes.length;continue}let c=0,l=0;for(;o<n.length&&n[o].type!==`equal`;){let e=n[o++];e.type===`delete`?c+=e.nodes.length:l+=e.nodes.length}o--;for(let n=0;n<Math.max(c,l);n++){let o=n<c?[e[i+n]]:[],s=n<l?[t[a+n]]:[];r.push({kind:o.length&&s.length?`modify`:o.length?`delete`:`insert`,old:o,current:s,oldIndex:o.length?i+n:void 0,newIndex:s.length?a+n:void 0})}i+=c,a+=l}return r}function vr(e,t){return _r(e.root.children.map(fr),t.root.children.map(fr)).map(e=>{let t={oldIndex:e.oldIndex,newIndex:e.newIndex};if(e.kind===`modify`){let n=e.old[0],r=e.current[0],i=n.type===r.type&&!pr(n,r)?ur(n,r):null;return i?{kind:`modify`,before:hr([i.oldNode]),value:hr([i.newNode]),...t}:{kind:`modify`,before:hr(e.old),value:hr(e.current),...t}}let n=e.kind===`delete`?e.old:e.current;return{kind:e.kind,value:hr(e.kind===`equal`?n:n.map(t=>Q(t,e.kind))),...t}})}var yr=e=>`${e.counter}@${e.peer}`,br=(e,t)=>e.lamport-t.lamport||e.peer.localeCompare(t.peer)||e.counter-t.counter;async function xr(e,t){await new Promise(e=>setTimeout(e,0));let n=Gn([...e.getAllChanges().values()].flat(),{properties:t,lineage:e.getTree(F).roots()[0]?.id}).sort(br),r=e.shallowSinceFrontiers(),i=new Map(r.map(e=>[yr(e),e])),a=[],o=[];for(let e of n){for(let t of e.deps)i.delete(yr(t));i.delete(yr({peer:e.peer,counter:e.counter-1}));let t={peer:e.peer,counter:e.counter+e.length-1};i.set(yr(t),t);let n={id:`${e.counter}@${e.peer}`,change:e,frontiers:[...i.values()]};a.push(n);let r=R(e.message),s=Te(e.message),c=o.at(-1),l=c?.entries.at(-1)?.change;c&&l&&r!==`unknown`&&c.source===r&&c.author===s&&l.peer===e.peer&&l.timestamp>0&&e.timestamp>=l.timestamp&&e.timestamp-l.timestamp<=60?(c.entries.push(n),c.id=n.id):o.push({id:n.id,source:r,...s&&{author:s},entries:[n]}),a.length%200==0&&await new Promise(e=>setTimeout(e,0))}return{entries:a,groups:o.reverse(),shallow:r.length>0}}function Sr(e,t,n){if(!n.length)return null;for(let r=t.entries.length-1;r>=0;r--){let i=t.entries[r];try{let t=e.cmpFrontiers(i.frontiers,n);if(t===0||t===-1)return i}catch{return null}}return null}function Cr(e,t,n){let r=e.fork(),i;try{r.checkout(t);let e=r.getTree(F).roots();if(e.length!==1)throw Error(G.t(`history.contentUnavailable`));let a=ee({nodes:n,editable:!1,onError:e=>{throw e}});i=_e(a,r);let o=e[0].children()??[],s=new Map,c=(e,t)=>{s.set(e.id,t),e.children()?.forEach(e=>c(e,t))};return o.forEach(e=>c(e,e.id)),{value:a.getEditorState().toJSON(),ids:o.map(e=>e.id),owners:s}}finally{i?.dispose(),r.free()}}var wr=/^cid:(\d+@\d+):Map$/;function Tr(e,t,n){let r=new Map(n.flatMap(e=>[...e.owners])),i=e.getTree(F),a=new Map,o=new Map(t.map((e,t)=>[e,t])),s=(e,t)=>{let n=a.get(e);(!n||o.get(n)<o.get(t))&&a.set(e,t)};for(let n of t){let{peer:t,counter:i,length:a}=n.change;for(let o of e.getChangedContainersIn({peer:t,counter:i},a)){let t=e.getContainerById(o);for(;t;){let e=wr.exec(t.id)?.[1],i=e&&r.get(e);if(i){s(i,n);break}t=t.parent()}}}let c=e=>e&&t.find(({change:t})=>t.peer===e.peer&&t.counter<=e.counter&&e.counter<t.counter+t.length);for(let e of new Set(r.values())){if(!i.isNodeDeleted(e))continue;let t=c(i.getNodeByID(e)?.getLastMoveId());t&&s(e,t)}return a}var Er=e=>!!e&&(e.startsWith(`agent:`)||e.startsWith(`session `));function Dr(e,t){try{e.frontiersToVV(t).free()}catch{return!1}let n=e.shallowSinceFrontiers();if(!n.length)return!0;let r=e.cmpFrontiers(t,n);return r===0||r===1}async function Or(e,t,n,r,i){if(!Dr(e,t))return{kind:`compacted`};let a=t=>Wn(t,{properties:i,lineage:e.getTree(F).roots()[0]?.id})?.name,{forward:o}=e.findIdSpansBetween(t,e.frontiers());if(!o.length)return{kind:`changes`,changes:[]};let s=e.fork();try{await new Promise(e=>setTimeout(e,0));let e=[];for(let t of o){let n=t.counter;for(;n<t.counter+t.length;){let r=s.getChangeAt({peer:t.peer,counter:n});Er(r.message)&&e.push({change:r}),n=r.counter+r.length}}if(e.sort((e,t)=>br(e.change,t.change)),!e.length)return{kind:`changes`,changes:[]};let i=Cr(s,t,n),c=Cr(s,s.frontiers(),n),l=Tr(s,e,[i,c]),u=(e,{change:t})=>`${e}@${t.counter+t.length-1}@${t.peer}`,d=(...e)=>e.map(e=>e&&l.get(e)).find(e=>!!e),f=new Set(c.ids),p=new Set(i.ids),m=s.getTree(F),h=[...e].reverse().find(({change:e})=>s.getChangedContainersIn({peer:e.peer,counter:e.counter},e.length).includes(m.id)),g=e=>e&&p.has(e)?h:void 0,_=new Set,v=c.value.root.children,y=[],b=0,x=null,S=()=>{x&&=(x.change.deleted={root:{...c.value.root,children:x.nodes}},r.has(x.change.key)||y.push(x.change),null)};for(let e of vr(i.value,c.value)){if(e.kind===`delete`){let t=i.ids[e.oldIndex];if(t&&f.has(t))continue;let n=d(t);if(!n){S();continue}let r=a(n.change);x&&x.change.author!==r&&S(),x?(x.change.count++,x.nodes.push(...e.value.root.children),n.change.timestamp>x.change.at&&(x.change.at=n.change.timestamp)):x={change:{key:u(t,n),author:r,kind:`delete`,index:b,count:1,at:n.change.timestamp},nodes:[...e.value.root.children]};continue}if(S(),b=e.newIndex+1,e.kind===`equal`){b=e.newIndex+e.value.root.children.length;continue}let t=c.ids[e.newIndex],n=e.kind===`insert`&&!!t&&p.has(t),o=d(t,e.oldIndex===void 0?void 0:i.ids[e.oldIndex])??(n?g(t):void 0);if(!o)continue;let s=u(t,o);if(r.has(s)||_.has(s))continue;_.add(s);let l=v[e.newIndex]?.$?.blockId;y.push({key:s,author:a(o.change),kind:n?`modify`:e.kind,index:e.newIndex,count:1,at:o.change.timestamp,...typeof l==`string`?{blockId:l}:{}})}return S(),{kind:`changes`,changes:y}}finally{s.free()}}function kr({onSeen:e,dwellMs:t=1e3}){let n=new Map,r=!1,i=()=>!r&&document.visibilityState===`visible`,a=e=>{clearTimeout(e.timer),e.timer=void 0},o=(r,o)=>{if(!o.inView||!i())return a(o);o.timer===void 0&&(o.timer=setTimeout(()=>{c.unobserve(r),n.delete(r),e(o.key)},t))},s=()=>n.forEach((e,t)=>o(t,e)),c=new IntersectionObserver(e=>{for(let{target:t,intersectionRatio:r,intersectionRect:i}of e){let e=n.get(t);e&&(e.inView=r>=.5||i.height>=window.innerHeight/2,o(t,e))}},{threshold:[0,.25,.5,.75,1]});document.addEventListener(`visibilitychange`,s);let l=()=>{n.forEach((e,t)=>{a(e),c.unobserve(t)}),n.clear()},u=(e,t)=>{let r=n.get(t);r?.key!==e&&(r&&a(r),n.set(t,{key:e,inView:!1}),c.observe(t))};return{observe:u,track:e=>{let t=new Map([...e].map(([e,t])=>[t,e]));n.forEach((e,r)=>{t.get(r)!==e.key&&(a(e),c.unobserve(r),n.delete(r))}),e.forEach((e,t)=>u(t,e))},clear:l,setPaused:e=>{r=e,s()},dispose:()=>{l(),c.disconnect(),document.removeEventListener(`visibilitychange`,s)}}}var Ar=`ryugi:read-since`;function jr(){try{let e=JSON.parse(globalThis.localStorage?.getItem(Ar)??`null`);return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}catch{return{}}}var Mr=e=>!!e&&typeof e.peer==`string`&&typeof e.counter==`number`;function Nr(e){let t=e;return!!t&&typeof t.at==`string`&&Array.isArray(t.frontiers)&&t.frontiers.every(Mr)&&Array.isArray(t.seen)&&t.seen.every(e=>typeof e==`string`)}function Pr(e){let t=jr()[e];return Nr(t)?t:null}function Fr(e,t){let n=jr();delete n[e],n[e]=t;let r=Object.keys(n);for(let e of r.slice(0,Math.max(0,r.length-200)))delete n[e];try{globalThis.localStorage?.setItem(Ar,JSON.stringify(n))}catch{return}}var Ir=2e3,Lr=400,Rr=300,zr=()=>new Date().toISOString();function Br(e){let t=e.oplogVersion();try{return t.remove(e.peerIdStr),e.vvToFrontiers(t)}catch{return e.frontiers()}finally{t.free()}}function Vr({properties:e,id:t,doc:n,nodes:r,streaming:i,active:a}){let[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(new Set),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(0),v=(0,q.useRef)(new Map),y=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!n)return;let e=Pr(t),r=e??{frontiers:Br(n),seen:[],at:zr()};e||Fr(t,r),s({baseline:r.frontiers,earlier:r.seen,at:r.at}),l(null),d(new Set),p(!1),h(null)},[t,n]),(0,q.useEffect)(()=>{if(!n)return;let e,t=n.subscribe(t=>{t.by===`import`&&(clearTimeout(e),e=setTimeout(()=>_(e=>e+1),Lr))});return()=>{clearTimeout(e),t()}},[n]),(0,q.useEffect)(()=>{if(!n||!o||i)return;let t=!1,a=Br(n);return Or(n,o.baseline,r,new Set(o.earlier),e).then(e=>{t||l({frontiers:a,compacted:e.kind===`compacted`,changes:e.kind===`changes`?e.changes:[]})},()=>void 0),()=>{t=!0}},[n,o,r,i,g,e]);let b=(0,q.useMemo)(()=>c?.changes??[],[c]),x=b.filter(e=>!u.has(e.key)).length,S=b.length>0&&x===0;(0,q.useEffect)(()=>{o&&c&&!c.compacted&&(S?Fr(t,{frontiers:c.frontiers,seen:[],at:zr()}):u.size&&Fr(t,{frontiers:o.baseline,seen:[...o.earlier,...u],at:o.at}))},[t,o,c,u,S]),(0,q.useEffect)(()=>{x>0&&p(!1)},[x]),(0,q.useEffect)(()=>{if(!S||f)return;let e=setTimeout(()=>p(!0),Ir);return()=>clearTimeout(e)},[S,f]);let C=wt()===`clear`&&S&&f;(0,q.useEffect)(()=>{if(!C||!c)return;let e=setTimeout(()=>{v.current=new Map,y.current?.clear(),s({baseline:c.frontiers,earlier:[],at:zr()}),d(new Set),h(null)},vt()?0:Rr);return()=>clearTimeout(e)},[C,c]),(0,q.useEffect)(()=>{let e=kr({onSeen:e=>d(t=>new Set(t).add(e))});return y.current=e,()=>{e.dispose(),y.current=null}},[]),(0,q.useEffect)(()=>y.current?.setPaused(!a),[a]);let w=(0,q.useRef)(u);w.current=u;let T=(0,q.useCallback)(()=>{let e=new Map([...v.current].filter(([e])=>!w.current.has(e)));y.current?.track(e)},[]),E=(0,q.useCallback)(e=>{v.current=e,T()},[T]);(0,q.useEffect)(T,[u,T]);let D=e=>{if(!b.length)return;let t=m===null?e>0?0:b.length-1:(m+e+b.length)%b.length;h(t),v.current.get(b[t].key)?.scrollIntoView?.({block:`center`,behavior:`instant`})},O=()=>{if(c?.compacted&&n){let e=Br(n);Fr(t,{frontiers:e,seen:[],at:zr()}),l({frontiers:e,compacted:!1,changes:[]})}d(new Set(b.map(e=>e.key))),p(!0)},k=c?.compacted??!1;return{baseline:o?.baseline??null,changes:b,compacted:k,done:S,focused:m===null?null:b[m]?.key??null,leaving:C,markAll:O,next:()=>D(1),prev:()=>D(-1),onElements:E,position:(m??0)+1,seen:u,since:o?Date.parse(o.at)/1e3:0,unread:x,visible:a&&!f&&(k||b.length>0)}}function Hr({since:e,ask:t,bottom:n}){let r=e!==null||t!==null,i=fn(r),[o,s]=(0,q.useState)(!1),l=(0,q.useRef)(null);if((0,q.useLayoutEffect)(()=>{l.current?.getBoundingClientRect(),s(i)},[i]),!i)return null;let u=r&&o;return(0,J.jsxs)(c,{"data-chrome":`bottom-bar`,position:`fixed`,ref:l,style:{gap:0,...n===void 0?{}:{bottom:n},opacity:+!!u,transform:`translateX(-50%) translateY(${u?0:8}px)`,transition:vt()?`none`:`opacity 400ms ${bt}, transform 400ms ${bt}, padding-inline-start 400ms ${bt}`},children:[(0,J.jsx)(Y,{"data-since-bar":``,gap:0,show:e!==null,children:e}),(0,J.jsxs)(Y,{lead:12,show:e!==null&&t!==null,children:[(0,J.jsx)(a,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(Y,{"data-ask-bar":``,show:t!==null,children:t})]})}function Ur({properties:e,id:t,doc:n,editor:r,nodes:i,streaming:a,active:o,asks:s,theme:c,phone:l,onCompare:u}){let d=ln(s),f=Vr({id:t,doc:n,nodes:i,streaming:a,active:o,properties:e}),p=[...new Set(f.changes.map(e=>e.author??`Agent`))].join(`, `)||`Agent`;return(0,J.jsxs)(J.Fragment,{children:[o&&r&&f.changes.length?(0,J.jsx)(Un,{changes:f.changes,editor:r,focused:f.focused,leaving:f.leaving,seen:f.seen,theme:c,onElements:f.onElements}):null,(0,J.jsx)(Hr,{ask:d,bottom:l?90:void 0,since:f.visible?(0,J.jsx)(bn,{agent:p,compact:l,compacted:f.compacted,done:f.done,merged:d!==null,position:f.position,since:f.since,total:f.changes.length,unread:f.unread,onCompare:()=>f.baseline&&u(f.baseline),onMarkAll:f.markAll,onNext:f.next,onPrev:f.prev}):null})]})}var Wr=60;function Gr(e,t={}){let n=new Map,r,i,a;return e.forEach(e=>{let{message:o,timestamp:s}=e,c=R(o),l=Wn(e,t);if(!l){n.size&&(c===`agent`||c===`human`||c===`session`)&&(r={kind:c===`session`?`unknown`:c,name:c===`agent`?`Agent`:c===`human`?`Human`:`Unknown`,at:s},c===`agent`&&(i={name:`Agent`,at:s}),c===`session`&&(i=void 0),a=void 0);return}if(c===`unknown`||c===`session`&&n.size>0)return;let u=c===`human`?`human`:`agent`,d=u+`\0`+l.name,f=n.get(d);f||(f={kind:u,name:l.name,models:[],edits:0,lastAt:s},n.set(d,f)),l.avatar&&(f.avatar=l.avatar),l.model&&(f.models=[l.model,...f.models.filter(e=>e!==l.model)]),(a?.key!==d||s-a.at>Wr)&&(f.edits+=1),f.lastAt=Math.max(f.lastAt,s),a={key:d,at:s},r={kind:u,name:l.name,at:s},u===`agent`&&(i={name:l.name,at:s})}),{contributors:[...n.values()].map(({avatar:e,...t})=>({kind:t.kind,name:t.name,...e&&{avatar:e},models:t.models,edits:t.edits,lastAt:t.lastAt})),...r&&{last:r},...i&&{lastAgent:i}}}var Kr=500,qr=(e,t)=>Gr([...e.getAllChanges().values()].flat().sort(br),{properties:t,lineage:e.getTree(F).roots()[0]?.id});function Jr(e,t){let[n,r]=(0,q.useState)(()=>e?qr(e,t):{contributors:[]});return(0,q.useEffect)(()=>{if(!e)return;let n;r(qr(e,t));let i=e.subscribe(()=>{clearTimeout(n),n=setTimeout(()=>r(qr(e,t)),Kr)});return()=>{clearTimeout(n),i()}},[e,t]),n}var Yr=280,Xr=`cubic-bezier(.2, .7, .2, 1)`,Zr={transform:`none`,filter:`none`,opacity:1},Qr={transform:`translateY(-10px) scale(.965)`,filter:`brightness(.9)`,opacity:1},$r={transform:`scale(1.045)`,filter:`none`,opacity:0};function ei(e,t,n){let r=(0,q.useRef)(null),i=(0,q.useRef)(null),a=(0,q.useRef)(n);return(0,q.useLayoutEffect)(()=>{a.current=n},[n]),(0,q.useLayoutEffect)(()=>{let e=r.current,t=a.current;if(r.current=null,!e||e.from===t||!e.paper.isConnected)return;i.current?.();let{leaf:n,paper:o}=e,s=t>e.from;n.style.zIndex=s?`3`:`1`,o.after(n),n.querySelector(`.history-space-scroll`).scrollTop=e.scrollTop;let c=s?[n.animate([Zr,$r],{duration:Yr,easing:`cubic-bezier(.4, 0, .6, 1)`,fill:`forwards`}),o.animate([Qr,Zr],{duration:Yr,easing:Xr})]:[o.animate([$r,Zr],{duration:Yr,easing:Xr}),n.animate([Zr,Qr],{duration:Yr,easing:Xr,fill:`forwards`})],l=()=>{i.current===l&&(i.current=null,c.forEach(e=>e.cancel()),n.remove())};i.current=l,Promise.all(c.map(e=>e.finished)).then(l,l)},[t]),t=>{if(vt())return;let n=e.current?.closest(`.history-space-shell`)?.querySelector(`.history-space-paper:not(.history-space-leaf)`),i=n?.querySelector(`.history-space-scroll`);if(!n||!i||typeof n.animate!=`function`)return;let a=document.createElement(`div`);a.className=`history-space-paper history-space-leaf`,a.setAttribute(`aria-hidden`,`true`),a.inert=!0;let o=i.cloneNode(!0);o.removeAttribute(`tabindex`),a.append(o),r.current={from:r.current?.from??t,leaf:a,paper:n,scrollTop:i.scrollTop}}}function ti({model:e,theme:t,title:n}){if(!e.comparison)return null;let r=e.comparison.snapshot.value;return(0,J.jsxs)(`section`,{"aria-busy":e.loading,"aria-label":V(`history.versionContent`),className:`history-space-snapshot`,hidden:e.mode!==`snapshot`,children:[r.root.children.some(e=>e.type===`heading`&&e.tag===`h1`)?null:(0,J.jsx)(`h1`,{className:`history-content-title`,children:n}),(0,J.jsx)(Pn,{theme:t,value:r})]})}function ni({model:e,title:t}){let{session:n,selected:r,comparison:i,loading:a,mode:o,error:s}=e,c=n?.history.groups??[],l=Sn(e),u=Math.max(0,l?c.indexOf(l):0),d=r?.id===n?.history.entries.at(-1)?.id,f=(0,q.useRef)(null),m=(0,q.useRef)(null),_=ei(f,i,u),v=t=>{t.id!==e.selected?.id&&(_(u),e.select(t))},y=(0,q.useRef)({choose:v,groups:c,at:u});(0,q.useLayoutEffect)(()=>{y.current={choose:v,groups:c,at:u}});let b=(0,q.useRef)(-1/0),S=(0,q.useRef)(null);(0,q.useEffect)(()=>{let e=e=>{let{choose:t,groups:n}=y.current,r=n[Math.max(0,Math.min(n.length-1,e))]?.entries.at(-1);r&&t(r)},t=t=>{if(f.current?.closest(`.history-space-shell`)&&!f.current.closest(`[data-open]`)||t.altKey||t.ctrlKey||t.metaKey||t.target?.closest?.(`input,textarea,select,[contenteditable="true"],[role="menu"]`))return;let n=t.key===`ArrowDown`?y.current.at+1:t.key===`ArrowUp`?y.current.at-1:t.key===`Home`?0:t.key===`End`?y.current.groups.length-1:null;n!==null&&(t.preventDefault(),e(n))},n=t=>{(!f.current?.closest(`.history-space-shell`)||f.current.closest(`[data-open]`))&&(t.preventDefault(),Math.abs(t.deltaY)<4||performance.now()-b.current<260||(b.current=performance.now(),e(y.current.at+Math.sign(t.deltaY))))};document.addEventListener(`keydown`,t);let r=f.current;return r?.addEventListener(`wheel`,n,{passive:!1}),()=>{document.removeEventListener(`keydown`,t),r?.removeEventListener(`wheel`,n)}},[]),(0,q.useEffect)(()=>{S.current?.scrollIntoView?.({block:`nearest`})},[r]);let w=e=>{let t=c[e]?.entries.at(-1);t&&v(t)},T=i?.from??r,E=Math.max(0,Math.min(u-20,c.length-50));return(0,J.jsxs)(B,{appearance:`dark`,className:`history-space-ui`,children:[(0,J.jsxs)(`header`,{className:`history-space-header`,ref:m,children:[(0,J.jsx)(g,{"aria-hidden":!0,size:16}),(0,J.jsx)(`strong`,{children:V(`history.title`)}),(0,J.jsx)(`span`,{className:`history-space-name`,children:t}),(0,J.jsxs)(`div`,{"aria-label":V(`history.selectedVersion`),className:`history-space-caption`,role:`group`,children:[r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`strong`,{className:`history-space-clock`,children:d?V(`history.now`):X(r.change.timestamp)}),(0,J.jsx)(`span`,{children:_n(r.change.timestamp)}),(0,J.jsxs)(`span`,{className:`history-space-source`,children:[(0,J.jsx)(D,{"aria-hidden":!0,size:12}),l?l.author??V(xn[l.source]):null]})]}):null,(0,J.jsx)(`div`,{"aria-live":`polite`,className:`history-space-description`,role:`status`,children:s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`strong`,{children:V(`history.failed`)}),(0,J.jsx)(`span`,{children:s}),(0,J.jsx)(`button`,{disabled:e.streaming,type:`button`,onClick:e.refresh,children:V(`common.retry`)})]}):a||!n?(0,J.jsx)(H,{label:e.streaming?V(`history.waitingEdits`):V(`history.loading`),size:14}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:d?V(`history.currentDocument`):o===`compare`?V(`history.changes`,{count:e.count}):V(`history.readingVersion`)}),o===`compare`&&!d?(0,J.jsx)(`span`,{children:V(`history.compareWithLatest`,{time:vn(n.history.entries.at(-1)?.change.timestamp??0)})}):null]})}),l&&l.entries.length>1?(0,J.jsx)(Tt,{placement:`bottomLeft`,portalProps:{container:m},items:[...l.entries].reverse().map(e=>({icon:e.id===r?.id?p:void 0,key:e.id,label:X(e.change.timestamp,!0),onClick:()=>v(e)})),children:(0,J.jsx)(x,{outdent:!0,className:`history-space-commits`,icon:(0,J.jsx)(h,{"aria-hidden":!0,size:14}),iconPosition:`end`,size:`small`,type:`text`,children:V(`history.commits`,{count:l.entries.length})})}):null]}),(0,J.jsx)(`span`,{"aria-live":`polite`,className:`history-space-updating`,children:a&&T?V(`history.loading`):``}),(0,J.jsxs)(`div`,{className:`history-space-actions`,children:[(0,J.jsx)(`div`,{"aria-label":V(`history.viewMode`),role:`group`,children:(0,J.jsx)(Et,{value:o,options:[{label:V(`history.versionContent`),value:`snapshot`},{disabled:!i||d,label:V(`history.compareNow`),value:`compare`}],onChange:e.setMode})}),(0,J.jsx)(x,{"data-history-exit":!0,icon:(0,J.jsx)(Dt,{"aria-hidden":!0,size:14}),iconPosition:`end`,onClick:e.close,children:V(`history.backToNow`)})]})]}),(0,J.jsx)(`div`,{"aria-label":V(`history.olderVersion`),className:`history-space-stack`,role:`group`,children:c.slice(u+1,u+3).map((e,t)=>(0,J.jsx)(`button`,{"aria-label":vn(e.entries.at(-1).change.timestamp),className:`history-space-sheet`,style:{"--depth":t+1},type:`button`,onClick:()=>w(u+t+1)},e.id))}),(0,J.jsxs)(`div`,{className:`history-space-side`,children:[(0,J.jsxs)(`nav`,{"aria-label":V(`history.chooseStart`),className:`history-space-steps`,children:[(0,J.jsx)(`button`,{"aria-label":V(`history.newerVersion`),disabled:!n||d,type:`button`,onClick:()=>w(Math.max(0,u-1)),children:(0,J.jsx)(C,{"aria-hidden":!0,size:17})}),n?(0,J.jsxs)(`span`,{children:[u+1,` / `,c.length]}):null,(0,J.jsx)(`button`,{"aria-label":V(`history.olderVersion`),disabled:!n||u>=c.length-1,type:`button`,onClick:()=>w(u+1),children:(0,J.jsx)(h,{"aria-hidden":!0,size:17})})]}),(0,J.jsxs)(`nav`,{"aria-label":V(`history.timeline`),className:`history-space-rail`,ref:f,children:[E>0?(0,J.jsx)(`button`,{className:`history-space-more`,type:`button`,onClick:()=>w(Math.max(0,E-25)),children:V(`history.newerVersion`)}):null,(0,J.jsx)(`ol`,{children:c.slice(E,E+50).map((e,t)=>{let n=E+t,r=e.entries.at(-1),i=_n(r.change.timestamp),a=t===0||i!==_n(c[n-1].entries.at(-1).change.timestamp);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{"aria-current":n===u?`true`:void 0,"aria-label":vn(r.change.timestamp),ref:n===u?S:void 0,type:`button`,onClick:()=>v(r),children:[(0,J.jsxs)(`span`,{children:[n===0?V(`history.now`):X(r.change.timestamp),a?(0,J.jsx)(`small`,{children:i}):null]}),(0,J.jsx)(`i`,{"aria-hidden":!0})]})},e.id)})}),E+50<c.length?(0,J.jsx)(`button`,{className:`history-space-more`,type:`button`,onClick:()=>w(E+50),children:V(`history.loadEarlier`)}):n?(0,J.jsx)(`p`,{children:V(n.history.shallow?`history.shallow`:`history.earliest`)}):null]}),(0,J.jsx)(`div`,{className:`history-space-notice`,children:(0,J.jsx)(En,{compact:!0,model:e})}),(0,J.jsx)(`span`,{className:`history-space-keyboard`,children:V(`history.keyboardHint`)})]})]})}var ri=e=>JSON.stringify(e.frontiers()),ii=(e,t)=>t===void 0?void 0:e[t];function ai({properties:e,doc:t,from:n,nodes:r,streaming:i,theme:a,title:o,open:s,onClose:c}){let[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(null),p=(0,q.useRef)(null),m=(0,q.useRef)(null),h=(0,q.useRef)(null),g=(0,q.useRef)(0),[_,v]=(0,q.useState)(!0),[y,b]=(0,q.useState)(null),[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(!1),[D,O]=(0,q.useState)(0),[k,A]=(0,q.useState)(!1),[ee,j]=(0,q.useState)(`snapshot`),[te,ne]=le(k),M=ze(`(max-width: 1100px)`),re=(0,q.useRef)(null),ie=(0,q.useCallback)(async()=>{if(!t)return;let i=++g.current;v(!0),b(null);let a=t.fork();try{let o=await xr(a,e),s=Cr(a,a.frontiers(),r);if(g.current!==i){a.free();return}let c=h.current;h.current=a;let l=p.current&&o.entries.find(e=>e.id===p.current.id),d=!p.current&&n?Sr(a,o,n):null,_=d??(!M&&p.current?.id===m.current?o.entries.at(-1):l)??(M?o.groups[1]?.entries.at(-1):o.entries.at(-1))??o.entries[0]??null;d&&j(`compare`),p.current=_,m.current=o.entries.at(-1)?.id??null,f(_),u({doc:a,history:o,latest:s}),S(ri(t)!==ri(a)),c?.free()}catch(e){a.free(),g.current===i&&b(e.message)}finally{g.current===i&&v(!1)}},[t,r,M,n,e]),N=(0,q.useRef)(e);if((0,q.useEffect)(()=>{N.current!==e&&(N.current=e,s&&!i&&h.current&&ie())},[e,s,i,ie]),(0,q.useEffect)(()=>{if(s)return()=>{g.current++,h.current?.free(),h.current=null,p.current=null,m.current=null,u(null),f(null),w(null),S(!1),b(null),v(!0),A(!1),E(!1),j(`snapshot`)}},[s,t]),(0,q.useEffect)(()=>{s&&!i&&!h.current&&ie()},[s,ie,i]),(0,q.useEffect)(()=>{if(s&&t)return t.subscribe(()=>S(h.current!==null&&ri(t)!==ri(h.current)))},[t,s]),(0,q.useEffect)(()=>{if(!s)return;let e=e=>{e.key===`Escape`&&(k?A(!1):c())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s,c,k]),(0,q.useEffect)(()=>{if(!l||!d)return;let e=!1;v(!0);let t=setTimeout(()=>{try{let t=Cr(l.doc,d.frontiers,r),{entries:n,groups:i}=l.history,a=Tr(l.doc,n.slice(n.indexOf(d)+1),[t,l.latest]),o=new Map(i.flatMap(e=>e.entries.map(t=>[t,e]))),s=vr(t.value,l.latest.value).map(e=>{if(e.kind===`equal`)return e;let n=[ii(l.latest.ids,e.newIndex),ii(t.ids,e.oldIndex)].map(e=>e&&a.get(e)).find(Boolean);return n?{...e,author:n,group:o.get(n)}:e});e||(w({blocks:s,latest:l.latest,from:d,snapshot:t}),O(0),b(null))}catch(t){e||b(t.message)}finally{e||v(!1)}},0);return()=>{e=!0,clearTimeout(t)}},[l,d,r]),!s||!t)return null;let ae=C?.blocks??[],oe=ae.filter(e=>e.kind!==`equal`).length,P={session:l,selected:d,blocks:ae,count:oe,comparison:C,changeIndex:D,loading:_,mode:ee,setMode:j,error:y,pending:x,streaming:i,onlyChanges:T,select:e=>{e.id!==p.current?.id&&(v(!0),e.id===l?.history.entries.at(-1)?.id&&j(`snapshot`),p.current=e,f(e),A(!1))},navigate:e=>{let t=Math.max(0,Math.min(oe-1,D+e));O(t),(re.current?.querySelectorAll(`[data-history-change]`))?.[t]?.scrollIntoView?.({block:`center`,behavior:`instant`})},toggleOnly:()=>E(e=>!e),showAll:()=>E(!1),refresh:()=>void ie(),close:c};return{ready:C!==null,immersive:!M,space:M?null:(0,J.jsx)(ni,{model:P,title:o}),content:(0,J.jsxs)(J.Fragment,{children:[M?null:(0,J.jsx)(ti,{model:P,theme:a,title:o}),(0,J.jsx)(`div`,{hidden:!M&&ee!==`compare`,children:(0,J.jsx)(Fn,{bodyRef:re,model:P,narrow:M,theme:a,title:o,onPick:()=>A(!0)})}),M&&te?(0,J.jsx)(On,{model:P,open:k,onDismiss:()=>A(!1),onExited:ne}):null]}),panel:null}}var oi=[...De.filter(e=>!Ce.some(t=>t.getType()===(`getType`in e?e.getType():e.replace.getType()))),...Ce];function si(e){let t=new Map;for(let n of e){if(!n.artboard)continue;let e=t.get(n.artboard)??{artboard:n.artboard,count:0};e.count+=1,!e.to&&n.to&&(e.to=n.to),t.set(n.artboard,e)}return[...t.values()]}function ci({refs:e,onOpen:t}){let{t:n}=Pe(),[r,i]=(0,q.useState)(!1),a=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!r)return;let e=e=>{a.current?.contains(e.target)||i(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[r]);let o=si(e);return o.length?(0,J.jsxs)(`div`,{ref:a,className:`x1n2onr6`,children:[(0,J.jsxs)(`button`,{"data-linked-boards":!0,"aria-expanded":r,type:`button`,onClick:()=>i(e=>!e),className:`x3nfvp2 x6s0dn4 x17d4w8g x1fgtraw x1awh872 xmkeg23 x1y0btm7 x12xov25 xur7f20 xjbqb8w xo2rkog xjb2p0i xfifm61 x1ypdohk xj0l527`,children:[(0,J.jsx)(Ot,{size:14}),n(`refs.linked`),(0,J.jsx)(`span`,{className:`xddlp02 xss6m8b`,children:o.length}),(0,J.jsx)(h,{size:13})]}),r&&(0,J.jsxs)(`div`,{role:`menu`,className:`x10l6tqk xwwefxd x3m8u43 x1355qak xdzyupr x1ruevkc x1q4ynmn x12ilycc x1d5q07e`,children:[(0,J.jsx)(`div`,{className:`xtxj4hr x1qt5hsa xddlp02`,children:n(`refs.linkedHint`)}),o.map(({artboard:e,count:r,to:a})=>(0,J.jsxs)(`button`,{"data-linked-board":e,role:`menuitem`,type:`button`,onClick:()=>{i(!1),t(a?{artboard:e,to:a}:{artboard:e})},className:`x78zum5 x6s0dn4 x883omv xh8yej3 xe8ttls xc342km xu4hgxq xjbqb8w xo2rkog xjb2p0i x4z9k3i x1yc453h x1ypdohk xj0l527`,children:[(0,J.jsx)(Ot,{size:15}),(0,J.jsx)(`span`,{className:`x98rzlu xeuugli xb3r6kr xlyipyv`,children:e}),(0,J.jsx)(`span`,{className:`x1qt5hsa xddlp02`,children:n(`refs.count`,{count:r})}),(0,J.jsx)(Gt,{size:15})]},e))]})]}):null}function li({editing:e,pending:t,agentActiveAt:n,now:r}){return e?{kind:`editing`}:t===0?{kind:`idle`}:{kind:`working`,pending:t,idleMs:n===void 0?null:Math.max(0,r-n)}}function ui(e){return e<6e4?G.t(`time.seconds`,{count:Math.floor(e/1e3)}):e<36e5?G.t(`time.minutes`,{count:Math.floor(e/6e4)}):G.t(`time.hours`,{count:Math.floor(e/36e5)})}function di(e,t,n){switch(e.kind){case`editing`:return n?G.t(`activity.editingSection`,{agent:t,section:n}):G.t(`activity.editing`,{agent:t});case`idle`:return null;case`working`:{let n=G.t(`activity.pending`,{agent:t,count:e.pending});return e.idleMs===null?n:e.idleMs<1e4?G.t(`activity.updatedJustNow`,{left:n}):G.t(`activity.updatedAgo`,{left:n,duration:ui(e.idleMs)})}}}function fi(e,t,n){switch(e.kind){case`editing`:return{agent:t,detail:n?G.t(`activity.brief.editingSection`,{section:n}):G.t(`activity.brief.editing`),time:null};case`idle`:return null;case`working`:{let n=G.t(`activity.brief.left`,{count:e.pending});return e.idleMs===null?{agent:t,detail:n,time:null}:{agent:t,detail:n,time:e.idleMs<1e4?G.t(`activity.brief.justNow`):G.t(`activity.brief.ago`,{duration:ui(e.idleMs)})}}}}function pi({id:e,title:t,activity:n,agentSection:r,offline:i,openComments:a,cloud:o,compact:s=!1,onDone:c,actions:l,agent:u=`Agent`,history:d,exportState:p,onExport:m,toolbar:h=!1}){let g=o?di(n,u,r):null,v=o?fi(n,u,r):null,[y,b,x]=[v?.agent,v?.detail,v?.time??null],S=(0,q.useMemo)(()=>y===void 0||b===void 0?null:{agent:y,detail:b,time:x},[y,b,x]),C=f(e,o?{...t?{title:t}:{},online:o.online,comments:a,activity:g,activityParts:S,activityTone:n.kind===`working`?`quiet`:`live`,retrying:i,reason:o.reason,history:d?.available,historyOpen:d?.open,documentExport:p,toolbar:h&&!s}:null);return C&&!s?null:(0,J.jsxs)(`header`,{"data-doc-topbar":!0,...{0:{className:`x7wzq59 x13vifvy x1n327nk xdd8jsf x78zum5 x6s0dn4 x1v2ro7d x1hr3lfm x1rozbrz xqfszdh`},1:{className:`x7wzq59 x13vifvy x1n327nk xdd8jsf x78zum5 x6s0dn4 x1hr3lfm x1rozbrz xqfszdh x883omv`}}[!!s|0],children:[s?null:(0,J.jsxs)(`span`,{className:`x1bo0w0s xfifm61 xuxw1ft`,children:[V(`type.document`),` / `,(0,J.jsx)(`span`,{className:`xo2rkog x1s688f`,children:e})]}),g?(0,J.jsxs)(`span`,{...{0:{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla xlssvyo x19ay2w6 x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv`},1:{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xahzvm9 x1bo0w0s`}}[n.kind===`working`|0],children:[(0,J.jsx)(`i`,{className:`x1v4s8kt xols6we x16rqkct xtwfq29`}),g]}):null,i?(0,J.jsx)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xqdcvd7 x7zghnd`,children:V(`document.notSynced`)}):null,d?.open?(0,J.jsxs)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g xj8oexa x1awh872 x1e6avla x1j6dyjg xuxw1ft xeuugli xb3r6kr xlyipyv xahzvm9 x1bo0w0s`,children:[(0,J.jsx)(At,{"aria-hidden":`true`,size:11}),V(`document.readOnlyHistory`)]}):null,o?.reason&&!s?(0,J.jsx)(`span`,{className:`xb3r6kr xddlp02 xfifm61 xuxw1ft xlyipyv`,children:o.reason}):null,(0,J.jsx)(`span`,{className:`x98rzlu`}),o?(0,J.jsxs)(`span`,{className:`x78zum5 x6s0dn4 x17d4w8g x1bo0w0s xfifm61 xuxw1ft`,children:[(0,J.jsx)(`i`,{...{0:{className:`xci0xqf x1hagigm x16rqkct xxwmxtg`},1:{className:`xci0xqf x1hagigm x16rqkct xux1nz0`}}[!!o.online|0]}),o.online?V(`share.computerOnline`):V(`share.computerOffline`)]}):null,d?(0,J.jsx)(_,{available:d.available,comments:a,compact:s,open:d.open,onComments:d.close,onHistory:d.toggle}):null,C?null:(0,J.jsx)(jt,{state:p,onExport:m}),c?(0,J.jsx)(`button`,{type:`button`,onClick:c,className:`x12ulsxz xaope02 xc342km x1kogg8i x19ckca5 xs0jrwl xqfszdh x4z9k3i x1s688f x1ypdohk`,children:V(`common.done`)}):o||s?null:l]})}function mi(e,t,n){let[r,i]=t<=n?[t,n]:[n,t];return{blockIds:e.slice(r,i+1).flatMap(e=>e.id?[e.id]:[]).slice(0,Mt.blockIds),heading:e.slice(0,r+1).filter(e=>e.heading).pop()?.text??``}}var hi=crypto.randomUUID(),gi=300,_i={quote:``,blockIds:[],heading:``};function vi(e){let t=e.read(()=>{let e=te();if(!O(e))return null;let t=j().getChildren(),n=t.filter(t=>e.has(t.getKey()));if(!n.length)return null;let r=t.indexOf(n[0]),{heading:i}=mi(t.map(e=>({id:A(e,ue),heading:e.getType()===`heading`,text:e.getTextContent()})),r,r);return{heading:i.slice(0,Mt.heading),blockIds:n.map(e=>A(e,ue)).filter(Boolean).slice(0,Mt.blockIds),quote:n.map(e=>e.getTextContent()).join(`
4
4
 
5
5
  `).slice(0,Mt.quote)}});if(t)return t;let n=window.getSelection(),r=e.getRootElement();if(!n||n.isCollapsed||!r?.contains(n.anchorNode)||!r.contains(n.focusNode))return _i;let i=n.toString().trim().slice(0,Mt.quote);return i?e.read(()=>{let t=j().getChildren(),r=ct(e,n.getRangeAt(0));if(!r.length)return{..._i,quote:i};let a=t.findIndex(e=>A(e,ue)===r[0].blockId),{heading:o}=mi(t.map(e=>({id:A(e,ue)||``,heading:e.getType()===`heading`,text:e.getTextContent().slice(0,Mt.heading)})),a,a);return{quote:i,heading:o,blockIds:r.map(e=>e.blockId).slice(0,Mt.blockIds)}}):_i}function yi(e,t,n,r){let i=(0,q.useRef)(_i);(0,q.useEffect)(()=>{if(!e)return;let n=0,a=()=>{let n=vi(e);JSON.stringify(n)!==JSON.stringify(i.current)&&(i.current=n,r({type:`selection`,artifact:t,tab:hi,human:!0,...n}))},o=()=>{clearTimeout(n),n=window.setTimeout(a,gi)};document.addEventListener(`selectionchange`,o);let s=e.registerUpdateListener(o);return()=>{clearTimeout(n),document.removeEventListener(`selectionchange`,o),s()}},[e,t,r]),(0,q.useEffect)(()=>{n&&(i.current.quote||i.current.blockIds.length)&&r({type:`selection`,artifact:t,tab:hi,human:!1,...i.current})},[n,t,r])}var bi=600,xi=e=>Promise.race([e,new Promise(e=>setTimeout(e,bi))]);function Si(e){let t=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(!e)return;let n=()=>{t.current&&e.getRootElement()?.childElementCount&&(t.current(),t.current=null)};return n(),e.registerUpdateListener(n)},[e]),(0,q.useCallback)(()=>new Promise(e=>{t.current=e}),[])}function Ci(e,t){let[n,r]=(0,q.useState)(0),i=(0,q.useRef)(e);return(0,q.useEffect)(()=>{let n=e&&!i.current;i.current=e,n&&t&&r(e=>e+1)},[e,t]),n}var wi={count:0,firstKey:null},Ti=e=>e.read(()=>{let e=j().getChildren().filter(e=>e.getType()===`pending`).map(e=>e.getKey());return{count:e.length,firstKey:e[0]??null}});function Ei(e){let[t,n]=(0,q.useState)(wi);return(0,q.useEffect)(()=>{if(!e){n(wi);return}let t=e=>n(t=>t.count===e.count&&t.firstKey===e.firstKey?t:e);return t(Ti(e.getEditorState())),e.registerUpdateListener(({editorState:e})=>t(Ti(e)))},[e]),t}function Di(e,t=15e3){let[n,r]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{if(!e)return;r(Date.now());let n=setInterval(()=>r(Date.now()),t);return()=>clearInterval(n)},[e,t]),n}function Oi(){let e=(0,q.useMemo)(()=>window.matchMedia(`(prefers-color-scheme: dark)`),[]),[t,n]=(0,q.useState)(e.matches);return(0,q.useEffect)(()=>{let t=()=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[e]),t}function ki({left:e,top:t,placement:n,canComment:r,canEdit:i,onComment:a,onEdit:o}){let s=(0,q.useRef)(null),c=[r?{label:V(`common.comment`),Icon:Nt,run:a,primary:!0}:null,i?{label:V(`document.editText`),Icon:Pt,run:o,primary:!1}:null].filter(e=>e!==null);return(0,q.useLayoutEffect)(()=>{yt(s.current,[{opacity:0,transform:`scale(0.96)`},{opacity:1,transform:`none`}],{duration:160,easing:bt})},[]),c.length===0?null:(0,J.jsxs)(`div`,{"data-edit-menu":!0,"data-placement":n,ref:s,...{0:{className:`x10l6tqk x1u8a7rm x78zum5 xdt5ytf x1cy8zhl`},1:{className:`x10l6tqk x1u8a7rm x78zum5 x1cy8zhl x3ieub6`}}[n===`above`|0],style:{left:e,top:t,transformOrigin:n===`above`?`22px 100%`:`22px 0`},onMouseDown:e=>e.preventDefault(),children:[(0,J.jsx)(`span`,{className:`xsmyaan x1kpxq89 xyqm7xq x1qp53xl x1cum3z5 x1t58bn5 x1158fpu`}),(0,J.jsx)(`div`,{className:`x78zum5 xn3w4p2 xfn1xvj x4pepcl x1t58bn5 xn8tshb`,children:c.map(({label:e,Icon:t,run:n,primary:r})=>(0,J.jsxs)(`button`,{type:`button`,onClick:n,...{0:{className:`x78zum5 x6s0dn4 x17d4w8g xn3w4p2 xt970qd xaope02 xc342km x1q4ynmn xjbqb8w x1cfj0a1 x2z4s37 xqfszdh xif65rj x1ypdohk`},1:{className:`x78zum5 x6s0dn4 x17d4w8g xn3w4p2 xt970qd xaope02 xc342km x1q4ynmn xjbqb8w x1cfj0a1 xqfszdh xif65rj x1ypdohk x6l8oc8 x1s688f`}}[!!r|0],children:[(0,J.jsx)(t,{"aria-hidden":!0,size:16}),e]},e))})]})}var $={state:{kmuXW:`x2lah0s`,kGuDYH:`xfifm61`,$$css:!0},waitingAgent:{kMwMTN:`x7zghnd`,$$css:!0},agentWorking:{kMwMTN:`x19ay2w6`,$$css:!0},answered:{kMwMTN:`xh0clw4`,$$css:!0},resolved:{kMwMTN:`xddlp02`,$$css:!0}},Ai=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function ji({thread:e,label:t,agent:n=`Agent`,actions:r,active:i=!1,offline:a=!1}){let o=T(e),s=y(e.id),c=e.status===`resolved`,[l,u]=(0,q.useState)(null),d=(0,q.useMemo)(()=>!!r&&l!==e.statusAt&&me(e),[r,l,e]),f=d?{label:e.statusName?V(`document.resolvedBy`,{agent:e.statusName}):V(`common.resolved`),tone:$.answered}:c?{label:V(`common.resolved`),tone:$.resolved}:o===`agent`&&s?{label:V(Ft[s.state],{agent:s.agent}),tone:s.state===`approval`?$.waitingAgent:s.state===`seen`?$.resolved:$.agentWorking}:o===`agent`?{label:V(`document.waitingAgentReply`,{agent:n}),tone:$.waitingAgent}:o===`human`?{label:V(`document.agentReplied`,{agent:[...e.messages].reverse().find(e=>e.author===`agent`&&!e.deleted)?.name??`Agent`}),tone:$.answered}:null;return(0,J.jsxs)(`div`,{"data-thread":e.id,...{0:{className:`xxlmvz2 x178xt8z x13fuv20 xxu5053 xqfszdh xo2rkog`},1:{className:`xxlmvz2 x178xt8z x13fuv20 xxu5053 xqfszdh xo2rkog xggygye`}}[!!i|0],children:[(0,J.jsxs)(`div`,{className:`x78zum5 x1pha0wt x167g77z x1lqa7cf x1vo0akb x19ypqd9 xmjjtr9 x4z9k3i`,children:[(0,J.jsx)(`span`,{className:`x98rzlu xeuugli xb3r6kr xuxw1ft xlyipyv x1bo0w0s`,children:t??P(e.anchor)}),f?(0,J.jsx)(`span`,{...U($.state,f.tone),children:f.label}):null]}),c&&!i&&!d?null:e.messages.map(e=>{let{label:t,initial:n}=zt(e);return(0,J.jsxs)(`div`,{className:`x14vqqas`,children:[(0,J.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x167g77z x4z9k3i x1s688f`,children:[(0,J.jsx)(It,{human:e.author===`human`,initial:n,name:e.name,src:e.avatar}),t,(0,J.jsx)(`span`,{className:`xddlp02 xo1l8bm xfifm61`,children:Ai(e.editedAt??e.at)})]}),(0,J.jsx)(`div`,{...{0:{className:`x1gslohp xxpkpgd x1jvydc1 x1dbl2gt x126k92a xj0a0fe`},1:{className:`x1gslohp xxpkpgd x1jvydc1 x1dbl2gt x126k92a xj0a0fe xc7n51q`}}[!!e.deleted|0],children:e.deleted?V(`common.deleted`):e.text})]},e.id)}),r?(0,J.jsxs)(`div`,{className:`x78zum5 x6s0dn4 xou54vl x1anpbxc xxpkpgd`,children:[c?null:(0,J.jsx)(`div`,{className:`x98rzlu xeuugli x1qyh8g1 xso031l x1q0q8m5 x1iz93xd`,children:(0,J.jsx)(Lt,{placeholder:V(`common.reply`),submitLabel:V(`composer.reply`),variant:`inline`,onSubmit:t=>r.reply(e.id,t)})}),d?(0,J.jsx)(`button`,{type:`button`,onClick:()=>{oe(e),u(e.statusAt)},className:`x2lah0s x1gg8mnh xt970qd xdqyycr x1w5wx5t xc342km xjbqb8w x1bo0w0s xqfszdh x4z9k3i x1ypdohk`,children:V(`document.doneReading`)}):null,a||!r.resolve||!r.reopen?null:(0,J.jsx)(`button`,{type:`button`,onClick:()=>c?r.reopen(e.id):r.resolve(e.id),className:`x2lah0s x1gg8mnh xt970qd xdqyycr x1w5wx5t xc342km xjbqb8w x1bo0w0s xqfszdh x4z9k3i x1ypdohk`,children:V(c?`common.reopen`:`common.resolve`)})]}):null]})}var Mi=.5,Ni=e=>e===78?Mi:e;function Pi({threads:e,agent:t=`Agent`,actions:n,offline:r,draft:i,labelOf:a,onCreate:o,onCancelDraft:s,activeId:c,snap:l,onSnap:u}){let d=(0,q.useRef)(null),f=e.filter(e=>!e.messages.every(e=>e.deleted)),p=f.filter(e=>T(e)===`agent`).length,m=r?V(`document.offlineNoComments`):p>0?V(`document.waitingCount`,{count:p,agent:t}):null;return(0,q.useEffect)(()=>{let e=c?d.current?.querySelector(`[data-thread="${CSS.escape(c)}"]`):null,t=e?.closest(`[data-sheet-body]`);e&&t&&(t.scrollTo({top:t.scrollTop+e.getBoundingClientRect().top-t.getBoundingClientRect().top-8,behavior:`smooth`}),yt(e,[{backgroundColor:Rt.warningChip},{backgroundColor:`transparent`}],{duration:600,delay:250,easing:bt}))},[c]),(0,J.jsx)(gt,{snap:l,snaps:[78,Mi,1],header:(0,J.jsxs)(`span`,{className:`x78zum5 x1pha0wt x17d4w8g xu0aao5 x17qtykl xwib8y2 xqfszdh x1jvydc1 x1s688f`,children:[V(`document.sheetComments`,{count:f.length}),m?(0,J.jsxs)(`span`,{className:`xddlp02 xfifm61 xo1l8bm`,children:[`· `,m]}):null]}),onScrim:()=>u(Mi),onSnap:u,children:(0,J.jsxs)(`div`,{ref:d,className:`x17qtykl xwxc41k`,children:[i&&n?(0,J.jsx)(`div`,{className:`x10dr8xq xqfszdh`,children:(0,J.jsx)(`div`,{className:`xb3r6kr xmkeg23 x1y0btm7 x12xov25 x4pepcl x1rozbrz`,children:(0,J.jsx)(Lt,{autoFocus:!0,excerpt:$e(i,Je(i)),placeholder:V(`composer.placeholder`),onCancel:s,onSubmit:e=>o(i,e).then(e=>(e&&s(),e))})})}):null,f.length===0&&!i?(0,J.jsx)(`div`,{className:`xr9q8rw xddlp02 xqfszdh x4z9k3i x2b8uid`,children:V(`document.noComments`)}):null,f.map(e=>(0,J.jsx)(ji,{actions:n,active:e.id===c,agent:t,label:a?.(e),offline:r,thread:e},e.id))]})})}var Fi=52;function Ii({editor:e,threads:t,actions:n,agent:r,canComment:i,canEdit:a,offline:o,selection:s,clearSelection:c,onCreate:l,onEdit:u,onMain:d,history:f,shareBase:p,children:m}){let[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(null),[y,b]=(0,q.useState)(78),[x,S]=(0,q.useState)(null),C=qe(e,t,h);Ue(C,t,_),We(x?.range??null,x?.elements);let w=()=>{window.getSelection()?.removeAllRanges(),c()};return(0,J.jsxs)(`main`,{ref:e=>{g(e),d?.(e)},className:`x1n2onr6 x1cnzs8 x17qtykl x1ffnkcp`,children:[(0,J.jsx)(pt,{editor:e}),e?(0,J.jsx)(Ke,{editor:e,shareBase:p}):null,(0,J.jsxs)(`article`,{onClick:e=>{let t=dt(C,e.clientX,e.clientY);v(t),t&&b(Ni)},children:[(0,J.jsx)(nt,{}),(0,J.jsx)(ft,{history:f,children:m})]}),s&&!x&&!f?(0,J.jsx)(ki,{...Ge(s,{left:8,right:(h?.clientWidth??0)-8},170,44,{top:h?.getBoundingClientRect().top??0,height:window.innerHeight,reserved:ht(y,window.innerHeight-Fi)}),canComment:i,canEdit:a&&s.kind!==`block`,onComment:()=>{S(s),b(Mi),w()},onEdit:()=>{u(s),c()}}):null,(0,J.jsx)(`div`,{hidden:!!f,className:`xixxii4 x1ozmhy9 xu96u03 x3m8u43 x1ey2m1c x1355qak x47corl`,children:(0,J.jsx)(Pi,{actions:n,activeId:_,agent:r,draft:x,offline:o,snap:y,threads:t,labelOf:e=>P(e.anchor,He(C.find(t=>t.threadId===e.id))),onCancelDraft:()=>S(null),onCreate:l,onSnap:b})})]})}var Li={playing:!1,section:null};function Ri({id:e,transport:t,live:n,cloud:r,fallback:i,actions:a,shareBase:o,refs:s,scenes:c}){let[u,f]=(0,q.useState)(null),[p,h]=(0,q.useState)(null),[g,_]=(0,q.useState)(),[y,x]=(0,q.useState)(i!=null),[S,C]=(0,q.useState)(E),[T,D]=(0,q.useState)(!1),[O,k]=(0,q.useState)(null);l(p!==null||O!==null);let[A,ee]=(0,q.useState)(!1),[te,ne]=(0,q.useState)(void 0),[re,ie]=(0,q.useState)(0),N=(0,q.useCallback)(e=>{e!==void 0&&ie(e-Date.now())},[]),[oe,P]=(0,q.useState)(Li),[se,ce]=(0,q.useState)(!1),[le,ue]=(0,q.useState)(void 0),[de,fe]=(0,q.useState)(!1),[pe,me]=(0,q.useState)(!1),[he,F]=(0,q.useState)(!1),[_e,ve]=(0,q.useState)(),I=!r||r.online&&!se,L=he&&I;(0,q.useEffect)(()=>{I||F(!1)},[I]),(0,q.useEffect)(()=>{if(!r)return;let t=t=>{m(t)&&t.data?.type===`ryugi:document-history`&&t.data.id===e&&(t.data.action===`close`?F(!1):t.data.action===`toggle`&&I&&F(e=>!e))};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e,r,I]);let[R,ye]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(!R||!le)return;let e=()=>fe(R.getEditorState().read(()=>j().getTextContent().trim()===``));return e(),R.registerUpdateListener(e)},[R,le]);let z=ot({id:e,editor:R,scenes:c,comments:S,contentBase:u?.contentBase??document.baseURI,title:u?.title||e,cloud:!!r,available:!L}),xe=tt(R,e,s,c?.use,c?.frames);ut(y?null:R);let Se=Si(R),Ce=Ye(xe?R:null),[Te,Ee]=(0,q.useState)(null),De=Oi(),{artifact:Ae,channel:Me}=t,Ne=!r||r.online,Pe=Ne&&Jt(r?.hubVersion),B=!r||r.canEdit,Fe=ze(Be),H=w(Fe),[U,W]=(0,q.useState)(!1),G=H?U&&B:B,Re=(0,q.useCallback)(async()=>{let e=await t.meta();e&&(f(e),e.properties&&_(e.properties))},[t]),He=Ci(n,O!==null);(0,q.useEffect)(()=>{let e=!1;return(async()=>{try{await Re();let n=await t.state();if(e)return;let r=new ae;r.setRecordTimestamp(!0),r.setChangeMergeInterval(20),r.import(be(n.snapshot)),n.properties&&_(n.properties),ee(!!n.streaming),ne(n.agentActiveAt),N(n.now),C(n.comments??E()),D(n.listening===!0),ue(n.prompt),k(null),h(r)}catch(t){e||k(t.message)}})(),()=>{e=!0}},[t,Re,N,He]),(0,q.useEffect)(()=>{if(!p||!y||!R)return;let e=!1;return xi(Se()).then(()=>{if(e)return;let t=b();t&&v(t),(0,Yt.flushSync)(()=>x(!1)),t&&rt(R,t)}),()=>{e=!0}},[p,y,R,Se]),(0,q.useEffect)(()=>Me.subscribe(e=>{e.type===`change`?Re():e.type===`doc-properties`?_(e.properties):e.type===`doc-status`?(ee(e.streaming),ne(e.agentActiveAt),N(e.now)):e.type===`doc-comments`&&(C(e.comments),e.listening!==void 0&&D(e.listening))}),[Me,Re,N]),(0,q.useEffect)(()=>{R?.setEditable(G&&!L)},[R,G,L]),(0,q.useEffect)(()=>{B||W(!1)},[B]);let Ue=(0,q.useCallback)(e=>{ee(!!e.streaming),e.properties&&_(e.properties),ne(e.agentActiveAt),N(e.now),e.comments&&C(e.comments),e.listening!==void 0&&D(e.listening)},[N]);Le(u?.contentBase),yi(R,Ae,n&&!L,t.send);let We=(0,q.useMemo)(()=>({artifact:Ae,contentBase:u?.contentBase??``,channel:Me,send:t.send}),[Ae,u?.contentBase,Me,t]);(0,q.useEffect)(()=>{let t=u?.title||e;document.title=t,d({kind:`title`,title:t})},[u?.title,e]),mt(`document`);let Ge=Ei(R),Ke=Di(Ge.count>0&&!A),qe=Jr(p,g),Je=li({editing:oe.playing||A,pending:Ge.count,agentActiveAt:te,now:Ke+re}),$e=qe.lastAgent?.name??u?.agent,nt=$e??`Agent`,it=(0,q.useMemo)(()=>({nextKey:Ge.firstKey,agent:nt,activity:Je.kind}),[Ge.firstKey,nt,Je.kind]),ct=(0,q.useMemo)(()=>je(S.threads),[S.threads]),lt=ct.filter(e=>e.status===`open`).length,[dt,ft,pt]=at(R,Te),ht=(0,q.useCallback)(()=>{F(!1),ve(void 0)},[]),gt=Ve({activity:r?di(Je,nt,oe.section):null,comments:lt,history:I,historyOpen:L,documentExport:z.state},e=>{e===`close`?ht():I&&F(e=>!e)},z.exportPdf),_t=ai({properties:g,doc:p,from:_e,nodes:oi,streaming:A,theme:De?`dark`:`light`,title:u?.title||e,open:L,onClose:ht}),K=(0,q.useCallback)(async e=>{try{return C(await t.comment(e)),!0}catch{return!1}},[t]),vt=(0,q.useMemo)(()=>({threads:S.threads,canAnswer:B&&!L,phone:H,send:e=>void K(e)}),[S.threads,B,L,H,K]),yt=(0,q.useMemo)(()=>({reply:(e,t)=>K({op:`reply`,threadId:e,text:t}),edit:(e,t,n)=>void K({op:`edit`,threadId:e,messageId:t,text:n}),remove:(e,t)=>void K({op:`delete`,threadId:e,messageId:t}),resolve:e=>void K({op:`resolve`,threadId:e}),reopen:e=>void K({op:`reopen`,threadId:e})}),[K]),bt=(0,q.useCallback)((e,t)=>K({op:`create`,blockId:e.blockId,...e.blockIds?{blockIds:e.blockIds}:{},...e.textRanges?{textRanges:e.textRanges}:{},...e.diagram?{diagram:e.diagram}:{},quote:e.quote,text:t}),[K]),xt=(0,q.useCallback)(e=>{if(!R)return;R.setEditable(!0),W(!0),R.getRootElement()?.focus({preventScroll:!0});let t=window.getSelection();t?.removeAllRanges(),t?.addRange(e.range)},[R]),St=e=>{let t=e!==null&&y;return(0,J.jsxs)(`div`,{...{0:{className:`xjp7ctv`},1:{className:`xrvj5dj`}}[!!t|0],children:[e===null||y?(0,J.jsx)(`div`,{...{0:{className:`xjp7ctv`},1:{className:`x15r89dc xeuugli`}}[!!t|0],children:i},`snapshot`):null,e===null?null:(0,J.jsx)(`div`,{"aria-hidden":y||void 0,inert:y,...{0:{className:`xjp7ctv`},1:{className:`x15r89dc xeuugli xlshs6z`}}[!!y|0],children:(0,J.jsx)(Xe,{value:y,children:e})},`live`)]})};if(!p&&i!=null)return St(null);if(O&&!p)return(0,J.jsx)(`div`,{className:`x1o8uwn5 x2b8uid x1bo0w0s xqfszdh xif65rj`,children:V(`document.offlineUnavailable`)});if(!p)return(0,J.jsx)(`div`,{className:`x1o8uwn5 x2b8uid x1bo0w0s xqfszdh xif65rj`,children:V(`common.loading`)});let Ct=(0,J.jsx)(ke.Provider,{value:We,children:(0,J.jsx)(M.Provider,{value:vt,children:(0,J.jsx)(ge.Provider,{value:xe,children:(0,J.jsxs)(we.Provider,{value:it,children:[le&&(0,J.jsx)(Ze,{empty:de,prompt:le,theme:De?`dark`:`light`}),(0,J.jsx)(Oe,{agent:$e,doc:p,human:u?.human,theme:De?`dark`:`light`,transport:t,onAgentPlayback:P,onEditorReady:ye,onOffline:ce,onState:Ue}),R?(0,J.jsx)(st,{byline:qe,editor:R,me:u?.human?.name}):null]})})})}),wt=(0,J.jsxs)(`div`,{className:`xugpy4h x1us19tq x1rozbrz xo2rkog`,className:`ryugi-doc ${{className:`xugpy4h x1us19tq x1rozbrz xo2rkog`}.className??``}`,children:[gt?null:(0,J.jsx)(pi,{activity:Je,agent:$e,agentSection:oe.section,cloud:r,compact:Fe,exportState:z.state,id:e,offline:se,openComments:lt,title:u?.title||e,toolbar:pe,actions:xe?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ci,{refs:Ce,onOpen:xe.open}),a]}):a,history:{available:I,open:L,toggle:()=>F(e=>!e),close:ht},onDone:H&&U?()=>W(!1):void 0,onExport:z.exportPdf}),H?(0,J.jsx)(Ii,{actions:yt,agent:$e,canComment:Ne,canEdit:B,clearSelection:ft,editor:R,history:_t,offline:!(!r||r.online),selection:U?null:dt,shareBase:o,threads:ct,onCreate:bt,onEdit:xt,onMain:Ee,children:Ct}):(0,J.jsx)(et,{actions:yt,agent:$e,canComment:Ne,canCommentDiagram:Pe,clearSelection:ft,editor:R,history:_t,resolveSelection:pt,selection:dt,shareBase:o,threads:ct,onCreate:bt,onMain:Ee,onToolbar:me,children:Ct}),(0,J.jsx)(Ur,{active:I&&!L,doc:p,editor:R,id:e,nodes:oi,phone:H,properties:g,streaming:A,theme:De?`dark`:`light`,asks:{agent:nt,canAct:B&&!L,editor:R,listening:T,send:K,threads:S.threads},onCompare:e=>{ve(e),F(!0)}}),(0,J.jsx)(Ie,{warnings:u?.warnings??[]}),(0,J.jsx)(Qe,{error:z.error,onDismiss:z.dismiss})]});return i==null?wt:St(wt)}var zi=[`pending`,`ask`,`ref`],Bi=`x-ryugi-document-features`;function Vi({id:e,channel:t,send:n}){let r=(t,n,r)=>fetch(W(`/api/document/${e}/${t}`),{method:`POST`,headers:{"Content-Type":r,[Bi]:zi.join(`,`)},body:n});return{artifact:`document/${e}`,channel:t,send:n,async meta(){let t=await fetch(W(`/api/artifacts/document/${e}`),{cache:`no-store`});return t.ok?await t.json():null},async state(){let t=await fetch(W(`/api/document/${e}/state`),{cache:`no-store`}),n=await t.json();if(!t.ok||!n.snapshot)throw Error(n.error??`load failed (${t.status})`);return n},async update(e){let t=await r(`update`,e,`application/octet-stream`);if(!t.ok)throw Error(`update failed (${t.status})`)},async comment(e){let t=await r(`comments`,JSON.stringify(e),`application/json`);if(!t.ok)throw Error(`comment failed (${t.status})`);return(await t.json()).comments}}}function Hi(e){let t=(0,q.useMemo)(lt,[]),n=`document/${e}`,{live:r,send:i}=Bt(e=>{e.artifact===n&&t.emit(e)},()=>t.emit({type:`open`}));return{transport:(0,q.useMemo)(()=>Vi({id:e,channel:t,send:i}),[e,t,i]),live:r}}var Ui=[2e3,5e3,15e3];function Wi(e,t,n=0){let[r,i]=(0,q.useState)(null),a=(0,q.useRef)(t);return a.current=t,(0,q.useEffect)(()=>{let t=!1,n,r=o=>{a.current().catch(()=>void 0).then(a=>{if(!t){if(a)return i({key:e,value:a});if(o>=Ui.length)return i({key:e,value:{unavailable:`failed`}});n=setTimeout(()=>r(o+1),Ui[o])}})};return r(0),()=>{t=!0,n&&clearTimeout(n)}},[e,n]),r?.key===e?r.value:void 0}var Gi=1e3,Ki=async e=>{let t=await fetch(e,{cache:`no-store`});if(t.status===404)return null;if(t.ok)return await t.json()};async function qi(e){let t=encodeURIComponent(Ht(e)),n=e.page??`main`;if(e.frame){let r=await Ki(W(`/api/whiteboard/${t}/pages`));if(r===null)return{unavailable:`gone`};if(r===void 0)return;n=r.frames?.[e.frame]?.page??`main`}let r=await Ki(W(`/api/whiteboard/${t}/scene?page=${encodeURIComponent(n)}`));if(r===null)return{unavailable:`gone`};if(r?.scene)return{...n===`main`?{}:{page:n},scene:{elements:r.scene.elements??[],files:r.scene.files??{}}}}function Ji(e){let t=Ht(e),{frame:n,page:r}=e,[i,a]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let e,n=Vt(n=>{`artifact`in n&&n.artifact===`whiteboard/${t}`&&(n.type===`change`||n.type===`whiteboard-update`)&&(e??=setTimeout(()=>{e=void 0,a(e=>e+1)},Gi))});return()=>{n(),e&&clearTimeout(e)}},[t]),Wi(`${t}:${n??``}:${r??``}`,()=>qi({whiteboard:t,frame:n,page:r}),i)}var Yi={frames:Ut,load:qi,use:Ji},Xi={online:!0,canEdit:!0,reason:null};function Zi({id:e}){let{transport:n,live:i}=Hi(e),{status:a}=r(),c=o(),l=t(a?.artifacts[`document/${e}`]).url;return(0,J.jsx)(Ri,{actions:c?void 0:(0,J.jsx)(s,{artifact:`document/${e}`}),cloud:S()?Xi:void 0,id:e,live:i,refs:Re,scenes:Yi,shareBase:l,transport:n})}export{Zi as default};
@@ -0,0 +1 @@
1
+ [data-chrome=bottom-bar]:has([data-ask-revise]):not(:has([data-since-bar][data-shown])){padding-inline-start:6px}.bar-text{align-items:center;display:inline-flex;position:relative}.bar-text-in{animation:.22s cubic-bezier(.2,0,0,1) 80ms both bar-text-in}.bar-text-out{white-space:nowrap;animation:.12s cubic-bezier(.4,0,1,1) both bar-text-out;position:absolute;top:50%;left:0;translate:0 -50%}@keyframes bar-text-in{0%{opacity:0;transform:translateY(4px)}}@keyframes bar-text-out{to{opacity:0;transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.bar-text-in,.bar-text-out{animation:none}.bar-text-out{display:none}}.since-marks{--since-agent:#7b61ff;--since-tint:#7b61ff12;pointer-events:none;position:absolute;inset:0}@media (prefers-color-scheme:dark){.since-marks{--since-agent:#9a86ff;--since-tint:#9a86ff1f}}[data-since-deleted=before]{margin-top:var(--since-gap)!important}[data-since-deleted=after]{margin-bottom:var(--since-gap)!important}.since-focus{z-index:-1;background:var(--since-tint);border-radius:8px;transition:opacity .3s cubic-bezier(.2,0,0,1);position:absolute}.since-mark{pointer-events:auto;width:12px;transition:opacity .3s cubic-bezier(.2,0,0,1);position:absolute}.since-mark:before{content:"";background:var(--since-agent);border-radius:2px;width:3px;position:absolute;top:4px;bottom:4px;left:4.5px}.since-mark[data-seen],.since-row[data-seen]{opacity:.35}.since-marks[data-leaving] .since-mark,.since-marks[data-leaving] .since-row,.since-marks[data-leaving] .since-focus{opacity:0;pointer-events:none}.since-tip{color:#e4e4e7;white-space:nowrap;background:#18181b;border-radius:6px;align-items:center;gap:6px;height:26px;padding:0 10px;font-size:12px;display:none;position:absolute;top:0;right:calc(100% + 8px)}.since-tip b{color:#fff;font-weight:500}.since-mark:hover .since-tip{display:inline-flex}.since-row{pointer-events:auto;transition:opacity .3s cubic-bezier(.2,0,0,1);position:absolute}.since-row-bar{background:repeating-linear-gradient(var(--since-agent) 0 3px, transparent 3px 6px);border-radius:2px;width:3px;position:absolute;top:4px;bottom:4px}.since-row-head{height:28px;color:var(--lobe-color-text-tertiary,#9a9a9a);align-items:center;gap:8px;font-size:13px;display:flex}.since-row-rule{background:var(--lobe-color-border-secondary,#efefef);flex:1;height:1px}.since-row-head button{color:var(--lobe-color-text-secondary,#5f5f5f);font:inherit;text-decoration:underline;-webkit-text-decoration-color:var(--lobe-color-border,#e5e5e5);text-decoration-color:var(--lobe-color-border,#e5e5e5);text-underline-offset:3px;cursor:pointer;background:0 0;border:0;padding:0}.since-row-body{padding-top:4px}.ryugi-editor-toolbar-slot:has(.ryugi-editor-toolbar,.history-bar)>.history-toolbar-space{display:none}.ryugi-doc:has(.history-toolbar-space){--ryugi-editor-toolbar-height:37px}.ryugi-doc:has(.history-toolbar-space):has([data-doc-topbar]){--ryugi-doc-top:44px}.ryugi-doc:has(.history-toolbar-space) [data-doc-topbar]{height:var(--ryugi-doc-top)}.history-view [hidden],.history-panel [hidden]{display:none!important}.history-block .rich-content,.history-block [class*=richContent]{max-width:100%;font-size:14px;line-height:1.75}.history-block .rich-content>:first-child{margin-top:0}.history-block .rich-content>:last-child{margin-bottom:0}.history-block .rich-content>.rich-heading-h1{font-size:24px;line-height:1.35}.history-block .rich-content>.rich-heading-h2{font-size:20px;line-height:1.4}.history-block .rich-content>.rich-heading-h3{font-size:17px;line-height:1.45}.history-block pre{white-space:pre-wrap;overflow-wrap:anywhere}.history-block table,.history-block img{max-width:100%}@media (width<=640px){.history-block table{font-size:12px}.history-block .rich-content,.history-block [class*=richContent]{font-size:16px}}.history-rail{min-width:0;height:100%;position:relative}.history-rail[data-moving]{overflow-clip-margin:1px;overflow:clip}.history-rail-track{grid-template-columns:100%;height:100%;transition:transform .28s cubic-bezier(.2,0,0,1);display:grid}.history-rail[data-open]>.history-rail-track{transform:translate(-100%)}.history-rail-comments,.history-rail-panel{grid-area:1/1;min-width:0}.history-rail-panel{border-left:1px solid var(--lobe-color-border-secondary);padding-left:20px;transform:translate(100%)}.history-rail:not([data-moving]) .history-rail-panel{display:none}.history-timeline-scroll{scrollbar-width:thin;overscroll-behavior:contain;min-height:0;overflow-y:auto}.history-change-summary{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}.history-rail-comments[aria-hidden=true]{pointer-events:none}.history-content{padding:40px 16px 28px}.history-content-title{margin:0 0 32px;font-size:24px;font-weight:700;line-height:1.35}.history-block{min-width:0;margin:0 0 16px;scroll-margin-top:120px;position:relative}.history-block[data-heading=h1]{margin-bottom:32px}.history-block[data-heading=h2]{margin-top:36px;margin-bottom:10px}.history-block[data-heading=h3]{margin-top:24px;margin-bottom:6px}.history-block[data-heading=h4],.history-block[data-heading=h5],.history-block[data-heading=h6]{margin-top:20px;margin-bottom:6px}.history-block[data-folded]{display:none}.history-block[data-kind=insert]>.history-current,.history-block[data-kind=modify]>.history-current{position:relative}.history-block[data-kind=insert]>.history-current:before,.history-block[data-kind=modify]>.history-current:before{content:"";background:var(--lobe-color-success-text);border-radius:1px;width:2px;position:absolute;top:0;bottom:0;left:-14px}.history-block[data-current]{outline:1px solid var(--lobe-color-border-secondary);outline-offset:8px;border-radius:3px}.history-before{grid-template-rows:1fr;transition:grid-template-rows .28s cubic-bezier(.2,0,0,1);display:grid}.history-before-inner{min-height:0;overflow:hidden}.history-old-content{border-left:2px solid var(--lobe-color-error-text);background:color-mix(in srgb, var(--lobe-color-error-text) 7%, var(--lobe-color-bg-container));border-radius:0 4px 4px 0;margin-top:10px;padding:8px 12px}.history-old-content .rich-content{color:var(--lobe-color-text);font-size:12px}.history-caption{color:color-mix(in srgb, var(--lobe-color-error-text) 70%, var(--lobe-color-text));font-variant-numeric:tabular-nums;flex-wrap:wrap;gap:8px;margin-bottom:5px;font-size:11px;display:flex}.history-caption>:last-child{color:var(--lobe-color-text-secondary)}.history-no-diff,.history-inline-status{color:var(--lobe-color-text-secondary);margin:12px 0;font-size:12px}.history-inline-status button,.history-expand{color:var(--lobe-color-text-secondary);background:var(--lobe-color-fill-tertiary);font:inherit;cursor:pointer;border:0;border-radius:4px;padding:7px 10px}.history-expand{text-align:left;width:100%;font-size:11px}@starting-style{.history-before{grid-template-rows:0fr}}@media (prefers-reduced-motion:reduce){.history-rail-track,.history-before{transition:none}}.history-space-toc{display:contents}.ryugi-doc:has(.history-space-shell[data-immersive]){overflow-x:clip}.history-space-shell[data-immersive]{--history-gutter:16px;--history-side-width:172px;--history-paper-left:var(--history-gutter);--history-paper-top:48px;--history-paper-width:calc(100% - var(--history-gutter) * 2 - var(--history-side-width) - 20px);z-index:200;position:fixed;inset:0;overflow:hidden}.ryugi-doc article:has(.history-space-shell[data-immersive]){z-index:100}.ryugi-doc [data-doc-topbar]{transition:opacity .62s cubic-bezier(.2,.8,.2,1)}.ryugi-doc:has(.history-space-shell[data-open]) [data-doc-topbar]{opacity:0;pointer-events:none}.ryugi-doc:has(.history-space-shell[data-open]) .history-space-toc>nav{opacity:0;pointer-events:none;transform:translate(-80px)}.ryugi-doc:has(.history-space-shell[data-open]) .history-space-comments{opacity:0;pointer-events:none;transform:translate(140px)}.history-space-toc>nav,.history-space-comments{transition:transform .54s cubic-bezier(.2,.8,.2,1),opacity .24s}.history-space-shell[data-immersive] .history-space-paper{left:var(--history-paper-left);top:var(--history-paper-top);width:var(--history-paper-width);z-index:2;border:1px solid var(--history-paper-border);background:var(--history-paper-bg);border-bottom:0;border-radius:8px 8px 0 0;transition:box-shadow .62s cubic-bezier(.2,.8,.2,1),border-color .62s cubic-bezier(.2,.8,.2,1),border-radius .62s cubic-bezier(.2,.8,.2,1);position:absolute;bottom:0;overflow:hidden;box-shadow:0 20px 64px #0003,0 1px 2px #0002}.history-space-shell[data-immersive]:not([data-open]) .history-space-paper{border-color:#0000;border-radius:0;box-shadow:0 0 #0000,0 0 #0000}.history-space-shell[data-immersive]{--history-paper-bg:var(--lobe-color-bg-container);--history-paper-border:#e9e4dc;--history-paper-rule:#eeebe5;--history-paper-muted:#796e5e;--history-paper-scrollbar:#d4cfc5;--history-sheet-bg:#c9c6c0;--history-sheet-border:#b5b1a9}@media not (prefers-color-scheme:dark){.history-space-shell[data-immersive] .history-space-paper{color:#2d2c28;--lobe-color-text:#2d2c28;--lobe-color-text-secondary:#71695f;--lobe-color-border-secondary:#e9e4da;--lobe-color-success-text:#2b6443;--lobe-color-error-text:#985544;--lobe-color-fill-tertiary:#f5f3ef;--rc-host-text:#2d2c28;--rc-host-text-secondary:#71695f;--rc-host-text-tertiary:#796e5e;--rc-host-bg:var(--history-paper-bg);--rc-host-bg-secondary:#faf9f6;--rc-host-bg-tertiary:#f4f2ed;--rc-host-bg-elevated:#fff;--rc-host-border:#e5e1da;--rc-host-border-subtle:#eeebe5;--rc-host-fill:#00000012;--rc-host-fill-secondary:#0000000b;--rc-host-fill-tertiary:#00000008;--rc-host-fill-quaternary:#00000005;--rc-host-link:#2563eb;--rc-host-code-text:#2d2c28;--rc-host-code-bg:#f4f2ed;--rc-host-code-header-bg:#f4f2ed;--rc-host-quote-bg:#f5f3ef;--rc-host-quote-border:#d4cfc5}}@media (prefers-color-scheme:dark){.history-space-shell[data-immersive]{--history-paper-border:#2c3036;--history-paper-rule:#2a2d33;--history-paper-muted:#8b8f96;--history-paper-scrollbar:#3a3e45;--history-sheet-bg:#2a2d33;--history-sheet-border:#3a3e45}.history-space-shell[data-immersive] .history-space-paper{color:var(--lobe-color-text);--rc-host-bg:var(--history-paper-bg);box-shadow:0 20px 64px #0008,0 0 0 1px #ffffff08}}.history-space-leaf{pointer-events:none}.history-space-shell[data-immersive] .history-space-scroll{box-sizing:border-box;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--history-paper-scrollbar) transparent;height:100%;padding:0 0 64px;overflow-y:auto}.history-space-shell[data-immersive] .history-space-scroll>div{max-width:var(--history-reading-width,760px);margin-inline:auto}.history-space-shell[data-immersive] .history-space-snapshot,.history-space-shell[data-immersive] .history-content{padding:40px 16px 0}.history-space-shell[data-immersive] .history-block[data-current]{outline:none}.history-space-shell[data-immersive] [hidden]{display:none!important}.history-space-snapshot .rich-content{font-size:14px;line-height:1.95}.history-space-ui{background:var(--lobe-color-bg-layout);color:#f1f0ed;opacity:0;font:13px/1.5 -apple-system,BlinkMacSystemFont,PingFang SC,sans-serif;transition:opacity .62s cubic-bezier(.2,.8,.2,1);position:absolute;inset:0}[data-open]>.history-space-ui{opacity:1}.history-space-ui button:not(.lobe-button,.lobe-segmented__item){font:inherit;color:inherit;cursor:pointer;background:0 0;border:0}.history-space-ui button:not(.lobe-button,.lobe-segmented__item):disabled{opacity:.3;cursor:default}.history-space-ui button:not(.lobe-button,.lobe-segmented__item):focus-visible{outline-offset:4px;outline:2px solid #e19779}.history-space-header{height:var(--history-paper-top);box-sizing:border-box;padding:0 var(--history-gutter);white-space:nowrap;z-index:4;align-items:center;gap:10px;display:flex;position:absolute;inset:0 0 auto}.history-space-header>strong{font-size:14px;font-weight:550}.history-space-name{color:#b0b1b4;text-overflow:ellipsis;border-left:1px solid #393d43;max-width:240px;margin-left:2px;padding-left:12px;font-size:12px;overflow:hidden}.history-space-caption{color:#b0b1b4;border-left:1px solid #393d43;align-items:center;gap:10px;min-width:0;margin-left:2px;padding-left:12px;font-size:12px;display:flex}.history-space-clock{color:#f1f0ed;font-variant-numeric:tabular-nums;font-size:15px;font-weight:550}.history-space-source{align-items:center;gap:5px;display:flex}.history-space-description{color:#a0a3a8;text-overflow:ellipsis;align-items:center;gap:8px;min-width:0;display:flex;overflow:hidden}.history-space-description:before{content:"·";color:#5c6067}.history-space-description button{text-decoration:underline}.history-space-updating{color:#a0a3a8;font-size:11px}.history-space-actions{align-items:center;gap:8px;margin-left:auto;display:flex}.history-space-caption .history-space-commits{color:inherit}.history-space-stack{opacity:0;z-index:1;left:var(--history-paper-left);top:var(--history-paper-top);width:var(--history-paper-width);height:40px;transition:opacity .26s;position:absolute}.history-space-ui .history-space-sheet{z-index:calc(5 - var(--depth));background:var(--history-sheet-bg);border:1px solid var(--history-sheet-border);width:100%;transform:translateY(calc(var(--depth) * -6px)) scaleX(calc(1 - var(--depth) * .014));opacity:calc(1 - var(--depth) * .3);border-radius:8px 8px 0 0;transition:transform .2s;position:absolute;inset:0}.history-space-ui .history-space-sheet:hover{transform:translateY(calc(var(--depth) * -6px - 3px)) scaleX(calc(1 - var(--depth) * .014))}.history-space-side{top:var(--history-paper-top);right:var(--history-gutter);bottom:var(--history-gutter);width:var(--history-side-width);z-index:4;flex-direction:column;gap:18px;display:flex;position:absolute}.history-space-steps{color:#a0a3a8;font-variant-numeric:tabular-nums;justify-content:flex-end;align-items:center;gap:10px;padding-right:9px;font-size:11px;display:flex}.history-space-steps button{border:1px solid #393d43;border-radius:50%;place-items:center;width:30px;height:30px;display:grid}.history-space-steps button:hover:not(:disabled){background:#30343a}.history-space-rail{overscroll-behavior:contain;scrollbar-width:none;flex:1;min-height:0;overflow-y:auto}.history-space-notice:empty{display:none}.history-space-keyboard{color:#a0a3a8;text-align:right;padding-right:9px;font-size:10px}.history-space-rail ol{margin:0;padding:0;list-style:none}.history-space-rail li{margin:0;padding:0}.history-space-rail ol button{text-align:right;color:#b0b1b4;font-variant-numeric:tabular-nums;justify-content:flex-end;align-items:center;gap:12px;width:100%;height:56px;padding:0 9px 0 0;font-size:11px;display:flex;position:relative}.history-space-rail ol button:after{content:"";background:#393d43;width:1px;position:absolute;top:0;bottom:0;right:9px}.history-space-rail small{color:#a0a3a8;margin-top:2px;font-size:9px;display:block}.history-space-rail i{z-index:1;background:#8d9095;flex:none;width:16px;height:1px;transition:width .3s;display:block}.history-space-rail ol button[aria-current]{color:#f1f0ed;font-size:13px}.history-space-rail button[aria-current] i{background:#e19779;width:38px;height:2px}.history-space-rail button:hover i{width:30px}.history-space-rail p,.history-space-ui .history-space-more{color:#a0a3a8;text-align:right;width:100%;padding:24px 9px 0 0;font-size:10px;display:block}[data-open]>.history-space-ui .history-space-stack{opacity:1;transition-delay:.48s}@starting-style{.history-space-shell[data-open] .history-space-paper{border-color:#0000;border-radius:0;box-shadow:0 0 #0000,0 0 #0000}[data-open]>.history-space-ui .history-space-stack,.history-space-shell[data-open]>.history-space-ui{opacity:0}}@media (width<=1280px){.history-space-name{max-width:160px}.history-space-description{display:none}}@media (prefers-reduced-motion:reduce){.history-space-shell,.history-space-ui,.history-space-toc>nav,.history-space-comments,.history-space-rail i,.history-space-stack,.history-space-ui .history-space-sheet,.history-space-shell .history-space-paper,.ryugi-doc [data-doc-topbar]{transition:none}}
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./shims-s-YVfIlz.js","./rolldown-runtime-XKyaHtl9.js","./SnapshotDocument-B9mIj1Hu.js","./editor-B9cVjpUI.js","./route-BEA0O_Ry.js","./bem-vbke-3KC.js","./react-DlmbjZJV.js","./jsx-runtime-LKYXHABd.js","./types-BCsOeYI6.js","./index2.css","./url-BaZreTXB.js","./useLayerZIndex-C1JpT09z.js","./MotionConfigContext-BqjwrGj9.js","./is-html-element-DvgHo_1h.js","./WhiteboardEditor-DrHOvXez-Bd1MyHmC.js","./Popover-HS6yjzxl.js","./chevron-right-DBC0wrKu.js","./stringifyLocale-VcrwrbQl.js","./code-CTMZ5SpG.js","./SelectScrollUpArrow-BFRXZrFq.js","./zoom-out-Cz3087-F.js","./text-align-start-CO9CK_EW.js","./ruler-DmQbsUQf.js","./maximize-2-Deo2WY_L.js","./mouse-pointer-2-naHRayvu.js","./undo-2-BH3P-I_n.js","./plus-C3ivaMGn.js","./MenuSubmenuTrigger-CLeiXsan.js","./index3.css","./Tooltip-Bi4V2FVJ.js","./pen-tool-B7HWrrcR.js","./underline-AY5gu1iN.js","./route-messages-o8lg2hOP.js","./ref-DjRYiP25.js","./table-2-F7QzFSYG.js","./video-tvDNJEhe.js","./message-square-BQbestX7.js","./presentation-qzIErT_u.js","./ThreadView-DTGR5uqU.js","./comments-DUAz1Q9X.js","./stable-DP74aChD.js","./icons-CCSPm9SD.js","./index5.css","./search-EBZOryv1.js","./shield-check-TdIPOf4j.js","./sliders-horizontal-DZKoxRty.js","./upload-D0s2oA1h.js","./agentLook-BPPrbQJ3.js","./DotGrid-DKKr_PyM.js","./rounds-DC6Dulo5.js","./useMedia-CFebB4XU.js","./BottomSheet-SYC_8Y6k.js","./motion-Cy65kd7X.js","./preference-oNdcNeml.js","./useSandboxFrame-CJmSnwgG.js","./index4.css","./DocumentExportMenu-DyhweUFo.js","./DropdownMenu-Dza6-jeN.js","./channel-Cuvtl_mH.js","./plugin-_bGVeqI0--OtMqC7P.js","./artifact-list-CuXyveqX.js","./embed-src-CmyqZplg.js","./jump-history-B-4GHf3_.js","./Canvas-CMN5apcj.js","./cssVar.stylex-CGbpAC1Y.js","./WritingCursor-CLEFH9bN.js","./PlaybackIcon-C4gbwHHl.js","./elements-4A4Lq7OM.js","./view-Bw41z8XN.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{t as n}from"./react-DlmbjZJV.js";import{C as r,E as i,f as a,j as o,o as s,s as c}from"./route-BEA0O_Ry.js";import{_ as l,i as u,m as d,y as f}from"./view-Bw41z8XN.js";import{t as p}from"./DotGrid-DKKr_PyM.js";import{t as m}from"./jsx-runtime-LKYXHABd.js";var h=t(n(),1),g={message:{kVAEAm:`xixxii4`,k87sOh:`x13vifvy`,kCIrl2:`x3m8u43`,krVfgx:`x1ey2m1c`,kbCHJM:`xu96u03`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kMv6JI:`xqfszdh`,kGuDYH:`xwsyq91`,kMwMTN:`x1bo0w0s`,kWkggS:`x184qs1t`,$$css:!0},html:{kVAEAm:`xixxii4`,k87sOh:`x13vifvy`,kCIrl2:`x3m8u43`,krVfgx:`x1ey2m1c`,kbCHJM:`xu96u03`,k1xSpc:`x1lliihq`,kzqmXN:`xh8yej3`,kZKoxP:`x5yr21d`,kMzoRj:`xc342km`,kfzvcC:`x47corl`,$$css:!0},canvas:{kVAEAm:`xixxii4`,k87sOh:`x13vifvy`,kCIrl2:`x3m8u43`,krVfgx:`x1ey2m1c`,kbCHJM:`xu96u03`,kVQacm:`xb3r6kr`,kWkggS:`x184qs1t`,$$css:!0}},_=m(),v=(0,h.lazy)(()=>i(()=>import(`./shims-s-YVfIlz.js`).then(e=>e.t).then(()=>i(()=>import(`./SnapshotDocument-B9mIj1Hu.js`),__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62]),import.meta.url)),__vite__mapDeps([0,1]),import.meta.url)),y=(0,h.lazy)(()=>i(async()=>{let{Canvas:e}=await import(`./Canvas-CMN5apcj.js`).then(e=>e.n);return{Canvas:e}},__vite__mapDeps([63,1,8,64,4,5,6,7,9,47,41,12,65,23,66,67,68]),import.meta.url).then(({Canvas:e})=>({default:e}))),b=()=>()=>{},x=()=>{},S=new Set,C={scrollX:0,scrollY:0,zoom:1};function w({type:e,id:t,data:n,failed:i}){let{t:c}=r(),[m,w]=(0,h.useState)(()=>({width:innerWidth,height:innerHeight}));(0,h.useEffect)(()=>{let e=()=>w({width:innerWidth,height:innerHeight});return addEventListener(`resize`,e),()=>removeEventListener(`resize`,e)},[]);let T=e=>(0,_.jsx)(`div`,{...o(g.message),children:e}),E=(0,_.jsx)(`div`,{...o(g.message),children:(0,_.jsx)(a,{stack:!0,label:c(`preview.loading`),size:32})});if(i)return T(c(`preview.unavailable`));if(!n)return E;let D=s(e).cardPreview;if(D===`page`)return n.warnings?.length?T(c(`preview.waitingPage`)):(0,_.jsx)(`iframe`,{...o(g.html),sandbox:`allow-scripts`,src:`${n.contentBase}index.html`,tabIndex:-1,title:n.title});if(D===`document`)return n.state?(0,_.jsx)(l,{resetKey:n.state,children:(0,_.jsx)(h.Suspense,{fallback:E,children:(0,_.jsx)(v,{contentBase:n.contentBase,id:t,state:n.state})})}):T(c(`preview.waitingDocument`));let O=n.canvas,k=O?.activePage??O?.pages[0]?.id,A=k?n.layout?.pages[k]?.bounds:null;if(!O||!k||!A)return T(c(`preview.waitingCanvas`));let j=u(A,m,{top:24,right:24,bottom:24,left:24}),M=Object.entries(O.boards).filter(([,e])=>e.page===k);return(0,_.jsxs)(`div`,{...o(g.canvas),children:[(0,_.jsx)(p,{color:`var(--lobe-color-border)`,spacing:12,viewport:C}),(0,_.jsx)(l,{resetKey:O,children:(0,_.jsx)(h.Suspense,{fallback:E,children:(0,_.jsx)(y,{boards:M,contentBase:n.contentBase,frameLoaded:x,frameRef:b,inspecting:!1,notes:Object.entries(O.notes??{}).filter(([,e])=>e.page===k),pending:new Set(n.pending),playing:S,replays:{},routes:f(O,k),versions:n.versions??{},view:j,culled:d(M.map(([e,t])=>({id:e,...t})),j,m)})})})]})}var T=e({PreviewLayout:()=>D});function E(e){let[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let t=new AbortController;return fetch(e,{signal:t.signal,credentials:`same-origin`}).then(e=>{if(!e.ok)throw Error(`Preview unavailable`);return e.json()}).then(n).catch(()=>{t.signal.aborted||i(!0)}),()=>t.abort()},[e]),{data:t,failed:r}}function D({type:e,id:t}){let{data:n,failed:r}=E(c(`/api/preview/${e}/${t}`));return(0,_.jsx)(w,{data:n,failed:r,id:t,type:e})}export{T as n,g as r,D as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./shims-s-YVfIlz.js","./rolldown-runtime-XKyaHtl9.js","./SnapshotDocument-C7mV8NQn.js","./editor-CLF22MpT.js","./route-BEA0O_Ry.js","./bem-vbke-3KC.js","./react-DlmbjZJV.js","./jsx-runtime-LKYXHABd.js","./types-BCsOeYI6.js","./index2.css","./url-BaZreTXB.js","./useLayerZIndex-C1JpT09z.js","./MotionConfigContext-BqjwrGj9.js","./is-html-element-DvgHo_1h.js","./WhiteboardEditor-DrHOvXez-Bd1MyHmC.js","./Popover-HS6yjzxl.js","./chevron-right-DBC0wrKu.js","./stringifyLocale-VcrwrbQl.js","./code-CTMZ5SpG.js","./SelectScrollUpArrow-BFRXZrFq.js","./zoom-out-Cz3087-F.js","./text-align-start-CO9CK_EW.js","./ruler-DmQbsUQf.js","./maximize-2-Deo2WY_L.js","./mouse-pointer-2-naHRayvu.js","./undo-2-BH3P-I_n.js","./plus-C3ivaMGn.js","./MenuSubmenuTrigger-CLeiXsan.js","./index3.css","./Tooltip-Bi4V2FVJ.js","./pen-tool-B7HWrrcR.js","./underline-AY5gu1iN.js","./route-messages-o8lg2hOP.js","./ref-DjRYiP25.js","./table-2-F7QzFSYG.js","./video-tvDNJEhe.js","./message-square-BQbestX7.js","./presentation-qzIErT_u.js","./ThreadView-DTGR5uqU.js","./comments-DUAz1Q9X.js","./stable-DP74aChD.js","./icons-CCSPm9SD.js","./index5.css","./search-EBZOryv1.js","./shield-check-TdIPOf4j.js","./sliders-horizontal-DZKoxRty.js","./upload-D0s2oA1h.js","./agentLook-BPPrbQJ3.js","./DotGrid-DKKr_PyM.js","./rounds-DC6Dulo5.js","./useMedia-CFebB4XU.js","./BottomSheet-SYC_8Y6k.js","./motion-Cy65kd7X.js","./preference-oNdcNeml.js","./useSandboxFrame-CJmSnwgG.js","./index4.css","./DocumentExportMenu-DyhweUFo.js","./DropdownMenu-Dza6-jeN.js","./channel-RZcAq9dq.js","./plugin-_bGVeqI0-D20LzbhT.js","./artifact-list-CuXyveqX.js","./embed-src-CmyqZplg.js","./jump-history-B-4GHf3_.js","./Canvas-CMN5apcj.js","./cssVar.stylex-CGbpAC1Y.js","./WritingCursor-CLEFH9bN.js","./PlaybackIcon-C4gbwHHl.js","./elements-4A4Lq7OM.js","./view-Bw41z8XN.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{t as n}from"./react-DlmbjZJV.js";import{C as r,E as i,f as a,j as o,o as s,s as c}from"./route-BEA0O_Ry.js";import{_ as l,i as u,m as d,y as f}from"./view-Bw41z8XN.js";import{t as p}from"./DotGrid-DKKr_PyM.js";import{t as m}from"./jsx-runtime-LKYXHABd.js";var h=t(n(),1),g={message:{kVAEAm:`xixxii4`,k87sOh:`x13vifvy`,kCIrl2:`x3m8u43`,krVfgx:`x1ey2m1c`,kbCHJM:`xu96u03`,k1xSpc:`x78zum5`,kGNEyG:`x6s0dn4`,kjj79g:`xl56j7k`,kMv6JI:`xqfszdh`,kGuDYH:`xwsyq91`,kMwMTN:`x1bo0w0s`,kWkggS:`x184qs1t`,$$css:!0},html:{kVAEAm:`xixxii4`,k87sOh:`x13vifvy`,kCIrl2:`x3m8u43`,krVfgx:`x1ey2m1c`,kbCHJM:`xu96u03`,k1xSpc:`x1lliihq`,kzqmXN:`xh8yej3`,kZKoxP:`x5yr21d`,kMzoRj:`xc342km`,kfzvcC:`x47corl`,$$css:!0},canvas:{kVAEAm:`xixxii4`,k87sOh:`x13vifvy`,kCIrl2:`x3m8u43`,krVfgx:`x1ey2m1c`,kbCHJM:`xu96u03`,kVQacm:`xb3r6kr`,kWkggS:`x184qs1t`,$$css:!0}},_=m(),v=(0,h.lazy)(()=>i(()=>import(`./shims-s-YVfIlz.js`).then(e=>e.t).then(()=>i(()=>import(`./SnapshotDocument-C7mV8NQn.js`),__vite__mapDeps([2,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62]),import.meta.url)),__vite__mapDeps([0,1]),import.meta.url)),y=(0,h.lazy)(()=>i(async()=>{let{Canvas:e}=await import(`./Canvas-CMN5apcj.js`).then(e=>e.n);return{Canvas:e}},__vite__mapDeps([63,1,8,64,4,5,6,7,9,47,41,12,65,23,66,67,68]),import.meta.url).then(({Canvas:e})=>({default:e}))),b=()=>()=>{},x=()=>{},S=new Set,C={scrollX:0,scrollY:0,zoom:1};function w({type:e,id:t,data:n,failed:i}){let{t:c}=r(),[m,w]=(0,h.useState)(()=>({width:innerWidth,height:innerHeight}));(0,h.useEffect)(()=>{let e=()=>w({width:innerWidth,height:innerHeight});return addEventListener(`resize`,e),()=>removeEventListener(`resize`,e)},[]);let T=e=>(0,_.jsx)(`div`,{...o(g.message),children:e}),E=(0,_.jsx)(`div`,{...o(g.message),children:(0,_.jsx)(a,{stack:!0,label:c(`preview.loading`),size:32})});if(i)return T(c(`preview.unavailable`));if(!n)return E;let D=s(e).cardPreview;if(D===`page`)return n.warnings?.length?T(c(`preview.waitingPage`)):(0,_.jsx)(`iframe`,{...o(g.html),sandbox:`allow-scripts`,src:`${n.contentBase}index.html`,tabIndex:-1,title:n.title});if(D===`document`)return n.state?(0,_.jsx)(l,{resetKey:n.state,children:(0,_.jsx)(h.Suspense,{fallback:E,children:(0,_.jsx)(v,{contentBase:n.contentBase,id:t,state:n.state})})}):T(c(`preview.waitingDocument`));let O=n.canvas,k=O?.activePage??O?.pages[0]?.id,A=k?n.layout?.pages[k]?.bounds:null;if(!O||!k||!A)return T(c(`preview.waitingCanvas`));let j=u(A,m,{top:24,right:24,bottom:24,left:24}),M=Object.entries(O.boards).filter(([,e])=>e.page===k);return(0,_.jsxs)(`div`,{...o(g.canvas),children:[(0,_.jsx)(p,{color:`var(--lobe-color-border)`,spacing:12,viewport:C}),(0,_.jsx)(l,{resetKey:O,children:(0,_.jsx)(h.Suspense,{fallback:E,children:(0,_.jsx)(y,{boards:M,contentBase:n.contentBase,frameLoaded:x,frameRef:b,inspecting:!1,notes:Object.entries(O.notes??{}).filter(([,e])=>e.page===k),pending:new Set(n.pending),playing:S,replays:{},routes:f(O,k),versions:n.versions??{},view:j,culled:d(M.map(([e,t])=>({id:e,...t})),j,m)})})})]})}var T=e({PreviewLayout:()=>D});function E(e){let[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let t=new AbortController;return fetch(e,{signal:t.signal,credentials:`same-origin`}).then(e=>{if(!e.ok)throw Error(`Preview unavailable`);return e.json()}).then(n).catch(()=>{t.signal.aborted||i(!0)}),()=>t.abort()},[e]),{data:t,failed:r}}function D({type:e,id:t}){let{data:n,failed:r}=E(c(`/api/preview/${e}/${t}`));return(0,_.jsx)(w,{data:n,failed:r,id:t,type:e})}export{T as n,g as r,D as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,Ct as n,T as r,Tt as i,b as a,c as o,n as s,r as c,u as l}from"./editor-B9cVjpUI.js";import{n as u}from"./comments-DUAz1Q9X.js";import{t as d}from"./react-DlmbjZJV.js";import{t as f}from"./DocumentExportMenu-DyhweUFo.js";import{E as p,g as m}from"./url-BaZreTXB.js";import{n as h,t as g}from"./useMedia-CFebB4XU.js";import{A as ee,d as _,f as v,h as y,i as b,n as x,o as te,p as ne,t as re,u as ie,v as ae}from"./channel-Cuvtl_mH.js";import{S}from"./route-BEA0O_Ry.js";import{t as C}from"./jsx-runtime-LKYXHABd.js";var w=e(d(),1);function T(e){if(e.op===`reply`)return{op:`reply`,threadId:e.threadId,text:e.text};if(e.op!==`create`)return null;let{op:t,text:n,...r}=e;return r.submit===void 0?r.ask===void 0?{op:`create`,anchor:r,text:n}:{op:`answer`,ask:r.ask,choice:r.choice??null,answer:r.answer??null}:null}var E=C();function D(){let e=(0,w.useMemo)(()=>window.matchMedia(`(prefers-color-scheme: dark)`),[]),[t,n]=(0,w.useState)(e.matches);return(0,w.useEffect)(()=>{let t=()=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[e]),t}var O=e=>!e.text?.trim()&&(e.children??[]).every(O);function k(e){let t=(0,w.useCallback)(async t=>{let n=e?T(t):null;return!n||e.post(n)},[e]);return{send:t,actions:(0,w.useMemo)(()=>e?.canComment?{reply:(e,n)=>t({op:`reply`,threadId:e,text:n}),...e.remove?{remove:(t,n)=>void e.remove(t,n)}:{}}:void 0,[e,t]),create:(0,w.useCallback)((e,n)=>t({op:`create`,blockId:e.blockId,...e.blockIds?{blockIds:e.blockIds}:{},...e.textRanges?{textRanges:e.textRanges}:{},...e.diagram?{diagram:e.diagram}:{},quote:e.quote,text:n}),[t])}}function A({id:e,state:d,contentBase:C,comments:T=u(),contributors:A,offline:j=!1,refs:M,prompt:N,remote:P,scenes:F}){let I=P?.comments??T,L=P?.canComment===!0,{send:R,actions:z,create:B}=k(P),[V,H]=(0,w.useState)(null),U=D(),W=h(g),[G,K]=(0,w.useState)(null),q=te({id:e,editor:G,scenes:F,comments:I,contentBase:C,title:e,cloud:!0}),J=b(G,e,M,F?.use,F?.frames);ie(G);let oe=(0,w.useMemo)(()=>({artifact:`cloud/${e}`,contentBase:C,channel:re(),send:()=>void 0}),[e,C]),[se,ce,le]=x(G,V),Y=(0,w.useMemo)(()=>i(I),[I]),X=(0,w.useMemo)(()=>L?{...Y.host,canAnswer:!0,send:e=>void R(e)}:Y.host,[Y.host,L,R]),Z=Y.open,Q=p(e,{comments:Z,activity:null,retrying:!1,reason:null,history:!1,historyOpen:!1,documentExport:q.state}),ue=ee({activity:null,comments:Z,history:!1,historyOpen:!1,documentExport:q.state},()=>{},q.exportPdf);(0,w.useEffect)(()=>{let e=document.createElement(`base`);return e.href=C,document.head.prepend(e),()=>e.remove()},[C]);let $=(0,E.jsx)(n.Provider,{value:X,children:(0,E.jsx)(l.Provider,{value:oe,children:(0,E.jsxs)(a.Provider,{value:J,children:[N&&(0,E.jsx)(_,{empty:O(d.root),prompt:N,theme:U?`dark`:`light`}),(0,E.jsxs)(r,{children:[(0,E.jsx)(t,{extraNodes:s,initialValue:d,rendererConfig:c,theme:U?`dark`:`light`,variant:`article`,onEditorReady:e=>{e?.setEditable(!1),K(e??null)},children:(0,E.jsx)(o,{})}),G&&A?(0,E.jsx)(ne,{byline:A,editor:G}):null]})]})})});return(0,E.jsxs)(`div`,{className:`xugpy4h x1us19tq x1rozbrz xo2rkog`,className:`ryugi-doc ${{className:`xugpy4h x1us19tq x1rozbrz xo2rkog`}.className??``}`,children:[!Q&&!ue?(0,E.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x17d4w8g x1vqgdyp x4l9tsp x1bo0w0s xqfszdh xfifm61`,children:[(0,E.jsx)(m,{available:!1,comments:Z,compact:W,open:!1,onComments:()=>{},onHistory:()=>{}}),(0,E.jsx)(`span`,{className:`xt0psk2 xkaaz9w x98rzlu`,children:S(`document.historyOffline`)}),(0,E.jsx)(f,{state:q.state,onExport:q.exportPdf})]}):null,j?(0,E.jsxs)(`div`,{...{0:{className:`x78zum5 x6s0dn4 x17d4w8g x1vqgdyp x4l9tsp x1bo0w0s xqfszdh xfifm61`},1:{className:`x6s0dn4 x17d4w8g x1vqgdyp x4l9tsp x1bo0w0s xqfszdh xfifm61 x1s85apg x1ux6vrq`}}[!!Q|0],children:[(0,E.jsx)(`i`,{className:`xci0xqf x1hagigm x16rqkct xxwmxtg`}),S(`document.offlineNoComments`)]}):null,L&&!W?(0,E.jsx)(y,{canComment:!0,actions:z,canCommentDiagram:!1,clearSelection:ce,editor:G,resolveSelection:le,selection:se,threads:Y.threads,onCreate:B,onMain:H,children:$}):(0,E.jsx)(ae,{actions:z,editor:G,threads:Y.threads,children:$}),(0,E.jsx)(v,{error:q.error,onDismiss:q.dismiss})]})}export{A as default};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$ as t,Ct as n,T as r,Tt as i,b as a,c as o,n as s,r as c,u as l}from"./editor-CLF22MpT.js";import{n as u}from"./comments-DUAz1Q9X.js";import{t as d}from"./react-DlmbjZJV.js";import{t as f}from"./DocumentExportMenu-DyhweUFo.js";import{E as p,g as m}from"./url-BaZreTXB.js";import{n as h,t as g}from"./useMedia-CFebB4XU.js";import{A as ee,d as _,f as v,h as y,i as b,n as x,o as te,p as ne,t as re,u as ie,v as ae}from"./channel-RZcAq9dq.js";import{S}from"./route-BEA0O_Ry.js";import{t as C}from"./jsx-runtime-LKYXHABd.js";var w=e(d(),1);function T(e){if(e.op===`reply`)return{op:`reply`,threadId:e.threadId,text:e.text};if(e.op!==`create`)return null;let{op:t,text:n,...r}=e;return r.submit===void 0?r.ask===void 0?{op:`create`,anchor:r,text:n}:{op:`answer`,ask:r.ask,choice:r.choice??null,answer:r.answer??null}:null}var E=C();function D(){let e=(0,w.useMemo)(()=>window.matchMedia(`(prefers-color-scheme: dark)`),[]),[t,n]=(0,w.useState)(e.matches);return(0,w.useEffect)(()=>{let t=()=>n(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[e]),t}var O=e=>!e.text?.trim()&&(e.children??[]).every(O);function k(e){let t=(0,w.useCallback)(async t=>{let n=e?T(t):null;return!n||e.post(n)},[e]);return{send:t,actions:(0,w.useMemo)(()=>e?.canComment?{reply:(e,n)=>t({op:`reply`,threadId:e,text:n}),...e.remove?{remove:(t,n)=>void e.remove(t,n)}:{}}:void 0,[e,t]),create:(0,w.useCallback)((e,n)=>t({op:`create`,blockId:e.blockId,...e.blockIds?{blockIds:e.blockIds}:{},...e.textRanges?{textRanges:e.textRanges}:{},...e.diagram?{diagram:e.diagram}:{},quote:e.quote,text:n}),[t])}}function A({id:e,state:d,contentBase:C,comments:T=u(),contributors:A,offline:j=!1,refs:M,prompt:N,remote:P,scenes:F}){let I=P?.comments??T,L=P?.canComment===!0,{send:R,actions:z,create:B}=k(P),[V,H]=(0,w.useState)(null),U=D(),W=h(g),[G,K]=(0,w.useState)(null),q=te({id:e,editor:G,scenes:F,comments:I,contentBase:C,title:e,cloud:!0}),J=b(G,e,M,F?.use,F?.frames);ie(G);let oe=(0,w.useMemo)(()=>({artifact:`cloud/${e}`,contentBase:C,channel:re(),send:()=>void 0}),[e,C]),[se,ce,le]=x(G,V),Y=(0,w.useMemo)(()=>i(I),[I]),X=(0,w.useMemo)(()=>L?{...Y.host,canAnswer:!0,send:e=>void R(e)}:Y.host,[Y.host,L,R]),Z=Y.open,Q=p(e,{comments:Z,activity:null,retrying:!1,reason:null,history:!1,historyOpen:!1,documentExport:q.state}),ue=ee({activity:null,comments:Z,history:!1,historyOpen:!1,documentExport:q.state},()=>{},q.exportPdf);(0,w.useEffect)(()=>{let e=document.createElement(`base`);return e.href=C,document.head.prepend(e),()=>e.remove()},[C]);let $=(0,E.jsx)(n.Provider,{value:X,children:(0,E.jsx)(l.Provider,{value:oe,children:(0,E.jsxs)(a.Provider,{value:J,children:[N&&(0,E.jsx)(_,{empty:O(d.root),prompt:N,theme:U?`dark`:`light`}),(0,E.jsxs)(r,{children:[(0,E.jsx)(t,{extraNodes:s,initialValue:d,rendererConfig:c,theme:U?`dark`:`light`,variant:`article`,onEditorReady:e=>{e?.setEditable(!1),K(e??null)},children:(0,E.jsx)(o,{})}),G&&A?(0,E.jsx)(ne,{byline:A,editor:G}):null]})]})})});return(0,E.jsxs)(`div`,{className:`xugpy4h x1us19tq x1rozbrz xo2rkog`,className:`ryugi-doc ${{className:`xugpy4h x1us19tq x1rozbrz xo2rkog`}.className??``}`,children:[!Q&&!ue?(0,E.jsxs)(`div`,{className:`x78zum5 x6s0dn4 x17d4w8g x1vqgdyp x4l9tsp x1bo0w0s xqfszdh xfifm61`,children:[(0,E.jsx)(m,{available:!1,comments:Z,compact:W,open:!1,onComments:()=>{},onHistory:()=>{}}),(0,E.jsx)(`span`,{className:`xt0psk2 xkaaz9w x98rzlu`,children:S(`document.historyOffline`)}),(0,E.jsx)(f,{state:q.state,onExport:q.exportPdf})]}):null,j?(0,E.jsxs)(`div`,{...{0:{className:`x78zum5 x6s0dn4 x17d4w8g x1vqgdyp x4l9tsp x1bo0w0s xqfszdh xfifm61`},1:{className:`x6s0dn4 x17d4w8g x1vqgdyp x4l9tsp x1bo0w0s xqfszdh xfifm61 x1s85apg x1ux6vrq`}}[!!Q|0],children:[(0,E.jsx)(`i`,{className:`xci0xqf x1hagigm x16rqkct xxwmxtg`}),S(`document.offlineNoComments`)]}):null,L&&!W?(0,E.jsx)(y,{canComment:!0,actions:z,canCommentDiagram:!1,clearSelection:ce,editor:G,resolveSelection:le,selection:se,threads:Y.threads,onCreate:B,onMain:H,children:$}):(0,E.jsx)(ae,{actions:z,editor:G,threads:Y.threads,children:$}),(0,E.jsx)(v,{error:q.error,onDismiss:q.dismiss})]})}export{A as default};