chamba 0.8.0 → 0.10.0

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 (73) hide show
  1. package/README.md +14 -3
  2. package/dist/commands/dev.js +11 -11
  3. package/dist/commands/menu.js +1 -1
  4. package/dist/commands/settings.js +9 -6
  5. package/dist/lib/awake-holder.js +3 -0
  6. package/dist/lib/awake-marker.js +4 -0
  7. package/dist/lib/awake.js +1 -0
  8. package/dist/lib/chamba-yaml.js +4 -4
  9. package/dist/lib/constants.js +1 -1
  10. package/dist/lib/global-config.js +3 -3
  11. package/dist/lib/skills.js +2 -2
  12. package/package.json +1 -1
  13. package/templates/Dockerfile +3 -3
  14. package/templates/context/baseline.md +2 -2
  15. package/templates/context/web-pane-craft.md +1 -1
  16. package/templates/pane-apps/client/assets/api-CguEsvNp.js +12 -0
  17. package/templates/pane-apps/client/assets/api-Cyoc3E6K.css +1 -0
  18. package/templates/pane-apps/client/assets/bee-B7t97l5B.webp +0 -0
  19. package/templates/pane-apps/client/assets/buzz-CUUsbnXH.mp3 +0 -0
  20. package/templates/pane-apps/client/assets/home-CLFnmg7u.css +1 -0
  21. package/templates/pane-apps/client/assets/home-CrhBkqDQ.js +1 -0
  22. package/templates/pane-apps/client/assets/pop-D5ZANBC3.mp3 +0 -0
  23. package/templates/pane-apps/client/assets/reviews-Bq8EwmG-.js +153 -0
  24. package/templates/pane-apps/client/assets/reviews-DzHtA35Q.css +1 -0
  25. package/templates/pane-apps/client/assets/search-DgFnnu-J.js +1 -0
  26. package/templates/pane-apps/client/assets/specs-JvdNFtXR.js +13 -0
  27. package/templates/pane-apps/client/assets/useNow-Ww-Gffnk.js +1 -0
  28. package/templates/pane-apps/client/home/index.html +16 -0
  29. package/templates/pane-apps/client/reviews/index.html +6 -4
  30. package/templates/pane-apps/client/specs/index.html +4 -3
  31. package/templates/pane-apps/server/home.mjs +11 -0
  32. package/templates/pane-apps/server/reviews.mjs +19 -18
  33. package/templates/pane-apps/server/specs.mjs +4 -4
  34. package/templates/skills/dx-review/SKILL.md +16 -3
  35. package/templates/skills/dx-review/references/acts.md +86 -15
  36. package/templates/skills/dx-spec/SKILL.md +11 -19
  37. package/templates/skills/dx-spec/references/review-guide.md +15 -9
  38. package/templates/skills/dx-spec/references/spec-guide.md +12 -5
  39. package/templates/skills/dx-spec/references/stages.md +44 -24
  40. package/templates/skills/dx-spec-execute/SKILL.md +78 -28
  41. package/templates/startup.mjs +13 -13
  42. package/templates/tool-helper.sh +4 -2
  43. package/templates/webterm/README.md +41 -17
  44. package/templates/webterm/awake.js +27 -0
  45. package/templates/webterm/config.js +30 -0
  46. package/templates/webterm/public/app/alerts.js +92 -11
  47. package/templates/webterm/public/app/composer.js +37 -3
  48. package/templates/webterm/public/app/connection.js +14 -0
  49. package/templates/webterm/public/app/dom.js +1 -0
  50. package/templates/webterm/public/app/frames.js +1 -1
  51. package/templates/webterm/public/app/home-host.js +16 -0
  52. package/templates/webterm/public/app/main.js +4 -2
  53. package/templates/webterm/public/app/pane-shape.js +5 -3
  54. package/templates/webterm/public/app/pane-shell.js +45 -5
  55. package/templates/webterm/public/app/pane.js +8 -2
  56. package/templates/webterm/public/app/reviews-host.js +5 -1
  57. package/templates/webterm/public/app/state.js +4 -0
  58. package/templates/webterm/public/app/tabs.js +37 -3
  59. package/templates/webterm/public/app/tool-host.js +19 -3
  60. package/templates/webterm/public/app/workspace-color.js +1 -1
  61. package/templates/webterm/public/index.html +5 -1
  62. package/templates/webterm/public/styles.css +65 -0
  63. package/templates/webterm/server.js +24 -1
  64. package/templates/webterm/tool-document.js +3 -2
  65. package/templates/webterm/tools/home.js +80 -0
  66. package/templates/webterm/tools/index.js +5 -4
  67. package/templates/webterm/tools/reviews.js +7 -3
  68. package/templates/pane-apps/client/assets/files-D0nJgFAA.js +0 -12
  69. package/templates/pane-apps/client/assets/files-h0K1vZyQ.css +0 -1
  70. package/templates/pane-apps/client/assets/reviews-BsoGZ35r.css +0 -1
  71. package/templates/pane-apps/client/assets/reviews-iW0Mbn4e.js +0 -153
  72. package/templates/pane-apps/client/assets/specs-D9z3neR-.js +0 -13
  73. package/templates/skills/dx-spec/references/principles-template.md +0 -2
