PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 All 36 releases
← All changes | assets/js/content-graph.min.js +5 -5 1.1.6 → 1.1.12 View file →
@@ -1,12 +1,12 @@
1 -(function(){"use strict";const Oe="desktop-mode";function _e(){return window.wp?.i18n}function w(s,e=Oe){return _e()?.__(s,e)??s}function xt(s,e,t,n=Oe){return _e()?._n(s,e,t,n)??(t===1?s:e)}function ee(s,...e){const t=_e()?.sprintf;if(t)return t(s,...e);let n=0;return s.replace(/%(?:(\d+)\$)?[sd]/g,(o,i)=>{const r=i?Number.parseInt(i,10)-1:n++;return String(e[r]??"")})}class vt extends Error{constructor(e,t,n){super(`[openstation] ${e} registration rejected — fields: `+t.join(", ")+"."),this.name="RegistrationError",this.kind=e,this.errors=t,this.def=n}}function Ct(s,e,t){if(e.length!==0)throw new vt(s,e,t)}const Pe="__openStationSharedStores";function Et(){const s=window;let e=s[Pe];return e||(e=new Map,s[Pe]=e),e}function be(s,e){const t=Et();let n=t.get(s);n||(n={state:e(),listeners:new Set,rebuild:e},t.set(s,n));const o={get state(){return n.state},set state(i){n.state=i},getState(){return n.state},notify(){for(const i of Array.from(n.listeners))try{i(n.state)}catch(r){console.error(`[desktop-mode/shared-store:${s}] subscriber threw:`,r)}},subscribe(i){return n.listeners.add(i),()=>{n.listeners.delete(i)}},setState(i){const r=n.state;if(typeof r!="object"||r===null){console.warn(`[desktop-mode/shared-store:${s}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(r,i),o.notify()},reset(){const i=n.rebuild(),r=n.state;if(typeof r=="object"&&r!==null&&typeof i=="object"&&i!==null){const c=r;for(const u of Object.keys(c))delete c[u];Object.assign(c,i)}else n.state=i;n.listeners.clear()}};return o}const De=be("desktop-mode/window-actions-registry",()=>({registry:new Map,listeners:new Set})),St=De.state.registry,Nt=De.state.listeners,Fe=/^[a-z0-9_/-]+$/;function kt(){for(const s of Array.from(Nt))try{s()}catch{}}function Tt(s){const e=[];!s||typeof s!="object"?e.push("def (not an object)"):(typeof s.id!="string"||s.id.trim()===""?e.push("id (missing)"):Fe.test(s.id.trim().toLowerCase())||e.push(`id (must match ${Fe} — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-id)`),typeof s.label!="string"&&typeof s.label!="function"?e.push("label (must be a string or a function)"):typeof s.label=="string"&&s.label.trim()===""&&e.push("label (empty)"),typeof s.onSelect!="function"&&e.push("onSelect (must be a function)"),s.isVisible!==void 0&&typeof s.isVisible!="function"&&e.push("isVisible (must be a function when set)"),s.checked!==void 0&&typeof s.checked!="function"?e.push("checked (must be a function when set)"):s.checkable&&typeof s.checked!="function"&&e.push("checked (required when checkable is set)")),Ct("WindowAction",e,s);const t=s.id.trim().toLowerCase();St.set(t,{...s,id:t}),kt()}function re(s,...e){return{__wpdHtml:!0,strings:s,values:e}}function It(s){return!!s&&s.__wpdHtml===!0}const At="$$wpd$$",$=/\$\$wpd\$\$(\d+)\$\$/g,Lt="$$wpd-node$$",Mt=/^\$\$wpd-node\$\$(\d+)\$\$$/,$t=new Set(["style","script","textarea","title"]);function Rt(s){let e="",t=!1,n=null,o=!1,i=null,r="",c=!1;for(let u=0;u<s.length;u++){const l=s[u];e+=l;for(let d=0;d<l.length;d++){const p=l[d];if(o){l.startsWith("-->",d)&&(o=!1,d+=2);continue}if(i!==null){p==="<"&&l[d+1]==="/"&&l.slice(d+2,d+2+i.length).toLowerCase()===i&&(d+=1+i.length,i=null,t=!0,c=!1,r="");continue}if(n!==null){p===n&&(n=null);continue}if(t){p==='"'||p==="'"?(n=p,c=!1):p===">"?(t=!1,c=!1,$t.has(r)&&(i=r),r=""):c&&(/[a-zA-Z0-9-]/.test(p)?r+=p.toLowerCase():c=!1);continue}if(l.startsWith("<!--",d)){o=!0,d+=3;continue}const b=l[d+1]??"";p==="<"&&/[a-zA-Z/!]/.test(b)&&(t=!0,r="",c=/[a-zA-Z]/.test(b))}u<s.length-1&&(e+=t||o||i!==null?`${At}${u}$$`:`<!--${Lt}${u}$$-->`)}return e}const We=new WeakMap;function Ve(s){const e=We.get(s);if(e)return e;const t=document.createElement("template");t.innerHTML=Rt(s);const n=[],o=(c,u)=>{if(c.nodeType===Node.ELEMENT_NODE){const p=c;for(const b of Array.from(p.attributes)){const m=b.name,y=b.value,g=m[0];if($.test(y))if($.lastIndex=0,g==="@"){const v=$.exec(y);$.lastIndex=0,n.push({path:u,kind:"event",name:m.slice(1),valueIndex:v?Number(v[1]):0}),p.removeAttribute(m)}else if(g==="."){const v=$.exec(y);$.lastIndex=0,n.push({path:u,kind:"prop",name:m.slice(1),valueIndex:v?Number(v[1]):0}),p.removeAttribute(m)}else if(g==="?"){const v=$.exec(y);$.lastIndex=0,n.push({path:u,kind:"bool",name:m.slice(1),valueIndex:v?Number(v[1]):0}),p.removeAttribute(m)}else{const v=[],N=[];let S=0,k;for($.lastIndex=0;(k=$.exec(y))!==null;)v.push(y.slice(S,k.index)),N.push(Number(k[1])),S=k.index+k[0].length;v.push(y.slice(S)),n.push({path:u,kind:"attr",name:m,template:v,valueIndices:N}),p.setAttribute(m,"")}}}const l=Array.from(c.childNodes);let d=0;for(let p=0;p<l.length;p++){const b=l[p],m=p+d;if(b.nodeType===Node.COMMENT_NODE){const y=Mt.exec(b.data);if(y){const g=document.createTextNode("");b.parentNode.replaceChild(g,b),n.push({path:[...u,m],kind:"node",valueIndex:Number(y[1])})}continue}if(b.nodeType===Node.TEXT_NODE){const y=b.textContent||"";if(!$.test(y)){$.lastIndex=0;continue}$.lastIndex=0;const g=b.parentNode;let v=0,N;const S=[],k=[];for($.lastIndex=0;(N=$.exec(y))!==null;){N.index>v&&S.push(document.createTextNode(y.slice(v,N.index)));const A=document.createTextNode("");S.push(A),k.push({path:[...u,m+S.length-1],kind:"node",valueIndex:Number(N[1])}),v=N.index+N[0].length}v<y.length&&S.push(document.createTextNode(y.slice(v)));for(const A of S)g.insertBefore(A,b);g.removeChild(b),d+=S.length-1,n.push(...k)}else o(b,[...u,m])}};o(t.content,[]);const r={template:t,buildParts:c=>{const u=[];for(const l of n){let d=c;for(const p of l.path)d=d.childNodes[p];l.kind==="node"?u.push({kind:"node",valueIndex:l.valueIndex,child:{anchor:d,state:null}}):l.kind==="attr"?u.push({kind:"attr",element:d,name:l.name,template:l.template,valueIndices:l.valueIndices}):l.kind==="event"?u.push({kind:"event",valueIndex:l.valueIndex,element:d,name:l.name}):l.kind==="prop"?u.push({kind:"prop",valueIndex:l.valueIndex,element:d,name:l.name}):l.kind==="bool"&&u.push({kind:"bool",valueIndex:l.valueIndex,element:d,name:l.name})}return u}};return We.set(s,r),r}const Ge=new WeakMap;function Ot(s,e){for(const t of s.nodes)if(t.parentNode!==e)return!1;return!0}function Pt(s,e){const t=Ge.get(e);if(t&&t.strings===s.strings&&Ot(t,e)){ae(t.parts,s.values);return}const n=Ve(s.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),r=Array.from(o.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(o),ae(i,s.values),Ge.set(e,{strings:s.strings,parts:i,nodes:r})}function ae(s,e){for(const t of s)if(t.kind==="node")ce(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let n=t.template[0];for(let o=0;o<t.valueIndices.length;o++)n+=He(e[t.valueIndices[o]]),n+=t.template[o+1];n!==t.last&&(t.last=n,n===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,n))}else if(t.kind==="event"){const n=e[t.valueIndex];n!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),n&&t.element.addEventListener(t.name,n),t.current=n)}else if(t.kind==="prop"){const n=e[t.valueIndex];n!==t.last&&(t.last=n,t.element[t.name]=n)}else if(t.kind==="bool"){const n=!!e[t.valueIndex];n!==t.last&&(t.last=n,n?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function ce(s,e){if(e==null||e===!1){s.state&&(D(s.state),s.state=null);return}if(Array.isArray(e)){Vt(s,e);return}if(It(e)){Wt(s,e);return}if(e instanceof Node){Dt(s,e);return}Ft(s,He(e))}function Dt(s,e){const t=s.state;t?.shape==="node"&&t.node===e||(t&&D(t),te(s,[e]),s.state={shape:"node",node:e})}function Ft(s,e){const t=s.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&D(t);const n=document.createTextNode(e);te(s,[n]),s.state={shape:"text",node:n,text:e}}function Wt(s,e){const t=s.state;if(t?.shape==="template"&&t.strings===e.strings){ae(t.parts,e.values);return}t&&D(t);const n=Ve(e.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),r=Array.from(o.childNodes);te(s,[o]),ae(i,e.values),s.state={shape:"template",strings:e.strings,parts:i,nodes:r}}function Vt(s,e){const t=s.state;if(t?.shape==="array"){const o=Math.min(t.entries.length,e.length);for(let i=0;i<o;i++)ce(t.entries[i],e[i]);if(e.length<t.entries.length){for(let i=e.length;i<t.entries.length;i++){const r=t.entries[i];r.state&&D(r.state),r.anchor.remove()}t.entries.length=e.length}else for(let i=t.entries.length;i<e.length;i++){const r=document.createTextNode("");te(s,[r]);const c={anchor:r,state:null};ce(c,e[i]),t.entries.push(c)}return}t&&D(t);const n=[];for(const o of e){const i=document.createTextNode("");te(s,[i]);const r={anchor:i,state:null};ce(r,o),n.push(r)}s.state={shape:"array",entries:n}}function te(s,e){const t=s.anchor.parentNode;if(t)for(const n of e)t.insertBefore(n,s.anchor)}function D(s){if(s.shape==="text"){s.node.remove();return}if(s.shape==="template"){for(const e of s.parts)e.kind==="node"&&e.child.state&&(D(e.child.state),e.child.state=null);for(const e of s.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(s.shape==="node"){s.node.parentNode&&s.node.parentNode.removeChild(s.node);return}for(const e of s.entries)e.state&&D(e.state),e.anchor.remove()}function He(s){return s==null||s===!1?"":String(s)}const W=class W extends HTMLElement{constructor(){super(),this._renderScheduled=!1,this._propValues={},this.constructor.shadow?(this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot):this._renderRoot=this,this._installPropAccessors()}static get observedAttributes(){return this.props.map(Ue)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,n){if(t===n)return;const o=Gt(e);this._propValues[o]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const n=(Array.isArray(e)?e:String(e).split(/\s+/)).map(o=>String(o).trim()).filter(o=>o!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const t of e.props){if(Object.getOwnPropertyDescriptor(this,t))continue;const n=Ue(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(n),set:o=>{let i;o==null||o===!1?i=null:o===!0?i="":i=String(o),this._propValues[t]=i,i===null?this.removeAttribute(n):this.setAttribute(n,i),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&Pt(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.length!==e.styles.length){for(const n of e.styles)if(!n.sheet){const o=document.createElement("style");o.textContent=n.cssText,this.shadowRoot.appendChild(o)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!W._lightStylesAdopted.has(e)){W._lightStylesAdopted.add(e);for(const t of e.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=t.cssText,document.head.appendChild(n)}}}};W.props=[],W.styles=[],W.shadow=!0,W._lightStylesAdopted=new WeakSet;let le=W;function ze(s,e){customElements.get(s)||customElements.define(s,e)}function Ue(s){return s.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function Gt(s){return s.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const Ht=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function Be(s,...e){let t=s[0];for(let n=1;n<s.length;n++){const o=e[n-1];if(typeof o=="string"||typeof o=="number")t+=String(o);else if(o&&o.__wpdCss)t+=o.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof o);t+=s[n]}if(Ht){const n=new CSSStyleSheet;return n.replaceSync(t),{__wpdCss:!0,sheet:n,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}const zt=Be`:host{display:inline-flex;align-items:center;justify-content:center;width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );color:inherit;line-height:1}:host( [ hidden ] ){display:none}.os-icon__glyph{font-size:var( --os-ui-icon-size,16px );width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );line-height:1;color:inherit;display:inline-flex;align-items:center;justify-content:center}.os-icon__glyph--char{font-family:dashicons;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none}.os-icon__glyph.dashicons{font-family:dashicons}`;let de=null;function Ut(s){let e=s.trim();if(e==="")return null;(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));const t=e.match(/^\\([0-9a-f]{1,6})\s?$/i);return t?String.fromCodePoint(parseInt(t[1],16)):e||null}function Ye(){const s=new Map;if(typeof document>"u")return s;const e=Array.from(document.styleSheets??[]);for(const t of e){let n=null;try{n=t.cssRules}catch{continue}if(n)for(const o of Array.from(n)){const i=o;if(!i||!i.selectorText)continue;const r=i.selectorText.match(/\.dashicons-([a-z0-9-]+)::?before/i);if(!r)continue;const c=i.style?.content;if(!c)continue;const u=Ut(c);u&&s.set(r[1],u)}}return s}function xe(s){de||(de=Ye());const e=s.startsWith("dashicons-")?s.slice(10):s;return de.get(e)??null}function Bt(){de=Ye()}let qe=!1;function Yt(){if(qe||typeof window>"u")return;qe=!0;const s=()=>{Bt()};document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",s,{once:!0}),window.addEventListener("load",s,{once:!0})}Yt();const ne=class ne extends le{render(){const e=this.name||"",t=e.startsWith("dashicons-")?e.slice(10):e,n=this.size;n&&/^\d+$/.test(n)&&this.style.setProperty("--os-ui-icon-size",`${n}px`);const o=xe(t);return o?re`<span
1 +(function(){"use strict";const Pe="desktop-mode";function _e(){return window.wp?.i18n}function y(s,e=Pe){return _e()?.__(s,e)??s}function vt(s,e,t,n=Pe){return _e()?._n(s,e,t,n)??(t===1?s:e)}function te(s,...e){const t=_e()?.sprintf;if(t)return t(s,...e);let n=0;return s.replace(/%(?:(\d+)\$)?[sd]/g,(o,i)=>{const r=i?Number.parseInt(i,10)-1:n++;return String(e[r]??"")})}class Ct extends Error{constructor(e,t,n){super(`[openstation] ${e} registration rejected — fields: `+t.join(", ")+"."),this.name="RegistrationError",this.kind=e,this.errors=t,this.def=n}}function Et(s,e,t){if(e.length!==0)throw new Ct(s,e,t)}const De="__openStationSharedStores";function St(){const s=window;let e=s[De];return e||(e=new Map,s[De]=e),e}function xe(s,e){const t=St();let n=t.get(s);n||(n={state:e(),listeners:new Set,rebuild:e},t.set(s,n));const o={get state(){return n.state},set state(i){n.state=i},getState(){return n.state},notify(){for(const i of Array.from(n.listeners))try{i(n.state)}catch(r){console.error(`[desktop-mode/shared-store:${s}] subscriber threw:`,r)}},subscribe(i){return n.listeners.add(i),()=>{n.listeners.delete(i)}},setState(i){const r=n.state;if(typeof r!="object"||r===null){console.warn(`[desktop-mode/shared-store:${s}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(r,i),o.notify()},reset(){const i=n.rebuild(),r=n.state;if(typeof r=="object"&&r!==null&&typeof i=="object"&&i!==null){const c=r;for(const u of Object.keys(c))delete c[u];Object.assign(c,i)}else n.state=i;n.listeners.clear()}};return o}const Fe=xe("desktop-mode/window-actions-registry",()=>({registry:new Map,listeners:new Set})),Nt=Fe.state.registry,kt=Fe.state.listeners,We=/^[a-z0-9_/-]+$/;function At(){for(const s of Array.from(kt))try{s()}catch{}}function Tt(s){const e=[];!s||typeof s!="object"?e.push("def (not an object)"):(typeof s.id!="string"||s.id.trim()===""?e.push("id (missing)"):We.test(s.id.trim().toLowerCase())||e.push(`id (must match ${We} — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-id)`),typeof s.label!="string"&&typeof s.label!="function"?e.push("label (must be a string or a function)"):typeof s.label=="string"&&s.label.trim()===""&&e.push("label (empty)"),typeof s.onSelect!="function"&&e.push("onSelect (must be a function)"),s.isVisible!==void 0&&typeof s.isVisible!="function"&&e.push("isVisible (must be a function when set)"),s.checked!==void 0&&typeof s.checked!="function"?e.push("checked (must be a function when set)"):s.checkable&&typeof s.checked!="function"&&e.push("checked (required when checkable is set)")),Et("WindowAction",e,s);const t=s.id.trim().toLowerCase();Nt.set(t,{...s,id:t}),At()}function ae(s,...e){return{__wpdHtml:!0,strings:s,values:e}}function It(s){return!!s&&s.__wpdHtml===!0}const Lt="$$wpd$$",$=/\$\$wpd\$\$(\d+)\$\$/g,Mt="$$wpd-node$$",$t=/^\$\$wpd-node\$\$(\d+)\$\$$/,Rt=new Set(["style","script","textarea","title"]);function Ot(s){let e="",t=!1,n=null,o=!1,i=null,r="",c=!1;for(let u=0;u<s.length;u++){const d=s[u];e+=d;for(let l=0;l<d.length;l++){const p=d[l];if(o){d.startsWith("-->",l)&&(o=!1,l+=2);continue}if(i!==null){p==="<"&&d[l+1]==="/"&&d.slice(l+2,l+2+i.length).toLowerCase()===i&&(l+=1+i.length,i=null,t=!0,c=!1,r="");continue}if(n!==null){p===n&&(n=null);continue}if(t){p==='"'||p==="'"?(n=p,c=!1):p===">"?(t=!1,c=!1,Rt.has(r)&&(i=r),r=""):c&&(/[a-zA-Z0-9-]/.test(p)?r+=p.toLowerCase():c=!1);continue}if(d.startsWith("<!--",l)){o=!0,l+=3;continue}const b=d[l+1]??"";p==="<"&&/[a-zA-Z/!]/.test(b)&&(t=!0,r="",c=/[a-zA-Z]/.test(b))}u<s.length-1&&(e+=t||o||i!==null?`${Lt}${u}$$`:`<!--${Mt}${u}$$-->`)}return e}const Ve=new WeakMap;function Ge(s){const e=Ve.get(s);if(e)return e;const t=document.createElement("template");t.innerHTML=Ot(s);const n=[],o=(c,u)=>{if(c.nodeType===Node.ELEMENT_NODE){const p=c;for(const b of Array.from(p.attributes)){const g=b.name,_=b.value,m=g[0];if($.test(_))if($.lastIndex=0,m==="@"){const v=$.exec(_);$.lastIndex=0,n.push({path:u,kind:"event",name:g.slice(1),valueIndex:v?Number(v[1]):0}),p.removeAttribute(g)}else if(m==="."){const v=$.exec(_);$.lastIndex=0,n.push({path:u,kind:"prop",name:g.slice(1),valueIndex:v?Number(v[1]):0}),p.removeAttribute(g)}else if(m==="?"){const v=$.exec(_);$.lastIndex=0,n.push({path:u,kind:"bool",name:g.slice(1),valueIndex:v?Number(v[1]):0}),p.removeAttribute(g)}else{const v=[],E=[];let k=0,N;for($.lastIndex=0;(N=$.exec(_))!==null;)v.push(_.slice(k,N.index)),E.push(Number(N[1])),k=N.index+N[0].length;v.push(_.slice(k)),n.push({path:u,kind:"attr",name:g,template:v,valueIndices:E}),p.setAttribute(g,"")}}}const d=Array.from(c.childNodes);let l=0;for(let p=0;p<d.length;p++){const b=d[p],g=p+l;if(b.nodeType===Node.COMMENT_NODE){const _=$t.exec(b.data);if(_){const m=document.createTextNode("");b.parentNode.replaceChild(m,b),n.push({path:[...u,g],kind:"node",valueIndex:Number(_[1])})}continue}if(b.nodeType===Node.TEXT_NODE){const _=b.textContent||"";if(!$.test(_)){$.lastIndex=0;continue}$.lastIndex=0;const m=b.parentNode;let v=0,E;const k=[],N=[];for($.lastIndex=0;(E=$.exec(_))!==null;){E.index>v&&k.push(document.createTextNode(_.slice(v,E.index)));const I=document.createTextNode("");k.push(I),N.push({path:[...u,g+k.length-1],kind:"node",valueIndex:Number(E[1])}),v=E.index+E[0].length}v<_.length&&k.push(document.createTextNode(_.slice(v)));for(const I of k)m.insertBefore(I,b);m.removeChild(b),l+=k.length-1,n.push(...N)}else o(b,[...u,g])}};o(t.content,[]);const r={template:t,buildParts:c=>{const u=[];for(const d of n){let l=c;for(const p of d.path)l=l.childNodes[p];d.kind==="node"?u.push({kind:"node",valueIndex:d.valueIndex,child:{anchor:l,state:null}}):d.kind==="attr"?u.push({kind:"attr",element:l,name:d.name,template:d.template,valueIndices:d.valueIndices}):d.kind==="event"?u.push({kind:"event",valueIndex:d.valueIndex,element:l,name:d.name}):d.kind==="prop"?u.push({kind:"prop",valueIndex:d.valueIndex,element:l,name:d.name}):d.kind==="bool"&&u.push({kind:"bool",valueIndex:d.valueIndex,element:l,name:d.name})}return u}};return Ve.set(s,r),r}const He=new WeakMap;function Pt(s,e){for(const t of s.nodes)if(t.parentNode!==e)return!1;return!0}function Dt(s,e){const t=He.get(e);if(t&&t.strings===s.strings&&Pt(t,e)){ce(t.parts,s.values);return}const n=Ge(s.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),r=Array.from(o.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(o),ce(i,s.values),He.set(e,{strings:s.strings,parts:i,nodes:r})}function ce(s,e){for(const t of s)if(t.kind==="node")le(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let n=t.template[0];for(let o=0;o<t.valueIndices.length;o++)n+=ze(e[t.valueIndices[o]]),n+=t.template[o+1];n!==t.last&&(t.last=n,n===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,n))}else if(t.kind==="event"){const n=e[t.valueIndex];n!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),n&&t.element.addEventListener(t.name,n),t.current=n)}else if(t.kind==="prop"){const n=e[t.valueIndex];n!==t.last&&(t.last=n,t.element[t.name]=n)}else if(t.kind==="bool"){const n=!!e[t.valueIndex];n!==t.last&&(t.last=n,n?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function le(s,e){if(e==null||e===!1){s.state&&(D(s.state),s.state=null);return}if(Array.isArray(e)){Gt(s,e);return}if(It(e)){Vt(s,e);return}if(e instanceof Node){Ft(s,e);return}Wt(s,ze(e))}function Ft(s,e){const t=s.state;t?.shape==="node"&&t.node===e||(t&&D(t),ne(s,[e]),s.state={shape:"node",node:e})}function Wt(s,e){const t=s.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&D(t);const n=document.createTextNode(e);ne(s,[n]),s.state={shape:"text",node:n,text:e}}function Vt(s,e){const t=s.state;if(t?.shape==="template"&&t.strings===e.strings){ce(t.parts,e.values);return}t&&D(t);const n=Ge(e.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),r=Array.from(o.childNodes);ne(s,[o]),ce(i,e.values),s.state={shape:"template",strings:e.strings,parts:i,nodes:r}}function Gt(s,e){const t=s.state;if(t?.shape==="array"){const o=Math.min(t.entries.length,e.length);for(let i=0;i<o;i++)le(t.entries[i],e[i]);if(e.length<t.entries.length){for(let i=e.length;i<t.entries.length;i++){const r=t.entries[i];r.state&&D(r.state),r.anchor.remove()}t.entries.length=e.length}else for(let i=t.entries.length;i<e.length;i++){const r=document.createTextNode("");ne(s,[r]);const c={anchor:r,state:null};le(c,e[i]),t.entries.push(c)}return}t&&D(t);const n=[];for(const o of e){const i=document.createTextNode("");ne(s,[i]);const r={anchor:i,state:null};le(r,o),n.push(r)}s.state={shape:"array",entries:n}}function ne(s,e){const t=s.anchor.parentNode;if(t)for(const n of e)t.insertBefore(n,s.anchor)}function D(s){if(s.shape==="text"){s.node.remove();return}if(s.shape==="template"){for(const e of s.parts)e.kind==="node"&&e.child.state&&(D(e.child.state),e.child.state=null);for(const e of s.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(s.shape==="node"){s.node.parentNode&&s.node.parentNode.removeChild(s.node);return}for(const e of s.entries)e.state&&D(e.state),e.anchor.remove()}function ze(s){return s==null||s===!1?"":String(s)}const W=class W extends HTMLElement{constructor(){super(),this._renderScheduled=!1,this._propValues={},this.constructor.shadow?(this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot):this._renderRoot=this,this._installPropAccessors()}static get observedAttributes(){return this.props.map(Be)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,n){if(t===n)return;const o=Ht(e);this._propValues[o]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const n=(Array.isArray(e)?e:String(e).split(/\s+/)).map(o=>String(o).trim()).filter(o=>o!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const t of e.props){if(Object.getOwnPropertyDescriptor(this,t))continue;const n=Be(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(n),set:o=>{let i;o==null||o===!1?i=null:o===!0?i="":i=String(o),this._propValues[t]=i,i===null?this.removeAttribute(n):this.setAttribute(n,i),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&Dt(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.length!==e.styles.length){for(const n of e.styles)if(!n.sheet){const o=document.createElement("style");o.textContent=n.cssText,this.shadowRoot.appendChild(o)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!W._lightStylesAdopted.has(e)){W._lightStylesAdopted.add(e);for(const t of e.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=t.cssText,document.head.appendChild(n)}}}};W.props=[],W.styles=[],W.shadow=!0,W._lightStylesAdopted=new WeakSet;let de=W;function Ue(s,e){customElements.get(s)||customElements.define(s,e)}function Be(s){return s.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function Ht(s){return s.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const zt=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function Ye(s,...e){let t=s[0];for(let n=1;n<s.length;n++){const o=e[n-1];if(typeof o=="string"||typeof o=="number")t+=String(o);else if(o&&o.__wpdCss)t+=o.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof o);t+=s[n]}if(zt){const n=new CSSStyleSheet;return n.replaceSync(t),{__wpdCss:!0,sheet:n,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}const Ut=Ye`:host{display:inline-flex;align-items:center;justify-content:center;width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );color:inherit;line-height:1}:host( [ hidden ] ){display:none}.os-icon__glyph{font-size:var( --os-ui-icon-size,16px );width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );line-height:1;color:inherit;display:inline-flex;align-items:center;justify-content:center}.os-icon__glyph--char{font-family:dashicons;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none}.os-icon__glyph.dashicons{font-family:dashicons}`;let he=null;function Bt(s){let e=s.trim();if(e==="")return null;(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));const t=e.match(/^\\([0-9a-f]{1,6})\s?$/i);return t?String.fromCodePoint(parseInt(t[1],16)):e||null}function qe(){const s=new Map;if(typeof document>"u")return s;const e=Array.from(document.styleSheets??[]);for(const t of e){let n=null;try{n=t.cssRules}catch{continue}if(n)for(const o of Array.from(n)){const i=o;if(!i||!i.selectorText)continue;const r=i.selectorText.match(/\.dashicons-([a-z0-9-]+)::?before/i);if(!r)continue;const c=i.style?.content;if(!c)continue;const u=Bt(c);u&&s.set(r[1],u)}}return s}function ve(s){he||(he=qe());const e=s.startsWith("dashicons-")?s.slice(10):s;return he.get(e)??null}function Yt(){he=qe()}let Xe=!1;function qt(){if(Xe||typeof window>"u")return;Xe=!0;const s=()=>{Yt()};document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",s,{once:!0}),window.addEventListener("load",s,{once:!0})}qt();const se=class se extends de{render(){const e=this.name||"",t=e.startsWith("dashicons-")?e.slice(10):e,n=this.size;n&&/^\d+$/.test(n)&&this.style.setProperty("--os-ui-icon-size",`${n}px`);const o=ve(t);return o?ae`<span
2 2 class="os-icon__glyph os-icon__glyph--char dashicons dashicons-${t}"
3 3 aria-hidden="true"
4 - >${o}</span>`:re`<span
4 + >${o}</span>`:ae`<span
5 5 class="os-icon__glyph dashicons dashicons-${t}"
6 6 aria-hidden="true"
7 - ></span>`}};ne.props=["name","size"],ne.styles=[zt],ne.help=void 0;let ve=ne;ze("os-icon",ve);const qt=Be`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:32px 24px;text-align:center;color:var( --os-ui-empty-state-fg,var( --os-ui-fg-muted,#646970 ) )}:host( [ hidden ] ){display:none}.os-empty-state__icon{margin-bottom:4px;color:var( --os-ui-empty-state-icon-color,currentColor );opacity:0.75}.os-empty-state__heading{margin:0;font-size:14px;font-weight:600;color:var( --os-ui-fg,#1d2327 )}.os-empty-state__description{margin:0;font-size:12px;line-height:1.4;max-width:48ch}.os-empty-state__description:empty{display:none}.os-empty-state__cta{margin-top:8px}.os-empty-state__cta:empty{display:none}`,se=class se extends le{render(){const e=this.icon||"",t=this.heading||"",n=this.description||"";return re`
8 - ${e?re`<os-icon
7 + ></span>`}};se.props=["name","size"],se.styles=[Ut],se.help=void 0;let Ce=se;Ue("os-icon",Ce);const Xt=Ye`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:32px 24px;text-align:center;color:var( --os-ui-empty-state-fg,var( --os-ui-fg-muted,#646970 ) )}:host( [ hidden ] ){display:none}.os-empty-state__icon{margin-bottom:4px;color:var( --os-ui-empty-state-icon-color,currentColor );opacity:0.75}.os-empty-state__heading{margin:0;font-size:14px;font-weight:600;color:var( --os-ui-fg,#1d2327 )}.os-empty-state__description{margin:0;font-size:12px;line-height:1.4;max-width:48ch}.os-empty-state__description:empty{display:none}.os-empty-state__cta{margin-top:8px}.os-empty-state__cta:empty{display:none}`,oe=class oe extends de{render(){const e=this.icon||"",t=this.heading||"",n=this.description||"";return ae`
8 + ${e?ae`<os-icon
9 9 class="os-empty-state__icon"
10 10 name=${e}
11 11 size="28"
12 12 ></os-icon>`:null}
@@ -15,5 +15,5 @@
15 15 <div class="os-empty-state__cta">
16 16 <slot name="cta"></slot>
17 17 </div>
18 18 <slot></slot>
19 - `}};se.props=["icon","heading","description"],se.styles=[qt],se.help=void 0;let Ce=se;ze("os-empty-state",Ce);function Xt(s){if(s.nodes>0)return s.edges>0?{kind:"none"}:{kind:"no-threads"};if(s.activeTypes.length===0&&s.types.length>0)return{kind:"all-off"};const e=new Set(s.activeTypes),t=s.types.some(o=>typeof o.count=="number");let n=0;for(const o of s.types)e.has(o.slug)||(n+=t?o.count??0:1);return n>0?{kind:"filtered-out"}:{kind:"no-content"}}const Kt="os-content-graph__empty",Ee="os-content-graph__hint";function jt(s){let e=null,t="none",n={kind:"none"},o=!1;const i=()=>{e?.remove(),e=null,t="none"},r=(d,p,b)=>{const m=document.createElement("os-empty-state");return m.className=Kt,m.setAttribute("icon",d),m.setAttribute("heading",p),m.setAttribute("description",b),m},c=(d,p)=>{const b=document.createElement("div");b.className=Ee,b.setAttribute("role","note");const m=document.createElement("strong");m.className=`${Ee}-title`,m.textContent=d;const y=document.createElement("p");return y.className=`${Ee}-body`,y.textContent=p,b.append(m,y),b},u=d=>{switch(d.kind){case"none":return null;case"no-content":return r("admin-post",w("Nothing on the board yet"),w("Publish a post or a page and it is pinned here. Threads are drawn between posts when one links to another."));case"filtered-out":return r("filter",w("Nothing to show for these types"),w("The post types switched on in the toolbar have no content yet. Switch another one on to see its posts."));case"all-off":return r("filter",w("Every post type is switched off"),w("Switch a type back on in the toolbar to see its posts."));case"no-threads":return c(w("No threads yet"),w("A thread joins two posts when one links to the other. Click a node to see its author, terms, comments, media and revisions, or group the board by category, tag, author, year or month from the toolbar."))}},l=()=>{const d=o&&n.kind==="no-threads"?{kind:"none"}:n;if(d.kind===t)return;i();const p=u(d);p&&(s.appendChild(p),e=p,t=d.kind)};return{set:d=>{n=d,l()},setSuppressed:d=>{o=d,l()},destroy:i}}const Zt=400,Y="os-content-graph__loading--visible";function Qt(s,e=Zt){let t=null;const n=()=>{t!==null&&(clearTimeout(t),t=null)};return s&&(s.hidden=!1,s.classList.remove(Y)),{show:()=>{!s||t!==null||s.classList.contains(Y)||(t=setTimeout(()=>{t=null,s.classList.add(Y)},e))},hide:()=>{n(),s?.classList.remove(Y)},destroy:()=>{n(),s?.classList.remove(Y)},isVisible:()=>!!s?.classList.contains(Y)}}const Jt="http://localhost/";function Se(s,e){const t=typeof window<"u"&&window.location?window.location.href:Jt,n=new URL(s,t),o=e.replace(/^\/+/,""),i=o.indexOf("?"),r=i===-1?o:o.slice(0,i),c=i===-1?"":o.slice(i+1);if(n.searchParams.has("rest_route")){const u=n.searchParams.get("rest_route")??"/",l=u.endsWith("/")?u:u+"/";n.searchParams.set("rest_route",l+r)}else{const u=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=u+r}return c&&new URLSearchParams(c).forEach((l,d)=>{n.searchParams.append(d,l)}),n.toString()}const Xe="X-WP-Nonce";function en(s,e){const t=tn();if(!t)return e;const n=nn(s);if(!n||!sn(n))return e;const o=e?.headers??(typeof Request<"u"&&s instanceof Request?s.headers:void 0),i=new Headers(o??{});return i.has(Xe)?e:(i.set(Xe,t),{...e??{},headers:i})}function tn(){if(typeof window>"u")return;const e=window.openStationConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function nn(s){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof s=="string"?new URL(s,e):s instanceof URL?s:typeof Request<"u"&&s instanceof Request?new URL(s.url,e):null}catch{return null}}function sn(s){return typeof window>"u"||!window.location||s.origin!==window.location.origin?!1:!!(s.pathname.includes("/wp-json/")||s.searchParams.has("rest_route"))}function q(s,e,t={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(s,e,t);const o=en(s,e);return fetch(s,o)}const G="desktop-mode-content-graph",X="desktop-mode/content-graph";function Ke(){const e=(window.openStationWindowConfig??{})[G];if(!e)throw new Error("Corkboard config missing — openstation_register_window args lost in transit.");return e}function K(s){return{Accept:"application/json","X-WP-Nonce":s.restNonce}}async function on(s){const e=await q(`${s.apiBase}/post-types`,{headers:K(s)},{source:X,windowId:G});if(!e.ok)throw new Error(`post-types: ${e.status}`);return await e.json()}async function rn(s,e){const t=new URL(`${s.apiBase}/nodes`);t.searchParams.set("types",e.join(","));const n=await q(t.toString(),{headers:K(s)},{source:X,windowId:G});if(!n.ok)throw new Error(`nodes: ${n.status}`);return await n.json()}async function an(s,e){const t=await q(`${s.apiBase}/post/${e}`,{headers:K(s)},{source:X,windowId:G});if(!t.ok)throw new Error(`post/${e}: ${t.status}`);return await t.json()}async function cn(s,e){const t=await q(Se(s.restRoot,`desktop-mode/v1/user-stats/${e}`),{headers:K(s)},{source:X,windowId:G});if(!t.ok)throw new Error(`user-stats/${e}: ${t.status}`);return await t.json()}async function ln(s,e,t){const n=await q(Se(s.restRoot,`desktop-mode/v1/term-stats/${encodeURIComponent(e)}/${t}`),{headers:K(s)},{source:X,windowId:G});if(!n.ok)throw new Error(`term-stats/${e}/${t}: ${n.status}`);return await n.json()}async function dn(s,e){const t=await q(Se(s.restRoot,`desktop-mode/v1/comment-stats/${e}`),{headers:K(s)},{source:X,windowId:G});if(!t.ok)throw new Error(`comment-stats/${e}: ${t.status}`);return await t.json()}const he="none";function hn(s,e,t){s.replaceChildren();const n=new Set(e.map(y=>y.slug)),o=document.createElement("div");o.className="os-content-graph__filters",s.appendChild(o);for(const y of e){const g=document.createElement("button");g.type="button",g.className="os-content-graph__chip is-active",g.dataset.slug=y.slug,g.innerHTML=`<span class="dashicons ${je(y.icon)}" aria-hidden="true"></span><span class="os-content-graph__chip-label">${pe(y.label)}</span><span class="os-content-graph__chip-count">${y.count}</span>`,g.addEventListener("click",()=>{n.has(y.slug)?(n.delete(y.slug),g.classList.remove("is-active")):(n.add(y.slug),g.classList.add("is-active")),t.onTypesChange(Array.from(n))}),o.appendChild(g)}const i=document.createElement("div");i.className="os-content-graph__search";const r=document.createElement("input");r.type="search",r.className="os-content-graph__search-input",r.placeholder=w("Search nodes…"),r.setAttribute("aria-label",w("Search posts and pages in the graph")),i.appendChild(r);const c=document.createElement("ul");c.className="os-content-graph__search-results",c.hidden=!0,i.appendChild(c),s.appendChild(i);const u=()=>{const y=r.value.trim().toLowerCase();if(y.length===0){c.hidden=!0,c.replaceChildren();return}const g=t.getNodes().filter(v=>v.title.toLowerCase().includes(y)).slice(0,10);c.replaceChildren();for(const v of g){const N=document.createElement("li"),S=document.createElement("button");S.type="button",S.className="os-content-graph__search-result",S.innerHTML=`<span class="os-content-graph__search-title">${pe(v.title||"#"+v.id)}</span><span class="os-content-graph__search-type">${pe(v.type)}</span>`,S.addEventListener("click",()=>{r.value="",c.hidden=!0,c.replaceChildren(),t.onSearchSelect(v)}),N.appendChild(S),c.appendChild(N)}c.hidden=g.length===0};r.addEventListener("input",u),r.addEventListener("focus",u),r.addEventListener("blur",()=>{setTimeout(()=>{c.hidden=!0},120)});const l=document.createElement("os-select");l.className="os-content-graph__group-by",l.setAttribute("value",he),l.setAttribute("aria-label",w("Group by")),l.title=w("Group posts by a shared facet");for(const[y,g]of[[he,w("No grouping")],["category",w("Group by category")],["tag",w("Group by tag")],["author",w("Group by author")],["year",w("Group by year")],["year_month",w("Group by year-month")]]){const v=document.createElement("os-option");v.setAttribute("value",y),v.textContent=g,l.appendChild(v)}l.addEventListener("os-pick",y=>{const v=y.detail?.value??he,N=v===he?null:v;t.onGroupChange(N)}),s.insertBefore(l,i);const d=document.createElement("div");d.className="os-content-graph__actions";const p=document.createElement("button");p.type="button",p.className="os-content-graph__btn",p.innerHTML=`<span class="dashicons dashicons-editor-expand" aria-hidden="true"></span><span>${pe(w("Fit"))}</span>`,p.title=w("Fit graph to view"),p.addEventListener("click",()=>t.onFitToView()),d.appendChild(p);const b=document.createElement("span");b.className="os-content-graph__toolbar-status",d.appendChild(b),s.appendChild(d);const m=y=>{i.contains(y.target)||(c.hidden=!0)};return document.addEventListener("click",m),{setStatus:y=>{b.textContent=y},updateCounts:y=>{for(const g of y){const v=o.querySelector(`.os-content-graph__chip[data-slug="${je(g.slug)}"] .os-content-graph__chip-count`);v&&(v.textContent=String(g.count??0))}},destroy:()=>{document.removeEventListener("click",m)}}}function pe(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function je(s){return s.replace(/[^a-zA-Z0-9 _\-]/g,"")}const pn="my-wordpress",j=be("desktop-mode/my-wordpress/open-target",()=>({kind:null,entityId:"",id:0,title:"",requestedAt:0}));function un(s){j.state.kind=s.kind,j.state.entityId=s.entityId,j.state.id=s.id,j.state.title=s.title,j.state.requestedAt=Date.now(),j.notify()}function fn(s){const e=window.wp?.os?.openWindow;e?.(pn,{source:s})}function mn(s){const e=Number(s.postId);!Number.isFinite(e)||e<=0||(un({kind:"detail",entityId:s.entityId||"posts",id:e,title:s.postTitle??""}),fn("my-wordpress/open-detail"))}function H(s){const e=document.createElement("textarea");return e.innerHTML=s,e.value}function gn(s,e,t){s.replaceChildren(),s.hidden=!1,s.classList.add("os-content-graph__panel--closed");const n=a=>{s.classList.toggle("os-content-graph__panel--closed",!a)};let o=null,i={kind:"post"},r=0;const c=document.createElement("div");c.className="os-content-graph__panel-frame";const u=document.createElement("nav");u.className="os-content-graph__panel-breadcrumb",u.hidden=!0;const l=document.createElement("header");l.className="os-content-graph__panel-head";const d=document.createElement("div");d.className="os-content-graph__panel-title-wrap";const p=document.createElement("h2");p.className="os-content-graph__panel-title";const b=document.createElement("p");b.className="os-content-graph__panel-meta",d.appendChild(p),d.appendChild(b);const m=document.createElement("button");m.type="button",m.className="os-content-graph__panel-close",m.innerHTML='<span class="dashicons dashicons-no-alt" aria-hidden="true"></span>',m.title=w("Close panel"),m.addEventListener("click",()=>t.onClose()),l.appendChild(d),l.appendChild(m);const y=document.createElement("div");y.className="os-content-graph__panel-body",c.appendChild(u),c.appendChild(l),c.appendChild(y),s.appendChild(c);let g=S();y.append(g);let v=null,N=0;function S(){const a=document.createElement("div");return a.className="os-content-graph__panel-page",a}const k=(a,f,h)=>{if(y.append(f),a===f||h==="none"){a!==f&&a.remove();return}const _=h==="forward"?"page-from-right":"page-from-left",x=h==="forward"?"page-to-left":"page-to-right";f.classList.add(`os-content-graph__${_}`),f.offsetWidth;const E=++N;requestAnimationFrame(()=>{E===N&&(f.classList.remove(`os-content-graph__${_}`),a.classList.add(`os-content-graph__${x}`))});let T=!1;const M=()=>{T||(T=!0,a.removeEventListener("transitionend",M),a.remove())};a.addEventListener("transitionend",M),setTimeout(M,360)},A=a=>{switch(a.kind){case"post":return null;case"user":return`user:${a.user.id}`;case"term":return`term:${a.term.taxonomy}:${a.term.id}`;case"comment":return`comment:${a.comment.id}`;case"media":return`media:${a.media.id}`;case"revision":return`revision:${a.revision.id}`}},O=()=>(window.wp??{}).os??{},C=(a,f,h,_)=>{const x=O();if(!x.windowManager||!x.deriveWindowId||!a){a&&(window.location.href=a);return}const E=x.windowManager.getFocused?.();E?.isFullscreen?.()&&E.toggleFullscreen?.();let T=x.deriveWindowId(a);_&&(T=`${T}-${_}`),x.windowManager.open({id:T,baseId:T,url:a,title:f,icon:h})},P=()=>{if(u.replaceChildren(),i.kind==="post"||!o){u.hidden=!0;return}u.hidden=!1;const a=document.createElement("button");a.type="button",a.className="os-content-graph__panel-breadcrumb-back";const f=document.createElement("span");f.className="dashicons dashicons-arrow-left-alt2 os-content-graph__panel-breadcrumb-arrow",f.setAttribute("aria-hidden","true");const h=document.createElement("span");h.className="os-content-graph__panel-breadcrumb-label",h.textContent=H(o.post.title)||`#${o.post.id}`,a.appendChild(f),a.appendChild(h),a.title=w("Back to post"),a.addEventListener("click",()=>{i={kind:"post"},L()}),u.appendChild(a)},L=()=>{n(!0),P();const a=S(),f=g;switch(g=a,i.kind){case"post":z(o);break;case"user":os(i);break;case"term":is(i);break;case"comment":rs(i);break;case"media":as(i.media);break;case"revision":cs(i.revision);break}let h="none";v!==null&&v!==i.kind&&(i.kind==="post"?h="back":h="forward"),k(f,a,h),t.onViewChange?.(A(i)),v=i.kind},z=a=>{if(!a){p.textContent="",b.textContent="";return}p.textContent=H(a.post.title)||`#${a.post.id}`,b.textContent=`${a.post.type} · ${a.post.status}`,g.appendChild(ye(a)),g.appendChild(oe(a)),g.appendChild(U([{label:w("Contributors"),value:a.contributors.length},{label:w("Comments"),value:a.comments.length},{label:w("Taxonomies"),value:a.categories.length},{label:w("Media"),value:a.attached_media.length},{label:w("Revisions"),value:a.revisions.length}])),g.appendChild(J(a))},ye=a=>{const f=document.createElement("div");if(f.className="os-content-graph__panel-author",!a.author)return f.hidden=!0,f;const h=document.createElement("span");h.className="os-content-graph__panel-section-label",h.textContent=w("Author"),f.appendChild(h);const _=document.createElement("div");if(_.className="os-content-graph__panel-author-row",a.author.avatar){const E=document.createElement("img");E.className="os-content-graph__panel-avatar",E.src=a.author.avatar,E.alt="",_.appendChild(E)}const x=document.createElement("span");return x.className="os-content-graph__panel-author-name",x.textContent=a.author.name,_.appendChild(x),f.appendChild(_),f},oe=a=>{const f=document.createElement("div");f.className="os-content-graph__panel-dates";const h=[];if(a.post.date&&h.push({label:w("Published"),iso:a.post.date}),a.post.modified&&a.post.modified!==a.post.date&&h.push({label:w("Modified"),iso:a.post.modified}),h.length===0)return f.hidden=!0,f;for(const _ of h){const x=document.createElement("div");x.className="os-content-graph__panel-date-row";const E=document.createElement("span");E.className="os-content-graph__panel-section-label",E.textContent=_.label;const T=document.createElement("span");T.className="os-content-graph__panel-date-value",T.textContent=Z(_.iso),x.appendChild(E),x.appendChild(T),f.appendChild(x)}return f},U=a=>{const f=document.createElement("ul");f.className="os-content-graph__panel-stats";for(const h of a){const _=document.createElement("li");_.className="os-content-graph__panel-stat";const x=document.createElement("span");x.className="os-content-graph__panel-stat-num",x.textContent=typeof h.value=="number"?ue(h.value):h.value;const E=document.createElement("span");E.className="os-content-graph__panel-stat-label",E.textContent=h.label,_.appendChild(x),_.appendChild(E),f.appendChild(_)}return f},J=a=>{const f=document.createElement("div");f.className="os-content-graph__panel-actions";{const h=we({label:ee(w("Open in %s"),Ke().siteName?.trim()||w("WordPress")),icon:"dashicons-wordpress",primary:!0});h.addEventListener("click",()=>{mn({entityId:a.post.type==="page"?"pages":"posts",postId:a.post.id,postTitle:H(a.post.title)||`#${a.post.id}`})}),f.appendChild(h)}if(a.post.edit_url){const h=we({label:w("Edit"),icon:"dashicons-edit"});h.addEventListener("click",()=>C(a.post.edit_url,H(a.post.title),"dashicons-admin-post",`post-${a.post.id}`)),f.appendChild(h)}if(a.post.view_url){const h=we({label:w("View"),icon:"dashicons-external"});h.addEventListener("click",()=>C(a.post.view_url,H(a.post.title),"dashicons-admin-post",`post-${a.post.id}`)),f.appendChild(h)}return f},os=a=>{const{user:f,role:h,stats:_,loading:x}=a;p.textContent=_?.profile.name??f.name,b.textContent=w(h==="author"?"Author":"Contributor");const E=document.createElement("div");E.className="os-content-graph__panel-detail-head";const T=_?.profile.avatarUrl||f.avatar;if(T){const I=document.createElement("img");I.className="os-content-graph__panel-detail-avatar os-content-graph__panel-detail-avatar--lg",I.src=T,I.alt="",E.appendChild(I)}const M=document.createElement("div");if(M.className="os-content-graph__panel-detail-handle",M.innerHTML=`<strong>${R(_?.profile.name??f.name)}</strong><span>@${R(f.slug)}</span>`,E.appendChild(M),g.appendChild(E),_?.profile.roleLabels?.length&&g.appendChild(wt(w("Roles"),_.profile.roleLabels)),_?.profile.description&&g.appendChild(Me(w("About"),_.profile.description)),_?.profile.website&&g.appendChild(ls(w("Website"),_.profile.website,_.profile.website)),_){const I=_.counts;g.appendChild(U([{label:w("Posts"),value:I.posts.total},{label:w("Pages"),value:I.pages.total},{label:w("CPT"),value:I.cpt},{label:w("Comments received"),value:I.commentsReceived},{label:w("Comments left"),value:I.commentsLeft}]))}_?.topTerms?.length&&g.appendChild(_t(w("Top topics"),_.topTerms)),_&&g.appendChild(bt([{label:w("First published"),iso:_.milestones.firstPublished},{label:w("Last published"),iso:_.milestones.lastPublished}])),x&&g.appendChild(Re()),g.appendChild(ie({label:w("Open in WordPress"),icon:"dashicons-admin-users",href:f.edit_url,title:f.name,primary:!0,windowKey:`user-${f.id}`}))},is=a=>{const{term:f,stats:h,loading:_}=a;p.textContent=h?.profile.name??f.name,b.textContent=`${h?.profile.taxonomyLabel??f.tax_label} · ${h?.profile.taxonomy??f.taxonomy}`,h?.profile.parentName&&g.appendChild($e([{label:w("Parent"),value:h.profile.parentName}])),h?.profile.description&&g.appendChild(Me(w("Description"),h.profile.description)),h?g.appendChild(U([{label:w("Posts"),value:h.counts.posts.total},{label:w("Comments"),value:h.counts.commentsReceived},{label:w("Authors"),value:h.counts.distinctAuthors}])):g.appendChild(U([{label:w("Posts"),value:f.count}])),h?.topAuthors?.length&&g.appendChild(ds(w("Top authors"),h.topAuthors)),h?.coTerms?.length&&g.appendChild(_t(w("Co-occurring"),h.coTerms.map(x=>({...x,taxonomy:f.taxonomy})))),h&&g.appendChild(bt([{label:w("First post"),iso:h.milestones.firstPosted},{label:w("Latest post"),iso:h.milestones.lastPosted}])),_&&g.appendChild(Re()),g.appendChild(ie({label:w("Open in WordPress"),icon:"dashicons-tag",href:f.edit_url,title:f.name,primary:!0}))},rs=a=>{const{comment:f,stats:h,loading:_}=a,x=h?.author.name??f.author;p.textContent=x||`#${f.id}`,b.textContent=Z(h?.comment.date??f.date);const E=h?.author.avatarUrl;if(E){const I=document.createElement("div");I.className="os-content-graph__panel-detail-head";const V=document.createElement("img");V.className="os-content-graph__panel-detail-avatar os-content-graph__panel-detail-avatar--lg",V.src=E,V.alt="",I.appendChild(V);const B=document.createElement("div");B.className="os-content-graph__panel-detail-handle",B.innerHTML=`<strong>${R(x)}</strong>`+(h?.author.totalApprovedComments?`<span>${ue(h.author.totalApprovedComments)} ${R(w("comments"))}</span>`:""),I.appendChild(B),g.appendChild(I)}const T=h?.comment.status??w("—");g.appendChild(wt(w("Status"),[T],{accent:T==="1"||T==="approved"?"green":"amber"}));const M=h?.comment.rendered;if(M){const I=document.createElement("div");I.className="os-content-graph__panel-detail-section";const V=document.createElement("span");V.className="os-content-graph__panel-section-label",V.textContent=w("Comment"),I.appendChild(V);const B=document.createElement("div");B.className="os-content-graph__panel-detail-html",B.innerHTML=M,I.appendChild(B),g.appendChild(I)}else f.excerpt&&g.appendChild(Me(w("Comment"),f.excerpt));if(h?.parent){const I=document.createElement("blockquote");I.className="os-content-graph__panel-detail-quote",I.innerHTML=`<strong>${R(h.parent.authorName)}</strong><span>${R(h.parent.excerpt)}</span>`,g.appendChild(I)}h?.replies?.length&&g.appendChild(hs(h.replies)),_&&g.appendChild(Re()),g.appendChild(ie({label:w("Open in WordPress"),icon:"dashicons-admin-comments",href:f.edit_url,title:x||w("Comment"),primary:!0}))},as=a=>{if(p.textContent=a.title||`#${a.id}`,b.textContent=a.mime||w("Media"),a.thumb){const f=document.createElement("div");f.className="os-content-graph__panel-detail-thumb";const h=document.createElement("img");h.src=a.thumb,h.alt=a.title||"",f.appendChild(h),g.appendChild(f)}g.appendChild($e([{label:w("Type"),value:a.mime}])),g.appendChild(ie({label:w("Open in WordPress"),icon:"dashicons-admin-media",href:a.edit_url,title:a.title,primary:!0}))},cs=a=>{if(p.textContent=a.author?.name??w("Revision"),b.textContent=Z(a.date),a.author){const f=document.createElement("div");if(f.className="os-content-graph__panel-detail-head",a.author.avatar){const _=document.createElement("img");_.className="os-content-graph__panel-detail-avatar os-content-graph__panel-detail-avatar--lg",_.src=a.author.avatar,_.alt="",f.appendChild(_)}const h=document.createElement("div");h.className="os-content-graph__panel-detail-handle",h.innerHTML=`<strong>${R(a.author.name)}</strong><span>@${R(a.author.slug)}</span>`,f.appendChild(h),g.appendChild(f)}g.appendChild($e([{label:w("Saved"),value:Z(a.date)}])),g.appendChild(ie({label:w("Open revision in WordPress"),icon:"dashicons-backup",href:a.edit_url,title:w("Revision"),primary:!0,windowKey:`revision-${a.id}`}))},Me=(a,f)=>{const h=document.createElement("div");h.className="os-content-graph__panel-detail-section";const _=document.createElement("span");_.className="os-content-graph__panel-section-label",_.textContent=a;const x=document.createElement("p");return x.className="os-content-graph__panel-detail-prose",x.textContent=f,h.appendChild(_),h.appendChild(x),h},wt=(a,f,h={})=>{const _=document.createElement("div");_.className="os-content-graph__panel-detail-section";const x=document.createElement("span");x.className="os-content-graph__panel-section-label",x.textContent=a,_.appendChild(x);const E=document.createElement("div");E.className="os-content-graph__panel-badges";for(const T of f){const M=document.createElement("span");M.className="os-content-graph__panel-badge"+(h.accent?` os-content-graph__panel-badge--${h.accent}`:""),M.textContent=T,E.appendChild(M)}return _.appendChild(E),_},$e=a=>{const f=document.createElement("div");f.className="os-content-graph__panel-inline-meta";for(const h of a){if(!h.value)continue;const _=document.createElement("div");_.className="os-content-graph__panel-inline-meta-row";const x=document.createElement("span");x.className="os-content-graph__panel-section-label",x.textContent=h.label;const E=document.createElement("span");E.className="os-content-graph__panel-date-value",E.textContent=h.value,_.appendChild(x),_.appendChild(E),f.appendChild(_)}return f},ls=(a,f,h)=>{const _=document.createElement("div");_.className="os-content-graph__panel-detail-section";const x=document.createElement("span");x.className="os-content-graph__panel-section-label",x.textContent=a;const E=document.createElement("a");return E.className="os-content-graph__panel-detail-link",E.href=h,E.textContent=f,E.target="_blank",E.rel="noopener noreferrer",_.appendChild(x),_.appendChild(E),_},_t=(a,f)=>{const h=document.createElement("div");h.className="os-content-graph__panel-detail-section";const _=document.createElement("span");_.className="os-content-graph__panel-section-label",_.textContent=a,h.appendChild(_);const x=document.createElement("ul");x.className="os-content-graph__panel-chips";for(const E of f.slice(0,8)){const T=document.createElement("li");T.className="os-content-graph__panel-chip",T.innerHTML=`<span>${R(E.name)}</span><span class="os-content-graph__panel-chip-count">${ue(E.count)}</span>`,x.appendChild(T)}return h.appendChild(x),h},ds=(a,f)=>{const h=document.createElement("div");h.className="os-content-graph__panel-detail-section";const _=document.createElement("span");_.className="os-content-graph__panel-section-label",_.textContent=a,h.appendChild(_);const x=document.createElement("ul");x.className="os-content-graph__panel-author-list";for(const E of f.slice(0,6)){const T=document.createElement("li");T.className="os-content-graph__panel-author-list-row",T.innerHTML=(E.userAvatarUrl?`<img class="os-content-graph__panel-avatar" src="${Ze(E.userAvatarUrl)}" alt="" />`:"")+`<span class="os-content-graph__panel-author-name">${R(E.userName)}</span><span class="os-content-graph__panel-chip-count">${ue(E.count)}</span>`,x.appendChild(T)}return h.appendChild(x),h},bt=a=>{const f=a.filter(E=>E.iso),h=document.createElement("div");if(h.className="os-content-graph__panel-detail-section",f.length===0)return h.hidden=!0,h;const _=document.createElement("span");_.className="os-content-graph__panel-section-label",_.textContent=w("Milestones"),h.appendChild(_);const x=document.createElement("div");x.className="os-content-graph__panel-milestones";for(const E of f){const T=document.createElement("div");T.className="os-content-graph__panel-milestone-row";const M=document.createElement("span");M.className="os-content-graph__panel-milestone-key",M.textContent=E.label;const I=document.createElement("span");I.className="os-content-graph__panel-date-value",I.textContent=Z(E.iso),T.appendChild(M),T.appendChild(I),x.appendChild(T)}return h.appendChild(x),h},hs=a=>{const f=document.createElement("div");f.className="os-content-graph__panel-detail-section";const h=document.createElement("span");h.className="os-content-graph__panel-section-label",h.textContent=ee(xt("Reply (%d)","Replies (%d)",a.length),a.length),f.appendChild(h);const _=document.createElement("ul");_.className="os-content-graph__panel-replies";for(const x of a.slice(0,5)){const E=document.createElement("li");E.className="os-content-graph__panel-reply",E.innerHTML=`<header><strong>${R(x.authorName)}</strong><span>${Z(x.date)}</span></header><p>${R(x.excerpt)}</p>`,_.appendChild(E)}return f.appendChild(_),f},Re=()=>{const a=document.createElement("div");return a.className="os-content-graph__panel-detail-loading",a.innerHTML=`<os-spinner></os-spinner><span>${R(w("Loading details…"))}</span>`,a},ie=a=>{const f=document.createElement("div");if(f.className="os-content-graph__panel-actions",!a.href)return f.hidden=!0,f;const h=we({label:a.label,icon:a.icon,primary:a.primary});return h.addEventListener("click",()=>C(a.href,a.title,a.icon,a.windowKey)),f.appendChild(h),f},we=a=>{const f=document.createElement("button");return f.type="button",f.className="os-content-graph__btn"+(a.primary?" os-content-graph__btn--primary":""),f.innerHTML=`<span class="dashicons ${Ze(a.icon)}" aria-hidden="true"></span><span>${R(a.label)}</span>`,f};return{setLoading:(a,f)=>{n(!0),u.hidden=!0,i={kind:"post"},v=null,p.textContent=f?H(f):`#${a}`,b.textContent=w("Loading…"),y.replaceChildren(),g=S(),y.append(g);const h=document.createElement("div");h.className="os-content-graph__panel-loading",h.innerHTML="<os-spinner></os-spinner>",g.appendChild(h),t.onViewChange?.(null)},setError:a=>{n(!0),u.hidden=!0,i={kind:"post"},v=null,y.replaceChildren(),g=S(),y.append(g);const f=document.createElement("p");f.className="os-content-graph__panel-empty",f.textContent=a,g.appendChild(f),t.onViewChange?.(null)},setDetail:a=>{o=a,i={kind:"post"},L()},showUser:a=>{if(!o)return;const f=o.author?.id===a,h=f?o.author:o.contributors.find(x=>x.id===a);if(!h)return;i={kind:"user",user:h,role:f?"author":"contributor",stats:null,loading:!0},L();const _=++r;cn(e,a).then(x=>{_!==r||i.kind!=="user"||i.user.id!==a||(i={...i,stats:x,loading:!1},L())}).catch(x=>{_!==r||i.kind!=="user"||i.user.id!==a||(i={...i,loading:!1},L(),console.warn("[content-graph] user-stats failed",x))})},showTerm:(a,f)=>{if(!o)return;const h=o.categories.find(x=>x.id===a&&x.taxonomy===f);if(!h)return;i={kind:"term",term:h,stats:null,loading:!0},L();const _=++r;ln(e,f,a).then(x=>{_!==r||i.kind!=="term"||i.term.id!==a||(i={...i,stats:x,loading:!1},L())}).catch(x=>{_!==r||i.kind!=="term"||i.term.id!==a||(i={...i,loading:!1},L(),console.warn("[content-graph] term-stats failed",x))})},showComment:a=>{if(!o)return;const f=o.comments.find(_=>_.id===a);if(!f)return;i={kind:"comment",comment:f,stats:null,loading:!0},L();const h=++r;dn(e,a).then(_=>{h!==r||i.kind!=="comment"||i.comment.id!==a||(i={...i,stats:_,loading:!1},L())}).catch(_=>{h!==r||i.kind!=="comment"||i.comment.id!==a||(i={...i,loading:!1},L(),console.warn("[content-graph] comment-stats failed",_))})},showMedia:a=>{if(!o)return;const f=o.attached_media.find(h=>h.id===a);f&&(i={kind:"media",media:f},L())},showRevision:a=>{if(!o)return;const f=o.revisions.find(h=>h.id===a);f&&(i={kind:"revision",revision:f},L())},hide:()=>{n(!1)},destroy:()=>{s.replaceChildren()}}}function Z(s){if(!s)return"";try{return new Date(s).toLocaleString()}catch{return s}}function ue(s){try{return new Intl.NumberFormat().format(s)}catch{return String(s)}}function R(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ze(s){return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const Qe=Object.freeze({top:0,right:0,bottom:0,left:0});function yn(s,e,t,n){return{left:s,top:e,width:t,height:n,right:s+t,bottom:e+n}}function wn(s,e){const t=o=>Math.min(Math.max(0,e.width),Math.max(0,o)),n=o=>Math.min(Math.max(0,e.height),Math.max(0,o));return{top:n(s.top-e.top),bottom:n(e.bottom-s.bottom),left:t(s.left-e.left),right:t(e.right-s.right)}}const _n="os/work-area";function bn(){return{insets:{...Qe},rect:{x:0,y:0,width:0,height:0},viewport:{x:0,y:0,width:0,height:0},area:{width:0,height:0}}}const Je=be(_n,()=>({snapshot:bn(),installed:!1,areaEl:null}));function xn(s){return{insets:{...s.insets},rect:{...s.rect},viewport:{...s.viewport},area:{...s.area}}}function fe(s){const{installed:e,snapshot:t}=Je.state;if(!e)return{...Qe};const n=t.viewport;return wn(yn(n.x,n.y,n.width,n.height),s.getBoundingClientRect())}function vn(s){return Je.subscribe(e=>{s(xn(e.snapshot))})}function Cn(){return window.PIXI??null}const En=12,Sn=80,Nn=700;function kn(s){return 120+18*s}function et(s=Math.random){const e=s()*Math.PI*2,t=150+s()*250;return{x:Math.cos(e)*t,y:Math.sin(e)*t}}function Tn(s,e=Math.random){if(s<=0)return[];if(s===1)return[{x:0,y:0}];if(s<=En){const c=kn(s),u=[];for(let l=0;l<s;l++){const d=Math.PI+l*Math.PI*2/s;u.push({x:Math.cos(d)*c,y:Math.sin(d)*c})}return u}const t=[];let n=0,o=0;for(let c=0;c<s;c++){const u=et(e);t.push(u),n+=u.x,o+=u.y}const i=n/s,r=o/s;for(const c of t)c.x-=i,c.y-=r;return t}const tt=90;function In(s){return s<=Sn?Nn:tt}function An(s,e,t){if(e.width<=0||e.height<=0)return null;let n=1/0,o=1/0,i=-1/0,r=-1/0;for(const y of s)y.x<n&&(n=y.x),y.y<o&&(o=y.y),y.x>i&&(i=y.x),y.y>r&&(r=y.y);if(n===1/0)return null;const c=i-n+t.padding*2,u=r-o+t.padding*2,l=e.width/c,d=e.height/u,p=Math.max(t.minScale,Math.min(t.maxScale,Math.min(l,d))),b=(n+i)/2,m=(o+r)/2;return{scale:p,x:e.width/2-b*p,y:e.height/2-m*p}}function nt(s){return Math.hypot(s.b.x-s.a.x,s.b.y-s.a.y)}function st(s){return{x:(s.a.x+s.b.x)/2,y:(s.a.y+s.b.y)/2}}function Ln(s,e,t,n){const o=nt(e),i=nt(t),r=o>0&&i>0?i/o:1,c=Math.max(n.min,Math.min(n.max,s.scale*r)),u=st(e),l=st(t),d=(u.x-s.x)/s.scale,p=(u.y-s.y)/s.scale;return{scale:c,x:l.x-d*c,y:l.y-p*c}}const Mn={repulsion:26e3,springK:.04,springLen:200,gravity:.0035,damping:.86},$n=.992,Rn=.01,ot=1,F=12;class On{constructor(e,t,n=Mn){this.dragOrigin=null,this.dragInfluenceRadius=500,this.groupAssignment=null,this.groupOrder=null,this.groupAttractorStrength=.12,this.groupOrderSpacing=320,this.groupOrderStaggerY=0,this.alpha=ot,this.nodes=e,this.edges=t,this.opts=n}reheat(e=ot,t=!0){if(this.alpha=Math.max(this.alpha,e),!t)return;const n=e*3;for(const o of this.nodes)o.pinned||(o.vx+=(Math.random()-.5)*n,o.vy+=(Math.random()-.5)*n)}get isSettled(){return this.alpha<Rn}step(e=1){if(this.isSettled)return;const{repulsion:t,springK:n,springLen:o,gravity:i,damping:r}=this.opts,c=this.nodes,u=c.length;for(let m=0;m<u;m++){const y=c[m];for(let g=m+1;g<u;g++){const v=c[g];let N=y.x-v.x,S=y.y-v.y,k=N*N+S*S;k<.01&&(N=(m-g)*.5,S=(m+g)*.5,k=N*N+S*S);const A=t/k,O=Math.sqrt(k),C=N/O*A,P=S/O*A,L=y.pinned?0:1,z=v.pinned?0:1;y.vx+=C*L,y.vy+=P*L,v.vx-=C*z,v.vy-=P*z}}for(const m of this.edges){const y=m.to.x-m.from.x,g=m.to.y-m.from.y,v=Math.sqrt(y*y+g*g)||1e-4,N=(v-o)*n,S=y/v*N,k=g/v*N;m.from.pinned||(m.from.vx+=S,m.from.vy+=k),m.to.pinned||(m.to.vx-=S,m.to.vy-=k)}this.applyClusterAttractor();const l=this.alpha,d=this.dragOrigin,p=this.dragInfluenceRadius,b=p*p;for(const m of c)if(!m.pinned){m.vx-=m.x*i,m.vy-=m.y*i,m.vx*=r,m.vy*=r,m.vx>F?m.vx=F:m.vx<-F&&(m.vx=-F),m.vy>F?m.vy=F:m.vy<-F&&(m.vy=-F);let y=l;if(d){const g=m.x-d.x,v=m.y-d.y,N=g*g+v*v;if(N>=b)y=0;else{const S=1-Math.sqrt(N)/p;y*=S*S*(3-2*S)}}m.x+=m.vx*y*e,m.y+=m.vy*y*e}this.alpha*=$n}applyClusterAttractor(){const e=this.groupAssignment;if(!e)return;const t=this.groupAttractorStrength;if(t<=0)return;const n=new Map,o=new Map;if(this.groupOrder&&this.groupOrder.length>0){const r=this.groupOrder.length,c=this.groupOrderSpacing,u=this.groupOrderStaggerY;for(let l=0;l<r;l++){const d=this.groupOrder[l];n.set(d,(l-(r-1)/2)*c),u>0&&o.set(d,l%2===0?-u:u)}}const i=new Map;for(const r of this.nodes){const c=e.get(r.id);if(!(!c||c.length===0))for(const u of c){const l=i.get(u);l?(l.sx+=r.x,l.sy+=r.y,l.count++):i.set(u,{sx:r.x,sy:r.y,count:1})}}for(const r of this.nodes){if(r.pinned)continue;const c=e.get(r.id);if(!c||c.length===0)continue;const u=t/c.length;for(const l of c){const d=i.get(l);if(!d||d.count===0)continue;const p=n.has(l)?n.get(l):d.sx/d.count,b=o.has(l)?o.get(l):d.sy/d.count;r.vx+=(p-r.x)*u,r.vy+=(b-r.y)*u}}}setGroupAssignment(e,t=null){this.groupAssignment=e,this.groupOrder=e?t:null,this.reheat(.3,!1)}}const it={user:3829232,term:2926970,comment:15239482,media:10510036,revision:7042949},rt={user:"admin-users",term:"tag",comment:"admin-comments",media:"admin-media",revision:"backup"};function Pn(s){switch(s.taxonomy){case"category":return"category";case"post_tag":return"tag";default:return rt.term}}const Dn={user:{x:0,y:3},term:{x:0,y:3},comment:{x:1,y:4},media:{x:-1,y:1},revision:{x:0,y:3}},me=14;class Fn{constructor(e,t,n,o,i,r){this.pixi=e,this.satelliteParent=t,this.spokeParent=n,this.onClick=o,this.hostEl=i,this.claimPointer=r,this.views=[],this.focused=null,this.rafId=null,this.selectedKey=null,this.linkGfx=new e.Graphics,this.spokeParent.addChild(this.linkGfx),this.layer=new e.Container,this.satelliteParent.addChild(this.layer),this.hoverEl=document.createElement("div"),this.hoverEl.className="os-content-graph__tooltip",this.hoverEl.hidden=!0,this.hostEl.appendChild(this.hoverEl)}clear(){this.linkGfx.clear(),this.layer.removeChildren(),this.views=[],this.focused=null,this.selectedKey=null,this.hideTooltip()}drawLinks(){if(this.linkGfx.clear(),!this.focused||this.views.length===0)return;const e=this.focused.radius+8,t=this.focused.x,n=this.focused.y;for(const o of this.views){const i=o.container.x-t,r=o.container.y-n,c=Math.sqrt(i*i+r*r);if(c<=e)continue;const u=e/c,l=t+i*u,d=n+r*u,p=it[o.ref.kind];this.linkGfx.moveTo(l,d).lineTo(o.container.x,o.container.y).stroke({color:p,width:o.selected?1.8:1.4,alpha:o.selected?.85:.5})}}setFocused(e,t){this.clear(),this.focused=e;const n=this.flattenDetail(t);if(n.length===0)return;const o=e.radius,r=Math.max(o+86,o+70+n.length*36/(2*Math.PI)),c=-Math.PI/2,u=2*Math.PI/n.length;n.forEach((l,d)=>{const p=c+d*u,b=e.x+Math.cos(p)*r,m=e.y+Math.sin(p)*r,y=this.buildSatellite(l,e.x,e.y);y.targetX=b,y.targetY=m,this.views.push(y)}),this.animateIn()}setSelectedKey(e){if(this.selectedKey!==e){this.selectedKey=e;for(const t of this.views){const n=t.key===e;n!==t.selected&&(t.selected=n,this.repaintDisc(t))}this.drawLinks()}}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.clear(),this.layer.destroy({children:!0}),this.linkGfx.destroy(),this.hoverEl.remove()}flattenDetail(e){const t=[];e.author&&t.push({kind:"user",userId:e.author.id,label:e.author.name,meta:w("Author"),avatar:e.author.avatar});for(const n of e.contributors.slice(0,8))t.push({kind:"user",userId:n.id,label:n.name,meta:w("Contributor"),avatar:n.avatar});for(const n of e.categories.slice(0,12))t.push({kind:"term",termId:n.id,taxonomy:n.taxonomy,label:n.name,meta:ee(w("%1$s · %2$d posts"),n.tax_label,n.count)});for(const n of e.comments.slice(0,8))t.push({kind:"comment",commentId:n.id,label:n.author,meta:n.excerpt||ct(n.date)});for(const n of e.attached_media.slice(0,12))t.push({kind:"media",mediaId:n.id,label:n.title,meta:n.mime,thumb:n.thumb});for(const n of e.revisions.slice(0,8))t.push({kind:"revision",revisionId:n.id,parentId:e.post.id,label:n.author?.name??w("Revision"),meta:ct(n.date)});return t}buildSatellite(e,t,n){const o=new this.pixi.Container;o.x=t,o.y=n,o.alpha=0,o.eventMode="static",o.cursor="pointer";const i=me+4;o.hitArea={contains:(k,A)=>k>=-i&&k<=i&&A>=-i&&A<=i+18};const r=new this.pixi.Graphics;o.addChild(r);const c=e.kind==="term"?Pn(e):rt[e.kind],u=xe(c),l=new this.pixi.Text({text:u??"?",style:{fontFamily:u?"dashicons":"sans-serif",fontSize:u?20:13,fill:16777215},resolution:2,anchor:{x:.5,y:.5}}),d=Dn[e.kind];l.x=d?.x??0,l.y=d?.y??0,o.addChild(l);const p=Wn(e.label||"—",28),b=new this.pixi.Graphics;o.addChild(b);const m=new this.pixi.Text({text:p,style:{fill:1711915,fontSize:11,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeight:"500"},resolution:2,anchor:{x:.5,y:0}});m.x=0,m.y=me+2,o.addChild(m);const y=6,g=1,v=m.width+y*2,N=m.height+g*2;b.roundRect(-v/2,m.y-g,v,N,4).fill({color:16777215,alpha:.92}).stroke({color:0,alpha:.08,width:1}),o.on("pointerdown",k=>{k.stopPropagation?.(),this.claimPointer()}),o.on("pointerover",k=>{r.alpha=1;const A=k;this.showTooltip(e,A.global)}),o.on("pointermove",k=>{const A=k;this.showTooltip(e,A.global)}),o.on("pointerout",()=>{r.alpha=.95,this.hideTooltip()}),o.on("pointertap",k=>{k.stopPropagation?.(),this.hideTooltip(),this.setSelectedKey(at(e)),this.onClick(e)}),this.layer.addChild(o);const S={ref:e,key:at(e),container:o,disc:r,icon:l,label:m,targetX:t,targetY:n,selected:!1};return this.repaintDisc(S),S}repaintDisc(e){const t=it[e.ref.kind];e.disc.clear(),e.selected&&e.disc.circle(0,0,me+6).fill({color:t,alpha:.18}),e.disc.circle(0,0,me).fill({color:t,alpha:.95}).stroke({color:16777215,width:e.selected?2.5:1.5,alpha:1})}animateIn(){const e=performance.now(),t=240,n=this.views.map(i=>({x:i.container.x,y:i.container.y})),o=i=>{const r=Math.min(1,(i-e)/t),c=1-Math.pow(1-r,3);for(let u=0;u<this.views.length;u++){const l=this.views[u],d=n[u];l.container.x=d.x+(l.targetX-d.x)*c,l.container.y=d.y+(l.targetY-d.y)*c,l.container.alpha=c}this.drawLinks(),r<1?this.rafId=requestAnimationFrame(o):this.rafId=null};this.rafId=requestAnimationFrame(o)}showTooltip(e,t){this.hoverEl.hidden=!1,this.hoverEl.innerHTML=`<strong>${lt(e.label||"—")}</strong>`+(e.meta?`<span>${lt(e.meta)}</span>`:""),t&&(this.hoverEl.style.left=`${t.x+14}px`,this.hoverEl.style.top=`${t.y+14}px`)}hideTooltip(){this.hoverEl.hidden=!0}}function at(s){switch(s.kind){case"user":return`user:${s.userId}`;case"term":return`term:${s.taxonomy}:${s.termId}`;case"comment":return`comment:${s.commentId}`;case"media":return`media:${s.mediaId}`;case"revision":return`revision:${s.revisionId}`}}function Wn(s,e){return s.length<=e?s:s.slice(0,e-1).trimEnd()+"…"}function ct(s){if(!s)return"";try{return new Date(s).toLocaleString()}catch{return s}}function lt(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Ne=4937059,dt=2911205,Vn=5213171,Gn=10135222,Hn=2911205,ke=Math.min((typeof window<"u"&&window.devicePixelRatio||1)*1.5,3),Te=[3829232,2926970,15239482,10510036,3122616,13914255,7042949],ht=16777215,zn=1.3,Un=0,Bn={"admin-post":{x:.06,y:.06}},Yn={category:"#2c6be5",tag:"#2ca97a",author:"#7c3aed",year:"#ea580c",year_month:"#ea580c"},Ie=.15,pt=4,qn={padding:100,minScale:Ie,maxScale:1.5},Xn=8e-4,ut=300,Kn=.18,Ae=.001,ft=24;class jn{constructor(e,t,n,o,i="disc"){this.groupLabelOverlay=null,this.satellites=null,this.nodeViews=new Map,this.edgeViews=[],this.groupViews=new Map,this.currentGrouping=null,this.groupCatalogs={authors:{},categories:{},tags:{}},this.groupingTween=null,this.fitFollowActive=!1,this.fitFollowStartedAt=0,this.fitFollowSawMotion=!1,this.fitFollowMaxDurationMs=3e3,this.fitFollowVelocityThreshold=1,this.nodes=[],this.edges=[],this.sim=null,this.focusedId=null,this.hoveredId=null,this.pressedNode=null,this.dragOffset={x:0,y:0},this.isPanning=!1,this.panStart={x:0,y:0,wx:0,wy:0},this.nodeClickActive=!1,this.pointers=new Map,this.pinchUntil=0,this.destroyed=!1,this.tickerCb=null,this.resizeObserver=null,this.fitInsets={top:0,right:0,bottom:0,left:0},this.unsubscribeWorkArea=null,this.lastResizeWidth=0,this.lastResizeHeight=0,this.fitPending=!1,this.targetScale=1,this.targetX=0,this.targetY=0,this.postTypeColor=new Map,this.nodeStyle="disc",this.host=e,this.callbacks=t,this.onSatelliteClick=n,this.nodeStyle=i;const r=new Map;this.postTypeBySlug=new Map;for(const c of o)r.set(c.slug,Zn(c.icon)),this.postTypeBySlug.set(c.slug,c);o.forEach((c,u)=>{this.postTypeColor.set(c.slug,Te[u%Te.length])}),this.postTypeIcon=c=>r.get(c)??Jn(c)}async mount(e){typeof e.loadModules=="function"&&await e.loadModules(["pixijs"]);const t=Cn();if(!t)throw new Error("PIXI namespace missing after loadModules.");if(this.pixi=t,typeof document<"u"&&document.fonts)try{await document.fonts.load("16px dashicons")}catch{}const n=new t.Application;await n.init({resizeTo:this.host,backgroundAlpha:0,antialias:!0,autoDensity:!0,resolution:ke,sharedTicker:!1}),this.app=n,this.host.appendChild(n.canvas),n.canvas.classList.add("os-content-graph__canvas"),this.world=new t.Container,this.world.x=this.host.clientWidth/2,this.world.y=this.host.clientHeight/2,this.world.scale.set(1),this.targetX=this.world.x,this.targetY=this.world.y,this.targetScale=1,n.stage.addChild(this.world),this.edgeLayer=new t.Container,this.spokeLayer=new t.Container,this.nodeLayer=new t.Container,this.labelLayer=new t.Container,this.world.addChild(this.edgeLayer,this.spokeLayer,this.nodeLayer,this.labelLayer),this.groupLabelOverlay=document.createElement("div"),this.groupLabelOverlay.className="os-content-graph__group-labels",this.host.appendChild(this.groupLabelOverlay),n.canvas.addEventListener("webglcontextlost",r=>{r.preventDefault();try{this.app?.ticker?.stop()}catch{}},!1);const o=n.renderer,i=o.render.bind(o);o.render=(...r)=>{try{return i(...r)}catch(c){try{this.app?.ticker?.stop()}catch{}console.warn("[content-graph] Pixi render threw, stopping ticker:",c);return}},this.satellites=new Fn(t,this.world,this.spokeLayer,this.onSatelliteClick,this.host,()=>{this.nodeClickActive=!0}),this.bindStageInput(n.canvas),this.bindResize(),this.tickerCb=r=>this.tick(r.deltaTime),n.ticker.add(this.tickerCb)}setData(e){const t=new Map;for(const l of this.nodes)t.set(l.id,l);this.groupCatalogs=e.groups??{authors:{},categories:{},tags:{}};const n=e.nodes.every(l=>!t.has(l.id)),o=n?Tn(e.nodes.length):null,i=e.nodes.map((l,d)=>{const p=t.get(l.id),b=o?o[d]:et();return{...l,x:p?.x??b.x,y:p?.y??b.y,vx:0,vy:0,pinned:!1,radius:4,color:Ne,degree:0}}),r=new Map;for(const l of i)r.set(l.id,l);const c=[];for(const l of e.edges){const d=r.get(l.from),p=r.get(l.to);!d||!p||(d.degree++,p.degree++,c.push({from:d,to:p}))}for(const l of i)l.radius=8+Math.min(8,Math.sqrt(l.degree)*2.4);this.nodes=i,this.edges=c,this.rebuildSprites(),this.sim=new On(i,c),this.sim.reheat(.12,!1);const u=n?In(i.length):tt;for(let l=0;l<u&&!this.sim.isSettled;l++)this.sim.step(1);this.currentGrouping&&this.setGrouping(this.currentGrouping)}rebuildSprites(){this.edgeLayer.removeChildren(),this.nodeLayer.removeChildren(),this.labelLayer.removeChildren(),this.nodeViews.clear(),this.edgeViews=[];for(const e of this.edges){const t=new this.pixi.Graphics;this.edgeLayer.addChild(t),this.edgeViews.push({edge:e,gfx:t})}for(const e of this.nodes){const t=new this.pixi.Container;t.eventMode="static",t.cursor="pointer",t.hitArea=new this.pixi.Circle(0,0,Math.max(18,e.radius+8)),this.bindNodeInput(t,e),this.nodeLayer.addChild(t);const n=new this.pixi.Graphics;t.addChild(n);const o=new this.pixi.Graphics;t.addChild(o);const i=this.postTypeIcon(e.type),r=xe(i),c=new this.pixi.Text({text:r??"●",style:{fontFamily:r?"dashicons":"sans-serif",fontSize:2*e.radius,fill:Ne},resolution:ke,anchor:{x:.5,y:.5}});t.addChild(c);const u=new this.pixi.Container;this.labelLayer.addChild(u);const l=new this.pixi.Graphics;u.addChild(l);const d=new this.pixi.Text({text:this.truncate(H(e.title)||`#${e.id}`,32),style:{fill:2042167,fontSize:11,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeight:"500"},resolution:ke,anchor:{x:.5,y:0}});u.addChild(d);const p=5,b=1,m=d.width+p*2,y=d.height+b*2;l.roundRect(-m/2,-b,m,y,4).fill({color:16777215,alpha:.78}).stroke({color:0,alpha:.06,width:1}),this.nodeViews.set(e.id,{node:e,container:t,halo:n,disc:o,icon:c,labelBox:u,labelBg:l,label:d,iconCharCode:r,iconName:i,typeColor:this.postTypeColor.get(e.type)??Te[0],discKey:""})}}truncate(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}bindNodeInput(e,t){let n={x:0,y:0},o=!1;const i=36;e.on("pointerdown",r=>{const c=r;c.stopPropagation?.(),n={x:c.global.x,y:c.global.y},this.nodeClickActive=!0,this.pressedNode=t,o=!1,t.pinned=!0,t.vx=0,t.vy=0}),e.on("pointerover",()=>{this.hoveredId=t.id,this.draw()}),e.on("pointerout",()=>{this.hoveredId===t.id&&(this.hoveredId=null,this.draw())}),e.on("pointerup",r=>{const c=r,u=c.global.x-n.x,l=c.global.y-n.y;!o&&u*u+l*l<=256&&!this.pinchRecent()&&this.callbacks.onNodeClick?.(t),t.pinned=this.focusedId===t.id,this.pressedNode=null,this.sim&&(this.sim.dragOrigin=null,o&&this.sim.reheat(.35,!1)),o=!1}),e.on("pointerupoutside",()=>{t.pinned=this.focusedId===t.id,this.pressedNode=null,this.sim&&(this.sim.dragOrigin=null),o=!1}),e.on("globalpointermove",r=>{if(this.pressedNode!==t)return;const c=r,u=c.global.x-n.x,l=c.global.y-n.y,d=u*u+l*l;if(!o){if(d<i)return;o=!0;const b=this.toWorld(c.global.x,c.global.y);this.dragOffset={x:t.x-b.x,y:t.y-b.y},this.sim&&(this.sim.dragOrigin={x:t.x,y:t.y},this.sim.reheat(.3,!1))}const p=this.toWorld(c.global.x,c.global.y);t.x=p.x+this.dragOffset.x,t.y=p.y+this.dragOffset.y,t.vx=0,t.vy=0,this.sim&&(this.sim.dragOrigin={x:t.x,y:t.y})})}pinchRecent(){return this.pointers.size>=2||performance.now()<this.pinchUntil}canvasPoint(e,t){const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}bindStageInput(e){e.style.touchAction="none",e.addEventListener("wheel",n=>{n.preventDefault();const o=Math.exp(-n.deltaY*Xn),i=Math.max(Ie,Math.min(pt,this.targetScale*o)),r=e.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,l=(c-this.targetX)/this.targetScale,d=(u-this.targetY)/this.targetScale;this.targetScale=i,this.targetX=c-l*i,this.targetY=u-d*i},{passive:!1}),e.addEventListener("pointerdown",n=>{if(this.pointers.set(n.pointerId,this.canvasPoint(e,n)),this.pointers.size===2){this.isPanning=!1,this.nodeClickActive=!1,this.pressedNode&&(this.pressedNode.pinned=this.focusedId===this.pressedNode.id,this.pressedNode=null,this.sim&&(this.sim.dragOrigin=null));return}n.target===e&&(this.nodeClickActive||this.pointers.size>1||(this.isPanning=!0,this.panStart={x:n.clientX,y:n.clientY,wx:this.world.x,wy:this.world.y}))}),window.addEventListener("pointermove",n=>{if(this.pointers.has(n.pointerId)){const r=this.pointers.get(n.pointerId),c=this.canvasPoint(e,n);if(this.pointers.set(n.pointerId,c),this.pointers.size===2){this.pinch(n.pointerId,r);return}}if(!this.isPanning||this.nodeClickActive||this.pointers.size>1)return;const o=this.panStart.wx+(n.clientX-this.panStart.x),i=this.panStart.wy+(n.clientY-this.panStart.y);this.world.x=o,this.world.y=i,this.targetX=o,this.targetY=i});const t=n=>{const o=this.pointers.size>=2;this.pointers.delete(n.pointerId),o&&(this.isPanning=!1,this.pinchUntil=performance.now()+ut)};window.addEventListener("pointercancel",t),window.addEventListener("pointerup",n=>{t(n);const o=this.nodeClickActive;if(this.nodeClickActive=!1,!this.isPanning)return;const i=n.clientX-this.panStart.x,r=n.clientY-this.panStart.y;this.isPanning=!1,!o&&!this.pinchRecent()&&i*i+r*r<9&&this.callbacks.onBackgroundClick?.()})}pinch(e,t){let n=null,o=null;for(const[r,c]of this.pointers)r===e?o=c:n=c;if(!o||!n)return;const i=Ln({scale:this.world.scale.x,x:this.world.x,y:this.world.y},{a:t,b:n},{a:o,b:n},{min:Ie,max:pt});this.world.scale.set(i.scale),this.world.x=i.x,this.world.y=i.y,this.targetScale=i.scale,this.targetX=i.x,this.targetY=i.y,this.pinchUntil=performance.now()+ut}bindResize(){this.lastResizeWidth=this.host.clientWidth,this.lastResizeHeight=this.host.clientHeight,this.resizeObserver=new ResizeObserver(()=>{if(this.destroyed)return;const e=this.host.clientWidth,t=this.host.clientHeight;if(this.fitInsets=fe(this.host),e<=0||t<=0)return;try{this.app.renderer.resize(e,t)}catch{return}try{this.app.render()}catch{}this.fitPending&&this.fitToView();const n=Math.abs(e-this.lastResizeWidth),o=Math.abs(t-this.lastResizeHeight);(n>=ft||o>=ft)&&(this.lastResizeWidth=e,this.lastResizeHeight=t)}),this.resizeObserver.observe(this.host),this.unsubscribeWorkArea=vn(()=>{this.destroyed||(this.fitInsets=fe(this.host))})}toWorld(e,t){const n=this.app.canvas.getBoundingClientRect(),o=e-n.left,i=t-n.top;return{x:(o-this.world.x)/this.world.scale.x,y:(i-this.world.y)/this.world.scale.y}}tick(e){if(this.destroyed||!this.app||!this.world)return;this.groupingTween?this.advanceGroupingTween():this.sim?.step(e);const t=1-Math.pow(1-Kn,e),n=this.targetScale-this.world.scale.x;Math.abs(n)<Ae?this.world.scale.set(this.targetScale):this.world.scale.set(this.world.scale.x+n*t);const o=this.targetX-this.world.x,i=this.targetY-this.world.y;Math.abs(o)<Ae?this.world.x=this.targetX:this.world.x+=o*t,Math.abs(i)<Ae?this.world.y=this.targetY:this.world.y+=i*t,this.draw(),this.drawGroupLabels(),this.satellites?.drawLinks(),this.advanceFitFollow()}advanceFitFollow(){if(!this.fitFollowActive)return;if(performance.now()-this.fitFollowStartedAt>this.fitFollowMaxDurationMs){this.fitFollowActive=!1;return}if(this.groupingTween)return;let e=0;for(const t of this.nodes){if(t.pinned)continue;const n=Math.hypot(t.vx,t.vy);n>e&&(e=n)}e>=this.fitFollowVelocityThreshold?(this.fitFollowSawMotion=!0,this.fitToView(!1)):this.fitFollowSawMotion&&(this.fitFollowActive=!1)}postTypeSupportsTaxonomy(e,t){return this.postTypeBySlug.get(e)?.taxonomies?.[t]??!1}postTypeLabel(e){return this.postTypeBySlug.get(e)?.label??e}deriveGroupKeys(e,t){switch(t){case"category":return this.postTypeSupportsTaxonomy(e.type,"category")?e.category_ids.length===0?["cat:uncat"]:e.category_ids.map(n=>`cat:${n}`):[`cat:type_${e.type}`];case"tag":return this.postTypeSupportsTaxonomy(e.type,"post_tag")?e.tag_ids.length===0?["tag:untagged"]:e.tag_ids.map(n=>`tag:${n}`):[`tag:type_${e.type}`];case"author":{const n=e.author_id||0,o=`author:${n}`,i=[o,o],r=Array.isArray(e.contributor_ids)?e.contributor_ids:[];for(const c of r)c>0&&c!==n&&i.push(`author:${c}`);return i}case"year":return[`year:${e.year||0}`];case"year_month":return[`ym:${e.year_month||"unknown"}`]}}labelForGroupKey(e){const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);switch(n){case"cat":{if(o==="uncat")return w("Uncategorized");if(o.startsWith("type_"))return this.postTypeLabel(o.slice(5));const i=Number(o);return this.groupCatalogs.categories[i]?.name??`#${i}`}case"tag":{if(o==="untagged")return w("Untagged");if(o.startsWith("type_"))return this.postTypeLabel(o.slice(5));const i=Number(o);return this.groupCatalogs.tags[i]?.name??`#${i}`}case"author":{const i=Number(o);return i<=0?w("Unknown author"):this.groupCatalogs.authors[i]?.name??`#${i}`}case"year":{const i=Number(o);return i<=0?w("Undated"):String(i)}case"ym":return o==="unknown"||o===""?w("Undated"):Qn(o)}return e}buildGroupViews(e,t){if(!this.groupLabelOverlay)return;const n=Yn[t];for(const[o,i]of e){if(i.length===0)continue;const r=`${this.labelForGroupKey(o)} (${i.length})`,c=document.createElement("div");c.className="os-content-graph__group-label",c.textContent=r,c.style.setProperty("--os-ui-cg-cluster-color",n),this.groupLabelOverlay.appendChild(c),this.groupViews.set(o,{key:o,label:r,el:c,members:i})}}clearGroupViews(){for(const e of this.groupViews.values())e.el.remove();this.groupViews.clear()}drawGroupLabels(){if(this.destroyed||this.groupViews.size===0)return;const e=1-Le(1.2,2.4,this.world.scale.x),t=this.world.scale.x,n=this.world.x,o=this.world.y;for(const i of this.groupViews.values()){let r=0,c=0,u=0;for(const p of i.members){const b=this.nodeViews.get(p)?.node;b&&(r+=b.x,c+=b.y,u++)}if(u===0||e<=.02){i.el.style.display="none";continue}const l=n+r/u*t,d=o+c/u*t;i.el.style.display="",i.el.style.transform=`translate(${l}px, ${d}px) translate(-50%, -50%)`,i.el.style.opacity=String(e)}}draw(){if(this.destroyed)return;const e=this.focusedId,t=this.hoveredId,n=new Set;if(e!==null){for(const d of this.edges)d.from.id===e&&n.add(d.to.id),d.to.id===e&&n.add(d.from.id);n.add(e)}const o=e!==null,r=.2+Le(.45,1.1,this.world.scale.x)*.35;for(const d of this.edgeViews){const{edge:p,gfx:b}=d;b.clear();const m=e!==null&&(p.from.id===e||p.to.id===e),y=t!==null&&(p.from.id===t||p.to.id===t);let g;o?g=m?.85:0:y?g=.7:g=r;const v=m||y?Hn:Gn,N=m||y?1.2:.7;let S=p.from.x,k=p.from.y,A=p.to.x,O=p.to.y;if(e!==null){if(p.from.id===e){const C=mt(p.from.x,p.from.y,p.to.x,p.to.y,p.from.radius+8);S=C.x,k=C.y}if(p.to.id===e){const C=mt(p.to.x,p.to.y,p.from.x,p.from.y,p.to.radius+8);A=C.x,O=C.y}}b.moveTo(S,k).lineTo(A,O).stroke({color:v,width:N,alpha:g})}const c=1/this.world.scale.x,u=Le(.55,.95,this.world.scale.x),l=this.nodeStyle==="disc";for(const d of this.nodeViews.values()){const{node:p,container:b,halo:m,disc:y,icon:g,labelBox:v}=d,N=p.id===e,S=p.id===t,k=e!==null&&n.has(p.id),A=e===null||k,O=A?1:.25;b.x=p.x,b.y=p.y,b.alpha=O;let C=Ne;N?C=dt:k&&(C=Vn);const P=N?dt:d.typeColor;m.clear(),(N||S)&&m.circle(0,0,p.radius+8).fill({color:l?P:C,alpha:.18});const L=N?p.radius*zn:p.radius,z=N||S?2.5:1.5,ye=l?`${P}|${L}|${z}`:"off";d.discKey!==ye&&(d.discKey=ye,y.clear(),l&&y.circle(0,0,L).fill({color:P,alpha:.95}).stroke({color:ht,width:z,alpha:1})),g.visible=!l||N||S,g.style.fill=l?ht:C;const oe=l?L*1.35:2*p.radius;g.style.fontSize=oe;const U=Bn[d.iconName];g.x=(U?.x??0)*oe,g.y=(U?.y??Un)*oe,v.x=p.x,v.y=p.y+(l?L:p.radius)+4,v.scale.set(c);let J;N?J=1:A?J=.92:J=.32,v.alpha=J*u,v.visible=v.alpha>.01}}focusNode(e){if(this.focusedId!==null){const n=this.nodeViews.get(this.focusedId);n&&(n.node.pinned=!1)}this.focusedId=e;const t=this.nodeViews.get(e);if(t){t.node.pinned=!0,t.node.vx=0,t.node.vy=0;const n=t.node,o=Math.max(this.targetScale,1.6);this.targetScale=o,this.targetX=this.host.clientWidth/2-n.x*o,this.targetY=this.host.clientHeight/2-n.y*o}this.draw()}setFocusedDetail(e){if(!this.satellites)return;if(!e||this.focusedId===null){this.satellites.clear();return}const t=this.nodeViews.get(this.focusedId)?.node;if(!t){this.satellites.clear();return}this.satellites.setFocused(t,e)}setGrouping(e){if(this.currentGrouping=e,this.clearGroupViews(),!e||!this.sim){this.sim?.setGroupAssignment(null);return}const t=new Map,n=new Map;for(const r of this.nodes){const c=this.deriveGroupKeys(r,e);t.set(r.id,c);const u=new Set;for(const l of c){if(u.has(l))continue;u.add(l);const d=n.get(l);d?d.push(r.id):n.set(l,[r.id])}}const o=this.chronologicalOrder(e,n);this.sim.groupOrderStaggerY=e==="year_month"?160:0,this.sim.setGroupAssignment(t,o);const i=this.buildGroupSeedTargets(t,n,o);this.startGroupingTween(i),this.fitToViewOfTargets(i),this.buildGroupViews(n,e),this.fitFollowActive=!0,this.fitFollowStartedAt=performance.now(),this.fitFollowSawMotion=!1}advanceGroupingTween(){if(this.destroyed)return;const e=this.groupingTween;if(!e)return;const t=Math.min(1,(performance.now()-e.startTime)/e.duration),n=1-Math.pow(1-t,3);for(const[o,i]of e.starts){const r=e.targets.get(o);if(!r)continue;const c=this.nodeViews.get(o)?.node;!c||c.pinned||(c.x=i.x+(r.x-i.x)*n,c.y=i.y+(r.y-i.y)*n,c.vx=0,c.vy=0)}t>=1&&(this.groupingTween=null,this.sim?.reheat(.18,!1))}buildGroupSeedTargets(e,t,n){const o=new Map;if(!this.sim)return o;const i=Array.from(t.keys()),r=new Map,c=this.sim.groupOrderSpacing;if(n&&n.length>0){const l=n.length,d=this.sim.groupOrderStaggerY,p=m=>d<=0?0:m%2===0?-d:d;for(let m=0;m<l;m++)r.set(n[m],{x:(m-(l-1)/2)*c,y:p(m)});let b=l;for(const m of i)r.has(m)||(r.set(m,{x:(b-(l-1)/2)*c,y:p(b)}),b++)}else{const l=i.length,d=Math.max(220,120+l*40);for(let p=0;p<l;p++){const b=p/Math.max(1,l)*Math.PI*2-Math.PI/2;r.set(i[p],{x:Math.cos(b)*d,y:Math.sin(b)*d})}}const u=40;for(const l of this.nodes){if(l.pinned)continue;const d=e.get(l.id);if(!d||d.length===0)continue;let p=0,b=0,m=0;for(const y of d){const g=r.get(y);g&&(p+=g.x,b+=g.y,m++)}m!==0&&o.set(l.id,{x:p/m+(Math.random()-.5)*u,y:b/m+(Math.random()-.5)*u})}return o}startGroupingTween(e){if(e.size===0){this.groupingTween=null;return}const t=new Map;for(const n of e.keys()){const o=this.nodeViews.get(n)?.node;o&&t.set(n,{x:o.x,y:o.y})}this.groupingTween={startTime:performance.now(),duration:450,starts:t,targets:e}}fitToViewOfTargets(e){e.size!==0&&(this.fitInsets=fe(this.host),this.frame(e.values()))}frame(e){const t=this.fitInsets,n=An(e,{width:this.host.clientWidth-t.left-t.right,height:this.host.clientHeight-t.top-t.bottom},qn);if(!n){this.fitPending=!0;return}this.fitPending=!1,this.targetScale=n.scale,this.targetX=t.left+n.x,this.targetY=t.top+n.y}chronologicalOrder(e,t){if(e!=="year"&&e!=="year_month")return null;const n=[];for(const o of t.keys()){const i=o.indexOf(":"),r=o.slice(i+1);if(e==="year"){const c=Number(r);if(!Number.isFinite(c)||c<=0)continue;n.push({key:o,sort:String(c).padStart(6,"0")})}else{if(r==="unknown"||r==="")continue;n.push({key:o,sort:r})}}return n.sort((o,i)=>o.sort<i.sort?-1:o.sort>i.sort?1:0),n.map(o=>o.key)}clearFocus(){if(this.focusedId!==null){const e=this.nodeViews.get(this.focusedId);e&&(e.node.pinned=!1)}this.focusedId=null,this.satellites?.clear(),this.sim?.reheat(.25,!1),this.draw()}setSatelliteSelectedKey(e){this.satellites?.setSelectedKey(e)}getNode(e){return this.nodes.find(t=>t.id===e)}getNodes(){return this.nodes}setNodeStyle(e){if(this.nodeStyle!==e){this.nodeStyle=e;for(const t of this.nodeViews.values())t.discKey=""}}getNodeStyle(){return this.nodeStyle}getFocusedId(){return this.focusedId}fitToView(e=!0){this.nodes.length!==0&&(e&&(this.fitInsets=fe(this.host)),this.frame(this.nodes))}destroy(){this.destroyed=!0;try{this.app?.ticker?.stop()}catch{}if(this.tickerCb){try{this.app?.ticker?.remove(this.tickerCb)}catch{}this.tickerCb=null}this.resizeObserver?.disconnect(),this.resizeObserver=null,this.unsubscribeWorkArea?.(),this.unsubscribeWorkArea=null,this.satellites?.destroy(),this.satellites=null,this.clearGroupViews(),this.groupLabelOverlay?.remove(),this.groupLabelOverlay=null;try{this.app.destroy({removeView:!0},{children:!0})}catch{}}}function Zn(s){return typeof s!="string"||s===""||s.startsWith("http://")||s.startsWith("https://")?"admin-generic":s.replace(/^dashicons-/,"")}function mt(s,e,t,n,o){const i=t-s,r=n-e,c=Math.sqrt(i*i+r*r);if(c===0)return{x:s,y:e};const u=Math.min(o/c,1);return{x:s+i*u,y:e+r*u}}function Le(s,e,t){if(t<=s)return 0;if(t>=e)return 1;const n=(t-s)/(e-s);return n*n*(3-2*n)}function Qn(s){const e=/^(\d{4})-(\d{2})$/.exec(s);if(!e)return s;const t=Number(e[2])-1;if(t<0||t>11)return s;const n=Number(e[1]);try{const o=new Date(Date.UTC(n,t,1));return new Intl.DateTimeFormat(void 0,{month:"short",year:"numeric",timeZone:"UTC"}).format(o)}catch{return s}}function Jn(s){switch(s){case"post":return"admin-post";case"page":return"admin-page";case"attachment":return"admin-media";default:return"admin-generic"}}const gt="desktop-mode-content-graph",yt="desktop-mode/corkboard-node-style",ge=new Set;let Q=es();function es(){try{return window.localStorage.getItem(yt)==="icon"?"icon":"disc"}catch{return"disc"}}function ts(s){try{window.localStorage.setItem(yt,s)}catch{}}Tt({id:"desktop-mode/corkboard-pins",label:w("Show pins"),checkable:!0,checked:()=>Q==="icon",isVisible:s=>(s.config.baseId??s.id)===gt,onSelect:()=>{Q=Q==="icon"?"disc":"icon",ts(Q);for(const s of ge)s.setNodeStyle(Q)}});async function ns(s){const e=s.querySelector("[data-os-content-graph-root]");if(!e)return s.textContent=w("Corkboard container missing."),{abort:()=>{}};const t=Ke(),n=e.querySelector("[data-os-content-graph-toolbar]"),o=e.querySelector("[data-os-content-graph-stage]"),i=e.querySelector("[data-os-content-graph-panel]"),r=e.querySelector("[data-os-content-graph-loading]"),c=window.wp?.os??{};let u=t.postTypes.map(C=>C.slug),l=t.postTypes,d=null,p=0,b=!1;const m=Qt(r),y=jt(o),g=gn(i,t,{onClose:()=>{g.hide(),d?.clearFocus()},onViewChange:C=>{d?.setSatelliteSelectedKey(C)}}),v=C=>{switch(C.kind){case"user":g.showUser(C.userId);break;case"term":g.showTerm(C.termId,C.taxonomy);break;case"comment":g.showComment(C.commentId);break;case"media":g.showMedia(C.mediaId);break;case"revision":g.showRevision(C.revisionId);break}},N=C=>{d?.focusNode(C.id),g.setLoading(C.id,C.title);const P=++p;(async()=>{try{const L=await an(t,C.id);if(b||P!==p)return;g.setDetail(L),d?.setFocusedDetail(L)}catch(L){if(b||P!==p)return;g.setError(ee(w("Could not load post #%d."),C.id)),console.warn("[content-graph] detail fetch failed",L)}})()},S=()=>({onTypesChange:C=>{u=C,A()},onFitToView:()=>d?.fitToView(),onSearchSelect:C=>N(C),onGroupChange:C=>{d?.setGrouping(C),y.setSuppressed(C!==null)},getNodes:()=>d?.getNodes()??[]}),k=hn(n,t.postTypes,S()),A=async()=>{if(!b){m.show(),k.setStatus(w("Loading graph…"));try{const C=await rn(t,u);if(b)return;d?.setData(C),k.setStatus(ee(w("%1$d nodes · %2$d links"),C.stats.nodes,C.stats.edges)),y.set(Xt({nodes:C.stats.nodes,edges:C.stats.edges,types:l,activeTypes:u})),d?.fitToView(),d?.clearFocus(),g.hide()}catch(C){if(b)return;y.set({kind:"none"}),k.setStatus(w("Failed to load graph.")),console.warn("[content-graph] graph fetch failed",C)}finally{m.hide()}}},O=()=>{p++,g.hide(),d?.clearFocus()};d=new jn(o,{onNodeClick:C=>{if(d?.getFocusedId()===C.id){O();return}N(C)},onBackgroundClick:O},v,t.postTypes,Q),ge.add(d);try{await d.mount(c)}catch(C){return o.textContent=w("Could not initialise the graph renderer."),console.warn("[content-graph] scene mount failed",C),ge.delete(d),{abort:()=>{}}}return(async()=>{try{const C=await on(t);if(b)return;l=C,k.updateCounts(C)}catch{}await A()})(),{abort:()=>{b=!0,m.destroy(),y.destroy(),k.destroy(),g.destroy(),d&&(ge.delete(d),d.destroy()),d=null}}}const ss=window.openStationNativeWindows??(window.openStationNativeWindows={});ss[gt]=async s=>(await ns(s)).abort})();
19 + `}};oe.props=["icon","heading","description"],oe.styles=[Xt],oe.help=void 0;let Ee=oe;Ue("os-empty-state",Ee);function Kt(s){if(s.nodes>0)return s.edges>0?{kind:"none"}:{kind:"no-threads"};if(s.activeTypes.length===0&&s.types.length>0)return{kind:"all-off"};const e=new Set(s.activeTypes),t=s.types.some(o=>typeof o.count=="number");let n=0;for(const o of s.types)e.has(o.slug)||(n+=t?o.count??0:1);return n>0?{kind:"filtered-out"}:{kind:"no-content"}}const jt="os-content-graph__empty",Se="os-content-graph__hint";function Zt(s){let e=null,t="none",n={kind:"none"},o=!1;const i=()=>{e?.remove(),e=null,t="none"},r=(l,p,b)=>{const g=document.createElement("os-empty-state");return g.className=jt,g.setAttribute("icon",l),g.setAttribute("heading",p),g.setAttribute("description",b),g},c=(l,p)=>{const b=document.createElement("div");b.className=Se,b.setAttribute("role","note");const g=document.createElement("strong");g.className=`${Se}-title`,g.textContent=l;const _=document.createElement("p");return _.className=`${Se}-body`,_.textContent=p,b.append(g,_),b},u=l=>{switch(l.kind){case"none":return null;case"no-content":return r("admin-post",y("Nothing on the board yet"),y("Publish a post or a page and it is pinned here. Threads are drawn between posts when one links to another."));case"filtered-out":return r("filter",y("Nothing to show for these types"),y("The post types switched on in the toolbar have no content yet. Switch another one on to see its posts."));case"all-off":return r("filter",y("Every post type is switched off"),y("Switch a type back on in the toolbar to see its posts."));case"no-threads":return c(y("No threads yet"),y("A thread joins two posts when one links to the other. Click a node to see its author, terms, comments, media and revisions, or group the board by category, tag, author, year or month from the toolbar."))}},d=()=>{const l=o&&n.kind==="no-threads"?{kind:"none"}:n;if(l.kind===t)return;i();const p=u(l);p&&(s.appendChild(p),e=p,t=l.kind)};return{set:l=>{n=l,d()},setSuppressed:l=>{o=l,d()},destroy:i}}const Qt=400,Y="os-content-graph__loading--visible";function Jt(s,e=Qt){let t=null;const n=()=>{t!==null&&(clearTimeout(t),t=null)};return s&&(s.hidden=!1,s.classList.remove(Y)),{show:()=>{!s||t!==null||s.classList.contains(Y)||(t=setTimeout(()=>{t=null,s.classList.add(Y)},e))},hide:()=>{n(),s?.classList.remove(Y)},destroy:()=>{n(),s?.classList.remove(Y)},isVisible:()=>!!s?.classList.contains(Y)}}const en="http://localhost/";function Ne(s,e){const t=typeof window<"u"&&window.location?window.location.href:en,n=new URL(s,t),o=e.replace(/^\/+/,""),i=o.indexOf("?"),r=i===-1?o:o.slice(0,i),c=i===-1?"":o.slice(i+1);if(n.searchParams.has("rest_route")){const u=n.searchParams.get("rest_route")??"/",d=u.endsWith("/")?u:u+"/";n.searchParams.set("rest_route",d+r)}else{const u=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=u+r}return c&&new URLSearchParams(c).forEach((d,l)=>{n.searchParams.append(l,d)}),n.toString()}const Ke="X-WP-Nonce";function tn(s,e){const t=nn();if(!t)return e;const n=sn(s);if(!n||!on(n))return e;const o=e?.headers??(typeof Request<"u"&&s instanceof Request?s.headers:void 0),i=new Headers(o??{});return i.has(Ke)?e:(i.set(Ke,t),{...e??{},headers:i})}function nn(){if(typeof window>"u")return;const e=window.openStationConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function sn(s){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof s=="string"?new URL(s,e):s instanceof URL?s:typeof Request<"u"&&s instanceof Request?new URL(s.url,e):null}catch{return null}}function on(s){return typeof window>"u"||!window.location||s.origin!==window.location.origin?!1:!!(s.pathname.includes("/wp-json/")||s.searchParams.has("rest_route"))}function q(s,e,t={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(s,e,t);const o=tn(s,e);return fetch(s,o)}class rn extends Error{constructor(e,t){super(e||t.serverMessage||`HTTP ${t.status}`),this.name="RestError",this.status=t.status,this.code=t.code,this.data=t.data,this.serverMessage=t.serverMessage??""}}function an(s){const e=typeof s=="object"&&s!==null?s:void 0;return{code:typeof e?.code=="string"?e.code:void 0,data:e?.data,serverMessage:typeof e?.message=="string"?e.message:""}}function cn(s,e,t=""){return new rn(t,{status:s,...an(e)})}async function X(s,e=""){let t=null;try{t=await s.json()}catch{t=null}return cn(s.status,t,e)}const G="desktop-mode-content-graph",K="desktop-mode/content-graph";function je(){const e=(window.openStationWindowConfig??{})[G];if(!e)throw new Error("Corkboard config missing — openstation_register_window args lost in transit.");return e}function j(s){return{Accept:"application/json","X-WP-Nonce":s.restNonce}}async function ln(s){const e=await q(`${s.apiBase}/post-types`,{headers:j(s)},{source:K,windowId:G});if(!e.ok)throw await X(e,`post-types: ${e.status}`);return await e.json()}async function dn(s,e){const t=new URL(`${s.apiBase}/nodes`);t.searchParams.set("types",e.join(","));const n=await q(t.toString(),{headers:j(s)},{source:K,windowId:G});if(!n.ok)throw await X(n,`nodes: ${n.status}`);return await n.json()}async function hn(s,e){const t=await q(`${s.apiBase}/post/${e}`,{headers:j(s)},{source:K,windowId:G});if(!t.ok)throw await X(t,`post/${e}: ${t.status}`);return await t.json()}async function pn(s,e){const t=await q(Ne(s.restRoot,`desktop-mode/v1/user-stats/${e}`),{headers:j(s)},{source:K,windowId:G});if(!t.ok)throw await X(t,`user-stats/${e}: ${t.status}`);return await t.json()}async function un(s,e,t){const n=await q(Ne(s.restRoot,`desktop-mode/v1/term-stats/${encodeURIComponent(e)}/${t}`),{headers:j(s)},{source:K,windowId:G});if(!n.ok)throw await X(n,`term-stats/${e}/${t}: ${n.status}`);return await n.json()}async function fn(s,e){const t=await q(Ne(s.restRoot,`desktop-mode/v1/comment-stats/${e}`),{headers:j(s)},{source:K,windowId:G});if(!t.ok)throw await X(t,`comment-stats/${e}: ${t.status}`);return await t.json()}const pe="none";function mn(s,e,t){s.replaceChildren();const n=new Set(e.map(m=>m.slug)),o=document.createElement("div");o.className="os-content-graph__filters",o.setAttribute("role","group"),o.setAttribute("aria-label",y("Show post types")),s.appendChild(o);for(const m of e){const v=document.createElement("button");v.type="button",v.className="os-content-graph__chip",v.setAttribute("aria-pressed","true"),v.dataset.slug=m.slug,v.innerHTML=`<span class="dashicons ${Ze(m.icon)}" aria-hidden="true"></span><span class="os-content-graph__chip-label">${ue(m.label)}</span><span class="os-content-graph__chip-count">${m.count}</span>`,v.addEventListener("click",()=>{n.has(m.slug)?n.delete(m.slug):n.add(m.slug),v.setAttribute("aria-pressed",String(n.has(m.slug))),t.onTypesChange(Array.from(n))}),o.appendChild(v)}const i=document.createElement("div");i.className="os-content-graph__search";const r=document.createElement("os-text-field");r.setAttribute("type","search"),r.setAttribute("label",y("Search posts and pages in the graph")),r.setAttribute("hide-label",""),r.setAttribute("clearable",""),r.setAttribute("placeholder",y("Search nodes…")),i.appendChild(r);const c=document.createElement("ul");c.className="os-content-graph__search-results",c.hidden=!0,i.appendChild(c),s.appendChild(i);const u=()=>r.value??"",d=()=>{const m=u().trim().toLowerCase();if(m.length===0){c.hidden=!0,c.replaceChildren();return}const v=t.getNodes().filter(E=>E.title.toLowerCase().includes(m)).slice(0,10);c.replaceChildren();for(const E of v){const k=document.createElement("li"),N=document.createElement("button");N.type="button",N.className="os-content-graph__search-result",N.innerHTML=`<span class="os-content-graph__search-title">${ue(E.title||"#"+E.id)}</span><span class="os-content-graph__search-type">${ue(E.type)}</span>`,N.addEventListener("click",()=>{r.value="",c.hidden=!0,c.replaceChildren(),t.onSearchSelect(E)}),k.appendChild(N),c.appendChild(k)}c.hidden=v.length===0};r.addEventListener("os-input-change",d),r.addEventListener("focusin",d),r.addEventListener("focusout",()=>{setTimeout(()=>{c.hidden=!0},120)});const l=document.createElement("os-select");l.className="os-content-graph__group-by",l.setAttribute("value",pe),l.setAttribute("aria-label",y("Group by")),l.title=y("Group posts by a shared facet");for(const[m,v]of[[pe,y("No grouping")],["category",y("Group by category")],["tag",y("Group by tag")],["author",y("Group by author")],["year",y("Group by year")],["year_month",y("Group by year-month")]]){const E=document.createElement("os-option");E.setAttribute("value",m),E.textContent=v,l.appendChild(E)}l.addEventListener("os-pick",m=>{const E=m.detail?.value??pe,k=E===pe?null:E;t.onGroupChange(k)}),s.insertBefore(l,i);const p=document.createElement("div");p.className="os-content-graph__actions";const b=document.createElement("os-button");b.setAttribute("variant","ghost"),b.innerHTML=`<span class="dashicons dashicons-editor-expand" aria-hidden="true"></span><span>${ue(y("Fit"))}</span>`,b.title=y("Fit graph to view"),b.addEventListener("click",()=>t.onFitToView()),p.appendChild(b);const g=document.createElement("span");g.className="os-content-graph__toolbar-status",g.setAttribute("role","status"),p.appendChild(g),s.appendChild(p);const _=m=>{i.contains(m.target)||(c.hidden=!0)};return document.addEventListener("click",_),{setStatus:m=>{g.textContent=m},updateCounts:m=>{for(const v of m){const E=o.querySelector(`.os-content-graph__chip[data-slug="${Ze(v.slug)}"] .os-content-graph__chip-count`);E&&(E.textContent=String(v.count??0))}},destroy:()=>{document.removeEventListener("click",_)}}}function ue(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ze(s){return s.replace(/[^a-zA-Z0-9 _\-]/g,"")}const gn="my-wordpress",Z=xe("desktop-mode/my-wordpress/open-target",()=>({kind:null,entityId:"",id:0,title:"",requestedAt:0}));function yn(s){Z.state.kind=s.kind,Z.state.entityId=s.entityId,Z.state.id=s.id,Z.state.title=s.title,Z.state.requestedAt=Date.now(),Z.notify()}function wn(s){const e=window.wp?.os?.openWindow;e?.(gn,{source:s})}function bn(s){const e=Number(s.postId);!Number.isFinite(e)||e<=0||(yn({kind:"detail",entityId:s.entityId||"posts",id:e,title:s.postTitle??""}),wn("my-wordpress/open-detail"))}function H(s){const e=document.createElement("textarea");return e.innerHTML=s,e.value}function _n(s,e,t){s.replaceChildren(),s.hidden=!1,s.classList.add("os-content-graph__panel--closed");const n=a=>{s.classList.toggle("os-content-graph__panel--closed",!a)};let o=null,i={kind:"post"},r=0;const c=document.createElement("div");c.className="os-content-graph__panel-frame";const u=document.createElement("nav");u.className="os-content-graph__panel-breadcrumb",u.hidden=!0;const d=document.createElement("header");d.className="os-content-graph__panel-head";const l=document.createElement("div");l.className="os-content-graph__panel-title-wrap";const p=document.createElement("h2");p.className="os-content-graph__panel-title";const b=document.createElement("p");b.className="os-content-graph__panel-meta",l.appendChild(p),l.appendChild(b);const g=document.createElement("button");g.type="button",g.className="os-content-graph__panel-close",g.innerHTML='<span class="dashicons dashicons-no-alt" aria-hidden="true"></span>',g.title=y("Close panel"),g.addEventListener("click",()=>t.onClose()),d.appendChild(l),d.appendChild(g);const _=document.createElement("div");_.className="os-content-graph__panel-body",c.appendChild(u),c.appendChild(d),c.appendChild(_),s.appendChild(c);let m=k();_.append(m);let v=null,E=0;function k(){const a=document.createElement("div");return a.className="os-content-graph__panel-page",a}const N=(a,f,h)=>{if(_.append(f),a===f||h==="none"){a!==f&&a.remove();return}const w=h==="forward"?"page-from-right":"page-from-left",x=h==="forward"?"page-to-left":"page-to-right";f.classList.add(`os-content-graph__${w}`),f.offsetWidth;const S=++E;requestAnimationFrame(()=>{S===E&&(f.classList.remove(`os-content-graph__${w}`),a.classList.add(`os-content-graph__${x}`))});let A=!1;const M=()=>{A||(A=!0,a.removeEventListener("transitionend",M),a.remove())};a.addEventListener("transitionend",M),setTimeout(M,360)},I=a=>{switch(a.kind){case"post":return null;case"user":return`user:${a.user.id}`;case"term":return`term:${a.term.taxonomy}:${a.term.id}`;case"comment":return`comment:${a.comment.id}`;case"media":return`media:${a.media.id}`;case"revision":return`revision:${a.revision.id}`}},O=()=>(window.wp??{}).os??{},C=(a,f,h,w)=>{const x=O();if(!x.windowManager||!x.deriveWindowId||!a){a&&(window.location.href=a);return}const S=x.windowManager.getFocused?.();S?.isFullscreen?.()&&S.toggleFullscreen?.();let A=x.deriveWindowId(a);w&&(A=`${A}-${w}`),x.windowManager.open({id:A,baseId:A,url:a,title:f,icon:h})},P=()=>{if(u.replaceChildren(),i.kind==="post"||!o){u.hidden=!0;return}u.hidden=!1;const a=document.createElement("button");a.type="button",a.className="os-content-graph__panel-breadcrumb-back";const f=document.createElement("span");f.className="dashicons dashicons-arrow-left-alt2 os-content-graph__panel-breadcrumb-arrow",f.setAttribute("aria-hidden","true");const h=document.createElement("span");h.className="os-content-graph__panel-breadcrumb-label",h.textContent=H(o.post.title)||`#${o.post.id}`,a.appendChild(f),a.appendChild(h),a.title=y("Back to post"),a.addEventListener("click",()=>{i={kind:"post"},L()}),u.appendChild(a)},L=()=>{n(!0),P();const a=k(),f=m;switch(m=a,i.kind){case"post":z(o);break;case"user":cs(i);break;case"term":ls(i);break;case"comment":ds(i);break;case"media":hs(i.media);break;case"revision":ps(i.revision);break}let h="none";v!==null&&v!==i.kind&&(i.kind==="post"?h="back":h="forward"),N(f,a,h),t.onViewChange?.(I(i)),v=i.kind},z=a=>{if(!a){p.textContent="",b.textContent="";return}p.textContent=H(a.post.title)||`#${a.post.id}`,b.textContent=`${a.post.type} · ${a.post.status}`,m.appendChild(we(a)),m.appendChild(ie(a)),m.appendChild(U([{label:y("Contributors"),value:a.contributors.length},{label:y("Comments"),value:a.comments.length},{label:y("Taxonomies"),value:a.categories.length},{label:y("Media"),value:a.attached_media.length},{label:y("Revisions"),value:a.revisions.length}])),m.appendChild(ee(a))},we=a=>{const f=document.createElement("div");if(f.className="os-content-graph__panel-author",!a.author)return f.hidden=!0,f;const h=document.createElement("span");h.className="os-content-graph__panel-section-label",h.textContent=y("Author"),f.appendChild(h);const w=document.createElement("div");if(w.className="os-content-graph__panel-author-row",a.author.avatar){const S=document.createElement("img");S.className="os-content-graph__panel-avatar",S.src=a.author.avatar,S.alt="",w.appendChild(S)}const x=document.createElement("span");return x.className="os-content-graph__panel-author-name",x.textContent=a.author.name,w.appendChild(x),f.appendChild(w),f},ie=a=>{const f=document.createElement("div");f.className="os-content-graph__panel-dates";const h=[];if(a.post.date&&h.push({label:y("Published"),iso:a.post.date}),a.post.modified&&a.post.modified!==a.post.date&&h.push({label:y("Modified"),iso:a.post.modified}),h.length===0)return f.hidden=!0,f;for(const w of h){const x=document.createElement("div");x.className="os-content-graph__panel-date-row";const S=document.createElement("span");S.className="os-content-graph__panel-section-label",S.textContent=w.label;const A=document.createElement("span");A.className="os-content-graph__panel-date-value",A.textContent=Q(w.iso),x.appendChild(S),x.appendChild(A),f.appendChild(x)}return f},U=a=>{const f=document.createElement("ul");f.className="os-content-graph__panel-stats";for(const h of a){const w=document.createElement("li");w.className="os-content-graph__panel-stat";const x=document.createElement("span");x.className="os-content-graph__panel-stat-num",x.textContent=typeof h.value=="number"?fe(h.value):h.value;const S=document.createElement("span");S.className="os-content-graph__panel-stat-label",S.textContent=h.label,w.appendChild(x),w.appendChild(S),f.appendChild(w)}return f},ee=a=>{const f=document.createElement("div");f.className="os-content-graph__panel-actions";{const h=be({label:te(y("Open in %s"),je().siteName?.trim()||y("WordPress")),icon:"dashicons-wordpress",primary:!0});h.addEventListener("click",()=>{bn({entityId:a.post.type==="page"?"pages":"posts",postId:a.post.id,postTitle:H(a.post.title)||`#${a.post.id}`})}),f.appendChild(h)}if(a.post.edit_url){const h=be({label:y("Edit"),icon:"dashicons-edit"});h.addEventListener("click",()=>C(a.post.edit_url,H(a.post.title),"dashicons-admin-post",`post-${a.post.id}`)),f.appendChild(h)}if(a.post.view_url){const h=be({label:y("View"),icon:"dashicons-external"});h.addEventListener("click",()=>C(a.post.view_url,H(a.post.title),"dashicons-admin-post",`post-${a.post.id}`)),f.appendChild(h)}return f},cs=a=>{const{user:f,role:h,stats:w,loading:x}=a;p.textContent=w?.profile.name??f.name,b.textContent=y(h==="author"?"Author":"Contributor");const S=document.createElement("div");S.className="os-content-graph__panel-detail-head";const A=w?.profile.avatarUrl||f.avatar;if(A){const T=document.createElement("img");T.className="os-content-graph__panel-detail-avatar os-content-graph__panel-detail-avatar--lg",T.src=A,T.alt="",S.appendChild(T)}const M=document.createElement("div");if(M.className="os-content-graph__panel-detail-handle",M.innerHTML=`<strong>${R(w?.profile.name??f.name)}</strong><span>@${R(f.slug)}</span>`,S.appendChild(M),m.appendChild(S),w?.profile.roleLabels?.length&&m.appendChild(bt(y("Roles"),w.profile.roleLabels)),w?.profile.description&&m.appendChild($e(y("About"),w.profile.description)),w?.profile.website&&m.appendChild(us(y("Website"),w.profile.website,w.profile.website)),w){const T=w.counts;m.appendChild(U([{label:y("Posts"),value:T.posts.total},{label:y("Pages"),value:T.pages.total},{label:y("CPT"),value:T.cpt},{label:y("Comments received"),value:T.commentsReceived},{label:y("Comments left"),value:T.commentsLeft}]))}w?.topTerms?.length&&m.appendChild(_t(y("Top topics"),w.topTerms)),w&&m.appendChild(xt([{label:y("First published"),iso:w.milestones.firstPublished},{label:y("Last published"),iso:w.milestones.lastPublished}])),x&&m.appendChild(Oe()),m.appendChild(re({label:y("Open in WordPress"),icon:"dashicons-admin-users",href:f.edit_url,title:f.name,primary:!0,windowKey:`user-${f.id}`}))},ls=a=>{const{term:f,stats:h,loading:w}=a;p.textContent=h?.profile.name??f.name,b.textContent=`${h?.profile.taxonomyLabel??f.tax_label} · ${h?.profile.taxonomy??f.taxonomy}`,h?.profile.parentName&&m.appendChild(Re([{label:y("Parent"),value:h.profile.parentName}])),h?.profile.description&&m.appendChild($e(y("Description"),h.profile.description)),h?m.appendChild(U([{label:y("Posts"),value:h.counts.posts.total},{label:y("Comments"),value:h.counts.commentsReceived},{label:y("Authors"),value:h.counts.distinctAuthors}])):m.appendChild(U([{label:y("Posts"),value:f.count}])),h?.topAuthors?.length&&m.appendChild(fs(y("Top authors"),h.topAuthors)),h?.coTerms?.length&&m.appendChild(_t(y("Co-occurring"),h.coTerms.map(x=>({...x,taxonomy:f.taxonomy})))),h&&m.appendChild(xt([{label:y("First post"),iso:h.milestones.firstPosted},{label:y("Latest post"),iso:h.milestones.lastPosted}])),w&&m.appendChild(Oe()),m.appendChild(re({label:y("Open in WordPress"),icon:"dashicons-tag",href:f.edit_url,title:f.name,primary:!0}))},ds=a=>{const{comment:f,stats:h,loading:w}=a,x=h?.author.name??f.author;p.textContent=x||`#${f.id}`,b.textContent=Q(h?.comment.date??f.date);const S=h?.author.avatarUrl;if(S){const T=document.createElement("div");T.className="os-content-graph__panel-detail-head";const V=document.createElement("img");V.className="os-content-graph__panel-detail-avatar os-content-graph__panel-detail-avatar--lg",V.src=S,V.alt="",T.appendChild(V);const B=document.createElement("div");B.className="os-content-graph__panel-detail-handle",B.innerHTML=`<strong>${R(x)}</strong>`+(h?.author.totalApprovedComments?`<span>${fe(h.author.totalApprovedComments)} ${R(y("comments"))}</span>`:""),T.appendChild(B),m.appendChild(T)}const A=h?.comment.status??y("—");m.appendChild(bt(y("Status"),[A],{accent:A==="1"||A==="approved"?"green":"amber"}));const M=h?.comment.rendered;if(M){const T=document.createElement("div");T.className="os-content-graph__panel-detail-section";const V=document.createElement("span");V.className="os-content-graph__panel-section-label",V.textContent=y("Comment"),T.appendChild(V);const B=document.createElement("div");B.className="os-content-graph__panel-detail-html",B.innerHTML=M,T.appendChild(B),m.appendChild(T)}else f.excerpt&&m.appendChild($e(y("Comment"),f.excerpt));if(h?.parent){const T=document.createElement("blockquote");T.className="os-content-graph__panel-detail-quote",T.innerHTML=`<strong>${R(h.parent.authorName)}</strong><span>${R(h.parent.excerpt)}</span>`,m.appendChild(T)}h?.replies?.length&&m.appendChild(ms(h.replies)),w&&m.appendChild(Oe()),m.appendChild(re({label:y("Open in WordPress"),icon:"dashicons-admin-comments",href:f.edit_url,title:x||y("Comment"),primary:!0}))},hs=a=>{if(p.textContent=a.title||`#${a.id}`,b.textContent=a.mime||y("Media"),a.thumb){const f=document.createElement("div");f.className="os-content-graph__panel-detail-thumb";const h=document.createElement("img");h.src=a.thumb,h.alt=a.title||"",f.appendChild(h),m.appendChild(f)}m.appendChild(Re([{label:y("Type"),value:a.mime}])),m.appendChild(re({label:y("Open in WordPress"),icon:"dashicons-admin-media",href:a.edit_url,title:a.title,primary:!0}))},ps=a=>{if(p.textContent=a.author?.name??y("Revision"),b.textContent=Q(a.date),a.author){const f=document.createElement("div");if(f.className="os-content-graph__panel-detail-head",a.author.avatar){const w=document.createElement("img");w.className="os-content-graph__panel-detail-avatar os-content-graph__panel-detail-avatar--lg",w.src=a.author.avatar,w.alt="",f.appendChild(w)}const h=document.createElement("div");h.className="os-content-graph__panel-detail-handle",h.innerHTML=`<strong>${R(a.author.name)}</strong><span>@${R(a.author.slug)}</span>`,f.appendChild(h),m.appendChild(f)}m.appendChild(Re([{label:y("Saved"),value:Q(a.date)}])),m.appendChild(re({label:y("Open revision in WordPress"),icon:"dashicons-backup",href:a.edit_url,title:y("Revision"),primary:!0,windowKey:`revision-${a.id}`}))},$e=(a,f)=>{const h=document.createElement("div");h.className="os-content-graph__panel-detail-section";const w=document.createElement("span");w.className="os-content-graph__panel-section-label",w.textContent=a;const x=document.createElement("p");return x.className="os-content-graph__panel-detail-prose",x.textContent=f,h.appendChild(w),h.appendChild(x),h},bt=(a,f,h={})=>{const w=document.createElement("div");w.className="os-content-graph__panel-detail-section";const x=document.createElement("span");x.className="os-content-graph__panel-section-label",x.textContent=a,w.appendChild(x);const S=document.createElement("div");S.className="os-content-graph__panel-badges";for(const A of f){const M=document.createElement("span");M.className="os-content-graph__panel-badge"+(h.accent?` os-content-graph__panel-badge--${h.accent}`:""),M.textContent=A,S.appendChild(M)}return w.appendChild(S),w},Re=a=>{const f=document.createElement("div");f.className="os-content-graph__panel-inline-meta";for(const h of a){if(!h.value)continue;const w=document.createElement("div");w.className="os-content-graph__panel-inline-meta-row";const x=document.createElement("span");x.className="os-content-graph__panel-section-label",x.textContent=h.label;const S=document.createElement("span");S.className="os-content-graph__panel-date-value",S.textContent=h.value,w.appendChild(x),w.appendChild(S),f.appendChild(w)}return f},us=(a,f,h)=>{const w=document.createElement("div");w.className="os-content-graph__panel-detail-section";const x=document.createElement("span");x.className="os-content-graph__panel-section-label",x.textContent=a;const S=document.createElement("a");return S.className="os-content-graph__panel-detail-link",S.href=h,S.textContent=f,S.target="_blank",S.rel="noopener noreferrer",w.appendChild(x),w.appendChild(S),w},_t=(a,f)=>{const h=document.createElement("div");h.className="os-content-graph__panel-detail-section";const w=document.createElement("span");w.className="os-content-graph__panel-section-label",w.textContent=a,h.appendChild(w);const x=document.createElement("ul");x.className="os-content-graph__panel-chips";for(const S of f.slice(0,8)){const A=document.createElement("li");A.className="os-content-graph__panel-chip",A.innerHTML=`<span>${R(S.name)}</span><span class="os-content-graph__panel-chip-count">${fe(S.count)}</span>`,x.appendChild(A)}return h.appendChild(x),h},fs=(a,f)=>{const h=document.createElement("div");h.className="os-content-graph__panel-detail-section";const w=document.createElement("span");w.className="os-content-graph__panel-section-label",w.textContent=a,h.appendChild(w);const x=document.createElement("ul");x.className="os-content-graph__panel-author-list";for(const S of f.slice(0,6)){const A=document.createElement("li");A.className="os-content-graph__panel-author-list-row",A.innerHTML=(S.userAvatarUrl?`<img class="os-content-graph__panel-avatar" src="${Qe(S.userAvatarUrl)}" alt="" />`:"")+`<span class="os-content-graph__panel-author-name">${R(S.userName)}</span><span class="os-content-graph__panel-chip-count">${fe(S.count)}</span>`,x.appendChild(A)}return h.appendChild(x),h},xt=a=>{const f=a.filter(S=>S.iso),h=document.createElement("div");if(h.className="os-content-graph__panel-detail-section",f.length===0)return h.hidden=!0,h;const w=document.createElement("span");w.className="os-content-graph__panel-section-label",w.textContent=y("Milestones"),h.appendChild(w);const x=document.createElement("div");x.className="os-content-graph__panel-milestones";for(const S of f){const A=document.createElement("div");A.className="os-content-graph__panel-milestone-row";const M=document.createElement("span");M.className="os-content-graph__panel-milestone-key",M.textContent=S.label;const T=document.createElement("span");T.className="os-content-graph__panel-date-value",T.textContent=Q(S.iso),A.appendChild(M),A.appendChild(T),x.appendChild(A)}return h.appendChild(x),h},ms=a=>{const f=document.createElement("div");f.className="os-content-graph__panel-detail-section";const h=document.createElement("span");h.className="os-content-graph__panel-section-label",h.textContent=te(vt("Reply (%d)","Replies (%d)",a.length),a.length),f.appendChild(h);const w=document.createElement("ul");w.className="os-content-graph__panel-replies";for(const x of a.slice(0,5)){const S=document.createElement("li");S.className="os-content-graph__panel-reply",S.innerHTML=`<header><strong>${R(x.authorName)}</strong><span>${Q(x.date)}</span></header><p>${R(x.excerpt)}</p>`,w.appendChild(S)}return f.appendChild(w),f},Oe=()=>{const a=document.createElement("div");return a.className="os-content-graph__panel-detail-loading",a.innerHTML=`<os-spinner></os-spinner><span>${R(y("Loading details…"))}</span>`,a},re=a=>{const f=document.createElement("div");if(f.className="os-content-graph__panel-actions",!a.href)return f.hidden=!0,f;const h=be({label:a.label,icon:a.icon,primary:a.primary});return h.addEventListener("click",()=>C(a.href,a.title,a.icon,a.windowKey)),f.appendChild(h),f},be=a=>{const f=document.createElement("button");return f.type="button",f.className="os-content-graph__btn"+(a.primary?" os-content-graph__btn--primary":""),f.innerHTML=`<span class="dashicons ${Qe(a.icon)}" aria-hidden="true"></span><span>${R(a.label)}</span>`,f};return{setLoading:(a,f)=>{n(!0),u.hidden=!0,i={kind:"post"},v=null,p.textContent=f?H(f):`#${a}`,b.textContent=y("Loading…"),_.replaceChildren(),m=k(),_.append(m);const h=document.createElement("div");h.className="os-content-graph__panel-loading",h.innerHTML="<os-spinner></os-spinner>",m.appendChild(h),t.onViewChange?.(null)},setError:a=>{n(!0),u.hidden=!0,i={kind:"post"},v=null,_.replaceChildren(),m=k(),_.append(m);const f=document.createElement("p");f.className="os-content-graph__panel-empty",f.textContent=a,m.appendChild(f),t.onViewChange?.(null)},setDetail:a=>{o=a,i={kind:"post"},L()},showUser:a=>{if(!o)return;const f=o.author?.id===a,h=f?o.author:o.contributors.find(x=>x.id===a);if(!h)return;i={kind:"user",user:h,role:f?"author":"contributor",stats:null,loading:!0},L();const w=++r;pn(e,a).then(x=>{w!==r||i.kind!=="user"||i.user.id!==a||(i={...i,stats:x,loading:!1},L())}).catch(x=>{w!==r||i.kind!=="user"||i.user.id!==a||(i={...i,loading:!1},L(),console.warn("[content-graph] user-stats failed",x))})},showTerm:(a,f)=>{if(!o)return;const h=o.categories.find(x=>x.id===a&&x.taxonomy===f);if(!h)return;i={kind:"term",term:h,stats:null,loading:!0},L();const w=++r;un(e,f,a).then(x=>{w!==r||i.kind!=="term"||i.term.id!==a||(i={...i,stats:x,loading:!1},L())}).catch(x=>{w!==r||i.kind!=="term"||i.term.id!==a||(i={...i,loading:!1},L(),console.warn("[content-graph] term-stats failed",x))})},showComment:a=>{if(!o)return;const f=o.comments.find(w=>w.id===a);if(!f)return;i={kind:"comment",comment:f,stats:null,loading:!0},L();const h=++r;fn(e,a).then(w=>{h!==r||i.kind!=="comment"||i.comment.id!==a||(i={...i,stats:w,loading:!1},L())}).catch(w=>{h!==r||i.kind!=="comment"||i.comment.id!==a||(i={...i,loading:!1},L(),console.warn("[content-graph] comment-stats failed",w))})},showMedia:a=>{if(!o)return;const f=o.attached_media.find(h=>h.id===a);f&&(i={kind:"media",media:f},L())},showRevision:a=>{if(!o)return;const f=o.revisions.find(h=>h.id===a);f&&(i={kind:"revision",revision:f},L())},hide:()=>{n(!1)},destroy:()=>{s.replaceChildren()}}}function Q(s){if(!s)return"";try{return new Date(s).toLocaleString()}catch{return s}}function fe(s){try{return new Intl.NumberFormat().format(s)}catch{return String(s)}}function R(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Qe(s){return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const Je=Object.freeze({top:0,right:0,bottom:0,left:0});function xn(s,e,t,n){return{left:s,top:e,width:t,height:n,right:s+t,bottom:e+n}}function vn(s,e){const t=o=>Math.min(Math.max(0,e.width),Math.max(0,o)),n=o=>Math.min(Math.max(0,e.height),Math.max(0,o));return{top:n(s.top-e.top),bottom:n(e.bottom-s.bottom),left:t(s.left-e.left),right:t(e.right-s.right)}}const Cn="os/work-area";function En(){return{insets:{...Je},rect:{x:0,y:0,width:0,height:0},viewport:{x:0,y:0,width:0,height:0},area:{width:0,height:0}}}const et=xe(Cn,()=>({snapshot:En(),installed:!1,areaEl:null}));function Sn(s){return{insets:{...s.insets},rect:{...s.rect},viewport:{...s.viewport},area:{...s.area}}}function me(s){const{installed:e,snapshot:t}=et.state;if(!e)return{...Je};const n=t.viewport;return vn(xn(n.x,n.y,n.width,n.height),s.getBoundingClientRect())}function Nn(s){return et.subscribe(e=>{s(Sn(e.snapshot))})}function kn(){return window.PIXI??null}const An=12,Tn=80,In=700;function Ln(s){return 120+18*s}function tt(s=Math.random){const e=s()*Math.PI*2,t=150+s()*250;return{x:Math.cos(e)*t,y:Math.sin(e)*t}}function Mn(s,e=Math.random){if(s<=0)return[];if(s===1)return[{x:0,y:0}];if(s<=An){const c=Ln(s),u=[];for(let d=0;d<s;d++){const l=Math.PI+d*Math.PI*2/s;u.push({x:Math.cos(l)*c,y:Math.sin(l)*c})}return u}const t=[];let n=0,o=0;for(let c=0;c<s;c++){const u=tt(e);t.push(u),n+=u.x,o+=u.y}const i=n/s,r=o/s;for(const c of t)c.x-=i,c.y-=r;return t}const nt=90;function $n(s){return s<=Tn?In:nt}function Rn(s,e,t){if(e.width<=0||e.height<=0)return null;let n=1/0,o=1/0,i=-1/0,r=-1/0;for(const _ of s)_.x<n&&(n=_.x),_.y<o&&(o=_.y),_.x>i&&(i=_.x),_.y>r&&(r=_.y);if(n===1/0)return null;const c=i-n+t.padding*2,u=r-o+t.padding*2,d=e.width/c,l=e.height/u,p=Math.max(t.minScale,Math.min(t.maxScale,Math.min(d,l))),b=(n+i)/2,g=(o+r)/2;return{scale:p,x:e.width/2-b*p,y:e.height/2-g*p}}function st(s){return Math.hypot(s.b.x-s.a.x,s.b.y-s.a.y)}function ot(s){return{x:(s.a.x+s.b.x)/2,y:(s.a.y+s.b.y)/2}}function On(s,e,t,n){const o=st(e),i=st(t),r=o>0&&i>0?i/o:1,c=Math.max(n.min,Math.min(n.max,s.scale*r)),u=ot(e),d=ot(t),l=(u.x-s.x)/s.scale,p=(u.y-s.y)/s.scale;return{scale:c,x:d.x-l*c,y:d.y-p*c}}const Pn={repulsion:26e3,springK:.04,springLen:200,gravity:.0035,damping:.86},Dn=.992,Fn=.01,it=1,F=12;class Wn{constructor(e,t,n=Pn){this.dragOrigin=null,this.dragInfluenceRadius=500,this.groupAssignment=null,this.groupOrder=null,this.groupAttractorStrength=.12,this.groupOrderSpacing=320,this.groupOrderStaggerY=0,this.alpha=it,this.nodes=e,this.edges=t,this.opts=n}reheat(e=it,t=!0){if(this.alpha=Math.max(this.alpha,e),!t)return;const n=e*3;for(const o of this.nodes)o.pinned||(o.vx+=(Math.random()-.5)*n,o.vy+=(Math.random()-.5)*n)}get isSettled(){return this.alpha<Fn}step(e=1){if(this.isSettled)return;const{repulsion:t,springK:n,springLen:o,gravity:i,damping:r}=this.opts,c=this.nodes,u=c.length;for(let g=0;g<u;g++){const _=c[g];for(let m=g+1;m<u;m++){const v=c[m];let E=_.x-v.x,k=_.y-v.y,N=E*E+k*k;N<.01&&(E=(g-m)*.5,k=(g+m)*.5,N=E*E+k*k);const I=t/N,O=Math.sqrt(N),C=E/O*I,P=k/O*I,L=_.pinned?0:1,z=v.pinned?0:1;_.vx+=C*L,_.vy+=P*L,v.vx-=C*z,v.vy-=P*z}}for(const g of this.edges){const _=g.to.x-g.from.x,m=g.to.y-g.from.y,v=Math.sqrt(_*_+m*m)||1e-4,E=(v-o)*n,k=_/v*E,N=m/v*E;g.from.pinned||(g.from.vx+=k,g.from.vy+=N),g.to.pinned||(g.to.vx-=k,g.to.vy-=N)}this.applyClusterAttractor();const d=this.alpha,l=this.dragOrigin,p=this.dragInfluenceRadius,b=p*p;for(const g of c)if(!g.pinned){g.vx-=g.x*i,g.vy-=g.y*i,g.vx*=r,g.vy*=r,g.vx>F?g.vx=F:g.vx<-F&&(g.vx=-F),g.vy>F?g.vy=F:g.vy<-F&&(g.vy=-F);let _=d;if(l){const m=g.x-l.x,v=g.y-l.y,E=m*m+v*v;if(E>=b)_=0;else{const k=1-Math.sqrt(E)/p;_*=k*k*(3-2*k)}}g.x+=g.vx*_*e,g.y+=g.vy*_*e}this.alpha*=Dn}applyClusterAttractor(){const e=this.groupAssignment;if(!e)return;const t=this.groupAttractorStrength;if(t<=0)return;const n=new Map,o=new Map;if(this.groupOrder&&this.groupOrder.length>0){const r=this.groupOrder.length,c=this.groupOrderSpacing,u=this.groupOrderStaggerY;for(let d=0;d<r;d++){const l=this.groupOrder[d];n.set(l,(d-(r-1)/2)*c),u>0&&o.set(l,d%2===0?-u:u)}}const i=new Map;for(const r of this.nodes){const c=e.get(r.id);if(!(!c||c.length===0))for(const u of c){const d=i.get(u);d?(d.sx+=r.x,d.sy+=r.y,d.count++):i.set(u,{sx:r.x,sy:r.y,count:1})}}for(const r of this.nodes){if(r.pinned)continue;const c=e.get(r.id);if(!c||c.length===0)continue;const u=t/c.length;for(const d of c){const l=i.get(d);if(!l||l.count===0)continue;const p=n.has(d)?n.get(d):l.sx/l.count,b=o.has(d)?o.get(d):l.sy/l.count;r.vx+=(p-r.x)*u,r.vy+=(b-r.y)*u}}}setGroupAssignment(e,t=null){this.groupAssignment=e,this.groupOrder=e?t:null,this.reheat(.3,!1)}}const rt={user:3829232,term:2926970,comment:15239482,media:10510036,revision:7042949},at={user:"admin-users",term:"tag",comment:"admin-comments",media:"admin-media",revision:"backup"};function Vn(s){switch(s.taxonomy){case"category":return"category";case"post_tag":return"tag";default:return at.term}}const Gn={user:{x:0,y:3},term:{x:0,y:3},comment:{x:1,y:4},media:{x:-1,y:1},revision:{x:0,y:3}},ge=14;class Hn{constructor(e,t,n,o,i,r){this.pixi=e,this.satelliteParent=t,this.spokeParent=n,this.onClick=o,this.hostEl=i,this.claimPointer=r,this.views=[],this.focused=null,this.rafId=null,this.selectedKey=null,this.linkGfx=new e.Graphics,this.spokeParent.addChild(this.linkGfx),this.layer=new e.Container,this.satelliteParent.addChild(this.layer),this.hoverEl=document.createElement("div"),this.hoverEl.className="os-content-graph__tooltip",this.hoverEl.hidden=!0,this.hostEl.appendChild(this.hoverEl)}clear(){this.linkGfx.clear(),this.layer.removeChildren(),this.views=[],this.focused=null,this.selectedKey=null,this.hideTooltip()}drawLinks(){if(this.linkGfx.clear(),!this.focused||this.views.length===0)return;const e=this.focused.radius+8,t=this.focused.x,n=this.focused.y;for(const o of this.views){const i=o.container.x-t,r=o.container.y-n,c=Math.sqrt(i*i+r*r);if(c<=e)continue;const u=e/c,d=t+i*u,l=n+r*u,p=rt[o.ref.kind];this.linkGfx.moveTo(d,l).lineTo(o.container.x,o.container.y).stroke({color:p,width:o.selected?1.8:1.4,alpha:o.selected?.85:.5})}}setFocused(e,t){this.clear(),this.focused=e;const n=this.flattenDetail(t);if(n.length===0)return;const o=e.radius,r=Math.max(o+86,o+70+n.length*36/(2*Math.PI)),c=-Math.PI/2,u=2*Math.PI/n.length;n.forEach((d,l)=>{const p=c+l*u,b=e.x+Math.cos(p)*r,g=e.y+Math.sin(p)*r,_=this.buildSatellite(d,e.x,e.y);_.targetX=b,_.targetY=g,this.views.push(_)}),this.animateIn()}setSelectedKey(e){if(this.selectedKey!==e){this.selectedKey=e;for(const t of this.views){const n=t.key===e;n!==t.selected&&(t.selected=n,this.repaintDisc(t))}this.drawLinks()}}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.clear(),this.layer.destroy({children:!0}),this.linkGfx.destroy(),this.hoverEl.remove()}flattenDetail(e){const t=[];e.author&&t.push({kind:"user",userId:e.author.id,label:e.author.name,meta:y("Author"),avatar:e.author.avatar});for(const n of e.contributors.slice(0,8))t.push({kind:"user",userId:n.id,label:n.name,meta:y("Contributor"),avatar:n.avatar});for(const n of e.categories.slice(0,12))t.push({kind:"term",termId:n.id,taxonomy:n.taxonomy,label:n.name,meta:te(y("%1$s · %2$d posts"),n.tax_label,n.count)});for(const n of e.comments.slice(0,8))t.push({kind:"comment",commentId:n.id,label:n.author,meta:n.excerpt||lt(n.date)});for(const n of e.attached_media.slice(0,12))t.push({kind:"media",mediaId:n.id,label:n.title,meta:n.mime,thumb:n.thumb});for(const n of e.revisions.slice(0,8))t.push({kind:"revision",revisionId:n.id,parentId:e.post.id,label:n.author?.name??y("Revision"),meta:lt(n.date)});return t}buildSatellite(e,t,n){const o=new this.pixi.Container;o.x=t,o.y=n,o.alpha=0,o.eventMode="static",o.cursor="pointer";const i=ge+4;o.hitArea={contains:(N,I)=>N>=-i&&N<=i&&I>=-i&&I<=i+18};const r=new this.pixi.Graphics;o.addChild(r);const c=e.kind==="term"?Vn(e):at[e.kind],u=ve(c),d=new this.pixi.Text({text:u??"?",style:{fontFamily:u?"dashicons":"sans-serif",fontSize:u?20:13,fill:16777215},resolution:2,anchor:{x:.5,y:.5}}),l=Gn[e.kind];d.x=l?.x??0,d.y=l?.y??0,o.addChild(d);const p=zn(e.label||"—",28),b=new this.pixi.Graphics;o.addChild(b);const g=new this.pixi.Text({text:p,style:{fill:1711915,fontSize:11,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeight:"500"},resolution:2,anchor:{x:.5,y:0}});g.x=0,g.y=ge+2,o.addChild(g);const _=6,m=1,v=g.width+_*2,E=g.height+m*2;b.roundRect(-v/2,g.y-m,v,E,4).fill({color:16777215,alpha:.92}).stroke({color:0,alpha:.08,width:1}),o.on("pointerdown",N=>{N.stopPropagation?.(),this.claimPointer()}),o.on("pointerover",N=>{r.alpha=1;const I=N;this.showTooltip(e,I.global)}),o.on("pointermove",N=>{const I=N;this.showTooltip(e,I.global)}),o.on("pointerout",()=>{r.alpha=.95,this.hideTooltip()}),o.on("pointertap",N=>{N.stopPropagation?.(),this.hideTooltip(),this.setSelectedKey(ct(e)),this.onClick(e)}),this.layer.addChild(o);const k={ref:e,key:ct(e),container:o,disc:r,icon:d,label:g,targetX:t,targetY:n,selected:!1};return this.repaintDisc(k),k}repaintDisc(e){const t=rt[e.ref.kind];e.disc.clear(),e.selected&&e.disc.circle(0,0,ge+6).fill({color:t,alpha:.18}),e.disc.circle(0,0,ge).fill({color:t,alpha:.95}).stroke({color:16777215,width:e.selected?2.5:1.5,alpha:1})}animateIn(){const e=performance.now(),t=240,n=this.views.map(i=>({x:i.container.x,y:i.container.y})),o=i=>{const r=Math.min(1,(i-e)/t),c=1-Math.pow(1-r,3);for(let u=0;u<this.views.length;u++){const d=this.views[u],l=n[u];d.container.x=l.x+(d.targetX-l.x)*c,d.container.y=l.y+(d.targetY-l.y)*c,d.container.alpha=c}this.drawLinks(),r<1?this.rafId=requestAnimationFrame(o):this.rafId=null};this.rafId=requestAnimationFrame(o)}showTooltip(e,t){this.hoverEl.hidden=!1,this.hoverEl.innerHTML=`<strong>${dt(e.label||"—")}</strong>`+(e.meta?`<span>${dt(e.meta)}</span>`:""),t&&(this.hoverEl.style.left=`${t.x+14}px`,this.hoverEl.style.top=`${t.y+14}px`)}hideTooltip(){this.hoverEl.hidden=!0}}function ct(s){switch(s.kind){case"user":return`user:${s.userId}`;case"term":return`term:${s.taxonomy}:${s.termId}`;case"comment":return`comment:${s.commentId}`;case"media":return`media:${s.mediaId}`;case"revision":return`revision:${s.revisionId}`}}function zn(s,e){return s.length<=e?s:s.slice(0,e-1).trimEnd()+"…"}function lt(s){if(!s)return"";try{return new Date(s).toLocaleString()}catch{return s}}function dt(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const ke=4937059,ht=2911205,Un=5213171,Bn=10135222,Yn=2911205,Ae=Math.min((typeof window<"u"&&window.devicePixelRatio||1)*1.5,3),Te=[3829232,2926970,15239482,10510036,3122616,13914255,7042949],pt=16777215,qn=1.3,Xn=0,Kn={"admin-post":{x:.06,y:.06}},jn={category:"#2c6be5",tag:"#2ca97a",author:"#7c3aed",year:"#ea580c",year_month:"#ea580c"},Ie=.15,ut=4,Zn={padding:100,minScale:Ie,maxScale:1.5},Qn=8e-4,ft=300,Jn=.18,Le=.001,mt=24;class es{constructor(e,t,n,o,i="disc"){this.groupLabelOverlay=null,this.satellites=null,this.nodeViews=new Map,this.edgeViews=[],this.groupViews=new Map,this.currentGrouping=null,this.groupCatalogs={authors:{},categories:{},tags:{}},this.groupingTween=null,this.fitFollowActive=!1,this.fitFollowStartedAt=0,this.fitFollowSawMotion=!1,this.fitFollowMaxDurationMs=3e3,this.fitFollowVelocityThreshold=1,this.nodes=[],this.edges=[],this.sim=null,this.focusedId=null,this.hoveredId=null,this.pressedNode=null,this.dragOffset={x:0,y:0},this.isPanning=!1,this.panStart={x:0,y:0,wx:0,wy:0},this.nodeClickActive=!1,this.pointers=new Map,this.pinchUntil=0,this.destroyed=!1,this.tickerCb=null,this.resizeObserver=null,this.fitInsets={top:0,right:0,bottom:0,left:0},this.unsubscribeWorkArea=null,this.lastResizeWidth=0,this.lastResizeHeight=0,this.fitPending=!1,this.targetScale=1,this.targetX=0,this.targetY=0,this.postTypeColor=new Map,this.nodeStyle="disc",this.host=e,this.callbacks=t,this.onSatelliteClick=n,this.nodeStyle=i;const r=new Map;this.postTypeBySlug=new Map;for(const c of o)r.set(c.slug,ts(c.icon)),this.postTypeBySlug.set(c.slug,c);o.forEach((c,u)=>{this.postTypeColor.set(c.slug,Te[u%Te.length])}),this.postTypeIcon=c=>r.get(c)??ss(c)}async mount(e){typeof e.loadModules=="function"&&await e.loadModules(["pixijs"]);const t=kn();if(!t)throw new Error("PIXI namespace missing after loadModules.");if(this.pixi=t,typeof document<"u"&&document.fonts)try{await document.fonts.load("16px dashicons")}catch{}const n=new t.Application;await n.init({resizeTo:this.host,backgroundAlpha:0,antialias:!0,autoDensity:!0,resolution:Ae,sharedTicker:!1}),this.app=n,this.host.appendChild(n.canvas),n.canvas.classList.add("os-content-graph__canvas"),this.world=new t.Container,this.world.x=this.host.clientWidth/2,this.world.y=this.host.clientHeight/2,this.world.scale.set(1),this.targetX=this.world.x,this.targetY=this.world.y,this.targetScale=1,n.stage.addChild(this.world),this.edgeLayer=new t.Container,this.spokeLayer=new t.Container,this.nodeLayer=new t.Container,this.labelLayer=new t.Container,this.world.addChild(this.edgeLayer,this.spokeLayer,this.nodeLayer,this.labelLayer),this.groupLabelOverlay=document.createElement("div"),this.groupLabelOverlay.className="os-content-graph__group-labels",this.host.appendChild(this.groupLabelOverlay),n.canvas.addEventListener("webglcontextlost",r=>{r.preventDefault();try{this.app?.ticker?.stop()}catch{}},!1);const o=n.renderer,i=o.render.bind(o);o.render=(...r)=>{try{return i(...r)}catch(c){try{this.app?.ticker?.stop()}catch{}console.warn("[content-graph] Pixi render threw, stopping ticker:",c);return}},this.satellites=new Hn(t,this.world,this.spokeLayer,this.onSatelliteClick,this.host,()=>{this.nodeClickActive=!0}),this.bindStageInput(n.canvas),this.bindResize(),this.tickerCb=r=>this.tick(r.deltaTime),n.ticker.add(this.tickerCb)}setData(e){const t=new Map;for(const d of this.nodes)t.set(d.id,d);this.groupCatalogs=e.groups??{authors:{},categories:{},tags:{}};const n=e.nodes.every(d=>!t.has(d.id)),o=n?Mn(e.nodes.length):null,i=e.nodes.map((d,l)=>{const p=t.get(d.id),b=o?o[l]:tt();return{...d,x:p?.x??b.x,y:p?.y??b.y,vx:0,vy:0,pinned:!1,radius:4,color:ke,degree:0}}),r=new Map;for(const d of i)r.set(d.id,d);const c=[];for(const d of e.edges){const l=r.get(d.from),p=r.get(d.to);!l||!p||(l.degree++,p.degree++,c.push({from:l,to:p}))}for(const d of i)d.radius=8+Math.min(8,Math.sqrt(d.degree)*2.4);this.nodes=i,this.edges=c,this.rebuildSprites(),this.sim=new Wn(i,c),this.sim.reheat(.12,!1);const u=n?$n(i.length):nt;for(let d=0;d<u&&!this.sim.isSettled;d++)this.sim.step(1);this.currentGrouping&&this.setGrouping(this.currentGrouping)}rebuildSprites(){this.edgeLayer.removeChildren(),this.nodeLayer.removeChildren(),this.labelLayer.removeChildren(),this.nodeViews.clear(),this.edgeViews=[];for(const e of this.edges){const t=new this.pixi.Graphics;this.edgeLayer.addChild(t),this.edgeViews.push({edge:e,gfx:t})}for(const e of this.nodes){const t=new this.pixi.Container;t.eventMode="static",t.cursor="pointer",t.hitArea=new this.pixi.Circle(0,0,Math.max(18,e.radius+8)),this.bindNodeInput(t,e),this.nodeLayer.addChild(t);const n=new this.pixi.Graphics;t.addChild(n);const o=new this.pixi.Graphics;t.addChild(o);const i=this.postTypeIcon(e.type),r=ve(i),c=new this.pixi.Text({text:r??"●",style:{fontFamily:r?"dashicons":"sans-serif",fontSize:2*e.radius,fill:ke},resolution:Ae,anchor:{x:.5,y:.5}});t.addChild(c);const u=new this.pixi.Container;this.labelLayer.addChild(u);const d=new this.pixi.Graphics;u.addChild(d);const l=new this.pixi.Text({text:this.truncate(H(e.title)||`#${e.id}`,32),style:{fill:2042167,fontSize:11,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',fontWeight:"500"},resolution:Ae,anchor:{x:.5,y:0}});u.addChild(l);const p=5,b=1,g=l.width+p*2,_=l.height+b*2;d.roundRect(-g/2,-b,g,_,4).fill({color:16777215,alpha:.78}).stroke({color:0,alpha:.06,width:1}),this.nodeViews.set(e.id,{node:e,container:t,halo:n,disc:o,icon:c,labelBox:u,labelBg:d,label:l,iconCharCode:r,iconName:i,typeColor:this.postTypeColor.get(e.type)??Te[0],discKey:""})}}truncate(e,t){return e.length<=t?e:e.slice(0,t-1).trimEnd()+"…"}bindNodeInput(e,t){let n={x:0,y:0},o=!1;const i=36;e.on("pointerdown",r=>{const c=r;c.stopPropagation?.(),n={x:c.global.x,y:c.global.y},this.nodeClickActive=!0,this.pressedNode=t,o=!1,t.pinned=!0,t.vx=0,t.vy=0}),e.on("pointerover",()=>{this.hoveredId=t.id,this.draw()}),e.on("pointerout",()=>{this.hoveredId===t.id&&(this.hoveredId=null,this.draw())}),e.on("pointerup",r=>{const c=r,u=c.global.x-n.x,d=c.global.y-n.y;!o&&u*u+d*d<=256&&!this.pinchRecent()&&this.callbacks.onNodeClick?.(t),t.pinned=this.focusedId===t.id,this.pressedNode=null,this.sim&&(this.sim.dragOrigin=null,o&&this.sim.reheat(.35,!1)),o=!1}),e.on("pointerupoutside",()=>{t.pinned=this.focusedId===t.id,this.pressedNode=null,this.sim&&(this.sim.dragOrigin=null),o=!1}),e.on("globalpointermove",r=>{if(this.pressedNode!==t)return;const c=r,u=c.global.x-n.x,d=c.global.y-n.y,l=u*u+d*d;if(!o){if(l<i)return;o=!0;const b=this.toWorld(c.global.x,c.global.y);this.dragOffset={x:t.x-b.x,y:t.y-b.y},this.sim&&(this.sim.dragOrigin={x:t.x,y:t.y},this.sim.reheat(.3,!1))}const p=this.toWorld(c.global.x,c.global.y);t.x=p.x+this.dragOffset.x,t.y=p.y+this.dragOffset.y,t.vx=0,t.vy=0,this.sim&&(this.sim.dragOrigin={x:t.x,y:t.y})})}pinchRecent(){return this.pointers.size>=2||performance.now()<this.pinchUntil}canvasPoint(e,t){const n=e.getBoundingClientRect();return{x:t.clientX-n.left,y:t.clientY-n.top}}bindStageInput(e){e.style.touchAction="none",e.addEventListener("wheel",n=>{n.preventDefault();const o=Math.exp(-n.deltaY*Qn),i=Math.max(Ie,Math.min(ut,this.targetScale*o)),r=e.getBoundingClientRect(),c=n.clientX-r.left,u=n.clientY-r.top,d=(c-this.targetX)/this.targetScale,l=(u-this.targetY)/this.targetScale;this.targetScale=i,this.targetX=c-d*i,this.targetY=u-l*i},{passive:!1}),e.addEventListener("pointerdown",n=>{if(this.pointers.set(n.pointerId,this.canvasPoint(e,n)),this.pointers.size===2){this.isPanning=!1,this.nodeClickActive=!1,this.pressedNode&&(this.pressedNode.pinned=this.focusedId===this.pressedNode.id,this.pressedNode=null,this.sim&&(this.sim.dragOrigin=null));return}n.target===e&&(this.nodeClickActive||this.pointers.size>1||(this.isPanning=!0,this.panStart={x:n.clientX,y:n.clientY,wx:this.world.x,wy:this.world.y}))}),window.addEventListener("pointermove",n=>{if(this.pointers.has(n.pointerId)){const r=this.pointers.get(n.pointerId),c=this.canvasPoint(e,n);if(this.pointers.set(n.pointerId,c),this.pointers.size===2){this.pinch(n.pointerId,r);return}}if(!this.isPanning||this.nodeClickActive||this.pointers.size>1)return;const o=this.panStart.wx+(n.clientX-this.panStart.x),i=this.panStart.wy+(n.clientY-this.panStart.y);this.world.x=o,this.world.y=i,this.targetX=o,this.targetY=i});const t=n=>{const o=this.pointers.size>=2;this.pointers.delete(n.pointerId),o&&(this.isPanning=!1,this.pinchUntil=performance.now()+ft)};window.addEventListener("pointercancel",t),window.addEventListener("pointerup",n=>{t(n);const o=this.nodeClickActive;if(this.nodeClickActive=!1,!this.isPanning)return;const i=n.clientX-this.panStart.x,r=n.clientY-this.panStart.y;this.isPanning=!1,!o&&!this.pinchRecent()&&i*i+r*r<9&&this.callbacks.onBackgroundClick?.()})}pinch(e,t){let n=null,o=null;for(const[r,c]of this.pointers)r===e?o=c:n=c;if(!o||!n)return;const i=On({scale:this.world.scale.x,x:this.world.x,y:this.world.y},{a:t,b:n},{a:o,b:n},{min:Ie,max:ut});this.world.scale.set(i.scale),this.world.x=i.x,this.world.y=i.y,this.targetScale=i.scale,this.targetX=i.x,this.targetY=i.y,this.pinchUntil=performance.now()+ft}bindResize(){this.lastResizeWidth=this.host.clientWidth,this.lastResizeHeight=this.host.clientHeight,this.resizeObserver=new ResizeObserver(()=>{if(this.destroyed)return;const e=this.host.clientWidth,t=this.host.clientHeight;if(this.fitInsets=me(this.host),e<=0||t<=0)return;try{this.app.renderer.resize(e,t)}catch{return}try{this.app.render()}catch{}this.fitPending&&this.fitToView();const n=Math.abs(e-this.lastResizeWidth),o=Math.abs(t-this.lastResizeHeight);(n>=mt||o>=mt)&&(this.lastResizeWidth=e,this.lastResizeHeight=t)}),this.resizeObserver.observe(this.host),this.unsubscribeWorkArea=Nn(()=>{this.destroyed||(this.fitInsets=me(this.host))})}toWorld(e,t){const n=this.app.canvas.getBoundingClientRect(),o=e-n.left,i=t-n.top;return{x:(o-this.world.x)/this.world.scale.x,y:(i-this.world.y)/this.world.scale.y}}tick(e){if(this.destroyed||!this.app||!this.world)return;this.groupingTween?this.advanceGroupingTween():this.sim?.step(e);const t=1-Math.pow(1-Jn,e),n=this.targetScale-this.world.scale.x;Math.abs(n)<Le?this.world.scale.set(this.targetScale):this.world.scale.set(this.world.scale.x+n*t);const o=this.targetX-this.world.x,i=this.targetY-this.world.y;Math.abs(o)<Le?this.world.x=this.targetX:this.world.x+=o*t,Math.abs(i)<Le?this.world.y=this.targetY:this.world.y+=i*t,this.draw(),this.drawGroupLabels(),this.satellites?.drawLinks(),this.advanceFitFollow()}advanceFitFollow(){if(!this.fitFollowActive)return;if(performance.now()-this.fitFollowStartedAt>this.fitFollowMaxDurationMs){this.fitFollowActive=!1;return}if(this.groupingTween)return;let e=0;for(const t of this.nodes){if(t.pinned)continue;const n=Math.hypot(t.vx,t.vy);n>e&&(e=n)}e>=this.fitFollowVelocityThreshold?(this.fitFollowSawMotion=!0,this.fitToView(!1)):this.fitFollowSawMotion&&(this.fitFollowActive=!1)}postTypeSupportsTaxonomy(e,t){return this.postTypeBySlug.get(e)?.taxonomies?.[t]??!1}postTypeLabel(e){return this.postTypeBySlug.get(e)?.label??e}deriveGroupKeys(e,t){switch(t){case"category":return this.postTypeSupportsTaxonomy(e.type,"category")?e.category_ids.length===0?["cat:uncat"]:e.category_ids.map(n=>`cat:${n}`):[`cat:type_${e.type}`];case"tag":return this.postTypeSupportsTaxonomy(e.type,"post_tag")?e.tag_ids.length===0?["tag:untagged"]:e.tag_ids.map(n=>`tag:${n}`):[`tag:type_${e.type}`];case"author":{const n=e.author_id||0,o=`author:${n}`,i=[o,o],r=Array.isArray(e.contributor_ids)?e.contributor_ids:[];for(const c of r)c>0&&c!==n&&i.push(`author:${c}`);return i}case"year":return[`year:${e.year||0}`];case"year_month":return[`ym:${e.year_month||"unknown"}`]}}labelForGroupKey(e){const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);switch(n){case"cat":{if(o==="uncat")return y("Uncategorized");if(o.startsWith("type_"))return this.postTypeLabel(o.slice(5));const i=Number(o);return this.groupCatalogs.categories[i]?.name??`#${i}`}case"tag":{if(o==="untagged")return y("Untagged");if(o.startsWith("type_"))return this.postTypeLabel(o.slice(5));const i=Number(o);return this.groupCatalogs.tags[i]?.name??`#${i}`}case"author":{const i=Number(o);return i<=0?y("Unknown author"):this.groupCatalogs.authors[i]?.name??`#${i}`}case"year":{const i=Number(o);return i<=0?y("Undated"):String(i)}case"ym":return o==="unknown"||o===""?y("Undated"):ns(o)}return e}buildGroupViews(e,t){if(!this.groupLabelOverlay)return;const n=jn[t];for(const[o,i]of e){if(i.length===0)continue;const r=`${this.labelForGroupKey(o)} (${i.length})`,c=document.createElement("div");c.className="os-content-graph__group-label",c.textContent=r,c.style.setProperty("--os-ui-cg-cluster-color",n),this.groupLabelOverlay.appendChild(c),this.groupViews.set(o,{key:o,label:r,el:c,members:i})}}clearGroupViews(){for(const e of this.groupViews.values())e.el.remove();this.groupViews.clear()}drawGroupLabels(){if(this.destroyed||this.groupViews.size===0)return;const e=1-Me(1.2,2.4,this.world.scale.x),t=this.world.scale.x,n=this.world.x,o=this.world.y;for(const i of this.groupViews.values()){let r=0,c=0,u=0;for(const p of i.members){const b=this.nodeViews.get(p)?.node;b&&(r+=b.x,c+=b.y,u++)}if(u===0||e<=.02){i.el.style.display="none";continue}const d=n+r/u*t,l=o+c/u*t;i.el.style.display="",i.el.style.transform=`translate(${d}px, ${l}px) translate(-50%, -50%)`,i.el.style.opacity=String(e)}}draw(){if(this.destroyed)return;const e=this.focusedId,t=this.hoveredId,n=new Set;if(e!==null){for(const l of this.edges)l.from.id===e&&n.add(l.to.id),l.to.id===e&&n.add(l.from.id);n.add(e)}const o=e!==null,r=.2+Me(.45,1.1,this.world.scale.x)*.35;for(const l of this.edgeViews){const{edge:p,gfx:b}=l;b.clear();const g=e!==null&&(p.from.id===e||p.to.id===e),_=t!==null&&(p.from.id===t||p.to.id===t);let m;o?m=g?.85:0:_?m=.7:m=r;const v=g||_?Yn:Bn,E=g||_?1.2:.7;let k=p.from.x,N=p.from.y,I=p.to.x,O=p.to.y;if(e!==null){if(p.from.id===e){const C=gt(p.from.x,p.from.y,p.to.x,p.to.y,p.from.radius+8);k=C.x,N=C.y}if(p.to.id===e){const C=gt(p.to.x,p.to.y,p.from.x,p.from.y,p.to.radius+8);I=C.x,O=C.y}}b.moveTo(k,N).lineTo(I,O).stroke({color:v,width:E,alpha:m})}const c=1/this.world.scale.x,u=Me(.55,.95,this.world.scale.x),d=this.nodeStyle==="disc";for(const l of this.nodeViews.values()){const{node:p,container:b,halo:g,disc:_,icon:m,labelBox:v}=l,E=p.id===e,k=p.id===t,N=e!==null&&n.has(p.id),I=e===null||N,O=I?1:.25;b.x=p.x,b.y=p.y,b.alpha=O;let C=ke;E?C=ht:N&&(C=Un);const P=E?ht:l.typeColor;g.clear(),(E||k)&&g.circle(0,0,p.radius+8).fill({color:d?P:C,alpha:.18});const L=E?p.radius*qn:p.radius,z=E||k?2.5:1.5,we=d?`${P}|${L}|${z}`:"off";l.discKey!==we&&(l.discKey=we,_.clear(),d&&_.circle(0,0,L).fill({color:P,alpha:.95}).stroke({color:pt,width:z,alpha:1})),m.visible=!d||E||k,m.style.fill=d?pt:C;const ie=d?L*1.35:2*p.radius;m.style.fontSize=ie;const U=Kn[l.iconName];m.x=(U?.x??0)*ie,m.y=(U?.y??Xn)*ie,v.x=p.x,v.y=p.y+(d?L:p.radius)+4,v.scale.set(c);let ee;E?ee=1:I?ee=.92:ee=.32,v.alpha=ee*u,v.visible=v.alpha>.01}}focusNode(e){if(this.focusedId!==null){const n=this.nodeViews.get(this.focusedId);n&&(n.node.pinned=!1)}this.focusedId=e;const t=this.nodeViews.get(e);if(t){t.node.pinned=!0,t.node.vx=0,t.node.vy=0;const n=t.node,o=Math.max(this.targetScale,1.6);this.targetScale=o,this.targetX=this.host.clientWidth/2-n.x*o,this.targetY=this.host.clientHeight/2-n.y*o}this.draw()}setFocusedDetail(e){if(!this.satellites)return;if(!e||this.focusedId===null){this.satellites.clear();return}const t=this.nodeViews.get(this.focusedId)?.node;if(!t){this.satellites.clear();return}this.satellites.setFocused(t,e)}setGrouping(e){if(this.currentGrouping=e,this.clearGroupViews(),!e||!this.sim){this.sim?.setGroupAssignment(null);return}const t=new Map,n=new Map;for(const r of this.nodes){const c=this.deriveGroupKeys(r,e);t.set(r.id,c);const u=new Set;for(const d of c){if(u.has(d))continue;u.add(d);const l=n.get(d);l?l.push(r.id):n.set(d,[r.id])}}const o=this.chronologicalOrder(e,n);this.sim.groupOrderStaggerY=e==="year_month"?160:0,this.sim.setGroupAssignment(t,o);const i=this.buildGroupSeedTargets(t,n,o);this.startGroupingTween(i),this.fitToViewOfTargets(i),this.buildGroupViews(n,e),this.fitFollowActive=!0,this.fitFollowStartedAt=performance.now(),this.fitFollowSawMotion=!1}advanceGroupingTween(){if(this.destroyed)return;const e=this.groupingTween;if(!e)return;const t=Math.min(1,(performance.now()-e.startTime)/e.duration),n=1-Math.pow(1-t,3);for(const[o,i]of e.starts){const r=e.targets.get(o);if(!r)continue;const c=this.nodeViews.get(o)?.node;!c||c.pinned||(c.x=i.x+(r.x-i.x)*n,c.y=i.y+(r.y-i.y)*n,c.vx=0,c.vy=0)}t>=1&&(this.groupingTween=null,this.sim?.reheat(.18,!1))}buildGroupSeedTargets(e,t,n){const o=new Map;if(!this.sim)return o;const i=Array.from(t.keys()),r=new Map,c=this.sim.groupOrderSpacing;if(n&&n.length>0){const d=n.length,l=this.sim.groupOrderStaggerY,p=g=>l<=0?0:g%2===0?-l:l;for(let g=0;g<d;g++)r.set(n[g],{x:(g-(d-1)/2)*c,y:p(g)});let b=d;for(const g of i)r.has(g)||(r.set(g,{x:(b-(d-1)/2)*c,y:p(b)}),b++)}else{const d=i.length,l=Math.max(220,120+d*40);for(let p=0;p<d;p++){const b=p/Math.max(1,d)*Math.PI*2-Math.PI/2;r.set(i[p],{x:Math.cos(b)*l,y:Math.sin(b)*l})}}const u=40;for(const d of this.nodes){if(d.pinned)continue;const l=e.get(d.id);if(!l||l.length===0)continue;let p=0,b=0,g=0;for(const _ of l){const m=r.get(_);m&&(p+=m.x,b+=m.y,g++)}g!==0&&o.set(d.id,{x:p/g+(Math.random()-.5)*u,y:b/g+(Math.random()-.5)*u})}return o}startGroupingTween(e){if(e.size===0){this.groupingTween=null;return}const t=new Map;for(const n of e.keys()){const o=this.nodeViews.get(n)?.node;o&&t.set(n,{x:o.x,y:o.y})}this.groupingTween={startTime:performance.now(),duration:450,starts:t,targets:e}}fitToViewOfTargets(e){e.size!==0&&(this.fitInsets=me(this.host),this.frame(e.values()))}frame(e){const t=this.fitInsets,n=Rn(e,{width:this.host.clientWidth-t.left-t.right,height:this.host.clientHeight-t.top-t.bottom},Zn);if(!n){this.fitPending=!0;return}this.fitPending=!1,this.targetScale=n.scale,this.targetX=t.left+n.x,this.targetY=t.top+n.y}chronologicalOrder(e,t){if(e!=="year"&&e!=="year_month")return null;const n=[];for(const o of t.keys()){const i=o.indexOf(":"),r=o.slice(i+1);if(e==="year"){const c=Number(r);if(!Number.isFinite(c)||c<=0)continue;n.push({key:o,sort:String(c).padStart(6,"0")})}else{if(r==="unknown"||r==="")continue;n.push({key:o,sort:r})}}return n.sort((o,i)=>o.sort<i.sort?-1:o.sort>i.sort?1:0),n.map(o=>o.key)}clearFocus(){if(this.focusedId!==null){const e=this.nodeViews.get(this.focusedId);e&&(e.node.pinned=!1)}this.focusedId=null,this.satellites?.clear(),this.sim?.reheat(.25,!1),this.draw()}setSatelliteSelectedKey(e){this.satellites?.setSelectedKey(e)}getNode(e){return this.nodes.find(t=>t.id===e)}getNodes(){return this.nodes}setNodeStyle(e){if(this.nodeStyle!==e){this.nodeStyle=e;for(const t of this.nodeViews.values())t.discKey=""}}getNodeStyle(){return this.nodeStyle}getFocusedId(){return this.focusedId}fitToView(e=!0){this.nodes.length!==0&&(e&&(this.fitInsets=me(this.host)),this.frame(this.nodes))}destroy(){this.destroyed=!0;try{this.app?.ticker?.stop()}catch{}if(this.tickerCb){try{this.app?.ticker?.remove(this.tickerCb)}catch{}this.tickerCb=null}this.resizeObserver?.disconnect(),this.resizeObserver=null,this.unsubscribeWorkArea?.(),this.unsubscribeWorkArea=null,this.satellites?.destroy(),this.satellites=null,this.clearGroupViews(),this.groupLabelOverlay?.remove(),this.groupLabelOverlay=null;try{this.app.destroy({removeView:!0},{children:!0})}catch{}}}function ts(s){return typeof s!="string"||s===""||s.startsWith("http://")||s.startsWith("https://")?"admin-generic":s.replace(/^dashicons-/,"")}function gt(s,e,t,n,o){const i=t-s,r=n-e,c=Math.sqrt(i*i+r*r);if(c===0)return{x:s,y:e};const u=Math.min(o/c,1);return{x:s+i*u,y:e+r*u}}function Me(s,e,t){if(t<=s)return 0;if(t>=e)return 1;const n=(t-s)/(e-s);return n*n*(3-2*n)}function ns(s){const e=/^(\d{4})-(\d{2})$/.exec(s);if(!e)return s;const t=Number(e[2])-1;if(t<0||t>11)return s;const n=Number(e[1]);try{const o=new Date(Date.UTC(n,t,1));return new Intl.DateTimeFormat(void 0,{month:"short",year:"numeric",timeZone:"UTC"}).format(o)}catch{return s}}function ss(s){switch(s){case"post":return"admin-post";case"page":return"admin-page";case"attachment":return"admin-media";default:return"admin-generic"}}const yt="desktop-mode-content-graph",wt="desktop-mode/corkboard-node-style",ye=new Set;let J=os();function os(){try{return window.localStorage.getItem(wt)==="icon"?"icon":"disc"}catch{return"disc"}}function is(s){try{window.localStorage.setItem(wt,s)}catch{}}Tt({id:"desktop-mode/corkboard-pins",label:y("Show pins"),checkable:!0,checked:()=>J==="icon",isVisible:s=>(s.config.baseId??s.id)===yt,onSelect:()=>{J=J==="icon"?"disc":"icon",is(J);for(const s of ye)s.setNodeStyle(J)}});async function rs(s){const e=s.querySelector("[data-os-content-graph-root]");if(!e)return s.textContent=y("Corkboard container missing."),{abort:()=>{}};const t=je(),n=e.querySelector("[data-os-content-graph-toolbar]"),o=e.querySelector("[data-os-content-graph-stage]"),i=e.querySelector("[data-os-content-graph-panel]"),r=e.querySelector("[data-os-content-graph-loading]"),c=window.wp?.os??{};let u=t.postTypes.map(C=>C.slug),d=t.postTypes,l=null,p=0,b=!1;const g=Jt(r),_=Zt(o),m=_n(i,t,{onClose:()=>{m.hide(),l?.clearFocus()},onViewChange:C=>{l?.setSatelliteSelectedKey(C)}}),v=C=>{switch(C.kind){case"user":m.showUser(C.userId);break;case"term":m.showTerm(C.termId,C.taxonomy);break;case"comment":m.showComment(C.commentId);break;case"media":m.showMedia(C.mediaId);break;case"revision":m.showRevision(C.revisionId);break}},E=C=>{l?.focusNode(C.id),m.setLoading(C.id,C.title);const P=++p;(async()=>{try{const L=await hn(t,C.id);if(b||P!==p)return;m.setDetail(L),l?.setFocusedDetail(L)}catch(L){if(b||P!==p)return;m.setError(te(y("Could not load post #%d."),C.id)),console.warn("[content-graph] detail fetch failed",L)}})()},k=()=>({onTypesChange:C=>{u=C,I()},onFitToView:()=>l?.fitToView(),onSearchSelect:C=>E(C),onGroupChange:C=>{l?.setGrouping(C),_.setSuppressed(C!==null)},getNodes:()=>l?.getNodes()??[]}),N=mn(n,t.postTypes,k()),I=async()=>{if(!b){g.show(),N.setStatus(y("Loading graph…"));try{const C=await dn(t,u);if(b)return;l?.setData(C),N.setStatus(te(y("%1$d nodes · %2$d links"),C.stats.nodes,C.stats.edges)),_.set(Kt({nodes:C.stats.nodes,edges:C.stats.edges,types:d,activeTypes:u})),l?.fitToView(),l?.clearFocus(),m.hide()}catch(C){if(b)return;_.set({kind:"none"}),N.setStatus(y("Failed to load graph.")),console.warn("[content-graph] graph fetch failed",C)}finally{g.hide()}}},O=()=>{p++,m.hide(),l?.clearFocus()};l=new es(o,{onNodeClick:C=>{if(l?.getFocusedId()===C.id){O();return}E(C)},onBackgroundClick:O},v,t.postTypes,J),ye.add(l);try{await l.mount(c)}catch(C){return o.textContent=y("Could not initialise the graph renderer."),console.warn("[content-graph] scene mount failed",C),ye.delete(l),{abort:()=>{}}}return(async()=>{try{const C=await ln(t);if(b)return;d=C,N.updateCounts(C)}catch{}await I()})(),{abort:()=>{b=!0,g.destroy(),_.destroy(),N.destroy(),m.destroy(),l&&(ye.delete(l),l.destroy()),l=null}}}const as=window.openStationNativeWindows??(window.openStationNativeWindows={});as[yt]=async s=>(await rs(s)).abort})();