dev-process-kit 0.0.1 → 0.0.2-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.
@@ -0,0 +1,692 @@
1
+ import{q as ae,ag as le,a8 as h,ad as f,ae as b,ab as p,ai as R,a7 as se,aa as C,a9 as k,aj as de,R as L,V as pe,a1 as l,a2 as ce,a0 as u,$ as ge,T as Q,av as ue,aw as he}from"./shared-5C6fORCL.js";import{c as q}from"./shared-ml5h7U5L.js";const fe=le("kind",[h({kind:R("option"),optionId:f(p(),b(1))}),h({kind:R("free"),text:p()}),h({kind:R("clear")})]),m={ANSWER_QUESTION:ae("ANSWER_QUESTION","question",fe)},N=(t,e)=>({type:"ANSWER_QUESTION",target:{type:"question",id:t},payload:e}),be=h({id:f(p(),b(1)),label:f(p(),b(1))}),ke=h({id:f(p(),b(1)),ref:k(f(p(),b(1))),title:f(p(),b(1)),description:k(p()),note:k(p()),options:k(C(be),[]),freeText:k(de(),!0)}),O=h({title:k(p(),""),questions:C(ke)}),_=t=>{const e=se(O,t),i=new Set,r=e.questions.map((n,o)=>{if(i.has(n.id))throw new Error(`duplicate question id: ${n.id}`);i.add(n.id);const s=new Set;for(const a of n.options){if(s.has(a.id))throw new Error(`duplicate option id: ${a.id} in question ${n.id}`);s.add(a.id)}return{id:n.id,ref:n.ref??`Q${o+1}`,title:n.title,description:n.description??null,note:n.note??null,options:n.options,freeText:n.freeText}});return{title:e.title,questions:r,answers:{}}},B=()=>({title:"",questions:[],answers:{}}),c=(t,e)=>t.questions.find(i=>i.id===e),xe=(t,e)=>c(t,e)?.ref??e,E=(t,e)=>{const i=c(t,e);return i?`${i.ref} \xB7 ${i.title}`:e},w=(t,e)=>e?e.kind==="option"?t.options.find(i=>i.id===e.optionId)?.label??"":e.text.trim():"",$=(t,e)=>w(t,e)!=="",G=t=>{let e="";for(let i=t+1;i>0;i=Math.floor((i-1)/26))e=String.fromCharCode(97+(i-1)%26)+e;return e},U=t=>({total:t.questions.length,answered:t.questions.filter(e=>$(e,t.answers[e.id])).length}),y=(t,e,i)=>{const r=t.answers[e];if(i===null){if(r===void 0)return t;const n={...t.answers};return delete n[e],{...t,answers:n}}return r?.kind===i.kind&&(r.kind==="option"&&i.kind==="option"&&r.optionId===i.optionId||r.kind==="free"&&i.kind==="free"&&r.text===i.text)?t:{...t,answers:{...t.answers,[e]:i}}},F=(t,e)=>{if(e.type!=="ANSWER_QUESTION")return null;const i=c(t,e.target.id);if(!i)return null;const r=L(m.ANSWER_QUESTION,e);return r.kind==="clear"?y(t,i.id,null):r.kind==="option"?i.options.some(n=>n.id===r.optionId)?y(t,i.id,{kind:"option",optionId:r.optionId}):null:y(t,i.id,{kind:"free",text:r.text})},H=t=>t.title===""?"Visually Grill":t.title,M=(t,e)=>{switch(e.type){case"question":return E(t,e.id);case"page":return"\u30DA\u30FC\u30B8\u5168\u4F53";default:return e.id}},ve=(t,e)=>{const i=L(m.ANSWER_QUESTION,e);return i.kind==="clear"?{title:"\u56DE\u7B54\u3092\u30AF\u30EA\u30A2",tone:"delete"}:i.kind==="option"?{title:"\u56DE\u7B54",tone:"update",body:`\u2192 \u300C${c(t,e.target.id)?.options.find(n=>n.id===i.optionId)?.label??i.optionId}\u300D`}:{title:"\u81EA\u7531\u8A18\u8FF0\u3067\u56DE\u7B54",tone:"update",body:`\u2192 \u300C${i.text.slice(0,120)}\u300D`}},W=(t,e,i)=>{let r;try{r=ve(i??e,t)}catch{r={title:t.type,tone:"meta"}}return{title:r.title,targetLabel:M(e,t.target),tone:r.tone,...r.body===void 0?{}:{summary:r.body}}},j=t=>`${t.type} ${pe(t.target)} ${JSON.stringify(t.payload)}`,P=t=>t.questions.map(e=>({value:`question:${e.id}`,label:E(t,e.id),group:"\u8CEA\u554F"})),V=(t,e)=>{const i=e.question;if(i!==void 0&&c(t,i))return e;const r=t.questions[0];return r===void 0?e:{...e,question:r.id}},D=(t,e)=>{const i=e.question;return i!==void 0&&c(t,i)?i:t.questions[0]?.id??null},me=(t,e)=>{const i=t.questions,r=i.findIndex(o=>o.id===e);return(r===-1?i:[...i.slice(r+1),...i.slice(0,r)]).find(o=>!$(o,t.answers[o.id]))?.id??null},we=(t,e,i)=>{const r=e.answers[t.id];return{id:t.id,ref:t.ref,title:t.title,description:t.description,note:t.note,open:t.id===i,answered:w(t,r)!=="",summary:w(t,r),choices:t.options.map((n,o)=>({id:n.id,letter:G(o),label:n.label,checked:r?.kind==="option"&&r.optionId===n.id})),draft:r?.kind==="free"?r.text:"",freeSelected:r?.kind==="free",allowFreeText:t.freeText}},K=(t,e)=>{const i=D(t,e);return{questions:t.questions.map(r=>we(r,t,i))}},Y=t=>{const e=U(t);return{progress:`\u56DE\u7B54\u6E08\u307F ${e.answered} / ${e.total}`,answered:e.answered,total:e.total}},J=(t,e)=>{switch(e.type){case"question":return c(t,e.id)!==void 0;case"page":return!0;default:return!1}},X={name:"grill",label:"Visually Grill",parseBase:_,emptyBase:B,actions:m,apply:F,hasTarget:J,describe:W,serialize:j,resolveNavigation:V,commentTargets:t=>P(t),title:H},x="data-grill-questions",$e=t=>{const e=[t];for(const i of t.querySelectorAll("*"))i.shadowRoot&&e.push(i.shadowRoot);return e},Z=(t,e,i)=>{const r=i.question??e.questions[0]?.id??null,n=new Map(e.questions.map(s=>[s.ref,s])),o=[];for(const s of $e(t))for(const a of s.querySelectorAll(`[${x}]`)){const g=a.getAttribute(x)??"";for(const S of g.split(/\s+/)){if(S==="")continue;const d=n.get(S);d&&o.push({index:o.length,target:a,questionId:d.id,ref:d.ref,title:d.title,answered:$(d,e.answers[d.id]),open:d.id===r})}}return o},ee=(t,e)=>{const i=t.getBoundingClientRect(),r=new Map;e.forEach((o,s)=>{const a=t.querySelector(`[data-label="${s}"]`);if(!a)return;const g=r.get(o.target)??[];g.push(a),r.set(o.target,g)});const n=new Map;for(const[o,s]of r){const a=o.getBoundingClientRect(),g=a.width>0||a.height>0,d=n.get(o)??ye(o,t);n.set(o,d);const A=a.bottom>i.top&&a.top<i.bottom&&a.right>i.left&&a.left<i.right,I=a.bottom>d.top&&a.top<d.bottom;s.forEach((v,re)=>{if(v.dataset.visible=String(g&&A&&I),!g||!A||!I)return;const T=v.offsetWidth,z=v.offsetHeight,ne=a.right-i.left-T+8-(s.length-1-re)*(T+5),oe=a.top-i.top-z/2;v.style.transform=`translate(${q(ne,0,Math.max(0,t.clientWidth-T))}px, ${q(oe,0,Math.max(0,t.clientHeight-z))}px)`})}},ye=(t,e)=>{const i=t.getRootNode(),r=i instanceof ShadowRoot?i.host:null,n=r?.shadowRoot?.querySelector(".diagram-canvas")??null;return n instanceof Element?n.getBoundingClientRect():r instanceof Element?r.getBoundingClientRect():e.getBoundingClientRect()},Se=(t,e)=>l`
2
+ <div class="grill-list">
3
+ ${t.questions.length===0?l`<p class="grill-empty">該当する質問はありません。</p>`:ce(t.questions,i=>i.id,i=>Te(i,e))}
4
+ </div>
5
+ `,Te=(t,e)=>l`
6
+ <section class="grill-question" data-question=${t.id} data-answered=${String(t.answered)}>
7
+ <button
8
+ class="grill-heading"
9
+ type="button"
10
+ aria-expanded=${t.open?"true":"false"}
11
+ aria-controls=${`grill-body-${t.id}`}
12
+ @click=${()=>e.open(t.id)}
13
+ >
14
+ <span class="grill-ref">${t.ref}</span>
15
+ <span class="grill-heading-text">
16
+ <strong>${t.title}</strong>
17
+ ${!t.open&&t.answered?l`<span class="grill-summary">${t.summary}</span>`:u}
18
+ </span>
19
+ <span class="grill-chevron" aria-hidden="true">${t.open?"\u2212":"+"}</span>
20
+ </button>
21
+ ${t.open?l`<div class="grill-body" id=${`grill-body-${t.id}`}>
22
+ ${t.description?l`<p class="grill-description">${t.description}</p>`:u}
23
+ ${t.note?l`<p class="grill-note">${t.note}</p>`:u}
24
+ <div class="grill-choices" role="radiogroup" aria-label=${t.title}>
25
+ ${t.choices.map(i=>Re(t.id,i,e))}
26
+ ${t.allowFreeText?l`<label class="grill-choice grill-choice--free" data-free=${String(t.freeSelected)}>
27
+ <input
28
+ type="radio"
29
+ name=${`grill-${t.id}`}
30
+ value="__free"
31
+ .checked=${t.freeSelected}
32
+ @change=${()=>e.answer(t.id,{kind:"free",text:""})}
33
+ />
34
+ <span class="grill-choice-text">自由記述</span>
35
+ </label>`:u}
36
+ </div>
37
+ ${t.allowFreeText?l`<textarea
38
+ class="dpk-textarea grill-free"
39
+ data-free-text=${t.id}
40
+ aria-label=${`${t.ref} \u306E\u81EA\u7531\u8A18\u8FF0`}
41
+ placeholder="回答を入力…(⌘/Ctrl+Enter で次へ)"
42
+ .value=${t.draft}
43
+ ?hidden=${!t.freeSelected}
44
+ @input=${i=>{const r=i.currentTarget;r instanceof HTMLTextAreaElement&&e.answer(t.id,{kind:"free",text:r.value})}}
45
+ @keydown=${i=>{i.isComposing||!(i.metaKey||i.ctrlKey)||i.key!=="Enter"||(i.preventDefault(),e.next(t.id))}}
46
+ ></textarea>`:u}
47
+ ${t.answered?l`<button
48
+ type="button"
49
+ class="grill-clear"
50
+ @click=${()=>e.answer(t.id,{kind:"clear"})}
51
+ >
52
+ 回答をクリア
53
+ </button>`:u}
54
+ </div>`:u}
55
+ </section>
56
+ `,Re=(t,e,i)=>l`
57
+ <label class="grill-choice" data-choice=${e.id}>
58
+ <input
59
+ type="radio"
60
+ name=${`grill-${t}`}
61
+ value=${e.id}
62
+ .checked=${e.checked}
63
+ @change=${()=>i.answer(t,{kind:"option",optionId:e.id})}
64
+ />
65
+ <span class="grill-choice-text">
66
+ <span class="grill-letter">(${e.letter})</span>
67
+ <span>${e.label}</span>
68
+ </span>
69
+ </label>
70
+ `,Ee=ge`
71
+ .dpk-main {
72
+ order: 1;
73
+ }
74
+
75
+ /* The shell's sidebar becomes a right-hand rail, keeping its width and scroll. */
76
+ .dpk-sidebar {
77
+ order: 2;
78
+ width: 336px;
79
+ display: flex;
80
+ flex-direction: column;
81
+ gap: 0;
82
+ padding: 0;
83
+ border-right: 0;
84
+ border-left: 1px solid var(--dpk-rule);
85
+ }
86
+
87
+ /* The header reserves room for the corner button, exactly like the review
88
+ button in the other templates. */
89
+ .grill-panel {
90
+ display: flex;
91
+ flex-direction: column;
92
+ flex: 1;
93
+ min-height: 0;
94
+ }
95
+
96
+ .grill-tab-panel {
97
+ display: flex;
98
+ flex-direction: column;
99
+ flex: 1;
100
+ min-height: 0;
101
+ overflow: auto;
102
+ }
103
+
104
+ .grill-tab-panel[hidden],
105
+ .dpk-sidebar[hidden] {
106
+ display: none;
107
+ }
108
+
109
+ .grill-tab-panel dpk-component-comment-panel {
110
+ flex: 1;
111
+ }
112
+
113
+ /* ------------------------------------------------------- header control */
114
+
115
+ /*
116
+ * The one control the reader always needs: the questions. It sits where the
117
+ * other templates put their review button, and folds the question column away
118
+ * so the diagrams get the width back.
119
+ */
120
+ .grill-toggle {
121
+ position: fixed;
122
+ top: 10px;
123
+ right: 16px;
124
+ z-index: 60;
125
+ display: inline-flex;
126
+ align-items: center;
127
+ justify-content: center;
128
+ width: 38px;
129
+ height: 38px;
130
+ padding: 0;
131
+ border: 1px solid var(--dpk-rule-strong);
132
+ border-radius: 999px;
133
+ background: var(--dpk-paper-raised);
134
+ color: var(--dpk-ink-soft);
135
+ font-size: 16.5px;
136
+ font-weight: 650;
137
+ line-height: 1;
138
+ box-shadow: var(--dpk-shadow);
139
+ cursor: pointer;
140
+ transition:
141
+ color 160ms ease,
142
+ background 160ms ease,
143
+ border-color 160ms ease,
144
+ box-shadow 160ms ease,
145
+ transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
146
+ }
147
+
148
+ .grill-toggle:hover {
149
+ color: var(--dpk-ink);
150
+ transform: translateY(-2px) scale(1.05);
151
+ box-shadow: var(--dpk-shadow-lg);
152
+ }
153
+
154
+ .grill-toggle:active {
155
+ transform: translateY(0) scale(0.97);
156
+ box-shadow: var(--dpk-shadow-xs);
157
+ }
158
+
159
+ .grill-toggle:focus-visible {
160
+ outline: none;
161
+ box-shadow: var(--dpk-focus);
162
+ }
163
+
164
+ .grill-toggle[aria-expanded='true'] {
165
+ color: var(--dpk-accent-ink);
166
+ border-color: transparent;
167
+ background: linear-gradient(135deg, var(--dpk-accent), var(--dpk-accent-strong));
168
+ box-shadow: 0 2px 8px rgba(217, 73, 32, 0.3);
169
+ }
170
+
171
+ .grill-toggle-glyph {
172
+ display: block;
173
+ }
174
+
175
+ .grill-toggle-badge {
176
+ position: absolute;
177
+ top: -5px;
178
+ right: -5px;
179
+ min-width: 22px;
180
+ height: 18px;
181
+ padding: 0 5px;
182
+ border: 2px solid var(--dpk-paper-raised);
183
+ border-radius: 999px;
184
+ background: var(--dpk-paper-inset);
185
+ color: var(--dpk-ink-faint);
186
+ font-family: var(--dpk-mono);
187
+ font-size: 9px;
188
+ font-weight: 600;
189
+ font-variant-numeric: tabular-nums;
190
+ line-height: 14px;
191
+ /* The widest value is wider than the button it sits on: keep it on one line. */
192
+ white-space: nowrap;
193
+ text-align: center;
194
+ }
195
+
196
+ .grill-toggle[aria-expanded='true'] .grill-toggle-badge {
197
+ background: var(--dpk-paper-raised);
198
+ color: var(--dpk-ink-soft);
199
+ }
200
+
201
+ /* ------------------------------------------------------------- the list */
202
+
203
+ .grill-tabs {
204
+ display: flex;
205
+ align-items: center;
206
+ gap: 2px;
207
+ flex-shrink: 0;
208
+ padding: 8px 10px;
209
+ border-bottom: 1px solid var(--dpk-rule);
210
+ background: var(--dpk-paper-raised);
211
+ }
212
+
213
+ .grill-tabs button {
214
+ display: inline-flex;
215
+ align-items: center;
216
+ gap: 5px;
217
+ padding: 5px 9px;
218
+ border: 1px solid transparent;
219
+ border-radius: var(--dpk-radius-xs);
220
+ background: transparent;
221
+ color: var(--dpk-ink-faint);
222
+ font-size: 11.5px;
223
+ cursor: pointer;
224
+ }
225
+
226
+ .grill-tabs button:hover {
227
+ background: var(--dpk-paper-inset);
228
+ color: var(--dpk-ink);
229
+ }
230
+
231
+ .grill-tabs button[aria-selected='true'] {
232
+ border-color: var(--dpk-rule-strong);
233
+ background: var(--dpk-paper-raised);
234
+ color: var(--dpk-ink);
235
+ font-weight: 600;
236
+ box-shadow: var(--dpk-shadow-xs);
237
+ }
238
+
239
+ .grill-count {
240
+ font-family: var(--dpk-mono);
241
+ font-size: 10px;
242
+ font-variant-numeric: tabular-nums;
243
+ color: var(--dpk-ink-faint);
244
+ }
245
+
246
+ .grill-list {
247
+ flex: 1;
248
+ min-height: 0;
249
+ overflow: auto;
250
+ overscroll-behavior: contain;
251
+ padding: 2px 10px 12px;
252
+ }
253
+
254
+ .grill-empty {
255
+ margin: 0;
256
+ padding: 22px 8px;
257
+ text-align: center;
258
+ font-size: 12px;
259
+ color: var(--dpk-ink-faint);
260
+ }
261
+
262
+ .grill-question {
263
+ border-bottom: 1px solid var(--dpk-rule);
264
+ }
265
+
266
+ .grill-question:last-child {
267
+ border-bottom: 0;
268
+ }
269
+
270
+ .grill-heading {
271
+ display: flex;
272
+ align-items: flex-start;
273
+ gap: 9px;
274
+ width: 100%;
275
+ padding: 11px 6px;
276
+ border: 0;
277
+ border-radius: var(--dpk-radius-xs);
278
+ background: none;
279
+ text-align: left;
280
+ cursor: pointer;
281
+ }
282
+
283
+ .grill-heading:hover {
284
+ background: var(--dpk-paper-sunken);
285
+ }
286
+
287
+ .grill-ref {
288
+ flex: 0 0 auto;
289
+ display: grid;
290
+ place-items: center;
291
+ min-width: 30px;
292
+ height: 22px;
293
+ padding: 0 6px;
294
+ border: 1px solid var(--dpk-rule-strong);
295
+ border-radius: 999px;
296
+ font-family: var(--dpk-mono);
297
+ font-size: 10px;
298
+ font-variant-numeric: tabular-nums;
299
+ color: var(--dpk-ink-faint);
300
+ }
301
+
302
+ .grill-question[data-answered='true'] .grill-ref {
303
+ border-color: transparent;
304
+ background: var(--dpk-green-soft);
305
+ color: var(--dpk-green);
306
+ font-weight: 600;
307
+ }
308
+
309
+ .grill-question:has(.grill-heading[aria-expanded='true']) .grill-ref {
310
+ border-color: transparent;
311
+ background: var(--dpk-accent-soft);
312
+ color: var(--dpk-accent);
313
+ font-weight: 600;
314
+ }
315
+
316
+ .grill-heading-text {
317
+ flex: 1;
318
+ min-width: 0;
319
+ }
320
+
321
+ .grill-heading-text strong {
322
+ display: block;
323
+ font-size: 12.5px;
324
+ font-weight: 600;
325
+ line-height: 1.6;
326
+ }
327
+
328
+ .grill-summary {
329
+ display: block;
330
+ margin-top: 4px;
331
+ font-size: 10.5px;
332
+ line-height: 1.6;
333
+ color: var(--dpk-green);
334
+ white-space: nowrap;
335
+ overflow: hidden;
336
+ text-overflow: ellipsis;
337
+ }
338
+
339
+ .grill-chevron {
340
+ flex: 0 0 auto;
341
+ width: 16px;
342
+ color: var(--dpk-ink-faint);
343
+ font-size: 12px;
344
+ line-height: 22px;
345
+ text-align: center;
346
+ }
347
+
348
+ .grill-body {
349
+ padding: 0 6px 13px 45px;
350
+ }
351
+
352
+ .grill-description {
353
+ margin: 0 0 8px;
354
+ font-size: 11.5px;
355
+ line-height: 1.85;
356
+ color: var(--dpk-ink-soft);
357
+ }
358
+
359
+ .grill-note {
360
+ margin: 0 0 10px;
361
+ padding: 7px 10px;
362
+ border-left: 2px solid var(--dpk-amber);
363
+ border-radius: 0 var(--dpk-radius-xs) var(--dpk-radius-xs) 0;
364
+ background: var(--dpk-amber-soft);
365
+ font-size: 11px;
366
+ line-height: 1.7;
367
+ color: var(--dpk-ink-soft);
368
+ }
369
+
370
+ .grill-choices {
371
+ display: grid;
372
+ gap: 6px;
373
+ }
374
+
375
+ .grill-choice {
376
+ display: flex;
377
+ align-items: flex-start;
378
+ gap: 8px;
379
+ padding: 8px 9px;
380
+ border: 1px solid var(--dpk-rule);
381
+ border-radius: var(--dpk-radius-sm);
382
+ background: var(--dpk-paper);
383
+ font-size: 11.5px;
384
+ line-height: 1.7;
385
+ cursor: pointer;
386
+ }
387
+
388
+ .grill-choice:hover {
389
+ border-color: var(--dpk-rule-strong);
390
+ }
391
+
392
+ .grill-choice:has(input:checked) {
393
+ border-color: color-mix(in srgb, var(--dpk-green) 45%, transparent);
394
+ background: var(--dpk-green-soft);
395
+ }
396
+
397
+ .grill-choice input {
398
+ flex: 0 0 auto;
399
+ margin: 3px 0 0;
400
+ accent-color: var(--dpk-green);
401
+ }
402
+
403
+ .grill-choice-text {
404
+ display: flex;
405
+ gap: 7px;
406
+ min-width: 0;
407
+ }
408
+
409
+ .grill-letter {
410
+ flex: 0 0 auto;
411
+ font-family: var(--dpk-mono);
412
+ font-size: 10px;
413
+ line-height: 1.9;
414
+ color: var(--dpk-green);
415
+ }
416
+
417
+ .grill-free {
418
+ margin-top: 7px;
419
+ min-height: 76px;
420
+ max-height: 240px;
421
+ }
422
+
423
+ .grill-clear {
424
+ margin-top: 10px;
425
+ padding: 0;
426
+ border: 0;
427
+ background: none;
428
+ color: var(--dpk-ink-faint);
429
+ font-size: 10.5px;
430
+ text-decoration: underline;
431
+ text-underline-offset: 3px;
432
+ cursor: pointer;
433
+ }
434
+
435
+ .grill-clear:hover {
436
+ color: var(--dpk-ink);
437
+ }
438
+
439
+ .grill-footer {
440
+ flex-shrink: 0;
441
+ padding: 10px 12px;
442
+ border-top: 1px solid var(--dpk-rule);
443
+ background: var(--dpk-paper-raised);
444
+ }
445
+
446
+ .grill-copy {
447
+ width: 100%;
448
+ }
449
+
450
+ /* Inside a Claude Artifact: send is the way, copy the fallback beside it. */
451
+ .grill-footer-actions {
452
+ display: flex;
453
+ gap: 6px;
454
+ }
455
+
456
+ .grill-send {
457
+ flex: 1;
458
+ min-width: 0;
459
+ }
460
+
461
+ .grill-footer-actions .grill-copy {
462
+ width: auto;
463
+ flex-shrink: 0;
464
+ }
465
+
466
+ .grill-send[data-status='sent'] {
467
+ border-color: transparent;
468
+ background: var(--dpk-green);
469
+ color: var(--dpk-accent-ink);
470
+ }
471
+
472
+ .grill-send[data-status='failed'] {
473
+ border-color: transparent;
474
+ background: var(--dpk-amber);
475
+ color: var(--dpk-accent-ink);
476
+ }
477
+
478
+ .grill-footer-note {
479
+ margin: 8px 0 0;
480
+ color: var(--dpk-ink-soft);
481
+ font-size: 11.5px;
482
+ line-height: 1.5;
483
+ }
484
+
485
+ /* The copy button reports the outcome, so a click is never silent. */
486
+ .grill-copy[data-status='copied'] {
487
+ border-color: transparent;
488
+ background: var(--dpk-green);
489
+ color: var(--dpk-accent-ink);
490
+ }
491
+
492
+ .grill-copy[data-status='copied']:hover:not([disabled]) {
493
+ border-color: transparent;
494
+ background: color-mix(in srgb, var(--dpk-green) 85%, #000);
495
+ }
496
+
497
+ .grill-copy[data-status='failed'] {
498
+ border-color: transparent;
499
+ background: var(--dpk-amber);
500
+ color: var(--dpk-accent-ink);
501
+ }
502
+
503
+ .grill-copy[data-status='failed']:hover:not([disabled]) {
504
+ border-color: transparent;
505
+ background: color-mix(in srgb, var(--dpk-amber) 85%, #000);
506
+ }
507
+
508
+ /* Announced to assistive tech; the button label change alone is easy to miss. */
509
+ .grill-sr {
510
+ position: absolute;
511
+ width: 1px;
512
+ height: 1px;
513
+ margin: -1px;
514
+ padding: 0;
515
+ overflow: hidden;
516
+ clip-path: inset(50%);
517
+ white-space: nowrap;
518
+ border: 0;
519
+ }
520
+
521
+ /* -------------------------------------------------- main area and badges */
522
+
523
+ .grill-stage {
524
+ position: relative;
525
+ min-width: 0;
526
+ }
527
+
528
+ .grill-labels {
529
+ position: absolute;
530
+ inset: 0;
531
+ z-index: 3;
532
+ overflow: hidden;
533
+ pointer-events: none;
534
+ }
535
+
536
+ .grill-label {
537
+ position: absolute;
538
+ display: inline-flex;
539
+ align-items: center;
540
+ justify-content: center;
541
+ min-width: 30px;
542
+ height: 22px;
543
+ padding: 0 7px;
544
+ border: 2px solid var(--dpk-paper-raised);
545
+ border-radius: 999px;
546
+ background: var(--dpk-accent);
547
+ color: var(--dpk-accent-ink);
548
+ font-family: var(--dpk-mono);
549
+ font-size: 10px;
550
+ font-weight: 600;
551
+ font-variant-numeric: tabular-nums;
552
+ box-shadow: var(--dpk-shadow-xs);
553
+ cursor: pointer;
554
+ pointer-events: auto;
555
+ }
556
+
557
+ .grill-label[data-visible='false'] {
558
+ visibility: hidden;
559
+ }
560
+
561
+ .grill-label:hover {
562
+ background: color-mix(in srgb, var(--dpk-accent) 80%, #000);
563
+ }
564
+
565
+ .grill-label[data-answered='true'] {
566
+ background: var(--dpk-green);
567
+ }
568
+
569
+ .grill-label[aria-pressed='true'] {
570
+ box-shadow:
571
+ 0 0 0 2px color-mix(in srgb, var(--dpk-accent) 45%, transparent),
572
+ var(--dpk-shadow-xs);
573
+ }
574
+
575
+ .grill-label:focus-visible {
576
+ outline: none;
577
+ box-shadow: var(--dpk-focus);
578
+ }
579
+ `;class te extends Q{constructor(){super(),this.definition=X,this.#o=[],this.#a=!1,this.#l=null,this.#s=null,this.#i=null,this.#e="idle",this.#r=null,this.#n={kind:"idle"},this.#t=()=>{this.#a||(this.#a=!0,requestAnimationFrame(()=>{this.#a=!1;const e=this.renderRoot.querySelector(".grill-labels");e&&ee(e,this.#o)}))},this.tab="questions",this.folded=!1}static{this.styles=[Q.styles,Ee]}static{this.properties={tab:{state:!0},folded:{state:!0}}}#o;#a;#l;#s;#i;#e;#r;#n;connectedCallback(){super.connectedCallback(),document.addEventListener("scroll",this.#t,!0),window.addEventListener("resize",this.#t),this.addEventListener("dpk-diagram-view",this.#t)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("scroll",this.#t,!0),window.removeEventListener("resize",this.#t),this.removeEventListener("dpk-diagram-view",this.#t),this.#i?.disconnect(),this.#i=null,this.#d()}renderRegions(e){return this.#o=Z(this,e.state,e.navigation),{header:this.#h(e),main:this.#x(e,this.#o),sidebar:this.#f(e),sidebarHidden:this.folded}}updated(){super.updated(),this.#$(),this.#t(),this.#y();const e=this.#s;e!==null&&(this.#s=null,this.renderRoot.querySelector(`[data-free-text="${e}"]`)?.focus())}get integratedReview(){return!0}requestComment(e){this.tab="review",this.folded=!1,super.requestComment(e)}#p(e,i){this.tab="questions",this.folded=!1,this.#l=null,e.navigate({question:i})}#h(e){const i=Y(e.state),n=`${this.folded?"\u8CEA\u554F / Review \u3092\u3072\u3089\u304F":"\u8CEA\u554F / Review \u3092\u305F\u305F\u3080"}\uFF08${i.progress}\uFF09`;return l`
580
+ <button
581
+ type="button"
582
+ class="grill-toggle"
583
+ aria-expanded=${this.folded?"false":"true"}
584
+ aria-label=${n}
585
+ title=${n}
586
+ @click=${()=>this.folded=!this.folded}
587
+ >
588
+ <span class="grill-toggle-glyph" aria-hidden="true">?</span>
589
+ <span class="grill-toggle-badge" aria-hidden="true">${i.answered} / ${i.total}</span>
590
+ </button>
591
+ `}#f(e){const i=K(e.state,e.navigation);return l`
592
+ <div class="grill-panel">
593
+ <div class="grill-tabs" role="tablist" aria-label="質問 / Review">
594
+ ${["questions","review"].map(r=>l`
595
+ <button
596
+ type="button"
597
+ role="tab"
598
+ id=${`grill-tab-${r}`}
599
+ data-tab=${r}
600
+ aria-controls=${`grill-panel-${r}`}
601
+ aria-selected=${String(this.tab===r)}
602
+ tabindex=${this.tab===r?0:-1}
603
+ @click=${()=>this.tab=r}
604
+ @keydown=${n=>this.#k(n)}
605
+ >
606
+ ${r==="questions"?"\u8CEA\u554F":"Review"}<span class="grill-count"
607
+ >${r==="questions"?e.state.questions.length:e.actions.length}</span
608
+ >
609
+ </button>
610
+ `)}
611
+ </div>
612
+ <div
613
+ class="grill-tab-panel"
614
+ id="grill-panel-questions"
615
+ role="tabpanel"
616
+ aria-labelledby="grill-tab-questions"
617
+ ?hidden=${this.tab!=="questions"}
618
+ >
619
+ ${Se(i,{open:r=>this.#p(e,r),answer:(r,n)=>this.#v(r,n),next:r=>this.#c(r)})}
620
+ </div>
621
+ <div
622
+ class="grill-tab-panel"
623
+ id="grill-panel-review"
624
+ role="tabpanel"
625
+ aria-labelledby="grill-tab-review"
626
+ ?hidden=${this.tab!=="review"}
627
+ >
628
+ ${this.renderReviewPanel(e)}
629
+ </div>
630
+ ${this.#b(e.actions.length===0)}
631
+ </div>
632
+ `}#b(e){const i=this.#e==="copied"?"\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F":this.#e==="failed"?"\u30B3\u30D4\u30FC\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F":"\u56DE\u7B54\u30FBReview \u3092\u307E\u3068\u3081\u3066\u30B3\u30D4\u30FC";if(!this.canSendToClaude)return l`
633
+ <div class="grill-footer">
634
+ <button
635
+ class="dpk-btn dpk-btn--accent grill-copy"
636
+ type="button"
637
+ data-status=${this.#e}
638
+ ?disabled=${e}
639
+ @click=${()=>{this.#g()}}
640
+ >
641
+ ${i}
642
+ </button>
643
+ <span class="grill-sr" role="status">${this.#e==="idle"?"":i}</span>
644
+ </div>
645
+ `;const r=this.#n,n=r.kind==="pending"?"\u9001\u4FE1\u4E2D\u2026":r.kind==="sent"?"Claude \u306B\u9001\u308A\u307E\u3057\u305F":r.kind==="failed"?"\u9001\u308C\u307E\u305B\u3093\u3067\u3057\u305F":"\u56DE\u7B54\u30FBReview \u3092 Claude \u306B\u9001\u308B",o=r.kind==="failed"?ue(r.reason):null,s=o??(r.kind==="sent"?n:this.#e==="idle"?"":i);return l`
646
+ <div class="grill-footer">
647
+ <div class="grill-footer-actions">
648
+ <button
649
+ class="dpk-btn dpk-btn--accent grill-send"
650
+ type="button"
651
+ data-status=${r.kind}
652
+ ?disabled=${e||r.kind==="pending"}
653
+ @click=${()=>{this.#m()}}
654
+ >
655
+ ${n}
656
+ </button>
657
+ <button
658
+ class="dpk-btn dpk-btn--ghost grill-copy"
659
+ type="button"
660
+ data-status=${this.#e}
661
+ title="回答・Review をまとめてコピー"
662
+ ?disabled=${e}
663
+ @click=${()=>{this.#g()}}
664
+ >
665
+ ${this.#e==="copied"?"\u30B3\u30D4\u30FC\u6E08\u307F":"\u30B3\u30D4\u30FC"}
666
+ </button>
667
+ </div>
668
+ ${o===null?null:l`<p class="grill-footer-note">${o}</p>`}
669
+ <span class="grill-sr" role="status">${s}</span>
670
+ </div>
671
+ `}#k(e){["ArrowLeft","ArrowRight","Home","End"].includes(e.key)&&(e.preventDefault(),this.tab=e.key==="Home"?"questions":e.key==="End"||this.tab==="questions"?"review":"questions",this.renderRoot.querySelector(`[data-tab="${this.tab}"]`)?.focus())}#x(e,i){return l`
672
+ <div class="grill-stage">
673
+ <slot name="main"></slot>
674
+ <div class="grill-labels">
675
+ ${i.map(r=>l`
676
+ <button
677
+ type="button"
678
+ class="grill-label"
679
+ data-label=${r.index}
680
+ data-answered=${String(r.answered)}
681
+ data-visible="false"
682
+ aria-pressed=${r.open?"true":"false"}
683
+ aria-label=${`${r.ref} \xB7 ${r.title}`}
684
+ title=${`${r.ref} \xB7 ${r.title}`}
685
+ @click=${()=>this.#p(e,r.questionId)}
686
+ >
687
+ ${r.ref}
688
+ </button>
689
+ `)}
690
+ </div>
691
+ </div>
692
+ `}#v(e,i){if(this.dispatch(N(e,i)).ok){if(i.kind==="option"){this.#c(e);return}i.kind==="free"&&i.text===""&&(this.#s=e)}}#c(e){const i=me(this.derivation.state,e);i!==null&&this.navigate({question:i})}async#g(){const e=this.api.exportBrief(),i=await he(e);this.#d(),this.#e=i?"copied":"failed",this.#u()}async#m(){this.#d(),this.#n={kind:"pending"},this.requestUpdate();const e=await this.sendToClaude();this.#n=e.ok?{kind:"sent"}:{kind:"failed",reason:e.reason},e.ok?this.#u():this.requestUpdate()}#u(){this.requestUpdate(),this.#r=setTimeout(()=>{this.#r=null,this.#e="idle",this.#n={kind:"idle"},this.requestUpdate()},2400)}#d(){this.#r!==null&&clearTimeout(this.#r),this.#r=null,this.#e="idle",this.#n={kind:"idle"}}#w(){this.requestUpdate()}#$(){this.#i?.disconnect(),this.#i??=new MutationObserver(()=>{this.#w(),this.#t()}),this.#i.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[x]});for(const e of this.querySelectorAll("*"))e===this||!e.shadowRoot||this.#i.observe(e.shadowRoot,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[x]})}#t;#y(){const e=this.navigation.question??null;if(this.tab!=="questions"||this.folded||e===null||e===this.#l)return;this.#l=e;const i=this.renderRoot.querySelector(`[data-question="${e}"]`);i!==null&&typeof i.scrollIntoView=="function"&&i.scrollIntoView({block:"nearest"})}}const ie=()=>{customElements.get("dpk-template-grill")||customElements.define("dpk-template-grill",te)},Ae=Object.freeze(Object.defineProperty({__proto__:null,DpkTemplateGrill:te,GRILL_QUESTIONS_ATTRIBUTE:x,answerCounts:U,answerQuestion:N,answerText:w,applyGrillAction:F,collectLabelBindings:Z,defineGrillElement:ie,describeGrillAction:W,emptyGrillBase:B,findQuestion:c,grillActions:m,grillBaseSchema:O,grillCommentTargets:P,grillDefinition:X,grillHasTarget:J,grillTargetLabel:M,grillTitle:H,isAnswered:$,openQuestionId:D,optionLetter:G,parseGrillBase:_,positionLabels:ee,presentGrillHeader:Y,presentGrillPanel:K,questionLabel:E,questionRef:xe,resolveGrillNavigation:V,serializeGrillAction:j,withAnswer:y},Symbol.toStringTag,{value:"Module"}));export{ie as d,Ae as i};