PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.11
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.11
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 0.8.8 All 35 releases
← All changes | assets/js/window-system.min.js +35 -21 0.9.8 → 1.1.11 View file →
@@ -1,6 +1,6 @@
1 -(function(){"use strict";function me(){const e=window.wp?.hooks;if(!e)throw new Error("[desktop-mode] `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 ht(e,t,n,o){me().addAction(e,t,n,o)}function mt(e,t){return me().removeAction(e,t)}function C(e,t,...n){return me().applyFilters(e,t,...n)}function h(e,...t){me().doAction(e,...t)}const u={INIT:"desktop-mode.init",WALLPAPERS:"desktop-mode.wallpapers",GAMES:"desktop-mode.games",UNFOCUS_EFFECTS:"desktop-mode.unfocus-effects",WINDOW_REVEALS:"desktop-mode.window-reveals",WALLPAPER_MOUNTING:"desktop-mode.wallpaper.mounting",WALLPAPER_MOUNTED:"desktop-mode.wallpaper.mounted",WALLPAPER_UNMOUNTING:"desktop-mode.wallpaper.unmounting",WALLPAPER_MOUNT_FAILED:"desktop-mode.wallpaper.mount-failed",WALLPAPER_VISIBILITY:"desktop-mode.wallpaper.visibility",WALLPAPER_SUSPEND:"desktop-mode.wallpaper.suspend",WALLPAPER_PREVIEW_PARAMS:"desktop-mode.wallpaper.preview-params",WALLPAPER_SETTINGS_CHANGED:"desktop-mode.wallpaper.settings-changed",IFRAME_READY:"desktop-mode.iframe.ready",IFRAME_ERROR:"desktop-mode.iframe.error",IFRAME_NETWORK_COMPLETED:"desktop-mode.iframe.network-completed",SHELL_ERROR:"desktop-mode.shell.error",BROADCAST:"desktop-mode.broadcast",MONITOR_ENTRY:"desktop-mode.monitor.entry",WALLPAPER_SURFACES:"desktop-mode.wallpaper.surfaces",DESKTOP_THEME_CHANGED:"desktop-mode.desktop-theme.changed",DESKTOP_THEME_ICON:"desktop-mode.desktop-theme.icon",DESKTOP_THEME_ICON_COLOR:"desktop-mode.desktop-theme.icon-color",WALLPAPERS_SERVER_CHANGED:"desktop-mode.wallpapers.server-changed",WINDOW_GEOMETRY:"desktop-mode.window.geometry",WINDOW_OPENED:"desktop-mode.window.opened",WINDOW_CONTENT_LOADING:"desktop-mode.window.content-loading",WINDOW_CONTENT_LOADED:"desktop-mode.window.content-loaded",WINDOW_LOADING_OVERLAY:"desktop-mode.window.loading-overlay",WINDOW_REOPENED:"desktop-mode.window.reopened",WINDOW_CLOSING:"desktop-mode.window.closing",WINDOW_CLOSED:"desktop-mode.window.closed",WINDOW_FOCUSED:"desktop-mode.window.focused",WINDOW_BLURRED:"desktop-mode.window.blurred",WINDOW_MINIMIZED:"desktop-mode.window.minimized",WINDOW_RESTORED:"desktop-mode.window.restored",WINDOW_MAXIMIZED:"desktop-mode.window.maximized",WINDOW_UNMAXIMIZED:"desktop-mode.window.unmaximized",WINDOW_FULLSCREEN_ENTERED:"desktop-mode.window.fullscreen-entered",WINDOW_FULLSCREEN_EXITED:"desktop-mode.window.fullscreen-exited",WINDOW_AUTO_EXIT_FULLSCREEN:"desktop-mode.window.auto-exit-fullscreen",WINDOW_FOCUS_ON_DRAG_HOVER:"desktop-mode.window.focus-on-drag-hover",WINDOW_BOUNDS_CHANGED:"desktop-mode.window.bounds-changed",WINDOW_MOVED:"desktop-mode.window.moved",WINDOW_RESIZED:"desktop-mode.window.resized",WINDOW_DRAG_START:"desktop-mode.window.drag-start",WINDOW_DRAG_END:"desktop-mode.window.drag-end",WINDOW_RESIZE_START:"desktop-mode.window.resize-start",WINDOW_RESIZE_END:"desktop-mode.window.resize-end",WINDOW_DETACHED:"desktop-mode.window.detached",WINDOW_RELOADED:"desktop-mode.window.reloaded",WINDOW_TITLE_CHANGED:"desktop-mode.window.title-changed",WINDOW_HIGHLIGHT_CHANGED:"desktop-mode.window.highlight-changed",WINDOW_BODY_RESIZED:"desktop-mode.window.body-resized",NATIVE_WINDOW_BEFORE_RENDER:"desktop-mode.native-window.before-render",NATIVE_WINDOW_AFTER_RENDER:"desktop-mode.native-window.after-render",NATIVE_WINDOW_BEFORE_CLOSE:"desktop-mode.native-window.before-close",WINDOW_CHROME_THEME:"desktop-mode.window.chrome.theme",WINDOW_CHROME_CONTROLS:"desktop-mode.window.chrome.controls",WINDOW_CHROME_SLOT:"desktop-mode.window.chrome.slot",WINDOW_CHROME_RENDER:"desktop-mode.window.chrome.render",WINDOW_CHROME_APPLIED:"desktop-mode.window.chrome.applied",WINDOW_CHROME_THEME_CHANGED:"desktop-mode.window.chrome.theme-changed",DESKTOP_ICON_CLICKED:"desktop-mode.desktop-icon.clicked",DESKTOP_ICONS_RENDERED:"desktop-mode.desktop-icons.rendered",ICON_BADGE_CHANGED:"desktop-mode.icon.badge-changed",COMPONENTS_REGISTERED:"desktop-mode.components.registered",DOCK_ITEM_APPENDED:"desktop-mode.dock.item-appended",DOCK_ITEM_REMOVED:"desktop-mode.dock.item-removed",DOCK_BEFORE_RENDER:"desktop-mode.dock.before-render",DOCK_AFTER_RENDER:"desktop-mode.dock.after-render",DOCK_TILE_CLASS:"desktop-mode.dock.tile-class",DOCK_TILE_ELEMENT:"desktop-mode.dock.tile-element",DOCK_TILE_RENDERED:"desktop-mode.dock.tile-rendered",DOCK_TILE_TOOLTIP:"desktop-mode.dock.tile-tooltip",DOCK_PEEK_CARD_CONTENT:"desktop-mode.dock.peek-card-content",DOCK_PEEK_CARD_ELEMENT:"desktop-mode.dock.peek-card-element",OVERVIEW_ENTERING:"desktop-mode.overview.entering",OVERVIEW_ENTERED:"desktop-mode.overview.entered",OVERVIEW_EXITING:"desktop-mode.overview.exiting",OVERVIEW_EXITED:"desktop-mode.overview.exited",OVERVIEW_WINDOW_HOVER:"desktop-mode.overview.window-hover",OVERVIEW_WINDOW_UNHOVER:"desktop-mode.overview.window-unhover",OVERVIEW_WINDOW_CLICK:"desktop-mode.overview.window-click",ARRANGE_CASCADE_STARTING:"desktop-mode.arrange.cascade.starting",ARRANGE_CASCADE_APPLIED:"desktop-mode.arrange.cascade.applied",ARRANGE_TILE_STARTING:"desktop-mode.arrange.tile.starting",ARRANGE_TILE_APPLIED:"desktop-mode.arrange.tile.applied",ARRANGE_TILE_DIMENSIONS:"desktop-mode.arrange.tile.dimensions",ARRANGE_SNAP_CHANGED:"desktop-mode.arrange.snap.changed",ARRANGE_SNAP_CELL_SIZE:"desktop-mode.arrange.snap.cell-size",ARRANGE_CUSTOM_ACTION:"desktop-mode.arrange.custom-action",SNAP_ZONE_PENDING:"desktop-mode.snap.zone-pending",SNAP_ZONE_CANCELED:"desktop-mode.snap.zone-canceled",SNAP_ZONE_COMMITTED:"desktop-mode.snap.zone-committed",SNAP_SPLIT_FILLED:"desktop-mode.snap.split-filled",WIDGETS:"desktop-mode.widgets",WIDGET_MOUNTING:"desktop-mode.widget.mounting",WIDGET_MOUNTED:"desktop-mode.widget.mounted",WIDGET_UNMOUNTING:"desktop-mode.widget.unmounting",WIDGET_MOUNT_FAILED:"desktop-mode.widget.mount-failed",WIDGET_ADDED:"desktop-mode.widget.added",WIDGET_REMOVED:"desktop-mode.widget.removed",DESKTOP_CREATED:"desktop-mode.desktop.created",DESKTOP_CLOSED:"desktop-mode.desktop.closed",DESKTOP_SWITCHED:"desktop-mode.desktop.switched",PRIMARY_DESKTOP_ID:"desktop-mode.primary-desktop-id",WINDOWS_BEFORE_CLOSE_ALL:"desktop-mode.windows.before-close-all",WINDOWS_CLOSE_ALL:"desktop-mode.windows.close-all",WINDOWS_AFTER_CLOSE_ALL:"desktop-mode.windows.after-close-all",COMMAND_BEFORE_RUN:"desktop-mode.command.before-run",COMMAND_AFTER_RUN:"desktop-mode.command.after-run",COMMAND_ERROR:"desktop-mode.command.error",SHELL_RESIZED:"desktop-mode.shell.resized",SHELL_VISIBILITY:"desktop-mode.shell.visibility",CONNECTION_OPENED:"desktop-mode.connection.opened",CONNECTION_CLOSED:"desktop-mode.connection.closed",CONNECTION_MESSAGE:"desktop-mode.connection.message",IFRAME_CONNECTION_REQUEST:"desktop-mode.iframe.connection-request",WINDOW_CONTENT_CHANGED:"desktop-mode.window-links.content-changed",WINDOW_LINK_GROUPS_CHANGED:"desktop-mode.window-links.groups-changed",WINDOW_LINKS_CONTENT:"desktop-mode.window-links.content",WINDOW_LINK_GROUPS:"desktop-mode.window-links.groups",WINDOW_LINK_EDGES:"desktop-mode.window-links.edges",RELATED_ENTITIES_ITEMS:"desktop-mode.related-entities.items",WINDOW_LINK_RENDERERS:"desktop-mode.window-links.renderers",WINDOW_LINK_RENDERER:"desktop-mode.window-links.renderer",EDITOR_PREVIEW_WINDOW_CONFIG:"desktop-mode.editor-preview.window-config",EDITOR_PREVIEW_LIVE:"desktop-mode.editor-preview.live",EDITOR_PREVIEW_OPENED:"desktop-mode.editor-preview.opened",EDITOR_PREVIEW_CLOSED:"desktop-mode.editor-preview.closed",FILE_DROP_FILES_DETECTED:"desktop-mode.drop.files-detected",FILE_DROP_FILES_REJECTED:"desktop-mode.drop.files-rejected",FILE_DROP_DIALOG_FIELDS:"desktop-mode.drop.dialog-fields",FILE_DROP_BEFORE_UPLOAD:"desktop-mode.drop.before-upload",FILE_DROP_UPLOAD_STARTED:"desktop-mode.drop.upload-started",FILE_DROP_UPLOAD_PROGRESS:"desktop-mode.drop.upload-progress",FILE_DROP_AFTER_UPLOAD:"desktop-mode.drop.after-upload",FILE_DROP_UPLOAD_FAILED:"desktop-mode.drop.upload-failed",AUTH_LOST:"desktop-mode.auth.lost",AUTH_RESTORED:"desktop-mode.auth.restored"},qn="desktop-mode.activity.";function We(e){return`${qn}${String(e)}`}let Vn=0;const Me={publish(e,t){h(We(e),t)},subscribe(e,t){const n=`desktop-mode/activity-sub/${++Vn}`,o=We(e);ht(o,n,i=>t(i));let s=!1;return()=>{s||(s=!0,mt(o,n))}},filter(e,t,...n){return C(We(e),t,...n)}},Pe=new Map,$e=new Map;function fe(e,t,n,o){let s=e.get(t);if(!s){if(!o)return;s=new Map,e.set(t,s)}let i=s.get(n);if(!i){if(!o)return;i=new Set,s.set(n,i)}return i}function ft(e,t,n,o){const s={channel:n,windowId:t},i=fe(e,t,n,!1);if(i)for(const l of Array.from(i))try{l(o,s)}catch(d){typeof console<"u"&&console.error(`[desktop-mode] window-channel subscriber for "${n}" threw:`,d)}const r=fe(e,t,"*",!1);if(r)for(const l of Array.from(r))try{l(o,s)}catch(d){typeof console<"u"&&console.error(`[desktop-mode] window-channel wildcard subscriber for "${t}" threw:`,d)}}function jn(e,t,n){const o=fe(Pe,e,t,!0);o.add(n);let s=!1;return()=>{s||(s=!0,o.delete(n))}}function wt(e,t,n){ft(Pe,e,t,n)}function Kn(e,t,n){const o=fe($e,e,t,!0);o.add(n);let s=!1;return()=>{s||(s=!0,o.delete(n))}}function Xn(e,t,n){ft($e,e,t,n)}const we=new Set,ge=new Set,te=new Map;function gt(e){return we.has(e)}function _e(e){ge.has(e)||(ge.add(e),h(u.WINDOW_CONTENT_LOADING,{windowId:e}),typeof document<"u"&&document.dispatchEvent(new CustomEvent("desktop-mode-window-content-loading",{detail:{windowId:e}})))}function P(e){if(!we.has(e)){we.add(e);const t=te.get(e);if(t){te.delete(e);for(const n of t)try{n.flush()}catch(o){typeof console<"u"&&console.error(`[desktop-mode] flushing queued window-send for "${n.channel}" threw:`,o)}}}ge.delete(e)&&(h(u.WINDOW_CONTENT_LOADED,{windowId:e}),typeof document<"u"&&document.dispatchEvent(new CustomEvent("desktop-mode-window-content-loaded",{detail:{windowId:e}})))}function Yn(e,t,n,o){let s=te.get(e);s||(s=[],te.set(e,s)),s.push({channel:t,payload:n,flush:o})}function Zn(e){Pe.delete(e),$e.delete(e),we.delete(e),ge.delete(e),te.delete(e)}const Qn=new Map;function Jn(e){return Qn.get(e)??null}const eo="desktop-mode";function _t(){return window.wp?.i18n}function g(e,t=eo){return _t()?.__(e,t)??e}function He(e,...t){const n=_t()?.sprintf;if(n)return n(e,...t);let o=0;return e.replace(/%(?:(\d+)\$)?[sd]/g,(s,i)=>{const r=i?Number.parseInt(i,10)-1:o++;return String(t[r]??"")})}let to=0;function no(e){const t=++to,n=a=>`desktop-mode/native-render-ctx/${e}/${t}/${a}`,o=new AbortController,s=[],i=(a,c,p,m)=>{const f=n(c);ht(a,f,S=>{p(S)&&m(S)});const _=()=>{mt(a,f)};return s.push(_),_},r=a=>!!a&&typeof a=="object"&&a.windowId===e;return{ctx:{window:{send(a,c){typeof a!="string"||a===""||wt(e,a,c)},on(a,c){return typeof a!="string"||a===""||typeof c!="function"?()=>{}:Kn(e,a,c)},markLoading(){_e(e)},markReady(){P(e)}},markLoading(){_e(e)},markReady(){P(e)},signal:o.signal,onResize(a){return typeof a!="function"?()=>{}:i(u.WINDOW_BODY_RESIZED,"on-resize",r,c=>{const{width:p,height:m}=c;try{a(p,m)}catch(f){h(u.SHELL_ERROR,{scope:"native-render-ctx/onResize",id:e,error:f})}})},onHide(a){return typeof a!="function"?()=>{}:i(u.WINDOW_MINIMIZED,"on-hide",r,()=>{try{a()}catch(c){h(u.SHELL_ERROR,{scope:"native-render-ctx/onHide",id:e,error:c})}})},onShow(a){return typeof a!="function"?()=>{}:i(u.WINDOW_RESTORED,"on-show",r,()=>{try{a()}catch(c){h(u.SHELL_ERROR,{scope:"native-render-ctx/onShow",id:e,error:c})}})}},dispose:()=>{try{o.abort()}catch{}for(;s.length;){const a=s.pop();try{a?.()}catch{}}}}}const oo=["post_type","page","taxonomy","path","post","c","tag_ID","item","p"];function bt(e){try{const t=new URL(e,window.location.origin),n=new URLSearchParams;for(const s of oo){const i=t.searchParams.get(s);i&&n.set(s,i)}n.sort();const o=n.toString();return t.pathname.replace(/\/+$/,"")+(o?`?${o}`:"")}catch{return e}}function U(e){try{const t=new URL(e,window.location.origin);return t.searchParams.delete("desktop_mode_chromeless"),t.searchParams.delete("desktop_mode_portal"),t.pathname.replace(/\/+$/,"")+"?"+t.searchParams.toString()}catch{return e}}function so(e){if(!e)return 214;let t=5381;for(let n=0;n<e.length;n++)t=Math.imul(t,33)+e.charCodeAt(n);return(t%360+360)%360}const yt="__desktopModeSharedStores";function io(){const e=window;let t=e[yt];return t||(t=new Map,e[yt]=t),t}function x(e,t){const n=io();let o=n.get(e);o||(o={state:t(),listeners:new Set,rebuild:t},n.set(e,o));const s={get state(){return o.state},set state(i){o.state=i},getState(){return o.state},notify(){for(const i of Array.from(o.listeners))try{i(o.state)}catch(r){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,r)}},subscribe(i){return o.listeners.add(i),()=>{o.listeners.delete(i)}},setState(i){const r=o.state;if(typeof r!="object"||r===null){console.warn(`[desktop-mode/shared-store:${e}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(r,i),s.notify()},reset(){const i=o.rebuild(),r=o.state;if(typeof r=="object"&&r!==null&&typeof i=="object"&&i!==null){const l=r;for(const d of Object.keys(l))delete l[d];Object.assign(l,i)}else o.state=i;o.listeners.clear()}};return s}const vt=x("desktop-mode/dock-rail-registry",()=>({registry:new Map,listeners:new Set,activeId:"default"}));vt.state.registry,vt.state.listeners;function ro(e,t){if(!e||typeof e!="object")return["def (not an object)"];const n=e,o=[];for(const s of t)s.valid(n)||o.push(`${s.field} (${s.message})`);return o}class ao extends Error{constructor(t,n,o){super(`[desktop-mode] ${t} registration rejected — fields: `+n.join(", ")+"."),this.name="RegistrationError",this.kind=t,this.errors=n,this.def=o}}function ze(e,t,n){if(t.length!==0)throw new ao(e,t,n)}function kt(e,t,n){typeof console>"u"||console.warn(`[desktop-mode] ${e} registration rejected — fields: `+t.join(", ")+".",n)}const F=[[0,0],[100,0],[100,100],[0,100]],lo=48,co=80,Ue=6,Fe=8,Et=4,At=3,St=64,Be=105,B=2;function Ct(e){return`${Math.round(e*1e3)/1e3}%`}function G(e){return e.slice().reverse()}function ne(e,t,n,o){return[[e,t],[n,t],[n,o],[e,o]]}function uo(e,t,n,o){const s=[];for(let i=0;i<o;i++){const r=i/o*Math.PI*2;s.push([e+Math.cos(r)*n,t+Math.sin(r)*n])}return s}function W(e,t=[]){const n=[],o=s=>{n.push(`${Ct(s[0])} ${Ct(s[1])}`)};for(const s of e)o(s);if(t.length>0){o(e[0]);for(const s of t){for(const i of s)o(i);o(s[0]),o(e[0])}}return`polygon( ${n.join(", ")} )`}function It(e){return W(F,[G(uo(50,50,e,lo))])}function Lt(e){return W(F,[G(ne(50-e,-B,50+e,100+B))])}function Tt(e){const t=100/Ue,n=[];for(let o=0;o<Ue;o++){const s=o*t;n.push(G(ne(-B,s,100+B,s+e)))}return W(F,n)}function Rt(e){return W(F,[G(ne(-B,50-e,100+B,50+e))])}function xt(e){const t=100/Fe,n=[];for(let o=0;o<Fe;o++){const s=o*t;n.push(G(ne(s,-B,s+e,100+B)))}return W(F,n)}function Ot(e){return W(F,[G([[50,50-e],[50+e,50],[50,50+e],[50-e,50]])])}function Nt(e){const t=100/Et,n=100/At,o=[];for(let s=0;s<At;s++)for(let i=0;i<Et;i++){const r=i*t+t/2,l=s*n+n/2,d=t/2*e,a=n/2*e;o.push(G(ne(r-d,l-a,r+d,l+a)))}return W(F,o)}function Dt(e){const t=-Math.PI/2,n=e/180*Math.PI,o=[[50,50]];for(let s=0;s<St;s++){const i=t+s/(St-1)*n;o.push([50+Math.cos(i)*Be,50+Math.sin(i)*Be])}return W(F,[G(o)])}function po(){return{from:It(0),to:It(co)}}function ho(){return{from:Lt(0),to:Lt(52)}}function mo(){return{from:Tt(0),to:Tt(100/Ue+.5)}}function fo(){return{from:Rt(0),to:Rt(52)}}function wo(){return{from:xt(0),to:xt(100/Fe+.5)}}function go(){return{from:Ot(0),to:Ot(Be)}}function _o(){return{from:Nt(0),to:Nt(1.04)}}function bo(){return{from:Dt(0),to:Dt(360)}}function yo(){return{from:"inset( 0% 0% 0% 0% )",to:"inset( 0% 0% 100% 0% )"}}function vo(){return{from:"inset( 0% 0% 0% 0% )",to:"inset( 0% 0% 0% 100% )"}}function ko(){return{from:W([[-60,0],[100,0],[100,100],[0,100]]),to:W([[100,0],[260,0],[260,100],[160,100]])}}const Ge=6,qe=100,Q=qe/2,be=200,Wt=90,Mt=["#5c5c6d","#525261","#484855","#3e3e49","#34343d","#2a2a31"],Eo="#101014",Ao=1.25,J="http://www.w3.org/2000/svg";let So=0;function ye(e){return Math.round(e*1e3)/1e3}function Ve(e){return e/Ge*Math.PI*2-Math.PI/2}function Co(e){const n=Ve(e)+Math.PI/Ge+Math.PI/2;return{x:Math.cos(n),y:Math.sin(n)}}function Io(e){const t=Ve(e),n=Ve(e+1);return[[Q,Q],[Q+Math.cos(t)*be,Q+Math.sin(t)*be],[Q+Math.cos(n)*be,Q+Math.sin(n)*be]]}function Pt(e,t){const n=Io(e),o=document.createElementNS(J,"path");return o.setAttribute("d",`M ${n.map(([s,i])=>`${ye(s)} ${ye(i)}`).join(" L ")} Z`),t?o.setAttribute("fill","#fff"):(o.setAttribute("fill",Mt[e%Mt.length]),o.setAttribute("stroke",Eo),o.setAttribute("stroke-width",String(Ao)),o.setAttribute("vector-effect","non-scaling-stroke"),o.setAttribute("stroke-linejoin","round")),o}function Lo(){const e=`desktop-mode-iris-${++So}`,t=document.createElementNS(J,"svg");t.setAttribute("viewBox",`0 0 ${qe} ${qe}`),t.setAttribute("preserveAspectRatio","none"),t.setAttribute("aria-hidden","true"),t.style.width="100%",t.style.height="100%",t.style.display="block";const n=document.createElementNS(J,"defs"),o=document.createElementNS(J,"mask");o.setAttribute("id",e);const s=document.createElementNS(J,"g"),i=document.createElementNS(J,"g");i.setAttribute("mask",`url(#${e})`);const r=[];for(let d=0;d<Ge;d++){const a=Pt(d,!0),c=Pt(d,!1);s.appendChild(a),i.appendChild(c),r.push({el:a,index:d},{el:c,index:d})}o.appendChild(s),n.appendChild(o),t.appendChild(n),t.appendChild(i);const l=document.createElement("div");return l.appendChild(t),{element:l,play:d=>r.map(({el:a,index:c})=>{const p=Co(c),m=ye(p.x*Wt),f=ye(p.y*Wt);return a.animate([{transform:"translate( 0px, 0px )"},{transform:`translate( ${m}px, ${f}px )`}],{duration:d.duration,easing:d.easing,delay:d.delay,fill:"both"})})}}const je="none",To=70,Ro=600,$t=x("desktop-mode/window-reveal-registry",()=>({registry:new Map,listeners:new Set})),Ht=$t.state.registry,xo=$t.state.listeners,zt=/^[a-z0-9_/-]+$/;function Ut(e){const t=/^\s*([a-zA-Z-]+)\s*\(/.exec(e);return t?t[1].toLowerCase():""}const Oo=0;function No(e){return typeof e!="number"||!Number.isFinite(e)?To:Math.min(Ro,Math.max(0,e))}function Do(e){return typeof e.render=="function"?[]:Array.isArray(e.layers)&&e.layers.length>0?e.layers:typeof e.from=="string"&&typeof e.to=="string"?[{from:e.from,to:e.to}]:[]}function Ft(e,t){const n=[],o=typeof e.from=="string"&&e.from.trim()!=="",s=typeof e.to=="string"&&e.to.trim()!=="";if(o||n.push(`${t}.from (missing — the clip-path covering the window)`),s||n.push(`${t}.to (missing — the clip-path uncovering the window)`),o&&s){const i=Ut(e.from),r=Ut(e.to);i===""||r===""?n.push(`${t}.from|to (must be shape functions, e.g. \`inset( … )\` or \`polygon( … )\` — bare keywords like \`none\` cannot be animated)`):i!==r&&n.push(`${t}.from|to (must use the same shape function to interpolate — got \`${i}()\` and \`${r}()\`)`)}return n}function Wo(e){if(typeof KeyframeEffect!="function")return!0;try{return new KeyframeEffect(null,null,{easing:e}),!0}catch{return!1}}function D(e){const t=[];if(!e||typeof e!="object")t.push("def (not an object)");else{typeof e.id!="string"||e.id.trim()===""?t.push("id (missing)"):zt.test(e.id.trim().toLowerCase())?e.id.trim().toLowerCase()===je&&t.push('id ("none" is reserved)'):t.push(`id (must match ${zt} — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-id)`),(typeof e.label!="string"||e.label.trim()==="")&&t.push("label (missing)");const o=e.render!==void 0,s=Array.isArray(e.layers),i=e.from!==void 0||e.to!==void 0;o&&typeof e.render!="function"?t.push("render (not a function)"):o&&(s||i)?t.push("render|layers|from|to (supply exactly one of: a from/to pair, a layers array, or a render function)"):o||(s&&i?t.push("layers|from|to (supply EITHER a single from/to pair OR a layers array, not both)"):s?(e.layers.length===0&&t.push("layers (empty — supply at least one matched pair)"),e.layers.forEach((r,l)=>{if(!r||typeof r!="object"){t.push(`layers[ ${l} ] (not an object)`);return}t.push(...Ft(r,`layers[ ${l} ]`))})):t.push(...Ft(e,"").map(r=>r.replace(/^\./,"")))),e.easing!==void 0&&(typeof e.easing!="string"||e.easing.trim()===""?t.push("easing (not a non-empty string)"):Wo(e.easing)||t.push("easing (not an easing the browser can parse — `Element.animate()` would throw at play time, with the covering surface already over the window)"))}ze("WindowReveal",t,e);const n=e.id.trim().toLowerCase();Ht.set(n,{...e,id:n}),$o()}function Mo(){const e=Array.from(Ht.values()),t=C(u.WINDOW_REVEALS,e);return Array.isArray(t)?t:(typeof console<"u"&&console.warn("[desktop-mode] `desktop-mode.window-reveals` filter returned a non-array; falling back to registry list."),e)}function Po(e){return Mo().find(t=>t.id===e)}function $o(){const e=Array.from(xo);for(const t of e)try{t()}catch(n){typeof console<"u"&&console.error("[desktop-mode] window-reveal registry listener threw:",n)}}D({id:"sweep",label:g("Sweep"),description:g("A straight edge travels across the window, uncovering the page behind it."),...vo(),duration:420}),D({id:"iris",label:g("Iris"),description:g("The page opens out from the centre of the window, like a camera shutter."),...po(),duration:520}),D({id:"curtain",label:g("Curtain"),description:g("Two panels part from the middle of the window and slide off the sides."),...ho(),duration:480}),D({id:"blinds",label:g("Blinds"),description:g("Six horizontal slats retract at once, letting the page through between them."),...mo(),duration:560}),D({id:"diagonal",label:g("Diagonal"),description:g("A slanted edge sweeps off the trailing corner of the window."),...ko(),duration:460}),D({id:"rise",label:g("Rise"),description:g("The page rises into the window from the bottom edge upward."),...yo(),duration:440}),D({id:"shutter",label:g("Shutter"),description:g("Two panels part from the middle of the window and slide off the top and bottom."),...fo(),duration:480}),D({id:"slats",label:g("Slats"),description:g("Eight vertical slats retract at once, letting the page through between them."),...wo(),duration:560}),D({id:"diamond",label:g("Diamond"),description:g("The page opens out from the centre of the window through a growing rhombus."),...go(),duration:520}),D({id:"mosaic",label:g("Mosaic"),description:g("The page arrives as a grid of tiles, each opening out from its own centre."),..._o(),duration:600}),D({id:"obturator",label:g("Camera shutter"),description:g("Six wedges slide aside in unison, opening a hexagonal aperture from the centre like the iris of a camera lens."),render:Lo,duration:720,edgeLag:0}),D({id:"radar",label:g("Radar"),description:g("A spoke sweeps a full turn around the centre of the window, uncovering the page behind it."),...bo(),duration:760});const Bt={dockSize:["compact","default","large"],desktopLayout:["classic","unified","spatial"],windowRadius:["sharp","default","round"],adminBarMode:["static","dynamic","hidden"]},Gt=["dockRailRenderer","windowReveal"],qt={windowRevealDuration:{min:80,max:4e3}},Ho=/^[a-z0-9_-]+$/;[...Object.keys(Bt),...Gt,...Object.keys(qt)];function zo(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t=e,n={},o={};for(const[s,i]of Object.entries(Bt)){const r=t[s];typeof r=="string"&&i.includes(r)&&(n[s]=r)}for(const s of Gt){const i=t[s];typeof i=="string"&&Ho.test(i)&&(n[s]=i)}for(const[s,i]of Object.entries(qt)){const r=t[s];typeof r=="number"&&Number.isFinite(r)&&(o[s]=Math.min(i.max,Math.max(i.min,Math.round(r))))}return{...n,...o}}const Uo=/^[a-z0-9_-]+$/,Vt=128;function Fo(e){return typeof e!="string"||e===""||e.length>2048?!1:e.startsWith("dashicons-")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("data:image/")}function Bo(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.slug=="string"?t.slug:"";if(!Uo.test(n))return null;const o={};if(t.icons&&typeof t.icons=="object"){let d=0;for(const[a,c]of Object.entries(t.icons)){if(d>=Vt)break;a===""||!Fo(c)||(o[a]=c,d+=1)}}const s={};if(t.tokens&&typeof t.tokens=="object")for(const[d,a]of Object.entries(t.tokens))typeof a=="string"&&(s[d]=a);const i=[];if(Array.isArray(t.fonts))for(const d of t.fonts)typeof d=="string"&&d!==""&&i.push(d);const r={};if(t.iconColors&&typeof t.iconColors=="object"){let d=0;for(const[a,c]of Object.entries(t.iconColors)){if(d>=Vt)break;a===""||typeof c!="string"||c===""||(r[a]=c,d+=1)}}const l=d=>typeof t[d]=="string"?t[d]:"";return{id:l("id")||n,slug:n,name:l("name")||n,version:l("version"),author:l("author"),description:l("description"),previewUrl:l("previewUrl"),cssUrl:l("cssUrl"),cssText:l("cssText"),tokens:s,fonts:i,icons:o,iconColors:r,recommendedOsSettings:zo(t.recommendedOsSettings),installedAt:typeof t.installedAt=="number"?t.installedAt:0,source:t.source==="code"?"code":"upload"}}function Go(){const t=window.desktopModeConfig?.serverDesktopThemes,n=[];if(Array.isArray(t))for(const o of t){const s=Bo(o);s&&n.push(s)}return{themes:n,activeId:null,activeIcons:null,activeIconColors:null}}const qo=x("desktop-mode/desktop-themes",Go);function jt(){return qo}function Kt(e){const t=jt().state;if(t.activeIcons===null||!e)return null;const n=t.activeIcons[e];if(typeof n!="string"||n==="")return null;const o=C(u.DESKTOP_THEME_ICON,n,{slot:e,themeId:t.activeId??""});return typeof o=="string"&&o!==""?o:null}function Xt(e){const t=jt().state;if(t.activeIconColors===null||!e)return null;const n=t.activeIconColors[e];if(typeof n!="string"||n==="")return null;const o=C(u.DESKTOP_THEME_ICON_COLOR,n,{slot:e,themeId:t.activeId??""});return typeof o=="string"&&o!==""?Vo(o):null}function Vo(e){const t=e.trim();if(t===""||t.length>64||/[;{}<>"'\\]/.test(t))return null;let n=0;for(const o of t)if(o==="(")n+=1;else if(o===")"&&(n-=1,n<0))return null;return n===0?t:null}function jo(e){return typeof e!="string"||e===""||e.length>4096||!/^(https?:\/\/|data:image\/)/i.test(e)?!1:!/['"()\\<>\s]/.test(e)}function Yt(e,t,n){if(!jo(t))return!1;const o=`url("${t}") center / contain no-repeat`;return e.style.backgroundImage="none",e.style.backgroundColor=n,e.style.setProperty("-webkit-mask",o),e.style.setProperty("mask",o),!0}const Zt="data:image/svg+xml;base64,",ve=new Map;function Ko(e){const t=ve.get(e);if(t!==void 0)return t;let n=!1;try{n=atob(e.slice(Zt.length)).includes("currentColor")}catch{}return ve.size>=256&&ve.clear(),ve.set(e,n),n}function Qt(e,t){const n=t.className??"",o=t.title??"";let s=null;if(t.slot){const d=Kt(t.slot);d!==null&&(e=d),s=Xt(t.slot)}if(typeof e=="string"&&e.startsWith("dashicons-")){const d=document.createElement("span");return d.className=`dashicons ${e} ${n}`.trim(),d.setAttribute("aria-hidden","true"),s!==null&&(d.style.color=s),d}if(s!==null&&typeof e=="string"){const d=document.createElement("span");if(d.className=n,d.setAttribute("aria-hidden","true"),d.style.display="inline-block",Yt(d,e,s))return d}if(typeof e=="string"&&e.startsWith("data:image/svg+xml;base64,")){const d=e.slice(Zt.length);if(/^[A-Za-z0-9+/=]+$/.test(d)){const a=document.createElement("span");return a.className=n,a.setAttribute("aria-hidden","true"),a.style.display="inline-block",Ko(e)&&Yt(a,e,"currentColor")||(a.style.backgroundImage=`url("${e}")`,a.style.backgroundRepeat="no-repeat",a.style.backgroundPosition="center",a.style.backgroundSize="contain"),a}}if(typeof e=="string"&&/^data:image\/(png|jpeg|jpg|gif|webp|x-icon|vnd\.microsoft\.icon);base64,/i.test(e)){const d=e.indexOf(","),a=d>=0?e.slice(d+1):"";if(/^[A-Za-z0-9+/=]+$/.test(a))return Jt(e,n)}if(typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://")))return Jt(e,n);const i=document.createElement("span");i.className=`${n} desktop-mode-icon-letter`.trim(),i.setAttribute("aria-hidden","true");const r=Xo(o);i.textContent=r;const l=so(o);return i.style.backgroundColor=`hsl( ${l}, 60%, 45% )`,i.style.color="#fff",i.style.display="inline-flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.fontWeight="600",i.style.borderRadius="4px",i}function Jt(e,t){const n=document.createElement("img");return n.className=t,n.src=e,n.alt="",n.setAttribute("aria-hidden","true"),n.draggable=!1,n}function Xo(e){const t=(e??"").trim();if(t==="")return"?";const n=t.split(/\s+/);if(n.length>=2)return(n[0][0]+n[1][0]).toUpperCase();const o=n[0];return o.length>=2?o.slice(0,2).toUpperCase():o.toUpperCase()}const oe={OS_SETTINGS:"OS_SETTINGS",RECYCLE_BIN:"RECYCLE_BIN",BUG_REPORT:"BUG_REPORT",EXIT_DESKTOP_MODE:"EXIT_DESKTOP_MODE",PWA_INSTALL:"PWA_INSTALL"},Yo={"desktop-mode-os-settings":oe.OS_SETTINGS,"desktop-mode-recycle-bin":oe.RECYCLE_BIN,"desktop-mode-bug-report":oe.BUG_REPORT,"desktop-mode-exit":oe.EXIT_DESKTOP_MODE,"desktop-mode-pwa-install":oe.PWA_INSTALL};function en(e){if(typeof e!="string"||e==="")return"";const t=Yo[e];if(t)return t;const n=e.toLowerCase().replace(/[^a-z0-9_-]/g,"");return n===""?"":`APP:${n}`}function Zo(e){if(typeof e!="string"||e==="")return"";const t=e.replace(/^core\//,"").toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return t===""?"":`WINDOW_CONTROL_${t}`}function Ke(e,t){const n=Zo(t),o=Kt(n),s=Xt(n);if(o===null&&s===null)return!1;if(s!==null?e.style.setProperty("--wpd-btn-icon-color",s):e.style.removeProperty("--wpd-btn-icon-color"),o===null)return e.style.setProperty("color",s),!1;if(o.startsWith("dashicons-")){e.removeAttribute("icon-src"),e.removeAttribute("icon");const i=document.createElement("span");return i.className=`dashicons ${o}`,i.setAttribute("aria-hidden","true"),s!==null&&(i.style.color=s),e.appendChild(i),!0}return e.setAttribute("icon-src",o),!0}const $=0,Xe=40,tn=5,Qo=tn*tn,Jo=3e3,es=x("desktop-mode/window-reveal-active",()=>({id:je,duration:Oo}));function ts(){const e=es.state.id;return!e||e===je?null:Po(e)??null}const Ye="desktop-mode-window__reveal",ns="desktop-mode-window__reveal--edge",os="desktop-mode-window__reveal--custom",nn="data-desktop-mode-reveal-armed",on="data-desktop-mode-reveal",sn="data-desktop-mode-reveal-layer",ss=x("desktop-mode/window-reveal-rendered",()=>({plays:new WeakMap})).state.plays;function rn(e,t,n,o,s){const i=document.createElement("div");i.className=s?`${Ye} ${ns}`:Ye;const r=s?e.edgeColor:t.color??e.surfaceColor;return typeof r=="string"&&r!==""&&(i.style.background=r),i.setAttribute("aria-hidden","true"),i.setAttribute(on,e.id),i.setAttribute(sn,String(n)),i.setAttribute(nn,String(o)),i.style.clipPath=t.from,i}function is(){const e=ts();if(!e)return[];if(typeof e.render=="function"){let s;try{s=e.render()}catch(r){return typeof console<"u"&&console.error(`[desktop-mode] window reveal "${e.id}" render threw:`,r),[]}if(!s?.element||typeof s.play!="function")return[];const i=s.element;return i.classList.add(Ye),i.classList.add(os),i.setAttribute("aria-hidden","true"),i.setAttribute(on,e.id),i.setAttribute(sn,"0"),i.setAttribute(nn,String(Date.now())),ss.set(i,s.play),[i]}const t=Do(e);if(t.length===0)return[];const n=Date.now(),o=[];return No(e.edgeLag)>0&&t.forEach((s,i)=>o.push(rn(e,s,i,n,!0))),t.forEach((s,i)=>o.push(rn(e,s,i,n,!1))),o}const rs=Symbol.for("desktop-mode/window-config");function as(e,t){e[rs]=t}const an=window.location.origin;function ke(e){const t=new URL(e,an);return t.origin!==an?null:(t.searchParams.set("desktop_mode_chromeless","1"),t.toString())}function ee(){const e=document.querySelectorAll(".desktop-mode-window--fullscreen:not(.desktop-mode-window--minimized)").length>0;document.body.classList.toggle("desktop-mode-has-fullscreen-window",e)}function ds(){const e=document.createElement("div");e.className="desktop-mode-window__loading",e.setAttribute("aria-hidden","true");const t=document.createElement("wpd-spinner");return t.setAttribute("preset","classic"),t.setAttribute("size","clamp(96px, 14vw, 192px)"),t.setAttribute("label",g("Loading window content")),e.appendChild(t),e}function ls(e){let t=ds();const n={windowId:e.id,config:e};if(typeof e.loading?.render=="function")try{e.loading.render(t,n)}catch(o){typeof console<"u"&&console.error(`[desktop-mode] loading.render threw for "${e.id}":`,o)}try{const o=C(u.WINDOW_LOADING_OVERLAY,t,n);o instanceof HTMLElement&&(t=o)}catch(o){typeof console<"u"&&console.error(`[desktop-mode] WINDOW_LOADING_OVERLAY filter threw for "${e.id}":`,o)}return t&&!t.classList.contains("desktop-mode-window__loading")&&t.classList.add("desktop-mode-window__loading"),t}function q(e){const t=document.createElement("span");return t.className=`desktop-mode-window__slot desktop-mode-window__slot--${e}`,t.dataset.slot=e,t}function cs(e){const t=document.createElement("div");t.className="desktop-mode-window",e.native&&t.classList.add("desktop-mode-window--native"),t.id=`wp-window-${e.id}`,t.setAttribute("role","dialog"),t.setAttribute("aria-labelledby",`wp-window-title-${e.id}`),t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`;const n=document.createElement("div");n.className="desktop-mode-window__titlebar";const o=document.createElement("wpd-window-button");o.setAttribute("icon","menu"),Ke(o,"core/menu"),o.setAttribute("aria-label",g("Window actions")),o.setAttribute("aria-haspopup","menu"),o.setAttribute("aria-expanded","false"),o.classList.add("desktop-mode-window__btn"),o.classList.add("desktop-mode-window__menu-btn");const s=document.createElement("wpd-menu");s.classList.add("desktop-mode-window__menu-panel"),s.hidden=!0;const i=document.createElement("wpd-menu-item");if(i.setAttribute("role","menuitemcheckbox"),i.setAttribute("value","startup"),i.classList.add("desktop-mode-window__menu-item"),i.classList.add("desktop-mode-window__menu-item--startup"),i.textContent=g("Open on startup"),s.appendChild(i),e.multi){const w=document.createElement("wpd-menu-item");w.setAttribute("role","menuitem"),w.setAttribute("value","open-another"),w.setAttribute("icon","dashicons-plus-alt2"),w.classList.add("desktop-mode-window__menu-item"),w.classList.add("desktop-mode-window__menu-item--open-another"),w.textContent=He(g("Open another %s"),e.title),s.appendChild(w)}if(!e.native){const w=document.createElement("wpd-menu-item");w.setAttribute("role","menuitem"),w.setAttribute("value","open-in-new-window"),w.setAttribute("icon","dashicons-plus-alt"),w.classList.add("desktop-mode-window__menu-item"),w.classList.add("desktop-mode-window__menu-item--open-in-new-window"),w.textContent=g("Open in new window"),s.appendChild(w)}if(!e.native){const w=document.createElement("wpd-menu-item");w.setAttribute("role","menuitem"),w.setAttribute("value","reload"),w.setAttribute("icon","dashicons-update"),w.classList.add("desktop-mode-window__menu-item"),w.classList.add("desktop-mode-window__menu-item--reload"),w.textContent=g("Reload"),s.appendChild(w);const I=document.createElement("wpd-menu-item");I.setAttribute("role","menuitem"),I.setAttribute("value","open-external"),I.setAttribute("icon","dashicons-external"),I.classList.add("desktop-mode-window__menu-item"),I.classList.add("desktop-mode-window__menu-item--open-external"),I.textContent=g("Open in browser tab"),s.appendChild(I)}const r=q("icon"),l=Qt(e.icon,{title:e.title,className:"desktop-mode-window__icon",slot:en(e.id)});r.appendChild(l);const d=q("title"),a=document.createElement("span");a.className="desktop-mode-window__title",a.id=`wp-window-title-${e.id}`,a.textContent=e.title,d.appendChild(a);const c=q("before-titlebar"),p=q("before-icon"),m=q("after-title"),f=q("before-controls"),_=q("after-controls"),S=q("after-titlebar"),y=document.createElement("div");y.className="desktop-mode-window__controls";const k=document.createElement("div");k.className="desktop-mode-window__screen-meta";const b=document.createElement("span");b.className="desktop-mode-window__custom-buttons desktop-mode-window__custom-buttons--left";const v=document.createElement("span");v.className="desktop-mode-window__custom-buttons desktop-mode-window__custom-buttons--right";const E=document.createElement("span");E.className="desktop-mode-window__activity";const T=document.createElement("wpd-save-status");T.setAttribute("mode","dot"),T.setAttribute("animation","modem"),T.setAttribute("phase","idle"),T.setAttribute("data-desktop-mode-activity-indicator",""),E.appendChild(T),n.appendChild(p),n.appendChild(r),n.appendChild(E),n.appendChild(d),n.appendChild(m),n.appendChild(b),n.appendChild(k),o&&s&&s.children.length>0&&(n.appendChild(o),n.appendChild(s)),n.appendChild(v),n.appendChild(f),n.appendChild(y),n.appendChild(_);for(const w of Array.from(n.children))w.setAttribute("data-desktop-mode-default-chrome","");const R=document.createElement("div");if(R.className="desktop-mode-window__body desktop-mode-window__body--loading",e.native)R.classList.add("desktop-mode-window__body--native");else{const w=document.createElement("iframe");w.className="desktop-mode-window__iframe",w.setAttribute("name",`desktop-mode-frame-${e.id}`);const I=e.url?ke(e.url):null;w.src=I??"about:blank",R.appendChild(w);const De=()=>{P(e.id)};w.addEventListener("load",De)}R.appendChild(ls(e));for(const w of is())R.appendChild(w);_e(e.id);const pe=[];for(const w of["ne","nw","se","sw"]){const I=document.createElement("div");I.className=`desktop-mode-window__resize-handle desktop-mode-window__resize-handle--${w}`,I.dataset.dir=w,I.setAttribute("aria-hidden","true"),pe.push(I)}if(t.appendChild(c),t.appendChild(n),t.appendChild(S),!e.native){const w=document.createElement("nav");if(w.className="desktop-mode-window__tabs",w.setAttribute("role","tablist"),w.setAttribute("aria-label",He(g("%s sub-pages"),e.title)),e.submenu&&e.submenu.length>0&&e.url){const I=U(e.url),De=e.parentUrl??e.url,wr=U(De),gr=e.submenu.some(he=>U(he.url)===wr)?[...e.submenu]:[{title:e.title,url:De},...e.submenu];for(const he of gr){const M=document.createElement("button");M.className="desktop-mode-window__tab",M.dataset.kind="submenu",M.setAttribute("type","button"),M.setAttribute("role","tab"),M.dataset.url=he.url,M.textContent=he.title,U(he.url)===I?(M.classList.add("desktop-mode-window__tab--active"),M.setAttribute("aria-selected","true")):M.setAttribute("aria-selected","false"),w.appendChild(M)}}t.appendChild(w)}t.appendChild(R);for(const w of pe)t.appendChild(w);return as(t,e),t}const us="wpd-confirm-dialog";let Ze=null;function Ee(){return typeof window.customElements<"u"&&!!window.customElements.get(us)}function ps(e){return new Promise((t,n)=>{const o=document.querySelector('script[data-desktop-mode-shell-overlays="1"]'),s=()=>{if(Ee()){t();return}n(new Error("[desktop-mode] shell-overlays bundle loaded but did not register the overlay components."))};if(o){Ee()?s():(o.addEventListener("load",s),o.addEventListener("error",()=>n(new Error("failed to load shell-overlays bundle"))));return}const i=document.createElement("script");i.src=e,i.async=!0,i.dataset.desktopModeShellOverlays="1",i.addEventListener("load",s),i.addEventListener("error",()=>n(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(i)})}function hs(e){return Ee()||!e?Promise.resolve():(Ze||(Ze=ps(e)),Ze)}function ms(){return window.desktopModeConfig?.shellOverlaysBundleUrl??""}function fs(e,t){const n=ms();if(Ee()||!n){t();return}hs(n).then(()=>{e()&&t()}).catch(o=>{typeof console<"u"&&console.warn("[desktop-mode] shell-overlays failed to load; menu/dialog suppressed:",o)})}const ws=4e3,gs=200;function dn(e){const t=Me.filter("desktop-mode/toast-requested",{...e});if(!t||t.cancel===!0)return()=>{};let n=!1,o=null;return fs(()=>!n,()=>{o=_s(t)}),()=>{n=!0,o&&o()}}function _s(e){const t=bs(),n=document.createElement("wpd-toast");n.textContent=e.message,e.action&&(n.setAttribute("action",e.action.label),n.addEventListener("wpd-toast-action",()=>{e.action?.onClick(),i()})),e.dismissible&&(n.setAttribute("dismissible",""),n.addEventListener("wpd-toast-dismiss",()=>{e.onDismiss?.(),i()})),t.appendChild(n);let o=!1,s=null;const i=()=>{o||(o=!0,s!==null&&(window.clearTimeout(s),s=null),n.setAttribute("state","out"),window.setTimeout(()=>{n.remove()},gs))};return requestAnimationFrame(()=>{n.setAttribute("state","in")}),e.persistent||(s=window.setTimeout(i,e.duration??ws)),Me.publish("desktop-mode/toast-shown",{...e}),i}function bs(){const e=document.querySelector("wpd-toast-container");if(e)return e;const t=document.createElement("wpd-toast-container");return document.body.appendChild(t),t}function ys(e,t){let n;try{n=new URL(t,window.location.origin)}catch{return null}const o=bt(t);let s=null,i=-1;for(const r of e){const l=r.dataset.url;if(!l||bt(l)!==o)continue;let d;try{d=new URL(l,window.location.origin)}catch{continue}let a=0,c=!1;for(const[p,m]of d.searchParams)if(!(p==="desktop_mode_chromeless"||p==="desktop_mode_portal")){if(n.searchParams.get(p)!==m){c=!0;break}a++}!c&&a>i&&(s=r,i=a)}return s}function ln(e,t){const n=e.element.querySelectorAll('.desktop-mode-window__tab[data-kind="submenu"]');if(!n.length)return;if(e._activeTabId!=="primary"){for(const i of n)i.classList.remove("desktop-mode-window__tab--active"),i.setAttribute("aria-selected","false");return}const o=U(t);let s=null;for(const i of n){const r=i.dataset.url;if(r&&U(r)===o){s=i;break}}s||(s=ys(n,t));for(const i of n){const r=i===s;i.classList.toggle("desktop-mode-window__tab--active",r),i.setAttribute("aria-selected",r?"true":"false")}}function cn(e,t,n){if(!e.iframe)return;const o=e.element.querySelector(".desktop-mode-window__tabs"),s=e.element.querySelector(".desktop-mode-window__body");if(!o||!s)return;vs(e,o);const i=`ext-${++e._externalTabSeq}`,r=document.createElement("button");r.className="desktop-mode-window__tab desktop-mode-window__tab--external",r.dataset.kind="external",r.dataset.tabId=i,r.setAttribute("type","button"),r.setAttribute("role","tab"),r.setAttribute("aria-selected","false"),r.title=t;const l=document.createElement("span");l.className="desktop-mode-window__tab-label",l.textContent=n,r.appendChild(l);const d=document.createElement("wpd-tab-chip");d.setAttribute("variant","detach"),d.dataset.tabAction="detach",d.dataset.tabId=i,d.setAttribute("aria-label",g("Open in a new browser tab")),d.title=g("Open in a new browser tab"),r.appendChild(d);const a=document.createElement("wpd-tab-chip");a.setAttribute("variant","close"),a.dataset.tabAction="close",a.dataset.tabId=i,a.setAttribute("aria-label",g("Close tab")),a.title=g("Close tab"),r.appendChild(a),o.appendChild(r);const c=document.createElement("iframe");c.className="desktop-mode-window__iframe desktop-mode-window__iframe--external",c.dataset.tabId=i,c.style.display="none",c.src=t,s.appendChild(c);let p=!1;const m=()=>{p=!0};c.addEventListener("load",m,{once:!0});const f=window.setTimeout(()=>{p||(c.removeEventListener("load",m),Es(e,i))},Jo),_=()=>{c.removeEventListener("load",m),window.clearTimeout(f)};e._externalTabs.set(i,{tabEl:r,iframe:c,url:t,label:n,cancelProbe:_}),se(e,i),r.scrollIntoView({behavior:"smooth",inline:"end",block:"nearest"}),e._emitChange("state")}function vs(e,t){if(t.querySelector('[data-kind="main"]')||t.querySelector('[data-kind="submenu"]'))return;const n=document.createElement("button");n.className="desktop-mode-window__tab desktop-mode-window__tab--main desktop-mode-window__tab--active",n.dataset.kind="main",n.setAttribute("type","button"),n.setAttribute("role","tab"),n.setAttribute("aria-selected","true"),n.textContent=e.config.title||"Main",t.prepend(n)}function se(e,t){if(e._activeTabId===t)return;e._activeTabId=t,e.iframe&&(e.iframe.style.display=t==="primary"?"":"none");for(const[o,s]of e._externalTabs)s.iframe.style.display=t===o?"":"none";e.element.querySelectorAll(".desktop-mode-window__tab").forEach(o=>{let s;o.dataset.kind==="main"?s=t==="primary":o.dataset.kind==="external"?s=o.dataset.tabId===t:s=t==="primary"&&o.classList.contains("desktop-mode-window__tab--active"),o.classList.toggle("desktop-mode-window__tab--active",s),o.setAttribute("aria-selected",s?"true":"false")})}function Qe(e,t){const n=e._externalTabs.get(t);n&&(n.cancelProbe(),n.tabEl.remove(),n.iframe.remove(),e._externalTabs.delete(t),e._activeTabId===t&&se(e,"primary"),e._externalTabs.size===0&&e.element.querySelector(".desktop-mode-window__tab--main")?.remove(),e._emitChange("state"))}function ks(e,t){const n=e._externalTabs.get(t);if(!n)return;let o=n.url;try{const s=n.iframe.contentWindow?.location.href;s&&s!=="about:blank"&&(o=s)}catch{}window.open(o,"_blank","noopener"),Qe(e,t)}function Es(e,t){const n=e._externalTabs.get(t);if(!n)return;const{url:o,label:s}=n;Qe(e,t),dn({message:He(g(`Opened "%s" in a new browser tab — this site doesn't allow embedding.`),s),action:{label:g("Open"),onClick:()=>{window.open(o,"_blank","noopener")}}}),window.open(o,"_blank","noopener")}function As(e){return e._externalTabs.size}function Ss(e){const t=[];for(const n of e._externalTabs.values()){let o=n.url;try{const s=n.iframe.contentWindow?.location.href;s&&s!=="about:blank"&&(o=s)}catch{}t.push({url:o,label:n.label})}return t}function Cs(e,t){const n=t.target,o=n.closest("[data-tab-action]");if(o){t.stopPropagation();const l=o.dataset.tabAction,d=o.dataset.tabId;if(!d)return;l==="close"?Qe(e,d):l==="detach"&&ks(e,d);return}const s=n.closest(".desktop-mode-window__tab");if(!s)return;t.stopPropagation();const i=s.dataset.kind,r=s.dataset.tabId;if(i==="external"&&r){se(e,r);return}if(i==="main"){se(e,"primary");return}if(s.dataset.url){const l=ke(s.dataset.url);l&&e.iframe&&(e.markContentLoading(),e.iframe.src=l),se(e,"primary")}}const Is=x("desktop-mode/native-url-remap",()=>({remaps:[],deps:null}));function Ls(e){const{deps:t,remaps:n}=Is.state;if(!t||!e)return!1;let o;try{o=new URL(e,t.adminUrl)}catch{return!1}const s=t.getSnapshot();for(const i of n)if(i.matches(e,o)&&!(i.enabled&&!i.enabled(s))){if(i.onMatch)try{i.onMatch(e,o)}catch(r){console.warn(`[desktop-mode] URL remap onMatch hook threw for "${i.id}":`,r)}if(t.openById(i.nativeWindowId))return!0}return!1}const Ts=x("desktop-mode/destructive-admin-actions",()=>({entries:[]}));function Rs(e,t){for(const n of Ts.state.entries)try{if(n.matches(e,t))return n.id}catch(o){console.warn(`[desktop-mode] destructive-action predicate threw for "${n.id}":`,o)}return null}const xs=32,Os=64,Ns=/^[a-z0-9_/-]+$/,H=x("desktop-mode/window-links",()=>({contentByWindow:new Map,focusSeq:new Map,seq:0,listeners:new Set,lastGroupsSignature:"",manager:null,started:!1}));function Ae(e){return`${e.type}:${e.id}`}function un(e){return e.root?Ae(e.root):Ae(e)}function pn(e){const t=o=>typeof o=="number"&&Number.isFinite(o)||typeof o=="string"&&o.trim()!=="",n=o=>typeof o=="string"&&Ns.test(o.trim().toLowerCase());return ro(e,[{field:"type",valid:o=>n(o.type),message:"must match /^[a-z0-9_/-]+$/ — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-type"},{field:"id",valid:o=>t(o.id),message:"must be a finite number or non-empty string"},{field:"root",valid:o=>o.root===void 0||!!o.root&&typeof o.root=="object"&&n(o.root.type)&&t(o.root.id),message:"when present, must be { type, id } with the same shapes as the ref itself"},{field:"related",valid:o=>o.related===void 0||Array.isArray(o.related)&&o.related.every(s=>!!s&&typeof s=="object"&&typeof s.id=="string"&&s.id.trim()!==""&&typeof s.group=="string"&&s.group.trim()!==""&&typeof s.label=="string"&&s.label.trim()!==""&&typeof s.url=="string"&&s.url.trim()!==""&&(s.groupLabel===void 0||typeof s.groupLabel=="string")&&(s.icon===void 0||typeof s.icon=="string")&&(s.count===void 0||typeof s.count=="number"&&Number.isFinite(s.count))),message:"when present, must be an array of { id, group, label, url, groupLabel?, icon?, count? } entries with non-empty strings"},{field:"links",valid:o=>o.links===void 0||Array.isArray(o.links)&&o.links.every(s=>!!s&&typeof s=="object"&&n(s.type)&&t(s.id)&&(s.rel===void 0||s.rel==="references"||s.rel==="child")),message:"when present, must be an array of { type, id, rel?: 'references'|'child' } entries"}])}function Ds(e,t){const n={type:e.type.trim().toLowerCase(),id:e.id,source:t};if(e.root&&(n.root={type:e.root.type.trim().toLowerCase(),id:e.root.id}),Array.isArray(e.links)&&e.links.length>0&&(n.links=e.links.slice(0,xs).map(o=>{const s={type:o.type.trim().toLowerCase(),id:o.id};return o.rel==="child"&&(s.rel="child"),s})),typeof e.label=="string"&&e.label!==""&&(n.label=e.label),typeof e.previewUrl=="string"&&e.previewUrl!=="")try{new URL(e.previewUrl,window.location.origin).origin===window.location.origin&&(n.previewUrl=e.previewUrl)}catch{}return Array.isArray(e.related)&&e.related.length>0&&(n.related=e.related.slice(0,Os).map(o=>{const s={id:o.id,group:o.group,label:o.label,url:o.url};return typeof o.groupLabel=="string"&&o.groupLabel!==""&&(s.groupLabel=o.groupLabel),typeof o.icon=="string"&&o.icon!==""&&(s.icon=o.icon),typeof o.count=="number"&&(s.count=o.count),s})),n}function hn(e){return!e||!e.related?"":e.related.map(t=>`${t.id}\0${t.group}\0${t.label}\0${t.url}\0${t.groupLabel??""}\0${t.icon??""}\0${t.count??""}`).join("|")}function Je(e){return e?[Ae(e),un(e),...(e.links??[]).map(t=>Ae(t)+(t.rel==="child"?"!child":""))].join("|"):""}function Ws(e,t,n={}){const o=n.source??"api";if(typeof e!="string"||e===""){ze("WindowContentRef",["windowId (must be a non-empty string)"],t);return}let s=null;if(t!=null){const l=pn(t);if(l.length>0){o==="api"&&ze("WindowContentRef",l,t),kt("WindowContentRef",l,t);return}s=Ds(t,o)}if(s=C(u.WINDOW_LINKS_CONTENT,s,{windowId:e,source:o}),s!==null&&(!s||pn(s).length>0)){kt("WindowContentRef",["filter (desktop-mode.window-links.content returned an invalid ref)"],s);return}const i=H.state.contentByWindow.get(e)??null;if(s===null&&i===null||s!==null&&i!==null&&Je(s)===Je(i)&&s.label===i.label&&s.previewUrl===i.previewUrl&&hn(s)===hn(i))return;s===null?H.state.contentByWindow.delete(e):H.state.contentByWindow.set(e,s);const r={windowId:e,content:s,previous:i,source:o};document.dispatchEvent(new CustomEvent("desktop-mode-window-content-changed",{detail:r})),h(u.WINDOW_CONTENT_CHANGED,r),Hs(),Ps()}function Ms(){const e=new Map;for(const[s,i]of H.state.contentByWindow){const r=un(i);let l=e.get(r);l||(l={key:r,root:i.root?{...i.root}:{type:i.type,id:i.id},rootWindowIds:[],children:[]},e.set(r,l)),i.root?l.children.push({windowId:s,content:i}):l.rootWindowIds.push(s)}const t=H.state.focusSeq;for(const s of e.values())s.rootWindowIds.sort((i,r)=>(t.get(r)??0)-(t.get(i)??0));const n=Array.from(e.values()),o=C(u.WINDOW_LINK_GROUPS,n);return Array.isArray(o)?o:(typeof console<"u"&&console.warn("[desktop-mode] `desktop-mode.window-links.groups` filter returned a non-array; falling back to computed groups."),n)}function Ps(){for(const e of Array.from(H.state.listeners))try{e()}catch(t){typeof console<"u"&&console.error("[desktop-mode] window-links listener threw:",t)}}function $s(){return Array.from(H.state.contentByWindow).map(([e,t])=>`${e}=${Je(t)}`).sort().join(";")}function Hs(){const e=$s();if(e===H.state.lastGroupsSignature)return;H.state.lastGroupsSignature=e;const n={groups:Ms()};document.dispatchEvent(new CustomEvent("desktop-mode-window-link-groups-changed",{detail:n})),h(u.WINDOW_LINK_GROUPS_CHANGED,n)}const zs="desktop-mode-my-wordpress",Us=Object.freeze({userId:null,userName:"",requestedAt:0});function mn(){return window.wp?.desktop}let Se=null;function Fs(){if(Se)return Se;const e=mn()?.createSharedStore;return typeof e!="function"?null:(Se=e("desktop-mode/my-wordpress/footprint-target",()=>({...Us})),Se)}function Bs(e,t=""){const n=Fs();if(n){n.state.userId=e,n.state.userName=t,n.state.requestedAt=Date.now(),n.notify();return}window._wpdFootprintTarget={userId:e,userName:t,requestedAt:Date.now()}}function Gs(e){const t=Number(e.userId);!Number.isFinite(t)||t<=0||(Bs(t,e.userName??""),mn()?.openWindow?.(zs,{source:"my-wordpress/open-user-footprint"}))}const V=window.location.origin,qs=x("desktop-mode/admin-link-deps",()=>({deps:null}));function Vs(e,t){if(t.origin!==V||!e.iframe||t.source!==e.iframe.contentWindow)return;const n=t.data;if(!(!n||typeof n.type!="string")){if(n.type==="desktop-mode-title-change"&&typeof n.title=="string"&&e.setTitle(n.title),n.type==="desktop-mode-content-identity"&&Ws(e.id,n.identity??null,{source:"bridge"}),n.type==="desktop-mode-window-publish"&&typeof n.channel=="string"&&n.channel!==""&&wt(e.id,n.channel,n.payload),typeof n.type=="string"&&n.type.startsWith("desktop-mode-bridge-")&&window.__desktopModeConnectionBridge?.routeIncomingFromIframe(n,e.id),n.type==="desktop-mode-ready"&&(e._iframeBridgeReady=!0,P(e.id),h(u.IFRAME_READY,{windowId:e.id})),n.type==="desktop-mode-bridge-beforeunload-response"){if(e._isDestroyed)return;e._closePending=!1,e._iframeCloseTimeout&&(clearTimeout(e._iframeCloseTimeout),e._iframeCloseTimeout=null),n.prevent?Promise.resolve().then(()=>fr).then(({wpdConfirm:o})=>o({title:typeof n.message=="string"&&n.message?n.message:g("Unsaved changes"),message:g("You have unsaved changes. Are you sure you want to close this window?"),confirmLabel:g("Close window"),danger:!0})).then(o=>{o&&e.destroy()}).catch(()=>{e.destroy()}):e.destroy()}if(n.type==="desktop-mode-navigate"&&typeof n.url=="string"&&n.url!==""&&js(e,n.url,n.target==="new"?"new":"self"),n.type==="desktop-mode-iframe-admin-link"&&typeof n.url=="string"&&n.url!==""){const o=qs.state.deps;if(Ls(n.url))e.close();else if(o){const s=typeof n.label=="string"?n.label:"";Qs(e,n.url,s,o)}}if(n.type==="desktop-mode-open-user-footprint"&&typeof n.userId=="number"&&n.userId>0&&Gs({userId:n.userId,userName:typeof n.userName=="string"?n.userName:""}),n.type==="desktop-mode-notification"&&typeof n.title=="string"&&n.title!==""&&Js(n.title,typeof n.body=="string"?n.body:""),n.type==="desktop-mode-focus-request"&&(e.element.classList.contains("desktop-mode-window--overview")||e.onFocusRequest?.(e)),n.type==="desktop-mode-screen-meta"&&Array.isArray(n.panels)&&ei(e,n.panels),n.type==="desktop-mode-screen-meta-state"&&ti(e,typeof n.open=="string"?n.open:null),n.type==="desktop-mode-external-link"&&typeof n.url=="string"&&n.url!==""){const o=typeof n.label=="string"&&n.label!==""?n.label:n.url;cn(e,n.url,o)}if(n.type==="desktop-mode-iframe-error"&&h(u.IFRAME_ERROR,{windowId:e.id,kind:n.kind==="unhandledrejection"?"unhandledrejection":"error",message:typeof n.message=="string"?n.message:"",filename:typeof n.filename=="string"?n.filename:null,lineno:typeof n.lineno=="number"?n.lineno:null,colno:typeof n.colno=="number"?n.colno:null,stack:typeof n.stack=="string"?n.stack:null}),n.type==="desktop-mode-chrome-theme"&&n.tokens&&typeof n.tokens=="object")try{e.setAppearanceTheme(n.tokens)}catch(o){h(u.SHELL_ERROR,{scope:"window-bridge-chrome-theme",windowId:e.id,error:o})}if(n.type==="desktop-mode-chrome-controls"&&n.config&&typeof n.config=="object")try{e.setAppearanceControls(n.config)}catch(o){h(u.SHELL_ERROR,{scope:"window-bridge-chrome-controls",windowId:e.id,error:o})}if(n.type==="desktop-mode-chrome-slot"&&typeof n.slot=="string"&&typeof n.html=="string")try{e.setAppearanceSlot(n.slot,{html:n.html})}catch(o){h(u.SHELL_ERROR,{scope:"window-bridge-chrome-slot",windowId:e.id,error:o})}if(n.type==="desktop-mode-iframe-network"){const o={windowId:e.id,method:typeof n.method=="string"?n.method:"GET",url:typeof n.url=="string"?n.url:"",status:typeof n.status=="number"?n.status:0,duration:typeof n.duration=="number"?n.duration:0,failed:!!n.failed};n.requestHeaders&&typeof n.requestHeaders=="object"&&(o.requestHeaders=n.requestHeaders),n.responseHeaders&&typeof n.responseHeaders=="object"&&(o.responseHeaders=n.responseHeaders),h(u.IFRAME_NETWORK_COMPLETED,o)}}}function js(e,t,n){let o;try{o=new URL(t,V)}catch{return}if(o.origin===V){if(n==="new"){window.open(o.toString(),"_blank","noopener,noreferrer");return}e.iframe&&(e.iframe.src=o.toString())}}const Ks=new Set(["trash","untrash","delete","spam","unspam","spamcomment","unspamcomment","trashcomment","untrashcomment","deletecomment","approvecomment","unapprovecomment"]);function Xs(e){const t=e.searchParams.get("action");return t&&Ks.has(t)&&(e.searchParams.has("_wpnonce")||e.searchParams.has("_wp_nonce"))?!0:Rs(e.toString(),e)!==null}function fn(e,t){if(e.searchParams.has("_wp_http_referer"))return e;let n="";try{n=t.iframe?.contentWindow?.location.href??""}catch{}if(n||(n=t.config.url||""),!n)return e;try{const o=new URL(n,V);if(o.origin!==V)return e;const s=new URL(e.href),i=new URL(o.href);return i.searchParams.delete("desktop_mode_chromeless"),s.searchParams.set("_wp_http_referer",i.pathname+(i.search?i.search:"")),s}catch{return e}}function Ys(e,t){let n="";try{n=e.getCurrentUrl?.()??""}catch{return""}if(!n||n.startsWith("#")||n==="about:blank")return"";try{const o=new URL(n,t.adminUrl);return o.origin!==V?"":t.deriveSlug(o.toString())}catch{return""}}function Zs(e,t,n){if(t===(e.config.baseId||e.id))return!0;const o=Ys(e,n);return o!==""&&o===t}function Qs(e,t,n,o){let s;try{s=new URL(t,o.adminUrl)}catch{return}if(s.origin!==V)return;const i=s.toString(),r=o.deriveSlug(i),l=Zs(e,r,o);if(!l&&Xs(s)){const m=fn(s,e),f=e.iframe?.contentWindow;if(f)try{f.location.assign(m.href)}catch{e.iframe&&(e.iframe.src=m.href)}return}if(l){const m=e.iframe?.contentWindow;if(m)try{m.location.assign(i)}catch{e.iframe&&(e.iframe.src=i)}return}const d=o.findDockEntry(i),a=n.trim(),c=d?.title||(a!==""?a:r),p=fn(s,e);o.openWindow({id:r,baseId:r,url:p.toString(),parentUrl:d?.url??i,title:c,icon:d?.icon??"dashicons-admin-generic",submenu:d?.submenu,multi:d?.multi})}function Js(e,t){const n=t!==""?`${e} — ${t}`:e;dn({message:n})}function ei(e,t){const n=e.element.querySelector(".desktop-mode-window__screen-meta");if(!n)return;n.innerHTML="";const o={"screen-options":{icon:"dashicons-admin-generic",label:"Screen Options"},help:{icon:"dashicons-editor-help",label:"Help"}};for(const s of t){const i=o[s];if(!i)continue;const r=document.createElement("button");r.className="desktop-mode-window__meta-btn",r.setAttribute("type","button"),r.setAttribute("aria-label",i.label),r.setAttribute("aria-pressed","false"),r.dataset.panel=s,r.innerHTML=`<span class="dashicons ${i.icon}" aria-hidden="true"></span>`,r.addEventListener("click",l=>{l.stopPropagation(),e.iframe?.contentWindow?.postMessage({type:"desktop-mode-toggle-panel",panel:s},V)}),n.appendChild(r)}}function ti(e,t){const n=e.element.querySelector(".desktop-mode-window__screen-meta");n&&n.querySelectorAll(".desktop-mode-window__meta-btn").forEach(o=>{const s=o.dataset.panel===t;o.classList.toggle("desktop-mode-window__meta-btn--active",s),o.setAttribute("aria-pressed",s?"true":"false")})}const wn=x("desktop-mode/title-bar-buttons-registry",()=>({registry:new Map,listeners:new Set})),ni=wn.state.registry,gn=wn.state.listeners;function oi(){return Array.from(ni.values()).sort((e,t)=>(e.order??100)-(t.order??100))}function si(e){const t=[],n=[];for(const o of oi()){try{if(!o.match(e))continue}catch{continue}o.placement==="right"?n.push(o):t.push(o)}return{left:t,right:n}}function ii(e){return gn.add(e),()=>{gn.delete(e)}}const ri=/^dashicons-[a-z0-9-]+$/i,ai=/^\s*<svg[\s>]/i;function _n(e,t){if(t){if(ri.test(t)){const n=document.createElement("span");n.className=`dashicons ${t}`,n.setAttribute("aria-hidden","true"),e.appendChild(n);return}if(ai.test(t)){const n=document.createElement("span");n.setAttribute("aria-hidden","true"),n.innerHTML=t,e.appendChild(n);return}e.setAttribute("icon",t)}}const bn=x("desktop-mode/window-themes-registry",()=>({registry:new Map,listeners:new Set})),di=bn.state.registry,yn=bn.state.listeners;function vn(){return Array.from(di.values()).sort((e,t)=>(e.priority??100)-(t.priority??100))}function li(e){let t=null;for(const n of vn()){try{if(!n.match(e))continue}catch(o){typeof console<"u"&&console.warn(`[desktop-mode] window-theme "${n.id}" match() threw — skipping`,o);continue}t=n}return t}function ci(e){return yn.add(e),()=>{yn.delete(e)}}const Ce=new WeakMap;function ui(e,t){let n=null,o={};if(t&&"tokens"in t&&t.tokens)n=null,o={...t.tokens};else if(t&&"themeId"in t&&t.themeId){const i=hi(t.themeId);i&&(n=i.id,o={...i.tokens})}else{const i=li(e);i&&(n=i.id,o={...i.tokens})}const s=C(u.WINDOW_CHROME_THEME,o,{windowId:e.id,themeId:n,config:e.config});return{themeId:n,tokens:s}}function et(e,t){const n=e.element;if(!n)return;const o=Ce.get(n),{themeId:s,tokens:i}=ui(e,t);if(o){for(const l of o.keys)if(!(l in i))try{n.style.removeProperty(l)}catch{}}const r=new Set;for(const[l,d]of Object.entries(i))try{n.style.setProperty(l,d),r.add(l)}catch(a){h(u.SHELL_ERROR,{scope:"window-theme-apply",windowId:e.id,key:l,error:a})}Ce.set(n,{themeId:s,keys:r}),h(u.WINDOW_CHROME_THEME_CHANGED,{windowId:e.id,themeId:s,tokens:i})}function pi(e){const t=e.element;if(!t)return;const n=Ce.get(t);if(n){for(const o of n.keys)try{t.style.removeProperty(o)}catch{}Ce.delete(t)}}function hi(e){for(const t of vn())if(t.id===e)return{id:t.id,tokens:t.tokens};return null}const kn=x("desktop-mode/window-controls-registry",()=>({registry:new Map,listeners:new Set})),mi=kn.state.registry,En=kn.state.listeners;function fi(){return Array.from(mi.values()).sort((e,t)=>{const n=e.order??100,o=t.order??100;return n!==o?n-o:e.id.localeCompare(t.id)})}function wi(e){const t=[],n=[],o=[];for(const s of fi()){try{if(!s.match(e))continue}catch(r){typeof console<"u"&&console.warn(`[desktop-mode] window-control "${s.id}" match() threw — skipping`,r);continue}const i=s.placement??"left";i==="right"?n.push(s):i==="controls"?o.push(s):t.push(s)}return{left:t,right:n,controls:o}}function gi(e){return En.add(e),()=>{En.delete(e)}}function _i(e,t){const n=wi(e),o=new Set(t?.hide??[]);let s=n.left.filter(a=>!o.has(a.id)),i=n.right.filter(a=>!o.has(a.id)),r=n.controls.filter(a=>!o.has(a.id));if(t?.custom){for(const a of t.custom){if(o.has(a.id))continue;const c={id:a.id,label:a.label,icon:a.icon,placement:a.placement??"controls",order:a.order??100,match:()=>!0,onClick:a.onClick?(p,m)=>a.onClick(m):void 0,render:a.render?p=>a.render(p):void 0};c.placement==="left"?s.push(c):c.placement==="right"?i.push(c):r.push(c)}s=tt(s),i=tt(i),r=tt(r)}t?.order&&t.order.length>0&&(r=bi(r,t.order));const l=t?.placement??"right",d={windowId:e.id,config:e.config};return s=C(u.WINDOW_CHROME_CONTROLS,s,{...d,placement:"left"}),i=C(u.WINDOW_CHROME_CONTROLS,i,{...d,placement:"right"}),r=C(u.WINDOW_CHROME_CONTROLS,r,{...d,placement:"controls"}),{left:s,right:i,controls:r,placement:l}}function tt(e){return[...e].sort((t,n)=>{const o=t.order??100,s=n.order??100;return o!==s?o-s:t.id.localeCompare(n.id)})}function bi(e,t){const n=new Map;for(const i of e)n.set(i.id,i);const o=[],s=new Set;for(const i of t){const r=n.get(i);r&&!s.has(i)&&(o.push(r),s.add(i))}for(const i of e)s.has(i.id)||o.push(i);return o}function yi(e,t){const n=document.createElement("wpd-window-button");n.setAttribute("aria-label",e.label),n.classList.add("desktop-mode-window__btn");const o=vi(e.id);if(n.classList.add(`desktop-mode-window__btn--${o}`),e.id==="core/close"&&n.setAttribute("danger",""),typeof e.render=="function")try{e.render(n,t)}catch(s){return h(u.SHELL_ERROR,{scope:"window-control-render",id:e.id,windowId:t.id,error:s}),{element:n}}else if(Ke(n,e.id)||_n(n,e.icon??""),typeof e.onClick=="function"){const s=i=>{i.stopPropagation();try{e.onClick(t,i)}catch(r){h(u.SHELL_ERROR,{scope:"window-control-onclick",id:e.id,windowId:t.id,error:r})}};return n.addEventListener("wpd-button-activate",s),{element:n,teardown:()=>{n.removeEventListener("wpd-button-activate",s)}}}return{element:n}}function vi(e){return e.startsWith("core/")?e.slice(5):e.replace(/\//g,"-")}function ki(e,t){const n=[];for(;t.firstChild;)t.removeChild(t.firstChild);const o=_i(e,e.config.appearance?.controls);t.classList.toggle("desktop-mode-window__controls--left",o.placement==="left");for(const s of o.controls){const{element:i,teardown:r}=yi(s,e);t.appendChild(i),r&&n.push(r)}return h(u.WINDOW_CHROME_APPLIED,{windowId:e.id,layer:"controls"}),()=>{for(const s of n)try{s()}catch{}}}const An=x("desktop-mode/window-slots-registry",()=>({registry:new Map,listeners:new Set})),Ei=An.state.registry,Sn=An.state.listeners;function Ai(){return Array.from(Ei.values()).sort((e,t)=>{const n=e.order??100,o=t.order??100;return n!==o?n-o:e.id.localeCompare(t.id)})}function Si(e,t){const n=[];for(const o of Ai())if(o.slot===t){try{if(!o.match(e))continue}catch(s){typeof console<"u"&&console.warn(`[desktop-mode] window-slot "${o.id}" match() threw — skipping`,s);continue}n.push(o)}return n}function Ci(e){return Sn.add(e),()=>{Sn.delete(e)}}const Cn=["before-titlebar","before-icon","icon","title","after-title","before-controls","after-controls","after-titlebar"],In=new WeakMap;function Ln(e,t){return e.querySelector(`[data-slot="${t}"]`)}function Ii(e){const t=new Map;for(const n of Cn){const o=Ln(e,n);o&&t.set(n,Array.from(o.childNodes).map(s=>s.cloneNode(!0)))}return t}function ie(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function Li(e,t){ie(e);for(const n of t)e.appendChild(n.cloneNode(!0))}function Ti(e){const t=[],n=e.element;if(!n)return()=>{};let o=In.get(n);o||(o=Ii(n),In.set(n,o));const s=e.config.appearance?.slots??{};for(const i of Cn){const r=Ln(n,i);if(!r)continue;const l=o.get(i)??[],d=s[i],a=Si(e,i);if(d===null)ie(r);else if(d&&"html"in d)ie(r),r.textContent=d.html;else if(d&&"render"in d){d.replace!==!1&&ie(r);try{const p=d.render(r);typeof p=="function"&&t.push(p)}catch(p){h(u.SHELL_ERROR,{scope:"window-slot-inline-render",windowId:e.id,slot:i,error:p})}}else Li(r,l);if(d!==null){let c=!1;for(const p of a){p.replace!==!1&&!c&&(ie(r),c=!0);try{const f=p.render(r,{window:e,slot:i});typeof f=="function"&&t.push(f)}catch(f){h(u.SHELL_ERROR,{scope:"window-slot-registry-render",windowId:e.id,slot:i,id:p.id,error:f})}}}C(u.WINDOW_CHROME_SLOT,r,{windowId:e.id,slot:i,config:e.config})}return h(u.WINDOW_CHROME_APPLIED,{windowId:e.id,layer:"slots"}),()=>{for(const i of t)try{i()}catch{}}}const Tn=x("desktop-mode/window-chrome-registry",()=>({registry:new Map,listeners:new Set})),Ri=Tn.state.registry,Rn=Tn.state.listeners;function xi(e){return Ri.get(e.toLowerCase())??null}function Oi(e){return Rn.add(e),()=>{Rn.delete(e)}}const Ie="core/standard",nt="desktop-mode-window--custom-chrome";function xn(e){const t=e.config.appearance?.chrome??Ie;return C(u.WINDOW_CHROME_RENDER,t,{windowId:e.id,config:e.config})}function On(e){return{title:e.config.title,icon:e.config.icon,focused:e.element.classList.contains("desktop-mode-window--focused"),state:e.state}}function Ni(e){const t=xn(e);if(t===Ie)return null;const n=xi(t);if(!n)return null;try{if(n.match&&!n.match(e))return null}catch{return null}e.element.classList.add(nt);let o;try{o=n.render(e.element,{window:e,state:On(e)})}catch(s){return e.element.classList.remove(nt),h(u.SHELL_ERROR,{scope:"window-chrome-render",windowId:e.id,chromeId:t,error:s}),null}return h(u.WINDOW_CHROME_APPLIED,{windowId:e.id,layer:"chrome",chromeId:t}),{id:t,handle:o}}function Nn(e){const t=e.element.querySelector(".desktop-mode-window__menu-panel");t&&(t.hidden?Dn(e):j(e))}function Dn(e){const t=e.element.querySelector(".desktop-mode-window__menu-panel"),n=e.element.querySelector(".desktop-mode-window__menu-btn");if(!t||!n)return;t.hidden=!1,n.setAttribute("aria-expanded","true");const o=t.querySelector(".desktop-mode-window__menu-item--startup");o&&ot(e,o),e._boundOnDocumentPointerDown||(e._boundOnDocumentPointerDown=i=>{const r=i.target;r&&(t.contains(r)||n.contains(r)||j(e))}),setTimeout(()=>{e._boundOnDocumentPointerDown&&document.addEventListener("pointerdown",e._boundOnDocumentPointerDown,!0)},0),t.querySelector('[role="menuitem"]')?.focus()}function j(e){const t=e.element.querySelector(".desktop-mode-window__menu-panel"),n=e.element.querySelector(".desktop-mode-window__menu-btn");t&&(t.hidden=!0),n&&n.setAttribute("aria-expanded","false"),e._boundOnDocumentPointerDown&&document.removeEventListener("pointerdown",e._boundOnDocumentPointerDown,!0)}function Di(e){e.hasAttribute("checked")?e.removeAttribute("checked"):e.setAttribute("checked","")}function ot(e,t){const n=window.wp?.desktop?.config?.defaultWindow;let o=!1;if(n&&n.enabled&&typeof n.url=="string")if(e.config.native)o=n.url===`native:${e.id}`;else try{const s=U(e.getCurrentUrl()),i=U(n.url);o=s===i}catch{o=!1}o?t.setAttribute("checked",""):t.removeAttribute("checked")}function Wn(e,t){let n=!1;return()=>{n||(n=!0,requestAnimationFrame(()=>{if(n=!1,!(t==="drag"&&!e._isDragging)&&!(t==="resize"&&!e._isResizing)&&!(e._isDestroyed||!e.element.isConnected))try{h(u.WINDOW_BOUNDS_CHANGED,{windowId:e.id,x:e.element.offsetLeft,y:e.element.offsetTop,width:e.element.offsetWidth,height:e.element.offsetHeight,state:e.state,phase:t})}catch{}}))}}function Wi(e,t){const n=t.target;if(n.closest(".desktop-mode-window__btn")||n.closest(".desktop-mode-window__custom-buttons")||n.closest(".desktop-mode-window__controls")||n.closest(".desktop-mode-window__screen-meta")||n.closest(".desktop-mode-window__menu-btn")||n.closest(".desktop-mode-window__menu-panel"))return;const o=e.state==="maximized",s=e.state==="snapped-left"||e.state==="snapped-right",i=o||s,r=t.clientX,l=t.clientY,d=t.pointerId,a=i?Mi(e,t):null;e._titleBar.setPointerCapture(d);const c=e.snapConfigProvider?.()??{enabled:!1,cellWidth:0,cellHeight:0},p=Wn(e,"drag");let m=!1;const f=(b,v)=>{if(m)return;m=!0;let E,T;if(a){const R=Pi(e,a,b,v);E=R.left,T=R.top}else E=e.element.offsetLeft,T=e.element.offsetTop;e.element.classList.add("desktop-mode-window--dragging"),c.enabled&&e.element.classList.add("desktop-mode-window--snap-drag"),e._isDragging=!0,e._dragOffsetX=b-E,e._dragOffsetY=v-T,h(u.WINDOW_DRAG_START,{windowId:e.id})};i||f(r,l);const _=b=>{if(!m){const R=b.clientX-r,pe=b.clientY-l;if(R*R+pe*pe<Qo)return;f(b.clientX,b.clientY)}if(!e._isDragging)return;let v=b.clientX-e._dragOffsetX,E=b.clientY-e._dragOffsetY;const T=e.element.parentElement;if(T){const R=zi(v,E,e.element.offsetWidth,T.clientWidth,T.clientHeight);v=R.x,E=R.y}c.enabled&&(v=Math.round(v/c.cellWidth)*c.cellWidth,E=Math.round(E/c.cellHeight)*c.cellHeight),e.element.style.left=`${v}px`,e.element.style.top=`${E}px`,e.onDragMove?.(e,b.clientX,b.clientY),p()},S=()=>{try{e._titleBar.releasePointerCapture(d)}catch{}},y=()=>{e._titleBar.removeEventListener("pointermove",_),e._titleBar.removeEventListener("pointerup",k),e._titleBar.removeEventListener("pointercancel",k),e._titleBar.removeEventListener("lostpointercapture",k)},k=()=>{if(!m){S(),y();return}if(!e._isDragging||(e._isDragging=!1,e.element.classList.remove("desktop-mode-window--dragging"),e.element.classList.remove("desktop-mode-window--snap-drag"),S(),y(),e.onDragEnd?.(e)??!1))return;e._emitChange("moved");const v={windowId:e.id,x:e.element.offsetLeft,y:e.element.offsetTop};h(u.WINDOW_DRAG_END,v),h(u.WINDOW_MOVED,v)};e._titleBar.addEventListener("pointermove",_),e._titleBar.addEventListener("pointerup",k),e._titleBar.addEventListener("pointercancel",k),e._titleBar.addEventListener("lostpointercapture",k)}function Mi(e,t){const n=e._titleBar.getBoundingClientRect(),o=n.width>0?(t.clientX-n.left)/n.width:.5,s=e.element.parentElement,i=s?Math.min(960,Math.round(s.clientWidth*.6)):640,r=s?Math.min(640,Math.round(s.clientHeight*.7)):480,l=e._savedGeometry?.width??i,d=e._savedGeometry?.height??r,a=s?.getBoundingClientRect();return{isMaximized:e.state==="maximized",cursorRatioX:o,titleBarHeight:n.height,areaLeft:a?.left??0,areaTop:a?.top??0,targetW:l,targetH:d}}function Pi(e,t,n,o){e.element.classList.remove("desktop-mode-window--maximized","desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),e.element.style.width=`${t.targetW}px`,e.element.style.height=`${t.targetH}px`;const s=Math.max($,Math.round(n-t.areaLeft-t.targetW*t.cursorRatioX)),i=Math.max($,Math.round(o-t.areaTop-t.titleBarHeight/2));return e.element.style.left=`${s}px`,e.element.style.top=`${i}px`,e.state="normal",e._emitChange("state"),t.isMaximized&&h(u.WINDOW_UNMAXIMIZED,{windowId:e.id}),{left:s,top:i}}function $i(e,t){if(e.state==="maximized"||e.state==="fullscreen")return;t.preventDefault(),t.stopPropagation();const n=t.target,o=n.dataset.dir??"se";e._isResizing=!0,e._resizeStartX=t.clientX,e._resizeStartY=t.clientY,e._resizeStartW=e.element.offsetWidth,e._resizeStartH=e.element.offsetHeight;const s=e.element.offsetLeft,i=e.element.offsetTop;n.setPointerCapture(t.pointerId),e.element.classList.add("desktop-mode-window--resizing"),h(u.WINDOW_RESIZE_START,{windowId:e.id});const r=Wn(e,"resize"),l=e.snapConfigProvider?.()??{enabled:!1,cellWidth:0,cellHeight:0};l.enabled&&e.element.classList.add("desktop-mode-window--snap-drag"),(e.state==="snapped-left"||e.state==="snapped-right")&&(e.element.classList.remove("desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),e.state="normal");const d=c=>{if(!e._isResizing)return;const p=c.clientX-e._resizeStartX,m=c.clientY-e._resizeStartY,f=Hi(o,p,m,s,i,e._resizeStartW,e._resizeStartH,e.config.minWidth,e.config.minHeight,l);e.element.style.left=`${f.x}px`,e.element.style.top=`${f.y}px`,e.element.style.width=`${f.width}px`,e.element.style.height=`${f.height}px`,r()},a=()=>{if(!e._isResizing)return;e._isResizing=!1,e.element.classList.remove("desktop-mode-window--resizing"),e.element.classList.remove("desktop-mode-window--snap-drag"),n.removeEventListener("pointermove",d),n.removeEventListener("pointerup",a),n.removeEventListener("pointercancel",a),n.removeEventListener("lostpointercapture",a),e._emitChange("resized");const c={windowId:e.id,width:e.element.offsetWidth,height:e.element.offsetHeight};h(u.WINDOW_RESIZE_END,c),h(u.WINDOW_RESIZED,c)};n.addEventListener("pointermove",d),n.addEventListener("pointerup",a),n.addEventListener("pointercancel",a),n.addEventListener("lostpointercapture",a)}function Hi(e,t,n,o,s,i,r,l,d,a){let c=i,p=r,m=o,f=s;if((e==="ne"||e==="se")&&(c=Math.max(l,i+t)),e==="nw"||e==="sw"){const _=Math.max(l,i-t);m=o+(i-_),c=_}if((e==="se"||e==="sw")&&(p=Math.max(d,r+n)),e==="ne"||e==="nw"){const _=Math.max(d,r-n);f=s+(r-_),p=_}if(a.enabled){const _=Math.max(l,Math.round(c/a.cellWidth)*a.cellWidth),S=Math.max(d,Math.round(p/a.cellHeight)*a.cellHeight);(e==="nw"||e==="sw")&&(m=o+(c-_)),(e==="nw"||e==="ne")&&(f=s+(p-S)),c=_,p=S}if(m<$){const _=$-m;m=$,c=Math.max(l,c-_)}if(f<$){const _=$-f;f=$,p=Math.max(d,p-_)}return{x:m,y:f,width:c,height:p}}function zi(e,t,n,o,s){const i=Xe-n,r=o-Xe,l=Math.max(i,Math.min(e,r)),d=$,a=s-Xe,c=Math.max(d,Math.min(t,a));return{x:l,y:c}}const st=window.location.origin,Oe=class Oe{constructor(t){if(this.state="normal",this._activityCount=0,this._activityPhase="idle",this._activityError=null,this._activityClearTimer=null,this._activitySavingStartedAt=0,this._activitySettleTimer=null,this._isDragging=!1,this._isResizing=!1,this._isDestroyed=!1,this._dragOffsetX=0,this._dragOffsetY=0,this._resizeStartX=0,this._resizeStartY=0,this._resizeStartW=0,this._resizeStartH=0,this._savedGeometry=null,this._savedFullscreenState=null,this._stateBeforeMinimize=null,this._externalTabs=new Map,this._externalTabSeq=0,this._titleBarButtonsUnsubscribe=null,this._windowThemesUnsubscribe=null,this._windowControlsUnsubscribe=null,this._windowControlsTeardown=null,this._windowSlotsUnsubscribe=null,this._windowSlotsTeardown=null,this._chromeHandle=null,this._chromeId=Ie,this._windowChromesUnsubscribe=null,this._nativeRenderTeardown=null,this._nativeRenderCtxDispose=null,this._closeSafetyNetTimer=null,this._onCloseTransitionEnd=null,this._isFinalized=!1,this._iframeBridgeReady=!1,this._iframeCloseTimeout=null,this._closePending=!1,this._activeTabId="primary",this.onFocusRequest=null,this.onClose=null,this.onMinimize=null,this.onOpenAnother=null,this.onOpenInNewWindow=null,this.onToggleStartup=null,this.snapConfigProvider=null,this.onDragMove=null,this.onDragEnd=null,this._boundOnDocumentPointerDown=null,this._bodyResizeObserver=null,this._swapBuffer=null,this._swapBufferTimer=null,this._suppressCloseFilter=!1,this.id=t.id,this.config=t,this.element=cs(t),this.iframe=t.native?null:this.element.querySelector(".desktop-mode-window__iframe"),this._titleBar=this.element.querySelector(".desktop-mode-window__titlebar"),this._titleEl=this.element.querySelector(".desktop-mode-window__title"),this._boundOnMessage=n=>Vs(this,n),this.bindEvents(),this.iframe&&this._wireContentFocusForwarder(this.iframe),this.renderCustomTitleBarButtons(),this._titleBarButtonsUnsubscribe=ii(()=>{this.renderCustomTitleBarButtons()}),et(this,this.config.appearance?.theme),this._windowThemesUnsubscribe=ci(()=>{this._isDestroyed||et(this,this.config.appearance?.theme)}),this.repaintWindowControls(),this._windowControlsUnsubscribe=gi(()=>{this._isDestroyed||this.repaintWindowControls()}),this.repaintWindowSlots(),this._windowSlotsUnsubscribe=Ci(()=>{this._isDestroyed||this.repaintWindowSlots()}),this.remountWindowChrome(),this._windowChromesUnsubscribe=Oi(()=>{if(this._isDestroyed)return;xn(this)!==this._chromeId&&this.remountWindowChrome()}),this._bodyResizeObserver=this.installBodyResizeObserver(),t.initialState==="minimized"){this.state="minimized",this.element.classList.add("desktop-mode-window--minimized"),this.iframe&&(this.iframe.style.visibility="hidden"),this.element.style.setProperty("content-visibility","hidden");return}(t.initialState==="snapped-left"||t.initialState==="snapped-right")&&this.element.classList.add(`desktop-mode-window--${t.initialState}`),this.element.classList.add("desktop-mode-window--opening"),this.element.addEventListener("animationend",()=>{this.element.classList.remove("desktop-mode-window--opening")},{once:!0}),t.initialState&&t.initialState!=="normal"&&requestAnimationFrame(()=>this.applyInitialState(t.initialState))}hydrateNative(){if(!this.config.native||!this.config.render)return;const t=this.element.querySelector(".desktop-mode-window__body");if(!t)return;const n=C(u.NATIVE_WINDOW_BEFORE_RENDER,t,{windowId:this.id,config:this.config}),o=n instanceof HTMLElement?n:t,{ctx:s,dispose:i}=no(this.id);this._nativeRenderCtxDispose=i;const r=this.config.render(o,s),l=a=>{typeof a=="function"&&(this._nativeRenderTeardown=a)};r instanceof Promise?r.then(a=>{this._isDestroyed||(l(a),P(this.id))},a=>{typeof console<"u"&&console.error(`[desktop-mode] native render rejected for "${this.id}":`,a),h(u.SHELL_ERROR,{scope:"window-open",id:this.id,error:a}),!this._isDestroyed&&P(this.id)}):(l(r),requestAnimationFrame(()=>{this._isDestroyed||P(this.id)})),h(u.NATIVE_WINDOW_AFTER_RENDER,{windowId:this.id,body:o,config:this.config});const d=this.config.autofocus;d&&requestAnimationFrame(()=>{if(this._isDestroyed)return;if(typeof d=="string"){o.querySelector(d)?.focus();return}o.hasAttribute("tabindex")||(o.tabIndex=-1),o.focus()})}applyInitialState(t){t==="minimized"?this.minimize():t==="maximized"?this.toggleMaximize():t==="fullscreen"?this.toggleFullscreen():t==="snapped-left"?this.applySnap("left"):t==="snapped-right"&&this.applySnap("right")}_emitChange(t){document.dispatchEvent(new CustomEvent("desktop-mode-window-changed",{detail:{windowId:this.id,reason:t,state:this.state}}))}snapGeometry(t){const n=this.snapConfigProvider?.();if(!n||!n.enabled)return t;const o=Math.max(this.config.minWidth,Math.round(t.width/n.cellWidth)*n.cellWidth),s=Math.max(this.config.minHeight,Math.round(t.height/n.cellHeight)*n.cellHeight);return{x:Math.round(t.x/n.cellWidth)*n.cellWidth,y:Math.round(t.y/n.cellHeight)*n.cellHeight,width:o,height:s}}getCurrentUrl(){if(!this.iframe)return this.config.url||`#${this.id}`;try{const t=this.iframe.contentWindow?.location.href;if(t&&t!=="about:blank")return t}catch{}return this.iframe.src}bindEvents(){this.element.addEventListener("pointerdown",()=>{this.element.classList.contains("desktop-mode-window--overview")||this.onFocusRequest?.(this)}),this.element.addEventListener("focusin",()=>{this.element.classList.contains("desktop-mode-window--overview")||this.onFocusRequest?.(this)}),this._titleBar.addEventListener("pointerdown",s=>Wi(this,s)),this.element.querySelectorAll(".desktop-mode-window__resize-handle").forEach(s=>{s.addEventListener("pointerdown",i=>$i(this,i))});const n=this.element.querySelector(".desktop-mode-window__menu-btn"),o=this.element.querySelector(".desktop-mode-window__menu-panel");if(n&&o){n.addEventListener("click",a=>{a.stopPropagation(),Nn(this)});const s=o.querySelector(".desktop-mode-window__menu-item--open-another");s&&s.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),j(this),this.onOpenAnother?.(this)});const i=o.querySelector(".desktop-mode-window__menu-item--open-in-new-window");i&&i.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),j(this),this.onOpenInNewWindow?.(this)});const r=o.querySelector(".desktop-mode-window__menu-item--reload");r&&r.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),j(this),this.reload()});const l=o.querySelector(".desktop-mode-window__menu-item--open-external");l&&l.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),j(this),this.detach()});const d=o.querySelector(".desktop-mode-window__menu-item--startup");d&&(ot(this,d),d.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),Di(d),this.onToggleStartup?.(this)}),document.addEventListener("desktop-mode-default-window-changed",()=>{ot(this,d)})),o.addEventListener("keydown",a=>{a.key==="Escape"&&(a.stopPropagation(),j(this),n.focus())})}if(this._titleBar.addEventListener("dblclick",s=>{s.target?.closest('button, [role="button"], [role="menuitem"], [role="menuitemcheckbox"], wpd-window-button, wpd-menu, wpd-menu-item, .desktop-mode-window__menu-panel, .desktop-mode-window__custom-buttons, input, select, textarea, a')||this.toggleMaximize()}),this.iframe){const s=this.iframe,i=this.element.querySelector(".desktop-mode-window__tabs");i&&i.addEventListener("click",r=>Cs(this,r)),this._wireTabNavSync(s),window.addEventListener("message",this._boundOnMessage)}}addExternalTab(t,n){cn(this,t,n)}setZIndex(t){this.element.style.zIndex=String(t)}setFocused(t){this.element.classList.toggle("desktop-mode-window--focused",t),this._notifyChromeStateChanged()}setTitle(t){this._titleEl.textContent=t,this.config.title=t,h(u.WINDOW_TITLE_CHANGED,{windowId:this.id,title:t}),this._notifyChromeStateChanged()}repaintWindowControls(){const t=this.element.querySelector(".desktop-mode-window__controls");if(t){if(this._windowControlsTeardown){try{this._windowControlsTeardown()}catch{}this._windowControlsTeardown=null}this._windowControlsTeardown=ki(this,t)}}repaintThemedChrome(){const t=this.element.querySelector(".desktop-mode-window__slot--icon");if(t){const o=t.querySelector(".desktop-mode-window__icon");o&&o.replaceWith(Qt(this.config.icon,{title:this.config.title,className:"desktop-mode-window__icon",slot:en(this.config.id)}))}const n=this.element.querySelector(".desktop-mode-window__menu-btn");n&&(n.querySelectorAll(":scope > .dashicons").forEach(o=>o.remove()),n.removeAttribute("icon-src"),n.setAttribute("icon","menu"),Ke(n,"core/menu"))}setAppearanceControls(t){this.config.appearance={...this.config.appearance??{},controls:t??void 0},this.repaintWindowControls()}repaintWindowSlots(){if(this._windowSlotsTeardown){try{this._windowSlotsTeardown()}catch{}this._windowSlotsTeardown=null}this._windowSlotsTeardown=Ti(this)}remountWindowChrome(){if(this._chromeHandle){try{this._chromeHandle.destroy()}catch{}this._chromeHandle=null}this.element.classList.remove(nt);const t=Ni(this);t?(this._chromeHandle=t.handle,this._chromeId=t.id):this._chromeId=Ie}setAppearanceChrome(t){this.config.appearance={...this.config.appearance??{},chrome:t??void 0},this.remountWindowChrome()}_notifyChromeStateChanged(){if(!this._isDestroyed&&this._chromeHandle?.update)try{this._chromeHandle.update(On(this))}catch{}}setAppearanceSlot(t,n){const s={...this.config.appearance?.slots??{}};n===void 0?delete s[t]:s[t]=n,this.config.appearance={...this.config.appearance??{},slots:s},this.repaintWindowSlots()}setAppearanceTheme(t){let n;t==null?n=void 0:typeof t=="string"?n={themeId:t}:typeof t=="object"&&("themeId"in t||"tokens"in t)?n=t:typeof t=="object"&&(n={tokens:t}),this.config.appearance={...this.config.appearance??{},theme:n},et(this,n)}applySnap(t){this._applySnapVisuals(t)&&(this.state=t==="left"?"snapped-left":"snapped-right",this._emitChange("state"))}_applySnapVisuals(t){const n=this.element.parentElement;if(!n)return!1;const o=Math.floor(n.clientWidth/2),s=n.clientHeight;return this.element.classList.remove("desktop-mode-window--maximized","desktop-mode-window--fullscreen","desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),this.element.classList.add(`desktop-mode-window--snapped-${t}`),this.element.style.left=t==="left"?"0px":`${o}px`,this.element.style.top="0px",this.element.style.width=`${o}px`,this.element.style.height=`${s}px`,!0}isMinimized(){return this.state==="minimized"}isMaximized(){return this.state==="maximized"}isFullscreen(){return this.state==="fullscreen"}isSnapped(t){return t==="left"?this.state==="snapped-left":t==="right"?this.state==="snapped-right":this.state==="snapped-left"||this.state==="snapped-right"}isFocused(){return this.element.classList.contains("desktop-mode-window--focused")}minimize(){this.state!=="minimized"&&(this._stateBeforeMinimize=this.state,this.state="minimized",this.element.classList.add("desktop-mode-window--minimized"),this.element.addEventListener("transitionend",t=>{t.propertyName==="opacity"&&this.state==="minimized"&&!this.element.classList.contains("desktop-mode-window--overview")&&(this.iframe&&(this.iframe.style.visibility="hidden"),this.element.style.setProperty("content-visibility","hidden"))},{once:!0}),this.onMinimize?.(this),this._emitChange("state"),h(u.WINDOW_MINIMIZED,{windowId:this.id,element:this.element}),this._stateBeforeMinimize==="fullscreen"&&ee())}restore(){this.element.style.removeProperty("content-visibility"),this.iframe&&(this.iframe.style.visibility="");const t=this.state==="minimized";this.element.classList.remove("desktop-mode-window--minimized"),t&&(this.state=this._stateBeforeMinimize??"normal",this._stateBeforeMinimize=null,this.state==="fullscreen"&&(ee(),this.updateFocusButtonState())),this.onFocusRequest?.(this),this._emitChange("state"),t&&h(u.WINDOW_RESTORED,{windowId:this.id,element:this.element})}maximize(){this.state!=="maximized"&&(this.state==="normal"&&(this._savedGeometry={x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight}),this._applyMaximizeVisuals()&&(this.state="maximized",this._emitChange("state"),h(u.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element})))}_applyMaximizeVisuals(){const t=this.element.parentElement;return t?(this.element.classList.remove("desktop-mode-window--fullscreen","desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),this.element.classList.add("desktop-mode-window--maximized"),this.element.style.left="0px",this.element.style.top="0px",this.element.style.width=`${t.clientWidth}px`,this.element.style.height=`${t.clientHeight}px`,!0):!1}toggleMaximize(){if(this.element.parentElement){if(this.state==="maximized"){if(this.element.classList.remove("desktop-mode-window--maximized"),this._savedGeometry){const n=this.snapGeometry(this._savedGeometry);this.element.style.left=`${n.x}px`,this.element.style.top=`${n.y}px`,this.element.style.width=`${n.width}px`,this.element.style.height=`${n.height}px`,this._savedGeometry=n}this.state="normal",this._emitChange("state"),h(u.WINDOW_UNMAXIMIZED,{windowId:this.id,element:this.element});return}if(this.state==="fullscreen"){this._savedFullscreenState=null,this._applyMaximizeVisuals(),this.state="maximized",ee(),this.updateFocusButtonState(),this._emitChange("state"),h(u.WINDOW_FULLSCREEN_EXITED,{windowId:this.id,element:this.element}),h(u.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element});return}this.maximize()}}toggleFullscreen(){if(this.state==="fullscreen"){this.element.classList.remove("desktop-mode-window--fullscreen");const t=this._savedFullscreenState;this._savedFullscreenState=null;let n=!1;if(t&&t.state==="maximized")this._applyMaximizeVisuals(),this.state="maximized",n=!0;else if(t&&(t.state==="snapped-left"||t.state==="snapped-right")){const o=t.state==="snapped-left"?"left":"right";this._applySnapVisuals(o),this.state=t.state}else t?(this.element.style.left=`${t.x}px`,this.element.style.top=`${t.y}px`,this.element.style.width=`${t.width}px`,this.element.style.height=`${t.height}px`,this.state="normal"):this.state="normal";ee(),this.updateFocusButtonState(),this._emitChange("state"),h(u.WINDOW_FULLSCREEN_EXITED,{windowId:this.id,element:this.element}),n&&h(u.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element});return}this.state==="normal"&&(this._savedGeometry={x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight}),this._savedFullscreenState={state:this.state,x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight},this.element.classList.remove("desktop-mode-window--maximized","desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),this.element.classList.add("desktop-mode-window--fullscreen"),this.state="fullscreen",ee(),this.updateFocusButtonState(),this._emitChange("state"),h(u.WINDOW_FULLSCREEN_ENTERED,{windowId:this.id,element:this.element})}updateFocusButtonState(){const t=this.element.querySelector(".desktop-mode-window__btn--focus");if(!t)return;const n=this.state==="fullscreen";t.classList.toggle("desktop-mode-window__btn--active",n),t.setAttribute("aria-pressed",n?"true":"false"),t.setAttribute("aria-label",g(n?"Exit fullscreen":"Enter fullscreen"))}detach(){const t=this.getCurrentUrl();let n;try{n=new URL(t,st)}catch{return}n.origin===st&&(n.searchParams.delete("desktop_mode_chromeless"),n.searchParams.delete("desktop_mode_portal"),n.searchParams.set("desktop_mode_classic","1"),window.open(n.toString(),"_blank","noopener"),h(u.WINDOW_DETACHED,{windowId:this.id,url:n.toString()}))}reload(){if(this.config.native||this.element.querySelector(".desktop-mode-window__body")?.classList.contains("desktop-mode-window__body--loading"))return;let n,o;if(this._activeTabId==="primary"){if(!this.iframe)return;const s=this.iframe;n=this.getCurrentUrl(),o=()=>{try{s.contentWindow?.location.reload()}catch{s.src=s.src}}}else{const s=this._externalTabs.get(this._activeTabId);if(!s)return;n=s.url,o=()=>{try{s.iframe.contentWindow?.location.reload()}catch{s.iframe.src=s.url}}}this._spinReloadButton(),this.markContentLoading(),o(),h(u.WINDOW_RELOADED,{windowId:this.id,url:n})}navigateTo(t){if(this.config.native||!this.iframe)return!1;const n=ke(t);if(!n)return!1;this.markContentLoading();const o=this.iframe.contentWindow;if(o)try{return o.location.assign(n),!0}catch{}return this.iframe.src=n,!0}_wireContentFocusForwarder(t){const n=()=>{let o=null;try{o=t.contentDocument}catch{return}o&&(o.location&&o.location.pathname.indexOf("/wp-admin/")!==-1||o.addEventListener("pointerdown",()=>{this.element.classList.contains("desktop-mode-window--overview")||this.onFocusRequest?.(this)},{capture:!0,passive:!0}))};t.addEventListener("load",n),n()}_wireTabNavSync(t){t.addEventListener("load",()=>{try{const n=t.contentWindow?.location.href;n&&ln(this,n)}catch{}})}_discardSwapBuffer(){this._swapBufferTimer!==null&&(window.clearTimeout(this._swapBufferTimer),this._swapBufferTimer=null),this._swapBuffer&&(this._swapBuffer.remove(),this._swapBuffer=null,this.iframe?.classList.remove("desktop-mode-window__iframe--swap-front"))}swapReload(t){if(this.config.native||!this.iframe||this._isDestroyed)return;if(this._activeTabId!=="primary"){this.reload();return}const n=t?ke(t):this.getCurrentUrl();if(!n)return;this._discardSwapBuffer();const o=this.iframe;o.classList.add("desktop-mode-window__iframe--swap-front");const s=document.createElement("iframe");s.className="desktop-mode-window__iframe desktop-mode-window__iframe--buffer",s.setAttribute("aria-hidden","true"),s.setAttribute("name",`desktop-mode-frame-${this.id}-buffer`),this._swapBuffer=s,this._swapBufferTimer=window.setTimeout(()=>{this._swapBuffer===s&&this._discardSwapBuffer()},2e4),s.addEventListener("load",()=>{if(this._swapBuffer!==s||this._isDestroyed)return;this._swapBuffer=null,this._swapBufferTimer!==null&&(window.clearTimeout(this._swapBufferTimer),this._swapBufferTimer=null);let i=0,r=0;try{i=o.contentWindow?.scrollX??0,r=o.contentWindow?.scrollY??0}catch{}if(i||r)try{s.contentWindow?.scrollTo(i,r)}catch{}s.classList.remove("desktop-mode-window__iframe--buffer"),s.removeAttribute("aria-hidden"),s.setAttribute("name",`desktop-mode-frame-${this.id}`),o.remove(),this.iframe=s,s.addEventListener("load",()=>{P(this.id)}),this._wireContentFocusForwarder(s),this._wireTabNavSync(s),ln(this,n),h(u.WINDOW_RELOADED,{windowId:this.id,url:n,silent:!0})},{once:!0}),o.insertAdjacentElement("afterend",s),s.src=n}_spinReloadButton(){const t=this.element.querySelector(".desktop-mode-window__btn--reload");t instanceof HTMLElement&&(t.classList.remove("desktop-mode-window__btn--spinning"),t.offsetWidth,t.classList.add("desktop-mode-window__btn--spinning"),t.addEventListener("animationend",()=>{t.classList.remove("desktop-mode-window__btn--spinning")},{once:!0}))}renderCustomTitleBarButtons(){const t=this.element.querySelector(".desktop-mode-window__custom-buttons--left"),n=this.element.querySelector(".desktop-mode-window__custom-buttons--right");if(!t||!n)return;t.innerHTML="",n.innerHTML="";const{left:o,right:s}=si(this),i=(r,l)=>{for(const d of l){const a=document.createElement("wpd-window-button");if(_n(a,d.icon),a.setAttribute("aria-label",d.label),a.setAttribute("title",d.label),a.classList.add("desktop-mode-window__btn"),a.classList.add("desktop-mode-window__btn--custom"),a.dataset.buttonId=d.id,r.appendChild(a),typeof d.render=="function")try{d.render(a,this)}catch(c){typeof console<"u"&&console.error("[desktop-mode] title-bar-button render threw:",d.id,c)}else typeof d.onClick=="function"&&a.addEventListener("wpd-button-activate",c=>{try{d.onClick(this,c)}catch(p){typeof console<"u"&&console.error("[desktop-mode] title-bar-button onClick threw:",d.id,p)}})}};i(t,o),i(n,s)}send(t,n){if(typeof t!="string"||t==="")return;const o=this.iframe??Jn(this.id);if(!o){Xn(this.id,t,n);return}const s=()=>{try{o.contentWindow?.postMessage({type:"desktop-mode-window-send",channel:t,payload:n},st)}catch(i){typeof console<"u"&&console.error("[desktop-mode] Window.send: postMessage failed",i)}};if(gt(this.id)){s();return}Yn(this.id,t,n,s)}on(t,n){return typeof t!="string"||t===""||typeof n!="function"?()=>{}:jn(this.id,t,n)}markContentLoading(){_e(this.id)}markContentLoaded(){P(this.id)}whenContentReady(){return gt(this.id)?Promise.resolve():new Promise(t=>{const n=this.id,o=s=>{const i=s.detail;!i||i.windowId!==n||(document.removeEventListener("desktop-mode-window-content-loaded",o),t())};document.addEventListener("desktop-mode-window-content-loaded",o)})}markActivity(t,n={}){this._activityPhase=t,this._activityError=n.error??null,this._paintActivityIndicator()}trackActivity(t){return this._markActivityStart(),t.then(n=>(this._markActivitySettled(!0),n),n=>{const o=n instanceof Error?n.message:String(n);throw this._markActivitySettled(!1,o),n})}_markActivityStart(){this._activityCount++,this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._activityCount===1&&(this._activityPhase="saving",this._activityError=null,this._activitySavingStartedAt=Date.now(),this._paintActivityIndicator())}_markActivitySettled(t,n){if(this._activityCount>0&&this._activityCount--,this._activityCount>0){!t&&n&&(this._activityError=n);return}const o=Date.now()-this._activitySavingStartedAt,s=Oe.MIN_SAVING_DISPLAY_MS-o;if(s>0){this._activitySettleTimer!==null&&window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=window.setTimeout(()=>{this._activitySettleTimer=null,this._finalizeActivitySettle(t,n)},s);return}this._finalizeActivitySettle(t,n)}_finalizeActivitySettle(t,n){this._activityPhase=t&&!this._activityError?"saved":"failed",!t&&n&&(this._activityError=n),this._paintActivityIndicator(),this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activityPhase==="saved"&&(this._activityClearTimer=window.setTimeout(()=>{this._activityClearTimer=null,this._activityPhase="idle",this._activityError=null,this._paintActivityIndicator()},2200))}_paintActivityIndicator(){if(this._isDestroyed)return;const t=this._titleBar.querySelector("[data-desktop-mode-activity-indicator]");t&&(t.setAttribute("phase",this._activityPhase),this._activityError?t.setAttribute("error",this._activityError):t.removeAttribute("error"))}requestAttention(t,n={}){const o=Me.filter("desktop-mode/window-attention-requested",{windowId:this.id,mode:t,durationMs:n.durationMs,intensity:n.intensity},n);if(!o||o.cancel===!0)return;const s=o.mode??t,i={...n,durationMs:typeof o.durationMs=="number"?o.durationMs:n.durationMs,intensity:typeof o.intensity=="string"?o.intensity:n.intensity},r=C("desktop-mode.window.attention",s,{windowId:this.id,opts:i}),l=window.wp,d=l?.desktop?.dock,a=l?.desktop?.taskbar;let c=!1;if(typeof d?.setAttention=="function"&&(d.setAttention(this.id,r,i),c=!0),typeof a?.setAttention=="function"&&(a.setAttention(this.id,r,i),c=!0),!c&&r!==null){this.setHighlight("persistent");const p=i.durationMs??4e3;p>0&&window.setTimeout(()=>{this.setHighlight(null)},p)}else!c&&r===null&&this.setHighlight(null)}shake(){if(C("desktop-mode.window.shake",!0,{windowId:this.id})===!1)return;const n=this.element;n.classList.remove("desktop-mode-window--shaking"),n.offsetWidth,n.classList.add("desktop-mode-window--shaking");const o=()=>{n.classList.remove("desktop-mode-window--shaking"),n.removeEventListener("animationend",o)};n.addEventListener("animationend",o)}setHighlight(t,n){const o=this.element;o&&(o.classList.remove("wp-window--highlight-preview","wp-window--highlight-persistent"),t==="preview"?o.classList.add("wp-window--highlight-preview"):t==="persistent"&&o.classList.add("wp-window--highlight-persistent"),n?.color?o.style.setProperty("--wp-window-highlight-color",n.color):t===null&&o.style.removeProperty("--wp-window-highlight-color"),h(u.WINDOW_HIGHLIGHT_CHANGED,{windowId:this.id,mode:t,color:n?.color}))}close(){if(!this._isDestroyed){if(this.config.native&&!this._suppressCloseFilter){if(C(u.NATIVE_WINDOW_BEFORE_CLOSE,!0,{windowId:this.id,config:this.config})===!1)return}else if(!this.config.native&&!this._suppressCloseFilter&&this._iframeBridgeReady&&this.iframe){if(this._closePending)return;this._closePending=!0;try{this.iframe.contentWindow?.postMessage({type:"desktop-mode-bridge-beforeunload-query"},location.origin),this._iframeCloseTimeout=setTimeout(()=>{this._isDestroyed||(this._suppressCloseFilter=!0,this._closePending=!1,this.close())},500);return}catch{this._closePending=!1}}if(this._isDestroyed=!0,this._discardSwapBuffer(),this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._titleBarButtonsUnsubscribe&&(this._titleBarButtonsUnsubscribe(),this._titleBarButtonsUnsubscribe=null),this._windowThemesUnsubscribe&&(this._windowThemesUnsubscribe(),this._windowThemesUnsubscribe=null),this._windowControlsUnsubscribe&&(this._windowControlsUnsubscribe(),this._windowControlsUnsubscribe=null),this._windowSlotsUnsubscribe&&(this._windowSlotsUnsubscribe(),this._windowSlotsUnsubscribe=null),this._windowChromesUnsubscribe&&(this._windowChromesUnsubscribe(),this._windowChromesUnsubscribe=null),this._nativeRenderCtxDispose){try{this._nativeRenderCtxDispose()}catch(t){h(u.SHELL_ERROR,{scope:"native-window-ctx-dispose",id:this.id,error:t})}this._nativeRenderCtxDispose=null}this._bodyResizeObserver?.disconnect(),this._bodyResizeObserver=null,Zn(this.id);try{this.config.onClose?.()}catch(t){h(u.SHELL_ERROR,{scope:"native-window-close",id:this.id,error:t})}this.onClose?.(this),this.element.classList.add("desktop-mode-window--closing"),this._onCloseTransitionEnd=t=>{t.propertyName==="opacity"&&this._finalizeClose()},this.element.addEventListener("transitionend",this._onCloseTransitionEnd),this._closeSafetyNetTimer=setTimeout(()=>this._finalizeClose(),300)}}destroy(){if(!this._isFinalized){if(!this._isDestroyed){this._suppressCloseFilter=!0;try{this.close()}finally{this._suppressCloseFilter=!1}}this._finalizeClose()}}_finalizeClose(){if(!this._isFinalized){if(this._isFinalized=!0,this._closeSafetyNetTimer!==null&&(clearTimeout(this._closeSafetyNetTimer),this._closeSafetyNetTimer=null),this._onCloseTransitionEnd&&(this.element.removeEventListener("transitionend",this._onCloseTransitionEnd),this._onCloseTransitionEnd=null),this._windowControlsTeardown){try{this._windowControlsTeardown()}catch{}this._windowControlsTeardown=null}if(this._windowSlotsTeardown){try{this._windowSlotsTeardown()}catch{}this._windowSlotsTeardown=null}if(this._chromeHandle){try{this._chromeHandle.destroy()}catch{}this._chromeHandle=null}if(pi(this),this._nativeRenderTeardown){try{this._nativeRenderTeardown()}catch(t){h(u.SHELL_ERROR,{scope:"native-window-teardown",id:this.id,error:t})}this._nativeRenderTeardown=null}window.removeEventListener("message",this._boundOnMessage),this._boundOnDocumentPointerDown&&document.removeEventListener("pointerdown",this._boundOnDocumentPointerDown,!0),this.element.remove(),ee()}}installBodyResizeObserver(){const t=this.element.querySelector(".desktop-mode-window__body");if(!t||typeof ResizeObserver>"u")return null;const n=new ResizeObserver(o=>{const s=o[0];if(!s)return;const i=s.contentRect,r=Math.round(i.width),l=Math.round(i.height);try{this.config.onResize?.(r,l)}catch(d){h(u.SHELL_ERROR,{scope:"native-window-resize",id:this.id,error:d})}h(u.WINDOW_BODY_RESIZED,{windowId:this.id,width:r,height:l})});return n.observe(t),n}getSnapshot(){if(this.element.offsetParent===null){const n=o=>{const s=parseFloat(o);return Number.isFinite(s)?Math.round(s):0};return{id:this.id,x:n(this.element.style.left),y:n(this.element.style.top),width:n(this.element.style.width),height:n(this.element.style.height),state:this.state}}return{id:this.id,x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight,state:this.state}}getExternalTabCount(){return As(this)}getExternalTabsSnapshot(){return Ss(this)}toggleActionsMenu(){Nn(this)}closeActionsMenu(){j(this)}openActionsMenu(){Dn(this)}};Oe.MIN_SAVING_DISPLAY_MS=1200;let it=Oe;function A(e,...t){return{__wpdHtml:!0,strings:e,values:t}}function Ui(e){return!!e&&e.__wpdHtml===!0}const Fi="$$wpd$$",L=/\$\$wpd\$\$(\d+)\$\$/g;function Bi(e){let t=e[0];for(let n=1;n<e.length;n++)t+=`${Fi}${n-1}$$`+e[n];return t}const Mn=new WeakMap;function Pn(e){const t=Mn.get(e);if(t)return t;const n=document.createElement("template");n.innerHTML=Bi(e);const o=[],s=(l,d)=>{if(l.nodeType===Node.ELEMENT_NODE){const p=l;for(const m of Array.from(p.attributes)){const f=m.name,_=m.value,S=f[0];if(L.test(_))if(L.lastIndex=0,S==="@"){const y=L.exec(_);L.lastIndex=0,o.push({path:d,kind:"event",name:f.slice(1),valueIndex:y?Number(y[1]):0}),p.removeAttribute(f)}else if(S==="."){const y=L.exec(_);L.lastIndex=0,o.push({path:d,kind:"prop",name:f.slice(1),valueIndex:y?Number(y[1]):0}),p.removeAttribute(f)}else if(S==="?"){const y=L.exec(_);L.lastIndex=0,o.push({path:d,kind:"bool",name:f.slice(1),valueIndex:y?Number(y[1]):0}),p.removeAttribute(f)}else{const y=[],k=[];let b=0,v;for(L.lastIndex=0;(v=L.exec(_))!==null;)y.push(_.slice(b,v.index)),k.push(Number(v[1])),b=v.index+v[0].length;y.push(_.slice(b)),o.push({path:d,kind:"attr",name:f,template:y,valueIndices:k}),p.setAttribute(f,"")}}}const a=Array.from(l.childNodes);let c=0;for(let p=0;p<a.length;p++){const m=a[p],f=p+c;if(m.nodeType===Node.TEXT_NODE){const _=m.textContent||"";if(!L.test(_)){L.lastIndex=0;continue}L.lastIndex=0;const S=m.parentNode;let y=0,k;const b=[],v=[];for(L.lastIndex=0;(k=L.exec(_))!==null;){k.index>y&&b.push(document.createTextNode(_.slice(y,k.index)));const E=document.createTextNode("");b.push(E),v.push({path:[...d,f+b.length-1],kind:"node",valueIndex:Number(k[1])}),y=k.index+k[0].length}y<_.length&&b.push(document.createTextNode(_.slice(y)));for(const E of b)S.insertBefore(E,m);S.removeChild(m),c+=b.length-1,o.push(...v)}else s(m,[...d,f])}};s(n.content,[]);const r={template:n,buildParts:l=>{const d=[];for(const a of o){let c=l;for(const p of a.path)c=c.childNodes[p];a.kind==="node"?d.push({kind:"node",valueIndex:a.valueIndex,child:{anchor:c,state:null}}):a.kind==="attr"?d.push({kind:"attr",element:c,name:a.name,template:a.template,valueIndices:a.valueIndices}):a.kind==="event"?d.push({kind:"event",valueIndex:a.valueIndex,element:c,name:a.name}):a.kind==="prop"?d.push({kind:"prop",valueIndex:a.valueIndex,element:c,name:a.name}):a.kind==="bool"&&d.push({kind:"bool",valueIndex:a.valueIndex,element:c,name:a.name})}return d}};return Mn.set(e,r),r}const $n=new WeakMap;function Gi(e,t){for(const n of e.nodes)if(n.parentNode!==t)return!1;return!0}function qi(e,t){const n=$n.get(t);if(n&&n.strings===e.strings&&Gi(n,t)){Le(n.parts,e.values);return}const o=Pn(e.strings),s=o.template.content.cloneNode(!0),i=o.buildParts(s),r=Array.from(s.childNodes);for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(s),Le(i,e.values),$n.set(t,{strings:e.strings,parts:i,nodes:r})}function Le(e,t){for(const n of e)if(n.kind==="node")rt(n.child,t[n.valueIndex]);else if(n.kind==="attr"){let o=n.template[0];for(let s=0;s<n.valueIndices.length;s++)o+=Hn(t[n.valueIndices[s]]),o+=n.template[s+1];o!==n.last&&(n.last=o,o===""?n.element.removeAttribute(n.name):n.element.setAttribute(n.name,o))}else if(n.kind==="event"){const o=t[n.valueIndex];o!==n.current&&(n.current&&n.element.removeEventListener(n.name,n.current),o&&n.element.addEventListener(n.name,o),n.current=o)}else if(n.kind==="prop"){const o=t[n.valueIndex];o!==n.last&&(n.last=o,n.element[n.name]=o)}else if(n.kind==="bool"){const o=!!t[n.valueIndex];o!==n.last&&(n.last=o,o?n.element.setAttribute(n.name,""):n.element.removeAttribute(n.name))}}function rt(e,t){if(t==null||t===!1){e.state&&(X(e.state),e.state=null);return}if(Array.isArray(t)){Xi(e,t);return}if(Ui(t)){Ki(e,t);return}if(t instanceof Node){Vi(e,t);return}ji(e,Hn(t))}function Vi(e,t){const n=e.state;n?.shape==="node"&&n.node===t||(n&&X(n),Te(e,[t]),e.state={shape:"node",node:t})}function ji(e,t){const n=e.state;if(n?.shape==="text"){n.text!==t&&(n.node.textContent=t,n.text=t);return}n&&X(n);const o=document.createTextNode(t);Te(e,[o]),e.state={shape:"text",node:o,text:t}}function Ki(e,t){const n=e.state;if(n?.shape==="template"&&n.strings===t.strings){Le(n.parts,t.values);return}n&&X(n);const o=Pn(t.strings),s=o.template.content.cloneNode(!0),i=o.buildParts(s),r=Array.from(s.childNodes);Te(e,[s]),Le(i,t.values),e.state={shape:"template",strings:t.strings,parts:i,nodes:r}}function Xi(e,t){const n=e.state;if(n?.shape==="array"&&n.entries.length===t.length){for(let s=0;s<t.length;s++)rt(n.entries[s],t[s]);return}n&&X(n);const o=[];for(const s of t){const i=document.createTextNode("");Te(e,[i]);const r={anchor:i,state:null};rt(r,s),o.push(r)}e.state={shape:"array",entries:o}}function Te(e,t){const n=e.anchor.parentNode;if(n)for(const o of t)n.insertBefore(o,e.anchor)}function X(e){if(e.shape==="text"){e.node.remove();return}if(e.shape==="template"){for(const t of e.parts)t.kind==="node"&&t.child.state&&(X(t.child.state),t.child.state=null);for(const t of e.nodes)t.parentNode&&t.parentNode.removeChild(t);return}if(e.shape==="node"){e.node.parentNode&&e.node.parentNode.removeChild(e.node);return}for(const t of e.entries)t.state&&X(t.state),t.anchor.remove()}function Hn(e){return e==null||e===!1?"":String(e)}const K=class K 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(zn)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(t,n,o){if(n===o)return;const s=Yi(t);this._propValues[s]=o,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(t){if(t==null){this.removeAttribute("class");return}const o=(Array.isArray(t)?t:String(t).split(/\s+/)).map(s=>String(s).trim()).filter(s=>s!=="");this.className=o.join(" ")}requestUpdate(){this._scheduleRender()}emit(t,n){return this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0}))}_installPropAccessors(){const t=this.constructor;for(const n of t.props){if(Object.getOwnPropertyDescriptor(this,n))continue;const o=zn(n);Object.defineProperty(this,n,{get:()=>n in this._propValues?this._propValues[n]:this.getAttribute(o),set:s=>{let i;s==null||s===!1?i=null:s===!0?i="":i=String(s),this._propValues[n]=i,i===null?this.removeAttribute(o):this.setAttribute(o,i),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&qi(this.render(),this._renderRoot)}))}_adoptStyles(){const t=this.constructor;if(t.styles.length!==0)if(t.shadow&&this.shadowRoot){const n=t.styles.map(o=>o.sheet).filter(o=>o!==null);if(this.shadowRoot.adoptedStyleSheets=n,n.length!==t.styles.length){for(const o of t.styles)if(!o.sheet){const s=document.createElement("style");s.textContent=o.cssText,this.shadowRoot.appendChild(s)}}}else this._adoptLightStyles(t)}_adoptLightStyles(t){if(!K._lightStylesAdopted.has(t)){K._lightStylesAdopted.add(t);for(const n of t.styles){const o=document.createElement("style");o.dataset.wpdUi=this.tagName.toLowerCase(),o.textContent=n.cssText,document.head.appendChild(o)}}}};K.props=[],K.styles=[],K.shadow=!0,K._lightStylesAdopted=new WeakSet;let z=K;function Y(e,t){customElements.get(e)||customElements.define(e,t)}function zn(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Yi(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}const Zi=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function Z(e,...t){let n=e[0];for(let o=1;o<e.length;o++){const s=t[o-1];if(typeof s=="string"||typeof s=="number")n+=String(s);else if(s&&s.__wpdCss)n+=s.cssText;else throw new TypeError("[wpd-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof s);n+=e[o]}if(Zi){const o=new CSSStyleSheet;return o.replaceSync(n),{__wpdCss:!0,sheet:o,cssText:n}}return{__wpdCss:!0,sheet:null,cssText:n}}const Qi=Z`:host{display:inline-flex}button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:none;border-radius:var( --wpd-btn-radius,5px );background-color:var( --wpd-btn-bg,transparent );background-image:var( --wpd-btn-bg-image,none );background-repeat:var( --wpd-btn-bg-image-repeat,no-repeat );background-size:var( --wpd-btn-bg-image-size,auto );background-position:var( --wpd-btn-bg-image-position,center );color:var( --wpd-btn-color,currentColor );cursor:pointer;transition:background-color 0.15s ease,color 0.15s ease}button:hover{color:var( --wpd-btn-color-hover,currentColor );background-color:var( --wpd-btn-bg-hover,var( --wpd-hover,rgba( 0,0,0,0.06 ) ) )}button:focus-visible{color:var( --wpd-btn-color-hover,currentColor );background-color:var( --wpd-btn-bg-hover,var( --wpd-hover,rgba( 0,0,0,0.06 ) ) );outline:2px solid var( --wpd-btn-outline,currentColor );outline-offset:1px}:host( [ active ] ) button{color:var( --wpd-btn-color-hover,currentColor );background-color:var( --wpd-btn-bg-active,var( --wpd-hover,rgba( 0,0,0,0.08 ) ) )}:host( [ danger ] ) button:hover{color:var( --wpd-fg-on-accent,#fff );background-color:var( --wpd-btn-danger-hover,var( --wpd-danger,#d63638 ) )}svg{display:block;pointer-events:none;flex-shrink:0}svg:empty{display:none}.themed-icon{display:block;width:14px;height:14px;flex-shrink:0;pointer-events:none;background-color:var( --wpd-btn-icon-color,currentColor )}::slotted( span ){line-height:1}::slotted( svg ){display:block}`,Ji={minimize:'<path d="M3 6h6" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>',maximize:'<rect x="3" y="3" width="6" height="6" rx="1" stroke="currentColor" stroke-width="1.25" fill="none"/>',fullscreen:'<path d="M4.5 2H2v2.5M10 4.5V2H7.5M4.5 10H2V7.5M10 7.5V10H7.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',"fullscreen-exit":'<path d="M2 4.5H4.5V2M7.5 2V4.5H10M2 7.5H4.5V10M7.5 10V7.5H10" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',detach:'<path d="M5 2H2.5v7.5H10V7M6.5 2H10v3.5M10 2L5.5 6.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',reload:'<g transform="translate(0.6 0.6) scale(0.021)" fill="currentColor"><path d="m504.554 233.704-76.447 91.467c-6.329 7.572-15.417 11.479-24.571 11.479a31.872 31.872 0 0 1-20.504-7.447l-91.467-76.447c-13.561-11.334-15.366-31.515-4.032-45.075s31.515-15.366 45.075-4.032l37.506 31.347c-10.274-74.891-74.668-132.774-152.337-132.774C132.984 102.223 64 171.207 64 256s68.984 153.777 153.777 153.777c17.673 0 32 14.327 32 32s-14.327 32-32 32c-58.17 0-112.859-22.653-153.991-63.785C22.653 368.859 0 314.17 0 256s22.653-112.859 63.786-153.992c41.132-41.132 95.821-63.785 153.991-63.785s112.859 22.653 153.992 63.785c32.517 32.516 53.471 73.508 60.829 117.991l22.849-27.339c11.334-13.56 31.515-15.364 45.075-4.032 13.56 11.335 15.365 31.516 4.032 45.076z"/></g>',close:'<path d="M3.25 3.25l5.5 5.5M3.25 8.75l5.5-5.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>',menu:'<circle cx="3" cy="6" r="1.2" fill="currentColor"/><circle cx="6" cy="6" r="1.2" fill="currentColor"/><circle cx="9" cy="6" r="1.2" fill="currentColor"/>'};function er(e){const t=(e??"").trim();return t===""||t.length>4096||!/^(https?:\/\/|data:image\/)/i.test(t)||/['"()\\<>\s]/.test(t)?"":t}const re=class re extends z{constructor(){super(...arguments),this._activateWired=!1}render(){const t=er(this["icon-src"]||this.getAttribute("icon-src")||""),n=t?"":this.icon||"",o=Ji[n]||"";return t?A`
2 - <button type="button">
1 +(function(){"use strict";function xe(){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 Mt(e,t,n,o){xe().addAction(e,t,n,o)}function Pt(e,t){return xe().removeAction(e,t)}function T(e,t,...n){return xe().applyFilters(e,t,...n)}function m(e,...t){xe().doAction(e,...t)}const f={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"},Po="os.activity.";function Ve(e){return Po+String(e).replace(/[^a-zA-Z0-9_.-]/g,".")}let $o=0;const Ke={publish(e,t){m(Ve(e),t)},subscribe(e,t){const n=`os/activity-sub/${++$o}`,o=Ve(e);Mt(o,n,s=>t(s));let i=!1;return()=>{i||(i=!0,Pt(o,n))}},filter(e,t,...n){return T(Ve(e),t,...n)}},$t="__openStationSharedStores";function zo(){const e=window;let t=e[$t];return t||(t=new Map,e[$t]=t),t}function k(e,t){const n=zo();let o=n.get(e);o||(o={state:t(),listeners:new Set,rebuild:t},n.set(e,o));const i={get state(){return o.state},set state(s){o.state=s},getState(){return o.state},notify(){for(const s of Array.from(o.listeners))try{s(o.state)}catch(r){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,r)}},subscribe(s){return o.listeners.add(s),()=>{o.listeners.delete(s)}},setState(s){const r=o.state;if(typeof r!="object"||r===null){console.warn(`[desktop-mode/shared-store:${e}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(r,s),i.notify()},reset(){const s=o.rebuild(),r=o.state;if(typeof r=="object"&&r!==null&&typeof s=="object"&&s!==null){const d=r;for(const a of Object.keys(d))delete d[a];Object.assign(d,s)}else o.state=s;o.listeners.clear()}};return i}const G=k("desktop-mode/window-channels",()=>({parentSubs:new Map,nativeSubs:new Map,readyWindows:new Set,loadingWindows:new Set,pendingSends:new Map}));function Te(e,t,n,o){let i=e.get(t);if(!i){if(!o)return;i=new Map,e.set(t,i)}let s=i.get(n);if(!s){if(!o)return;s=new Set,i.set(n,s)}return s}function zt(e,t,n,o){const i={channel:n,windowId:t},s=Te(e,t,n,!1);if(s)for(const d of Array.from(s))try{d(o,i)}catch(a){typeof console<"u"&&console.error(`[openstation] window-channel subscriber for "${n}" threw:`,a)}const r=Te(e,t,"*",!1);if(r)for(const d of Array.from(r))try{d(o,i)}catch(a){typeof console<"u"&&console.error(`[openstation] window-channel wildcard subscriber for "${t}" threw:`,a)}}function Ho(e,t,n){const o=Te(G.state.parentSubs,e,t,!0);o.add(n);let i=!1;return()=>{i||(i=!0,o.delete(n))}}function Ht(e,t,n){zt(G.state.parentSubs,e,t,n)}function Fo(e,t,n){const o=Te(G.state.nativeSubs,e,t,!0);o.add(n);let i=!1;return()=>{i||(i=!0,o.delete(n))}}function Uo(e,t,n){zt(G.state.nativeSubs,e,t,n)}function Ft(e){return G.state.readyWindows.has(e)}function Ie(e){const{loadingWindows:t}=G.state;t.has(e)||(t.add(e),m(f.WINDOW_CONTENT_LOADING,{windowId:e}),typeof document<"u"&&document.dispatchEvent(new CustomEvent("os-window-content-loading",{detail:{windowId:e}})))}function $(e){const{readyWindows:t,loadingWindows:n,pendingSends:o}=G.state;if(!t.has(e)){t.add(e);const i=o.get(e);if(i){o.delete(e);for(const s of i)try{s.flush()}catch(r){typeof console<"u"&&console.error(`[openstation] flushing queued window-send for "${s.channel}" threw:`,r)}}}n.delete(e)&&(m(f.WINDOW_CONTENT_LOADED,{windowId:e}),typeof document<"u"&&document.dispatchEvent(new CustomEvent("os-window-content-loaded",{detail:{windowId:e}})))}function Go(e,t,n,o){const{pendingSends:i}=G.state;let s=i.get(e);s||(s=[],i.set(e,s)),s.push({channel:t,payload:n,flush:o})}function Bo(e){const t=G.state;t.parentSubs.delete(e),t.nativeSubs.delete(e),t.readyWindows.delete(e),t.loadingWindows.delete(e),t.pendingSends.delete(e)}const qo=k("desktop-mode/connection",()=>({connSeq:0,connections:new Map,connectionsByTarget:new Map,syntheticIframes:new Map}));function Vo(e){return qo.state.syntheticIframes.get(e)??null}const Ko="data-os-mode";function Ut(e=typeof document<"u"?document.documentElement:null){return!!e&&e.getAttribute(Ko)==="mobile"}const jo=Object.freeze({top:0,right:0,bottom:0,left:0});function Yo(e,t,n){return{x:n.left,y:n.top,width:Math.max(0,e-n.left-n.right),height:Math.max(0,t-n.top-n.bottom)}}const Xo="os/work-area";function Zo(){return{insets:{...jo},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=k(Xo,()=>({snapshot:Zo(),installed:!1,areaEl:null}));function Ye(e){const t=e??je.state.areaEl;if(!t)return{...je.state.snapshot.rect};const n=t.clientWidth||t.getBoundingClientRect().width,o=t.clientHeight||t.getBoundingClientRect().height;return Yo(n,o,je.state.snapshot.insets)}const Qo="desktop-mode";function Gt(){return window.wp?.i18n}function _(e,t=Qo){return Gt()?.__(e,t)??e}function ie(e,...t){const n=Gt()?.sprintf;if(n)return n(e,...t);let o=0;return e.replace(/%(?:(\d+)\$)?[sd]/g,(i,s)=>{const r=s?Number.parseInt(s,10)-1:o++;return String(t[r]??"")})}const Jo="openstation";function ei(e,t){let n;if(typeof e=="string")try{n=new URL(e,t??(typeof window<"u"?window.location.href:void 0))}catch{return!1}else n=e;return n.pathname.slice(n.pathname.lastIndexOf("/")+1)==="admin.php"&&n.searchParams.get("page")===Jo}const Bt="os_tab",ti=k("desktop-mode/native-url-remap",()=>({remaps:[],deps:null}));function Xe(e,t={}){const{deps:n,remaps:o}=ti.state;if(!n||!e)return!1;let i;try{i=new URL(e,n.adminUrl)}catch{return!1}const s=n.getSnapshot();for(const r of o){if(!r.matches(e,i)||r.enabled&&!r.enabled(s))continue;if(r.onMatch)try{r.onMatch(e,i)}catch(u){console.warn(`[openstation] URL remap onMatch hook threw for "${r.id}":`,u)}let d;const a=i.searchParams.get(Bt);if(r.params)try{d=r.params(e,i)??void 0}catch(u){console.warn(`[openstation] URL remap params hook threw for "${r.id}":`,u)}a&&/^[a-z0-9_-]+$/.test(a)&&(d={...d??{},tab:a});const c=t.newInstance&&n.openNewById?n.openNewById:n.openById;if(d?c(r.nativeWindowId,{params:d}):c(r.nativeWindowId))return!0}return!1}const ni="os-window-tab-change";function Ze(e){return Array.from(e.querySelectorAll(".os-window__tab"))}function qt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-")}function Vt(e,t){return`${e.id||"os-window"}-tab-${qt(t)}`}function Kt(e,t){return`${e.id||"os-window"}-panel-${qt(t)}`}function jt(e){const t=e.querySelector(".os-window__tab-plate");if(!t)return;const n=e.querySelector(".os-window__tab--active");if(!n){t.dataset.empty="",e.dataset.tabPlateEmpty="";return}delete t.dataset.empty,delete e.dataset.tabPlateEmpty,e.style.setProperty("--_tab-plate-x",`${n.offsetLeft}px`),e.style.setProperty("--_tab-plate-w",`${n.offsetWidth}px`),e.style.setProperty("--_tab-strip-w",`${e.clientWidth}px`),n.offsetWidth>0&&(t.dataset.placed="")}function le(e){if(e){if(e.querySelector(":scope > .os-window__tab")){e.setAttribute("role","tablist");const t=e.dataset.tablistLabel;t&&e.setAttribute("aria-label",t);return}e.setAttribute("role","presentation"),e.removeAttribute("aria-label")}}function Yt(e){const t=Ze(e);if(t.length===0)return;const n=t.find(o=>o.classList.contains("os-window__tab--active"))??t[0];for(const o of t){const i=o===n?0:-1;o.tabIndex!==i&&(o.tabIndex=i)}}function oi(e,t){const n=t;if(n.altKey||n.ctrlKey||n.metaKey)return;const i=n.target?.closest(".os-window__tab");if(!i)return;const s=Ze(e),r=s.indexOf(i);if(r<0)return;const d=getComputedStyle(e).direction==="rtl";let a;switch(n.key){case"ArrowRight":a=s[d?r-1:r+1];break;case"ArrowLeft":a=s[d?r+1:r-1];break;case"Home":a=s[0];break;case"End":a=s[s.length-1];break;default:return}!a||a===i||(n.preventDefault(),i.tabIndex=-1,a.tabIndex=0,a.focus(),a.scrollIntoView?.({block:"nearest",inline:"nearest"}))}function Xt(e){const t=new Map;for(const n of Ze(e))n.dataset.kind==="panel"&&n.dataset.panel&&t.set(n.dataset.panel,n);return t}function Zt(e){const t=e.querySelector(".os-window__body");return t?Array.from(t.querySelectorAll("os-tabpanel[ for ]")).filter(n=>!n.parentElement?.closest("os-tabpanel, os-tabs")):[]}function Qe(e,t){const n=e.querySelector(".os-window__tabs");if(!n)return;let o=!1;for(const[i,s]of Xt(n)){const r=i===t;o=o||r,s.classList.toggle("os-window__tab--active",r),s.setAttribute("aria-selected",r?"true":"false")}if(o){for(const i of Zt(e)){const s=i.getAttribute("for")===t;i.toggleAttribute("hidden",!s),i.setAttribute("aria-hidden",s?"false":"true")}Yt(n),jt(n),e.dispatchEvent(new CustomEvent(ni,{bubbles:!0,detail:{value:t}}))}}function ii(e,t,n){const o=e.querySelector(".os-window__tabs");if(!o)return;const i=Xt(o),s=Array.from(i.entries()).find(([,l])=>l.classList.contains("os-window__tab--active"))?.[0];let r=o.querySelector(".os-window__tab-plate");for(const l of t){let u=i.get(l.value);if(u)i.delete(l.value);else{const p=document.createElement("button");p.type="button",u=p,u.className="os-window__tab",u.dataset.kind="panel",u.dataset.panel=l.value,u.setAttribute("role","tab"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}u.textContent!==l.label&&(u.textContent=l.label),u.id=Vt(e,l.value),u.setAttribute("aria-controls",Kt(e,l.value)),u.previousElementSibling!==r&&o.insertBefore(u,r?r.nextSibling:o.firstChild),r=u}for(const l of i.values())l.remove();le(o);const d=o.querySelector(":scope > .os-window__tab")!==null;for(const l of Zt(e)){const u=l.getAttribute("for");u&&(l.id=Kt(e,u),d?l.setAttribute("aria-labelledby",Vt(e,u)):l.removeAttribute("aria-labelledby"))}const a=l=>l!==void 0&&t.some(u=>u.value===l),c=[n,s,t[0]?.value].find(a);c!==void 0&&Qe(e,c)}let si=0;function ri(e,t={}){const n=++si,o=l=>`desktop-mode/native-render-ctx/${e}/${n}/${l}`,i=new AbortController,s=[],r=(l,u,p,g)=>{const b=o(u);Mt(l,b,w=>{p(w)&&g(w)});const y=()=>{Pt(l,b)};return s.push(y),y},d=l=>!!l&&typeof l=="object"&&l.windowId===e;return{ctx:{window:{send(l,u){typeof l!="string"||l===""||Ht(e,l,u)},on(l,u){return typeof l!="string"||l===""||typeof u!="function"?()=>{}:Fo(e,l,u)},markLoading(){Ie(e)},markReady(){$(e)}},markLoading(){Ie(e)},markReady(){$(e)},signal:i.signal,onResize(l){return typeof l!="function"?()=>{}:r(f.WINDOW_BODY_RESIZED,"on-resize",d,u=>{const{width:p,height:g}=u;try{l(p,g)}catch(b){m(f.SHELL_ERROR,{scope:"native-render-ctx/onResize",id:e,error:b})}})},onHide(l){return typeof l!="function"?()=>{}:r(f.WINDOW_MINIMIZED,"on-hide",d,()=>{try{l()}catch(u){m(f.SHELL_ERROR,{scope:"native-render-ctx/onHide",id:e,error:u})}})},onShow(l){return typeof l!="function"?()=>{}:r(f.WINDOW_RESTORED,"on-show",d,()=>{try{l()}catch(u){m(f.SHELL_ERROR,{scope:"native-render-ctx/onShow",id:e,error:u})}})},params:t},dispose:()=>{try{i.abort()}catch{}for(;s.length;){const l=s.pop();try{l?.()}catch{}}}}}const Qt=["post_type","page","taxonomy","path","post","c","tag_ID","item","p"].filter(e=>e!=="p"),Je=[];function ai(e){if(!e.pathname.endsWith("/admin.php")||!e.searchParams.get("page"))return Je;const t=e.searchParams.get("action");return t==="edit"&&e.searchParams.get("id")?["id"]:t==="new"?["action"]:Je}function Jt(e){try{const t=new URL(e,window.location.origin),n=new URLSearchParams,o=[...Qt,...ai(t)];for(const s of o){const r=t.searchParams.get(s);r?n.set(s,r):s==="post_type"&&(t.pathname.endsWith("/edit.php")||t.pathname.endsWith("/post-new.php"))&&n.set(s,"post")}n.sort();const i=n.toString();return t.pathname.replace(/\/+$/,"")+(i?`?${i}`:"")}catch{return e}}function Y(e){try{const t=new URL(e,window.location.origin);return t.searchParams.delete("openstation_chromeless"),t.searchParams.delete("desktop_mode_portal"),t.pathname.replace(/\/+$/,"")+"?"+t.searchParams.toString()}catch{return e}}const en="X-WP-Nonce";function li(e,t){const n=ci();if(!n)return t;const o=di(e);if(!o||!ui(o))return t;const i=t?.headers??(typeof Request<"u"&&e instanceof Request?e.headers:void 0),s=new Headers(i??{});return s.has(en)?t:(s.set(en,n),{...t??{},headers:s})}function ci(){if(typeof window>"u")return;const t=window.openStationConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function di(e){try{const t=typeof window<"u"&&window.location?window.location.href:void 0;return typeof e=="string"?new URL(e,t):e instanceof URL?e:typeof Request<"u"&&e instanceof Request?new URL(e.url,t):null}catch{return null}}function ui(e){return typeof window>"u"||!window.location||e.origin!==window.location.origin?!1:!!(e.pathname.includes("/wp-json/")||e.searchParams.has("rest_route"))}function hi(e,t,n={}){const o=window.wp?.os?.fetch;if(typeof o=="function")return o(e,t,n);const i=li(e,t);return fetch(e,i)}const tn=k("desktop-mode/dock-rail-registry",()=>({registry:new Map,listeners:new Set,activeId:"default"}));tn.state.registry,tn.state.listeners;function fi(e,t){if(!e||typeof e!="object")return["def (not an object)"];const n=e,o=[];for(const i of t)i.valid(n)||o.push(`${i.field} (${i.message})`);return o}class pi extends Error{constructor(t,n,o){super(`[openstation] ${t} registration rejected — fields: `+n.join(", ")+"."),this.name="RegistrationError",this.kind=t,this.errors=n,this.def=o}}function et(e,t,n){if(t.length!==0)throw new pi(e,t,n)}function nn(e,t,n){typeof console>"u"||console.warn(`[openstation] ${e} registration rejected — fields: `+t.join(", ")+".",n)}const X=[[0,0],[100,0],[100,100],[0,100]],mi=48,gi=80,tt=6,nt=8,on=4,sn=3,rn=64,ot=105,Z=2;function an(e){return`${Math.round(e*1e3)/1e3}%`}function Q(e){return e.slice().reverse()}function ce(e,t,n,o){return[[e,t],[n,t],[n,o],[e,o]]}function _i(e,t,n,o){const i=[];for(let s=0;s<o;s++){const r=s/o*Math.PI*2;i.push([e+Math.cos(r)*n,t+Math.sin(r)*n])}return i}function z(e,t=[]){const n=[],o=i=>{n.push(`${an(i[0])} ${an(i[1])}`)};for(const i of e)o(i);if(t.length>0){o(e[0]);for(const i of t){for(const s of i)o(s);o(i[0]),o(e[0])}}return`polygon( ${n.join(", ")} )`}function ln(e){return z(X,[Q(_i(50,50,e,mi))])}function cn(e){return z(X,[Q(ce(50-e,-Z,50+e,100+Z))])}function dn(e){const t=100/tt,n=[];for(let o=0;o<tt;o++){const i=o*t;n.push(Q(ce(-Z,i,100+Z,i+e)))}return z(X,n)}function un(e){return z(X,[Q(ce(-Z,50-e,100+Z,50+e))])}function hn(e){const t=100/nt,n=[];for(let o=0;o<nt;o++){const i=o*t;n.push(Q(ce(i,-Z,i+e,100+Z)))}return z(X,n)}function fn(e){return z(X,[Q([[50,50-e],[50+e,50],[50,50+e],[50-e,50]])])}function pn(e){const t=100/on,n=100/sn,o=[];for(let i=0;i<sn;i++)for(let s=0;s<on;s++){const r=s*t+t/2,d=i*n+n/2,a=t/2*e,c=n/2*e;o.push(Q(ce(r-a,d-c,r+a,d+c)))}return z(X,o)}function mn(e){const t=-Math.PI/2,n=e/180*Math.PI,o=[[50,50]];for(let i=0;i<rn;i++){const s=t+i/(rn-1)*n;o.push([50+Math.cos(s)*ot,50+Math.sin(s)*ot])}return z(X,[Q(o)])}function bi(){return{from:ln(0),to:ln(gi)}}function wi(){return{from:cn(0),to:cn(52)}}function yi(){return{from:dn(0),to:dn(100/tt+.5)}}function vi(){return{from:un(0),to:un(52)}}function Ei(){return{from:hn(0),to:hn(100/nt+.5)}}function Ai(){return{from:fn(0),to:fn(ot)}}function Si(){return{from:pn(0),to:pn(1.04)}}function Ci(){return{from:mn(0),to:mn(360)}}function ki(){return{from:"inset( 0% 0% 0% 0% )",to:"inset( 0% 0% 100% 0% )"}}function xi(){return{from:"inset( 0% 0% 0% 0% )",to:"inset( 0% 0% 0% 100% )"}}function Ti(){return{from:z([[-60,0],[100,0],[100,100],[0,100]]),to:z([[100,0],[260,0],[260,100],[160,100]])}}const it=6,st=100,se=st/2,Le=200,gn=90,_n=["#5c5c6d","#525261","#484855","#3e3e49","#34343d","#2a2a31"],Ii="#101014",Li=1.25,re="http://www.w3.org/2000/svg";let Ni=0;function Ne(e){return Math.round(e*1e3)/1e3}function rt(e){return e/it*Math.PI*2-Math.PI/2}function Ri(e){const n=rt(e)+Math.PI/it+Math.PI/2;return{x:Math.cos(n),y:Math.sin(n)}}function Oi(e){const t=rt(e),n=rt(e+1);return[[se,se],[se+Math.cos(t)*Le,se+Math.sin(t)*Le],[se+Math.cos(n)*Le,se+Math.sin(n)*Le]]}function bn(e,t){const n=Oi(e),o=document.createElementNS(re,"path");return o.setAttribute("d",`M ${n.map(([i,s])=>`${Ne(i)} ${Ne(s)}`).join(" L ")} Z`),t?o.setAttribute("fill","#fff"):(o.setAttribute("fill",_n[e%_n.length]),o.setAttribute("stroke",Ii),o.setAttribute("stroke-width",String(Li)),o.setAttribute("vector-effect","non-scaling-stroke"),o.setAttribute("stroke-linejoin","round")),o}function Di(){const e=`os-iris-${++Ni}`,t=document.createElementNS(re,"svg");t.setAttribute("viewBox",`0 0 ${st} ${st}`),t.setAttribute("preserveAspectRatio","none"),t.setAttribute("aria-hidden","true"),t.style.width="100%",t.style.height="100%",t.style.display="block";const n=document.createElementNS(re,"defs"),o=document.createElementNS(re,"mask");o.setAttribute("id",e);const i=document.createElementNS(re,"g"),s=document.createElementNS(re,"g");s.setAttribute("mask",`url(#${e})`);const r=[];for(let a=0;a<it;a++){const c=bn(a,!0),l=bn(a,!1);i.appendChild(c),s.appendChild(l),r.push({el:c,index:a},{el:l,index:a})}o.appendChild(i),n.appendChild(o),t.appendChild(n),t.appendChild(s);const d=document.createElement("div");return d.appendChild(t),{element:d,play:a=>r.map(({el:c,index:l})=>{const u=Ri(l),p=Ne(u.x*gn),g=Ne(u.y*gn);return c.animate([{transform:"translate( 0px, 0px )"},{transform:`translate( ${p}px, ${g}px )`}],{duration:a.duration,easing:a.easing,delay:a.delay,fill:"both"})})}}const at="none",Wi=70,Mi=600,wn=k("desktop-mode/window-reveal-registry",()=>({registry:new Map,listeners:new Set})),yn=wn.state.registry,Pi=wn.state.listeners,vn=/^[a-z0-9_/-]+$/;function En(e){const t=/^\s*([a-zA-Z-]+)\s*\(/.exec(e);return t?t[1].toLowerCase():""}const $i=0;function zi(e){return typeof e!="number"||!Number.isFinite(e)?Wi:Math.min(Mi,Math.max(0,e))}function Hi(e){return typeof e.render=="function"?[]:Array.isArray(e.layers)&&e.layers.length>0?e.layers:typeof e.from=="string"&&typeof e.to=="string"?[{from:e.from,to:e.to}]:[]}function An(e,t){const n=[],o=typeof e.from=="string"&&e.from.trim()!=="",i=typeof e.to=="string"&&e.to.trim()!=="";if(o||n.push(`${t}.from (missing — the clip-path covering the window)`),i||n.push(`${t}.to (missing — the clip-path uncovering the window)`),o&&i){const s=En(e.from),r=En(e.to);s===""||r===""?n.push(`${t}.from|to (must be shape functions, e.g. \`inset( … )\` or \`polygon( … )\` — bare keywords like \`none\` cannot be animated)`):s!==r&&n.push(`${t}.from|to (must use the same shape function to interpolate — got \`${s}()\` and \`${r}()\`)`)}return n}function Fi(e){if(typeof KeyframeEffect!="function")return!0;try{return new KeyframeEffect(null,null,{easing:e}),!0}catch{return!1}}function W(e){const t=[];if(!e||typeof e!="object")t.push("def (not an object)");else{typeof e.id!="string"||e.id.trim()===""?t.push("id (missing)"):vn.test(e.id.trim().toLowerCase())?e.id.trim().toLowerCase()===at&&t.push('id ("none" is reserved)'):t.push(`id (must match ${vn} — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-id)`),(typeof e.label!="string"||e.label.trim()==="")&&t.push("label (missing)");const o=e.render!==void 0,i=Array.isArray(e.layers),s=e.from!==void 0||e.to!==void 0;o&&typeof e.render!="function"?t.push("render (not a function)"):o&&(i||s)?t.push("render|layers|from|to (supply exactly one of: a from/to pair, a layers array, or a render function)"):o||(i&&s?t.push("layers|from|to (supply EITHER a single from/to pair OR a layers array, not both)"):i?(e.layers.length===0&&t.push("layers (empty — supply at least one matched pair)"),e.layers.forEach((r,d)=>{if(!r||typeof r!="object"){t.push(`layers[ ${d} ] (not an object)`);return}t.push(...An(r,`layers[ ${d} ]`))})):t.push(...An(e,"").map(r=>r.replace(/^\./,"")))),e.easing!==void 0&&(typeof e.easing!="string"||e.easing.trim()===""?t.push("easing (not a non-empty string)"):Fi(e.easing)||t.push("easing (not an easing the browser can parse — `Element.animate()` would throw at play time, with the covering surface already over the window)"))}et("WindowReveal",t,e);const n=e.id.trim().toLowerCase();yn.set(n,{...e,id:n}),Bi()}function Ui(){const e=Array.from(yn.values()),t=T(f.WINDOW_REVEALS,e);return Array.isArray(t)?t:(typeof console<"u"&&console.warn("[openstation] `os.window-reveals` filter returned a non-array; falling back to registry list."),e)}function Gi(e){return Ui().find(t=>t.id===e)}function Bi(){const e=Array.from(Pi);for(const t of e)try{t()}catch(n){typeof console<"u"&&console.error("[openstation] window-reveal registry listener threw:",n)}}W({id:"sweep",label:_("Sweep"),description:_("A straight edge travels across the window, uncovering the page behind it."),...xi(),duration:420}),W({id:"iris",label:_("Iris"),description:_("The page opens out from the centre of the window, like a camera shutter."),...bi(),duration:520}),W({id:"curtain",label:_("Curtain"),description:_("Two panels part from the middle of the window and slide off the sides."),...wi(),duration:480}),W({id:"blinds",label:_("Blinds"),description:_("Six horizontal slats retract at once, letting the page through between them."),...yi(),duration:560}),W({id:"diagonal",label:_("Diagonal"),description:_("A slanted edge sweeps off the trailing corner of the window."),...Ti(),duration:460}),W({id:"rise",label:_("Rise"),description:_("The page rises into the window from the bottom edge upward."),...ki(),duration:440}),W({id:"shutter",label:_("Shutter"),description:_("Two panels part from the middle of the window and slide off the top and bottom."),...vi(),duration:480}),W({id:"slats",label:_("Slats"),description:_("Eight vertical slats retract at once, letting the page through between them."),...Ei(),duration:560}),W({id:"diamond",label:_("Diamond"),description:_("The page opens out from the centre of the window through a growing rhombus."),...Ai(),duration:520}),W({id:"mosaic",label:_("Mosaic"),description:_("The page arrives as a grid of tiles, each opening out from its own centre."),...Si(),duration:600}),W({id:"obturator",label:_("Camera shutter"),description:_("Six wedges slide aside in unison, opening a hexagonal aperture from the centre like the iris of a camera lens."),render:Di,duration:720,edgeLag:0}),W({id:"radar",label:_("Radar"),description:_("A spoke sweeps a full turn around the centre of the window, uncovering the page behind it."),...Ci(),duration:760});const Sn={dockSize:["compact","default","large"],desktopLayout:["classic","unified"],dockPlacement:["bottom","left","right"],windowRadius:["sharp","default","round"],adminBarMode:["static","dynamic","hidden"]},Cn=["dockRailRenderer","windowReveal","accent"],kn={windowRevealDuration:{min:80,max:4e3}},qi=/^[a-z0-9_-]+$/;[...Object.keys(Sn),...Cn,...Object.keys(kn)];function Vi(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t=e,n={},o={};for(const[i,s]of Object.entries(Sn)){const r=t[i];typeof r=="string"&&s.includes(r)&&(n[i]=r)}for(const i of Cn){const s=t[i];typeof s=="string"&&qi.test(s)&&(n[i]=s)}for(const[i,s]of Object.entries(kn)){const r=t[i];typeof r=="number"&&Number.isFinite(r)&&(o[i]=Math.min(s.max,Math.max(s.min,Math.round(r))))}return{...n,...o}}const Ki=/^[a-z0-9_-]+$/,xn=128;function ji(e){return typeof e!="string"||e===""||e.length>2048?!1:e.startsWith("dashicons-")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("data:image/")}function Yi(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.slug=="string"?t.slug:"";if(!Ki.test(n))return null;const o={};if(t.icons&&typeof t.icons=="object"){let a=0;for(const[c,l]of Object.entries(t.icons)){if(a>=xn)break;c===""||!ji(l)||(o[c]=l,a+=1)}}const i={};if(t.tokens&&typeof t.tokens=="object")for(const[a,c]of Object.entries(t.tokens))typeof c=="string"&&(i[a]=c);const s=[];if(Array.isArray(t.fonts))for(const a of t.fonts)typeof a=="string"&&a!==""&&s.push(a);const r={};if(t.iconColors&&typeof t.iconColors=="object"){let a=0;for(const[c,l]of Object.entries(t.iconColors)){if(a>=xn)break;c===""||typeof l!="string"||l===""||(r[c]=l,a+=1)}}const d=a=>typeof t[a]=="string"?t[a]:"";return{id:d("id")||n,slug:n,name:d("name")||n,version:d("version"),author:d("author"),description:d("description"),previewUrl:d("previewUrl"),cssUrl:d("cssUrl"),cssText:d("cssText"),tokens:i,fonts:s,icons:o,iconColors:r,recommendedOsSettings:Vi(t.recommendedOsSettings),installedAt:typeof t.installedAt=="number"?t.installedAt:0,source:t.source==="code"?"code":"upload",cssDeferred:t.cssDeferred===!0}}function Xi(){const t=window.openStationConfig?.serverDesktopThemes,n=[];if(Array.isArray(t))for(const o of t){const i=Yi(o);i&&n.push(i)}return{themes:n,activeId:null,activeIcons:null,activeIconColors:null}}const Zi=k("desktop-mode/desktop-themes",Xi);function Tn(){return Zi}function In(e){const t=Tn().state;if(t.activeIcons===null||!e)return null;const n=t.activeIcons[e];if(typeof n!="string"||n==="")return null;const o=T(f.DESKTOP_THEME_ICON,n,{slot:e,themeId:t.activeId??""});return typeof o=="string"&&o!==""?o:null}function Ln(e){const t=Tn().state;if(t.activeIconColors===null||!e)return null;const n=t.activeIconColors[e];if(typeof n!="string"||n==="")return null;const o=T(f.DESKTOP_THEME_ICON_COLOR,n,{slot:e,themeId:t.activeId??""});return typeof o=="string"&&o!==""?Qi(o):null}function Qi(e){const t=e.trim();if(t===""||t.length>64||/[;{}<>"'\\]/.test(t))return null;let n=0;for(const o of t)if(o==="(")n+=1;else if(o===")"&&(n-=1,n<0))return null;return n===0?t:null}const de={OS_SETTINGS:"OS_SETTINGS",RECYCLE_BIN:"RECYCLE_BIN",BUG_REPORT:"BUG_REPORT",EXIT_OPENSTATION:"EXIT_OPENSTATION",PWA_INSTALL:"PWA_INSTALL"},Ji={"desktop-mode-os-settings":de.OS_SETTINGS,"desktop-mode-recycle-bin":de.RECYCLE_BIN,"desktop-mode-bug-report":de.BUG_REPORT,"os-exit":de.EXIT_OPENSTATION,"os-pwa-install":de.PWA_INSTALL};function es(e){if(typeof e!="string"||e==="")return"";const t=Ji[e];if(t)return t;const n=e.toLowerCase().replace(/[^a-z0-9_-]/g,"");return n===""?"":`APP:${n}`}function ts(e){if(typeof e!="string"||e==="")return"";const t=e.replace(/^core\//,"").toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return t===""?"":`WINDOW_CONTROL_${t}`}function lt(e,t){const n=ts(t),o=In(n),i=Ln(n);if(o===null&&i===null)return!1;if(i!==null?e.style.setProperty("--os-ui-btn-icon-color",i):e.style.removeProperty("--os-ui-btn-icon-color"),o===null)return e.style.setProperty("color",i),!1;if(o.startsWith("dashicons-")){e.removeAttribute("icon-src"),e.removeAttribute("icon");const s=document.createElement("span");return s.className=`dashicons ${o}`,s.setAttribute("aria-hidden","true"),i!==null&&(s.style.color=i),e.appendChild(s),!0}return e.setAttribute("icon-src",o),!0}let ct=null;function Re(){return!!window.openStationShellOverlays}function ns(e){return new Promise((t,n)=>{const o=document.querySelector('script[data-os-shell-overlays="1"]'),i=()=>{if(Re()){t();return}n(new Error("[openstation] shell-overlays bundle loaded but did not set `window.openStationShellOverlays`."))};if(o){Re()?i():(o.addEventListener("load",i),o.addEventListener("error",()=>n(new Error("failed to load shell-overlays bundle"))));return}const s=document.createElement("script");s.src=e,s.async=!0,s.dataset.osShellOverlays="1",s.addEventListener("load",i),s.addEventListener("error",()=>n(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(s)})}function os(e){return Re()||!e?Promise.resolve():(ct||(ct=ns(e)),ct)}function is(){return window.openStationConfig?.shellOverlaysBundleUrl??""}function ss(e,t){const n=is();if(Re()||!n){t();return}os(n).then(()=>{e()&&t()}).catch(o=>{typeof console<"u"&&console.warn("[openstation] shell-overlays failed to load; menu/dialog suppressed:",o)})}const rs=4e3,as=200,ls=1200;function dt(e){const t=Ke.filter("os/toast-requested",{...e});if(!t||t.cancel===!0)return()=>{};let n=!1,o=null;return ss(()=>!n,()=>{o=us(t)}),()=>{n=!0,o&&o()}}const cs={success:"positive",warning:"warning",error:"critical","shell-error":"critical"};function ds(e){return e?window.openStationConfig?.toastTypes?.find(o=>o.id===e)?.tone??cs[e]??null:null}function us(e){const t=ms(),n=document.createElement("os-toast");n.textContent=e.message;const o=ds(e.type);o&&n.setAttribute("tone",o),e.action&&(n.setAttribute("action",e.action.label),n.addEventListener("os-toast-action",()=>{e.action?.onClick(),c()})),e.dismissible&&(n.setAttribute("dismissible",""),n.addEventListener("os-toast-dismiss",()=>{e.onDismiss?.(),c()})),t.appendChild(n);let i=!1,s=null,r=e.duration??rs,d=0;const a=()=>{s!==null&&(window.clearTimeout(s),s=null)},c=()=>{i||(i=!0,a(),ps(n),n.setAttribute("state","out"),window.setTimeout(()=>{n.remove(),fs()},as))},l=()=>{i||e.persistent||s!==null||(d=Date.now(),s=window.setTimeout(c,r))},u=()=>{s!==null&&(r=Math.max(0,r-(Date.now()-d)),a())};return requestAnimationFrame(()=>{n.setAttribute("state","in")}),n.addEventListener("os-toast-hold",p=>{if(p.detail?.held){u();return}r=Math.max(r,ls),l()}),hs(n),l(),Ke.publish("os/toast-shown",{...e}),c}let Oe=null,ue=0;function Nn(e){const t=e.target;t instanceof HTMLElement&&(t.closest("os-toast-container")||(Oe=t))}function hs(e){ue===0&&document.addEventListener("focusin",Nn,!0),ue+=1;const t=e.ownerDocument,n=t.activeElement;n instanceof HTMLElement&&n!==t.body&&!n.closest("os-toast-container")&&(Oe=n)}function fs(){ue=Math.max(0,ue-1),ue===0&&document.removeEventListener("focusin",Nn,!0)}function ps(e){const t=e.ownerDocument.activeElement;t!==e&&!e.contains(t)||Oe?.isConnected===!0&&Oe.focus()}function ms(){const e=document.querySelector("os-toast-container");if(e)return e;const t=document.createElement("os-toast-container");return document.body.appendChild(t),t}const gs="http://localhost/";function _s(e,t){const n=typeof window<"u"&&window.location?window.location.href:gs,o=new URL(e,n),i=t.replace(/^\/+/,""),s=i.indexOf("?"),r=s===-1?i:i.slice(0,s),d=s===-1?"":i.slice(s+1);if(o.searchParams.has("rest_route")){const a=o.searchParams.get("rest_route")??"/",c=a.endsWith("/")?a:a+"/";o.searchParams.set("rest_route",c+r)}else{const a=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";o.pathname=a+r}return d&&new URLSearchParams(d).forEach((c,l)=>{o.searchParams.append(l,c)}),o.toString()}`${btoa('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="6" stroke-linejoin="round"><rect x="6" y="6" width="27" height="27" rx="5"/><rect x="43" y="6" width="15" height="15" rx="5"/><rect x="43" y="31" width="15" height="27" rx="5"/><rect x="6" y="43" width="27" height="15" rx="5"/></svg>')}`,`${btoa('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="6" stroke-linecap="round"><path d="M10 22h44M10 42h44"/><circle cx="24" cy="22" r="7" fill="currentColor" stroke="none"/><circle cx="42" cy="42" r="7" fill="currentColor" stroke="none"/></svg>')}`;function bs(e){try{(window.top??window).location.assign(e)}catch{window.location.assign(e)}}const Rn=800;function ws(e,t=Rn){window.setTimeout(()=>{if(e){bs(e);return}try{(window.top??window).location.reload()}catch{window.location.reload()}},t)}const ys="desktop-mode/v1",vs=3e4,Es=3,he=k("desktop-mode/plugin-presence",()=>({confirmInFlight:!1,lastConfirmAt:null,exiting:!1,booted:!1,negativeConfirms:0}));function ut(){return window.wp?.os?.config??{}}function As(){const e=ut().adminUrl||"/wp-admin/";let t;try{t=new URL(e,window.location.href).pathname}catch{t="/wp-admin/"}return t.endsWith("/")?t:`${t}/`}function Ss(){const e=ut().restUrl;return e?_s(e,ys):null}function Cs(){he.state.negativeConfirms=0}async function ks(){const e=he.state;if(e.exiting||e.confirmInFlight||e.negativeConfirms>=Es)return;const t=Ss();if(!t)return;const n=Date.now();if(!(e.lastConfirmAt!==null&&n-e.lastConfirmAt<vs)){e.lastConfirmAt=n,e.confirmInFlight=!0;try{const o=await hi(t,{credentials:"same-origin"},{silent:!0,source:"desktop-mode/plugin-presence"});if(o.status!==404){e.negativeConfirms+=1;return}if((await o.json())?.code!=="rest_no_route"){e.negativeConfirms+=1;return}xs()}catch{}finally{e.confirmInFlight=!1}}}function xs(){if(!he.state.exiting){he.state.exiting=!0,ws(ut().adminUrl||"");try{dt({message:_("OpenStation is no longer active. Returning to the WordPress dashboard…"),duration:Rn})}catch{}}}function ht(e){if(he.state.exiting)return;let t=null;try{t=e.contentDocument}catch{return}if(!(!t?.body||!t.location)&&t.location.pathname.startsWith(As())){if(t.body.classList.contains("os-chromeless")){Cs();return}ks()}}const B=0,ft=40,On=5,Ts=On*On,Is=3e3,Ls=250,Ns=15e3,Rs=120,pt="os-window__loading",Dn="os-window__loading--visible",Os=k("desktop-mode/window-reveal-active",()=>({id:at,duration:$i}));function Ds(){const e=Os.state.id;return!e||e===at?null:Gi(e)??null}const mt="os-window__reveal",Ws="os-window__reveal--edge",Ms="os-window__reveal--custom",Wn="data-os-reveal",Mn="data-os-reveal-layer",Ps=k("desktop-mode/window-reveal-rendered",()=>({plays:new WeakMap})).state.plays;function Pn(e,t,n,o){const i=document.createElement("div");i.className=o?`${mt} ${Ws}`:mt;const s=o?e.edgeColor:t.color??e.surfaceColor;return typeof s=="string"&&s!==""&&(i.style.background=s),i.setAttribute("aria-hidden","true"),i.setAttribute(Wn,e.id),i.setAttribute(Mn,String(n)),i.style.clipPath=t.from,i}function $s(){const e=Ds();if(!e)return[];if(typeof e.render=="function"){let o;try{o=e.render()}catch(s){return typeof console<"u"&&console.error(`[openstation] window reveal "${e.id}" render threw:`,s),[]}if(!o?.element||typeof o.play!="function")return[];const i=o.element;return i.classList.add(mt),i.classList.add(Ms),i.setAttribute("aria-hidden","true"),i.setAttribute(Wn,e.id),i.setAttribute(Mn,"0"),Ps.set(i,o.play),[i]}const t=Hi(e);if(t.length===0)return[];const n=[];return zi(e.edgeLag)>0&&t.forEach((o,i)=>n.push(Pn(e,o,i,!0))),t.forEach((o,i)=>n.push(Pn(e,o,i,!1))),n}const $n="os-window__body--loading",zn="data-os-loading-at",Hn="data-os-loading-cycle";function zs(e){return e.getAttribute(Hn)??"0"}function Hs(e){e.setAttribute(zn,String(Date.now())),e.setAttribute(Hn,String(Number(zs(e))+1))}function Fs(e,t){const n=Number(e.getAttribute(zn)),o=Number.isFinite(n)&&n>0?Date.now()-n:0,i=Rs-o;if(i<=0){t.classList.add(Dn);return}window.setTimeout(()=>{t.isConnected&&e.classList.contains($n)&&t.classList.add(Dn)},i)}const Us=Symbol.for("desktop-mode/window-config");function Gs(e,t){e[Us]=t}const gt=window.location.origin;function Bs(e){try{return new URL(e,gt).searchParams.has(Bt)}catch{return!1}}function fe(e){const t=new URL(e,gt);return t.origin!==gt||ei(t)?null:(t.searchParams.set("openstation_chromeless","1"),t.toString())}function J(){const e=document.querySelectorAll(".os-window--fullscreen:not(.os-window--minimized)").length>0;document.body.classList.toggle("os-has-fullscreen-window",e)}function qs(){const e=document.createElement("div");e.className=pt,e.setAttribute("role","status"),e.setAttribute("aria-live","polite");const t=document.createElement("os-spinner");return t.setAttribute("preset","classic"),t.setAttribute("size","clamp(96px, 14vw, 192px)"),t.setAttribute("label",_("Loading window content")),e.appendChild(t),e}function Vs(e){let t=qs();const n={windowId:e.id,config:e};if(typeof e.loading?.render=="function")try{e.loading.render(t,n)}catch(o){typeof console<"u"&&console.error(`[openstation] loading.render threw for "${e.id}":`,o)}try{const o=T(f.WINDOW_LOADING_OVERLAY,t,n);o instanceof HTMLElement&&(t=o)}catch(o){typeof console<"u"&&console.error(`[openstation] WINDOW_LOADING_OVERLAY filter threw for "${e.id}":`,o)}return t&&!t.classList.contains(pt)&&t.classList.add(pt),t}function ee(e){const t=document.createElement("span");return t.className=`os-window__slot os-window__slot--${e}`,t.dataset.slot=e,t}function Ks(e){const t=document.createElement("div");t.className="os-window",e.native&&t.classList.add("os-window--native"),t.id=`wp-window-${e.id}`,t.setAttribute("role","dialog"),t.setAttribute("aria-labelledby",`wp-window-title-${e.id}`),t.setAttribute("aria-busy","true"),t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`;const n=document.createElement("div");n.className="os-window__titlebar";const o=document.createElement("os-window-button");o.setAttribute("icon","menu"),lt(o,"core/menu"),o.setAttribute("aria-label",_("Window actions")),o.setAttribute("aria-haspopup","menu"),o.setAttribute("aria-expanded","false"),o.classList.add("os-window__btn"),o.classList.add("os-window__menu-btn");const i=document.createElement("os-menu");i.classList.add("os-window__menu-panel"),i.hidden=!0;const s=document.createElement("os-menu-item");if(s.setAttribute("role","menuitemcheckbox"),s.setAttribute("value","startup"),s.classList.add("os-window__menu-item"),s.classList.add("os-window__menu-item--startup"),s.textContent=_("Open on startup"),i.appendChild(s),e.multi){const h=document.createElement("os-menu-item");h.setAttribute("role","menuitem"),h.setAttribute("value","open-another"),h.setAttribute("icon","dashicons-plus-alt2"),h.classList.add("os-window__menu-item"),h.classList.add("os-window__menu-item--open-another"),h.textContent=ie(_("Open another %s"),e.title),i.appendChild(h)}if(!e.native){const h=document.createElement("os-menu-item");h.setAttribute("role","menuitem"),h.setAttribute("value","open-in-new-window"),h.setAttribute("icon","dashicons-plus-alt"),h.classList.add("os-window__menu-item"),h.classList.add("os-window__menu-item--open-in-new-window"),h.textContent=_("Open in new window"),i.appendChild(h)}if(!e.native||e.render){const h=document.createElement("os-menu-item");h.setAttribute("role","menuitem"),h.setAttribute("value","reload"),h.setAttribute("icon","dashicons-update"),h.classList.add("os-window__menu-item"),h.classList.add("os-window__menu-item--reload"),h.textContent=_("Reload"),i.appendChild(h)}if(!e.native){const h=document.createElement("os-menu-item");h.setAttribute("role","menuitem"),h.setAttribute("value","open-external"),h.setAttribute("icon","dashicons-external"),h.classList.add("os-window__menu-item"),h.classList.add("os-window__menu-item--open-external"),h.textContent=_("Open in browser tab"),i.appendChild(h)}const r=ee("icon"),d=ee("title"),a=document.createElement("span");a.className="os-window__title",a.id=`wp-window-title-${e.id}`,a.textContent=e.title,d.appendChild(a);const c=ee("before-titlebar"),l=ee("before-icon"),u=ee("after-title"),p=ee("before-controls"),g=ee("after-controls"),b=ee("after-titlebar"),y=document.createElement("div");y.className="os-window__controls";const w=document.createElement("div");w.className="os-window__screen-meta";const S=document.createElement("span");S.className="os-window__custom-buttons os-window__custom-buttons--left";const E=document.createElement("span");E.className="os-window__custom-buttons os-window__custom-buttons--right";const C=document.createElement("os-save-status");C.className="os-window__status",C.setAttribute("mode","icon"),C.setAttribute("variant","ring"),C.setAttribute("phase","idle"),C.setAttribute("data-os-activity-indicator","");const N=document.createElement("span");N.className="os-window__activity-status",N.setAttribute("role","status"),N.setAttribute("aria-live","polite"),n.appendChild(N),n.appendChild(C),n.appendChild(l),n.appendChild(r),n.appendChild(d),n.appendChild(u),n.appendChild(S),n.appendChild(w),o&&i&&i.children.length>0&&(n.appendChild(o),n.appendChild(i)),n.appendChild(E),n.appendChild(p),n.appendChild(y),n.appendChild(g);for(const h of Array.from(n.children))h.setAttribute("data-os-default-chrome","");const D=document.createElement("div");if(D.className=`os-window__body ${$n}`,Hs(D),e.native)D.classList.add("os-window__body--native");else{const h=document.createElement("iframe");h.className="os-window__iframe",h.setAttribute("name",`os-frame-${e.id}`);const v=e.url?fe(e.url):null;h.src=v??"about:blank",D.appendChild(h);const I=()=>{$(e.id),ht(h)};h.addEventListener("load",I)}const Se=Vs(e);D.appendChild(Se),Fs(D,Se);for(const h of $s())D.appendChild(h);Ie(e.id);const j=[];for(const h of["ne","nw","se","sw"]){const v=document.createElement("div");v.className=`os-window__resize-handle os-window__resize-handle--${h}`,v.dataset.dir=h,v.setAttribute("aria-hidden","true"),j.push(v)}t.appendChild(c),t.appendChild(n),t.appendChild(b);{const h=document.createElement("nav");h.className="os-window__tabs";const v=document.createElement("span");v.className="os-window__tab-plate",v.setAttribute("aria-hidden","true");const I=document.createElement("span");I.className="os-window__tab-plate-fill";const H=document.createElement("span");H.className="os-window__tab-plate-joint",v.appendChild(I),v.appendChild(H),h.appendChild(v),e.native?h.dataset.tablistLabel=ie(_("%s sections"),e.title):h.dataset.tablistLabel=ie(_("%s sub-pages"),e.title);const P=(e.submenu??[]).filter(F=>!F.offSite&&!Bs(F.url));if(P.length>0&&e.url){const F=Y(e.url),Ce=e.parentUrl??e.url,Ol=Y(Ce),Dl=P.some(ke=>Y(ke.url)===Ol)?[...P]:[{title:e.selfLabel||e.title,url:Ce},...P];for(const ke of Dl){const U=document.createElement("button");U.className="os-window__tab",U.dataset.kind="submenu",U.setAttribute("type","button"),U.setAttribute("role","tab"),U.dataset.url=ke.url,U.textContent=ke.title,Y(ke.url)===F?(U.classList.add("os-window__tab--active"),U.setAttribute("aria-selected","true")):U.setAttribute("aria-selected","false"),h.appendChild(U)}}le(h),t.appendChild(h)}t.appendChild(D);for(const h of j)t.appendChild(h);return Gs(t,e),t}const Fn=window.location.origin;let Un=0;function js(e,{timeoutMs:t=Ls}={}){const n=e?.contentWindow;if(!n)return Promise.resolve(!1);Un+=1;const o=`os-unsaved-guard-${Date.now()}-${Un}`;return new Promise(i=>{let s=null,r=!1;const d=c=>{r||(r=!0,window.removeEventListener("message",a),s!==null&&window.clearTimeout(s),i(c))},a=c=>{if(c.origin!==Fn)return;const l=c?.data;!l||typeof l!="object"||l.type!=="os-bridge-beforeunload-response"||l.requestId!==o||d(l.prevent===!0)};window.addEventListener("message",a),s=window.setTimeout(()=>d(!1),t);try{n.postMessage({type:"os-bridge-beforeunload-query",requestId:o},Fn)}catch{d(!1)}})}function _t(e,{commit:t,navigate:n}){if(!e._iframeBridgeReady||!e.iframe){t(),n();return}e._unsavedGuardPending=!0,js(e.iframe).then(o=>{if(e._unsavedGuardPending=!1,!e._isDestroyed){if(!o){t(),n();return}e._deferNavigationCommit(t,Ns),n()}})}function Ys(e,t){let n;try{n=new URL(t,window.location.origin)}catch{return null}const o=Jt(t);let i=null,s=-1;for(const r of e){const d=r.dataset.url;if(!d||Jt(d)!==o)continue;let a;try{a=new URL(d,window.location.origin)}catch{continue}let c=0,l=!1;for(const[u,p]of a.searchParams){if(u==="openstation_chromeless"||u==="desktop_mode_portal"||Qt.includes(u))continue;if(n.searchParams.get(u)!==p){l=!0;break}c++}!l&&c>s&&(i=r,s=c)}return i}function pe(e,t){const n=e.element.querySelectorAll('.os-window__tab[data-kind="submenu"]');if(!n.length)return;if(e._activeTabId!=="primary"){for(const s of n)s.classList.remove("os-window__tab--active"),s.setAttribute("aria-selected","false");return}const o=Y(t);let i=null;for(const s of n){const r=s.dataset.url;if(r&&Y(r)===o){i=s;break}}if(i||(i=Ys(n,t)),!i){if(Array.from(n).some(d=>d.classList.contains("os-window__tab--active")))return;let r=!1;try{const d=new URL(t,window.location.origin);r=d.pathname.endsWith("/admin.php")&&d.searchParams.has("page")}catch{return}if(!r||!n[0])return;i=n[0]}for(const s of n){const r=s===i;s.classList.toggle("os-window__tab--active",r),s.setAttribute("aria-selected",r?"true":"false")}}function Gn(e,t,n){if(!e.iframe)return;const o=e.element.querySelector(".os-window__tabs"),i=e.element.querySelector(".os-window__body");if(!o||!i)return;Xs(e,o);const s=`ext-${++e._externalTabSeq}`,r=document.createElement("button");r.className="os-window__tab os-window__tab--external",r.dataset.kind="external",r.dataset.tabId=s,r.setAttribute("type","button"),r.setAttribute("role","tab"),r.setAttribute("aria-selected","false"),r.title=t;const d=document.createElement("span");d.className="os-window__tab-label",d.textContent=n,r.appendChild(d);const a=document.createElement("os-tab-chip");a.setAttribute("variant","detach"),a.dataset.tabAction="detach",a.dataset.tabId=s,a.setAttribute("aria-label",_("Open in a new browser tab")),a.title=_("Open in a new browser tab"),r.appendChild(a);const c=document.createElement("os-tab-chip");c.setAttribute("variant","close"),c.dataset.tabAction="close",c.dataset.tabId=s,c.setAttribute("aria-label",_("Close tab")),c.title=_("Close tab"),r.appendChild(c),o.appendChild(r),le(o);const l=document.createElement("iframe");l.className="os-window__iframe os-window__iframe--external",l.dataset.tabId=s,l.style.display="none",l.src=t,i.appendChild(l);let u=!1;const p=()=>{u=!0};l.addEventListener("load",p,{once:!0});const g=window.setTimeout(()=>{u||(l.removeEventListener("load",p),Qs(e,s))},Is),b=()=>{l.removeEventListener("load",p),window.clearTimeout(g)};e._externalTabs.set(s,{tabEl:r,iframe:l,url:t,label:n,cancelProbe:b}),me(e,s),r.scrollIntoView({behavior:"smooth",inline:"end",block:"nearest"}),e._emitChange("state")}function Xs(e,t){if(t.querySelector('[data-kind="main"]')||t.querySelector('[data-kind="submenu"]'))return;const n=document.createElement("button");n.className="os-window__tab os-window__tab--main os-window__tab--active",n.dataset.kind="main",n.setAttribute("type","button"),n.setAttribute("role","tab"),n.setAttribute("aria-selected","true"),n.textContent=e.config.title||"Main",t.prepend(n),le(t)}function me(e,t){if(e._activeTabId===t)return;e._activeTabId=t,e.iframe&&(e.iframe.style.display=t==="primary"?"":"none");for(const[o,i]of e._externalTabs)i.iframe.style.display=t===o?"":"none";e.element.querySelectorAll(".os-window__tab").forEach(o=>{let i;o.dataset.kind==="main"?i=t==="primary":o.dataset.kind==="external"?i=o.dataset.tabId===t:i=t==="primary"&&o.classList.contains("os-window__tab--active"),o.classList.toggle("os-window__tab--active",i),o.setAttribute("aria-selected",i?"true":"false")})}function bt(e,t){const n=e._externalTabs.get(t);n&&(n.cancelProbe(),n.tabEl.remove(),n.iframe.remove(),e._externalTabs.delete(t),e._activeTabId===t&&me(e,"primary"),e._externalTabs.size===0&&e.element.querySelector(".os-window__tab--main")?.remove(),le(e.element.querySelector(".os-window__tabs")),e._emitChange("state"))}function Zs(e,t){const n=e._externalTabs.get(t);if(!n)return;let o=n.url;try{const i=n.iframe.contentWindow?.location.href;i&&i!=="about:blank"&&(o=i)}catch{}window.open(o,"_blank","noopener"),bt(e,t)}function Qs(e,t){const n=e._externalTabs.get(t);if(!n)return;const{url:o,label:i}=n;bt(e,t),dt({message:ie(_(`Opened "%s" in a new browser tab — this site doesn't allow embedding.`),i),action:{label:_("Open"),onClick:()=>{window.open(o,"_blank","noopener")}}}),window.open(o,"_blank","noopener")}function Js(e){return e._externalTabs.size}function er(e){const t=[];for(const n of e._externalTabs.values()){let o=n.url;try{const i=n.iframe.contentWindow?.location.href;i&&i!=="about:blank"&&(o=i)}catch{}t.push({url:o,label:n.label})}return t}function tr(e,t){const n=t.target,o=n.closest("[data-tab-action]");if(o){t.stopPropagation();const d=o.dataset.tabAction,a=o.dataset.tabId;if(!a)return;d==="close"?bt(e,a):d==="detach"&&Zs(e,a);return}const i=n.closest(".os-window__tab");if(!i)return;t.stopPropagation();const s=i.dataset.kind,r=i.dataset.tabId;if(s==="external"&&r){me(e,r);return}if(s==="main"){me(e,"primary");return}if(s==="panel"&&i.dataset.panel){Qe(e.element,i.dataset.panel);return}if(i.dataset.url){const d=i.dataset.url;if(Xe(d))return;const a=fe(d);me(e,"primary");const c=()=>{e.markContentLoading(),pe(e,d)};a&&e.iframe?_t(e,{commit:c,navigate:()=>{e.iframe&&(e.iframe.src=a)}}):pe(e,d)}}const wt=1;function nr(e,t){const n=Math.max(0,e.scrollWidth-e.clientWidth);if(n<=wt){delete e.dataset.overflow;return}const o=Math.abs(e.scrollLeft),i=o<=wt,s=o>=n-wt,r=t??window.getComputedStyle(e).direction==="rtl",d=r?!s:!i,a=r?!i:!s;d&&a?e.dataset.overflow="both":d?e.dataset.overflow="left":a?e.dataset.overflow="right":delete e.dataset.overflow}function or(e){let t=null,n=null;const o=()=>{n===null&&(n=window.requestAnimationFrame(()=>{n=null,t===null&&(t=window.getComputedStyle(e).direction==="rtl"),nr(e,t),jt(e),Yt(e)}))},i=()=>{t=null,o()};e.addEventListener("scroll",o,{passive:!0});const s=typeof ResizeObserver>"u"?null:new ResizeObserver(i);s?.observe(e);const r=typeof MutationObserver>"u"?null:new MutationObserver(i);return r?.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),o(),()=>{e.removeEventListener("scroll",o),s?.disconnect(),r?.disconnect(),n!==null&&(window.cancelAnimationFrame(n),n=null)}}const ir=k("desktop-mode/destructive-admin-actions",()=>({entries:[]}));function sr(e,t){for(const n of ir.state.entries)try{if(n.matches(e,t))return n.id}catch(o){console.warn(`[openstation] destructive-action predicate threw for "${n.id}":`,o)}return null}const rr=32,ar=64,lr=/^[a-z0-9_/-]+$/,q=k("desktop-mode/window-links",()=>({contentByWindow:new Map,focusSeq:new Map,seq:0,listeners:new Set,lastGroupsSignature:"",manager:null,started:!1}));function De(e){return`${e.type}:${e.id}`}function Bn(e){return e.root?De(e.root):De(e)}function qn(e){const t=o=>typeof o=="number"&&Number.isFinite(o)||typeof o=="string"&&o.trim()!=="",n=o=>typeof o=="string"&&lr.test(o.trim().toLowerCase());return fi(e,[{field:"type",valid:o=>n(o.type),message:"must match /^[a-z0-9_/-]+$/ — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-type"},{field:"id",valid:o=>t(o.id),message:"must be a finite number or non-empty string"},{field:"root",valid:o=>o.root===void 0||!!o.root&&typeof o.root=="object"&&n(o.root.type)&&t(o.root.id),message:"when present, must be { type, id } with the same shapes as the ref itself"},{field:"related",valid:o=>o.related===void 0||Array.isArray(o.related)&&o.related.every(i=>!!i&&typeof i=="object"&&typeof i.id=="string"&&i.id.trim()!==""&&typeof i.group=="string"&&i.group.trim()!==""&&typeof i.label=="string"&&i.label.trim()!==""&&typeof i.url=="string"&&i.url.trim()!==""&&(i.groupLabel===void 0||typeof i.groupLabel=="string")&&(i.icon===void 0||typeof i.icon=="string")&&(i.count===void 0||typeof i.count=="number"&&Number.isFinite(i.count))),message:"when present, must be an array of { id, group, label, url, groupLabel?, icon?, count? } entries with non-empty strings"},{field:"links",valid:o=>o.links===void 0||Array.isArray(o.links)&&o.links.every(i=>!!i&&typeof i=="object"&&n(i.type)&&t(i.id)&&(i.rel===void 0||i.rel==="references"||i.rel==="child")),message:"when present, must be an array of { type, id, rel?: 'references'|'child' } entries"},{field:"revisionCount",valid:o=>o.revisionCount===void 0||typeof o.revisionCount=="number"&&Number.isFinite(o.revisionCount),message:"when present, must be a finite number"}])}function Vn(e){if(!(typeof e!="string"||e===""))try{return new URL(e,window.location.origin).origin===window.location.origin?e:void 0}catch{return}}function cr(e,t){const n={type:e.type.trim().toLowerCase(),id:e.id,source:t};e.root&&(n.root={type:e.root.type.trim().toLowerCase(),id:e.root.id}),Array.isArray(e.links)&&e.links.length>0&&(n.links=e.links.slice(0,rr).map(s=>{const r={type:s.type.trim().toLowerCase(),id:s.id};return s.rel==="child"&&(r.rel="child"),r})),typeof e.label=="string"&&e.label!==""&&(n.label=e.label);const o=Vn(e.previewUrl);o&&(n.previewUrl=o);const i=Vn(e.revisionsUrl);return i&&(n.revisionsUrl=i,typeof e.revisionCount=="number"&&Number.isFinite(e.revisionCount)&&(n.revisionCount=Math.max(0,Math.trunc(e.revisionCount)))),Array.isArray(e.related)&&e.related.length>0&&(n.related=e.related.slice(0,ar).map(s=>{const r={id:s.id,group:s.group,label:s.label,url:s.url};return typeof s.groupLabel=="string"&&s.groupLabel!==""&&(r.groupLabel=s.groupLabel),typeof s.icon=="string"&&s.icon!==""&&(r.icon=s.icon),typeof s.count=="number"&&(r.count=s.count),r})),n}function Kn(e){return!e||!e.related?"":e.related.map(t=>`${t.id}\0${t.group}\0${t.label}\0${t.url}\0${t.groupLabel??""}\0${t.icon??""}\0${t.count??""}`).join("|")}function yt(e){return e?[De(e),Bn(e),...(e.links??[]).map(t=>De(t)+(t.rel==="child"?"!child":""))].join("|"):""}function dr(e,t,n={}){const o=n.source??"api";if(typeof e!="string"||e===""){et("WindowContentRef",["windowId (must be a non-empty string)"],t);return}let i=null;if(t!=null){const d=qn(t);if(d.length>0){o==="api"&&et("WindowContentRef",d,t),nn("WindowContentRef",d,t);return}i=cr(t,o)}if(i=T(f.WINDOW_LINKS_CONTENT,i,{windowId:e,source:o}),i!==null&&(!i||qn(i).length>0)){nn("WindowContentRef",["filter (os.window-links.content returned an invalid ref)"],i);return}const s=q.state.contentByWindow.get(e)??null;if(i===null&&s===null||i!==null&&s!==null&&yt(i)===yt(s)&&i.label===s.label&&i.previewUrl===s.previewUrl&&i.revisionsUrl===s.revisionsUrl&&i.revisionCount===s.revisionCount&&Kn(i)===Kn(s))return;i===null?q.state.contentByWindow.delete(e):q.state.contentByWindow.set(e,i);const r={windowId:e,content:i,previous:s,source:o};document.dispatchEvent(new CustomEvent("os-window-content-changed",{detail:r})),m(f.WINDOW_CONTENT_CHANGED,r),pr(),hr()}function ur(){const e=new Map;for(const[i,s]of q.state.contentByWindow){const r=Bn(s);let d=e.get(r);d||(d={key:r,root:s.root?{...s.root}:{type:s.type,id:s.id},rootWindowIds:[],children:[]},e.set(r,d)),s.root?d.children.push({windowId:i,content:s}):d.rootWindowIds.push(i)}const t=q.state.focusSeq;for(const i of e.values())i.rootWindowIds.sort((s,r)=>(t.get(r)??0)-(t.get(s)??0));const n=Array.from(e.values()),o=T(f.WINDOW_LINK_GROUPS,n);return Array.isArray(o)?o:(typeof console<"u"&&console.warn("[openstation] `os.window-links.groups` filter returned a non-array; falling back to computed groups."),n)}function hr(){for(const e of Array.from(q.state.listeners))try{e()}catch(t){typeof console<"u"&&console.error("[openstation] window-links listener threw:",t)}}function fr(){return Array.from(q.state.contentByWindow).map(([e,t])=>`${e}=${yt(t)}`).sort().join(";")}function pr(){const e=fr();if(e===q.state.lastGroupsSignature)return;q.state.lastGroupsSignature=e;const n={groups:ur()};document.dispatchEvent(new CustomEvent("os-window-link-groups-changed",{detail:n})),m(f.WINDOW_LINK_GROUPS_CHANGED,n)}const mr="my-wordpress",gr=Object.freeze({userId:null,userName:"",requestedAt:0});function jn(){return window.wp?.os}let We=null;function _r(){if(We)return We;const e=jn()?.createSharedStore;return typeof e!="function"?null:(We=e("desktop-mode/my-wordpress/footprint-target",()=>({...gr})),We)}function br(e,t=""){const n=_r();if(n){n.state.userId=e,n.state.userName=t,n.state.requestedAt=Date.now(),n.notify();return}window._wpdFootprintTarget={userId:e,userName:t,requestedAt:Date.now()}}function wr(e){const t=Number(e.userId);if(!Number.isFinite(t)||t<=0)return;const n=e.userName??"";br(t,n),jn()?.openWindow?.(mr,{source:"my-wordpress/open-user-footprint",params:{footprint:t,fpName:n}})}const M=window.location.origin,vt=k("desktop-mode/admin-link-deps",()=>({deps:null}));function yr(e,t){if(t.origin!==M||!e.iframe||t.source!==e.iframe.contentWindow)return;const n=t.data;if(!(!n||typeof n.type!="string")){if(n.type==="os-title-change"&&typeof n.title=="string"&&e.setTitle(n.title),n.type==="os-content-identity"&&dr(e.id,n.identity??null,{source:"bridge"}),n.type==="os-window-publish"&&typeof n.channel=="string"&&n.channel!==""&&Ht(e.id,n.channel,n.payload),typeof n.type=="string"&&n.type.startsWith("os-bridge-")&&window.__openStationConnectionBridge?.routeIncomingFromIframe(n,e.id),n.type==="os-iframe-navigated"&&e._settleNavigationActivity(),n.type==="os-ready"&&(e._iframeBridgeReady=!0,e._clearDeferredNavigation(),e._settleNavigationActivity(!0)||e._resetActivity(),$(e.id),m(f.IFRAME_READY,{windowId:e.id})),n.type==="os-iframe-unloading"&&e._commitDeferredNavigation(),n.type==="os-bridge-beforeunload-response"){if(e._isDestroyed||typeof n.requestId=="string"&&n.requestId!=="")return;e._closePending=!1,e._iframeCloseTimeout&&(clearTimeout(e._iframeCloseTimeout),e._iframeCloseTimeout=null),n.prevent?Promise.resolve().then(()=>Rl).then(({osConfirm:o})=>o({title:typeof n.message=="string"&&n.message?n.message:_("Unsaved changes"),message:_("You have unsaved changes. Are you sure you want to close this window?"),confirmLabel:_("Close window"),danger:!0})).then(o=>{o&&e.destroy()}).catch(()=>{e.destroy()}):e.destroy()}if(n.type==="os-navigate"&&typeof n.url=="string"&&n.url!==""&&Er(e,n.url,n.target==="new"?"new":"self"),n.type==="os-iframe-other-admin-link"&&typeof n.url=="string"&&n.url!==""&&vt.state.deps?.openOtherAdmin?.(n.url),n.type==="os-iframe-admin-link"&&typeof n.url=="string"&&n.url!==""){const o=vt.state.deps;if(Xe(n.url))e.close();else if(o){const i=typeof n.label=="string"?n.label:"";xr(e,n.url,i,o,n.newContext===!0)}}if(n.type==="os-open-user-footprint"&&typeof n.userId=="number"&&n.userId>0&&wr({userId:n.userId,userName:typeof n.userName=="string"?n.userName:""}),n.type==="os-notification"&&typeof n.title=="string"&&n.title!==""&&Or(n.title,typeof n.body=="string"?n.body:""),n.type==="os-focus-request"&&(e.element.classList.contains("os-window--overview")||e.onFocusRequest?.(e)),n.type==="os-screen-meta"&&Array.isArray(n.panels)&&Dr(e,n.panels),n.type==="os-screen-meta-state"&&Wr(e,typeof n.open=="string"?n.open:null),n.type==="os-external-link"&&typeof n.url=="string"&&n.url!==""){const o=typeof n.label=="string"&&n.label!==""?n.label:n.url;Gn(e,n.url,o)}if(n.type==="os-iframe-error"&&m(f.IFRAME_ERROR,{windowId:e.id,kind:n.kind==="unhandledrejection"?"unhandledrejection":"error",message:typeof n.message=="string"?n.message:"",filename:typeof n.filename=="string"?n.filename:null,lineno:typeof n.lineno=="number"?n.lineno:null,colno:typeof n.colno=="number"?n.colno:null,stack:typeof n.stack=="string"?n.stack:null}),n.type==="os-chrome-theme"&&n.tokens&&typeof n.tokens=="object")try{e.setAppearanceTheme(n.tokens)}catch(o){m(f.SHELL_ERROR,{scope:"window-bridge-chrome-theme",windowId:e.id,error:o})}if(n.type==="os-chrome-controls"&&n.config&&typeof n.config=="object")try{e.setAppearanceControls(n.config)}catch(o){m(f.SHELL_ERROR,{scope:"window-bridge-chrome-controls",windowId:e.id,error:o})}if(n.type==="os-chrome-slot"&&typeof n.slot=="string"&&typeof n.html=="string")try{e.setAppearanceSlot(n.slot,{html:n.html})}catch(o){m(f.SHELL_ERROR,{scope:"window-bridge-chrome-slot",windowId:e.id,error:o})}if(n.type==="os-iframe-activity"){if(n.phase==="start")e._markActivityStart(),n.navigation&&e._noteNavigationActivity();else if(n.phase==="end"){const o=!!n.failed,i=typeof n.status=="number"?n.status:0;e._markActivitySettled(!o,o?vr(i):void 0)}}if(n.type==="os-iframe-network"){const o={windowId:e.id,method:typeof n.method=="string"?n.method:"GET",url:typeof n.url=="string"?n.url:"",status:typeof n.status=="number"?n.status:0,duration:typeof n.duration=="number"?n.duration:0,failed:!!n.failed};n.requestHeaders&&typeof n.requestHeaders=="object"&&(o.requestHeaders=n.requestHeaders),n.responseHeaders&&typeof n.responseHeaders=="object"&&(o.responseHeaders=n.responseHeaders),m(f.IFRAME_NETWORK_COMPLETED,o)}}}function vr(e){return e<=0?_("Request failed."):ie(_("Request failed (HTTP %d)."),e)}function Er(e,t,n){let o;try{o=new URL(t,M)}catch{return}if(o.origin===M){if(n==="new"){window.open(o.toString(),"_blank","noopener,noreferrer");return}e.iframe&&(e.iframe.src=o.toString())}}const Ar=new Set(["trash","untrash","delete","spam","unspam","spamcomment","unspamcomment","trashcomment","untrashcomment","deletecomment","approvecomment","unapprovecomment"]);function Sr(e){const t=e.searchParams.get("action");return t&&Ar.has(t)&&(e.searchParams.has("_wpnonce")||e.searchParams.has("_wp_nonce"))?!0:sr(e.toString(),e)!==null}function Yn(e,t){if(e.searchParams.has("_wp_http_referer"))return e;let n="";try{n=t.iframe?.contentWindow?.location.href??""}catch{}if(n||(n=t.config.url||""),!n)return e;try{const o=new URL(n,M);if(o.origin!==M)return e;const i=new URL(e.href),s=new URL(o.href);return s.searchParams.delete("openstation_chromeless"),i.searchParams.set("_wp_http_referer",s.pathname+(s.search?s.search:"")),i}catch{return e}}function Cr(e,t){let n="";try{n=e.getCurrentUrl?.()??""}catch{return""}if(!n||n.startsWith("#")||n==="about:blank")return"";try{const o=new URL(n,t.adminUrl);return o.origin!==M?"":t.deriveSlug(o.toString())}catch{return""}}function kr(e,t,n){if(t===(e.config.baseId||e.id))return!0;const o=Cr(e,n);return o!==""&&o===t}function xr(e,t,n,o,i=!1){let s;try{s=new URL(t,o.adminUrl)}catch{return}if(s.origin!==M)return;if(i){Et(e,s,n,o);return}const r=s.toString(),d=o.deriveSlug(r),a=kr(e,d,o);if(!a&&Sr(s)){const c=Yn(s,e),l=e.iframe?.contentWindow;if(l)try{l.location.assign(c.href)}catch{e.iframe&&(e.iframe.src=c.href)}return}if(a){const c=e.iframe?.contentWindow;if(c)try{c.location.assign(r)}catch{e.iframe&&(e.iframe.src=r)}return}Et(e,s,n,o)}function Et(e,t,n,o){const i=t.toString(),s=o.deriveSlug(i),r=o.findDockEntry(i),d=n.trim(),a=r?.title||(d!==""?d:s),c=Yn(t,e);o.openWindow({id:s,baseId:s,url:c.toString(),parentUrl:r?.url??i,title:a,titleFromPage:!r,icon:r?.icon??"dashicons-admin-generic",submenu:r?.submenu,selfLabel:r?.selfLabel,multi:r?.multi})}function Me(e){if(!e||e.startsWith("#"))return"";try{const t=new URL(e,M);return t.origin!==M?"":t.pathname.split("/").pop()??""}catch{return""}}const Tr=new Set(["revision.php"]);function Ir(e,t){try{const o=e.iframe?.contentWindow?.performance?.getEntriesByType?.("navigation")?.[0]?.name??"";if(o&&Me(o)===Me(t))return o}catch{}return t}function Lr(e,t){const n=Me(e.config.url??"");if(!n||!Tr.has(n))return!1;const o=Me(t);if(!o||o===n)return!1;if(Xe(t))return e.close(),!0;const i=vt.state.deps;if(!i)return!1;let s;try{s=new URL(Ir(e,t),i.adminUrl)}catch{return!1}return s.origin!==M?!1:(Et(e,s,"",i),e.close(),!0)}function Nr(e){if(!e.config.titleFromPage)return;let t="";try{t=e.iframe?.contentDocument?.title??""}catch{return}const n=Rr(t);n!==""&&n!==e.config.title&&e.setTitle(n)}function Rr(e){const t=e.trim(),n=t.indexOf(" ‹ ");return(n>0?t.slice(0,n):t).trim()}function Or(e,t){const n=t!==""?`${e} — ${t}`:e;dt({message:n})}function Dr(e,t){const n=e.element.querySelector(".os-window__screen-meta");if(!n)return;n.innerHTML="";const o={"screen-options":{icon:"dashicons-admin-generic",label:"Screen Options"},help:{icon:"dashicons-editor-help",label:"Help"}};for(const i of t){const s=o[i];if(!s)continue;const r=document.createElement("button");r.className="os-window__meta-btn",r.setAttribute("type","button"),r.setAttribute("aria-label",s.label),r.setAttribute("aria-pressed","false"),r.dataset.panel=i,r.innerHTML=`<span class="dashicons ${s.icon}" aria-hidden="true"></span>`,r.addEventListener("click",d=>{d.stopPropagation(),e.iframe?.contentWindow?.postMessage({type:"os-toggle-panel",panel:i},M)}),n.appendChild(r)}}function Wr(e,t){const n=e.element.querySelector(".os-window__screen-meta");n&&n.querySelectorAll(".os-window__meta-btn").forEach(o=>{const i=o.dataset.panel===t;o.classList.toggle("os-window__meta-btn--active",i),o.setAttribute("aria-pressed",i?"true":"false")})}const Xn=k("desktop-mode/title-bar-buttons-registry",()=>({registry:new Map,listeners:new Set})),Mr=Xn.state.registry,At=Xn.state.listeners;function Pr(){return Array.from(Mr.values()).sort((e,t)=>(e.order??100)-(t.order??100))}function $r(e){const t=[],n=[];for(const o of Pr()){try{if(!o.match(e))continue}catch{continue}o.placement==="right"?n.push(o):t.push(o)}return{left:t,right:n}}function zr(e){return At.add(e),()=>{At.delete(e)}}function Hr(){const e=Array.from(At);for(const t of e)try{t()}catch(n){typeof console<"u"&&console.error("[openstation] title-bar-button registry listener threw:",n)}}typeof document<"u"&&document.addEventListener("os-settings-save-lifecycle",e=>{const t=e.detail;t&&t.phase==="saved"&&Hr()});const Fr=/^dashicons-[a-z0-9-]+$/i,Ur=/^\s*<svg[\s>]/i;function Zn(e,t){if(t){if(Fr.test(t)){const n=document.createElement("span");n.className=`dashicons ${t}`,n.setAttribute("aria-hidden","true"),e.appendChild(n);return}if(Ur.test(t)){const n=document.createElement("span");n.setAttribute("aria-hidden","true"),n.innerHTML=t,e.appendChild(n);return}e.setAttribute("icon",t)}}const Qn=k("desktop-mode/window-themes-registry",()=>({registry:new Map,listeners:new Set})),Gr=Qn.state.registry,Jn=Qn.state.listeners;function eo(){return Array.from(Gr.values()).sort((e,t)=>(e.priority??100)-(t.priority??100))}function Br(e){let t=null;for(const n of eo()){try{if(!n.match(e))continue}catch(o){typeof console<"u"&&console.warn(`[openstation] window-theme "${n.id}" match() threw — skipping`,o);continue}t=n}return t}function qr(e){return Jn.add(e),()=>{Jn.delete(e)}}const Pe=new WeakMap;function Vr(e,t){let n=null,o={};if(t&&"tokens"in t&&t.tokens)n=null,o={...t.tokens};else if(t&&"themeId"in t&&t.themeId){const s=jr(t.themeId);s&&(n=s.id,o={...s.tokens})}else{const s=Br(e);s&&(n=s.id,o={...s.tokens})}const i=T(f.WINDOW_CHROME_THEME,o,{windowId:e.id,themeId:n,config:e.config});return{themeId:n,tokens:i}}function St(e,t){const n=e.element;if(!n)return;const o=Pe.get(n),{themeId:i,tokens:s}=Vr(e,t);if(o){for(const d of o.keys)if(!(d in s))try{n.style.removeProperty(d)}catch{}}const r=new Set;for(const[d,a]of Object.entries(s))try{n.style.setProperty(d,a),r.add(d)}catch(c){m(f.SHELL_ERROR,{scope:"window-theme-apply",windowId:e.id,key:d,error:c})}Pe.set(n,{themeId:i,keys:r}),m(f.WINDOW_CHROME_THEME_CHANGED,{windowId:e.id,themeId:i,tokens:s})}function Kr(e){const t=e.element;if(!t)return;const n=Pe.get(t);if(n){for(const o of n.keys)try{t.style.removeProperty(o)}catch{}Pe.delete(t)}}function jr(e){for(const t of eo())if(t.id===e)return{id:t.id,tokens:t.tokens};return null}const to=k("desktop-mode/window-controls-registry",()=>({registry:new Map,listeners:new Set})),Yr=to.state.registry,no=to.state.listeners;function Xr(){return Array.from(Yr.values()).sort((e,t)=>{const n=e.order??100,o=t.order??100;return n!==o?n-o:e.id.localeCompare(t.id)})}function Zr(e){const t=[],n=[],o=[];for(const i of Xr()){try{if(!i.match(e))continue}catch(r){typeof console<"u"&&console.warn(`[openstation] window-control "${i.id}" match() threw — skipping`,r);continue}const s=i.placement??"left";s==="right"?n.push(i):s==="controls"?o.push(i):t.push(i)}return{left:t,right:n,controls:o}}function Qr(e){return no.add(e),()=>{no.delete(e)}}function Jr(e,t){const n=Zr(e),o=new Set(t?.hide??[]);let i=n.left.filter(c=>!o.has(c.id)),s=n.right.filter(c=>!o.has(c.id)),r=n.controls.filter(c=>!o.has(c.id));if(t?.custom){for(const c of t.custom){if(o.has(c.id))continue;const l={id:c.id,label:c.label,icon:c.icon,placement:c.placement??"controls",order:c.order??100,match:()=>!0,onClick:c.onClick?(u,p)=>c.onClick(p):void 0,render:c.render?u=>c.render(u):void 0};l.placement==="left"?i.push(l):l.placement==="right"?s.push(l):r.push(l)}i=Ct(i),s=Ct(s),r=Ct(r)}t?.order&&t.order.length>0&&(r=ea(r,t.order));const d=t?.placement??"right",a={windowId:e.id,config:e.config};return i=T(f.WINDOW_CHROME_CONTROLS,i,{...a,placement:"left"}),s=T(f.WINDOW_CHROME_CONTROLS,s,{...a,placement:"right"}),r=T(f.WINDOW_CHROME_CONTROLS,r,{...a,placement:"controls"}),{left:i,right:s,controls:r,placement:d}}function Ct(e){return[...e].sort((t,n)=>{const o=t.order??100,i=n.order??100;return o!==i?o-i:t.id.localeCompare(n.id)})}function ea(e,t){const n=new Map;for(const s of e)n.set(s.id,s);const o=[],i=new Set;for(const s of t){const r=n.get(s);r&&!i.has(s)&&(o.push(r),i.add(s))}for(const s of e)i.has(s.id)||o.push(s);return o}function ta(e,t){const n=document.createElement("os-window-button");n.setAttribute("aria-label",e.label||e.id),n.classList.add("os-window__btn");const o=na(e.id);if(n.classList.add(`os-window__btn--${o}`),e.id==="core/close"&&n.setAttribute("danger",""),typeof e.render=="function")try{e.render(n,t)}catch(i){return m(f.SHELL_ERROR,{scope:"window-control-render",id:e.id,windowId:t.id,error:i}),{element:n}}else if(lt(n,e.id)||Zn(n,e.icon??""),typeof e.onClick=="function"){const i=s=>{s.stopPropagation();try{e.onClick(t,s)}catch(r){m(f.SHELL_ERROR,{scope:"window-control-onclick",id:e.id,windowId:t.id,error:r})}};return n.addEventListener("os-button-activate",i),{element:n,teardown:()=>{n.removeEventListener("os-button-activate",i)}}}return{element:n}}function na(e){return e.startsWith("core/")?e.slice(5):e.replace(/\//g,"-")}function oa(e,t){const n=[];for(;t.firstChild;)t.removeChild(t.firstChild);const o=Jr(e,e.config.appearance?.controls);t.classList.toggle("os-window__controls--left",o.placement==="left");for(const i of o.controls){const{element:s,teardown:r}=ta(i,e);t.appendChild(s),r&&n.push(r)}return m(f.WINDOW_CHROME_APPLIED,{windowId:e.id,layer:"controls"}),()=>{for(const i of n)try{i()}catch{}}}function ia(e){if(!e)return 214;let t=5381;for(let n=0;n<e.length;n++)t=Math.imul(t,33)+e.charCodeAt(n);return(t%360+360)%360}function sa(e){return typeof e!="string"||e===""||e.length>4096||!/^(https?:\/\/|data:image\/)/i.test(e)?!1:!/['"()\\<>\s]/.test(e)}function oo(e,t,n){if(!sa(t))return!1;const o=`url("${t}") center / contain no-repeat`;return e.style.backgroundImage="none",e.style.backgroundColor=n,e.style.setProperty("-webkit-mask",o),e.style.setProperty("mask",o),!0}const io="data:image/svg+xml;base64,",$e=new Map;function ra(e){const t=$e.get(e);if(t!==void 0)return t;let n=!1;try{n=atob(e.slice(io.length)).includes("currentColor")}catch{}return $e.size>=256&&$e.clear(),$e.set(e,n),n}function aa(e,t){const n=t.className??"",o=t.title??"";let i=null;if(t.slot){const a=In(t.slot);a!==null&&(e=a),i=Ln(t.slot)}if(typeof e=="string"&&e.startsWith("dashicons-")){const a=document.createElement("span");return a.className=`dashicons ${e} ${n}`.trim(),a.setAttribute("aria-hidden","true"),i!==null&&(a.style.color=i),a}if(i!==null&&typeof e=="string"){const a=document.createElement("span");if(a.className=n,a.setAttribute("aria-hidden","true"),a.style.display="inline-block",oo(a,e,i))return a}if(typeof e=="string"&&e.startsWith("data:image/svg+xml;base64,")){const a=e.slice(io.length);if(/^[A-Za-z0-9+/=]+$/.test(a)){const c=document.createElement("span");return c.className=n,c.setAttribute("aria-hidden","true"),c.style.display="inline-block",ra(e)&&oo(c,e,"currentColor")||(c.style.backgroundImage=`url("${e}")`,c.style.backgroundRepeat="no-repeat",c.style.backgroundPosition="center",c.style.backgroundSize="contain"),c}}if(typeof e=="string"&&/^data:image\/(png|jpeg|jpg|gif|webp|x-icon|vnd\.microsoft\.icon);base64,/i.test(e)){const a=e.indexOf(","),c=a>=0?e.slice(a+1):"";if(/^[A-Za-z0-9+/=]+$/.test(c))return so(e,n)}if(typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://")))return so(e,n);const s=document.createElement("span");s.className=`${n} os-icon-letter`.trim(),s.setAttribute("aria-hidden","true");const r=la(o);s.textContent=r;const d=ia(o);return s.style.backgroundColor=`hsl( ${d}, 60%, 45% )`,s.style.color="#fff",s.style.display="inline-flex",s.style.alignItems="center",s.style.justifyContent="center",s.style.fontWeight="600",s.style.borderRadius="4px",s}function so(e,t){const n=document.createElement("img");return n.className=t,n.src=e,n.alt="",n.setAttribute("aria-hidden","true"),n.draggable=!1,n}function la(e){const t=(e??"").trim();if(t==="")return"?";const n=t.split(/\s+/);if(n.length>=2)return(n[0][0]+n[1][0]).toUpperCase();const o=n[0];return o.length>=2?o.slice(0,2).toUpperCase():o.toUpperCase()}const ro=k("desktop-mode/window-slots-registry",()=>({registry:new Map,listeners:new Set})),ca=ro.state.registry,ao=ro.state.listeners;function da(){return Array.from(ca.values()).sort((e,t)=>{const n=e.order??100,o=t.order??100;return n!==o?n-o:e.id.localeCompare(t.id)})}function ua(e,t){const n=[];for(const o of da())if(o.slot===t){try{if(!o.match(e))continue}catch(i){typeof console<"u"&&console.warn(`[openstation] window-slot "${o.id}" match() threw — skipping`,i);continue}n.push(o)}return n}function ha(e){return ao.add(e),()=>{ao.delete(e)}}const lo=["before-titlebar","before-icon","icon","title","after-title","before-controls","after-controls","after-titlebar"],co=new WeakMap;function uo(e,t){return e.querySelector(`[data-slot="${t}"]`)}function fa(e){const t=new Map;for(const n of lo){const o=uo(e,n);o&&t.set(n,Array.from(o.childNodes).map(i=>i.cloneNode(!0)))}return t}function ge(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function pa(e,t){ge(e);for(const n of t)e.appendChild(n.cloneNode(!0))}function ma(e,t){const n=e.querySelector(".os-window__title");n&&(n.textContent=t)}function ga(e){const t=[],n=e.element;if(!n)return()=>{};let o=co.get(n);o||(o=fa(n),co.set(n,o));const i=e.config.appearance?.slots??{};for(const s of lo){const r=uo(n,s);if(!r)continue;const d=o.get(s)??[],a=i[s],c=ua(e,s);if(a===null)ge(r);else if(a&&"html"in a)ge(r),r.textContent=a.html;else if(a&&"render"in a){a.replace!==!1&&ge(r);try{const u=a.render(r);typeof u=="function"&&t.push(u)}catch(u){m(f.SHELL_ERROR,{scope:"window-slot-inline-render",windowId:e.id,slot:s,error:u})}}else pa(r,d),s==="title"&&ma(r,e.config.title);if(a!==null){let l=!1;for(const u of c){u.replace!==!1&&!l&&(ge(r),l=!0);try{const g=u.render(r,{window:e,slot:s});typeof g=="function"&&t.push(g)}catch(g){m(f.SHELL_ERROR,{scope:"window-slot-registry-render",windowId:e.id,slot:s,id:u.id,error:g})}}}T(f.WINDOW_CHROME_SLOT,r,{windowId:e.id,slot:s,config:e.config})}return m(f.WINDOW_CHROME_APPLIED,{windowId:e.id,layer:"slots"}),()=>{for(const s of t)try{s()}catch{}}}const ho=k("desktop-mode/window-chrome-registry",()=>({registry:new Map,listeners:new Set})),_a=ho.state.registry,fo=ho.state.listeners;function ba(e){return _a.get(e.toLowerCase())??null}function wa(e){return fo.add(e),()=>{fo.delete(e)}}const ze="core/standard",kt="os-window--custom-chrome";function po(e){const t=e.config.appearance?.chrome??ze;return T(f.WINDOW_CHROME_RENDER,t,{windowId:e.id,config:e.config})}function mo(e){return{title:e.config.title,icon:e.config.icon,focused:e.element.classList.contains("os-window--focused"),state:e.state}}function ya(e){const t=po(e);if(t===ze)return null;const n=ba(t);if(!n)return null;try{if(n.match&&!n.match(e))return null}catch{return null}e.element.classList.add(kt);let o;try{o=n.render(e.element,{window:e,state:mo(e)})}catch(i){return e.element.classList.remove(kt),m(f.SHELL_ERROR,{scope:"window-chrome-render",windowId:e.id,chromeId:t,error:i}),null}return m(f.WINDOW_CHROME_APPLIED,{windowId:e.id,layer:"chrome",chromeId:t}),{id:t,handle:o}}const go=k("desktop-mode/window-actions-registry",()=>({registry:new Map,listeners:new Set})),va=go.state.registry,_o=go.state.listeners;function Ea(){return Array.from(va.values()).sort((e,t)=>(e.order??100)-(t.order??100))}function Aa(e){return _o.add(e),()=>{_o.delete(e)}}function Sa(e,t){if(typeof e.label=="function")try{return String(e.label(t)??"")}catch{return""}return e.label}function Ca(e,t){if(typeof e.icon=="function")try{return String(e.icon(t)??"")}catch{return""}return e.icon??""}function ka(e,t){if(!e.checkable||typeof e.checked!="function")return!1;try{return!!e.checked(t)}catch{return!1}}function xa(e,t){if(typeof e.isVisible!="function")return!0;try{return!!e.isVisible(t)}catch{return!1}}function bo(e){const t=e.element.querySelector(".os-window__menu-panel");t&&(t.hidden?wo(e):V(e))}function wo(e){const t=e.element.querySelector(".os-window__menu-panel"),n=e.element.querySelector(".os-window__menu-btn");if(!t||!n)return;t.hidden=!1,n.setAttribute("aria-expanded","true");const o=t.querySelector(".os-window__menu-item--startup");o&&xt(e,o),vo(e,t),e._unsubscribeWindowActions?.(),e._unsubscribeWindowActions=Aa(()=>{t.hidden||vo(e,t)}),m(f.WINDOW_MENU_OPENED,{windowId:e.id,element:t}),e._boundOnDocumentPointerDown||(e._boundOnDocumentPointerDown=s=>{const r=s.target;r&&(t.contains(r)||n.contains(r)||V(e))}),setTimeout(()=>{e._boundOnDocumentPointerDown&&document.addEventListener("pointerdown",e._boundOnDocumentPointerDown,!0)},0),t.querySelector('[role="menuitem"]')?.focus()}function V(e){const t=e.element.querySelector(".os-window__menu-panel"),n=e.element.querySelector(".os-window__menu-btn");t&&(t.hidden=!0),n&&n.setAttribute("aria-expanded","false"),e._boundOnDocumentPointerDown&&document.removeEventListener("pointerdown",e._boundOnDocumentPointerDown,!0),e._unsubscribeWindowActions?.(),e._unsubscribeWindowActions=null}function yo(e){e.hasAttribute("checked")?e.removeAttribute("checked"):e.setAttribute("checked","")}function xt(e,t){const n=window.wp?.os?.config?.defaultWindow;let o=!1;if(n&&n.enabled&&typeof n.url=="string")if(e.config.native)o=n.url===`native:${e.id}`;else try{const i=Y(e.getCurrentUrl()),s=Y(n.url);o=i===s}catch{o=!1}o?t.setAttribute("checked",""):t.removeAttribute("checked")}function vo(e,t){for(const n of Array.from(t.querySelectorAll(".os-window__menu-item--action")))n.remove();for(const n of Ea()){if(!xa(n,e))continue;const o=Sa(n,e);if(!o)continue;const i=document.createElement("os-menu-item");if(i.setAttribute("value",n.id),i.classList.add("os-window__menu-item"),i.classList.add("os-window__menu-item--action"),i.setAttribute("data-action-id",n.id),i.textContent=o,n.checkable)i.setAttribute("role","menuitemcheckbox"),ka(n,e)&&i.setAttribute("checked","");else{i.setAttribute("role","menuitem");const r=Ca(n,e);r&&i.setAttribute("icon",r)}const s=n.closeOnSelect??!n.checkable;i.addEventListener("os-menu-item-click",r=>{r.stopPropagation(),n.checkable&&yo(i),s&&V(e);try{n.onSelect(e)}catch(d){typeof console<"u"&&console.error(`[openstation] window action "${n.id}" threw:`,d)}}),t.appendChild(i)}}const Ta={minDurationMs:1e3,minReversals:5,minAmplitudePx:14,maxGapMs:320,cooldownMs:600},Ia="os-pointer-shake";function La(e={}){const t={...Ta,...e};let n={origin:0,dir:0,extent:0},o={origin:0,dir:0,extent:0},i=[],s=!1,r=-1/0;const d=()=>{n={origin:0,dir:0,extent:0},o={origin:0,dir:0,extent:0},i=[],s=!1},a=(l,u)=>{if(l.dir===0){const g=u-l.origin;return Math.abs(g)>=t.minAmplitudePx&&(l.dir=g>0?1:-1,l.extent=Math.abs(g)),!1}const p=(u-l.origin)*l.dir;if(p>=l.extent)return l.extent=p,!1;if(l.extent-p>=t.minAmplitudePx){const g=l.origin+l.dir*l.extent;return l.origin=g,l.dir=l.dir===1?-1:1,l.extent=l.extent-p,l.extent>=0}return!1};return{feed:(l,u,p)=>{if(p<r)return null;if(!s)return s=!0,n.origin=l,o.origin=u,null;const g=i[i.length-1];g&&p-g.t>t.maxGapMs&&(i=[]);const b=a(n,l),y=a(o,u);if(b&&i.push({t:p,axis:"x"}),y&&i.push({t:p,axis:"y"}),!b&&!y||i.length<t.minReversals)return null;const w=p-i[0].t;if(w<t.minDurationMs)return null;let S=0;for(const C of i)C.axis==="x"&&S++;const E={x:l,y:u,durationMs:w,reversals:i.length,axis:S*2>=i.length?"x":"y"};return d(),r=p+t.cooldownMs,E},reset:d}}function Na(e,t){e.dispatchEvent(new CustomEvent(Ia,{detail:t,bubbles:!0,composed:!0}))}function Eo(e,t){let n=!1;return()=>{n||(n=!0,requestAnimationFrame(()=>{if(n=!1,!(t==="drag"&&!e._isDragging)&&!(t==="resize"&&!e._isResizing)&&!(e._isDestroyed||!e.element.isConnected))try{m(f.WINDOW_BOUNDS_CHANGED,{windowId:e.id,x:e.element.offsetLeft,y:e.element.offsetTop,width:e.element.offsetWidth,height:e.element.offsetHeight,state:e.state,phase:t})}catch{}}))}}function Ra(e,t){const n=t.target;if(n.closest(".os-window__btn")||n.closest(".os-window__custom-buttons")||n.closest(".os-window__controls")||n.closest(".os-window__screen-meta")||n.closest(".os-window__menu-btn")||n.closest(".os-window__menu-panel")||Ut())return;const o=e.state==="maximized",i=e.state==="snapped-left"||e.state==="snapped-right",s=o||i,r=t.clientX,d=t.clientY,a=t.pointerId,c=s?Oa(e,t):null;e._titleBar.setPointerCapture(a);const l=e.snapConfigProvider?.()??{enabled:!1,cellWidth:0,cellHeight:0},u=Eo(e,"drag"),p=La();let g=!1,b=r,y=d;const w=(h,v,I)=>{h===g||!e._isDragging||(g=h,e.onDragGesture?.(e,{type:"modifier",active:h,clientX:v,clientY:I}))},S=h=>{h.key==="Alt"&&(h.preventDefault(),w(h.type==="keydown",b,y))};let E=!1;const C=(h,v)=>{if(E)return;E=!0;let I,H;if(c){const P=Da(e,c,h,v);I=P.left,H=P.top}else I=e.element.offsetLeft,H=e.element.offsetTop;e.element.classList.add("os-window--dragging"),l.enabled&&e.element.classList.add("os-window--snap-drag"),e._isDragging=!0,e._dragOffsetX=h-I,e._dragOffsetY=v-H,window.addEventListener("keydown",S),window.addEventListener("keyup",S),m(f.WINDOW_DRAG_START,{windowId:e.id})};s||C(r,d);const N=h=>{if(!E){const F=h.clientX-r,Ce=h.clientY-d;if(F*F+Ce*Ce<Ts)return;C(h.clientX,h.clientY)}if(!e._isDragging)return;let v=h.clientX-e._dragOffsetX,I=h.clientY-e._dragOffsetY;const H=e.element.parentElement;if(H){const F=Pa(v,I,e.element.offsetWidth,{x:0,y:0,width:H.clientWidth,height:H.clientHeight});v=F.x,I=F.y}l.enabled&&(v=Math.round(v/l.cellWidth)*l.cellWidth,I=Math.round(I/l.cellHeight)*l.cellHeight),e.element.style.left=`${v}px`,e.element.style.top=`${I}px`,b=h.clientX,y=h.clientY,w(h.altKey,h.clientX,h.clientY),e.onDragMove?.(e,h.clientX,h.clientY);const P=p.feed(h.clientX,h.clientY,h.timeStamp);P&&(Na(e.element,P),m(f.POINTER_SHAKE,{...P,windowId:e.id}),e.onDragGesture?.(e,{type:"shake",clientX:h.clientX,clientY:h.clientY})),u()},D=()=>{try{e._titleBar.releasePointerCapture(a)}catch{}},Se=()=>{e._titleBar.removeEventListener("pointermove",N),e._titleBar.removeEventListener("pointerup",j),e._titleBar.removeEventListener("pointercancel",j),e._titleBar.removeEventListener("lostpointercapture",j),window.removeEventListener("keydown",S),window.removeEventListener("keyup",S),p.reset()},j=()=>{if(!E){D(),Se();return}if(!e._isDragging||(e._isDragging=!1,e.element.classList.remove("os-window--dragging"),e.element.classList.remove("os-window--snap-drag"),D(),Se(),e.onDragEnd?.(e)??!1))return;e._gridSpan=null,e._emitChange("moved");const v={windowId:e.id,x:e.element.offsetLeft,y:e.element.offsetTop};m(f.WINDOW_DRAG_END,v),m(f.WINDOW_MOVED,v)};e._titleBar.addEventListener("pointermove",N),e._titleBar.addEventListener("pointerup",j),e._titleBar.addEventListener("pointercancel",j),e._titleBar.addEventListener("lostpointercapture",j)}function Oa(e,t){const n=e._titleBar.getBoundingClientRect(),o=n.width>0?(t.clientX-n.left)/n.width:.5,i=e.element.parentElement,s=i?Ye(i):null,r=s?Math.min(960,Math.round(s.width*.6)):640,d=s?Math.min(640,Math.round(s.height*.7)):480,a=e._savedGeometry?.width??r,c=e._savedGeometry?.height??d,l=i?.getBoundingClientRect();return{isMaximized:e.state==="maximized",cursorRatioX:o,titleBarHeight:n.height,areaLeft:l?.left??0,areaTop:l?.top??0,targetW:a,targetH:c}}function Da(e,t,n,o){e.element.classList.remove("os-window--maximized","os-window--snapped-left","os-window--snapped-right"),e.element.style.width=`${t.targetW}px`,e.element.style.height=`${t.targetH}px`;const i=Math.max(B,Math.round(n-t.areaLeft-t.targetW*t.cursorRatioX)),s=Math.max(B,Math.round(o-t.areaTop-t.titleBarHeight/2));return e.element.style.left=`${i}px`,e.element.style.top=`${s}px`,e.state="normal",e._emitChange("state"),t.isMaximized&&m(f.WINDOW_UNMAXIMIZED,{windowId:e.id}),{left:i,top:s}}function Wa(e,t){if(e.state==="maximized"||e.state==="fullscreen")return;t.preventDefault(),t.stopPropagation();const n=t.target,o=n.dataset.dir??"se";e._isResizing=!0,e._resizeStartX=t.clientX,e._resizeStartY=t.clientY,e._resizeStartW=e.element.offsetWidth,e._resizeStartH=e.element.offsetHeight;const i=e.element.offsetLeft,s=e.element.offsetTop;n.setPointerCapture(t.pointerId),e.element.classList.add("os-window--resizing"),m(f.WINDOW_RESIZE_START,{windowId:e.id});const r=Eo(e,"resize"),d=e.snapConfigProvider?.()??{enabled:!1,cellWidth:0,cellHeight:0};d.enabled&&e.element.classList.add("os-window--snap-drag"),(e.state==="snapped-left"||e.state==="snapped-right")&&(e.element.classList.remove("os-window--snapped-left","os-window--snapped-right"),e.state="normal");const a=l=>{if(!e._isResizing)return;const u=l.clientX-e._resizeStartX,p=l.clientY-e._resizeStartY,g=Ma(o,u,p,i,s,e._resizeStartW,e._resizeStartH,e.config.minWidth,e.config.minHeight,d);e.element.style.left=`${g.x}px`,e.element.style.top=`${g.y}px`,e.element.style.width=`${g.width}px`,e.element.style.height=`${g.height}px`,r()},c=()=>{if(!e._isResizing)return;e._isResizing=!1,e.element.classList.remove("os-window--resizing"),e.element.classList.remove("os-window--snap-drag"),n.removeEventListener("pointermove",a),n.removeEventListener("pointerup",c),n.removeEventListener("pointercancel",c),n.removeEventListener("lostpointercapture",c),e._gridSpan=null,e._emitChange("resized");const l={windowId:e.id,width:e.element.offsetWidth,height:e.element.offsetHeight};m(f.WINDOW_RESIZE_END,l),m(f.WINDOW_RESIZED,l)};n.addEventListener("pointermove",a),n.addEventListener("pointerup",c),n.addEventListener("pointercancel",c),n.addEventListener("lostpointercapture",c)}function Ma(e,t,n,o,i,s,r,d,a,c){let l=s,u=r,p=o,g=i;if((e==="ne"||e==="se")&&(l=Math.max(d,s+t)),e==="nw"||e==="sw"){const b=Math.max(d,s-t);p=o+(s-b),l=b}if((e==="se"||e==="sw")&&(u=Math.max(a,r+n)),e==="ne"||e==="nw"){const b=Math.max(a,r-n);g=i+(r-b),u=b}if(c.enabled){const b=Math.max(d,Math.round(l/c.cellWidth)*c.cellWidth),y=Math.max(a,Math.round(u/c.cellHeight)*c.cellHeight);(e==="nw"||e==="sw")&&(p=o+(l-b)),(e==="nw"||e==="ne")&&(g=i+(u-y)),l=b,u=y}if(p<B){const b=B-p;p=B,l=Math.max(d,l-b)}if(g<B){const b=B-g;g=B,u=Math.max(a,u-b)}return{x:p,y:g,width:l,height:u}}function Pa(e,t,n,o){const i=o.x+ft-n,s=o.x+o.width-ft,r=Math.max(i,Math.min(e,s)),d=o.y+B,a=o.y+o.height-ft,c=Math.max(d,Math.min(t,a));return{x:r,y:c}}const $a="os-speculate-doc",Ao=new Map,za=1e3;function Ha(e){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker.controller)return;let t;try{const i=new URL(e,window.location.href);if(i.origin!==window.location.origin)return;t=i.toString()}catch{return}const n=Date.now(),o=Ao.get(t);if(!(o!==void 0&&n-o<za)){Ao.set(t,n);try{navigator.serviceWorker.controller.postMessage({type:$a,url:t})}catch{}}}const Tt=window.location.origin,Fa="os-window-open",Ua=300;function Ga(e){if(!window.wp?.os?.getOsSettings?.().windowPrewarmEnabled)return;const n=fe(e);n&&Ha(n)}const Ba=120,ae=class ae{constructor(t){if(this.state="normal",this._activityCount=0,this._activityPhase="idle",this._activityError=null,this._activityClearTimer=null,this._activitySavingStartedAt=0,this._activitySettleTimer=null,this._navigationActivity="none",this._navigationActivityTimer=null,this._isDragging=!1,this._isResizing=!1,this._isDestroyed=!1,this._dragOffsetX=0,this._dragOffsetY=0,this._resizeStartX=0,this._resizeStartY=0,this._resizeStartW=0,this._resizeStartH=0,this._savedGeometry=null,this._gridSpan=null,this._savedFullscreenState=null,this._stateBeforeMinimize=null,this._minimizeAnimation=null,this._restoreAnimation=null,this._externalTabs=new Map,this._externalTabSeq=0,this._titleBarButtonsUnsubscribe=null,this._windowThemesUnsubscribe=null,this._windowControlsUnsubscribe=null,this._windowControlsTeardown=null,this._windowSlotsUnsubscribe=null,this._windowSlotsTeardown=null,this._chromeHandle=null,this._chromeId=ze,this._windowChromesUnsubscribe=null,this._nativeRenderTeardown=null,this._nativeRenderCtxDispose=null,this._closeSafetyNetTimer=null,this._clearOpeningClassRemoval=null,this._onCloseTransitionEnd=null,this._isFinalized=!1,this._iframeBridgeReady=!1,this._iframeCloseTimeout=null,this._closePending=!1,this._unsavedGuardPending=!1,this._deferredNavigationCommit=null,this._deferredNavigationTimer=null,this._activeTabId="primary",this.onFocusRequest=null,this.onClose=null,this.onMinimize=null,this.onRestore=null,this.onOpenAnother=null,this.onOpenInNewWindow=null,this.onToggleStartup=null,this.snapConfigProvider=null,this.onDragMove=null,this.onDragEnd=null,this.onDragGesture=null,this._boundOnDocumentPointerDown=null,this._unsubscribeWindowActions=null,this._bodyResizeObserver=null,this._tabOverflowTeardown=null,this._tabSpeculateTimer=null,this._swapBuffer=null,this._swapBufferTimer=null,this._suppressCloseFilter=!1,this.id=t.id,this.config=t,this.element=Ks(t),this.iframe=t.native?null:this.element.querySelector(".os-window__iframe"),this._titleBar=this.element.querySelector(".os-window__titlebar"),this._titleEl=this.element.querySelector(".os-window__title"),this._boundOnMessage=n=>yr(this,n),this.bindEvents(),this.iframe&&this._wireContentFocusForwarder(this.iframe),this.renderCustomTitleBarButtons(),this._titleBarButtonsUnsubscribe=zr(()=>{this.renderCustomTitleBarButtons()}),St(this,this.config.appearance?.theme),this._windowThemesUnsubscribe=qr(()=>{this._isDestroyed||St(this,this.config.appearance?.theme)}),this.repaintWindowControls(),this._windowControlsUnsubscribe=Qr(()=>{this._isDestroyed||this.repaintWindowControls()}),this.repaintWindowSlots(),this._windowSlotsUnsubscribe=ha(()=>{this._isDestroyed||this.repaintWindowSlots()}),this.remountWindowChrome(),this._windowChromesUnsubscribe=wa(()=>{if(this._isDestroyed)return;po(this)!==this._chromeId&&this.remountWindowChrome()}),this._bodyResizeObserver=this.installBodyResizeObserver(),t.initialState==="minimized"){this.state="minimized",this.element.classList.add("os-window--minimized"),this.iframe&&(this.iframe.style.visibility="hidden"),this.element.style.setProperty("content-visibility","hidden");return}(t.initialState==="snapped-left"||t.initialState==="snapped-right")&&this.element.classList.add(`os-window--${t.initialState}`),document.hidden||(this.element.classList.add("os-window--opening"),this._armOpeningClassRemoval()),t.initialState&&t.initialState!=="normal"&&requestAnimationFrame(()=>this.applyInitialState(t.initialState))}_armOpeningClassRemoval(){const t=this.element;let n=null,o=!1;const i=()=>{o||(o=!0,this._clearOpeningClassRemoval=null,n!==null&&(window.clearTimeout(n),n=null),t.removeEventListener("animationend",s),t.removeEventListener("animationcancel",s),t.classList.remove("os-window--opening"))},s=r=>{r.target!==t||r.animationName!==Fa||i()};t.addEventListener("animationend",s),t.addEventListener("animationcancel",s),n=window.setTimeout(()=>{n=null,i()},Ua),this._clearOpeningClassRemoval=i}hydrateNative(){if(!this.config.native||!this.config.render)return;const t=this.element.querySelector(".os-window__body");if(!t)return;const n=T(f.NATIVE_WINDOW_BEFORE_RENDER,t,{windowId:this.id,config:this.config}),o=n instanceof HTMLElement?n:t,{ctx:i,dispose:s}=ri(this.id,this.config.params??{});this._nativeRenderCtxDispose=s;const r=this.config.render(o,i),d=c=>{typeof c=="function"&&(this._nativeRenderTeardown=c)};r instanceof Promise?r.then(c=>{this._isDestroyed||(d(c),$(this.id))},c=>{typeof console<"u"&&console.error(`[openstation] native render rejected for "${this.id}":`,c),m(f.SHELL_ERROR,{scope:"window-open",id:this.id,error:c}),!this._isDestroyed&&$(this.id)}):(d(r),requestAnimationFrame(()=>{this._isDestroyed||$(this.id)})),m(f.NATIVE_WINDOW_AFTER_RENDER,{windowId:this.id,body:o,config:this.config});const a=this.config.autofocus;a&&requestAnimationFrame(()=>{if(this._isDestroyed)return;if(typeof a=="string"){o.querySelector(a)?.focus();return}o.hasAttribute("tabindex")||(o.tabIndex=-1),o.focus()})}applyInitialState(t){t==="minimized"?this.minimize():t==="maximized"?this.toggleMaximize():t==="fullscreen"?this.toggleFullscreen():t==="snapped-left"?this.applySnap("left"):t==="snapped-right"&&this.applySnap("right")}_emitChange(t){t==="state"&&(this._gridSpan=null),document.dispatchEvent(new CustomEvent("os-window-changed",{detail:{windowId:this.id,reason:t,state:this.state}}))}snapGeometry(t){const n=this.snapConfigProvider?.();if(!n||!n.enabled)return t;const o=Math.max(this.config.minWidth,Math.round(t.width/n.cellWidth)*n.cellWidth),i=Math.max(this.config.minHeight,Math.round(t.height/n.cellHeight)*n.cellHeight);return{x:Math.round(t.x/n.cellWidth)*n.cellWidth,y:Math.round(t.y/n.cellHeight)*n.cellHeight,width:o,height:i}}getCurrentUrl(){if(!this.iframe)return this.config.url||`#${this.id}`;try{const t=this.iframe.contentWindow?.location.href;if(t&&t!=="about:blank")return t}catch{}return this.iframe.src}bindEvents(){this.element.addEventListener("pointerdown",()=>{this.element.classList.contains("os-window--overview")||this.onFocusRequest?.(this)}),this.element.addEventListener("focusin",()=>{this.element.classList.contains("os-window--overview")||this.onFocusRequest?.(this)}),this._titleBar.addEventListener("pointerdown",s=>Ra(this,s)),this.element.querySelectorAll(".os-window__resize-handle").forEach(s=>{s.addEventListener("pointerdown",r=>Wa(this,r))});const n=this.element.querySelector(".os-window__menu-btn"),o=this.element.querySelector(".os-window__menu-panel");if(n&&o){n.addEventListener("click",l=>{l.stopPropagation(),bo(this)});const s=o.querySelector(".os-window__menu-item--open-another");s&&s.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),V(this),this.onOpenAnother?.(this)});const r=o.querySelector(".os-window__menu-item--open-in-new-window");r&&r.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),V(this),this.onOpenInNewWindow?.(this)});const d=o.querySelector(".os-window__menu-item--reload");d&&d.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),V(this),this.reload()});const a=o.querySelector(".os-window__menu-item--open-external");a&&a.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),V(this),this.detach()});const c=o.querySelector(".os-window__menu-item--startup");c&&(xt(this,c),c.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),yo(c),this.onToggleStartup?.(this)}),document.addEventListener("os-default-window-changed",()=>{xt(this,c)})),o.addEventListener("keydown",l=>{l.key==="Escape"&&(l.stopPropagation(),V(this),n.focus())})}this._titleBar.addEventListener("dblclick",s=>{s.target?.closest('button, [role="button"], [role="menuitem"], [role="menuitemcheckbox"], os-window-button, os-menu, os-menu-item, .os-window__menu-panel, .os-window__custom-buttons, input, select, textarea, a')||Ut()||this.toggleMaximize()});const i=this.element.querySelector(".os-window__tabs");if(i&&(i.addEventListener("click",s=>tr(this,s)),i.addEventListener("keydown",s=>oi(i,s)),i.addEventListener("pointerover",s=>{const r=s;if(r.pointerType!=="mouse")return;const d=r.target?.closest?.(".os-window__tab[data-url]"),a=d?.dataset.url;a&&(d?.classList.contains("is-active")||(this._tabSpeculateTimer&&window.clearTimeout(this._tabSpeculateTimer),this._tabSpeculateTimer=window.setTimeout(()=>{this._tabSpeculateTimer=null,Ga(a)},Ba)))}),i.addEventListener("pointerleave",()=>{this._tabSpeculateTimer&&(window.clearTimeout(this._tabSpeculateTimer),this._tabSpeculateTimer=null)}),this._tabOverflowTeardown=or(i)),this.iframe){const s=this.iframe;this._wireTabNavSync(s),window.addEventListener("message",this._boundOnMessage)}}addExternalTab(t,n){Gn(this,t,n)}setTabs(t,n){ii(this.element,t,n)}activateTab(t){Qe(this.element,t)}setZIndex(t){this.element.style.zIndex=String(t)}setFocused(t){this.element.classList.toggle("os-window--focused",t),this._notifyChromeStateChanged()}setTitle(t){const n=this.element.querySelector(".os-window__title");n&&(this._titleEl=n,n.textContent=t),this.config.title=t,m(f.WINDOW_TITLE_CHANGED,{windowId:this.id,title:t}),this._notifyChromeStateChanged()}repaintWindowControls(){const t=this.element.querySelector(".os-window__controls");if(t){if(this._windowControlsTeardown){try{this._windowControlsTeardown()}catch{}this._windowControlsTeardown=null}this._windowControlsTeardown=oa(this,t)}}repaintThemedChrome(){const t=this.element.querySelector(".os-window__slot--icon");if(t){const o=t.querySelector(".os-window__icon");o&&o.replaceWith(aa(this.config.icon,{title:this.config.title,className:"os-window__icon",slot:es(this.config.id)}))}const n=this.element.querySelector(".os-window__menu-btn");n&&(n.querySelectorAll(":scope > .dashicons").forEach(o=>o.remove()),n.removeAttribute("icon-src"),n.setAttribute("icon","menu"),lt(n,"core/menu"))}setAppearanceControls(t){this.config.appearance={...this.config.appearance??{},controls:t??void 0},this.repaintWindowControls()}repaintWindowSlots(){if(this._windowSlotsTeardown){try{this._windowSlotsTeardown()}catch{}this._windowSlotsTeardown=null}this._windowSlotsTeardown=ga(this)}remountWindowChrome(){if(this._chromeHandle){try{this._chromeHandle.destroy()}catch{}this._chromeHandle=null}this.element.classList.remove(kt);const t=ya(this);t?(this._chromeHandle=t.handle,this._chromeId=t.id):this._chromeId=ze}setAppearanceChrome(t){this.config.appearance={...this.config.appearance??{},chrome:t??void 0},this.remountWindowChrome()}_notifyChromeStateChanged(){if(!this._isDestroyed&&this._chromeHandle?.update)try{this._chromeHandle.update(mo(this))}catch{}}setAppearanceSlot(t,n){const i={...this.config.appearance?.slots??{}};n===void 0?delete i[t]:i[t]=n,this.config.appearance={...this.config.appearance??{},slots:i},this.repaintWindowSlots()}setAppearanceTheme(t){let n;t==null?n=void 0:typeof t=="string"?n={themeId:t}:typeof t=="object"&&("themeId"in t||"tokens"in t)?n=t:typeof t=="object"&&(n={tokens:t}),this.config.appearance={...this.config.appearance??{},theme:n},St(this,n)}applySnap(t){this._applySnapVisuals(t)&&(this.state=t==="left"?"snapped-left":"snapped-right",this._emitChange("state"))}_applySnapVisuals(t){const n=this.element.parentElement;if(!n)return!1;const o=Ye(n),i=Math.floor(o.width/2);return this.element.classList.remove("os-window--maximized","os-window--fullscreen","os-window--snapped-left","os-window--snapped-right"),this.element.classList.add(`os-window--snapped-${t}`),this.element.style.left=`${t==="left"?o.x:o.x+o.width-i}px`,this.element.style.top=`${o.y}px`,this.element.style.width=`${i}px`,this.element.style.height=`${o.height}px`,!0}isMinimized(){return this.state==="minimized"}isMaximized(){return this.state==="maximized"}isFullscreen(){return this.state==="fullscreen"}isSnapped(t){return t==="left"?this.state==="snapped-left":t==="right"?this.state==="snapped-right":this.state==="snapped-left"||this.state==="snapped-right"}isFocused(){return this.element.classList.contains("os-window--focused")}_prefersReducedMotion(){try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}_getDockTarget(){const t=[],n=s=>{typeof s=="string"&&s!==""&&!t.includes(s)&&t.push(s)};n(this.id),n(this.config.baseId);for(const s of t){let r=s;try{typeof CSS<"u"&&typeof CSS.escape=="function"&&(r=CSS.escape(s))}catch{r=s}const d=[`.os-dock__item[data-os-window-base-id="${r}"] .os-dock__item-primary`,`.os-dock__item[data-os-window-base-id="${r}"]`,`.os-dock__item[data-menu-slug="${r}"] .os-dock__item-primary`,`.os-dock__item[data-system-id="${r}"] .os-dock__item-primary`,`.os-dock__item[data-nav-id="${r}"] .os-dock__item-primary`,`.os-dock__item[data-menu-slug="${r}"]`,`.os-dock__item[data-system-id="${r}"]`,`.os-dock__item[data-nav-id="${r}"]`];for(const a of d){const c=document.querySelector(a);if(c){const l=c.getBoundingClientRect();if(l.width>0&&l.height>0)return c}}}const o=['.os-dock__item[data-os-window-base-id="os-system"] .os-dock__item-primary','.os-dock__item[data-system-id="os-system"] .os-dock__item-primary','.os-dock__item[data-os-window-base-id="os-system"]','.os-dock__item[data-system-id="os-system"]'];if(this.id==="desktop-mode-os-settings"||this.id==="os-settings"||this.config.baseId==="desktop-mode-os-settings")for(const s of o){const r=document.querySelector(s);if(r){const d=r.getBoundingClientRect();if(d.width>0&&d.height>0)return r}}const i=document.querySelector("#os-dock")??document.querySelector(".os-dock");if(i){const s=i.getBoundingClientRect();if(s.width>0&&s.height>0)return i}return null}_clearGenieStyles(){this.element.style.removeProperty("will-change"),this.element.style.removeProperty("transform"),this.element.style.removeProperty("opacity")}_cancelGenieAnimation(t){const n=t==="minimize",o=n?this._minimizeAnimation:this._restoreAnimation;if(o){try{o.cancel()}catch{}n?(this._minimizeAnimation=null,this.element.classList.remove("os-window--minimizing")):(this._restoreAnimation=null,this.element.classList.remove("os-window--restoring")),this._clearGenieStyles()}}_buildGenieTransform(t,n,o){const i=n.left+n.width/2-(t.left+t.width/2),s=n.top+n.height/2-(t.top+t.height/2),r=Math.min(n.width/t.width,n.height/t.height);return{dx:i,dy:s,scale:Math.max(.06,Math.min(r,o))}}_canGenieAnimate(t){return!!t&&!this._prefersReducedMotion()&&typeof this.element.animate=="function"&&!document.hidden&&!this.element.classList.contains("os-window--overview")}_installMinimizeContentVisibilityGuard(){const t=()=>{this.state==="minimized"&&!this.element.classList.contains("os-window--overview")&&(this.iframe&&(this.iframe.style.visibility="hidden"),this.element.style.setProperty("content-visibility","hidden"))};t(),this.element.addEventListener("transitionend",n=>{n.propertyName==="opacity"&&t()},{once:!0})}minimize(){if(this.state==="minimized")return;this._cancelGenieAnimation("restore"),this._cancelGenieAnimation("minimize"),this._stateBeforeMinimize=this.state;const t=this._getDockTarget();if(this._canGenieAnimate(t)){const n=this.element.getBoundingClientRect(),o=t.getBoundingClientRect();if(n.width>0&&n.height>0&&o.width>0&&o.height>0){this.state="minimized",this.element.classList.add("os-window--minimizing"),this.element.style.willChange="transform";const{dx:s,dy:r,scale:d}=this._buildGenieTransform(n,o,.22);let a=null;try{a=this.element.animate([{transform:"translate(0px, 0px) scale(1)",opacity:1},{offset:.6,transform:`translate(${s*.6}px, ${r*.6}px) scale(${1-(1-d)*.6})`,opacity:1},{transform:`translate(${s}px, ${r}px) scale(${d})`,opacity:0}],{duration:480,easing:"cubic-bezier(0.32, 0.72, 0, 1)",fill:"forwards"})}catch{a=null}if(a){this._minimizeAnimation=a,a.onfinish=()=>{if(this._minimizeAnimation===a){this._minimizeAnimation=null,this.element.classList.add("os-window--minimized"),this.element.classList.remove("os-window--minimizing"),this._clearGenieStyles();try{a.cancel()}catch{}this._installMinimizeContentVisibilityGuard()}},a.oncancel=()=>{this._minimizeAnimation===a&&(this._minimizeAnimation=null,this.element.classList.remove("os-window--minimizing"),this._clearGenieStyles())},this.onMinimize?.(this),this._emitChange("state"),m(f.WINDOW_MINIMIZED,{windowId:this.id,element:this.element}),this._stateBeforeMinimize==="fullscreen"&&J();return}this.element.classList.remove("os-window--minimizing"),this._clearGenieStyles()}}this.state="minimized",this.element.classList.add("os-window--minimized"),this._installMinimizeContentVisibilityGuard(),this.onMinimize?.(this),this._emitChange("state"),m(f.WINDOW_MINIMIZED,{windowId:this.id,element:this.element}),this._stateBeforeMinimize==="fullscreen"&&J()}restore(){this._cancelGenieAnimation("minimize"),this._cancelGenieAnimation("restore");const t=this.state==="minimized",n=t?this._getDockTarget():null;if(t&&this._canGenieAnimate(n)){this.element.style.removeProperty("content-visibility"),this.iframe&&(this.iframe.style.visibility=""),this.element.classList.remove("os-window--minimized"),this.element.classList.add("os-window--restoring"),this.element.style.willChange="transform";const o=this._stateBeforeMinimize??"normal";this.state=o,this._stateBeforeMinimize=null,o==="fullscreen"&&(J(),this.updateFocusButtonState());const i=this.element.getBoundingClientRect(),s=n.getBoundingClientRect();if(i.width>0&&i.height>0&&s.width>0&&s.height>0){const{dx:d,dy:a,scale:c}=this._buildGenieTransform(i,s,.24);let l=null;try{l=this.element.animate([{transform:`translate(${d}px, ${a}px) scale(${c})`,opacity:0},{offset:.4,transform:`translate(${d*.4}px, ${a*.4}px) scale(${1-(1-c)*.4})`,opacity:1},{transform:"translate(0px, 0px) scale(1)",opacity:1}],{duration:480,easing:"cubic-bezier(0.32, 0.72, 0, 1)",fill:"forwards"})}catch{l=null}if(l){this._restoreAnimation=l;const u=()=>{if(this._restoreAnimation===l){this._restoreAnimation=null,this.element.classList.remove("os-window--restoring"),this._clearGenieStyles();try{l.cancel()}catch{}}};l.onfinish=u,l.oncancel=()=>{this._restoreAnimation===l&&(this._restoreAnimation=null,this.element.classList.remove("os-window--restoring"),this._clearGenieStyles())},this.onRestore?.(this),this.onFocusRequest?.(this),this._emitChange("state"),m(f.WINDOW_RESTORED,{windowId:this.id,element:this.element});return}}this.element.classList.remove("os-window--restoring"),this._clearGenieStyles(),this.onRestore?.(this),this.onFocusRequest?.(this),this._emitChange("state"),m(f.WINDOW_RESTORED,{windowId:this.id,element:this.element});return}this.element.style.removeProperty("content-visibility"),this.iframe&&(this.iframe.style.visibility=""),this.element.classList.remove("os-window--minimized"),t&&(this.state=this._stateBeforeMinimize??"normal",this._stateBeforeMinimize=null,this.state==="fullscreen"&&(J(),this.updateFocusButtonState())),t&&this.onRestore?.(this),this.onFocusRequest?.(this),this._emitChange("state"),t&&m(f.WINDOW_RESTORED,{windowId:this.id,element:this.element})}maximize(){this.state!=="maximized"&&(this.state==="normal"&&(this._savedGeometry={x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight}),this._applyMaximizeVisuals()&&(this.state="maximized",this._emitChange("state"),m(f.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element})))}_applyMaximizeVisuals(){const t=this.element.parentElement;if(!t)return!1;this.element.classList.remove("os-window--fullscreen","os-window--snapped-left","os-window--snapped-right"),this.element.classList.add("os-window--maximized");const n=Ye(t);return this.element.style.left=`${n.x}px`,this.element.style.top=`${n.y}px`,this.element.style.width=`${n.width}px`,this.element.style.height=`${n.height}px`,!0}toggleMaximize(){if(this.element.parentElement){if(this.state==="maximized"){if(this.element.classList.remove("os-window--maximized"),this._savedGeometry){const n=this.snapGeometry(this._savedGeometry);this.element.style.left=`${n.x}px`,this.element.style.top=`${n.y}px`,this.element.style.width=`${n.width}px`,this.element.style.height=`${n.height}px`,this._savedGeometry=n}this.state="normal",this._emitChange("state"),m(f.WINDOW_UNMAXIMIZED,{windowId:this.id,element:this.element});return}if(this.state==="fullscreen"){this._savedFullscreenState=null,this._applyMaximizeVisuals(),this.state="maximized",J(),this.updateFocusButtonState(),this._emitChange("state"),m(f.WINDOW_FULLSCREEN_EXITED,{windowId:this.id,element:this.element}),m(f.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element});return}this.maximize()}}toggleFullscreen(){if(this.state==="fullscreen"){this.element.classList.remove("os-window--fullscreen");const t=this._savedFullscreenState;this._savedFullscreenState=null;let n=!1;if(t&&t.state==="maximized")this._applyMaximizeVisuals(),this.state="maximized",n=!0;else if(t&&(t.state==="snapped-left"||t.state==="snapped-right")){const o=t.state==="snapped-left"?"left":"right";this._applySnapVisuals(o),this.state=t.state}else t?(this.element.style.left=`${t.x}px`,this.element.style.top=`${t.y}px`,this.element.style.width=`${t.width}px`,this.element.style.height=`${t.height}px`,this.state="normal"):this.state="normal";J(),this.updateFocusButtonState(),this._emitChange("state"),m(f.WINDOW_FULLSCREEN_EXITED,{windowId:this.id,element:this.element}),n&&m(f.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element});return}this.state==="normal"&&(this._savedGeometry={x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight}),this._savedFullscreenState={state:this.state,x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight},this.element.classList.remove("os-window--maximized","os-window--snapped-left","os-window--snapped-right"),this.element.classList.add("os-window--fullscreen"),this.state="fullscreen",J(),this.updateFocusButtonState(),this._emitChange("state"),m(f.WINDOW_FULLSCREEN_ENTERED,{windowId:this.id,element:this.element})}updateFocusButtonState(){const t=this.element.querySelector(".os-window__btn--focus");if(!t)return;const n=this.state==="fullscreen";t.classList.toggle("os-window__btn--active",n),t.setAttribute("aria-pressed",n?"true":"false"),t.setAttribute("aria-label",_(n?"Exit fullscreen":"Enter fullscreen"))}detach(){const t=this.getCurrentUrl();let n;try{n=new URL(t,Tt)}catch{return}n.origin===Tt&&(n.searchParams.delete("openstation_chromeless"),n.searchParams.delete("desktop_mode_portal"),n.searchParams.set("desktop_mode_classic","1"),window.open(n.toString(),"_blank","noopener"),m(f.WINDOW_DETACHED,{windowId:this.id,url:n.toString()}))}reload(){if(this.element.querySelector(".os-window__body")?.classList.contains("os-window__body--loading")||this._unsavedGuardPending)return;if(this.config.native){this._reloadNative();return}let n,o;if(this._activeTabId==="primary"){if(!this.iframe)return;const r=this.iframe;n=this.getCurrentUrl(),o=()=>{try{r.contentWindow?.location.reload()}catch{r.src=r.src}}}else{const r=this._externalTabs.get(this._activeTabId);if(!r)return;n=r.url,o=()=>{try{r.iframe.contentWindow?.location.reload()}catch{r.iframe.src=r.url}}}this._spinReloadButton();const i=()=>{this.markContentLoading()},s=()=>{o(),m(f.WINDOW_RELOADED,{windowId:this.id,url:n})};this._activeTabId==="primary"?_t(this,{commit:i,navigate:s}):(i(),s())}_reloadNative(){if(!this.config.render)return;const t=this.element.querySelector(".os-window__body");if(t){if(this._nativeRenderCtxDispose){try{this._nativeRenderCtxDispose()}catch(n){m(f.SHELL_ERROR,{scope:"native-window-ctx-dispose",id:this.id,error:n})}this._nativeRenderCtxDispose=null}if(this._nativeRenderTeardown){try{this._nativeRenderTeardown()}catch(n){m(f.SHELL_ERROR,{scope:"native-window-teardown",id:this.id,error:n})}this._nativeRenderTeardown=null}t.replaceChildren(),this._spinReloadButton(),this.markContentLoading(),this.hydrateNative(),m(f.WINDOW_RELOADED,{windowId:this.id,url:this.config.url??""})}}navigateTo(t){if(this.config.native||!this.iframe)return!1;const n=fe(t);return n?(_t(this,{commit:()=>{this.markContentLoading(),pe(this,t)},navigate:()=>{const o=this.iframe?.contentWindow;if(o)try{o.location.assign(n);return}catch{}this.iframe&&(this.iframe.src=n)}}),!0):!1}_wireContentFocusForwarder(t){const n=()=>{let o=null;try{o=t.contentDocument}catch{return}o&&(o.location&&o.location.pathname.indexOf("/wp-admin/")!==-1||o.addEventListener("pointerdown",()=>{this.element.classList.contains("os-window--overview")||this.onFocusRequest?.(this)},{capture:!0,passive:!0}))};t.addEventListener("load",n),n()}_wireTabNavSync(t){t.addEventListener("load",()=>{try{const n=t.contentWindow?.location.href;if(!n||Lr(this,n))return;Nr(this),pe(this,n)}catch{}})}_discardSwapBuffer(){this._swapBufferTimer!==null&&(window.clearTimeout(this._swapBufferTimer),this._swapBufferTimer=null),this._swapBuffer&&(this._swapBuffer.remove(),this._swapBuffer=null,this.iframe?.classList.remove("os-window__iframe--swap-front"))}swapReload(t){if(this.config.native||!this.iframe||this._isDestroyed)return;if(this._activeTabId!=="primary"){this.reload();return}const n=t?fe(t):this.getCurrentUrl();if(!n)return;this._discardSwapBuffer();const o=this.iframe;o.classList.add("os-window__iframe--swap-front");const i=document.createElement("iframe");i.className="os-window__iframe os-window__iframe--buffer",i.setAttribute("aria-hidden","true"),i.setAttribute("name",`os-frame-${this.id}-buffer`),this._swapBuffer=i,this._swapBufferTimer=window.setTimeout(()=>{this._swapBuffer===i&&this._discardSwapBuffer()},2e4),i.addEventListener("load",()=>{if(this._swapBuffer!==i||this._isDestroyed)return;this._swapBuffer=null,this._swapBufferTimer!==null&&(window.clearTimeout(this._swapBufferTimer),this._swapBufferTimer=null);let s=0,r=0;try{s=o.contentWindow?.scrollX??0,r=o.contentWindow?.scrollY??0}catch{}if(s||r)try{i.contentWindow?.scrollTo(s,r)}catch{}i.classList.remove("os-window__iframe--buffer"),i.removeAttribute("aria-hidden"),i.setAttribute("name",`os-frame-${this.id}`),o.remove(),this.iframe=i,$(this.id),ht(i),i.addEventListener("load",()=>{$(this.id),ht(i)}),this._wireContentFocusForwarder(i),this._wireTabNavSync(i),pe(this,n),m(f.WINDOW_RELOADED,{windowId:this.id,url:n,silent:!0})},{once:!0}),o.insertAdjacentElement("afterend",i),i.src=n}_spinReloadButton(){const t=this.element.querySelector(".os-window__btn--reload");t instanceof HTMLElement&&(t.classList.remove("os-window__btn--spinning"),t.offsetWidth,t.classList.add("os-window__btn--spinning"),t.addEventListener("animationend",()=>{t.classList.remove("os-window__btn--spinning")},{once:!0}))}renderCustomTitleBarButtons(){const t=this.element.querySelector(".os-window__custom-buttons--left"),n=this.element.querySelector(".os-window__custom-buttons--right");if(!t||!n)return;t.innerHTML="",n.innerHTML="";const{left:o,right:i}=$r(this),s=(r,d)=>{for(const a of d){const c=document.createElement("os-window-button");if(Zn(c,a.icon),c.setAttribute("aria-label",a.label),c.setAttribute("title",a.label),c.classList.add("os-window__btn"),c.classList.add("os-window__btn--custom"),c.dataset.buttonId=a.id,r.appendChild(c),typeof a.render=="function")try{a.render(c,this)}catch(l){typeof console<"u"&&console.error("[openstation] title-bar-button render threw:",a.id,l)}else typeof a.onClick=="function"&&c.addEventListener("os-button-activate",l=>{try{a.onClick(this,l)}catch(u){typeof console<"u"&&console.error("[openstation] title-bar-button onClick threw:",a.id,u)}})}};s(t,o),s(n,i)}send(t,n){if(typeof t!="string"||t==="")return;const o=this.iframe??Vo(this.id);if(!o){Uo(this.id,t,n);return}const i=()=>{try{o.contentWindow?.postMessage({type:"os-window-send",channel:t,payload:n},Tt)}catch(s){typeof console<"u"&&console.error("[openstation] Window.send: postMessage failed",s)}};if(Ft(this.id)){i();return}Go(this.id,t,n,i)}on(t,n){return typeof t!="string"||t===""||typeof n!="function"?()=>{}:Ho(this.id,t,n)}markContentLoading(){Ie(this.id)}markContentLoaded(){$(this.id)}whenContentReady(){return Ft(this.id)?Promise.resolve():new Promise(t=>{const n=this.id,o=i=>{const s=i.detail;!s||s.windowId!==n||(document.removeEventListener("os-window-content-loaded",o),t())};document.addEventListener("os-window-content-loaded",o)})}markActivity(t,n={}){this._activityPhase=t,this._activityError=n.error??null,this._paintActivityIndicator()}_resetActivity(){this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activityCount=0,this._activityPhase="idle",this._activityError=null,this._paintActivityIndicator()}_deferNavigationCommit(t,n){this._clearDeferredNavigation(),this._deferredNavigationCommit=t,this._deferredNavigationTimer=window.setTimeout(()=>{this._deferredNavigationTimer=null,this._deferredNavigationCommit=null},n)}_commitDeferredNavigation(){const t=this._deferredNavigationCommit;this._clearDeferredNavigation(),!(!t||this._isDestroyed)&&t()}_clearDeferredNavigation(){this._deferredNavigationTimer!==null&&(window.clearTimeout(this._deferredNavigationTimer),this._deferredNavigationTimer=null),this._deferredNavigationCommit=null}_noteNavigationActivity(){this._navigationActivity="pending",this._navigationActivityTimer!==null&&window.clearTimeout(this._navigationActivityTimer),this._navigationActivityTimer=window.setTimeout(()=>{this._navigationActivityTimer=null,this._navigationActivity="none",this._resetActivity()},ae.NAVIGATION_ACTIVITY_TIMEOUT_MS)}_settleNavigationActivity(t=!1){const n=this._navigationActivity!=="none";return this._navigationActivity==="pending"&&(this._navigationActivity="settled",this._navigationActivityTimer!==null&&(window.clearTimeout(this._navigationActivityTimer),this._navigationActivityTimer=null),this._resetActivity(),this._finalizeActivitySettle(!0)),t&&(this._navigationActivity="none"),n}trackActivity(t){return this._markActivityStart(),t.then(n=>(this._markActivitySettled(!0),n),n=>{const o=n instanceof Error?n.message:String(n);throw this._markActivitySettled(!1,o),n})}_markActivityStart(){this._activityCount++,this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._activityCount===1&&(this._activityPhase="saving",this._activityError=null,this._activitySavingStartedAt=Date.now(),this._paintActivityIndicator())}_markActivitySettled(t,n){if(this._activityCount>0&&this._activityCount--,this._activityCount>0){!t&&n&&(this._activityError=n);return}const o=Date.now()-this._activitySavingStartedAt,i=ae.MIN_SAVING_DISPLAY_MS-o;if(i>0){this._activitySettleTimer!==null&&window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=window.setTimeout(()=>{this._activitySettleTimer=null,this._finalizeActivitySettle(t,n)},i);return}this._finalizeActivitySettle(t,n)}_finalizeActivitySettle(t,n){this._activityPhase=t&&!this._activityError?"saved":"failed",!t&&n&&(this._activityError=n),this._paintActivityIndicator(),this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activityPhase==="saved"&&(this._activityClearTimer=window.setTimeout(()=>{this._activityClearTimer=null,this._activityPhase="idle",this._activityError=null,this._paintActivityIndicator()},2200))}_paintActivityIndicator(){if(this._isDestroyed)return;const t=this._activityPhase;t==="idle"?this._titleBar.removeAttribute("data-os-activity"):this._titleBar.setAttribute("data-os-activity",t);const n=this._titleBar.querySelector(".os-window__activity-status");if(n){const i=t==="failed";n.setAttribute("role",i?"alert":"status"),n.setAttribute("aria-live",i?"assertive":"polite"),n.textContent=this._activityStatusText()}this._titleBar.querySelectorAll("[data-os-activity-indicator]").forEach(i=>{i.setAttribute("phase",t),this._activityError?i.setAttribute("error",this._activityError):i.removeAttribute("error")})}_activityStatusText(){switch(this._activityPhase){case"saved":return _("Saved");case"failed":return this._activityError?ie(_("Not saved. %s"),this._activityError):_("Not saved.");default:return""}}requestAttention(t,n={}){const o=Ke.filter("os/window-attention-requested",{windowId:this.id,mode:t,durationMs:n.durationMs,intensity:n.intensity},n);if(!o||o.cancel===!0)return;const i=o.mode??t,s={...n,durationMs:typeof o.durationMs=="number"?o.durationMs:n.durationMs,intensity:typeof o.intensity=="string"?o.intensity:n.intensity},r=T("os.window.attention",i,{windowId:this.id,opts:s}),d=window.wp,a=d?.os?.dock,c=d?.os?.taskbar;let l=!1;if(typeof a?.setAttention=="function"&&(a.setAttention(this.id,r,s),l=!0),typeof c?.setAttention=="function"&&(c.setAttention(this.id,r,s),l=!0),!l&&r!==null){this.setHighlight("persistent");const u=s.durationMs??4e3;u>0&&window.setTimeout(()=>{this.setHighlight(null)},u)}else!l&&r===null&&this.setHighlight(null)}shake(){if(T("os.window.shake",!0,{windowId:this.id})===!1)return;const n=this.element;n.classList.remove("os-window--shaking"),n.offsetWidth,n.classList.add("os-window--shaking");const o=()=>{n.classList.remove("os-window--shaking"),n.removeEventListener("animationend",o)};n.addEventListener("animationend",o)}setHighlight(t,n){const o=this.element;o&&(o.classList.remove("wp-window--highlight-preview","wp-window--highlight-persistent"),t==="preview"?o.classList.add("wp-window--highlight-preview"):t==="persistent"&&o.classList.add("wp-window--highlight-persistent"),n?.color?o.style.setProperty("--wp-window-highlight-color",n.color):t===null&&o.style.removeProperty("--wp-window-highlight-color"),m(f.WINDOW_HIGHLIGHT_CHANGED,{windowId:this.id,mode:t,color:n?.color}))}close(){if(!this._isDestroyed){if(this.config.native&&!this._suppressCloseFilter){if(T(f.NATIVE_WINDOW_BEFORE_CLOSE,!0,{windowId:this.id,config:this.config})===!1)return}else if(!this.config.native&&!this._suppressCloseFilter&&this._iframeBridgeReady&&this.iframe){if(this._closePending)return;this._closePending=!0;try{this.iframe.contentWindow?.postMessage({type:"os-bridge-beforeunload-query"},location.origin),this._iframeCloseTimeout=setTimeout(()=>{this._isDestroyed||(this._suppressCloseFilter=!0,this._closePending=!1,this.close())},500);return}catch{this._closePending=!1}}if(this._isDestroyed=!0,this._discardSwapBuffer(),this._clearDeferredNavigation(),this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._navigationActivityTimer!==null&&(window.clearTimeout(this._navigationActivityTimer),this._navigationActivityTimer=null),this._titleBarButtonsUnsubscribe&&(this._titleBarButtonsUnsubscribe(),this._titleBarButtonsUnsubscribe=null),this._windowThemesUnsubscribe&&(this._windowThemesUnsubscribe(),this._windowThemesUnsubscribe=null),this._windowControlsUnsubscribe&&(this._windowControlsUnsubscribe(),this._windowControlsUnsubscribe=null),this._windowSlotsUnsubscribe&&(this._windowSlotsUnsubscribe(),this._windowSlotsUnsubscribe=null),this._windowChromesUnsubscribe&&(this._windowChromesUnsubscribe(),this._windowChromesUnsubscribe=null),this._nativeRenderCtxDispose){try{this._nativeRenderCtxDispose()}catch(t){m(f.SHELL_ERROR,{scope:"native-window-ctx-dispose",id:this.id,error:t})}this._nativeRenderCtxDispose=null}this._bodyResizeObserver?.disconnect(),this._bodyResizeObserver=null,this._tabSpeculateTimer&&(window.clearTimeout(this._tabSpeculateTimer),this._tabSpeculateTimer=null),this._tabOverflowTeardown?.(),this._tabOverflowTeardown=null,Bo(this.id);try{this.config.onClose?.()}catch(t){m(f.SHELL_ERROR,{scope:"native-window-close",id:this.id,error:t})}this.onClose?.(this),this.element.classList.add("os-window--closing"),this._onCloseTransitionEnd=t=>{t.propertyName==="opacity"&&this._finalizeClose()},this.element.addEventListener("transitionend",this._onCloseTransitionEnd),this._closeSafetyNetTimer=setTimeout(()=>this._finalizeClose(),300)}}destroy(){if(!this._isFinalized){if(!this._isDestroyed){this._suppressCloseFilter=!0;try{this.close()}finally{this._suppressCloseFilter=!1}}this._finalizeClose()}}_finalizeClose(){if(!this._isFinalized){if(this._isFinalized=!0,this._closeSafetyNetTimer!==null&&(clearTimeout(this._closeSafetyNetTimer),this._closeSafetyNetTimer=null),this._iframeCloseTimeout!==null&&(clearTimeout(this._iframeCloseTimeout),this._iframeCloseTimeout=null),this._clearOpeningClassRemoval&&this._clearOpeningClassRemoval(),this._onCloseTransitionEnd&&(this.element.removeEventListener("transitionend",this._onCloseTransitionEnd),this._onCloseTransitionEnd=null),this._cancelGenieAnimation("minimize"),this._cancelGenieAnimation("restore"),this._windowControlsTeardown){try{this._windowControlsTeardown()}catch{}this._windowControlsTeardown=null}if(this._windowSlotsTeardown){try{this._windowSlotsTeardown()}catch{}this._windowSlotsTeardown=null}if(this._chromeHandle){try{this._chromeHandle.destroy()}catch{}this._chromeHandle=null}if(Kr(this),this._nativeRenderTeardown){try{this._nativeRenderTeardown()}catch(t){m(f.SHELL_ERROR,{scope:"native-window-teardown",id:this.id,error:t})}this._nativeRenderTeardown=null}window.removeEventListener("message",this._boundOnMessage),this._boundOnDocumentPointerDown&&document.removeEventListener("pointerdown",this._boundOnDocumentPointerDown,!0),this._unsubscribeWindowActions?.(),this._unsubscribeWindowActions=null,this.element.remove(),J()}}installBodyResizeObserver(){const t=this.element.querySelector(".os-window__body");if(!t||typeof ResizeObserver>"u")return null;const n=new ResizeObserver(o=>{const i=o[0];if(!i)return;const s=i.contentRect,r=Math.round(s.width),d=Math.round(s.height);try{this.config.onResize?.(r,d)}catch(a){m(f.SHELL_ERROR,{scope:"native-window-resize",id:this.id,error:a})}m(f.WINDOW_BODY_RESIZED,{windowId:this.id,width:r,height:d})});return n.observe(t),n}getSnapshot(){if(this.element.offsetParent===null){const n=o=>{const i=parseFloat(o);return Number.isFinite(i)?Math.round(i):0};return{id:this.id,x:n(this.element.style.left),y:n(this.element.style.top),width:n(this.element.style.width),height:n(this.element.style.height),state:this.state}}return{id:this.id,x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight,state:this.state}}getExternalTabCount(){return Js(this)}getExternalTabsSnapshot(){return er(this)}toggleActionsMenu(){bo(this)}closeActionsMenu(){V(this)}openActionsMenu(){wo(this)}};ae.NAVIGATION_ACTIVITY_TIMEOUT_MS=3e4,ae.MIN_SAVING_DISPLAY_MS=1200;let It=ae;function A(e,...t){return{__wpdHtml:!0,strings:e,values:t}}function qa(e){return!!e&&e.__wpdHtml===!0}const Va="$$wpd$$",L=/\$\$wpd\$\$(\d+)\$\$/g,Ka="$$wpd-node$$",ja=/^\$\$wpd-node\$\$(\d+)\$\$$/,Ya=new Set(["style","script","textarea","title"]);function Xa(e){let t="",n=!1,o=null,i=!1,s=null,r="",d=!1;for(let a=0;a<e.length;a++){const c=e[a];t+=c;for(let l=0;l<c.length;l++){const u=c[l];if(i){c.startsWith("-->",l)&&(i=!1,l+=2);continue}if(s!==null){u==="<"&&c[l+1]==="/"&&c.slice(l+2,l+2+s.length).toLowerCase()===s&&(l+=1+s.length,s=null,n=!0,d=!1,r="");continue}if(o!==null){u===o&&(o=null);continue}if(n){u==='"'||u==="'"?(o=u,d=!1):u===">"?(n=!1,d=!1,Ya.has(r)&&(s=r),r=""):d&&(/[a-zA-Z0-9-]/.test(u)?r+=u.toLowerCase():d=!1);continue}if(c.startsWith("<!--",l)){i=!0,l+=3;continue}const p=c[l+1]??"";u==="<"&&/[a-zA-Z/!]/.test(p)&&(n=!0,r="",d=/[a-zA-Z]/.test(p))}a<e.length-1&&(t+=n||i||s!==null?`${Va}${a}$$`:`<!--${Ka}${a}$$-->`)}return t}const So=new WeakMap;function Co(e){const t=So.get(e);if(t)return t;const n=document.createElement("template");n.innerHTML=Xa(e);const o=[],i=(d,a)=>{if(d.nodeType===Node.ELEMENT_NODE){const u=d;for(const p of Array.from(u.attributes)){const g=p.name,b=p.value,y=g[0];if(L.test(b))if(L.lastIndex=0,y==="@"){const w=L.exec(b);L.lastIndex=0,o.push({path:a,kind:"event",name:g.slice(1),valueIndex:w?Number(w[1]):0}),u.removeAttribute(g)}else if(y==="."){const w=L.exec(b);L.lastIndex=0,o.push({path:a,kind:"prop",name:g.slice(1),valueIndex:w?Number(w[1]):0}),u.removeAttribute(g)}else if(y==="?"){const w=L.exec(b);L.lastIndex=0,o.push({path:a,kind:"bool",name:g.slice(1),valueIndex:w?Number(w[1]):0}),u.removeAttribute(g)}else{const w=[],S=[];let E=0,C;for(L.lastIndex=0;(C=L.exec(b))!==null;)w.push(b.slice(E,C.index)),S.push(Number(C[1])),E=C.index+C[0].length;w.push(b.slice(E)),o.push({path:a,kind:"attr",name:g,template:w,valueIndices:S}),u.setAttribute(g,"")}}}const c=Array.from(d.childNodes);let l=0;for(let u=0;u<c.length;u++){const p=c[u],g=u+l;if(p.nodeType===Node.COMMENT_NODE){const b=ja.exec(p.data);if(b){const y=document.createTextNode("");p.parentNode.replaceChild(y,p),o.push({path:[...a,g],kind:"node",valueIndex:Number(b[1])})}continue}if(p.nodeType===Node.TEXT_NODE){const b=p.textContent||"";if(!L.test(b)){L.lastIndex=0;continue}L.lastIndex=0;const y=p.parentNode;let w=0,S;const E=[],C=[];for(L.lastIndex=0;(S=L.exec(b))!==null;){S.index>w&&E.push(document.createTextNode(b.slice(w,S.index)));const N=document.createTextNode("");E.push(N),C.push({path:[...a,g+E.length-1],kind:"node",valueIndex:Number(S[1])}),w=S.index+S[0].length}w<b.length&&E.push(document.createTextNode(b.slice(w)));for(const N of E)y.insertBefore(N,p);y.removeChild(p),l+=E.length-1,o.push(...C)}else i(p,[...a,g])}};i(n.content,[]);const r={template:n,buildParts:d=>{const a=[];for(const c of o){let l=d;for(const u of c.path)l=l.childNodes[u];c.kind==="node"?a.push({kind:"node",valueIndex:c.valueIndex,child:{anchor:l,state:null}}):c.kind==="attr"?a.push({kind:"attr",element:l,name:c.name,template:c.template,valueIndices:c.valueIndices}):c.kind==="event"?a.push({kind:"event",valueIndex:c.valueIndex,element:l,name:c.name}):c.kind==="prop"?a.push({kind:"prop",valueIndex:c.valueIndex,element:l,name:c.name}):c.kind==="bool"&&a.push({kind:"bool",valueIndex:c.valueIndex,element:l,name:c.name})}return a}};return So.set(e,r),r}const ko=new WeakMap;function Za(e,t){for(const n of e.nodes)if(n.parentNode!==t)return!1;return!0}function Qa(e,t){const n=ko.get(t);if(n&&n.strings===e.strings&&Za(n,t)){He(n.parts,e.values);return}const o=Co(e.strings),i=o.template.content.cloneNode(!0),s=o.buildParts(i),r=Array.from(i.childNodes);for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(i),He(s,e.values),ko.set(t,{strings:e.strings,parts:s,nodes:r})}function He(e,t){for(const n of e)if(n.kind==="node")Fe(n.child,t[n.valueIndex]);else if(n.kind==="attr"){let o=n.template[0];for(let i=0;i<n.valueIndices.length;i++)o+=xo(t[n.valueIndices[i]]),o+=n.template[i+1];o!==n.last&&(n.last=o,o===""?n.element.removeAttribute(n.name):n.element.setAttribute(n.name,o))}else if(n.kind==="event"){const o=t[n.valueIndex];o!==n.current&&(n.current&&n.element.removeEventListener(n.name,n.current),o&&n.element.addEventListener(n.name,o),n.current=o)}else if(n.kind==="prop"){const o=t[n.valueIndex];o!==n.last&&(n.last=o,n.element[n.name]=o)}else if(n.kind==="bool"){const o=!!t[n.valueIndex];o!==n.last&&(n.last=o,o?n.element.setAttribute(n.name,""):n.element.removeAttribute(n.name))}}function Fe(e,t){if(t==null||t===!1){e.state&&(te(e.state),e.state=null);return}if(Array.isArray(t)){nl(e,t);return}if(qa(t)){tl(e,t);return}if(t instanceof Node){Ja(e,t);return}el(e,xo(t))}function Ja(e,t){const n=e.state;n?.shape==="node"&&n.node===t||(n&&te(n),_e(e,[t]),e.state={shape:"node",node:t})}function el(e,t){const n=e.state;if(n?.shape==="text"){n.text!==t&&(n.node.textContent=t,n.text=t);return}n&&te(n);const o=document.createTextNode(t);_e(e,[o]),e.state={shape:"text",node:o,text:t}}function tl(e,t){const n=e.state;if(n?.shape==="template"&&n.strings===t.strings){He(n.parts,t.values);return}n&&te(n);const o=Co(t.strings),i=o.template.content.cloneNode(!0),s=o.buildParts(i),r=Array.from(i.childNodes);_e(e,[i]),He(s,t.values),e.state={shape:"template",strings:t.strings,parts:s,nodes:r}}function nl(e,t){const n=e.state;if(n?.shape==="array"){const i=Math.min(n.entries.length,t.length);for(let s=0;s<i;s++)Fe(n.entries[s],t[s]);if(t.length<n.entries.length){for(let s=t.length;s<n.entries.length;s++){const r=n.entries[s];r.state&&te(r.state),r.anchor.remove()}n.entries.length=t.length}else for(let s=n.entries.length;s<t.length;s++){const r=document.createTextNode("");_e(e,[r]);const d={anchor:r,state:null};Fe(d,t[s]),n.entries.push(d)}return}n&&te(n);const o=[];for(const i of t){const s=document.createTextNode("");_e(e,[s]);const r={anchor:s,state:null};Fe(r,i),o.push(r)}e.state={shape:"array",entries:o}}function _e(e,t){const n=e.anchor.parentNode;if(n)for(const o of t)n.insertBefore(o,e.anchor)}function te(e){if(e.shape==="text"){e.node.remove();return}if(e.shape==="template"){for(const t of e.parts)t.kind==="node"&&t.child.state&&(te(t.child.state),t.child.state=null);for(const t of e.nodes)t.parentNode&&t.parentNode.removeChild(t);return}if(e.shape==="node"){e.node.parentNode&&e.node.parentNode.removeChild(e.node);return}for(const t of e.entries)t.state&&te(t.state),t.anchor.remove()}function xo(e){return e==null||e===!1?"":String(e)}const ne=class ne 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(To)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(t,n,o){if(n===o)return;const i=ol(t);this._propValues[i]=o,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(t){if(t==null){this.removeAttribute("class");return}const o=(Array.isArray(t)?t:String(t).split(/\s+/)).map(i=>String(i).trim()).filter(i=>i!=="");this.className=o.join(" ")}requestUpdate(){this._scheduleRender()}emit(t,n){return this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0}))}_installPropAccessors(){const t=this.constructor;for(const n of t.props){if(Object.getOwnPropertyDescriptor(this,n))continue;const o=To(n);Object.defineProperty(this,n,{get:()=>n in this._propValues?this._propValues[n]:this.getAttribute(o),set:i=>{let s;i==null||i===!1?s=null:i===!0?s="":s=String(i),this._propValues[n]=s,s===null?this.removeAttribute(o):this.setAttribute(o,s),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&Qa(this.render(),this._renderRoot)}))}_adoptStyles(){const t=this.constructor;if(t.styles.length!==0)if(t.shadow&&this.shadowRoot){const n=t.styles.map(o=>o.sheet).filter(o=>o!==null);if(this.shadowRoot.adoptedStyleSheets=n,n.length!==t.styles.length){for(const o of t.styles)if(!o.sheet){const i=document.createElement("style");i.textContent=o.cssText,this.shadowRoot.appendChild(i)}}}else this._adoptLightStyles(t)}_adoptLightStyles(t){if(!ne._lightStylesAdopted.has(t)){ne._lightStylesAdopted.add(t);for(const n of t.styles){const o=document.createElement("style");o.dataset.osUi=this.tagName.toLowerCase(),o.textContent=n.cssText,document.head.appendChild(o)}}}};ne.props=[],ne.styles=[],ne.shadow=!0,ne._lightStylesAdopted=new WeakSet;let K=ne;function oe(e,t){customElements.get(e)||customElements.define(e,t)}function To(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function ol(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}const il=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function x(e,...t){let n=e[0];for(let o=1;o<e.length;o++){const i=t[o-1];if(typeof i=="string"||typeof i=="number")n+=String(i);else if(i&&i.__wpdCss)n+=i.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof i);n+=e[o]}if(il){const o=new CSSStyleSheet;return o.replaceSync(n),{__wpdCss:!0,sheet:o,cssText:n}}return{__wpdCss:!0,sheet:null,cssText:n}}const sl=x`:host{display:inline-flex}button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:none;border-radius:var( --os-ui-btn-radius,5px );background-color:var( --os-ui-btn-bg,transparent );background-image:var( --os-ui-btn-bg-image,none );background-repeat:var( --os-ui-btn-bg-image-repeat,no-repeat );background-size:var( --os-ui-btn-bg-image-size,auto );background-position:var( --os-ui-btn-bg-image-position,center );color:var( --os-ui-btn-color,currentColor );cursor:pointer;transition:background-color 0.15s ease,color 0.15s ease,transform 80ms ease}button:active:not(:disabled){transform:scale( 0.9 )}@media ( prefers-reduced-motion:reduce ){button:active:not(:disabled){transform:none}}button:disabled{opacity:0.5;cursor:default}button:hover:not(:disabled){color:var( --os-ui-btn-color-hover,currentColor );background-color:var( --os-ui-btn-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) )}button:focus-visible{color:var( --os-ui-btn-color-hover,currentColor );background-color:var( --os-ui-btn-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) );outline:2px solid var( --os-ui-btn-outline,currentColor );outline-offset:1px}:host( [ active ] ) button{color:var( --os-ui-btn-color-hover,currentColor );background-color:var( --os-ui-btn-bg-active,var( --os-ui-hover,rgba( 0,0,0,0.08 ) ) )}:host( [ danger ] ) button:hover{color:var( --os-ui-fg-on-accent,#fff );background-color:var( --os-ui-btn-danger-hover,var( --os-ui-danger,#d63638 ) )}svg{display:block;pointer-events:none;flex-shrink:0}svg:empty{display:none}.themed-icon{display:block;width:14px;height:14px;flex-shrink:0;pointer-events:none;background-color:var( --os-ui-btn-icon-color,currentColor )}::slotted( span ){line-height:1}::slotted( svg ){display:block}`,rl={minimize:'<path d="M3 6h6" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>',maximize:'<rect x="3" y="3" width="6" height="6" rx="1" stroke="currentColor" stroke-width="1.25" fill="none"/>',fullscreen:'<path d="M4.5 2H2v2.5M10 4.5V2H7.5M4.5 10H2V7.5M10 7.5V10H7.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',"fullscreen-exit":'<path d="M2 4.5H4.5V2M7.5 2V4.5H10M2 7.5H4.5V10M7.5 10V7.5H10" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',detach:'<path d="M5 2H2.5v7.5H10V7M6.5 2H10v3.5M10 2L5.5 6.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',reload:'<g transform="translate(0.6 0.6) scale(0.021)" fill="currentColor"><path d="m504.554 233.704-76.447 91.467c-6.329 7.572-15.417 11.479-24.571 11.479a31.872 31.872 0 0 1-20.504-7.447l-91.467-76.447c-13.561-11.334-15.366-31.515-4.032-45.075s31.515-15.366 45.075-4.032l37.506 31.347c-10.274-74.891-74.668-132.774-152.337-132.774C132.984 102.223 64 171.207 64 256s68.984 153.777 153.777 153.777c17.673 0 32 14.327 32 32s-14.327 32-32 32c-58.17 0-112.859-22.653-153.991-63.785C22.653 368.859 0 314.17 0 256s22.653-112.859 63.786-153.992c41.132-41.132 95.821-63.785 153.991-63.785s112.859 22.653 153.992 63.785c32.517 32.516 53.471 73.508 60.829 117.991l22.849-27.339c11.334-13.56 31.515-15.364 45.075-4.032 13.56 11.335 15.365 31.516 4.032 45.076z"/></g>',close:'<path d="M3.25 3.25l5.5 5.5M3.25 8.75l5.5-5.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>',menu:'<circle cx="3" cy="6" r="1.2" fill="currentColor"/><circle cx="6" cy="6" r="1.2" fill="currentColor"/><circle cx="9" cy="6" r="1.2" fill="currentColor"/>'};function al(e){const t=(e??"").trim();return t===""||t.length>4096||!/^(https?:\/\/|data:image\/)/i.test(t)||/['"()\\<>\s]/.test(t)?"":t}const be=class be extends K{constructor(){super(...arguments),this._activateWired=!1}static get observedAttributes(){return[...super.observedAttributes,"aria-label","aria-pressed"]}render(){const t=al(this["icon-src"]||this.getAttribute("icon-src")||""),n=t?"":this.icon||"",o=rl[n]||"",i=this.getAttribute("aria-label")||"";return t?A`
2 + <button type="button" aria-label="${i}" aria-pressed="${this.getAttribute("aria-pressed")||""}" ?disabled="${this.hasAttribute("disabled")}">
3 3 <span
4 4 class="themed-icon"
5 5 aria-hidden="true"
6 6 style="-webkit-mask: url('${t}') center / contain no-repeat; mask: url('${t}') center / contain no-repeat;"
@@ -7,9 +7,9 @@
7 7 ></span>
8 8 <slot></slot>
9 9 </button>
10 10 `:A`
11 - <button type="button">
11 + <button type="button" aria-label="${i}" aria-pressed="${this.getAttribute("aria-pressed")||""}" ?disabled="${this.hasAttribute("disabled")}">
12 12 <svg
13 13 width="14"
14 14 height="14"
15 15 viewBox="0 0 12 12"
@@ -18,18 +18,18 @@
18 18 ></svg>
19 19 <slot></slot>
20 20 </button>
21 21 <span data-svg-buffer style="display:none">${o}</span>
22 - `}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>this._paintSvg()),queueMicrotask(()=>this._wireActivateEvent())}attributeChangedCallback(t,n,o){super.attributeChangedCallback(t,n,o),queueMicrotask(()=>this._paintSvg())}_paintSvg(){const t=this.shadowRoot;if(!t)return;const n=t.querySelector("svg"),o=t.querySelector("[data-svg-buffer]");if(n&&o){const s=o.textContent||"";n.innerHTML!==s&&(n.innerHTML=s)}}_wireActivateEvent(){if(this._activateWired)return;const t=this.shadowRoot;if(!t)return;const n=t.querySelector("button");n&&(this._activateWired=!0,n.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("wpd-button-activate",{bubbles:!0,composed:!0,cancelable:!0}))}))}};re.props=["icon","icon-src","active","danger"],re.styles=[Qi],re.help=void 0;let at=re;Y("wpd-window-button",at);const tr=Z`:host{display:inline-flex;align-items:center;gap:6px;font-size:var( --wpd-save-status-font-size,11px );line-height:1;color:var( --wpd-save-status-fg,currentColor );vertical-align:middle;min-width:0;opacity:1;pointer-events:auto}.wpd-save-status__indicator{display:inline-flex;align-items:center;justify-content:center;width:12px;height:12px;border-radius:50%;flex-shrink:0;box-sizing:border-box;background:var( --wpd-save-status-bg,transparent );border:2px solid var( --wpd-save-status-idle-color,color-mix( in srgb,var( --wp-admin-theme-color,#2271b1 ) 55%,transparent ) );color:var( --wp-admin-theme-color,#2271b1 );transition:background-color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease}:host( [ phase='pending' ] ) .wpd-save-status__indicator,:host( [ phase='saving' ] ) .wpd-save-status__indicator{background:var( --wpd-save-status-bg,var( --wp-admin-theme-color,#2271b1 ) );border-color:transparent;color:var( --wp-admin-theme-color,#2271b1 );animation:wpd-save-status-pulse 1.2s ease-in-out infinite}:host( [ animation='modem' ][ phase='pending' ] ) .wpd-save-status__indicator,:host( [ animation='modem' ][ phase='saving' ] ) .wpd-save-status__indicator{background:var( --wpd-save-status-bg,var( --wp-admin-theme-color,#2271b1 ) );border-color:transparent;color:var( --wp-admin-theme-color,#2271b1 );animation:wpd-save-status-modem-stutter 1.8s ease-in-out infinite,wpd-save-status-modem-glow 2.4s ease-in-out infinite}@keyframes wpd-save-status-modem-stutter{0%,4%{opacity:1}5%,30%{opacity:0.22}31%,36%{opacity:1}37%,39%{opacity:0.22}40%,44%{opacity:1}45%,67%{opacity:0.22}68%,76%{opacity:1}77%,100%{opacity:0.22}}@keyframes wpd-save-status-modem-glow{0%,12%{box-shadow:0 0 0 0 transparent}13%,22%{box-shadow:0 0 4px 0 currentColor}23%,50%{box-shadow:0 0 0 0 transparent}51%,58%{box-shadow:0 0 4px 0 currentColor}59%,84%{box-shadow:0 0 0 0 transparent}85%,94%{box-shadow:0 0 5px 0 currentColor}95%,100%{box-shadow:0 0 0 0 transparent}}@media ( prefers-reduced-motion:reduce ){:host( [ phase='pending' ] ) .wpd-save-status__indicator,:host( [ phase='saving' ] ) .wpd-save-status__indicator,:host( [ animation='modem' ][ phase='pending' ] ) .wpd-save-status__indicator,:host( [ animation='modem' ][ phase='saving' ] ) .wpd-save-status__indicator{animation:none;opacity:0.85}}:host( [ phase='saved' ] ) .wpd-save-status__indicator{background:var( --wpd-save-status-saved-bg,var( --wpd-surface,#1d6f42 ) );border-color:transparent;color:var( --wpd-save-status-saved-bg,var( --wpd-success-fg,#1d6f42 ) )}:host( [ phase='failed' ] ) .wpd-save-status__indicator{background:var( --wpd-save-status-failed-bg,var( --wpd-surface,#d63638 ) );border-color:transparent;color:var( --wpd-save-status-failed-bg,var( --wpd-danger,#d63638 ) );animation:wpd-save-status-pulse 0.8s ease-in-out 2}@keyframes wpd-save-status-pulse{0%,100%{opacity:0.55;transform:scale( 0.9 )}50%{opacity:1;transform:scale( 1 )}}:host( [ mode='pill' ] ) .wpd-save-status{display:inline-flex;align-items:center;gap:6px;padding:2px 10px;border-radius:999px;background:var( --wpd-save-status-pill-bg,transparent );font-weight:500;white-space:nowrap}:host( [ mode='pill' ][ phase='saving' ] ) .wpd-save-status,:host( [ mode='pill' ][ phase='pending' ] ) .wpd-save-status{background:var( --wpd-save-status-pill-bg,var( --wpd-hover,rgba( 0,0,0,0.04 ) ) );color:var( --wpd-save-status-pill-fg,var( --wpd-fg-muted,#50575e ) )}:host( [ mode='pill' ][ phase='saved' ] ) .wpd-save-status{background:var( --wpd-save-status-pill-bg,rgba( 30,132,73,0.12 ) );color:var( --wpd-save-status-pill-fg,var( --wpd-success-fg,#1d6f42 ) )}:host( [ mode='pill' ][ phase='failed' ] ) .wpd-save-status{background:var( --wpd-save-status-pill-bg,rgba( 214,54,56,0.12 ) );color:var( --wpd-save-status-pill-fg,var( --wpd-danger-hover,#a02622 ) )}.wpd-save-status__label{min-width:0;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host( [ phase='saved' ] ) .wpd-save-status__glyph,:host( [ phase='failed' ] ) .wpd-save-status__glyph{display:inline-block;color:var( --wpd-fg-on-accent,#fff );width:8px;height:8px}.wpd-save-status__glyph{display:none}.wpd-save-status__glyph svg{display:block;width:100%;height:100%}`,Un="desktop-mode-os-settings-save-lifecycle",nr=2200,or=6e3,ae=class ae extends z{constructor(){super(...arguments),this._autoTimer=null,this._docListener=null}connectedCallback(){super.connectedCallback(),this.auto!==null&&this._installAutoListener()}disconnectedCallback(){this._removeAutoListener(),this._autoTimer!==null&&(window.clearTimeout(this._autoTimer),this._autoTimer=null)}attributeChangedCallback(t,n,o){if(super.attributeChangedCallback(t,n,o),(t==="auto"||t==="event")&&(this._removeAutoListener(),this.auto!==null&&this._installAutoListener()),t==="phase"){this._scheduleAutoClear();const s={phase:this.phase??"idle",error:this.error??void 0};this.emit("wpd-save-status-change",s)}}render(){const t=this.phase??"idle",n=this.mode??"dot",s=(this.error??"")||this._labelForPhase(t);return s?this.setAttribute("title",s):this.removeAttribute("title"),this.setAttribute("aria-live",t==="failed"?"assertive":"polite"),this.setAttribute("role",t==="failed"?"alert":"status"),A`
23 - <span class="wpd-save-status">
24 - <span class="wpd-save-status__indicator" aria-hidden="true">
25 - <span class="wpd-save-status__glyph">${this._renderGlyph(t)}</span>
22 + `}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>this._paintSvg()),queueMicrotask(()=>this._wireActivateEvent())}attributeChangedCallback(t,n,o){super.attributeChangedCallback(t,n,o),queueMicrotask(()=>this._paintSvg())}_paintSvg(){const t=this.shadowRoot;if(!t)return;const n=t.querySelector("svg"),o=t.querySelector("[data-svg-buffer]");if(n&&o){const i=o.textContent||"";n.innerHTML!==i&&(n.innerHTML=i)}}_wireActivateEvent(){if(this._activateWired)return;const t=this.shadowRoot;if(!t)return;const n=t.querySelector("button");n&&(this._activateWired=!0,n.addEventListener("click",()=>{this.hasAttribute("disabled")||this.dispatchEvent(new CustomEvent("os-button-activate",{bubbles:!0,composed:!0,cancelable:!0}))}))}};be.props=["icon","icon-src","active","danger","disabled"],be.styles=[sl],be.help=void 0;let Lt=be;oe("os-window-button",Lt);const ll=x`:host{display:inline-flex;align-items:center;gap:6px;font-size:var( --os-ui-save-status-font-size,11px );line-height:1;color:var( --os-ui-save-status-fg,currentColor );vertical-align:middle;min-width:0;opacity:1;pointer-events:auto}.os-save-status__indicator{display:inline-flex;align-items:center;justify-content:center;width:var( --os-ui-save-status-size,12px );height:var( --os-ui-save-status-size,12px );border-radius:50%;flex-shrink:0;box-sizing:border-box;background:var( --os-ui-save-status-bg,transparent );border:2px solid var( --os-ui-save-status-idle-color,color-mix( in srgb,var( --wp-admin-theme-color,#2271b1 ) 55%,transparent ) );color:var( --wp-admin-theme-color,#2271b1 );transition:background-color 0.2s ease,border-color 0.2s ease,box-shadow 0.2s ease}:host( [ phase='pending' ] ) .os-save-status__indicator,:host( [ phase='saving' ] ) .os-save-status__indicator{background:var( --os-ui-save-status-bg,var( --wp-admin-theme-color,#2271b1 ) );border-color:transparent;color:var( --wp-admin-theme-color,#2271b1 );animation:os-save-status-pulse 1.2s ease-in-out infinite}:host( [ animation='modem' ][ phase='pending' ] ) .os-save-status__indicator,:host( [ animation='modem' ][ phase='saving' ] ) .os-save-status__indicator{background:var( --os-ui-save-status-bg,var( --wp-admin-theme-color,#2271b1 ) );border-color:transparent;color:var( --wp-admin-theme-color,#2271b1 );animation:os-save-status-modem-stutter 1.8s ease-in-out infinite,os-save-status-modem-glow 2.4s ease-in-out infinite}@keyframes os-save-status-modem-stutter{0%,4%{opacity:1}5%,30%{opacity:0.22}31%,36%{opacity:1}37%,39%{opacity:0.22}40%,44%{opacity:1}45%,67%{opacity:0.22}68%,76%{opacity:1}77%,100%{opacity:0.22}}@keyframes os-save-status-modem-glow{0%,12%{box-shadow:0 0 0 0 transparent}13%,22%{box-shadow:0 0 4px 0 currentColor}23%,50%{box-shadow:0 0 0 0 transparent}51%,58%{box-shadow:0 0 4px 0 currentColor}59%,84%{box-shadow:0 0 0 0 transparent}85%,94%{box-shadow:0 0 5px 0 currentColor}95%,100%{box-shadow:0 0 0 0 transparent}}@media ( prefers-reduced-motion:reduce ){:host( [ phase='pending' ] ) .os-save-status__indicator,:host( [ phase='saving' ] ) .os-save-status__indicator,:host( [ animation='modem' ][ phase='pending' ] ) .os-save-status__indicator,:host( [ animation='modem' ][ phase='saving' ] ) .os-save-status__indicator{animation:none;opacity:0.85}}:host( [ phase='saved' ] ) .os-save-status__indicator{background:var( --os-ui-save-status-saved-bg,var( --os-ui-success-fg,#1d6f42 ) );border-color:transparent;color:var( --os-ui-save-status-saved-bg,var( --os-ui-success-fg,#1d6f42 ) )}:host( [ phase='failed' ] ) .os-save-status__indicator{background:var( --os-ui-save-status-failed-bg,var( --os-ui-danger,#d63638 ) );border-color:transparent;color:var( --os-ui-save-status-failed-bg,var( --os-ui-danger,#d63638 ) );animation:os-save-status-pulse 0.8s ease-in-out 2}:host( [ variant='ring' ] ) .os-save-status__indicator{background:transparent}:host( [ variant='ring' ][ phase='pending' ] ) .os-save-status__indicator,:host( [ variant='ring' ][ phase='saving' ] ) .os-save-status__indicator{background:transparent;border-color:var( --os-ui-save-status-ring-color,var( --os-ui-save-status-bg,var( --wp-admin-theme-color,#2271b1 ) ) );animation:os-save-status-ring-pulse 1.6s var( --os-ui-ease-loop,ease-in-out ) infinite}:host( [ variant='ring' ][ phase='failed' ] ) .os-save-status__indicator{background:transparent;border-color:var( --os-ui-save-status-failed-bg,var( --os-ui-danger,#d63638 ) );animation:os-save-status-ring-alert 0.62s var( --os-ui-ease-out,ease-out ) 1}:host( [ variant='ring' ][ phase='failed' ] ) .os-save-status__glyph{color:var( --os-ui-save-status-failed-bg,var( --os-ui-danger,#d63638 ) )}:host( [ variant='ring' ][ phase='saved' ] ) .os-save-status__indicator{background:var( --os-ui-save-status-saved-bg,var( --wp-admin-theme-color,#2271b1 ) );border-color:transparent;animation:os-save-status-ring-land 0.42s var( --os-ui-ease-out,ease-out ) 1}:host( [ variant='ring' ][ phase='saved' ] ) .os-save-status__glyph,:host( [ variant='ring' ][ phase='failed' ] ) .os-save-status__glyph{animation:os-save-status-glyph-in 0.24s var( --os-ui-ease-out,ease-out ) 0.08s 1 backwards}@keyframes os-save-status-ring-pulse{0%,100%{opacity:0.45;scale:0.9}50%{opacity:1;scale:1}}@keyframes os-save-status-ring-land{0%{scale:0.82}55%{scale:1.06}100%{scale:1}}@keyframes os-save-status-ring-alert{0%{scale:0.9}25%{scale:1.08}50%{scale:0.98}75%{scale:1.04}100%{scale:1}}@keyframes os-save-status-glyph-in{0%{opacity:0;scale:0.4}100%{opacity:1;scale:1}}@media ( prefers-reduced-motion:reduce ){:host( [ variant='ring' ] ) .os-save-status__indicator,:host( [ variant='ring' ] ) .os-save-status__glyph{animation:none;opacity:1;scale:1}}@keyframes os-save-status-pulse{0%,100%{opacity:0.55;transform:scale( 0.9 )}50%{opacity:1;transform:scale( 1 )}}:host( [ mode='pill' ] ) .os-save-status{display:inline-flex;align-items:center;gap:6px;padding:2px 10px;border-radius:999px;background:var( --os-ui-save-status-pill-bg,transparent );font-weight:500;white-space:nowrap}:host( [ mode='pill' ][ phase='saving' ] ) .os-save-status,:host( [ mode='pill' ][ phase='pending' ] ) .os-save-status{background:var( --os-ui-save-status-pill-bg,var( --os-ui-hover,rgba( 0,0,0,0.04 ) ) );color:var( --os-ui-save-status-pill-fg,var( --os-ui-fg-muted,#50575e ) )}:host( [ mode='pill' ][ phase='saved' ] ) .os-save-status{background:var( --os-ui-save-status-pill-bg,rgba( 30,132,73,0.12 ) );color:var( --os-ui-save-status-pill-fg,var( --os-ui-success-fg,#1d6f42 ) )}:host( [ mode='pill' ][ phase='failed' ] ) .os-save-status{background:var( --os-ui-save-status-pill-bg,rgba( 214,54,56,0.12 ) );color:var( --os-ui-save-status-pill-fg,var( --os-ui-danger-hover,#a02622 ) )}.os-save-status__label{min-width:0;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host( [ phase='saved' ] ) .os-save-status__glyph,:host( [ phase='failed' ] ) .os-save-status__glyph{display:inline-block;color:var( --os-ui-fg-on-accent,#fff );width:calc( var( --os-ui-save-status-size,12px ) * 0.66 );height:calc( var( --os-ui-save-status-size,12px ) * 0.66 )}.os-save-status__glyph{display:none}.os-save-status__glyph svg{display:block;width:100%;height:100%}`,Io="os-settings-save-lifecycle",cl=2200,dl=6e3,we=class we extends K{constructor(){super(...arguments),this._autoTimer=null,this._docListener=null}connectedCallback(){super.connectedCallback(),this.auto!==null&&this._installAutoListener()}disconnectedCallback(){this._removeAutoListener(),this._autoTimer!==null&&(window.clearTimeout(this._autoTimer),this._autoTimer=null)}attributeChangedCallback(t,n,o){if(super.attributeChangedCallback(t,n,o),(t==="auto"||t==="event")&&(this._removeAutoListener(),this.auto!==null&&this._installAutoListener()),t==="phase"){this._scheduleAutoClear();const i={phase:this.phase??"idle",error:this.error??void 0};this.emit("os-save-status-change",i)}}render(){const t=this.phase??"idle",n=this.mode??"dot",i=(this.error??"")||this._labelForPhase(t);return i?this.setAttribute("title",i):this.removeAttribute("title"),this.setAttribute("aria-live",t==="failed"?"assertive":"polite"),this.setAttribute("role",t==="failed"?"alert":"status"),A`
23 + <span class="os-save-status">
24 + <span class="os-save-status__indicator" aria-hidden="true">
25 + <span class="os-save-status__glyph">${this._renderGlyph(t)}</span>
26 26 </span>
27 - ${n==="pill"?A`<span class="wpd-save-status__label"
27 + ${n==="pill"?A`<span class="os-save-status__label"
28 28 >${this._labelForPhase(t)}</span
29 29 >`:A``}
30 30 </span>
31 - `}_renderGlyph(t){return t==="saved"?sr():t==="failed"?ir():""}_labelForPhase(t){switch(t){case"pending":case"saving":return this["saving-label"]??"Saving…";case"saved":return this["saved-label"]??"Saved";case"failed":return(this.error??"")||"Couldn’t save";default:return this["idle-label"]??""}}_installAutoListener(){const t=this.event||Un;this._docListener=n=>{const o=n.detail;!o||typeof o.phase!="string"||(this.phase=o.phase,o.error?this.error=o.error:o.phase!=="failed"&&this.error&&this.removeAttribute("error"))},document.addEventListener(t,this._docListener)}_removeAutoListener(){if(!this._docListener)return;const t=this.event||Un;document.removeEventListener(t,this._docListener),this._docListener=null}_scheduleAutoClear(){this._autoTimer!==null&&(window.clearTimeout(this._autoTimer),this._autoTimer=null);const t=this.phase??"idle",n=this._autoClearMsFor(t);n<=0||(this._autoTimer=window.setTimeout(()=>{this._autoTimer=null,this.phase="idle"},n))}_autoClearMsFor(t){if(t==="saved"){const n=this["auto-clear-saved-ms"];return parseInt(n||"",10)||nr}if(t==="failed"){const n=this["auto-clear-failed-ms"];return parseInt(n||"",10)||or}return 0}};ae.props=["phase","mode","animation","auto","event","error","saving-label","saved-label","idle-label","auto-clear-saved-ms","auto-clear-failed-ms"],ae.styles=[tr],ae.help=void 0;let dt=ae;Y("wpd-save-status",dt);function sr(){return A`
31 + `}_renderGlyph(t){return t==="saved"?ul():t==="failed"?hl():""}_labelForPhase(t){switch(t){case"pending":case"saving":return this["saving-label"]??"Saving…";case"saved":return this["saved-label"]??"Saved";case"failed":return(this.error??"")||"Couldn’t save";default:return this["idle-label"]??""}}_installAutoListener(){const t=this.event||Io;this._docListener=n=>{const o=n.detail;!o||typeof o.phase!="string"||(this.phase=o.phase,o.error?this.error=o.error:o.phase!=="failed"&&this.error&&this.removeAttribute("error"))},document.addEventListener(t,this._docListener)}_removeAutoListener(){if(!this._docListener)return;const t=this.event||Io;document.removeEventListener(t,this._docListener),this._docListener=null}_scheduleAutoClear(){this._autoTimer!==null&&(window.clearTimeout(this._autoTimer),this._autoTimer=null);const t=this.phase??"idle",n=this._autoClearMsFor(t);n<=0||(this._autoTimer=window.setTimeout(()=>{this._autoTimer=null,this.phase="idle"},n))}_autoClearMsFor(t){if(t==="saved"){const n=this["auto-clear-saved-ms"];return parseInt(n||"",10)||cl}if(t==="failed"){const n=this["auto-clear-failed-ms"];return parseInt(n||"",10)||dl}return 0}};we.props=["phase","mode","variant","animation","auto","event","error","saving-label","saved-label","idle-label","auto-clear-saved-ms","auto-clear-failed-ms"],we.styles=[ll],we.help=void 0;let Nt=we;oe("os-save-status",Nt);function ul(){return A`
32 32 <svg
33 33 viewBox="0 0 12 12"
34 34 aria-hidden="true"
35 35 focusable="false"
@@ -40,9 +40,9 @@
40 40 stroke-linejoin="round"
41 41 >
42 42 <path d="M2.5 6 L5 8.5 L9.5 4" />
43 43 </svg>
44 - `}function ir(){return A`
44 + `}function hl(){return A`
45 45 <svg
46 46 viewBox="0 0 12 12"
47 47 aria-hidden="true"
48 48 focusable="false"
@@ -51,24 +51,34 @@
51 51 <path
52 52 d="M5 2 H7 V7 H5 z M5 8.5 H7 V10.5 H5 z"
53 53 />
54 54 </svg>
55 - `}const rr=Z`:host{display:inline-block;--wpd-spinner-color:var( --wp-admin-theme-color,#21759b );--wpd-spinner-accent:#fff;--wpd-spinner-size:48px;width:var( --wpd-spinner-size );height:var( --wpd-spinner-size );color:var( --wpd-spinner-color );vertical-align:middle;line-height:0}:host( [ hidden ] ){display:none}:host( [ preset='inline' ] ){--wpd-spinner-color:currentColor;--wpd-spinner-size:16px}.root,.root svg{display:block;width:100%;height:100%}.root svg .mark{fill:var( --wpd-spinner-accent,var( --wpd-accent,#fff ) )}@keyframes wpd-spinner-spin{to{transform:rotate( 360deg )}}@keyframes wpd-spinner-scale{0%,100%{transform:scale( 1 )}50%{transform:scale( 1.045 )}}@keyframes wpd-spinner-opacity{0%,100%{opacity:1}50%{opacity:0.7}}@media ( prefers-reduced-motion:reduce ){.root svg [ style*='animation' ]{animation:none !important}}`,Fn=Object.freeze({classic:{sp1:12,sp2:24,sp3:40,a1:28,a2:15,a3:8,gap:4,dir2:1,dir3:-1,pulse:"none",dots:0},comet:{sp1:8,sp2:14,sp3:26,a1:50,a2:28,a3:12,gap:3,dir2:1,dir3:1,pulse:"none",dots:5},orbit:{sp1:10,sp2:10,sp3:32,a1:50,a2:50,a3:8,gap:5,dir2:-1,dir3:-1,pulse:"opacity",dots:3},pulse:{sp1:6,sp2:18,sp3:30,a1:20,a2:12,a3:6,gap:4,dir2:1,dir3:-1,pulse:"both",dots:8},inline:{sp1:8,sp2:8,sp3:8,a1:25,a2:25,a3:25,gap:0,dir2:1,dir3:1,pulse:"none",dots:0}}),O=61.26,N=61.26,Bn=58.453,ar='<path d="m8.708 61.26c0 20.802 12.089 38.779 29.619 47.298l-25.069-68.686c-2.916 6.536-4.55 13.769-4.55 21.388z"/><path d="m96.74 58.608c0-6.495-2.333-10.993-4.334-14.494-2.664-4.329-5.161-7.995-5.161-12.324 0-4.831 3.664-9.328 8.825-9.328.233 0 .454.029.681.042-9.35-8.566-21.807-13.796-35.489-13.796-18.36 0-34.513 9.42-43.91 23.688 1.233.037 2.395.063 3.382.063 5.497 0 14.006-.667 14.006-.667 2.833-.167 3.167 3.994.337 4.329 0 0-2.847.335-6.015.501l19.138 56.925 11.501-34.493-8.188-22.434c-2.83-.166-5.511-.501-5.511-.501-2.832-.166-2.5-4.496.332-4.329 0 0 8.679.667 13.843.667 5.496 0 14.006-.667 14.006-.667 2.835-.167 3.168 3.994.337 4.329 0 0-2.853.335-6.015.501l18.992 56.494 5.242-17.517c2.272-7.269 4.001-12.49 4.001-16.989z"/><path d="m62.184 65.857-15.768 45.819c4.708 1.384 9.687 2.141 14.846 2.141 6.12 0 11.989-1.058 17.452-2.979-.141-.225-.269-.464-.374-.724z"/><path d="m107.376 36.046c.226 1.674.354 3.471.354 5.404 0 5.333-.996 11.328-3.996 18.824l-16.053 46.413c15.624-9.111 26.133-26.038 26.133-45.426.001-9.137-2.333-17.729-6.438-25.215z"/>',de=class de extends z{constructor(){super(...arguments),this._paintScheduled=!1}connectedCallback(){super.connectedCallback(),this._schedulePaint()}render(){return A`<div class="root" part="root"></div>`}requestUpdate(){super.requestUpdate(),this._schedulePaint()}_schedulePaint(){this._paintScheduled||!this.isConnected||(this._paintScheduled=!0,queueMicrotask(()=>{this._paintScheduled=!1,this.isConnected&&this._paint()}))}_paint(){this._syncCssVars();const t=this.shadowRoot?.querySelector(".root");t&&(t.innerHTML=this._buildSvg())}_syncCssVars(){const t=(n,o,s)=>{const i=this.getAttribute(n);i===null?this.style.removeProperty(o):this.style.setProperty(o,s?s(i):i)};t("color","--wpd-spinner-color"),t("accent","--wpd-spinner-accent"),t("size","--wpd-spinner-size",n=>/^-?\d+(\.\d+)?$/.test(n.trim())?`${n}px`:n)}_effectiveConfig(){const t=this.getAttribute("preset")??"classic",n=Fn[t]??Fn.classic,o=(r,l)=>{const d=this.getAttribute(r);if(d===null)return l;const a=parseFloat(d);return Number.isFinite(a)?a:l},s=(r,l)=>{const d=this.getAttribute(r);if(d===null)return l;const a=d.toLowerCase();return a==="-1"||a==="ccw"||a==="reverse"?-1:1},i=()=>{const r=this.getAttribute("pulse");return r==="scale"||r==="opacity"||r==="both"||r==="none"?r:n.pulse};return{sp1:o("sp1",n.sp1),sp2:o("sp2",n.sp2),sp3:o("sp3",n.sp3),a1:o("a1",n.a1),a2:o("a2",n.a2),a3:o("a3",n.a3),gap:o("gap",n.gap),dir2:s("dir2",n.dir2),dir3:s("dir3",n.dir3),pulse:i(),dots:Math.max(0,Math.floor(o("dots",n.dots)))}}_buildInlineSvg(t){const n=Gn(this.getAttribute("label")??"Loading"),o=9,s=(t.sp1/10).toFixed(2);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-label="${n}"><circle cx="12" cy="12" r="${o}" fill="none" stroke="currentColor" stroke-width="2.4" stroke-opacity="0.22"/><circle cx="12" cy="12" r="${o}" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-dasharray="${Re(o,t.a1)}" style="transform-origin:12px 12px;animation: wpd-spinner-spin ${s}s linear infinite"/></svg>`}_buildSvg(){const t=this._effectiveConfig();if(this.getAttribute("preset")==="inline")return this._buildInlineSvg(t);const n=Gn(this.getAttribute("label")??"Loading"),o=t.gap*3+14,s=-o,i=122.52+o*2,r=Bn+t.gap+2,l=r+t.gap+2,d=l+t.gap+1.5,a=`animation: wpd-spinner-spin ${(t.sp1/10).toFixed(2)}s linear infinite`,c=`animation: wpd-spinner-spin ${(t.sp2/10).toFixed(2)}s linear infinite${t.dir2<0?" reverse":""}`,p=`animation: wpd-spinner-spin ${(t.sp3/10).toFixed(2)}s linear infinite${t.dir3<0?" reverse":""}`,m=(t.sp1*1.8/10).toFixed(1),f=(t.sp1*2.3/10).toFixed(1);let _="";t.pulse==="scale"?_=`animation: wpd-spinner-scale ${m}s ease-in-out infinite`:t.pulse==="opacity"?_=`animation: wpd-spinner-opacity ${f}s ease-in-out infinite`:t.pulse==="both"&&(_=`animation: wpd-spinner-scale ${m}s ease-in-out infinite, wpd-spinner-opacity ${f}s ease-in-out infinite`);let S="";if(t.dots>0){const y=d+t.gap+1,k=2*Math.PI*y,b=1.6,v=(t.sp1*.65/10).toFixed(2);for(let E=0;E<t.dots;E++){const T=-(E/t.dots)*k;S+=`<circle cx="${O}" cy="${N}" r="${y.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="${b}" stroke-dasharray="${b.toFixed(2)} ${(k-b).toFixed(2)}" stroke-dashoffset="${T.toFixed(2)}" stroke-linecap="round" stroke-opacity="0.65" style="transform-origin:${O}px ${N}px;animation: wpd-spinner-spin ${v}s linear infinite"/>`}}return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${s} ${s} ${i} ${i}" role="img" aria-label="${n}"><g style="transform-origin:${O}px ${N}px${_?";"+_:""}"><circle cx="${O}" cy="${N}" r="${Bn}" fill="currentColor"/><g class="mark">${ar}</g></g><circle cx="${O}" cy="${N}" r="${r.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.6" stroke-opacity="0.2"/><circle cx="${O}" cy="${N}" r="${r.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="2.2" stroke-dasharray="${Re(r,t.a1)}" stroke-linecap="round" style="transform-origin:${O}px ${N}px;${a}"/><circle cx="${O}" cy="${N}" r="${l.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.5" stroke-opacity="0.15"/><circle cx="${O}" cy="${N}" r="${l.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="1.6" stroke-opacity="0.8" stroke-dasharray="${Re(l,t.a2)}" stroke-linecap="round" style="transform-origin:${O}px ${N}px;${c}"/><circle cx="${O}" cy="${N}" r="${d.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.4" stroke-opacity="0.12"/><circle cx="${O}" cy="${N}" r="${d.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="1.0" stroke-opacity="0.6" stroke-dasharray="${Re(d,t.a3)}" stroke-linecap="round" style="transform-origin:${O}px ${N}px;${p}"/>`+S+"</svg>"}};de.props=["preset","size","color","accent","sp1","sp2","sp3","a1","a2","a3","gap","dir2","dir3","pulse","dots","label"],de.styles=[rr],de.help=void 0;let lt=de;function Re(e,t){const n=2*Math.PI*e,o=t/100*n,s=n-o;return`${o.toFixed(2)} ${s.toFixed(2)}`}function Gn(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}Y("wpd-spinner",lt);const dr=Z`:host{display:block;min-width:220px;padding:4px;background:var( --desktop-mode-window-bg,#fff );background-image:var( --wpd-menu-bg-image,none );background-repeat:var( --wpd-menu-bg-image-repeat,repeat );background-size:var( --wpd-menu-bg-image-size,auto );background-position:var( --wpd-menu-bg-image-position,center );color:var( --wpd-fg,#1d2327 );border:1px solid var( --desktop-mode-window-border,#c3c4c7 );border-radius:8px;box-shadow:0 8px 24px rgba( 0,0,0,0.18 ),0 2px 6px rgba( 0,0,0,0.08 )}:host( [ hidden ] ){display:none}`,lr=Z`:host{display:block}button{display:flex;align-items:center;gap:10px;width:100%;min-height:32px;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:inherit;font:inherit;font-size:13px;line-height:1.3;text-align:start;cursor:pointer;transition:background-color 0.12s ease,color 0.12s ease}button:hover,button:focus-visible{background:var( --wpd-hover,rgba( 0,0,0,0.06 ) );color:var( --wpd-fg,#000 );outline:none}button:focus-visible{outline:2px solid var( --wp-admin-theme-color,#2271b1 );outline-offset:-2px}.wpd-menu-item__icon{flex-shrink:0;width:18px;height:18px;font-size:18px;line-height:1;color:var( --wp-admin-theme-color,#2271b1 )}.wpd-menu-item__icon[ hidden ]{display:none}.wpd-menu-item__label{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wpd-menu-item__check{flex-shrink:0;width:16px;height:16px;border-radius:3px;border:1.5px solid var( --wpd-border,rgba( 0,0,0,0.25 ) );position:relative;background:transparent;transition:background-color 0.12s ease,border-color 0.12s ease}.wpd-menu-item__check[ hidden ]{display:none}:host( [ checked ] ) .wpd-menu-item__check{background:var( --wp-admin-theme-color,#2271b1 );border-color:var( --wp-admin-theme-color,#2271b1 )}:host( [ checked ] ) .wpd-menu-item__check::after{content:'';position:absolute;top:1px;left:4px;width:4px;height:8px;border:solid var( --wpd-fg-on-accent,#fff );border-width:0 2px 2px 0;transform:rotate( 45deg )}`,Ne=class Ne extends z{connectedCallback(){super.connectedCallback(),this.setAttribute("role","menu")}render(){return A`<slot></slot>`}};Ne.styles=[dr],Ne.help=void 0;let ct=Ne;Y("wpd-menu",ct);const le=class le extends z{connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","menuitem")}render(){const t=this.icon||"",n=this.getAttribute("role")==="menuitemcheckbox",o=this.checked!==null;return n&&this.setAttribute("aria-checked",o?"true":"false"),A`
56 - <button type="button" @click=${s=>this._onPick(s)}>
55 + `}const fl=x`:host{display:inline-block;--_color:var( --os-ui-spinner-color,var( --wp-admin-theme-color,#21759b ) );--_accent:var( --os-ui-spinner-accent,var( --os-ui-fg-on-accent,#fff ) );--_size:var( --os-ui-spinner-size,48px );width:var( --_size );height:var( --_size );color:var( --_color );vertical-align:middle;line-height:0}:host( [ hidden ] ){display:none}:host( [ preset='inline' ] ){--os-ui-spinner-color:currentColor;--os-ui-spinner-size:16px}.root,.root svg{display:block;width:100%;height:100%}.root svg .mark{fill:var( --_accent )}@keyframes os-spinner-spin{to{transform:rotate( 360deg )}}@keyframes os-spinner-scale{0%,100%{transform:scale( 1 )}50%{transform:scale( 1.045 )}}@keyframes os-spinner-opacity{0%,100%{opacity:1}50%{opacity:0.7}}@media ( prefers-reduced-motion:reduce ){.root svg [ style*='animation' ]{animation:none !important}}`,Lo=Object.freeze({classic:{sp1:12,sp2:24,sp3:40,a1:28,a2:15,a3:8,gap:4,dir2:1,dir3:-1,pulse:"none",dots:0},comet:{sp1:8,sp2:14,sp3:26,a1:50,a2:28,a3:12,gap:3,dir2:1,dir3:1,pulse:"none",dots:5},orbit:{sp1:10,sp2:10,sp3:32,a1:50,a2:50,a3:8,gap:5,dir2:-1,dir3:-1,pulse:"opacity",dots:3},pulse:{sp1:6,sp2:18,sp3:30,a1:20,a2:12,a3:6,gap:4,dir2:1,dir3:-1,pulse:"both",dots:8},inline:{sp1:8,sp2:8,sp3:8,a1:25,a2:25,a3:25,gap:0,dir2:1,dir3:1,pulse:"none",dots:0}}),R=61.26,O=61.26,No=58.453,pl='<path d="m8.708 61.26c0 20.802 12.089 38.779 29.619 47.298l-25.069-68.686c-2.916 6.536-4.55 13.769-4.55 21.388z"/><path d="m96.74 58.608c0-6.495-2.333-10.993-4.334-14.494-2.664-4.329-5.161-7.995-5.161-12.324 0-4.831 3.664-9.328 8.825-9.328.233 0 .454.029.681.042-9.35-8.566-21.807-13.796-35.489-13.796-18.36 0-34.513 9.42-43.91 23.688 1.233.037 2.395.063 3.382.063 5.497 0 14.006-.667 14.006-.667 2.833-.167 3.167 3.994.337 4.329 0 0-2.847.335-6.015.501l19.138 56.925 11.501-34.493-8.188-22.434c-2.83-.166-5.511-.501-5.511-.501-2.832-.166-2.5-4.496.332-4.329 0 0 8.679.667 13.843.667 5.496 0 14.006-.667 14.006-.667 2.835-.167 3.168 3.994.337 4.329 0 0-2.853.335-6.015.501l18.992 56.494 5.242-17.517c2.272-7.269 4.001-12.49 4.001-16.989z"/><path d="m62.184 65.857-15.768 45.819c4.708 1.384 9.687 2.141 14.846 2.141 6.12 0 11.989-1.058 17.452-2.979-.141-.225-.269-.464-.374-.724z"/><path d="m107.376 36.046c.226 1.674.354 3.471.354 5.404 0 5.333-.996 11.328-3.996 18.824l-16.053 46.413c15.624-9.111 26.133-26.038 26.133-45.426.001-9.137-2.333-17.729-6.438-25.215z"/>',ye=class ye extends K{constructor(){super(...arguments),this._paintScheduled=!1}connectedCallback(){super.connectedCallback(),this._schedulePaint()}render(){return A`<div class="root" part="root"></div>`}requestUpdate(){super.requestUpdate(),this._schedulePaint()}_schedulePaint(){this._paintScheduled||!this.isConnected||(this._paintScheduled=!0,queueMicrotask(()=>{this._paintScheduled=!1,this.isConnected&&this._paint()}))}_paint(){this._syncCssVars();const t=this.shadowRoot?.querySelector(".root");t&&(t.innerHTML=this._buildSvg())}_syncCssVars(){const t=(n,o,i)=>{const s=this.getAttribute(n);s===null?this.style.removeProperty(o):this.style.setProperty(o,i?i(s):s)};t("color","--os-ui-spinner-color"),t("accent","--os-ui-spinner-accent"),t("size","--os-ui-spinner-size",n=>/^-?\d+(\.\d+)?$/.test(n.trim())?`${n}px`:n)}_effectiveConfig(){const t=this.getAttribute("preset")??"classic",n=Lo[t]??Lo.classic,o=(r,d)=>{const a=this.getAttribute(r);if(a===null)return d;const c=parseFloat(a);return Number.isFinite(c)?c:d},i=(r,d)=>{const a=this.getAttribute(r);if(a===null)return d;const c=a.toLowerCase();return c==="-1"||c==="ccw"||c==="reverse"?-1:1},s=()=>{const r=this.getAttribute("pulse");return r==="scale"||r==="opacity"||r==="both"||r==="none"?r:n.pulse};return{sp1:o("sp1",n.sp1),sp2:o("sp2",n.sp2),sp3:o("sp3",n.sp3),a1:o("a1",n.a1),a2:o("a2",n.a2),a3:o("a3",n.a3),gap:o("gap",n.gap),dir2:i("dir2",n.dir2),dir3:i("dir3",n.dir3),pulse:s(),dots:Math.max(0,Math.floor(o("dots",n.dots)))}}_buildInlineSvg(t){const n=Ro(this.getAttribute("label")??"Loading"),o=9,i=(t.sp1/10).toFixed(2);return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-label="${n}"><circle cx="12" cy="12" r="${o}" fill="none" stroke="currentColor" stroke-width="2.4" stroke-opacity="0.22"/><circle cx="12" cy="12" r="${o}" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-dasharray="${Ue(o,t.a1)}" style="transform-origin:12px 12px;animation: os-spinner-spin ${i}s linear infinite"/></svg>`}_buildSvg(){const t=this._effectiveConfig();if(this.getAttribute("preset")==="inline")return this._buildInlineSvg(t);const n=Ro(this.getAttribute("label")??"Loading"),o=t.gap*3+14,i=-o,s=122.52+o*2,r=No+t.gap+2,d=r+t.gap+2,a=d+t.gap+1.5,c=`animation: os-spinner-spin ${(t.sp1/10).toFixed(2)}s linear infinite`,l=`animation: os-spinner-spin ${(t.sp2/10).toFixed(2)}s linear infinite${t.dir2<0?" reverse":""}`,u=`animation: os-spinner-spin ${(t.sp3/10).toFixed(2)}s linear infinite${t.dir3<0?" reverse":""}`,p=(t.sp1*1.8/10).toFixed(1),g=(t.sp1*2.3/10).toFixed(1);let b="";t.pulse==="scale"?b=`animation: os-spinner-scale ${p}s ease-in-out infinite`:t.pulse==="opacity"?b=`animation: os-spinner-opacity ${g}s ease-in-out infinite`:t.pulse==="both"&&(b=`animation: os-spinner-scale ${p}s ease-in-out infinite, os-spinner-opacity ${g}s ease-in-out infinite`);let y="";if(t.dots>0){const w=a+t.gap+1,S=2*Math.PI*w,E=1.6,C=(t.sp1*.65/10).toFixed(2);for(let N=0;N<t.dots;N++){const D=-(N/t.dots)*S;y+=`<circle cx="${R}" cy="${O}" r="${w.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="${E}" stroke-dasharray="${E.toFixed(2)} ${(S-E).toFixed(2)}" stroke-dashoffset="${D.toFixed(2)}" stroke-linecap="round" stroke-opacity="0.65" style="transform-origin:${R}px ${O}px;animation: os-spinner-spin ${C}s linear infinite"/>`}}return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${i} ${i} ${s} ${s}" role="img" aria-label="${n}"><g style="transform-origin:${R}px ${O}px${b?";"+b:""}"><circle cx="${R}" cy="${O}" r="${No}" fill="currentColor"/><g class="mark">${pl}</g></g><circle cx="${R}" cy="${O}" r="${r.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.6" stroke-opacity="0.2"/><circle cx="${R}" cy="${O}" r="${r.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="2.2" stroke-dasharray="${Ue(r,t.a1)}" stroke-linecap="round" style="transform-origin:${R}px ${O}px;${c}"/><circle cx="${R}" cy="${O}" r="${d.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.5" stroke-opacity="0.15"/><circle cx="${R}" cy="${O}" r="${d.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="1.6" stroke-opacity="0.8" stroke-dasharray="${Ue(d,t.a2)}" stroke-linecap="round" style="transform-origin:${R}px ${O}px;${l}"/><circle cx="${R}" cy="${O}" r="${a.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="0.4" stroke-opacity="0.12"/><circle cx="${R}" cy="${O}" r="${a.toFixed(2)}" fill="none" stroke="currentColor" stroke-width="1.0" stroke-opacity="0.6" stroke-dasharray="${Ue(a,t.a3)}" stroke-linecap="round" style="transform-origin:${R}px ${O}px;${u}"/>`+y+"</svg>"}};ye.props=["preset","size","color","accent","sp1","sp2","sp3","a1","a2","a3","gap","dir2","dir3","pulse","dots","label"],ye.styles=[fl],ye.help=void 0;let Rt=ye;function Ue(e,t){const n=2*Math.PI*e,o=t/100*n,i=n-o;return`${o.toFixed(2)} ${i.toFixed(2)}`}function Ro(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}oe("os-spinner",Rt);const Ge=x`:host{--_holo-fill:var( --os-ui-holo-fill,${"linear-gradient( 124deg, #afa2e8 0%, #f5a8ea 46%, #8ee9f7 100% )"} );--_holo-ink:var( --os-ui-holo-ink,#0c0b0f );--_holo-sheen:var( --os-ui-holo-sheen,linear-gradient( 124deg,rgba( 159,214,255,0.1 ) 0%,rgba( 236,155,255,0.12 ) 34%,rgba( 242,82,252,0.1 ) 58%,rgba( 147,240,198,0.09 ) 100% ) );--_holo-edge:var( --os-ui-holo-edge,linear-gradient( 124deg,rgba( 154,242,255,0.7 ) 0%,rgba( 236,155,255,0.85 ) 38%,rgba( 242,82,252,0.7 ) 62%,rgba( 159,152,255,0.6 ) 100% ) );--_holo-edge-quiet:var( --os-ui-holo-edge-quiet,linear-gradient( 124deg,rgba( 154,242,255,0.22 ) 0%,rgba( 236,155,255,0.28 ) 38%,rgba( 242,82,252,0.22 ) 62%,rgba( 159,152,255,0.2 ) 100% ) );--_holo-glow:var( --os-ui-holo-glow,0 0 0 1px rgba( 242,82,252,0.28 ),0 2px 10px rgba( 242,82,252,0.22 ) );--_holo-glow-strong:var( --os-ui-holo-glow-strong,0 0 0 1px rgba( 242,82,252,0.42 ),0 4px 18px rgba( 242,82,252,0.38 ),0 1px 3px rgba( 12,11,15,0.6 ) );--_holo-track:var( --os-ui-holo-track,rgba( 255,251,255,0.16 ) );--_holo-track-edge:var( --os-ui-holo-track-edge,#8c8f94 );--_holo-ring-color:var( --os-ui-accent-dim,#2271b1 );--_holo-focus:var( --os-ui-focus-ring,0 0 0 2px rgba( 12,11,15,0.9 ),0 0 0 4px #f252fc,0 0 12px 2px rgba( 242,82,252,0.45 ) );--_holo-focus-field:var( --os-ui-focus-ring-field,0 0 0 1px #f252fc,0 0 0 4px rgba( 242,82,252,0.18 ) );--_holo-t:var( --os-ui-holo-transition,220ms );--_holo-t-fast:var( --os-ui-motion-fast,140ms );--_holo-t-slow:var( --os-ui-motion-slow,340ms );--_holo-t-ambient:var( --os-ui-motion-ambient,12s );--_holo-spring:var( --os-ui-ease-spring,cubic-bezier( 0.32,1.5,0.55,1 ) );--_holo-ease:var( --os-ui-ease-out,cubic-bezier( 0.22,0.9,0.28,1 ) );--_holo-loop:var( --os-ui-ease-loop,cubic-bezier( 0.45,0,0.55,1 ) )}`,ml=x` .os-holo-fill{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --_holo-ink );transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease}.os-holo-fill:hover{background-position:74% 66%}.os-holo-fill:active{background-position:88% 82%;filter:brightness( 0.94 )}@media ( prefers-reduced-motion:reduce ){.os-holo-fill{transition-duration:1ms}.os-holo-fill:hover,.os-holo-fill:active{background-position:22% 28%}}`,gl=x` .os-holo-sheen{position:relative;isolation:isolate}.os-holo-sheen::before{content:'';position:absolute;inset:0;z-index:-1;border-radius:inherit;background-image:var( --_holo-sheen );background-size:200% 200%;background-position:20% 30%;opacity:0;pointer-events:none;transition:opacity var( --_holo-t ) ease,background-position var( --_holo-t ) ease}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{opacity:1;background-position:76% 68%}@media ( prefers-reduced-motion:reduce ){.os-holo-sheen::before{transition-duration:1ms}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{background-position:20% 30%}}`,_l=x` .os-holo-edge{position:relative}.os-holo-edge::after{content:'';position:absolute;inset:0;border-radius:inherit;padding:1px;background-image:var( --_holo-edge-quiet );opacity:0;pointer-events:none;-webkit-mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );-webkit-mask-composite:xor;mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );mask-composite:exclude;transition:opacity var( --_holo-t ) ease}.os-holo-edge:hover::after,.os-holo-edge:focus-visible::after{background-image:var( --_holo-edge );opacity:1}.os-holo-edge.is-lit::after{background-image:var( --_holo-edge );opacity:1}@media ( prefers-reduced-motion:reduce ){.os-holo-edge::after{transition-duration:1ms}}`,bl=x` .os-holo-glint{position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none}.os-holo-glint::before{content:'';position:absolute;top:-60%;bottom:-60%;width:45%;inset-inline-start:-60%;background:linear-gradient( 90deg,transparent 0%,rgba( 255,251,255,0.14 ) 45%,rgba( 255,251,255,0.22 ) 50%,rgba( 255,251,255,0.14 ) 55%,transparent 100% );transform:rotate( 18deg ) translateX( 0 );opacity:0}:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:os-holo-glint var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-glint{0%{opacity:0;transform:rotate( 18deg ) translateX( 0 )}15%{opacity:1}85%{opacity:1}100%{opacity:0;transform:rotate( 18deg ) translateX( 240vw )}}@media ( prefers-reduced-motion:reduce ){:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:none}}`,wl=x` .os-holo-ring{position:absolute;inset:0;border-radius:inherit;box-shadow:0 0 0 0 var( --_holo-ring-color );opacity:0;pointer-events:none}:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:os-holo-ring var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-ring{0%{opacity:0.45;box-shadow:0 0 0 0 var( --_holo-ring-color )}100%{opacity:0;box-shadow:0 0 0 10px transparent}}@media ( prefers-reduced-motion:reduce ){:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:none}}`,yl=x` .os-holo-shimmer{background-image:var( --_holo-fill );background-size:300% 300%;background-repeat:no-repeat;animation:os-holo-shimmer 2.4s var( --_holo-loop ) infinite}@keyframes os-holo-shimmer{0%{background-position:0% 50%}100%{background-position:100% 50%}}@media ( prefers-reduced-motion:reduce ){.os-holo-shimmer{animation:none;background-position:30% 50%}}`,Oo=x` .os-holo-enter{animation:os-holo-enter var( --_holo-t ) var( --_holo-spring )}@keyframes os-holo-enter{from{opacity:0;transform:scale( 0.96 )}}@media ( prefers-reduced-motion:reduce ){.os-holo-enter{animation:none}}`,vl=x` input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):hover:not(:disabled ),select:hover:not(:disabled ),textarea:hover:not(:disabled ){border-color:var( --os-ui-border-strong,#8c8f94 )}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus,input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus-visible,select:focus,select:focus-visible,textarea:focus,textarea:focus-visible{outline:none;border-color:var( --os-ui-accent,#2271b1 );box-shadow:var( --_holo-focus-field )}input::placeholder,textarea::placeholder{color:var( --os-ui-fg-faint,#8c8f94 );opacity:1}input::selection,textarea::selection{background:var( --os-ui-selection-bg,rgba( 159,152,255,0.6 ) );color:var( --os-ui-selection-fg,#fffbff )}@media ( prefers-reduced-motion:reduce ){input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition-duration:1ms}}`,El=x` input[ type='checkbox' ],input[ type='radio' ]{appearance:none;-webkit-appearance:none;position:relative;flex:0 0 auto;box-sizing:border-box;width:16px;height:16px;margin:0;padding:0;border:1px solid var( --_holo-track-edge );border-radius:4px;background-color:var( --_holo-track );background-image:none;background-repeat:no-repeat;cursor:inherit;transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='radio' ]{border-radius:50%}input[ type='checkbox' ]:hover:not(:disabled ),input[ type='radio' ]:hover:not(:disabled ){border-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:focus-visible,input[ type='radio' ]:focus-visible{outline:none;box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked,input[ type='checkbox' ]:indeterminate,input[ type='radio' ]:checked{border-color:transparent;background-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:checked:focus-visible,input[ type='radio' ]:checked:focus-visible{box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:46%;width:3.5px;height:7.5px;border:solid var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );border-width:0 2px 2px 0;transform:translate( -50%,-50% ) rotate( 45deg );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:indeterminate::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:8px;height:2px;border:0;border-radius:1px;background:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );transform:translate( -50%,-50% )}input[ type='radio' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:6px;height:6px;border-radius:50%;background:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );transform:translate( -50%,-50% );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:disabled,input[ type='radio' ]:disabled{cursor:not-allowed}@keyframes os-holo-tick{from{opacity:0;transform:translate( -50%,-50% ) rotate( 45deg ) scale( 0.4 )}}@media ( prefers-reduced-motion:reduce ){input[ type='checkbox' ]:checked::after,input[ type='radio' ]:checked::after{animation:none}}`,Al=x` @keyframes os-holo-drift{0%{background-position:16% 26%}50%{background-position:84% 74%}100%{background-position:16% 26%}}.os-holo-alive{animation:os-holo-drift var( --_holo-t-ambient ) var( --_holo-loop ) infinite}@media ( prefers-reduced-motion:reduce ){.os-holo-alive{animation:none}}`;x` ${Ge} ${ml} ${gl} ${_l} ${bl} ${wl} ${yl} ${Oo} ${vl} ${El} ${Al} `;const Sl=x` ${Ge} ${Oo}:host{display:block;animation:os-holo-enter var( --_holo-t ) var( --_holo-spring );transform-origin:top left;min-width:220px;padding:4px;background:var( --os-window-bg,#fff );background-image:var( --os-ui-menu-bg-image,none );background-repeat:var( --os-ui-menu-bg-image-repeat,repeat );background-size:var( --os-ui-menu-bg-image-size,auto );background-position:var( --os-ui-menu-bg-image-position,center );color:var( --os-ui-fg,#1d2327 );border:1px solid var( --os-window-border,#c3c4c7 );border-radius:8px;box-shadow:0 8px 24px rgba( 0,0,0,0.18 ),0 2px 6px rgba( 0,0,0,0.08 )}:host(:dir( rtl ) ){transform-origin:top right}@media ( prefers-reduced-motion:reduce ){:host{animation:none}}:host( [ hidden ] ){display:none}`,Cl=x`:host{display:block}button{display:flex;align-items:center;gap:10px;width:100%;min-height:32px;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:inherit;font:inherit;font-size:13px;line-height:1.3;text-align:start;cursor:pointer;transition:background-color 0.12s ease,color 0.12s ease}button:hover,button:focus-visible{background:var( --os-ui-hover,rgba( 0,0,0,0.06 ) );color:var( --os-ui-fg,#000 );outline:none}button:focus-visible{outline:none;box-shadow:inset 0 0 0 2px var( --os-ui-accent,#2271b1 )}.os-menu-item__icon{flex-shrink:0;width:18px;height:18px;font-size:18px;line-height:1;color:var( --wp-admin-theme-color,#2271b1 )}.os-menu-item__icon[ hidden ]{display:none}.os-menu-item__label{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.os-menu-item__check{flex-shrink:0;width:16px;height:16px;border-radius:3px;border:1.5px solid var( --os-ui-border,rgba( 0,0,0,0.25 ) );position:relative;background:transparent;transition:background-color 0.12s ease,border-color 0.12s ease}.os-menu-item__check[ hidden ]{display:none}:host( [ checked ] ) .os-menu-item__check{background-color:transparent;background-image:var( --os-ui-holo-fill,linear-gradient( 124deg,#afa2e8 0%,#f5a8ea 46%,#8ee9f7 100% ) );background-size:200% 200%;background-position:25% 30%;border-color:transparent;box-shadow:var( --os-ui-holo-glow,0 0 0 1px rgba( 242,82,252,0.28 ),0 2px 10px rgba( 242,82,252,0.22 ) )}:host( [ checked ] ) .os-menu-item__check::after{content:'';position:absolute;top:1px;left:4px;width:4px;height:8px;border:solid var( --os-ui-holo-ink,#0c0b0f );border-width:0 2px 2px 0;transform:rotate( 45deg )}`,qe=class qe extends K{connectedCallback(){super.connectedCallback(),this.setAttribute("role","menu")}render(){return A`<slot></slot>`}};qe.styles=[Sl],qe.help=void 0;let Ot=qe;oe("os-menu",Ot);const ve=class ve extends K{connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","menuitem")}render(){const t=this.icon||"",n=this.getAttribute("role")==="menuitemcheckbox",o=this.checked!==null;return n&&this.setAttribute("aria-checked",o?"true":"false"),A`
56 + <button type="button" @click=${i=>this._onPick(i)}>
57 57 <span
58 - class="wpd-menu-item__check"
58 + class="os-menu-item__check"
59 59 ?hidden=${!n}
60 60 ></span>
61 61 <span
62 - class="wpd-menu-item__icon dashicons ${t}"
62 + class="os-menu-item__icon dashicons ${t}"
63 63 aria-hidden="true"
64 64 ?hidden=${n||!t}
65 65 ></span>
66 - <span class="wpd-menu-item__label">
66 + <span class="os-menu-item__label">
67 67 <slot></slot>
68 68 </span>
69 69 </button>
70 - `}_onPick(t){t.preventDefault(),this.emit("wpd-menu-item-click",{value:this.value})}};le.props=["icon","value","checked"],le.styles=[lr],le.help={title:"Menu item",summary:'Single row inside a <wpd-menu>. Supports three looks: plain label, left-aligned dashicon (icon="dashicons-…"), or a checkbox indicator (role="menuitemcheckbox" + checked).',status:"stable",since:"0.9.0",props:[{name:"icon",type:"string (dashicons class)",description:'Dashicons class rendered on the left. Ignored when role="menuitemcheckbox".'},{name:"value",type:"string",description:"Identifier emitted in wpd-menu-item-click.detail.value."},{name:"checked",type:"boolean attribute",description:'Visible check indicator. Only honoured when role="menuitemcheckbox".'}],slots:[{name:"(default)",description:"Menu item label."}],events:[{name:"wpd-menu-item-click",description:"Fires when the item is clicked; bubbles so the <wpd-menu> parent can delegate.",detail:"{ value: string | null }"}]};let ut=le;Y("wpd-menu-item",ut);const cr=Z`:host{display:inline-flex}button{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:4px;background:transparent;color:var( --wpd-fg-muted,rgba( 0,0,0,0.45 ) );cursor:pointer;transition:background-color 0.15s ease,color 0.15s ease,transform 0.12s ease}:host( [ variant='detach' ] ) button:hover{color:var( --wp-admin-theme-color,#2271b1 );background:rgba( 34,113,177,0.12 );transform:translateY( -1px )}:host( [ variant='detach' ] ) button:focus-visible{outline:2px solid var( --wp-admin-theme-color,#2271b1 );outline-offset:1px}:host( [ variant='close' ] ) button:hover{color:var( --wpd-fg-on-accent,#fff );background:var( --wpd-danger,#d63638 )}:host( [ variant='close' ] ) button:focus-visible{color:var( --wpd-fg-on-accent,#fff );background:var( --wpd-danger,#d63638 );outline:2px solid rgba( 214,54,56,0.6 );outline-offset:1px}svg{display:block;pointer-events:none;width:12px;height:12px}@media ( prefers-reduced-motion:reduce ){button{transition-duration:0.01ms}:host( [ variant='detach' ] ) button:hover{transform:none}}`,ur={detach:'<path d="M5 2H2.5v7.5H10V7M6.5 2H10v3.5M10 2L5.5 6.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',close:'<path d="M2.5 2.5l7 7M9.5 2.5l-7 7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>'},ce=class ce extends z{render(){const t=this.variant||"",n=ur[t]||"";return A`
70 + `}_onPick(t){t.preventDefault(),this.emit("os-menu-item-click",{value:this.value})}};ve.props=["icon","value","checked"],ve.styles=[Cl],ve.help={title:"Menu item",summary:'Single row inside a <os-menu>. Supports three looks: plain label, left-aligned dashicon (icon="dashicons-…"), or a checkbox indicator (role="menuitemcheckbox" + checked).',status:"stable",props:[{name:"icon",type:"string (dashicons class)",description:'Dashicons class rendered on the left. Ignored when role="menuitemcheckbox".'},{name:"value",type:"string",description:"Identifier emitted in os-menu-item-click.detail.value."},{name:"checked",type:"boolean attribute",description:'Visible check indicator. Only honoured when role="menuitemcheckbox".'}],slots:[{name:"(default)",description:"Menu item label."}],events:[{name:"os-menu-item-click",description:"Fires when the item is clicked; bubbles so the <os-menu> parent can delegate.",detail:"{ value: string | null }"}],example:A`
71 + <os-menu>
72 + <os-menu-item value="plain">Plain item</os-menu-item>
73 + <os-menu-item value="icon" icon="dashicons-external">
74 + With an icon
75 + </os-menu-item>
76 + <os-menu-item value="startup" role="menuitemcheckbox" checked>
77 + Checked (menuitemcheckbox)
78 + </os-menu-item>
79 + </os-menu>
80 + `};let Dt=ve;oe("os-menu-item",Dt);const kl=x` ${Ge}:host{display:inline-flex}button{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:4px;background:transparent;color:var( --os-ui-fg-muted,rgba( 0,0,0,0.45 ) );cursor:pointer;transition:background-color 0.15s ease,color 0.15s ease,transform 0.12s ease}:host( [ variant='detach' ] ) button:hover{color:var( --wp-admin-theme-color,#2271b1 );background:var( --os-ui-accent-soft,rgba( 34,113,177,0.12 ) );transform:translateY( -1px )}:host( [ variant='detach' ] ) button:focus-visible{outline:none;color:var( --os-ui-accent,#2271b1 );background:var( --os-ui-accent-soft,rgba( 34,113,177,0.12 ) );box-shadow:var( --_holo-focus )}:host( [ variant='close' ] ) button:hover{color:var( --os-ui-fg-on-accent,#fff );background:var( --os-ui-danger,#d63638 )}:host( [ variant='close' ] ) button:focus-visible{color:var( --os-ui-fg-on-accent,#fff );background:var( --os-ui-danger,#d63638 );outline:none;box-shadow:0 0 0 2px rgba( 12,11,15,0.9 ),0 0 0 4px var( --os-ui-danger,#d63638 ),0 0 12px 2px rgba( 214,54,56,0.45 )}svg{display:block;pointer-events:none;width:12px;height:12px}@media ( prefers-reduced-motion:reduce ){button{transition-duration:0.01ms}:host( [ variant='detach' ] ) button:hover{transform:none}}`,xl={detach:'<path d="M5 2H2.5v7.5H10V7M6.5 2H10v3.5M10 2L5.5 6.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',close:'<path d="M2.5 2.5l7 7M9.5 2.5l-7 7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>'},Ee=class Ee extends K{render(){const t=this.variant||"",n=xl[t]||"";return A`
71 81 <button type="button">
72 82 <svg
73 83 viewBox="0 0 12 12"
74 84 aria-hidden="true"
@@ -76,11 +86,11 @@
76 86 ></svg>
77 87 <slot></slot>
78 88 </button>
79 89 <span data-svg-buffer style="display:none">${n}</span>
80 - `}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>this._paintSvg())}attributeChangedCallback(t,n,o){super.attributeChangedCallback(t,n,o),queueMicrotask(()=>this._paintSvg())}_paintSvg(){const t=this.shadowRoot;if(!t)return;const n=t.querySelector("svg"),o=t.querySelector("[data-svg-buffer]");if(n&&o){const s=o.textContent||"";n.innerHTML!==s&&(n.innerHTML=s)}}};ce.props=["variant"],ce.styles=[cr],ce.help=void 0;let pt=ce;Y("wpd-tab-chip",pt);const pr={createWindow(e){return new it(e)}};window.desktopModeWindowSystem=pr;const hr=Z`:host{display:none;position:fixed;inset:0;align-items:center;justify-content:center;background:var( --wpd-scrim,rgba( 0,0,0,0.45 ) );background-image:var( --wpd-scrim-image,none );background-repeat:var( --wpd-scrim-image-repeat,repeat );background-size:var( --wpd-scrim-image-size,auto );background-position:var( --wpd-scrim-image-position,center );backdrop-filter:blur( 2px );z-index:10000}:host( [ open ] ){display:flex}.dialog{width:min( 420px,92vw );background-color:var( --wpd-confirm-dialog-bg,#1d2327 );background-image:var( --wpd-dialog-bg-image,none );background-repeat:var( --wpd-dialog-bg-image-repeat,repeat );background-size:var( --wpd-dialog-bg-image-size,auto );background-position:var( --wpd-dialog-bg-image-position,center );color:var( --wpd-confirm-dialog-fg,var( --desktop-mode-fg,#fff ) );border:1px solid var( --wpd-border,rgba( 255,255,255,0.08 ) );border-radius:10px;box-shadow:0 20px 50px rgba( 0,0,0,0.6 );padding:20px 22px 18px;display:flex;flex-direction:column;gap:10px;position:relative}.close{position:absolute;top:8px;right:10px;width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:0;border-radius:6px;color:var( --wpd-confirm-dialog-fg-muted,var( --wpd-fg-muted,rgba( 255,255,255,0.7 ) ) );cursor:pointer;font-size:22px;line-height:1;padding:0}.close:hover{background:var( --wpd-hover,rgba( 255,255,255,0.08 ) );color:inherit}.title{margin:0 0 4px;font-size:16px;font-weight:600}.message{margin:0;color:var( --wpd-confirm-dialog-fg-muted,var( --wpd-fg-muted,rgba( 255,255,255,0.7 ) ) );line-height:1.45;white-space:pre-line}.actions{display:flex;justify-content:flex-end;gap:8px;margin-top:6px}.btn{border:0;border-radius:6px;padding:8px 14px;font-size:13px;cursor:pointer;font-weight:500}.btn--secondary{background:var( --wpd-hover,rgba( 255,255,255,0.08 ) );color:inherit}.btn--secondary:hover{background:var( --wpd-hover,rgba( 255,255,255,0.14 ) )}.btn--primary{background:var( --wp-admin-theme-color,#2271b1 );color:var( --wpd-fg-on-accent,#fff )}.btn--primary:hover{filter:brightness( 1.08 )}.btn--danger{background:var( --wpd-danger,#d63638 );color:var( --wpd-fg-on-accent,#fff )}.btn--danger:hover{filter:brightness( 1.08 )}`,ue=class ue extends z{constructor(){super(...arguments),this._onKey=t=>{t.key==="Escape"&&(t.preventDefault(),this._cancel()),t.key==="Enter"&&!t.isComposing&&(t.preventDefault(),this._confirm())},this._onBackdrop=t=>{const n=t.composedPath();(n.length>0?n[0]:t.target)===this&&this._cancel()},this._confirm=()=>{this.emit("wpd-confirm",{confirmed:!0}),this.removeAttribute("open")},this._cancel=()=>{this.emit("wpd-cancel",{confirmed:!1}),this.removeAttribute("open")}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.addEventListener("keydown",this._onKey),this.addEventListener("click",this._onBackdrop)}disconnectedCallback(){this.removeEventListener("keydown",this._onKey),this.removeEventListener("click",this._onBackdrop)}render(){const t=this.title??"",n=this.message??"",o=this["confirm-label"]||"Confirm",s=this["cancel-label"]||"Cancel",i=this.hasAttribute("danger"),r=this.hasAttribute("hide-cancel"),l=this.hasAttribute("dismissable");return A`
90 + `}connectedCallback(){super.connectedCallback(),queueMicrotask(()=>this._paintSvg())}attributeChangedCallback(t,n,o){super.attributeChangedCallback(t,n,o),queueMicrotask(()=>this._paintSvg())}_paintSvg(){const t=this.shadowRoot;if(!t)return;const n=t.querySelector("svg"),o=t.querySelector("[data-svg-buffer]");if(n&&o){const i=o.textContent||"";n.innerHTML!==i&&(n.innerHTML=i)}}};Ee.props=["variant"],Ee.styles=[kl],Ee.help=void 0;let Wt=Ee;oe("os-tab-chip",Wt);const Tl={createWindow(e){return new It(e)}};window.openStationWindowSystem=Tl;const Il=x` ${Ge}:host{display:none;position:fixed;inset:0;align-items:center;justify-content:center;background:var( --os-ui-scrim,rgba( 0,0,0,0.45 ) );background-image:var( --os-ui-scrim-image,none );background-repeat:var( --os-ui-scrim-image-repeat,repeat );background-size:var( --os-ui-scrim-image-size,auto );background-position:var( --os-ui-scrim-image-position,center );backdrop-filter:blur( 2px );z-index:10000}:host( [ open ] ){display:flex;animation:os-confirm-scrim var( --_holo-t ) var( --_holo-ease )}:host( [ open ] ) .dialog{animation:os-confirm-dialog var( --_holo-t ) var( --_holo-spring )}@keyframes os-confirm-scrim{from{opacity:0}}@keyframes os-confirm-dialog{from{opacity:0;transform:scale( 0.96 ) translateY( 8px )}}@media ( prefers-reduced-motion:reduce ){:host( [ open ] ),:host( [ open ] ) .dialog{animation:none}}.dialog{width:min( 420px,92vw );background-color:var( --os-ui-confirm-dialog-bg,#1d2327 );background-image:var( --os-ui-dialog-bg-image,none );background-repeat:var( --os-ui-dialog-bg-image-repeat,repeat );background-size:var( --os-ui-dialog-bg-image-size,auto );background-position:var( --os-ui-dialog-bg-image-position,center );color:var( --os-ui-confirm-dialog-fg,var( --os-fg,#fff ) );border:1px solid var( --os-ui-border,rgba( 255,255,255,0.08 ) );border-radius:10px;box-shadow:0 20px 50px rgba( 0,0,0,0.6 );padding:20px 22px 18px;display:flex;flex-direction:column;gap:10px;position:relative}.close{position:absolute;top:8px;right:10px;width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;background:transparent;border:0;border-radius:6px;color:var( --os-ui-confirm-dialog-fg-muted,var( --os-ui-fg-muted,rgba( 255,255,255,0.7 ) ) );cursor:pointer;font-size:22px;line-height:1;padding:0}.close:hover{background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) );color:inherit}.btn:focus,.close:focus{outline:none;box-shadow:var( --_holo-focus )}.dialog:focus,.dialog:focus-visible{outline:none}.title{margin:0 0 4px;font-size:16px;font-weight:600}.message{margin:0;color:var( --os-ui-confirm-dialog-fg-muted,var( --os-ui-fg-muted,rgba( 255,255,255,0.7 ) ) );line-height:1.45;white-space:pre-line}.remember{display:flex;align-items:center;gap:8px;margin-top:4px;font-size:12px;color:var( --os-ui-confirm-dialog-fg-muted,var( --os-ui-fg-muted,rgba( 255,255,255,0.7 ) ) );cursor:pointer;user-select:none}.remember__box{margin:0;accent-color:var( --os-ui-accent,#2271b1 );cursor:pointer}.remember__box:focus,.remember__box:focus-visible{outline:none;box-shadow:var( --_holo-focus )}.actions{display:flex;justify-content:flex-end;gap:8px;margin-top:6px}.btn{border:0;border-radius:6px;padding:8px 14px;font-size:13px;cursor:pointer;font-weight:500}.btn--secondary{background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) );color:inherit}.btn--secondary:hover{background:var( --os-ui-hover,rgba( 255,255,255,0.14 ) )}.btn--primary{background:var( --wp-admin-theme-color,#2271b1 );color:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) )}.btn--primary:hover{filter:brightness( 1.08 )}.btn--danger{background:var( --os-ui-danger,#d63638 );color:var( --os-ui-fg-on-accent,#fff )}.btn--danger:hover{filter:brightness( 1.08 )}`,Do='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Ll(e){let t=e?.activeElement??null;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t&&t!==e?.body?t:null}function Wo(e){const t=e.composedPath(),n=t.length>0?t[0]:e.target;return n instanceof HTMLElement?n:null}function Mo(e){return e!==null&&e.matches(Do)}const Ae=class Ae extends K{constructor(){super(...arguments),this._prevFocus=null,this._focusTries=0,this._onKey=t=>{if(t.key==="Escape"){t.preventDefault(),this._cancel();return}if(t.key==="Tab"){this._trapTab(t);return}if(t.key==="Enter"&&!t.isComposing){if(Mo(Wo(t))||this.hasAttribute("danger"))return;t.preventDefault(),this._confirm()}},this._focusInitial=()=>{if(!this.hasAttribute("open"))return;const t=this.isConnected?this._initialFocusTarget():null;if(t){t.focus();return}if(this._focusTries++<5){queueMicrotask(this._focusInitial);return}this.isConnected&&this.focus()},this._onBackdrop=t=>{const n=t.composedPath();(n.length>0?n[0]:t.target)===this&&this._cancel()},this._confirm=()=>{this.emit("os-confirm",{confirmed:!0,remember:this._remembered()}),this.removeAttribute("open")},this._cancel=()=>{this.emit("os-cancel",{confirmed:!1}),this.removeAttribute("open")}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),this.addEventListener("keydown",this._onKey),this.addEventListener("click",this._onBackdrop)}disconnectedCallback(){this.removeEventListener("keydown",this._onKey),this.removeEventListener("click",this._onBackdrop),this._restoreFocus()}attributeChangedCallback(t,n,o){super.attributeChangedCallback(t,n,o),t==="open"&&(o!==null?(this._prevFocus=Ll(this.ownerDocument),this._focusTries=0,queueMicrotask(this._focusInitial)):this._restoreFocus())}_focusables(){const t=this.shadowRoot;return t?Array.from(t.querySelectorAll(Do)):[]}_trapTab(t){const n=this._focusables();if(n.length===0)return;const o=n[0],i=n[n.length-1],s=Wo(t),r=!Mo(s);t.shiftKey&&(r||s===o)?(t.preventDefault(),i.focus()):!t.shiftKey&&(r||s===i)&&(t.preventDefault(),o.focus())}_initialFocusTarget(){const t=this.shadowRoot;if(!t)return null;const n=t.querySelector(".btn--secondary"),o=t.querySelector(".dialog");return this.hasAttribute("danger")?n??t.querySelector(".close")??o:t.querySelector(".btn--primary, .btn--danger")??n??o}_restoreFocus(){const t=this._prevFocus;this._prevFocus=null,!(!t||!t.isConnected)&&t.focus()}_remembered(){return this.shadowRoot?.querySelector(".remember__box")?.checked===!0}render(){const t=this.title??"",n=this.message??"",o=this["confirm-label"]||"Confirm",i=this["cancel-label"]||"Cancel",s=this.hasAttribute("danger"),r=this.hasAttribute("hide-cancel"),d=this.hasAttribute("dismissable"),a=this["remember-label"]??"";return A`
81 91 <div class="dialog" tabindex="-1">
82 - ${l?A`<button
92 + ${d?A`<button
83 93 type="button"
84 94 class="close"
85 95 aria-label="Close"
86 96 @click=${()=>this._cancel()}
@@ -86,8 +96,12 @@
86 96 @click=${()=>this._cancel()}
87 97 >&times;</button>`:A``}
88 98 ${t?A`<h2 class="title">${t}</h2>`:A``}
89 99 ${n?A`<p class="message">${n}</p>`:A``}
100 + ${a?A`<label class="remember">
101 + <input type="checkbox" class="remember__box" />
102 + <span class="remember__label">${a}</span>
103 + </label>`:A``}
90 104 <div class="actions">
91 105 ${r?A``:A`<button
92 106 type="button"
93 107 class="btn btn--secondary"
@@ -92,13 +106,13 @@
92 106 type="button"
93 107 class="btn btn--secondary"
94 108 @click=${()=>this._cancel()}
95 109 >
96 - ${s}
110 + ${i}
97 111 </button>`}
98 112 <button
99 113 type="button"
100 - class="btn ${i?"btn--danger":"btn--primary"}"
114 + class="btn ${s?"btn--danger":"btn--primary"}"
101 115 @click=${()=>this._confirm()}
102 116 >
103 117 ${o}
104 118 </button>
@@ -103,5 +117,5 @@
103 117 ${o}
104 118 </button>
105 119 </div>
106 120 </div>
107 - `}};ue.props=["open","title","message","confirm-label","cancel-label","danger","hide-cancel","dismissable"],ue.styles=[hr],ue.help=void 0;let xe=ue;Y("wpd-confirm-dialog",xe);function mr(e){return new Promise(t=>{const n=document.createElement("wpd-confirm-dialog");n.setAttribute("open",""),e.title&&n.setAttribute("title",e.title),n.setAttribute("message",e.message),e.confirmLabel&&n.setAttribute("confirm-label",e.confirmLabel),e.cancelLabel&&n.setAttribute("cancel-label",e.cancelLabel),e.danger&&n.setAttribute("danger",""),e.hideCancel&&n.setAttribute("hide-cancel",""),e.dismissable&&n.setAttribute("dismissable","");const o=i=>{n.remove(),t(i)};n.addEventListener("wpd-confirm",()=>o(!0)),n.addEventListener("wpd-cancel",()=>o(!1)),document.body.appendChild(n),(n.shadowRoot?.querySelector(".dialog")??n).focus?.()})}const fr=Object.freeze(Object.defineProperty({__proto__:null,WpdConfirmDialog:xe,wpdConfirm:mr},Symbol.toStringTag,{value:"Module"}))})();
121 + `}};Ae.props=["open","title","message","confirm-label","cancel-label","danger","hide-cancel","dismissable","remember-label"],Ae.styles=[Il],Ae.help=void 0;let Be=Ae;oe("os-confirm-dialog",Be);function Nl(e){return new Promise(t=>{const n=document.createElement("os-confirm-dialog");n.setAttribute("open",""),e.title&&n.setAttribute("title",e.title),n.setAttribute("message",e.message),e.confirmLabel&&n.setAttribute("confirm-label",e.confirmLabel),e.cancelLabel&&n.setAttribute("cancel-label",e.cancelLabel),e.danger&&n.setAttribute("danger",""),e.hideCancel&&n.setAttribute("hide-cancel",""),e.dismissable&&n.setAttribute("dismissable",""),e.rememberLabel&&n.setAttribute("remember-label",e.rememberLabel);const o=i=>{n.remove(),t(i)};n.addEventListener("os-confirm",i=>{e.onRemember?.(i.detail?.remember===!0),o(!0)}),n.addEventListener("os-cancel",()=>o(!1)),document.body.appendChild(n)})}const Rl=Object.freeze(Object.defineProperty({__proto__:null,OsConfirmDialog:Be,osConfirm:Nl},Symbol.toStringTag,{value:"Module"}))})();