dev-process-kit 0.3.0 → 0.3.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 (28) hide show
  1. package/dist/boards.js +1 -1
  2. package/dist/chunks/{shared-B_Tiv_T3.js → shared-2OsWmhrI.js} +1 -1
  3. package/dist/chunks/{shared-DNsl9DK1.js → shared-B57TT0rn.js} +1 -1
  4. package/dist/chunks/{shared-DYDJzB79.js → shared-B8ZhyjWv.js} +140 -137
  5. package/dist/chunks/{shared-BfByEotW.js → shared-BXywwm1a.js} +740 -366
  6. package/dist/chunks/shared-Be43xweD.js +43 -0
  7. package/dist/chunks/{shared-FMBoDqPg.js → shared-C0M3Ib7z.js} +1 -1
  8. package/dist/chunks/{shared-Ln6ei2B2.js → shared-C89fKgKG.js} +98 -94
  9. package/dist/chunks/{shared-Bs2YYFvO.js → shared-CF2_VP2x.js} +1 -1
  10. package/dist/chunks/{shared-DegJ_tfw.js → shared-CeCpFPDQ.js} +1 -1
  11. package/dist/chunks/{shared-BYbcHniE.js → shared-DIEJ9E2G.js} +1 -1
  12. package/dist/chunks/{shared-RvLH2Fqp.js → shared-DJtGS7Ct.js} +1 -1
  13. package/dist/chunks/{shared-epAjO2d1.js → shared-Dd8JfvQe.js} +1 -1
  14. package/dist/chunks/{shared-TtB-p2Zh.js → shared-Dn92ukYW.js} +1 -1
  15. package/dist/chunks/{shared-WtWbdwp_.js → shared-Dql0ZVdC.js} +1 -1
  16. package/dist/chunks/shared-LHG2FbnK.js +1 -0
  17. package/dist/chunks/{shared-BFraiskj.js → shared-egtdNQhY.js} +264 -281
  18. package/dist/chunks/{shared-DqlTHpRQ.js → shared-ubG0-RQ-.js} +1 -1
  19. package/dist/components.js +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/views/delegation-poker.js +1 -1
  22. package/dist/views/plain.js +1 -1
  23. package/dist/views/prototype.js +1 -1
  24. package/dist/views/slides.js +1 -1
  25. package/dist/views/task-board.js +1 -1
  26. package/dist/views/usm.js +1 -1
  27. package/package.json +1 -1
  28. package/dist/chunks/shared-DMksNmni.js +0 -1
