wicked-studio 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "id": "wicked-deck",
3
3
  "title": "Slides",
4
- "version": "0.8.0",
4
+ "version": "0.9.0",
5
5
  "protocol": [
6
- 1
6
+ 1,
7
+ 2
7
8
  ],
8
9
  "kinds": [
9
10
  "deck"
@@ -30,6 +31,58 @@
30
31
  {
31
32
  "id": "ui.fullscreen",
32
33
  "why": "to present the deck full screen"
34
+ },
35
+ {
36
+ "id": "artifact.export",
37
+ "why": "to offer the deck as PowerPoint or PDF from its card (the host makes the file)"
38
+ },
39
+ {
40
+ "id": "artifact.theme",
41
+ "why": "to change the deck’s theme, colours and fonts from its Style tab, as one version with Undo"
33
42
  }
34
- ]
43
+ ],
44
+ "surfaces": {
45
+ "card": {
46
+ "interactive": true,
47
+ "aspect": "16:9",
48
+ "actions": [
49
+ {
50
+ "id": "prev",
51
+ "label": "Previous slide",
52
+ "verb": "plugin"
53
+ },
54
+ {
55
+ "id": "next",
56
+ "label": "Next slide",
57
+ "verb": "plugin",
58
+ "primary": true
59
+ },
60
+ {
61
+ "id": "ask",
62
+ "label": "Ask about this",
63
+ "verb": "host:ask"
64
+ },
65
+ {
66
+ "id": "export",
67
+ "label": "Export",
68
+ "verb": "host:export"
69
+ }
70
+ ]
71
+ },
72
+ "options": {
73
+ "tabs": [
74
+ {
75
+ "id": "style",
76
+ "label": "Style",
77
+ "render": "plugin"
78
+ },
79
+ {
80
+ "id": "notes",
81
+ "label": "Speaker notes",
82
+ "render": "plugin"
83
+ }
84
+ ]
85
+ },
86
+ "full": {}
87
+ }
35
88
  }
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="wicked-editor" content="wicked-deck">
6
- <meta name="wicked-editor-version" content="0.8.0">
6
+ <meta name="wicked-editor-version" content="0.9.0">
7
7
  <title>Slides</title>
8
8
  <style>