@@ -0,0 +1 @@
1
+ import{A as e,C as t,D as n,E as r,O as i,c as a,i as o,k as s,n as c,r as l,s as u,t as d,y as f}from"./api-CguEsvNp.js";import{t as p}from"./useNow-Ww-Gffnk.js";var m=e(),h=i(),g=/^[A-Za-z0-9._/-]+$/;function _(e){return g.test(e)?e:`'${e.replace(/'/g,`'\\''`)}'`}function v(e){return e===`merged`||e===`squash`||e===`stale`}function y(e,t){return`git branch ${t===`merged`?`-d`:`-D`} -- ${_(e)}`}var b=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function x(e){return e.toLocaleString(`en-GB`)}function S(e,t){return`${x(e)} ${t}${e===1?``:`s`}`}function C(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(t===null)return null;let n=Number(t[2])-1;return n<0||n>11?null:{year:t[1]??``,month:n,date:Number(t[3])}}function w(e){if(e===null)return``;let t=C(e.slice(0,10));return t===null?``:`${t.date} ${b[t.month]} ${t.year}`}function T(e){let t=C(e.slice(0,10));return t===null?``:`${t.date} ${b[t.month]}`}function ee(e,t){let n=C(e.slice(0,10)),r=C(t.slice(0,10));return n===null||r===null?``:n.year===r.year&&n.month===r.month?`${n.date}-${r.date} ${b[n.month]}`:`${T(e)} - ${T(t)}`}function te(e){return e===0?`working tree clean`:`${S(e,`uncommitted change`)}`}function ne(e,t){return`+${x(e)} / -${x(t)}`}var E=n();function re(e,t){switch(e){case`current`:return`current`;case`default`:return`default`;case`merged`:return`merged`;case`squash`:return`merged (squash)`;case`stale`:return`stale`;default:return`ahead of ${t}`}}function ie(e){let t=e.filter(e=>e.state===`merged`||e.state===`squash`).length,n=e.filter(e=>e.state===`stale`).length;return`${x(e.length)} local · ${x(t)} merged, ${x(n)} stale`}function ae(e,t){return e===`stale`?{said:`This branch holds work that is not on ${t}. The command deletes it anyway.`,warn:!0}:e===`squash`?{said:`Squash-merged into ${t}. git cannot see a squash merge, so the force flag is needed. Home checked that the whole change is on ${t}.`,warn:!1}:{said:`Merged into ${t}, so the safe delete works.`,warn:!1}}function oe(e){let t=e.default??`the default branch`,[n,i]=(0,m.useState)(null),a=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(n===null)return;let e=e=>{a.current?.contains(e.target)!==!0&&i(null)};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)},[n]),(0,E.jsx)(`div`,{className:`hm-list`,children:e.branches.map(o=>{let s=o.ahead>0?` · ${S(o.ahead,`commit`)} ahead of ${t}`:``;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{className:`hm-name`,title:`${o.name}${s}`,children:o.name}),(0,E.jsx)(`span`,{className:`hm-muted`,children:u(o.lastCommit,e.now)}),(0,E.jsx)(`span`,{className:`hm-flag hm-${o.state}`,children:re(o.state,t)}),(0,E.jsx)(`span`,{className:`hm-pop`,children:v(o.state)&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{type:`button`,className:`hm-del`,title:`Delete this branch`,onClick:e=>{e.stopPropagation(),i(n===o.name?null:o.name)},children:(0,E.jsx)(r,{size:14})}),n===o.name&&(0,E.jsx)(se,{branch:o,into:t,held:a})]})})]},o.name)})})}function se(e){let t=ae(e.branch.state,e.into),n=y(e.branch.name,e.branch.state);return(0,E.jsxs)(`div`,{className:`hm-popover`,ref:e.held,children:[(0,E.jsxs)(`p`,{children:[(0,E.jsx)(`span`,{className:t.warn?`hm-warn-text`:void 0,children:t.said}),` Deletes the local branch alone: a remote branch of the same name is not touched.`]}),(0,E.jsxs)(`div`,{className:`hm-cmd`,children:[(0,E.jsx)(`input`,{readOnly:!0,value:n,"aria-label":`The command that deletes this branch`,onClick:e=>e.currentTarget.select()}),(0,E.jsx)(`span`,{className:`hm-hint`,children:`click selects · copy with the keyboard`})]})]})}function D(e){let{title:t,note:n,state:r,said:i,loaderHeight:a=120}=e;return(0,E.jsxs)(`section`,{className:e.className===void 0?`hm-card`:`hm-card ${e.className}`,children:[t!==void 0&&(0,E.jsxs)(`h3`,{children:[t,r===`read`&&n!==void 0&&(0,E.jsx)(`small`,{children:n})]}),r===`loading`?(0,E.jsx)(`div`,{className:`hm-loader`,style:{height:`${a}px`}}):r===`failed`?(0,E.jsxs)(`p`,{className:`hm-notice`,children:[(0,E.jsx)(`span`,{children:i}),` `,(0,E.jsx)(`span`,{className:`hm-muted`,children:`Read the repository again to try.`})]}):e.children]})}var ce=``+new URL(`bee-B7t97l5B.webp`,import.meta.url).href,le=``+new URL(`buzz-CUUsbnXH.mp3`,import.meta.url).href,ue=``+new URL(`pop-D5ZANBC3.mp3`,import.meta.url).href,O=[{said:`Simplicity is prerequisite for reliability.`,who:`Edsger W. Dijkstra, EWD498, 1975`},{said:`Any organization that designs a system will produce a design whose structure is a copy of the organization's communication structure.`,who:`Melvin Conway, How Do Committees Invent?, 1967`},{said:`Perfection is attained not when there is nothing more to add, but when there is nothing left to take away.`,who:`Antoine de Saint-Exupéry, Terre des Hommes, 1939`},{said:`Have nothing in your houses that you do not know to be useful, or believe to be beautiful.`,who:`William Morris, The Beauty of Life, 1880`}],de=640,fe=[270,330],pe=[30,60],me=[.15,.75],he=[60,120],ge=[95,125],_e=16,ve=[14,32],ye=[2.2,3.4],be=.6,xe=.25,Se=.05;function k(e,t){return e+Math.random()*(t-e)}function A(){return{width:window.innerWidth,height:window.innerHeight}}var Ce={scale:1,quick:1,gap:fe,talks:!0},j={scale:1/3,quick:3,gap:he,talks:!1};function M(e,t){return Math.round(110*Math.min(1,t.width/de)*e.scale)}function we(e,t){let n=t.height*me[0]+e,r=t.height*me[1]-e;if(r>n)return[n,r];let i=(n+r)/2;return[i,i]}function Te(){return window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0}function Ee(e,t){return{x:0,y:0,base:0,amplitude:0,period:3,t:0,direction:1,speed:110,tilt:0,away:t,flying:!1,clicks:0,dart:null,drawn:0,kind:e}}function De(e,t){let n=M(e.kind,t),r=Math.random()*Math.PI-Math.PI/2,[i,a]=we(e.amplitude,t),o=Math.max(0,Math.min(t.width-n,e.x-e.direction*Math.cos(r)*n));o=e.direction>0?Math.min(o,e.x):Math.max(o,e.x);let s=Math.max(i,Math.min(a,e.base+Math.sin(r)*n));e.dart={fromX:e.x,fromY:e.y,toX:o,toY:s,t:0}}function N(e){let t=(0,m.useRef)(null),n=(0,m.useRef)(null),r=(0,m.useRef)(null),[i]=(0,m.useState)(Te),[a,o]=(0,m.useState)(null),s=(0,m.useRef)(e.sound);s.current=e.sound;let c=(0,m.useRef)(0),[l]=(0,m.useState)(()=>Math.floor(Math.random()*O.length)),u=(0,m.useRef)(null),[d]=(0,m.useState)(()=>Ee(Ce,k(pe[0],pe[1]))),[f]=(0,m.useState)(()=>Ee(j,k(j.gap[0],j.gap[1]))),p=(0,m.useRef)(()=>{}),h=(0,m.useCallback)(()=>{o({quote:(l+c.current)%O.length,shown:!0}),c.current+=1,u.current={left:6,hovered:!1,fading:0},p.current()},[l]),g=(0,m.useCallback)(e=>{if(s.current)try{let t=new Audio(e);t.volume=.7,t.play().catch(e=>{console.warn(`[home] the bee could not play its clip:`,e)})}catch(e){console.warn(`[home] the bee could not play its clip:`,e)}},[]),_=(0,m.useCallback)(e=>{if(!(e.kind.talks&&u.current!==null)){if(i){g(ue),h();return}if(e.flying){if(e.kind.talks&&(e.clicks+=1,e.clicks>=3)){g(ue),h();return}g(le),De(e,A())}}},[g,h,i]),v=(0,m.useCallback)(()=>{let e=u.current;e!==null&&(e.hovered=!0)},[]),y=(0,m.useCallback)(()=>{let e=u.current;e!==null&&(e.hovered=!1,e.left=Math.max(e.left,1))},[]);(0,m.useEffect)(()=>{let e=t.current;if(e===null)return;i&&(e.style.width=`${M(Ce,A())}px`,e.classList.add(`hm-parked`,`hm-here`));let a=0,s=0,c=(e,t,n)=>{let r=M(e.kind,n.view);if(r!==e.drawn&&(e.drawn=r,t.style.width=`${r}px`),e.flying){let i=e.kind.talks&&u.current!==null;if(e.dart!==null){let t=e.dart;t.t+=n.flown;let r=Math.min(1,t.t/xe),i=1-(1-r)**3;e.x=t.fromX+(t.toX-t.fromX)*i,e.y=t.fromY+(t.toY-t.fromY)*i,r>=1&&(e.base=t.toY,e.dart=null,e.t=0)}else if(!(i&&u.current?.hovered===!0)){let t=i?_e:e.speed;e.t+=n.flown,e.x+=e.direction*t*n.flown;let r=e.t/e.period*2*Math.PI;e.y=e.base+Math.sin(r)*e.amplitude;let a=Math.cos(r)*e.amplitude*2*Math.PI/e.period;e.tilt=Math.atan2(a,t)*180/Math.PI*be}(e.x<-r*1.5||e.x>n.view.width+r*.5)&&!i&&(e.flying=!1,e.away=k(e.kind.gap[0],e.kind.gap[1]),t.classList.remove(`hm-here`))}else{if(e.away-=n.waited,e.away>0)return;e.direction=Math.random()<.5?1:-1,e.x=e.direction>0?-r:n.view.width,e.amplitude=k(ve[0],ve[1]);let[i,a]=we(e.amplitude,n.view);e.base=k(i,a),e.y=e.base,e.tilt=0,e.period=k(ye[0],ye[1]),e.speed=k(ge[0],ge[1])*e.kind.quick,e.t=0,e.clicks=0,e.dart=null,e.flying=!0,t.classList.add(`hm-here`)}t.style.transform=`translate(${e.x}px, ${e.y}px) scaleX(${e.direction}) rotate(${e.direction*e.tilt}deg)`},l=e=>{let t=u.current;if(t!==null){if(t.fading>0){t.fading-=e,t.fading<=0&&(u.current=null,d.clicks=0,o(null));return}t.hovered||(t.left-=e),t.left<=0&&(t.fading=1,o(e=>e===null?null:{...e,shown:!1}))}},m=t=>{let o=(t-s)/1e3;s=t;let p={waited:o,flown:Math.min(Se,o),view:A()};if(!i){c(d,e,p),n.current!==null&&c(f,n.current,p);let t=r.current;t!==null&&u.current!==null&&(t.style.left=`${Math.min(Math.max(8,d.x-110),p.view.width-300)}px`,t.style.top=`${Math.max(8,d.y-92)}px`)}if(l(p.flown),i&&u.current===null){a=0;return}a=requestAnimationFrame(m)},h=()=>{a===0&&(s=performance.now(),a=requestAnimationFrame(m))};return p.current=h,i||h(),()=>{cancelAnimationFrame(a),a=0,p.current=()=>{}}},[i,d,f]);let b=a===null?null:O[a.quote];return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`button`,{type:`button`,className:`hm-bee`,ref:t,"aria-label":`The bee`,title:`A quote`,onClick:()=>_(d),children:(0,E.jsx)(`img`,{src:ce,alt:``})}),!i&&(0,E.jsx)(`button`,{type:`button`,className:`hm-bee hm-small`,ref:n,"aria-label":`A small bee`,onClick:()=>_(f),children:(0,E.jsx)(`img`,{src:``+new URL(`bee-B7t97l5B.webp`,import.meta.url).href,alt:``})}),(0,E.jsx)(`div`,{className:a?.shown===!0?`hm-bubble hm-said`:`hm-bubble`,ref:r,onMouseEnter:v,onMouseLeave:y,children:b!=null&&(0,E.jsxs)(E.Fragment,{children:[b.said,(0,E.jsxs)(`span`,{className:`hm-who`,children:[`- `,b.who]})]})})]})}var Oe=`counting-exceptions`;function ke(e){return e.length===0?``:e.join(` and `)}function Ae(e){let t=o({className:`hm-infotip hm-counting-tip`,side:`bottom`});if(e.toolPaths.length===0)return null;let n=e.counting===`all`,r=ke(e.toolPaths),i=(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`b`,{children:[`Off, every count of lines and of files on this page leaves out `,r,`.`]}),(0,E.jsx)(`p`,{children:`That is the height of each plant, the lines since Monday, the tree and the growth card.`}),(0,E.jsx)(`p`,{children:`It never changes a count of commits - the total above, the active days, both rhythm cards, the longest streak and the biggest day - nor the uncommitted changes, which are what git status says, nor the branches card, nor the ignored size.`})]});return(0,E.jsxs)(`span`,{className:`hm-counting`,children:[(0,E.jsxs)(`button`,{type:`button`,className:`hm-control hm-switch`,role:`switch`,"aria-checked":n,"aria-describedby":Oe,onClick:()=>e.onChange(n?`work`:`all`),...t.anchor,children:[(0,E.jsx)(`span`,{className:`hm-switch-track`,"aria-hidden":`true`,children:(0,E.jsx)(`i`,{})}),`count chamba files`,t.says(i)]}),(0,E.jsxs)(`span`,{className:`visually-hidden`,id:Oe,children:[`Off, every count of lines and of files on this page leaves out `,r,`. It never changes a count of commits, the uncommitted changes, the branches card or the ignored size.`]})]})}function P(e,t){return t===`all`?e.all:e.work}var je=1e4,F=10,I=170,Me=10,Ne=128,L=12,Pe=60,R=500,z=2e3,B=`Its height follows the lines changed that day, added plus deleted, on a square-root scale so a huge day does not flatten the rest.`,V=`plant-height`,Fe=5,Ie=.7;function Le(e,t){return P(e.added,t)+P(e.deleted,t)}function Re(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)%1e4/1e4}function ze(e,t){let n=Math.min(Math.max((t-R)/(z-R),0),1),r=Math.min(Math.max(n+(Re(e)-.5)*Ie,0),1);return Math.round(r*(Fe-1))}function H(e){let[t=0,n=1,r=1]=e.split(`-`).map(Number);return Date.UTC(t,n-1,r)}function U(e,t){return Math.round((H(t)-H(e))/864e5)}function Be(e,t,n){if(n<=0)return[0,0];let r=t-Pe,i=t+n+Pe,a=0;for(;a<e.length&&(e[a]??0)<r;)a+=1;let o=a;for(;o<e.length&&(e[o]??0)<=i;)o+=1;return[a,o]}function Ve(e,t){let n=[],r=``,i=``;for(let a=0;a<t;a+=1){let t=new Date(H(e)+a*864e5).toISOString().slice(0,10),o=L+a*F;t.slice(0,4)!==i&&(i=t.slice(0,4),n.push({x:o,said:i,year:!0})),t.slice(0,7)!==r&&(r=t.slice(0,7),n.push({x:o,said:T(t).split(` `)[1]??``,year:!1}))}return n}function He(e){let{at:t,lines:n}=e,r=Me+Math.sqrt(n)/e.tallest*Ne,i=I-r,a=e.index%2==0?-3:3,o=I-r*.55;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`path`,{className:`hm-stem`,d:`M${t},${I} q${a},${-r/2} 0,${-r}`}),(0,E.jsx)(`ellipse`,{className:`hm-leaf`,cx:t-4,cy:o,rx:4,ry:2,transform:`rotate(-25 ${t-4} ${o})`}),n>=R?(0,E.jsx)(`circle`,{className:`hm-flower hm-shade-${ze(e.date,n)}`,cx:t,cy:i,r:n>=z?5.5:3.5}):(0,E.jsx)(`circle`,{className:`hm-bud`,cx:t,cy:i,r:2})]})}function Ue(e){let{days:t,today:n,counting:r}=e,i=o({className:`hm-infotip`,side:`top`}),a=(0,m.useRef)(null),s=(0,m.useRef)(null),c=(0,m.useRef)([]),l=(0,m.useRef)([0,0]),[u,d]=(0,m.useState)(!1),p=t[0]?.date??n,h=t[t.length-1]?.date??n,g=Math.max(1,U(p,h>n?h:n)+1),_=g*F+L*2,v=Math.sqrt(Math.max(1,...t.map(e=>Le(e,r)))),y=(0,m.useMemo)(()=>t.filter(e=>e.commits>0).map(e=>({day:e,x:L+U(p,e.date)*F})),[t,p]),b=(0,m.useCallback)(()=>{let e=a.current,t=s.current;if(e===null||t===null)return;let n=t.querySelectorAll(`g.hm-plant`),[r,i]=Be(c.current,e.scrollLeft,e.clientWidth),[o,u]=l.current;for(let e=o;e<u;e+=1)(e<r||e>=i)&&n[e]?.classList.remove(`hm-sway`);for(let e=r;e<i;e+=1)n[e]?.classList.add(`hm-sway`);l.current=[r,i],d(e.scrollLeft>4)},[]);return(0,m.useEffect)(()=>{let e=a.current;if(e===null)return;c.current=y.map(e=>e.x),l.current=[0,0],e.scrollLeft=e.scrollWidth,b();let t=new ResizeObserver(b);return t.observe(e),()=>t.disconnect()},[b,y]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:u?`hm-garden-wrap hm-more`:`hm-garden-wrap`,children:[u&&(0,E.jsxs)(`div`,{className:`hm-earlier`,children:[(0,E.jsx)(`i`,{children:`‹`}),` earlier`]}),(0,E.jsxs)(`div`,{className:`hm-scroll`,ref:a,onScroll:b,"data-testid":`garden-scroll`,children:[(0,E.jsx)(`svg`,{className:`hm-garden`,ref:s,width:_,height:I,role:`img`,"aria-label":`One plant for each day worked on since ${w(p)}`,children:y.map(({day:t,x:n},i)=>(0,E.jsx)(`g`,{className:`hm-plant`,"data-day":t.date,style:{transformOrigin:`${n}px ${I}px`,animationDelay:`${i%7*-.4}s`},...e.hover(`${w(t.date)} · ${ne(P(t.added,r),P(t.deleted,r))} · ${S(t.commits,`commit`)}`),children:(0,E.jsx)(He,{at:n,index:i,date:t.date,lines:Le(t,r),tallest:v})},t.date))}),(0,E.jsx)(`div`,{className:`hm-axis`,style:{width:`${_}px`},children:Ve(p,g).map(e=>(0,E.jsx)(`span`,{className:e.year?`hm-year`:void 0,style:{left:`${e.x}px`},children:e.said},`${e.said}-${e.x}`))})]})]}),(0,E.jsxs)(`div`,{className:`hm-legend`,children:[(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`b`,{children:`Each plant is one day`}),(0,E.jsxs)(`button`,{type:`button`,className:`hm-info`,"aria-label":`What a plant's height means`,"aria-describedby":V,...i.anchor,children:[(0,E.jsx)(f,{size:13}),(0,E.jsx)(`span`,{className:`visually-hidden`,id:V,children:B}),i.says(B)]})]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`i`,{className:`hm-key hm-bud-key`}),`a bud: a day with a change`]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`i`,{className:`hm-key hm-flower-key`}),`a flower: a day of 500 lines or more`]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`i`,{className:`hm-key hm-big-key`}),`a big flower: a day of 2,000 or more`]})]})]})}var W=100,G=100,We=.92;function Ge(e){let t=e[e.length-1];if(t===void 0)return null;let n=Math.max(1,...e),r=e.length===1?0:W/(e.length-1);return{line:e.map((t,i)=>{let a=e.length===1?W/2:i*r,o=G-t/n*G*We;return`${K(a)},${K(o)}`}).join(` `),last:t}}function K(e){return Math.round(e*100)/100}function Ke(e){let{points:t}=e.growth,n=Ge(t.map(t=>P(t.files,e.counting))),r=Ge(t.map(t=>P(t.lines,e.counting)));if(n===null||r===null)return(0,E.jsx)(`p`,{className:`hm-sub`,children:`Counting the history. The line fills in as the points land.`});let i=t[0],a=t[t.length-1],o=t.length===1?W:W/(t.length-1);return(0,E.jsxs)(`div`,{className:`hm-growth`,children:[(0,E.jsxs)(`svg`,{className:`hm-growth-plot`,viewBox:`0 0 ${W} ${G}`,preserveAspectRatio:`none`,role:`img`,"aria-label":`${S(n.last,`tracked file`)} and ${x(r.last)} tracked lines, from ${w(i?.date??null)} to ${w(a?.date??null)}`,children:[(0,E.jsx)(`polyline`,{className:`hm-growth-lines`,points:r.line,vectorEffect:`non-scaling-stroke`}),(0,E.jsx)(`polyline`,{className:`hm-growth-files`,points:n.line,vectorEffect:`non-scaling-stroke`}),t.map((n,r)=>(0,E.jsx)(`rect`,{className:`hm-growth-band`,x:K(Math.max(0,r*o-o/2)),y:0,width:K(r===0||r===t.length-1?o/2:o),height:G,...e.hover(`${w(n.date)} · ${S(P(n.files,e.counting),`file`)} · ${x(P(n.lines,e.counting))} lines`)},n.date))]}),(0,E.jsxs)(`div`,{className:`hm-growth-axis`,children:[(0,E.jsx)(`span`,{children:w(i?.date??null)}),(0,E.jsx)(`span`,{children:w(a?.date??null)})]}),(0,E.jsxs)(`div`,{className:`hm-sub hm-growth-keys`,children:[(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`i`,{className:`hm-key hm-lines-key`}),x(r.last),` lines`]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`i`,{className:`hm-key hm-files-key`}),S(n.last,`file`)]}),e.growth.counted<e.growth.of&&(0,E.jsxs)(`span`,{className:`hm-muted`,children:[`counted at `,e.growth.counted,` of `,e.growth.of,` points so far`]})]})]})}function qe(e){let{repository:t,onTop:n,readAt:r,now:i}=e,a=(0,E.jsx)(Je,{readAt:r,now:i,onRefresh:e.onRefresh,toolPaths:e.toolPaths,counting:e.counting,onCounting:e.onCounting});return t===null?(0,E.jsxs)(`div`,{className:`hm-head`,children:[(0,E.jsx)(`span`,{className:`hm-bar hm-bar-name`}),(0,E.jsx)(`span`,{className:`hm-bar`}),(0,E.jsx)(`span`,{className:`hm-bar`}),a]}):(0,E.jsxs)(`div`,{className:`hm-head`,children:[(0,E.jsx)(`span`,{className:`hm-repo`,children:t.name}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:t.changedFiles>0?`hm-dot hm-dirty`:`hm-dot`}),t.detached?`${t.branch}, detached`:t.branch,` ·`,` `,te(t.changedFiles)]}),t.commits>0&&(0,E.jsxs)(E.Fragment,{children:[n===null?(0,E.jsx)(`span`,{children:S(t.commits,`commit`)}):(0,E.jsxs)(`span`,{children:[S(n.count,`commit`),` on top of `,n.base,` · `,x(t.commits),` `,`in total`]}),t.firstCommit!==null&&(0,E.jsxs)(`span`,{children:[`since `,w(t.firstCommit),t.shallow&&(0,E.jsx)(`span`,{className:`hm-muted`,children:` (shallow)`})]}),t.lastCommit!==null&&(0,E.jsxs)(`span`,{children:[`last commit `,u(t.lastCommit,i)]})]}),a]})}function Je(e){return(0,E.jsxs)(`span`,{className:`hm-read`,children:[(0,E.jsx)(Ae,{toolPaths:e.toolPaths,counting:e.counting,onChange:e.onCounting}),(0,E.jsx)(Ye,{readAt:e.readAt,now:e.now,onRefresh:e.onRefresh})]})}function Ye(e){let n=o({className:`hm-infotip hm-read-tip`,side:`bottom`}),r=e.readAt===null?null:u(e.readAt.toISOString(),e.now);return(0,E.jsxs)(`button`,{type:`button`,className:`hm-control hm-refresh`,"aria-label":r===null?`Refresh`:`Refresh, read ${r}`,onClick:e.onRefresh,...n.anchor,children:[(0,E.jsx)(t,{size:14}),n.says((0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`b`,{children:`Read the repository again`}),r!==null&&(0,E.jsxs)(`p`,{children:[`Read `,r,`.`]})]}))]})}var Xe=s();function Ze(){let e=(0,m.useRef)(null),t=(0,m.useRef)(``);return{hover:(0,m.useCallback)(n=>({onMouseMove(r){t.current=n;let i=e.current;if(i===null)return;i.textContent=n;let a=l({left:r.clientX,top:r.clientY,width:0,height:0},{width:i.offsetWidth,height:i.offsetHeight},{width:window.innerWidth,height:window.innerHeight},`top`);i.style.left=`${a.left}px`,i.style.top=`${a.top}px`,i.classList.add(`hm-tip-on`)},onMouseLeave(){t.current===n&&(t.current=``,e.current?.classList.remove(`hm-tip-on`))}}),[]),node:(0,Xe.createPortal)((0,E.jsx)(`div`,{className:`tip hm-tip`,"aria-hidden":`true`,ref:e}),document.body)}}var q=`none`,J=`-`;function Qe(e){let{facts:t,now:n}=e,r=t.longestStreak;return(0,E.jsx)(`div`,{className:`hm-list`,children:[[`First commit`,t.firstCommit===null?q:e.shallow?`${w(t.firstCommit)} (shallow)`:w(t.firstCommit),t.firstCommit===null?J:u(t.firstCommit,n)],[`Commits`,x(e.commits),`${t.commitsPerDay} a day`],[`Longest streak`,r===null?q:S(r.days,`day`),r===null?J:ee(r.from,r.to)],[`Biggest day`,t.biggestDay===null?q:w(t.biggestDay.date),t.biggestDay===null?J:S(t.biggestDay.commits,`commit`)],[`Last tag`,t.lastTag===null?q:t.lastTag.name,t.lastTag===null?J:u(t.lastTag.date,n)],[`Stashes`,x(t.stashes),J]].map(([e,t,n])=>(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`span`,{children:e}),(0,E.jsx)(`span`,{className:`hm-muted`,children:t}),(0,E.jsx)(`span`,{className:`hm-muted`,children:n})]},e))})}var $e=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],et=[`0`,`6`,`12`,`18`,`23`];function tt(e){let t=Math.max(...e.counts);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`div`,{className:e.wide===!0?`hm-bars hm-bars-wide`:`hm-bars`,children:e.counts.map((n,r)=>(0,E.jsx)(`i`,{className:n===t&&t>0?`hm-tall`:void 0,style:{height:t>0?`${n/t*100}%`:`0%`},...e.hover(e.said(r,n))},r))}),(0,E.jsx)(`div`,{className:`hm-axis-x`,children:e.marks.map(e=>(0,E.jsx)(`span`,{children:e},e))})]})}function nt(e){return(0,E.jsx)(tt,{counts:e.counts,marks:et,hover:e.hover,said:(e,t)=>`${String(e).padStart(2,`0`)}:00 - ${S(t,`commit`)}`})}function rt(e){return(0,E.jsx)(tt,{counts:e.counts,marks:$e,wide:!0,hover:e.hover,said:(e,t)=>`${$e[e]} - ${S(t,`commit`)}`})}var Y=c(`home`);Y.receive;var it=Y.credentialsReady,at=Y.onSession;Y.openOutside;var ot=Y.sayWaiting,st=Y.listen;function ct(e){return(0,E.jsxs)(`div`,{className:`hm-hbar`,children:[(0,E.jsx)(`span`,{className:`hm-key-name`,title:e.name,children:e.name}),(0,E.jsx)(`div`,{className:`hm-track`,children:(0,E.jsx)(`i`,{style:{width:`${e.width}%`,background:e.colour}})}),(0,E.jsx)(`span`,{className:`hm-value`,children:e.value}),e.note!==void 0&&(0,E.jsx)(`span`,{className:e.note.className,title:e.note.title,children:e.note.said})]})}var lt=[`#3987e5`,`#8b949e`,`#c98500`,`#199e70`,`#d95926`,`#d55181`,`#4f74d6`];function ut(e,t){if(e===null)return{size:`ignored files not counted yet`,when:``};let n=a(e.bytes),r=e.atLeast?`the count hit its ${je/1e3} s limit · `:``;return{size:`${e.atLeast?`at least ${n}`:n} ignored`,when:`${r}counted ${u(e.countedAt,t)}`}}function dt(e,t,n){if(n===`all`||t.length===0)return``;let r=e.files.all-e.files.work,i=e.lines.all-e.lines.work;return r===0?``:`${t.join(` and `)} left out · ${S(r,`file`)} and ${x(i)} lines`}function ft(e){let t=ut(e.ignored,e.now),n=dt(e.tracked,e.toolPaths,e.counting);return(0,E.jsxs)(`div`,{children:[e.kinds.map((e,t)=>(0,E.jsx)(ct,{name:e.kind,width:e.share,colour:lt[t%lt.length]??``,value:`${e.share}%`},e.kind)),(0,E.jsxs)(`div`,{className:`hm-sub`,children:[S(P(e.tracked.files,e.counting),`tracked file`),` ·`,` `,x(P(e.tracked.lines,e.counting)),` lines ·`,` `,a(P(e.tracked.bytes,e.counting)),` tracked · `,(0,E.jsx)(`b`,{children:t.size}),t.when!==``&&` · ${t.when}`]}),n!==``&&(0,E.jsx)(`div`,{className:`hm-sub hm-left-out`,children:n})]})}var X=d({prefix:`home`,label:`Home`,credentialsReady:it});function pt(){return X.ask(`history`)}function mt(){return X.ask(`branches`)}function ht(){return X.ask(`tree`)}var Z={status:`waiting`},gt=1500,_t=90,vt=5;function yt(e){let t=e instanceof Error?e.message:String(e);return t===``?`the Home tool could not read the repository`:t}function bt(){let[e,t]=(0,m.useState)(Z),[n,r]=(0,m.useState)(Z),[i,a]=(0,m.useState)(Z),[o,s]=(0,m.useState)(null),c=(0,m.useRef)(0),l=(0,m.useRef)(!0);(0,m.useEffect)(()=>(l.current=!0,()=>{l.current=!1}),[]);let u=(0,m.useRef)({reads:0,counted:-1,stalls:0}),d=(0,m.useCallback)(()=>{c.current+=1;let e=c.current,n=()=>l.current&&c.current===e;u.current={reads:0,counted:-1,stalls:0},s(new Date);let i=(e,t)=>{t(Z),e().then(e=>{n()&&t({status:`read`,answer:e})},e=>{n()&&t({status:`failed`,said:yt(e)})})};i(pt,t),i(mt,r),i(ht,a)},[]),f=(0,m.useCallback)(()=>{let e=c.current;ht().then(t=>{l.current&&c.current===e&&a({status:`read`,answer:t})},()=>{})},[]);return(0,m.useEffect)(()=>{if(i.status!==`read`)return;let e=i.answer;if(e.repository===null||!e.growth.filling)return;let t=u.current;if(e.growth.counted>t.counted?(t.counted=e.growth.counted,t.stalls=0):t.stalls+=1,t.reads+=1,t.stalls>vt||t.reads>_t)return;let n=setTimeout(f,gt);return()=>clearTimeout(n)},[i,f]),{history:e,branches:n,tree:i,readAt:o,read:d}}function xt(e){let t=(0,m.useRef)(e);t.current=e,(0,m.useEffect)(()=>{let e=!1,n=new ResizeObserver(n=>{let r=(n[n.length-1]?.contentRect.width??0)>0;r&&!e&&t.current(),e=r});return n.observe(document.documentElement),()=>n.disconnect()},[])}function St(e){return e===1?`active day`:`active days`}var Ct=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function wt(e){return{year:e.getFullYear(),month:e.getMonth(),date:e.getDate()}}function Tt(e,t,n){let r=new Date(e,t,n),i=String(r.getMonth()+1).padStart(2,`0`),a=String(r.getDate()).padStart(2,`0`);return`${r.getFullYear()}-${i}-${a}`}function Q(e,t,n,r){let i=[];for(let a=0;a<r;a++)i.push(Tt(e,t,n+a));return i}function Et(e){return(e.getDay()+6)%7+1}function Dt(e,t){return new Date(e,t+1,0).getDate()}function $(e,t){return t.filter(t=>(e.get(t)?.commits??0)>0).length}function Ot(e,t,n){let r=0,i=0;for(let a of t){let t=e.get(a);t!==void 0&&(r+=P(t.added,n),i+=P(t.deleted,n))}return{added:r,deleted:i}}function kt(e,t,n){if(t===0)return e===0?{said:`none on ${n} either`,up:!1}:{said:`none on ${n}`,up:!0};let r=Math.round((e-t)/t*100);return{said:`${r>=0?`+`:``}${r}% on ${n}`,up:r>0}}function At(e,t,n=`work`){let r=new Map(e.map(e=>[e.date,e])),i=wt(t),a=Q(i.year,i.month,1,i.date),o=i.month===0?{year:i.year-1,month:11}:{year:i.year,month:i.month-1},s=Q(o.year,o.month,1,Math.min(i.date,Dt(o.year,o.month))),c=Et(t),l=Q(i.year,i.month,i.date-c+1,c),u=Q(i.year,i.month,i.date-c-6,c),d=Ot(r,l,n);return{month:{planted:$(r,a),name:Ct[i.month]??``,against:kt($(r,a),$(r,s),`the same days of ${Ct[o.month]??``}`)},week:{planted:$(r,l),against:kt($(r,l),$(r,u),`the same days last week`)},lines:{added:d.added,deleted:d.deleted,perDay:Math.round((d.added+d.deleted)/c)}}}function jt(e){let t=At(e.days,e.now,e.counting);return(0,E.jsxs)(`div`,{className:`hm-tiles`,children:[(0,E.jsxs)(`div`,{className:`hm-card hm-tile`,children:[(0,E.jsxs)(`div`,{className:`hm-big`,children:[x(t.month.planted),` `,(0,E.jsxs)(`span`,{className:`hm-span`,children:[St(t.month.planted),` in `,t.month.name]})]}),(0,E.jsx)(`div`,{className:`hm-sub`,children:(0,E.jsx)(Mt,{...t.month.against})})]}),(0,E.jsxs)(`div`,{className:`hm-card hm-tile`,children:[(0,E.jsxs)(`div`,{className:`hm-big`,children:[x(t.week.planted),` `,(0,E.jsxs)(`span`,{className:`hm-span`,children:[St(t.week.planted),` since Monday`]})]}),(0,E.jsx)(`div`,{className:`hm-sub`,children:(0,E.jsx)(Mt,{...t.week.against})})]}),(0,E.jsxs)(`div`,{className:`hm-card hm-tile`,children:[(0,E.jsxs)(`div`,{className:`hm-big hm-lines`,children:[(0,E.jsxs)(`span`,{className:`hm-added`,children:[`+`,x(t.lines.added)]}),(0,E.jsx)(`span`,{className:`hm-slash`,children:` / `}),(0,E.jsxs)(`span`,{className:`hm-deleted`,children:[`-`,x(t.lines.deleted)]})]}),(0,E.jsxs)(`div`,{className:`hm-sub`,children:[`lines since Monday · `,x(t.lines.perDay),` a day on average`]})]})]})}function Mt(e){return(0,E.jsx)(`span`,{className:e.up?`hm-up`:void 0,children:e.said})}function Nt(e){if(e===null||e.default===null)return null;let t=e.branches.find(e=>e.current);return t===void 0||t.name===e.default?null:{count:t.ahead,base:e.default}}function Pt(){let e=bt(),t=p(!0),n=Ze(),[r,i]=(0,m.useState)(!0);(0,m.useEffect)(()=>at(e=>i(e.sound)),[]);let[a,o]=(0,m.useState)(`work`),s=Te();xt(e.read),(0,m.useEffect)(()=>{ot(0,!0)},[]);let c=e.history,l=c.status===`read`?c.answer:null,u=l===null?null:l.repository;if(l!==null&&l.repository===null)return(0,E.jsx)(`div`,{className:`hm-page`,children:(0,E.jsx)(`div`,{className:`hm-column`,children:(0,E.jsx)(`p`,{className:`hm-plain`,children:`This workspace holds no git repository, so there is no pulse to show.`})})});let d=u===null?`loading`:`read`,f=e.branches,h=e.tree,g=e=>e.status===`read`?`read`:e.status===`failed`?`failed`:`loading`,_=e=>e.status===`failed`?e.said:void 0,v=f.status===`read`&&f.answer.repository!==null?f.answer:null,y=h.status===`read`&&h.answer.repository!==null?h.answer:null,b=l!==null&&l.repository!==null?l:null,x=u!==null&&u.commits===0,S=[u,y?.repository,v?.repository].find(e=>(e?.toolPaths.length??0)>0)?.toolPaths??[],C=(0,E.jsx)(D,{title:`Branches`,note:v===null?void 0:ie(v.branches),state:g(f),said:_(f),loaderHeight:130,className:`hm-branches-card`,children:v!==null&&(0,E.jsx)(oe,{branches:v.branches,default:v.default,now:t})}),w=(0,E.jsx)(D,{title:`The tree`,note:`what the workspace is made of`,state:g(h),said:_(h),loaderHeight:130,children:y!==null&&(0,E.jsx)(ft,{kinds:a===`all`?y.kinds:y.kindsWork,tracked:y.tracked,ignored:y.ignored,toolPaths:y.repository.toolPaths,counting:a,now:t})}),T=(0,E.jsx)(D,{title:`Growth`,note:`tracked files and lines, since the first commit`,state:g(h),said:_(h),loaderHeight:130,className:`hm-growth-card`,children:y!==null&&(0,E.jsx)(Ke,{growth:y.growth,counting:a,hover:n.hover})});return c.status===`failed`?(0,E.jsxs)(`div`,{className:s?`hm-page hm-still`:`hm-page`,children:[(0,E.jsxs)(`div`,{className:`hm-column`,children:[(0,E.jsxs)(`div`,{className:`hm-failed`,children:[(0,E.jsx)(`span`,{children:c.said}),` `,(0,E.jsx)(`span`,{className:`hm-muted`,children:`Read the repository again to try.`}),(0,E.jsxs)(`span`,{className:`hm-read`,children:[(0,E.jsx)(Ae,{toolPaths:S,counting:a,onChange:o}),(0,E.jsx)(Ye,{readAt:e.readAt,now:t,onRefresh:e.read})]})]}),(0,E.jsxs)(`div`,{className:`hm-grid`,children:[C,T]}),(0,E.jsx)(`div`,{className:`hm-grid`,children:w})]}),n.node,(0,E.jsx)(N,{sound:r})]}):(0,E.jsxs)(`div`,{className:s?`hm-page hm-still`:`hm-page`,children:[(0,E.jsxs)(`div`,{className:`hm-column`,children:[(0,E.jsx)(qe,{repository:u,onTop:Nt(v),readAt:e.readAt,now:t,onRefresh:e.read,toolPaths:S,counting:a,onCounting:o}),x?(0,E.jsx)(`p`,{className:`hm-plain`,children:`This repository has no commit yet. The page fills in as the work starts.`}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(D,{state:d,loaderHeight:192,className:`hm-garden-card`,children:[b!==null&&(0,E.jsx)(Ue,{days:b.days,today:b.readAt.slice(0,10),counting:a,hover:n.hover}),b?.repository.cut===!0&&(0,E.jsx)(`p`,{className:`hm-cut`,children:`The full history was too large to walk, so this garden is the last two years alone.`})]}),b===null?(0,E.jsxs)(`div`,{className:`hm-tiles`,children:[(0,E.jsx)(`div`,{className:`hm-card hm-tile`,children:(0,E.jsx)(`div`,{className:`hm-loader`,style:{height:`46px`}})}),(0,E.jsx)(`div`,{className:`hm-card hm-tile`,children:(0,E.jsx)(`div`,{className:`hm-loader`,style:{height:`46px`}})}),(0,E.jsx)(`div`,{className:`hm-card hm-tile`,children:(0,E.jsx)(`div`,{className:`hm-loader`,style:{height:`46px`}})})]}):(0,E.jsx)(jt,{days:b.days,now:t,counting:a}),(0,E.jsxs)(`div`,{className:`hm-grid`,children:[(0,E.jsx)(D,{title:`Rhythm`,note:`commits by hour, author time`,state:d,loaderHeight:84,children:b!==null&&(0,E.jsx)(nt,{counts:b.hours,hover:n.hover})}),(0,E.jsx)(D,{title:`Rhythm`,note:`commits by weekday`,state:d,loaderHeight:84,children:b!==null&&(0,E.jsx)(rt,{counts:b.weekdays,hover:n.hover})})]}),(0,E.jsxs)(`div`,{className:`hm-grid`,children:[C,T]}),(0,E.jsxs)(`div`,{className:`hm-grid`,children:[w,(0,E.jsx)(D,{title:`Milestones`,state:d,loaderHeight:130,children:b!==null&&(0,E.jsx)(Qe,{facts:b.milestones,commits:b.repository.commits,now:t,shallow:b.repository.shallow})})]})]})]}),n.node,(0,E.jsx)(N,{sound:r})]})}st();var Ft=document.getElementById(`root`);Ft&&(0,h.createRoot)(Ft).render((0,E.jsx)(m.StrictMode,{children:(0,E.jsx)(Pt,{})}));