@@ -1,29 +1,29 @@
1
- import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Yi,aD as Ie,au as Hi,bk as Je,bl as Bi,aa as N,ay as x,b9 as Wi,aB as qi,p as w,a9 as b,t as oe,aO as se,a8 as Fi,N as Gi,e as ji,a5 as Ki,h as Qe,K as _e,S as Y,R as Xi,P as k,as as l,ai as h,bm as Pe,bn as De,aH as Zi,y as Re,aP as et,l as tt,b0 as q,bo as Ji,z as it,bp as nt,G as Qi,I as en,b4 as tn,b5 as nn,ah as on,V as ot,ag as sn,bq as rn,aE as an,aF as ve,aG as st,C as dn,br as ln}from"./shared-DYDJzB79.js";import{c as pn,a as cn}from"./shared-TtB-p2Zh.js";import{m as un}from"./shared-B_Tiv_T3.js";import{h as rt,d as at,e as hn,f as vn,a as dt,b as lt,i as pt,p as fn,r as gn,k as mn,l as yn,m as wn,g as bn,c as kn,s as xn,n as ct,j as ut,t as En}from"./shared-WtWbdwp_.js";const Sn=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21"}]],$n=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]],Tn=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}],["path",{d:"M12 18h.01"}]],An=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18"}]],In=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}],["circle",{cx:"12",cy:"7",r:"4"}]],_n=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72"}],["path",{d:"m14 7 3 3"}],["path",{d:"M5 6v4"}],["path",{d:"M19 14v4"}],["path",{d:"M10 2v2"}],["path",{d:"M7 8H3"}],["path",{d:"M21 16h-4"}],["path",{d:"M11 3H9"}]],ht=["browser","native","mail","plain"],vt=["mobile","tablet","desktop","fluid"],J=t=>"screen"in t,Pn=D({from:g(u()),to:g(u()),cc:g(u()),subject:g(u()),date:g(u())}),ft={id:_,kind:M(he(ht),"browser"),viewport:M(he(vt),"fluid"),label:g(u()),url:g(u()),mail:g(Pn)},Ne=y(u(),Ae(t=>t.trim()!=="","a note needs some text")),gt=y(u(),Yi()),Dn=D({id:_,selector:y(u(),x(1)),text:g(u()),body:Ne,createdAt:g(gt)}),mt='a preview `mail` envelope needs `"kind": "mail"`',yt=y(D(ft),Ae(t=>t.mail===void 0||t.kind==="mail",mt)),wt=y(D({...ft,notes:g(N(Dn))}),Ae(t=>t.mail===void 0||t.kind==="mail",mt)),bt=D({screen:_,preview:g(_)}),Rn=Ie([bt,D({material:yt})]),Nn=Ie([bt,D({material:wt})]),On=D({id:_,name:y(u(),x(1)),description:g(u()),actor:g(y(u(),x(1))),situation:g(y(u(),x(1))),panes:M(N(Nn),[])}),Cn=D({id:_,name:y(u(),x(1)),description:g(u()),actor:g(y(u(),x(1))),steps:M(N(On),[])}),Mn=D({id:_,name:y(u(),x(1)),description:g(u()),actor:g(y(u(),x(1))),stories:M(N(Cn),[])}),kt=y(u(),x(1)),Ln=D({id:_,label:y(u(),x(1)),description:g(u()),fill:g(Wi(kt,Ie([u(),qi()]))),click:g(N(kt))}),Un=D({id:_,title:y(u(),x(1)),description:g(u()),previews:M(N(wt),[]),actions:M(N(Ln),[])}),Vn=D({id:_,name:y(u(),x(1)),description:g(u()),actor:g(y(u(),x(1))),screens:M(N(Un),[])}),xt=D({title:g(u()),baseUrl:g(u()),apps:M(N(Vn),[]),activities:M(N(Mn),[])}),Et=t=>t.flatMap(e=>J(e)?[]:[e.material]),zn=t=>{const e=new Set,i=new Set,n=a=>{for(const d of a){if(e.has(d.id))return`duplicate preview id "${d.id}": preview ids are global, they name a light DOM slot`;e.add(d.id);for(const p of d.notes??[]){if(i.has(p.id))return`duplicate note id "${p.id}": note ids are global`;i.add(p.id)}}return null},o=new Set,s=new Set;for(const a of t.apps){if(o.has(a.id))return`duplicate app id "${a.id}"`;o.add(a.id);for(const d of a.screens){if(s.has(d.id))return`duplicate screen id "${d.id}": screen ids are global`;s.add(d.id);const p=n(d.previews);if(p!==null)return p;const c=new Set;for(const v of d.actions){if(c.has(v.id))return`duplicate action id "${v.id}" on screen "${d.id}"`;c.add(v.id)}}}const r=new Set;for(const a of t.activities){if(r.has(a.id))return`duplicate activity id "${a.id}"`;r.add(a.id);const d=new Set;for(const p of a.stories){if(d.has(p.id))return`duplicate story id "${p.id}" in activity "${a.id}"`;d.add(p.id);const c=new Set;for(const v of p.steps){if(c.has(v.id))return`duplicate step id "${v.id}" in story "${p.id}"`;c.add(v.id);const f=n(Et(v.panes));if(f!==null)return f}}}return null},St=(t,e)=>{const i=new Map;for(const n of e.panes){if(!J(n))continue;const o=t(n.screen);if(o===void 0)return`unknown screen "${n.screen}" on step "${e.id}": declare it under \`apps[].screens\``;if(n.preview!==void 0&&!o.includes(n.preview))return`preview "${n.preview}" on step "${e.id}" is not a rendition of screen "${n.screen}"`;const s=i.get(n.screen)??[];if(s.length>0&&(n.preview===void 0||s.includes(n.preview)||s.includes(void 0)))return`screen "${n.screen}" is shown twice on step "${e.id}": give each pane a different \`preview\``;i.set(n.screen,[...s,n.preview])}return null},Yn=t=>{const e=new Map(t.apps.flatMap(i=>i.screens.map(n=>[n.id,n.previews.map(o=>o.id)])));for(const i of t.activities.flatMap(n=>n.stories.flatMap(o=>o.steps))){const n=St(o=>e.get(o),i);if(n!==null)return n}return null},Hn=(t,e)=>St(i=>L(t,i)?.screen.previews.map(n=>n.id),e),O="ui",re=t=>{const e=t.text?.replaceAll('"',"'");return`${t.previewId}/${t.selector}${e===void 0?"":` "${e}"`}`},Q=t=>{const e=t.indexOf("/");if(e<=0)return;const i=t.slice(0,e);if(!Bi(_,i))return;const n=t.slice(e+1),o=/ "([^"]*)"$/.exec(n),s=(o?n.slice(0,o.index):n).trim();if(s!=="")return o?.[1]===void 0?{previewId:i,selector:s}:{previewId:i,selector:s,text:o[1]}},$t=t=>{const e=Hi(xt,t),i=zn(e)??Yn(e);if(i!==null)throw new Error(i);return e},Tt=()=>({apps:[],activities:[]}),H=t=>t.apps.flatMap(e=>e.screens.map(i=>({app:e,screen:i}))),L=(t,e)=>{if(e!==void 0)return H(t).find(i=>i.screen.id===e)},fe=(t,e)=>e.panes.flatMap(i=>{const n=J(i)?L(t,i.screen):void 0;return n?[n]:[]}),F=t=>Et(t.panes),Bn=(t,e)=>t.panes.some(i=>J(i)&&i.screen===e),U=(t,e)=>{if(e!==void 0)return t.activities.find(i=>i.id===e)},C=(t,e)=>`${t}.${e}`,$=(t,e)=>{if(e===void 0)return;const i=Je(e,2);if(i){const[o,s]=i;if(o===void 0||s===void 0)return;const r=t.activities.find(d=>d.id===o),a=r?.stories.find(d=>d.id===s);return r&&a?{activity:r,story:a}:void 0}if(e.includes("."))return;const n=t.activities.flatMap(o=>o.stories.filter(s=>s.id===e).map(s=>({activity:o,story:s})));return n.length===1?n[0]:void 0},At=t=>{const e=t.lastIndexOf(".");return e>=0?t.slice(e+1):t},ae=t=>`${t.activity.id}.${t.story.id}.${t.step.id}`,ge=(t,e,i)=>`${t.id}.${e.id}.${i.id}`,S=(t,e)=>{if(e===void 0)return;const i=Je(e,3);if(i){const[o,s,r]=i;if(o===void 0||s===void 0||r===void 0)return;const a=t.activities.find(v=>v.id===o),d=a?.stories.find(v=>v.id===s),p=d?d.steps.findIndex(v=>v.id===r):-1,c=d&&p>=0?d.steps[p]:void 0;return a&&d&&c?{activity:a,story:d,step:c,stepIndex:p}:void 0}if(e.includes("."))return;const n=B(t).filter(o=>o.step.id===e);return n.length===1?n[0]:void 0},E=(t,e)=>{if(e!==void 0){for(const i of H(t)){const n=i.screen.previews.find(o=>o.id===e);if(n)return{owner:{kind:"screen",...i},preview:n}}for(const i of B(t)){const n=F(i.step).find(o=>o.id===e);if(n)return{owner:{kind:"step",...i},preview:n}}}},It=t=>[...H(t).flatMap(e=>e.screen.previews),...B(t).flatMap(e=>F(e.step))],_t=t=>It(t).flatMap(e=>(e.notes??[]).map(i=>i.id)),B=t=>t.activities.flatMap(e=>e.stories.flatMap(i=>i.steps.map((n,o)=>({activity:e,story:i,step:n,stepIndex:o})))),Pt=t=>B(t).map(e=>e.step.id),Oe=y(u(),x(1)),Dt=t=>{const e=Fi(b({noteId:Oe}),t.payload);return`${t.type}|${e.success?e.output.noteId:JSON.stringify(t.payload)}`},m={SET_ACTIVITY_NAME:w("SET_ACTIVITY_NAME","activity",b({name:y(u(),x(1))})),SET_ACTIVITY_DESCRIPTION:w("SET_ACTIVITY_DESCRIPTION","activity",b({description:u()})),SET_STORY_NAME:w("SET_STORY_NAME","story",b({name:y(u(),x(1))})),SET_STORY_DESCRIPTION:w("SET_STORY_DESCRIPTION","story",b({description:u()})),SET_STEP_NAME:w("SET_STEP_NAME","step",b({name:y(u(),x(1))})),SET_STEP_DESCRIPTION:w("SET_STEP_DESCRIPTION","step",b({description:u()})),SET_PREVIEW_KIND:w("SET_PREVIEW_KIND","preview",b({kind:he(ht)})),SET_PREVIEW_VIEWPORT:w("SET_PREVIEW_VIEWPORT","preview",b({viewport:he(vt)})),SET_PREVIEW_LABEL:w("SET_PREVIEW_LABEL","preview",b({label:u()})),REORDER_ACTIVITY:w("REORDER_ACTIVITY","activity",b({after:se(u())}),{mode:"sequence"}),REORDER_STORY:w("REORDER_STORY","story",b({after:se(u())}),{mode:"sequence"}),REORDER_STEP:w("REORDER_STEP","step",b({after:se(u())}),{mode:"sequence"}),MOVE_STORY:w("MOVE_STORY","story",b({toActivity:y(u(),x(1)),after:se(u())}),{mode:"sequence"}),MOVE_STEP:w("MOVE_STEP","step",b({toStory:y(u(),x(1)),after:se(u())}),{mode:"sequence"}),ADD_ACTIVITY:w("ADD_ACTIVITY","page",b({id:_,name:y(u(),x(1)),description:g(u())}),{dedupeKey:oe}),ADD_STORY:w("ADD_STORY","activity",b({id:_,name:y(u(),x(1)),description:g(u())}),{dedupeKey:oe}),ADD_STEP:w("ADD_STEP","story",b({id:_,name:y(u(),x(1)),description:g(u()),panes:g(N(Rn))}),{dedupeKey:oe}),ADD_PREVIEW:w("ADD_PREVIEW","step",yt,{dedupeKey:oe}),DELETE_ACTIVITY:w("DELETE_ACTIVITY","activity",b({})),DELETE_STORY:w("DELETE_STORY","story",b({})),DELETE_STEP:w("DELETE_STEP","step",b({})),DELETE_PREVIEW:w("DELETE_PREVIEW","preview",b({})),ADD_UI_NOTE:w("ADD_UI_NOTE",O,b({id:_,body:Ne,createdAt:g(gt)}),{dedupeKey:oe}),SET_UI_NOTE_BODY:w("SET_UI_NOTE_BODY",O,b({noteId:Oe,body:Ne}),{dedupeKey:Dt}),DELETE_UI_NOTE:w("DELETE_UI_NOTE",O,b({noteId:Oe}),{dedupeKey:Dt})},W={setActivityName:(t,e)=>({type:"SET_ACTIVITY_NAME",target:{type:"activity",id:t},payload:{name:e}}),setActivityDescription:(t,e)=>({type:"SET_ACTIVITY_DESCRIPTION",target:{type:"activity",id:t},payload:{description:e}}),setStoryName:(t,e)=>({type:"SET_STORY_NAME",target:{type:"story",id:t},payload:{name:e}}),setStoryDescription:(t,e)=>({type:"SET_STORY_DESCRIPTION",target:{type:"story",id:t},payload:{description:e}}),setStepName:(t,e)=>({type:"SET_STEP_NAME",target:{type:"step",id:t},payload:{name:e}}),setStepDescription:(t,e)=>({type:"SET_STEP_DESCRIPTION",target:{type:"step",id:t},payload:{description:e}}),setPreviewViewport:(t,e)=>({type:"SET_PREVIEW_VIEWPORT",target:{type:"preview",id:t},payload:{viewport:e}}),setPreviewKind:(t,e)=>({type:"SET_PREVIEW_KIND",target:{type:"preview",id:t},payload:{kind:e}}),setPreviewLabel:(t,e)=>({type:"SET_PREVIEW_LABEL",target:{type:"preview",id:t},payload:{label:e}}),reorderActivity:(t,e)=>({type:"REORDER_ACTIVITY",target:{type:"activity",id:t},payload:{after:e}}),reorderStory:(t,e)=>({type:"REORDER_STORY",target:{type:"story",id:t},payload:{after:e}}),reorderStep:(t,e)=>({type:"REORDER_STEP",target:{type:"step",id:t},payload:{after:e}}),moveStep:(t,e,i)=>({type:"MOVE_STEP",target:{type:"step",id:t},payload:{toStory:e,after:i}}),moveStory:(t,e,i)=>({type:"MOVE_STORY",target:{type:"story",id:t},payload:{toActivity:e,after:i}}),addActivity:(t,e,i)=>({type:"ADD_ACTIVITY",target:{type:"page",id:"prototype"},payload:{id:t,name:e,...i===void 0?{}:{description:i}}}),addStory:(t,e,i,n)=>({type:"ADD_STORY",target:{type:"activity",id:t},payload:{id:e,name:i,...n===void 0?{}:{description:n}}}),addStep:(t,e,i,n)=>({type:"ADD_STEP",target:{type:"story",id:t},payload:{id:e,name:i,...n===void 0?{}:{panes:n}}}),addPreview:(t,e)=>({type:"ADD_PREVIEW",target:{type:"step",id:t},payload:{...e}}),deleteActivity:t=>({type:"DELETE_ACTIVITY",target:{type:"activity",id:t},payload:{}}),deleteStory:t=>({type:"DELETE_STORY",target:{type:"story",id:t},payload:{}}),deleteStep:t=>({type:"DELETE_STEP",target:{type:"step",id:t},payload:{}}),deletePreview:t=>({type:"DELETE_PREVIEW",target:{type:"preview",id:t},payload:{}}),addUiNote:(t,e,i,n)=>({type:"ADD_UI_NOTE",target:{type:O,id:re(t)},payload:{id:e,body:i,...n===void 0?{}:{createdAt:n}}}),setUiNoteBody:(t,e,i)=>({type:"SET_UI_NOTE_BODY",target:{type:O,id:re(t)},payload:{noteId:e,body:i}}),deleteUiNote:(t,e)=>({type:"DELETE_UI_NOTE",target:{type:O,id:re(t)},payload:{noteId:e}})},Rt=(t,e)=>{const i=Gi(m,e);if(i===null)return null;const n=i.target.id;switch(i.type){case"SET_ACTIVITY_NAME":return G(t,n,o=>({...o,name:i.payload.name}));case"SET_ACTIVITY_DESCRIPTION":return G(t,n,o=>({...o,description:i.payload.description}));case"SET_STORY_NAME":return j(t,n,o=>({...o,name:i.payload.name}));case"SET_STORY_DESCRIPTION":return j(t,n,o=>({...o,description:i.payload.description}));case"SET_STEP_NAME":return me(t,n,o=>({...o,name:i.payload.name}));case"SET_STEP_DESCRIPTION":return me(t,n,o=>({...o,description:i.payload.description}));case"SET_PREVIEW_KIND":return ee(t,n,o=>({...o,kind:i.payload.kind}));case"SET_PREVIEW_VIEWPORT":return ee(t,n,o=>({...o,viewport:i.payload.viewport}));case"SET_PREVIEW_LABEL":return ee(t,n,o=>({...o,label:i.payload.label}));case"REORDER_ACTIVITY":{const{after:o}=i.payload,s=de(t.activities,n,o);return s===null?null:{...t,activities:s}}case"REORDER_STORY":{const{after:o}=i.payload,s=$(t,n);if(!s)return null;const r=o===null?null:$(t,o);if(o!==null&&(!r||r.activity!==s.activity))return null;const a=de(s.activity.stories,s.story.id,r?.story.id??null);return a===null?null:G(t,s.activity.id,d=>({...d,stories:a}))}case"REORDER_STEP":{const{after:o}=i.payload,s=S(t,n);if(!s)return null;const r=o===null?null:S(t,o);if(o!==null&&(!r||r.story!==s.story))return null;const a=de(s.story.steps,s.step.id,r?.step.id??null);return a===null?null:j(t,C(s.activity.id,s.story.id),d=>({...d,steps:a}))}case"MOVE_STORY":{const{toActivity:o,after:s}=i.payload,r=$(t,n);if(!r)return null;const a=t.activities.find(v=>v.id===o);if(!a)return null;const d=s===null?null:$(t,s);if(s!==null&&(!d||d.activity!==a))return null;const p=d?.story.id??null;if(r.activity.id===o){const v=de(r.activity.stories,r.story.id,p);return v===null?null:G(t,o,f=>({...f,stories:v}))}if(a.stories.some(v=>v.id===r.story.id))return null;const c=Me(a.stories,r.story,p);return Ce(t,v=>v.id===r.activity.id?{...v,stories:v.stories.filter(f=>f.id!==At(n))}:v.id===o?{...v,stories:c}:v)}case"MOVE_STEP":{const{toStory:o,after:s}=i.payload,r=S(t,n);if(!r)return null;const a=$(t,o);if(!a)return null;const d=s===null?null:S(t,s);if(s!==null&&(!d||d.story!==a.story))return null;const p=d?.step.id??null;if(r.story===a.story){const v=de(r.story.steps,r.step.id,p);return v===null?null:j(t,o,f=>({...f,steps:v}))}if(a.story.steps.some(v=>v.id===r.step.id))return null;const c=Me(a.story.steps,r.step,p);return Ce(t,v=>({...v,stories:v.stories.map(f=>f===r.story?{...f,steps:f.steps.filter(I=>I.id!==At(n))}:f===a.story?{...f,steps:c}:f)}))}case"ADD_ACTIVITY":{const o=i.payload;if(t.activities.some(r=>r.id===o.id))return t;const s={id:o.id,name:o.name,...o.description===void 0?{}:{description:o.description},stories:[]};return{...t,activities:[...t.activities,s]}}case"ADD_STORY":{const o=i.payload,s=t.activities.find(a=>a.id===n);if(!s)return null;if(s.stories.some(a=>a.id===o.id))return t;const r={id:o.id,name:o.name,...o.description===void 0?{}:{description:o.description},steps:[]};return G(t,n,a=>({...a,stories:[...a.stories,r]}))}case"ADD_STEP":{const o=i.payload,s=$(t,n)?.story;if(!s)return null;if(s.steps.some(d=>d.id===o.id))return t;const r=o.panes??[],a={id:o.id,name:o.name,...o.description===void 0?{}:{description:o.description},panes:r};return Wn(t,a)?j(t,n,d=>({...d,steps:[...d.steps,a]})):null}case"ADD_PREVIEW":{const o=i.payload,s=S(t,n)?.step;return s?F(s).some(r=>r.id===o.id)?t:E(t,o.id)?null:me(t,n,r=>({...r,panes:[...r.panes,{material:o}]})):null}case"DELETE_ACTIVITY":{const o=n;return t.activities.some(s=>s.id===o)?{...t,activities:t.activities.filter(s=>s.id!==o)}:null}case"DELETE_STORY":{const o=$(t,n);return o?G(t,o.activity.id,s=>({...s,stories:s.stories.filter(r=>r.id!==o.story.id)})):null}case"DELETE_STEP":{const o=S(t,n);return o?j(t,C(o.activity.id,o.story.id),s=>({...s,steps:s.steps.filter(r=>r.id!==o.step.id)})):null}case"DELETE_PREVIEW":{const o=E(t,n);return o?Nt(t,o.owner,s=>s.filter(r=>r.id!==o.preview.id)):null}case"ADD_UI_NOTE":{const{id:o,body:s,createdAt:r}=i.payload,a=Q(n),d=a===void 0?void 0:E(t,a.previewId);if(a===void 0||d===void 0)return null;if(d.preview.notes?.some(c=>c.id===o&&c.selector===a.selector))return t;if(_t(t).includes(o))return null;const p={id:o,selector:a.selector,...a.text===void 0?{}:{text:a.text},body:s,...r===void 0?{}:{createdAt:r}};return ee(t,d.preview.id,c=>({...c,notes:[...c.notes??[],p]}))}case"SET_UI_NOTE_BODY":{const{noteId:o,body:s}=i.payload,r=Q(n),a=r===void 0?void 0:E(t,r.previewId);return a?.preview.notes?.some(d=>d.id===o)?ee(t,a.preview.id,d=>({...d,notes:(d.notes??[]).map(p=>p.id===o?{...p,body:s}:p)})):null}case"DELETE_UI_NOTE":{const{noteId:o}=i.payload,s=Q(n),r=s===void 0?void 0:E(t,s.previewId);return r?.preview.notes?.some(a=>a.id===o)?ee(t,r.preview.id,a=>{const d=(a.notes??[]).filter(v=>v.id!==o),{notes:p,...c}=a;return d.length===0?c:{...c,notes:d}}):null}default:return ji(i)}},Ce=(t,e)=>({...t,activities:t.activities.map(e)}),G=(t,e,i)=>{const n=e;return t.activities.some(o=>o.id===n)?Ce(t,o=>o.id===n?i(o):o):null},j=(t,e,i)=>{const n=$(t,e);if(!n)return null;const o=n.story.id;return G(t,n.activity.id,s=>({...s,stories:s.stories.map(r=>r.id===o?i(r):r)}))},me=(t,e,i)=>{const n=S(t,e);if(!n)return null;const o=n.step.id;return j(t,C(n.activity.id,n.story.id),s=>({...s,steps:s.steps.map(r=>r.id===o?i(r):r)}))},ee=(t,e,i)=>{const n=E(t,e);if(!n)return null;const o=n.preview.id;return Nt(t,n.owner,s=>s.map(r=>r.id===o?i(r):r))},Wn=(t,e)=>{const i=F(e).map(n=>n.id);return Hn(t,e)===null&&new Set(i).size===i.length&&!i.some(n=>E(t,n))},Nt=(t,e,i)=>{if(e.kind==="step")return me(t,ae(e),o=>{const s=new Map(i([...F(o)]).map(r=>[r.id,r]));return{...o,panes:o.panes.flatMap(r=>{if(J(r))return[r];const a=s.get(r.material.id);return a?[{material:a}]:[]})}});const n=e.screen.id;return{...t,apps:t.apps.map(o=>o.id===e.app.id?{...o,screens:o.screens.map(s=>s.id===n?{...s,previews:i(s.previews)}:s)}:o)}},de=(t,e,i)=>{const n=t.findIndex(r=>r.id===e);if(n<0||i!==null&&!t.some(r=>r.id===i))return null;if(e===i)return[...t];const o=t[n];if(o===void 0)return null;const s=t.filter(r=>r.id!==e);return Me(s,o,i)},Me=(t,e,i)=>{const n=[...t],o=i===null?-1:n.findIndex(s=>s.id===i);return n.splice(o+1,0,e),n},Ot={"iphone-se":"iPhone SE","iphone-16":"iPhone 16","iphone-16-pro-max":"iPhone 16 Pro Max","pixel-7":"Pixel 7","galaxy-s24":"Galaxy S24","ipad-mini":"iPad mini","ipad-air-11":'iPad Air 11"',"ipad-pro-11":'iPad Pro 11"',"ipad-pro-13":'iPad Pro 13"'},qn={"laptop-13":'13" laptop',"laptop-15":'15" laptop',"full-hd":"Full HD","monitor-27":'27" monitor',ultrawide:"Ultrawide"},Fn={"laptop-13":"13 \u30A4\u30F3\u30C1 \u30CE\u30FC\u30C8","laptop-15":"15 \u30A4\u30F3\u30C1 \u30CE\u30FC\u30C8","full-hd":"\u30D5\u30EB HD","monitor-27":"27 \u30A4\u30F3\u30C1 \u30E2\u30CB\u30BF\u30FC",ultrawide:"\u30A6\u30EB\u30C8\u30E9\u30EF\u30A4\u30C9"},le=Ki({en:{renameActivity:"Rename Activity",updateActivityDescription:"Update Activity description",renameStory:"Rename UserStory",updateStoryDescription:"Update UserStory description",renameStep:"Rename Step",updateStepDescription:"Update Step description",changePreviewKind:"Change Preview kind",changePreviewViewport:"Change Preview viewport",changePreviewLabel:"Change Preview label",moveStory:"Move UserStory",moveStep:"Move Step",deleteTitle:"Delete",reorderTitle:t=>`Reorder ${t}`,addTitle:t=>`Add ${t}`,toFront:"\u2192 To the front",afterName:t=>`\u2192 Right after "${t}"`,unknownTarget:"(unknown target)",activityGroup:"Activity",storyGroup:"UserStory",stepGroup:"Step",screenGroup:"Screen",openInApp:"Open this screen in the app view",previewGroup:"Preview",pageGroup:"Page",uiGroup:"UI",targetLabel:(t,e)=>`${t} \xB7 ${e}`,targetMissing:(t,e)=>`${t} \xB7 ${e} (missing)`,noActivityBefore:"There are no Activities yet. Add ",noActivityAfter:" to the base JSON, or ask the agent.",deleteStepAria:"Delete step",addStepButton:"+ Step",stepNameLabel:"Step name",descriptionLabel:"Description",descriptionPlaceholder:"What happens in this Step (click to edit)",newStepName:"New step",viewLabel:"View",viewScenario:"Scenario",viewApp:"App",viewScenarioHint:"Follow one user story step by step",viewAppHint:"Use the UI as one app, whatever the scenario",appScreens:"Screens",appScreensHint:"Pick a screen to start from, then move around through the UI itself.",appSelectLabel:"App",appOutsideBrowser:"Outside the browser",noStepBefore:"There are no Steps yet. A Prototype has the meaning structure ",noStepAfter:" \u2014 one Step is one moment of the story: the screen the user is on and what they have at hand. Add a Step to the base JSON, and its screen will appear here.",noScreens:"This product has no screens yet. Declare its apps and their screens under apps[].screens in the base JSON, and they will appear here.",noPreviewMetadata:"No preview metadata \u2014 ask the agent to add it.",storyWithoutSteps:"This UserStory has no Steps yet, so there is no screen to show. Add one with + Step, or ask the agent to prototype it.",pageActor:t=>`Used by ${t}`,maximize:"Maximize",restore:"Restore size",maximizeHint:"Show the preview alone across the tab \xB7 Esc to restore",situation:"Situation",uiComment:"Comment on UI",uiCommentHint:"Click any part of the preview to comment on it \xB7 Esc to finish",commentOnElement:"Comment on element",uiCommentPin:(t,e)=>`Comment ${t}: ${e}`,uiCommentAs:"What it is",uiCommentFeedback:"Review comment",uiCommentFeedbackHint:"Sent to the Agent as a message. Gone once it is reflected.",uiCommentNote:"Note",uiCommentNoteHint:"Kept on the element as part of the prototype, shown as a badge in the scenario view.",uiNoteSubmit:"Keep",uiNotes:t=>t===1?"1 note":`${t} notes`,uiNotesOn:t=>`Notes on ${t}`,uiNoteDate:t=>Ct("en-US",t),deleteUiNoteAria:"Delete the note",editUiNoteAria:"Edit the note",editUiNoteLabel:"Note",editUiNoteHint:"Ctrl/Cmd + Enter to save, Esc to close",saveUiNote:"Save",cancelUiNote:"Cancel",closeUiNotes:"Close",addUiNote:"Add a note",editUiNote:"Edit a note",deleteUiNote:"Delete a note",mailFrom:"From",mailTo:"To",mailCc:"Cc",mailDate:"Date",demo:"Demo",demoHint:"Use the app in a browser across the tab, with nothing else on screen \xB7 Esc to finish",exitDemo:"Exit demo",browserBack:"Back",browserForward:"Forward",browserReload:"Reload",browserAddress:"Address",browserTabs:"Tabs",newTab:"New tab",closeTab:"Close tab",browserProfile:t=>`Profile: ${t}`,browserGuest:"Guest",newTabShortcuts:"Pages of this app",unreachableTitle:"This site can\u2019t be reached",unreachableBody:"No page of the prototype has this address.",device:"Device",deviceHint:"The window the app runs in: a page taller than it scrolls inside, as on the device",deviceName:t=>Ot[t]??qn[t]??t,deviceZoom:t=>`Shown at ${t}% to fit`,actions:"Actions",actionsHint:"Make the screen do something in one go, e.g. fill its form with sample data"},ja:{renameActivity:"Activity \u540D\u3092\u5909\u66F4",updateActivityDescription:"Activity \u306E\u8AAC\u660E\u3092\u66F4\u65B0",renameStory:"UserStory \u540D\u3092\u5909\u66F4",updateStoryDescription:"UserStory \u306E\u8AAC\u660E\u3092\u66F4\u65B0",renameStep:"Step \u540D\u3092\u5909\u66F4",updateStepDescription:"Step \u306E\u8AAC\u660E\u3092\u66F4\u65B0",changePreviewKind:"Preview \u306E\u7A2E\u5225\u3092\u5909\u66F4",changePreviewViewport:"Preview \u306E\u30D3\u30E5\u30FC\u30DD\u30FC\u30C8\u3092\u5909\u66F4",changePreviewLabel:"Preview \u306E\u30E9\u30D9\u30EB\u3092\u5909\u66F4",moveStory:"UserStory \u3092\u79FB\u52D5",moveStep:"Step \u3092\u79FB\u52D5",deleteTitle:"\u524A\u9664",reorderTitle:t=>`${t} \u306E\u9806\u5E8F\u3092\u5909\u66F4`,addTitle:t=>`${t} \u3092\u8FFD\u52A0`,toFront:"\u2192 \u5148\u982D\u3078",afterName:t=>`\u2192 "${t}" \u306E\u76F4\u5F8C\u3078`,unknownTarget:"(unknown target)",activityGroup:"Activity",storyGroup:"UserStory",stepGroup:"Step",screenGroup:"\u753B\u9762",openInApp:"\u3053\u306E\u753B\u9762\u3092\u30A2\u30D7\u30EA\u30D3\u30E5\u30FC\u3067\u958B\u304F",previewGroup:"Preview",pageGroup:"Page",uiGroup:"UI",targetLabel:(t,e)=>`${t} \xB7 ${e}`,targetMissing:(t,e)=>`${t} \xB7 ${e} (missing)`,noActivityBefore:"Activity \u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002base JSON \u306E ",noActivityAfter:" \u3092\u8FFD\u52A0\u3059\u308B\u304B\u3001Agent \u306B\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",deleteStepAria:"\u30B9\u30C6\u30C3\u30D7\u3092\u524A\u9664",addStepButton:"+ Step",stepNameLabel:"Step \u540D",descriptionLabel:"\u8AAC\u660E",descriptionPlaceholder:"\u3053\u306E Step \u3067\u4F55\u304C\u8D77\u304D\u308B\u304B\uFF08\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u7DE8\u96C6\uFF09",newStepName:"\u65B0\u3057\u3044\u30B9\u30C6\u30C3\u30D7",viewLabel:"\u8868\u793A",viewScenario:"\u30B7\u30CA\u30EA\u30AA",viewApp:"\u30A2\u30D7\u30EA",viewScenarioHint:"\u30E6\u30FC\u30B6\u30FC\u30B9\u30C8\u30FC\u30EA\u30FC\u306B\u6CBF\u3063\u3066 Step \u3092\u9806\u306B\u305F\u3069\u308B",viewAppHint:"\u30B7\u30CA\u30EA\u30AA\u306B\u95A2\u4FC2\u306A\u304F\u3001UI \u3092 1 \u3064\u306E\u30A2\u30D7\u30EA\u3068\u3057\u3066\u89E6\u308B",appScreens:"\u753B\u9762",appScreensHint:"\u8D77\u70B9\u306B\u3059\u308B\u753B\u9762\u3092\u9078\u3073\u3001\u3042\u3068\u306F UI \u306E\u30EA\u30F3\u30AF\u3067\u79FB\u52D5\u3057\u307E\u3059\u3002",appSelectLabel:"\u30A2\u30D7\u30EA",appOutsideBrowser:"\u30D6\u30E9\u30A6\u30B6\u4EE5\u5916",noStepBefore:"Step \u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002Prototype \u306F ",noStepAfter:" \u306E\u610F\u5473\u69CB\u9020\u3092\u6301\u3061\u30011 Step = \u30B7\u30CA\u30EA\u30AA\u306E 1 \u5834\u9762\uFF08\u30E6\u30FC\u30B6\u30FC\u304C\u3044\u308B\u753B\u9762\u3068\u3001\u624B\u5143\u306B\u3042\u308B\u3082\u306E\uFF09\u3067\u3059\u3002base JSON \u306B Step \u3092\u8FFD\u52A0\u3059\u308B\u3068\u3001\u3053\u3053\u306B\u305D\u306E\u753B\u9762\u304C\u73FE\u308C\u307E\u3059\u3002",noScreens:"\u3053\u306E\u30D7\u30ED\u30C0\u30AF\u30C8\u306B\u306F\u307E\u3060\u753B\u9762\u304C\u3042\u308A\u307E\u305B\u3093\u3002base JSON \u306E apps[].screens \u306B\u30A2\u30D7\u30EA\u3068\u753B\u9762\u3092\u5BA3\u8A00\u3059\u308B\u3068\u3001\u3053\u3053\u306B\u73FE\u308C\u307E\u3059\u3002",noPreviewMetadata:"preview metadata \u304C\u3042\u308A\u307E\u305B\u3093 \u2014 \u8FFD\u52A0\u306F Agent \u306B\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044",storyWithoutSteps:"\u3053\u306E UserStory \u306B\u306F\u307E\u3060 Step \u304C\u306A\u304F\u3001\u898B\u305B\u308B\u753B\u9762\u304C\u3042\u308A\u307E\u305B\u3093\u3002+ Step \u3067\u8FFD\u52A0\u3059\u308B\u304B\u3001Agent \u306B\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u3092\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",pageActor:t=>`\u5229\u7528\u8005: ${t}`,maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",maximizeHint:"\u30D7\u30EC\u30D3\u30E5\u30FC\u3060\u3051\u3092\u30BF\u30D6\u3044\u3063\u3071\u3044\u306B\u8868\u793A \xB7 Esc \u3067\u623B\u308B",situation:"\u72B6\u6CC1",uiComment:"UI \u306B\u30B3\u30E1\u30F3\u30C8",uiCommentHint:"\u30D7\u30EC\u30D3\u30E5\u30FC\u306E\u8981\u7D20\u3092\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u30B3\u30E1\u30F3\u30C8 \xB7 Esc \u3067\u7D42\u4E86",commentOnElement:"\u8981\u7D20\u306B\u30B3\u30E1\u30F3\u30C8",uiCommentPin:(t,e)=>`\u30B3\u30E1\u30F3\u30C8 ${t}: ${e}`,uiCommentAs:"\u30B3\u30E1\u30F3\u30C8\u306E\u7A2E\u985E",uiCommentFeedback:"\u30EC\u30D3\u30E5\u30FC\u30B3\u30E1\u30F3\u30C8",uiCommentFeedbackHint:"Agent \u3078\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u3057\u3066\u9001\u4FE1\u3055\u308C\u307E\u3059\u3002\u53CD\u6620\u3055\u308C\u308B\u3068\u6D88\u3048\u307E\u3059\u3002",uiCommentNote:"\u30E1\u30E2",uiCommentNoteHint:"\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u306E\u4E00\u90E8\u3068\u3057\u3066\u8981\u7D20\u306B\u6B8B\u308A\u3001\u30B7\u30CA\u30EA\u30AA\u30D3\u30E5\u30FC\u3067\u30D0\u30C3\u30B8\u3068\u3057\u3066\u8868\u793A\u3055\u308C\u307E\u3059\u3002",uiNoteSubmit:"\u6B8B\u3059",uiNotes:t=>`\u30E1\u30E2 ${t} \u4EF6`,uiNotesOn:t=>`${t} \u306E\u30E1\u30E2`,uiNoteDate:t=>Ct("ja-JP",t),deleteUiNoteAria:"\u30E1\u30E2\u3092\u524A\u9664",editUiNoteAria:"\u30E1\u30E2\u3092\u7DE8\u96C6",editUiNoteLabel:"\u30E1\u30E2",editUiNoteHint:"Ctrl/Cmd + Enter \u3067\u4FDD\u5B58\u3001Esc \u3067\u9589\u3058\u308B",saveUiNote:"\u4FDD\u5B58",cancelUiNote:"\u30AD\u30E3\u30F3\u30BB\u30EB",closeUiNotes:"\u9589\u3058\u308B",addUiNote:"\u30E1\u30E2\u3092\u8FFD\u52A0",editUiNote:"\u30E1\u30E2\u3092\u7DE8\u96C6",deleteUiNote:"\u30E1\u30E2\u3092\u524A\u9664",mailFrom:"\u5DEE\u51FA\u4EBA",mailTo:"\u5B9B\u5148",mailCc:"Cc",mailDate:"\u65E5\u6642",demo:"\u30C7\u30E2",demoHint:"\u307B\u304B\u306B\u4F55\u3082\u51FA\u3055\u305A\u3001\u30BF\u30D6\u3044\u3063\u3071\u3044\u306E\u30D6\u30E9\u30A6\u30B6\u3067\u30A2\u30D7\u30EA\u3092\u89E6\u308B \xB7 Esc \u3067\u7D42\u4E86",exitDemo:"\u30C7\u30E2\u3092\u7D42\u4E86",browserBack:"\u623B\u308B",browserForward:"\u9032\u3080",browserReload:"\u518D\u8AAD\u307F\u8FBC\u307F",browserAddress:"\u30A2\u30C9\u30EC\u30B9",browserTabs:"\u30BF\u30D6",newTab:"\u65B0\u3057\u3044\u30BF\u30D6",closeTab:"\u30BF\u30D6\u3092\u9589\u3058\u308B",browserProfile:t=>`\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB: ${t}`,browserGuest:"\u30B2\u30B9\u30C8",newTabShortcuts:"\u3053\u306E\u30A2\u30D7\u30EA\u306E\u30DA\u30FC\u30B8",unreachableTitle:"\u3053\u306E\u30B5\u30A4\u30C8\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093",unreachableBody:"\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u306B\u3053\u306E\u30A2\u30C9\u30EC\u30B9\u306E\u30DA\u30FC\u30B8\u306F\u3042\u308A\u307E\u305B\u3093\u3002",device:"\u30C7\u30D0\u30A4\u30B9",deviceHint:"\u30A2\u30D7\u30EA\u3092\u52D5\u304B\u3059\u753B\u9762\u306E\u5927\u304D\u3055\u3002\u53CE\u307E\u3089\u306A\u3044\u30DA\u30FC\u30B8\u306F\u5B9F\u6A5F\u3068\u540C\u3058\u304F\u753B\u9762\u306E\u4E2D\u3067\u30B9\u30AF\u30ED\u30FC\u30EB\u3059\u308B",deviceName:t=>Ot[t]??Fn[t]??t,deviceZoom:t=>`\u53CE\u307E\u308B\u3088\u3046 ${t}% \u3067\u8868\u793A`,actions:"\u30A2\u30AF\u30B7\u30E7\u30F3",actionsHint:"\u30D5\u30A9\u30FC\u30E0\u306B\u30B5\u30F3\u30D7\u30EB\u30C7\u30FC\u30BF\u3092\u5165\u308C\u308B\u306A\u3069\u3001\u753B\u9762\u306B\u7528\u610F\u3055\u308C\u305F\u64CD\u4F5C\u3092\u4E00\u5EA6\u306B\u884C\u3046"}}),Ct=(t,e)=>new Intl.DateTimeFormat(t,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e)),Gn=["scenario","app"],V="view",pe=t=>t[V]==="app"?"app":"scenario",Mt=t=>({[V]:t==="app"?"app":null}),ce=(t,e)=>t===void 0?`\u2192 "${e}"`:`"${t}" \u2192 "${e}"`,jn=t=>({SET_ACTIVITY_NAME:(e,i)=>({title:t.renameActivity,tone:"update",body:ce(U(i,e.target.id)?.name,k(m.SET_ACTIVITY_NAME,e).name)}),SET_ACTIVITY_DESCRIPTION:(e,i)=>({title:t.updateActivityDescription,tone:"update",body:ye(U(i,e.target.id)?.description,k(m.SET_ACTIVITY_DESCRIPTION,e).description)}),SET_STORY_NAME:(e,i)=>({title:t.renameStory,tone:"update",body:ce($(i,e.target.id)?.story.name,k(m.SET_STORY_NAME,e).name)}),SET_STORY_DESCRIPTION:(e,i)=>({title:t.updateStoryDescription,tone:"update",body:ye($(i,e.target.id)?.story.description,k(m.SET_STORY_DESCRIPTION,e).description)}),SET_STEP_NAME:(e,i)=>({title:t.renameStep,tone:"update",body:ce(S(i,e.target.id)?.step.name,k(m.SET_STEP_NAME,e).name)}),SET_STEP_DESCRIPTION:(e,i)=>({title:t.updateStepDescription,tone:"update",body:ye(S(i,e.target.id)?.step.description,k(m.SET_STEP_DESCRIPTION,e).description)}),SET_PREVIEW_KIND:(e,i)=>({title:t.changePreviewKind,tone:"update",body:ce(E(i,e.target.id)?.preview.kind,k(m.SET_PREVIEW_KIND,e).kind)}),SET_PREVIEW_VIEWPORT:(e,i)=>({title:t.changePreviewViewport,tone:"update",body:ce(E(i,e.target.id)?.preview.viewport,k(m.SET_PREVIEW_VIEWPORT,e).viewport)}),SET_PREVIEW_LABEL:e=>({title:t.changePreviewLabel,tone:"update",body:`\u2192 "${k(m.SET_PREVIEW_LABEL,e).label}"`}),REORDER_ACTIVITY:e=>Ue(t,t.activityGroup,k(m.REORDER_ACTIVITY,e).after),REORDER_STORY:e=>Ue(t,t.storyGroup,k(m.REORDER_STORY,e).after),REORDER_STEP:e=>Ue(t,t.stepGroup,k(m.REORDER_STEP,e).after),MOVE_STORY:(e,i)=>({title:t.moveStory,tone:"move",body:`\u2192 ${U(i,k(m.MOVE_STORY,e).toActivity)?.name??k(m.MOVE_STORY,e).toActivity}`}),MOVE_STEP:(e,i)=>({title:t.moveStep,tone:"move",body:`\u2192 ${$(i,k(m.MOVE_STEP,e).toStory)?.story.name??k(m.MOVE_STEP,e).toStory}`}),ADD_ACTIVITY:e=>we(t,t.activityGroup,k(m.ADD_ACTIVITY,e).name),ADD_STORY:e=>we(t,t.storyGroup,k(m.ADD_STORY,e).name),ADD_STEP:e=>we(t,t.stepGroup,k(m.ADD_STEP,e).name),ADD_PREVIEW:e=>we(t,t.previewGroup,k(m.ADD_PREVIEW,e).label??k(m.ADD_PREVIEW,e).id),DELETE_ACTIVITY:(e,i)=>be(t,U(i,e.target.id)?.name),DELETE_STORY:(e,i)=>be(t,$(i,e.target.id)?.story.name),DELETE_STEP:(e,i)=>be(t,S(i,e.target.id)?.step.name),DELETE_PREVIEW:(e,i)=>be(t,E(i,e.target.id)?.preview.label),ADD_UI_NOTE:e=>({title:t.addUiNote,tone:"create",body:`+ "${Le(k(m.ADD_UI_NOTE,e).body)}"`}),SET_UI_NOTE_BODY:(e,i)=>{const{noteId:n,body:o}=k(m.SET_UI_NOTE_BODY,e);return{title:t.editUiNote,tone:"update",body:ye(Yt(i,n)?.body,o)}},DELETE_UI_NOTE:(e,i)=>{const{noteId:n}=k(m.DELETE_UI_NOTE,e),o=Yt(i,n);return{title:t.deleteUiNote,tone:"delete",body:o===void 0?t.unknownTarget:`\u2212 "${Le(o.body)}"`}}}),ye=(t,e)=>{const i=e.length>90?`${e.slice(0,90)}\u2026`:e;return t===void 0||t===""?`\u2192 "${i}"`:`"${Le(t)}" \u2192 "${i}"`},Le=t=>t.length>60?`${t.slice(0,60)}\u2026`:t,Ue=(t,e,i)=>({title:t.reorderTitle(e),tone:"move",body:i===null?t.toFront:t.afterName(i)}),we=(t,e,i)=>({title:t.addTitle(e),tone:"create",body:`+ "${i}"`}),be=(t,e)=>({title:t.deleteTitle,tone:"delete",body:e===void 0?t.unknownTarget:`\u2212 "${e}"`}),Lt=(t,e,i,n)=>{const o=jn(t),s=Object.hasOwn(o,e.type)?o[e.type]:void 0,r=s?s(e,n??i):{title:e.type,tone:"meta"};return{title:r.title,targetLabel:Vt(t,i,e.target),tone:r.tone,...r.body===void 0?{}:{summary:r.body}}},Ut=t=>`${t.type} ${Y(t.target)} ${JSON.stringify(t.payload)}`,Vt=(t,e,i)=>{switch(i.type){case"activity":{const n=U(e,i.id);return n?t.targetLabel(t.activityGroup,n.name):t.targetMissing(t.activityGroup,i.id)}case"story":{const n=$(e,i.id)?.story;return n?t.targetLabel(t.storyGroup,n.name):t.targetMissing(t.storyGroup,i.id)}case"step":{const n=S(e,i.id)?.step;return n?t.targetLabel(t.stepGroup,n.name):t.targetMissing(t.stepGroup,i.id)}case"screen":{const n=L(e,i.id)?.screen;return n?t.targetLabel(t.screenGroup,n.title):t.targetMissing(t.screenGroup,i.id)}case"preview":{const n=E(e,i.id)?.preview;return n?t.targetLabel(t.previewGroup,n.label??n.id):t.targetMissing(t.previewGroup,i.id)}case"page":return t.targetLabel(t.pageGroup,He(e));case O:{const n=Q(i.id),o=n?E(e,n.previewId)?.preview:void 0;return n&&o?t.targetLabel(t.uiGroup,Ve(o,n)):t.targetMissing(t.uiGroup,i.id)}default:return t.targetLabel(i.type,i.id)}},Ve=(t,e)=>{const i=e.text===void 0?e.selector:`"${e.text}"`;return`${t.label??t.id} \u203A ${i}`},zt=(t,e)=>{const i=[];for(const n of t){if(n.target.type!==O)continue;const o=Q(n.target.id);!o||!e.includes(o.previewId)||i.push({id:n.id,previewId:o.previewId,selector:o.selector,number:i.length+1,body:Qe(n)})}return i},Kn=(t,e)=>e.flatMap(i=>{const n=E(t,i)?.preview,o=new Map;for(const s of n?.notes??[])o.set(s.selector,[...o.get(s.selector)??[],s]);return n===void 0?[]:[...o].map(([s,r])=>({previewId:i,selector:s,label:Ve(n,{selector:s,...Xn(r)}),notes:r}))}),Xn=t=>{const e=[...t].reverse().find(i=>i.text!==void 0)?.text;return e===void 0?{}:{text:e}},Yt=(t,e)=>It(t).flatMap(i=>i.notes??[]).find(i=>i.id===e),Ht=(t,e)=>zt(t,e).length,Zn=/^[a-z][a-z0-9+.-]*:/i,Jn=t=>{const e=t.baseUrl?.trim(),i=Xi(t.title??"");return`${(e?e.startsWith("http")?e:`https://${e}`:`https://${i==="item"?"page":i}.example.com`).replace(/\/+$/,"")}/`},ke=(t,e)=>{const i=Jn(t);if(!e.url)return`${i}${e.id}`;if(Zn.test(e.url))return e.url;try{return decodeURI(new URL(e.url,i).href)}catch{return e.url}},Qn=t=>{switch(t.type){case"activity":return{[V]:null,activity:t.id};case"story":return{[V]:null,activity:null,story:t.id};case"step":return{[V]:null,activity:null,story:null,step:t.id};case"screen":return{screen:t.id};default:return null}},Bt=(t,e)=>{const i=t.kind==="screen"?[{type:"screen",id:t.screen.id}]:[{type:"activity",id:t.activity.id},{type:"story",id:C(t.activity.id,t.story.id)},...t.kind==="step"?[{type:"step",id:ae(t)}]:[]];for(const n of e?.panes??[])n.kind==="screen"&&i.push({type:"screen",id:n.screen.screen.id});return[...new Set(i.map(Y))].join(" ")},ze=",",Wt=t=>t.preview?.split(ze)??[],eo=(t,e)=>t.kind===e.kind&&t.viewport===e.viewport,qt=(t,e,i)=>{const n=e.find(s=>i.includes(s.id));if(n)return n;const o=i.flatMap(s=>E(t,s)?.preview??[]);return e.find(s=>o.some(r=>eo(s,r)))??e[0]},Ft=(t,e,i,n)=>{const o=e.screen.previews,s=i===void 0?qt(t,o,Wt(n)):o.find(a=>a.id===i);if(!s)return;const r=i===void 0&&o.length>1;return{kind:"screen",screen:e,preview:s,pinned:i!==void 0,tabs:r?o:[]}},Gt=t=>({layout:t.length>1?"side-by-side":"single",panes:t,shown:t.map(e=>e.preview)}),jt=(t,e,i)=>e.panes.flatMap(n=>{if(!J(n))return[{kind:"material",preview:n.material}];const o=L(t,n.screen),s=o&&Ft(t,o,n.preview,i);return s?[s]:[]}),Ye=(t,e,i)=>{if(e.kind==="screen"){const n=Ft(t,e,void 0,i);return Gt(n?[n]:[])}return Gt(jt(t,e.step,i))},to=(t,e)=>t.panes.flatMap(i=>i.kind!=="screen"||i.tabs.length===0?[]:[i.tabs.some(n=>n.id===e)?e:i.preview.id]).join(ze),Kt=(t,e)=>{const i=new Map;for(const n of e){const o=E(t,n)?.owner;if(o?.kind!=="screen"||o.screen.actions.length===0)continue;const s=i.get(o.screen.id)??{screen:o.screen,previewIds:[]};s.previewIds.push(n),i.set(o.screen.id,s)}return[...i.values()].map(({screen:n,previewIds:o})=>({screen:n,previewIds:o,actions:n.actions}))},io=(t,e)=>[...F(e),...fe(t,e).flatMap(i=>i.screen.previews)],no=["activity","story","step","screen","preview"],oo=(t,e,i)=>{switch(e){case"activity":return U(t,i)!==void 0;case"story":return $(t,i)!==void 0||t.activities.some(n=>n.stories.some(o=>o.id===i));case"step":return S(t,i)!==void 0||B(t).some(n=>n.step.id===i);case"screen":return L(t,i)!==void 0;case"preview":return E(t,i)!==void 0;default:return!1}},so=(t,e)=>{let i;if(e.navigate!==null)i=e.navigate.includes("=")?e.navigate:`step=${e.navigate}`;else{const s=e.href?.trim()??"";if(s===""||s==="#"||s.toLowerCase().startsWith("javascript:"))return"no-destination";if(!s.startsWith("#"))return null;i=s}const n=_e(i),o=no.filter(s=>n[s]!==void 0);return o.length===0?e.navigate===null?null:"unknown-target":o.every(s=>oo(t,s,n[s]??""))?null:"unknown-target"},ro=(t,e)=>{const i=e.mail??{},n=[{label:t.mailFrom,value:i.from},{label:t.mailTo,value:i.to},{label:t.mailCc,value:i.cc},{label:t.mailDate,value:i.date}].flatMap(r=>r.value===void 0||r.value.trim()===""?[]:[{label:r.label,value:r.value}]),o=i.from?.replace(/<[^>]*>/g,"").replace(/["']/g,"").trim()||i.from?.trim(),s=o?Array.from(o)[0]?.toUpperCase():void 0;return{...i.subject===void 0||i.subject.trim()===""?{}:{subject:i.subject},...o?{sender:o}:{},...s===void 0?{}:{initial:s},rows:n}},Xt=(t,e)=>{const i=[];for(const n of e.activities){i.push({value:Y({type:"activity",id:n.id}),label:n.name,group:t.activityGroup});for(const o of n.stories){i.push({value:Y({type:"story",id:C(n.id,o.id)}),label:`${n.name} \u203A ${o.name}`,group:t.storyGroup});for(const s of o.steps)i.push({value:Y({type:"step",id:ge(n,o,s)}),label:`${o.name} \u203A ${s.name}`,group:t.stepGroup})}}for(const{app:n,screen:o}of H(e))i.push({value:Y({type:"screen",id:o.id}),label:`${n.name} \u203A ${o.title}`,group:t.screenGroup});return i},ao=(t,e,i)=>{const n=te(e,i);if(n?.kind==="screen"){const{screen:o}=n;return{value:Y({type:"screen",id:o.id}),label:o.title,group:t.screenGroup}}return n?.kind!=="step"?null:{value:Y({type:"step",id:ae(n)}),label:n.step.name,group:t.stepGroup}},te=(t,e)=>{if(pe(e)==="app"){const s=L(t,e.screen);return s?{kind:"screen",...s}:void 0}const i=S(t,e.step);if(i)return{kind:"step",...i};const n=U(t,e.activity),o=n?.stories.find(s=>s.id===e.story||C(n.id,s.id)===e.story);return n&&o?{kind:"story",activity:n,story:o}:void 0},Zt=(t,e)=>{const i=(d,p)=>p===void 0?{title:d}:{actor:p,title:d};if(e.kind==="screen")return i(e.screen.title,e.app.actor);const{activity:n,story:o,step:s}=e,r=fe(t,s),a=r.length===1?r[0]:void 0;return i(a?.screen.title??s.name,s.actor??o.actor??n.actor??a?.app.actor)},lo=(t,e)=>{const i=e.actor??t.actor;return i===void 0?{title:e.name}:{actor:i,title:e.name}},He=t=>t.title??"UX Prototype",Jt=(t,e)=>(e?t.preview=e:delete t.preview,t),po=(t,e,i)=>{if(!e)return;const n=jt(t,e,i).flatMap(o=>o.kind==="screen"&&!o.pinned?[o.preview.id]:[]);return n.length===0?void 0:n.join(ze)},Qt=(t,e)=>{const i=()=>{if(e.step===void 0&&e.story===void 0)return;const s=ei(t,{...e,[V]:""}),r=S(t,s.step);return r&&fe(t,r.step)[0]},n=L(t,e.screen)??i()??H(t)[0],o={...e,[V]:"app"};for(const s of["activity","story","step"])delete o[s];return n?o.screen=n.screen.id:delete o.screen,Jt(o,n&&qt(t,n.screen.previews,Wt(e))?.id)},co=(t,e,i)=>{const n=r=>Bn(r.step,e);if(i&&n(i))return i;const o=i?.story.steps??[],s=r=>{const a=o[r];return i&&a?{...i,step:a,stepIndex:r}:void 0};for(let r=(i?.stepIndex??0)+1;r<o.length;r+=1){const a=s(r);if(a&&n(a))return a}for(let r=(i?.stepIndex??0)-1;r>=0;r-=1){const a=s(r);if(a&&n(a))return a}return B(t).find(n)},ei=(t,e)=>{const i=U(t,e.activity),n=e.story,o=i?.stories.find(z=>z.id===n||C(i.id,z.id)===n),s=o&&i?{activity:i,story:o}:$(t,n),r=e.step,d=(s&&r?S(t,`${C(s.activity.id,s.story.id)}.${r}`):void 0)??S(t,r),p=e.screen,c=p===void 0?void 0:co(t,p,d);if(p!==void 0&&!c&&L(t,p))return Qt(t,{...e,[V]:"app"});const v=c??d,f=v?.activity??s?.activity??i??t.activities[0],I=v?.story??(s&&s.activity===f?s.story:void 0)??f?.stories[0],P=v?.step??I?.steps[0],T={...e};return delete T.screen,f?T.activity=f.id:delete T.activity,I&&f?T.story=$(t,I.id)?I.id:C(f.id,I.id):delete T.story,P&&I&&f?T.step=S(t,P.id)?P.id:ge(f,I,P):delete T.step,delete T[V],Jt(T,po(t,P,e))},uo=["activity","story","step","screen"],xe=(t,e)=>pe(e)==="app"?Qt(t,e):ei(t,e),ho=(t,e)=>{const i=e.screen.previews.find(s=>s.kind==="browser");if(!i)return;let n;try{n=new URL(ke(t,i),"https://page.example.com")}catch{return}const o=n.pathname.split("/").filter(s=>s!=="").map(s=>{try{return decodeURIComponent(s)}catch{return s}});return{origin:n.origin,segments:o}},ti=()=>({screens:[],children:new Map}),Be=(t,e,i)=>{const[n,...o]=t.children.entries();if(t.screens.length===0&&n&&o.length===0&&i!=="/"){const[s,r]=n;return Be(r,`${e}/${s}`,`${i}/${s}`)}return{segment:e,path:i,screens:t.screens,children:[...t.children.entries()].map(([s,r])=>Be(r,`/${s}`,`${i==="/"?"":i}/${s}`))}},vo=t=>{const e=new Map;for(const[i,n]of t){const o=e.get(n.origin)??ti();e.set(n.origin,o);let s=o;for(const r of n.segments){const a=s.children.get(r)??ti();s.children.set(r,a),s=a}s.screens.push(i)}return[...e.entries()].map(([i,n])=>({origin:i,root:Be(n,"/","/")}))},fo=(t,e)=>{const i=e.screens.map(s=>({app:e,screen:s})),n=[],o=[];for(const s of i){const r=ho(t,s);r?n.push([s,r]):o.push(s)}return{app:e,screens:i,trees:vo(n),others:o}},ii=t=>t.apps.map(e=>fo(t,e)).filter(e=>e.screens.length>0),ni=(t,e)=>e?.kind!=="screen"?t[0]:t.find(i=>i.app.id===e.app.id)??t[0],go=(t,e)=>{switch(e.type){case"activity":return U(t,e.id)!==void 0;case"story":return $(t,e.id)!==void 0;case"step":return S(t,e.id)!==void 0;case"screen":return L(t,e.id)!==void 0;case"preview":return E(t,e.id)!==void 0;case"page":return!0;case O:{const i=Q(e.id);return i!==void 0&&E(t,i.previewId)!==void 0}default:return!1}},oi=t=>{const e=le(t);return{kind:"view",name:"prototype",label:"UX Prototype",addable:!1,parseBase:$t,emptyBase:Tt,actions:m,apply:Rt,hasTarget:go,canonicalTarget:(i,n)=>{if(n.type==="step"){const o=S(i,n.id);return o?{...n,id:ae(o)}:n}if(n.type==="story"){const o=$(i,n.id);return o?{...n,id:C(o.activity.id,o.story.id)}:n}if(n.type==="preview"){const o=E(i,n.id);return o?{...n,id:o.preview.id}:n}return n},describe:(i,n,o)=>Lt(e,i,n,o),serialize:Ut,resolveNavigation:xe,navigationHierarchy:uo,navigationFor:(i,n)=>Qn(n),commentTargets:(i,n)=>Xt(e,i),currentTarget:(i,n)=>ao(e,i,n),title:He}},mo=(t,e)=>{const i=e.flatMap(n=>{const o=Math.max(n.left,t.left)-t.left,s=Math.max(n.top,t.top)-t.top,r=Math.min(n.right,t.right)-t.left-o,a=Math.min(n.bottom,t.bottom)-t.top-s;return r>0&&a>0?[`M${o} ${s}h${r}v${a}h-${r}Z`]:[]});return i.length===0?"none":`path(evenodd, 'M0 0H${t.width}V${t.height}H0Z ${i.join(" ")}')`},Ee="data-dpk-modal",yo=t=>{try{return t.matches(":modal")}catch{return!1}},si=t=>{t.setAttribute(Ee,""),t.open||t.show()},ri=t=>{Object.hasOwn(t,"showModal")||Object.defineProperty(t,"showModal",{configurable:!0,value:()=>si(t)})},ai=(t,e)=>{if(!yo(e))return;const i=n=>{n.target===e&&(n.stopImmediatePropagation(),t.removeEventListener("close",i,!0))};t.addEventListener("close",i,!0),e.close(),si(e)},di=(t,e)=>{try{return Array.from(t.querySelectorAll(e))}catch{return[]}},wo=(t,e)=>{const i=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value");i?.set?i.set.call(t,e):t.value=e},bo=t=>t instanceof HTMLInputElement&&(t.type==="checkbox"||t.type==="radio"),ko=(t,e)=>{if(bo(t)){const n=typeof e=="boolean"?e:t.value===e;return typeof e=="string"&&!n?!1:(t.checked=n,!0)}const i=String(e);return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?(wo(t,i),!0):(t.textContent=i,!1)},xo=(t,e)=>{const i=[];for(const[n,o]of Object.entries(e)){const s=di(t,n);s.length===0&&i.push(n);for(const r of s)ko(r,o)&&(r.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})))}return i},Eo=(t,e)=>{const i=[];for(const n of e){const[o]=di(t,n);o instanceof HTMLElement?o.click():i.push(n)}return i},So='a, button, input, select, textarea, label, summary, [role="button"], [role="link"], [role="tab"]',li=/^-?[A-Za-z_][\w-]*$/,pi=40,$o=(t,e)=>{const i=t.closest(So);return i!==null&&i!==e&&e.contains(i)?i:t},Se=t=>{const e=t.replace(/\s+/g," ").trim();if(e==="")return;const i=Array.from(e);return i.length>pi?`${i.slice(0,pi).join("")}\u2026`:e},To=t=>{const e=t.getAttribute("aria-label")??t.getAttribute("title");if(e)return Se(e);const i=t.tagName.toLowerCase();return Se(i==="input"||i==="textarea"||i==="select"?t.getAttribute("placeholder")??t.getAttribute("name")??"":i==="img"?t.getAttribute("alt")??"":t.textContent??"")},Ao=t=>{const e=t.getAttribute("id");if(e&&li.test(e))return`#${e}`;const i=t.tagName.toLowerCase(),n=Array.from(t.classList).filter(a=>li.test(a)).slice(0,2).map(a=>`.${a}`).join(""),o=t.parentElement,s=o?Array.from(o.children).filter(a=>a.tagName===t.tagName):[],r=s.length>1?`:nth-of-type(${s.indexOf(t)+1})`:"";return`${i}${n}${r}`},Io=(t,e,i)=>{try{const n=t.querySelectorAll(e);return n.length===1&&n[0]===i}catch{return!1}},_o=(t,e)=>{const i=[];let n=t;for(;n!==null&&n!==e;){const s=Ao(n);if(i.unshift(s),s.startsWith("#")||Io(e,i.join(" > "),t))break;n=n.parentElement}const o=To(t);return{selector:i.length===0?":scope":i.join(" > "),tag:t.tagName.toLowerCase(),...o===void 0?{}:{text:o}}},Po=(t,e)=>{if(e===":scope")return t;try{return t.querySelector(e)}catch{return null}},ci=(t,e)=>{const i=xe(t,e),n=te(t,i);if(n?.kind!=="screen")return null;const[o]=Ye(t,n,i).shown;return o?.kind!=="browser"?null:{screen:n.screen.id,preview:o.id}},$e=(t,e)=>{const i=te(t,xe(t,{[V]:"app",...e}));return i?.kind==="screen"?i:void 0},Do=(t,e,i)=>{const n=dt(e,i);if(n===null)return null;const o=lt(n);for(const{screen:s}of H(t))for(const r of s.previews){if(r.kind!=="browser")continue;const a=dt(ke(t,r),i);if(a!==null&&lt(a)===o)return{screen:s.id,preview:r.id}}return null},Ro=(t,e,i)=>e===void 0||e.kind==="new-tab"?i.newTab:e.kind==="unreachable"?rt(e.url):$e(t,e.page)?.screen.title??i.newTab,ui=(t,e)=>{if(e===void 0||e.kind==="new-tab")return"";if(e.kind==="unreachable")return e.url;const i=$e(t,e.page)?.screen.previews.find(n=>n.id===e.page.preview);return i===void 0?"":ke(t,i)},hi=t=>{const e=at(t);for(let i=e.index;i>=0;i-=1){const n=e.history[i];if(n?.kind==="page")return n.page}for(const i of t.tabs){const n=i.history[i.index];if(n?.kind==="page")return n.page}},No=(t,e)=>e===void 0?void 0:$e(t,e)?.app.actor,vi=(t,e,i,n=null)=>{const o=at(e),s=o.history[o.index],r=No(t,hi(e)??n??void 0);return{tabs:e.tabs.map(a=>({id:a.id,title:Ro(t,a.history[a.index],i),url:ui(t,a.history[a.index]),active:a.id===o.id})),entry:s,url:ui(t,s),canBack:vn(e),canForward:hn(e),...r===void 0?{}:{profile:r}}},Oo=t=>hi(t)??null,Co=(t,e)=>{const i=e===null?void 0:$e(t,e),n=ni(ii(t),i),o=[],s=(r,a)=>{for(const{screen:d}of a.screens){const p=d.previews.find(c=>c.kind==="browser");p!==void 0&&o.push({title:d.title,url:`${r}${a.path==="/"?"":a.path}`,page:{screen:d.id,preview:p.id}})}for(const d of a.children)s(r,d)};for(const r of n?.trees??[])s(rt(r.origin),r.root);return o},A=(t,e,i,n)=>({id:e,deviceClass:t,width:i,height:n}),fi=[A("phone","iphone-se",375,667),A("phone","iphone-16",393,852),A("phone","iphone-16-pro-max",440,956),A("phone","pixel-7",412,915),A("phone","galaxy-s24",360,780),A("tablet","ipad-mini",744,1133),A("tablet","ipad-air-11",820,1180),A("tablet","ipad-pro-11",834,1194),A("tablet","ipad-pro-13",1024,1366),A("desktop","laptop-13",1280,800),A("desktop","laptop-15",1440,900),A("desktop","full-hd",1920,1080),A("desktop","monitor-27",2560,1440),A("desktop","ultrawide",3440,1440)],Mo={phone:A("phone","iphone-16",393,852),tablet:A("tablet","ipad-pro-11",834,1194),desktop:A("desktop","laptop-13",1280,800)},gi=t=>t==="mobile"?"phone":t==="tablet"?"tablet":"desktop",Lo=t=>t!=="plain",mi=t=>fi.filter(e=>e.deviceClass===t),Uo=(t,e)=>{const i=gi(t),n=e[i];return mi(i).find(o=>o.id===n)??Mo[i]},Vo=(t,e)=>{const i=fi.find(n=>n.id===e);return i===void 0||t[i.deviceClass]===e?t:{...t,[i.deviceClass]:e}},zo=(t,e)=>`${t.deviceName(e.id)} \xB7 ${e.width}\xD7${e.height}`,Yo=(t,e)=>{const i=[1,e.width/t.width];e.height!==void 0&&i.push(e.height/t.height);const n=Math.min(...i);return!Number.isFinite(n)||n<=0?1:Math.max(.1,Math.floor(n*100)/100)},yi=(t,e,i)=>{const{state:n,navigation:o}=t,s=te(n,o),r=pe(o);return l`
1
+ import{ax as w,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Yi,aD as Ie,au as Hi,bk as Je,bl as Bi,aa as N,ay as x,b9 as Wi,aB as qi,p as y,a9 as b,t as se,aO as oe,a8 as Fi,N as Gi,e as ji,a5 as Ki,h as Qe,K as _e,S as Y,R as Xi,P as k,as as l,ai as h,bm as Pe,bn as De,aH as Zi,y as Re,aP as et,l as tt,b0 as q,bo as Ji,z as it,bp as nt,G as Qi,I as en,b4 as tn,b5 as nn,ah as sn,V as st,ag as on,bq as rn,aE as an,aF as ve,aG as ot,C as dn,br as ln}from"./shared-B8ZhyjWv.js";import{c as pn,a as cn}from"./shared-Dn92ukYW.js";import{m as un}from"./shared-2OsWmhrI.js";import{h as rt,d as at,e as hn,f as vn,a as dt,b as lt,i as pt,p as fn,r as gn,k as mn,l as wn,m as yn,g as bn,c as kn,s as xn,n as ct,j as ut,t as En}from"./shared-Dql0ZVdC.js";const Sn=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21"}]],$n=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"}]],Tn=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2"}],["path",{d:"M12 18h.01"}]],An=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18"}]],In=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}],["circle",{cx:"12",cy:"7",r:"4"}]],_n=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72"}],["path",{d:"m14 7 3 3"}],["path",{d:"M5 6v4"}],["path",{d:"M19 14v4"}],["path",{d:"M10 2v2"}],["path",{d:"M7 8H3"}],["path",{d:"M21 16h-4"}],["path",{d:"M11 3H9"}]],ht=["browser","native","mail","plain"],vt=["mobile","tablet","desktop","fluid"],J=t=>"screen"in t,Pn=D({from:g(u()),to:g(u()),cc:g(u()),subject:g(u()),date:g(u())}),ft={id:_,kind:M(he(ht),"browser"),viewport:M(he(vt),"fluid"),label:g(u()),url:g(u()),mail:g(Pn)},Ne=w(u(),Ae(t=>t.trim()!=="","a note needs some text")),gt=w(u(),Yi()),Dn=D({id:_,selector:w(u(),x(1)),text:g(u()),body:Ne,createdAt:g(gt)}),mt='a preview `mail` envelope needs `"kind": "mail"`',wt=w(D(ft),Ae(t=>t.mail===void 0||t.kind==="mail",mt)),yt=w(D({...ft,notes:g(N(Dn))}),Ae(t=>t.mail===void 0||t.kind==="mail",mt)),bt=D({screen:_,preview:g(_)}),Rn=Ie([bt,D({material:wt})]),Nn=Ie([bt,D({material:yt})]),On=D({id:_,name:w(u(),x(1)),description:g(u()),actor:g(w(u(),x(1))),situation:g(w(u(),x(1))),panes:M(N(Nn),[])}),Cn=D({id:_,name:w(u(),x(1)),description:g(u()),actor:g(w(u(),x(1))),steps:M(N(On),[])}),Mn=D({id:_,name:w(u(),x(1)),description:g(u()),actor:g(w(u(),x(1))),stories:M(N(Cn),[])}),kt=w(u(),x(1)),Ln=D({id:_,label:w(u(),x(1)),description:g(u()),fill:g(Wi(kt,Ie([u(),qi()]))),click:g(N(kt))}),Un=D({id:_,title:w(u(),x(1)),description:g(u()),previews:M(N(yt),[]),actions:M(N(Ln),[])}),Vn=D({id:_,name:w(u(),x(1)),description:g(u()),actor:g(w(u(),x(1))),screens:M(N(Un),[])}),xt=D({title:g(u()),baseUrl:g(u()),apps:M(N(Vn),[]),activities:M(N(Mn),[])}),Et=t=>t.flatMap(e=>J(e)?[]:[e.material]),zn=t=>{const e=new Set,i=new Set,n=a=>{for(const d of a){if(e.has(d.id))return`duplicate preview id "${d.id}": preview ids are global, they name a light DOM slot`;e.add(d.id);for(const p of d.notes??[]){if(i.has(p.id))return`duplicate note id "${p.id}": note ids are global`;i.add(p.id)}}return null},s=new Set,o=new Set;for(const a of t.apps){if(s.has(a.id))return`duplicate app id "${a.id}"`;s.add(a.id);for(const d of a.screens){if(o.has(d.id))return`duplicate screen id "${d.id}": screen ids are global`;o.add(d.id);const p=n(d.previews);if(p!==null)return p;const c=new Set;for(const v of d.actions){if(c.has(v.id))return`duplicate action id "${v.id}" on screen "${d.id}"`;c.add(v.id)}}}const r=new Set;for(const a of t.activities){if(r.has(a.id))return`duplicate activity id "${a.id}"`;r.add(a.id);const d=new Set;for(const p of a.stories){if(d.has(p.id))return`duplicate story id "${p.id}" in activity "${a.id}"`;d.add(p.id);const c=new Set;for(const v of p.steps){if(c.has(v.id))return`duplicate step id "${v.id}" in story "${p.id}"`;c.add(v.id);const f=n(Et(v.panes));if(f!==null)return f}}}return null},St=(t,e)=>{const i=new Map;for(const n of e.panes){if(!J(n))continue;const s=t(n.screen);if(s===void 0)return`unknown screen "${n.screen}" on step "${e.id}": declare it under \`apps[].screens\``;if(n.preview!==void 0&&!s.includes(n.preview))return`preview "${n.preview}" on step "${e.id}" is not a rendition of screen "${n.screen}"`;const o=i.get(n.screen)??[];if(o.length>0&&(n.preview===void 0||o.includes(n.preview)||o.includes(void 0)))return`screen "${n.screen}" is shown twice on step "${e.id}": give each pane a different \`preview\``;i.set(n.screen,[...o,n.preview])}return null},Yn=t=>{const e=new Map(t.apps.flatMap(i=>i.screens.map(n=>[n.id,n.previews.map(s=>s.id)])));for(const i of t.activities.flatMap(n=>n.stories.flatMap(s=>s.steps))){const n=St(s=>e.get(s),i);if(n!==null)return n}return null},Hn=(t,e)=>St(i=>L(t,i)?.screen.previews.map(n=>n.id),e),O="ui",re=t=>{const e=t.text?.replaceAll('"',"'");return`${t.previewId}/${t.selector}${e===void 0?"":` "${e}"`}`},Q=t=>{const e=t.indexOf("/");if(e<=0)return;const i=t.slice(0,e);if(!Bi(_,i))return;const n=t.slice(e+1),s=/ "([^"]*)"$/.exec(n),o=(s?n.slice(0,s.index):n).trim();if(o!=="")return s?.[1]===void 0?{previewId:i,selector:o}:{previewId:i,selector:o,text:s[1]}},$t=t=>{const e=Hi(xt,t),i=zn(e)??Yn(e);if(i!==null)throw new Error(i);return e},Tt=()=>({apps:[],activities:[]}),H=t=>t.apps.flatMap(e=>e.screens.map(i=>({app:e,screen:i}))),L=(t,e)=>{if(e!==void 0)return H(t).find(i=>i.screen.id===e)},fe=(t,e)=>e.panes.flatMap(i=>{const n=J(i)?L(t,i.screen):void 0;return n?[n]:[]}),F=t=>Et(t.panes),Bn=(t,e)=>t.panes.some(i=>J(i)&&i.screen===e),U=(t,e)=>{if(e!==void 0)return t.activities.find(i=>i.id===e)},C=(t,e)=>`${t}.${e}`,$=(t,e)=>{if(e===void 0)return;const i=Je(e,2);if(i){const[s,o]=i;if(s===void 0||o===void 0)return;const r=t.activities.find(d=>d.id===s),a=r?.stories.find(d=>d.id===o);return r&&a?{activity:r,story:a}:void 0}if(e.includes("."))return;const n=t.activities.flatMap(s=>s.stories.filter(o=>o.id===e).map(o=>({activity:s,story:o})));return n.length===1?n[0]:void 0},At=t=>{const e=t.lastIndexOf(".");return e>=0?t.slice(e+1):t},ae=t=>`${t.activity.id}.${t.story.id}.${t.step.id}`,ge=(t,e,i)=>`${t.id}.${e.id}.${i.id}`,S=(t,e)=>{if(e===void 0)return;const i=Je(e,3);if(i){const[s,o,r]=i;if(s===void 0||o===void 0||r===void 0)return;const a=t.activities.find(v=>v.id===s),d=a?.stories.find(v=>v.id===o),p=d?d.steps.findIndex(v=>v.id===r):-1,c=d&&p>=0?d.steps[p]:void 0;return a&&d&&c?{activity:a,story:d,step:c,stepIndex:p}:void 0}if(e.includes("."))return;const n=B(t).filter(s=>s.step.id===e);return n.length===1?n[0]:void 0},E=(t,e)=>{if(e!==void 0){for(const i of H(t)){const n=i.screen.previews.find(s=>s.id===e);if(n)return{owner:{kind:"screen",...i},preview:n}}for(const i of B(t)){const n=F(i.step).find(s=>s.id===e);if(n)return{owner:{kind:"step",...i},preview:n}}}},It=t=>[...H(t).flatMap(e=>e.screen.previews),...B(t).flatMap(e=>F(e.step))],_t=t=>It(t).flatMap(e=>(e.notes??[]).map(i=>i.id)),B=t=>t.activities.flatMap(e=>e.stories.flatMap(i=>i.steps.map((n,s)=>({activity:e,story:i,step:n,stepIndex:s})))),Pt=t=>B(t).map(e=>e.step.id),Oe=w(u(),x(1)),Dt=t=>{const e=Fi(b({noteId:Oe}),t.payload);return`${t.type}|${e.success?e.output.noteId:JSON.stringify(t.payload)}`},m={SET_ACTIVITY_NAME:y("SET_ACTIVITY_NAME","activity",b({name:w(u(),x(1))})),SET_ACTIVITY_DESCRIPTION:y("SET_ACTIVITY_DESCRIPTION","activity",b({description:u()})),SET_STORY_NAME:y("SET_STORY_NAME","story",b({name:w(u(),x(1))})),SET_STORY_DESCRIPTION:y("SET_STORY_DESCRIPTION","story",b({description:u()})),SET_STEP_NAME:y("SET_STEP_NAME","step",b({name:w(u(),x(1))})),SET_STEP_DESCRIPTION:y("SET_STEP_DESCRIPTION","step",b({description:u()})),SET_PREVIEW_KIND:y("SET_PREVIEW_KIND","preview",b({kind:he(ht)})),SET_PREVIEW_VIEWPORT:y("SET_PREVIEW_VIEWPORT","preview",b({viewport:he(vt)})),SET_PREVIEW_LABEL:y("SET_PREVIEW_LABEL","preview",b({label:u()})),REORDER_ACTIVITY:y("REORDER_ACTIVITY","activity",b({after:oe(u())}),{mode:"sequence"}),REORDER_STORY:y("REORDER_STORY","story",b({after:oe(u())}),{mode:"sequence"}),REORDER_STEP:y("REORDER_STEP","step",b({after:oe(u())}),{mode:"sequence"}),MOVE_STORY:y("MOVE_STORY","story",b({toActivity:w(u(),x(1)),after:oe(u())}),{mode:"sequence"}),MOVE_STEP:y("MOVE_STEP","step",b({toStory:w(u(),x(1)),after:oe(u())}),{mode:"sequence"}),ADD_ACTIVITY:y("ADD_ACTIVITY","page",b({id:_,name:w(u(),x(1)),description:g(u())}),{dedupeKey:se}),ADD_STORY:y("ADD_STORY","activity",b({id:_,name:w(u(),x(1)),description:g(u())}),{dedupeKey:se}),ADD_STEP:y("ADD_STEP","story",b({id:_,name:w(u(),x(1)),description:g(u()),panes:g(N(Rn))}),{dedupeKey:se}),ADD_PREVIEW:y("ADD_PREVIEW","step",wt,{dedupeKey:se}),DELETE_ACTIVITY:y("DELETE_ACTIVITY","activity",b({})),DELETE_STORY:y("DELETE_STORY","story",b({})),DELETE_STEP:y("DELETE_STEP","step",b({})),DELETE_PREVIEW:y("DELETE_PREVIEW","preview",b({})),ADD_UI_NOTE:y("ADD_UI_NOTE",O,b({id:_,body:Ne,createdAt:g(gt)}),{dedupeKey:se}),SET_UI_NOTE_BODY:y("SET_UI_NOTE_BODY",O,b({noteId:Oe,body:Ne}),{dedupeKey:Dt}),DELETE_UI_NOTE:y("DELETE_UI_NOTE",O,b({noteId:Oe}),{dedupeKey:Dt})},W={setActivityName:(t,e)=>({type:"SET_ACTIVITY_NAME",target:{type:"activity",id:t},payload:{name:e}}),setActivityDescription:(t,e)=>({type:"SET_ACTIVITY_DESCRIPTION",target:{type:"activity",id:t},payload:{description:e}}),setStoryName:(t,e)=>({type:"SET_STORY_NAME",target:{type:"story",id:t},payload:{name:e}}),setStoryDescription:(t,e)=>({type:"SET_STORY_DESCRIPTION",target:{type:"story",id:t},payload:{description:e}}),setStepName:(t,e)=>({type:"SET_STEP_NAME",target:{type:"step",id:t},payload:{name:e}}),setStepDescription:(t,e)=>({type:"SET_STEP_DESCRIPTION",target:{type:"step",id:t},payload:{description:e}}),setPreviewViewport:(t,e)=>({type:"SET_PREVIEW_VIEWPORT",target:{type:"preview",id:t},payload:{viewport:e}}),setPreviewKind:(t,e)=>({type:"SET_PREVIEW_KIND",target:{type:"preview",id:t},payload:{kind:e}}),setPreviewLabel:(t,e)=>({type:"SET_PREVIEW_LABEL",target:{type:"preview",id:t},payload:{label:e}}),reorderActivity:(t,e)=>({type:"REORDER_ACTIVITY",target:{type:"activity",id:t},payload:{after:e}}),reorderStory:(t,e)=>({type:"REORDER_STORY",target:{type:"story",id:t},payload:{after:e}}),reorderStep:(t,e)=>({type:"REORDER_STEP",target:{type:"step",id:t},payload:{after:e}}),moveStep:(t,e,i)=>({type:"MOVE_STEP",target:{type:"step",id:t},payload:{toStory:e,after:i}}),moveStory:(t,e,i)=>({type:"MOVE_STORY",target:{type:"story",id:t},payload:{toActivity:e,after:i}}),addActivity:(t,e,i)=>({type:"ADD_ACTIVITY",target:{type:"page",id:"prototype"},payload:{id:t,name:e,...i===void 0?{}:{description:i}}}),addStory:(t,e,i,n)=>({type:"ADD_STORY",target:{type:"activity",id:t},payload:{id:e,name:i,...n===void 0?{}:{description:n}}}),addStep:(t,e,i,n)=>({type:"ADD_STEP",target:{type:"story",id:t},payload:{id:e,name:i,...n===void 0?{}:{panes:n}}}),addPreview:(t,e)=>({type:"ADD_PREVIEW",target:{type:"step",id:t},payload:{...e}}),deleteActivity:t=>({type:"DELETE_ACTIVITY",target:{type:"activity",id:t},payload:{}}),deleteStory:t=>({type:"DELETE_STORY",target:{type:"story",id:t},payload:{}}),deleteStep:t=>({type:"DELETE_STEP",target:{type:"step",id:t},payload:{}}),deletePreview:t=>({type:"DELETE_PREVIEW",target:{type:"preview",id:t},payload:{}}),addUiNote:(t,e,i,n)=>({type:"ADD_UI_NOTE",target:{type:O,id:re(t)},payload:{id:e,body:i,...n===void 0?{}:{createdAt:n}}}),setUiNoteBody:(t,e,i)=>({type:"SET_UI_NOTE_BODY",target:{type:O,id:re(t)},payload:{noteId:e,body:i}}),deleteUiNote:(t,e)=>({type:"DELETE_UI_NOTE",target:{type:O,id:re(t)},payload:{noteId:e}})},Rt=(t,e)=>{const i=Gi(m,e);if(i===null)return null;const n=i.target.id;switch(i.type){case"SET_ACTIVITY_NAME":return G(t,n,s=>({...s,name:i.payload.name}));case"SET_ACTIVITY_DESCRIPTION":return G(t,n,s=>({...s,description:i.payload.description}));case"SET_STORY_NAME":return j(t,n,s=>({...s,name:i.payload.name}));case"SET_STORY_DESCRIPTION":return j(t,n,s=>({...s,description:i.payload.description}));case"SET_STEP_NAME":return me(t,n,s=>({...s,name:i.payload.name}));case"SET_STEP_DESCRIPTION":return me(t,n,s=>({...s,description:i.payload.description}));case"SET_PREVIEW_KIND":return ee(t,n,s=>({...s,kind:i.payload.kind}));case"SET_PREVIEW_VIEWPORT":return ee(t,n,s=>({...s,viewport:i.payload.viewport}));case"SET_PREVIEW_LABEL":return ee(t,n,s=>({...s,label:i.payload.label}));case"REORDER_ACTIVITY":{const{after:s}=i.payload,o=de(t.activities,n,s);return o===null?null:{...t,activities:o}}case"REORDER_STORY":{const{after:s}=i.payload,o=$(t,n);if(!o)return null;const r=s===null?null:$(t,s);if(s!==null&&(!r||r.activity!==o.activity))return null;const a=de(o.activity.stories,o.story.id,r?.story.id??null);return a===null?null:G(t,o.activity.id,d=>({...d,stories:a}))}case"REORDER_STEP":{const{after:s}=i.payload,o=S(t,n);if(!o)return null;const r=s===null?null:S(t,s);if(s!==null&&(!r||r.story!==o.story))return null;const a=de(o.story.steps,o.step.id,r?.step.id??null);return a===null?null:j(t,C(o.activity.id,o.story.id),d=>({...d,steps:a}))}case"MOVE_STORY":{const{toActivity:s,after:o}=i.payload,r=$(t,n);if(!r)return null;const a=t.activities.find(v=>v.id===s);if(!a)return null;const d=o===null?null:$(t,o);if(o!==null&&(!d||d.activity!==a))return null;const p=d?.story.id??null;if(r.activity.id===s){const v=de(r.activity.stories,r.story.id,p);return v===null?null:G(t,s,f=>({...f,stories:v}))}if(a.stories.some(v=>v.id===r.story.id))return null;const c=Me(a.stories,r.story,p);return Ce(t,v=>v.id===r.activity.id?{...v,stories:v.stories.filter(f=>f.id!==At(n))}:v.id===s?{...v,stories:c}:v)}case"MOVE_STEP":{const{toStory:s,after:o}=i.payload,r=S(t,n);if(!r)return null;const a=$(t,s);if(!a)return null;const d=o===null?null:S(t,o);if(o!==null&&(!d||d.story!==a.story))return null;const p=d?.step.id??null;if(r.story===a.story){const v=de(r.story.steps,r.step.id,p);return v===null?null:j(t,s,f=>({...f,steps:v}))}if(a.story.steps.some(v=>v.id===r.step.id))return null;const c=Me(a.story.steps,r.step,p);return Ce(t,v=>({...v,stories:v.stories.map(f=>f===r.story?{...f,steps:f.steps.filter(I=>I.id!==At(n))}:f===a.story?{...f,steps:c}:f)}))}case"ADD_ACTIVITY":{const s=i.payload;if(t.activities.some(r=>r.id===s.id))return t;const o={id:s.id,name:s.name,...s.description===void 0?{}:{description:s.description},stories:[]};return{...t,activities:[...t.activities,o]}}case"ADD_STORY":{const s=i.payload,o=t.activities.find(a=>a.id===n);if(!o)return null;if(o.stories.some(a=>a.id===s.id))return t;const r={id:s.id,name:s.name,...s.description===void 0?{}:{description:s.description},steps:[]};return G(t,n,a=>({...a,stories:[...a.stories,r]}))}case"ADD_STEP":{const s=i.payload,o=$(t,n)?.story;if(!o)return null;if(o.steps.some(d=>d.id===s.id))return t;const r=s.panes??[],a={id:s.id,name:s.name,...s.description===void 0?{}:{description:s.description},panes:r};return Wn(t,a)?j(t,n,d=>({...d,steps:[...d.steps,a]})):null}case"ADD_PREVIEW":{const s=i.payload,o=S(t,n)?.step;return o?F(o).some(r=>r.id===s.id)?t:E(t,s.id)?null:me(t,n,r=>({...r,panes:[...r.panes,{material:s}]})):null}case"DELETE_ACTIVITY":{const s=n;return t.activities.some(o=>o.id===s)?{...t,activities:t.activities.filter(o=>o.id!==s)}:null}case"DELETE_STORY":{const s=$(t,n);return s?G(t,s.activity.id,o=>({...o,stories:o.stories.filter(r=>r.id!==s.story.id)})):null}case"DELETE_STEP":{const s=S(t,n);return s?j(t,C(s.activity.id,s.story.id),o=>({...o,steps:o.steps.filter(r=>r.id!==s.step.id)})):null}case"DELETE_PREVIEW":{const s=E(t,n);return s?Nt(t,s.owner,o=>o.filter(r=>r.id!==s.preview.id)):null}case"ADD_UI_NOTE":{const{id:s,body:o,createdAt:r}=i.payload,a=Q(n),d=a===void 0?void 0:E(t,a.previewId);if(a===void 0||d===void 0)return null;if(d.preview.notes?.some(c=>c.id===s&&c.selector===a.selector))return t;if(_t(t).includes(s))return null;const p={id:s,selector:a.selector,...a.text===void 0?{}:{text:a.text},body:o,...r===void 0?{}:{createdAt:r}};return ee(t,d.preview.id,c=>({...c,notes:[...c.notes??[],p]}))}case"SET_UI_NOTE_BODY":{const{noteId:s,body:o}=i.payload,r=Q(n),a=r===void 0?void 0:E(t,r.previewId);return a?.preview.notes?.some(d=>d.id===s)?ee(t,a.preview.id,d=>({...d,notes:(d.notes??[]).map(p=>p.id===s?{...p,body:o}:p)})):null}case"DELETE_UI_NOTE":{const{noteId:s}=i.payload,o=Q(n),r=o===void 0?void 0:E(t,o.previewId);return r?.preview.notes?.some(a=>a.id===s)?ee(t,r.preview.id,a=>{const d=(a.notes??[]).filter(v=>v.id!==s),{notes:p,...c}=a;return d.length===0?c:{...c,notes:d}}):null}default:return ji(i)}},Ce=(t,e)=>({...t,activities:t.activities.map(e)}),G=(t,e,i)=>{const n=e;return t.activities.some(s=>s.id===n)?Ce(t,s=>s.id===n?i(s):s):null},j=(t,e,i)=>{const n=$(t,e);if(!n)return null;const s=n.story.id;return G(t,n.activity.id,o=>({...o,stories:o.stories.map(r=>r.id===s?i(r):r)}))},me=(t,e,i)=>{const n=S(t,e);if(!n)return null;const s=n.step.id;return j(t,C(n.activity.id,n.story.id),o=>({...o,steps:o.steps.map(r=>r.id===s?i(r):r)}))},ee=(t,e,i)=>{const n=E(t,e);if(!n)return null;const s=n.preview.id;return Nt(t,n.owner,o=>o.map(r=>r.id===s?i(r):r))},Wn=(t,e)=>{const i=F(e).map(n=>n.id);return Hn(t,e)===null&&new Set(i).size===i.length&&!i.some(n=>E(t,n))},Nt=(t,e,i)=>{if(e.kind==="step")return me(t,ae(e),s=>{const o=new Map(i([...F(s)]).map(r=>[r.id,r]));return{...s,panes:s.panes.flatMap(r=>{if(J(r))return[r];const a=o.get(r.material.id);return a?[{material:a}]:[]})}});const n=e.screen.id;return{...t,apps:t.apps.map(s=>s.id===e.app.id?{...s,screens:s.screens.map(o=>o.id===n?{...o,previews:i(o.previews)}:o)}:s)}},de=(t,e,i)=>{const n=t.findIndex(r=>r.id===e);if(n<0||i!==null&&!t.some(r=>r.id===i))return null;if(e===i)return[...t];const s=t[n];if(s===void 0)return null;const o=t.filter(r=>r.id!==e);return Me(o,s,i)},Me=(t,e,i)=>{const n=[...t],s=i===null?-1:n.findIndex(o=>o.id===i);return n.splice(s+1,0,e),n},Ot={"iphone-se":"iPhone SE","iphone-16":"iPhone 16","iphone-16-pro-max":"iPhone 16 Pro Max","pixel-7":"Pixel 7","galaxy-s24":"Galaxy S24","ipad-mini":"iPad mini","ipad-air-11":'iPad Air 11"',"ipad-pro-11":'iPad Pro 11"',"ipad-pro-13":'iPad Pro 13"'},qn={"laptop-13":'13" laptop',"laptop-15":'15" laptop',"full-hd":"Full HD","monitor-27":'27" monitor',ultrawide:"Ultrawide"},Fn={"laptop-13":"13 \u30A4\u30F3\u30C1 \u30CE\u30FC\u30C8","laptop-15":"15 \u30A4\u30F3\u30C1 \u30CE\u30FC\u30C8","full-hd":"\u30D5\u30EB HD","monitor-27":"27 \u30A4\u30F3\u30C1 \u30E2\u30CB\u30BF\u30FC",ultrawide:"\u30A6\u30EB\u30C8\u30E9\u30EF\u30A4\u30C9"},le=Ki({en:{renameActivity:"Rename Activity",updateActivityDescription:"Update Activity description",renameStory:"Rename UserStory",updateStoryDescription:"Update UserStory description",renameStep:"Rename Step",updateStepDescription:"Update Step description",changePreviewKind:"Change Preview kind",changePreviewViewport:"Change Preview viewport",changePreviewLabel:"Change Preview label",moveStory:"Move UserStory",moveStep:"Move Step",deleteTitle:"Delete",reorderTitle:t=>`Reorder ${t}`,addTitle:t=>`Add ${t}`,toFront:"\u2192 To the front",afterName:t=>`\u2192 Right after "${t}"`,unknownTarget:"(unknown target)",activityGroup:"Activity",storyGroup:"UserStory",stepGroup:"Step",screenGroup:"Screen",openInApp:"Open this screen in the app view",previewGroup:"Preview",pageGroup:"Page",uiGroup:"UI",targetLabel:(t,e)=>`${t} \xB7 ${e}`,targetMissing:(t,e)=>`${t} \xB7 ${e} (missing)`,noActivityBefore:"There are no Activities yet. Add ",noActivityAfter:" to the base JSON, or ask the agent.",deleteStepAria:"Delete step",addStepButton:"+ Step",stepNameLabel:"Step name",descriptionLabel:"Description",descriptionPlaceholder:"What happens in this Step (click to edit)",newStepName:"New step",viewLabel:"View",viewScenario:"Scenario",viewApp:"App",viewScenarioHint:"Follow one user story step by step",viewAppHint:"Use the UI as one app, whatever the scenario",appScreens:"Screens",appScreensHint:"Pick a screen to start from, then move around through the UI itself.",appSelectLabel:"App",appOutsideBrowser:"Outside the browser",noStepBefore:"There are no Steps yet. A Prototype has the meaning structure ",noStepAfter:" \u2014 one Step is one moment of the story: the screen the user is on and what they have at hand. Add a Step to the base JSON, and its screen will appear here.",noScreens:"This product has no screens yet. Declare its apps and their screens under apps[].screens in the base JSON, and they will appear here.",noPreviewMetadata:"No preview metadata \u2014 ask the agent to add it.",storyWithoutSteps:"This UserStory has no Steps yet, so there is no screen to show. Add one with + Step, or ask the agent to prototype it.",pageActor:t=>`Used by ${t}`,maximize:"Maximize",restore:"Restore size",maximizeHint:"Show the preview alone across the tab \xB7 Esc to restore",situation:"Situation",uiComment:"Comment on UI",uiCommentHint:"Click any part of the preview to comment on it \xB7 Esc to finish",commentOnElement:"Comment on element",uiCommentPin:(t,e)=>`Comment ${t}: ${e}`,uiCommentAs:"What it is",uiCommentFeedback:"Review comment",uiCommentFeedbackHint:"Sent to the Agent as a message. Gone once it is reflected.",uiCommentNote:"Note",uiCommentNoteHint:"Kept on the element as part of the prototype, shown as a badge in the scenario view.",uiNoteSubmit:"Keep",uiNotes:t=>t===1?"1 note":`${t} notes`,uiNotesOn:t=>`Notes on ${t}`,uiNoteDate:t=>Ct("en-US",t),deleteUiNoteAria:"Delete the note",editUiNoteAria:"Edit the note",editUiNoteLabel:"Note",editUiNoteHint:"Ctrl/Cmd + Enter to save, Esc to close",saveUiNote:"Save",cancelUiNote:"Cancel",closeUiNotes:"Close",addUiNote:"Add a note",editUiNote:"Edit a note",deleteUiNote:"Delete a note",mailFrom:"From",mailTo:"To",mailCc:"Cc",mailDate:"Date",demo:"Demo",demoHint:"Use the app in a browser across the tab, with nothing else on screen \xB7 Esc to finish",exitDemo:"Exit demo",browserBack:"Back",browserForward:"Forward",browserReload:"Reload",browserAddress:"Address",browserTabs:"Tabs",newTab:"New tab",closeTab:"Close tab",browserProfile:t=>`Profile: ${t}`,browserGuest:"Guest",newTabShortcuts:"Pages of this app",unreachableTitle:"This site can\u2019t be reached",unreachableBody:"No page of the prototype has this address.",device:"Device",deviceHint:"The window the app runs in: a page taller than it scrolls inside, as on the device",deviceName:t=>Ot[t]??qn[t]??t,deviceZoom:t=>`Shown at ${t}% to fit`,actions:"Actions",actionsHint:"Make the screen do something in one go, e.g. fill its form with sample data"},ja:{renameActivity:"Activity \u540D\u3092\u5909\u66F4",updateActivityDescription:"Activity \u306E\u8AAC\u660E\u3092\u66F4\u65B0",renameStory:"UserStory \u540D\u3092\u5909\u66F4",updateStoryDescription:"UserStory \u306E\u8AAC\u660E\u3092\u66F4\u65B0",renameStep:"Step \u540D\u3092\u5909\u66F4",updateStepDescription:"Step \u306E\u8AAC\u660E\u3092\u66F4\u65B0",changePreviewKind:"Preview \u306E\u7A2E\u5225\u3092\u5909\u66F4",changePreviewViewport:"Preview \u306E\u30D3\u30E5\u30FC\u30DD\u30FC\u30C8\u3092\u5909\u66F4",changePreviewLabel:"Preview \u306E\u30E9\u30D9\u30EB\u3092\u5909\u66F4",moveStory:"UserStory \u3092\u79FB\u52D5",moveStep:"Step \u3092\u79FB\u52D5",deleteTitle:"\u524A\u9664",reorderTitle:t=>`${t} \u306E\u9806\u5E8F\u3092\u5909\u66F4`,addTitle:t=>`${t} \u3092\u8FFD\u52A0`,toFront:"\u2192 \u5148\u982D\u3078",afterName:t=>`\u2192 "${t}" \u306E\u76F4\u5F8C\u3078`,unknownTarget:"(unknown target)",activityGroup:"Activity",storyGroup:"UserStory",stepGroup:"Step",screenGroup:"\u753B\u9762",openInApp:"\u3053\u306E\u753B\u9762\u3092\u30A2\u30D7\u30EA\u30D3\u30E5\u30FC\u3067\u958B\u304F",previewGroup:"Preview",pageGroup:"Page",uiGroup:"UI",targetLabel:(t,e)=>`${t} \xB7 ${e}`,targetMissing:(t,e)=>`${t} \xB7 ${e} (missing)`,noActivityBefore:"Activity \u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002base JSON \u306E ",noActivityAfter:" \u3092\u8FFD\u52A0\u3059\u308B\u304B\u3001Agent \u306B\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",deleteStepAria:"\u30B9\u30C6\u30C3\u30D7\u3092\u524A\u9664",addStepButton:"+ Step",stepNameLabel:"Step \u540D",descriptionLabel:"\u8AAC\u660E",descriptionPlaceholder:"\u3053\u306E Step \u3067\u4F55\u304C\u8D77\u304D\u308B\u304B\uFF08\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u7DE8\u96C6\uFF09",newStepName:"\u65B0\u3057\u3044\u30B9\u30C6\u30C3\u30D7",viewLabel:"\u8868\u793A",viewScenario:"\u30B7\u30CA\u30EA\u30AA",viewApp:"\u30A2\u30D7\u30EA",viewScenarioHint:"\u30E6\u30FC\u30B6\u30FC\u30B9\u30C8\u30FC\u30EA\u30FC\u306B\u6CBF\u3063\u3066 Step \u3092\u9806\u306B\u305F\u3069\u308B",viewAppHint:"\u30B7\u30CA\u30EA\u30AA\u306B\u95A2\u4FC2\u306A\u304F\u3001UI \u3092 1 \u3064\u306E\u30A2\u30D7\u30EA\u3068\u3057\u3066\u89E6\u308B",appScreens:"\u753B\u9762",appScreensHint:"\u8D77\u70B9\u306B\u3059\u308B\u753B\u9762\u3092\u9078\u3073\u3001\u3042\u3068\u306F UI \u306E\u30EA\u30F3\u30AF\u3067\u79FB\u52D5\u3057\u307E\u3059\u3002",appSelectLabel:"\u30A2\u30D7\u30EA",appOutsideBrowser:"\u30D6\u30E9\u30A6\u30B6\u4EE5\u5916",noStepBefore:"Step \u304C\u307E\u3060\u3042\u308A\u307E\u305B\u3093\u3002Prototype \u306F ",noStepAfter:" \u306E\u610F\u5473\u69CB\u9020\u3092\u6301\u3061\u30011 Step = \u30B7\u30CA\u30EA\u30AA\u306E 1 \u5834\u9762\uFF08\u30E6\u30FC\u30B6\u30FC\u304C\u3044\u308B\u753B\u9762\u3068\u3001\u624B\u5143\u306B\u3042\u308B\u3082\u306E\uFF09\u3067\u3059\u3002base JSON \u306B Step \u3092\u8FFD\u52A0\u3059\u308B\u3068\u3001\u3053\u3053\u306B\u305D\u306E\u753B\u9762\u304C\u73FE\u308C\u307E\u3059\u3002",noScreens:"\u3053\u306E\u30D7\u30ED\u30C0\u30AF\u30C8\u306B\u306F\u307E\u3060\u753B\u9762\u304C\u3042\u308A\u307E\u305B\u3093\u3002base JSON \u306E apps[].screens \u306B\u30A2\u30D7\u30EA\u3068\u753B\u9762\u3092\u5BA3\u8A00\u3059\u308B\u3068\u3001\u3053\u3053\u306B\u73FE\u308C\u307E\u3059\u3002",noPreviewMetadata:"preview metadata \u304C\u3042\u308A\u307E\u305B\u3093 \u2014 \u8FFD\u52A0\u306F Agent \u306B\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044",storyWithoutSteps:"\u3053\u306E UserStory \u306B\u306F\u307E\u3060 Step \u304C\u306A\u304F\u3001\u898B\u305B\u308B\u753B\u9762\u304C\u3042\u308A\u307E\u305B\u3093\u3002+ Step \u3067\u8FFD\u52A0\u3059\u308B\u304B\u3001Agent \u306B\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u3092\u4F9D\u983C\u3057\u3066\u304F\u3060\u3055\u3044\u3002",pageActor:t=>`\u5229\u7528\u8005: ${t}`,maximize:"\u6700\u5927\u5316",restore:"\u5143\u306E\u30B5\u30A4\u30BA\u306B\u623B\u3059",maximizeHint:"\u30D7\u30EC\u30D3\u30E5\u30FC\u3060\u3051\u3092\u30BF\u30D6\u3044\u3063\u3071\u3044\u306B\u8868\u793A \xB7 Esc \u3067\u623B\u308B",situation:"\u72B6\u6CC1",uiComment:"UI \u306B\u30B3\u30E1\u30F3\u30C8",uiCommentHint:"\u30D7\u30EC\u30D3\u30E5\u30FC\u306E\u8981\u7D20\u3092\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u30B3\u30E1\u30F3\u30C8 \xB7 Esc \u3067\u7D42\u4E86",commentOnElement:"\u8981\u7D20\u306B\u30B3\u30E1\u30F3\u30C8",uiCommentPin:(t,e)=>`\u30B3\u30E1\u30F3\u30C8 ${t}: ${e}`,uiCommentAs:"\u30B3\u30E1\u30F3\u30C8\u306E\u7A2E\u985E",uiCommentFeedback:"\u30EC\u30D3\u30E5\u30FC\u30B3\u30E1\u30F3\u30C8",uiCommentFeedbackHint:"Agent \u3078\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u3057\u3066\u9001\u4FE1\u3055\u308C\u307E\u3059\u3002\u53CD\u6620\u3055\u308C\u308B\u3068\u6D88\u3048\u307E\u3059\u3002",uiCommentNote:"\u30E1\u30E2",uiCommentNoteHint:"\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u306E\u4E00\u90E8\u3068\u3057\u3066\u8981\u7D20\u306B\u6B8B\u308A\u3001\u30B7\u30CA\u30EA\u30AA\u30D3\u30E5\u30FC\u3067\u30D0\u30C3\u30B8\u3068\u3057\u3066\u8868\u793A\u3055\u308C\u307E\u3059\u3002",uiNoteSubmit:"\u6B8B\u3059",uiNotes:t=>`\u30E1\u30E2 ${t} \u4EF6`,uiNotesOn:t=>`${t} \u306E\u30E1\u30E2`,uiNoteDate:t=>Ct("ja-JP",t),deleteUiNoteAria:"\u30E1\u30E2\u3092\u524A\u9664",editUiNoteAria:"\u30E1\u30E2\u3092\u7DE8\u96C6",editUiNoteLabel:"\u30E1\u30E2",editUiNoteHint:"Ctrl/Cmd + Enter \u3067\u4FDD\u5B58\u3001Esc \u3067\u9589\u3058\u308B",saveUiNote:"\u4FDD\u5B58",cancelUiNote:"\u30AD\u30E3\u30F3\u30BB\u30EB",closeUiNotes:"\u9589\u3058\u308B",addUiNote:"\u30E1\u30E2\u3092\u8FFD\u52A0",editUiNote:"\u30E1\u30E2\u3092\u7DE8\u96C6",deleteUiNote:"\u30E1\u30E2\u3092\u524A\u9664",mailFrom:"\u5DEE\u51FA\u4EBA",mailTo:"\u5B9B\u5148",mailCc:"Cc",mailDate:"\u65E5\u6642",demo:"\u30C7\u30E2",demoHint:"\u307B\u304B\u306B\u4F55\u3082\u51FA\u3055\u305A\u3001\u30BF\u30D6\u3044\u3063\u3071\u3044\u306E\u30D6\u30E9\u30A6\u30B6\u3067\u30A2\u30D7\u30EA\u3092\u89E6\u308B \xB7 Esc \u3067\u7D42\u4E86",exitDemo:"\u30C7\u30E2\u3092\u7D42\u4E86",browserBack:"\u623B\u308B",browserForward:"\u9032\u3080",browserReload:"\u518D\u8AAD\u307F\u8FBC\u307F",browserAddress:"\u30A2\u30C9\u30EC\u30B9",browserTabs:"\u30BF\u30D6",newTab:"\u65B0\u3057\u3044\u30BF\u30D6",closeTab:"\u30BF\u30D6\u3092\u9589\u3058\u308B",browserProfile:t=>`\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB: ${t}`,browserGuest:"\u30B2\u30B9\u30C8",newTabShortcuts:"\u3053\u306E\u30A2\u30D7\u30EA\u306E\u30DA\u30FC\u30B8",unreachableTitle:"\u3053\u306E\u30B5\u30A4\u30C8\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093",unreachableBody:"\u30D7\u30ED\u30C8\u30BF\u30A4\u30D7\u306B\u3053\u306E\u30A2\u30C9\u30EC\u30B9\u306E\u30DA\u30FC\u30B8\u306F\u3042\u308A\u307E\u305B\u3093\u3002",device:"\u30C7\u30D0\u30A4\u30B9",deviceHint:"\u30A2\u30D7\u30EA\u3092\u52D5\u304B\u3059\u753B\u9762\u306E\u5927\u304D\u3055\u3002\u53CE\u307E\u3089\u306A\u3044\u30DA\u30FC\u30B8\u306F\u5B9F\u6A5F\u3068\u540C\u3058\u304F\u753B\u9762\u306E\u4E2D\u3067\u30B9\u30AF\u30ED\u30FC\u30EB\u3059\u308B",deviceName:t=>Ot[t]??Fn[t]??t,deviceZoom:t=>`\u53CE\u307E\u308B\u3088\u3046 ${t}% \u3067\u8868\u793A`,actions:"\u30A2\u30AF\u30B7\u30E7\u30F3",actionsHint:"\u30D5\u30A9\u30FC\u30E0\u306B\u30B5\u30F3\u30D7\u30EB\u30C7\u30FC\u30BF\u3092\u5165\u308C\u308B\u306A\u3069\u3001\u753B\u9762\u306B\u7528\u610F\u3055\u308C\u305F\u64CD\u4F5C\u3092\u4E00\u5EA6\u306B\u884C\u3046"}}),Ct=(t,e)=>new Intl.DateTimeFormat(t,{dateStyle:"medium",timeStyle:"short"}).format(new Date(e)),Gn=["scenario","app"],V="view",pe=t=>t[V]==="app"?"app":"scenario",Mt=t=>({[V]:t==="app"?"app":null}),ce=(t,e)=>t===void 0?`\u2192 "${e}"`:`"${t}" \u2192 "${e}"`,jn=t=>({SET_ACTIVITY_NAME:(e,i)=>({title:t.renameActivity,tone:"update",body:ce(U(i,e.target.id)?.name,k(m.SET_ACTIVITY_NAME,e).name)}),SET_ACTIVITY_DESCRIPTION:(e,i)=>({title:t.updateActivityDescription,tone:"update",body:we(U(i,e.target.id)?.description,k(m.SET_ACTIVITY_DESCRIPTION,e).description)}),SET_STORY_NAME:(e,i)=>({title:t.renameStory,tone:"update",body:ce($(i,e.target.id)?.story.name,k(m.SET_STORY_NAME,e).name)}),SET_STORY_DESCRIPTION:(e,i)=>({title:t.updateStoryDescription,tone:"update",body:we($(i,e.target.id)?.story.description,k(m.SET_STORY_DESCRIPTION,e).description)}),SET_STEP_NAME:(e,i)=>({title:t.renameStep,tone:"update",body:ce(S(i,e.target.id)?.step.name,k(m.SET_STEP_NAME,e).name)}),SET_STEP_DESCRIPTION:(e,i)=>({title:t.updateStepDescription,tone:"update",body:we(S(i,e.target.id)?.step.description,k(m.SET_STEP_DESCRIPTION,e).description)}),SET_PREVIEW_KIND:(e,i)=>({title:t.changePreviewKind,tone:"update",body:ce(E(i,e.target.id)?.preview.kind,k(m.SET_PREVIEW_KIND,e).kind)}),SET_PREVIEW_VIEWPORT:(e,i)=>({title:t.changePreviewViewport,tone:"update",body:ce(E(i,e.target.id)?.preview.viewport,k(m.SET_PREVIEW_VIEWPORT,e).viewport)}),SET_PREVIEW_LABEL:e=>({title:t.changePreviewLabel,tone:"update",body:`\u2192 "${k(m.SET_PREVIEW_LABEL,e).label}"`}),REORDER_ACTIVITY:e=>Ue(t,t.activityGroup,k(m.REORDER_ACTIVITY,e).after),REORDER_STORY:e=>Ue(t,t.storyGroup,k(m.REORDER_STORY,e).after),REORDER_STEP:e=>Ue(t,t.stepGroup,k(m.REORDER_STEP,e).after),MOVE_STORY:(e,i)=>({title:t.moveStory,tone:"move",body:`\u2192 ${U(i,k(m.MOVE_STORY,e).toActivity)?.name??k(m.MOVE_STORY,e).toActivity}`}),MOVE_STEP:(e,i)=>({title:t.moveStep,tone:"move",body:`\u2192 ${$(i,k(m.MOVE_STEP,e).toStory)?.story.name??k(m.MOVE_STEP,e).toStory}`}),ADD_ACTIVITY:e=>ye(t,t.activityGroup,k(m.ADD_ACTIVITY,e).name),ADD_STORY:e=>ye(t,t.storyGroup,k(m.ADD_STORY,e).name),ADD_STEP:e=>ye(t,t.stepGroup,k(m.ADD_STEP,e).name),ADD_PREVIEW:e=>ye(t,t.previewGroup,k(m.ADD_PREVIEW,e).label??k(m.ADD_PREVIEW,e).id),DELETE_ACTIVITY:(e,i)=>be(t,U(i,e.target.id)?.name),DELETE_STORY:(e,i)=>be(t,$(i,e.target.id)?.story.name),DELETE_STEP:(e,i)=>be(t,S(i,e.target.id)?.step.name),DELETE_PREVIEW:(e,i)=>be(t,E(i,e.target.id)?.preview.label),ADD_UI_NOTE:e=>({title:t.addUiNote,tone:"create",body:`+ "${Le(k(m.ADD_UI_NOTE,e).body)}"`}),SET_UI_NOTE_BODY:(e,i)=>{const{noteId:n,body:s}=k(m.SET_UI_NOTE_BODY,e);return{title:t.editUiNote,tone:"update",body:we(Yt(i,n)?.body,s)}},DELETE_UI_NOTE:(e,i)=>{const{noteId:n}=k(m.DELETE_UI_NOTE,e),s=Yt(i,n);return{title:t.deleteUiNote,tone:"delete",body:s===void 0?t.unknownTarget:`\u2212 "${Le(s.body)}"`}}}),we=(t,e)=>{const i=e.length>90?`${e.slice(0,90)}\u2026`:e;return t===void 0||t===""?`\u2192 "${i}"`:`"${Le(t)}" \u2192 "${i}"`},Le=t=>t.length>60?`${t.slice(0,60)}\u2026`:t,Ue=(t,e,i)=>({title:t.reorderTitle(e),tone:"move",body:i===null?t.toFront:t.afterName(i)}),ye=(t,e,i)=>({title:t.addTitle(e),tone:"create",body:`+ "${i}"`}),be=(t,e)=>({title:t.deleteTitle,tone:"delete",body:e===void 0?t.unknownTarget:`\u2212 "${e}"`}),Lt=(t,e,i,n)=>{const s=jn(t),o=Object.hasOwn(s,e.type)?s[e.type]:void 0,r=o?o(e,n??i):{title:e.type,tone:"meta"};return{title:r.title,targetLabel:Vt(t,i,e.target),tone:r.tone,...r.body===void 0?{}:{summary:r.body}}},Ut=t=>`${t.type} ${Y(t.target)} ${JSON.stringify(t.payload)}`,Vt=(t,e,i)=>{switch(i.type){case"activity":{const n=U(e,i.id);return n?t.targetLabel(t.activityGroup,n.name):t.targetMissing(t.activityGroup,i.id)}case"story":{const n=$(e,i.id)?.story;return n?t.targetLabel(t.storyGroup,n.name):t.targetMissing(t.storyGroup,i.id)}case"step":{const n=S(e,i.id)?.step;return n?t.targetLabel(t.stepGroup,n.name):t.targetMissing(t.stepGroup,i.id)}case"screen":{const n=L(e,i.id)?.screen;return n?t.targetLabel(t.screenGroup,n.title):t.targetMissing(t.screenGroup,i.id)}case"preview":{const n=E(e,i.id)?.preview;return n?t.targetLabel(t.previewGroup,n.label??n.id):t.targetMissing(t.previewGroup,i.id)}case"page":return t.targetLabel(t.pageGroup,He(e));case O:{const n=Q(i.id),s=n?E(e,n.previewId)?.preview:void 0;return n&&s?t.targetLabel(t.uiGroup,Ve(s,n)):t.targetMissing(t.uiGroup,i.id)}default:return t.targetLabel(i.type,i.id)}},Ve=(t,e)=>{const i=e.text===void 0?e.selector:`"${e.text}"`;return`${t.label??t.id} \u203A ${i}`},zt=(t,e)=>{const i=[];for(const n of t){if(n.target.type!==O)continue;const s=Q(n.target.id);!s||!e.includes(s.previewId)||i.push({id:n.id,previewId:s.previewId,selector:s.selector,number:i.length+1,body:Qe(n)})}return i},Kn=(t,e)=>e.flatMap(i=>{const n=E(t,i)?.preview,s=new Map;for(const o of n?.notes??[])s.set(o.selector,[...s.get(o.selector)??[],o]);return n===void 0?[]:[...s].map(([o,r])=>({previewId:i,selector:o,label:Ve(n,{selector:o,...Xn(r)}),notes:r}))}),Xn=t=>{const e=[...t].reverse().find(i=>i.text!==void 0)?.text;return e===void 0?{}:{text:e}},Yt=(t,e)=>It(t).flatMap(i=>i.notes??[]).find(i=>i.id===e),Ht=(t,e)=>zt(t,e).length,Zn=/^[a-z][a-z0-9+.-]*:/i,Jn=t=>{const e=t.baseUrl?.trim(),i=Xi(t.title??"");return`${(e?e.startsWith("http")?e:`https://${e}`:`https://${i==="item"?"page":i}.example.com`).replace(/\/+$/,"")}/`},ke=(t,e,i=null)=>{const n=Jn(t),s=i==null||i===""?e.url:i;if(!s)return`${n}${e.id}`;if(Zn.test(s))return s;try{return decodeURI(new URL(s,n).href)}catch{return s}},Qn=t=>{switch(t.type){case"activity":return{[V]:null,activity:t.id};case"story":return{[V]:null,activity:null,story:t.id};case"step":return{[V]:null,activity:null,story:null,step:t.id};case"screen":return{screen:t.id};default:return null}},Bt=(t,e)=>{const i=t.kind==="screen"?[{type:"screen",id:t.screen.id}]:[{type:"activity",id:t.activity.id},{type:"story",id:C(t.activity.id,t.story.id)},...t.kind==="step"?[{type:"step",id:ae(t)}]:[]];for(const n of e?.panes??[])n.kind==="screen"&&i.push({type:"screen",id:n.screen.screen.id});return[...new Set(i.map(Y))].join(" ")},ze=",",Wt=t=>t.preview?.split(ze)??[],es=(t,e)=>t.kind===e.kind&&t.viewport===e.viewport,qt=(t,e,i)=>{const n=e.find(o=>i.includes(o.id));if(n)return n;const s=i.flatMap(o=>E(t,o)?.preview??[]);return e.find(o=>s.some(r=>es(o,r)))??e[0]},Ft=(t,e,i,n)=>{const s=e.screen.previews,o=i===void 0?qt(t,s,Wt(n)):s.find(a=>a.id===i);if(!o)return;const r=i===void 0&&s.length>1;return{kind:"screen",screen:e,preview:o,pinned:i!==void 0,tabs:r?s:[]}},Gt=t=>({layout:t.length>1?"side-by-side":"single",panes:t,shown:t.map(e=>e.preview)}),jt=(t,e,i)=>e.panes.flatMap(n=>{if(!J(n))return[{kind:"material",preview:n.material}];const s=L(t,n.screen),o=s&&Ft(t,s,n.preview,i);return o?[o]:[]}),Ye=(t,e,i)=>{if(e.kind==="screen"){const n=Ft(t,e,void 0,i);return Gt(n?[n]:[])}return Gt(jt(t,e.step,i))},ts=(t,e)=>t.panes.flatMap(i=>i.kind!=="screen"||i.tabs.length===0?[]:[i.tabs.some(n=>n.id===e)?e:i.preview.id]).join(ze),Kt=(t,e)=>{const i=new Map;for(const n of e){const s=E(t,n)?.owner;if(s?.kind!=="screen"||s.screen.actions.length===0)continue;const o=i.get(s.screen.id)??{screen:s.screen,previewIds:[]};o.previewIds.push(n),i.set(s.screen.id,o)}return[...i.values()].map(({screen:n,previewIds:s})=>({screen:n,previewIds:s,actions:n.actions}))},is=(t,e)=>[...F(e),...fe(t,e).flatMap(i=>i.screen.previews)],ns=["activity","story","step","screen","preview"],ss=(t,e,i)=>{switch(e){case"activity":return U(t,i)!==void 0;case"story":return $(t,i)!==void 0||t.activities.some(n=>n.stories.some(s=>s.id===i));case"step":return S(t,i)!==void 0||B(t).some(n=>n.step.id===i);case"screen":return L(t,i)!==void 0;case"preview":return E(t,i)!==void 0;default:return!1}},os=(t,e)=>{let i;if(e.navigate!==null)i=e.navigate.includes("=")?e.navigate:`step=${e.navigate}`;else{const o=e.href?.trim()??"";if(o===""||o==="#"||o.toLowerCase().startsWith("javascript:"))return"no-destination";if(!o.startsWith("#"))return null;i=o}const n=_e(i),s=ns.filter(o=>n[o]!==void 0);return s.length===0?e.navigate===null?null:"unknown-target":s.every(o=>ss(t,o,n[o]??""))?null:"unknown-target"},rs=(t,e)=>{const i=e.mail??{},n=[{label:t.mailFrom,value:i.from},{label:t.mailTo,value:i.to},{label:t.mailCc,value:i.cc},{label:t.mailDate,value:i.date}].flatMap(r=>r.value===void 0||r.value.trim()===""?[]:[{label:r.label,value:r.value}]),s=i.from?.replace(/<[^>]*>/g,"").replace(/["']/g,"").trim()||i.from?.trim(),o=s?Array.from(s)[0]?.toUpperCase():void 0;return{...i.subject===void 0||i.subject.trim()===""?{}:{subject:i.subject},...s?{sender:s}:{},...o===void 0?{}:{initial:o},rows:n}},Xt=(t,e)=>{const i=[];for(const n of e.activities){i.push({value:Y({type:"activity",id:n.id}),label:n.name,group:t.activityGroup});for(const s of n.stories){i.push({value:Y({type:"story",id:C(n.id,s.id)}),label:`${n.name} \u203A ${s.name}`,group:t.storyGroup});for(const o of s.steps)i.push({value:Y({type:"step",id:ge(n,s,o)}),label:`${s.name} \u203A ${o.name}`,group:t.stepGroup})}}for(const{app:n,screen:s}of H(e))i.push({value:Y({type:"screen",id:s.id}),label:`${n.name} \u203A ${s.title}`,group:t.screenGroup});return i},as=(t,e,i)=>{const n=te(e,i);if(n?.kind==="screen"){const{screen:s}=n;return{value:Y({type:"screen",id:s.id}),label:s.title,group:t.screenGroup}}return n?.kind!=="step"?null:{value:Y({type:"step",id:ae(n)}),label:n.step.name,group:t.stepGroup}},te=(t,e)=>{if(pe(e)==="app"){const o=L(t,e.screen);return o?{kind:"screen",...o}:void 0}const i=S(t,e.step);if(i)return{kind:"step",...i};const n=U(t,e.activity),s=n?.stories.find(o=>o.id===e.story||C(n.id,o.id)===e.story);return n&&s?{kind:"story",activity:n,story:s}:void 0},Zt=(t,e)=>{const i=(d,p)=>p===void 0?{title:d}:{actor:p,title:d};if(e.kind==="screen")return i(e.screen.title,e.app.actor);const{activity:n,story:s,step:o}=e,r=fe(t,o),a=r.length===1?r[0]:void 0;return i(a?.screen.title??o.name,o.actor??s.actor??n.actor??a?.app.actor)},ds=(t,e)=>{const i=e.actor??t.actor;return i===void 0?{title:e.name}:{actor:i,title:e.name}},He=t=>t.title??"UX Prototype",Jt=(t,e)=>(e?t.preview=e:delete t.preview,t),ls=(t,e,i)=>{if(!e)return;const n=jt(t,e,i).flatMap(s=>s.kind==="screen"&&!s.pinned?[s.preview.id]:[]);return n.length===0?void 0:n.join(ze)},Qt=(t,e)=>{const i=()=>{if(e.step===void 0&&e.story===void 0)return;const o=ei(t,{...e,[V]:""}),r=S(t,o.step);return r&&fe(t,r.step)[0]},n=L(t,e.screen)??i()??H(t)[0],s={...e,[V]:"app"};for(const o of["activity","story","step"])delete s[o];return n?s.screen=n.screen.id:delete s.screen,Jt(s,n&&qt(t,n.screen.previews,Wt(e))?.id)},ps=(t,e,i)=>{const n=r=>Bn(r.step,e);if(i&&n(i))return i;const s=i?.story.steps??[],o=r=>{const a=s[r];return i&&a?{...i,step:a,stepIndex:r}:void 0};for(let r=(i?.stepIndex??0)+1;r<s.length;r+=1){const a=o(r);if(a&&n(a))return a}for(let r=(i?.stepIndex??0)-1;r>=0;r-=1){const a=o(r);if(a&&n(a))return a}return B(t).find(n)},ei=(t,e)=>{const i=U(t,e.activity),n=e.story,s=i?.stories.find(z=>z.id===n||C(i.id,z.id)===n),o=s&&i?{activity:i,story:s}:$(t,n),r=e.step,d=(o&&r?S(t,`${C(o.activity.id,o.story.id)}.${r}`):void 0)??S(t,r),p=e.screen,c=p===void 0?void 0:ps(t,p,d);if(p!==void 0&&!c&&L(t,p))return Qt(t,{...e,[V]:"app"});const v=c??d,f=v?.activity??o?.activity??i??t.activities[0],I=v?.story??(o&&o.activity===f?o.story:void 0)??f?.stories[0],P=v?.step??I?.steps[0],T={...e};return delete T.screen,f?T.activity=f.id:delete T.activity,I&&f?T.story=$(t,I.id)?I.id:C(f.id,I.id):delete T.story,P&&I&&f?T.step=S(t,P.id)?P.id:ge(f,I,P):delete T.step,delete T[V],Jt(T,ls(t,P,e))},cs=["activity","story","step","screen"],xe=(t,e)=>pe(e)==="app"?Qt(t,e):ei(t,e),us=(t,e)=>{const i=e.screen.previews.find(o=>o.kind==="browser");if(!i)return;let n;try{n=new URL(ke(t,i),"https://page.example.com")}catch{return}const s=n.pathname.split("/").filter(o=>o!=="").map(o=>{try{return decodeURIComponent(o)}catch{return o}});return{origin:n.origin,segments:s}},ti=()=>({screens:[],children:new Map}),Be=(t,e,i)=>{const[n,...s]=t.children.entries();if(t.screens.length===0&&n&&s.length===0&&i!=="/"){const[o,r]=n;return Be(r,`${e}/${o}`,`${i}/${o}`)}return{segment:e,path:i,screens:t.screens,children:[...t.children.entries()].map(([o,r])=>Be(r,`/${o}`,`${i==="/"?"":i}/${o}`))}},hs=t=>{const e=new Map;for(const[i,n]of t){const s=e.get(n.origin)??ti();e.set(n.origin,s);let o=s;for(const r of n.segments){const a=o.children.get(r)??ti();o.children.set(r,a),o=a}o.screens.push(i)}return[...e.entries()].map(([i,n])=>({origin:i,root:Be(n,"/","/")}))},vs=(t,e)=>{const i=e.screens.map(o=>({app:e,screen:o})),n=[],s=[];for(const o of i){const r=us(t,o);r?n.push([o,r]):s.push(o)}return{app:e,screens:i,trees:hs(n),others:s}},ii=t=>t.apps.map(e=>vs(t,e)).filter(e=>e.screens.length>0),ni=(t,e)=>e?.kind!=="screen"?t[0]:t.find(i=>i.app.id===e.app.id)??t[0],fs=(t,e)=>{switch(e.type){case"activity":return U(t,e.id)!==void 0;case"story":return $(t,e.id)!==void 0;case"step":return S(t,e.id)!==void 0;case"screen":return L(t,e.id)!==void 0;case"preview":return E(t,e.id)!==void 0;case"page":return!0;case O:{const i=Q(e.id);return i!==void 0&&E(t,i.previewId)!==void 0}default:return!1}},si=t=>{const e=le(t);return{kind:"view",name:"prototype",label:"UX Prototype",addable:!1,parseBase:$t,emptyBase:Tt,actions:m,apply:Rt,hasTarget:fs,canonicalTarget:(i,n)=>{if(n.type==="step"){const s=S(i,n.id);return s?{...n,id:ae(s)}:n}if(n.type==="story"){const s=$(i,n.id);return s?{...n,id:C(s.activity.id,s.story.id)}:n}if(n.type==="preview"){const s=E(i,n.id);return s?{...n,id:s.preview.id}:n}return n},describe:(i,n,s)=>Lt(e,i,n,s),serialize:Ut,resolveNavigation:xe,navigationHierarchy:cs,navigationFor:(i,n)=>Qn(n),commentTargets:(i,n)=>Xt(e,i),currentTarget:(i,n)=>as(e,i,n),title:He}},gs=(t,e)=>{const i=e.flatMap(n=>{const s=Math.max(n.left,t.left)-t.left,o=Math.max(n.top,t.top)-t.top,r=Math.min(n.right,t.right)-t.left-s,a=Math.min(n.bottom,t.bottom)-t.top-o;return r>0&&a>0?[`M${s} ${o}h${r}v${a}h-${r}Z`]:[]});return i.length===0?"none":`path(evenodd, 'M0 0H${t.width}V${t.height}H0Z ${i.join(" ")}')`},Ee="data-dpk-modal",ms=t=>{try{return t.matches(":modal")}catch{return!1}},oi=t=>{t.setAttribute(Ee,""),t.open||t.show()},ri=t=>{Object.hasOwn(t,"showModal")||Object.defineProperty(t,"showModal",{configurable:!0,value:()=>oi(t)})},ai=(t,e)=>{if(!ms(e))return;const i=n=>{n.target===e&&(n.stopImmediatePropagation(),t.removeEventListener("close",i,!0))};t.addEventListener("close",i,!0),e.close(),oi(e)},di=(t,e)=>{try{return Array.from(t.querySelectorAll(e))}catch{return[]}},ws=(t,e)=>{const i=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value");i?.set?i.set.call(t,e):t.value=e},ys=t=>t instanceof HTMLInputElement&&(t.type==="checkbox"||t.type==="radio"),bs=(t,e)=>{if(ys(t)){const n=typeof e=="boolean"?e:t.value===e;return typeof e=="string"&&!n?!1:(t.checked=n,!0)}const i=String(e);return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?(ws(t,i),!0):(t.textContent=i,!1)},ks=(t,e)=>{const i=[];for(const[n,s]of Object.entries(e)){const o=di(t,n);o.length===0&&i.push(n);for(const r of o)bs(r,s)&&(r.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),r.dispatchEvent(new Event("change",{bubbles:!0})))}return i},xs=(t,e)=>{const i=[];for(const n of e){const[s]=di(t,n);s instanceof HTMLElement?s.click():i.push(n)}return i},Es='a, button, input, select, textarea, label, summary, [role="button"], [role="link"], [role="tab"]',li=/^-?[A-Za-z_][\w-]*$/,pi=40,Ss=(t,e)=>{const i=t.closest(Es);return i!==null&&i!==e&&e.contains(i)?i:t},Se=t=>{const e=t.replace(/\s+/g," ").trim();if(e==="")return;const i=Array.from(e);return i.length>pi?`${i.slice(0,pi).join("")}\u2026`:e},$s=t=>{const e=t.getAttribute("aria-label")??t.getAttribute("title");if(e)return Se(e);const i=t.tagName.toLowerCase();return Se(i==="input"||i==="textarea"||i==="select"?t.getAttribute("placeholder")??t.getAttribute("name")??"":i==="img"?t.getAttribute("alt")??"":t.textContent??"")},Ts=t=>{const e=t.getAttribute("id");if(e&&li.test(e))return`#${e}`;const i=t.tagName.toLowerCase(),n=Array.from(t.classList).filter(a=>li.test(a)).slice(0,2).map(a=>`.${a}`).join(""),s=t.parentElement,o=s?Array.from(s.children).filter(a=>a.tagName===t.tagName):[],r=o.length>1?`:nth-of-type(${o.indexOf(t)+1})`:"";return`${i}${n}${r}`},As=(t,e,i)=>{try{const n=t.querySelectorAll(e);return n.length===1&&n[0]===i}catch{return!1}},Is=(t,e)=>{const i=[];let n=t;for(;n!==null&&n!==e;){const o=Ts(n);if(i.unshift(o),o.startsWith("#")||As(e,i.join(" > "),t))break;n=n.parentElement}const s=$s(t);return{selector:i.length===0?":scope":i.join(" > "),tag:t.tagName.toLowerCase(),...s===void 0?{}:{text:s}}},_s=(t,e)=>{if(e===":scope")return t;try{return t.querySelector(e)}catch{return null}},ci=(t,e)=>{const i=xe(t,e),n=te(t,i);if(n?.kind!=="screen")return null;const[s]=Ye(t,n,i).shown;return s?.kind!=="browser"?null:{screen:n.screen.id,preview:s.id}},$e=(t,e)=>{const i=te(t,xe(t,{[V]:"app",...e}));return i?.kind==="screen"?i:void 0},Ps=(t,e,i,n=new Map)=>{const s=dt(e,i);if(s===null)return null;const o=lt(s);for(const{screen:r}of H(t))for(const a of r.previews){if(a.kind!=="browser")continue;const d=dt(ke(t,a,n.get(a.id)),i);if(d!==null&&lt(d)===o)return{screen:r.id,preview:a.id}}return null},Ds=(t,e,i)=>e===void 0||e.kind==="new-tab"?i.newTab:e.kind==="unreachable"?rt(e.url):$e(t,e.page)?.screen.title??i.newTab,ui=(t,e,i)=>{if(e===void 0||e.kind==="new-tab")return"";if(e.kind==="unreachable")return e.url;const n=$e(t,e.page)?.screen.previews.find(s=>s.id===e.page.preview);return n===void 0?"":ke(t,n,i.get(n.id))},hi=t=>{const e=at(t);for(let i=e.index;i>=0;i-=1){const n=e.history[i];if(n?.kind==="page")return n.page}for(const i of t.tabs){const n=i.history[i.index];if(n?.kind==="page")return n.page}},Rs=(t,e)=>e===void 0?void 0:$e(t,e)?.app.actor,vi=(t,e,i,n=null,s=new Map)=>{const o=at(e),r=o.history[o.index],a=Rs(t,hi(e)??n??void 0);return{tabs:e.tabs.map(d=>({id:d.id,title:Ds(t,d.history[d.index],i),url:ui(t,d.history[d.index],s),active:d.id===o.id})),entry:r,url:ui(t,r,s),canBack:vn(e),canForward:hn(e),...a===void 0?{}:{profile:a}}},Ns=t=>hi(t)??null,Os=(t,e)=>{const i=e===null?void 0:$e(t,e),n=ni(ii(t),i),s=[],o=(r,a)=>{for(const{screen:d}of a.screens){const p=d.previews.find(c=>c.kind==="browser");p!==void 0&&s.push({title:d.title,url:`${r}${a.path==="/"?"":a.path}`,page:{screen:d.id,preview:p.id}})}for(const d of a.children)o(r,d)};for(const r of n?.trees??[])o(rt(r.origin),r.root);return s},A=(t,e,i,n)=>({id:e,deviceClass:t,width:i,height:n}),fi=[A("phone","iphone-se",375,667),A("phone","iphone-16",393,852),A("phone","iphone-16-pro-max",440,956),A("phone","pixel-7",412,915),A("phone","galaxy-s24",360,780),A("tablet","ipad-mini",744,1133),A("tablet","ipad-air-11",820,1180),A("tablet","ipad-pro-11",834,1194),A("tablet","ipad-pro-13",1024,1366),A("desktop","laptop-13",1280,800),A("desktop","laptop-15",1440,900),A("desktop","full-hd",1920,1080),A("desktop","monitor-27",2560,1440),A("desktop","ultrawide",3440,1440)],Cs={phone:A("phone","iphone-16",393,852),tablet:A("tablet","ipad-pro-11",834,1194),desktop:A("desktop","laptop-13",1280,800)},gi=t=>t==="mobile"?"phone":t==="tablet"?"tablet":"desktop",Ms=t=>t!=="plain",mi=t=>fi.filter(e=>e.deviceClass===t),Ls=(t,e)=>{const i=gi(t),n=e[i];return mi(i).find(s=>s.id===n)??Cs[i]},Us=(t,e)=>{const i=fi.find(n=>n.id===e);return i===void 0||t[i.deviceClass]===e?t:{...t,[i.deviceClass]:e}},Vs=(t,e)=>`${t.deviceName(e.id)} \xB7 ${e.width}\xD7${e.height}`,zs=(t,e)=>{const i=[1,e.width/t.width];e.height!==void 0&&i.push(e.height/t.height);const n=Math.min(...i);return!Number.isFinite(n)||n<=0?1:Math.max(.1,Math.floor(n*100)/100)},wi=(t,e,i)=>{const{state:n,navigation:s}=t,o=te(n,s),r=pe(s);return l`
2
2
  <div class="nav">
3
- ${Wo(t,e,r)}
4
- ${r==="app"?qo(t,e,s,i.app):s!==void 0&&s.kind!=="screen"?jo(t,e,s,i):l`<p class="nav-empty">${e.noActivityBefore}<code>activities</code>${e.noActivityAfter}</p>`}
3
+ ${Bs(t,e,r)}
4
+ ${r==="app"?Ws(t,e,o,i.app):o!==void 0&&o.kind!=="screen"?Gs(t,e,o,i):l`<p class="nav-empty">${e.noActivityBefore}<code>activities</code>${e.noActivityAfter}</p>`}
5
5
  </div>
6
- `},Ho={scenario:"viewScenario",app:"viewApp"},Bo={scenario:"viewScenarioHint",app:"viewAppHint"},Wo=(t,e,i)=>l`<nav class="dpk-segmented view-switch" aria-label=${e.viewLabel}>
6
+ `},Ys={scenario:"viewScenario",app:"viewApp"},Hs={scenario:"viewScenarioHint",app:"viewAppHint"},Bs=(t,e,i)=>l`<nav class="dpk-segmented view-switch" aria-label=${e.viewLabel}>
7
7
  ${Gn.map(n=>l`<a
8
8
  class="view-option"
9
9
  href=${t.hashFor(Mt(n))}
10
- title=${e[Bo[n]]}
10
+ title=${e[Hs[n]]}
11
11
  aria-current=${n===i?"page":h}
12
12
  data-view=${n}
13
- >${e[Ho[n]]}</a
13
+ >${e[Ys[n]]}</a
14
14
  >`)}
15
- </nav>`,qo=(t,e,i,n)=>{const o=i?.kind==="screen"?i:void 0,s=ii(t.state),r=ni(s,i),a={context:t,currentId:o?.screen.id},d=r?.others??[];return l`
16
- ${s.length>1&&r?Fo(t,e,s,r,n):h}
17
- ${s.length===1&&r?.app.description?l`<p class="app-description">${r.app.description}</p>`:h}
15
+ </nav>`,Ws=(t,e,i,n)=>{const s=i?.kind==="screen"?i:void 0,o=ii(t.state),r=ni(o,i),a={context:t,currentId:s?.screen.id},d=r?.others??[];return l`
16
+ ${o.length>1&&r?qs(t,e,o,r,n):h}
17
+ ${o.length===1&&r?.app.description?l`<p class="app-description">${r.app.description}</p>`:h}
18
18
  <div class="steps-head">
19
19
  <span class="dpk-label">${e.appScreens}</span>
20
20
  <span class="dpk-label">${r?.screens.length??0}</span>
21
21
  </div>
22
22
  <p class="app-hint">${e.appScreensHint}</p>
23
23
  ${r?.trees.map(p=>l`<section class="app-tree">
24
- <h3 class="app-origin">${Go(p.origin)}</h3>
24
+ <h3 class="app-origin">${Fs(p.origin)}</h3>
25
25
  <ul class="tree">
26
- ${wi(a,p.root,0)}
26
+ ${yi(a,p.root,0)}
27
27
  </ul>
28
28
  </section>`)}
29
29
  ${d.length===0?h:l`<section class="app-group">
@@ -37,24 +37,24 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
37
37
  </li>`})}
