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/window-link-visuals.min.js +1 -1 1.1.7 → 1.1.12 View file →
@@ -1 +1 @@
1 -(function(){"use strict";function z(){const e=window.wp?.hooks;if(!e)throw new Error("[openstation] `window.wp.hooks` is not available. The plugin declares `wp-hooks` as a script dependency; if you are seeing this error, verify the enqueue order.");return e}function v(e,o,t,n){z().addAction(e,o,t,n)}function H(e,o,...t){return z().applyFilters(e,o,...t)}function $(e,...o){z().doAction(e,...o)}const N={INIT:"os.init",WALLPAPERS:"os.wallpapers",GAMES:"os.games",UNFOCUS_EFFECTS:"os.unfocus-effects",WINDOW_REVEALS:"os.window-reveals",WALLPAPER_MOUNTING:"os.wallpaper.mounting",WALLPAPER_MOUNTED:"os.wallpaper.mounted",WALLPAPER_UNMOUNTING:"os.wallpaper.unmounting",WALLPAPER_MOUNT_FAILED:"os.wallpaper.mount-failed",WALLPAPER_VISIBILITY:"os.wallpaper.visibility",WALLPAPER_SUSPEND:"os.wallpaper.suspend",WALLPAPER_PREVIEW_PARAMS:"os.wallpaper.preview-params",WALLPAPER_SETTINGS_CHANGED:"os.wallpaper.settings-changed",IFRAME_READY:"os.iframe.ready",IFRAME_ERROR:"os.iframe.error",IFRAME_NETWORK_COMPLETED:"os.iframe.network-completed",SHELL_ERROR:"os.shell.error",BROADCAST:"os.broadcast",MONITOR_ENTRY:"os.monitor.entry",WALLPAPER_SURFACES:"os.wallpaper.surfaces",DESKTOP_THEME_CHANGED:"os.os-theme.changed",DESKTOP_THEME_ICON:"os.os-theme.icon",DESKTOP_THEME_ICON_COLOR:"os.os-theme.icon-color",WALLPAPERS_SERVER_CHANGED:"os.wallpapers.server-changed",EXTENDED_OPTIONS_CHANGED:"os.extended-options.changed",WINDOW_GEOMETRY:"os.window.geometry",WINDOW_OPENED:"os.window.opened",WINDOW_CONTENT_LOADING:"os.window.content-loading",WINDOW_CONTENT_LOADED:"os.window.content-loaded",WINDOW_LOADING_OVERLAY:"os.window.loading-overlay",WINDOW_REOPENED:"os.window.reopened",WINDOW_MENU_OPENED:"os.window.menu-opened",WINDOW_CLOSING:"os.window.closing",WINDOW_CLOSED:"os.window.closed",WINDOW_FOCUSED:"os.window.focused",WINDOW_BLURRED:"os.window.blurred",WINDOW_MINIMIZED:"os.window.minimized",WINDOW_RESTORED:"os.window.restored",WINDOW_CHILD_BLOCKED:"os.window.child-blocked",WINDOW_MAXIMIZED:"os.window.maximized",WINDOW_UNMAXIMIZED:"os.window.unmaximized",WINDOW_FULLSCREEN_ENTERED:"os.window.fullscreen-entered",WINDOW_FULLSCREEN_EXITED:"os.window.fullscreen-exited",WINDOW_AUTO_EXIT_FULLSCREEN:"os.window.auto-exit-fullscreen",WINDOW_FOCUS_ON_DRAG_HOVER:"os.window.focus-on-drag-hover",WINDOW_BOUNDS_CHANGED:"os.window.bounds-changed",WINDOW_MOVED:"os.window.moved",WINDOW_RESIZED:"os.window.resized",WINDOW_DRAG_START:"os.window.drag-start",WINDOW_DRAG_END:"os.window.drag-end",WINDOW_RESIZE_START:"os.window.resize-start",WINDOW_RESIZE_END:"os.window.resize-end",WINDOW_DETACHED:"os.window.detached",WINDOW_RELOADED:"os.window.reloaded",WINDOW_TITLE_CHANGED:"os.window.title-changed",WINDOW_HIGHLIGHT_CHANGED:"os.window.highlight-changed",WINDOW_BODY_RESIZED:"os.window.body-resized",NATIVE_WINDOW_BEFORE_RENDER:"os.native-window.before-render",NATIVE_WINDOW_AFTER_RENDER:"os.native-window.after-render",NATIVE_WINDOW_BEFORE_CLOSE:"os.native-window.before-close",WINDOW_CHROME_THEME:"os.window.chrome.theme",WINDOW_CHROME_CONTROLS:"os.window.chrome.controls",WINDOW_CHROME_SLOT:"os.window.chrome.slot",WINDOW_CHROME_RENDER:"os.window.chrome.render",WINDOW_CHROME_APPLIED:"os.window.chrome.applied",WINDOW_CHROME_THEME_CHANGED:"os.window.chrome.theme-changed",DESKTOP_ICON_CLICKED:"os.os-icon.clicked",DESKTOP_ICONS_RENDERED:"os.os-icons.rendered",ICON_BADGE_CHANGED:"os.icon.badge-changed",COMPONENTS_REGISTERED:"os.components.registered",DOCK_ITEM_APPENDED:"os.dock.item-appended",DOCK_ITEM_REMOVED:"os.dock.item-removed",DOCK_BEFORE_RENDER:"os.dock.before-render",DOCK_AFTER_RENDER:"os.dock.after-render",DOCK_REFRESH_ACTIVE:"os.dock.refresh-active",DOCK_TILE_CLASS:"os.dock.tile-class",DOCK_TILE_ELEMENT:"os.dock.tile-element",DOCK_TILE_RENDERED:"os.dock.tile-rendered",DOCK_TILE_TOOLTIP:"os.dock.tile-tooltip",DOCK_PEEK_CARD_CONTENT:"os.dock.peek-card-content",DOCK_PEEK_CARD_ELEMENT:"os.dock.peek-card-element",CONSTELLATION_PANEL:"os.constellation.panel",CONSTELLATION_OPENED:"os.constellation.opened",CONSTELLATION_CLOSED:"os.constellation.closed",OVERVIEW_ENTERING:"os.overview.entering",OVERVIEW_ENTERED:"os.overview.entered",OVERVIEW_EXITING:"os.overview.exiting",OVERVIEW_EXITED:"os.overview.exited",OVERVIEW_WINDOW_HOVER:"os.overview.window-hover",OVERVIEW_WINDOW_UNHOVER:"os.overview.window-unhover",OVERVIEW_WINDOW_CLICK:"os.overview.window-click",WORK_AREA_CHANGED:"os.work-area.changed",ARRANGE_CASCADE_STARTING:"os.arrange.cascade.starting",ARRANGE_CASCADE_APPLIED:"os.arrange.cascade.applied",ARRANGE_TILE_STARTING:"os.arrange.tile.starting",ARRANGE_TILE_APPLIED:"os.arrange.tile.applied",ARRANGE_TILE_DIMENSIONS:"os.arrange.tile.dimensions",ARRANGE_COLUMNS_STARTING:"os.arrange.columns.starting",ARRANGE_COLUMNS_APPLIED:"os.arrange.columns.applied",ARRANGE_FOCUS_SPLIT:"os.arrange.focus.split",ARRANGE_FOCUS_STARTING:"os.arrange.focus.starting",ARRANGE_FOCUS_APPLIED:"os.arrange.focus.applied",ARRANGE_SNAP_CHANGED:"os.arrange.snap.changed",ARRANGE_SNAP_CELL_SIZE:"os.arrange.snap.cell-size",ARRANGE_CUSTOM_ACTION:"os.arrange.custom-action",POINTER_SHAKE:"os.pointer.shake",GRID_SNAP_DIMENSIONS:"os.grid-snap.dimensions",GRID_SNAP_ARMED:"os.grid-snap.armed",GRID_SNAP_CHANGED:"os.grid-snap.changed",GRID_SNAP_ANCHOR_RESET:"os.grid-snap.anchor-reset",GRID_SNAP_CANCELED:"os.grid-snap.canceled",GRID_SNAP_COMMITTED:"os.grid-snap.committed",GRID_SNAP_REFLOWED:"os.grid-snap.reflowed",SNAP_ZONE_PENDING:"os.snap.zone-pending",SNAP_ZONE_CANCELED:"os.snap.zone-canceled",SNAP_ZONE_COMMITTED:"os.snap.zone-committed",SNAP_SPLIT_FILLED:"os.snap.split-filled",WIDGETS:"os.widgets",WIDGET_MOUNTING:"os.widget.mounting",WIDGET_MOUNTED:"os.widget.mounted",WIDGET_UNMOUNTING:"os.widget.unmounting",WIDGET_MOUNT_FAILED:"os.widget.mount-failed",WIDGET_ADDED:"os.widget.added",WIDGET_REMOVED:"os.widget.removed",DESKTOP_CREATED:"os.os.created",DESKTOP_CLOSED:"os.os.closed",DESKTOP_SWITCHED:"os.os.switched",DESKTOP_RENAMED:"os.os.renamed",WINDOW_DESKTOP_CHANGED:"os.os.window-moved",PRIMARY_DESKTOP_ID:"os.primary-desktop-id",WORKSPACE_PRESETS:"os.workspaces.presets",WORKSPACE_PROFILE:"os.workspaces.profile",WORKSPACE_UPDATED:"os.workspaces.updated",WORKSPACE_PROVISIONED:"os.workspaces.provisioned",WINDOWS_BEFORE_CLOSE_ALL:"os.windows.before-close-all",WINDOWS_CLOSE_ALL:"os.windows.close-all",WINDOWS_AFTER_CLOSE_ALL:"os.windows.after-close-all",COMMAND_BEFORE_RUN:"os.command.before-run",COMMAND_AFTER_RUN:"os.command.after-run",COMMAND_ERROR:"os.command.error",SHELL_RESIZED:"os.shell.resized",SHELL_VISIBILITY:"os.shell.visibility",CONNECTION_OPENED:"os.connection.opened",CONNECTION_CLOSED:"os.connection.closed",CONNECTION_MESSAGE:"os.connection.message",IFRAME_CONNECTION_REQUEST:"os.iframe.connection-request",WINDOW_CONTENT_CHANGED:"os.window-links.content-changed",WINDOW_LINK_GROUPS_CHANGED:"os.window-links.groups-changed",WINDOW_LINKS_CONTENT:"os.window-links.content",WINDOW_LINK_GROUPS:"os.window-links.groups",WINDOW_LINK_EDGES:"os.window-links.edges",RELATED_ENTITIES_ITEMS:"os.related-entities.items",WINDOW_LINK_RENDERERS:"os.window-links.renderers",WINDOW_LINK_RENDERER:"os.window-links.renderer",EDITOR_PREVIEW_WINDOW_CONFIG:"os.editor-preview.window-config",EDITOR_PREVIEW_LIVE:"os.editor-preview.live",EDITOR_PREVIEW_OPENED:"os.editor-preview.opened",EDITOR_PREVIEW_CLOSED:"os.editor-preview.closed",REVISIONS_WINDOW_CONFIG:"os.revisions.window-config",REVISIONS_OPENED:"os.revisions.opened",FILE_DROP_FILES_DETECTED:"os.drop.files-detected",FILE_DROP_FILES_REJECTED:"os.drop.files-rejected",FILE_DROP_DIALOG_FIELDS:"os.drop.dialog-fields",FILE_DROP_BEFORE_UPLOAD:"os.drop.before-upload",FILE_DROP_UPLOAD_STARTED:"os.drop.upload-started",FILE_DROP_UPLOAD_PROGRESS:"os.drop.upload-progress",FILE_DROP_AFTER_UPLOAD:"os.drop.after-upload",FILE_DROP_UPLOAD_FAILED:"os.drop.upload-failed",AUTH_LOST:"os.auth.lost",AUTH_RESTORED:"os.auth.restored",MODE_CHANGED:"os.mode.changed",SESSION_SNAPSHOT:"os.session.snapshot"};class we extends Error{constructor(o,t,n){super(`[openstation] ${o} registration rejected — fields: `+t.join(", ")+"."),this.name="RegistrationError",this.kind=o,this.errors=t,this.def=n}}function fe(e,o,t){if(o.length!==0)throw new we(e,o,t)}const q="__openStationSharedStores";function ue(){const e=window;let o=e[q];return o||(o=new Map,e[q]=o),o}function J(e,o){const t=ue();let n=t.get(e);n||(n={state:o(),listeners:new Set,rebuild:o},t.set(e,n));const s={get state(){return n.state},set state(r){n.state=r},getState(){return n.state},notify(){for(const r of Array.from(n.listeners))try{r(n.state)}catch(l){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,l)}},subscribe(r){return n.listeners.add(r),()=>{n.listeners.delete(r)}},setState(r){const l=n.state;if(typeof l!="object"||l===null){console.warn(`[desktop-mode/shared-store:${e}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(l,r),s.notify()},reset(){const r=n.rebuild(),l=n.state;if(typeof l=="object"&&l!==null&&typeof r=="object"&&r!==null){const c=l;for(const a of Object.keys(c))delete c[a];Object.assign(c,r)}else n.state=r;n.listeners.clear()}};return s}const L=J("desktop-mode/window-links",()=>({contentByWindow:new Map,focusSeq:new Map,seq:0,listeners:new Set,lastGroupsSignature:"",manager:null,started:!1}));function G(e){return`${e.type}:${e.id}`}function _e(e){return e.root?G(e.root):G(e)}function Ie(e){return L.state.contentByWindow.get(e)}function Q(){const e=new Map;for(const[s,r]of L.state.contentByWindow){const l=_e(r);let c=e.get(l);c||(c={key:l,root:r.root?{...r.root}:{type:r.type,id:r.id},rootWindowIds:[],children:[]},e.set(l,c)),r.root?c.children.push({windowId:s,content:r}):c.rootWindowIds.push(s)}const o=L.state.focusSeq;for(const s of e.values())s.rootWindowIds.sort((r,l)=>(o.get(l)??0)-(o.get(r)??0));const t=Array.from(e.values()),n=H(N.WINDOW_LINK_GROUPS,t);return Array.isArray(n)?n:(typeof console<"u"&&console.warn("[openstation] `os.window-links.groups` filter returned a non-array; falling back to computed groups."),t)}function Ne(e){return Q().find(o=>o.rootWindowIds.includes(e)||o.children.some(t=>t.windowId===e))}function Oe(e){const o=new Set,t=Ne(e);if(t)for(const n of[...t.rootWindowIds,...t.children.map(s=>s.windowId)])o.add(n);for(const n of V())n.fromWindowId===e?o.add(n.toWindowId):n.toWindowId===e&&o.add(n.fromWindowId);return o.delete(e),Array.from(o)}function De(e){const o=new Set;for(const t of V())t.fromWindowId===e?o.add(t.toWindowId):t.toWindowId===e&&o.add(t.fromWindowId);return o.delete(e),Array.from(o)}function V(){const e=L.state.focusSeq,o=new Map;for(const[c,a]of L.state.contentByWindow){const i=G(a),f=o.get(i);(!f||(e.get(c)??0)>(e.get(f)??0))&&o.set(i,c)}const t=new Map,n=(c,a)=>`${c}→${a}`;for(const[c,a]of L.state.contentByWindow){if(a.root){const i=o.get(G(a.root));i&&i!==c&&t.set(n(c,i),{fromWindowId:c,toWindowId:i,kind:"child-root",bidirectional:!1})}for(const i of a.links??[]){const f=o.get(G(i));if(!f||f===c)continue;if(i.rel==="child"){const I=n(f,c),p=t.get(I);(!p||p.kind!=="child-root")&&t.set(I,{fromWindowId:f,toWindowId:c,kind:"child-root",bidirectional:!1});continue}const E=n(c,f);t.has(E)||t.set(E,{fromWindowId:c,toWindowId:f,kind:"reference",bidirectional:!1})}}const s=[],r=new Set;for(const[c,a]of t){if(r.has(c))continue;const i=n(a.toWindowId,a.fromWindowId),f=t.get(i);if(f&&a.kind==="reference"){if(f.kind==="reference"){r.add(i),s.push({...a,bidirectional:!0});continue}continue}s.push(a)}const l=H(N.WINDOW_LINK_EDGES,s);return Array.isArray(l)?l:(typeof console<"u"&&console.warn("[openstation] `os.window-links.edges` filter returned a non-array; falling back to derived edges."),s)}function Re(e){return L.state.listeners.add(e),()=>{L.state.listeners.delete(e)}}const b="none",Z="svg-splines",ee=J("desktop-mode/window-link-renderer-registry",()=>({registry:new Map,listeners:new Set})),oe=ee.state.registry,X=ee.state.listeners,te=/^[a-z0-9_/-]+$/;function pe(e){const o=[];!e||typeof e!="object"?o.push("def (not an object)"):(typeof e.id!="string"||e.id.trim()===""?o.push("id (missing)"):te.test(e.id.trim().toLowerCase())?e.id.trim().toLowerCase()===b&&o.push('id ("none" is reserved)'):o.push(`id (must match ${te} — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-id)`),(typeof e.label!="string"||e.label.trim()==="")&&o.push("label (missing)"),typeof e.mount!="function"&&o.push("mount (not a function)")),fe("WindowLinkRenderer",o,e);const t=e.id.trim().toLowerCase();oe.set(t,{...e,id:t}),ge()}function We(){const e=Array.from(oe.values()),o=H(N.WINDOW_LINK_RENDERERS,e);return Array.isArray(o)?o:(typeof console<"u"&&console.warn("[openstation] `os.window-links.renderers` filter returned a non-array; falling back to registry list."),e)}function j(e){return We().find(o=>o.id===e)}function he(e){return X.add(e),()=>{X.delete(e)}}function ge(){const e=Array.from(X);for(const o of e)try{o()}catch(t){typeof console<"u"&&console.error("[openstation] window-link-renderer registry listener threw:",t)}}const Ae="desktop-mode";function me(){return window.wp?.i18n}function ne(e,o=Ae){return me()?.__(e,o)??e}const Le=16;function Se(e,o){const t=o.map(r=>({start:Math.max(e.start,r.start),end:Math.min(e.end,r.end)})).filter(r=>r.end>r.start).sort((r,l)=>r.start-l.start),n=[];let s=e.start;for(const r of t)r.start>s&&n.push({start:s,end:r.start}),s=Math.max(s,r.end);return s<e.end&&n.push({start:s,end:e.end}),n}function ye(e,o){const t=e.x+e.width/2,n=e.y+e.height/2,s=o.x-t,r=o.y-n;if(s===0&&r===0)return{x:t,y:n,side:"right"};const l=s!==0?e.width/2/Math.abs(s):1/0,c=r!==0?e.height/2/Math.abs(r):1/0,a=Math.min(l,c),i=t+s*a,f=n+r*a;let E;return l<=c?E=s>0?"right":"left":E=r>0?"bottom":"top",{x:i,y:f,side:E}}function se(e,o,t,n){for(const s of t)if(!(s.windowId===n||s.zIndex<=o)&&e.x>=s.rect.x&&e.x<=s.rect.x+s.rect.width&&e.y>=s.rect.y&&e.y<=s.rect.y+s.rect.height)return!1;return!0}function Te(e,o,t,n,s){const r=t.filter(i=>i.windowId!==n&&i.zIndex>o),l=[{side:"top",base:{start:e.x,end:e.x+e.width},at:e.y,horizontal:!0},{side:"bottom",base:{start:e.x,end:e.x+e.width},at:e.y+e.height,horizontal:!0},{side:"left",base:{start:e.y,end:e.y+e.height},at:e.x,horizontal:!1},{side:"right",base:{start:e.y,end:e.y+e.height},at:e.x+e.width,horizontal:!1}];let c=null,a=1/0;for(const{side:i,base:f,at:E,horizontal:I}of l){const p=[];for(const{rect:_}of r)(I?_.y<=E&&E<=_.y+_.height:_.x<=E&&E<=_.x+_.width)&&p.push(I?{start:_.x,end:_.x+_.width}:{start:_.y,end:_.y+_.height});for(const _ of Se(f,p)){if(_.end-_.start<Le)continue;const W=(_.start+_.end)/2,R=I?W:E,h=I?E:W,y=Math.hypot(s.x-R,s.y-h);y<a&&(a=y,c={x:R,y:h,side:i})}}return c}function ke(e,o){const t=Math.max(o.x-(e.x+e.width),e.x-(o.x+o.width)),n=Math.max(o.y-(e.y+e.height),e.y-(o.y+o.height));if(t<0&&n<0)return null;const s=Math.max(e.x,o.x),r=Math.min(e.x+e.width,o.x+o.width),l=Math.max(e.y,o.y),c=Math.min(e.y+e.height,o.y+o.height);let a,i;r>=s?a=i=(s+r)/2:o.x>e.x?(a=e.x+e.width,i=o.x):(a=e.x,i=o.x+o.width);let f,E;c>=l?f=E=(l+c)/2:o.y>e.y?(f=e.y+e.height,E=o.y):(f=e.y,E=o.y+o.height);const I=t>=n,p=(_,W,R)=>I?W<=_.x?"left":"right":R<=_.y?"top":"bottom";return{from:{x:a,y:f,side:p(e,a,f)},to:{x:i,y:E,side:p(o,i,E)}}}function ie(e,o){const t=Math.min(160,Math.max(24,.4*o));switch(e.side){case"left":return{x:e.x-t,y:e.y};case"right":return{x:e.x+t,y:e.y};case"top":return{x:e.x,y:e.y-t};default:return{x:e.x,y:e.y+t}}}function Ce(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}const M="http://www.w3.org/2000/svg";let Pe=0;function re(e,o,t,n,s){const r=ye(e,s);return o===null||se(r,o,n,t)?r:Te(e,o,n,t,s)??r}function ve(e,o){const t=document.createElementNS(M,"defs"),n=(c,a,i)=>{const f=`${o}-${c}`,E=document.createElementNS(M,"marker");E.setAttribute("id",f),E.setAttribute("viewBox","0 0 10 10"),E.setAttribute("refX","5"),E.setAttribute("refY","5"),E.setAttribute("markerWidth",i),E.setAttribute("markerHeight",i),E.setAttribute("markerUnits","strokeWidth");const I=document.createElementNS(M,"circle");return I.setAttribute("cx","5"),I.setAttribute("cy","5"),I.setAttribute("r","4"),I.classList.add(a),E.appendChild(I),t.appendChild(E),f},s="os-window-link__endpoint",r=`${s}--active`,l={dot:{normal:n("dot",s,"7"),active:n("dot-active",r,"7")},port:{normal:n("port",s,"4.5"),active:n("port-active",r,"4.5")}};return e.appendChild(t),l}pe({id:"svg-splines",label:ne("Splines"),description:ne("Curved connectors between related windows, ending in circular dots — the larger dot sits on the window the content belongs to; windows that reference each other get large dots on both ends."),mount:e=>{const o=++Pe,t=(c,a)=>{const i=document.createElementNS(M,"svg");return i.classList.add("os-window-links__svg"),c.appendChild(i),{svg:i,markers:ve(i,`os-window-link-${o}${a}`)}},n={base:t(e.container,""),elevated:t(e.elevatedContainer,"-elevated")},s=new Map,r=c=>{for(const{svg:i}of[n.base,n.elevated])i.setAttribute("width",String(c.container.width)),i.setAttribute("height",String(c.container.height)),i.setAttribute("viewBox",`0 0 ${c.container.width} ${c.container.height}`);const a=new Set;for(const i of c.edges){if(!i.from||!i.to)continue;const f=`${i.fromWindowId}→${i.toWindowId}:${i.kind}`;a.add(f);const E=i.elevated?"elevated":"base";let I=s.get(f);if(I&&I.surface!==E&&(I.group.remove(),s.delete(f),I=void 0),!I){const g=document.createElementNS(M,"g");g.classList.add("os-window-link");const S=document.createElementNS(M,"path");S.classList.add("os-window-link__path"),g.appendChild(S),n[E].svg.appendChild(g),I={group:g,path:S,surface:E},s.set(f,I)}const p=c.obstacles??[],_=ke(i.from,i.to),W=(g,S,F)=>S===null||se(g,S,p,F);let R=null;_&&W(_.from,i.fromZIndex,i.fromWindowId)&&(R=_.from),R||(R=re(i.from,i.fromZIndex,i.fromWindowId,p,_?{x:_.to.x,y:_.to.y}:Ce(i.to)));let h=null;_&&W(_.to,i.toZIndex,i.toWindowId)&&(h=_.to),h||(h=re(i.to,i.toZIndex,i.toWindowId,p,{x:R.x,y:R.y}));const y=Math.hypot(h.x-R.x,h.y-R.y),x=ie(R,y),K=ie(h,y);I.path.setAttribute("d",`M ${R.x} ${R.y} C ${x.x} ${x.y}, ${K.x} ${K.y}, ${h.x} ${h.y}`);const T=n[I.surface].markers,m=i.focused?"active":"normal";I.path.setAttribute("marker-end",`url(#${T.dot[m]})`),I.path.setAttribute("marker-start",`url(#${i.bidirectional?T.dot[m]:T.port[m]})`),I.group.classList.toggle("os-window-link--active",i.focused)}for(const[i,f]of Array.from(s))a.has(i)||(f.group.remove(),s.delete(i))},l=e.onFrame(r);return r(e.getFrame()),()=>{l(),s.clear(),n.base.svg.remove(),n.elevated.svg.remove()}}});const de="os-window-links",ce="os-window--linked",ae="os-window-links--visible";let le=!1;function be({manager:e,osSettings:o}){if(le)return;le=!0;let t=o.getOsSettingsSnapshot(),n=null,s=null,r=null,l=null,c=0;const a=new Set;let i=!1;const f=new Set;let E=!1;const I=d=>{const w=d.element;return!w||!w.isConnected||d.state==="minimized"||w.offsetParent===null?null:{x:w.offsetLeft,y:w.offsetTop,width:w.offsetWidth,height:w.offsetHeight}},p=d=>d.state==="snapped-left"||d.state==="snapped-right"?null:I(d),_=()=>{const d=[];for(const u of Q()){if(u.rootWindowIds.length===0||u.children.length===0)continue;const O=[],P=(A,Me,Ee)=>{const B=e.getById(A);!B||!Ee||O.push({windowId:A,role:Me,content:Ee,rect:p(B),focused:B.isFocused(),state:B.state})};for(const A of u.rootWindowIds)P(A,"root",Ie(A));for(const A of u.children)P(A.windowId,"child",A.content);O.length>0&&d.push({key:u.key,root:u.root,members:O})}const w=u=>{const O=Number.parseInt(u.element?.style.zIndex||"",10);return Number.isFinite(O)?O:null},D=e.getFocused()?.id??null,k=[];for(const u of V()){const O=e.getById(u.fromWindowId),P=e.getById(u.toWindowId);if(!O||!P)continue;const A=O.isFocused()||P.isFocused();k.push({fromWindowId:u.fromWindowId,toWindowId:u.toWindowId,kind:u.kind,bidirectional:u.bidirectional,focused:A,from:p(O),to:p(P),fromZIndex:w(O),toZIndex:w(P),elevated:D!==null&&(u.fromWindowId===D||u.toWindowId===D)})}const C=[];for(const u of e.getAll()){const O=I(u);O&&C.push({windowId:u.id,rect:O,zIndex:w(u)??0})}return{groups:d,edges:k,obstacles:C,container:{width:n?.offsetWidth??0,height:n?.offsetHeight??0}}},W=()=>{i||a.size===0||(i=!0,requestAnimationFrame(()=>{if(i=!1,!r)return;const d=_();for(const w of Array.from(a))try{w(d)}catch(D){typeof console<"u"&&console.error("[openstation] window-link frame subscriber threw:",D)}}))},R=()=>{if(n&&n.isConnected&&s?.isConnected)return n;const d=document.getElementById("os-area");if(!d)return null;n=document.createElement("div"),n.id=de,n.className="os-window-links",n.setAttribute("aria-hidden","true"),s=document.createElement("div"),s.id=`${de}-elevated`,s.className="os-window-links os-window-links--elevated",s.setAttribute("aria-hidden","true");const w=document.getElementById("os-widgets");return w&&w.parentElement===d?(w.insertAdjacentElement("afterend",s),w.insertAdjacentElement("afterend",n)):d.prepend(n,s),n},h=()=>V().length>0,y=()=>{let d=t.windowLinkRenderer||Z;return d=H(N.WINDOW_LINK_RENDERER,d),d===b?b:j(d)?d:j(Z)?Z:b},x=()=>{if(c++,a.clear(),i=!1,l){try{l()}catch(d){$(N.SHELL_ERROR,{scope:"window-link-renderer-teardown",error:d})}l=null}r=null,n?.replaceChildren(),s?.replaceChildren()},K=d=>{const w=j(d),D=R();if(!w||!D||!s)return;r=d;const k=++c,C={container:D,elevatedContainer:s,getFrame:_,onFrame:u=>(a.add(u),()=>{a.delete(u)})};try{const u=w.mount(C);u instanceof Promise?u.then(O=>{if(k!==c){typeof O=="function"&&O();return}typeof O=="function"&&(l=O)}).catch(O=>{$(N.SHELL_ERROR,{scope:"window-link-renderer-mount",error:O}),k===c&&(r=null)}):typeof u=="function"&&(l=u)}catch(u){$(N.SHELL_ERROR,{scope:"window-link-renderer-mount",error:u}),r=null}W()},T=()=>{const d=e.getFocused();return d?new Set(Oe(d.id)):new Set},m=()=>t.windowLinksEnabled!==!1,g=()=>{if(!n)return;const d=!E&&m()&&(t.windowLinkVisibility==="always"||t.windowLinkVisibility==="focus"&&T().size>0);n.classList.toggle(ae,d),s?.classList.toggle(ae,d)},S=()=>{if(!m()||t.windowLinkRaiseOnFocus===!1||t.windowLinkVisibility==="off")return;const d=e.getFocused();if(d)for(const w of De(d.id)){const D=e.getById(w);D&&D.state!=="minimized"&&e.raise(w)}},F=()=>{if(!s)return;const d=e.getFocused(),w=T();if(!d||w.size===0||!m()||t.windowLinkVisibility==="off"){s.style.zIndex="";return}let D=-1/0;for(const k of[d.id,...w]){const C=e.getById(k),u=C?.element;if(!u||C.state==="minimized")continue;const O=Number.parseInt(u.style.zIndex||"",10);Number.isFinite(O)&&(D=Math.max(D,O))}s.style.zIndex=Number.isFinite(D)?String(D):""},Y=()=>{const d=m()&&t.windowLinkHighlight!==!1&&t.windowLinkVisibility!=="off"?T():new Set;for(const w of f)d.has(w)||e.getById(w)?.element?.classList.remove(ce);for(const w of d)e.getById(w)?.element?.classList.add(ce);f.clear();for(const w of d)f.add(w)},U=()=>{const d=m()&&t.windowLinkVisibility!=="off"&&h()?y():b;d===b?r&&x():d!==r&&(x(),K(d)),g(),Y(),F(),W()};v(N.WINDOW_BOUNDS_CHANGED,"desktop-mode/window-links-frame",()=>W());for(const d of[N.WINDOW_MOVED,N.WINDOW_RESIZED,N.WINDOW_MINIMIZED,N.WINDOW_RESTORED,N.WINDOW_MAXIMIZED,N.WINDOW_UNMAXIMIZED,N.WINDOW_FULLSCREEN_ENTERED,N.WINDOW_FULLSCREEN_EXITED,N.SNAP_ZONE_COMMITTED,N.SNAP_SPLIT_FILLED,N.DESKTOP_SWITCHED,N.SHELL_RESIZED])v(d,"desktop-mode/window-links-frame",()=>W());v(N.WINDOW_FOCUSED,"desktop-mode/window-links-focus",()=>{S(),g(),Y(),F(),W()}),v(N.WINDOW_BLURRED,"desktop-mode/window-links-blur",()=>{g(),Y(),F(),W()}),v(N.OVERVIEW_ENTERING,"desktop-mode/window-links-overview",()=>{E=!0,g()}),v(N.OVERVIEW_EXITED,"desktop-mode/window-links-overview",()=>{E=!1,g(),W()}),Re(U),he(U),o.subscribeOsSettings(d=>{const w=d.windowLinkRenderer!==t.windowLinkRenderer,D=w||d.windowLinkVisibility!==t.windowLinkVisibility||d.windowLinksEnabled!==t.windowLinksEnabled||d.windowLinkRaiseOnFocus!==t.windowLinkRaiseOnFocus||d.windowLinkHighlight!==t.windowLinkHighlight;t=d,D&&(w&&r&&x(),U())}),U()}window.openStationWindowLinkVisuals={start:be}})();
1 +(function(){"use strict";function z(){const e=window.wp?.hooks;if(!e)throw new Error("[openstation] `window.wp.hooks` is not available. The plugin declares `wp-hooks` as a script dependency; if you are seeing this error, verify the enqueue order.");return e}function v(e,o,t,n){z().addAction(e,o,t,n)}function H(e,o,...t){return z().applyFilters(e,o,...t)}function $(e,...o){z().doAction(e,...o)}const N={INIT:"os.init",WALLPAPERS:"os.wallpapers",GAMES:"os.games",UNFOCUS_EFFECTS:"os.unfocus-effects",WINDOW_REVEALS:"os.window-reveals",WALLPAPER_MOUNTING:"os.wallpaper.mounting",WALLPAPER_MOUNTED:"os.wallpaper.mounted",WALLPAPER_UNMOUNTING:"os.wallpaper.unmounting",WALLPAPER_MOUNT_FAILED:"os.wallpaper.mount-failed",WALLPAPER_VISIBILITY:"os.wallpaper.visibility",WALLPAPER_SUSPEND:"os.wallpaper.suspend",WALLPAPER_PREVIEW_PARAMS:"os.wallpaper.preview-params",WALLPAPER_SETTINGS_CHANGED:"os.wallpaper.settings-changed",IFRAME_READY:"os.iframe.ready",IFRAME_ERROR:"os.iframe.error",IFRAME_NETWORK_COMPLETED:"os.iframe.network-completed",SHELL_ERROR:"os.shell.error",BROADCAST:"os.broadcast",MONITOR_ENTRY:"os.monitor.entry",WALLPAPER_SURFACES:"os.wallpaper.surfaces",DESKTOP_THEME_CHANGED:"os.os-theme.changed",DESKTOP_THEME_ICON:"os.os-theme.icon",DESKTOP_THEME_ICON_COLOR:"os.os-theme.icon-color",WALLPAPERS_SERVER_CHANGED:"os.wallpapers.server-changed",EXTENDED_OPTIONS_CHANGED:"os.extended-options.changed",WINDOW_GEOMETRY:"os.window.geometry",WINDOW_OPENED:"os.window.opened",WINDOW_CONTENT_LOADING:"os.window.content-loading",WINDOW_CONTENT_LOADED:"os.window.content-loaded",WINDOW_LOADING_OVERLAY:"os.window.loading-overlay",WINDOW_REOPENED:"os.window.reopened",WINDOW_MENU_OPENED:"os.window.menu-opened",WINDOW_CLOSING:"os.window.closing",WINDOW_CLOSED:"os.window.closed",WINDOW_FOCUSED:"os.window.focused",WINDOW_BLURRED:"os.window.blurred",WINDOW_MINIMIZED:"os.window.minimized",WINDOW_RESTORED:"os.window.restored",WINDOW_CHILD_BLOCKED:"os.window.child-blocked",WINDOW_MAXIMIZED:"os.window.maximized",WINDOW_UNMAXIMIZED:"os.window.unmaximized",WINDOW_FULLSCREEN_ENTERED:"os.window.fullscreen-entered",WINDOW_FULLSCREEN_EXITED:"os.window.fullscreen-exited",WINDOW_AUTO_EXIT_FULLSCREEN:"os.window.auto-exit-fullscreen",WINDOW_FOCUS_ON_DRAG_HOVER:"os.window.focus-on-drag-hover",WINDOW_BOUNDS_CHANGED:"os.window.bounds-changed",WINDOW_MOVED:"os.window.moved",WINDOW_RESIZED:"os.window.resized",WINDOW_DRAG_START:"os.window.drag-start",WINDOW_DRAG_END:"os.window.drag-end",WINDOW_RESIZE_START:"os.window.resize-start",WINDOW_RESIZE_END:"os.window.resize-end",WINDOW_DETACHED:"os.window.detached",WINDOW_RELOADED:"os.window.reloaded",WINDOW_TITLE_CHANGED:"os.window.title-changed",WINDOW_HIGHLIGHT_CHANGED:"os.window.highlight-changed",WINDOW_BODY_RESIZED:"os.window.body-resized",NATIVE_WINDOW_BEFORE_RENDER:"os.native-window.before-render",NATIVE_WINDOW_AFTER_RENDER:"os.native-window.after-render",NATIVE_WINDOW_BEFORE_CLOSE:"os.native-window.before-close",WINDOW_CHROME_THEME:"os.window.chrome.theme",WINDOW_CHROME_CONTROLS:"os.window.chrome.controls",WINDOW_CHROME_SLOT:"os.window.chrome.slot",WINDOW_CHROME_RENDER:"os.window.chrome.render",WINDOW_CHROME_APPLIED:"os.window.chrome.applied",WINDOW_CHROME_THEME_CHANGED:"os.window.chrome.theme-changed",DESKTOP_ICON_CLICKED:"os.os-icon.clicked",DESKTOP_ICONS_RENDERED:"os.os-icons.rendered",ICON_BADGE_CHANGED:"os.icon.badge-changed",COMPONENTS_REGISTERED:"os.components.registered",DOCK_ITEM_APPENDED:"os.dock.item-appended",DOCK_ITEM_REMOVED:"os.dock.item-removed",DOCK_BEFORE_RENDER:"os.dock.before-render",DOCK_AFTER_RENDER:"os.dock.after-render",DOCK_REFRESH_ACTIVE:"os.dock.refresh-active",DOCK_TILE_CLASS:"os.dock.tile-class",DOCK_TILE_ELEMENT:"os.dock.tile-element",DOCK_TILE_RENDERED:"os.dock.tile-rendered",DOCK_TILE_TOOLTIP:"os.dock.tile-tooltip",DOCK_PEEK_CARD_CONTENT:"os.dock.peek-card-content",DOCK_PEEK_CARD_ELEMENT:"os.dock.peek-card-element",CONSTELLATION_PANEL:"os.constellation.panel",CONSTELLATION_OPENED:"os.constellation.opened",CONSTELLATION_CLOSED:"os.constellation.closed",OVERVIEW_ENTERING:"os.overview.entering",OVERVIEW_ENTERED:"os.overview.entered",OVERVIEW_EXITING:"os.overview.exiting",OVERVIEW_EXITED:"os.overview.exited",OVERVIEW_WINDOW_HOVER:"os.overview.window-hover",OVERVIEW_WINDOW_UNHOVER:"os.overview.window-unhover",OVERVIEW_WINDOW_CLICK:"os.overview.window-click",WORK_AREA_CHANGED:"os.work-area.changed",ARRANGE_CASCADE_STARTING:"os.arrange.cascade.starting",ARRANGE_CASCADE_APPLIED:"os.arrange.cascade.applied",ARRANGE_TILE_STARTING:"os.arrange.tile.starting",ARRANGE_TILE_APPLIED:"os.arrange.tile.applied",ARRANGE_TILE_DIMENSIONS:"os.arrange.tile.dimensions",ARRANGE_COLUMNS_STARTING:"os.arrange.columns.starting",ARRANGE_COLUMNS_APPLIED:"os.arrange.columns.applied",ARRANGE_FOCUS_SPLIT:"os.arrange.focus.split",ARRANGE_FOCUS_STARTING:"os.arrange.focus.starting",ARRANGE_FOCUS_APPLIED:"os.arrange.focus.applied",ARRANGE_SNAP_CHANGED:"os.arrange.snap.changed",ARRANGE_SNAP_CELL_SIZE:"os.arrange.snap.cell-size",POINTER_SHAKE:"os.pointer.shake",GRID_SNAP_DIMENSIONS:"os.grid-snap.dimensions",GRID_SNAP_ARMED:"os.grid-snap.armed",GRID_SNAP_CHANGED:"os.grid-snap.changed",GRID_SNAP_ANCHOR_RESET:"os.grid-snap.anchor-reset",GRID_SNAP_CANCELED:"os.grid-snap.canceled",GRID_SNAP_COMMITTED:"os.grid-snap.committed",GRID_SNAP_REFLOWED:"os.grid-snap.reflowed",SNAP_ZONE_PENDING:"os.snap.zone-pending",SNAP_ZONE_CANCELED:"os.snap.zone-canceled",SNAP_ZONE_COMMITTED:"os.snap.zone-committed",SNAP_SPLIT_FILLED:"os.snap.split-filled",WIDGETS:"os.widgets",WIDGET_MOUNTING:"os.widget.mounting",WIDGET_MOUNTED:"os.widget.mounted",WIDGET_UNMOUNTING:"os.widget.unmounting",WIDGET_MOUNT_FAILED:"os.widget.mount-failed",WIDGET_ADDED:"os.widget.added",WIDGET_REMOVED:"os.widget.removed",DESKTOP_CREATED:"os.os.created",DESKTOP_CLOSED:"os.os.closed",DESKTOP_SWITCHED:"os.os.switched",DESKTOP_RENAMED:"os.os.renamed",WINDOW_DESKTOP_CHANGED:"os.os.window-moved",PRIMARY_DESKTOP_ID:"os.primary-desktop-id",WORKSPACE_PRESETS:"os.workspaces.presets",WORKSPACE_PROFILE:"os.workspaces.profile",WORKSPACE_UPDATED:"os.workspaces.updated",WORKSPACE_PROVISIONED:"os.workspaces.provisioned",WINDOWS_BEFORE_CLOSE_ALL:"os.windows.before-close-all",WINDOWS_CLOSE_ALL:"os.windows.close-all",WINDOWS_AFTER_CLOSE_ALL:"os.windows.after-close-all",COMMAND_BEFORE_RUN:"os.command.before-run",COMMAND_AFTER_RUN:"os.command.after-run",COMMAND_ERROR:"os.command.error",SHELL_RESIZED:"os.shell.resized",SHELL_VISIBILITY:"os.shell.visibility",CONNECTION_OPENED:"os.connection.opened",CONNECTION_CLOSED:"os.connection.closed",CONNECTION_MESSAGE:"os.connection.message",IFRAME_CONNECTION_REQUEST:"os.iframe.connection-request",WINDOW_CONTENT_CHANGED:"os.window-links.content-changed",WINDOW_LINK_GROUPS_CHANGED:"os.window-links.groups-changed",WINDOW_LINKS_CONTENT:"os.window-links.content",WINDOW_LINK_GROUPS:"os.window-links.groups",WINDOW_LINK_EDGES:"os.window-links.edges",RELATED_ENTITIES_ITEMS:"os.related-entities.items",WINDOW_LINK_RENDERERS:"os.window-links.renderers",WINDOW_LINK_RENDERER:"os.window-links.renderer",EDITOR_PREVIEW_WINDOW_CONFIG:"os.editor-preview.window-config",EDITOR_PREVIEW_LIVE:"os.editor-preview.live",EDITOR_PREVIEW_OPENED:"os.editor-preview.opened",EDITOR_PREVIEW_CLOSED:"os.editor-preview.closed",REVISIONS_WINDOW_CONFIG:"os.revisions.window-config",REVISIONS_OPENED:"os.revisions.opened",FILE_DROP_FILES_DETECTED:"os.drop.files-detected",FILE_DROP_FILES_REJECTED:"os.drop.files-rejected",FILE_DROP_DIALOG_FIELDS:"os.drop.dialog-fields",FILE_DROP_BEFORE_UPLOAD:"os.drop.before-upload",FILE_DROP_UPLOAD_STARTED:"os.drop.upload-started",FILE_DROP_UPLOAD_PROGRESS:"os.drop.upload-progress",FILE_DROP_AFTER_UPLOAD:"os.drop.after-upload",FILE_DROP_UPLOAD_FAILED:"os.drop.upload-failed",AUTH_LOST:"os.auth.lost",AUTH_RESTORED:"os.auth.restored",MODE_CHANGED:"os.mode.changed",SESSION_SNAPSHOT:"os.session.snapshot"};class we extends Error{constructor(o,t,n){super(`[openstation] ${o} registration rejected — fields: `+t.join(", ")+"."),this.name="RegistrationError",this.kind=o,this.errors=t,this.def=n}}function fe(e,o,t){if(o.length!==0)throw new we(e,o,t)}const q="__openStationSharedStores";function ue(){const e=window;let o=e[q];return o||(o=new Map,e[q]=o),o}function J(e,o){const t=ue();let n=t.get(e);n||(n={state:o(),listeners:new Set,rebuild:o},t.set(e,n));const s={get state(){return n.state},set state(r){n.state=r},getState(){return n.state},notify(){for(const r of Array.from(n.listeners))try{r(n.state)}catch(l){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,l)}},subscribe(r){return n.listeners.add(r),()=>{n.listeners.delete(r)}},setState(r){const l=n.state;if(typeof l!="object"||l===null){console.warn(`[desktop-mode/shared-store:${e}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(l,r),s.notify()},reset(){const r=n.rebuild(),l=n.state;if(typeof l=="object"&&l!==null&&typeof r=="object"&&r!==null){const c=l;for(const a of Object.keys(c))delete c[a];Object.assign(c,r)}else n.state=r;n.listeners.clear()}};return s}const L=J("desktop-mode/window-links",()=>({contentByWindow:new Map,focusSeq:new Map,seq:0,listeners:new Set,lastGroupsSignature:"",manager:null,started:!1}));function G(e){return`${e.type}:${e.id}`}function _e(e){return e.root?G(e.root):G(e)}function Ie(e){return L.state.contentByWindow.get(e)}function Q(){const e=new Map;for(const[s,r]of L.state.contentByWindow){const l=_e(r);let c=e.get(l);c||(c={key:l,root:r.root?{...r.root}:{type:r.type,id:r.id},rootWindowIds:[],children:[]},e.set(l,c)),r.root?c.children.push({windowId:s,content:r}):c.rootWindowIds.push(s)}const o=L.state.focusSeq;for(const s of e.values())s.rootWindowIds.sort((r,l)=>(o.get(l)??0)-(o.get(r)??0));const t=Array.from(e.values()),n=H(N.WINDOW_LINK_GROUPS,t);return Array.isArray(n)?n:(typeof console<"u"&&console.warn("[openstation] `os.window-links.groups` filter returned a non-array; falling back to computed groups."),t)}function Ne(e){return Q().find(o=>o.rootWindowIds.includes(e)||o.children.some(t=>t.windowId===e))}function Oe(e){const o=new Set,t=Ne(e);if(t)for(const n of[...t.rootWindowIds,...t.children.map(s=>s.windowId)])o.add(n);for(const n of V())n.fromWindowId===e?o.add(n.toWindowId):n.toWindowId===e&&o.add(n.fromWindowId);return o.delete(e),Array.from(o)}function De(e){const o=new Set;for(const t of V())t.fromWindowId===e?o.add(t.toWindowId):t.toWindowId===e&&o.add(t.fromWindowId);return o.delete(e),Array.from(o)}function V(){const e=L.state.focusSeq,o=new Map;for(const[c,a]of L.state.contentByWindow){const i=G(a),f=o.get(i);(!f||(e.get(c)??0)>(e.get(f)??0))&&o.set(i,c)}const t=new Map,n=(c,a)=>`${c}→${a}`;for(const[c,a]of L.state.contentByWindow){if(a.root){const i=o.get(G(a.root));i&&i!==c&&t.set(n(c,i),{fromWindowId:c,toWindowId:i,kind:"child-root",bidirectional:!1})}for(const i of a.links??[]){const f=o.get(G(i));if(!f||f===c)continue;if(i.rel==="child"){const I=n(f,c),R=t.get(I);(!R||R.kind!=="child-root")&&t.set(I,{fromWindowId:f,toWindowId:c,kind:"child-root",bidirectional:!1});continue}const E=n(c,f);t.has(E)||t.set(E,{fromWindowId:c,toWindowId:f,kind:"reference",bidirectional:!1})}}const s=[],r=new Set;for(const[c,a]of t){if(r.has(c))continue;const i=n(a.toWindowId,a.fromWindowId),f=t.get(i);if(f&&a.kind==="reference"){if(f.kind==="reference"){r.add(i),s.push({...a,bidirectional:!0});continue}continue}s.push(a)}const l=H(N.WINDOW_LINK_EDGES,s);return Array.isArray(l)?l:(typeof console<"u"&&console.warn("[openstation] `os.window-links.edges` filter returned a non-array; falling back to derived edges."),s)}function pe(e){return L.state.listeners.add(e),()=>{L.state.listeners.delete(e)}}const b="none",Z="svg-splines",ee=J("desktop-mode/window-link-renderer-registry",()=>({registry:new Map,listeners:new Set})),oe=ee.state.registry,X=ee.state.listeners,te=/^[a-z0-9_/-]+$/;function Re(e){const o=[];!e||typeof e!="object"?o.push("def (not an object)"):(typeof e.id!="string"||e.id.trim()===""?o.push("id (missing)"):te.test(e.id.trim().toLowerCase())?e.id.trim().toLowerCase()===b&&o.push('id ("none" is reserved)'):o.push(`id (must match ${te} — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-id)`),(typeof e.label!="string"||e.label.trim()==="")&&o.push("label (missing)"),typeof e.mount!="function"&&o.push("mount (not a function)")),fe("WindowLinkRenderer",o,e);const t=e.id.trim().toLowerCase();oe.set(t,{...e,id:t}),ge()}function We(){const e=Array.from(oe.values()),o=H(N.WINDOW_LINK_RENDERERS,e);return Array.isArray(o)?o:(typeof console<"u"&&console.warn("[openstation] `os.window-links.renderers` filter returned a non-array; falling back to registry list."),e)}function j(e){return We().find(o=>o.id===e)}function he(e){return X.add(e),()=>{X.delete(e)}}function ge(){const e=Array.from(X);for(const o of e)try{o()}catch(t){typeof console<"u"&&console.error("[openstation] window-link-renderer registry listener threw:",t)}}const Ae="desktop-mode";function me(){return window.wp?.i18n}function ne(e,o=Ae){return me()?.__(e,o)??e}const Le=16;function Se(e,o){const t=o.map(r=>({start:Math.max(e.start,r.start),end:Math.min(e.end,r.end)})).filter(r=>r.end>r.start).sort((r,l)=>r.start-l.start),n=[];let s=e.start;for(const r of t)r.start>s&&n.push({start:s,end:r.start}),s=Math.max(s,r.end);return s<e.end&&n.push({start:s,end:e.end}),n}function ye(e,o){const t=e.x+e.width/2,n=e.y+e.height/2,s=o.x-t,r=o.y-n;if(s===0&&r===0)return{x:t,y:n,side:"right"};const l=s!==0?e.width/2/Math.abs(s):1/0,c=r!==0?e.height/2/Math.abs(r):1/0,a=Math.min(l,c),i=t+s*a,f=n+r*a;let E;return l<=c?E=s>0?"right":"left":E=r>0?"bottom":"top",{x:i,y:f,side:E}}function se(e,o,t,n){for(const s of t)if(!(s.windowId===n||s.zIndex<=o)&&e.x>=s.rect.x&&e.x<=s.rect.x+s.rect.width&&e.y>=s.rect.y&&e.y<=s.rect.y+s.rect.height)return!1;return!0}function Te(e,o,t,n,s){const r=t.filter(i=>i.windowId!==n&&i.zIndex>o),l=[{side:"top",base:{start:e.x,end:e.x+e.width},at:e.y,horizontal:!0},{side:"bottom",base:{start:e.x,end:e.x+e.width},at:e.y+e.height,horizontal:!0},{side:"left",base:{start:e.y,end:e.y+e.height},at:e.x,horizontal:!1},{side:"right",base:{start:e.y,end:e.y+e.height},at:e.x+e.width,horizontal:!1}];let c=null,a=1/0;for(const{side:i,base:f,at:E,horizontal:I}of l){const R=[];for(const{rect:_}of r)(I?_.y<=E&&E<=_.y+_.height:_.x<=E&&E<=_.x+_.width)&&R.push(I?{start:_.x,end:_.x+_.width}:{start:_.y,end:_.y+_.height});for(const _ of Se(f,R)){if(_.end-_.start<Le)continue;const W=(_.start+_.end)/2,p=I?W:E,h=I?E:W,y=Math.hypot(s.x-p,s.y-h);y<a&&(a=y,c={x:p,y:h,side:i})}}return c}function ke(e,o){const t=Math.max(o.x-(e.x+e.width),e.x-(o.x+o.width)),n=Math.max(o.y-(e.y+e.height),e.y-(o.y+o.height));if(t<0&&n<0)return null;const s=Math.max(e.x,o.x),r=Math.min(e.x+e.width,o.x+o.width),l=Math.max(e.y,o.y),c=Math.min(e.y+e.height,o.y+o.height);let a,i;r>=s?a=i=(s+r)/2:o.x>e.x?(a=e.x+e.width,i=o.x):(a=e.x,i=o.x+o.width);let f,E;c>=l?f=E=(l+c)/2:o.y>e.y?(f=e.y+e.height,E=o.y):(f=e.y,E=o.y+o.height);const I=t>=n,R=(_,W,p)=>I?W<=_.x?"left":"right":p<=_.y?"top":"bottom";return{from:{x:a,y:f,side:R(e,a,f)},to:{x:i,y:E,side:R(o,i,E)}}}function ie(e,o){const t=Math.min(160,Math.max(24,.4*o));switch(e.side){case"left":return{x:e.x-t,y:e.y};case"right":return{x:e.x+t,y:e.y};case"top":return{x:e.x,y:e.y-t};default:return{x:e.x,y:e.y+t}}}function Ce(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}const M="http://www.w3.org/2000/svg";let Pe=0;function re(e,o,t,n,s){const r=ye(e,s);return o===null||se(r,o,n,t)?r:Te(e,o,n,t,s)??r}function ve(e,o){const t=document.createElementNS(M,"defs"),n=(c,a,i)=>{const f=`${o}-${c}`,E=document.createElementNS(M,"marker");E.setAttribute("id",f),E.setAttribute("viewBox","0 0 10 10"),E.setAttribute("refX","5"),E.setAttribute("refY","5"),E.setAttribute("markerWidth",i),E.setAttribute("markerHeight",i),E.setAttribute("markerUnits","strokeWidth");const I=document.createElementNS(M,"circle");return I.setAttribute("cx","5"),I.setAttribute("cy","5"),I.setAttribute("r","4"),I.classList.add(a),E.appendChild(I),t.appendChild(E),f},s="os-window-link__endpoint",r=`${s}--active`,l={dot:{normal:n("dot",s,"7"),active:n("dot-active",r,"7")},port:{normal:n("port",s,"4.5"),active:n("port-active",r,"4.5")}};return e.appendChild(t),l}Re({id:"svg-splines",label:ne("Splines"),description:ne("Curved connectors between related windows, ending in circular dots — the larger dot sits on the window the content belongs to; windows that reference each other get large dots on both ends."),mount:e=>{const o=++Pe,t=(c,a)=>{const i=document.createElementNS(M,"svg");return i.classList.add("os-window-links__svg"),c.appendChild(i),{svg:i,markers:ve(i,`os-window-link-${o}${a}`)}},n={base:t(e.container,""),elevated:t(e.elevatedContainer,"-elevated")},s=new Map,r=c=>{for(const{svg:i}of[n.base,n.elevated])i.setAttribute("width",String(c.container.width)),i.setAttribute("height",String(c.container.height)),i.setAttribute("viewBox",`0 0 ${c.container.width} ${c.container.height}`);const a=new Set;for(const i of c.edges){if(!i.from||!i.to)continue;const f=`${i.fromWindowId}→${i.toWindowId}:${i.kind}`;a.add(f);const E=i.elevated?"elevated":"base";let I=s.get(f);if(I&&I.surface!==E&&(I.group.remove(),s.delete(f),I=void 0),!I){const g=document.createElementNS(M,"g");g.classList.add("os-window-link");const S=document.createElementNS(M,"path");S.classList.add("os-window-link__path"),g.appendChild(S),n[E].svg.appendChild(g),I={group:g,path:S,surface:E},s.set(f,I)}const R=c.obstacles??[],_=ke(i.from,i.to),W=(g,S,F)=>S===null||se(g,S,R,F);let p=null;_&&W(_.from,i.fromZIndex,i.fromWindowId)&&(p=_.from),p||(p=re(i.from,i.fromZIndex,i.fromWindowId,R,_?{x:_.to.x,y:_.to.y}:Ce(i.to)));let h=null;_&&W(_.to,i.toZIndex,i.toWindowId)&&(h=_.to),h||(h=re(i.to,i.toZIndex,i.toWindowId,R,{x:p.x,y:p.y}));const y=Math.hypot(h.x-p.x,h.y-p.y),x=ie(p,y),K=ie(h,y);I.path.setAttribute("d",`M ${p.x} ${p.y} C ${x.x} ${x.y}, ${K.x} ${K.y}, ${h.x} ${h.y}`);const T=n[I.surface].markers,m=i.focused?"active":"normal";I.path.setAttribute("marker-end",`url(#${T.dot[m]})`),I.path.setAttribute("marker-start",`url(#${i.bidirectional?T.dot[m]:T.port[m]})`),I.group.classList.toggle("os-window-link--active",i.focused)}for(const[i,f]of Array.from(s))a.has(i)||(f.group.remove(),s.delete(i))},l=e.onFrame(r);return r(e.getFrame()),()=>{l(),s.clear(),n.base.svg.remove(),n.elevated.svg.remove()}}});const de="os-window-links",ce="os-window--linked",ae="os-window-links--visible";let le=!1;function be({manager:e,osSettings:o}){if(le)return;le=!0;let t=o.getOsSettingsSnapshot(),n=null,s=null,r=null,l=null,c=0;const a=new Set;let i=!1;const f=new Set;let E=!1;const I=d=>{const w=d.element;return!w||!w.isConnected||d.state==="minimized"||w.offsetParent===null?null:{x:w.offsetLeft,y:w.offsetTop,width:w.offsetWidth,height:w.offsetHeight}},R=d=>d.state==="snapped-left"||d.state==="snapped-right"?null:I(d),_=()=>{const d=[];for(const u of Q()){if(u.rootWindowIds.length===0||u.children.length===0)continue;const O=[],P=(A,Me,Ee)=>{const B=e.getById(A);!B||!Ee||O.push({windowId:A,role:Me,content:Ee,rect:R(B),focused:B.isFocused(),state:B.state})};for(const A of u.rootWindowIds)P(A,"root",Ie(A));for(const A of u.children)P(A.windowId,"child",A.content);O.length>0&&d.push({key:u.key,root:u.root,members:O})}const w=u=>{const O=Number.parseInt(u.element?.style.zIndex||"",10);return Number.isFinite(O)?O:null},D=e.getFocused()?.id??null,k=[];for(const u of V()){const O=e.getById(u.fromWindowId),P=e.getById(u.toWindowId);if(!O||!P)continue;const A=O.isFocused()||P.isFocused();k.push({fromWindowId:u.fromWindowId,toWindowId:u.toWindowId,kind:u.kind,bidirectional:u.bidirectional,focused:A,from:R(O),to:R(P),fromZIndex:w(O),toZIndex:w(P),elevated:D!==null&&(u.fromWindowId===D||u.toWindowId===D)})}const C=[];for(const u of e.getAll()){const O=I(u);O&&C.push({windowId:u.id,rect:O,zIndex:w(u)??0})}return{groups:d,edges:k,obstacles:C,container:{width:n?.offsetWidth??0,height:n?.offsetHeight??0}}},W=()=>{i||a.size===0||(i=!0,requestAnimationFrame(()=>{if(i=!1,!r)return;const d=_();for(const w of Array.from(a))try{w(d)}catch(D){typeof console<"u"&&console.error("[openstation] window-link frame subscriber threw:",D)}}))},p=()=>{if(n&&n.isConnected&&s?.isConnected)return n;const d=document.getElementById("os-area");if(!d)return null;n=document.createElement("div"),n.id=de,n.className="os-window-links",n.setAttribute("aria-hidden","true"),s=document.createElement("div"),s.id=`${de}-elevated`,s.className="os-window-links os-window-links--elevated",s.setAttribute("aria-hidden","true");const w=document.getElementById("os-widgets");return w&&w.parentElement===d?(w.insertAdjacentElement("afterend",s),w.insertAdjacentElement("afterend",n)):d.prepend(n,s),n},h=()=>V().length>0,y=()=>{let d=t.windowLinkRenderer||Z;return d=H(N.WINDOW_LINK_RENDERER,d),d===b?b:j(d)?d:j(Z)?Z:b},x=()=>{if(c++,a.clear(),i=!1,l){try{l()}catch(d){$(N.SHELL_ERROR,{scope:"window-link-renderer-teardown",error:d})}l=null}r=null,n?.replaceChildren(),s?.replaceChildren()},K=d=>{const w=j(d),D=p();if(!w||!D||!s)return;r=d;const k=++c,C={container:D,elevatedContainer:s,getFrame:_,onFrame:u=>(a.add(u),()=>{a.delete(u)})};try{const u=w.mount(C);u instanceof Promise?u.then(O=>{if(k!==c){typeof O=="function"&&O();return}typeof O=="function"&&(l=O)}).catch(O=>{$(N.SHELL_ERROR,{scope:"window-link-renderer-mount",error:O}),k===c&&(r=null)}):typeof u=="function"&&(l=u)}catch(u){$(N.SHELL_ERROR,{scope:"window-link-renderer-mount",error:u}),r=null}W()},T=()=>{const d=e.getFocused();return d?new Set(Oe(d.id)):new Set},m=()=>t.windowLinksEnabled!==!1,g=()=>{if(!n)return;const d=!E&&m()&&(t.windowLinkVisibility==="always"||t.windowLinkVisibility==="focus"&&T().size>0);n.classList.toggle(ae,d),s?.classList.toggle(ae,d)},S=()=>{if(!m()||t.windowLinkRaiseOnFocus===!1||t.windowLinkVisibility==="off")return;const d=e.getFocused();if(d)for(const w of De(d.id)){const D=e.getById(w);D&&D.state!=="minimized"&&e.raise(w)}},F=()=>{if(!s)return;const d=e.getFocused(),w=T();if(!d||w.size===0||!m()||t.windowLinkVisibility==="off"){s.style.zIndex="";return}let D=-1/0;for(const k of[d.id,...w]){const C=e.getById(k),u=C?.element;if(!u||C.state==="minimized")continue;const O=Number.parseInt(u.style.zIndex||"",10);Number.isFinite(O)&&(D=Math.max(D,O))}s.style.zIndex=Number.isFinite(D)?String(D):""},Y=()=>{const d=m()&&t.windowLinkHighlight!==!1&&t.windowLinkVisibility!=="off"?T():new Set;for(const w of f)d.has(w)||e.getById(w)?.element?.classList.remove(ce);for(const w of d)e.getById(w)?.element?.classList.add(ce);f.clear();for(const w of d)f.add(w)},U=()=>{const d=m()&&t.windowLinkVisibility!=="off"&&h()?y():b;d===b?r&&x():d!==r&&(x(),K(d)),g(),Y(),F(),W()};v(N.WINDOW_BOUNDS_CHANGED,"desktop-mode/window-links-frame",()=>W());for(const d of[N.WINDOW_MOVED,N.WINDOW_RESIZED,N.WINDOW_MINIMIZED,N.WINDOW_RESTORED,N.WINDOW_MAXIMIZED,N.WINDOW_UNMAXIMIZED,N.WINDOW_FULLSCREEN_ENTERED,N.WINDOW_FULLSCREEN_EXITED,N.SNAP_ZONE_COMMITTED,N.SNAP_SPLIT_FILLED,N.DESKTOP_SWITCHED,N.SHELL_RESIZED])v(d,"desktop-mode/window-links-frame",()=>W());v(N.WINDOW_FOCUSED,"desktop-mode/window-links-focus",()=>{S(),g(),Y(),F(),W()}),v(N.WINDOW_BLURRED,"desktop-mode/window-links-blur",()=>{g(),Y(),F(),W()}),v(N.OVERVIEW_ENTERING,"desktop-mode/window-links-overview",()=>{E=!0,g()}),v(N.OVERVIEW_EXITED,"desktop-mode/window-links-overview",()=>{E=!1,g(),W()}),pe(U),he(U),o.subscribeOsSettings(d=>{const w=d.windowLinkRenderer!==t.windowLinkRenderer,D=w||d.windowLinkVisibility!==t.windowLinkVisibility||d.windowLinksEnabled!==t.windowLinksEnabled||d.windowLinkRaiseOnFocus!==t.windowLinkRaiseOnFocus||d.windowLinkHighlight!==t.windowLinkHighlight;t=d,D&&(w&&r&&x(),U())}),U()}window.openStationWindowLinkVisuals={start:be}})();