dev-process-kit 0.2.1 → 0.3.0-beta.1

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 (51) hide show
  1. package/README.md +178 -60
  2. package/dist/boards.js +1 -0
  3. package/dist/chunks/shared-BX1EnRfr.js +1 -0
  4. package/dist/chunks/shared-C-M2Nfmu.js +686 -0
  5. package/dist/chunks/shared-Cas88qVh.js +2165 -0
  6. package/dist/chunks/{shared-DeXM1v86.js → shared-Cejw83eH.js} +21 -29
  7. package/dist/chunks/shared-CfVpKPRY.js +1844 -0
  8. package/dist/chunks/shared-CnPCm4bJ.js +31 -0
  9. package/dist/chunks/shared-D1iBuYZV.js +6208 -0
  10. package/dist/chunks/shared-D7VtCoY6.js +3586 -0
  11. package/dist/chunks/{shared-zZF1zU0o.js → shared-DHVDag3x.js} +25 -56
  12. package/dist/chunks/shared-DdpMqkAH.js +4928 -0
  13. package/dist/chunks/shared-EYOAbLSo.js +1 -0
  14. package/dist/chunks/shared-TrlnHjrJ.js +1 -0
  15. package/dist/chunks/shared-a9QCZpxj.js +574 -0
  16. package/dist/chunks/shared-df9XN7ns.js +904 -0
  17. package/dist/chunks/shared-dnY35u9q.js +2530 -0
  18. package/dist/chunks/shared-e9ia12Uz.js +1636 -0
  19. package/dist/chunks/shared-qk9TB_UM.js +705 -0
  20. package/dist/components.js +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/views/delegation-poker.js +1 -0
  23. package/dist/views/plain.js +1 -0
  24. package/dist/views/prototype.js +1 -0
  25. package/dist/views/slides.js +1 -0
  26. package/dist/views/task-board.js +1 -0
  27. package/dist/views/usm.js +1 -0
  28. package/package.json +8 -10
  29. package/dist/chunks/shared-B5lBiq5s.js +0 -1
  30. package/dist/chunks/shared-BjyoXjSO.js +0 -1
  31. package/dist/chunks/shared-C-d71uRP.js +0 -573
  32. package/dist/chunks/shared-C5n6LBUz.js +0 -1105
  33. package/dist/chunks/shared-CAWKGcWJ.js +0 -1053
  34. package/dist/chunks/shared-CdZhkPto.js +0 -1
  35. package/dist/chunks/shared-DB_C1Mdu.js +0 -1
  36. package/dist/chunks/shared-DDOpqbVL.js +0 -49
  37. package/dist/chunks/shared-DehzCTC2.js +0 -1616
  38. package/dist/chunks/shared-Dfj6O0K4.js +0 -2774
  39. package/dist/chunks/shared-DiFAX1_p.js +0 -3780
  40. package/dist/chunks/shared-DkPo0jX3.js +0 -4214
  41. package/dist/chunks/shared-GL2Z98Cz.js +0 -4206
  42. package/dist/chunks/shared-cMhjZGRs.js +0 -301
  43. package/dist/templates/delegation-poker.js +0 -1
  44. package/dist/templates/event-storming.js +0 -1
  45. package/dist/templates/example-mapping.js +0 -1
  46. package/dist/templates/plain.js +0 -1
  47. package/dist/templates/prototype.js +0 -1
  48. package/dist/templates/slides.js +0 -1
  49. package/dist/templates/task-board.js +0 -1
  50. package/dist/templates/usm.js +0 -1
  51. package/dist/templates/whiteboard.js +0 -1
