wicked-studio 0.14.0 → 0.15.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.
- package/README.md +11 -9
- package/dist/assets/KnowledgeGraph-Cpm46tEp.js +1 -0
- package/dist/assets/WickedSansA-Regular-CGPJLyb8.woff2 +0 -0
- package/dist/assets/WickedSansA-SemiBold-Bk9KXUaV.woff2 +0 -0
- package/dist/assets/favicon-BJA6hF2f.svg +1 -0
- package/dist/assets/index-BRBwWQMH.css +32 -0
- package/dist/assets/index-CVrWDGRP.js +1097 -0
- package/dist/assets/wicked-studio-lettering-small-CBwSGqop.svg +2 -0
- package/dist/assets/wicked-studio-wordmark-small-gF5xn6IC.svg +2 -0
- package/dist/editors/wicked-apps/editor.json +45 -0
- package/dist/editors/wicked-apps/icon.svg +1 -0
- package/dist/editors/wicked-apps/index.html +151 -0
- package/dist/editors/wicked-deck/editor.json +1 -1
- package/dist/editors/wicked-deck/index.html +12 -8
- package/dist/editors/wicked-doc/editor.json +1 -1
- package/dist/editors/wicked-doc/index.html +12 -8
- package/dist/editors/wicked-insights/editor.json +1 -1
- package/dist/editors/wicked-insights/index.html +1 -1
- package/dist/editors/wicked-page/editor.json +1 -1
- package/dist/editors/wicked-page/index.html +12 -8
- package/dist/editors/wicked-video/editor.json +1 -1
- package/dist/editors/wicked-video/index.html +1 -1
- package/dist/fonts/LICENSE-WickedSans.txt +97 -0
- package/dist/index.html +3 -2
- package/dist/testid-inventory.json +10850 -6700
- package/package.json +3 -3
- package/dist/assets/WickedSans-Regular-fb698rcD.woff2 +0 -0
- package/dist/assets/WickedSans-SemiBold-CD53n1AC.woff2 +0 -0
- package/dist/assets/index-BUZ_-Syk.css +0 -32
- package/dist/assets/index-C_UIgTiy.js +0 -986
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="wicked-editor" content="wicked-doc">
|
|
6
|
-
<meta name="wicked-editor-version" content="0.
|
|
6
|
+
<meta name="wicked-editor-version" content="0.15.0">
|
|
7
7
|
<title>Document</title>
|
|
8
8
|
<style>
|
|
9
9
|
/* The plugin's own chrome takes the host's tokens (`host.hello.theme` / `host.theme`), with plain
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
</style>
|
|
46
46
|
</head>
|
|
47
47
|
<body data-size="pane">
|
|
48
|
-
<script>var
|
|
48
|
+
<script>var kn=Object.defineProperty;var xn=(X,P,J)=>P in X?kn(X,P,{enumerable:!0,configurable:!0,writable:!0,value:J}):X[P]=J;var vt=(X,P,J)=>xn(X,typeof P!="symbol"?P+"":P,J);(function(){"use strict";const X=/^slide-(\d+)-([a-z-]+)-(\d+)$/,P=/^section-(\d+)$/,J={heading:"heading",paragraph:"paragraph","list-item":"list item",quote:"quote",caption:"caption",cell:"table cell",link:"link",button:"button",image:"image",block:"block",text:"line"},bt=/^[A-Za-z]{2,}(?:[-_ ][A-Za-z]{2,})*$/;function ne(e,n){const r=X.exec(e);if(r!==null){const i=Number(r[1]),l=J[r[2]??""]??(r[2]??"").replace(/-+/g," "),a=Number(r[3]);return n==="deck"?`slide ${i+1}’s ${l==="heading"&&a===1?"title":`${l} ${a}`}`:i===0?`${l} ${a}`:`${l} ${a} in section ${i+1}`}const s=P.exec(e);return s!==null?n==="deck"?`slide ${Number(s[1])+1}`:`section ${Number(s[1])+1}`:bt.test(e)?`the ${e.replace(/[-_]+/g," ").toLowerCase()}`:"this part"}function wt(e,n){const r=Object.entries(n).filter(([,s])=>!s.composite&&s.text!=="");return e.map(s=>{const i=s.reqId.trim();if(i==="")return{...s,wid:null};const l=r.find(([,a])=>kt(a.text,i));return{...s,wid:l===void 0?null:l[0]}})}const Xe=/[A-Za-z0-9_-]/,Ye=/[A-Za-z0-9]/;function kt(e,n){const r=e.toLowerCase(),s=n.toLowerCase();if(s==="")return!1;for(let i=r.indexOf(s);i!==-1;i=r.indexOf(s,i+1)){const l=r.charAt(i-1),a=r.charAt(i+s.length),u=Xe.test(l)||l==="."&&Ye.test(r.charAt(i-2)),w=Xe.test(a)||a==="."&&Ye.test(r.charAt(i+s.length+1));if(!u&&!w)return!0}return!1}function xt(e,n){const r=e.filter(i=>i.wid!==null).length,s=n>e.length?` (the first ${e.length} of ${n})`:"";return`${r} of ${e.length} named in this document${s}`}const At={"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"}},Et=new Set(["Escape","Mod+K","Tab","Shift+Tab"]);function He(e){if(Et.has(e))return!0;const n=At[Ct(e)];return n!==void 0&&n.verb==="navigate"}function Ct(e){const n=/^alt\+(.)$/i.exec(e);return n===null?e:`Alt+${n[1].toUpperCase()}`}function $t(e,n,r){return{left:e.left-(r.scrollX-n.scrollX),top:e.top-(r.scrollY-n.scrollY),width:e.width,height:e.height}}const St=/^[A-Za-z0-9_.:-]{1,100}$/;function _(e){return typeof e=="number"&&isFinite(e)}function Tt(e){if(typeof e!="object"||e===null)return!1;const n=e;return n.section!==void 0&&(typeof n.section!="string"||!St.test(n.section))?!1:typeof n.text=="string"&&typeof n.composite=="boolean"}function Ot(e){if(typeof e!="object"||e===null)return!1;const n=e;return _(n.x)&&_(n.y)&&_(n.width)&&_(n.height)&&_(n.top)&&_(n.left)&&_(n.right)&&_(n.bottom)}function Lt(e){if(typeof e!="object"||e===null)return null;const n=e;if(n.v!==1)return null;const r=n.type;if(r==="wid-inventory"){const s=n.widMap,i=n.scrollX,l=n.scrollY;if(typeof s!="object"||s===null||!_(i)||!_(l))return null;const a={};for(const[C,v]of Object.entries(s)){if(!Ot(v))return null;a[C]=v}const u=n.blocks;if(u===void 0)return{v:1,type:"wid-inventory",widMap:a,scrollX:i,scrollY:l};if(typeof u!="object"||u===null)return null;const w={};for(const[C,v]of Object.entries(u)){if(!Tt(v))return null;w[C]={text:v.text,composite:v.composite,...v.cut===!0?{cut:!0}:{},...v.section!==void 0?{section:v.section}:{}}}return{v:1,type:"wid-inventory",widMap:a,scrollX:i,scrollY:l,blocks:w}}if(r==="scroll-state"){const s=n.scrollX,i=n.scrollY;return!_(s)||!_(i)?null:{v:1,type:"scroll-state",scrollX:s,scrollY:i}}if(r==="scroll-ack"){const s=n.wid;if(typeof s!="string"||s==="")return null;const i=n.scrollX,l=n.scrollY,a=n.seq;return{v:1,type:"scroll-ack",wid:s,..._(i)&&_(l)?{scrollX:i,scrollY:l}:{},...typeof a=="number"&&Number.isInteger(a)&&a>0?{seq:a}:{}}}if(r==="wid-click"){const s=n.wid;return typeof s!="string"||s===""?null:{v:1,type:"wid-click",wid:s}}if(r==="wid-hover"){const s=n.wid;return s!==null&&(typeof s!="string"||s==="")?null:{v:1,type:"wid-hover",wid:s}}return null}const Rt=Object.freeze({v:1,type:"request-inventory"});function Mt(e,n){return n===void 0?{v:1,type:"scroll-to-wid",wid:e}:{v:1,type:"scroll-to-wid",wid:e,seq:n}}const Ft="request-inventory";function _t(e){return e.includes(Ft)}const jt=`
|
|
49
49
|
(function () {
|
|
50
50
|
if (window.__wickedInstrumentBridge) return;
|
|
51
51
|
window.__wickedInstrumentBridge = 1;
|
|
@@ -123,18 +123,22 @@
|
|
|
123
123
|
post(inventory());
|
|
124
124
|
}
|
|
125
125
|
})();
|
|
126
|
-
`;function
|
|
126
|
+
`;function Bt(e){const n=`<script>${jt}<\/script>`;return/<\/body>/i.test(e)?e.replace(/<\/body>/i,()=>`${n}</body>`):`${e}${n}`}const V=String.raw`\s*-?(?:\d+(?:\.\d+)?|\.\d+)%?\s*`,Dt=new RegExp(`^(?:#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\\((?:${V},){2}${V}(?:,${V})?\\)|hsla?\\(\\s*-?\\d+(?:\\.\\d+)?(?:deg)?\\s*,${V},${V}(?:,${V})?\\)|var\\(--wi-[a-z0-9-]{1,40}\\)|revert-layer)$`,"i");function Nt(e,n=new Set){if(!Dt.test(e))return!1;const r=/^var\((--wi-[a-z0-9-]+)\)$/i.exec(e);return r===null||n.has(r[1].toLowerCase())}const qt=[["--wi-bg","Background"],["--wi-surface","Surface"],["--wi-card-bg","Card"],["--wi-primary","Primary"],["--wi-secondary","Secondary"],["--wi-accent","Accent"],["--wi-text","Text"],["--wi-text-secondary","Secondary text"],["--wi-muted","Muted"],["--wi-border","Border"]],Ce="revert-layer";function It(e){const n=new Map;for(const i of e.matchAll(/(--wi-[a-z-]{1,40})\s*:\s*([^;}{]{1,80})/gi))n.set(i[1].toLowerCase(),i[2].trim());const r=new Set,s=[];for(const[i,l]of qt){const a=n.get(i);if(a===void 0)continue;const u=a.startsWith("#")?a.toLowerCase():a;!Nt(u)||r.has(u.toLowerCase())||(r.add(u.toLowerCase()),s.push({token:i,value:u,label:l}))}return s}const oe="wicked.editor",re=1,Je=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),zt=["card","options","full"];function Pt(e){return e==="inline"?"card":e==="pane"?"options":"full"}function Kt(e){return e==="card"?"inline":e==="options"?"pane":"full"}function Ut(e){const n=Je(e)?e:{},r=n.size==="inline"||n.size==="full"?n.size:"pane",s=n.protocol===2?2:1,i=s===2&&typeof n.tab=="string"?n.tab:null,l=s===2&&zt.includes(n.surface)?n.surface:Pt(r),a=l==="options"&&i===null?"full":l,u=s===2&&(n.mode==="simple"||n.mode==="advanced")?n.mode:null;return{protocol:s,surface:a,tab:i,mode:u,size:r}}function Wt(e,n,r){return{editor:e,version:n,protocol:[1,2],surfaces:r}}function Xt(e,n){const r=document.querySelector('meta[name="wicked-editor-version"]')?.getAttribute("content")??"0.0.0";parent.postMessage({p:oe,v:re,type:"plugin.ready",payload:Wt(e,r,n)},"*")}function Yt(e,n,r){const s=e.metaKey||e.ctrlKey;let i=null;if(e.key==="Escape")i="Escape";else if(s&&!e.altKey&&e.key.toLowerCase()==="k")i="Mod+K";else if(e.altKey&&!s&&/^Key[A-Z]$/.test(e.code)&&He(`Alt+${e.code.slice(3)}`))i=`Alt+${e.code.slice(3)}`;else if(e.key==="Tab"){const l=Array.from(n.querySelectorAll("button, input, select, textarea, [tabindex]")).filter(u=>u.tabIndex>=0&&!u.matches(":disabled")&&u.closest("[hidden]")===null),a=l.indexOf(e.target);(e.shiftKey?a<=0:a===-1||a===l.length-1)&&(i=e.shiftKey?"Shift+Tab":"Tab")}return i===null?!1:(e.preventDefault(),e.stopPropagation(),r(i),!0)}class Ht{constructor(n,r){vt(this,"revs",new Map);this.port=n,this.h=r}reply(n,r){this.port.postMessage({p:oe,v:re,re:n,ok:!0,payload:r})}refuse(n,r,s){this.port.postMessage({p:oe,v:re,re:n,ok:!1,error:{code:r,message:s}})}bump(n){const r=(this.revs.get(n)??0)+1;return this.revs.set(n,r),r}values(n,r){this.port.postMessage({p:oe,v:re,type:"options.values",payload:{tab:n,rev:this.bump(n),values:r}})}height(n){this.port.postMessage({p:oe,v:re,type:"ui.height",payload:{px:Math.round(n)}})}dispatch(n){const r=Je(n.payload)?n.payload:{},s=typeof n.id=="string"?n.id:null;switch(n.type){case"host.surface":{const i=r.surface;return(i==="card"||i==="options"||i==="full")&&this.h.surface?.(i,r.mode==="simple"||r.mode==="advanced"?r.mode:null),!0}case"host.mode":{if(s===null)return!0;const i=r.mode;return i!=="simple"&&i!=="advanced"?(this.refuse(s,"bad_request","mode is simple or advanced"),!0):(this.reply(s,{mode:this.h.mode?.(i)??i}),!0)}case"host.action":{if(s===null)return!0;const i=r.id;return typeof i!="string"||this.h.action===void 0?(this.reply(s,{handled:!1}),!0):(Promise.resolve(this.h.action(i)).then(l=>this.reply(s,{handled:l.handled===!0,...typeof l.status=="string"?{status:l.status.slice(0,120)}:{}}),()=>this.reply(s,{handled:!1})),!0)}case"host.tab":return typeof r.tab=="string"&&this.h.tab?.(r.tab),!0;case"host.selection":return Array.isArray(r.anchors)&&this.h.selection?.(r.anchors),!0;case"options.changed":{if(s===null)return!0;const i=r.tab,l=r.id;return typeof i!="string"||typeof l!="string"||this.h.optionsChanged===void 0?(this.refuse(s,"unsupported","no controls here"),!0):(Promise.resolve(this.h.optionsChanged(i,l,r.value)).then(a=>this.reply(s,{applied:a.applied,rev:this.bump(i),values:a.values,...a.reason!==void 0?{reason:a.reason.slice(0,120)}:{}}),a=>this.refuse(s,"unavailable",a instanceof Error?a.message.slice(0,120):"failed")),!0)}default:return!1}}}const ue=[{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"}}],Ve=["Inter","Roboto","Source Sans 3","IBM Plex Sans","Calibri","Georgia","system-ui"],Jt=[["background","Background"],["surface","Surface"],["primary","Primary"],["accent","Accent"],["text_primary","Text"]],$e=e=>({name:e.name,colors:{...e.colors},fonts:{...e.fonts}});function Vt(e,n){e.replaceChildren(),e.classList.add("plugin-style"),e.onkeydown=g=>{n.key!==void 0&&Yt(g,e,n.key)};const r=document.createElement("style");r.textContent=`.plugin-style{padding:16px;box-sizing:border-box;color:var(--ink-high);background:var(--surface-base);font:13px var(--font-sans,system-ui)}
|
|
127
127
|
.plugin-style h2{font-size:16px;margin:0 0 12px}.plugin-style .theme-cards{display:grid;gap:8px;margin-bottom:18px}
|
|
128
128
|
.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}
|
|
129
129
|
.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)}
|
|
130
130
|
.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}
|
|
131
131
|
.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}
|
|
132
|
-
.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}`,
|
|
133
|
-
`),
|
|
132
|
+
.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}`,e.append(r);const s=document.createElement("h2");s.textContent="Style",e.append(s);const i=document.createElement("div");i.className="theme-cards",e.append(i);const l=document.createElement("p");l.setAttribute("role","status"),l.setAttribute("aria-live","polite");let a=!1;const u=[],w=()=>$e(n.tokens()??ue[0]),C=[],v=[],A=()=>{const g=w();for(const{key:m,picker:x,hex:$}of C)$.value=g.colors[m],x.value=/^#[0-9a-f]{6}$/i.test(g.colors[m])?g.colors[m]:"";for(const{key:m,select:x}of v)x.value=Ve.includes(g.fonts[m])?g.fonts[m]:"system-ui";for(const m of Array.from(i.querySelectorAll("button")))m.setAttribute("aria-pressed",String(m.dataset.theme===g.name))},F=async g=>{if(!a){a=!0,u.forEach(m=>{m.disabled=!0}),l.textContent="Applying theme…";try{const m=await n.apply(g);l.textContent=m.ok?"Theme applied.":`Theme was not applied: ${m.reason}`}catch(m){l.textContent=`Theme was not applied: ${m instanceof Error?m.message:"unavailable"}`}finally{a=!1,u.forEach(m=>{m.disabled=!1}),A()}}};for(const g of ue){const m=document.createElement("button");m.type="button",m.dataset.theme=g.name;const x=document.createElement("span");x.className="ps-swatches",x.setAttribute("aria-hidden","true");for(const y of["background","surface","primary","secondary","accent"]){const k=document.createElement("span");k.style.backgroundColor=g.colors[y],x.append(k)}const $=document.createElement("span");$.textContent=g.display_name,m.append(x,$),m.addEventListener("click",()=>{F($e(g))}),i.append(m),u.push(m)}for(const[g,m]of Jt){const x=document.createElement("label"),$=document.createElement("span");$.textContent=m;const y=document.createElement("input");y.type="color",y.setAttribute("aria-label",m);const k=document.createElement("input");k.type="text",k.maxLength=7,k.setAttribute("aria-label",`${m} hex`);const L=Z=>{if(!/^#[0-9a-f]{6}$/i.test(Z)){l.textContent="Enter a six-digit hex colour: a # and six digits or letters a to f.",A();return}const D=w();D.name="custom",D.colors[g]=Z,F(D)};y.addEventListener("change",()=>L(y.value)),k.addEventListener("change",()=>L(k.value)),x.append($,y,k),e.append(x),u.push(y,k),C.push({key:g,picker:y,hex:k})}for(const g of["heading","body"]){const m=document.createElement("label"),x=document.createElement("span");x.textContent=g==="heading"?"Heading font":"Body font";const $=document.createElement("select");$.setAttribute("aria-label",x.textContent);for(const y of Ve){const k=document.createElement("option");k.value=y,k.textContent=y,$.append(k)}$.addEventListener("change",()=>{const y=w();y.name="custom",y.fonts[g]=$.value,F(y)}),m.append(x,$),e.append(m),u.push($),v.push({key:g,select:$})}const B=document.createElement("p");return B.textContent="Match a website or a PDF: the host's Match button under this tab",e.append(B,l),A(),{refresh:A}}function Zt(e){const n=new DOMParser().parseFromString(e,"text/html"),r=Array.from(n.querySelectorAll("style")).map(u=>u.textContent??"").join(`
|
|
133
|
+
`),s=new Map;for(const u of r.matchAll(/(--wi-[a-z-]+)\s*:\s*([^;}{]+)/gi))s.set(u[1].toLowerCase(),u[2].trim());if(s.size===0)return null;const i=$e(ue[0]),l={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 u of Object.keys(l)){const w=s.get(l[u]);w!==void 0&&/^(#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgb|hsl)a?\([0-9.,%\s]+\))$/i.test(w)&&(i.colors[u]=w)}for(const u of["heading","body","mono"]){const w=s.get(`--wi-font-${u}`);w!==void 0&&(i.fonts[u]=w.split(",")[0].trim().replace(/^['"]|['"]$/g,""))}const a=ue.find(u=>JSON.stringify(u.colors)===JSON.stringify(i.colors)&&JSON.stringify(u.fonts)===JSON.stringify(i.fonts));return i.name=a?.name??"custom",i}const Gt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),I=(e,n)=>e>>>n|e<<32-n;function Ze(e){const n=new TextEncoder().encode(e),r=n.length*8,s=new Uint8Array(Math.ceil((n.length+9)/64)*64);s.set(n),s[n.length]=128;const i=new DataView(s.buffer);i.setUint32(s.length-8,Math.floor(r/4294967296)),i.setUint32(s.length-4,r>>>0);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let C=0;C<s.length;C+=64){for(let y=0;y<16;y++)a[y]=i.getUint32(C+y*4);for(let y=16;y<64;y++){const k=I(a[y-15],7)^I(a[y-15],18)^a[y-15]>>>3,L=I(a[y-2],17)^I(a[y-2],19)^a[y-2]>>>10;a[y]=a[y-16]+k+a[y-7]+L>>>0}let[v,A,F,B,g,m,x,$]=[l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7]];for(let y=0;y<64;y++){const k=$+(I(g,6)^I(g,11)^I(g,25))+(g&m^~g&x)+Gt[y]+a[y]>>>0,L=(I(v,2)^I(v,13)^I(v,22))+(v&A^v&F^A&F)>>>0;$=x,x=m,m=g,g=B+k>>>0,B=F,F=A,A=v,v=k+L>>>0}l[0]=l[0]+v>>>0,l[1]=l[1]+A>>>0,l[2]=l[2]+F>>>0,l[3]=l[3]+B>>>0,l[4]=l[4]+g>>>0,l[5]=l[5]+m>>>0,l[6]=l[6]+x>>>0,l[7]=l[7]+$>>>0}const u=new DataView(new ArrayBuffer(32));l.forEach((C,v)=>u.setUint32(v*4,C));let w="";for(let C=0;C<32;C++)w+=String.fromCharCode(u.getUint8(C));return btoa(w)}const Ge="WebRTC is not available in an editor frame",Qt=["RTCPeerConnection","webkitRTCPeerConnection","mozRTCPeerConnection","RTCDataChannel","RTCIceTransport","RTCDtlsTransport","RTCSctpTransport","RTCRtpSender","RTCRtpReceiver","RTCRtpTransceiver","RTCIceCandidate","RTCSessionDescription","RTCCertificate"],Se='(function(w,o){if(typeof w!=="object"||w===null||w.window!==w)throw '+JSON.stringify(Ge)+";var n="+JSON.stringify(Qt)+",k=o.getOwnPropertyNames(w),i,d;for(i=0;i!==k.length;i++)if(/^(webkit|moz)?RTC/.test(k[i])&&(d=o.getOwnPropertyDescriptor(w,k[i]))&&d.configurable)n.push(k[i]);for(i=0;i!==n.length;i++){o.defineProperty(w,n[i],{value:void 0,writable:false,configurable:false});if(w[n[i]]!==void 0)throw "+JSON.stringify(Ge)+`}})(window,({}).constructor);
|
|
134
|
+
`,se=/[\n\r\u2028\u2029]/,Qe=/\s/,et=/[\w$\\\u0080-\uFFFF]/;function en(e,n){if(n>=e.length)return!0;const r=e[n];if(r==='"'||r==="'"||r==="{"||r==="~"||/[0-9]/.test(r))return!0;if(r==="!")return e[n+1]!=="=";if(r===".")return/[0-9]/.test(e[n+1]??"");if(r==="\\")return!0;if(r==="+"||r==="-")return e[n+1]===r;if(!et.test(r))return!1;let s=n;for(;s<e.length&&et.test(e[s])&&!Qe.test(e[s]);)s++;const i=e.slice(n,s);return i!=="in"&&i!=="instanceof"}function tn(e){const n=e.length;let r=0,s=0,i=!1,l=!1;if(e.startsWith("#!")){for(;r<n&&!se.test(e[r]);)r++;s=r,i=!0}let a=!1,u=!0,w=!0;const C=()=>{for(;;){for(;r<n&&Qe.test(e[r]);)se.test(e[r])&&(a=!0,u=!0),r++;if(w&&u&&e.startsWith("-->",r)){for(;r<n&&!se.test(e[r]);)r++;continue}if(e.startsWith("/*",r)){const v=e.indexOf("*/",r+2);if(v<0)return!1;se.test(e.slice(r,v))&&(a=!0,u=!0),r=v+2}else if(e.startsWith("//",r)||w&&e.startsWith("<!--",r))for(;r<n&&!se.test(e[r]);)r++;else return!0}};for(;C();){const v=e[r];if(v!=='"'&&v!=="'")break;w=!1;let A=r+1,F=!1;for(;A<n;){const g=e[A];if(g==="\\"){A+=2;continue}if(g===v){F=!0,A+=1;break}if(g===`
|
|
135
|
+
`||g==="\r")break;A+=1}if(!F)break;u=!1;const B=A;if(r=A,a=!1,!C())break;if(e[r]===";")r+=1,u=!1,s=r,l=!1;else if(e.startsWith("<!--",r)){s=B,l=!0,i=!1;break}else if((a||r>=n)&&en(e,r))s=B,l=!0;else break;i=!1}return{at:s,afterHashbang:i,semicolon:l}}function nn(e){const{at:n,afterHashbang:r,semicolon:s}=tn(e);return e.slice(0,n)+(s?";":"")+(r?`
|
|
136
|
+
`:"")+Se+e.slice(n)}const on=new Set(["application/ecmascript","application/javascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript"]),tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";function rn(e){if(e.namespaceURI===tt?e.hasAttribute("href")||e.hasAttribute("xlink:href"):e.hasAttribute("src"))return!1;const n=e.namespaceURI===tt?null:e.getAttribute("language"),r=e.hasAttribute("type")?e.getAttribute("type"):n!==null&&n!==""?`text/${n}`:"";return r===""||r.toLowerCase()==="module"?!0:on.has(r.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g,"").toLowerCase())}function ot(e){const n=Array.from(e.querySelectorAll("script"));for(const r of Array.from(e.querySelectorAll("template")))r.namespaceURI===nt&&n.push(...ot(r.content));return n}function rt(e){const n=Array.from(e.querySelectorAll("meta[http-equiv]")).filter(r=>r.getAttribute("http-equiv").trim().toLowerCase()==="content-security-policy");for(const r of Array.from(e.querySelectorAll("template")))r.namespaceURI===nt&&n.push(...rt(r.content));return n}function sn(e){return e.doctype===null?"":new XMLSerializer().serializeToString(e.doctype)}function an(e){const n=new DOMParser().parseFromString(e,"text/html"),r=new Set([Ze(Se)]);for(const a of ot(n)){if(!rn(a))continue;const u=nn((a.textContent??"").replace(/\r\n?/g,`
|
|
137
|
+
`));a.textContent=u,r.add(Ze(u))}for(const a of rt(n)){const u=(a.getAttribute("content")??"").split(";").map(w=>w.trim()).filter(w=>w!==""&&!/^script-src(-elem|-attr)?(\s|$)/i.test(w));a.setAttribute("content",[...u,"script-src 'unsafe-inline'"].join("; "))}const s=n.createElement("meta");s.setAttribute("http-equiv","Content-Security-Policy"),s.setAttribute("content",`script-src ${[...r].map(a=>`'sha256-${a}'`).join(" ")}; frame-src 'none'; child-src 'none'; worker-src 'none'; object-src 'none'`);const i=n.createElement("meta");i.setAttribute("http-equiv","Content-Security-Policy"),i.setAttribute("content","script-src 'unsafe-inline'");const l=n.createElement("script");return l.textContent=Se,n.head.prepend(s,i,l),`${sn(n)}${n.documentElement.outerHTML}`}const ie="wicked.editor",pe=1,ln=[[390,"Phone"],[820,"Tablet"],[1280,"Desktop"]],Te=34,cn=[0,250,750,1500],dn=`
|
|
134
138
|
<div data-testid="page-style" id="style" class="style-pane" hidden></div>
|
|
135
139
|
<div data-testid="page-editor" id="editor" class="editor" data-kind="page" data-head="" data-pickable="false" data-selected="" data-size="pane" data-width="" tabindex="0" role="application" aria-label="The page">
|
|
136
140
|
<div data-testid="page-tools" id="tools" class="tools" role="toolbar" aria-label="Page width">
|
|
137
|
-
${
|
|
141
|
+
${ln.map(([e,n])=>`<button type="button" data-testid="page-width" data-width="${e}" aria-pressed="false" title="${n} · ${e} px wide">${n} ${e}</button>`).join("")}
|
|
138
142
|
</div>
|
|
139
143
|
<div id="stage" class="stage"></div>
|
|
140
144
|
<div data-testid="page-hover-box" id="hover" class="box box--hover" hidden></div>
|
|
@@ -149,13 +153,13 @@
|
|
|
149
153
|
<span class="swatches" data-testid="page-swatches" data-prop="background" id="fills"><span class="word">Fill</span></span>
|
|
150
154
|
<span class="swatches" data-testid="page-swatches" data-prop="color" id="inks"><span class="word">Text</span></span>
|
|
151
155
|
</div>
|
|
152
|
-
</div>`;function
|
|
156
|
+
</div>`;function M(e){const n=document.getElementById(e);if(n===null)throw new Error(`wicked-page: no #${e}`);return n}function st(e,n){const r=e?.blocks[n];return e===null||e.widMap[n]===void 0||r===void 0?"unmeasured":r.composite?"container":r.cut===!0?"cut":"yes"}function Oe(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}function un(e){document.body.insertAdjacentHTML("afterbegin",dn);const n=M("editor");n.dataset.kind=e.kind,n.setAttribute("aria-label",e.kind==="document"?"The document":"The page");const r=M("stage");let s=null;const i=M("hover"),l=M("selected"),a=M("input"),u=M("handle"),w=M("hint"),C=M("note"),v=M("tools"),A=M("peek"),F=M("to-section"),B=M("remove"),g=M("fills"),m=M("inks");let x=null,$=[],y="pane",k=1,L="options",Z="style",D="simple",Le=null;const ae=()=>k===1?y!=="inline":L==="full",G=()=>ae()&&(k===1||D==="advanced");let fe=null,pn=0;const Re=new Map,K=(t,o)=>{x?.postMessage({p:ie,v:pe,type:t,payload:o})},le=(t,o)=>new Promise(c=>{if(x===null){c({ok:!1,error:{code:"unavailable",message:"no host yet"}});return}const d=`wp-${++pn}`;Re.set(d,c),x.postMessage({p:ie,v:pe,type:t,id:d,payload:o})}),he=t=>K("ui.status",{line:t.slice(0,120)});let O=null,Me=Object.create(null),Q=null,Fe=0,ce=!1,_e=!1,Y=null;const E=e.coverage?document.createElement("aside"):null;if(E!==null){E.id="coverage",E.dataset.testid="doc-coverage",E.setAttribute("aria-label","Requirements"),E.hidden=!0,document.body.append(E);const t=document.createElement("style");t.textContent=`#coverage{box-sizing:border-box;height:100%;overflow:auto;padding:16px;color:var(--ink-high);background:var(--surface-base);font:13px var(--font-sans,system-ui)}
|
|
153
157
|
#coverage h2{font-size:16px;margin:0 0 12px}#coverage p{color:var(--ink-muted);line-height:1.5}
|
|
154
158
|
#coverage button{display:block;width:100%;padding:10px 8px;text-align:left;font:inherit;color:var(--ink-high);background:var(--surface-card);border:1px solid var(--border);border-radius:4px;margin:6px 0;cursor:pointer}
|
|
155
159
|
#coverage button:disabled{cursor:default}#coverage button:focus-visible{outline:2px solid var(--accent)}
|
|
156
160
|
#coverage p button{display:inline;width:auto;padding:0;margin:0;border:0;background:transparent;color:var(--accent);text-decoration:underline}
|
|
157
161
|
body[data-coverage="side"] .editor{width:calc(100% - min(300px,38%))}
|
|
158
|
-
body[data-coverage="side"] #coverage{position:absolute;right:0;top:0;width:min(300px,38%);border-left:1px solid var(--border)}`,document.body.append(e)}const fe=()=>{if(w===null)return;if(w.replaceChildren(),delete w.dataset.total,delete w.dataset.rows,delete w.dataset.named,ae){const p=document.createElement("p");p.textContent="Couldn't read the requirements · ";const $=document.createElement("button");$.type="button",$.textContent="Try again",$.addEventListener("click",()=>{Be()}),p.append($),w.append(p);return}if(V===null){const p=document.createElement("p");p.textContent="Reading requirements…",w.append(p);return}if(V.length===0){const p=document.createElement("p");p.textContent="No requirements for this document's repository",w.append(p);return}const e=ct(V.map(p=>({key:p.id,reqId:p.id,title:p.text,risk:!1})),Oe),t=e.filter(p=>p.wid!==null),i=e.filter(p=>p.wid===null);w.dataset.total=String(Le),w.dataset.rows=String(e.length),w.dataset.named=String(t.length);const a=document.createElement("h2");a.textContent="Requirements",w.append(a);const d=document.createElement("p");d.dataset.testid="doc-coverage-line",d.textContent=ut(e,Le),w.append(d);const u=(p,$)=>{if($.length===0)return;const le=document.createElement("p");le.textContent=`${p} (${$.length})`,w.append(le);for(const z of $){const I=document.createElement("button");I.type="button",I.dataset.testid="doc-coverage-row",I.dataset.req=z.reqId,I.dataset.named=String(z.wid!==null),I.disabled=z.wid===null,I.textContent=`${z.reqId} · ${z.title}${z.wid===null?"":` · ${ee(z.wid,n.kind)}`}`,I.addEventListener("click",()=>{if(z.wid!==null){if(M==="options"){A.includes("selection.chip")&&N("selection.set",{anchors:[{kind:"element",id:z.wid}]});return}Q(z.wid,!0),ke(z.wid)}}),w.append(I)}};u("Not named",i),u("Named",t)},Be=async()=>{if(!(!n.coverage||V!==null||Me)){Me=!0,ae=!1,fe();try{const e=await ie("checks.read",{}),t=e.ok?e.payload.checks:null;if(!e.ok||!Array.isArray(t)){ae=!0;return}V=t.filter(i=>typeof i=="object"&&i!==null&&typeof i.id=="string"&&typeof i.text=="string"),Le=typeof e.payload.total=="number"?e.payload.total:V.length}catch{ae=!0}finally{Me=!1,fe()}}},Wt=e=>{const t=new DOMParser().parseFromString(e,"text/html");Oe=Object.create(null);const i=Array.from(t.querySelectorAll("[data-wid]")),a=new Map;for(const d of i){const u=d.getAttribute("data-wid")??"";a.set(u,(a.get(u)??0)+1)}for(const d of i){const u=d.getAttribute("data-wid")??"";!/^[A-Za-z0-9_.:-]{1,100}$/.test(u)||a.get(u)!==1||(Oe[u]={text:(d.textContent??"").replace(/\s+/g," ").trim(),composite:d.querySelector("[data-wid]")!==null})}fe()};let E=null,he={scrollX:0,scrollY:0},ye=null,m=null,B=null,me=null,R=!1,Ze=[],q=null,Fe=0,Je=-1,G=null,_e=null,Ve=0,ge=[],Re=!1,ze=null,ve=null;const Ge=e=>{r?.contentWindow?.postMessage(e,"*")},Ht=e=>{if(e===r){Je=Fe;for(const t of ge)clearTimeout(t);ge=It.map(t=>setTimeout(()=>Ge(wt),t))}},Ut=e=>{const t=document.createElement("iframe");for(const[a,d]of Object.entries({"data-testid":"page-frame",sandbox:"allow-scripts",title:n.kind==="document"?"The document":"The page",class:"frame"}))t.setAttribute(a,d);t.addEventListener("load",()=>Ht(t));const i=r;r=t;for(const a of ge)clearTimeout(a);t.srcdoc=e,s.appendChild(t),i?.remove(),be()},Qe=()=>{const e=v==="inline"?0:$e;if(q===null)return{x:0,y:e,s:1};const t=s.clientWidth,i=t>0?Math.min(1,t/q):1;return{x:Math.max(0,(t-q*i)/2),y:e,s:i}},be=()=>{s.style.top=`${v==="inline"?0:$e}px`,o.dataset.width=q===null?"":String(q);for(const i of Array.from(S.querySelectorAll("[data-width]")))i.setAttribute("aria-pressed",String(Number(i.dataset.width)===q));if(r===null)return;if(q===null){r.style.cssText="";return}const e=Qe(),t=s.clientHeight>0?s.clientHeight/e.s:0;r.style.cssText=`position:absolute;left:${e.x}px;top:0;width:${q}px;${t>0?`height:${t}px;`:""}transform:scale(${e.s});transform-origin:0 0`},we=e=>{if(e===null||E===null)return null;const t=E.widMap[e];if(t===void 0)return null;const i=yt(t,E.measured,he),a=Qe();return{left:a.x+i.left*a.s,top:a.y+i.top*a.s,width:i.width*a.s,height:i.height*a.s}},De=(e,t,i=0,a=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,i)}px`,e.style.height=`${Math.max(t.height,a)}px`},qe=()=>(v!=="inline"||b>=2&&M==="card")&&E!==null,T=()=>{if(o.dataset.head=C===null?"":String(C),o.dataset.pickable=String(qe()),o.dataset.selected=m??"",o.dataset.size=v,De(l,ye!==m&&B===null?we(ye):null),f.dataset.wid=m??"",De(f,B===null?we(m):null),B!==null?De(c,we(B.wid),160,30):c.hidden=!0,S.hidden=v==="inline",o.dataset.mode=b>=2?_:"",re.hidden=!J(),g.hidden=!J(),y.hidden=!J(),Zt(),!se()||!qe()||B!==null){x.hidden=!0;return}if(x.hidden=!1,m===null){x.removeAttribute("data-editable"),x.textContent="Click an element to make it the subject · type on it to change it";return}const e=ee(m,n.kind),t=Ue(E,m);x.dataset.editable=String(t==="yes"),x.textContent=t==="yes"?`Type to change ${e} · Enter to edit its text · Esc to let go`:t==="container"?`${Ce(e)} holds other parts — click a line of text inside it to change the words · Esc to let go`:t==="cut"?`${Ce(e)} is too long to change by typing — say what to change in the message box · Esc to let go`:`${Ce(e)} can’t be changed by typing — say what to change in the message box · Esc to let go`},Zt=()=>{const e=J()&&qe()&&B===null&&!R?we(m):null;if(e===null||m===null){F.hidden=!0;return}F.hidden=!1,U.hidden=E?.blocks[m]?.section===void 0;const t=F.offsetHeight||30,i=e.top+e.height+6,a=o.clientHeight===0||i+t<=o.clientHeight-4,d=F.offsetWidth,u=o.clientWidth>0?o.clientWidth-d-4:1/0;F.style.left=`${Math.max(4,Math.min(e.left,u))}px`,F.style.top=`${a?i:Math.max($e+2,e.top-t-6)}px`},et=(e,t)=>{for(const a of Array.from(e.querySelectorAll("button")))a.remove();const i=(a,d)=>{const u=document.createElement("button");u.type="button",u.className=a===Ae?"swatch swatch--default":"swatch";for(const[p,$]of Object.entries({"data-testid":"page-swatch"}))u.setAttribute(p,$);u.dataset.prop=t,u.dataset.value=a,u.title=`${t==="background"?"Fill":"Text"}: ${d}`,u.setAttribute("aria-label",u.title),a===Ae?u.textContent="Default":u.style.setProperty("--swatch",a),u.addEventListener("click",()=>{m!==null&&Vt(m,t,a,d)}),e.appendChild(u)};for(const a of Ze)i(a.value,a.label);i(Ae,"Default")},j=()=>{if(B===null)return;B=null,c.hidden=!0,c.value="";const e=me;me=null,e!==null&&Ke(e),T()},Q=(e,t=!1)=>{X=null,m=e,j(),T(),e!==null&&(A.includes("selection.chip")&&N("selection.set",{anchors:[{kind:"element",id:e}]}),t||h.focus())},ke=e=>{Ve+=1,Ge(kt(e,Ve))},Ke=e=>{const t=e.version;if(typeof t=="number"&&C!==null&&t<C)return;if(B!==null){const d=me?.version;typeof t=="number"&&t>B.base&&(typeof d!="number"||t>=d)&&(me=e);return}D.hidden=!0;const i=e.content,a=typeof i?.html=="string"?i.html:"";n.coverage&&Wt(a),C=typeof t=="number"?t:C,Ze=Ot(a),ue=Nt(a)??ue,Ie?.refresh(),et(g,"background"),et(y,"color"),Fe+=1,_e=G,G=null,E=null,ye=null,m=null,j(),T(),Ut(At(a)?a:$t(a))},Y=async e=>{if(Re){if(e!==void 0&&e===ze)return;ve=e===void 0?{}:{version:e};return}Re=!0,ze=e??null;try{const t=await ie("artifact.read",e===void 0?{}:{version:e});if(!t.ok){D.hidden=!1,D.textContent=t.error.code==="not_granted"?`This editor may not read the ${n.kind} here.`:`The ${n.kind} could not be read (${t.error.code}).`;return}Ke(t.payload)}finally{if(Re=!1,ze=null,ve!==null){const t=ve;ve=null,(t.version===void 0||t.version!==C)&&Y(t.version)}}};window.addEventListener("message",e=>{if(r===null||r.contentWindow===null||e.source!==r.contentWindow||Je!==Fe)return;const t=bt(e.data);if(t!==null){if(t.type==="wid-inventory"){for(const a of ge)clearTimeout(a);E={widMap:t.widMap,blocks:t.blocks??{},measured:{scrollX:t.scrollX,scrollY:t.scrollY}},he={scrollX:t.scrollX,scrollY:t.scrollY};const i=_e;_e=null,i!==null&&t.widMap[i]!==void 0&&ke(i),X!==null&&t.widMap[X]!==void 0&&(m=X,n.coverage&&ke(X)),T()}else if(t.type==="scroll-state")he={scrollX:t.scrollX,scrollY:t.scrollY},T();else if(t.type==="scroll-ack")t.scrollX!==void 0&&t.scrollY!==void 0&&(he={scrollX:t.scrollX,scrollY:t.scrollY},T());else if(t.type==="wid-hover")ye=t.wid,T();else if(t.type==="wid-click"){if(b===1&&v==="inline")return;if(b===2&&M==="card"){Q(t.wid);return}const i=t.wid===m?E?.blocks[t.wid]?.section:void 0;Q(i!==void 0&&E?.widMap[i]!==void 0?i:t.wid)}}});const tt=(e,t)=>{if(!se()||R||C===null||E===null||Ue(E,e)!=="yes")return;const i=E.blocks[e]?.text??"";B={wid:e,before:i,base:C},c.value=t??i,T(),c.focus(),t===null?c.select():c.setSelectionRange(c.value.length,c.value.length)},Ne=async(e,t,i,a,d=C)=>{if(C===null||R)return;R=!0,T(),pe(i);const u=a;try{const p=await ie("version.write",{base:d,ops:e,summary:t});if(p.ok)G=u,await Y(typeof p.payload.version=="number"?p.payload.version:void 0);else if(p.error.code==="stale"||p.error.code==="head_moved"){pe(p.error.code==="stale"&&p.error.message?p.error.message:"Not changed: it moved while you typed"),G=u;const $=p.payload?.head;p.error.code==="head_moved"?await Y(typeof $=="number"?$:void 0):typeof $=="number"&&$!==C&&await Y($)}else p.error.code==="timeout"||(p.error.code==="refused"?pe(p.error.message||"Nothing changed"):pe(`Not changed: ${p.error.message||p.error.code}`))}finally{R=!1,T()}},Jt=async()=>{if(B===null||C===null||R)return;const{wid:e,before:t,base:i}=B,a=c.value.replace(/\s*\n\s*/g," ");if(j(),h.focus(),a===t)return;const d=ee(e,n.kind);await Ne([{op:"text",anchor:e,value:a,before:t}],d,`Changing ${d}…`,e,i)},nt=async e=>{if(!J()||R||E?.widMap[e]===void 0)return;const t=ee(e,n.kind),i=E.blocks[e]?.section??null;h.focus(),await Ne([{op:"remove",anchor:e}],t,`Removing ${t}…`,i)},Vt=async(e,t,i,a)=>{if(!J()||R||E?.widMap[e]===void 0)return;const d=ee(e,n.kind);h.focus(),await Ne([{op:"style",anchor:e,style:{[t]:i}}],d,`${t==="background"?"Filling":"Colouring the text of"} ${d}: ${a.toLowerCase()}…`,e)},ot=e=>{const t=E?.blocks[e]?.section;return t===void 0||E?.widMap[t]===void 0?!1:(Q(t),!0)};U.addEventListener("click",()=>{m!==null&&ot(m)}),re.addEventListener("click",()=>{m!==null&&nt(m)});for(const e of Array.from(S.querySelectorAll("[data-width]")))e.addEventListener("click",()=>{const t=Number(e.dataset.width);q=q===t?null:t,be(),T()});window.addEventListener("resize",()=>{be(),T()}),c.addEventListener("keydown",e=>{e.stopPropagation(),e.key==="Enter"?(e.preventDefault(),Jt()):e.key==="Escape"&&(e.preventDefault(),j(),h.focus())}),c.addEventListener("blur",()=>{j()});const Gt=()=>[...Array.from(S.querySelectorAll("button")),h,...Array.from(F.querySelectorAll("button")),...Array.from(w?.querySelectorAll("button")??[])].filter(e=>e.closest("[hidden]")===null&&!(e instanceof HTMLButtonElement&&e.disabled)),rt=(e,t)=>{if(e.target===c)return;const i=e.target?.tagName==="BUTTON";if(!(i&&(e.key==="Enter"||e.key===" "))){if(e.key==="Escape"){if(!t&&m!==null){e.preventDefault(),Q(null);return}e.preventDefault(),N("ui.key",{key:"Escape"});return}if((e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()==="k"){e.preventDefault(),N("ui.key",{key:"Mod+K"});return}if(!t&&(e.metaKey||e.ctrlKey)&&!e.altKey&&(e.key==="Backspace"||e.key==="Delete")){e.preventDefault(),m!==null&&!R&&nt(m);return}if(!t&&e.altKey&&!e.metaKey&&!e.ctrlKey&&e.key==="ArrowUp"){e.preventDefault(),m!==null&&ot(m);return}if(e.altKey&&!e.metaKey&&!e.ctrlKey&&/^Key[A-Z]$/.test(e.code)&&Ye(`Alt+${e.code.slice(3)}`)){e.preventDefault(),N("ui.key",{key:`Alt+${e.code.slice(3)}`});return}if(e.key==="Tab"){e.preventDefault();const a=Gt(),d=a.indexOf(document.activeElement),u=d===-1&&document.activeElement===o&&!e.shiftKey?0:d+(e.shiftKey?-1:1);if(d===-1&&u!==0||u<0||u>=a.length){N("ui.key",{key:e.shiftKey?"Shift+Tab":"Tab"});return}a[u].focus();return}if(!(e.metaKey||e.ctrlKey||e.altKey)&&!(i&&e.key.length!==1)){if(e.key==="Enter"){!t&&m!==null&&!R&&se()&&(e.preventDefault(),tt(m,null));return}if(e.key.length===1){if(e.preventDefault(),!t&&m!==null&&!R&&se()){tt(m,e.key);return}N("ui.typed",{grapheme:e.key})}}}};o.addEventListener("keydown",e=>rt(e,!1)),w?.addEventListener("keydown",e=>rt(e,!0));const je=e=>{v=e,document.body.dataset.size=e,e==="inline"&&(j(),b<2&&Q(null),document.activeElement?.blur?.()),be(),T()},st=e=>{if(!(typeof e!="object"||e===null))for(const[t,i]of Object.entries(e))/^--[a-z0-9-]+$/.test(t)&&typeof i=="string"&&i.length<=200&&!/url\(/i.test(i)&&document.documentElement.style.setProperty(t,i)},Qt=e=>{const t=e.data;try{if(t===null||typeof t!="object"||t.p!==oe||t.v!==de)return;if(typeof t.re=="string"){const a=Te.get(t.re);if(a===void 0)return;Te.delete(t.re);const d=typeof t.payload=="object"&&t.payload!==null?t.payload:{};t.ok===!0?a({ok:!0,payload:d}):a({ok:!1,error:t.error??{code:"unavailable",message:"no answer"},payload:d});return}if(Se!==null&&Se.dispatch(t))return;const i=typeof t.payload=="object"&&t.payload!==null?t.payload:{};switch(t.type){case"host.ping":typeof t.id=="string"&&k?.postMessage({p:oe,v:de,re:t.id,ok:!0,payload:{}});return;case"host.size":(i.size==="inline"||i.size==="pane"||i.size==="full")&&je(i.size);return;case"host.theme":st(i.theme);return;case"artifact.changed":{ae&&Be();const a=i.version;typeof a=="number"&&a!==C&&(G=G??m,Y(a));return}case"selection.cleared":X=null,m!==null&&(m=null,j(),T());return;default:return}}catch{}};window.addEventListener("message",e=>{const t=e.data;if(k!==null||t===null||typeof t!="object"||t.p!==oe||t.type!=="host.hello"||e.ports[0]===void 0)return;k=e.ports[0],k.onmessage=Qt;const i=typeof t.payload=="object"&&t.payload!==null?t.payload:{};A=Array.isArray(i.grants)?i.grants.filter(d=>typeof d=="string"):[],st(i.theme);const a=Ft(i);b=a.protocol,b>=2?(M=i.surface==="options"?"options":a.surface,Z=a.tab??"style",_=a.mode??"simple",Se=new Dt(k,{surface:(d,u)=>{M=d,u!==null&&(_=u),xe()},mode:d=>(_=d,n.coverage?xe():T(),_),tab:d=>{n.coverage&&(Z=d,xe())},selection:d=>{const u=d.find(p=>typeof p=="object"&&p!==null&&p.kind==="element"&&typeof p.id=="string");M==="options"&&u!==void 0||(X=u?.id??null,m=u!==void 0&&E?.widMap[u.id]!==void 0?u.id:null,m!==null&&n.coverage&&ke(m),j(),T())}}),xe()):je(a.size),Y()});const it=O("style");let Ie=null;const xe=()=>{const e=M==="options",t=n.coverage&&e&&Z==="coverage",i=n.coverage&&M==="full"&&_==="advanced";n.coverage&&(document.body.dataset.coverage=i?"side":"",w!==null&&(w.hidden=!t&&!i),(t||i)&&(fe(),Be())),it.hidden=!e||t,o.hidden=e,e&&!t&&Ie===null&&(Ie=Kt(it,{tokens:()=>ue,key:a=>N("ui.key",{key:a}),apply:async a=>{for(let d=0;d<2;d+=1){if(C===null)return{ok:!1,reason:`The ${n.kind} is not loaded yet`};const u=await ie("theme.set",{base:C,tokens:a});if(u.ok){const le=u.payload.version;return ue={name:a.name,colors:{...a.colors},fonts:{...a.fonts}},typeof le=="number"&&await Y(le),{ok:!0}}if(u.error.code!=="head_moved")return{ok:!1,reason:u.error.message};const p=await ie("artifact.read",{});if(!p.ok)return{ok:!1,reason:p.error.message||p.error.code};const $=p.payload.version;if(typeof $!="number"||C!==null&&$<C)return{ok:!1,reason:`The current ${n.kind} version could not be read.`};if(Ke(p.payload),d===1)return{ok:!1,reason:u.error.message||u.error.code}}return{ok:!1,reason:`The ${n.kind} changed again: try once more`}}})),je(Bt(M))};Rt(n.editor,n.surfaces)}Xt({editor:"wicked-doc",surfaces:{card:{interactive:!0,aspect:"16:9",actions:[{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:"coverage",label:"Coverage",render:"plugin"}]},full:{modes:["simple","advanced"],default:"simple"}},kind:"document",coverage:!0})})();
|
|
162
|
+
body[data-coverage="side"] #coverage{position:absolute;right:0;top:0;width:min(300px,38%);border-left:1px solid var(--border)}`,document.body.append(t)}const ye=()=>{if(E===null)return;if(E.replaceChildren(),delete E.dataset.total,delete E.dataset.rows,delete E.dataset.named,ce){const h=document.createElement("p");h.textContent="Couldn't read the requirements · ";const T=document.createElement("button");T.type="button",T.textContent="Try again",T.addEventListener("click",()=>{je()}),h.append(T),E.append(h);return}if(Q===null){const h=document.createElement("p");h.textContent="Reading requirements…",E.append(h);return}if(Q.length===0){const h=document.createElement("p");h.textContent="No requirements for this document's repository",E.append(h);return}const t=wt(Q.map(h=>({key:h.id,reqId:h.id,title:h.text,risk:!1})),Me),o=t.filter(h=>h.wid!==null),c=t.filter(h=>h.wid===null);E.dataset.total=String(Fe),E.dataset.rows=String(t.length),E.dataset.named=String(o.length);const d=document.createElement("h2");d.textContent="Requirements",E.append(d);const p=document.createElement("p");p.dataset.testid="doc-coverage-line",p.textContent=xt(t,Fe),E.append(p);const f=(h,T)=>{if(T.length===0)return;const de=document.createElement("p");de.textContent=`${h} (${T.length})`,E.append(de);for(const q of T){const W=document.createElement("button");W.type="button",W.dataset.testid="doc-coverage-row",W.dataset.req=q.reqId,W.dataset.named=String(q.wid!==null),W.disabled=q.wid===null,W.textContent=`${q.reqId} · ${q.title}${q.wid===null?"":` · ${ne(q.wid,e.kind)}`}`,W.addEventListener("click",()=>{if(q.wid!==null){if(L==="options"){$.includes("selection.chip")&&K("selection.set",{anchors:[{kind:"element",id:q.wid}]});return}te(q.wid,!0),Ae(q.wid)}}),E.append(W)}};f("Not named",c),f("Named",o)},je=async()=>{if(!(!e.coverage||Q!==null||_e)){_e=!0,ce=!1,ye();try{const t=await le("checks.read",{}),o=t.ok?t.payload.checks:null;if(!t.ok||!Array.isArray(o)){ce=!0;return}Q=o.filter(c=>typeof c=="object"&&c!==null&&typeof c.id=="string"&&typeof c.text=="string"),Fe=typeof t.payload.total=="number"?t.payload.total:Q.length}catch{ce=!0}finally{_e=!1,ye()}}},fn=t=>{const o=new DOMParser().parseFromString(t,"text/html");Me=Object.create(null);const c=Array.from(o.querySelectorAll("[data-wid]")),d=new Map;for(const p of c){const f=p.getAttribute("data-wid")??"";d.set(f,(d.get(f)??0)+1)}for(const p of c){const f=p.getAttribute("data-wid")??"";!/^[A-Za-z0-9_.:-]{1,100}$/.test(f)||d.get(f)!==1||(Me[f]={text:(p.textContent??"").replace(/\s+/g," ").trim(),composite:p.querySelector("[data-wid]")!==null})}ye()};let S=null,me={scrollX:0,scrollY:0},ge=null,b=null,j=null,ve=null,N=!1,it=[],z=null,Be=0,at=-1,ee=null,De=null,lt=0,be=[],Ne=!1,qe=null,we=null;const ct=t=>{s?.contentWindow?.postMessage(t,"*")},hn=t=>{if(t===s){at=Be;for(const o of be)clearTimeout(o);be=cn.map(o=>setTimeout(()=>ct(Rt),o))}},yn=t=>{const o=document.createElement("iframe");for(const[d,p]of Object.entries({"data-testid":"page-frame",sandbox:"allow-scripts",title:e.kind==="document"?"The document":"The page",class:"frame"}))o.setAttribute(d,p);o.addEventListener("load",()=>hn(o));const c=s;s=o;for(const d of be)clearTimeout(d);o.srcdoc=an(t),r.appendChild(o),c?.remove(),ke()},dt=()=>{const t=y==="inline"?0:Te;if(z===null)return{x:0,y:t,s:1};const o=r.clientWidth,c=o>0?Math.min(1,o/z):1;return{x:Math.max(0,(o-z*c)/2),y:t,s:c}},ke=()=>{r.style.top=`${y==="inline"?0:Te}px`,n.dataset.width=z===null?"":String(z);for(const c of Array.from(v.querySelectorAll("[data-width]")))c.setAttribute("aria-pressed",String(Number(c.dataset.width)===z));if(s===null)return;if(z===null){s.style.cssText="";return}const t=dt(),o=r.clientHeight>0?r.clientHeight/t.s:0;s.style.cssText=`position:absolute;left:${t.x}px;top:0;width:${z}px;${o>0?`height:${o}px;`:""}transform:scale(${t.s});transform-origin:0 0`},xe=t=>{if(t===null||S===null)return null;const o=S.widMap[t];if(o===void 0)return null;const c=$t(o,S.measured,me),d=dt();return{left:d.x+c.left*d.s,top:d.y+c.top*d.s,width:c.width*d.s,height:c.height*d.s}},Ie=(t,o,c=0,d=0)=>{if(o===null){t.hidden=!0;return}t.hidden=!1,t.style.left=`${o.left}px`,t.style.top=`${o.top}px`,t.style.width=`${Math.max(o.width,c)}px`,t.style.height=`${Math.max(o.height,d)}px`},ze=()=>(y!=="inline"||k>=2&&L==="card")&&S!==null,R=()=>{if(n.dataset.head=O===null?"":String(O),n.dataset.pickable=String(ze()),n.dataset.selected=b??"",n.dataset.size=y,Ie(i,ge!==b&&j===null?xe(ge):null),l.dataset.wid=b??"",Ie(l,j===null?xe(b):null),j!==null?Ie(a,xe(j.wid),160,30):a.hidden=!0,v.hidden=y==="inline",n.dataset.mode=k>=2?D:"",B.hidden=!G(),g.hidden=!G(),m.hidden=!G(),mn(),!ae()||!ze()||j!==null){w.hidden=!0;return}if(w.hidden=!1,b===null){w.removeAttribute("data-editable"),w.textContent="Click an element to make it the subject · type on it to change it";return}const t=ne(b,e.kind),o=st(S,b);w.dataset.editable=String(o==="yes"),w.textContent=o==="yes"?`Type to change ${t} · Enter to edit its text · Esc to let go`:o==="container"?`${Oe(t)} holds other parts — click a line of text inside it to change the words · Esc to let go`:o==="cut"?`${Oe(t)} is too long to change by typing — say what to change in the message box · Esc to let go`:`${Oe(t)} can’t be changed by typing — say what to change in the message box · Esc to let go`},mn=()=>{const t=G()&&ze()&&j===null&&!N?xe(b):null;if(t===null||b===null){A.hidden=!0;return}A.hidden=!1,F.hidden=S?.blocks[b]?.section===void 0;const o=A.offsetHeight||30,c=t.top+t.height+6,d=n.clientHeight===0||c+o<=n.clientHeight-4,p=A.offsetWidth,f=n.clientWidth>0?n.clientWidth-p-4:1/0;A.style.left=`${Math.max(4,Math.min(t.left,f))}px`,A.style.top=`${d?c:Math.max(Te+2,t.top-o-6)}px`},ut=(t,o)=>{for(const d of Array.from(t.querySelectorAll("button")))d.remove();const c=(d,p)=>{const f=document.createElement("button");f.type="button",f.className=d===Ce?"swatch swatch--default":"swatch";for(const[h,T]of Object.entries({"data-testid":"page-swatch"}))f.setAttribute(h,T);f.dataset.prop=o,f.dataset.value=d,f.title=`${o==="background"?"Fill":"Text"}: ${p}`,f.setAttribute("aria-label",f.title),d===Ce?f.textContent="Default":f.style.setProperty("--swatch",d),f.addEventListener("click",()=>{b!==null&&vn(b,o,d,p)}),t.appendChild(f)};for(const d of it)c(d.value,d.label);c(Ce,"Default")},U=()=>{if(j===null)return;j=null,a.hidden=!0,a.value="";const t=ve;ve=null,t!==null&&Pe(t),R()},te=(t,o=!1)=>{Y=null,b=t,U(),R(),t!==null&&($.includes("selection.chip")&&K("selection.set",{anchors:[{kind:"element",id:t}]}),o||u.focus())},Ae=t=>{lt+=1,ct(Mt(t,lt))},Pe=t=>{const o=t.version;if(typeof o=="number"&&O!==null&&o<O)return;if(j!==null){const p=ve?.version;typeof o=="number"&&o>j.base&&(typeof p!="number"||o>=p)&&(ve=t);return}C.hidden=!0;const c=t.content,d=typeof c?.html=="string"?c.html:"";e.coverage&&fn(d),O=typeof o=="number"?o:O,it=It(d),fe=Zt(d)??fe,We?.refresh(),ut(g,"background"),ut(m,"color"),Be+=1,De=ee,ee=null,S=null,ge=null,b=null,U(),R(),yn(_t(d)?d:Bt(d))},H=async t=>{if(Ne){if(t!==void 0&&t===qe)return;we=t===void 0?{}:{version:t};return}Ne=!0,qe=t??null;try{const o=await le("artifact.read",t===void 0?{}:{version:t});if(!o.ok){C.hidden=!1,C.textContent=o.error.code==="not_granted"?`This editor may not read the ${e.kind} here.`:`The ${e.kind} could not be read (${o.error.code}).`;return}Pe(o.payload)}finally{if(Ne=!1,qe=null,we!==null){const o=we;we=null,(o.version===void 0||o.version!==O)&&H(o.version)}}};window.addEventListener("message",t=>{if(s===null||s.contentWindow===null||t.source!==s.contentWindow||at!==Be)return;const o=Lt(t.data);if(o!==null){if(o.type==="wid-inventory"){for(const d of be)clearTimeout(d);S={widMap:o.widMap,blocks:o.blocks??{},measured:{scrollX:o.scrollX,scrollY:o.scrollY}},me={scrollX:o.scrollX,scrollY:o.scrollY};const c=De;De=null,c!==null&&o.widMap[c]!==void 0&&Ae(c),Y!==null&&o.widMap[Y]!==void 0&&(b=Y,e.coverage&&Ae(Y)),R()}else if(o.type==="scroll-state")me={scrollX:o.scrollX,scrollY:o.scrollY},R();else if(o.type==="scroll-ack")o.scrollX!==void 0&&o.scrollY!==void 0&&(me={scrollX:o.scrollX,scrollY:o.scrollY},R());else if(o.type==="wid-hover")ge=o.wid,R();else if(o.type==="wid-click"){if(k===1&&y==="inline")return;if(k===2&&L==="card"){te(o.wid);return}const c=o.wid===b?S?.blocks[o.wid]?.section:void 0;te(c!==void 0&&S?.widMap[c]!==void 0?c:o.wid)}}});const pt=(t,o)=>{if(!ae()||N||O===null||S===null||st(S,t)!=="yes")return;const c=S.blocks[t]?.text??"";j={wid:t,before:c,base:O},a.value=o??c,R(),a.focus(),o===null?a.select():a.setSelectionRange(a.value.length,a.value.length)},Ke=async(t,o,c,d,p=O)=>{if(O===null||N)return;N=!0,R(),he(c);const f=d;try{const h=await le("version.write",{base:p,ops:t,summary:o});if(h.ok)ee=f,await H(typeof h.payload.version=="number"?h.payload.version:void 0);else if(h.error.code==="stale"||h.error.code==="head_moved"){he(h.error.code==="stale"&&h.error.message?h.error.message:"Not changed: it moved while you typed"),ee=f;const T=h.payload?.head;h.error.code==="head_moved"?await H(typeof T=="number"?T:void 0):typeof T=="number"&&T!==O&&await H(T)}else h.error.code==="timeout"||(h.error.code==="refused"?he(h.error.message||"Nothing changed"):he(`Not changed: ${h.error.message||h.error.code}`))}finally{N=!1,R()}},gn=async()=>{if(j===null||O===null||N)return;const{wid:t,before:o,base:c}=j,d=a.value.replace(/\s*\n\s*/g," ");if(U(),u.focus(),d===o)return;const p=ne(t,e.kind);await Ke([{op:"text",anchor:t,value:d,before:o}],p,`Changing ${p}…`,t,c)},ft=async t=>{if(!G()||N||S?.widMap[t]===void 0)return;const o=ne(t,e.kind),c=S.blocks[t]?.section??null;u.focus(),await Ke([{op:"remove",anchor:t}],o,`Removing ${o}…`,c)},vn=async(t,o,c,d)=>{if(!G()||N||S?.widMap[t]===void 0)return;const p=ne(t,e.kind);u.focus(),await Ke([{op:"style",anchor:t,style:{[o]:c}}],p,`${o==="background"?"Filling":"Colouring the text of"} ${p}: ${d.toLowerCase()}…`,t)},ht=t=>{const o=S?.blocks[t]?.section;return o===void 0||S?.widMap[o]===void 0?!1:(te(o),!0)};F.addEventListener("click",()=>{b!==null&&ht(b)}),B.addEventListener("click",()=>{b!==null&&ft(b)});for(const t of Array.from(v.querySelectorAll("[data-width]")))t.addEventListener("click",()=>{const o=Number(t.dataset.width);z=z===o?null:o,ke(),R()});window.addEventListener("resize",()=>{ke(),R()}),a.addEventListener("keydown",t=>{t.stopPropagation(),t.key==="Enter"?(t.preventDefault(),gn()):t.key==="Escape"&&(t.preventDefault(),U(),u.focus())}),a.addEventListener("blur",()=>{U()});const bn=()=>[...Array.from(v.querySelectorAll("button")),u,...Array.from(A.querySelectorAll("button")),...Array.from(E?.querySelectorAll("button")??[])].filter(t=>t.closest("[hidden]")===null&&!(t instanceof HTMLButtonElement&&t.disabled)),yt=(t,o)=>{if(t.target===a)return;const c=t.target?.tagName==="BUTTON";if(!(c&&(t.key==="Enter"||t.key===" "))){if(t.key==="Escape"){if(!o&&b!==null){t.preventDefault(),te(null);return}t.preventDefault(),K("ui.key",{key:"Escape"});return}if((t.metaKey||t.ctrlKey)&&!t.altKey&&t.key.toLowerCase()==="k"){t.preventDefault(),K("ui.key",{key:"Mod+K"});return}if(!o&&(t.metaKey||t.ctrlKey)&&!t.altKey&&(t.key==="Backspace"||t.key==="Delete")){t.preventDefault(),b!==null&&!N&&ft(b);return}if(!o&&t.altKey&&!t.metaKey&&!t.ctrlKey&&t.key==="ArrowUp"){t.preventDefault(),b!==null&&ht(b);return}if(t.altKey&&!t.metaKey&&!t.ctrlKey&&/^Key[A-Z]$/.test(t.code)&&He(`Alt+${t.code.slice(3)}`)){t.preventDefault(),K("ui.key",{key:`Alt+${t.code.slice(3)}`});return}if(t.key==="Tab"){t.preventDefault();const d=bn(),p=d.indexOf(document.activeElement),f=p===-1&&document.activeElement===n&&!t.shiftKey?0:p+(t.shiftKey?-1:1);if(p===-1&&f!==0||f<0||f>=d.length){K("ui.key",{key:t.shiftKey?"Shift+Tab":"Tab"});return}d[f].focus();return}if(!(t.metaKey||t.ctrlKey||t.altKey)&&!(c&&t.key.length!==1)){if(t.key==="Enter"){!o&&b!==null&&!N&&ae()&&(t.preventDefault(),pt(b,null));return}if(t.key.length===1){if(t.preventDefault(),!o&&b!==null&&!N&&ae()){pt(b,t.key);return}K("ui.typed",{grapheme:t.key})}}}};n.addEventListener("keydown",t=>yt(t,!1)),E?.addEventListener("keydown",t=>yt(t,!0));const Ue=t=>{y=t,document.body.dataset.size=t,t==="inline"&&(U(),k<2&&te(null),document.activeElement?.blur?.()),ke(),R()},mt=t=>{if(!(typeof t!="object"||t===null))for(const[o,c]of Object.entries(t))/^--[a-z0-9-]+$/.test(o)&&typeof c=="string"&&c.length<=200&&!/url\(/i.test(c)&&document.documentElement.style.setProperty(o,c)},wn=t=>{const o=t.data;try{if(o===null||typeof o!="object"||o.p!==ie||o.v!==pe)return;if(typeof o.re=="string"){const d=Re.get(o.re);if(d===void 0)return;Re.delete(o.re);const p=typeof o.payload=="object"&&o.payload!==null?o.payload:{};o.ok===!0?d({ok:!0,payload:p}):d({ok:!1,error:o.error??{code:"unavailable",message:"no answer"},payload:p});return}if(Le!==null&&Le.dispatch(o))return;const c=typeof o.payload=="object"&&o.payload!==null?o.payload:{};switch(o.type){case"host.ping":typeof o.id=="string"&&x?.postMessage({p:ie,v:pe,re:o.id,ok:!0,payload:{}});return;case"host.size":(c.size==="inline"||c.size==="pane"||c.size==="full")&&Ue(c.size);return;case"host.theme":mt(c.theme);return;case"artifact.changed":{ce&&je();const d=c.version;typeof d=="number"&&d!==O&&(ee=ee??b,H(d));return}case"selection.cleared":Y=null,b!==null&&(b=null,U(),R());return;default:return}}catch{}};window.addEventListener("message",t=>{const o=t.data;if(x!==null||o===null||typeof o!="object"||o.p!==ie||o.type!=="host.hello"||t.ports[0]===void 0)return;x=t.ports[0],x.onmessage=wn;const c=typeof o.payload=="object"&&o.payload!==null?o.payload:{};$=Array.isArray(c.grants)?c.grants.filter(p=>typeof p=="string"):[],mt(c.theme);const d=Ut(c);k=d.protocol,k>=2?(L=c.surface==="options"?"options":d.surface,Z=d.tab??"style",D=d.mode??"simple",Le=new Ht(x,{surface:(p,f)=>{L=p,f!==null&&(D=f),Ee()},mode:p=>(D=p,e.coverage?Ee():R(),D),tab:p=>{e.coverage&&(Z=p,Ee())},selection:p=>{const f=p.find(h=>typeof h=="object"&&h!==null&&h.kind==="element"&&typeof h.id=="string");L==="options"&&f!==void 0||(Y=f?.id??null,b=f!==void 0&&S?.widMap[f.id]!==void 0?f.id:null,b!==null&&e.coverage&&Ae(b),U(),R())}}),Ee()):Ue(d.size),H()});const gt=M("style");let We=null;const Ee=()=>{const t=L==="options",o=e.coverage&&t&&Z==="coverage",c=e.coverage&&L==="full"&&D==="advanced";e.coverage&&(document.body.dataset.coverage=c?"side":"",E!==null&&(E.hidden=!o&&!c),(o||c)&&(ye(),je())),gt.hidden=!t||o,n.hidden=t,t&&!o&&We===null&&(We=Vt(gt,{tokens:()=>fe,key:d=>K("ui.key",{key:d}),apply:async d=>{for(let p=0;p<2;p+=1){if(O===null)return{ok:!1,reason:`The ${e.kind} is not loaded yet`};const f=await le("theme.set",{base:O,tokens:d});if(f.ok){const de=f.payload.version;return fe={name:d.name,colors:{...d.colors},fonts:{...d.fonts}},typeof de=="number"&&await H(de),{ok:!0}}if(f.error.code!=="head_moved")return{ok:!1,reason:f.error.message};const h=await le("artifact.read",{});if(!h.ok)return{ok:!1,reason:h.error.message||h.error.code};const T=h.payload.version;if(typeof T!="number"||O!==null&&T<O)return{ok:!1,reason:`The current ${e.kind} version could not be read.`};if(Pe(h.payload),p===1)return{ok:!1,reason:f.error.message||f.error.code}}return{ok:!1,reason:`The ${e.kind} changed again: try once more`}}})),Ue(Kt(L))};Xt(e.editor,e.surfaces)}un({editor:"wicked-doc",surfaces:{card:{interactive:!0,aspect:"16:9",actions:[{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:"coverage",label:"Coverage",render:"plugin"}]},full:{modes:["simple","advanced"],default:"simple"}},kind:"document",coverage:!0})})();
|
|
159
163
|
</script>
|
|
160
164
|
</body>
|
|
161
165
|
</html>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="wicked-editor" content="wicked-insights">
|
|
6
|
-
<meta name="wicked-editor-version" content="0.
|
|
6
|
+
<meta name="wicked-editor-version" content="0.15.0">
|
|
7
7
|
<title>Run insights</title>
|
|
8
8
|
<style>
|
|
9
9
|
/* The host's tokens arrive in host.hello / host.theme; these are plain fallbacks. */
|