38
38
  </ul>
39
39
  </section>`}
40
- ${o?.screen.description?l`<div class="detail">
41
- <div class="screen-description dpk-prose">${Pe(De(o.screen.description))}</div>
40
+ ${s?.screen.description?l`<div class="detail">
41
+ <div class="screen-description dpk-prose">${Pe(De(s.screen.description))}</div>
42
42
  </div>`:h}
43
- `},Fo=(t,e,i,n,o)=>l`<div class="field">
43
+ `},qs=(t,e,i,n,s)=>l`<div class="field">
44
44
  <span class="dpk-label">${e.appSelectLabel}</span>
45
- ${o.render({options:i.map((s,r)=>({value:String(r),label:s.app.name})),value:String(i.indexOf(n)),onChange:s=>{const r=i[Number(s)]?.screens[0];r&&t.navigate(ki(r))},ariaLabel:e.appSelectLabel})}
45
+ ${s.render({options:i.map((o,r)=>({value:String(r),label:o.app.name})),value:String(i.indexOf(n)),onChange:o=>{const r=i[Number(o)]?.screens[0];r&&t.navigate(ki(r))},ariaLabel:e.appSelectLabel})}
46
46
  ${n.app.description?l`<p class="app-description">${n.app.description}</p>`:h}
47
- </div>`,wi=(t,e,i)=>l`<li
47
+ </div>`,yi=(t,e,i)=>l`<li
48
48
  class="tree-node"