@@ -0,0 +1,904 @@
1
+ import{a5 as G,ah as E,ak as D,X as I,j as X,ag as Et,al as Y,aE as Dt,ai as p,as as l,bp as It,aH as b,I as V,au as At,a8 as A,av as C,a9 as L,aw as w,b8 as J,ax as y,ay as k,ac as g,aD as B,aa as T,ad as Q,bJ as O,aB as Lt,az as Z,aF as Bt,bG as Ot,x as qt,w as Mt,A as tt,z as Ut,l as _t}from"./shared-DdpMqkAH.js";import{o as Nt}from"./shared-TrlnHjrJ.js";const zt={active:[],match:"single"},Pt=(s,t)=>t.active.length===0?!0:t.match==="all"?t.active.every(e=>s.includes(e)):t.active.some(e=>s.includes(e)),q=s=>{try{return s.split("/").map(t=>decodeURIComponent(t))}catch{return null}},et="BC:",jt=s=>`${et}${s}`,$={kind:"idle"},M="text/plain",Ht=s=>`${s.type}:${s.id}`,rt=(s,t)=>{const e=(s??"").trim();if(e.length===0)return null;const r=e.indexOf(":");if(r<0)return{type:t,id:e};const a=e.slice(0,r),i=e.slice(r+1);return a.length===0||i.length===0?null:{type:a,id:i}},st=(s,t)=>t<=s.top+s.height/2?"before":"after";class Ft{#e;#r=$;#n;constructor(t){this.#e=t,t.addController(this)}hostDisconnected(){this.reset()}get state(){return this.#r}get item(){return this.#r.kind==="dragging"?this.#r.item:null}isDragging(t,e){const r=this.item;return r!==null&&r.type===t&&r.id===e}isOver(t){return this.#r.kind!=="idle"&&this.#r.over===t}reset(){clearTimeout(this.#n),this.#n=void 0,this.#t($)}source(t){return{dragstart:e=>{e.dataTransfer&&(e.dataTransfer.setData(M,Ht(t)),e.dataTransfer.effectAllowed="move"),clearTimeout(this.#n),this.#n=setTimeout(()=>{this.#n=void 0,this.#t({kind:"dragging",item:t,over:null})},0)},dragend:()=>this.reset()}}target(t){return{dragenter:r=>{this.#i(t.accepts)&&(r.preventDefault(),this.#a(t.key))},dragover:r=>{this.#i(t.accepts)&&(r.preventDefault(),r.dataTransfer&&(r.dataTransfer.dropEffect="move"),this.#a(t.key))},dragleave:()=>{this.isOver(t.key)&&this.#a(null)},drop:r=>{r.preventDefault();const a=rt(r.dataTransfer?.getData(M),t.accepts)??this.item;if(this.#t($),!a||a.type!==t.accepts)return;const i=t.hovered?.(r)??null;t.onDrop({item:{type:t.accepts,id:a.id},hoveredId:i?.id??null,place:i?st(i.element.getBoundingClientRect(),r.clientY):"end",event:r})}}}combine(t,e){const r=()=>{const a=this.item!==null;return e.flatMap(([i,o])=>a||i===t?[o]:[])};return{dragenter:a=>r().forEach(i=>i.dragenter(a)),dragover:a=>r().forEach(i=>i.dragover(a)),dragleave:()=>e.forEach(([,a])=>a.dragleave()),drop:a=>{const i=rt(a.dataTransfer?.getData(M),t)?.type??this.item?.type,o=e.find(([n])=>n===i)?.[1];if(o){o.drop(a);return}a.preventDefault(),this.#t($)}}}#i(t){const e=this.item;return e===null||e.type===t}#a(t){const e=this.#r;if(e.kind==="dragging"){e.over!==t&&this.#t({...e,over:t});return}if(t===null){e.kind==="receiving"&&this.#t($);return}(e.kind==="idle"||e.over!==t)&&this.#t({kind:"receiving",over:t})}#t(t){this.#r!==t&&(this.#r=t,this.#e.requestUpdate())}}const R=(s,t,e,r)=>{const i=s.filter(c=>c!==t).at(-1)??null;if(e===null||r==="end")return i;const o=s.indexOf(t),n=s.indexOf(e);if(n<0)return i;const d=c=>c<=0?null:s.at(c-1)??null;return o>=0?o<n?e:d(n):r==="after"?e:d(n)},at=(s,t)=>new Intl.DateTimeFormat(s,{dateStyle:"medium",timeStyle:"short"}).format(new Date(t)),Kt=G({en:{heading:"Comments",commentsOn:s=>`Comments on \u201C${s}\u201D`,commentCountAria:s=>`${s} comment${s===1?"":"s"}`,empty:"No comments yet.",add:"Add comment",cancel:"Cancel",deleteComment:"Delete comment",sendFailed:"Could not save the comment.",commentDate:s=>at("en-US",s)},ja:{heading:"\u30B3\u30E1\u30F3\u30C8",commentsOn:s=>`\u300C${s}\u300D\u306E\u30B3\u30E1\u30F3\u30C8`,commentCountAria:s=>`\u30B3\u30E1\u30F3\u30C8 ${s} \u4EF6`,empty:"\u30B3\u30E1\u30F3\u30C8\u306F\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002",add:"\u30B3\u30E1\u30F3\u30C8\u3092\u8FFD\u52A0",cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",deleteComment:"\u30B3\u30E1\u30F3\u30C8\u3092\u524A\u9664",sendFailed:"\u30B3\u30E1\u30F3\u30C8\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002",commentDate:s=>at("ja-JP",s)}}),Wt=E`
2
+ :host {
3
+ display: inline-block;
4
+ }
5
+
6
+ .thread-trigger {
7
+ display: inline-flex;
8
+ align-items: center;
9
+ gap: 4px;
10
+ min-width: 0;
11
+ padding: 1px 7px;
12
+ border: none;
13
+ border-radius: 6px;
14
+ background: color-mix(in oklab, var(--dpk-ink-faint) 10%, var(--dpk-paper-sunken));
15
+ color: var(--dpk-ink-soft);
16
+ font: inherit;
17
+ font-size: 10.5px;
18
+ font-weight: 600;
19
+ font-family: var(--dpk-mono);
20
+ font-variant-numeric: tabular-nums;
21
+ line-height: 18px;
22
+ white-space: nowrap;
23
+ cursor: pointer;
24
+ }
25
+
26
+ .thread-trigger:hover,
27
+ .thread-trigger[aria-expanded='true'] {
28
+ background: var(--dpk-blue-soft);
29
+ color: var(--dpk-blue);
30
+ }
31
+
32
+ .thread-trigger:focus-visible {
33
+ outline: none;
34
+ box-shadow: var(--dpk-focus);
35
+ }
36
+
37
+ .thread-trigger svg {
38
+ flex: none;
39
+ width: 12px;
40
+ height: 12px;
41
+ }
42
+
43
+ .thread-pop {
44
+ width: 320px;
45
+ max-height: 360px;
46
+ }
47
+
48
+ .thread-heading {
49
+ font-size: 12.5px;
50
+ overflow-wrap: anywhere;
51
+ }
52
+
53
+ .thread-list {
54
+ list-style: none;
55
+ margin: 0;
56
+ padding: 0;
57
+ display: grid;
58
+ gap: 6px;
59
+ max-height: 180px;
60
+ overflow: auto;
61
+ }
62
+
63
+ .thread-list li {
64
+ display: flex;
65
+ align-items: flex-start;
66
+ gap: 6px;
67
+ padding: 6px 8px;
68
+ border-radius: var(--dpk-radius-xs);
69
+ background: var(--dpk-accent-soft);
70
+ }
71
+
72
+ .thread-item-main {
73
+ flex: 1;
74
+ min-width: 0;
75
+ display: grid;
76
+ gap: 2px;
77
+ }
78
+
79
+ .thread-item-body {
80
+ margin: 0;
81
+ overflow-wrap: anywhere;
82
+ white-space: pre-wrap;
83
+ font-size: 12px;
84
+ color: var(--dpk-ink);
85
+ }
86
+
87
+ .thread-item-time {
88
+ font-size: 10.5px;
89
+ color: var(--dpk-ink-faint);
90
+ }
91
+
92
+ .thread-empty {
93
+ margin: 0;
94
+ color: var(--dpk-ink-soft);
95
+ font-size: 12px;
96
+ }
97
+
98
+ .thread-form {
99
+ display: grid;
100
+ gap: 8px;
101
+ }
102
+
103
+ .thread-error {
104
+ margin: 0;
105
+ font-size: 11px;
106
+ color: var(--dpk-danger);
107
+ }
108
+
109
+ .thread-actions {
110
+ display: flex;
111
+ gap: 6px;
112
+ justify-content: flex-end;
113
+ }
114
+ `;class it extends D{static{this.styles=[I,X,Et,Wt]}static{this.properties={comments:{attribute:!1},label:{type:String},inline:{type:Boolean,reflect:!0},draftKey:{type:String,attribute:"draft-key"},open:{state:!0}}}#e=!1;#r=!1;#n=new Y(this);#i=new Dt(this);constructor(){super(),this.comments=[],this.label=null,this.inline=!1,this.draftKey=null,this.open=!1}willUpdate(t){t.has("comments")&&(this.#e=!1)}updated(){if(this.inline)return;const t=this.renderRoot.querySelector(".thread-pop"),e=this.renderRoot.querySelector(".thread-trigger"),r=!this.#r&&this.open;this.#r=this.open,!(!t||!e)&&(this.#i.open(t,e,{width:320,height:360},{placement:"bottom-end"}),r&&t.querySelector("textarea")?.focus({preventScroll:!0}))}render(){return this.inline?this.#s():l`${this.#g()}${this.open?this.#m():p}`}get#a(){return Kt(this.#n.locale)}#t(){return this.label?this.#a.commentsOn(this.label):this.#a.heading}#g(){const t=this.#a,e=this.comments.length,r=this.#t(),a=e>0?`${r} (${t.commentCountAria(e)})`:r;return l`<button
115
+ class="thread-trigger"
116
+ type="button"
117
+ aria-haspopup="dialog"
118
+ aria-expanded=${this.open?"true":"false"}
119
+ aria-label=${a}
120
+ title=${a}
121
+ @click=${()=>{this.open=!this.open}}
122
+ >
123
+ ${It()}${e>0?l`<span>${e}</span>`:p}
124
+ </button>`}#m(){return l`<div
125
+ class="comment-pop thread-pop"
126
+ popover="manual"
127
+ role="dialog"
128
+ aria-label=${this.#t()}
129
+ @keydown=${t=>{t.isComposing||t.key!=="Escape"||(t.preventDefault(),t.stopPropagation(),this.open=!1)}}
130
+ >
131
+ ${this.#s()}
132
+ </div>`}#s(){const t=this.#a;return l`
133
+ ${this.inline?p:l`<strong class="thread-heading">${this.#t()}</strong>`}
134
+ ${this.comments.length===0?l`<p class="thread-empty">${t.empty}</p>`:l`<ol class="thread-list">
135
+ ${b(this.comments,e=>e.id,e=>l`<li>
136
+ <div class="thread-item-main">
137
+ <p class="thread-item-body">${e.body}</p>
138
+ ${e.createdAt===void 0?p:l`<time class="thread-item-time" datetime=${e.createdAt}
139
+ >${t.commentDate(e.createdAt)}</time
140
+ >`}
141
+ </div>
142
+ <button
143
+ class="dpk-icon-btn"
144
+ type="button"
145
+ data-role="delete-comment"
146
+ aria-label=${t.deleteComment}
147
+ title=${t.deleteComment}
148
+ @click=${()=>{this.#l(e.id)}}
149
+ >
150
+ ${V()}
151
+ </button>
152
+ </li>`)}
153
+ </ol>`}
154
+ <form
155
+ class="thread-form"
156
+ @submit=${e=>{e.preventDefault(),e.currentTarget instanceof HTMLFormElement&&this.#o(e.currentTarget)}}
157
+ >
158
+ <textarea
159
+ class="dpk-textarea"
160
+ rows="2"
161
+ aria-label=${t.heading}
162
+ data-dpk-text-key=${this.draftKey??p}
163
+ @keydown=${e=>{if(e.isComposing||e.key!=="Enter"||!(e.ctrlKey||e.metaKey))return;e.preventDefault();const r=e.currentTarget instanceof HTMLElement?e.currentTarget.closest("form"):null;r&&this.#o(r)}}
164
+ ></textarea>
165
+ ${this.#e?l`<p class="thread-error" role="alert">${t.sendFailed}</p>`:p}
166
+ <div class="thread-actions">
167
+ ${this.inline?p:l`<button
168
+ class="dpk-btn dpk-btn--ghost"
169
+ type="button"
170
+ data-dpk-text-discard
171
+ @click=${()=>{this.open=!1}}
172
+ >
173
+ ${t.cancel}
174
+ </button>`}
175
+ <button class="dpk-btn dpk-btn--accent" type="submit">${t.add}</button>
176
+ </div>
177
+ </form>
178
+ `}#o(t){const e=t.querySelector("textarea"),r=e?.value.trim()??"";if(!e||r==="")return;const a=!this.dispatchEvent(new CustomEvent("dpk-thread-comment-add",{detail:{body:r},bubbles:!0,composed:!0,cancelable:!0}));this.#e=!a,a&&(e.value=""),this.requestUpdate()}#l(t){this.dispatchEvent(new CustomEvent("dpk-thread-comment-delete",{detail:{id:t},bubbles:!0,composed:!0,cancelable:!0}))}}const Gt=()=>{customElements.get("dpk-comment-thread")||customElements.define("dpk-comment-thread",it)},Xt=G({en:{heading:"Table",empty:"No rows.",notRecorded:"Could not record it. Place this inside a dpk-view-* element.",filterPlaceholder:"Filter\u2026",filterAriaLabel:"Filter rows",groupByLabel:"Group by",groupByNone:"None",sortAscending:"Sorted ascending",sortDescending:"Sorted descending",sortButtonAriaLabel:s=>`Sort by ${s}`,addRowButton:"+ Row",deleteRowAriaLabel:s=>`Delete ${s}`,commentAriaLabel:s=>`Comment on ${s}`,rowCount:(s,t)=>s===t?`${t} row`:`${s} / ${t} row`,addRowTitle:"Add row",addRowSummary:s=>`Added ${s}`,setCellTitle:"Edit cell",setCellSummary:(s,t)=>`${s}: ${t}`,deleteRowTitle:"Delete row",deleteRowSummary:s=>`Removed ${s}`,reorderRowTitle:"Reorder row",reorderRowSummary:s=>`Moved ${s}`},ja:{heading:"\u30C6\u30FC\u30D6\u30EB",empty:"\u884C\u304C\u3042\u308A\u307E\u305B\u3093\u3002",notRecorded:"\u8A18\u9332\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08dpk-view-* \u8981\u7D20\u306E\u4E2D\u306B\u7F6E\u3044\u3066\u304F\u3060\u3055\u3044\uFF09\u3002",filterPlaceholder:"\u7D5E\u308A\u8FBC\u307F\u2026",filterAriaLabel:"\u884C\u3092\u7D5E\u308A\u8FBC\u3080",groupByLabel:"\u30B0\u30EB\u30FC\u30D7\u5316",groupByNone:"\u306A\u3057",sortAscending:"\u6607\u9806\u3067\u4E26\u3079\u66FF\u3048",sortDescending:"\u964D\u9806\u3067\u4E26\u3079\u66FF\u3048",sortButtonAriaLabel:s=>`${s} \u3067\u4E26\u3079\u66FF\u3048`,addRowButton:"\uFF0B \u884C",deleteRowAriaLabel:s=>`${s} \u3092\u524A\u9664`,commentAriaLabel:s=>`${s} \u306B\u30B3\u30E1\u30F3\u30C8`,rowCount:(s,t)=>s===t?`${t} \u884C`:`${s} / ${t} \u884C`,addRowTitle:"\u884C\u3092\u8FFD\u52A0",addRowSummary:s=>`${s} \u3092\u8FFD\u52A0`,setCellTitle:"\u30BB\u30EB\u3092\u7DE8\u96C6",setCellSummary:(s,t)=>`${s}: ${t}`,deleteRowTitle:"\u884C\u3092\u524A\u9664",deleteRowSummary:s=>`${s} \u3092\u524A\u9664`,reorderRowTitle:"\u884C\u3092\u4E26\u3079\u66FF\u3048",reorderRowSummary:s=>`${s} \u3092\u79FB\u52D5`}}),Yt=["gray","blue","green","amber","violet","red"],Vt=["text","number","tag","status","person"],ot=()=>({columns:[],rows:[]}),Jt=C({id:y(g(),k(1)),label:y(g(),k(1)),type:Z(Vt),sortable:w(Lt())}),nt=C({label:g(),tone:Z(Yt)}),Qt=B([g(),Q(),O(),T(g()),nt]),Zt=C({id:y(g(),k(1)),cells:w(J(g(),Qt),{}),questions:w(g())}),te=C({columns:T(Jt),rows:w(T(Zt),[])}),U=(s,t)=>{switch(s.type){case"text":if(t==null)return{type:"text",value:null};if(typeof t=="string")return{type:"text",value:t};break;case"number":if(t==null)return{type:"number",value:null};if(typeof t=="number")return{type:"number",value:t};break;case"person":if(t==null)return{type:"person",value:null};if(typeof t=="string")return{type:"person",value:t};break;case"tag":if(t===void 0)return{type:"tag",value:[]};if(Array.isArray(t))return{type:"tag",value:t};break;case"status":if(t==null)return{type:"status",value:null};if(typeof t=="object"&&!Array.isArray(t)&&"tone"in t)return{type:"status",value:t};break}throw new Error(`cell for column "${s.id}" does not match its type "${s.type}"`)},dt=s=>{const t=At(te,s),e=new Set,r=t.columns.map(n=>{if(e.has(n.id))throw new Error(`duplicate column id: ${n.id}`);return e.add(n.id),{id:n.id,label:n.label,type:n.type,sortable:n.sortable??!0}}),a=new Map(r.map(n=>[n.id,n])),i=new Set,o=t.rows.map(n=>{if(i.has(n.id))throw new Error(`duplicate row id: ${n.id}`);i.add(n.id);for(const c of Object.keys(n.cells))if(!a.has(c))throw new Error(`row "${n.id}" has a cell for unknown column "${c}"`);const d={};for(const c of r)d[c.id]=U(c,n.cells[c.id]);return n.questions===void 0?{id:n.id,cells:d}:{id:n.id,cells:d,questions:n.questions}});return{columns:r,rows:o}},ee={sort:null,groupBy:null,filter:""},_=s=>{switch(s.type){case"text":case"person":return s.value??"";case"number":return s.value===null?"":String(s.value);case"tag":return s.value.join(" ");case"status":return s.value?.label??""}},lt=s=>s.type==="number"?s.value??-1/0:_(s).toLowerCase(),re=(s,t)=>{const e=t.trim().toLowerCase();return e===""?!0:Object.values(s.cells).some(r=>_(r).toLowerCase().includes(e))},se=(s,t)=>{const e=s.rows.filter(d=>re(d,t.filter)),r=t.sort,a=r===null?e:[...e].sort((d,c)=>{const h=lt(d.cells[r.column]??{type:"text",value:null}),u=lt(c.cells[r.column]??{type:"text",value:null}),f=h<u?-1:h>u?1:0;return r.direction==="asc"?f:-f});if(t.groupBy===null)return[{key:"",label:"",rows:a}];const i=t.groupBy,o=[],n=new Map;for(const d of a){const c=d.cells[i],h=c===void 0?"":_(c),u=h===""?"\0empty":h;n.has(u)||(o.push(u),n.set(u,[])),n.get(u)?.push(d)}return o.map(d=>({key:d,label:d==="\0empty"?"":d,rows:n.get(d)??[]}))},ct="ADD_ROW",N="SET_CELL",ut="DELETE_ROW",ht="REORDER_ROW",pt=s=>`element:${encodeURIComponent(s)}/table/rows`,x=(s,t)=>`element:${encodeURIComponent(s)}/row/${encodeURIComponent(t)}`,z=s=>{const t=q(s);return t?.length===3&&t[1]==="row"?t[2]??null:null},ae=s=>{const t=q(s);return t?.length===3&&t[1]==="table"&&t[2]==="rows"},gt=B([g(),Q(),O(),T(g()),nt]),ie=L({id:y(g(),k(1)),cells:w(J(g(),gt),{})}),oe=L({column:y(g(),k(1)),value:gt}),ne=L({before:B([g(),O()])}),de=(s,t,e)=>{let r=[...t.rows];const a=o=>r.findIndex(n=>n.id===o),i=e.map(o=>{if(o.type===ct){if(!ae(o.target.id))return{id:o.id,title:s.addRowTitle,stale:"target-missing"};const n=A(ie,o.payload);if(!n.success||a(n.output.id)>=0)return{id:o.id,title:s.addRowTitle,stale:"constraint-violated"};const d={};for(const c of t.columns)d[c.id]=U(c,n.output.cells[c.id]);return r=[...r,{id:n.output.id,cells:d}],{id:o.id,title:s.addRowTitle,summary:s.addRowSummary(n.output.id),tone:"create"}}if(o.type===N){const n=z(o.target.id),d=n===null?-1:a(n),c=A(oe,o.payload),h=d<0?void 0:r[d];if(h===void 0||!c.success)return{id:o.id,title:s.setCellTitle,stale:"target-missing"};const u=t.columns.find(m=>m.id===c.output.column);if(u===void 0)return{id:o.id,title:s.setCellTitle,stale:"constraint-violated"};let f;try{f=U(u,c.output.value)}catch{return{id:o.id,title:s.setCellTitle,stale:"constraint-violated"}}return r=r.map((m,v)=>v===d?{...m,cells:{...m.cells,[u.id]:f}}:m),{id:o.id,title:s.setCellTitle,summary:s.setCellSummary(h.id,u.label),tone:"update"}}if(o.type===ut){const n=z(o.target.id),d=n===null?-1:a(n);if(d<0)return{id:o.id,title:s.deleteRowTitle,stale:"target-missing"};const c=r[d];return r=r.filter((h,u)=>u!==d),{id:o.id,title:s.deleteRowTitle,summary:s.deleteRowSummary(c?.id??""),tone:"delete"}}if(o.type===ht){const n=z(o.target.id),d=n===null?-1:a(n),c=A(ne,o.payload);if(d<0||!c.success)return{id:o.id,title:s.reorderRowTitle,stale:"target-missing"};const h=c.output.before,u=h===null?r.length:a(h);if(h!==null&&(u<0||h===n))return{id:o.id,title:s.reorderRowTitle,stale:"constraint-violated"};const f=r[d];if(f===void 0)return{id:o.id,title:s.reorderRowTitle,stale:"target-missing"};const m=r.filter((W,St)=>St!==d),v=h===null?m.length:m.findIndex(W=>W.id===h);return r=v<0?[...m,f]:[...m.slice(0,v),f,...m.slice(v)],{id:o.id,title:s.reorderRowTitle,summary:s.reorderRowSummary(f.id),tone:"move"}}return{id:o.id,title:o.type,stale:"unsupported-action-type"}});return{data:{columns:t.columns,rows:r},results:i}},le=E`
179
+ :host {
180
+ display: block;
181
+ color: var(--dpk-ink);
182
+ font-family: var(--dpk-body);
183
+ }
184
+
185
+ .head {
186
+ display: flex;
187
+ align-items: baseline;
188
+ justify-content: space-between;
189
+ gap: 12px;
190
+ margin-bottom: 8px;
191
+ }
192
+
193
+ .heading {
194
+ font-weight: 650;
195
+ }
196
+
197
+ .count {
198
+ color: var(--dpk-ink-soft);
199
+ font-family: var(--dpk-mono);
200
+ font-size: 12px;
201
+ }
202
+
203
+ .toolbar {
204
+ display: flex;
205
+ flex-wrap: wrap;
206
+ align-items: center;
207
+ gap: 8px;
208
+ margin-bottom: 10px;
209
+ }
210
+
211
+ .filter {
212
+ border: 1px solid var(--dpk-rule-strong);
213
+ border-radius: var(--dpk-radius-sm);
214
+ background: var(--dpk-paper-raised);
215
+ color: var(--dpk-ink);
216
+ font: inherit;
217
+ font-size: 13px;
218
+ padding: 5px 9px;
219
+ min-width: 160px;
220
+ }
221
+
222
+ .group-by {
223
+ display: inline-flex;
224
+ align-items: center;
225
+ gap: 6px;
226
+ color: var(--dpk-ink-soft);
227
+ font-size: 12px;
228
+ }
229
+
230
+ .add-row {
231
+ margin-inline-start: auto;
232
+ border: 1px dashed var(--dpk-rule-strong);
233
+ border-radius: var(--dpk-radius-sm);
234
+ background: transparent;
235
+ color: var(--dpk-ink-soft);
236
+ font: inherit;
237
+ font-size: 13px;
238
+ padding: 5px 10px;
239
+ cursor: pointer;
240
+ }
241
+
242
+ .add-row:hover {
243
+ color: var(--dpk-accent);
244
+ border-color: var(--dpk-accent);
245
+ }
246
+
247
+ .scroll {
248
+ overflow-x: auto;
249
+ border: 1px solid var(--dpk-rule);
250
+ border-radius: var(--dpk-radius);
251
+ }
252
+
253
+ table {
254
+ width: 100%;
255
+ border-collapse: collapse;
256
+ font-size: 13px;
257
+ }
258
+
259
+ thead th {
260
+ position: sticky;
261
+ top: 0;
262
+ z-index: 1;
263
+ background: var(--dpk-paper-sunken);
264
+ text-align: left;
265
+ font-weight: 600;
266
+ white-space: nowrap;
267
+ border-bottom: 1px solid var(--dpk-rule-strong);
268
+ }
269
+
270
+ th,
271
+ td {
272
+ padding: 7px 10px;
273
+ }
274
+
275
+ .handle-col,
276
+ .actions-col {
277
+ width: 1%;
278
+ }
279
+
280
+ .sort {
281
+ display: inline-flex;
282
+ align-items: center;
283
+ gap: 4px;
284
+ border: 0;
285
+ background: transparent;
286
+ color: inherit;
287
+ font: inherit;
288
+ font-weight: 600;
289
+ padding: 0;
290
+ cursor: pointer;
291
+ }
292
+
293
+ .sort-icon svg {
294
+ width: 12px;
295
+ height: 12px;
296
+ display: block;
297
+ }
298
+
299
+ .group-head th {
300
+ background: var(--dpk-paper-inset);
301
+ color: var(--dpk-ink-soft);
302
+ font-weight: 600;
303
+ font-size: 12px;
304
+ }
305
+
306
+ tbody tr[data-row] {
307
+ border-bottom: 1px solid var(--dpk-rule);
308
+ cursor: pointer;
309
+ }
310
+
311
+ tbody tr[data-row]:hover {
312
+ background: var(--dpk-paper-sunken);
313
+ }
314
+
315
+ tbody tr[data-row].is-selected {
316
+ background: color-mix(in srgb, var(--dpk-blue-soft) 70%, transparent);
317
+ }
318
+
319
+ tbody tr[data-row].is-dragging {
320
+ opacity: 0.4;
321
+ }
322
+
323
+ tbody tr[data-row][data-drop-before] {
324
+ box-shadow: inset 0 2px 0 0 var(--dpk-accent);
325
+ }
326
+
327
+ tbody tr[data-row]:focus-visible {
328
+ outline: none;
329
+ box-shadow: var(--dpk-focus);
330
+ }
331
+
332
+ td.handle {
333
+ cursor: grab;
334
+ color: var(--dpk-ink-faint);
335
+ }
336
+
337
+ td.handle svg {
338
+ width: 14px;
339
+ height: 14px;
340
+ display: block;
341
+ }
342
+
343
+ td.editing {
344
+ padding: 3px 6px;
345
+ }
346
+
347
+ .cell-input {
348
+ width: 100%;
349
+ box-sizing: border-box;
350
+ border: 1px solid var(--dpk-accent);
351
+ border-radius: var(--dpk-radius-xs);
352
+ background: var(--dpk-paper-raised);
353
+ color: var(--dpk-ink);
354
+ font: inherit;
355
+ font-size: 13px;
356
+ padding: 4px 6px;
357
+ }
358
+
359
+ .tags {
360
+ display: flex;
361
+ flex-wrap: wrap;
362
+ gap: 4px;
363
+ }
364
+
365
+ .tag {
366
+ border-radius: var(--dpk-radius-xs);
367
+ background: var(--dpk-paper-inset);
368
+ color: var(--dpk-ink-soft);
369
+ font-size: 11px;
370
+ padding: 2px 6px;
371
+ }
372
+
373
+ .status {
374
+ display: inline-flex;
375
+ align-items: center;
376
+ border-radius: var(--dpk-radius-xs);
377
+ font-size: 12px;
378
+ font-weight: 600;
379
+ padding: 2px 8px;
380
+ }
381
+
382
+ .status[data-tone='gray'] {
383
+ background: var(--dpk-paper-inset);
384
+ color: var(--dpk-ink-soft);
385
+ }
386
+
387
+ .status[data-tone='blue'] {
388
+ background: var(--dpk-blue-soft);
389
+ color: var(--dpk-blue-strong);
390
+ }
391
+
392
+ .status[data-tone='green'] {
393
+ background: var(--dpk-green-soft);
394
+ color: var(--dpk-green);
395
+ }
396
+
397
+ .status[data-tone='amber'] {
398
+ background: var(--dpk-amber-soft);
399
+ color: var(--dpk-amber);
400
+ }
401
+
402
+ .status[data-tone='violet'] {
403
+ background: var(--dpk-violet-soft);
404
+ color: var(--dpk-violet);
405
+ }
406
+
407
+ .status[data-tone='red'] {
408
+ background: var(--dpk-danger-soft);
409
+ color: var(--dpk-danger);
410
+ }
411
+
412
+ .person {
413
+ color: var(--dpk-ink-soft);
414
+ }
415
+
416
+ .row-actions {
417
+ display: flex;
418
+ gap: 2px;
419
+ white-space: nowrap;
420
+ }
421
+
422
+ .comment,
423
+ .delete {
424
+ display: inline-grid;
425
+ place-items: center;
426
+ width: 24px;
427
+ height: 24px;
428
+ padding: 0;
429
+ border: 0;
430
+ border-radius: var(--dpk-radius-sm);
431
+ background: transparent;
432
+ color: var(--dpk-ink-soft);
433
+ opacity: 0;
434
+ cursor: pointer;
435
+ }
436
+
437
+ tr:hover .comment,
438
+ tr:hover .delete,
439
+ tr:focus-within .comment,
440
+ tr:focus-within .delete {
441
+ opacity: 1;
442
+ }
443
+
444
+ .comment:hover {
445
+ color: var(--dpk-blue);
446
+ }
447
+
448
+ .delete:hover {
449
+ color: var(--dpk-danger);
450
+ }
451
+
452
+ .comment:focus-visible,
453
+ .delete:focus-visible {
454
+ outline: none;
455
+ box-shadow: var(--dpk-focus);
456
+ }
457
+
458
+ .comment svg,
459
+ .delete svg {
460
+ width: 14px;
461
+ height: 14px;
462
+ }
463
+
464
+ .error,
465
+ .empty {
466
+ color: var(--dpk-ink-soft);
467
+ font-size: 13px;
468
+ }
469
+
470
+ .error {
471
+ color: var(--dpk-danger);
472
+ }
473
+ `,ce=(...s)=>s.filter(t=>typeof t=="string"&&t.length>0).join(" ");class mt extends D{static{this.styles=[I,X,le]}static{this.properties={id:{type:String,reflect:!0},heading:{type:String},readonly:{type:Boolean,reflect:!0},data:{attribute:!1}}}#e=new Y(this);#r=new Bt(this);#n=null;#i=null;#a=null;#t=ot();#g=[];#m=[];#s=ee;#o=null;#l=null;#c=null;#d=null;#f=null;constructor(){super(),this.id=this.getAttribute("id")??"",this.heading=null,this.readonly=!1,this.data=null}connectedCallback(){super.connectedCallback(),this.#n=Nt(this,dt,t=>{this.data===null&&(t.ok?(this.#i=t.value,this.#a=null):(this.#i=null,this.#a=t.error),this.#O(),this.dispatchEvent(new CustomEvent("dpk-comment-targets-change",{bubbles:!0,composed:!0})))})}disconnectedCallback(){super.disconnectedCallback(),this.#n?.(),this.#n=null}willUpdate(t){t.has("data")&&this.data!==null&&(this.#i=this.data,this.#a=null,this.#O())}get commentTargets(){if(!this.id)return[];const t=`${this.#h} \xB7 ${this.id}`;return[{value:pt(this.id),label:this.#h,group:t},...this.#t.rows.map(e=>({value:x(this.id,e.id),label:this.#w(e),group:t}))]}get elementActions(){return this.#g}set elementActions(t){this.#g=t,this.#O()}get elementActionResults(){return this.#m}get selection(){return this.#o}render(){const t=this.#u;if(this.#a!==null)return l`<p class="error">${this.#a}</p>`;const e=se(this.#t,this.#s),r=this.#t.rows.length,a=e.reduce((o,n)=>o+n.rows.length,0),i=this.#p();return l`
474
+ <div class="head">
475
+ <span class="heading">${this.#h}</span>
476
+ <span class="count">${t.rowCount(a,r)}</span>
477
+ </div>
478
+ <div class="toolbar">
479
+ <input
480
+ type="search"
481
+ class="filter"
482
+ placeholder=${t.filterPlaceholder}
483
+ aria-label=${t.filterAriaLabel}
484
+ .value=${this.#s.filter}
485
+ @input=${Ot(o=>{this.#s={...this.#s,filter:o},this.requestUpdate()})}
486
+ />
487
+ ${this.#t.columns.length===0?p:l`<label class="group-by">
488
+ <span>${t.groupByLabel}</span>
489
+ ${this.#r.render({options:[{value:"",label:t.groupByNone},...this.#t.columns.map(o=>({value:o.id,label:o.label}))],value:this.#s.groupBy??"",onChange:o=>{this.#s={...this.#s,groupBy:o===""?null:o},this.requestUpdate()},ariaLabel:t.groupByLabel})}
490
+ </label>`}
491
+ ${!this.readonly&&this.id?l`<button type="button" class="add-row" @click=${()=>this.#R()}>${t.addRowButton}</button>`:p}
492
+ </div>
493
+ ${this.#f==="row"?l`<p class="error" role="alert">${t.notRecorded}</p>`:p}
494
+ ${r===0?l`<p class="empty">${t.empty}</p>`:l`<div class="scroll">
495
+ <table>
496
+ <thead>
497
+ <tr>
498
+ ${i?l`<th class="handle-col"></th>`:p}
499
+ ${this.#t.columns.map(o=>this.#b(t,o))}
500
+ <th class="actions-col"></th>
501
+ </tr>
502
+ </thead>
503
+ ${e.map(o=>this.#D(t,o,i))}
504
+ </table>
505
+ </div>`}
506
+ `}get#u(){return Xt(this.#e.locale)}get#h(){return this.heading??this.#u.heading}#p(){return!this.readonly&&this.id.length>0&&this.#s.sort===null&&this.#s.groupBy===null}#b(t,e){if(!e.sortable)return l`<th>${e.label}</th>`;const r=this.#s.sort,a=r?.column===e.id;return l`<th>
507
+ <button
508
+ type="button"
509
+ class="sort"
510
+ aria-label=${t.sortButtonAriaLabel(e.label)}
511
+ title=${a?r?.direction==="asc"?t.sortAscending:t.sortDescending:""}
512
+ @click=${()=>this.#x(e.id)}
513
+ >
514
+ <span>${e.label}</span>
515
+ ${a?l`<span class="sort-icon">${r?.direction==="asc"?qt():Mt()}</span>`:p}
516
+ </button>
517
+ </th>`}#x(t){const e=this.#s.sort;if(e?.column===t&&e.direction==="desc")this.#s={...this.#s,sort:null};else{const r=e?.column===t&&e.direction==="asc"?"desc":"asc";this.#s={...this.#s,sort:{column:t,direction:r}}}this.requestUpdate()}#D(t,e,r){const a=this.#t.columns.length+1+(r?1:0);return l`<tbody
518
+ @dragover=${i=>this.#U(i,r)}
519
+ @drop=${i=>this.#_(i,r)}
520
+ >
521
+ ${this.#s.groupBy===null?p:l`<tr class="group-head">
522
+ <th colspan=${a}>${e.label===""?t.groupByNone:e.label} (${e.rows.length})</th>
523
+ </tr>`}
524
+ ${b(e.rows,i=>i.id,i=>this.#k(t,i,r))}
525
+ </tbody>`}#k(t,e,r){const a=this.#o===e.id;return l`<tr
526
+ data-row=${e.id}
527
+ data-grill-questions=${this.#N(e)}
528
+ class=${ce(a&&"is-selected",this.#c===e.id&&"is-dragging")}
529
+ ?data-drop-before=${this.#d===e.id}
530
+ tabindex="0"
531
+ role="button"
532
+ aria-pressed=${a}
533
+ @click=${()=>this.#v(e.id)}
534
+ @keydown=${i=>this.#L(i,e.id)}
535
+ >
536
+ ${r?l`<td
537
+ class="handle"
538
+ draggable="true"
539
+ @click=${i=>i.stopPropagation()}
540
+ @dragstart=${i=>this.#E(i,e.id)}
541
+ @dragend=${()=>this.#q()}
542
+ >
543
+ ${tt()}
544
+ </td>`:p}
545
+ ${this.#t.columns.map(i=>this.#I(e,i))}
546
+ <td class="row-actions">
547
+ ${this.id?l`<button
548
+ type="button"
549
+ class="comment"
550
+ aria-label=${t.commentAriaLabel(this.#w(e))}
551
+ title=${t.commentAriaLabel(this.#w(e))}
552
+ @click=${i=>{i.stopPropagation(),this.#B(e.id)}}
553
+ >
554
+ ${Ut()}
555
+ </button>`:p}
556
+ ${!this.readonly&&this.id?l`<button
557
+ type="button"
558
+ class="delete"
559
+ aria-label=${t.deleteRowAriaLabel(this.#w(e))}
560
+ title=${t.deleteRowAriaLabel(this.#w(e))}
561
+ @click=${i=>{i.stopPropagation(),this.#S(e)}}
562
+ >
563
+ ${V()}
564
+ </button>`:p}
565
+ </td>
566
+ </tr>`}#I(t,e){const r=t.cells[e.id];if(r===void 0)return l`<td></td>`;switch(r.type){case"text":return this.#$(t,e,r.value??"");case"number":return this.#$(t,e,r.value===null?"":String(r.value));case"tag":return l`<td>
567
+ <div class="tags">${r.value.map(a=>l`<span class="tag">${a}</span>`)}</div>
568
+ </td>`;case"status":return l`<td>
569
+ ${r.value?l`<span class="status" data-tone=${r.value.tone}>${r.value.label}</span>`:p}
570
+ </td>`;case"person":return l`<td>${r.value?l`<span class="person">${r.value}</span>`:p}</td>`}}#$(t,e,r){return this.readonly||!this.id?l`<td>${r}</td>`:this.#l?.row===t.id&&this.#l.column===e.id?l`<td class="editing" @click=${i=>i.stopPropagation()}>
571
+ <input
572
+ class="cell-input"
573
+ type=${e.type==="number"?"number":"text"}
574
+ .value=${r}
575
+ @keydown=${i=>this.#T(i)}
576
+ @blur=${i=>this.#A(t,e,i)}
577
+ />
578
+ </td>`:l`<td @dblclick=${()=>this.#C(t.id,e.id)}>${r}</td>`}#C(t,e){this.#l={row:t,column:e},this.requestUpdate(),this.updateComplete.then(()=>{const r=this.renderRoot.querySelector(".cell-input");r?.focus(),r?.select()})}#T(t){t.isComposing||(t.key==="Escape"?(t.preventDefault(),this.#l=null,this.requestUpdate()):t.key==="Enter"&&t.currentTarget instanceof HTMLInputElement&&(t.preventDefault(),t.currentTarget.blur()))}#A(t,e,r){if(!(r.target instanceof HTMLInputElement))return;this.#l=null;const a=r.target.value;if(e.type==="number"){const i=a.trim()===""?null:Number(a);if(i!==null&&Number.isNaN(i)){this.requestUpdate();return}this.#y(N,x(this.id,t.id),{column:e.id,value:i})}else this.#y(N,x(this.id,t.id),{column:e.id,value:a});this.requestUpdate()}#R(){if(!this.id)return;const t=new Set(this.#t.rows.map(a=>a.id)),e=_t("row",t),r=this.#y(ct,pt(this.id),{id:e,cells:{}});this.#f=r?null:"row",r&&(this.#o=e),this.requestUpdate()}#S(t){this.id&&(this.#y(ut,x(this.id,t.id),{}),this.#o===t.id&&(this.#o=null))}#v(t){this.#o=t,this.requestUpdate(),this.dispatchEvent(new CustomEvent("dpk-table-select",{detail:{id:t},bubbles:!0,composed:!0}))}#L(t,e){t.target===t.currentTarget&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#v(e))}#B(t){this.dispatchEvent(new CustomEvent("dpk-comment-request",{detail:{target:x(this.id,t)},bubbles:!0,composed:!0}))}#E(t,e){this.#p()&&(this.#c=e,t.dataTransfer?.setData("text/plain",e))}#U(t,e){if(!e||this.#c===null)return;t.preventDefault();const r=this.#M(t);r!==this.#d&&(this.#d=r,this.requestUpdate())}#_(t,e){const r=this.#c;if(!e||r===null||!this.id)return;t.preventDefault();const a=this.#M(t);if(this.#q(),a===r)return;const i=this.#t.rows,o=i.findIndex(d=>d.id===r),n=a===null?i.length:i.findIndex(d=>d.id===a);o===n||o+1===n||this.#y(ht,x(this.id,r),{before:a})}#q(){this.#c===null&&this.#d===null||(this.#c=null,this.#d=null,this.requestUpdate())}#M(t){const e=t.currentTarget;return(e instanceof HTMLElement?[...e.querySelectorAll("[data-row]")]:[]).find(i=>{if(i.dataset.row===this.#c)return!1;const o=i.getBoundingClientRect();return t.clientY<o.top+o.height/2})?.dataset.row??null}#w(t){for(const e of this.#t.columns){const r=t.cells[e.id];if(r?.type==="text"&&r.value||r?.type==="person"&&r.value)return r.value}return t.id}#N(t){const e=t.questions?.trim();return e===void 0||e===""?p:e}#y(t,e,r){const a=new CustomEvent("dpk-element-action",{detail:{type:t,target:e,payload:r},bubbles:!0,composed:!0,cancelable:!0});return this.dispatchEvent(a),a.defaultPrevented}#O(){if(this.#i===null)this.#t=ot(),this.#m=this.#g.map(t=>({id:t.id,title:t.type,stale:"target-missing"}));else{const t=de(this.#u,this.#i,this.#g);this.#t=t.data,this.#m=t.results}this.#o!==null&&!this.#t.rows.some(t=>t.id===this.#o)&&(this.#o=null),this.requestUpdate()}}const ue=()=>{customElements.get("dpk-table")||customElements.define("dpk-table",mt)},ft=(s,t)=>{const e=Math.max(s.left,t.left),r=Math.max(s.top,t.top),a=Math.min(s.left+s.width,t.left+t.width),i=Math.min(s.top+s.height,t.top+t.height);return a>e&&i>r?{left:e,top:r,width:a-e,height:i-r}:null},he=(s,t)=>{const e=t.flatMap(d=>{const c=ft(s,d);return c?[c]:[]});if(!e[0])return null;const a=Math.min(...e.map(d=>d.left)),i=Math.min(...e.map(d=>d.top)),o=Math.max(...e.map(d=>d.left+d.width)),n=Math.max(...e.map(d=>d.top+d.height));return{box:{left:a,top:i,width:o-a,height:n-i},parts:t.map(d=>ft(s,d)?{left:d.left-a,top:d.top-i,width:d.width,height:d.height}:null)}},pe=(s,t,e)=>{const r=s.dataTransfer;if(!r)return;const a=he(e.getBoundingClientRect(),t.map(d=>d.getBoundingClientRect()));if(!a)return;const{box:i}=a,o=document.createElement("div");o.style.cssText=["position: fixed",`left: ${i.left}px`,`top: ${i.top}px`,`width: ${i.width}px`,`height: ${i.height}px`,"overflow: hidden","pointer-events: none","z-index: 2147483647",`background: ${getComputedStyle(e).backgroundColor}`].join("; ");for(const[d,c]of t.entries()){const h=a.parts[d],u=S(c);!h||!(u instanceof HTMLElement)||(u.style.position="absolute",u.style.left=`${h.left}px`,u.style.top=`${h.top}px`,u.style.width=`${h.width}px`,u.style.height=`${h.height}px`,u.style.margin="0",u.style.boxSizing="border-box",o.append(u))}const n=e.getRootNode();(n instanceof ShadowRoot?n:document.body).append(o),r.setDragImage(o,s.clientX-i.left,s.clientY-i.top),setTimeout(()=>o.remove(),0)},S=s=>{if(s instanceof Element&&s.shadowRoot)return ge(s,s.shadowRoot);const t=s.cloneNode(!1);t instanceof Element&&t.removeAttribute("id");for(const e of s.childNodes)t.appendChild(S(e));return t},ge=(s,t)=>{const e=document.createElement("span");for(const o of s.attributes)o.name!=="id"&&e.setAttribute(o.name,o.value);const r=getComputedStyle(s),a=s.getBoundingClientRect();e.style.display=r.display==="inline"?"inline-block":r.display,e.style.width=`${a.width}px`,e.style.height=`${a.height}px`,e.style.boxSizing="border-box",e.style.flex="none",e.style.verticalAlign=r.verticalAlign;const i=e.attachShadow({mode:"open"});"adoptedStyleSheets"in t&&(i.adoptedStyleSheets=t.adoptedStyleSheets);for(const o of t.childNodes)i.appendChild(S(o));for(const o of s.childNodes)e.appendChild(S(o));return e},bt=s=>s.some(t=>(t.subColumns?.length??0)>0),xt=s=>Math.max(s.subColumns?.length??1,1),vt=s=>{const t=s.subColumns??[];return t.length===0?[{columnId:s.id}]:t.map(e=>({columnId:s.id,subColumnId:e.id}))},P=s=>s.flatMap(vt),me=(s,t)=>t.subColumnId===void 0?s.draggable!==!1:(s.subColumns??[]).find(e=>e.id===t.subColumnId)?.draggable!==!1,j=(s,t)=>{const e=s.subColumns??[];return[e[0]?.id===t?"first":"",e.at(-1)?.id===t?"last":""].filter(r=>r!=="").join(" ")},wt="corner",yt="corner-sub",H=s=>`row-head:${s}`,F=s=>`col-head:${s}`,K=(s,t)=>`sub-head:${s}:${t}`,kt=(s,t)=>t.subColumnId===void 0?`cell:${s}:${t.columnId}`:`cell:${s}:${t.columnId}:${t.subColumnId}`,$t="dpk-matrix-reorder-row",Ct="dpk-matrix-reorder-column",Tt="dpk-matrix-reorder-sub-column",fe=E`
579
+ :host {
580
+ display: block;
581
+ --dpk-matrix-row-head-width: 140px;
582
+ --dpk-matrix-column-width: minmax(180px, 240px);
583
+ --dpk-matrix-dock-clearance: 0px;
584
+ /* A host with its own fully-styled head content (a raised band, say) sets
585
+ this to 0 on its own \`<dpk-matrix>\` rather than fight the padding from
586
+ outside the shadow root; the cell pad has no such escape hatch yet, since
587
+ every host so far wants it. */
588
+ --dpk-matrix-head-pad: 10px;
589
+ --dpk-matrix-cell-pad: 10px;
590
+ /* The width a draggable head's own grip plus the gap after it takes up
591
+ (14px icon + 8px gap, below): exposed so a host's slotted content can
592
+ bleed its own surface behind the grip (below) and, if it has a second
593
+ line, indent that line to the same start the first line's text gets. */
594
+ --dpk-matrix-grip-span: 22px;
595
+ }
596
+ /* The scroll frame fills the host a fill layout gave a height to, so the
597
+ grid scrolls inside it instead of spilling out of it: a frame taller than
598
+ its host would push the whole page into scrolling under a board that was
599
+ supposed to scroll itself, taking anything pinned to the page's bottom
600
+ edge with it. A host whose own height is its content keeps that height
601
+ (a percentage against an automatic height resolves to the content's). */
602
+ .matrix-scroll {
603
+ min-width: 0;
604
+ max-width: 100%;
605
+ height: 100%;
606
+ overflow: auto;
607
+ overscroll-behavior-x: contain;
608
+ border: 1px solid var(--dpk-rule);
609
+ border-radius: var(--dpk-radius-lg);
610
+ background: var(--dpk-paper-sunken);
611
+ box-shadow: var(--dpk-shadow);
612
+ }
613
+ .matrix-grid {
614
+ display: grid;
615
+ gap: 0;
616
+ min-width: max-content;
617
+ padding-bottom: var(--dpk-matrix-dock-clearance);
618
+ }
619
+ .matrix-row {
620
+ display: grid;
621
+ grid-template-columns: var(--dpk-matrix-row-head-width) repeat(var(--matrix-cols), var(--dpk-matrix-column-width));
622
+ }
623
+ .matrix-row + .matrix-row {
624
+ border-top: 1px solid var(--dpk-rule);
625
+ }
626
+
627
+ /* The head stays at the top while the rows scroll. */
628
+ .matrix-head {
629
+ position: sticky;
630
+ top: 0;
631
+ z-index: 3;
632
+ border-bottom: 1px solid var(--dpk-rule-strong);
633
+ box-shadow: 0 8px 14px -12px var(--dpk-shade-3);
634
+ }
635
+
636
+ /* The lead column (the corner and every row's head) stays at the left while
637
+ the columns scroll sideways; opaque, so cells pass under it. The
638
+ background is set here, not left to the slotted content: a row's head
639
+ spans the whole row (as tall as the cards stacked in any of its cells),
640
+ taller than its own label, so without it the row's own background would
641
+ leave that extra height transparent and a cell scrolled underneath would
642
+ show through instead of staying hidden under the sticky column. */
643
+ .matrix-corner,
644
+ .matrix-row-head {
645
+ position: sticky;
646
+ left: 0;
647
+ z-index: 2;
648
+ padding: var(--dpk-matrix-head-pad);
649
+ background: var(--dpk-paper-sunken);
650
+ box-shadow: 1px 0 0 var(--dpk-rule);
651
+ }
652
+
653
+ .matrix-col-head,
654
+ .matrix-sub-head {
655
+ padding: var(--dpk-matrix-head-pad);
656
+ background: var(--dpk-paper-sunken);
657
+ border-left: 1px solid var(--dpk-rule);
658
+ }
659
+
660
+ /* A draggable row/column/sub-column head carries its own grip (below), laid
661
+ out as a flex sibling of whatever the host slots in; a head with no grip
662
+ (none draggable) still gets the same box, just with nothing in that
663
+ slot. Baseline-aligned, not centred on the whole box: a host's head can
664
+ hold more than one line (a name plus a meta line, a title plus a steps
665
+ list), and the grip should still sit with the *first* line's text, the
666
+ way it did when the host drew it inline there itself. */
667
+ .matrix-row-head,
668
+ .matrix-col-head,
669
+ .matrix-sub-head {
670
+ display: flex;
671
+ align-items: baseline;
672
+ gap: 8px;
673
+ }
674
+ .matrix-row-head ::slotted(*),
675
+ .matrix-col-head ::slotted(*),
676
+ .matrix-sub-head ::slotted(*) {
677
+ flex: 1 1 auto;
678
+ min-width: 0;
679
+ }
680
+ /* The grip is the component's own, but the head's background, highlight or
681
+ border is the host's (its slotted content's) — so that surface has to
682
+ reach under the grip too, not stop at the slot's own flex box. A
683
+ draggable head's slotted content bleeds left by the grip's span and pads
684
+ the same amount back in: its content stays exactly where it was, but its
685
+ background now runs the full width of the cell, grip included (and,
686
+ with the grip's own stacking below, paints under it rather than over
687
+ it). A non-draggable head has no grip to bleed behind, so it is left at
688
+ its own natural padding. */
689
+ .matrix-row-head[draggable='true'] ::slotted(*),
690
+ .matrix-col-head[draggable='true'] ::slotted(*),
691
+ .matrix-sub-head[draggable='true'] ::slotted(*) {
692
+ margin-inline-start: calc(-1 * var(--dpk-matrix-grip-span));
693
+ padding-inline-start: var(--dpk-matrix-grip-span);
694
+ }
695
+
696
+ /* The grip itself: the same affordance everywhere a head can be dragged,
697
+ rendered by the component so every host gets it for free instead of
698
+ drawing its own. Lifted onto its own layer so the slotted content's
699
+ bled-left background (above) paints under it, not over it. Quiet until
700
+ the head it belongs to is hovered. */
701
+ .matrix-grip {
702
+ position: relative;
703
+ z-index: 1;
704
+ flex: none;
705
+ display: inline-flex;
706
+ color: var(--dpk-ink-faint);
707
+ transition: color 140ms ease;
708
+ }
709
+ .matrix-grip svg {
710
+ display: block;
711
+ width: 14px;
712
+ height: 14px;
713
+ }
714
+ .matrix-row-head:hover .matrix-grip,
715
+ .matrix-col-head:hover .matrix-grip,
716
+ .matrix-sub-head:hover .matrix-grip {
717
+ color: var(--dpk-blue);
718
+ }
719
+ /* The working surface: a quiet dot lattice on the sunken paper, so a card a
720
+ host places inside reads as something set down on the board rather than
721
+ text in a table cell. */
722
+ .matrix-cell {
723
+ padding: var(--dpk-matrix-cell-pad);
724
+ background: var(--dpk-dots), var(--dpk-paper-sunken);
725
+ border-left: 1px solid var(--dpk-rule);
726
+ border-top: 1px solid var(--dpk-rule);
727
+ }
728
+
729
+ /* Row drag: the head is the handle (hover/active cursor), the whole row the target. */
730
+ .matrix-row-head[draggable='true'] {
731
+ cursor: grab;
732
+ -webkit-user-select: none;
733
+ user-select: none;
734
+ }
735
+ .matrix-row-head[draggable='true']:active {
736
+ cursor: grabbing;
737
+ }
738
+ .matrix-row[data-draggable='true'] {
739
+ cursor: grab;
740
+ }
741
+ .matrix-row[data-draggable='true']:active {
742
+ cursor: grabbing;
743
+ }
744
+ /*
745
+ * Dragging state: entire row fades. Never disable pointer events on the
746
+ * source here: Lit applies this state in the microtask right after
747
+ * dragstart, and Blink then re-hit-tests the pointer and aborts the drag
748
+ * when the source is no longer under it.
749
+ */
750
+ .matrix-row[data-row-dragging='true'] {
751
+ opacity: 0.45;
752
+ }
753
+ .matrix-row[data-row-drop='true'] {
754
+ outline: 2px dashed var(--dpk-blue);
755
+ outline-offset: -2px;
756
+ }
757
+
758
+ /* Column drag: a column's or sub-column's head is its handle, like a row's. */
759
+ .matrix-col-head[draggable='true'],
760
+ .matrix-sub-head[draggable='true'] {
761
+ cursor: grab;
762
+ -webkit-user-select: none;
763
+ user-select: none;
764
+ }
765
+ .matrix-col-head[draggable='true']:active,
766
+ .matrix-sub-head[draggable='true']:active {
767
+ cursor: grabbing;
768
+ }
769
+ /* The dragged column fades from head to last cell, like a dragged row. */
770
+ .matrix-col-head[data-col-dragging='true'],
771
+ .matrix-sub-head[data-col-dragging='true'],
772
+ .matrix-cell[data-col-dragging='true'] {
773
+ opacity: 0.45;
774
+ }
775
+ /* The column a dragged one would land in lights up from head to last cell:
776
+ its sides run down every part and its head caps it. A column spans its
777
+ sub-columns, so only its outer sub-columns draw its sides. */
778
+ .matrix-col-head:is([data-col-drop='column'], [data-col-drop='subColumn']),
779
+ .matrix-sub-head:is([data-col-drop='column'], [data-col-drop='subColumn']),
780
+ .matrix-cell:is([data-col-drop='column'], [data-col-drop='subColumn']) {
781
+ --matrix-col-left: 2px;
782
+ --matrix-col-right: 2px;
783
+ --matrix-col-top: 0px;
784
+ box-shadow:
785
+ inset var(--matrix-col-left) 0 0 var(--dpk-blue),
786
+ inset calc(var(--matrix-col-right) * -1) 0 0 var(--dpk-blue),
787
+ inset 0 var(--matrix-col-top) 0 var(--dpk-blue);
788
+ }
789
+ [data-col-drop='column'][data-sub-edge]:not([data-sub-edge~='first']) {
790
+ --matrix-col-left: 0px;
791
+ }
792
+ [data-col-drop='column'][data-sub-edge]:not([data-sub-edge~='last']) {
793
+ --matrix-col-right: 0px;
794
+ }
795
+ .matrix-col-head[data-col-drop='column'],
796
+ .matrix-sub-head[data-col-drop='subColumn'] {
797
+ --matrix-col-top: 2px;
798
+ }
799
+ .matrix-cell:is([data-col-drop='column'], [data-col-drop='subColumn']) {
800
+ background: linear-gradient(var(--dpk-blue-soft), var(--dpk-blue-soft)), var(--dpk-dots), var(--dpk-paper-sunken);
801
+ }
802
+ /* The heads stay opaque: the cells scroll under them. */
803
+ .matrix-col-head:is([data-col-drop='column'], [data-col-drop='subColumn']),
804
+ .matrix-sub-head:is([data-col-drop='column'], [data-col-drop='subColumn']) {
805
+ background-image: linear-gradient(var(--dpk-blue-soft), var(--dpk-blue-soft));
806
+ }
807
+ `;class Rt extends D{static{this.styles=[I,fe]}static{this.properties={rows:{attribute:!1},columns:{attribute:!1}}}#e=null;#r=null;constructor(){super(),this.rows=[],this.columns=[]}willUpdate(t){!t.has("rows")&&!t.has("columns")||this.#e&&!this.#n()&&(this.#e=null,this.#r=null)}#n(){const t=this.#e;return t?t.kind==="row"?this.rows.some(r=>r.id===t.id):t.kind==="column"?this.columns.some(r=>r.id===t.id):(this.columns.find(r=>r.id===t.columnId)?.subColumns??[]).some(r=>r.id===t.id):!0}updated(){this.#i()}#i(){for(const t of this.rows)this.#a(H(t.id),t.draggable!==!1);for(const t of this.columns){this.#a(F(t.id),t.draggable!==!1);for(const e of t.subColumns??[])this.#a(K(t.id,e.id),e.draggable!==!1)}}#a(t,e){const r=this.renderRoot.querySelector(`slot[name="${t}"]`);if(r instanceof HTMLSlotElement)for(const a of r.assignedElements({flatten:!0}))a instanceof HTMLElement&&(a.draggable=e)}#t(t){return t?l`<span class="matrix-grip" aria-hidden="true">${tt()}</span>`:""}render(){const t=bt(this.columns),e=P(this.columns).length;return l`
808
+ <div class="matrix-scroll">
809
+ <div class="matrix-grid" style=${`--matrix-cols:${e}`}>
810
+ <div class="matrix-head">
811
+ <div class="matrix-row">
812
+ <div class="matrix-corner"><slot name=${wt}></slot></div>
813
+ ${b(this.columns,r=>r.id,r=>this.#g(r))}
814
+ </div>
815
+ ${t?l`<div class="matrix-row">
816
+ <div class="matrix-corner"><slot name=${yt}></slot></div>
817
+ ${b(this.columns,r=>r.id,r=>this.#m(r))}
818
+ </div>`:""}
819
+ </div>
820
+ ${b(this.rows,r=>r.id,r=>this.#o(r))}
821
+ </div>
822
+ </div>
823
+ `}#g(t){const e=t.draggable!==!1;return l`
824
+ <div
825
+ class="matrix-col-head"
826
+ style=${`grid-column: span ${xt(t)}`}
827
+ data-column=${t.id}
828
+ draggable=${e?"true":"false"}
829
+ data-col-dragging=${String(this.#d({columnId:t.id}))}
830
+ data-col-drop=${this.#f({columnId:t.id})}
831
+ @dragstart=${r=>this.#$(r,t)}
832
+ @dragend=${()=>this.#p()}
833
+ @dragenter=${r=>this.#C(r,t)}
834
+ @dragover=${r=>this.#C(r,t)}
835
+ @dragleave=${()=>this.#h(`column:${t.id}`)}
836
+ @drop=${r=>this.#T(r,t)}
837
+ >
838
+ ${this.#t(e)}
839
+ <slot name=${F(t.id)} @slotchange=${()=>this.#i()}></slot>
840
+ </div>
841
+ `}#m(t){const e=t.subColumns??[];if(e.length===0){const r={columnId:t.id};return l`<div
842
+ class="matrix-sub-head matrix-sub-head-spacer"
843
+ data-column=${t.id}
844
+ data-col-dragging=${String(this.#d(r))}
845
+ data-col-drop=${this.#f(r)}
846
+ ></div>`}return l`${b(e,r=>r.id,r=>this.#s(t,r))}`}#s(t,e){const r=e.draggable!==!1,a={columnId:t.id,subColumnId:e.id};return l`
847
+ <div
848
+ class="matrix-sub-head"
849
+ data-column=${t.id}
850
+ data-sub-column=${e.id}
851
+ data-sub-edge=${j(t,e.id)}
852
+ draggable=${r?"true":"false"}
853
+ data-col-dragging=${String(this.#d(a))}
854
+ data-col-drop=${this.#f(a)}
855
+ @dragstart=${i=>this.#A(i,t,e.id)}
856
+ @dragend=${()=>this.#p()}
857
+ @dragenter=${i=>this.#R(i,t,e.id)}
858
+ @dragover=${i=>this.#R(i,t,e.id)}
859
+ @dragleave=${()=>this.#h(`sub:${t.id}:${e.id}`)}
860
+ @drop=${i=>this.#S(i,t,e.id)}
861
+ >
862
+ ${this.#t(r)}
863
+ <slot name=${K(t.id,e.id)} @slotchange=${()=>this.#i()}></slot>
864
+ </div>
865
+ `}#o(t){const e=t.draggable!==!1;return l`
866
+ <div
867
+ class="matrix-row"
868
+ data-row=${t.id}
869
+ data-draggable=${String(e)}
870
+ data-row-dragging=${String(this.#e?.kind==="row"&&this.#e.id===t.id)}
871
+ data-row-drop=${String(this.#r===`row:${t.id}`)}
872
+ @dragenter=${r=>this.#k(r,t)}
873
+ @dragover=${r=>this.#k(r,t)}
874
+ @dragleave=${()=>this.#h(`row:${t.id}`)}
875
+ @drop=${r=>this.#I(r,t)}
876
+ >
877
+ <div
878
+ class="matrix-row-head"
879
+ draggable=${e?"true":"false"}
880
+ @dragstart=${r=>this.#D(r,t)}
881
+ @dragend=${()=>this.#p()}
882
+ >
883
+ ${this.#t(e)}
884
+ <slot name=${H(t.id)} @slotchange=${()=>this.#i()}></slot>
885
+ </div>
886
+ ${b(P(this.columns),r=>r.subColumnId===void 0?r.columnId:`${r.columnId}:${r.subColumnId}`,r=>this.#l(t,r))}
887
+ </div>
888
+ `}#l(t,e){return l`
889
+ <div
890
+ class="matrix-cell"
891
+ data-row=${t.id}
892
+ data-column=${e.columnId}
893
+ data-sub-column=${e.subColumnId??""}
894
+ data-col-dragging=${String(this.#d(e))}
895
+ data-col-drop=${this.#f(e)}
896
+ data-sub-edge=${this.#c(e)}
897
+ @dragenter=${r=>this.#v(r,e)}
898
+ @dragover=${r=>this.#v(r,e)}
899
+ @dragleave=${()=>this.#L(e)}
900
+ @drop=${r=>this.#B(r,e)}
901
+ >
902
+ <slot name=${kt(t.id,e)}></slot>
903
+ </div>
904
+ `}#c(t){if(t.subColumnId===void 0)return"";const e=this.columns.find(r=>r.id===t.columnId);return e?j(e,t.subColumnId):""}#d(t){const e=this.#e;return e?e.kind==="column"?e.id===t.columnId:e.kind==="subColumn"?e.columnId===t.columnId&&e.id===t.subColumnId:!1:!1}#f(t){return this.#r===`column:${t.columnId}`?"column":t.subColumnId!==void 0&&this.#r===`sub:${t.columnId}:${t.subColumnId}`?"subColumn":"none"}#u(t){this.#r!==t&&(this.#r=t,this.requestUpdate())}#h(t){this.#r===t&&(this.#r=null,this.requestUpdate())}#p(){this.#e===null&&this.#r===null||(this.#e=null,this.#r=null,this.requestUpdate())}#b(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0,cancelable:!0}))}#x(t){const e=t.currentTarget;return e instanceof Element?st(e.getBoundingClientRect(),t.clientY):"end"}#D(t,e){if(e.draggable===!1)return;this.#e={kind:"row",id:e.id},t.dataTransfer?.setData("text/plain",`row:${e.id}`),t.dataTransfer&&(t.dataTransfer.effectAllowed="move");const a=(t.currentTarget instanceof Element?t.currentTarget:null)?.closest(".matrix-row");if(a&&t.dataTransfer){const i=a.getBoundingClientRect();t.dataTransfer.setDragImage(a,t.clientX-i.left,t.clientY-i.top)}this.requestUpdate()}#k(t,e){e.draggable===!1||this.#e?.kind!=="row"||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this.#u(`row:${e.id}`))}#I(t,e){const r=this.#e;if(e.draggable===!1||r?.kind!=="row")return;t.preventDefault();const a=this.#x(t),i=R(this.rows.map(o=>o.id),r.id,e.id,a);this.#p(),this.#b($t,{rowId:r.id,after:i})}#$(t,e){e.draggable!==!1&&(this.#e={kind:"column",id:e.id},t.dataTransfer?.setData("text/plain",`column:${e.id}`),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"),this.#E(t,r=>r.getAttribute("data-column")===e.id),this.requestUpdate())}#C(t,e){e.draggable===!1||this.#e?.kind!=="column"||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this.#u(`column:${e.id}`))}#T(t,e){const r=this.#e;if(e.draggable===!1||r?.kind!=="column")return;t.preventDefault();const a=this.#x(t),i=R(this.columns.map(o=>o.id),r.id,e.id,a);this.#p(),this.#b(Ct,{columnId:r.id,after:i})}#A(t,e,r){(e.subColumns??[]).find(i=>i.id===r)?.draggable!==!1&&(this.#e={kind:"subColumn",columnId:e.id,id:r},t.dataTransfer?.setData("text/plain",`sub-column:${e.id}:${r}`),t.dataTransfer&&(t.dataTransfer.effectAllowed="move"),this.#E(t,i=>i.getAttribute("data-column")===e.id&&i.getAttribute("data-sub-column")===r),this.requestUpdate())}#R(t,e,r){const a=this.#e;a?.kind!=="subColumn"||a.columnId!==e.id||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this.#u(`sub:${e.id}:${r}`))}#S(t,e,r){const a=this.#e;if(a?.kind!=="subColumn"||a.columnId!==e.id)return;t.preventDefault();const i=this.#x(t),o=(e.subColumns??[]).map(d=>d.id),n=R(o,a.id,r,i);this.#p(),this.#b(Tt,{columnId:e.id,subColumnId:a.id,after:n})}#v(t,e){const r=this.#e;if(r){if(r.kind==="column"){t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this.#u(`column:${e.columnId}`);return}r.kind==="subColumn"&&e.subColumnId!==void 0&&r.columnId===e.columnId&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this.#u(`sub:${e.columnId}:${e.subColumnId}`))}}#L(t){this.#h(`column:${t.columnId}`),t.subColumnId!==void 0&&this.#h(`sub:${t.columnId}:${t.subColumnId}`)}#B(t,e){const r=this.#e;if(r){if(r.kind==="column"){const a=this.columns.find(i=>i.id===e.columnId);a&&this.#T(t,a);return}if(r.kind==="subColumn"&&e.subColumnId!==void 0&&r.columnId===e.columnId){const a=this.columns.find(i=>i.id===e.columnId);a&&this.#S(t,a,e.subColumnId)}}}#E(t,e){const r=this.renderRoot.querySelector(".matrix-scroll");if(!r)return;const a=[...r.querySelectorAll("[data-column]")].filter(e),i=a.filter(n=>n.classList.contains("matrix-col-head")||n.classList.contains("matrix-sub-head")),o=a.filter(n=>!i.includes(n));pe(t,[...o,...i],r)}}const be=()=>{customElements.get("dpk-matrix")||customElements.define("dpk-matrix",Rt)};export{et as B,wt as C,it as D,zt as E,Ct as M,yt as a,Rt as b,mt as c,$t as d,Tt as e,P as f,kt as g,F as h,Gt as i,be as j,ue as k,bt as l,me as m,vt as n,j as o,dt as p,K as q,H as r,xt as s,Pt as t,jt as u,q as v,R as w,Ft as x};