9
9
  /* The editor's own chrome takes the host's tokens (`host.hello.theme` / `host.theme`), with plain
@@ -19,7 +19,7 @@
19
19
  .deck { position: relative; display: grid; grid-template-columns: 196px minmax(0, 1fr); width: 100%; height: 100%; outline: none; }
20
20
  .deck:focus { box-shadow: inset 0 0 0 2px var(--accent); }
21
21
  body[data-size="inline"] .deck, body[data-present="true"] .deck { grid-template-columns: minmax(0, 1fr); }
22
- body[data-size="inline"] .deck { pointer-events: none; }
22
+ body[data-size="inline"]:not([data-protocol="2"]) .deck { pointer-events: none; }
23
23
  body[data-size="inline"] .strip, body[data-size="inline"] .tools, body[data-size="inline"] .notes,
24
24
  body[data-present="true"] .strip, body[data-present="true"] .tools, body[data-present="true"] .notes { display: none; }
25
25
 
@@ -50,8 +50,22 @@
50
50
  .menu button { text-align: left; border-color: transparent; }
51
51
 
52
52
  .stage { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: var(--surface-card); }
53
+ .slide-box { position: absolute; overflow: hidden; }
54
+ .stage[data-zoom="100"] { overflow: auto; }
53
55
  .stage iframe { position: absolute; left: 0; top: 0; border: 0; background: var(--surface-base); transform-origin: 0 0; box-shadow: 0 1px 6px rgba(0,0,0,.08); }
54
56
  body[data-present="true"] .stage { background: #111; }
57
+ .zoom { display: flex; }
58
+ .zoom button[aria-pressed="true"] { border-color: var(--accent); background: var(--surface-raised); }
59
+ .cutoff { position: absolute; z-index: 3; pointer-events: none; color: var(--ink-high); }
60
+ .cutoff[data-edge="bottom"] { border-top: 1px dashed var(--accent); }
61
+ .cutoff[data-edge="right"] { border-left: 1px dashed var(--accent); }
62
+ .cutoff span { position: absolute; font-size: 10px; white-space: nowrap; padding: 2px 5px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface-raised); }
63
+ .cutoff[data-edge="bottom"] span { bottom: 3px; left: 8px; }
64
+ .cutoff[data-edge="right"] span { right: 3px; top: 8px; }
65
+ body[data-surface="options"][data-protocol="2"] .deck { grid-template-columns: minmax(0, 1fr); }
66
+ #style-panel { overflow: auto; height: 100%; }
67
+ body[data-surface="options"][data-protocol="2"] .notes { flex: 1; align-content: start; border-top: 0; }
68
+ body[data-surface="options"][data-protocol="2"] .notes textarea { min-height: 180px; max-height: none; }
55
69
  .box { position: absolute; pointer-events: none; border: 2px solid var(--accent); border-radius: 3px; box-sizing: border-box; z-index: 2; }
56
70
  .box--hover { border-style: dashed; opacity: .55; }
57
71
  .input { position: absolute; z-index: 3; box-sizing: border-box; font: inherit; font-size: 14px; line-height: 1.35; padding: 4px 6px; border: 2px solid var(--accent); border-radius: 3px; background: var(--surface-base); color: var(--ink-high); outline: none; resize: none; overflow: auto; }
@@ -70,7 +84,14 @@
70
84
  </style>
71
85
  </head>
72
86
  <body data-size="pane">
73
- <script>var wickedEditor=(function(le){"use strict";const pe="section, [data-slide], .slide",ot=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),se="aside[data-notes-for]",Be=80,Ne=o=>{const i=o.tagName.toLowerCase();return!ot.has(i)&&!(i==="aside"&&o.hasAttribute("data-notes-for"))};function Ye(o){return Array.from(o.querySelectorAll(pe)).filter(i=>{if(!Ne(i)||i.closest(se)!==null)return!1;for(let d=i.parentElement;d!==null;d=d.parentElement)if(d.matches(pe)&&Ne(d))return!1;return!0})}const ye=o=>o.replace(/\s+/g," ").trim(),it=o=>o.length>Be?`${o.slice(0,Be-1).trimEnd()}…`:o;function rt(o){const i=Array.from(o.querySelectorAll(se)).find(d=>d.parentElement?.closest(pe)===o);return i===void 0?"":(i.textContent??"").trim()}function lt(o){const i=o.cloneNode(!0);for(const d of Array.from(i.querySelectorAll(se)))d.remove();for(const d of Array.from(i.querySelectorAll("h1,h2,h3,h4,h5,h6,p,li,td,th,div,section,figcaption,blockquote,br")))d.append(" ");return ye(i.textContent??"")}function st(o){const i=new DOMParser().parseFromString(o,"text/html");return Ye(i).map((d,c)=>{const y=Array.from(d.querySelectorAll("h1,h2,h3,h4,h5,h6")).find(b=>b.closest(se)===null&&ye(b.textContent??"")!==""),g=lt(d);return{id:d.getAttribute("data-slide-id"),wid:d.getAttribute("data-wid"),n:c+1,title:it(y!==void 0?ye(y.textContent??""):g),notes:rt(d),text:g}})}function at(o,i,d){return{left:o.left-(d.scrollX-i.scrollX),top:o.top-(d.scrollY-i.scrollY),width:o.width,height:o.height}}const dt=/^[A-Za-z0-9_.:-]{1,100}$/;function E(o){return typeof o=="number"&&isFinite(o)}function ct(o){if(typeof o!="object"||o===null)return!1;const i=o;return i.section!==void 0&&(typeof i.section!="string"||!dt.test(i.section))?!1:typeof i.text=="string"&&typeof i.composite=="boolean"}function ut(o){if(typeof o!="object"||o===null)return!1;const i=o;return E(i.x)&&E(i.y)&&E(i.width)&&E(i.height)&&E(i.top)&&E(i.left)&&E(i.right)&&E(i.bottom)}function ft(o){if(typeof o!="object"||o===null)return null;const i=o;if(i.v!==1)return null;const d=i.type;if(d==="wid-inventory"){const c=i.widMap,y=i.scrollX,g=i.scrollY;if(typeof c!="object"||c===null||!E(y)||!E(g))return null;const b={};for(const[V,w]of Object.entries(c)){if(!ut(w))return null;b[V]=w}const j=i.blocks;if(j===void 0)return{v:1,type:"wid-inventory",widMap:b,scrollX:y,scrollY:g};if(typeof j!="object"||j===null)return null;const ne={};for(const[V,w]of Object.entries(j)){if(!ct(w))return null;ne[V]={text:w.text,composite:w.composite,...w.cut===!0?{cut:!0}:{},...w.section!==void 0?{section:w.section}:{}}}return{v:1,type:"wid-inventory",widMap:b,scrollX:y,scrollY:g,blocks:ne}}if(d==="scroll-state"){const c=i.scrollX,y=i.scrollY;return!E(c)||!E(y)?null:{v:1,type:"scroll-state",scrollX:c,scrollY:y}}if(d==="scroll-ack"){const c=i.wid;if(typeof c!="string"||c==="")return null;const y=i.scrollX,g=i.scrollY,b=i.seq;return{v:1,type:"scroll-ack",wid:c,...E(y)&&E(g)?{scrollX:y,scrollY:g}:{},...typeof b=="number"&&Number.isInteger(b)&&b>0?{seq:b}:{}}}if(d==="wid-click"){const c=i.wid;return typeof c!="string"||c===""?null:{v:1,type:"wid-click",wid:c}}if(d==="wid-hover"){const c=i.wid;return c!==null&&(typeof c!="string"||c==="")?null:{v:1,type:"wid-hover",wid:c}}return null}const pt=Object.freeze({v:1,type:"request-inventory"}),yt="request-inventory";function vt(o){return o.includes(yt)}const ht=`
87
+ <script>var wickedEditor=(function(X){"use strict";var Fn=Object.defineProperty;var Kn=(X,Z,Se)=>Z in X?Fn(X,Z,{enumerable:!0,configurable:!0,writable:!0,value:Se}):X[Z]=Se;var _t=(X,Z,Se)=>Kn(X,typeof Z!="symbol"?Z+"":Z,Se);const qt={card:{interactive:!0,aspect:"16:9",actions:[{id:"prev",label:"Previous slide",verb:"plugin"},{id:"next",label:"Next slide",verb:"plugin",primary:!0},{id:"ask",label:"Ask about this",verb:"host:ask"},{id:"export",label:"Export",verb:"host:export"}]},options:{tabs:[{id:"style",label:"Style",render:"plugin"},{id:"notes",label:"Speaker notes",render:"plugin"}]},full:{}},Nt={"Alt+J":{verb:"navigate",what:"next card or row"},"Alt+K":{verb:"navigate",what:"previous card or row"},"Alt+/":{verb:"navigate",what:"the keyboard shortcuts overlay"},"Alt+P":{verb:"navigate",what:"peek at the top item that needs you"},"Alt+G":{verb:"navigate",what:"jump to the top item that needs you"},"Alt+B":{verb:"navigate",what:"back to where you were"},"Alt+T":{verb:"navigate",what:"the run’s evidence timeline"},"Alt+U":{verb:"navigate",what:"the run’s unit list"},"Alt+A":{verb:"approve",what:"approve the open gate"},"Alt+R":{verb:"decide",what:"reject the open gate"},"Alt+X":{verb:"decide",what:"select a gate for batch resolution"},"Alt+N":{verb:"compose",what:"compose a steer note"}},Pt=new Set(["Escape","Mod+K","Tab","Shift+Tab"]);function ct(o){if(Pt.has(o))return!0;const r=Nt[Rt(o)];return r!==void 0&&r.verb==="navigate"}function Rt(o){const r=/^alt\+(.)$/i.exec(o);return r===null?o:`Alt+${r[1].toUpperCase()}`}const $e="wicked.editor",Ce=1,ut=o=>typeof o=="object"&&o!==null&&!Array.isArray(o),It=["card","options","full"];function jt(o){return o==="inline"?"card":o==="pane"?"options":"full"}function ft(o){return o==="card"?"inline":o==="options"?"pane":"full"}function Xt(o){const r=ut(o)?o:{},i=r.size==="inline"||r.size==="full"?r.size:"pane",d=r.protocol===2?2:1,c=d===2&&typeof r.tab=="string"?r.tab:null,u=d===2&&It.includes(r.surface)?r.surface:jt(i),h=u==="options"&&c===null?"full":u,m=d===2&&(r.mode==="simple"||r.mode==="advanced")?r.mode:null;return{protocol:d,surface:h,tab:c,mode:m,size:i}}function Yt(o,r,i){return{editor:o,version:r,protocol:[1,2],surfaces:i}}function Ht(o,r){const i=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:$e,v:Ce,type:"plugin.ready",payload:Yt(o,i,r)},"*")}function pt(o,r,i){const d=o.metaKey||o.ctrlKey;let c=null;if(o.key==="Escape")c="Escape";else if(d&&!o.altKey&&o.key.toLowerCase()==="k")c="Mod+K";else if(o.altKey&&!d&&/^Key[A-Z]$/.test(o.code)&&ct(`Alt+${o.code.slice(3)}`))c=`Alt+${o.code.slice(3)}`;else if(o.key==="Tab"){const u=Array.from(r.querySelectorAll("button, input, select, textarea, [tabindex]")).filter(m=>m.tabIndex>=0&&!m.matches(":disabled")&&m.closest("[hidden]")===null),h=u.indexOf(o.target);(o.shiftKey?h<=0:h===-1||h===u.length-1)&&(c=o.shiftKey?"Shift+Tab":"Tab")}return c===null?!1:(o.preventDefault(),o.stopPropagation(),i(c),!0)}class Wt{constructor(r,i){_t(this,"revs",new Map);this.port=r,this.h=i}reply(r,i){this.port.postMessage({p:$e,v:Ce,re:r,ok:!0,payload:i})}refuse(r,i,d){this.port.postMessage({p:$e,v:Ce,re:r,ok:!1,error:{code:i,message:d}})}bump(r){const i=(this.revs.get(r)??0)+1;return this.revs.set(r,i),i}values(r,i){this.port.postMessage({p:$e,v:Ce,type:"options.values",payload:{tab:r,rev:this.bump(r),values:i}})}height(r){this.port.postMessage({p:$e,v:Ce,type:"ui.height",payload:{px:Math.round(r)}})}dispatch(r){const i=ut(r.payload)?r.payload:{},d=typeof r.id=="string"?r.id:null;switch(r.type){case"host.surface":{const c=i.surface;return(c==="card"||c==="options"||c==="full")&&this.h.surface?.(c,i.mode==="simple"||i.mode==="advanced"?i.mode:null),!0}case"host.mode":{if(d===null)return!0;const c=i.mode;return c!=="simple"&&c!=="advanced"?(this.refuse(d,"bad_request","mode is simple or advanced"),!0):(this.reply(d,{mode:this.h.mode?.(c)??c}),!0)}case"host.action":{if(d===null)return!0;const c=i.id;return typeof c!="string"||this.h.action===void 0?(this.reply(d,{handled:!1}),!0):(Promise.resolve(this.h.action(c)).then(u=>this.reply(d,{handled:u.handled===!0,...typeof u.status=="string"?{status:u.status.slice(0,120)}:{}}),()=>this.reply(d,{handled:!1})),!0)}case"host.tab":return typeof i.tab=="string"&&this.h.tab?.(i.tab),!0;case"host.selection":return Array.isArray(i.anchors)&&this.h.selection?.(i.anchors),!0;case"options.changed":{if(d===null)return!0;const c=i.tab,u=i.id;return typeof c!="string"||typeof u!="string"||this.h.optionsChanged===void 0?(this.refuse(d,"unsupported","no controls here"),!0):(Promise.resolve(this.h.optionsChanged(c,u,i.value)).then(h=>this.reply(d,{applied:h.applied,rev:this.bump(c),values:h.values,...h.reason!==void 0?{reason:h.reason.slice(0,120)}:{}}),h=>this.refuse(d,"unavailable",h instanceof Error?h.message.slice(0,120):"failed")),!0)}default:return!1}}}const Oe=[{name:"corporate-light",display_name:"Corporate Light",colors:{background:"#FFFFFF",surface:"#F8FAFC",primary:"#1E3A5F",secondary:"#2563EB",accent:"#0891B2",text_primary:"#1E293B",text_secondary:"#64748B",text_muted:"#94A3B8",border:"#E2E8F0"},fonts:{heading:"Calibri",body:"Calibri",mono:"Consolas"}},{name:"midnight-purple",display_name:"Midnight Purple",colors:{background:"#0A0A0F",surface:"#13091D",primary:"#A100FF",secondary:"#6B2FA0",accent:"#F59E0B",text_primary:"#FFFFFF",text_secondary:"#A0A0B0",text_muted:"#6B6B80",border:"#2A2A3D"},fonts:{heading:"Calibri",body:"Calibri",mono:"Consolas"}},{name:"warm-dark",display_name:"Warm Dark",colors:{background:"#1A1A2E",surface:"#16213E",primary:"#FF6B6B",secondary:"#C44569",accent:"#FFD93D",text_primary:"#F8F8F2",text_secondary:"#B0B0C0",text_muted:"#6B6B80",border:"#2D2D44"},fonts:{heading:"Calibri",body:"Calibri",mono:"Consolas"}}],ht=["Inter","Roboto","Source Sans 3","IBM Plex Sans","Calibri","Georgia","system-ui"],Ut=[["background","Background"],["surface","Surface"],["primary","Primary"],["accent","Accent"],["text_primary","Text"]],Be=o=>({name:o.name,colors:{...o.colors},fonts:{...o.fonts}});function Gt(o,r){o.replaceChildren(),o.classList.add("plugin-style"),o.onkeydown=b=>{r.key!==void 0&&pt(b,o,r.key)};const i=document.createElement("style");i.textContent=`.plugin-style{padding:16px;box-sizing:border-box;color:var(--ink-high);background:var(--surface-base);font:13px var(--font-sans,system-ui)}
88
+ .plugin-style h2{font-size:16px;margin:0 0 12px}.plugin-style .theme-cards{display:grid;gap:8px;margin-bottom:18px}
89
+ .plugin-style button,.plugin-style input,.plugin-style select{font:inherit;color:var(--ink-high);background:var(--surface-card);border:1px solid var(--border);border-radius:4px}
90
+ .plugin-style button{padding:8px;text-align:left;cursor:pointer}.plugin-style button:focus-visible,.plugin-style input:focus-visible,.plugin-style select:focus-visible{outline:2px solid var(--accent)}
91
+ .plugin-style .ps-swatches{display:flex;width:100%;height:16px;margin-bottom:6px;border:1px solid var(--border)}.plugin-style .ps-swatches span{flex:1}
92
+ .plugin-style label{display:flex;align-items:center;gap:8px;margin:10px 0}.plugin-style label>span:first-child{flex:1}.plugin-style input[type=color]{width:36px;height:30px;padding:2px}.plugin-style input[type=text]{width:80px;padding:5px}.plugin-style select{max-width:170px;padding:5px}
93
+ .plugin-style p{line-height:1.5;color:var(--ink-body)}.plugin-style [role=status]{min-height:1.5em}.plugin-style :disabled{opacity:.6;cursor:default}`,o.append(i);const d=document.createElement("h2");d.textContent="Style",o.append(d);const c=document.createElement("div");c.className="theme-cards",o.append(c);const u=document.createElement("p");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let h=!1;const m=[],F=()=>Be(r.tokens()??Oe[0]),U=[],K=[],te=()=>{const b=F();for(const{key:p,picker:C,hex:L}of U)L.value=b.colors[p],C.value=/^#[0-9a-f]{6}$/i.test(b.colors[p])?b.colors[p]:"";for(const{key:p,select:C}of K)C.value=ht.includes(b.fonts[p])?b.fonts[p]:"system-ui";for(const p of Array.from(c.querySelectorAll("button")))p.setAttribute("aria-pressed",String(p.dataset.theme===b.name))},G=async b=>{if(!h){h=!0,m.forEach(p=>{p.disabled=!0}),u.textContent="Applying theme…";try{const p=await r.apply(b);u.textContent=p.ok?"Theme applied.":`Theme was not applied: ${p.reason}`}catch(p){u.textContent=`Theme was not applied: ${p instanceof Error?p.message:"unavailable"}`}finally{h=!1,m.forEach(p=>{p.disabled=!1}),te()}}};for(const b of Oe){const p=document.createElement("button");p.type="button",p.dataset.theme=b.name;const C=document.createElement("span");C.className="ps-swatches",C.setAttribute("aria-hidden","true");for(const S of["background","surface","primary","secondary","accent"]){const M=document.createElement("span");M.style.backgroundColor=b.colors[S],C.append(M)}const L=document.createElement("span");L.textContent=b.display_name,p.append(C,L),p.addEventListener("click",()=>{G(Be(b))}),c.append(p),m.push(p)}for(const[b,p]of Ut){const C=document.createElement("label"),L=document.createElement("span");L.textContent=p;const S=document.createElement("input");S.type="color",S.setAttribute("aria-label",p);const M=document.createElement("input");M.type="text",M.maxLength=7,M.setAttribute("aria-label",`${p} hex`);const Me=ve=>{if(!/^#[0-9a-f]{6}$/i.test(ve)){u.textContent="Enter a six-digit hex colour: a # and six digits or letters a to f.",te();return}const ae=F();ae.name="custom",ae.colors[b]=ve,G(ae)};S.addEventListener("change",()=>Me(S.value)),M.addEventListener("change",()=>Me(M.value)),C.append(L,S,M),o.append(C),m.push(S,M),U.push({key:b,picker:S,hex:M})}for(const b of["heading","body"]){const p=document.createElement("label"),C=document.createElement("span");C.textContent=b==="heading"?"Heading font":"Body font";const L=document.createElement("select");L.setAttribute("aria-label",C.textContent);for(const S of ht){const M=document.createElement("option");M.value=S,M.textContent=S,L.append(M)}L.addEventListener("change",()=>{const S=F();S.name="custom",S.fonts[b]=L.value,G(S)}),p.append(C,L),o.append(p),m.push(L),K.push({key:b,select:L})}const Y=document.createElement("p");return Y.textContent="Match a website or a PDF: the host's Match button under this tab",o.append(Y,u),te(),{refresh:te}}function Jt(o){const r=new DOMParser().parseFromString(o,"text/html"),i=Array.from(r.querySelectorAll("style")).map(m=>m.textContent??"").join(`
94
+ `),d=new Map;for(const m of i.matchAll(/(--wi-[a-z-]+)\s*:\s*([^;}{]+)/gi))d.set(m[1].toLowerCase(),m[2].trim());if(d.size===0)return null;const c=Be(Oe[0]),u={background:"--wi-bg",surface:"--wi-surface",primary:"--wi-primary",secondary:"--wi-secondary",accent:"--wi-accent",text_primary:"--wi-text",text_secondary:"--wi-text-secondary",text_muted:"--wi-muted",border:"--wi-border"};for(const m of Object.keys(u)){const F=d.get(u[m]);F!==void 0&&/^(#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgb|hsl)a?\([0-9.,%\s]+\))$/i.test(F)&&(c.colors[m]=F)}for(const m of["heading","body","mono"]){const F=d.get(`--wi-font-${m}`);F!==void 0&&(c.fonts[m]=F.split(",")[0].trim().replace(/^['"]|['"]$/g,""))}const h=Oe.find(m=>JSON.stringify(m.colors)===JSON.stringify(c.colors)&&JSON.stringify(m.fonts)===JSON.stringify(c.fonts));return c.name=h?.name??"custom",c}const je="section, [data-slide], .slide",Vt=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Fe="aside[data-notes-for]",yt=80,mt=o=>{const r=o.tagName.toLowerCase();return!Vt.has(r)&&!(r==="aside"&&o.hasAttribute("data-notes-for"))};function vt(o){return Array.from(o.querySelectorAll(je)).filter(r=>{if(!mt(r)||r.closest(Fe)!==null)return!1;for(let i=r.parentElement;i!==null;i=i.parentElement)if(i.matches(je)&&mt(i))return!1;return!0})}const Xe=o=>o.replace(/\s+/g," ").trim(),Zt=o=>o.length>yt?`${o.slice(0,yt-1).trimEnd()}…`:o;function Qt(o){const r=Array.from(o.querySelectorAll(Fe)).find(i=>i.parentElement?.closest(je)===o);return r===void 0?"":(r.textContent??"").trim()}function en(o){const r=o.cloneNode(!0);for(const i of Array.from(r.querySelectorAll(Fe)))i.remove();for(const i of Array.from(r.querySelectorAll("h1,h2,h3,h4,h5,h6,p,li,td,th,div,section,figcaption,blockquote,br")))i.append(" ");return Xe(r.textContent??"")}function tn(o){const r=new DOMParser().parseFromString(o,"text/html");return vt(r).map((i,d)=>{const c=Array.from(i.querySelectorAll("h1,h2,h3,h4,h5,h6")).find(h=>h.closest(Fe)===null&&Xe(h.textContent??"")!==""),u=en(i);return{id:i.getAttribute("data-slide-id"),wid:i.getAttribute("data-wid"),n:d+1,title:Zt(c!==void 0?Xe(c.textContent??""):u),notes:Qt(i),text:u}})}function nn(o,r,i){return{left:o.left-(i.scrollX-r.scrollX),top:o.top-(i.scrollY-r.scrollY),width:o.width,height:o.height}}const on=/^[A-Za-z0-9_.:-]{1,100}$/;function _(o){return typeof o=="number"&&isFinite(o)}function rn(o){if(typeof o!="object"||o===null)return!1;const r=o;return r.section!==void 0&&(typeof r.section!="string"||!on.test(r.section))?!1:typeof r.text=="string"&&typeof r.composite=="boolean"}function sn(o){if(typeof o!="object"||o===null)return!1;const r=o;return _(r.x)&&_(r.y)&&_(r.width)&&_(r.height)&&_(r.top)&&_(r.left)&&_(r.right)&&_(r.bottom)}function ln(o){if(typeof o!="object"||o===null)return null;const r=o;if(r.v!==1)return null;const i=r.type;if(i==="wid-inventory"){const d=r.widMap,c=r.scrollX,u=r.scrollY;if(typeof d!="object"||d===null||!_(c)||!_(u))return null;const h={};for(const[U,K]of Object.entries(d)){if(!sn(K))return null;h[U]=K}const m=r.blocks;if(m===void 0)return{v:1,type:"wid-inventory",widMap:h,scrollX:c,scrollY:u};if(typeof m!="object"||m===null)return null;const F={};for(const[U,K]of Object.entries(m)){if(!rn(K))return null;F[U]={text:K.text,composite:K.composite,...K.cut===!0?{cut:!0}:{},...K.section!==void 0?{section:K.section}:{}}}return{v:1,type:"wid-inventory",widMap:h,scrollX:c,scrollY:u,blocks:F}}if(i==="scroll-state"){const d=r.scrollX,c=r.scrollY;return!_(d)||!_(c)?null:{v:1,type:"scroll-state",scrollX:d,scrollY:c}}if(i==="scroll-ack"){const d=r.wid;if(typeof d!="string"||d==="")return null;const c=r.scrollX,u=r.scrollY,h=r.seq;return{v:1,type:"scroll-ack",wid:d,..._(c)&&_(u)?{scrollX:c,scrollY:u}:{},...typeof h=="number"&&Number.isInteger(h)&&h>0?{seq:h}:{}}}if(i==="wid-click"){const d=r.wid;return typeof d!="string"||d===""?null:{v:1,type:"wid-click",wid:d}}if(i==="wid-hover"){const d=r.wid;return d!==null&&(typeof d!="string"||d==="")?null:{v:1,type:"wid-hover",wid:d}}return null}const an=Object.freeze({v:1,type:"request-inventory"}),dn="request-inventory";function cn(o){return o.includes(dn)}const un=`
74
95
  (function () {
75
96
  if (window.__wickedInstrumentBridge) return;
76
97
  window.__wickedInstrumentBridge = 1;
@@ -148,7 +169,7 @@
148
169
  post(inventory());
149
170
  }
150
171
  })();
151
- `;function mt(o){const i=`<script>${ht}<\/script>`;return/<\/body>/i.test(o)?o.replace(/<\/body>/i,()=>`${i}</body>`):`${o}${i}`}const F="wicked.editor",G=1,wt="wicked-deck",ve=1280,he=720,gt=[0,250,750,1500],bt=1500,kt=`
172
+ `;function fn(o){const r=`<script>${un}<\/script>`;return/<\/body>/i.test(o)?o.replace(/<\/body>/i,()=>`${r}</body>`):`${o}${r}`}const Le="wicked.editor",Ke=1,pn="wicked-deck",Q=1280,ee=720,hn=[0,250,750,1500],yn=1500,mn=`
152
173
  <div data-testid="deck-editor" id="deck" class="deck" data-kind="deck" data-head="" data-current="" data-count="0" data-size="pane" data-present="false" data-selected="" tabindex="0" role="application" aria-label="The deck">
153
174
  <nav id="strip" class="strip" aria-label="Slides" data-testid="deck-strip"><ol id="thumbs"></ol></nav>
154
175
  <div class="main">
@@ -159,10 +180,20 @@
159
180
  <button type="button" id="up" data-testid="deck-move-up" title="Move this slide up (⌥↑)" aria-label="Move up">↑ Up</button>
160
181
  <button type="button" id="down" data-testid="deck-move-down" title="Move this slide down (⌥↓)" aria-label="Move down">↓ Down</button>
161
182
  <button type="button" id="del" class="danger" data-testid="deck-delete" title="Delete this slide (⌘⌫) — Undo puts it back">Delete</button>
183
+ <div class="zoom" role="group" aria-label="Slide zoom">
184
+ <button type="button" id="fit" data-testid="deck-fit" aria-pressed="true">Fit</button>
185
+ <button type="button" id="zoom-100" data-testid="deck-zoom-100" aria-pressed="false">100%</button>
186
+ </div>
187
+ <button type="button" id="fullscreen" data-testid="deck-fullscreen">Full screen</button>
188
+ <button type="button" id="notes-toggle" data-testid="deck-notes-toggle" aria-pressed="false" title="Show the speaker notes under the slide">Notes</button>
162
189
  <button type="button" id="present" data-testid="deck-present" title="Show the slide on its own; ← → move, Esc leaves">Present</button>
163
190
  </div>
164
191
  <div data-testid="deck-add-menu" id="menu" class="menu" role="menu" aria-label="Add a slide like" hidden></div>
192
+ <div id="style-panel" data-testid="deck-style" hidden></div>
165
193
  <div data-testid="deck-stage" id="stage" class="stage">
194
+ <div id="slide-box" class="slide-box"></div>
195
+ <div data-testid="deck-cutoff" id="cutoff-bottom" class="cutoff" data-edge="bottom" hidden><span>Cut off below</span></div>
196
+ <div data-testid="deck-cutoff" id="cutoff-right" class="cutoff" data-edge="right" hidden><span>Cut off right</span></div>
166
197
  <div data-testid="deck-hover-box" id="hover" class="box box--hover" hidden></div>
167
198
  <div data-testid="deck-selected-box" id="selected" class="box" data-wid="" hidden></div>
168
199
  <textarea data-testid="deck-edit-input" id="input" class="input" rows="1" aria-label="New text" hidden></textarea>
@@ -171,14 +202,29 @@
171
202
  </div>
172
203
  <p data-testid="deck-hint" id="hint" class="hint" hidden></p>
173
204
  <p data-testid="deck-note" id="note" class="note" hidden></p>
174
- <div id="notes-box" class="notes">
205
+ <div id="notes-box" data-testid="deck-notes-tab" class="notes">
175
206
  <label for="notes" id="notes-label" data-testid="deck-notes-label">Speaker notes</label>
176
207
  <textarea id="notes" data-testid="deck-notes" placeholder="What to say on this slide. Saved when you leave the field; Undo puts the old notes back."></textarea>
177
208
  </div>
178
209
  </div>
179
210
  <div data-testid="deck-handle" id="handle" class="handle" tabindex="-1"></div>
180
- </div>`;function u(o){const i=document.getElementById(o);if(i===null)throw new Error(`wicked-deck: no #${o}`);return i}const m=o=>o.id??`#${o.n}`;function me(o,i,d){const c=new DOMParser().parseFromString(o,"text/html");Ye(c).forEach((g,b)=>{b!==i&&g.setAttribute("data-wi-deck-off","")});const y=c.createElement("style");if(y.textContent=`[data-wi-deck-off]{display:none!important}${d.thumbnail?"html,body{overflow:hidden!important}":""}`,c.head.append(y),d.thumbnail)for(const g of Array.from(c.querySelectorAll("script")))g.remove();return`<!doctype html>${c.documentElement.outerHTML}`}function Xe(){document.body.insertAdjacentHTML("afterbegin",kt);const o=u("deck");u("strip");const i=u("thumbs"),d=u("count"),c=u("tools"),y=u("add"),g=u("dup"),b=u("up"),j=u("down"),ne=u("del"),V=u("present"),w=u("menu"),Z=u("stage"),Et=u("hover"),je=u("selected"),x=u("input"),ze=u("badge"),Re=u("present-bar"),Q=u("hint"),we=u("note"),$=u("notes"),xt=u("notes-label"),B=u("handle");let z=null,oe=[],D="pane",St=0;const ge=new Map,T=(e,t)=>{z?.postMessage({p:F,v:G,type:e,payload:t})},be=(e,t)=>new Promise(n=>{if(z===null){n({ok:!1,error:{code:"unavailable",message:"no host yet"}});return}const l=`wd-${++St}`;ge.set(l,n),z.postMessage({p:F,v:G,type:e,id:l,payload:t})}),J=e=>T("ui.status",{line:e.slice(0,120)}),ke=()=>oe.includes("artifact.write");let S=null,ae="",a=[],C=null,R=null,k=!1,_=!1,Ee=!1,ee=null,I=!1,P="",xe=null,W=null,A=null,Se=0,_e=-1,Ae=[],L=null,$e={scrollX:0,scrollY:0},de=null,h=null,q=null;const K=()=>{const e=a.findIndex(t=>m(t)===C);return e<0?0:e},O=()=>a[K()]??null,Pe=()=>{const e=Z.clientWidth,t=Z.clientHeight;if(e===0||t===0)return{x:0,y:0,s:1};const n=Math.min(e/ve,t/he);return{x:Math.max(0,(e-ve*n)/2),y:Math.max(0,(t-he*n)/2),s:n}},te=()=>{if(A===null)return;const e=Pe();A.style.cssText=`left:${e.x}px;top:${e.y}px;width:${ve}px;height:${he}px;transform:scale(${e.s})`},De=e=>{if(e===null||L===null)return null;const t=L.widMap[e];if(t===void 0||t.width===0&&t.height===0)return null;const n=at(t,L.measured,$e),l=Pe();return{left:l.x+n.left*l.s,top:l.y+n.top*l.s,width:n.width*l.s,height:n.height*l.s}},Le=(e,t,n=0,l=0)=>{if(t===null){e.hidden=!0;return}e.hidden=!1,e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${Math.max(t.width,n)}px`,e.style.height=`${Math.max(t.height,l)}px`},We=e=>{const t=L?.blocks[e];return L===null||t===void 0||L.widMap[e]===void 0?"unmeasured":t.composite?"container":t.cut===!0?"cut":"yes"},v=()=>{const e=O(),t=a.length;o.dataset.head=S===null?"":String(S),o.dataset.current=e?.id??"",o.dataset.currentN=e===null?"":String(e.n),o.dataset.count=String(t),o.dataset.size=D,o.dataset.present=String(k),o.dataset.selected=h??"",document.body.dataset.present=String(k),d.textContent=t===0?"No slides yet":`${e?.n??1} of ${t}`,d.title=t===0?"":`Slide ${e?.n??1} of ${t}`;const n=ke()&&!_&&e!==null;for(const r of[y,g,ne])r.disabled=!n||e?.id===null;b.disabled=!n||K()===0||e?.id===null,j.disabled=!n||K()>=t-1||e?.id===null,V.disabled=t===0,y.setAttribute("aria-expanded",String(I)),w.hidden=!I||D==="inline",ze.hidden=D!=="inline"||t===0,ze.textContent=`${t} slide${t===1?"":"s"}`,Re.hidden=!k,Re.textContent=`${e?.n??0} / ${t} · ← → · Esc leaves`;for(const r of Array.from(i.children)){const f=r.querySelector("button");f!==null&&f.setAttribute("aria-current",String(f.dataset.key===C))}xt.textContent=e===null?"Speaker notes":`Speaker notes · slide ${e.n}`,document.activeElement!==$&&($.value=N!==null&&N.key===C?N.text:e?.notes??""),$.readOnly=!n;const l=D!=="inline"&&!k&&L!==null;if(Le(Et,l&&de!==h&&q===null?De(de):null),je.dataset.wid=h??"",Le(je,l&&q===null?De(h):null),q!==null?Le(x,De(q.wid),160,30):x.hidden=!0,c.hidden=D==="inline"||k,D==="inline"||k||q!==null){Q.hidden=!0;return}if(Q.hidden=!1,h===null){Q.removeAttribute("data-editable"),Q.textContent=t===0?"":"← → to move between slides · click a line to point at it · type on it to change it";return}const s=We(h);Q.dataset.editable=String(s==="yes"),Q.textContent=s==="yes"?"Type to change it · Enter to edit its text · Esc to let go":s==="container"?"This part holds other parts: click a line inside it to change the words · Esc to let go":"This can’t be changed by typing: say what to change in the message box · Esc to let go"},ce=new Map,At=()=>{const e=new Set,t=[];a.forEach((n,l)=>{const s=m(n);e.add(s);const r=me(ae,l,{thumbnail:!0});let f=ce.get(s);if(f===void 0){const Je=document.createElement("li"),p=document.createElement("button");p.type="button",p.className="thumb";for(const[X,H]of Object.entries({"data-testid":"deck-thumb"}))p.setAttribute(X,H);p.innerHTML='<span class="n"></span><span class="mini"><iframe sandbox="" tabindex="-1" aria-hidden="true"></iframe></span><span class="t"></span>',p.addEventListener("click",()=>{ie(p.dataset.key??null),Ue(),B.focus()}),p.draggable=!0,p.addEventListener("dragstart",X=>{W=p.dataset.key??null,X.dataTransfer?.setData("text/plain",W??"")}),p.addEventListener("dragover",X=>{if(W===null||W===p.dataset.key)return;X.preventDefault();const H=p.getBoundingClientRect();p.dataset.drop=X.clientY<H.top+H.height/2?"before":"after"}),p.addEventListener("dragleave",()=>{delete p.dataset.drop}),p.addEventListener("drop",X=>{X.preventDefault();const H=p.dataset.drop;delete p.dataset.drop;const et=W;if(W=null,et===null||H===void 0)return;const tt=a.findIndex(Yt=>m(Yt)===p.dataset.key),nt=a[tt];if(nt?.id==null)return;const Nt=H==="after"?nt.id:a[tt-1]?.id??null;Ce(et,Nt)}),p.addEventListener("dragend",()=>{W=null}),Je.appendChild(p),f={li:Je,srcdoc:""},ce.set(s,f)}const M=f.li.querySelector("button");M.dataset.key=s,M.dataset.slideId=n.id??"",M.dataset.n=String(n.n),M.setAttribute("aria-label",n.title===""?`Slide ${n.n}`:`Slide ${n.n}: ${n.title}`),M.querySelector(".n").textContent=String(n.n),M.querySelector(".t").textContent=n.title===""?`Slide ${n.n}`:n.title,f.srcdoc!==r&&(f.srcdoc=r,M.querySelector("iframe").srcdoc=r),t.push(f.li)});for(const[n,l]of ce)e.has(n)||(l.li.remove(),ce.delete(n));i.replaceChildren(...t)},$t=e=>{if(e===A){_e=Se;for(const t of Ae)clearTimeout(t);Ae=gt.map(t=>setTimeout(()=>A?.contentWindow?.postMessage(pt,"*"),t))}},Me=()=>{Se+=1,L=null,de=null,h=null,Y();const e=D==="inline"?0:K();if(a.length===0){A?.remove(),A=null,v();return}const t=me(ae,e,{thumbnail:!1}),n=document.createElement("iframe");for(const[s,r]of Object.entries({"data-testid":"deck-frame",sandbox:"allow-scripts",title:`Slide ${e+1}`}))n.setAttribute(s,r);A=n;const l=()=>{for(const s of Array.from(Z.querySelectorAll("iframe")))s!==A&&s.remove()};n.addEventListener("load",()=>{$t(n),A===n&&l()}),n.srcdoc=vt(t)?t:mt(t),Z.insertBefore(n,Z.firstChild),te(),setTimeout(()=>{A===n&&l()},2e3),v()},ie=e=>{if(e===null||e===C||!a.some(t=>m(t)===e)){v();return}Ke(),C=e,Me()},ue=e=>{const t=Math.max(0,Math.min(a.length-1,K()+e)),n=a[t];n!==void 0&&ie(m(n))},Ue=()=>{const e=O()?.wid;e!=null&&oe.includes("selection.chip")&&T("selection.set",{anchors:[{kind:"element",id:e}]})},Dt=(e,t)=>e.version===void 0||t.version===void 0?{}:e.version>=t.version?e:t,re=async e=>{if(!(e!==void 0&&S!==null&&e<=S)){if(Ee){const t=e===void 0?{}:{version:e};ee=ee===null?t:Dt(ee,t);return}Ee=!0;try{const t=await be("artifact.read",e===void 0?{}:{version:e});if(!t.ok){we.hidden=!1,we.textContent=t.error.code==="not_granted"?"This editor may not read the deck here.":`The deck could not be read (${t.error.code}).`;return}const n=t.payload.version;if(typeof n=="number"&&S!==null&&n<S)return;we.hidden=!0;const l=t.payload.content;if(ae=typeof l?.html=="string"?l.html:"",S=typeof n=="number"?n:S,a=st(ae),R!==null){const s=a[Math.max(0,Math.min(a.length-1,R))];C=s===void 0?null:m(s),R=null}else a.some(s=>m(s)===C)||(C=a[0]===void 0?null:m(a[0]));At(),Me()}finally{if(Ee=!1,ee!==null){const t=ee;ee=null,(t.version===void 0||S===null||t.version>S)&&re(t.version)}}}};window.addEventListener("message",e=>{if(A===null||A.contentWindow===null||e.source!==A.contentWindow||_e!==Se)return;const t=ft(e.data);if(t!==null){if(t.type==="wid-inventory"){for(const n of Ae)clearTimeout(n);L={widMap:t.widMap,blocks:t.blocks??{},measured:{scrollX:t.scrollX,scrollY:t.scrollY}},$e={scrollX:t.scrollX,scrollY:t.scrollY},v()}else if(t.type==="scroll-state"||t.type==="scroll-ack")t.scrollX!==void 0&&t.scrollY!==void 0&&($e={scrollX:t.scrollX,scrollY:t.scrollY},v());else if(t.type==="wid-hover")de=t.wid,v();else if(t.type==="wid-click"){if(D==="inline")return;if(k){ue(1);return}Te(t.wid===O()?.wid?null:t.wid),t.wid===O()?.wid&&Ue()}}});const Te=e=>{h=e,Y(),v(),e!==null&&(oe.includes("selection.chip")&&T("selection.set",{anchors:[{kind:"element",id:e}]}),B.focus())},U=async(e,t,n,l=S,s)=>{if(l===null||_||!ke())return!1;_=!0,I=!1,v(),J(n);try{const r=await be("version.write",{base:l,ops:e,summary:t});if(r.ok)return await re(typeof r.payload.version=="number"?r.payload.version:void 0),!0;if(R=null,r.error.code==="stale"||r.error.code==="head_moved"){s!==void 0?s():J(r.error.code==="stale"&&r.error.message?r.error.message:"Not changed: the deck changed meanwhile");const f=r.payload?.head;typeof f=="number"&&f!==S&&await re(f)}else r.error.code==="timeout"||J(r.error.message?r.error.code==="refused"||r.error.message.startsWith("Not changed")?r.error.message:`Not changed: ${r.error.message}`:"Nothing changed");return!1}finally{_=!1,v()}},Ce=async(e,t)=>{const n=a.find(r=>m(r)===e);if(n?.id==null)return;const l=a.indexOf(n),s=t===null?-1:a.findIndex(r=>r.id===t);t===n.id||s===l-1||(C=m(n),await U([{op:"slide-move",slide:n.id,after:t}],`slide ${n.n}`,`Moving slide ${n.n}…`))},Oe=e=>{const t=K(),n=a[t];n?.id!=null&&(e===-1&&t>0&&Ce(m(n),a[t-2]?.id??null),e===1&&t<a.length-1&&Ce(m(n),a[t+1]?.id??null))},He=()=>{const e=O();e?.id!=null&&(R=K()+1,U([{op:"slide-duplicate",slide:e.id}],`slide ${e.n}`,`Duplicating slide ${e.n}…`))},Fe=e=>{const t=O();e.id===null||t?.id==null||(R=K()+1,U([{op:"slide-insert",slide:e.id,after:t.id}],`a slide after slide ${t.n}`,`Adding a slide after slide ${t.n}…`))},Ge=()=>{const e=O();e?.wid==null||a.length===0||(R=Math.max(0,K()-(K()===a.length-1?1:0)),U([{op:"remove",anchor:e.wid}],`slide ${e.n}`,`Deleting slide ${e.n}…`))},Lt=e=>{L?.widMap[e]!==void 0&&U([{op:"remove",anchor:e}],"part of the slide","Removing it…")};let fe=null,qe=null,N=null;const Ke=()=>{const e=a.find(f=>m(f)===fe),t=qe;if(fe=null,qe=null,e?.id==null||$.readOnly)return;const n=$.value.replace(/\r\n/g,`
181
- `),l=e.notes,s=m(e),r=()=>{N?.key===s&&(N=null)};if(n.trim()===l.trim()){r();return}U([{op:"notes-set",slide:e.id,text:n}],`slide ${e.n}’s notes`,`Saving slide ${e.n}’s notes…`,t,()=>{N={key:s,text:n},J(`Not saved: the deck changed while you typed slide ${e.n}’s notes. They are still in the field; leave it again to save them over the change.`),v()}).then(f=>{f&&r()})};$.addEventListener("focus",()=>{fe=C,qe=S}),$.addEventListener("blur",()=>Ke()),$.addEventListener("keydown",e=>{if(e.stopPropagation(),e.key==="Escape"){e.preventDefault(),N?.key===C&&(N=null),$.value=O()?.notes??"",fe=null,B.focus();return}if(e.key==="Enter"&&(e.metaKey||e.ctrlKey)){e.preventDefault(),B.focus();return}if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="k"){e.preventDefault(),T("ui.key",{key:"Mod+K"});return}if(e.key==="Tab"&&!e.shiftKey){e.preventDefault(),$.blur(),T("ui.key",{key:"Tab"});return}e.key==="Tab"&&e.shiftKey&&(e.preventDefault(),B.focus())});const Y=()=>{q!==null&&(q=null,x.hidden=!0,x.value="",v())},Ve=(e,t)=>{if(_||!ke()||L===null||We(e)!=="yes")return;const n=L.blocks[e]?.text??"";q={wid:e,before:n},x.value=t??n,v(),x.focus(),t===null?x.select():x.setSelectionRange(x.value.length,x.value.length)},Mt=async()=>{if(q===null)return;const{wid:e,before:t}=q,n=x.value.replace(/\s*\n\s*/g," ");Y(),B.focus(),n!==t&&await U([{op:"text",anchor:e,value:n,before:t}],`slide ${O()?.n??""}`,"Changing the text…")};x.addEventListener("keydown",e=>{if(e.stopPropagation(),(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="k"){e.preventDefault(),Y(),T("ui.key",{key:"Mod+K"});return}e.key==="Enter"?(e.preventDefault(),Mt()):e.key==="Escape"&&(e.preventDefault(),Y(),B.focus())}),x.addEventListener("blur",()=>Y());const Tt=()=>{w.replaceChildren();const e=document.createElement("span");e.className="word",e.textContent="A blank slide laid out like",w.appendChild(e);for(const t of a){if(t.id===null)continue;const n=document.createElement("button");n.type="button";for(const[l,s]of Object.entries({role:"menuitem","data-testid":"deck-add-like"}))n.setAttribute(l,s);n.dataset.slideId=t.id,n.textContent=t.title===""?`Slide ${t.n}`:`Slide ${t.n} — ${t.title}`,n.addEventListener("click",()=>Fe(t)),w.appendChild(n)}I=!0,v(),w.querySelector("button")?.focus()},Ie=()=>{I&&(I=!1,v(),y.focus())};w.addEventListener("keydown",e=>{if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),Ie();return}if(e.key!=="ArrowDown"&&e.key!=="ArrowUp")return;e.preventDefault(),e.stopPropagation();const t=Array.from(w.querySelectorAll("button")),n=t.indexOf(document.activeElement);t[(n+(e.key==="ArrowDown"?1:t.length-1)+t.length)%t.length]?.focus()}),y.addEventListener("click",()=>I?Ie():Tt()),g.addEventListener("click",()=>He()),b.addEventListener("click",()=>Oe(-1)),j.addEventListener("click",()=>Oe(1)),ne.addEventListener("click",()=>Ge()),V.addEventListener("click",()=>void Ct());const Ct=async()=>{a.length!==0&&(Ke(),k=!0,Te(null),oe.includes("ui.fullscreen")&&await be("ui.fullscreen",{}),v(),te(),o.focus())},Ot=()=>{k=!1,v(),te(),o.focus()};window.addEventListener("resize",()=>{te(),v()}),typeof ResizeObserver=="function"&&new ResizeObserver(()=>{te(),v()}).observe(Z);const qt=()=>[...Array.from(i.querySelectorAll("button")).filter(()=>D!=="inline"&&!k),...Array.from(c.querySelectorAll("button")).filter(e=>!c.hidden&&!e.disabled),B,...D==="inline"||k?[]:[$]],Kt=e=>{P=`${P}${e}`.slice(-3),xe!==null&&clearTimeout(xe),xe=setTimeout(()=>{P=""},bt),J(`Go to slide ${P} — Enter`)};o.addEventListener("keydown",e=>{if(e.target===x||e.target===$)return;const t=e.target?.tagName==="BUTTON",n=e.target?.dataset?.testid==="deck-thumb",l=e.key==="Enter"&&n&&P!=="";if(t&&!l&&(e.key==="Enter"||e.key===" "))return;const s=e.metaKey||e.ctrlKey;if(e.key==="Escape"){if(e.preventDefault(),I){Ie();return}if(k){Ot();return}if(h!==null){Te(null);return}T("ui.key",{key:"Escape"});return}if(s&&!e.altKey&&e.key.toLowerCase()==="k"){e.preventDefault(),T("ui.key",{key:"Mod+K"});return}if(s&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="n"){e.preventDefault();const r=O();r!==null&&Fe(r);return}if(s&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="d"){e.preventDefault(),He();return}if(s&&!e.altKey&&(e.key==="Backspace"||e.key==="Delete")){e.preventDefault(),h!==null&&h!==O()?.wid?Lt(h):Ge();return}if(e.altKey&&!s&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),Oe(e.key==="ArrowUp"?-1:1);return}if(e.altKey&&!s&&/^Key[A-Z]$/.test(e.code)){e.preventDefault(),T("ui.key",{key:`Alt+${e.code.slice(3)}`});return}if(e.key==="Tab"){e.preventDefault();const r=qt(),f=r.indexOf(document.activeElement),M=f===-1&&document.activeElement===o&&!e.shiftKey?0:f+(e.shiftKey?-1:1);if(f===-1&&M!==0||M<0||M>=r.length){T("ui.key",{key:e.shiftKey?"Shift+Tab":"Tab"});return}r[M].focus();return}if(!(s||e.altKey)){if(e.key==="ArrowRight"||e.key==="PageDown"||e.key==="ArrowDown"&&!t){e.preventDefault(),ue(1);return}if(e.key==="ArrowLeft"||e.key==="PageUp"||e.key==="ArrowUp"&&!t){e.preventDefault(),ue(-1);return}if(e.key==="Home"){e.preventDefault();const r=a[0];r!==void 0&&ie(m(r));return}if(e.key==="End"){e.preventDefault();const r=a[a.length-1];r!==void 0&&ie(m(r));return}if(k&&e.key===" "){e.preventDefault(),ue(1);return}if(l){e.preventDefault();const r=a[Number(P)-1];P="",r!==void 0&&(ie(m(r)),i.querySelector(`[data-key="${CSS.escape(m(r))}"]`)?.focus()),J(r===void 0?"There is no such slide":`Slide ${r.n}`);return}if(!(t&&e.key.length!==1)){if(e.key==="Enter"){h!==null&&!_&&(e.preventDefault(),Ve(h,null));return}if(e.key.length===1){if(e.preventDefault(),h!==null&&!_){Ve(h,e.key);return}if(/^[0-9]$/.test(e.key)&&n){Kt(e.key);return}T("ui.typed",{grapheme:e.key})}}}});const Ze=e=>{const t=D;D=e,document.body.dataset.size=e,e==="inline"&&(k=!1,Y(),h=null,I=!1,document.activeElement?.blur?.()),e!=="full"&&k&&(k=!1),t==="inline"!=(e==="inline")&&a.length>0&&Me(),te(),v()},Qe=e=>{if(!(typeof e!="object"||e===null))for(const[t,n]of Object.entries(e))/^--[a-z0-9-]+$/.test(t)&&typeof n=="string"&&n.length<=200&&!/url\(/i.test(n)&&document.documentElement.style.setProperty(t,n)},It=e=>{const t=e.data;try{if(t===null||typeof t!="object"||t.p!==F||t.v!==G)return;if(typeof t.re=="string"){const l=ge.get(t.re);if(l===void 0)return;ge.delete(t.re);const s=typeof t.payload=="object"&&t.payload!==null?t.payload:{};t.ok===!0?l({ok:!0,payload:s}):l({ok:!1,error:t.error??{code:"unavailable",message:"no answer"},payload:s});return}const n=typeof t.payload=="object"&&t.payload!==null?t.payload:{};switch(t.type){case"host.ping":typeof t.id=="string"&&z?.postMessage({p:F,v:G,re:t.id,ok:!0,payload:{}});return;case"host.size":(n.size==="inline"||n.size==="pane"||n.size==="full")&&Ze(n.size);return;case"host.theme":Qe(n.theme);return;case"artifact.changed":{const l=n.version;typeof l=="number"&&l!==S&&re(l);return}case"selection.cleared":h!==null&&(h=null,Y(),v());return;default:return}}catch{}};window.addEventListener("message",e=>{const t=e.data;if(z!==null||t===null||typeof t!="object"||t.p!==F||t.type!=="host.hello"||e.ports[0]===void 0)return;z=e.ports[0],z.onmessage=It;const n=typeof t.payload=="object"&&t.payload!==null?t.payload:{};oe=Array.isArray(n.grants)?n.grants.filter(l=>typeof l=="string"):[],Qe(n.theme),Ze(n.size==="inline"||n.size==="full"?n.size:"pane"),re()});const Bt=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:F,v:G,type:"plugin.ready",payload:{editor:wt,version:Bt,protocol:[G]}},"*")}return Xe(),le.oneSlideHtml=me,le.start=Xe,Object.defineProperty(le,Symbol.toStringTag,{value:"Module"}),le})({});
211
+ </div>`;function v(o){const r=document.getElementById(o);if(r===null)throw new Error(`wicked-deck: no #${o}`);return r}const x=o=>o.id??`#${o.n}`;function Ye(o,r,i){const d=new DOMParser().parseFromString(o,"text/html");vt(d).forEach((u,h)=>{h!==r?u.setAttribute("data-wi-deck-off",""):u.setAttribute("data-wi-deck-current","")});const c=d.createElement("style");if(c.textContent="[data-wi-deck-off]{display:none!important}html,body{margin:0!important;padding:0!important;width:1280px!important;height:720px!important;overflow:hidden!important}[data-wi-deck-current]{position:absolute!important;left:0!important;top:0!important;width:1280px!important;height:720px!important;min-height:0!important;max-width:none!important;margin:0!important;box-sizing:border-box!important;overflow:hidden!important}",d.head.append(c),i.thumbnail)for(const u of Array.from(d.querySelectorAll("script")))u.remove();else{const u=d.createElement("script");u.textContent=`(function(){
212
+ function report(){
213
+ var slide=document.querySelector('[data-wi-deck-current]');
214
+ if(!slide)return;
215
+ parent.postMessage({v:1,type:'deck-extents',width:slide.scrollWidth,height:slide.scrollHeight},'*');
216
+ }
217
+ window.addEventListener('message',function(e){if(e.source===parent&&e.data&&e.data.v===1&&e.data.type==='request-inventory')report();});
218
+ window.addEventListener('resize',report);
219
+ window.addEventListener('load',function(){
220
+ report();
221
+ var slide=document.querySelector('[data-wi-deck-current]');
222
+ if(slide&&typeof ResizeObserver==='function')new ResizeObserver(report).observe(slide);
223
+ if(slide&&typeof MutationObserver==='function')new MutationObserver(report).observe(slide,{childList:true,subtree:true,characterData:true,attributes:true});
224
+ if(document.fonts)document.fonts.ready.then(report);
225
+ });
226
+ })();`,d.body.append(u)}return`<!doctype html>${d.documentElement.outerHTML}`}function bt(){document.body.insertAdjacentHTML("afterbegin",mn);const o=v("deck"),r=v("strip"),i=v("thumbs"),d=v("count"),c=v("tools"),u=v("add"),h=v("dup"),m=v("up"),F=v("down"),U=v("del"),K=v("present"),te=v("notes-toggle");let G=!1;const Y=v("menu"),b=v("stage"),p=v("slide-box"),C=v("cutoff-bottom"),L=v("cutoff-right"),S=v("fit"),M=v("zoom-100"),Me=v("fullscreen"),ve=v("style-panel"),ae=v("notes-box"),vn=v("hover"),gt=v("selected"),q=v("input"),wt=v("badge"),kt=v("present-bar"),be=v("hint"),He=v("note"),B=v("notes"),bn=v("notes-label"),ne=v("handle");let oe=null,de=[],k="pane",D=1,T="options",De="style",xt=null,ze="fit",_e=null,ge=null,gn=0;const We=new Map,N=(e,t)=>{oe?.postMessage({p:Le,v:Ke,type:e,payload:t})},we=(e,t)=>new Promise(n=>{if(oe===null){n({ok:!1,error:{code:"unavailable",message:"no host yet"}});return}const s=`wd-${++gn}`;We.set(s,n),oe.postMessage({p:Le,v:Ke,type:e,id:s,payload:t})}),ce=e=>N("ui.status",{line:e.slice(0,120)}),Ue=()=>de.includes("artifact.write");let O=null,re="",f=[],P=null,ue=null,g=!1,fe=!1,Ge=!1,ke=null,J=!1,pe="",Je=null,he=null,R=null,Ve=0,Et=-1,Ze=[],z=null,qe=null,xe={scrollX:0,scrollY:0},Ne=null,$=null,H=null;const I=()=>{const e=f.findIndex(t=>x(t)===P);return e<0?0:e},j=()=>f[I()]??null,Qe=()=>{const e=b.clientWidth,t=b.clientHeight;if(e===0||t===0)return{x:0,y:0,s:1};const n=ze==="100"&&k!=="inline"&&!g?1:Math.min(e/Q,t/ee);return{x:Math.max(0,(e-Q*n)/2),y:Math.max(0,(t-ee*n)/2),s:n}},W=()=>{const e=ze==="fit"||k==="inline"||g;if(b.dataset.zoom=e?"fit":"100",S.setAttribute("aria-pressed",String(e)),M.setAttribute("aria-pressed",String(!e)),e&&(b.scrollLeft=0,b.scrollTop=0),R===null)return;const t=Qe();p.style.cssText=`left:${t.x}px;top:${t.y}px;width:${Q*t.s}px;height:${ee*t.s}px`,R.style.cssText=`width:${Q}px;height:${ee}px;transform:scale(${t.s})`,At()},At=()=>{const e=Object.values(z?.widMap??{}).filter(a=>a.width>0&&a.height>0),t=e.reduce((a,y)=>Math.max(a,y.bottom+(z?.measured.scrollY??0)),Math.max(ee+xe.scrollY,qe?.height??0)),n=e.reduce((a,y)=>Math.max(a,y.right+(z?.measured.scrollX??0)),Math.max(Q+xe.scrollX,qe?.width??0)),s=Qe(),l=D===2&&T==="full"&&!g;C.hidden=!l||t<=ee,L.hidden=!l||n<=Q,C.style.cssText=`left:${s.x}px;top:${s.y+ee*s.s-1}px;width:${Q*s.s}px`,L.style.cssText=`left:${s.x+Q*s.s-1}px;top:${s.y}px;height:${ee*s.s}px`},et=e=>{if(e===null||z===null)return null;const t=z.widMap[e];if(t===void 0||t.width===0&&t.height===0)return null;const n=nn(t,z.measured,xe),s=Qe();return{left:s.x+n.left*s.s,top:s.y+n.top*s.s,width:n.width*s.s,height:n.height*s.s}},tt=(e,t,n=0,s=0)=>{if(t===null){e.hidden=!0;return}e.hidden=!1,e.style.left=`${t.left}px`,e.style.top=`${t.top}px`,e.style.width=`${Math.max(t.width,n)}px`,e.style.height=`${Math.max(t.height,s)}px`},St=e=>{const t=z?.blocks[e];return z===null||t===void 0||z.widMap[e]===void 0?"unmeasured":t.composite?"container":t.cut===!0?"cut":"yes"},w=()=>{const e=j(),t=f.length;o.dataset.head=O===null?"":String(O),o.dataset.current=e?.id??"",o.dataset.currentN=e===null?"":String(e.n),o.dataset.count=String(t),o.dataset.size=k,o.dataset.surface=T,o.dataset.tab=De;const n=D===2&&T==="options";r.hidden=k==="inline"||g||n,b.hidden=n,ve.hidden=!n||De!=="style";const s=D===2&&T==="full"&&!G&&!g;ae.hidden=k==="inline"||g||n&&De!=="notes"||s,te.hidden=!(D===2&&T==="full"),te.setAttribute("aria-pressed",String(G)),At(),o.dataset.present=String(g),o.dataset.selected=$??"",document.body.dataset.present=String(g),d.textContent=t===0?"No slides yet":`${e?.n??1} of ${t}`,d.title=t===0?"":`Slide ${e?.n??1} of ${t}`;const l=Ue()&&!fe&&e!==null;for(const E of[u,h,U])E.disabled=!l||e?.id===null;m.disabled=!l||I()===0||e?.id===null,F.disabled=!l||I()>=t-1||e?.id===null,K.disabled=t===0,u.setAttribute("aria-expanded",String(J)),Y.hidden=!J||k==="inline",wt.hidden=D===2||k!=="inline"||t===0,wt.textContent=`${t} slide${t===1?"":"s"}`,kt.hidden=!g,kt.textContent=`${e?.n??0} / ${t} · ← → · Esc leaves`;for(const E of Array.from(i.children)){const V=E.querySelector("button");V!==null&&V.setAttribute("aria-current",String(V.dataset.key===P))}bn.textContent=e===null?"Speaker notes":`Speaker notes · slide ${e.n}`,document.activeElement!==B&&(B.value=ie!==null&&ie.key===P?ie.text:e?.notes??""),B.readOnly=!l;const a=k!=="inline"&&!g&&z!==null;if(tt(vn,a&&Ne!==$&&H===null?et(Ne):null),gt.dataset.wid=$??"",tt(gt,a&&H===null?et($):null),H!==null?tt(q,et(H.wid),160,30):q.hidden=!0,c.hidden=k==="inline"||g||n,Me.hidden=!de.includes("ui.fullscreen"),k==="inline"||g||n||H!==null||D===2&&T==="full"){be.hidden=!0;return}if(be.hidden=!1,$===null){be.removeAttribute("data-editable"),be.textContent=t===0?"":"← → to move between slides · click a line to point at it · type on it to change it";return}const y=St($);be.dataset.editable=String(y==="yes"),be.textContent=y==="yes"?"Type to change it · Enter to edit its text · Esc to let go":y==="container"?"This part holds other parts: click a line inside it to change the words · Esc to let go":"This can’t be changed by typing: say what to change in the message box · Esc to let go"},Pe=new Map,wn=()=>{const e=new Set,t=[];f.forEach((n,s)=>{const l=x(n);e.add(l);const a=Ye(re,s,{thumbnail:!0});let y=Pe.get(l);if(y===void 0){const V=document.createElement("li"),A=document.createElement("button");A.type="button",A.className="thumb";for(const[le,me]of Object.entries({"data-testid":"deck-thumb"}))A.setAttribute(le,me);A.innerHTML='<span class="n"></span><span class="mini"><iframe sandbox="" tabindex="-1" aria-hidden="true"></iframe></span><span class="t"></span>',A.addEventListener("click",()=>{Ee(A.dataset.key??null,!1),ot(),ne.focus()}),A.draggable=!0,A.addEventListener("dragstart",le=>{he=A.dataset.key??null,le.dataTransfer?.setData("text/plain",he??"")}),A.addEventListener("dragover",le=>{if(he===null||he===A.dataset.key)return;le.preventDefault();const me=A.getBoundingClientRect();A.dataset.drop=le.clientY<me.top+me.height/2?"before":"after"}),A.addEventListener("dragleave",()=>{delete A.dataset.drop}),A.addEventListener("drop",le=>{le.preventDefault();const me=A.dataset.drop;delete A.dataset.drop;const Ft=he;if(he=null,Ft===null||me===void 0)return;const Kt=f.findIndex(Bn=>x(Bn)===A.dataset.key),zt=f[Kt];if(zt?.id==null)return;const On=me==="after"?zt.id:f[Kt-1]?.id??null;rt(Ft,On)}),A.addEventListener("dragend",()=>{he=null}),V.appendChild(A),y={li:V,srcdoc:""},Pe.set(l,y)}const E=y.li.querySelector("button");E.dataset.key=l,E.dataset.slideId=n.id??"",E.dataset.n=String(n.n),E.setAttribute("aria-label",n.title===""?`Slide ${n.n}`:`Slide ${n.n}: ${n.title}`),E.querySelector(".n").textContent=String(n.n),E.querySelector(".t").textContent=n.title===""?`Slide ${n.n}`:n.title,y.srcdoc!==a&&(y.srcdoc=a,E.querySelector("iframe").srcdoc=a),t.push(y.li)});for(const[n,s]of Pe)e.has(n)||(s.li.remove(),Pe.delete(n));i.replaceChildren(...t)},kn=e=>{if(e===R){Et=Ve;for(const t of Ze)clearTimeout(t);Ze=hn.map(t=>setTimeout(()=>R?.contentWindow?.postMessage(an,"*"),t))}},nt=()=>{Ve+=1,z=null,qe=null,xe={scrollX:0,scrollY:0},Ne=null,$=null,se();const e=D===1&&k==="inline"?0:I();if(f.length===0){p.replaceChildren(),R=null,W(),w();return}const t=Ye(re,e,{thumbnail:!1}),n=document.createElement("iframe");for(const[l,a]of Object.entries({"data-testid":"deck-frame",sandbox:"allow-scripts",title:`Slide ${e+1}`}))n.setAttribute(l,a);R=n;const s=()=>{for(const l of Array.from(p.querySelectorAll("iframe")))l!==R&&l.remove()};n.addEventListener("load",()=>{kn(n),R===n&&s()}),n.srcdoc=cn(re)?t:fn(t),p.prepend(n),W(),setTimeout(()=>{R===n&&s()},2e3),w()},Ee=(e,t=!0)=>{if(e===null||e===P||!f.some(n=>x(n)===e)){w();return}lt(),P=e,nt(),t&&D===2&&T!=="options"&&ot()},Te=e=>{const t=Math.max(0,Math.min(f.length-1,I()+e)),n=f[t];n!==void 0&&Ee(x(n))},ot=()=>{const e=j()?.wid;e!=null&&de.includes("selection.chip")&&N("selection.set",{anchors:[{kind:"element",id:e}]})},xn=(e,t)=>e.version===void 0||t.version===void 0?{}:e.version>=t.version?e:t,$t=e=>{const t=e.version;if(typeof t=="number"&&O!==null&&t<O)return;He.hidden=!0;const n=e.content;if(re=typeof n?.html=="string"?n.html:"",O=typeof t=="number"?t:O,En(re),Lt.refresh(),f=tn(re),ue!==null){const l=f[Math.max(0,Math.min(f.length-1,ue))];P=l===void 0?null:x(l),ue=null}else f.some(l=>x(l)===P)||(P=f[0]===void 0?null:x(f[0]));const s=ge===null?void 0:f.find(l=>l.id===ge||l.wid===ge)??Ct(ge);T==="options"&&s!==void 0&&(ge=x(s),P=x(s)),wn(),nt()},Ae=async e=>{if(!(e!==void 0&&O!==null&&e<=O)){if(Ge){const t=e===void 0?{}:{version:e};ke=ke===null?t:xn(ke,t);return}Ge=!0;try{const t=await we("artifact.read",e===void 0?{}:{version:e});if(!t.ok){He.hidden=!1,He.textContent=t.error.code==="not_granted"?"This editor may not read the deck here.":`The deck could not be read (${t.error.code}).`;return}$t(t.payload)}finally{if(Ge=!1,ke!==null){const t=ke;ke=null,(t.version===void 0||O===null||t.version>O)&&Ae(t.version)}}}},Ct=e=>{if(re===""||!/^[A-Za-z0-9_.:-]{1,100}$/.test(e))return;const s=new DOMParser().parseFromString(re,"text/html").querySelector(`[data-wid="${e}"]`)?.closest("[data-slide-id]")?.getAttribute("data-slide-id")??null;return s===null?void 0:f.find(l=>l.id===s)},En=e=>{_e=Jt(e)??_e},Lt=Gt(ve,{tokens:()=>_e,key:e=>N("ui.key",{key:e}),apply:async e=>{if(D!==2||!de.includes("artifact.theme"))return{ok:!1,reason:"Theme changes are not granted here."};if(O===null)return{ok:!1,reason:"The deck has not loaded yet."};for(let t=0;t<2;t+=1){const n=await we("theme.set",{base:O,tokens:e});if(n.ok)return _e=Be(e),await Ae(typeof n.payload.version=="number"?n.payload.version:void 0),{ok:!0};if(n.error.code!=="head_moved")return{ok:!1,reason:n.error.message||n.error.code};const s=await we("artifact.read",{});if(!s.ok)return{ok:!1,reason:s.error.message||s.error.code};const l=s.payload.version;if(typeof l!="number"||O!==null&&l<O)return{ok:!1,reason:"The current deck version could not be read."};if($t(s.payload),t===1)return{ok:!1,reason:n.error.message||n.error.code}}return{ok:!1,reason:"The deck changed meanwhile."}}});window.addEventListener("message",e=>{if(R===null||R.contentWindow===null||e.source!==R.contentWindow||Et!==Ve)return;const t=e.data;if(t!==null&&typeof t=="object"&&t.v===1&&t.type==="deck-extents"){typeof t.width=="number"&&Number.isFinite(t.width)&&t.width>=0&&typeof t.height=="number"&&Number.isFinite(t.height)&&t.height>=0&&(qe={width:t.width,height:t.height},w());return}const n=ln(e.data);if(n!==null){if(n.type==="wid-inventory"){for(const s of Ze)clearTimeout(s);z={widMap:n.widMap,blocks:n.blocks??{},measured:{scrollX:n.scrollX,scrollY:n.scrollY}},xe={scrollX:n.scrollX,scrollY:n.scrollY},w()}else if(n.type==="scroll-state"||n.type==="scroll-ack")n.scrollX!==void 0&&n.scrollY!==void 0&&(xe={scrollX:n.scrollX,scrollY:n.scrollY},w());else if(n.type==="wid-hover")Ne=n.wid,w();else if(n.type==="wid-click"){if(k==="inline"){D===2&&Re(n.wid);return}if(g){Te(1);return}Re(n.wid===j()?.wid?null:n.wid),n.wid===j()?.wid&&ot()}}});const Re=e=>{$=e,se(),w(),e!==null&&(de.includes("selection.chip")&&N("selection.set",{anchors:[{kind:"element",id:e}]}),ne.focus())},ye=async(e,t,n,s=O,l)=>{if(s===null||fe||!Ue())return!1;fe=!0,J=!1,w(),ce(n);try{const a=await we("version.write",{base:s,ops:e,summary:t});if(a.ok)return await Ae(typeof a.payload.version=="number"?a.payload.version:void 0),!0;if(ue=null,a.error.code==="stale"||a.error.code==="head_moved"){l!==void 0?l():ce(a.error.code==="stale"&&a.error.message?a.error.message:"Not changed: the deck changed meanwhile");const y=a.payload?.head;typeof y=="number"&&y!==O&&await Ae(y)}else a.error.code==="timeout"||ce(a.error.message?a.error.code==="refused"||a.error.message.startsWith("Not changed")?a.error.message:`Not changed: ${a.error.message}`:"Nothing changed");return!1}finally{fe=!1,w()}},rt=async(e,t)=>{if(k==="inline"||g)return;const n=f.find(a=>x(a)===e);if(n?.id==null)return;const s=f.indexOf(n),l=t===null?-1:f.findIndex(a=>a.id===t);t===n.id||l===s-1||(P=x(n),await ye([{op:"slide-move",slide:n.id,after:t}],`slide ${n.n}`,`Moving slide ${n.n}…`))},it=e=>{const t=I(),n=f[t];n?.id!=null&&(e===-1&&t>0&&rt(x(n),f[t-2]?.id??null),e===1&&t<f.length-1&&rt(x(n),f[t+1]?.id??null))},Mt=()=>{if(k==="inline"||g)return;const e=j();e?.id!=null&&(ue=I()+1,ye([{op:"slide-duplicate",slide:e.id}],`slide ${e.n}`,`Duplicating slide ${e.n}…`))},Dt=e=>{if(k==="inline"||g)return;const t=j();e.id===null||t?.id==null||(ue=I()+1,ye([{op:"slide-insert",slide:e.id,after:t.id}],`a slide after slide ${t.n}`,`Adding a slide after slide ${t.n}…`))},Tt=()=>{if(k==="inline"||g)return;const e=j();e?.wid==null||f.length===0||(ue=Math.max(0,I()-(I()===f.length-1?1:0)),ye([{op:"remove",anchor:e.wid}],`slide ${e.n}`,`Deleting slide ${e.n}…`))},An=e=>{k==="inline"||g||z?.widMap[e]!==void 0&&ye([{op:"remove",anchor:e}],"part of the slide","Removing it…")};let Ie=null,st=null,ie=null;const lt=()=>{const e=f.find(y=>x(y)===Ie),t=st;if(Ie=null,st=null,e?.id==null||B.readOnly)return;const n=B.value.replace(/\r\n/g,`
227
+ `),s=e.notes,l=x(e),a=()=>{ie?.key===l&&(ie=null)};if(n.trim()===s.trim()){a();return}ye([{op:"notes-set",slide:e.id,text:n}],`slide ${e.n}’s notes`,`Saving slide ${e.n}’s notes…`,t,()=>{ie={key:l,text:n},ce(`Not saved: the deck changed while you typed slide ${e.n}’s notes. They are still in the field; leave it again to save them over the change.`),w()}).then(y=>{y&&a()})};B.addEventListener("focus",()=>{Ie=P,st=O}),B.addEventListener("blur",()=>lt()),B.addEventListener("keydown",e=>{if(e.stopPropagation(),!(D===2&&T==="options"&&pt(e,ae,t=>{(t==="Tab"||t==="Shift+Tab")&&B.blur(),N("ui.key",{key:t})}))){if(e.altKey&&!e.metaKey&&!e.ctrlKey&&/^Key[A-Z]$/.test(e.code)&&ct(`Alt+${e.code.slice(3)}`)){e.preventDefault(),N("ui.key",{key:`Alt+${e.code.slice(3)}`});return}if(e.key==="Escape"){e.preventDefault(),ie?.key===P&&(ie=null),B.value=j()?.notes??"",Ie=null,ne.focus();return}if(e.key==="Enter"&&(e.metaKey||e.ctrlKey)){e.preventDefault(),D===2&&T==="options"?B.blur():ne.focus();return}if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="k"){e.preventDefault(),N("ui.key",{key:"Mod+K"});return}if(e.key==="Tab"&&!e.shiftKey){e.preventDefault(),B.blur(),N("ui.key",{key:"Tab"});return}e.key==="Tab"&&e.shiftKey&&(e.preventDefault(),ne.focus())}});const se=()=>{H!==null&&(H=null,q.hidden=!0,q.value="",w())},Ot=(e,t)=>{if(k==="inline"||g||fe||!Ue()||z===null||St(e)!=="yes")return;const n=z.blocks[e]?.text??"";H={wid:e,before:n},q.value=t??n,w(),q.focus(),t===null?q.select():q.setSelectionRange(q.value.length,q.value.length)},Sn=async()=>{if(H===null)return;const{wid:e,before:t}=H,n=q.value.replace(/\s*\n\s*/g," ");se(),ne.focus(),n!==t&&await ye([{op:"text",anchor:e,value:n,before:t}],`slide ${j()?.n??""}`,"Changing the text…")};q.addEventListener("keydown",e=>{if(e.stopPropagation(),(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="k"){e.preventDefault(),se(),N("ui.key",{key:"Mod+K"});return}e.key==="Enter"?(e.preventDefault(),Sn()):e.key==="Escape"&&(e.preventDefault(),se(),ne.focus())}),q.addEventListener("blur",()=>se());const $n=()=>{Y.replaceChildren();const e=document.createElement("span");e.className="word",e.textContent="A blank slide laid out like",Y.appendChild(e);for(const t of f){if(t.id===null)continue;const n=document.createElement("button");n.type="button";for(const[s,l]of Object.entries({role:"menuitem","data-testid":"deck-add-like"}))n.setAttribute(s,l);n.dataset.slideId=t.id,n.textContent=t.title===""?`Slide ${t.n}`:`Slide ${t.n} — ${t.title}`,n.addEventListener("click",()=>Dt(t)),Y.appendChild(n)}J=!0,w(),Y.querySelector("button")?.focus()},at=()=>{J&&(J=!1,w(),u.focus())};Y.addEventListener("keydown",e=>{if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),at();return}if(e.key!=="ArrowDown"&&e.key!=="ArrowUp")return;e.preventDefault(),e.stopPropagation();const t=Array.from(Y.querySelectorAll("button")),n=t.indexOf(document.activeElement);t[(n+(e.key==="ArrowDown"?1:t.length-1)+t.length)%t.length]?.focus()}),u.addEventListener("click",()=>J?at():$n()),h.addEventListener("click",()=>Mt()),m.addEventListener("click",()=>it(-1)),F.addEventListener("click",()=>it(1)),U.addEventListener("click",()=>Tt()),K.addEventListener("click",()=>void Cn()),te.addEventListener("click",()=>{G=!G,w(),W(),G&&B.focus()}),Me.addEventListener("click",()=>{we("ui.fullscreen",{}).then(e=>{e.ok||ce(e.error.message)})}),S.addEventListener("click",()=>{ze="fit",W(),w()}),M.addEventListener("click",()=>{ze="100",W(),w()});const Cn=async()=>{f.length!==0&&(lt(),g=!0,Re(null),de.includes("ui.fullscreen")&&await we("ui.fullscreen",{}),w(),W(),o.focus())},Ln=()=>{g=!1,w(),W(),o.focus()};window.addEventListener("resize",()=>{W(),w()}),typeof ResizeObserver=="function"&&new ResizeObserver(()=>{W(),w()}).observe(b);const Mn=()=>[...Array.from(i.querySelectorAll("button")).filter(()=>k!=="inline"&&!g),...Array.from(c.querySelectorAll("button")).filter(e=>!c.hidden&&!e.hidden&&!e.disabled),ne,...k==="inline"||g||ae.hidden?[]:[B]],Dn=e=>{pe=`${pe}${e}`.slice(-3),Je!==null&&clearTimeout(Je),Je=setTimeout(()=>{pe=""},yn),ce(`Go to slide ${pe} — Enter`)};o.addEventListener("keydown",e=>{if(e.target===q||e.target===B||ve.contains(e.target)||D===2&&T==="options")return;const t=e.target?.tagName==="BUTTON",n=e.target?.dataset?.testid==="deck-thumb",s=e.key==="Enter"&&n&&pe!=="";if(t&&!s&&(e.key==="Enter"||e.key===" "))return;const l=e.metaKey||e.ctrlKey;if(e.key==="Escape"){if(e.preventDefault(),J){at();return}if(g){Ln();return}if($!==null){Re(null);return}N("ui.key",{key:"Escape"});return}if(l&&!e.altKey&&e.key.toLowerCase()==="k"){e.preventDefault(),N("ui.key",{key:"Mod+K"});return}if(l&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="n"){e.preventDefault();const a=j();a!==null&&Dt(a);return}if(l&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="d"){e.preventDefault(),Mt();return}if(l&&!e.altKey&&(e.key==="Backspace"||e.key==="Delete")){e.preventDefault(),$!==null&&$!==j()?.wid?An($):Tt();return}if(e.altKey&&!l&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),it(e.key==="ArrowUp"?-1:1);return}if(e.altKey&&!l&&/^Key[A-Z]$/.test(e.code)){e.preventDefault(),N("ui.key",{key:`Alt+${e.code.slice(3)}`});return}if(e.key==="Tab"){e.preventDefault();const a=Mn(),y=a.indexOf(document.activeElement),E=y===-1&&document.activeElement===o&&!e.shiftKey?0:y+(e.shiftKey?-1:1);if(y===-1&&E!==0||E<0||E>=a.length){N("ui.key",{key:e.shiftKey?"Shift+Tab":"Tab"});return}a[E].focus();return}if(!(l||e.altKey)){if(e.key==="ArrowRight"||e.key==="PageDown"||e.key==="ArrowDown"&&!t){e.preventDefault(),Te(1);return}if(e.key==="ArrowLeft"||e.key==="PageUp"||e.key==="ArrowUp"&&!t){e.preventDefault(),Te(-1);return}if(e.key==="Home"){e.preventDefault();const a=f[0];a!==void 0&&Ee(x(a));return}if(e.key==="End"){e.preventDefault();const a=f[f.length-1];a!==void 0&&Ee(x(a));return}if(g&&e.key===" "){e.preventDefault(),Te(1);return}if(s){e.preventDefault();const a=f[Number(pe)-1];pe="",a!==void 0&&(Ee(x(a)),i.querySelector(`[data-key="${CSS.escape(x(a))}"]`)?.focus()),ce(a===void 0?"There is no such slide":`Slide ${a.n}`);return}if(!(t&&e.key.length!==1)){if(e.key==="Enter"){$!==null&&!fe&&(e.preventDefault(),Ot($,null));return}if(e.key.length===1){if(e.preventDefault(),k!=="inline"&&!g&&$!==null&&!fe){Ot($,e.key);return}if(/^[0-9]$/.test(e.key)&&n){Dn(e.key);return}N("ui.typed",{grapheme:e.key})}}}});const dt=e=>{const t=k;k=e,document.body.dataset.size=e,e==="inline"&&(g=!1,se(),$=null,J=!1,document.activeElement?.blur?.()),e!=="full"&&g&&(g=!1),D===1&&t==="inline"!=(e==="inline")&&f.length>0&&nt(),W(),w()},Bt=e=>{if(!(typeof e!="object"||e===null))for(const[t,n]of Object.entries(e))/^--[a-z0-9-]+$/.test(t)&&typeof n=="string"&&n.length<=200&&!/url\(/i.test(n)&&document.documentElement.style.setProperty(t,n)},Tn=e=>{const t=e.data;try{if(t===null||typeof t!="object"||t.p!==Le||t.v!==Ke)return;if(typeof t.re=="string"){const s=We.get(t.re);if(s===void 0)return;We.delete(t.re);const l=typeof t.payload=="object"&&t.payload!==null?t.payload:{};t.ok===!0?s({ok:!0,payload:l}):s({ok:!1,error:t.error??{code:"unavailable",message:"no answer"},payload:l});return}if(D===2&&xt?.dispatch(t))return;const n=typeof t.payload=="object"&&t.payload!==null?t.payload:{};switch(t.type){case"host.ping":typeof t.id=="string"&&oe?.postMessage({p:Le,v:Ke,re:t.id,ok:!0,payload:{}});return;case"host.size":(n.size==="inline"||n.size==="pane"||n.size==="full")&&dt(n.size);return;case"host.theme":Bt(n.theme);return;case"artifact.changed":{const s=n.version;typeof s=="number"&&s!==O&&Ae(s);return}case"selection.cleared":$!==null&&($=null,se(),w());return;default:return}}catch{}};window.addEventListener("message",e=>{const t=e.data;if(oe!==null||t===null||typeof t!="object"||t.p!==Le||t.type!=="host.hello"||e.ports[0]===void 0)return;oe=e.ports[0],oe.onmessage=Tn;const n=typeof t.payload=="object"&&t.payload!==null?t.payload:{};de=Array.isArray(n.grants)?n.grants.filter(l=>typeof l=="string"):[];const s=Xt(n);D=s.protocol,T=s.surface,De=s.tab??"style",document.body.dataset.protocol=String(D),document.body.dataset.surface=T,xt=new Wt(oe,{surface:l=>{l!=="options"&&(T=l,document.body.dataset.surface=l,dt(ft(l)))},action:l=>{if(T==="options"||l!=="prev"&&l!=="next")return{handled:!1};const a=I()+(l==="next"?1:-1);return a<0||a>=f.length?{handled:!1}:(Te(l==="next"?1:-1),{handled:!0,status:`Slide ${I()+1} of ${f.length}`})},tab:l=>{T!=="options"||l!=="style"&&l!=="notes"||(B.blur(),De=l,Lt.refresh(),w())},selection:l=>{if(T==="options")for(const a of l){if(typeof a!="object"||a===null)continue;const y=a;if(y.kind!=="element"||typeof y.id!="string")continue;const E=f.find(V=>V.id===y.id||V.wid===y.id)??Ct(y.id);if((f.length===0||E!==void 0)&&(ge=E===void 0?y.id:x(E)),E!==void 0){B.blur(),Ee(x(E),!1);break}}}}),Bt(n.theme),dt(D===2?ft(T):s.size),Ae()}),Ht(pn,qt)}return bt(),X.oneSlideHtml=Ye,X.start=bt,Object.defineProperty(X,Symbol.toStringTag,{value:"Module"}),X})({});
182
228
  </script>
183
229
  </body>
184
230
  </html>
@@ -0,0 +1,91 @@
1
+ {
2
+ "id": "wicked-doc",
3
+ "title": "Document",
4
+ "version": "0.9.0",
5
+ "protocol": [
6
+ 1,
7
+ 2
8
+ ],
9
+ "kinds": [
10
+ "document"
11
+ ],
12
+ "entry": "index.html",
13
+ "sizes": [
14
+ "inline",
15
+ "pane",
16
+ "full"
17
+ ],
18
+ "permissions": [
19
+ {
20
+ "id": "artifact.read",
21
+ "why": "to show the document and read its words"
22
+ },
23
+ {
24
+ "id": "artifact.write",
25
+ "why": "to land what you type on an element as one version, with Undo"
26
+ },
27
+ {
28
+ "id": "selection.chip",
29
+ "why": "to make the element you click the subject of your next message"
30
+ },
31
+ {
32
+ "id": "network.media",
33
+ "why": "to show the document’s web images and fonts"
34
+ },
35
+ {
36
+ "id": "checks.read",
37
+ "why": "to show which requirements this document names"
38
+ },
39
+ {
40
+ "id": "artifact.export",
41
+ "why": "to offer the document as a PDF or a web page from its card (the host makes the file)"
42
+ },
43
+ {
44
+ "id": "artifact.theme",
45
+ "why": "to change the document’s theme, colours and fonts from its Style tab, as one version with Undo"
46
+ },
47
+ {
48
+ "id": "ui.fullscreen",
49
+ "why": "to show the document full screen"
50
+ }
51
+ ],
52
+ "surfaces": {
53
+ "card": {
54
+ "interactive": true,
55
+ "aspect": "16:9",
56
+ "actions": [
57
+ {
58
+ "id": "ask",
59
+ "label": "Ask about this",
60
+ "verb": "host:ask"
61
+ },
62
+ {
63
+ "id": "export",
64
+ "label": "Export",
65
+ "verb": "host:export"
66
+ }
67
+ ]
68
+ },
69
+ "options": {
70
+ "tabs": [
71
+ {
72
+ "id": "style",
73
+ "label": "Style",
74
+ "render": "plugin"
75
+ },
76
+ {
77
+ "id": "coverage",
78
+ "label": "Coverage",
79
+ "render": "plugin"
80
+ }
81
+ ]
82
+ },
83
+ "full": {
84
+ "modes": [
85
+ "simple",
86
+ "advanced"
87
+ ],
88
+ "default": "simple"
89
+ }
90
+ }
91
+ }