49
49
  >
50
50
  ${e.screens.length===0&&i===0?h:e.screens.length===0?l`<div class="tree-row" data-depth=${String(i)} data-current="false">
51
51
  <span class="tree-link" title=${e.path}><code class="tree-path">${e.segment}</code></span>
52
- </div>`:e.screens.map(n=>{const o=bi(t,n);return l`<div class="tree-row" data-depth=${String(i)} data-current=${String(o)}>
52
+ </div>`:e.screens.map(n=>{const s=bi(t,n);return l`<div class="tree-row" data-depth=${String(i)} data-current=${String(s)}>
53
53
  <a
54
54
  class="tree-link"
55
55
  href=${xi(t.context,n)}
56
56
  title=${e.path}
57
- aria-current=${o?"page":h}
57
+ aria-current=${s?"page":h}
58
58
  >
59
59
  <code class="tree-path">${e.segment}</code>
60
60
  <span class="tree-title">${n.screen.title}</span>
@@ -62,25 +62,25 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
62
62
  </a>
63
63
  </div>`})}
64
64
  ${e.children.length>0?l`<ul class="tree">
65
- ${e.children.map(n=>wi(t,n,i+1))}
65
+ ${e.children.map(n=>yi(t,n,i+1))}
66
66
  </ul>`:h}
67
- </li>`,bi=(t,e)=>e.screen.id===t.currentId,ki=t=>({screen:t.screen.id,preview:null}),xi=(t,e)=>t.hashFor(ki(e)),Ei=(t,e)=>{const i=t.commentCount({type:"screen",id:e.screen.id})+Ht(t.comments,e.screen.previews.map(n=>n.id));return i>0?l`<span class="step-note">${i}</span>`:h},Go=t=>t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,""),jo=(t,e,i,n)=>{const{state:o}=t,{activity:s,story:r}=i,a=r.steps,d=i.kind==="step"?i.step:void 0,p=i.kind==="step"?ae(i):void 0;return l`
67
+ </li>`,bi=(t,e)=>e.screen.id===t.currentId,ki=t=>({screen:t.screen.id,preview:null}),xi=(t,e)=>t.hashFor(ki(e)),Ei=(t,e)=>{const i=t.commentCount({type:"screen",id:e.screen.id})+Ht(t.comments,e.screen.previews.map(n=>n.id));return i>0?l`<span class="step-note">${i}</span>`:h},Fs=t=>t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,""),Gs=(t,e,i,n)=>{const{state:s}=t,{activity:o,story:r}=i,a=r.steps,d=i.kind==="step"?i.step:void 0,p=i.kind==="step"?ae(i):void 0;return l`
68
68
  <div class="field">
69
69
  <span class="dpk-label">Activity</span>
70
- ${n.activity.render({options:o.activities.map(c=>({value:c.id,label:c.name})),value:s.id,onChange:c=>t.navigate({activity:c,story:null,step:null}),ariaLabel:"Activity"})}
70
+ ${n.activity.render({options:s.activities.map(c=>({value:c.id,label:c.name})),value:o.id,onChange:c=>t.navigate({activity:c,story:null,step:null}),ariaLabel:"Activity"})}
71
71
  </div>
72
72
  <div class="field">
73
73
  <span class="dpk-label">User Story</span>
74
- ${n.story.render({options:s.stories.map(c=>({value:c.id,label:c.name})),value:r.id,onChange:c=>t.navigate({activity:s.id,story:c,step:null}),ariaLabel:"User Story"})}
74
+ ${n.story.render({options:o.stories.map(c=>({value:c.id,label:c.name})),value:r.id,onChange:c=>t.navigate({activity:o.id,story:c,step:null}),ariaLabel:"User Story"})}
75
75
  </div>
76
76
  <div class="steps-head">
77
77
  <span class="dpk-label">Step</span>
78
78
  <span class="dpk-label">${a.length}</span>
79
79
  </div>
80
80
  <ol class="steps">
81
- ${Zi(a,c=>ge(s,r,c),(c,v)=>{const f=ge(s,r,c),I=t.commentCount({type:"step",id:f})+Ht(t.comments,io(o,c).map(P=>P.id));return l`
81
+ ${Zi(a,c=>ge(o,r,c),(c,v)=>{const f=ge(o,r,c),I=t.commentCount({type:"step",id:f})+Ht(t.comments,is(s,c).map(P=>P.id));return l`
82
82
  <li class="step-row" data-current=${String(c.id===d?.id)}>
83
- <a class="step-link" href=${t.hashFor({activity:s.id,story:r.id,step:c.id})}>
83
+ <a class="step-link" href=${t.hashFor({activity:o.id,story:r.id,step:c.id})}>
84
84
  <span class="step-index">${String(v+1).padStart(2,"0")}</span>
85
85
  <span class="step-name">${c.name}</span>
86
86
  ${I>0?l`<span class="step-note">${I}</span>`:h}
@@ -98,7 +98,7 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
98
98
  </li>
99
99
  `})}
100
100
  </ol>
101
- <button class="dpk-btn" type="button" @click=${()=>Xo(t,e,C(s.id,r.id))}>
101
+ <button class="dpk-btn" type="button" @click=${()=>Ks(t,e,C(o.id,r.id))}>
102
102
  ${e.addStepButton}
103
103
  </button>
104
104
  ${d?pt(p,l`<div class="detail">
@@ -126,24 +126,24 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
126
126
  ></dpk-inline-edit>
127
127
  </span>
128
128
  </div>
129
- ${Ko(t,e,d)}
129
+ ${js(t,e,d)}
130
130
  </div>`):h}
131
- `},Ko=(t,e,i)=>{const n=fe(t.state,i);return n.length===0?h:l`<div class="detail-row">
131
+ `},js=(t,e,i)=>{const n=fe(t.state,i);return n.length===0?h:l`<div class="detail-row">
132
132
  <span class="dpk-label">${e.screenGroup}</span>
133
133
  <span class="detail-value">
134
- ${n.map(({app:o,screen:s})=>l`<div class="step-screen-entry">
134
+ ${n.map(({app:s,screen:o})=>l`<div class="step-screen-entry">
135
135
  <a
136
136
  class="step-screen"
137
- href=${t.hashFor({...Mt("app"),screen:s.id})}
137
+ href=${t.hashFor({...Mt("app"),screen:o.id})}
138
138
  title=${e.openInApp}
139
- >${o.name} › ${s.title}</a
139
+ >${s.name} › ${o.title}</a
140
140
  >
141
- ${s.description?l`<div class="screen-description dpk-prose">
142
- ${Pe(De(s.description))}
141
+ ${o.description?l`<div class="screen-description dpk-prose">
142
+ ${Pe(De(o.description))}
143
143
  </div>`:h}
144
144
  </div>`)}
145
145
  </span>
146
- </div>`},Xo=(t,e,i)=>{const n=tt("new-step",Pt(t.state));t.dispatch(W.addStep(i,n,e.newStepName)).ok&&t.navigate({story:i,step:n})},Zo=q(_n),Jo=q(Ji),Si=(t,e,i="bar")=>l`<button
146
+ </div>`},Ks=(t,e,i)=>{const n=tt("new-step",Pt(t.state));t.dispatch(W.addStep(i,n,e.newStepName)).ok&&t.navigate({story:i,step:n})},Xs=q(_n),Zs=q(Ji),Si=(t,e,i="bar")=>l`<button
147
147
  class=${i==="demo"?"demo-control actions-toggle":"dpk-btn actions-toggle"}
148
148
  type="button"
149
149
  data-role="actions"
@@ -152,25 +152,25 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
152
152
  title=${t.actionsHint}
153
153
  @click=${e.toggle}
154
154
  >
155
- ${Zo()} ${t.actions} ${Jo()}
156
- </button>`,Qo=t=>{const e=t.currentTarget;if(!(e instanceof HTMLElement))return;const i=[...e.querySelectorAll('[role="menuitem"]')],n=i.findIndex(a=>a===t.composedPath()[0]),o=t.key==="ArrowDown"?1:t.key==="ArrowUp"?-1:0,s=t.key==="Home"?0:t.key==="End"?i.length-1:o===0?-1:(n+o+i.length)%i.length,r=i[s];r!==void 0&&(t.preventDefault(),r.focus())},es=(t,e)=>{if(!e.open||e.groups.length===0)return h;const i=e.groups.length>1;return l`<div
155
+ ${Xs()} ${t.actions} ${Zs()}
156
+ </button>`,Js=t=>{const e=t.currentTarget;if(!(e instanceof HTMLElement))return;const i=[...e.querySelectorAll('[role="menuitem"]')],n=i.findIndex(a=>a===t.composedPath()[0]),s=t.key==="ArrowDown"?1:t.key==="ArrowUp"?-1:0,o=t.key==="Home"?0:t.key==="End"?i.length-1:s===0?-1:(n+s+i.length)%i.length,r=i[o];r!==void 0&&(t.preventDefault(),r.focus())},Qs=(t,e)=>{if(!e.open||e.groups.length===0)return h;const i=e.groups.length>1;return l`<div
157
157
  class="comment-pop actions-menu"
158
158
  popover="manual"
159
159
  role="menu"
160
160
  aria-label=${t.actions}
161
- @keydown=${Qo}
161
+ @keydown=${Js}
162
162
  >
163
163
  ${e.groups.map(n=>l`<div class="actions-group" role="group" aria-label=${n.screen.title}>
164
164
  ${i?l`<span class="actions-group-title" aria-hidden="true">${n.screen.title}</span>`:h}
165
- ${n.actions.map(o=>l`<button
165
+ ${n.actions.map(s=>l`<button
166
166
  class="actions-item"
167
167
  type="button"
168
168
  role="menuitem"
169
- data-action=${o.id}
170
- @click=${()=>e.run(n.screen.id,o.id)}
169
+ data-action=${s.id}
170
+ @click=${()=>e.run(n.screen.id,s.id)}
171
171
  >
172
- <span class="actions-label">${o.label}</span>
173
- ${o.description===void 0?h:l`<span class="actions-description">${o.description}</span>`}
172
+ <span class="actions-label">${s.label}</span>
173
+ ${s.description===void 0?h:l`<span class="actions-description">${s.description}</span>`}
174
174
  </button>`)}
175
175
  </div>`)}
176
176
  </div>`},$i=(t,e,i="bar")=>{const n=e.mode.kind!=="off";return l`<button
@@ -181,7 +181,7 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
181
181
  @click=${()=>e.send({kind:"toggle"})}
182
182
  >
183
183
  ${it()} ${t.uiComment}
184
- </button>`},ts=(t,e)=>e.mode.kind==="off"?h:l`<p class="ui-comment-hint" role="status">${it()} ${t.uiCommentHint}</p>`,is=(t,e)=>e.mode.kind==="off"?h:l`<div class="ui-layer" aria-hidden="true">
184
+ </button>`},eo=(t,e)=>e.mode.kind==="off"?h:l`<p class="ui-comment-hint" role="status">${it()} ${t.uiCommentHint}</p>`,to=(t,e)=>e.mode.kind==="off"?h:l`<div class="ui-layer" aria-hidden="true">
185
185
  <div class="ui-catcher"></div>
186
186
  <div class="ui-box ui-hover" hidden></div>
187
187
  <div class="ui-box ui-picked" hidden></div>
@@ -193,30 +193,30 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
193
193
  title=${t.uiCommentPin(i.number,i.body)}
194
194
  >${i.number}</span
195
195
  >`)}
196
- </div>`,ns=t=>t==="feedback"||t==="note",os=(t,e)=>{const i=e.mode;if(i.kind!=="composing")return h;const n=fn(i.body,e.notes,{key:`ui:${i.target.previewId}/${i.target.selector}`,...e.targetLabel===void 0?{}:{label:e.targetLabel},choice:{label:t.uiCommentAs,value:i.as,options:[{value:"feedback",label:t.uiCommentFeedback,hint:t.uiCommentFeedbackHint},{value:"note",label:t.uiCommentNote,hint:t.uiCommentNoteHint}]},...i.as==="note"?{submitLabel:t.uiNoteSubmit}:{}});return l`${pt(`${i.target.previewId}/${i.target.selector}`,gn(e.composer,n,o=>{o.kind==="input"?e.send({kind:"input",body:o.body}):o.kind==="comment"?e.submit(o.body):o.kind==="choose"?ns(o.value)&&e.send({kind:"choose",as:o.value}):e.send({kind:"dismiss"})}))}`},Ti=(t,e)=>l`<div class="demo-controls">
196
+ </div>`,io=t=>t==="feedback"||t==="note",no=(t,e)=>{const i=e.mode;if(i.kind!=="composing")return h;const n=fn(i.body,e.notes,{key:`ui:${i.target.previewId}/${i.target.selector}`,...e.targetLabel===void 0?{}:{label:e.targetLabel},choice:{label:t.uiCommentAs,value:i.as,options:[{value:"feedback",label:t.uiCommentFeedback,hint:t.uiCommentFeedbackHint},{value:"note",label:t.uiCommentNote,hint:t.uiCommentNoteHint}]},...i.as==="note"?{submitLabel:t.uiNoteSubmit}:{}});return l`${pt(`${i.target.previewId}/${i.target.selector}`,gn(e.composer,n,s=>{s.kind==="input"?e.send({kind:"input",body:s.body}):s.kind==="comment"?e.submit(s.body):s.kind==="choose"?io(s.value)&&e.send({kind:"choose",as:s.value}):e.send({kind:"dismiss"})}))}`},Ti=(t,e)=>l`<div class="demo-controls">
197
197
  ${e.actions.groups.length>0?Si(t,e.actions,"demo"):h}
198
198
  ${$i(t,e.uiComment,"demo")}
199
199
  <button class="demo-control demo-exit" type="button" title=${t.exitDemo} @click=${e.onExit}>
200
200
  ${Re()} ${t.exitDemo} <kbd>Esc</kbd>
201
201
  </button>
202
- </div>`,Ai={mobile:"390px",tablet:"834px",desktop:"1180px",fluid:"100%"},Ii={mobile:"620px",tablet:"640px",desktop:"520px",fluid:"420px"},ss={browser:0,native:22,mail:0,plain:0},_i=(t,e,i)=>{const n=`--frame-width:${Ai[e]};--frame-min-height:${Ii[e]}`;if(i?.kind!=="device")return n;const o=ss[t];return`${n};--device-width:${i.width+o}px;--device-height:${i.height+o}px;zoom:${i.zoom}`},rs=t=>({back:t.browserBack,forward:t.browserForward,reload:t.browserReload,address:t.browserAddress,tabs:t.browserTabs,newTab:t.newTab,closeTab:t.closeTab,profile:t.browserProfile,guest:t.browserGuest,shortcuts:t.newTabShortcuts,unreachableTitle:t.unreachableTitle,unreachableBody:t.unreachableBody}),as=(t,e)=>l`<slot name=${`preview:${t.id}`}></slot> ${e?h:l`<div class="frame-placeholder">
202
+ </div>`,Ai={mobile:"390px",tablet:"834px",desktop:"1180px",fluid:"100%"},Ii={mobile:"620px",tablet:"640px",desktop:"520px",fluid:"420px"},so={browser:0,native:22,mail:0,plain:0},_i=(t,e,i)=>{const n=`--frame-width:${Ai[e]};--frame-min-height:${Ii[e]}`;if(i?.kind!=="device")return n;const s=so[t];return`${n};--device-width:${i.width+s}px;--device-height:${i.height+s}px;zoom:${i.zoom}`},oo=t=>({back:t.browserBack,forward:t.browserForward,reload:t.browserReload,address:t.browserAddress,tabs:t.browserTabs,newTab:t.newTab,closeTab:t.closeTab,profile:t.browserProfile,guest:t.browserGuest,shortcuts:t.newTabShortcuts,unreachableTitle:t.unreachableTitle,unreachableBody:t.unreachableBody}),ro=(t,e)=>l`<slot name=${`preview:${t.id}`}></slot> ${e?h:l`<div class="frame-placeholder">
203
203
  <span class="dpk-label">light dom preview</span>
204
204
  <code>&lt;div slot="preview" data-preview-id="${t.id}"&gt;</code>
205
- </div>`}`,ds=(t,e,i)=>{const{preview:n,viewport:o}=i,s={view:i.view,phone:o==="mobile",switcher:i.switcher,shortcuts:i.shortcuts.map(r=>({...r,href:t.hashFor(r.page)})),labels:rs(e),...i.demo===void 0?{}:{extra:Ti(e,i.demo)},send:i.send};return l`<figure
205
+ </div>`}`,ao=(t,e,i)=>{const{preview:n,viewport:s}=i,o={view:i.view,phone:s==="mobile",switcher:i.switcher,shortcuts:i.shortcuts.map(r=>({...r,href:t.hashFor(r.page)})),labels:oo(e),...i.demo===void 0?{}:{extra:Ti(e,i.demo)},send:i.send};return l`<figure
206
206
  class="frame browser"
207
207
  data-kind="browser"
208
- data-viewport=${o}
208
+ data-viewport=${s}
209
209
  ?data-loading=${i.loading}
210
210
  ?data-empty=${n!==void 0&&!i.hasContent}
211
211
  data-window=${i.window.kind}
212
- style=${_i("browser",o,i.window)}
212
+ style=${_i("browser",s,i.window)}
213
213
  >
214
- ${mn(s)}
214
+ ${mn(o)}
215
215
  <div class="viewport browser-page">
216
- ${yn(s,n===void 0?void 0:as(n,i.hasContent))}
216
+ ${wn(o,n===void 0?void 0:ro(n,i.hasContent))}
217
217
  </div>
218
- ${wn(s)}
219
- </figure>`},ie=t=>`${t.previewId}/${t.selector}`,ls=(t,e)=>e.badges.length===0?h:l`<div class="ui-notes">
218
+ ${yn(o)}
219
+ </figure>`},ie=t=>`${t.previewId}/${t.selector}`,lo=(t,e)=>e.badges.length===0?h:l`<div class="ui-notes">
220
220
  ${e.badges.map(i=>{const n=e.open!==null&&ie(e.open)===ie(i);return l`<button
221
221
  class="ui-note-badge"
222
222
  type="button"
@@ -231,7 +231,7 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
231
231
  >
232
232
  ${nt()}<span>${i.notes.length}</span>
233
233
  </button>`})}
234
- </div>`,ps=(t,e)=>{const i=e.open;return i===null?h:l`<div
234
+ </div>`,po=(t,e)=>{const i=e.open;return i===null?h:l`<div
235
235
  class="comment-pop ui-notes-pop"
236
236
  popover="manual"
237
237
  role="dialog"
@@ -252,7 +252,7 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
252
252
  </button>
253
253
  </div>
254
254
  <ol class="ui-note-list">
255
- ${i.notes.map(n=>e.editing?.noteId===n.id?l`<li data-id=${n.id}>${cs(t,e,e.editing)}</li>`:l`<li data-id=${n.id}>
255
+ ${i.notes.map(n=>e.editing?.noteId===n.id?l`<li data-id=${n.id}>${co(t,e,e.editing)}</li>`:l`<li data-id=${n.id}>
256
256
  <div class="ui-note-main">
257
257
  <p class="ui-note-body">${n.body}</p>
258
258
  ${n.createdAt===void 0?h:l`<time class="ui-note-time" datetime=${n.createdAt}>${t.uiNoteDate(n.createdAt)}</time>`}
@@ -278,7 +278,7 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
278
278
  </button>
279
279
  </li>`)}
280
280
  </ol>
281
- </div>`},cs=(t,e,i)=>l`
281
+ </div>`},co=(t,e,i)=>l`
282
282
  <div class="ui-note-editor">
283
283
  <textarea
284
284
  class="dpk-textarea"
@@ -303,10 +303,10 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
303
303
  </button>
304
304
  </div>
305
305
  </div>
306
- `,Pi=(t,e,i)=>{const{state:n,navigation:o}=t,s=te(n,o),r=s===void 0||s.kind==="story"?void 0:s,a=pe(o)==="app",d=Ni(n,[]);if(s?.kind==="story"){const{activity:R,story:Te}=s;return l`
306
+ `,Pi=(t,e,i)=>{const{state:n,navigation:s}=t,o=te(n,s),r=o===void 0||o.kind==="story"?void 0:o,a=pe(s)==="app",d=Ni(n,[]);if(o?.kind==="story"){const{activity:R,story:Te}=o;return l`
307
307
  <div class="stage">
308
- <section class="stage-story" data-dpk-target=${Bt(s,null)}>
309
- ${Di(e,lo(R,Te))}
308
+ <section class="stage-story" data-dpk-target=${Bt(o,null)}>
309
+ ${Di(e,ds(R,Te))}
310
310
  ${Te.description?l`<div class="story-description dpk-prose">${Pe(De(Te.description))}</div>`:h}
311
311
  <p class="stage-empty">${e.storyWithoutSteps}</p>
312
312
  </section>
@@ -319,7 +319,7 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
319
319
  </p>`}
320
320
  ${d}
321
321
  </div>
322
- `;const p=Ye(n,r,o),{layout:c,panes:v,shown:f}=p,[I]=c==="single"?v:[],P=i.uiComment,T=i.lift,z=T?.mode==="demo",K=i.browser,Fe=K!==null&&K.view.entry?.kind!=="page"?[]:f,[X]=Fe,ue=(X??f[0])?.viewport??"desktop",Ge=z&&K!==null&&ue!=="mobile",je={onExit:i.onToggleDemo,uiComment:P,actions:i.actions},zi=X??f[0],Ke=K!==null?"browser":zi?.kind??"browser",Xe=z&&Ke==="browser"&&gi(ue)==="desktop",Z=i.devices,ne=Z===null||Xe||!Lo(Ke)?null:Uo(ue,Z.choice),Ze=ne!==null&&Z!==null?{kind:"device",width:ne.width,height:ne.height,zoom:Z.zoom}:Xe?{kind:"fill"}:null;return l`
322
+ `;const p=Ye(n,r,s),{layout:c,panes:v,shown:f}=p,[I]=c==="single"?v:[],P=i.uiComment,T=i.lift,z=T?.mode==="demo",K=i.browser,Fe=K!==null&&K.view.entry?.kind!=="page"?[]:f,[X]=Fe,ue=(X??f[0])?.viewport??"desktop",Ge=z&&K!==null&&ue!=="mobile",je={onExit:i.onToggleDemo,uiComment:P,actions:i.actions},zi=X??f[0],Ke=K!==null?"browser":zi?.kind??"browser",Xe=z&&Ke==="browser"&&gi(ue)==="desktop",Z=i.devices,ne=Z===null||Xe||!Ms(Ke)?null:Ls(ue,Z.choice),Ze=ne!==null&&Z!==null?{kind:"device",width:ne.width,height:ne.height,zoom:Z.zoom}:Xe?{kind:"fill"}:null;return l`
323
323
  ${T===null?h:l`<div class="stage-placeholder" style=${`height:${T.height}px`}></div>`}
324
324
  <div
325
325
  class=${T===null?"stage":z?"stage is-demo":"stage is-maximized"}
@@ -331,14 +331,14 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
331
331
  ${Di(e,Zt(n,r))}
332
332
  <div class="stage-tools">
333
333
  ${I?.kind==="screen"&&I.tabs.length>0?Ri(t,p,I):h}
334
- ${ne!==null&&Z!==null?ms(e,ne,Z,i.deviceSelect):h}
334
+ ${ne!==null&&Z!==null?mo(e,ne,Z,i.deviceSelect):h}
335
335
  ${i.actions.groups.length>0?Si(e,i.actions):h}
336
336
  ${f.length>0?$i(e,P):h}
337
- ${f.length===0?h:a?ys(e,i.onToggleDemo):ws(e,T!==null,i.onToggleMaximize)}
337
+ ${f.length===0?h:a?wo(e,i.onToggleDemo):yo(e,T!==null,i.onToggleMaximize)}
338
338
  </div>
339
339
  </div>`}
340
- ${r.kind==="step"&&r.step.situation!==void 0?fs(e,r.step.situation):h}
341
- ${z?h:ts(e,P)}
340
+ ${r.kind==="step"&&r.step.situation!==void 0?fo(e,r.step.situation):h}
341
+ ${z?h:eo(e,P)}
342
342
  <div
343
343
  class="canvas"
344
344
  data-layout=${c}
@@ -349,45 +349,45 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
349
349
  @wheel=${{handleEvent:i.canvasEvents.wheel,passive:!1}}
350
350
  @scroll=${{handleEvent:i.canvasEvents.scroll,capture:!0}}
351
351
  >
352
- ${K!==null?ds(t,e,{...K,...X===void 0?{}:{preview:X},...Ge?{demo:je}:{},hasContent:X===void 0||i.hasPreviewContent(X.id),viewport:ue,window:Ze??{kind:"fill"}}):c==="side-by-side"?l`<div class="panes">
352
+ ${K!==null?ao(t,e,{...K,...X===void 0?{}:{preview:X},...Ge?{demo:je}:{},hasContent:X===void 0||i.hasPreviewContent(X.id),viewport:ue,window:Ze??{kind:"fill"}}):c==="side-by-side"?l`<div class="panes">
353
353
  ${v.map(R=>l`<div class="pane" data-viewport=${R.preview.viewport} data-pane=${R.kind}>
354
- ${gs(t,p,R)}
355
- ${We(t,e,R.preview,i.hasPreviewContent(R.preview.id))}
354
+ ${go(t,p,R)}
355
+ ${We(t,e,R.preview,i.hasPreviewContent(R.preview.id),i.previewUrls)}
356
356
  </div>`)}
357
- </div>`:f.map(R=>We(t,e,R,i.hasPreviewContent(R.id),Ze))}
357
+ </div>`:f.map(R=>We(t,e,R,i.hasPreviewContent(R.id),i.previewUrls,Ze))}
358
358
  ${f.length===0?l`<p class="dpk-label">${e.noPreviewMetadata}</p>`:h}
359
- ${ls(e,i.uiNotes)} ${is(e,P)}
359
+ ${lo(e,i.uiNotes)} ${to(e,P)}
360
360
  </div>
361
- ${os(e,P)} ${ps(e,i.uiNotes)} ${es(e,i.actions)}
361
+ ${no(e,P)} ${po(e,i.uiNotes)} ${Qs(e,i.actions)}
362
362
  ${Ni(n,Fe.map(R=>R.id))}
363
363
  </div>
364
- `},us=q(In),hs=q($n),vs={phone:q(Tn),tablet:q(An),desktop:q(Sn)},Di=(t,e)=>l`<div class="page-head">
364
+ `},uo=q(In),ho=q($n),vo={phone:q(Tn),tablet:q(An),desktop:q(Sn)},Di=(t,e)=>l`<div class="page-head">
365
365
  ${e.actor===void 0?h:l`<span class="page-actor" role="note" aria-label=${t.pageActor(e.actor)} title=${e.actor}>
366
- ${us()} <span class="page-actor-name">${e.actor}</span>
366
+ ${uo()} <span class="page-actor-name">${e.actor}</span>
367
367
  </span>`}
368
368
  <h2 class="page-title">${e.title}</h2>
369
- </div>`,fs=(t,e)=>l`<aside class="situation">
369
+ </div>`,fo=(t,e)=>l`<aside class="situation">
370
370
  <span class="situation-label">${t.situation}</span>
371
371
  <p class="situation-text">${e}</p>
372
372
  </aside>`,Ri=(t,e,i)=>l`<div class="dpk-segmented tabs" role="tablist">
373
- ${i.tabs.map(n=>{const o=n.id===i.preview.id;return l`<a
373
+ ${i.tabs.map(n=>{const s=n.id===i.preview.id;return l`<a
374
374
  class="tab"
375
375
  role="tab"
376
- data-current=${String(o)}
377
- aria-selected=${o?"true":"false"}
378
- href=${t.hashFor({preview:to(e,n.id)})}
376
+ data-current=${String(s)}
377
+ aria-selected=${s?"true":"false"}
378
+ href=${t.hashFor({preview:ts(e,n.id)})}
379
379
  >${n.label??n.viewport}</a
380
380
  >`})}
381
- </div>`,gs=(t,e,i)=>i.kind==="material"?i.preview.label===void 0?h:l`<span class="pane-label" title=${i.preview.label}>${i.preview.label}</span>`:l`<div class="pane-head">
381
+ </div>`,go=(t,e,i)=>i.kind==="material"?i.preview.label===void 0?h:l`<span class="pane-label" title=${i.preview.label}>${i.preview.label}</span>`:l`<div class="pane-head">
382
382
  <span class="pane-label" title=${i.screen.screen.title}>${i.screen.screen.title}</span>
383
383
  ${i.tabs.length>0?Ri(t,e,i):h}
384
- </div>`,ms=(t,e,i,n)=>{const o=Math.round(i.zoom*100);return l`<span class="device-pick" title=${t.deviceHint}>
385
- ${vs[e.deviceClass]()}
386
- ${n.render({options:mi(e.deviceClass).map(s=>({value:s.id,label:zo(t,s)})),value:e.id,onChange:s=>i.onPick(s),ariaLabel:t.device,className:"device-select"})}
387
- ${o<100?l`<span class="device-zoom" title=${t.deviceZoom(o)}>${o}%</span>`:h}
388
- </span>`},ys=(t,e)=>l`<button class="dpk-btn stage-demo" type="button" title=${t.demoHint} @click=${e}>
389
- ${hs()} ${t.demo}
390
- </button>`,ws=(t,e,i)=>l`<button
384
+ </div>`,mo=(t,e,i,n)=>{const s=Math.round(i.zoom*100);return l`<span class="device-pick" title=${t.deviceHint}>
385
+ ${vo[e.deviceClass]()}
386
+ ${n.render({options:mi(e.deviceClass).map(o=>({value:o.id,label:Vs(t,o)})),value:e.id,onChange:o=>i.onPick(o),ariaLabel:t.device,className:"device-select"})}
387
+ ${s<100?l`<span class="device-zoom" title=${t.deviceZoom(s)}>${s}%</span>`:h}
388
+ </span>`},wo=(t,e)=>l`<button class="dpk-btn stage-demo" type="button" title=${t.demoHint} @click=${e}>
389
+ ${ho()} ${t.demo}
390
+ </button>`,yo=(t,e,i)=>l`<button
391
391
  class="dpk-btn stage-maximize"
392
392
  type="button"
393
393
  aria-pressed=${e?"true":"false"}
@@ -395,7 +395,7 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
395
395
  @click=${i}
396
396
  >
397
397
  ${e?l`${tn()} ${t.restore}`:l`${nn()} ${t.maximize}`}
398
- </button>`,We=(t,e,i,n,o=null)=>l`
398
+ </button>`,We=(t,e,i,n,s,o=null)=>l`
399
399
  <figure
400
400
  class="frame"
401
401
  data-kind=${i.kind}
@@ -405,10 +405,12 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
405
405
  style=${_i(i.kind,i.viewport,o)}
406
406
  >
407
407
  ${i.kind==="browser"?l`<div class="dpk-browser-frame-bar">
408
- <span class="dpk-browser-frame-url">${ke(t.state,i)}</span>
409
- </div>`:i.kind==="mail"?bs(ro(e,i)):h}
408
+ <span class="dpk-browser-frame-url"
409
+ >${ke(t.state,i,s.get(i.id))}</span
410
+ >
411
+ </div>`:i.kind==="mail"?bo(rs(e,i)):h}
410
412
  <div class="viewport">
411
- ${i.kind==="native"?ks():h}
413
+ ${i.kind==="native"?ko():h}
412
414
  <slot name=${`preview:${i.id}`}></slot>
413
415
  ${n?h:l`<div class="frame-placeholder">
414
416
  <span class="dpk-label">light dom preview</span>
@@ -416,7 +418,7 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
416
418
  </div>`}
417
419
  </div>
418
420
  </figure>
419
- `,bs=t=>l`<header class="dpk-received-mail">
421
+ `,bo=t=>l`<header class="dpk-received-mail">
420
422
  ${t.subject===void 0?h:l`<h3 class="dpk-received-mail-subject">${t.subject}</h3>`}
421
423
  <div class="dpk-received-mail-envelope">
422
424
  ${t.initial===void 0?h:l`<span class="dpk-avatar" data-size="lg" aria-hidden="true">${t.initial}</span>`}
@@ -427,9 +429,9 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
427
429
  </div>`)}
428
430
  </dl>
429
431
  </div>
430
- </header>`,ks=()=>l`<div class="dpk-status-bar"><span>9:41</span></div>`,Ni=(t,e)=>{const n=[...H(t).flatMap(o=>o.screen.previews),...B(t).flatMap(o=>F(o.step))].filter(o=>!e.includes(o.id));return n.length===0?l`${h}`:l`<div class="parked" aria-hidden="true">
431
- ${n.map(o=>l`<slot name=${`preview:${o.id}`}></slot>`)}
432
- </div>`},xs=on`
432
+ </header>`,ko=()=>l`<div class="dpk-status-bar"><span>9:41</span></div>`,Ni=(t,e)=>{const n=[...H(t).flatMap(s=>s.screen.previews),...B(t).flatMap(s=>F(s.step))].filter(s=>!e.includes(s.id));return n.length===0?l`${h}`:l`<div class="parked" aria-hidden="true">
433
+ ${n.map(s=>l`<slot name=${`preview:${s.id}`}></slot>`)}
434
+ </div>`},xo=sn`
433
435
  :host {
434
436
  --dpk-prototype-accent: var(--dpk-blue);
435
437
  }
@@ -889,6 +891,8 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
889
891
  gap: 8px;
890
892
  min-width: 0;
891
893
  margin-left: auto;
894
+ /* Maximize (and the other tools) sit below the floating menu otherwise. */
895
+ margin-inline-end: var(--dpk-floating-menu-clearance, 0px);
892
896
  }
893
897
 
894
898
  .stage-maximize svg,
@@ -1823,7 +1827,7 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
1823
1827
  .parked {
1824
1828
  display: none;
1825
1829
  }
1826
- `,Es=`
1830
+ `,Eo=`
1827
1831
  /*
1828
1832
  * The wrapper is a stretch grid (see \`.viewport ::slotted(*)\`): one child
1829
1833
  * fills the frame, but several would share the extra height as gaps between
@@ -1859,6 +1863,6 @@ import{ax as y,bi as Ae,av as D,aM as _,aL as g,ac as u,aw as M,az as he,bj as Y
1859
1863
  max-height: calc(100% - 32px);
1860
1864
  margin: auto;
1861
1865
  }
1862
- `,qe={kind:"off"},Ss=(t,e)=>{switch(e.kind){case"toggle":return t.kind==="off"?{kind:"picking",as:"feedback"}:qe;case"exit":return qe;case"pick":return t.kind==="off"?t:{kind:"composing",target:e.target,body:t.kind==="composing"?t.body:"",as:t.as};case"input":return t.kind==="composing"?{...t,body:e.body}:t;case"choose":return t.kind==="off"||t.as===e.as?t:{...t,as:e.as};case"dismiss":case"submitted":return t.kind==="off"?t:{kind:"picking",as:t.as};default:return t}},$s={width:300,height:300},Ts=360,As={width:280,height:360},Is={width:300,height:320},Oi=(t,e)=>({previewId:t.previewId,selector:e.selector,...e.text===void 0?{}:{text:e.text}}),Ci=".comment-pop:not(.ui-notes-pop)",_s="prototype-ui-comment",Ps="comment-ui-element",Mi="dpk-view-prototype-document-styles",Ds=24,Rs=()=>{if(document.getElementById(Mi)!==null)return;const t=Object.assign(document.createElement("style"),{id:Mi,textContent:Es});document.head.append(t)},Ns=(t,e,i)=>{const n=getComputedStyle(t),o=/auto|scroll/.test(n.overflowX)&&t.scrollWidth>t.clientWidth,s=/auto|scroll/.test(n.overflowY)&&t.scrollHeight>t.clientHeight,r=e<0?t.scrollLeft>0:e>0&&t.scrollLeft+t.clientWidth<t.scrollWidth-1,a=i<0?t.scrollTop>0:i>0&&t.scrollTop+t.clientHeight<t.scrollHeight-1;return o&&r||s&&a},Li=t=>{if(t.assignedSlot!==null)return t.assignedSlot;if(t.parentElement!==null)return t.parentElement;const e=t.getRootNode();return e instanceof ShadowRoot?e.host:null},Os=(t,e)=>{let i=t;for(;i!==null;){if(i===e)return!0;i=Li(i)}return!1};class Ui extends ot{static{this.styles=[ot.styles,sn,rn,pn,cn,un,bn,xs]}#e=qe;#k=!1;#p=null;#o=[];#x=new an(this);#K={app:new ve(this),activity:new ve(this),story:new ve(this)};#X=new ve(this);#O=!1;#i=null;#s=null;#C=!1;#h=!1;#E=!1;#r=null;#S=null;#$={};#T=1;#v=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{this.#q(),this.#w()});#c=null;#u=null;#f=null;#A=!1;#n=null;#I=null;#g=null;#t=null;#m=null;#M=typeof MutationObserver>"u"?null:new MutationObserver(()=>this.#ue());#d=null;constructor(){super(),new st(this,{open:()=>this.#f!==null,closesOn:e=>!e.some(i=>i instanceof Element&&this.#Q(i)),ownsEscape:()=>!0,dismiss:()=>this.#_(!0)}),new st(this,{open:()=>this.#n!==null,closesOn:e=>!e.some(i=>i instanceof Element&&(i.classList.contains("ui-notes-pop")||i.classList.contains("ui-note-badge"))),ownsEscape:()=>!0,dismiss:()=>this.#P(!0)})}definitionFor(e){return oi(e)}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this.#H),window.addEventListener("resize",this.#D),this.addEventListener("toggle",this.#F,!0),this.addEventListener("click",this.#b,!0),this.addEventListener("auxclick",this.#b,!0),this.#M?.observe(this,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),Rs()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.#H),window.removeEventListener("resize",this.#D),this.removeEventListener("toggle",this.#F,!0),this.removeEventListener("click",this.#b,!0),this.removeEventListener("auxclick",this.#b,!0),this.#v?.disconnect(),this.#c=null,this.#M?.disconnect(),this.#d!==null&&cancelAnimationFrame(this.#d),this.#d=null,this.#j()}renderRegions(e){const i=le(this.locale),n=te(e.state,e.navigation),o=pe(e.navigation)==="app";this.#i!==null&&this.#i.mode==="demo"!==o&&this.#G();const s=o?this.#we(e,i):null;return this.#C=s!==null,this.#o=n!==void 0&&n.kind!=="story"&&(s===null||s.view.entry?.kind==="page")?Ye(e.state,n,e.navigation).shown.map(r=>r.id):[],this.#r!==null&&this.#r.page!==this.#o.join(" ")&&this.#j(),{sidebar:yi(e,i,this.#K),main:Pi(e,i,{deviceSelect:this.#X,hasPreviewContent:r=>this.#$e(r),lift:this.#i,onToggleMaximize:()=>this.#N(this.#i===null?"maximized":null),onToggleDemo:()=>this.#N(this.#i===null?"demo":null),onLiftedWheel:this.#ye,browser:s===null?null:{...s,loading:this.#r!==null},devices:o?{choice:this.#$,zoom:this.#T,onPick:r=>{this.#$=Vo(this.#$,r),this.requestUpdate()}}:null,uiComment:this.#ne(e),uiNotes:this.#se(e,o),actions:this.#Z(e),canvasEvents:{click:this.#de,pointermove:this.#le,pointerleave:this.#pe,wheel:this.#ce,scroll:this.#D}})}}updated(){super.updated(),this.#ge(),this.#ve(),this.#he(),this.#q();const e=this.#e;if(e.kind==="composing"&&!this.#o.includes(e.target.previewId)){this.#l({kind:"dismiss"});return}this.#me(),this.#ee(),this.#E&&(this.#E=!1,this.renderRoot.querySelector('.browser-tab[aria-selected="true"]')?.focus()),this.#w(),this.#re();const i=e.kind==="composing"&&!this.#k;if(this.#k=e.kind==="composing",e.kind!=="composing"||this.#p===null)return;const n=this.renderRoot.querySelector(Ci);n&&(this.#x.open(n,this.#p,$s,{placement:"right-start"}),i&&n.querySelector("textarea")?.focus({preventScroll:!0}))}#Z(e){const i=Kt(e.state,this.#o),n=i.map(s=>s.screen.id).join(" "),o=i.length>0&&this.#u===n;return{groups:i,open:o,toggle:()=>o?this.#_(!1):this.#J(n),run:(s,r)=>this.#te(s,r)}}#J(e){this.#u=e,this.requestUpdate()}#_(e){this.#u!==null&&(this.#u=null,this.#A=e,this.requestUpdate())}#Q(e){return e.classList.contains("actions-menu")||e.getAttribute("data-role")==="actions"}#ee(){const e=this.renderRoot.querySelector(".actions-menu"),i=this.renderRoot.querySelector('[data-role="actions"]');if(e===null){this.#f=null,this.#A&&i?.focus({preventScroll:!0}),this.#A=!1;return}e===this.#f||i===null||(this.#f=e,this.#x.open(e,i,As),e.querySelector('[role="menuitem"]')?.focus({preventScroll:!0}))}#te(e,i){this.#_(!0);const n=Kt(this.derivation.state,this.#o).find(d=>d.screen.id===e),o=n?.actions.find(d=>d.id===i);if(n===void 0||o===void 0)return;const r=this.#y().filter(d=>n.previewIds.includes(d.getAttribute("data-preview-id")??"")).map(d=>{const p=[...xo(d,o.fill??{}),...Eo(d,o.click??[])];return d.dispatchEvent(new CustomEvent("dpk-action",{bubbles:!0,detail:{id:o.id,screen:n.screen.id}})),p}),a=(r[0]??[]).filter(d=>r.every(p=>p.includes(d)));a.length!==0&&console.warn(`[dev-process-kit] <dpk-view-prototype>: action "${o.id}" of screen "${n.screen.id}" found nothing on screen for: ${a.join(", ")}`)}getContextMenuItems(e){const i=e.origin??null;return!(i instanceof Element)||this.#o.length===0||!this.#ie(i)?null:[{id:_s,entries:[{kind:"item",id:Ps,label:le(this.locale).commentOnElement,run:()=>{this.#e.kind==="off"&&this.#l({kind:"toggle"})}}]}]}#ie(e){const i=this.renderRoot.querySelector(".stage");return i!==null&&Os(e,i)?!0:this.#y().some(n=>n===e||n.contains(e))}#ne(e){const i=this.#e,n=i.kind==="composing"?i.target:void 0,o=n?E(e.state,n.previewId)?.preview:void 0,s=n?re(n):void 0,r=i.kind==="composing"&&i.as==="note"?(o?.notes??[]).filter(a=>a.selector===n?.selector).map(a=>a.body):e.comments.filter(a=>a.target.type===O&&a.target.id===s).map(a=>Qe(a));return{mode:i,pins:i.kind==="off"?[]:zt(e.comments,this.#o),...n&&o?{targetLabel:Ve(o,n)}:{},notes:r,composer:kn(this.locale),send:a=>this.#l(a),submit:a=>this.#oe(e.state,a)}}#l(e){const i=Ss(this.#e,e);i!==this.#e&&(this.#e=i,i.kind!=="composing"&&(this.#p=null),i.kind!=="off"&&(this.#n=null),this.requestUpdate())}#oe(e,i){const n=this.#e;if(n.kind!=="composing")return;(n.as==="note"?this.dispatch(W.addUiNote(n.target,tt("note",_t(e)),i,new Date().toISOString())):this.dispatch({type:dn,target:{type:O,id:re(n.target)},payload:{body:i}})).ok&&this.#l({kind:"submitted"})}#se(e,i){const n=i?[]:Kn(e.state,this.#o),o=this.#e.kind==="off"&&this.#n!==null?n.find(r=>ie(r)===this.#n)??null:null;o===null&&(this.#n=null);const s=this.#t;return s!==null&&!o?.notes.some(r=>r.id===s.noteId)&&(this.#t=null),{badges:n,open:o,toggle:r=>{const a=ie(r);this.#n===a?this.#P(!1):(this.#n=a,this.#t=null,this.requestUpdate())},close:()=>this.#P(!0),remove:(r,a)=>{const d=r.notes.find(p=>p.id===a);d!==void 0&&this.dispatch(W.deleteUiNote(Oi(r,d),a))},editing:this.#t,edit:(r,a)=>{this.#t={noteId:r,body:a},this.#m={noteId:r,part:"editor"},this.requestUpdate()},input:r=>{this.#t!==null&&(this.#t={...this.#t,body:r}),this.requestUpdate()},save:()=>{const r=this.#t,a=o?.notes.find(p=>p.id===r?.noteId),d=r?.body.trim()??"";o===null||r===null||a===void 0||d===""||(d!==a.body&&this.dispatch(W.setUiNoteBody(Oi(o,a),a.id,d)),this.#L())},cancel:()=>this.#L()}}#L(){this.#t!==null&&(this.#m={noteId:this.#t.noteId,part:"edit"},this.#t=null,this.requestUpdate())}#P(e){this.#n!==null&&(this.#g=e?this.#n:null,this.#n=null,this.requestUpdate())}#re(){const e=this.renderRoot.querySelector(".ui-notes-pop");if(e===null){this.#I=null,this.#g!==null&&this.#U(this.#g)?.focus({preventScroll:!0}),this.#g=null;return}const i=this.#U(e.dataset.key??""),n=this.#m;this.#m=null,n!==null&&e.querySelector(`li[data-id="${CSS.escape(n.noteId)}"]`)?.querySelector(n.part==="editor"?"textarea":'[data-role="edit-note"]')?.focus({preventScroll:!0}),!(e===this.#I||i===null)&&(this.#I=e,this.#x.open(e,i,Is,{placement:"bottom-start"}),e.querySelector('[data-role="close-notes"]')?.focus({preventScroll:!0}))}#U(e){return Array.from(this.renderRoot.querySelectorAll(".ui-note-badge")).find(i=>i.dataset.key===e)??null}#V(e){const i=e.composedPath(),n=i[0];if(n instanceof Element&&n.classList.contains("ui-catcher"))return this.#ae(e.clientX,e.clientY);const o=i.find(s=>s instanceof Element&&s.parentElement===this&&s.hasAttribute("data-preview-id"));return!o||!(n instanceof Element)||!o.contains(n)?null:this.#Y(n,o)}#ae(e,i){const n=this.#z(e,i);return n===null?null:this.#Y(n.element,n.wrapper)}#z(e,i){if(typeof document.elementsFromPoint!="function")return null;const n=this.#y();for(const o of document.elementsFromPoint(e,i)){const s=n.find(r=>r.contains(o));if(s!==void 0)return{element:o,wrapper:s}}return null}#Y(e,i){const n=i.getAttribute("data-preview-id");if(!n)return null;const o=$o(e,i),s=_o(o,i);return{element:o,target:{previewId:n,selector:s.selector,...s.text===void 0?{}:{text:s.text}}}}#y(){return Array.from(this.children).filter(e=>{const i=e.getAttribute("data-preview-id");return i!==null&&this.#o.includes(i)})}#de=e=>{if(this.#e.kind==="off")return;const i=this.#V(e);i&&(e.preventDefault(),e.stopPropagation(),this.#p=i.element,this.#l({kind:"pick",target:i.target}))};#le=e=>{if(this.#e.kind==="off")return;const i=this.#V(e);this.#R(".ui-hover",i?.element??null)};#pe=()=>{this.#R(".ui-hover",null)};#ce=e=>{const i=e.composedPath()[0];if(!(i instanceof Element)||!i.classList.contains("ui-catcher"))return;const n=this.renderRoot.querySelector(".canvas");let o=this.#z(e.clientX,e.clientY)?.element??null;for(;o!==null&&o!==n;){if(Ns(o,e.deltaX,e.deltaY)){e.preventDefault(),o.scrollBy({left:e.deltaX,top:e.deltaY});return}o=Li(o)}};#H=e=>{e.key!=="Escape"||e.defaultPrevented||(this.#e.kind!=="off"?this.#l({kind:"exit"}):this.#N(null))};#D=()=>{this.#w()};#ue(){this.#d!==null||typeof requestAnimationFrame!="function"||(this.#d=requestAnimationFrame(()=>{this.#d=null,this.#w()}))}#w(){const e=this.renderRoot.querySelector(".canvas");if(e&&this.#B(e,".ui-note-badge","left"),this.#e.kind==="off"||(this.#R(".ui-picked",this.#p),!e))return;const i=this.renderRoot.querySelector(".ui-catcher");if(i){i.style.width=`${e.scrollWidth}px`,i.style.height=`${e.scrollHeight}px`;const n=[...this.renderRoot.querySelectorAll(".demo-controls")].map(o=>o.getBoundingClientRect());i.style.clipPath=mo(i.getBoundingClientRect(),n)}this.#B(e,".ui-pin","right")}#B(e,i,n){for(const o of this.renderRoot.querySelectorAll(i)){const s=this.#fe(o.dataset.preview??""),a=(s?Po(s,o.dataset.selector??""):null)?.getBoundingClientRect();if(!a||a.width===0&&a.height===0){o.hidden=!0;continue}const d=this.#W(e);o.hidden=!1,o.style.left=`${a[n]-d.left}px`,o.style.top=`${a.top-d.top}px`}}#R(e,i){const n=this.renderRoot.querySelector(e),o=this.renderRoot.querySelector(".canvas");if(!n||!o)return;const s=i?.getBoundingClientRect();if(!s){n.hidden=!0;return}const r=this.#W(o);n.hidden=!1,n.style.left=`${s.left-r.left}px`,n.style.top=`${s.top-r.top}px`,n.style.width=`${s.width}px`,n.style.height=`${s.height}px`}#W(e){const i=e.getBoundingClientRect();return{left:i.left+e.clientLeft-e.scrollLeft,top:i.top+e.clientTop-e.scrollTop}}#he(){const e=this.renderRoot.querySelector(".canvas");e===this.#c||this.#v===null||(this.#c!==null&&this.#v.unobserve(this.#c),this.#c=e,e!==null&&this.#v.observe(e))}#q(){const e=this.renderRoot.querySelector('.frame[data-window="device"]'),i=e?.closest(".canvas");if(!e||!(i instanceof HTMLElement))return;const n=getComputedStyle(e),o={width:parseFloat(n.getPropertyValue("--device-width")),height:parseFloat(n.getPropertyValue("--device-height"))},s=getComputedStyle(i),r=i.clientWidth-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight),a=this.#i?.mode==="demo",d=a?Ds*2:0,p=Yo(o,{width:r-d,...a?{height:i.clientHeight-d}:{}});p!==this.#T&&(this.#T=p,this.requestUpdate())}#ve(){for(const e of this.querySelectorAll(":scope > [data-preview-id]"))for(const i of e.querySelectorAll("dialog"))ri(i),ai(this,i)}#F=e=>{const i=e.target;!(i instanceof HTMLDialogElement)||!i.open||Array.from(this.children).some(n=>n.hasAttribute("data-preview-id")&&n.contains(i))&&(ri(i),ai(this,i))};#fe(e){return Array.from(this.children).find(i=>i.getAttribute("data-preview-id")===e)}#ge(){if(this.#O||this.renderRoot.querySelector(".stage")===null)return;this.#O=!0;const e=this.derivation.state,i=[];for(const n of Array.from(this.children)){const o=n.getAttribute("data-preview-id");if(o!==null)for(const s of n.querySelectorAll("a, [data-dpk-navigate]")){const r=so(e,{href:s.getAttribute("href"),navigate:s.getAttribute("data-dpk-navigate")});if(r===null)continue;const a=(s.textContent??"").replace(/\s+/g," ").trim().slice(0,40),d=s.getAttribute("data-dpk-navigate")??s.getAttribute("href")??"(no href)";i.push(` ${o}: <${s.tagName.toLowerCase()}> "${a}" \u2192 ${d} (${r})`)}}i.length!==0&&console.warn(`[dev-process-kit] <dpk-view-prototype>: ${i.length} link(s) in the previews lead nowhere. Point each at the screen it opens (data-dpk-navigate="screen=\u2026"); a link that only moves the scenario on can name a step (data-dpk-navigate="step=\u2026") or a user story (data-dpk-navigate="story=\u2026"):
1866
+ `,qe={kind:"off"},So=(t,e)=>{switch(e.kind){case"toggle":return t.kind==="off"?{kind:"picking",as:"feedback"}:qe;case"exit":return qe;case"pick":return t.kind==="off"?t:{kind:"composing",target:e.target,body:t.kind==="composing"?t.body:"",as:t.as};case"input":return t.kind==="composing"?{...t,body:e.body}:t;case"choose":return t.kind==="off"||t.as===e.as?t:{...t,as:e.as};case"dismiss":case"submitted":return t.kind==="off"?t:{kind:"picking",as:t.as};default:return t}},$o={width:300,height:300},To=360,Ao={width:280,height:360},Io={width:300,height:320},Oi=(t,e)=>({previewId:t.previewId,selector:e.selector,...e.text===void 0?{}:{text:e.text}}),Ci=".comment-pop:not(.ui-notes-pop)",_o="prototype-ui-comment",Po="comment-ui-element",Mi="dpk-view-prototype-document-styles",Do=24,Ro=()=>{if(document.getElementById(Mi)!==null)return;const t=Object.assign(document.createElement("style"),{id:Mi,textContent:Eo});document.head.append(t)},No=(t,e,i)=>{const n=getComputedStyle(t),s=/auto|scroll/.test(n.overflowX)&&t.scrollWidth>t.clientWidth,o=/auto|scroll/.test(n.overflowY)&&t.scrollHeight>t.clientHeight,r=e<0?t.scrollLeft>0:e>0&&t.scrollLeft+t.clientWidth<t.scrollWidth-1,a=i<0?t.scrollTop>0:i>0&&t.scrollTop+t.clientHeight<t.scrollHeight-1;return s&&r||o&&a},Li=t=>{if(t.assignedSlot!==null)return t.assignedSlot;if(t.parentElement!==null)return t.parentElement;const e=t.getRootNode();return e instanceof ShadowRoot?e.host:null},Oo=(t,e)=>{let i=t;for(;i!==null;){if(i===e)return!0;i=Li(i)}return!1};class Ui extends st{static{this.styles=[st.styles,on,rn,pn,cn,un,bn,xo]}#e=qe;#k=!1;#p=null;#s=[];#x=new an(this);#Z={app:new ve(this),activity:new ve(this),story:new ve(this)};#J=new ve(this);#C=!1;#i=null;#o=null;#M=!1;#h=!1;#E=!1;#r=null;#S=null;#$={};#T=1;#v=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{this.#G(),this.#y()});#c=null;#u=null;#f=null;#A=!1;#n=null;#I=null;#g=null;#t=null;#m=null;#L=typeof MutationObserver>"u"?null:new MutationObserver(()=>this.#ve());#U=typeof MutationObserver>"u"?null:new MutationObserver(e=>{e.some(i=>i.attributeName==="data-url")&&this.requestUpdate()});#d=null;constructor(){super(),new ot(this,{open:()=>this.#f!==null,closesOn:e=>!e.some(i=>i instanceof Element&&this.#te(i)),ownsEscape:()=>!0,dismiss:()=>this.#_(!0)}),new ot(this,{open:()=>this.#n!==null,closesOn:e=>!e.some(i=>i instanceof Element&&(i.classList.contains("ui-notes-pop")||i.classList.contains("ui-note-badge"))),ownsEscape:()=>!0,dismiss:()=>this.#P(!0)})}definitionFor(e){return si(e)}connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this.#W),window.addEventListener("resize",this.#D),this.addEventListener("toggle",this.#j,!0),this.addEventListener("click",this.#b,!0),this.addEventListener("auxclick",this.#b,!0),this.#L?.observe(this,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),this.#U?.observe(this,{subtree:!0,attributes:!0,attributeFilter:["data-url"]}),Ro()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.#W),window.removeEventListener("resize",this.#D),this.removeEventListener("toggle",this.#j,!0),this.removeEventListener("click",this.#b,!0),this.removeEventListener("auxclick",this.#b,!0),this.#v?.disconnect(),this.#c=null,this.#L?.disconnect(),this.#U?.disconnect(),this.#d!==null&&cancelAnimationFrame(this.#d),this.#d=null,this.#X()}renderRegions(e){const i=le(this.locale),n=te(e.state,e.navigation),s=pe(e.navigation)==="app";this.#i!==null&&this.#i.mode==="demo"!==s&&this.#K();const o=s?this.#ke(e,i):null;return this.#M=o!==null,this.#s=n!==void 0&&n.kind!=="story"&&(o===null||o.view.entry?.kind==="page")?Ye(e.state,n,e.navigation).shown.map(r=>r.id):[],this.#r!==null&&this.#r.page!==this.#s.join(" ")&&this.#X(),{sidebar:wi(e,i,this.#Z),main:Pi(e,i,{deviceSelect:this.#J,hasPreviewContent:r=>this.#Ae(r),previewUrls:this.#N(),lift:this.#i,onToggleMaximize:()=>this.#O(this.#i===null?"maximized":null),onToggleDemo:()=>this.#O(this.#i===null?"demo":null),onLiftedWheel:this.#be,browser:o===null?null:{...o,loading:this.#r!==null},devices:s?{choice:this.#$,zoom:this.#T,onPick:r=>{this.#$=Us(this.#$,r),this.requestUpdate()}}:null,uiComment:this.#oe(e),uiNotes:this.#ae(e,s),actions:this.#Q(e),canvasEvents:{click:this.#pe,pointermove:this.#ce,pointerleave:this.#ue,wheel:this.#he,scroll:this.#D}})}}updated(){super.updated(),this.#we(),this.#ge(),this.#fe(),this.#G();const e=this.#e;if(e.kind==="composing"&&!this.#s.includes(e.target.previewId)){this.#l({kind:"dismiss"});return}this.#ye(),this.#ie(),this.#E&&(this.#E=!1,this.renderRoot.querySelector('.browser-tab[aria-selected="true"]')?.focus()),this.#y(),this.#de();const i=e.kind==="composing"&&!this.#k;if(this.#k=e.kind==="composing",e.kind!=="composing"||this.#p===null)return;const n=this.renderRoot.querySelector(Ci);n&&(this.#x.open(n,this.#p,$o,{placement:"right-start"}),i&&n.querySelector("textarea")?.focus({preventScroll:!0}))}#Q(e){const i=Kt(e.state,this.#s),n=i.map(o=>o.screen.id).join(" "),s=i.length>0&&this.#u===n;return{groups:i,open:s,toggle:()=>s?this.#_(!1):this.#ee(n),run:(o,r)=>this.#ne(o,r)}}#ee(e){this.#u=e,this.requestUpdate()}#_(e){this.#u!==null&&(this.#u=null,this.#A=e,this.requestUpdate())}#te(e){return e.classList.contains("actions-menu")||e.getAttribute("data-role")==="actions"}#ie(){const e=this.renderRoot.querySelector(".actions-menu"),i=this.renderRoot.querySelector('[data-role="actions"]');if(e===null){this.#f=null,this.#A&&i?.focus({preventScroll:!0}),this.#A=!1;return}e===this.#f||i===null||(this.#f=e,this.#x.open(e,i,Ao),e.querySelector('[role="menuitem"]')?.focus({preventScroll:!0}))}#ne(e,i){this.#_(!0);const n=Kt(this.derivation.state,this.#s).find(d=>d.screen.id===e),s=n?.actions.find(d=>d.id===i);if(n===void 0||s===void 0)return;const r=this.#w().filter(d=>n.previewIds.includes(d.getAttribute("data-preview-id")??"")).map(d=>{const p=[...ks(d,s.fill??{}),...xs(d,s.click??[])];return d.dispatchEvent(new CustomEvent("dpk-action",{bubbles:!0,detail:{id:s.id,screen:n.screen.id}})),p}),a=(r[0]??[]).filter(d=>r.every(p=>p.includes(d)));a.length!==0&&console.warn(`[dev-process-kit] <dpk-view-prototype>: action "${s.id}" of screen "${n.screen.id}" found nothing on screen for: ${a.join(", ")}`)}getContextMenuItems(e){const i=e.origin??null;return!(i instanceof Element)||this.#s.length===0||!this.#se(i)?null:[{id:_o,entries:[{kind:"item",id:Po,label:le(this.locale).commentOnElement,run:()=>{this.#e.kind==="off"&&this.#l({kind:"toggle"})}}]}]}#se(e){const i=this.renderRoot.querySelector(".stage");return i!==null&&Oo(e,i)?!0:this.#w().some(n=>n===e||n.contains(e))}#oe(e){const i=this.#e,n=i.kind==="composing"?i.target:void 0,s=n?E(e.state,n.previewId)?.preview:void 0,o=n?re(n):void 0,r=i.kind==="composing"&&i.as==="note"?(s?.notes??[]).filter(a=>a.selector===n?.selector).map(a=>a.body):e.comments.filter(a=>a.target.type===O&&a.target.id===o).map(a=>Qe(a));return{mode:i,pins:i.kind==="off"?[]:zt(e.comments,this.#s),...n&&s?{targetLabel:Ve(s,n)}:{},notes:r,composer:kn(this.locale),send:a=>this.#l(a),submit:a=>this.#re(e.state,a)}}#l(e){const i=So(this.#e,e);i!==this.#e&&(this.#e=i,i.kind!=="composing"&&(this.#p=null),i.kind!=="off"&&(this.#n=null),this.requestUpdate())}#re(e,i){const n=this.#e;if(n.kind!=="composing")return;(n.as==="note"?this.dispatch(W.addUiNote(n.target,tt("note",_t(e)),i,new Date().toISOString())):this.dispatch({type:dn,target:{type:O,id:re(n.target)},payload:{body:i}})).ok&&this.#l({kind:"submitted"})}#ae(e,i){const n=i?[]:Kn(e.state,this.#s),s=this.#e.kind==="off"&&this.#n!==null?n.find(r=>ie(r)===this.#n)??null:null;s===null&&(this.#n=null);const o=this.#t;return o!==null&&!s?.notes.some(r=>r.id===o.noteId)&&(this.#t=null),{badges:n,open:s,toggle:r=>{const a=ie(r);this.#n===a?this.#P(!1):(this.#n=a,this.#t=null,this.requestUpdate())},close:()=>this.#P(!0),remove:(r,a)=>{const d=r.notes.find(p=>p.id===a);d!==void 0&&this.dispatch(W.deleteUiNote(Oi(r,d),a))},editing:this.#t,edit:(r,a)=>{this.#t={noteId:r,body:a},this.#m={noteId:r,part:"editor"},this.requestUpdate()},input:r=>{this.#t!==null&&(this.#t={...this.#t,body:r}),this.requestUpdate()},save:()=>{const r=this.#t,a=s?.notes.find(p=>p.id===r?.noteId),d=r?.body.trim()??"";s===null||r===null||a===void 0||d===""||(d!==a.body&&this.dispatch(W.setUiNoteBody(Oi(s,a),a.id,d)),this.#V())},cancel:()=>this.#V()}}#V(){this.#t!==null&&(this.#m={noteId:this.#t.noteId,part:"edit"},this.#t=null,this.requestUpdate())}#P(e){this.#n!==null&&(this.#g=e?this.#n:null,this.#n=null,this.requestUpdate())}#de(){const e=this.renderRoot.querySelector(".ui-notes-pop");if(e===null){this.#I=null,this.#g!==null&&this.#z(this.#g)?.focus({preventScroll:!0}),this.#g=null;return}const i=this.#z(e.dataset.key??""),n=this.#m;this.#m=null,n!==null&&e.querySelector(`li[data-id="${CSS.escape(n.noteId)}"]`)?.querySelector(n.part==="editor"?"textarea":'[data-role="edit-note"]')?.focus({preventScroll:!0}),!(e===this.#I||i===null)&&(this.#I=e,this.#x.open(e,i,Io,{placement:"bottom-start"}),e.querySelector('[data-role="close-notes"]')?.focus({preventScroll:!0}))}#z(e){return Array.from(this.renderRoot.querySelectorAll(".ui-note-badge")).find(i=>i.dataset.key===e)??null}#Y(e){const i=e.composedPath(),n=i[0];if(n instanceof Element&&n.classList.contains("ui-catcher"))return this.#le(e.clientX,e.clientY);const s=i.find(o=>o instanceof Element&&o.parentElement===this&&o.hasAttribute("data-preview-id"));return!s||!(n instanceof Element)||!s.contains(n)?null:this.#B(n,s)}#le(e,i){const n=this.#H(e,i);return n===null?null:this.#B(n.element,n.wrapper)}#H(e,i){if(typeof document.elementsFromPoint!="function")return null;const n=this.#w();for(const s of document.elementsFromPoint(e,i)){const o=n.find(r=>r.contains(s));if(o!==void 0)return{element:s,wrapper:o}}return null}#B(e,i){const n=i.getAttribute("data-preview-id");if(!n)return null;const s=Ss(e,i),o=Is(s,i);return{element:s,target:{previewId:n,selector:o.selector,...o.text===void 0?{}:{text:o.text}}}}#w(){return Array.from(this.children).filter(e=>{const i=e.getAttribute("data-preview-id");return i!==null&&this.#s.includes(i)})}#pe=e=>{if(this.#e.kind==="off")return;const i=this.#Y(e);i&&(e.preventDefault(),e.stopPropagation(),this.#p=i.element,this.#l({kind:"pick",target:i.target}))};#ce=e=>{if(this.#e.kind==="off")return;const i=this.#Y(e);this.#R(".ui-hover",i?.element??null)};#ue=()=>{this.#R(".ui-hover",null)};#he=e=>{const i=e.composedPath()[0];if(!(i instanceof Element)||!i.classList.contains("ui-catcher"))return;const n=this.renderRoot.querySelector(".canvas");let s=this.#H(e.clientX,e.clientY)?.element??null;for(;s!==null&&s!==n;){if(No(s,e.deltaX,e.deltaY)){e.preventDefault(),s.scrollBy({left:e.deltaX,top:e.deltaY});return}s=Li(s)}};#W=e=>{e.key!=="Escape"||e.defaultPrevented||(this.#e.kind!=="off"?this.#l({kind:"exit"}):this.#O(null))};#D=()=>{this.#y()};#ve(){this.#d!==null||typeof requestAnimationFrame!="function"||(this.#d=requestAnimationFrame(()=>{this.#d=null,this.#y()}))}#y(){const e=this.renderRoot.querySelector(".canvas");if(e&&this.#q(e,".ui-note-badge","left"),this.#e.kind==="off"||(this.#R(".ui-picked",this.#p),!e))return;const i=this.renderRoot.querySelector(".ui-catcher");if(i){i.style.width=`${e.scrollWidth}px`,i.style.height=`${e.scrollHeight}px`;const n=[...this.renderRoot.querySelectorAll(".demo-controls")].map(s=>s.getBoundingClientRect());i.style.clipPath=gs(i.getBoundingClientRect(),n)}this.#q(e,".ui-pin","right")}#q(e,i,n){for(const s of this.renderRoot.querySelectorAll(i)){const o=this.#me(s.dataset.preview??""),a=(o?_s(o,s.dataset.selector??""):null)?.getBoundingClientRect();if(!a||a.width===0&&a.height===0){s.hidden=!0;continue}const d=this.#F(e);s.hidden=!1,s.style.left=`${a[n]-d.left}px`,s.style.top=`${a.top-d.top}px`}}#R(e,i){const n=this.renderRoot.querySelector(e),s=this.renderRoot.querySelector(".canvas");if(!n||!s)return;const o=i?.getBoundingClientRect();if(!o){n.hidden=!0;return}const r=this.#F(s);n.hidden=!1,n.style.left=`${o.left-r.left}px`,n.style.top=`${o.top-r.top}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}#F(e){const i=e.getBoundingClientRect();return{left:i.left+e.clientLeft-e.scrollLeft,top:i.top+e.clientTop-e.scrollTop}}#fe(){const e=this.renderRoot.querySelector(".canvas");e===this.#c||this.#v===null||(this.#c!==null&&this.#v.unobserve(this.#c),this.#c=e,e!==null&&this.#v.observe(e))}#G(){const e=this.renderRoot.querySelector('.frame[data-window="device"]'),i=e?.closest(".canvas");if(!e||!(i instanceof HTMLElement))return;const n=getComputedStyle(e),s={width:parseFloat(n.getPropertyValue("--device-width")),height:parseFloat(n.getPropertyValue("--device-height"))},o=getComputedStyle(i),r=i.clientWidth-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight),a=this.#i?.mode==="demo",d=a?Do*2:0,p=zs(s,{width:r-d,...a?{height:i.clientHeight-d}:{}});p!==this.#T&&(this.#T=p,this.requestUpdate())}#ge(){for(const e of this.querySelectorAll(":scope > [data-preview-id]"))for(const i of e.querySelectorAll("dialog"))ri(i),ai(this,i)}#j=e=>{const i=e.target;!(i instanceof HTMLDialogElement)||!i.open||Array.from(this.children).some(n=>n.hasAttribute("data-preview-id")&&n.contains(i))&&(ri(i),ai(this,i))};#me(e){return Array.from(this.children).find(i=>i.getAttribute("data-preview-id")===e)}#N(){const e=new Map;for(const i of this.children){const n=i.getAttribute("data-preview-id"),s=i.getAttribute("data-url");n!==null&&s!==null&&s!==""&&e.set(n,s)}return e}#we(){if(this.#C||this.renderRoot.querySelector(".stage")===null)return;this.#C=!0;const e=this.derivation.state,i=[];for(const n of Array.from(this.children)){const s=n.getAttribute("data-preview-id");if(s!==null)for(const o of n.querySelectorAll("a, [data-dpk-navigate]")){const r=os(e,{href:o.getAttribute("href"),navigate:o.getAttribute("data-dpk-navigate")});if(r===null)continue;const a=(o.textContent??"").replace(/\s+/g," ").trim().slice(0,40),d=o.getAttribute("data-dpk-navigate")??o.getAttribute("href")??"(no href)";i.push(` ${s}: <${o.tagName.toLowerCase()}> "${a}" \u2192 ${d} (${r})`)}}i.length!==0&&console.warn(`[dev-process-kit] <dpk-view-prototype>: ${i.length} link(s) in the previews lead nowhere. Point each at the screen it opens (data-dpk-navigate="screen=\u2026"); a link that only moves the scenario on can name a step (data-dpk-navigate="step=\u2026") or a user story (data-dpk-navigate="story=\u2026"):
1863
1867
  `+i.join(`
1864
- `))}#N(e){if(e===(this.#i?.mode??null))return;const i=this.renderRoot.querySelector(".stage"),n=this.#i?.height??i?.offsetHeight??0;this.#G(),e!==null&&(this.#i={mode:e,height:n}),this.#u=null,this.#n=null,e!==null&&this.#e.kind==="composing"&&(ln(this.renderRoot.querySelector(Ci)),this.#k=!1),this.requestUpdate()}#G(){this.#i=null,this.#S=null}#me(){const e=this.renderRoot.querySelector(".stage");if(!(this.#i===null||!e||typeof e.showPopover!="function")&&e!==this.#S){this.#S=e;try{e.showPopover()}catch{}}}#ye=e=>{const i=this.renderRoot.querySelector(".canvas");(i===null||!e.composedPath().includes(i))&&e.preventDefault()};#we(e,i){const n=ci(e.state,e.navigation);this.#s=this.#s===null?n===null?null:xn(n):ct(this.#s,{kind:"observe",page:n});const o=this.#s;if(o===null)return null;const s=ut(o),r=s?.kind!=="page"&&o.seen!==null;if(n===null&&!r)return null;const a=Oo(o)??n;return{view:vi(e.state,o,i,a),shortcuts:s?.kind==="new-tab"?Co(e.state,a):[],switcher:this.#h,send:d=>this.#ke(d)}}#a(e){if(this.#s===null)return;const i=ct(this.#s,e);if(i===this.#s)return;this.#s=i;const n=ut(i);n?.kind==="page"&&this.#be(n.page),this.requestUpdate()}#be(e){this.navigate({screen:e.screen??null,preview:e.preview??null})}#ke(e){switch(e.kind){case"reload":this.#Ee();return;case"address":this.#xe(e.input);return;case"back":case"forward":case"new-tab":this.#h=!1,this.#a({kind:e.kind});return;case"switcher":this.#h=e.open,this.requestUpdate();return;case"activate":this.#h=!1,this.#E=e.focus===!0,this.#a({kind:"activate",id:e.id}),this.requestUpdate();return;case"close-tab":this.#a({kind:e.kind,id:e.id});return;case"visit":this.#a({kind:"visit",page:e.page});return;default:return}}#xe(e){const i=this.#s;if(i===null)return;const n=this.derivation.state,o=vi(n,i,le(this.locale)).url||"https://page.example.com/",s=Do(n,e,o);if(s!==null){this.#a({kind:"visit",page:s});return}this.#a({kind:"unreachable",url:En(e,o)})}#Ee(){if(this.#r!==null)return;const e=setTimeout(()=>{this.#r=null;for(const i of this.#y()){for(const n of i.querySelectorAll("form"))n.reset();for(const n of i.querySelectorAll("dialog"))n.close();i.scrollTop=0,i.dispatchEvent(new CustomEvent("dpk-reload",{bubbles:!0}))}this.renderRoot.querySelector(".browser .viewport")?.scrollTo?.({top:0}),this.requestUpdate()},Ts);this.#r={page:this.#o.join(" "),timer:e},this.requestUpdate()}#j(){this.#r!==null&&(clearTimeout(this.#r.timer),this.#r=null)}#b=e=>{if(!this.#C||this.#e.kind!=="off"||this.#s===null||e.type==="auxclick"&&e.button!==1)return;const i=this.#Se(e);if(i===null)return;const n=e.metaKey||e.ctrlKey||e.button===1;if(!i.blank&&!n)return;e.preventDefault(),e.stopPropagation();const o=ci(this.derivation.state,_e(this.hashFor(i.patch)));if(o===null){n||this.navigate(i.patch);return}this.#a({kind:"open-tab",entry:{kind:"page",page:o},background:n})};#Se(e){const i=e.composedPath();if(!i.some(o=>o instanceof Element&&o.parentElement===this&&o.hasAttribute("data-preview-id")))return null;for(const o of i){if(!(o instanceof Element)||o===this)break;const s=o.getAttribute("data-dpk-navigate"),r=o instanceof HTMLAnchorElement?o.getAttribute("href"):null,a=s??(r?.startsWith("#")?r:null);if(a===null)continue;const d=s!==null&&!s.includes("=")?`step=${s}`:a;return{patch:{..._e(d)},blank:o.getAttribute("target")==="_blank"}}return null}#$e(e){return Array.from(this.querySelectorAll("[data-preview-id]")).some(i=>i.getAttribute("data-preview-id")===e)}}const Vi=()=>{customElements.get("dpk-view-prototype")||customElements.define("dpk-view-prototype",Ui)},Cs=Object.freeze(Object.defineProperty({__proto__:null,DpkViewPrototype:Ui,VIEWPORT_MIN_HEIGHT:Ii,VIEWPORT_WIDTH:Ai,allScreens:H,allStepIds:Pt,applyPrototypeAction:Rt,definePrototypeElement:Vi,describePrototypeAction:Lt,emptyPrototypeBase:Tt,findActivity:U,findPreview:E,findScreen:L,findStep:S,findStory:$,flattenSteps:B,parsePrototypeBase:$t,prototypeAction:W,prototypeActions:m,prototypeBaseSchema:xt,prototypeCommentTargets:Xt,prototypeDefinitionFor:oi,prototypeMessages:le,prototypePageHeading:Zt,prototypeTargetLabel:Vt,prototypeTitle:He,renderFrame:We,renderNav:yi,renderStage:Pi,resolvePrototypeNavigation:xe,serializePrototypeAction:Ut},Symbol.toStringTag,{value:"Module"}));export{Vi as d,Cs as i};
1868
+ `))}#O(e){if(e===(this.#i?.mode??null))return;const i=this.renderRoot.querySelector(".stage"),n=this.#i?.height??i?.offsetHeight??0;this.#K(),e!==null&&(this.#i={mode:e,height:n}),this.#u=null,this.#n=null,e!==null&&this.#e.kind==="composing"&&(ln(this.renderRoot.querySelector(Ci)),this.#k=!1),this.requestUpdate()}#K(){this.#i=null,this.#S=null}#ye(){const e=this.renderRoot.querySelector(".stage");if(!(this.#i===null||!e||typeof e.showPopover!="function")&&e!==this.#S){this.#S=e;try{e.showPopover()}catch{}}}#be=e=>{const i=this.renderRoot.querySelector(".canvas");(i===null||!e.composedPath().includes(i))&&e.preventDefault()};#ke(e,i){const n=ci(e.state,e.navigation);this.#o=this.#o===null?n===null?null:xn(n):ct(this.#o,{kind:"observe",page:n});const s=this.#o;if(s===null)return null;const o=ut(s),r=o?.kind!=="page"&&s.seen!==null;if(n===null&&!r)return null;const a=Ns(s)??n;return{view:vi(e.state,s,i,a,this.#N()),shortcuts:o?.kind==="new-tab"?Os(e.state,a):[],switcher:this.#h,send:d=>this.#Ee(d)}}#a(e){if(this.#o===null)return;const i=ct(this.#o,e);if(i===this.#o)return;this.#o=i;const n=ut(i);n?.kind==="page"&&this.#xe(n.page),this.requestUpdate()}#xe(e){this.navigate({screen:e.screen??null,preview:e.preview??null})}#Ee(e){switch(e.kind){case"reload":this.#$e();return;case"address":this.#Se(e.input);return;case"back":case"forward":case"new-tab":this.#h=!1,this.#a({kind:e.kind});return;case"switcher":this.#h=e.open,this.requestUpdate();return;case"activate":this.#h=!1,this.#E=e.focus===!0,this.#a({kind:"activate",id:e.id}),this.requestUpdate();return;case"close-tab":this.#a({kind:e.kind,id:e.id});return;case"visit":this.#a({kind:"visit",page:e.page});return;default:return}}#Se(e){const i=this.#o;if(i===null)return;const n=this.derivation.state,s=this.#N(),o=vi(n,i,le(this.locale),null,s).url||"https://page.example.com/",r=Ps(n,e,o,s);if(r!==null){this.#a({kind:"visit",page:r});return}this.#a({kind:"unreachable",url:En(e,o)})}#$e(){if(this.#r!==null)return;const e=setTimeout(()=>{this.#r=null;for(const i of this.#w()){for(const n of i.querySelectorAll("form"))n.reset();for(const n of i.querySelectorAll("dialog"))n.close();i.scrollTop=0,i.dispatchEvent(new CustomEvent("dpk-reload",{bubbles:!0}))}this.renderRoot.querySelector(".browser .viewport")?.scrollTo?.({top:0}),this.requestUpdate()},To);this.#r={page:this.#s.join(" "),timer:e},this.requestUpdate()}#X(){this.#r!==null&&(clearTimeout(this.#r.timer),this.#r=null)}#b=e=>{if(!this.#M||this.#e.kind!=="off"||this.#o===null||e.type==="auxclick"&&e.button!==1)return;const i=this.#Te(e);if(i===null)return;const n=e.metaKey||e.ctrlKey||e.button===1;if(!i.blank&&!n)return;e.preventDefault(),e.stopPropagation();const s=ci(this.derivation.state,_e(this.hashFor(i.patch)));if(s===null){n||this.navigate(i.patch);return}this.#a({kind:"open-tab",entry:{kind:"page",page:s},background:n})};#Te(e){const i=e.composedPath();if(!i.some(s=>s instanceof Element&&s.parentElement===this&&s.hasAttribute("data-preview-id")))return null;for(const s of i){if(!(s instanceof Element)||s===this)break;const o=s.getAttribute("data-dpk-navigate"),r=s instanceof HTMLAnchorElement?s.getAttribute("href"):null,a=o??(r?.startsWith("#")?r:null);if(a===null)continue;const d=o!==null&&!o.includes("=")?`step=${o}`:a;return{patch:{..._e(d)},blank:s.getAttribute("target")==="_blank"}}return null}#Ae(e){return Array.from(this.querySelectorAll("[data-preview-id]")).some(i=>i.getAttribute("data-preview-id")===e)}}const Vi=()=>{customElements.get("dpk-view-prototype")||customElements.define("dpk-view-prototype",Ui)},Co=Object.freeze(Object.defineProperty({__proto__:null,DpkViewPrototype:Ui,VIEWPORT_MIN_HEIGHT:Ii,VIEWPORT_WIDTH:Ai,allScreens:H,allStepIds:Pt,applyPrototypeAction:Rt,definePrototypeElement:Vi,describePrototypeAction:Lt,emptyPrototypeBase:Tt,findActivity:U,findPreview:E,findScreen:L,findStep:S,findStory:$,flattenSteps:B,parsePrototypeBase:$t,prototypeAction:W,prototypeActions:m,prototypeBaseSchema:xt,prototypeCommentTargets:Xt,prototypeDefinitionFor:si,prototypeMessages:le,prototypePageHeading:Zt,prototypeTargetLabel:Vt,prototypeTitle:He,renderFrame:We,renderNav:wi,renderStage:Pi,resolvePrototypeNavigation:xe,serializePrototypeAction:Ut},Symbol.toStringTag,{value:"Module"}));export{Vi as d,Co as i};